diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 65ff48a..3b82823 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -105,8 +105,8 @@ IWB_WRITE_BOUNDARY_SNAPSHOT=1 node tests/architecture-boundary-guard-test.js # | 守卫 | 位置 | 现在的上限 | |---|---|---| -| `app.js` 总行数 | `tests/source-text-ratchet-test.js` `MAX_APP_JS_LINES` | **8,324**(另守「占总源码 ≤ 40%」,见 `MAX_APP_JS_SHARE`) | -| `Workbench()` 行数 | 同上 `MAX_WORKBENCH_LINES` | **2,178** | +| `app.js` 总行数 | `tests/source-text-ratchet-test.js` `MAX_APP_JS_LINES` | **8,325**(另守「占总源码 ≤ 40%」,见 `MAX_APP_JS_SHARE`) | +| `Workbench()` 行数 | 同上 `MAX_WORKBENCH_LINES` | **2,179** | | 单组件行数(不含 Workbench)| 同上 `MAX_APP_COMPONENT_LINES` | **423** | 三条都是**只减不增**。确需在 app.js 增长时,必须**同步上调上限并在 commit 里写理由**(等于显式记账,不会悄悄发生)。 diff --git a/app.js b/app.js index d75b596..a3af69b 100644 --- a/app.js +++ b/app.js @@ -6459,6 +6459,7 @@ const tbCenterSeed = (type, refs) => { const groupOf = (...a) => wbCmd().groupOf(...a) const makeGroup = (...a) => wbCmd().makeGroup(...a) const ungroup = (...a) => wbCmd().ungroup(...a) + const ungroupNode = (...a) => wbCmd().ungroupNode(...a) const joinGroupOf = (...a) => wbCmd().joinGroupOf(...a) const renameGroup = (...a) => wbCmd().renameGroup(...a) const duplicateGroup = (...a) => wbCmd().duplicateGroup(...a) @@ -7749,7 +7750,7 @@ const tbCenterSeed = (type, refs) => { })() : (() => { const sn = (refs.nodes || nodes).find((n) => n && n.id === sel[0]); if (!sn) return null; const title = (sn.data && sn.data.title) || (nodeTypeTitle(sn.type)); const metaLabel = floatbarMetaLabel(wRawCfg(), sn); const pl = floatbarPlace(sn.y, sn.y + hOf(sn), floatbarLift(hasNodeTitle(sn), nodeInGroup(sn), true), viewport); return el('div', { className: 'iwb-node-floatbar' + (pl.below ? ' iwb-node-floatbar-below' : ''), onPointerDown: (e) => e.stopPropagation(), style: { left: viewport.x + (sn.x + nodeWidth(sn) / 2) * viewport.scale, top: pl.top, '--iwb-fb-k': String(pl.k) } }, metaLabel ? el('span', { className: 'iwb-node-floatbar-title', title: '当前服务商 · Key 分组' }, metaLabel) : null, UiGenCfgModule && UiGenCfgModule.NodeBgPalette ? el(UiGenCfgModule.NodeBgPalette, { key: 'bgc', current: (sn.data && sn.data.bg) || '', onPreview: (bg) => previewNodeBg([sn.id], bg), onPreviewEnd: endNodeBgPreview, onPick: (bg) => updateNode(sn.id, { bg }) }) : null, - groupOf(sn.id) ? el('button', { 'aria-label': '解组', 'data-tip': '解组', onClick: (e) => { e.stopPropagation(); const g = groupOf(sn.id); if (g) ungroup(g.id) } }, I('ungroup')) : null, + groupOf(sn.id) ? el('button', { 'aria-label': '解组', 'data-tip': '移出节点组', onClick: (e) => { e.stopPropagation(); ungroupNode(sn.id) } }, I('ungroup')) : null, // 未编组且与某个分组相连 ⇒「并入分组」(多个相连组时取成员最多的) !groupOf(sn.id) && IWWorkbenchLogic.connectedGroupIdsOf(refs, sn.id).length ? el('button', { 'aria-label': '并入分组', 'data-tip': '并入分组', onClick: (e) => { e.stopPropagation(); joinGroupOf(sn.id) } }, I('group')) : null, sn.type === 'prompt' ? el('button', { 'aria-label': '放大编辑', 'data-tip': '放大编辑', onClick: (e) => { e.stopPropagation(); if (IWNodeBodies && IWNodeBodies.openPromptExpand) IWNodeBodies.openPromptExpand({ value: (sn.data && sn.data.text) || '', onCommit: (v) => updateNode(sn.id, { text: v }) }) } }, I('maximize')) : null, diff --git a/docs/standards/architecture-current-state.md b/docs/standards/architecture-current-state.md index c1b3cb4..d104f03 100644 --- a/docs/standards/architecture-current-state.md +++ b/docs/standards/architecture-current-state.md @@ -22,7 +22,7 @@ - 图片**新写入主通道 = IndexedDB Blob `{__blob}` / key `imgblob__`** (A) `app.js:2143`;`{__cache}`(Cache Storage)为兜底;\`ref_\`(`app.js` 内定义的 `IDB_REF_PREFIX = 'ref_'`)为 legacy 形态 (A)。 - 大图判定:`isBigDataUrl` = `data:` 且 `length > 3000` (A) `app.js:2018`;**画布保存保留阈值** `< 16384` 才原样保留 (A) `app.js:2182`。**两处阈值并存,含义不同**。 - 单测是**源码契约测试**:`tests/` 目录共 **493** 处源码文本钉点(`source.includes` / `source.indexOf` / `/re/.test(source)`),分布在 **20** 个文件(其中 `iwb-v32-web-test.js` 一个就占 **407**)→ **结构性重构会先打红测试**。**该数字已由 `tests/source-text-ratchet-test.js` 的「只减不增」棘轮守门**(2026-10-20 起守卫范围从 1 个文件扩到全目录:新增任何一处源码文本钉点都会打红)。**2026-11-12 复算**(`npm run audit:pins`,v3.24.76):二分 STRUCT **417** / NAME **76**;形态 **POS 403 / NEG 87 / COUNT 3**;难度 **易 62 / 中 316 / 难 115**。钉点减法第一批(v3.24.72)把 **537 → 505**:8 条探针钉点改为「门禁内 spec 是否真的读该计数器」、5 条改为运行时断言(生产态 `window` 上无探针)、10 条改为 DOM 断言(质量档位禁用 / 传输页无三模式按钮 / 模型项 title)、4 条改为运行时对象断言(健康检查两域、策略对象冻结)、其余 9 条有同文件 DOM 等价断言或仅剩 NEG。第二批(v3.24.76)把 **505 → 493**:94-5~7 三条「多标签释放语义」(10 处正则)换成 `tests/iwb-tabs-release.spec.js` 的 3 条真 e2e,剩 1 条「消费方契约」(断言该 spec 在门禁内且 spec 源码真的读两个探针);另 2 条 `wPurgeIntent.add` 钉点改为读 `src/workspace-purge.js`。**这一批一换就查出 3 个真缺陷**(objectURL 从未释放 / 彻底删除留孤儿标签 · session / 刷新后误回收打开标签的图)—— 见 CHANGELOG v3.24.76。 -- `app.js` = 单 IIFE **8,324 行**(**双层预算**:绝对上限 8,324 / 占总源码 ≤ 40%,现 **26.3%**,2026-11-12 起;此前为单一上限 8,509、零余量);`Workbench()` = **2,178 行**(上限 **2,178**,余量 0;2026-11-16 把生成取消族 `cancelRunsFor`/`cancelRun`/`cancelTaskJobs` 与工作区列表写回族 `persistWs`/`duplicateWs` 搬进 `src/runtime-workbench-logic.js`(`createCancelActions` / `createWorkspaceListActions`),并删掉全仓零调用的 `runAll`,3090 → 2,998);大量逻辑已抽到 `src/*.js`(现 **115** 个模块 / 23,307 行,`sourceModules` 115 项;v3.24.68 新增 `clipboard-graph.js`,v3.24.74 新增 `image-admit.js`,v3.24.75 新增 `image-dedupe.js`,v3.24.76 新增 `workspace-purge.js`,v3.24.79 新增 `generation-provider-ping.js`,v3.24.80 删除无调用的 `createWBFlushViewport` 17 行)。 +- `app.js` = 单 IIFE **8,325 行**(**双层预算**:绝对上限 8,325 / 占总源码 ≤ 40%,现 **26.3%**,2026-11-12 起;此前为单一上限 8,509、零余量);`Workbench()` = **2,179 行**(上限 **2,179**,余量 0;2026-11-16 把生成取消族 `cancelRunsFor`/`cancelRun`/`cancelTaskJobs` 与工作区列表写回族 `persistWs`/`duplicateWs` 搬进 `src/runtime-workbench-logic.js`(`createCancelActions` / `createWorkspaceListActions`),并删掉全仓零调用的 `runAll`,3090 → 2,998);大量逻辑已抽到 `src/*.js`(现 **115** 个模块 / 23,328 行,`sourceModules` 115 项;v3.24.68 新增 `clipboard-graph.js`,v3.24.74 新增 `image-admit.js`,v3.24.75 新增 `image-dedupe.js`,v3.24.76 新增 `workspace-purge.js`,v3.24.79 新增 `generation-provider-ping.js`,v3.24.80 删除无调用的 `createWBFlushViewport` 17 行)。 - 门禁:`npm run verify` = `verify:ci`(`build` → `node --check app.js` → `node --check dist/app.js` → `check-dist.js` → `lint`(ESLint 正确性规则,`src/` + `app.js`,P4-16a)→ `test:unit` → `test` → `test:facts`)+ `test:e2e` (A) `package.json`。 ## 2. 门禁与环境现状 diff --git a/scripts/gen-tokens.js b/scripts/gen-tokens.js index 4dd8f40..2341e2e 100644 --- a/scripts/gen-tokens.js +++ b/scripts/gen-tokens.js @@ -62,7 +62,7 @@ const varName = (k) => '--iwb-' + (ALIAS[k] || k.replace(/[A-Z]/g, (m) => '-' + /* 一个 token 在 CSS 里出现的顺序(= 阅读顺序:先表面、再描边、再文字、再品牌、再插件) */ const COLOR_ORDER = [ 'bg', 'canvasBg', 'layer', 'layer2', 'panel', 'nodeBg', 'field', - 'border', 'border2', + 'border', 'border2', 'selSurface', 'selRing', 'text', 'text2', 'textDim', 'canvasText', 'nodeText', 'nodeText2', 'tint', 'brand', 'brandText', 'onBrand', 'edge', 'edgeHot', 'gridDot', 'surface', 'hover', 'menuBg', @@ -350,7 +350,7 @@ function buildCss () { L.push(' /* —— 结构层(公式与 derive 一致,见文件头) —— */') L.push(...LIGHT_ONLY.map(decl)) L.push(' /* —— 描边 / 文字三级(目标对比度见 IWBThemeTokens.RATIO) —— */') - L.push(...colorDecls(LIGHT, ['border', 'border2', 'text', 'text2', 'textDim', 'canvasText', 'nodeText', 'nodeText2', 'tint'])) + L.push(...colorDecls(LIGHT, ['border', 'border2', 'selSurface', 'selRing', 'text', 'text2', 'textDim', 'canvasText', 'nodeText', 'nodeText2', 'tint'])) L.push(' /* —— 品牌色:填充与文字是两个角色(D7) —— */') L.push(...colorDecls(LIGHT, ['brand', 'brandText', 'onBrand', 'gridDot'])) L.push(' /* —— 插件表面四层(只提供取值,不做变量重指) —— */') @@ -371,7 +371,7 @@ function buildCss () { L.push(' /* 生图动效在暗色下必须「发亮」:--iwb-brand 是中性灰,直接用会糊在深底里 */') L.push(...DARK_ANIM.map(decl)) L.push(' /* —— 表面阶 —— */') - L.push(...colorDecls(DARK, ['bg', 'canvasBg', 'layer', 'layer2', 'panel', 'nodeBg', 'field', 'border', 'border2'])) + L.push(...colorDecls(DARK, ['bg', 'canvasBg', 'layer', 'layer2', 'panel', 'nodeBg', 'field', 'border', 'border2', 'selSurface', 'selRing'])) L.push(' /* —— 文字 / 品牌 —— */') L.push(...colorDecls(DARK, ['text', 'text2', 'textDim', 'canvasText', 'nodeText', 'nodeText2', 'tint', 'brand', 'brandText', 'onBrand', 'gridDot'])) L.push(' /* —— 插件表面 / 浮层 / 语义色 —— */') diff --git a/src/design-tokens.css b/src/design-tokens.css index 600ea00..aec4b76 100644 --- a/src/design-tokens.css +++ b/src/design-tokens.css @@ -48,6 +48,8 @@ /* —— 描边 / 文字三级(目标对比度见 IWBThemeTokens.RATIO) —— */ --iwb-border: #c2c2c2; --iwb-border2: #ababab; + --iwb-sel-surface: #eff0f1; + --iwb-sel-ring: #383838; --iwb-text: #404040; --iwb-text2: #5c5c5c; --iwb-text-dim: #767676; @@ -196,6 +198,8 @@ --iwb-field: #494949; --iwb-border: #333333; --iwb-border2: #4d4d4d; + --iwb-sel-surface: #313234; + --iwb-sel-ring: #e8e8e8; /* —— 文字 / 品牌 —— */ --iwb-text: #e3e3e3; --iwb-text2: #bababa; diff --git a/src/runtime-workbench-logic.js b/src/runtime-workbench-logic.js index bfb48c9..516616c 100644 --- a/src/runtime-workbench-logic.js +++ b/src/runtime-workbench-logic.js @@ -1888,6 +1888,20 @@ const nextGroups = refs.groups.filter((g) => g.id !== gid) commitCanvas(undefined, undefined, nextGroups) } + // v3.26.109:把**单个节点**移出所在组(气泡上的「解组」原先是整组解散)。 + // 组内剩 2 个及以上 ⇒ 只改成员;只剩 1 个 ⇒ 组没有意义,直接解散。 + const ungroupNode = (nid) => { + const g = refs.groups.find((x) => x && Array.isArray(x.memberIds) && x.memberIds.includes(nid)) + if (!g) return false + const rest = g.memberIds.filter((id) => id !== nid) + pushHistory() + const nextGroups = refs.groups.filter((x) => x.id !== g.id) + if (rest.length >= 2) nextGroups.push(Object.assign({}, g, { memberIds: rest })) // 保留组 id/名字/留白 + commitCanvas(undefined, undefined, nextGroups) + saveNow({ nodes: refs.nodes, edges: refs.edges, groups: nextGroups }) // 组变更立刻落盘 + setNotice({ type: 'ok', text: rest.length >= 2 ? '已把该节点移出节点组' : '节点组只剩 1 个节点,已自动解散' }) + return true + } const joinGroupOf = (nid) => joinGroupOfCore({ pushHistory, commitCanvas, refs, setNotice }, nid) // 逻辑在 src/runtime-workbench-logic.js // 重命名节点组(双击操作栏组名 → 就地编辑)。空名不生效,保持原名,避免出现无名组。 const renameGroup = (gid, name) => { @@ -2219,7 +2233,7 @@ setViewport(next) } - return { historyStore, HISTORY_IMG_REF_FIELDS, historyRefUsable, historyRefData, historyRawSnapshot, pushHistory, pushHistoryDebounced, restore, undo, redo, UNDO_KEYS, updateNode, clearGenResults, deleteNodes, deleteEdge, copyOffset, duplicateNodes, floatbarRefPaste, outResultUrls, stageClip, copyNodes, pasteGraph, readClipboardGraph, pasteCopiedNodes, clearClipboard, cutNodes, groupOf, makeGroup, ungroup, joinGroupOf, renameGroup, duplicateGroup, saveGroupSnapshot, saveSelectionAsGroup, instantiateGroup, loadSavedGroups, findSpot, placeAtDrop, addNode, addPluginNode, addRefFromUrl, refSrcOf, refreshOutputs, deleteOutputs, loadDemo, doFit } + return { historyStore, HISTORY_IMG_REF_FIELDS, historyRefUsable, historyRefData, historyRawSnapshot, pushHistory, pushHistoryDebounced, restore, undo, redo, UNDO_KEYS, updateNode, clearGenResults, deleteNodes, deleteEdge, copyOffset, duplicateNodes, floatbarRefPaste, outResultUrls, stageClip, copyNodes, pasteGraph, readClipboardGraph, pasteCopiedNodes, clearClipboard, cutNodes, groupOf, makeGroup, ungroup, ungroupNode, joinGroupOf, renameGroup, duplicateGroup, saveGroupSnapshot, saveSelectionAsGroup, instantiateGroup, loadSavedGroups, findSpot, placeAtDrop, addNode, addPluginNode, addRefFromUrl, refSrcOf, refreshOutputs, deleteOutputs, loadDemo, doFit } } // ── createWorkbenchSessions(2026-11-06 从 Workbench 外移;行为逐字保留)────────────── function createWorkbenchSessions(ctx) { diff --git a/src/theme-tokens.js b/src/theme-tokens.js index 07b7dad..63f3031 100644 --- a/src/theme-tokens.js +++ b/src/theme-tokens.js @@ -173,7 +173,10 @@ const brandText = clampAgainst(A, textSurfaces, RATIO.text2) const brandHover = mix(A, d ? '#ffffff' : '#000000', 0.14) const edgeHot = d ? mix(A, '#ffffff', 0.25) : A - const gridDot = mix(N, t, d ? 0.36 : 0.30) + const gridDot = mix(N, t, d ? 0.36 : 0.30) // v3.26.109:卡片/条目「选中」态(画布库卡片原先只有 border2 的弱描边,看不出选中)。 + // 方向:亮色把底色略压深并加一圈 brand 描边;暗色把底色略提亮 + 描边提亮,两端都能与未选中拉开。 + const selSurface = d ? mix(surface2, A, 0.16) : mix(surface1, A, 0.10) + const selRing = d ? mix(text, '#ffffff', 0.18) : mix(text, '#000000', 0.12) // 语义色:色相固定,明度随主题调整(暗色提亮一档,避免发闷) // 亮色状态色必须能**直接当文字色**(.iwb-status-ok / .iwb-ratio.ok / 插件状态标签都这么用)。 @@ -225,6 +228,8 @@ brandText, brandHover, edge: border2, + selSurface, + selRing, edgeHot, gridDot, // 亮色层 @@ -255,6 +260,8 @@ s('--iwb-plugin-hover', tokens.pluginHover) s('--iwb-border', tokens.border) s('--iwb-border2', tokens.border2) + s('--iwb-sel-surface', tokens.selSurface) + s('--iwb-sel-ring', tokens.selRing) s('--iwb-text', tokens.text) s('--iwb-text2', tokens.text2) s('--iwb-text-dim', tokens.textDim) diff --git a/style.css b/style.css index 3497312..71c2229 100644 --- a/style.css +++ b/style.css @@ -1243,7 +1243,7 @@ body .iwb-history-embedded .iwb-history-item.iwb-history-selected:hover img { .iwb-home-card-cat-empty { color: var(--iwb-text2); background: transparent; border-color: var(--iwb-border2); } .iwb-home-card-cat:hover { border-color: var(--iwb-border2); color: var(--iwb-text); } .iwb-home-card-actions button { display: inline-flex; align-items: center; justify-content: center; } -.iwb-home-card-selected { border-color: var(--iwb-border2); box-shadow: 0 0 0 1px var(--iwb-border2), 0 6px 18px rgba(0,0,0,.10); background: color-mix(in srgb, var(--iwb-panel) 72%, var(--iwb-layer) 28%); } +.iwb-home-card.iwb-home-card-selected { border-color: var(--iwb-sel-ring); box-shadow: 0 0 0 2px var(--iwb-sel-ring), 0 6px 18px rgba(0,0,0,.10); background: var(--iwb-sel-surface); } /* 画布库:卡片撑满、去右侧留白、卡片更紧凑 */ .iwb-home-card-top { padding-top: var(--iwb-space-16); padding-left: var(--iwb-space-20); padding-right: var(--iwb-space-20); } diff --git a/tests/source-text-ratchet-test.js b/tests/source-text-ratchet-test.js index 5690d65..04691ef 100644 --- a/tests/source-text-ratchet-test.js +++ b/tests/source-text-ratchet-test.js @@ -170,7 +170,7 @@ const MAX_SRC_COMPONENT_LINES = 531 // · 图标解析统一(右键菜单 + 设置页走同一解析器,2 行) +2 // 通用件(pick/grant/stat/readDataUrl/readBlob/参数校验)全部在 src/image-file-ref.js // 与 src/plugin-api-images.js,app.js 只做装配。 -const MAX_APP_JS_LINES = 8324 // +11(2026-11-27:停靠栏就绪后按新占位重新适应的监听;app.js 8315→8326) // +15(2026-11-26 复制/粘贴通道重写:DOM copy 事件装配、pasteCtx 增补实时选择/剪贴板读写、⌘V 改为主动粘贴;逻辑在 src/clipboard-graph.js 的 bindCopy 与 src/clipboard-paste.js 的 pasteFromKey) // +1(2026-11-26 相册外部路径重启复授权装配;逻辑在 src/image-file-ref.js) // +5(2026-11-26 标注覆盖保存:桌面端不再生成死 __cache(4 行)+ 插件 saveNodeImage 装配(1 行);事务逻辑在 src/runtime-workbench-logic.js) +const MAX_APP_JS_LINES = 8325 // +11(2026-11-27:停靠栏就绪后按新占位重新适应的监听;app.js 8315→8326) // +15(2026-11-26 复制/粘贴通道重写:DOM copy 事件装配、pasteCtx 增补实时选择/剪贴板读写、⌘V 改为主动粘贴;逻辑在 src/clipboard-graph.js 的 bindCopy 与 src/clipboard-paste.js 的 pasteFromKey) // +1(2026-11-26 相册外部路径重启复授权装配;逻辑在 src/image-file-ref.js) // +5(2026-11-26 标注覆盖保存:桌面端不再生成死 __cache(4 行)+ 插件 saveNodeImage 装配(1 行);事务逻辑在 src/runtime-workbench-logic.js) const MAX_APP_JS_SHARE = 0.40 // ── 历史记账(供回溯,逐条保留)────────────────────────────────────────────── @@ -213,7 +213,7 @@ const MAX_APP_JS_SHARE = 0.40 // 需要实时读 .iwb-world 变换 + 按同类型实测高度校正视觉中心;属装配层的 DOM 读取, // 放 src 会引入新的全局读取与边界快照改动,权衡后留在 app.js // +10(2026-11-01):背景色「悬停预览」的 DOM 补丁助手(纯 DOM,不写数据/不进撤销栈); // 属装配层最小的 DOM 操作,放 src 会引入新的全局读取与边界快照改动,权衡后留在 app.js -const MAX_WORKBENCH_LINES = 2178 // +11(2026-11-27:同上,Workbench 2169→2180) // 2026-11-26 复制/粘贴通道重写(+14:refs 新增粘贴时间戳/系统剪贴板可信标记、pasteCtx 增补 ids/clipboardOf/stageClip/readNativeText、bindCopy 装配) +const MAX_WORKBENCH_LINES = 2179 // +11(2026-11-27:同上,Workbench 2169→2180) // 2026-11-26 复制/粘贴通道重写(+14:refs 新增粘贴时间戳/系统剪贴板可信标记、pasteCtx 增补 ids/clipboardOf/stageClip/readNativeText、bindCopy 装配) // 2026-11-18 v3.25.21:模态层指针守卫(2 行) // 实测 3090 → 2998(省 92):① 生成取消族 cancelRunsFor/cancelRun/cancelTaskJobs // → src/runtime-workbench-logic.js 的 createCancelActions(−53);② 工作区列表写回族