@clazic/kordoc 2.4.12 → 2.4.13
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/{chunk-KJEZPVEK.js → chunk-UX75CBUO.js} +1 -1
- package/dist/{chunk-KJEZPVEK.js.map → chunk-UX75CBUO.js.map} +1 -1
- package/dist/cli.js +2 -2
- package/dist/index.cjs +32 -10
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +32 -10
- package/dist/index.js.map +1 -1
- package/dist/mcp.js +1 -1
- package/dist/{watch-SOMS2KR7.js → watch-3MTAXFEA.js} +2 -2
- package/package.json +1 -1
- /package/dist/{watch-SOMS2KR7.js.map → watch-3MTAXFEA.js.map} +0 -0
package/dist/cli.js
CHANGED
|
@@ -4,7 +4,7 @@ import {
|
|
|
4
4
|
markdownToHwpx,
|
|
5
5
|
markdownToXlsx,
|
|
6
6
|
parse
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-UX75CBUO.js";
|
|
8
8
|
import "./chunk-YW5G6BCJ.js";
|
|
9
9
|
import {
|
|
10
10
|
VERSION,
|
|
@@ -291,7 +291,7 @@ program.command("init-env").description("kordoc\uC6A9 .env \uD15C\uD50C\uB9BF \u
|
|
|
291
291
|
}
|
|
292
292
|
});
|
|
293
293
|
program.command("watch <dir>").description("\uB514\uB809\uD1A0\uB9AC \uAC10\uC2DC \u2014 \uC0C8 \uBB38\uC11C \uC790\uB3D9 \uBCC0\uD658").option("--webhook <url>", "\uACB0\uACFC \uC804\uC1A1 \uC6F9\uD6C5 URL").option("-d, --out-dir <dir>", "\uBCC0\uD658 \uACB0\uACFC \uCD9C\uB825 \uB514\uB809\uD1A0\uB9AC").option("-p, --pages <range>", "\uD398\uC774\uC9C0/\uC139\uC158 \uBC94\uC704").option("--format <type>", "\uCD9C\uB825 \uD615\uC2DD: markdown \uB610\uB294 json", "markdown").option("--silent", "\uC9C4\uD589 \uBA54\uC2DC\uC9C0 \uC228\uAE30\uAE30").action(async (dir, opts) => {
|
|
294
|
-
const { watchDirectory } = await import("./watch-
|
|
294
|
+
const { watchDirectory } = await import("./watch-3MTAXFEA.js");
|
|
295
295
|
await watchDirectory({
|
|
296
296
|
dir,
|
|
297
297
|
outDir: opts.outDir,
|
package/dist/index.cjs
CHANGED
|
@@ -11396,6 +11396,7 @@ async function runUnifiedOcrPipeline(inputPath, options = {}) {
|
|
|
11396
11396
|
const maxRetriesPerPage = options.maxRetriesPerPage ?? 5;
|
|
11397
11397
|
const dpi = options.dpi ?? 300;
|
|
11398
11398
|
const modelsInput = options.modelCandidates?.length ? options.modelCandidates : DEFAULT_MODELS;
|
|
11399
|
+
const probeConcurrency = Math.max(1, Math.floor(options.probeConcurrency ?? Math.min(3, modelsInput.length)));
|
|
11399
11400
|
const modelCache = await loadModelCache(modelCachePath);
|
|
11400
11401
|
const models = sortModelsByCache(modelsInput, modelCache);
|
|
11401
11402
|
const modelMaxTokens = { ...DEFAULT_MODEL_MAX_TOKENS, ...options.modelMaxTokens ?? {} };
|
|
@@ -11446,11 +11447,10 @@ async function runUnifiedOcrPipeline(inputPath, options = {}) {
|
|
|
11446
11447
|
const probeStart = Date.now();
|
|
11447
11448
|
currentStage = "probe";
|
|
11448
11449
|
markStageStart("probe", "\uBAA8\uB378 \uC18D\uB3C4 \uD504\uB85C\uBE0C \uC218\uD589 \uC911");
|
|
11449
|
-
logStage("info", "probe", "start", "\uBAA8\uB378 \uC18D\uB3C4 \uD504\uB85C\uBE0C \uC2DC\uC791", { models });
|
|
11450
|
+
logStage("info", "probe", "start", "\uBAA8\uB378 \uC18D\uB3C4 \uD504\uB85C\uBE0C \uC2DC\uC791", { models, probeConcurrency });
|
|
11450
11451
|
const probeImage = await pickRepresentativeImage(images);
|
|
11451
|
-
|
|
11452
|
-
|
|
11453
|
-
const model = models[i];
|
|
11452
|
+
let probeDone = 0;
|
|
11453
|
+
const probeResultsByIndex = await mapWithConcurrency(models, probeConcurrency, async (model, index) => {
|
|
11454
11454
|
const t0 = Date.now();
|
|
11455
11455
|
try {
|
|
11456
11456
|
await ocrImageViaNim({
|
|
@@ -11465,18 +11465,25 @@ async function runUnifiedOcrPipeline(inputPath, options = {}) {
|
|
|
11465
11465
|
logger,
|
|
11466
11466
|
stage: "probe"
|
|
11467
11467
|
});
|
|
11468
|
-
|
|
11468
|
+
const result = { model, durationMs: Date.now() - t0, success: true };
|
|
11469
|
+
probeDone += 1;
|
|
11470
|
+
markStageProgress("probe", Math.round(probeDone / models.length * 100), probeDone, models.length, `\uBAA8\uB378 \uD504\uB85C\uBE0C ${probeDone}/${models.length}`);
|
|
11471
|
+
logStage("debug", "probe", "progress", "\uBAA8\uB378 \uD504\uB85C\uBE0C \uC9C4\uD589", { index: index + 1, total: models.length, model, result });
|
|
11472
|
+
return result;
|
|
11469
11473
|
} catch (err) {
|
|
11470
|
-
|
|
11474
|
+
const result = {
|
|
11471
11475
|
model,
|
|
11472
11476
|
durationMs: Date.now() - t0,
|
|
11473
11477
|
success: false,
|
|
11474
11478
|
error: err instanceof Error ? err.message : String(err)
|
|
11475
|
-
}
|
|
11479
|
+
};
|
|
11480
|
+
probeDone += 1;
|
|
11481
|
+
markStageProgress("probe", Math.round(probeDone / models.length * 100), probeDone, models.length, `\uBAA8\uB378 \uD504\uB85C\uBE0C ${probeDone}/${models.length}`);
|
|
11482
|
+
logStage("debug", "probe", "progress", "\uBAA8\uB378 \uD504\uB85C\uBE0C \uC9C4\uD589", { index: index + 1, total: models.length, model, result });
|
|
11483
|
+
return result;
|
|
11476
11484
|
}
|
|
11477
|
-
|
|
11478
|
-
|
|
11479
|
-
}
|
|
11485
|
+
});
|
|
11486
|
+
const probeResults = probeResultsByIndex;
|
|
11480
11487
|
const selectedModel = chooseFastestModel(probeResults);
|
|
11481
11488
|
if (!selectedModel) throw new UnifiedOcrError("PROBE_FAILED", "probe", "\uC18D\uB3C4 \uD504\uB85C\uBE0C \uC2E4\uD328: \uC0AC\uC6A9 \uAC00\uB2A5\uD55C OCR \uBAA8\uB378\uC774 \uC5C6\uC2B5\uB2C8\uB2E4.");
|
|
11482
11489
|
const fallbackModelOrder = probeResults.filter((r) => r.success).sort((a, b) => a.durationMs - b.durationMs).map((r) => r.model);
|
|
@@ -11691,6 +11698,21 @@ async function pickRepresentativeImage(images) {
|
|
|
11691
11698
|
use.sort((a, b) => a.size - b.size);
|
|
11692
11699
|
return use[Math.floor(use.length / 2)].path;
|
|
11693
11700
|
}
|
|
11701
|
+
async function mapWithConcurrency(items, concurrency, mapper) {
|
|
11702
|
+
const results = new Array(items.length);
|
|
11703
|
+
let nextIndex = 0;
|
|
11704
|
+
async function worker() {
|
|
11705
|
+
while (true) {
|
|
11706
|
+
const idx = nextIndex;
|
|
11707
|
+
if (idx >= items.length) return;
|
|
11708
|
+
nextIndex += 1;
|
|
11709
|
+
results[idx] = await mapper(items[idx], idx);
|
|
11710
|
+
}
|
|
11711
|
+
}
|
|
11712
|
+
const workerCount = Math.max(1, Math.min(concurrency, items.length));
|
|
11713
|
+
await Promise.all(Array.from({ length: workerCount }, () => worker()));
|
|
11714
|
+
return results;
|
|
11715
|
+
}
|
|
11694
11716
|
function chooseFastestModel(results) {
|
|
11695
11717
|
const ok = results.filter((r) => r.success).sort((a, b) => a.durationMs - b.durationMs);
|
|
11696
11718
|
return ok[0]?.model ?? null;
|