@taptap/maker 0.0.37-beta.4 → 0.0.37-beta.6
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.md +3 -3
- package/dist/maker.js +43296 -4254
- package/docs/MAKER_CONSOLE.md +131 -1
- package/docs/MAKER_MCP_CONNECTION_TROUBLESHOOTING.md +5 -5
- package/package.json +1 -1
- package/skills/lua-ui-to-json/SKILL.md +10 -8
- package/skills/lua-ui-to-json/references/conversion.md +33 -20
- package/skills/lua-ui-to-json/references/nanovg.md +109 -0
- package/skills/lua-ui-to-json/runtime/MakerNanoVG.lua +289 -0
- package/skills/lua-ui-to-json/scripts/ui-json-check.cjs +74 -2
- package/skills/maker-ui-workflow/SKILL.md +109 -4
- package/skills/maker-ui-workflow/references/chatgpt-web.md +50 -0
- package/skills/maker-ui-workflow/references/workflow.md +29 -0
- package/skills/maker-ui-workflow/scripts/assemble-ui.mjs +194 -3
- package/skills/taptap-maker-local/SKILL.md +1 -1
|
@@ -0,0 +1,289 @@
|
|
|
1
|
+
-- Maker NanoVG data adapter. No Lua source is stored in UI documents.
|
|
2
|
+
-- capture() is an explicit, synchronous development operation; hooks never survive it.
|
|
3
|
+
local M = {}
|
|
4
|
+
local unpack = table.unpack or unpack
|
|
5
|
+
local active = false
|
|
6
|
+
local signatures = {
|
|
7
|
+
save = "", restore = "", beginPath = "", closePath = "", fill = "", stroke = "",
|
|
8
|
+
moveTo = "nn", lineTo = "nn", bezierTo = "nnnnnn", quadTo = "nnnn", arcTo = "nnnnn",
|
|
9
|
+
rect = "nnnn", roundedRect = "nnnnn", roundedRectVarying = "nnnnnnnn",
|
|
10
|
+
circle = "nnn", ellipse = "nnnn", arc = "nnnnnn",
|
|
11
|
+
translate = "nn", scale = "nn", rotate = "n", skewX = "n", skewY = "n", transform = "nnnnnn",
|
|
12
|
+
scissor = "nnnn", intersectScissor = "nnnn",
|
|
13
|
+
fillColor = "c", strokeColor = "c", fillPaint = "p", strokePaint = "p",
|
|
14
|
+
strokeWidth = "n", miterLimit = "n", lineCap = "n", lineJoin = "n", globalAlpha = "n",
|
|
15
|
+
fontSize = "n", fontFace = "s", textAlign = "n", textLetterSpacing = "n", text = "nns", textBox = "nnns",
|
|
16
|
+
}
|
|
17
|
+
local paints = { linearGradient = "nnnncc", radialGradient = "nnnncc", imagePattern = "nnnnnsn" }
|
|
18
|
+
|
|
19
|
+
local function finite(n) return type(n) == "number" and n == n and math.abs(n) < math.huge end
|
|
20
|
+
local function color(value)
|
|
21
|
+
if type(value) == "string" then
|
|
22
|
+
assert((#value == 7 or #value == 9) and value:match("^#%x+$"), "Invalid NanoVG color")
|
|
23
|
+
return { tonumber(value:sub(2, 3), 16), tonumber(value:sub(4, 5), 16),
|
|
24
|
+
tonumber(value:sub(6, 7), 16), #value == 9 and tonumber(value:sub(8, 9), 16) or 255 }
|
|
25
|
+
end
|
|
26
|
+
assert(type(value) == "table" and #value == 4, "Expected RGBA color")
|
|
27
|
+
for i = 1, 4 do assert(finite(value[i]) and value[i] >= 0 and value[i] <= 255, "Invalid color channel") end
|
|
28
|
+
return value
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
local function validateArgs(args, sig)
|
|
32
|
+
assert(type(args) == "table" and #args == #sig, "Invalid NanoVG argument count")
|
|
33
|
+
for i = 1, #sig do
|
|
34
|
+
local kind, value = sig:sub(i, i), args[i]
|
|
35
|
+
if kind == "n" then assert(finite(value), "Expected finite NanoVG number")
|
|
36
|
+
elseif kind == "s" then assert(type(value) == "string", "Expected NanoVG string")
|
|
37
|
+
elseif kind == "c" then color(value)
|
|
38
|
+
else
|
|
39
|
+
assert(type(value) == "table" and paints[value.kind], "Unsupported NanoVG paint")
|
|
40
|
+
validateArgs(value.args, paints[value.kind])
|
|
41
|
+
end
|
|
42
|
+
end
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
local function validate(node)
|
|
46
|
+
assert(type(node) == "table" and node.type == "NanoVG", "Expected NanoVG node")
|
|
47
|
+
validateArgs(node.viewBox, "nnnn")
|
|
48
|
+
assert(node.viewBox[3] > 0 and node.viewBox[4] > 0, "Invalid NanoVG viewBox")
|
|
49
|
+
assert(type(node.commands) == "table" and #node.commands <= 20000, "Too many NanoVG commands")
|
|
50
|
+
local depth = 0
|
|
51
|
+
for _, cmd in ipairs(node.commands) do
|
|
52
|
+
assert(type(cmd) == "table" and signatures[cmd[1]], "Unsupported NanoVG command: " .. tostring(cmd[1]))
|
|
53
|
+
local args = {}; for i = 2, #cmd do args[#args + 1] = cmd[i] end
|
|
54
|
+
validateArgs(args, signatures[cmd[1]])
|
|
55
|
+
if cmd[1] == "textBox" then assert(args[3] > 0, "Text box width must be positive") end
|
|
56
|
+
if cmd[1] == "save" then depth = depth + 1 end
|
|
57
|
+
if cmd[1] == "restore" then depth = depth - 1 end
|
|
58
|
+
assert(depth >= 0 and depth <= 32, "Unbalanced NanoVG state stack (layer limit: 32)")
|
|
59
|
+
end
|
|
60
|
+
assert(depth == 0, "Unbalanced NanoVG state stack")
|
|
61
|
+
end
|
|
62
|
+
M.validate = validate
|
|
63
|
+
|
|
64
|
+
-- opts.images maps existing native image handles to assets-relative resource paths.
|
|
65
|
+
-- opts.fonts maps existing font IDs to names. Unknown APIs/opaque paints fail capture.
|
|
66
|
+
function M.capture(ctx, opts, draw)
|
|
67
|
+
assert(not active, "Nested NanoVG capture is not supported; capture separate named layers")
|
|
68
|
+
assert(type(opts) == "table" and type(draw) == "function", "capture requires options and a draw function")
|
|
69
|
+
local node = { type = "NanoVG", id = opts.id, position = "absolute", left = opts.left or 0,
|
|
70
|
+
top = opts.top or 0, width = opts.width, height = opts.height,
|
|
71
|
+
viewBox = opts.viewBox or { 0, 0, opts.width, opts.height }, commands = {} }
|
|
72
|
+
local originals, colors, paintValues = {}, {}, {}
|
|
73
|
+
local images, fonts = opts.images or {}, opts.fonts or {}
|
|
74
|
+
local depth, failure = 0, nil
|
|
75
|
+
local function remember(op, args)
|
|
76
|
+
assert(#node.commands < 20000, "NanoVG command limit exceeded")
|
|
77
|
+
local cmd = { op }; for _, value in ipairs(args) do cmd[#cmd + 1] = value end
|
|
78
|
+
node.commands[#node.commands + 1] = cmd
|
|
79
|
+
end
|
|
80
|
+
local function capturedColor(value)
|
|
81
|
+
assert(colors[value], "Color was created outside capture; create it inside the draw callback")
|
|
82
|
+
return colors[value]
|
|
83
|
+
end
|
|
84
|
+
local function wrap(name, fn)
|
|
85
|
+
if originals[name] then
|
|
86
|
+
_G[name] = function(...)
|
|
87
|
+
local result = { pcall(fn, ...) }
|
|
88
|
+
if not result[1] then failure = tostring(result[2]); error(failure) end
|
|
89
|
+
return unpack(result, 2)
|
|
90
|
+
end
|
|
91
|
+
end
|
|
92
|
+
end
|
|
93
|
+
for name, fn in pairs(_G) do
|
|
94
|
+
if type(fn) == "function" and name:match("^nvg[A-Z]") then originals[name] = fn end
|
|
95
|
+
end
|
|
96
|
+
assert(originals.nvgSave and originals.nvgRestore and originals.nvgReset, "NanoVG context is unavailable")
|
|
97
|
+
originals.nvgSave(ctx)
|
|
98
|
+
active = true
|
|
99
|
+
-- Refuse unrecorded drawing instead of returning a visually incomplete success.
|
|
100
|
+
for name in pairs(originals) do
|
|
101
|
+
local api = name
|
|
102
|
+
_G[api] = function()
|
|
103
|
+
failure = "Unsupported NanoVG capture API: " .. api
|
|
104
|
+
error(failure)
|
|
105
|
+
end
|
|
106
|
+
end
|
|
107
|
+
for op, sig in pairs(signatures) do
|
|
108
|
+
local operation, signature = op, sig
|
|
109
|
+
local name = "nvg" .. op:sub(1, 1):upper() .. op:sub(2)
|
|
110
|
+
wrap(name, function(vg, ...)
|
|
111
|
+
assert(vg == ctx, "A capture may only use its own NanoVG context")
|
|
112
|
+
local args = { ... }
|
|
113
|
+
for i = 1, #signature do
|
|
114
|
+
local kind = signature:sub(i, i)
|
|
115
|
+
if kind == "c" then args[i] = capturedColor(args[i])
|
|
116
|
+
elseif kind == "p" then
|
|
117
|
+
assert(paintValues[args[i]], "Paint was created outside capture")
|
|
118
|
+
args[i] = paintValues[args[i]]
|
|
119
|
+
end
|
|
120
|
+
end
|
|
121
|
+
validateArgs(args, signature)
|
|
122
|
+
if operation == "save" then assert(depth < 32, "NanoVG stack limit") end
|
|
123
|
+
if operation == "restore" then assert(depth > 0, "Unbalanced NanoVG restore") end
|
|
124
|
+
remember(operation, args)
|
|
125
|
+
local result = originals[name](vg, ...)
|
|
126
|
+
if operation == "save" then depth = depth + 1 end
|
|
127
|
+
if operation == "restore" then depth = depth - 1 end
|
|
128
|
+
return result
|
|
129
|
+
end)
|
|
130
|
+
end
|
|
131
|
+
for _, name in ipairs({ "nvgRGB", "nvgRGBA", "nvgRGBf", "nvgRGBAf" }) do
|
|
132
|
+
local api = name
|
|
133
|
+
wrap(api, function(...)
|
|
134
|
+
local a = { ... }; local factor = api:sub(-1) == "f" and 255 or 1
|
|
135
|
+
local rgba = { a[1] * factor, a[2] * factor, a[3] * factor, a[4] and a[4] * factor or 255 }
|
|
136
|
+
color(rgba)
|
|
137
|
+
local result = originals[api](...); colors[result] = rgba; return result
|
|
138
|
+
end)
|
|
139
|
+
end
|
|
140
|
+
for kind, sig in pairs(paints) do
|
|
141
|
+
local paintKind, signature = kind, sig
|
|
142
|
+
local name = "nvg" .. kind:sub(1, 1):upper() .. kind:sub(2)
|
|
143
|
+
wrap(name, function(vg, ...)
|
|
144
|
+
assert(vg == ctx, "NanoVG context mismatch")
|
|
145
|
+
local args = { ... }
|
|
146
|
+
if paintKind == "imagePattern" then
|
|
147
|
+
assert(images[args[6]], "Image handle requires opts.images mapping")
|
|
148
|
+
args[6] = images[args[6]]
|
|
149
|
+
else args[5] = capturedColor(args[5]); args[6] = capturedColor(args[6]) end
|
|
150
|
+
validateArgs(args, signature)
|
|
151
|
+
local result = originals[name](vg, ...)
|
|
152
|
+
paintValues[result] = { kind = paintKind, args = args }
|
|
153
|
+
return result
|
|
154
|
+
end)
|
|
155
|
+
end
|
|
156
|
+
wrap("nvgFontFaceId", function(vg, id)
|
|
157
|
+
assert(vg == ctx and fonts[id], "Font ID requires opts.fonts mapping")
|
|
158
|
+
remember("fontFace", { fonts[id] }); return originals.nvgFontFaceId(vg, id)
|
|
159
|
+
end)
|
|
160
|
+
for _, name in ipairs({ "nvgImageSize", "nvgTextBounds", "nvgTextMetrics" }) do
|
|
161
|
+
if originals[name] then _G[name] = originals[name] end
|
|
162
|
+
end
|
|
163
|
+
local ok, err = xpcall(function()
|
|
164
|
+
originals.nvgReset(ctx)
|
|
165
|
+
originals.nvgBeginPath(ctx)
|
|
166
|
+
draw()
|
|
167
|
+
assert(not failure, failure)
|
|
168
|
+
validate(node)
|
|
169
|
+
end, function(e) return tostring(e) end)
|
|
170
|
+
for name, fn in pairs(originals) do _G[name] = fn end
|
|
171
|
+
for _ = 1, depth do originals.nvgRestore(ctx) end
|
|
172
|
+
originals.nvgRestore(ctx)
|
|
173
|
+
active = false
|
|
174
|
+
if not ok then error(err) end
|
|
175
|
+
return node
|
|
176
|
+
end
|
|
177
|
+
|
|
178
|
+
local function nativeColor(value) return nvgRGBA(unpack(color(value))) end
|
|
179
|
+
local function multiply(a, b)
|
|
180
|
+
return { a[1]*b[1]+a[3]*b[2], a[2]*b[1]+a[4]*b[2], a[1]*b[3]+a[3]*b[4],
|
|
181
|
+
a[2]*b[3]+a[4]*b[4], a[1]*b[5]+a[3]*b[6]+a[5], a[2]*b[5]+a[4]*b[6]+a[6] }
|
|
182
|
+
end
|
|
183
|
+
local function inverse(m)
|
|
184
|
+
local d = m[1]*m[4]-m[2]*m[3]
|
|
185
|
+
if math.abs(d) < 1e-12 then return nil end
|
|
186
|
+
return { m[4]/d, -m[2]/d, -m[3]/d, m[1]/d,
|
|
187
|
+
(m[3]*m[6]-m[4]*m[5])/d, (m[2]*m[5]-m[1]*m[6])/d }
|
|
188
|
+
end
|
|
189
|
+
|
|
190
|
+
-- Draw a leaf inside the caller's active NanoVG frame. Layout belongs to the caller.
|
|
191
|
+
-- resolveImage(path, ctx) returns a cached native handle; this module owns no resources.
|
|
192
|
+
function M.draw(ctx, node, x, y, width, height, resolveImage, opacity)
|
|
193
|
+
validate(node)
|
|
194
|
+
local view, depth = node.viewBox, 0
|
|
195
|
+
local matrix, clips, stack = { 1, 0, 0, 1, 0, 0 }, {}, {}
|
|
196
|
+
nvgSave(ctx)
|
|
197
|
+
local ok, err = xpcall(function()
|
|
198
|
+
nvgTranslate(ctx, x or node.left or 0, y or node.top or 0)
|
|
199
|
+
nvgScale(ctx, (width or node.width or view[3]) / view[3], (height or node.height or view[4]) / view[4])
|
|
200
|
+
nvgTranslate(ctx, -view[1], -view[2])
|
|
201
|
+
nvgFillColor(ctx, nvgRGBA(255, 255, 255, 255)); nvgStrokeColor(ctx, nvgRGBA(0, 0, 0, 255))
|
|
202
|
+
nvgStrokeWidth(ctx, 1); nvgMiterLimit(ctx, 10); nvgLineCap(ctx, 0); nvgLineJoin(ctx, 4)
|
|
203
|
+
nvgFontSize(ctx, 16); nvgFontFace(ctx, "sans"); nvgTextAlign(ctx, 65)
|
|
204
|
+
nvgTextLetterSpacing(ctx, 0)
|
|
205
|
+
if opacity then nvgGlobalAlpha(ctx, opacity) end
|
|
206
|
+
nvgBeginPath(ctx)
|
|
207
|
+
local function clipped(fn, args)
|
|
208
|
+
if #clips == 0 then fn(ctx, unpack(args)); return end
|
|
209
|
+
local inv = inverse(matrix)
|
|
210
|
+
if not inv then return end
|
|
211
|
+
-- Apply layer scissors at paint time so replacing a local scissor cannot
|
|
212
|
+
-- discard an enclosing Widget/ScrollView clip.
|
|
213
|
+
nvgSave(ctx)
|
|
214
|
+
local painted, problem = pcall(function()
|
|
215
|
+
nvgTransform(ctx, unpack(inv))
|
|
216
|
+
for _, clip in ipairs(clips) do
|
|
217
|
+
local back = inverse(clip.matrix)
|
|
218
|
+
if not back then return end
|
|
219
|
+
nvgTransform(ctx, unpack(clip.matrix))
|
|
220
|
+
nvgIntersectScissor(ctx, unpack(clip.args))
|
|
221
|
+
nvgTransform(ctx, unpack(back))
|
|
222
|
+
end
|
|
223
|
+
nvgTransform(ctx, unpack(matrix))
|
|
224
|
+
fn(ctx, unpack(args))
|
|
225
|
+
end)
|
|
226
|
+
nvgRestore(ctx)
|
|
227
|
+
if not painted then error(problem) end
|
|
228
|
+
end
|
|
229
|
+
for _, cmd in ipairs(node.commands) do
|
|
230
|
+
local op, args = cmd[1], {}
|
|
231
|
+
for i = 2, #cmd do args[#args + 1] = cmd[i] end
|
|
232
|
+
if op == "fillColor" or op == "strokeColor" then args[1] = nativeColor(args[1]) end
|
|
233
|
+
if op == "globalAlpha" then args[1] = args[1] * (opacity or 1) end
|
|
234
|
+
if op == "fillPaint" or op == "strokePaint" then
|
|
235
|
+
local p, a = args[1], {}; for i, value in ipairs(args[1].args) do a[i] = value end
|
|
236
|
+
if p.kind == "imagePattern" then
|
|
237
|
+
assert(resolveImage, "Image paint requires resolveImage(path, ctx)")
|
|
238
|
+
a[6] = resolveImage(a[6], ctx)
|
|
239
|
+
assert(type(a[6]) == "number" and a[6] > 0, "NanoVG image could not be resolved")
|
|
240
|
+
else a[5] = nativeColor(a[5]); a[6] = nativeColor(a[6]) end
|
|
241
|
+
args[1] = _G["nvg" .. p.kind:sub(1, 1):upper() .. p.kind:sub(2)](ctx, unpack(a))
|
|
242
|
+
end
|
|
243
|
+
local fn = _G["nvg" .. op:sub(1, 1):upper() .. op:sub(2)]
|
|
244
|
+
assert(type(fn) == "function", "NanoVG runtime API missing: " .. op)
|
|
245
|
+
if op == "scissor" or op == "intersectScissor" then
|
|
246
|
+
local nextClips = {}
|
|
247
|
+
if op == "intersectScissor" then for i, clip in ipairs(clips) do nextClips[i] = clip end end
|
|
248
|
+
nextClips[#nextClips + 1] = { matrix = matrix, args = args }; clips = nextClips
|
|
249
|
+
elseif op == "fill" or op == "stroke" or op == "text" or op == "textBox" then clipped(fn, args)
|
|
250
|
+
else fn(ctx, unpack(args)) end
|
|
251
|
+
if op == "save" then depth = depth + 1; stack[depth] = { matrix = matrix, clips = clips } end
|
|
252
|
+
if op == "restore" then matrix = stack[depth].matrix; clips = stack[depth].clips; stack[depth] = nil; depth = depth - 1 end
|
|
253
|
+
local t
|
|
254
|
+
if op == "transform" then t = args
|
|
255
|
+
elseif op == "translate" then t = { 1, 0, 0, 1, args[1], args[2] }
|
|
256
|
+
elseif op == "scale" then t = { args[1], 0, 0, args[2], 0, 0 }
|
|
257
|
+
elseif op == "rotate" then
|
|
258
|
+
local c, s = math.cos(args[1]), math.sin(args[1]); t = { c, s, -s, c, 0, 0 }
|
|
259
|
+
elseif op == "skewX" then t = { 1, 0, math.tan(args[1]), 1, 0, 0 }
|
|
260
|
+
elseif op == "skewY" then t = { 1, math.tan(args[1]), 0, 1, 0, 0 } end
|
|
261
|
+
if t then matrix = multiply(matrix, t) end
|
|
262
|
+
end
|
|
263
|
+
end, function(e) return tostring(e) end)
|
|
264
|
+
for _ = 1, depth do nvgRestore(ctx) end
|
|
265
|
+
nvgRestore(ctx)
|
|
266
|
+
if not ok then error(err) end
|
|
267
|
+
end
|
|
268
|
+
|
|
269
|
+
-- Register the node before UI.LoadJSON; reuse the engine's layout, input and transforms.
|
|
270
|
+
function M.register(UI, resolveImage)
|
|
271
|
+
assert(not UI.NanoVG, "UI.NanoVG is already registered")
|
|
272
|
+
local Widget = require("urhox-libs/UI/Core/Widget")
|
|
273
|
+
local Vector = Widget:Extend("NanoVG")
|
|
274
|
+
function Vector:Render(ctx)
|
|
275
|
+
local layout = self:GetAbsoluteLayout()
|
|
276
|
+
local data = { type = "NanoVG", commands = self.props.commands, viewBox = self.props.viewBox }
|
|
277
|
+
local opacity, widget = 1, self
|
|
278
|
+
while widget do
|
|
279
|
+
local a = widget.renderProps_ and widget.renderProps_.opacity or widget.props.opacity or 1
|
|
280
|
+
opacity = opacity * math.max(0, math.min(1, a))
|
|
281
|
+
widget = widget.parent
|
|
282
|
+
end
|
|
283
|
+
M.draw(ctx, data, layout.x, layout.y, layout.w, layout.h, resolveImage, opacity)
|
|
284
|
+
end
|
|
285
|
+
UI.NanoVG = Vector
|
|
286
|
+
return Vector
|
|
287
|
+
end
|
|
288
|
+
|
|
289
|
+
return M
|
|
@@ -1,6 +1,74 @@
|
|
|
1
1
|
(function (root) {
|
|
2
2
|
"use strict";
|
|
3
|
-
var previewTypes = new Set(["Panel", "Label", "Button"]);
|
|
3
|
+
var previewTypes = new Set(["Panel", "Label", "Button", "NanoVG"]);
|
|
4
|
+
// An allowlist shared by the browser, CLI and standalone document checker.
|
|
5
|
+
var nanoOps = {
|
|
6
|
+
save: "", restore: "", beginPath: "", closePath: "", fill: "", stroke: "",
|
|
7
|
+
moveTo: "nn", lineTo: "nn", bezierTo: "nnnnnn", quadTo: "nnnn", arcTo: "nnnnn",
|
|
8
|
+
rect: "nnnn", roundedRect: "nnnnn", roundedRectVarying: "nnnnnnnn",
|
|
9
|
+
circle: "nnn", ellipse: "nnnn", arc: "nnnnnn",
|
|
10
|
+
translate: "nn", scale: "nn", rotate: "n", skewX: "n", skewY: "n", transform: "nnnnnn",
|
|
11
|
+
scissor: "nnnn", intersectScissor: "nnnn",
|
|
12
|
+
fillColor: "c", strokeColor: "c", fillPaint: "p", strokePaint: "p",
|
|
13
|
+
strokeWidth: "n", miterLimit: "n", lineCap: "n", lineJoin: "n", globalAlpha: "n",
|
|
14
|
+
fontSize: "n", fontFace: "s", textAlign: "n", textLetterSpacing: "n", text: "nns", textBox: "nnns",
|
|
15
|
+
};
|
|
16
|
+
function nanoColor(value) {
|
|
17
|
+
return typeof value === "string" && /^#[0-9a-f]{6}([0-9a-f]{2})?$/i.test(value) ||
|
|
18
|
+
Array.isArray(value) && value.length === 4 && value.every(function (n) {
|
|
19
|
+
return typeof n === "number" && Number.isFinite(n) && n >= 0 && n <= 255;
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
function checkNanoVG(node, issue, resource) {
|
|
23
|
+
var box = node.viewBox, commands = node.commands, depth = 0;
|
|
24
|
+
if (!Array.isArray(box) || box.length !== 4 || box.some(function (n) {
|
|
25
|
+
return typeof n !== "number" || !Number.isFinite(n);
|
|
26
|
+
}) || box[2] <= 0 || box[3] <= 0) issue("/viewBox", "viewBox 必须是 [x, y, 正宽度, 正高度]。");
|
|
27
|
+
if (!Array.isArray(commands) || commands.length > 20000) {
|
|
28
|
+
issue("/commands", "绘制指令必须是数组,最多 20000 条。"); return;
|
|
29
|
+
}
|
|
30
|
+
function paint(value, at) {
|
|
31
|
+
if (!value || typeof value !== "object" || Array.isArray(value) || typeof value.kind !== "string") return false;
|
|
32
|
+
var signatures = { linearGradient: "nnnncc", radialGradient: "nnnncc", imagePattern: "nnnnnsn" };
|
|
33
|
+
var sig = Object.prototype.hasOwnProperty.call(signatures, value.kind) && signatures[value.kind];
|
|
34
|
+
if (!sig || !args(value.args, sig, at + "/args")) return false;
|
|
35
|
+
if (value.kind === "radialGradient" && (value.args[2] < 0 || value.args[3] <= value.args[2])) return false;
|
|
36
|
+
if (value.kind === "imagePattern") {
|
|
37
|
+
if (value.args[2] <= 0 || value.args[3] <= 0 || value.args[6] < 0 || value.args[6] > 1) return false;
|
|
38
|
+
resource(value.args[5], at + "/args/5");
|
|
39
|
+
}
|
|
40
|
+
return true;
|
|
41
|
+
}
|
|
42
|
+
function args(values, sig, at) {
|
|
43
|
+
return Array.isArray(values) && values.length === sig.length && values.every(function (value, i) {
|
|
44
|
+
var type = sig[i];
|
|
45
|
+
return type === "n" ? typeof value === "number" && Number.isFinite(value) :
|
|
46
|
+
type === "s" ? typeof value === "string" : type === "c" ? nanoColor(value) : paint(value, at + "/" + i);
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
commands.forEach(function (command, i) {
|
|
50
|
+
var at = "/commands/" + i;
|
|
51
|
+
if (!Array.isArray(command) || typeof command[0] !== "string" || !Object.prototype.hasOwnProperty.call(nanoOps, command[0]) ||
|
|
52
|
+
!args(command.slice(1), nanoOps[command[0]], at)) {
|
|
53
|
+
issue(at, "不支持的 NanoVG 指令或参数。使用 ui capabilities 查询支持范围。"); return;
|
|
54
|
+
}
|
|
55
|
+
var op = command[0], a = command.slice(1);
|
|
56
|
+
if (op === "save" && ++depth > 32) issue(at, "NanoVG 图层状态栈超过 32 层,需为引擎保留栈空间。");
|
|
57
|
+
if (op === "restore" && --depth < 0) { issue(at, "restore 没有对应的 save。"); depth = 0; }
|
|
58
|
+
if (op === "globalAlpha" && (a[0] < 0 || a[0] > 1)) issue(at, "透明度必须在 0 到 1 之间。");
|
|
59
|
+
if (["strokeWidth", "miterLimit", "fontSize"].includes(op) && a[0] <= 0) issue(at, "值必须大于 0。");
|
|
60
|
+
if (op === "lineCap" && ![0, 1, 2].includes(a[0]) || op === "lineJoin" && ![1, 3, 4].includes(a[0]) ||
|
|
61
|
+
op === "arc" && ![1, 2].includes(a[5])) issue(at, "无效的 NanoVG 枚举值。");
|
|
62
|
+
if (op === "textBox" && a[2] <= 0) issue(at, "文本框宽度必须大于 0。");
|
|
63
|
+
if (op === "textAlign" && ![0, 1, 2, 4].some(function (h) {
|
|
64
|
+
return [0, 8, 16, 32, 64].some(function (v) { return a[0] === h + v; });
|
|
65
|
+
})) issue(at, "文本对齐每个方向最多指定一个 NanoVG 标志。");
|
|
66
|
+
if (op === "circle" && a[2] < 0 || op === "ellipse" && (a[2] < 0 || a[3] < 0) ||
|
|
67
|
+
op === "arc" && a[2] < 0 || op === "arcTo" && a[4] < 0 ||
|
|
68
|
+
op.startsWith("roundedRect") && a.slice(4).some(function (n) { return n < 0; })) issue(at, "半径不能为负数。");
|
|
69
|
+
});
|
|
70
|
+
if (depth) issue("/commands", "save/restore 必须配对。");
|
|
71
|
+
}
|
|
4
72
|
var lengths = ["width", "height", "minWidth", "minHeight", "maxWidth", "maxHeight",
|
|
5
73
|
"left", "right", "top", "bottom", "padding", "paddingLeft", "paddingRight",
|
|
6
74
|
"paddingTop", "paddingBottom", "paddingHorizontal", "paddingVertical",
|
|
@@ -94,6 +162,10 @@
|
|
|
94
162
|
}
|
|
95
163
|
});
|
|
96
164
|
resource(node.backgroundImage, pointer + "/backgroundImage");
|
|
165
|
+
resource(node.pressedBackgroundImage, pointer + "/pressedBackgroundImage");
|
|
166
|
+
if (node.type === "NanoVG") checkNanoVG(node, function (at, message) {
|
|
167
|
+
issue("UI_NANOVG", "error", pointer + at, message);
|
|
168
|
+
}, function (ref, at) { resource(ref, pointer + at); });
|
|
97
169
|
if (node.component != null) {
|
|
98
170
|
if (token(node.component)) {
|
|
99
171
|
parameterized = true;
|
|
@@ -128,7 +200,7 @@
|
|
|
128
200
|
.concat(options.resourceExists ? [] : ["resource-existence"]),
|
|
129
201
|
};
|
|
130
202
|
}
|
|
131
|
-
var api = { checkDocument: checkDocument };
|
|
203
|
+
var api = { checkDocument: checkDocument, checkNanoVG: checkNanoVG, nanoOps: nanoOps };
|
|
132
204
|
if (typeof module !== "undefined" && module.exports) module.exports = api;
|
|
133
205
|
else root.UrhoxUICheck = api;
|
|
134
206
|
})(typeof window !== "undefined" ? window : globalThis);
|
|
@@ -16,27 +16,96 @@ Maker 是流程入口;自由画布展示分析与切图,脚本按显式布
|
|
|
16
16
|
- 已有 UI.json,要调位置或对照:直接打开编辑器,不重新生图或覆盖现有文档。
|
|
17
17
|
- 只说“做个背包/商店界面”:从上下文找原稿及风格要求;缺少会改变结果的设计意图时再询问。
|
|
18
18
|
|
|
19
|
+
已有 UI 的命令行编辑使用同包 taptap-maker ui:capabilities 查看格式,list 找文档,
|
|
20
|
+
inspect 读取保存版本及 revision,patch 按节点 ID(或 children pointer)批量增删改和移动。
|
|
21
|
+
先用 --dry-run 检查,再带同一 revision 执行;版本冲突时重读并合并,不强制覆盖。
|
|
22
|
+
check 检查声明和资源,open --no-open 返回控制台 UI 编辑器地址。CLI 不读取网页未保存草稿;
|
|
23
|
+
网页有草稿时先保留,CLI 写入后通过文档菜单重新从磁盘加载或打开保存版本。
|
|
24
|
+
|
|
19
25
|
## 准备
|
|
20
26
|
|
|
27
|
+
调用生图或识图前先执行 `taptap-maker canvas model-settings`,读取全局设置;不自行选择或回退渠道。
|
|
28
|
+
generation=maker 时沿用 Maker;custom 时通过画布 run 调用选定 API,不读取或传递密钥。
|
|
29
|
+
vision=chatgpt-web 时执行 [网页识图](references/chatgpt-web.md),复用客户端浏览器;登录可选,不安装独立执行器。
|
|
30
|
+
local 时由当前客户端使用自身能力执行,缺少对应能力则提示用户;画布 run 无法调用客户端模型。
|
|
31
|
+
本地图片可用 canvas import 导入,但它只新增图片卡,不会自动回填或完成已有模板节点,
|
|
32
|
+
不得把导入成功当成原工作流完成。已有 Bbox 仍通过 update-nodes 写入所属识图卡并按原契约校验。
|
|
33
|
+
|
|
21
34
|
读取 Maker 状态并绑定明确的项目目录;沿用对话中已选项目。控制台打开、画布 CLI 和付费生成遵循
|
|
22
35
|
同包 taptap-maker-local 与工具实际 schema。保持同一 target-dir,不凭全局当前项目推断。
|
|
23
36
|
打开控制台后用 canvas pages / snapshot 读取当前页面、画布和 revision;通过页面桥接操作和保存,
|
|
24
37
|
不能直接覆写打开中的画布文件。命令参数先读当前 CLI 的 canvas 帮助。
|
|
38
|
+
修改卡片显示大小使用 canvas update-nodes,例如 input 为
|
|
39
|
+
`{"nodes":[{"id":"卡片ID","width":800}]}`。图片卡设置 width 或 height 即等比调整另一边,
|
|
40
|
+
它只改变卡片,不改变图片像素、其它卡片位置或画布缩放;具体范围以 canvas capabilities 为准。
|
|
41
|
+
|
|
42
|
+
尺寸以图片像素为准,不使用画布卡片的 width/height:inspect 的 imageInfo 是当前图片实际宽高和比例,
|
|
43
|
+
originalImage 是沿引用链取得的原稿坐标基准。去文字、背景准备和整屏标注默认 parameters.aspectRatio=source,
|
|
44
|
+
跟随原稿;图集保持自己的行列排版。固定比例可用 canvas capabilities 的选项显式覆盖。
|
|
45
|
+
非常见比例先向用户说明可能影响构图和切图;跟随的比例不被接口支持时,在运行前选择支持的比例,
|
|
46
|
+
不静默拉伸、裁剪原稿,也不把 9:21 当成已支持的输出。原图尺寸和请求/结果尺寸分别保留。
|
|
47
|
+
生成记录的 referenceImages、originalImage、parameters.targetSize、resultImageInfo 和 warnings 用于核对;
|
|
48
|
+
submittedPrompt 包含实际发送的参考图尺寸。实际结果比例不符时先核对,不把请求尺寸当成成功结果。
|
|
25
49
|
|
|
26
50
|
有完整 UI 拆解用户模板时优先复用,在新画布替换原稿;没有时用现有图片和资源卡建立同样的流程。
|
|
27
51
|
旧示例结果只供参考。换原稿后重做识别、布局、素材绑定与网格核对,不能只换首图就沿用旧结果。
|
|
28
52
|
|
|
53
|
+
官方合批模板与历史分类模板保留各自保存的识图开关;CLI 的 canvas run 游戏 UI 分组或图片步骤默认开启识图,
|
|
54
|
+
保存开关,先完成去文字,再取得去文字图的清单后才继续下游,不依赖 Agent 额外开启。
|
|
55
|
+
带当前 page-id、canvas-id、revision 和 target-dir 执行;只有用户明确要求无识图对照时,
|
|
56
|
+
在本次及后续 run 的 input 中显式传 `"recognition":false`,例如
|
|
57
|
+
`{"id":"分组ID","recognition":false}`。仅提前关闭卡片开关不能覆盖 CLI run 的默认值。
|
|
58
|
+
识图遵循设置:local 才使用当前客户端模型;custom 使用选中的命名 API 配置和模型;
|
|
59
|
+
chatgpt-web 按网页识图引用完成两轮、校验和回填;Server API 开发中,不可选择,不回退。
|
|
60
|
+
自定义 API 的 GPT-6.1 Sol 使用 low 档位,其它模型不强加该参数。
|
|
61
|
+
以下两次接口执行步骤适用于 custom;local 按同样输入与 Bbox 契约由客户端识别后写回。
|
|
62
|
+
取得两次识图的付费授权后执行:
|
|
63
|
+
|
|
64
|
+
1. run「去文字设计稿」,确认其已完成,且直接连线引用唯一原稿。
|
|
65
|
+
2. 运行去文字卡的两次识图(分组 run 也会自动执行):第一次只看去文字图提取 UI;
|
|
66
|
+
第二次只看原稿提取文字,并带第一次已换算到原稿像素的清单。不要加入旧稿数量或额外识图 Skill。
|
|
67
|
+
3. inspect 读取选用结果的 uiRecognition.results[].bbox,或在识图面板导出 Bbox JSON。
|
|
68
|
+
固定 version=1、coordinateSpace=design-pixels、bboxFormat=xywh,design/cutSource 保存图片路径、
|
|
69
|
+
哈希及真实尺寸;elements 为 E 编号的 icon/frame/panel/button/tab/title,texts 为 T 编号的文字。
|
|
70
|
+
所有 bbox 都是原稿像素 [x,y,w,h];切去文字图才按两张图的实际宽高换算。
|
|
71
|
+
4. 完整结果保存后继续拆图。文字的 text、parentId、role、align、color、bold 全部保留,cutout=false,
|
|
72
|
+
后续做 Label,不入切图清单。unknown 或中断只查询原请求,不重放;第二次失败不把第一次当作完成。
|
|
73
|
+
|
|
74
|
+
不要重新看图猜坐标或让用户换当前对话模型。已有 Bbox 时直接复用;换原稿或重新去文字后再识别。
|
|
75
|
+
旧版单次清单没有文字 Bbox,需要双次识图后才能按本流程完整组装。
|
|
76
|
+
|
|
77
|
+
当前「游戏UI制作」模板按控件、图标、装备、面板、人物和背景分类自动分批,单张最多 5×5,
|
|
78
|
+
分类内按 Bbox 尺寸和长宽比合批,横长、竖长与普通素材分开;长条每批最多五格,
|
|
79
|
+
续批保留元素 ID 和状态绑定,不按旧序号解释新图。duplicateOf 实例共用槽位,但保留各自的坐标和绑定。
|
|
80
|
+
执行该模板时沿用自动规划,不额外改成混合分类或固定更大的网格。自定义流程的合批建议见
|
|
81
|
+
references/workflow.md 的「图集合批」。已有结果保留,不为了合批重新付费生成。
|
|
82
|
+
|
|
83
|
+
只执行已配置的画布模板时,确认输入和参数后使用分组 run(取得付费授权后传 --allow-paid)。
|
|
84
|
+
local / chatgpt-web 在缺少识图结果时交给 Agent 执行;完成回填、确认保存后读取最新 revision,
|
|
85
|
+
再次 run 原分组继续下游,保留 recognition=true,不通过关闭识图绕过等待。
|
|
86
|
+
队列按连线自动接续图片与资源卡,资源卡按已保存网格裁切并保存独立 PNG,不必逐张调用。
|
|
87
|
+
最后一步是内容就绪的资源包卡片;入项目、meta、UI.json 和编辑器属于后续独立任务,
|
|
88
|
+
仅在用户要求时继续。自动裁切不表示视觉复核通过;缺少网格或结果未知时处理原阻塞后再继续。
|
|
89
|
+
|
|
29
90
|
## 执行
|
|
30
91
|
|
|
31
92
|
布局字段、坐标依据、冗余资源和双重对位契约见 [workflow.md](references/workflow.md)。
|
|
32
93
|
|
|
33
|
-
1.
|
|
34
|
-
|
|
35
|
-
|
|
94
|
+
1. 官方合批模板与历史分类模板都先准备原稿与去文字稿,再分别识别去文字稿 UI 与原稿文字。
|
|
95
|
+
两条流程都保存同格式 Bbox JSON,按设置使用识图来源。
|
|
96
|
+
相似按钮逐个记录,切图清单用于标框和拆图;原稿文字清单留给组装。重新去文字后必须重新识别。
|
|
97
|
+
2. 按去文字稿的清单分别标注按钮、图标;背景在去文字后再去除前景。
|
|
98
|
+
美术字是独立支线:标注和提取始终引用未去文字的原设计稿,不能因去文字清单没有美术字而跳过。
|
|
36
99
|
提取提示词分开写“参考与目标”“保留”“移除”“输出”。按钮默认/按下态分别生成、统一画布与锚点,
|
|
37
100
|
图标与按钮底板分离;美术字只保留字形及字效,不带后方底框。
|
|
38
|
-
|
|
101
|
+
普通文字从第二次识图的 texts 还原为 Label,不混入去文字切图清单,不重新猜位置。
|
|
102
|
+
3. 切图前固定 uiAtlasPlan:每格关联元素 ID、状态,按从左到右、从上到下输出,
|
|
103
|
+
提示词带名称和换算到参考图的 Bbox。生成结果保存本次清单,不用后续修改的清单解释旧图。
|
|
104
|
+
当前官方模板按分类自动生成清单及续批;自定义清单才由 Agent 显式规划。更换原稿或识图结果后重新规划,不能沿用旧绑定。
|
|
105
|
+
查看真实结果。透明处理、必要的重新排版要明确使用已有能力或可重复的本地处理,不能把人工修图冒充模板自动能力。
|
|
39
106
|
用图集预览核对完整边界后确认,再导出独立 PNG;未知远端任务只查原任务,不自动重提。
|
|
107
|
+
数量相同不能证明内容顺序正确。未核对的切图保持 unreviewed,不允许直接拼装。
|
|
108
|
+
导出资源包同时包含 bbox.json、bindings.json,PNG 仍按分类分文件夹。
|
|
40
109
|
4. 正式素材按 assets/ui/<界面>/images/ 归档;备用图同目录 reserve/ 保留但不入布局。
|
|
41
110
|
过程文件、layout.json、corrections.json 留在项目 .maker/ui-workflows/<界面>/,不混入正式 PNG。
|
|
42
111
|
明确绑定资源 ID 与元素 ID、默认/按下态,记录图片尺寸与哈希;显式调用 generate_resource_meta。
|
|
@@ -48,6 +117,20 @@ Maker 是流程入口;自由画布展示分析与切图,脚本按显式布
|
|
|
48
117
|
|
|
49
118
|
## 组装和打开
|
|
50
119
|
|
|
120
|
+
### 隔一段时间继续拼 UI
|
|
121
|
+
|
|
122
|
+
官方合批模板与历史分类模板共用本地归档,不依赖聊天记忆或控制台保持开启。
|
|
123
|
+
先运行 `taptap-maker canvas ui-archives --target-dir <项目>`,按名称、uiId 和 revision 选择用户指定的 UI;
|
|
124
|
+
读取返回的同一条记录的 bboxPath、bindingsPath。多个版本不能擅自选最新,也不跨界面借用坐标。
|
|
125
|
+
旧画布尚无归档时,先保存,再运行 `canvas archive-ui --target-dir <项目> --canvas-id <ID>`;
|
|
126
|
+
该命令只归档已保存数据,不生图、不识图、不读取未保存草稿。
|
|
127
|
+
recognized 记录只有 Bbox;resources 记录才包含分类 PNG、设计稿、去文字稿和 bindings.json。
|
|
128
|
+
资源版本为不可变快照,重识图或重切保存新版本;改名称不改变 uiId,复制新画布产生新 uiId。
|
|
129
|
+
从该归档目录或用户解压的资源包导入图片,保留 bbox.design/cutSource 的 assets/ 路径和哈希;
|
|
130
|
+
素材按分类放入 assets/ui/<界面>/images/,只改 bindings.assets 中的 path,不改元素 ID 或 Bbox。
|
|
131
|
+
合并 bbox.json 与 bindings.json 为 assembly.json,保留 ui 字段;脚本检查 Bbox 哈希,拒绝混搭版本。
|
|
132
|
+
原参考图目标路径已存在时先核对哈希,不覆盖不同图片。归档不自动清理,删除整个项目仍需自行备份 ZIP。
|
|
133
|
+
|
|
51
134
|
在已安装的 Skill 目录运行(正式分发的脚本已打包依赖,无需 npm install):
|
|
52
135
|
|
|
53
136
|
node scripts/assemble-ui.mjs <项目绝对路径> <layout.json> <新输出目录> [corrections.json]
|
|
@@ -56,6 +139,28 @@ Maker 是流程入口;自由画布展示分析与切图,脚本按显式布
|
|
|
56
139
|
用当前分发的 CLI 执行 console open --target-dir <项目> --no-open --json,取得真实地址;
|
|
57
140
|
保留其项目参数,追加 &page=ui-editor&ui=<URL编码的 assets/ 相对 UI 路径>,即可直达文档。
|
|
58
141
|
控制台已打开时也可进入「UI 编辑器」并刷新文件列表。不要启动独立 UrhoxUIEditor 或 Python 服务。
|
|
142
|
+
也可直接运行 taptap-maker ui open --target-dir <项目> --file <assets/相对UI路径> --no-open --json,
|
|
143
|
+
取得含项目与 checkout 身份的直达地址;不要手工拼接另一个项目的 URL。
|
|
144
|
+
|
|
145
|
+
### 直接使用 Bbox JSON 组装
|
|
146
|
+
|
|
147
|
+
已有单次或两次识图的 Bbox 时,不手工重建另一份坐标。准备一个 assembly.json,包含:
|
|
148
|
+
|
|
149
|
+
- bbox:导出的完整 Bbox JSON 对象;所有框已是原稿像素 [x,y,w,h]。
|
|
150
|
+
- assets:沿用 layout 格式的资源记录(id、assets/ 相对 path、sha256、width、height、role)。
|
|
151
|
+
- bindings:每个 E 元素的显式 {elementId,assetId},按钮可附 pressedAssetId;备用素材 role=reserve。
|
|
152
|
+
|
|
153
|
+
资源包的 bindings.json 可直接与 bbox.json 合并,仅将资源 path 改为导入后的 assets/ 路径;
|
|
154
|
+
保留 confirmed、review、哈希、contentRect 和 backgroundAssetId。缺件或未确认清单不能拼装。
|
|
155
|
+
contentRect 是 PNG 内的有效区域,脚本确定性裁掉透明边距到新目录,原素材不变;不是视觉纠偏。
|
|
156
|
+
已有素材只有存在明确的元素 ID/路径/哈希记录才能回填为 recorded,不能按文件顺序臆测旧关联。
|
|
157
|
+
|
|
158
|
+
将 assembly.json 作为 assemble-ui.mjs 的第二个参数。脚本按 Bbox 生成图像节点和 Label,
|
|
159
|
+
自动换算父子相对位置,保留文本、对齐、颜色和粗体;字号以墨迹高度初拟合,字体沿用编辑器 PingFang SC。
|
|
160
|
+
输出额外的 layout.json,后续纠偏使用该文件与已有 corrections 契约。不从 PNG 名称或相似外观猜绑定,
|
|
161
|
+
缺少任一 E 元素的绑定即停止;文字无需 PNG。组装目前仍要求参考源和素材为 PNG,
|
|
162
|
+
非 PNG 参考先在项目中转为 PNG 并明确更新路径、哈希与尺寸,不修改 bbox 坐标。
|
|
163
|
+
字体度量、素材透明边距、图层顺序和生图形变仍需编辑器对照;Bbox 通过校验不代表视觉验收通过。
|
|
59
164
|
|
|
60
165
|
## 完成检查
|
|
61
166
|
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
# ChatGPT 网页识图
|
|
2
|
+
|
|
3
|
+
使用当前 Agent 已有的浏览器工具,先读工具规则。复用已打开的 ChatGPT 和登录态,
|
|
4
|
+
不安装浏览器或执行器,不复制 Cookie。缺少浏览器工具时明确说明,不改用客户端模型或 API。
|
|
5
|
+
|
|
6
|
+
## 登录与模型
|
|
7
|
+
|
|
8
|
+
- 先检查页面。已登录时读取当前模型和思考程度,沿用用户设置;不要每轮重选。
|
|
9
|
+
- 未登录时说明:「未登录也可识图,但无法选择模型,识别质量和 Bbox 准确度可能有偏差。」
|
|
10
|
+
让用户选择「直接识图」或「登录后识图」。已有明确选择就直接执行,不重复问。
|
|
11
|
+
- 选择直接识图后继续使用网页当前可用模型,不检查推荐模型是否存在作为阻断条件。
|
|
12
|
+
记录实际可见模型;不明时用 ChatGPT web / unknown model,不能写成 GPT-6 Astra。
|
|
13
|
+
- 选择登录后识图时才等待用户在当前页面完成登录。若用户要求推荐,建议 GPT-6 Astra/轻度;
|
|
14
|
+
只有用户要求或确认更换时才操作模型菜单。登录不保证账号拥有指定模型。
|
|
15
|
+
- 网页实际限制仍需遵守:验证码、无法上传图片、额度用尽或强制登录时说明具体限制,
|
|
16
|
+
由用户处理后继续。不要把“登录可选”解释为绕过网站门槛。
|
|
17
|
+
|
|
18
|
+
## 输入、执行、回填
|
|
19
|
+
|
|
20
|
+
1. 官方合批模板与历史分类模板使用同一双轮流程。先完成去文字并保存画布,用 canvas inspect 找到
|
|
21
|
+
inputRole=text-free 的识图卡及其唯一上游原稿,不按标题里的序号或示例数量选择输入。
|
|
22
|
+
获取第一轮输入(命令只读已保存画布,不发模型请求):
|
|
23
|
+
|
|
24
|
+
taptap-maker canvas recognition-input --target-dir <项目> --canvas-id <画布> --id <识图卡>
|
|
25
|
+
|
|
26
|
+
保存返回的 canvasId、nodeId、design、cutSource,整个过程不改这些身份字段。
|
|
27
|
+
上传返回的 imagePath,只发送返回的 prompt。每轮用新对话,保持当前模型与档位。
|
|
28
|
+
浏览器只允许上传工作目录中的文件时,复制这张图片到允许目录,不改图片内容。
|
|
29
|
+
确认附件上传完成、发送可用后只发送一次;等待完整回复,保存 cut JSON 和原对话 URL。
|
|
30
|
+
|
|
31
|
+
2. 写 reply.json,内容为第一步的四个身份字段加 cut(网页原始 JSON 对象)。
|
|
32
|
+
原样再次调用 recognition-input,附加 --input-file <reply.json>。
|
|
33
|
+
命令验证 UI 清单,返回原稿 imagePath 和包含已换算坐标的文字轮 prompt。
|
|
34
|
+
上传并发送,保存完整的 text JSON 和对话 URL。失败或中断先查原对话,不自动重发。
|
|
35
|
+
|
|
36
|
+
3. 在 reply.json 增加 text、model(实际网页模型说明)和 durationMs。durationMs 是从第一次上传开始到两轮回复收齐的毫秒数,必须大于 0。没有测到的时间不要写 0。执行:
|
|
37
|
+
|
|
38
|
+
taptap-maker canvas recognition-result --target-dir <项目> --canvas-id <画布> --id <识图卡> --input-file <reply.json>
|
|
39
|
+
|
|
40
|
+
输出是 canvas update-nodes 的输入。两轮阶段、图片身份、尺寸、框和父子引用全部校验;
|
|
41
|
+
不完整的结果不能写回为成功。校验失败先检查网页原回复,不自行捏造坐标来通过。
|
|
42
|
+
|
|
43
|
+
4. 重新读取 canvas pages / inspect 的 page-id 和 revision,将上一步输出保存为 update.json:
|
|
44
|
+
|
|
45
|
+
taptap-maker canvas update-nodes --target-dir <项目> --page-id <页面> --canvas-id <画布> --revision <版本> --input-file <update.json>
|
|
46
|
+
|
|
47
|
+
查询返回的 operation-id,确认成功;打开「查看标注」,核对 UI 和文字,保存后重开。
|
|
48
|
+
复用自动 Bbox 归档;准备命令成功不等于网页识图成功,结构校验不等于像素级视觉验收。
|
|
49
|
+
用户只要求识图时到此结束,不触发生图、切图或组装。
|
|
50
|
+
已授权整组执行时,以最新 revision 再次 run 原分组并保留 recognition=true,复用已保存结果。
|
|
@@ -30,6 +30,13 @@
|
|
|
30
30
|
|
|
31
31
|
### 布局文件与组装工具
|
|
32
32
|
|
|
33
|
+
双次识图的固定 Bbox JSON 可以直接作为组装输入:在 assembly.json 中保存 bbox、assets 和 bindings,
|
|
34
|
+
bindings 每项用 elementId 显式指定 assetId(按钮可加 pressedAssetId)。Bbox 的 elements 和 texts
|
|
35
|
+
均使用 design-pixels 的 xywh;去文字图的尺寸与身份单列 cutSource,不混用图集坐标。
|
|
36
|
+
assemble-ui.mjs 自动生成图像节点与 Label、换算父子位置,并额外输出 layout.json 供后续纠偏。
|
|
37
|
+
文本保持内容、对齐、颜色和粗体,字号按墨迹高度初拟合;仍需编辑器复核字体与图层顺序。
|
|
38
|
+
缺少切图元素绑定即停止,备用素材保留但不自动创建节点。参考源与素材目前均须为 PNG。
|
|
39
|
+
|
|
33
40
|
组装脚本 <本 Skill 目录>/scripts/assemble-ui.mjs 不调用付费模型、不写 meta、不修改已打开画布。
|
|
34
41
|
随 Maker 的 npm 包和客户端插件分发;使用安装位置下的 Skill 脚本,不依赖开发仓库。
|
|
35
42
|
布局文件放项目开发资源目录,UI 和正式 PNG 放 assets。命令输出目录必须不存在,避免覆盖手工编辑。
|
|
@@ -68,6 +75,28 @@ review 包含 designSha256 与 evidence(实际对照截图路径),adjustme
|
|
|
68
75
|
连线、提示词和示例结果,但不会把旧设计稿的元素清单、标框、网格和布局坐标自动适配到新图。
|
|
69
76
|
旧结果只供参考,不能在替换首图后直接当作新设计稿的交付物。
|
|
70
77
|
|
|
78
|
+
### 图集合批
|
|
79
|
+
|
|
80
|
+
当前官方「游戏UI制作」模板按分类自动规划,每张最多 5×5;执行时沿用模板的槽位和续批,
|
|
81
|
+
不使用本节自定义流程建议覆盖其网格、顺序和绑定。
|
|
82
|
+
自定义流程由 Agent 先通看 Bbox 清单,按预计输出尺寸、长宽比和保留/移除要求合批。
|
|
83
|
+
语义分类用于素材命名和导出组织,不意味着每类必须单独调用一次模型;不固定沿用示例批次数。
|
|
84
|
+
|
|
85
|
+
- 小图标、物品等前景可合图;按钮、页签、槽框、标签等清空内部覆盖物的底板可合图。
|
|
86
|
+
小素材以约 5×5 的容量作为排版参考,不是必须填满、最低数量或硬上限;按清晰度调整。
|
|
87
|
+
- 角色、头像、场景插画等大素材可每图放两三个;面板与长条可按面积混排。数量不是上限,
|
|
88
|
+
保证每个主体完整、足够清晰且有透明间隔;不为单个背景零件另开一批,也不把大角色塞进小格。
|
|
89
|
+
- 整屏背景补绘与透明前景的输出要求不同,通常保留独立一张;普通文字只保留 Bbox/Label。
|
|
90
|
+
已要求的默认/按下态一起纳入容量预算,可同图分区,不机械增加一整批;同底板复用保留显式绑定。
|
|
91
|
+
- 由 AI 决定适合的行列或混排方式,但元素 ID、所需状态和数量以清单为准,不让模型猜测或省略。
|
|
92
|
+
不为凑满网格复制素材。输出后按实际完整边界切图,混排使用内容区域;图集区域到元素 ID
|
|
93
|
+
显式绑定,不能把图集位置当原稿 Bbox,也不能未经核对按生成前的预期格子直接导出。
|
|
94
|
+
- 先复核再补缺;只合并返修有问题的元素,不因一个漏项重生整套或自动反复付费。
|
|
95
|
+
合批不取消接口真实限制、原请求查询和付费确认。已完成的旧画布不为优化批次重跑或覆盖。
|
|
96
|
+
|
|
97
|
+
此策略用于 Agent 编排的新流程;旧模板已有的分类队列和网格不会自动改成合批执行。
|
|
98
|
+
仅本地拼接已有 PNG 可以改善展示,不能宣称减少了已经发生的模型调用。
|
|
99
|
+
|
|
71
100
|
复用时由 Agent 跟随以下步骤,继续使用现有画布操作,不新增自动工作流引擎:
|
|
72
101
|
|
|
73
102
|
1. 在新原稿上重新记录元素 ID、位置和状态。重复的奖励格保留不同实例 ID,可以共用素材;
|