ppt-dsl-renderer 1.1.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.
Files changed (49) hide show
  1. package/AGENT_PPTX_EXPORT.md +81 -0
  2. package/AGENT_USAGE.md +87 -0
  3. package/LICENSE +21 -0
  4. package/README.md +112 -0
  5. package/THIRD_PARTY_NOTICES.md +43 -0
  6. package/dist/browser/renderer.css +1 -0
  7. package/dist/browser/renderer.js +80 -0
  8. package/dist/cli.js +243 -0
  9. package/dist/index.js +140 -0
  10. package/dist/pptx/exporter.js +129 -0
  11. package/dist/pptx/index.js +7437 -0
  12. package/dist/vue/renderer.css +1 -0
  13. package/dist/vue/renderer.js +577 -0
  14. package/docs/AGENT.md +36 -0
  15. package/docs/DSL.md +60 -0
  16. package/docs/VUE.md +231 -0
  17. package/examples/deck.json +302 -0
  18. package/package.json +85 -0
  19. package/src/index.d.ts +24 -0
  20. package/src/pptx.d.ts +30 -0
  21. package/src/types/ppt-dsl.d.ts +241 -0
  22. package/src/types/vue.d.ts +40 -0
  23. package/src/vue.d.ts +16 -0
  24. package/third-party-licenses/core-util-is/LICENSE +19 -0
  25. package/third-party-licenses/dompurify/LICENSE +568 -0
  26. package/third-party-licenses/echarts/LICENSE +222 -0
  27. package/third-party-licenses/echarts/LICENSE-d3 +27 -0
  28. package/third-party-licenses/echarts/NOTICE +5 -0
  29. package/third-party-licenses/immediate/LICENSE.txt +20 -0
  30. package/third-party-licenses/inherits/LICENSE +16 -0
  31. package/third-party-licenses/isarray/LICENSE +22 -0
  32. package/third-party-licenses/jszip/LICENSE.markdown +651 -0
  33. package/third-party-licenses/lie/license.md +7 -0
  34. package/third-party-licenses/pako/LICENSE +21 -0
  35. package/third-party-licenses/pptxgenjs/LICENSE +21 -0
  36. package/third-party-licenses/readable-stream/LICENSE +47 -0
  37. package/third-party-licenses/safe-buffer/LICENSE +21 -0
  38. package/third-party-licenses/setimmediate/LICENSE.txt +20 -0
  39. package/third-party-licenses/string_decoder/LICENSE +48 -0
  40. package/third-party-licenses/svg-pathdata/LICENSE +20 -0
  41. package/third-party-licenses/tinycolor2/LICENSE +20 -0
  42. package/third-party-licenses/tslib/LICENSE.txt +12 -0
  43. package/third-party-licenses/util-deprecate/LICENSE +24 -0
  44. package/third-party-licenses/vue/LICENSE +21 -0
  45. package/third-party-licenses/vue-reactivity/LICENSE +21 -0
  46. package/third-party-licenses/vue-runtime-core/LICENSE +21 -0
  47. package/third-party-licenses/vue-runtime-dom/LICENSE +21 -0
  48. package/third-party-licenses/vue-shared/LICENSE +21 -0
  49. package/third-party-licenses/zrender/LICENSE +29 -0
@@ -0,0 +1,81 @@
1
+ # PPTX 后端接入
2
+
3
+ Agent 默认使用统一 CLI。命令、参数、输入和返回协议以 [Agent 调用指南](AGENT_USAGE.md) 为准;本文说明后端集成及导出边界。
4
+
5
+ ## 后端通过 CLI 调用
6
+
7
+ ### 部署与浏览器
8
+
9
+ 需要 Node.js 22+、包含 `export-pptx` 的构建包,以及后端机器/容器中已安装的 Chrome/Chromium、系统库和字体。`playwright-core@1.62.1` 是包的 Node 运行依赖,不能作为测试依赖删除;它不下载浏览器,也不要求 Python 安装 `playwright`。
10
+
11
+ 默认使用 Google Chrome。若后端通过自己的 Playwright 安装了 Chromium,可将其实际可执行文件路径传给 `--browser-executable`,并确保 CLI 进程有执行权限。**每次 CLI 调用仍会启动一个新实例,不复用已有浏览器进程或 Playwright 对象;当前没有 CDP/远程连接参数。**
12
+
13
+ ### Python 任务进程示例
14
+
15
+ 下面在同步任务 worker 中执行。`/app`、`/work/ppt-task` 和 Chromium 路径需换成实际部署路径;业务方已将完整 DSL 写入该任务独立的 `deck.json`。使用参数数组,不拼接 shell 命令。
16
+
17
+ ```python
18
+ import json
19
+ import subprocess
20
+ from pathlib import Path
21
+
22
+ cli = Path("/app/node_modules/ppt-dsl-renderer/dist/cli.js")
23
+ task_dir = Path("/work/ppt-task") # 每个任务使用独立目录。
24
+
25
+ result = subprocess.run(
26
+ [
27
+ "node", str(cli),
28
+ "export-pptx", str(task_dir / "deck.json"),
29
+ "--out", str(task_dir / "result.pptx"),
30
+ "--browser-executable", "/usr/bin/chromium",
31
+ "--timeout", "120000",
32
+ # 选页时追加 "--pages", "1,3";省略则导出全部页。
33
+ ],
34
+ capture_output=True,
35
+ text=True,
36
+ encoding="utf-8",
37
+ check=False,
38
+ )
39
+ if result.returncode != 0:
40
+ raise RuntimeError(result.stderr or f"CLI 退出码:{result.returncode}")
41
+
42
+ manifest = json.loads(result.stdout)
43
+ pptx_path = Path(manifest["file"])
44
+ pptx_bytes = pptx_path.read_bytes()
45
+ # 由业务方保存/上传 pptx_bytes 或提供 pptx_path 的下载。
46
+ ```
47
+
48
+ 默认 Chrome 部署可去掉 `--browser-executable` 及其值。也可用 PATH 中的 `ppt-dsl-renderer` 代替 `node` 加 CLI 路径;直接指定包内入口可避免服务进程与终端的 PATH 不同。Java/Node 等后端沿用相同的子进程参数、退出码和 JSON 协议。
49
+
50
+ 成功依据是退出码 0,而不是 stderr 为空或文件存在。结果文件已经写好,路径在顶层 `file`。CLI 正常完成或生成失败后关闭自己的浏览器,不操作后端其他实例。
51
+
52
+ ### 任务管理
53
+
54
+ - 限制并发量,每次调用都会启动浏览器;各任务使用独立输出路径。
55
+ - `--timeout` 分别约束浏览器启动和页面生成,不是总时限,也不覆盖最后写文件。后端总时限需留出两个阶段及写入时间。
56
+ - 若外部强制终止 CLI,任务执行器还需回收该任务的子进程,不能依赖 finally 一定执行。
57
+ - CLI 不提供实时进度、HTTP 服务、上传或断点续传。业务方负责任务状态、存储和下载;不要在每个任务中安装包、下载浏览器或执行 build。
58
+
59
+ ## CLI 实现范围
60
+
61
+ `src/cli.js` 新增 `export-pptx` 及其参数;`src/pptx-cli.js` 包装浏览器生命周期、二进制传输和文件保存。`package.json`/`yarn.lock` 声明 `playwright-core` 运行依赖,`vite.cli.config.js` 将驱动作为外部依赖,发布入口仍为 `dist/cli.js`。
62
+
63
+ CLI 复用原 `dist/pptx/exporter.js`,没有修改 DSL、Vue/HTML 渲染或 PPTX 转换算法,没有增加 demo 接口。原有 `render` 和浏览器 `exportToPptx` API 保持兼容。
64
+
65
+ ## 导出兼容边界
66
+
67
+ - 结构化资源使用 HTTP(S) URL 或 data URL。空白页面通常使用不透明来源,远程素材仍受 CORS、网络和权限约束;来源不被允许时,可由后端读取素材并明确转成 data URL 后传入 DSL。本包不会自动绕过跨域限制或以占位内容替换读取失败的资源。
68
+ - 默认嵌入音视频。视频支持 avi、mp4、m4v、mov、wmv;音频支持 mp3、m4a、mp4、wav、wma。URL 无后缀时填写元素 `ext`;data URL 可按明确的媒体 MIME 识别。格式不支持会报告页码和元素 ID。实际播放还取决于 Office/系统编解码器,原有 autoplay/loop 字段不额外映射。
69
+ - 视频封面会转成 PNG 后写入 PPTX;音视频实际内容嵌入文件,不仅保留链接或封面。
70
+ - 渐变/特殊形状、图片填充形状和有路径的公式使用 SVG 图片导出,不能当作原生可编辑形状/公式。无公式路径时沿用当前预览,输出公式源码文字。
71
+ - 渐变页面背景取首尾色的混合色,渐变文字取显式色标平均色;普通图表使用原生可编辑图表,`bar` 横向、`column` 竖向。表格禁止自动拆成额外页面,保持选定页数;合并区域使用包含占位单元格的完整行列网格,导出时跳过被覆盖的单元格。
72
+ - 默认母版背景取 `document.theme.backgroundColor`,省略时为白色;各页显式背景优先。不把主题字体、颜色自动下沉到所有元素。
73
+ - 普通文本与形状文字的 `inset` 均按「上、右、下、左」解释,单位为 CSS 像素;默认分别为 0px、8px,与网页一致。两者均读取 `lineHeight`、`paragraphSpace`、`wordSpace`,默认行高 1.4、段距和字距为 0;富文本内显式的 `line-height`、`letter-spacing`、段落 `margin-top/bottom` 优先。行高按字号换算为 PPTX 点数,显式换行分别计算;Office 自动折行的混合字号段落仍可能与浏览器存在差异。
74
+ - 字体栈取第一个字体名并进行 XML 属性转义,避免引号或 `&` 破坏 PPTX。图片背景按 `image.size` 导出:默认 `cover` 居中裁切,`contain` 等比完整显示,`stretch` 拉伸;背景图片作为最底层图片对象,留白使用页面背景色。
75
+ - 富文本里的粗体细对勾 `✓` 导出为可编辑的重对勾 `✔`,避免浏览器字体回退与 Office 固定字体产生明显不同的字形;非粗体细对勾保持原字符。
76
+ - 普通文本、标题及 `fixedHeight` 文本均保持 DSL 的位置和宽高,不再额外扩宽或设置 Office 自动改框。字体不一致导致的换行差异应通过字体环境核对,不能靠修改原框掩盖。
77
+ - 普通文本无显式换行、列表或段距,且行高等于扣除上下内边距后的框高时,按 HTML 的单行居中用法导出为原生垂直居中,不再保留整框高度的段落行距。多行、竖排及未撑满框高的正文保留原来的行距和对齐。
78
+ - 选页导出的元素页内链接按输出页序重新定位;目标页不在范围时不生成该链接。导出支持 DSL 的主要几何、颜色和文字样式,不承诺与浏览器逐像素一致,也不保留浏览器的所有图片滤镜。
79
+ - 字体依赖浏览器和打开 PPTX 的系统,不自动嵌入字体;生成成功不能代替 Office/WPS 中的实际视觉和媒体播放验收。
80
+
81
+ 导出模块基于当前 DSL 和 `pptxgenjs` 公开 API 实现。运行依赖的授权说明见 [第三方声明](THIRD_PARTY_NOTICES.md)。
package/AGENT_USAGE.md ADDED
@@ -0,0 +1,87 @@
1
+ # Agent 调用指南
2
+
3
+ Agent 先读取安装包内的 `node_modules/ppt-dsl-renderer/AGENT_USAGE.md`,即可通过统一 CLI 生成 HTML 或 PPTX,无需阅读源码。后端子进程示例见 [PPTX 后端接入](AGENT_PPTX_EXPORT.md#后端通过-cli-调用)。
4
+
5
+ ## 运行准备
6
+
7
+ - Node.js 22+。部署时安装 `ppt-dsl-renderer`,使用包含当前 CLI 和渲染/导出产物的构建包;不在每个任务中临时安装包或执行 build。
8
+ - HTML 生成不启动浏览器。PPTX 导出依赖随包安装的 `playwright-core@1.62.1`,使用运行机器上已安装的 Google Chrome/Chromium;包不下载浏览器。
9
+ - 浏览器所需系统库、字体、素材访问权限及可写任务目录由部署方准备。
10
+ - DSL 是完整 JSON 文件,不是命令行 JSON 字符串或 stdin。字段见 [DSL 文档](docs/DSL.md),示例见 [deck.json](examples/deck.json)。相对路径以终端当前目录为基准,并发任务使用独立的输入/输出路径。
11
+
12
+ ## 命令与参数
13
+
14
+ 下面使用已在 PATH 中的 `ppt-dsl-renderer`。若包仅安装在当前项目,将命令替换为 `./node_modules/.bin/ppt-dsl-renderer`,或使用 `node ./node_modules/ppt-dsl-renderer/dist/cli.js`。
15
+
16
+ ```bash
17
+ # 查看当前安装版本支持的命令
18
+ ppt-dsl-renderer --help
19
+
20
+ # 生成全部页的 HTML
21
+ ppt-dsl-renderer render ./deck.json --out-dir ./preview
22
+
23
+ # 导出全部页为一个 PPTX
24
+ ppt-dsl-renderer export-pptx ./deck.json --out ./result.pptx
25
+
26
+ # 仅导出第 1、3 页
27
+ ppt-dsl-renderer export-pptx ./deck.json --out ./selected.pptx --pages 1,3
28
+ ```
29
+
30
+ | 参数 | 适用命令 | 规则 |
31
+ | --- | --- | --- |
32
+ | `<deck.json>` | 两个命令 | 必填,完整 DSL 文件路径 |
33
+ | `--out-dir <directory>` | `render` | 必填,HTML 输出目录 |
34
+ | `--out <file.pptx>` | `export-pptx` | 必填,PPTX 文件路径,不能覆盖输入 DSL |
35
+ | `--pages 1,3` | 两个命令 | 可选,默认全部页;从 1 开始,排序去重;越界、空列表和非整数报错 |
36
+ | `--browser-executable <path>` | `export-pptx` | 可选,已有 Chromium 的程序路径;省略时使用已安装的 Google Chrome |
37
+ | `--timeout <milliseconds>` | `export-pptx` | 可选,正整数,默认 120000;启动、生成阶段各自的超时,不是进程总时限 |
38
+ | `--help` / `-h` | 两个命令 | 查看用法,不启动浏览器 |
39
+
40
+ `--out` 与 `--out-dir` 不可混用。若帮助中没有 `export-pptx`,由部署方更新安装包;重复运行或改用 `--out-dir` 不能补上缺失命令。
41
+
42
+ ## 成功判定与取文件
43
+
44
+ **等待进程结束,且退出码为 0,再解析 stdout 中的 JSON。** 退出码由命令执行工具提供,不在 stdout 的 JSON 内。stderr 也可能包含浏览器诊断日志,不能仅凭其非空判定失败。
45
+
46
+ ### HTML 结果
47
+
48
+ ```json
49
+ {
50
+ "pages": [
51
+ {
52
+ "pageNumber": 1,
53
+ "slideId": "cover",
54
+ "width": 1000,
55
+ "height": 562.5,
56
+ "file": "/work/ppt-task/preview/slide-001.html"
57
+ }
58
+ ]
59
+ }
60
+ ```
61
+
62
+ 从 `pages[].file` 取每页 HTML 的绝对路径,文件名对应原始页码。重复执行只覆盖本次选中页,不清空旧文件;以本次清单为准。写入失败时可能保留部分已生成页面。
63
+
64
+ CLI 成功只表示文件生成成功。需要截图时打开 HTML,按 [渲染与截图协议](docs/AGENT.md) 等待 `window.__PPT_DSL_RENDER__.status` 为 `ready`,再截图 `#ppt-slide`;`error` 状态先读取错误。
65
+
66
+ ### PPTX 结果
67
+
68
+ ```json
69
+ {
70
+ "file": "/work/ppt-task/result.pptx",
71
+ "pages": [{ "pageNumber": 1, "slideId": "cover" }],
72
+ "bytes": 12345
73
+ }
74
+ ```
75
+
76
+ 从顶层 `file` 取完整 PPTX,不是 `pages[].file`。`pages` 对应原 DSL 页码,`bytes` 是实际字节数(上例仅作格式演示)。文件位于 CLI 所在机器,上传、下载链接和存储由业务方负责。
77
+
78
+ 不必先执行 `render` 或启动网页服务。CLI 每次新建无头浏览器,加载包内 `dist/pptx/exporter.js`,调用原 `window.exportToPptx`;正常完成或生成失败后关闭本次实例。`--browser-executable` 只指定浏览器程序,不接受 Playwright 包目录或连接地址,也不复用后端已运行的浏览器。
79
+
80
+ CLI 只返回最终清单,不提供结构化实时进度。生成成功不等于已通过 Office/WPS 视觉验收。
81
+
82
+ ## 失败处理
83
+
84
+ - 退出码为 1:读取 stderr,不返回成功清单。PPTX 生成后才替换目标,失败保留原文件;不能因同名旧文件存在就报告本次成功。
85
+ - 缺少命令、产物或浏览器:由部署方修正版本/环境,不擅自安装浏览器、执行 build 或更改安全设置。
86
+ - 参数或 DSL 错误:按错误修正输入;不要用其他字段或参数隐式替代。
87
+ - 素材错误:检查运行机器的网络、权限及空白页面跨域访问条件,或由调用方明确提供 data URL;不要静默替换或丢弃素材。
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 ppt-dsl-renderer contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,112 @@
1
+ # ppt-dsl-renderer
2
+
3
+ 用同一套组件将 PPT DSL 渲染为 Vue 页面,或转为一页一个、可直接在浏览器打开的 HTML。独立 HTML 为 agent 提供稳定的页面节点和渲染完成状态,由 agent 自行截图、审查和修改 DSL。
4
+
5
+ 提供浏览器侧标准可编辑 PPTX 生成方法,返回完整 ArrayBuffer,默认全部页,可指定页码,保留音视频并应用默认母版。后端通过统一 CLI 直接保存 PPTX。
6
+
7
+ 运行要求:Node.js 22+;Vue 接入要求 Vue 3.4.21+(3.x);浏览器需要支持现代 DOM、SVG、Canvas。
8
+
9
+ ## 安装
10
+
11
+ 发布后可安装:
12
+
13
+ ```bash
14
+ yarn add ppt-dsl-renderer
15
+ ```
16
+
17
+ ## CLI 与 Agent 接入
18
+
19
+ ```bash
20
+ ppt-dsl-renderer --help
21
+ ppt-dsl-renderer render ./deck.json --out-dir ./preview
22
+ ppt-dsl-renderer export-pptx ./deck.json --out ./result.pptx
23
+ ```
24
+
25
+ 仅在当前项目安装时,使用 `./node_modules/.bin/ppt-dsl-renderer`。PPTX CLI 通过随包安装的 `playwright-core` 启动已有 Chrome/Chromium,每次创建新实例,不复用后端正在运行的浏览器;不改变原导出算法。
26
+
27
+ Agent 先读 [统一调用指南](AGENT_USAGE.md),其中集中说明运行前提、全部参数、JSON 返回值及失败处理。后端子进程调用、浏览器生命周期和修改范围见 [PPTX 后端接入](AGENT_PPTX_EXPORT.md)。两份文档随 npm 包发布。
28
+
29
+ ## Node API
30
+
31
+ ```ts
32
+ import { renderToHtml, type PptDslDocument } from 'ppt-dsl-renderer'
33
+ import { writeFile } from 'node:fs/promises'
34
+
35
+ const document: PptDslDocument = {
36
+ title: 'Hello DSL', width: 1000, height: 562.5,
37
+ slides: [{
38
+ id: 'cover',
39
+ elements: [{
40
+ id: 'title', type: 'text', left: 60, top: 70, width: 800, height: 100,
41
+ content: '<p style="font-size: 48px">Hello DSL</p>',
42
+ }],
43
+ }],
44
+ }
45
+
46
+ const pages = await renderToHtml(document, { pages: [1] })
47
+ await writeFile('slide.html', pages[0].html)
48
+ ```
49
+
50
+ 返回 `{ pageNumber, slideId, width, height, html }[]`。API 不写文件、不启动浏览器、不下载素材、不修改输入。Node 入口仅使用 Node 内置模块,Vue 等库已经打包进 HTML 的浏览器运行代码。
51
+
52
+ ## Vue 前端接入
53
+
54
+ 发布包提供预编译的 ESM 组件;前端通过 `/vue` 入口导入,样式只需引入一次:
55
+
56
+ ```vue
57
+ <script setup lang="ts">
58
+ import { SlideRenderer } from 'ppt-dsl-renderer/vue'
59
+ import type { PptDslSlide } from 'ppt-dsl-renderer'
60
+ import 'ppt-dsl-renderer/style.css'
61
+
62
+ defineProps<{ slide: PptDslSlide; width: number; height: number }>()
63
+ </script>
64
+
65
+ <template>
66
+ <SlideRenderer :slide="slide" :width="width" :height="height" />
67
+ </template>
68
+ ```
69
+
70
+ `SlideRenderer` 用于只读整页和缩略图,支持 `scale`。`ElementRenderer` 用于编辑画布,提供文字、形状文字和表格单元格插槽;展示结构与样式由包维护,编辑控件、交互和数据回写由前端维护。Vue 入口不会自动挂载页面或设置全局截图状态,CSS 不包含独立 HTML 的全局重置和光标隐藏规则。
71
+
72
+ Vue 从宿主项目复用;纯 Node 使用者无需安装 Vue。完整 API、插槽示例及现有渲染器的迁移步骤见 [Vue 接入指南](docs/VUE.md)。
73
+
74
+ ## Agent 接入
75
+
76
+ 1. 生成符合 [DSL 文档](docs/DSL.md) 的 JSON。
77
+ 2. 使用 CLI 或 API 生成 HTML,从本次结果清单取得文件路径。
78
+ 3. 在浏览器打开文件,等待 `window.__PPT_DSL_RENDER__.status` 不再为 `loading`。
79
+ 4. 状态为 `error` 时读取 `errors`;为 `ready` 时截图 `#ppt-slide`。
80
+ 5. 根据截图修改 DSL,再生成需要重审的页。
81
+
82
+ 完整调用流程见根目录 [Agent 调用指南](AGENT_USAGE.md),页面状态协议见 [Agent 渲染与截图协议](docs/AGENT.md)。本包不包含截图工具、MCP 服务、视觉模型或自动布局评价。
83
+
84
+ HTML 内嵌 JS、CSS 和该页数据,打开后等比例适配窗口并居中,窗口较大时保持原尺寸。DSL 坐标和内部尺寸不变;需要原始分辨率截图时,将浏览器 viewport 设置为 DSL 的 width、height。图片、背景图和视频封面支持 HTTP(S) URL 或 data URL;使用远程素材时仍需网络。视频只显示封面,音频只显示静态控件,不加载音视频内容。字体来自浏览器环境;缺少字体可能产生替换和换行差异,`ready` 不代表视觉通过或字体与其他系统完全相同。
85
+
86
+ ## PPTX 导出
87
+
88
+ 浏览器模块现已支持生成完整 PPTX ArrayBuffer,不自动下载:
89
+
90
+ ```js
91
+ import { exportToPptx } from 'ppt-dsl-renderer/pptx'
92
+
93
+ const binary = await exportToPptx(document)
94
+ // 指定页:await exportToPptx(document, { pages: [1, 3] })
95
+ ```
96
+
97
+ 后端通过统一 CLI 导出,调用示例及兼容边界见 [PPTX 后端接入](AGENT_PPTX_EXPORT.md)。
98
+
99
+ ## 开发与验证
100
+
101
+ ```bash
102
+ yarn test
103
+ yarn coverage
104
+ ```
105
+
106
+ 测试覆盖输入、分页、CLI 文件行为、JSON 嵌入、渲染状态、图片加载等待及 Vue 组件和样式语法;Vue 行为测试在内存中编译源码,验证缩放、插槽切换、多实例 SVG 引用和图表生命周期,并通过单个消费端夹具检查公开类型。图表测试使用 ECharts 交互替身,API 与安装目录模拟测试使用明确标识的测试运行资源,不代替生产构建或浏览器视觉验收;测试不会调用 build、vue-tsc 或启动本地服务。
107
+
108
+ 发布前由维护者显式执行 `yarn build`,生成 `dist/index.js`、`dist/cli.js`、`dist/browser`、`dist/vue` 和 `dist/pptx` 中的运行产物,再使用 `yarn pack` 检查安装包。npm 包只发布 `dist`、TypeScript 声明、使用文档、示例和第三方许可,不发布实现用的 `src/*.js`、`src/pptx` 或 source map。`prepack` 会检查公开入口、构建资源和发布清单,但不会自动构建。真实包验收应在独立目录安装生成的 tgz,验证 Node 生成示例 HTML、CLI、Vue 组件及 CSS、PPTX 模块的导入,再在浏览器核对渲染、PPTX 二进制返回和媒体播放。PPTX 单元测试检查真实 ZIP/XML、媒体字节和返回的 ArrayBuffer;DOM/Canvas 适配不代替浏览器或 Office 验收。另确认 npm 包名和构建产物的开源授权后再发布。
109
+
110
+ ## 许可证
111
+
112
+ 本包采用 MIT 许可证。浏览器依赖的许可证及声明见 [第三方声明](THIRD_PARTY_NOTICES.md)。
@@ -0,0 +1,43 @@
1
+ # Third-party notices
2
+
3
+ The standalone browser runtime bundles the following libraries. Original license and notice texts are distributed in third-party-licenses/. The package's MIT license does not replace their terms.
4
+
5
+ | Package | Installed version | License |
6
+ | --- | --- | --- |
7
+ | vue | 3.4.21 | MIT |
8
+ | @vue/shared | 3.4.21 | MIT |
9
+ | @vue/reactivity | 3.4.21 | MIT |
10
+ | @vue/runtime-core | 3.4.21 | MIT |
11
+ | @vue/runtime-dom | 3.4.21 | MIT |
12
+ | echarts | 6.1.0 | Apache-2.0 |
13
+ | zrender | 6.1.0 | BSD-3-Clause |
14
+ | tslib | 2.3.0 | 0BSD |
15
+ | dompurify | 3.3.1 | (MPL-2.0 OR Apache-2.0) |
16
+
17
+ DOMPurify is distributed under the Apache-2.0 option of its dual license. Its original license file is retained in full. ECharts' NOTICE and embedded d3 attribution are also included.
18
+
19
+ Build and test tools are development dependencies and are not required by the published Node entrypoint. Recheck bundled dependencies and notices whenever versions change.
20
+
21
+ ## PPTX export dependencies
22
+
23
+ The PPTX exporter is implemented against this package's DSL and the public PptxGenJS API. It does not include the demo editor's export source. The browser bundle additionally uses the following packages. License texts are retained in third-party-licenses/. JSZip is used under its MIT option; its prebundled browser distribution contains compression, promise and stream utilities.
24
+
25
+ | Package | Installed version | License |
26
+ | --- | --- | --- |
27
+ | pptxgenjs | 3.12.0 | MIT |
28
+ | tinycolor2 | 1.6.0 | MIT |
29
+ | svg-pathdata | 7.2.0 | MIT |
30
+ | jszip | 3.10.1 | (MIT OR GPL-3.0-or-later) |
31
+ | pako | 1.0.11 | (MIT AND Zlib) |
32
+ | lie | 3.3.0 | MIT |
33
+ | immediate | 3.0.6 | MIT |
34
+ | setimmediate | 1.0.5 | MIT |
35
+ | readable-stream | 2.3.8 | MIT |
36
+ | safe-buffer | 5.1.2 | MIT |
37
+ | string_decoder | 1.1.1 | MIT |
38
+ | util-deprecate | 1.0.2 | MIT |
39
+ | core-util-is | 1.0.3 | MIT |
40
+ | inherits | 2.0.4 | ISC |
41
+ | isarray | 1.0.0 | MIT |
42
+
43
+ Node-only PptxGenJS dependencies such as image-size and https are excluded by its browser mapping. DOMPurify's notice above also applies to export text sanitization.
@@ -0,0 +1 @@
1
+ .ppt-text-content[data-v-c728acd4],.ppt-text-static[data-v-c728acd4]{width:100%;box-sizing:border-box}.ppt-text-content[data-v-c728acd4]{display:flex;flex-direction:column;height:100%;position:relative;overflow-wrap:break-word;word-break:normal;white-space:normal}.ppt-text-editable[data-v-c728acd4]{-webkit-user-select:text;user-select:text}.ppt-text-static[data-v-c728acd4]{font-size:16px;position:relative}.ppt-text-static[data-v-c728acd4] p,.ppt-text-static[data-v-c728acd4] h1,.ppt-text-static[data-v-c728acd4] h2,.ppt-text-static[data-v-c728acd4] h3,.ppt-text-static[data-v-c728acd4] h4,.ppt-text-static[data-v-c728acd4] h5,.ppt-text-static[data-v-c728acd4] ol,.ppt-text-static[data-v-c728acd4] ul,.ppt-text-static[data-v-c728acd4] li{margin:0}.ppt-text-static[data-v-c728acd4] ol,.ppt-text-static[data-v-c728acd4] ul{padding-inline-start:1.25em}.ppt-text-static[data-v-c728acd4] li[style*="text-align: center"],.ppt-text-static[data-v-c728acd4] li[style*="text-align: right"]{list-style-position:inside}.ppt-text-static[data-v-c728acd4] li[style*="text-align: center"]>p,.ppt-text-static[data-v-c728acd4] li[style*="text-align: right"]>p{display:inline}.ppt-text-static-fixed[data-v-c728acd4]{display:flex;flex-direction:column;height:100%;justify-content:inherit}.ppt-image-content[data-v-bb8ba6cb]{position:relative;width:100%;height:100%;box-sizing:border-box}.ppt-image-content img[data-v-bb8ba6cb]{width:100%;height:100%;pointer-events:none}.ppt-image-mask[data-v-bb8ba6cb]{position:absolute;top:0;right:0;bottom:0;left:0;pointer-events:none}.ppt-shape-content[data-v-bde892d3],.ppt-shape-content svg[data-v-bde892d3],.ppt-shape-text[data-v-bde892d3]{position:absolute;top:0;right:0;bottom:0;left:0;width:100%;height:100%}.ppt-shape-text[data-v-bde892d3]{display:flex;justify-content:center;box-sizing:border-box;text-align:center;pointer-events:none}.ppt-shape-text[data-v-bde892d3] p,.ppt-shape-text[data-v-bde892d3] h1,.ppt-shape-text[data-v-bde892d3] h2,.ppt-shape-text[data-v-bde892d3] h3,.ppt-shape-text[data-v-bde892d3] h4,.ppt-shape-text[data-v-bde892d3] h5{margin:0}.ppt-shape-text-static[data-v-bde892d3]{width:100%}.ppt-shape-text-static[data-v-bde892d3] ol,.ppt-shape-text-static[data-v-bde892d3] ul,.ppt-shape-text-static[data-v-bde892d3] li{margin:0}.ppt-shape-text-static[data-v-bde892d3] ol,.ppt-shape-text-static[data-v-bde892d3] ul{padding-inline-start:1.25em}.ppt-shape-text-editable[data-v-bde892d3]{pointer-events:auto;-webkit-user-select:text;user-select:text}.ppt-shape-text-static[data-v-bde892d3] li[style*="text-align: center"],.ppt-shape-text-static[data-v-bde892d3] li[style*="text-align: right"]{list-style-position:inside}.ppt-shape-text-static[data-v-bde892d3] li[style*="text-align: center"]>p,.ppt-shape-text-static[data-v-bde892d3] li[style*="text-align: right"]>p{display:inline}.ppt-line-content[data-v-029177ed]{width:100%;height:100%;overflow:visible}.ppt-chart-content[data-v-d0925046]{width:100%;height:100%}.ppt-table-content[data-v-b7c947a1]{width:100%;height:100%;border-collapse:collapse;table-layout:fixed}.ppt-table-content td[data-v-b7c947a1]{padding:6px 10px;border:inherit;box-sizing:border-box;outline:0}.ppt-table-cell-editable[data-v-b7c947a1]{-webkit-user-select:text;user-select:text}.ppt-latex-content[data-v-bc1283bd]{display:flex;align-items:center;justify-content:center;width:100%;height:100%;color:#333;font:20px Georgia,serif}.ppt-latex-content svg[data-v-bc1283bd]{width:100%;height:100%}.ppt-video-content[data-v-51f57e49]{width:100%;height:100%;background:#111}.ppt-video-content img[data-v-51f57e49]{width:100%;height:100%;object-fit:contain}.ppt-audio-content[data-v-100cc51b]{display:flex;align-items:center;gap:8px;width:100%;height:100%;padding:8px;box-sizing:border-box;border:1px solid #e2e5ec;border-radius:8px;background:#fff}.ppt-audio-icon[data-v-100cc51b]{font-size:26px;font-weight:700}.ppt-audio-content audio[data-v-100cc51b]{width:calc(100% - 36px);height:32px;pointer-events:none}.ppt-element[data-v-4031d518]{position:absolute;transform-origin:center;-webkit-user-select:none;user-select:none;color:#272931;font-family:PingFang SC,Microsoft YaHei,sans-serif}.ppt-slide[data-v-a6a99631]{position:relative;overflow:hidden;isolation:isolate;color:#272931;font-family:PingFang SC,Microsoft YaHei,sans-serif}html,body{margin:0;padding:0}body{color:#272931;font-family:PingFang SC,Microsoft YaHei,sans-serif}#ppt-root{width:max-content}#ppt-slide *,#ppt-slide *:before,#ppt-slide *:after{animation:none!important;transition:none!important;caret-color:transparent!important}