dsh-vscode-mode 0.39.0 → 0.41.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.
Files changed (51) hide show
  1. package/README.md +11 -8
  2. package/lib/client.js +83 -64
  3. package/lib/client.js.map +1 -1
  4. package/lib/index.js +4765 -1886
  5. package/lib/index.js.map +1 -1
  6. package/package.json +1 -1
  7. package/skills/dsh-vscodemode-test-check/SKILL.md +82 -0
  8. package/skills/dsh-vscodemode-ui-kit/SKILL.md +84 -0
  9. package/skills/dsh-vscodemode-ui-kit/fixtures/selftest/spec.json +65 -0
  10. package/skills/dsh-vscodemode-ui-kit/references/detect.md +90 -0
  11. package/skills/dsh-vscodemode-ui-kit/references/lib.md +48 -0
  12. package/skills/dsh-vscodemode-ui-kit/references/questions.md +68 -0
  13. package/skills/dsh-vscodemode-ui-kit/references/spec.md +99 -0
  14. package/skills/dsh-vscodemode-ui-kit/references/verify.md +37 -0
  15. package/skills/dsh-vscodemode-ui-kit/runtime/build.mjs +348 -0
  16. package/skills/dsh-vscodemode-ui-kit/runtime/css/framework.css +398 -0
  17. package/skills/dsh-vscodemode-ui-kit/runtime/js/01-core.js +182 -0
  18. package/skills/dsh-vscodemode-ui-kit/runtime/js/02-state.js +96 -0
  19. package/skills/dsh-vscodemode-ui-kit/runtime/js/03-tree.js +144 -0
  20. package/skills/dsh-vscodemode-ui-kit/runtime/js/04-canvas.js +194 -0
  21. package/skills/dsh-vscodemode-ui-kit/runtime/js/05-inspector.js +241 -0
  22. package/skills/dsh-vscodemode-ui-kit/runtime/js/06-diff.js +52 -0
  23. package/skills/dsh-vscodemode-ui-kit/runtime/js/07-reply.js +71 -0
  24. package/skills/dsh-vscodemode-ui-kit/runtime/js/08-main.js +147 -0
  25. package/skills/dsh-vscodemode-ui-kit/runtime/spec.schema.json +79 -0
  26. package/src/attachmentBytes.ts +84 -0
  27. package/src/client/index.ts +6 -0
  28. package/src/client/openReceipt.ts +5 -2
  29. package/src/client/sidebar/panels/TestCheckPanel.ts +485 -0
  30. package/src/client/sidebar/panels/useTestCheckData.ts +414 -0
  31. package/src/client/sidebar/types.ts +2 -0
  32. package/src/client/styles/editor.css +78 -0
  33. package/src/client/testCheck/TestCheckChip.ts +181 -0
  34. package/src/client/testCheck/TestCheckPanel.ts +339 -0
  35. package/src/client/testCheckPanelState.ts +173 -0
  36. package/src/client/ui/EditorView.ts +69 -6
  37. package/src/htmlPlanAttachments.ts +4 -1
  38. package/src/htmlPlanCommand.ts +4 -62
  39. package/src/index.ts +4 -0
  40. package/src/rpc.ts +3 -0
  41. package/src/shared/rpc.ts +44 -0
  42. package/src/shared/testCheck.ts +759 -0
  43. package/src/shared/testCheckHtml.ts +276 -0
  44. package/src/shared/testCheckPolicyDefault.ts +37 -0
  45. package/src/shared/testCheckSnippets.ts +197 -0
  46. package/src/testCheckCommand.ts +287 -0
  47. package/src/testCheckGuidance.ts +79 -0
  48. package/src/testCheckMode.ts +654 -0
  49. package/src/testCheckPolicy.ts +141 -0
  50. package/src/testCheckRpc.ts +196 -0
  51. package/src/testCheckStore.ts +822 -0
@@ -0,0 +1,144 @@
1
+ /* 03 · 树:折叠、选中、右键菜单 */
2
+ (function (UK) {
3
+ 'use strict'
4
+
5
+ var collapsed = {}
6
+
7
+ UK.toggleCollapse = function (id) {
8
+ collapsed[id] = !collapsed[id]
9
+ UK.renderAll()
10
+ }
11
+
12
+ UK.revealInTree = function (id) {
13
+ var spec = UK.state.spec
14
+ var byId = UK.index(spec)
15
+ var p = id ? (byId[id] || {}).parent : null
16
+ while (p && byId[p]) { collapsed[p] = false; p = byId[p].parent }
17
+ }
18
+
19
+ function leafName(id) {
20
+ var parts = String(id || '').split('/')
21
+ return parts[parts.length - 1] || id
22
+ }
23
+
24
+ UK.renderTree = function (host) {
25
+ host.innerHTML = ''
26
+ var spec = UK.state.spec
27
+ var nodes = spec.nodes || []
28
+ if (!nodes.length) {
29
+ host.appendChild(UK.el('div', { class: 'ui-empty-note', text: '还没有节点。在画布上右键新增,或让 agent 写进 spec。' }))
30
+ return
31
+ }
32
+
33
+ var wrap = UK.el('div', { class: 'ui-tree' })
34
+ var roots = nodes.filter(function (n) { return n && (n.parent == null || !UK.index(spec)[n.parent]) })
35
+ var renderInto = function (parentId, depth) {
36
+ var kids = nodes.filter(function (n) { return n && n.parent === parentId })
37
+ kids.forEach(function (node) {
38
+ var children = UK.childrenOf(spec, node.id)
39
+ var open = !collapsed[node.id]
40
+ var hasBind = !!node.bind
41
+ var row = UK.el('div', {
42
+ class: 'ui-row' + (UK.state.selected === node.id ? ' sel' : ''),
43
+ 'data-id': node.id,
44
+ style: { paddingLeft: 4 + depth * 12 + 'px' },
45
+ title: node.id + (node.bind ? ' · ' + node.bind : ''),
46
+ onclick: function (e) { e.stopPropagation(); UK.select(node.id) },
47
+ oncontextmenu: function (e) { e.preventDefault(); e.stopPropagation(); UK.openMenu(e, node) }
48
+ }, [
49
+ UK.el('span', {
50
+ class: 'ui-caret',
51
+ text: children.length ? (open ? '▾' : '▸') : '',
52
+ onclick: function (e) {
53
+ if (!children.length) return
54
+ e.stopPropagation()
55
+ UK.toggleCollapse(node.id)
56
+ }
57
+ }),
58
+ hasBind ? UK.el('span', { class: 'ui-binddot' }) : null,
59
+ UK.el('span', { class: 'ui-name', text: leafName(node.id) }),
60
+ UK.el('span', { class: 'ui-kind', text: node.kind || '?' })
61
+ ])
62
+ wrap.appendChild(row)
63
+ if (children.length && open) renderInto(node.id, depth + 1)
64
+ })
65
+ }
66
+ renderInto(null, 0)
67
+ host.appendChild(wrap)
68
+ }
69
+
70
+ /* 右键菜单:存库、定范围、删除 */
71
+ UK.openMenu = function (event, node) {
72
+ UK.closeMenu()
73
+ UK.select(node.id)
74
+ var menu = UK.el('div', {
75
+ class: 'ui-menu',
76
+ id: 'uk-menu',
77
+ style: { left: Math.min(event.clientX, window.innerWidth - 170) + 'px', top: Math.min(event.clientY, window.innerHeight - 150) + 'px' }
78
+ })
79
+
80
+ menu.appendChild(UK.el('button', {
81
+ text: '存成库条目…',
82
+ onclick: function () { UK.closeMenu(); UK.openExtract(node) }
83
+ }))
84
+ menu.appendChild(UK.el('button', {
85
+ text: '框定本次范围',
86
+ onclick: function () {
87
+ UK.closeMenu()
88
+ UK.state.scope = [node.id]
89
+ UK.commit({ op: 'scope', ids: [node.id] })
90
+ }
91
+ }))
92
+ menu.appendChild(UK.el('button', {
93
+ text: '在父节点里新建兄弟',
94
+ onclick: function () {
95
+ UK.closeMenu()
96
+ UK.addNode(node.parent || null)
97
+ }
98
+ }))
99
+ menu.appendChild(UK.el('hr'))
100
+ menu.appendChild(UK.el('button', {
101
+ text: '删除节点',
102
+ onclick: function () { UK.closeMenu(); UK.deleteNode(node.id) }
103
+ }))
104
+
105
+ document.body.appendChild(menu)
106
+ setTimeout(function () { document.addEventListener('mousedown', UK.closeMenu, { once: true }) }, 0)
107
+ }
108
+
109
+ UK.closeMenu = function () {
110
+ var m = document.getElementById('uk-menu')
111
+ if (m) m.remove()
112
+ }
113
+
114
+ /* 新增节点:放在父节点里,落在可见区域中间偏上 */
115
+ UK.addNode = function (parentId) {
116
+ var spec = UK.state.spec
117
+ var byId = UK.index(spec)
118
+ var parent = parentId ? byId[parentId] : null
119
+ var pw = parent ? parent.rect[2] : (spec.screen || {}).w || 1080
120
+ var ph = parent ? parent.rect[3] : (spec.screen || {}).h || 1920
121
+ var n = 1
122
+ var base = (parent ? parent.id : 'Node') + '/New'
123
+ var id = base
124
+ while (byId[id]) { id = base + (++n) }
125
+ var rect = [Math.round(pw * 0.1), Math.round(ph * 0.1), Math.round(Math.min(pw * 0.6, 240)), 44]
126
+ UK.commit({
127
+ op: 'add',
128
+ parent: parentId,
129
+ node: {
130
+ id: id, parent: parentId, kind: 'text', rect: rect,
131
+ text: { s: '新文本', size: 24, color: '#333333' },
132
+ anchor: { min: [0, 0], max: [0, 0], pivot: [0, 0] }
133
+ }
134
+ })
135
+ UK.select(id)
136
+ }
137
+
138
+ UK.deleteNode = function (id) {
139
+ var node = UK.index(UK.state.spec)[id]
140
+ if (!node) return
141
+ UK.commit({ op: 'del', id: id })
142
+ if (UK.state.selected === id) UK.select(null)
143
+ }
144
+ })(window.__UIKIT__ = window.__UIKIT__ || {})
@@ -0,0 +1,194 @@
1
+ /* 04 · 画布:缩放、平移、选中、拖边改 rect */
2
+ (function (UK) {
3
+ 'use strict'
4
+
5
+ var stage = null
6
+
7
+ function applyDelta(r, dx, dy, handle) {
8
+ if (!handle) {
9
+ r[0] = r[0] + dx
10
+ r[1] = r[1] + dy
11
+ } else {
12
+ if (handle.indexOf('w') >= 0) { r[0] = r[0] + dx; r[2] = r[2] - dx }
13
+ if (handle.indexOf('e') >= 0) { r[2] = r[2] + dx }
14
+ if (handle.indexOf('n') >= 0) { r[1] = r[1] + dy; r[3] = r[3] - dy }
15
+ if (handle.indexOf('s') >= 0) { r[3] = r[3] + dy }
16
+ if (r[2] < 4) { if (handle.indexOf('w') >= 0) r[0] = r[0] - (4 - r[2]); r[2] = 4 }
17
+ if (r[3] < 4) { if (handle.indexOf('n') >= 0) r[1] = r[1] - (4 - r[3]); r[3] = 4 }
18
+ }
19
+ for (var i = 0; i < 4; i++) r[i] = Math.round(r[i])
20
+ }
21
+
22
+ function beginDrag(e, node, handle) {
23
+ e.preventDefault()
24
+ e.stopPropagation()
25
+ if (UK.state.selected !== node.id) UK.select(node.id)
26
+
27
+ var st = UK.state
28
+ var startRect = node.rect.slice()
29
+ var startX = e.clientX
30
+ var startY = e.clientY
31
+ var moved = false
32
+ var finalRect = startRect.slice()
33
+ UK.__dragging = true
34
+
35
+ function onMove(ev) {
36
+ var dx = (ev.clientX - startX) / st.zoom
37
+ var dy = (ev.clientY - startY) / st.zoom
38
+ if (!moved && Math.abs(dx) < 1 && Math.abs(dy) < 1) return
39
+ moved = true
40
+ finalRect = startRect.slice()
41
+ applyDelta(finalRect, dx, dy, handle)
42
+ node.rect = finalRect
43
+ var box = document.querySelector('#uk-canvas [data-id="' + node.id.replace(/"/g, '\\"') + '"]')
44
+ if (box) {
45
+ var abs = UK.absRect(st.spec, node)
46
+ box.style.left = abs[0] + 'px'
47
+ box.style.top = abs[1] + 'px'
48
+ box.style.width = abs[2] + 'px'
49
+ box.style.height = abs[3] + 'px'
50
+ var tag = box.querySelector('.ui-node-tag')
51
+ if (tag) tag.textContent = finalRect.join(', ')
52
+ if (UK.syncInspectorRect) UK.syncInspectorRect(finalRect)
53
+ }
54
+ }
55
+
56
+ function onUp() {
57
+ window.removeEventListener('pointermove', onMove)
58
+ window.removeEventListener('pointerup', onUp)
59
+ UK.__dragging = false
60
+ if (moved) UK.commit({ op: 'set', id: node.id, field: 'rect', value: finalRect.slice() })
61
+ else UK.notify()
62
+ }
63
+
64
+ window.addEventListener('pointermove', onMove)
65
+ window.addEventListener('pointerup', onUp)
66
+ }
67
+
68
+ UK.renderCanvas = function (host) {
69
+ stage = host
70
+ if (UK.__dragging) return
71
+ var st = UK.state
72
+ var screen = st.spec.screen || { w: 1080, h: 1920 }
73
+ host.innerHTML = ''
74
+
75
+ var canvas = UK.el('div', {
76
+ class: 'ui-canvas',
77
+ id: 'uk-canvas',
78
+ style: {
79
+ width: screen.w + 'px',
80
+ height: screen.h + 'px',
81
+ transform: 'translate(' + st.pan.x + 'px,' + st.pan.y + 'px) scale(' + st.zoom + ')'
82
+ }
83
+ })
84
+
85
+ var mock = st.spec.mock
86
+ if (mock && mock.src) {
87
+ canvas.appendChild(UK.el('img', { src: mock.src, alt: '', draggable: 'false' }))
88
+ } else {
89
+ canvas.appendChild(UK.el('div', { class: 'ui-empty' }, [
90
+ UK.el('div', { text: '没有效果图' }),
91
+ UK.el('div', { style: { 'font-size': '11px', opacity: '.75' }, text: '节点照常显示;图放进 assets/ 后重新 build' })
92
+ ]))
93
+ }
94
+
95
+ var layer = UK.el('div', { class: 'ui-nodes' })
96
+ var nodes = (st.spec.nodes || []).slice()
97
+ nodes.sort(function (a, b) {
98
+ var da = UK.depthOf(st.spec, a)
99
+ var db = UK.depthOf(st.spec, b)
100
+ return da === db ? (a.__i || 0) - (b.__i || 0) : da - db
101
+ })
102
+
103
+ nodes.forEach(function (node) {
104
+ if (!node || !node.rect) return
105
+ var abs = UK.absRect(st.spec, node)
106
+ var sel = st.selected === node.id
107
+ var box = UK.el('div', {
108
+ class: 'ui-node' + (sel ? ' sel' : '') + (node.opaque ? ' opaque' : ''),
109
+ 'data-id': node.id,
110
+ style: { left: abs[0] + 'px', top: abs[1] + 'px', width: abs[2] + 'px', height: abs[3] + 'px' }
111
+ })
112
+
113
+ if (node.kind === 'text' && node.text) {
114
+ box.appendChild(UK.el('div', {
115
+ class: 'ui-node-text',
116
+ style: {
117
+ 'font-size': (node.text.size || 24) + 'px',
118
+ color: node.text.color || '#333',
119
+ 'line-height': '1.25',
120
+ 'text-align': node.text.align || 'left',
121
+ padding: '0 2px'
122
+ },
123
+ text: node.text.s || ''
124
+ }))
125
+ }
126
+
127
+ if (sel) {
128
+ box.appendChild(UK.el('div', { class: 'ui-node-tag', text: node.rect.join(', ') }))
129
+ ;['nw', 'n', 'ne', 'w', 'e', 'sw', 's', 'se'].forEach(function (h) {
130
+ box.appendChild(UK.el('div', {
131
+ class: 'ui-handle ' + h,
132
+ 'data-handle': h,
133
+ onpointerdown: function (e) { beginDrag(e, node, h) }
134
+ }))
135
+ })
136
+ }
137
+
138
+ box.addEventListener('pointerdown', function (e) {
139
+ if (e.target && e.target.getAttribute && e.target.getAttribute('data-handle')) return
140
+ beginDrag(e, node, null)
141
+ })
142
+ box.addEventListener('contextmenu', function (e) {
143
+ e.preventDefault()
144
+ UK.openMenu(e, node)
145
+ })
146
+ layer.appendChild(box)
147
+ })
148
+
149
+ canvas.appendChild(layer)
150
+ host.appendChild(canvas)
151
+ if (UK.renderStatusLine) UK.renderStatusLine()
152
+ }
153
+
154
+ /* 缩放与平移:滚轮缩放,空白处左拖或中键拖动平移 */
155
+ UK.bindStage = function (host) {
156
+ host.addEventListener('wheel', function (e) {
157
+ e.preventDefault()
158
+ var box = host.getBoundingClientRect()
159
+ UK.setZoom(UK.state.zoom * Math.exp(-e.deltaY * 0.0016), {
160
+ x: e.clientX - box.left,
161
+ y: e.clientY - box.top
162
+ })
163
+ }, { passive: false })
164
+
165
+ host.addEventListener('pointerdown', function (e) {
166
+ if (e.target && e.target.closest && e.target.closest('.ui-node')) return
167
+ if (e.button !== 0 && e.button !== 1) return
168
+ e.preventDefault()
169
+ var startX = e.clientX
170
+ var startY = e.clientY
171
+ var pan = { x: UK.state.pan.x, y: UK.state.pan.y }
172
+ var moved = false
173
+ host.classList.add('panning')
174
+ function onMove(ev) {
175
+ var dx = ev.clientX - startX
176
+ var dy = ev.clientY - startY
177
+ if (!moved && Math.abs(dx) < 3 && Math.abs(dy) < 3) return
178
+ moved = true
179
+ UK.state.pan.x = pan.x + dx
180
+ UK.state.pan.y = pan.y + dy
181
+ var canvas = document.getElementById('uk-canvas')
182
+ if (canvas) canvas.style.transform = 'translate(' + UK.state.pan.x + 'px,' + UK.state.pan.y + 'px) scale(' + UK.state.zoom + ')'
183
+ }
184
+ function onUp() {
185
+ window.removeEventListener('pointermove', onMove)
186
+ window.removeEventListener('pointerup', onUp)
187
+ host.classList.remove('panning')
188
+ if (!moved) UK.select(null)
189
+ }
190
+ window.addEventListener('pointermove', onMove)
191
+ window.addEventListener('pointerup', onUp)
192
+ })
193
+ }
194
+ })(window.__UIKIT__ = window.__UIKIT__ || {})
@@ -0,0 +1,241 @@
1
+ /* 05 · 属性面板:改数值、锚点、文字、绑定,存库入口 */
2
+ (function (UK) {
3
+ 'use strict'
4
+
5
+ var KINDS = ['group', 'text', 'image', 'sprite', 'button', 'list', 'prefab']
6
+ var PRESETS = [
7
+ { id: 'tl', mark: '↖', min: [0, 0], max: [0, 0] }, { id: 't', mark: '↑', min: [0.5, 0], max: [0.5, 0] }, { id: 'tr', mark: '↗', min: [1, 0], max: [1, 0] },
8
+ { id: 'l', mark: '←', min: [0, 0.5], max: [0, 0.5] }, { id: 'c', mark: '●', min: [0.5, 0.5], max: [0.5, 0.5] }, { id: 'r', mark: '→', min: [1, 0.5], max: [1, 0.5] },
9
+ { id: 'bl', mark: '↙', min: [0, 1], max: [0, 1] }, { id: 'b', mark: '↓', min: [0.5, 1], max: [0.5, 1] }, { id: 'br', mark: '↘', min: [1, 1], max: [1, 1] }
10
+ ]
11
+ var extractTarget = null
12
+
13
+ function field(label, control) {
14
+ return UK.el('div', { class: 'ui-field' }, [UK.el('label', { text: label }), control])
15
+ }
16
+
17
+ function numInput(value, onCommit, step) {
18
+ var input = UK.el('input', { type: 'number', step: step || '1', value: value })
19
+ input.addEventListener('change', function () { onCommit(Number(input.value)) })
20
+ return input
21
+ }
22
+
23
+ function setField(node, path, value) {
24
+ UK.commit({ op: 'set', id: node.id, field: path, value: value })
25
+ }
26
+
27
+ function anchorOf(node) {
28
+ var a = node.anchor || {}
29
+ return {
30
+ min: a.min || [0, 0],
31
+ max: a.max || [0, 0],
32
+ pivot: a.pivot || [0, 0]
33
+ }
34
+ }
35
+
36
+ function presetId(anchor) {
37
+ var hit = PRESETS.filter(function (p) {
38
+ return p.min[0] === anchor.min[0] && p.min[1] === anchor.min[1] &&
39
+ p.max[0] === anchor.max[0] && p.max[1] === anchor.max[1]
40
+ })[0]
41
+ return hit ? hit.id : ''
42
+ }
43
+
44
+ UK.syncInspectorRect = function (rect) {
45
+ var ids = ['in-x', 'in-y', 'in-w', 'in-h']
46
+ ids.forEach(function (id, i) {
47
+ var input = document.getElementById(id)
48
+ if (input) input.value = rect[i]
49
+ })
50
+ }
51
+
52
+ UK.renderInspector = function (host) {
53
+ host.innerHTML = ''
54
+ var node = UK.selectedNode()
55
+ var head = UK.el('div', { class: 'ui-pane-head' }, [UK.el('span', { text: '属性' })])
56
+ host.appendChild(head)
57
+
58
+ if (!node) {
59
+ host.appendChild(UK.el('div', { class: 'ui-empty-note', text: '在左边树或画布上选一个节点。' }))
60
+ host.appendChild(UK.el('div', { class: 'ui-group' }, [
61
+ UK.el('div', { class: 'ui-hint' }, [
62
+ UK.el('div', { text: '滚轮缩放 · 空白拖动画布 · 方向键微调 · Delete 删除' })
63
+ ])
64
+ ]))
65
+ return
66
+ }
67
+
68
+ var rect = node.rect || [0, 0, 0, 0]
69
+
70
+ /* 基本 */
71
+ var basic = UK.el('div', { class: 'ui-group' }, [
72
+ UK.el('h4', { text: '基本' }),
73
+ UK.el('div', { class: 'ui-id', text: node.id }),
74
+ UK.el('div', { class: 'ui-grid2', style: { 'margin-top': '8px' } }, [
75
+ field('类型', (function () {
76
+ var sel = UK.el('select', {}, KINDS.map(function (k) {
77
+ return UK.el('option', { value: k, text: k, selected: node.kind === k })
78
+ }))
79
+ sel.addEventListener('change', function () {
80
+ setField(node, 'kind', sel.value)
81
+ if (sel.value === 'text' && !node.text) {
82
+ UK.commit({ op: 'set', id: node.id, field: 'text', value: { s: '文本', size: 24, color: '#333333' } })
83
+ }
84
+ })
85
+ return sel
86
+ })()),
87
+ field('绑定', (function () {
88
+ var input = UK.el('input', { type: 'text', value: node.bind || '', placeholder: '可选' })
89
+ input.addEventListener('change', function () {
90
+ if (input.value) setField(node, 'bind', input.value)
91
+ else UK.commit({ op: 'set', id: node.id, field: 'bind', value: null })
92
+ })
93
+ return input
94
+ })())
95
+ ])
96
+ ])
97
+ host.appendChild(basic)
98
+
99
+ /* 矩形 */
100
+ var rectGroup = UK.el('div', { class: 'ui-group' }, [
101
+ UK.el('h4', { text: '位置与尺寸(父节点局部)' }),
102
+ UK.el('div', { class: 'ui-grid2' }, [
103
+ field('X', numInput(rect[0], function (v) { setRect(node, 0, v) })),
104
+ field('Y', numInput(rect[1], function (v) { setRect(node, 1, v) })),
105
+ field('宽', numInput(rect[2], function (v) { setRect(node, 2, Math.max(4, v)) })),
106
+ field('高', numInput(rect[3], function (v) { setRect(node, 3, Math.max(4, v)) }))
107
+ ])
108
+ ])
109
+ host.appendChild(rectGroup)
110
+
111
+ /* 锚点 */
112
+ var anchor = anchorOf(node)
113
+ var active = presetId(anchor)
114
+ var presetBox = UK.el('div', { class: 'ui-preset' }, PRESETS.map(function (p) {
115
+ return UK.el('button', {
116
+ title: p.id,
117
+ text: p.mark,
118
+ style: active === p.id ? { background: 'var(--uk-accent)', borderColor: 'var(--uk-accent)', color: '#fff' } : null,
119
+ onclick: function () {
120
+ UK.commit({
121
+ op: 'set', id: node.id, field: 'anchor',
122
+ value: { min: p.min.slice(), max: p.max.slice(), pivot: p.min.slice() }
123
+ })
124
+ }
125
+ })
126
+ }))
127
+ var anchorGroup = UK.el('div', { class: 'ui-group' }, [
128
+ UK.el('h4', { text: '锚点' }),
129
+ UK.el('div', { style: { display: 'flex', gap: '10px', 'align-items': 'flex-start' } }, [
130
+ presetBox,
131
+ UK.el('div', { class: 'ui-hint', style: { 'flex': '1' } }, [
132
+ UK.el('div', { text: active ? '当前:' + active : '当前:自定义(满铺或手改)' }),
133
+ UK.el('div', { text: '窄屏拉伸时按锚点重算位置' })
134
+ ])
135
+ ])
136
+ ])
137
+ host.appendChild(anchorGroup)
138
+
139
+ /* 文本 */
140
+ if (node.kind === 'text') {
141
+ var text = node.text || { s: '', size: 24, color: '#333333' }
142
+ var area = UK.el('textarea', { rows: '2' })
143
+ area.value = text.s || ''
144
+ area.addEventListener('change', function () { setField(node, 'text.s', area.value) })
145
+ var sizeInput = numInput(text.size || 24, function (v) { setField(node, 'text.size', Math.max(4, v)) })
146
+ var colorInput = UK.el('input', { type: 'color', value: toHex(text.color) })
147
+ colorInput.addEventListener('change', function () { setField(node, 'text.color', colorInput.value) })
148
+
149
+ host.appendChild(UK.el('div', { class: 'ui-group' }, [
150
+ UK.el('h4', { text: '文本' }),
151
+ field('内容', area),
152
+ UK.el('div', { class: 'ui-grid2', style: { 'margin-top': '6px' } }, [
153
+ field('字号', sizeInput),
154
+ field('颜色', colorInput)
155
+ ])
156
+ ]))
157
+ }
158
+
159
+ /* 引用 / 预制体 */
160
+ if (node.ref || node.prefab || node.kind === 'list' || node.kind === 'prefab') {
161
+ var extra = UK.el('div', { class: 'ui-group' }, [UK.el('h4', { text: '来源' })])
162
+ if (node.prefab !== undefined) {
163
+ var prefabInput = UK.el('input', { type: 'text', value: node.prefab || '', placeholder: 'Assets/UI/Common/CloseBtn.prefab' })
164
+ prefabInput.addEventListener('change', function () { setField(node, 'prefab', prefabInput.value) })
165
+ extra.appendChild(field('预制体路径', prefabInput))
166
+ var opaqueBox = UK.el('input', { type: 'checkbox' })
167
+ opaqueBox.checked = !!node.opaque
168
+ opaqueBox.addEventListener('change', function () { setField(node, 'opaque', opaqueBox.checked) })
169
+ extra.appendChild(UK.el('label', { style: { display: 'flex', gap: '6px', 'align-items': 'center', 'margin-top': '6px', 'font-size': '12px' } }, [opaqueBox, UK.el('span', { text: '内部结构未知(不往里插虚拟节点)' })]))
170
+ }
171
+ if (node.ref) {
172
+ extra.appendChild(UK.el('div', { class: 'ui-id', style: { 'margin-top': '6px' }, text: node.ref }))
173
+ }
174
+ if (node.kind === 'list') {
175
+ var count = numInput((node.params && node.params.count) || 5, function (v) {
176
+ setField(node, 'params.count', Math.max(1, Math.round(v)))
177
+ })
178
+ extra.appendChild(UK.el('div', { style: { 'margin-top': '6px' } }, [field('示意条数', count)]))
179
+ }
180
+ host.appendChild(extra)
181
+ }
182
+
183
+ /* 动作 */
184
+ host.appendChild(UK.el('div', { class: 'ui-group' }, [
185
+ UK.el('h4', { text: '动作' }),
186
+ UK.el('div', { style: { display: 'flex', gap: '6px', 'flex-wrap': 'wrap' } }, [
187
+ UK.el('button', { class: 'ui-btn', text: '存成库条目…', onclick: function () { extractTarget = node.id; UK.renderAll() } }),
188
+ UK.el('button', { class: 'ui-btn', text: '框定范围', onclick: function () { UK.commit({ op: 'scope', ids: [node.id] }) } }),
189
+ UK.el('button', { class: 'ui-btn', text: '子节点加一个', onclick: function () { UK.addNode(node.id) } }),
190
+ UK.el('button', { class: 'ui-btn', text: '删除', onclick: function () { UK.deleteNode(node.id) } })
191
+ ])
192
+ ]))
193
+
194
+ if (extractTarget === node.id) host.appendChild(extractPanel(node))
195
+ }
196
+
197
+ function setRect(node, index, value) {
198
+ var rect = (node.rect || [0, 0, 4, 4]).slice()
199
+ rect[index] = Math.round(value)
200
+ UK.commit({ op: 'set', id: node.id, field: 'rect', value: rect })
201
+ }
202
+
203
+ function toHex(color) {
204
+ if (typeof color === 'string' && /^#[0-9a-f]{6}$/i.test(color)) return color
205
+ return '#333333'
206
+ }
207
+
208
+ function extractPanel(node) {
209
+ var meta = {
210
+ name: (node.id.split('/').pop() || node.id) + ' 条目',
211
+ desc: '',
212
+ when: '',
213
+ whenNot: ''
214
+ }
215
+ var panel = UK.el('div', { class: 'ui-group', style: { background: '#f6f2e8' } })
216
+ panel.appendChild(UK.el('h4', { text: '存成库条目(草稿)' }))
217
+
218
+ ;[['name', '名称', '基础列表条目'], ['desc', '一句话描述', '左侧图标,中间标题,右侧数量'],
219
+ ['when', '什么时候用', '列表里的一行,宽度撑满容器'], ['whenNot', '什么时候别用', '需要多列排布时']].forEach(function (row) {
220
+ var input = UK.el('input', { type: 'text', value: meta[row[0]], placeholder: row[2] })
221
+ input.addEventListener('input', function () { meta[row[0]] = input.value })
222
+ panel.appendChild(field(row[1], input))
223
+ panel.lastChild.style.marginBottom = '6px'
224
+ })
225
+
226
+ panel.appendChild(UK.el('div', { style: { display: 'flex', gap: '6px', 'margin-top': '8px' } }, [
227
+ UK.el('button', {
228
+ class: 'ui-btn ui-primary',
229
+ text: '生成提取指令',
230
+ onclick: function () {
231
+ UK.commit({ op: 'extract', node: node.id, meta: meta })
232
+ extractTarget = null
233
+ UK.state.drawer = true
234
+ UK.renderAll()
235
+ }
236
+ }),
237
+ UK.el('button', { class: 'ui-btn', text: '取消', onclick: function () { extractTarget = null; UK.renderAll() } })
238
+ ]))
239
+ return panel
240
+ }
241
+ })(window.__UIKIT__ = window.__UIKIT__ || {})
@@ -0,0 +1,52 @@
1
+ /* 06 · 改动抽屉:逐条列 op、撤单条、预览 patch */
2
+ (function (UK) {
3
+ 'use strict'
4
+
5
+ UK.renderDiff = function (host) {
6
+ var st = UK.state
7
+ host.innerHTML = ''
8
+ if (!st.drawer) { host.hidden = true; return }
9
+ host.hidden = false
10
+
11
+ host.appendChild(UK.el('div', { class: 'ui-drawer-head' }, [
12
+ UK.el('b', { text: '本次改动 ' + st.ops.length + ' 条' }),
13
+ UK.el('span', { class: 'ui-chip', text: 'base ' + st.baseHash }),
14
+ UK.el('span', { class: 'ui-spacer', style: { flex: '1' } }),
15
+ UK.el('button', { class: 'ui-btn ui-ghost', text: '关闭', onclick: function () { st.drawer = false; UK.renderAll() } })
16
+ ]))
17
+
18
+ var list = UK.el('div', { class: 'ui-ops' })
19
+ if (!st.ops.length) {
20
+ list.appendChild(UK.el('div', { class: 'ui-empty-note', text: '还没有改动。拖一拖、改个数值,这里会出现一条。' }))
21
+ }
22
+ st.ops.forEach(function (op, i) {
23
+ list.appendChild(UK.el('div', { class: 'ui-op' }, [
24
+ UK.el('span', { class: 'ui-op-kind ' + op.op, text: op.op }),
25
+ UK.el('span', { class: 'ui-op-body', text: UK.opLabel(op) }),
26
+ UK.el('button', {
27
+ class: 'ui-op-x',
28
+ title: '撤销这一条',
29
+ text: '✕',
30
+ onclick: function () { UK.removeOp(i) }
31
+ })
32
+ ]))
33
+ })
34
+ host.appendChild(list)
35
+
36
+ var foot = UK.el('div', { class: 'ui-drawer-foot' })
37
+ var note = UK.el('textarea', { placeholder: '一句人话:改了什么,为什么' })
38
+ note.value = st.note || ''
39
+ note.addEventListener('input', function () { st.note = note.value })
40
+ foot.appendChild(note)
41
+
42
+ var patch = UK.buildPatch()
43
+ foot.appendChild(UK.el('pre', { class: 'ui-patch', text: JSON.stringify(patch, null, 2) }))
44
+
45
+ foot.appendChild(UK.el('div', { style: { display: 'flex', gap: '6px' } }, [
46
+ UK.el('button', { class: 'ui-btn', text: '撤销全部', onclick: function () { UK.resetOps() } }),
47
+ UK.el('button', { class: 'ui-btn', text: '复制 patch', onclick: function () { UK.copyText(UK.replyText()) } }),
48
+ UK.el('button', { class: 'ui-btn ui-primary', text: '提交给 agent', onclick: function () { UK.sendReply() } })
49
+ ]))
50
+ host.appendChild(foot)
51
+ }
52
+ })(window.__UIKIT__ = window.__UIKIT__ || {})