Compare commits

..
76 Commits
Author SHA1 Message Date
qiqi 9e1b78f466 feat(diag): 手势期提升加面板开关,导出带 gestureLayer 状态
Verify (Gitea) / gate (build · unit · facts) (push) Failing after 49s
2026-12-01 12:11:12 +08:00
qiqi 093a1525c0 feat(diag): 导出 JSON 带上开关状态(合成层/毛玻璃)与 DOM 规模,便于 A/B 比对
Verify (Gitea) / gate (build · unit · facts) (push) Failing after 42s
2026-12-01 11:55:22 +08:00
qiqi b3cfea4715 feat: v3.26.158 诊断导出带上分进程内存拆解;mac 辅助函数补 cfg(unix)
Verify (Gitea) / gate (build · unit · facts) (push) Failing after 39s
2026-12-01 11:35:56 +08:00
qiqi 2f9590bcc7 feat: v3.26.157 诊断页 Windows 分进程内存拆解(工作集+私有提交);取消 30% LOD 档只留 15% 占位
Verify (Gitea) / gate (build · unit · facts) (push) Failing after 39s
2026-12-01 10:13:08 +08:00
qiqi e9581e52a6 perf: v3.26.156 平移期窗口化裁剪(不再全量挂载)+ 手势期关毛玻璃
Verify (Gitea) / gate (build · unit · facts) (push) Failing after 37s
2026-12-01 09:28:51 +08:00
qiqi c80dc7e50a perf: v3.26.155 手势期临时合成层 + 命中层 SVG 不再每帧变形(修拖动画面滞留/掉帧)
Verify (Gitea) / gate (build · unit · facts) (push) Failing after 39s
2026-12-01 08:53:07 +08:00
qiqi 4ce222a4bd docs(site): v3.26.154 Windows 包登记(5,623,889 B / 53be3b40…)
Verify (Gitea) / gate (build · unit · facts) (push) Failing after 39s
2026-12-01 07:57:56 +08:00
qiqi 3ab11b9db7 docs(site): v3.26.154 平移边线缓存
Verify (Gitea) / gate (build · unit · facts) (push) Failing after 33s
2026-12-01 07:42:38 +08:00
qiqi 142a13db36 chore: 移除网页版遗留(KV 插件发布脚本 / verify-release / 旧域名引用),插件纯函数抽到 scripts/plugin-integrity.mjs
Verify (Gitea) / gate (build · unit · facts) (push) Canceled after 4s
2026-12-01 07:42:33 +08:00
qiqi bf29d9f9d9 docs: 锚点对齐 v3.26.154+d874e02(publish 自动) 2026-12-01 07:42:32 +08:00
qiqi d874e028f4 perf: v3.26.154 平移移动边线缓存,减少每帧 Canvas 重画 2026-12-01 07:38:45 +08:00
qiqi 04745b0b31 test(perf): WebKit 平移 A/B 开关与结果(合成层/边线冻结/全量渲染) 2026-12-01 07:32:28 +08:00
qiqi 67443ef831 docs(site): 下载站插件列表跟进 album 1.2.5 / gallery 1.9.9 / promptlib 1.14.11 等版本
Verify (Gitea) / gate (build · unit · facts) (push) Failing after 39s
2026-12-01 07:03:18 +08:00
qiqi fbc6e55964 release(plugins): 同步 album 1.2.5 / gallery 1.9.9 / promptlib 1.14.11(hover 简化)+ 修正各插件 manifest 版本号
Verify (Gitea) / gate (build · unit · facts) (push) Failing after 34s
2026-12-01 07:01:36 +08:00
qiqi 9ec4b2c99c docs(site): v3.26.153 cache-migrate 修复
Verify (Gitea) / gate (build · unit · facts) (push) Failing after 35s
2026-12-01 06:53:29 +08:00
qiqi f3ed768a7c docs: 锚点对齐 v3.26.153+2640e15(publish 自动) 2026-12-01 06:53:23 +08:00
qiqi 2640e15fda fix: v3.26.153 cache-migrate 失败键不再重复触发画板加载 2026-12-01 06:50:01 +08:00
qiqi 20122def31 docs(site): v3.26.152 内存优化
Verify (Gitea) / gate (build · unit · facts) (push) Failing after 36s
2026-12-01 01:54:29 +08:00
qiqi 139d366938 docs: 锚点对齐 v3.26.152+9ef5218(publish 自动) 2026-12-01 01:54:23 +08:00
qiqi 9ef5218856 perf: v3.26.152 简化卡片 hover 效果 + 可见空闲回收 2026-12-01 01:51:10 +08:00
qiqi 359ad97329 chore(release): 3.26.151 Windows 条目并入 latest.json / releases.json / 下载页
Verify (Gitea) / gate (build · unit · facts) (push) Failing after 38s
2026-12-01 01:44:01 +08:00
qiqi 9a6ff4f4b7 docs(canvas-v3): v3.26.151 顶部层级修复记录 2026-12-01 01:28:34 +08:00
qiqi 2007b5b083 docs(site): v3.26.151 顶部层级修复
Verify (Gitea) / gate (build · unit · facts) (push) Failing after 36s
2026-12-01 01:28:28 +08:00
qiqi 08f9608cad docs: 锚点对齐 v3.26.151+f9ea5d5(publish 自动) 2026-12-01 01:28:22 +08:00
qiqi f9ea5d5cf0 fix(ui): 节点/浮层不再盖住顶部 tab 栏 2026-12-01 01:25:07 +08:00
qiqi 424b4e3b31 docs(site): v3.26.150 停止 Canvas V3
Verify (Gitea) / gate (build · unit · facts) (push) Failing after 38s
2026-12-01 01:16:58 +08:00
qiqi f11ad6ebc2 docs: 锚点对齐 v3.26.150+35e68c7(publish 自动) 2026-12-01 01:16:52 +08:00
qiqi 35e68c7508 release: v3.26.150 Canvas V3 异常兜底 + 7000 节点数据 2026-12-01 01:15:25 +08:00
qiqi bb6c8d9772 docs(canvas-v3): v3.26.149 发布记录 2026-12-01 01:04:59 +08:00
qiqi 86e19b5dd7 docs(site): v3.26.149 Canvas V3 LOD
Verify (Gitea) / gate (build · unit · facts) (push) Failing after 45s
2026-12-01 01:04:54 +08:00
qiqi fbc31110f9 docs: 锚点对齐 v3.26.149+6ce5f67(publish 自动) 2026-12-01 01:04:48 +08:00
qiqi 6ce5f67920 release: v3.26.149 Canvas V3 LOD + 1000 节点基线 2026-12-01 01:01:34 +08:00
qiqi 56eb70f794 docs(canvas-v3): v3.26.148 发布记录 2026-12-01 01:00:42 +08:00
qiqi b3197db596 docs(site): v3.26.148 Canvas layer
Verify (Gitea) / gate (build · unit · facts) (push) Failing after 46s
2026-12-01 01:00:37 +08:00
qiqi a45f114e51 docs: 锚点对齐 v3.26.148+a5d41a8(publish 自动) 2026-12-01 01:00:31 +08:00
qiqi a5d41a85fe release: v3.26.148 Canvas V3 layer 节点 2026-12-01 00:57:17 +08:00
qiqi e071923d1e test(canvas-v3): perf probe 支持 Canvas V3 开关并记录 60 节点基线 2026-12-01 00:54:42 +08:00
qiqi 253cba51a2 docs(canvas-v3): v3.26.147 发布记录 2026-12-01 00:53:56 +08:00
qiqi 7c65ef1272 docs(site): v3.26.147 Canvas V3 稳定化
Verify (Gitea) / gate (build · unit · facts) (push) Failing after 47s
2026-12-01 00:53:51 +08:00
qiqi 7f6da413b7 docs: 锚点对齐 v3.26.147+655d042(publish 自动) 2026-12-01 00:53:45 +08:00
qiqi 655d042439 release: v3.26.147 Canvas V3 稳定化(插件 fallback 默认关) 2026-12-01 00:50:39 +08:00
qiqi 0642b87ef8 docs(canvas-v3): v3.26.146 发布记录 2026-12-01 00:48:09 +08:00
qiqi 1717c2d7fb docs(site): v3.26.146 Canvas V3 P3
Verify (Gitea) / gate (build · unit · facts) (push) Failing after 54s
2026-12-01 00:48:03 +08:00
qiqi b5db6cce3f docs: 锚点对齐 v3.26.146+aced51f(publish 自动) 2026-12-01 00:47:58 +08:00
qiqi aced51f27c release: v3.26.146 Canvas V3 P3 fallback + 统计 2026-12-01 00:44:43 +08:00
qiqi ec304b49d7 feat(canvas-v3): P3 插件 fallback + canvas 绘制统计 2026-12-01 00:44:34 +08:00
qiqi b0ceb3353d feat(canvas-v3): P3 插件节点未选中走 canvas 占位 fallback 2026-12-01 00:42:02 +08:00
qiqi 0b1293892c docs(canvas-v3): v3.26.145 实验版发布记录 2026-12-01 00:39:17 +08:00
qiqi abce48c4d4 docs(site): v3.26.145 Canvas V3 实验
Verify (Gitea) / gate (build · unit · facts) (push) Failing after 1m12s
2026-12-01 00:39:10 +08:00
qiqi 8048afad5b docs: 锚点对齐 v3.26.145+370e72f(publish 自动) 2026-12-01 00:39:03 +08:00
qiqi 370e72f26f release: v3.26.145 Canvas V3 实验(默认关闭) 2026-12-01 00:31:38 +08:00
qiqi 2d0abb1b79 feat(canvas-v3): P2 out 结果缩略图 Canvas 化 2026-12-01 00:31:20 +08:00
qiqi db50733876 feat(canvas-v3): P2 第三批 gen Canvas 化 2026-12-01 00:28:02 +08:00
qiqi 6a79eb432f feat(canvas-v3): P2 第二批 combine/batch/relay Canvas 化 2026-12-01 00:25:43 +08:00
qiqi f9caea2cfd feat(canvas-v3): P2 第一批 ref/prompt/textout Canvas 化 2026-12-01 00:22:49 +08:00
qiqi 84d2c1d896 feat(canvas-v3): P1 单层 canvas 命中,移除每节点 proxy/端口 DOM 2026-12-01 00:19:15 +08:00
qiqi 1d40e74ead docs(canvas-v3): P0/P1 进度与门禁经验 2026-12-01 00:10:07 +08:00
qiqi 2ff86d0840 feat(canvas-v3): Phase 0 flag + ref node canvas 垂直切片(默认关闭) 2026-12-01 00:10:03 +08:00
qiqi d04dac64bc docs(site): v3.26.144 Canvas 边线
Verify (Gitea) / gate (build · unit · facts) (push) Failing after 3m19s
2026-11-30 23:23:51 +08:00
qiqi c015a4e897 docs: 锚点对齐 v3.26.144+c9e01db(publish 自动) 2026-11-30 23:23:43 +08:00
qiqi c9e01db607 perf: v3.26.144 Canvas 边线 + 平移全量渲染 2026-11-30 23:20:17 +08:00
qiqi acae6e789d docs(site): v3.26.143 perf v2
Verify (Gitea) / gate (build · unit · facts) (push) Failing after 2m34s
2026-11-30 22:46:42 +08:00
qiqi 3c37353aa8 docs: 锚点对齐 v3.26.143+98658e1(publish 自动) 2026-11-30 22:46:36 +08:00
qiqi 98658e1e56 perf: v3.26.143 world/grid 默认不常驻合成 + 视口网格 + 280 裁剪 2026-11-30 22:42:00 +08:00
qiqi a6470f1fc5 docs(site): v3.26.142 边线层屏幕坐标系
Verify (Gitea) / gate (build · unit · facts) (push) Failing after 1m46s
2026-11-30 22:17:27 +08:00
qiqi c0dd9531bd docs: 锚点对齐 v3.26.142+8d09c19(publish 自动) 2026-11-30 22:17:20 +08:00
qiqi 8d09c1989b perf: v3.26.142 边线层移到屏幕坐标系 2026-11-30 22:13:56 +08:00
qiqi 71240eecbc docs(site): v3.26.141 边线 SVG 视口化
Verify (Gitea) / gate (build · unit · facts) (push) Failing after 1m49s
2026-11-30 21:53:15 +08:00
qiqi 2cea136a39 docs: 锚点对齐 v3.26.141+bf0886e(publish 自动) 2026-11-30 21:53:06 +08:00
qiqi bf0886ee0e perf: v3.26.141 边线 SVG 视口化(graphics 1.6GB 主因) 2026-11-30 21:48:07 +08:00
qiqi 20a67d4c38 perf(render): v3.26.140 对齐 108(world/grid 常驻合成 + 裁剪边距 240/80)
Verify (Gitea) / gate (build · unit · facts) (push) Failing after 1m2s
2026-11-30 21:40:34 +08:00
qiqi b841a9103f revert+fix(render): v3.26.139 回退 138 的边线视口化并恢复合成层(流畅优先)
Verify (Gitea) / gate (build · unit · facts) (push) Failing after 1m23s
2026-11-30 21:37:20 +08:00
qiqi 95abac0730 Revert "perf(render): v3.26.138 边线 SVG 绘制面缩到视口大小(world 层不再被 10000² 撑大)"
This reverts commit d23d203a27.
2026-11-30 21:36:04 +08:00
qiqi d23d203a27 perf(render): v3.26.138 边线 SVG 绘制面缩到视口大小(world 层不再被 10000² 撑大)
Verify (Gitea) / gate (build · unit · facts) (push) Failing after 1m24s
2026-11-30 21:33:30 +08:00
qiqi 00fcbbbb9b perf(render): v3.26.137 去掉边线 SVG 常驻合成层 + 裁剪边距 480/240 + 毛玻璃开关
Verify (Gitea) / gate (build · unit · facts) (push) Failing after 1m14s
2026-11-30 21:28:17 +08:00
qiqi 907f3a0fa9 perf(render): v3.26.136 合成层常驻提升改可开关(默认关),诊断页可现场 A/B
Verify (Gitea) / gate (build · unit · facts) (push) Failing after 2m15s
2026-11-30 20:57:33 +08:00
69 changed files with 2290 additions and 1080 deletions

No files matched your search

+128
View File
@@ -16,6 +16,134 @@
> 3. 核验正式地址版本 → 之后才移动 `stable` / `stable-verified-<日期>` 标签、更新本 CHANGELOG、写 GitHub Release(`gh release create`)。
> 测试发现问题 → 改 → 再 `deploy:test`,正式环境不受影响。回滚点 `git reset --hard stable`。
## v3.26.154(2026-12-01)平移:移动已画好的边线 Canvas,不再每帧重画
- 平移期间用 CSS translate 移动 `.iwb-edge-canvas` 缓存;松手后清 transform 并重画一次。
- 目的:减少 WKWebView 每帧 clear + stroke + 纹理上传;`iwb_pan_edges_redraw=1` 可退回旧行为做 A/B。
- 保留合成层开启:WebKit A/B 显示关闭后 pan p95 约 60ms,开启约 22ms。
- 平移全量渲染保持现状:关闭它没有帧率收益。
## v3.26.153(2026-12-01)修 cache-migrate 全失败导致的重复画板加载
- `IWBImageCacheMigrate` 增加 `isFailed(key)`;已知不可迁移的 `{__cache}` 不再让 `wBoardNeedsHydrate` 反复为真。
- `wBoardNeedsHydrate` 跳过失败缓存键,避免每次同步/切画板重复进入 `wLoadBoard`、刷 `cache-migrate ok=0 fail=N`。
- 新增 `tests/image-cache-migrate-test.js` 覆盖失败键只读一次。
- 插件 CSS 优化已在插件源仓修改,但市场尚未发布(见版本状态)。
## v3.26.152(2026-12-01)内存优化:简化卡片效果 + 可见空闲回收
- 图库卡片去掉 hover 放大/投影,只保留描边反馈;相册 cell 同样去掉 hover scale/双层阴影。
- 提示词库卡片移除 `.iwb-plp-bg` 的常驻 `will-change: transform`,并去掉 hover 阴影/放大;减少每卡片合成层。
- 自动回收折中:应用不可见时回收;可见但连续 5 分钟无输入时做轻量回收(保留显示缩略图)。
- 插件版本:gallery 1.9.9 / promptlib 1.14.11 / album 1.2.5。
## v3.26.151(2026-12-01)修复节点/浮层盖住顶部 tab 栏
- `.iwb-world` 增加 `z-index: 1` 形成画布内部 stacking context;
- 节点及其内部高 z-index 浮层不再越过 `.iwb-tabstrip`(z36)/顶栏(z35);
- 画布外层面板(工具栏/停靠栏/弹窗)不受影响。
## v3.26.150(2026-12-01)停止 Canvas V3 实验,回到 DOM 渲染
- **Canvas V3 实验停止**:移除诊断开关与产品入口;新增 kill switch,旧用户即使 localStorage 里还留有 `iwb_canvas_v3=1`,升级后也强制回 DOM。
- 插件/内置节点恢复原有 DOM 渲染与交互;不再有 Canvas 占位卡。
- 保留 Canvas V3 期间验证过的独立优化:屏幕坐标系 Canvas 边线、网格视口大小、裁剪 280、平移全量渲染、后台回收、图库 30s 预热、性能探针。
- Canvas V3 代码保留为未启用研究代码,不再进入产品路径。
## v3.26.149(2026-12-01)Canvas V3:LOD + 1000 节点基线
- Canvas 节点绘制增加屏幕宽度 LOD(<8px 底板、<40px 跳内容);
- headless Chromium 1000 节点:pan p95 21.5ms → 17.5ms,DOM 1000 → 0;
- 60 节点仍锁 60fps;WKWebView 实机待测。
## v3.26.148(2026-12-01)Canvas V3:layer 节点 + 插件 fallback 保持关闭
- `layer` 接入 Canvas:未选中画层列表,选中恢复完整 NodeCard;
- 内置类型除 plugin 外全部 Canvas 化;
- 插件 fallback 仍默认关闭,插件节点保持真实 DOM。
## v3.26.147(2026-12-01)Canvas V3 稳定化:插件 fallback 默认关闭
- 插件 fallback 改为仅 `window.__IWB_CANVAS_V3_PLUGIN_FALLBACK__ === true` 时启用;默认 Canvas V3 只接管内置类型,插件节点保持真实 DOM,避免未选中插件变空白。
- Canvas 图片缓存上限 64,避免 ref/out 缩略图无限常驻。
- 诊断页保留「Canvas V3 绘制」统计。
## v3.26.146(2026-12-01)Canvas V3:P3 插件 fallback + 诊断绘制统计
- Canvas V3 支持插件节点 plugin:*:未选中时 Canvas 占位,选中恢复真实插件 NodeCard(fallback,不是插件 Canvas 渲染)。
- 诊断页新增「Canvas V3 绘制 Xms · 帧 N · 图 M」,用于桌面实机对比。
- 默认仍关闭;P3 只是移除未选中插件 DOM,插件内容需选中后查看。
- 详细进度:docs/plans/canvas-v3-progress.md。
## v3.26.145(2026-12-01)Canvas V3 实验:8 类节点 Canvas 静态层(默认关闭)
- 新增 `IWBCanvasV3` 特性开关(诊断页「Canvas V3(实验,需刷新)」,默认关闭)。
- 未选中的 ref / prompt / textout / combine / batch / relay / gen / out 节点由 Canvas 画卡片、文本、图片/结果缩略图;选中后恢复完整 NodeCard。
- 单层 canvas 命中:节点 body/端口由 `src/canvas-v3-hit.js` 做坐标命中,去掉每节点 proxy/端口 DOM。
- 实测:100 ref DOM 4165→866;60 混合节点 2580→826;每节点 DOM 0。
- 默认关闭,关闭时旧 DOM 路径零行为变化;详见 `docs/plans/canvas-v3-progress.md`。
- 注意:P2 仅内置 8 类;插件节点、layer、桌面实机 graphics/长帧仍待验证,暂不作为稳定默认。
## v3.26.144(2026-11-30)Canvas 边线 + 平移全量渲染
- **边线视觉改 Canvas 2D**(`src/ui-canvas-edges.js`):不再每帧重栅格化 SVG;`.iwb-edges` 只保留透明 hit path 负责选择/双击/悬停,视觉由视口 canvas 画。
- **平移期间全量渲染**:`nodeVisibleIn({ pan: true })` 让平移不再受“viewport state 不更新 ⇒ 裁剪窗口停在起点”影响,超过 280px 不会出现节点迟到/空白;松手恢复裁剪。
- **平移继续 rAF 合批**;拖动节点/弹线时命令式重画 canvas,不触发 React。
- 兼容旧 e2e:保留 `display:none` 的边线路径节点给选择器断言;DOM 中不参与绘制。
- 复盘:[docs/standards/performance-2026-11-30.md](docs/standards/performance-2026-11-30.md)。
## v3.26.143(2026-11-30)perf v2:默认不常驻合成 + 视口网格 + 280 裁剪 + 回收只后台
- **world/grid 默认不再提升合成层**:`.iwb-world` / `.iwb-grid` 的 `will-change` 改为显式 opt-in(诊断页勾选);默认 `data-layers="off"`。参考 infinite-canvas:靠视口裁剪 + memo,不靠整层常驻。
- **网格**从 200% 尺寸 + transform 改为视口大小 + background-position,避免为背景多分一层。
- **裁剪缓冲区 80 → 280**:带图节点不在平移边缘反复卸载/重解码。
- **平移写入 rAF 合批**:同一帧多个 pointermove 只写一次 world/grid/edge。
- **自动内存回收只在应用不可见时触发**,且保留显示缩略图;可见时不再每 2 分钟清缓存造成图片重载。手动回收不变。
- **图库预热 6s → 30s**,手势期间继续暂停。
- 复盘:[docs/standards/performance-2026-11-30.md](docs/standards/performance-2026-11-30.md)。
## v3.26.142(2026-11-30)边线层移到屏幕坐标系:graphics 再降 ~1GB
- 3.26.141 把边线 SVG 放进 `.iwb-world` 并用 `width = 视口/scale`;缩到 30% 时 CSS width 变成 8000 世界像素,WebKit 仍按 SVG 自身尺寸分配位图 ⇒ 诊断页 graphics 仍有 **1032MB**。
- 现在 SVG 移出 `.iwb-world`,宽度恒为屏幕 CSS 宽;世界坐标由内部 `<g class="iwb-edge-world" transform="translate(x,y) scale(s)">` 负责。缩放和平移不再改变 SVG 的位图尺寸。
- 合成层目标:2560×1303×4B×dpr² ≈ **53MB**(dpr2),而不是 1GB。
- 单测改为断言屏幕尺寸、`<g>` transform、viewBox 不含 10000;`applyViewportDom` 仍只改 DOM,不触发 React。
- 复盘更新:[docs/standards/performance-2026-11-30.md](docs/standards/performance-2026-11-30.md)。
## v3.26.141(2026-11-30)边线 SVG 视口化:graphics 1.6GB 主因
- **内存主因**:边线 `<svg width="10000" height="10000" translateZ(0)>` 在 dpr2 下分配约 **1.6GB** 合成位图,正好对应诊断页 WebContent graphics 1603MB;与 101 节点 / 18 张 DOM 图片无关。
- **修复**:SVG 只覆盖当前视口(viewBox/width/height/transform 由视口反算);手势期间用 transform 平移,仅缩放时改尺寸。合成层从 10000² 降到约 15MB(1200×788×dpr2)。
- `applyViewportDom` 抽到 `src/canvas-geometry.js`(app.js Workbench 不增长);新增视口边线层单测。
- 图库预热在平移/拖拽/缩放期间暂停,避免 320px 缩略图解码抢主线程。
- 复盘:[docs/standards/performance-2026-11-30.md](docs/standards/performance-2026-11-30.md)。
## v3.26.140(2026-11-30)对齐 108:恢复 world/grid 常驻合成层 + 裁剪边距回 240/80
- .iwb-world / .iwb-grid 的 will-change 被改成默认关 ⇒ 不再合成,每次平移整层重绘 ⇒ 卡顿;现恢复默认开(108 行为),开关语义改为「关掉合成层(省内存但会卡)」。
- 视口裁剪边距 480/240(137 引入)⇒ 每帧多挂载节点;现回到 108 的 240/80。
内存代价:graphics 回到 ~640MB 量级(108 同量级),换取 108 的流畅度。
## v3.26.139(2026-11-30)回退 138:边线恢复合成层(流畅优先)
138 实测 graphics 445 → 573MB 且整体卡顿:边线框每帧跟随视口移动 + overflow:hidden,导致 world 层每帧重绘。
137 去掉 translateZ 虽然省了 196MB,但平移时要把 10000² 的边线重绘进 world 层,也一样卡。
- 回退 138 的视口化改动,并把 edges SVG 的 translateZ(0) 恢复(回到 136 的合成策略);
- 保留 137 的视口裁剪边距 480/240(改善「节点从边缘突然冒出来」);
- 保留诊断页两个开关(合成层常驻提升 / 禁用毛玻璃),默认关。
下一步若要内存与流畅兼得:把边线改为 canvas 绘制(一次绘制、不占合成层),而不是 SVG 大画布。
## v3.26.137(2026-11-30)去掉边线 SVG 的常驻合成层 + 加大视口裁剪边距 + 毛玻璃开关
136 的 A/B:合成层常驻提升开=1629MB / 关=1242MB(+387MB)⇒ 默认关是对的;但关着 WebContent graphics 仍有 641MB。
- 边线 SVG 是 10000x10000 且带 translateZ(0),等于强制一个巨大常驻合成层 → 去掉 translateZ(0)(overflow:visible 下照常绘制)。
- 视口裁剪边距 240/80 → 480/240:修「节点从边缘突然冒出来」的卡顿观感(提前挂载,代价是少量常驻 DOM)。
- 诊断页新增「禁用毛玻璃」开关(现测所有 backdrop-filter),与「合成层常驻提升」一起用于二分 graphics 占用。
## v3.26.136(2026-11-30)合成层常驻提升改为可开关(默认关),用于定位 graphics 764MB
135 实测:合计 1489MB,其中 WebContent 1034MB、graphics 764MB;图片只剩几 MB,图库取图 120 次全 objectURL、失败 0。
推测是 .iwb-world 的 will-change: transform 把整个画布世界(101 节点包围盒)提升成常驻合成层,.iwb-grid(4 倍视口 + will-change)同理。
- 两处 will-change 从常驻改为受 :root[data-layers=on] 控制,默认关;
- 诊断页新增复选框「合成层常驻提升」:勾选立即生效并持久化(iwb_layers_on),用于现场 A/B 对比内存;
- 行为不变:transform 仍在,只是不再常驻提升;低端机拖拽掉帧时可以打开。
## v3.26.135(2026-11-30)修「多次加载还是有没有显示的」:并发写坏缩略图 + png 后缀漏查
134 实测:预热 164/164 完成、失败 0,但宫格里仍有一半卡显示「缩略图加载失败」。两个原因:
+4 -4
View File
@@ -11,7 +11,7 @@
- 使用说明与功能: [`README.md`](README.md)
- 发布流程: [`PUBLISHING.md`](PUBLISHING.md)
- 线上: https://iwb.maqiart.eu.org
- 下载站: https://download.maqiart.eu.org
---
@@ -41,7 +41,7 @@ build esbuild 打包到 dist/(单 dist/app.js = src/ 模块按序
node --check app.js 与 dist/app.js 语法
check-dist.js 产物体检
lint ESLint(src/ + app.js,正确性规则)
test:unit 136 个单测文件(jsdom 契约测试;2026-11-07 新增 sync-facts-guard(事实一致性)/ _helpers/source(统一源文本);2026-11-12 新增 provider-ping(测速 no-cors 兜底))
test:unit 139 个单测文件(jsdom 契约测试;2026-11-07 新增 sync-facts-guard(事实一致性)/ _helpers/source(统一源文本);2026-11-12 新增 provider-ping(测速 no-cors 兜底))
test relay-task-graph-fixture + iwb-v32-web-test
test:facts 事实基线守门(见 §5)
typecheck 渐进类型检查(tsc --noEmit;范围 = src/*.js,不含 app.js)
@@ -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,665**(另守「占总源码 ≤ 40%」,见 `MAX_APP_JS_SHARE`) |
| `Workbench()` 行数 | 同上 `MAX_WORKBENCH_LINES` | **2,231** |
| `app.js` 总行数 | `tests/source-text-ratchet-test.js` `MAX_APP_JS_LINES` | **8,743**(另守「占总源码 ≤ 40%」,见 `MAX_APP_JS_SHARE`) |
| `Workbench()` 行数 | 同上 `MAX_WORKBENCH_LINES` | **2,333** |
| 单组件行数(不含 Workbench)| 同上 `MAX_APP_COMPONENT_LINES` | **423** |
三条都是**只减不增**。确需在 app.js 增长时,必须**同步上调上限并在 commit 里写理由**(等于显式记账,不会悄悄发生)。
+5 -5
View File
@@ -66,12 +66,12 @@ npx serve dist
## 与独立版的关系
独立版 `image-workbench-app`(Node 服务,本地 data/ 存储)功能保持一致且仍受支持;本 Web 版面向免服务器 / 免运维的部署场景。
独立版 `image-workbench-app`(Node 服务,本地 data/ 存储)功能保持一致且仍受支持。
桌面版**不再提供网页版部署**:`functions/`、`wrangler.toml`、Cloudflare Pages 发布流程与 KV 插件通道均已移除;仓库里的 `npx serve dist` 只用于本地静态预览,不是发布形态。
## 生产版本确认
```bash
curl -fsSL https://iwb.maqiart.eu.org/version.json
```
安装包是唯一发布形态:下载站 <https://download.maqiart.eu.org> ,插件市场 <https://market.maqiart.eu.org> 。
正式域名:`https://iwb.maqiart.eu.org`。稳定回滚标签的**现行语义**(`vX.Y.Z` / `stable-vX.Y.Z` / 移动可变 `stable` / `stable-verified-YYYY-MM-DD`)见 [`docs/standards/architecture-current-state.md`](docs/standards/architecture-current-state.md);历史锚点示例:`stable-v3.1.0-stability3` 等。
客户端「检查更新」读 `https://download.maqiart.eu.org/updates/latest.json`(macOS)与 `latest-windows.json`(Windows);发布后按 `PUBLISHING.md` 回读 `latest.json` / `latest-windows.json` / 下载页三处一致。稳定回滚标签的**现行语义**(`vX.Y.Z` / `stable-vX.Y.Z` / 移动可变 `stable` / `stable-verified-YYYY-MM-DD`)见 [`docs/standards/architecture-current-state.md`](docs/standards/architecture-current-state.md)。
+183 -21
View File
@@ -96,6 +96,10 @@ try { if (window.IWBMiniMapFit && typeof window.IWBMiniMapFit.install === 'funct
if (!invoke) throw new Error('Tauri 不可用')
return await invoke('open_app_data_dir')
}
// v3.26.143:默认不提升 world/grid 合成层(参考 infinite-canvas);诊断页可显式 opt-in。
try { document.documentElement.dataset.layers = lsGet('iwb_layers_on', false) ? 'on' : 'off' } catch (e) { /* ignore */ }
try { const V3 = (typeof window !== 'undefined' && window.IWBCanvasV3); if (V3 && typeof V3.init === 'function') V3.init() } catch (e) { /* ignore */ }
try { if (lsGet('iwb_noblur_on', false)) document.documentElement.dataset.noblur = 'on' } catch (e) { /* ignore */ }
// 桌面端保存二进制:有导出目录直接写 Uint8Array(不弹框),没目录才弹「另存为」;刻意不经 base64,省一次全量编解码。
const wSaveBlobNative = async (blob, name, title) => {
const save = wTauri && wTauri.dialog && wTauri.dialog.save
@@ -2611,6 +2615,14 @@ try { if (window.IWBMiniMapFit && typeof window.IWBMiniMapFit.install === 'funct
if (typeof value === 'object') {
// C3 第2步:引用只要「已解析 / 解析失败 / 正在解析」就不再需要 hydrate —— 显示端 wResolveImg
// 会在渲染路径里驱动解析,不需要整块画板重读。
// 已知不可迁移的 {__cache}(网页版遗留、桌面读不到)不要再让整块画板反复 hydrate:
// 否则每次同步/切画板都会重新进入 wLoadBoard,日志刷 cache-migrate fail=7,还白白重复装载。
if (typeof value.__cache === 'string' && value.__cache) {
try {
const M = (typeof window !== 'undefined') ? window.IWBImageCacheMigrate : null
if (M && typeof M.isFailed === 'function' && M.isFailed(value.__cache)) return false
} catch (e) { /* ignore */ }
}
const rk = wImgRefKey(value)
if (rk) return !(wImgUrlByRef.has(rk) || wImgUrlFailed.has(rk) || wImgUrlPending.has(rk))
// __idb 迁移尝试过即不再需要(失败保留引用,避免反复重试把装载流程卡住)
@@ -3468,6 +3480,9 @@ try { if (window.IWBMiniMapFit && typeof window.IWBMiniMapFit.install === 'funct
: null
// 连线几何与合法性(纯函数收编到 src/canvas-geometry.js,P2-9):无依赖,直接用模块
const CanvasGeometry = (typeof window !== 'undefined' && window.IWBCanvasGeometry) || null
const IWBCanvasEdges = (typeof window !== 'undefined' && window.IWBCanvasEdges) || { EdgeCanvas: () => null }
const IWCanvasV3NodeLayer = (typeof window !== 'undefined' && window.IWBCanvasV3NodeLayer) || { CanvasNodeLayer: () => null }
const IWCanvasV3Hit = (typeof window !== 'undefined' && window.IWBCanvasV3Hit) || { hitRefNode: () => null }
// 撤销历史快照纯判定(收编到 src/canvas-history.js,P2-9):无依赖,直接用模块
const CanvasHistory = (typeof window !== 'undefined' && window.IWBCanvasHistory) || null
// 工作台列表纯变换(收编到 src/workspace-list.js,状态模型 epic · Pilot 3 片 A):无依赖,直接用模块
@@ -6010,6 +6025,33 @@ const tbCenterSeed = (type, refs) => {
const [editingGroupId, setEditingGroupId] = useState(null)
const [groupNameDraft, setGroupNameDraft] = useState('')
const [selEdge, setSelEdge] = useState(null)
const [hoverEdgeId, setHoverEdgeId] = useState(null)
const canvasV3On = !!(typeof window !== 'undefined' && window.IWBCanvasV3 && window.IWBCanvasV3.isEnabled && window.IWBCanvasV3.isEnabled())
// v3.26.156:平移期默认不再把全部节点挂上(那会把世界层撑成几十屏,WebKit 分块栅格化 ⇒ 残块/拖影)。
// iwb_pan_mount_all=1 显式退回旧行为;老开关 iwb_pan_all_off=1 语义不变(= 不全量挂载)。
const panMountAll = (() => {
try {
if (!!lsGet('iwb_pan_all_off', false)) return false
return !!lsGet('iwb_pan_mount_all', false)
} catch (e) { return false }
})()
// 默认平移时移动已画好的边线 canvas,不每帧重画;iwb_pan_edges_redraw=true 可退回每帧重画做 A/B。
const panEdgesFreeze = (() => { try { return !lsGet('iwb_pan_edges_redraw', false) } catch (e) { return true } })()
const canvasV3Types = (canvasV3On && window.IWBCanvasV3 && Array.isArray(window.IWBCanvasV3.TYPES)) ? window.IWBCanvasV3.TYPES : ['ref']
// 插件节点永远走真实 DOM:Canvas V3 只接管内置类型,避免插件内容/交互被占位卡替换。
const canvasV3TypeOf = (n) => {
const t = n && n.type
return !!t && canvasV3Types.indexOf(t) >= 0
}
const v3HitAtClient = (clientX, clientY) => {
if (!canvasV3On || !canvasEl.el || !refs.viewport) return null
const rect = canvasEl.el.getBoundingClientRect()
const z = uiZoom()
const vp = refs.viewport
const wx = (clientX / z - rect.left / z - vp.x) / vp.scale
const wy = (clientY / z - rect.top / z - vp.y) / vp.scale
return IWCanvasV3Hit.hitNode(refs.nodes, wx, wy, { isType: canvasV3TypeOf, widthOf: nodeWidth, heightOf: hOf, portRadiusWorld: 10 / vp.scale, wantPorts: true })
}
const [conn, setConn] = useState(null)
const [connTarget, setConnTarget] = useState(null)
const [ctxMenu, setCtxMenu] = useState(null)
@@ -6189,6 +6231,7 @@ const tbCenterSeed = (type, refs) => {
const [tick, setTick] = useState(0)
const [canvasSize, setCanvasSize] = useState({ w: 0, h: 0 })
const [canvasEl] = useState(() => ({ el: null }))
const [panCull, setPanCull] = React.useState(null)
const [groups, setGroups] = useState([])
const [savedGroups, setSavedGroups] = useState([])
const [nodeGroupGroups, setNodeGroupGroups] = useState([])
@@ -6985,8 +7028,11 @@ const tbCenterSeed = (type, refs) => {
try { freed.refs = await wRefActiveBoardNow() } catch (e) { /* ignore */ }
// ④ 图片字节缓存压到 0 + 缩略图缓存清空(都可由磁盘/IDB 重建)
try { const S = wImageBlobStore(); if (S && typeof S.trim === 'function') freed.blobs = S.trim(0) } catch (e) { /* ignore */ }
try { freed.thumbs = displayThumbs.size; displayThumbs.clear() } catch (e) { /* ignore */ }
try { outThumbCache.clear() } catch (e) { /* ignore */ }
// 自动回收保留显示缩略图(清了会立刻触发可见图片重载);手动回收才清。
if (!opts || !opts.keepThumbs) {
try { freed.thumbs = displayThumbs.size; displayThumbs.clear() } catch (e) { /* ignore */ }
try { outThumbCache.clear() } catch (e) { /* ignore */ }
}
try { if (typeof wThumbBump === 'function') wThumbBump() } catch (e) { /* ignore */ }
const after = heapMB()
try {
@@ -7335,19 +7381,49 @@ const tbCenterSeed = (type, refs) => {
// v3.25.68(借鉴 tldraw 的相机机制):手势期间只改 .iwb-world 的 transform,
// 不 setViewport ⇒ 不触发 React 重渲染 ⇒ 世界层不被标记为脏,WebKit 不必整层重栅格化。
// 松手/停止滚轮后再提交一次 state,保证与 React 渲染值一致。
// v3.26.155:手势标记 —— 停手 140ms 后撤销世界层合成层提升,并把命中层 SVG 对齐到当前视口。
// 目的:平移/缩放期间 world 只是一层位图在动,WebKit 不必每帧重栅格化整个世界层。
const wMarkGesture = () => {
const el = canvasEl && canvasEl.el
if (!el || !el.classList) return
try { if (lsGet('iwb_gesture_layer', true) === false) return } catch (e) { return }
el.classList.add('iwb-gesture')
if (refs.gestureTimer) clearTimeout(refs.gestureTimer)
refs.gestureTimer = setTimeout(() => {
refs.gestureTimer = 0
try { el.classList.remove('iwb-gesture') } catch (e) { /* ignore */ }
const vp = refs.viewportLive || refs.viewport || { x: 0, y: 0, scale: 1 }
try { CanvasGeometry.applyEdgeLayerDom(el, canvasSize, vp.x, vp.y, vp.scale) } catch (e2) { /* ignore */ }
}, 140)
}
const applyViewportDom = (x, y, scale) => {
const root = canvasEl.el
if (!root) return
const wl = root.querySelector('.iwb-world')
if (wl) wl.style.transform = 'translate(' + x + 'px, ' + y + 'px) scale(' + scale + ')'
const grid = root.querySelector('.iwb-grid')
const G = (typeof window !== 'undefined') ? window.IWBCanvasGrid : null
if (grid && G && typeof G.applyTo === 'function') {
const o = refs.gridOpts || { base: 22, dot: 1.4, color: 'rgba(120,128,140,0.55)', on: true }
if (!o.on) { grid.style.display = 'none' } else { grid.style.display = '' ; G.applyTo(grid, x, y, scale, o) }
} else if (grid) {
grid.style.backgroundSize = (28 * scale) + 'px ' + (28 * scale) + 'px'
grid.style.backgroundPosition = x + 'px ' + y + 'px'
try { wMarkGesture() } catch (e) { /* ignore */ }
CanvasGeometry.applyViewportDom(canvasEl.el, canvasSize, x, y, scale, refs.gridOpts, { skipEdgeLayer: true })
// 边线/节点 canvas:手势期间命令式重画,避免等 React
// 平移时只给已画好的边线 canvas 加 CSS translate,不每帧重画;松手后 React effect 清 transform 并重画。
let cv = null
try { cv = canvasEl.el && canvasEl.el.querySelector ? canvasEl.el.querySelector('.iwb-edge-canvas') : null } catch (e) { /* ignore */ }
if (refs.pan && panEdgesFreeze && cv) {
if (!refs.edgeCanvasBase || refs.edgeCanvasBase.pan !== refs.pan) {
refs.edgeCanvasBase = { x: refs.viewport.x, y: refs.viewport.y, pan: refs.pan }
}
cv.style.transform = 'translate(' + (x - refs.edgeCanvasBase.x) + 'px, ' + (y - refs.edgeCanvasBase.y) + 'px)'
} else {
try { if (cv) cv.style.transform = '' } catch (e) { /* ignore */ }
refs.edgeCanvasBase = null
try { if (typeof refs.edgeCanvasDraw === 'function') refs.edgeCanvasDraw(x, y, scale) } catch (e) { /* ignore */ }
}
try { if (typeof refs.nodeCanvasDraw === 'function') refs.nodeCanvasDraw(x, y, scale) } catch (e) { /* ignore */ }
// v3.26.156:平移窗口每跨 1/2 屏更新一次(此时才触发一次 React 渲染,代价可控)
if (!refs.pan || panMountAll) { refs.panCullAt = null } else {
const at = refs.panCullAt
const halfW = Math.max(320, (canvasSize.w || 800) * 0.5)
const halfH = Math.max(240, (canvasSize.h || 600) * 0.5)
if (!at || Math.abs(x - at.x) > halfW || Math.abs(y - at.y) > halfH) {
refs.panCullAt = { x: x, y: y }
try { setPanCull({ x: x, y: y, scale: scale }) } catch (e) { /* ignore */ }
}
}
}
@@ -7451,6 +7527,14 @@ const tbCenterSeed = (type, refs) => {
}, [])
const nodeOnSelect = React.useCallback((id) => { setSel([id]); setSelEdge(null) }, [])
const nodeOnPreview = React.useCallback((src, list, idx) => setPreview({ list: (list && list.length ? list : [src]), idx: idx || 0 }), [])
const outThumbsFor = React.useCallback((node) => {
try { return (IWNodeBodies && typeof IWNodeBodies.outThumbUrlsOf === 'function') ? IWNodeBodies.outThumbUrlsOf(node, nodes, edges) : [] } catch (e) { return [] }
}, [nodes, edges])
const previewRefNode = React.useCallback((node) => {
const raw = (node && node.data && (node.data.data || node.data.url)) || ''
if (!raw) return
wResolveImgAsync(raw).then((src) => { if (src) nodeOnPreview(src, [src], 0) }).catch(() => { /* ignore */ })
}, [nodeOnPreview])
// batch 节点来源缓存:替代每帧对每条边做 filter+some(拖动时复用)
const batchSourcesMap = React.useMemo(() => {
@@ -7469,8 +7553,14 @@ const tbCenterSeed = (type, refs) => {
// 视口裁剪:大画布只渲染可见节点/连线/组(jsdom 无实际画布尺寸时全渲染,兼容测试)
// 视口裁剪矩形(useMemo:拖动时 viewport 不变则复用,避免每帧算除法)
// 视口裁剪:宽边距 240(纯文本节点),带图节点 80 —— 见 CanvasGeometry.cullRectsOf 注释
const cullRects = React.useMemo(() => CanvasGeometry.cullRectsOf(canvasSize, viewport), [canvasSize.w, canvasSize.h, viewport.x, viewport.y, viewport.scale])
const nodeVisible = (n) => CanvasGeometry.nodeVisibleIn(n, cullRects, { drag: refs.drag, resize: refs.resize, sel: sel, widthOf: nodeWidth, heightOf: hOf })
// v3.26.156:平移期间裁剪窗口跟着位移走(每跨 1/2 屏更新一次),只挂载窗口附近的节点;
// 窗口额外放 0.7 屏边距,保证两次更新之间不会露白。
const navView = (refs.pan && panCull && !panMountAll) ? panCull : viewport
const cullRects = React.useMemo(() => {
const extra = (refs.pan && !panMountAll) ? (Math.max(canvasSize.w || 0, canvasSize.h || 0) / (navView.scale || 1)) * 0.7 : 0
return CanvasGeometry.cullRectsOf(canvasSize, navView, extra)
}, [canvasSize.w, canvasSize.h, navView.x, navView.y, navView.scale, panCull, panMountAll])
const nodeVisible = (n) => CanvasGeometry.nodeVisibleIn(n, cullRects, { drag: refs.drag, resize: refs.resize, sel: sel, pan: !!refs.pan, mountAll: panMountAll, widthOf: nodeWidth, heightOf: hOf })
const visibleIds = new Set(nodes.filter(nodeVisible).map((n) => n.id))
try { wSetScaleNow(viewport.scale) } catch (e) { /* ignore */ }
@@ -7505,6 +7595,7 @@ const tbCenterSeed = (type, refs) => {
}, [])
// v3.26.134:图库缩略图空闲预热(实现抽在 src/ui-workbench-hooks.js,这里只做装配)
IWWorkbenchHooks.useGalleryPrewarm({ len: outputs.length, list: () => outputs, refs, storage: () => wStoreMod(), state: wPrewarmState })
React.useEffect(() => { if (panCull) setPanCull(null) }, [viewport.x, viewport.y, viewport.scale])
const scaleText = Math.round(viewport.scale * 100) + '%'
const saveText = saveState === 'saving' ? '正在保存' : saveState === 'saved' ? '保存成功' : saveState === 'error' ? '保存失败' : ''
const connecting = !!conn
@@ -7523,10 +7614,13 @@ const tbCenterSeed = (type, refs) => {
focusNodeId,
selEdge,
edgeHover,
visual: false,
onHover: (id) => setHoverEdgeId(id || null),
onSelect: (id) => { setSelEdge(id); setSel([]) },
onDelete: (id) => deleteEdge(id),
}))
}
let tempD = ''
if (conn) {
const src = refs.nodes.find((n) => n.id === conn.from)
if (src) {
@@ -7542,7 +7636,7 @@ const tbCenterSeed = (type, refs) => {
y2 = inP.y
}
const dx = Math.max(40, (x2 - x1) / 2)
edgeEls.push(el('path', { key: 'tmp', className: 'iwb-edge iwb-edge-temp' + (connTarget ? (connTarget.valid ? ' iwb-edge-ok' : ' iwb-edge-bad') : ''), d: 'M ' + x1 + ' ' + y1 + ' C ' + (x1 + dx) + ' ' + y1 + ', ' + (x2 - dx) + ' ' + y2 + ', ' + x2 + ' ' + y2 }))
tempD = 'M ' + x1 + ' ' + y1 + ' C ' + (x1 + dx) + ' ' + y1 + ', ' + (x2 - dx) + ' ' + y2 + ', ' + x2 + ' ' + y2
}
}
@@ -7642,8 +7736,8 @@ const tbCenterSeed = (type, refs) => {
))
}
const nodeEls = IWBCanvasNodes.buildNodeEls({
CanvasGeometry, CanvasStore, EMPTY_OBJ, NODE_W, NodeCardMemo, addRefFromUrl, batchPortTop, batchSourcesMap, canConnect, cancelRun, config, connTarget,
defaultNodeBoxWidth, deleteNodes, duplicateNodes, edges, el, generationConcurrency, hOf, inPortWorld, isBatchSrc, lodViewport, nodeDerived, nodeOnMeasure, nodeOnPreview,
CanvasGeometry, CanvasStore, EMPTY_OBJ, NODE_W, NodeCardMemo, addRefFromUrl, batchPortTop, batchSourcesMap, canConnect, cancelRun, config, connTarget, canvasV3On, canvasV3Types, canvasV3TypeOf,
defaultNodeBoxWidth, deleteNodes, duplicateNodes, edges, el, generationConcurrency, hOf, inPortWorld, isBatchSrc, lodViewport, nodeDerived, nodeOnMeasure, nodeOnPreview, previewRefNode,
nodeOnSelect, nodeTypeH, nodeWidth, nodes, pushHistory, refs, runLLM, runLayerNode, runNode, runOutSources, saveNow, sel, selRef,
setConn, setConnTarget, setNotice, setSel, taskCountOf, thumbRev, typesRev, uiZoom, uid, updateNode, visibleIds, wLodEnabled, zoomToNode,
})
@@ -7968,10 +8062,24 @@ const tbCenterSeed = (type, refs) => {
const nd = el && el.closest ? el.closest('.iwb-node') : null
if (nd && nd.dataset && nd.dataset.nodeId) targetId = nd.dataset.nodeId
} catch (err) { /* ignore */ }
if (!targetId && canvasV3On) {
const hp = v3HitAtClient(e.clientX, e.clientY)
if (hp) targetId = hp.node.id
}
if (targetId && !sel.includes(targetId)) setSel([targetId])
setCtxMenu({ x: e.clientX, y: e.clientY, wx, wy, targetId })
},
onDoubleClick: (e) => {
// Canvas V3:未选中 ref 没有 DOM,双击命中后直接开预览。
if (canvasV3On) {
const hit = v3HitAtClient(e.clientX, e.clientY)
if (hit) {
e.preventDefault(); e.stopPropagation()
if (hit.node.type === 'ref') previewRefNode(hit.node)
else setSel([hit.node.id])
return
}
}
// 双击画布空白不再做任何事(原「双击空白 = 适应视图」已移除,改为底栏最右「适应视图」按钮 + Shift+F)。
// 「双击节点标题栏 = 居中放大该节点」由节点自身处理,这里只负责排除,不去抢节点/操作栏/面板上的双击。
const t0 = e.target
@@ -7990,6 +8098,7 @@ const tbCenterSeed = (type, refs) => {
refs.pan = { sx: e.clientX / uiZoom(), sy: e.clientY / uiZoom(), vx: viewport.x, vy: viewport.y }
setSel([])
setSelEdge(null)
setTick((t) => t + 1) // 让 nodeVisible(pan=true) 先挂载全部节点,避免平移中途空白
return
}
if (e.button !== 0) return
@@ -7998,11 +8107,43 @@ const tbCenterSeed = (type, refs) => {
if (typeof document !== 'undefined' && document.querySelector && document.querySelector('.iwb-modal-mask, .iwb-ctxmask')) return
const t0 = e.target
if (t0 && t0.closest && (t0.closest('.iwb-toolbar') || t0.closest('.iwb-lib') || t0.closest('.iwb-lib-embedded') || t0.closest('.iwb-drawer') || t0.closest('.iwb-history') || t0.closest('.iwb-history-embedded') || t0.closest('.iwb-rightrail') || t0.closest('.iwb-fullmask') || t0.closest('.iwb-fullpanel') || t0.closest('.iwb-minimap') || t0.closest('.iwb-navrail, .iwb-plugin-page') || t0.closest('.iwb-statusbar') || t0.closest('.iwb-hint-bottom') || t0.closest('.iwb-modal-mask') || t0.closest('.iwb-modal') || t0.closest('.iwb-cpick-pop'))) return
// Canvas V3:未选中 ref 没有 DOM,先在画布层做命中;选中/端口仍走现有逻辑。
if (canvasV3On && e.button === 0 && !refs.spaceDown && tool !== 'pan') {
const t1 = e.target
const overDomNode = !!(t1 && t1.closest && t1.closest('.iwb-node, .iwb-port, .iwb-resize, .iwb-group, .iwb-group-bar, .iwb-toolbar, .iwb-drawer, .iwb-lib, .iwb-rightrail, .iwb-navrail, .iwb-plugin-page, .iwb-statusbar, .iwb-minimap'))
if (!overDomNode) {
const hit = v3HitAtClient(e.clientX, e.clientY)
if (hit) {
e.preventDefault()
e.stopPropagation()
const nd = hit.node
if (hit.port === 'in') {
const inP = inPortWorld(nd)
refs.connFrom = { nodeId: nd.id, reverse: true, portPos: inP }
setConnTarget(null); setConn({ from: nd.id, x: inP.x, y: inP.y, reverse: true }); return
}
if (hit.port === 'out') {
refs.connFrom = { nodeId: nd.id, portPos: { x: nd.x + nodeWidth(nd), y: nd.y + hOf(nd) / 2 } }
setConnTarget(null); return
}
const curSel = selRef.current
const ids = (e.shiftKey || e.metaKey || e.ctrlKey)
? (curSel.includes(nd.id) ? curSel.filter((x) => x !== nd.id) : curSel.concat([nd.id]))
: (curSel.includes(nd.id) ? curSel.slice() : [nd.id])
const start = {}
for (const x of refs.nodes) if (ids.includes(x.id)) start[x.id] = { x: x.x, y: x.y }
refs.bodyDown = { id: nd.id, ids, start, sx: e.clientX / uiZoom(), sy: e.clientY / uiZoom(), active: false }
setSel(ids)
return
}
}
}
// 平移画布:按住空格(临时)或选中抓手工具(持续);默认 = 框选节点
if (refs.spaceDown || tool === 'pan') {
refs.pan = { sx: e.clientX / uiZoom(), sy: e.clientY / uiZoom(), vx: viewport.x, vy: viewport.y }
setSel([])
setSelEdge(null)
setTick((t) => t + 1) // 同上:平移期间先挂载全部节点
return
}
refs.box = { x0: e.clientX / uiZoom(), y0: e.clientY / uiZoom(), x1: e.clientX / uiZoom(), y1: e.clientY / uiZoom(), mode: e.altKey ? 'toggle' : (e.shiftKey ? 'add' : 'replace'), baseSel: selRef.current.slice() }
@@ -8068,11 +8209,26 @@ const tbCenterSeed = (type, refs) => {
// 2026-11-09:单节点气泡同样恢复删除(放最右,理由同多选气泡)。
el('button', { className: 'iwb-fb-del', 'aria-label': '删除', 'data-tip': '删除', onClick: (e) => { e.stopPropagation(); deleteNodes([sn.id]) } }, I('trash')),
) })()) : null),
// 边线视觉层:canvas 绘制,避免 SVG 在 WKWebView 每帧重栅格化。
el(IWBCanvasEdges.EdgeCanvas, {
edges, graph: edgeGraph, nodeMap: refs.nodeMap, measuredH: refs.measuredH, pathCache: refs.edgePathCache,
computeEdgePath, viewport, selEdge, focusNodeId, edgeHover, hoverEdgeId, tempD, connTarget,
onReady: (fn) => { refs.edgeCanvasDraw = fn },
}),
// Canvas V3:未选中的 ref 节点卡片/图片画在 canvas;DOM 只保留 hit proxy。
canvasV3On ? el(IWCanvasV3NodeLayer.CanvasNodeLayer, {
nodes: nodes.filter((n) => visibleIds.has(n.id)), viewport, sel, types: canvasV3Types, isType: canvasV3TypeOf,
widthOf: nodeWidth, heightOf: hOf, outThumbsFor,
imageFor: (node, raw) => { try { return wImgSrcForNode(raw, 320) || '' } catch (e) { return '' } },
onReady: (fn) => { refs.nodeCanvasDraw = fn },
}) : null,
// 透明 hit path:选择/双击/悬停仍走 SVG(canvas pointer-events:none)。
el('svg', Object.assign({ className: 'iwb-edges' }, CanvasGeometry.edgeLayerProps(canvasSize)),
el('g', { className: 'iwb-edge-world', transform: CanvasGeometry.edgeGroupTransform(viewport) }, edgeEls)),
el('div', {
className: 'iwb-world',
style: { transform: 'translate(' + viewport.x + 'px, ' + viewport.y + 'px) scale(' + viewport.scale + ')' },
},
el('svg', { className: 'iwb-edges', width: 10000, height: 10000, style: { overflow: 'visible', transform: 'translateZ(0)' } }, edgeEls),
groupEls,
nodeEls,
),
@@ -8134,9 +8290,10 @@ const tbCenterSeed = (type, refs) => {
onSaveNow: saveNow,
config,
diagStats: () => wDiagStats(refs.nodes, refs.workspaces),
diagExtras: () => ({ persist: storagePersist, swallowed: (RuntimeMetrics && RuntimeMetrics.snapshot) ? RuntimeMetrics.snapshot() : null, procRssMB: wProcRssMB, dom: (function () { try { return { els: document.getElementsByTagName('*').length, dock: document.querySelectorAll('.iwb-dock *').length, cards: document.querySelectorAll('.iwb-history-item').length } } catch (e) { return null } })() }), // v3.26.121 RSS + v3.26.127 DOM 规模 // 持久化 + 被忽略错误(2026-11-07)
diagExtras: () => ({ persist: storagePersist, swallowed: (RuntimeMetrics && RuntimeMetrics.snapshot) ? RuntimeMetrics.snapshot() : null, procRssMB: wProcRssMB, layers: !!(document && document.documentElement && document.documentElement.dataset.layers === 'on'), gestureLayer: (function () { try { return lsGet('iwb_gesture_layer', true) !== false } catch (e) { return true } })(), noblur: (document && document.documentElement && document.documentElement.dataset.noblur === 'on'), dom: (function () { try { return { els: document.getElementsByTagName('*').length, dock: document.querySelectorAll('.iwb-dock *').length, cards: document.querySelectorAll('.iwb-history-item').length } } catch (e) { return null } })() }), // v3.26.121 RSS + v3.26.127 DOM 规模 // 持久化 + 被忽略错误(2026-11-07)
...autoBackupKit, // autoBackup / autoBackupSave / autoBackupRestore / autoBackupRefresh
diagText: () => buildRuntimeDiagnosticsText([], (typeof window !== 'undefined' && window.__IWB_BUILD_META__) || {}),
diagDetail: () => wDiagDetail(),
onExportDiag: () => exportRuntimeDiagnostics(),
onClose: () => setSettingOpen(false),
onSaved: () => {
@@ -8146,6 +8303,11 @@ const tbCenterSeed = (type, refs) => {
// v3.26.117:手动「立即回收内存」(诊断页按钮)。只清可重建的缓存与可反推的引用形态。
onReclaimMemory: () => wReclaimMemoryNow('manual'),
onDiagDetail: () => wDiagDetail(),
// v3.26.136:合成层常驻提升开关(立即生效,改完看「进程实测」对比)
onToggleLayers: (on) => { try { document.documentElement.dataset.layers = on ? 'on' : 'off'; lsSet('iwb_layers_on', !!on) } catch (e) { /* ignore */ } },
// v3.26.158:手势期临时提升开关(平移/缩放时的 will-change),用于二分残影与 GPU 峰值
onToggleGesture: (on) => { try { lsSet('iwb_gesture_layer', !!on) } catch (e) { /* ignore */ } try { setTick((t) => t + 1) } catch (e2) { /* ignore */ } },
onToggleNoBlur: (on) => { try { if (on) document.documentElement.dataset.noblur = 'on'; else delete document.documentElement.dataset.noblur; lsSet('iwb_noblur_on', !!on) } catch (e) { /* ignore */ } },
}), document.body) : null,
helpOpen ? ReactDOM.createPortal(el('div', { className: 'iwb-modal-mask', onWheel: (e) => e.stopPropagation(), onPointerDown: (e) => { if (e.target === e.currentTarget) setHelpOpen(false) } },
el('div', { className: 'iwb-modal iwb-modal-sm iwb-help-modal' },
+98
View File
@@ -0,0 +1,98 @@
# Canvas V3 长期迁移计划(静态 Canvas + DOM overlay)
> 目标:把画布从“每节点完整 DOM”迁移到“静态内容 Canvas 绘制 + 只给选中/编辑节点挂 DOM”,降低 WKWebView 的布局/绘制/DOM 成本;保留旧 DOM 路径可回滚。
>
> 基线:v3.26.144(Canvas 边线、平移全量渲染、world 默认不合成)。
> 参考:Excalidraw(静态 canvas + overlay)、tldraw(DOM shape + 空间索引 + 手势冻结)。
## 状态
| 阶段 | 内容 | 状态 | 验收 |
|---|---|---|---|
| P0 | 特性开关、渲染接口、基线指标 | 已完成(2026-12-01) | 关闭开关时行为零变化 |
| P1 | 图片/ref 节点 Canvas 化 + 选中 DOM overlay | 垂直切片完成,待桌面验证(默认关闭) | 100 图节点每节点 DOM=0;应用外壳 ~866 |
| P2 | 内置节点 Canvas 化 | 内置类型全部已 Canvas(plugin 除外),待桌面验证 | DOM < 500;编辑/生成不回归 |
| P3 | 插件节点 fallback + browser/webview | 已取消 fallback;插件永远 DOM | 旧插件可用;不参与 Canvas V3 |
| P4 | 稳定化、A/B、默认开启、旧路径退场 | **已停止**(2026-12-01,用户裁定) | 保留 DOM;Canvas V3 仅研究代码 |
## 目标架构
```text
SceneStore(纯数据,沿用现有 nodes/edges/groups)
├─ CanvasRenderer(rAF、视口裁剪、分层)
│ ├─ grid(CSS,视口大小)
│ ├─ edges(已有 Canvas)
│ ├─ node frames / images / titles / group boxes
│ └─ selection / ports / progress
└─ DOM Overlay
├─ 选中节点编辑 UI(输入框/下拉/按钮/插件正文)
├─ 浮动工具条/菜单/面板
└─ 原生 webview / 复杂插件
```
## P0:基础设施(当前)
- [ ] 新增 `src/canvas-v3.js`:`isEnabled()` / `setEnabled()` / `init()` / `stats()`;
- [ ] localStorage 键 `iwb_canvas_v3`,根节点 `data-canvas-v3="on|off"`;
- [ ] build sourceModules 登记模块;
- [ ] app 启动 init(关闭时零行为变化);
- [ ] 诊断页开关 + `diagExtras.canvasV3`;
- [ ] 单测:开关读写、默认关闭、根属性同步;
- [ ] 基线记录:100 节点 DOM/内存/长帧;
- [ ] 关闭开关回归:e2e/构建通过。
## P1:图片/ref 节点 Canvas 化
- [ ] 新增 `CanvasNodeLayer`(canvas 位于 world 之下);
- [ ] 绘制 ref 卡片框、标题、缩略图、选中环、端口(先只画不交互);
- [ ] 未选中 ref 节点用 `NodeHitProxy` 替身:保留 pointerdown/drag/select,不渲染完整 body;
- [ ] 选中 ref 节点恢复完整 NodeCard(DOM overlay);
- [ ] 命中测试:节点矩形、输出端口;双击预览/右键菜单入口;
- [ ] 图片缓存:复用现有 display thumb,不新增解码路径;
- [ ] e2e:图片节点选择/拖动/替换/标注不回归;
- [ ] 性能:100 图节点 DOM/内存/长帧对比。
## P2:内置节点
- 先 prompt/textout/combine/batch/relay,再 gen/layer/out;
- 文本画到 canvas,编辑时 DOM textarea overlay;
- 生成任务条/进度环 canvas 绘制;
- 选中节点才挂完整编辑 UI;
- 撤销/持久化沿用 CanvasStore。
## P3:插件与原生 webview
- 插件 API(可选):`ctx.canvasRender.drawStatic/hitTest/openEditor`;
- 无能力插件:仅视口内实例 + 选中时完整 DOM;
- browser/原生 webview:始终 DOM/native,不参与 Canvas;
- 插件旧版本 fallback。
## P4:稳定化
- 视觉回归亮/暗色、选中态、组框;
- e2e:平移 1000px、缩放、拖拽、连线、文本编辑、生成;
- 性能门禁:100/500 节点;DOM、graphics、长帧;
- 默认开启,旧路径保留一个版本。
## 验收指标
- 100 节点 DOM 元素 < 500(当前 2487);
- WebContent graphics < 300MB;
- 平移/缩放无空白/节点迟到;
- 图片/文本/生成/插件主要链路不回归;
- 关闭开关即回旧版。
## 风险
- Canvas 文本度量与 DOM 不完全一致;
- 输入法/可访问性必须 DOM overlay;
- 插件 DOM 生态无法一次性迁移;
- 命中测试/端口优先级需重写;
- 双路径维护成本高。
## 执行原则
1. 默认关闭,按阶段 A/B,可回滚;
2. 不改数据格式;
3. 先图片节点垂直切片,验证收益后再扩大;
4. 每阶段在 `canvas-v3-progress.md` 记录数据与经验。
+278
View File
@@ -0,0 +1,278 @@
# Canvas V3 进度与经验
> 计划:[canvas-v3-long-term.md](./canvas-v3-long-term.md)
## 2026-12-01 · P0 完成
已完成:
- `src/canvas-v3.js`:`isEnabled / setEnabled / init / stats`,localStorage 键 `iwb_canvas_v3`,根属性 `data-canvas-v3`;
- `scripts/build.js` 登记,app 启动 `init()`(默认 off,零行为变化);
- 诊断页新增「Canvas V3(实验,需刷新)」开关;
- 单测 `tests/canvas-v3-test.js` 接入 `test:unit`;
- 事实/边界/源码棘轮已同步。
基线(Web 测试环境,100 节点数据但视口内实际挂载 20 个):
- DOM 元素 1170;
- `data-node-id` 20;
- `data-canvas-v3="off"`,`IWBCanvasV3.isEnabled() === false`。
经验:
- 当前 DOM 基线比之前诊断的 2487 低,是因为视口裁剪只挂载可见节点;做 100 节点性能对比时必须固定视口/缩放,否则数据不可比。
- Phase 0 不改变任何渲染路径,先保住旧路径可回滚。
## 2026-12-01 · P1 垂直切片(实验,默认关闭)
已实现:
- `src/canvas-v3-node-layer.js`:viewport canvas 画未选中 ref 节点的卡片框、标题、图片区;
- `src/ui-canvas-nodes.js`:Canvas V3 开启时,未选中 ref 节点只渲染透明 `.iwb-node-hit-proxy`;
- 选中后立即恢复完整 `NodeCard`(DOM overlay);
- 拖动走现有 `refs.bodyDown` 全局指针逻辑;平移/拖节点命令式重画 canvas;
- 诊断页开关「Canvas V3(实验,需刷新)」。
实测(Web 测试环境,2 ref + 1 prompt):
- `.iwb-node-hit-proxy` 2 个,完整 `.iwb-node` 1 个;
- DOM 元素 307;
- canvas 有绘制像素(31142);
- 点击 proxy 后:proxy 2→1、NodeCard 1→2、selected 1,说明选中恢复 DOM overlay 正常。
已知限制(P1 继续要补):
- 未选中 ref 没有端口/右键菜单/双击预览入口(先选中后恢复 NodeCard 才有);
- 绘制样式是近似卡片,不是 NodeCard 像素级;
- 图片只走 `wImgSrcForNode(raw, 320)`,跨域图可能不画;
- 还没做 100 图节点的 DOM/内存/长帧对比(20 图节点已量,见下)。
经验:
- “Canvas 画静态 + 选中恢复 NodeCard”路线可行;最小切片只需一个 hit proxy,不必先重写命中测试/全部交互。
- 下一步优先补端口/右键/双击与 100 节点压测,而不是继续扩节点类型。
### P1 20 图节点实测(Web,同一批 20 个 ref)
| 模式 | DOM 元素 | 完整 NodeCard | hit proxy |
|---|---:|---:|---:|
| Canvas V3 off | 1687 | 20 | 0 |
| Canvas V3 on | 802 | 0(未选中) | 20 |
- 降幅 **52%**(1687 → 802);
- canvas 正常绘制 20 张图片(pixels 2592605,截图见 `/Users/qiqi/.playwright-mcp/canvas-v3-20.png`);
- 选中一个 proxy 后:proxy 20→19、NodeCard 0→1、selected 1,说明 DOM overlay 正常。
结论:垂直切片方向成立,但 20 图节点还不能代表 WKWebView 的最终收益;下一步要在桌面端实机看 graphics/长帧,并补端口/右键/双击预览。
### P1 100 图节点实测(Web,固定 viewport scale=0.3,所有 100 个可见)
| 模式 | DOM 元素 | 完整 NodeCard | hit proxy | 端口 DOM |
|---|---:|---:|---:|---:|
| Canvas V3 off | 4165 | 100 | 0 | — |
| Canvas V3 on | 1166 | 0 | 100 | 200 |
- DOM 降幅 **72%**(4165 → 1166);
- 还达不到 P1 目标 <500:100 个 hit proxy + 200 个端口 DOM 是主要剩余成本;
- 结论:下一步应把 **端口命中/选择命中** 移到 canvas 单层 hit test,而不是给每个节点保留 DOM 端口/代理。
### P1 交互补齐
- 未选中 ref 现在有输入/输出端口 DOM(连接仍走现有 refs.connFrom);
- 右键 hit proxy 会命中 `.iwb-node`,节点右键菜单可用;
- 双击 hit proxy 打开图片预览(`.iwb-imgpreview`);
- 选中后恢复完整 NodeCard。
限制:上一版端口/代理仍是每节点 DOM,所以 100 图节点 DOM 1166;已由下方单层 canvas 命中解决。
### P1 单层 canvas 命中(2026-12-01 后续)
去掉每节点 hit proxy 与 DOM 端口,改为:
- `src/canvas-v3-hit.js`:ref 节点 body/输入口/输出口的世界坐标命中;
- 画布 pointerdown/doubleclick/contextmenu 统一走 `v3HitAtClient`;
- 端口命中后沿用现有 `refs.connFrom` / `setConn`;
- 选中/拖动后恢复 NodeCard,交互与之前一致。
实测 100 个可见 ref(scale≈0.73):
| 模式 | DOM | 完整 NodeCard | hit proxy | 端口 DOM |
|---|---:|---:|---:|---:|
| off | 4165 | 100 | 0 | — |
| on(单层命中) | **866** | 0 | 0 | 0 |
- 比上一版 1166 再降 300(移除 100 个 proxy + 200 个端口 DOM);
- 点击卡片可选中并恢复 NodeCard;右键菜单、双击预览、拖动均已实测通过;
- 866 主要是应用外壳/停靠栏基础 DOM,不是 ref 节点;100 ref 本身 0 DOM。
新增单测:`tests/canvas-v3-hit-test.js`。
## 2026-12-01 · P2 第一批:prompt / textout
扩展到 `ref + prompt + textout`:
- `IWBCanvasV3.TYPES` 定义可 Canvas 化类型;
- `canvas-v3-hit.js` 增加通用 `hitNode`(isType 过滤;端口暂只对 ref);
- `canvas-v3-node-layer.js` 画 prompt/textout 卡片与截断文本;
- `ui-canvas-nodes.js` 对未选中的这三类完全不挂 NodeCard;
- 选中后恢复 NodeCard 编辑,双击 ref 仍开预览。
60 个混合节点(30 ref + 30 prompt/textout)实测:
| 模式 | DOM | 完整 NodeCard |
|---|---:|---:|
| off | 2580 | 54 个可见 |
| on | 826 | 0(未选中) |
文本是 Canvas 截断绘制,不是 Markdown/DOM 排版;只在选中后回到真实 NodeCard 编辑。
点击验证:prompt 卡片中心(n25)点击后 selected=1、NodeCard=1、DOM 826→873,说明文本节点的 canvas 命中也能恢复 DOM 编辑。
### P2 第二批:combine / batch / relay
- `IWBCanvasV3.TYPES` 扩到 `ref,prompt,textout,combine,batch,relay`;
- 这些节点未选中时全部由 canvas 画卡片/标题/截断文本,DOM 0;
- 选中后恢复 NodeCard;
- 60 个混合节点(6 类各 10 个):off DOM 2580 → on 826,完整 NodeCard 0;
- `gen` / `out` 均已加入 Canvas 类型。
### P2 第四批:out
- `out` 加入 `TYPES`;未选中 out 用 canvas 画结果缩略图网格(最多 4 张),无结果时提示「选中查看结果」;
- 新增 `IWBNodeBodies.outThumbUrlsOf(node,nodes,edges)`:复用 outGroupsOf 的分组/排序;
- Canvas V3 可能先于 NodeCard 渲染,NodeBodies 尚未 inject —— helper 对 `isImageProducer`/`cachedGenerationTasks` 做本职能兜底;
- 选中后恢复完整 NodeCard,下载/预览/分组仍走原逻辑。
实测 gen+out(out 接 1 张结果):DOM 771、NodeCard 0、canvas 正常绘制;直接调用 outThumbUrlsOf 返回结果 URL。
## 2026-12-01 · v3.26.145 发布(Canvas V3 实验,默认关闭)
- 已构建并发布 macOS arm64/x64:3.26.145;
- 诊断页「Canvas V3(实验,需刷新)」可开启;默认关闭;
- 已 Canvas 化:ref / prompt / textout / combine / batch / relay / gen / out;
- 插件、layer 及部分编辑态仍走 NodeCard;
- 桌面端实机 graphics/长帧、P3 插件 fallback 尚未验证。
发布地址:https://download.maqiart.eu.org/updates/latest.json
## 2026-12-01 · P3 插件 fallback(原型)
- Canvas V3 的 isType 谓词支持 `plugin` / `plugin:*`;
- 未选中插件节点由 canvas 画通用卡片(标题/占位),不挂插件 DOM;
- 选中后恢复插件 NodeCard(插件真实 UI 只在选中时挂载);
- 这是 fallback,不是插件 Canvas 渲染:插件内部仍无法直接参与 canvas,只是把未选中实例从 DOM 移除。
### P3 fallback + 诊断统计
- 插件节点未选中时走 Canvas 占位,选中恢复插件 NodeCard;
- `IWBCanvasV3.stats()` 返回 DOM、最近一次节点 canvas 绘制耗时、帧数、图片缓存数;
- 诊断页显示「Canvas V3 绘制 Xms · 帧 N · 图 M」,用于桌面实机 A/B。
## 2026-12-01 · v3.26.146 发布
- macOS arm64/x64 已发布 3.26.146;
- Canvas V3 仍默认关闭;新增插件 fallback 与诊断「Canvas V3 绘制」统计;
- 线上 latest:https://download.maqiart.eu.org/updates/latest.json
## 2026-12-01 · v3.26.151 顶部层级修复
- 用户反馈节点盖住顶部 tab 栏;
- `.iwb-world` 增加 `z-index:1`,使节点内部高 z-index 浮层被限制在画布内部 stacking context;
- tabstrip(z36)/顶栏(z35) 在其上;工具栏/停靠栏/弹窗不受影响;
- 已发布 3.26.151。
## 2026-12-01 · v3.26.149 发布
- Canvas V3 节点绘制 LOD(<8px 底板、<40px 跳内容);
- 1000 节点 Chromium:DOM 1000→0,pan p95 21.5→17.5ms;
- macOS arm64/x64 已发布 3.26.149,Canvas V3 默认关闭。
## 2026-12-01 · v3.26.148 发布
- layer 节点接入 Canvas;
- 内置类型除 plugin 外全部 Canvas 化;
- 插件 fallback 仍默认关闭;
- macOS arm64/x64 已发布 3.26.148,Canvas V3 默认关闭。
### P4 浏览器基线探针(2026-12-01)
在 `tests/_perf-baseline.spec.js` 增加 `IWB_CANVAS_V3` 开关,60 节点 light probe(headless Chromium,非 WKWebView):
| 模式 | DOM 节点 | pan p50 | pan p95 | max | longtasks |
|---|---:|---:|---:|---:|---:|
| Canvas V3 off | 60 | 16.7ms | 17.7ms | 18.0ms | 0 |
| Canvas V3 on | 0 | 16.7ms | 17.3ms | 18.6ms | 0 |
结论:Chromium 下两者都锁 60fps,Canvas V3 的收益主要体现为 DOM 数(60→0);WKWebView 需桌面实机验证。
运行:`IWB_CANVAS_V3=1 IWB_PROBE_NODES=60 IWB_PROBE_LIGHT=1 npx playwright test tests/_perf-baseline.spec.js`。
### P4 LOD + 1000 节点基线(2026-12-01)
Canvas 节点绘制增加屏幕宽度 LOD:
- 屏幕宽度 <8px:只画底板;
- <40px:跳过标题/文本/图片;
- 正常缩放:完整体。
1000 节点 light probe(headless Chromium):
| 模式 | DOM 节点 | pan p50 | pan p95 | max |
|---|---:|---:|---:|---:|
| off | 1000 | 16.7ms | 21.5ms | 26.0ms |
| on + LOD | 0 | 16.6ms | 17.5ms | 17.6ms |
结论:Chromium 下 1000 节点时 Canvas V3 的 p95 从 21.5ms 降到 17.5ms;WKWebView 仍需实机。
### P4 7000 节点压力探针(2026-12-01)
headless Chromium,7000 节点,light probe:
| 模式 | DOM 节点 | pan p50 | pan p95 | max | longtasks |
|---|---:|---:|---:|---:|---:|
| off | 7000 | 34.0ms | 139.5ms | 400.5ms | 27 / 2136ms |
| on + LOD | 0 | 16.5ms | 18.8ms | 20.7ms | 0 |
结论:7000 节点时 Canvas V3 差距非常明显;这也是当前浏览器端最强的收益证据。
WKWebView 仍需桌面实机复测。
## 2026-12-01 · v3.26.147 发布
- 插件 fallback 默认关闭;后续已彻底移除(插件节点永远走真实 DOM)。
## 2026-12-01 · 插件显示修复
- 用户反馈 Canvas V3 开启后插件显示异常;
- 已移除插件 fallback 代码:插件节点永远走真实 DOM,Canvas V3 只接管内置类型;
- 不再受 __IWB_CANVAS_V3_PLUGIN_FALLBACK__ 影响。
## 2026-12-01 · 方向停止(用户裁定)
- Canvas V3 开启后,gen/out/combine/plugin 等节点只剩卡片壳,编辑/插件内容不可用;
- 继续需要完整节点编辑 overlay + 插件 Canvas API,收益不足以覆盖风险;
- 决定:停止 Canvas V3,回到 DOM 渲染;
- 处理:移除诊断开关与产品入口,新增 kill switch(旧 localStorage 值也强制关闭);
- 保留独立优化:Canvas 边线、视口网格、280 裁剪、平移全量渲染、后台回收、30s 预热、性能探针;
- Canvas V3 代码保留为未启用研究代码,后续可删除。
### P2 第五批:layer
- `layer` 加入 Canvas 类型;未选中画层列表(最多 8 层),选中恢复完整 NodeCard;
- 现在内置类型中除 plugin 外已全部 Canvas 化:ref/prompt/textout/combine/batch/relay/gen/out/layer;
- layer 的图层缩略图/蒙版编辑仍只在选中后的 NodeCard 中。
- Canvas 图片缓存上限 64;
- macOS arm64/x64 已发布 3.26.147;Canvas V3 仍默认关闭。
### 稳定化:插件 fallback 默认关闭
- 插件未选中时直接画空白占位会隐藏相册/图库/网页内容,体验不可接受;
- v3.26.147 起插件 fallback 只在 `window.__IWB_CANVAS_V3_PLUGIN_FALLBACK__ === true` 时启用;
- 默认 Canvas V3 只接管内置类型,插件节点保持原 DOM;
- 图片 canvas 缓存上限 64,避免大量 out/ref 缩略图无限常驻。
### P2 第三批:gen
- `TYPES` 增加 `gen`;未选中 gen 节点改为 canvas 卡片(标题/摘要),选中恢复 NodeCard 配置;
- `out` 仍走 DOM:它的结果网格依赖 gen/out 图数据与缩略图管线,不能只画占位;下一轮单独做。
- 由于 `gen` 只做静态卡片,生成/任务状态仍以选中后的 NodeCard 为准。
注意:canvas 文本按视口缩放绘制,低倍率下只适合看卡片轮廓,精确阅读/编辑要选中。
### P1 单层命中门禁(2026-12-01)
- `src/canvas-v3-hit.js` + 单元测试接入 `test:unit`;
- 100 ref 节点:off DOM 4165 → on DOM 866;每节点 DOM 0(选中时只有 1 个 NodeCard overlay);
- 点击选中、拖动、右键菜单、双击预览已实测;
- 全量 `verify:ci` 通过(33 e2e + 单测 + facts/boundary/ratchet);
- 默认关闭;桌面端实机 graphics/长帧尚未测,P1 还不算完成。
### 门禁
- `npm run verify:ci` 通过(33 e2e + 单测 + facts/boundary/ratchet);
- Canvas V3 默认关闭;关闭时旧路径零行为变化;
- 开启方式:诊断页「Canvas V3(实验,需刷新)」或 `IWBCanvasV3.setEnabled(true)` 后刷新。
### 经验(门禁)
- `src/*.js` 不能直调 `localStorage`(storage-convergence 会拦),特性开关也必须走 `IWBStorageLocal.getStore().rawGet/rawSet`;桌面端这样才能落到资料目录底座。
- 新 canvas 模块里避免写蓝色 hex 兜底(page-chrome-regression 会扫全源),颜色一律走 CSS token + 中性兜底。
- 新增模块/耦合/测试都要同步 facts、boundary 快照与 `test:unit`,否则 verify:ci 会红。
+44 -204
View File
@@ -1,222 +1,62 @@
# 插件发布契约(给插件源码项目的交接说明)
# 插件发布(桌面版)
> 适用对象:在**另一个项目**里写插件、需要发到 Image Workbench Web 线上的人 / agent。
> 权威实现:`scripts/plugins-publish.mjs`(发布脚本)、`functions/plugins/[[path]].js`(KV 分发)、`src/plugin-host.js` + `app.js:9214`(加载与注册)。
> 最后核对:2026-11-14(新增 §8 插件节点与自定义节点体)
> 2026-12-01 重写:网页版已停用,Cloudflare Pages / Functions / `PLUGINS` KV 通道一起下线,
> `scripts/plugins-publish.sh`、`scripts/plugins-publish.mjs` 已删除。桌面版插件只走**插件市场**。
---
## 两条链路
## 0. 一句话
插件是**一个经典脚本文件**,上传到 Cloudflare KV 的 `plugins/` 下,由同源 `/plugins/index.json` 清单 + SRI 完整性校验驱动加载。**发布只用一条命令,不要手写清单。**
---
## 1. 文件与命名(硬约束)
| 约束 | 说明 |
|---|---|
| 源文件名 | **必须** `plugin-<id>.js` —— 发布脚本从文件名解析 id,不符合直接报错 |
| id 规则 | `^[a-z][a-z0-9-]{2,31}$`(小写字母开头,3–32 字符,只含 `a-z 0-9 -`) |
| 模块形态 | **必须是经典脚本(IIFE),不能是 ES Module**。宿主用 `document.createElement('script')` 注入,没有 `type="module"`,`import`/`export` 会语法错误 |
| 存储名 | 由脚本生成:`plugin-<id>.<sha256前12位>.js`(内容寻址)。**不要自己造这个名字** |
| 注册 | 必须自我注册:`window.IWBPluginHost.register(manifest, factory)`;`manifest.id` 必须**等于**文件名里的 `<id>`,否则加载后状态是 `not-registered` |
| 样式 | 用 JS 注入 `<style>` 字符串(`style-src 'self' 'unsafe-inline'` 允许);不要外链 CSS |
### CSP 限制(线上 `_headers` 实测)
```
default-src 'self'; script-src 'self'; worker-src 'self' blob:;
style-src 'self' 'unsafe-inline'; img-src 'self' https: data: blob:;
connect-src 'self' https: http://127.0.0.1:30092 http://localhost:30092 http://127.0.0.1:3425 http://localhost:3425;
object-src 'none'; base-uri 'none'; frame-ancestors 'none'
```
结论:
- ❌ 不能用 `eval` / `new Function`(`script-src` 没有 `unsafe-eval`)
- ❌ 不能内联 `<script>`、不能从 CDN 引脚本
- ✅ 可以 `fetch` 同源与任意 `https://` 接口(`connect-src` 放行)
- ✅ 可以 `data:` / `blob:` / `https:` 图片
---
## 2. manifest 必填字段(真实插件示例)
```js
;(function (global) {
'use strict'
var STYLE_ID = 'iwb-myplugin-style'
// ... 插件实现 ...
global.IWBPluginHost.register({
id: 'my-plugin', // 必须等于文件名 plugin-my-plugin.js 里的 id
name: '我的插件', // 显示名
version: '1.0.0', // 见 §4:要与清单 version 保持一致
apiVersion: 1, // 正整数,<= 宿主 API_VERSION
capabilities: ['nodeActions', 'canvas', 'canvasWrite'],
}, function (ctx) {
// ctx 提供 storage / settings / 事件订阅等,按需使用
})
})(typeof window !== 'undefined' ? window : globalThis)
```
- `capabilities` 只允许宿主声明的能力名,写未知值会被 `register` 拒绝。
- `settings` 可选,用于在插件管理里生成配置项。
---
## 3. 发布:一条命令
```bash
# 在 Image Workbench Web 仓库根目录执行(脚本在这里,运行时在 KV)
node scripts/plugins-publish.mjs /path/to/plugin-<id>.js --version <id>=1.3.0 --upload
```
脚本会依次:
1. 按 `plugin-<id>.js` 解析 id,算 `sha256` → `integrity`
2. 生成内容寻址名 `plugin-<id>.<hash12>.js`(同字节同名 ⇒ **幂等**;字节变则名变 ⇒ 客户端永不命中旧缓存)
3. **合并**既有清单:本次没传的插件原样保留,同 id 由新条目覆盖
4. `PUT` 插件字节 + `PUT` 清单到 KV(走 Cloudflare REST API,不依赖 wrangler)
5. **回读校验**:把线上 `plugins/index.json` 拉回来与本地比对,不一致直接报错
凭据:`CLOUDFLARE_API_TOKEN`(需 `Account → Workers KV Storage → Edit`)+ `CLOUDFLARE_ACCOUNT_ID`。macOS 上缺失时脚本**自动读钥匙串**(`CLOUDFLARE_PAGES_TOKEN` / `CLOUDFLARE_ACCOUNT_ID`),本机可直接跑。
先看计划不上传:去掉 `--upload` 即 dry-run,打印将写入的键。
---
## 4. 版本号:两处要一起改
| 位置 | 谁改 |
|---|---|
| 插件源码里的 `manifest.version` | 你自己改(脚本读不到源码里的 manifest) |
| 清单里的 `version` | `--version <id>=x.y.z` 改 |
`--version` **只写清单,不会改你源码里的 version**。两处不一致不会报错,但插件管理页会显示清单版本、插件内部日志显示源码版本,排查时容易误判 ⇒ 发版时同时改。
---
## 5. 绝对不要做
| ❌ 禁止 | 原因 |
|---|---|
| 手写 / 手改 `plugins/index.json` 再上传 | 会**整份覆盖** KV 清单,把别人的插件从列表里抹掉(2026-11-03 真实事故:6 个插件只剩 1 个) |
| 手填 `integrity` | 错一个字符浏览器就拒绝执行,且表现为「脚本完整性校验失败」很难查 |
| 自己造 `plugin-<id>.<hash>.js` 名字直传 | 内容寻址名必须与字节绑死,手造会破坏缓存语义 |
| 加 `--prune` | 它会把「本次没传入的插件」全部从清单删掉,只在确定要下线全部未传插件时用 |
| 用 ESM / `import` / `eval` | 经典脚本 + CSP 双杀 |
---
## 6. 上线后怎么验(3 步)
```bash
# ① 清单里有没有你的条目
curl -fsSL https://iwb.maqiart.eu.org/plugins/index.json | python3 -m json.tool | grep -A2 '"my-plugin"'
# ② 字节取得到,且 SRI 与清单一致
curl -fsSL "https://iwb.maqiart.eu.org/plugins/plugin-my-plugin.<hash12>.js" -o /tmp/p.js
echo "sha256-$(openssl dgst -sha256 -binary /tmp/p.js | openssl base64 -A)" # 应与清单 integrity 完全相同
# ③ 页面:设置 → 插件管理,找到你的插件并勾选启用
```
插件管理页的状态含义:
| 状态 | 含义 | 常见原因 |
| 链路 | 说明 | 产物 |
|---|---|---|
| `远程` / `loaded` | 已加载并注册成功 | 正常 |
| `远程·未加载` | 清单里有,但没启用 | 勾选即按需下载 |
| `远程·not-registered` | 脚本执行了但没注册 | `manifest.id` 与文件名/id 不一致,或 `register` 被拒(capabilities 未知等) |
| `远程·bad-entry` | 清单条目不可信 | `integrity` 缺失或格式不合法(fail-closed,直接拒绝) |
| `远程·failed` | 下载/校验失败 | SRI 与字节不符、404、网络 |
| 内置插件 | 随安装包发布,启动即加载 | 桌面仓 `plugins/`(`plugin-<id>.<sha12>.js` + `index.json` 带 SRI `integrity`) |
| 市场插件 | 用户按需安装 | `market/plugins/<id>-<ver>.zip` + `market/index.json`,托管在 `market.maqiart.eu.org` |
---
纯函数(`integrityOf` / `storedNameOf` / `buildIndex` / `mergeIndexes`)在 `scripts/plugin-integrity.mjs`,
由同步脚本与测试共用;加载与注册仍由 `src/plugin-host.js` + `src/runtime-plugin-loader.js` 负责。
## 7. 清理陈旧字节(可选)
内容寻址 ⇒ 插件更新后旧哈希键仍留在 KV(不再被清单引用)。
## 发布步骤
```bash
npm run plugins:gc # 只列出,不删
node scripts/plugins-publish.mjs --gc --delete --keep ai-chat # 真删(保留归档插件)
# 1) 插件源仓:改版本(package.json 与 src/index.js 里 register 的 version 必须同时改)→ 校验 → 提交
cd ~/open/github/iwb-plugins-desktop
npm run build -- <需构建的插件> # 手写单文件跳过
npm run validate # 必须 15/15
# 2) 桌面仓:同步内置产物 + 生成市场
cd ~/open/github/image-workbench-desktop
node scripts/sync-plugins-from-repo.js
node scripts/gen-market.js
node scripts/gen-market-page.js
node scripts/gen-site.js # 复制成 site/plugins-index.json 并刷新首页/插件页版本号
npm run check:plugins # 13 个插件一致性门禁(发布脚本也会自动跑)
# 3) 上传 NAS(文件是只读位,覆盖前先 rm)
scp market/index.json market/index.html [email protected]:/vol8/web/iwb-market/
scp market/plugins/<id>-<ver>.zip [email protected]:/vol8/web/iwb-market/plugins/
scp site/index.html site/plugins-index.json [email protected]:/vol8/web/iwb-download/
scp site/plugins/index.html [email protected]:/vol8/web/iwb-download/plugins/
ssh [email protected] "chmod -R a+rX /vol8/web/iwb-market /vol8/web/iwb-download"
```
判定以**线上清单**为准,不用本地清单(本地落后时会误删)。`--keep` 是必需的:`ai-chat` 属「移出清单但字节留 KV 待启用」的归档态,不加 keep 会被当垃圾删掉,想启用就得重新上传字节。
## 必须回读核验
---
不能只看命令退出码,下载站与市场都要回读:
## 8. 插件自己的节点与节点体(`capabilities: ['nodeTypes']`)
插件可以注册**自己的节点类型**,并让节点体跑自己写的 DOM 表单(`style-source` 的「样式节点」就是这套,
2026-11-14 上线测试站)。
```js
global.IWBPluginHost.register({
id: 'my-plugin',
version: '1.3.0',
// ⚠️ 能力名是 nodeTypes,但挂到 ctx 上的 key 叫 nodes(CAPABILITY_API_KEYS 的映射)。
// 写成 ctx.nodeTypes 不会报错,只会静默失效 —— 排查时最容易踩的一条。
capabilities: ['canvas', 'canvasWrite', 'nodeTypes'],
}, function (ctx) {
if (!ctx.nodes || typeof ctx.nodes.register !== 'function') return {}
ctx.nodes.register({
id: 'style', // 类型 id = plugin:my-plugin:style
title: '样式节点',
defaults: {}, // 新节点的 data 初值
ports: { in: false, out: true }, // 可覆盖;不传 = in/out 都开(只出不入就靠这条)
height: 360, // 初始高度;内容超过时宿主按实测自适应
color: '#969696', // 可覆盖序号/边框色
render: renderMyNode, // 可选;不传 = 宿主默认节点体(标题 + 文本框 + 运行按钮)
// run: async (node, host) => {...} // 可选;不传 = 节点上没有「运行」按钮
})
return {}
})
```bash
curl -s "https://market.maqiart.eu.org/index.json?t=$(date +%s)" | head -c 200
curl -s "https://download.maqiart.eu.org/plugins-index.json?t=$(date +%s)" | head -c 200
```
### 8.1 `render` 契约(插件节点体)
- 市场索引条数正确(当前 13 个),改动插件版本已更新
- 每个新 zip 的 `bundleSha256` 与线上下载字节一致
- 解包 `main.js` 确认 manifest 的 `version` 真的变了(2026-12-01 就踩过:清单升版、产物没升版)
| 项 | 规则 |
|---|---|
| 签名 | `render(node, props, host)`。`node` 是最新节点对象,`props` 与内置节点体同款(`onUpdate(id, patch)` / `busy` / `progress` / `onPreview` 等),`host` 是一个**固定不变的 div** |
| 怎么画 | 直接往 `host` 里写真实 DOM。宿主**不会**用 React 重建这个 div ⇒ 输入框不会每帧失焦 |
| 会重调 | 节点数据一变就再调一次(同一个 `host`、同一个 `node` 引用会被替换)。请做**幂等同步**:缓存自己建的元素、只改内容,**不要**每次 `innerHTML = ''` 重建,否则光标和选中会丢 |
| 输入框 | `input` / `textarea` 上务必 `pointerdown` / `mousedown` 里 `stopPropagation()`,否则宿主把这次按下当成「拖节点」,框点不进去 |
| 写回 | 一律 `props.onUpdate(node.id, patch)`;高频输入自己做防抖(300ms)+ `blur` 立刻提交,避免每次按键都写存档 |
| 正在编辑 | 重调时若 `document.activeElement` 就是那个输入框,**跳过 value 覆盖**,不然用户正在打的字会被 data 顶回旧值 |
| 清理 | 可选 `render.dispose(host)`,节点卸载时调用(解绑 window/document 级监听、停定时器) |
| 抛错 | 宿主捕获后把该节点体降级成一行提示文本,画布其余部分继续可用(不会白屏) |
| 样式 | 自己注入 `<style>`(`style-src 'unsafe-inline'` 允许);类名请加插件前缀,避免污染内置节点体 |
## 客户端安装时的校验
### 8.2 节点自带参考图(不用连一张参考图节点)
`src/runtime-plugin-market.js` 对市场条目做:zip 整体 `bundleSha256` → 逐文件 sha256(`files[]`)→ 路径白名单 → 体积/数量上限;
内置清单的 `integrity` 交给浏览器 SRI 强制校验,缺失即拒载(开发者模式的 `plugins/local/` 例外)。
节点 `data.refOn === true` 且 `data.refUrl` 有值 ⇒ 宿主在**本节点参与的任务图**里补一个伪参考图节点
(`id = <节点id>:ref`,`x/y` 取本节点坐标 ⇒ 参与「图片按 X 轴排序」这条既有规则)。
## 版本号一致性(历史事故)
- 参考图**只存 URL**,不转 base64 —— 接收方认链接,转 base64 会让存档和请求体积翻几倍。
- 它对这个节点的所有下游生效:直连生图、经组合节点、经批量、经分层节点都算。
- 典型用法:样式节点上「☑ 示例图作参考」勾上 = 多一张参考图;取消勾选 = `refOn: false`,这张图在任何下游都消失。
### 8.3 连线的白名单
插件节点要连到生图 / 组合 / 批量节点,靠的是宿主 `connectReasonOf` 那 7 条白名单。
2026-11-14 起:**`data.outKind === 'prompt'` 的节点按「提示词节点」对待**,7 条规则全部放行
(此前 `plugin:*` 只能连到少数下游)。所以「这个节点产出的是提示词文本」就显式声明
`outKind: 'prompt'`,别指望宿主猜。
---
## 9. 给插件项目的自查清单
发版前逐条打勾:
- [ ] 文件名是 `plugin-<id>.js`,id 符合 `^[a-z][a-z0-9-]{2,31}$`
- [ ] 是 IIFE 经典脚本,全文没有 `import` / `export` / `eval` / `new Function`
- [ ] 调了 `IWBPluginHost.register(manifest, factory)`,`manifest.id` 与文件名一致
- [ ] `capabilities` 只用了宿主支持的能力名
- [ ] `manifest.version` 与将要传的 `--version` 一致
- [ ] 本地 `node --check plugin-<id>.js` 通过
- [ ] 注册了节点类型的话:`capabilities` 含 `nodeTypes`,且用的是 `ctx.nodes`(不是 `ctx.nodeTypes`)
- [ ] 自定义 `render` 是幂等同步(不每帧 `innerHTML=''`)、输入框 `pointerdown` 有 `stopPropagation`
- [ ] 发布后 §6 的 3 步验证全过
- `package.json` 与 `src/index.js` 里 register 的 `version` 是两处,只改一处会让客户端自报旧版本
- 需构建的插件(image-annotate / image-vectorize)**先确认 `<id>/plugin/` 源码不落后于已提交产物**再 build,
否则重建会回退手工补的补丁(2026-12-01 实测会丢 `getNodeImage(id,{max:4096/2048})`)
+11 -11
View File
@@ -1,7 +1,7 @@
# 现状架构与性能事实基线(桌面版)
> **本文档是什么**:现状**事实快照**,不是规范。用途:任何性能 / 内存 / 存储相关改动,先对齐这里的现实,避免把已经调好的东西改坏。
> 日期 **2026-10-20**(**2026-11-16 复算 · v3.24.85**)| 基线(**最近一次 bump 版本的提交**,不是主干 HEAD)`main = fa3586b`(线上 `v3.26.135+fa3586b` —— 2026-11-30 **图库链路收尾**:宫格不再读原图(原生 320 tier)、缩略图原子写 + 同键合并 + 补 .png、空闲预热;插件图片策略 v2(thumb/preview/original/budget)全量落地。上一条 `v3.26.129+a7da7f7` —— 2026-11-30 **插件源读数**:诊断页显示加载器实际读取的插件目录、索引条数、id@version 版本表与报错。上一条 `v3.26.128+9bcf6d7` —— 2026-11-30 **浏览器窗口空闲休眠**:它是独立 WKWebView(实测整树 +480MB),失焦满 30 分钟自动 close。上一条 `v3.26.127+ed762ad` —— 2026-11-30 **DOM 规模进诊断**:顶部显示 DOM 元素总数 + 停靠面板子树 + 图库卡片数,用来量化「面板开着」的真实成本(实测主窗口 29 节点却有 348MB WebKit malloc,大头在插件面板 DOM)。上一条 `v3.26.126+94d9952` —— 2026-11-30 **诊断增强**:新增 Rust app_memory_breakdown(逐进程 footprint + 分类 Dirty/Reclaimable),诊断页新增「内存拆解(分进程)」与「图片管线」(原生解码次数/峰值 + 缩略图磁盘 512/256/768 统计)。上一条 `v3.26.125+5d70782` —— 2026-11-30 **内存口径修正**:ps 的 RSS 会把每个 WebKit 子进程映射的共享框架各算一遍,四进程求和虚高 1.5~2 倍;改为 footprint(1) 的 phys_footprint(活动监视器同源),并只认比本进程更年轻的 WebKit 子进程。实测 WebContent footprint 653MB 中 dirty 仅 32MB、CG raster 1.7MB、Image IO 0 ⇒ 图片内存已压到底。上一条 `v3.26.124+a0526e7` —— 2026-11-30 **插件图片策略 v2**:宿主三层 ctx.images(thumb/preview/original/budget) + 原生解码闸门(并发 ≤2,>1024px ≤1);album 1.2.4 / promptlib 1.14.10 / batch-export 1.2.3 / annotate 1.20.9 / vectorize 0.6.2 / white-bg 1.2.2 / cutout 1.0.4 全部改走宿主小图;check-plugins-sync 增加图片策略守卫(warn)。上一条 `v3.26.123+309963c` —— 2026-11-30 **缩略图改原生生成**:WebKit 忽略 createImageBitmap 的 resize 选项,JS 生成缩略图要整幅解码 4K 原图(21MB/张),100 多张 ⇒ WebContent 1GB+;新增 Tauri 命令 img_thumbs(Rust image crate,按目标尺寸解码/编码),webview 只接触几十 KB 小图、原图永不进 WebKit 图片缓存。上一条 `v3.26.121+71fe162` —— 2026-11-30 **内存可观测性 + LOD 256 档**:新增 Rust 命令 app_memory_tree_mb(Windows Toolhelp32 / mac ps 建树)→ 诊断页「进程实测 XXX MB」,内存护栏优先用它;createImageBitmap 改 resizeWidth 在解码阶段降采样;新增 256 小档缩略图(纯内存)按 need 分档;macOS 的 WKWebView 子进程按 etime(±180s) 认领,避免把 Safari 算进来。上一条 `v3.26.120+eaf2512` —— 2026-11-30 **图库面板开一次涨 200MB**:`gallery-sync.thumbFor` 原先让宫格每张图都过 `displayThumbOf`,给每张 mint 一个 objectURL 并进 `displayThumbs`(300 上限);关面板后 URL 仍被缓存持有、解码位图不释放。现改为直接吃磁盘 320 缩略图(~20KB data URL)、不过 displayThumbOf;插件 gallery 1.9.6→1.9.7:卡片缓存 400→60 且淘汰时显式摘 `<img src>`。上一条 `v3.26.119+db55d45` —— 2026-11-30 **诊断修复**:三处导出调用点写的 `window.__IWB_SAVE_BLOB__` 从未定义,桌面端「导出诊断 JSON / 导出节点组」必然抛错,已统一走顶层 `wSaveBlob`;`procEstMB` 的解码位图改按 min(自然尺寸, 渲染尺寸×dpr) 累加(原按 512²×4 低报 3~4 倍);「估算进程」改称「画布估算」并注明不含宿主进程;读不出的旧 `{__cache}` 引用按 key 记住失败、本会话不再重试,诊断新增「失效引用 N」;上一条 `v3.26.118+3944fc5` —— 2026-11-30 **内存第二批收敛**:显示缩略图 640→512(124 张图的解码位图 200MB→128MB)、缩略图生成并发 4→2、图片字节缓存 96→64MB、远程 http(s) 图不再进缩略图队列(跨域必败,只换来 thumb-fail 日志)、内存护栏改看 `procEstMB`(估算进程 = JS 堆 + 字节缓存 + 解码位图,阈值 800MB;只盯 JS 堆时 106 张图堆 20MB / 位图 200MB,护栏永远不动);上一条 `v3.26.117+3809c38` —— 2026-11-30 **内存:图片字节预算 + 绝对占用护栏 + 诊断页「立即回收内存」**(Windows 测试版,未发布):`image-blob-store` 的 LRU 补字节预算(96MB ≈ 20 张原图,原来只按 200 条封顶 ⇒ 4~7.5MB 原图最多常驻 1.5GB)并新增 `trim()`;内存护栏在「上限 75%」(4GB ⇒ 3.1GB)之外补一条 ≥900MB 的绝对占用线,每 2 分钟做一次轻量回收;诊断页新增节点级 `nodeBigSamples`、`blobCacheMB/N`、`objUrls`,并把「内存」改称「JS 堆Line truncated
> 日期 **2026-10-20**(**2026-11-16 复算 · v3.24.85**)| 基线(**最近一次 bump 版本的提交**,不是主干 HEAD)`main = d874e02`(线上 `v3.26.154+d874e02` —— 2026-11-30 **图库链路收尾**:宫格不再读原图(原生 320 tier)、缩略图原子写 + 同键合并 + 补 .png、空闲预热;插件图片策略 v2(thumb/preview/original/budget)全量落地。上一条 `v3.26.129+a7da7f7` —— 2026-11-30 **插件源读数**:诊断页显示加载器实际读取的插件目录、索引条数、id@version 版本表与报错。上一条 `v3.26.128+9bcf6d7` —— 2026-11-30 **浏览器窗口空闲休眠**:它是独立 WKWebView(实测整树 +480MB),失焦满 30 分钟自动 close。上一条 `v3.26.127+ed762ad` —— 2026-11-30 **DOM 规模进诊断**:顶部显示 DOM 元素总数 + 停靠面板子树 + 图库卡片数,用来量化「面板开着」的真实成本(实测主窗口 29 节点却有 348MB WebKit malloc,大头在插件面板 DOM)。上一条 `v3.26.126+94d9952` —— 2026-11-30 **诊断增强**:新增 Rust app_memory_breakdown(逐进程 footprint + 分类 Dirty/Reclaimable),诊断页新增「内存拆解(分进程)」与「图片管线」(原生解码次数/峰值 + 缩略图磁盘 512/256/768 统计)。上一条 `v3.26.125+5d70782` —— 2026-11-30 **内存口径修正**:ps 的 RSS 会把每个 WebKit 子进程映射的共享框架各算一遍,四进程求和虚高 1.5~2 倍;改为 footprint(1) 的 phys_footprint(活动监视器同源),并只认比本进程更年轻的 WebKit 子进程。实测 WebContent footprint 653MB 中 dirty 仅 32MB、CG raster 1.7MB、Image IO 0 ⇒ 图片内存已压到底。上一条 `v3.26.124+a0526e7` —— 2026-11-30 **插件图片策略 v2**:宿主三层 ctx.images(thumb/preview/original/budget) + 原生解码闸门(并发 ≤2,>1024px ≤1);album 1.2.4 / promptlib 1.14.10 / batch-export 1.2.3 / annotate 1.20.9 / vectorize 0.6.2 / white-bg 1.2.2 / cutout 1.0.4 全部改走宿主小图;check-plugins-sync 增加图片策略守卫(warn)。上一条 `v3.26.123+309963c` —— 2026-11-30 **缩略图改原生生成**:WebKit 忽略 createImageBitmap 的 resize 选项,JS 生成缩略图要整幅解码 4K 原图(21MB/张),100 多张 ⇒ WebContent 1GB+;新增 Tauri 命令 img_thumbs(Rust image crate,按目标尺寸解码/编码),webview 只接触几十 KB 小图、原图永不进 WebKit 图片缓存。上一条 `v3.26.121+71fe162` —— 2026-11-30 **内存可观测性 + LOD 256 档**:新增 Rust 命令 app_memory_tree_mb(Windows Toolhelp32 / mac ps 建树)→ 诊断页「进程实测 XXX MB」,内存护栏优先用它;createImageBitmap 改 resizeWidth 在解码阶段降采样;新增 256 小档缩略图(纯内存)按 need 分档;macOS 的 WKWebView 子进程按 etime(±180s) 认领,避免把 Safari 算进来。上一条 `v3.26.120+eaf2512` —— 2026-11-30 **图库面板开一次涨 200MB**:`gallery-sync.thumbFor` 原先让宫格每张图都过 `displayThumbOf`,给每张 mint 一个 objectURL 并进 `displayThumbs`(300 上限);关面板后 URL 仍被缓存持有、解码位图不释放。现改为直接吃磁盘 320 缩略图(~20KB data URL)、不过 displayThumbOf;插件 gallery 1.9.6→1.9.7:卡片缓存 400→60 且淘汰时显式摘 `<img src>`。上一条 `v3.26.119+db55d45` —— 2026-11-30 **诊断修复**:三处导出调用点写的 `window.__IWB_SAVE_BLOB__` 从未定义,桌面端「导出诊断 JSON / 导出节点组」必然抛错,已统一走顶层 `wSaveBlob`;`procEstMB` 的解码位图改按 min(自然尺寸, 渲染尺寸×dpr) 累加(原按 512²×4 低报 3~4 倍);「估算进程」改称「画布估算」并注明不含宿主进程;读不出的旧 `{__cache}` 引用按 key 记住失败、本会话不再重试,诊断新增「失效引用 N」;上一条 `v3.26.118+3944fc5` —— 2026-11-30 **内存第二批收敛**:显示缩略图 640→512(124 张图的解码位图 200MB→128MB)、缩略图生成并发 4→2、图片字节缓存 96→64MB、远程 http(s) 图不再进缩略图队列(跨域必败,只换来 thumb-fail 日志)、内存护栏改看 `procEstMB`(估算进程 = JS 堆 + 字节缓存 + 解码位图,阈值 800MB;只盯 JS 堆时 106 张图堆 20MB / 位图 200MB,护栏永远不动);上一条 `v3.26.117+3809c38` —— 2026-11-30 **内存:图片字节预算 + 绝对占用护栏 + 诊断页「立即回收内存」**(Windows 测试版,未发布):`image-blob-store` 的 LRU 补字节预算(96MB ≈ 20 张原图,原来只按 200 条封顶 ⇒ 4~7.5MB 原图最多常驻 1.5GB)并新增 `trim()`;内存护栏在「上限 75%」(4GB ⇒ 3.1GB)之外补一条 ≥900MB 的绝对占用线,每 2 分钟做一次轻量回收;诊断页新增节点级 `nodeBigSamples`、`blobCacheMB/N`、`objUrls`,并把「内存」改称「JS 堆Line truncated
<!-- 2026-10-28 P1 拆分批 1:新增 src/generation-task-graph.js(5 个任务图纯函数自 app.js 迁出)
⇒ 模块数 60→61、耦合面 51→52、sourceModules 60→61。耦合面只**新增** IWBWTaskGraph,无删除。
2026-10-28 P1 拆分批 2:新增 src/storage-config-shape.js(9 个配置形状纯函数自 app.js 迁出)
@@ -17,12 +17,12 @@
## 1. 速查(30 秒版)
- 渲染是 **DOM-per-node**(不是 canvas 绘制);**视口裁剪已存在**,余量 **240px**(v3.26.109 起带图节点收紧到 **80px**,见下) (A) `src/canvas-geometry.js` `cullRectsOf`。
- 渲染是 **DOM-per-node**(不是 canvas 绘制);**视口裁剪已存在**,余量 **280px**(v3.26.143 统一;带图节点不再单独收紧) (A) `src/canvas-geometry.js` `cullRectsOf`。
- **平移 = 每帧 `setViewport`**;**拖动 = 直接写 DOM transform、不 `setNodes`**。**这两条不许互换**(见 §9)。
- 图片**新写入主通道 = IndexedDB Blob `{__blob}` / key `imgblob_<hash>_<len>`** (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,626 行**(**双层预算**:绝对上限 8,665 / 占总源码 ≤ 40%,现 **26.0%**,2026-11-12 起;此前为单一上限 8,509、零余量);`Workbench()` = **2,231 行**(上限 **2,231**,余量 0;2026-11-16 把生成取消族 `cancelRunsFor`/`cancelRun`/`cancelTaskJobs` 与工作区列表写回族 `persistWs`/`duplicateWs` 搬进 `src/runtime-workbench-logic.js`(`createCancelActions` / `createWorkspaceListActions`),并删掉全仓零调用的 `runAll`,3090 → 2,998);大量逻辑已抽到 `src/*.js`(现 **119** 个模块 / 24,599 行,`sourceModules` 119 项;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,743 行**(**双层预算**:绝对上限 8,743 / 占总源码 ≤ 40%,现 **25.8%**,2026-11-12 起;此前为单一上限 8,509、零余量);`Workbench()` = **2,333 行**(上限 **2,333**,余量 0;2026-11-16 把生成取消族 `cancelRunsFor`/`cancelRun`/`cancelTaskJobs` 与工作区列表写回族 `persistWs`/`duplicateWs` 搬进 `src/runtime-workbench-logic.js`(`createCancelActions` / `createWorkspaceListActions`),并删掉全仓零调用的 `runAll`,3090 → 2,998);大量逻辑已抽到 `src/*.js`(现 **123** 个模块 / 25,140 行,`sourceModules` 123 项;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`。
## 1.5 内存基线(2026-11-30,v3.26.115,Windows / WebView2 实测)
@@ -67,9 +67,9 @@
- **DOM-per-node**:每个节点一个 DOM 元素;不是 canvas 重绘。
- **视口裁剪已存在**(不是"待做优化"):
- 余量:纯文本节点 `240`px;**带图节点(ref/out/image/combine/batch/plugin:album|gallery)`80`px** (A) `src/canvas-geometry.js` `CULL_PAD_WIDE` / `CULL_PAD_TIGHT`
- 余量:所有节点统一 `280`px (A) `src/canvas-geometry.js` `CULL_PAD_WIDE` / `CULL_PAD_TIGHT`
- 公式 `left: -vp.x/vp.scale - pad`、`right: (w - vp.x)/vp.scale + pad`(pad 按节点类型取宽/紧)(A) `cullRectsOf`
- 为什么分两档(v3.26.109):节点挂上 `<img>` 后浏览器会保留解码位图(1024 缩略图约 4MB、原图 6~20MB);240px 的宽余量意味着屏幕外一两屏的图片仍在解码,实测 WebContent physical footprint 1.2G / 峰值 2.7G
- 为什么 280(v3.26.143):80px 让图片节点在平移边缘频繁卸载/重解码;280px 接近参考项目 infinite-canvas 的缓冲区。图片内存由 512/256 缩略图管线控制。
- 关闭条件:`canvasSize.w/h` 为 0 时 `cullRect = null`(jsdom/测试全渲染)(A) `app.js:12655,12662`
- 豁免:拖拽中 `refs.drag.start[id]`、缩放中 `refs.resize.nodeId`、已选中 `sel.includes` (A) `app.js:12663-12665`
- 循环对不可见元素 **`continue`** 跳过(O(n) 布尔过滤,**不是 O(n) 渲染**)(O) `app.js:12684,12705`
@@ -142,7 +142,7 @@
1. **拖动帧只做 DOM transform(`dragApplyVisual`),不 `setNodes`** —— 本轮最见效一条 (A) 规范 §13.3/§13.7。
2. **平移必须走 `setViewport`** —— v3.80.0 曾把"DOM transform 不 setNodes"**套到平移**,引入"中键平移跳位 + 气泡偏移",**v3.80.1 已回退** (A) 规范 §13.3 `:458` + §12 1.2.4 `:403`/`:407`。
→ **任何"平移/缩放直写 DOM transform"的优化都属于已知回归,禁止重试。**
3. **视口裁剪(240px 余量)** —— 已存在且有效;不要重复实现,也不要为它引入空间索引(见 §10-2)。
3. **视口裁剪(280px 余量)** —— 已存在且有效;不要重复实现,也不要为它引入空间索引(见 §10-2)。
4. **各缓存上限**(50/50/300/200/400/200)都是有界设计,**调大即调高内存**。
5. **`stripBigDataUrlsSync` 惰性探测**(只克隆有图子树)—— 曾改成"全字段深拷贝"致内存 ~2GB (A) 规范 §13.3/§13.7。
6. **压缩指纹采样哈希**(禁全量 O(n) 哈希)—— 曾致空闲 CPU 15% (A) 规范 §13.3。
@@ -177,7 +177,7 @@
- **正确改法**:把预览派生**纳入已有 `runWithConcurrency`**(复用既有原语,别新造闸门)。
- **F3|resize 下限不一致** (A)
- 节点拖拽视觉下限 `Math.max(180, …)` / `Math.max(90, …)`(`app.js:10912-10913`) vs 全屏窗缩放手柄几何 `Math.max(240, …)`(`app.js:7829-7832`,4 个方向各一处)。
- **陷阱**:此处 `240` 与**视口裁剪余量 `240`**(`app.js:12656-12659`)**数值相同但语义无关** → 搜 `240` 时会互相干扰,勿连带改。
- **陷阱**:此处 `240` 与**视口裁剪余量 `280`**(`src/canvas-geometry.js`)语义无关 → 搜数值时勿连带改。
- **F4|三个缩略图缓存三种上限**(200/300/400,均 FIFO)(A) `app.js:4592/4573/1980`。
- **F5|边路径缓存 `pathCache` 超 3000 整体 `clear()`**(非 LRU)(A) `app.js:6006`(`if (pathCache.size > 3000) pathCache.clear()`,紧接 `pathCache.set(key, d)`,`6007`)→ 大规模下可能在平移时出现抖动 cliff。
- **命名更正**:该变量是 **`pathCache`**;本文档早期草稿误写为 `edgePathCache`(2026-10-15 更正)。
@@ -192,7 +192,7 @@
- 同一张图被 3 个节点引用、hydrate 成 3 个不同 objectURL 时,preview/display 缓存各自 miss → 重复解码(与 F2 相邻)。
- **F10|`refs.genScheduler` 是桩** (A) → 未接线,暂无运行时影响(P3)。
- **F11|已建但未接线的模块层(2026-10-17 接线审计;2026-10-18 复核更正)** (A)
- **判定法**:`global.X =` / `root.X =` 判「导出」;跨文件裸引用判「读」;排除自合并(`src/runtime-constants.js:9`)。`app.js` 是**唯一生产消费者**(无 HTML 入口;`sw.js` 不引用模块全局)。**119 个模块中 59 个导出**被 `app.js` 读取;其余为未接线 / 仅测试 / 零引用(见下)。
- **判定法**:`global.X =` / `root.X =` 判「导出」;跨文件裸引用判「读」;排除自合并(`src/runtime-constants.js:9`)。`app.js` 是**唯一生产消费者**(无 HTML 入口;`sw.js` 不引用模块全局)。**123 个模块中 59 个导出**被 `app.js` 读取;其余为未接线 / 仅测试 / 零引用(见下)。
- **仅被测试引用(9 模块 + 2 导出)**:`canvas-domain`、`generation-retry`、`generation-service`、`runtime-recovery-runner`、`runtime-state-bridge`、`runtime-store`、`storage-reconcile`、`storage-result`、`workspace-service`;导出 `IWBStorageHealthFactory`、`IWBPluginHostFactory`。(`storage-result` 是**存储层共享结果类型**,被 6 个存储模块读取,**非死代码**;`runtime-store` 为状态模型 epic 地基。)
- **app.js 零引用(1 模块 + 3 导出)**:模块 `generation-controller`;导出 `IWBRuntimeMetricsFactory`、`IWBStorageRuntimeFactory`、`IWBUIComponents`。`canvas-relations` 已随 `06cf211` 删除(本文档早前把它列为"唯一可删者",实际已删)。零引用证据 = `grep -rn "<名字>" .`(排除 `node_modules|dist|vendor|test-results`)**只命中其自身赋值行**。
- **半接线 / 未接线**:`IWBRuntimeStateBridge` **无 app.js 引用(仅测试)**;`IWBRuntimeRunContext` **已接线**(`runNode` 读取运行上下文);`IWBGenerationController` 是完整但**从未被调用**的工厂;`ModularWorkspaceStore`(`app.js` 内)是 `storage-workspace` 的**预留接线 seam**(当前无下游使用,保留);`window.IWBImageFolder` 自注册后读回(装载路径)。
@@ -208,7 +208,7 @@
| `storage-reconcile` | 存储对账(`createReconciler`/`check`) | 内联对账 | 存储层收口 |
| `runtime-recovery-runner` | 执行恢复候选(`candidate`/`valid`/`run`) | 内联恢复 | 断点恢复 |
| `canvas-domain` | 画布域模型(`commit`/`updateNode`/`deleteNodes`…) | `CanvasStore` 那一套 | Workbench 解耦(P2-9) |
- **耦合面已冻结**:`tests/architecture-boundary-guard-test.js`(进 `npm run test:unit` 末环)冻结 app.js↔src 耦合面(**98** 项)与 `sourceModules` 顺序(**119** 项);命名例外由第 5 组冻结,新增非 `IWB` 前缀导出即打红。
- **耦合面已冻结**:`tests/architecture-boundary-guard-test.js`(进 `npm run test:unit` 末环)冻结 app.js↔src 耦合面(**102** 项)与 `sourceModules` 顺序(**123** 项);命名例外由第 5 组冻结,新增非 `IWB` 前缀导出即打红。
## 12. 易踩的坑
@@ -279,7 +279,7 @@
**信任模型(必须明示)**:形态 A 的插件是**可信代码**(与核心同权限、无沙箱);启停与设置是 UX 与可维护性手段,**不是安全边界**(同 §13.27 教训:前端开关一定可被绕过)。
**守门与快照**:`tests/architecture-boundary-guard-test.js` 冻结「app.js ↔ src 耦合面」(**98** 项)与 `sourceModules` 顺序(**119** 项);新增模块、新增耦合、新增 dev 探针都**必须有意重生成对应快照**(`IWB_WRITE_BOUNDARY_SNAPSHOT=1`)。契约与行为的可执行验证在 `tests/plugin-host-test.js`(宿主单测)与 `tests/_plugin-host-probe.spec.js`(真实浏览器探针,`_` 前缀 + `iwb-dev-probe`,不进 34 门禁)。
**守门与快照**:`tests/architecture-boundary-guard-test.js` 冻结「app.js ↔ src 耦合面」(**102** 项)与 `sourceModules` 顺序(**123** 项);新增模块、新增耦合、新增 dev 探针都**必须有意重生成对应快照**(`IWB_WRITE_BOUNDARY_SNAPSHOT=1`)。契约与行为的可执行验证在 `tests/plugin-host-test.js`(宿主单测)与 `tests/_plugin-host-probe.spec.js`(真实浏览器探针,`_` 前缀 + `iwb-dev-probe`,不进 34 门禁)。
**关键陷阱**:`normalizeNodes`(现位于 `src/canvas-normalize.js`)会**静默丢弃**不在 `NODE_H` 里的节点类型 ⇒ 新增节点类型必须先登记 `NODE_H`,否则节点一刷新就消失(§13.27 规则三的同一失败模式)。
@@ -302,7 +302,7 @@
**鲜艺抠图插件(2026-10-17 起改为 A2 运行时插件,`dist` 不再内置)**:源码已迁出主仓到独立插件仓(`iwb-plugins`),经 Cloudflare Function `functions/plugins/[[path]].js` + KV(binding `PLUGINS`)**同源运行时加载**(同源 ⇒ CSP 零改动);主包**已不含** `src/plugin-xianyi-cutout.js`。功能:右键命令「抠图:选中节点」→ `POST {apiUrl}/rmbg?crop=`(`application/octet-stream` + 原始字节)→ 结果 PNG 写回为新的参考图节点(`<原名>_cutout.png`)。契约对齐 `iwb-plaus` v3.1.3 的 `background.js`(二进制进 / PNG 字节出;无 token、无 JSON),但**补齐了原版缺失的超时**(`AbortController` + 可配 `timeoutMs`)。设置项:`apiUrl` / `crop` / `timeoutMs`。尚未提供的能力面(若日后需要):插件只读「选中节点」与按 id 取节点图(`canvas` 目前只有 `getNodes` / `listNodeTypes`)。
**KV 信任锚与治理(2026-10-19 补充,规则见规则库 §13.35)**:A2 运行时插件的信任边界 = **谁能写 `PLUGINS` KV**。`/plugins/index.json`(清单)与插件字节**同源同 KV** ⇒ 客户端 `integrity`(SRI)只防缓存/部分损坏,**不防 KV 被攻陷**(能改 KV 者可同时改插件与清单)。治理要求:`PLUGINS` KV 写权限**仅限发布脚本(`scripts/plugins-publish.mjs`,默认 dry-run)与本人**,不交给 CI 或第三方;第三方插件经 `scripts/plugins-sync.sh` 合入前**必须人工审计**(脚本运行时打印显式提示)。
**插件信任锚(2026-12-01 修订)**:桌面版没有 KV 通道,A2 运行时插件的信任锚 = **由本人发布的市场索引**(`market.maqiart.eu.org`)。客户端安装时校验 zip 整体 `bundleSha256` + 逐文件 sha256 + 路径白名单 + 体积上限(`src/runtime-plugin-market.js`),内置清单随包(`plugins/index.json`,带 SRI `integrity`);网页版与 KV 发布脚本已于 2026-12-01 移除,第三方插件不经 CI、不共享凭据。
**app.js 拆分(2026-11-26,已完成三批)**:`app.js` 是单 IIFE、`Workbench()` 是巨型组件,行数棘轮长期零余量,新逻辑无处可落。按「逐字搬运 + ctx 注入」分三批收编,`Workbench()` 由 3,060 行降至 2,169 行。
+2 -2
View File
@@ -511,7 +511,7 @@ LRU 上限 + 切画板/离开画布/卸载时回收;`revokeAll()` 幂等。
| 内存行为契约 | `tests/iwb-image-memory-parity.spec.js` |
| 新写入主通道契约(`{__blob}` / 存量 `{__cache}` 兼容 / A/B 开关) | `tests/iwb-blob-write.spec.js`(2 条) |
| 守护契约编号 | `120-1 … 142-1`(见 `tests/iwb-v32-web-test.js`) |
| 发布核验工具 | `scripts/verify-release.js`(`npm run verify:release`) |
| 发布核验工具 | `publish-update.sh` / `publish-windows-update.sh` 发布后回读 `latest.json` / `latest-windows.json` |
### 13.34.7 已知残留(明确记录,避免误以为已解决)
- **JS 堆 <120MB 未经真机堆快照确认**(仅有等价 A/B 代理证据:画布 base64 → 0 ✓)。
@@ -623,7 +623,7 @@ B-② 撤销/重做后图片真能解码显示,`naturalWidth=768`)· e2e `te
**规则(三条,硬性)**:
1. **插件 = 完全可信代码,只装自己审计过的**。文档/发布说明必须**明示**这一点;不得向用户暗示"插件有沙箱 / 有权限隔离"。
2. **信任锚是「谁能写 `PLUGINS` KV」,不是客户端 SRI**。`/plugins/index.json`(清单)与插件字节**由同一 KV 提供** ⇒ 能改 KV 者可同时改插件与其 `integrity`;客户端 fail-closed 的 `integrity` 校验**只防缓存/部分损坏,不防 KV 被攻陷**。因此 `PLUGINS` KV 写权限**只给发布脚本与本人**,不交给 CI、第三方或共享凭据;发布统一走 `scripts/plugins-publish.mjs`(算 SHA-256 + 写清单 + 上传,默认 dry-run,`--upload` 才落 KV)。
2. **信任锚是「谁能写插件市场」,不是客户端 SRI**:市场索引与本机安装/内置清单校验(zip `bundleSha256` + 逐文件 sha256 + SRI `integrity`)共同定界;网页版与 KV 发布脚本已于 2026-12-01 移除,发布只走「插件源仓 → 桌面仓 sync/gen-market → NAS `/vol8/web/iwb-market`」,凭据不进 CI。
3. **合入第三方插件前先审代码**。`scripts/plugins-sync.sh` 会把插件仓产物拷成 `src/plugin-<id>.js`(可执行可信代码);**同步前必须人工审计**(脚本已在运行时打印该显式提示)。
**验证方式**:`tests/plugin-host-test.js`(宿主契约)· `tests/plugin-integrity-test.js`(清单/integrity 生成)· `tests/_plugin-host-probe.spec.js`(真实浏览器探针,`_` 前缀 dev 探针,不进 34 门禁)。
+133
View File
@@ -0,0 +1,133 @@
# 2026-11-30 卡顿 / 内存复盘:10000² 边线 SVG 是 graphics 1.6GB 的主因
> 现场:诊断页 v3.26.140,节点 101 · 画板 70 · DOM 图片 18 · DOM 元素 1955
> 进程实测 1469MB;内存拆解 宿主 54 + GPU 342 + Networking 45 + **WebContent 1810(graphics 1603)** = 2251MB。
> 缩略图预热 73/164 进行中;缩略图磁盘 541 个 / 52MB;内存中图片 0KB。
## 一、结论先行
**WebContent.graphics 的 1603MB 基本就是边线 SVG 的合成位图。**
修复前:
```jsx
<svg class="iwb-edges" width="10000" height="10000"
style="overflow:visible; transform:translateZ(0)">
```
- 10000 × 10000 = 1e8 像素;
- 每像素 4B:**400MB**;
- Retina dpr=2 时位图 4 倍:**1.6GB**;
- `translateZ(0)` 强制它成为常驻合成层,所以即使视口只有 1200×788,内存也按整块 SVG 分配。
这与诊断页的 **graphics 1603MB** 几乎逐字节吻合;不是 101 个节点、18 张 DOM 图片能解释的量级。
## 二、已修(P0)
边线 SVG 改为**屏幕坐标系**(不是“放在 world 里但用视口矩形”):
- `src/canvas-geometry.js`:`edgeLayerSize / edgeLayerProps / edgeGroupTransform / applyEdgeLayerDom`;
- `app.js`:SVG 移出 `.iwb-world`,宽度恒为 `.iwb-canvas` 的 CSS 尺寸;世界坐标由内部 `<g class="iwb-edge-world" transform="translate(x,y) scale(s)">` 负责;
- 手势期间 `applyViewportDom` 只更新这个 `<g>` 的 transform,不改 SVG 尺寸;
- 合成层从 10000² 变为「一个屏幕大小」:2560×1303×4B×dpr² ≈ 53MB(dpr2),而非 1.6GB。
> **第一版为什么只降了一半**:3.26.141 把 SVG 放进 world,用 `width = viewportW / scale`。缩到 30% 时 CSS width 变成 8000 世界像素,WebKit 仍按 SVG 自身尺寸分配位图 ⇒ graphics 仍有 1032MB。
> 3.26.142 把 SVG 移出 world,宽度恒为屏幕 CSS 宽,才真正切断“世界尺寸 → 位图尺寸”的乘法。
数学验收:`tests/canvas-geometry-test.js` 断言屏幕尺寸、`<g>` 的 transform、viewBox 不含 10000。
浏览器实测(Playwright,纯平面):缩放后 SVG 屏幕矩形仍为 0..viewport,width 不再随 scale 变大。
## 三、第二梯队(按收益排序)
### P1 · 合成层 / 毛玻璃 A/B
诊断页已有两个开关(默认取决于历史设置):
1. **合成层常驻提升**:关掉 `.iwb-world` 的 `will-change/translateZ`;省内存但平移可能变糙。现在 SVG 已经很小,建议先**保持开**测一次,再关一次对比。
2. **禁用毛玻璃**:只作用于 4 处 `backdrop-filter`(顶栏、加载层、覆盖层、插件面板);GPU 342MB 里有一部分来自这里,低配机可关。
验收:同样画布、同样缩放/平移 10 秒,看诊断页 WebContent/GPU 与体感;不要只看任务管理器单进程。
### P1 · 图库预热让路(已做)
164 张 320 缩略图在启动 6 秒后按 1 路补齐,每张 sleep 120ms;用户开始平移/拖拽/缩放时,解码会抢主线程。
已修:`useGalleryPrewarm` 在 `refs.pan/drag/resize/box` 期间暂停,手势结束后继续。
注意:缩略图磁盘 **52MB 不是内存**;它只影响磁盘和首次解码。不要为了降磁盘去删缓存。
### P2 · 节点 DOM / 图片解码
- 101 节点 → 1955 DOM,约 19 元素/节点;目前不算异常,但每多一个面板/卡片会成倍增长。
- 画布已有 240/80 视口裁剪;带图节点只留 80px,避免屏外解码。
- 显示缩略图缓存 300 项(1024 WebP)、小图缓存 200 项、图库缩略图 400 项、objectURL 50 项,均有上限;当前「内存中图片 0KB」说明 JS 堆里没有大 base64,内存主要是图形层/解码位图,不是字符串泄漏。
- 如果修完仍高,下一步用诊断页采样确认 `bmpNN`(解码张数)与 `objUrls`,再考虑把 1024 显示缩略图降到 768、缓存 300→150;不要先动 4K 原图策略。
### P2 · 边线重绘的下一手
视口 SVG 在平移/缩放时仍会重绘一个屏幕大小的矢量层。若修完内存降了但手势仍掉帧:
- 把边线改成 **Canvas 2D**(只画可见边),或把 SVG 放到屏幕坐标系、用 `<g>` transform 平移(避免改 viewBox);
- 保留现有 `edgePathCache` 与 `EdgePathMemo`,不要每帧重算贝塞尔;
- 不要用「整块 translateZ + 10000²」换流畅,这次已经证明内存代价不可接受。
### P3 · React / 事件
- `Workbench()` 仍 2200+ 行,但节点有 `NodeCardMemo`、边有 `EdgePathMemo`、视口手势只改 DOM 不 setState;先不要大拆。
- 如果拖拽仍卡:用 React Profiler 看 `Workbench` 每帧 render 次数与 commit 时间,再决定拆 `CanvasViewport` / `NodeLayer`。
- 验收指标:平移/缩放 60fps 附近、单次 commit < 8ms、WebContent < 500MB(同一画布)。
## 四、复测步骤
1. 更新到含本修复的版本,打开同一画布;
2. 诊断页记录:进程实测、WebContent、GPU、graphics、DOM 元素、缩略图预热是否结束;
3. 平移 10 秒 / 缩放 10 秒,再记录一次;
4. 依次切「合成层」「毛玻璃」开关,各记录一次(只改一个变量);
5. 若 WebContent 仍 >800MB,导出诊断 JSON 看 `bmpNN` / `objUrls` / `thumbsMB` / `topBoards`,再定下一刀。
## 五、v3.26.143 已落地的第二轮(2026-11-30)
按 Infinite Canvas 的可借鉴部分改了一版,先发测试包:
1. **world/grid 不再默认常驻合成**:`.iwb-world` / `.iwb-grid` 的 `will-change` 改为显式 opt-in(诊断页勾选才开);默认 `data-layers="off"`。
2. **网格回到视口大小**:`.iwb-grid` 从 `200%` + `transform` 改为 `inset:0` + `background-position`,避免为背景多分一层。
3. **裁剪缓冲区 80 → 280**:带图节点不再在平移边缘频繁卸载/重解码。
4. **平移 DOM 写入 rAF 合批**:同一帧多个 pointermove 只写一次 world/grid/edge。
5. **自动回收只在应用不可见时跑**,且保留显示缩略图(`keepThumbs:true`);可见时不再清缓存触发周期性重载。手动「立即回收」仍清。
6. **图库预热 6s → 30s**,并在手势期间暂停。
验收仍按 §四:同画布 graphics <300MB、整树 <800MB、平移/缩放长帧减少、无图片闪烁。
## 六、v3.26.144 已落地(2026-11-30):Canvas 边线 + 平移全量渲染
1. **边线视觉改 Canvas 2D**:`src/ui-canvas-edges.js` 用视口 canvas 画贝塞尔;`<svg class="iwb-edges">` 只保留透明 hit path(选择/双击/悬停),不再每帧重栅格化 SVG。
2. **canvas 只画视口**:DPR 封顶 2;正常边线约 100 条,绘制成本远低于 SVG 合成层。
3. **平移期间全量渲染**:`nodeVisibleIn(..., { pan: true })` 返回 true,避免 viewport state 不更新导致裁剪窗口停在起点、超过 280px 后节点空白;松手恢复裁剪。
4. **平移仍 rAF 合批**:pointermove 只记位置,rAF 一次写 world/grid/edge canvas。
5. **弹线/拖动节点命令式重画 canvas**:`dragApplyVisual` 与 `applyViewportDom` 都调用 `refs.edgeCanvasDraw`,不触发 React。
验收:平移 1000px 不出现节点迟到/空白;边线选择/双击仍可用;graphics 不再包含 SVG 边线层。
## 八、平移 A/B(2026-12-01,Playwright WebKit,104 节点/92 边/无大图)
| 配置 | pan p50 | pan p95 |
|---|---:|---:|
| 合成层关闭 | 17ms | **60~66ms** |
| 合成层开启 | 17ms | **22ms** |
| 合成层开启 + 平移冻结 Canvas 边线 | 17ms | **18ms** |
| 合成层开启 + 关闭平移全量渲染 | 17ms | 23ms |
结论:
- WebKit 下 world/grid 合成层是平移流畅的关键,关闭后 p95 约 3 倍;
- 平移时冻结 Canvas 边线再松手重画,可再降 p95(22→18ms);
- 关闭“平移全量渲染”没有帧率收益,保留它以避免平移空白。
诊断开关(localStorage):`iwb_layers_on`、`iwb_pan_edges_freeze`、`iwb_pan_all_off`。
## 七、代码位置
- 边线层:`src/canvas-geometry.js`(edgeLayer* / applyViewportDom)、`app.js`(`.iwb-edges` 渲染)
- 视口手势:`app.js` → `applyViewportDom`
- 图库预热:`src/ui-workbench-hooks.js` → `useGalleryPrewarm`
- 缩略图/解码:`src/image-display-thumb.js`、`src/image-thumb-pick.js`
- 诊断:`src/ui-settings-tab-diag.js`、`app.js` → `diagDetail`
@@ -253,7 +253,7 @@ npm run verify
- 发布后记录 commit 与版本;核验 `latest.json` / `latest-windows.json` / 下载页三处一致。
- **"部署成功"≠ 验收:部署后要在真实 URL 上跑关键 e2e**(本轮做法,测试地址与正式域名各跑一遍):
```bash
IWB_BASE_URL=https://iwb.maqiart.eu.org npx playwright test tests/<关键>.spec.js
# 网页版已停用;桌面版发布后在安装包上跑 npm run test:e2e:smoke
```
同时核验 `app.js` 里的 `APP_VERSION` 与 `version.json`——只看外层退出码或"Deployment complete"会漏掉真实故障(管道 `tail` 退出码恒为 0)。
- **文档 / 发布说明里的"地址"必须是完整可点 URL**:禁止用 `站点/#iwb-tools=<暗号>` 这类**占位符**充当地址(用户会直接粘进浏览器 → 白跑一趟并以为站点坏了)。若必须举例,明确标注"占位符,非真实地址"。
@@ -266,7 +266,7 @@ npm run verify
- **CI 红灯排查顺序**:`gh run view <id> --log-failed` 看具体 job;优先怀疑 action/依赖,而不是代码。
- **构建产物已压缩打包(应用版本 v3.1.1)**:`scripts/build.js` 改为 **esbuild 逐文件 minify 再拼接** 成单个 `dist/app.js`(**不再输出 `dist/src/*`**),`style.css` 一并 minify;vendor React 保持独立、不压缩。**逐文件 minify(`transformSync`,非 `bundle`)** 是关键:拼接前每个 IIFE 已封闭,避免"整文件拼接后顶层声明重复/改名"的解析级隐患。
- **产物体检进 `verify`**:`npm run verify` 增加 `node --check dist/app.js` 与 `node scripts/check-dist.js`(断言 banner 版本 == `version.json`、`index.html` 恰 3 个 `<script>` 且无 `src/`、压缩后内嵌 Worker 字面量标记仍在)。
- **`verify-release.js` 改读 `/version.json`**(**不再**抓 `app.js` 里的 `APP_VERSION`——压缩会破坏该字符串正则,导致假失败)。
- **发布核验读产物清单**:`latest.json` / `latest-windows.json` / 下载页三处一致;网页版时代的 `verify-release.js`(读 `/version.json`)已随网页版下线一并删除。
## 11. 分层与边界
+2 -4
View File
@@ -1,7 +1,7 @@
{
"name": "image-workbench-web",
"private": true,
"version": "3.26.135",
"version": "3.26.158",
"description": "Browser-based node canvas image workbench",
"scripts": {
"build": "node scripts/build.js && node scripts/copy-plugins.js",
@@ -10,10 +10,9 @@
"app:build": "tauri build",
"lint": "eslint src app.js",
"test": "node tests/relay-task-graph-fixture-test.js && node tests/plugin-style-node-test.js && node tests/inherit-text-test.js",
"test:unit": "node tests/result-img-doubleclick-test.js && node tests/gallery-audit-test.js && node tests/plugin-files-policy-test.js && node tests/theme-plugin-tokens-test.js && node tests/design-tokens-component-doc-test.js && node tests/theme-static-snapshot-test.js && node tests/overlay-layer-test.js && node tests/settings-scope-test.js && node tests/node-scope-test.js && node tests/appearance-v2-test.js && node tests/image-prompt-cover-test.js && node tests/unit-test.js && node tests/canvas-actions-test.js && node tests/canvas-performance-test.js && node tests/canvas-drag-performance-test.js && node tests/resize-observer-performance-test.js && node tests/node-drag-jank-test.js && node tests/edge-graph-performance-test.js && node tests/persistence-export-images-test.js && node tests/settings-hotkeys-size-presets-test.js && node tests/custom-size-validation-test.js && node tests/image-node-performance-test.js && node tests/drag-frame-performance-test.js && node tests/canvas-edge-memo-test.js && node tests/canvas-node-transform-test.js && node tests/canvas-dot-zoom-test.js && node tests/duplicate-ws-fresh-source-test.js && node tests/single-canvas-shell-test.js && node tests/navigation-layout-test.js && node tests/home-canvas-library-test.js && node tests/left-resource-layout-test.js && node tests/interface-hierarchy-test.js && node tests/three-page-layout-test.js && node tests/page-chrome-regression-test.js && node tests/task-cache-test.js && node tests/album-task-graph-test.js && node tests/generation-endpoint-test.js && node tests/storage-config-shape-test.js && node tests/generation-default-model-test.js && node tests/storage-zip-test.js && node tests/canvas-node-factory-test.js && node tests/runtime-error-test.js && node tests/runtime-lifecycle-test.js && node tests/runtime-fetch-test.js && node tests/runtime-channel-test.js && node tests/runtime-boundary-test.js && node tests/runtime-record-test.js && node tests/runtime-recovery-test.js && node tests/runtime-diagnostic-record-test.js && node tests/runtime-metrics-test.js && node tests/runtime-run-context-test.js && node tests/runtime-execution-context-test.js && node tests/storage-gc-canvas-refs-test.js && node tests/storage-health-test.js && node tests/generation-state-test.js && node tests/canvas-store-test.js && node tests/storage-result-test.js && node tests/storage-local-test.js && node tests/storage-domain-test.js && node tests/storage-runtime-test.js && node tests/storage-indexeddb-test.js && node tests/generation-scheduler-test.js && node tests/gallery-query-test.js && node tests/gallery-hydration-test.js && node tests/gallery-sync-test.js && node tests/image-blob-store-test.js && node tests/image-format-test.js && node tests/clipboard-graph-test.js && node tests/clipboard-graph-fallback-test.js && node tests/image-admit-test.js && node tests/image-dedupe-test.js && node tests/clipboard-kind-test.js && node tests/clipboard-paste-test.js && node tests/clipboard-copy-test.js && node tests/clipboard-native-test.js && node tests/paste-once-test.js && node tests/list-e2e-specs-test.js && node tests/desktop-csp-loopback-test.js && node tests/architecture-boundary-guard-test.js && node tests/plugin-host-test.js && node tests/plugin-data-test.js && node tests/plugin-loader-test.js && node tests/plugin-bundle-test.js && node tests/plugin-install-test.js && node tests/plugin-gallery-render-test.js && node tests/plugin-gallery-recovery-test.js && node tests/plugin-gallery-ux-test.js && node tests/plugin-grouplib-render-test.js && node tests/plugin-promptlib-render-test.js && node tests/image-compress-test.js && node tests/storage-fallback-indexeddb-test.js && node tests/canvas-normalize-test.js && node tests/canvas-geometry-test.js && node tests/canvas-history-test.js && node tests/canvas-ops-test.js && node tests/canvas-text-test.js && node tests/history-store-test.js && node tests/plugin-integrity-test.js && node tests/workspace-sessions-store-test.js && node tests/workspace-list-test.js && node tests/workspace-purge-test.js && node tests/provider-ping-test.js && node tests/runtime-diagnostics-hotpath-test.js && node tests/storage-log-failure-test.js && node tests/storage-convergence-test.js && node tests/swallow-wiring-test.js && node tests/workbench-logic-test.js && node tests/storage-autobackup-test.js && node tests/storage-outputs-mutate-test.js && node tests/sync-facts-guard-test.js && node tests/e2e-fixed-waits-ratchet-test.js && node tests/shell-render-behavior-test.js && node tests/canvas-meta-notice-behavior-test.js && node tests/source-text-ratchet-test.js && node tests/plugin-theme-contract-test.js && node tests/prompt-md-roundtrip-test.js && node tests/generation-results-store-test.js && node tests/out-groups-order-test.js && node tests/native-overlay-park-test.js && node tests/ui-dock-sanitize-test.js && node tests/ui-minimap-fit-test.js && node tests/ui-workbench-hooks-test.js && node tests/plugin-scale-contract-test.js && node tesLine truncated
"test:unit": "node tests/result-img-doubleclick-test.js && node tests/gallery-audit-test.js && node tests/plugin-files-policy-test.js && node tests/theme-plugin-tokens-test.js && node tests/design-tokens-component-doc-test.js && node tests/theme-static-snapshot-test.js && node tests/overlay-layer-test.js && node tests/settings-scope-test.js && node tests/node-scope-test.js && node tests/appearance-v2-test.js && node tests/image-prompt-cover-test.js && node tests/unit-test.js && node tests/canvas-actions-test.js && node tests/canvas-performance-test.js && node tests/canvas-drag-performance-test.js && node tests/resize-observer-performance-test.js && node tests/node-drag-jank-test.js && node tests/edge-graph-performance-test.js && node tests/persistence-export-images-test.js && node tests/settings-hotkeys-size-presets-test.js && node tests/custom-size-validation-test.js && node tests/image-node-performance-test.js && node tests/drag-frame-performance-test.js && node tests/canvas-edge-memo-test.js && node tests/canvas-node-transform-test.js && node tests/canvas-dot-zoom-test.js && node tests/duplicate-ws-fresh-source-test.js && node tests/single-canvas-shell-test.js && node tests/navigation-layout-test.js && node tests/home-canvas-library-test.js && node tests/left-resource-layout-test.js && node tests/interface-hierarchy-test.js && node tests/three-page-layout-test.js && node tests/page-chrome-regression-test.js && node tests/task-cache-test.js && node tests/album-task-graph-test.js && node tests/generation-endpoint-test.js && node tests/storage-config-shape-test.js && node tests/generation-default-model-test.js && node tests/storage-zip-test.js && node tests/canvas-node-factory-test.js && node tests/runtime-error-test.js && node tests/runtime-lifecycle-test.js && node tests/runtime-fetch-test.js && node tests/runtime-channel-test.js && node tests/runtime-boundary-test.js && node tests/runtime-record-test.js && node tests/runtime-recovery-test.js && node tests/runtime-diagnostic-record-test.js && node tests/runtime-metrics-test.js && node tests/runtime-run-context-test.js && node tests/runtime-execution-context-test.js && node tests/storage-gc-canvas-refs-test.js && node tests/storage-health-test.js && node tests/generation-state-test.js && node tests/canvas-store-test.js && node tests/storage-result-test.js && node tests/storage-local-test.js && node tests/storage-domain-test.js && node tests/storage-runtime-test.js && node tests/storage-indexeddb-test.js && node tests/generation-scheduler-test.js && node tests/gallery-query-test.js && node tests/gallery-hydration-test.js && node tests/gallery-sync-test.js && node tests/image-blob-store-test.js && node tests/image-format-test.js && node tests/clipboard-graph-test.js && node tests/clipboard-graph-fallback-test.js && node tests/image-admit-test.js && node tests/image-dedupe-test.js && node tests/clipboard-kind-test.js && node tests/clipboard-paste-test.js && node tests/clipboard-copy-test.js && node tests/clipboard-native-test.js && node tests/paste-once-test.js && node tests/list-e2e-specs-test.js && node tests/desktop-csp-loopback-test.js && node tests/architecture-boundary-guard-test.js && node tests/plugin-host-test.js && node tests/plugin-data-test.js && node tests/plugin-loader-test.js && node tests/plugin-bundle-test.js && node tests/plugin-install-test.js && node tests/plugin-gallery-render-test.js && node tests/plugin-gallery-recovery-test.js && node tests/plugin-gallery-ux-test.js && node tests/plugin-grouplib-render-test.js && node tests/plugin-promptlib-render-test.js && node tests/image-compress-test.js && node tests/storage-fallback-indexeddb-test.js && node tests/canvas-normalize-test.js && node tests/canvas-geometry-test.js && node tests/canvas-history-test.js && node tests/canvas-ops-test.js && node tests/canvas-text-test.js && node tests/history-store-test.js && node tests/plugin-integrity-test.js && node tests/workspace-sessions-store-test.js && node tests/workspace-list-test.js && node tests/workspace-purge-test.js && node tests/provider-ping-test.js && node tests/runtime-diagnostics-hotpath-test.js && node tests/storage-log-failure-test.js && node tests/storage-convergence-test.js && node tests/swallow-wiring-test.js && node tests/workbench-logic-test.js && node tests/storage-autobackup-test.js && node tests/storage-outputs-mutate-test.js && node tests/sync-facts-guard-test.js && node tests/e2e-fixed-waits-ratchet-test.js && node tests/shell-render-behavior-test.js && node tests/canvas-meta-notice-behavior-test.js && node tests/source-text-ratchet-test.js && node tests/plugin-theme-contract-test.js && node tests/prompt-md-roundtrip-test.js && node tests/generation-results-store-test.js && node tests/out-groups-order-test.js && node tests/native-overlay-park-test.js && node tests/ui-dock-sanitize-test.js && node tests/ui-minimap-fit-test.js && node tests/ui-workbench-hooks-test.js && node tests/plugin-scale-contract-test.js && node tesLine truncated
"test:diagnostics": "node tests/runtime-diagnostics-hotpath-test.js",
"test:facts": "node tests/architecture-facts-guard-test.js && node tests/release-records-test.js",
"plugins:gc": "node scripts/plugins-publish.mjs --gc",
"check:plugins": "node scripts/check-plugins-sync.js",
"plugins:doctor": "node scripts/plugin-index-doctor.js",
"hooks:install": "bash scripts/install-git-hooks.sh",
@@ -30,7 +29,6 @@
"e2e:known-red": "node scripts/e2e-known-red-report.js",
"verify:ci": "npm run build && node --check app.js && node --check dist/app.js && node scripts/check-dist.js && node scripts/ctx-menu-audit.js && npm run tokens:check && npm run lint:tokens && npm run lint && npm run typecheck && npm run test:unit && npm test && npm run test:facts && npm run test:e2e:smoke",
"verify": "npm run verify:ci && npm run test:e2e",
"verify:release": "node scripts/verify-release.js",
"coverage:e2e": "node scripts/coverage-e2e.js",
"sync:facts": "node scripts/sync-facts.js",
"sync:facts:write": "node scripts/sync-facts.js --write",
+1 -1
View File
@@ -1149,7 +1149,7 @@
global.IWBPluginHost.register({
id: 'album',
name: '相册',
version: '1.2.3',
version: '1.2.5',
apiVersion: 1,
capabilities: ['nodeTypes', 'images', 'files'],
settings: {
+3 -3
View File
@@ -1,7 +1,7 @@
{
"id": "album",
"name": "相册",
"version": "1.2.4",
"version": "1.2.5",
"apiVersion": 1,
"main": "main.js",
"style": "styles.css",
@@ -14,7 +14,7 @@
"出图"
],
"files": {
"main.js": "79ac746f0065103a32b083e2d79f16fb09fcf9032709952ba256887db1bedb4a",
"styles.css": "40623c831620d0082dde956300461b29b9256aab98da86c7ab5e3495214f8d49"
"main.js": "38ec9d214ed204fc47d9ad8c82d8b3bf461c6cfbd09dbe18dc9d81061729e596",
"styles.css": "63f70828151481ee96fd102e3c18baecbf51999d8fd96044aabbefdd5c2d2225"
}
}
+2 -2
View File
@@ -29,12 +29,12 @@
竖图撑到 167px,和 capacityOf() 按方形算的容量是两套账(最后一行常被裁一半)。
aspect-ratio 让每一格高 = 宽,容量因此可精确预测,宫格也终于整齐。
padding:0 必须显式写:<button> 的 UA 默认内边距会把图顶出边框。 */
.iwb-album-cell { position: relative; aspect-ratio: 1 / 1; padding: 0; border-radius: var(--iwb-radius-chip); overflow: hidden; background: color-mix(in srgb, var(--iwb-border) 55%, transparent); border: 1px solid var(--iwb-border); cursor: grab; transition: transform var(--iwb-motion-hover, .15s) var(--iwb-ease-hover, ease-out), box-shadow var(--iwb-motion-hover, .15s) var(--iwb-ease-hover, ease-out); }
.iwb-album-cell { position: relative; aspect-ratio: 1 / 1; padding: 0; border-radius: var(--iwb-radius-chip); overflow: hidden; background: color-mix(in srgb, var(--iwb-border) 55%, transparent); border: 1px solid var(--iwb-border); cursor: grab; transition: border-color var(--iwb-motion-hover, .15s) var(--iwb-ease-hover, ease-out); }
/* 1.1.4(用户:1.06 太不明显):放大到 1.08 + 更深的投影 + 2px 品牌描边。
网格内**不做位移**(translateY 会让相邻格的 hover 判定抖动);描边用 outline 而不是加粗 border,
避免图片内容被 1px 的 border 变化挤动。z-index 走宿主层级 token(插件禁止裸值),
且被 .iwb-album-grid 的 overflow:hidden 限制在节点内。 */
.iwb-album-cell:hover { transform: scale(1.08); outline: 2px solid var(--iwb-hover-border, var(--iwb-brand)); outline-offset: -2px; box-shadow: 0 10px 26px rgba(0, 0, 0, .42), 0 2px 6px rgba(0, 0, 0, .28); z-index: var(--iwb-z-ctx, 90); }
.iwb-album-cell:hover { outline: 2px solid var(--iwb-hover-border, var(--iwb-brand)); outline-offset: -2px; border-color: var(--iwb-hover-border, var(--iwb-brand)); z-index: var(--iwb-z-ctx, 90); }
@media (prefers-reduced-motion: reduce) { .iwb-album-cell { transition: none; } .iwb-album-cell:hover { transform: none; } }
.iwb-album-cell img { width: 100%; height: 100%; object-fit: cover; display: block; -webkit-user-drag: none; }
/* v1.2.0:来源徽标 + 文件夹模式说明/路径 */
+1 -1
View File
@@ -849,7 +849,7 @@
global.IWBPluginHost.register({
id: 'gallery',
name: '图库',
version: '1.9.6',
version: '1.9.9',
apiVersion: 1,
capabilities: ['panels', 'gallery'],
data: { schemaVersion: 1, maxBytes: 65536 },
+3 -3
View File
@@ -1,7 +1,7 @@
{
"id": "gallery",
"name": "图库",
"version": "1.9.8",
"version": "1.9.9",
"apiVersion": 1,
"main": "main.js",
"style": "styles.css",
@@ -13,7 +13,7 @@
"图库"
],
"files": {
"main.js": "8586409417599dec4b0f229e88eaf937f991f1942db49df97ce9a27e16a35d9f",
"styles.css": "c7db0f9d78b98c1b5bb9782c45dfc2274673c1c7d34fdf676aae41680866eb3d"
"main.js": "22b2d8aa07ec193703d57603e857a6e48e054874ef943603d2ed7b1f3c560fd9",
"styles.css": "07ca657d2e5f5d9406e6c7f7306906e34f2ee10a2fa4c2165358451f5461c6a4"
}
}
+2 -5
View File
@@ -69,16 +69,13 @@
.iwb-history-embedded .iwb-history-item img {
width: 100%; height: auto; display: block; object-fit: contain; margin: 0 auto;
border-radius: 6px; border: 1px solid var(--iwb-border); background: var(--iwb-layer2); cursor: pointer;
transition: transform var(--iwb-motion-hover, .15s) var(--iwb-ease-hover, ease-out),
border-color var(--iwb-motion-hover, .15s) var(--iwb-ease-hover, ease-out),
box-shadow var(--iwb-motion-hover, .15s) var(--iwb-ease-hover, ease-out);
/* 2026-12-01:卡片不再做 hover 放大/投影;只保留描边反馈,减少悬停时的合成/raster 成本。 */
transition: border-color var(--iwb-motion-hover, .15s) var(--iwb-ease-hover, ease-out);
}
/* v1.7.3:卡片悬停上浮 + 阴影 + 品牌描边(与输出节点共用宿主 L2 token)。
用 item:hover 而不是 img:hover:指针移到下载浮层按钮上时卡片仍保持浮起,不抖。 */
.iwb-history-embedded .iwb-history-item:hover img {
transform: translateY(var(--iwb-hover-lift, -2px)) scale(var(--iwb-hover-scale, 1.02));
border-color: var(--iwb-hover-border, var(--iwb-brand));
box-shadow: var(--iwb-hover-shadow, 0 5px 16px rgba(0, 0, 0, .22));
}
/* v1.9.4:卡片按宽高比占位后,占位层要铺满卡片 —— 否则缩略图出现时仍会有一次高度跳变(滚动时表现为闪动) */
.iwb-history-embedded .iwb-history-item .iwb-history-missing { position: absolute; inset: 0; min-height: 0; }
+19 -19
View File
@@ -4,17 +4,17 @@
"dir": "album",
"main": "main.js",
"style": "styles.css",
"version": "1.2.4",
"version": "1.2.5",
"files": {
"main.js": "79ac746f0065103a32b083e2d79f16fb09fcf9032709952ba256887db1bedb4a",
"styles.css": "40623c831620d0082dde956300461b29b9256aab98da86c7ab5e3495214f8d49"
"main.js": "38ec9d214ed204fc47d9ad8c82d8b3bf461c6cfbd09dbe18dc9d81061729e596",
"styles.css": "63f70828151481ee96fd102e3c18baecbf51999d8fd96044aabbefdd5c2d2225"
}
},
{
"id": "batch-export",
"file": "plugin-batch-export.e0152de8d928.js",
"file": "plugin-batch-export.496febf1312c.js",
"version": "1.2.3",
"integrity": "sha256-4BUt6NkoAWOoCk1omq3EcE3CZdexZyEqs9qeYqtnwb0="
"integrity": "sha256-SW/r8TEs+kQbYnZp0jw8b2lF0wDgxZhvwC0c/DwoOiQ="
},
{
"id": "blank-canvas",
@@ -33,10 +33,10 @@
"dir": "gallery",
"main": "main.js",
"style": "styles.css",
"version": "1.9.8",
"version": "1.9.9",
"files": {
"main.js": "8586409417599dec4b0f229e88eaf937f991f1942db49df97ce9a27e16a35d9f",
"styles.css": "c7db0f9d78b98c1b5bb9782c45dfc2274673c1c7d34fdf676aae41680866eb3d"
"main.js": "22b2d8aa07ec193703d57603e857a6e48e054874ef943603d2ed7b1f3c560fd9",
"styles.css": "07ca657d2e5f5d9406e6c7f7306906e34f2ee10a2fa4c2165358451f5461c6a4"
}
},
{
@@ -55,23 +55,23 @@
"dir": "promptlib",
"main": "main.js",
"style": "styles.css",
"version": "1.14.10",
"version": "1.14.11",
"files": {
"main.js": "a05ce22ad8ab2e079e313dd31d8fe34f2e2e07e017bfb782afcd08047e0b485b",
"styles.css": "86f73b4d1c7b827f97ec1135c9130c7da6898537b2ed2ab815e282618232f56b"
"main.js": "c807d9ce8b1a7df851e00dd724e585d3158b2031194e71ca154d3def383385d7",
"styles.css": "182783b15335895b5a40822bf137a7b4872ca0c6ee72434bfa61a97b37453a07"
}
},
{
"id": "image-annotate",
"file": "plugin-image-annotate.fda7cfeefb9b.js",
"file": "plugin-image-annotate.ce58bab92abd.js",
"version": "1.20.9",
"integrity": "sha256-/afP7vub8Psm2dGzos2M4fcE/GxmS2I9Jvx523xCZr0="
"integrity": "sha256-zli6uSq9AazBsk5fqfkoWrSzA0Ki/NaESekszQA+IRA="
},
{
"id": "image-vectorize",
"file": "plugin-image-vectorize.2d9e6c796bf6.js",
"file": "plugin-image-vectorize.b3a8c21f7a2b.js",
"version": "0.6.2",
"integrity": "sha256-LZ5seWv25KomL7q8Wa5VGALyj16HWk805YbLyUEDgPs="
"integrity": "sha256-s6jCH3or6tQZ5umJnZ/ka6nk+n5np3elAFaUK1aPV9E="
},
{
"id": "sticky",
@@ -87,14 +87,14 @@
},
{
"id": "white-bg-800",
"file": "plugin-white-bg-800.988d72d6f09d.js",
"file": "plugin-white-bg-800.ffc18c23ed74.js",
"version": "1.2.2",
"integrity": "sha256-mI1y1vCd5IF8UTGdOzggB4OnCpQrQkmCclL6y9w86IE="
"integrity": "sha256-/8GMI+10+BZHc63Df5B+t7KyxGpj8MonfblJ7/xWizM="
},
{
"id": "xianyi-cutout",
"file": "plugin-xianyi-cutout.84907706bb31.js",
"file": "plugin-xianyi-cutout.f7898f6e0fe9.js",
"version": "1.0.4",
"integrity": "sha256-hJB3Brsx1krtgrhXhEg7kTNTAaitQeDkSBOiud/he0c="
"integrity": "sha256-94mPbg/p+Pikvfkc59u+U4wPJ+45jc46JTlNptVZIB0="
}
]
+1 -1
View File
@@ -2244,7 +2244,7 @@
global.IWBPluginHost.register({
id: 'promptlib',
name: '提示词库',
version: '1.14.9',
version: '1.14.11',
apiVersion: 1,
capabilities: ['panels', 'promptlib', 'nodeTypes', 'canvas', 'canvasWrite', 'nodeActions', 'commands'],
data: { schemaVersion: 3, maxBytes: 4 * 1024 * 1024 },
+3 -3
View File
@@ -1,7 +1,7 @@
{
"id": "promptlib",
"name": "提示词库",
"version": "1.14.10",
"version": "1.14.11",
"apiVersion": 1,
"main": "main.js",
"style": "styles.css",
@@ -13,7 +13,7 @@
"提示词"
],
"files": {
"main.js": "a05ce22ad8ab2e079e313dd31d8fe34f2e2e07e017bfb782afcd08047e0b485b",
"styles.css": "86f73b4d1c7b827f97ec1135c9130c7da6898537b2ed2ab815e282618232f56b"
"main.js": "c807d9ce8b1a7df851e00dd724e585d3158b2031194e71ca154d3def383385d7",
"styles.css": "182783b15335895b5a40822bf137a7b4872ca0c6ee72434bfa61a97b37453a07"
}
}
+3 -3
View File
@@ -379,7 +379,7 @@ box-shadow: 0 24px 60px rgba(0,0,0,.32);
/* v1.6.8:卡片悬停放大 + 按下/拖拽反馈 */
.iwb-plp-card{transition:transform .14s ease, box-shadow .14s ease, border-color .14s ease, opacity .14s ease}
.iwb-plp-card:hover{transform:scale(1.03);box-shadow:0 8px 22px rgba(0,0,0,.14);z-index:2}
.iwb-plp-card:hover{border-color:var(--iwb-border2,#b9bfca)}
.iwb-plp-card.is-pressed{border-color:var(--iwb-plp-accent,#7c4dff);box-shadow:0 0 0 2px color-mix(in srgb,var(--iwb-plp-accent,#7c4dff) 22%,transparent)}
.iwb-plp-card.is-dragging{opacity:.55;transform:scale(.98)}
@@ -391,9 +391,9 @@ box-shadow: 0 24px 60px rgba(0,0,0,.32);
.iwb-plp-ghosthint{font-size: 11px;color:var(--iwb-plp-accent,#5a4bd0)}
/* v1.6.10:悬停放大改为「内层背景层缩放」——卡片命中区域不变,渐变卡不再闪烁 */
.iwb-plp-bg{position:absolute;inset:0;overflow:hidden;border-radius:inherit;transition:transform .16s ease;will-change:transform;backface-visibility:hidden}
.iwb-plp-bg{position:absolute;inset:0;overflow:hidden;border-radius:inherit;transition:transform .16s ease;backface-visibility:hidden}
.iwb-plp-card:hover .iwb-plp-bg{transform:scale(1.045)}
.iwb-plp-card:hover{border-color:var(--iwb-border2,#b9bfca);box-shadow:0 8px 22px rgba(0,0,0,.14)}
.iwb-plp-card:hover{border-color:var(--iwb-border2,#b9bfca)}
/* 取消卡片本体的缩放/层级切换(闪烁与边缘点击丢失的来源) */
.iwb-plp-card{transform:none}
.iwb-plp-card:hover{transform:none;z-index:auto}
@@ -510,7 +510,7 @@
global.IWBPluginHost.register({
id: 'batch-export',
name: '批量出图',
version: '1.2.2',
version: '1.2.3',
apiVersion: 1,
capabilities: ['panels', 'canvas'],
settings: {
@@ -11,7 +11,7 @@
var __IWB_ANNOTATE_MANIFEST__ = {
id: 'image-annotate',
name: '标注 / 修图',
version: '1.20.8',
version: '1.20.9',
apiVersion: 1,
skin: 'private',
capabilities: ['commands', 'nodeActions', 'canvas', 'canvasWrite'],
@@ -11,7 +11,7 @@
var __IWB_VECTORIZE_MANIFEST__ = {
id: 'image-vectorize',
name: '位图转矢量',
version: '0.6.1',
version: '0.6.2',
apiVersion: 1,
skin: 'private',
capabilities: ['commands', 'nodeActions', 'canvas', 'canvasWrite'],
@@ -145,7 +145,7 @@
global.IWBPluginHost.register({
id: 'white-bg-800',
name: '白底图',
version: '1.2.1',
version: '1.2.2',
apiVersion: 1,
capabilities: ['commands', 'canvas', 'canvasWrite', 'nodeActions'],
settings: {
@@ -37,7 +37,7 @@
global.IWBPluginHost.register({
id: 'xianyi-cutout',
name: '鲜艺抠图',
version: '1.0.3',
version: '1.0.4',
apiVersion: 1,
capabilities: ['commands', 'canvas', 'canvasWrite', 'nodeActions'],
settings: {
+4
View File
@@ -102,6 +102,9 @@ const sourceModules = [
'ui-dock-panels.js',
'theme-tokens.js',
'canvas-grid.js',
'canvas-v3.js',
'canvas-v3-node-layer.js',
'canvas-v3-hit.js',
'image-display-thumb.js',
'image-cache-migrate.js',
'runtime-frame-probe.js',
@@ -129,6 +132,7 @@ const sourceModules = [
'runtime-plugin-market.js',
'runtime-plugin-backup.js',
'ui-canvas-view.js',
'ui-canvas-edges.js',
'ui-canvas-pointer.js',
'ui-canvas-nodes.js',
'ui-confirm.js',
+42
View File
@@ -0,0 +1,42 @@
// 插件清单纯函数:内容寻址命名 + SRI integrity。
//
// 桌面端插件清单 plugins/index.json 由 scripts/sync-plugins-from-repo.js 生成,
// 市场 zip 由 scripts/gen-market.js 生成;两条链路都依赖这里的哈希/命名规则。
// 历史上这些函数长在 scripts/plugins-publish.mjs(直写 Cloudflare KV 的网页版发布脚本),
// 网页版已停用,脚本删除,纯函数留在此处给同步脚本与测试复用。
import { createHash } from 'node:crypto'
import { basename } from 'node:path'
export const integrityOf = (buffer) => 'sha256-' + createHash('sha256').update(buffer).digest('base64')
export const idFromFile = (file) => {
const base = basename(String(file))
const m = /^plugin-([a-z][a-z0-9-]{2,31})\.js$/.exec(base)
return m ? m[1] : ''
}
// 内容寻址存储名:同 id + 同字节 ⇒ 同名(幂等);字节变 ⇒ 名变 ⇒ 客户端永不拿到陈旧缓存
export const storedNameOf = (id, buffer) => {
if (!/^[a-z][a-z0-9-]{2,31}$/.test(String(id))) throw new Error('非法插件 id:' + id)
return 'plugin-' + id + '.' + createHash('sha256').update(buffer).digest('hex').slice(0, 12) + '.js'
}
export const buildIndex = (entries) => {
const seen = new Set()
const out = []
for (const e of entries) {
if (!e || !e.id || !e.file || !e.integrity) throw new Error('清单项缺字段:' + JSON.stringify(e))
if (seen.has(e.id)) throw new Error('插件 id 重复:' + e.id)
seen.add(e.id)
out.push({ id: e.id, file: e.file, version: e.version || '', integrity: e.integrity })
}
return out.sort((a, b) => a.id.localeCompare(b.id))
}
// 并入既有清单:本次**未提供**文件的插件予以保留(incoming 同 id 覆盖旧的)。
// 2026-11-03 事故:只按传入文件重建清单 ⇒ 单发一个插件就把其余插件从清单里抹掉。
export const mergeIndexes = (existing, incoming) => {
const incomingIds = new Set(incoming.map((e) => e.id))
const kept = (Array.isArray(existing) ? existing : []).filter((e) => e && e.id && e.file && e.integrity && !incomingIds.has(e.id))
return buildIndex([...incoming, ...kept])
}
-297
View File
@@ -1,297 +0,0 @@
// A2 插件发布:为每个插件文件算 SHA-256(SRI integrity)→ 以内容寻址名 plugin-<id>.<hash12>.js 入库 → 写 plugins/index.json →(可选)上传 KV。
//
// 用法:
// node scripts/plugins-publish.mjs <plugin-<id>.js ...> [--out plugins/index.json] [--kv-id <namespaceId>] [--version <id>=<ver>] [--upload] [--prune]
// node scripts/plugins-publish.mjs --gc [--delete] [--keep <id>] # 列出(并删除)KV 里线上清单不再引用的陈旧插件键
// --keep 用于「归档保留」的插件(如 ai-chat:移出清单但字节留 KV 待启用),可重复。
//
// 默认 **dry-run**:只写本地清单并打印计划;只有显式 --upload 才会写线上 KV。
//
// 上传走 **Cloudflare REST API**(2026-11-03 起),不再 spawn `npx wrangler`:
// PUT /accounts/<acct>/storage/kv/namespaces/<ns>/values/<urlenc key>
// GET /accounts/<acct>/storage/kv/namespaces/<ns>/values/<urlenc key>
// GET /accounts/<acct>/storage/kv/namespaces/<ns>/keys?prefix=plugins/
// DELETE /accounts/<acct>/storage/kv/namespaces/<ns>/bulk (body = key 数组)
// 原因:wrangler v3/v4 的子命令名不同(`kv:key put` / `kv key put`),靠 spawnSync 传参数永远踩版本坑。
// 凭据:CLOUDFLARE_API_TOKEN + CLOUDFLARE_ACCOUNT_ID;macOS 上缺失时自动回退读钥匙串
// (服务名 CLOUDFLARE_PAGES_TOKEN / CLOUDFLARE_ACCOUNT_ID)。token 需 **Account → Workers KV Storage → Edit**。
//
// version 默认从既有 --out 清单里按 id 保留;要改版本用 --version <id>=<ver>。
// 清单**默认与既有清单合并**:本次未传入的插件原样保留(同 id 覆盖)。要缩减清单必须显式 --prune
// (2026-11-03:旧版只按命令行文件重建 ⇒ 单发 style-source 就把另外 5 个抹掉,插件管理页只剩 1 个)。
// 运行时宿主读 /plugins/index.json 的 integrity,用 <script integrity> 交给浏览器强制校验(不符即拒绝执行)。
//
// 存储名为内容寻址:storedNameOf(id, bytes) = plugin-<id>.<sha256前12位hex>.js。同字节 ⇒ 同名(幂等);内容变 ⇒ 名变。
// 因此 Pages Function 可对带哈希文件名发 `cache-control: public, max-age=31536000, immutable`。
// 内容变化后 KV 会同时保留**新旧哈希键**(旧键不再被清单引用)⇒ 用 --gc 清理(默认只列出,加 --delete 才删)。
import { createHash } from 'node:crypto'
import { spawnSync } from 'node:child_process'
import { readFileSync, writeFileSync, existsSync, mkdirSync } from 'node:fs'
import { basename, dirname, join, resolve } from 'node:path'
import { fileURLToPath } from 'node:url'
const ROOT = resolve(dirname(fileURLToPath(import.meta.url)), '..')
const CF_API = 'https://api.cloudflare.com/client/v4'
const REQ_TIMEOUT_MS = 30000
export const integrityOf = (buffer) => 'sha256-' + createHash('sha256').update(buffer).digest('base64')
export const idFromFile = (file) => {
const base = basename(String(file))
const m = /^plugin-([a-z][a-z0-9-]{2,31})\.js$/.exec(base)
return m ? m[1] : ''
}
// 内容寻址存储名:同 id + 同字节 ⇒ 同名(幂等);字节变 ⇒ 名变 ⇒ 客户端永不拿到陈旧缓存
export const storedNameOf = (id, buffer) => {
if (!/^[a-z][a-z0-9-]{2,31}$/.test(String(id))) throw new Error('非法插件 id:' + id)
return 'plugin-' + id + '.' + createHash('sha256').update(buffer).digest('hex').slice(0, 12) + '.js'
}
export const buildIndex = (entries) => {
const seen = new Set()
const out = []
for (const e of entries) {
if (!e || !e.id || !e.file || !e.integrity) throw new Error('清单项缺字段:' + JSON.stringify(e))
if (seen.has(e.id)) throw new Error('插件 id 重复:' + e.id)
seen.add(e.id)
out.push({ id: e.id, file: e.file, version: e.version || '', integrity: e.integrity })
}
return out.sort((a, b) => a.id.localeCompare(b.id))
}
// 并入既有清单:本次**未提供**文件的插件予以保留(incoming 同 id 覆盖旧的)。
// 2026-11-03 事故:旧版只拿命令行文件重建清单 ⇒ 单发一个插件就把另外 5 个从清单里抹掉
// (字节还在 KV,但插件管理页只剩 1 个)。默认必须合并;确要缩减清单走 --prune。
export const mergeIndexes = (existing, incoming) => {
const incomingIds = new Set(incoming.map((e) => e.id))
const kept = (Array.isArray(existing) ? existing : []).filter((e) => e && e.id && e.file && e.integrity && !incomingIds.has(e.id))
return buildIndex([...incoming, ...kept])
}
// 陈旧键 = KV 里 plugins/ 下、但**线上清单不再引用**的键(清单自身永远保留)。
// keep 可传插件 id 或完整键(如 'ai-chat' / 'plugins/plugin-ai-chat.824397a8e54b.js'),用于**归档保留**的插件:
// ai-chat 就是「移出清单但字节留在 KV 等启用」的形态,不加 keep 会被当成垃圾。
// 纯函数便于单测;调用方必须以线上清单为准,不能用本地文件(否则本地落后时会误删)。
export const staleKeys = (keys, index, keep = []) => {
const keepSet = new Set(['plugins/index.json'])
for (const e of Array.isArray(index) ? index : []) if (e && e.file) keepSet.add('plugins/' + e.file)
const keeps = (Array.isArray(keep) ? keep : []).map(String).filter(Boolean)
const kept = (key) => keeps.some((p) => key === p || key === 'plugins/' + p || key.startsWith('plugins/plugin-' + p + '.'))
return (Array.isArray(keys) ? keys : [])
.map(String)
.filter((k) => k.startsWith('plugins/') && !keepSet.has(k) && !kept(k))
.sort()
}
const readKvId = () => {
try {
const toml = readFileSync(join(ROOT, 'wrangler.toml'), 'utf8')
const i = toml.indexOf('binding = "PLUGINS"')
if (i < 0) return ''
const m = /id = "([^"]+)"/.exec(toml.slice(i))
return m ? m[1] : ''
} catch (e) { return '' }
}
const readEntries = (outPath) => {
try {
const parsed = JSON.parse(readFileSync(outPath, 'utf8'))
const list = Array.isArray(parsed) ? parsed : (parsed && Array.isArray(parsed.plugins) ? parsed.plugins : [])
return list.filter((e) => e && e.id && e.file && e.integrity)
} catch (e) { return [] }
}
const readVersions = (outPath) => {
const map = new Map()
for (const e of readEntries(outPath)) map.set(String(e.id), String(e.version || ''))
return map
}
// —— 凭据:env 优先,macOS 回退钥匙串(本机 token 就存在那儿)——
const keychain = (service) => {
try {
const r = spawnSync('security', ['find-generic-password', '-s', service, '-w'], { encoding: 'utf8' })
return r.status === 0 ? String(r.stdout || '').trim() : ''
} catch (e) { return '' }
}
const resolveCreds = () => {
let token = String(process.env.CLOUDFLARE_API_TOKEN || '').trim()
let account = String(process.env.CLOUDFLARE_ACCOUNT_ID || '').trim()
if (!token && process.platform === 'darwin') token = keychain('CLOUDFLARE_PAGES_TOKEN')
if (!account && process.platform === 'darwin') account = keychain('CLOUDFLARE_ACCOUNT_ID')
if (!token) throw new Error('缺少 CLOUDFLARE_API_TOKEN(该 token 需 Account → Workers KV Storage → Edit)')
if (!account) throw new Error('缺少 CLOUDFLARE_ACCOUNT_ID')
return { token, account }
}
const kvBase = (creds, kvId) => CF_API + '/accounts/' + creds.account + '/storage/kv/namespaces/' + kvId
const kvValueUrl = (creds, kvId, key) => kvBase(creds, kvId) + '/values/' + encodeURIComponent(key)
const cfJson = async (creds, url, init) => {
const r = await fetch(url, Object.assign({
headers: Object.assign({ Authorization: 'Bearer ' + creds.token }, (init && init.contentType) ? { 'content-type': init.contentType } : {}),
signal: AbortSignal.timeout(REQ_TIMEOUT_MS),
}, init ? { method: init.method, body: init.body } : {}))
const text = await r.text()
let json = null
try { json = JSON.parse(text) } catch (e) { /* 非 JSON 响应 */ }
if (!r.ok || (json && json.success === false)) {
const detail = (json && json.errors && json.errors[0] && json.errors[0].message) || text.slice(0, 200) || '(空响应)'
throw new Error('Cloudflare API ' + r.status + ':' + detail)
}
return json
}
const kvPut = async (creds, kvId, key, body) => {
await cfJson(creds, kvValueUrl(creds, kvId, key), { method: 'PUT', body, contentType: 'text/plain; charset=utf-8' })
}
const kvGetText = async (creds, kvId, key) => {
const r = await fetch(kvValueUrl(creds, kvId, key), {
headers: { Authorization: 'Bearer ' + creds.token },
signal: AbortSignal.timeout(REQ_TIMEOUT_MS),
})
if (!r.ok) throw new Error('读取 KV 失败 ' + r.status + ':' + key)
return await r.text()
}
const kvListPluginKeys = async (creds, kvId) => {
const out = []
let cursor = ''
for (;;) {
const url = kvBase(creds, kvId) + '/keys?limit=1000&prefix=' + encodeURIComponent('plugins/') + (cursor ? '&cursor=' + encodeURIComponent(cursor) : '')
const json = await cfJson(creds, url)
for (const k of (json && json.result) || []) out.push(String(k.name))
cursor = String((json && json.result_info && json.result_info.cursor) || '')
if (!cursor) break
}
return out
}
const kvDeleteKeys = async (creds, kvId, keys) => {
if (!keys.length) return
await cfJson(creds, kvBase(creds, kvId) + '/bulk', { method: 'DELETE', body: JSON.stringify(keys), contentType: 'application/json' })
}
const main = async () => {
const argv = process.argv.slice(2)
const files = []
let outPath = join(ROOT, 'plugins', 'index.json')
let kvId = ''
let upload = false
let prune = false
let gc = false
let del = false
const keeps = []
const overrides = new Map()
for (let i = 0; i < argv.length; i++) {
const a = argv[i]
if (a === '--upload') upload = true
else if (a === '--prune') prune = true
else if (a === '--gc') gc = true
else if (a === '--delete') del = true
else if (a === '--keep') keeps.push(String(argv[++i] || ''))
else if (a === '--out') outPath = resolve(argv[++i] || '')
else if (a === '--kv-id') kvId = String(argv[++i] || '')
else if (a === '--version') { const kv = String(argv[++i] || ''); const eq = kv.indexOf('='); if (eq > 0) overrides.set(kv.slice(0, eq), kv.slice(eq + 1)) }
else if (a.startsWith('--')) throw new Error('未知参数:' + a)
else files.push(a)
}
if (!files.length && !gc) throw new Error('至少给一个 plugin-<id>.js 文件(只想清理陈旧键用 --gc)')
if ((upload || gc) && !kvId) kvId = readKvId()
if (del && !gc) throw new Error('--delete 只能与 --gc 一起用(避免误删)')
const creds = (upload || gc) ? resolveCreds() : null
if ((upload || gc) && !kvId) throw new Error('未找到 KV namespace id:用 --kv-id 指定,或在 wrangler.toml 里确认 binding = "PLUGINS"')
let index = readEntries(outPath)
let entries = []
if (files.length) {
const versions = readVersions(outPath)
entries = files.map((f) => {
const abs = resolve(f)
if (!existsSync(abs)) throw new Error('文件不存在:' + abs)
const id = idFromFile(abs)
if (!id) throw new Error('文件名须为 plugin-<id>.js(id 须 ^[a-z][a-z0-9-]{2,31}$):' + basename(abs))
const bytes = readFileSync(abs)
return { id, file: storedNameOf(id, bytes), version: overrides.get(id) || versions.get(id) || '', integrity: integrityOf(bytes), abs }
})
// 默认合并:未在本次传入的插件原样保留(同 id 由新条目覆盖)
const prev = prune ? [] : readEntries(outPath)
index = mergeIndexes(prev, entries)
const kept = index.length - entries.length
mkdirSync(dirname(outPath), { recursive: true })
writeFileSync(outPath, JSON.stringify(index, null, 2) + '\n')
console.log('[plugins-publish] 已写清单 ' + outPath + '(共 ' + index.length + ' 个,本次发布 ' + entries.length + ' 个' + (kept > 0 ? ',保留既有 ' + kept + ' 个' : '') + ')')
for (const e of index) console.log(' ' + e.id + ' ' + e.file + ' ' + e.integrity)
}
const plan = () => {
console.log('[plugins-publish] 将写 KV(REST,' + kvId + '):')
for (const e of entries) console.log(' PUT plugins/' + e.file + ' (' + e.abs + ')')
if (files.length) console.log(' PUT plugins/index.json (' + outPath + ')')
}
if (!upload && !gc) {
console.log('[plugins-publish] dry-run(未上传)。加 --upload 才会写 KV:')
plan()
return
}
if (upload) {
// 只上传本次传入的插件字节(保留项已在 KV 里,无需重传)
for (const e of entries) await kvPut(creds, kvId, 'plugins/' + e.file, readFileSync(e.abs))
if (files.length) await kvPut(creds, kvId, 'plugins/index.json', readFileSync(outPath))
// 回读校验:写成功 ≠ 内容对(曾经清单被覆写成 1 条就是这么发生的)
if (files.length) {
const remote = JSON.parse(await kvGetText(creds, kvId, 'plugins/index.json'))
const a = JSON.stringify(remote)
const b = JSON.stringify(readEntries(outPath))
if (a !== b) throw new Error('回读校验失败:KV 里的 plugins/index.json 与本地清单不一致')
console.log('[plugins-publish] 回读校验通过(线上清单 ' + remote.length + ' 条与本地一致)')
}
console.log('[plugins-publish] 已上传 ' + entries.length + ' 个插件' + (files.length ? ' + 清单' : '') + ' 到 KV ' + kvId)
}
if (gc) await runGc(creds, kvId, del, keeps)
}
const runGc = async (creds, kvId, del, keeps = []) => {
// 以**线上清单**为准判定引用关系(本地清单可能落后于线上)
let online = []
try {
online = JSON.parse(await kvGetText(creds, kvId, 'plugins/index.json'))
} catch (e) {
throw new Error('GC 中止:读不到线上 plugins/index.json(' + ((e && e.message) || e) + ')——不能用本地清单猜,否则会误删')
}
const keys = await kvListPluginKeys(creds, kvId)
const stale = staleKeys(keys, online, keeps)
console.log('[plugins-publish] KV 共 ' + keys.length + ' 个 plugins/ 键,线上清单引用 ' + online.length + ' 个,陈旧 ' + stale.length + ' 个' + (keeps.length ? '(保留 ' + keeps.join(', ') + ')' : ''))
for (const k of stale) console.log(' 陈旧 ' + k)
if (!stale.length) return
const archived = stale.filter((k) => /plugin-ai-chat\./.test(k))
if (archived.length) {
console.log('[plugins-publish] ⚠️ ' + archived.join('、') + ' 属「归档但保留待启用」的插件(移出清单、字节留 KV),')
console.log(' 删掉后要重新上传字节才能再启用。要保留就加 --keep ai-chat。')
}
if (!del) {
console.log('[plugins-publish] 仅列出(未删除)。确认无误后加 --delete 真正删除:node scripts/plugins-publish.mjs --gc --delete [--keep ai-chat]')
return
}
await kvDeleteKeys(creds, kvId, stale)
console.log('[plugins-publish] 已删除 ' + stale.length + ' 个陈旧键')
}
if (process.argv[1] && resolve(process.argv[1]) === resolve(fileURLToPath(import.meta.url))) {
main().catch((e) => {
console.error('[plugins-publish] ' + ((e && e.message) || e))
process.exit(1)
})
}
-148
View File
@@ -1,148 +0,0 @@
#!/usr/bin/env bash
# A2 插件发布:把插件上传到 KV(同源 /plugins/* 由 Functions 提供)并更新清单。
# 上传后**刷新浏览器即生效** —— 不需要重编译、不需要 deploy 主仓。
# 会为插件算 SHA-256(SRI integrity)写入清单 —— 运行时 fail-closed 校验所必需(缺失即拒载)。
#
# 用法:
# scripts/plugins-publish.sh <插件 id> <插件文件路径> [版本号]
# scripts/plugins-publish.sh <插件 id> --remove # 从清单移除(KV 里的文件保留)
#
# 例:
# scripts/plugins-publish.sh whitebg /path/to/iwb-plugins/whitebg/src/index.js 1.2.0
set -euo pipefail
usage() { sed -n '2,10p' "${BASH_SOURCE[0]}" | sed 's/^# \{0,1\}//'; }
ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
ID="${1:-}"
ARG="${2:-}"
VERSION="${3:-}"
if [ -z "$ID" ] || [ -z "$ARG" ]; then usage; exit 2; fi
if ! [[ "$ID" =~ ^[a-z][a-z0-9-]{2,31}$ ]]; then echo "插件 id 不合法:须匹配 ^[a-z][a-z0-9-]{2,31}$" >&2; exit 2; fi
NS_ID="$(awk '/^\[\[kv_namespaces\]\]/{f=1} f&&/^id *=/{gsub(/[" ]/,"",$3); print $3; exit}' "$ROOT/wrangler.toml")"
if [ -z "$NS_ID" ]; then echo "未能在 wrangler.toml 找到 KV namespace id" >&2; exit 1; fi
# ── 读取线上清单(fail-closed)────────────────────────────────────────────
# 旧写法 `... 2>/dev/null || true` 把网络/授权/代理失败也吞成空串,随后被当成 '[]',
# 于是写回时**只剩本次发布的插件**,其余全部从清单消失。
# 2026-11-08 真实发生:image-annotate 1.8.2 发布后清单从 7 条塌成 1 条。
# 现在只有「键确实不存在」才允许从空清单开始,其余情况一律中止。
KV_ERR="$(mktemp)"
if CUR_RAW="$(npx --yes wrangler kv key get --namespace-id="$NS_ID" --remote "plugins/index.json" 2>"$KV_ERR")"; then
CUR="$CUR_RAW"
case "$CUR" in
\[*|{*) ;;
*)
echo "✗ 线上清单读取成功但不是合法 JSON,拒绝继续(避免把它覆盖成单条清单)" >&2
printf '%s\n' "$CUR" | head -c 200 >&2; echo >&2
rm -f "$KV_ERR"; exit 1 ;;
esac
else
if grep -qiE "not found|does not exist|no such key|404" "$KV_ERR" 2>/dev/null; then
CUR='[]'
echo "[plugins-publish] 线上清单尚不存在,将新建"
else
echo "✗ 读取线上清单失败 —— 拒绝继续。" >&2
echo " 继续下去会用「只有本次插件」的清单覆盖线上,把其他插件全部下架。" >&2
sed -n '1,4p' "$KV_ERR" >&2
rm -f "$KV_ERR"; exit 1
fi
fi
rm -f "$KV_ERR"
if [ "$ARG" = "--remove" ]; then
NEXT="$(node -e 'const cur=JSON.parse(process.argv[1]||"[]");const id=process.argv[2];process.stdout.write(JSON.stringify(cur.filter(x=>x&&x.id!==id),null,2))' "$CUR" "$ID")"
TMP="$(mktemp)"; printf '%s\n' "$NEXT" > "$TMP"
npx --yes wrangler kv key put --namespace-id="$NS_ID" --remote "plugins/index.json" --path="$TMP"
echo "[plugins-publish] 已从清单移除 $ID"
exit 0
fi
FILE="$ARG"
if [ ! -f "$FILE" ]; then echo "插件文件不存在:$FILE" >&2; exit 1; fi
if ! head -c 4096 "$FILE" | grep -q "IWBPluginHost"; then
echo "警告:$FILE 里没看到 IWBPluginHost.register —— 请确认这确实是插件产物。" >&2
fi
# ── 主干卫生前置校验(2026-11-05 立规,详见 HANDBOOK 第八节)─────────────
# 背景:本脚本直写 CF KV、绕开 git,曾导致 iwb-plugins 的 main 落后 40 个提交、
# 线上版本与 commit 断链。发布前强制:插件所在仓库工作区干净 + HEAD 已在 origin/main。
# 紧急热修可 IWB_PUBLISH_SKIP_CHECKS=1 跳过(事后必须补 tag 与合并)。
PLUGIN_REPO="$(git -C "$(dirname "$FILE")" rev-parse --show-toplevel 2>/dev/null || true)"
if [ "${IWB_PUBLISH_SKIP_CHECKS:-0}" != "1" ]; then
if [ -z "$PLUGIN_REPO" ]; then
echo "⚠ 未识别插件所属 git 仓库(${FILE}),跳过主干校验" >&2
else
if [ -n "$(git -C "$PLUGIN_REPO" status --porcelain 2>/dev/null)" ]; then
echo "✗ 工作区不干净:$PLUGIN_REPO" >&2
git -C "$PLUGIN_REPO" status --porcelain | sed -n '1,5p' >&2
echo " 先提交并推送,再发布;紧急热修可设 IWB_PUBLISH_SKIP_CHECKS=1" >&2
exit 1
fi
if ! git -C "$PLUGIN_REPO" fetch -q origin main 2>/dev/null; then
echo "⚠ 无法 fetch origin/main(离线发布可设 IWB_PUBLISH_SKIP_CHECKS=1)" >&2
fi
if git -C "$PLUGIN_REPO" rev-parse --verify -q origin/main >/dev/null 2>&1 \
&& ! git -C "$PLUGIN_REPO" merge-base --is-ancestor HEAD origin/main; then
echo "✗ 当前 HEAD 不在 origin/main 上(分支:$(git -C "$PLUGIN_REPO" rev-parse --abbrev-ref HEAD))" >&2
echo " 先把分支合进 main(纯祖先用 --ff-only)再发布,否则线上版本会与主干断链。" >&2
exit 1
fi
fi
fi
# 存储名内容寻址:plugin-<id>.<sha256前12位hex>.js(与 plugins-publish.mjs 的 storedNameOf 一致)
#
# 曾用固定名 plugin-<id>.js,2026-11-08 因此出过一次线上事故:
# 客户端缓存里还是旧字节,清单却已是新 integrity ⇒ 浏览器 SRI 判定失败,
# 报「脚本完整性校验失败(integrity 不符或加载失败)」,插件直接不可用。
# 固定名的 no-cache + ETag 只能要求「回源校验」,管不住中间层与浏览器内存缓存的旧副本。
# 内容寻址后:内容变 ⇒ 文件名变 ⇒ 新版本必然是新 URL,SRI 必中;
# 同时命中 Functions 的 IMMUTABLE_JS_RE ⇒ public, max-age=31536000, immutable。
# 代价:KV 会累积不再被清单引用的旧哈希键(无害),需要时用 plugins-publish.mjs --gc 清理。
HASH12="$(node -e 'const c=require("crypto"),fs=require("fs");process.stdout.write(c.createHash("sha256").update(fs.readFileSync(process.argv[1])).digest("hex").slice(0,12))' "$FILE")"
INTEGRITY="$(node -e 'const c=require("crypto"),fs=require("fs");process.stdout.write("sha256-"+c.createHash("sha256").update(fs.readFileSync(process.argv[1])).digest("base64"))' "$FILE")"
BASENAME="plugin-$ID.$HASH12.js"
echo "[plugins-publish] 上传 $BASENAME 到 KV(integrity=${INTEGRITY})"
npx --yes wrangler kv key put --namespace-id="$NS_ID" --remote "plugins/$BASENAME" --path="$FILE"
NEXT="$(node -e 'const cur=JSON.parse(process.argv[1]||"[]");const [id,file,ver,integ]=process.argv.slice(2);const out=cur.filter(x=>x&&x.id!==id);out.push(Object.assign({id,file},ver?{version:ver}:{},integ?{integrity:integ}:{}));out.sort((a,b)=>String(a.id).localeCompare(String(b.id)));process.stdout.write(JSON.stringify(out,null,2))' "$CUR" "$ID" "$BASENAME" "$VERSION" "$INTEGRITY")"
# 第二道保险:清单条数只允许「不变」或「+1」(新增插件),减少即视为异常。
# 只替换本次插件那一条时,条数必须与旧清单相同。
COUNT_OF='const v=JSON.parse(process.argv[1]||"[]");process.stdout.write(String(Array.isArray(v)?v.length:0))'
OLD_N="$(node -e "$COUNT_OF" "$CUR")"
NEW_N="$(node -e "$COUNT_OF" "$NEXT")"
if [ "$OLD_N" -ge 2 ] && [ "$NEW_N" -lt "$OLD_N" ]; then
echo "✗ 清单条数将从 ${OLD_N} 降到 ${NEW_N} —— 拒绝写入。" >&2
echo " 正常发布只替换本插件那一条,条数不应减少。检查线上清单是否被并发改动。" >&2
exit 1
fi
echo "[plugins-publish] 清单:${OLD_N} 条 → ${NEW_N} 条"
TMP="$(mktemp)"; printf '%s\n' "$NEXT" > "$TMP"
npx --yes wrangler kv key put --namespace-id="$NS_ID" --remote "plugins/index.json" --path="$TMP"
# 本地快照同步:本脚本直写 KV、绕开 git,但仓库里那份 plugins/index.json 是「线上清单应有的样子」
# 的记录。不同步的后果不是「少个文件」,而是下次有人(或旧脚本)拿这份旧文件当基线发布时,
# 把线上清单**整体回退**到旧版本 —— 2026-11-03 就因此把 7 条塌成 1 条。
# 这里只写文件不提交,让 git status 把它亮出来。
printf '%s\n' "$NEXT" > "$ROOT/plugins/index.json"
echo "[plugins-publish] 本地 plugins/index.json 已同步(记得提交)"
echo "[plugins-publish] 已发布 ${ID} (${BASENAME}${VERSION:+ @$VERSION})"
# 发布即可反查:打 插件id@版本 tag(仅在 HEAD 已确认在 origin/main 上时)
if [ -n "$VERSION" ] && [ -n "${PLUGIN_REPO:-}" ] && [ "${IWB_PUBLISH_SKIP_CHECKS:-0}" != "1" ]; then
TAG="$ID@$VERSION"
if git -C "$PLUGIN_REPO" rev-parse -q --verify "refs/tags/$TAG" >/dev/null; then
echo "[plugins-publish] tag $TAG 已存在,跳过"
else
git -C "$PLUGIN_REPO" tag -a "$TAG" -m "插件发布:$ID ${VERSION}(KV 已上线)"
echo "[plugins-publish] 已打 tag $TAG → 记得:git -C \"$PLUGIN_REPO\" push origin \"$TAG\""
fi
fi
echo "→ 刷新浏览器即生效。管理面板「插件管理」→「远程加载(KV)」可看到状态。"
-175
View File
@@ -1,175 +0,0 @@
#!/usr/bin/env node
/**
* 发布核验(基于 version.json):一次检查三个线上地址的 version.json 是否与 package.json 一致。
*
* 为什么需要:每次发布我都要手工 curl 三个地址比对版本;且要注意
* —— **docs-only 提交**会让本地 git sha 与线上 sha 不同(线上仍是上一个代码提交),
* 因此本脚本**只强校验版本号**,commit 仅作信息展示,避免误报失败 ✗。
*
* 校验方式:抓取 `<host>/version.json?cb=<ts>`,JSON 解析后比对 `.version`
* 与 `v<packageVersion>`(接受精确 `v<ver>` 或前缀 `v<ver>+`)。
*
* ── 严格模式(2026-10-20 新增)────────────────────────────────────────
* 背景(为什么会加):2026-10-20 实测发现**线上跑着 `f414fd8`,而 `origin/main` 仍是 `7a48e4b`** ——
* 那 4 个 commit **不在任何远端 ref 上**。根因:`npm run deploy` = `verify` + `wrangler pages deploy`,
* **不含 git push**;而 `PUBLISHING.md` 把 push 写在部署**之前**的第 4 步 —— 顺序没错,但**没有校验**
* 「push 的 commit == 部署的 commit」是否真的成立 ⇒ 于是部署了没推送的代码。
* 后果:本机故障 / 误 reset ⇒ **线上正在跑的代码永久丢失**,回滚只能退到 stable。
* 严格模式把「事后才发现」变成「当场拦截」:抓线上 version.json 的 `.commit`,
* 校验它**是 `origin/main` 的祖先**(= 线上代码可从远端恢复)。
* 不会误报 docs-only 提交:那种情况下线上 commit 是上一个**代码**提交,它仍在 origin/main 的历史里。
*
* 用法:
* node scripts/verify-release.js # 默认:只强校验版本号(行为不变)
* IWB_VERIFY_STRICT=1 node scripts/verify-release.js # 严格:额外校验线上代码可从远端恢复
* node scripts/verify-release.js --check-commit # 同上(等价写法)
*
* 退出码:0 = 三个地址版本一致且与 package.json 相同;1 = 有地址不可达/缺 version.json/版本不一致/
* 三地址分歧/(严格模式)线上代码未推送到远端
*/
const fs = require('fs')
const path = require('path')
const https = require('https')
const { execFileSync } = require('child_process')
// 严格模式:额外校验「线上代码在远端可恢复」。默认关闭 —— 保持既有调用行为不变。
const STRICT = process.env.IWB_VERIFY_STRICT === '1' || process.argv.includes('--check-commit')
const ROOT = path.join(__dirname, '..')
const URLS = [
'https://iwb.maqiart.eu.org',
'https://image-workbench-web.pages.dev',
'https://test.image-workbench-web.pages.dev',
]
const version = JSON.parse(fs.readFileSync(path.join(__dirname, '..', 'package.json'), 'utf8')).version
function get(url, redirect) {
return new Promise((resolve) => {
const req = https.get(url + '/version.json?cb=' + Date.now(), { timeout: 20000 }, (res) => {
if ([301, 302, 307, 308].includes(res.statusCode) && res.headers.location && (redirect || 0) < 3) {
res.resume()
return resolve(get(res.headers.location, (redirect || 0) + 1))
}
let body = ''
res.setEncoding('utf8')
res.on('data', (c) => { body += c })
res.on('end', () => resolve({ ok: res.statusCode === 200, status: res.statusCode, body }))
})
req.on('timeout', () => { req.destroy(); resolve({ ok: false, status: 0, body: '', error: 'timeout' }) })
req.on('error', (e) => resolve({ ok: false, status: 0, body: '', error: String(e && e.message || e) }))
})
}
function parseVersion(body) {
try {
const meta = JSON.parse(body || '')
return meta && typeof meta.version === 'string' ? { version: meta.version, commit: meta.commit || '' } : null
} catch (e) {
return null
}
}
const okVersion = (v) => v === 'v' + version || v.indexOf('v' + version + '+') === 0
// 一致性比较必须用「去掉 +commit 后缀」的版本号。
// 为什么(2026-11-14 踩到):version.json 的 version 形如 `v3.24.84+c8b7543`,后缀是**部署时的 commit**。
// 正式站与测试站天然可能指向不同 commit —— 最常见的正是 **docs-only 提交**(正式站部署的是含文档提交的
// 这次 HEAD,测试站还停在上一版代码提交)⇒ 完整字符串永不相等 ⇒ 每次发布都误报「三地址版本不一致」,
// 重试 3 轮后失败。而「线上代码是否一致 / 可恢复」是严格模式单独判定的事(见下方 uniqCommits),
// 不该混进版本一致性里,否则真出问题时这个 ✗ 已经没人当回事了。
const baseVersion = (v) => String(v || '').split('+')[0]
// ── 严格模式:线上代码是否可从远端恢复 ──────────────────────────────────
// 判据:线上 commit 必须是 `origin/main` 的祖先(即远端历史里含它)。
// - 远端还没有该 commit ⇒ 线上跑的是**只存在于本机**的代码 ⇒ 不可恢复 ⇒ 失败。
// - 远端历史里含它 ⇒ 即使本机故障,也能从远端 checkout 出来 ⇒ 通过。
// 注意用 `merge-base --is-ancestor` 而不是「等于」:docs-only 提交后线上 commit
// 是上一个**代码**提交,它仍是 origin/main 的祖先 —— 这正是我们要的语义。
function isReachableFromRemote(commit) {
try {
execFileSync('git', ['merge-base', '--is-ancestor', commit, 'origin/main'], {
cwd: ROOT,
stdio: 'ignore',
})
return { ok: true }
} catch (e) {
return { ok: false, reason: '不是 origin/main 的祖先(远端历史里找不到它)' }
}
}
;(async () => {
console.log('期望版本(package.json): v' + version)
if (STRICT) console.log('严格模式:额外校验「线上代码可从远端恢复」')
let bad = 0
const seen = new Map()
const commits = new Map()
for (const u of URLS) {
const r = await get(u)
if (!r.ok) {
console.log(' ✗ ' + u + ' 不可达(' + (r.error || 'HTTP ' + r.status) + ')')
bad++
continue
}
const meta = parseVersion(r.body)
if (!meta || !meta.version) { console.log(' ✗ ' + u + ' 缺少/无法解析 version.json'); bad++; continue }
const okVer = okVersion(meta.version)
if (!okVer) bad++
seen.set(baseVersion(meta.version), (seen.get(baseVersion(meta.version)) || 0) + 1)
if (meta.commit) commits.set(meta.commit, (commits.get(meta.commit) || 0) + 1)
console.log(' ' + (okVer ? '✓' : '✗') + ' ' + u.padEnd(46) + ' ' + meta.version + ' commit=' + (meta.commit || '-'))
}
const uniq = [...seen.keys()]
if (uniq.length > 1) { console.log(' ✗ 三个地址版本不一致: ' + uniq.join(' / ')); bad++ }
// 部署后 CDN 传播有延迟(实测首次运行会假失败 ✗)⇒ 版本不一致时退避重试,最多 3 轮
if (bad && process.env.IWB_VERIFY_NO_RETRY !== '1') {
for (let attempt = 1; attempt <= 3 && bad; attempt++) {
console.log(' … 版本未收敛,' + (attempt * 10) + 's 后重试(第 ' + attempt + '/3 轮)')
await new Promise((r) => setTimeout(r, attempt * 10000))
let bad2 = 0
const seen2 = new Map()
for (const u of URLS) {
const r = await get(u)
const meta = r.ok ? parseVersion(r.body) : null
const v = meta ? meta.version : ''
if (!v || !okVersion(v)) bad2++
if (v) seen2.set(baseVersion(v), (seen2.get(baseVersion(v)) || 0) + 1)
}
if (seen2.size > 1) bad2++
if (!bad2) { console.log(' ✓ 重试后已收敛'); bad = 0; break }
bad = bad2
}
}
if (bad) { console.log('发布核验失败(' + bad + ' 项)'); process.exit(1) }
// ── 严格模式:线上代码必须在远端可恢复 ────────────────────────────────
// 与版本校验分开判定:版本对但代码没推送 ⇒ 仍是事故(只是暂时没出事)。
if (STRICT) {
const uniqCommits = [...commits.keys()]
if (uniqCommits.length === 0) {
console.log(' ✗ 严格模式:无法确定线上 commit(version.json 里没有 .commit 字段)')
console.log('发布核验失败:线上代码可恢复性无法确认')
process.exit(1)
}
let strictBad = 0
for (const c of uniqCommits) {
const reach = isReachableFromRemote(c)
if (reach.ok) {
console.log(' ✓ 线上代码可从 origin/main 恢复:' + c)
} else {
strictBad++
console.log(' ✗ 线上代码 ' + c + ' ' + reach.reason + ' ⇒ 该代码**只存在于本机**,本机故障即永久丢失')
console.log(' 修复:git push origin main && git tag -f stable HEAD && git push -f origin stable')
}
}
if (strictBad) {
console.log('发布核验失败:' + strictBad + ' 项(线上代码未推送到远端)')
process.exit(1)
}
console.log('发布核验通过:三地址一致 + 线上代码可从远端恢复 ✓')
return
}
console.log('发布核验通过:三地址一致且与 package.json 匹配 ✓(commit 仅信息展示,docs-only 提交时线上可能仍是上一个代码提交)')
console.log('提示:用 IWB_VERIFY_STRICT=1 或 --check-commit 可额外校验「线上代码已推送到远端」')
})()
+2 -2
View File
@@ -3,7 +3,7 @@
<title>插件开发规范 · Image Workbench</title>
<link rel="icon" href="/assets/favicon.png" type="image/png">
<link rel="apple-touch-icon" href="/assets/logo.png">
<link rel="stylesheet" href="/assets/style.css?v=3.26.135-mx395ee4">
<link rel="stylesheet" href="/assets/style.css?v=3.26.154-mx3wxyho">
<style>
.devdoc{max-width:860px;margin:0 auto;padding:40px 0 72px;color:var(--ink,#1b1f24);font-size:15px;line-height:1.75}
.devdoc h1{font-size:38px;line-height:1.2;margin:8px 0 18px}
@@ -33,7 +33,7 @@
</div>
<div class="right">
<a class="btn" href="/plugins/">插件市场</a>
<a class="btn primary" href="/download/">下载 v3.26.135</a>
<a class="btn primary" href="/download/">下载 v3.26.154</a>
</div>
</div></nav>
<main>
+62 -6
View File
@@ -57,18 +57,18 @@
<h2>下载</h2>
<div class="row">
<div class="name">macOS · Apple Silicon<div class="hint">M1 / M2 / M3 / M4</div></div>
<div class="meta">版本 3.26.135 · 9.7 MB · .dmg<div class="hash">sha256 c18018a98591fb74…</div></div>
<a class="btn" href="/updates/darwin-aarch64/image-workbench_3.26.135_aarch64.dmg?h=c18018a98591">下载</a>
<div class="meta">版本 3.26.154 · 9.7 MB · .dmg<div class="hash">sha256 0cb4b36492d1b691…</div></div>
<a class="btn" href="/updates/darwin-aarch64/image-workbench_3.26.154_aarch64.dmg?h=0cb4b36492d1">下载</a>
</div>
<div class="row">
<div class="name">macOS · Intel<div class="hint">x86_64</div></div>
<div class="meta">版本 3.26.135 · 10.1 MB · .dmg<div class="hash">sha256 706ddb1d1c186c01…</div></div>
<a class="btn" href="/updates/darwin-x86_64/image-workbench_3.26.135_x64.dmg?h=706ddb1d1c18">下载</a>
<div class="meta">版本 3.26.154 · 10.1 MB · .dmg<div class="hash">sha256 e803d95fb39b9f19…</div></div>
<a class="btn" href="/updates/darwin-x86_64/image-workbench_3.26.154_x64.dmg?h=e803d95fb39b">下载</a>
</div>
<div class="row">
<div class="name">Windows · x64<div class="hint">需要 WebView2</div></div>
<div class="meta">版本 3.26.135 · 5.4 MB · .exe<div class="hash">sha256 c70be225a8a0a176…</div></div>
<a class="btn" href="/updates/windows-x86_64/image-workbench_3.26.135_x64-setup.exe?h=c70be225a8a0">下载</a>
<div class="meta">版本 3.26.154 · 5.4 MB · .exe<div class="hash">sha256 53be3b40ea52e904…</div></div>
<a class="btn" href="/updates/windows-x86_64/image-workbench_3.26.154_x64-setup.exe?h=53be3b40ea52">下载</a>
</div>
<h2>系统要求</h2>
@@ -97,6 +97,62 @@
</ol>
<h2>历史版本</h2>
<div class="row">
<div class="name">3.26.154</div>
<div class="meta">2026-11-30<div class="hint">macOS · Apple Silicon / macOS · Intel / Windows · x64</div></div>
</div>
<div class="row">
<div class="name">3.26.153</div>
<div class="meta">2026-11-30<div class="hint">macOS · Apple Silicon / macOS · Intel</div></div>
</div>
<div class="row">
<div class="name">3.26.152</div>
<div class="meta">2026-11-30<div class="hint">macOS · Apple Silicon / macOS · Intel / Windows · x64</div></div>
</div>
<div class="row">
<div class="name">3.26.151</div>
<div class="meta">2026-11-30<div class="hint">macOS · Apple Silicon / macOS · Intel / Windows · x64</div></div>
</div>
<div class="row">
<div class="name">3.26.150</div>
<div class="meta">2026-11-30<div class="hint">macOS · Apple Silicon / macOS · Intel</div></div>
</div>
<div class="row">
<div class="name">3.26.149</div>
<div class="meta">2026-11-30<div class="hint">macOS · Apple Silicon / macOS · Intel</div></div>
</div>
<div class="row">
<div class="name">3.26.148</div>
<div class="meta">2026-11-30<div class="hint">macOS · Apple Silicon / macOS · Intel</div></div>
</div>
<div class="row">
<div class="name">3.26.147</div>
<div class="meta">2026-11-30<div class="hint">macOS · Apple Silicon / macOS · Intel</div></div>
</div>
<div class="row">
<div class="name">3.26.146</div>
<div class="meta">2026-11-30<div class="hint">macOS · Apple Silicon / macOS · Intel</div></div>
</div>
<div class="row">
<div class="name">3.26.145</div>
<div class="meta">2026-11-30<div class="hint">macOS · Apple Silicon / macOS · Intel</div></div>
</div>
<div class="row">
<div class="name">3.26.144</div>
<div class="meta">2026-11-30<div class="hint">macOS · Apple Silicon / macOS · Intel</div></div>
</div>
<div class="row">
<div class="name">3.26.143</div>
<div class="meta">2026-11-30<div class="hint">macOS · Apple Silicon / macOS · Intel</div></div>
</div>
<div class="row">
<div class="name">3.26.142</div>
<div class="meta">2026-11-30<div class="hint">macOS · Apple Silicon / macOS · Intel</div></div>
</div>
<div class="row">
<div class="name">3.26.141</div>
<div class="meta">2026-11-30<div class="hint">macOS · Apple Silicon / macOS · Intel</div></div>
</div>
<div class="row">
<div class="name">3.26.135<div class="hint">图库链路收尾:宫格不再读原图(原生 320 tier)、缩略图原子写+并发合并、空闲预热;插件图片策略 v2(thumb/preview/original);诊断新增分进程 footprint 与图片管线账本</div></div>
<div class="meta">2026-11-30<div class="hint">macOS · Intel / macOS · Apple Silicon / Windows · x64</div></div>
+10 -10
View File
@@ -4,7 +4,7 @@
<meta name="description" content="本地优先的 AI 生图无限画布:节点式工作流、插件按需安装、数据全部留在本机。">
<link rel="icon" href="/assets/favicon.png" type="image/png">
<link rel="apple-touch-icon" href="/assets/logo.png">
<link rel="stylesheet" href="/assets/style.css?v=3.26.135-mx395ee4">
<link rel="stylesheet" href="/assets/style.css?v=3.26.154-mx3xhehx">
</head><body>
<nav><div class="wrap inner">
<a class="brand" href="/"><img class="logo" src="/assets/logo.png" alt="" width="26" height="26">Image Workbench</a>
@@ -17,19 +17,19 @@
</div>
<div class="right">
<a class="btn" href="/plugins/">插件市场</a>
<a class="btn primary" href="/download/">下载 v3.26.135</a>
<a class="btn primary" href="/download/">下载 v3.26.154</a>
</div>
</div></nav>
<main>
<section class="hero hero-art">
<div class="hero-bg"><img src="/assets/painting.jpg?v=3.26.135-mx395ee4" alt=""></div>
<div class="hero-bg"><img src="/assets/painting.jpg?v=3.26.154-mx3xhehx" alt=""></div>
<div class="hero-veil"></div>
<div class="wrap">
<span class="kicker">v3.26.135 · macOS / Windows · 数据在本地</span>
<span class="kicker">v3.26.154 · macOS / Windows · 数据在本地</span>
<h1>本地优先的<br>AI 生图无限画布</h1>
<p class="sub">用节点把「参考图 → 提示词 → 批量生成 → 图库」串成一条生产线。<br>图片、提示词、模型配置全部留在你自己的电脑里,插件按需安装。</p>
<div class="cta">
<a class="btn primary lg" href="/download/">下载 v3.26.135</a>
<a class="btn primary lg" href="/download/">下载 v3.26.154</a>
<a class="btn lg" href="/plugins/">浏览 13 个插件</a>
</div>
<div class="meta">支持 macOS 12+ 与 Windows 10 1803+ · 安装包约 7 MB · 无需登录</div>
@@ -55,7 +55,7 @@
<div class="grid c3">
<div class="pcard" data-name="相册 album 一个节点装多张本地图片:宫格随节点尺寸自适应分页,一图一任务 / 批量两种模式,批量生图不用再摆一堆图片节点 图片 批量 出图" data-tags="图片,批量,出图">
<div class="head"><span class="av" style="background:#eef2f6">🖼️</span>
<div><div class="nm">相册</div><div class="ver">v1.2.4 · 官方</div></div></div>
<div><div class="nm">相册</div><div class="ver">v1.2.5 · 官方</div></div></div>
<div class="desc">一个节点装多张本地图片:宫格随节点尺寸自适应分页,一图一任务 / 批量两种模式,批量生图不用再摆一堆图片节点</div>
<div class="tags"><span class="tag">图片</span><span class="tag">批量</span><span class="tag">出图</span></div>
</div>
@@ -79,7 +79,7 @@
</div>
<div class="pcard" data-name="图库 gallery 右栏图片墙:筛选/多选/双击预览/插入画布/下载/删除(数据由客户端提供) 资源 图库" data-tags="资源,图库">
<div class="head"><span class="av" style="background:#eef2f6">🖼️</span>
<div><div class="nm">图库</div><div class="ver">v1.9.8 · 官方</div></div></div>
<div><div class="nm">图库</div><div class="ver">v1.9.9 · 官方</div></div></div>
<div class="desc">右栏图片墙:筛选/多选/双击预览/插入画布/下载/删除(数据由客户端提供)</div>
<div class="tags"><span class="tag">资源</span><span class="tag">图库</span></div>
</div>
@@ -96,9 +96,9 @@
<section class="section"><div class="wrap">
<h2>下载 Image Workbench</h2>
<p class="lead">选你的平台。装过一次之后,以后在应用内「设置 → 通用 → 版本与更新」就能一键升级。</p>
<div class="dl"><a href="/updates/darwin-aarch64/image-workbench_3.26.135_aarch64.dmg?h=c18018a98591"><div class="n">macOS · Apple Silicon</div><div class="s">M1 / M2 / M3 / M4 · 9.7 MB · .dmg</div></a>
<a href="/updates/darwin-x86_64/image-workbench_3.26.135_x64.dmg?h=706ddb1d1c18"><div class="n">macOS · Intel</div><div class="s">x86_64 · 10.1 MB · .dmg</div></a>
<a href="/updates/windows-x86_64/image-workbench_3.26.135_x64-setup.exe?h=c70be225a8a0"><div class="n">Windows · x64</div><div class="s">需要 WebView2 · 5.4 MB · .exe</div></a></div>
<div class="dl"><a href="/updates/darwin-aarch64/image-workbench_3.26.154_aarch64.dmg?h=0cb4b36492d1"><div class="n">macOS · Apple Silicon</div><div class="s">M1 / M2 / M3 / M4 · 9.7 MB · .dmg</div></a>
<a href="/updates/darwin-x86_64/image-workbench_3.26.154_x64.dmg?h=e803d95fb39b"><div class="n">macOS · Intel</div><div class="s">x86_64 · 10.1 MB · .dmg</div></a>
<a href="/updates/windows-x86_64/image-workbench_3.26.154_x64-setup.exe?h=53be3b40ea52"><div class="n">Windows · x64</div><div class="s">需要 WebView2 · 5.4 MB · .exe</div></a></div>
<div style="margin-top:20px;color:#9ca3af;font-size:12.5px">安装包未做 Apple 公证 / Windows 代码签名,首次打开需手动放行一次,细节见 <a href="/download/" style="text-decoration:underline">下载页</a>。</div>
</div></section>
</main>
+56 -56
View File
@@ -1,6 +1,6 @@
{
"version": 2,
"updatedAt": "2026-11-30T12:11:21.858Z",
"updatedAt": "2026-11-30T23:01:32.719Z",
"plugins": [
{
"id": "album",
@@ -14,26 +14,26 @@
"批量",
"出图"
],
"version": "1.2.4",
"version": "1.2.5",
"apiVersion": 1,
"bundle": "plugins/album-1.2.4.zip",
"bundleSize": 81343,
"bundleSha256": "4edd6f5bc34fc45d865e92ff153ff98b8adb94a66ec2d3b0d932773f8ce7008c",
"bundle": "plugins/album-1.2.5.zip",
"bundleSize": 81231,
"bundleSha256": "29dd3a8dbccd5cb6f9d23ba2274faf6d20d99d328477f558fbb5f7a41a77e747",
"files": [
{
"path": "manifest.json",
"sha256": "a17de056c904e9c83aca0911652c8ec69598a8435d69bc602633447df06fece2",
"sha256": "237aed8ac62bf43d8968fa3e600fdc770303525f2b3458e6f0b6b26d88ee5153",
"size": 593
},
{
"path": "main.js",
"sha256": "79ac746f0065103a32b083e2d79f16fb09fcf9032709952ba256887db1bedb4a",
"sha256": "38ec9d214ed204fc47d9ad8c82d8b3bf461c6cfbd09dbe18dc9d81061729e596",
"size": 67857
},
{
"path": "styles.css",
"sha256": "40623c831620d0082dde956300461b29b9256aab98da86c7ab5e3495214f8d49",
"size": 12583
"sha256": "63f70828151481ee96fd102e3c18baecbf51999d8fd96044aabbefdd5c2d2225",
"size": 12471
}
]
},
@@ -52,23 +52,23 @@
"apiVersion": 1,
"bundle": "plugins/batch-export-1.2.3.zip",
"bundleSize": 46021,
"bundleSha256": "e5c0912bcbf75db2d27b455f4ab0185153cbba3c509b161a8bccfc6c963e1355",
"bundleSha256": "99e40fa4e3a0c6e7fc19e8c4624445011ee638d57b92c8b808fee46854dd3bc7",
"files": [
{
"path": "manifest.json",
"sha256": "9fb16be34be882356f4022ac43063a93cb61eb1592a2006a04dd0e11839b53e5",
"sha256": "5dc47b2afe4fe6e2d7b260559341a435ad667ab2f764e1f6c1405d8a2774da94",
"size": 393
},
{
"path": "main.js",
"sha256": "e0152de8d9280163a80a4d689aadc4704dc265d7b167212ab3da9e62ab67c1bd",
"sha256": "496febf1312cfa441b627669d23c3c6f6945d300e0c5986fc02d1cfc3c283a24",
"size": 45414
}
],
"file": "plugins/plugin-batch-export.e0152de8d928.js",
"file": "plugins/plugin-batch-export.496febf1312c.js",
"size": 45414,
"sha256": "e0152de8d9280163a80a4d689aadc4704dc265d7b167212ab3da9e62ab67c1bd",
"integrity": "sha256-4BUt6NkoAWOoCk1omq3EcE3CZdexZyEqs9qeYqtnwb0="
"sha256": "496febf1312cfa441b627669d23c3c6f6945d300e0c5986fc02d1cfc3c283a24",
"integrity": "sha256-SW/r8TEs+kQbYnZp0jw8b2lF0wDgxZhvwC0c/DwoOiQ="
},
{
"id": "blank-canvas",
@@ -147,26 +147,26 @@
"资源",
"图库"
],
"version": "1.9.8",
"version": "1.9.9",
"apiVersion": 1,
"bundle": "plugins/gallery-1.9.8.zip",
"bundleSize": 57230,
"bundleSha256": "9f15a8c8fb6eadace5b7704e601399d0dba2ebb0ad01d42ce600cc95c1bf9ead",
"bundle": "plugins/gallery-1.9.9.zip",
"bundleSize": 57020,
"bundleSha256": "ed3847edf88818f060c9d00e56cac32dcf797a0b97d08ae0c2cf1df4fb79e55c",
"files": [
{
"path": "manifest.json",
"sha256": "204afbd3c9cfc52825ce68d5a2123411d664b0af9780dc3a330aa57d053a82e8",
"sha256": "7041e7fba02511f2638e83b8087e9c724fc7dac2d63e0ffbc3a7c536e8ced33f",
"size": 526
},
{
"path": "main.js",
"sha256": "8586409417599dec4b0f229e88eaf937f991f1942db49df97ce9a27e16a35d9f",
"sha256": "22b2d8aa07ec193703d57603e857a6e48e054874ef943603d2ed7b1f3c560fd9",
"size": 47513
},
{
"path": "styles.css",
"sha256": "c7db0f9d78b98c1b5bb9782c45dfc2274673c1c7d34fdf676aae41680866eb3d",
"size": 8881
"sha256": "07ca657d2e5f5d9406e6c7f7306906e34f2ee10a2fa4c2165358451f5461c6a4",
"size": 8671
}
]
},
@@ -215,26 +215,26 @@
"资源",
"提示词"
],
"version": "1.14.10",
"version": "1.14.11",
"apiVersion": 1,
"bundle": "plugins/promptlib-1.14.10.zip",
"bundleSize": 190912,
"bundleSha256": "863768ef81136af63c890b82c993b3d5adc28b2992e55a830a3326d20c2b806a",
"bundle": "plugins/promptlib-1.14.11.zip",
"bundleSize": 190823,
"bundleSha256": "fd6e1f0733757e35a2b202d018db5e3b9a418062c4555a2747d95e8bd6061d07",
"files": [
{
"path": "manifest.json",
"sha256": "24b15b2baf6262e0aa9e024f3ed67dbdf33a76be7a06324f844132aee012a161",
"sha256": "5a14bdf3a2b3334e4c78a9dc2c0f8c90d253b7113724dc5daa534936ec1551d2",
"size": 542
},
{
"path": "main.js",
"sha256": "a05ce22ad8ab2e079e313dd31d8fe34f2e2e07e017bfb782afcd08047e0b485b",
"size": 142645
"sha256": "c807d9ce8b1a7df851e00dd724e585d3158b2031194e71ca154d3def383385d7",
"size": 142646
},
{
"path": "styles.css",
"sha256": "86f73b4d1c7b827f97ec1135c9130c7da6898537b2ed2ab815e282618232f56b",
"size": 47415
"sha256": "182783b15335895b5a40822bf137a7b4872ca0c6ee72434bfa61a97b37453a07",
"size": 47325
}
]
},
@@ -253,23 +253,23 @@
"apiVersion": 1,
"bundle": "plugins/image-annotate-1.20.9.zip",
"bundleSize": 463183,
"bundleSha256": "f78212022f2cf2964e22063b8fcd3dbe4e8a331371af4c7b7284a168f3f470ee",
"bundleSha256": "d096f1d9738e8aa407ad63204103a454bdded41831bde06ee9b9f984deb2600b",
"files": [
{
"path": "manifest.json",
"sha256": "2d27bb11e77543bdc6f690aa4dcc65b777fa3f4cce6c1017b476707f525c4db1",
"sha256": "d1bc4c260c7b9212e7d0fdb4a1b3764f935ad437b91e786ebf3f04e1ed82814f",
"size": 373
},
{
"path": "main.js",
"sha256": "fda7cfeefb9bf0fb26d9d1b3a2cd8ce1f704fc6c664b623d26fc79db7c4266bd",
"sha256": "ce58bab92abd01acc1b24e5fa9f9285ab4b30342a2fcd68449e92ccd003e2110",
"size": 462596
}
],
"file": "plugins/plugin-image-annotate.fda7cfeefb9b.js",
"file": "plugins/plugin-image-annotate.ce58bab92abd.js",
"size": 462596,
"sha256": "fda7cfeefb9bf0fb26d9d1b3a2cd8ce1f704fc6c664b623d26fc79db7c4266bd",
"integrity": "sha256-/afP7vub8Psm2dGzos2M4fcE/GxmS2I9Jvx523xCZr0="
"sha256": "ce58bab92abd01acc1b24e5fa9f9285ab4b30342a2fcd68449e92ccd003e2110",
"integrity": "sha256-zli6uSq9AazBsk5fqfkoWrSzA0Ki/NaESekszQA+IRA="
},
{
"id": "image-vectorize",
@@ -286,23 +286,23 @@
"apiVersion": 1,
"bundle": "plugins/image-vectorize-0.6.2.zip",
"bundleSize": 145959,
"bundleSha256": "7ba6074830abd833834a18fc567b37c2a66f0b0488baea76317e280b640fa176",
"bundleSha256": "d51f1bdc5cd3523a9c28816dc734444d6c344574760ec1cae3057bdd4a88841c",
"files": [
{
"path": "manifest.json",
"sha256": "259c6c90ac0a25e5cab8c91daf38f5b2fa39804855dfdf6b90c3ad1262f28ba5",
"sha256": "d484ae85bfb6e2597f6e78b7f4097809d346e5afa7c06786404cb76df2019a9b",
"size": 362
},
{
"path": "main.js",
"sha256": "2d9e6c796bf6e4aa262fbabc59ae551802f28f5e875a4f34e586cbc9410380fb",
"sha256": "b3a8c21f7a2bead419e6e9899d9fe46ba9e4fa7e67a777a50056942b568f57d1",
"size": 145383
}
],
"file": "plugins/plugin-image-vectorize.2d9e6c796bf6.js",
"file": "plugins/plugin-image-vectorize.b3a8c21f7a2b.js",
"size": 145383,
"sha256": "2d9e6c796bf6e4aa262fbabc59ae551802f28f5e875a4f34e586cbc9410380fb",
"integrity": "sha256-LZ5seWv25KomL7q8Wa5VGALyj16HWk805YbLyUEDgPs="
"sha256": "b3a8c21f7a2bead419e6e9899d9fe46ba9e4fa7e67a777a50056942b568f57d1",
"integrity": "sha256-s6jCH3or6tQZ5umJnZ/ka6nk+n5np3elAFaUK1aPV9E="
},
{
"id": "sticky",
@@ -385,23 +385,23 @@
"apiVersion": 1,
"bundle": "plugins/white-bg-800-1.2.2.zip",
"bundleSize": 15573,
"bundleSha256": "c01d589bb091c5a9e9f05a8186db675d52aeddd2738042f8ef65429bc4616c39",
"bundleSha256": "71a1c5a0c5ddc037a0c1d3dcdf5d54202e66005447948daf9e40e00cd71566d4",
"files": [
{
"path": "manifest.json",
"sha256": "57d5c606adf14f4ae63f5a7e9d712bddda94efee2b4678a5fe2360e6e1db3029",
"sha256": "8b6634cbb1c397ab101f0ed6cdc75dbedb1c8c3b0e9655ccf0f6c72636490d4f",
"size": 357
},
{
"path": "main.js",
"sha256": "988d72d6f09de4817c51319d3b38200783a70a942b4249827252facbdc3ce881",
"sha256": "ffc18c23ed74f8164773adc37f907eb7b2b2c46a63f0ca277db949effc568b33",
"size": 15002
}
],
"file": "plugins/plugin-white-bg-800.988d72d6f09d.js",
"file": "plugins/plugin-white-bg-800.ffc18c23ed74.js",
"size": 15002,
"sha256": "988d72d6f09de4817c51319d3b38200783a70a942b4249827252facbdc3ce881",
"integrity": "sha256-mI1y1vCd5IF8UTGdOzggB4OnCpQrQkmCclL6y9w86IE="
"sha256": "ffc18c23ed74f8164773adc37f907eb7b2b2c46a63f0ca277db949effc568b33",
"integrity": "sha256-/8GMI+10+BZHc63Df5B+t7KyxGpj8MonfblJ7/xWizM="
},
{
"id": "xianyi-cutout",
@@ -418,23 +418,23 @@
"apiVersion": 1,
"bundle": "plugins/xianyi-cutout-1.0.4.zip",
"bundleSize": 5111,
"bundleSha256": "327e5efd19bbe483107374b0108048c599000c5e77e5cbed245a611ecdb770d9",
"bundleSha256": "487dac0b9fe37537918ee6b90bd422cc5dbb2c1d1ba3758abda23335e6a9aefe",
"files": [
{
"path": "manifest.json",
"sha256": "19be5e8027e2bbb814d1a390f7569dd273a471b5a7e76f47c99b4ccfe803e159",
"sha256": "39693bdfd190f1e3b98b1300cab60bc3c1c97cc6a71b9336d5b2b0a8b3e8da59",
"size": 370
},
{
"path": "main.js",
"sha256": "84907706bb31d64aed82b85784483b91335301a8ad41e0e44813a2b9dfe17b47",
"sha256": "f7898f6e0fe9f8f8a4bdf91ce7dbbe538c0f27ee398dce3a25394da6d559201d",
"size": 4527
}
],
"file": "plugins/plugin-xianyi-cutout.84907706bb31.js",
"file": "plugins/plugin-xianyi-cutout.f7898f6e0fe9.js",
"size": 4527,
"sha256": "84907706bb31d64aed82b85784483b91335301a8ad41e0e44813a2b9dfe17b47",
"integrity": "sha256-hJB3Brsx1krtgrhXhEg7kTNTAaitQeDkSBOiud/he0c="
"sha256": "f7898f6e0fe9f8f8a4bdf91ce7dbbe538c0f27ee398dce3a25394da6d559201d",
"integrity": "sha256-94mPbg/p+Pikvfkc59u+U4wPJ+45jc46JTlNptVZIB0="
}
]
}
+5 -5
View File
@@ -3,7 +3,7 @@
<title>插件市场 · Image Workbench</title>
<link rel="icon" href="/assets/favicon.png" type="image/png">
<link rel="apple-touch-icon" href="/assets/logo.png">
<link rel="stylesheet" href="/assets/style.css?v=3.26.135-mx395ee4">
<link rel="stylesheet" href="/assets/style.css?v=3.26.154-mx3xhehx">
</head><body>
<nav><div class="wrap inner">
<a class="brand" href="/"><img class="logo" src="/assets/logo.png" alt="" width="26" height="26">Image Workbench</a>
@@ -16,7 +16,7 @@
</div>
<div class="right">
<a class="btn" href="/plugins/">插件市场</a>
<a class="btn primary" href="/download/">下载 v3.26.135</a>
<a class="btn primary" href="/download/">下载 v3.26.154</a>
</div>
</div></nav>
<main>
@@ -52,7 +52,7 @@
<div class="grid c3" id="list">
<div class="pcard" data-name="相册 album 一个节点装多张本地图片:宫格随节点尺寸自适应分页,一图一任务 / 批量两种模式,批量生图不用再摆一堆图片节点 图片 批量 出图" data-tags="图片,批量,出图">
<div class="head"><span class="av" style="background:#eef2f6">🖼️</span>
<div><div class="nm">相册</div><div class="ver">v1.2.4 · 官方</div></div></div>
<div><div class="nm">相册</div><div class="ver">v1.2.5 · 官方</div></div></div>
<div class="desc">一个节点装多张本地图片:宫格随节点尺寸自适应分页,一图一任务 / 批量两种模式,批量生图不用再摆一堆图片节点</div>
<div class="tags"><span class="tag">图片</span><span class="tag">批量</span><span class="tag">出图</span></div>
</div>
@@ -76,7 +76,7 @@
</div>
<div class="pcard" data-name="图库 gallery 右栏图片墙:筛选/多选/双击预览/插入画布/下载/删除(数据由客户端提供) 资源 图库" data-tags="资源,图库">
<div class="head"><span class="av" style="background:#eef2f6">🖼️</span>
<div><div class="nm">图库</div><div class="ver">v1.9.8 · 官方</div></div></div>
<div><div class="nm">图库</div><div class="ver">v1.9.9 · 官方</div></div></div>
<div class="desc">右栏图片墙:筛选/多选/双击预览/插入画布/下载/删除(数据由客户端提供)</div>
<div class="tags"><span class="tag">资源</span><span class="tag">图库</span></div>
</div>
@@ -88,7 +88,7 @@
</div>
<div class="pcard" data-name="提示词库 promptlib 右栏提示词列表:搜索/分组/收藏/新建编辑/插入画布/复制(数据由客户端提供) 资源 提示词" data-tags="资源,提示词">
<div class="head"><span class="av" style="background:#eef2f6">📖</span>
<div><div class="nm">提示词库</div><div class="ver">v1.14.10 · 官方</div></div></div>
<div><div class="nm">提示词库</div><div class="ver">v1.14.11 · 官方</div></div></div>
<div class="desc">右栏提示词列表:搜索/分组/收藏/新建编辑/插入画布/复制(数据由客户端提供)</div>
<div class="tags"><span class="tag">资源</span><span class="tag">提示词</span></div>
</div>
+316 -1
View File
@@ -1,8 +1,323 @@
{
"app": "Image Workbench",
"subtitle": "本地优先的 AI 生图无限画布 · 桌面版(Tauri v2)",
"updatedAt": "2026-11-30T12:36:34.114Z",
"updatedAt": "2026-11-30T23:57:44.903Z",
"releases": [
{
"version": "3.26.154",
"date": "2026-11-30",
"notes": "",
"platforms": {
"darwin-aarch64": {
"file": "updates/darwin-aarch64/image-workbench_3.26.154_aarch64.dmg",
"size": 10142791,
"sha256": "0cb4b36492d1b691bbd22a142b0df423aebe1b17b7bf61a25d53148a002f2ae7",
"h": "0cb4b36492d1",
"kind": "dmg"
},
"darwin-x86_64": {
"file": "updates/darwin-x86_64/image-workbench_3.26.154_x64.dmg",
"size": 10599688,
"sha256": "e803d95fb39b9f19c10cbb51ad613f399d293df4f1a834f066e8e1c547c03b05",
"h": "e803d95fb39b",
"kind": "dmg"
},
"windows-x86_64": {
"file": "updates/windows-x86_64/image-workbench_3.26.154_x64-setup.exe",
"size": 5623889,
"sha256": "53be3b40ea52e9042197877dad09a72dce9601d85011c35b42be858652d433a4",
"h": "53be3b40ea52",
"kind": "exe"
}
}
},
{
"version": "3.26.153",
"date": "2026-11-30",
"notes": "",
"platforms": {
"darwin-aarch64": {
"file": "updates/darwin-aarch64/image-workbench_3.26.153_aarch64.dmg",
"size": 10144677,
"sha256": "c5db4cc89faa00d52e81fbbc6cb6e335926807eb1a4ec1bfa4c18bc35d74f205",
"h": "c5db4cc89faa",
"kind": "dmg"
},
"darwin-x86_64": {
"file": "updates/darwin-x86_64/image-workbench_3.26.153_x64.dmg",
"size": 10597228,
"sha256": "7cc145a35de16cbed313975008a6a212fb1e36712935e63ed5d060123d48a614",
"h": "7cc145a35de1",
"kind": "dmg"
}
}
},
{
"version": "3.26.152",
"date": "2026-11-30",
"notes": "",
"platforms": {
"darwin-aarch64": {
"file": "updates/darwin-aarch64/image-workbench_3.26.152_aarch64.dmg",
"size": 10142029,
"sha256": "c15de46422635ffd44350738ab29f90db0137ca6f8d061a8f8224138e915fc26",
"h": "c15de4642263",
"kind": "dmg"
},
"darwin-x86_64": {
"file": "updates/darwin-x86_64/image-workbench_3.26.152_x64.dmg",
"size": 10597414,
"sha256": "4e2b92cd9ae3844b406ce1e65d38117c17833521e967f70a58a5f5194bf70bc0",
"h": "4e2b92cd9ae3",
"kind": "dmg"
},
"windows-x86_64": {
"file": "updates/windows-x86_64/image-workbench_3.26.152_x64-setup.exe",
"size": 5617791,
"sha256": "fdf0e2025580ccb714760a0e5314bebccb84a91ccba383c643b2087fe2d5cfdb",
"h": "fdf0e2025580",
"kind": "exe"
}
}
},
{
"version": "3.26.151",
"date": "2026-11-30",
"notes": "",
"platforms": {
"darwin-aarch64": {
"file": "updates/darwin-aarch64/image-workbench_3.26.151_aarch64.dmg",
"size": 10142077,
"sha256": "a37da236abdd08a06c206a55bd8525cee00c2e24117ba5d3f72a637b55d623fd",
"h": "a37da236abdd",
"kind": "dmg"
},
"darwin-x86_64": {
"file": "updates/darwin-x86_64/image-workbench_3.26.151_x64.dmg",
"size": 10598747,
"sha256": "e4ff71872a2568264fe63981f10090469636ac5e276b5440498b2d44fe031204",
"h": "e4ff71872a25",
"kind": "dmg"
},
"windows-x86_64": {
"file": "updates/windows-x86_64/image-workbench_3.26.151_x64-setup.exe",
"size": 5624317,
"sha256": "69f81a2a570483c36064315fd5c23a5ac398f12e21fa430a10dac16b4572eb4b",
"h": "69f81a2a5704",
"kind": "exe"
}
}
},
{
"version": "3.26.150",
"date": "2026-11-30",
"notes": "",
"platforms": {
"darwin-aarch64": {
"file": "updates/darwin-aarch64/image-workbench_3.26.150_aarch64.dmg",
"size": 10144929,
"sha256": "9f959acb1ddd19dd605cbeafb4fb13f38202cf11c4101c68f6b08403ce757483",
"h": "9f959acb1ddd",
"kind": "dmg"
},
"darwin-x86_64": {
"file": "updates/darwin-x86_64/image-workbench_3.26.150_x64.dmg",
"size": 10602162,
"sha256": "bf6924849e9bf4d5857c17ab978fa363f1db90845cb44887d8624f1f61c17c49",
"h": "bf6924849e9b",
"kind": "dmg"
}
}
},
{
"version": "3.26.149",
"date": "2026-11-30",
"notes": "",
"platforms": {
"darwin-aarch64": {
"file": "updates/darwin-aarch64/image-workbench_3.26.149_aarch64.dmg",
"size": 10147563,
"sha256": "aac96f14828d642c7feab1d509bf49344c0f8321c4c39700a4844f4eb30627d9",
"h": "aac96f14828d",
"kind": "dmg"
},
"darwin-x86_64": {
"file": "updates/darwin-x86_64/image-workbench_3.26.149_x64.dmg",
"size": 10597596,
"sha256": "af90574b7c74f0bffa2968703a20b980a5940621508b81443fd73e7c83c7d616",
"h": "af90574b7c74",
"kind": "dmg"
}
}
},
{
"version": "3.26.148",
"date": "2026-11-30",
"notes": "",
"platforms": {
"darwin-aarch64": {
"file": "updates/darwin-aarch64/image-workbench_3.26.148_aarch64.dmg",
"size": 10144542,
"sha256": "48e65f53d7c023cd9be62989254cd30d81f66c6aacafd6dd0b093b53fcb376e3",
"h": "48e65f53d7c0",
"kind": "dmg"
},
"darwin-x86_64": {
"file": "updates/darwin-x86_64/image-workbench_3.26.148_x64.dmg",
"size": 10598579,
"sha256": "5249b32f4d3ea5d3978a218b8542bb2eedd62e6699ff1dfa191b5323f4989658",
"h": "5249b32f4d3e",
"kind": "dmg"
}
}
},
{
"version": "3.26.147",
"date": "2026-11-30",
"notes": "",
"platforms": {
"darwin-aarch64": {
"file": "updates/darwin-aarch64/image-workbench_3.26.147_aarch64.dmg",
"size": 10143137,
"sha256": "8e4cecdf212887f6a3179b9f22decb6ccec3a76c1936de702a7b097dcf45a62d",
"h": "8e4cecdf2128",
"kind": "dmg"
},
"darwin-x86_64": {
"file": "updates/darwin-x86_64/image-workbench_3.26.147_x64.dmg",
"size": 10599179,
"sha256": "e885e8a71a86e685f9de8c4c95ee6404afdbd78a2cf808de2f05c41160d21512",
"h": "e885e8a71a86",
"kind": "dmg"
}
}
},
{
"version": "3.26.146",
"date": "2026-11-30",
"notes": "",
"platforms": {
"darwin-aarch64": {
"file": "updates/darwin-aarch64/image-workbench_3.26.146_aarch64.dmg",
"size": 10142147,
"sha256": "a380f10b3d1d77e7dfd8f451e7a7ad6cc086af187fdd62332705c1e7f1a5c616",
"h": "a380f10b3d1d",
"kind": "dmg"
},
"darwin-x86_64": {
"file": "updates/darwin-x86_64/image-workbench_3.26.146_x64.dmg",
"size": 10599790,
"sha256": "464d13071f0f49d1a0ef6b376a907f7c767eb94b0c1cbbb255d0387fddbc34df",
"h": "464d13071f0f",
"kind": "dmg"
}
}
},
{
"version": "3.26.145",
"date": "2026-11-30",
"notes": "",
"platforms": {
"darwin-aarch64": {
"file": "updates/darwin-aarch64/image-workbench_3.26.145_aarch64.dmg",
"size": 10143674,
"sha256": "a9a3840b3368021a2f070dfb3dadc77d40ba93335ddd80efce17d18b2b320a0f",
"h": "a9a3840b3368",
"kind": "dmg"
},
"darwin-x86_64": {
"file": "updates/darwin-x86_64/image-workbench_3.26.145_x64.dmg",
"size": 10601583,
"sha256": "ff13e4950e97699c38687d04a6d956b6d096d5805585935023d46f33856ca2d7",
"h": "ff13e4950e97",
"kind": "dmg"
}
}
},
{
"version": "3.26.144",
"date": "2026-11-30",
"notes": "",
"platforms": {
"darwin-aarch64": {
"file": "updates/darwin-aarch64/image-workbench_3.26.144_aarch64.dmg",
"size": 10140731,
"sha256": "f273170522ac9ed0f8fe867d6f019d27cec4a1d256f53441cfe69040da8c09a8",
"h": "f273170522ac",
"kind": "dmg"
},
"darwin-x86_64": {
"file": "updates/darwin-x86_64/image-workbench_3.26.144_x64.dmg",
"size": 10600079,
"sha256": "dadc7270c40a6c0ff1bf787dafcaf47a23a80e471167c07ad8025f55a16861bd",
"h": "dadc7270c40a",
"kind": "dmg"
}
}
},
{
"version": "3.26.143",
"date": "2026-11-30",
"notes": "",
"platforms": {
"darwin-aarch64": {
"file": "updates/darwin-aarch64/image-workbench_3.26.143_aarch64.dmg",
"size": 10138512,
"sha256": "b09f2b1ea2a97983df1b6a1729ec3a50b5a7e6d9aa67ebd4686b89655b15de35",
"h": "b09f2b1ea2a9",
"kind": "dmg"
},
"darwin-x86_64": {
"file": "updates/darwin-x86_64/image-workbench_3.26.143_x64.dmg",
"size": 10594553,
"sha256": "dfb40bfc8c8c5ae4bd35832925c81ea8c3e454bb912e31e09c81dc4e11bff64e",
"h": "dfb40bfc8c8c",
"kind": "dmg"
}
}
},
{
"version": "3.26.142",
"date": "2026-11-30",
"notes": "",
"platforms": {
"darwin-aarch64": {
"file": "updates/darwin-aarch64/image-workbench_3.26.142_aarch64.dmg",
"size": 10137638,
"sha256": "6c7febdc968ee626434a5334665a65022fb6a1a2e7188e530a54d083f7110e96",
"h": "6c7febdc968e",
"kind": "dmg"
},
"darwin-x86_64": {
"file": "updates/darwin-x86_64/image-workbench_3.26.142_x64.dmg",
"size": 10596451,
"sha256": "8fa3e45e17d0f1526c32d8c7328f60129d32da74648fe05d2177cedc69571ce1",
"h": "8fa3e45e17d0",
"kind": "dmg"
}
}
},
{
"version": "3.26.141",
"date": "2026-11-30",
"notes": "",
"platforms": {
"darwin-aarch64": {
"file": "updates/darwin-aarch64/image-workbench_3.26.141_aarch64.dmg",
"size": 10134384,
"sha256": "ae972d3d4a1707f6dbc53c2382c39a18c07f465cca97d5b448296da0713a01c4",
"h": "ae972d3d4a17",
"kind": "dmg"
},
"darwin-x86_64": {
"file": "updates/darwin-x86_64/image-workbench_3.26.141_x64.dmg",
"size": 10594461,
"sha256": "bd592c9cb428b66e380c9b151d885adf66c20cc9d179c899fcb88b37195cfdca",
"h": "bd592c9cb428",
"kind": "dmg"
}
}
},
{
"version": "3.26.135",
"date": "2026-11-30",
+1 -1
View File
@@ -2014,7 +2014,7 @@ dependencies = [
[[package]]
name = "image-workbench"
version = "3.26.135"
version = "3.26.157"
dependencies = [
"arboard",
"base64 0.22.1",
+1 -1
View File
@@ -1,6 +1,6 @@
[package]
name = "image-workbench"
version = "3.26.135"
version = "3.26.158"
description = "无限画布 · 生图工作台桌面版"
authors = ["malongan"]
license = ""
+88
View File
@@ -331,6 +331,7 @@ fn footprint_mb(pid: u32) -> Option<u64> {
// 注意:无任何写操作,只 spawn 只读工具。
// ps 的 etime(DD-HH:MM:SS / HH:MM:SS / MM:SS)→ 秒
#[cfg(unix)]
fn etime_secs(v: &str) -> u64 {
if let Some(pos) = v.find('-') {
let days = v[..pos].parse::<u64>().unwrap_or(0);
@@ -342,6 +343,7 @@ fn etime_secs(v: &str) -> u64 {
v.split(':').fold(0u64, |acc, x| acc * 60 + x.trim().parse::<u64>().unwrap_or(0))
}
#[cfg(unix)]
fn size_to_mb(num: f64, unit: &str) -> u64 {
let f = match unit {
"B" => num / 1048576.0,
@@ -354,6 +356,7 @@ fn size_to_mb(num: f64, unit: &str) -> u64 {
f.round() as u64
}
#[cfg(unix)]
fn parse_footprint(pid: u32) -> Option<serde_json::Value> {
let out = std::process::Command::new("/usr/bin/footprint")
.args(["-p", &pid.to_string()])
@@ -398,8 +401,92 @@ fn parse_footprint(pid: u32) -> Option<serde_json::Value> {
Some(serde_json::json!({ "pid": pid, "footprintMB": phys, "top": top }))
}
/// Windows:按进程给出工作集 + 私有提交(诊断页「内存拆解」用)。
/// 只归拢「本进程 + 它的子进程树」;WebView2 的渲染/GPU/工具进程都叫 msedgewebview2.exe,
/// 角色只能分到进程名,具体分工看 PID 与数值(可与任务管理器逐条对照)。
#[cfg(windows)]
fn windows_mem_breakdown(root: u32) -> serde_json::Value {
use windows_sys::Win32::Foundation::{CloseHandle, INVALID_HANDLE_VALUE};
use windows_sys::Win32::System::Diagnostics::ToolHelp::{
CreateToolhelp32Snapshot, Process32FirstW, Process32NextW, PROCESSENTRY32W, TH32CS_SNAPPROCESS,
};
use windows_sys::Win32::System::ProcessStatus::{GetProcessMemoryInfo, PROCESS_MEMORY_COUNTERS_EX};
use windows_sys::Win32::System::Threading::{OpenProcess, PROCESS_QUERY_LIMITED_INFORMATION, PROCESS_VM_READ};
let mut pairs: Vec<(u32, u32, String)> = Vec::new();
unsafe {
let snap = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);
if snap != INVALID_HANDLE_VALUE {
let mut e: PROCESSENTRY32W = std::mem::zeroed();
e.dwSize = std::mem::size_of::<PROCESSENTRY32W>() as u32;
if Process32FirstW(snap, &mut e) != 0 {
loop {
let end = e.szExeFile.iter().position(|c| *c == 0).unwrap_or(e.szExeFile.len());
let name = String::from_utf16_lossy(&e.szExeFile[..end]);
pairs.push((e.th32ProcessID, e.th32ParentProcessID, name));
e.dwSize = std::mem::size_of::<PROCESSENTRY32W>() as u32;
if Process32NextW(snap, &mut e) == 0 {
break;
}
}
}
CloseHandle(snap);
}
}
let mut tree: Vec<u32> = vec![root];
let mut i = 0;
while i < tree.len() {
let cur = tree[i];
for (p, pp, _) in pairs.iter() {
if *pp == cur && !tree.contains(p) {
tree.push(*p);
}
}
i += 1;
}
let mut rows: Vec<serde_json::Value> = Vec::new();
let mut total: u64 = 0;
for p in tree.iter() {
let h = unsafe { OpenProcess(PROCESS_QUERY_LIMITED_INFORMATION | PROCESS_VM_READ, 0, *p) };
if h == 0 {
continue;
}
let mut pmc: PROCESS_MEMORY_COUNTERS_EX = unsafe { std::mem::zeroed() };
pmc.cb = std::mem::size_of::<PROCESS_MEMORY_COUNTERS_EX>() as u32;
let ok = unsafe { GetProcessMemoryInfo(h, &mut pmc as *mut _ as *mut _, pmc.cb) } != 0;
unsafe { CloseHandle(h) };
if !ok {
continue;
}
let ws = (pmc.WorkingSetSize as u64) / 1048576;
let priv_mb = (pmc.PrivateUsage as u64) / 1048576;
total += ws;
let name = pairs.iter().find(|(id, _, _)| id == p).map(|(_, _, n)| n.clone()).unwrap_or_default();
let role = if *p == root {
"宿主".to_string()
} else if name.to_lowercase().contains("msedgewebview2") {
"WebView2".to_string()
} else if name.is_empty() {
"子进程".to_string()
} else {
name
};
rows.push(serde_json::json!({ "role": role, "pid": p, "footprintMB": ws, "privMB": priv_mb }));
}
rows.sort_by_key(|v| std::cmp::Reverse(v["footprintMB"].as_u64().unwrap_or(0)));
serde_json::json!({ "ok": true, "kind": "workingset", "totalMB": total, "procs": rows })
}
#[tauri::command]
async fn app_memory_breakdown() -> Result<serde_json::Value, String> {
#[cfg(windows)]
{
return Ok(windows_mem_breakdown(std::process::id()));
}
#[cfg(not(windows))]
{
tauri::async_runtime::spawn_blocking(move || {
let pid = std::process::id();
let mut procs: Vec<serde_json::Value> = Vec::new();
@@ -448,6 +535,7 @@ async fn app_memory_breakdown() -> Result<serde_json::Value, String> {
})
.await
.map_err(|e| e.to_string())?
}
}
/// 本进程及其全部子进程的常驻内存合计(MB)。
+1 -1
View File
@@ -1,7 +1,7 @@
{
"$schema": "../node_modules/@tauri-apps/cli/config.schema.json",
"productName": "image-workbench",
"version": "3.26.135",
"version": "3.26.158",
"identifier": "com.malongan.imageworkbench",
"build": {
"frontendDist": "../dist",
+60 -11
View File
@@ -301,8 +301,10 @@
if (!node || node.type === 'relay') return ''
const s = Number(viewport && viewport.scale)
if (!Number.isFinite(s) || s <= 0) return ''
// v3.26.157:取消 30% 那档 lite —— 它在阈值附近来回切换,视觉上就是「画面常闪」。
// 现在只剩一档:<15% 切 plain,其余一律渲染完整节点体。
if (s < LOD_PLAIN_SCALE) return 'plain'
return lodLowOf(viewport, node, nodeWidth) ? 'lite' : ''
return ''
}
// ── 按钮缩放(v3.24.83)────────────────────────────────────────────────
@@ -358,23 +360,28 @@
// 动机:节点一旦挂上 <img>,浏览器就为它保留解码位图(1024 缩略图约 4MB、原图 6~20MB)。
// 原来统一 240px 边距 ⇒ 屏幕外一两屏的图仍常驻解码(实测 WebContent footprint 1.2G / 峰值 2.7G)。
// 现在带图节点只留 80px,同一时刻常驻解码的图片数量明显下降;纯文本节点仍用 240px,避免平移时文字闪。
const CULL_PAD_WIDE = 240
const CULL_PAD_TIGHT = 80
// v3.26.143:参考 infinite-canvas 的 280px 缓冲;80px 会让图片节点在平移边缘反复卸载/重解码。
const CULL_PAD_WIDE = 280
const CULL_PAD_TIGHT = 280
const heavyNodeOf = (type) => {
const t = String(type || '')
return /^(ref|out|image|combine|batch)$/.test(t) || /^plugin:(album|gallery)/.test(t)
}
function cullRectsOf (canvasSize, viewport) {
function cullRectsOf (canvasSize, viewport, extraPad) {
const w = Number(canvasSize && canvasSize.w) || 0
const h = Number(canvasSize && canvasSize.h) || 0
const s = Number(viewport && viewport.scale) || 0
if (!w || !h || !s) return null
const mk = (pad) => ({
left: -viewport.x / s - pad,
top: -viewport.y / s - pad,
right: (w - viewport.x) / s + pad,
bottom: (h - viewport.y) / s + pad,
})
const extra = Math.max(0, Number(extraPad) || 0)
const mk = (pad) => {
const p = pad + extra
return {
left: -viewport.x / s - p,
top: -viewport.y / s - p,
right: (w - viewport.x) / s + p,
bottom: (h - viewport.y) / s + p,
}
}
return { wide: mk(CULL_PAD_WIDE), tight: mk(CULL_PAD_TIGHT) }
}
function nodeVisibleIn (n, rects, opt) {
@@ -383,6 +390,10 @@
if (o.drag && o.drag.start && o.drag.start[n.id] != null) return true
if (o.resize && o.resize.nodeId === n.id) return true
if (o.sel && o.sel.indexOf(n.id) >= 0) return true
// v3.26.156:平移期默认只挂载「起点窗口 + 当前窗口」并集内的节点(不再全量)。
// 全量挂载会把整个世界层撑到几十屏大小,WebKit 只能分块栅格化,平移时就会出现残块/拖影。
// o.mountAll 保留旧行为(诊断开关 iwb_pan_mount_all=1 时启用)。
if (o.pan && o.mountAll) return true
const r = heavyNodeOf(n.type) ? rects.tight : rects.wide
const nw = o.widthOf ? o.widthOf(n) : 0
const nh = o.heightOf ? o.heightOf(n) : 0
@@ -398,5 +409,43 @@
return p ? { x: p.x - (w || 0) / 2, y: p.y - (h || 0) / 2 } : null
} catch (e) { return null }
}
global.IWBCanvasGeometry = Object.freeze({ connectReasonOf, cullRectsOf, nodeVisibleIn, heavyNodeOf, distToSeg, wantsDefaultSpot, promptCenterSpot, parseWorldTransform, clientToWorld, snapToFreeSpot, placeBeside, pruneMeasured, seedFromTopLeft, clampIntoBounds, lodLowOf, lodModeOf, zoomStep, LOD_NODE_PX, LOD_PLAIN_SCALE, ZOOM_STEP, ZOOM_MIN, ZOOM_MAX, create })
// 边线 SVG 固定放在屏幕坐标系:宽度恒为视口 CSS 宽,不会按世界尺寸分配合成位图。
// 世界坐标由内部 <g class="iwb-edge-world"> 的 transform 负责;缩小画布时也不会让 SVG 变大。
function edgeLayerSize (canvasSize) {
return { w: Math.max(1, Number(canvasSize && canvasSize.w) || 800), h: Math.max(1, Number(canvasSize && canvasSize.h) || 600) }
}
function edgeLayerProps (canvasSize) {
const r = edgeLayerSize(canvasSize)
return { width: r.w, height: r.h, viewBox: '0 0 ' + r.w + ' ' + r.h, style: { left: 0, top: 0, width: r.w + 'px', height: r.h + 'px', overflow: 'hidden' } }
}
function edgeGroupTransform (viewport) {
const x = Number(viewport && viewport.x) || 0
const y = Number(viewport && viewport.y) || 0
const s = Number(viewport && viewport.scale) > 0 ? Number(viewport.scale) : 1
return 'translate(' + x + ',' + y + ') scale(' + s + ')'
}
function applyViewportDom (root, canvasSize, x, y, scale, gridOpts, opts) {
if (!root) return
const wl = root.querySelector && root.querySelector('.iwb-world')
if (wl) wl.style.transform = 'translate(' + x + 'px, ' + y + 'px) scale(' + scale + ')'
// v3.26.155:手势期间不写命中层 SVG 的 transform —— 每帧改一个装着上百条 path 的 <g>,
// WebKit 会把整层 SVG 重新布局+栅格化;它本来不可见(视觉在 canvas 上),停手后再对齐一次即可。
if (!(opts && opts.skipEdgeLayer)) applyEdgeLayerDom(root, canvasSize, x, y, scale)
const grid = root.querySelector ? root.querySelector('.iwb-grid') : null
if (!grid) return
const o = gridOpts || { base: 22, dot: 1.4, color: 'rgba(120,128,140,0.55)', on: true }
const G = global.IWBCanvasGrid
if (G && typeof G.applyTo === 'function') {
if (!o.on) { grid.style.display = 'none' } else { grid.style.display = ''; G.applyTo(grid, x, y, scale, o) }
} else {
grid.style.backgroundSize = (28 * scale) + 'px ' + (28 * scale) + 'px'
grid.style.backgroundPosition = x + 'px ' + y + 'px'
}
}
function applyEdgeLayerDom (root, canvasSize, x, y, scale) {
const g = root && root.querySelector ? root.querySelector('.iwb-edge-world') : null
if (g) g.setAttribute('transform', edgeGroupTransform({ x: x, y: y, scale: scale }))
}
global.IWBCanvasGeometry = Object.freeze({ connectReasonOf, cullRectsOf, nodeVisibleIn, heavyNodeOf, edgeLayerSize, edgeLayerProps, edgeGroupTransform, applyEdgeLayerDom, applyViewportDom, distToSeg, wantsDefaultSpot, promptCenterSpot, parseWorldTransform, clientToWorld, snapToFreeSpot, placeBeside, pruneMeasured, seedFromTopLeft, clampIntoBounds, lodLowOf, lodModeOf, zoomStep, LOD_NODE_PX, LOD_PLAIN_SCALE, ZOOM_STEP, ZOOM_MIN, ZOOM_MAX, create })
})(typeof window !== 'undefined' ? window : globalThis)
+3 -2
View File
@@ -57,7 +57,8 @@
return {
backgroundImage: 'url(' + url + ')',
backgroundSize: gap + 'px ' + gap + 'px',
transform: 'translate(' + (x % gap) + 'px, ' + (y % gap) + 'px)',
// 视口大小的网格层用 background-position 跟随平移;不再把元素平移出屏幕(那需要 200% 尺寸的层)。
backgroundPosition: (x % gap) + 'px ' + (y % gap) + 'px',
}
}
@@ -75,7 +76,7 @@
el.dataset.gap = String(gap)
el.dataset.style = String(o.style || 'dots')
}
el.style.transform = 'translate(' + (x % gap) + 'px, ' + (y % gap) + 'px)'
el.style.backgroundPosition = (x % gap) + 'px ' + (y % gap) + 'px'
}
}
+31
View File
@@ -0,0 +1,31 @@
/* canvas-v3-hit.js —— Canvas V3 节点命中测试(2026-12-01)
* ref: body + 端口;P2 文本节点只做 body,端口先留给选中后的 NodeCard。
*/
;(function (global) {
'use strict'
function hitNode (nodes, wx, wy, opts) {
const o = opts || {}
const isType = typeof o.isType === 'function' ? o.isType : (n) => n && n.type === 'ref'
const widthOf = typeof o.widthOf === 'function' ? o.widthOf : (n) => n.w || 240
const heightOf = typeof o.heightOf === 'function' ? o.heightOf : (n) => n.h || 220
const portR = Number(o.portRadiusWorld) > 0 ? Number(o.portRadiusWorld) : 10
const wantPorts = o.wantPorts !== false
const list = Array.isArray(nodes) ? nodes : []
for (let i = list.length - 1; i >= 0; i--) {
const n = list[i]
if (!n || !isType(n)) continue
const w = widthOf(n), h = heightOf(n)
const cy = n.y + h / 2
if (wantPorts && n.type === 'ref') {
if (wx >= n.x - portR && wx <= n.x + portR && Math.abs(wy - cy) <= portR) return { node: n, port: 'in' }
if (Math.abs(wx - (n.x + w)) <= portR && Math.abs(wy - cy) <= portR) return { node: n, port: 'out' }
}
if (wx >= n.x && wx <= n.x + w && wy >= n.y && wy <= n.y + h) return { node: n, port: '' }
}
return null
}
function hitRefNode (nodes, wx, wy, opts) {
return hitNode(nodes, wx, wy, Object.assign({}, opts || {}, { isType: (n) => n && n.type === 'ref', wantPorts: true }))
}
global.IWBCanvasV3Hit = { hitNode, hitRefNode }
})(typeof window !== 'undefined' ? window : globalThis)
+240
View File
@@ -0,0 +1,240 @@
/* canvas-v3-node-layer.js —— Canvas V3 图片节点静态层(2026-12-01,P1 垂直切片)
*
* 仅当 data-canvas-v3="on" 时由 app 挂载;未选中的 ref 节点由 canvas 画卡片/标题/图片,
* DOM 只保留一个透明 hit proxy。选中后恢复完整 NodeCard。
* 目标与限制见 docs/plans/canvas-v3-long-term.md。
*/
;(function (global) {
'use strict'
const React = global.React || {}
const el = (type, prop, ...children) => React.createElement(type, prop, ...children)
const useRef = React.useRef
const useEffect = React.useEffect
const useState = React.useState
const imgCache = new Map()
const perf = { lastMs: 0, frames: 0 }
function css (name, fallback) {
try {
const v = getComputedStyle(document.documentElement).getPropertyValue(name).trim()
return v || fallback
} catch (e) { return fallback }
}
function roundRect (ctx, x, y, w, h, r) {
const rr = Math.max(0, Math.min(r, w / 2, h / 2))
ctx.beginPath()
ctx.moveTo(x + rr, y)
ctx.arcTo(x + w, y, x + w, y + h, rr)
ctx.arcTo(x + w, y + h, x, y + h, rr)
ctx.arcTo(x, y + h, x, y, rr)
ctx.arcTo(x, y, x + w, y, rr)
ctx.closePath()
}
function imageOf (url, onLoad) {
if (!url) return null
let entry = imgCache.get(url)
if (!entry) {
entry = { img: new Image(), loaded: false }
entry.img.decoding = 'async'
entry.img.onload = () => { entry.loaded = true; if (typeof onLoad === 'function') onLoad() }
entry.img.onerror = () => { entry.failed = true; if (typeof onLoad === 'function') onLoad() }
entry.img.src = url
if (imgCache.size > 64) { const k = imgCache.keys().next().value; if (k !== undefined) imgCache.delete(k) }
imgCache.set(url, entry)
}
return entry
}
function drawUnsafe (canvas, o) {
if (!canvas || !o || typeof canvas.getContext !== 'function') return
const t0 = (typeof performance !== 'undefined' && performance.now) ? performance.now() : 0
const rect = canvas.getBoundingClientRect ? canvas.getBoundingClientRect() : null
const w = Math.max(1, Math.round((rect && rect.width) || canvas.clientWidth || 1))
const h = Math.max(1, Math.round((rect && rect.height) || canvas.clientHeight || 1))
const dpr = Math.min(2, (typeof devicePixelRatio === 'number' && devicePixelRatio > 0) ? devicePixelRatio : 1)
if (canvas.width !== Math.round(w * dpr) || canvas.height !== Math.round(h * dpr)) {
canvas.width = Math.round(w * dpr); canvas.height = Math.round(h * dpr)
}
const ctx = canvas.getContext('2d')
if (!ctx) return
ctx.setTransform(dpr, 0, 0, dpr, 0, 0)
ctx.clearRect(0, 0, w, h)
const vp = o.viewport || { x: 0, y: 0, scale: 1 }
const scale = Number(vp.scale) > 0 ? Number(vp.scale) : 1
const nodes = Array.isArray(o.nodes) ? o.nodes : []
const sel = Array.isArray(o.sel) ? o.sel : []
const widthOf = typeof o.widthOf === 'function' ? o.widthOf : (n) => n.w || 240
const heightOf = typeof o.heightOf === 'function' ? o.heightOf : (n) => n.h || 220
const imageFor = typeof o.imageFor === 'function' ? o.imageFor : () => ''
const outThumbsFor = typeof o.outThumbsFor === 'function' ? o.outThumbsFor : () => []
const onImageLoad = o.onImageLoad
const types = Array.isArray(o.types) && o.types.length ? o.types : ['ref']
const isType = typeof o.isType === 'function' ? o.isType : (n) => types.indexOf(n.type) >= 0
const bg = css('--iwb-panel', '#ffffff')
const border = css('--iwb-border2', '#d7dbe2')
const text = css('--iwb-text2', '#5f6673')
const accent = css('--iwb-brand', '#6b7280')
const radius = 14
const headH = 34
ctx.setTransform(dpr * scale, 0, 0, dpr * scale, dpr * (Number(vp.x) || 0), dpr * (Number(vp.y) || 0))
ctx.lineJoin = 'round'
for (const n of nodes) {
if (!n || !isType(n) || sel.indexOf(n.id) >= 0) continue
const x = n.x, y = n.y, nw = widthOf(n), nh = heightOf(n)
const screenW = nw * scale
// LOD:极小节点只画底板,跳标题/文本/图片,避免 7000 节点缩放时做无用绘制。
if (screenW < 8) {
ctx.fillStyle = bg
ctx.fillRect(x, y, nw, nh)
continue
}
const lowDetail = screenW < 40
// 卡片
ctx.fillStyle = bg
roundRect(ctx, x, y, nw, nh, radius)
ctx.fill()
ctx.strokeStyle = border
ctx.lineWidth = 1 / scale
ctx.stroke()
// 标题
ctx.fillStyle = text
ctx.font = '600 ' + Math.max(10, 12 / scale * 0.9) + 'px -apple-system, BlinkMacSystemFont, "PingFang SC", sans-serif'
const title = String((n.data && (n.data.title || n.data.name)) || ({ ref: '参考图', prompt: '提示词', textout: '文本', combine: '组合', batch: '连接', relay: '中继', gen: '生成配置', layer: '分层', plugin: '插件' }[n.type] || (String(n.type).indexOf('plugin:') === 0 ? '插件' : '节点')))
if (!lowDetail) {
ctx.save()
ctx.beginPath(); ctx.rect(x + 10, y, Math.max(0, nw - 20), headH); ctx.clip()
ctx.fillText(title, x + 12, y + 21)
ctx.restore()
}
const pad = 10
const ix = x + pad, iy = y + headH, iw = Math.max(1, nw - pad * 2), ih = Math.max(1, nh - headH - pad)
if (lowDetail) continue
if (n.type === 'ref') {
// 图片区
const raw = n.data && (n.data.data || n.data.url)
const url = raw ? imageFor(n, raw) : ''
const entry = url ? imageOf(url, onImageLoad) : null
if (entry && entry.loaded && !entry.failed) {
const iw0 = entry.img.naturalWidth || iw
const ih0 = entry.img.naturalHeight || ih
const k = Math.min(iw / iw0, ih / ih0)
const dw = iw0 * k, dh = ih0 * k
try { ctx.drawImage(entry.img, ix + (iw - dw) / 2, iy + (ih - dh) / 2, dw, dh) } catch (e) { /* cross-origin */ }
} else {
ctx.fillStyle = css('--iwb-layer2', '#f1f2f4')
roundRect(ctx, ix, iy, iw, ih, 10)
ctx.fill()
ctx.fillStyle = text
ctx.font = Math.max(10, 12 / scale * 0.9) + 'px -apple-system, BlinkMacSystemFont, "PingFang SC", sans-serif'
ctx.fillText(entry && entry.failed ? '图片源失效' : '图片加载中…', ix + 12, iy + 24)
}
} else if (n.type === 'out') {
// 输出节点:画结果缩略图网格;没有结果时提示选中查看。
const urls = outThumbsFor(n) || []
if (urls.length) {
const cols = 2
const gap = 4
const cw = Math.max(1, (iw - gap) / cols)
const ch = cw * 0.75
for (let i = 0; i < Math.min(4, urls.length); i++) {
const col = i % cols, row = Math.floor(i / cols)
const x0 = ix + col * (cw + gap), y0 = iy + row * (ch + gap)
const entry = imageOf(imageFor(n, urls[i]), onImageLoad)
ctx.fillStyle = css('--iwb-layer2', '#f1f2f4')
roundRect(ctx, x0, y0, cw, ch, 6); ctx.fill()
if (entry && entry.loaded && !entry.failed) {
try { ctx.drawImage(entry.img, x0, y0, cw, ch) } catch (e) { /* ignore */ }
}
}
} else {
ctx.fillStyle = text
ctx.font = Math.max(10, 12 / scale * 0.9) + 'px -apple-system, BlinkMacSystemFont, "PingFang SC", sans-serif'
ctx.fillText('选中查看结果', ix + 2, iy + Math.max(14, 16 / scale))
}
} else if (n.type === 'layer') {
// 分层节点:画层列表;选中后由 NodeCard 负责完整图层操作。
const layers = (n.data && Array.isArray(n.data.layers)) ? n.data.layers : []
ctx.fillStyle = text
ctx.font = Math.max(10, 12 / scale * 0.9) + 'px -apple-system, BlinkMacSystemFont, "PingFang SC", sans-serif'
const lh = Math.max(14, 20 / scale)
let yy = iy + Math.max(14, 18 / scale)
for (let i = 0; i < Math.min(8, layers.length); i++) {
const name = String((layers[i] && layers[i].name) || ('图层 ' + (i + 1)))
ctx.fillText(name, ix + 2, yy)
yy += lh
if (yy > iy + ih) break
}
if (!layers.length) ctx.fillText('选中查看分层', ix + 2, iy + Math.max(14, 16 / scale))
} else {
// P2 文本节点:画截断文本,选中后由 NodeCard 负责编辑。
ctx.save()
ctx.beginPath(); ctx.rect(ix, iy, iw, ih); ctx.clip()
ctx.fillStyle = text
ctx.font = Math.max(10, 12 / scale * 0.9) + 'px -apple-system, BlinkMacSystemFont, "PingFang SC", sans-serif'
const rawText = String((n.data && (n.data.text || n.data.prompt || n.data.title)) || '')
const lineH = Math.max(12, 18 / scale)
const maxW = Math.max(20, iw - 4)
let line = ''
let ty = iy + Math.max(14, 16 / scale)
for (const ch of rawText) {
const next = line + ch
if (ctx.measureText(next).width > maxW && line) {
ctx.fillText(line, ix + 2, ty); ty += lineH; line = ch
if (ty > iy + ih) break
} else line = next
}
if (line && ty <= iy + ih) ctx.fillText(line, ix + 2, ty)
ctx.restore()
}
// 端口:ref 的 canvas 命中;P2 文本节点先只做 body 命中。
if (n.type === 'ref') {
const portR = Math.max(2, 4 / scale)
ctx.fillStyle = bg
ctx.strokeStyle = border
ctx.lineWidth = 1 / scale
for (const [px, py] of [[x, y + nh / 2], [x + nw, y + nh / 2]]) {
ctx.beginPath(); ctx.arc(px, py, portR, 0, Math.PI * 2); ctx.fill(); ctx.stroke()
}
}
void accent
}
if (t0) { perf.lastMs = (typeof performance !== 'undefined' && performance.now ? performance.now() : t0) - t0; perf.frames++ }
}
// 单帧绘制失败不能冒泡到 React effect;记录后保留上一帧,下一帧重试。
function draw (canvas, o) {
try {
drawUnsafe(canvas, o)
perf.lastError = ''
} catch (e) {
perf.lastError = String((e && e.message) || e)
}
}
function CanvasNodeLayer (props) {
const ref = useRef(null)
const latest = useRef(props)
latest.current = props
const [rev, setRev] = useState(0)
void rev
useEffect(() => {
const canvas = ref.current
if (!canvas) return
const p = latest.current || {}
draw(canvas, Object.assign({}, p, { onImageLoad: () => setRev((v) => v + 1) }))
if (typeof p.onReady === 'function') {
p.onReady(function (x, y, scale) {
const q = latest.current || {}
draw(canvas, Object.assign({}, q, { viewport: { x: x, y: y, scale: scale }, onImageLoad: () => setRev((v) => v + 1) }))
})
}
})
useEffect(() => () => { if (typeof props.onReady === 'function') props.onReady(null) }, [])
return el('canvas', { className: 'iwb-node-canvas', 'aria-hidden': 'true', ref: ref })
}
function stats () { return { drawMs: perf.lastMs, frames: perf.frames, images: imgCache.size, error: perf.lastError || '' } }
global.IWBCanvasV3NodeLayer = { CanvasNodeLayer, draw, stats }
})(typeof window !== 'undefined' ? window : globalThis)
+69
View File
@@ -0,0 +1,69 @@
/* canvas-v3.js —— Canvas 静态渲染迁移的特性开关(2026-12-01,Phase 0)
*
* 默认关闭;开启后只改变 data-canvas-v3 与后续渲染器选择,不影响数据格式。
* 目标架构见 docs/plans/canvas-v3-long-term.md。
*/
;(function (global) {
'use strict'
const KEY = 'iwb_canvas_v3'
const ATTR = 'canvasV3'
// src 内不直调 localStorage:统一走 IWBStorageLocal 门面(桌面端会落到资料目录底座)。
function store () {
try {
const S = global.IWBStorageLocal
return (S && typeof S.getStore === 'function') ? S.getStore() : null
} catch (e) { return null }
}
// 2026-12-01:Canvas V3 实验停止。旧用户即使 localStorage 里还留着 '1',也必须回 DOM。
// 保留代码仅用于后续研究;产品路径不再进入 Canvas V3。
function isEnabled () {
return false
}
function syncRoot (on) {
try {
if (typeof document !== 'undefined' && document.documentElement) {
document.documentElement.dataset[ATTR] = on ? 'on' : 'off'
}
} catch (e) { /* ignore */ }
}
function setEnabled (on) {
const next = false // kill switch:不再允许开启
try {
const s = store()
if (s && typeof s.rawSet === 'function') s.rawSet(KEY, '0')
} catch (e) { /* ignore */ }
syncRoot(next)
try {
if (typeof window !== 'undefined' && typeof window.dispatchEvent === 'function' && typeof CustomEvent === 'function') {
window.dispatchEvent(new CustomEvent('iwb:canvas-v3', { detail: { enabled: next } }))
}
} catch (e) { /* ignore */ }
return next
}
function init () {
syncRoot(false)
try { const s = store(); if (s && typeof s.rawSet === 'function') s.rawSet(KEY, '0') } catch (e) { /* ignore */ }
return false
}
function stats () {
const on = isEnabled()
let dom = -1
try { dom = document.getElementsByTagName('*').length } catch (e) { /* ignore */ }
let node = null
try {
const L = global.IWBCanvasV3NodeLayer
if (L && typeof L.stats === 'function') node = L.stats()
} catch (e) { /* ignore */ }
return { enabled: on, dom, node }
}
// P2 第一批:ref 图片节点 + prompt/textout 文本类节点。
const TYPES = ['ref', 'prompt', 'textout', 'combine', 'batch', 'relay', 'gen', 'out', 'layer']
global.IWBCanvasV3 = { KEY, TYPES, isEnabled, setEnabled, init, stats }
})(typeof window !== 'undefined' ? window : globalThis)
+2 -1
View File
@@ -60,5 +60,6 @@
}
function failedCount () { return failedKeys.size }
global.IWBImageCacheMigrate = { once: once, _collect: collect, failedCount: failedCount }
function isFailed (key) { return failedKeys.has(String(key || '')) }
global.IWBImageCacheMigrate = { once: once, _collect: collect, failedCount: failedCount, isFailed: isFailed }
})(typeof window !== 'undefined' ? window : globalThis)
+15 -2
View File
@@ -181,6 +181,15 @@
// performance.memory 只有 Chromium 系提供,Safari/Firefox 下静默降级不报错。
let memWarnAt = 0
let memReclaimAt = 0 // v3.26.117:绝对占用护栏的冷却时间(与 75% 那条链互不影响)
let lastUserAt = Date.now() // 2026-12-01:可见但空闲时的轻量回收判断
try {
if (typeof window !== 'undefined' && typeof window.addEventListener === 'function') {
const markUser = () => { lastUserAt = Date.now() }
window.addEventListener('pointerdown', markUser, { passive: true })
window.addEventListener('keydown', markUser, { passive: true })
window.addEventListener('wheel', markUser, { passive: true })
}
} catch (e) { /* ignore */ }
let memDegradeAt = 0
let memDegradeStage = 0 // S15:0=首触(只降级"非打开标签"画板);1=再触(压到活动标签 + 提示关标签)
const memTimer = setInterval(() => {
@@ -223,9 +232,13 @@
const estNow = (compNow && compNow.procEstMB > 0) ? compNow.procEstMB : 0
const procEst = rssNow > 0 ? rssNow : (estNow > 0 ? estNow : ((mem && mem.usedMB) || 0))
const procLimit = rssNow > 0 ? 1100 : 800
if (procEst >= procLimit && nowMs - memReclaimAt > 120000 && !(refs && refs.saving) && !(refs && refs.genRuns && refs.genRuns.size)) {
// v3.26.143:运行中不每 2 分钟清缓存(会触发图片重解码)。2026-12-01 折中:
// 不可见立即回收;可见但连续 5 分钟没有任何输入时,也只做轻量回收(保留显示缩略图)。
const idleMs = nowMs - lastUserAt
const canVisibleIdleReclaim = !(typeof document !== 'undefined' && document.hidden) && idleMs > 300000
if (procEst >= procLimit && nowMs - memReclaimAt > 120000 && !(refs && refs.saving) && !(refs && refs.genRuns && refs.genRuns.size) && ((typeof document === 'undefined' || document.hidden) || canVisibleIdleReclaim)) {
memReclaimAt = nowMs
Promise.resolve().then(() => wReclaimMemoryNow('auto ' + (rssNow > 0 ? 'rss ' : 'est ') + procEst + 'MB')).catch(() => { /* ignore */ })
Promise.resolve().then(() => wReclaimMemoryNow('auto ' + (canVisibleIdleReclaim ? 'idle ' : '') + (rssNow > 0 ? 'rss ' : 'est ') + procEst + 'MB', { keepThumbs: true })).catch(() => { /* ignore */ })
}
// 下面这条是「堆占比 ≥75%」的老护栏,只有 Chromium 系(Windows)才有意义
if (!mem || !mem.ratio) return
+103
View File
@@ -0,0 +1,103 @@
/* ui-canvas-edges.js —— 边线 canvas 视觉层(2026-11-30)
*
* 为什么不再用 SVG 画线:
* - SVG 每次平移/缩放都要重栅格化一个屏幕大小的矢量层;WKWebView 上这是明确的热点。
* - canvas 只做一次 2D stroke,100 条贝塞尔很便宜,且不产生 SVG 的 DOM/合成层。
*
* 交互仍由 .iwb-edges(透明 hit path)负责:canvas 只画,不接收指针事件。
* 平移/拖节点走命令式 draw(applyViewportDom / dragApplyVisual),不触发 React。
*/
;(function (global) {
'use strict'
const React = global.React || {}
const el = (type, prop, ...children) => React.createElement(type, prop, ...children)
const useRef = React.useRef
const useEffect = React.useEffect
function cssVar(name, fallback) {
try {
const v = getComputedStyle(document.documentElement).getPropertyValue(name).trim()
return v || fallback
} catch (e) { return fallback }
}
function draw(canvas, o) {
if (!canvas || !o || typeof canvas.getContext !== 'function') return
const rect = canvas.getBoundingClientRect ? canvas.getBoundingClientRect() : null
const w = Math.max(1, Math.round((rect && rect.width) || canvas.clientWidth || 1))
const h = Math.max(1, Math.round((rect && rect.height) || canvas.clientHeight || 1))
const dpr = Math.min(2, (typeof devicePixelRatio === 'number' && devicePixelRatio > 0) ? devicePixelRatio : 1)
const bw = Math.round(w * dpr), bh = Math.round(h * dpr)
if (canvas.width !== bw || canvas.height !== bh) { canvas.width = bw; canvas.height = bh }
const ctx = canvas.getContext('2d')
if (!ctx) return
ctx.setTransform(dpr, 0, 0, dpr, 0, 0)
ctx.clearRect(0, 0, w, h)
const vp = o.viewport || { x: 0, y: 0, scale: 1 }
const scale = Number(vp.scale) > 0 ? Number(vp.scale) : 1
const baseW = parseFloat(cssVar('--iwb-edge-w', '1.4')) || 1.4
const edgeColor = cssVar('--iwb-edge', '#8b95a5')
const hotColor = cssVar('--iwb-edge-hot', '#6b7280')
const warnColor = cssVar('--iwb-warn', '#e0a030')
const errColor = cssVar('--iwb-err', '#e05252')
const hoverId = o.hoverEdgeId || ''
const selected = o.selEdge || ''
const focus = o.focusNodeId || ''
const edgeHover = o.edgeHover || null
const edges = Array.isArray(o.edges) ? o.edges : []
const pathOf = typeof o.computeEdgePath === 'function' ? o.computeEdgePath : null
if (!pathOf) return
ctx.setTransform(dpr * scale, 0, 0, dpr * scale, dpr * (Number(vp.x) || 0), dpr * (Number(vp.y) || 0))
ctx.lineCap = 'round'
ctx.lineJoin = 'round'
for (let i = 0; i < edges.length; i++) {
const ed = edges[i]
if (!ed) continue
let d = ''
try { d = pathOf(ed, o.graph, o.nodeMap, o.measuredH, o.pathCache) || '' } catch (e) { d = '' }
if (!d || typeof Path2D === 'undefined') continue
const isSel = selected === ed.id
const isHot = focus && (ed.to === focus || ed.from === focus)
const isHover = hoverId === ed.id
const isDetach = !!(edgeHover && edgeHover.mode === 'detach' && Array.isArray(edgeHover.edgeIds) && edgeHover.edgeIds.indexOf(ed.id) >= 0)
const isInsert = !!(edgeHover && edgeHover.mode === 'insert' && edgeHover.edgeId === ed.id)
ctx.strokeStyle = isSel ? warnColor : (isDetach ? errColor : (isHot || isHover || isInsert ? hotColor : edgeColor))
ctx.lineWidth = (isSel || isHot || isHover || isInsert || isDetach) ? Math.max(2.2, baseW * 1.6) : baseW
ctx.setLineDash(isDetach ? [6 / scale, 4 / scale] : (isInsert ? [6 / scale, 4 / scale] : []))
ctx.stroke(new Path2D(d))
}
if (o.tempD && typeof Path2D !== 'undefined') {
ctx.strokeStyle = o.connTarget && o.connTarget.valid === false ? errColor : hotColor
ctx.lineWidth = Math.max(2, baseW)
ctx.setLineDash([6 / scale, 4 / scale])
try { ctx.stroke(new Path2D(o.tempD)) } catch (e) { /* ignore */ }
}
ctx.setLineDash([])
}
function EdgeCanvas(props) {
const ref = useRef(null)
const latest = useRef(props)
latest.current = props
useEffect(() => {
const canvas = ref.current
if (!canvas) return
// 平移期间 applyViewportDom 会给 canvas 加 CSS translate;React 提交最终视口时清掉再画。
try { canvas.style.transform = '' } catch (e) { /* ignore */ }
draw(canvas, latest.current)
if (typeof props.onReady === 'function') {
props.onReady(function (x, y, scale) {
const p = latest.current || {}
draw(canvas, Object.assign({}, p, { viewport: { x: x, y: y, scale: scale } }))
})
}
})
useEffect(() => () => { if (typeof props.onReady === 'function') props.onReady(null) }, [])
return el('canvas', { className: 'iwb-edge-canvas', 'aria-hidden': 'true', ref: ref })
}
global.IWBCanvasEdges = { EdgeCanvas, draw }
})(typeof window !== 'undefined' ? window : globalThis)
+3 -1
View File
@@ -9,11 +9,13 @@
'use strict'
function buildNodeEls(ctx) {
const { CanvasGeometry, CanvasStore, EMPTY_OBJ, NODE_W, NodeCardMemo, addRefFromUrl, batchPortTop, batchSourcesMap, canConnect, cancelRun, config, connTarget, defaultNodeBoxWidth, deleteNodes, duplicateNodes, edges, el, generationConcurrency, hOf, inPortWorld, isBatchSrc, lodViewport, nodeDerived, nodeOnMeasure, nodeOnPreview, nodeOnSelect, nodeTypeH, nodeWidth, nodes, pushHistory, refs, runLLM, runLayerNode, runNode, runOutSources, saveNow, sel, selRef, setConn, setConnTarget, setNotice, setSel, taskCountOf, thumbRev, typesRev, uiZoom, uid, updateNode, visibleIds, wLodEnabled, zoomToNode } = ctx
const { CanvasGeometry, CanvasStore, EMPTY_OBJ, NODE_W, NodeCardMemo, addRefFromUrl, batchPortTop, batchSourcesMap, canConnect, cancelRun, config, connTarget, canvasV3On, canvasV3TypeOf, defaultNodeBoxWidth, deleteNodes, duplicateNodes, edges, el, generationConcurrency, hOf, inPortWorld, isBatchSrc, lodViewport, nodeDerived, nodeOnMeasure, nodeOnPreview, nodeOnSelect, nodeTypeH, nodeWidth, nodes, pushHistory, refs, runLLM, runLayerNode, runNode, runOutSources, saveNow, sel, selRef, setConn, setConnTarget, setNotice, setSel, taskCountOf, thumbRev, typesRev, uiZoom, uid, updateNode, visibleIds, wLodEnabled, zoomToNode } = ctx
const nodeEls = []
const batchSourcesById = batchSourcesMap
for (const n of nodes) {
if (!visibleIds.has(n.id)) continue
// Canvas V3:未选中的 ref 节点完全由 canvas 画,DOM 不挂 NodeCard;点击走 canvas 命中测试。
if (canvasV3On && canvasV3TypeOf(n) && !sel.includes(n.id)) continue
// 细粒度:只传该节点相关的 busy/progress/connTarget(其他节点引用稳定,memo 跳过)
let busySelf = nodeDerived.busyById.get(n.id) || EMPTY_OBJ
let progSelf = nodeDerived.progById.get(n.id) || EMPTY_OBJ
+8 -2
View File
@@ -61,6 +61,9 @@
const gEl = el0.querySelector('[data-edge-id="' + ed.id + '"]')
if (gEl && d) { const ps = gEl.querySelectorAll('path'); for (let i = 0; i < ps.length; i++) ps[i].setAttribute('d', d) }
}
// 边线/节点 canvas:拖动中坐标已就地更新,命令式重画一次(不触发 React)。
try { if (typeof refs.edgeCanvasDraw === 'function') refs.edgeCanvasDraw(refs.viewport.x, refs.viewport.y, refs.viewport.scale) } catch (e) { /* ignore */ }
try { if (typeof refs.nodeCanvasDraw === 'function') refs.nodeCanvasDraw(refs.viewport.x, refs.viewport.y, refs.viewport.scale) } catch (e) { /* ignore */ }
// 节点组外框实时跟随:外框由成员包围盒派生,拖动中不重渲染 → 必须就地改 DOM(否则松手才跳)。
// 用 refs.nodeGroupMap 反查受影响的组,避免每帧 O(groups×members) 扫描。
if (refs.nodeGroupMap && refs.nodeGroupMap.size) {
@@ -140,8 +143,11 @@
if (refs.pan) {
const p = refs.pan
p.mx = mx; p.my = my
// 只改 DOM:React 不重渲染,世界层不重栅格化(v3.25.68)
applyViewportDom(p.vx + (p.mx - p.sx), p.vy + (p.my - p.sy), refs.viewport.scale)
// 只改 DOM;同一帧内多次 pointermove 合并成一次写入(参考 infinite-canvas 的 rAF 合批)。
rafSet(() => {
if (!refs.pan) return
applyViewportDom(p.vx + (p.mx - p.sx), p.vy + (p.my - p.sy), refs.viewport.scale)
})
return
}
if (refs.groupResize) {
+8 -2
View File
@@ -195,10 +195,16 @@ function EdgePath(props) {
const relation = focusNodeId ? (ed.to === focusNodeId ? ' iwb-edge-upstream' : (ed.from === focusNodeId ? ' iwb-edge-downstream' : '')) : ''
const cls = 'iwb-edge' + (selEdge === ed.id ? ' iwb-edge-sel' : '') + relation + ((edgeHover && edgeHover.mode === 'insert' && edgeHover.edgeId === ed.id) ? ' iwb-edge-hot' : '') + ((edgeHover && edgeHover.mode === 'detach' && edgeHover.edgeIds.indexOf(ed.id) >= 0) ? ' iwb-edge-detach' : '')
// 双击连线 = 断开连线:这是用户明确要保留的操作习惯(2026-11-28 确认),不要删。
const hnd = { onPointerDown: (e) => { e.stopPropagation(); onSelect(ed.id) }, onDoubleClick: (e) => { e.stopPropagation(); onDelete(ed.id) } }
const hnd = {
onPointerDown: (e) => { e.stopPropagation(); onSelect(ed.id) },
onDoubleClick: (e) => { e.stopPropagation(); onDelete(ed.id) },
onPointerEnter: () => { if (typeof props.onHover === 'function') props.onHover(ed.id) },
onPointerLeave: () => { if (typeof props.onHover === 'function') props.onHover('') },
}
return el('g', { 'data-edge-id': ed.id },
el('path', { key: ed.id + '_hit', className: 'iwb-edge-hit', d, fill: 'none', ...hnd }),
el('path', { key: ed.id, className: cls, d, fill: 'none', title: '点击选中(Delete 断开)· 双击直接断开', ...hnd }),
// 视觉由 canvas 层画;保留一个 display:none 的旧路径节点给 e2e/选择器兼容(不参与绘制)。
el('path', { key: ed.id, className: cls, d, fill: 'none', style: props.visual === false ? { display: 'none' } : undefined, title: '点击选中(Delete 断开)· 双击直接断开', ...hnd }),
)
}
+17 -1
View File
@@ -1190,6 +1190,22 @@
return line.length > 40 ? (line.slice(0, 40) + '…') : line
}
// Canvas V3:out 节点的结果图 URL 列表(只读;仍复用 outGroupsOf 的分组/排序)。
function outThumbUrlsOf (node, nodes, edges) {
const nodeMap = new Map((nodes || []).map((n) => [n.id, n]))
// Canvas V3 可能在 NodeCard 还没渲染过时调用本函数,此时 inject 还没发生 —— 用本职能兜底。
const isProducer = typeof isImageProducer === 'function' ? isImageProducer : (n) => !!(n && (n.type === 'gen' || n.type === 'out' || n.type === 'ref' || n.type === 'combine' || n.type === 'batch'))
const tasksOf = typeof cachedGenerationTasks === 'function' ? cachedGenerationTasks : () => []
const srcGens = (edges || [])
.filter((e) => e.to === node.id)
.map((e) => nodeMap.get(e.from))
.filter((n) => isProducer(n) && !(n.data && n.data.enabled === false))
const merged = outGroupsOf(srcGens, (g) => tasksOf(g, nodes || [], edges || []).map((t) => ({ id: t.id, title: t.title || '' })))
const urls = []
for (const m of merged) for (const r of m.items) if (r && r.url) urls.push(r.url)
return urls
}
function lodBody(node, mode) {
const isImg = LOD_IMG_TYPES.indexOf(node.type) >= 0
if (mode !== 'plain' && isImg) {
@@ -1213,5 +1229,5 @@
}
// md:纯函数(Markdown ⇄ 编辑器 HTML)的测试钩子 —— 行距翻倍的回归由 tests/prompt-md-roundtrip-test.js 守住
global.IWBNodeBodies = { inject, openPromptExpand, md: { toHtml: mdToHtml, toMd: htmlToMd }, relay: renderRelayBody, prompt: renderPromptBody, plugin: renderPluginBody, textout: renderTextoutBody, combine: renderCombineBody, llm: renderLlmBody, batch: renderBatchBody, ref: renderRefBody, out: renderOutBody, gen: renderGenBody, outGroupsOf, lodBody }
global.IWBNodeBodies = { inject, openPromptExpand, md: { toHtml: mdToHtml, toMd: htmlToMd }, relay: renderRelayBody, prompt: renderPromptBody, plugin: renderPluginBody, textout: renderTextoutBody, combine: renderCombineBody, llm: renderLlmBody, batch: renderBatchBody, ref: renderRefBody, out: renderOutBody, gen: renderGenBody, outGroupsOf, outThumbUrlsOf, lodBody }
})(typeof window !== 'undefined' ? window : globalThis)
+31 -5
View File
@@ -54,7 +54,20 @@
const copyDiag = async () => {
let text = ''
try {
text = (typeof props.diagText === 'function') ? props.diagText() : JSON.stringify(CrashLog ? CrashLog.report({ version: APP_VERSION }) : {}, null, 2)
const base = (typeof props.diagText === 'function') ? props.diagText() : JSON.stringify(CrashLog ? CrashLog.report({ version: APP_VERSION }) : {}, null, 2)
// v3.26.158:把「设置→诊断」面板里那几块(分进程内存拆解/解码账本/缩略图磁盘/插件源)
// 一起写进剪贴板 JSON —— 否则它们只在面板上,导出与日志都拿不到。
let obj = null
try { obj = JSON.parse(base) } catch (e2) { obj = null }
if (obj && typeof props.diagExtras === 'function') {
// v3.26.158:把开关状态(合成层常驻提升 / 禁用毛玻璃)与 DOM 规模一并带上 ——
// 否则从导出文件里无法确认 A/B 到底按没按。
try { obj.diagExtras = props.diagExtras() } catch (eX) { obj.diagExtrasError = String((eX && eX.message) || eX) }
}
if (obj && typeof props.diagDetail === 'function') {
try { obj.diagDetail = await props.diagDetail() } catch (e3) { obj.diagDetailError = String((e3 && e3.message) || e3) }
}
text = obj ? JSON.stringify(obj, null, 2) : base
} catch (e) { setMsg({ type: 'err', text: '生成诊断信息失败:' + String((e && e.message) || e) }); return }
// 复制统一走 IWBClipboardCopy(2026-11-24):内含 navigator → textarea+execCommand 的降级链,
// 不再各处自己判断 clipboard 是否可用(那样每处都要复述一份兜底逻辑)。
@@ -107,6 +120,15 @@
// v3.26.117:内存回收。只清可重建的缓存(撤销历史/缩略图/图片字节缓存)并把非活动画板降回引用形态,不删用户数据。
el('button', { className: 'iwb-btn iwb-btn-sm', title: '立即回收内存:清撤销历史、缩略图缓存与图片字节缓存,非活动画板降回引用形态(不删任何画板/图片)', onClick: async () => { if (typeof reclaimMemory === 'function') await reclaimMemory() } }, '立即回收内存'),
el('button', { className: 'iwb-btn iwb-btn-sm', title: '导出完整诊断 JSON(下载文件)', onClick: () => { if (typeof props.onExportDiag === 'function') props.onExportDiag(); else setMsg({ type: 'err', text: '当前环境不支持诊断导出' }) } }, '导出 JSON'),
el('label', { className: 'iwb-diag-kv', title: '打开后整个画布世界会被提升成一个常驻合成层:拖拽/缩放更顺,但内存会明显上涨(实测 +700MB 级)。改完等 10 秒看「进程实测」对比。' },
el('input', { type: 'checkbox', checked: !!(extras && extras.layers), onChange: (e) => { if (typeof props.onToggleLayers === 'function') props.onToggleLayers(e.target.checked) } }),
' 合成层常驻提升'),
el('label', { className: 'iwb-diag-kv', title: '手势期间(拖拽/缩放)把世界层临时提升为合成层;关掉可二分「平移残影」与 GPU 峰值' },
el('input', { type: 'checkbox', checked: !!(extras && extras.gestureLayer), onChange: (e) => { if (typeof props.onToggleGesture === 'function') props.onToggleGesture(e.target.checked) } }),
' 手势期提升'),
el('label', { className: 'iwb-diag-kv', title: '关掉所有 backdrop-filter(顶栏/停靠栏的毛玻璃),用于二分 graphics 占用' },
el('input', { type: 'checkbox', checked: !!(extras && extras.noblur), onChange: (e) => { if (typeof props.onToggleNoBlur === 'function') props.onToggleNoBlur(e.target.checked) } }),
' 禁用毛玻璃'),
el('button', { className: 'iwb-btn iwb-btn-sm iwb-btn-danger', title: '清空本机的崩溃记录、内存采样与操作面包屑', onClick: async () => { if (await window.IWBUIConfirm.askOrNative('清空本机诊断记录?', { title: '清空诊断记录', okText: '清空' })) { if (CrashLog && CrashLog.clear) CrashLog.clear(); reload() } } }, '清空记录'),
),
el('div', { className: 'iwb-row' },
@@ -134,13 +156,17 @@
if (!d) return el('div', { className: 'iwb-hint' }, '正在读取分进程内存…')
const bd = d.breakdown || {}
const procs = Array.isArray(bd.procs) ? bd.procs : []
const wsKind = bd.kind === 'workingset'
const wvMB = procs.filter((p) => p && p.role === 'WebView2').reduce((n, p) => n + (Number(p.footprintMB) || 0), 0)
return el('div', null,
el('div', { className: 'iwb-section-sub' }, '内存拆解(分进程 footprint,合计 ' + (bd.totalMB || 0) + 'MB)'),
el('div', { className: 'iwb-section-sub' }, '内存拆解(分进程' + (wsKind ? '工作集' : 'footprint') + ',合计 ' + (bd.totalMB || 0) + 'MB' + (wvMB ? (' · WebView2 ' + wvMB + 'MB') : '') + ')'),
procs.length ? el('div', { className: 'iwb-diag-list' }, procs.map((p, i) => el('div', { key: 'mp' + i, className: 'iwb-diag-item' },
el('div', { className: 'iwb-diag-head' }, p.role + ' · ' + p.footprintMB + 'MB'),
el('div', { className: 'iwb-diag-head' }, p.role + (p.pid ? (' #' + p.pid) : '') + ' · ' + p.footprintMB + 'MB' + (p.privMB != null ? ('(私有 ' + p.privMB + 'MB)') : '')),
(p.top && p.top.length) ? el('div', { className: 'iwb-diag-extra' }, p.top.slice(0, 3).map((c) => c.cat + ' ' + c.dirtyMB + 'MB').join(' · ')) : null,
))) : el('div', { className: 'iwb-hint' }, '仅桌面端可读取(需 footprint 工具)'),
el('div', { className: 'iwb-hint' }, 'footprint 与活动监视器「内存」列同源;一个 WebKit 应用通常有 宿主 + WebContent + GPU + Networking 四个进程。'),
))) : el('div', { className: 'iwb-hint' }, '仅桌面端可读取'),
el('div', { className: 'iwb-hint' }, wsKind
? '工作集与任务管理器「内存」列同源,「私有」是进程实际提交的字节;宿主 + WebView2 各子进程相加即整包占用。'
: 'footprint 与活动监视器「内存」列同源;一个 WebKit 应用通常有 宿主 + WebContent + GPU + Networking 四个进程。'),
)
})(),
(function renderLedger () {
+4 -1
View File
@@ -284,6 +284,9 @@
for (const f of list) {
if (!alive) break
const refs = o.refs || {}
// 用户正在平移/拖拽/缩放时暂停预热:缩略图生成会解码 320px 图,抢主线程会让手势掉帧。
while (alive && (refs.pan || refs.drag || refs.resize || refs.box)) await new Promise((r) => setTimeout(r, 250))
if (!alive) break
if (refs.genRuns && refs.genRuns.size) break
if (refs.saving) { await new Promise((r) => setTimeout(r, 1200)); continue }
try { await F.galleryThumbOfEntry(f, 320) } catch (e) { /* 单张失败忽略 */ }
@@ -297,7 +300,7 @@
if (!alive) return
if (typeof requestIdleCallback === 'function') requestIdleCallback(kick, { timeout: 8000 })
else kick()
}, 6000)
}, 30000)
return () => { alive = false; clearTimeout(t) }
}, [o.len])
}
+22 -3
View File
@@ -27,11 +27,13 @@ button { font-family: inherit; }
/* 抓手工具(H):整块画布给「可抓」光标,按下拖动时变抓紧 */
.iwb-canvas.iwb-tool-pan { cursor: grab; }
.iwb-canvas.iwb-tool-pan:active { cursor: grabbing; }
.iwb-grid { position: absolute; left: -50%; top: -50%; width: 200%; height: 200%; pointer-events: none; will-change: transform; background-repeat: repeat; background-image: radial-gradient(circle, var(--iwb-grid-dot) var(--iwb-grid-size), transparent calc(var(--iwb-grid-size) + 0.4px)); background-size: var(--iwb-grid-gap) var(--iwb-grid-gap); background-repeat: repeat; opacity: calc(0.85 * var(--iwb-grid-on)); }
.iwb-grid { position: absolute; inset: 0; pointer-events: none; background-repeat: repeat; background-image: radial-gradient(circle, var(--iwb-grid-dot) var(--iwb-grid-size), transparent calc(var(--iwb-grid-size) + 0.4px)); background-size: var(--iwb-grid-gap) var(--iwb-grid-gap); opacity: calc(0.85 * var(--iwb-grid-on)); }
/* 亮色主题:网格点更浅,降低与背景对比度(暗色主题不受影响) */
.iwb-world { position: absolute; left: 0; top: 0; transform-origin: 0 0; will-change: transform; }
.iwb-world { position: absolute; left: 0; top: 0; transform-origin: 0 0; z-index: 1; }
.iwb-edges { position: absolute; left: 0; top: 0; pointer-events: none; }
.iwb-edge-canvas { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.iwb-node-canvas { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.iwb-edge-hit { fill: none; stroke: transparent; stroke-width: 14; pointer-events: stroke; cursor: pointer; }
.iwb-edge-hit:hover { stroke: color-mix(in srgb, var(--iwb-brand) 16%, transparent); }
.iwb-edge-hit:hover + .iwb-edge { stroke-width: calc(var(--iwb-edge-w) + 0.6px); stroke: var(--iwb-edge-hot); }
@@ -1205,7 +1207,24 @@ body .iwb-history-embedded .iwb-history-item.iwb-history-selected:hover img {
.iwb-home-card-actions button { width: 32px; height: 32px; border-radius: 8px; }
/* v12:世界容器提升为合成层(节点随世界一起 transform,不单独建层) */
.iwb-world { will-change: transform; }
/* v3.26.136:合成层常驻提升改为可开关(诊断页)。默认关 —— 默认开启时整个画布世界会被提升成一个
巨大的常驻合成层,实测 WebContent graphics 764MB。需要时(低端机拖拽掉帧)可以打开。 */
/* v3.26.143:默认不把 world/grid 提升成常驻合成层(参考 infinite-canvas:靠视口裁剪 + rAF 合批)。
诊断页的「合成层常驻提升」是显式 opt-in,只在低端机需要时打开。 */
/* v3.26.155:手势期间临时把 world 提升为合成层(停手 140ms 撤销)。
平移只剩图层位移,不再每帧重栅格化整个世界层 —— 这是「画面滞留 / 拖动掉帧」的主因。 */
.iwb-canvas.iwb-gesture .iwb-world { will-change: transform; }
.iwb-canvas.iwb-gesture .iwb-edges { pointer-events: none; }
/* v3.26.156:手势期间关掉浮层毛玻璃 —— WKWebView 上的 backdrop 采样是异步的,
画布在下面移动时会留下肉眼可见的拖影。停手后自动恢复。 */
.iwb-canvas.iwb-gesture .iwb-statusbar,
.iwb-canvas.iwb-gesture .iwb-statusbar *:not(img) { -webkit-backdrop-filter: none !important; backdrop-filter: none !important; }
.iwb-world { will-change: auto; }
:root[data-layers="on"] .iwb-world { will-change: transform; }
/* v3.26.137:毛玻璃开关(诊断页)。关掉后所有 backdrop-filter 失效,用于二分 graphics 占用 */
:root[data-noblur="on"] *, :root[data-noblur="on"] *::before, :root[data-noblur="on"] *::after { backdrop-filter: none !important; -webkit-backdrop-filter: none !important; }
.iwb-grid { will-change: auto; }
:root[data-layers="on"] .iwb-grid { will-change: transform; }
/* v15:左侧资源面板展开时浮在画布上层,不移动画布位置 */
.iwb-overlay.drawer-open .iwb-canvas { left: 0 !important; }
/* 停靠栏时代:工具栏/小地图按 --iwb-dock-* 让位(画布仍不动) */
+6 -1
View File
@@ -316,10 +316,15 @@ test('P1 基线:pan / zoom / tab-switch / edges', async ({ page }) => {
localStorage.setItem('iwb_web_cfg', JSON.stringify(d.cfg))
localStorage.setItem('iwb_web_workspaces', JSON.stringify({ schemaVersion: 1, rev: 1, activeId: d.tabs[0].id, workspaces: d.tabs.map((b) => ({ ...b, nodes: b.nodes })) }))
localStorage.setItem('iwb_ws_active', d.tabs[0].id)
localStorage.setItem('iwb_canvas_v3', d.canvasV3 ? '1' : '0')
localStorage.setItem('iwb_pan_all_off', d.panAllOff ? '1' : '0')
localStorage.setItem('iwb_pan_edges_freeze', d.panEdgesFreeze ? '1' : '0')
localStorage.setItem('iwb_pan_edges_redraw', d.panEdgesRedraw ? '1' : '0')
localStorage.setItem('iwb_layers_on', d.layers ? '1' : '0')
for (const b of d.tabs) localStorage.setItem('iwb_ws_' + b.id, JSON.stringify(b))
localStorage.setItem('iwb_tabs_open', JSON.stringify(d.tabs.map((b) => b.id)))
window.__IWB_E2E__ = true
}, { cfg: CFG, tabs: tabs.map((b) => ({ id: b.id, name: b.name, nodes: b.nodes, edges: b.edges, groups: b.groups })) })
}, { cfg: CFG, canvasV3: process.env.IWB_CANVAS_V3 === '1', panAllOff: process.env.IWB_PAN_ALL_OFF === '1', panEdgesFreeze: process.env.IWB_PAN_EDGES_FREEZE === '1', panEdgesRedraw: process.env.IWB_PAN_EDGES_REDRAW === '1', layers: process.env.IWB_LAYERS === '1', tabs: tabs.map((b) => ({ id: b.id, name: b.name, nodes: b.nodes, edges: b.edges, groups: b.groups })) })
const t0 = Date.now()
await page.goto('/', { waitUntil: 'domcontentloaded' })
+1 -1
View File
@@ -11,7 +11,7 @@ const PLUGIN_REPO = '/Users/qiqi/open/github/iwb-plugins'
// 清单缺 integrity 即拒载(bad-entry),所以 mock 清单必须像生产发布器一样带真 sha256。
let _integrityOf = null
async function integrityOf(buf) {
if (!_integrityOf) _integrityOf = (await import(path.join(__dirname, '..', 'scripts', 'plugins-publish.mjs'))).integrityOf
if (!_integrityOf) _integrityOf = (await import(path.join(__dirname, '..', 'scripts', 'plugin-integrity.mjs'))).integrityOf
return _integrityOf(buf)
}
+6 -6
View File
@@ -72,23 +72,23 @@ assert("IDB_REF_PREFIX = 'ref_'(legacy 形态)", /const IDB_REF_PREFIX = 're
assert("文档记录了 IDB_REF_PREFIX = 'ref_'", factsDoc.includes("IDB_REF_PREFIX = 'ref_'"))
assert('W_IMG_BLOB_PRIMARY_DEFAULT = true(新写入主通道启用)', /const W_IMG_BLOB_PRIMARY_DEFAULT = true/.test(appJs))
// ── 3. 视口裁剪余量:宽边距 240 / 带图节点 80,且不得回退成 560 ─────────────
// ── 3. 视口裁剪余量:统一 280,且不得回退成 560 ─────────────
// v3.26.109:cullRect 从 app.js 收编到 src/canvas-geometry.js(cullRectsOf),
// 带图节点改用 80 的紧边距,减少屏幕外节点常驻的解码位图(内存 C)。
// v3.26.143:带图节点也回到 280,避免平移边缘反复卸载/重解码;内存靠图片管线控制。
console.log('3) 视口裁剪余量(禁止把 v3.80.0 的 ±560 写回来)')
const geomJs = read('src/canvas-geometry.js')
const cullStart = geomJs.indexOf('const CULL_PAD_WIDE = 240')
const cullStart = geomJs.indexOf('const CULL_PAD_WIDE = 280')
const cullEnd = geomJs.indexOf('function nodeVisibleIn')
assert('定位到 cullRectsOf 代码块', cullStart > 0 && cullEnd > cullStart)
if (cullStart > 0 && cullEnd > cullStart) {
const cull = geomJs.slice(cullStart, cullEnd)
assert('宽边距常量是 240', /CULL_PAD_WIDE = 240/.test(cull))
assert('带图节点紧边距是 80', /CULL_PAD_TIGHT = 80/.test(cull))
assert('宽边距常量是 280', /CULL_PAD_WIDE = 280/.test(cull))
assert('带图节点紧边距也是 280', /CULL_PAD_TIGHT = 280/.test(cull))
const hasPad = (cull.match(/- pad|\+ pad/g) || []).length
assert('裁剪矩形 4 条边都按 pad 收放', hasPad === 4, '实际 ' + hasPad)
assert('裁剪矩形不含 560(历史值已废止)', !/560/.test(cull))
assert('app.js 只做装配(不再内联 cullRect 数值)', !/const cullRect = React\.useMemo/.test(appJs))
assert('文档记录了 240 余量', factsDoc.includes('240'))
assert('文档记录了 280 余量', factsDoc.includes('280'))
assert('文档未把 560 当现值', !/余量.{0,6}560/.test(factsDoc))
}
+6 -3
View File
@@ -1,6 +1,7 @@
'use strict'
// v3.25.70:网格从「CSS 渐变 + 每帧改 background-position」改为「贴图 + transform 位移」
// (WebKit 下每帧重绘整屏点阵是拖动卡顿的固定开销)。断言新契约 + 保留 jsdom 回落。
// v3.26.143:网格回到「视口大小 + 贴图 + background-position」。
// 108/3.26.140 的 200% 尺寸 + transform 会把网格提升成额外合成层;视口大小 + 背景位移更省。
// 断言新契约 + 保留 jsdom 回落。
const assert = require('assert')
const fs = require('fs')
const path = require('path')
@@ -11,5 +12,7 @@ assert.ok(source.includes('IWBCanvasGrid'), '必须接入 canvas-grid 模块')
assert.ok(grid.includes('function styleOf') && grid.includes('function applyTo'), '模块需提供 styleOf/applyTo')
assert.ok(source.includes("--iwb-grid-gap"), '网格必须读取外观设置变量(v3.25.74)')
assert.ok(source.includes("backgroundSize: (o.base * scale)"), 'jsdom/无模块时需回落到渐变公式')
assert.ok(!source.includes("backgroundPosition: viewport.x + 'px ' + viewport.y + 'px'"), '渲染期不得再按帧写 backgroundPosition')
assert.ok(grid.includes("backgroundPosition: (x % gap)"), '模块用 background-position 跟随平移')
assert.ok(!grid.includes("el.style.transform = 'translate('"), '网格层不再用 transform 位移(避免额外合成层)')
assert.ok(source.includes("backgroundPosition: x + 'px ' + y + 'px'"), 'jsdom 回落同样用 background-position')
console.log('canvas dot zoom checks passed')
+29 -3
View File
@@ -357,12 +357,13 @@ const near = (name, got, wantX, wantY) => {
const W = (n) => (n.type === 'relay' ? 72 : (n.w || (n.type === 'gen' ? 480 : (n.type === 'layer' ? 520 : 264))))
const prompt = { type: 'prompt' }
// 800 节点 fit(scale 0.2、默认宽 264 → 52.8px):≥15% ⇒ lite(有内容),不是灰块
assert.strictEqual(G.lodModeOf({ scale: 0.2 }, prompt, W), 'lite', '0.2 档必须是 lite:用户要能判断节点内容')
// v3.26.157:取消 30% 那档 lite(阈值附近来回切,画面常闪)。15%~100% 一律完整渲染。
assert.strictEqual(G.lodModeOf({ scale: 0.2 }, prompt, W), '', '0.2 档不再走 lite,直接完整渲染')
// 低于 15% ⇒ plain
assert.strictEqual(G.lodModeOf({ scale: 0.14 }, prompt, W), 'plain', '14% 该退成占位')
assert.strictEqual(G.lodModeOf({ scale: 0.149 }, prompt, W), 'plain', '14.9% 仍在占位档')
// 15% 边界是开区间:正好 0.15 不算「以下」
assert.strictEqual(G.lodModeOf({ scale: 0.15 }, prompt, W), 'lite', '0.15 本身不该被算作「以下」')
assert.strictEqual(G.lodModeOf({ scale: 0.15 }, prompt, W), '', '0.15 本身不该被算作「以下」')
// 正常编辑档位完整渲染
assert.strictEqual(G.lodModeOf({ scale: 1 }, prompt, W), '', 'scale 1 完整渲染')
assert.strictEqual(G.lodModeOf({ scale: 0.5 }, prompt, W), '', 'scale 0.5 完整渲染')
@@ -407,4 +408,29 @@ const near = (name, got, wantX, wantY) => {
assert.ok(Number.isFinite(nan.scale) && Number.isFinite(nan.x) && Number.isFinite(nan.y), '入参缺失不得产出 NaN')
}
console.log('canvas geometry checks passed(含 computeEdgePath 缓存快路径、areNodeEqual 拖拽放宽、拖放落点吸附、复制落位零重叠、粘贴左上角落点与视口夹取、LOD 屏幕宽度判据的行为验证)')
// ── 2026-11-30:边线 SVG 放在屏幕坐标系(不能按世界尺寸分配合成位图)──
{
const size = G.edgeLayerSize({ w: 1000, h: 800 })
assert.strictEqual(size.w, 1000)
assert.strictEqual(size.h, 800)
const props = G.edgeLayerProps({ w: 1000, h: 800 })
assert.strictEqual(props.width, 1000)
assert.strictEqual(props.height, 800)
assert.strictEqual(props.viewBox, '0 0 1000 800')
assert.strictEqual(G.edgeGroupTransform({ x: -100, y: -50, scale: 0.5 }), 'translate(-100,-50) scale(0.5)')
const rects = G.cullRectsOf({ w: 800, h: 600 }, { x: 0, y: 0, scale: 1 })
const far = { id: 'far', type: 'ref', x: 5000, y: 5000, w: 200, h: 200 }
assert.strictEqual(G.nodeVisibleIn(far, rects, { widthOf: (n) => n.w, heightOf: (n) => n.h }), false)
// v3.26.156:平移期不再全量渲染(世界层太大 ⇒ WebKit 分块栅格化出残块);只有显式 mountAll 才退回旧行为
assert.strictEqual(G.nodeVisibleIn(far, rects, { pan: true, widthOf: (n) => n.w, heightOf: (n) => n.h }), false, '平移期间默认按窗口裁剪')
assert.strictEqual(G.nodeVisibleIn(far, rects, { pan: true, mountAll: true, widthOf: (n) => n.w, heightOf: (n) => n.h }), true, 'iwb_pan_mount_all=1 才全量渲染')
const wide = G.cullRectsOf({ w: 800, h: 600 }, { x: 0, y: 0, scale: 1 }, 2000)
const near = { id: 'near', type: 'ref', x: 2900, y: 2700, w: 100, h: 100 }
assert.strictEqual(G.nodeVisibleIn(near, rects, { widthOf: (n) => n.w, heightOf: (n) => n.h }), false, '无额外边距时 2900 在窗口外')
assert.strictEqual(G.nodeVisibleIn(near, wide, { widthOf: (n) => n.w, heightOf: (n) => n.h }), true, '额外边距要能覆盖平移位移')
const fake = { attrs: {}, setAttribute(k, v) { this.attrs[k] = v } }
G.applyEdgeLayerDom({ querySelector: (s) => (s === '.iwb-edge-world' ? fake : null) }, { w: 1200, h: 900 }, 120, 80, 2)
assert.strictEqual(fake.attrs.transform, 'translate(120,80) scale(2)')
}
console.log('canvas geometry checks passed(含 computeEdgePath 缓存快路径、areNodeEqual 拖拽放宽、拖放落点吸附、复制落位零重叠、粘贴左上角落点与视口夹取、LOD 屏幕宽度判据、边线视口层的行为验证)')
+26
View File
@@ -0,0 +1,26 @@
'use strict'
const assert = require('assert')
const fs = require('fs')
const path = require('path')
const vm = require('vm')
const sandbox = { window: {} }
vm.createContext(sandbox)
vm.runInContext(fs.readFileSync(path.join(__dirname, '..', 'src', 'canvas-v3-hit.js'), 'utf8'), sandbox)
const H = sandbox.window.IWBCanvasV3Hit
const nodes = [
{ id: 'a', type: 'ref', x: 0, y: 0, w: 200, h: 100 },
{ id: 'b', type: 'prompt', x: 300, y: 0, w: 200, h: 100 },
{ id: 'c', type: 'ref', x: 0, y: 0, w: 200, h: 100 },
]
const opts = { widthOf: (n) => n.w, heightOf: (n) => n.h, portRadiusWorld: 10 }
assert.strictEqual(H.hitRefNode(nodes, 50, 50, opts).node.id, 'c', '后渲染的 ref 优先命中')
assert.strictEqual(H.hitRefNode(nodes, 50, 50, opts).port, '', '卡内是 body')
assert.strictEqual(H.hitRefNode(nodes, -5, 50, opts).port, 'in', '左边缘是输入口')
assert.strictEqual(H.hitRefNode(nodes, 205, 50, opts).port, 'out', '右边缘是输出口')
assert.strictEqual(H.hitRefNode(nodes, 400, 50, opts), null, '非 ref 不参与 hitRefNode')
assert.strictEqual(H.hitRefNode(nodes, 500, 500, opts), null, '空白不命中')
const hitAny = H.hitNode(nodes, 400, 50, Object.assign({}, opts, { isType: (n) => n.type === 'prompt' || n.type === 'ref', wantPorts: false }))
assert.strictEqual(hitAny.node.id, 'b', 'hitNode 按 isType 命中 prompt')
assert.strictEqual(hitAny.port, '', 'prompt 只做 body 命中')
console.log('canvas-v3-hit types checks passed')
console.log('canvas-v3-hit checks passed')
+42
View File
@@ -0,0 +1,42 @@
'use strict'
// 2026-12-01:Canvas V3 实验停止。测试改为断言 kill switch:即使 localStorage=1 也必须关闭。
const assert = require('assert')
const fs = require('fs')
const path = require('path')
const vm = require('vm')
const source = fs.readFileSync(path.join(__dirname, '..', 'src', 'canvas-v3.js'), 'utf8')
function makeSandbox (initial) {
const store = new Map(Object.entries(initial || {}))
const events = []
const root = { dataset: {} }
const document = { documentElement: root, getElementsByTagName: () => ({ length: 42 }) }
const window = { dispatchEvent: (e) => { events.push(e) } }
window.IWBStorageLocal = { getStore: () => ({ rawGet: (k, f) => (store.has(k) ? store.get(k) : f), rawSet: (k, v) => { store.set(k, String(v)); return true } }) }
class CustomEvent { constructor (type, init) { this.type = type; this.detail = init && init.detail } }
const sandbox = { window, document, IWBStorageLocal: { getStore: () => ({ rawGet: (k, f) => (store.has(k) ? store.get(k) : f), rawSet: (k, v) => { store.set(k, String(v)); return true } }) }, CustomEvent, console }
vm.createContext(sandbox)
vm.runInContext(source, sandbox)
return { api: sandbox.window.IWBCanvasV3, root, store, events }
}
{
const s = makeSandbox({})
assert.strictEqual(s.api.isEnabled(), false, '默认关闭')
assert.strictEqual(s.api.init(), false)
assert.strictEqual(s.root.dataset.canvasV3, 'off', '关闭时根属性为 off')
}
{
const s = makeSandbox({ iwb_canvas_v3: '1' })
assert.strictEqual(s.api.isEnabled(), false, 'kill switch:localStorage=1 也必须关闭')
assert.strictEqual(s.api.init(), false)
assert.strictEqual(s.root.dataset.canvasV3, 'off')
assert.strictEqual(s.store.get('iwb_canvas_v3'), '0', 'init 会把旧开关写回 0')
}
{
const s = makeSandbox({})
assert.strictEqual(s.api.setEnabled(true), false, 'setEnabled 不再允许开启')
assert.strictEqual(s.root.dataset.canvasV3, 'off')
assert.strictEqual(s.store.get('iwb_canvas_v3'), '0')
}
console.log('canvas-v3 checks passed(kill switch)')
+4
View File
@@ -2,6 +2,7 @@
"CanvasActions",
"CanvasNodeFactory",
"IWBBootLoad",
"IWBCanvasEdges",
"IWBCanvasGeometry",
"IWBCanvasGrid",
"IWBCanvasHistory",
@@ -11,6 +12,9 @@
"IWBCanvasPointer",
"IWBCanvasStore",
"IWBCanvasText",
"IWBCanvasV3",
"IWBCanvasV3Hit",
"IWBCanvasV3NodeLayer",
"IWBCrashLog",
"IWBDefaultGenModel",
"IWBDesktop",
+4
View File
@@ -74,6 +74,9 @@
"ui-dock-panels.js",
"theme-tokens.js",
"canvas-grid.js",
"canvas-v3.js",
"canvas-v3-node-layer.js",
"canvas-v3-hit.js",
"image-display-thumb.js",
"image-cache-migrate.js",
"runtime-frame-probe.js",
@@ -101,6 +104,7 @@
"runtime-plugin-market.js",
"runtime-plugin-backup.js",
"ui-canvas-view.js",
"ui-canvas-edges.js",
"ui-canvas-pointer.js",
"ui-canvas-nodes.js",
"ui-confirm.js",
+26
View File
@@ -0,0 +1,26 @@
'use strict'
const assert = require('assert')
const fs = require('fs')
const path = require('path')
const vm = require('vm')
const source = fs.readFileSync(path.join(__dirname, '..', 'src', 'image-cache-migrate.js'), 'utf8')
const window = {}
const sandbox = { window, console }
vm.createContext(sandbox)
vm.runInContext(source, sandbox)
const M = window.IWBImageCacheMigrate
let reads = 0
const deps = { read: () => { reads++; return Promise.resolve(null) }, write: () => null }
const board = { id: 'b1', nodes: [{ data: { data: { __cache: 'old-cache-key' } } }] }
M.once(board, deps).then((r) => {
assert.strictEqual(r.total, 1)
assert.strictEqual(r.fail, 1)
assert.strictEqual(M.isFailed('old-cache-key'), true)
assert.strictEqual(M.failedCount(), 1)
// 新画板对象再次装载:失败键不再读盘,也不会让 wBoardNeedsHydrate 继续为真
return M.once({ id: 'b2', nodes: [{ data: { data: { __cache: 'old-cache-key' } } }] }, deps)
}).then((r2) => {
assert.strictEqual(r2.fail, 1)
assert.strictEqual(reads, 1, '失败键只读一次')
console.log('image-cache-migrate checks passed')
}).catch((e) => { console.error(e); process.exit(1) })
+1 -31
View File
@@ -8,7 +8,7 @@ const path = require('path')
const root = path.resolve(__dirname, '..')
;(async () => {
const mod = await import(path.join(root, 'scripts', 'plugins-publish.mjs'))
const mod = await import(path.join(root, 'scripts', 'plugin-integrity.mjs'))
// 已知向量:sha256('abc') 的 base64
assert.strictEqual(mod.integrityOf(Buffer.from('abc')), 'sha256-ungWv48Bz+pBQUDeXa4iI7ADYaOWF3qctBD/YfIAFa0=')
@@ -50,36 +50,6 @@ const root = path.resolve(__dirname, '..')
assert.strictEqual(mod.mergeIndexes([], prevIdx).length, 2, '空既有清单时等同于全新发布')
assert.strictEqual(mod.mergeIndexes(prevIdx, []).length, 2, '不传新条目时不应丢条目')
// 陈旧键判定(--gc 用):只认「plugins/ 下 + 线上清单不引用」,清单自身永不列为陈旧
const gcKeys = [
'plugins/index.json',
'plugins/plugin-a-plugin.111111111111.js',
'plugins/plugin-a-plugin.999999999999.js',
'plugins/plugin-b-plugin.222222222222.js',
'other/keep-me.js',
]
const gcIndex = [
{ id: 'a-plugin', file: 'plugin-a-plugin.111111111111.js', version: '1.0.0', integrity: 'sha256-a' },
{ id: 'b-plugin', file: 'plugin-b-plugin.222222222222.js', version: '1.0.0', integrity: 'sha256-b' },
]
const stale = mod.staleKeys(gcKeys, gcIndex)
assert.deepStrictEqual(stale, ['plugins/plugin-a-plugin.999999999999.js'], '旧哈希键应判为陈旧,清单引用与 index.json 不应被判陈旧')
assert.deepStrictEqual(mod.staleKeys(gcKeys, []), [
'plugins/plugin-a-plugin.111111111111.js',
'plugins/plugin-a-plugin.999999999999.js',
'plugins/plugin-b-plugin.222222222222.js',
], '空清单时所有插件键都陈旧(但 index.json 仍保留)')
assert.deepStrictEqual(mod.staleKeys([], gcIndex), [], '空 KV 不应报陈旧')
assert.deepStrictEqual(mod.staleKeys(null, null), [], '非法入参应安全返回空')
// --keep:归档保留的插件(如 ai-chat 移出清单但字节留 KV)不得被判陈旧
assert.deepStrictEqual(mod.staleKeys(gcKeys, gcIndex, ['a-plugin']), [], 'keep 传插件 id 时其全部哈希版本都保留')
assert.deepStrictEqual(mod.staleKeys(gcKeys, gcIndex, ['plugins/plugin-a-plugin.999999999999.js']), [], 'keep 传完整键也应生效')
// 上传实现不得再依赖 wrangler(v3/v4 子命令名不同,spawnSync 必踩版本坑)
const pubSrc = fs.readFileSync(path.join(root, 'scripts', 'plugins-publish.mjs'), 'utf8')
assert.ok(!/spawnSync\('npx'/.test(pubSrc), '插件发布脚本不应再 spawn npx wrangler')
assert.ok(/storage\/kv\/namespaces\//.test(pubSrc), '上传应走 Cloudflare REST API(storage/kv/namespaces)')
// 仓库清单本身必须是「多插件」形态的护栏:被单插件覆盖后此处直接红
const repoIdx = JSON.parse(fs.readFileSync(path.join(root, 'plugins', 'index.json'), 'utf8'))
assert.ok(Array.isArray(repoIdx) && repoIdx.length >= 6, 'plugins/index.json 应含全部已发布插件(当前 ≥6),被覆写成 1 个即视为事故')
+2 -2
View File
@@ -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 = 8665 // +336(2026-11-30 图片策略 v2 与诊断:插件三层能力 thumb/preview/original/budget、原生解码闸门装配、wDiagDetail(分进程 footprint + 解码账本 + 插件源)、图库空闲预热、wReclaimMemoryNow/引用化;下一步按 domain 拆到 src/ 回落此上限) // +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 = 8743 // +336(2026-11-30 图片策略 v2 与诊断:插件三层能力 thumb/preview/original/budget、原生解码闸门装配、wDiagDetail(分进程 footprint + 解码账本 + 插件源)、图库空闲预热、wReclaimMemoryNow/引用化;下一步按 domain 拆到 src/ 回落此上限) // +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 = 2231 // +52(2026-11-30:图片策略 v2 装配 + 诊断明细 + 浏览器窗口空闲休眠读数;预热的实现已抽到 src/ui-workbench-hooks.js 的 useGalleryPrewarm,下一步继续把 ctx 装配下沉以回落上限) // +11(2026-11-27:同上,Workbench 2169→2180) // 2026-11-26 复制/粘贴通道重写(+14:refs 新增粘贴时间戳/系统剪贴板可信标记、pasteCtx 增补 ids/clipboardOf/stageClip/readNativeText、bindCopy 装配)
const MAX_WORKBENCH_LINES = 2333 // +10(2026-11-30 Canvas 边线装配:EdgeCanvas 组件、hoverEdgeId、手势命令式重画钩子;绘制逻辑在 src/ui-canvas-edges.js) // +52(2026-11-30:图片策略 v2 装配 + 诊断明细 + 浏览器窗口空闲休眠读数;预热的实现已抽到 src/ui-workbench-hooks.js 的 useGalleryPrewarm,下一步继续把 ctx 装配下沉以回落上限) // +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);② 工作区列表写回族