dsh-design-studio 0.13.1 → 0.15.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/lib/client.js CHANGED
@@ -32,7 +32,7 @@ window.__ModuleLoader__.load({
32
32
  return module.exports
33
33
  }
34
34
  const h = react.createElement
35
- const { useState, useEffect, useRef, useCallback } = react
35
+ const { useState, useEffect, useRef, useCallback, useMemo } = react
36
36
 
37
37
  const NS = 'dsh-design-studio'
38
38
  const TAB_ID = 'dsh-design-studio'
@@ -183,6 +183,39 @@ window.__ModuleLoader__.load({
183
183
  exShow: '整套展示图',
184
184
  exPdf: 'PDF · 每屏一页',
185
185
  exPptx: 'PPT · 每屏一页(整页图片)',
186
+ exOpts: '导出选项…',
187
+ exportedDocMiss: '已导出 {name}({n} 页,{miss} 屏没截到)',
188
+ xoTitle: '导出选项',
189
+ xoTip: '不动这里,导出的结果和直接导出一样。',
190
+ xoWarn: '有内容会被裁掉,先看一眼',
191
+ xoChecking: '正在量页面…',
192
+ xoClean: '没有会被裁掉的内容。',
193
+ xoOver: '{n} 个页面比画幅大,会被裁',
194
+ xoLong: '{n} 个页面是长页,只会截首屏',
195
+ xoLongPpt: '{n} 个页面是长页,PPT 只会截首屏',
196
+ xoLongH: '{n} 个页面比指定高度长,下面会被裁',
197
+ xoDead: '{n} 个链接点了可能没反应',
198
+ xoFail: '{n} 屏没量到,结果可能不全',
199
+ xoAgain: '重新检查',
200
+ xoGone: '设计换了,这次导出取消了',
201
+ xoResize: '按内容改画幅({size})',
202
+ xoFull: '取景改成整页',
203
+ xoLayout: '版面',
204
+ xoAuto: '跟随画幅',
205
+ xoA3: 'A3 横向',
206
+ xoCustom: '自定义',
207
+ xoCustomPh: '宽x高,比如 1920x1080',
208
+ xoView: '每页取景',
209
+ xoViewAuto: '自动',
210
+ xoViewOne: '一屏',
211
+ xoViewPage: '整页',
212
+ xoViewH: '指定高度',
213
+ xoViewHPh: '高度(像素),比如 1200',
214
+ xoCols: '拼版',
215
+ xoCols1: '每页 1 屏',
216
+ xoCols2: '每页 2 屏',
217
+ xoPdf: '导出 PDF',
218
+ xoPpt: '导出 PPT',
186
219
  exWhere: '存到设计目录的 exports/;图片还会复制到剪贴板',
187
220
  exportedDoc: '已导出 {name}({n} 页)',
188
221
  check: '设计体检',
@@ -490,6 +523,9 @@ window.__ModuleLoader__.load({
490
523
  screensHd: '屏幕',
491
524
  screensAll: '全部 {n} 屏',
492
525
  screensN: '{name} · {n} 屏',
526
+ screensHidden: '还有 {n} 屏没显示(最多显示 {max} 屏,最新的优先)',
527
+ canvasAsleep: '挪近就加载',
528
+ checkPartial: '屏太多,这次只体检了画布上加载着的 {n} 屏',
493
529
  openOther: '打开别的页面…',
494
530
  phoneOnTip: '手机预览开着',
495
531
  lookSet: '整套',
@@ -952,6 +988,39 @@ window.__ModuleLoader__.load({
952
988
  exShow: 'Showcase of all screens',
953
989
  exPdf: 'PDF · one page per screen',
954
990
  exPptx: 'PowerPoint · one slide per screen (as images)',
991
+ exOpts: 'Export options…',
992
+ exportedDocMiss: 'Exported {name} ({n} pages, {miss} screens could not be captured)',
993
+ xoTitle: 'Export options',
994
+ xoTip: 'Leave these alone and the file comes out the same as a direct export.',
995
+ xoWarn: 'Some content would be cut off. Have a look first',
996
+ xoChecking: 'Measuring pages…',
997
+ xoClean: 'Nothing will be cut off.',
998
+ xoOver: '{n} page(s) are larger than the canvas and will be cut off',
999
+ xoLong: '{n} long page(s): only the first screen is captured',
1000
+ xoLongPpt: '{n} long page(s): the PPT only captures the first screen',
1001
+ xoLongH: '{n} page(s) are taller than the set height and will be cut off',
1002
+ xoDead: '{n} link(s) may do nothing when clicked',
1003
+ xoFail: '{n} screen(s) could not be measured, so this may be incomplete',
1004
+ xoAgain: 'Check again',
1005
+ xoGone: 'The design changed, so this export was cancelled',
1006
+ xoResize: 'Fit canvas to content ({size})',
1007
+ xoFull: 'Switch to full page',
1008
+ xoLayout: 'Page size',
1009
+ xoAuto: 'Match canvas',
1010
+ xoA3: 'A3 landscape',
1011
+ xoCustom: 'Custom',
1012
+ xoCustomPh: 'WxH, e.g. 1920x1080',
1013
+ xoView: 'Each page shows',
1014
+ xoViewAuto: 'Auto',
1015
+ xoViewOne: 'One screen',
1016
+ xoViewPage: 'Full page',
1017
+ xoViewH: 'Set height',
1018
+ xoViewHPh: 'Height in px, e.g. 1200',
1019
+ xoCols: 'Per page',
1020
+ xoCols1: '1 screen',
1021
+ xoCols2: '2 screens',
1022
+ xoPdf: 'Export PDF',
1023
+ xoPpt: 'Export PPT',
955
1024
  exWhere: 'Saved to exports/ in the design folder; images are also copied to the clipboard',
956
1025
  exportedDoc: 'Exported {name} ({n} pages)',
957
1026
  check: 'Design check',
@@ -1258,6 +1327,9 @@ window.__ModuleLoader__.load({
1258
1327
  screensHd: 'Screens',
1259
1328
  screensAll: 'All {n}',
1260
1329
  screensN: '{name} · {n} screens',
1330
+ screensHidden: '{n} more not shown (up to {max} screens, newest first)',
1331
+ canvasAsleep: 'Move closer to load',
1332
+ checkPartial: 'Too many screens: checked only the {n} loaded on the canvas',
1261
1333
  openOther: 'Open another page…',
1262
1334
  phoneOnTip: 'Phone preview is on',
1263
1335
  lookSet: 'Overall',
@@ -1702,6 +1774,8 @@ window.__ModuleLoader__.load({
1702
1774
  .ddp-menu{position:absolute;right:0;top:33px;min-width:196px;padding:5px;border-radius:11px;background:var(--dsw-alias-bg-layer-1);
1703
1775
  box-shadow:0 12px 32px rgba(0,0,0,.24),0 0 0 .5px var(--dsw-alias-border-l3);animation:ddp-in .16s ${EASE}}
1704
1776
  .ddp-menu .hd{padding:5px 9px 4px;color:var(--dsw-alias-label-tertiary);font-size:11px}
1777
+ .ddp-menu .nt{padding:5px 9px 4px;color:var(--dsw-alias-label-tertiary);font-size:11px;line-height:1.5}
1778
+ .ddp-addr em.hid{flex:none;font-style:normal;font-size:11px;color:var(--dsw-alias-label-tertiary)}
1705
1779
  .ddp-menu a{display:flex;align-items:center;gap:9px;height:30px;padding:0 9px;border-radius:7px;color:var(--dsw-alias-label-primary);text-decoration:none}
1706
1780
  .ddp-menu a:hover{background:var(--dsw-alias-interactive-bg-hover,rgba(127,127,127,.12))}
1707
1781
  .ddp-menu a svg{width:15px;height:15px;flex:none;color:var(--dsw-alias-label-secondary)}
@@ -1758,6 +1832,7 @@ window.__ModuleLoader__.load({
1758
1832
  .ddp-world{position:absolute;left:0;top:0;transform-origin:0 0;will-change:transform}
1759
1833
  .ddp-world.anim{transition:transform .45s ${EASE}}
1760
1834
  .ddp-cell{position:absolute;transition:left .45s ${EASE},top .45s ${EASE};animation:ddp-cell .5s ${EASE}}
1835
+ .ddp-canvas.heavy .ddp-cell{transition:none;will-change:translate,scale}
1761
1836
  @keyframes ddp-cell{from{opacity:0;scale:.94}}
1762
1837
  .ddp-cell.sel>.ddp-dev{outline:calc(2px / var(--z)) solid ${ACCENT};outline-offset:calc(5px / var(--z))}
1763
1838
  .ddp-shield{position:absolute;inset:0;z-index:6;cursor:default}
@@ -2325,6 +2400,17 @@ window.__ModuleLoader__.load({
2325
2400
  .ddp-lib .seg button:hover,.ddp-homebar .seg button:hover{color:var(--dsw-alias-label-primary)}
2326
2401
  .ddp-lib .seg button.on,.ddp-homebar .seg button.on{background:var(--dsw-alias-bg-layer-1);color:var(--dsw-alias-label-primary);box-shadow:0 1px 2px rgba(0,0,0,.12)}
2327
2402
  .ddp-lib>.bd{flex:1;min-height:0;overflow:auto;padding:14px}
2403
+ .ddp-xo .seg{display:flex;flex-wrap:wrap;gap:4px;margin:0 6px}
2404
+ .ddp-xo .seg button{height:26px;padding:0 9px;border:1px solid var(--dsw-alias-separator-primary,rgba(127,127,127,.3));border-radius:7px;background:transparent;color:var(--dsw-alias-label-secondary);font:inherit;font-size:12px;cursor:pointer}
2405
+ .ddp-xo .seg button:hover{background:var(--dsw-alias-interactive-bg-hover,rgba(127,127,127,.12));color:var(--dsw-alias-label-primary)}
2406
+ .ddp-xo .seg button.on{border-color:${ACCENT};background:color-mix(in srgb,${ACCENT} 10%,transparent);color:var(--dsw-alias-label-primary)}
2407
+ .ddp-xo .chk{margin:4px 6px 0;padding:8px 10px;border-radius:10px;background:var(--dsw-alias-bg-layer-2);font-size:12px;line-height:1.55;color:var(--dsw-alias-label-secondary)}
2408
+ .ddp-xo .chk.warn{background:color-mix(in srgb,var(--dsw-alias-state-error-primary,#d54941) 9%,transparent);color:var(--dsw-alias-label-primary)}
2409
+ .ddp-xo .chk p{margin:0}
2410
+ .ddp-xo .chk p+p,.ddp-xo .chk .lk{margin-top:4px}
2411
+ .ddp-xo .chk .lk{display:block;text-align:left}
2412
+ .ddp-xo input.who.bad{border-color:var(--dsw-alias-state-error-primary,#d54941)}
2413
+ .ddp-ghost{position:fixed;left:0;top:0;width:100vw;height:100vh;overflow:hidden;opacity:0;pointer-events:none;z-index:-1}
2328
2414
  .ddp-pack .lk{border:0;padding:0;background:transparent;color:${ACCENT};font:inherit;cursor:pointer}
2329
2415
  .ddp-pack .lk:hover{text-decoration:underline;text-underline-offset:2px}
2330
2416
  .ddp-pack input.who{display:block;width:calc(100% - 16px);box-sizing:border-box;height:28px;margin:6px 8px 0;padding:0 9px;border:1px solid var(--dsw-alias-separator-primary,rgba(127,127,127,.3));border-radius:8px;background:var(--dsw-alias-bg-layer-1);color:var(--dsw-alias-label-primary);font:12px inherit;outline:none}
@@ -3470,7 +3556,7 @@ ${Object.entries(CHIP_ICON).map(([k, d]) => `[data-composer-chip="${chipSrc(k)}"
3470
3556
  const NOT_STYLE_FENG = /通风|台风|新风(系统|机|量)|风险|风控|风景|风扇|风味|风暴|风光|风速|风向|风筝|风铃|风车|吹风|防风|挡风|避风|屏风|旋风|狂风|微风|寒风|疾风|顺风|逆风|作风|中风|风湿|风水/g
3471
3557
  const SAID_STYLE = /风格|配色|色调|主色|色系|[^\s。,,、::;;((]风|\b(style|styled|aesthetic|vibe|palette|colou?r scheme|look and feel)\b/i
3472
3558
  // 「风格你定」「配色:随意」「any style」:等于没说(「配色定为蓝白」是说了)
3473
- const STYLE_FREE = /(风格|配色|色调|主色)[::]?\s?(你定|您定|你来定|您来定|你决定|你看着办|随意|随便|不限|都行|无所谓|自由发挥)|\b(any|whatever)\s(style|colou?rs?|palette)\b|\b(style|colou?rs?|palette)\s(is\s)?up\sto\syou\b/gi
3559
+ const STYLE_FREE = /(风格|配色|色调|主色)\s*(?:[::]\s*)?(你定|您定|你来定|您来定|你决定|你看着办|随意|随便|不限|都行|无所谓|自由发挥)|\b(any|whatever)\s(style|colou?rs?|palette)\b|\b(style|colou?rs?|palette)\s(is\s)?up\sto\syou\b/gi
3474
3560
  function autoStyle(text, kind) {
3475
3561
  const s = String(text || '')
3476
3562
  if (!s.trim()) return null
@@ -4319,7 +4405,7 @@ ${Object.entries(CHIP_ICON).map(([k, d]) => `[data-composer-chip="${chipSrc(k)}"
4319
4405
  H = Math.max(H, h)
4320
4406
  }
4321
4407
  if (!W) return ''
4322
- // 一组屏共用一个画幅:别的屏量不出比默认大(正好默认大小的也报不出来),画幅不能比默认小,不然它们被裁
4408
+ // 一组屏共用一个画幅:别的屏量不出比默认大,画幅不能比默认小,不然它们被裁
4323
4409
  return list.length > 1 ? `${Math.max(W, dw)}x${Math.max(H, dh)}` : `${W}x${H}`
4324
4410
  }
4325
4411
 
@@ -4338,6 +4424,15 @@ ${Object.entries(CHIP_ICON).map(([k, d]) => `[data-composer-chip="${chipSrc(k)}"
4338
4424
  const LAB = 34 // 每屏上面标题占的高度(屏幕像素,不跟着缩放)
4339
4425
  const GAP = 18 // 两屏之间最少隔开的屏幕像素
4340
4426
  const clampZ = (z) => Math.max(ZMIN, Math.min(ZMAX, z))
4427
+ const HEAVY_N = 12 // 超过这么多屏,画布按「重」的来:拖宽度时只挪镜头、列数变了才重排,换行动画走合成层(不然所有 iframe 每一帧都按新比例重绘,整个窗口跟着闪)
4428
+ const LIVE_MAX = 24 // 同时跑几个 iframe。超过这么多屏,画布只挂镜头附近的(选中的那屏总在),导出时分批挂
4429
+ /** 该挂着的几屏:离镜头中心最近的 max 屏,选中的那屏排最前。cx、cy 是镜头中心在画布上的坐标 */
4430
+ function nearestLive(ids, pos, dw, dh, cx, cy, selId, max, prev) {
4431
+ // 挂着的优先留着:镜头稍微挪一点,边上那几屏别来回撤了又载
4432
+ const rows = ids.map((id, i) => ({ id, d: id === selId ? -1 : ((pos[i].x + dw / 2 - cx) ** 2 + (pos[i].y + dh / 2 - cy) ** 2) * (prev && prev.has(id) ? 0.5 : 1) }))
4433
+ rows.sort((a, b) => a.d - b.d)
4434
+ return new Set(rows.slice(0, max).map((x) => x.id))
4435
+ }
4341
4436
 
4342
4437
  /**
4343
4438
  * n 屏排成网格:试每种列数,挑缩进舞台后最大的那种。
@@ -5087,6 +5182,14 @@ ${Object.entries(CHIP_ICON).map(([k, d]) => `[data-composer-chip="${chipSrc(k)}"
5087
5182
  postTo(curRef.current, { type: 'check', id, kind, quiet: !!quiet })
5088
5183
  setTimeout(() => { if (caps.current.has(id)) { caps.current.delete(id); reject(new Error('timeout')) } }, 15000)
5089
5184
  }),
5185
+ // 导出前预检:页面实际多大、有几个点了没反应的链接
5186
+ measure: () => new Promise((resolve, reject) => {
5187
+ if (!curRef.current) { reject(new Error('not loaded')); return }
5188
+ const id = `${Date.now()}-${++seq}`
5189
+ caps.current.set(id, { resolve, reject })
5190
+ postTo(curRef.current, { type: 'measure', id })
5191
+ setTimeout(() => { if (caps.current.has(id)) { caps.current.delete(id); reject(new Error('timeout')) } }, 8000)
5192
+ }),
5090
5193
  checkFocus: (i) => { if (curRef.current) postTo(curRef.current, { type: 'checkFocus', i }) },
5091
5194
  checkClear: () => { if (curRef.current) postTo(curRef.current, { type: 'checkClear' }) },
5092
5195
  unpin: () => { if (curRef.current) postTo(curRef.current, { type: 'unpin' }) }, // 去掉「已选」虚线框
@@ -5297,6 +5400,7 @@ ${Object.entries(CHIP_ICON).map(([k, d]) => `[data-composer-chip="${chipSrc(k)}"
5297
5400
  if (isCur && p.onEditDone) p.onEditDone()
5298
5401
  break
5299
5402
  case 'checked':
5403
+ case 'measured':
5300
5404
  case 'captured': {
5301
5405
  const c = caps.current.get(d.id)
5302
5406
  if (c) {
@@ -6442,7 +6546,7 @@ ${Object.entries(CHIP_ICON).map(([k, d]) => `[data-composer-chip="${chipSrc(k)}"
6442
6546
  items.push(['raw', I.image, t('exRaw', n)])
6443
6547
  if (kind !== 'poster' && kind !== 'slides') items.push(['long', I.long, t('exLong', n)]) // 海报、幻灯片画幅是定的,没有「整页」
6444
6548
  if (count > 1) items.push(['show', I.canvas, t('exShow')])
6445
- items.push(['pdf', I.pdf, t('exPdf')], ['pptx', I.deck, t('exPptx')])
6549
+ items.push(['pdf', I.pdf, t('exPdf')], ['pptx', I.deck, t('exPptx')], ['opts', I.sliders, t('exOpts')])
6446
6550
  return items
6447
6551
  }
6448
6552
 
@@ -6546,7 +6650,7 @@ ${Object.entries(CHIP_ICON).map(([k, d]) => `[data-composer-chip="${chipSrc(k)}"
6546
6650
  }
6547
6651
 
6548
6652
  // 左上屏名 ▾:换屏(画布 / 某一屏)、多尺寸、类型、打开别的页面——「在看什么、怎么看」都在这一个菜单里
6549
- function ScreenMenu({ t, label, title, tip, src, busy, list, cur, canvas, open, setOpen, onPick, onAll, onOther, sizes, kind, onKind }) {
6653
+ function ScreenMenu({ t, label, title, tip, src, busy, list, cur, canvas, open, setOpen, onPick, onAll, onOther, sizes, kind, onKind, hidden, hiddenText }) {
6550
6654
  const ref = useRef(null)
6551
6655
  useDismiss(open, setOpen, ref)
6552
6656
  const n = list.length
@@ -6555,12 +6659,14 @@ ${Object.entries(CHIP_ICON).map(([k, d]) => `[data-composer-chip="${chipSrc(k)}"
6555
6659
  h('button', { className: 'ddp-addr' + (open ? ' sel' : ''), ...(tip ? tipA(tip[0], tip[1]) : { title: title || t('screensT') }), 'data-src': src || undefined, 'aria-haspopup': 'menu', 'aria-expanded': open, onClick: () => setOpen(!open) },
6556
6660
  h('i', { className: 'ddp-dot' + (busy ? ' wait' : '') }),
6557
6661
  (() => { const m = /^(.+?)( · [^·]+)$/.exec(label || ''); return m ? h('span', { className: 'lb2' }, h('b', null, m[1]), h('em', null, m[2])) : h('span', null, label) })(),
6662
+ hidden ? h('em', { className: 'hid', title: hiddenText }, '+' + hidden) : null,
6558
6663
  h(I.caret)),
6559
6664
  open ? h('div', { className: 'ddp-menu l', role: 'menu' },
6560
6665
  h('div', { className: 'hd' }, n > 1 ? t('screensHd') : t('screensT')),
6561
6666
  h('button', { className: canvas && !(sizes && sizes.on) ? 'sel' : '', role: 'menuitemradio', 'aria-checked': canvas, onClick: close(onAll) }, h(I.canvas), h('span', null, t('canvasShort')), n > 1 ? h('em', null, t('screensAll', { n })) : null),
6562
6667
  h('div', { className: 'ls' }, ...list.map((x) => h('button', { key: x.key, className: !canvas && !(sizes && sizes.on) && x.key === cur ? 'sel' : '', role: 'menuitemradio', 'aria-checked': !canvas && x.key === cur, title: x.key, onClick: close(() => onPick(x.key)) },
6563
6668
  h(I.single), h('span', null, x.label)))),
6669
+ hidden ? h('div', { className: 'nt' }, hiddenText) : null,
6564
6670
  sizes ? h('div', { className: 'sp', role: 'separator' }) : null,
6565
6671
  sizes ? h('button', { className: sizes.on ? 'sel' : '', role: 'menuitemcheckbox', 'aria-checked': !!sizes.on, disabled: !!sizes.off, title: sizes.tip, onClick: close(sizes.run) }, h(I.sizes), h('span', null, t('sizesShort')), sizes.note ? h('em', null, sizes.note) : null) : null,
6566
6672
  onKind ? h('div', { className: 'hd' }, t('kind')) : null,
@@ -7118,6 +7224,101 @@ ${Object.entries(CHIP_ICON).map(([k, d]) => `[data-composer-chip="${chipSrc(k)}"
7118
7224
  }
7119
7225
 
7120
7226
  /** 打成 zip:选授权 → 检查 → 过了存到「下载」,没过列出来交给模型改 */
7227
+ /**
7228
+ * 导出前预检:list 是各屏量到的大小,limit 是每页取到多高(0 = 一屏,Infinity = 整页)。
7229
+ * over 比画幅大(横向永远会被裁;幻灯片、海报竖向也算);long 长页只截到一部分;dead 点了没反应的链接
7230
+ */
7231
+ function precheckOf(list, kind, limit) {
7232
+ const fixed = kind === 'slides' || kind === 'poster'
7233
+ const r = { over: 0, long: 0, dead: 0, fail: 0 }
7234
+ for (const m of list) {
7235
+ if (m.failed) { r.fail++; continue }
7236
+ const tall = m.pageH > (limit || m.h) + 2
7237
+ if (m.pageW > m.w + 2 || (fixed && tall)) r.over++
7238
+ if (!fixed && tall) r.long++
7239
+ const from = limit ? 0 : m.sy || 0 // 一屏:只看现在看得到的那段
7240
+ const to = limit || from + m.h
7241
+ r.dead += (Array.isArray(m.dead) ? m.dead : []).filter((y) => y >= from && y < to).length
7242
+ }
7243
+ return r
7244
+ }
7245
+
7246
+ /** 「按内容改画幅」改成多大:'宽x高',不用改或改不了返回 ''。幻灯片、海报按量到的版面,别的只把宽度加上去;竖着堆了好几页的不改高 */
7247
+ function fitCanvas(list, kind, size) {
7248
+ const fixed = kind === 'slides' || kind === 'poster'
7249
+ let [W, H] = size
7250
+ for (const m of list) {
7251
+ if (m.failed) continue
7252
+ if (fixed && Array.isArray(m.natural)) { W = Math.max(W, m.natural[0]); H = Math.max(H, m.natural[1]) } else if (m.pageW > m.w + 2) W = Math.max(W, m.pageW)
7253
+ }
7254
+ return (W === size[0] && H === size[1]) || W > 8000 || H > 8000 ? '' : `${W}x${H}`
7255
+ }
7256
+
7257
+ const layoutOk = (s) => { const m = /^\s*(\d{3,4})\s*[x×*]\s*(\d{3,4})\s*$/.exec(String(s || '')); return !!m && +m[1] >= 200 && +m[2] >= 200 && +m[1] <= 8000 && +m[2] <= 8000 }
7258
+ const fitHOk = (s) => /^\d{3,5}$/.test(String(s).trim()) && +s >= 200 && +s <= 30000
7259
+
7260
+ /** 按高度裁一张截图:h 是图对应的 CSS 高度 */
7261
+ function cropImg(img, h, maxH) {
7262
+ const c = document.createElement('canvas')
7263
+ c.width = img.width
7264
+ c.height = Math.round(img.height * maxH / h)
7265
+ c.getContext('2d').drawImage(img, 0, 0)
7266
+ return c
7267
+ }
7268
+
7269
+ function ExportPanel({ t, kind, size, opts, setOpts, screens, rev, measure, onResize, onExport, onClose }) {
7270
+ const [list, setList] = useState(null)
7271
+ const [working, setWorking] = useState(false)
7272
+ const [again, setAgain] = useState(0)
7273
+ const firstRun = useRef(true)
7274
+ useEffect(() => {
7275
+ let off = false
7276
+ setList(null)
7277
+ const first = firstRun.current
7278
+ firstRun.current = false
7279
+ // 页面刚改过:等它重新载入再量
7280
+ const timer = setTimeout(() => {
7281
+ measure().then((l) => { if (!off) setList(l) }, () => { if (!off) setList([{ failed: true }]) })
7282
+ }, first ? 0 : 900)
7283
+ return () => { off = true; clearTimeout(timer) }
7284
+ }, [size.join('x'), screens, rev, again])
7285
+ const limit = opts.fit === 'page' ? Infinity : opts.fit === 'height' && fitHOk(opts.fitH) ? +opts.fitH : 0
7286
+ const rep = list ? precheckOf(list, kind, limit) : null
7287
+ const canFit = list ? fitCanvas(list, kind, size) : ''
7288
+ const cut = rep && (rep.over || rep.long)
7289
+ const longKey = opts.fit === 'height' ? 'xoLongH' : !opts.fit && (kind === 'web' || kind === 'email') ? 'xoLongPpt' : 'xoLong'
7290
+ const seg = (k, items) => h('div', { className: 'seg', role: 'radiogroup' }, ...items.map(([v, label]) => h('button', { key: String(v), type: 'button', role: 'radio', 'aria-checked': opts[k] === v, className: opts[k] === v ? 'on' : '', onClick: () => setOpts({ ...opts, [k]: v }) }, label)))
7291
+ const bad = (opts.layout === 'custom' && !layoutOk(opts.custom)) || (opts.fit === 'height' && !fitHOk(opts.fitH))
7292
+ const go = async (format) => {
7293
+ setWorking(true)
7294
+ try { await onExport(format) } finally { setWorking(false) }
7295
+ }
7296
+ return h('div', { className: 'ddp-tokens ddp-pack ddp-xo', onPointerDown: (e) => e.stopPropagation() },
7297
+ h('header', null, h(I.sliders), h('b', null, t('xoTitle')), h('button', { className: 'ddp-btn', title: '×', onClick: onClose }, h(I.close))),
7298
+ h('p', { className: 'tip' }, t('xoTip')),
7299
+ h('div', { className: 'bd' },
7300
+ !rep ? h('div', { className: 'chk' }, h('p', null, t('xoChecking'))) : h('div', { className: 'chk' + (cut ? ' warn' : '') },
7301
+ rep.over ? h('p', null, t('xoOver', { n: rep.over })) : null,
7302
+ rep.long ? h('p', null, t(longKey, { n: rep.long })) : null,
7303
+ rep.dead ? h('p', null, t('xoDead', { n: rep.dead })) : null,
7304
+ rep.fail ? h('p', null, t('xoFail', { n: rep.fail })) : null,
7305
+ !cut && !rep.dead && !rep.fail ? h('p', null, t('xoClean')) : null,
7306
+ rep.over && canFit ? h('button', { className: 'lk', onClick: () => onResize(canFit) }, t('xoResize', { size: canFit.replace('x', '×') })) : null,
7307
+ rep.long && opts.fit !== 'page' ? h('button', { className: 'lk', onClick: () => setOpts({ ...opts, fit: 'page' }) }, t('xoFull')) : null,
7308
+ h('button', { className: 'lk', onClick: () => setAgain((n) => n + 1) }, t('xoAgain'))),
7309
+ h('h4', null, t('xoLayout')),
7310
+ seg('layout', [['auto', t('xoAuto')], ['16:9', '16:9'], ['4:3', '4:3'], ['a3', t('xoA3')], ['custom', t('xoCustom')]]),
7311
+ opts.layout === 'custom' ? h('input', { className: 'who' + (opts.custom && !layoutOk(opts.custom) ? ' bad' : ''), value: opts.custom, maxLength: 11, placeholder: t('xoCustomPh'), 'aria-label': t('xoCustom'), onChange: (e) => setOpts({ ...opts, custom: e.target.value }) }) : null,
7312
+ h('h4', null, t('xoView')),
7313
+ seg('fit', [['', t('xoViewAuto')], ['view', t('xoViewOne')], ['page', t('xoViewPage')], ['height', t('xoViewH')]]),
7314
+ opts.fit === 'height' ? h('input', { className: 'who' + (opts.fitH && !fitHOk(opts.fitH) ? ' bad' : ''), value: opts.fitH, maxLength: 5, inputMode: 'numeric', placeholder: t('xoViewHPh'), 'aria-label': t('xoViewH'), onChange: (e) => setOpts({ ...opts, fitH: e.target.value }) }) : null,
7315
+ h('h4', null, t('xoCols')),
7316
+ seg('cols', [[1, t('xoCols1')], [2, t('xoCols2')]])),
7317
+ h('footer', { className: 'row' },
7318
+ h('button', { disabled: working || bad, onClick: () => go('pptx') }, h('span', null, t('xoPpt'))),
7319
+ h('button', { className: 'go', disabled: working || bad, onClick: () => go('pdf') }, h('span', null, t('xoPdf')))))
7320
+ }
7321
+
7121
7322
  function PackPanel({ t, sid, root, onFix, onSay, onClose }) {
7122
7323
  const [lic, setLic] = useState('CC0-1.0')
7123
7324
  // CC BY 要署名:填过一次记住(只存在这台电脑的浏览器里)
@@ -7253,6 +7454,21 @@ ${Object.entries(CHIP_ICON).map(([k, d]) => `[data-composer-chip="${chipSrc(k)}"
7253
7454
  issues.more ? h('p', null, t('pkMore', { n: issues.more })) : null)))
7254
7455
  }
7255
7456
 
7457
+ const GHOST_CELL = '__ghost'
7458
+ const cellsOf = (world) => [...world.children].filter((el) => el.dataset && el.dataset.cell)
7459
+ const labOf = (cell) => cell.querySelector(':scope > .ddp-lab')
7460
+ // 换行前记下画面现在的样子(正在滑的也算):每格的屏幕位置、标题的反向缩放、底纹点阵
7461
+ function snapStage(stage, world) {
7462
+ const bg = getComputedStyle(stage)
7463
+ return {
7464
+ bg: { backgroundSize: bg.backgroundSize, backgroundPosition: bg.backgroundPosition },
7465
+ cells: new Map(cellsOf(world).map((el) => {
7466
+ const lab = labOf(el)
7467
+ return [el.dataset.cell, { rect: el.getBoundingClientRect(), lab: lab ? getComputedStyle(lab).transform : '' }]
7468
+ })),
7469
+ }
7470
+ }
7471
+
7256
7472
  function Canvas(props) {
7257
7473
  const { t, screens, kind, size, ghost, picking, sel, labelOf } = props
7258
7474
  const ref = useRef(null)
@@ -7262,12 +7478,17 @@ ${Object.entries(CHIP_ICON).map(([k, d]) => `[data-composer-chip="${chipSrc(k)}"
7262
7478
  const [drag, setDrag] = useState(false)
7263
7479
  const [zoomMenu, setZoomMenu] = useState(false)
7264
7480
  const auto = useRef(true)
7481
+ const liveCam = useRef(null) // 拖宽度时直接写到画布上的镜头,React 的 cam 还没追上;平移、缩放要从画面上的这个算
7265
7482
  const camRef = useRef(cam)
7266
- camRef.current = cam
7483
+ camRef.current = liveCam.current || cam
7267
7484
  const lastTap = useRef({ key: '', at: 0 })
7268
7485
  const f = FRAME[kind] || FRAME.web
7269
7486
  const [dw, dh] = deviceBox(kind, size)
7270
7487
  const n = screens.length + (ghost ? 1 : 0)
7488
+ const heavy = !props.items && screens.length > HEAVY_N
7489
+ const heavyRef = useRef(heavy)
7490
+ heavyRef.current = heavy
7491
+ const worldRef = useRef(null)
7271
7492
  // 多尺寸:每块自己的类型和大小(items[i] = { kind, size })
7272
7493
  const items = props.items || null
7273
7494
  const boxes = items ? items.map((it) => deviceBox(it.kind, it.size)) : null
@@ -7280,24 +7501,177 @@ ${Object.entries(CHIP_ICON).map(([k, d]) => `[data-composer-chip="${chipSrc(k)}"
7280
7501
  const vw = box.w - ins
7281
7502
  const layoutKey = L ? [n, L.cols, dw, dh, box.w, box.h, rt, bh, ins, boxes ? boxes.join(';') : ''].join('|') : ''
7282
7503
  const fitAt = () => { const c = fitCam(L, vw, bh); return { ...c, y: c.y + rt } }
7504
+ // 屏多时拖宽度:新镜头直接写到画布上,不走 React,也不动 --z,这样既跟手又不让 iframe 每帧重绘。
7505
+ // 列数变了(或者松手了)才真重排:先记下每格现在在屏幕上的样子,镜头和格子一次换好,再从记下的样子滑过去,中间没有哪一帧会跳。返回有没有真重排
7506
+ const followRef = useRef(null)
7507
+ const flipFirst = useRef(null)
7508
+ const unpinRef = useRef(false)
7509
+ followRef.current = (w, h, final) => {
7510
+ const sh = Math.max(0, h - rt - (props.bottom || 0))
7511
+ const world = worldRef.current
7512
+ if (!L || !world || !(w > 0) || !(sh > 0)) { setBox({ w, h }); return false }
7513
+ const next = layoutGrid(n, dw, dh, w, sh)
7514
+ const sw = w - (props.inset && w - props.inset >= 240 ? props.inset : 0)
7515
+ if (final || next.cols !== L.cols) {
7516
+ if (w === box.w && h === box.h) {
7517
+ if (liveCam.current && !auto.current) setCam(liveCam.current)
7518
+ else if (liveCam.current) { liveCam.current = null; camRef.current = cam }
7519
+ return false
7520
+ }
7521
+ flipFirst.current = snapStage(ref.current, world)
7522
+ if (auto.current) { const c = fitCam(next, sw, sh); setCam({ ...c, y: c.y + rt }) }
7523
+ else if (liveCam.current) setCam(liveCam.current)
7524
+ setBox({ w, h })
7525
+ return true
7526
+ }
7527
+ if (auto.current) {
7528
+ const c = fitCam({ ...L, z: next.z }, sw, sh)
7529
+ liveCam.current = camRef.current = { ...c, y: c.y + rt }
7530
+ world.style.transform = `translate(${c.x}px, ${c.y + rt}px) scale(${c.z})`
7531
+ }
7532
+ return false
7533
+ }
7534
+ // 屏多的时候只挂镜头附近的,别的先放占位。镜头停下来才换,拖动时不闪、不反复重载
7535
+ const cull = !!props.sleep && !!L && screens.length > LIVE_MAX
7536
+ const [live, setLive] = useState(null)
7537
+ const liveIds = cull ? screens.map((x) => x.id || x.key) : []
7538
+ const liveSig = liveIds.join('|')
7539
+ useEffect(() => {
7540
+ if (!cull || !cam) { if (live) setLive(null); return undefined }
7541
+ const run = () => {
7542
+ const c = camRef.current
7543
+ const selIdx = screens.findIndex((x) => x.key === props.sel)
7544
+ setLive((prev) => {
7545
+ // 「适合画布」时所有屏都在画面里,光是重排就别换加载着的屏,换了会闪
7546
+ const selId = selIdx < 0 ? '' : liveIds[selIdx]
7547
+ if (prev && auto.current && prev.size === Math.min(LIVE_MAX, liveIds.length) && (!selId || prev.has(selId)) && [...prev].every((id) => liveIds.includes(id))) return prev
7548
+ const next = nearestLive(liveIds, L.pos, dw, dh, (vw / 2 - c.x) / c.z, (rt + bh / 2 - c.y) / c.z, selIdx < 0 ? '' : liveIds[selIdx], LIVE_MAX, prev)
7549
+ return prev && prev.size === next.size && [...next].every((id) => prev.has(id)) ? prev : next
7550
+ })
7551
+ }
7552
+ if (!live) { run(); return undefined }
7553
+ const timer = setTimeout(run, 160)
7554
+ return () => clearTimeout(timer)
7555
+ }, [cull, cam, layoutKey, liveSig, props.sel])
7283
7556
 
7284
7557
  useEffect(() => {
7285
7558
  const el = ref.current
7286
7559
  if (!el) return undefined
7287
- const measure = () => setBox({ w: el.clientWidth, h: el.clientHeight })
7288
- measure()
7560
+ const apply = () => setBox({ w: el.clientWidth, h: el.clientHeight })
7561
+ let timer = 0
7562
+ const pin = (v) => { if (worldRef.current) worldRef.current.style.transition = v }
7563
+ const settle = () => { if (followRef.current(el.clientWidth, el.clientHeight, true)) unpinRef.current = true; else pin('') }
7564
+ const measure = () => {
7565
+ clearTimeout(timer)
7566
+ if (!heavyRef.current) { pin(''); apply(); return }
7567
+ pin('none') // 拖动时镜头不做过渡:每帧重开过渡正是闪的来源之一
7568
+ followRef.current(el.clientWidth, el.clientHeight, false)
7569
+ timer = setTimeout(settle, 160)
7570
+ }
7571
+ apply()
7289
7572
  if (typeof ResizeObserver === 'undefined') return undefined
7290
7573
  const ro = new ResizeObserver(measure)
7291
7574
  ro.observe(el)
7292
- return () => ro.disconnect()
7575
+ return () => { clearTimeout(timer); ro.disconnect() }
7293
7576
  }, [])
7294
7577
 
7578
+ // 屏多时的换行动画:格子先到新位置,再用 translate 从旧位置滑过来,全程走合成层,不用每帧重新排版 30 个格子
7579
+ const flipFrom = useRef(null)
7580
+ const flipUntil = useRef(0)
7581
+ const SLIDE = { id: 'ddp-flip', duration: 450, easing: EASE }
7582
+ const stopFlip = (el) => { for (const old of el.getAnimations()) if (old.id === 'ddp-flip') old.cancel() }
7583
+ // first 是镜头和格子换之前的样子,这里量换完的样子,差多少就从那儿滑回来。先量完再统一开动画,别读写交错
7584
+ function playFlip(world, first) {
7585
+ flipUntil.current = performance.now() + 450
7586
+ const list = cellsOf(world)
7587
+ for (const el of [...list, ...list.map(labOf), ref.current]) if (el) stopFlip(el)
7588
+ const jobs = []
7589
+ for (const el of list) {
7590
+ const f = first.cells.get(el.dataset.cell)
7591
+ if (!f) continue
7592
+ const l = el.getBoundingClientRect()
7593
+ if (!l.width || !el.offsetWidth) continue
7594
+ const k = l.width / el.offsetWidth
7595
+ const dx = (f.rect.left + f.rect.width / 2 - l.left - l.width / 2) / k
7596
+ const dy = (f.rect.top + f.rect.height / 2 - l.top - l.height / 2) / k
7597
+ const s = f.rect.width / l.width
7598
+ if (Math.abs(dx) < 0.5 && Math.abs(dy) < 0.5 && Math.abs(s - 1) < 0.001) continue
7599
+ jobs.push([el, { translate: `${dx}px ${dy}px`, scale: String(s) }, f.lab])
7600
+ }
7601
+ for (const [el, from, labFrom] of jobs) {
7602
+ el.animate([from, { translate: '0 0', scale: '1' }], SLIDE)
7603
+ const lab = labOf(el)
7604
+ if (lab && labFrom && labFrom !== 'none') lab.animate([{ transform: labFrom }, { transform: lab.style.transform }], SLIDE)
7605
+ }
7606
+ ref.current.animate([first.bg, { backgroundSize: ref.current.style.backgroundSize, backgroundPosition: ref.current.style.backgroundPosition }], SLIDE)
7607
+ // 选中屏的连线画在新位置,等格子落定再淡出来,别在半路错位
7608
+ const lines = world.querySelector(':scope > .ddp-flows')
7609
+ if (lines) lines.animate([{ opacity: 0 }, { opacity: 0, offset: 0.7 }, { opacity: 1 }], { duration: 450 })
7610
+ }
7611
+ react.useLayoutEffect(() => {
7612
+ if (!L) return
7613
+ const now = new Map(screens.map((sc, i) => [String(sc.id || sc.key), L.pos[i]]))
7614
+ if (ghost) now.set(GHOST_CELL, L.pos[n - 1])
7615
+ const was = flipFrom.current
7616
+ flipFrom.current = now
7617
+ const first = flipFirst.current
7618
+ flipFirst.current = null
7619
+ const world = worldRef.current
7620
+ if (world && heavy && !reduced()) {
7621
+ if (first) playFlip(world, first)
7622
+ else if (was) {
7623
+ // 别的原因重排(加屏、删屏):镜头有自己的过渡,格子只补世界坐标里的差;上一段没滑完就从当前看到的样子接着滑
7624
+ for (const el of cellsOf(world)) {
7625
+ const a = was.get(el.dataset.cell)
7626
+ const b = now.get(el.dataset.cell)
7627
+ if (!a || !b || (a.x === b.x && a.y === b.y)) continue
7628
+ const cs = getComputedStyle(el)
7629
+ const [ox, oy] = cs.translate && cs.translate !== 'none' ? cs.translate.split(' ').map(parseFloat) : [0, 0]
7630
+ const sc0 = cs.scale && cs.scale !== 'none' ? cs.scale.split(' ')[0] : '1'
7631
+ stopFlip(el)
7632
+ el.animate([{ translate: `${a.x - b.x + (ox || 0)}px ${a.y - b.y + (oy || 0)}px`, scale: sc0 }, { translate: '0 0', scale: '1' }], SLIDE)
7633
+ }
7634
+ }
7635
+ }
7636
+ if (unpinRef.current) { unpinRef.current = false; if (world) world.style.transition = '' }
7637
+ }, [layoutKey])
7638
+
7639
+ // 镜头一提交,画面就以它为准:拖宽度时直接写过 DOM,React 看值没变可能不重写,这里显式写一次
7640
+ react.useLayoutEffect(() => {
7641
+ liveCam.current = null
7642
+ camRef.current = cam
7643
+ const world = worldRef.current
7644
+ if (!world || !cam) return
7645
+ world.style.transform = `translate(${cam.x}px, ${cam.y}px) scale(${cam.z})`
7646
+ // 标题还在往旧倍率滑的时候镜头又变了:从当前看到的样子改滑向新倍率,别滑完再跳一下
7647
+ if (heavy && performance.now() < flipUntil.current) {
7648
+ for (const el of cellsOf(world)) {
7649
+ const lab = labOf(el)
7650
+ const run = lab && lab.getAnimations().find((x) => x.id === 'ddp-flip')
7651
+ if (!run || run.effect.getKeyframes().at(-1).transform === lab.style.transform) continue
7652
+ const from = getComputedStyle(lab).transform
7653
+ stopFlip(lab)
7654
+ lab.animate([{ transform: from }, { transform: lab.style.transform }], SLIDE)
7655
+ flipUntil.current = performance.now() + 450
7656
+ }
7657
+ }
7658
+ const first = flipFirst.current
7659
+ if (!first) return
7660
+ flipFirst.current = null
7661
+ if (heavy && !reduced()) playFlip(world, first)
7662
+ }, [cam])
7663
+
7295
7664
  // 屏数 / 类型 / 舞台大小变了:用户没自己动过镜头就重新摆好
7296
7665
  useEffect(() => {
7297
7666
  if (!L) return
7298
7667
  if (auto.current || !camRef.current) {
7299
- setAnim(!!camRef.current)
7300
- setCam(fitAt())
7668
+ const world = worldRef.current
7669
+ const to = fitAt()
7670
+ const c = camRef.current
7671
+ // 拖着宽度的时候屏数变了:镜头这时不走过渡,和换行一样先记下画面再滑过去
7672
+ if (heavy && world && c && world.style.transition === 'none' && (c.x !== to.x || c.y !== to.y || c.z !== to.z)) flipFirst.current = snapStage(ref.current, world)
7673
+ setAnim(!!c)
7674
+ setCam(to)
7301
7675
  } else if (ins && props.sel) showKey(props.sel) // 自己挪过镜头:只把选中的那屏挪出来,别被面板挡着
7302
7676
  }, [layoutKey])
7303
7677
 
@@ -7401,30 +7775,34 @@ ${Object.entries(CHIP_ICON).map(([k, d]) => `[data-composer-chip="${chipSrc(k)}"
7401
7775
  while (grid < 12) grid *= 2
7402
7776
  while (grid > 48) grid /= 2
7403
7777
  const lab = (key, body, w = dw) => h('div', { className: 'ddp-lab', 'data-key': key, style: { width: w * z, transform: `scale(${1 / z})` } }, ...body)
7404
- const cells = []
7405
- if (cam && L) {
7778
+ // 只是挪镜头(props、缩放都没变):别重建每一屏,省得所有 iframe 跟着过一遍 React
7779
+ const cells = useMemo(() => {
7780
+ const out = []
7781
+ if (!cam || !L) return out
7406
7782
  screens.forEach((sc, i) => {
7407
7783
  const on = sel === sc.key
7408
7784
  const [cw, ch] = boxes ? boxes[i] : [dw, dh]
7409
7785
  const fr = items ? FRAME[items[i].kind] || FRAME.web : f
7410
- cells.push(h('div', {
7786
+ out.push(h('div', {
7411
7787
  key: sc.id || sc.key,
7788
+ 'data-cell': String(sc.id || sc.key),
7412
7789
  className: 'ddp-cell' + (on ? ' sel' : ''),
7413
7790
  style: { left: L.pos[i].x, top: L.pos[i].y, width: cw, height: ch },
7414
7791
  },
7415
7792
  lab(sc.key, [props.tag ? props.tag(sc) : null, h('span', { key: 's' }, labelOf(sc)), !picking && props.badge ? props.badge(sc) : null, !picking && props.actions ? h('span', { key: 'a', className: 'ddp-act' }, ...props.actions(sc)) : null], cw),
7416
- props.render(sc, z, i),
7793
+ cull && !(live && live.has(sc.id || sc.key)) ? props.sleep(sc, z) : props.render(sc, z, i),
7417
7794
  picking ? null : h('div', { className: 'ddp-shield', 'data-key': sc.key, title: items ? '' : t('openScreen'), style: { borderRadius: fr.r } })))
7418
7795
  })
7419
7796
  if (ghost) {
7420
7797
  const p = L.pos[n - 1]
7421
- cells.push(h('div', { key: '__ghost', className: 'ddp-cell ghost', style: { left: p.x, top: p.y, width: dw, height: dh } },
7798
+ out.push(h('div', { key: '__ghost', 'data-cell': GHOST_CELL, className: 'ddp-cell ghost', style: { left: p.x, top: p.y, width: dw, height: dh } },
7422
7799
  lab('', [h('i', { key: 'i', className: 'sp' }), h('span', { key: 's' }, t('generating'))]),
7423
7800
  h(Device, { kind, w: size[0], h: size[1], label: '' },
7424
7801
  h(GhostDraw, { key: 'gd', t, kind, pulse: props.pulse || 0 }),
7425
7802
  props.draft ? h(DraftFrame, { key: 'df', url: props.draft, z, lang: t('lang'), onEnd: props.onDraftEnd }) : null)))
7426
7803
  }
7427
- }
7804
+ return out
7805
+ }, [props, z, live, layoutKey, !!cam])
7428
7806
  let flowSvg = null
7429
7807
  if (cam && L && props.flows && props.flows.length && !picking) {
7430
7808
  // 只画选中那屏通向哪(不画哪些通向它),底栏、返回这种每屏都有的导航只描框
@@ -7435,12 +7813,13 @@ ${Object.entries(CHIP_ICON).map(([k, d]) => `[data-composer-chip="${chipSrc(k)}"
7435
7813
  }
7436
7814
  }
7437
7815
  return h('div', {
7438
- className: 'ddp-canvas' + (drag ? ' drag' : ''),
7816
+ className: 'ddp-canvas' + (drag ? ' drag' : '') + (heavy ? ' heavy' : ''),
7439
7817
  ref,
7440
7818
  onPointerDown,
7441
7819
  style: cam ? { backgroundSize: `${grid}px ${grid}px`, backgroundPosition: `${cam.x}px ${cam.y}px` } : undefined,
7442
7820
  },
7443
7821
  cam && L ? h('div', {
7822
+ ref: worldRef,
7444
7823
  className: 'ddp-world' + (anim ? ' anim' : ''),
7445
7824
  style: { transform: `translate(${cam.x}px, ${cam.y}px) scale(${z})`, '--z': z },
7446
7825
  }, ...cells, flowSvg) : null,
@@ -7451,7 +7830,7 @@ ${Object.entries(CHIP_ICON).map(([k, d]) => `[data-composer-chip="${chipSrc(k)}"
7451
7830
  ['', I.minus, t('zoomOut'), false, z <= ZMIN, () => center(1 / 1.25)],
7452
7831
  'sep',
7453
7832
  ['', I.fit, t('fit'), false, false, fit],
7454
- ['', I.single, t('zoomReal'), Math.abs(z - 1) < 0.005, false, () => center(1 / z)],
7833
+ ['', I.single, t('zoomReal'), Math.abs(z - 1) < 0.005, false, () => center(1 / camRef.current.z)],
7455
7834
  ] })))
7456
7835
  }
7457
7836
 
@@ -7545,6 +7924,15 @@ ${Object.entries(CHIP_ICON).map(([k, d]) => `[data-composer-chip="${chipSrc(k)}"
7545
7924
  const markRun = useRef(0) // 每开 / 关一次标注加一:发送途中关掉(或关了又开)的,旧的那次作废
7546
7925
  const [tw, setTw] = useState({}) // 拖过的滑块:id → 值(还没写进文件)
7547
7926
  const apis = useRef(new Map()) // 屏 → 截图用的接口
7927
+ const ghostApis = useRef(new Map()) // 单看时导出:在背后临时挂上的各屏
7928
+ const ghostQueue = useRef(Promise.resolve())
7929
+ const ghostBatch = useRef(0)
7930
+ const [backFrames, setBackFrames] = useState(null) // { list, size }:开始时的那些屏,途中换设计也不跟着变
7931
+ const designNow = useRef('') // 现在开着哪套设计
7932
+ const designSeq = useRef(0) // 换一次设计加一:导出途中换过(换回来也算)就不存了
7933
+ const [loadTick, setLoadTick] = useState(0) // 导出面板开着时页面又载入了一次:重新量
7934
+ const warned = useRef('') // 预检提醒过的结果:同样的结果只拦一次
7935
+ const [xo, setXo] = useState({ layout: 'auto', custom: '', fit: '', fitH: '', cols: 1 }) // 导出选项
7548
7936
  const cmpRef = useRef(null)
7549
7937
  const [box, setBox] = useState({ w: 0, h: 0 })
7550
7938
  const stageRef = useRef(null)
@@ -7567,6 +7955,7 @@ ${Object.entries(CHIP_ICON).map(([k, d]) => `[data-composer-chip="${chipSrc(k)}"
7567
7955
  const draftedR = useRef(new Map()) // 边写边看过的屏 → 什么时候:真文件出来时不再播一遍生成动画
7568
7956
  const pulseR = useRef({ key: '', lines: 0, n: 0 }) // 模型真有动静就加一(占位里的鼠标按它动)
7569
7957
  const singleDraftR = useRef('') // 单屏里正在看着写的那屏:写完换过去看它
7958
+ const peekR = useRef('') // 这轮生成里用户自己点开的那屏:就给他看这屏,别拿在写的草稿盖住,写完也别把他带走
7570
7959
  const playR = useRef({ url: '', key: '', hold: 0, end: false, meta: '', lump: false }) // 在放的草稿(见下面 dr)
7571
7960
  const M = marks.current
7572
7961
  if (M.site !== site) {
@@ -7793,10 +8182,11 @@ ${Object.entries(CHIP_ICON).map(([k, d]) => `[data-composer-chip="${chipSrc(k)}"
7793
8182
  }
7794
8183
 
7795
8184
  const remember = (key, m, title, toks, dk, links, nat) => {
8185
+ if (pane === 'export') setLoadTick((n) => n + 1)
7796
8186
  const k = site + '|' + key
7797
8187
  const sig = JSON.stringify([toks || [], links || []])
7798
8188
  setInfo((cur) => {
7799
- const natural = nat || (cur[k] && cur[k].natural) || null // 画幅放大后页面不再比框大、报空:还按上回量的
8189
+ const natural = nat === 0 ? null : nat || (cur[k] && cur[k].natural) || null // 画幅放大后页面正好撑满、报空:还按上回量的;0 是这页不再是一整块:清掉
7800
8190
  return cur[k] && cur[k].meta === m && cur[k].title === title && cur[k].sig === sig && cur[k].dark === dk && String(cur[k].natural) === String(natural) ? cur
7801
8191
  : { ...cur, [k]: { meta: m, title, tokens: toks || [], links: links || [], sig, dark: dk, natural } }
7802
8192
  })
@@ -7817,8 +8207,15 @@ ${Object.entries(CHIP_ICON).map(([k, d]) => `[data-composer-chip="${chipSrc(k)}"
7817
8207
  if (!patch.focus && poll && poll.state) poll.set({ ...poll.state, ...patch })
7818
8208
  post('view', { session: sid, ...patch }).then((s) => poll && poll.set(s), (e) => say(t('openFailed', { msg: e.message })))
7819
8209
  }
8210
+ // 用户自己点开一屏(双击、菜单、单看按钮)
8211
+ const openByUser = (key) => {
8212
+ singleDraftR.current = ''
8213
+ peekR.current = key || focus
8214
+ change(key ? { view: 'single', focus: key } : { view: 'single' })
8215
+ }
7820
8216
  // 单屏里看着写完的那屏:真文件出来了就换过去看它(不然写完一闪又回到原来那屏)
7821
8217
  useEffect(() => {
8218
+ if (!busy && !dr) peekR.current = ''
7822
8219
  let k = singleDraftR.current
7823
8220
  if (k === '*' && sd && sd.key) k = singleDraftR.current = sd.key
7824
8221
  if (!k || dr) return
@@ -8070,8 +8467,7 @@ ${Object.entries(CHIP_ICON).map(([k, d]) => `[data-composer-chip="${chipSrc(k)}"
8070
8467
  useEffect(() => { setDemo(null) }, [site])
8071
8468
 
8072
8469
  const openSingle = () => {
8073
- if (sel && sel !== focus && screens.some((s) => s.key === sel)) change({ view: 'single', focus: sel })
8074
- else change({ view: 'single' })
8470
+ openByUser(sel && sel !== focus && screens.some((s) => s.key === sel) ? sel : '')
8075
8471
  }
8076
8472
 
8077
8473
  const renderScreen = (sc, z, fill) => h(Device, { kind, w: size[0], h: size[1], fill, label: labelOf(sc), top: tops[ik(sc)], os: meta.os },
@@ -8105,52 +8501,125 @@ ${Object.entries(CHIP_ICON).map(([k, d]) => `[data-composer-chip="${chipSrc(k)}"
8105
8501
  onBuilt: (title) => onBuilt(sc, title),
8106
8502
  }))
8107
8503
 
8504
+ // 画布上屏太多、离镜头远的:先不挂 iframe,放个占位
8505
+ const sleepScreen = (sc, z) => h(Device, { kind, w: size[0], h: size[1], fill: false, label: labelOf(sc), top: tops[ik(sc)], os: meta.os },
8506
+ h('div', { className: 'ddp-scr' + (dark ? ' dk' : '') }, h('div', { className: 'ddp-away', style: { fontSize: 13 / Math.max(0.25, z || 1) } }, t('canvasAsleep'))))
8507
+
8108
8508
  // ── 导出图片 ──
8109
8509
  // 截一屏:图片和它的 CSS 尺寸(PDF / PPT 按这个定页面大小)
8110
8510
  // 那一屏的接口(截图、体检);刚载入的等它就绪
8111
- const apiOf = async (sc) => {
8112
- let api = apis.current.get(ik(sc))
8113
- for (let i = 0; i < 40 && !(api && api.ready()); i++) {
8511
+ const apiOf = async (sc, map = apis.current) => {
8512
+ const tries = map === apis.current ? 40 : 120 // 背后现挂的要等它载完
8513
+ let api = map.get(ik(sc))
8514
+ for (let i = 0; i < tries && !(api && api.ready()); i++) {
8114
8515
  await new Promise((r) => setTimeout(r, 150))
8115
- api = apis.current.get(ik(sc))
8516
+ api = map.get(ik(sc))
8116
8517
  }
8117
8518
  if (!api) throw new Error('not loaded')
8118
8519
  return api
8119
8520
  }
8120
- const captureOf = async (sc, full) => {
8121
- const api = await apiOf(sc)
8122
- const r = await api.capture({ full: !!full, scale: 2 })
8123
- return { img: await loadImg(r.png), w: r.w, h: r.h, links: Array.isArray(r.links) ? r.links : [], top: typeof r.top === 'boolean' ? r.top : null }
8521
+ const captureOf = async (sc, full, map, maxH) => {
8522
+ const api = await apiOf(sc, map)
8523
+ const r = await api.capture({ full: !!full, scale: 2, ...(maxH ? { maxH } : {}) })
8524
+ return { img: await loadImg(r.png), w: r.w, h: r.h, links: Array.isArray(r.links) ? r.links : [], top: typeof r.top === 'boolean' ? r.top : null, title: String(r.title || '').trim() }
8124
8525
  }
8526
+ // 导出用的标题:屏多的时候有的屏没在画布上挂过,手上没有它的标题,用截图时页面报的
8527
+ const exportTitle = (sc, r) => (infoOf(ik(sc)) || {}).title || r.title || sc.label
8125
8528
 
8529
+ const targetKey = st && st.target ? (st.target.kind === 'file' ? `file|${st.target.root}` : `proxy|${st.target.port}`) : ''
8126
8530
  const saveImage = async (name, blob) => {
8127
8531
  const png = await blobB64(blob)
8128
- const r = await post('export', { session: sid, name, png })
8532
+ const r = await post('export', { session: sid, name, png, target: targetKey })
8129
8533
  const copied = await copyImage(blob)
8130
8534
  const file = String(r.path || '').split(/[\\/]/).pop()
8131
8535
  say(t(copied ? 'exportedCopied' : 'exported', { name: file }), { label: t('reveal'), run: () => post('reveal', { path: r.path }).catch(() => {}) })
8132
8536
  }
8133
8537
 
8134
- const doExport = async (mode, key) => {
8538
+ const designId = JSON.stringify([sid, targetKey, ver ? ver.n : 0])
8539
+ if (designNow.current !== designId) { designNow.current = designId; designSeq.current++ }
8540
+ // 单看时只挂着正在看的那屏;要所有屏(PDF、PPT、拼图、预检)时按画幅大小在背后挂上,用完就撤
8541
+ const withFrames = async (fn, only) => {
8542
+ if (!only && ((canvas && shown.length <= LIVE_MAX) || shown.length < 2)) return fn(apis.current)
8543
+ // 网页单看时铺满右侧栏,和画幅不一样宽,都在背后重挂;别的类型正在看的那屏直接用(滚动位置、打开的弹窗都还在)
8544
+ // 画布屏多的时候镜头一动画布上的屏就会撤,也都在背后挂
8545
+ const stamp = designSeq.current
8546
+ const run = async () => {
8547
+ if (designSeq.current !== stamp) throw new Error('designChanged') // 排队的时候换了设计
8548
+ // 轮到了才算要挂哪些:排队时前台可能已经换了一屏
8549
+ const list = only || (canvas || kind === 'web' ? shown : shown.filter((sc) => !apis.current.has(ik(sc))))
8550
+ const back = new Set(list.map(ik))
8551
+ const place = new Map(list.map((sc, i) => [ik(sc), i]))
8552
+ // 屏多的时候分批挂:只挂轮到的这一批,别几十个一起跑
8553
+ let at = 0
8554
+ // 每个任务一批新的 iframe:上一批的深浅色、接口都不留(不然拿到上一批「已就绪」的就截了)
8555
+ ghostApis.current.clear()
8556
+ setBackFrames({ list, size, at, dark, batch: ++ghostBatch.current }) // 深浅色跟点导出时的走,和文件名对得上
8557
+ const get = (k) => {
8558
+ const i = place.get(k)
8559
+ if (i !== undefined && (i < at || i >= at + LIVE_MAX)) { at = i; setBackFrames((b) => (b ? { ...b, at: i } : b)) }
8560
+ return (back.has(k) ? ghostApis.current : apis.current).get(k)
8561
+ }
8562
+ try { return await fn({ get }) } finally { setBackFrames(null) }
8563
+ }
8564
+ // 背后挂的屏一次只给一个任务用(预检和导出撞上,会互相把对方要的那批撤掉)
8565
+ const job = ghostQueue.current.then(run, run)
8566
+ ghostQueue.current = job.catch(() => {})
8567
+ return job
8568
+ }
8569
+ const measureAll = async (map) => {
8570
+ const stamp = designSeq.current
8571
+ const list = []
8572
+ for (const sc of shown) {
8573
+ if (designSeq.current !== stamp) break // 设计换了:别再等旧的屏
8574
+ try { const api = await apiOf(sc, map); list.push(await api.measure()) } catch (e) { console.warn('[dsh-design-studio] 量页面失败', sc.key, e); list.push({ failed: true }) }
8575
+ }
8576
+ return list
8577
+ }
8578
+
8579
+ const doExport = async (mode, key, opts) => {
8135
8580
  setExMenu(false)
8581
+ if (mode === 'opts') { if (pane !== 'export') openPane('export'); return }
8136
8582
  if (mode === 'zip') return openPack(fileTarget ? st.target.root : '')
8137
8583
  if (mode === 'share') return openShare(fileTarget ? st.target.root : '')
8138
8584
  say(t('exporting'))
8585
+ const design = designNow.current
8586
+ const stamp = designSeq.current
8587
+ const gone = () => designSeq.current !== stamp
8139
8588
  try {
8140
8589
  const prefix = ver ? `v${ver.n}-` : ''
8141
8590
  const suffix = dark ? '-dark' : ''
8142
8591
  if (mode === 'pdf' || mode === 'pptx') {
8143
- // 每屏一页。PDF 里网页、邮件放整页长图(页面多高就多高);PPT 一张幻灯片一个画面
8144
- const long = mode === 'pdf' && (kind === 'web' || kind === 'email')
8592
+ // 每屏一页。PDF 里网页、邮件放整页长图(页面多高就多高);PPT 一张幻灯片一个画面。选项面板里可以改
8593
+ const fit = (opts && opts.fit) || ''
8594
+ const long = fit === 'page' || fit === 'height' || (!fit && mode === 'pdf' && (kind === 'web' || kind === 'email'))
8595
+ const maxH = fit === 'height' ? Number(opts.fitH) || 0 : 0
8596
+ let deadN = 0
8597
+ await withFrames(async (map) => {
8598
+ // 从菜单直接点:先量一遍,有内容会被裁就先给看清单(同样的结果只拦一次)
8599
+ if (!opts) {
8600
+ const seen = await measureAll(map)
8601
+ const rep = precheckOf(seen, kind, long ? Infinity : 0)
8602
+ deadN = rep.dead
8603
+ const sig = rep.over || rep.long ? [design, shown.map(ik).join(','), size.join('x'), long ? 1 : 0, seen.map((m) => (m.failed ? '-' : `${m.pageW}x${m.pageH}`)).join(',')].join('|') : ''
8604
+ if (sig && warned.current !== sig) {
8605
+ warned.current = sig
8606
+ say(t('xoWarn'))
8607
+ if (pane !== 'export') openPane('export')
8608
+ return
8609
+ }
8610
+ }
8145
8611
  const pages = []
8146
8612
  const keys = []
8147
8613
  for (const sc of shown) {
8614
+ if (gone()) break
8148
8615
  try {
8149
- const r = await captureOf(sc, long)
8150
- pages.push({ jpg: await jpegB64(r.img), w: r.w, h: r.h, title: labelOf(sc), links: r.links })
8616
+ const r = await captureOf(sc, long, map, maxH)
8617
+ const cut = maxH && r.h > maxH
8618
+ pages.push({ jpg: await jpegB64(cut ? cropImg(r.img, r.h, maxH) : r.img), w: r.w, h: cut ? maxH : r.h, title: exportTitle(sc, r), links: r.links })
8151
8619
  keys.push(sc.key)
8152
8620
  } catch (e) { console.warn('[dsh-design-studio] 截图失败', sc.key, e) }
8153
8621
  }
8622
+ if (gone()) { say(t('xoGone')); return }
8154
8623
  if (!pages.length) throw new Error('no screens')
8155
8624
  // 原型里的跳转:路径换成第几页,PDF / PPT 里点了能跳过去
8156
8625
  for (const p of pages) {
@@ -8159,16 +8628,25 @@ ${Object.entries(CHIP_ICON).map(([k, d]) => `[data-composer-chip="${chipSrc(k)}"
8159
8628
  const sp = splitTitles(pages.map((x) => x.title))
8160
8629
  const folder = st && st.target && st.target.kind === 'file' ? String(st.target.file).split(/[\\/]/).slice(-2, -1)[0] : ''
8161
8630
  const title = sp.brand || folder || st.label || ''
8162
- const r = await post('doc', { session: sid, format: mode, name: prefix + (title || 'design') + suffix, title, bg: hexOf(pickColors(tokens).bg), pages })
8631
+ const layout = opts ? (opts.layout === 'custom' ? opts.custom.trim() : opts.layout === 'auto' ? '' : opts.layout) : ''
8632
+ const cols = opts && opts.cols === 2 ? 2 : 1
8633
+ const r = await post('doc', { session: sid, format: mode, name: prefix + (title || 'design') + suffix, title, bg: hexOf(pickColors(tokens).bg), pages, layout, cols, target: targetKey })
8163
8634
  const file = String(r.path || '').split(/[\\/]/).pop()
8164
- say(t('exportedDoc', { name: file, n: pages.length }), { label: t('reveal'), run: () => post('reveal', { path: r.path }).catch(() => {}) })
8635
+ const miss = shown.length - pages.length
8636
+ const sheets = Math.ceil(pages.length / cols)
8637
+ say((miss ? t('exportedDocMiss', { name: file, n: sheets, miss }) : t('exportedDoc', { name: file, n: sheets })) + (deadN ? ' · ' + t('xoDead', { n: deadN }) : ''), { label: t('reveal'), run: () => post('reveal', { path: r.path }).catch(() => {}) })
8638
+ })
8165
8639
  return
8166
8640
  }
8167
8641
  if (mode === 'show') {
8168
8642
  const shots = []
8169
- for (const sc of shown) {
8170
- try { const c = await captureOf(sc, false); shots.push({ img: c.img, top: c.top, title: labelOf(sc) }) } catch (e) { console.warn('[dsh-design-studio] 截图失败', sc.key, e) }
8171
- }
8643
+ await withFrames(async (map) => {
8644
+ for (const sc of shown) {
8645
+ if (gone()) break
8646
+ try { const c = await captureOf(sc, false, map); shots.push({ img: c.img, top: c.top, title: exportTitle(sc, c) }) } catch (e) { console.warn('[dsh-design-studio] 截图失败', sc.key, e) }
8647
+ }
8648
+ })
8649
+ if (gone()) { say(t('xoGone')); return }
8172
8650
  if (!shots.length) throw new Error('no screens')
8173
8651
  const sp = splitTitles(shots.map((x) => x.title))
8174
8652
  const colors = pickColors(tokens)
@@ -8190,7 +8668,12 @@ ${Object.entries(CHIP_ICON).map(([k, d]) => `[data-composer-chip="${chipSrc(k)}"
8190
8668
  const sc = shown.find((x) => x.key === k) || shown[0]
8191
8669
  if (!sc) throw new Error('no screen')
8192
8670
  const base = prefix + sc.key.replace(/\.html?$/i, '') + suffix
8193
- const { img, top } = await captureOf(sc, mode === 'long')
8671
+ // 画布屏多的时候这屏可能没挂着(镜头一动也可能撤掉):在背后单独挂一份来截
8672
+ let shot = null
8673
+ if (canvas && shown.length > LIVE_MAX) await withFrames(async (map) => { shot = await captureOf(sc, mode === 'long', map) }, [sc])
8674
+ else shot = await captureOf(sc, mode === 'long')
8675
+ if (gone()) { say(t('xoGone')); return }
8676
+ const { img, top } = shot
8194
8677
  if (mode === 'frame') await saveImage(base, await composeOne(kind, size, img, labelOf(sc), top, meta.os))
8195
8678
  else {
8196
8679
  const c = document.createElement('canvas')
@@ -8200,7 +8683,7 @@ ${Object.entries(CHIP_ICON).map(([k, d]) => `[data-composer-chip="${chipSrc(k)}"
8200
8683
  await saveImage(base + (mode === 'long' ? '-full' : ''), await canvasBlob(c))
8201
8684
  }
8202
8685
  } catch (e) {
8203
- say(t('exportFail', { msg: e.message }))
8686
+ say(e.message === 'designChanged' ? t('xoGone') : t('exportFail', { msg: e.message }))
8204
8687
  }
8205
8688
  }
8206
8689
 
@@ -8243,7 +8726,7 @@ ${Object.entries(CHIP_ICON).map(([k, d]) => `[data-composer-chip="${chipSrc(k)}"
8243
8726
  const actions = (sc) => [
8244
8727
  h('button', { key: 'x', className: 'ddp-btn', title: t('exThis'), onClick: () => doExport(FRAMED[kind] ? 'frame' : 'raw', sc.key) }, h(I.download), h('span', { className: 'lb' }, t('actX'))),
8245
8728
  sc.v ? null : h('button', { key: 'v', className: 'ddp-btn', title: t('variants'), onClick: () => askVariants(sc) }, h(I.sparkle), h('span', { className: 'lb' }, t('actV'))),
8246
- h('button', { key: 'o', className: 'ddp-btn', title: t('openScreen'), onClick: () => change({ view: 'single', focus: sc.key }) }, h(I.single), h('span', { className: 'lb' }, t('actO'))),
8729
+ h('button', { key: 'o', className: 'ddp-btn', title: t('openScreen'), onClick: () => openByUser(sc.key) }, h(I.single), h('span', { className: 'lb' }, t('actO'))),
8247
8730
  ]
8248
8731
 
8249
8732
  // 对比:拖中间的把手
@@ -8281,7 +8764,8 @@ ${Object.entries(CHIP_ICON).map(([k, d]) => `[data-composer-chip="${chipSrc(k)}"
8281
8764
  if (ck) for (const sc of ck.list || []) { const a = apis.current.get(ik(sc)); if (a) a.checkClear() }
8282
8765
  setCk(null)
8283
8766
  }
8284
- const checkList = () => (canvas ? shown : [shown.find((x) => x.key === focus) || { key: focus, url, label: st.label }])
8767
+ // 画布屏多的时候只量挂着的(别的没有页面可量)
8768
+ const checkList = () => (canvas ? (shown.length > LIVE_MAX ? shown.filter((sc) => apis.current.has(ik(sc))) : shown) : [shown.find((x) => x.key === focus) || { key: focus, url, label: st.label }])
8285
8769
  // 几屏一起量(各量各的 iframe),一屏卡住不拖累别的
8286
8770
  const measure = (list, quiet) => Promise.all(list.map(async (sc) => {
8287
8771
  const row = { key: sc.key, v: sc.v, label: labelOf(sc), url: sc.url, issues: [] }
@@ -8297,6 +8781,7 @@ ${Object.entries(CHIP_ICON).map(([k, d]) => `[data-composer-chip="${chipSrc(k)}"
8297
8781
  setPanel(false); setHist(false); setPhone(false)
8298
8782
  setCk({ running: true, list: [] })
8299
8783
  const out = await measure(checkList(), false)
8784
+ if (canvas && shown.length > LIVE_MAX) say(t('checkPartial', { n: out.length }))
8300
8785
  setCk({ running: false, list: out })
8301
8786
  setCkCount(total(out))
8302
8787
  // 有问题的第一屏被面板挡着、在画布外面:挪过来
@@ -8308,6 +8793,8 @@ ${Object.entries(CHIP_ICON).map(([k, d]) => `[data-composer-chip="${chipSrc(k)}"
8308
8793
  const sc = (ck && ck.list.find((x) => x.key === key)) || null
8309
8794
  if (!sc) return
8310
8795
  if (canvas) { setSel(key); setReveal((r) => ({ key, n: ((r && r.n) || 0) + 1 })) }
8796
+ // 屏多的时候这屏可能撤过(重新载入后页面里的体检标记没了):等它挂上,量一遍再定位
8797
+ if (canvas && shown.length > LIVE_MAX) { apiOf(sc).then((api) => api.check(kind, false).then(() => api.checkFocus(i))).catch((e) => console.warn('[dsh-design-studio] 定位问题失败', key, e)); return }
8311
8798
  const a = apis.current.get(ik(sc))
8312
8799
  if (a) a.checkFocus(i)
8313
8800
  }
@@ -8561,6 +9048,15 @@ ${Object.entries(CHIP_ICON).map(([k, d]) => `[data-composer-chip="${chipSrc(k)}"
8561
9048
  }
8562
9049
  useEffect(() => { if (styleOff) setStyleEdit(false) }, [styleOff])
8563
9050
  autoCk.current = { ck, off: checkOff, run: runCheck, list: checkList, measure }
9051
+ // 屏数超过上限:不声不响地少几屏,用户会以为没生成
9052
+ const hiddenN = (st && st.hidden) || 0
9053
+ const hiddenText = hiddenN ? t('screensHidden', { n: hiddenN, max: st.maxScreens }) : ''
9054
+ const hiddenSaid = useRef('')
9055
+ useEffect(() => {
9056
+ const sig = hiddenN ? `${targetKey}|${hiddenN}` : ''
9057
+ if (sig && sig !== hiddenSaid.current) say(hiddenText)
9058
+ hiddenSaid.current = sig
9059
+ }, [hiddenN, targetKey])
8564
9060
  useEffect(() => { if (checkOff && ck) closeCheck() }, [checkOff])
8565
9061
 
8566
9062
  const toggleDemo = () => (demo ? setDemo(null) : startDemo())
@@ -8640,7 +9136,7 @@ ${Object.entries(CHIP_ICON).map(([k, d]) => `[data-composer-chip="${chipSrc(k)}"
8640
9136
  setMulti(false)
8641
9137
  if (demo) setDemo(null)
8642
9138
  setSel(key)
8643
- if (canvas || key !== focus) change({ view: 'single', focus: key })
9139
+ if (canvas || key !== focus || dr) openByUser(key)
8644
9140
  }
8645
9141
  // 导出菜单写出是哪一屏(和 doExport 取同一屏)
8646
9142
  const exSc = shown.find((x) => x.key === (canvas ? sel || focus : focus)) || shown[0]
@@ -8657,7 +9153,7 @@ ${Object.entries(CHIP_ICON).map(([k, d]) => `[data-composer-chip="${chipSrc(k)}"
8657
9153
  h('div', { className: 'ddp-isl tl' },
8658
9154
  h('button', { className: 'ddp-btn lab' + (homeAt === 'on' ? ' sel' : ''), ...tipA(t('homeBtn'), t('dHome'), homeAt === 'on' ? 'Esc' : ''), 'aria-pressed': homeAt === 'on', onClick: () => (homeAt === 'on' ? homeClose() : homeOpen()) }, h(I.home), h('span', { className: 'lb' }, t('homeBtn'))),
8659
9155
  h('span', { className: 'ddp-sep' }),
8660
- h(ScreenMenu, { t, label: scrLabel, tip: [scrLabel || stLabel, t('dScreen')], src: stLabel, busy, list: screens.map((x) => { const L = takeTag(x); return { key: x.key, label: dropBrand(shortOf(x)) + (L ? ' · ' + L : '') } }), cur: curKey, canvas: canvas && !inMulti && !demo, open: scrMenu, setOpen: setScrMenu,
9156
+ h(ScreenMenu, { t, hidden: hiddenN, hiddenText, label: scrLabel, tip: [scrLabel || stLabel, t('dScreen')], src: stLabel, busy, list: screens.map((x) => { const L = takeTag(x); return { key: x.key, label: dropBrand(shortOf(x)) + (L ? ' · ' + L : '') } }), cur: curKey, canvas: canvas && !inMulti && !demo, open: scrMenu, setOpen: setScrMenu,
8661
9157
  onPick: pickScreen, onAll: () => { setMulti(false); if (demo) setDemo(null); change({ view: 'canvas' }) }, onOther: () => setEditing(true),
8662
9158
  sizes: mark ? null : { on: inMulti, off: !sizeSet || !!ver, tip: sizeSet ? t('sizes') : t('sizesNo'), note: sizeSet ? '' : t('sizesNoShort'), run: () => setMulti(!inMulti) },
8663
9159
  kind, onKind: mark ? null : (k) => change({ kind: k }) })),
@@ -8806,7 +9302,10 @@ ${Object.entries(CHIP_ICON).map(([k, d]) => `[data-composer-chip="${chipSrc(k)}"
8806
9302
  }),
8807
9303
  toast ? h('div', { className: 'ddp-toast low' }, h('span', null, toast.text)) : null) : null
8808
9304
  // 开着设计时点「首页」:首页叠在画布上(设计库再叠在它上面)
8809
- const root = (...kids) => h('div', rootProps, ...kids, url && homeAt ? homeView(true) : null, libLayer, dropLayer, fileInput, pageFileInput)
9305
+ // 单看时导出:所有屏按画幅大小挂在背后(看不见、点不到,放在视口里是因为视口外的 iframe 浏览器会停掉它的绘制)
9306
+ const ghostLayer = backFrames ? h('div', { className: 'ddp-ghost', 'aria-hidden': true }, ...backFrames.list.slice(backFrames.at || 0, (backFrames.at || 0) + LIVE_MAX).map((sc) => h('div', { key: backFrames.batch + '|' + ik(sc), className: 'ddp-vp', style: { left: 0, top: 0, width: backFrames.size[0], height: backFrames.size[1] } },
9307
+ h(Screen, { t, remote, src: sc.url, label: labelOf(sc), dark: backFrames.dark, apis: ghostApis.current, apiKey: ik(sc), quietPick: true, zoom: 1, reloadSeq, tweak: sc.v ? null : tweak, styleEdit: styleEdit && !sc.v, styleSel: sty && sty.key === sc.key ? sty.selector : '', styleCss: sty && sty.key === sc.key ? sty.live : null })))) : null
9308
+ const root = (...kids) => h('div', rootProps, ...kids, url && homeAt ? homeView(true) : null, libLayer, dropLayer, fileInput, pageFileInput, ghostLayer)
8810
9309
 
8811
9310
  // ── 设计库:打成 zip、拖进来的设计包、存成我的风格 ──
8812
9311
  function openPack(dir) {
@@ -8925,6 +9424,9 @@ ${Object.entries(CHIP_ICON).map(([k, d]) => `[data-composer-chip="${chipSrc(k)}"
8925
9424
  if (pane === 'zip' && zipIssues) {
8926
9425
  return h(ZipIssues, { t, issues: zipIssues, onClose: () => { setPane(''); setZipIssues(null) } })
8927
9426
  }
9427
+ if (pane === 'export') {
9428
+ return h(ExportPanel, { t, kind, size, opts: xo, setOpts: setXo, screens: shown.map(ik).join('|'), rev: `${st ? st.rev : 0}|${reloadSeq}|${loadTick}`, measure: () => withFrames(measureAll), onResize: (s) => change({ size: s }), onExport: (format) => doExport(format, undefined, xo), onClose: () => setPane('') })
9429
+ }
8928
9430
  if (pane === 'handoff') {
8929
9431
  return h(HandoffPanel, { t, sid, root: fileTarget ? st.target.root : '', fileTarget, count: screens.length, cur: (curScreen && curScreen.key) || focus, onGo: doHandoff, onSay: say, onClose: () => setPane('') })
8930
9432
  }
@@ -9153,9 +9655,10 @@ ${Object.entries(CHIP_ICON).map(([k, d]) => `[data-composer-chip="${chipSrc(k)}"
9153
9655
  reveal,
9154
9656
  inset: ck || styleEdit || panel || pane || hist || phone ? 296 : 0, // 右边的面板 276 宽,离边 10
9155
9657
  render: (sc, z) => renderScreen(sc, z, false),
9658
+ sleep: sleepScreen,
9156
9659
  flows,
9157
9660
  onSelect: setSel,
9158
- onOpen: (key) => change({ view: 'single', focus: key }),
9661
+ onOpen: (key) => openByUser(key),
9159
9662
  })
9160
9663
  } else {
9161
9664
  const fill = kind === 'web'
@@ -9170,7 +9673,7 @@ ${Object.entries(CHIP_ICON).map(([k, d]) => `[data-composer-chip="${chipSrc(k)}"
9170
9673
  const z = lock ? Math.max(0.05, Math.min(1, box.w / lock.w, ah / lock.h)) : fill ? 1 : Math.max(0.05, Math.min(1, (box.w - aside - 32) / dw, (ah - 16 - (ver || hintTop || busyGap ? 46 : 0)) / dh))
9171
9674
  const one = ver ? shown.find((x) => x.key === focus) || shown[0] || { key: focus, url, label: st.label } : { key: focus, url, label: st.label }
9172
9675
  // 单屏时模型在写新的一屏:先看着它写(没在选、改字、调样式、标注的时候),写完换过去
9173
- const watch = dr && !ver && !demo && !picking && !textEdit && !styleEdit && !mark && !lock
9676
+ const watch = dr && !ver && !demo && !picking && !textEdit && !styleEdit && !mark && !lock && !peekR.current
9174
9677
  if (watch) singleDraftR.current = dr.key || '*' // 还不知道是哪屏:名字到了再说
9175
9678
  body = h('div', { className: 'ddp-single', style: aside ? { right: aside } : undefined },
9176
9679
  h('div', { className: 'ddp-fit' + (fill && !lock ? ' fill' : ''), style: fill && !lock ? undefined : { width: lock ? lock.w : dw, height: lock ? lock.h : dh, transform: `translate(-50%, -50%) scale(${z})` } },
@@ -9397,7 +9900,7 @@ ${Object.entries(CHIP_ICON).map(([k, d]) => `[data-composer-chip="${chipSrc(k)}"
9397
9900
  // 注意:这里是客户端**服务名**(短的),不是包名
9398
9901
  exports.inject = INJECT
9399
9902
  // 测试用
9400
- exports._test = { autoSize, pulseStep, MarketDetail, dragKind, droppedOf, pickInfo, pickLabel, pickRanges, pickRule, chipOf, chipRanges, makeT, ZH, EN, formatCheck, formatTweaks, markHit, markPath, STYLES, formatStyle, accentUse, autoStyle, styleLook, padInsert, pageOf, pxOf, styleChanges, formatStyleAsk, takesOf, formatCheckTool, poller, frameOf, paletteOf, formatRef, layoutRow, keyOfPath, flowsOf, flowLines, flowMarks, formatPick, whereOf, parseMeta, sizeOf, layoutGrid, fitCam, tokenKind, formatToken, splitTitles, pickColors, hhmm, formatTpl, formatPrep, styleFromTokens, myStyleOf, isZipFile }
9903
+ exports._test = { precheckOf, fitCanvas, layoutOk, fitHOk, autoSize, pulseStep, MarketDetail, dragKind, droppedOf, pickInfo, pickLabel, pickRanges, pickRule, chipOf, chipRanges, makeT, ZH, EN, formatCheck, formatTweaks, markHit, markPath, STYLES, formatStyle, accentUse, autoStyle, styleLook, padInsert, pageOf, pxOf, styleChanges, formatStyleAsk, takesOf, formatCheckTool, poller, frameOf, paletteOf, formatRef, layoutRow, keyOfPath, flowsOf, flowLines, flowMarks, formatPick, whereOf, parseMeta, sizeOf, layoutGrid, fitCam, nearestLive, LIVE_MAX, tokenKind, formatToken, splitTitles, pickColors, hhmm, formatTpl, formatPrep, styleFromTokens, myStyleOf, isZipFile }
9401
9904
  return module.exports
9402
9905
  },
9403
9906
  })