dsh-ppt 0.12.0 → 0.12.1

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/CHANGELOG.md CHANGED
@@ -4,6 +4,11 @@
4
4
 
5
5
  [历史英文记录](docs/CHANGELOG.en.md)
6
6
 
7
+ ## 0.12.1(2026-10-20)
8
+
9
+ - 修复 #4:记录 HTML / PPTX 的 SHA-256;检测外部修改或旧工程缺少记录时拒绝覆盖,新增「另存副本」与 `ppt_edit.saveAs`,原文件保留。副本从 JSON 重建,不导入 Office 手工修改。
10
+ - 读入当前工程和撤销历史时验证品牌颜色、字体及图片适应方式,拒绝不合规工程;纯文字 PPTX 清理 XML 禁止字符,保留中文与 emoji。
11
+
7
12
  ## 0.12.0(2026-10-20)
8
13
 
9
14
  - 新增逐页 Markdown 讲稿下载,使用当前页序、标题与备注,保留空备注提示和修订保护。
package/README.en.md CHANGED
@@ -31,6 +31,8 @@ For the web version, replace `desktop` with `web`. Restart DSH after installatio
31
31
 
32
32
  Ask to turn your material into a deliverable deck with HTML, PPTX and project files. From 0.8.0, use Settings → Presentations to edit projects generated by this plugin, or continue editing the PPTX in PowerPoint or WPS.
33
33
 
34
+ Office changes do not sync back to JSON. Externally changed outputs and legacy projects without integrity records cannot be overwritten. Use **Save a copy** or `ppt_edit(saveAs:true)` to rebuild a new trio from JSON while preserving the originals. The copy does not import Office edits.
35
+
34
36
  ## Requirements and configuration
35
37
 
36
38
  Normal generation does not require Office. Final PPTX rendering uses the optional official LibreOffice Kit; see the guide for dependencies, fonts and installation.
package/README.md CHANGED
@@ -31,6 +31,8 @@ dsh plugin --profile desktop add dsh-ppt
31
31
 
32
32
  可说:“把这份材料做成可直接交付的演示文稿,生成 HTML、PPTX 和工程文件。”0.8.0 起可在「设置 → 演示文稿」轻量修改自产工程,也可在 PowerPoint / WPS 中继续编辑 PPTX。
33
33
 
34
+ Office 中的修改不会同步回 JSON。插件检测到成品在外部修改,或旧工程没有校验记录时,会拒绝直接覆盖;可用面板「另存副本」或 `ppt_edit(saveAs:true)` 从 JSON 生成新文件,保留原成品。副本不包含 Office 手工修改。
35
+
34
36
  ## 依赖与配置
35
37
 
36
38
  普通生成不需要 Office。最终 PPTX 渲染使用可选的官方 LibreOffice Kit;依赖版本、字体环境和安装方法见使用说明。
package/docs/USAGE.md CHANGED
@@ -4,6 +4,8 @@
4
4
 
5
5
  ## 本次改进
6
6
 
7
+ 每次生成保存 HTML / PPTX 校验值。外部修改过成品或旧工程缺少校验记录时,`ppt_edit`、`ppt_undo` 和面板保存会拒绝覆盖。保留 Office 修改后的原件,点击「另存副本」或调用 `ppt_edit({deckPath, saveAs:true})` 从 JSON 重建不同文件名的三件套;副本不导入 Office 修改,使用新工程 ID 和修订号 0。
8
+
7
9
  在演示文稿设置页保存修改后点击“下载成品包 ZIP”。单文件下载仍可使用。ZIP 不包含配置、密钥或工作区其他文件;单文件 ≤64 MiB、合计 ≤128 MiB。
8
10
 
9
11
  ## 能力一览
package/lib/client.js CHANGED
@@ -115,6 +115,8 @@ const EN = Object.freeze({
115
115
  "正在读取图片,切换页面会取消本次读取。": "Reading the image. Switching slides cancels this upload.",
116
116
  "图片已载入,保存后生效。": "Image loaded. Save this slide to apply it.",
117
117
  "下载讲稿 Markdown": "Download speaker notes",
118
+ "另存副本": "Save a copy",
119
+ "副本已保存,原文件保留。副本从工程生成,不包含 Office 手工修改。": "Copy saved. Original files are preserved. The copy is rebuilt from the project and does not include external Office edits.",
118
120
  "演示文稿编辑": "Presentation editor",
119
121
  "修改本插件生成的成品,保存时同步更新 HTML、可编辑 PPTX 和工程文件。": "Edit presentations generated by this plugin. Saving updates the HTML, editable PPTX and project file together.",
120
122
  "载入最新版本,保留我的输入": "Load latest and keep my input",
@@ -333,12 +335,12 @@ function useLanguage(locale) {
333
335
  });
334
336
  }
335
337
  function choose(row) { if (dirty || busy) return; imageLoader.current.cancel(); setSelected(row.id); setDraft(draftFor(row)); setImage(null); setMessage(''); }
336
- function save() {
338
+ function save(saveAs = false) {
337
339
  const original = draftFor(slide), patch = {};
338
340
  for (const [key] of fields) if (draft[key] !== original[key]) patch[key] = key === 'bullets' ? draft[key].split('\n').map(v => v.trim()).filter(Boolean) : draft[key];
339
341
  if (image) patch.image = { src: image.src, alt: image.alt, fit: image.fit, caption: image.caption };
340
- return perform(signal => action({ operation: 'edit', id: project.id, expectedRevision: project.revision, slide: slide.id, patch }, signal), value => {
341
- adopt(value.project, slide.id); setMessage(value.changed === false ? t("内容没有变化。") : t("已保存,HTML、PPTX 和工程文件已同步更新。"));
342
+ return perform(signal => action({ operation: 'edit', id: project.id, expectedRevision: project.revision, slide: slide.id, patch, saveAs }, signal), value => {
343
+ adopt(value.project, slide.id); setMessage(saveAs ? t("副本已保存,原文件保留。副本从工程生成,不包含 Office 手工修改。") : value.changed === false ? t("内容没有变化。") : t("已保存,HTML、PPTX 和工程文件已同步更新。"));
342
344
  });
343
345
  }
344
346
  function move(delta) {
@@ -409,8 +411,8 @@ function useLanguage(locale) {
409
411
  h('input', { id: 'pptw-image', type: 'file', accept: 'image/png,image/jpeg', disabled: busy, onChange: upload }),
410
412
  currentImage && h('img', { className: 'image-preview', src: currentImage, alt: image?.alt || slide.image?.alt || t("当前图片") }),
411
413
  image && h(React.Fragment, null, h('p', { className: 'muted' }, t("已选择:") + image.name), h('label', { htmlFor: 'pptw-alt' }, t("图片说明")), h('input', { id: 'pptw-alt', value: image.alt, disabled: busy, onChange: e => setImage({ ...image, alt: e.target.value }) }), h('label', { htmlFor: 'pptw-fit' }, t("图片适应方式")), h('select', { id: 'pptw-fit', value: image.fit, disabled: busy, onChange: e => setImage({ ...image, fit: e.target.value }) }, h('option', { value: 'contain' }, t("完整显示")), h('option', { value: 'cover' }, t("填满并裁切")))),
412
- h('div', { className: 'tools' }, h('button', { className: 'primary', disabled: busy || imagePending || !dirty, onClick: save }, t("保存此页")), h('button', { disabled: busy || (!dirty && !imagePending), onClick: () => { imageLoader.current.cancel(); setDraft(draftFor(slide)); setImage(null); setDirty(false); setError(''); setMessage(''); setConflict(false); setOverlaps([]); } }, t("取消修改")), h('button', { disabled: busy || dirty || imagePending || !project.undoAvailable, onClick: undo }, t("撤销上次修改")))),
413
- h('details', { className: 'card' }, h('summary', null, t("质量提醒(") + project.quality.warningCount + (languageOf() === 'en' ? ')' : ')')), (project.quality.issues || []).map((issue, i) => h('p', { key: i }, t("第 ") + issue.slide + t(" 页:") + (languageOf() === 'en' ? issue.messageEn : issue.message) + (languageOf() === 'en' ? ' ' : ';') + (languageOf() === 'en' ? issue.suggestionEn : issue.suggestion)))),
414
+ h('div', { className: 'tools' }, h('button', { className: 'primary', disabled: busy || imagePending || !dirty, onClick: () => save() }, t("保存此页")), h('button', { disabled: busy || imagePending, onClick: () => save(true) }, t("另存副本")), h('button', { disabled: busy || (!dirty && !imagePending), onClick: () => { imageLoader.current.cancel(); setDraft(draftFor(slide)); setImage(null); setDirty(false); setError(''); setMessage(''); setConflict(false); setOverlaps([]); } }, t("取消修改")), h('button', { disabled: busy || dirty || imagePending || !project.undoAvailable, onClick: undo }, t("撤销上次修改")))),
415
+ h('details', { className: 'card' }, h('summary', null, t("质量提醒(") + (project.quality.warningCount + project.quality.errorCount) + (languageOf() === 'en' ? ')' : ')')), (project.quality.issues || []).map((issue, i) => h('p', { key: i }, (issue.slide > 0 ? t("第 ") + issue.slide + t(" 页:") : "") + (languageOf() === 'en' ? issue.messageEn : issue.message) + (languageOf() === 'en' ? ' ' : ';') + (languageOf() === 'en' ? issue.suggestionEn : issue.suggestion)))),
414
416
  h('p', { className: 'muted' }, t("成品包包含 PPTX、HTML 和工程文件。请先保存修改,再下载最新版本。")),
415
417
  h('div', { className: 'tools' }, h('button', { className: 'primary', disabled: busy || dirty || imagePending, onClick: () => download('bundle') }, t("下载成品包 ZIP")), h('button', { disabled: busy || dirty || imagePending, onClick: () => download('pptx') }, t("下载最新 PPTX")), h('button', { disabled: busy || dirty || imagePending, onClick: () => download('html') }, t("下载 HTML")), h('button', { disabled: busy || dirty || imagePending, onClick: () => download('notes') }, t("下载讲稿 Markdown")), h('button', { disabled: busy || dirty || imagePending, onClick: () => download('json') }, t("备份工程")))
416
418
  )
package/lib/tools.js CHANGED
@@ -214,6 +214,7 @@ export function buildPptTools(config) {
214
214
  name: 'ppt_edit',
215
215
  description: 'Modify selected slides in an existing dsh-ppt JSON project, preserving other pages and stable IDs. Each edit uses a 1-based slide number or ID and a patch of changed fields. Regenerates the HTML/PPTX/JSON trio atomically, embeds new images, stores undo history. Use ppt_check first and expectedRevision. 中文:按页码或 ID 修改指定页,其他页不变,支持撤销;可同步调整品牌。',
216
216
  parameters: compileParameters({ ...projectParameters,
217
+ saveAs: { type: 'boolean', description: 'Save a new uniquely named trio, leaving the originals untouched. Rebuilds from JSON; does not import external Office edits. Required for legacy projects or externally changed outputs.' },
217
218
  edits: { type: 'array', items: { type: 'object', properties: { slide: { type: ['integer', 'string'], description: '1-based page number or stable slide ID' }, patch: { type: 'object', properties: slideProperties, additionalProperties: false } }, required: ['slide', 'patch'], additionalProperties: false } },
218
219
  order: { type: 'array', items: { type: 'string' }, description: 'Reorder pages using every stable slide ID exactly once. May be used alone or together with edits; one undo restores the previous content and order.' },
219
220
  duplicate: { type: 'array', items: { type: ['integer', 'string'] }, description: 'Copy selected existing slides immediately after their originals, including images/charts/notes. References are 1-based page numbers or stable IDs from before this edit. Copies get new IDs; undo restores the previous deck.' },
package/lib/types.d.ts CHANGED
@@ -88,6 +88,7 @@ export interface PptEditArgs {
88
88
  order?: string[];
89
89
  brand?: PptBrand | null;
90
90
  expectedRevision?: number;
91
+ saveAs?: boolean;
91
92
  }
92
93
  export interface PptProjectArgs {
93
94
  deckPath: string;
@@ -26,6 +26,8 @@ const messages = {
26
26
  export function englishWorkbenchMessage(message) {
27
27
  if (messages[message])
28
28
  return messages[message];
29
+ if (/外部修改|成品校验|保留原成品/.test(message))
30
+ return 'Outputs changed externally, are missing, or have no integrity record. Keep the originals and use Save a copy. The copy comes from JSON and does not import Office edits.';
29
31
  if (/修订号冲突|已被修改|正在被另一次|其他操作修改/.test(message))
30
32
  return 'The project changed or is busy. Load the latest version and review your edits before retrying.';
31
33
  if (/渲染引擎不可用/.test(message))
@@ -45,6 +47,7 @@ export function englishWorkbenchMessage(message) {
45
47
  return /[\u3400-\u9fff]/.test(message) ? 'The operation failed. Check the project files and DSH logs, then try again.' : message;
46
48
  }
47
49
  const quality = {
50
+ 'artifact-conflict': ['Outputs changed externally, are missing, or have no integrity record.', 'Keep the originals and use Save a copy. The copy is rebuilt from JSON and does not import Office edits.'],
48
51
  'missing-title': ['This slide has no title.', 'Add a title that explains the slide.'],
49
52
  'title-overflow': ['The title may wrap too much or exceed its area.', 'Shorten the title and move explanations into the body.'],
50
53
  'dense-bullets': ['This slide has too many bullets for comfortable reading.', 'Reduce the bullets or split them across slides.'],
package/lib/workbench.js CHANGED
@@ -194,11 +194,12 @@ export class PptWorkbench {
194
194
  if (body.slide !== undefined && (typeof body.slide !== 'string' || !manifest.slides.some((s) => s.id === body.slide)))
195
195
  throw new Error('页面不存在');
196
196
  const args = { deckPath: entry.path, expectedRevision: body.expectedRevision, signal,
197
+ saveAs: body.saveAs === true,
197
198
  ...(body.slide === undefined ? {} : { edits: [{ slide: body.slide, patch: this.patch(body.patch) }] }),
198
199
  ...(body.order === undefined ? {} : { order: body.order }) };
199
200
  const result = await engine.editDeck(args);
200
201
  await this.remember(result, args);
201
- return { ...await this.view(entry.id), changed: result.changed };
202
+ return { ...await this.view(digest(result.jsonPath)), changed: result.changed };
202
203
  }
203
204
  if (body.operation === 'duplicate' || body.operation === 'remove') {
204
205
  if (typeof body.slide !== 'string' || !manifest.slides.some((s) => s.id === body.slide))
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-ppt",
3
- "version": "0.12.0",
3
+ "version": "0.12.1",
4
4
  "description": "DSH 演示文稿插件:生成 HTML、可编辑 PPTX 和工程文件,支持图表、轻量编辑、撤销与质量检查。",
5
5
  "type": "module",
6
6
  "main": "lib/index.js",
@@ -15,6 +15,8 @@ allowed-tools: "Bash, Read, Write, Edit"
15
15
 
16
16
  ## 执行纪律(每次都要遵守)
17
17
 
18
+ - 修改工程先 `ppt_check`。外部编辑过的 HTML/PPTX、缺少成品校验记录的旧工程不可覆盖;告知用户 `saveAs:true` 只从 JSON 另存新副本,原件保留,Office 手工修改不会导入。不得绕过校验或自行篡改校验值。
19
+
18
20
  - 一页一个观点;标题是判断句,不是名词短语。
19
21
  - 内容语言由你撰写;`lang` 只决定界面文字。
20
22
  - 先选主题再构建;不确定就用默认 `data`。
@@ -1,5 +1,5 @@
1
1
  import { mkdirSync, readFileSync, statSync, openSync, closeSync, rmSync } from 'node:fs'
2
- import { resolve, dirname, extname } from 'node:path'
2
+ import { resolve, dirname, extname, basename } from 'node:path'
3
3
  import { createHash, randomUUID } from 'node:crypto'
4
4
  import { inflateSync } from 'node:zlib'
5
5
  import { buildPptx, renderHtml, normalizeBuildOptions, normalizeSlides, resolveTheme, resolveLanguage, resolveDeckFileName, commitDeckArtifacts, DECK_VERSION, pptxEastAsianFont } from './deck-core.mjs'
@@ -307,6 +307,7 @@ function withLock(path, commit) {
307
307
  }
308
308
  async function generate(manifest, signal) {
309
309
  abort(signal)
310
+ validateSnapshot(manifest, manifest.assets)
310
311
  collectAssets(manifest)
311
312
  manifest.slideCount = manifest.slides.length
312
313
  manifest.quality = checkManifest(manifest)
@@ -319,7 +320,34 @@ async function generate(manifest, signal) {
319
320
  }
320
321
  function commit(paths, data) {
321
322
  const html = renderHtml(data.manifest, data.theme, data.language, paths)
322
- commitDeckArtifacts([{ path: paths.json, data: data.json, encoding: 'utf8' }, { path: paths.html, data: html, encoding: 'utf8' }, { path: paths.pptx, data: data.pptx }])
323
+ data.manifest.artifacts = { html: hash(html), pptx: hash(data.pptx) }
324
+ commitDeckArtifacts([{ path: paths.json, data: documentBytes(data.manifest), encoding: 'utf8' }, { path: paths.html, data: html, encoding: 'utf8' }, { path: paths.pptx, data: data.pptx }])
325
+ }
326
+
327
+ function validateSnapshot(value, assets) {
328
+ resolveTheme(value.theme); resolveLanguage(value.language)
329
+ validateRawSlides(value.slides)
330
+ if (value.brand != null) {
331
+ if (Object.hasOwn(value.brand, 'logo')) fail('工程品牌仅支持嵌入的 logoAssetId,不读取本地 logo 路径')
332
+ for (const key of ['primaryColor', 'backgroundColor', 'textColor', 'fontFamily', 'name', 'footer']) {
333
+ if (value.brand[key] !== undefined && typeof value.brand[key] !== 'string') fail('工程 brand.' + key + ' 必须为字符串')
334
+ }
335
+ normalizeBrand(value.brand, assets, '.')
336
+ }
337
+ for (const slide of value.slides) {
338
+ if (slide.image) {
339
+ if (slide.image.fit !== undefined && !['contain', 'cover'].includes(slide.image.fit)) fail('工程 image.fit 只允许 contain / cover')
340
+ if (slide.image.src !== undefined || !assets[slide.image.assetId]) fail('工程图片必须使用有效的嵌入资产')
341
+ }
342
+ if (slide.chart) normalizeChart(slide.chart)
343
+ }
344
+ }
345
+ function artifactProblem(manifest, paths) {
346
+ if (!manifest.artifacts) return '旧工程没有成品校验记录,无法确认外部修改;请另存副本,保留原文件。'
347
+ for (const kind of ['html', 'pptx']) {
348
+ try { if (hash(readFileSync(paths[kind])) === manifest.artifacts[kind]) continue } catch {}
349
+ return kind.toUpperCase() + ' 已在外部修改或缺失,不会覆盖;请另存副本。副本从 JSON 生成,不导入 Office 手工修改。'
350
+ }
323
351
  }
324
352
 
325
353
  export async function buildDeckAsync(options = {}) {
@@ -361,6 +389,10 @@ function readDocument(pathInput, cwd = '.') {
361
389
  document.assets ??= {}; document.history ??= []
362
390
  if (typeof document.assets !== 'object' || Array.isArray(document.assets)) fail('工程图片资产无效')
363
391
  if (!Array.isArray(document.history) || document.history.length > MAX_HISTORY || document.history.some(h => !h || !Array.isArray(h.slides))) fail('工程历史无效')
392
+ validateSnapshot(document, document.assets)
393
+ for (const prior of document.history) validateSnapshot(prior, document.assets)
394
+ if (document.artifacts !== undefined && (!document.artifacts || typeof document.artifacts !== 'object'
395
+ || ['html', 'pptx'].some(kind => !/^[a-f0-9]{64}$/.test(document.artifacts[kind])))) fail('工程成品校验记录无效')
364
396
  const ids = new Set()
365
397
  for (const slide of document.slides) {
366
398
  if (!slide || !layouts.has(slide.layout)) fail('工程含有未知页面布局')
@@ -379,12 +411,21 @@ export function readDeckProject(options = {}) {
379
411
  function expected(manifest, revision) {
380
412
  if (revision !== undefined && (!Number.isInteger(revision) || revision !== manifest.revision)) fail(`修订号冲突:当前 revision=${manifest.revision},请重新读取工程后修改`)
381
413
  }
382
- async function saveRevision(state, next, signal) {
414
+ async function saveRevision(state, next, signal, saveAs = false) {
415
+ if (!saveAs) { const problem = artifactProblem(state.manifest, pathsFor(state.path)); if (problem) fail(problem) }
383
416
  next.version = DECK_VERSION; next.schemaVersion = 1; next.revision = state.manifest.revision + 1
384
- const data = await generate(next, signal), paths = pathsFor(state.path)
417
+ if (saveAs) { next.deckId = randomUUID(); next.revision = 0; next.history = [] }
418
+ const data = await generate(next, signal)
419
+ let paths = pathsFor(state.path)
385
420
  withLock(state.path, () => {
386
421
  abort(signal)
387
422
  if (hash(readFileSync(state.path)) !== state.fingerprint) fail('工程已被其他操作修改,请重新读取后重试')
423
+ if (saveAs) {
424
+ const file = resolveDeckFileName(dirname(state.path), basename(state.path, '.json') + '-dsh', false)
425
+ paths = pathsFor(resolve(dirname(state.path), file + '.json'))
426
+ } else {
427
+ const problem = artifactProblem(state.manifest, paths); if (problem) fail(problem)
428
+ }
388
429
  commit(paths, data)
389
430
  })
390
431
  return result(next, paths)
@@ -396,7 +437,7 @@ export async function editDeck(options = {}) {
396
437
  expected(current, options.expectedRevision)
397
438
  const next = clone(current)
398
439
  if (!Array.isArray(options.edits) || !options.edits.length) {
399
- if (options.brand === undefined && options.order === undefined && options.duplicate === undefined && options.remove === undefined) fail('请提供 edits、order、duplicate、remove 或 brand')
440
+ if (options.brand === undefined && options.order === undefined && options.duplicate === undefined && options.remove === undefined && options.saveAs !== true) fail('请提供 edits、order、duplicate、remove 或 brand')
400
441
  }
401
442
  const used = new Set(), allowed = new Set(['layout', 'title', 'subtitle', 'kicker', 'text', 'bullets', 'rows', 'notes', 'image', 'chart'])
402
443
  for (const edit of options.edits ?? []) {
@@ -445,9 +486,9 @@ export async function editDeck(options = {}) {
445
486
  duplicate.has(slide.id) ? [slide, { ...clone(slide), id: randomUUID() }] : [slide])
446
487
  if (options.brand !== undefined) next.brand = normalizeBrand(options.brand === null ? null : { ...next.brand, ...options.brand,
447
488
  ...(options.brand?.logo === null ? { logo: undefined, logoAssetId: undefined } : {}) }, next.assets, resolve(options.cwd || '.'))
448
- if (JSON.stringify(snapshot(next)) === JSON.stringify(snapshot(current))) return { ...result(current, pathsFor(state.path)), changed: false }
489
+ if (options.saveAs !== true && JSON.stringify(snapshot(next)) === JSON.stringify(snapshot(current))) return { ...result(current, pathsFor(state.path)), changed: false }
449
490
  next.history = [...next.history, snapshot(current)].slice(-MAX_HISTORY)
450
- return { ...await saveRevision(state, next, options.signal), changed: true }
491
+ return { ...await saveRevision(state, next, options.signal, options.saveAs === true), changed: true }
451
492
  }
452
493
 
453
494
  export async function undoDeck(options = {}) {
@@ -464,7 +505,12 @@ export async function undoDeck(options = {}) {
464
505
  export function checkDeck(options = {}) {
465
506
  abort(options.signal)
466
507
  const { manifest, path } = readDocument(options.deckPath, options.cwd)
467
- return { ...checkManifest(manifest), deckPath: path, deckId: manifest.deckId, revision: manifest.revision,
508
+ const quality = checkManifest(manifest), problem = artifactProblem(manifest, pathsFor(path))
509
+ if (problem) {
510
+ quality.issues.push({ slide: 0, severity: 'error', code: 'artifact-conflict', message: problem, suggestion: '保留原成品,使用 saveAs:true 或面板「另存副本」。副本不包含 Office 手工修改。' })
511
+ quality.errorCount++; quality.ok = false
512
+ }
513
+ return { ...quality, deckPath: path, deckId: manifest.deckId, revision: manifest.revision,
468
514
  verification: { static: 'checked', pptxRender: 'not-verified', visual: 'not-verified' },
469
515
  undoAvailable: manifest.history.length, slides: manifest.slides.map((s, i) => ({ slide: i + 1, id: s.id, title: s.title, layout: s.layout })) }
470
516
  }
@@ -418,7 +418,7 @@ export function clampInt(value, fallback, min, max) {
418
418
  const WINDOWS_RESERVED_FILE_NAME = /^(con|prn|aux|nul|com[1-9]|lpt[1-9])(\.|$)/i
419
419
 
420
420
  export function sanitizeFileName(input) {
421
- const base = String(input ?? 'deck').trim().replace(/\.(html?|pptx|json)$/i, '')
421
+ const base = String(input ?? 'deck').toWellFormed().trim().replace(/[\uFFFE\uFFFF]/g, '-').replace(/\.(html?|pptx|json)$/i, '')
422
422
  let cleaned = base
423
423
  .replace(/[<>:"/\\|?*\u0000-\u001F]/g, '-')
424
424
  .replace(/\s+/g, '-')
@@ -449,6 +449,8 @@ export function resolveDeckFileName(outputDir, requestedFileName, overwrite) {
449
449
 
450
450
  export function escapeXml(value) {
451
451
  return String(value ?? '')
452
+ .replace(/[\u000B\u000C]/g, '\n')
453
+ .replace(/[^\u0009\u000A\u000D\u0020-\uD7FF\uE000-\uFFFD\u{10000}-\u{10FFFF}]/gu, '')
452
454
  .replace(/&/g, '&amp;')
453
455
  .replace(/</g, '&lt;')
454
456
  .replace(/>/g, '&gt;')