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
|
@@ -0,0 +1,729 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* deck-showcase.mjs —— dsh-ppt 科技产品与工程展示版式引擎(零外部依赖)。
|
|
3
|
+
*
|
|
4
|
+
* 包含 2 大高频旗舰版式(HTML + 100% 原生可编辑 PowerPoint DrawingML 双端同构):
|
|
5
|
+
* 1. mockup(设备样机框):browser(macOS 浏览器窗口)/ mobile(灵动岛手机框)/ split(设备 + 右侧特性拆解卡)
|
|
6
|
+
* 支持在屏幕视口内直接嵌图(由 deck-advanced.mjs 注入),无图时自动渲染高质感结构化 UI/指标预览卡片。
|
|
7
|
+
* 2. code(原生语法高亮代码窗):零依赖词法高亮器支持 JS/TS/Python/SQL/Bash/JSON/YAML/Go/Rust/CSS/HTML,
|
|
8
|
+
* 渲染深色编辑器窗口(红黄绿三点 + 文件名/语言标签 + 行号槽 + 多色 OOXML <a:r> 语法高亮),
|
|
9
|
+
* 当同时提供 items/bullets 时自动切换左右分栏代码精讲模式(62% 代码窗 + 35% 要点解析卡)。
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
import { mixHex } from './deck-themes.mjs'
|
|
13
|
+
import {
|
|
14
|
+
roundRectAdj,
|
|
15
|
+
escapeXml,
|
|
16
|
+
escapeHtml,
|
|
17
|
+
renderInlineHtml,
|
|
18
|
+
computeTextFit,
|
|
19
|
+
resolveEffectiveItems,
|
|
20
|
+
ooxmlSolidFill,
|
|
21
|
+
ooxmlRichParagraph,
|
|
22
|
+
ooxmlShape,
|
|
23
|
+
ooxmlLine,
|
|
24
|
+
computeBadgePillWidth,
|
|
25
|
+
renderSurfaceCardPptx,
|
|
26
|
+
} from './deck-chrome.mjs'
|
|
27
|
+
import { normalizeIconName, resolveSemanticIcon, renderIconBadgePptx, renderIconBadgeHtml } from './deck-icons.mjs'
|
|
28
|
+
import { resolveActiveTaste } from './deck-taste.mjs'
|
|
29
|
+
|
|
30
|
+
export const SHOWCASE_LAYOUTS = new Set(['mockup', 'code'])
|
|
31
|
+
|
|
32
|
+
// ---------------------------------------------------------------------------
|
|
33
|
+
// 1. 零依赖轻量多语言词法高亮器(面向 HTML <span> 与 OOXML <a:r> 双端输出)
|
|
34
|
+
// ---------------------------------------------------------------------------
|
|
35
|
+
|
|
36
|
+
const CODE_THEME = Object.freeze({
|
|
37
|
+
bg: '#0F172A',
|
|
38
|
+
chromeBg: '#1E293B',
|
|
39
|
+
border: '#334155',
|
|
40
|
+
gutter: '#64748B',
|
|
41
|
+
plain: '#E2E8F0',
|
|
42
|
+
keyword: '#C084FC',
|
|
43
|
+
string: '#34D399',
|
|
44
|
+
comment: '#64748B',
|
|
45
|
+
number: '#FBBF24',
|
|
46
|
+
func: '#38BDF8',
|
|
47
|
+
type: '#F472B6',
|
|
48
|
+
operator: '#94A3B8',
|
|
49
|
+
})
|
|
50
|
+
|
|
51
|
+
const KEYWORDS_BY_LANG = Object.freeze({
|
|
52
|
+
js: new Set(['const', 'let', 'var', 'function', 'return', 'async', 'await', 'export', 'import', 'from', 'default', 'if', 'else', 'for', 'of', 'in', 'while', 'switch', 'case', 'break', 'new', 'class', 'extends', 'try', 'catch', 'finally', 'throw', 'typeof', 'interface', 'type', 'enum', 'implements', 'public', 'private', 'readonly', 'as', 'true', 'false', 'null', 'undefined']),
|
|
53
|
+
py: new Set(['def', 'class', 'return', 'async', 'await', 'import', 'from', 'as', 'if', 'elif', 'else', 'for', 'in', 'while', 'try', 'except', 'finally', 'with', 'yield', 'lambda', 'pass', 'raise', 'and', 'or', 'not', 'is', 'True', 'False', 'None', 'self']),
|
|
54
|
+
sql: new Set(['SELECT', 'FROM', 'WHERE', 'JOIN', 'LEFT', 'RIGHT', 'INNER', 'ON', 'GROUP', 'BY', 'ORDER', 'HAVING', 'LIMIT', 'INSERT', 'INTO', 'VALUES', 'UPDATE', 'SET', 'DELETE', 'CREATE', 'TABLE', 'INDEX', 'AS', 'AND', 'OR', 'NOT', 'IN', 'DISTINCT', 'CASE', 'WHEN', 'THEN', 'ELSE', 'END', 'WITH', 'OVER', 'PARTITION', 'DESC', 'ASC']),
|
|
55
|
+
sh: new Set(['if', 'then', 'else', 'fi', 'for', 'do', 'done', 'export', 'echo', 'cd', 'npm', 'npx', 'pnpm', 'node', 'git', 'curl', 'docker', 'kubectl', 'python', 'pip', 'set', 'local']),
|
|
56
|
+
go: new Set(['package', 'import', 'func', 'return', 'type', 'struct', 'interface', 'var', 'const', 'if', 'else', 'for', 'range', 'go', 'defer', 'chan', 'select', 'case', 'make', 'nil', 'true', 'false']),
|
|
57
|
+
rust: new Set(['fn', 'let', 'mut', 'pub', 'struct', 'enum', 'impl', 'trait', 'use', 'mod', 'match', 'if', 'else', 'for', 'in', 'while', 'async', 'await', 'return', 'Result', 'Option', 'Some', 'None', 'Ok', 'Err', 'true', 'false']),
|
|
58
|
+
})
|
|
59
|
+
|
|
60
|
+
function canonicalLang(raw) {
|
|
61
|
+
const s = String(raw ?? '').trim().toLowerCase()
|
|
62
|
+
if (/^(ts|tsx|typescript|js|jsx|javascript|mjs|cjs)$/.test(s)) return 'js'
|
|
63
|
+
if (/^(py|python)$/.test(s)) return 'py'
|
|
64
|
+
if (/^sql$/.test(s)) return 'sql'
|
|
65
|
+
if (/^(sh|bash|zsh|shell|powershell|ps1)$/.test(s)) return 'sh'
|
|
66
|
+
if (/^go(lang)?$/.test(s)) return 'go'
|
|
67
|
+
if (/^(rs|rust)$/.test(s)) return 'rust'
|
|
68
|
+
if (/^json$/.test(s)) return 'json'
|
|
69
|
+
if (/^(yml|yaml)$/.test(s)) return 'yaml'
|
|
70
|
+
return s || 'js'
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
export function tokenizeCodeLine(line, rawLang = 'ts') {
|
|
74
|
+
const lang = canonicalLang(rawLang)
|
|
75
|
+
const kwSet = KEYWORDS_BY_LANG[lang] || KEYWORDS_BY_LANG.js
|
|
76
|
+
const tokens = []
|
|
77
|
+
const text = String(line ?? '')
|
|
78
|
+
let i = 0
|
|
79
|
+
|
|
80
|
+
const push = (kind, value) => {
|
|
81
|
+
if (!value) return
|
|
82
|
+
if (tokens.length > 0 && tokens[tokens.length - 1].kind === kind) {
|
|
83
|
+
tokens[tokens.length - 1].value += value
|
|
84
|
+
} else {
|
|
85
|
+
tokens.push({ kind, value })
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
while (i < text.length) {
|
|
90
|
+
const ch = text[i]
|
|
91
|
+
const rest = text.slice(i)
|
|
92
|
+
|
|
93
|
+
// Comments
|
|
94
|
+
if (
|
|
95
|
+
((lang === 'py' || lang === 'sh' || lang === 'yaml') && ch === '#') ||
|
|
96
|
+
(lang === 'sql' && rest.startsWith('--')) ||
|
|
97
|
+
(lang !== 'py' && lang !== 'sql' && lang !== 'yaml' && rest.startsWith('//'))
|
|
98
|
+
) {
|
|
99
|
+
push('comment', rest)
|
|
100
|
+
break
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
// Strings
|
|
104
|
+
if (ch === '"' || ch === "'" || ch === '`') {
|
|
105
|
+
let j = i + 1
|
|
106
|
+
while (j < text.length) {
|
|
107
|
+
if (text[j] === '\\') { j += 2; continue }
|
|
108
|
+
if (text[j] === ch) { j += 1; break }
|
|
109
|
+
j += 1
|
|
110
|
+
}
|
|
111
|
+
const lit = text.slice(i, j)
|
|
112
|
+
if (lang === 'json' && /^\s*:/.test(text.slice(j))) {
|
|
113
|
+
push('func', lit)
|
|
114
|
+
} else {
|
|
115
|
+
push('string', lit)
|
|
116
|
+
}
|
|
117
|
+
i = j
|
|
118
|
+
continue
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
// Numbers
|
|
122
|
+
const numMatch = /^(?:0x[\da-fA-F]+|\d+(?:\.\d+)?(?:e[+-]?\d+)?)\b/.exec(rest)
|
|
123
|
+
if (numMatch && (i === 0 || !/[A-Za-z0-9_$]/.test(text[i - 1]))) {
|
|
124
|
+
push('number', numMatch[0])
|
|
125
|
+
i += numMatch[0].length
|
|
126
|
+
continue
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
// Identifiers / Keywords / Types / Functions
|
|
130
|
+
const idMatch = /^[A-Za-z_$][\w$-]*/.exec(rest)
|
|
131
|
+
if (idMatch) {
|
|
132
|
+
const word = idMatch[0]
|
|
133
|
+
const after = text.slice(i + word.length)
|
|
134
|
+
if (lang === 'sql' ? kwSet.has(word.toUpperCase()) : kwSet.has(word)) {
|
|
135
|
+
push('keyword', word)
|
|
136
|
+
} else if (lang === 'yaml' && /^\s*:/.test(after)) {
|
|
137
|
+
push('func', word)
|
|
138
|
+
} else if (/^\s*\(/.test(after)) {
|
|
139
|
+
push('func', word)
|
|
140
|
+
} else if (/^[A-Z][A-Za-z0-9_]+$/.test(word)) {
|
|
141
|
+
push('type', word)
|
|
142
|
+
} else {
|
|
143
|
+
push('plain', word)
|
|
144
|
+
}
|
|
145
|
+
i += word.length
|
|
146
|
+
continue
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
// Operators & punctuation
|
|
150
|
+
if (/[=<>!+\-*/%&|^~?:{}[\](),.;]/.test(ch)) {
|
|
151
|
+
push('operator', ch)
|
|
152
|
+
i += 1
|
|
153
|
+
continue
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
push('plain', ch)
|
|
157
|
+
i += 1
|
|
158
|
+
}
|
|
159
|
+
return tokens.length > 0 ? tokens : [{ kind: 'plain', value: ' ' }]
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
export function extractCodeSource(slide) {
|
|
163
|
+
if (typeof slide?.code === 'string' && slide.code.trim()) return slide.code.replace(/\r\n/g, '\n').trimEnd()
|
|
164
|
+
if (typeof slide?.text === 'string' && slide.text.trim()) {
|
|
165
|
+
const fenced = /^```[\w.+-]*\n([\s\S]*?)\n?```$/.exec(slide.text.trim())
|
|
166
|
+
return (fenced ? fenced[1] : slide.text).replace(/\r\n/g, '\n').trimEnd()
|
|
167
|
+
}
|
|
168
|
+
return '// Add code snippet here'
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
/**
|
|
172
|
+
* 计算设备样机屏幕视口坐标(供 deck-showcase.mjs 渲染及 deck-advanced.mjs 注入截图共用,确保 100% 对齐)。
|
|
173
|
+
*/
|
|
174
|
+
export function computeMockupGeometry(slide, bodyTopY, bodyH) {
|
|
175
|
+
const variant = String(slide?.variant || 'browser').trim().toLowerCase()
|
|
176
|
+
const items = resolveEffectiveItems(slide)
|
|
177
|
+
const hasSide = (variant === 'split' || variant === 'mobile') && items.length > 0
|
|
178
|
+
const hasImage = Boolean(slide?.image?.assetId || slide?.image?.src)
|
|
179
|
+
|
|
180
|
+
if (variant === 'mobile') {
|
|
181
|
+
const phoneW = Math.min(3.35, bodyH * 0.56)
|
|
182
|
+
const phoneH = Math.min(bodyH - 0.08, 4.78)
|
|
183
|
+
const phoneX = hasSide ? 1.12 : (13.3333 - phoneW) / 2
|
|
184
|
+
const phoneY = bodyTopY + (bodyH - phoneH) / 2
|
|
185
|
+
const pad = 0.14
|
|
186
|
+
const screenBox = {
|
|
187
|
+
x: +(phoneX + pad).toFixed(4),
|
|
188
|
+
y: +(phoneY + 0.44).toFixed(4),
|
|
189
|
+
w: +(phoneW - pad * 2).toFixed(4),
|
|
190
|
+
h: +(phoneH - 0.62).toFixed(4),
|
|
191
|
+
}
|
|
192
|
+
const sideBox = hasSide
|
|
193
|
+
? { x: 5.02, y: bodyTopY + 0.04, w: 7.68, h: bodyH - 0.08 }
|
|
194
|
+
: null
|
|
195
|
+
return { kind: 'mobile', frameBox: { x: phoneX, y: phoneY, w: phoneW, h: phoneH }, screenBox, sideBox, hasImage }
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
// browser / desktop / split
|
|
199
|
+
const isSplit = variant === 'split' || (hasSide && items.length > 0 && hasImage)
|
|
200
|
+
const frameW = isSplit ? 7.65 : 11.45
|
|
201
|
+
const frameH = Math.min(bodyH - 0.08, 4.82)
|
|
202
|
+
const frameX = isSplit ? 0.62 : (13.3333 - frameW) / 2
|
|
203
|
+
const frameY = bodyTopY + (bodyH - frameH) / 2
|
|
204
|
+
const chromeH = 0.44
|
|
205
|
+
const screenBox = {
|
|
206
|
+
x: +(frameX + 0.06).toFixed(4),
|
|
207
|
+
y: +(frameY + chromeH + 0.02).toFixed(4),
|
|
208
|
+
w: +(frameW - 0.12).toFixed(4),
|
|
209
|
+
h: +(frameH - chromeH - 0.08).toFixed(4),
|
|
210
|
+
}
|
|
211
|
+
const sideBox = isSplit
|
|
212
|
+
? { x: 8.58, y: frameY, w: 4.13, h: frameH }
|
|
213
|
+
: null
|
|
214
|
+
return { kind: 'browser', frameBox: { x: frameX, y: frameY, w: frameW, h: frameH }, chromeH, screenBox, sideBox, hasImage }
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
// ---------------------------------------------------------------------------
|
|
218
|
+
// 2. PPTX 原生 DrawingML 渲染器(mockup & code)
|
|
219
|
+
// ---------------------------------------------------------------------------
|
|
220
|
+
|
|
221
|
+
function ooxmlCodeParagraph(lineNum, tokens, sizePt, lineHeight) {
|
|
222
|
+
const numStr = String(lineNum).padStart(2, ' ') + ' '
|
|
223
|
+
const sz = Math.round(sizePt * 100)
|
|
224
|
+
const runs = [
|
|
225
|
+
`<a:r><a:rPr lang="en-US" sz="${sz}" dirty="0">${ooxmlSolidFill(CODE_THEME.gutter)}<a:latin typeface="Consolas"/><a:ea typeface="Microsoft YaHei"/></a:rPr><a:t xml:space="preserve">${escapeXml(numStr)}</a:t></a:r>`,
|
|
226
|
+
...tokens.map((tok) => {
|
|
227
|
+
const col = CODE_THEME[tok.kind] || CODE_THEME.plain
|
|
228
|
+
const boldAttr = tok.kind === 'keyword' ? ' b="1"' : ''
|
|
229
|
+
const italicAttr = tok.kind === 'comment' ? ' i="1"' : ''
|
|
230
|
+
return `<a:r><a:rPr lang="en-US" sz="${sz}"${boldAttr}${italicAttr} dirty="0">${ooxmlSolidFill(col)}<a:latin typeface="Consolas"/><a:ea typeface="Microsoft YaHei"/></a:rPr><a:t xml:space="preserve">${escapeXml(tok.value)}</a:t></a:r>`
|
|
231
|
+
}),
|
|
232
|
+
]
|
|
233
|
+
return `<a:p><a:pPr algn="l"><a:lnSpc><a:spcPct val="${Math.round(lineHeight * 100000)}"/></a:lnSpc></a:pPr>${runs.join('')}</a:p>`
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
export function renderShowcaseSlideBodyPptx(slide, ctx) {
|
|
237
|
+
const layout = slide.layout
|
|
238
|
+
if (!SHOWCASE_LAYOUTS.has(layout)) return null
|
|
239
|
+
const { theme, langAttr, chromeCfg, nextId, bodyTopY, bodyH, manifest = {} } = ctx
|
|
240
|
+
const tk = theme.tokens
|
|
241
|
+
const taste = resolveActiveTaste(manifest, slide)
|
|
242
|
+
const shapes = []
|
|
243
|
+
|
|
244
|
+
if (layout === 'code') {
|
|
245
|
+
const codeSrc = extractCodeSource(slide)
|
|
246
|
+
const rawLines = codeSrc.split('\n').slice(0, 22)
|
|
247
|
+
const langTag = String(slide.language || 'typescript').trim()
|
|
248
|
+
const fileLabel = String(slide.filename || slide.url || `snippet.${canonicalLang(langTag)}`).trim()
|
|
249
|
+
const items = Array.isArray(slide.items) && slide.items.length > 0
|
|
250
|
+
? slide.items
|
|
251
|
+
: (Array.isArray(slide.bullets) && slide.bullets.length > 0 ? resolveEffectiveItems(slide) : [])
|
|
252
|
+
const hasSide = items.length > 0 && String(slide.variant || '').toLowerCase() !== 'full'
|
|
253
|
+
|
|
254
|
+
const winW = hasSide ? 7.72 : 12.09
|
|
255
|
+
const winH = Math.min(bodyH - 0.08, 4.82)
|
|
256
|
+
const winX = 0.62
|
|
257
|
+
const winY = bodyTopY + (bodyH - winH) / 2
|
|
258
|
+
const chromeH = 0.44
|
|
259
|
+
|
|
260
|
+
// 外壳圆角深色代码窗
|
|
261
|
+
shapes.push(ooxmlShape(nextId(), 'Code Window Shell', { x: winX, y: winY, w: winW, h: winH }, {
|
|
262
|
+
preset: 'roundRect',
|
|
263
|
+
adj: roundRectAdj(winW, winH, 12),
|
|
264
|
+
fill: CODE_THEME.bg,
|
|
265
|
+
stroke: CODE_THEME.border,
|
|
266
|
+
strokePt: 1.0,
|
|
267
|
+
shadow: true,
|
|
268
|
+
}))
|
|
269
|
+
// 顶部 macOS 窗口标题栏
|
|
270
|
+
shapes.push(ooxmlShape(nextId(), 'Code Window Chrome', { x: winX, y: winY, w: winW, h: chromeH }, {
|
|
271
|
+
preset: 'roundRect',
|
|
272
|
+
adj: roundRectAdj(winW, chromeH, 10),
|
|
273
|
+
fill: CODE_THEME.chromeBg,
|
|
274
|
+
}))
|
|
275
|
+
shapes.push(ooxmlShape(nextId(), 'Code Chrome Bottom Mask', { x: winX, y: winY + chromeH - 0.14, w: winW, h: 0.14 }, {
|
|
276
|
+
preset: 'rect',
|
|
277
|
+
fill: CODE_THEME.chromeBg,
|
|
278
|
+
}))
|
|
279
|
+
shapes.push(ooxmlLine(nextId(), 'Code Chrome Rule', { x: winX, y: winY + chromeH }, { x: winX + winW, y: winY + chromeH }, {
|
|
280
|
+
color: CODE_THEME.border,
|
|
281
|
+
widthPt: 0.75,
|
|
282
|
+
}))
|
|
283
|
+
// 红黄绿交通灯圆点
|
|
284
|
+
;['#FF5F56', '#FFBD2E', '#27C93F'].forEach((dotCol, di) => {
|
|
285
|
+
shapes.push(ooxmlShape(nextId(), `Window Dot ${di + 1}`, { x: winX + 0.18 + di * 0.21, y: winY + 0.155, w: 0.13, h: 0.13 }, {
|
|
286
|
+
preset: 'ellipse',
|
|
287
|
+
fill: dotCol,
|
|
288
|
+
}))
|
|
289
|
+
})
|
|
290
|
+
// 文件名与语言徽章
|
|
291
|
+
shapes.push(ooxmlShape(nextId(), 'Code Filename', { x: winX + 0.92, y: winY + 0.06, w: winW - 2.35, h: 0.32 }, {
|
|
292
|
+
txBox: true,
|
|
293
|
+
anchor: 'ctr',
|
|
294
|
+
marginsIn: { l: 0, r: 0, t: 0, b: 0 },
|
|
295
|
+
paragraphs: [
|
|
296
|
+
ooxmlRichParagraph(fileLabel, { sizePt: 11, color: '#CBD5E1', bold: true, lang: 'en-US', font: 'Consolas' }),
|
|
297
|
+
],
|
|
298
|
+
}))
|
|
299
|
+
const langPillW = computeBadgePillWidth(langTag.toUpperCase(), 9.5, 1.5, 0.72)
|
|
300
|
+
shapes.push(ooxmlShape(nextId(), 'Code Lang Pill', { x: winX + winW - langPillW - 0.14, y: winY + 0.09, w: langPillW, h: 0.26 }, {
|
|
301
|
+
preset: 'roundRect',
|
|
302
|
+
adj: 50000,
|
|
303
|
+
fill: tk.accentPrimary,
|
|
304
|
+
fillAlpha: 0.25,
|
|
305
|
+
stroke: tk.accentPrimary,
|
|
306
|
+
strokeAlpha: 0.65,
|
|
307
|
+
strokePt: 0.6,
|
|
308
|
+
anchor: 'ctr',
|
|
309
|
+
marginsIn: { l: 0.04, r: 0.04, t: 0.01, b: 0.01 },
|
|
310
|
+
paragraphs: [
|
|
311
|
+
ooxmlRichParagraph(langTag.toUpperCase(), { sizePt: 9, color: '#E2E8F0', bold: true, lang: 'en-US', align: 'ctr', font: 'Consolas', spc: 100 }),
|
|
312
|
+
],
|
|
313
|
+
}))
|
|
314
|
+
|
|
315
|
+
// 代码内容区(自适应字号防溢出)
|
|
316
|
+
const maxLineLen = Math.max(20, ...rawLines.map((l) => l.length + 4))
|
|
317
|
+
const availCodeW = winW - 0.44
|
|
318
|
+
const availCodeH = winH - chromeH - 0.28
|
|
319
|
+
const ptByH = (availCodeH * 72) / (Math.max(1, rawLines.length) * 1.44)
|
|
320
|
+
const ptByW = (availCodeW * 72) / (maxLineLen * 0.60)
|
|
321
|
+
const codePt = Math.max(9.5, Math.min(13.5, +Math.min(ptByH, ptByW).toFixed(1)))
|
|
322
|
+
|
|
323
|
+
const codeParagraphs = rawLines.map((line, idx) =>
|
|
324
|
+
ooxmlCodeParagraph(idx + 1, tokenizeCodeLine(line, langTag), codePt, 1.38),
|
|
325
|
+
)
|
|
326
|
+
shapes.push(ooxmlShape(nextId(), 'Code Content', { x: winX + 0.20, y: winY + chromeH + 0.14, w: availCodeW, h: availCodeH }, {
|
|
327
|
+
txBox: true,
|
|
328
|
+
anchor: rawLines.length <= 10 ? 'ctr' : 't',
|
|
329
|
+
marginsIn: { l: 0.04, r: 0.04, t: 0.02, b: 0.02 },
|
|
330
|
+
paragraphs: codeParagraphs,
|
|
331
|
+
}))
|
|
332
|
+
|
|
333
|
+
// 右侧代码亮点解析卡
|
|
334
|
+
if (hasSide) {
|
|
335
|
+
const sideX = winX + winW + 0.28
|
|
336
|
+
const sideW = 12.71 - sideX
|
|
337
|
+
const shown = items.slice(0, 4)
|
|
338
|
+
const gap = 0.16
|
|
339
|
+
const cardH = (winH - gap * (shown.length - 1)) / shown.length
|
|
340
|
+
shown.forEach((it, idx) => {
|
|
341
|
+
const cy = winY + idx * (cardH + gap)
|
|
342
|
+
const box = { x: sideX, y: cy, w: sideW, h: cardH }
|
|
343
|
+
shapes.push(renderSurfaceCardPptx(`Code Note Surface ${idx + 1}`, box, {
|
|
344
|
+
fill: tk.surface1,
|
|
345
|
+
focal: idx === 0,
|
|
346
|
+
cardMaterial: taste.cardMaterial,
|
|
347
|
+
}, nextId, chromeCfg, theme))
|
|
348
|
+
const iconName = normalizeIconName(it.icon) || (taste.iconMode === 'auto' ? resolveSemanticIcon(it, idx) : '')
|
|
349
|
+
let tx = box.x + 0.18
|
|
350
|
+
if (iconName) {
|
|
351
|
+
shapes.push(renderIconBadgePptx(`Code Note Icon ${idx + 1}`, { x: tx, y: box.y + 0.16, w: 0.34, h: 0.34 }, iconName, nextId, theme, {
|
|
352
|
+
style: taste.iconBadgeStyle,
|
|
353
|
+
}))
|
|
354
|
+
tx += 0.44
|
|
355
|
+
}
|
|
356
|
+
const tagText = it.tag || String(idx + 1).padStart(2, '0')
|
|
357
|
+
shapes.push(ooxmlShape(nextId(), `Code Note ${idx + 1}`, { x: tx, y: box.y + 0.10, w: box.x + box.w - tx - 0.14, h: box.h - 0.18 }, {
|
|
358
|
+
txBox: true,
|
|
359
|
+
anchor: 'ctr',
|
|
360
|
+
marginsIn: { l: 0, r: 0, t: 0, b: 0 },
|
|
361
|
+
paragraphs: [
|
|
362
|
+
...(!iconName ? [ooxmlRichParagraph(tagText, { sizePt: 10, color: tk.accentText, bold: true, lang: 'en-US', font: theme.fonts.heading, spc: 100, spaceAfterPt: 2 })] : []),
|
|
363
|
+
...(it.title ? [ooxmlRichParagraph(it.title, { sizePt: 14, color: tk.inkPrimary, bold: true, lang: langAttr, font: theme.fonts.heading, spaceAfterPt: it.text ? 3 : 0 })] : []),
|
|
364
|
+
...(it.text ? [ooxmlRichParagraph(it.text, { sizePt: 12.5, color: tk.inkSecondary, lang: langAttr, font: theme.fonts.body, lineHeight: 1.32 })] : []),
|
|
365
|
+
],
|
|
366
|
+
}))
|
|
367
|
+
})
|
|
368
|
+
}
|
|
369
|
+
return shapes.join('')
|
|
370
|
+
}
|
|
371
|
+
|
|
372
|
+
// layout === 'mockup'
|
|
373
|
+
const geom = computeMockupGeometry(slide, bodyTopY, bodyH)
|
|
374
|
+
const items = resolveEffectiveItems(slide)
|
|
375
|
+
const urlText = String(slide.url || slide.filename || 'https://app.dsh-ppt.studio/workspace').trim()
|
|
376
|
+
|
|
377
|
+
if (geom.kind === 'mobile') {
|
|
378
|
+
const fb = geom.frameBox
|
|
379
|
+
const sb = geom.screenBox
|
|
380
|
+
// 手机深色金属外框
|
|
381
|
+
shapes.push(ooxmlShape(nextId(), 'Mobile Device Bezel', fb, {
|
|
382
|
+
preset: 'roundRect',
|
|
383
|
+
adj: roundRectAdj(fb.w, fb.h, 28),
|
|
384
|
+
fill: '#0F172A',
|
|
385
|
+
stroke: theme.dark ? '#475569' : '#334155',
|
|
386
|
+
strokePt: 2.0,
|
|
387
|
+
shadow: true,
|
|
388
|
+
}))
|
|
389
|
+
// 内部屏幕视口
|
|
390
|
+
shapes.push(ooxmlShape(nextId(), 'Mobile Screen Viewport', sb, {
|
|
391
|
+
preset: 'roundRect',
|
|
392
|
+
adj: roundRectAdj(sb.w, sb.h, 18),
|
|
393
|
+
fill: tk.canvas,
|
|
394
|
+
stroke: tk.hairline,
|
|
395
|
+
strokePt: 0.5,
|
|
396
|
+
}))
|
|
397
|
+
// 顶部灵动岛胶囊
|
|
398
|
+
const islandW = Math.min(1.05, fb.w * 0.34)
|
|
399
|
+
shapes.push(ooxmlShape(nextId(), 'Dynamic Island', { x: fb.x + (fb.w - islandW) / 2, y: fb.y + 0.17, w: islandW, h: 0.16 }, {
|
|
400
|
+
preset: 'roundRect',
|
|
401
|
+
adj: 50000,
|
|
402
|
+
fill: '#020617',
|
|
403
|
+
}))
|
|
404
|
+
// 底部 Home 指示条
|
|
405
|
+
shapes.push(ooxmlShape(nextId(), 'Home Indicator', { x: fb.x + (fb.w - 0.96) / 2, y: fb.y + fb.h - 0.12, w: 0.96, h: 0.045 }, {
|
|
406
|
+
preset: 'roundRect',
|
|
407
|
+
adj: 50000,
|
|
408
|
+
fill: '#64748B',
|
|
409
|
+
}))
|
|
410
|
+
// 无外部图片时在手机屏内绘制精简应用 UI 卡片预览
|
|
411
|
+
if (!geom.hasImage) {
|
|
412
|
+
shapes.push(ooxmlShape(nextId(), 'Mobile App Header', { x: sb.x + 0.14, y: sb.y + 0.14, w: sb.w - 0.28, h: 0.42 }, {
|
|
413
|
+
preset: 'roundRect',
|
|
414
|
+
adj: roundRectAdj(sb.w - 0.28, 0.42, 8),
|
|
415
|
+
fill: tk.accentPrimary,
|
|
416
|
+
anchor: 'ctr',
|
|
417
|
+
marginsIn: { l: 0.10, r: 0.10, t: 0.02, b: 0.02 },
|
|
418
|
+
paragraphs: [
|
|
419
|
+
ooxmlRichParagraph(slide.kicker || slide.url || 'Mobile App', { sizePt: 11, color: tk.inkOnAccent, bold: true, lang: langAttr, align: 'ctr', font: theme.fonts.heading }),
|
|
420
|
+
],
|
|
421
|
+
}))
|
|
422
|
+
const uiCards = items.slice(0, 3)
|
|
423
|
+
const cGap = 0.12
|
|
424
|
+
const cTop = sb.y + 0.68
|
|
425
|
+
const cH = (sb.h - 0.84 - cGap * Math.max(0, uiCards.length - 1)) / Math.max(1, uiCards.length)
|
|
426
|
+
uiCards.forEach((it, ci) => {
|
|
427
|
+
const cy = cTop + ci * (cH + cGap)
|
|
428
|
+
shapes.push(ooxmlShape(nextId(), `Mobile Screen Card ${ci + 1}`, { x: sb.x + 0.14, y: cy, w: sb.w - 0.28, h: cH }, {
|
|
429
|
+
preset: 'roundRect',
|
|
430
|
+
adj: roundRectAdj(sb.w - 0.28, cH, 10),
|
|
431
|
+
fill: ci === 0 ? tk.accentSoft : tk.surface1,
|
|
432
|
+
stroke: ci === 0 ? tk.accentPrimary : tk.hairline,
|
|
433
|
+
strokePt: 0.75,
|
|
434
|
+
anchor: 'ctr',
|
|
435
|
+
marginsIn: { l: 0.12, r: 0.12, t: 0.06, b: 0.06 },
|
|
436
|
+
paragraphs: [
|
|
437
|
+
...(it.value ? [ooxmlRichParagraph(it.value + (it.unit ? ' ' + it.unit : ''), { sizePt: 18, color: tk.accentText, bold: true, lang: 'en-US', font: theme.fonts.heading, spaceAfterPt: 2 })] : []),
|
|
438
|
+
ooxmlRichParagraph(it.title || it.text || '', { sizePt: 12, color: tk.inkPrimary, bold: true, lang: langAttr, font: theme.fonts.heading }),
|
|
439
|
+
],
|
|
440
|
+
}))
|
|
441
|
+
})
|
|
442
|
+
}
|
|
443
|
+
} else {
|
|
444
|
+
// macOS 浏览器窗口样机
|
|
445
|
+
const fb = geom.frameBox
|
|
446
|
+
const sb = geom.screenBox
|
|
447
|
+
const chromeH = geom.chromeH
|
|
448
|
+
shapes.push(ooxmlShape(nextId(), 'Browser Window Shell', fb, {
|
|
449
|
+
preset: 'roundRect',
|
|
450
|
+
adj: roundRectAdj(fb.w, fb.h, 12),
|
|
451
|
+
fill: tk.canvas,
|
|
452
|
+
stroke: tk.hairline,
|
|
453
|
+
strokePt: 1.0,
|
|
454
|
+
shadow: true,
|
|
455
|
+
}))
|
|
456
|
+
shapes.push(ooxmlShape(nextId(), 'Browser Top Bar', { x: fb.x, y: fb.y, w: fb.w, h: chromeH }, {
|
|
457
|
+
preset: 'roundRect',
|
|
458
|
+
adj: roundRectAdj(fb.w, chromeH, 10),
|
|
459
|
+
fill: tk.surface2,
|
|
460
|
+
}))
|
|
461
|
+
shapes.push(ooxmlShape(nextId(), 'Browser Bar Mask', { x: fb.x, y: fb.y + chromeH - 0.14, w: fb.w, h: 0.14 }, {
|
|
462
|
+
preset: 'rect',
|
|
463
|
+
fill: tk.surface2,
|
|
464
|
+
}))
|
|
465
|
+
shapes.push(ooxmlLine(nextId(), 'Browser Bar Rule', { x: fb.x, y: fb.y + chromeH }, { x: fb.x + fb.w, y: fb.y + chromeH }, {
|
|
466
|
+
color: tk.hairline,
|
|
467
|
+
widthPt: 0.75,
|
|
468
|
+
}))
|
|
469
|
+
;['#FF5F56', '#FFBD2E', '#27C93F'].forEach((dotCol, di) => {
|
|
470
|
+
shapes.push(ooxmlShape(nextId(), `Browser Dot ${di + 1}`, { x: fb.x + 0.18 + di * 0.20, y: fb.y + 0.155, w: 0.125, h: 0.125 }, {
|
|
471
|
+
preset: 'ellipse',
|
|
472
|
+
fill: dotCol,
|
|
473
|
+
}))
|
|
474
|
+
})
|
|
475
|
+
const urlW = Math.min(fb.w - 2.1, 5.4)
|
|
476
|
+
shapes.push(ooxmlShape(nextId(), 'Browser Address Bar', { x: fb.x + (fb.w - urlW) / 2, y: fb.y + 0.08, w: urlW, h: 0.28 }, {
|
|
477
|
+
preset: 'roundRect',
|
|
478
|
+
adj: 50000,
|
|
479
|
+
fill: tk.canvas,
|
|
480
|
+
stroke: tk.hairline,
|
|
481
|
+
strokePt: 0.6,
|
|
482
|
+
anchor: 'ctr',
|
|
483
|
+
marginsIn: { l: 0.10, r: 0.10, t: 0.01, b: 0.01 },
|
|
484
|
+
paragraphs: [
|
|
485
|
+
ooxmlRichParagraph(urlText, { sizePt: 10, color: tk.inkMuted, lang: 'en-US', align: 'ctr', font: 'Consolas' }),
|
|
486
|
+
],
|
|
487
|
+
}))
|
|
488
|
+
|
|
489
|
+
// 无外部图片时在浏览器视口内绘制精致模拟 SaaS 仪表盘界面(左侧导航 + 主指标/卡片)
|
|
490
|
+
if (!geom.hasImage) {
|
|
491
|
+
const navW = Math.min(1.65, sb.w * 0.21)
|
|
492
|
+
shapes.push(ooxmlShape(nextId(), 'Mockup Sidebar', { x: sb.x + 0.08, y: sb.y + 0.08, w: navW, h: sb.h - 0.16 }, {
|
|
493
|
+
preset: 'roundRect',
|
|
494
|
+
adj: roundRectAdj(navW, sb.h - 0.16, 8),
|
|
495
|
+
fill: tk.surface1,
|
|
496
|
+
stroke: tk.hairline,
|
|
497
|
+
strokePt: 0.5,
|
|
498
|
+
}))
|
|
499
|
+
const navItems = ['Overview', 'Analytics', 'Workflows', 'Settings']
|
|
500
|
+
navItems.forEach((lbl, ni) => {
|
|
501
|
+
shapes.push(ooxmlShape(nextId(), `Mockup Nav ${ni + 1}`, { x: sb.x + 0.18, y: sb.y + 0.26 + ni * 0.44, w: navW - 0.20, h: 0.34 }, {
|
|
502
|
+
preset: 'roundRect',
|
|
503
|
+
adj: roundRectAdj(navW - 0.20, 0.34, 6),
|
|
504
|
+
fill: ni === 0 ? tk.accentSoft : '',
|
|
505
|
+
anchor: 'ctr',
|
|
506
|
+
marginsIn: { l: 0.08, r: 0.06, t: 0.02, b: 0.02 },
|
|
507
|
+
paragraphs: [
|
|
508
|
+
ooxmlRichParagraph(lbl, { sizePt: 10.5, color: ni === 0 ? tk.accentText : tk.inkMuted, bold: ni === 0, lang: 'en-US', font: theme.fonts.body }),
|
|
509
|
+
],
|
|
510
|
+
}))
|
|
511
|
+
})
|
|
512
|
+
const mainX = sb.x + navW + 0.22
|
|
513
|
+
const mainW = sb.x + sb.w - mainX - 0.12
|
|
514
|
+
const uiItems = (geom.sideBox ? items.slice(0, 2) : items.slice(0, 4))
|
|
515
|
+
const cols = Math.min(2, Math.max(1, uiItems.length))
|
|
516
|
+
const rows = Math.ceil(Math.max(1, uiItems.length) / cols)
|
|
517
|
+
const cGap = 0.16
|
|
518
|
+
const cW = (mainW - cGap * (cols - 1)) / cols
|
|
519
|
+
const cH = (sb.h - 0.24 - cGap * (rows - 1)) / rows
|
|
520
|
+
uiItems.forEach((it, idx) => {
|
|
521
|
+
const col = idx % cols
|
|
522
|
+
const row = Math.floor(idx / cols)
|
|
523
|
+
const cx = mainX + col * (cW + cGap)
|
|
524
|
+
const cy = sb.y + 0.12 + row * (cH + cGap)
|
|
525
|
+
shapes.push(ooxmlShape(nextId(), `Mockup UI Card ${idx + 1}`, { x: cx, y: cy, w: cW, h: cH }, {
|
|
526
|
+
preset: 'roundRect',
|
|
527
|
+
adj: roundRectAdj(cW, cH, 10),
|
|
528
|
+
fill: idx === 0 ? tk.accentSoft : tk.surface1,
|
|
529
|
+
stroke: idx === 0 ? tk.accentPrimary : tk.hairline,
|
|
530
|
+
strokePt: 0.75,
|
|
531
|
+
anchor: 'ctr',
|
|
532
|
+
marginsIn: { l: 0.16, r: 0.16, t: 0.10, b: 0.10 },
|
|
533
|
+
paragraphs: [
|
|
534
|
+
...(it.tag ? [ooxmlRichParagraph(it.tag.toUpperCase(), { sizePt: 9.5, color: tk.accentText, bold: true, lang: 'en-US', spc: 100, spaceAfterPt: 3 })] : []),
|
|
535
|
+
...(it.value ? [ooxmlRichParagraph(it.value + (it.unit ? ' ' + it.unit : ''), { sizePt: 22, color: tk.accentText, bold: true, lang: 'en-US', font: theme.fonts.heading, spaceAfterPt: 3 })] : []),
|
|
536
|
+
...(it.title ? [ooxmlRichParagraph(it.title, { sizePt: 13.5, color: tk.inkPrimary, bold: true, lang: langAttr, font: theme.fonts.heading, spaceAfterPt: it.text ? 3 : 0 })] : []),
|
|
537
|
+
...(it.text ? [ooxmlRichParagraph(it.text, { sizePt: 11.5, color: tk.inkSecondary, lang: langAttr, font: theme.fonts.body, lineHeight: 1.32 })] : []),
|
|
538
|
+
],
|
|
539
|
+
}))
|
|
540
|
+
})
|
|
541
|
+
}
|
|
542
|
+
}
|
|
543
|
+
|
|
544
|
+
// 右侧说明栏(mobile 或 split 变体)
|
|
545
|
+
if (geom.sideBox && items.length > 0) {
|
|
546
|
+
const sb = geom.sideBox
|
|
547
|
+
const shown = items.slice(0, 4)
|
|
548
|
+
const gap = 0.18
|
|
549
|
+
const rowH = (sb.h - gap * (shown.length - 1)) / shown.length
|
|
550
|
+
shown.forEach((it, idx) => {
|
|
551
|
+
const ry = sb.y + idx * (rowH + gap)
|
|
552
|
+
const box = { x: sb.x, y: ry, w: sb.w, h: rowH }
|
|
553
|
+
shapes.push(renderSurfaceCardPptx(`Mockup Feature ${idx + 1}`, box, {
|
|
554
|
+
fill: tk.surface1,
|
|
555
|
+
focal: idx === 0,
|
|
556
|
+
cardMaterial: taste.cardMaterial,
|
|
557
|
+
}, nextId, chromeCfg, theme))
|
|
558
|
+
const iconName = normalizeIconName(it.icon) || (taste.iconMode === 'auto' ? resolveSemanticIcon(it, idx) : '')
|
|
559
|
+
let tx = box.x + 0.18
|
|
560
|
+
if (iconName) {
|
|
561
|
+
shapes.push(renderIconBadgePptx(`Mockup Feature Icon ${idx + 1}`, { x: tx, y: box.y + (box.h - 0.38) / 2, w: 0.38, h: 0.38 }, iconName, nextId, theme, {
|
|
562
|
+
style: taste.iconBadgeStyle,
|
|
563
|
+
}))
|
|
564
|
+
tx += 0.50
|
|
565
|
+
}
|
|
566
|
+
shapes.push(ooxmlShape(nextId(), `Mockup Callout ${idx + 1}`, { x: tx, y: box.y + 0.08, w: box.x + box.w - tx - 0.16, h: box.h - 0.16 }, {
|
|
567
|
+
txBox: true,
|
|
568
|
+
anchor: 'ctr',
|
|
569
|
+
marginsIn: { l: 0, r: 0, t: 0, b: 0 },
|
|
570
|
+
paragraphs: [
|
|
571
|
+
...(it.title ? [ooxmlRichParagraph(it.title, { sizePt: 14.5, color: tk.inkPrimary, bold: true, lang: langAttr, font: theme.fonts.heading, spaceAfterPt: it.text ? 3 : 0 })] : []),
|
|
572
|
+
...(it.text ? [ooxmlRichParagraph(it.text, { sizePt: 12.5, color: tk.inkSecondary, lang: langAttr, font: theme.fonts.body, lineHeight: 1.35 })] : []),
|
|
573
|
+
],
|
|
574
|
+
}))
|
|
575
|
+
})
|
|
576
|
+
}
|
|
577
|
+
|
|
578
|
+
return shapes.join('')
|
|
579
|
+
}
|
|
580
|
+
|
|
581
|
+
// ---------------------------------------------------------------------------
|
|
582
|
+
// 3. HTML 双端同构渲染器(mockup & code)
|
|
583
|
+
// ---------------------------------------------------------------------------
|
|
584
|
+
|
|
585
|
+
export function renderShowcaseSlideBodyHtml(slide, ctx = {}) {
|
|
586
|
+
const layout = slide.layout
|
|
587
|
+
if (!SHOWCASE_LAYOUTS.has(layout)) return null
|
|
588
|
+
const { manifest = {} } = ctx
|
|
589
|
+
const taste = resolveActiveTaste(manifest, slide)
|
|
590
|
+
const matClass = taste.cardMaterial && taste.cardMaterial !== 'solid' ? ` mat-${taste.cardMaterial}` : ''
|
|
591
|
+
|
|
592
|
+
if (layout === 'code') {
|
|
593
|
+
const codeSrc = extractCodeSource(slide)
|
|
594
|
+
const rawLines = codeSrc.split('\n').slice(0, 22)
|
|
595
|
+
const langTag = String(slide.language || 'typescript').trim()
|
|
596
|
+
const fileLabel = String(slide.filename || slide.url || `snippet.${canonicalLang(langTag)}`).trim()
|
|
597
|
+
const items = Array.isArray(slide.items) && slide.items.length > 0
|
|
598
|
+
? slide.items
|
|
599
|
+
: (Array.isArray(slide.bullets) && slide.bullets.length > 0 ? resolveEffectiveItems(slide) : [])
|
|
600
|
+
const hasSide = items.length > 0 && String(slide.variant || '').toLowerCase() !== 'full'
|
|
601
|
+
|
|
602
|
+
const linesHtml = rawLines.map((line, idx) => {
|
|
603
|
+
const toks = tokenizeCodeLine(line, langTag)
|
|
604
|
+
const codeHtml = toks.map((tk) => `<span class="tok-${tk.kind}">${escapeHtml(tk.value)}</span>`).join('')
|
|
605
|
+
return `<div class="code-line"><span class="code-ln">${String(idx + 1).padStart(2, ' ')}</span><span class="code-src">${codeHtml}</span></div>`
|
|
606
|
+
}).join('')
|
|
607
|
+
|
|
608
|
+
const winHtml =
|
|
609
|
+
`<div class="code-window">` +
|
|
610
|
+
`<div class="code-chrome"><span class="win-dots"><i></i><i></i><i></i></span><span class="code-file">${escapeHtml(fileLabel)}</span><span class="code-lang">${escapeHtml(langTag.toUpperCase())}</span></div>` +
|
|
611
|
+
`<pre class="code-body"><code>${linesHtml}</code></pre>` +
|
|
612
|
+
`</div>`
|
|
613
|
+
|
|
614
|
+
if (!hasSide) return `<div class="code-stage">${winHtml}</div>`
|
|
615
|
+
const notesHtml = items.slice(0, 4).map((it, idx) => {
|
|
616
|
+
const iconName = normalizeIconName(it.icon) || (taste.iconMode === 'auto' ? resolveSemanticIcon(it, idx) : '')
|
|
617
|
+
return (
|
|
618
|
+
`<div class="surface-card code-note${idx === 0 ? ' is-focal' : ''}${matClass}" data-item-index="${idx}">` +
|
|
619
|
+
(iconName ? renderIconBadgeHtml(iconName, { style: taste.iconBadgeStyle, size: 17 }) : `<span class="item-badge">${escapeHtml(it.tag || String(idx + 1).padStart(2, '0'))}</span>`) +
|
|
620
|
+
`<div class="code-note-copy">` +
|
|
621
|
+
(it.title ? `<div class="card-title" data-item-field="title">${renderInlineHtml(it.title)}</div>` : '') +
|
|
622
|
+
(it.text ? `<div class="card-body" data-item-field="text">${renderInlineHtml(it.text)}</div>` : '') +
|
|
623
|
+
`</div></div>`
|
|
624
|
+
)
|
|
625
|
+
}).join('')
|
|
626
|
+
return `<div class="code-stage is-split">${winHtml}<div class="code-notes">${notesHtml}</div></div>`
|
|
627
|
+
}
|
|
628
|
+
|
|
629
|
+
// layout === 'mockup'
|
|
630
|
+
const variant = String(slide.variant || 'browser').trim().toLowerCase()
|
|
631
|
+
const items = resolveEffectiveItems(slide)
|
|
632
|
+
const hasSide = (variant === 'split' || variant === 'mobile') && items.length > 0
|
|
633
|
+
const urlText = String(slide.url || slide.filename || 'https://app.dsh-ppt.studio/workspace').trim()
|
|
634
|
+
const rawAsset = slide.image?.assetId && manifest.assets?.[slide.image.assetId]
|
|
635
|
+
const imgData = rawAsset
|
|
636
|
+
? (String(rawAsset.data || '').startsWith('data:') ? rawAsset.data : `data:${rawAsset.mime};base64,${rawAsset.data}`)
|
|
637
|
+
: (typeof slide.image?.src === 'string' && slide.image.src.startsWith('data:image/') ? slide.image.src : '')
|
|
638
|
+
|
|
639
|
+
let deviceHtml = ''
|
|
640
|
+
if (variant === 'mobile') {
|
|
641
|
+
const innerContent = imgData
|
|
642
|
+
? `<img class="mockup-img" src="${imgData}" alt="${escapeHtml(slide.image?.alt || slide.title || '')}"/>`
|
|
643
|
+
: `<div class="mobile-ui-head">${escapeHtml(slide.kicker || 'Mobile App')}</div>` +
|
|
644
|
+
items.slice(0, 3).map((it, ci) =>
|
|
645
|
+
`<div class="mobile-ui-card${ci === 0 ? ' is-accent' : ''}">` +
|
|
646
|
+
(it.value ? `<div class="card-stat">${escapeHtml(it.value + (it.unit ? ' ' + it.unit : ''))}</div>` : '') +
|
|
647
|
+
`<div class="card-title">${renderInlineHtml(it.title || it.text || '')}</div>` +
|
|
648
|
+
`</div>`,
|
|
649
|
+
).join('')
|
|
650
|
+
deviceHtml =
|
|
651
|
+
`<div class="mockup-phone"><div class="phone-island" aria-hidden="true"></div>` +
|
|
652
|
+
`<div class="phone-screen">${innerContent}</div>` +
|
|
653
|
+
`<div class="phone-home" aria-hidden="true"></div></div>`
|
|
654
|
+
} else {
|
|
655
|
+
const innerContent = imgData
|
|
656
|
+
? `<img class="mockup-img" src="${imgData}" alt="${escapeHtml(slide.image?.alt || slide.title || '')}"/>`
|
|
657
|
+
: `<div class="browser-ui-grid"><aside class="browser-ui-nav"><span class="is-on">Overview</span><span>Analytics</span><span>Workflows</span><span>Settings</span></aside>` +
|
|
658
|
+
`<div class="browser-ui-cards">` +
|
|
659
|
+
(hasSide ? items.slice(0, 2) : items.slice(0, 4)).map((it, idx) =>
|
|
660
|
+
`<div class="browser-ui-card${idx === 0 ? ' is-accent' : ''}">` +
|
|
661
|
+
(it.tag ? `<span class="kicker">${escapeHtml(it.tag)}</span>` : '') +
|
|
662
|
+
(it.value ? `<div class="card-stat">${escapeHtml(it.value + (it.unit ? ' ' + it.unit : ''))}</div>` : '') +
|
|
663
|
+
(it.title ? `<div class="card-title">${renderInlineHtml(it.title)}</div>` : '') +
|
|
664
|
+
(it.text ? `<div class="card-body">${renderInlineHtml(it.text)}</div>` : '') +
|
|
665
|
+
`</div>`,
|
|
666
|
+
).join('') +
|
|
667
|
+
`</div></div>`
|
|
668
|
+
deviceHtml =
|
|
669
|
+
`<div class="mockup-browser">` +
|
|
670
|
+
`<div class="browser-chrome"><span class="win-dots"><i></i><i></i><i></i></span><span class="browser-url">${escapeHtml(urlText)}</span></div>` +
|
|
671
|
+
`<div class="browser-screen">${innerContent}</div></div>`
|
|
672
|
+
}
|
|
673
|
+
|
|
674
|
+
if (!hasSide) return `<div class="mockup-stage">${deviceHtml}</div>`
|
|
675
|
+
const sideHtml = items.slice(0, 4).map((it, idx) => {
|
|
676
|
+
const iconName = normalizeIconName(it.icon) || (taste.iconMode === 'auto' ? resolveSemanticIcon(it, idx) : '')
|
|
677
|
+
return (
|
|
678
|
+
`<div class="surface-card mockup-note${idx === 0 ? ' is-focal' : ''}${matClass}" data-item-index="${idx}">` +
|
|
679
|
+
(iconName ? renderIconBadgeHtml(iconName, { style: taste.iconBadgeStyle, size: 18 }) : '') +
|
|
680
|
+
`<div class="mockup-note-copy">` +
|
|
681
|
+
(it.title ? `<div class="card-title" data-item-field="title">${renderInlineHtml(it.title)}</div>` : '') +
|
|
682
|
+
(it.text ? `<div class="card-body" data-item-field="text">${renderInlineHtml(it.text)}</div>` : '') +
|
|
683
|
+
`</div></div>`
|
|
684
|
+
)
|
|
685
|
+
}).join('')
|
|
686
|
+
return `<div class="mockup-stage is-split is-${variant}">${deviceHtml}<div class="mockup-notes">${sideHtml}</div></div>`
|
|
687
|
+
}
|
|
688
|
+
|
|
689
|
+
export const SHOWCASE_CSS = `
|
|
690
|
+
/* Phase 7 Tech & Product Showcase: Device Mockups & Syntax-Highlighted Code Windows */
|
|
691
|
+
.code-stage{display:grid;grid-template-columns:1fr;gap:clamp(16px,2vw,26px);width:100%;align-items:stretch}
|
|
692
|
+
.code-stage.is-split{grid-template-columns:1.68fr 1fr}
|
|
693
|
+
.code-window{background:#0F172A;border:1px solid #334155;border-radius:12px;overflow:hidden;box-shadow:0 18px 44px rgba(2,6,23,.24);display:flex;flex-direction:column}
|
|
694
|
+
.code-chrome,.browser-chrome{display:flex;align-items:center;gap:12px;padding:10px 16px;background:#1E293B;border-bottom:1px solid #334155}
|
|
695
|
+
.browser-chrome{background:var(--surface2);border-bottom-color:var(--hairline)}
|
|
696
|
+
.win-dots{display:inline-flex;gap:6px;flex:0 0 auto}
|
|
697
|
+
.win-dots i{width:11px;height:11px;border-radius:50%;display:block}
|
|
698
|
+
.win-dots i:nth-child(1){background:#FF5F56}
|
|
699
|
+
.win-dots i:nth-child(2){background:#FFBD2E}
|
|
700
|
+
.win-dots i:nth-child(3){background:#27C93F}
|
|
701
|
+
.code-file{font-family:Consolas,"SFMono-Regular",ui-monospace,monospace;font-size:13px;font-weight:600;color:#CBD5E1;margin-right:auto}
|
|
702
|
+
.code-lang{font-family:Consolas,monospace;font-size:11px;font-weight:700;letter-spacing:.08em;padding:2px 10px;border-radius:999px;background:rgba(56,189,248,.18);border:1px solid rgba(56,189,248,.45);color:#E2E8F0}
|
|
703
|
+
.code-body{margin:0;padding:16px 20px;overflow:auto;font-family:Consolas,"SFMono-Regular",ui-monospace,monospace;font-size:clamp(12px,1.15vw,16px);line-height:1.52;color:#E2E8F0;flex:1}
|
|
704
|
+
.code-line{display:flex;gap:14px;white-space:pre}
|
|
705
|
+
.code-ln{color:#64748B;user-select:none;min-width:2ch;text-align:right}
|
|
706
|
+
.tok-keyword{color:#C084FC;font-weight:700}.tok-string{color:#34D399}.tok-comment{color:#64748B;font-style:italic}.tok-number{color:#FBBF24}.tok-func{color:#38BDF8}.tok-type{color:#F472B6}.tok-operator{color:#94A3B8}
|
|
707
|
+
.code-notes,.mockup-notes{display:flex;flex-direction:column;gap:12px;justify-content:space-between}
|
|
708
|
+
.code-note,.mockup-note{flex-direction:row;align-items:center;gap:12px;padding:14px 16px}
|
|
709
|
+
.mockup-stage{display:flex;justify-content:center;align-items:center;width:100%;gap:clamp(20px,2.8vw,38px)}
|
|
710
|
+
.mockup-stage.is-split{display:grid;grid-template-columns:1.65fr 1fr;align-items:stretch}
|
|
711
|
+
.mockup-stage.is-split.is-mobile{grid-template-columns:300px 1fr;align-items:center}
|
|
712
|
+
.mockup-browser{width:100%;background:var(--bg);border:1px solid var(--hairline);border-radius:12px;overflow:hidden;box-shadow:0 20px 48px rgba(15,23,42,.12);display:flex;flex-direction:column}
|
|
713
|
+
.browser-url{flex:1;max-width:440px;margin:0 auto;padding:4px 14px;border-radius:999px;background:var(--bg);border:1px solid var(--hairline);color:var(--muted);font-family:Consolas,monospace;font-size:12px;text-align:center;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
|
|
714
|
+
.browser-screen{padding:16px;min-height:290px;display:flex;flex-direction:column;flex:1}
|
|
715
|
+
.browser-ui-grid{display:grid;grid-template-columns:140px 1fr;gap:14px;flex:1}
|
|
716
|
+
.browser-ui-nav{background:var(--surface1);border:1px solid var(--hairline);border-radius:8px;padding:12px 10px;display:flex;flex-direction:column;gap:6px;font-size:12px;color:var(--muted)}
|
|
717
|
+
.browser-ui-nav .is-on{background:var(--accent-soft);color:var(--accent-text);font-weight:700;padding:5px 8px;border-radius:6px}
|
|
718
|
+
.browser-ui-nav span:not(.is-on){padding:5px 8px}
|
|
719
|
+
.browser-ui-cards{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:12px}
|
|
720
|
+
.browser-ui-card{background:var(--surface1);border:1px solid var(--hairline);border-radius:10px;padding:14px;display:flex;flex-direction:column;justify-content:center;gap:6px}
|
|
721
|
+
.browser-ui-card.is-accent,.mobile-ui-card.is-accent{background:var(--accent-soft);border-color:var(--accent)}
|
|
722
|
+
.mockup-phone{width:270px;background:#0F172A;border:3px solid #334155;border-radius:36px;padding:14px 12px 10px;box-shadow:0 24px 52px rgba(2,6,23,.28);display:flex;flex-direction:column;align-items:center;gap:8px;margin:0 auto}
|
|
723
|
+
.phone-island{width:84px;height:14px;border-radius:999px;background:#020617}
|
|
724
|
+
.phone-screen{width:100%;min-height:360px;background:var(--bg);border-radius:22px;padding:12px;display:flex;flex-direction:column;gap:10px;overflow:hidden}
|
|
725
|
+
.phone-home{width:88px;height:4px;border-radius:999px;background:#64748B;margin-top:2px}
|
|
726
|
+
.mobile-ui-head{background:var(--accent);color:var(--ink-on-accent);font-weight:700;font-size:12px;text-align:center;padding:8px 10px;border-radius:8px}
|
|
727
|
+
.mobile-ui-card{background:var(--surface1);border:1px solid var(--hairline);border-radius:10px;padding:10px 12px}
|
|
728
|
+
.mockup-img{width:100%;height:100%;object-fit:cover;border-radius:8px;display:block}
|
|
729
|
+
`
|