dsh-design-studio 0.29.0 → 1.0.1

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
@@ -31,21 +31,22 @@ If DSH can't reach the npm registry, it falls back to a mirror in China. To upda
31
31
 
32
32
  ## Quick start
33
33
 
34
- 1. In Design mode, say what to make, for example "Design a member app for a neighborhood gym". The empty sidebar also has a few example prompts you can click into the input.
35
- 2. The model asks two or three questions, then lays out three directions side by side. Click **✓ Use this** next to the title of the one you like and send it; the model builds the rest.
36
- 3. To change something, click **Select** in the toolbar, then the element, type "bigger" or "make it red", and send.
34
+ 1. In Design mode, say what to make, for example "Design a member app for a neighborhood gym". You can also type it in the big box on the studio's home page: pick a type and a style and press ↑ (Tab fills in an example when the box is empty).
35
+ 2. The model asks two or three questions, then lays out three directions side by side. Click **✓ Use this take** next to the title of the one you like and send it; the model builds the rest.
36
+ 3. To change something, click **Select** on the island at the bottom (or press V), then the element, type "bigger" or "make it red", and send.
37
37
 
38
38
  ## What it does
39
39
 
40
+ - **The 1.0 interface:** a title bar on top (Page setup, screens, Share, Export, Build as code) and an island at the bottom (Ask or run a command, Select, Text, Style, Draw, Play, Look, Check). One panel at a time: a drawer on a narrow sidebar, a card on the right with DSH full screen. ⇧⌘K (Ctrl+Shift+K on Windows) opens the command palette, V T S P R L C switch tools, and the motion is a soft aurora.
40
41
  - **Pick from three directions:** three different first screens side by side, then the full set in the one you pick. Any single screen can also get two alternative takes.
41
42
  - **Click to edit:** click an element or drag over an area, and a small chip lands in the input (hover it for details); just add how to change it. Markup, style changes, style cards and check lists land as chips too, not walls of text. The model still gets the full location and styles. Changed spots flash in the preview. You can also draw circles, arrows and notes right on the page and hand the marked-up screenshot to the model, or copy it to paste elsewhere. Adjust style can apply a change to every screen at once, and when you edit a design by hand in the sidebar, the model is told before its next step so it won't undo your edits.
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
+ - **Open what you have:** home + › Open HTML… picks 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
44
  - **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
45
  - **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), 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); designs with hundreds of screens export in full (up to 1000); 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
+ - **Export and share:** Export makes showcase images, PDF and PowerPoint (links between screens still work), and designs with hundreds of screens export in full (up to 1000). Share has a clickable HTML demo that opens with a double-click (device frame included, ready to send to a client), a temporary public link (beta; opens in WeChat or any browser, closes after 2 hours), and 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
47
  - **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
48
  - **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
- - **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.
49
+ - **Gallery, My designs, Inspiration:** three tabs on the home page. My designs has everything you've designed (and your saved frames, which you can rename or delete); Inspiration holds saved references and styles; the Gallery has templates, design systems and style cards others shared, and "Start from this" copies one for you to keep editing. Submit your own with Share › Submit to gallery: it's checked, zipped and submitted, 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.
49
50
  - **Your brand, and real code:** give a site URL to extract a brand design system and design with it from then on; turn a finished design into React / Vue / HTML (mini programs straight into uni-app or native WeChat code, HBuilderX projects included), compared screen by screen against the design.
50
51
  - **Built-in photo library:** for designs that rely on photos (hotels, food, cafes, fitness, beauty, fashion, education, travel), the model uses real-looking photos instead of only drawing illustrations. About 8 MB is downloaded the first time it is needed. All of them are AI-generated placeholders, so replace them with real photos before launch.
51
52
  - **A style that fits the subject:** when you have not chosen a style, the model first picks a style card for the subject (colors, fonts, corner radius) and builds with it, so a homestay app, a bubble-tea shop and a review deck no longer all come out beige. If you name a style or colors, it follows yours.
package/README.md CHANGED
@@ -32,20 +32,21 @@
32
32
  ## 三步上手
33
33
 
34
34
  1. 在设计模式里说一句要做什么,比如「帮我设计一个社区健身房的会员 App」。也可以直接在设计台首页的大输入框里说:挑个类型、风格,点 ↑ 就发出去(没写字时按 Tab 用例子)。
35
- 2. 模型先问两三个问题,再出三个方向并排在画布上。看中哪个,点它标题旁的「✓ 就要这个」,发出去,模型接着做全套。
36
- 3. 哪里不对,点工具栏「选择」,再点那个元素,接着说「字大一点」「换成红色」,发出去。
35
+ 2. 模型先问两三个问题,再出三个方向并排在画布上。看中哪个,点它标题旁的「✓ 用这版」,发出去,模型接着做全套。
36
+ 3. 哪里不对,点底下灵动条的「选择」(或按 V),再点那个元素,接着说「字大一点」「换成红色」,发出去。
37
37
 
38
38
  ## 能做什么
39
39
 
40
+ - **1.0 新界面**:顶上一行标题栏(页面设置、换屏、分享、导出、转成代码),底下一条灵动条(说一句或输命令、选择、改字、调样式、画笔、试用、外观、体检),面板一次只开一个,窄栏是抽屉、DSH 全屏时在右边。⇧⌘K(Windows 是 Ctrl+Shift+K)开命令面板,V T S P R L C 一键切工具;动效换成柔和的极光。
40
41
  - **三个方向挑着做**:先出三个风格不同的首屏并排比,挑中再做全套;单独一屏也能「再出两版」。
41
42
  - **点一下就改**:点元素或框一块区域,输入框里出现一个小标签(悬停看详情),你只要补一句怎么改;标注、调样式、风格、体检清单这些放进输入框的也都是小标签,不再是一大段字;发出去模型拿到完整的位置和样式。改过的地方在预览里闪一下。也能直接在页面上画圈、画箭头、写字,拼成一张图交给模型,或者复制下来贴到别处。调样式可以「各屏一起改」;你在右侧栏亲手改过的地方,模型下一步会先知道,不会改回去。
42
- - **打开已有的页面**:首页输入框左边的「+」→「打开已有的 HTML…」选一个,或把 HTML 文件 / 文件夹拖进右侧栏就能预览(桌面版);也能输路径或开发服务器端口。
43
+ - **打开已有的页面**:首页输入框左边的「+」→「打开 HTML…」选一个,或把 HTML 文件 / 文件夹拖进右侧栏就能预览(桌面版);也能输路径或开发服务器端口。
43
44
  - **设计体检**:一键查文字溢出、对比度不够、按钮太小、字太小,问题直接标在页面上;模型做完也会自己查一遍再改。
44
45
  - **版本和对比**:每轮自动存一版,左右拖动对比,随时回到任意一版。
45
- - **导出和手机上看**:导出展示图、PDF、PPT(屏和屏之间的跳转照样能点),或一个双击就能开的 HTML 演示(带外壳、点得动,发给客户直接看),也能临时发个公网链接(实验,微信里点开就能看,2 小时自动关),几百屏的设计也全部导出(最多 1000 屏);扫码在手机上按真机尺寸看。页面比默认画幅大的幻灯片、海报,画幅自动跟页面走;也可以在类型后面跟 `宽x高` 指定,比如 `<meta name="dsh-design" content="slides 1440x810">`。导出选项里可以选版面(16:9、4:3、A3 横向、自定义)、每页取景(一屏、整页、指定高度)和每页拼 2 屏;有内容会被裁时,导出前先给一张清单,可以一键按内容改画幅。
46
+ - **导出和分享**:标题栏「导出」出展示图、PDF、PPT(屏和屏之间的跳转照样能点),几百屏的设计也全部导出(最多 1000 屏);「分享」里有双击就能开的 HTML 演示(带外壳、点得动,发给客户直接看)、临时公网链接(实验,微信里点开就能看,2 小时自动关),扫码在手机上按真机尺寸看。页面比默认画幅大的幻灯片、海报,画幅自动跟页面走;也可以在类型后面跟 `宽x高` 指定,比如 `<meta name="dsh-design" content="slides 1440x810">`。导出选项里可以选版面(16:9、4:3、A3 横向、自定义)、每页取景(一屏、整页、指定高度)和每页拼 2 屏;有内容会被裁时,导出前先给一张清单,可以一键按内容改画幅。
46
47
  - **图表**:思维导图、技术路线图(申报书、开题报告那种)、产品路线图、系统架构图。连线、分叉、箭头自动排好,改字、加节点自己重排;配色跟着设计风格走,导出高清 PNG 或 PDF 贴进 Word / PPT。申报书、结题报告的框架图先帮你理清「哪个问题对应哪项内容」请你确认再画,版块之间画出带关系词的箭头;默认是立体渐变的「申报书炫酷样式」,也能照你给的参考图画。
47
48
  - **DSH 插件**:给 DSH 做插件界面时,四周直接套上 DSH 桌面端的外框(左侧栏入口、设置分区、会话标签页、右侧栏面板四个位置,浅色、深色都有),只设计插件那一块,一眼看出装进 DSH 是什么样;外框被改了体检会提醒。
48
- - **设计库和设计市场**:以前做过的设计、收的参考图和风格都在「设计库」里;市场里逛大家分享的模板、设计系统和风格卡,点「用这个开始」复制一份接着改。自己做的点「分享到设计市场」,查过打成 zip,在网页里交上去,审过就上架。市场目录从 npm 镜像取,签了名、核对过才用;不想让它联网,在插件页打开「设计库不联网」。
49
+ - **市场、我的作品、灵感**:首页顶上三个页签。以前做过的设计(还有自己存的外框,能改名、删除)在「我的作品」,收的参考图和风格在「灵感」;「市场」里逛大家分享的模板、设计系统和风格卡,点「用这个开始」复制一份接着改。自己做的从「分享」›「投稿到市场」交上去,查过打成 zip,审过就上架。市场目录从 npm 镜像取,签了名、核对过才用;不想让它联网,在插件页打开「设计库不联网」。
49
50
  - **照品牌风格做、转成代码**:给官网地址,提一套品牌设计系统,以后都照它做;做好的设计转成 React / Vue / HTML,小程序直接转成 uni-app 或原生小程序代码(HBuilderX 建的项目也认得出),逐屏和设计稿比对。
50
51
  - **自带照片库**:民宿酒店、餐饮、奶茶咖啡、健身、美妆、服饰、教育、旅行风景这些靠照片说话的设计,模型会直接用上照片,不再只画插画。第一次用到时下载约 8 MB。都是 AI 生成的示意图,上线前请换成真实照片。
51
52
  - **按题材挑风格**:没定风格时,模型先按题材挑一张风格卡(配色、字体、圆角)再动手,民宿、奶茶店、复盘幻灯片不再都是一个米色调;你自己说了风格或配色就照你的。
package/assets/demo.gif CHANGED
Binary file
Binary file
package/lib/canvthumb.js CHANGED
@@ -3,6 +3,7 @@
3
3
  *
4
4
  * GET scrthumb ?session=&root=&key=&w=&h=&dark= → JPEG(取不到 404 / 503,页面上照旧显示「挪近就加载」)。响应头:
5
5
  * X-Dsh-Title 页面标题;X-Dsh-Thumb 这张图的名字(同一张页面就不换);X-Dsh-Recheck 目录没在监听(改了不会通知)时,过几秒再来要
6
+ * GET verthumb ?session=&n=&key=&w=&h=&dark= → 旧版本里某一屏的 JPEG(1.0 版本面板的卡片)。存下的版本不会再变,按「版本号 + 存的时间」缓存,不用看文件
6
7
  *
7
8
  * 只截本地文件的设计:开发服务器的页面别在后台再开一份(可能会发请求、改数据)。root 必须是这个会话现在开着的目录
8
9
  * (换了设计,晚到的请求不会拿新设计的图冒充),key 必须是它现在的某一屏。
@@ -164,7 +165,7 @@ export function createCanvasThumbs({ tracker, browser, trust = () => '', strictR
164
165
 
165
166
  async function capture(job) {
166
167
  const { o } = job
167
- const stamp = stampOf(o)
168
+ const stamp = o.v ? 'v' : stampOf(o) // 旧版本不会再变:一个记号到底
168
169
  job.stamp = stamp
169
170
  const name = `${job.id}-${stamp}`
170
171
  const file = path.join(dir, name + '.jpg')
@@ -185,7 +186,7 @@ export function createCanvasThumbs({ tracker, browser, trust = () => '', strictR
185
186
  fs.renameSync(tmp, file)
186
187
  // 截的时候文件又改了:这张留给等着的人,但别把(可能已经截好的)新的那张当旧的删了
187
188
  let fresh = false
188
- try { fresh = stampOf(o, true) === stamp } catch { fresh = false }
189
+ try { fresh = o.v ? true : stampOf(o, true) === stamp } catch { fresh = false }
189
190
  prune(job.id, name, fresh)
190
191
  return { file, title }
191
192
  }
@@ -210,8 +211,8 @@ export function createCanvasThumbs({ tracker, browser, trust = () => '', strictR
210
211
 
211
212
  /** 这屏的缩略图 { file, title }(要截就排队)。onLeave 交出「这个请求不等了」的回调 */
212
213
  function thumb(o, onLeave) {
213
- const id = sha1([path.resolve(o.root), o.key, o.w, o.h, o.dark ? 1 : 0].join('\0')).slice(0, 20)
214
- const stamp = stampOf(o) // 文件没了这里就抛
214
+ const id = sha1([path.resolve(o.root), o.key, o.w, o.h, o.dark ? 1 : 0, ...(o.v ? [`v${o.v}@${o.at}`] : [])].join('\0')).slice(0, 20)
215
+ const stamp = o.v ? 'v' : stampOf(o) // 文件没了这里就抛
215
216
  const file = path.join(dir, `${id}-${stamp}.jpg`)
216
217
  if (fs.existsSync(file)) return Promise.resolve({ file, title: titleOf(file) })
217
218
  let job = jobs.get(id)
@@ -274,5 +275,54 @@ export function createCanvasThumbs({ tracker, browser, trust = () => '', strictR
274
275
  res.end(buf)
275
276
  }
276
277
 
277
- return { route, thumb, pending: () => queue.length + running }
278
+ /**
279
+ * 旧版本里某一屏的缩略图(1.0 版本面板的卡片):只给这个会话现在开着的本地目录、存过的那一版、那一版里有的屏。
280
+ * 页面走预览服务器的 /__dsh_design__/v/<n>/(那一版的文件),和看旧版本时画布上的一样
281
+ */
282
+ async function verRoute(req, res) {
283
+ if (!admit(req, res)) return
284
+ if (req.method !== 'GET') return json(res, 405, { error: 'method not allowed' })
285
+ const q = new URL(req.url, 'http://x').searchParams
286
+ const sid = q.get('session') || ''
287
+ const key = q.get('key') || ''
288
+ const n = intIn(q.get('n'), 1, 1e9)
289
+ const w = intIn(q.get('w'), 100, 8000)
290
+ const h = intIn(q.get('h'), 100, 8000)
291
+ if (!sid || !key || !n || !w || !h) return json(res, 400, { error: 'bad request' })
292
+ if (!/^[^/\\]+\.html?$/i.test(key) || key === '.' || key === '..') return json(res, 400, { error: 'bad key' })
293
+ const snap = tracker.snapshot(sid)
294
+ const t = snap && snap.target
295
+ if (!t || t.kind !== 'file' || !t.root) return json(res, 404, { error: 'not a local design' })
296
+ const st = tracker.stateOf ? tracker.stateOf(sid) : null
297
+ const origin = (st && st.origin) || ''
298
+ let list = []
299
+ try { list = (tracker.versions && tracker.versions(sid)) || [] } catch { list = [] }
300
+ const v = list.find((x) => x && x.n === n)
301
+ if (!origin || !v || !(v.screens || []).includes(key)) return json(res, 404, { error: 'no such version' })
302
+ // 请求是给哪个项目、哪一次存的版(1.0 起地址带 root / at):刚换了项目、晚到的旧请求别拿新项目的同号版本去顶(还会被浏览器按旧地址缓存一天)
303
+ const qr = q.get('root')
304
+ const qa = q.get('at')
305
+ if ((qr && qr !== t.root) || (qa && Number(qa) !== Number(v.at))) return json(res, 409, { error: 'version moved' })
306
+ const b = browser()
307
+ if (!b || !b.available()) return json(res, 503, { error: 'no browser' })
308
+ let got
309
+ let buf = null
310
+ try {
311
+ for (let i = 0; i < 2 && !buf; i++) {
312
+ got = await thumb({ root: t.root, key, v: n, at: v.at, url: `${origin}/__dsh_design__/v/${n}/${encodeURIComponent(key)}`, w, h, dark: q.get('dark') === '1' }, (leave) => res.on('close', leave))
313
+ try { buf = await fs.promises.readFile(got.file) } catch (e) { if (e.code !== 'ENOENT') throw e }
314
+ }
315
+ } catch (e) {
316
+ if (e.code !== 'gone' && e.code !== 'ENOENT') log(e)
317
+ if (!res.headersSent) json(res, 503, { error: 'thumb failed' })
318
+ return
319
+ }
320
+ if (res.destroyed || res.headersSent) return
321
+ if (!buf || !buf.length) return json(res, 503, { error: 'thumb failed' })
322
+ // 存下的版本不会变:让浏览器缓存(同一版、同一屏、同一画幅地址就一样)
323
+ res.writeHead(200, { 'Content-Type': 'image/jpeg', 'Content-Length': buf.length, 'Cache-Control': 'private, max-age=86400' })
324
+ res.end(buf)
325
+ }
326
+
327
+ return { route, verRoute, thumb, pending: () => queue.length + running }
278
328
  }