dsh-ppt 0.27.2 → 0.28.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 +15 -0
- package/README.en.md +22 -22
- package/README.md +22 -22
- package/docs/USAGE.en.md +1 -0
- package/docs/USAGE.md +1 -0
- package/docs/VALIDATION.md +4 -0
- 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 +264 -25
- package/lib/tools.js +17 -2
- package/lib/workbench.js +153 -5
- package/package.json +1 -1
- package/skills/dsh-ppt/SKILL.md +1 -1
- package/skills/dsh-ppt/package.json +1 -1
- package/skills/dsh-ppt/scripts/deck-advanced.mjs +30 -14
- package/skills/dsh-ppt/scripts/deck-charts-pro.mjs +976 -0
- package/skills/dsh-ppt/scripts/deck-chrome.mjs +27 -6
- package/skills/dsh-ppt/scripts/deck-core.mjs +93 -3
- package/skills/dsh-ppt/scripts/deck-covers.mjs +156 -2
- package/skills/dsh-ppt/scripts/deck-layouts.mjs +84 -0
- package/skills/dsh-ppt/scripts/deck-showcase.mjs +729 -0
package/lib/tools.js
CHANGED
|
@@ -281,6 +281,12 @@ const slideItemSchema = {
|
|
|
281
281
|
role: { type: 'string', description: 'Role/title badge for org/team cards.' },
|
|
282
282
|
conversion: { type: 'string', description: 'Stage conversion rate badge for funnel/flywheel process steps.' },
|
|
283
283
|
icon: { type: 'string', description: 'Native vector icon name (e.g. rocket, shield, cpu, trending-up, coins, cloud, bot, spark, target, users, or "auto").' },
|
|
284
|
+
avatar: { type: 'string', description: 'Optional monogram or portrait label for team cards.' },
|
|
285
|
+
x: { type: 'number', description: 'Horizontal coordinate (0-100) for quadrant/bubble-matrix items.' },
|
|
286
|
+
y: { type: 'number', description: 'Vertical coordinate (0-100) for quadrant/bubble-matrix items.' },
|
|
287
|
+
size: { type: 'number', description: 'Relative bubble size weight for quadrant/bubble-matrix items.' },
|
|
288
|
+
before: { type: 'number', description: 'Baseline/before numeric value for dumbbell/slope comparison items.' },
|
|
289
|
+
after: { type: 'number', description: 'Target/after numeric value for dumbbell/slope comparison items.' },
|
|
284
290
|
status: { type: 'string', enum: ['positive', 'negative', 'warning', 'neutral', 'accent'] },
|
|
285
291
|
tone: { type: 'string', enum: ['positive', 'negative', 'warning', 'neutral', 'accent'] },
|
|
286
292
|
},
|
|
@@ -291,6 +297,8 @@ const slideLayouts = [
|
|
|
291
297
|
'kpi', 'cards', 'comparison', 'matrix', 'process', 'callout',
|
|
292
298
|
'gantt', 'architecture', 'harvey', 'tam', 'org',
|
|
293
299
|
'marimekko', 'sankey', 'swot',
|
|
300
|
+
'mockup', 'code', 'quadrant', 'radar', 'dumbbell', 'heatmap',
|
|
301
|
+
'device', 'browser', 'mobile', 'snippet', 'bubble-matrix', 'magic-quadrant', 'spider', 'slope', 'heat-matrix',
|
|
294
302
|
'table', 'closing', 'image', 'image-left', 'image-right',
|
|
295
303
|
'chart', 'chart-split', 'gallery', 'waterfall', 'flywheel',
|
|
296
304
|
'bento', 'pillars', 'exec-summary', 'timeline', 'steps', 'layers', 'funnel', 'chevron', 'value-chain',
|
|
@@ -318,17 +326,24 @@ const slideProperties = {
|
|
|
318
326
|
text: { type: 'string' },
|
|
319
327
|
formula: { type: 'string', description: 'LaTeX math expression rendered as native Office Math (<m:oMath>) in PPTX and MathML in HTML (e.g. on callout slides with variant: "formula").' },
|
|
320
328
|
mermaid: { type: 'string', description: 'Mermaid flowchart or sequenceDiagram code compiled into native editable PowerPoint shapes & attached connectors in PPTX and SVG in HTML.' },
|
|
329
|
+
code: { type: 'string', description: 'Source code snippet for code slides with multi-color syntax highlighting in HTML and native Consolas OOXML runs in PPTX.' },
|
|
330
|
+
language: { type: 'string', description: 'Programming language tag for code slides (e.g. typescript, python, sql, bash, go, rust, json, yaml).' },
|
|
331
|
+
filename: { type: 'string', description: 'Optional file path or window title for code/mockup slides.' },
|
|
332
|
+
url: { type: 'string', description: 'Optional browser URL displayed inside mockup[browser] address bar.' },
|
|
333
|
+
coverPattern: { type: 'string', enum: ['dots', 'grid', 'rings'], description: 'Optional subtle geometric vector backdrop pattern on cover slides.' },
|
|
334
|
+
xLabel: { type: 'string', description: 'Horizontal axis label for quadrant/bubble-matrix slides.' },
|
|
335
|
+
yLabel: { type: 'string', description: 'Vertical axis label for quadrant/bubble-matrix slides.' },
|
|
321
336
|
notes: { type: 'string' },
|
|
322
337
|
start: { type: 'number' }, span: { type: 'number' },
|
|
323
338
|
activeIndex: { type: 'integer' },
|
|
324
339
|
tableStyle: { type: 'string', enum: tableStyles },
|
|
325
340
|
bullets: { type: 'array', items: { type: 'string' } },
|
|
326
|
-
items: { type: 'array', items: slideItemSchema, description: 'Structured sub-elements for kpi, cards, comparison, matrix, process, callout, gantt, architecture, tam, org, or chart-split.' },
|
|
341
|
+
items: { type: 'array', items: slideItemSchema, description: 'Structured sub-elements for kpi, cards, comparison, matrix, process, callout, gantt, architecture, tam, org, mockup, code, quadrant, radar, dumbbell, or chart-split.' },
|
|
327
342
|
cards: { type: 'array', items: slideItemSchema },
|
|
328
343
|
metrics: { type: 'array', items: slideItemSchema },
|
|
329
344
|
columns: { type: 'array', items: { oneOf: [{ type: 'string' }, slideItemSchema] }, description: 'Time-header labels (string[]) for gantt slides, or column items (object[]) as an items alias.' },
|
|
330
345
|
steps: { type: 'array', items: slideItemSchema },
|
|
331
|
-
quadrants: { type: 'array', items: slideItemSchema },
|
|
346
|
+
quadrants: { type: 'array', items: { oneOf: [{ type: 'string' }, slideItemSchema] }, description: '4 corner labels (string[4]) for quadrant bubble charts, or 4 item objects for 2x2 matrix.' },
|
|
332
347
|
rows: { type: 'array', items: { type: 'array', items: { type: ['string', 'number'] } } },
|
|
333
348
|
image: imageSchema,
|
|
334
349
|
images: { type: 'array', items: { oneOf: [{ type: 'object', properties: imageObjectProperties, additionalProperties: false }, { type: 'string' }] } },
|
package/lib/workbench.js
CHANGED
|
@@ -20,6 +20,7 @@ const ALLOWED_LAYOUTS = new Set([
|
|
|
20
20
|
'kpi', 'cards', 'comparison', 'matrix', 'process', 'callout',
|
|
21
21
|
'gantt', 'architecture', 'harvey', 'tam', 'org',
|
|
22
22
|
'marimekko', 'sankey', 'swot',
|
|
23
|
+
'mockup', 'code', 'quadrant', 'radar', 'dumbbell', 'heatmap',
|
|
23
24
|
'table', 'closing', 'image', 'image-left', 'image-right', 'chart', 'chart-split',
|
|
24
25
|
'waterfall', 'gallery', 'flywheel', 'chevron', 'value-chain',
|
|
25
26
|
'mermaid', 'flowchart', 'sequence',
|
|
@@ -30,7 +31,8 @@ const ALLOWED_ITEM_STATUS = new Set(['neutral', 'accent', 'positive', 'negative'
|
|
|
30
31
|
const ALLOWED_CHROME_STYLES = new Set(['consulting-classic', 'keynote-spatial', 'editorial-folio', 'saas-bento', 'academic-minimal', 'gov-ceremonial']);
|
|
31
32
|
const ALLOWED_CARD_MATERIALS = new Set(['solid', 'frameless', 'glass', 'editorial-rule']);
|
|
32
33
|
const ALLOWED_ICON_MODES = new Set(['off', 'explicit', 'auto']);
|
|
33
|
-
const
|
|
34
|
+
const ALLOWED_COVER_PATTERNS = new Set(['dots', 'grid', 'rings']);
|
|
35
|
+
const ITEM_KEYS = new Set(['tag', 'badge', 'title', 'text', 'body', 'value', 'unit', 'delta', 'start', 'span', 'milestone', 'role', 'conversion', 'icon', 'avatar', 'x', 'y', 'size', 'before', 'after', 'status', 'tone', 'bullets']);
|
|
34
36
|
const BRAND_KEYS = new Set(['name', 'primaryColor', 'secondaryColor', 'backgroundColor', 'textColor', 'fontFamily', 'headingFont', 'coverMode', 'coverBg', 'logo', 'footer', 'chromeStyle', 'cardMaterial', 'iconMode', 'taste']);
|
|
35
37
|
const VISUAL_KEYS = new Set(['titleSize', 'bodySize', 'chartLabelSize', 'density', 'tableStyle', 'chrome']);
|
|
36
38
|
/** Sharing keeps the offline deck, but omits the control for a project not in the ZIP. */
|
|
@@ -317,6 +319,76 @@ function starterSlide(archetype, language) {
|
|
|
317
319
|
: 'sequenceDiagram\n participant 用户\n participant 工作台\n participant 引擎\n 用户->>工作台: 上传 .xlsx / .docx\n 工作台->>引擎: 智能剖析与编排\n 引擎-->>用户: HTML + 原生 PPTX',
|
|
318
320
|
};
|
|
319
321
|
}
|
|
322
|
+
if (kind === 'mockup') {
|
|
323
|
+
return {
|
|
324
|
+
layout: 'mockup',
|
|
325
|
+
variant: 'browser',
|
|
326
|
+
title: en ? 'Unified studio delivers live preview & native export' : '一体化工作台实时联动预览与原生导出',
|
|
327
|
+
url: 'https://studio.dsh-ppt.dev/workspace',
|
|
328
|
+
items: [
|
|
329
|
+
{ tag: 'LIVE', value: '60 fps', title: en ? 'Zero-latency canvas' : '实时同源预览', text: en ? 'Double-click any heading to edit inline.' : '画布双击标题或要点即刻原地改字。' },
|
|
330
|
+
{ tag: 'NATIVE', value: '100%', title: en ? 'Editable OOXML' : '原生可编辑 PPTX', text: en ? 'Charts, Mermaid, math & 61 vector icons.' : '图表、流程图、公式与 61 枚矢量图标原生可改。' },
|
|
331
|
+
],
|
|
332
|
+
};
|
|
333
|
+
}
|
|
334
|
+
if (kind === 'code') {
|
|
335
|
+
return {
|
|
336
|
+
layout: 'code',
|
|
337
|
+
language: 'typescript',
|
|
338
|
+
filename: 'src/pipeline.ts',
|
|
339
|
+
title: en ? 'Declarative pipeline compiles slides deterministically' : '声明式流水线一行生成高审美同源三件套',
|
|
340
|
+
code: "import { buildDeckAsync } from 'dsh-ppt/deck-advanced'\n\nexport async function shipExecutiveDeck(notes: string) {\n return buildDeckAsync({\n title: '2026 Annual Strategy Review',\n taste: 'mckinsey-partner',\n content: notes,\n outputDir: './dist',\n })\n}",
|
|
341
|
+
items: [
|
|
342
|
+
{ tag: '01', icon: 'sparkles', title: en ? 'Curated Taste Recipe' : '大师品味配方驱动', text: en ? 'Orchestrates cover, materiality & chart spotlight.' : '自动联动封面、材质、图标与图表聚光灯。' },
|
|
343
|
+
{ tag: '02', icon: 'shield', title: en ? 'Zero-Dep Compiler' : '零外部依赖确定性编译', text: en ? 'Validates OOXML schema before writing files.' : '落盘前自动校验 OOXML 结构,确保零报错。' },
|
|
344
|
+
],
|
|
345
|
+
};
|
|
346
|
+
}
|
|
347
|
+
if (kind === 'quadrant') {
|
|
348
|
+
return {
|
|
349
|
+
layout: 'quadrant',
|
|
350
|
+
title: en ? 'Competitive positioning leads on execution & vision' : '竞品魔力象限:我们在执行力与产品前瞻性双双领跑',
|
|
351
|
+
xLabel: en ? 'Completeness of Vision →' : '产品前瞻性与生态完整度 →',
|
|
352
|
+
yLabel: en ? 'Ability to Execute ↑' : '工程交付与规模化执行力 ↑',
|
|
353
|
+
items: [
|
|
354
|
+
{ title: en ? 'Our Platform' : '本平台', x: 84, y: 86, size: 80, status: 'accent' },
|
|
355
|
+
{ title: en ? 'Vendor A' : '竞品 A', x: 64, y: 68, size: 58, status: 'neutral' },
|
|
356
|
+
{ title: en ? 'Vendor B' : '竞品 B', x: 32, y: 74, size: 46, status: 'neutral' },
|
|
357
|
+
{ title: en ? 'Vendor C' : '竞品 C', x: 74, y: 34, size: 40, status: 'neutral' },
|
|
358
|
+
{ title: en ? 'Legacy Suite' : '传统工具', x: 24, y: 26, size: 50, status: 'negative' },
|
|
359
|
+
],
|
|
360
|
+
};
|
|
361
|
+
}
|
|
362
|
+
if (kind === 'radar') {
|
|
363
|
+
return {
|
|
364
|
+
layout: 'radar',
|
|
365
|
+
title: en ? 'Six-dimension capability benchmark outperforms market average' : '六维核心能力评估全面领先行业基线',
|
|
366
|
+
rows: en
|
|
367
|
+
? [['Dimension', 'Our Platform', 'Industry Avg'], ['Throughput', 94, 70], ['Latency', 91, 68], ['Reliability', 96, 76], ['Security', 92, 72], ['Efficiency', 88, 64], ['Ecosystem', 86, 74]]
|
|
368
|
+
: [['能力维度', '本平台', '行业均值'], ['推理吞吐', 94, 70], ['响应延迟', 91, 68], ['高可用性', 96, 76], ['安全合规', 92, 72], ['成本效率', 88, 64], ['生态兼容', 86, 74]],
|
|
369
|
+
};
|
|
370
|
+
}
|
|
371
|
+
if (kind === 'dumbbell') {
|
|
372
|
+
return {
|
|
373
|
+
layout: 'dumbbell',
|
|
374
|
+
title: en ? 'Automation upgrade delivers step-change gains across KPIs' : '智能化升级驱动核心运营指标全面跃迁(Before → After)',
|
|
375
|
+
items: [
|
|
376
|
+
{ title: en ? 'Automation Rate' : '流程自动化率', before: 38, after: 84, unit: '%', delta: '+46pp', status: 'positive' },
|
|
377
|
+
{ title: en ? 'First-Pass Yield' : '一次交付达标率', before: 64, after: 93, unit: '%', delta: '+29pp', status: 'positive' },
|
|
378
|
+
{ title: en ? 'Unit Cost Index' : '单笔成本指数', before: 92, after: 54, unit: '', delta: '-41%', status: 'accent' },
|
|
379
|
+
{ title: en ? 'Team Adoption' : '团队活跃渗透率', before: 45, after: 89, unit: '%', delta: '+44pp', status: 'positive' },
|
|
380
|
+
],
|
|
381
|
+
};
|
|
382
|
+
}
|
|
383
|
+
if (kind === 'heatmap') {
|
|
384
|
+
return {
|
|
385
|
+
layout: 'heatmap',
|
|
386
|
+
title: en ? 'Regional attainment heatmap highlights Q4 acceleration' : '各大区季度目标达成率热力图凸显 Q4 全面冲刺',
|
|
387
|
+
rows: en
|
|
388
|
+
? [['Region \\ Qtr', 'Q1', 'Q2', 'Q3', 'Q4'], ['North America', 74, 82, 89, 96], ['Europe', 65, 72, 80, 88], ['APAC', 60, 76, 86, 94], ['LatAm', 44, 52, 61, 73]]
|
|
389
|
+
: [['区域 \\ 季度', 'Q1', 'Q2', 'Q3', 'Q4'], ['华东大区', 78, 84, 91, 97], ['华南大区', 68, 75, 83, 90], ['华北大区', 62, 69, 77, 85], ['海外新兴', 44, 56, 71, 88]],
|
|
390
|
+
};
|
|
391
|
+
}
|
|
320
392
|
return {
|
|
321
393
|
layout: 'bullets',
|
|
322
394
|
title: en ? 'New slide key takeaway' : '请填写本页核心结论句',
|
|
@@ -627,6 +699,14 @@ export class PptWorkbench {
|
|
|
627
699
|
const role = raw.role;
|
|
628
700
|
const conversion = raw.conversion;
|
|
629
701
|
const icon = raw.icon;
|
|
702
|
+
const avatar = raw.avatar;
|
|
703
|
+
for (const nk of ['x', 'y', 'size', 'before', 'after']) {
|
|
704
|
+
const nv = raw[nk];
|
|
705
|
+
if (nv !== undefined && (typeof nv !== 'number' || !Number.isFinite(nv)))
|
|
706
|
+
throw new Error('结构化卡片内容无效');
|
|
707
|
+
if (typeof nv === 'number')
|
|
708
|
+
clean[nk] = nv;
|
|
709
|
+
}
|
|
630
710
|
if (start !== undefined && (typeof start !== 'number' || !Number.isFinite(start) || start < 0 || start > 999))
|
|
631
711
|
throw new Error('结构化卡片内容无效');
|
|
632
712
|
if (span !== undefined && (typeof span !== 'number' || !Number.isFinite(span) || span < 0 || span > 999))
|
|
@@ -639,6 +719,8 @@ export class PptWorkbench {
|
|
|
639
719
|
throw new Error('结构化卡片内容无效');
|
|
640
720
|
if (icon !== undefined && (typeof icon !== 'string' || icon.length > 48))
|
|
641
721
|
throw new Error('结构化卡片内容无效');
|
|
722
|
+
if (avatar !== undefined && (typeof avatar !== 'string' || avatar.length > 64))
|
|
723
|
+
throw new Error('结构化卡片内容无效');
|
|
642
724
|
if (typeof start === 'number')
|
|
643
725
|
clean.start = start;
|
|
644
726
|
if (typeof span === 'number')
|
|
@@ -651,6 +733,8 @@ export class PptWorkbench {
|
|
|
651
733
|
clean.conversion = conversion.trim();
|
|
652
734
|
if (typeof icon === 'string' && icon.trim())
|
|
653
735
|
clean.icon = icon.trim();
|
|
736
|
+
if (typeof avatar === 'string' && avatar.trim())
|
|
737
|
+
clean.avatar = avatar.trim();
|
|
654
738
|
return clean;
|
|
655
739
|
});
|
|
656
740
|
}
|
|
@@ -662,11 +746,30 @@ export class PptWorkbench {
|
|
|
662
746
|
throw new Error('结构化卡片内容无效');
|
|
663
747
|
const result = {};
|
|
664
748
|
for (const [key, item] of Object.entries(raw)) {
|
|
665
|
-
if (['title', 'subtitle', 'kicker', 'takeaway', 'source', 'text', 'formula', 'notes'].includes(key)) {
|
|
749
|
+
if (['title', 'subtitle', 'kicker', 'takeaway', 'source', 'text', 'formula', 'notes', 'language', 'filename', 'url', 'xLabel', 'yLabel'].includes(key)) {
|
|
666
750
|
if (typeof item !== 'string' || item.length > 8000)
|
|
667
751
|
throw new Error('文字字段过长或无效');
|
|
668
752
|
result[key] = item;
|
|
669
753
|
}
|
|
754
|
+
else if (key === 'code') {
|
|
755
|
+
if (typeof item !== 'string' || item.length > 16000)
|
|
756
|
+
throw new Error('代码片段无效或超过 16,000 字符');
|
|
757
|
+
result.code = item;
|
|
758
|
+
}
|
|
759
|
+
else if (key === 'coverPattern') {
|
|
760
|
+
if (item !== null && item !== '' && (typeof item !== 'string' || !ALLOWED_COVER_PATTERNS.has(item)))
|
|
761
|
+
throw new Error('封面底纹名称无效');
|
|
762
|
+
result.coverPattern = item ? item : undefined;
|
|
763
|
+
}
|
|
764
|
+
else if (key === 'quadrants') {
|
|
765
|
+
if (item === null) {
|
|
766
|
+
result.quadrants = undefined;
|
|
767
|
+
continue;
|
|
768
|
+
}
|
|
769
|
+
if (!Array.isArray(item) || item.length !== 4 || item.some(q => typeof q !== 'string' || q.length > 80))
|
|
770
|
+
throw new Error('象限名称需为 4 项字符串');
|
|
771
|
+
result.quadrants = item;
|
|
772
|
+
}
|
|
670
773
|
else if (key === 'mermaid') {
|
|
671
774
|
if (typeof item !== 'string' || item.length > 16000)
|
|
672
775
|
throw new Error('Mermaid 代码无效或超过 16,000 字符');
|
|
@@ -1411,7 +1514,7 @@ export class PptWorkbench {
|
|
|
1411
1514
|
return denied;
|
|
1412
1515
|
try {
|
|
1413
1516
|
const params = new URL(request.url).searchParams, kind = params.get('kind');
|
|
1414
|
-
if (!['html', 'pptx', 'json', 'bundle', 'share', 'notes', 'handout', 'onepager', 'remotion', 'coaching', 'data', 'visual'].includes(String(kind)))
|
|
1517
|
+
if (!['html', 'pptx', 'json', 'bundle', 'share', 'notes', 'handout', 'onepager', 'remotion', 'pdf', 'png-zip', 'coaching', 'data', 'visual'].includes(String(kind)))
|
|
1415
1518
|
return fail(400, '不支持此文件类型');
|
|
1416
1519
|
const { entry, manifest, files, engine } = await this.project(params.get('id'));
|
|
1417
1520
|
if (String(manifest.revision) !== params.get('revision'))
|
|
@@ -1468,6 +1571,51 @@ export class PptWorkbench {
|
|
|
1468
1571
|
bytes = zipSync(zipEntries, { level: 0 });
|
|
1469
1572
|
name = basename(entry.path, '.json') + '-remotion.zip';
|
|
1470
1573
|
}
|
|
1574
|
+
else if (kind === 'pdf' || kind === 'png-zip') {
|
|
1575
|
+
if (!existsSync(files.pptx))
|
|
1576
|
+
return fail(400, 'PPTX 文件不存在,请先保存一次再导出');
|
|
1577
|
+
const tmpOut = join(dirname(this.catalogPath), `.export-${randomUUID()}`);
|
|
1578
|
+
try {
|
|
1579
|
+
const rendered = await engine.renderDeck({
|
|
1580
|
+
pptxPath: files.pptx,
|
|
1581
|
+
outputDir: tmpOut,
|
|
1582
|
+
format: kind === 'pdf' ? 'pdf' : 'png',
|
|
1583
|
+
width: 1440,
|
|
1584
|
+
signal: request.signal,
|
|
1585
|
+
});
|
|
1586
|
+
if (!rendered.ok) {
|
|
1587
|
+
return fail(rendered.status === 'unavailable' ? 503 : 500, rendered.message || '导出失败:当前环境未安装 @deepseek-ai/libreoffice-kit 渲染引擎 / PDF/PNG export requires @deepseek-ai/libreoffice-kit');
|
|
1588
|
+
}
|
|
1589
|
+
if (kind === 'pdf') {
|
|
1590
|
+
if (!rendered.pdfPath || !existsSync(rendered.pdfPath))
|
|
1591
|
+
return fail(400, 'PDF 渲染产物缺失');
|
|
1592
|
+
bytes = ordinaryFile(rendered.pdfPath);
|
|
1593
|
+
name = basename(entry.path, '.json') + '.pdf';
|
|
1594
|
+
}
|
|
1595
|
+
else {
|
|
1596
|
+
const pngList = Array.isArray(rendered.pngPaths) ? rendered.pngPaths : [];
|
|
1597
|
+
if (pngList.length === 0)
|
|
1598
|
+
return fail(400, 'PNG 渲染产物缺失');
|
|
1599
|
+
const zipEntries = {};
|
|
1600
|
+
let totalBytes = 0;
|
|
1601
|
+
pngList.forEach((pPath, pi) => {
|
|
1602
|
+
const buf = ordinaryFile(pPath);
|
|
1603
|
+
totalBytes += buf.byteLength;
|
|
1604
|
+
if (totalBytes > BUNDLE_LIMIT)
|
|
1605
|
+
throw new Error('PNG 图包超过 128 MiB 上限');
|
|
1606
|
+
zipEntries[`slide-${String(pi + 1).padStart(2, '0')}.png`] = buf;
|
|
1607
|
+
});
|
|
1608
|
+
bytes = zipSync(zipEntries, { level: 0 });
|
|
1609
|
+
name = basename(entry.path, '.json') + '-slides-png.zip';
|
|
1610
|
+
}
|
|
1611
|
+
}
|
|
1612
|
+
finally {
|
|
1613
|
+
try {
|
|
1614
|
+
rmSync(tmpOut, { recursive: true, force: true });
|
|
1615
|
+
}
|
|
1616
|
+
catch { /* ignore */ }
|
|
1617
|
+
}
|
|
1618
|
+
}
|
|
1471
1619
|
else if (kind === 'bundle' || kind === 'share') {
|
|
1472
1620
|
const entries = {};
|
|
1473
1621
|
let total = 0;
|
|
@@ -1505,8 +1653,8 @@ export class PptWorkbench {
|
|
|
1505
1653
|
request.signal.throwIfAborted();
|
|
1506
1654
|
if ((await this.project(entry.id)).manifest.revision !== manifest.revision)
|
|
1507
1655
|
return fail(409, '项目已被修改,请重新打开后下载');
|
|
1508
|
-
const archive = kind === 'bundle' || kind === 'share' || kind === 'remotion';
|
|
1509
|
-
const type = ['notes', 'handout', 'coaching', 'data', 'visual'].includes(String(kind)) ? 'text/markdown; charset=utf-8' : archive ? 'application/zip' : kind === 'pptx' ? 'application/vnd.openxmlformats-officedocument.presentationml.presentation' : (kind === 'html' || kind === 'onepager') ? 'text/html; charset=utf-8' : 'application/json; charset=utf-8';
|
|
1656
|
+
const archive = kind === 'bundle' || kind === 'share' || kind === 'remotion' || kind === 'png-zip';
|
|
1657
|
+
const type = ['notes', 'handout', 'coaching', 'data', 'visual'].includes(String(kind)) ? 'text/markdown; charset=utf-8' : archive ? 'application/zip' : kind === 'pdf' ? 'application/pdf' : kind === 'pptx' ? 'application/vnd.openxmlformats-officedocument.presentationml.presentation' : (kind === 'html' || kind === 'onepager') ? 'text/html; charset=utf-8' : 'application/json; charset=utf-8';
|
|
1510
1658
|
return new Response(new Uint8Array(bytes), { headers: {
|
|
1511
1659
|
'content-type': type, 'cache-control': 'no-store', 'x-content-type-options': 'nosniff',
|
|
1512
1660
|
'content-disposition': `attachment; filename="presentation.${archive ? 'zip' : ['notes', 'handout', 'coaching', 'data', 'visual'].includes(String(kind)) ? 'md' : kind === 'onepager' ? 'html' : kind}"; filename*=UTF-8''${encodeURIComponent(name)}`,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-ppt",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.28.0",
|
|
4
4
|
"description": "DeepSeek Harness 演示文稿生成与编辑工作台:输入材料即可导出离线 HTML 放映、可编辑 PPTX 与工程包,支持按页编辑、数据推演与预审演练,以及原生清透 / 米白纸感 / Claude 暖书卷 / 8-Bit 像素 / 晴空薄荷五套明亮工作台主题。欢迎提交 issues 和 PR。",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "lib/index.js",
|
package/skills/dsh-ppt/SKILL.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: dsh-ppt
|
|
3
|
-
description: "Turn one sentence, a Markdown document, structured slides, Office files (.xlsx/.csv/.docx), or a benchmark .pptx into a world-class presentation deck: standalone HTML web slideshow (with Dual-Screen Presenter Console & Executive One-Pager) + 100% native-editable PPTX (with 8 Curated Taste Recipes, 4 poster covers, 61 native <a:custGeom> vector icons, glass/frameless/editorial materiality, native <m:oMath> formulas, Mermaid flowcharts/sequences, Marimekko, Sankey, Porter Value Chain, SWOT) + project manifest + Speaker Handout. Features Zero-Question Scenario Auto-Direction (theme: auto), 24 curated themes, 8 Taste Recipes & benchmark .pptx aesthetic DNA learning (.dsh-ppt/taste-recipes.json), 6 Master Chrome Skeletons,
|
|
3
|
+
description: "Turn one sentence, a Markdown document, structured slides, Office files (.xlsx/.csv/.docx), or a benchmark .pptx into a world-class presentation deck: standalone HTML web slideshow (with Dual-Screen Presenter Console & Executive One-Pager) + 100% native-editable PPTX (with 8 Curated Taste Recipes, 4 poster covers + Hero Photo Split + coverPattern, 61 native <a:custGeom> vector icons, glass/frameless/editorial materiality, device mockups, 9-language syntax-highlighted code terminals, Magic Quadrant, Radar, Dumbbell, Heatmap, native <m:oMath> formulas, Mermaid flowcharts/sequences, Marimekko, Sankey, Porter Value Chain, SWOT) + project manifest + Speaker Handout. Features Zero-Question Scenario Auto-Direction (theme: auto), 24 curated themes, 8 Taste Recipes & benchmark .pptx aesthetic DNA learning (.dsh-ppt/taste-recipes.json), 6 Master Chrome Skeletons, 35+ native-editable layouts, 20 industry blueprints, 13 publication-grade charts with spotlight/referenceLine/growth callouts, and bilingual ZH/EN support. 中文:把一句话、文档、表格或标杆 PPTX 变成大师级演示文稿,内置 8 套大师品味配方(Taste Recipes)、设备原型 mockup、9 语言语法高亮代码窗 code、魔力象限/雷达图/哑铃图/热力图与 61 枚原生矢量图标、35+ 原生可编辑版式与标杆 PPTX 审美 DNA 持久化复用。"
|
|
4
4
|
compatibility: "Node ^22.19.0 or >=24.0.0. Images/charts/PPTX absorption use @office-kit/pptx@0.21.0; optional data models use jsep@1.4.0 and csv-parse@6.1.0. Optional PNG/PDF renderer: @deepseek-ai/libreoffice-kit@0.2.3 (bundled by DSH 0.2.2+; 0.1.5 also supported). Cross-harness: copy the full directory and run npm install --ignore-scripts there."
|
|
5
5
|
allowed-tools: "Bash, Read, Write, Edit"
|
|
6
6
|
---
|
|
@@ -3,8 +3,8 @@ import { resolve, dirname, extname, basename, join } 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, resolveLanguage, resolveDeckFileName, commitDeckArtifacts, DECK_VERSION, buildDeck } from './deck-core.mjs'
|
|
6
|
-
import { listThemes, listMasterPresets, resolveTheme, buildThemePreview as buildThemePreviewFromThemes, deriveBrandedTheme, pptxEastAsianFont } from './deck-themes.mjs'
|
|
7
|
-
import { CORE_LAYOUTS, LAYOUT_ALIASES, stripInlineMarkdown } from './deck-layouts.mjs'
|
|
6
|
+
import { listThemes, listMasterPresets, resolveTheme, resolveChromeStyle, buildThemePreview as buildThemePreviewFromThemes, deriveBrandedTheme, pptxEastAsianFont } from './deck-themes.mjs'
|
|
7
|
+
import { CORE_LAYOUTS, LAYOUT_ALIASES, stripInlineMarkdown, computeMockupGeometry, getChromeConfig } from './deck-layouts.mjs'
|
|
8
8
|
import { MEDIA_LAYOUTS, mediaBoxes, LOGO_BOX, FOOTER_BOX, normalizeChart, buildOfficeKitChartSpec, computeWaterfallGeometry } from './deck-media.mjs'
|
|
9
9
|
import { normalizeDataModel, prepareDataSlides, validateDataSnapshot, previewDataChange, dataNotes, dataReport } from './deck-data.mjs'
|
|
10
10
|
import { normalizeVisual, applyVisualActions } from './deck-visual.mjs'
|
|
@@ -222,8 +222,8 @@ function validateRawSlides(slides) {
|
|
|
222
222
|
const eff = effectiveLayout(s.layout)
|
|
223
223
|
const hasImg = Boolean(s.image || (Array.isArray(s.images) && s.images.length > 0))
|
|
224
224
|
if (s.chart && hasImg) fail(`第 ${i + 1} 页不能同时放入 image 和 chart`)
|
|
225
|
-
if (hasImg && eff && !['image', 'image-left', 'image-right'].includes(eff)) fail(`第 ${i + 1} 页图片需使用 image / image-left / image-right / gallery 布局`)
|
|
226
|
-
if (s.chart && eff && !['chart', 'chart-split'].includes(eff)) fail(`第 ${i + 1} 页图表需使用 chart / chart-split / waterfall 布局`)
|
|
225
|
+
if (hasImg && eff && !['image', 'image-left', 'image-right', 'cover', 'mockup'].includes(eff)) fail(`第 ${i + 1} 页图片需使用 image / image-left / image-right / gallery / cover / mockup 布局`)
|
|
226
|
+
if (s.chart && eff && !['chart', 'chart-split', 'radar'].includes(eff)) fail(`第 ${i + 1} 页图表需使用 chart / chart-split / waterfall / radar 布局`)
|
|
227
227
|
})
|
|
228
228
|
}
|
|
229
229
|
|
|
@@ -425,9 +425,22 @@ async function exportPptx(manifest, theme, language, signal) {
|
|
|
425
425
|
if (img?.assetId) putImage(slide, img.assetId, gBox, img.fit || 'cover', `Gallery image ${gIdx + 1}`, img.alt)
|
|
426
426
|
})
|
|
427
427
|
} else if (source.image) {
|
|
428
|
-
|
|
428
|
+
let targetBox = boxes.image
|
|
429
|
+
let targetFit = source.image.fit
|
|
430
|
+
if (source.layout === 'cover') {
|
|
431
|
+
targetBox = { x: 6.65, y: 0, w: 6.6833, h: 7.5 }
|
|
432
|
+
targetFit = source.image.fit || 'cover'
|
|
433
|
+
} else if (source.layout === 'mockup') {
|
|
434
|
+
const chromeStyle = resolveChromeStyle(theme, source, manifest.brand)
|
|
435
|
+
const chromeCfg = getChromeConfig(chromeStyle, theme)
|
|
436
|
+
const hasTakeaway = typeof source.takeaway === 'string' && source.takeaway.trim() !== ''
|
|
437
|
+
const bodyH = (hasTakeaway ? 6.08 : 6.72) - chromeCfg.bodyTopY
|
|
438
|
+
targetBox = computeMockupGeometry(source, chromeCfg.bodyTopY, bodyH).screenBox
|
|
439
|
+
targetFit = source.image.fit || 'cover'
|
|
440
|
+
}
|
|
441
|
+
putImage(slide, source.image.assetId, targetBox, targetFit, 'Slide image', source.image.alt)
|
|
429
442
|
}
|
|
430
|
-
if (source.chart) {
|
|
443
|
+
if (source.chart && source.layout !== 'radar') {
|
|
431
444
|
if (source.chart.kind === 'waterfall') {
|
|
432
445
|
if (!lib.findShapeByName(slide, 'Waterfall Bar 1')) {
|
|
433
446
|
drawNativeWaterfallWithKit(lib, slide, source.chart, boxes.chart, theme)
|
|
@@ -831,9 +844,9 @@ export async function editDeck(options = {}) {
|
|
|
831
844
|
}
|
|
832
845
|
const used = new Set()
|
|
833
846
|
const allowed = new Set([
|
|
834
|
-
'layout', 'variant', 'chrome', 'cardMaterial', 'iconMode', 'title', 'subtitle', 'kicker', 'takeaway', 'source',
|
|
835
|
-
'text', 'formula', 'mermaid', '
|
|
836
|
-
'columns', 'steps', 'quadrants', 'rows', 'notes', 'image', 'images', 'chart', 'visual',
|
|
847
|
+
'layout', 'variant', 'chrome', 'cardMaterial', 'iconMode', 'coverPattern', 'title', 'subtitle', 'kicker', 'takeaway', 'source',
|
|
848
|
+
'text', 'formula', 'mermaid', 'code', 'language', 'filename', 'url', 'xLabel', 'yLabel', 'activeIndex', 'tableStyle',
|
|
849
|
+
'bullets', 'items', 'cards', 'metrics', 'columns', 'steps', 'quadrants', 'rows', 'notes', 'image', 'images', 'chart', 'visual',
|
|
837
850
|
])
|
|
838
851
|
for (const edit of options.edits ?? []) {
|
|
839
852
|
const index = typeof edit.slide === 'number' && Number.isInteger(edit.slide) ? edit.slide - 1 : next.slides.findIndex(s => s.id === edit.slide)
|
|
@@ -850,18 +863,21 @@ export async function editDeck(options = {}) {
|
|
|
850
863
|
delete changed.items
|
|
851
864
|
}
|
|
852
865
|
if (edit.patch.chart) {
|
|
853
|
-
if (!edit.patch.layout && !['chart', 'chart-split', 'waterfall'].includes(changed.layout)) changed.layout = 'chart'
|
|
854
|
-
if (['chart', 'chart-split', 'waterfall'].includes(changed.layout)) { delete changed.image; delete changed.images }
|
|
866
|
+
if (!edit.patch.layout && !['chart', 'chart-split', 'waterfall', 'radar'].includes(changed.layout)) changed.layout = 'chart'
|
|
867
|
+
if (['chart', 'chart-split', 'waterfall', 'radar'].includes(changed.layout)) { delete changed.image; delete changed.images }
|
|
855
868
|
}
|
|
856
869
|
if (edit.patch.image || edit.patch.images) {
|
|
857
|
-
if (!edit.patch.layout && !['image', 'image-left', 'image-right', 'gallery'].includes(changed.layout)) {
|
|
870
|
+
if (!edit.patch.layout && !['image', 'image-left', 'image-right', 'gallery', 'cover', 'mockup'].includes(changed.layout)) {
|
|
858
871
|
changed.layout = Array.isArray(edit.patch.images) && edit.patch.images.length > 1 ? 'image' : 'image-right'
|
|
859
872
|
}
|
|
860
|
-
if (['image', 'image-left', 'image-right', 'gallery'].includes(changed.layout)) delete changed.chart
|
|
873
|
+
if (['image', 'image-left', 'image-right', 'gallery', 'cover', 'mockup'].includes(changed.layout)) delete changed.chart
|
|
861
874
|
}
|
|
862
875
|
if (edit.patch.layout) {
|
|
863
876
|
const eff = effectiveLayout(edit.patch.layout)
|
|
864
|
-
if (!MEDIA_LAYOUTS.has(eff)) {
|
|
877
|
+
if (!MEDIA_LAYOUTS.has(eff)) {
|
|
878
|
+
if (eff !== 'cover' && eff !== 'mockup') { delete changed.image; delete changed.images }
|
|
879
|
+
if (eff !== 'radar') { delete changed.chart }
|
|
880
|
+
}
|
|
865
881
|
}
|
|
866
882
|
validateRawSlides([changed])
|
|
867
883
|
let slides
|