@clazic/kordoc 2.6.1 → 2.7.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.
- package/dist/{chunk-BZPZXI66.js → chunk-FZJLIDFL.js} +74 -26
- package/dist/chunk-FZJLIDFL.js.map +1 -0
- package/dist/{chunk-4X5JCZFZ.js → chunk-YIJCHZLO.js} +2 -2
- package/dist/cli.js +6 -6
- package/dist/index.cjs +191 -161
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +8 -2
- package/dist/index.d.ts +8 -2
- package/dist/index.js +192 -162
- package/dist/index.js.map +1 -1
- package/dist/mcp.js +2 -2
- package/dist/{utils-56QT5C33.js → utils-MAETCW66.js} +2 -2
- package/dist/{watch-HRNMJWSE.js → watch-6HVRALTX.js} +3 -3
- package/package.json +1 -1
- package/dist/chunk-BZPZXI66.js.map +0 -1
- /package/dist/{chunk-4X5JCZFZ.js.map → chunk-YIJCHZLO.js.map} +0 -0
- /package/dist/{utils-56QT5C33.js.map → utils-MAETCW66.js.map} +0 -0
- /package/dist/{watch-HRNMJWSE.js.map → watch-6HVRALTX.js.map} +0 -0
|
@@ -7,7 +7,7 @@ import {
|
|
|
7
7
|
precheckZipSize,
|
|
8
8
|
sanitizeHref,
|
|
9
9
|
toArrayBuffer
|
|
10
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-YIJCHZLO.js";
|
|
11
11
|
import {
|
|
12
12
|
parsePageRange
|
|
13
13
|
} from "./chunk-MOL7MDBG.js";
|
|
@@ -9842,6 +9842,7 @@ import { join as join2, delimiter } from "path";
|
|
|
9842
9842
|
import { mkdir, access, symlink, rm } from "fs/promises";
|
|
9843
9843
|
import { createWriteStream } from "fs";
|
|
9844
9844
|
import { spawn } from "child_process";
|
|
9845
|
+
var installInFlight = null;
|
|
9845
9846
|
var CACHE_DIR = join2(homedir(), ".cache", "kordoc", "libreoffice");
|
|
9846
9847
|
var VERSION_FILE = join2(CACHE_DIR, "version");
|
|
9847
9848
|
var PACKAGES = {
|
|
@@ -9862,13 +9863,11 @@ var PACKAGES = {
|
|
|
9862
9863
|
}
|
|
9863
9864
|
};
|
|
9864
9865
|
async function findInPath() {
|
|
9865
|
-
|
|
9866
|
-
const
|
|
9867
|
-
|
|
9868
|
-
|
|
9869
|
-
}
|
|
9870
|
-
return null;
|
|
9871
|
-
}
|
|
9866
|
+
return new Promise((resolve2) => {
|
|
9867
|
+
const child = spawn("soffice", ["--version"], { stdio: "ignore" });
|
|
9868
|
+
child.on("close", (code) => resolve2(code === 0 ? "soffice" : null));
|
|
9869
|
+
child.on("error", () => resolve2(null));
|
|
9870
|
+
});
|
|
9872
9871
|
}
|
|
9873
9872
|
async function findInCache() {
|
|
9874
9873
|
const cachedBin = join2(CACHE_DIR, "bin", "soffice");
|
|
@@ -9879,6 +9878,38 @@ async function findInCache() {
|
|
|
9879
9878
|
return null;
|
|
9880
9879
|
}
|
|
9881
9880
|
}
|
|
9881
|
+
async function findInDefaultPaths() {
|
|
9882
|
+
const platform = process.platform;
|
|
9883
|
+
const paths = [];
|
|
9884
|
+
if (platform === "darwin") {
|
|
9885
|
+
paths.push(
|
|
9886
|
+
"/Applications/LibreOffice.app/Contents/MacOS/soffice",
|
|
9887
|
+
"/opt/homebrew/bin/soffice",
|
|
9888
|
+
"/usr/local/bin/soffice"
|
|
9889
|
+
);
|
|
9890
|
+
} else if (platform === "linux") {
|
|
9891
|
+
paths.push(
|
|
9892
|
+
"/usr/bin/soffice",
|
|
9893
|
+
"/usr/lib/libreoffice/program/soffice"
|
|
9894
|
+
);
|
|
9895
|
+
} else if (platform === "win32") {
|
|
9896
|
+
const pf = process.env["ProgramFiles"] ?? "C:\\Program Files";
|
|
9897
|
+
const pf86 = process.env["ProgramFiles(x86)"] ?? "C:\\Program Files (x86)";
|
|
9898
|
+
paths.push(
|
|
9899
|
+
join2(pf, "LibreOffice", "program", "soffice.exe"),
|
|
9900
|
+
join2(pf86, "LibreOffice", "program", "soffice.exe")
|
|
9901
|
+
);
|
|
9902
|
+
}
|
|
9903
|
+
for (const p of paths) {
|
|
9904
|
+
try {
|
|
9905
|
+
await access(p);
|
|
9906
|
+
return p;
|
|
9907
|
+
} catch {
|
|
9908
|
+
continue;
|
|
9909
|
+
}
|
|
9910
|
+
}
|
|
9911
|
+
return null;
|
|
9912
|
+
}
|
|
9882
9913
|
async function downloadWithProgress(url, dest, totalBytes, onProgress) {
|
|
9883
9914
|
const response = await fetch(url);
|
|
9884
9915
|
if (!response.body) throw new Error("\uB2E4\uC6B4\uB85C\uB4DC \uC2E4\uD328: response body \uC5C6\uC74C");
|
|
@@ -9889,13 +9920,17 @@ async function downloadWithProgress(url, dest, totalBytes, onProgress) {
|
|
|
9889
9920
|
while (true) {
|
|
9890
9921
|
const { done, value } = await reader.read();
|
|
9891
9922
|
if (done) break;
|
|
9892
|
-
file.write(value)
|
|
9923
|
+
if (!file.write(value)) {
|
|
9924
|
+
await new Promise((resolve2) => file.once("drain", resolve2));
|
|
9925
|
+
}
|
|
9893
9926
|
downloaded += value.length;
|
|
9894
9927
|
onProgress?.(downloaded, totalBytes);
|
|
9895
9928
|
}
|
|
9896
9929
|
} finally {
|
|
9897
|
-
file.end();
|
|
9898
9930
|
reader.releaseLock();
|
|
9931
|
+
await new Promise((resolve2, reject) => {
|
|
9932
|
+
file.end((err) => err ? reject(err) : resolve2());
|
|
9933
|
+
});
|
|
9899
9934
|
}
|
|
9900
9935
|
}
|
|
9901
9936
|
async function installForPlatform(pkg, onProgress) {
|
|
@@ -10006,6 +10041,11 @@ async function resolveSoffice(emitter, autoInstall = true) {
|
|
|
10006
10041
|
emitter.validate("soffice_found", "\uCE90\uC2DC\uB41C LibreOffice \uBC1C\uACAC", { sofficePath: inCache });
|
|
10007
10042
|
return inCache;
|
|
10008
10043
|
}
|
|
10044
|
+
const inDefault = await findInDefaultPaths();
|
|
10045
|
+
if (inDefault) {
|
|
10046
|
+
emitter.validate("soffice_found", "\uAE30\uBCF8 \uACBD\uB85C\uC5D0\uC11C LibreOffice \uBC1C\uACAC", { sofficePath: inDefault });
|
|
10047
|
+
return inDefault;
|
|
10048
|
+
}
|
|
10009
10049
|
if (!autoInstall) {
|
|
10010
10050
|
emitter.error(
|
|
10011
10051
|
"validate",
|
|
@@ -10015,23 +10055,31 @@ async function resolveSoffice(emitter, autoInstall = true) {
|
|
|
10015
10055
|
);
|
|
10016
10056
|
throw new ConvertError("SOFFICE_NOT_FOUND", "LibreOffice\uAC00 \uC124\uCE58\uB418\uC9C0 \uC54A\uC558\uC2B5\uB2C8\uB2E4");
|
|
10017
10057
|
}
|
|
10058
|
+
if (installInFlight) {
|
|
10059
|
+
return installInFlight;
|
|
10060
|
+
}
|
|
10018
10061
|
emitter.install("install_start", "LibreOffice \uC790\uB3D9 \uC124\uCE58\uB97C \uC2DC\uC791\uD569\uB2C8\uB2E4...");
|
|
10019
|
-
|
|
10020
|
-
|
|
10021
|
-
const
|
|
10022
|
-
|
|
10023
|
-
percent
|
|
10024
|
-
|
|
10025
|
-
|
|
10062
|
+
installInFlight = (async () => {
|
|
10063
|
+
try {
|
|
10064
|
+
const installed = await installLibreOffice((downloaded, total) => {
|
|
10065
|
+
const percent = Math.round(downloaded / total * 100);
|
|
10066
|
+
emitter.install("download_progress", `\uB2E4\uC6B4\uB85C\uB4DC \uC911... ${percent}%`, {
|
|
10067
|
+
percent,
|
|
10068
|
+
downloadedBytes: downloaded,
|
|
10069
|
+
totalBytes: total
|
|
10070
|
+
});
|
|
10026
10071
|
});
|
|
10027
|
-
|
|
10028
|
-
|
|
10029
|
-
|
|
10030
|
-
|
|
10031
|
-
|
|
10032
|
-
|
|
10033
|
-
|
|
10034
|
-
|
|
10072
|
+
emitter.install("install_complete", "\uC124\uCE58 \uC644\uB8CC", { installedPath: installed });
|
|
10073
|
+
return installed;
|
|
10074
|
+
} catch (err) {
|
|
10075
|
+
const errorMsg = err instanceof Error ? err.message : String(err);
|
|
10076
|
+
emitter.install("install_failed", "\uC124\uCE58 \uC2E4\uD328", { error: errorMsg });
|
|
10077
|
+
throw err;
|
|
10078
|
+
} finally {
|
|
10079
|
+
installInFlight = null;
|
|
10080
|
+
}
|
|
10081
|
+
})();
|
|
10082
|
+
return installInFlight;
|
|
10035
10083
|
}
|
|
10036
10084
|
|
|
10037
10085
|
// src/convert/libreoffice.ts
|
|
@@ -10641,4 +10689,4 @@ export {
|
|
|
10641
10689
|
cfb/cfb.js:
|
|
10642
10690
|
(*! crc32.js (C) 2014-present SheetJS -- http://sheetjs.com *)
|
|
10643
10691
|
*/
|
|
10644
|
-
//# sourceMappingURL=chunk-
|
|
10692
|
+
//# sourceMappingURL=chunk-FZJLIDFL.js.map
|