release: 发布 v0.6.4 环境自适应与 macOS 打包

新增能力:桌面端新增 macOS 打包支持,electron-builder 增加独立 mac 配置块,
产出 dmg,按 arm64、x64 分别单独构建、不产出 universal 包;Pandoc 运行时清单
新增 darwin/arm64、darwin/x64 两个官方发行项(含独立许可证文件来源),桌面
Pandoc 候选路径与 prepare-pandoc-runtime.mjs 均已泛化为按 --platform/--arch
参数选取目标,不再只认 Windows x64。AGENTS.md 不再硬编码 Windows 绝对路径与
强制 PowerShell 语法,改为按当前 Shell 与仓库实际位置自适应。

问题修复:修复解压内置 Pandoc 时未保留 Unix 可执行权限位的问题(unzipSync
不保留压缩包内权限,已补 chmod 0o755);修复根 package.json 中
build:web-runtime/dev/desktop:dev 三个脚本的构建顺序错误
(@md-to-pdf/application 被排在其依赖的 @md-to-pdf/preview-engine 之前,在
没有历史 dist 残留的全新环境中会导致类型解析失败);修正
packages/docx-engine/tests/pandoc-runtime.test.ts 与
apps/desktop/tests/markdown-file.test.ts 中依赖宿主 OS 或路径分隔符的测试
断言,避免这些用例只能在特定平台上通过。

验证结果:docx-engine 包 93 项测试、desktop 包 62 项测试(61 通过 + 1 项
Windows 专属用例按预期跳过)均通过;全项目类型检查、生产构建通过,
git diff --check 无空白错误。跳过依赖 Git 忽略的真实客户文档语料(tmp/)的
test:docx-real-world-corpus 与 test:docx-release-gate-suites 后,其余全部
工作区测试均通过;这两步需要接入真实语料的机器上单独执行。本机 macOS
(Apple Silicon)实测 npm run package:mac:arm64 全链路成功,内置 Pandoc
3.9.0.2 完成下载、哈希校验与真实 DOCX 冒烟转换;实际截图确认窗口、macOS
原生菜单栏、编辑器工具栏、中文字体与实时预览渲染正常。

兼容与部署:版本统一为 0.6.4。本版本仅完成开发基础设施与验证,未构建正式
发行文件:没有产出真实签名的 dmg、没有重新构建 Windows 安装包,也没有重新
构建 Docker 镜像;正式 macOS 发行产物与 Windows/Docker 同步验证留待 DOCX
发布门禁阶段完成后一并发布。

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01K5N6pcbjV4jVfXrcH3NcLP
This commit is contained in:
SkyJourney
2026-08-26 19:32:38 +08:00
co-authored by Claude Sonnet 5
parent effeca7ca8
commit c4df499680
22 changed files with 412 additions and 148 deletions
+61 -12
View File
@@ -9,9 +9,25 @@ const windowsIcon = path.resolve(
__dirname,
"../../logos/desktop/windows/app.ico"
);
const macIcon = path.resolve(
__dirname,
"../../logos/desktop/macos/app.icns"
);
const nsisInclude = process.env.MD_TO_PDF_NSIS_INCLUDE?.trim() ||
"build/installer.nsh";
// macOS 每次只构建一个架构的 dmgarm64 或 x64),不产出 universal 包——
// 项目内置完整 Chromium/Electron 运行时和固定版本 Pandoc,合并双架构会让单个
// 安装包体积翻倍。目标架构通过环境变量显式声明,用于挑选对应的内置 Pandoc
// 资源目录;不依赖 electron-builder 的 `${arch}` 路径宏(该宏在 extraResources
// 场景下有已知的可靠性问题)。
const macTargetArch = process.env.MD_TO_PDF_MAC_TARGET_ARCH?.trim() || "";
if (macTargetArch && macTargetArch !== "arm64" && macTargetArch !== "x64") {
throw new Error(
`未知 macOS 目标架构:${macTargetArch}(仅支持 arm64 或 x64`
);
}
module.exports = {
appId: brand.appId,
productName: brand.englishName,
@@ -46,22 +62,12 @@ module.exports = {
to: "font-packs",
filter: ["**/*"]
},
{
from: `.runtime/pandoc/${pandocRuntime.version}/windows-x86_64`,
to: `pandoc/${pandocRuntime.version}/windows-x86_64`,
filter: [
"pandoc.exe",
"COPYING.rtf",
"COPYRIGHT.txt",
"runtime-manifest.json"
]
},
{
from: windowsIcon,
to: "app.ico"
},
{
from: "../../logos/desktop/macos/app.icns",
from: macIcon,
to: "app.icns"
}
],
@@ -78,7 +84,19 @@ module.exports = {
],
icon: windowsIcon,
executableName: brand.executableName,
artifactName: `${brand.artifactPrefix}-${version}-x86_64.\${ext}`
artifactName: `${brand.artifactPrefix}-${version}-x86_64.\${ext}`,
extraResources: [
{
from: `.runtime/pandoc/${pandocRuntime.version}/windows-x86_64`,
to: `pandoc/${pandocRuntime.version}/windows-x86_64`,
filter: [
"pandoc.exe",
"COPYING.rtf",
"COPYRIGHT.txt",
"runtime-manifest.json"
]
}
]
},
nsis: {
oneClick: false,
@@ -94,5 +112,36 @@ module.exports = {
installerLanguages: ["zh_CN"],
include: nsisInclude,
artifactName: `${brand.artifactPrefix}-${version}-x86_64-Setup.\${ext}`
},
mac: {
category: "public.app-category.productivity",
icon: macIcon,
executableName: brand.executableName,
// 项目当前没有 Apple Developer 证书,显式声明不签名,与 Windows 侧
// 一贯记录在案的"未签名"状态保持一致;后续如需公证再补齐。
identity: null,
target: [
{
target: "dmg"
}
],
extraResources: macTargetArch
? [
{
from: `.runtime/pandoc/${pandocRuntime.version}/darwin-${macTargetArch}`,
to: `pandoc/${pandocRuntime.version}/darwin-${macTargetArch}`,
filter: [
"pandoc",
"COPYING.md",
"COPYRIGHT",
"runtime-manifest.json"
]
}
]
: []
},
dmg: {
title: brand.displayName,
artifactName: `${brand.artifactPrefix}-${version}-\${arch}.\${ext}`
}
};