@clazic/kordoc 2.4.9 → 2.4.11
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/{batch-provider-VX7CY6UH.js → batch-provider-5BFJRKAZ.js} +15 -4
- package/dist/{batch-provider-VX7CY6UH.js.map → batch-provider-5BFJRKAZ.js.map} +1 -1
- package/dist/{chunk-YC2MEB7R.js → chunk-34WIGIQC.js} +16 -5
- package/dist/chunk-34WIGIQC.js.map +1 -0
- package/dist/{chunk-MPMKWVV2.js → chunk-JGMLDBW5.js} +4 -4
- package/dist/{chunk-SHM3PYVA.js → chunk-PJSXZBZB.js} +2 -2
- package/dist/{chunk-SHM3PYVA.js.map → chunk-PJSXZBZB.js.map} +1 -1
- package/dist/cli.js +6 -6
- package/dist/index.cjs +30 -8
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +30 -8
- package/dist/index.js.map +1 -1
- package/dist/mcp.js +3 -3
- package/dist/{resolve-BGOGWG6E.js → resolve-4I65IGMM.js} +4 -4
- package/dist/{utils-IUWGWQWV.js → utils-HKVOS2O3.js} +2 -2
- package/dist/{watch-CRENPZU5.js → watch-EYOGF3HY.js} +4 -4
- package/package.json +1 -1
- package/dist/chunk-YC2MEB7R.js.map +0 -1
- /package/dist/{chunk-MPMKWVV2.js.map → chunk-JGMLDBW5.js.map} +0 -0
- /package/dist/{resolve-BGOGWG6E.js.map → resolve-4I65IGMM.js.map} +0 -0
- /package/dist/{utils-IUWGWQWV.js.map → utils-HKVOS2O3.js.map} +0 -0
- /package/dist/{watch-CRENPZU5.js.map → watch-EYOGF3HY.js.map} +0 -0
package/dist/index.js
CHANGED
|
@@ -2034,7 +2034,7 @@ import { join } from "path";
|
|
|
2034
2034
|
import { tmpdir } from "os";
|
|
2035
2035
|
function getTempDir() {
|
|
2036
2036
|
if (!_tempDir) {
|
|
2037
|
-
_tempDir = join(process.cwd(), "
|
|
2037
|
+
_tempDir = join(process.cwd(), ".kordoc_ocr_tmp");
|
|
2038
2038
|
mkdirSync(_tempDir, { recursive: true });
|
|
2039
2039
|
}
|
|
2040
2040
|
return _tempDir;
|
|
@@ -2059,6 +2059,12 @@ function createCliOcrProvider(mode) {
|
|
|
2059
2059
|
}
|
|
2060
2060
|
};
|
|
2061
2061
|
}
|
|
2062
|
+
function checkForLimitError(output, mode) {
|
|
2063
|
+
const lower = output.toLowerCase();
|
|
2064
|
+
if (lower.includes("usage limit") || lower.includes("rate limit")) {
|
|
2065
|
+
throw new Error(`${mode} \uC0AC\uC6A9\uB7C9/\uC18D\uB3C4 \uC81C\uD55C: ${output.trim().slice(0, 200)}`);
|
|
2066
|
+
}
|
|
2067
|
+
}
|
|
2062
2068
|
function callCli(mode, imagePath) {
|
|
2063
2069
|
if (mode === "codex") {
|
|
2064
2070
|
return callCodexCli(imagePath);
|
|
@@ -2079,7 +2085,9 @@ function callCli(mode, imagePath) {
|
|
|
2079
2085
|
const errMsg = result.stderr?.trim() || `exit code ${result.status}`;
|
|
2080
2086
|
throw new Error(`${mode} OCR \uC2E4\uD328: ${errMsg}`);
|
|
2081
2087
|
}
|
|
2082
|
-
|
|
2088
|
+
const output = result.stdout || "";
|
|
2089
|
+
checkForLimitError(output, mode);
|
|
2090
|
+
return output;
|
|
2083
2091
|
}
|
|
2084
2092
|
function callCodexCli(imagePath) {
|
|
2085
2093
|
const outPath = join(tmpdir(), `kordoc-codex-out-${Date.now()}.txt`);
|
|
@@ -2102,11 +2110,14 @@ function callCodexCli(imagePath) {
|
|
|
2102
2110
|
const errMsg = result.stderr?.trim() || `exit code ${result.status}`;
|
|
2103
2111
|
throw new Error(`codex OCR \uC2E4\uD328: ${errMsg}`);
|
|
2104
2112
|
}
|
|
2113
|
+
let text;
|
|
2105
2114
|
try {
|
|
2106
|
-
|
|
2115
|
+
text = readFileSync(outPath, "utf-8");
|
|
2107
2116
|
} catch {
|
|
2108
|
-
|
|
2117
|
+
text = result.stdout || "";
|
|
2109
2118
|
}
|
|
2119
|
+
checkForLimitError(text, "codex");
|
|
2120
|
+
return text;
|
|
2110
2121
|
} finally {
|
|
2111
2122
|
try {
|
|
2112
2123
|
unlinkSync(outPath);
|
|
@@ -2374,7 +2385,9 @@ ${fileRefs}`;
|
|
|
2374
2385
|
const errMsg = result.stderr?.trim() || `exit code ${result.exitCode}`;
|
|
2375
2386
|
throw new Error(`${mode} \uBC30\uCE58 OCR \uC2E4\uD328: ${errMsg}`);
|
|
2376
2387
|
}
|
|
2377
|
-
|
|
2388
|
+
const output = result.stdout || "";
|
|
2389
|
+
checkForLimitError2(output, mode);
|
|
2390
|
+
return output;
|
|
2378
2391
|
}
|
|
2379
2392
|
async function callBatchCodexCli(imagePaths) {
|
|
2380
2393
|
const outPath = join2(tmpdir2(), `kordoc-codex-batch-${Date.now()}-${Math.random().toString(36).slice(2)}.txt`);
|
|
@@ -2395,11 +2408,14 @@ async function callBatchCodexCli(imagePaths) {
|
|
|
2395
2408
|
const errMsg = result.stderr?.trim() || `exit code ${result.exitCode}`;
|
|
2396
2409
|
throw new Error(`codex \uBC30\uCE58 OCR \uC2E4\uD328: ${errMsg}`);
|
|
2397
2410
|
}
|
|
2411
|
+
let text;
|
|
2398
2412
|
try {
|
|
2399
|
-
|
|
2413
|
+
text = readFileSync2(outPath, "utf-8");
|
|
2400
2414
|
} catch {
|
|
2401
|
-
|
|
2415
|
+
text = result.stdout || "";
|
|
2402
2416
|
}
|
|
2417
|
+
checkForLimitError2(text, "codex");
|
|
2418
|
+
return text;
|
|
2403
2419
|
} finally {
|
|
2404
2420
|
try {
|
|
2405
2421
|
unlinkSync2(outPath);
|
|
@@ -2407,6 +2423,12 @@ async function callBatchCodexCli(imagePaths) {
|
|
|
2407
2423
|
}
|
|
2408
2424
|
}
|
|
2409
2425
|
}
|
|
2426
|
+
function checkForLimitError2(output, mode) {
|
|
2427
|
+
const lower = output.toLowerCase();
|
|
2428
|
+
if (lower.includes("usage limit") || lower.includes("rate limit")) {
|
|
2429
|
+
throw new Error(`${mode} \uC0AC\uC6A9\uB7C9/\uC18D\uB3C4 \uC81C\uD55C: ${output.trim().slice(0, 200)}`);
|
|
2430
|
+
}
|
|
2431
|
+
}
|
|
2410
2432
|
function stripCodeFence2(text) {
|
|
2411
2433
|
const match = text.match(/^```(?:markdown|md)?\s*\n([\s\S]*?)\n```\s*$/m);
|
|
2412
2434
|
return match ? match[1].trim() : text;
|
|
@@ -2834,7 +2856,7 @@ import JSZip2 from "jszip";
|
|
|
2834
2856
|
import { DOMParser } from "@xmldom/xmldom";
|
|
2835
2857
|
|
|
2836
2858
|
// src/utils.ts
|
|
2837
|
-
var VERSION = true ? "2.4.
|
|
2859
|
+
var VERSION = true ? "2.4.11" : "0.0.0-dev";
|
|
2838
2860
|
function toArrayBuffer(buf) {
|
|
2839
2861
|
if (buf.byteOffset === 0 && buf.byteLength === buf.buffer.byteLength) {
|
|
2840
2862
|
return buf.buffer;
|