dsh-ppt 0.25.0 → 0.27.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.
- package/CHANGELOG.md +22 -0
- package/README.en.md +14 -13
- package/README.md +14 -13
- package/docs/DATA.md +2 -2
- package/docs/REFERENCE.en.md +8 -8
- package/docs/REFERENCE.zh.md +8 -8
- package/docs/USAGE.en.md +12 -7
- package/docs/USAGE.md +12 -7
- package/docs/VALIDATION.md +8 -0
- package/docs/WORKBENCH.md +4 -4
- package/docs/assets/intro/workflow-en-dark.svg +1 -1
- package/docs/assets/intro/workflow-en-light.svg +1 -1
- package/docs/assets/intro/workflow-en-mobile-dark.svg +1 -1
- package/docs/assets/intro/workflow-en-mobile-light.svg +1 -1
- package/docs/assets/intro/workflow-zh-dark.svg +1 -1
- package/docs/assets/intro/workflow-zh-light.svg +1 -1
- package/docs/assets/intro/workflow-zh-mobile-dark.svg +1 -1
- package/docs/assets/intro/workflow-zh-mobile-light.svg +1 -1
- package/lib/client.js +312 -84
- package/lib/ecosystem.d.ts +73 -0
- package/lib/ecosystem.js +1352 -0
- package/lib/execution.d.ts +6 -1
- package/lib/execution.js +77 -4
- package/lib/tools.js +133 -1
- package/lib/types.d.ts +121 -1
- package/lib/workbench-language.js +4 -0
- package/lib/workbench.d.ts +2 -0
- package/lib/workbench.js +397 -10
- package/package.json +1 -1
- package/skills/dsh-ppt/SKILL.md +6 -6
- package/skills/dsh-ppt/package.json +1 -1
- package/skills/dsh-ppt/references/advanced.md +10 -5
- package/skills/dsh-ppt/references/syntax.md +1 -0
- package/skills/dsh-ppt/scripts/build-deck.mjs +53 -10
- package/skills/dsh-ppt/scripts/deck-absorb.mjs +114 -1
- package/skills/dsh-ppt/scripts/deck-advanced.mjs +153 -25
- package/skills/dsh-ppt/scripts/deck-chrome.mjs +1814 -0
- package/skills/dsh-ppt/scripts/deck-core.mjs +122 -6
- package/skills/dsh-ppt/scripts/deck-covers.mjs +804 -0
- package/skills/dsh-ppt/scripts/deck-delivery.mjs +636 -41
- package/skills/dsh-ppt/scripts/deck-diagrams.mjs +2842 -0
- package/skills/dsh-ppt/scripts/deck-director.mjs +167 -4
- package/skills/dsh-ppt/scripts/deck-icons.mjs +469 -0
- package/skills/dsh-ppt/scripts/deck-layouts.mjs +816 -5177
- package/skills/dsh-ppt/scripts/deck-media.mjs +159 -15
- package/skills/dsh-ppt/scripts/deck-mermaid.mjs +2737 -0
- package/skills/dsh-ppt/scripts/deck-office.mjs +1541 -0
- package/skills/dsh-ppt/scripts/deck-taste.mjs +347 -0
|
@@ -10,16 +10,29 @@ import { normalizeDataModel, prepareDataSlides, validateDataSnapshot, previewDat
|
|
|
10
10
|
import { normalizeVisual, applyVisualActions } from './deck-visual.mjs'
|
|
11
11
|
import { absorbPptx, CHROME_STYLE_IDS } from './deck-absorb.mjs'
|
|
12
12
|
import { extractPptxSlides } from './deck-import.mjs'
|
|
13
|
-
import { renderHandoutMarkdown } from './deck-delivery.mjs'
|
|
14
|
-
import { SCENARIO_TEMPLATES, findScenarioTemplate, buildScenarioSlides, listScenarioTemplates, inferThemeFromContent, promoteMarkdownSlides, auditSlideAesthetics } from './deck-director.mjs'
|
|
13
|
+
import { renderHandoutMarkdown, computePaceBudget, renderOnePagerHtml } from './deck-delivery.mjs'
|
|
14
|
+
import { SCENARIO_TEMPLATES, findScenarioTemplate, buildScenarioSlides, listScenarioTemplates, inferThemeFromContent, promoteMarkdownSlides, optimizeVisualRhythm, auditSlideAesthetics } from './deck-director.mjs'
|
|
15
|
+
import {
|
|
16
|
+
CARD_MATERIALS,
|
|
17
|
+
ICON_MODES,
|
|
18
|
+
resolveTasteRecipe,
|
|
19
|
+
resolveActiveTaste,
|
|
20
|
+
sanitizeCustomTasteRecipe,
|
|
21
|
+
loadWorkspaceTasteRecipes,
|
|
22
|
+
saveWorkspaceTasteRecipe,
|
|
23
|
+
listAllTasteRecipes,
|
|
24
|
+
listCuratedTasteRecipes,
|
|
25
|
+
} from './deck-taste.mjs'
|
|
15
26
|
export { readRenderReceipt } from './deck-render.mjs'
|
|
16
27
|
export { dataNotes, dataReport } from './deck-data.mjs'
|
|
17
28
|
export { buildDeck, resolveLanguage } from './deck-core.mjs'
|
|
18
29
|
export { listThemes, listMasterPresets, resolveTheme } from './deck-themes.mjs'
|
|
19
30
|
export { absorbPptx } from './deck-absorb.mjs'
|
|
20
31
|
export { extractPptxSlides } from './deck-import.mjs'
|
|
21
|
-
export { renderHandoutMarkdown } from './deck-delivery.mjs'
|
|
22
|
-
export {
|
|
32
|
+
export { renderHandoutMarkdown, computePaceBudget, renderOnePagerHtml } from './deck-delivery.mjs'
|
|
33
|
+
export { extractOfficeSource, importOfficeDeck } from './deck-office.mjs'
|
|
34
|
+
export { inferThemeFromContent, optimizeVisualRhythm } from './deck-director.mjs'
|
|
35
|
+
export { listAllTasteRecipes, listCuratedTasteRecipes, loadWorkspaceTasteRecipes, saveWorkspaceTasteRecipe, resolveTasteRecipe } from './deck-taste.mjs'
|
|
23
36
|
|
|
24
37
|
export function buildThemePreview(options = {}) {
|
|
25
38
|
return buildThemePreviewFromThemes(options, resolveLanguage, DECK_VERSION)
|
|
@@ -140,6 +153,23 @@ function normalizeBrand(input, assets, cwd) {
|
|
|
140
153
|
if (!CHROME_STYLE_SET.has(cs)) fail('brand.chromeStyle 需为 ' + CHROME_STYLE_IDS.join(' / '))
|
|
141
154
|
brand.chromeStyle = cs
|
|
142
155
|
}
|
|
156
|
+
if (input.cardMaterial !== undefined && input.cardMaterial !== null && input.cardMaterial !== '') {
|
|
157
|
+
const cm = String(input.cardMaterial).trim().toLowerCase()
|
|
158
|
+
if (!CARD_MATERIALS.includes(cm)) fail('brand.cardMaterial 需为 ' + CARD_MATERIALS.join(' / '))
|
|
159
|
+
brand.cardMaterial = cm
|
|
160
|
+
}
|
|
161
|
+
if (input.iconMode !== undefined && input.iconMode !== null && input.iconMode !== '') {
|
|
162
|
+
const im = String(input.iconMode).trim().toLowerCase()
|
|
163
|
+
if (!ICON_MODES.includes(im)) fail('brand.iconMode 需为 ' + ICON_MODES.join(' / '))
|
|
164
|
+
brand.iconMode = im
|
|
165
|
+
}
|
|
166
|
+
if (input.taste !== undefined && input.taste !== null && input.taste !== '') {
|
|
167
|
+
brand.taste = String(input.taste).trim().slice(0, 64)
|
|
168
|
+
}
|
|
169
|
+
if (input.tasteRecipe && typeof input.tasteRecipe === 'object' && !Array.isArray(input.tasteRecipe)) {
|
|
170
|
+
const cleanRecipe = sanitizeCustomTasteRecipe(input.tasteRecipe)
|
|
171
|
+
if (cleanRecipe) brand.tasteRecipe = cleanRecipe
|
|
172
|
+
}
|
|
143
173
|
if (input.logo) brand.logoAssetId = addAsset({ src: input.logo }, assets, cwd, '品牌 Logo')
|
|
144
174
|
else if (input.logoAssetId) {
|
|
145
175
|
if (!assets[input.logoAssetId]) fail('品牌 Logo 嵌入资产不存在')
|
|
@@ -198,7 +228,7 @@ function validateRawSlides(slides) {
|
|
|
198
228
|
}
|
|
199
229
|
|
|
200
230
|
function snapshot(manifest) {
|
|
201
|
-
return clone(Object.fromEntries(['title', 'theme', 'language', 'motion', 'slides', 'brand', 'template', 'dataModel'].filter(k => manifest[k] !== undefined).map(k => [k, manifest[k]])))
|
|
231
|
+
return clone(Object.fromEntries(['title', 'theme', 'language', 'motion', 'slides', 'brand', 'template', 'dataModel', 'targetMinutes', 'taste'].filter(k => manifest[k] !== undefined).map(k => [k, manifest[k]])))
|
|
202
232
|
}
|
|
203
233
|
|
|
204
234
|
function collectAssets(manifest) {
|
|
@@ -388,7 +418,7 @@ async function exportPptx(manifest, theme, language, signal) {
|
|
|
388
418
|
manifest.slides.forEach((source, index) => {
|
|
389
419
|
abort(signal)
|
|
390
420
|
const slide = slides[index]
|
|
391
|
-
const boxes = MEDIA_LAYOUTS.has(source.layout) ? mediaBoxes(source.layout, source.variant, source) : mediaBoxes('image')
|
|
421
|
+
const boxes = MEDIA_LAYOUTS.has(source.layout) ? mediaBoxes(source.layout, source.variant, source, manifest) : mediaBoxes('image')
|
|
392
422
|
if (Array.isArray(boxes.gallery) && Array.isArray(source.images) && source.images.length > 1) {
|
|
393
423
|
boxes.gallery.forEach((gBox, gIdx) => {
|
|
394
424
|
const img = source.images[gIdx]
|
|
@@ -404,12 +434,16 @@ async function exportPptx(manifest, theme, language, signal) {
|
|
|
404
434
|
}
|
|
405
435
|
} else {
|
|
406
436
|
const font = pptxEastAsianFont(theme.fonts.body)
|
|
407
|
-
const
|
|
437
|
+
const activeTaste = resolveActiveTaste(manifest, source)
|
|
438
|
+
const chartForSpec = activeTaste.chartSpotlight && source.chart.highlight === undefined && source.chart.spotlight === undefined
|
|
439
|
+
? { ...source.chart, spotlight: true }
|
|
440
|
+
: source.chart
|
|
441
|
+
const spec = buildOfficeKitChartSpec(chartForSpec, theme, source.visual, font)
|
|
408
442
|
lib.addSlideChart(slide, { ...emu(boxes.chart), name: 'Editable data chart', spec })
|
|
409
443
|
}
|
|
410
444
|
}
|
|
411
445
|
if (manifest.brand?.logoAssetId) putImage(slide, manifest.brand.logoAssetId, LOGO_BOX, 'contain', 'Brand logo', manifest.brand.name)
|
|
412
|
-
if (manifest.brand?.footer && !lib.findShapeByName(slide, 'Footer source')) {
|
|
446
|
+
if (manifest.brand?.footer && source.layout !== 'cover' && source.layout !== 'closing' && !lib.findShapeByName(slide, 'Footer source')) {
|
|
413
447
|
const footer = lib.addSlideTextBox(slide, { ...emu(FOOTER_BOX), text: manifest.brand.footer, name: 'Brand footer' })
|
|
414
448
|
lib.setShapeTextFormat(footer, { size: 10, font: pptxEastAsianFont(theme.fonts.body), color: theme.palette.muted })
|
|
415
449
|
}
|
|
@@ -426,15 +460,18 @@ function documentBytes(manifest) {
|
|
|
426
460
|
if (Buffer.byteLength(text) > MAX_DOCUMENT) fail('JSON 工程含历史超过 64 MiB,请缩减图片或清理历史后另存工程')
|
|
427
461
|
return text
|
|
428
462
|
}
|
|
429
|
-
function result(manifest, paths, writeHandout = false) {
|
|
463
|
+
function result(manifest, paths, writeHandout = false, writeOnePager = false) {
|
|
430
464
|
const handoutPath = paths.json.slice(0, -5) + '.handout.md'
|
|
465
|
+
const onePagerPath = paths.json.slice(0, -5) + '.onepager.html'
|
|
466
|
+
const paceBudget = computePaceBudget(manifest)
|
|
431
467
|
return { ok: true, title: manifest.title, theme: manifest.theme, language: manifest.language,
|
|
432
468
|
slideCount: manifest.slides.length, deckId: manifest.deckId, revision: manifest.revision,
|
|
433
469
|
slides: manifest.slides.map((s, i) => ({ slide: i + 1, id: s.id, title: s.title, layout: s.layout })),
|
|
434
470
|
undoAvailable: manifest.history.length, deliveryStatus: manifest.quality?.issues.some(i => i.code === 'template-unfilled') ? 'draft' : 'ready-for-review',
|
|
435
|
-
quality: manifest.quality, verification: { static: 'checked', pptxRender: 'not-verified', visual: 'not-verified' }, outputDir: dirname(paths.json),
|
|
471
|
+
quality: manifest.quality, paceBudget, verification: { static: 'checked', pptxRender: 'not-verified', visual: 'not-verified' }, outputDir: dirname(paths.json),
|
|
436
472
|
files: paths, htmlPath: paths.html, pptxPath: paths.pptx, jsonPath: paths.json,
|
|
437
|
-
...(writeHandout ? { handoutPath } : {})
|
|
473
|
+
...(writeHandout ? { handoutPath } : {}),
|
|
474
|
+
...(writeOnePager ? { onePagerPath } : {}) }
|
|
438
475
|
}
|
|
439
476
|
function pathsFor(jsonPath) {
|
|
440
477
|
const base = jsonPath.slice(0, -5)
|
|
@@ -459,9 +496,14 @@ async function generate(manifest, signal) {
|
|
|
459
496
|
abort(signal)
|
|
460
497
|
return { json, pptx, manifest, theme, language }
|
|
461
498
|
}
|
|
462
|
-
function commit(paths, data, writeHandout = false) {
|
|
499
|
+
function commit(paths, data, writeHandout = false, writeOnePager = false) {
|
|
463
500
|
const handoutPath = paths.json.slice(0, -5) + '.handout.md'
|
|
464
|
-
const
|
|
501
|
+
const onePagerPath = paths.json.slice(0, -5) + '.onepager.html'
|
|
502
|
+
const html = renderHtml(data.manifest, data.theme, data.language, {
|
|
503
|
+
...paths,
|
|
504
|
+
...(writeHandout ? { handout: handoutPath } : {}),
|
|
505
|
+
...(writeOnePager ? { onepager: onePagerPath } : {}),
|
|
506
|
+
})
|
|
465
507
|
data.manifest.artifacts = { html: hash(html), pptx: hash(data.pptx) }
|
|
466
508
|
const artifacts = [
|
|
467
509
|
{ path: paths.json, data: documentBytes(data.manifest), encoding: 'utf8' },
|
|
@@ -471,6 +513,9 @@ function commit(paths, data, writeHandout = false) {
|
|
|
471
513
|
if (writeHandout) {
|
|
472
514
|
artifacts.push({ path: handoutPath, data: renderHandoutMarkdown(data.manifest, data.language.id), encoding: 'utf8' })
|
|
473
515
|
}
|
|
516
|
+
if (writeOnePager) {
|
|
517
|
+
artifacts.push({ path: onePagerPath, data: renderOnePagerHtml(data.manifest, data.language.id), encoding: 'utf8' })
|
|
518
|
+
}
|
|
474
519
|
commitDeckArtifacts(artifacts)
|
|
475
520
|
}
|
|
476
521
|
|
|
@@ -481,11 +526,16 @@ function validateEmbeddedImgObject(img, assets) {
|
|
|
481
526
|
|
|
482
527
|
function validateSnapshot(value, assets) {
|
|
483
528
|
resolveTheme(value.theme); resolveLanguage(value.language)
|
|
529
|
+
if (value.targetMinutes !== undefined) {
|
|
530
|
+
if (typeof value.targetMinutes !== 'number' || !Number.isFinite(value.targetMinutes) || value.targetMinutes <= 0 || value.targetMinutes > 480) {
|
|
531
|
+
fail('targetMinutes 需为 0 到 480 之间的正数')
|
|
532
|
+
}
|
|
533
|
+
}
|
|
484
534
|
validateRawSlides(value.slides)
|
|
485
535
|
validateDataSnapshot(value, normalizeSlides)
|
|
486
536
|
if (value.brand != null) {
|
|
487
537
|
if (Object.hasOwn(value.brand, 'logo')) fail('工程品牌仅支持嵌入的 logoAssetId,不读取本地 logo 路径')
|
|
488
|
-
for (const key of ['primaryColor', 'secondaryColor', 'backgroundColor', 'textColor', 'fontFamily', 'headingFont', 'coverMode', 'coverBg', 'name', 'footer', 'chromeStyle']) {
|
|
538
|
+
for (const key of ['primaryColor', 'secondaryColor', 'backgroundColor', 'textColor', 'fontFamily', 'headingFont', 'coverMode', 'coverBg', 'name', 'footer', 'chromeStyle', 'cardMaterial', 'iconMode', 'taste']) {
|
|
489
539
|
if (value.brand[key] !== undefined && typeof value.brand[key] !== 'string') fail('工程 brand.' + key + ' 必须为字符串')
|
|
490
540
|
}
|
|
491
541
|
normalizeBrand(value.brand, assets, '.')
|
|
@@ -570,11 +620,21 @@ export async function buildDeckAsync(options = {}) {
|
|
|
570
620
|
absorbed = await absorbPptx({ pptxPath: String(options.referencePptx).trim(), cwd, extractLogo: true, signal: options.signal })
|
|
571
621
|
}
|
|
572
622
|
|
|
623
|
+
const workspaceTastes = loadWorkspaceTasteRecipes(cwd)
|
|
624
|
+
const resolvedTaste = options.taste !== undefined && options.taste !== null && options.taste !== ''
|
|
625
|
+
? resolveTasteRecipe(options.taste, workspaceTastes)
|
|
626
|
+
: (absorbed?.styleRecipe && options.cloneStructure === true ? absorbed.styleRecipe : null)
|
|
627
|
+
if (options.taste !== undefined && options.taste !== null && options.taste !== '' && !resolvedTaste) {
|
|
628
|
+
fail('未知品味配方 taste:' + String(options.taste))
|
|
629
|
+
}
|
|
630
|
+
|
|
573
631
|
const rawThemeOpt = typeof options.theme === 'string' && options.theme.trim() ? options.theme.trim() : undefined
|
|
574
632
|
let chosenThemeId = rawThemeOpt
|
|
575
633
|
let directorHint = null
|
|
576
|
-
if (chosenThemeId === 'auto' || (!chosenThemeId && (options.persona || absorbed || scenario))) {
|
|
577
|
-
if (
|
|
634
|
+
if (chosenThemeId === 'auto' || (!chosenThemeId && (options.persona || absorbed || scenario || resolvedTaste))) {
|
|
635
|
+
if (resolvedTaste?.theme && (!rawThemeOpt || rawThemeOpt === 'auto') && !options.persona) {
|
|
636
|
+
chosenThemeId = resolvedTaste.theme
|
|
637
|
+
} else if (absorbed && (!rawThemeOpt || rawThemeOpt === 'auto') && !options.persona && !scenario) {
|
|
578
638
|
chosenThemeId = absorbed.recommendedTheme
|
|
579
639
|
} else {
|
|
580
640
|
directorHint = inferThemeFromContent({
|
|
@@ -614,12 +674,27 @@ export async function buildDeckAsync(options = {}) {
|
|
|
614
674
|
}
|
|
615
675
|
}
|
|
616
676
|
}
|
|
617
|
-
if (directorHint?.tableStyle === 'booktabs') {
|
|
618
|
-
|
|
677
|
+
if (directorHint?.tableStyle === 'booktabs' || resolvedTaste?.tableStyle) {
|
|
678
|
+
const effTableStyle = resolvedTaste?.tableStyle || directorHint?.tableStyle
|
|
679
|
+
normalized.deck.slides = normalized.deck.slides.map(s => s.layout === 'table' && !s.tableStyle ? { ...s, tableStyle: effTableStyle } : s)
|
|
680
|
+
}
|
|
681
|
+
if (resolvedTaste && options.smartLayout !== false) {
|
|
682
|
+
normalized.deck.slides = optimizeVisualRhythm(normalized.deck.slides, resolvedTaste)
|
|
619
683
|
}
|
|
620
684
|
|
|
621
685
|
const assets = {}
|
|
622
686
|
let brandInput = options.brand
|
|
687
|
+
if (resolvedTaste && options.brand !== null) {
|
|
688
|
+
const tasteBrandBase = {
|
|
689
|
+
...(resolvedTaste.brand && typeof resolvedTaste.brand === 'object' ? resolvedTaste.brand : {}),
|
|
690
|
+
...(resolvedTaste.chromeStyle ? { chromeStyle: resolvedTaste.chromeStyle } : {}),
|
|
691
|
+
...(resolvedTaste.cardMaterial ? { cardMaterial: resolvedTaste.cardMaterial } : {}),
|
|
692
|
+
...(resolvedTaste.iconMode ? { iconMode: resolvedTaste.iconMode } : {}),
|
|
693
|
+
taste: resolvedTaste.id,
|
|
694
|
+
...(!listCuratedTasteRecipes().some(r => r.id === resolvedTaste.id) ? { tasteRecipe: resolvedTaste } : {}),
|
|
695
|
+
}
|
|
696
|
+
brandInput = { ...tasteBrandBase, ...(brandInput || {}) }
|
|
697
|
+
}
|
|
623
698
|
if (absorbed) {
|
|
624
699
|
const baseAbsorbedBrand = {
|
|
625
700
|
...absorbed.sanitizedBrand,
|
|
@@ -633,10 +708,17 @@ export async function buildDeckAsync(options = {}) {
|
|
|
633
708
|
) {
|
|
634
709
|
delete baseAbsorbedBrand.backgroundColor
|
|
635
710
|
}
|
|
636
|
-
brandInput = options.brand === null ? null : { ...baseAbsorbedBrand, ...(
|
|
711
|
+
brandInput = options.brand === null ? null : { ...baseAbsorbedBrand, ...(brandInput || {}) }
|
|
637
712
|
}
|
|
638
713
|
const brand = normalizeBrand(brandInput, assets, cwd)
|
|
639
714
|
|
|
715
|
+
const targetMinutesRaw = options.targetMinutes !== undefined && options.targetMinutes !== null
|
|
716
|
+
? Number(options.targetMinutes)
|
|
717
|
+
: undefined
|
|
718
|
+
if (targetMinutesRaw !== undefined && (!Number.isFinite(targetMinutesRaw) || targetMinutesRaw <= 0 || targetMinutesRaw > 480)) {
|
|
719
|
+
fail('targetMinutes 需为 0 到 480 之间的正数')
|
|
720
|
+
}
|
|
721
|
+
|
|
640
722
|
const manifest = {
|
|
641
723
|
version: DECK_VERSION,
|
|
642
724
|
schemaVersion: 1,
|
|
@@ -646,6 +728,8 @@ export async function buildDeckAsync(options = {}) {
|
|
|
646
728
|
theme: normalized.theme.id,
|
|
647
729
|
language: normalized.language.id,
|
|
648
730
|
motion: normalized.motion,
|
|
731
|
+
...(resolvedTaste ? { taste: listCuratedTasteRecipes().some(r => r.id === resolvedTaste.id) ? resolvedTaste.id : resolvedTaste } : {}),
|
|
732
|
+
...(targetMinutesRaw !== undefined ? { targetMinutes: targetMinutesRaw } : {}),
|
|
649
733
|
...(scenario ? { template: scenario.id } : {}),
|
|
650
734
|
...(brand ? { brand } : {}),
|
|
651
735
|
...(dataModel ? { dataModel } : {}),
|
|
@@ -659,8 +743,9 @@ export async function buildDeckAsync(options = {}) {
|
|
|
659
743
|
const file = resolveDeckFileName(normalized.outputDir, normalized.fileName, normalized.overwrite)
|
|
660
744
|
const paths = pathsFor(resolve(normalized.outputDir, file + '.json'))
|
|
661
745
|
const writeHandout = options.handout === true
|
|
662
|
-
|
|
663
|
-
|
|
746
|
+
const writeOnePager = options.onePager === true
|
|
747
|
+
withLock(paths.json, () => { abort(options.signal); commit(paths, data, writeHandout, writeOnePager) })
|
|
748
|
+
return result(manifest, paths, writeHandout, writeOnePager)
|
|
664
749
|
}
|
|
665
750
|
|
|
666
751
|
function readDocument(pathInput, cwd = '.') {
|
|
@@ -732,20 +817,22 @@ export async function editDeck(options = {}) {
|
|
|
732
817
|
if (
|
|
733
818
|
options.brand === undefined &&
|
|
734
819
|
options.theme === undefined &&
|
|
820
|
+
options.taste === undefined &&
|
|
735
821
|
options.referencePptx === undefined &&
|
|
736
822
|
options.order === undefined &&
|
|
737
823
|
options.duplicate === undefined &&
|
|
738
824
|
options.remove === undefined &&
|
|
739
825
|
options.append === undefined &&
|
|
826
|
+
options.targetMinutes === undefined &&
|
|
740
827
|
options.saveAs !== true
|
|
741
828
|
) {
|
|
742
|
-
fail('请提供 edits、theme、referencePptx、order、duplicate、remove、append 或 brand')
|
|
829
|
+
fail('请提供 edits、theme、taste、referencePptx、order、duplicate、remove、append、targetMinutes 或 brand')
|
|
743
830
|
}
|
|
744
831
|
}
|
|
745
832
|
const used = new Set()
|
|
746
833
|
const allowed = new Set([
|
|
747
|
-
'layout', 'variant', 'chrome', 'title', 'subtitle', 'kicker', 'takeaway', 'source',
|
|
748
|
-
'text', 'formula', 'activeIndex', 'tableStyle', 'bullets', 'items', 'cards', 'metrics',
|
|
834
|
+
'layout', 'variant', 'chrome', 'cardMaterial', 'iconMode', 'title', 'subtitle', 'kicker', 'takeaway', 'source',
|
|
835
|
+
'text', 'formula', 'mermaid', 'activeIndex', 'tableStyle', 'bullets', 'items', 'cards', 'metrics',
|
|
749
836
|
'columns', 'steps', 'quadrants', 'rows', 'notes', 'image', 'images', 'chart', 'visual',
|
|
750
837
|
])
|
|
751
838
|
for (const edit of options.edits ?? []) {
|
|
@@ -840,6 +927,47 @@ export async function editDeck(options = {}) {
|
|
|
840
927
|
next.brand = normalizeBrand({ ...next.brand, ...absorbedBrand }, next.assets, cwd)
|
|
841
928
|
}
|
|
842
929
|
|
|
930
|
+
if (options.taste !== undefined) {
|
|
931
|
+
if (options.taste === null || options.taste === '') {
|
|
932
|
+
delete next.taste
|
|
933
|
+
if (next.brand) {
|
|
934
|
+
delete next.brand.taste
|
|
935
|
+
delete next.brand.tasteRecipe
|
|
936
|
+
delete next.brand.cardMaterial
|
|
937
|
+
delete next.brand.iconMode
|
|
938
|
+
}
|
|
939
|
+
} else {
|
|
940
|
+
const wsTastes = loadWorkspaceTasteRecipes(cwd)
|
|
941
|
+
const tr = resolveTasteRecipe(options.taste, wsTastes)
|
|
942
|
+
if (!tr) fail('未知品味配方 taste:' + String(options.taste))
|
|
943
|
+
const isBuiltin = listCuratedTasteRecipes().some(r => r.id === tr.id)
|
|
944
|
+
next.taste = isBuiltin ? tr.id : tr
|
|
945
|
+
if (options.theme === undefined && tr.theme) next.theme = resolveTheme(tr.theme).id
|
|
946
|
+
next.brand = normalizeBrand({
|
|
947
|
+
...(next.brand || {}),
|
|
948
|
+
...(tr.brand && typeof tr.brand === 'object' ? tr.brand : {}),
|
|
949
|
+
...(tr.chromeStyle ? { chromeStyle: tr.chromeStyle } : {}),
|
|
950
|
+
...(tr.cardMaterial ? { cardMaterial: tr.cardMaterial } : {}),
|
|
951
|
+
...(tr.iconMode ? { iconMode: tr.iconMode } : {}),
|
|
952
|
+
taste: tr.id,
|
|
953
|
+
...(!isBuiltin ? { tasteRecipe: tr } : {}),
|
|
954
|
+
}, next.assets, cwd)
|
|
955
|
+
if (options.optimizeRhythm !== false) {
|
|
956
|
+
next.slides = optimizeVisualRhythm(next.slides, tr)
|
|
957
|
+
}
|
|
958
|
+
}
|
|
959
|
+
}
|
|
960
|
+
|
|
961
|
+
if (options.targetMinutes !== undefined) {
|
|
962
|
+
if (options.targetMinutes === null) {
|
|
963
|
+
delete next.targetMinutes
|
|
964
|
+
} else {
|
|
965
|
+
const tm = Number(options.targetMinutes)
|
|
966
|
+
if (!Number.isFinite(tm) || tm <= 0 || tm > 480) fail('targetMinutes 需为 0 到 480 之间的正数')
|
|
967
|
+
next.targetMinutes = tm
|
|
968
|
+
}
|
|
969
|
+
}
|
|
970
|
+
|
|
843
971
|
if (options.brand !== undefined) {
|
|
844
972
|
next.brand = normalizeBrand(options.brand === null ? null : { ...next.brand, ...options.brand,
|
|
845
973
|
...(options.brand?.logo === null ? { logo: undefined, logoAssetId: undefined } : {}) }, next.assets, cwd)
|
|
@@ -870,7 +998,7 @@ export async function undoDeck(options = {}) {
|
|
|
870
998
|
expected(state.manifest, options.expectedRevision)
|
|
871
999
|
if (!state.manifest.history.length) fail('该工程没有可撤销的修改')
|
|
872
1000
|
const next = clone(state.manifest), prior = next.history.pop()
|
|
873
|
-
for (const key of ['brand', 'template', 'dataModel']) delete next[key]
|
|
1001
|
+
for (const key of ['brand', 'template', 'dataModel', 'targetMinutes', 'taste']) delete next[key]
|
|
874
1002
|
Object.assign(next, prior)
|
|
875
1003
|
return saveRevision(state, next, options.signal)
|
|
876
1004
|
}
|