dsh-design-studio 0.4.0 → 0.4.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/lib/client.js CHANGED
@@ -144,6 +144,7 @@ window.__ModuleLoader__.load({
144
144
  textAsk: '把页面上的「{before}」改成「{after}」(只改这一处文字,别的不动)。\n{where}\n',
145
145
  demoNone: '这一屏还没有跳到别的屏的按钮;可以让模型用 <a href="detail.html"> 把几屏串起来',
146
146
  phone: '在手机上看',
147
+ away: '这里看不到预览:预览跑在电脑本机上,从手机或别的电脑打开 DSH 时连不过去。回到那台电脑上看;想在手机上看,就在电脑上点「在手机上看」扫码(同一个 Wi-Fi)。',
147
148
  phoneStarting: '正在打开…',
148
149
  phoneHow: '用手机相机扫一扫',
149
150
  phoneWifi: '手机和电脑要连同一个 Wi-Fi',
@@ -289,6 +290,7 @@ window.__ModuleLoader__.load({
289
290
  textAsk: 'Change the text "{before}" to "{after}" on the page (only this text, nothing else).\n{where}\n',
290
291
  demoNone: 'This screen has no links to other screens yet. Ask the model to connect screens with <a href="detail.html">',
291
292
  phone: 'View on phone',
293
+ away: 'The preview runs on the computer itself, so it can\'t load when DSH is opened from a phone or another computer. View it on that computer, or click "View on phone" there and scan the code (same Wi-Fi).',
292
294
  phoneStarting: 'Starting…',
293
295
  phoneHow: 'Scan with your phone camera',
294
296
  phoneWifi: 'Phone and computer must be on the same Wi-Fi',
@@ -385,6 +387,7 @@ window.__ModuleLoader__.load({
385
387
  .ddp-stage{position:relative;flex:1;min-height:0;overflow:hidden;background:var(--dsw-alias-bg-layer-2)}
386
388
  .ddp-stage.full{background:#fff}
387
389
  .ddp-scr{position:absolute;inset:0;overflow:hidden}
390
+ .ddp-away{position:absolute;inset:0;display:flex;align-items:center;justify-content:center;padding:24px;text-align:center;font-size:13px;line-height:1.6;color:var(--dsw-alias-text-secondary,#888);background:var(--dsw-alias-bg-layer-1)}
388
391
  .ddp-frame{position:absolute;left:0;top:0;width:100%;height:100%;border:0;background:#fff;opacity:0;z-index:0;pointer-events:none}
389
392
  .ddp-frame.old{opacity:1;z-index:1}
390
393
  .ddp-frame.cur{opacity:1;z-index:2;pointer-events:auto;transition:opacity .32s ease}
@@ -1468,6 +1471,12 @@ window.__ModuleLoader__.load({
1468
1471
  * 一屏:几帧 iframe 叠在一起。cur 是正在显示的;比它新的在后台载,载好了淡入换上来,旧的随后拆掉(不白屏)。
1469
1472
  * 和页面里 picker.js 的握手:hello → init(上一帧的滚动位置和指纹)→ ready → 换上来 → reveal(闪改动 / 播生成动画)。
1470
1473
  */
1474
+ const LOCAL_HOST = /^(127\.0\.0\.1|localhost|\[::1\]|::1)$/i
1475
+ /** 预览在电脑本机,而 DSH 网页是从别的设备打开的 */
1476
+ function away(src) {
1477
+ try { return !!src && LOCAL_HOST.test(new URL(src).hostname) && /^https?:$/.test(location.protocol) && !LOCAL_HOST.test(location.hostname) } catch { return false }
1478
+ }
1479
+
1471
1480
  function Screen(props) {
1472
1481
  const src = props.src
1473
1482
  const origin = src ? new URL(src).origin : ''
@@ -1678,6 +1687,9 @@ window.__ModuleLoader__.load({
1678
1687
  }, 1600)
1679
1688
  }
1680
1689
 
1690
+ // 预览服务器只听电脑本机(127.0.0.1)。从手机(dsh-mobile)或别的电脑打开 DSH 网页时,这个地址指的是它们自己,
1691
+ // 框里会一直空白:说清楚
1692
+ if (away(src)) return h('div', { className: 'ddp-scr' + (props.dark ? ' dk' : '') }, h('div', { className: 'ddp-away', style: { fontSize: 13 / Math.max(0.25, props.zoom || 1) } }, props.t ? props.t('away') : ZH.away)) // 画布缩小了,字别跟着变小
1681
1693
  return h('div', { className: 'ddp-scr' + (props.dark ? ' dk' : '') },
1682
1694
  ...frames.map((f) => h('iframe', {
1683
1695
  key: f.id,
@@ -2355,7 +2367,7 @@ window.__ModuleLoader__.load({
2355
2367
  }
2356
2368
 
2357
2369
  const renderScreen = (sc, z, fill) => h(Device, { kind, w: size[0], h: size[1], fill, label: labelOf(sc) },
2358
- h(Screen, {
2370
+ h(Screen, { t,
2359
2371
  src: sc.url,
2360
2372
  label: labelOf(sc),
2361
2373
  busy: busy && !sc.v,
@@ -2622,7 +2634,7 @@ window.__ModuleLoader__.load({
2622
2634
  h('div', { className: 'ddp-single' },
2623
2635
  h('div', { className: 'ddp-fit' + (fill ? ' fill' : ''), style: fill ? undefined : { width: dw, height: dh, transform: `translate(-50%, -50%) scale(${z})` } },
2624
2636
  h(Device, { kind, w: size[0], h: size[1], fill, label },
2625
- h(Screen, {
2637
+ h(Screen, { t,
2626
2638
  src: urlOfKey(l.key),
2627
2639
  label,
2628
2640
  busy: false,
@@ -2656,7 +2668,7 @@ window.__ModuleLoader__.load({
2656
2668
  sel: '',
2657
2669
  labelOf: (sc) => sc.label,
2658
2670
  render: (sc, z, i) => h(Device, { kind: items[i].kind, w: items[i].size[0], h: items[i].size[1], label: labelOf(base) },
2659
- h(Screen, {
2671
+ h(Screen, { t,
2660
2672
  src: base.url,
2661
2673
  label: labelOf(base),
2662
2674
  busy,
@@ -2685,7 +2697,7 @@ window.__ModuleLoader__.load({
2685
2697
  const z = fill ? 1 : Math.max(0.05, Math.min(1, (box.w - 32) / dw, (box.h - 32 - (ver ? 46 : 0)) / dh))
2686
2698
  // 两边的小标签不跟着画面缩小(缩了看不清);手机、平板躲开状态栏
2687
2699
  const tagAt = (side) => ({ top: kind === 'app' || kind === 'tablet' ? 60 : 10, transform: `scale(${1 / z})`, transformOrigin: 'top ' + side })
2688
- const screenOf = (sc) => h(Screen, { src: sc.url, label: labelOf(sc), busy: false, born: false, picking: false, dark, zoom: z, reloadSeq,
2700
+ const screenOf = (sc) => h(Screen, { t, src: sc.url, label: labelOf(sc), busy: false, born: false, picking: false, dark, zoom: z, reloadSeq,
2689
2701
  apis: apis.current, apiKey: 'cmp|' + ik(sc), onMeta: (m, title, toks, dk) => remember(ik(sc), m, title, toks, dk) })
2690
2702
  body = h('div', { className: 'ddp-single' },
2691
2703
  h('div', { className: 'ddp-fit' + (fill ? ' fill' : ''), style: fill ? undefined : { width: dw, height: dh, transform: `translate(-50%, -50%) scale(${z})` } },
package/lib/preset.js CHANGED
@@ -1,5 +1,22 @@
1
1
  /**
2
- * dsh-design-studio/preset:设计模式那一行。就是 DSH 自带的 Agent 预设,
3
- * 换个入口好让 DSH「插件」页里显示成设计模式(名字和说明见 locale/preset/),而不是通用的「Agent 预设定义」
2
+ * dsh-design-studio/preset:设计模式那一行。和 DSH 自带的 Agent 预设(@deepseek-ai/dsh-agent-preset)一模一样,
3
+ * 换个入口好让 DSH「插件」页里显示成设计模式(名字和说明见 locale/preset/),而不是通用的「Agent 预设定义」。
4
+ *
5
+ * 不直接 re-export 那个包:用 link: 装、插件文件夹在 DSH 目录外面时(本地开发),从这里找不到 @deepseek-ai/* 包,
6
+ * 这一行就起不来、模式列表里没有设计模式。官方实现只有十几行,照抄;两个键是 cordis 的全局符号(Symbol.for)。
4
7
  */
5
- export { default } from '@deepseek-ai/dsh-agent-preset'
8
+ export default class DesignPreset {
9
+ static inject = ['agentPresets']
10
+ // 子插件的配置原样留着,等各自激活时再解析(官方的 EntryGroup.key)
11
+ static [Symbol.for('cordis.group')] = true
12
+
13
+ constructor(ctx, config) {
14
+ this.ctx = ctx
15
+ this.config = config
16
+ }
17
+
18
+ // 官方的 Service.init:注册上就算起来了,停用时 yield 出去的反注册会被调用
19
+ async * [Symbol.for('cordis.init')]() {
20
+ yield await this.ctx.agentPresets.register(this.config)
21
+ }
22
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-design-studio",
3
- "version": "0.4.0",
3
+ "version": "0.4.1",
4
4
  "type": "module",
5
5
  "scripts": {
6
6
  "test": "node --test --test-concurrency=1 test/*.mjs"