@clazic/kordoc 2.6.1 → 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/{chunk-BZPZXI66.js → chunk-3FTA6V7S.js} +68 -24
- package/dist/chunk-3FTA6V7S.js.map +1 -0
- package/dist/{chunk-4X5JCZFZ.js → chunk-USE7IDLV.js} +2 -2
- package/dist/cli.js +6 -6
- package/dist/index.cjs +185 -159
- 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 +186 -160
- package/dist/index.js.map +1 -1
- package/dist/mcp.js +2 -2
- package/dist/{utils-56QT5C33.js → utils-XYBJBWM2.js} +2 -2
- package/dist/{watch-HRNMJWSE.js → watch-CJRS6OYE.js} +3 -3
- package/package.json +1 -1
- package/dist/chunk-BZPZXI66.js.map +0 -1
- /package/dist/{chunk-4X5JCZFZ.js.map → chunk-USE7IDLV.js.map} +0 -0
- /package/dist/{utils-56QT5C33.js.map → utils-XYBJBWM2.js.map} +0 -0
- /package/dist/{watch-HRNMJWSE.js.map → watch-CJRS6OYE.js.map} +0 -0
|
@@ -7,7 +7,7 @@ import {
|
|
|
7
7
|
precheckZipSize,
|
|
8
8
|
sanitizeHref,
|
|
9
9
|
toArrayBuffer
|
|
10
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-USE7IDLV.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");
|
|
@@ -10006,6 +10037,11 @@ async function resolveSoffice(emitter, autoInstall = true) {
|
|
|
10006
10037
|
emitter.validate("soffice_found", "\uCE90\uC2DC\uB41C LibreOffice \uBC1C\uACAC", { sofficePath: inCache });
|
|
10007
10038
|
return inCache;
|
|
10008
10039
|
}
|
|
10040
|
+
const inDefault = await findInDefaultPaths();
|
|
10041
|
+
if (inDefault) {
|
|
10042
|
+
emitter.validate("soffice_found", "\uAE30\uBCF8 \uACBD\uB85C\uC5D0\uC11C LibreOffice \uBC1C\uACAC", { sofficePath: inDefault });
|
|
10043
|
+
return inDefault;
|
|
10044
|
+
}
|
|
10009
10045
|
if (!autoInstall) {
|
|
10010
10046
|
emitter.error(
|
|
10011
10047
|
"validate",
|
|
@@ -10015,23 +10051,31 @@ async function resolveSoffice(emitter, autoInstall = true) {
|
|
|
10015
10051
|
);
|
|
10016
10052
|
throw new ConvertError("SOFFICE_NOT_FOUND", "LibreOffice\uAC00 \uC124\uCE58\uB418\uC9C0 \uC54A\uC558\uC2B5\uB2C8\uB2E4");
|
|
10017
10053
|
}
|
|
10054
|
+
if (installInFlight) {
|
|
10055
|
+
return installInFlight;
|
|
10056
|
+
}
|
|
10018
10057
|
emitter.install("install_start", "LibreOffice \uC790\uB3D9 \uC124\uCE58\uB97C \uC2DC\uC791\uD569\uB2C8\uB2E4...");
|
|
10019
|
-
|
|
10020
|
-
|
|
10021
|
-
const
|
|
10022
|
-
|
|
10023
|
-
percent
|
|
10024
|
-
|
|
10025
|
-
|
|
10058
|
+
installInFlight = (async () => {
|
|
10059
|
+
try {
|
|
10060
|
+
const installed = await installLibreOffice((downloaded, total) => {
|
|
10061
|
+
const percent = Math.round(downloaded / total * 100);
|
|
10062
|
+
emitter.install("download_progress", `\uB2E4\uC6B4\uB85C\uB4DC \uC911... ${percent}%`, {
|
|
10063
|
+
percent,
|
|
10064
|
+
downloadedBytes: downloaded,
|
|
10065
|
+
totalBytes: total
|
|
10066
|
+
});
|
|
10026
10067
|
});
|
|
10027
|
-
|
|
10028
|
-
|
|
10029
|
-
|
|
10030
|
-
|
|
10031
|
-
|
|
10032
|
-
|
|
10033
|
-
|
|
10034
|
-
|
|
10068
|
+
emitter.install("install_complete", "\uC124\uCE58 \uC644\uB8CC", { installedPath: installed });
|
|
10069
|
+
return installed;
|
|
10070
|
+
} catch (err) {
|
|
10071
|
+
const errorMsg = err instanceof Error ? err.message : String(err);
|
|
10072
|
+
emitter.install("install_failed", "\uC124\uCE58 \uC2E4\uD328", { error: errorMsg });
|
|
10073
|
+
throw err;
|
|
10074
|
+
} finally {
|
|
10075
|
+
installInFlight = null;
|
|
10076
|
+
}
|
|
10077
|
+
})();
|
|
10078
|
+
return installInFlight;
|
|
10035
10079
|
}
|
|
10036
10080
|
|
|
10037
10081
|
// src/convert/libreoffice.ts
|
|
@@ -10641,4 +10685,4 @@ export {
|
|
|
10641
10685
|
cfb/cfb.js:
|
|
10642
10686
|
(*! crc32.js (C) 2014-present SheetJS -- http://sheetjs.com *)
|
|
10643
10687
|
*/
|
|
10644
|
-
//# sourceMappingURL=chunk-
|
|
10688
|
+
//# sourceMappingURL=chunk-3FTA6V7S.js.map
|