feat: 内置 Desktop Pandoc 最小运行时

This commit is contained in:
SkyJourney
2026-08-02 10:44:40 +08:00
parent 9a2aa3c341
commit 3a8d2c1c2e
16 changed files with 636 additions and 46 deletions
@@ -1,4 +1,5 @@
import { DOCX_PANDOC_VERSION } from "@md-to-pdf/core";
import runtimeManifest from "./pandoc-runtime.json" with { type: "json" };
export interface PandocRuntimeArtifact {
platform: "win32" | "linux";
@@ -8,39 +9,23 @@ export interface PandocRuntimeArtifact {
sha256: string;
executableRelativePath: string;
licenseFiles: readonly string[];
files?: Readonly<
Record<string, { bytes: number; sha256: string }>
>;
}
export const pandocRuntimeManifest = {
version: DOCX_PANDOC_VERSION,
license: "GPL-2.0-or-later",
projectUrl: "https://pandoc.org/",
sourceArchiveUrl:
"https://github.com/jgm/pandoc/releases/download/3.9.0.2/pandoc-3.9.0.2-source.tar.gz",
artifacts: [
{
platform: "win32",
architecture: "x64",
archiveType: "zip",
downloadUrl:
"https://github.com/jgm/pandoc/releases/download/3.9.0.2/pandoc-3.9.0.2-windows-x86_64.zip",
sha256:
"C97542F2800F446E788D9F74237856D995421AD1BB3CC8324286840C5F272D3A",
executableRelativePath: "pandoc.exe",
licenseFiles: ["COPYING.rtf", "COPYRIGHT.txt"]
},
{
platform: "linux",
architecture: "x64",
archiveType: "tar.gz",
downloadUrl:
"https://github.com/jgm/pandoc/releases/download/3.9.0.2/pandoc-3.9.0.2-linux-amd64.tar.gz",
sha256:
"A69ABFABABDA8A56969A254B09F9553A7BE89DDEC00D4E0FE9FD585D71A67508",
executableRelativePath: "bin/pandoc",
licenseFiles: ["COPYING.md", "COPYRIGHT"]
}
] satisfies readonly PandocRuntimeArtifact[]
} as const;
if (runtimeManifest.version !== DOCX_PANDOC_VERSION) {
throw new Error(
`Pandoc 运行时清单版本 ${runtimeManifest.version} 与 DOCX 协议版本 ${DOCX_PANDOC_VERSION} 不一致`
);
}
export const pandocRuntimeManifest = runtimeManifest as Omit<
typeof runtimeManifest,
"artifacts"
> & {
artifacts: readonly PandocRuntimeArtifact[];
};
export function findPandocRuntimeArtifact(
platform: NodeJS.Platform,
@@ -0,0 +1,40 @@
{
"version": "3.9.0.2",
"license": "GPL-2.0-or-later",
"projectUrl": "https://pandoc.org/",
"sourceArchiveUrl": "https://github.com/jgm/pandoc/releases/download/3.9.0.2/pandoc-3.9.0.2-source.tar.gz",
"artifacts": [
{
"platform": "win32",
"architecture": "x64",
"archiveType": "zip",
"downloadUrl": "https://github.com/jgm/pandoc/releases/download/3.9.0.2/pandoc-3.9.0.2-windows-x86_64.zip",
"sha256": "C97542F2800F446E788D9F74237856D995421AD1BB3CC8324286840C5F272D3A",
"executableRelativePath": "pandoc.exe",
"licenseFiles": ["COPYING.rtf", "COPYRIGHT.txt"],
"files": {
"pandoc.exe": {
"bytes": 231056136,
"sha256": "E83F8354C0F507222B5684797B9C5AE766F03889785995D14AAC27816EC456BA"
},
"COPYING.rtf": {
"bytes": 20401,
"sha256": "DA9A2C9D0C3A3327D18684635424A13CDA9FC65D406A0FFC40AE8D016B476669"
},
"COPYRIGHT.txt": {
"bytes": 9823,
"sha256": "43575D901FD50CC06F49042B82F114667A82C17D63B429E99635AE9430C977C4"
}
}
},
{
"platform": "linux",
"architecture": "x64",
"archiveType": "tar.gz",
"downloadUrl": "https://github.com/jgm/pandoc/releases/download/3.9.0.2/pandoc-3.9.0.2-linux-amd64.tar.gz",
"sha256": "A69ABFABABDA8A56969A254B09F9553A7BE89DDEC00D4E0FE9FD585D71A67508",
"executableRelativePath": "bin/pandoc",
"licenseFiles": ["COPYING.md", "COPYRIGHT"]
}
]
}
+1
View File
@@ -4,6 +4,7 @@
"target": "ES2022",
"module": "NodeNext",
"moduleResolution": "NodeNext",
"resolveJsonModule": true,
"rootDir": "src",
"outDir": "dist",
"declaration": true,