dsh-design-studio 0.26.0 → 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/README.en.md CHANGED
@@ -42,7 +42,7 @@ If DSH can't reach the npm registry, it falls back to a mirror in China. To upda
42
42
  - **Open what you have:** click "Browse…" on the empty page to pick an HTML file, or drop an HTML file or folder onto the sidebar (desktop app); you can also type a path or a dev-server port.
43
43
  - **Design check:** one click finds overflowing text, low contrast, small tap targets and tiny text, marked right on the page. In Design mode the model also checks its own work and fixes what it finds.
44
44
  - **Versions and compare:** every turn is saved; drag a slider to compare, and go back to any version.
45
- - **Export and phone preview:** showcase images, PDF and PowerPoint (links between screens still work); scan a QR code to see it on your phone at real size. Slides and posters larger than the default canvas now use the page's real size. You can also set it by adding `WIDTHxHEIGHT` after the type, for example `<meta name="dsh-design" content="slides 1440x810">`. Export options let you pick the page size (16:9, 4:3, A3 landscape or custom), what each page shows (one screen, full page or a set height) and two screens per page. If anything would be cut off, you get a checklist first, with a one-click fix that fits the canvas to the content.
45
+ - **Export and phone preview:** showcase images, PDF and PowerPoint (links between screens still work), or a clickable HTML demo that opens with a double-click (device frame included, ready to send to a client), or share it as a temporary public link (beta; opens in WeChat or any browser, closes after 2 hours); scan a QR code to see it on your phone at real size. Slides and posters larger than the default canvas now use the page's real size. You can also set it by adding `WIDTHxHEIGHT` after the type, for example `<meta name="dsh-design" content="slides 1440x810">`. Export options let you pick the page size (16:9, 4:3, A3 landscape or custom), what each page shows (one screen, full page or a set height) and two screens per page. If anything would be cut off, you get a checklist first, with a one-click fix that fits the canvas to the content.
46
46
  - **Diagrams:** mind maps, technical route charts (the kind in grant proposals and theses), product roadmaps and system architecture diagrams. Lines, branches and arrows are laid out for you and re-flow when you change text or add nodes; colors follow the design style, and a high-resolution PNG or PDF export drops straight into Word or PowerPoint. For grant-proposal and final-report frameworks, the model first lists how the parts relate (which problem maps to which task) for you to confirm, then draws labelled arrows between the blocks, in a bold 3D-gradient "proposal" style by default or after a reference image you give it.
47
47
  - **DSH plugins:** design a plugin inside the real DSH desktop frame (left sidebar entry, settings section, session tab or right sidebar panel, in light and dark). Only the plugin area is designed, so you see exactly how it looks once installed; the design check warns if the frame gets changed.
48
48
  - **Design library and gallery:** everything you've designed, plus saved references and styles, lives in the Library. Browse templates, design systems and style cards others shared, and "Start from this" copies one for you to keep editing. Share your own with "Share to the gallery": it's checked, zipped and submitted on a web page, and listed once reviewed. The gallery catalog comes from npm mirrors and is used only when its signature and checksums match; to keep it offline, turn on "Design library offline" on the Plugins page.
package/README.md CHANGED
@@ -42,7 +42,7 @@
42
42
  - **打开已有的页面**:首页输入框左边的「+」→「打开已有的 HTML…」选一个,或把 HTML 文件 / 文件夹拖进右侧栏就能预览(桌面版);也能输路径或开发服务器端口。
43
43
  - **设计体检**:一键查文字溢出、对比度不够、按钮太小、字太小,问题直接标在页面上;模型做完也会自己查一遍再改。
44
44
  - **版本和对比**:每轮自动存一版,左右拖动对比,随时回到任意一版。
45
- - **导出和手机上看**:导出展示图、PDF、PPT(屏和屏之间的跳转照样能点);扫码在手机上按真机尺寸看。页面比默认画幅大的幻灯片、海报,画幅自动跟页面走;也可以在类型后面跟 `宽x高` 指定,比如 `<meta name="dsh-design" content="slides 1440x810">`。导出选项里可以选版面(16:9、4:3、A3 横向、自定义)、每页取景(一屏、整页、指定高度)和每页拼 2 屏;有内容会被裁时,导出前先给一张清单,可以一键按内容改画幅。
45
+ - **导出和手机上看**:导出展示图、PDF、PPT(屏和屏之间的跳转照样能点),或一个双击就能开的 HTML 演示(带外壳、点得动,发给客户直接看),也能临时发个公网链接(实验,微信里点开就能看,2 小时自动关);扫码在手机上按真机尺寸看。页面比默认画幅大的幻灯片、海报,画幅自动跟页面走;也可以在类型后面跟 `宽x高` 指定,比如 `<meta name="dsh-design" content="slides 1440x810">`。导出选项里可以选版面(16:9、4:3、A3 横向、自定义)、每页取景(一屏、整页、指定高度)和每页拼 2 屏;有内容会被裁时,导出前先给一张清单,可以一键按内容改画幅。
46
46
  - **图表**:思维导图、技术路线图(申报书、开题报告那种)、产品路线图、系统架构图。连线、分叉、箭头自动排好,改字、加节点自己重排;配色跟着设计风格走,导出高清 PNG 或 PDF 贴进 Word / PPT。申报书、结题报告的框架图先帮你理清「哪个问题对应哪项内容」请你确认再画,版块之间画出带关系词的箭头;默认是立体渐变的「申报书炫酷样式」,也能照你给的参考图画。
47
47
  - **DSH 插件**:给 DSH 做插件界面时,四周直接套上 DSH 桌面端的外框(左侧栏入口、设置分区、会话标签页、右侧栏面板四个位置,浅色、深色都有),只设计插件那一块,一眼看出装进 DSH 是什么样;外框被改了体检会提醒。
48
48
  - **设计库和设计市场**:以前做过的设计、收的参考图和风格都在「设计库」里;市场里逛大家分享的模板、设计系统和风格卡,点「用这个开始」复制一份接着改。自己做的点「分享到设计市场」,查过打成 zip,在网页里交上去,审过就上架。市场目录从 npm 镜像取,签了名、核对过才用;不想让它联网,在插件页打开「设计库不联网」。
package/lib/browser.js CHANGED
@@ -265,6 +265,25 @@ export function createBrowser({ bin = findBrowser(), log = () => {}, idleMs = ID
265
265
  // 换深浅色媒体(prefers-color-scheme),不重开页面:存外框时浅色、深色都在真的媒体环境下量
266
266
  media: (dk) => c('Emulation.setEmulatedMedia', { features: [{ name: 'prefers-color-scheme', value: dk ? 'dark' : 'light' }, { name: 'prefers-reduced-motion', value: 'reduce' }] }),
267
267
  mouse: (x, y) => c('Input.dispatchMouseEvent', { type: 'mouseMoved', x, y }), // 把鼠标挪到页面上某处(测「鼠标停在外框上」用)
268
+ // 在页面里最后一个子 iframe 里跑一段(沙盒、不透明源的也行:开一个隔离环境,DOM 是同一份)。测 HTML 演示包用
269
+ frameEval: async (expression) => {
270
+ const { frameTree } = await c('Page.getFrameTree')
271
+ const kids = frameTree.childFrames || []
272
+ let r
273
+ if (kids.length) {
274
+ const { executionContextId } = await c('Page.createIsolatedWorld', { frameId: kids[kids.length - 1].frame.id, worldName: 'ddp-test' })
275
+ r = await c('Runtime.evaluate', { expression, contextId: executionContextId, awaitPromise: true, returnByValue: true })
276
+ } else {
277
+ // 沙盒 iframe 在单独的进程里(站点隔离):是另一个目标,连上去跑
278
+ const { targetInfos } = await call('Target.getTargets')
279
+ const fr = targetInfos.filter((x) => x.type === 'iframe')
280
+ if (!fr.length) throw new Error('no child frame')
281
+ const { sessionId: fs2 } = await call('Target.attachToTarget', { targetId: fr[fr.length - 1].targetId, flatten: true })
282
+ try { r = await call('Runtime.evaluate', { expression, awaitPromise: true, returnByValue: true }, fs2) } finally { call('Target.detachFromTarget', { sessionId: fs2 }).catch(() => {}) }
283
+ }
284
+ if (r.exceptionDetails) throw new Error((r.exceptionDetails.exception && r.exceptionDetails.exception.description) || r.exceptionDetails.text || 'eval failed')
285
+ return r.result ? r.result.value : undefined
286
+ },
268
287
  eval: async (expression) => {
269
288
  const r = await c('Runtime.evaluate', { expression, awaitPromise: true, returnByValue: true })
270
289
  if (r.exceptionDetails) throw new Error((r.exceptionDetails.exception && r.exceptionDetails.exception.description) || r.exceptionDetails.text || 'eval failed')
package/lib/client.js CHANGED
@@ -200,6 +200,11 @@ window.__ModuleLoader__.load({
200
200
  exPptx: 'PPT · 每屏一页(整页图片)',
201
201
  exOpts: '导出选项…',
202
202
  exportedDocMiss: '已导出 {name}({n} 页,{miss} 屏没截到)',
203
+ exHtml: '整套 HTML 演示(双击就能开)',
204
+ exportedHtml: '已导出 {name}({n} 屏,发给别人双击就能看)',
205
+ exportedHtmlMiss: '已导出 {name}({n} 屏,{miss} 屏没读到)',
206
+ htmlTooBig: '图片太多,演示包超过 150 MB,没导出。少放几屏再试',
207
+ htmlNoScreens: '一屏都没读到(文件被挪走或删了?),没导出',
203
208
  xoTitle: '导出选项',
204
209
  xoTip: '不动这里,导出的结果和直接导出一样。',
205
210
  xoWarn: '有内容会被裁掉,先看一眼',
@@ -505,6 +510,55 @@ window.__ModuleLoader__.load({
505
510
  phoneFail: '没打开:{msg}',
506
511
  phoneHelp: '确认在同一个 Wi-Fi;手机开着代理 / VPN 的先关掉;电脑问「是否允许传入连接」时点允许。',
507
512
  phoneTrouble: '打不开?',
513
+ pub: '公网链接(实验)',
514
+ exPub: '发公网链接(实验)',
515
+ pubWhat: '发个链接给不在身边的人看',
516
+ pubP1: '对方不用连同一个 Wi-Fi,微信里点开就能看、能点着换屏',
517
+ pubP2: '只放这套设计的整套演示,电脑上别的东西都碰不到',
518
+ pubP3: '2 小时后自动关,也能随时关;关了链接马上失效',
519
+ pubP4: '走 Cloudflare 的免费临时通道(trycloudflare.com),不经过我们的服务器',
520
+ pubGo: '生成链接',
521
+ pubStarting: '正在连 Cloudflare…',
522
+ pubStartingFine: '一般 10 秒左右',
523
+ pubReady: '公网可见',
524
+ pubLeft: '还剩 {t}',
525
+ pubViews: '打开过 {n} 次',
526
+ pubHow: '微信、浏览器里打开都行',
527
+ pubLive: '改了这几屏,对方刷新就是新的;换到别的设计会自动关。',
528
+ pubWarn: '拿到链接的人都能看,别发到公开的群里。',
529
+ pubCopied: '链接已复制,可以发到微信里',
530
+ pubStop: '停止分享',
531
+ pubNeed: '要先装 cloudflared:Cloudflare 的临时通道工具,免费、不用注册。',
532
+ pubDl: '下载(约 19 MB)',
533
+ pubDlFrom: '从 Cloudflare 官方 GitHub 下载,放进插件自己的目录。',
534
+ pubDling: '正在下载 cloudflared… {p}',
535
+ pubDlFail: '没下载下来:{msg}',
536
+ pubSelf: '也可以自己装:Mac 在终端里运行 brew install cloudflared;Windows 运行 winget install --id Cloudflare.cloudflared。装好后这里会出现「生成链接」。',
537
+ pubDlCancel: '取消下载',
538
+ pubGone: '设计换了(或者现在看的不是本地文件),没有生成。确认要放的是这套设计再点一次。',
539
+ pubScreens: '会放出这 {n} 屏:{names}。之后新加的屏不会自动放出去。',
540
+ pubShared: '放出去的是这 {n} 屏:{names}',
541
+ pubBrokenShort: '对方现在打不开',
542
+ pubBroken: '对方现在打开会看到「暂时打不开」:{why}。改好后对方刷新就行,也可以先停止分享。',
543
+ pubDlStalled: '下载卡住了(30 秒没动),多半是连不上 GitHub。可以再试,或者按下面的方法自己装。',
544
+ pubDlNoBuild: '这台电脑的系统没有现成的 cloudflared,要自己装。',
545
+ pubReconnecting: '正在重连',
546
+ pubReconnectingFine: '和 Cloudflare 暂时断了,正在自己重连,链接不变;90 秒还没连上就关掉。',
547
+ pubRetry: '再试',
548
+ pubFail: '没连上 Cloudflare:{msg}',
549
+ pubFailHint: '公司网络、代理软件有时会拦;换个网络或关掉代理再试。',
550
+ pubTooBig: '图片太多,演示超过 150 MB,发不了。少放几屏再试',
551
+ pubNoScreens: '一屏都没读到(文件被挪走或删了?)',
552
+ pubEndExpired: '上一个链接到 2 小时,自动关了。',
553
+ pubEndDropped: '上一个链接断了(网络变了或电脑睡着了),已经失效。',
554
+ pubEndMoved: '换了设计,上一个链接关了。',
555
+ pubAgain: '再生成一个(链接会变)',
556
+ pubTrouble: '对方打不开?',
557
+ pubHelp: '刚生成的链接要等几秒才打得开。微信里提示风险或打不开,让对方点右上角,选「在浏览器打开」。电脑睡着、合上盖子,链接也会断。',
558
+ pubOff: '公网链接关了:{why}',
559
+ pubWhyExpired: '到 2 小时了',
560
+ pubWhyDropped: '通道断了',
561
+ pubWhyMoved: '换了设计',
508
562
  zoomIn: '放大',
509
563
  zoomOut: '缩小',
510
564
  fit: '适合画布',
@@ -1128,6 +1182,11 @@ window.__ModuleLoader__.load({
1128
1182
  exPptx: 'PowerPoint · one slide per screen (as images)',
1129
1183
  exOpts: 'Export options…',
1130
1184
  exportedDocMiss: 'Exported {name} ({n} pages, {miss} screens could not be captured)',
1185
+ exHtml: 'Clickable HTML demo (opens with a double-click)',
1186
+ exportedHtml: 'Exported {name} ({n} screens; anyone can open it with a double-click)',
1187
+ exportedHtmlMiss: 'Exported {name} ({n} screens, {miss} could not be read)',
1188
+ htmlTooBig: 'Too many images: the demo would be over 150 MB, so nothing was exported. Try with fewer screens',
1189
+ htmlNoScreens: 'None of the screens could be read (moved or deleted?), so nothing was exported',
1131
1190
  xoTitle: 'Export options',
1132
1191
  xoTip: 'Leave these alone and the file comes out the same as a direct export.',
1133
1192
  xoWarn: 'Some content would be cut off. Have a look first',
@@ -1433,6 +1492,55 @@ window.__ModuleLoader__.load({
1433
1492
  phoneFail: 'Could not start: {msg}',
1434
1493
  phoneHelp: 'Check both are on the same Wi-Fi, turn off any VPN or proxy on the phone, and allow incoming connections if your computer asks.',
1435
1494
  phoneTrouble: "Won't open?",
1495
+ pub: 'Public link (beta)',
1496
+ exPub: 'Public link (beta)',
1497
+ pubWhat: 'Send a link to someone who is not nearby',
1498
+ pubP1: 'No shared Wi-Fi needed: they open it in WeChat or any browser and can click through the screens',
1499
+ pubP2: 'Only this design\'s clickable demo goes out; nothing else on your computer is reachable',
1500
+ pubP3: 'Closes after 2 hours, or whenever you stop it; the link stops working right away',
1501
+ pubP4: 'Uses a free Cloudflare quick tunnel (trycloudflare.com), not our servers',
1502
+ pubGo: 'Create link',
1503
+ pubStarting: 'Connecting to Cloudflare…',
1504
+ pubStartingFine: 'Usually about 10 seconds',
1505
+ pubReady: 'Public',
1506
+ pubLeft: '{t} left',
1507
+ pubViews: 'Opened {n} times',
1508
+ pubHow: 'Opens in WeChat or any browser',
1509
+ pubLive: 'Edits to these screens show up when they refresh. Switching to another design closes the link.',
1510
+ pubWarn: 'Anyone with the link can see it. Don\'t post it in public groups.',
1511
+ pubCopied: 'Link copied. Paste it into a chat',
1512
+ pubStop: 'Stop sharing',
1513
+ pubNeed: 'This needs cloudflared, Cloudflare\'s free tunnel tool (no account needed).',
1514
+ pubDl: 'Download (about 19 MB)',
1515
+ pubDlFrom: 'Downloaded from Cloudflare\'s official GitHub into the plugin\'s own folder.',
1516
+ pubDling: 'Downloading cloudflared… {p}',
1517
+ pubDlFail: 'Download failed: {msg}',
1518
+ pubSelf: 'Or install it yourself: on a Mac run brew install cloudflared; on Windows run winget install --id Cloudflare.cloudflared. Create link shows up here once it is installed.',
1519
+ pubDlCancel: 'Cancel download',
1520
+ pubGone: 'The design changed (or this isn\'t a local file), so no link was created. Check it\'s the right design and try again.',
1521
+ pubScreens: 'Shares these {n} screens: {names}. Screens added later are not shared automatically.',
1522
+ pubShared: 'Sharing these {n} screens: {names}',
1523
+ pubBrokenShort: 'Visitors can\'t open it now',
1524
+ pubBroken: 'Visitors currently see "Not available": {why}. Once fixed they can just refresh, or you can stop sharing.',
1525
+ pubDlStalled: 'The download stalled (no progress for 30 seconds), probably because GitHub is unreachable. Try again, or install it yourself as below.',
1526
+ pubDlNoBuild: 'There is no ready-made cloudflared for this system. Please install it yourself.',
1527
+ pubReconnecting: 'Reconnecting',
1528
+ pubReconnectingFine: 'Lost the connection to Cloudflare for now and reconnecting. The link stays the same; it closes if not back within 90 seconds.',
1529
+ pubRetry: 'Try again',
1530
+ pubFail: 'Could not reach Cloudflare: {msg}',
1531
+ pubFailHint: 'Office networks and proxy apps sometimes block it. Try another network or turn off the proxy.',
1532
+ pubTooBig: 'Too many images: the demo would be over 150 MB. Try with fewer screens',
1533
+ pubNoScreens: 'None of the screens could be read (moved or deleted?)',
1534
+ pubEndExpired: 'The last link closed after 2 hours.',
1535
+ pubEndDropped: 'The last link dropped (network changed or the computer slept) and no longer works.',
1536
+ pubEndMoved: 'You switched designs, so the last link was closed.',
1537
+ pubAgain: 'Create a new link (it will change)',
1538
+ pubTrouble: "They can't open it?",
1539
+ pubHelp: 'A new link takes a few seconds to start working. If WeChat warns or won\'t open it, tap the top-right menu and open it in the browser. The link also drops if the computer sleeps.',
1540
+ pubOff: 'Public link closed: {why}',
1541
+ pubWhyExpired: '2 hours are up',
1542
+ pubWhyDropped: 'the tunnel dropped',
1543
+ pubWhyMoved: 'you switched designs',
1436
1544
  zoomIn: 'Zoom in',
1437
1545
  zoomOut: 'Zoom out',
1438
1546
  fit: 'Fit',
@@ -2278,6 +2386,9 @@ window.__ModuleLoader__.load({
2278
2386
  .ddp-phone .fine{color:var(--dsw-alias-label-tertiary);font-size:11px;line-height:16px}
2279
2387
  .ddp-phone .row{display:flex;gap:6px;margin-top:6px}
2280
2388
  .ddp-phone .row .ddp-go{height:28px;padding:0 12px;font-size:12px}
2389
+ .ddp-phone .warn{color:#c2410c}
2390
+ .ddp-pub .ddp-publist{margin:2px 0 4px;padding:0 0 0 18px;text-align:left;display:flex;flex-direction:column;gap:3px}
2391
+ .ddp-pub .ddp-publink{width:100%;box-sizing:border-box;height:28px;padding:0 8px;border-radius:7px;border:.5px solid var(--dsw-alias-border-primary,rgba(0,0,0,.15));background:var(--dsw-alias-bg-layer-2);color:var(--dsw-alias-label-primary);font:11px/28px ui-monospace,SFMono-Regular,Menlo,monospace;text-overflow:ellipsis}
2281
2392
  @keyframes ddp-pulse{50%{opacity:1}}
2282
2393
  .ddp-tokens .none{padding:6px 6px 0;color:var(--dsw-alias-label-secondary);line-height:1.6}
2283
2394
  .ddp-tokens .none .ddp-go{margin-top:10px}
@@ -7696,6 +7807,143 @@ ${Object.entries(CHIP_ICON).map(([k, d]) => `[data-composer-chip="${chipSrc(k)}"
7696
7807
  h('div', { className: 'bd' }, bd))
7697
7808
  }
7698
7809
 
7810
+ /**
7811
+ * 公网链接(#27,实验):把整套 HTML 演示临时放到公网上(cloudflared 临时通道),给链接和二维码。
7812
+ * 开之前先说清楚是公网可见;没装 cloudflared 的先请人下载;连上了显示还剩多久、打开过几次
7813
+ */
7814
+ function PubPanel({ t, sid, body, brief, onCopy, onClose }) {
7815
+ const [res, setRes] = useState(null)
7816
+ const [err, setErr] = useState('')
7817
+ const [busy, setBusy] = useState(false)
7818
+ const [, setNow] = useState(0)
7819
+ const resRef = useRef(null)
7820
+ // 回包可能乱序:只认比上一次用过的更晚发出的(关掉以后,之前发出去的 peek 晚到也不会把旧链接显示回来)
7821
+ const seq = useRef(0)
7822
+ const used = useRef(0)
7823
+ const send = (b) => { const n = ++seq.current; return post('pubshare', b).then((d) => { if (n > used.current) { used.current = n; take(d) } return d }) }
7824
+ const take = (d) => { resRef.current = d; setRes(d); setErr('') }
7825
+ useEffect(() => {
7826
+ let alive = true
7827
+ let tm = 0
7828
+ const tick = () => send({ session: sid, peek: true }).catch((e) => { if (alive) setErr(e.message) }).finally(() => {
7829
+ if (!alive) return
7830
+ const r = resRef.current
7831
+ const fast = r && ((r.on && r.state === 'starting') || (r.dl && !r.dl.done))
7832
+ tm = setTimeout(tick, fast ? 700 : 3000)
7833
+ })
7834
+ tick()
7835
+ const clock = setInterval(() => setNow(Date.now()), 1000)
7836
+ return () => { alive = false; seq.current++; used.current = seq.current; clearTimeout(tm); clearInterval(clock) }
7837
+ }, [sid])
7838
+ // 马上不显示旧链接和二维码(之前发出去还没回来的回包作废),再马上问一次完整状态,不等下一次轮询
7839
+ const dropNow = (ended) => {
7840
+ const r = resRef.current
7841
+ used.current = ++seq.current // 不管面板现在显示什么,之前发出去的都作废(第一次 peek 还没回来也一样)
7842
+ if (r && r.on) take({ on: false, ended, tool: r.tool })
7843
+ send({ session: sid, peek: true }).catch(() => {})
7844
+ }
7845
+ // 右侧栏的状态从开变成关(到点、断了、起不来)(起不来的具体原因等 peek 带回来,先不显示个代号)。
7846
+ // 面板正在「连」的时候不管:刚停了又点生成,停的那一刻的旧状态晚到,别把新的闪成关
7847
+ const briefOn = brief ? !!brief.on : null
7848
+ const briefWas = useRef(briefOn)
7849
+ useEffect(() => {
7850
+ const was = briefWas.current
7851
+ briefWas.current = briefOn
7852
+ const r = resRef.current
7853
+ if (was === true && briefOn === false && !(r && r.on && r.state === 'starting')) dropNow((brief && brief.ended) || '')
7854
+ }, [briefOn])
7855
+ // 换了设计(地址栏、拖进来、设计库 / 市场「用这个」……哪条路都算):链接已经跟着关了,面板马上跟上
7856
+ const tk = body().target
7857
+ const tkWas = useRef(tk)
7858
+ useEffect(() => {
7859
+ if (tkWas.current === tk) return
7860
+ tkWas.current = tk
7861
+ dropNow('moved')
7862
+ }, [tk])
7863
+ const start = () => {
7864
+ setBusy(true)
7865
+ send({ session: sid, on: true, ...body() }).then((d) => {
7866
+ if (!d.on && d.error === 'no-cloudflared' && !d.tool) return download()
7867
+ }).catch((e) => setErr(e.message)).finally(() => setBusy(false))
7868
+ }
7869
+ const download = () => send({ session: sid, download: true }).catch((e) => setErr(e.message))
7870
+ const cancel = () => send({ session: sid, cancel: true }).catch((e) => setErr(e.message))
7871
+ const stop = () => send({ session: sid, on: false }).catch((e) => setErr(e.message))
7872
+ // 下完了不自动生成:面板回到「会放出这几屏」+「生成链接」,按下载完时的画布让人再看一眼、自己点
7873
+ const left = (ms) => {
7874
+ const x = Math.max(0, Math.round(ms / 1000))
7875
+ return `${Math.floor(x / 3600)}:${String(Math.floor((x % 3600) / 60)).padStart(2, '0')}:${String(x % 60).padStart(2, '0')}`
7876
+ }
7877
+ // 会放出去的是哪几屏(画布上的全部屏,单看一屏时也是全部):生成前写清楚
7878
+ const shotList = (() => {
7879
+ const list = (body().screens || []).map((x) => x.label || x.key)
7880
+ if (!list.length) return ''
7881
+ return t('pubScreens', { n: list.length, names: list.join(t('sep')) })
7882
+ })()
7883
+ const errText = (r) => (r.error === 'tooBig' ? t('pubTooBig') : r.error === 'noScreens' ? t('pubNoScreens') : t('pubFail', { msg: r.message || r.error || '' }))
7884
+ // 接口拒了(点生成的那一刻换了设计、或者现在看的不是本地文件):别说成「没连上 Cloudflare」
7885
+ const errMsg = (m) => (m === 'designChanged' || m === 'not-file' ? t('pubGone') : t('pubFail', { msg: m }))
7886
+ const ended = (r) => (r.ended === 'expired' ? t('pubEndExpired') : r.ended === 'dropped' ? t('pubEndDropped') : r.ended === 'moved' ? t('pubEndMoved') : '')
7887
+ let bd
7888
+ if (err && !res) bd = h('p', null, errMsg(err))
7889
+ else if (!res) bd = h('p', null, t('phoneStarting'))
7890
+ else if (res.on && res.state === 'starting') {
7891
+ bd = [
7892
+ h('span', { key: 'st', className: 'st' }, h('i'), t('pubStarting')),
7893
+ h('p', { key: 'f', className: 'fine' }, t('pubStartingFine')),
7894
+ h('div', { key: 'row', className: 'row' }, h('button', { className: 'ddp-go sec', onClick: stop }, t('pubStop'))),
7895
+ ]
7896
+ } else if (res.on) {
7897
+ bd = [
7898
+ h('div', { key: 'qr', className: 'qr' }, h(QrCode, { rows: res.qr || [] })),
7899
+ h('b', { key: 'how', className: 'how' }, t('pubHow')),
7900
+ h('input', { key: 'url', className: 'ddp-publink', readOnly: true, value: res.url, onFocus: (e) => e.target.select(), 'aria-label': t('pub') }),
7901
+ h('span', { key: 'st', className: 'st' + (res.state === 'reconnecting' || res.broken ? '' : ' ok') }, res.state === 'reconnecting' || res.broken ? h('i') : h(I.check), (res.broken ? t('pubBrokenShort') : res.state === 'reconnecting' ? t('pubReconnecting') : t('pubReady')) + ' · ' + t('pubLeft', { t: left(res.expires - Date.now()) }) + (res.views ? ' · ' + t('pubViews', { n: res.views }) : '')),
7902
+ res.state === 'reconnecting' ? h('p', { key: 'rc', className: 'fine warn' }, t('pubReconnectingFine')) : null,
7903
+ res.broken ? h('p', { key: 'broken', className: 'fine warn' }, t('pubBroken', { why: res.broken === 'tooBig' ? t('pubTooBig') : res.broken === 'noScreens' ? t('pubNoScreens') : res.broken })) : null,
7904
+ res.screens && res.screens.length ? h('p', { key: 'scr', className: 'fine' }, t('pubShared', { n: res.screens.length, names: res.screens.join(t('sep')) })) : null,
7905
+ h('p', { key: 'live', className: 'fine' }, t('pubLive')),
7906
+ h('p', { key: 'warn', className: 'fine warn' }, t('pubWarn')),
7907
+ h('div', { key: 'row', className: 'row' },
7908
+ h('button', { className: 'ddp-go sec', onClick: stop }, t('pubStop')),
7909
+ h('button', { className: 'ddp-go', onClick: () => onCopy(res.url) }, t('phoneCopy'))),
7910
+ h('details', { key: 'more', className: 'fine' }, h('summary', null, t('pubTrouble')), h('p', null, t('pubHelp'))),
7911
+ ]
7912
+ } else if (res.dl && !res.dl.done && !res.tool) {
7913
+ const pct = res.dl.total ? Math.round((res.dl.got / res.dl.total) * 100) + '%' : Math.round(res.dl.got / 1048576) + ' MB'
7914
+ bd = [
7915
+ h('span', { key: 'st', className: 'st' }, h('i'), t('pubDling', { p: pct })),
7916
+ h('p', { key: 'f', className: 'fine' }, t('pubDlFrom')),
7917
+ h('p', { key: 'self', className: 'fine' }, t('pubSelf')),
7918
+ h('div', { key: 'row', className: 'row' }, h('button', { className: 'ddp-go sec', onClick: cancel }, t('pubDlCancel'))),
7919
+ ]
7920
+ } else {
7921
+ // 没开:先说清楚是公网可见;本机没有 cloudflared 的,主按钮变成「下载」(下完接着生成)
7922
+ const why = res.error ? errText(res) : ended(res)
7923
+ const noTool = !res.tool
7924
+ bd = [
7925
+ h('b', { key: 'what', className: 'how' }, t('pubWhat')),
7926
+ h('ul', { key: 'ul', className: 'ddp-publist' }, ['pubP1', 'pubP2', 'pubP3', 'pubP4'].map((k) => h('li', { key: k }, t(k)))),
7927
+ shotList ? h('p', { key: 'scr', className: 'fine' }, shotList) : null,
7928
+ why && res.error !== 'no-cloudflared' ? h('p', { key: 'why', className: 'warn' }, why) : null,
7929
+ res.error === 'tunnel' || res.error === 'timeout' ? h('p', { key: 'hint', className: 'fine' }, t('pubFailHint')) : null,
7930
+ err ? h('p', { key: 'err', className: 'warn' }, errMsg(err)) : null,
7931
+ noTool ? h('p', { key: 'need' }, t('pubNeed')) : null,
7932
+ noTool && res.dl && res.dl.error ? h('p', { key: 'dlf', className: 'warn' }, res.dl.error === 'stalled' ? t('pubDlStalled') : res.dl.error === 'unsupported' ? t('pubDlNoBuild') : t('pubDlFail', { msg: res.dl.error })) : null,
7933
+ h('div', { key: 'row', className: 'row' },
7934
+ noTool && res.dl && res.dl.error ? h('button', { className: 'ddp-go sec', onClick: start, disabled: busy }, t('pubRetry')) : null,
7935
+ noTool
7936
+ ? h('button', { className: 'ddp-go', disabled: busy, onClick: download }, t('pubDl'))
7937
+ : h('button', { className: 'ddp-go', onClick: start, disabled: busy }, why ? t('pubAgain') : t('pubGo'))),
7938
+ noTool ? h('p', { key: 'from', className: 'fine' }, t('pubDlFrom')) : null,
7939
+ noTool ? h('p', { key: 'self', className: 'fine' }, t('pubSelf')) : null,
7940
+ ]
7941
+ }
7942
+ return h('div', { className: 'ddp-tokens ddp-phone ddp-pub', onPointerDown: (e) => e.stopPropagation() },
7943
+ h('header', null, h(I.web), h('b', null, t('pub')), h('button', { className: 'ddp-btn', title: '×', onClick: onClose }, h(I.close))),
7944
+ h('div', { className: 'bd' }, bd))
7945
+ }
7946
+
7699
7947
  /** 版本面板:现在 + 存过的几版(新的在前),点一版看当时的样子 */
7700
7948
  function HistoryPanel({ t, versions, ver, onPick, onClose }) {
7701
7949
  const files = (list) => {
@@ -9019,7 +9267,7 @@ ${Object.entries(CHIP_ICON).map(([k, d]) => `[data-composer-chip="${chipSrc(k)}"
9019
9267
  // x:这一次画面的值(会话、状态、类型、画幅、几屏…)、几个 ref(各屏接口、背后挂的那批、设计序号)和面板里共用的 apiOf / targetKey
9020
9268
  // onWarn:预检发现会被裁时打开导出选项
9021
9269
  function makeExporter(x) {
9022
- const { sid, st, kind, size, dark, meta, tokens, t, say, canvas, focus, sel, shown, ik, labelOf, infoOf, fileTarget, ver, apis, designNow, designSeq, ghostApis, ghostBatch, ghostQueue, setBackFrames, warned, onWarn, apiOf, targetKey } = x
9270
+ const { sid, st, kind, size, dark, meta, tokens, t, say, canvas, focus, sel, shown, ik, labelOf, infoOf, fileTarget, ver, apis, designNow, designSeq, ghostApis, ghostBatch, ghostQueue, setBackFrames, warned, onWarn, apiOf, targetKey, tops, tweak, webFit } = x
9023
9271
  // 截一屏:图片和它的 CSS 尺寸(PDF / PPT 按这个定页面大小)
9024
9272
  // 这次导出截到的 AI 示意图(文件名去重):每种导出结束的提示里都带一句「上线前换成真实照片」
9025
9273
  const aiTail = (ai) => (ai && ai.size ? ' · ' + t('xoAi', { n: ai.size }) : '')
@@ -9187,7 +9435,44 @@ ${Object.entries(CHIP_ICON).map(([k, d]) => `[data-composer-chip="${chipSrc(k)}"
9187
9435
  say(e.message === 'designChanged' ? t('xoGone') : t('exportFail', { msg: e.message }))
9188
9436
  }
9189
9437
  }
9190
- return { withFrames, measureAll, exportShots }
9438
+ // 整套 HTML 演示(#26):服务端把每屏连同样式、图片、图标打进一个 .html,不截图(几秒出来)。
9439
+ // 屏、版本、画幅、深浅色、调节滑块没存的值都按眼前的;外壳在演示页面里能开关
9440
+ // 公网链接(#27)也用这一份:右侧栏眼前的屏、画幅、深浅色、调节值
9441
+ const htmlBody = () => {
9442
+ const list = []
9443
+ const seen = new Set()
9444
+ for (const sc of shown) { // 看旧版本时 shown 就是那一版的几屏(都带 v)
9445
+ if (seen.has(sc.key)) continue
9446
+ seen.add(sc.key)
9447
+ list.push(sc)
9448
+ }
9449
+ const sp = splitTitles(list.map((sc) => (infoOf(ik(sc)) || {}).title || sc.label))
9450
+ const folder = st && st.target && st.target.kind === 'file' ? String(st.target.file).split(/[\\/]/).slice(-2, -1)[0] : ''
9451
+ const title = sp.brand || folder || (st && st.label) || ''
9452
+ return {
9453
+ target: targetKey, v: ver ? ver.n : 0,
9454
+ title, lang: t('lang') === 'en' ? 'en' : 'zh', kind, w: size[0], h: size[1], os: meta.os || '', dark: !!dark, tweak: ver ? null : tweak || null, // 旧版本不套调节滑块的值(和画布上一样)
9455
+ // 没开「深色」时页面跟着系统深浅色走:记下右侧栏这会儿是哪种,演示里照这个显示(不跟看的人电脑走)
9456
+ scheme: typeof matchMedia === 'function' && matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'light',
9457
+ fit: !!webFit, // 网页开着「按画幅显示」:演示里默认也套浏览器框、按画幅缩放
9458
+ screens: list.map((sc) => ({ key: sc.key, label: labelOf(sc), top: !!(tops && tops[ik(sc)]) })),
9459
+ }
9460
+ }
9461
+ const exportHtml = async () => {
9462
+ if (!fileTarget) return
9463
+ say(t('exporting'))
9464
+ try {
9465
+ const b = htmlBody()
9466
+ const r = await post('htmlpack', { session: sid, ...b, name: (ver ? `v${ver.n}-` : '') + (b.title || 'design') + (dark ? '-dark' : '') })
9467
+ const file = String(r.path || '').split(/[\\/]/).pop()
9468
+ const miss = Array.isArray(r.missing) ? r.missing.length : 0
9469
+ say((miss ? t('exportedHtmlMiss', { name: file, n: r.count, miss }) : t('exportedHtml', { name: file, n: r.count })) + (r.ai ? ' · ' + t('xoAi', { n: r.ai }) : ''), { label: t('reveal'), run: () => post('reveal', { path: r.path }).catch(() => {}) })
9470
+ } catch (e) {
9471
+ const m = String((e && e.message) || '')
9472
+ say(m === 'designChanged' || m === 'not-file' ? t('xoGone') : m === 'tooBig' ? t('htmlTooBig') : m === 'noScreens' ? t('htmlNoScreens') : t('exportFail', { msg: m }))
9473
+ }
9474
+ }
9475
+ return { withFrames, measureAll, exportShots, exportHtml, htmlBody }
9191
9476
  }
9192
9477
 
9193
9478
  // ── 画笔标注(从预览面板里拆出来的):台面上看得到的几屏截图拼好、叠上画的,存进 refs/ 交给模型,或者复制
@@ -9608,6 +9893,7 @@ ${Object.entries(CHIP_ICON).map(([k, d]) => `[data-composer-chip="${chipSrc(k)}"
9608
9893
  const [implAway, setImplAway] = useState('') // 真页面换到了别的路由(点了站内链接):那条路由
9609
9894
  const [dark, setDark] = useState(false)
9610
9895
  const [phone, setPhone] = useState(false) // 手机上看的面板
9896
+ const [pubP, setPubP] = useState(false) // 公网链接的面板
9611
9897
  const [multi, setMulti] = useState(false) // 多尺寸并排
9612
9898
  const ckGen = useRef(0) // 每量一次、每关一次面板 +1:量完发现不是最新的一次就不算数
9613
9899
  const ckOpen = useRef(false) // 面板开着(或正在量):过期的一次结果回来时别清掉新一轮的标记
@@ -10110,7 +10396,7 @@ ${Object.entries(CHIP_ICON).map(([k, d]) => `[data-composer-chip="${chipSrc(k)}"
10110
10396
  setTextEdit(false)
10111
10397
  setPanel(false)
10112
10398
  setHist(false)
10113
- setPhone(false)
10399
+ setPhone(false); setPubP(false)
10114
10400
  closeCheck()
10115
10401
  setStyleEdit(true)
10116
10402
  }
@@ -10305,15 +10591,37 @@ ${Object.entries(CHIP_ICON).map(([k, d]) => `[data-composer-chip="${chipSrc(k)}"
10305
10591
  }
10306
10592
  // ── 导出图片(makeExporter)──
10307
10593
  // 在和做出来的比:导出的「这一屏」是比的那屏,画布没挂着(别的屏在背后挂)
10308
- const { withFrames, measureAll, exportShots } = makeExporter({ apiOf, targetKey, sid, st, kind, size, dark, meta, tokens, t, say, canvas: canvas && !implSc, focus: implSc ? implSc.key : focus, sel, shown, ik, labelOf, infoOf, fileTarget, ver, apis, designNow, designSeq, ghostApis, ghostBatch, ghostQueue, setBackFrames, warned,
10594
+ const { withFrames, measureAll, exportShots, exportHtml, htmlBody } = makeExporter({ apiOf, targetKey, sid, st, kind, size, dark, meta, tokens, t, say, canvas: canvas && !implSc, focus: implSc ? implSc.key : focus, sel, shown, ik, labelOf, infoOf, fileTarget, ver, apis, designNow, designSeq, ghostApis, ghostBatch, ghostQueue, setBackFrames, warned, tops, tweak, webFit,
10309
10595
  onWarn: () => { if (pane !== 'export') openPane('export') } })
10310
10596
  const designId = JSON.stringify([sid, targetKey, ver ? ver.n : 0])
10311
10597
  if (designNow.current !== designId) { designNow.current = designId; designSeq.current++ }
10598
+ // 公网链接(#27)开着:右侧栏换了屏、画幅、深浅色、调节值,对方下次打开就按新的(看旧版本时不动)
10599
+ const pubOn = !!(st && st.pub && st.pub.on)
10600
+ const pubKey = pubOn && !ver ? JSON.stringify(htmlBody()) : ''
10601
+ const lastPub = useRef('')
10602
+ useEffect(() => {
10603
+ if (!pubKey) { lastPub.current = ''; return }
10604
+ if (lastPub.current === pubKey) return
10605
+ lastPub.current = pubKey
10606
+ // 刚开的那次也发:参数一样插件那边什么都不做,不一样(开的时候右侧栏正好在变)就补上
10607
+ post('pubshare', { session: sid, update: true, ...JSON.parse(pubKey) }).catch(() => {})
10608
+ }, [pubKey])
10609
+ // 面板关着的时候链接自己关了(到点、断了、换了设计):说一声
10610
+ const pubEnded = st && st.pub && !st.pub.on ? st.pub.ended || '' : ''
10611
+ const pubKnown = !!(st && st.pub) // 设计库 / 拖 ZIP 换设计的回包里没有 pub:当不知道,等完整状态回来再判断
10612
+ const pubWas = useRef(false)
10613
+ useEffect(() => {
10614
+ if (!pubKnown) return
10615
+ if (pubOn) { pubWas.current = true; return }
10616
+ if (pubWas.current && pubEnded && !pubP) say(t('pubOff', { why: t(pubEnded === 'expired' ? 'pubWhyExpired' : pubEnded === 'dropped' ? 'pubWhyDropped' : 'pubWhyMoved') }))
10617
+ pubWas.current = false
10618
+ }, [pubOn, pubEnded, pubKnown])
10312
10619
  const doExport = async (mode, key, opts) => {
10313
10620
  setExMenu(false)
10314
10621
  if (mode === 'opts') { if (pane !== 'export') openPane('export'); return }
10315
10622
  if (mode === 'zip') return openPack(fileTarget ? st.target.root : '')
10316
10623
  if (mode === 'share') return openShare(fileTarget ? st.target.root : '')
10624
+ if (mode === 'html') return exportHtml()
10317
10625
  return exportShots(mode, key, opts)
10318
10626
  }
10319
10627
 
@@ -10400,7 +10708,7 @@ ${Object.entries(CHIP_ICON).map(([k, d]) => `[data-composer-chip="${chipSrc(k)}"
10400
10708
  // ── 设计体检:画布上量所有屏,单页量这一屏;问题标在页面上,列在面板里 ──
10401
10709
  // 设计体检:量、开面板、定位、交给模型(makeCheck)
10402
10710
  const { closeCheck, checkList, measure, total, runCheck, focusIssue, fixIssues } = makeCheck({ kind, url, st, stRef, canvas, shown, focus, ik, labelOf, apis, apiOf, ck, setCk, ckGen, ckOpen, setCkCount, setReveal, setSel, insert, say, t,
10403
- onOpen: () => { setPanel(false); setHist(false); setPhone(false); setAn(false) } })
10711
+ onOpen: () => { setPanel(false); setHist(false); setPhone(false); setPubP(false); setAn(false) } })
10404
10712
  // 打开一套设计、模型又干完一轮(turns 变了):面板开着就再查一次(改没改好一眼看到);关着就悄悄量一下,问题数标在按钮上。
10405
10713
  // 模型干着活时不量;等一会儿再量:刚写完的屏还在刷新、播生成动画
10406
10714
  const autoCk = useRef(null)
@@ -10446,7 +10754,7 @@ ${Object.entries(CHIP_ICON).map(([k, d]) => `[data-composer-chip="${chipSrc(k)}"
10446
10754
  useEffect(() => { setAnStates({}) }, [anFile ? anFile.sig : '']) // 文件变了(模型改过选择器):别的屏的旧结果作废,等页面重新报
10447
10755
  const toggleAn = () => {
10448
10756
  if (an) { setAn(false); setAnSel(''); return }
10449
- setPanel(false); setHist(false); setPhone(false); setPane(''); closeCheck(); setStyleEdit(false); setMark(false)
10757
+ setPanel(false); setHist(false); setPhone(false); setPubP(false); setPane(''); closeCheck(); setStyleEdit(false); setMark(false)
10450
10758
  setAn(true)
10451
10759
  }
10452
10760
  const focusAn = (a) => {
@@ -10487,6 +10795,7 @@ ${Object.entries(CHIP_ICON).map(([k, d]) => `[data-composer-chip="${chipSrc(k)}"
10487
10795
  setPanel(false)
10488
10796
  setHist(false)
10489
10797
  setPhone(false)
10798
+ setPubP(false)
10490
10799
  closeCheck()
10491
10800
  setPane('')
10492
10801
  // 之前点选 / 调样式留下的「已选」框别夹在标注里
@@ -10514,14 +10823,14 @@ ${Object.entries(CHIP_ICON).map(([k, d]) => `[data-composer-chip="${chipSrc(k)}"
10514
10823
  useEffect(() => { if (checkOff) { setAn(false); setAnSel('') } }, [checkOff])
10515
10824
 
10516
10825
  const toggleDemo = () => (demo ? setDemo(null) : startDemo())
10517
- const openLook = (tab) => { if (tab) setLookTab(tab); setPanel(true); setHist(false); setPhone(false); closeCheck(); setStyleEdit(false); setAn(false) }
10518
- const toggleHist = () => { setHist(!hist); setPanel(false); setPhone(false); closeCheck(); setStyleEdit(false); setAn(false) }
10826
+ const openLook = (tab) => { if (tab) setLookTab(tab); setPanel(true); setHist(false); setPhone(false); setPubP(false); closeCheck(); setStyleEdit(false); setAn(false) }
10827
+ const toggleHist = () => { setHist(!hist); setPanel(false); setPhone(false); setPubP(false); closeCheck(); setStyleEdit(false); setAn(false) }
10519
10828
  // 右边同一时间只开一个面板:别的开了,这几个关掉;开这几个时别的关掉
10520
- const oldOpen = !!(panel || hist || phone || ck || styleEdit)
10829
+ const oldOpen = !!(panel || hist || phone || pubP || ck || styleEdit)
10521
10830
  useEffect(() => { if (oldOpen) setPane('') }, [oldOpen])
10522
10831
  const openPane = (p) => {
10523
10832
  const next = pane === p ? '' : p
10524
- if (next) { setPanel(false); setHist(false); setPhone(false); closeCheck(); setStyleEdit(false); setAn(false) }
10833
+ if (next) { setPanel(false); setHist(false); setPhone(false); setPubP(false); closeCheck(); setStyleEdit(false); setAn(false) }
10525
10834
  setPane(next)
10526
10835
  }
10527
10836
  const setTweak = (k, v) => setTw((c) => {
@@ -10563,7 +10872,8 @@ ${Object.entries(CHIP_ICON).map(([k, d]) => `[data-composer-chip="${chipSrc(k)}"
10563
10872
  }), 'insertedSend')
10564
10873
  setPane('')
10565
10874
  }
10566
- const togglePhone = () => { setPhone(!phone); setPanel(false); setHist(false); closeCheck(); setStyleEdit(false); setAn(false) }
10875
+ const togglePhone = () => { setPhone(!phone); setPubP(false); setPanel(false); setHist(false); closeCheck(); setStyleEdit(false); setAn(false) }
10876
+ const togglePub = () => { setPubP(!pubP); setPhone(false); setPanel(false); setHist(false); closeCheck(); setStyleEdit(false); setAn(false) }
10567
10877
  const reload = () => setReloadSeq((x) => x + 1)
10568
10878
 
10569
10879
  // 浮在画布上的几块,各管一件事,按钮都带字:左上 设计库 | 屏名 ▾(换屏、多尺寸、类型都在这个菜单里);
@@ -10626,15 +10936,17 @@ ${Object.entries(CHIP_ICON).map(([k, d]) => `[data-composer-chip="${chipSrc(k)}"
10626
10936
  anOn ? h('button', { className: 'ddp-btn lab' + (anUp ? ' sel' : ''), ...tipA(t('an'), anCount && !anUp ? t('dAnN', { n: anCount }) : t('dAn')), disabled: checkOff, onClick: toggleAn },
10627
10937
  h(I.note), h('span', { className: 'lb' }, t('an')), anCount && !anUp && !checkOff ? h('span', { className: 'bdg' }, anCount > 99 ? '99+' : String(anCount)) : null) : null,
10628
10938
  h('span', { className: 'ddp-sep' }),
10629
- h(DropMenu, { t, tip: [t('deliver'), t('dExport')], btnCls: 'pri', icon: I.download, label: t('deliver'), caret: true, open: exMenu, setOpen: setExMenu, disabled: !url, items: [
10939
+ h(DropMenu, { t, tip: [t('deliver'), t('dExport')], btnCls: 'pri', icon: I.download, label: t('deliver'), caret: true, has: pubOn && !pubP, open: exMenu, setOpen: setExMenu, disabled: !url, items: [
10630
10940
  'hd:' + t('deliverCode'),
10631
10941
  ['', I.code, t('handoff'), pane === 'handoff', !!ver, () => openPane('handoff')],
10632
10942
  ['', I.overlay, t('implCmp'), !!implSc, !!ver || !exSc || implFar, () => (implSc ? implClose() : implOpen(exSc.key))],
10633
10943
  'hd:' + t('exFiles'),
10634
10944
  ...exportItems(t, kind, shown.length, exName).map(([mode, Icon, label]) => ['', Icon, label, false, false, () => doExport(mode)]),
10945
+ fileTarget ? ['', I.web, t('exHtml'), false, false, () => doExport('html')] : null, // 只有本地文件的设计能打成 HTML(开发服务器的页面靠它跑)
10635
10946
  fileTarget ? 'hd:' + t('deliverShare') : null, // 只有本地的设计才能打包、分享
10636
10947
  fileTarget ? ['', I.box, t('exZip'), false, false, () => doExport('zip')] : null,
10637
10948
  fileTarget ? ['', I.share, t('exShare'), false, false, () => doExport('share')] : null,
10949
+ fileTarget ? ['', I.web, t('exPub'), pubP, !!ver, togglePub, pubOn ? t('phoneOnShort') : ''] : null, // 公网链接(实验):只有本地文件的设计(放的是整套 HTML 演示)
10638
10950
  ], foot: t('exWhere') }),
10639
10951
  h(DropMenu, { t, cls: 'ddp-more', tip: [t('more'), phoneOn && !phone ? t('phoneOnTip') + ' · ' + t('dMore') : t('dMore')], icon: I.more, has: phoneOn && !phone, open: more, setOpen: setMore, items: [
10640
10952
  dockTight ? ['', I.play, t('demoShort'), !!demo, !url || !!ver, () => { if (implSc) implClose(); toggleDemo() }] : null, // 侧栏太窄,底部工具坞放不下「试用」:挪到这里
@@ -11155,7 +11467,7 @@ ${Object.entries(CHIP_ICON).map(([k, d]) => `[data-composer-chip="${chipSrc(k)}"
11155
11467
  sel: sel || focus,
11156
11468
  labelOf: shortOf,
11157
11469
  reveal,
11158
- inset: anUp || ck || styleEdit || panel || pane || hist || phone ? 296 : 0, // 右边的面板 276 宽,离边 10
11470
+ inset: anUp || ck || styleEdit || panel || pane || hist || phone || pubP ? 296 : 0, // 右边的面板 276 宽,离边 10
11159
11471
  render: (sc, z) => renderScreen(sc, z, false),
11160
11472
  sleep: sleepScreen,
11161
11473
  flows,
@@ -11165,7 +11477,7 @@ ${Object.entries(CHIP_ICON).map(([k, d]) => `[data-composer-chip="${chipSrc(k)}"
11165
11477
  })
11166
11478
  } else {
11167
11479
  // 右边开着面板(体检、调样式、设计规范、换风格):手机这类有外框的让到面板左边(侧栏够宽时),别被挡住
11168
- const sideOn = !!(anUp || ck || styleEdit || panel || pane || hist || phone) && box.w - 296 >= 240
11480
+ const sideOn = !!(anUp || ck || styleEdit || panel || pane || hist || phone || pubP) && box.w - 296 >= 240
11169
11481
  // 网页铺满时右边开着面板(业务标注、体检、调样式…,#22):按现在的大小定住、整体缩到面板左边,不重排,右边的内容也不被挡
11170
11482
  // 高度按铺满时真有的那么高:上面挂着横幅(看旧版本)时少 46,和下面 .ddp-body 的 vb 一样算
11171
11483
  const sideLock = fill && sideOn && !mark ? { w: box.w, h: ah - (ver || demo || hintTop ? 46 : 0) } : null
@@ -11271,6 +11583,14 @@ ${Object.entries(CHIP_ICON).map(([k, d]) => `[data-composer-chip="${chipSrc(k)}"
11271
11583
  onStop: () => { post('phone', { session: sid, on: false }).catch(() => {}); setPhone(false); if (poll && poll.state) poll.set({ ...poll.state, phone: { on: false, seen: 0 } }) },
11272
11584
  onClose: () => setPhone(false),
11273
11585
  }) : null,
11586
+ pubP ? h(PubPanel, {
11587
+ t,
11588
+ sid,
11589
+ body: htmlBody,
11590
+ brief: st && st.pub,
11591
+ onCopy: (link) => { navigator.clipboard.writeText(link).then(() => say(t('pubCopied'))).catch(() => say(link)) },
11592
+ onClose: () => setPubP(false),
11593
+ }) : null,
11274
11594
  hist ? h(HistoryPanel, { t, versions, ver, onPick: (v) => { setVer(v); if (!v) setCmp(false) }, onClose: () => setHist(false) }) : null,
11275
11595
  mark && !markOff ? h(MarkLayer, { t, sending: markBusy, frames: markFrames, onCancel: () => { markRun.current++; setMark(false) }, onSend: sendMark, onCopy: canCopyImage() ? copyMark : null }) : null,
11276
11596
  demo ? h('div', { className: 'ddp-banner' + side },
package/lib/handoff.js CHANGED
@@ -971,9 +971,11 @@ export async function compareScreens(browser, { design, impl, shown = '', size,
971
971
  return { png, blocks, pageH, blocked: page.blocked ? page.blocked.slice() : [] }
972
972
  })
973
973
  // 一个接一个截:同时开两个页面时系统字体(中文)偶尔还没画好就截了,差异会虚高
974
- const A = await shoot(design.url, true, [w, h])
974
+ // 刚写完文件就比:预览服务器的「改了自动刷新」可能在截图途中把页面刷新一次(页面没了)→ 重截一次
975
+ const again = (fn) => fn().catch((e) => (!blocked.length && /navigated or closed/i.test(e.message) ? fn() : Promise.reject(e)))
976
+ const A = await again(() => shoot(design.url, true, [w, h]))
975
977
  if (slot && slot.hidden) return { pct: null, boxes: [], jpg: null, text: `没比:${design.label || design.key} 套了外框,按 ${w}×${h} 开时外框里的 main 槽位露不出来。size 填外框自己的尺寸 ${slot.fw}x${slot.fh} 再比。` }
976
- const B = await shoot(impl, false, slot ? [slot.w, slot.h] : [w, h]).catch((e) => {
978
+ const B = await again(() => shoot(impl, false, slot ? [slot.w, slot.h] : [w, h])).catch((e) => {
977
979
  // 页面自己跳到外网被拦下、截图时页面没了:说清楚是跳走了
978
980
  if (blocked.length) throw new Error(`做出来的页面跳到了本机以外的地址,拦下了:${blocked[0].slice(0, 120)}`)
979
981
  throw e