# @md-to-pdf/core 跨 Web、Server、Desktop 和渲染器共享的纯数据模型与校验规则。该包不 依赖浏览器、Electron 或 Fastify,负责保证各运行端使用同一份协议。 ## 目录结构 ```text src/ document.ts Markdown 文档、分页载荷、结果与耗时模型 export-config.ts 纸张、边距、页眉页脚、页码与图表配置 theme.ts 主题清单、主题能力与 CSS 载荷模型 index.ts 公共导出入口 tests/ document.test.ts export-config.test.ts ``` ## 使用 ```ts import { createPagedDocumentPayload, defaultExportConfig, exportConfigSchema } from "@md-to-pdf/core"; const config = exportConfigSchema.parse(defaultExportConfig); const payload = createPagedDocumentPayload({ document, fileName: "example.md", themeCss, exportConfig: config }); ``` 新增跨端字段时,应先在这里定义类型、默认值、Zod 校验和兼容迁移,再由 各适配层消费,避免 Web 与 Desktop 分别维护协议。 ## 开发与验证 ```powershell npm run dev -w @md-to-pdf/core npm run test -w @md-to-pdf/core npm run typecheck -w @md-to-pdf/core npm run build -w @md-to-pdf/core ```