diff --git a/CHANGELOG.md b/CHANGELOG.md index 01b1876..9781cad 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -16,6 +16,12 @@ > 3. 核验正式地址版本 → 之后才移动 `stable` / `stable-verified-<日期>` 标签、更新本 CHANGELOG、写 GitHub Release(`gh release create`)。 > 测试发现问题 → 改 → 再 `deploy:test`,正式环境不受影响。回滚点 `git reset --hard stable`。 +## v3.26.80(2026-11-26)插件节点图标与入口范围 + +- 底栏「插件节点」列表:每项使用插件自己的图标(相册=拼图、网页=地球、便利贴=标签、提示词模板=书、样式节点=调色板),不再统一拼图。 +- 图标解析改为四级:插件声明 variant.icon → 宿主映射 → 拼图兜底,且只接受宿主图标白名单里的名字。 +- 入口范围:支持插件声明 toolbar:"hide" 自隐藏;本轮先由宿主强制隐藏「提示词模板」「样式节点」(它们有专属入口,插件下次发版可自助声明)。 + ## v3.26.79(2026-11-26)设置页:每个插件配上对应图标 - 设置 → 左侧「插件」分区不再一律星标:相册=拼图、空白画布=面板、浏览器=地球、图库=图片、节点组=编组、 diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 86b15f9..01fe290 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -102,7 +102,7 @@ IWB_WRITE_BOUNDARY_SNAPSHOT=1 node tests/architecture-boundary-guard-test.js # | 守卫 | 位置 | 现在的上限 | |---|---|---| -| `app.js` 总行数 | `tests/source-text-ratchet-test.js` `MAX_APP_JS_LINES` | **9,173**(另守「占总源码 ≤ 40%」,见 `MAX_APP_JS_SHARE`) | +| `app.js` 总行数 | `tests/source-text-ratchet-test.js` `MAX_APP_JS_LINES` | **9,178**(另守「占总源码 ≤ 40%」,见 `MAX_APP_JS_SHARE`) | | `Workbench()` 行数 | 同上 `MAX_WORKBENCH_LINES` | **3,046** | | 单组件行数(不含 Workbench)| 同上 `MAX_APP_COMPONENT_LINES` | **423** | diff --git a/app.js b/app.js index 6298349..43d6f22 100644 --- a/app.js +++ b/app.js @@ -3385,8 +3385,14 @@ try { if (window.IWBMiniMapFit && typeof window.IWBMiniMapFit.install === 'funct // P2-11b-1a:节点类型注册表(NODE_TYPES)。内置类型从四表 seed;插件/动态类型运行时经 registerNodeType 注册。 // 四张字面表保持不动(守门第 6 组按字面文本校验),注册表在其上叠加;读取点逐步改走注册表(1b)。 // 插件图标(按插件 id 指定,统一视觉;manifest 自带 icon 时优先用 manifest 的) - const PLUGIN_ICONS = { 'image-annotate': 'pencil-ruler', 'xianyi-cutout': 'scissors', 'white-bg-800': 'vector-square', 'image-vectorize': 'pen-tool' } + const PLUGIN_ICONS = { album: 'puzzle', browser: 'globe', sticky: 'tag', gallery: 'ref', grouplib: 'group', promptlib: 'book', 'style-source': 'palette', 'white-bg-800': 'layout', 'image-annotate': 'edit', 'image-vectorize': 'tool', 'xianyi-cutout': 'scissors', 'batch-export': 'archive', 'blank-canvas': 'panel' } + // 插件图标解析(2026-11-26):插件声明 → 宿主映射 → 拼图兜底;只接受 ICONS 白名单里的名字。 const pluginIconOf = (id) => PLUGIN_ICONS[String(id || '')] || undefined + const PLUGIN_TOOLBAR_HIDE = { promptlib: true, 'style-source': true } + const resolvePluginIcon = (pluginId, declared) => { + const ok = (n) => (typeof n === 'string' && Object.prototype.hasOwnProperty.call(ICONS, n)) ? n : '' + return ok(declared) || ok(pluginIconOf(pluginId)) || 'puzzle' + } const NODE_TYPES = new Map() // 注册表版本号(2026-11-14):插件节点体(render)是**异步**注册的 —— 冷启动时画布先按存档把节点画出来, // 那一刻插件脚本还在下载,`NODE_TYPES.get(type).render` 是 null ⇒ 走通用兜底体(hint + textarea), @@ -9003,11 +9009,11 @@ items.push(el('button', { key: 'bgc', className: 'iwb-ctx-item', onClick: (e) => : { in: true, out: true } const height = Number.isFinite(variant.height) ? variant.height : 200 const color = (typeof variant.color === 'string' && variant.color) ? variant.color : '#969696' - const entry = { id: String(variant.id), title: String(variant.title), defaults: variant.defaults || {}, run: typeof variant.run === 'function' ? variant.run : null, pluginId: ctx.id, w: Number.isFinite(variant.width) ? variant.width : undefined } + const entry = { id: String(variant.id), title: String(variant.title), defaults: variant.defaults || {}, run: typeof variant.run === 'function' ? variant.run : null, pluginId: ctx.id, icon: resolvePluginIcon(ctx.id, variant.icon), toolbar: (variant.toolbar === 'hide' || PLUGIN_TOOLBAR_HIDE[ctx.id]) ? 'hide' : 'show', w: Number.isFinite(variant.width) ? variant.width : undefined } wPluginNodeVariants.push(entry) owned.push(entry) wPluginVariantMeta.set(entry.id, { id: entry.id, title: entry.title, defaults: entry.defaults, pluginId: ctx.id, ports: ports, height: height }) - registerNodeType({ id: pluginTypeId(ctx.id, entry.id), title: entry.title, defaults: entry.defaults, height: height, color: color, hasTitle: true, producer: false, ports: ports, icon: pluginIconOf(ctx.id) || entry.icon, run: entry.run, render: typeof variant.render === 'function' ? variant.render : null }) + registerNodeType({ id: pluginTypeId(ctx.id, entry.id), title: entry.title, defaults: entry.defaults, height: height, color: color, hasTitle: true, producer: false, ports: ports, icon: entry.icon, run: entry.run, render: typeof variant.render === 'function' ? variant.render : null }) try { const meta = ctx.storage && typeof ctx.storage.namespace === 'function' ? ctx.storage.namespace('__nodeTypes') : null if (meta) meta.set(entry.id, { id: entry.id, title: entry.title, defaults: entry.defaults, ports: ports, height: height }) diff --git a/docs/standards/architecture-current-state.md b/docs/standards/architecture-current-state.md index 940c306..4b20bf1 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 **9,172 行**(**双层预算**:绝对上限 9,173 / 占总源码 ≤ 40%,现 **29.9%**,2026-11-12 起;此前为单一上限 8,509、零余量);`Workbench()` = **3,040 行**(上限 **3,046**,余量 6;2026-11-16 把生成取消族 `cancelRunsFor`/`cancelRun`/`cancelTaskJobs` 与工作区列表写回族 `persistWs`/`duplicateWs` 搬进 `src/runtime-workbench-logic.js`(`createCancelActions` / `createWorkspaceListActions`),并删掉全仓零调用的 `runAll`,3090 → 2,998);大量逻辑已抽到 `src/*.js`(现 **111** 个模块 / 21,520 行,`sourceModules` 111 项;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 **9,178 行**(**双层预算**:绝对上限 9,178 / 占总源码 ≤ 40%,现 **29.9%**,2026-11-12 起;此前为单一上限 8,509、零余量);`Workbench()` = **3,040 行**(上限 **3,046**,余量 6;2026-11-16 把生成取消族 `cancelRunsFor`/`cancelRun`/`cancelTaskJobs` 与工作区列表写回族 `persistWs`/`duplicateWs` 搬进 `src/runtime-workbench-logic.js`(`createCancelActions` / `createWorkspaceListActions`),并删掉全仓零调用的 `runAll`,3090 → 2,998);大量逻辑已抽到 `src/*.js`(现 **111** 个模块 / 21,520 行,`sourceModules` 111 项;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/package.json b/package.json index 6b4da96..09380e2 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "image-workbench-web", "private": true, - "version": "3.26.79", + "version": "3.26.80", "description": "Browser-based node canvas image workbench", "scripts": { "build": "node scripts/build.js && node scripts/copy-plugins.js", diff --git a/src-tauri/Cargo.toml b/src-tauri/Cargo.toml index 5993e59..5673a15 100644 --- a/src-tauri/Cargo.toml +++ b/src-tauri/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "image-workbench" -version = "3.26.79" +version = "3.26.80" description = "无限画布 · 生图工作台桌面版" authors = ["malongan"] license = "" diff --git a/src-tauri/tauri.conf.json b/src-tauri/tauri.conf.json index 848f445..03716cd 100644 --- a/src-tauri/tauri.conf.json +++ b/src-tauri/tauri.conf.json @@ -1,7 +1,7 @@ { "$schema": "../node_modules/@tauri-apps/cli/config.schema.json", "productName": "image-workbench", - "version": "3.26.79", + "version": "3.26.80", "identifier": "com.malongan.imageworkbench", "build": { "frontendDist": "../dist", diff --git a/src/ui-canvas-view.js b/src/ui-canvas-view.js index d1cdb04..bb75418 100644 --- a/src/ui-canvas-view.js +++ b/src/ui-canvas-view.js @@ -118,7 +118,7 @@ function PluginAddButton(props) { document.addEventListener('keydown', onKey) return () => { document.removeEventListener('pointerdown', onDoc, true); document.removeEventListener('keydown', onKey) } }, [open]) - const list = Array.isArray(props.variants) ? props.variants : [] + const list = (Array.isArray(props.variants) ? props.variants : []).filter((pv) => pv && pv.toolbar !== 'hide') return el('span', { className: 'iwb-plugin-add-wrap', ref: boxRef }, el('button', { className: 'iwb-btn iwb-plugin-add' + (open ? ' iwb-btn-on' : ''), @@ -135,7 +135,7 @@ function PluginAddButton(props) { className: 'iwb-ctx-item', role: 'menuitem', onClick: () => { setOpen(false); if (typeof props.onPick === 'function') props.onPick(pv.id) }, - }, I('puzzle'), el('span', { className: 'iwb-btn-text' }, pv.title || pv.id))), + }, I(pv.icon || 'puzzle'), el('span', { className: 'iwb-btn-text' }, pv.title || pv.id))), ) : null, ) } diff --git a/tests/source-text-ratchet-test.js b/tests/source-text-ratchet-test.js index 6380bc5..065006d 100644 --- a/tests/source-text-ratchet-test.js +++ b/tests/source-text-ratchet-test.js @@ -165,9 +165,10 @@ const MAX_SRC_COMPONENT_LINES = 531 // · 本地文件模块惰性取用 wFileRefMod(避免跨文件引用脆弱,8 行) +8 // · 底栏「插件节点」下拉接线(回调 + 传参,2 行) +2 // · 底栏换拼图图标入口(puzzle 图标 + 组件接线,2 行) +2 +// · 插件图标解析 + toolbar 隐藏(2026-11-26,5 行) +5 // 通用件(pick/grant/stat/readDataUrl/readBlob/参数校验)全部在 src/image-file-ref.js // 与 src/plugin-api-images.js,app.js 只做装配。 -const MAX_APP_JS_LINES = 9173 +const MAX_APP_JS_LINES = 9178 const MAX_APP_JS_SHARE = 0.40 // ── 历史记账(供回溯,逐条保留)──────────────────────────────────────────────