Compare commits

..
244 Commits
Author SHA1 Message Date
qiqi e57d6d0a57 fix(preview): 输出节点双击预览走图库条目(本地原图优先)
Verify (Gitea) / gate (build · unit · facts) (push) Failing after 53s
2026-12-03 18:40:00 +08:00
qiqi d740f2565e docs: v3.26.240 补记任务合并/取消/输出节点修复 2026-12-03 18:18:56 +08:00
qiqi 8d110f285c fix: 图+文本合并单任务;取消作废在飞结果;ready 不再回退远程
Verify (Gitea) / gate (build · unit · facts) (push) Failing after 48s
2026-12-03 18:18:44 +08:00
qiqi 189ba3b8f8 docs: v3.26.240 补记多参考图合并修复 2026-12-03 17:56:51 +08:00
qiqi 475c048694 fix(task-graph): 插件文本节点接多张参考图合并为 1 个任务(相册仍一图一任务)
Verify (Gitea) / gate (build · unit · facts) (push) Failing after 1m44s
2026-12-03 17:56:41 +08:00
qiqi 858144aabe docs: 锚点/事实同步 v3.26.240
Verify (Gitea) / gate (build · unit · facts) (push) Failing after 1m5s
2026-12-03 17:31:15 +08:00
qiqi 33631d1176 chore: v3.26.240(下载走系统网络栈 + 并发可调) 2026-12-03 17:31:06 +08:00
qiqi 2ff1ccd2d1 feat(download): 走系统网络栈(Rust)+并发默认30可调;修并发限制从未生效
Verify (Gitea) / gate (build · unit · facts) (push) Failing after 48s
2026-12-03 17:29:48 +08:00
qiqi 3894c697ac docs: 锚点/事实同步 v3.26.239
Verify (Gitea) / gate (build · unit · facts) (push) Failing after 48s
2026-12-03 16:43:46 +08:00
qiqi 87e5851b72 chore: v3.26.239(清理未引用修正 + 模板节点连图修复;promptlib 1.14.14) 2026-12-03 16:43:38 +08:00
qiqi c59aa4c3e8 fix(task-graph): 插件文本节点接上游时不再丢自己的文本(修连图后生图 400)
Verify (Gitea) / gate (build · unit · facts) (push) Failing after 1m12s
2026-12-03 16:37:18 +08:00
qiqi 1dd0652825 chore(plugins): promptlib 1.14.14(模板节点补输入端口)
Verify (Gitea) / gate (build · unit · facts) (push) Failing after 54s
2026-12-03 16:26:24 +08:00
qiqi 4c16bcafbb chore(plugins): promptlib 1.14.13(打开即自适应 + 编辑防误关)
Verify (Gitea) / gate (build · unit · facts) (push) Failing after 46s
2026-12-03 16:21:05 +08:00
qiqi 8f5803d75a site: 插件页同步 promptlib 1.14.12
Verify (Gitea) / gate (build · unit · facts) (push) Failing after 49s
2026-12-03 16:05:16 +08:00
qiqi db550fac8a chore(plugins): promptlib 1.14.12(长文本变量 + 双击回填)
Verify (Gitea) / gate (build · unit · facts) (push) Failing after 50s
2026-12-03 16:02:03 +08:00
qiqi 0ff4859268 docs: 域名边界(iwb 网页版独立,桌面版只碰 download/market) 2026-12-03 14:22:41 +08:00
qiqi c98b14df5b fix(settings): 清理未引用图片跳过缩略图缓存;弹窗文案与实现对齐
Verify (Gitea) / gate (build · unit · facts) (push) Failing after 1m3s
2026-12-03 13:54:30 +08:00
qiqi c3bbff9f57 release: v3.26.238 下载页/站点(三平台齐平)
Verify (Gitea) / gate (build · unit · facts) (push) Failing after 1m44s
2026-12-03 12:49:16 +08:00
qiqi 7577b66b78 docs: 插件 SRI 与换行符(Windows autocrlf)记录 2026-12-03 12:34:24 +08:00
qiqi 1f94249282 fix(build): 插件产物按 LF 写入 dist + dist/plugins 哈希校验;e2e 图库夹具补 orig
Verify (Gitea) / gate (build · unit · facts) (push) Failing after 50s
2026-12-03 12:34:01 +08:00
qiqi d9848e2e52 docs: 图片读取/下载规范定稿 + 2026-12-03 经验记录 2026-12-03 12:05:18 +08:00
qiqi a86606e2cc docs: 锚点与事实同步 v3.26.238
Verify (Gitea) / gate (build · unit · facts) (push) Failing after 2m2s
2026-12-03 11:55:44 +08:00
qiqi 48a68a7e8a chore: v3.26.238(图片读取/下载本地优先 + 命名统一图库行名) 2026-12-03 11:55:28 +08:00
qiqi ec9ca02a82 site: 插件页同步 taskqueue 1.0.3(含 gallery 1.9.12 等已上线版本)
Verify (Gitea) / gate (build · unit · facts) (push) Failing after 54s
2026-12-03 11:35:30 +08:00
qiqi c3b76ec444 docs: 锚点同步 v3.26.237
Verify (Gitea) / gate (build · unit · facts) (push) Canceled after 24s
2026-12-03 11:35:02 +08:00
qiqi dc5c1a6b0a chore: v3.26.237(任务队列页头固定 / 老记录预览取原图,taskqueue 1.0.3) 2026-12-03 11:34:53 +08:00
qiqi a8b9296558 docs: 锚点同步 v3.26.236
Verify (Gitea) / gate (build · unit · facts) (push) Failing after 43s
2026-12-03 11:02:34 +08:00
qiqi ab8579dcef chore: v3.26.236(测试版:标签条 portal 固定) 2026-12-03 11:02:24 +08:00
qiqi 9cbd5fa673 docs: 锚点同步 v3.26.235
Verify (Gitea) / gate (build · unit · facts) (push) Failing after 1m3s
2026-12-03 10:46:38 +08:00
qiqi ac6a0062c3 chore: v3.26.235(测试版:任务队列修复) 2026-12-03 10:46:33 +08:00
qiqi 2e62769421 docs: 锚点同步 v3.26.234
Verify (Gitea) / gate (build · unit · facts) (push) Failing after 45s
2026-12-03 10:22:55 +08:00
qiqi 42033a54ab chore: v3.26.234(测试版:任务队列体验修正) 2026-12-03 10:22:37 +08:00
qiqi 48232bec5c fix(queue): 选中态/缩略图复用/提示词标题/画布归属/状态与下载语义 2026-12-03 10:20:05 +08:00
qiqi 7b2bb0d58e docs: 锚点同步 v3.26.233
Verify (Gitea) / gate (build · unit · facts) (push) Failing after 46s
2026-12-03 09:55:08 +08:00
qiqi 1c7cbd9726 chore: v3.26.233(测试版:任务队列左栏整页插件) 2026-12-03 09:54:59 +08:00
qiqi 630949eac7 fix(queue): 定位回画布 / 已在图库判定 / 上限保护 / 缩略图与兜底 2026-12-03 09:51:38 +08:00
qiqi 9edc635ed8 fix(queue): link-only 再次下载回到 queued + 执行计划状态 2026-12-03 09:45:08 +08:00
qiqi a0f86bf09c fix(queue): 账本上限/进行中保留 + 任务队列页工具区与状态修正 2026-12-03 09:44:35 +08:00
qiqi f5859b7596 feat(queue): 任务队列左栏整页插件 + 宿主 queue/pages 能力 2026-12-03 09:39:48 +08:00
qiqi 3cc53eec4b docs(plan): 任务队列左栏整页插件执行计划 2026-12-03 09:30:11 +08:00
qiqi 380d39146d docs(mockup): 任务队列缩略图支持点击预览(cursor/提示) 2026-12-03 09:23:13 +08:00
qiqi 81e73bd89b docs(mockup): 任务队列页 UI 原型(token 化、浅/深色截图) 2026-12-03 09:20:59 +08:00
qiqi 4cf0947e76 docs: 锚点同步 v3.26.232
Verify (Gitea) / gate (build · unit · facts) (push) Failing after 40s
2026-12-03 08:15:34 +08:00
qiqi ba2918ff95 chore: v3.26.232(测试版:NEW 标记层叠修正) 2026-12-03 08:15:30 +08:00
qiqi bb9e7f487f docs: 锚点同步 v3.26.231
Verify (Gitea) / gate (build · unit · facts) (push) Failing after 37s
2026-12-03 07:28:43 +08:00
qiqi 6102b7358a chore: v3.26.231(测试版:NEW 标记排除未落地) 2026-12-03 07:28:36 +08:00
qiqi 287da25a24 docs: 锚点同步 v3.26.230
Verify (Gitea) / gate (build · unit · facts) (push) Failing after 34s
2026-12-03 07:17:58 +08:00
qiqi 14457c04f2 chore: v3.26.230(测试版:新图 NEW 标记) 2026-12-03 07:17:45 +08:00
qiqi e996975bf9 plugins: gallery 1.9.12(卡片下载钮对齐输出面板:SVG 图标 / 26px / 无阴影) 2026-12-03 07:10:51 +08:00
qiqi d81c085972 docs: 锚点同步 v3.26.229
Verify (Gitea) / gate (build · unit · facts) (push) Failing after 38s
2026-12-03 01:08:48 +08:00
qiqi aeba3d3785 chore: v3.26.229(测试版:图库下载圆钮对齐输出面板) 2026-12-03 01:08:41 +08:00
qiqi 6d9842ecd3 docs: 锚点同步 v3.26.228
Verify (Gitea) / gate (build · unit · facts) (push) Failing after 1m2s
2026-12-03 00:40:31 +08:00
qiqi f948a45fcc chore: v3.26.228(测试版:输出节点下载圆钮) 2026-12-03 00:40:26 +08:00
qiqi c3bbe1a75a docs: 锚点同步 v3.26.227
Verify (Gitea) / gate (build · unit · facts) (push) Failing after 51s
2026-12-03 00:25:56 +08:00
qiqi 0b9d7d4cfc chore: v3.26.227(测试版:图库一致性快修) 2026-12-03 00:25:50 +08:00
qiqi 7d106d2f2c fix(types): 补 window.__iwbIngest 声明(typecheck)
Verify (Gitea) / gate (build · unit · facts) (push) Failing after 54s
2026-12-02 23:38:56 +08:00
qiqi a95e38d2f7 docs: 锚点同步 v3.26.226 2026-12-02 23:38:39 +08:00
qiqi f0ccaf79d3 chore: v3.26.226(测试版:先落地再显示 / 单次下载) 2026-12-02 23:38:27 +08:00
qiqi ae6549354d docs: 锚点同步 v3.26.225
Verify (Gitea) / gate (build · unit · facts) (push) Failing after 1m40s
2026-12-02 22:49:40 +08:00
qiqi 32e2c037ff chore: v3.26.225(测试版:撤销失败态) 2026-12-02 22:49:40 +08:00
qiqi 8c115c6f7d fix(out): onLoad 时撤销 is-broken / is-broken-cell(修「加载失败」盖在正常图上) 2026-12-02 22:49:40 +08:00
qiqi 308324a749 docs(workflow): 明确交付节奏 —— 报问题后先分析,经用户确认再改代码/构建 2026-12-02 22:46:24 +08:00
qiqi 8bac6bc701 docs: 锚点同步 v3.26.224
Verify (Gitea) / gate (build · unit · facts) (push) Failing after 2m24s
2026-12-02 22:43:16 +08:00
qiqi c7f7d54db8 chore: v3.26.224(测试版:白板期可见) 2026-12-02 22:43:16 +08:00
qiqi 9463db2538 fix(out): 角标默认显示(onLoad 后由 CSS 收起);骨架垫在图片下方,白板期也能看到 2026-12-02 22:43:16 +08:00
qiqi 5246a1ef85 docs: 锚点同步 v3.26.223
Verify (Gitea) / gate (build · unit · facts) (push) Failing after 55s
2026-12-02 22:40:37 +08:00
qiqi f8d547353f chore: v3.26.223(测试版:去重 + 续传) 2026-12-02 22:40:37 +08:00
qiqi 61dbbb83d3 feat(gallery): 启动按 url 去重(修 220 遗留的重复条目);超时失败在窗口聚焦时自动续传 2026-12-02 22:40:37 +08:00
qiqi fd5f7c7a17 chore(ratchet): app.js 9049→9053、Workbench→2552(归档补漏修正 +8 行)
Verify (Gitea) / gate (build · unit · facts) (push) Failing after 2m29s
2026-12-02 22:31:17 +08:00
qiqi 61c31b3203 docs: 锚点同步 v3.26.222
Verify (Gitea) / gate (build · unit · facts) (push) Canceled after 7s
2026-12-02 22:31:07 +08:00
qiqi 75e81ebc29 chore: v3.26.222(测试版:归档补漏修正) 2026-12-02 22:31:07 +08:00
qiqi aa9a54cdc2 fix(gallery): 归档补漏改按 item 级 url 判定(条目本身没有 url,原判定恒为待补 → 重复入库) 2026-12-02 22:31:07 +08:00
qiqi 7caa564ea1 docs: 锚点同步 v3.26.221
Verify (Gitea) / gate (build · unit · facts) (push) Failing after 1m51s
2026-12-02 22:08:50 +08:00
qiqi f62ec18b0f chore: v3.26.221(测试版:渐进渲染回归) 2026-12-02 22:08:49 +08:00
qiqi 4e8f3215a5 fix(out): 有远程 url 时不做骨架遮挡(回到渐进渲染);落地超时改 5 分钟安全阀 2026-12-02 22:08:49 +08:00
qiqi ee09343011 docs: 锚点同步 v3.26.220
Verify (Gitea) / gate (build · unit · facts) (push) Failing after 1m45s
2026-12-02 22:06:28 +08:00
qiqi 2b2eb263cd chore: v3.26.220(测试版:少一张 + 超时) 2026-12-02 22:06:28 +08:00
qiqi 25335ddd3d fix(gallery): 已归档但索引缺失的条目仍补入库;落地超时 25s→60s 2026-12-02 22:06:27 +08:00
qiqi 2c1a7e01e9 docs: 锚点同步 v3.26.219
Verify (Gitea) / gate (build · unit · facts) (push) Failing after 1m19s
2026-12-02 21:54:53 +08:00
qiqi d86031bd76 chore: v3.26.219(诊断版:入库计数) 2026-12-02 21:54:53 +08:00
qiqi 6fe52f0ece diag(gallery): 记录 add-outputs / archive 的张数与跳过原因(定位「总少一张」) 2026-12-02 21:54:53 +08:00
qiqi 2ffe95f0aa docs: 锚点同步 v3.26.218
Verify (Gitea) / gate (build · unit · facts) (push) Failing after 1m54s
2026-12-02 21:25:53 +08:00
qiqi f4ab497c73 chore: v3.26.218(测试版:下载超时) 2026-12-02 21:25:53 +08:00
qiqi 2f79d12c54 fix(ingest): 下载加 25s 超时(fetch 挂住会让状态永久停在下载中) 2026-12-02 21:25:52 +08:00
qiqi 95b6f45bfd docs: 锚点同步 v3.26.217
Verify (Gitea) / gate (build · unit · facts) (push) Failing after 1m38s
2026-12-02 21:13:51 +08:00
qiqi b59120beb4 chore: v3.26.217(测试版:打类目标修正 + 骨架撑高) 2026-12-02 21:13:51 +08:00
qiqi 49d11744a6 fix(out): 加载/失败类打到最近的 .iwb-out-cell(img 被浮层包裹,parentElement 不是单元格) 2026-12-02 21:13:51 +08:00
qiqi 420e87628e docs: 锚点同步 v3.26.216
Verify (Gitea) / gate (build · unit · facts) (push) Canceled after 1m9s
2026-12-02 21:12:41 +08:00
qiqi ebde29c9d7 chore: v3.26.216(测试版:骨架撑高) 2026-12-02 21:12:41 +08:00
qiqi 15b3352f8f fix(out): 骨架改为撑高(min-height 140px),出图前不再塌成一条线 2026-12-02 21:12:40 +08:00
qiqi 8fdcf3b3dc docs: 锚点同步 v3.26.215
Verify (Gitea) / gate (build · unit · facts) (push) Failing after 1m34s
2026-12-02 21:05:17 +08:00
qiqi fa0b97bdf6 chore: v3.26.215(测试版:失败态) 2026-12-02 21:05:17 +08:00
qiqi 37fe86c88c fix(out): 加载/失败态改用父容器打类(去 :has 依赖);破图显示「加载失败」 2026-12-02 21:05:17 +08:00
qiqi c20834b623 docs: 锚点同步 v3.26.214
Verify (Gitea) / gate (build · unit · facts) (push) Failing after 58s
2026-12-02 20:59:09 +08:00
qiqi 10ad8618d7 chore: v3.26.214(测试版:加载态与回退) 2026-12-02 20:59:09 +08:00
qiqi fd1a9c636b feat(out): 骨架/角标改以图片 onLoad 为准(CSS :has 联动);onError 两级回退并标失败态 2026-12-02 20:59:09 +08:00
qiqi 8398a389fe docs: 锚点同步 v3.26.213
Verify (Gitea) / gate (build · unit · facts) (push) Failing after 57s
2026-12-02 20:36:29 +08:00
qiqi 8487ef2c91 chore: v3.26.213(测试版:骨架 TDZ 修复) 2026-12-02 20:36:29 +08:00
qiqi 9f88b3a71c fix(out): 修骨架 TDZ(_localSrc 先声明),骨架仅对远程 url 生效 2026-12-02 20:36:29 +08:00
qiqi f0c39fb1c4 fix(style): 骨架用已定义 token(layer2/text2),修「引用未定义变量 +2」
Verify (Gitea) / gate (build · unit · facts) (push) Failing after 53s
2026-12-02 20:30:45 +08:00
qiqi 5fe41ffad4 docs: 锚点同步 v3.26.212
Verify (Gitea) / gate (build · unit · facts) (push) Canceled after 14s
2026-12-02 20:30:30 +08:00
qiqi 7f38d31ac2 chore: v3.26.212(测试版:下载骨架) 2026-12-02 20:30:30 +08:00
qiqi 301669a148 feat(out): 无本地源时显示「下载中…」骨架(方案 A),有缩略图时仍走 LOD(方案 B) 2026-12-02 20:30:30 +08:00
qiqi d36bbe3b91 docs: 锚点同步 v3.26.211
Verify (Gitea) / gate (build · unit · facts) (push) Failing after 58s
2026-12-02 20:09:54 +08:00
qiqi 768d01360d chore: v3.26.211(测试版:角标空指针修复) 2026-12-02 20:09:54 +08:00
qiqi fce4fedad6 fix(out): 角标空指针(视图未命中时 ingSt 为 null)+ 未落地优先于下载中 2026-12-02 20:09:54 +08:00
qiqi a6d4f5cc63 docs: 锚点同步 v3.26.210
Verify (Gitea) / gate (build · unit · facts) (push) Failing after 2m25s
2026-12-02 20:01:01 +08:00
qiqi dde8e861e8 chore: v3.26.210(测试版:恢复下载中角标 + 分层修正) 2026-12-02 20:01:01 +08:00
qiqi e8894d6864 feat(out): 恢复「下载中」角标(按「无本地源且为远程 url」判定,不依赖视图命中) 2026-12-02 20:01:01 +08:00
qiqi 3a70e16ead refactor(boundary): 落地状态视图改为注入(src 不再直接读 window 全局);ResultImg 回到纯展示
Verify (Gitea) / gate (build · unit · facts) (push) Failing after 1m20s
2026-12-02 19:31:53 +08:00
qiqi c346256115 docs: 锚点同步 v3.26.209
Verify (Gitea) / gate (build · unit · facts) (push) Failing after 48s
2026-12-02 19:21:22 +08:00
qiqi 2d3aba2ed2 chore: v3.26.209(测试版:对账去轮询) 2026-12-02 19:21:22 +08:00
qiqi 9893d1121d perf(ingest): 对账改为「启动一次 + 窗口聚焦时」,去掉 30s 常驻轮询(用户要求空闲零开销) 2026-12-02 19:21:22 +08:00
qiqi 1b36960e4f docs(changelog): 补 v3.26.208 条目 2026-12-02 19:19:25 +08:00
qiqi 0bc96494e9 docs: 锚点同步 v3.26.208
Verify (Gitea) / gate (build · unit · facts) (push) Failing after 1m26s
2026-12-02 19:19:18 +08:00
qiqi dd24679c3a chore: v3.26.208(测试版:ingest 日志 + 对账) 2026-12-02 19:19:18 +08:00
qiqi 9c8867fdae feat(ingest): 补进队/失败/就绪日志;新增索引对账(启动 3s 后 + 每 30s,幂等) 2026-12-02 19:19:17 +08:00
qiqi c0e4efc06e docs(changelog): 补 v3.26.207 与历史缺失的 v3.24.86 条目(release-records 守卫) 2026-12-02 18:35:43 +08:00
qiqi 9222144d22 docs: 锚点同步 v3.26.207
Verify (Gitea) / gate (build · unit · facts) (push) Failing after 46s
2026-12-02 18:29:21 +08:00
qiqi ac4446d4a0 chore: v3.26.207(测试版:落地重试 + 留痕) 2026-12-02 18:29:20 +08:00
qiqi 1606e0cd7c fix(gallery): 落地 ready 未命中索引时延迟重试(1s/3s)并留痕(修批量静默不落库) 2026-12-02 18:29:20 +08:00
qiqi 17a8681897 docs(changelog): 补 v3.26.206 条目(183 起无记录,release-records 守卫需要) 2026-12-02 18:15:57 +08:00
qiqi c34cadc7d9 fix(style): 恢复 .iwb-pop-anchor 的 z-index(下拉弹层被压在节点下面,打不开)
Verify (Gitea) / gate (build · unit · facts) (push) Failing after 47s
2026-12-02 18:14:51 +08:00
qiqi a4d0f8ab79 fix(style): 去掉角标规则里的 z-index 声明(计数棘轮 +2;DOM 顺序已足够)
Verify (Gitea) / gate (build · unit · facts) (push) Failing after 46s
2026-12-02 18:08:13 +08:00
qiqi a56ad1829b chore(plugins): 回滚后重新同步插件产物(gallery 1.9.11) 2026-12-02 18:07:59 +08:00
qiqi bbd1e090b5 docs: 锚点同步 v3.26.206 2026-12-02 18:07:44 +08:00
qiqi fd76c76589 chore: v3.26.206(测试版:回滚到 203 行为) 2026-12-02 18:07:44 +08:00
qiqi 71cd7bc41e test: 补 useEffect 桩(183 起既有失败,与本轮无关) 2026-12-02 18:07:44 +08:00
qiqi af9d261636 revert(ui): 整树回滚到 v3.26.203 行为(下载钮/浮层/token 改造导致图库加载异常,先恢复功能) 2026-12-02 18:07:36 +08:00
qiqi 7c20ca90ee docs: 锚点同步 v3.26.205
Verify (Gitea) / gate (build · unit · facts) (push) Failing after 40s
2026-12-02 17:48:28 +08:00
qiqi 8755e7327c chore: v3.26.205(测试版:图库圆钮位置/尺寸修正) 2026-12-02 17:48:27 +08:00
qiqi dc311ec0a9 fix(ui): 图库下载钮回右下角(覆盖宿主旧规则)、尺寸 28→26、与输出节点同款 2026-12-02 17:48:27 +08:00
qiqi eddd635846 fix(ui): 圆钮容器 pointer-events:none(空白时不挡图);修 result-img 单测(useEffect 桩 + 新结构断言)
Verify (Gitea) / gate (build · unit · facts) (push) Canceled after 25s
2026-12-02 17:47:59 +08:00
qiqi c22d28320e chore(plugins): gallery 1.9.11 产物(修圆钮掉出卡片)
Verify (Gitea) / gate (build · unit · facts) (push) Failing after 33s
2026-12-02 17:45:49 +08:00
qiqi c6e3488aed docs: 锚点同步 v3.26.204
Verify (Gitea) / gate (build · unit · facts) (push) Failing after 28s
2026-12-02 17:37:17 +08:00
qiqi e1c4501f00 chore: v3.26.204(测试版:宿主下载按钮圆形 + token 化;诊断读数修正) 2026-12-02 17:37:16 +08:00
qiqi 42304bc88f chore(tokens): 收紧 token 计数基线(deadTokens 31 / hex 78 / fontSize 119 / radius 69 / spacing 351 / radiusDistinct 12)
Verify (Gitea) / gate (build · unit · facts) (push) Failing after 29s
2026-12-02 17:33:44 +08:00
qiqi f83ed2e08a feat(tokens): 下载按钮尺寸提升为正式 token(--iwb-dl-size/radius/inset/gap),宿主与 gallery 共用
Verify (Gitea) / gate (build · unit · facts) (push) Failing after 31s
2026-12-02 17:31:17 +08:00
qiqi 559945281f chore(plugins): gallery 1.9.10 产物(卡片下载改圆形图标、选中只留外框)
Verify (Gitea) / gate (build · unit · facts) (push) Failing after 41s
2026-12-02 17:24:29 +08:00
qiqi fcbeab6cb1 feat(ui): 下载浮层改右下角圆形图标;图库选中只留外框(不显示角标)
Verify (Gitea) / gate (build · unit · facts) (push) Failing after 32s
2026-12-02 17:18:14 +08:00
qiqi 499f16a2df fix(diag): 私有内存读数做防守(Windows 出现 private>工作集 的错误值时不展示)
Verify (Gitea) / gate (build · unit · facts) (push) Failing after 34s
2026-12-02 16:58:15 +08:00
qiqi 1677f86129 docs: 锚点同步 v3.26.203
Verify (Gitea) / gate (build · unit · facts) (push) Failing after 35s
2026-12-02 16:32:08 +08:00
qiqi 8872c2fa47 chore: v3.26.203(测试版:节点 LOD 优先) 2026-12-02 16:32:08 +08:00
qiqi 56b39b9829 perf(out): 节点取图回到 LOD 优先(本地源才走缩略图),并用本地字节预热 512/768 2026-12-02 16:32:08 +08:00
qiqi 711822092e fix(gallery): mutate 返回 {ok:false} 也按失败处理(避免误记 ok 并白刷一次)
Verify (Gitea) / gate (build · unit · facts) (push) Failing after 34s
2026-12-02 16:19:16 +08:00
qiqi c330d3ecf8 docs: 锚点同步 v3.26.202
Verify (Gitea) / gate (build · unit · facts) (push) Failing after 32s
2026-12-02 16:08:58 +08:00
qiqi 65ea7dff9d chore: v3.26.202(测试版:orig 写对数据源) 2026-12-02 16:08:58 +08:00
qiqi 409233670c fix(gallery): orig 状态改写 ModularOutputStore(插件读的那份),不再只改 KV 索引 2026-12-02 16:08:58 +08:00
qiqi a9f36c26e7 docs: 锚点同步 v3.26.201
Verify (Gitea) / gate (build · unit · facts) (push) Failing after 59s
2026-12-02 15:56:33 +08:00
qiqi 8b539ca03e chore: v3.26.201(测试版:图库刷新修复) 2026-12-02 15:56:33 +08:00
qiqi 4315072394 fix(gallery): 原图回填后让宿主重读 outputs(修「数据已 ok、界面不刷新」) 2026-12-02 15:56:33 +08:00
qiqi 8742bbd256 docs: 锚点同步 v3.26.200
Verify (Gitea) / gate (build · unit · facts) (push) Failing after 34s
2026-12-02 15:35:19 +08:00
qiqi b674aae1bc chore: v3.26.200(诊断版修正) 2026-12-02 15:35:19 +08:00
qiqi 3563e54bd0 fix(diag): wIngestLog 自递归改为 wLog(上一版把 helper 内的调用也替换了) 2026-12-02 15:35:19 +08:00
qiqi d5787ca44a docs: 锚点同步 v3.26.199
Verify (Gitea) / gate (build · unit · facts) (push) Failing after 43s
2026-12-02 15:26:36 +08:00
qiqi c411fbe851 chore: v3.26.199(诊断版:日志进 _boot.log) 2026-12-02 15:26:36 +08:00
qiqi bda61026ff diag(gallery): gallery-orig 双写 _boot.log(wLog 不进 _boot.log) 2026-12-02 15:26:36 +08:00
qiqi 3ab39fd522 docs: 锚点同步 v3.26.198
Verify (Gitea) / gate (build · unit · facts) (push) Failing after 48s
2026-12-02 15:21:29 +08:00
qiqi 3993673ee6 chore: v3.26.198(诊断版:gallery-orig 日志) 2026-12-02 15:21:29 +08:00
qiqi c962859837 diag(gallery): 原图回填加 gallery-orig 日志(取证:为什么不命中) 2026-12-02 15:21:29 +08:00
qiqi 0276efd813 docs: 锚点同步 v3.26.197
Verify (Gitea) / gate (build · unit · facts) (push) Failing after 35s
2026-12-02 15:11:22 +08:00
qiqi 68480551c6 chore: v3.26.197(测试版:原图回填补跑) 2026-12-02 15:11:22 +08:00
qiqi 434cf0d92d fix(gallery): 原图回填抽成公共函数,并在 wAddOutputs 之后补跑(修「下载比索引先完成」的时序竞争) 2026-12-02 15:11:22 +08:00
qiqi eb19811c8f docs: 锚点同步 v3.26.196
Verify (Gitea) / gate (build · unit · facts) (push) Failing after 54s
2026-12-02 14:31:41 +08:00
qiqi 7228436b6f chore: v3.26.196(测试版:修图库原图状态) 2026-12-02 14:31:41 +08:00
qiqi a5b8b8b693 fix(gallery): 落地写原图后同步索引 orig=ok(修「仅缩略图」不消失) 2026-12-02 14:31:41 +08:00
qiqi 9f4abdbf44 docs: 锚点同步 v3.26.195
Verify (Gitea) / gate (build · unit · facts) (push) Failing after 1m36s
2026-12-02 14:13:40 +08:00
qiqi 39294cec38 chore: v3.26.195(测试版:落地即存原图) 2026-12-02 14:13:40 +08:00
qiqi 1862d55563 feat(gallery): 落地成功即写原图到 images/gallery(out_orig_)并把索引 orig 置 ok 2026-12-02 14:13:40 +08:00
qiqi b756ae0ce7 docs: 锚点同步 v3.26.194
Verify (Gitea) / gate (build · unit · facts) (push) Failing after 1m12s
2026-12-02 13:44:21 +08:00
qiqi 71d4a34197 chore: v3.26.194(测试版:图库读本地副本) 2026-12-02 13:44:21 +08:00
qiqi 5df4f626ee feat(gallery): 图库缩略图优先用落地本地副本;摘掉「生成中」样式 2026-12-02 13:44:21 +08:00
qiqi ff6e8ec883 docs: 锚点同步 v3.26.193
Verify (Gitea) / gate (build · unit · facts) (push) Failing after 1m34s
2026-12-02 13:33:47 +08:00
qiqi fe94d89a46 chore: v3.26.193(测试版:生成中改 id 无关判定) 2026-12-02 13:33:47 +08:00
qiqi d3ef0f3940 fix(out): 生成中改为「存在任一 out 运行」判定,不再依赖具体节点 id 2026-12-02 13:33:47 +08:00
qiqi ae41246f5a docs: 锚点同步 v3.26.192
Verify (Gitea) / gate (build · unit · facts) (push) Failing after 1m5s
2026-12-02 13:22:59 +08:00
qiqi 1fed4d4df3 chore: v3.26.192(测试版:生成中按宿主 busy 信号) 2026-12-02 13:22:59 +08:00
qiqi 73936ae076 fix(out): 生成中改读 busy[out::out](宿主运行态写入点,确定信号) 2026-12-02 13:22:59 +08:00
qiqi 67a379a0cf docs: 锚点同步 v3.26.191
Verify (Gitea) / gate (build · unit · facts) (push) Failing after 1m0s
2026-12-02 13:16:32 +08:00
qiqi 48829aea5d chore: v3.26.191(测试版:生成中看源节点进度) 2026-12-02 13:16:32 +08:00
qiqi 61b6df94c5 fix(out): 生成中同时看源节点进度(等上游时表头取的是 sourceProgOut) 2026-12-02 13:16:32 +08:00
qiqi 02ccb87ec7 docs: 锚点同步 v3.26.190
Verify (Gitea) / gate (build · unit · facts) (push) Failing after 1m4s
2026-12-02 13:01:44 +08:00
qiqi 5137f38b7f chore: v3.26.190(测试版:生成中角标按进度信号) 2026-12-02 13:01:44 +08:00
qiqi 2c46b0b756 feat(out): 生成中角标改用 progress[node::out](与表头进度同源,无 TDZ) 2026-12-02 13:01:44 +08:00
qiqi b4d8a7ba6a docs: 锚点同步 v3.26.189
Verify (Gitea) / gate (build · unit · facts) (push) Canceled after 43s
2026-12-02 13:00:59 +08:00
qiqi a594efc64a chore: v3.26.189(测试版:摘掉生成中角标,保留落地角标) 2026-12-02 13:00:59 +08:00
qiqi a4928d472c revert(out): 先摘掉「生成中」角标(忙碌信号取不到,不能带着猜实现;下载角标保留) 2026-12-02 13:00:59 +08:00
qiqi a8b0999a1b docs: 锚点同步 v3.26.188
Verify (Gitea) / gate (build · unit · facts) (push) Failing after 37s
2026-12-02 12:56:49 +08:00
qiqi ce8a837923 chore: v3.26.188(测试版:修输出节点渲染崩溃) 2026-12-02 12:56:49 +08:00
qiqi 5947e0c18b fix(out): 生成中判定改用 busy 标记(修 TDZ 崩溃 Cannot access before initialization) 2026-12-02 12:56:49 +08:00
qiqi a204298fee docs: 锚点同步 v3.26.187
Verify (Gitea) / gate (build · unit · facts) (push) Failing after 38s
2026-12-02 12:51:18 +08:00
qiqi 955423eac6 chore: v3.26.187(测试版:生成中角标) 2026-12-02 12:51:17 +08:00
qiqi 7ff3dd57f4 docs: 事实快照同步(srcLines) 2026-12-02 12:51:17 +08:00
qiqi 2cadad7ea7 feat(out): 生成中给旧图压暗 + 「生成中」角标(不动 data,失败即恢复)
Verify (Gitea) / gate (build · unit · facts) (push) Canceled after 9s
2026-12-02 12:51:08 +08:00
qiqi 6ff6ab6a9f docs: 基线锚点同步到 v3.26.186(a1ac3dff)
Verify (Gitea) / gate (build · unit · facts) (push) Failing after 36s
2026-12-02 12:40:15 +08:00
qiqi a1ac3dffe1 chore: v3.26.186(测试版:输出节点落地角标 + 本地优先) 2026-12-02 12:40:15 +08:00
qiqi 4b7dc6ee40 fix(ingest): 入队改到「结果写进节点数据」处,输出节点体本地优先 + 角标
Verify (Gitea) / gate (build · unit · facts) (push) Canceled after 6s
上一版把角标加在了 ResultImg,而它全仓没有调用点(输出节点用的是
ui-node-bodies 的 iwb-out-cell-img),所以用户看不到任何变化。

- runtime-workbench-logic.liveUpsert:每张结果写入节点数据时 enqueue(批量/恢复都走这里)
- ui-node-bodies:输出单元格优先用 ingest 的 localUrl,另加「排队中/下载中/未落地」角标
- app.js onEvent 里补 wThumbBump(),让命令式渲染的节点体跟着重绘
- 棘轮:app 8,895→8,896、Workbench 2,487→2,488
2026-12-02 12:40:06 +08:00
qiqi a409fa6206 docs: 基线锚点同步到 v3.26.185(b2a01354)
Verify (Gitea) / gate (build · unit · facts) (push) Failing after 30s
2026-12-02 12:28:33 +08:00
qiqi b2a0135467 chore: v3.26.185(测试版:出图结果接落地队列,仅 win 测试用) 2026-12-02 12:28:33 +08:00
qiqi c6e259a2b0 fix(ingest): ready 后异步补一次本地 URL(首次 objectURL 未就绪时也能切到本地)
Verify (Gitea) / gate (build · unit · facts) (push) Canceled after 13s
2026-12-02 12:28:17 +08:00
qiqi a8c2cd9d97 feat(ingest): 出图结果接落地队列(节点先显示远程,就绪后换本地)
Verify (Gitea) / gate (build · unit · facts) (push) Canceled after 29s
- src/image-ingest-store.js:localStorage 索引(500 条上限、pinned 不淘汰)+ url→状态视图(供组件订阅)
- app.js:装配 ingest(fetchBytes = wBlobFromSrc → dataURL → wImgRefWrite;persist 走 store)
  启动时 restore,出图后立即 enqueue(不等下载完)
- ui-components ResultImg:读视图状态,排队/下载中显示角标并压暗,失败显示「未落地」,
  就绪后 src 换成本地 objectURL(不再直连 CDN)
- style.css:角标样式全部走 token(z-anchor / radius-full / font-xs / err 语义色)
- 棘轮:app.js 8,860→8,891、Workbench 2,454→2,483、global 122→123(均按 B3 记账)

验证:image-ingest 24 条 + writeback 23 条单测、e2e 冒烟 33/33、lint/typecheck/facts/ratchet/token-lint 全绿。
图库侧仍走原缩略图链路,下一步接同一份本地引用。
2026-12-02 12:27:47 +08:00
qiqi bca71e53b9 feat(ingest): 结果图片落地管线基座(src/image-ingest.js + 24 条契约单测)
Verify (Gitea) / gate (build · unit · facts) (push) Failing after 58s
背景:出图后输出节点直接用 <img src=远程CDN>、图库缩略图再各自 fetch 一次,
CDN 慢/断流时就是「从上往下慢慢刷 / 卡住半张」,图库还晚一步。
先把「远程结果 → 本地字节」收敛成一条队列,本次只落基座,不接线(零行为变化)。

- src/image-ingest.js:状态机 queued/downloading/ready/failed/link-only;
  幂等(同 url 复用记录)、重试 1s/2s/4s×3、并发 ≤2、失败保留 url、
  释放字节(link-only)、启动恢复(queued/downloading 重排)、markMissing 自检入口。
  依赖全注入(fetchBytes/writeRef/persist/onEvent/sleep),不读任何全局,便于单测。
- tests/image-ingest-test.js:24 条断言(正常落地/幂等/重试成功/彻底失败/manual retry/
  释放/恢复/取消/并发上限/统计),已进 test:unit。
- 注册:build.js 顺序 + 模块顺序快照 + 耦合面快照;global 写入口 121→122(单列命名空间)。

下一步(未做):接线到出图结果与图库、节点改吃本地副本、失败/进度 UI —— 需与显示层一起上。
2026-12-02 12:19:30 +08:00
qiqi 200c1d35b1 docs(design): 任务队列页面方案 + 交互样式图(mockup HTML / 浅色·深色截图) 2026-12-02 12:11:37 +08:00
qiqi fae497289d docs(site): v3.26.184 发布登记(三平台齐平)
Verify (Gitea) / gate (build · unit · facts) (push) Failing after 43s
- releases.json:3.26.184 / darwin-aarch64(10,145,011 B)、darwin-x86_64(10,601,813 B)、windows-x86_64(5,589,965 B)
- 首页 / 下载页 / 插件页重新生成并上传(显示 v3.26.184)
- latest.json 三平台齐平(windows 条目来自 latest-windows.json 的 184)
2026-12-02 11:49:26 +08:00
qiqi 0cf7af230f docs: 基线锚点同步到 v3.26.184(08367fc7)
Verify (Gitea) / gate (build · unit · facts) (push) Failing after 54s
2026-12-02 11:36:12 +08:00
qiqi 08367fc707 chore: v3.26.184(测试版:插件画布桥拆分 + 性能快照接口)
相对 3.26.183 的运行时变化只有两处:
- 插件画布桥从 app.js 迁到 src/plugin-canvas-bridge.js(行为等价,app.js −51 行)
- IWBPerf 新增只读 snapshot()(性能基线用,不影响业务)

其余为工程侧:发布验收脚本、插件 harness 修正、插件产物同步(安装包会剥离插件,不影响包内)。
2026-12-02 11:36:05 +08:00
qiqi 04d309435e docs(plan): 记录插件 harness 巡检结果(10/10 全绿,6 份过期断言已修) 2026-12-02 11:31:52 +08:00
qiqi 29d8c22d53 refactor: 插件画布桥迁到 src/plugin-canvas-bridge.js(app.js −51 / Workbench −51)
Verify (Gitea) / gate (build · unit · facts) (push) Failing after 41s
app.js 与 Workbench 的行数棘轮都是零余量(8,911 / 2,505),再改一行就红。桥本身不需要 React
(只读 refs + 调已有命令),适合按 ctx + 注入搬出。

- 新增 src/plugin-canvas-bridge.js:getNodes / getSelectedNode / getNodeImage / createNode /
  screenToWorld / createImageNode / setNodeImage / saveNodeImage 全部迁出,内部持有
  src/image-writeback 实例;依赖(findSpot/placeAtDrop/addPluginNode/uid/cloneNodeDefaults/
  gallerySync/imgRefWrite/ensureTier/pluginPreview/shrinkDataUrl/showToast…)由 app.js 注入。
- app.js 只保留 20 行装配:wPluginCanvasBridge / wImageWriteback 由工厂返回,卸载置空。
- 棘轮:MAX_APP_JS_LINES 8,911→8,860(−51)、MAX_WORKBENCH_LINES 2,505→2,454(−51),按 B3 记账。
- 顺带删两个从未被引用的工厂导出(IWBStorageRuntimeFactory / IWBRuntimeMetricsFactory),
  global 写入口 122→121(+1 新模块,−2 死导出)。
- scripts/perf-baseline.js 改用 npm run build(含 copy-plugins):只跑 build.js 会缺 plugins/,
  图库面板相关 e2e 会假红。

验证:test:unit 140 文件、e2e 冒烟 33/33、lint/typecheck/facts/ratchet/boundary 全绿。
2026-12-02 11:19:51 +08:00
qiqi 8c47ef75fe feat(release): 发布后统一验收 npm run release:verify
Verify (Gitea) / gate (build · unit · facts) (push) Failing after 54s
背景:v3.26.183 发布时踩了两次坑 —— 残留脚本覆盖产物、三处版本/记录不同步,都是人工比对才发现的。

- 新增 scripts/release-verify.js:一次核对
  ① latest.json / latest-windows.json / site/releases.json / package.json 四处版本
  ② 三平台齐全 + 文件形态(mac 更新器 .app.tar.gz / 下载 .dmg;win 同一 setup.exe)+ 签名非空
  ③ 每个资产线上实际 size(HEAD)与 sha256(下载校验,--fast 跳过)与登记一致
  ④ 下载页含当前版本
- package.json 增加 release:verify;PUBLISHING/ CONTRIBUTING 增加「发布收尾必须跑」的说明
- 实测当前 3.26.183:25 项全过(mtime/sha 与线上一致)
2026-12-02 11:11:43 +08:00
qiqi 3707eb6f2c feat(perf): 性能基线纳入 App 帧探针断言(C 项)
Verify (Gitea) / gate (build · unit · facts) (push) Failing after 39s
背景:之前的 _perf-baseline.spec.js 只用页内自建的 __FRAMES__ 探针测,与 App 运行时真正
输出的 perf 行(IWBPerf,长帧 >50ms + longtask)不是同一套数据,用户日志里的数值无法回归。

- src/runtime-frame-probe.js:新增只读 snapshot()(结构化读数 + 清零),与 60s 落盘窗口解耦,
  _boot.log 的 perf 行格式不变。
- tests/_perf-baseline.spec.js:平移段前后取快照,新增 3 条断言
  · frames > 30(防「探针没启动 → 0 长帧」假绿)
  · 长帧比例 ≤ 40%
  · longtask 总时长 ≤ 2500ms
  快照同时写入 P1_BASELINE= 便于历史对比;IWB_PROBE_PERF=0 可只测不断言。
- scripts/perf-baseline.js + npm run perf:baseline:build → 动态端口起本地服 → 只跑该 spec → 关服。
- 本机实测(headless / 7000 节点 / 12 步平移,三次):长帧 13~17/57~59(22.8%~30.9%)、
  longtask 25 次 1905~1934ms、最长帧 ~400ms;阈值取实测最大值 ×1.3,换机器需重设。
- 文档:performance-lessons 增加「性能回归怎么跑」;计划 C 项标记完成。

仍不进 CI(无头环境无 GPU,数字不可比),只作真机回归。
2026-12-02 09:41:32 +08:00
qiqi 80f19a74da docs(site): 下掉 3.26.182(历史产物已被残留脚本污染,统一使用 3.26.183)
Verify (Gitea) / gate (build · unit · facts) (push) Failing after 49s
- site/releases.json 移除 3.26.182 条目(下载页历史版本不再提供该版本)
- 重新生成并上传 首页 / 下载页 / 插件页;下载页已无 3.26.182 链接
- NAS 上 182 的 mac 产物(dmg ×2 / app.tar.gz ×2 / sig ×2,字节已被覆盖成 183)
  移到 updates/_deprecated/182/,对应 URL 现返回 404,避免下载到与记录不符的文件
- scripts/audit-release-files.js 复跑:14 条全部一致(退出码 0)
2026-12-02 09:21:18 +08:00
qiqi e4a9fdacd0 feat(release): 发布收尾增加「产物 == 登记」机械自检
Verify (Gitea) / gate (build · unit · facts) (push) Failing after 50s
背景(2026-12-02):v3.26.183 发布时发现 NAS 上 3.26.182 的 mac 产物被一个残留后台脚本
覆盖成了 183 的字节,而 site/releases.json 仍记着旧 size/sha256 —— 用户下载到的文件与记录不符,
全程零报错,直到事后人工比对才发现。

- 新增 scripts/audit-release-files.js:读 site/releases.json,对最近 5 个版本的每个平台发 HEAD,
  比对线上 content-length 与记录的 size;--all 全量、--sha 对最新版本额外下载核对 sha256;
  不一致 / 404 以非零退出。
- publish-update.sh 收尾调用它:不一致就中止,release.sh 因此不会继续登记站点/打 tag。
- 实测:当前恰好指出 3.26.182 的两条 mac 记录不一致(10143942≠10142798、10605679≠10600607),
  其余 13 条(183/169/154/153 + 182 win)全部一致。
2026-12-02 09:14:55 +08:00
qiqi 78ddeee40a docs(site): v3.26.183 发布登记(三平台齐平)
Verify (Gitea) / gate (build · unit · facts) (push) Failing after 40s
- releases.json:3.26.183 / darwin-aarch64(10,143,986 B)、darwin-x86_64(10,605,713 B)、windows-x86_64(5,591,250 B)
- 下载页 / 首页 / 插件页重新生成并上传 NAS(页面显示 v3.26.183)
- 更新源 latest.json 已含三平台(windows 条目来自 latest-windows.json 的 183)
2026-12-02 09:11:41 +08:00
qiqi 4abdd2323a docs(site): 插件市场发布 white-bg-800 1.2.3 / blank-canvas 1.0.1(站点与插件页同步)
Verify (Gitea) / gate (build · unit · facts) (push) Failing after 37s
- market.maqiart.eu.org:index.json + 两个 zip + 旧版单文件产物 + 展示页已更新并回读校验
  (索引版本 1.2.3 / 1.0.1;下载 zip 的 sha256 == 索引 bundleSha256;单文件 sha256 == 索引 file.sha256)
- 下载站:index.html / plugins-index.json / plugins/index.html 重新生成并上传(插件卡片版本同步)
2026-12-02 08:56:11 +08:00
qiqi 036865a201 chore(plugins+preflight): white-bg-800 1.2.3 / blank-canvas 1.0.1 产物 + preflight B1/B2/B3
Verify (Gitea) / gate (build · unit · facts) (push) Failing after 38s
插件批次(插件仓 e2982e3,产物同步到 plugins/):
- white-bg-800 1.2.3:覆盖模式走 saveNodeImage(落盘校验/失败回滚/可读原因),老宿主回退同步 setNodeImage;
  harness 改为双形态(new/old)并把两处过期断言改对
- blank-canvas 1.0.1:空白判定补 localRef/ref,避免只有本地引用的节点被白图覆盖

preflight / 守卫:
- B1 preflight 第 6 项:扫现行文档里已下线的路径与命令(functions/api、verify:release、plugins-publish、_inbox、wrangler),
  删除线/已弃用豁免;首次运行抓到 4 处仍在教 NAS _inbox 取件的过期说明,改为 tailnet HTTP 流程
- B2 source-text-ratchet 增加 src global.* 写入口棘轮(实测 122,只减不增)
- B3 棘轮上限行必须带「日期 + 相对上一版的差(或基线说明)+ 原因」,否则红(防"谁写谁抬")
2026-12-02 08:53:02 +08:00
qiqi 04c87ff0f6 docs: 基线锚点同步到 v3.26.183(b721febd)
Verify (Gitea) / gate (build · unit · facts) (push) Failing after 36s
守门第 7 组要求锚点 == 最近一次 bump 版本的提交,发版提交 b721febd 之后必须同步,
否则 npm run test:facts 恒红。顺带在锚点描述里记上 183 的改动主题。
2026-12-02 07:40:23 +08:00
qiqi b721febd63 chore: v3.26.183(三处版本一致 + Cargo.lock 版本对齐)
- package.json / src-tauri/tauri.conf.json / src-tauri/Cargo.toml 三处 3.26.183
- Cargo.lock 里 image-workbench 的 version 一并改为 3.26.183:
  此前它停在 3.26.180,而 Cargo.toml 已是 3.26.182,任何一次 cargo 构建都会把锁文件改脏,
  preflight 就只能靠人工还原。对齐后构建不再产生这份噪声改动。
2026-12-02 07:40:13 +08:00
qiqi 5728efd9b4 refactor: 图片写回收口到 src/image-writeback.js(3.26.183 前置)
四个线上问题(174~182)都落在同一条链上:插件写图 → 节点数据 → 缩略图缓存 → 渲染。
旧实现分散在 app.js 插件桥与 runtime-workbench-logic,顺序靠人记,改一处漏一处就复发。

- 新增 src/image-writeback.js 三入口:
  · replaceNodeImage:引用化 → 一次 commit → saveNow → 回读校验(失败回滚旧图)→ 旧/新双 key 失效 → bump
  · replaceNodeImageSync:同步严格布尔、只改内存不落盘(blank-canvas / white-bg-800 依赖此语义)
  · createNodeImage:同步返回 id,大图后台引用化(6 个建图插件零改动)
- app.js 只做装配:删除 origImagePatch 与三个写入口旧实现;「还原替换前原图」支持引用形态
- 阈值只留一条判据:IMPORT_INLINE_MAX + wImportImage(keepOriginal);删除 182 的 200KB + 裸 wImgRefWrite 旁路
- orig 一起引用化,并补进 HISTORY_IMG_REF_FIELDS(撤销快照不再整串存旧图)
- 单测 tests/image-writeback-test.js(23 条断言)已进 test:unit
- 棘轮记账:MAX_APP_JS_LINES 8743→8911(+168)、MAX_WORKBENCH_LINES 2333→2505(+172,相对 HEAD −19)
  (174~182 修 bug 期间累计 +196 未记账,本轮把写回逻辑搬进 src 后按实测显式上调)
- 门禁修复:裁剪矩形守卫文本(cullRectsOf 已用 p = pad + extra)、事实文档数字与基线锚点、模块顺序/耦合面快照
- 文档:plugin-development.md 修正 ctx.canvasWrite 旧写法 + 新增「图片写回契约」表;
  workflow-2026-12-02.md 增加分工红线(代码改动只在 mac 侧,构建机只做流程性动作)
2026-12-02 07:40:02 +08:00
qiqi 49a35e5dc3 docs: 质量与性能优化计划(待确认) 2026-12-02 07:09:05 +08:00
qiqi e8806eb705 docs: Windows 发布流程改为 tailnet 取件(弃用 _inbox 路径说明) 2026-12-02 07:00:51 +08:00
qiqi 19e2fcd690 docs: 清理过期说明(网页版 Functions/KV、verify:release、插件来路、基线锚点)+ 修 Windows 签名脚本 env 冲突
Verify (Gitea) / gate (build · unit · facts) (push) Failing after 40s
2026-12-02 07:00:22 +08:00
qiqi 30cf375ea0 docs+tooling: 工程流程优化约定(preflight 体检 / diag-tail 日志过滤)
Verify (Gitea) / gate (build · unit · facts) (push) Failing after 41s
2026-12-02 06:54:16 +08:00
qiqi 32ac08faeb docs(site): v3.26.182 Windows 条目(5,587,784 B / 41dd2e78…)
Verify (Gitea) / gate (build · unit · facts) (push) Failing after 1m47s
2026-12-01 22:14:58 +08:00
qiqi 795a67bf80 docs: v3.26.182 发布记录与下载页(mac 双架构)
Verify (Gitea) / gate (build · unit · facts) (push) Failing after 55s
2026-12-01 22:12:52 +08:00
qiqi 2429577637 docs: 画布性能与图片链路优化参考(2026-12-01 排查结论) 2026-12-01 22:08:49 +08:00
qiqi 738b70c535 perf: v3.26.182 标注写回后大图无损引用化(DOM 不再挂 1.2MB base64)
Verify (Gitea) / gate (build · unit · facts) (push) Failing after 2m11s
2026-12-01 22:02:11 +08:00
qiqi f0b75b401d perf: 缩略图失败 key 负缓存(v3.26.181 实际源码,之前漏提交)
Verify (Gitea) / gate (build · unit · facts) (push) Canceled after 13m54s
2026-12-01 21:48:16 +08:00
qiqi 7d0ee9c11a perf: v3.26.181 缩略图生成失败的 key 不再重试(标注覆盖后反复解码吃 CPU)
Verify (Gitea) / gate (build · unit · facts) (push) Failing after 1m58s
2026-12-01 21:44:08 +08:00
qiqi 190ec3934b perf: v3.26.180 停用常驻合成层(窗口可见时持续 CPU)
Verify (Gitea) / gate (build · unit · facts) (push) Failing after 9m19s
2026-12-01 21:34:29 +08:00
qiqi 7ca372efec fix: v3.26.179 无缩略图时直接显示原图(空 src 触发 onError 被永久标失效);onLoad 清除失效标记
Verify (Gitea) / gate (build · unit · facts) (push) Failing after 1m49s
2026-12-01 21:20:31 +08:00
qiqi c3227ce0d5 fix: v3.26.178 logPut 兼容单对象入参;plugin-img 同时写 _boot.log
Verify (Gitea) / gate (build · unit · facts) (push) Failing after 2m46s
2026-12-01 21:01:22 +08:00
qiqi 44073f8d09 diag: v3.26.177 插件写回加可见 toast(成功/失败原因)
Verify (Gitea) / gate (build · unit · facts) (push) Canceled after 1m0s
2026-12-01 21:00:21 +08:00
qiqi d4983a8aa1 diag: v3.26.176 插件图片写回路径落 _boot.log(定位标注覆盖不生效)
Verify (Gitea) / gate (build · unit · facts) (push) Failing after 1m11s
2026-12-01 20:52:40 +08:00
qiqi e9d22d235d fix: v3.26.175 覆盖替换图片时清掉 localRef/ref(旧引用一直压过新图)
Verify (Gitea) / gate (build · unit · facts) (push) Failing after 1m53s
2026-12-01 20:45:04 +08:00
qiqi 7833e6c4fe fix: v3.26.174 插件写回图片后失效缩略图缓存并重渲染(修标注覆盖后不落地/CPU 空转)
Verify (Gitea) / gate (build · unit · facts) (push) Failing after 1m3s
2026-12-01 20:34:18 +08:00
qiqi e2b976413c feat: v3.26.173 帧探针可开关(rAF 帧时长 + JS 长任务写 _boot.log)
Verify (Gitea) / gate (build · unit · facts) (push) Failing after 2m5s
2026-12-01 20:01:31 +08:00
qiqi 7bc0752cec fix: v3.26.172 新图无缩略图时最多占位 300ms 后回退原图(修标注替换原图后节点空白)
Verify (Gitea) / gate (build · unit · facts) (push) Failing after 41s
2026-12-01 17:40:43 +08:00
qiqi 56975e69fd release(plugins): image-vectorize 0.6.3(关闭面板释放源图与 SVG)
Verify (Gitea) / gate (build · unit · facts) (push) Failing after 42s
2026-12-01 17:36:48 +08:00
qiqi b1b2438fa0 perf: v3.26.171 自动回收阈值放松(空闲 90s;RSS>2500MB 直接完整回收)
Verify (Gitea) / gate (build · unit · facts) (push) Failing after 1m57s
2026-12-01 17:15:25 +08:00
qiqi 624cc4a34f feat: v3.26.170 诊断采样可关闭(15s 曲线 + 4s 进程轮询)+ 面板明细 60s 缓存
Verify (Gitea) / gate (build · unit · facts) (push) Failing after 41s
2026-12-01 17:13:44 +08:00
qiqi b0fd0a725c perf: v3.26.170 诊断面板明细改为 60s 缓存 + 手动刷新(修面板开着时空闲 CPU 20%)
Verify (Gitea) / gate (build · unit · facts) (push) Failing after 2m47s
2026-12-01 17:04:46 +08:00
qiqi 30c9ef93be docs(site): v3.26.169 Windows 条目(5,586,528 B / 90f1fad7…)
Verify (Gitea) / gate (build · unit · facts) (push) Failing after 51s
2026-12-01 15:12:21 +08:00
qiqi 766e434e1d docs: v3.26.169 发布记录与下载页(mac 双架构)
Verify (Gitea) / gate (build · unit · facts) (push) Failing after 49s
2026-12-01 15:02:50 +08:00
qiqi a0a98b738e docs: 锚点对齐 v3.26.169+7856afd(publish 自动) 2026-12-01 15:00:28 +08:00
103 changed files with 5750 additions and 415 deletions

No files matched your search

+227
View File
@@ -16,6 +16,233 @@
> 3. 核验正式地址版本 → 之后才移动 `stable` / `stable-verified-<日期>` 标签、更新本 CHANGELOG、写 GitHub Release(`gh release create`)。
> 测试发现问题 → 改 → 再 `deploy:test`,正式环境不受影响。回滚点 `git reset --hard stable`。
## v3.24.86(2026-11-16)补记
- 历史条目补录:该 tag 当时未在 CHANGELOG 记录(release-records 守卫要求 tag 与条目双向一致),内容按当时提交补一句占位说明。
## v3.26.240(2026-12-03)下载改系统网络栈 + 并发可调
- 图片下载改走 Rust fetch_image_b64(reqwest,系统网络栈):不受 CORS/WebView 限制,修「浏览器能下、任务队列卡在 55% 不动」;失败仍回退 WebView fetch。
- 同时下载默认 30(设置 → 通用 → 生成 → 同时下载,1–64 可调),改设置下一轮立即生效。
- 修并发限制从未生效的老 bug:pump() 的 active++ 原在延迟任务里,会把整个队列一次性放出去。
- 新增/扩展 tests/image-ingest-test.js(Rust 优先/回退、并发按设置生效)。
- 任务图:插件文本节点接了多张参考图时合并为 1 个任务(此前一条边一个任务);相册一图一任务不受影响。
- 任务图:图 + 文本混合上游也合并为 1 个任务(此前会多生成一张没图的)。
- 落地:取消/重下的在飞结果作废(不再双写或把 link-only 复活);abort 后不再回退二次抓取。
- 输出节点:ready 但本地 URL 未就绪时不再回退远程,修新图「从上往下」渐进重下。
- 输出节点双击预览改用图库条目(origIdb → 磁盘原图),不再直接喂远程 URL;打开即有缩略图、原图本地解析。
## v3.26.239(2026-12-03)清理未引用修正 + 模板节点连图修复
- 设置「清理未引用图片」:`images/thumbs/*_<max>` 缩略图缓存不再计入未引用、不再搬进 trash;弹窗文案与实现对齐(画布在用=保留、登记表缺失=已丢失无法恢复);trash 同名冲突加时间戳。
- 生成任务图:插件文本节点接了上游(如参考图)时不再丢自己的文本 —— 修「参考图 → 提示词模板 → 生图」只发图不发提示词导致的 400 INVALID_ARGUMENT。
- 新增守卫 `tests/plugin-text-node-refs-test.js`(6 条,进 test:unit)。
- 插件:promptlib 1.14.14(模板节点输入端口 / 变量内容支持长文本多行 / 节点双击标题回填 / 编辑防误关)。
## v3.26.238(2026-12-03)图片读取/下载口径统一(本地优先 + 图库行名)
- 新增本地原图读取:`galleryOriginalOf`(预览,原生按 2048 解码)/ `galleryOriginalBlob`(下载,原始字节),老记录不再退 320 缩略图。
- 任务队列预览改为只读本地(origIdb → images/gallery 原图);本地没有就提示「先下载」,远程链接不再参与预览。
- 下载统一本地优先(`wResolveOutputSrc` 先读本地字节);输出节点 / 预览 / 批量下载的文件名统一用图库行名(未落地回退 image.png、image-001.png)。
- 新增规范 `docs/standards/image-read-and-download.md` 与守卫 `tests/image-download-contract-test.js`(命名写死、预览直连远程都会被拦)。
- 棘轮:app.js 9345→9354(+9)、Workbench 2686→2687(+1),原因已写在常量注释。
- 构建链:`copy-plugins` 统一按 LF 写入 dist;`check-dist` 增加 dist/plugins 与 index.json 哈希校验(修 Windows autocrlf 下 style-source 被 SRI 拒绝)。
## v3.26.237(2026-12-03)任务队列页头/页签固定、页脚不再被压
- 插件根节点改为占满整页高度(`.iwb-tq{height:100%}`),宿主不再整页滚动;只有列表自己滚。
- 列表加 overflow-y:auto:修「行内容溢出压在页脚说明上」与「页头/筛选页签随列表滚走」。
- 任务队列预览取源改「原图优先」:老记录(无 origIdb)不再被 320 缩略图放大,改为原图链接优先、缩略图只兜底。
- 插件 taskqueue 1.0.3。
## v3.26.236(2026-12-03)顶栏标签条彻底固定
- 工作区标签条 portal 到 body + position:fixed,脱离 overlay 的滚动/层叠;插件页改 position:fixed。
- 修 235 在 WebView2 下仍会被整页滚动带走的问题。
## v3.26.235(2026-12-03)任务队列修复(选中/滚动/缩略图/定位)
- 修任务队列入口在离开页面后仍高亮(activePage 增加 shellView==='page' 判断)。
- 锁住插件整页滚动(只有 body 滚);工作区标签条改 fixed,页头不再被滚走。
- 队列缩略图/预览优先图库稳定字节(row.idb / row.origIdb),localUrl 最后;img onerror 回退占位。
- `archiveGenerationResults` 支持 meta(boardId/boardName/nodeId),兜底入队不再「未知画布」。
- 下载中超过 60 秒显示「可能卡住」并提供「重新下载」(cancel + retry);等待时长可见。
- 插件 taskqueue 1.0.2。
## v3.26.234(2026-12-03)任务队列体验修正
- 修任务队列页打开时画布图标仍选中(nav view 空串回退 canvas)。
- 缩略图复用图库已有的 320 缩略图(按 url 取 idb);占位图标修 SVG 命名空间;一次最多读 120 条并缓存。
- 标题改用提示词前 24 字 + 「第 N 张」;旧记录用「历史记录 · 时间 · #id」兜底;显示画布名(旧记录显示未知画布,不补)。
- 状态细分为「已入图库 / 待入库 / 下载中·排队中 / 下载失败 / 未下载」;失败行主按钮改为「下载」(land 会建图库行并重试),去掉含义模糊的「重试」。
- 插件 taskqueue 1.0.1。
## v3.26.233(2026-12-03)任务队列(左栏整页插件)
- 新增宿主 `queue` / `pages` 能力:全局生图账本(url/状态/画布/节点/模型/尺寸)、记录上限、下载落地图库、重试、复制原始链接、定位节点、点击缩略图预览。
- 新增插件 `taskqueue 1.0.0`:左栏一级入口「任务队列」整页;可启用/禁用;插件关闭时宿主仍按上限记账。
- 账本独立落 `library/task-queue/index.json`;上限 `canvas.taskQueueMax` 默认 500(100~5000),淘汰最旧不影响图库文件。
- 图库保持只显示已落地图片;「下载」= 建索引行 + 入落地队列,图库自动刷新。
## v3.26.232(2026-12-03)NEW 标记层叠修正
- 修「NEW 标记实际不可见」:角标在图片浮层(.iwb-dl-ov)之前、又没有 z-index,被图片盖住;把角标移到浮层之后(同为 positioned 元素,靠 DOM 顺序压在上面),不新增 z-index 声明。
- 实测:真实单元格 DOM(角标 + 图片浮层)下,角标像素为品牌色、在图片之上;点击仍不挡图。
## v3.26.231(2026-12-03)NEW 标记排除未落地
- 修「未落地且没有上一张可显示」时仍显示 NEW:isNew 增加 failed 状态排除,与「下载中/未落地不显示 NEW」一致。
## v3.26.230(2026-12-03)新图 NEW 标记 + 图库插件 1.9.12
- 输出节点新图左上角新增「NEW」标记:只标本次启动后生成、且已显示的新图;点击/双击即消失。
- 设置 → 生成 →「新图标记」可自定义显示时长(默认 120 秒,0 = 不自动消失);不跨重启。
- 图库插件 gallery 1.9.12:卡片下载钮改为与输出面板一致的 SVG 图标 / 26px / 无阴影(需在市场更新插件)。
## v3.26.229(2026-12-03)图库下载圆钮对齐输出面板
- 图库卡片的下载按钮改到右下角圆形图标(26px),与输出节点一致;修宿主旧规则把按钮居中在底部的问题。
- 只改宿主 CSS(body .iwb-history-embedded 作用域覆盖),不动插件产物、不改类名、不动 z-index/token。
## v3.26.228(2026-12-03)输出节点下载圆钮
- 输出节点结果图的下载浮层从底部横条改为右下角圆形图标:只占一个角,矮图不再被横条挡住中心。
- 只新增 .iwb-dl-corner / .iwb-dl-round 规则;容器 pointer-events:none、按钮 auto;不动 z-index、不动 token、不动图库。旧的横条样式保留可回退。
## v3.26.227(2026-12-03)图库一致性快修
- add 按 url 幂等(已存在复用、本批去重),从源头杜绝同一张图两条索引。
- 整批补漏前先等单张归档队列排空;每批结束自动按 url 去重(不再只在启动时去重)。
- markOk 前校验原图真的落盘;索引建行保留 orig 字段(修「文件在但图库一直不显示」)。
- 图库面板打开/刷新时做一次轻量自愈(去重 + 补标 ok),不用重启就能恢复。
## v3.26.226(2026-12-02)先落地再显示(单次下载)
- 结果图改为「先落地、再显示」:落地队列成为唯一下载器,输出格在新图本地字节就绪前继续显示上一张(不再白板),就绪后整体替换。
- 不再为缩略图/原图二次抓远程:图库索引与 320 缩略图统一由落地字节生成;自动下载也优先等落地字节(最多 20s)。
- 下载中显示百分比(有 content-length 时),失败保留旧图 + 「未落地」可点重试。
- 图库只展示已落地(orig=ok)的图,pending/missing 静默隐藏,修「缩略图加载失败」空卡。
## v3.26.225(2026-12-02)撤销失败态
- onLoad 时清除 is-broken / is-broken-cell:首帧本地 blob 失效打上的失败态,在回退远程加载成功后撤销,避免「加载失败」与半透明一直盖在正常图上。
## v3.26.224(2026-12-02)白板期可见
- 角标默认显示、图片 onLoad 后由 CSS 收起;骨架垫在图片下方(未绘制时可见),白板期不再没有任何提示。
## v3.26.223(2026-12-02)图库去重 + 超时续传
- 启动时按 url 去重图库索引(修 220 遗留的重复条目,同 url 优先保留已落地原图的那条)。
- 超时失败不再判永久失败:窗口重新聚焦时自动放回队列重试。
## v3.26.222(2026-12-02)归档补漏判定修正
- 归档补漏改按 item 级 url 判定(条目形状是 items[{url}],原先读 e.url 恒为 undefined → 重复入库)。
## v3.26.221(2026-12-02)回到渐进渲染
- 有远程 url 时不再用骨架遮挡(回到 203 的渐进渲染观感);骨架仅在连 url 都没有时出现。
- 落地下载超时由 60s 改为 300s(只作真挂死的安全阀,不误杀慢 CDN)。
## v3.26.220(2026-12-02)图库少一张 + 落地超时
- 修「一次出多张、图库少一张」:wasArchived 按条目对象记,单张归档标记后批量归档整批跳过;现在已标记但图库索引里查不到该 url 的仍会补入库。
- 落地下载超时 25s → 60s(实测该 CDN 常超 25s)。
## v3.26.219(2026-12-02)入库诊断
- 记录 add-outputs(in/accepted/skipNoOk/skipNoUrl)与 archive(entries/pending),用于定位「出图多张、图库少一张」。
## v3.26.218(2026-12-02)落地下载超时
- 落地队列的下载加 25s 超时:fetch 挂住时不再永久停在「下载中」,按失败重试并最终降级。
## v3.26.217(2026-12-02)打类目标修正
- 加载/失败态改用 closest(.iwb-out-cell)(img 被下载浮层包裹,parentElement 不是单元格);含 216 的骨架撑高。
## v3.26.216(2026-12-02)骨架撑高
- 输出单元格骨架由绝对定位改为撑高(min-height 140px),出图前不再塌成一条线。
## v3.26.215(2026-12-02)失败态可见
- 加载/失败态改用父容器打类(去掉 :has 依赖,兼容老 WebView2);破图收起骨架与角标并显示「加载失败」。
## v3.26.214(2026-12-02)加载态与失败回退
- 骨架与「下载中」角标改以图片 onLoad 为准(CSS :has 联动),消除「角标已撤、图还没出来」的空窗。
- onError 两级回退(本地 blob → 远程 url),都失败标 is-broken(半透明),不再显示破图。
## v3.26.213(2026-12-02)骨架 TDZ 修复
- 修输出单元格骨架的 TDZ(_localSrc 先声明再用,上一版五态全崩);骨架仅对远程 url 生效。
## v3.26.212(2026-12-02)输出单元格加载骨架
- 无本地源时在单元格垫一层「下载中…」骨架,避免大图区域纯空白;有缩略图时仍走 LOD 显示。
## v3.26.211(2026-12-02)角标空指针修复
- 修输出单元格角标在「视图未命中 + 远程 url」时抛 TypeError(先取安全状态再判);未落地优先于下载中。
## v3.26.210(2026-12-02)输出节点恢复「下载中」角标 + 分层修正
- 恢复输出单元格的「下载中」角标:判定改为「无本地源且结果为远程 url」,不再依赖落地视图是否命中。
- 落地状态视图改为宿主注入(src 不再直接读 window.IWBImageIngestView),修 architecture-boundary-guard;ResultImg 回到纯展示。
## v3.26.209(2026-12-02)对账不再常驻轮询
- 索引对账由「每 30s」改为「启动 3s 后 + 窗口重新获得焦点时」,闲置零开销(用户要求)。
## v3.26.208(2026-12-02)落地可观测 + 对账兜底
- ingest 补 enqueue/ready/failed 三类日志(kind=gallery-orig,双写 _boot.log),下载失败不再静默。
- 新增索引对账:启动 3s 后与每 30s 各扫一次,把「索引未 ok 但落地已有本地引用」的条目补写原图(幂等)。
## v3.26.207(2026-12-02)结果落地重试
- 修「批量出图部分原图不进 gallery」:ready 事件早于图库索引写入时,原来静默 return;现在记 orig-defer 并在 1s / 3s 后各重试一次,命中即补写原图。
## v3.26.206(2026-12-02)结果落地管线 / 图库原图 / 回滚下载钮改造
- 新增「结果落地队列」:出图后后台把远程图下到本地(幂等、重试 1/2/4s×3、并发 2、失败保留 URL、重启续跑),节点与图库不再直连 CDN。
- 落地成功即把**原图**写进 images/gallery(out_orig_)并把图库索引 orig 置 ok(写 ModularOutputStore,插件读的就是这份);修「仅缩略图」不消失。
- 节点取图回到 LOD 优先(本地源才走缩略图),避免每张图整幅解码原图。
- 图库缩略图优先用落地得到的本地副本,不再为同一张图二次请求远程。
- 回滚 204/205 的下载钮圆钮改造与 --iwb-dl-* token(导致图库加载异常、下拉弹层被压);恢复 203 的横条下载按钮。
- 修 .iwb-pop-anchor 的 z-index 被误删(模型/尺寸下拉打不开)。
- 补 result-img 单测的 useEffect 桩(183 起既有失败)。
## v3.26.182(2026-12-01)标注覆盖落地 / 空闲 CPU / 画布平移
- 修「标注插件覆盖后图片丢失」:写回后清空 localRef/ref(旧引用曾压过新数据)、失效缩略图缓存并重渲染;>200KB 的新图无损转 __blob 引用,DOM 不再挂 1.2MB base64(这也是空闲 CPU 15% 的主因)。
- 修「图片源已失效」:无缩略图时直接显示原图(不再返回空 src 触发 onError),onLoad 清除失效标记。
- 缩略图生成失败加负缓存,避免每次重渲染重复解码。
- 停用「合成层常驻提升」:常驻合成层会让窗口可见时持续吃 CPU;手势期临时提升保留。
- 平移:连线不再按视口裁剪、边线层不冻结;裁剪窗口边距 1.5 屏、步长 1/3 屏,手势期间只扩张不收缩;命中层每帧同步(空格平移无 pointerup)。
- 取消约 30% 的 LOD lite 档,只在 <15% 切占位,避免阈值附近闪动。
- 诊断:Windows 分进程内存拆解(工作集+私有+PID)、导出 JSON 带开关状态与图片管线、帧探针(rAF+longtask)、可关闭诊断采样;修 logPut 契约导致日志丢失。
- 插件:image-vectorize 0.6.3(关闭面板释放源图与 SVG)。
- 自动内存回收阈值放松:可见空闲 90s 轻量回收;RSS ≥ 2500MB 立即完整回收。
## v3.26.172(2026-12-01)空闲 CPU / 图片回退 / 诊断开关
- 修「标注替换原图后节点空白」:新写入的本地图片在没有缩略图时最多占位 300ms,超时回退显示原图;粘贴、图库插入、标注替换走同一逻辑。
- 自动内存回收阈值放松:可见空闲 90 秒即轻量回收;RSS ≥ 2500MB 时不等空闲,直接完整回收(含缩略图缓存)。实测大堆导致的空闲 GC 抖动(CPU ~20%)由此消除。
- 诊断页新增「关闭诊断采样」总开关(关掉后 15s 采样与 4s 进程轮询降频/跳过);面板明细自动刷新 8s → 60s,「刷新」按钮改为强制重取。
- 插件:image-vectorize 0.6.3(关闭面板释放源图与 SVG)。
## v3.26.169(2026-12-01)平移稳定性与诊断补强
- 平移不再按视口裁剪连线(新进入区域的连线不再迟到);平移期不冻结边线层,改为按帧重画。
- 节点裁剪窗口边距 0.7→1.5 屏、更新步长 1/2→1/3 屏;平移期间「挂过即不卸载」,松手后再按视口回收,消除节点在视野内突然出现。
- 连线命中层(透明 SVG)在手势期间每帧同步,并在松开空格/中键时收尾对齐;修复「平移后鼠标扫过旧位置仍点亮已移走的连线」。
- 诊断页:新增 Windows 分进程内存拆解(工作集 + 私有提交 + PID/角色)、导出 JSON 带开关状态与解码/缩略图/图库读数;新增「手势期提升」开关。
- 取消约 30% 的 LOD lite 档,只在 <15% 切纯占位,避免阈值附近来回切换导致画面闪。
- 清理 3 条 mac 侧 dead-code 警告(辅助函数补 cfg(unix))。
## v3.26.154(2026-12-01)平移:移动已画好的边线 Canvas,不再每帧重画
- 平移期间用 CSS translate 移动 `.iwb-edge-canvas` 缓存;松手后清 transform 并重画一次。
+7 -4
View File
@@ -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 139 个单测文件(jsdom 契约测试;2026-11-07 新增 sync-facts-guard(事实一致性)/ _helpers/source(统一源文本);2026-11-12 新增 provider-ping(测速 no-cors 兜底))
test:unit 143 个单测文件(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,743**(另守「占总源码 ≤ 40%」,见 `MAX_APP_JS_SHARE`) |
| `Workbench()` 行数 | 同上 `MAX_WORKBENCH_LINES` | **2,333** |
| `app.js` 总行数 | `tests/source-text-ratchet-test.js` `MAX_APP_JS_LINES` | **9,368**(另守「占总源码 ≤ 40%」,见 `MAX_APP_JS_SHARE`) |
| `Workbench()` 行数 | 同上 `MAX_WORKBENCH_LINES` | **2,690** |
| 单组件行数(不含 Workbench)| 同上 `MAX_APP_COMPONENT_LINES` | **423** |
三条都是**只减不增**。确需在 app.js 增长时,必须**同步上调上限并在 commit 里写理由**(等于显式记账,不会悄悄发生)。
@@ -183,6 +183,8 @@ release: vX.Y.Z 发版
| 记在哪 | 记什么 |
|---|---|
| [`docs/standards/engineering-rulebook.md`](docs/standards/engineering-rulebook.md) | 新增的**工程规则**(§13.x,按主题编号) |
| [`docs/standards/image-read-and-download.md`](docs/standards/image-read-and-download.md) | **图片读取/下载口径**(取源顺序、命名;新增预览/下载入口先对照) |
| [`docs/standards/deploy-domains.md`](docs/standards/deploy-domains.md) | **域名边界**(网页版 / 下载站 / 插件市场互不干扰) |
| [`docs/standards/architecture-current-state.md`](docs/standards/architecture-current-state.md) | 改动的**现状事实**(常量、模块数、已知缺陷) |
| [`CHANGELOG.md`](CHANGELOG.md) | 用户可见的变更(发版时) |
@@ -195,8 +197,9 @@ release: vX.Y.Z 发版
1. bump 版本:`node scripts/set-version.js X.Y.Z`,更新 CHANGELOG 后提交
2. `npm run verify:ci`
3. mac:`bash scripts/publish-update.sh`(构建双架构、签名、上传、生成 latest.json)
4. Windows:按 [`docs/WIN_BUILD_SPEC.md`](docs/WIN_BUILD_SPEC.md) 出 exe → NAS `_inbox/` → mac `publish-windows-update.sh` → 再跑一次 `publish-update.sh` 合并 latest.json
4. Windows:按 [`docs/WIN_BUILD_SPEC.md`](docs/WIN_BUILD_SPEC.md) 出 exe → 由 win 起一次性 tailnet HTTP 服务、mac 拉取并核对 sha256 → mac `publish-windows-update.sh` → 再跑一次 `publish-update.sh` 合并 latest.json
5. 登记 `site/releases.json`、生成站点、上传 NAS,打 tag `vX.Y.Z` 并 push
6. 发布验收:`npm run release:verify`(四处版本 + 三平台资产 sha + 下载页;有任何 ✗ 视为未发布完成)
> 版本只认 `package.json`;平台必须同批。详细规则见 [`PUBLISHING.md`](PUBLISHING.md) 与工程规则 §13.60。
+5 -5
View File
@@ -71,12 +71,12 @@ Windows 未签名:SmartScreen 提示,仅影响首次运行体验。
## 六、插件资源的来路
网页版插件由 Cloudflare KV 在 `/plugins/*` 提供;桌面版没有服务端,所以把
**发布产物**(`plugins/runtime/*.js`,文件名带内容哈希)随仓库带走,构建后由
`scripts/copy-plugins.js` 拷进 `dist/plugins/`。每个文件的 SHA-256 与
`plugins/index.json` 里的 `integrity` 一致(已校验)。
桌面版没有服务端:插件由**插件市场**(`market.maqiart.eu.org`)分发,用户按需安装到
`<资料目录>/plugins/`;安装时按 zip 的 `bundleSha256` + 逐文件 sha256 校验。
升级插件时:换掉 `plugins/runtime/` 里的文件 + 同步 `plugins/index.json` 即可,代码不用动。
随安装包内置的插件在仓库 `plugins/`(目录形插件 + 内容寻址的 `runtime/plugin-<id>.<hash12>.js`),构建时由 `scripts/copy-plugins.js` 拷入 `dist/plugins/`,打包后由 `strip-plugins` 剥离(插件只走市场)。
升级插件:源仓改 → `sync-plugins-from-repo.js` → `gen-market.js` → 上传市场(详见 `docs/reference/plugin-publish.md`)。
## 七、本机实测记录(2026-11-16,macOS arm64)
+8 -4
View File
@@ -29,12 +29,16 @@ bash scripts/publish-update.sh
`release.sh` 收尾会校验线上 `latest.json`,与本次版本不一致时打印告警并提示补跑 `publish-update.sh`。
注意 `publish-update.sh` 会**重新构建并覆盖 dmg**,所以顺序建议:先 `publish-update.sh`(写 latest.json + 覆盖 dmg),再跑 `update-releases.js` 按新 dmg 的 size/sha 登记、gen 站点、上传。
`npm run release:verify` 是发布收尾的统一验收(2026-12-02 新增):核对 latest.json / latest-windows.json / site/releases.json / package.json 四处版本一致、三平台齐全、每个资产在线上实际 size+sha256 与登记一致、下载页含当前版本。完整模式会下载 dmg/exe(约 40s),`-- --fast` 只比对 size。**任何一项 ✗ 都不要对外宣布发布完成。**
## Windows 发布
1. Windows 端按 [`docs/WIN_BUILD_SPEC.md`](docs/WIN_BUILD_SPEC.md) 构建 `*-setup.exe`,放 NAS `_inbox/`
2. mac 端签名:`bash scripts/publish-windows-update.sh <setup.exe>`
3. **再跑一次** `bash scripts/publish-update.sh`,把 `windows-x86_64` 合并进 `latest.json`
4. 下载页登记 Windows 条目并核验
1. Windows 端构建 `*-setup.exe`(不签名、不产 .sig),回报:本地路径 / 字节 / sha256 / `dist/version.json`。
2. **取件**:用户在 Windows 本机时优先让他直接装本地产物;mac 需要签名时,由 Windows 端起**一次性 tailnet HTTP**(`http://100.101.6.64:1876x/<token>/<file>`),mac 拉取并核对 sha256。
- 局域网地址(如 `10.20.2.111`)跨网段不通;早先用的 NAS `_inbox/` 取件已弃用(UDG 共享 mac 读不到),现在只走 tailnet HTTP。
3. mac 端签名并上传:`bash scripts/publish-windows-update.sh <setup.exe>`(签名 → 上传 `updates/windows-x86_64` → 写 `latest-windows.json`)。
4. 把 `windows-x86_64` 条目并入 `latest.json`(保留 darwin 两条签名),核验三平台齐平。
5. 下载页登记 Windows 条目,回读 exe 的字节与 sha256 一致。
## 版本/tag 纪律
+588 -99
View File
@@ -83,7 +83,8 @@ try { if (window.IWBMiniMapFit && typeof window.IWBMiniMapFit.install === 'funct
? window.IWBDownloadAuto.create({
getDir: wDownloadDir,
isOn: wAutoDownload,
resolveSrc: (item) => window.IWBDownloadAuto.resolveLocalFirst(item, { resolveDirect: (x) => wResolveOutputSrc(x, true), listFiles: () => (ModularOutputStore ? ModularOutputStore.list({ metaOnly: true }).then((r) => (r && r.ok && r.value && r.value.files) || []).catch(() => []) : lsGet(OUT_KEY, [])), readIdb: (k) => IDB.get(k).catch(() => null) }),
// 2026-12-02(方案 A):等落地队列的本地字节(最多 20s),拿不到才回落原有本地优先链路
resolveSrc: async (item) => { try { const du = await window.IWBDownloadAuto.waitIngestRef(item && item.url, { get: (u) => (window.IWBImageIngestView && typeof window.IWBImageIngestView.get === 'function') ? window.IWBImageIngestView.get(u) : null, refDataUrl: wImgRefDataUrl }); if (du) return du } catch (eIng) { /* ignore */ } return window.IWBDownloadAuto.resolveLocalFirst(item, { resolveDirect: (x) => wResolveOutputSrc(x, true), listFiles: () => (ModularOutputStore ? ModularOutputStore.list({ metaOnly: true }).then((r) => (r && r.ok && r.value && r.value.files) || []).catch(() => []) : lsGet(OUT_KEY, [])), readIdb: (k) => IDB.get(k).catch(() => null) }) },
// dataURL 直接解码成 Blob(不再 fetch(dataURL));远程 URL 返回 null 让调用方走 fetch
toBlob: (src) => (String(src || '').indexOf('data:') === 0 ? wBlobFromDataUrl(src) : null),
write: wWriteBlobToDir,
@@ -236,9 +237,12 @@ try { if (window.IWBMiniMapFit && typeof window.IWBMiniMapFit.install === 'funct
// 与 wPluginNodeVariants(菜单/运行用,仅"已激活"变体)分开,故不影响启停语义。
const wPluginVariantMeta = new Map()
const wPluginPanels = []
const wPluginPages = [] // 插件整页(pages 能力):{id,title,icon,mount,pluginId}
const wQueueThumbCache = new Map() // 任务队列缩略图缓存:url -> 320 dataURL
const wPluginGenHooks = []
const wPluginProviders = []
let wPluginCanvasBridge = null
let wImageWriteback = null // 图片写回唯一收口(src/image-writeback.js,v3.26.183)
const wPluginNodeActions = []
const wRuntimePlugins = []
const StorageMigrations = (typeof window !== 'undefined' && window.IWBStorageMigrations) || null
@@ -415,7 +419,7 @@ try { if (window.IWBMiniMapFit && typeof window.IWBMiniMapFit.install === 'funct
// autoSaveImages 已废弃(v3.25.33):保留字段只为老配置兼容,**不再驱动任何下载行为**。
// 「出图自动保存」由 设置 → 图片导出目录 → 自动下载(iwb.autoDownload + wAutoSaver)负责。
// lodLowZoom(v3.25.71):15% 以下是否切轻量节点体(用户可关)
const W_DEF_CANVAS = { generationConcurrency: 4, taskStallEndMs: 300000, autoSaveImages: true, backupOriginals: true, lodLowZoom: true, appearance: W_DEF_APPEARANCE }
const W_DEF_CANVAS = { generationConcurrency: 4, taskStallEndMs: 300000, autoSaveImages: true, backupOriginals: true, lodLowZoom: true, newBadgeSec: 120, taskQueueMax: 500, downloadConcurrency: 30, appearance: W_DEF_APPEARANCE }
// 任务条「结束」按钮出现的阈值:默认 5 分钟。判据是「该任务距上一次进展的时长」,
// 而不是任务总时长 —— 多个变体(如 3 张)正常跑 6 分钟也不会误报"卡住"。
const TASK_STALL_END_MIN = 60000
@@ -1922,6 +1926,168 @@ try { if (window.IWBMiniMapFit && typeof window.IWBMiniMapFit.install === 'funct
// v3.87.33:抓取失败的输出(多为图床 CORS/403)记入"不再重试",否则每次生成都会把
// 全部失败图重新抓取+整尺寸解码(配合并发 5 → 单次 500~900MB 尖峰,实测 d720/d898)。
const wThumbFail = new Set()
// 2026-12-02(197):把「落地队列拿到的本地字节」写成图库原图(out_orig_)并同步索引。
// 幂等:已 ok / 已有 origIdb / 取不到字节都直接跳过。onEvent(ready) 与 wAddOutputs 之后各调一次,
// 覆盖「下载比索引先完成」的时序竞争(196 就是只挂在前者,才出现「有些正常有些一直仅缩略图」)。
// 诊断专用:既写 wLog(IDB/data.json),也写 _boot.log(用户最容易取到的那条通道)
function wIngestLog(msg) {
try { wLog('gallery-orig', msg) } catch (e1) { /* ignore */ }
try { const SF = window.IWBStorageFile; if (SF && typeof SF.logLine === 'function') SF.logLine('gallery-orig ' + msg) } catch (e2) { /* ignore */ }
}
// 索引条目 → 用落地队列已拿到的本地字节写原图 + 缩略图(不再抓第二次远程)。返回是否已写。
function wFillOutputFromIngest(item) {
try {
const view = (typeof window !== 'undefined') ? window.IWBImageIngestView : null
const v = (view && typeof view.get === 'function') ? view.get(item && item.url) : null
if (v && v.ref) return wIngestOrigFromRef(item.name, item.url, v.ref)
} catch (e) { /* ignore */ }
return null
}
function wIngestOrigFromRef(name, url, ref) {
if (!name || !ref) return Promise.resolve(false)
return Promise.resolve(wImgRefDataUrl(ref)).then((du) => {
if (!du) return false
// 同时预热节点显示用的 512/768 缩略图(ref key),让画布不必再解原图或抓远程
try { if (typeof wPrimeDisplayThumbForRef === 'function') wPrimeDisplayThumbForRef(ref, du) } catch (e5) { /* ignore */ }
// 先等原图 + 320 缩略图**真的写完**,再把索引标 ok 并通知图库 ——
// 否则插件先看到 ok 却取不到缩略图,就是用户看到的「图库显示缩略图加载失败」。
return Promise.resolve(storeOutputThumb({ name: name, url: url, data: du }, true)).catch(() => null).then((written) => {
// 2026-12-03:原图没真正落盘就不许标 ok —— 否则会出现「图库有卡片、images/gallery 没文件」。
if (!written) { try { wIngestLog('orig-write-fail name=' + name) } catch (eW) { /* ignore */ } return false }
// 202:必须写进 **ModularOutputStore**(图库/插件读的是它),只改 KV 索引不会生效。
const markOk = (list) => (Array.isArray(list) ? list.map((f) => (f && f.name === name)
? Object.assign({}, f, { orig: 'ok', origIdb: IDB_ORIG_PREFIX + name })
: f) : list)
const after = () => {
try { if (typeof wGalleryChanged === 'function') wGalleryChanged('output') } catch (eG) { /* ignore */ }
try { if (typeof window !== 'undefined' && typeof window.__iwbRefreshOutputs === 'function') window.__iwbRefreshOutputs() } catch (eR) { /* ignore */ }
try { wIngestLog('ok name=' + name) } catch (eL) { /* ignore */ }
}
try {
if (ModularOutputStore && typeof ModularOutputStore.mutate === 'function') {
Promise.resolve(ModularOutputStore.mutate(markOk)).then((r) => {
// storage-outputs 的失败约定是「返回 {ok:false}」而不是 reject(2026-12-02 构建机指出)。
// 不判这一下,写失败也会记 ok、还会白刷一次图库,下一轮诊断会被误导。
if (r && r.ok === false) { try { wIngestLog('index-write-fail ' + name + ' err=' + String(r.error && (r.error.code || r.error.message) || r.error || '-')) } catch (eF1) { /* ignore */ } return }
after()
}).catch(() => { try { wIngestLog('index-write-fail ' + name) } catch (eF) { /* ignore */ } })
} else {
lsSet(OUT_KEY, markOk(lsGet(OUT_KEY, []) || []))
after()
}
} catch (e2) { wIngestLog('index-write-fail ' + name) }
return true
})
}).catch(() => false)
}
// 按结果列表回填:给每条还没 ok 的条目找落地队列里的本地引用
// 2026-12-02(207 之后):对账兜底 —— 只靠 ready 时刻匹配会漏(索引写得更慢 / 进程被杀)。
// 这里扫一遍索引:orig 未 ok 且落地队列已有本地引用的,直接补写;幂等,可反复跑。
// 2026-12-02:图库索引去重 —— 220 那次「补漏」读错字段导致同一 url 被写入多条。
// 这里按 url 分组,同 url 只保留一条(优先保留已落地原图的那条),幂等,可反复跑。
// 按 url 去重(同一张图只留一行,优先保留已落地的)。写回走 ModularOutputStore.mutate(同一把锁),
// 不再直接 lsSet —— 直写会绕过锁,与归档并发时互相覆盖。
async function wDedupeOutputs() {
try {
const compute = (list) => {
const idx = Array.isArray(list) ? list : []
if (idx.length < 2) return { kept: idx, removed: 0 }
const best = new Map()
let removed = 0
for (const f of idx) {
const u = String((f && f.url) || '')
if (!u) continue
const prev = best.get(u)
if (!prev) { best.set(u, f); continue }
const score = (x) => ((x && x.orig === 'ok') ? 2 : 0) + ((x && x.origIdb) ? 1 : 0)
if (score(f) > score(prev)) best.set(u, f)
removed++
}
if (!removed) return { kept: idx, removed: 0 }
const kept = []
const seen = new Set()
for (const f of idx) {
const u = String((f && f.url) || '')
if (!u) { kept.push(f); continue }
if (seen.has(u)) continue
seen.add(u)
kept.push(best.get(u))
}
return { kept, removed }
}
let removed = 0, left = 0
if (ModularOutputStore && typeof ModularOutputStore.mutate === 'function') {
const r = await ModularOutputStore.mutate((list) => { const out = compute(list); removed = out.removed; left = out.kept.length; return out.removed ? out.kept : null })
if (r && r.ok === false) return 0
} else {
const out = compute(lsGet(OUT_KEY, []) || [])
removed = out.removed; left = out.kept.length
if (removed) lsSet(OUT_KEY, out.kept)
}
if (!removed) return 0
try { wIngestLog('dedupe removed=' + removed + ' left=' + left) } catch (e1) { /* ignore */ }
try { if (typeof wGalleryChanged === 'function') wGalleryChanged('output') } catch (e2) { /* ignore */ }
try { if (typeof window !== 'undefined' && typeof window.__iwbRefreshOutputs === 'function') window.__iwbRefreshOutputs() } catch (e3) { /* ignore */ }
return removed
} catch (e4) { return 0 }
}
function wIngestReconcile(repairOnly) {
try {
const idx = lsGet(OUT_KEY, []) || []
const view = (typeof window !== 'undefined') ? window.IWBImageIngestView : null
if (!view || typeof view.get !== 'function') return 0
let n = 0
for (const f of idx) {
if (!f || !f.url || f.orig === 'ok' || f.origIdb) continue
const v = view.get(f.url)
if (v && v.ref) { try { wIngestOrigFromRef(f.name, f.url, v.ref); n++ } catch (e1) { /* ignore */ } }
}
if (n) { try { wIngestLog('reconcile fixed=' + n) } catch (e2) { /* ignore */ } }
// 2026-12-02:超时失败不判死 —— 下次窗口聚焦时放回队列重试(慢 CDN 超过 5 分钟也能续上)
if (!repairOnly) try {
const ing = (typeof window !== 'undefined') ? window.__iwbIngest : null
if (ing && typeof ing.retry === 'function') {
let re = 0
for (const f of idx) {
if (!f || !f.url || f.orig === 'ok' || f.origIdb) continue
const v = view.get(f.url)
if (v && v.status === 'failed' && /timeout/i.test(String(v.error || ''))) { try { ing.retry(v.id); re++ } catch (e5) { /* ignore */ } }
}
if (re) { try { wIngestLog('reconcile retry-timeout=' + re) } catch (e6) { /* ignore */ } }
}
} catch (e7) { /* ignore */ }
return n
} catch (e3) { return 0 }
}
// 图库面板打开/刷新时的轻量自愈(节流 1.5s):去重 + 把「有落地字节但索引没标 ok」的行补上。
// 运行期出现状态漂移时,打开图库就能立刻修好,不必重启。
let wLastGalleryRepairAt = 0
function wGalleryRepair() {
try {
const now = Date.now()
if (now - wLastGalleryRepairAt < 1500) return
wLastGalleryRepairAt = now
try { wDedupeOutputs() } catch (e1) { /* ignore */ }
try { wIngestReconcile(true) } catch (e2) { /* ignore */ }
} catch (e3) { /* ignore */ }
}
function wIngestOrigBackfill(results) {
try {
const idx = lsGet(OUT_KEY, []) || []
const view = (typeof window !== 'undefined') ? window.IWBImageIngestView : null
for (const r of (results || [])) {
if (!r || !r.url) continue
const f = idx.find((x) => x && String(x.url || '') === String(r.url))
if (!f) { try { wIngestLog('backfill-no-index-entry url=' + String(r.url).slice(0, 60)) } catch (eL1) { /* ignore */ } continue }
if (f.orig === 'ok' || f.origIdb) continue
const v = view && typeof view.get === 'function' ? view.get(r.url) : null
if (!v) { try { wIngestLog('backfill-no-view name=' + f.name) } catch (eL2) { /* ignore */ } continue }
if (!v.ref) { try { wIngestLog('backfill-no-ref name=' + f.name + ' status=' + String(v.status)) } catch (eL3) { /* ignore */ } continue }
try { wIngestLog('backfill-hit name=' + f.name + ' orig=' + String(f.orig || '-')) } catch (eL4) { /* ignore */ }
try { wIngestOrigFromRef(f.name, r.url, v.ref) } catch (e3) { /* ignore */ }
}
} catch (e4) { /* ignore */ }
}
const wThumbProxyTried = new Set() // 经本站代理重试过(每个 URL 只试一次)
const wThumbFailKey = (item) => String((item && item.url) || (item && item.name) || '')
function storeOutputThumb(item, forceOrig) {
@@ -2053,10 +2219,33 @@ try { if (window.IWBMiniMapFit && typeof window.IWBMiniMapFit.install === 'funct
const awaitArchive = !!(opts && opts.awaitArchive)
if (ModularOutputStore) {
const items = []
let _skNoOk = 0, _skNoUrl = 0, _skDup = 0
// 2026-12-03:幂等 —— 同一 url 只允许一行。已存在的复用(还没落地就用本地字节补),本批内重复只取第一条。
const _idx0 = lsGet(OUT_KEY, []) || []
const _byUrl = new Map()
for (const f of _idx0) { const u = String((f && f.url) || ''); if (u && !_byUrl.has(u)) _byUrl.set(u, f) }
const _seen = new Set()
const _reuse = []
for (const r of (results || [])) {
if (!r || !r.ok || !r.url) continue
if (!r || !r.ok) { _skNoOk++; continue }
if (!r.url) { _skNoUrl++; continue }
const _u = String(r.url)
if (_byUrl.has(_u) || _seen.has(_u)) {
_skDup++
const ex = _byUrl.get(_u)
if (ex && ex.orig !== 'ok' && !ex.origIdb) _reuse.push(ex)
continue
}
_seen.add(_u)
items.push({ name: 'gen_' + Date.now() + '_' + Math.floor(Math.random() * 1e6) + '.png', url: r.url, size: 0, mtime: Date.now(), width: r.width || 0, height: r.height || 0, label: r.label || '', snapshot: r.snapshot || null, orig: 'pending' })
}
try { wIngestLog('add-outputs in=' + (results || []).length + ' accepted=' + items.length + ' skipNoOk=' + _skNoOk + ' skipNoUrl=' + _skNoUrl + ' skipDup=' + _skDup) } catch (eL0) { /* ignore */ }
if (!items.length) {
// 没有新行要建;命中的旧行若还没落地,用本地字节补上(不新建行)
const _ing0 = !!(typeof window !== 'undefined' && window.IWBImageIngestView)
for (const item of _reuse) if (_ing0) { try { wFillOutputFromIngest(item) } catch (eR) { /* ignore */ } }
return []
}
const prevIdx = lsGet(OUT_KEY, [])
const modular = await ModularOutputStore.add(items, { retention: wRawCfg().outputsRetention })
if (modular && modular.ok) {
@@ -2072,17 +2261,15 @@ try { if (window.IWBMiniMapFit && typeof window.IWBMiniMapFit.install === 'funct
// v3.87.37:只处理**本次新增**的条目。之前每次生成都会把整库(实测 109 条)重扫 + 逐条 hydrate,
// 点「生成」后 480ms 内就 +720MB(探针实测),这是最大的内存尖峰来源。
const newNames = new Set(items.map((x) => x && x.name).filter(Boolean))
const needThumb = curFiles.filter((item) => item && newNames.has(item.name) && !item.idb && !wThumbFail.has(wThumbFailKey(item)))
if (needThumb.length) {
const thumbJob = runWithConcurrency(needThumb, 2, (item) => storeOutputThumb(item))
const onThumbFail = (e) => {
// 整批缩略图失败此前是**零反馈**:图库里看不到缩略图,用户不知道发生了什么。
// 现在:记录 + 提示一次(整批失败才提示,不逐张刷屏)。
try { if (CrashLog && typeof CrashLog.record === 'function') CrashLog.record('thumb-batch-failed', { scope: 'output-store', message: '缩略图批量生成失败(' + needThumb.length + ' 张):' + String((e && e.message) || e), version: APP_VERSION }) } catch (err) { /* ignore */ }
wLogNotice('部分图片的缩略图生成失败(' + needThumb.length + ' 张),图库中可能显示为空白。', 'err')
}
if (awaitArchive) { try { await thumbJob } catch (e) { onThumbFail(e) } } else thumbJob.catch(onThumbFail)
// 2026-12-02(方案 A):不再为同一张图抓第二次远程 —— 缩略图/原图统一用落地队列的本地字节。
// 已落地(ready)的立刻写;未落地的等 onEvent(ready) 回填(已有 1s/3s 重试)。
const ingOn = !!(typeof window !== 'undefined' && window.IWBImageIngestView)
const fills = []
for (const item of curFiles) if (item && newNames.has(item.name) && !item.idb) {
const p = ingOn ? wFillOutputFromIngest(item) : storeOutputThumb(item)
if (awaitArchive && p && typeof p.then === 'function') fills.push(p)
}
if (fills.length) { try { await Promise.all(fills) } catch (eF) { /* ignore */ } }
for (const item of curFiles) {
if (item && newNames.has(item.name) && imageFolderApi) imageFolderApi.save(item, item.data).catch(() => {})
}
@@ -2091,8 +2278,12 @@ try { if (window.IWBMiniMapFit && typeof window.IWBMiniMapFit.install === 'funct
}
const idx = lsGet(OUT_KEY, [])
const added = []
const _seen2 = new Set(idx.map((f) => String((f && f.url) || '')).filter(Boolean))
for (const r of (results || [])) {
if (!r || !r.ok || !r.url) continue
const _u2 = String(r.url)
if (_seen2.has(_u2)) continue
_seen2.add(_u2)
const name = 'gen_' + Date.now() + '_' + Math.floor(Math.random() * 1e6) + '.png'
idx.push({ name, url: r.url, size: 0, mtime: Date.now(), w: r.width || 0, h: r.height || 0, label: r.label || '', snapshot: r.snapshot || null, orig: 'pending' })
added.push(name)
@@ -2110,16 +2301,9 @@ try { if (window.IWBMiniMapFit && typeof window.IWBMiniMapFit.install === 'funct
// 保留策略剪掉的条目:连同缩略图+原图一并移除(Plan A 整体删除,不留孤儿原图)
const removedNames = idx.filter((f) => !keptNames.has(f.name)).map((f) => f.name)
if (removedNames.length) wPruneOutputIdb(removedNames)
const needThumb2 = idx.filter((f) => keptNames.has(f.name) && !f.idb)
if (needThumb2.length) {
const thumbJob2 = runWithConcurrency(needThumb2, 5, (f) => storeOutputThumb(f))
const onThumbFail2 = (e) => {
// 同上:整批失败原先零反馈(用户只看到图库空白,不知道原因)
try { if (CrashLog && typeof CrashLog.record === 'function') CrashLog.record('thumb-batch-failed', { scope: 'output-store', message: '缩略图批量生成失败(' + needThumb2.length + ' 张):' + String((e && e.message) || e), version: APP_VERSION }) } catch (err) { /* ignore */ }
wLogNotice('部分图片的缩略图生成失败(' + needThumb2.length + ' 张),图库中可能显示为空白。', 'err')
}
if (awaitArchive) { try { await thumbJob2 } catch (e) { onThumbFail2(e) } } else thumbJob2.catch(onThumbFail2)
}
// 同上:只补本次新增、且还没有缩略图的;有落地队列时一律从本地字节生成(不重复抓远程)
const ingOn2 = !!(typeof window !== 'undefined' && window.IWBImageIngestView)
for (const f of idx) if (keptNames.has(f.name) && !f.idb && added.indexOf(f.name) >= 0) { if (ingOn2) wFillOutputFromIngest(f); else storeOutputThumb(f).catch(() => {}) }
for (const f of idx) {
if (keptNames.has(f.name) && imageFolderApi) imageFolderApi.save(f, f.data).catch(() => {})
}
@@ -2281,6 +2465,9 @@ try { if (window.IWBMiniMapFit && typeof window.IWBMiniMapFit.install === 'funct
async function wResolveOutputSrc(item, localFirst) {
if (!item) return ''
if (item.origIdb) { const v = await IDB.get(item.origIdb).catch(() => null); if (v) return v }
// 2026-12-03(用户裁定「统一本地优先」):老记录原图在 images/gallery 文件里,先读本地字节,再谈远程。
const FL = wStoreMod()
if (FL && typeof FL.galleryOriginalBlob === 'function') { try { const b = await FL.galleryOriginalBlob(item); if (b && b.size) return wRegisterBlobUrl(b) } catch (e) { /* ignore */ } }
// C3 第2步:物品的 data 可能是引用形态({__cache}/{__blob}/{__idb})——调用方要的是能直接用的字节/dataURL,
// 这里按需解析(不写回物品、不留驻);远程 URL 仍只作最后回退。
const localData = (item.data && typeof item.data === 'object') ? await wImgRefDataUrl(item.data) : item.data
@@ -2291,6 +2478,22 @@ try { if (window.IWBMiniMapFit && typeof window.IWBMiniMapFit.install === 'funct
if (item.idb) { const v = await IDB.get(item.idb).catch(() => null); if (v) return v }
return ''
}
// 2026-12-03(用户):输出节点双击预览与图库同一口径 —— 有图库行就给 __gallery 条目
// (origIdb / idb / 缩略图),由 ImagePreview 按「本地原图 → 磁盘原图」解析;没有行才退回裸 url。
function wPreviewEntryOf (url) {
try {
const u = String(url || '')
if (!u) return ''
const row = (lsGet(OUT_KEY, []) || []).find((f) => f && String(f.url) === u)
if (!row || !row.name) return u
return { __gallery: true, name: String(row.name), origIdb: row.origIdb, idb: row.idb, url: '', thumb: row.data || null }
} catch (e) { return url }
}
// 2026-12-03(下载命名规范):同一张图,不论从输出节点、预览还是图库下载,都用图库行名。
// 未落地的图没有行名,调用方回退自己的默认名。
function wOutNameOf (url) {
try { const u = String(url || ''); if (!u) return ''; const row = (lsGet(OUT_KEY, []) || []).find((f) => f && String(f.url) === u); return (row && row.name) ? String(row.name) : '' } catch (e) { return '' }
}
// 图库条目 → 可直接交给 <img>/下载/剪贴板的 src:命中「有界 objectURL 缓存」即复用,
// 避免每次点击都把 2MB+ base64 重新读进堆(驱逐时统一 revoke)。
async function wOutputSrcForUse(item, cacheKey, localFirst) {
@@ -3519,6 +3722,7 @@ try { if (window.IWBMiniMapFit && typeof window.IWBMiniMapFit.install === 'funct
settings: '<path d="M12.22 2h-.44a2 2 0 0 0-2 2v.18a2 2 0 0 1-1 1.73l-.43.25a2 2 0 0 1-2 0l-.15-.08a2 2 0 0 0-2.73.73l-.22.38a2 2 0 0 0 .73 2.73l.15.1a2 2 0 0 1 1 1.72v.51a2 2 0 0 1-1 1.74l-.15.09a2 2 0 0 0-.73 2.73l.22.38a2 2 0 0 0 2.73.73l.15-.08a2 2 0 0 1 2 0l.43.25a2 2 0 0 1 1 1.73V20a2 2 0 0 0 2 2h.44a2 2 0 0 0 2-2v-.18a2 2 0 0 1 1-1.73l.43-.25a2 2 0 0 1 2 0l.15.08a2 2 0 0 0 2.73-.73l.22-.39a2 2 0 0 0-.73-2.73l-.15-.08a2 2 0 0 1-1-1.74v-.5a2 2 0 0 1 1-1.74l.15-.09a2 2 0 0 0 .73-2.73l-.22-.38a2 2 0 0 0-2.73-.73l-.15.08a2 2 0 0 1-2 0l-.43-.25a2 2 0 0 1-1-1.73V4a2 2 0 0 0-2-2z"/><circle cx="12" cy="12" r="3"/>',
help: '<circle cx="12" cy="12" r="10"/><path d="M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3"/><path d="M12 17h.01"/>',
download: '<path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"/><polyline points="7 10 12 15 17 10"/><line x1="12" x2="12" y1="15" y2="3"/>',
queue: '<path d="M8 6h13M8 12h13M8 18h13"/><circle cx="3.5" cy="6" r="1"/><circle cx="3.5" cy="12" r="1"/><circle cx="3.5" cy="18" r="1"/>',
upload: '<path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"/><polyline points="17 8 12 3 7 8"/><line x1="12" x2="12" y1="3" y2="15"/>',
save: '<path d="M19 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h11l5 5v11a2 2 0 0 1-2 2z"/><polyline points="17 21 17 13 7 13 7 21"/><polyline points="7 3 7 8 15 8"/>',
github: '<path d="M15 22v-4a4.8 4.8 0 0 0-1-3.5c3 0 6-2 6-5.5.08-1.25-.27-2.48-1-3.5.28-1.15.28-2.35 0-3.5 0 0-1 0-3 1.5-2.64-.5-5.36-.5-8 0C6 2 5 2 5 2c-.3 1.15-.3 2.35 0 3.5A5.403 5.403 0 0 0 4 9c0 3.5 3 5.5 6 5.5-.39.49-.68 1.05-.85 1.65-.17.6-.22 1.23-.15 1.85v4"/><path d="M9 18c-4.51 2-5-2-7-2"/>',
@@ -3830,8 +4034,13 @@ try { if (window.IWBMiniMapFit && typeof window.IWBMiniMapFit.install === 'funct
function upsertGenerationEntry(entries, entry) {
const list = Array.isArray(entries) ? entries : []
if (!entry) return list.slice()
const prev = list.find((x) => x && x.promptId === entry.promptId && x.vi === entry.vi)
const keep = list.filter((x) => !(x && x.promptId === entry.promptId && x.vi === entry.vi))
return keep.concat([entry])
// 2026-12-02(方案 A:先落地再显示):新图下载期间保留上一张作为 pending,
// 输出格先继续显示旧图,等新图本地字节就绪再整体替换 —— 中间不再出现白板。
const prevItems = prev && Array.isArray(prev.items) ? prev.items.filter((it) => it && it.ok && it.url) : []
const next = prevItems.length ? Object.assign({}, entry, { pending: { items: prevItems, at: Number(prev.at) || 0 } }) : entry
return keep.concat([next])
}
// 将任务条目展平为图库结果:统一标签,不修改输入数据。
@@ -3846,22 +4055,43 @@ try { if (window.IWBMiniMapFit && typeof window.IWBMiniMapFit.install === 'funct
// 生成归档边界:图库索引/缩略图属于旁路缓存,不能阻塞生成结果和画布保存。
// v3.26.61:每张结果在生成过程中已由 wArchiveEntryNow 逐张入库(图库要「出图即见」),
// 这里只补剩下没归档的(失败条目/兜底路径),不再整批重写一遍 —— 否则同一张图会入两次库。
async function archiveGenerationResults(entries, refresh) {
async function archiveGenerationResults(entries, refresh, meta) {
const all = Array.isArray(entries) ? entries : []
const results = flattenGenerationEntries(all)
// 先入落地队列(不等下载完):节点先显示远程,就绪后换成 localUrl;失败保留 url 可重试
// meta:兜底入队(分层/非 liveUpsert 路径)也要带画布/节点,否则任务队列显示「未知画布」、无法定位。
try { if (window.__iwbIngest) for (const r of results) if (r && r.ok && r.url) window.__iwbIngest.enqueue({ url: r.url, source: 'gen', w: r.width, h: r.height, meta: Object.assign({}, meta || {}, { prompt: String((r && r.label) || (meta && meta.prompt) || '') }) }) } catch (eI) { /* 落地失败不得影响出图 */ }
iwbDebugCounter('archiveGenerationResults', { entries: results.length })
const pendingEntries = all.filter((e) => !(wGallerySync && wGallerySync.wasArchived(e)))
for (const hook of wPluginGenHooks) {
if (typeof hook.afterResult !== 'function') continue
try { hook.afterResult(results) } catch (e) { /* 插件钩子异常不得影响结果归档 */ }
}
// 归档 → 刷新 → 自动下载串行:自动下载必须等本批原图写进图库(out_orig_)后再跑,才谈得上「从本地字节复制」。
Promise.resolve().then(async () => {
// 2026-12-03:先把单张归档队列排空,再判断补漏 —— 否则最后一张的索引还在写,会被误判成
// 「未归档」再 add 一次,同一 url 出现两行(图库重复卡 + Gallery 重复文件)。
try { if (wGallerySync && typeof wGallerySync.whenIdle === 'function') await wGallerySync.whenIdle() } catch (eW) { /* ignore */ }
// 2026-12-02:wasArchived 是按「条目对象」记的,单张归档路径标记后,批量归档会整批跳过 ——
// 于是「一次出 2 张,图库只进 1 张」。这里加一道校验:已标记归档但图库索引里查不到该 url 的,仍然补。
const _idxNow = lsGet(OUT_KEY, []) || []
const _urlInIdx = new Set(_idxNow.map((f) => String((f && f.url) || '')))
const pendingEntries = all.filter((e) => {
const archived = !!(wGallerySync && wGallerySync.wasArchived(e))
if (!archived) return true
// 条目形状是 {promptId,vi,label,items:[{ok,url}]},**没有 e.url** —— 必须下沉到 item 级取 url。
// 只要有任一 item 的 url 不在图库索引里才补;全都在索引里就跳过(否则会重复入库)。
const urls = flattenGenerationEntries([e]).map((i) => String((i && i.url) || '')).filter(Boolean)
if (!urls.length) return false
return urls.some((u) => !_urlInIdx.has(u))
})
try { wIngestLog('archive entries=' + all.length + ' pending=' + pendingEntries.length) } catch (eL1) { /* ignore */ }
// 只有「自动下载」开启时才等归档完成:它要从本地原图复制,必须等 out_orig_ 落盘;
// 没开就保持后台异步归档,避免出图到图库可点开的时间被拖长。
const needArchiveWait = !!(wAutoSaver && typeof wAutoSaver.enabled === 'function' && wAutoSaver.enabled())
const rest = flattenGenerationEntries(pendingEntries)
if (rest.length) { try { await wAddOutputs(rest, { awaitArchive: needArchiveWait }) } catch (e) { /* 图库缓存失败不影响画布结果 */ } }
try { wIngestOrigBackfill(rest) } catch (eBk) { /* 回填不影响出图 */ }
try { wDedupeOutputs() } catch (eDd) { /* 去重失败不影响出图 */ }
try { if (typeof refresh === 'function') await refresh() } catch (e) { /* ignore */ }
try { wGalleryChanged('output') } catch (e) { /* ignore */ }
try { if (wAutoSaver) await wAutoSaver.saveResults(results) } catch (e) { /* 自动下载失败不影响生图 */ }
@@ -5506,10 +5736,11 @@ const tbCenterSeed = (type, refs) => {
try {
IWNodeBodies.inject({ el, I, LocalTextField, autoGrow, nodePreviewRefsV2, nodeInheritOf, combineSourcePairs, isPluginTypeId,
orderedUniqueRefNodes, uploadRefToImageHost, wDisplayThumbOf, wImgSrcForNode, wImportImage, wPreviewUrlOf, wRawCfg, wResolveImg,
wThumbSrc, downloadUrl, wResolveOutputSrc, isImageProducer, outProgUI, outThumbCache,
wThumbSrc, downloadUrl, wResolveOutputSrc, wOutNameOf, wPreviewEntryOf, isImageProducer, outProgUI, outThumbCache,
ingestView: () => window.IWBImageIngestView,
wPluginNodeVariants, wPluginVariantMeta, isBatchSrc, batchSrcText, compareCanvasTextOrder,
GenParams, RATIOS, RES_KEYS, RES_MAP, cachedGenerationTasks, classifyErr, fmtDur, presetDisplayName,
ratioOfSize, resOfSize, taskStallEndMs, wDedupeTaskIds, React, ReactDOM })
ratioOfSize, resOfSize, taskStallEndMs, wDedupeTaskIds, React, ReactDOM, wThumbBump: () => { try { if (typeof wThumbBump === 'function') wThumbBump() } catch (e) { /* ignore */ } } })
IWNodeBodies.__iwbInjected = true
} catch (e) { /* 注入失败:继续用内置分支 */ }
}
@@ -5909,12 +6140,28 @@ const tbCenterSeed = (type, refs) => {
// 快捷键弹窗内容(分区罗列 + 折叠说明)
const HotkeyHelp = (typeof window !== 'undefined' && window.IWBUIHotkeyHelp) ? window.IWBUIHotkeyHelp.HotkeyHelp : null
// 插件整页(复用设置里的插件管理块;页面壳在 src/ui-plugin-page.js)
// 插件整页容器(pages 能力):把 host DOM 交给插件 mount,离开/禁用时清理。
const PluginPageHost = (props) => {
const page = props && props.page
const hostRef = React.useRef(null)
React.useEffect(() => {
const host = hostRef.current
if (!host || !page || typeof page.mount !== 'function') return undefined
let cleanup = null
try { cleanup = page.mount(host) } catch (e) { try { host.textContent = '插件页面加载失败:' + String((e && e.message) || e) } catch (e2) { /* ignore */ } }
return () => { try { if (typeof cleanup === 'function') cleanup(); else host.innerHTML = '' } catch (e) { /* ignore */ } }
}, [page])
return el('div', { className: 'iwb-plugin-page iwb-plugin-page-custom' },
el('div', { className: 'iwb-plugin-page-head' }, el('span', { className: 'iwb-plugin-page-title' }, (page && page.title) || '任务队列')),
el('div', { className: 'iwb-plugin-page-body', ref: hostRef }),
)
}
const PluginsPage = (typeof window !== 'undefined') ? window.IWBUIPluginPage : null
// 依赖注入点:放在 Workbench 之前 —— 此处 ICONS / computeEdgePath / downloadUrl / IDB 等全部已定义。
_mod.inject({
ICONS, IDB, computeEdgePath, copyImageToClipboard, downloadUrl,
ICONS, IDB, computeEdgePath, copyImageToClipboard, downloadUrl, wOutNameOf,
nodeTypeColor, nodeTypeH, nodeWidth, wBlobFromDataUrl, wRegisterBlobUrl,
})
@@ -5981,11 +6228,6 @@ const tbCenterSeed = (type, refs) => {
} catch (e) { return '' }
}
// 覆盖式替换图片前备份原图:优先保留已有 orig,其次 data,最后 url。返回 updateNode patch。
function origImagePatch(prev, dataUrl) {
const orig = (prev && prev.orig) || (prev && typeof prev.data === 'string' && /^data:/i.test(prev.data) ? prev.data : '') || (prev && typeof prev.url === 'string' ? prev.url : '')
return orig ? { data: String(dataUrl), url: '', orig } : { data: String(dataUrl), url: '' }
}
function Workbench() {
// runtime-workbench-logic 模块的 app.js 模块级依赖:渲染前注入一次(常量/纯函数,无陈旧值风险)
if (IWWorkbenchLogic && !IWWorkbenchLogic.__iwbInjected) {
@@ -6125,64 +6367,120 @@ const tbCenterSeed = (type, refs) => {
return PluginHost.on(() => setPluginRev((v) => v + 1))
}, [])
React.useEffect(() => {
wPluginCanvasBridge = {
getNodes: () => refs.nodes.map((n) => ({ id: n.id, type: n.type, x: n.x, y: n.y, data: n.data || {} })),
getSelectedNode: () => {
const id = selRef.current && selRef.current[0]
const n = id ? refs.nodes.find((x) => x.id === id) : null
return n ? { id: n.id, type: n.type, name: String((n.data && (n.data.name || n.data.title)) || '') } : null
},
// v3.26.61:逻辑在 src/gallery-sync.js 的 nodeImageOf(补 localRef 候选 + 远程按需落地)
getNodeImage: async (id, opts) => {
const n = refs.nodes.find((x) => x.id === id)
if (!n || !wGallerySync) return null
const img = await wGallerySync.nodeImageOf(n, { writeRef: (src) => wImgRefWrite(src), onLocalRef: (ref) => updateNode(n.id, { localRef: ref }) })
// v3.26.124:插件只要能看/能预览时,给**缩过的**图,别让它整幅解码原图
const max = Math.max(64, Number(opts && opts.max) || 0)
if (!img || !max) return img
// 201:把「重读 outputs」暴露给模块级的落地回填(它改完索引后要让图库状态刷新,
// storage 事件在本文档不触发、BroadcastChannel 也不回送自己,只能走这个回调)
try { if (typeof window !== 'undefined') window.__iwbRefreshOutputs = () => { try { refreshOutputs(100) } catch (e) { /* ignore */ } } } catch (e0) { /* ignore */ }
return () => { try { if (typeof window !== 'undefined') window.__iwbRefreshOutputs = null } catch (e1) { /* ignore */ } }
}, [])
React.useEffect(() => {
// 插件画布桥 + 图片写回收口(v3.26.183 收口,2026-12-02 拆到 src/plugin-canvas-bridge.js)
// 这里只装配依赖:引用化统一走 wImportImage(keepOriginal),阈值共用 IMPORT_INLINE_MAX。
const built = (window.IWBPluginCanvasBridge && typeof window.IWBPluginCanvasBridge.create === 'function')
? window.IWBPluginCanvasBridge.create({
refs,
selRef,
updateNode,
commitCanvas,
saveNow,
findSpot,
placeAtDrop,
addPluginNode,
uid,
cloneNodeDefaults,
NODE_TYPES,
CanvasGeometry,
readWorkspace: () => WorkspaceStore.read(null),
activeWsId: () => activeWsIdRef.current || activeWsId,
inlineMax: IMPORT_INLINE_MAX,
importer: (dataUrl) => new Promise((resolve) => { try { wImportImage(String(dataUrl), { keepOriginal: true }, resolve) } catch (e) { resolve(null) } }),
invalidate: (v) => { try { const k = wDisplayThumbKeyOf(v); if (k) { displayThumbs.delete(k); displayThumbsSm.delete(k) } } catch (e) { /* ignore */ } },
bump: () => { try { if (typeof wThumbBump === 'function') wThumbBump() } catch (e) { /* ignore */ } },
resolveRef: (v) => wImgRefDataUrl(v),
showToast,
gallerySync: wGallerySync,
imgRefWrite: wImgRefWrite,
ensureTier: wEnsureTier,
pluginPreview: wPluginPreview,
shrinkDataUrl: wShrinkDataUrl,
imageWritebackFactory: window.IWBImageWriteback,
log: (line) => {
try { const SF = window.IWBStorageFile; if (SF && typeof SF.logLine === 'function') SF.logLine(line) } catch (e) { /* ignore */ }
try { wLog('plugin-img', line) } catch (e) { /* ignore */ }
},
})
: null
wPluginCanvasBridge = built ? built.bridge : null
wImageWriteback = built ? built.writeback : null
return () => { wPluginCanvasBridge = null; wImageWriteback = null }
}, [])
// 结果落地队列(2026-12-02):出图后后台把远程图下到本地,节点/图库不再直连 CDN。
React.useEffect(() => {
if (!window.IWBImageIngest || !window.IWBImageIngestStore) return undefined
const store = window.IWBImageIngestStore.createStore({ get: (k) => lsGet(k, null), set: (k, v) => lsSet(k, v), max: () => { try { return Number(wRawCfg().canvas.taskQueueMax) || 500 } catch (e) { return 500 } } })
window.__iwbIngestStore = store
const view = window.IWBImageIngestStore.createView()
window.IWBImageIngestView = view
const ing = window.IWBImageIngest.create({
// 2026-12-02(方案 A):取字节 = 流式下载(带百分比)+ 超时 + 回退既有 wBlobFromSrc;实现在 src/image-ingest.js
// 2026-12-03:下载优先走系统网络栈(Rust reqwest,不受 CORS/WebView 限制);失败再回退 WebView fetch。
fetchBytes: window.IWBImageIngest.createFetchBytes({ blobFromSrc: wBlobFromSrc, blobToDataUrl: wImgBlobToDataUrl, rustFetch: (u) => (wTauri && wTauri.core && typeof wTauri.core.invoke === 'function') ? wTauri.core.invoke('fetch_image_b64', { url: String(u), referer: null }) : Promise.reject(new Error('no-rust-http')) }),
// 并发数走设置(通用 → 同时下载),默认 30;改设置后下一轮 pump 立即生效。
getConcurrency: () => { try { return Math.max(1, Math.min(64, Number(wRawCfg().canvas.downloadConcurrency) || 30)) } catch (e) { return 30 } },
writeRef: (dataUrl) => wImgRefWrite(dataUrl),
persist: (e) => store.save(e),
removeEntry: (id) => store.remove(id),
onEvent: (kind, e) => {
const patch = Object.assign({}, e)
try { if (window.IWBPluginQueue) window.IWBPluginQueue.emit(kind) } catch (eQ) { /* ignore */ }
if (e && e.ref) {
try { patch.localUrl = wResolveImg(e.ref) || '' } catch (err) { patch.localUrl = '' }
// 首次 ready 时 objectURL 可能还没建好:异步解析完成后再补一次视图,确保节点真的切到本地
try { Promise.resolve(wResolveImgAsync(e.ref)).then((u) => { if (u) { view.set(Object.assign({}, e, { localUrl: u })); view.notify(); try { if (typeof wThumbBump === 'function') wThumbBump() } catch (eB2) { /* ignore */ } } }).catch(() => {}) } catch (err2) { /* ignore */ }
}
try {
const src = img.localRef || img.url || img.dataUrl
if (src && typeof src === 'object') { const t = await wEnsureTier(src, max); if (t) { const d = await wPluginPreview(src, { max }); if (d && d.ok) return Object.assign({}, img, { dataUrl: d.dataUrl, capped: max }) } }
else if (typeof src === 'string' && src.indexOf('data:') === 0) { const s2 = await wShrinkDataUrl(src, max); if (s2) return Object.assign({}, img, { dataUrl: s2, capped: max }) }
} catch (e) { /* ignore */ }
return img
if (kind === 'queued') wIngestLog('enqueue id=' + e.id + ' url=' + String(e.url || '').slice(0, 60))
else if (kind === 'failed') wIngestLog('failed id=' + e.id + ' err=' + String(e.lastError || '-') + ' retries=' + (e.retries || 0) + ' url=' + String(e.url || '').slice(0, 60))
else if (kind === 'ready') wIngestLog('ready id=' + e.id + ' ref=' + (e.ref ? 'Y' : 'N'))
} catch (eL0) { /* ignore */ }
view.set(patch); view.notify()
try { if (typeof wThumbBump === 'function') wThumbBump() } catch (eB) { /* 触发画布节点体重绘 */ }
// 195:落地成功就把**原图**写进图库(images/gallery/,key=out_orig_<name>)并把索引 orig 置 ok。
// 用本机已有字节,不再二次抓 CDN;失败保持 pending,由原来的抓取路径兜底。
try {
if (kind === 'ready' && e && e.ref) {
// 207:原来是「索引没命中就静默 return」—— 落地变快后 ready 常早于索引写入,
// 于是整批图静默不落库(用户实测 4/16 张)。改成:未命中延迟重试 1s / 3s,并留痕。
const tryOnce = (attempt) => {
const idx = lsGet(OUT_KEY, []) || []
const hit = idx.find((f) => f && String(f.url || '') === String(e.url || ''))
if (hit) {
if (hit.orig !== 'ok' && !hit.origIdb && typeof storeOutputThumb === 'function') {
try { wIngestOrigFromRef(hit.name, hit.url, e.ref) } catch (e5) { /* ignore */ }
}
return true
}
try { wIngestLog('orig-defer url=' + String(e.url || '').slice(0, 60) + ' attempt=' + attempt) } catch (e6) { /* ignore */ }
return false
}
if (!tryOnce(1)) {
setTimeout(() => { if (!tryOnce(2)) setTimeout(() => { tryOnce(3) }, 3000) }, 1000)
}
}
} catch (eG) { /* 图库写入不得影响出图 */ }
},
createNode: (type, x, y, data) => {
// 插件节点传的是变体 id(web/style…):不在 NODE_TYPES 里,交给 addPluginNode 拼出 plugin:<插件>:<变体>
if (!NODE_TYPES.has(type)) return addPluginNode(type, x, y, data) || null
const spot = (CanvasGeometry && CanvasGeometry.wantsDefaultSpot(x, y)) ? findSpot(type) : placeAtDrop(type, x, y)
const node = { id: uid('n'), type, x: spot.x, y: spot.y, data: Object.assign({}, cloneNodeDefaults(type), data || {}) }
commitCanvas(refs.nodes.concat([node]), undefined, undefined)
return node.id
},
// 屏幕坐标 → 世界坐标:供插件「按住按钮拖到画布上松手」建节点(2026-11-02)。
// 读 .iwb-world 的实时 transform 与 .iwb-canvas 的 rect —— 与 tbCenterSeed 同一套口径,
// 不用 refs.viewport(渲染落后一拍时换算会偏)。换算本身是纯函数,在 canvas-geometry。
screenToWorld: (clientX, clientY) => {
const c = document.querySelector('.iwb-canvas')
if (!c || !c.clientWidth) return null
const wl = document.querySelector('.iwb-world')
const t = (CanvasGeometry && CanvasGeometry.parseWorldTransform) ? CanvasGeometry.parseWorldTransform(wl && wl.style ? wl.style.transform : '') : null
return CanvasGeometry.clientToWorld(clientX, clientY, c.getBoundingClientRect(), t || refs.viewport)
},
createImageNode: (payload) => {
const src = payload && payload.dataUrl
if (!src || !/^data:/i.test(String(src))) return null
const at = payload || {}
// 与 createNode 同一套坐标语义:给了有限坐标就用它(拖拽松手点,压住节点时就近吸附),否则走 findSpot 找位
const spot = (CanvasGeometry && CanvasGeometry.wantsDefaultSpot(at.x, at.y)) ? findSpot('ref') : placeAtDrop('ref', at.x, at.y)
const node = { id: uid('n'), type: 'ref', x: spot.x, y: spot.y, data: { url: '', data: String(src), name: String((payload && payload.name) || 'plugin.png'), localName: null } }
commitCanvas(refs.nodes.concat([node]), undefined, undefined)
return node.id
},
setNodeImage: (id, dataUrl) => {
if (!/^data:/i.test(String(dataUrl || ''))) return false
const t = refs.nodes.find((x) => x.id === id); if (!t) return false
updateNode(id, origImagePatch(t.data || {}, String(dataUrl))); return true
},
saveNodeImage: (id, dataUrl) => (IWWorkbenchLogic ? IWWorkbenchLogic.saveNodeImage({ refs, commitCanvas, saveNow, readWorkspace: () => WorkspaceStore.read(null), activeWsId: () => activeWsIdRef.current || activeWsId, origPatch: origImagePatch }, id, dataUrl) : Promise.resolve({ ok: false, error: '画布能力未就绪' })),
}
return () => { wPluginCanvasBridge = null }
})
window.__iwbIngest = ing
const saved = store.load()
view.hydrate(saved)
ing.restore(saved)
try { store.trim() } catch (eTrim) { /* 上限收紧后启动即裁剪 */ }
// 启动先对一次账,之后每 30s 一次(幂等;不阻塞启动)
try { setTimeout(() => { try { wDedupeOutputs() } catch (eD0) { /* ignore */ } try { wIngestReconcile() } catch (eR0) { /* ignore */ } }, 3000) } catch (eR1) { /* ignore */ }
// 2026-12-02:不做常驻轮询(用户要求不占空闲 CPU)。改成「窗口重新获得焦点时」跑一次:
// 用户切回来通常就是「图该出来了」的时刻,成本与操作频率同阶,闲置时零开销。
const onFocusReconcile = () => { try { wIngestReconcile() } catch (eR2) { /* ignore */ } }
try { window.addEventListener('focus', onFocusReconcile) } catch (eR3) { /* ignore */ }
return () => { window.__iwbIngest = null; window.__iwbIngestStore = null; try { window.removeEventListener('focus', onFocusReconcile) } catch (eR4) { /* ignore */ } }
}, [])
const [layoutLocked, setLayoutLocked] = useState(false)
const [wsMoreOpen, setWsMoreOpen] = useState(false) // 顶部 ⋯ 三点菜单(展开态)
@@ -6310,6 +6608,13 @@ const tbCenterSeed = (type, refs) => {
return () => { try { delete window.__IWB_E2E_HISTORY__; delete window.__IWB_E2E_CANVAS__; delete window.__IWB_E2E_SETREF__; delete window.__IWB_E2E_PUSH_HISTORY__ } catch (e) { /* ignore */ } }
}, [])
const [shellView, setShellView] = useState(() => { try { return lsRawGet('iwb_shell_view', null) === 'canvas' ? 'canvas' : 'home' } catch (e) { return 'home' } }) // landing=首页说明,home=我的画布,canvas=无限画布;刷新时恢复上次所在的视图
const [pluginPage, setPluginPage] = useState(null) // 插件整页:{pluginId,pageId};仅 pages 能力注册的页面
// 插件被禁用/页面被移除时,若正停在该页,回到画布(避免空白页)
React.useEffect(() => {
if (!pluginPage) return
const ok = wPluginPages.some((p) => p.pluginId === pluginPage.pluginId && p.id === pluginPage.pageId)
if (!ok) { setPluginPage(null); setShellView('canvas') }
}, [pluginRev, pluginPage])
// 记住当前视图;刷新后在画布编辑器则恢复到画布编辑器(画布库则仍回画布库)
useEffect(() => { try { lsRawSet('iwb_shell_view', shellView) } catch (e) { /* ignore */ } }, [shellView])
const [homeSelectedWs, setHomeSelectedWs] = useState([])
@@ -7651,6 +7956,7 @@ const tbCenterSeed = (type, refs) => {
const tick = () => {
if (!alive) return
if (typeof document !== 'undefined' && document.hidden) { timer = setTimeout(tick, 8000); return }
if (lsGet('iwb_diag_off', false)) { timer = setTimeout(tick, 30000); return }
Promise.resolve().then(() => {
const T = (typeof window !== 'undefined') ? window.__TAURI__ : null
const inv = T && T.core && T.core.invoke
@@ -7893,7 +8199,7 @@ const tbCenterSeed = (type, refs) => {
setWsMorePos,
setWsMoreOpen,
})
: (shellView === 'plugins' ? null : el(ProductNav, { shellView, setShellView, setSettingOpen: openSettings, setHelpOpen, toggleTheme, theme }))
: ((shellView === 'plugins' || shellView === 'page') ? null : el(ProductNav, { shellView, setShellView, setSettingOpen: openSettings, setHelpOpen, toggleTheme, theme }))
// 底栏工具栏:稳定动作(useCallback 读 refs/selRef) + 派生状态(拖拽时不变化) → React.memo 跳过重渲,缩小拖拽 re-render 范围
// 工具栏编组/取消编组按钮已移除;多选节点组气泡的禁用态直接用 sel / groupOf 判定,故不再需要派生 canGroup/canUngroup。
const tbOnAdd = React.useCallback((t) => addNode(t, null, null, tbCenterSeed(t, refs)), [])
@@ -7959,10 +8265,20 @@ const tbCenterSeed = (type, refs) => {
})
}
if (window.IWBPluginGallery) window.IWBPluginGallery.setImpl({
list: (o) => window.IWBPluginGallery.query(outputs, o),
list: (o) => { try { wGalleryRepair() } catch (eRp) { /* ignore */ } return window.IWBPluginGallery.query(outputs, o) },
// v3.26.61:缩略图取源顺序(清单 data → images/thumbs → 本地原图 → 远程)在 gallery-sync 里,
// 原因是「生图后图库不显示」有一半出在这里 —— 新图 data 还没 hydrate 就只剩远程 url 可退。
thumb: (name) => (wGallerySync ? wGallerySync.thumbFor(name, { outputs, displayThumbOf: wDisplayThumbOf, galleryThumb: (h) => { const F = (typeof window !== 'undefined') ? window.IWBStorageFile : null; return (F && typeof F.galleryThumb === 'function') ? F.galleryThumb(h) : Promise.resolve('') }, galleryThumbUrl: (h) => { const F = (typeof window !== 'undefined') ? window.IWBStorageFile : null; return (F && typeof F.galleryThumbUrl === 'function') ? F.galleryThumbUrl(h) : Promise.resolve('') }, galleryThumbOf: (f, max) => { const F = (typeof window !== 'undefined') ? window.IWBStorageFile : null; return (F && typeof F.galleryThumbOfEntry === 'function') ? F.galleryThumbOfEntry(f, max) : Promise.resolve('') } }) : ''),
thumb: (name) => (wGallerySync ? wGallerySync.thumbFor(name, { outputs, displayThumbOf: wDisplayThumbOf, galleryThumb: (h) => { const F = (typeof window !== 'undefined') ? window.IWBStorageFile : null; return (F && typeof F.galleryThumb === 'function') ? F.galleryThumb(h) : Promise.resolve('') }, galleryThumbUrl: (h) => { const F = (typeof window !== 'undefined') ? window.IWBStorageFile : null; return (F && typeof F.galleryThumbUrl === 'function') ? F.galleryThumbUrl(h) : Promise.resolve('') }, galleryThumbOf: (f, max) => {
// 2026-12-02:图库缩略图优先用落地队列拿到的**本地副本**,别再为同一张图去 fetch 远程。
// 未落地(无 localUrl)时行为不变,回落原来的 f.url。
let ff = f
try {
const v = window.IWBImageIngestView && typeof window.IWBImageIngestView.get === 'function' ? window.IWBImageIngestView.get(f && f.url) : null
if (v && v.localUrl) ff = Object.assign({}, f, { url: v.localUrl })
} catch (eIng) { /* ignore */ }
const F = (typeof window !== 'undefined') ? window.IWBStorageFile : null
return (F && typeof F.galleryThumbOfEntry === 'function') ? F.galleryThumbOfEntry(ff, max) : Promise.resolve('')
} }) : ''),
preview: (name) => setPreview({ list: outputs.map((x) => ({ __gallery: true, name: x.name, origIdb: x.origIdb, idb: x.idb, url: x.url, thumb: x.data || null })), idx: Math.max(0, outputs.findIndex((x) => x.name === name)) }),
download: async (names) => {
const failed = []
@@ -7981,6 +8297,143 @@ const tbCenterSeed = (type, refs) => {
insert: async (names, o) => ({ ok: true, inserted: await insertOutputsToCanvas((outputs || []).filter((f) => names.indexOf(f.name) >= 0), (o && o.insertK) || '1k') }),
remove: async (names) => { const n = await deleteOutputs(names); return { ok: n > 0, removed: n } }, openFolder: () => window.IWBDesktopHelpers.openGalleryDir(), backfill: (names) => { const want = Array.isArray(names) ? names : []; const hits = (outputs || []).filter((f) => want.indexOf(f.name) >= 0); return Promise.all(hits.map((f) => storeOutputThumb(f, true))).then((rs) => ({ ok: rs.filter(Boolean).length, count: rs.filter(Boolean).length, failed: hits.filter((f, i) => !rs[i]).map((f) => f.name) })) },
})
// 任务队列插件(queue):账本/下载/落地/定位/上限全部在宿主,插件只做视图。
if (window.IWBPluginQueue) {
const qList = () => { try { return window.__iwbIngest ? window.__iwbIngest.list() : [] } catch (e) { return [] } }
const qEntry = (id) => qList().find((x) => x.id === id) || null
const qView = (url) => { try { return (window.IWBImageIngestView && typeof window.IWBImageIngestView.get === 'function') ? window.IWBImageIngestView.get(url) : null } catch (e) { return null } }
const qMapStatus = (s) => s === 'ready' ? 'ok' : (s === 'failed' ? 'fail' : ((s === 'queued' || s === 'downloading') ? 'down' : 'only'))
window.IWBPluginQueue.setImpl({
list: async (o) => {
const opt = o || {}
const want = String(opt.status || '')
const limit = Math.max(1, Math.min(5000, Number(opt.limit) || 500))
const q = String(opt.query || '').toLowerCase()
const idxNow = lsGet(OUT_KEY, []) || []
let items = qList().map((e) => {
const v = qView(e.url)
const meta = e.meta || {}
return {
id: e.id, url: e.url, status: e.status, kind: qMapStatus(e.status),
progress: Number(e.progress) || 0, bytes: Number(e.bytes) || 0,
w: Number(e.w) || 0, h: Number(e.h) || 0, error: String(e.lastError || ''),
retries: Number(e.retries) || 0, createdAt: Number(e.createdAt) || 0, updatedAt: Number(e.updatedAt) || 0,
meta,
thumbUrl: (wQueueThumbCache.get(e.url) || outThumbCache.get(e.url) || ''),
localUrl: (v && v.localUrl) ? v.localUrl : '',
inGallery: (() => { const row = idxNow.find((f) => f && String(f.url) === String(e.url)); return !!(row && (row.orig === 'ok' || row.origIdb)) })(),
}
})
if (want && want !== 'all') items = items.filter((x) => x.kind === want)
if (q) items = items.filter((x) => (String(x.meta.prompt || '') + ' ' + String(x.meta.boardName || '') + ' ' + String(x.url || '')).toLowerCase().indexOf(q) >= 0)
items.sort((a, b) => (b.createdAt || 0) - (a.createdAt || 0))
const page = items.slice(0, limit)
// 缩略图:图库里本来就有 320 缩略图(row.idb),这里按需读出来复用;最多 120 条/次,其余下次刷新再补。
const need = page.filter((x) => !x.thumbUrl && x.url).slice(0, 120)
if (need.length) {
await Promise.all(need.map(async (x) => {
const row = idxNow.find((f) => f && String(f.url) === String(x.url))
if (!row || !row.idb) { if (x.localUrl) x.thumbUrl = x.localUrl; return }
try {
const v = await IDB.get(row.idb)
const ok = (v && typeof v === 'string' && v.length > 20)
if (ok) {
x.thumbUrl = v
if (wQueueThumbCache.size > 500) { const k0 = wQueueThumbCache.keys().next().value; if (k0) wQueueThumbCache.delete(k0) }
wQueueThumbCache.set(x.url, v)
} else if (x.localUrl) x.thumbUrl = x.localUrl
} catch (e) { if (x.localUrl) x.thumbUrl = x.localUrl }
}))
}
return { items: page, total: items.length }
},
retry: (id) => { try { return window.__iwbIngest ? window.__iwbIngest.retry(id) : null } catch (e) { return null } },
restart: (id) => { try { if (!window.__iwbIngest) return null; try { window.__iwbIngest.cancel(id) } catch (e0) { /* ignore */ } return window.__iwbIngest.retry(id) } catch (e) { return null } },
land: async (id) => {
const e = qEntry(id)
if (!e) return { ok: false, error: 'record-missing' }
if (!/^https?:/i.test(String(e.url || ''))) return { ok: false, error: 'no-url' }
const idx = lsGet(OUT_KEY, []) || []
const row = idx.find((f) => f && String(f.url) === String(e.url))
if (row && (row.orig === 'ok' || row.origIdb)) return { ok: true, already: true }
if (!row) {
try { await wAddOutputs([{ ok: true, url: e.url, width: e.w, height: e.h, label: String((e.meta && e.meta.prompt) || '') }], {}) } catch (e1) { /* ignore */ }
}
try { window.__iwbIngest.enqueue({ url: e.url, source: 'task-queue', w: e.w, h: e.h, meta: e.meta }) } catch (e2) { /* ignore */ }
const hit = (lsGet(OUT_KEY, []) || []).find((f) => f && String(f.url) === String(e.url))
const v = qView(e.url)
if (hit && v && v.ref) { try { wIngestOrigFromRef(hit.name, e.url, v.ref) } catch (e3) { /* ignore */ } }
try { wIngestLog('queue-land url=' + String(e.url).slice(0, 60)) } catch (e4) { /* ignore */ }
return { ok: true }
},
preview: async (id) => {
const all = qList().filter((x) => x && x.url)
const idx = all.findIndex((x) => x.id === id)
if (idx < 0) return { ok: false, error: 'record-missing' }
const idxNow = lsGet(OUT_KEY, []) || []
const F = wStoreMod()
const rowOf = (x) => idxNow.find((f) => f && String(f.url) === String(x.url)) || null
// 2026-12-03(用户裁定):预览只读本地 —— origIdb → images/gallery 原图文件;都没有就提示未下载。
// 列表条目交给 ImagePreview 的 __gallery 解析(它按需读原图),这里不再直连远程、不再把 320 缩略图当原图。
const curRow = rowOf(all[idx])
let hasLocal = !!(curRow && curRow.origIdb)
if (!hasLocal && curRow && F && typeof F.galleryOriginalOf === 'function') { try { const g = await F.galleryOriginalOf(curRow, 2048); hasLocal = !!(g && g.url) } catch (e) { /* ignore */ } }
if (!hasLocal) { setNotice({ type: 'err', text: '这张图还没有下载到本地,先点「下载」' }); return { ok: false, error: 'not-local' } }
const list = all.map((x) => {
const row = rowOf(x)
const thumb = wQueueThumbCache.get(x.url) || ''
if (row && row.name) return { __gallery: true, name: row.name, origIdb: row.origIdb, idb: row.idb, url: '', thumb: thumb || row.data || null, w: Number(x.w) || 0, h: Number(x.h) || 0 }
return { url: '', thumb: thumb || undefined, w: Number(x.w) || 0, h: Number(x.h) || 0, name: String((x.meta && (x.meta.promptText || x.meta.prompt)) || '') }
})
setPreview({ list, idx })
return { ok: true }
},
copyLink: (id) => {
const e = qEntry(id)
if (!e || !e.url) return { ok: false, error: 'record-missing' }
const C = (typeof window !== 'undefined') ? window.IWBClipboardCopy : null
if (!C || typeof C.copyText !== 'function') return { ok: false, error: 'clipboard-unavailable' }
return C.copyText(String(e.url)).then((ok) => ok ? { ok: true } : { ok: false, error: 'copy-failed' })
},
locate: (id) => {
const e = qEntry(id)
const meta = (e && e.meta) || {}
const bid = String(meta.boardId || '')
const nid = String(meta.nodeId || '')
if (!bid || !nid) return Promise.resolve({ ok: false, error: 'missing-meta' })
const pick = (n) => new Promise((resolve) => {
const hit = (refs.nodes || []).find((x) => x.id === nid)
if (hit) { try { setSel([nid]) } catch (e1) { /* ignore */ } ; resolve({ ok: true }); return }
if (n < 10) { setTimeout(() => { pick(n + 1).then(resolve) }, 200); return }
resolve({ ok: false, error: 'node-missing' })
})
const target = (refs.workspaces || []).find((w) => w.id === bid)
if (!target) return Promise.resolve({ ok: false, error: 'board-missing' })
if (bid !== activeWsId) { try { switchWs(bid) } catch (e2) { /* ignore */ } }
else { try { setShellView('canvas') } catch (e3) { /* ignore */ } }
return pick(0)
},
stats: () => {
const out = { total: 0, ok: 0, down: 0, fail: 0, only: 0 }
for (const e of qList()) { out.total++; const k = qMapStatus(e.status); if (out[k] !== undefined) out[k]++ }
return out
},
clear: () => { try { return window.__iwbIngest ? window.__iwbIngest.clearFinished() : 0 } catch (e) { return 0 } },
getLimit: () => { try { return Math.max(100, Math.min(5000, Number(wRawCfg().canvas.taskQueueMax) || 500)) } catch (e) { return 500 } },
setLimit: (n) => {
const v = Math.max(100, Math.min(5000, Math.round(Number(n) || 500)))
try {
const stored = wRawStoredCfg()
const next = Object.assign({}, stored, { canvas: Object.assign({}, stored.canvas || {}, { taskQueueMax: v }) })
LocalStore.set(StorageContract.localKeys.config, next)
if (window.__iwbIngestStore && typeof window.__iwbIngestStore.trim === 'function') window.__iwbIngestStore.trim()
else { const S = window.IWBImageIngestStore; if (S) S.createStore({ get: (k) => lsGet(k, null), set: (k, x) => lsSet(k, x), max: () => v }).trim() }
} catch (e) { /* ignore */ }
try { if (window.IWBPluginQueue) window.IWBPluginQueue.emit('limit') } catch (e2) { /* ignore */ }
return { ok: true, limit: v }
},
})
}
// 节点组库插件(grouplib):数据仍由宿主持有,插件只拿读写/实例化能力
if (window.IWBPluginGroupLib) {
window.IWBPluginGroupLib.setImpl({
@@ -8012,7 +8465,7 @@ const tbCenterSeed = (type, refs) => {
const dockPanels = (typeof window !== 'undefined' && window.IWBUIDockPanels)
? window.IWBUIDockPanels.build(PluginHost, wPluginPanels)
: {}
return el('div', { className: 'iwb-overlay' + (shellView === 'landing' ? ' iwb-view-landing' : shellView === 'home' ? ' iwb-view-home' : (shellView === 'plugins' ? ' iwb-view-plugins' : ' iwb-view-canvas')) + (drawerOpen ? ' drawer-open' : '') + ((nodes.length && loaded) ? ' has-minimap' : '') },
return el('div', { className: 'iwb-overlay' + (shellView === 'landing' ? ' iwb-view-landing' : shellView === 'home' ? ' iwb-view-home' : ((shellView === 'plugins' || shellView === 'page') ? ' iwb-view-plugins' : ' iwb-view-canvas')) + (drawerOpen ? ' drawer-open' : '') + ((nodes.length && loaded) ? ' has-minimap' : '') },
// 页面加载动画(真实进度条:src/ui-splash.js + src/boot-progress.js,加载完成后淡出)
!splashDone && window.IWBUISplash ? el(window.IWBUISplash.Splash, { fade: loaded, icon: I('palette') }) : null,
shellView === 'home' ? el('div', { className: 'iwb-home-panel' },
@@ -8110,7 +8563,10 @@ const tbCenterSeed = (type, refs) => {
NavRail ? el(NavRail, {
I,
logoIcon: 'brand',
view: shellView === 'plugins' ? 'plugins' : (shellView === 'home' ? 'home' : 'canvas'),
view: shellView === 'page' ? 'page' : (shellView === 'plugins' ? 'plugins' : (shellView === 'home' ? 'home' : 'canvas')),
pages: wPluginPages.slice(),
activePage: (shellView === 'page' && pluginPage) ? (pluginPage.pluginId + ':' + pluginPage.pageId) : '',
onPage: (pid, id) => { setPluginPage({ pluginId: pid, pageId: id }); setShellView('page') },
skinIcon: theme === 'dark' ? 'sun' : 'moon',
onHome: () => { setShellView('home'); try { goHome() } catch (e) { /* ignore */ } },
onCanvas: () => setShellView('canvas'),
@@ -8126,7 +8582,11 @@ const tbCenterSeed = (type, refs) => {
shellView === 'plugins' ? (PluginsPage
? el(PluginsPage, { I, PluginHost, wRuntimePlugins, wEnsurePluginLoaded, Sections: window.IWBUISettingsSections, onBack: () => setShellView('canvas') })
: el('div', { className: 'iwb-plugin-page' }, el('div', { className: 'iwb-plugin-page-head' }, '插件页未就绪'))) : null,
tabstripEl, // S12:顶部标签条(在顶栏上方)
shellView === 'page' && pluginPage ? (() => {
const page = wPluginPages.find((p) => p.pluginId === pluginPage.pluginId && p.id === pluginPage.pageId)
return page ? el(PluginPageHost, { key: page.pluginId + ':' + page.id, page }) : null
})() : null,
ReactDOM.createPortal(tabstripEl, document.body), // S12:顶部标签条(portal 到 body,脱离 overlay 的滚动/层叠)
topbarEl,
el('div', {
className: 'iwb-canvas' + (shellView !== 'canvas' ? ' iwb-canvas-hidden' : '') + (connecting ? ' iwb-connecting' : '') + (refs.drag ? ' iwb-dragging' : '') + (tool === 'pan' ? ' iwb-tool-pan' : ''),
@@ -8284,7 +8744,7 @@ const tbCenterSeed = (type, refs) => {
el('button', { 'aria-label': '复制', 'data-tip': '复制', onClick: (e) => { e.stopPropagation(); duplicateNodes(sel) } }, I('copy')),
sn.type === 'ref' ? el('label', { 'aria-label': '替换', 'data-tip': '替换', onPointerDown: (e) => e.stopPropagation() }, I('upload'), el('input', { type: 'file', accept: 'image/*', style: { display: 'none' }, onChange: (e) => { const f = e.target.files && e.target.files[0]; if (!f) return; try { const rd = new FileReader(); rd.onload = () => wImportImage(rd.result, { onError: (msg) => setNotice({ type: 'err', text: msg }) }, (r) => { if (!r || !r.ok || !r.data) return; updateNode(sn.id, { data: r.data, name: f.name, localName: null, url: '' }) }); rd.onerror = () => setNotice({ type: 'err', text: '读取图片文件失败:' + String(f.name || '') }); rd.readAsDataURL(f) } catch (err) { console.error(err) } } }, null)) : null,
sn.type === 'ref' ? el('button', { 'aria-label': '粘贴', 'data-tip': '粘贴', onClick: (e) => { e.stopPropagation(); floatbarRefPaste(sn.id) }, onPointerDown: (e) => e.stopPropagation() }, I('paste')) : null,
sn.type === 'out' ? (() => { const uout = outResultUrls(sn.id); return el('button', { 'aria-label': '下载', 'data-tip': '下载', disabled: !uout.length, onClick: (e) => { e.stopPropagation(); uout.forEach((u, i) => setTimeout(() => downloadUrl(u, 'image-' + String(i + 1).padStart(3, '0') + '.png'), i * 350)) } }, I('download')) })() : null,
sn.type === 'out' ? (() => { const uout = outResultUrls(sn.id); return el('button', { 'aria-label': '下载', 'data-tip': '下载', disabled: !uout.length, onClick: (e) => { e.stopPropagation(); uout.forEach((u, i) => setTimeout(() => downloadUrl(u, wOutNameOf(u) || ('image-' + String(i + 1).padStart(3, '0') + '.png')), i * 350)) } }, I('download')) })() : null,
...pluginNodeActionItems.filter((a) => !a.appliesTo || a.appliesTo({ id: sn.id, type: sn.type, data: sn.data || {} })).map((a) => el('button', {
key: 'plug_' + a.id, className: 'iwb-node-floatbar-plugin', title: a.title, 'data-tip': a.title,
onPointerDown: (e) => e.stopPropagation(),
@@ -8381,7 +8841,7 @@ 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, 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)
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 } })(), diagOff: (function () { try { return lsGet('iwb_diag_off', false) === true } catch (e) { return false } })(), perfProbe: (function () { try { return !!(window.IWBPerf && window.IWBPerf.running && window.IWBPerf.running()) } catch (e) { return false } })(), 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(),
@@ -8397,6 +8857,8 @@ const tbCenterSeed = (type, refs) => {
// 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 峰值
onTogglePerf: (on) => { try { lsSet('iwb_perf_probe', on ? '1' : '0') } catch (e) { /* ignore */ } try { const P = window.IWBPerf; if (P) { if (on) P.start(); else P.stop() } } catch (e2) { /* ignore */ } try { setTick((t) => t + 1) } catch (e3) { /* ignore */ } },
onToggleDiagOff: (off) => { try { lsSet('iwb_diag_off', !!off) } catch (e) { /* ignore */ } try { setTick((t) => t + 1) } catch (e2) { /* ignore */ } },
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,
@@ -8439,7 +8901,8 @@ const tbCenterSeed = (type, refs) => {
const items = []
if (isImageProducer(tgt)) items.push(el('button', { key: 'run', className: 'iwb-ctx-item', onClick: () => { runProducer(tgt.id); setCtxMenu(null) } }, I('run'), el('span', { className: 'iwb-btn-text' }, tgt.type === 'layer' ? '运行该分层' : '运行该生图')))
if (tgt.type === 'llm') items.push(el('button', { key: 'pol', className: 'iwb-ctx-item', onClick: () => { runLLM(tgt.id); setCtxMenu(null) } }, I('llm'), el('span', { className: 'iwb-btn-text' }, '▶ 润色')))
if (tgt.type === 'ref' && tgt.data && typeof tgt.data.orig === 'string' && tgt.data.orig) items.push(el('button', { key: 'restore-orig', className: 'iwb-ctx-item', onClick: () => { pushHistory(); updateNode(tgt.id, { data: tgt.data.orig, url: '', orig: '' }); setCtxMenu(null) } }, I('undo'), el('span', { className: 'iwb-btn-text' }, '还原替换前原图')))
// v3.26.183:orig 现在可能是引用对象(不再只存 data URL),还原动作统一走 image-writeback.restoreOrig
if (tgt.type === 'ref' && tgt.data && tgt.data.orig) items.push(el('button', { key: 'restore-orig', className: 'iwb-ctx-item', onClick: () => { const rid = tgt.id; pushHistory(); setCtxMenu(null); Promise.resolve(wImageWriteback ? wImageWriteback.restoreOrig(rid) : { ok: false, error: '画布能力未就绪' }).then((r) => { if (r && r.ok === false) { try { showToast(String(r.error || '原图已不可用'), 'err') } catch (e) { /* ignore */ } } }).catch(() => { /* ignore */ }) } }, I('undo'), el('span', { className: 'iwb-btn-text' }, '还原替换前原图')))
items.push(el('button', { key: 'bgc', className: 'iwb-ctx-item', onClick: (e) => { const rc = e && e.currentTarget ? e.currentTarget.getBoundingClientRect() : null; setCtxMenu(null); if (UiGenCfgModule && UiGenCfgModule.openNodeBgPalette) UiGenCfgModule.openNodeBgPalette({ current: (tgt.data && tgt.data.bg) || '', anchorRect: rc, onPreview: (bg) => previewNodeBg([tgt.id], bg), onPreviewEnd: endNodeBgPreview, onPick: (bg) => updateNode(tgt.id, { bg }) }) } }, I('palette'), el('span', { className: 'iwb-btn-text' }, '背景色')), el('button', { key: 'ren', className: 'iwb-ctx-item', onClick: () => { setCtxMenu(null); wRenameNodeDialog(tgt, td, updateNode) } }, I('edit'), el('span', { className: 'iwb-btn-text' }, '重命名节点')), el('button', { key: 'del', className: 'iwb-ctx-item iwb-ctx-danger', onClick: () => { deleteNodes([tgt.id]); setCtxMenu(null) } }, I('x'), el('span', { className: 'iwb-btn-text' }, '删除该节点')))
// 子菜单默认向上展开(底对齐入口):两组入口都在一级菜单下半区,向下会顶出视口
return el('div', { className: 'iwb-ctx-subwrap' }, el('button', { className: 'iwb-ctx-item' }, I('edit'), el('span', { className: 'iwb-btn-text' }, '该节点'), el('i', { className: 'iwb-ctx-arrow' }, '▸')), el('div', { className: 'iwb-ctxmenu iwb-ctx-sub' }, items))
@@ -8646,6 +9109,7 @@ items.push(el('button', { key: 'bgc', className: 'iwb-ctx-item', onClick: (e) =>
log: () => { try { wLog.apply(null, arguments) } catch (e) { /* ignore */ } },
capabilities: {
gallery: () => ((typeof window !== 'undefined' && window.IWBPluginGallery) ? window.IWBPluginGallery.api() : {}),
queue: () => ((typeof window !== 'undefined' && window.IWBPluginQueue) ? window.IWBPluginQueue.api() : {}),
grouplib: () => ((typeof window !== 'undefined' && window.IWBPluginGroupLib) ? window.IWBPluginGroupLib.api() : {}),
promptlib: () => ((typeof window !== 'undefined' && window.IWBPluginPromptLib) ? window.IWBPluginPromptLib.api() : {}),
// 插件文件能力(v3.26.36):沙箱目录 plugin-data/<id>/files,供插件自持图片
@@ -8677,6 +9141,31 @@ items.push(el('button', { key: 'bgc', className: 'iwb-ctx-item', onClick: (e) =>
dir: () => need().dir(ctx.id),
}
},
pages: (ctx) => {
const owned = []
const changed = () => { try { if (PluginHost && typeof PluginHost.emit === 'function') PluginHost.emit('plugin-pages-changed') } catch (e) { /* ignore */ } }
return {
registerPage: (page) => {
if (!page || !page.id || !page.title || typeof page.mount !== 'function') return false
for (let i = wPluginPages.length - 1; i >= 0; i--) {
const e = wPluginPages[i]
if (e && e.pluginId === ctx.id && e.id === String(page.id)) wPluginPages.splice(i, 1)
}
const entry = { id: String(page.id), title: String(page.title), icon: pluginIconOf(ctx.id) || page.icon || 'queue', mount: page.mount, pluginId: ctx.id }
wPluginPages.push(entry)
owned.push(entry)
changed()
return true
},
dispose: () => {
for (const entry of owned.splice(0)) {
const i = wPluginPages.indexOf(entry)
if (i >= 0) wPluginPages.splice(i, 1)
}
changed()
},
}
},
commands: (ctx) => {
const owned = []
return {
+1 -1
View File
@@ -45,7 +45,7 @@
|---|---|
| `nodeActions` | 给节点右键/工具条加自定义动作 |
| `canvas` | 只读访问画布(`getNodes` 等) |
| `canvasWrite` | 写画布(`setNodeImage` 等),**必须同时声明** |
| `canvasWrite` | 写画布(`setNodeImage` / `saveNodeImage`),接口合并进 `ctx.canvas`(无 `ctx.canvasWrite`),**必须同时声明** |
| `events` | 订阅宿主事件 |
| `storage` | 插件私有持久化(按插件 id 隔离) |
+1
View File
@@ -115,6 +115,7 @@ Get-ChildItem src-tauri\target\release\bundle -Recurse -File |
顺手验一下版本已嵌进 PE:`(Get-Item <setup.exe>).VersionInfo.FileVersion`。
## 7. 交付:**Taildrop 是首选通道(不需要任何密钥)**
> 2026-12-02 更新:实测 Windows 侧 `T:\iwb-download\_inbox` 落在 UGD 共享,mac 的 `/vol8/web` 读不到;现在默认用**一次性 tailnet HTTP**(`100.101.6.64:1876x/<token>/<file>`,token 两侧带斜杠)或 Taildrop,取完即关。
规范 §6 的路径是 scp 到 `[email protected]:/vol8/web/iwb-download/_inbox/`。**本机现状**:
Binary file not shown.

After

Width:  |  Height:  |  Size: 504 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 529 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 120 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 120 KiB

+485
View File
@@ -0,0 +1,485 @@
<!doctype html>
<html lang="zh-CN">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>任务队列 · UI 原型</title>
<style>
/* 设计 token 静态快照 —— **生成文件,勿手改**
*
* 源:src/theme-tokens.js(derive() + 本文件生成器的 SCALE 表)
* 生成:node scripts/gen-tokens.js --write (校验:--check,已进 verify:ci)
*
* 为什么要有这一层:JS 未执行的那一帧没有内联变量,用它顶住,避免首屏闪白/跳变。
* 所以它必须逐值等于 derive() 的输出 —— 这条约束由 scripts/gen-tokens.js --check 强制。
* 结构层(chrome/home/dock/edge/hr)刻意用 color-mix 表达关系式:换主题时 :root 的声明会在
* html 元素上按新的 --iwb-bg/--iwb-canvas-bg 重新求值,天然跟随。
*/
:root {
/* —— 表面阶(亮色往白里 mix) —— */
--iwb-bg: #f7f7f7;
--iwb-canvas-bg: #c6c6c6;
--iwb-layer: #f5f5f5;
--iwb-layer2: #ffffff;
--iwb-panel: #fefefe;
--iwb-node-bg: #efefef;
--iwb-field: #ffffff;
/* —— 结构层(公式与 derive 一致,见文件头) —— */
--iwb-chrome: color-mix(in srgb, var(--iwb-bg) 60%, var(--iwb-canvas-bg) 40%); /* 顶部 chrome 色:页面底与画布之间的过渡层(标签条用) */
--iwb-home-bg: color-mix(in srgb, var(--iwb-bg) 35%, var(--iwb-canvas-bg) 65%); /* 首页底色:画布色与顶栏色之间取 35/65 */
--iwb-hr: color-mix(in srgb, var(--iwb-border) 50%, var(--iwb-border2) 50%); /* 首页上的细分隔线 */
--iwb-dock-bg: color-mix(in srgb, var(--iwb-chrome) 55%, var(--iwb-canvas-bg) 45%); /* 左右停靠栏底色:排进 bg→chrome→home→canvas 灰阶 */
--iwb-dock-head-bg: color-mix(in srgb, var(--iwb-panel) 55%, var(--iwb-dock-bg)); /* 顶栏底色比停靠栏更浅一档 */
--iwb-accent-on-surface: color-mix(in srgb, var(--iwb-brand) 45%, var(--iwb-text)); /* 强调色当文字/图标用:与正文色混,亮色更沉、暗色更亮,两端过 4.5:1 */
--iwb-accent-tint: color-mix(in srgb, var(--iwb-brand) 18%, transparent); /* 强调色淡底:选中标签/药丸的底(与 --iwb-accent-on-surface 配对使用) */
--iwb-plugin-bg: var(--iwb-bg); /* v3.25.85 插件主题契约:插件只能用这组别名 */
--iwb-plugin-panel: var(--iwb-panel);
--iwb-plugin-layer: var(--iwb-layer);
--iwb-plugin-border: var(--iwb-border);
--iwb-plugin-text: var(--iwb-text);
--iwb-plugin-text2: var(--iwb-text2);
--iwb-plugin-brand: var(--iwb-brand);
--iwb-plugin-on-brand: var(--iwb-on-brand);
--iwb-plugin-err: var(--iwb-err);
--iwb-plugin-ok: var(--iwb-ok);
--iwb-plugin-warn: var(--iwb-warn);
--iwb-edge: var(--iwb-border2); /* 连线默认色:跟随边框灰(主题色只用于选中/悬停/上游高亮) */
--iwb-edge-hot: var(--iwb-brand);
--iwb-focus-ring: 2px solid color-mix(in srgb, var(--iwb-brand-text) 70%, transparent); /* 键盘焦点环(D8):颜色走 brand-text,暗色下 brand 画不出环 */
--iwb-edge-w: 1.8px; /* 外观自定义:由 src/ui-appearance.js 按配置写入,这里只给兜底默认值 */
--iwb-edge-dash: 4 3;
--iwb-node-radius: 14px;
--iwb-node-sel-w: 1px;
--iwb-grid-size: 1.4px;
--iwb-grid-gap: 22px;
--iwb-grid-on: 1;
--iwb-nav-w: 52px; /* 一级导航宽度:左停靠栏/工具栏让位都以它为基准 */
/* —— 描边 / 文字三级(目标对比度见 IWBThemeTokens.RATIO) —— */
--iwb-border: #c2c2c2;
--iwb-border2: #ababab;
--iwb-sel-surface: #eff0f1;
--iwb-sel-ring: #383838;
--iwb-text: #404040;
--iwb-text2: #5c5c5c;
--iwb-text-dim: #767676;
--iwb-color-text-on-canvas: #404040;
--iwb-node-text: #404040;
--iwb-node-text2: #6b6b6b;
--iwb-tint: #404040;
/* —— 品牌色:填充与文字是两个角色(D7) —— */
--iwb-brand: #6b7280;
--iwb-brand-text: #575d69;
--iwb-on-brand: #ffffff;
--iwb-grid-dot: #a6a6a6;
/* —— 插件表面四层(只提供取值,不做变量重指) —— */
--iwb-surface: #fefefe;
--iwb-hover: #e9e9e9;
--iwb-bg-menu: #fefefe;
--iwb-plugin-surface: #f5f5f5;
--iwb-plugin-card: #fefefe;
--iwb-plugin-inset: #ebebeb;
--iwb-plugin-hover: #e2e2e2;
/* —— 语义色 —— */
--iwb-err: #b91c1c;
--iwb-ok: #15803d;
--iwb-warn: #b45309;
--iwb-err-bg: #f1e1e1;
--iwb-err-bd: #dfa4a4;
--iwb-ok-bg: #e0ebe4;
--iwb-ok-bd: #a1cab0;
--iwb-warn-bg: #f0e7df;
--iwb-warn-bd: #deb99d;
/* —— 尺度层(L1)—— */
--sp-1: 4px; /* @deprecated 全部 5 个 → M3 的 --iwb-space-4/8/12/16/24 */
--sp-2: 8px;
--sp-3: 12px;
--sp-4: 16px;
--sp-5: 24px;
--rd-sm: 6px; /* @deprecated rd-sm/rd-md/rd-lg → M3 的 --iwb-radius-chip/control/popover */
--rd: 8px;
--rd-md: 10px;
--rd-lg: 12px;
--fs-xs: 10px; /* @deprecated fs-xs/fs-md/fs-lg/fs-xl → M3 的 --iwb-font-*(fs-sm 仍被引用) */
--fs-sm: 11px;
--fs-md: 12px;
--fs-lg: 13px;
--fs-xl: 14px;
--tr-fast: 0.1s ease-out;
--tr-base: 0.2s ease-out; /* @deprecated tr-base/tr-slow → M3 的 --iwb-motion-*(tr-fast 仍被引用) */
--tr-slow: 0.3s ease-out;
--iwb-space-2: 2px;
--iwb-space-4: 4px;
--iwb-space-6: 6px;
--iwb-space-8: 8px;
--iwb-space-10: 10px;
--iwb-space-12: 12px;
--iwb-space-16: 16px;
--iwb-space-20: 20px;
--iwb-space-24: 24px;
--iwb-space-32: 32px;
--iwb-space-40: 40px;
--iwb-space-48: 48px;
--iwb-space-64: 64px;
--iwb-radius-chip: 6px; /* M4 圆角:胶囊/标签 */
--iwb-radius-control: 8px; /* 输入框/按钮 */
--iwb-radius-card: 10px; /* 卡片/分组 */
--iwb-radius-panel: 12px; /* 面板/工具栏 */
--iwb-radius-popover: 14px; /* 浮层/菜单/右键 */
--iwb-radius-full: 999px; /* 圆形/药丸 */
--iwb-font-2xs: 10px; /* 极小标注:徽标角标/画布坐标/缩略图角标(2026-11-24 承认它,此前 29 处裸写) */
--iwb-font-xs: 11px; /* M4 字号:状态栏/徽标 */
--iwb-font-sm: 12px; /* 标签/次要正文 */
--iwb-font-md: 13px; /* 紧凑正文/工具栏标题 */
--iwb-font-base: 14px; /* 标准正文:表单行标题/命令输入/帮助正文 */
--iwb-font-lg: 15px; /* 小标题/节点标题 */
--iwb-font-xl: 17px; /* 面板标题 */
--iwb-font-2xl: 20px; /* 页面大标题 */
--iwb-font-display: 24px; /* 展示级标题:页面/视图主标题(≤5 处) */
--iwb-chrome-h: 36px; /* 顶部标签条高度:tabstrip / dockarea / home-panel 三处共用(原来各写一遍 36px) */
--iwb-tab-h: 28px; /* 标签高度 */
--iwb-tab-radius: 7px; /* 标签圆角 */
--iwb-control-h: 30px; /* 表单控件高度:同一行里的输入框与默认按钮必须等高(设置页实测曾是 33 vs 24) */
--iwb-bw: 1px; /* 描边宽度(2026-11-24):常规分隔/控件边框 */
--iwb-bw-strong: 2px; /* 强调描边:选中/焦点/危险操作(不要再用 2px 裸值) */
--iwb-icon-sm: 14px; /* 小图标:行内/按钮内 */
--iwb-icon-md: 16px; /* 标准图标:工具栏/菜单 */
--iwb-icon-lg: 18px; /* 大图标:导航/空态 */
--iwb-opacity-disabled: 0.45; /* 禁用态透明度(此前 0.45/0.55 混用) */
--iwb-opacity-muted: 0.7; /* 次要/未激活元素透明度 */
--iwb-ease-out: cubic-bezier(0.16, 1, 0.3, 1); /* 入场/展开缓动:快出慢停 */
--iwb-ease-in-out: cubic-bezier(0.4, 0, 0.2, 1); /* 状态切换缓动 */
--iwb-motion-fast: 0.12s; /* M6 动效:悬停/开关/小位移 */
--iwb-motion-base: 0.15s; /* M6 动效:面板展开/尺寸变化 */
--iwb-motion-slow: 0.3s; /* M6 动效:整屏过渡/抽屉 */
--iwb-motion-hover: 0.15s; /* L2 悬停:卡片/结果图浮层统一时长 */
--iwb-ease-hover: cubic-bezier(0.16, 1, 0.3, 1); /* L2 悬停:快出慢停 */
--iwb-hover-lift: -2px; /* L2 悬停:上浮位移 */
--iwb-hover-scale: 1.02; /* L2 悬停:缩放(相册格子单独用 1.08) */
--iwb-hover-shadow: 0 6px 16px rgba(0, 0, 0, 0.35); /* L2 悬停:投影(单值,供 filter: drop-shadow 用;box-shadow 会多一种写法) */
--iwb-hover-border: var(--iwb-brand); /* L2 悬停:描边色 */
--iwb-scrim: rgba(0, 0, 0, 0.62); /* 图片上的遮罩渐变底:下载浮层/预览条(两套主题都用深色,保证白字可读) */
--iwb-selection-ring: var(--iwb-brand); /* 选中描边(跟随强调色) */
--iwb-selection-on: var(--iwb-on-brand); /* 选中描边的隔离内环(品牌底上的文字色) */
--iwb-selection-bg: color-mix(in srgb, var(--iwb-brand) 12%, transparent); /* 选中格淡底(不压黑缩略图) */
--iwb-selection-halo: color-mix(in srgb, var(--iwb-brand) 45%, transparent); /* 选中外发光(与 hover 区分) */
--iwb-z-ctx: 90; /* 右键遮罩 */
--iwb-z-ctx-menu: 91; /* 右键菜单 */
--iwb-z-curtain: 100; /* 应用遮罩 / 图片预览底 */
--iwb-z-command: 120; /* 命令面板(⌘K) */
--iwb-z-sheet: 260; /* 全窗口面板(资源中心) */
--iwb-z-sheet-menu: 270; /* 面板内 portal 菜单:> sheet、< modal */
--iwb-z-modal: 300; /* 弹窗 + 遮罩 */
--iwb-z-modal-menu: 310; /* 侧栏/弹窗里挂 body 的菜单 */
--iwb-z-splash: 400; /* 启动页 */
--iwb-z-toast: 500; /* 提示条:必须高于弹窗 */
--iwb-z-preview: 800; /* 图片预览(全屏) */
--iwb-z-anchor: 3200; /* 锚定浮层:挂 body 的面板/首页菜单 */
--iwb-z-palette: 3300; /* 背景色板 host(含锚定浮层) */
--iwb-z-alert: 4000; /* 确认框 / 崩溃屏(最后一道) */
/* —— 阴影 —— */
--sh-sm: 0 2px 8px rgba(0, 0, 0, 0.12); /* @deprecated → M3 的 --iwb-elevation-1 */
--sh-md: 0 6px 20px rgba(0, 0, 0, 0.16);
--sh-lg: 0 12px 32px rgba(0, 0, 0, 0.24);
--iwb-elevation-1: 0 2px 8px rgba(0, 0, 0, 0.12); /* 贴面浮层:浮动条 / 状态栏 */
--iwb-elevation-2: 0 10px 30px rgba(0, 0, 0, 0.18), 0 1px 3px rgba(0, 0, 0, 0.10); /* 浮窗 / 菜单 / toast */
--iwb-elevation-3: 0 18px 56px rgba(0, 0, 0, 0.26); /* 命令面板 / 锚定大浮层 */
--iwb-elevation-4: 0 24px 64px rgba(0, 0, 0, 0.30); /* 弹窗 / 全窗口面板 */
}
/* 暗色主题:html.theme-dark
* 同一套语义名,值来自 derive(DEFAULTS, true)。结构层不在这里重复定义 ——
* :root 的 color-mix 公式会在本元素上按新的 --iwb-bg/--iwb-canvas-bg 重新求值。 */
.theme-dark {
/* 生图动效在暗色下必须「发亮」:--iwb-brand 是中性灰,直接用会糊在深底里 */
--iwb-anim: #ffffff;
--iwb-anim-track: color-mix(in srgb, #ffffff 18%, transparent);
--iwb-anim-glow: rgba(255, 255, 255, 0.72);
--iwb-anim-tint: color-mix(in srgb, #ffffff 16%, transparent);
--iwb-anim-flow-a: color-mix(in srgb, #ffffff 26%, var(--iwb-layer));
--iwb-anim-flow-b: color-mix(in srgb, #ffffff 76%, var(--iwb-layer));
/* —— 表面阶 —— */
--iwb-bg: #121212;
--iwb-canvas-bg: #313131;
--iwb-layer: #161616;
--iwb-layer2: #1c1c1c;
--iwb-panel: #1c1c1c;
--iwb-node-bg: #3d3d3d;
--iwb-field: #494949;
--iwb-border: #333333;
--iwb-border2: #4d4d4d;
--iwb-sel-surface: #313234;
--iwb-sel-ring: #e8e8e8;
/* —— 文字 / 品牌 —— */
--iwb-text: #e3e3e3;
--iwb-text2: #bababa;
--iwb-text-dim: #989898;
--iwb-color-text-on-canvas: #b2b2b2;
--iwb-node-text: #e3e3e3;
--iwb-node-text2: #aaaaaa;
--iwb-tint: #e3e3e3;
--iwb-brand: #6b7280;
--iwb-brand-text: #b6bac0;
--iwb-on-brand: #ffffff;
--iwb-grid-dot: #525252;
/* —— 插件表面 / 浮层 / 语义色 —— */
--iwb-surface: #1c1c1c;
--iwb-hover: #2a2a2a;
--iwb-bg-menu: #3c3c3c;
--iwb-plugin-surface: #232323;
--iwb-plugin-card: #2c2c2c;
--iwb-plugin-inset: #191919;
--iwb-plugin-hover: #383838;
--iwb-err: #f26666;
--iwb-ok: #4acf7b;
--iwb-warn: #e1953d;
/* —— 阴影 —— */
--sh-sm: 0 2px 8px rgba(0, 0, 0, 0.35);
--sh-md: 0 6px 20px rgba(0, 0, 0, 0.45);
--sh-lg: 0 12px 32px rgba(0, 0, 0, 0.6);
--iwb-elevation-1: 0 2px 8px rgba(0, 0, 0, 0.40);
--iwb-elevation-2: 0 8px 28px rgba(0, 0, 0, 0.55), 0 1px 3px rgba(0, 0, 0, 0.40);
--iwb-elevation-3: 0 18px 56px rgba(0, 0, 0, 0.62);
--iwb-elevation-4: 0 24px 64px rgba(0, 0, 0, 0.70);
}
/* 亮色主题的生图动效 token:与暗色同结构,色取品牌色 */
:root:not(.theme-dark) {
--iwb-anim: var(--iwb-brand);
--iwb-anim-track: color-mix(in srgb, var(--iwb-brand) 16%, transparent);
--iwb-anim-glow: color-mix(in srgb, var(--iwb-brand) 75%, transparent);
--iwb-anim-tint: color-mix(in srgb, var(--iwb-brand) 7%, transparent);
--iwb-anim-flow-a: color-mix(in srgb, var(--iwb-brand) 16%, var(--iwb-layer));
--iwb-anim-flow-b: color-mix(in srgb, var(--iwb-brand) 46%, var(--iwb-layer));
}
/* component.settings:由 gen-tokens 生成,勿手改;布局属性仍在 style.css */
.iwb-settings-modal {
--iwb-set-label-w: 180px; /* 标签列宽 */
--iwb-set-col-gap: var(--iwb-space-16); /* 标签列与控件列间距 */
--iwb-set-row-h: 40px; /* 设置行高 */
--iwb-set-row-pad-y: var(--iwb-space-8); /* 行上下内边距 */
--iwb-set-group-gap: var(--iwb-space-32); /* 分组之间(规范 §3.11:32px) */
--iwb-set-title-gap: var(--iwb-space-8); /* 分组标题与分组体间距 */
--iwb-set-group-bg: hsl(0 0% 97.6%); /* 分组体底色:设计值 #F9F9F9(用 hsl 表达以过 hex 闸门) */
--iwb-set-group-radius: var(--iwb-radius-card); /* 分组体圆角 */
--iwb-set-group-pad-x: var(--iwb-space-20); /* 分组体左右内边距 */
--iwb-set-group-pad-y: var(--iwb-space-12); /* 分组体上下内边距 */
--iwb-set-divider: color-mix(in srgb, var(--iwb-border) 55%, transparent); /* 行分隔线 */
--iwb-set-hint-color: var(--iwb-text-dim); /* 说明文字色 */
--iwb-set-hint-size: var(--iwb-font-xs); /* 说明文字字号 */
--iwb-set-hint-gap: var(--iwb-space-2); /* 说明文字上间距 */
--iwb-set-input-border: color-mix(in srgb, var(--iwb-border) 40%, var(--iwb-panel)); /* 输入框描边 */
--iwb-set-check-size: 16px; /* 复选项尺寸 */
--iwb-set-check-radius: 4px; /* 复选项圆角 */
--iwb-set-btn-gap: var(--iwb-space-8); /* 操作按钮间距 */
}
/* component.settings · 暗色覆盖 */
.theme-dark .iwb-settings-modal {
--iwb-set-group-bg: color-mix(in srgb, var(--iwb-text) 8%, var(--iwb-panel)); /* 暗色分组体:文字色 8% 混面板 */
}
/* component.popover:由 gen-tokens 生成,勿手改;布局属性仍在 style.css */
.iwb-pop {
--iwb-pop-w: 360px; /* 面板宽度(窄屏靠 max-width 兜底) */
--iwb-pop-pad-y: var(--iwb-space-10); /* 面板上下内边距 */
--iwb-pop-pad-x: var(--iwb-space-12); /* 面板左右内边距 */
--iwb-pop-gap: var(--iwb-space-8); /* 分组之间 */
--iwb-pop-radius: var(--iwb-radius-popover); /* 面板圆角 */
--iwb-pop-title-size: var(--iwb-font-base); /* 面板标题字号 */
--iwb-pop-chip-h: 28px; /* 选择项/下拉/数字框高度 */
--iwb-pop-chip-pad-x: var(--iwb-space-10); /* 选择项左右内边距 */
--iwb-pop-chip-radius: 6px; /* 选择项圆角 */
--iwb-pop-chip-gap: var(--iwb-space-6); /* 选择项间距 */
--iwb-pop-chip-size: var(--iwb-font-md); /* 选择项字号 */
}
</style>
<style>
* { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; background: var(--iwb-bg); color: var(--iwb-text); font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans CJK SC", sans-serif; font-size: var(--iwb-font-base); line-height: 1.45; }
.app { display: flex; height: 100vh; overflow: hidden; }
.rail { width: 56px; flex: 0 0 56px; background: var(--iwb-dock-bg); border-right: 1px solid var(--iwb-border); display: flex; flex-direction: column; align-items: center; padding: var(--iwb-space-10) 0; gap: var(--iwb-space-6); }
.rail .logo { width: 30px; height: 30px; border-radius: var(--iwb-radius-control); background: var(--iwb-brand); color: var(--iwb-on-brand); display: grid; place-items: center; font-size: var(--iwb-font-sm); font-weight: 700; margin-bottom: var(--iwb-space-6); }
.rail .item { width: 36px; height: 36px; border-radius: var(--iwb-radius-control); display: grid; place-items: center; color: var(--iwb-text2); cursor: default; }
.rail .item svg { width: var(--iwb-icon-lg); height: var(--iwb-icon-lg); }
.rail .item:hover { background: var(--iwb-hover); color: var(--iwb-text); }
.rail .item.active { background: var(--iwb-accent-tint); color: var(--iwb-accent-on-surface); }
.page { flex: 1; min-width: 0; padding: var(--iwb-space-24) var(--iwb-space-32) var(--iwb-space-16); display: flex; flex-direction: column; gap: var(--iwb-space-16); overflow: hidden; }
.head { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--iwb-space-16); }
.title { font-size: var(--iwb-font-2xl); font-weight: 650; letter-spacing: .01em; }
.sub { display: block; margin-top: 2px; font-size: var(--iwb-font-sm); font-weight: 400; color: var(--iwb-text2); }
.tools { display: flex; align-items: center; gap: var(--iwb-space-8); flex-wrap: wrap; justify-content: flex-end; }
.field { display: inline-flex; align-items: center; gap: var(--iwb-space-6); font-size: var(--iwb-font-sm); color: var(--iwb-text2); }
select, button { font: inherit; }
select { height: 30px; padding: 0 var(--iwb-space-10); color: var(--iwb-text); background: var(--iwb-field); border: 1px solid var(--iwb-border2); border-radius: var(--iwb-radius-control); }
.btn { height: 30px; padding: 0 var(--iwb-space-12); border-radius: var(--iwb-radius-control); border: 1px solid var(--iwb-border2); background: var(--iwb-panel); color: var(--iwb-text); display: inline-flex; align-items: center; gap: var(--iwb-space-6); cursor: pointer; font-size: var(--iwb-font-sm); white-space: nowrap; }
.btn:hover { background: var(--iwb-hover); border-color: var(--iwb-hover-border); }
.btn.primary { background: var(--iwb-brand); color: var(--iwb-on-brand); border-color: var(--iwb-brand); }
.btn.primary:hover { filter: brightness(1.05); }
.btn.ghost { background: transparent; }
.btn:disabled { opacity: .5; cursor: default; background: var(--iwb-layer); color: var(--iwb-text2); border-color: var(--iwb-border); }
.tabs { display: flex; gap: var(--iwb-space-4); border-bottom: 1px solid var(--iwb-border); padding-bottom: 0; }
.tab { padding: var(--iwb-space-6) var(--iwb-space-10); font-size: var(--iwb-font-sm); color: var(--iwb-text2); border-radius: var(--iwb-radius-control) var(--iwb-radius-control) 0 0; cursor: pointer; display: inline-flex; align-items: center; gap: var(--iwb-space-6); }
.tab:hover { color: var(--iwb-text); background: var(--iwb-hover); }
.tab.active { color: var(--iwb-accent-on-surface); background: var(--iwb-accent-tint); }
.tab .n { font-size: var(--iwb-font-2xs); color: var(--iwb-text2); background: var(--iwb-layer); border: 1px solid var(--iwb-border); border-radius: var(--iwb-radius-full); padding: 0 6px; line-height: 15px; }
.tab.active .n { color: var(--iwb-accent-on-surface); background: transparent; border-color: var(--iwb-accent-on-surface); }
.list { flex: 1; min-height: 0; overflow: auto; display: flex; flex-direction: column; gap: var(--iwb-space-8); padding-right: 2px; }
.row { display: grid; grid-template-columns: 96px minmax(0,1fr) auto; gap: var(--iwb-space-12); align-items: center; padding: var(--iwb-space-10); background: var(--iwb-panel); border: 1px solid var(--iwb-border); border-radius: var(--iwb-radius-card); transition: border-color .15s, background .15s; }
.row:hover { border-color: var(--iwb-hover-border); }
.row.failed { border-color: var(--iwb-err-bd); background: color-mix(in srgb, var(--iwb-err) 9%, var(--iwb-panel)); }
.thumb { cursor: zoom-in; width: 96px; height: 64px; border-radius: var(--iwb-radius-control); border: 1px solid var(--iwb-border); background: var(--iwb-layer2); overflow: hidden; position: relative; display: grid; place-items: center; }
.thumb svg, .thumb img { width: 100%; height: 100%; display: block; object-fit: cover; }
.thumb .ph { color: var(--iwb-text2); display: grid; place-items: center; gap: 2px; font-size: var(--iwb-font-2xs); }
.thumb .ph svg { width: 20px; height: 20px; }
.thumb .prog { position: absolute; left: 0; right: 0; bottom: 0; height: 3px; background: var(--iwb-layer); }
.thumb .prog i { display: block; height: 100%; width: 42%; background: var(--iwb-brand); }
.main { min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.line1 { display: flex; align-items: center; gap: var(--iwb-space-8); min-width: 0; }
.name { font-size: var(--iwb-font-base); font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.badge { flex: 0 0 auto; height: 18px; padding: 0 var(--iwb-space-8); border-radius: var(--iwb-radius-full); font-size: var(--iwb-font-2xs); line-height: 18px; border: 1px solid var(--iwb-border2); color: var(--iwb-text2); background: var(--iwb-layer); }
.badge.ok { color: var(--iwb-ok); border-color: var(--iwb-ok-bd); background: var(--iwb-ok-bg); }
.badge.err { color: var(--iwb-err); border-color: var(--iwb-err-bd); background: var(--iwb-err-bg); }
.badge.warn { color: var(--iwb-warn); border-color: var(--iwb-warn-bd); background: var(--iwb-warn-bg); }
.meta { font-size: var(--iwb-font-sm); color: var(--iwb-text2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.errline { font-size: var(--iwb-font-xs); color: var(--iwb-err); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.actions { display: flex; align-items: center; gap: var(--iwb-space-6); flex-wrap: wrap; justify-content: flex-end; }
.foot { font-size: var(--iwb-font-xs); color: var(--iwb-text2); display: flex; justify-content: space-between; gap: var(--iwb-space-12); }
.foot .hint { color: var(--iwb-text-dim); }
.empty { padding: var(--iwb-space-32); text-align: center; color: var(--iwb-text2); font-size: var(--iwb-font-sm); }
@media (max-width: 860px) { .page { padding: var(--iwb-space-16); } .row { grid-template-columns: 72px minmax(0,1fr); } .actions { grid-column: 2; justify-content: flex-start; } .thumb { width: 72px; height: 50px; } }
</style>
</head>
<body>
<div class="app">
<aside class="rail" aria-label="主导航">
<div class="logo">IW</div>
<div class="item" title="首页"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.7"><path d="M3 10.5 12 3l9 7.5"/><path d="M5 9.5V21h14V9.5"/></svg></div>
<div class="item" title="画布"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.7"><rect x="3" y="4" width="18" height="16" rx="2"/><path d="M3 9h18"/></svg></div>
<div class="item" title="插件"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.7"><path d="M4 4h6v6H4zM14 4h6v6h-6zM4 14h6v6H4zM14 14h6v6h-6z"/></svg></div>
<div class="item active" title="任务队列"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.7"><path d="M4 6h12M4 12h12M4 18h8"/><circle cx="19" cy="18" r="2.2"/></svg></div>
</aside>
<main class="page">
<header class="head">
<div>
<div class="title">任务队列</div>
<span class="sub">全局生图记录 · 数据由宿主保存,插件关闭也继续记录</span>
</div>
<div class="tools">
<label class="field">记录上限
<select id="limit"><option>200</option><option selected>500</option><option>1000</option><option>2000</option><option>5000</option></select>
</label>
<button class="btn ghost" id="clear">清空记录</button>
<button class="btn ghost" id="theme">深色</button>
</div>
</header>
<nav class="tabs" id="tabs">
<div class="tab active" data-f="all">全部 <span class="n">6</span></div>
<div class="tab" data-f="ok">已完成 <span class="n">2</span></div>
<div class="tab" data-f="down">下载中 <span class="n">1</span></div>
<div class="tab" data-f="fail">失败 <span class="n">1</span></div>
<div class="tab" data-f="only">仅记录 <span class="n">2</span></div>
</nav>
<section class="list" id="list">
<!-- 已完成 -->
<div class="row" data-s="ok">
<div class="thumb" title="点击预览"><svg viewBox="0 0 96 64"><rect width="96" height="64" fill="#fff"/><text x="8" y="24" font-size="13" font-weight="700" fill="#111">古茗草莓</text><text x="8" y="40" font-size="13" font-weight="700" fill="#111">新品专场</text><text x="8" y="55" font-size="9" fill="#555">单杯不到12r</text></svg></div>
<div class="main">
<div class="line1"><span class="name">pop 手绘体设计 · 第 1 张</span><span class="badge ok">已完成</span></div>
<div class="meta">品牌视觉 · 12-03 14:20 · 1536×1024 · gpt-image-2.6</div>
</div>
<div class="actions">
<button class="btn" disabled>已在图库</button>
<button class="btn ghost">复制原始链接</button>
<button class="btn ghost">定位</button>
</div>
</div>
<!-- 下载中 -->
<div class="row" data-s="down">
<div class="thumb" title="点击预览"><svg viewBox="0 0 96 64"><rect width="96" height="64" fill="#fff"/><text x="8" y="26" font-size="13" font-weight="700" fill="#111">艺术字体</text><text x="8" y="44" font-size="11" fill="#111">买一送一</text></svg><div class="prog"><i></i></div></div>
<div class="main">
<div class="line1"><span class="name">艺术字体 · 第 1 张</span><span class="badge">下载中 42%</span></div>
<div class="meta">活动海报 · 12-03 14:22 · 1536×1024 · 正在写入 images/gallery</div>
</div>
<div class="actions">
<button class="btn" disabled>下载中…</button>
<button class="btn ghost">复制原始链接</button>
<button class="btn ghost">定位</button>
</div>
</div>
<!-- 失败 -->
<div class="row failed" data-s="fail">
<div class="thumb" title="点击预览"><svg viewBox="0 0 96 64"><rect width="96" height="64" fill="#fff"/><text x="8" y="26" font-size="12" font-weight="700" fill="#111">披萨新品</text><text x="8" y="44" font-size="12" font-weight="700" fill="#111">买一送一</text></svg></div>
<div class="main">
<div class="line1"><span class="name">艺术字体 · 第 2 张</span><span class="badge err">失败</span></div>
<div class="meta">活动海报 · 12-03 14:25 · 1536×1024</div>
<div class="errline">timeout · 已重试 3 次 · 原始链接仍可复制</div>
</div>
<div class="actions">
<button class="btn primary">重试</button>
<button class="btn ghost">复制原始链接</button>
<button class="btn ghost">定位</button>
</div>
</div>
<!-- 仅记录 -->
<div class="row" data-s="only">
<div class="thumb" title="点击预览"><div class="ph"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.6"><path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"/><polyline points="7 10 12 15 17 10"/><line x1="12" x2="12" y1="15" y2="3"/></svg><span>仅记录</span></div></div>
<div class="main">
<div class="line1"><span class="name">披萨新品 · 买一送一</span><span class="badge warn">仅记录</span></div>
<div class="meta">活动海报 · 12-02 18:10 · 1536×1024 · gpt-image-2.5</div>
</div>
<div class="actions">
<button class="btn primary">下载</button>
<button class="btn ghost">复制原始链接</button>
<button class="btn ghost">定位</button>
</div>
</div>
<!-- 已完成,画布已删除 -->
<div class="row" data-s="ok">
<div class="thumb" title="点击预览"><svg viewBox="0 0 96 64"><rect width="96" height="64" fill="#fff"/><text x="8" y="24" font-size="12" font-weight="700" fill="#111">pop 手绘体</text><text x="8" y="42" font-size="10" fill="#555">新品上市</text></svg></div>
<div class="main">
<div class="line1"><span class="name">pop 手绘体设计 · 第 2 张</span><span class="badge ok">已完成</span></div>
<div class="meta">品牌视觉 · 12-01 09:40 · 1536×1024</div>
</div>
<div class="actions">
<button class="btn" disabled>已在图库</button>
<button class="btn ghost">复制原始链接</button>
<button class="btn ghost" disabled>画布已删除</button>
</div>
</div>
<!-- 仅记录,节点已删除 -->
<div class="row" data-s="only">
<div class="thumb" title="点击预览"><div class="ph"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.6"><path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"/><polyline points="7 10 12 15 17 10"/><line x1="12" x2="12" y1="15" y2="3"/></svg><span>仅记录</span></div></div>
<div class="main">
<div class="line1"><span class="name">艺术字体 · 第 3 张</span><span class="badge warn">仅记录</span></div>
<div class="meta">活动海报 · 11-30 16:05 · 1536×1024</div>
</div>
<div class="actions">
<button class="btn primary">下载</button>
<button class="btn ghost">复制原始链接</button>
<button class="btn ghost" disabled>节点已删除</button>
</div>
</div>
</section>
<footer class="foot">
<span>记录只保留链接与本机状态;上限内自动淘汰最旧记录,不影响 images/gallery 里的文件。</span>
<span class="hint">点击「下载」= 落地到图库(图库会自动刷新出现)</span>
</footer>
</main>
</div>
<script>
const html = document.documentElement
const themeBtn = document.getElementById('theme')
themeBtn.addEventListener('click', () => { html.classList.toggle('theme-dark'); themeBtn.textContent = html.classList.contains('theme-dark') ? '浅色' : '深色' })
const tabs = Array.from(document.querySelectorAll('#tabs .tab'))
const rows = Array.from(document.querySelectorAll('#list .row'))
tabs.forEach((t) => t.addEventListener('click', () => {
tabs.forEach((x) => x.classList.toggle('active', x === t))
const f = t.getAttribute('data-f')
rows.forEach((r) => { r.style.display = (f === 'all' || r.getAttribute('data-s') === f) ? '' : 'none' })
}))
</script>
</body>
</html>
+163
View File
@@ -0,0 +1,163 @@
<!doctype html>
<html lang="zh-CN" data-theme="light">
<head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1">
<title>任务队列 · UI 方案</title>
<style>
:root{--bg:#f6f7f9;--panel:#fff;--panel2:#fafbfc;--line:#e8eaee;--line2:#dfe2e8;--text:#1a1a1a;--text2:#6b7280;--text3:#9aa1ab;--brand:#f59e0b;--brand-weak:#fff7e6;--brand-line:#f5d08a;--ok:#16a34a;--ok-weak:#eefaf0;--err:#dc2626;--err-weak:#fdeeee;--r:10px;--rs:8px;--shadow:0 1px 2px rgba(16,24,40,.04),0 8px 24px rgba(16,24,40,.06)}
html[data-theme="dark"]{--bg:#121212;--panel:#1c1c1c;--panel2:#202020;--line:#2a2a2a;--line2:#343434;--text:#e9e9ea;--text2:#9a9a9a;--text3:#6f6f6f;--brand:#f5a623;--brand-weak:#2a2114;--brand-line:#5a4420;--ok:#4ade80;--ok-weak:#16281b;--err:#f87171;--err-weak:#2c1a1a;--shadow:0 1px 2px rgba(0,0,0,.4),0 8px 24px rgba(0,0,0,.35)}
*{box-sizing:border-box}
body{margin:0;background:var(--bg);color:var(--text);font:13px/1.5 -apple-system,"PingFang SC","Microsoft YaHei",sans-serif}
.app{display:flex;min-height:100vh}
.rail{width:52px;flex:0 0 52px;background:var(--panel);border-right:1px solid var(--line);display:flex;flex-direction:column;align-items:center;padding:10px 0;gap:6px}
.rail .logo{width:30px;height:30px;border-radius:9px;background:linear-gradient(135deg,#111,#444);margin-bottom:8px}
.rail button{width:36px;height:36px;border:0;border-radius:10px;background:transparent;color:var(--text2);display:grid;place-items:center;cursor:pointer}
.rail button:hover{background:var(--panel2);color:var(--text)}
.rail button.on{background:var(--text);color:var(--panel)}
.rail .spacer{flex:1}
.rail svg{width:18px;height:18px;fill:none;stroke:currentColor;stroke-width:1.7;stroke-linecap:round;stroke-linejoin:round}
.main{flex:1;min-width:0;display:flex;flex-direction:column}
.head{padding:20px 24px 0;display:flex;align-items:center;gap:12px}
.head h1{margin:0;font-size:20px;font-weight:650}
.head .right{margin-left:auto;display:flex;gap:8px}
.ghost{height:30px;padding:0 12px;border:1px solid var(--line2);border-radius:var(--rs);background:var(--panel);color:var(--text2);cursor:pointer;font-size:12px}
.ghost:hover{background:var(--panel2);color:var(--text)}
.tabs{display:flex;gap:22px;padding:14px 24px 0;border-bottom:1px solid var(--line);margin-top:8px}
.tab{position:relative;padding:0 0 10px;border:0;background:none;color:var(--text2);font-size:13px;cursor:pointer}
.tab b{font-weight:600;margin-left:3px;color:var(--text3);font-size:12px}
.tab.on{color:var(--text);font-weight:600}
.tab.on:after{content:"";position:absolute;left:0;right:0;bottom:-1px;height:2px;background:var(--brand);border-radius:2px}
.filters{display:flex;align-items:center;gap:8px;padding:12px 24px;flex-wrap:wrap}
.chip{height:30px;padding:0 10px;border:1px solid var(--line2);border-radius:8px;background:var(--panel);color:var(--text2);cursor:pointer;display:inline-flex;align-items:center;gap:6px;font-size:12px}
.chip.on{border-color:var(--brand);background:var(--brand-weak);color:var(--text)}
.search{flex:1;min-width:220px;height:32px;border:1px solid var(--line2);border-radius:8px;background:var(--panel);display:flex;align-items:center;gap:8px;padding:0 10px;color:var(--text3)}
.search input{border:0;outline:0;background:none;flex:1;font-size:12px;color:var(--text)}
.date{height:30px;padding:0 10px;border:1px solid var(--line2);border-radius:8px;background:var(--panel);display:inline-flex;align-items:center;color:var(--text3);font-size:12px}
.dates{display:flex;align-items:center;gap:8px;color:var(--text2);font-size:12px}
.list{padding:4px 24px 120px;display:flex;flex-direction:column;gap:8px}
.row{position:relative;display:flex;gap:14px;padding:14px;background:var(--panel);border:1px solid var(--line);border-radius:var(--r);box-shadow:var(--shadow)}
.row:hover{border-color:var(--line2)}
.row.sel{border-color:var(--brand);box-shadow:0 0 0 1px var(--brand-line),var(--shadow)}
.thumb{position:relative;width:88px;height:88px;flex:0 0 88px;border-radius:var(--rs);overflow:hidden;background:var(--panel2);border:1px solid var(--line)}
.thumb .ph{position:absolute;inset:0;display:grid;place-items:center;color:var(--text3);font-size:10px;letter-spacing:.5px}
.thumb .img{position:absolute;inset:0;background:radial-gradient(120% 90% at 15% 10%,#ffe9c9 0,transparent 55%),radial-gradient(90% 70% at 85% 0,#d7f0e3 0,transparent 60%),linear-gradient(160deg,#efe6d8,#d9cbb8 45%,#bfae98)}
.thumb .img.b{background:radial-gradient(100% 80% at 20% 20%,#dfe8ff 0,transparent 60%),linear-gradient(160deg,#e9edff,#c7d3f5 50%,#a9b8e8)}
.thumb .img.c{background:radial-gradient(100% 80% at 70% 10%,#ffe3e0 0,transparent 60%),linear-gradient(160deg,#ffe9e5,#efc9c1 55%,#d9a99f)}
.thumb .badge{position:absolute;left:6px;top:6px;padding:1px 6px;border-radius:6px;font-size:10px;background:rgba(0,0,0,.55);color:#fff}
.thumb .prog{position:absolute;left:0;right:0;bottom:0;height:4px;background:rgba(0,0,0,.12)}
.thumb .prog i{display:block;height:100%;background:var(--brand);width:62%}
.thumb .err{position:absolute;inset:0;display:grid;place-items:center;background:var(--err-weak);color:var(--err);font-size:22px}
.body{flex:1;min-width:0;display:flex;flex-direction:column;gap:6px}
.title{font-size:13.5px;font-weight:600;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.meta{display:flex;align-items:center;gap:10px;color:var(--text3);font-size:12px;flex-wrap:wrap}
.dot{width:3px;height:3px;border-radius:50%;background:var(--line2)}
.state{display:inline-flex;align-items:center;gap:5px;padding:1px 7px;border-radius:999px;font-size:11px;border:1px solid transparent}
.state.ok{color:var(--ok);background:var(--ok-weak);border-color:rgba(22,163,74,.25)}
.state.err{color:var(--err);background:var(--err-weak);border-color:rgba(220,38,38,.25)}
.state.dl{color:#b45309;background:var(--brand-weak);border-color:var(--brand-line)}
.state.wait{color:var(--text2);background:var(--panel2);border-color:var(--line2)}
.link{color:var(--brand);cursor:pointer;border-bottom:1px dashed rgba(245,158,11,.5)}
.errbar{margin-top:2px;padding:7px 10px;border-radius:8px;background:var(--err-weak);color:var(--err);font-size:12px;display:flex;gap:8px}
.errbar .rid{color:var(--text3);font-size:11px}
.actions{display:flex;align-items:center;gap:4px;flex:0 0 auto}
.ico{width:30px;height:30px;border:0;border-radius:8px;background:transparent;color:var(--text3);display:grid;place-items:center;cursor:pointer;font-size:14px}
.ico:hover{background:var(--panel2);color:var(--text)}
.primary{height:30px;padding:0 14px;border:0;border-radius:999px;background:var(--brand);color:#fff;font-size:12px;font-weight:600;cursor:pointer}
.primary:hover{filter:brightness(.96)}
.primary.ghostish{background:var(--panel);color:var(--text);border:1px solid var(--line2)}
.batchbar{position:fixed;left:50%;bottom:22px;transform:translateX(-50%);background:var(--panel);border:1px solid var(--line2);border-radius:12px;box-shadow:var(--shadow);display:flex;align-items:center;gap:10px;padding:8px 12px}
.batchbar .n{font-size:12px;color:var(--text2)}
.batchbar button{height:28px;padding:0 10px;border-radius:8px;border:1px solid var(--line2);background:var(--panel);color:var(--text);font-size:12px;cursor:pointer}
.drawer{position:fixed;top:0;right:0;bottom:0;width:400px;background:var(--panel);border-left:1px solid var(--line);box-shadow:-12px 0 32px rgba(16,24,40,.1);padding:18px;overflow:auto}
.drawer h3{margin:0 0 4px;font-size:15px}
.drawer .sub{color:var(--text3);font-size:12px;margin-bottom:14px}
.kv{display:grid;grid-template-columns:78px 1fr;gap:8px 10px;font-size:12px;margin-bottom:14px}
.kv .k{color:var(--text3)}
.kv .v{word-break:break-all}
.kv code{font-family:ui-monospace,Menlo,monospace;font-size:11.5px;background:var(--panel2);border:1px solid var(--line);border-radius:6px;padding:2px 6px}
.sect{font-size:11px;letter-spacing:.6px;color:var(--text3);margin:16px 0 8px}
.row2{display:flex;gap:8px;flex-wrap:wrap}
.warn{margin-top:10px;padding:8px 10px;border-radius:8px;background:var(--brand-weak);border:1px solid var(--brand-line);color:#8a5a00;font-size:11.5px}
.hint{position:fixed;right:16px;bottom:16px;font-size:11px;color:var(--text3);background:var(--panel);border:1px dashed var(--line2);border-radius:8px;padding:6px 10px}
</style>
</head>
<body>
<div class="app">
<aside class="rail">
<div class="logo"></div>
<button title="首页"><svg viewBox="0 0 24 24"><path d="M3 10.5 12 3l9 7.5"/><path d="M5 9.5V21h14V9.5"/></svg></button>
<button title="画布"><svg viewBox="0 0 24 24"><rect x="3" y="4" width="18" height="16" rx="2"/><path d="M3 9h18"/></svg></button>
<button class="on" title="任务队列(新增)"><svg viewBox="0 0 24 24"><path d="M4 6h16"/><path d="M4 12h16"/><path d="M4 18h10"/><circle cx="19" cy="18" r="2.2"/></svg></button>
<button title="插件"><svg viewBox="0 0 24 24"><path d="M12 3l8 4.5v9L12 21l-8-4.5v-9L12 3z"/><path d="M12 12l8-4.5M12 12v9M12 12L4 7.5"/></svg></button>
<div class="spacer"></div>
<button title="帮助"><svg viewBox="0 0 24 24"><circle cx="12" cy="12" r="9"/><path d="M9.5 9a2.5 2.5 0 1 1 3.6 2.3c-.7.4-1.1 1-1.1 1.8"/><path d="M12 17h.01"/></svg></button>
<button title="设置"><svg viewBox="0 0 24 24"><circle cx="12" cy="12" r="3"/><path d="M4 12h2M18 12h2M12 4v2M12 18v2"/></svg></button>
</aside>
<main class="main">
<div class="head"><h1>任务队列</h1><div class="right"><button class="ghost" id="themeBtn">切换深色</button><button class="ghost">全部重试</button><button class="ghost">清理已完成</button></div></div>
<div class="tabs"><button class="tab on">全部 <b>124</b></button><button class="tab">下载中 <b>1</b></button><button class="tab">失败 <b>1</b></button><button class="tab">已完成 <b>121</b></button><button class="tab">历史 <b>1111</b></button></div>
<div class="filters">
<button class="chip on">▾ 筛选</button><button class="chip on">图片</button><button class="chip">视频</button><button class="chip">音频</button><button class="chip">文本</button>
<label class="search">🔍<input placeholder="搜索提示词、文件名或原始链接"></label>
<div class="dates"><span>创建日期</span><span class="date">2026-12-01</span><span>至</span><span class="date">2026-12-02</span></div>
<button class="chip">多选</button>
</div>
<div class="list">
<div class="row sel" data-drawer="1"><div class="thumb"><div class="img"></div><span class="badge">下载 62%</span><div class="prog"><i></i></div></div>
<div class="body"><div class="title">去掉画面顶部的文案与文案的装饰,保留背景与商品和装饰内容。</div>
<div class="meta"><span class="state dl">下载中 62%</span><span>gpt-image-2.6</span><span class="dot"></span><span>1824×2288</span><span class="dot"></span><span>1.8 / 2.9 MB</span></div>
<div class="meta"><span>2026-12-02 11:04:10</span><span class="dot"></span><span>耗时 1m 13s</span><span class="dot"></span><a class="link">查看原始链接</a></div></div>
<div class="actions"><button class="ico" title="取消下载">×</button><button class="primary ghostish">暂停</button></div></div>
<div class="row" data-drawer="1"><div class="thumb"><div class="err">!</div><span class="badge">未落地</span></div>
<div class="body"><div class="title">减少图片边缘四周的植物,提高清晰度</div>
<div class="meta"><span class="state err">下载失败 · 已重试 3 次</span><span>gpt-image-2.6</span><span class="dot"></span><span>1824×2288</span></div>
<div class="meta"><span>2026-12-02 10:51:22</span><span class="dot"></span><span>原始链接仍可用</span></div>
<div class="errbar">连接超时(CDN 返回 504)<span class="rid">request id 202612020905172288</span></div></div>
<div class="actions"><button class="ico" title="复制链接">⧉</button><button class="ico" title="浏览器打开">↗</button><button class="ico" title="删除">🗑</button><button class="primary">重试</button></div></div>
<div class="row" data-drawer="1"><div class="thumb"><div class="img b"></div><span class="badge">2048</span></div>
<div class="body"><div class="title">去掉图片边缘四周的植物,提高清晰度</div>
<div class="meta"><span class="state ok">已完成</span><span>gpt-image-2.6-vip</span><span class="dot"></span><span>批量 1/1</span><span class="dot"></span><span>1824×2288</span><span class="dot"></span><span>2.9 MB</span></div>
<div class="meta"><span>2026-12-02 10:43:08</span><span class="dot"></span><span>58s</span><span class="dot"></span><a class="link">打开预览</a><span class="dot"></span><a class="link">原始链接</a></div></div>
<div class="actions"><button class="ico" title="下载原图">↓</button><button class="ico" title="复制链接">⧉</button><button class="ico" title="定位节点">◎</button><button class="ico" title="删除">🗑</button><button class="primary">插入画布</button></div></div>
<div class="row" data-drawer="1"><div class="thumb"><div class="img c"></div><span class="badge">2048</span></div>
<div class="body"><div class="title">扩图,向 4 周扩图</div>
<div class="meta"><span class="state ok">已完成</span><span>gpt-image-2.6-vip</span><span class="dot"></span><span>1868×2288</span><span class="dot"></span><span>3.2 MB</span></div>
<div class="meta"><span>2026-12-02 10:02:17</span><span class="dot"></span><a class="link">打开预览</a><span class="dot"></span><a class="link">原始链接</a></div></div>
<div class="actions"><button class="ico" title="下载原图">↓</button><button class="ico" title="复制链接">⧉</button><button class="primary">插入画布</button></div></div>
<div class="row" data-drawer="1"><div class="thumb"><div class="ph">本地已清理</div><span class="badge">仅链接</span></div>
<div class="body"><div class="title">去掉画面顶部的文案与文案的装饰,保留背景与商品和装饰内容。</div>
<div class="meta"><span class="state wait">仅保留链接</span><span>gpt-image-2.6</span><span class="dot"></span><span>1824×2288</span></div>
<div class="meta"><span>2026-12-01 16:58:23</span><span class="dot"></span><a class="link">复制原始链接</a><span class="dot"></span><span>可重新下载</span></div></div>
<div class="actions"><button class="ico" title="复制链接">⧉</button><button class="primary">重新下载</button></div></div>
<div class="row" data-drawer="1"><div class="thumb"><div class="img"></div></div>
<div class="body"><div class="title">把背景换成浅灰色,保留商品与投影</div>
<div class="meta"><span class="state ok">已完成</span><span>gpt-image-2.6</span><span class="dot"></span><span>1536×1536</span><span class="dot"></span><span>1.4 MB</span></div>
<div class="meta"><span>2026-12-01 15:20:44</span><span class="dot"></span><span>47s</span><span class="dot"></span><a class="link">打开预览</a></div></div>
<div class="actions"><button class="ico" title="下载原图">↓</button><button class="primary">插入画布</button></div></div>
</div>
</main>
<aside class="drawer" id="drawer">
<h3>去掉图片边缘四周的植物,提高清晰度</h3>
<div class="sub">2026-12-02 10:43:08 · 58s · gpt-image-2.6-vip</div>
<div class="kv">
<div class="k">原始链接</div><div class="v"><code>https://cdn.example.com/gen/8f3a…-1824.png</code></div>
<div class="k">本地副本</div><div class="v">已落地 · 2.9 MB · <code>__blob:3f7c…</code></div>
<div class="k">显示层</div><div class="v">长边 2048(≈9 MB 纹理,导出仍用原图)</div>
<div class="k">来源</div><div class="v">节点「出图 3」 · 画板「主图」</div>
</div>
<div class="sect">操作</div>
<div class="row2"><button class="primary">插入画布</button><button class="chip">复制图片</button><button class="chip">复制链接</button><button class="chip">下载原图</button></div>
<div class="sect">重新获取</div>
<div class="row2"><button class="chip">重新下载(覆盖本地)</button><button class="chip">仅保留链接</button></div>
<div class="warn">本地字节被清理后,这条会变成「仅保留链接」;原始链接随时可重新下载,不会丢。</div>
</aside>
</div>
<div class="batchbar"><span class="n">已选 1 项</span><button>插入画布</button><button>批量下载</button><button>复制链接</button><button>删除</button></div>
<div class="hint">mockup:点行看详情 · 右上角切换深色</div>
<script>
var html=document.documentElement;
document.getElementById("themeBtn").onclick=function(){html.dataset.theme=html.dataset.theme==="dark"?"light":"dark";this.textContent=html.dataset.theme==="dark"?"切换浅色":"切换深色"};
document.querySelectorAll(".tab").forEach(function(b){b.onclick=function(){document.querySelectorAll(".tab").forEach(function(x){x.classList.remove("on")});b.classList.add("on")}});
document.querySelectorAll(".row").forEach(function(r){r.onclick=function(e){if(e.target.closest("button"))return;document.getElementById("drawer").style.transform="none"}});
</script>
</body>
</html>
+254
View File
@@ -0,0 +1,254 @@
# 质量与性能优化计划(2026-12-02,执行中 · 未提交)
> 依据:`performance-lessons-2026-12-01.md`、`workflow-2026-12-02.md`、2026-12-02 代码体检与插件调用面取证。
> 状态:第 0 步 + A 已提交并出包 3.26.183(Windows 包已验证通过);A2 + B 本轮完成(未提交);C 未开工。
## 0. 体检结论(含门禁现状)
- `app.js` 8,939 行(单文件装配,不在 tsc 范围);`src/` 123 个模块;单测 139 个文件。
- `tsc` / `eslint` 通过。**但 `verify:ci` 在 HEAD 上是红的**,共 4 处,不能拿「全绿」当基线:
1. `source-text-ratchet`:app.js 8,939 > 上限 8,743(174–182 连续修 bug 期间累积 +196,未记账)。
2. `architecture-facts-guard` §3:视口裁剪守卫还在找 `- pad / + pad` 文本,`cullRectsOf` 已重构成 `const p = pad + extra`(行为等价,守卫文本过期)。
3. `architecture-facts-guard` §6:`architecture-current-state.md` 里的棘轮数字(appLines / workbenchLines / sharePct / srcLines)过时。
4. `architecture-facts-guard` §7:文档未记录基线 SHA `738b70c5`。
- `preflight` 仅因 `src-tauri/Cargo.lock` 有一行构建残留(3.26.180→3.26.182)而红,已还原。
- 近两天 4 个线上问题全部落在同一条图片链路:取图 → 缩略图 → 写回 → 节点渲染。
## 1. 范围
| 编号 | 事项 | 产出 |
| --- | --- | --- |
| 0 | 门禁恢复绿 | 棘轮记账、守卫文本、事实文档、Cargo.lock |
| A | 图片写入路径收口 | `src/image-writeback.js` + 单测 |
| A2 | 插件批次(解耦,不占出包) | white-bg-800 1.2.3、blank-canvas 1.0.1 |
| B | preflight 强化 | 文档过期词扫描 + `global.*` 只减不增 |
| C | 性能回归入口 | 扩展 `_perf-baseline.spec.js` 帧探针断言 |
不做(另排):发布脚本固化(`release:desktop`)、远程图纹理长边限制、`src` 开 `noImplicitAny`。
## 2. A|图片写入路径收口
### 2.1 插件调用面取证(12 个插件实测)
| 能力 | 使用方 | 结论 |
| --- | --- | --- |
| `setNodeImage` | blank-canvas、white-bg-800 | **同步返回布尔**,必须保持同步 |
| `saveNodeImage` | image-annotate(+ setNodeImage 兜底) | 唯一关心落盘结果的插件 |
| `createImageNode` | white-bg-800、image-annotate、image-vectorize、xianyi-cutout、style-source、promptlib | 只用返回 id/布尔 → 宿主引用化对插件透明 |
| `getNodeImage` | 上述 + batch-export、ai-chat | 只读;`nodeImageOf` 走 `refDataUrl`,引用化后仍返回 dataUrl |
| `ctx.images.*` | 仅 album | 本来就走 `wImportImage` 引用式,与写回不交叉 |
### 2.2 三条硬边界
1. **`setNodeImage` 不得改成异步**:`blank-canvas/src/index.js:90`、`white-bg-800/src/index.js:273` 都是 `if (!setNodeImage(...)) throw`;返回 Promise 会恒真、错误静默,image-annotate 的兜底三元也会误判。它只能是同步包装:改内存(commit 一次)+ 失效缓存 + bump,**不调 saveNow**。
2. **`createImageNode` 目前完全不做引用化**:白底新建(`replace` 默认 false)、抠图、矢量化、风格图、提示词封面都把几 MB base64 直接写进 `node.data.data` —— 与标注同源。宿主内部异步引用化对 6 个调用点零改动。
3. **`orig` 备份是 182 的隐性坑**:首覆盖把旧图整串塞进 `data.orig`(工作区 JSON 多一份);第二次覆盖时 `prev.data` 已是引用对象,`typeof === 'string'` 不成立 → orig 判空,右键「还原替换前原图」静默消失。
### 2.3 三个入口(`src/image-writeback.js`)
- `replaceNodeImage(id, dataUrl)`:`await importer(keepOriginal)` → 组装 patch(`data/url/localRef/ref` 同指一个引用,orig 一并引用化)→ `commitCanvas` 一次 → `saveNow` → 回读校验,失败回滚旧图并返回原因 → 失效缩略图(**旧值 key + 新值 key,双档**)→ `bump` → 写 `plugin-img` 日志。
- `replaceNodeImageSync(id, dataUrl)`:同步 patch + 失效 + bump,返回严格布尔;仅当 `length > inlineMax` 时后台引用化(同样的 commit 通道,靠防抖落盘)。
- `createNodeImage(payload)`:同步建节点返回 id;`length > inlineMax` 时后台引用化并 `bump`。
### 2.4 阈值唯一口径
**唯一判据 = `wImportImage` 的内联阈值 `IMPORT_INLINE_MAX`(字符数,现 3000)**,超过即引用化。
- 引用化一律走 `wImportImage(dataUrl, { keepOriginal: true })`(无损、不重压缩、含 `{__blob}` 主通道与 `{__cache}` 兜底)。
- **删除 182 里那处裸 `wImgRefWrite` + `200 * 1024` 字符阈值的旁路**,不留第二套。
- `inlineMax` 由 `app.js` 从同一个常量注入,模块内不写字面量。
### 2.5 `orig` 读取点盘点(收口前逐个改)
| 位置 | 用途 | 处理 |
| --- | --- | --- |
| `app.js` `origImagePatch` | 写入 | 迁进模块;旧图走同一 importer 引用化,已是引用则原样保留 |
| `app.js` 右键「还原替换前原图」 | 读取/回填 | 改为 `wImgRefDataUrl` 解析(string/ref 都支持),回填后同样引用化 |
| `src/runtime-workbench-logic.js` `dataOk` 校验 | 读取比较 | 保持引用比较(`sd.orig !== prev.orig`) |
| `src/runtime-workbench-logic.js` `HISTORY_IMG_REF_FIELDS` | 撤销快照引用化 | **补 `'orig'`**(现在漏了 ⇒ 每次覆盖都在历史里留一整串 base64) |
### 2.6 文档修正(本轮一起做)
- `docs/standards/plugin-development.md:53,57`:`canvasWrite` 已合并进 `ctx.canvas`(`src/plugin-host.js:8`),旧写法会让新插件调 `ctx.canvasWrite.setNodeImage` 直接报「宿主不支持」。
- 同文档补两行契约:`setNodeImage` = 同步、不落盘;`saveNodeImage` = 落盘 + 校验 + 失败回滚。
- 补一句 `getNodes()` 返回的 `data` 是只读视图(实际目前是同一对象引用,见 §9 记录,本轮不改)。
### 2.7 单测(`tests/image-writeback-test.js`,5 条具体断言)
1. `replaceNodeImageSync` 返回**严格布尔**(`typeof === 'boolean'`、不是 Promise),`saveNow` 调用 0 次(不落盘),`commitCanvas` 恰好 1 次(UI 必须更新,这里的「不提交」只指不落盘)。
2. `replaceNodeImage` 成功后 `data / data.localRef / data.ref` 三者是同一个引用对象,且节点里没有 `data:` 字符串残留。
3. 覆盖两次:第一次把旧图变成 `orig` 引用;第二次 `orig` 仍是引用(不是 base64、不丢),且还原动作能解析回原图。
4. 阈值唯一:`length <= inlineMax` 时不产生引用(不调 importer);`> inlineMax` 时恰好调一次 importer。
5. 双 key 失效:旧值 key 与新值 key 都被失效(引用对象也取得到 key),512/256 两档都删。
> 门禁联动:新测试文件必须加进 `package.json` 的 `test:unit`(`architecture-facts-guard` 查「无孤儿单测」);`source-text-ratchet` 里 `saveNodeImage` 相关文本钉点按实测收紧。
### 2.8 行数棘轮处理
搬走写回装配约 −70 行后仍有差额(8,939 → ≈8,869,上限 8,743)。处理方式:
- 本轮**显式上调** `MAX_APP_JS_LINES` 到实测值(零余量),注释写清:174–182 修 bug 期间 +196 未记账、本轮搬走写回装配 −70、剩余 +126 显式记账,后续按 domain 拆回落。
- 不新增任何 app.js 逻辑;A 项之后 app.js 只减不增。
## 3. A2|插件批次(与出包解耦)
- **white-bg-800 1.2.3**:覆盖模式改「`saveNodeImage` 优先 + 老宿主 `setNodeImage` 兜底」(与 image-annotate 同款三段式),失败要有可见提示。
- **harness 必须双形态参数化**(2026-12-02 补):市场窗口期用户可能仍跑 3.26.182(无 `saveNodeImage` 的新语义),所以 mock 要按 `hostKind` 跑两遍 ——
① 新宿主:有 `saveNodeImage`(返回 `{ok,error}`、会校验落盘);断言「走 saveNodeImage 时 setNodeImage 调用 0 次」、失败时把 error 抛给用户;
② 老宿主:没有 `saveNodeImage`;断言回落到同步 `setNodeImage` 且仍返回 `true`。
只覆盖一种形态等于另一半永远假通过。
- **blank-canvas 1.0.1**:空白判定从 `!data.data && !data.url` 加上 `localRef / ref`,避免只有本地引用的节点被误判为空、被白图覆盖。
- image-annotate 不改。
- 插件不进安装包(`beforeBuildCommand` 已剥离 `dist/plugins`),两仓可并行推进;但**插件改动必须各自过 harness/测试**才算完成。
## 4. B|preflight 强化
**B1 文档过期词扫描**:扫 `README.md` / `CONTRIBUTING.md` / `PUBLISHING.md` / `docs/standards` / `docs/reference`(排除 `archive`、`history`、`CHANGELOG`),命中即 FAIL:
`functions/api`、`functions/plugins`、`verify:release`、`plugins-publish`、`wrangler`、`_inbox`。行内含 `~~` 或「已删除/已下线/已停用」时豁免。
**B2 `global.*` 棘轮**:统计 `src/*.js` 的 `global.X =`(实测 119),写成常量只减不增;新增需同批下调基线。
**B3 棘轮上调必须自证(2026-12-02 补,针对「谁写谁抬」)**:`MAX_APP_JS_LINES` / `MAX_WORKBENCH_LINES` / `MAX_SRC_COMPONENT_LINES` 这一行
必须同时含「日期 + 行数差 + 原因」,否则 CI 红。判据:该行能匹配 `\d{4}-\d{2}-\d{2}`、`[+-]\d+`、且长度 > 40 字。
目的:上调本身仍是一次**显式记账**(评审能在 diff 里看到日期和差额),而不是把上限改成一个更大的数字了事。
验收:`npm run preflight` 通过;故意加一行 `global.FooBar =` 会红;故意写 `verify:release` 会红;把某条棘轮上限改大但删掉「日期/差额」→ 红(B3)。
## 5. C|性能回归入口
扩展既有 `tests/_perf-baseline.spec.js`(7k 节点平移、可选 CPU/VISUAL/PROFILE,已被 `list-e2e-specs.js` 排除,不进 CI):
1. 复用平移段,开 `iwb_perf_probe` 后读 `window.IWBPerf.recent`;
2. 新增断言:`long` 帧比例与 `js` 总时长上限(阈值先宽,跑稳再收紧);
3. `IWB_PROBE_LIGHT=1` 作为日常快速档。
验收:本地跑出基线并记录;连续两次差异 <20%。
## 6. 出包口径(Windows 侧)
- A 项改宿主代码 ⇒ 完工后出新版本 **3.26.183**,三处同步:`package.json` / `src-tauri/tauri.conf.json` / `src-tauri/Cargo.toml`(`preflight` 第 2 项校验这三处);`src-tauri/Cargo.lock` 由构建改动,**交付前还原**。
- win 侧只出 NSIS x64:不签名、不产 `.sig`、不动 `latest*.json` / `releases.json` / 站点。
- mac 侧交付时给:基线 commit + 三处版本号;win 侧回:路径 / 字节 / sha256 / FileVersion。
- 插件批次不占出包,单独走市场。
- **183 出包前若还要动 app.js,棘轮必红**(上限已等于实测、零余量):必须在**同一次提交**里同步上调 `MAX_APP_JS_LINES` / `MAX_WORKBENCH_LINES`,并按 B3 写清「日期 + **相对上一版上限**的差(如 +196 / −28)+ 原因」,别等 CI 红了临时抬;差值不要写成相对 HEAD,否则基线一漂就没人能核对。
- **提交 3.26.183 之后必须同步基线锚点**:`docs/standards/architecture-current-state.md` 第 4 行的 `main = <sha>` 要指向**这次 bump 提交**,
否则 `npm run test:facts` 会红(守门第 7 组)。当前锚点是 `main = 738b70c5`(最近一次 bump,v3.26.182 的提交),A 项未提交期间这是正确的。
## 7. 执行顺序与检查点
0. 门禁恢复绿(§0 的 4 处)→ `npm run test:facts` + `node tests/source-text-ratchet-test.js` 绿
1. A 代码 + 单测 → `node --check app.js`、新单测、棘轮
2. A2 插件仓(独立,各自 harness 绿)
3. B → `npm run preflight`
4. C → `IWB_PROBE_LIGHT=1` 记录基线
5. 收尾:更新 `performance-lessons`(每项 3 行)
每步不过就停。
## 8. 交付物
- 代码:`src/image-writeback.js`、两处调用改造 + `createImageNode` 引用化、`orig` 四处读取点、`tests/image-writeback-test.js`、preflight 两条检查、`_perf-baseline` 扩展
- 文档:本计划、`plugin-development.md` 修正、`architecture-current-state.md`(sync-facts)、执行小结
- 插件:white-bg-800 1.2.3、blank-canvas 1.0.1
## 9. 复查记录
**第 1 遍(正确性与风险)**
- A 是搬移 + 固定顺序,唯一行为变化是「引用化提前到落盘前」与「orig 也引用化」;回滚为 revert 两个调用点。
- B1 有误报风险(历史引用旧词)→ 只扫现行文档 + 删除线/已删除词豁免。
- C 在 CI 无 GPU 环境不稳定 → 不进 CI 必跑,只作真机回归。
- 结论:无阻断风险。
**第 2 遍(覆盖与顺序)**
- C 不新建 spec:扩展 `_perf-baseline.spec.js` 口径更统一。
- A 新单测必须加进 `test:unit`,否则孤儿门禁红。
- A 会动源码棘轮钉点,需按实测收紧。
- 顺序 0→A→A2→B→C 合理:门禁先绿,B 的基线才可信。
- 结论:补齐后可行。
**第 3 遍(插件面与出包口径,2026-12-02 补)**
- 插件侧只有 3 个写回点;其中 2 个依赖同步语义 ⇒ `setNodeImage` 保持同步是**契约红线**,不是实现偏好。
- `createImageNode` 覆盖面比写回更广(6 个插件),必须一起做,否则「白底/抠图/矢量化」仍是同一根因。
- orig 有 4 个读取点,漏一个就会复现「第二次覆盖静默失效」+ 历史快照存 base64,故列为盘点项。
- 门禁在 HEAD 上已红 ⇒ 增加第 0 步;否则 A 完成后无法用 `verify:ci` 证明没有回归。
- 插件批次不占出包,可与 3.26.183 并行,但 harness mock 修复是验收项(否则假通过)。
- 结论:可执行。
## 10. 执行记录(2026-12-02)
### 已完成
**第 0 步|门禁恢复绿**
- `src-tauri/Cargo.lock`:还原构建残留(工作区该行不计入改动)。
- `tests/architecture-facts-guard-test.js`:裁剪矩形守卫从 `- pad / + pad` 改为「先认 `const p = pad + extra`,再数 4 条边按 p 收放」(`cullRectsOf` 早已重构成局部变量 p,守卫文本过期)。
- `docs/standards/architecture-current-state.md`:锚点改为 `main = 738b70c5`;计数/棘轮数字用 `node scripts/sync-facts.js --write` 复算。
- `tests/fixtures/iwb-source-modules-order.json`:补 `image-writeback.js`(顺序与 build.js 一致);耦合面快照用 `IWB_WRITE_BOUNDARY_SNAPSHOT=1` 更新(新增 `IWBImageWriteback`)。
- 结果:`test:facts`、`source-text-ratchet`、`architecture-boundary-guard` 全部通过。
**A 项|写回收口**
- 新增 `src/image-writeback.js`(184 行,三入口 + restoreOrig),注册进 `scripts/build.js`。
- `app.js`:删除 `origImagePatch` 与三个写入口的旧实现,改为装配 `IWBImageWriteback`;右键「还原替换前原图」改走 `restoreOrig`(支持引用形态)。
- `src/runtime-workbench-logic.js`:删除搬走的 `saveNodeImage`;`HISTORY_IMG_REF_FIELDS` 补 `'orig'`(撤销快照不再整串存旧图)。
- 阈值:只有 `IMPORT_INLINE_MAX` 一条判据,引用化统一走 `wImportImage(keepOriginal)`;**182 的 200KB + 裸 `wImgRefWrite` 旁路已删除**。
- `createImageNode` 大图后台引用化(6 个建图插件零改动)。
- 文档:`docs/standards/plugin-development.md` 修正 `ctx.canvasWrite` 旧写法 + 新增「图片写回契约」表(含 setNodeImage 同步不落盘、saveNodeImage 落盘校验、getNodes 只读);`docs/PLUGIN-SDK.md` 同步。
- 单测:`tests/image-writeback-test.js`(21 条断言,覆盖 §2.7 五条契约)已进 `test:unit`。
**行数记账**
- `MAX_APP_JS_LINES`:8,743 → **8,911**(实测;174–182 累积 +196 未记账,本轮搬走写回装配 −29,剩余 +168 显式记账)。
- `MAX_WORKBENCH_LINES`:2,333 → **2,505**(= 本轮实测 2,505;HEAD 是 2,524,本轮 −19,所以 2,505 并不小于实测,二者相等)。
- 两个上限当前都是**零余量**(上限 == 实测)。这是本仓既有纪律(守卫文件里写明「上限取实测值本身,留 0 余量」);
针对「谁写谁抬」的风险,B3 会把「上调必须带日期+行数差记账」变成机械检查。
### 验证结果
- `npm run build` + `node scripts/check-dist.js`:通过;dist 内含 `IWBImageWriteback`,`node --check dist/app.js` 通过。
- `npm run lint` / `npm run typecheck`:通过。
- `npm run test:unit`(140 个文件)与 `npm test`:通过。
- `npm run test:facts` / `node tests/source-text-ratchet-test.js` / `node tests/architecture-boundary-guard-test.js` / `node scripts/ctx-menu-audit.js` / `tokens:check` / `check-plugins-sync`:通过。
- `preflight`:仅「存在未提交改动」一项红(未提交阶段预期);提交后应转绿。
### 未做(等确认)
- A2 插件批次(white-bg-800 1.2.3 / blank-canvas 1.0.1,在插件仓,需发市场)。
- B preflight 两条检查;C `_perf-baseline` 扩展。
- 3.26.183 版本号三处 bump(出包前做,避免提前改版本号)。
### A2|插件批次(2026-12-02 完成,未发市场)
- **white-bg-800 1.2.3**:覆盖模式改「`saveNodeImage` 优先 + 老宿主 `setNodeImage` 兜底」;harness 双形态(new/old)跑通:
new 断言「saveNodeImage 1 次 / setNodeImage 0 次」、落盘失败必须把宿主原因抛给用户;old 断言回退同步写回仍成功。
顺带修了 harness 两处早已过期的断言(version 写死 1.2.0、icon 写成 fit)——说明这份 harness 之前没人跑,现已全绿。
- **blank-canvas 1.0.1**:空白判定改为「data / url / localRef / ref 四者皆无」,避免只有本地引用的节点被白图覆盖。
- 插件仓提交 `e2982e3` 已推 gitea;宿主的 `plugins/` 产物已 `sync-plugins-from-repo` 同步。
- **已发布市场(2026-12-02)**:white-bg-800 1.2.3 / blank-canvas 1.0.1 已上传 `market.maqiart.eu.org`(index.json + zip + 旧版单文件产物 + 展示页),并回读校验(索引版本对得上、下载 zip 的 sha256 == 索引 bundleSha256);下载站插件页同步更新。
### B|preflight 强化(2026-12-02 完成)
- **B1 文档过期写法**:preflight 第 6 项扫 `README/CONTRIBUTING/PUBLISHING/docs/standards/docs/reference`,
命中 `functions/api`、`functions/plugins`、`verify:release`、`plugins-publish`、`wrangler`、`_inbox` 即红(删除线 / 已弃用等豁免)。
首次运行就抓到 4 处真实过期内容(仍在教人用 NAS `_inbox/` 取件),已一并改为 tailnet HTTP 流程。
- **B2 `global.*` 写入口棘轮**:`src/*.js` 的 `global.X =` 实测 122,写成常量只减不增(已试:+1 即红)。
- **B3 棘轮上调必须自证**:`MAX_APP_JS_LINES` / `MAX_WORKBENCH_LINES` / `MAX_SRC_COMPONENT_LINES` 行必须含
「日期 + 相对上一版的差(或基线说明)+ 原因」,否则红(已试:改成 9000 且无注释 → 立刻红)。
### C|性能回归入口(2026-12-02 完成)
- `IWBPerf` 新增只读 `snapshot()`(结构化读数 + 清零),与 60s 落盘窗口解耦,不影响 `_boot.log` 格式。
- `tests/_perf-baseline.spec.js`:平移段前后取快照,新增 3 条断言 —— `frames > 30`(防探针没启动导致「0 长帧」假绿)、
长帧比例 ≤ 40%、longtask 总时长 ≤ 2500ms;快照同时写进 `P1_BASELINE=` 便于历史对比;`IWB_PROBE_PERF=0` 可只测不断言。
- `scripts/perf-baseline.js` + `npm run perf:baseline`:build → 动态端口起本地服 → 只跑该 spec → 关服(不用再开两个终端)。
- 实测(本机 headless,7000 节点 / 12 步平移,三次):长帧 13~17 / 帧 57~59(22.8%~30.9%)、longtask 25 次 / 1905~1934ms、最长帧 ~400ms。
阈值取「实测最大值 ×1.3" → 40% / 2500ms;换机器必须重设基线(写进注释)。
- 仍不进 CI(无头环境无 GPU,数字不可比),只作真机回归。
### D|app.js 拆分:插件画布桥(2026-12-02 完成)
- 新增 `src/plugin-canvas-bridge.js`:把 `wPluginCanvasBridge`(getNodes / getSelectedNode / getNodeImage / createNode / screenToWorld / createImageNode / setNodeImage / saveNodeImage)
与图片写回装配整体迁出 Workbench,模块只做装配、依赖全部注入。
- app.js 8,911 → 8,860(−51),Workbench 2,505 → 2,454(−51),两个棘轮上限同步收紧(B3 记账)。
- 顺带删掉两个从未被引用的工厂导出(`IWBStorageRuntimeFactory` / `IWBRuntimeMetricsFactory`),
`global.*` 写入口 122 → 121(新模块 +1,删死导出 −2)。
- 验证:test:unit 140 文件、e2e 冒烟 33 条、lint/typecheck/facts/ratchet/boundary 全绿。
注:冒烟必须用 `npm run build`(含 copy-plugins),只跑 build.js 会缺 plugins/,图库面板相关 3 条会假红 —— 已把它写进 perf 脚本。
### E|插件 harness 巡检(2026-12-02 完成)
- 10 个插件 harness 全跑一遍:4 个绿、6 个长期假红(说明没人跑)。逐条判定后**全部是测试过期**,不是插件回归:
- album:写死版本 1.1.2(实为 1.2.5);`addPaths` 涨到 36 行导致 900 字符窗口不够;缩略图写入形态改成 `ctx.files.put(thumbNameOf(key, ext), url)`
- gallery / promptlib:同样写死版本
- style-source:要求 chips「必须一行」(当时 9~10 个标签),标签涨到 13 个必然换行 → 改钉「不溢出 + 行数 ≤3」
- image-vectorize:11-19 起「取消」改名「关闭」并用主色区分,「四颗同色」规则已作废
- sticky:改成纯节点类型后不再注册面板,harness 仍要求 panels 并在 `panelApi.mount` 崩
- 修复原则:**测试只钉「会真出错的点」**(两处版本一致、不溢出、顺序与区分色),不再钉死具体版本号与当时的布局数值。
- 复跑 10/10 全绿(插件仓 `4f7bb25`)。
+108
View File
@@ -0,0 +1,108 @@
# 任务队列(左栏整页插件)执行计划 · 2026-12-03
> 上游讨论:`docs/plans/task-queue-plan.md`(2026-12-02)、`docs/mockups/task-queue-v2.html`。
> 本文是**本次实施口径**:宿主记账 + 插件整页 + 左栏入口;图库保持「只显示已落地」。
## 1. 目标 / 非目标
**目标**
- 记录每一次生成结果(url、状态、画布/节点、时间、模型/尺寸),全局跨画布。
- 记录由**宿主**保存;插件关闭也继续记录,重新开启即可看到历史。
- 左栏一级入口「任务队列」(插件整页),可启用/禁用。
- 行内主操作「下载」= 落地到 `images/gallery`,图库自动刷新出现。
- 支持「重试 / 复制原始链接 / 定位节点 / 点击缩略图预览」。
- 记录上限可在插件页设置(宿主配置),超限淘汰最旧;淘汰不影响图库文件。
**非目标**
- 不做自动对账(图库保持只读展示,不扫描、不补录)。
- 不处理本版本之前的旧记录(无 meta 显示「未知画板」)。
- 不做详情抽屉、批量选择、进度详情页。
- 不新增下载器:复用 `image-ingest`。
## 2. 数据与存储
- 账本:沿用 `image-ingest-store`(全局 key `iwb_ingest_idx`)。
- 新增 meta(入队时写):`boardId / boardName / nodeId / prompt / model / size / at`。
- 桌面端独立文件:`src/storage-file.js` 的 `LIB_FILES` 增加
`iwb_ingest_idx: 'task-queue/index.json'`(不塞 data.json)。
- 上限:配置 `canvas.taskQueueMax`,默认 500,范围 100~5000;store 写入时按上限淘汰最旧(不删图片)。
- 备份/导出:确认包含 `library/task-queue/index.json`,不包含则补清单。
## 3. 宿主能力
### 3.1 `queue` 能力(新)`src/plugin-api-queue.js`
- `list({status, limit, query})`:返回账本记录(含 meta、状态、url、`thumbUrl`:仅 ready 的本地缩略图/objectURL)。
- `retry(id)`:重新入队。
- `land(id)`:建图库索引行(按 url 幂等)→ 入队 → 已有本地字节则立即补写;图库自动刷新。
- `preview(id)`:用现有 `ImagePreview` 打开,列表=所有可预览记录(本地优先,否则远程 url)。
- `copyLink(id)`:复制完整原始链接(页面不展示链接)。
- `locate(id)`:按 `boardId` 切画布、加载后选中 `nodeId`;画布/节点缺失返回错误。
- `stats()`:各状态计数。
- `clear()`:清空非进行中的记录(不动图库/文件)。
- `getLimit()/setLimit(n)`:读写 `canvas.taskQueueMax`,立即裁剪。
- `onChanged(fn)`:订阅账本变更(下载进度/状态)。
### 3.2 `pages` 能力(新)
- `plugin-host.js`:`CAPABILITIES` 加 `pages`,`CAPABILITY_API_KEYS.pages = 'ui'`。
- 插件 `ctx.ui.registerPage({id,title,icon,mount})`;禁用插件自动移除;若当前正停在该页,自动切回画布。
- `ui-nav-rail.js` 增加插件页图标;app.js 增加 `pluginPage` 状态与页面容器(`.iwb-plugin-page`)。
## 4. 插件 `taskqueue`(左栏整页)
- 源仓:`~/open/github/iwb-plugins-desktop/taskqueue`(package.json + src/index.js + styles.css)。
- 清单:`capabilities: ['pages','queue']`,page `{id:'taskqueue', title:'任务队列', icon:'list'}`。
- UI 按 `docs/mockups/task-queue-v2.html`:
- 页签:全部 / 已完成 / 下载中 / 失败 / 仅记录(计数)。
- 行:缩略图(可点击预览)、标题、状态徽标、画布·时间·尺寸/模型;失败行错误摘要。
- 操作:**下载**(主)/ 重试 / 复制原始链接 / 定位;删除态提示「画布已删除 / 节点已删除」。
- 顶部:记录上限下拉(200/500/1000/2000/5000)、清空记录。
- 颜色/字体/圆角/间距全部用 `var(--iwb-*)`;结构尺寸可字面量(与 gallery 一致)。
## 5. 代码改动清单
| 文件 | 改动 |
| --- | --- |
| `src/image-ingest-store.js` | 上限可注入(函数)、`trim()`、`clear()`;meta 透传 |
| `src/image-ingest.js` | `enqueue` 支持 meta;`clearFinished()`(保留进行中) |
| `src/storage-file.js` | `LIB_FILES` 加 `iwb_ingest_idx` |
| `src/runtime-workbench-logic.js` | `liveUpsert` 入队时补 board/node/prompt/model/size meta |
| `src/plugin-api-queue.js`(新) | queue 能力桥(setImpl/api/emit) |
| `src/plugin-api-pages.js`(新)或并入 plugin-host | pages 注册桥 |
| `src/plugin-host.js` | 注册 `queue` / `pages` 能力 |
| `src/ui-nav-rail.js` | 渲染插件页入口 |
| `app.js` | queue/pages 能力实现;land/preview/locate/clear/limit;页面状态与容器;ingest onEvent 通知插件 |
| `plugins/taskqueue/*`(新) | 整页插件 |
| `plugins/index.json` / `manifest` / `market` | 新插件产物与市场 |
| `tests/*` | queue 能力契约、插件渲染/空态、上限裁剪、locate 错误 |
| docs | 本计划、CHANGELOG、锚点/事实同步 |
## 6. 关键实现口径
- `land(id)`:`wAddOutputs([{ok:true,url,...}])`(幂等)→ `enqueue({url,source:'task-queue'})` → 若 view 已 ready 立即 `wFillOutputFromIngest`;图库靠 `wGalleryChanged` 自动刷新。
- 预览:`setPreview({list, idx})`,list 项 `{url, w, h, name}`;本地 ready 用 `wResolveImg(ref)`,否则用原始 url;失败提示「预览失败」。
- `locate`:`setActiveWsId(boardId)` → `openTab` → `loadWsInto` → 等加载 → `setSel([nodeId])` + 居中;失败返回 `{ok:false,error}`。
- 上限:`setLimit` 写配置并 `store.trim()`;插件页只调用 API。
- 账本淘汰只删记录,不删 `images/gallery`、不动图库索引。
- 插件禁用:账本继续记录(宿主),页面入口消失;重新启用可见历史。
## 7. 验收
1. 生成 1 张:左栏任务队列出现 1 条;点「下载」→ `images/gallery` 出现、图库自动显示;重复点不产生第二条/第二份文件。
2. 失败记录:状态失败 + 错误摘要;点重试成功;复制链接可用。
3. 点击缩略图打开预览;本地秒开,仅记录走远程;失效提示。
4. 定位:跳到对应画布并选中节点;画布/节点删除时提示。
5. 上限改 200:记录裁剪到 200 条,图库文件不变。
6. 禁用插件:记账继续(上限内);启用后历史仍在。
7. 跨画布:在 A 画布生成、切到 B 画布,队列仍能看到 A 的记录并定位。
8. 门禁:build / eslint / typecheck / 单测 / tokens / plugin 契约 / facts。
## 8. 交付节奏
- 代码 + 本地验证完成 → 通知用户,**不构建**;等用户确认后再 bump 版本、出测试包、发插件市场。
## 9. 实施状态(2026-12-03)
- 已完成:宿主 `queue`/`pages` 能力、账本 meta/独立文件 `library/task-queue/index.json`、上限配置 `canvas.taskQueueMax`、左栏整页插件 `taskqueue 1.0.0`、下载落地/预览/定位/复制链接/清空/重试、真实应用页面与注入记录验证。
- 待确认:bump 版本、出测试包、上传插件市场(taskqueue 1.0.0)。
+97
View File
@@ -0,0 +1,97 @@
# 任务队列(左栏页)方案 · 2026-12-02
> 交互样式见 docs/mockups/task-queue.html(可点行看详情、右上角切深色),截图 task-queue-light.png / -dark.png。
> 本文只谈设计与落地口径,代码未动。
## 1. 定位
左栏新增一级入口「任务队列」:记录**每一次收到图片链接的事实**——生成结果、插件产出、外链参考图——
即使本地字节被清理,也能从原始链接重新取回;并能定位到画布上对应的节点。
它不是一个新系统,而是「结果落地管线」的**账本 + 操作台**:
- 执行器:src/image-ingest.js(后台下载 / 重试 / 断点恢复)
- 账本:src/task-queue-store.js(一条记录 = 一次 ingest 任务)
- 界面:src/ui-task-queue.js(本方案)
## 2. 数据模型(一条记录)
| 字段 | 说明 |
| --- | --- |
| id / createdAt / updatedAt | 记录标识与时间 |
| source | gen(生成)/ plugin(插件产出)/ remote-ref(外链参考)/ manual(手动导入) |
| status | queued / downloading / ready / failed / link-only / missing |
| url | **原始链接,永不改写**(生成/导出/重试都以它为准) |
| localRef / displayRef / thumbRef | 原图字节 / 显示层(长边 2048)/ 缩略图(320) |
| bytes / sha256 / w / h / mime | 落地后回填 |
| prompt / model / size / batch / durationMs | 生成信息,用于搜索与展示 |
| nodeId / boardId / wsId | 定位到画布节点 |
| retries / lastError / requestId | 失败可诊断 |
| pinned | 被画布或图库引用时置位,清理时跳过 |
## 3. 状态机
queued → downloading(进度) → ready →(清理策略触发)→ link-only
↘ failed(重试 1s/2s/4s,最多 3 次)
ready/link-only →(字节丢失)→ missing(可一键回源)
- 幂等键:记录 id;同一 url 重复触发不重复下载
- 断点:任务表落 IDB,重启后 queued 继续、downloading 重新排队
- 原子写:临时键 → 校验 bytes(有 content-length 比对)→ 提交索引 → 才算 ready
## 4. 交互(对照样式图)
1. 左栏第 3 个图标(列表+圆点)→ 整页;与首页/画布/插件同级
2. 顶部页签:全部 / 下载中 / 失败 / 已完成 / 历史,均带计数
3. 筛选行:类型 chips(图片/视频/音频/文本)、搜索(提示词 / 文件名 / 原始链接)、创建日期区间、多选
4. 行结构:缩略图(下载中叠进度条与百分比;失败盖错误标)→ 标题=提示词 → 第一行元信息(状态徽标 / 模型 / 批量 / 尺寸 / 字节)→ 第二行(时间 / 耗时 / 打开预览 / 原始链接)
5. 行操作(hover 显示图标,主操作常驻按钮):下载原图 / 复制链接 / 插入画布 / 定位节点 / 重试 / 删除
6. 失败行:红色错误条 + request id + 「重试」;原始链接仍可用(可复制/浏览器打开)
7. 详情抽屉(点行打开):原始链接(可复制,默认打码)、本地副本状态与 blob 引用、显示层说明、来源节点与画板、操作(插入 / 复制图片 / 复制链接 / 下载 / 重新下载 / 仅保留链接)
8. 多选:底部浮动条(已选 N 项 → 插入画布 / 批量下载 / 复制链接 / 删除)
9. 空态:没有记录时给一句「出图后会自动出现在这里」+ 前往画布
10. 离线态:只读展示已有记录,下载类操作置灰并提示
## 5. 保留与清理
- 默认保留 30 天 / 500 条(可设置);pinned 记录永不自动清理
- 「仅保留链接」:释放原图字节,保留元数据与 URL(历史页签可见,可重新下载)
- 清理只删字节,不删记录;删除记录才移除行
## 6. 安全
- 原始链接常带签名参数:列表里默认打码(显示前 24 字符 + …),点「显示」才完整展示
- 复制/打开外链走现有的 openExternal(系统浏览器),不内嵌 iframe
## 7. 性能
- 列表虚拟化(与图库同一套),只渲染可视区
- 缩略图 320,绝不为了列表去解码原图
- 索引分页读取;下载进度用事件节流(≥200ms 一次)
## 8. 改动清单(代码,全部落在 src)
| 文件 | 改动 |
| --- | --- |
| src/task-queue-store.js(新) | 索引 CRUD、状态机、清理策略、pinned 判定 |
| src/ui-task-queue.js(新) | 页面组件(页签/筛选/列表/抽屉/批量条) |
| src/image-ingest.js(新,见落地管线方案) | 后台下载、重试、断点、派生 |
| src/ui-nav-rail.js | 增加 rail 项与 props.onQueue |
| app.js | 只加装配:页面状态 + 把 ingest 事件接到 store(预计 +8 行,需同步上调 MAX_APP_JS_LINES 并记账) |
| src/ui-components.js | 结果图支持「下载中/失败」两种状态外观 |
## 9. 分期
| 阶段 | 范围 | 预估 |
| --- | --- | --- |
| P1 | 只读账本:记录已有生成结果与原始链接,列表 + 详情 + 复制/下载/重新下载 + 定位节点 | 1 天 |
| P2 | 接 ingest:实时进度、失败重试、断点恢复;节点与图库改吃本地副本 | 1 天 |
| P3 | 显示层派生(长边 2048)+ 清理策略 + 批量操作 | 0.5 天 |
## 10. 验收
- 出图后 3 秒内列表出现该条;下载中能看到进度;完成后节点/图库/队列三处一致
- 断网:行显示失败 + request id;恢复网络点重试成功
- 清理字节后行变「仅保留链接」,点重新下载能取回
- 同一条只下载一次(网络面板 1 次请求)
- 链接默认打码,点显示才完整
- 7000 节点画布下打开队列页,滚动不掉帧
+6 -6
View File
@@ -1,7 +1,7 @@
# 现状架构与性能事实基线(桌面版)
> **本文档是什么**:现状**事实快照**,不是规范。用途:任何性能 / 内存 / 存储相关改动,先对齐这里的现实,避免把已经调好的东西改坏。
> 日期 **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-12-02**(**2026-12-02 复算 · v3.26.184**)| 基线(**最近一次 bump 版本的提交**,不是主干 HEAD)`main = 33631d11`(线上 `v3.26.240+33631d11` —— 2026-12-02 **图片写回收口**:插件写回三入口统一到 src/image-writeback.js(同步布尔 / 落盘校验 / 建图引用化),阈值只剩 IMPORT_INLINE_MAX,orig 一起引用化并进撤销快照;上一条 `v3.26.182+738b70c` —— 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)并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 迁出)
@@ -22,7 +22,7 @@
- 图片**新写入主通道 = 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,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 行)。
- `app.js` = 单 IIFE **9,368 行**(**双层预算**:绝对上限 9,368 / 占总源码 ≤ 40%,现 **26.2%**,2026-11-12 起;此前为单一上限 8,509、零余量);`Workbench()` = **2,690 行**(上限 **2,690**,余量 0;2026-11-16 把生成取消族 `cancelRunsFor`/`cancelRun`/`cancelTaskJobs` 与工作区列表写回族 `persistWs`/`duplicateWs` 搬进 `src/runtime-workbench-logic.js`(`createCancelActions` / `createWorkspaceListActions`),并删掉全仓零调用的 `runAll`,3090 → 2,998);大量逻辑已抽到 `src/*.js`(现 **128** 个模块 / 26,334 行,`sourceModules` 128 项;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 实测)
@@ -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` 不引用模块全局)。**123 个模块中 59 个导出**被 `app.js` 读取;其余为未接线 / 仅测试 / 零引用(见下)。
- **判定法**:`global.X =` / `root.X =` 判「导出」;跨文件裸引用判「读」;排除自合并(`src/runtime-constants.js:9`)。`app.js` 是**唯一生产消费者**(无 HTML 入口;`sw.js` 不引用模块全局)。**128 个模块中 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 耦合面(**102** 项)与 `sourceModules` 顺序(**123** 项);命名例外由第 5 组冻结,新增非 `IWB` 前缀导出即打红。
- **耦合面已冻结**:`tests/architecture-boundary-guard-test.js`(进 `npm run test:unit` 末环)冻结 app.js↔src 耦合面(**107** 项)与 `sourceModules` 顺序(**128** 项);命名例外由第 5 组冻结,新增非 `IWB` 前缀导出即打红。
## 12. 易踩的坑
@@ -279,7 +279,7 @@
**信任模型(必须明示)**:形态 A 的插件是**可信代码**(与核心同权限、无沙箱);启停与设置是 UX 与可维护性手段,**不是安全边界**(同 §13.27 教训:前端开关一定可被绕过)。
**守门与快照**:`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 门禁)。
**守门与快照**:`tests/architecture-boundary-guard-test.js` 冻结「app.js ↔ src 耦合面」(**107** 项)与 `sourceModules` 顺序(**128** 项);新增模块、新增耦合、新增 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 规则三的同一失败模式)。
@@ -300,7 +300,7 @@
v3.25.11 的「CSP 清理」误判 30092 为遗留端口删掉 ⇒ 桌面版鲜艺抠图插件 `Failed to fetch`。
现由 `tests/desktop-csp-loopback-test.js` 钉住(只断言桌面 CSP 的运行时值,避免源码钉点棘轮)。
**鲜艺抠图插件(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`)。
**鲜艺抠图插件(现为市场插件 `xianyi-cutout` 1.0.4)**:源码在独立插件仓 `iwb-plugins-desktop`,桌面端从插件市场安装到 `<资料目录>/plugins/`,不再经 Cloudflare Function / KV。功能:右键命令「抠图:选中节点」→ `POST {apiUrl}/rmbg?crop=`(`application/octet-stream` + 原始字节)→ 结果 PNG 写回为新的参考图节点(`<原名>_cutout.png`)。设置项:`apiUrl` / `crop` / `timeoutMs`。
**插件信任锚(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、不共享凭据。
+20
View File
@@ -0,0 +1,20 @@
# 域名边界(2026-12-03 用户裁定)
三个域名属于**两个互不干扰的项目**。桌面版的发布流程只允许碰后两个。
| 域名 | 归属 | 托管 | 允许谁改 |
|---|---|---|---|
| `iwb.maqiart.eu.org` | **网页版项目(独立)** | Cloudflare Pages(独立项目) | 只有网页版项目自己。桌面版发布流程**不得**改它的 DNS / Pages / 内容 / 重定向 |
| `download.maqiart.eu.org` | 桌面版下载站 | NAS `/vol8/web/iwb-download` | 桌面版发布(`publish-update.sh` / `release.sh` / 手工 scp) |
| `market.maqiart.eu.org` | 桌面版插件市场 | NAS `/vol8/web/iwb-market` | 桌面版插件发布(`gen-market.js` + scp) |
## 硬规则
- `iwb.maqiart.eu.org` 是网页版,**与桌面版无关**;即使它挂掉/522,也不要用桌面版站点去「接管」这个地址。
- 发布脚本、Cloudflare 操作、DNS 改动,动手前先确认目标是上表里的哪个域名;不确定就别动。
- 网页版与桌面版的代码/产物/插件清单各自独立,不要互相覆盖。
## 历史
- 2026-12-01:网页版退役期间,曾用 `CNAME → iwb-redirect-979.pages.dev` 把 `iwb.maqiart.eu.org` 301 到下载站。
- 2026-12-03:用户恢复网页版访问,并明确「以后不要动这个地址、两个项目不要相互干扰」。本文件为长期约束。
+9 -9
View File
@@ -52,7 +52,7 @@
- **唯一版本源**:`package.json`;`node scripts/set-version.js X.Y.Z` 同步 `tauri.conf.json` / `Cargo.toml`。
- **mac**:`npm run verify:ci` → 更新 CHANGELOG → 提交 → `bash scripts/publish-update.sh`(双架构构建、签名、上传、生成 `latest.json`)。
- **Windows**:按 `docs/WIN_BUILD_SPEC.md` 构建 `*-setup.exe` → 放 NAS `_inbox/` → mac `publish-windows-update.sh` 重签 → **再跑一次** `publish-update.sh` 把 `windows-x86_64` 合并进 `latest.json`。
- **Windows**:按 `docs/WIN_BUILD_SPEC.md` 构建 `*-setup.exe` → 由 win 起一次性 tailnet HTTP 服务、mac 拉取并核对 sha256(NAS `_inbox/` 已弃用)→ mac `publish-windows-update.sh` 重签 → **再跑一次** `publish-update.sh` 把 `windows-x86_64` 合并进 `latest.json`。
- **站点**:登记 `site/releases.json` → `gen-release-page.js` / `gen-site.js` → 上传 NAS → 核验 200 与字节数。
- **tag**:`vX.Y.Z` 指向 bump 提交;docs/站点提交可在 tag 之后,但不要再改业务代码。
- 平台版本必须同批;Windows 落后时不要往 `latest.json` 塞旧包。
@@ -74,7 +74,7 @@
**方法论沉淀(也是排查顺序):**
- **先抓真实用户反馈**,不要凭猜测改。症状要问清:是「本地存空间不足 / CPU 持续高 / 内存爬升 / 拖动掉帧」中的哪一种,各自根因不同。
- **用 Performance 画像定位**:录**干净空闲段**看 Bottom-Up / Call Tree。CPU 高要看 React 渲染 / graph 缓存 / IDB 读写;内存爬升要看**无界缓存**(如 `outThumbCache` 原为无上限 Map)和**每次保存的深拷贝/全量扫描**;掉帧要看**每帧 O(n) 重渲染**和 **Layout/Paint**。
- **改动要能回滚**:每段先打 `vX-pre-Y` 标签;`npm run verify` 346/0/5 + e2e 16/16 是契约;部署确认 wrangler "Deployment complete" + 域名版本。
- **改动要能回滚**:每段先打 `vX-pre-Y` 标签;`npm run verify:ci` 是契约;桌面版发布用 `scripts/publish-update.sh` / `publish-windows-update.sh`,核验以 `latest.json` / `latest-windows.json` / 下载页三处一致为准(网页版的 wrangler 部署已废弃)。
- **性能修复也要「不增加不必要的 O(n)」**:惰性剥离、引用 memo、节流、DOM transform——都遵循「能 O(1) 就别 O(n),能按需就别全量」。
- **规范先行**:这类经验写入 13 章,避免将来反向改回去(如曾出现的「大图缓存失败保留 base64」与 CPU/内存冲突)。
@@ -254,7 +254,7 @@
### 13.23 CSP 是运行环境的一部分:本地 e2e 必须下发 `_headers`(v3.86.10 沉淀)
- **本地测试服务器不解析 `_headers` = 永远测不到线上安全策略**:本项目线上是 Cloudflare Pages,CSP 写在 `_headers` 里;本地 `serve-test.js` 若只发 `content-type`,`fetch(data:)` / `fetch(blob:)` / CDN `<script>` / `new Worker(blob:)` 这些**在线上必然被拦**的写法会在本地全绿。规则:**测试服务器必须下发与线上同源的响应头**(`scripts/serve-test.js` 解析仓库根 `_headers`,按 Pages 的路径分组语义应用;解析失败只提示不报错)。
- **本地 e2e 必须与真机同源的 CSP**:网页版时代 CSP 写在 `_headers`(已随 Cloudflare Pages 下线删除);桌面版 CSP 在 `src-tauri/tauri.conf.json`,`scripts/serve-test.js` 需要下发与桌面端一致的响应头,否则 `fetch(data:)` / `fetch(blob:)` / CDN `<script>` 这类**真机必被拦**的写法会在本地全绿。
- **当前 CSP(`_headers` 的 `/*` 组)实际拦掉什么**(全部为 Chromium 实测原文,别凭记忆猜):
- `connect-src 'self' https:` → **`fetch(data:...)` 与 `fetch(blob:...)` 都被拦**("Refused to connect to 'blob:...' ... connect-src 'self' https:")。注意 `blob:` URL 属于 document 的 origin,但**仍然不在 `'self'` 的 scheme 匹配里**——这条最反直觉。
- `script-src 'self'` → 动态插的 CDN `<script>` 触发 `onerror`("Refused to load the script ... script-src 'self'"),`eval` / `new Function` 也全禁用(Playwright 的 `page.evaluate` 传字符串同样会被拒)。
@@ -421,7 +421,7 @@
### 规则二:**跨域图床必须走"本站同源代理",禁止第三方代理**
豆包(火山 TOS)等图床**不发 CORS 头** ⇒ `fetch(cors)` 必失败。做法:
- 新增 `functions/api/img.js`(Cloudflare Pages Function):本站 CORS 头 + **仅 https** + **域名白名单** + 仅透传 `image/*`;
- ~~新增 `functions/api/img.js`(Cloudflare Pages Function)~~ —— **网页版已停用,该 Function 已删除**;桌面端跨域取字节走宿主能力,失败必须有可见提示。
- `downloadUrl` 链路:直连 → 本地已归档原图 → **本站代理** → 新标签兜底(**绝不静默失败**,失败必有可见提示);
- 断言锁死"全代码库不得出现第三方代理域名"。
@@ -481,7 +481,7 @@ LRU 上限 + 切画板/离开画布/卸载时回收;`revokeAll()` 幂等。
### 13.34.3 跨域图片:唯一允许的取字节方式
- 豆包(火山 TOS)、七牛、阿里云等**不发 CORS 头** ⇒ `fetch(cors)` 必失败;`canvas.toDataURL()` 因污染必抛错。
- **必须**经本站同源代理 `functions/api/img.js`(`/api/img?url=`):仅 https + 域名白名单 + 仅透传 `image/*` + 本站 CORS 头。
- **桌面端**:跨域取字节走宿主(Tauri http / 本地归档优先);网页版时代的 `functions/api/img.js` 代理已删除,文档与代码都不要再引用它。
- **禁止第三方代理**(曾用 `wsrv.nl`,已按用户要求移除);下载链路四级兜底:直连 → 本地已归档原图 → **本站代理** → 新标签(绝不静默失败)。
### 13.34.4 契约与验证方法(本方案的"证据链")
@@ -495,7 +495,7 @@ LRU 上限 + 切画板/离开画布/卸载时回收;`revokeAll()` 幂等。
### 13.34.5 发布纪律(在 §13.32 基础上追加,均为真实失误驱动)
1. `verify`/`deploy` **不得管道给 `tail`**(吞退出码 ⇒ 假成功)。
2. **先部署、后打标签**,标签必须指向"已部署且验证通过"的提交;三地址核验一律执行 `npm run verify:release`(含 CDN 传播退避重试)。
2. **先发布、后打标签**,标签必须指向“已发布且验证通过”的提交;核验读 `latest.json` / `latest-windows.json` / 下载页三处一致(旧 `npm run verify:release` 已随网页版删除)。
3. **任何时刻线上保持绿色**:改动失败即 `git reset --hard` 回到已知良好提交;不留"半成品分支状态"。
4. **探针三原则**:零行为变更 / 用户可自助取回 / **查清即删并加"零残留"契约**。
5. 每版必写 `CHANGELOG`(含"如实记录的残留风险");每个里程碑建 GitHub Release。
@@ -507,7 +507,7 @@ LRU 上限 + 切画板/离开画布/卸载时回收;`revokeAll()` 幂等。
| 完整执行文档与复盘(§0–§13,含被推翻推断的留档、踩坑清单、验收表) | `docs/archive/plans/opentu-parity-image-memory.md` |
| ~~预览产物生成器(解码即缩放 + `close()` + objectURL 回收)~~ **已于 v3.26.65 删除**:交付时只做到「模块 + 单测」,从未接到 `wPreviewUrlOf`(实际是恒等函数)—— 属"假绿",重做见 BACKLOG | — |
| 图片字节 Blob 仓库(内容寻址去重) | `src/image-blob-store.js`(9/9 单测) |
| 同源图片代理(跨域取字节唯一通道) | `functions/api/img.js` |
| ~~同源图片代理(跨域取字节唯一通道)~~ **网页版时代已删除**:桌面端无此代理 | — |
| 内存行为契约 | `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`) |
@@ -616,7 +616,7 @@ B-② 撤销/重做后图片真能解码显示,`naturalWidth=768`)· e2e `te
## §13.35 插件 = 完全可信代码:信任模型与治理(2026-10-19)
> 适用:应用内插件体系(现状见事实基线 §14)。自 A2 起,远程插件经 Cloudflare Pages Function `functions/plugins/[[path]].js` + KV(binding `PLUGINS`)**同源运行时加载**。
> 适用:应用内插件体系(现状见事实基线 §14)。桌面版插件经**插件市场**(`market.maqiart.eu.org`)分发,安装到 `<资料目录>/plugins/`,安装时按 zip 的 `bundleSha256` + 逐文件 sha256 校验;网页版的 Pages Function + KV 通道已下线。
**背景(为什么会踩)**:插件是**同源 JS**,与主程序同权 —— 可读 `localStorage` 里的**全部 API Key**、IndexedDB 里的**全部图片**、注入任意 UI、发起任意 `https:` 与本机请求。宿主**不做沙箱**(`script-src 'self'` 对同源脚本无能为力)。启停与设置是 UX 与可维护性手段,**不是安全边界**(同 §13.27)。
@@ -1657,6 +1657,6 @@ JS 只能拿到 `TypeError: Failed to fetch`。
- 构建机只认 `package.json` 的版本;文档中的固定版本号是历史示例,照抄必错。
- `tokens:check` 失败先看 CRLF:`build.js` 与 `gen-tokens.js` 都必须把 `\r\n` 归一后再比较;只修一处会在 `app:build` 再炸一次。
- `.gitattributes` 的 `eol=lf` 不会 renormalize 已有 checkout;校验层容忍才是根治。
- Windows 只负责出 `*-setup.exe` 放 NAS `_inbox/`;签名、`latest-windows.json`、合并 `latest.json` 全部在 mac 做。
- Windows 只负责出 `*-setup.exe` 并通过 tailnet HTTP 交给 mac(`_inbox/` 已弃用);签名、`latest-windows.json`、合并 `latest.json` 全部在 mac 做。
- 平台版本必须同批:Windows 版本落后时 mac 的 `latest.json` 不应塞旧 win 包,等 win 同版本发布后重跑发布脚本自动齐平。
- 发布后核验三件事:`latest.json` 含三平台、`latest-windows.json` 版本一致、下载页 exe 可 200 且字节数一致。
+69
View File
@@ -0,0 +1,69 @@
# 图片读取与下载口径(2026-12-03 定稿)
> **这是规范**:同一张图,不管从输出节点、图库、任务队列还是预览打开/下载/复制,
> **取源顺序与文件名只有一套**。新代码按本文写;`tests/image-download-contract-test.js` 会拦住已知的偏离写法。
>
> 背景与踩坑记录见 [`image-read-lessons-2026-12-03.md`](image-read-lessons-2026-12-03.md)。
## 0. 术语
| 词 | 含义 |
|---|---|
| 原图 | 用户要看的完整分辨率图片。桌面端 = `images/gallery/<文件>` 或 `origIdb` 字节 |
| 缩略图 | 320px 级小图(`row.idb` / `images/thumbs/`),**只用于列表、宫格、占位** |
| 图库行 | 输出索引里的一行(`f.name` / `f.url` / `f.orig` / `f.origIdb` / `f.idb`) |
| 会话副本 | `IWBImageIngestView.localUrl`,本次运行内有效,重启即失效 |
| 远程 URL | 生成结果上游地址(图床),会过期、跨域、慢 |
## 1. 取源顺序(唯一口径)
按顺序取,**拿到一层就停**:
1. **`origIdb`** —— 图库行写入的原图字节(新记录)
2. **`images/gallery/<文件>`** —— 本地原图文件(老记录没有 `origIdb`;入口 `IWBStorageFile.galleryOriginalOf` / `galleryOriginalBlob`)
3. **会话副本** —— `IWBImageIngestView.localUrl`(任务队列专用)
4. **远程 URL** —— 仅「下载 / 插入画布」允许兜底
5. **320 缩略图** —— 只做占位底图,**永远不当原图**
硬规则:
- **预览不许直连远程**:本地没有原图就提示「先下载」,不打开预览,也不把 320 缩略图放大冒充原图。
- **下载必须本地优先**:`wResolveOutputSrc` 先 `origIdb` → 本地原图文件 → 数据 → 远程。
- 缩略图可以「先出画面」,但 `ImagePreview` / 节点体必须在原图到达后替换掉它(现有的「先糊后清」逻辑)。
- 「能显示 = 本地有图」是产品判据:显示不出来就是没落地,不是网络慢。
### 各场景落点
| 场景 | 入口 | 取源 |
|---|---|---|
| 任务队列预览 | `queue.preview` → `ImagePreview` | 本地原图;无则提示未下载 |
| 图库预览 | `gallery.preview` → `ImagePreview` | `origIdb` → 本地原图文件 |
| 输出节点双击 | `props.onPreview` → `ImagePreview` | 同上(条目带 `name` 时按行名读本地) |
| 输出节点 ↓、预览下载、图库下载 | `wResolveOutputSrc` | 本地优先 |
| 插件 `ctx.images.preview/thumb` | `wPluginPreview` | 已有分层(thumb/preview/original) |
## 2. 下载文件名
**一律用图库行名 `f.name`**(经 `wOutNameOf(url)` 按 url 查行)。
| 场景 | 文件名 |
|---|---|
| 图库卡片下载 | `f.name` |
| 输出节点 ↓ | `wOutNameOf(url) \|\| 'image.png'` |
| 预览「下载当前图片」 | 图库条目用 `entry.name`,其余 `wOutNameOf(url) \|\| 'image.png'` |
| 输出节点批量下载 | `wOutNameOf(url) \|\| 'image-001.png'` |
| 任务队列「下载」 | 落地到图库,不产生浏览器下载 |
禁止:给 `downloadUrl(...)` 传写死的业务文件名。`image.png` / `image-00N.png` 只允许作为「还没落地、没有行名」的兜底。
## 3. 相关入口(实现索引)
- `src/storage-file.js`:`galleryOriginalOf(row, max)`(预览,原生按尺寸解码、落 thumbs 缓存)、`galleryOriginalBlob(row)`(下载,原始字节,不重编码)
- `app.js`:`wResolveOutputSrc`(下载取源)、`wOutNameOf`(命名)、`queue.preview`(任务队列预览)
- `src/ui-canvas-view.js`:`ImagePreview` 统一解析 `{__gallery, name, origIdb, idb}` 条目
- `src/ui-node-bodies.js`:输出节点下载 / 预览入口
## 4. 检查
- `node tests/image-download-contract-test.js`(已进 `npm run test:unit`)
- 新增下载/预览入口时,先对照本表;守卫不覆盖的写法,**改守卫**再写代码。
@@ -0,0 +1,47 @@
# 图片本地读取改造 · 经验与踩坑(2026-12-03)
> 对应规范:[`image-read-and-download.md`](image-read-and-download.md)。本文只记「为什么」和踩过的坑,
> 下次改图片读取/预览/下载前先看这里。
## 1. 老记录为什么会被「放大发糊」
- 图库行有两种原图形态:**新记录**写 `origIdb`(IndexedDB 字节);**老记录**只有磁盘文件 `images/gallery/<文件>`,索引里 `origIdb` 是空的。
- 任务队列预览曾经按 `origIdb → idb → localUrl` 取源。老记录没有 `origIdb`,直接落 `idb` —— 那是 **320 缩略图**,全屏一放大必然糊。
- 教训:**`idb` 永远是缩略图,不是原图**。任何「原图」路径都不允许读 `idb`。
- 判定方法:新图清晰、老图糊,且糊得很均匀 → 先怀疑取到了 320 档。
## 2. 「本地有」不等于「IndexedDB 里有」
- 桌面端的权威原图是 `images/gallery` 的**文件**;`origIdb` 只是其中一种缓存形态。
- 所以「本地优先」必须包含**按行名读磁盘**这一步(`galleryOriginalOf` / `galleryOriginalBlob`),否则老记录只能退远程或缩略图。
- `assets` 的键约定:`out_orig_<name>`;行里 `origIdb` 为空时可以按这个约定回查。
## 3. 预览只读本地之后的产品语义
- 能显示 = 本地有图;显示不出来 = 没落地。
- 本地没有原图时给提示「先下载」,**不要**偷偷回退远程 —— 否则用户以为图在本地,断网/过期就整片破图。
- 缩略图只做「先糊后清」的底图,不能作为最终图。
## 4. 预览路径与缓存归属(容易踩内存坑)
- `galleryOriginalOf` 返回的 objectURL **归 storage 持有**(`thumbUrlCache`,不 revoke)。
- `ImagePreview` 自己的 `urlsRef` 会在淘汰时 `URL.revokeObjectURL`;**不要把 storage 的 URL 塞进 `remember()`**,否则一处淘汰、另一处还在用 → 破图。
- 反过来:`galleryOriginalBlob` 给的是原始字节,可以交给预览的下载/复制链路自行登记 URL。
## 5. 下载命名的坑
- 改之前:图库下载用行名 `gen_...png`,输出节点写死 `image.png`。同一张图两个名字,用户对不上。
- 统一规则:**行名优先,未落地才回退**。新增下载入口一律走 `wOutNameOf(url)`。
- 守卫 `tests/image-download-contract-test.js` 会拦「写死业务文件名 / 预览直连远程 / 把 idb 当原图」。
## 6. 任务队列页头被滚走 / 页脚被压(同日,相关布局坑)
- 现象一:筛选页签、页头随列表滚走。原因:整页容器和列表都在滚。
- 现象二:列表行压在页脚说明上。原因:宿主滚动容器高度固定,插件根节点 `flex: column` 里的列表被压缩到 540px,但列表没设 `overflow`,内容溢出画在页脚上。
- 修法:插件根 `.iwb-tq{height:100%}` + 列表 `.iwb-tq-list{overflow-y:auto}` —— 只有列表自己滚。
- 教训:**「谁滚」只能有一个**;滚动容器里再放一个 `flex:1; min-height:0` 的子块,必须给它 `overflow`,否则内容会溢出到兄弟元素上。
## 7. 工程约束
- `app.js` 有行数棘轮(新能力优先落 `src/<domain>-*.js`);本次因下载命名 + 队列预览同期改,棘轮 9345→9354、Workbench 2686→2687,注释已写日期/差/原因。
- 改完跑:`npm run build && node --check dist/app.js && npx eslint src app.js && npm run typecheck && npm run test:unit && npm run test:facts`。
@@ -0,0 +1,193 @@
# 画布性能与图片链路优化参考(2026-12-01)
> 来源:v3.26.154 → v3.26.182 之间连续多轮真机排查(Windows 为主,mac 对照)。
> 本文只记录**已验证的事实**与**可复用的方法**,不是规范条文;改代码前先看「反模式」与「回归清单」。
## 0. 一页结论
1. **JS 堆不是内存大头**:正常态 20–80MB;`performance.memory` 只是堆,和任务管理器差 1.5–3 倍是正常的。
2. **WebView2 的 GPU 进程私有内存会冲到 1–2.6GB,但大头是「已提交未驻留」**:工作集只 130–180MB,20–60 秒内自己回落到比基线还低。不要拿任务管理器的「私有」当泄漏证据。
3. **真正不回落的是 renderer**:一次「开大画板 + 平移」会抬 40–120MB 并长期不降,量级与 DOM 元素数同步(1500 → 4600+)。
4. **空闲 CPU 高 ≠ 有后台任务**:多数是内存压力导致的 GC 抖动,或「常驻合成层 + 大 base64 图片」让合成器持续工作。判据:最小化窗口 CPU 掉 → 渲染/合成侧;不掉 → JS 侧。
5. **DOM 里挂 1MB 级 base64 `<img src>` 是明确的 CPU/内存放大器**:标注覆盖后图能显示,但 CPU 从个位数升到 15% 且不回落;把它转成 `{__blob}` 引用后立刻恢复。
6. **空 `src` 会把节点永久标成「图片源已失效」**:缩略图未就绪时返回 `""` 会触发 `onError`,遮罩加上后没人移除;显示层必须「有图就显示原图」,不要空占位。
7. **取图优先级是 `localRef → data → url`**:覆盖式替换图片时必须同时清 `localRef`/`ref`,否则旧引用(及其缓存的 objectURL)永远压过新数据。
8. **缩略图生成失败必须负缓存**:失败后每次重渲染都重新入队 → 反复整幅解码,是「做一次标注后 CPU 一直高」的直接原因。
9. **视口裁剪是双刃剑**:裁得太紧,平移时节点/连线会「突然冒出来」;正确做法是「手势期间只扩张不收缩 + 边距 1.5 屏 + 步长 1/3 屏」,松手后再回收。
10. **常驻合成层(`data-layers=on` 给 world 加 `will-change`)应停用**:手势期间的临时提升已经够用,常驻只会让窗口可见时持续吃 CPU。
## 1. 诊断方法论(先取数,再改代码)
### 1.1 三层指标,别混用
| 指标 | 来源 | 说明 |
| --- | --- | --- |
| JS 堆 | `performance.memory.usedJSHeapSize` | 只有 Chromium 有;WKWebView 恒空。20–80MB 属正常,锯齿是 GC |
| 进程工作集 / 私有提交 | 诊断页「内存拆解」 | Windows 用 Toolhelp32 + `GetProcessMemoryInfo`;mac 用 `footprint` |
| 进程树合计 | `app_memory_tree_mb` | 宿主 + 全部 WebView2 子进程;和任务管理器「内存」列同源 |
判读顺序:**先看进程树合计是否随操作抬升并回落**,再看 renderer 是否台阶式上涨,最后才看堆。
### 1.2 三个对照实验(各 30 秒,性价比最高)
- **最小化对照**:窗口最小化后 CPU 掉 → 渲染/合成侧;不掉 → 定时器/JS 侧。
- **回收对照**:点「立即回收内存」后 CPU 掉 → 与缓存/大对象有关(历史、缩略图、图片字节、大 base64)。
- **开关对照**:逐个关「合成层常驻提升 / 手势期提升 / 帧探针」,看 CPU 与残影变化。
### 1.3 帧探针(`iwb_perf_probe=1` 或诊断页勾选)
每 60 秒写一条到 `_boot.log`:
```
perf 60s frames=3598 long=0 max=0ms js=0/0ms tags=- domImgs=13
```
- `js=条数/总ms`:主线程长任务(>50ms)。为 0 说明不是脚本在算。
- `frames`:rAF 次数(探针自身也在跑,接近 60 说明页面在出帧)。
- 注意:**短任务不会进 longtask**;60fps 的小任务循环(如逐帧 canvas 重绘)表现为「js=0 但 CPU 高」。
### 1.4 插件写回日志(`plugin-img`)
写回路径会往 `_boot.log` 记一行:`plugin-img save id=… ok=… err=… len=… localRef=Y/N keys=…`。
- `ok=false` → 写回校验失败(保存/落盘问题)
- `localRef=Y` → 旧引用还在,新图会被压住
- `keys` 缺 `data` → 数据没落到节点上
> 坑:桌面端 `logPut` 曾经签名不匹配(app 传对象、存储层收两个参数),所有 `wLog` 都写进 `log:[object Object]`、值为 `undefined`。排查日志类问题前先确认落盘通道本身是通的。
## 2. 内存:真实的构成与阈值
### 2.1 谁在吃内存
- **GPU 进程**:合成层/纹理。峰值 1–2.6GB 但大部分可换出,会自己回落;工作集只有 130–180MB。
- **renderer**:DOM + 图片解码 + JS 堆。开 97 节点画板时 DOM 1500 → 4600+,私有内存 +40–120MB 且不回。
- **宿主**:30–50MB,稳定。
- **图片字节缓存**:`blobCache` 按条数+字节双上限(96/64MB);`imgBigN` 必须为 0(DOM 里不得出现 >500KB 的 base64)。
### 2.2 阈值与自动回收(v3.26.171 之后)
- 可见空闲 **90 秒** → 轻量回收(保留显示缩略图)。
- 进程树 RSS **≥ 2500MB** → 不等空闲,直接完整回收(含缩略图缓存)。
- 旧策略要求「可见 + 空闲 5 分钟」,日常几乎不触发,是「内存上来不降」的隐藏原因之一。
### 2.3 已证伪的假设(不要再走一遍)
- 「deps/.fingerprint 被删导致构建慢」:实际是构建机 shell 的文件视图看不到那两个目录,cargo 一直命中缓存。
- 「GPU 私有 1.3GB 是泄漏」:是已提交未驻留,工作集只有 100MB 级,会回落。
- 「切画板残留 DOM」:DOM 在 720↔3752 之间振荡,停止切换后回落,不构成阶梯泄漏。
## 3. 画布渲染:分层与手势
### 3.1 分层现状
- **边线**:canvas 视觉层(视口大小)+ 透明 SVG 命中层(负责 hover/点选/双击断线)。
- **节点**:DOM(`.iwb-world` 内的绝对定位节点)。
- **网格**:预生成贴图 + `background-position`。
### 3.2 手势期间的正确姿势
1. **世界层临时提升**:`.iwb-canvas.iwb-gesture .iwb-world { will-change: transform }`,停手后撤销(不要常驻)。
2. **连线不再按视口裁剪**:全部绘制,canvas 自身被视口裁掉;否则新进入视口的线会「迟到」。
3. **边线层不冻结**:平移期每帧重画,而不是把 canvas 用 CSS 平移走。
4. **节点裁剪窗口**:边距 1.5 屏、更新步长 1/3 屏;**手势期间只扩张不收缩**(`panKeep`),松手后按视口回收。
5. **命中层每帧同步**:空格平移不经过 `pointerup`,只靠手势结束事件对齐会漏。
### 3.3 LOD
- 只保留一档:`<15%` 切纯占位;取消 ~30% 的 lite 档(阈值附近来回切换会「画面常闪」)。
### 3.4 仍存在的已知问题
- 平移松手后仍有极轻微残影(合成层位图延迟),当前以「手势结束重绘 + 短暂关闭命中层」缓解,未彻底消除。
- renderer 相对最早基线高 ~36MB(DOM 规模导致),暂不处理。
## 4. 插件
### 4.1 生命周期
- 关闭插件面板 **不等于** 停用插件:面板只卸 DOM,插件实例仍在。重对象必须在 `close()` 里主动释放。
- 反例(已修):`image-vectorize` 关闭面板时只删 DOM,源图解码位图与 SVG 字符串仍挂在闭包里,开过一次大图后堆不回落。0.6.3 起在 `close()` 里置空 `source` / `currentSvg`。
### 4.2 插件写回图片的接口
- `ctx.canvas.saveNodeImage(id, dataUrl)`:写入 → 落盘 → 回读校验,失败回滚并返回原因(首选)。
- `ctx.canvas.setNodeImage(id, dataUrl)`:同步写节点数据,不做落盘校验。
- 两条路径都必须:**清旧引用 → 失效缩略图缓存 → 触发重渲染 → 大图引用化**。
## 5. 图片保存链路(标注覆盖为例)
### 5.1 正确流程
```
编辑器输出 Blob
→ imageToDataUrl
→ saveNodeImage(id, dataUrl)
├ 写节点:{ data, url:"", localRef:null, ref:null, orig:旧图 }
├ commitCanvas(setNodes 触发渲染)
├ saveNow(落盘)
└ 回读校验:磁盘上的节点数据必须与旧值不同,否则回滚并报错
→ 成功后:删缩略图缓存条目 → wThumbBump()
→ 若 dataUrl > 200KB:wImgRefWrite 无损转 {__blob},节点三字段指向引用
```
### 5.2 四个必须同时满足的条件(缺一个就表现为「图丢了」)
1. `localRef` / `ref` 必须清空 —— 否则旧引用压过新 `data`。
2. 显示层不得返回空 `src` —— 空 src 触发 `onError`,节点被永久标成「图片源已失效」。
3. `onLoad` 必须清除 `is-broken` 标记 —— 否则换图后遮罩残留。
4. 缩略图失败要负缓存 —— 否则每次重渲染重新解码。
### 5.3 大图不要留在 DOM
- 1.2MB base64 挂在 `<img src>` 上:内存上涨,且合成器持续工作 → 空闲 CPU 15%。
- 落地方式:`wImgRefWrite(dataUrl)` → `{__blob}` → 显示走 objectURL;磁盘/IDB 存字节。
- 阈值:>200KB 即引用化;小图(≤ `IMPORT_INLINE_MAX`)可内联。
## 6. 反模式清单
- ❌ 用任务管理器的「私有内存」判断泄漏(先看工作集与回落曲线)。
- ❌ 用 JS 堆判断图片内存(图片在 renderer 原生侧,不在堆里)。
- ❌ 在渲染路径里返回空 `src` 当占位。
- ❌ 覆盖替换图片只改 `data`,不清 `localRef` / `ref`。
- ❌ 缩略图失败后无限重试。
- ❌ 常驻 `will-change: transform` 把整个世界层做成合成层。
- ❌ 手势期间收缩裁剪窗口(节点/连线会「突然出现」)。
- ❌ 依赖「手势结束事件」对齐命中层(空格平移没有 pointerup)。
- ❌ 插件关闭面板只删 DOM,不释放大对象。
## 7. 回归检查清单
改到以下位置时,至少跑一遍对应检查:
| 改动 | 必查 |
| --- | --- |
| 缩略图 / 取图 | `imgBigN=0`、`imgMaxKB<500`、节点不出现「源已失效」 |
| 裁剪 / 手势 | 快速平移:连线不迟到、节点不突现、松手后不残留 |
| 插件写回 | 标注覆盖后立刻显示新图、`plugin-img ok=true`、DOM 无大 base64 |
| 内存回收 | 空闲 2 分钟 CPU 稳定、堆不锯齿、进程树不持续抬升 |
| 合成层 / will-change | 最小化对照:CPU 应随窗口最小化明显下降 |
## 8. 工具与开关速查
| 开关 | 位置 | 作用 |
| --- | --- | --- |
| `iwb_perf_probe` | 诊断页「帧探针」 | rAF 帧时长 + longtask → `_boot.log` |
| `iwb_diag_off` | 诊断页「关闭诊断采样」 | 停 15s 采样与 4s 进程轮询 |
| `iwb_gesture_layer` | 诊断页「手势期提升」 | 手势期间临时合成层 |
| `iwb_layers_on` | 诊断页「合成层常驻提升」 | **已停用**(不再产生常驻层) |
| `iwb_noblur_on` | 诊断页「禁用毛玻璃」 | 二分 graphics 占用 |
## 9. 后续方向
1. 平移残影:把边线层移出主合成层(独立 layer / `contain: paint`)后再观察。
2. renderer 台阶:DOM 规模是硬成本;若要继续降,只能走「静态内容 canvas 化」(Canvas V3 已被否决,需重新评估范围)。
3. 图片管线:远程图(http)目前仍可能以原图进纹理,按缩放档限制长边是下一步。
4. 诊断:把 `_boot.log` 的 mem 采样改成可配置频率,并支持一键导出最近 10 分钟曲线。
## 性能回归怎么跑(2026-12-02 起)
- 日常:`npm run perf:baseline`(build → 起本地服 → 只跑 `tests/_perf-baseline.spec.js` → 关服;默认 LIGHT=1,12 步平移)
- 完整档:`IWB_PROBE_LIGHT=0 npm run perf:baseline`;只测不断言:`IWB_PROBE_PERF=0`
- 判据(本机 2026-12-02 headless 基线):长帧比例 ≤ 40%、longtask 总时长 ≤ 2500ms、帧数 > 30(防探针没启动导致假绿)
- 实测参考:长帧 22.8%~30.9%、longtask 1905~1934ms、最长帧 ~400ms —— **换机器必须重设阈值**,注释里已写明
+16 -3
View File
@@ -49,14 +49,27 @@ package.json:
| panels | ctx.ui | 侧栏/独立面板注册 |
| promptlib | ctx.promptlib | 提示词库数据 + 文件 + 备份 |
| nodeTypes | ctx.nodes | 画布节点类型注册 |
| canvas | ctx.canvas | 只读:getNodes / getSelectedNode / screenToWorld |
| canvasWrite | ctx.canvasWrite | 写入:createNode / createImageNode / setNodeImage |
| canvas | ctx.canvas | 读:getNodes / getSelectedNode / getNodeImage / screenToWorld |
| canvasWrite | ctx.canvas(**合并,没有 ctx.canvasWrite**) | 写:createNode / createImageNode / setNodeImage / saveNodeImage |
| nodeActions | ctx.nodeActions | 节点右键/气泡动作 |
| commands | ctx.commands | 命令面板 |
| settings | ctx.settings | KV 配置 |
| data | ctx.data | 插件数据文件 |
**注意**:createNode 在 ctx.canvasWrite,不在 ctx.canvas。调错只会提示“宿主不支持”。
**注意**:`CAPABILITY_API_KEYS` 把 canvasWrite 的接口**合并进 `ctx.canvas`**(`src/plugin-host.js`);
`ctx.canvasWrite` 并不存在,但 manifest 的 `capabilities` 仍须同时声明 `canvas` 与 `canvasWrite`,否则拿不到写接口。
调错只会提示“宿主不支持”。
**图片写回契约(v3.26.183,改前必读)**:
| 接口 | 语义 | 用法 |
|---|---|---|
| `ctx.canvas.setNodeImage(id, dataUrl)` | **同步**返回严格布尔;只改内存 + 失效缓存 + 重渲染,**不落盘** | 只要“立刻显示”的场景(blank-canvas 填白图、white-bg-800 覆盖) |
| `ctx.canvas.saveNodeImage(id, dataUrl)` | 返回 `Promise<{ok, error}>`;落盘 + 回读校验,失败**回滚旧图**并给原因 | 用户编辑成果必须落地的场景(image-annotate 覆盖) |
| `ctx.canvas.createImageNode({ dataUrl, name, x?, y? })` | **同步**返回节点 id;超过内联阈值的图由宿主后台引用化 | 生成新图(白底新建、抠图、矢量化、插图) |
- 大图(> 宿主内联阈值,现 3000 字符)会被宿主转成本地引用,`getNodeImage` 仍返回 dataUrl,插件无需感知。
- `getNodes()` 返回的 `data` 是**只读视图**:不要原地改,宿主不会失效缩略图/触发保存;写图只走上面三个接口。
## 3. 面板
+7
View File
@@ -105,3 +105,10 @@ node scripts/gen-market.js && node scripts/gen-market-page.js
- 插件版本独立于客户端版本:客户端 3.26.x 与插件 1.9.x/1.14.x 互不绑定。
- 插件改动**不需要**重打客户端(桌面包不含插件);发完市场,用户重启客户端即生效。
- 客户端需要新插件能力(新宿主 API)时,先在桌面仓实现并发布客户端,再升插件版本依赖它——顺序不能反。
## 8. 换行符与 SRI(2026-12-03 Windows 实测)
- 现象:Windows 构建机(`core.autocrlf=true`)出的包里,`plugin-style-source.*.js` 的 SRI 校验失败,WebView2 拒绝执行该插件;构建本身不报错。
- 根因:插件产物是逐字拷进 dist 的,CRLF 让字节和 `plugins/index.json` 里记的哈希对不上;`git status` 看不出(text 归一化)。
- 已修:`scripts/copy-plugins.js` 写 dist 时对 `.js/.css/.json/.html/.svg/.txt/.md` 统一转 LF;`scripts/check-dist.js` 新增「dist/plugins 逐条 vs index.json 哈希」校验(`verify:ci` 会跑)。
- 以后新增「逐字拷贝」的文件类型,必须同时进 `TEXT_EXT` 或保持二进制,别让它带着平台换行进包。
+85
View File
@@ -0,0 +1,85 @@
# 工程流程优化建议(2026-12-02)
> 背景:v3.26.154 → v3.26.182 两天内连续排掉「标注覆盖丢图 / 图片源失效 / 空闲 CPU 15% / 平移残影」四类问题,
> 过程中走了不少弯路(连改 6 版靠猜、日志写丢、提交漏文件、并行构建抢锁)。本文把教训固化成流程。
> 技术细节见 `performance-lessons-2026-12-01.md`;UI 数值规则见 `ui-change-checklist.md`。本文只谈「怎么做事」。
## 0. 现状判断:规范不缺,缺的是执行顺序
- 已有:`engineering-rulebook.md`(技术规则)、`ui-change-checklist.md`(token 四道闸门)、`plugin-*.md`(插件契约)、多份 lessons 文档。
- 缺的是:**一次问题从「现象」到「验证」的标准路径**,以及「什么时候必须停下来取数、不许再改代码」。
## 1. 这两天真事暴露的 5 个流程缺陷
| # | 现象 | 根因 | 新约定 |
| --- | --- | --- | --- |
| 1 | 162→168 连改 6 版,163 反而更糟 | 全程靠假设,没有先取证 | 先取数,再改代码(见 §2) |
| 2 | 加了 plugin-img 日志却查不到 | 观测通道本身没验证(logPut 契约不匹配) | 改代码前先确认日志真能落盘 |
| 3 | 181 提交 message 写了、diff 里没有 | 提交前没对文件清单 | 提交后 `git show --stat` 自检 |
| 4 | 两个构建任务同时跑,互相抢 artifact 锁 | 没有「构建单实例」约束 | 构建前 `preflight`,任务名带版本 |
| 5 | 一天 bump 29 个版本 | 每次小改都出一版 | 一轮修复只出一个测试包(除非用户明确要逐版) |
## 2. 修 bug 的标准流程(7 步,缺一步就回到第 1 步)
1. **写现象卡**:可复现步骤、期望 vs 实际、影响面(哪个页面/哪个动作)。
2. **取证**(至少一项):诊断页数值 / `_boot.log` / 帧探针 `perf` / 最小对照实验(最小化、回收内存、关开关)。
3. **列假设**(≤3 条),每条写清「如果成立,应该看到什么数据」。
4. **一次只改一条**,改前记录基线(CPU、堆、进程、DOM、日志行)。
5. **验证**:同一条复现路径,数值回到基线或现象消失。
6. **留断言**:单测 / 契约测试 / 日志断言,必须能在这个 bug 上变红。
7. **写 3 行结论**进 lessons 文档并提交(现象、根因、修法)。
> 硬性停止条件:同一假设连改两次没效果 → 停下来重新取证,不要换着位置继续改。
## 3. 新功能探索:先切片,再扩展
1. **最小切片**:一个文件 + 一个 feature flag + 一条接线,先用真机确认「方向对」。
2. **先定退出条件**:什么算成功(指标/截图/日志),达不到就回滚,不带病上线。
3. **不变量自查**:会不会碰图片链路(字节/引用/缩略图)、存储(落盘/回滚)、插件契约(ctx.api)?碰了就按对应 lessons 文档过一遍。
4. **一次一个行为**:不把「重构 + 新功能 + 样式」塞进同一个提交。
## 4. UI 与 design token
沿用 `ui-change-checklist.md` 的四道闸门(`tokens:check` / `lint:tokens` / 插件契约 / 尺度棘轮 / 视觉回归)。
新增改 UI 前的「三问」:
1. 这个值属于哪一层 token?(L2 语义层优先,禁止裸值)
2. 有没有同类组件先例?(有就复用,不新造)
3. 这次改动的视觉基线是哪张截图?(改完要和它 diff)
新增 token 的门槛不变:消费者 ≥2、亮暗两套值、有弃用计划(见 `design-tokens.md` §5.1)。
## 5. 与构建机(work)协作
> **交付节奏(2026-12-02 用户明确)**:用户报问题后,先只做分析与方案,**不要立即改代码、不要构建任何版本(含 Windows 测试包)**;等用户明确说「开始/可以做」再动手。构建前必须得到确认。
> **分工红线(2026-12-02 用户明确)**:**所有代码修改只在 mac 侧执行**(mac 上负责实施的 agent)。
> win 构建机只做「拉取指定 SHA → 构建/打包 → 回报路径/字节/sha256/FileVersion」这类流程性动作,
> **不具备也不承担改代码的能力**;遇到需要改源码/测试/文档的情况,一律回报给 mac 侧处理,不许在 win 侧就地改。
> 文档/计划/单测同样算代码改动。
- **基线只认已推送的 SHA**;给不出明确基线时,由 mac 侧先 fetch 再指定。
- 产物回报四件套:本地路径 / 字节 / sha256 / `dist/version.json`。
- 取件只走 tailnet(局域网段、UGD 共享都验过不通);用户在本机时优先让他直接装本地产物。
- 构建前跑 `preflight`,确保没有并行构建。
## 6. 已落地的工具
| 命令 | 作用 |
| --- | --- |
| `npm run preflight` | 工作区 / 三处版本一致 / 构建单实例 / 插件两仓一致 / token 快照,一次体检 |
| `npm run diag:tail` | 取资料目录 `_boot.log` 的 `plugin-img / perf / thumb-fail / mem` 关键行 |
脚本在 `scripts/preflight.sh`、`scripts/diag-tail.sh`;`IWB_DATA_DIR` 可指定非默认资料目录。
## 7. 过程度量(用来判断流程是否真的在起作用)
每个问题记录三个数:**版本数、构建数、往返次数**(用户测 → 反馈 → 再改算一次往返)。
- 目标:版本 ≤2、构建 ≤3、往返 ≤3。
- 超过任一阈值 → 停下来写现象卡,而不是继续试。
## 8. 一句话总结
> 先取证再动手;一次只动一个变量;改完留断言;提交前对清单;发版前跑 preflight。
+7 -3
View File
@@ -1,7 +1,7 @@
{
"name": "image-workbench-web",
"private": true,
"version": "3.26.169",
"version": "3.26.240",
"description": "Browser-based node canvas image workbench",
"scripts": {
"build": "node scripts/build.js && node scripts/copy-plugins.js",
@@ -10,7 +10,7 @@
"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/plugin-text-node-refs-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/image-writeback-test.js && node tests/image-ingest-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/uiLine 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",
"check:plugins": "node scripts/check-plugins-sync.js",
@@ -36,7 +36,11 @@
"release:desktop": "bash scripts/release.sh",
"lint:tokens": "node scripts/token-lint.js",
"test:tokens": "node tests/design-token-ratchet-test.js && node tests/theme-contrast-test.js",
"test:e2e:smoke": "node scripts/e2e-smoke.js"
"test:e2e:smoke": "node scripts/e2e-smoke.js",
"preflight": "bash scripts/preflight.sh",
"diag:tail": "bash scripts/diag-tail.sh",
"perf:baseline": "node scripts/perf-baseline.js",
"release:verify": "node scripts/release-verify.js"
},
"devDependencies": {
"@playwright/test": "^1.64.1",
+30 -4
View File
@@ -76,6 +76,28 @@
svg.appendChild(p)
return p
}
// 2026-12-03:卡片下载图标与输出面板同款(同一组 path / 线宽 / 14px)。
// 之前是文本 '↓',字形随字体渲染,和宿主按钮对不齐。
function dlGlyph () {
var svg = document.createElementNS(SVG_NS, 'svg')
svg.setAttribute('viewBox', '0 0 24 24')
svg.setAttribute('width', '14')
svg.setAttribute('height', '14')
svg.setAttribute('fill', 'none')
svg.setAttribute('stroke', 'currentColor')
svg.setAttribute('stroke-width', '2')
svg.setAttribute('stroke-linecap', 'round')
svg.setAttribute('stroke-linejoin', 'round')
svg.setAttribute('aria-hidden', 'true')
svgPath(svg, 'M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4')
var pl = document.createElementNS(SVG_NS, 'polyline')
pl.setAttribute('points', '7 10 12 15 17 10')
svg.appendChild(pl)
var ln = document.createElementNS(SVG_NS, 'line')
ln.setAttribute('x1', '12'); ln.setAttribute('x2', '12'); ln.setAttribute('y1', '15'); ln.setAttribute('y2', '3')
svg.appendChild(ln)
return svg
}
function sel (options, value) {
var s = el('select', { class: 'iwb-input iwb-select-compact' })
for (var i = 0; i < options.length; i++) {
@@ -578,12 +600,16 @@
b.addEventListener('click', function (e) { e.stopPropagation(); fn() })
return b
}
// v1.7.2:图片卡片上只留「下载」;插入仍可从顶部工具栏或右键菜单进入。
acts.appendChild(act('下载', '下载到本地', function () { doDownload([it.name]) }))
// 2026-12-02(用户裁定):卡片上的「下载」胶囊改成右下角圆形图标 —— 矮图不再被横条压住中心;
// 只留图标不加文案(title/aria-label 兜底)。插入仍走顶部工具栏与右键菜单。
var dlBtn = el('button', { class: 'iwb-gal-dl', title: '下载到本地', 'aria-label': '下载' }, dlGlyph())
dlBtn.addEventListener('click', function (e) { e.stopPropagation(); doDownload([it.name]) })
acts.appendChild(dlBtn)
// 不要再改 class:定位样式挂在 .iwb-history-actions 上,改名会让按钮掉出卡片
box.appendChild(acts)
// 角标/勾选最后挂:不要 z-index(插件层级闸门禁止裸值),靠 DOM 顺序盖在图片上
if (origBadge) box.appendChild(origBadge)
if (on) box.appendChild(el('span', { class: 'iwb-history-check', title: '已选中' }))
// 2026-12-02:选中只留外框,不再挂角标图标(用户裁定)
box.__iwbItem = it
box.__iwbBoot = boot
nodeCache[it.name] = box
@@ -849,7 +875,7 @@
global.IWBPluginHost.register({
id: 'gallery',
name: '图库',
version: '1.9.9',
version: '1.9.12',
apiVersion: 1,
capabilities: ['panels', 'gallery'],
data: { schemaVersion: 1, maxBytes: 65536 },
+3 -3
View File
@@ -1,7 +1,7 @@
{
"id": "gallery",
"name": "图库",
"version": "1.9.9",
"version": "1.9.12",
"apiVersion": 1,
"main": "main.js",
"style": "styles.css",
@@ -13,7 +13,7 @@
"图库"
],
"files": {
"main.js": "22b2d8aa07ec193703d57603e857a6e48e054874ef943603d2ed7b1f3c560fd9",
"styles.css": "07ca657d2e5f5d9406e6c7f7306906e34f2ee10a2fa4c2165358451f5461c6a4"
"main.js": "017277118b96545cd7cae386b37dca9b23a44593f53e0e858aedf901b994a153",
"styles.css": "d0479dad661370dfa23d85e4470c5885cbe38fb3b4de9097ad084c952e16d516"
}
}
+16 -7
View File
@@ -84,19 +84,28 @@
min-height: 84px; padding: 8px; border-radius: 6px; border: 1px dashed var(--iwb-border);
font-size: 11px; color: var(--iwb-text2); background: var(--iwb-layer2); word-break: break-all;
}
/* v1.7.3:把「下载」做成卡片底部渐变的下载浮层(与输出节点同一套语义)。
条本身 pointer-events:none,只有悬停后按钮可点,避免挡住卡片点击/双击预览。 */
/* 2026-12-02(用户裁定):卡片下载从「底部横条」改为「右下角圆形图标」。
—— 矮图(宽幅)不再被横条压住中心,除按钮外整张图都能点。
尺寸/圆角/间距抽成 --iwb-dl-* 变量,宿主 style.css 用同名变量(同一套 token 口径,后续可提升到主题层)。 */
.iwb-history-actions {
position: absolute; left: 0; right: 0; bottom: 0; display: flex; justify-content: center; gap: 4px;
padding: var(--iwb-space-16) var(--iwb-space-4) var(--iwb-space-4); border-radius: 0 0 6px 6px;
background-image: linear-gradient(to top, rgba(0, 0, 0, .62), transparent);
position: absolute; right: var(--iwb-dl-inset, 8px); bottom: var(--iwb-dl-inset, 8px);
display: flex; gap: var(--iwb-dl-gap, 4px);
opacity: 0; transition: opacity var(--iwb-motion-hover, .15s) var(--iwb-ease-hover, ease-out);
pointer-events: none;
}
.iwb-history-embedded .iwb-history-item:hover .iwb-history-actions,
.iwb-history-embedded .iwb-history-item:focus-within .iwb-history-actions { opacity: 1; pointer-events: auto; }
.iwb-history-actions .iwb-btn-sm { padding: 2px 8px; font-size: 11px; border: none; background: var(--iwb-panel); color: var(--iwb-text); }
.iwb-history-actions .iwb-btn-sm:hover { background: var(--iwb-panel); color: var(--iwb-brand); }
/* 2026-12-03:与输出面板的圆钮完全对齐(26px / 无阴影 / SVG 14px / hover 只变底色)。 */
.iwb-gal-dl {
width: var(--iwb-dl-size, 26px); height: var(--iwb-dl-size, 26px);
border-radius: var(--iwb-dl-radius, 999px);
border: 1px solid var(--iwb-border2);
background: var(--iwb-panel); color: var(--iwb-text);
display: grid; place-items: center; padding: 0; cursor: pointer;
font-size: var(--iwb-font-xs); line-height: 1;
}
.iwb-gal-dl svg { width: 14px; height: 14px; }
.iwb-gal-dl:hover { background: var(--iwb-hover); color: var(--iwb-text); }
@media (prefers-reduced-motion: reduce) {
.iwb-history-embedded .iwb-history-item img { transition: none; }
.iwb-history-embedded .iwb-history-item:hover img { transform: none; }
+26 -15
View File
@@ -18,9 +18,9 @@
},
{
"id": "blank-canvas",
"file": "plugin-blank-canvas.67763893fa99.js",
"version": "1.0.0",
"integrity": "sha256-Z3Y4k/qZyP4di89kBCb1u8V2q9NbzchMkQt7CPeZZPk="
"file": "plugin-blank-canvas.80bcccc04527.js",
"version": "1.0.1",
"integrity": "sha256-gLzMwEUn42aQISBsetmCJ2GKdNHPoDmrlZB6WkOMam8="
},
{
"id": "browser",
@@ -33,10 +33,10 @@
"dir": "gallery",
"main": "main.js",
"style": "styles.css",
"version": "1.9.9",
"version": "1.9.12",
"files": {
"main.js": "22b2d8aa07ec193703d57603e857a6e48e054874ef943603d2ed7b1f3c560fd9",
"styles.css": "07ca657d2e5f5d9406e6c7f7306906e34f2ee10a2fa4c2165358451f5461c6a4"
"main.js": "017277118b96545cd7cae386b37dca9b23a44593f53e0e858aedf901b994a153",
"styles.css": "d0479dad661370dfa23d85e4470c5885cbe38fb3b4de9097ad084c952e16d516"
}
},
{
@@ -55,10 +55,10 @@
"dir": "promptlib",
"main": "main.js",
"style": "styles.css",
"version": "1.14.11",
"version": "1.14.14",
"files": {
"main.js": "c807d9ce8b1a7df851e00dd724e585d3158b2031194e71ca154d3def383385d7",
"styles.css": "182783b15335895b5a40822bf137a7b4872ca0c6ee72434bfa61a97b37453a07"
"main.js": "27f5c4dd5e90ee6ae0bf7ad8ecf36bae62c2e436c2882c7c41f6272a32f7bafd",
"styles.css": "a086b172cc8261b9f346e612b5f76cc085d5a1e486657d0c656cb87c675f238c"
}
},
{
@@ -69,9 +69,9 @@
},
{
"id": "image-vectorize",
"file": "plugin-image-vectorize.b3a8c21f7a2b.js",
"version": "0.6.2",
"integrity": "sha256-s6jCH3or6tQZ5umJnZ/ka6nk+n5np3elAFaUK1aPV9E="
"file": "plugin-image-vectorize.a47baa43948e.js",
"version": "0.6.3",
"integrity": "sha256-pHuqQ5SODCQ4EoAXRgKzsHghTLBvKu9pibGz6jNZQrk="
},
{
"id": "sticky",
@@ -87,14 +87,25 @@
},
{
"id": "white-bg-800",
"file": "plugin-white-bg-800.ffc18c23ed74.js",
"version": "1.2.2",
"integrity": "sha256-/8GMI+10+BZHc63Df5B+t7KyxGpj8MonfblJ7/xWizM="
"file": "plugin-white-bg-800.a27695876233.js",
"version": "1.2.3",
"integrity": "sha256-onaVh2IzZW8Gluc4ZhDbMEh5KO+yaRWB7LsIhOaoBEY="
},
{
"id": "xianyi-cutout",
"file": "plugin-xianyi-cutout.f7898f6e0fe9.js",
"version": "1.0.4",
"integrity": "sha256-94mPbg/p+Pikvfkc59u+U4wPJ+45jc46JTlNptVZIB0="
},
{
"id": "taskqueue",
"dir": "taskqueue",
"main": "main.js",
"style": "styles.css",
"version": "1.0.3",
"files": {
"main.js": "5f08181338062c9327f22e742be7e1e161a32d2e1bc41ae775a73e0e15b9f3a9",
"styles.css": "4de612a1d25cb74a76f1888fdde32c0f617cc6ab5cc1a0f0bd6ff1adccc757e4"
}
}
]
+11
View File
@@ -140,5 +140,16 @@
"批量",
"出图"
]
},
"taskqueue": {
"name": "任务队列",
"desc": "全局生图记录:链接/状态/画布节点;下载落地图库、重试、复制链接、定位节点(数据由宿主保存)",
"author": "official",
"icon": "⏳",
"color": "#eef6f6",
"tags": [
"工具",
"记录"
]
}
}
+125 -38
View File
@@ -85,7 +85,7 @@
// 看不到 mount() 内部的函数(曾导致 "Can't find variable: fillTpl")。
function detectVars (text) {
var out = [], seen = {}
var re = /\{([^{}\n]{1,60})\}/g, m
var re = /\{([^{}]*)\}/g, m
var str = String(text || '')
while ((m = re.exec(str))) {
var k = String(m[1] || '').trim()
@@ -96,7 +96,7 @@
return out
}
function fillTpl (tpl, vals) {
return String(tpl || '').replace(/\{([^{}\n]{1,60})\}/g, function (all, k) {
return String(tpl || '').replace(/\{([^{}]*)\}/g, function (all, k) {
var key = String(k || '').trim()
var v = (vals && Object.prototype.hasOwnProperty.call(vals, key)) ? String(vals[key] == null ? '' : vals[key]) : ''
return v ? v : all
@@ -125,27 +125,36 @@
ta.style.overflowY = h > max + 1 ? 'auto' : 'hidden'
}
// `{…}` 里能放多少字:v1.13.0 起占位符里放的是「内容」原文(用户裁定),所以这条上限
// 按「一句内容」定,不再按短变量名定。**必须与下面所有正则里的 {1,60} 保持一致**:
// 识别用 60、替换用更小的值,就会出现「识别到了但替换不到」⇒ 变量那段被 outputText 整段删掉。
var KEY_MAX = 60
// 变量「内容」框的最大高度(约 10 行后框内滚动)。下限由 rows=3 + CSS min-height 保证。
// v1.13.0:用户要求「默认最高行数多加 4 行」⇒ 6 行(132px)→ 10 行(212px,行高 1.65×12px≈19.8)。
var VDEF_MAX = 212
// 内容 → 正文里的占位符键:`{…}` 只能单行、不超过 KEY_MAX 字、不含花括号。
// v1.15.0(2026-12-03,用户裁定):正文 `{}` 里放「内容」原文,**不限长度、允许多行**;只禁花括号。
// 下面 6 处正则必须保持一致(都以「最近的一对花括号」为界),否则会「识别到但替换不到」。
// 变量「内容」框的最大高度(超出后框内滚动;面板本身可拖大)。
var VDEF_MAX = 320
// 节点输入框:默认最多 20 行(行高 1.5×12px=18px),超过后折叠,可「展开」看全;永不出滚动条。
var NIN_LINES = 20
var NIN_LINE_H = 18
var NIN_MAX = NIN_LINES * NIN_LINE_H + 8
// 空值只显示灰字提示时的上限:避免一条几千字的默认内容把刚放下的节点撑很高。
var NIN_PH_MAX = 120
// 内容 → 正文里的占位符键:任意长、可多行,但不能含花括号(边界会分不清)。
// 不满足就返回空串 ⇒ 调用方保留原键(正文不跟随),绝不硬塞进 `{}` —— 塞进去会让变量
// 直接识别不到,下次 sync 就把它从变量列表里清掉,用户刚写的内容当场丢失。
function contentKeyOf (s) {
// 2026-12-03(用户裁定):正文 `{}` 里就是内容原文,允许长文本与多行;只禁花括号(否则边界分不清)。
var t = String(s || '').trim()
if (!t || t.length > KEY_MAX) return ''
if (/[{}\n\r]/.test(t)) return ''
if (!t) return ''
if (/[{}]/.test(t)) return ''
return t
}
// 提交给下游/生图的文本:填完变量后,把未填的 {占位} 从输出里剔除(只在编辑器里展示)。
function outputText (tpl, vals) {
var s = fillTpl(tpl, vals)
return s.replace(/[{][^{}]{1,60}[}]/g, ' ').replace(/[ ]{2,}/g, ' ').trim()
// 2026-12-03:先剔除「没有值」的占位,再填值 —— 填完不再扫花括号,避免把值里的 {} 一起删掉。
var s = String(tpl || '').replace(/\{([^{}]*)\}/g, function (all, k) {
var key = String(k || '').trim()
var has = !!(vals && Object.prototype.hasOwnProperty.call(vals, key) && String(vals[key] == null ? '' : vals[key]) !== '')
return has ? all : ' '
})
return fillTpl(s, vals).replace(/[ ]{2,}/g, ' ').trim()
}
function varsOf (p) {
@@ -1143,9 +1152,17 @@
function up () { global.removeEventListener('pointermove', mv); global.removeEventListener('pointerup', up); saveDlg(key, live) }
global.addEventListener('pointermove', mv); global.addEventListener('pointerup', up)
})
mask.addEventListener('pointerdown', function (e) { if (e.target === mask) close() })
// 2026-12-03:关闭前给调用方一次拦截机会(编辑词例用它做「未保存确认」);
// maskClose:false 时点空白不关闭(防止误点丢编辑)。
function requestClose () {
if (typeof opts.confirmClose === 'function') {
try { opts.confirmClose(close); return } catch (e) { /* 回退到直接关闭 */ }
}
close()
}
mask.addEventListener('pointerdown', function (e) { if (opts.maskClose !== false && e.target === mask) requestClose() })
function onKey (e) {
if (e.key === 'Escape') { e.stopPropagation(); close() } else if ((e.metaKey || e.ctrlKey) && e.key === 'Enter' && opts.onSaveKey) { e.preventDefault(); opts.onSaveKey() }
if (e.key === 'Escape') { e.stopPropagation(); requestClose() } else if ((e.metaKey || e.ctrlKey) && e.key === 'Enter' && opts.onSaveKey) { e.preventDefault(); opts.onSaveKey() }
}
function close () {
saveDlg(key, live)
@@ -1164,7 +1181,7 @@
// label = 变量名称:只影响节点左栏显示(最多 4 字,超出省略),空则显示 key
// def = 内容:正文里 `{}` 里的那段字,也是节点输入框留空时真正传给下游的值
// desc = 说明:可选,填了就优先于内容作为节点输入框的灰字提示
// 约束:`{}` 里不能换行、不能超过 KEY_MAX(60) 字。不满足时正文保留原键并在摘要里提示,
// 约束:`{}` 里不能含花括号。不满足时正文保留原键并在摘要里提示,
// 绝不硬塞 —— 塞进去变量就识别不到了,下次 sync 会把它从列表里清掉,内容当场丢失。
// 收起态只留一行「名称 + 内容字数」,展开出现名称/内容/说明;允许多个同时展开。
function makeVarsEditor (text, initial, onTextChange, opts) {
@@ -1202,8 +1219,9 @@
// 摘要:内容字数 + 说明 + 「正文未同步」告警(内容塞不进 `{}` 时才会出现)。
function summaryOf (v) {
var body = bodyOf(v)
var base = (body ? '内容 ' + body.length + ' 字' : '未填内容') + (v.desc ? ' · 有说明' : '')
if (v.def && !contentKeyOf(v.def)) base += ' · 正文未同步(需单行 ≤' + KEY_MAX + ' 字)'
var nl = body ? body.split('\n').length : 0
var base = (body ? '内容 ' + body.length + ' 字' + (nl > 1 ? ' · ' + nl + ' 行' : '') : '未填内容') + (v.desc ? ' · 有说明' : '')
if (v.def && !contentKeyOf(v.def)) base += ' · 内容里不能有 { }(无法同步到正文)'
return base
}
function field (labelText, ctrl) {
@@ -1247,7 +1265,7 @@
// v1.12.3:内容固定从 3 行起步(rows=3),可继续长到 VDEF_MAX 后框内滚动。
// 上一版 rows=1 且「append 之前」就 autoGrowArea ⇒ 元素不在文档里时 scrollHeight 读不到,
// 高度被 CSS min-height 兜成一行,长文案在框里被裁切(用户截图里就是这个现象)。
var area = el('textarea', { class: 'iwb-input iwb-plp-vdef', rows: '3', placeholder: '内容(单行 ≤' + KEY_MAX + ' 字)' })
var area = el('textarea', { class: 'iwb-input iwb-plp-vdef', rows: '3', placeholder: '内容(可多行,不能含 { })' })
area.value = bodyOf(v)
area.addEventListener('input', function () {
v.def = area.value
@@ -1744,7 +1762,7 @@
var txt = el('div', { class: 'iwb-plp-dtext' })
;(function paintText () {
var str = String(p.text || '')
var re = /[{]([^{}]{1,60})[}]/g, last = 0, m
var re = /[{]([^{}]*)[}]/g, last = 0, m
while ((m = re.exec(str))) {
if (m.index > last) txt.appendChild(document.createTextNode(str.slice(last, m.index)))
txt.appendChild(el('span', { class: 'iwb-plp-dvar', text: m[0] }))
@@ -1809,11 +1827,17 @@
var cancelBtn = el('button', { class: 'iwb-btn iwb-btn-sm', text: '取消' })
var saveBtn = el('button', { class: 'iwb-btn iwb-btn-primary iwb-btn-sm', text: isNew ? '创建' : '保存' })
var dirty = false
function closeWithGuard (done) {
if (!dirty) { done(); return }
ask('有未保存的修改,确定放弃?', { title: '放弃修改', okText: '放弃' }).then(function (ok) { if (ok) done() })
}
openDialog({
key: 'edit',
title: isNew ? '新建词例' : '编辑词例',
width: 880, height: 640,
actions: [cancelBtn, saveBtn],
maskClose: false,
confirmClose: function (done) { closeWithGuard(done) },
onSaveKey: function () { doSave() },
build: function (bodyEl, footEl, close) {
var left = el('div', { class: 'iwb-plp-eleft' })
@@ -1898,7 +1922,7 @@
function paintHl () {
var v = textIn.value || ''
hl.textContent = ''
var re = /[{]([^{}]{1,60})[}]/g, last = 0, m
var re = /[{]([^{}]*)[}]/g, last = 0, m
while ((m = re.exec(v))) {
if (m.index > last) hl.appendChild(document.createTextNode(v.slice(last, m.index)))
hl.appendChild(el('span', { class: 'iwb-plp-hlvar', text: m[0] }))
@@ -1938,7 +1962,7 @@
var e = Math.min(Math.max(lastSel.e == null ? s : lastSel.e, s), v.length)
var picked = s !== e ? String(v.slice(s, e)).trim() : ''
// v1.13.0(用户裁定):`{}` 里放的就是内容原文 ⇒ 选中的原文直接当占位符。
// 塞不进 `{}` 时才退到「变量N」:没选中、含换行、或超过 KEY_MAX 字。
// 塞不进 `{}` 时才退到「变量N」:没选中,或选中的文字里带花括号。
// (1.12.0 曾把长句一律改成变量N + 原文进内容,用户否掉了:正文该跟着内容走。)
var embed = contentKeyOf(picked)
var used = {}
@@ -2017,7 +2041,9 @@
}).catch(function () { saveBtn.disabled = false; notify('保存失败', 'err') })
}
saveBtn.addEventListener('click', doSave)
cancelBtn.addEventListener('click', function () { close(); if (!isNew && p) { try { openDetailModal(p) } catch (e) { /* ignore */ } } })
cancelBtn.addEventListener('click', function () {
closeWithGuard(function () { close(); if (!isNew && p) { try { openDetailModal(p) } catch (e) { /* ignore */ } } })
})
dupBtn.addEventListener('click', function () {
var c = collect()
close()
@@ -2244,7 +2270,7 @@
global.IWBPluginHost.register({
id: 'promptlib',
name: '提示词库',
version: '1.14.11',
version: '1.14.14',
apiVersion: 1,
capabilities: ['panels', 'promptlib', 'nodeTypes', 'canvas', 'canvasWrite', 'nodeActions', 'commands'],
data: { schemaVersion: 3, maxBytes: 4 * 1024 * 1024 },
@@ -2361,7 +2387,7 @@
if (st.title.textContent !== name) st.title.textContent = name
var tpl = String(d.tpl || '')
var defs = Array.isArray(d.vdefs) && d.vdefs.length ? d.vdefs : (function () {
var out = [], seen = {}, re = /\{([^{}\n]{1,60})\}/g, m
var out = [], seen = {}, re = /\{([^{}]*)\}/g, m
while ((m = re.exec(tpl))) {
var k = String(m[1] || '').trim()
if (!k || seen[k]) continue
@@ -2386,16 +2412,73 @@
defs.forEach(function (v) {
var row = el('div', { class: 'iwb-plp-nrow' })
var nk = el('span', { class: 'iwb-plp-nk', text: v.label || v.key })
nk.title = v.label || v.key
nk.title = (v.label || v.key) + '(双击回填原内容)'
row.appendChild(nk)
// v1.12.0:单行 input → 自适应 textarea(rows=1 起,最多约 5 行后框内滚动)。
// 以前长文案挤在 24px 单行框里,只能左右拖动看末尾。
// v1.12.3:值默认为空(用户裁定);不填说明时用「内容」当灰字提示,与说明同一样式。
// v1.12.0:单行 input → 自适应 textarea。
// v1.15.0:节点上最多 20 行(NIN_MAX),超出折叠成「展开」,永不出滚动条;节点高度跟着内容走。
var inp = el('textarea', { class: 'iwb-input iwb-plp-nin', rows: '1', placeholder: v.desc || v.def || ('填写 ' + (v.label || v.key)) })
inp.value = String((d.vars && d.vars[v.key]) || '')
inp.addEventListener('input', function () { autoGrowArea(inp, 96); scheduleUpdate(st, d) })
// 失焦后重测:清空输入框时焦点在框内,placeholder 高度没量到,blur 时补一次
inp.addEventListener('blur', function () { autoGrowArea(inp, 96) })
var more = el('button', { class: 'iwb-plp-nmore', type: 'button' })
more.style.display = 'none'
if (!st.expanded) st.expanded = {}
if (!st.refreshH) st.refreshH = {}
var cell = el('div', { class: 'iwb-plp-ncell' }, inp, more)
var refreshH = function () {
var has = String(inp.value || '') !== ''
// 空值的高度靠灰字提示撑:浏览器不把 placeholder 计入 scrollHeight,
// 未聚焦时临时塞进 value 量一次再恢复(沿用旧 autoGrowArea 的做法,不打断输入法)。
var restore = ''
if (!has && (typeof document === 'undefined' || document.activeElement !== inp)) {
var ph = ''
try { ph = String(inp.getAttribute('placeholder') || '') } catch (e0) { ph = '' }
if (ph) { restore = ph; inp.value = ph }
}
inp.style.height = 'auto'
var full = Number(inp.scrollHeight) || 0
if (restore) inp.value = ''
var expanded = !!st.expanded[v.key]
var max = has ? NIN_MAX : NIN_PH_MAX
inp.style.height = Math.min(full, expanded ? full : max) + 'px'
inp.style.overflowY = 'hidden'
if (has && full > NIN_MAX) {
more.style.display = ''
more.textContent = expanded ? '收起' : ('展开(共 ' + String(inp.value || '').length + ' 字)')
} else more.style.display = 'none'
}
// 宽度变化(拖对话框 / 改节点宽度 / 窗口缩放)时重测;只认宽度,避免高度变化自己触发自己。
st.__lastW = st.__lastW || {}
if (typeof ResizeObserver !== 'undefined') {
try {
var ro = new ResizeObserver(function () {
var w = inp.clientWidth
if (w === st.__lastW[v.key]) return
st.__lastW[v.key] = w
refreshH()
})
ro.observe(inp)
} catch (eRO) { /* ignore */ }
}
st.refreshH[v.key] = refreshH
more.addEventListener('pointerdown', function (e) { e.stopPropagation() })
more.addEventListener('click', function (e) {
e.preventDefault(); e.stopPropagation()
st.expanded[v.key] = !st.expanded[v.key]
refreshH()
})
// 双击左侧标题:把这条变量的「内容」回填进输入框(仅当输入框为空),方便接着改长文。
nk.addEventListener('dblclick', function (e) {
e.preventDefault(); e.stopPropagation()
if (String(inp.value || '') !== '') return
var def = st.defOf(v.key)
if (!def) { notify('这条变量没有预设内容'); return }
inp.value = def
st.expanded[v.key] = true
refreshH()
try { inp.focus(); inp.setSelectionRange(inp.value.length, inp.value.length) } catch (err) { /* ignore */ }
scheduleUpdate(st, d)
})
inp.addEventListener('input', function () { refreshH(); scheduleUpdate(st, d) })
inp.addEventListener('blur', function () { refreshH() })
// 宿主的可交互控件白名单是 input/select/button…(src/ui-node-card.js:281,不含 textarea)⇒
// 不拦的话按住文本框拖选文字会把整个节点拖走。
inp.addEventListener('pointerdown', function (e) {
@@ -2408,11 +2491,14 @@
if (inp.scrollHeight > inp.clientHeight + 1) e.stopPropagation()
}, { passive: true })
st.inputs[v.key] = inp
row.appendChild(inp)
row.appendChild(cell)
st.vars.appendChild(row)
// 必须 append 之后再量:脱离文档的元素 scrollHeight 不可靠(会量不到 placeholder 的折行)
autoGrowArea(inp, 96)
setTimeout(function () { autoGrowArea(inp, 96) }, 0)
refreshH()
setTimeout(refreshH, 0)
// 字体/布局晚一拍才定下来:再补两次,避免「打开时偏矮、点一下才对」
try { (typeof requestAnimationFrame === 'function' ? requestAnimationFrame : function (f) { setTimeout(f, 16) })(refreshH) } catch (e1) { /* ignore */ }
setTimeout(refreshH, 120)
})
if (!defs.length) st.vars.appendChild(el('div', { class: 'iwb-plp-nempty', text: '正文里没有 {变量}' }))
try {
@@ -2428,7 +2514,7 @@
var inp = st.inputs[v.key]
if (!inp) return
var ph = v.desc || v.def || ('填写 ' + (v.label || v.key))
if (inp.placeholder !== ph) { inp.placeholder = ph; autoGrowArea(inp, 96) }
if (inp.placeholder !== ph) { inp.placeholder = ph; try { st.refreshH && st.refreshH[v.key] && st.refreshH[v.key]() } catch (e2) { /* ignore */ } }
})
// 缩略图:封面可能是 dataURL,也可能是插件文件引用
@@ -2471,7 +2557,8 @@
}
if (ctx.nodes && typeof ctx.nodes.register === 'function') {
try {
ctx.nodes.register({ id: 'ptpl', title: '提示词模板', defaults: { outKind: 'prompt' }, ports: { in: false, out: true }, height: 360, render: renderTplNode })
// 2026-12-03(用户):补输入端口 —— 参考图节点可以接到模板上(宿主的 nodeRefsOf 会把入边 ref 透传给下游生图)。
ctx.nodes.register({ id: 'ptpl', title: '提示词模板', defaults: { outKind: 'prompt' }, ports: { in: true, out: true }, height: 360, render: renderTplNode })
} catch (e) {
try { ctx.storage && ctx.storage.set('lastError', 'node:' + String((e && e.message) || e)) } catch (e2) { /* ignore */ }
}
+3 -3
View File
@@ -1,7 +1,7 @@
{
"id": "promptlib",
"name": "提示词库",
"version": "1.14.11",
"version": "1.14.14",
"apiVersion": 1,
"main": "main.js",
"style": "styles.css",
@@ -13,7 +13,7 @@
"提示词"
],
"files": {
"main.js": "c807d9ce8b1a7df851e00dd724e585d3158b2031194e71ca154d3def383385d7",
"styles.css": "182783b15335895b5a40822bf137a7b4872ca0c6ee72434bfa61a97b37453a07"
"main.js": "27f5c4dd5e90ee6ae0bf7ad8ecf36bae62c2e436c2882c7c41f6272a32f7bafd",
"styles.css": "a086b172cc8261b9f346e612b5f76cc085d5a1e486657d0c656cb87c675f238c"
}
}
+7 -1
View File
@@ -149,7 +149,7 @@
/* v1.12.1:标签列定宽(此前是 flex:0 0 auto,宽度跟着名称长短变 ⇒ 每个变量输入框左边缘错位)。
v1.13.0:用户要求按 4 字定宽 ⇒ 56px(12px 字号 × 4 + 8px 余量)。超过 4 字的名称省略号截断,完整名称在 title 里。 */
.iwb-plp-nrow{display:flex;align-items:flex-start;gap:6px;min-height:26px}
.iwb-plp-nk{flex:0 0 56px;width:56px;max-width:56px;padding-top:4px;color:var(--iwb-text2,#5b6472);font-size: 12px;line-height:1.35;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.iwb-plp-nk{flex:0 0 56px;width:56px;max-width:56px;padding-top:4px;color:var(--iwb-text2,#5b6472);font-size: 12px;line-height:1.35;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;cursor:pointer;-webkit-user-select:none;user-select:none}
.iwb-plp-nin{flex:1 1 auto;min-width:0;height:auto;min-height:24px;padding:2px 8px;line-height:1.5;font-size: 12px;resize:none;overflow-y:hidden}
/* v1.14.2:参考图开关移到头部(与样式节点一致)——做成浅色药丸,不再是底部分隔行 */
.iwb-plp-nref{display:inline-flex;align-items:center;gap:6px;margin-top:6px;padding:2px 8px;border-radius:6px;background:var(--iwb-layer,#f0f1f4);color:var(--iwb-text2,#4d5668);font-size: 12px;cursor:pointer;align-self:flex-start}
@@ -605,3 +605,9 @@ body.iwb-plp-dragging, body.iwb-plp-dragging *{user-select:none!important;-webki
.iwb-plp-dialog .iwb-plp-vrow2{padding:0 var(--iwb-space-4)}
.iwb-plp-dialog .iwb-plp-vrow2:hover{background:var(--iwb-plugin-hover);border-radius:var(--iwb-radius-control, var(--iwb-radius-card))}
.iwb-plp-vitem.is-open .iwb-plp-vcaret{color:var(--iwb-plp-accent, var(--iwb-text2))}
/* v1.15.0:节点变量输入框(20 行内自然长高,超出折叠;无滚动条) */
.iwb-plp-ncell{flex:1 1 auto;min-width:0;display:flex;flex-direction:column;gap:2px}
.iwb-plp-ncell .iwb-plp-nin{width:100%;flex:0 0 auto}
.iwb-plp-nmore{align-self:flex-start;border:0;background:transparent;color:var(--iwb-brand-text,#2f6bff);font-size:11px;line-height:1.4;padding:0 0 2px;cursor:pointer}
.iwb-plp-nmore:hover{text-decoration:underline}
@@ -39,7 +39,7 @@
global.IWBPluginHost.register({
id: 'blank-canvas',
name: '空白画布',
version: '1.0.0',
version: '1.0.1',
apiVersion: 1,
capabilities: ['nodeActions', 'canvas', 'canvasWrite'],
}, function (ctx) {
@@ -56,10 +56,13 @@
}
// 与上游 isEmptyRefNode 等价:ref 节点且既无本地数据也无 URL({__blob}/{__cache} 引用是对象,天然为真)
// 空白判定:data / url / localRef / ref 任一存在都不算空白。
// v1.0.1:宿主 3.26.183 起大图会被引用化(data 变成 {__blob}/{__file} 对象、localRef/ref 同时指向它),
// 只看 data/url 时「只有本地引用」的节点会被误判为空、直接被白图覆盖掉。
function isEmptyImageNode(node) {
if (!node || node.type !== 'ref') return false
var d = node.data || {}
return !d.data && !d.url
return !d.data && !d.url && !d.localRef && !d.ref
}
function whitePng(w, h) {
@@ -11,7 +11,7 @@
var __IWB_VECTORIZE_MANIFEST__ = {
id: 'image-vectorize',
name: '位图转矢量',
version: '0.6.2',
version: '0.6.3',
apiVersion: 1,
skin: 'private',
capabilities: ['commands', 'nodeActions', 'canvas', 'canvasWrite'],
@@ -3597,6 +3597,11 @@ var __IWB_VECTORIZE_MANIFEST__ = {
document.removeEventListener("keyup", onKeyUp, true);
window.removeEventListener("blur", onBlur);
releasePreview();
// v0.6.3: free heavy state on close (decoded source image + svg string were retained by the closure)
source = null;
currentSvg = "";
lastElements = 0;
lastIslands = 0;
const node = root;
root = null;
els = null;
@@ -145,7 +145,7 @@
global.IWBPluginHost.register({
id: 'white-bg-800',
name: '白底图',
version: '1.2.2',
version: '1.2.3',
apiVersion: 1,
capabilities: ['commands', 'canvas', 'canvasWrite', 'nodeActions'],
settings: {
@@ -228,6 +228,23 @@
return clamp(Number(ctx.settings.get(key)) || fallback, min, max)
}
// 写回(2026-12-02,宿主 3.26.183+):优先 saveNodeImage —— 它会落盘、回读校验、失败回滚旧图并带回原因;
// 老宿主(市场窗口期仍可能是 3.26.182 及更早)没有这个接口,退回同步 setNodeImage。
async function writeBack(id, dataUrl) {
const cw = ctx.canvas
if (cw && typeof cw.saveNodeImage === 'function') {
let r = null
try {
r = await cw.saveNodeImage(id, dataUrl)
} catch (e) {
throw new Error((e && e.message) || '写回画布失败')
}
if (!r || r.ok === false) throw new Error((r && r.error) || '写回画布失败')
return
}
if (!cw || typeof cw.setNodeImage !== 'function' || !cw.setNodeImage(id, dataUrl)) throw new Error('写回画布失败')
}
async function runOne(nodeId, nodeName) {
const img = await resolveImage(nodeId)
@@ -270,7 +287,7 @@
const encoded = await encodeTarget(canvas, target.format, quality, maxBytes, target.allowOversize)
const name = outName(base, size, encoded, target.format)
if (replace && !dual) {
if (!ctx.canvas.setNodeImage(nodeId, encoded.dataUrl)) throw new Error('写回画布失败')
await writeBack(nodeId, encoded.dataUrl)
made.push('覆盖当前节点')
} else {
const created = ctx.canvas.createImageNode({ dataUrl: encoded.dataUrl, name: name })
+249
View File
@@ -0,0 +1,249 @@
// iwb-plugin: 任务队列 —— 左栏整页
//
// 数据全部在宿主:账本(image-ingest-store)、下载/重试(image-ingest)、落地图库、定位节点、记录上限。
// 插件只做视图与手动操作;禁用插件时宿主仍记账(上限内)。
;(function (global) {
'use strict'
if (!global.IWBPluginHost) return
var PAGE_ID = 'taskqueue-page'
var TABS = [['all', '全部'], ['ok', '已完成'], ['down', '下载中'], ['fail', '失败'], ['only', '仅记录']]
var STATUS = { ok: '已完成', down: '下载中', fail: '失败', only: '仅记录' }
var LIMITS = [100, 200, 500, 1000, 2000, 5000]
function el (tag, attrs) {
var node = document.createElement(tag)
if (attrs) {
for (var k in attrs) {
if (!Object.prototype.hasOwnProperty.call(attrs, k)) continue
var v = attrs[k]
if (v === null || v === undefined) continue
if (k === 'class') node.className = v
else if (k === 'text') node.textContent = v
else if (k === 'style') node.setAttribute('style', v)
else node.setAttribute(k, v)
}
}
for (var i = 2; i < arguments.length; i++) append(node, arguments[i])
return node
}
function append (node, v) {
if (v === null || v === undefined || v === false) return
if (Array.isArray(v)) { for (var i = 0; i < v.length; i++) append(node, v[i]); return }
node.appendChild(typeof v === 'string' ? document.createTextNode(v) : v)
}
function clear (node) { while (node.firstChild) node.removeChild(node.firstChild) }
var SVG_NS = 'http://www.w3.org/2000/svg'
function svgEl (tag, attrs) {
var node = document.createElementNS(SVG_NS, tag)
if (attrs) for (var k in attrs) if (Object.prototype.hasOwnProperty.call(attrs, k)) node.setAttribute(k, attrs[k])
return node
}
function fmtTime (ms) {
var d = new Date(Number(ms) || 0)
if (!isFinite(d.getTime())) return ''
var p = function (n) { return (n < 10 ? '0' : '') + n }
return p(d.getMonth() + 1) + '-' + p(d.getDate()) + ' ' + p(d.getHours()) + ':' + p(d.getMinutes())
}
function fmtSize (w, h) { return (w > 0 && h > 0) ? (w + '×' + h) : '' }
function titleOf (it) {
var m = it.meta || {}
var base = String(m.promptText || m.prompt || '').trim()
if (!base) return '历史记录 · ' + fmtTime(it.createdAt) + ' · #' + String(it.id || '').slice(-4)
if (base.length > 24) base = base.slice(0, 24) + '…'
if (m.variant) base += ' · 第 ' + m.variant + ' 张'
return base
}
function mount (host, ctx) {
clear(host)
if (!ctx || !ctx.queue) { host.textContent = '任务队列能力未就绪(请更新客户端)'; return function () {} }
host.classList.add('iwb-plugin-node-body', 'iwb-tq')
var state = { filter: 'all', limit: 500, items: [], total: 0, loading: true, msg: '' }
var timer = 0
var unsub = function () {}
var head = el('div', { class: 'iwb-tq-head' })
var sub = el('div', { class: 'iwb-tq-sub', text: '全局生图记录 · 数据由宿主保存,插件关闭也继续记录' })
var tools = el('div', { class: 'iwb-tq-tools' })
var limitSel = el('select', { class: 'iwb-input iwb-tq-limit', 'aria-label': '记录上限' })
for (var li = 0; li < LIMITS.length; li++) limitSel.appendChild(el('option', { value: String(LIMITS[li]), text: String(LIMITS[li]) + ' 条' }))
var clearBtn = el('button', { class: 'iwb-btn iwb-btn-sm iwb-tq-ghost', text: '清空记录' })
var refreshBtn = el('button', { class: 'iwb-btn iwb-btn-sm iwb-tq-ghost', text: '刷新' })
tools.appendChild(el('span', { class: 'iwb-tq-tool-lbl', text: '记录上限' }))
tools.appendChild(limitSel)
tools.appendChild(clearBtn)
tools.appendChild(refreshBtn)
append(head, [sub, tools])
var tabs = el('div', { class: 'iwb-tq-tabs' })
var tabEls = {}
for (var ti = 0; ti < TABS.length; ti++) {
var key = TABS[ti][0]
var t = el('button', { class: 'iwb-tq-tab' + (key === 'all' ? ' on' : ''), 'data-k': key },
el('span', { text: TABS[ti][1] }), el('span', { class: 'iwb-tq-n', text: '0' }))
tabEls[key] = t
tabs.appendChild(t)
}
var list = el('div', { class: 'iwb-tq-list' })
var foot = el('div', { class: 'iwb-tq-foot' })
// 2026-12-03:整页高度由宿主给满(.iwb-tq{height:100%}),只有列表自己滚;
// 页头/页签/底部说明全程不动,也不会再出现列表撑出容器压住底部说明。
append(host, [head, tabs, list, foot])
function setMsg (m) { state.msg = m || ''; renderFoot() }
function renderFoot () {
clear(foot)
append(foot, [
el('span', { text: '记录只保留链接与本机状态;上限内自动淘汰最旧记录,不影响 images/gallery 里的文件。' }),
el('span', { class: 'iwb-tq-hint', text: state.msg || '点击「下载」= 落地到图库(图库会自动刷新出现)' }),
])
}
function setCounts (stats) {
var s = stats || {}
var map = { all: s.total || 0, ok: s.ok || 0, down: s.down || 0, fail: s.fail || 0, only: s.only || 0 }
for (var k in tabEls) {
var n = tabEls[k].querySelector('.iwb-tq-n')
if (n) n.textContent = String(map[k] || 0)
}
}
function phEl (it) {
return el('div', { class: 'iwb-tq-ph' },
(function () { var s = svgEl('svg', { viewBox: '0 0 24 24', width: '20', height: '20', fill: 'none', stroke: 'currentColor', 'stroke-width': '1.6', 'aria-hidden': 'true' }); s.appendChild(svgEl('path', { d: 'M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4' })); s.appendChild(svgEl('polyline', { points: '7 10 12 15 17 10' })); s.appendChild(svgEl('line', { x1: '12', x2: '12', y1: '15', y2: '3' })); return s })(),
el('span', { text: it && it.kind === 'only' ? '仅记录' : '' }))
}
function thumbOf (it) {
if (it.thumbUrl) {
var img = el('img', { class: 'iwb-tq-img', src: it.thumbUrl, alt: '', draggable: 'false' })
img.addEventListener('error', function () { try { if (img.parentNode) img.parentNode.replaceChild(phEl(it), img) } catch (e) { /* ignore */ } })
return img
}
return phEl(it)
}
function stuckMin (it) {
if (!it || it.kind !== 'down' || it.status !== 'downloading') return 0
var t = Number(it.updatedAt) || Number(it.createdAt) || 0
if (!t) return 0
var ms = Date.now() - t
return ms > 60000 ? Math.floor(ms / 60000) : 0
}
function badgeOf (it) {
if (it.kind === 'ok') return el('span', { class: 'iwb-tq-badge ' + (it.inGallery ? 'ok' : 'warn'), text: it.inGallery ? '已入图库' : '待入库' })
if (it.kind === 'down') {
var sm = stuckMin(it)
if (sm) return el('span', { class: 'iwb-tq-badge warn', text: '可能卡住 · ' + sm + ' 分' })
var label = it.status === 'queued' ? '排队中' : '下载中'
if (it.status === 'downloading' && it.progress > 0) label += ' ' + Math.round(it.progress * 100) + '%'
return el('span', { class: 'iwb-tq-badge', text: label })
}
if (it.kind === 'fail') return el('span', { class: 'iwb-tq-badge fail', text: '下载失败' })
return el('span', { class: 'iwb-tq-badge warn', text: '未下载' })
}
function btn (label, cls, onClick) {
var b = el('button', { class: 'iwb-btn iwb-btn-sm iwb-tq-btn' + (cls ? ' ' + cls : ''), text: label })
b.addEventListener('click', function (e) { e.stopPropagation(); onClick(b) })
return b
}
function rowOf (it) {
var meta = it.meta || {}
var thumb = el('div', { class: 'iwb-tq-thumb', title: '点击预览' }, thumbOf(it))
thumb.addEventListener('click', function () { try { Promise.resolve(ctx.queue.preview(it.id)).catch(function () { setMsg('预览失败') }) } catch (e) { setMsg('预览失败') } })
var line1 = el('div', { class: 'iwb-tq-line1' }, el('span', { class: 'iwb-tq-name', text: titleOf(it), title: String(meta.promptText || meta.prompt || '') }), badgeOf(it))
var bits = []
bits.push(meta.boardName || '未知画布')
if (it.createdAt) bits.push(fmtTime(it.createdAt))
var sz = fmtSize(it.w, it.h); if (sz) bits.push(sz)
if (meta.model) bits.push(meta.model)
var metaLine = el('div', { class: 'iwb-tq-meta', text: bits.join(' · ') })
var main = el('div', { class: 'iwb-tq-main' }, line1, metaLine)
if (it.kind === 'fail' && it.error) main.appendChild(el('div', { class: 'iwb-tq-err', text: it.error + (it.retries ? (' · 已重试 ' + it.retries + ' 次') : '') }))
var acts = el('div', { class: 'iwb-tq-actions' })
if (it.kind === 'ok' && it.inGallery) acts.appendChild(el('button', { class: 'iwb-btn iwb-btn-sm iwb-tq-btn', text: '已在图库', disabled: 'disabled' }))
else if (it.kind === 'down' && !stuckMin(it)) acts.appendChild(el('button', { class: 'iwb-btn iwb-btn-sm iwb-tq-btn', text: '下载中…', disabled: 'disabled' }))
else if (it.kind === 'down') acts.appendChild(btn('重新下载', 'iwb-tq-primary', function () { Promise.resolve(ctx.queue.restart(it.id)).then(function () { setMsg('已重新排队'); schedule() }).catch(function () { setMsg('重新下载失败') }) }))
else acts.appendChild(btn('下载', 'iwb-tq-primary', function (b) { b.disabled = true; ctx.queue.land(it.id).then(function (r) { b.disabled = false; setMsg(r && r.already ? '已在图库' : (r && r.ok ? '已加入落地队列,图库会自动刷新' : '下载失败')) ; schedule() }).catch(function () { b.disabled = false; setMsg('下载失败') }) }))
acts.appendChild(btn('复制原始链接', '', function () { ctx.queue.copyLink(it.id).then(function (r) { setMsg(r && r.ok ? '链接已复制' : '复制失败') }).catch(function () { setMsg('复制失败') }) }))
var loc = btn('定位', '', function (b) { b.disabled = true; ctx.queue.locate(it.id).then(function (r) { b.disabled = false; setMsg(r && r.ok ? '已定位到节点' : ({ 'board-missing': '画布已删除', 'node-missing': '节点已删除', 'missing-meta': '没有定位信息' }[r && r.error] || '定位失败')) }).catch(function () { b.disabled = false; setMsg('定位失败') }) })
if (!(meta.boardId && meta.nodeId)) { loc.disabled = true; loc.title = '没有画布/节点信息' }
acts.appendChild(loc)
return el('div', { class: 'iwb-tq-row ' + (it.kind || '') }, thumb, main, acts)
}
function renderList () {
clear(list)
if (!state.items.length) {
list.appendChild(el('div', { class: 'iwb-tq-empty', text: state.loading ? '加载中…' : '暂无记录 · 生成后会自动出现在这里' }))
return
}
for (var i = 0; i < state.items.length; i++) list.appendChild(rowOf(state.items[i]))
}
function load () {
state.loading = true
renderList()
Promise.all([
ctx.queue.list({ status: state.filter, limit: state.limit }),
ctx.queue.stats(),
ctx.queue.getLimit(),
]).then(function (rs) {
var r = rs[0] || {}
state.items = Array.isArray(r.items) ? r.items : []
state.total = Number(r.total) || state.items.length
state.loading = false
setCounts(rs[1])
var lim = Number(rs[2]) || 500
if (LIMITS.indexOf(lim) < 0) lim = 500
limitSel.value = String(lim)
state.limit = lim
renderList()
}).catch(function () {
state.loading = false; state.items = []; renderList(); setMsg('加载失败')
})
}
function schedule () { clearTimeout(timer); timer = setTimeout(load, 250) }
for (var k in tabEls) (function (key) {
tabEls[key].addEventListener('click', function () {
state.filter = key
for (var kk in tabEls) tabEls[kk].classList.toggle('on', kk === key)
load()
})
})(k)
limitSel.addEventListener('change', function () {
var n = Number(limitSel.value) || 500
state.limit = n
ctx.queue.setLimit(n).then(function () { setMsg('记录上限已改为 ' + n) ; load() }).catch(function () { setMsg('修改上限失败') })
})
clearBtn.addEventListener('click', function () {
if (!global.confirm('清空已完成/失败的记录?不会删除图库文件。')) return
ctx.queue.clear().then(function () { setMsg('已清空记录'); load() }).catch(function () { setMsg('清空失败') })
})
refreshBtn.addEventListener('click', function () { load() })
renderFoot()
load()
try { unsub = ctx.queue.onChanged(schedule) || function () {} } catch (e) { unsub = function () {} }
return function () { clearTimeout(timer); try { unsub() } catch (e) { /* ignore */ } }
}
global.IWBPluginHost.register({
id: 'taskqueue',
name: '任务队列',
version: '1.0.3',
apiVersion: 1,
capabilities: ['pages', 'queue'],
}, function (ctx) {
ctx.ui.registerPage({
id: PAGE_ID,
title: '任务队列',
icon: 'queue',
mount: function (host) { return mount(host, ctx) },
})
return {}
})
})(typeof window !== 'undefined' ? window : globalThis)
+19
View File
@@ -0,0 +1,19 @@
{
"id": "taskqueue",
"name": "任务队列",
"version": "1.0.3",
"apiVersion": 1,
"main": "main.js",
"style": "styles.css",
"description": "全局生图记录:链接/状态/画布节点;下载落地图库、重试、复制链接、定位节点(数据由宿主保存)",
"author": "official",
"icon": "⏳",
"tags": [
"工具",
"记录"
],
"files": {
"main.js": "5f08181338062c9327f22e742be7e1e161a32d2e1bc41ae775a73e0e15b9f3a9",
"styles.css": "4de612a1d25cb74a76f1888fdde32c0f617cc6ab5cc1a0f0bd6ff1adccc757e4"
}
}
+40
View File
@@ -0,0 +1,40 @@
/* 任务队列页(插件)—— 颜色/字号/圆角/间距全部走宿主 token;结构尺寸允许字面量。 */
.iwb-tq { display: flex; flex-direction: column; height: 100%; min-height: 0; gap: var(--iwb-space-10); }
.iwb-tq-head { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--iwb-space-16); flex-wrap: nowrap; }
.iwb-tq-sub { color: var(--iwb-text2); font-size: var(--iwb-font-sm); }
.iwb-tq-tools { display: flex; align-items: center; gap: var(--iwb-space-8); flex: 0 0 auto; flex-wrap: nowrap; }
.iwb-tq-tool-lbl { font-size: var(--iwb-font-sm); color: var(--iwb-text2); white-space: nowrap; }
.iwb-tq-limit { height: 28px; padding: 0 var(--iwb-space-8); flex: 0 0 auto; width: auto; min-width: 76px; max-width: 96px; }
.iwb-tq-ghost { background: var(--iwb-panel); white-space: nowrap; flex: 0 0 auto; }
.iwb-tq-tabs { display: flex; gap: var(--iwb-space-4); border-bottom: 1px solid var(--iwb-border); }
.iwb-tq-tab { display: inline-flex; align-items: center; gap: var(--iwb-space-6); padding: var(--iwb-space-6) var(--iwb-space-10); border: 0; background: transparent; color: var(--iwb-text2); font: inherit; font-size: var(--iwb-font-sm); border-radius: var(--iwb-radius-card) var(--iwb-radius-card) 0 0; cursor: pointer; }
.iwb-tq-tab:hover { color: var(--iwb-text); background: var(--iwb-hover); }
.iwb-tq-tab.on { color: var(--iwb-accent-on-surface); background: var(--iwb-accent-tint); }
.iwb-tq-n { font-size: var(--iwb-font-2xs); line-height: 15px; padding: 0 var(--iwb-space-6); border-radius: var(--iwb-radius-full); border: 1px solid var(--iwb-border); color: var(--iwb-text2); }
.iwb-tq-tab.on .iwb-tq-n { border-color: var(--iwb-accent-on-surface); color: var(--iwb-accent-on-surface); background: transparent; }
.iwb-tq-list { flex: 1 1 auto; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding-right: 2px; display: flex; flex-direction: column; gap: var(--iwb-space-8); }
.iwb-tq-row { display: grid; grid-template-columns: 96px minmax(0,1fr) auto; gap: var(--iwb-space-12); align-items: center; padding: var(--iwb-space-10); background: var(--iwb-panel); border: 1px solid var(--iwb-border); border-radius: var(--iwb-radius-card); }
.iwb-tq-row:hover { border-color: var(--iwb-hover-border); }
.iwb-tq-row.fail { border-color: var(--iwb-err-bd); background: color-mix(in srgb, var(--iwb-err) 9%, var(--iwb-panel)); }
.iwb-tq-thumb { width: 96px; height: 64px; border-radius: var(--iwb-radius-control); border: 1px solid var(--iwb-border); background: var(--iwb-layer2); overflow: hidden; display: grid; place-items: center; cursor: zoom-in; position: relative; }
.iwb-tq-img { width: 100%; height: 100%; object-fit: cover; display: block; }
.iwb-tq-ph { display: grid; place-items: center; gap: var(--iwb-space-2); color: var(--iwb-text2); font-size: var(--iwb-font-2xs); }
.iwb-tq-ph svg { width: 20px; height: 20px; }
.iwb-tq-main { min-width: 0; display: flex; flex-direction: column; gap: var(--iwb-space-4); }
.iwb-tq-line1 { display: flex; align-items: center; gap: var(--iwb-space-8); min-width: 0; }
.iwb-tq-name { font-size: var(--iwb-font-base); font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.iwb-tq-badge { flex: 0 0 auto; height: 18px; line-height: 18px; padding: 0 var(--iwb-space-8); border-radius: var(--iwb-radius-full); border: 1px solid var(--iwb-border2); background: var(--iwb-layer); color: var(--iwb-text2); font-size: var(--iwb-font-2xs); }
.iwb-tq-badge.ok { color: var(--iwb-ok); border-color: var(--iwb-ok-bd); background: var(--iwb-ok-bg); }
.iwb-tq-badge.fail { color: var(--iwb-err); border-color: var(--iwb-err-bd); background: var(--iwb-err-bg); }
.iwb-tq-badge.only { color: var(--iwb-warn); border-color: var(--iwb-warn-bd); background: var(--iwb-warn-bg); }
.iwb-tq-badge.warn { color: var(--iwb-warn); border-color: var(--iwb-warn-bd); background: var(--iwb-warn-bg); }
.iwb-tq-meta { font-size: var(--iwb-font-sm); color: var(--iwb-text2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.iwb-tq-err { font-size: var(--iwb-font-xs); color: var(--iwb-err); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.iwb-tq-actions { display: flex; align-items: center; gap: var(--iwb-space-6); flex-wrap: wrap; justify-content: flex-end; }
.iwb-tq-btn { white-space: nowrap; }
.iwb-tq-btn.iwb-tq-primary { background: var(--iwb-brand); color: var(--iwb-on-brand); border-color: var(--iwb-brand); }
.iwb-tq-btn.iwb-tq-primary:hover { filter: brightness(1.05); }
.iwb-tq-empty { padding: var(--iwb-space-32); text-align: center; color: var(--iwb-text2); font-size: var(--iwb-font-sm); }
.iwb-tq-foot { display: flex; justify-content: space-between; gap: var(--iwb-space-12); color: var(--iwb-text2); font-size: var(--iwb-font-xs); }
.iwb-tq-hint { color: var(--iwb-text-dim); }
@media (max-width: 900px) { .iwb-tq-row { grid-template-columns: 72px minmax(0,1fr); } .iwb-tq-actions { grid-column: 2; justify-content: flex-start; } .iwb-tq-thumb { width: 72px; height: 50px; } }
+94
View File
@@ -0,0 +1,94 @@
#!/usr/bin/env node
'use strict'
// 发布产物与站点登记的一致性自检(2026-12-02)
//
// 为什么有它:v3.26.183 发布时发现,NAS 上 3.26.182 的 mac 产物被一个残留后台脚本覆盖成了 183 的字节,
// 而 site/releases.json 仍记着旧 size/sha256 —— 用户下载到的文件与记录不符,全程没有任何报错。
// 这个脚本把「记录 == 线上」变成发布收尾的机械检查:不一致就 FAIL,发版当场发现,而不是等用户下载到错字节。
//
// 用法:
// node scripts/audit-release-files.js # 最近 5 个版本,逐条 HEAD 比对 size(快)
// node scripts/audit-release-files.js --all # 全部版本
// node scripts/audit-release-files.js --sha # 最新版本额外下载核对 sha256(慢)
// 退出码:0 = 全部一致;1 = 有不一致 / 404
//
// 环境变量:IWB_RELEASE_BASE(默认 https://download.maqiart.eu.org/)便于本地/测试站核对。
const fs = require('fs')
const path = require('path')
const https = require('https')
const http = require('http')
const crypto = require('crypto')
const BASE = (process.env.IWB_RELEASE_BASE || 'https://download.maqiart.eu.org/').replace(/\/?$/, '/')
const argv = process.argv.slice(2)
const ALL = argv.includes('--all')
const WITH_SHA = argv.includes('--sha')
const LIMIT = ALL ? Infinity : 5
const json = JSON.parse(fs.readFileSync(path.join(__dirname, '..', 'site', 'releases.json'), 'utf8'))
const releases = (json.releases || []).slice(0, LIMIT)
function request (url, method) {
return new Promise((resolve, reject) => {
const lib = url.indexOf('https:') === 0 ? https : http
const req = lib.request(url, { method }, (res) => {
if (method === 'GET') {
const hash = crypto.createHash('sha256')
let bytes = 0
res.on('data', (c) => { bytes += c.length; hash.update(c) })
res.on('end', () => resolve({ status: res.statusCode, size: bytes, sha256: hash.digest('hex') }))
res.on('error', reject)
return
}
res.resume()
resolve({ status: res.statusCode, size: Number(res.headers['content-length'] || 0) })
})
req.on('error', reject)
req.setTimeout(20000, () => req.destroy(new Error('timeout')))
req.end()
})
}
;(async () => {
const bad = []
const rows = []
let first = true
for (const rel of releases) {
for (const [platform, p] of Object.entries(rel.platforms || {})) {
const url = BASE + String(p.file || '')
const wantSize = Number(p.size || 0)
const wantSha = String(p.sha256 || '')
let got
try {
got = await request(url, 'HEAD')
if (got.status !== 200) throw new Error('HTTP ' + got.status)
} catch (e) {
bad.push(rel.version + ' ' + platform + ' → ' + (e && e.message ? e.message : 'request failed'))
rows.push(['✗', rel.version, platform, '?', String(wantSize), String(e && e.message)])
continue
}
const sizeOk = !wantSize || got.size === wantSize
let shaNote = ''
if (sizeOk && WITH_SHA && first && wantSha) {
try {
const full = await request(url, 'GET')
shaNote = full.sha256 === wantSha ? 'sha ok' : ('sha DIFF ' + full.sha256.slice(0, 12) + ' ≠ ' + wantSha.slice(0, 12))
if (full.sha256 !== wantSha) bad.push(rel.version + ' ' + platform + ' → sha256 不一致(线上 ' + full.sha256.slice(0, 12) + '… / 记录 ' + wantSha.slice(0, 12) + '…)')
} catch (e) { shaNote = 'sha 校验失败' }
}
if (!sizeOk) bad.push(rel.version + ' ' + platform + ' → size 不一致(线上 ' + got.size + ' B / 记录 ' + wantSize + ' B)' + (got.size === (p.size || 0) ? '' : ',文件可能被覆盖'))
rows.push([sizeOk ? '✓' : '✗', rel.version, platform, String(got.size), String(wantSize), shaNote])
}
first = false
}
const pad = (s, n) => String(s).padEnd(n)
console.log('发布产物一致性检查(' + BASE + (ALL ? ',全部版本' : ',最近 ' + Math.min(LIMIT, (json.releases || []).length) + ' 个版本') + ')')
for (const r of rows) console.log(' ' + r[0] + ' ' + pad(r[1], 10) + ' ' + pad(r[2], 16) + ' 线上 ' + pad(r[3], 10) + ' 记录 ' + pad(r[4], 10) + ' ' + r[5])
if (bad.length) {
console.error('\n不一致 ' + bad.length + ' 处:')
for (const b of bad) console.error(' - ' + b)
console.error('\n处理:重传该版本产物并同步 site/releases.json,或把该版本从下载页下掉。')
process.exit(1)
}
console.log('\n全部一致(' + rows.length + ' 条)')
})()
+5
View File
@@ -84,6 +84,7 @@ const sourceModules = [
'ui-components.js',
'plugin-data.js',
'plugin-api-gallery.js',
'plugin-api-queue.js',
'plugin-api-grouplib.js',
'plugin-api-promptlib.js',
'plugin-host.js',
@@ -107,6 +108,9 @@ const sourceModules = [
'canvas-v3-hit.js',
'image-display-thumb.js',
'image-cache-migrate.js',
'image-writeback.js',
'image-ingest.js',
'image-ingest-store.js',
'runtime-frame-probe.js',
'image-remote-cache.js',
'gallery-sync.js',
@@ -148,6 +152,7 @@ const sourceModules = [
'ui-gen-config-panel.js',
'canvas-webview.js',
'plugin-api-images.js',
'plugin-canvas-bridge.js',
'plugin-files-policy.js',
'image-prompt-cover.js',
]
+31
View File
@@ -75,3 +75,34 @@ for (const f of ['favicon.svg', 'manifest.webmanifest', 'icon-192.png', 'icon-51
}
if (!fs.existsSync(path.join(dist, 'sw.js'))) fail('dist/sw.js 必须保留(更新检测 + 图片缓存)')
pass('PWA 图标/manifest 未进 dist,index.html 无引用;sw.js 保留')
// 7. dist/plugins 逐条与 plugins/index.json 的哈希一致(2026-12-03)。
// 动机:Windows 构建机 autocrlf 会把插件 .js 检出成 CRLF,SRI 对不上 → WebView2 拒绝执行该插件,
// 而构建本身不报错(style-source 真实踩过)。这条在 verify:ci 里跑,跨平台都能拦住。
const crypto = require('crypto')
const pluginsDist = path.join(dist, 'plugins')
const pluginsIdxPath = path.join(pluginsDist, 'index.json')
if (!fs.existsSync(pluginsIdxPath)) fail('dist/plugins/index.json 不存在')
const pidx = JSON.parse(fs.readFileSync(pluginsIdxPath, 'utf8'))
const sha256of = (p) => crypto.createHash('sha256').update(fs.readFileSync(p)).digest('hex')
let pin = 0
for (const ent of (pidx || [])) {
if (ent.file) {
const p = path.join(pluginsDist, ent.file)
if (!fs.existsSync(p)) fail('dist/plugins/' + ent.file + ' 不存在')
if (ent.integrity) {
const want = 'sha256-' + crypto.createHash('sha256').update(fs.readFileSync(p)).digest('base64')
if (want !== ent.integrity) fail('dist/plugins/' + ent.file + ' 的 SRI 与 index.json 不一致(换行符/字节被改动?)')
}
if (ent.sha256 && sha256of(p) !== ent.sha256) fail('dist/plugins/' + ent.file + ' 的 sha256 与 index.json 不一致')
pin++
} else if (ent.dir) {
for (const [rel, want] of Object.entries(ent.files || {})) {
const p = path.join(pluginsDist, ent.dir, rel)
if (!fs.existsSync(p)) fail('dist/plugins/' + ent.dir + '/' + rel + ' 不存在')
if (sha256of(p) !== want) fail('dist/plugins/' + ent.dir + '/' + rel + ' 的 sha256 与 index.json 不一致(换行符/字节被改动?)')
pin++
}
}
}
pass('dist/plugins 与 index.json 哈希一致(' + pin + ' 个文件)')
+29 -2
View File
@@ -16,9 +16,35 @@ if (!fs.existsSync(src)) {
}
fs.mkdirSync(dst, { recursive: true })
// 2026-12-03:文本类插件文件统一按 LF 写入 dist。
// Windows 构建机 core.autocrlf=true 时,检出的 .js 是 CRLF;直接 copyFile 会让 dist 里的字节
// 与 plugins/index.json 记的 SRI/sha256 对不上 → WebView2 拒绝执行(style-source 真实踩过)。
const TEXT_EXT = new Set(['.js', '.css', '.json', '.html', '.svg', '.txt', '.md'])
function copyNormalized(from, to) {
if (TEXT_EXT.has(path.extname(from).toLowerCase())) {
const buf = fs.readFileSync(from)
const txt = buf.toString('utf8')
if (txt.indexOf('\r\n') >= 0) {
fs.writeFileSync(to, txt.replace(/\r\n/g, '\n'))
return
}
}
fs.copyFileSync(from, to)
}
function normalizeTree(dir) {
for (const name of fs.readdirSync(dir)) {
const abs = path.join(dir, name)
const st = fs.statSync(abs)
if (st.isDirectory()) { normalizeTree(abs); continue }
if (!TEXT_EXT.has(path.extname(name).toLowerCase())) continue
const txt = fs.readFileSync(abs, 'utf8')
if (txt.indexOf('\r\n') >= 0) fs.writeFileSync(abs, txt.replace(/\r\n/g, '\n'))
}
}
let count = 0
for (const name of fs.readdirSync(src)) {
fs.copyFileSync(path.join(src, name), path.join(dst, name))
copyNormalized(path.join(src, name), path.join(dst, name))
count++
}
// v3.25.41(M1):目录插件 <plugins>/<id>/{manifest.json,main.js} 一并进包(应用按 /plugins/<id>/… 取)
@@ -30,8 +56,9 @@ for (const name of fs.readdirSync(pluginsRoot)) {
if (name === 'runtime' || name === 'local') continue
if (!fs.existsSync(path.join(abs, 'manifest.json'))) continue
fs.cpSync(abs, path.join(dst, name), { recursive: true })
normalizeTree(path.join(dst, name))
folders++
}
// 索引与插件文件必须同源同包:应用按 index.json 里的 filename / dir 去 /plugins/ 取
fs.copyFileSync(path.join(root, 'plugins', 'index.json'), path.join(dst, 'index.json'))
copyNormalized(path.join(root, 'plugins', 'index.json'), path.join(dst, 'index.json'))
console.log('[copy-plugins] 已拷入 ' + count + ' 个文件 + ' + folders + ' 个目录插件 → dist/plugins/')
+9
View File
@@ -0,0 +1,9 @@
#!/usr/bin/env bash
# 取资料目录 _boot.log 的关键行。
set -uo pipefail
DIR="${IWB_DATA_DIR:-$HOME/Documents/ImageWorkbench}"
LOG="$DIR/_boot.log"
if [ ! -f "$LOG" ]; then echo "找不到 $LOG(可用 IWB_DATA_DIR 指定资料目录)"; exit 2; fi
PAT="${*:-plugin-img|perf |thumb-fail|mem }"
echo "== $LOG (匹配:$PAT)"
tail -n 400 "$LOG" | grep -E "$PAT" | tail -n 40
+91
View File
@@ -0,0 +1,91 @@
#!/usr/bin/env node
'use strict'
/* 性能基线日常跑(2026-12-02,C 项)
*
* 做什么:build → 起本地静态服(动态端口)→ 只跑 tests/_perf-baseline.spec.js → 关服。
* 为什么单起一个脚本:playwright 没有 webServer 配置,日常跑要手动开两个终端;这里封成一条命令。
* 注意:本 spec **不进 CI**(无头环境没 GPU,数字不可比),只作真机回归。
*
* 用法:
* npm run perf:baseline # 日常档(IWB_PROBE_LIGHT=1,12 步平移)
* IWB_PROBE_LIGHT=0 npm run perf:baseline # 完整档(50 步平移 + 缩放 + 切标签)
* IWB_PROBE_PERF=0 npm run perf:baseline # 只测量不断言(排查时用)
* 阈值可用环境变量覆盖:IWB_PROBE_LR_MAX(长帧比例)/ IWB_PROBE_JS_MAX(longtask 总 ms)/ IWB_PROBE_MIN_FRAMES
*/
const { spawn } = require('node:child_process')
const http = require('node:http')
const net = require('node:net')
const path = require('node:path')
const root = path.resolve(__dirname, '..')
const wait = (ms) => new Promise((r) => setTimeout(r, ms))
function freePort () {
return new Promise((resolve, reject) => {
const s = net.createServer()
s.unref()
s.on('error', reject)
s.listen(0, '127.0.0.1', () => {
const port = s.address().port
s.close(() => resolve(port))
})
})
}
function ping (base) {
return new Promise((resolve) => {
const req = http.get(base + '/', (res) => { res.resume(); resolve(res.statusCode === 200) })
req.on('error', () => resolve(false))
req.setTimeout(1000, () => { req.destroy(); resolve(false) })
})
}
async function main () {
console.log('== 1/3 构建 dist')
// 用 npm run build(build.js + copy-plugins):少了插件,页面 DOM 与真机不一致,帧数据会偏
const build = spawn('npm', ['run', 'build'], { cwd: root, stdio: 'inherit' })
const buildCode = await new Promise((resolve) => build.on('exit', (c) => resolve(c == null ? 1 : c)))
if (buildCode !== 0) { console.error('[perf] 构建失败'); return buildCode }
const PORT = await freePort()
const BASE = 'http://127.0.0.1:' + PORT
const server = spawn(process.execPath, [path.join(root, 'scripts', 'serve-test.js')], {
cwd: root,
env: Object.assign({}, process.env, { IWB_LOCAL_PORT: String(PORT) }),
stdio: ['ignore', 'ignore', 'pipe'],
})
let serverErr = ''
server.stderr.on('data', (d) => { serverErr += String(d) })
const stop = () => { try { server.kill('SIGTERM') } catch (e) { /* ignore */ } }
process.on('SIGINT', () => { stop(); process.exit(130) })
try {
console.log('== 2/3 起本地服 ' + BASE)
let up = false
for (let i = 0; i < 40; i++) {
if (await ping(BASE)) { up = true; break }
if (server.exitCode !== null) break
await wait(250)
}
if (!up) { console.error('[perf] 测试服没起来(端口 ' + PORT + ')' + (serverErr ? '\n' + serverErr.slice(0, 400) : '')); return 1 }
const env = Object.assign({}, process.env, { IWB_BASE_URL: BASE })
if (env.IWB_PROBE_LIGHT == null) env.IWB_PROBE_LIGHT = '1'
console.log('== 3/3 跑基线(LIGHT=' + env.IWB_PROBE_LIGHT + (env.IWB_PROBE_PERF === '0' ? ',只测不断言' : '') + ')')
const args = [require.resolve('@playwright/test/cli'), 'test', 'tests/_perf-baseline.spec.js', '--reporter=line', '--workers=1']
const code = await new Promise((resolve) => {
const pw = spawn(process.execPath, args, { cwd: root, env, stdio: 'inherit' })
pw.on('exit', (c) => resolve(c == null ? 1 : c))
})
if (code !== 0 && serverErr) console.error('[perf] 测试服 stderr:\n' + serverErr.slice(0, 800))
return code
} finally {
stop()
await wait(150)
}
}
main().then((code) => process.exit(code)).catch((e) => {
console.error('[perf] ' + (e && e.message))
process.exit(1)
})
+31
View File
@@ -0,0 +1,31 @@
#!/usr/bin/env bash
# 发版/构建前的统一体检(只读)。
set -uo pipefail
cd "$(dirname "$0")/.."
fail=0
ok() { printf " ok %s\n" "$1"; }
bad() { printf " FAIL %s\n" "$1"; fail=1; }
echo "== 1. 工作区"
dirty=$(git status --porcelain | grep -v -E '^(\?\? (PLUGIN-API-GOVERNANCE-ISSUE|docs/ISSUE-REPLIES|icon\.png))' || true)
if [ -z "$dirty" ]; then ok "无未提交改动(长期未跟踪文件除外)"; else bad "存在未提交改动"; printf "%s\n" "$dirty" | sed 's/^/ /'; fi
echo "== 2. 版本号三处一致"
v1=$(node -p 'require("./package.json").version' 2>/dev/null)
v2=$(node -p 'require("./src-tauri/tauri.conf.json").version' 2>/dev/null)
v3=$(grep -m1 '^version = ' src-tauri/Cargo.toml | cut -d'"' -f2)
if [ "$v1" = "$v2" ] && [ "$v1" = "$v3" ]; then ok "版本 $v1"; else bad "版本不一致 pkg=$v1 tauri=$v2 cargo=$v3"; fi
echo "== 3. 构建单实例"
if pgrep -f 'tauri build|cargo build --bins' >/dev/null 2>&1; then bad "已有构建在跑(等它结束,避免抢锁)"; else ok "无并行构建"; fi
echo "== 4. 插件两仓一致"
if node scripts/check-plugins-sync.js >/dev/null 2>&1; then ok "plugins/ 与源仓一致"; else bad "插件两仓不一致(跑 sync-plugins-from-repo.js)"; fi
echo "== 5. 设计 token 快照"
if npm run -s tokens:check >/dev/null 2>&1; then ok "tokens 无漂移"; else bad "tokens 漂移(npm run tokens:check 看详情)"; fi
echo "== 6. 文档过期写法"
# B1(2026-12-02):现行文档里不得再出现已下线的路径/命令;历史说明用 ~~删除线~~ 或「已弃用/已移除」等词豁免。
stale=$(grep -rnE 'functions/api|functions/plugins|verify:release|plugins-publish|wrangler|_inbox' \
README.md CONTRIBUTING.md PUBLISHING.md docs/standards docs/reference 2>/dev/null \
| grep -v '~~' \
| grep -vE '已删除|已下线|已停用|已移除|已废弃|已弃用|已不存在|已无|不再|删除|废弃|历史|旧|曾' || true)
if [ -z "$stale" ]; then ok "无过期写法(functions/api、verify:release、plugins-publish、_inbox、wrangler)"; else bad "仍有过期写法"; printf "%s\n" "$stale" | sed 's/^/ /' | head -8; fi
echo
if [ "$fail" = "0" ]; then echo "preflight: 通过"; else echo "preflight: 有问题,见上"; fi
exit "$fail"
+11
View File
@@ -135,6 +135,17 @@ if git rev-parse --git-dir >/dev/null 2>&1; then
fi
fi
# == 发布产物一致性自检(2026-12-02)==
# 动机:183 发布时发现 NAS 上 182 的产物被残留后台脚本覆盖,而 releases.json 仍记旧字节,
# 用户下载到错字节却没有任何报错。这里在发布收尾做机械核对(最近 5 个版本 HEAD 比对 size),
# 不一致就非零退出 —— release.sh 会因此停在上传/登记之前,避免把错记录继续带出去。
if node scripts/audit-release-files.js; then
echo "== 产物一致性:通过"
else
echo "✗ 发布产物与 site/releases.json 不一致(见上)—— 先修产物或登记,再继续发版" >&2
exit 1
fi
echo "== 完成:https://download.maqiart.eu.org/updates/latest.json"
curl -s -m 15 https://download.maqiart.eu.org/updates/latest.json | head -c 200; echo
+1 -1
View File
@@ -30,7 +30,7 @@ echo " $OUT"
echo " size=$SIZE sha256=$SHA"
echo "== 2/4 用正式私钥签名"
npx tauri signer sign -f "$KEY" -p "${TAURI_SIGNING_PRIVATE_KEY_PASSWORD:-}" --app-version "$V" "$OUT" >/dev/null
env -u TAURI_SIGNING_PRIVATE_KEY npx tauri signer sign -f "$KEY" -p "${TAURI_SIGNING_PRIVATE_KEY_PASSWORD:-}" --app-version "$V" "$OUT" >/dev/null
SIG_FILE="$OUT.sig"
[ -f "$SIG_FILE" ] || { echo "签名失败:没有产出 $SIG_FILE"; exit 1; }
echo " .sig $(wc -c < "$SIG_FILE" | tr -d ' ') 字节"
+143
View File
@@ -0,0 +1,143 @@
#!/usr/bin/env node
'use strict'
/* 发布后验收(2026-12-02)
*
* 为什么有它:v3.26.183 发布时踩过两次坑 ——
* ① 一个残留后台脚本把 NAS 上的产物覆盖成别的版本,releases.json 仍记旧字节;
* ② latest.json / latest-windows.json / 站点 releases.json 三处版本一度不同步。
* 这两个问题当时全靠人工比对才发现。本脚本把「发布后该核对什么」变成一条命令。
*
* 核对项:
* 1) latest.json / latest-windows.json / site/releases.json / package.json 四处版本一致
* 2) 三平台齐全(darwin-aarch64 / darwin-x86_64 / windows-x86_64),且 latest.json 的 URL 指向同一版本文件
* 3) releases.json 里每条记录的 size(HEAD)与 sha256(下载校验,--fast 可跳过)与线上实际一致
* 4) 下载页 HTML 含当前版本号
*
* 用法:
* npm run release:verify # 完整(会下载 dmg/exe 核对 sha256,约 30~60s)
* npm run release:verify -- --fast # 只 HEAD 比对 size
* 退出码:0 通过;1 有不一致
*/
const fs = require('fs')
const path = require('path')
const https = require('https')
const http = require('http')
const crypto = require('crypto')
const BASE = (process.env.IWB_RELEASE_BASE || 'https://download.maqiart.eu.org/').replace(/\/?$/, '/')
const FAST = process.argv.includes('--fast')
const root = path.resolve(__dirname, '..')
const PLATS = ['darwin-aarch64', 'darwin-x86_64', 'windows-x86_64']
const rows = []
let failed = 0
const add = (ok, name, detail, warnOnly) => {
if (!ok && !warnOnly) failed++
rows.push({ ok, warnOnly: !!warnOnly, name, detail })
console.log(' ' + (ok ? '✓' : (warnOnly ? '!' : '✗')) + ' ' + String(name).padEnd(22) + ' ' + (detail || ''))
}
function req (url, method) {
return new Promise((resolve, reject) => {
const lib = url.indexOf('https:') === 0 ? https : http
const r = lib.request(url, { method, headers: { 'cache-control': 'no-cache' } }, (res) => {
if (res.statusCode >= 300 && res.statusCode < 400 && res.headers.location) {
res.resume(); return resolve(req(new URL(res.headers.location, url).toString(), method))
}
if (method === 'GET') {
const hash = crypto.createHash('sha256'); let bytes = 0; const chunks = []
res.on('data', (c) => { bytes += c.length; hash.update(c); chunks.push(c) })
res.on('end', () => resolve({ status: res.statusCode, size: bytes, sha256: hash.digest('hex'), body: Buffer.concat(chunks) }))
res.on('error', reject); return
}
res.resume()
resolve({ status: res.statusCode, size: Number(res.headers['content-length'] || 0) })
})
r.on('error', reject)
r.setTimeout(20000, () => r.destroy(new Error('timeout')))
r.end()
})
}
async function getJson (url) {
const r = await req(url + (url.indexOf('?') >= 0 ? '&' : '?') + 'x=' + Date.now(), 'HEAD')
if (r.status !== 200) throw new Error('HTTP ' + r.status)
const g = await req(url + (url.indexOf('?') >= 0 ? '&' : '?') + 'x=' + Date.now(), 'GET')
if (g.status !== 200) throw new Error('HTTP ' + g.status)
return JSON.parse(g.body.toString('utf8'))
}
;(async () => {
console.log('发布验收 ' + BASE + (FAST ? '(fast:跳过 sha256)' : ''))
const pkg = JSON.parse(fs.readFileSync(path.join(root, 'package.json'), 'utf8'))
const site = JSON.parse(fs.readFileSync(path.join(root, 'site', 'releases.json'), 'utf8'))
let latest = null, win = null
try { latest = await getJson(BASE + 'updates/latest.json') } catch (e) { add(false, 'latest.json', '拉取失败:' + e.message) }
try { win = await getJson(BASE + 'updates/latest-windows.json') } catch (e) { add(false, 'latest-windows.json', '拉取失败:' + e.message) }
const rel = (site.releases || [])[0] || {}
const vLatest = latest && latest.version
const vWin = win && win.version
const vSite = rel.version
const vPkg = pkg.version
add(!!vLatest, 'latest.json', vLatest ? ('v' + vLatest + '(' + Object.keys(latest.platforms || {}).length + ' 平台)') : '缺失')
add(!!vWin, 'latest-windows.json', vWin ? ('v' + vWin) : '缺失')
add(!!vSite, 'site/releases.json', vSite ? ('v' + vSite + '(' + Object.keys(rel.platforms || {}).length + ' 平台)') : '缺失')
add(vPkg === vLatest || vPkg === vSite, 'package.json', 'v' + vPkg + (vPkg === vLatest ? '' : '(与线上不一致,发布前正常)'), true)
if (vLatest && vWin && vSite) {
add(vLatest === vWin, '三处版本一致', vLatest === vWin ? 'latest == latest-windows' : ('latest ' + vLatest + ' ≠ windows ' + vWin))
add(vLatest === vSite, '三处版本一致', vLatest === vSite ? 'latest == releases.json' : ('latest ' + vLatest + ' ≠ releases ' + vSite))
}
// 平台齐全 + latest.json 的 URL 与 releases.json 指向同一文件
for (const p of PLATS) {
const lp = latest && latest.platforms && latest.platforms[p]
const rp = rel.platforms && rel.platforms[p]
const ok = !!(lp && rp)
add(ok, '平台 ' + p, ok ? 'latest + releases 都有' : ('缺 ' + (lp ? '' : 'latest.json ') + (rp ? '' : 'releases.json')))
if (ok) {
const lb = String(lp.url || '').split('/').pop()
const rb = String(rp.file || '').split('/').pop()
// mac:更新器拿 .app.tar.gz、下载页给 .dmg(本来就是两个文件);win:两者都是同一个 setup.exe
const wantUpdater = p === 'windows-x86_64' ? /\.exe$/ : /\.app\.tar\.gz$/
const wantDownload = p === 'windows-x86_64' ? /\.exe$/ : /\.dmg$/
add(wantUpdater.test(lb) && wantDownload.test(rb), ' 文件形态', lb + ' / ' + rb)
add(String(lp.signature || '').length > 100, ' 签名非空', String((lp.signature || '').length) + ' B')
add(lb.indexOf(vLatest) >= 0 && rb.indexOf(vLatest) >= 0, ' 文件名含版本', lb + ' / ' + rb)
}
}
// 资产实体:size + sha256
for (const [p, item] of Object.entries(rel.platforms || {})) {
const url = BASE + String(item.file || '')
let h
try { h = await req(url, 'HEAD') } catch (e) { add(false, '资产 ' + p, '请求失败:' + e.message); continue }
if (h.status !== 200) { add(false, '资产 ' + p, 'HTTP ' + h.status); continue }
const sizeOk = h.size === Number(item.size || 0)
add(sizeOk, '资产 ' + p, sizeOk ? (h.size + ' B') : ('线上 ' + h.size + ' B ≠ 记录 ' + item.size + ' B(文件可能被覆盖)'))
if (!sizeOk) continue
if (FAST) continue
try {
const g = await req(url, 'GET')
const shaOk = g.sha256 === String(item.sha256 || '')
add(shaOk, ' sha256 ' + p, shaOk ? (g.sha256.slice(0, 12) + '…') : ('线上 ' + g.sha256.slice(0, 12) + '… ≠ 记录 ' + String(item.sha256 || '').slice(0, 12) + '…'))
} catch (e) { add(false, ' sha256 ' + p, '下载失败:' + e.message) }
}
// 下载页
try {
const g = await req(BASE + 'download/?x=' + Date.now(), 'GET')
const html = g.body.toString('utf8')
add(g.status === 200 && html.indexOf(vLatest) >= 0, '下载页', g.status === 200 ? (html.indexOf(vLatest) >= 0 ? '含 v' + vLatest : ('未出现 v' + vLatest)) : ('HTTP ' + g.status))
} catch (e) { add(false, '下载页', '请求失败:' + e.message) }
console.log('')
if (failed) {
console.error('验收失败:' + failed + ' 项不一致(见上 ✗)')
process.exit(1)
}
console.log('验收通过:' + rows.filter((r) => r.ok).length + ' 项')
})().catch((e) => { console.error('验收异常:' + (e && e.message)); process.exit(1) })
+1 -1
View File
@@ -10,7 +10,7 @@ const crypto = require('crypto')
const root = path.resolve(__dirname, '..')
const srcRoot = process.argv[2] ? path.resolve(process.argv[2]) : path.resolve(root, '..', 'iwb-plugins-desktop')
const outDir = path.join(root, 'plugins', 'runtime')
const IDS = ['album', 'batch-export', 'blank-canvas', 'browser', 'gallery', 'grouplib', 'promptlib', 'image-annotate', 'image-vectorize', 'sticky', 'style-source', 'white-bg-800', 'xianyi-cutout']
const IDS = ['album', 'batch-export', 'blank-canvas', 'browser', 'gallery', 'grouplib', 'promptlib', 'image-annotate', 'image-vectorize', 'sticky', 'style-source', 'white-bg-800', 'xianyi-cutout', 'taskqueue']
// v3.25.41(M1):目录化插件试点 —— 这些 id 产出 <id>/{manifest.json,main.js},其余仍是单文件(双轨兼容)
// ⚠️ 2026-11-20 修正:桌面包不随包发插件(scripts/strip-plugins.js),插件只能从市场装,
// 而市场目前只支持单文件 ⇒ 目录形态暂不用于生产插件,等 M3(zip 安装)落地再启用。
+17 -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.154-mx3wxyho">
<link rel="stylesheet" href="/assets/style.css?v=3.26.238-mx7aia6a">
<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.154</a>
<a class="btn primary" href="/download/">下载 v3.26.238</a>
</div>
</div></nav>
<main>
@@ -77,14 +77,26 @@
<tr><td>panels</td><td>ctx.ui</td><td>侧栏/独立面板注册</td></tr>
<tr><td>promptlib</td><td>ctx.promptlib</td><td>提示词库数据 + 文件 + 备份</td></tr>
<tr><td>nodeTypes</td><td>ctx.nodes</td><td>画布节点类型注册</td></tr>
<tr><td>canvas</td><td>ctx.canvas</td><td>只读:getNodes / getSelectedNode / screenToWorld</td></tr>
<tr><td>canvasWrite</td><td>ctx.canvasWrite</td><td>写入:createNode / createImageNode / setNodeImage</td></tr>
<tr><td>canvas</td><td>ctx.canvas</td><td>读:getNodes / getSelectedNode / getNodeImage / screenToWorld</td></tr>
<tr><td>canvasWrite</td><td>ctx.canvas(<strong>合并,没有 ctx.canvasWrite</strong>)</td><td>写:createNode / createImageNode / setNodeImage / saveNodeImage</td></tr>
<tr><td>nodeActions</td><td>ctx.nodeActions</td><td>节点右键/气泡动作</td></tr>
<tr><td>commands</td><td>ctx.commands</td><td>命令面板</td></tr>
<tr><td>settings</td><td>ctx.settings</td><td>KV 配置</td></tr>
<tr><td>data</td><td>ctx.data</td><td>插件数据文件</td></tr>
</tbody></table>
<p><strong>注意</strong>:createNode 在 ctx.canvasWrite,不在 ctx.canvas。调错只会提示“宿主不支持”。</p>
<p><strong>注意</strong>:<code>CAPABILITY_API_KEYS</code> 把 canvasWrite 的接口<strong>合并进 <code>ctx.canvas</code></strong>(<code>src/plugin-host.js</code>);</p>
<p><code>ctx.canvasWrite</code> 并不存在,但 manifest 的 <code>capabilities</code> 仍须同时声明 <code>canvas</code> 与 <code>canvasWrite</code>,否则拿不到写接口。</p>
<p>调错只会提示“宿主不支持”。</p>
<p><strong>图片写回契约(v3.26.183,改前必读)</strong>:</p>
<table><thead><tr><th>接口</th><th>语义</th><th>用法</th></tr></thead><tbody>
<tr><td><code>ctx.canvas.setNodeImage(id, dataUrl)</code></td><td><strong>同步</strong>返回严格布尔;只改内存 + 失效缓存 + 重渲染,<strong>不落盘</strong></td><td>只要“立刻显示”的场景(blank-canvas 填白图、white-bg-800 覆盖)</td></tr>
<tr><td><code>ctx.canvas.saveNodeImage(id, dataUrl)</code></td><td>返回 <code>Promise&lt;{ok, error}&gt;</code>;落盘 + 回读校验,失败<strong>回滚旧图</strong>并给原因</td><td>用户编辑成果必须落地的场景(image-annotate 覆盖)</td></tr>
<tr><td><code>ctx.canvas.createImageNode({ dataUrl, name, x?, y? })</code></td><td><strong>同步</strong>返回节点 id;超过内联阈值的图由宿主后台引用化</td><td>生成新图(白底新建、抠图、矢量化、插图)</td></tr>
</tbody></table>
<ul>
<li>大图(&gt; 宿主内联阈值,现 3000 字符)会被宿主转成本地引用,<code>getNodeImage</code> 仍返回 dataUrl,插件无需感知。</li>
<li><code>getNodes()</code> 返回的 <code>data</code> 是<strong>只读视图</strong>:不要原地改,宿主不会失效缩略图/触发保存;写图只走上面三个接口。</li>
</ul>
<h2>3. 面板</h2>
<pre><code>ctx.ui.registerPanel({
id: 'my-panel',
+23 -7
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.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 class="meta">版本 3.26.238 · 9.7 MB · .dmg<div class="hash">sha256 9ecea14ff71c7ef0…</div></div>
<a class="btn" href="/updates/darwin-aarch64/image-workbench_3.26.238_aarch64.dmg?h=9ecea14ff71c">下载</a>
</div>
<div class="row">
<div class="name">macOS · Intel<div class="hint">x86_64</div></div>
<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 class="meta">版本 3.26.238 · 10.1 MB · .dmg<div class="hash">sha256 0cef46585d874ba2…</div></div>
<a class="btn" href="/updates/darwin-x86_64/image-workbench_3.26.238_x64.dmg?h=0cef46585d87">下载</a>
</div>
<div class="row">
<div class="name">Windows · x64<div class="hint">需要 WebView2</div></div>
<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 class="meta">版本 3.26.238 · 5.3 MB · .exe<div class="hash">sha256 d77c051770a139d5…</div></div>
<a class="btn" href="/updates/windows-x86_64/image-workbench_3.26.238_x64-setup.exe?h=d77c051770a1">下载</a>
</div>
<h2>系统要求</h2>
@@ -97,6 +97,22 @@
</ol>
<h2>历史版本</h2>
<div class="row">
<div class="name">3.26.238<div class="hint">任务队列页头/页签固定;图片读取/下载本地优先 + 命名统一图库行名</div></div>
<div class="meta">2026-12-03<div class="hint">macOS · Apple Silicon / macOS · Intel / Windows · x64</div></div>
</div>
<div class="row">
<div class="name">3.26.184</div>
<div class="meta">2026-12-02<div class="hint">macOS · Apple Silicon / macOS · Intel / Windows · x64</div></div>
</div>
<div class="row">
<div class="name">3.26.183</div>
<div class="meta">2026-12-02<div class="hint">macOS · Apple Silicon / macOS · Intel / Windows · x64</div></div>
</div>
<div class="row">
<div class="name">3.26.169</div>
<div class="meta">2026-12-01<div class="hint">macOS · Apple Silicon / macOS · Intel / Windows · x64</div></div>
</div>
<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>
@@ -815,7 +831,7 @@
</div>
<div class="foot">
本页由 <code>scripts/gen-release-page.js</code> 从 releases.json 生成 · 源码 <a href="https://git.maqiart.eu.org/malongan/image-workbench-desktop">git.maqiart.eu.org</a> · 更新于 2026-11-30
本页由 <code>scripts/gen-release-page.js</code> 从 releases.json 生成 · 源码 <a href="https://git.maqiart.eu.org/malongan/image-workbench-desktop">git.maqiart.eu.org</a> · 更新于 2026-12-03
</div>
</div></div>
+12 -12
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.154-mx3xhehx">
<link rel="stylesheet" href="/assets/style.css?v=3.26.238-mx7aia6a">
</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,20 +17,20 @@
</div>
<div class="right">
<a class="btn" href="/plugins/">插件市场</a>
<a class="btn primary" href="/download/">下载 v3.26.154</a>
<a class="btn primary" href="/download/">下载 v3.26.238</a>
</div>
</div></nav>
<main>
<section class="hero hero-art">
<div class="hero-bg"><img src="/assets/painting.jpg?v=3.26.154-mx3xhehx" alt=""></div>
<div class="hero-bg"><img src="/assets/painting.jpg?v=3.26.238-mx7aia6a" alt=""></div>
<div class="hero-veil"></div>
<div class="wrap">
<span class="kicker">v3.26.154 · macOS / Windows · 数据在本地</span>
<span class="kicker">v3.26.238 · macOS / Windows · 数据在本地</span>
<h1>本地优先的<br>AI 生图无限画布</h1>
<p class="sub">用节点把「参考图 → 提示词 → 批量生成 → 图库」串成一条生产线。<br>图片、提示词、模型配置全部留在你自己的电脑里,插件按需安装。</p>
<div class="cta">
<a class="btn primary lg" href="/download/">下载 v3.26.154</a>
<a class="btn lg" href="/plugins/">浏览 13 个插件</a>
<a class="btn primary lg" href="/download/">下载 v3.26.238</a>
<a class="btn lg" href="/plugins/">浏览 14 个插件</a>
</div>
<div class="meta">支持 macOS 12+ 与 Windows 10 1803+ · 安装包约 7 MB · 无需登录</div>
</div></section>
@@ -67,7 +67,7 @@
</div>
<div class="pcard" data-name="空白画布 blank-canvas 新建空白画布节点,用于分区分组 画布 效率" data-tags="画布,效率">
<div class="head"><span class="av" style="background:#eef2f6">⬜</span>
<div><div class="nm">空白画布</div><div class="ver">v1.0.0 · 官方</div></div></div>
<div><div class="nm">空白画布</div><div class="ver">v1.0.1 · 官方</div></div></div>
<div class="desc">新建空白画布节点,用于分区分组</div>
<div class="tags"><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.9 · 官方</div></div></div>
<div><div class="nm">图库</div><div class="ver">v1.9.12 · 官方</div></div></div>
<div class="desc">右栏图片墙:筛选/多选/双击预览/插入画布/下载/删除(数据由客户端提供)</div>
<div class="tags"><span class="tag">资源</span><span class="tag">图库</span></div>
</div>
@@ -90,15 +90,15 @@
<div class="tags"><span class="tag">资源</span><span class="tag">节点组</span></div>
</div>
</div>
<div style="margin-top:22px"><a class="btn" href="/plugins/">查看全部 13 个插件</a></div>
<div style="margin-top:22px"><a class="btn" href="/plugins/">查看全部 14 个插件</a></div>
</div></section>
<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.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 class="dl"><a href="/updates/darwin-aarch64/image-workbench_3.26.238_aarch64.dmg?h=9ecea14ff71c"><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.238_x64.dmg?h=0cef46585d87"><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.238_x64-setup.exe?h=d77c051770a1"><div class="n">Windows · x64</div><div class="s">需要 WebView2 · 5.3 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>
+87 -53
View File
@@ -1,6 +1,6 @@
{
"version": 2,
"updatedAt": "2026-11-30T23:01:32.719Z",
"updatedAt": "2026-12-03T08:25:39.506Z",
"plugins": [
{
"id": "album",
@@ -81,27 +81,27 @@
"画布",
"效率"
],
"version": "1.0.0",
"version": "1.0.1",
"apiVersion": 1,
"bundle": "plugins/blank-canvas-1.0.0.zip",
"bundleSize": 6674,
"bundleSha256": "b6bb7f37d7ae1ed5c0e19dacbae0050cf42b88dcdb6151385fd799443176ed7d",
"bundle": "plugins/blank-canvas-1.0.1.zip",
"bundleSize": 7021,
"bundleSha256": "3f588219048e23d869aa5b5259bc22ba68690d3df417b9c5e1df88e2d979d74b",
"files": [
{
"path": "manifest.json",
"sha256": "4ce80b37f07f900efaeddd68ef5379b755433555e4bdab222adbac509c2a21a6",
"sha256": "704c10d41877d4167d2f641c77e6d07d3b9cbe8eefe8829161aef6d0c876a9b9",
"size": 366
},
{
"path": "main.js",
"sha256": "67763893fa99c8fe1d8bcf640426f5bbc576abd35bcdc84c910b7b08f79964f9",
"size": 6094
"sha256": "80bcccc04527e3669021206c7ad98227618a74d1cfa039ab95907a5a438c6a6f",
"size": 6441
}
],
"file": "plugins/plugin-blank-canvas.67763893fa99.js",
"size": 6094,
"sha256": "67763893fa99c8fe1d8bcf640426f5bbc576abd35bcdc84c910b7b08f79964f9",
"integrity": "sha256-Z3Y4k/qZyP4di89kBCb1u8V2q9NbzchMkQt7CPeZZPk="
"file": "plugins/plugin-blank-canvas.80bcccc04527.js",
"size": 6441,
"sha256": "80bcccc04527e3669021206c7ad98227618a74d1cfa039ab95907a5a438c6a6f",
"integrity": "sha256-gLzMwEUn42aQISBsetmCJ2GKdNHPoDmrlZB6WkOMam8="
},
{
"id": "browser",
@@ -147,26 +147,26 @@
"资源",
"图库"
],
"version": "1.9.9",
"version": "1.9.12",
"apiVersion": 1,
"bundle": "plugins/gallery-1.9.9.zip",
"bundleSize": 57020,
"bundleSha256": "ed3847edf88818f060c9d00e56cac32dcf797a0b97d08ae0c2cf1df4fb79e55c",
"bundle": "plugins/gallery-1.9.12.zip",
"bundleSize": 58788,
"bundleSha256": "faf9e06c07e40b370867f9d28cfd0a69f6c9ddd77d7f8f4a7fdd6431a8da53e2",
"files": [
{
"path": "manifest.json",
"sha256": "7041e7fba02511f2638e83b8087e9c724fc7dac2d63e0ffbc3a7c536e8ced33f",
"size": 526
"sha256": "2d93e891c43679101ecc86538fb5bb376fa64f8e8a098511b9e63446f5db8931",
"size": 527
},
{
"path": "main.js",
"sha256": "22b2d8aa07ec193703d57603e857a6e48e054874ef943603d2ed7b1f3c560fd9",
"size": 47513
"sha256": "017277118b96545cd7cae386b37dca9b23a44593f53e0e858aedf901b994a153",
"size": 48954
},
{
"path": "styles.css",
"sha256": "07ca657d2e5f5d9406e6c7f7306906e34f2ee10a2fa4c2165358451f5461c6a4",
"size": 8671
"sha256": "d0479dad661370dfa23d85e4470c5885cbe38fb3b4de9097ad084c952e16d516",
"size": 8997
}
]
},
@@ -215,26 +215,26 @@
"资源",
"提示词"
],
"version": "1.14.11",
"version": "1.14.14",
"apiVersion": 1,
"bundle": "plugins/promptlib-1.14.11.zip",
"bundleSize": 190823,
"bundleSha256": "fd6e1f0733757e35a2b202d018db5e3b9a418062c4555a2747d95e8bd6061d07",
"bundle": "plugins/promptlib-1.14.14.zip",
"bundleSize": 196105,
"bundleSha256": "968e1ad0922d04ff9b396cf116ec21435961c9e3e300bea1c0d409fd95b4bd39",
"files": [
{
"path": "manifest.json",
"sha256": "5a14bdf3a2b3334e4c78a9dc2c0f8c90d253b7113724dc5daa534936ec1551d2",
"sha256": "7460c3b6d8d60e9bf3400cf5d51ed6d2968122c051fdac5d132c4bcd9236ff63",
"size": 542
},
{
"path": "main.js",
"sha256": "c807d9ce8b1a7df851e00dd724e585d3158b2031194e71ca154d3def383385d7",
"size": 142646
"sha256": "27f5c4dd5e90ee6ae0bf7ad8ecf36bae62c2e436c2882c7c41f6272a32f7bafd",
"size": 147420
},
{
"path": "styles.css",
"sha256": "182783b15335895b5a40822bf137a7b4872ca0c6ee72434bfa61a97b37453a07",
"size": 47325
"sha256": "a086b172cc8261b9f346e612b5f76cc085d5a1e486657d0c656cb87c675f238c",
"size": 47833
}
]
},
@@ -282,27 +282,27 @@
"转换",
"矢量"
],
"version": "0.6.2",
"version": "0.6.3",
"apiVersion": 1,
"bundle": "plugins/image-vectorize-0.6.2.zip",
"bundleSize": 145959,
"bundleSha256": "d51f1bdc5cd3523a9c28816dc734444d6c344574760ec1cae3057bdd4a88841c",
"bundle": "plugins/image-vectorize-0.6.3.zip",
"bundleSize": 146158,
"bundleSha256": "40fcb486828af5794e7fa562458f0974303b58eba780410fb1d1a829607fb179",
"files": [
{
"path": "manifest.json",
"sha256": "d484ae85bfb6e2597f6e78b7f4097809d346e5afa7c06786404cb76df2019a9b",
"sha256": "b04701b97ca190eb7578e0411e67f59ea39bd277dc62cbccb784e1797e7a14d3",
"size": 362
},
{
"path": "main.js",
"sha256": "b3a8c21f7a2bead419e6e9899d9fe46ba9e4fa7e67a777a50056942b568f57d1",
"size": 145383
"sha256": "a47baa43948e0c24381280174602b3b078214cb06f2aef6989b1b3ea335942b9",
"size": 145582
}
],
"file": "plugins/plugin-image-vectorize.b3a8c21f7a2b.js",
"size": 145383,
"sha256": "b3a8c21f7a2bead419e6e9899d9fe46ba9e4fa7e67a777a50056942b568f57d1",
"integrity": "sha256-s6jCH3or6tQZ5umJnZ/ka6nk+n5np3elAFaUK1aPV9E="
"file": "plugins/plugin-image-vectorize.a47baa43948e.js",
"size": 145582,
"sha256": "a47baa43948e0c24381280174602b3b078214cb06f2aef6989b1b3ea335942b9",
"integrity": "sha256-pHuqQ5SODCQ4EoAXRgKzsHghTLBvKu9pibGz6jNZQrk="
},
{
"id": "sticky",
@@ -381,27 +381,27 @@
"电商",
"出图"
],
"version": "1.2.2",
"version": "1.2.3",
"apiVersion": 1,
"bundle": "plugins/white-bg-800-1.2.2.zip",
"bundleSize": 15573,
"bundleSha256": "71a1c5a0c5ddc037a0c1d3dcdf5d54202e66005447948daf9e40e00cd71566d4",
"bundle": "plugins/white-bg-800-1.2.3.zip",
"bundleSize": 16347,
"bundleSha256": "a7ec18de6a59a15a6f71e70237f1f0804655994924ad6de677557f83280b587f",
"files": [
{
"path": "manifest.json",
"sha256": "8b6634cbb1c397ab101f0ed6cdc75dbedb1c8c3b0e9655ccf0f6c72636490d4f",
"sha256": "e02dba3a85ad7948e3b4755812ae8d2a6068a47397d74185d0e0c042c4a46f16",
"size": 357
},
{
"path": "main.js",
"sha256": "ffc18c23ed74f8164773adc37f907eb7b2b2c46a63f0ca277db949effc568b33",
"size": 15002
"sha256": "a27695876233656f0696e7386610db30487928efb2691581ecbb0884e6a80446",
"size": 15776
}
],
"file": "plugins/plugin-white-bg-800.ffc18c23ed74.js",
"size": 15002,
"sha256": "ffc18c23ed74f8164773adc37f907eb7b2b2c46a63f0ca277db949effc568b33",
"integrity": "sha256-/8GMI+10+BZHc63Df5B+t7KyxGpj8MonfblJ7/xWizM="
"file": "plugins/plugin-white-bg-800.a27695876233.js",
"size": 15776,
"sha256": "a27695876233656f0696e7386610db30487928efb2691581ecbb0884e6a80446",
"integrity": "sha256-onaVh2IzZW8Gluc4ZhDbMEh5KO+yaRWB7LsIhOaoBEY="
},
{
"id": "xianyi-cutout",
@@ -435,6 +435,40 @@
"size": 4527,
"sha256": "f7898f6e0fe9f8f8a4bdf91ce7dbbe538c0f27ee398dce3a25394da6d559201d",
"integrity": "sha256-94mPbg/p+Pikvfkc59u+U4wPJ+45jc46JTlNptVZIB0="
},
{
"id": "taskqueue",
"name": "任务队列",
"desc": "全局生图记录:链接/状态/画布节点;下载落地图库、重试、复制链接、定位节点(数据由宿主保存)",
"author": "official",
"icon": "⏳",
"color": "#eef6f6",
"tags": [
"工具",
"记录"
],
"version": "1.0.3",
"apiVersion": 1,
"bundle": "plugins/taskqueue-1.0.3.zip",
"bundleSize": 19127,
"bundleSha256": "c414710b3e1e7dac931a80f765dafd4e4bc8b0a8d3c4abfc54f84363cc010a47",
"files": [
{
"path": "manifest.json",
"sha256": "18830aec4c11dd8f0e55e4c4bb431fd00130cb12920c4d176d9c80eb38032821",
"size": 563
},
{
"path": "main.js",
"sha256": "5f08181338062c9327f22e742be7e1e161a32d2e1bc41ae775a73e0e15b9f3a9",
"size": 13189
},
{
"path": "styles.css",
"sha256": "4de612a1d25cb74a76f1888fdde32c0f617cc6ab5cc1a0f0bd6ff1adccc757e4",
"size": 5065
}
]
}
]
}
+16 -8
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.154-mx3xhehx">
<link rel="stylesheet" href="/assets/style.css?v=3.26.238-mx7aia6a">
</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,13 +16,13 @@
</div>
<div class="right">
<a class="btn" href="/plugins/">插件市场</a>
<a class="btn primary" href="/download/">下载 v3.26.154</a>
<a class="btn primary" href="/download/">下载 v3.26.238</a>
</div>
</div></nav>
<main>
<section class="hero" style="padding:64px 0 8px;text-align:left"><div class="wrap">
<h1 style="font-size:40px;margin:0">插件市场</h1>
<p class="sub" style="margin:14px 0 0;text-align:left;max-width:720px">共 13 个插件。安装方式:应用内 <b>设置 → 插件 → 浏览</b>,点「安装」后重启生效。</p>
<p class="sub" style="margin:14px 0 0;text-align:left;max-width:720px">共 14 个插件。安装方式:应用内 <b>设置 → 插件 → 浏览</b>,点「安装」后重启生效。</p>
</div></section>
<section class="section" style="border-top:0;padding-top:24px"><div class="wrap">
<div style="display:flex;gap:8px;flex-wrap:wrap;margin:0 0 18px" id="chips">
@@ -47,6 +47,8 @@
<button class="tag" data-tag="电商" style="cursor:pointer;padding:5px 12px">电商</button>
<button class="tag" data-tag="抠图" style="cursor:pointer;padding:5px 12px">抠图</button>
<button class="tag" data-tag="去背景" style="cursor:pointer;padding:5px 12px">去背景</button>
<button class="tag" data-tag="工具" style="cursor:pointer;padding:5px 12px">工具</button>
<button class="tag" data-tag="记录" style="cursor:pointer;padding:5px 12px">记录</button>
</div>
<input id="q" placeholder="搜索插件,例如:出图、抠图、矢量…" style="width:100%;max-width:420px;height:40px;padding:0 14px;border:1px solid var(--line);border-radius:10px;font-size:14px;outline:none;margin-bottom:22px">
<div class="grid c3" id="list">
@@ -64,7 +66,7 @@
</div>
<div class="pcard" data-name="空白画布 blank-canvas 新建空白画布节点,用于分区分组 画布 效率" data-tags="画布,效率">
<div class="head"><span class="av" style="background:#eef2f6">⬜</span>
<div><div class="nm">空白画布</div><div class="ver">v1.0.0 · 官方</div></div></div>
<div><div class="nm">空白画布</div><div class="ver">v1.0.1 · 官方</div></div></div>
<div class="desc">新建空白画布节点,用于分区分组</div>
<div class="tags"><span class="tag">画布</span><span class="tag">效率</span></div>
</div>
@@ -76,7 +78,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.9 · 官方</div></div></div>
<div><div class="nm">图库</div><div class="ver">v1.9.12 · 官方</div></div></div>
<div class="desc">右栏图片墙:筛选/多选/双击预览/插入画布/下载/删除(数据由客户端提供)</div>
<div class="tags"><span class="tag">资源</span><span class="tag">图库</span></div>
</div>
@@ -88,7 +90,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.11 · 官方</div></div></div>
<div><div class="nm">提示词库</div><div class="ver">v1.14.14 · 官方</div></div></div>
<div class="desc">右栏提示词列表:搜索/分组/收藏/新建编辑/插入画布/复制(数据由客户端提供)</div>
<div class="tags"><span class="tag">资源</span><span class="tag">提示词</span></div>
</div>
@@ -100,7 +102,7 @@
</div>
<div class="pcard" data-name="位图转矢量 image-vectorize 把位图转成 svg 矢量路径 转换 矢量" data-tags="转换,矢量">
<div class="head"><span class="av" style="background:#eaf3ea">✒️</span>
<div><div class="nm">位图转矢量</div><div class="ver">v0.6.2 · 官方</div></div></div>
<div><div class="nm">位图转矢量</div><div class="ver">v0.6.3 · 官方</div></div></div>
<div class="desc">把位图转成 SVG 矢量路径</div>
<div class="tags"><span class="tag">转换</span><span class="tag">矢量</span></div>
</div>
@@ -118,7 +120,7 @@
</div>
<div class="pcard" data-name="白底图 white-bg-800 批量生成电商白底图(800px) 电商 出图" data-tags="电商,出图">
<div class="head"><span class="av" style="background:#eef7fb">🧾</span>
<div><div class="nm">白底图</div><div class="ver">v1.2.2 · 官方</div></div></div>
<div><div class="nm">白底图</div><div class="ver">v1.2.3 · 官方</div></div></div>
<div class="desc">批量生成电商白底图(800px)</div>
<div class="tags"><span class="tag">电商</span><span class="tag">出图</span></div>
</div>
@@ -128,6 +130,12 @@
<div class="desc">接入鲜艺抠图模型的一键去背景</div>
<div class="tags"><span class="tag">抠图</span><span class="tag">去背景</span></div>
</div>
<div class="pcard" data-name="任务队列 taskqueue 全局生图记录:链接/状态/画布节点;下载落地图库、重试、复制链接、定位节点(数据由宿主保存) 工具 记录" data-tags="工具,记录">
<div class="head"><span class="av" style="background:#eef6f6">⏳</span>
<div><div class="nm">任务队列</div><div class="ver">v1.0.3 · 官方</div></div></div>
<div class="desc">全局生图记录:链接/状态/画布节点;下载落地图库、重试、复制链接、定位节点(数据由宿主保存)</div>
<div class="tags"><span class="tag">工具</span><span class="tag">记录</span></div>
</div>
</div>
<div class="note" style="margin-top:26px">插件安装后会写进你的资料目录 <code>~/Documents/ImageWorkbench/plugins/</code>;卸载只删插件文件,不动画布与图库。</div>
</div></section>
+113 -1
View File
@@ -1,8 +1,120 @@
{
"app": "Image Workbench",
"subtitle": "本地优先的 AI 生图无限画布 · 桌面版(Tauri v2)",
"updatedAt": "2026-11-30T23:57:44.903Z",
"updatedAt": "2026-12-03T04:48:38.283Z",
"releases": [
{
"version": "3.26.238",
"date": "2026-12-03",
"notes": "任务队列页头/页签固定;图片读取/下载本地优先 + 命名统一图库行名",
"platforms": {
"darwin-aarch64": {
"file": "updates/darwin-aarch64/image-workbench_3.26.238_aarch64.dmg",
"size": 10152907,
"sha256": "9ecea14ff71c7ef0fa91e28241f2a77ca5fea09dee0fa5e3e1024ee01edc0f8f",
"h": "9ecea14ff71c",
"kind": "dmg"
},
"darwin-x86_64": {
"file": "updates/darwin-x86_64/image-workbench_3.26.238_x64.dmg",
"size": 10610501,
"sha256": "0cef46585d874ba20522aeecbfe9b10e8e52fbf1ea0ec5a8261eb8a10a789595",
"h": "0cef46585d87",
"kind": "dmg"
},
"windows-x86_64": {
"file": "updates/windows-x86_64/image-workbench_3.26.238_x64-setup.exe",
"size": 5601034,
"sha256": "d77c051770a139d50aaa4e914763375abb85836d502b98cd13da8000aa9c3511",
"h": "d77c051770a1",
"kind": "exe"
}
}
},
{
"version": "3.26.184",
"date": "2026-12-02",
"notes": "",
"platforms": {
"darwin-aarch64": {
"file": "updates/darwin-aarch64/image-workbench_3.26.184_aarch64.dmg",
"size": 10145011,
"sha256": "2358abf9f64ff17a4c3339f66cd4dd3bb17aea875b1af62335d329d5f32d8e80",
"h": "2358abf9f64f",
"kind": "dmg"
},
"darwin-x86_64": {
"file": "updates/darwin-x86_64/image-workbench_3.26.184_x64.dmg",
"size": 10601813,
"sha256": "24d1030ba35016995181b712e65feba818e556257560b716434bace21ee334fc",
"h": "24d1030ba350",
"kind": "dmg"
},
"windows-x86_64": {
"file": "updates/windows-x86_64/image-workbench_3.26.184_x64-setup.exe",
"size": 5589965,
"sha256": "d26a90dda86df474ce278751ec9c1f05916fd96f58c3f754538d987526507c92",
"h": "d26a90dda86d",
"kind": "exe"
}
}
},
{
"version": "3.26.183",
"date": "2026-12-02",
"notes": "",
"platforms": {
"darwin-aarch64": {
"file": "updates/darwin-aarch64/image-workbench_3.26.183_aarch64.dmg",
"size": 10143986,
"sha256": "dc2d519f38ad502998001cc567a39c873a6af0431310187016bebbd8387636a0",
"h": "dc2d519f38ad",
"kind": "dmg"
},
"darwin-x86_64": {
"file": "updates/darwin-x86_64/image-workbench_3.26.183_x64.dmg",
"size": 10605713,
"sha256": "d6decca171fcddfaca280a5fca718648fab047981021a5af8c850dcf504eba2f",
"h": "d6decca171fc",
"kind": "dmg"
},
"windows-x86_64": {
"file": "updates/windows-x86_64/image-workbench_3.26.183_x64-setup.exe",
"size": 5591250,
"sha256": "02d1264162eaed0d95274de1c0a20bfe173030931db5a41d7443cbb2a874ae4a",
"h": "02d1264162ea",
"kind": "exe"
}
}
},
{
"version": "3.26.169",
"date": "2026-12-01",
"notes": "",
"platforms": {
"darwin-aarch64": {
"file": "updates/darwin-aarch64/image-workbench_3.26.169_aarch64.dmg",
"size": 10139404,
"sha256": "c133b12c2b9660bbcbd8f1f175d4a4e3e3a8856ae4c746c53efe54221e2afbfd",
"h": "c133b12c2b96",
"kind": "dmg"
},
"darwin-x86_64": {
"file": "updates/darwin-x86_64/image-workbench_3.26.169_x64.dmg",
"size": 10600637,
"sha256": "f0520a62218b2a827584ee292406d5a98b61caa686621bb5abe2734ab43fa97e",
"h": "f0520a62218b",
"kind": "dmg"
},
"windows-x86_64": {
"file": "updates/windows-x86_64/image-workbench_3.26.169_x64-setup.exe",
"size": 5586528,
"sha256": "90f1fad79b2f54dd710beda6940a1549086a4a8b06d0c9fcfbfa8d7da597c947",
"h": "90f1fad79b2f",
"kind": "exe"
}
}
},
{
"version": "3.26.154",
"date": "2026-11-30",
+1 -1
View File
@@ -2014,7 +2014,7 @@ dependencies = [
[[package]]
name = "image-workbench"
version = "3.26.167"
version = "3.26.240"
dependencies = [
"arboard",
"base64 0.22.1",
+1 -1
View File
@@ -1,6 +1,6 @@
[package]
name = "image-workbench"
version = "3.26.169"
version = "3.26.240"
description = "无限画布 · 生图工作台桌面版"
authors = ["malongan"]
license = ""
+37 -1
View File
@@ -292,6 +292,41 @@ fn do_thumbs(src: &str, jobs: &[ThumbJob]) -> Result<serde_json::Value, String>
Ok(serde_json::json!({ "ok": true, "files": out }))
}
// 2026-12-03(用户裁定):图片下载走系统网络栈。
// 为什么:WebView 的 fetch 是跨域 XHR,图床/CDN 会限速、挂起或按防盗链策略直接不回包
// (实测任务队列卡在 55% 不动);Rust 侧 reqwest 与浏览器导航同一栈,不受 CORS 约束。
// 返回 base64 + mime + 字节数;不写盘、不解析图片,调用方自己决定落到哪里。
#[tauri::command]
async fn fetch_image_b64(url: String, referer: Option<String>) -> Result<serde_json::Value, String> {
use base64::Engine as _;
let client = tauri_plugin_http::reqwest::Client::builder()
.connect_timeout(std::time::Duration::from_secs(15))
.timeout(std::time::Duration::from_secs(120))
.user_agent("Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36")
.build()
.map_err(|e| e.to_string())?;
let mut req = client.get(&url);
if let Some(r) = referer {
if !r.is_empty() {
req = req.header(tauri_plugin_http::reqwest::header::REFERER, r);
}
}
let resp = req.send().await.map_err(|e| e.to_string())?;
let status = resp.status();
if !status.is_success() {
return Ok(serde_json::json!({ "ok": false, "error": format!("http-{}", status.as_u16()) }));
}
let mime = resp
.headers()
.get(tauri_plugin_http::reqwest::header::CONTENT_TYPE)
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream")
.to_string();
let bytes = resp.bytes().await.map_err(|e| e.to_string())?;
let b64 = base64::engine::general_purpose::STANDARD.encode(&bytes);
Ok(serde_json::json!({ "ok": true, "mime": mime, "bytes": bytes.len(), "b64": b64 }))
}
#[tauri::command]
async fn img_thumbs(src: String, jobs: Vec<ThumbJob>) -> Result<serde_json::Value, String> {
tauri::async_runtime::spawn_blocking(move || do_thumbs(&src, &jobs))
@@ -2055,7 +2090,8 @@ pub fn run() {
app_memory_mb,
app_memory_tree_mb,
app_memory_breakdown,
img_thumbs
img_thumbs,
fetch_image_b64
])
.setup(|app| {
if cfg!(debug_assertions) {
+1 -1
View File
@@ -1,7 +1,7 @@
{
"$schema": "../node_modules/@tauri-apps/cli/config.schema.json",
"productName": "image-workbench",
"version": "3.26.169",
"version": "3.26.240",
"identifier": "com.malongan.imageworkbench",
"build": {
"frontendDist": "../dist",
+4 -1
View File
@@ -123,6 +123,9 @@
return out
}
// 等当前归档队列排空(整批补漏前调用:避免最后一张的索引还在写就被误判成「未归档」)
function whenIdle () { return queue.chain }
// 这条结果是否已经逐张归档过(整轮归档据此跳过,避免同一张图入两次库)
function wasArchived (entry) {
return !!(archived && entry && typeof entry === 'object' && archived.has(entry))
@@ -247,7 +250,7 @@
return ''
}
return { archiveEntryNow, wasArchived, notifyChanged, localCopySrcOf, prepareInsert, gridSpots, nodeImageOf, thumbFor, thumbStats }
return { archiveEntryNow, whenIdle, wasArchived, notifyChanged, localCopySrcOf, prepareInsert, gridSpots, nodeImageOf, thumbFor, thumbStats }
}
let attached = null
+29 -3
View File
@@ -184,9 +184,35 @@
return groups.map((g, gi) => ({ sourceNodeId: n.id + '#b' + gi, ownerNodeId: n.id, title: String((n.data && n.data.title) || '').trim(), text: albumText, refNodes: g, diagnostics: diag }))
}
if (children.length) {
return selfRefs.length
? children.map((t) => ({ ...t, ownerNodeId: n.id, refNodes: dedupeTaskRefs((t.refNodes || []).concat(selfRefs)) }))
: children.map((t) => ({ ...t, ownerNodeId: n.id }))
// 2026-12-03:插件文本节点接了上游(例如给「提示词模板」接一张参考图)时,
// 这里原来直接返回 children,把节点自己的 data.text 丢成空串 ⇒ 发出去只有图没有提示词,
// 生图服务商报 400 INVALID_ARGUMENT。口径与上面的 prompt 分支一致:自己的文本优先,参考图取并集。
const ownTitle = String((n.data && n.data.title) || '').trim()
// 2026-12-03(用户):上游是「纯图片」或「图片 + 至多一段文本」时,合并成**一个**任务
// (图1+图2 一起带,文本用节点自己的 > 上游那段);两段以上文本、相册/批量等多值源保持一子一任务。
const refChildren = []
const otherChildren = []
for (const t of children) {
const sn = graph.byId.get(t.sourceNodeId)
if (sn && sn.type === 'ref') refChildren.push(t)
else otherChildren.push(t)
}
const mergedRefs = dedupeTaskRefs(refChildren.flatMap((t) => t.refNodes || []))
const mergedDiag = { cycles: children.flatMap((t) => (t.diagnostics && t.diagnostics.cycles) || []), disabledSources: [] }
let base = children
if (refChildren.length && !otherChildren.length) {
base = [{ sourceNodeId: n.id, ownerNodeId: n.id, title: ownTitle, text: '', refNodes: mergedRefs, diagnostics: mergedDiag }]
} else if (refChildren.length && otherChildren.length === 1) {
const tc = otherChildren[0]
base = [{ ...tc, sourceNodeId: own ? n.id : (tc.sourceNodeId || n.id), ownerNodeId: n.id, title: ownTitle || tc.title || '', text: String(tc.text || ''), refNodes: dedupeTaskRefs((tc.refNodes || []).concat(mergedRefs)), diagnostics: tc.diagnostics || mergedDiag }]
}
return base.map((t) => ({
...t,
ownerNodeId: n.id,
title: ownTitle || t.title || '',
text: own || t.text,
refNodes: dedupeTaskRefs((t.refNodes || []).concat(selfRefs)),
}))
}
return [{ sourceNodeId: n.id, ownerNodeId: n.id, text: own, refNodes: selfRefs, diagnostics: { cycles: [], disabledSources: [] } }]
}
+6 -3
View File
@@ -25,6 +25,9 @@
const pending = o.pending
if (!cache || !pending) throw new Error('cache/pending required')
const queue = []
// v3.26.181:失败过的 key 不再重试(标注覆盖后的新图没有缩略图,生成失败时
// 每次重渲染都会重新入队 → 反复整幅解码,CPU 被吃掉)。
const failed = new Set()
let running = 0
let scheduled = false
@@ -146,7 +149,7 @@
try { ok = await runNative(key) } catch (e) { ok = false }
if (!ok) { try { ok = await runBitmap(key, v) } catch (e) { ok = false } }
if (!ok) { try { ok = await runImg(key, v) } catch (e2) { ok = false } }
if (ok) bump()
if (ok) { failed.delete(key); bump() } else if (!(typeof o.isTransient === 'function' && o.isTransient(v))) failed.add(key)
return ok
}
@@ -174,13 +177,13 @@
return {
queue: function (key, v) {
if (!key || cache.has(key) || pending.has(key)) return false
if (!key || cache.has(key) || pending.has(key) || failed.has(key)) return false
pending.add(key)
queue.push({ key: key, v: v })
schedule()
return true
},
stats: function () { return { queued: queue.length, running: running } }
stats: function () { return { queued: queue.length, running: running, failed: failed.size } }
}
}
+111
View File
@@ -0,0 +1,111 @@
/* image-ingest-store.js —— 落地队列的持久化 + 状态视图(2026-12-02)
*
* 两个职责,都很薄:
* 1) store:把 ingest 的记录存在 localStorage(只存元数据与引用,不存字节;字节在 blob 引用存储里)
* —— 断点恢复靠它;上限 500 条,超出按最旧淘汰(pinned 不动)
* 2) view:url → 状态的内存索引,供结果图组件按 url 查「下载中 / 失败 / 已就绪」
* —— 组件订阅 notify 后重渲染,不需要把状态灌进画布节点数据
*
* 与 image-ingest.js 的分工:那边是执行器(下载/重试),这边只管「记账」和「给 UI 看」。
*/
;(function (global) {
'use strict'
const KEY = 'iwb_ingest_idx'
const MAX = 500
function createStore (deps) {
const d = deps || {}
const lsGet = typeof d.get === 'function' ? d.get : () => null
const lsSet = typeof d.set === 'function' ? d.set : () => {}
// 2026-12-03:上限由宿主配置注入(默认 500,范围 100~5000);插件只读/改配置。
const maxOf = () => {
let n = 500
try { n = typeof d.max === 'function' ? d.max() : (Number(d.max) || 500) } catch (e) { n = 500 }
n = Math.round(Number(n) || 500)
return Math.max(1, Math.min(5000, n))
}
let cache = null
function load () {
if (cache) return cache
let arr = null
try { arr = lsGet(KEY) } catch (e) { arr = null }
cache = Array.isArray(arr) ? arr.filter((x) => x && x.id && x.url) : []
return cache
}
function save (entry) {
if (!entry || !entry.id) return
const arr = load()
const at = arr.findIndex((x) => x.id === entry.id)
if (at >= 0) arr[at] = entry
else arr.push(entry)
const max = maxOf()
if (arr.length > max) {
// 淘汰最旧的非 pinned 记录(pinned = 被画布/图库引用)
const isActive = (x) => !!(x && (x.status === 'queued' || x.status === 'downloading'))
const drop = arr.filter((x) => !x.pinned && !isActive(x) && x.id !== entry.id).sort((a, b) => (a.createdAt || 0) - (b.createdAt || 0))
while (arr.length > max && drop.length) {
const victim = drop.shift()
const i = arr.indexOf(victim)
if (i >= 0) arr.splice(i, 1)
}
}
try { lsSet(KEY, arr) } catch (e) { /* 配额满:保留内存态,下次启动丢,不影响当前会话 */ }
}
function remove (id) {
const arr = load()
const i = arr.findIndex((x) => x.id === id)
if (i >= 0) arr.splice(i, 1)
try { lsSet(KEY, arr) } catch (e) { /* ignore */ }
}
function list () { return load().slice() }
// 立即按当前上限裁剪(改设置后调用;只删记录,不删图片)
function trim () {
const arr = load()
const max = maxOf()
if (arr.length <= max) return 0
const isActive = (x) => !!(x && (x.status === 'queued' || x.status === 'downloading'))
const drop = arr.filter((x) => !x.pinned && !isActive(x)).sort((a, b) => (a.createdAt || 0) - (b.createdAt || 0))
let removed = 0
while (arr.length > max && drop.length) {
const victim = drop.shift()
const i = arr.indexOf(victim)
if (i >= 0) { arr.splice(i, 1); removed++ }
}
if (removed) { try { lsSet(KEY, arr) } catch (e) { /* ignore */ } }
return removed
}
function clear () { cache = []; try { lsSet(KEY, []) } catch (e) { /* ignore */ } }
return { load, save, remove, list, trim, clear, KEY, MAX }
}
// 视图:url → { status, localUrl, bytes, error };订阅者用于 React 重渲染
function createView () {
const byUrl = new Map()
const subs = new Set()
function set (entry) {
if (!entry || !entry.url) return
const prev = byUrl.get(entry.url) || {}
byUrl.set(entry.url, {
id: entry.id,
status: entry.status,
ref: entry.ref || prev.ref || null,
displayRef: entry.displayRef || prev.displayRef || null,
localUrl: entry.localUrl || prev.localUrl || '',
bytes: entry.bytes || 0,
progress: entry.progress || 0,
receivedBytes: entry.receivedBytes || 0,
totalBytes: entry.totalBytes || 0,
error: entry.lastError || '',
})
}
function byUrlOf (url) { return byUrl.get(String(url || '')) || null }
function hydrate (entries) { for (const e of (entries || [])) set(e) }
function subscribe (fn) { if (typeof fn === 'function') { subs.add(fn); return () => subs.delete(fn) } return () => {} }
function notify () { for (const fn of [...subs]) { try { fn() } catch (e) { /* ignore */ } } }
return { set, get: byUrlOf, hydrate, subscribe, notify }
}
global.IWBImageIngestStore = { createStore, createView, KEY }
})(typeof window !== 'undefined' ? window : globalThis)
+347
View File
@@ -0,0 +1,347 @@
/* image-ingest.js —— 结果图片落地管线(2026-12-02)
*
* 解决什么:出图后输出节点直接用 <img src=远程CDN>,图库缩略图又各自去 fetch 一遍;
* CDN 慢/断流时表现为「图片从上往下慢慢刷 / 卡住半张」,图库还晚一步才出现。
* 这里把「远程结果 → 本地字节」收敛成一条队列:下载一次,节点/图库/队列页共用。
*
* 设计约束:
* · 幂等:同一条记录重复 enqueue 不会重复下载(按 id 去重;id 缺省用 url 的稳定 hash)
* · 不丢图:原始 url 永远保留在 entry 上;失败只改状态,不删记录
* · 可恢复:状态由宿主持久化(deps.persist),启动时用 restore() 把 queued/downloading 重排
* · 原子:先写字节再置 ready;写失败保持 failed,可重试
* · 可关:宿主不接线就是不启用(本模块自身不读任何全局)
*
* 依赖全部注入(便于单测):
* fetchBytes(url) -> Promise<{ ok, dataUrl?, bytes?, mime?, error? }>
* writeRef(dataUrl)-> Promise<ref|null> // 走宿主的唯一引用化入口
* persist(entry) -> void // 状态变化时持久化
* onEvent(kind, entry) -> void // 进度节流事件(宿主用来刷新 UI)
* now() -> number
* sleep(ms) -> Promise // 测试可注入
* concurrency -> number(默认 2)
* retries -> number(默认 3)
*/
;(function (global) {
'use strict'
const STATE = { QUEUED: 'queued', DOWNLOADING: 'downloading', READY: 'ready', FAILED: 'failed', LINK_ONLY: 'link-only' }
function create (deps) {
const d = deps || {}
// 2026-12-03(用户裁定):默认 30 并发,设置页可调(1–64);getConcurrency 让改动立即生效。
const concurrencyOf = () => {
const v = (typeof d.getConcurrency === 'function') ? d.getConcurrency() : d.concurrency
return Math.max(1, Math.min(64, Number(v) || 30))
}
const maxRetries = Math.max(0, Number(d.retries) || 3)
const now = typeof d.now === 'function' ? d.now : () => Date.now()
const sleep = typeof d.sleep === 'function' ? d.sleep : (ms) => new Promise((r) => setTimeout(r, ms))
const entries = new Map() // id -> entry
const queue = [] // 待下载 id
let active = 0
let seq = 0
const uid = () => 'ing_' + now().toString(36) + '_' + (++seq)
function hash (s) {
let h = 5381
const str = String(s || '')
for (let i = 0; i < str.length; i++) h = ((h * 33) ^ str.charCodeAt(i)) >>> 0
return h.toString(36)
}
const emit = (kind, e) => { try { if (typeof d.onEvent === 'function') d.onEvent(kind, e) } catch (err) { /* ignore */ } }
const persist = (e) => { try { if (typeof d.persist === 'function') d.persist(e) } catch (err) { /* ignore */ } }
function publicView (e) {
return {
id: e.id, url: e.url, source: e.source, status: e.status,
bytes: e.bytes || 0, mime: e.mime || '', w: e.w || 0, h: e.h || 0,
progress: e.progress || 0, receivedBytes: e.receivedBytes || 0, totalBytes: e.totalBytes || 0,
ref: e.ref || null, displayRef: e.displayRef || null, thumbRef: e.thumbRef || null,
retries: e.retries || 0, lastError: e.lastError || '', requestId: e.requestId || '',
createdAt: e.createdAt, updatedAt: e.updatedAt, meta: e.meta || {},
}
}
function get (id) { const e = entries.get(id); return e ? publicView(e) : null }
function list () { return [...entries.values()].map(publicView) }
function stats () {
const out = { total: 0, queued: 0, downloading: 0, ready: 0, failed: 0, linkOnly: 0, active: 0 }
for (const e of entries.values()) {
out.total++
if (e.status === STATE.QUEUED) out.queued++
else if (e.status === STATE.DOWNLOADING) out.downloading++
else if (e.status === STATE.READY) out.ready++
else if (e.status === STATE.FAILED) out.failed++
else if (e.status === STATE.LINK_ONLY) out.linkOnly++
}
out.active = active
return out
}
function setStatus (e, status, patch) {
e.status = status
e.updatedAt = now()
if (patch) Object.assign(e, patch)
persist(publicView(e))
emit(status, publicView(e))
}
async function runOne (e) {
// active 由 pump 在「决定启动」时同步 +1(见 pump):放在这里会晚一个微任务,
// pump 的 while 就会在 active 还是 0 时把整个队列一次性放出去(2026-12-03 实测并发限制从未生效)。
// 2026-12-03:每次运行带「运行序号 + 取消控制器」—— 取消/重下时旧请求的结果必须作废,
// 否则回包晚到会把 link-only 覆盖成 ready,或和新一轮同时写同一条记录。
const mySeq = (e.runSeq || 0) + 1
e.runSeq = mySeq
const ctrl = (typeof AbortController === 'function') ? new AbortController() : null
e.ctrl = ctrl
const stale = () => (e.runSeq !== mySeq || e.status !== STATE.DOWNLOADING)
const settle = () => { active--; try { delete e.ctrl } catch (e0) { /* ignore */ } pump() }
setStatus(e, STATE.DOWNLOADING, { lastError: '', progress: 0, receivedBytes: 0, totalBytes: 0 })
let lastErr = ''
// 2026-12-02:下载进度(有 content-length 才算百分比;拿不到就退回「下载中」文案)。
// 事件节流 250ms —— 每 chunk 都触发会让画布整树重渲染,反而拖慢下载。
const onProgress = (received, total) => {
const rcv = Math.max(0, Number(received) || 0)
const tot = Math.max(0, Number(total) || 0)
e.receivedBytes = rcv
e.totalBytes = tot
e.progress = tot > 0 ? Math.min(1, rcv / tot) : 0
const t = now()
e.updatedAt = t
if (t - (e._progAt || 0) < 250 && !(tot > 0 && rcv >= tot)) return
e._progAt = t
emit('progress', publicView(e))
}
for (let attempt = 0; attempt <= maxRetries; attempt++) {
try {
const got = typeof d.fetchBytes === 'function' ? await d.fetchBytes(e.url, onProgress, ctrl ? ctrl.signal : undefined) : { ok: false, error: 'no-fetcher' }
if (stale()) { settle(); return publicView(e) }
if (!got || !got.ok || !got.dataUrl) throw new Error((got && got.error) || 'fetch-failed')
const ref = typeof d.writeRef === 'function' ? await d.writeRef(got.dataUrl) : null
if (!ref) throw new Error('write-ref-failed')
if (stale()) { settle(); return publicView(e) }
active--
setStatus(e, STATE.READY, {
ref,
progress: 1,
bytes: Number(got.bytes || 0) || Math.round(String(got.dataUrl).length * 0.75),
mime: String(got.mime || ''),
w: Number(got.w || 0) || e.w || 0,
h: Number(got.h || 0) || e.h || 0,
retries: attempt,
lastError: '',
})
pump()
return publicView(e)
} catch (err) {
lastErr = (err && err.message) ? err.message : String(err)
if (stale()) { settle(); return publicView(e) }
if (attempt < maxRetries) {
setStatus(e, STATE.DOWNLOADING, { retries: attempt + 1, lastError: lastErr })
await sleep(Math.min(8000, 1000 * Math.pow(2, attempt)))
continue
}
}
}
if (stale()) { settle(); return publicView(e) }
active--
try { delete e.ctrl } catch (e1) { /* ignore */ }
setStatus(e, STATE.FAILED, { retries: maxRetries, lastError: lastErr })
pump()
return publicView(e)
}
function pump () {
while (active < concurrencyOf() && queue.length) {
const id = queue.shift()
const e = entries.get(id)
if (!e || e.status !== STATE.QUEUED) continue
active++
Promise.resolve().then(() => runOne(e))
}
}
// 入队:同一 url 已存在(且未失败)则直接返回旧记录,避免重复下载
function enqueue (input) {
const src = input || {}
const url = String(src.url || '')
if (!url) return null
const id = String(src.id || ('u_' + hash(url)))
const exist = entries.get(id)
if (exist) {
if (exist.status === STATE.FAILED || exist.status === STATE.LINK_ONLY) return retry(id)
return publicView(exist)
}
const e = {
id,
url,
source: String(src.source || 'gen'),
status: STATE.QUEUED,
bytes: 0, mime: '', w: Number(src.w || 0), h: Number(src.h || 0),
ref: null, displayRef: null, thumbRef: null,
retries: 0, lastError: '', requestId: String(src.requestId || ''),
createdAt: now(), updatedAt: now(), meta: src.meta || {},
}
entries.set(id, e)
queue.push(id)
persist(publicView(e))
emit(STATE.QUEUED, publicView(e))
pump()
return publicView(e)
}
// 重试:复位状态重新排队(失败记录不删,url 保留)
function retry (id) {
const e = entries.get(id)
if (!e) return null
e.runSeq = (e.runSeq || 0) + 1 // 旧运行作废(回包晚到不覆盖新状态)
e.retries = 0
setStatus(e, STATE.QUEUED, { lastError: '' })
queue.push(id)
pump()
return publicView(e)
}
// 取消:仅对排队中/下载中有效;字节未落地的记录回到 queued 之外的状态由宿主任意处理
function cancel (id) {
const e = entries.get(id)
if (!e) return null
e.runSeq = (e.runSeq || 0) + 1
try { if (e.ctrl && typeof e.ctrl.abort === 'function') e.ctrl.abort() } catch (eC) { /* ignore */ }
try { delete e.ctrl } catch (eD) { /* ignore */ }
const at = queue.indexOf(id)
if (at >= 0) queue.splice(at, 1)
if (e.status === STATE.QUEUED || e.status === STATE.DOWNLOADING) setStatus(e, STATE.LINK_ONLY, { lastError: 'cancelled' })
return publicView(e)
}
// 释放本地字节,保留记录与 url(「仅保留链接」)
function release (id) {
const e = entries.get(id)
if (!e) return null
setStatus(e, STATE.LINK_ONLY, { ref: null, displayRef: null, thumbRef: null })
return publicView(e)
}
// 清空已结束的记录(ready/failed/link-only);进行中的保留(正在下载/排队),避免清掉在飞任务。
function clearFinished () {
let n = 0
for (const [id, e] of Array.from(entries.entries())) {
if (e.status === STATE.READY || e.status === STATE.FAILED || e.status === STATE.LINK_ONLY) {
entries.delete(id)
try { if (typeof d.removeEntry === 'function') d.removeEntry(id) } catch (err) { /* ignore */ }
n++
}
}
if (n) emit('cleared', { count: n })
return n
}
function remove (id) {
const at = queue.indexOf(id)
if (at >= 0) queue.splice(at, 1)
entries.delete(id)
try { if (typeof d.removeEntry === 'function') d.removeEntry(id) } catch (e) { /* ignore */ }
emit('removed', { id })
return true
}
// 启动恢复:queued / downloading 重新排队;ready 但宿主说字节不在了 → missing(keep url)
function restore (saved) {
const arr = Array.isArray(saved) ? saved : []
for (const raw of arr) {
if (!raw || !raw.id || !raw.url) continue
const e = Object.assign({}, raw, { meta: raw.meta || {} })
if (e.status === STATE.READY) e.status = STATE.READY
else if (e.status === STATE.FAILED) e.status = STATE.FAILED
else if (e.status === STATE.LINK_ONLY) e.status = STATE.LINK_ONLY
else e.status = STATE.QUEUED
entries.set(e.id, e)
if (e.status === STATE.QUEUED) queue.push(e.id)
}
pump()
return stats()
}
// 宿主自检回调:索引是 ready 但字节读不出来 → 标 missing(仍保留 url,可 retry)
function markMissing (id, reason) {
const e = entries.get(id)
if (!e) return null
setStatus(e, STATE.FAILED, { lastError: String(reason || 'missing-bytes'), ref: null, displayRef: null })
return publicView(e)
}
return { enqueue, retry, cancel, release, remove, clearFinished, get, list, stats, restore, markMissing, STATE }
}
// 带进度的取字节:流式读 body,按 content-length 报百分比;拿不到长度就只报已收字节。
// 失败(CORS/非 2xx/无 body)抛错,交给宿主回退到既有 wBlobFromSrc。
function blobToDataUrl (blob) {
return new Promise((resolve) => {
try {
const fr = new FileReader()
fr.onload = () => resolve(String(fr.result || ''))
fr.onerror = () => resolve('')
fr.readAsDataURL(blob)
} catch (e) { resolve('') }
})
}
async function fetchWithProgress (url, onProgress, signal) {
const res = await fetch(url, signal ? { signal: signal } : undefined)
if (!res || !res.ok) throw new Error('http-' + String((res && res.status) || 'error'))
const total = Number(res.headers && res.headers.get && res.headers.get('content-length')) || 0
let blob = null
if (res.body && typeof res.body.getReader === 'function') {
const reader = res.body.getReader()
const chunks = []
let received = 0
for (;;) {
const step = await reader.read()
if (!step || step.done) break
if (step.value) { chunks.push(step.value); received += step.value.length || 0 }
if (typeof onProgress === 'function') onProgress(received, total)
}
blob = new Blob(chunks, { type: String((res.headers && res.headers.get && res.headers.get('content-type')) || '') })
} else {
blob = await res.blob()
if (typeof onProgress === 'function') onProgress(blob ? blob.size : 0, total)
}
const dataUrl = blob ? await blobToDataUrl(blob) : ''
if (!dataUrl) return { ok: false, error: 'empty-bytes' }
return { ok: true, dataUrl, mime: String((blob && blob.type) || ''), bytes: (blob && blob.size) || 0 }
}
// 宿主取字节适配器:流式(带进度)→ 失败回退宿主既有 blob 取法;整体带超时。
// 放进本模块是为了让 app.js 只留一行装配(Workbench 行数棘轮)。
function createFetchBytes (deps) {
const d = deps || {}
const timeoutMs = Math.max(1000, Number(d.timeoutMs) || 300000)
return async function fetchBytes (url, onProgress, signal) {
// 2026-12-03(用户裁定):优先用系统网络栈(Rust reqwest)—— 不受 CORS/WebView 限制,
// 图床/CDN 对 XHR 的限速、挂起、防盗链都不会再影响下载。拿不到再退回 WebView fetch。
if (typeof d.rustFetch === 'function') {
try {
const r = await d.rustFetch(url)
if (r && r.ok && r.b64) {
const mime = String(r.mime || 'application/octet-stream')
if (typeof onProgress === 'function') onProgress(Number(r.bytes) || 0, Number(r.bytes) || 0)
return { ok: true, dataUrl: 'data:' + mime + ';base64,' + String(r.b64), mime: mime, bytes: Number(r.bytes) || 0 }
}
} catch (eR) { /* 非 Tauri / 命令缺失 → 回退 WebView fetch */ }
}
let timer = null
const job = fetchWithProgress(url, onProgress, signal).catch(async () => {
// 用户取消(abort)导致的失败:不要回退再抓一次,直接按中止返回。
if (signal && signal.aborted) return { ok: false, error: 'aborted' }
const blob = await d.blobFromSrc(url)
const dataUrl = blob ? await d.blobToDataUrl(blob) : ''
return dataUrl ? { ok: true, dataUrl, mime: String((blob && blob.type) || '') } : { ok: false, error: 'empty-bytes' }
})
const timeout = new Promise((resolve) => { timer = setTimeout(() => resolve({ ok: false, error: 'timeout' }), timeoutMs) })
try { return await Promise.race([job, timeout]) } catch (e) { return { ok: false, error: String((e && e.message) || 'fetch-failed') } } finally { try { if (timer) clearTimeout(timer) } catch (e2) { /* ignore */ } }
}
}
global.IWBImageIngest = { create, STATE, fetchWithProgress, createFetchBytes }
})(typeof window !== 'undefined' ? window : globalThis)
+10 -2
View File
@@ -11,6 +11,7 @@
function create (deps) {
const d = deps || {}
const missAt = new Map() // key -> 首次发现「无缩略图」的时间(300ms 后回退原图)
const cache = d.cache // Map<stableKey, url>
const max = Math.max(64, Number(d.max) || 768)
// v3.26.121:小档(256)缓存与队列;缺省不启用(只有注入时才分档)
@@ -56,13 +57,20 @@
// 小图没就绪时先给 512(已有就秒出)或占位,绝不为了"小一档"去同步解原图。
if (key && smallCache && need <= smallMax) {
const sm = smallCache.get(key)
if (sm) return sm
if (sm) { missAt.delete(key); return sm }
const orig0 = (v && typeof v === 'object')
? ((typeof d.resolveImg === 'function' ? d.resolveImg(v) : '') || '')
: String(v || '')
if (orig0 && !/^https?:/i.test(orig0) && typeof smallQueue === 'function') smallQueue(key, orig0)
if (thumb) return thumb
return /^https?:/i.test(orig0) ? orig0 : (thumb || '')
// v3.26.172:小图还没生成时**最多占位 300ms**,超时就退回原图 ——
// 之前本地图无缩略图时一律返回空串,遇到「标注替换原图」这类新字节,
// 新 key 没有缓存、缩略图又生成失败/很慢时,节点就一直是空白(观感=图片丢了)。
// v3.26.179:本地图没有缩略图时**直接返回原图**。
// 之前返回空串占位,<img src=""> 会触发 onError,节点体把它永久标成「图片源已失效」,
// 之后又没有重渲染去纠正 ⇒ 标注覆盖后看起来就是“图丢了”(且错误态反复重试吃 CPU)。
// 缩略图仍会在后台生成,就绪后由 bump 触发一次重渲染换小图。
return orig0 || thumb || ''
}
if (thumb && need <= ORIG_HARD_CAP) return thumb
const orig = (v && typeof v === 'object')
+187
View File
@@ -0,0 +1,187 @@
/* image-writeback.js —— 图片写回的唯一收口(v3.26.183)
*
* 为什么单独成模块:v3.26.174~182 的 4 个线上问题全部落在同一条链上
* 「插件写图 → 节点数据 → 缩略图缓存 → 节点渲染」
* 修复时逻辑分散在 app.js 插件桥 / runtime-workbench-logic.saveNodeImage / 缩略图模块,
* 顺序靠人记(先清引用、再写、再失效、再重渲染),改一处漏一处就会复现「图不落地 / CPU 空转」。
* 这里把顺序固定下来,app.js 只做装配。
*
* 插件侧契约(改前先读 docs/standards/plugin-development.md):
* · replaceNodeImageSync —— 同步返回严格布尔:只改内存 + 失效缓存 + bump,不落盘。
* blank-canvas / white-bg-800 都写成 if (!setNodeImage(...)) throw,
* 返回 Promise 会恒真、错误静默,所以这条语义不能改。
* · replaceNodeImage —— Promise<{ok,error}>:落盘 + 回读校验,失败回滚旧图。
* · createNodeImage —— 同步返回节点 id;大图在后台引用化(失败保留 data URL,功能不降级)。
*
* 阈值只有一条判据:deps.inlineMax(= app.js 的 IMPORT_INLINE_MAX,与 wImportImage 同一个常量)。
* 超过即引用化,且统一走 deps.importer(app.js 注入 wImportImage(keepOriginal))——
* 不另造第二套阈值/写库通道。
*/
;(function (global) {
'use strict'
function create (deps) {
const d = deps || {}
const inlineMax = Math.max(1, Number(d.inlineMax) || 3000)
const log = typeof d.log === 'function' ? d.log : function () {}
const isDataUrl = (v) => typeof v === 'string' && v.indexOf('data:') === 0
const isBig = (v) => isDataUrl(v) && v.length > inlineMax
function nodes () { return (d.refs && d.refs.nodes) || [] }
function findNode (id) { const ns = nodes(); for (let i = 0; i < ns.length; i++) if (ns[i] && ns[i].id === id) return ns[i]; return null }
function invalidate (v) { if (v == null || v === '') return; try { if (typeof d.invalidate === 'function') d.invalidate(v) } catch (e) { /* ignore */ } }
function bump () { try { if (typeof d.bump === 'function') d.bump() } catch (e) { /* ignore */ } }
// 引用化:只处理「大于内联阈值」的数据;小图直接内联(同一判据,见模块头)
async function importFor (dataUrl) {
if (!isBig(dataUrl)) return null
if (typeof d.importer !== 'function') return null
try {
const r = await d.importer(dataUrl)
return (r && r.ok) ? r : null
} catch (e) { return null }
}
// 旧图备份:首覆盖取旧 data(其次 url),之后原样沿用;base64 一律引用化
async function origValue (prev) {
const own = prev && prev.orig
if (own) {
if (typeof own !== 'string') return own
if (!isDataUrl(own)) return own
const r = await importFor(own)
return r ? (r.ref || r.data) : own
}
const d0 = prev && prev.data
// 旧图可能已经是引用对象(上一次写回/迁移后的形态):原样当备份,不能再「引用化引用」
const cand = isDataUrl(d0) ? d0 : ((d0 && typeof d0 === 'object') ? d0 : ((prev && typeof prev.url === 'string') ? prev.url : ''))
if (!cand) return ''
if (typeof cand !== 'string') return cand
const r = await importFor(cand)
return r ? (r.ref || r.data) : cand
}
function readBack (id) {
try {
const res = typeof d.readWorkspace === 'function' ? d.readWorkspace() : null
const doc = (res && res.ok === true && res.value) ? res.value : (res && res.workspaces ? res : null)
const ws = ((doc && doc.workspaces) || []).find((w) => w.id === (typeof d.activeWsId === 'function' ? d.activeWsId() : ''))
return (ws && (ws.nodes || []).find((n) => n.id === id)) || null
} catch (e) { return null }
}
// 异步写回:引用化 → 一次 commit → 落盘 → 回读校验(失败回滚)→ 失效双 key → bump
async function replaceNodeImage (id, dataUrl) {
const src = String(dataUrl == null ? '' : dataUrl)
if (!isDataUrl(src)) return { ok: false, error: '图片数据无效' }
const t = findNode(id)
if (!t) return { ok: false, error: '原节点不存在' }
const prev = t.data || {}
if (prev.data === src) return { ok: true } // 没改动:不必落盘,也不该被「数据未变化」误判失败
const res = await importFor(src)
const ref = (res && res.ref) ? res.ref : null
const dataVal = (res && res.data) ? res.data : src
const orig = await origValue(prev)
const patch = { data: dataVal, url: '', localRef: ref, ref: ref }
if (orig) patch.orig = orig
const next = nodes().map((n) => (n && n.id === id ? { ...n, data: { ...(n.data || {}), ...patch } } : n))
d.commitCanvas(next, undefined, undefined)
try { await d.saveNow({ nodes: next }) } catch (e) { /* saveNow 内部会记恢复点 */ }
const saved = readBack(id)
const sd = saved && saved.data
// 不能只看「有没有 data」:保存失败时磁盘上仍是旧图,也是 truthy,必须确认相对旧值发生了变化
const dataOk = !!(sd && ((sd.data && sd.data !== prev.data) || sd.orig !== prev.orig || (sd.url && sd.url !== prev.url)))
if (!dataOk) {
const back = nodes().map((n) => (n && n.id === id ? { ...n, data: prev } : n))
try { d.commitCanvas(back, undefined, undefined) } catch (e) { /* ignore */ }
invalidate(prev.data); invalidate(prev.localRef)
bump()
log('plugin-img save id=' + id + ' ok=false err=disk-verify')
return { ok: false, error: '保存失败,已恢复原图;请检查磁盘空间或资料目录权限' }
}
invalidate(prev.data); invalidate(prev.localRef); invalidate(dataVal); invalidate(src)
bump()
log('plugin-img save id=' + id + ' ok=true ref=' + (ref ? 'Y' : 'N') + ' len=' + src.length)
return { ok: true }
}
// 同步写回:只改内存(一次 commit)+ 失效 + bump,绝不调 saveNow;
// 大图在后台引用化,避免把多 MB base64 留在 DOM/工作区里(与「立即回收内存」同一动作)
function replaceNodeImageSync (id, dataUrl) {
const src = String(dataUrl == null ? '' : dataUrl)
if (!isDataUrl(src)) return false
const t = findNode(id)
if (!t) return false
const prev = t.data || {}
const origCand = (prev.orig && typeof prev.orig !== 'string') ? prev.orig
: (typeof prev.orig === 'string' ? prev.orig
: (isDataUrl(prev.data) ? prev.data : (typeof prev.url === 'string' ? prev.url : '')))
const patch = { data: src, url: '', localRef: null, ref: null }
if (origCand) patch.orig = origCand
try { d.updateNode(id, patch) } catch (e) { return false }
invalidate(prev.data); invalidate(prev.localRef); invalidate(src)
bump()
log('plugin-img set id=' + id + ' len=' + src.length + ' prevLocal=' + (prev.localRef ? 'Y' : 'N'))
if (isBig(src)) {
importFor(src).then((r) => {
if (!r || !r.ref) return
const cur = findNode(id)
if (!cur || (cur.data || {}).data !== src) return // 期间又被覆盖过:不抢
try { d.updateNode(id, { data: r.ref, url: '', localRef: r.ref, ref: r.ref }) } catch (e) { return }
invalidate(src); invalidate(r.ref); bump()
log('plugin-img set id=' + id + ' ref=Y')
}).catch(() => { /* 引用化失败:保留 data URL,功能不降级 */ })
}
const oldOrig = patch.orig
if (isBig(oldOrig)) {
importFor(oldOrig).then((r) => {
if (!r || !(r.ref || r.data)) return
const cur = findNode(id)
if (!cur || (cur.data || {}).orig !== oldOrig) return
try { d.updateNode(id, { orig: r.ref || r.data }) } catch (e) { /* ignore */ }
}).catch(() => { /* ignore */ })
}
return true
}
// 建「参考图」节点:同步返回 id,大图后台引用化(6 个插件只用返回值,故对插件透明)
function createNodeImage (payload) {
const src = payload && payload.dataUrl
if (!isDataUrl(String(src == null ? '' : src))) return null
const at = payload || {}
const id = typeof d.createRefNode === 'function' ? d.createRefNode(at) : null
if (!id) return null
const s = String(src)
if (isBig(s)) {
importFor(s).then((r) => {
if (!r || !r.ref) return
const cur = findNode(id)
if (!cur || (cur.data || {}).data !== s) return
try { d.updateNode(id, { data: r.ref, url: '', localRef: r.ref, ref: r.ref }) } catch (e) { return }
invalidate(s); invalidate(r.ref); bump()
log('plugin-img new id=' + id + ' ref=Y len=' + s.length)
}).catch(() => { /* 保留 data URL */ })
}
return id
}
// 「还原替换前原图」:orig 可能是 string,也可能是引用对象
async function restoreOrig (id) {
const t = findNode(id)
if (!t) return { ok: false, error: '原节点不存在' }
const own = (t.data || {}).orig
let du = ''
if (typeof own === 'string') du = own
else if (own && typeof d.resolveRef === 'function') { try { du = await d.resolveRef(own) } catch (e) { du = '' } }
if (!isDataUrl(du)) return { ok: false, error: '原图已不可用' }
const r = await importFor(du)
const ref = (r && r.ref) ? r.ref : null
d.updateNode(id, { data: (r && r.data) || du, url: '', localRef: ref, ref: ref, orig: '' })
invalidate(du); invalidate(ref); bump()
return { ok: true }
}
return { replaceNodeImage, replaceNodeImageSync, createNodeImage, restoreOrig }
}
global.IWBImageWriteback = { create }
})(typeof window !== 'undefined' ? window : globalThis)
+5 -2
View File
@@ -63,10 +63,13 @@
const res = (Q && typeof Q.queryOutputs === 'function')
? Q.queryOutputs(list, { query: o.query || '', range: o.range || '', limit, width: 320, tile: 130 })
: { filtered: list, visible: list.slice(0, limit), total: list.length }
// 2026-12-02(方案 A:先落地再显示):只展示已落地(orig=ok)的图;
// pending(下载中)/ missing(失败)一律静默隐藏 —— 用户要的是「图库出现时就是完整可用的」,
// 不再先冒一张取不到缩略图的空卡。'off' 是旧版「不备份原图」的历史条目(有缩略图),保留可见。
const items = (res.visible || []).map(function (f) {
return { name: f.name, label: f.label || '', w: f.w || 0, h: f.h || 0, mtime: f.mtime || 0, orig: f.orig || (f.origIdb ? 'ok' : 'missing') }
})
return { items: items, total: res.total || items.length }
}).filter(function (it) { return it.orig === 'ok' || it.orig === 'off' })
return { items: items, total: items.length }
}
global.IWBPluginGallery = { setImpl: setImpl, api: function () { return API }, query: query, emit: emit }
+48
View File
@@ -0,0 +1,48 @@
/* plugin-api-queue.js —— 宿主「任务队列」能力(2026-12-03)
*
* 插件只是一个视图:账本、下载、落地、定位、记录上限全部在宿主。
* 与 gallery 能力同构:setImpl 由 Workbench 每次渲染注入,插件拿到稳定代理。
*/
;(function (global) {
'use strict'
let impl = null
const listeners = []
function setImpl (next) { impl = (next && typeof next === 'object') ? next : null }
function call (name) {
return function () {
const fn = impl && impl[name]
if (typeof fn !== 'function') return Promise.reject(new Error('任务队列能力未就绪'))
try { return Promise.resolve(fn.apply(null, arguments)) } catch (e) { return Promise.reject(e) }
}
}
function emit (reason) {
for (const fn of listeners.slice()) {
try { fn(reason || 'changed') } catch (e) { /* 插件回调异常不影响宿主 */ }
}
}
const API = {
list: call('list'),
retry: call('retry'),
restart: call('restart'),
land: call('land'),
preview: call('preview'),
copyLink: call('copyLink'),
locate: call('locate'),
stats: call('stats'),
clear: call('clear'),
getLimit: call('getLimit'),
setLimit: call('setLimit'),
onChanged: function (fn) {
if (typeof fn !== 'function') return function () {}
listeners.push(fn)
return function () { const i = listeners.indexOf(fn); if (i >= 0) listeners.splice(i, 1) }
},
}
global.IWBPluginQueue = { setImpl, api: function () { return API }, emit }
})(typeof window !== 'undefined' ? window : globalThis)
+126
View File
@@ -0,0 +1,126 @@
/* plugin-canvas-bridge.js —— 插件画布桥(2026-12-02 从 app.js 迁出)
*
* 为什么单独成模块:这是插件唯一能碰画布的入口(读节点 / 建节点 / 写图),
* 之前整块躺在 Workbench 里,占掉约 90 行,而 app.js 与 Workbench 行数棘轮都是零余量。
* 逻辑本身不需要 React —— 依赖全是「读 refs、调用已有命令」,所以按 ctx + 注入搬出来。
*
* 依赖约定(全部由 app.js 注入,模块内不读任何全局可变状态):
* · refs / selRef 画布节点与选中的实时引用
* · updateNode / commitCanvas / saveNow
* · findSpot / placeAtDrop / addPluginNode / uid / cloneNodeDefaults / NODE_TYPES
* · CanvasGeometry 坐标换算(纯函数)
* · importer / inlineMax 引用化唯一入口(app.js 的 wImportImage(keepOriginal) 与 IMPORT_INLINE_MAX)
* · invalidate / bump 缩略图双档缓存失效与重渲染
* · gallerySync / imgRefWrite / ensureTier / pluginPreview / shrinkDataUrl 取图链路
* · showToast / log 用户提示与 _boot.log
* · imageWritebackFactory src/image-writeback.js 的 create
*
* 返回 { bridge, writeback }:app.js 只保存这两个引用,卸载时置空。
*/
;(function (global) {
'use strict'
function create (deps) {
const d = deps || {}
const refs = d.refs
const CanvasGeometry = d.CanvasGeometry
const NODE_TYPES = d.NODE_TYPES
const gallerySync = d.gallerySync
const log = typeof d.log === 'function' ? d.log : function () {}
const showToast = typeof d.showToast === 'function' ? d.showToast : function () {}
const writeback = (d.imageWritebackFactory && typeof d.imageWritebackFactory.create === 'function')
? d.imageWritebackFactory.create({
refs,
updateNode: d.updateNode,
commitCanvas: d.commitCanvas,
saveNow: d.saveNow,
readWorkspace: d.readWorkspace,
activeWsId: d.activeWsId,
inlineMax: d.inlineMax,
importer: d.importer,
invalidate: d.invalidate,
bump: d.bump,
resolveRef: d.resolveRef,
createRefNode: (payload) => {
const at = payload || {}
// 与 createNode 同一套坐标语义:给了有限坐标就用它(拖拽松手点,压住节点时就近吸附),否则走 findSpot 找位
const spot = (CanvasGeometry && CanvasGeometry.wantsDefaultSpot(at.x, at.y)) ? d.findSpot('ref') : d.placeAtDrop('ref', at.x, at.y)
const node = { id: d.uid('n'), type: 'ref', x: spot.x, y: spot.y, data: { url: '', data: String(at.dataUrl), name: String(at.name || 'plugin.png'), localName: null } }
d.commitCanvas(refs.nodes.concat([node]), undefined, undefined)
return node.id
},
log: log,
})
: null
const bridge = {
getNodes: () => refs.nodes.map((n) => ({ id: n.id, type: n.type, x: n.x, y: n.y, data: n.data || {} })),
getSelectedNode: () => {
const id = d.selRef.current && d.selRef.current[0]
const n = id ? refs.nodes.find((x) => x.id === id) : null
return n ? { id: n.id, type: n.type, name: String((n.data && (n.data.name || n.data.title)) || '') } : null
},
// v3.26.61:逻辑在 src/gallery-sync.js 的 nodeImageOf(补 localRef 候选 + 远程按需落地)
getNodeImage: async (id, opts) => {
const n = refs.nodes.find((x) => x.id === id)
if (!n || !gallerySync) return null
const img = await gallerySync.nodeImageOf(n, { writeRef: (src) => d.imgRefWrite(src), onLocalRef: (ref) => d.updateNode(n.id, { localRef: ref }) })
// v3.26.124:插件只要能看/能预览时,给**缩过的**图,别让它整幅解码原图
const max = Math.max(64, Number(opts && opts.max) || 0)
if (!img || !max) return img
try {
const src = img.localRef || img.url || img.dataUrl
if (src && typeof src === 'object') {
const t = await d.ensureTier(src, max)
if (t) { const p = await d.pluginPreview(src, { max }); if (p && p.ok) return Object.assign({}, img, { dataUrl: p.dataUrl, capped: max }) }
} else if (typeof src === 'string' && src.indexOf('data:') === 0) {
const s2 = await d.shrinkDataUrl(src, max)
if (s2) return Object.assign({}, img, { dataUrl: s2, capped: max })
}
} catch (e) { /* ignore */ }
return img
},
createNode: (type, x, y, data) => {
// 插件节点传的是变体 id(web/style…):不在 NODE_TYPES 里,交给 addPluginNode 拼出 plugin:<插件>:<变体>
if (!NODE_TYPES.has(type)) return d.addPluginNode(type, x, y, data) || null
const spot = (CanvasGeometry && CanvasGeometry.wantsDefaultSpot(x, y)) ? d.findSpot(type) : d.placeAtDrop(type, x, y)
const node = { id: d.uid('n'), type, x: spot.x, y: spot.y, data: Object.assign({}, d.cloneNodeDefaults(type), data || {}) }
d.commitCanvas(refs.nodes.concat([node]), undefined, undefined)
return node.id
},
// 屏幕坐标 → 世界坐标:供插件「按住按钮拖到画布上松手」建节点(2026-11-02)。
// 读 .iwb-world 的实时 transform 与 .iwb-canvas 的 rect —— 与 tbCenterSeed 同一套口径,
// 不用 refs.viewport(渲染落后一拍时换算会偏)。换算本身是纯函数,在 canvas-geometry。
screenToWorld: (clientX, clientY) => {
const c = global.document ? global.document.querySelector('.iwb-canvas') : null
if (!c || !c.clientWidth) return null
const wl = /** @type {any} */ (global.document.querySelector('.iwb-world'))
const t = (CanvasGeometry && CanvasGeometry.parseWorldTransform) ? CanvasGeometry.parseWorldTransform(wl && wl.style ? wl.style.transform : '') : null
return CanvasGeometry.clientToWorld(clientX, clientY, c.getBoundingClientRect(), t || refs.viewport)
},
createImageNode: (payload) => (writeback ? writeback.createNodeImage(payload) : null),
// 同步入口:契约上必须返回严格布尔、不落盘(blank-canvas / white-bg-800 依赖)
setNodeImage: (id, dataUrl) => {
const ok = writeback ? writeback.replaceNodeImageSync(id, String(dataUrl || '')) : false
if (ok) { try { showToast('已替换图片', 'ok') } catch (eT) { /* ignore */ } }
return ok
},
// 异步入口:落盘 + 回读校验 + 失败回滚,结果原样回给插件(image-annotate 依赖 ok/error)
saveNodeImage: (id, dataUrl) => {
if (!writeback) return Promise.resolve({ ok: false, error: '画布能力未就绪' })
return writeback.replaceNodeImage(id, dataUrl).then((r) => {
try {
if (r && r.ok) showToast('已覆盖原图', 'ok')
else showToast('覆盖失败:' + String((r && r.error) || '未知原因'), 'err')
} catch (eT) { /* ignore */ }
return r
})
},
}
return { bridge, writeback }
}
global.IWBPluginCanvasBridge = { create }
})(typeof window !== 'undefined' ? window : globalThis)
+2 -2
View File
@@ -4,8 +4,8 @@
const API_VERSION = 1
const ID_PATTERN = /^[a-z][a-z0-9-]{2,31}$/
const REQUIRED_FIELDS = ['id', 'name', 'version', 'apiVersion', 'capabilities']
const CAPABILITIES = ['panels', 'commands', 'nodeTypes', 'generationHooks', 'providers', 'canvas', 'canvasWrite', 'nodeActions', 'gallery', 'grouplib', 'promptlib', 'files', 'images']
const CAPABILITY_API_KEYS = { panels: 'ui', commands: 'commands', nodeTypes: 'nodes', generationHooks: 'generation', providers: 'providers', canvas: 'canvas', canvasWrite: 'canvas', nodeActions: 'nodeActions', gallery: 'gallery', grouplib: 'grouplib', promptlib: 'promptlib', files: 'files', images: 'images' }
const CAPABILITIES = ['panels', 'commands', 'nodeTypes', 'generationHooks', 'providers', 'canvas', 'canvasWrite', 'nodeActions', 'gallery', 'grouplib', 'promptlib', 'files', 'images', 'queue', 'pages']
const CAPABILITY_API_KEYS = { panels: 'ui', commands: 'commands', nodeTypes: 'nodes', generationHooks: 'generation', providers: 'providers', canvas: 'canvas', canvasWrite: 'canvas', nodeActions: 'nodeActions', gallery: 'gallery', grouplib: 'grouplib', promptlib: 'promptlib', files: 'files', images: 'images', queue: 'queue', pages: 'ui' }
function createPluginHost(options) {
const opt = options || {}
+10 -3
View File
@@ -193,6 +193,8 @@
let memDegradeAt = 0
let memDegradeStage = 0 // S15:0=首触(只降级"非打开标签"画板);1=再触(压到活动标签 + 提示关标签)
const memTimer = setInterval(() => {
// v3.26.170:诊断关掉时整轮跳过(不采样、不算内存构成、不跑护栏)
try { if (lsGet('iwb_diag_off', false)) return } catch (e) { /* ignore */ }
try {
// v3.87.6:每次采样都落盘(环形 40 条 ≈ 10 分钟)——标签页被杀后重开即可看到"崩溃前的增长曲线"
// v3.87.37:启动后执行一次存量原图副本清理(只跑一次,localStorage 标记)
@@ -235,10 +237,15 @@
// 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)) {
// v3.26.171:自动回收阈值放松 —— 实测 3.4GB 时手动回收能立刻把 CPU 从 20% 降下来
// (大堆导致持续 GC),而旧策略要求「可见且空闲 5 分钟」才动手,日常很难触发。
// 现在:空闲 90s 即可轻量回收;RSS 超过 2500MB 时不等空闲,直接做完整回收(含缩略图缓存)。
const canVisibleIdleReclaim = !(typeof document !== 'undefined' && document.hidden) && idleMs > 90000
const heavyNow = procEst >= 2500
const canReclaim = (typeof document === 'undefined' || document.hidden) || canVisibleIdleReclaim || heavyNow
if (procEst >= procLimit && nowMs - memReclaimAt > 120000 && !(refs && refs.saving) && !(refs && refs.genRuns && refs.genRuns.size) && canReclaim) {
memReclaimAt = nowMs
Promise.resolve().then(() => wReclaimMemoryNow('auto ' + (canVisibleIdleReclaim ? 'idle ' : '') + (rssNow > 0 ? 'rss ' : 'est ') + procEst + 'MB', { keepThumbs: true })).catch(() => { /* ignore */ })
Promise.resolve().then(() => wReclaimMemoryNow('auto ' + (heavyNow ? 'heavy ' : (canVisibleIdleReclaim ? 'idle ' : '')) + (rssNow > 0 ? 'rss ' : 'est ') + procEst + 'MB', { keepThumbs: !heavyNow })).catch(() => { /* ignore */ })
}
// 下面这条是「堆占比 ≥75%」的老护栏,只有 Chromium 系(Windows)才有意义
if (!mem || !mem.ratio) return
+20 -1
View File
@@ -91,5 +91,24 @@
return direct
}
g.IWBDownloadAuto = Object.freeze({ create, resolveLocalFirst })
// 方案 A(2026-12-02):自动下载优先等落地队列的本地字节,避免为同一张图再抓一次远程。
// 返回 dataURL;拿不到(无记录/失败/超时)返回 '',交给调用方走原有本地优先链路。
async function waitIngestRef (url, deps) {
const d = deps || {}
if (!url || typeof d.get !== 'function') return ''
const t0 = Date.now()
const max = Math.max(0, Number(d.timeoutMs) || 20000)
for (;;) {
const v = d.get(url)
if (v && v.ref) {
const du = typeof d.refDataUrl === 'function' ? await d.refDataUrl(v.ref) : ''
if (du) return du
}
if (!v || v.status === 'failed') return ''
if (Date.now() - t0 >= max) return ''
await new Promise((r) => setTimeout(r, 250))
}
}
g.IWBDownloadAuto = Object.freeze({ create, resolveLocalFirst, waitIngestRef })
})(typeof window !== 'undefined' ? window : globalThis)
+51 -5
View File
@@ -32,17 +32,20 @@
if (global.console && global.console.warn) global.console.warn('[iwb] ' + line)
} catch (e) { /* ignore */ }
}
const blank = () => ({ at: Date.now(), n: 0, long: 0, max: 0, tags: Object.create(null) })
const blank = () => ({ at: Date.now(), n: 0, long: 0, max: 0, tags: Object.create(null), js: 0, jsMs: 0 })
// 累计器:给自动化测试用的结构化读数。与 60s 落盘窗口相互独立,
// 所以「取一次 snapshot」既不会打断 _boot.log 的汇总节奏,也不会被窗口边界截断。
const total = Object.assign(blank(), { since: 0 })
function tag (name) { tagName = String(name || ''); tagAt = Date.now() }
function flush (now) {
if (!bucket || now - bucket.at < WINDOW_MS) return
if (bucket.long > 0) {
{
const tags = Object.keys(bucket.tags).map((k) => k + ':' + bucket.tags[k]).join(',')
const imgs = (global.document && global.document.images) ? global.document.images.length : -1
logLine('perf ' + Math.round((now - bucket.at) / 1000) + 's frames=' + bucket.n + ' long=' + bucket.long +
' max=' + Math.round(bucket.max) + 'ms tags=' + (tags || '-') + ' domImgs=' + imgs)
' max=' + Math.round(bucket.max) + 'ms js=' + bucket.js + '/' + Math.round(bucket.jsMs) + 'ms tags=' + (tags || '-') + ' domImgs=' + imgs)
}
bucket = blank()
}
@@ -54,11 +57,16 @@
// 首帧、标签页休眠恢复、窗口最小化回来时 dt 会非常大,不算进统计
if (!(dt > 0) || dt > 3000) return
bucket.n++
total.n++
if (!total.since) total.since = Date.now()
if (dt > LONG_MS) {
bucket.long++
if (dt > bucket.max) bucket.max = dt
const name = (Date.now() - tagAt < TAG_TTL) ? tagName : 'idle'
bucket.tags[name] = (bucket.tags[name] || 0) + 1
total.long++
if (dt > total.max) total.max = dt
total.tags[name] = (total.tags[name] || 0) + 1
}
flush(Date.now())
}
@@ -66,14 +74,52 @@
function start () {
if (raf || typeof global.requestAnimationFrame !== 'function') return
bucket = blank()
total.n = 0; total.long = 0; total.max = 0; total.tags = Object.create(null); total.js = 0; total.jsMs = 0; total.since = 0
last = global.performance && global.performance.now ? global.performance.now() : Date.now()
raf = global.requestAnimationFrame(tick)
watchLongTasks()
}
global.IWBPerf = { tag: tag, start: start, recent: recent }
let jsObserver = null
function watchLongTasks () {
if (jsObserver || typeof global.PerformanceObserver !== 'function') return
try {
jsObserver = new global.PerformanceObserver(function (list) {
for (const e of list.getEntries()) { total.js++; total.jsMs += Number(e.duration) || 0; if (!bucket) continue; bucket.js++; bucket.jsMs += Number(e.duration) || 0 }
})
jsObserver.observe({ entryTypes: ['longtask'] })
} catch (e) { jsObserver = null }
}
function stop () {
if (raf) { try { global.cancelAnimationFrame(raf) } catch (e) { /* ignore */ } }
raf = 0
bucket = null
try { if (jsObserver) jsObserver.disconnect() } catch (e) { /* ignore */ }
jsObserver = null
}
// snapshot():返回「自 start() 或上次 snapshot() 以来」的累计读数并清零(结构化,供自动化断言)。
// 字段:frames(帧数)/ long(>50ms 长帧数)/ max(最长帧 ms)/ js、jsMs(longtask 次数与总时长)/ tags(长帧归属)/ since(本段起点)
function snapshot () {
const out = {
frames: total.n,
long: total.long,
max: Math.round(total.max),
js: total.js,
jsMs: Math.round(total.jsMs),
tags: Object.assign({}, total.tags),
since: total.since || 0,
}
total.n = 0; total.long = 0; total.max = 0; total.tags = Object.create(null); total.js = 0; total.jsMs = 0; total.since = 0
return out
}
global.IWBPerf = { tag: tag, start: start, stop: stop, snapshot: snapshot, recent: recent, running: () => !!raf }
// 默认不启动:正式包(对外)不能往 _boot.log 写性能采样。
// 只有构建时 IWB_PERF_PROBE=1 注入 window.__IWB_PERF_PROBE__,
// 或显式设置 localStorage.iwb_perf_probe='1' 时才开启(排查用)。
const wantProbe = global.__IWB_PERF_PROBE__ === 1 || global.__IWB_PERF_PROBE__ === true
let lsOn = false
try { const S = global.IWBStorageLocal; const st = (S && typeof S.getStore === 'function') ? S.getStore() : null; lsOn = !!(st && String(st.get('iwb_perf_probe', '')).replace(/"/g, '') === '1') } catch (e) { lsOn = false }
const wantProbe = global.__IWB_PERF_PROBE__ === 1 || global.__IWB_PERF_PROBE__ === true || lsOn
if (wantProbe && typeof global.requestAnimationFrame === 'function') start()
})(typeof window !== 'undefined' ? window : globalThis)
-1
View File
@@ -36,6 +36,5 @@
} catch (_) { /* 记账本身失败绝不能影响主流程 */ }
}
global.IWBMetricsSwallow = swallow
global.IWBRuntimeMetricsFactory = create
global.IWBRuntimeMetrics = create()
})(typeof window !== 'undefined' ? window : globalThis)
+23 -36
View File
@@ -16,38 +16,6 @@
// 唯一的可变模块级状态:getter/setter 注入(模块内 1 读 1 写)
/** @type {{ get: () => number, set: (v: number) => void }} */
let selfSaveAt = { get: () => 0, set: () => {} }
// 标注「覆盖保存」:写完立刻落盘并校验;失败回滚旧图,返回可读错误。
// 放在本模块是为了守住 app.js 行数棘轮(只做装配);依赖由调用点注入。
async function saveNodeImage(deps, id, dataUrl) {
const d = deps || {}
const refs = d.refs
if (!refs || !/^data:/i.test(String(dataUrl || ''))) return { ok: false, error: '图片数据无效' }
const t = (refs.nodes || []).find((x) => x.id === id)
if (!t) return { ok: false, error: '原节点不存在' }
const prev = t.data || {}
if (prev.data === String(dataUrl)) return { ok: true } // 没改动:不必落盘,也不该被「数据未变化」误判失败
const patch = typeof d.origPatch === 'function' ? d.origPatch(prev, String(dataUrl)) : { data: String(dataUrl), url: '' }
const next = (refs.nodes || []).map((n) => (n.id === id ? { ...n, data: { ...n.data, ...patch } } : n))
d.commitCanvas(next, undefined, undefined)
try { await d.saveNow({ nodes: next }) } catch (e) { /* saveNow 内部会记恢复点 */ }
let saved = null
try {
const res = typeof d.readWorkspace === 'function' ? d.readWorkspace() : null
const doc = (res && res.ok === true && res.value) ? res.value : (res && res.workspaces ? res : null)
const ws = ((doc && doc.workspaces) || []).find((w) => w.id === (typeof d.activeWsId === 'function' ? d.activeWsId() : ''))
saved = ws && (ws.nodes || []).find((n) => n.id === id)
} catch (e) { saved = null }
// 不能只看「有没有 data」:保存失败时磁盘上仍是旧图,也是 truthy。必须确认节点数据相对旧值发生了变化
// (压缩/引用化后 data 可能是 __blob/__cache 对象,但一定不等于旧值)。
const sd = saved && saved.data
const dataOk = !!(sd && ((sd.data && sd.data !== prev.data) || sd.orig !== prev.orig || (sd.url && sd.url !== prev.url)))
if (!dataOk) {
try { d.commitCanvas((refs.nodes || []).map((n) => (n.id === id ? { ...n, data: prev } : n)), undefined, undefined) } catch (e) { /* ignore */ }
return { ok: false, error: '保存失败,已恢复原图;请检查磁盘空间或资料目录权限' }
}
return { ok: true }
}
function inject(d) {
const D = d || {}
GEN_HARD_TIMEOUT_MIN = D.GEN_HARD_TIMEOUT_MIN
@@ -271,6 +239,23 @@
const gn = baseNodes.find((n) => n.id === nodeId)
const cur = gn && Array.isArray(gn.data.result) ? gn.data.result : []
const nextResult = upsertGenerationEntry(cur, entry)
// 2026-12-02:每张结果落地就入队(这里是「结果写进节点数据」的唯一入口,批量/恢复都经过它)
// 2026-12-03:带 meta(画布/节点/提示词/模型/尺寸),任务队列页据此跨画布展示与定位。
const _ws0 = (refs.workspaces || []).find((w) => w.id === runWorkspaceId)
const _task0 = (node && node.data && Array.isArray(node.data.tasks) ? node.data.tasks : []).find((t) => String(t && t.id) === String(pid))
const _promptText = String((_task0 && _task0.text) || (entry && entry.label) || '').slice(0, 80)
const _meta = {
boardId: runWorkspaceId,
boardName: String((_ws0 && _ws0.name) || ''),
nodeId,
prompt: String((entry && (entry.taskTitle || entry.label)) || '').slice(0, 200),
promptText: _promptText,
variant: Number(vi) + 1,
model: String((node && node.data && node.data.model) || ''),
size: size || ((entry && entry.width && entry.height) ? (entry.width + 'x' + entry.height) : ''),
at: Number(entry && entry.at) || Date.now(),
}
try { if (global.__iwbIngest && entry && entry.url) global.__iwbIngest.enqueue({ url: entry.url, source: 'gen', w: entry.width, h: entry.height, meta: _meta }) } catch (eI) { /* 落地失败不得影响出图 */ }
genLatest = baseNodes.map((n) => (n.id === nodeId ? { ...n, data: { ...(n.data || {}), result: nextResult } } : n))
genLatest = commitRunNodes(runWorkspaceId, genLatest)
}
@@ -468,7 +453,8 @@
if (od && od.type === 'out' && (od.w || NODE_W) < 420) applyPatch(od.id, { w: 420 })
}
// 浏览器模式:图库索引/缩略图异步旁路写入,不阻塞生成结果和画布保存。
const runResult = await archiveGenerationResults(groups, () => refreshOutputs())
const _wsName = ((refs.workspaces || []).find((w) => w.id === runWorkspaceId) || {}).name || ''
const runResult = await archiveGenerationResults(groups, () => refreshOutputs(), { boardId: runWorkspaceId, boardName: String(_wsName), nodeId })
const failItems = []
for (const g of groups) for (const x of (g.items || [])) if (!x.ok) failItems.push(x.error || '生成失败')
if (failItems.length) {
@@ -822,7 +808,7 @@
}
const entry = { promptId: 'layers', label: '图层(' + ok.length + ' 张)', items: ok.map((l) => ({ ...l, label: l.name })) }
commitLayerResult(entry)
await archiveGenerationResults([entry], () => refreshOutputs())
await archiveGenerationResults([entry], () => refreshOutputs(), { boardId: activeWsId, boardName: String(((refs.workspaces || []).find((w) => w.id === activeWsId) || {}).name || ''), nodeId })
setNotice({ type: 'ok', text: '已生成 ' + ok.length + ' 张图层 ≈ ¥' + (ok.length * layerPriceOf(szParam)).toFixed(2) })
} catch (e) {
setNotice({ type: 'err', text: apiErrorMessage(e) })
@@ -1666,7 +1652,8 @@
// ③ 语义不变:仍是「变更前捕获」,深度仍 HISTORY_MAX=20,栈结构与存储格式都不变
// ④ 恢复:restore → wBoardNeedsHydrate → wHydrateWorkspace → wEnsureImgUrl 解析 {__cache} → objectURL ✓
// 边界:Cache Storage 不可用(非安全上下文)时**不引用化** —— 宁可多占内存,也不产出指向不存在字节的引用。
const HISTORY_IMG_REF_FIELDS = ['data', 'url', 'result']
// v3.26.183:orig 也进引用化名单 —— 覆盖后 orig 是旧图备份,漏了它每次覆盖都会在撤销快照里留一整串 base64
const HISTORY_IMG_REF_FIELDS = ['data', 'url', 'result', 'orig']
const historyRefUsable = () => { try { return typeof caches !== 'undefined' && !!caches && typeof caches.open === 'function' } catch (e) { return false } }
// d 是快照**独占**的浅拷贝(`{ ...n.data }` 当场生成,谁都不再持有)⇒ 就地改写安全,实时画布的字节不受影响。
// 失败退化为带字节的 data(多占内存,但绝不影响编辑主流程、也绝不丢撤销)。
@@ -2401,5 +2388,5 @@
}
return exportCanvas
}
global.IWBWorkbenchLogic = { inject, saveNodeImage, createCancelActions, createWorkspaceListActions, createWBExportCanvas, createWorkbenchSessions, createWorkbenchCommands, applyLatestSync, ensurePolished, taskCountOf, saveWorkspaceSnapshot, runWorkspaceNodes, commitRunNodes, computeHistColumns, syncOnceNow, startSyncPolling, startCanvasDrop, startGalleryMeasure, startCanvasZoomAndSize, startWsMoreOutside, nodeInGroupOf, selAnchorOf, keyAnomalyOf, joinGroupOf, connectedGroupIdsOf, runNode, saveNow , resumeRuns, pasteGraph, runLLM, runLayerNode, finishGenerationRun, importCanvasFile}
global.IWBWorkbenchLogic = { inject, createCancelActions, createWorkspaceListActions, createWBExportCanvas, createWorkbenchSessions, createWorkbenchCommands, applyLatestSync, ensurePolished, taskCountOf, saveWorkspaceSnapshot, runWorkspaceNodes, commitRunNodes, computeHistColumns, syncOnceNow, startSyncPolling, startCanvasDrop, startGalleryMeasure, startCanvasZoomAndSize, startWsMoreOutside, nodeInGroupOf, selAnchorOf, keyAnomalyOf, joinGroupOf, connectedGroupIdsOf, runNode, saveNow , resumeRuns, pasteGraph, runLLM, runLayerNode, finishGenerationRun, importCanvasFile}
})(typeof window !== 'undefined' ? window : globalThis)
+59 -6
View File
@@ -63,6 +63,7 @@
iwb_web_groups: 'groups.json', // 节点组
iwb_web_groupgroups: 'group-groups.json', // 节点组的分组树
iwb_web_outputs: 'gallery/index.json', // 图库清单(图片字节仍在 images/gallery/,按 hash 引用)
iwb_ingest_idx: 'task-queue/index.json', // 任务队列账本(全局生成记录;不随设置/画布一起写)
}
const libFileOf = (k) => LIB_FILES[k] || ''
const dirtyWs = new Set()
@@ -256,7 +257,13 @@
} catch (e) { return false }
},
async keys() { try { return Object.keys(assets).concat(Object.keys(small)) } catch (e) { return [] } },
async logPut(id, entry) { return kv.put('log:' + id, JSON.stringify(entry)) },
async logPut(id, entry) {
// v3.26.178:兼容两种调用 —— 浏览器端传 (entry),app.js 传 ({id, at, kind, msg, detail})。
// 旧实现只认 (id, entry),桌面端把整个对象当 id ⇒ key 变 log:[object Object]、值变 undefined,
// 所有 wLog 记录互相覆盖成一条垃圾数据。
if (id && typeof id === 'object') { entry = id; id = entry.id || ('log-' + Date.now()) }
return kv.put('log:' + id, JSON.stringify(entry))
},
async logAll() {
const out = []
for (const k of Object.keys(small)) if (k.indexOf('log:') === 0) { try { out.push(JSON.parse(small[k])) } catch (e) { /* ignore */ } }
@@ -1093,6 +1100,36 @@
} catch (e) { return '' }
}
// 2026-12-03:图库条目 → **本地原图**。桌面端原图在 images/gallery/<文件>,老记录没有 origIdb。
// 预览用 galleryOriginalOf(原生按 max 解码,落 thumbs 缓存,可反复命中);下载用 galleryOriginalBlob(原始字节)。
function galleryOrigAssetOf (f) {
try {
if (!enabled() || !dir || !f) return null
const key = String(f.origIdb || ('out_orig_' + String(f.name || '')))
const a = assets[key]
return (a && a.f) ? a : null
} catch (e) { return null }
}
async function galleryOriginalOf (f, max) {
try {
const a = galleryOrigAssetOf(f)
if (!a) return null
const abs = await join(dir, a.f)
const m = Math.max(256, Number(max) || 2048)
const h16 = await sha16(new TextEncoder().encode('galorig:' + String(f.name || a.f)))
const r = await makeDisplayThumbFromPath(h16, abs, m)
return (r && r.url) ? { url: r.url, w: r.w || 0, h: r.h || 0 } : null
} catch (e) { return null }
}
async function galleryOriginalBlob (f) {
try {
const a = galleryOrigAssetOf(f)
if (!a) return null
const abs = await join(dir, a.f)
const u8 = await fs().readFile(abs)
return (u8 && u8.length) ? new Blob([u8], { type: a.m || 'application/octet-stream' }) : null
} catch (e) { return null }
}
// v3.26.131:宫格缩略图改发 **objectURL**(同一张只读一次盘、只建一次 URL)。
// 原来每张都 base64 成 dataURL(20~40KB 字符串),164 张 ⇒ 每次开面板 3~6MB 字符串 + 164 次 IPC,
// 这就是「能加载但很慢」的来源。objectURL 首帧即用,重复打开直接命中。
@@ -1473,6 +1510,10 @@
// 子目录也要扫:images/{canvas,gallery,thumbs,legacy}/ 里的孤儿同样占空间
const subs = ['', 'canvas', 'gallery', 'thumbs', 'legacy']
const orphans = []
// 2026-12-03:thumbs/<hash>_<max>.<ext> 是**显示缓存**(320/512/768/2048),不进 assets、可再生。
// 之前把它们算成「未引用图片」并搬进 trash ⇒ 每次清理都搬一遍新缓存,数字也被夸大。默认不动。
const THUMB_CACHE_RE = /_\d+\.(jpg|jpeg|webp|png)$/i
let thumbCaches = 0
for (const sub of subs) {
const abs = sub ? await join(imgAbs, sub) : imgAbs
let entries = []
@@ -1480,25 +1521,37 @@
for (const e of entries) {
if (!e || e.isDirectory) continue
const rel = IMG_DIR + '/' + (sub ? sub + '/' : '') + e.name
if (!used.has(rel)) orphans.push({ sub: sub, name: e.name, rel: rel })
if (used.has(rel)) continue
if (sub === 'thumbs' && THUMB_CACHE_RE.test(String(e.name))) { thumbCaches++; continue }
orphans.push({ sub: sub, name: e.name, rel: rel })
}
}
// 断链:画布引用了、但登记表里没有的 key —— 这类节点的图**已经显示不出来**,
// GC 不会动它们(文件根本不在),但值得在确认弹窗里报数,让用户知道数据已经缺了。
const dangling = Array.from(canvasKeys).filter((k) => !assets[k]).length
const keptByCanvas = referenced.size
if (dryRun || !orphans.length) return { ok: true, orphans: orphans.length, moved: 0, dryRun: dryRun, dangling: dangling, keptByCanvas: keptByCanvas }
if (dryRun || !orphans.length) return { ok: true, orphans: orphans.length, moved: 0, dryRun: dryRun, dangling: dangling, keptByCanvas: keptByCanvas, thumbCaches: thumbCaches }
const trashAbs = await join(dir, 'trash')
let moved = 0
for (const item of orphans) {
try {
const targetDir = item.sub ? await join(trashAbs, item.sub) : trashAbs
await fs().mkdir(targetDir, { recursive: true })
await fs().rename(await join(imgAbs, item.sub, item.name), await join(targetDir, item.name))
let target = await join(targetDir, item.name)
try {
await fs().rename(await join(imgAbs, item.sub, item.name), target)
} catch (eR) {
// 同名已在 trash 里(上次清理过):加时间戳,别让整条静默失败
const dot = String(item.name).lastIndexOf('.')
const sfx = '-' + Date.now()
const alt = dot > 0 ? String(item.name).slice(0, dot) + sfx + String(item.name).slice(dot) : String(item.name) + sfx
target = await join(targetDir, alt)
await fs().rename(await join(imgAbs, item.sub, item.name), target)
}
moved++
} catch (e) { /* 单条失败忽略 */ }
}
return { ok: true, orphans: orphans.length, moved: moved, dryRun: dryRun, dangling: dangling, keptByCanvas: keptByCanvas }
return { ok: true, orphans: orphans.length, moved: moved, dryRun: dryRun, dangling: dangling, keptByCanvas: keptByCanvas, thumbCaches: thumbCaches }
} catch (e) { return { ok: false, error: String((e && e.message) || e) } }
}
@@ -1606,7 +1659,7 @@
enabled, ready: init, flush,
// 供其它模块把诊断写进 _boot.log(v3.26.109)
logLine: (m) => blog(m),
runtime, pickDir, switchTo, migrateTo, deleteImageBytes, deleteGalleryBytesFor, galleryAudit, gcImages, rotateTrash, galleryThumb, galleryThumbUrl, galleryThumbOfEntry, readDisplayThumb, readDisplayThumbUrl, makeDisplayThumb, makeDisplayThumbFromPath, resizeDataUrl, decodeStats, thumbStats, writeDisplayThumb, writeDisplayThumbBlob, pruneThumbs, cleanupLegacy, maintain,
runtime, pickDir, switchTo, migrateTo, deleteImageBytes, deleteGalleryBytesFor, galleryAudit, gcImages, rotateTrash, galleryThumb, galleryThumbUrl, galleryThumbOfEntry, galleryOriginalOf, galleryOriginalBlob, readDisplayThumb, readDisplayThumbUrl, makeDisplayThumb, makeDisplayThumbFromPath, resizeDataUrl, decodeStats, thumbStats, writeDisplayThumb, writeDisplayThumbBlob, pruneThumbs, cleanupLegacy, maintain,
plugins: { manifest: pluginManifest, read: pluginRead, write: pluginWrite, remove: pluginRemove, dir: pluginDir, listLocal: pluginListLocal, listDirs: pluginListDirs, readFile: pluginReadFile, writeFile: pluginWriteFile, writeBinary: pluginWriteBinary, mkdir: pluginMkdir, removeDir: pluginRemoveDir, renameDir: pluginRenameDir, existsDir: pluginExistsDir },
pluginData: { read: pluginDataRead, write: pluginDataWrite, remove: pluginDataRemove, list: pluginDataList },
pluginFiles: { put: pluginFilePut, get: pluginFileGet, list: pluginFileList, remove: pluginFileRemove, stat: pluginFileStat, dir: pluginFilesDir, readBytes: pluginFileReadBytes, listAll: pluginFilesListAll },
+2 -1
View File
@@ -29,7 +29,8 @@
const added = []
for (const item of items || []) if (item && item.url) {
const name = item.name || ('gen_' + Date.now() + '_' + Math.floor(Math.random() * 1e6) + '.png')
index.push({ name, url: item.url, size: item.size || 0, mtime: item.mtime || Date.now(), w: item.width || item.w || 0, h: item.height || item.h || 0, label: item.label || '' })
// 2026-12-03:保留 orig 状态 —— 之前重建行时丢掉它,行若在 markOk 之后创建就永远显示「未落地」。
index.push({ name, url: item.url, size: item.size || 0, mtime: item.mtime || Date.now(), w: item.width || item.w || 0, h: item.height || item.h || 0, label: item.label || '', orig: item.orig || 'pending' })
added.push(name)
}
const opts = options || {}
-1
View File
@@ -139,6 +139,5 @@
const runtimeInstance = createStorageRuntime(defaultContract)
const runtimeCompat = function (contract) { return createStorageRuntime(contract || defaultContract) }
Object.assign(runtimeCompat, runtimeInstance)
global.IWBStorageRuntimeFactory = createStorageRuntime
global.IWBStorageRuntime = runtimeCompat
})(typeof window !== 'undefined' ? window : globalThis)
+18 -2
View File
@@ -20,7 +20,7 @@
const useCallback = React.useCallback
const useLayoutEffect = React.useLayoutEffect
let ICONS, IDB, computeEdgePath, copyImageToClipboard, downloadUrl, nodeTypeColor, nodeTypeH, nodeWidth, wBlobFromDataUrl, wRegisterBlobUrl
let ICONS, IDB, computeEdgePath, copyImageToClipboard, downloadUrl, wOutNameOf, nodeTypeColor, nodeTypeH, nodeWidth, wBlobFromDataUrl, wRegisterBlobUrl
function inject (d) {
if (!d) throw new Error('[iwb][IWBUICanvasView] 依赖未注入')
@@ -29,6 +29,7 @@
computeEdgePath = d.computeEdgePath
copyImageToClipboard = d.copyImageToClipboard
downloadUrl = d.downloadUrl
wOutNameOf = d.wOutNameOf
nodeTypeColor = d.nodeTypeColor
nodeTypeH = d.nodeTypeH
nodeWidth = d.nodeWidth
@@ -339,6 +340,15 @@ function ImagePreview(props) {
if (!e || typeof e === 'string' || !e.__gallery) return Promise.resolve(placeholderOf(e))
const key = 'orig:' + entryKeyOf(e)
const hit = cachedOf(key); if (hit) return Promise.resolve(hit)
// 2026-12-03(用户裁定「本地优先」):没有 origIdb 的老记录,直接按行名读 images/gallery 原图(原生解码),
// 不再退回 320 缩略图、也不直连远程;返回的是宿主持有的 objectURL,不进本组件的回收表。
const SF = (typeof window !== 'undefined') ? window.IWBStorageFile : null
if (!e.origIdb && e.name && SF && typeof SF.galleryOriginalOf === 'function') {
return Promise.resolve(SF.galleryOriginalOf({ name: e.name, origIdb: e.origIdb }, 2048))
.then((g) => (g && g.url) || '')
.catch(() => '')
.then((u) => u || urlOfFallback(e.url || placeholderOf(e), key, 'orig'))
}
const idbKey = e.origIdb || e.idb
if (!idbKey) return urlOfFallback(e.url || placeholderOf(e), key, 'orig')
const p = (typeof IDB.getBlob === 'function') ? IDB.getBlob(idbKey) : IDB.get(idbKey)
@@ -363,6 +373,10 @@ function ImagePreview(props) {
return wBlobFromDataUrl(str)
}
const fallbackStr = e.url || placeholderOf(e)
const SF2 = (typeof window !== 'undefined') ? window.IWBStorageFile : null
if (!e.origIdb && e.name && SF2 && typeof SF2.galleryOriginalBlob === 'function') {
return Promise.resolve(SF2.galleryOriginalBlob({ name: e.name, origIdb: e.origIdb })).then((b) => b || null).catch(() => null)
}
const idbKey = e.origIdb || e.idb
if (!idbKey) return Promise.resolve(asBlobOf(fallbackStr)).then((b) => ((b && b.size) ? b : null)).catch(() => null)
const p = (typeof IDB.getBlob === 'function') ? IDB.getBlob(idbKey) : IDB.get(idbKey)
@@ -533,7 +547,9 @@ function ImagePreview(props) {
// downloadUrl 只吃 URL:把字节登记成**可取回**的 objectURL(wBlobRefGet 能反查),否则下载链路取不到 Blob
const blob = await loadOriginalBlob(entry).catch(() => null)
const blobUrl = (blob && typeof wRegisterBlobUrl === 'function') ? wRegisterBlobUrl(blob) : ''
downloadUrl(blobUrl || src, 'image.png')
// 2026-12-03:预览下载同样走图库行名(图库条目直接用行名,其余按 url 查),未落地才回退 image.png
const dlName = (entry && entry.__gallery && entry.name) ? String(entry.name) : ((typeof wOutNameOf === 'function' && wOutNameOf(entry && entry.url)) || 'image.png')
downloadUrl(blobUrl || src, dlName)
},
}, I('download'), ' 下载'),
),
+14 -8
View File
@@ -5,8 +5,11 @@
const el = React.createElement
function ResultImg(props) {
const useState = React.useState
const useEffect = React.useEffect
const [hover, setHover] = useState(false)
const item = props.item || {}
// 2026-12-02:落地状态展示改在输出节点体(ui-node-bodies);本组件全仓无调用点,保持纯展示
const doCopyRef = () => { props.onCopyRef && props.onCopyRef(item.url) }
const doCopyLink = () => {
// 统一走 IWBClipboardCopy(2026-11-24)
@@ -25,27 +28,30 @@
) : null,
)
}
// 共享「下载浮层」:底部渐变 + 下载(可选复制),hover/focus 才出现。
// 图库插件是原生 DOM,用同一组 token 在插件 CSS 里复刻;宿主这里只需一个 React 组件。
// pointer-events:浮层条本身不吃事件(否则会挡住图片点击/双击),只有悬停后按钮才可点。
// 共享「下载浮层」:右下角圆形图标(可选复制),hover/focus 才出现。
// 2026-12-03(用户裁定):只改输出节点这一处呈现 —— 底部横条会压住矮图的中心,改成只占右下角。
// 约束(上一次改造踩过的坑):① 容器 pointer-events:none、只有按钮 auto;② 不改任何类名之外的 DOM 结构;
// ③ 不动 z-index 层级表、不动 token 体系;旧的 .iwb-dl-bar 样式保留在 CSS 里可随时回退。
function ResultDownloadOverlay (props) {
const p = props || {}
const stopDown = (e) => { try { e.stopPropagation() } catch (err) { /* ignore */ } }
return el('div', { className: 'iwb-dl-ov' },
p.children,
el('div', { className: 'iwb-dl-bar' },
el('div', { className: 'iwb-dl-corner' },
p.onCopyRef ? el('button', {
className: 'iwb-dl-btn iwb-dl-btn-ghost',
className: 'iwb-dl-round',
title: p.copyTitle || '插入为参考图节点',
'aria-label': p.copyLabel || '复制',
onPointerDown: stopDown,
onClick: (e) => { e.stopPropagation(); p.onCopyRef() },
}, p.copyIcon || null, el('span', { className: 'iwb-dl-txt' }, p.copyLabel || '复制')) : null,
}, p.copyIcon || '⧉') : null,
el('button', {
className: 'iwb-dl-btn',
className: 'iwb-dl-round iwb-dl-round-primary',
title: p.downloadTitle || '下载原图',
'aria-label': p.label || '下载',
onPointerDown: stopDown,
onClick: (e) => { e.stopPropagation(); if (p.onDownload) p.onDownload() },
}, p.icon || null, el('span', { className: 'iwb-dl-txt' }, p.label || '下载')),
}, p.icon || '↓'),
),
)
}
+4
View File
@@ -77,6 +77,9 @@
const onHome = props.onHome
const onCanvas = props.onCanvas
const onPlugins = props.onPlugins
const pages = Array.isArray(props.pages) ? props.pages : []
const activePage = String(props.activePage || '')
const onPage = props.onPage
const onHelp = props.onHelp
const onHotkeys = props.onHotkeys
const onSkin = props.onSkin
@@ -195,6 +198,7 @@
item('home', 'home', '首页(画布库)', view === 'home', onHome),
item('canvas', 'layer', '列表(画布工作区)', view === 'canvas', onCanvas),
item('plugins', 'box', '插件', view === 'plugins', onPlugins),
pages.map((p) => item('pg:' + p.pluginId + ':' + p.id, p.icon || 'queue', p.title, activePage === (p.pluginId + ':' + p.id), () => { if (typeof onPage === 'function') onPage(p.pluginId, p.id) })),
),
el('div', { className: 'iwb-navrail-spacer' }),
el('div', { className: 'iwb-navrail-group' },
+142 -7
View File
@@ -11,11 +11,15 @@
// · ctx = { onUpdate, busy, progress, h, stop, refMini },由调用方 renderBodyInner 组装。
// ── 注入依赖(app.js 在首次渲染时调用 inject 注入)─────────────────────────
let I, LocalTextField, autoGrow, React, ReactDOM, combineSourcePairs, downloadUrl, wResolveOutSrc, isImageProducer, nodePreviewRefsV2, nodeInheritOf, orderedUniqueRefNodes, outProgUI, outThumbCache, uploadRefToImageHost, wDisplayThumbOf, wImgSrcForNode, wImportImage, wPreviewUrlOf, wRawCfg, wResolveImg, wThumbSrc, el, wPluginNodeVariants, wPluginVariantMeta, isBatchSrc, batchSrcText, compareCanvasTextOrder, GenParams, RATIOS, RES_KEYS, RES_MAP, cachedGenerationTasks, classifyErr, fmtDur, presetDisplayName, ratioOfSize, resOfSize, taskStallEndMs, wDedupeTaskIds
let ingestView, I, LocalTextField, autoGrow, React, ReactDOM, combineSourcePairs, downloadUrl, wResolveOutSrc, wOutNameOf, wPreviewEntryOf, isImageProducer, nodePreviewRefsV2, nodeInheritOf, orderedUniqueRefNodes, outProgUI, outThumbCache, uploadRefToImageHost, wDisplayThumbOf, wImgSrcForNode, wImportImage, wPreviewUrlOf, wRawCfg, wResolveImg, wThumbSrc, el, wPluginNodeVariants, wPluginVariantMeta, isBatchSrc, batchSrcText, compareCanvasTextOrder, GenParams, RATIOS, RES_KEYS, RES_MAP, cachedGenerationTasks, classifyErr, fmtDur, presetDisplayName, ratioOfSize, resOfSize, taskStallEndMs, wDedupeTaskIds, wThumbBump
// 2026-12-03:输出格「NEW」标记 —— 只认本次启动之后生成的图;已确认的 key 记在内存里,不写画布存档。
const OUT_NEW_SINCE = Date.now()
const outNewSeen = new Set()
function inject(d) {
const D = d || {}
I = D.I
wPluginNodeVariants = D.wPluginNodeVariants
ingestView = D.ingestView // 2026-12-02:落地状态视图由宿主注入(不直接读 window 全局)
wPluginVariantMeta = D.wPluginVariantMeta
isBatchSrc = D.isBatchSrc
batchSrcText = D.batchSrcText
@@ -25,6 +29,8 @@
combineSourcePairs = D.combineSourcePairs
downloadUrl = D.downloadUrl
wResolveOutSrc = D.wResolveOutputSrc
wOutNameOf = D.wOutNameOf
wPreviewEntryOf = D.wPreviewEntryOf
isImageProducer = D.isImageProducer
nodePreviewRefsV2 = D.nodePreviewRefsV2
nodeInheritOf = D.nodeInheritOf
@@ -54,6 +60,7 @@
resOfSize = D.resOfSize
taskStallEndMs = D.taskStallEndMs
wDedupeTaskIds = D.wDedupeTaskIds
wThumbBump = D.wThumbBump
}
@@ -717,7 +724,17 @@
return el('div', { className: 'iwb-node-body iwb-ref-body' },
hasImg
? el('div', { className: 'iwb-ref-show' },
el('img', { className: 'iwb-ref-single', decoding: 'async', fetchPriority: 'low', src: wPreviewUrlOf((typeof wImgSrcForNode === 'function' ? wImgSrcForNode : wDisplayThumbOf)(wThumbSrc(src), Math.min(320, (props.node && props.node.w) || 280))), alt: '图片', draggable: false, onLoad: (e) => { fitRefNodeOnce(e, props.node, onUpdate) }, onError: (e) => {
el('img', { className: 'iwb-ref-single', decoding: 'async', fetchPriority: 'low', src: wPreviewUrlOf((typeof wImgSrcForNode === 'function' ? wImgSrcForNode : wDisplayThumbOf)(wThumbSrc(src), Math.min(320, (props.node && props.node.w) || 280))), alt: '图片', draggable: false, onLoad: (e) => {
// v3.26.179:图片恢复可读时清掉「源已失效」标记 —— 之前 is-broken 是命令式加的,
// 换图后没有任何地方移除,遮罩会一直盖在新图上。
try {
const img = e.currentTarget
if (img && img.dataset) img.dataset.fb = ''
const host = img && img.closest ? img.closest('.iwb-ref-show') : null
if (host) host.classList.remove('is-broken')
} catch (err0) { /* ignore */ }
fitRefNodeOnce(e, props.node, onUpdate)
}, onError: (e) => {
// 第一次失败先退回原图;第二次仍失败 → 标记容器,换成「源已失效 · 双击重新导入」占位
// (用户 2026-11-29:破图图标会被误当成渲染 bug,必须明确告知是图片源丢了)
try {
@@ -845,7 +862,18 @@
for (const e of grp.entries) { const prev = keep.get(e.vi); if (!prev || e.at >= prev.at) keep.set(e.vi, e) }
const items = []
for (const e of Array.from(keep.values()).sort((a, b) => (a.vi - b.vi) || (a.at - b.at))) {
for (const it of (Array.isArray(e.en.items) ? e.en.items : [])) if (it && it.ok && it.url) items.push(it)
// 2026-12-02(方案 A):新图下载期间 entry.pending 存着上一张 —— 逐位配对成 _prev,
// 渲染时按「新图本地字节是否就绪」决定显示新图还是旧图(见 renderOutBody)。
const prevItems = (e.en.pending && Array.isArray(e.en.pending.items)) ? e.en.pending.items.filter((it) => it && it.ok && it.url) : []
const its = (Array.isArray(e.en.items) ? e.en.items : []).filter((it) => it && it.ok && it.url)
const genAt = numOr(e.en.at, 0)
for (let k = 0; k < its.length; k++) {
const prev = prevItems[k] || null
// 始终复制:_genAt/_genKey 只给渲染用,绝不能挂到画布存档的 item 上。
const extra = { _genAt: genAt, _genKey: String(grp.promptId) + '|' + String(e.vi) + '|' + String(genAt) }
if (prev) extra._prev = prev
items.push(Object.assign({}, its[k], extra))
}
}
return { genId: grp.genId, promptId: grp.promptId, taskTitle: grp.taskTitle, taskTitleNow: grp.taskTitleNow, label: grp.label, at: grp.at, known: grp.known, items }
})
@@ -860,9 +888,29 @@
.filter((n) => isImageProducer(n) && !(n.data && n.data.enabled === false))
// 顺序以任务卡为准:metaOf 读的正是任务卡渲染用的同一份任务列表(同一个缓存),顺序必然一致
const merged = outGroupsOf(srcGens, (g) => cachedGenerationTasks(g, props.nodes || [], props.edges || []).map((t) => ({ id: t.id, title: t.title || '' })))
// 2026-12-02(方案 A):新图本地字节就绪前先显示上一张(_prev),就绪后再换成新图。
const ingView0 = (typeof ingestView === 'function') ? ingestView() : null
const localReady = (r) => {
if (!r) return false
if (r.idb && r.data) return true
if (r.url && outThumbCache.get(r.url)) return true
const v = (ingView0 && typeof ingView0.get === 'function') ? ingView0.get(r.url) : null
return !!(v && v.localUrl)
}
for (const m of merged) m.items = m.items.map((r) => (r && r._prev && !localReady(r)) ? Object.assign({}, r._prev, { _awaitUrl: r.url }) : r)
// 2026-12-03:NEW 标记自动消失时长(秒,0=不自动消失);设置 → 生成 →「新图标记」。
const newBadgeMs = (() => {
try {
const c = (typeof wRawCfg === 'function') ? wRawCfg() : null
const sec = Number(c && c.canvas && c.canvas.newBadgeSec)
return Number.isFinite(sec) ? Math.max(0, Math.min(3600, sec)) * 1000 : 120000
} catch (e) { return 120000 }
})()
const allOk = []
for (const m of merged) for (const r of m.items) allOk.push(r)
const openPreviewAt = (i) => { const u = allOk[i] && allOk[i].url; if (u) props.onPreview && props.onPreview(u, allOk.map((x) => x.url), i) }
// 2026-12-03(用户):预览条目与图库同口径 —— 有图库行就给 __gallery(本地原图优先),不再一律喂远程 url。
const previewEntryOf = (u) => (typeof wPreviewEntryOf === 'function' ? wPreviewEntryOf(u) : u)
const openPreviewAt = (i) => { const u = allOk[i] && allOk[i].url; if (u) props.onPreview && props.onPreview(previewEntryOf(u), allOk.map((x) => previewEntryOf(x.url)), i) }
// 生图节点中的 result 项不一定携带与自身匹配的缩略图;只有明确带 idb 引用时才使用 data,避免多张图共享旧缩略图。
const thumbOf = (r) => (r && r.idb && r.data) ? r.data : ((r && r.url && outThumbCache.get(r.url)) || (r && r.url))
let imgIndex = 0
@@ -875,16 +923,103 @@
let src = r.url
// v3.25.18:从资料目录的本地归档取图(原图优先),远端 URL 只作兜底
try { if (wResolveOutSrc) src = (await wResolveOutSrc(r, true)) || r.url } catch (e) { /* 回退远端 */ }
downloadUrl(src, 'image.png')
// 2026-12-03:文件名统一用图库行名(未落地才回退 image.png),与图库下载一致
downloadUrl(src, (typeof wOutNameOf === 'function' && wOutNameOf(r.url)) || 'image.png')
}
const imgEl = el('img', { key: 'out-img-' + cur + '-' + String(r.url || '').slice(-48), className: 'iwb-out-cell-img', decoding: 'async', fetchPriority: 'low', referrerPolicy: 'no-referrer', src: wPreviewUrlOf((typeof wImgSrcForNode === 'function' ? wImgSrcForNode : wDisplayThumbOf)(thumbOf(r), Math.max(120, Math.min(360, (node && node.w ? node.w - 40 : 240))))), draggable: true, style: { aspectRatio: (r.width && r.height) ? String(r.width) + ' / ' + String(r.height) : undefined }, title: r.idb && r.data ? '单击选中 · 双击查看原图 · 拖到画布作参考图' : '单击选中 · 双击放大(可左右切换)· 拖到画布作参考图', onError: (e) => { if (e.currentTarget && e.currentTarget.src !== r.url) e.currentTarget.src = r.url }, onPointerDown: (e) => { e.stopPropagation(); props.onSelect && props.onSelect(node.id) }, onDragStart: (e) => { try { const u = r.url || ''; e.dataTransfer.setData('application/x-iwb-output-ref', u); e.dataTransfer.setData('text/plain', u); e.dataTransfer.effectAllowed = 'copy' } catch (err) { /* 浏览器拒写自定义 MIME 时仍保留 text/plain */ } }, onDoubleClick: (e) => { e.stopPropagation(); openPreviewAt(cur) } })
// 生成中(2026-12-02,用户裁定「方案 1」):某一轮还在跑时,旧图压暗 + 角标「生成中」,
// 但不改 data.result —— 失败时旧图原样保留,不会出现「图没了」。
// 2026-12-02(方案 A):显示项可能是「上一张」(_prev),而下载状态属于「等待中的新 url」。
const awaitUrl = r._awaitUrl || r.url
const ingView = (typeof ingestView === 'function') ? ingestView() : null
const ingSt = (ingView && typeof ingView.get === 'function') ? ingView.get(awaitUrl) : null
// 2026-12-02(方案 A):这一格还没有任何本地源时,垫一层骨架 + 「下载中…」文字,
// 避免大图区域纯空白(有缩略图时 LOD 已经会显示模糊可辨的画面,不需要这层)。
// 2026-12-02 修 TDZ:_localSrc 必须先声明再用(上一版 phEl 读它时还没初始化,五态全崩)
const _localSrc = (r && r.idb && r.data) ? r.data : ((r && r.url && outThumbCache.get(r.url)) || null)
// 2026-12-02:骨架只在「连远程 url 都没有」时出现。有 url 就让 <img> 直接渐进渲染(203 的观感),
// 不要用骨架盖住一张正在下载的图 —— 慢 CDN 上那会变成长时间空白。
// 2026-12-02:骨架改为「垫在图片下面」的底层(不再只在没有 url 时出现)——
// 图片未绘制前看到的是骨架,绘制完成(.is-loaded-cell)后骨架自动被隐藏,不会遮挡渐进渲染。
// 显示上一张时绝不盖骨架(骨架是不透明垫层,会遮住旧图);骨架只服务「无任何可显示字节」的新格。
const phEl = (!r._awaitUrl && !_localSrc && !(ingSt && ingSt.localUrl))
? el('div', { className: 'iwb-out-cell-ph', key: 'ph' }, el('span', { className: 'iwb-out-cell-ph-txt' }, '下载中…'))
: null
const imgEl = el('img', { key: 'out-img-' + cur + '-' + String(r.url || '').slice(-48), className: 'iwb-out-cell-img', decoding: 'async', fetchPriority: 'low', referrerPolicy: 'no-referrer', onLoad: (e) => {
// 2026-12-02:img 被包在下载浮层(.iwb-dl-ov)里,parentElement 不是单元格 —— 必须向上找 .iwb-out-cell
try {
const im = e && e.currentTarget
if (!im) return
im.classList.add('is-loaded')
// 2026-12-02:加载成功后必须撤销失败态 —— 首帧本地 blob 失效会先打 is-broken,
// 回退远程成功后若不撤销,「加载失败」与 25% 透明度会一直盖在正常图上。
im.classList.remove('is-broken')
const cell = (im.closest && im.closest('.iwb-out-cell')) || im.parentElement
// 显示的是上一张(新图还在下)时不收角标,否则「下载中」会被旧图的 onLoad 立刻吃掉。
if (cell && !r._awaitUrl) { cell.classList.add('is-loaded-cell'); cell.classList.remove('is-broken-cell') }
} catch (e0) { /* ignore */ }
}, src: (function () {
var need = Math.max(120, Math.min(360, (node && node.w ? node.w - 40 : 240)))
var pick = (typeof wImgSrcForNode === 'function') ? wImgSrcForNode : wDisplayThumbOf
// 本地源(已落库/已入缩略图缓存)才走 LOD —— 避免 thumbOf 回落到远程后又整幅解码原图
var localSrc = (r && r.idb && r.data) ? r.data : ((r && r.url && outThumbCache.get(r.url)) || null)
if (localSrc) { try { var u = wPreviewUrlOf(pick(localSrc, need)); if (u) return u } catch (eL) { /* ignore */ } }
if (ingSt && ingSt.localUrl) return ingSt.localUrl // 缩略图还没好:先用本地原图,别等远程
if (r._awaitUrl) return r.url
// 2026-12-03(用户):只有「没有落地记录」的旧数据才允许直连远程。
// 已 ready 但本地 URL 还没解析出来的那一小段时间里空着等本地(缩略图已在上面返回),
// 不要退回远程 —— 否则新图会「从上往下」渐进重下一遍,看起来像没取原图。
if (!ingSt) return r.url
return undefined // 未落地/本地 URL 待解析:不设 src(React 省略属性),避免空 src 触发伪请求
})(), draggable: true, style: { aspectRatio: (r.width && r.height) ? String(r.width) + ' / ' + String(r.height) : undefined }, title: r.idb && r.data ? '单击选中 · 双击查看原图 · 拖到画布作参考图' : '单击选中 · 双击放大(可左右切换)· 拖到画布作参考图', onError: (e) => {
// 2026-12-02:多级回退 —— 本地 blob 失效 → 远程 url;远程也失败才标 is-broken
try {
const im = e && e.currentTarget
if (!im) return
// 空 src(未落地/等待本地字节)不算失败,别把它当成「本地失效」去回退远程
if (!im.getAttribute || !im.getAttribute('src')) return
if (im.dataset && im.dataset.fb !== 'remote' && r && r.url) { im.dataset.fb = 'remote'; im.src = r.url; return }
if (im.dataset) im.dataset.fb = 'broken'
im.classList.add('is-broken')
const cellB = (im.closest && im.closest('.iwb-out-cell')) || im.parentElement
if (cellB && !r._awaitUrl) cellB.classList.add('is-broken-cell')
} catch (e1) { /* ignore */ }
}, onPointerDown: (e) => { ackNew(); e.stopPropagation(); props.onSelect && props.onSelect(node.id) }, onDragStart: (e) => { try { const u = r.url || ''; e.dataTransfer.setData('application/x-iwb-output-ref', u); e.dataTransfer.setData('text/plain', u); e.dataTransfer.effectAllowed = 'copy' } catch (err) { /* 浏览器拒写自定义 MIME 时仍保留 text/plain */ } }, onDoubleClick: (e) => { ackNew(); e.stopPropagation(); openPreviewAt(cur) } })
// 下载浮层:与图库共用同一组 hover token;组件缺失时退回旧的双小按钮(单文件/旧加载顺序)
const DlOv = (typeof global !== 'undefined' && global.IWBResultDownloadOverlay) || null
const actions = DlOv ? null : el('div', { className: 'iwb-out-cell-actions' },
el('button', { className: 'iwb-btn iwb-btn-sm', title: '下载', onClick: doDownload, onPointerDown: stop }, I('download')),
)
return el('div', { key: String(r.url || '') + '|' + ri, className: 'iwb-out-cell' },
// 2026-12-02(用户要求恢复):角标不再只依赖视图命中 —— 只要这一格还没有本地源、
// 而结果又是远程 url,就说明还在从网络取图,直接标「下载中」,保证一定有可见反馈。
const _remoteOnly = !_localSrc && !(ingSt && ingSt.localUrl) && /^https?:/i.test(String((r && r.url) || ''))
// 2026-12-02 修:先取安全状态再判 —— 之前或运算与三元混用,条件为真时仍解引用 ingSt.status,
// 视图没命中(ingSt=null)会抛 TypeError。优先级:未落地 > 排队中/下载中。
// 2026-12-02(第四次收敛):角标**默认渲染**,靠 CSS 在图片 onLoad(.is-loaded-cell)后收起。
// 之前按「有没有本地源」决定是否渲染 —— 本地缓存失效但图片还在等远程时就没有任何提示(白板)。
// NEW:本次启动后生成、新图已就绪(不是旧图占位)、未确认、且未超过显示时长。
const ingFailed = !!(ingSt && ingSt.status === 'failed')
const isNew = !!(r && r._genAt && r._genAt > OUT_NEW_SINCE && !outNewSeen.has(r._genKey) && !r._awaitUrl && !ingFailed && (newBadgeMs === 0 || (Date.now() - r._genAt) < newBadgeMs))
const ackNew = () => {
try {
if (!r || !r._genKey) return
outNewSeen.add(r._genKey)
if (typeof wThumbBump === 'function') wThumbBump()
} catch (e) { /* ignore */ }
}
const newBadge = (isNew && r._genKey) ? el('span', { className: 'iwb-out-cell-new', key: 'new', style: newBadgeMs > 0 ? { animationDuration: (newBadgeMs / 1000) + 's' } : { animation: 'none' } }, 'NEW') : null
const ingStatus = ingSt ? ingSt.status : null
const ingPct = (ingSt && ingSt.progress) ? Math.round(ingSt.progress * 100) : 0
const retryIng = (e) => { try { e.stopPropagation(); if (window.__iwbIngest && ingSt) window.__iwbIngest.retry(ingSt.id) } catch (e1) { /* ignore */ } }
const ingBadge = (ingStatus === 'failed')
? el('span', { className: 'iwb-out-cell-flag iwb-out-cell-flag-err', key: 'ing-flag', title: '点击重试下载', onClick: retryIng }, '未落地')
: el('span', { className: 'iwb-out-cell-flag', key: 'ing-flag' }, ingStatus === 'queued' ? '排队中' : (ingPct ? '下载中 ' + ingPct + '%' : '下载中'))
return el('div', { key: String(r.url || '') + '|' + String(awaitUrl) + '|' + ri, className: 'iwb-out-cell' },
phEl,
el('span', { className: 'iwb-out-cell-err', key: 'err' }, '加载失败'),
ingBadge,
DlOv ? el(DlOv, { key: 'ov', onDownload: doDownload, icon: I('download'), label: '下载' }, imgEl) : imgEl,
// NEW 放在图片浮层之后:同为 positioned 元素时靠 DOM 顺序压在上面,不必新增 z-index 声明。
newBadge,
el('div', { className: 'iwb-out-cell-meta' }, (r.width || '?') + '×' + (r.height || '?')),
actions,
)
+21 -4
View File
@@ -631,9 +631,10 @@ function GSetGroup (props) {
const rDry = await F.gcImages({ dryRun: true })
if (!rDry.ok) { setNote('检查失败:' + rDry.error); return }
if (!rDry.orphans) { setNote('没有未引用的图片'); return }
const lines = ['发现 ' + rDry.orphans + ' 个文件没有被画布/图库引用。']
if (rDry.keptByCanvas) lines.push('其中 ' + rDry.keptByCanvas + ' 张虽然登记表里没有,但画布仍在引用 → 会自动保留。')
if (rDry.dangling) lines.push('另有 ' + rDry.dangling + ' 处画布引用已经找不到图片(之前丢的,本次不影响它们)。')
const lines = ['发现 ' + rDry.orphans + ' 个图片文件没有被画布/图库引用。']
if (rDry.thumbCaches) lines.push('另有 ' + rDry.thumbCaches + ' 个缩略图缓存(可再生,本次不动)。')
if (rDry.keptByCanvas) lines.push(rDry.keptByCanvas + ' 个文件画布/图库同时在用 → 自动保留。')
if (rDry.dangling) lines.push('另有 ' + rDry.dangling + ' 处画布引用的图片已经缺失(登记表里没有,无法恢复,本次不受影响)。')
lines.push('移动到 trash/(不直接删除,可在回收站找回)?')
if (!(await window.IWBUIConfirm.askOrNative(lines.join('\n'), { title: '清理未引用图片', okText: '移动' }))) return
const rGo = await F.gcImages({ dryRun: false })
@@ -733,6 +734,22 @@ function GSetGroup (props) {
el('div', null, '可在不误触的前提下提前结束该任务,不影响同批其他任务。'),
),
),
el('div', { className: 'iwb-gset-row' },
el('span', { className: 'iwb-gset-row-label' }, '新图标记'),
el('div', { className: 'iwb-gset-row-ctl' },
el('input', { className: 'iwb-input iwb-num', type: 'number', min: 0, max: 3600, step: 10, value: Number.isFinite(Number(draft.canvas.newBadgeSec)) ? Number(draft.canvas.newBadgeSec) : 120, onChange: (e) => setDraft((d) => ({ ...d, canvas: { ...d.canvas, newBadgeSec: Math.max(0, Math.min(3600, Number(e.target.value) || 0)) } })) }),
el('span', { className: 'iwb-hint' }, '秒'),
),
),
el('div', { className: 'iwb-gset-hint' }, '输出节点新图左上角「NEW」的显示时长;0 表示不自动消失(点一下图才消失)。'),
el('div', { className: 'iwb-gset-row' },
el('span', { className: 'iwb-gset-row-label' }, '同时下载'),
el('div', { className: 'iwb-gset-row-ctl' },
el('input', { className: 'iwb-input iwb-num', type: 'number', min: 1, max: 64, step: 1, value: Number(draft.canvas.downloadConcurrency) || 30, onChange: (e) => setDraft((d) => ({ ...d, canvas: { ...d.canvas, downloadConcurrency: Math.max(1, Math.min(64, Number(e.target.value) || 30)) } })) }),
el('span', { className: 'iwb-hint' }, '张(1–64,默认 30)'),
),
),
el('div', { className: 'iwb-gset-hint' }, '出图后同时下载到本地的并发数;调大更快,但更吃内存。下载走系统网络栈,不受图床跨域限制。'),
el('div', { className: 'iwb-gset-row' },
el('span', { className: 'iwb-gset-row-label' }, '低缩放简化'),
el('div', { className: 'iwb-gset-row-ctl' },
@@ -1433,7 +1450,7 @@ function GSetGroup (props) {
security: { password: draft.sec.clear ? '__CLEAR__' : ((draft.sec.password && draft.sec.password.trim()) || (draft.sec.hasPassword ? '__KEEP__' : '')) },
// autoSaveImages 已废弃(v3.25.33):保留归一化只为老配置兼容,不再驱动任何下载;
// 「出图自动保存」见 设置 → 图片导出目录 → 自动下载。
canvas: { hotkeys: Object.assign({}, HOTKEY_DEFAULTS, draft.canvas.hotkeys || {}), appearance: (function () { const A = (typeof window !== 'undefined') ? window.IWBUIApearance : null; return A ? A.normalize(draft) : ((draft.canvas && draft.canvas.appearance) || {}) })(), sizePresets: Array.isArray(draft.canvas.sizePresets) && draft.canvas.sizePresets.length ? draft.canvas.sizePresets : RATIOS, generationConcurrency: Math.max(GEN_CONCURRENCY_MIN, Math.min(GEN_CONCURRENCY_MAX, Number(draft.canvas.generationConcurrency) || GEN_CONCURRENCY_DEFAULT)), taskStallEndMs: Math.max(TASK_STALL_END_MIN, Math.min(TASK_STALL_END_MAX, Number(draft.canvas.taskStallEndMs) || 300000)), autoSaveImages: draft.canvas.autoSaveImages !== false, backupOriginals: true, lodLowZoom: draft.canvas.lodLowZoom !== false },
canvas: { hotkeys: Object.assign({}, HOTKEY_DEFAULTS, draft.canvas.hotkeys || {}), appearance: (function () { const A = (typeof window !== 'undefined') ? window.IWBUIApearance : null; return A ? A.normalize(draft) : ((draft.canvas && draft.canvas.appearance) || {}) })(), sizePresets: Array.isArray(draft.canvas.sizePresets) && draft.canvas.sizePresets.length ? draft.canvas.sizePresets : RATIOS, generationConcurrency: Math.max(GEN_CONCURRENCY_MIN, Math.min(GEN_CONCURRENCY_MAX, Number(draft.canvas.generationConcurrency) || GEN_CONCURRENCY_DEFAULT)), taskStallEndMs: Math.max(TASK_STALL_END_MIN, Math.min(TASK_STALL_END_MAX, Number(draft.canvas.taskStallEndMs) || 300000)), autoSaveImages: draft.canvas.autoSaveImages !== false, backupOriginals: true, lodLowZoom: draft.canvas.lodLowZoom !== false, newBadgeSec: Number.isFinite(Number(draft.canvas.newBadgeSec)) ? Math.max(0, Math.min(3600, Number(draft.canvas.newBadgeSec))) : 120, downloadConcurrency: Math.max(1, Math.min(64, Number(draft.canvas.downloadConcurrency) || 30)) },
webhook: { enabled: !!draft.webhook.enabled, url: (draft.webhook.url || '').trim() },
})
setSaving(false)
+12 -3
View File
@@ -20,7 +20,10 @@
function ensureDetail (ctx) {
const now = Date.now()
if (_detail.busy) return _detail.data
if (_detail.data && now - _detail.at < 8000) return _detail.data
// v3.26.170:8s → 60s。原来面板每 8 秒自动重扫(进程树 + 500+ 缩略图文件 + 插件目录),
// 每扫一次就 setDiagRev 重渲染一次 —— 面板开着时表现为持续 20% CPU、堆锯齿、磁盘 0.1MB/s。
// 现在只在第一次打开时取一次,之后靠「刷新」按钮手动更新。
if (_detail.data && now - _detail.at < 60000) return _detail.data
_detail.busy = true
Promise.resolve(typeof ctx.onDiagDetail === 'function' ? ctx.onDiagDetail() : null).then((d) => {
_detail = { at: Date.now(), data: d, busy: false }
@@ -115,14 +118,20 @@
el('div', { className: 'iwb-section-title' }, '运行诊断'),
el('div', { className: 'iwb-hint' }, '用于排查「崩溃 / 内存占用高 / 界面出错」。记录只存在本机(localStorage),不含 Key、提示词和图片本体;进程/标签页意外结束后重开仍能看到崩溃前的记录。'),
el('div', { className: 'iwb-row' },
el('button', { className: 'iwb-btn iwb-btn-sm', onClick: () => { setDiagRev((v) => v + 1) } }, '刷新'),
el('button', { className: 'iwb-btn iwb-btn-sm', onClick: () => { _detail.at = 0; _detail.data = null; setDiagRev((v) => v + 1) } }, '刷新'),
el('button', { className: 'iwb-btn iwb-btn-sm', title: '复制完整诊断 JSON(含崩溃记录与内存采样)', onClick: copyDiag }, '复制诊断 JSON'),
// 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('label', { className: 'iwb-diag-kv', title: '已弃用:常驻合成层会让窗口可见时持续占用 CPU(实测 15%,最小化即消失),手势期间已有临时提升,无需常驻。' },
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: '记录 rAF 帧时长与 JS 长任务到 _boot.log(每 60s 一条),用于判断卡顿/高 CPU 是渲染还是脚本' },
el('input', { type: 'checkbox', checked: !!(extras && extras.perfProbe), onChange: (e) => { if (typeof props.onTogglePerf === 'function') props.onTogglePerf(e.target.checked) } }),
' 帧探针'),
el('label', { className: 'iwb-diag-kv', title: '关掉后台诊断采样(每 15s 内存曲线 + 每 4s 进程轮询)。关闭后不再记录曲线,崩溃记录仍保留' },
el('input', { type: 'checkbox', checked: !!(extras && extras.diagOff), onChange: (e) => { if (typeof props.onToggleDiagOff === 'function') props.onToggleDiagOff(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) } }),
' 手势期提升'),
+62 -5
View File
@@ -334,6 +334,13 @@ button { font-family: inherit; }
.iwb-history-actions { position: absolute; left: 0; right: 0; bottom: 2px; display: flex; gap: var(--iwb-space-4); justify-content: center; opacity: 0; transition: opacity .15s; }
.iwb-history-item:hover .iwb-history-actions { opacity: 1; }
.iwb-history-actions .iwb-btn { font-size: var(--iwb-font-2xs); padding: 1px 5px; background: var(--iwb-panel); text-decoration: none; } /*iwb:raw-until=3.28.0*/
/* 2026-12-03:图库卡片的下载按钮与输出节点统一为「右下角圆形图标」。
旧宿主规则 .iwb-history-actions 是「整条铺满 + 居中」,插件产物沿用了这个类名 ⇒ 按钮被居中。
这里用 body .iwb-history-embedded 提高优先级覆盖,只作用于图库面板,不动旧历史面板。 */
body .iwb-history-embedded .iwb-history-actions { left: auto; right: var(--iwb-space-8); bottom: var(--iwb-space-8); justify-content: flex-end; padding: 0; background-image: none; gap: var(--iwb-space-4); }
body .iwb-history-embedded .iwb-history-actions .iwb-gal-dl { width: 26px; height: 26px; border-radius: var(--iwb-radius-full); border: 1px solid var(--iwb-border2); background: var(--iwb-panel); color: var(--iwb-brand-text, var(--iwb-text)); display: grid; place-items: center; padding: 0; font-size: var(--iwb-font-base); line-height: 1; cursor: pointer; }
body .iwb-history-embedded .iwb-history-actions .iwb-gal-dl:hover { background: var(--iwb-hover); }
.iwb-modal-sm { width: 460px; }
.iwb-pickrow { display: flex; gap: 8px; align-items: flex-start; padding: 5px 0; cursor: pointer; font-size: 12px; }
.iwb-picktext { color: var(--iwb-text); line-height: 1.4; word-break: break-all; }
@@ -957,6 +964,15 @@ body .iwb-history-embedded .iwb-history-item.iwb-history-selected:hover img {
.iwb-dl-btn-ghost { background: color-mix(in srgb, var(--iwb-panel) 18%, transparent); color: var(--iwb-on-brand); border-color: color-mix(in srgb, var(--iwb-on-brand) 26%, transparent); }
.iwb-dl-btn .iwb-ic { width: var(--iwb-icon-sm); height: var(--iwb-icon-sm); }
.iwb-dl-txt { white-space: nowrap; }
/* 2026-12-03:输出节点下载浮层改右下角圆形图标(只占一个角,矮图不再被横条挡住中心)。
容器不吃事件、只有按钮吃;不引入 z-index(DOM 顺序已保证在图片之上)。旧 .iwb-dl-bar 保留可回退。 */
.iwb-dl-corner { position: absolute; right: var(--iwb-space-8); bottom: var(--iwb-space-8); display: flex; gap: var(--iwb-space-4); opacity: 0; pointer-events: none; transition: opacity var(--iwb-motion-hover) var(--iwb-ease-hover); }
.iwb-dl-ov:hover .iwb-dl-corner, .iwb-dl-ov:focus-within .iwb-dl-corner { opacity: 1; }
.iwb-dl-round { pointer-events: auto; width: 26px; height: 26px; border-radius: var(--iwb-radius-full); border: 1px solid var(--iwb-border2); background: var(--iwb-panel); color: var(--iwb-text); display: grid; place-items: center; padding: 0; cursor: pointer; font-size: var(--iwb-font-xs); line-height: 1; }
.iwb-dl-round:hover { background: var(--iwb-hover); }
.iwb-dl-round-primary { color: var(--iwb-brand-text, var(--iwb-text)); }
.iwb-dl-round .iwb-ic { width: var(--iwb-icon-sm); height: var(--iwb-icon-sm); }
@media (prefers-reduced-motion: reduce) { .iwb-dl-corner { transition: none; } }
@media (prefers-reduced-motion: reduce) { .iwb-out-cell-img, .iwb-dl-bar { transition: none; } .iwb-out-cell:hover .iwb-out-cell-img { transform: none; } }
.iwb-out-cell-meta { font-size: var(--iwb-font-2xs); color: var(--iwb-text2); text-align: center; margin-top: var(--iwb-space-2); }
.iwb-out-cell-actions { position: absolute; left: 0; right: 0; bottom: 0; height: 22px; display: flex; align-items: center; justify-content: center; gap: var(--iwb-space-10); opacity: 0; transition: opacity .15s; border-radius: 0 0 8px 8px; background: rgba(0,0,0,0.45); } /*iwb:raw-until=3.28.0*/
@@ -1222,11 +1238,13 @@ body .iwb-history-embedded .iwb-history-item.iwb-history-selected:hover img {
.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.180:常驻合成层已停用 —— 它会强制把整个世界层保持为一张大合成层,
实测“窗口可见时 CPU 持续 15%、最小化就掉”,且 155 起手势期间已有临时提升,常驻没有收益。 */
:root[data-layers="on"] .iwb-world { will-change: auto; }
/* 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; }
:root[data-layers="on"] .iwb-grid { will-change: auto; }
/* v15:左侧资源面板展开时浮在画布上层,不移动画布位置 */
.iwb-overlay.drawer-open .iwb-canvas { left: 0 !important; }
/* 停靠栏时代:工具栏/小地图按 --iwb-dock-* 让位(画布仍不动) */
@@ -1240,7 +1258,7 @@ body .iwb-history-embedded .iwb-history-item.iwb-history-selected:hover img {
.iwb-canvas-meta .iwb-status-err { color: var(--iwb-err); }
.iwb-canvas-topbar .iwb-top-nav-icon { width: 30px; height: 30px; }
/* S12:顶部标签条(浏览器式多画布标签)——UX_SPEC §4 单框扁平 token(容器透明、active 品牌色扁平高亮、只用 CSS 变量) */
.iwb-tabstrip { position: absolute; left: 0; right: 0; top: 0; height: var(--iwb-chrome-h); z-index: 36; display: flex; align-items: center; gap: 8px; padding: 0 14px; background: var(--iwb-chrome); box-sizing: border-box; border-bottom: 1px solid var(--iwb-border); overflow-x: auto; scrollbar-width: none; pointer-events: none; }
.iwb-tabstrip { position: fixed; left: 0; right: 0; top: 0; height: var(--iwb-chrome-h); z-index: calc(var(--iwb-z-curtain) + 1); display: flex; align-items: center; gap: 8px; padding: 0 14px; background: var(--iwb-chrome); box-sizing: border-box; border-bottom: 1px solid var(--iwb-border); overflow-x: auto; scrollbar-width: none; pointer-events: none; }
.iwb-tabstrip .iwb-tab { pointer-events: auto; }
.iwb-tabstrip::-webkit-scrollbar { display: none; }
/* 标签:**全项目只有这一套**(v3.27.1 收敛)。高度/圆角/字号/内距走 token,改一档全局一致。
@@ -2264,9 +2282,10 @@ body .iwb-history-embedded .iwb-history-item.iwb-history-selected:hover img {
/* 用「整屏 + 内边距」而不是 top:36/left:52:
标签条高度或导航宽度以后若有变化,页头也不会被压在标签条下面(v3.25.60 修重叠) */
.iwb-plugin-page {
position: absolute; inset: 0; z-index: 25; box-sizing: border-box;
position: fixed; inset: 0; z-index: 25; box-sizing: border-box;
padding: 42px 0 0 52px;
display: flex; flex-direction: column; background: var(--iwb-bg);
overflow: hidden; /* 2026-12-03:整页锁滚,只有 body 滚;避免标签条/页头被一起滚走 */
}
.iwb-plugin-page-head {
flex: 0 0 auto; display: flex; align-items: center; gap: 12px;
@@ -2274,7 +2293,7 @@ body .iwb-history-embedded .iwb-history-item.iwb-history-selected:hover img {
}
.iwb-plugin-page-title { font-weight: 800; font-size: 16px; color: var(--iwb-text); }
.iwb-plugin-page-sub { font-size: 12px; color: var(--iwb-text2); }
.iwb-plugin-page-body { flex: 1 1 auto; min-height: 0; overflow-y: auto; padding: 18px 22px 40px; }
.iwb-plugin-page-body { flex: 1 1 auto; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 18px 22px 40px; }
/* ── 快捷键弹窗(v3.25.59 分区罗列)──────────────────────────────────── */
.iwb-hotkey-help { display: flex; flex-direction: column; gap: 12px; }
@@ -2562,3 +2581,41 @@ body .iwb-history-embedded .iwb-history-item.iwb-history-selected:hover img {
/* 升级中:左侧导航的升级箭头自己也转(菜单里那个已经在转,这里补"外面这个")*/
.iwb-nav-more-upgrading .iwb-nav-up-spin { animation: iwb-nav-spin 0.9s linear infinite; }
/* 结果图落地状态(2026-12-02):出图后先排队/下载,就绪再换本地 objectURL */
.iwb-rimg { position: relative; }
.iwb-rimg-pending .iwb-result-thumb { opacity: .55; filter: saturate(.8); }
.iwb-rimg-flag { position: absolute; left: var(--iwb-space-4); top: var(--iwb-space-4); padding: 0 var(--iwb-space-8); border-radius: var(--iwb-radius-full); font-size: var(--iwb-font-xs); line-height: 16px; color: var(--iwb-text); background: var(--iwb-panel); border: 1px solid var(--iwb-border2); opacity: .92; }
.iwb-rimg-flag-err { color: var(--iwb-err); border-color: var(--iwb-err-bd); background: var(--iwb-err-bg); }
/* 输出节点体的落地角标(2026-12-02) */
.iwb-out-cell { position: relative; }
.iwb-out-cell-flag { position: absolute; left: var(--iwb-space-4); top: var(--iwb-space-4); padding: 0 var(--iwb-space-8); border-radius: var(--iwb-radius-full); font-size: var(--iwb-font-xs); line-height: 16px; color: var(--iwb-text); background: var(--iwb-panel); border: 1px solid var(--iwb-border2); opacity: .92; }
.iwb-out-cell-flag-err { color: var(--iwb-err); border-color: var(--iwb-err-bd); background: var(--iwb-err-bg); }
/* 2026-12-03:输出格「NEW」新图标记(会话内新生成;点击即消,或按设置时长自动淡出)。 */
.iwb-out-cell-new { position: absolute; left: var(--iwb-space-4); top: var(--iwb-space-4); padding: 0 var(--iwb-space-8); border-radius: var(--iwb-radius-full); font-size: var(--iwb-font-2xs); line-height: 16px; letter-spacing: .04em; color: var(--iwb-on-brand); background: var(--iwb-brand); border: 1px solid var(--iwb-brand); pointer-events: none; animation-name: iwb-out-new-expire; animation-timing-function: linear; animation-fill-mode: forwards; }
@keyframes iwb-out-new-expire { 0%, 90% { opacity: 1; visibility: visible; } 100% { opacity: 0; visibility: hidden; } }
/* 生成中:旧图压暗 + 「生成中」角标(不动 data,失败即恢复) */
.iwb-out-cell-busy .iwb-out-cell-img { opacity: .5; filter: saturate(.75); }
.iwb-out-cell-flag-busy { color: var(--iwb-warn); border-color: var(--iwb-warn-bd); background: var(--iwb-warn-bg); }
/* 2026-12-02:输出单元格「下载中」骨架(无本地源时垫底,避免大图区域纯空白) */
/* 2026-12-02:骨架改成「撑高」而不是绝对定位 —— 之前单元格没有高度,出图前会塌成一条线 */
.iwb-out-cell-ph { position: absolute; inset: 0; display: grid; place-items: center; border-radius: var(--iwb-radius-card); background: var(--iwb-layer2); color: var(--iwb-text2); font-size: var(--iwb-font-xs); }
.iwb-out-cell-img { position: relative; }
.iwb-out-cell-ph-txt { opacity: .85; }
/* 2026-12-02:图片真正加载完成(is-loaded)后才收起骨架与角标 —— 之前以「本地源就绪」为准,
会出现「角标没了、图还没出来」的空窗。用 :has 做纯 CSS 联动,不需要重渲染。 */
/* 2026-12-02:改用「父容器打类」,不依赖 :has()(老 WebView2 会整条丢弃选择器) */
.iwb-out-cell.is-loaded-cell .iwb-out-cell-ph,
.iwb-out-cell.is-loaded-cell .iwb-out-cell-flag { display: none; }
/* 破图:收起骨架与角标,改为明确的「加载失败」文案 */
.iwb-out-cell.is-broken-cell .iwb-out-cell-ph,
.iwb-out-cell.is-broken-cell .iwb-out-cell-flag { display: none; }
.iwb-out-cell-err { display: none; position: absolute; inset: 0; place-items: center; color: var(--iwb-err); font-size: var(--iwb-font-xs); }
.iwb-out-cell.is-broken-cell .iwb-out-cell-err { display: grid; }
/* 两级回退都失败:明确显示失败态,而不是留一张破图 */
.iwb-out-cell-img.is-broken { opacity: .25; }
+33 -1
View File
@@ -23,6 +23,13 @@ const PROFILE = process.env.IWB_PROBE_PROFILE === '1' // 只读诊断:平移
const CPU = process.env.IWB_PROBE_CPU === '1' // 只读诊断:量浏览器进程 CPU 占用(%)
const VISUAL = process.env.IWB_PROBE_VISUAL === '1' // 只读诊断:平移中逐帧截屏 => 画面完整度(空白率 / 边缘密度)
const TARGET_SCALE = num('IWB_PROBE_SCALE', 0) // >0 则平移前把 .iwb-world 缩放调到该档(隔离 LOD 影响)
// C(2026-12-02):把 App 自己的帧探针(window.IWBPerf)纳入断言。
// 与上面的 __FRAMES__ 不同,它统计的是**真实用户路径**的数据(长帧 >50ms、longtask 总时长),
// 与用户日志里的 perf 60s frames=… long=… 同源。IWB_PROBE_PERF=0 可只测不断言。
const PERF = process.env.IWB_PROBE_PERF !== '0'
const LR_MAX = num('IWB_PROBE_LR_MAX', 0.4) // 长帧比例上限(2026-12-02 实测 22.8%~30.9%,取 max×1.3)
const JS_MAX = num('IWB_PROBE_JS_MAX', 2500) // 本段 longtask 总时长上限(实测 1905~1934ms,取 ×1.3;换机器需重设基线)
const MIN_FRAMES = num('IWB_PROBE_MIN_FRAMES', 30) // 帧数下限:防「探针没开 → 0 长帧」假绿
// 重模式预算:7000 节点下 PROFILE/CPU/VISUAL 单是平移段就 >130s(默认 300s 会在后续 zoom 段超时,
// 实测 2026-10-16)。给足预算,仍可用 IWB_PROBE_TIMEOUT 覆盖(毫秒)。
@@ -321,10 +328,12 @@ test('P1 基线:pan / zoom / tab-switch / edges', async ({ page }) => {
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')
localStorage.setItem('iwb_perf_probe', d.perf ? '1' : '0')
if (d.perf) window.__IWB_PERF_WINDOW_MS__ = 2000 // 缩短 60s 汇总窗口,避免测试里等一分钟才有一条汇总
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, 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 })) })
}, { cfg: CFG, perf: PERF, 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' })
@@ -378,6 +387,16 @@ test('P1 基线:pan / zoom / tab-switch / edges', async ({ page }) => {
visRef = await page.screenshot({ clip: visClip })
}
await page.evaluate(() => { window.__IWB_E2E_BODY_RENDERS__ = 0 })
if (PERF) {
const perfReady = await page.evaluate(() => {
const P = window.IWBPerf
if (!P || typeof P.snapshot !== 'function') return false
if (!P.running()) P.start()
P.snapshot() // 清零:只统计本次平移段
return true
})
if (!perfReady) console.warn('[perf] window.IWBPerf.snapshot 不可用(dist 未含 C 项改动?)')
}
await startFrameProbe(page)
let traceH = null
let profClient = null
@@ -393,6 +412,7 @@ test('P1 基线:pan / zoom / tab-switch / edges', async ({ page }) => {
const cpuW1 = Date.now()
if (CPU) console.log('PAN_CPU=' + JSON.stringify({ idle: cpuIdle, pan: mkCpu(cpuA, cpuB, cpuW0, cpuW1), procs: (cpuB && cpuB.procs) || [] }))
await page.waitForTimeout(250)
const perfSnap = PERF ? await page.evaluate(() => (window.IWBPerf && typeof window.IWBPerf.snapshot === 'function') ? window.IWBPerf.snapshot() : null) : null
const panRaw = await stopFrameProbe(page)
const panRenders = await page.evaluate(() => Number(window.__IWB_E2E_BODY_RENDERS__ || 0))
if (PROFILE) {
@@ -455,6 +475,17 @@ test('P1 基线:pan / zoom / tab-switch / edges', async ({ page }) => {
}
}
// ── C(2026-12-02):App 帧探针断言 ─────────────────────────────────────────
// 阈值先宽(--env 可覆盖),跑稳后再收紧;这里只守「明显退化」,不追求精确数值。
if (PERF) {
expect(perfSnap, 'App 帧探针读数缺失:window.IWBPerf.snapshot 不可用(dist 未含 C 项改动?)').toBeTruthy()
expect(perfSnap.frames, '帧探针没采到帧(探测未启动时 long=0 会假绿)').toBeGreaterThan(MIN_FRAMES)
const longRatio = perfSnap.long / Math.max(1, perfSnap.frames)
expect(longRatio, '长帧比例 ' + (longRatio * 100).toFixed(1) + '% 超过上限 ' + (LR_MAX * 100).toFixed(0) + '%(长帧 ' + perfSnap.long + '/' + perfSnap.frames + ',最长 ' + perfSnap.max + 'ms)').toBeLessThanOrEqual(LR_MAX)
expect(perfSnap.jsMs, '本段 longtask 总时长 ' + perfSnap.jsMs + 'ms 超过上限 ' + JS_MAX + 'ms(' + perfSnap.js + ' 次)').toBeLessThanOrEqual(JS_MAX)
console.log('PAN_PERF=' + JSON.stringify(perfSnap))
}
const hydrates = await page.evaluate(() => Number(window.__IWB_E2E_HYDRATES__ || 0))
const summary = {
scenario: { NODES, EDGES, TABS, IMGS, imgsOk, tabCount, domNodes, vpScale },
@@ -462,6 +493,7 @@ test('P1 基线:pan / zoom / tab-switch / edges', async ({ page }) => {
hydrates,
pan: { p50: pct(panRaw.frames, 0.5), p95: pct(panRaw.frames, 0.95), max: pct(panRaw.frames, 1), frames: panRaw.frames.length, longtasks: panRaw.longtasks.length, longtaskTotalMs: Math.round(panRaw.longtasks.reduce((a, b) => a + b, 0)), bodyRenders: panRenders },
zoom: { bodyRenders: zoomRenders },
perf: perfSnap ? { frames: perfSnap.frames, long: perfSnap.long, max: perfSnap.max, js: perfSnap.js, jsMs: perfSnap.jsMs, tags: perfSnap.tags, longRatio: Math.round((perfSnap.long / Math.max(1, perfSnap.frames)) * 1000) / 1000 } : null,
tabSwitch: { n: switchTimes.length, p50: pct(switchTimes, 0.5), p95: pct(switchTimes, 0.95), max: pct(switchTimes, 1) },
errors,
}
+5 -2
View File
@@ -84,8 +84,11 @@ if (cullStart > 0 && cullEnd > cullStart) {
const cull = geomJs.slice(cullStart, cullEnd)
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)
// 2026-12-02:cullRectsOf 重构成 mk(pad){ const p = pad + extra; ... },变量名从 pad 变 p。
// 守卫改为「先认 p = pad + extra,再数 4 条边都按 p 收放」——语义不变,也不会因为改名而假绿。
const hasP = /const p = pad \+ extra/.test(cull)
const hasPad = (cull.match(/- p\b|\+ p\b/g) || []).length
assert('裁剪矩形 4 条边都按 p(=pad+extra) 收放', hasP && hasPad === 4, 'p=' + hasP + ' 边数=' + hasPad)
assert('裁剪矩形不含 560(历史值已废止)', !/560/.test(cull))
assert('app.js 只做装配(不再内联 cullRect 数值)', !/const cullRect = React\.useMemo/.test(appJs))
assert('文档记录了 280 余量', factsDoc.includes('280'))
+5
View File
@@ -34,19 +34,24 @@
"IWBImageCompress",
"IWBImageDisplayThumb",
"IWBImageFileRef",
"IWBImageIngest",
"IWBImageIngestStore",
"IWBImageRemoteCache",
"IWBImageThumbPick",
"IWBImageWriteback",
"IWBMetricsSwallow",
"IWBMiniMapFit",
"IWBNativeClipboard",
"IWBNodeBodies",
"IWBPerf",
"IWBPluginApiImages",
"IWBPluginCanvasBridge",
"IWBPluginData",
"IWBPluginGallery",
"IWBPluginGroupLib",
"IWBPluginHost",
"IWBPluginPromptLib",
"IWBPluginQueue",
"IWBPromptCover",
"IWBProviderPing",
"IWBResultImg",
+5
View File
@@ -56,6 +56,7 @@
"ui-components.js",
"plugin-data.js",
"plugin-api-gallery.js",
"plugin-api-queue.js",
"plugin-api-grouplib.js",
"plugin-api-promptlib.js",
"plugin-host.js",
@@ -79,6 +80,9 @@
"canvas-v3-hit.js",
"image-display-thumb.js",
"image-cache-migrate.js",
"image-writeback.js",
"image-ingest.js",
"image-ingest-store.js",
"runtime-frame-probe.js",
"image-remote-cache.js",
"gallery-sync.js",
@@ -120,6 +124,7 @@
"ui-gen-config-panel.js",
"canvas-webview.js",
"plugin-api-images.js",
"plugin-canvas-bridge.js",
"plugin-files-policy.js",
"image-prompt-cover.js"
]
+43
View File
@@ -0,0 +1,43 @@
#!/usr/bin/env node
'use strict'
/* 图片读取/下载口径守卫(2026-12-03)
*
* 规则来源:docs/standards/image-read-and-download.md
* ① 下载命名一律用图库行名(wOutNameOf),写死的 image.png 只允许做未落地兜底;
* ② 预览只读本地:任务队列 preview 不得直连远程,也不得把 320 缩略图当原图;
* ③ 老记录原图必须能从 images/gallery 读(storage-file 暴露 galleryOriginalOf/Blob)。
*/
const fs = require('fs')
const path = require('path')
const root = path.resolve(__dirname, '..')
const read = (p) => fs.readFileSync(path.join(root, p), 'utf8')
let fail = 0
const ok = (cond, msg) => { if (cond) console.log(' PASS ' + msg); else { fail++; console.error(' FAIL ' + msg) } }
const doc = read('docs/standards/image-read-and-download.md')
ok(/取源顺序/.test(doc) && /wOutNameOf/.test(doc), '规范文档存在且写了取源顺序与命名')
const sf = read('src/storage-file.js')
ok(/galleryOriginalOf/.test(sf) && /galleryOriginalBlob/.test(sf), 'storage-file 暴露本地原图读取(预览/下载)')
const app = read('app.js')
ok(/function wOutNameOf \(url\)/.test(app), '宿主提供 wOutNameOf(按 url 查图库行名)')
ok(/downloadUrl\(u, wOutNameOf\(u\)/.test(app), '批量下载用图库行名')
ok(/galleryOriginalBlob\(item\)/.test(app), '下载取源(wResolveOutputSrc)本地优先')
const qBlock = app.slice(app.indexOf('preview: async (id) => {'), app.indexOf('copyLink: (id) => {'))
ok(qBlock.length > 0 && !/\^https\?:/.test(qBlock), '任务队列预览不直连远程')
ok(!/IDB\.get\(row\.idb\)/.test(qBlock), '任务队列预览不把 320 缩略图当原图')
ok(/not-local/.test(qBlock), '任务队列预览在本地无图时给出「未下载」提示')
ok(/function wPreviewEntryOf \(url\)/.test(app), '输出节点预览按 url 查图库行(__gallery 条目)')
ok(/previewEntryOf\(x\.url\)/.test(read('src/ui-node-bodies.js')) && /wPreviewEntryOf/.test(read('src/ui-node-bodies.js')), '输出节点双击预览使用图库条目(本地原图优先)')
const bodies = read('src/ui-node-bodies.js')
ok(/downloadUrl\(src, \(typeof wOutNameOf/.test(bodies), '输出节点下载用图库行名')
const view = read('src/ui-canvas-view.js')
ok(/wOutNameOf\(entry && entry\.url\)/.test(view), '预览下载用图库行名')
ok(/galleryOriginalOf/.test(view) && /galleryOriginalBlob/.test(view), '预览按行名读本地原图(不退回缩略图/远程)')
if (fail) { console.error('image-download contract: ' + fail + ' 项不符(见 docs/standards/image-read-and-download.md)'); process.exit(1) }
console.log('image-download contract checks passed(取源本地优先 / 命名统一图库行名 / 预览不直连远程)')
+276
View File
@@ -0,0 +1,276 @@
// 结果落地管线(src/image-ingest.js)契约测试 —— 2026-12-02
// 钉住的都是「会真丢图 / 会真重复下载」的点:幂等、重试、失败保留 url、恢复、释放。
'use strict'
const fs = require('fs')
const path = require('path')
const src = fs.readFileSync(path.join(__dirname, '..', 'src', 'image-ingest.js'), 'utf8')
const box = {}
new Function('window', 'globalThis', src)(box, box)
let pass = 0, fail = 0
const ok = (name, cond, extra) => {
if (cond) { pass++; console.log(' ✅ ' + name) } else { fail++; console.log(' ❌ ' + name + (extra !== undefined ? ' → ' + JSON.stringify(extra) : '')) }
}
const tick = () => new Promise((r) => setTimeout(r, 5))
async function until (fn, ms) {
const end = Date.now() + (ms || 1000)
while (Date.now() < end) { if (fn()) return true; await tick() }
return false
}
function make (opts) {
const o = opts || {}
const st = { fetched: [], written: [], persisted: [], events: [], maxActive: 0, active: 0 }
let attempt = 0
const ingest = box.IWBImageIngest.create({
concurrency: o.concurrency || 2,
retries: o.retries === undefined ? 3 : o.retries,
sleep: async () => {}, // 测试里不真等退避
now: () => 1000,
fetchBytes: async (url) => {
st.fetched.push(url)
st.active++
st.maxActive = Math.max(st.maxActive, st.active)
try {
if (o.failTimes && st.fetched.length <= o.failTimes) return { ok: false, error: 'net-' + st.fetched.length }
if (o.alwaysFail) return { ok: false, error: 'net-down' }
return { ok: true, dataUrl: 'data:image/png;base64,AAAA', bytes: 1234, mime: 'image/png' }
} finally { st.active-- }
},
writeRef: async (dataUrl) => { st.written.push(dataUrl); return { __blob: 'b' + st.written.length } },
persist: (e) => st.persisted.push(e.id + ':' + e.status),
onEvent: (k) => st.events.push(k),
removeEntry: () => {},
})
return { ingest, st }
}
async function main () {
// ① 正常落地
{
const { ingest, st } = make()
const e = ingest.enqueue({ url: 'https://cdn/x.png', source: 'gen', w: 1024, h: 1024 })
ok('①-1 入队立刻可见(queued)', !!ingest.get(e.id) && ingest.get(e.id).status === 'queued')
await until(() => ingest.get(e.id).status === 'ready')
const r = ingest.get(e.id)
ok('①-2 落地后 ready + ref + bytes', r.status === 'ready' && !!r.ref && r.bytes === 1234, r)
ok('①-3 只下载一次、只写一次引用', st.fetched.length === 1 && st.written.length === 1, { f: st.fetched.length, w: st.written.length })
ok('①-4 状态变化被持久化', st.persisted.indexOf(e.id + ':ready') >= 0, st.persisted)
}
// ② 幂等:同 url 再入队不重复下载
{
const { ingest, st } = make()
const a = ingest.enqueue({ url: 'https://cdn/y.png' })
await until(() => ingest.get(a.id).status === 'ready')
const b = ingest.enqueue({ url: 'https://cdn/y.png' })
await tick()
ok('②-1 同 url 复用同一条记录', a.id === b.id)
ok('②-2 没有第二次下载', st.fetched.length === 1, st.fetched.length)
ok('②-3 重复 enqueue 不会把 ready 打回 queued', ingest.get(a.id).status === 'ready')
}
// ③ 重试:失败两次后成功
{
const { ingest } = make({ failTimes: 2 })
const e = ingest.enqueue({ url: 'https://cdn/retry.png' })
await until(() => ingest.get(e.id).status === 'ready')
const r = ingest.get(e.id)
ok('③-1 第 3 次成功后 ready', r.status === 'ready', r.status)
ok('③-2 重试次数如实记录', r.retries === 2, r.retries)
ok('③-3 成功后清空 lastError', r.lastError === '', r.lastError)
}
// ④ 彻底失败:保留 url、可重试
{
const { ingest } = make({ alwaysFail: true, retries: 2 })
const e = ingest.enqueue({ url: 'https://cdn/bad.png' })
await until(() => ingest.get(e.id).status === 'failed', 2000)
const r = ingest.get(e.id)
ok('④-1 重试用尽后 failed', r.status === 'failed', r.status)
ok('④-2 原始 url 原样保留(不丢图)', r.url === 'https://cdn/bad.png')
ok('④-3 带可读错误', /net-down/.test(r.lastError), r.lastError)
ok('④-4 记录仍在列表里', ingest.list().length === 1)
}
// ⑤ 失败后手动 retry 能恢复
{
const { ingest } = make({ alwaysFail: true, retries: 1 })
const e = ingest.enqueue({ url: 'https://cdn/later.png' })
await until(() => ingest.get(e.id).status === 'failed', 2000)
const again = ingest.retry(e.id)
ok('⑤-1 retry 复位为 queued', !!again && again.retries === 0)
}
// ⑥ 释放字节(仅保留链接)
{
const { ingest } = make()
const e = ingest.enqueue({ url: 'https://cdn/rel.png' })
await until(() => ingest.get(e.id).status === 'ready')
const r = ingest.release(e.id)
ok('⑥-1 变为 link-only', r.status === 'link-only')
ok('⑥-2 引用被清空但 url 保留', r.ref === null && r.url === 'https://cdn/rel.png')
// 任务队列「下载」会再次 enqueue 同 url:link-only 必须回到 queued(否则永远不下)
const again = ingest.enqueue({ url: 'https://cdn/rel.png' })
ok('⑥-3 link-only 再次 enqueue → queued', again && again.status === 'queued', again && again.status)
await until(() => ingest.get(e.id).status === 'ready', 2000)
}
// ⑦ 启动恢复:downloading/queued 重排,ready 保持
{
const { ingest, st } = make()
ingest.restore([
{ id: 'a', url: 'https://cdn/a.png', status: 'downloading', createdAt: 1, updatedAt: 1 },
{ id: 'b', url: 'https://cdn/b.png', status: 'queued', createdAt: 1, updatedAt: 1 },
{ id: 'c', url: 'https://cdn/c.png', status: 'ready', ref: { __blob: 'x' }, createdAt: 1, updatedAt: 1 },
{ id: 'd', url: 'https://cdn/d.png', status: 'failed', lastError: 'net', createdAt: 1, updatedAt: 1 },
])
ok('⑦-1 failed 不被自动重排', ingest.get('d').status === 'failed')
ok('⑦-2 ready 保持 ready', ingest.get('c').status === 'ready')
await until(() => ingest.get('a').status === 'ready' && ingest.get('b').status === 'ready')
ok('⑦-3 downloading/queued 恢复后自动跑完', ingest.get('a').status === 'ready' && ingest.get('b').status === 'ready')
}
// ⑧ 取消排队中的
{
const { ingest } = make({ concurrency: 1 })
ingest.enqueue({ url: 'https://cdn/busy.png' })
const q = ingest.enqueue({ url: 'https://cdn/wait.png' })
ingest.cancel(q.id)
ok('⑧-1 排队中被取消 → link-only', ingest.get(q.id).status === 'link-only', ingest.get(q.id).status)
}
// ⑨ 并发上限
{
const { ingest, st } = make({ concurrency: 2 })
for (let i = 0; i < 6; i++) ingest.enqueue({ url: 'https://cdn/c' + i + '.png' })
await until(() => ingest.stats().ready === 6, 3000)
ok('⑨-1 6 条全部落地', ingest.stats().ready === 6, ingest.stats())
ok('⑨-2 同时下载不超过 2 路', st.maxActive <= 2, st.maxActive)
}
// ⑩ 统计
{
const { ingest } = make()
const a = ingest.enqueue({ url: 'https://cdn/s1.png' })
await until(() => ingest.get(a.id).status === 'ready')
ingest.enqueue({ url: 'https://cdn/s2.png' })
await tick()
const s = ingest.stats()
ok('⑩-1 total/ready/queued 计数正确', s.total === 2 && s.ready >= 1, s)
}
// ⑪ 下载优先走系统网络栈(Rust);失败/不可用才回退 WebView fetch
{
let rustCalls = 0
const fb = box.IWBImageIngest.createFetchBytes({
rustFetch: async () => { rustCalls++; return { ok: true, mime: 'image/png', bytes: 3, b64: 'AAA' } },
blobFromSrc: async () => null,
blobToDataUrl: async () => '',
})
const r = await fb('https://cdn/rust.png', () => {})
ok('⑪-1 rustFetch 成功 → dataUrl + bytes', r.ok && r.dataUrl === 'data:image/png;base64,AAA' && r.bytes === 3 && rustCalls === 1, r)
const fb2 = box.IWBImageIngest.createFetchBytes({
rustFetch: async () => ({ ok: false, error: 'http-403' }),
blobFromSrc: async () => ({ size: 1 }),
blobToDataUrl: async () => 'data:image/png;base64,BB',
})
const r2 = await fb2('https://cdn/fallback.png', () => {})
ok('⑪-2 rustFetch 失败 → 回退宿主取字节', r2.ok && r2.dataUrl === 'data:image/png;base64,BB', r2)
}
// ⑪b 用户取消(abort)不回退再抓一次
{
let blobCalls = 0
const ac = new AbortController()
ac.abort()
const fb = box.IWBImageIngest.createFetchBytes({
rustFetch: async () => { throw new Error('no-rust') },
blobFromSrc: async () => { blobCalls++; return null },
blobToDataUrl: async () => '',
})
const r = await fb('https://cdn/abort.png', () => {}, ac.signal)
ok('⑪b 已 abort 时直接返回失败、不回退抓取', r.ok === false && blobCalls === 0, { r, blobCalls })
}
// ⑫ 并发数走 getConcurrency(默认 30,设置页可调)
{
let release = null
const gate = new Promise((r) => { release = r })
let active = 0, maxActive = 0
const ing = box.IWBImageIngest.create({
getConcurrency: () => 3,
retries: 0,
sleep: async () => {},
now: () => 1000,
fetchBytes: async () => {
active++; maxActive = Math.max(maxActive, active)
await gate
active--
return { ok: true, dataUrl: 'data:image/png;base64,AA', bytes: 1, mime: 'image/png' }
},
writeRef: async () => ({ __blob: 'b' }),
persist: () => {}, onEvent: () => {}, removeEntry: () => {},
})
for (let i = 0; i < 5; i++) ing.enqueue({ url: 'https://cdn/g' + i + '.png' })
await until(() => maxActive === 3, 500)
ok('⑫-1 同时下载按 getConcurrency 生效(3 路)', maxActive === 3, maxActive)
release()
await until(() => ing.stats().ready === 5, 1500)
ok('⑫-2 释放后 5 条全部完成', ing.stats().ready === 5, ing.stats())
}
// ⑬ 取消:在飞结果作废(不写引用、不把 link-only 覆盖成 ready)
{
let release = null
const gate = new Promise((r) => { release = r })
let calls = 0, written = 0
const ing = box.IWBImageIngest.create({
retries: 2, sleep: async () => {}, now: () => 1000,
fetchBytes: async () => { calls++; await gate; return { ok: true, dataUrl: 'data:image/png;base64,AA', bytes: 1, mime: 'image/png' } },
writeRef: async () => { written++; return { __blob: 'b' } },
persist: () => {}, onEvent: () => {}, removeEntry: () => {},
})
const e = ing.enqueue({ url: 'https://cdn/cancel.png' })
await until(() => ing.get(e.id).status === 'downloading', 500)
ing.cancel(e.id)
release()
await tick(); await tick(); await tick()
ok('⑬-1 取消后状态是 link-only', ing.get(e.id).status === 'link-only', ing.get(e.id).status)
ok('⑬-2 取消后在飞结果不写引用', written === 0, written)
ok('⑬-3 取消后不会重试', calls === 1, calls)
}
// ⑭ 取消后重试:新请求正常落地,旧请求的结果被丢弃
{
let release = null
const gate = new Promise((r) => { release = r })
let calls = 0, written = 0
const ing = box.IWBImageIngest.create({
retries: 0, sleep: async () => {}, now: () => 1000,
fetchBytes: async () => {
calls++
if (calls === 1) await gate
return { ok: true, dataUrl: 'data:image/png;base64,AA', bytes: 1, mime: 'image/png' }
},
writeRef: async () => { written++; return { __blob: 'b' } },
persist: () => {}, onEvent: () => {}, removeEntry: () => {},
})
const e = ing.enqueue({ url: 'https://cdn/retry.png' })
await until(() => ing.get(e.id).status === 'downloading', 500)
ing.cancel(e.id)
ing.retry(e.id)
release()
await until(() => ing.get(e.id).status === 'ready', 1000)
await tick()
ok('⑭-1 重试后落地 ready', ing.get(e.id).status === 'ready', ing.get(e.id).status)
ok('⑭-2 只写一次引用(旧结果被丢弃)', written === 1, written)
}
console.log('')
console.log(pass + ' passed, ' + fail + ' failed')
if (fail) process.exit(1)
}
main().catch((e) => { console.error(e); process.exit(1) })
+138
View File
@@ -0,0 +1,138 @@
// 图片写回唯一收口的契约测试(src/image-writeback.js)—— 2026-12-02 新增
//
// 为什么单独钉:v3.26.174~182 的 4 个线上问题都在这条链上,而三个入口的语义
// (同步布尔 / 异步校验 / 后台引用化)是插件侧(blank-canvas、white-bg-800、
// image-annotate)直接依赖的契约。任何一条被改成"看起来差不多"的写法,
// 都会以"图不落地 / CPU 空转 / 提示成功其实没保存"的形式复发。
'use strict'
const fs = require('fs')
const path = require('path')
const src = fs.readFileSync(path.join(__dirname, '..', 'src', 'image-writeback.js'), 'utf8')
const box = {}
new Function('window', 'globalThis', src)(box, box)
const W = box.IWBImageWriteback
let pass = 0
let fail = 0
const ok = (name, cond, extra) => {
if (cond) { pass++; console.log(' ✅ ' + name) } else { fail++; console.log(' ❌ ' + name + (extra ? ' → ' + JSON.stringify(extra) : '')) }
}
const SMALL = 'data:image/png;base64,AAAA'
const BIG = 'data:image/png;base64,' + 'A'.repeat(4000)
const REF = { __blob: 'blob-1' }
// 造一份可控依赖:importer 只对「大于内联阈值」的输入给出引用(与 wImportImage 同语义)
function make (opts) {
const o = opts || {}
const st = { refs: { nodes: [{ id: 'n1', type: 'ref', data: { data: o.initial || SMALL, url: '' } }] }, commits: 0, saves: 0, invalidated: [], bumps: 0, imported: [] }
const deps = {
refs: st.refs,
updateNode: (id, patch) => { st.refs.nodes = st.refs.nodes.map((n) => (n.id === id ? { ...n, data: { ...n.data, ...patch } } : n)); st.commits++ },
commitCanvas: (next) => { st.refs.nodes = next; st.commits++ },
saveNow: async () => { st.saves++ },
readWorkspace: () => ({ ok: true, value: { workspaces: [{ id: 'w1', nodes: st.refs.nodes }] } }),
activeWsId: () => 'w1',
inlineMax: 3000,
importer: async (dataUrl) => { st.imported.push(dataUrl); return { ok: true, data: REF, ref: REF } },
invalidate: (v) => st.invalidated.push(v),
bump: () => { st.bumps++ },
resolveRef: async () => 'data:image/png;base64,ORIGINAL',
createRefNode: (payload) => { const id = 'n' + (st.refs.nodes.length + 1); st.refs.nodes = st.refs.nodes.concat([{ id: id, type: 'ref', data: { data: String(payload.dataUrl) } }]); return id },
log: () => {},
}
return { w: W.create(deps), st, deps }
}
const node = (st, id) => st.refs.nodes.find((n) => n.id === (id || 'n1'))
const hasBase64 = (d) => Object.keys(d || {}).some((k) => typeof d[k] === 'string' && d[k].indexOf('data:') === 0)
async function main () {
// ── ① 同步入口:严格布尔、不落盘、只 commit 一次(blank-canvas / white-bg-800 依赖)──
{
const { w, st } = make()
const r = w.replaceNodeImageSync('n1', BIG)
ok('①-1 同步入口返回严格布尔 true(不是 Promise)', r === true && typeof r === 'boolean')
ok('①-2 同步入口不落盘(saveNow 0 次)', st.saves === 0, st.saves)
ok('①-3 同步入口只 commit 一次(UI 必须立刻更新)', st.commits === 1, st.commits)
ok('①-4 非法数据/不存在的节点返回 false', w.replaceNodeImageSync('n1', 'http://x/y.png') === false && w.replaceNodeImageSync('nope', BIG) === false)
}
// ── ② 异步入口:data / localRef / ref 三者同指一个引用,节点里不留 base64 ──
{
const { w, st } = make()
const r = await w.replaceNodeImage('n1', BIG)
const d = node(st).data
ok('②-1 返回 {ok:true}', !!(r && r.ok === true), r)
ok('②-2 data / localRef / ref 是同一个引用对象', d.data === REF && d.localRef === REF && d.ref === REF)
// orig 允许是 string(旧图本来是内联的,小图不引用化);这里只看显示/落盘用的四个字段
const shown = { data: d.data, url: d.url, localRef: d.localRef, ref: d.ref }
ok('②-3 显示/落盘字段里没有 data: 字符串残留', !hasBase64(shown), Object.keys(shown))
ok('②-4 落盘 1 次 + bump 至少 1 次', st.saves === 1 && st.bumps >= 1, { saves: st.saves, bumps: st.bumps })
}
// ── ③ orig 两次覆盖都保留且是引用;还原能取回原图 ──
{
const { w, st } = make({ initial: BIG })
await w.replaceNodeImage('n1', BIG.replace('A', 'B'))
const first = node(st).data.orig
ok('③-1 首覆盖:orig 已引用化(不是 base64 字符串)', !!first && typeof first === 'object' && first === REF, typeof first)
await w.replaceNodeImage('n1', BIG.replace('A', 'C'))
const second = node(st).data.orig
ok('③-2 第二次覆盖:orig 仍是引用、没丢', !!second && typeof second === 'object', typeof second)
const rr = await w.restoreOrig('n1')
const d = node(st).data
ok('③-3 还原动作能把原图取回来(清空 orig)', !!(rr && rr.ok) && d.orig === '' && /ORIGINAL|^data:/.test(String(d.data)))
}
// ── ③b 旧图已是引用、又没有 orig 时:直接把该引用当备份(否则第二次覆盖会静默丢 orig)──
{
const { w, st } = make()
st.refs.nodes = [{ id: 'n1', type: 'ref', data: { data: REF, url: '', localRef: REF, ref: REF } }]
await w.replaceNodeImage('n1', BIG.replace('A', 'E'))
const d = node(st).data
ok('③b-1 旧图是引用时,原样当备份(不再丢失 orig)', d.orig === REF, typeof d.orig)
ok('③b-2 备份没有引发额外写库(引用不再引用化)', st.imported.length === 1, st.imported.length)
}
// ── ④ 阈值唯一:<= inlineMax 不引用;> inlineMax 恰好引用一次 ──
{
const small = make()
const r = await small.w.replaceNodeImage('n1', SMALL.replace('AAAA', 'AAAB'))
ok('④-1 小图不产生引用(importer 0 次、data 仍是字符串)', small.st.imported.length === 0 && typeof node(small.st).data.data === 'string', { calls: small.st.imported.length })
ok('④-2 小图也不留 localRef/ref', node(small.st).data.localRef === null && node(small.st).data.ref === null)
const big = make()
await big.w.replaceNodeImage('n1', BIG)
ok('④-3 大图恰好引用一次(不含旧图备份时)', big.st.imported.length === 1, big.st.imported.length)
}
// ── ⑤ 双 key 失效:旧值 + 新值都失效(引用对象也要取到 key)──
{
const { w, st } = make({ initial: BIG })
await w.replaceNodeImage('n1', BIG.replace('A', 'D'))
const got = st.invalidated
ok('⑤-1 旧值被失效', got.some((v) => typeof v === 'string' && v.indexOf('data:') === 0 && v !== BIG.replace('A', 'D')), got.map((v) => typeof v))
ok('⑤-2 新引用也被失效(供 512/256 两档删除)', got.includes(REF))
ok('⑤-3 invalidate 由模块统一调用(不是各调用点各写一套)', st.bumps >= 1 && got.length >= 3, got.length)
}
// ── ⑥ 建节点:同步返回 id;大图后台引用化,小图不动 ──
{
const { w, st } = make()
const idSmall = w.createNodeImage({ dataUrl: SMALL, name: 'a.png' })
const idBig = w.createNodeImage({ dataUrl: BIG, name: 'b.png' })
ok('⑥-1 同步返回节点 id', typeof idSmall === 'string' && typeof idBig === 'string')
await new Promise((r) => setTimeout(r, 10))
const bigN = st.refs.nodes.find((n) => n.id === idBig)
ok('⑥-2 大图在后台被引用化', bigN && bigN.data.data === REF, bigN && typeof bigN.data.data)
ok('⑥-3 小图保持内联(不写库)', st.imported.length === 1, st.imported.length)
ok('⑥-4 非法 data URL 返回 null', w.createNodeImage({ dataUrl: 'https://x/y.png' }) === null)
}
console.log('')
console.log(pass + ' passed, ' + fail + ' failed')
if (fail) process.exit(1)
}
main().catch((e) => { console.error(e); process.exit(1) })
+4 -3
View File
@@ -219,7 +219,8 @@ test('3. 预览复制 PNG 源 → 剪贴板为 image/png', async ({ page }) => {
page.on('pageerror', (e) => errors.push(String((e && e.message) || e)))
const urls = await makeDataUrls(page)
await seed(page, [
{ name: 'png_src.png', url: urls.png, data: urls.png, size: 900, mtime: Date.now() - 1000, w: 8, h: 8 },
// 2026-12-03:图库自 v3.26.226 只显示 orig='ok'(已落地)的条目,夹具必须带 orig,否则面板 0 条
{ name: 'png_src.png', url: urls.png, data: urls.png, size: 900, mtime: Date.now() - 1000, w: 8, h: 8, orig: 'ok' },
])
const clip = await copyFromGalleryPreview(page, 'png_src.png')
expect(clip.types, JSON.stringify(clip)).toContain('image/png')
@@ -235,8 +236,8 @@ test('4. 预览复制 JPEG 源 → 也必须成功且为 image/png', async ({ pa
const urls = await makeDataUrls(page)
expect(urls.jpeg.indexOf('data:image/jpeg') === 0, 'JPEG 夹具应是 image/jpeg').toBe(true)
await seed(page, [
{ name: 'png_src.png', url: urls.png, data: urls.png, size: 900, mtime: Date.now() - 1000, w: 8, h: 8 },
{ name: 'jpeg_src.jpg', url: urls.jpeg, data: urls.jpeg, size: 900, mtime: Date.now() - 2000, w: 8, h: 8 },
{ name: 'png_src.png', url: urls.png, data: urls.png, size: 900, mtime: Date.now() - 1000, w: 8, h: 8, orig: 'ok' },
{ name: 'jpeg_src.jpg', url: urls.jpeg, data: urls.jpeg, size: 900, mtime: Date.now() - 2000, w: 8, h: 8, orig: 'ok' },
])
const clip = await copyFromGalleryPreview(page, 'jpeg_src.jpg')
expect(clip.types, JSON.stringify(clip)).toContain('image/png')
+12
View File
@@ -118,4 +118,16 @@ const urls = (groups) => Array.from(groups, (g) => Array.from(g.items, (r) => St
assert.strictEqual(B.outGroupsOf([gi2], () => [{ id: 't1', title: '当前标题' }])[0].taskTitle, '快照标题', '⑨ 结果快照优先于当前标题')
}
// ── 10. NEW 标记元数据:渲染项必须带 _genAt/_genKey,且是副本(不能挂到存档对象上)──
{
const src = item('new0')
const gi = gen('g1', 0, 0, [{ promptId: 't1', vi: 0, at: 1796230000000, items: [src] }])
const groups = B.outGroupsOf([gi], () => [{ id: 't1' }])
const it = groups[0].items[0]
assert.strictEqual(it._genAt, 1796230000000, '⑩ _genAt 来自条目 at')
assert.strictEqual(it._genKey, 't1|0|1796230000000', '⑩ _genKey = 任务|变体|时间')
assert.notStrictEqual(it, src, '⑩ 渲染项必须是副本,不能把 _genAt 挂到画布存档对象上')
assert.strictEqual(src._genAt, undefined, '⑩ 原始 item 不得被污染')
}
console.log('out-groups-order: 全部通过')
+1 -1
View File
@@ -13,7 +13,7 @@ vm.runInNewContext(source, sandbox)
const host0 = sandbox.IWBPluginHost
assert.ok(Number.isInteger(host0.apiVersion) && host0.apiVersion >= 1, 'apiVersion 必须是正整数')
assert.ok(Array.isArray(host0.capabilities) && host0.capabilities.length >= 7, '能力清单应非空')
assert.strictEqual(host0.capabilities.slice().sort().join(','), 'canvas,canvasWrite,commands,files,gallery,generationHooks,grouplib,images,nodeActions,nodeTypes,panels,promptlib,providers')
assert.strictEqual(host0.capabilities.slice().sort().join(','), 'canvas,canvasWrite,commands,files,gallery,generationHooks,grouplib,images,nodeActions,nodeTypes,pages,panels,promptlib,providers,queue')
const manifest = (over) => Object.assign({ id: 'demo-plugin', name: 'Demo', version: '1.0.0', apiVersion: 1, capabilities: [] }, over)
const stateOf = (ids) => {
+137
View File
@@ -0,0 +1,137 @@
'use strict'
/* 插件文本节点 + 上游参考图:任务文本不能被丢空(2026-12-03)
*
* 守的是什么:
* · 一图一任务:相册 N 张 → N 个任务,每个只带自己那张图
* · 批量模式:按 ALBUM_BATCH_MAX(12) 分批 → ⌈N/12⌉ 个任务,每批多张参考图
* · 组合扇出:相册接在组合前面时必须变成 N 个任务(否则会被压成 1 个任务 + N 张图)
* · 零回归:没有相册时,ref/组合/中继的任务数逐字不变
*
* 用真实模块 + 最小注入实现(不切片 app.js):依赖全是纯函数,本文件里各写一份等价实现。
*/
const assert = require('assert')
const fs = require('fs')
const path = require('path')
const vm = require('vm')
const src = fs.readFileSync(path.join(__dirname, '..', 'src', 'generation-task-graph.js'), 'utf8')
const box = { console }
vm.runInNewContext(src, box)
const TG = box.IWBWTaskGraph
assert.ok(TG && typeof TG.create === 'function', '模块应导出 IWBWTaskGraph.create')
// ── 最小注入依赖(语义与 app.js 一致,但实现从简)──
const byPos = (a, b) => (Number(a.x) - Number(b.x)) || (Number(a.y) - Number(b.y)) || String(a.id).localeCompare(String(b.id))
const dedupeTaskRefs = (list) => { const seen = new Set(), out = []; for (const r of (list || [])) { if (!r || seen.has(r.id)) continue; seen.add(r.id); out.push(r) } return out }
const refArgsOf = (rn) => { const d = (rn && rn.data) || {}; if (d.localName) return [{ type: 'local', name: d.localName }]; if (d.data) return [{ type: 'data', value: d.data, name: d.name || 'ref.png' }]; if (typeof d.url === 'string') return d.url.trim() ? [{ type: 'url', value: d.url.trim() }] : []; if (d.url) return [{ type: 'data', value: d.url, name: d.name || 'ref.png' }]; return [] }
const isBatchSrc = (n) => !!n && (n.type === 'prompt' || n.type === 'textout' || n.type === 'combine' || n.type === 'batch' || (n.data && n.data.outKind === 'prompt'))
const batchJoinedText = (data, base) => String((data && data.combined) || base || '')
const batchSrcText = (n) => String((n && n.data && (n.data.combined || n.data.text)) || '')
const wDedupeTaskIds = (list) => { const seen = new Set(), out = []; for (const t of (list || [])) { if (!t || seen.has(t.id)) continue; seen.add(t.id); out.push(t) } return out }
const tg = TG.create({
sortByPosition: (arr) => arr.slice().sort(byPos),
compareCanvasImageOrder: byPos,
compareCanvasTextOrder: byPos,
dedupeTaskRefs,
isBatchSrc,
batchJoinedText,
wDedupeTaskIds,
refArgsOf,
batchSrcText,
standardSizeOf: (n) => ({ w: 1024, h: 1024 }),
})
let failed = 0
const ok = (name, cond, extra) => { if (!cond) failed++; console.log((cond ? '✓ ' : '✗ ') + name + (cond || !extra ? '' : ' · ' + extra)) }
const ref = { id: 'r1', type: 'ref', x: 0, y: 0, data: { url: 'data:image/png;base64,AAA' } }
const tpl = { id: 't1', type: 'plugin:promptlib:ptpl', x: 100, y: 0, data: { text: '我要画一只猫', outKind: 'prompt' } }
const gen = { id: 'g1', type: 'gen', x: 200, y: 0, data: { model: 'm' } }
const e1 = { id: 'e1', from: 'r1', to: 't1' }
const e2 = { id: 'e2', from: 't1', to: 'g1' }
// 1) 插件文本节点接了参考图:文本必须保留,图也要带上
let tasks = tg.buildGenerationTasksV2(gen, [ref, tpl, gen], [e1, e2])
ok('插件文本节点 + 上游参考图:任务文本保留', tasks.length === 1 && tasks[0].text === '我要画一只猫', JSON.stringify(tasks.map((t) => t.text)))
ok('插件文本节点 + 上游参考图:参考图带上', tasks.length === 1 && tasks[0].refs.length === 1)
// 2) 没有上游参考图:行为不变
tasks = tg.buildGenerationTasksV2(gen, [tpl, gen], [e2])
ok('无上游参考图:文本仍是自己的', tasks.length === 1 && tasks[0].text === '我要画一只猫' && tasks[0].refs.length === 0)
// 3) 插件节点自己没有文本、只带上游图:仍然允许「纯图任务」(不新增文本)
const tplEmpty = { id: 't1', type: 'plugin:promptlib:ptpl', x: 100, y: 0, data: { text: '', outKind: 'prompt' } }
tasks = tg.buildGenerationTasksV2(gen, [ref, tplEmpty, gen], [e1, e2])
ok('空文本 + 上游图:任务仍成立且文本为空', tasks.length === 1 && tasks[0].text === '' && tasks[0].refs.length === 1)
// 4) 上游是文本节点(非 ref):自己的文本仍然优先
const textNode = { id: 'x1', type: 'textout', x: -50, y: 0, data: { text: '上游文本' } }
const ex = { id: 'ex', from: 'x1', to: 't1' }
tasks = tg.buildGenerationTasksV2(gen, [textNode, tpl, gen], [ex, e2])
ok('上游文本 + 自己文本:自己的优先', tasks.length === 1 && tasks[0].text === '我要画一只猫', JSON.stringify(tasks.map((t) => t.text)))
// 5) 对照:内置 prompt 节点行为不变
const promptNode = { id: 'p1', type: 'prompt', x: 100, y: 0, data: { text: '内置提示词' } }
const ep = { id: 'ep', from: 'p1', to: 'g1' }
tasks = tg.buildGenerationTasksV2(gen, [ref, promptNode, gen], [{ id: 'er', from: 'r1', to: 'p1' }, ep])
ok('内置 prompt 节点 + 上游图:文本保留', tasks.length === 1 && tasks[0].text === '内置提示词' && tasks[0].refs.length === 1)
// 6) 两张参考图 → 插件文本节点:必须合并成 1 个任务(图1+图2 一起带)
{
const r2 = { id: 'r2', type: 'ref', x: 0, y: 100, data: { url: 'data:image/png;base64,BBB' } }
const edges2 = [{ id: 'e1', from: 'r1', to: 't1' }, { id: 'e1b', from: 'r2', to: 't1' }, e2]
const ts = tg.buildGenerationTasksV2(gen, [ref, r2, tpl, gen], edges2)
ok('两张参考图 → 1 个任务', ts.length === 1, JSON.stringify(ts.map((t) => t.refs.length)))
ok('两张参考图 → refs=2 且文本保留', ts.length === 1 && ts[0].refs.length === 2 && ts[0].text === '我要画一只猫')
}
// 7) 两张参考图 + 空文本的插件节点:仍是 1 个任务(纯图任务)
{
const r2 = { id: 'r2', type: 'ref', x: 0, y: 100, data: { url: 'data:image/png;base64,BBB' } }
const tplEmpty2 = { id: 't1', type: 'plugin:promptlib:ptpl', x: 100, y: 0, data: { text: '', outKind: 'prompt' } }
const edges2 = [{ id: 'e1', from: 'r1', to: 't1' }, { id: 'e1b', from: 'r2', to: 't1' }, e2]
const ts = tg.buildGenerationTasksV2(gen, [ref, r2, tplEmpty2, gen], edges2)
ok('两张参考图 + 空文本 → 1 个任务、refs=2', ts.length === 1 && ts[0].text === '' && ts[0].refs.length === 2, JSON.stringify(ts.map((t) => ({ t: t.text, r: t.refs.length }))))
}
// 7b) 一张图 + 一段文本 → 插件文本节点:合并成 1 个任务(不能多生成一张没图的)
{
const txtNode = { id: 'x9', type: 'textout', x: -50, y: 20, data: { text: '上游文案' } }
const edges2 = [{ id: 'e1', from: 'r1', to: 't1' }, { id: 'ex9', from: 'x9', to: 't1' }, e2]
const ts = tg.buildGenerationTasksV2(gen, [ref, txtNode, tpl, gen], edges2)
ok('图 + 文本 → 1 个任务', ts.length === 1, JSON.stringify(ts.map((t) => ({ t: t.text, r: t.refs.length }))))
ok('图 + 文本 → 自己的文本优先、refs=1', ts.length === 1 && ts[0].text === '我要画一只猫' && ts[0].refs.length === 1)
}
// 7c) 图 + 文本(节点自己没文本)→ 用上游文本、refs=1
{
const txtNode = { id: 'x9', type: 'textout', x: -50, y: 20, data: { text: '上游文案' } }
const tplEmpty3 = { id: 't1', type: 'plugin:promptlib:ptpl', x: 100, y: 0, data: { text: '', outKind: 'prompt' } }
const edges2 = [{ id: 'e1', from: 'r1', to: 't1' }, { id: 'ex9', from: 'x9', to: 't1' }, e2]
const ts = tg.buildGenerationTasksV2(gen, [ref, txtNode, tplEmpty3, gen], edges2)
ok('图 + 文本(节点无文本)→ 1 个任务、用上游文本', ts.length === 1 && ts[0].text === '上游文案' && ts[0].refs.length === 1, JSON.stringify(ts.map((t) => ({ t: t.text, r: t.refs.length }))))
}
// 8) 回归:相册(2 张) → 插件文本节点 → 仍是一图一任务(不能被压平)
{
const album = { id: 'a1', type: 'plugin:album:album', x: 0, y: 0, data: { outKind: 'images', items: [{ src: 'data:image/png;base64,AAA' }, { src: 'data:image/png;base64,BBB' }] } }
const ea = { id: 'ea', from: 'a1', to: 't1' }
const ts = tg.buildGenerationTasksV2(gen, [album, tpl, gen], [ea, e2])
ok('相册(2 张) → 插件文本节点:仍 2 个任务、各带 1 张', ts.length === 2 && ts.every((t) => t.refs.length === 1), JSON.stringify(ts.map((t) => t.refs.length)))
ok('相册 → 插件文本节点:每个任务都带自己的文本', ts.every((t) => t.text === '我要画一只猫'))
}
// 9) 回归:两个文本上游 → 插件节点:仍是 2 个任务
{
const x1 = { id: 'x1', type: 'textout', x: -100, y: 0, data: { text: '上游A' } }
const x2 = { id: 'x2', type: 'textout', x: -100, y: 100, data: { text: '上游B' } }
const ex1 = { id: 'ex1', from: 'x1', to: 't1' }
const ex2 = { id: 'ex2', from: 'x2', to: 't1' }
const ts = tg.buildGenerationTasksV2(gen, [x1, x2, tpl, gen], [ex1, ex2, e2])
ok('两个文本上游 → 仍 2 个任务', ts.length === 2, JSON.stringify(ts.map((t) => t.text)))
}
if (failed) { console.error('plugin-text-node-refs: ' + failed + ' 项失败'); process.exit(1) }
console.log('plugin-text-node-refs checks passed')
+9 -3
View File
@@ -14,6 +14,8 @@ const React = {
return { type, props: Object.assign({}, props || {}, { children }) }
},
useState(init) { return [init, function () {}] },
// 183 起 ResultImg 用 useEffect 订阅落地状态;假 React 必须提供(既有失败,与本次回滚无关)
useEffect(fn) { try { const c = fn && fn(); if (typeof c === 'function') c() } catch (e) { /* ignore */ } },
}
const sandbox = { React }
vm.runInNewContext(fs.readFileSync(path.join(root, 'src', 'ui-components.js'), 'utf8'), sandbox)
@@ -48,10 +50,14 @@ const ov = sandbox.IWBResultDownloadOverlay({
onCopyRef: () => { copied++ },
children: { type: 'img', props: {} },
})
const bar = ov.props.children.find((c) => c && c.props && c.props.className === 'iwb-dl-bar')
assert.ok(bar, '浮层必须渲染底部条')
const btns = bar.props.children.filter(Boolean)
// 2026-12-03:下载浮层从底部横条改成右下角圆形图标(只占一个角)
const corner = ov.props.children.find((c) => c && c.props && c.props.className === 'iwb-dl-corner')
assert.ok(corner, '浮层必须渲染右下角操作区')
const btns = corner.props.children.filter(Boolean)
assert.strictEqual(btns.length, 2, '浮层应有复制 + 下载两个按钮')
assert.ok(String(btns[0].props.className).indexOf('iwb-dl-round') >= 0, '复制按钮必须是圆钮')
assert.ok(String(btns[1].props.className).indexOf('iwb-dl-round-primary') >= 0, '下载按钮必须是主圆钮')
assert.strictEqual(btns[1].props['aria-label'], '下载', '图标按钮必须有 aria-label(可发现性)')
btns[0].props.onClick({ stopPropagation() {} })
btns[1].props.onClick({ stopPropagation() {} })
btns[1].props.onPointerDown({ stopPropagation() { stopped++ } })
+33 -3
View File
@@ -125,7 +125,12 @@ const MAX_APP_COMPONENT_LINES = 423
// 2026-11-10 演进:首版 1034 → 拆完 10 个块后 SettingsModal 落到 531。
// 按项目纪律(棘轮收紧到实测值本身、零余量,与 MAX_APP_JS_LINES 余量 1 行同理)
// 上限设为 **531** —— 任何"组件又长大了"都会立刻打红,这才是有意义的守卫。
const MAX_SRC_COMPONENT_LINES = 531
const MAX_SRC_COMPONENT_LINES = 531 // 2026-12-02 纳入记账基线(此前无注释);src 内单个组件最大行数只减不增,上调须在本行写「日期 + 相对上一版的差 + 原因」(守卫 B3)
// src 模块挂到 window/global 的写入口数量(2026-12-02 实测 121):只减不增。
// −1(122→121)2026-12-02:插件画布桥新增 IWBPluginCanvasBridge(+1),同时删掉两个从未被引用的工厂导出
// IWBStorageRuntimeFactory / IWBRuntimeMetricsFactory(−2,实例导出 IWBStorageRuntime / IWBRuntimeMetrics 仍在用)。
// 新增模块请先看能不能挂到已有命名空间;确需新增则同批下调基线。
const MAX_SRC_GLOBALS = 124 // 2026-12-03 +1(123→124):新增 IWBPluginQueue(任务队列能力桥,与 gallery 同构)。之后只减不增。
// ── app.js 总行数 & Workbench 行数棘轮(只减不增)────────────────────────────
// 动机(2026-10-29 用户提问"以后新功能会不会还往 app.js 里加"):
// 上面的 MAX_APP_COMPONENT_LINES **明确跳过 Workbench**,而且此前**没有** app.js 总行数守卫
@@ -170,7 +175,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 = 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_LINES = 9368 // +11(9,357→9,368)2026-12-03:输出节点预览改图库条目(wPreviewEntryOf)。之前 +3 下载并发接线;+9 下载命名/队列预览;+199 任务队列装配。之后只减不增。
const MAX_APP_JS_SHARE = 0.40
// ── 历史记账(供回溯,逐条保留)──────────────────────────────────────────────
@@ -213,7 +218,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 = 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 装配)
const MAX_WORKBENCH_LINES = 2690 // +3(2,687→2,690)2026-12-03:下载改系统网络栈(rustFetch)与并发设置接线。之前 +1 队列预览;+153 任务队列装配。之后只减不增。
// 2026-11-18 v3.25.21:模态层指针守卫(2 行)
// 实测 3090 → 2998(省 92):① 生成取消族 cancelRunsFor/cancelRun/cancelTaskJobs
// → src/runtime-workbench-logic.js 的 createCancelActions(−53);② 工作区列表写回族
@@ -460,6 +465,31 @@ assert.ok(dirPins.total <= MAX_DIR_SOURCE_PINS,
'(' + worst.lines + ') 于 ' + worst.file + ')—— 请按职责拆分,不要改上限')
}
// 2026-12-02:全局写入口棘轮(只减不增)——新模块最容易在这里"悄悄多一个 global"
{
const srcDir2 = path.join(root, 'src')
let g = 0
for (const f of fs.readdirSync(srcDir2).filter((n) => n.endsWith('.js'))) {
const t = fs.readFileSync(path.join(srcDir2, f), 'utf8')
g += (t.match(/^\s*global\.[A-Za-z0-9_]+\s*=/gm) || []).length
}
assert.ok(g <= MAX_SRC_GLOBALS,
'src 的 global.* 写入口不得超过 ' + MAX_SRC_GLOBALS + '(现 ' + g + ')—— 优先挂已有命名空间;确需新增请同批下调本上限')
}
// 2026-12-02(B3):棘轮上限上调必须自证 —— 行内要有日期 + 相对上一版的差(或"基线"说明)+ 原因,
// 否则"谁写谁抬"就成了橡皮图章(只改数字、评审看不出为什么)。
{
const selfSrc = fs.readFileSync(path.join(__dirname, 'source-text-ratchet-test.js'), 'utf8')
for (const name of ['MAX_APP_JS_LINES', 'MAX_WORKBENCH_LINES', 'MAX_SRC_COMPONENT_LINES']) {
const line = selfSrc.split('\n').find((l) => l.indexOf('const ' + name + ' =') === 0) || ''
const hasDate = /\d{4}-\d{2}-\d{2}/.test(line)
const hasDelta = /[+\u2212-]\d+/.test(line) || line.indexOf('基线') >= 0
assert.ok(hasDate && hasDelta && line.length > 40,
name + ' 必须带「日期 + 相对上一版的差(或基线说明)+ 原因」才能改上限(B3);现在是:' + line.slice(0, 80))
}
}
assert.ok(total <= MAX_APP_JS_LINES,
'app.js 总行数不得增加(现 ' + total + ' / 上限 ' + MAX_APP_JS_LINES + ')'
+ ' —— 新功能请落到 src/<domain>-*.js;app.js 只做装配(状态 + 注入 + 分派)。'
Loaded 100 of 103 files, more files were not shown because too many files have changed in this diff. Show more