Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
48a68a7e8a | ||
|
|
ec9ca02a82 | ||
|
|
c3b76ec444 | ||
|
|
dc5c1a6b0a | ||
|
|
a8b9296558 | ||
|
|
ab8579dcef | ||
|
|
9cbd5fa673 | ||
|
|
ac6a0062c3 | ||
|
|
2e62769421 | ||
|
|
42033a54ab | ||
|
|
48232bec5c | ||
|
|
7b2bb0d58e | ||
|
|
1c7cbd9726 | ||
|
|
630949eac7 | ||
|
|
9edc635ed8 | ||
|
|
a0f86bf09c | ||
|
|
f5859b7596 | ||
|
|
3cc53eec4b | ||
|
|
380d39146d | ||
|
|
81e73bd89b | ||
|
|
4cf0947e76 | ||
|
|
ba2918ff95 | ||
|
|
bb9e7f487f | ||
|
|
6102b7358a | ||
|
|
287da25a24 | ||
|
|
14457c04f2 | ||
|
|
e996975bf9 | ||
|
|
d81c085972 | ||
|
|
aeba3d3785 | ||
|
|
6d9842ecd3 | ||
|
|
f948a45fcc | ||
|
|
c3bbe1a75a | ||
|
|
0b9d7d4cfc | ||
|
|
7d106d2f2c | ||
|
|
a95e38d2f7 | ||
|
|
f0ccaf79d3 | ||
|
|
ae6549354d | ||
|
|
32e2c037ff | ||
|
|
8c115c6f7d | ||
|
|
308324a749 | ||
|
|
8bac6bc701 | ||
|
|
c7f7d54db8 | ||
|
|
9463db2538 | ||
|
|
5246a1ef85 | ||
|
|
f8d547353f | ||
|
|
61dbbb83d3 | ||
|
|
fd5f7c7a17 | ||
|
|
61c31b3203 | ||
|
|
75e81ebc29 | ||
|
|
aa9a54cdc2 | ||
|
|
7caa564ea1 | ||
|
|
f62ec18b0f | ||
|
|
4e8f3215a5 | ||
|
|
ee09343011 | ||
|
|
2b2eb263cd | ||
|
|
25335ddd3d | ||
|
|
2c1a7e01e9 | ||
|
|
d86031bd76 | ||
|
|
6fe52f0ece | ||
|
|
2ffe95f0aa | ||
|
|
f4ab497c73 | ||
|
|
2f79d12c54 | ||
|
|
95b6f45bfd | ||
|
|
b59120beb4 | ||
|
|
49d11744a6 | ||
|
|
420e87628e | ||
|
|
ebde29c9d7 | ||
|
|
15b3352f8f | ||
|
|
8fdcf3b3dc | ||
|
|
fa0b97bdf6 | ||
|
|
37fe86c88c | ||
|
|
c20834b623 | ||
|
|
10ad8618d7 | ||
|
|
fd1a9c636b | ||
|
|
8398a389fe | ||
|
|
8487ef2c91 | ||
|
|
9f88b3a71c | ||
|
|
f0c39fb1c4 | ||
|
|
5fe41ffad4 | ||
|
|
7f38d31ac2 | ||
|
|
301669a148 | ||
|
|
d36bbe3b91 | ||
|
|
768d01360d | ||
|
|
fce4fedad6 | ||
|
|
a6d4f5cc63 | ||
|
|
dde8e861e8 | ||
|
|
e8894d6864 | ||
|
|
3a70e16ead | ||
|
|
c346256115 | ||
|
|
2d3aba2ed2 | ||
|
|
9893d1121d | ||
|
|
1b36960e4f | ||
|
|
0bc96494e9 | ||
|
|
dd24679c3a | ||
|
|
9c8867fdae | ||
|
|
c0e4efc06e | ||
|
|
9222144d22 | ||
|
|
ac4446d4a0 | ||
|
|
1606e0cd7c | ||
|
|
17a8681897 | ||
|
|
c34cadc7d9 | ||
|
|
a4d0f8ab79 | ||
|
|
a56ad1829b | ||
|
|
bbd1e090b5 | ||
|
|
fd76c76589 | ||
|
|
71cd7bc41e | ||
|
|
af9d261636 | ||
|
|
7c20ca90ee | ||
|
|
8755e7327c | ||
|
|
dc311ec0a9 | ||
|
|
eddd635846 | ||
|
|
c22d28320e | ||
|
|
c6e3488aed | ||
|
|
e1c4501f00 | ||
|
|
42304bc88f | ||
|
|
f83ed2e08a | ||
|
|
559945281f | ||
|
|
fcbeab6cb1 | ||
|
|
499f16a2df | ||
|
|
1677f86129 | ||
|
|
8872c2fa47 | ||
|
|
56b39b9829 | ||
|
|
711822092e | ||
|
|
c330d3ecf8 | ||
|
|
65ea7dff9d | ||
|
|
409233670c | ||
|
|
a9f36c26e7 | ||
|
|
8b539ca03e | ||
|
|
4315072394 | ||
|
|
8742bbd256 | ||
|
|
b674aae1bc | ||
|
|
3563e54bd0 | ||
|
|
d5787ca44a | ||
|
|
c411fbe851 | ||
|
|
bda61026ff | ||
|
|
3ab39fd522 | ||
|
|
3993673ee6 | ||
|
|
c962859837 | ||
|
|
0276efd813 | ||
|
|
68480551c6 | ||
|
|
434cf0d92d | ||
|
|
eb19811c8f | ||
|
|
7228436b6f | ||
|
|
a5b8b8b693 | ||
|
|
9f4abdbf44 | ||
|
|
39294cec38 | ||
|
|
1862d55563 | ||
|
|
b756ae0ce7 | ||
|
|
71d4a34197 | ||
|
|
5df4f626ee | ||
|
|
ff6e8ec883 | ||
|
|
fe94d89a46 | ||
|
|
d3ef0f3940 | ||
|
|
ae41246f5a | ||
|
|
1fed4d4df3 | ||
|
|
73936ae076 | ||
|
|
67a379a0cf | ||
|
|
48829aea5d | ||
|
|
61b6df94c5 | ||
|
|
02ccb87ec7 | ||
|
|
5137f38b7f | ||
|
|
2c46b0b756 | ||
|
|
b4d8a7ba6a | ||
|
|
a594efc64a | ||
|
|
a4928d472c | ||
|
|
a8b0999a1b | ||
|
|
ce8a837923 | ||
|
|
5947e0c18b | ||
|
|
a204298fee | ||
|
|
955423eac6 | ||
|
|
7ff3dd57f4 | ||
|
|
2cadad7ea7 | ||
|
|
6ff6ab6a9f | ||
|
|
a1ac3dffe1 | ||
|
|
4b7dc6ee40 | ||
|
|
a409fa6206 | ||
|
|
b2a0135467 | ||
|
|
c6e259a2b0 | ||
|
|
a8c2cd9d97 | ||
|
|
bca71e53b9 | ||
|
|
200c1d35b1 | ||
|
|
fae497289d | ||
|
|
0cf7af230f | ||
|
|
08367fc707 | ||
|
|
04d309435e | ||
|
|
29d8c22d53 | ||
|
|
8c47ef75fe | ||
|
|
3707eb6f2c | ||
|
|
80f19a74da | ||
|
|
e4a9fdacd0 | ||
|
|
78ddeee40a | ||
|
|
4abdd2323a | ||
|
|
036865a201 | ||
|
|
04c87ff0f6 | ||
|
|
b721febd63 | ||
|
|
5728efd9b4 | ||
|
|
49a35e5dc3 | ||
|
|
e8806eb705 | ||
|
|
19e2fcd690 | ||
|
|
30cf375ea0 | ||
|
|
32ac08faeb | ||
|
|
795a67bf80 | ||
|
|
2429577637 |
No files matched your search
+198
@@ -16,6 +16,204 @@
|
||||
> 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.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),原因已写在常量注释。
|
||||
|
||||
## 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)平移稳定性与诊断补强
|
||||
|
||||
- 平移不再按视口裁剪连线(新进入区域的连线不再迟到);平移期不冻结边线层,改为按帧重画。
|
||||
|
||||
+5
-4
@@ -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 141 个单测文件(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,345**(另守「占总源码 ≤ 40%」,见 `MAX_APP_JS_SHARE`) |
|
||||
| `Workbench()` 行数 | 同上 `MAX_WORKBENCH_LINES` | **2,686** |
|
||||
| 单组件行数(不含 Workbench)| 同上 `MAX_APP_COMPONENT_LINES` | **423** |
|
||||
|
||||
三条都是**只减不增**。确需在 app.js 增长时,必须**同步上调上限并在 commit 里写理由**(等于显式记账,不会悄悄发生)。
|
||||
@@ -195,8 +195,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
@@ -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
@@ -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 纪律
|
||||
|
||||
|
||||
@@ -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, 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,11 @@ 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(下载命名规范):同一张图,不论从输出节点、预览还是图库下载,都用图库行名。
|
||||
// 未落地的图没有行名,调用方回退自己的默认名。
|
||||
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 +3711,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 +4023,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 +4044,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 +5725,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, 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 +6129,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,16 +6217,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 : '')
|
||||
// v3.26.175:覆盖式替换必须**同时清掉 localRef / ref**。
|
||||
// 节点体的取图优先级是 localRef → data → url,旧实现只改 data,
|
||||
// 于是旧的本地引用(及其缓存的 objectURL)一直赢,新图不显示;
|
||||
// 直到用户点「立即回收内存」把引用缓存清空,才轮到 data 露出来。
|
||||
const base = { data: String(dataUrl), url: '', localRef: null, ref: null }
|
||||
return orig ? Object.assign(base, { orig }) : base
|
||||
}
|
||||
|
||||
function Workbench() {
|
||||
// runtime-workbench-logic 模块的 app.js 模块级依赖:渲染前注入一次(常量/纯函数,无陈旧值风险)
|
||||
if (IWWorkbenchLogic && !IWWorkbenchLogic.__iwbInjected) {
|
||||
@@ -6130,116 +6356,117 @@ 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
|
||||
fetchBytes: window.IWBImageIngest.createFetchBytes({ blobFromSrc: wBlobFromSrc, blobToDataUrl: wImgBlobToDataUrl }),
|
||||
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
|
||||
},
|
||||
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
|
||||
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 {
|
||||
const line = 'plugin-img set id=' + id + ' len=' + String(dataUrl || '').length + ' prevLocal=' + (t.data && t.data.localRef ? 'Y' : 'N')
|
||||
const SF = window.IWBStorageFile
|
||||
if (SF && typeof SF.logLine === 'function') SF.logLine(line)
|
||||
wLog('plugin-img', line)
|
||||
} catch (eL) { /* ignore */ }
|
||||
updateNode(id, origImagePatch(t.data || {}, String(dataUrl)))
|
||||
// v3.26.174:同步失效这张图的缩略图/URL 缓存并触发重渲染(与 saveNodeImage 同因)
|
||||
try { const k = wDisplayThumbKeyOf(String(dataUrl || '')); if (k) { displayThumbs.delete(k); displayThumbsSm.delete(k) } } catch (e1) { /* ignore */ }
|
||||
try { if (typeof wThumbBump === 'function') wThumbBump() } catch (e2) { /* ignore */ }
|
||||
try { showToast('已替换图片', 'ok') } catch (eT) { /* ignore */ }
|
||||
return true
|
||||
},
|
||||
saveNodeImage: (id, dataUrl) => {
|
||||
if (!IWWorkbenchLogic) return Promise.resolve({ ok: false, error: '画布能力未就绪' })
|
||||
return IWWorkbenchLogic.saveNodeImage({ refs, commitCanvas, saveNow, readWorkspace: () => WorkspaceStore.read(null), activeWsId: () => activeWsIdRef.current || activeWsId, origPatch: origImagePatch }, id, dataUrl).then((r) => {
|
||||
// v3.26.174:写回成功后必须让「这张图」重新出图 —— 之前只改了节点数据,
|
||||
// 缩略图/URL 缓存与节点体都没失效,界面一直显示旧图或空白,
|
||||
// 直到用户点「立即回收内存」清缓存才显示出来(CPU 期间一直在反复重绘/重解码)。
|
||||
// v3.26.176:把写回结果写进 _boot.log(kind=plugin-img),复现一次就能看到到底哪步没生效
|
||||
try {
|
||||
const nd = (refs.nodes || []).find((x) => x && x.id === id) || null
|
||||
const keys = nd && nd.data ? Object.keys(nd.data).join(',') : ''
|
||||
const hasLocal = nd && nd.data ? (nd.data.localRef ? 'Y' : 'N') : '?'
|
||||
const line = 'plugin-img save id=' + id + ' ok=' + (r && r.ok) + ' err=' + String((r && r.error) || '-') + ' len=' + String(dataUrl || '').length + ' localRef=' + hasLocal + ' keys=' + keys
|
||||
try { const SF = window.IWBStorageFile; if (SF && typeof SF.logLine === 'function') SF.logLine(line) } catch (eB) { /* ignore */ }
|
||||
wLog('plugin-img', line)
|
||||
} catch (eL) { /* ignore */ }
|
||||
try {
|
||||
if (r && r.ok) showToast('已覆盖原图', 'ok')
|
||||
else showToast('覆盖失败:' + String((r && r.error) || '未知原因'), 'err')
|
||||
} catch (eT) { /* ignore */ }
|
||||
if (r && r.ok) {
|
||||
// v3.26.182:写回后立刻把大 base64 引用化(与「立即回收内存」③ 同一动作)。
|
||||
// 1.2MB 的 data URL 直接挂在 <img src> 上会让渲染/合成持续吃 CPU,
|
||||
// 转成 {__blob} 引用后显示走 objectURL,DOM 里只剩短 URL。
|
||||
try {
|
||||
if (typeof wImgRefWrite === 'function' && String(dataUrl || '').length > 200 * 1024) {
|
||||
Promise.resolve(wImgRefWrite(String(dataUrl))).then((ref) => {
|
||||
if (!ref) return
|
||||
// 无损引用化:不重新压缩,只把字节搬进 blob 存储,DOM 改用 objectURL
|
||||
try { updateNode(id, { data: ref, url: '', localRef: ref, ref: ref }) } catch (e3) { /* ignore */ }
|
||||
try { if (typeof wThumbBump === 'function') wThumbBump() } catch (e4) { /* ignore */ }
|
||||
}).catch(() => { /* ignore */ })
|
||||
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
|
||||
}
|
||||
} catch (eI) { /* ignore */ }
|
||||
try {
|
||||
const k = wDisplayThumbKeyOf(String(dataUrl || ''))
|
||||
if (k) { displayThumbs.delete(k); displayThumbsSm.delete(k) }
|
||||
} catch (e1) { /* ignore */ }
|
||||
try { if (typeof wThumbBump === 'function') wThumbBump() } catch (e2) { /* ignore */ }
|
||||
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)
|
||||
}
|
||||
}
|
||||
return r
|
||||
})
|
||||
} catch (eG) { /* 图库写入不得影响出图 */ }
|
||||
},
|
||||
}
|
||||
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) // 顶部 ⋯ 三点菜单(展开态)
|
||||
@@ -6367,6 +6594,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([])
|
||||
@@ -7951,7 +8185,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)), [])
|
||||
@@ -8017,10 +8251,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 = []
|
||||
@@ -8039,6 +8283,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({
|
||||
@@ -8070,7 +8451,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' },
|
||||
@@ -8168,7 +8549,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'),
|
||||
@@ -8184,7 +8568,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' : ''),
|
||||
@@ -8342,7 +8730,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(),
|
||||
@@ -8499,7 +8887,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))
|
||||
@@ -8706,6 +9095,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,供插件自持图片
|
||||
@@ -8737,6 +9127,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
@@ -45,7 +45,7 @@
|
||||
|---|---|
|
||||
| `nodeActions` | 给节点右键/工具条加自定义动作 |
|
||||
| `canvas` | 只读访问画布(`getNodes` 等) |
|
||||
| `canvasWrite` | 写画布(`setNodeImage` 等),**必须同时声明** |
|
||||
| `canvasWrite` | 写画布(`setNodeImage` / `saveNodeImage`),接口合并进 `ctx.canvas`(无 `ctx.canvasWrite`),**必须同时声明** |
|
||||
| `events` | 订阅宿主事件 |
|
||||
| `storage` | 插件私有持久化(按插件 id 隔离) |
|
||||
|
||||
|
||||
@@ -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 |
@@ -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>
|
||||
@@ -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>
|
||||
@@ -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`)。
|
||||
@@ -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)。
|
||||
@@ -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 节点画布下打开队列页,滚动不掉帧
|
||||
@@ -1,7 +1,7 @@
|
||||
# 现状架构与性能事实基线(桌面版)
|
||||
|
||||
> **本文档是什么**:现状**事实快照**,不是规范。用途:任何性能 / 内存 / 存储相关改动,先对齐这里的现实,避免把已经调好的东西改坏。
|
||||
> 日期 **2026-10-20**(**2026-11-16 复算 · v3.24.85**)| 基线(**最近一次 bump 版本的提交**,不是主干 HEAD)`main = 7856afd`(线上 `v3.26.169+7856afd` —— 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 = dc5c1a6b`(线上 `v3.26.237+dc5c1a6b` —— 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,879 行**(**双层预算**:绝对上限 8,743 / 占总源码 ≤ 40%,现 **26.1%**,2026-11-12 起;此前为单一上限 8,509、零余量);`Workbench()` = **2,469 行**(上限 **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,169 行,`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,345 行**(**双层预算**:绝对上限 9,345 / 占总源码 ≤ 40%,现 **26.3%**,2026-11-12 起;此前为单一上限 8,509、零余量);`Workbench()` = **2,686 行**(上限 **2,686**,余量 0;2026-11-16 把生成取消族 `cancelRunsFor`/`cancelRun`/`cancelTaskJobs` 与工作区列表写回族 `persistWs`/`duplicateWs` 搬进 `src/runtime-workbench-logic.js`(`createCancelActions` / `createWorkspaceListActions`),并删掉全仓零调用的 `runAll`,3090 → 2,998);大量逻辑已抽到 `src/*.js`(现 **128** 个模块 / 26,194 行,`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、不共享凭据。
|
||||
|
||||
|
||||
@@ -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 且字节数一致。
|
||||
@@ -0,0 +1,40 @@
|
||||
# 图片读取与下载口径(2026-12-03)
|
||||
|
||||
> 目的:同一张图,不管从输出节点、图库、任务队列还是预览打开/下载,**取源顺序与文件名只有一套**。
|
||||
> 新代码按本文写;`tests/image-download-contract-test.js` 会拦住已知的偏离写法。
|
||||
|
||||
## 1. 取源顺序(桌面端)
|
||||
|
||||
预览 / 下载统一按这个顺序取,**能拿到上一层就不再往下走**:
|
||||
|
||||
1. `origIdb` —— 图库行写入的原图字节(新记录)
|
||||
2. `images/gallery/<文件>` —— 本地原图文件(老记录没有 `origIdb`;入口 `IWBStorageFile.galleryOriginalOf` / `galleryOriginalBlob`)
|
||||
3. 会话本地副本 —— `IWBImageIngestView.localUrl`(任务队列专用,重启即失效)
|
||||
4. 远程 URL —— **仅下载/插入**可兜底
|
||||
5. 320 缩略图(`row.idb`)—— **只做列表/宫格/预览的占位底图,永远不当原图**
|
||||
|
||||
硬规则:
|
||||
|
||||
- **预览不许直连远程**。本地没有原图就提示「这张图还没有下载到本地」,不打开预览、不放大缩略图。
|
||||
- 下载必须**本地优先**:`wResolveOutputSrc` 先 `origIdb` → 本地文件 → 数据 → 远程。
|
||||
- 缩略图可以「先出画面」,但只作为 `ImagePreview` / 节点体的底图,原图解析到后必须换掉。
|
||||
|
||||
## 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` 只允许作为「还没落地的兜底」)。
|
||||
|
||||
## 3. 相关入口
|
||||
|
||||
- `src/storage-file.js`:`galleryOriginalOf(row, max)`(预览用,原生按尺寸解码)、`galleryOriginalBlob(row)`(下载用,原始字节)
|
||||
- `app.js`:`wResolveOutputSrc`(下载取源)、`wOutNameOf`(命名)
|
||||
- `src/ui-canvas-view.js`:`ImagePreview` 统一解析 `{__gallery, name, origIdb, idb}`
|
||||
@@ -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 —— **换机器必须重设阈值**,注释里已写明
|
||||
@@ -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. 面板
|
||||
|
||||
|
||||
@@ -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
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "image-workbench-web",
|
||||
"private": true,
|
||||
"version": "3.26.182",
|
||||
"version": "3.26.238",
|
||||
"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/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/ui-minimap-fit-test.js && node tests/ui-workbeLine 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
@@ -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 },
|
||||
|
||||
@@ -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"
|
||||
}
|
||||
}
|
||||
@@ -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; }
|
||||
|
||||
+20
-9
@@ -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"
|
||||
}
|
||||
},
|
||||
{
|
||||
@@ -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"
|
||||
}
|
||||
}
|
||||
]
|
||||
@@ -140,5 +140,16 @@
|
||||
"批量",
|
||||
"出图"
|
||||
]
|
||||
},
|
||||
"taskqueue": {
|
||||
"name": "任务队列",
|
||||
"desc": "全局生图记录:链接/状态/画布节点;下载落地图库、重试、复制链接、定位节点(数据由宿主保存)",
|
||||
"author": "official",
|
||||
"icon": "⏳",
|
||||
"color": "#eef6f6",
|
||||
"tags": [
|
||||
"工具",
|
||||
"记录"
|
||||
]
|
||||
}
|
||||
}
|
||||
+5
-2
@@ -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) {
|
||||
+19
-2
@@ -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 })
|
||||
@@ -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)
|
||||
@@ -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"
|
||||
}
|
||||
}
|
||||
@@ -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; } }
|
||||
@@ -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 + ' 条)')
|
||||
})()
|
||||
@@ -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',
|
||||
]
|
||||
|
||||
Executable
+9
@@ -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
|
||||
@@ -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)
|
||||
})
|
||||
Executable
+31
@@ -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"
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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 ' ') 字节"
|
||||
|
||||
@@ -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) })
|
||||
@@ -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
@@ -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.184-mx704yxj">
|
||||
<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.184</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<{ok, error}></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>大图(> 宿主内联阈值,现 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',
|
||||
|
||||
@@ -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.169 · 9.7 MB · .dmg<div class="hash">sha256 c133b12c2b9660bb…</div></div>
|
||||
<a class="btn" href="/updates/darwin-aarch64/image-workbench_3.26.169_aarch64.dmg?h=c133b12c2b96">下载</a>
|
||||
<div class="meta">版本 3.26.184 · 9.7 MB · .dmg<div class="hash">sha256 2358abf9f64ff17a…</div></div>
|
||||
<a class="btn" href="/updates/darwin-aarch64/image-workbench_3.26.184_aarch64.dmg?h=2358abf9f64f">下载</a>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="name">macOS · Intel<div class="hint">x86_64</div></div>
|
||||
<div class="meta">版本 3.26.169 · 10.1 MB · .dmg<div class="hash">sha256 f0520a62218b2a82…</div></div>
|
||||
<a class="btn" href="/updates/darwin-x86_64/image-workbench_3.26.169_x64.dmg?h=f0520a62218b">下载</a>
|
||||
<div class="meta">版本 3.26.184 · 10.1 MB · .dmg<div class="hash">sha256 24d1030ba3501699…</div></div>
|
||||
<a class="btn" href="/updates/darwin-x86_64/image-workbench_3.26.184_x64.dmg?h=24d1030ba350">下载</a>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="name">Windows · x64<div class="hint">需要 WebView2</div></div>
|
||||
<div class="meta">版本 3.26.169 · 5.3 MB · .exe<div class="hash">sha256 90f1fad79b2f54dd…</div></div>
|
||||
<a class="btn" href="/updates/windows-x86_64/image-workbench_3.26.169_x64-setup.exe?h=90f1fad79b2f">下载</a>
|
||||
<div class="meta">版本 3.26.184 · 5.3 MB · .exe<div class="hash">sha256 d26a90dda86df474…</div></div>
|
||||
<a class="btn" href="/updates/windows-x86_64/image-workbench_3.26.184_x64-setup.exe?h=d26a90dda86d">下载</a>
|
||||
</div>
|
||||
|
||||
<h2>系统要求</h2>
|
||||
@@ -97,6 +97,14 @@
|
||||
</ol>
|
||||
|
||||
<h2>历史版本</h2>
|
||||
<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>
|
||||
@@ -819,7 +827,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-12-01
|
||||
本页由 <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-02
|
||||
</div>
|
||||
</div></div>
|
||||
|
||||
|
||||
+12
-12
@@ -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.169-mx4i5ngr">
|
||||
<link rel="stylesheet" href="/assets/style.css?v=3.26.184-mx704yxj">
|
||||
</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.169</a>
|
||||
<a class="btn primary" href="/download/">下载 v3.26.184</a>
|
||||
</div>
|
||||
</div></nav>
|
||||
<main>
|
||||
<section class="hero hero-art">
|
||||
<div class="hero-bg"><img src="/assets/painting.jpg?v=3.26.169-mx4i5ngr" alt=""></div>
|
||||
<div class="hero-bg"><img src="/assets/painting.jpg?v=3.26.184-mx704yxj" alt=""></div>
|
||||
<div class="hero-veil"></div>
|
||||
<div class="wrap">
|
||||
<span class="kicker">v3.26.169 · macOS / Windows · 数据在本地</span>
|
||||
<span class="kicker">v3.26.184 · macOS / Windows · 数据在本地</span>
|
||||
<h1>本地优先的<br>AI 生图无限画布</h1>
|
||||
<p class="sub">用节点把「参考图 → 提示词 → 批量生成 → 图库」串成一条生产线。<br>图片、提示词、模型配置全部留在你自己的电脑里,插件按需安装。</p>
|
||||
<div class="cta">
|
||||
<a class="btn primary lg" href="/download/">下载 v3.26.169</a>
|
||||
<a class="btn lg" href="/plugins/">浏览 13 个插件</a>
|
||||
<a class="btn primary lg" href="/download/">下载 v3.26.184</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.169_aarch64.dmg?h=c133b12c2b96"><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.169_x64.dmg?h=f0520a62218b"><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.169_x64-setup.exe?h=90f1fad79b2f"><div class="n">Windows · x64</div><div class="s">需要 WebView2 · 5.3 MB · .exe</div></a></div>
|
||||
<div class="dl"><a href="/updates/darwin-aarch64/image-workbench_3.26.184_aarch64.dmg?h=2358abf9f64f"><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.184_x64.dmg?h=24d1030ba350"><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.184_x64-setup.exe?h=d26a90dda86d"><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>
|
||||
|
||||
+67
-33
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"version": 2,
|
||||
"updatedAt": "2026-12-01T09:36:23.512Z",
|
||||
"updatedAt": "2026-12-03T03:24:51.310Z",
|
||||
"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
|
||||
}
|
||||
]
|
||||
},
|
||||
@@ -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
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
+14
-6
@@ -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.169-mx4i5ngr">
|
||||
<link rel="stylesheet" href="/assets/style.css?v=3.26.184-mx704yxj">
|
||||
</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.169</a>
|
||||
<a class="btn primary" href="/download/">下载 v3.26.184</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>
|
||||
@@ -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>
|
||||
|
||||
+57
-1
@@ -1,8 +1,64 @@
|
||||
{
|
||||
"app": "Image Workbench",
|
||||
"subtitle": "本地优先的 AI 生图无限画布 · 桌面版(Tauri v2)",
|
||||
"updatedAt": "2026-12-01T07:11:56.203Z",
|
||||
"updatedAt": "2026-12-02T03:49:12.414Z",
|
||||
"releases": [
|
||||
{
|
||||
"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",
|
||||
|
||||
Generated
+1
-1
@@ -2014,7 +2014,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "image-workbench"
|
||||
version = "3.26.180"
|
||||
version = "3.26.238"
|
||||
dependencies = [
|
||||
"arboard",
|
||||
"base64 0.22.1",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "image-workbench"
|
||||
version = "3.26.182"
|
||||
version = "3.26.238"
|
||||
description = "无限画布 · 生图工作台桌面版"
|
||||
authors = ["malongan"]
|
||||
license = ""
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"$schema": "../node_modules/@tauri-apps/cli/config.schema.json",
|
||||
"productName": "image-workbench",
|
||||
"version": "3.26.182",
|
||||
"version": "3.26.238",
|
||||
"identifier": "com.malongan.imageworkbench",
|
||||
"build": {
|
||||
"frontendDist": "../dist",
|
||||
|
||||
+4
-1
@@ -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
|
||||
|
||||
@@ -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)
|
||||
@@ -0,0 +1,310 @@
|
||||
/* 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 || {}
|
||||
const concurrency = Math.max(1, Number(d.concurrency) || 2)
|
||||
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++
|
||||
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) : { ok: false, error: 'no-fetcher' }
|
||||
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')
|
||||
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 (attempt < maxRetries) {
|
||||
setStatus(e, STATE.DOWNLOADING, { retries: attempt + 1, lastError: lastErr })
|
||||
await sleep(Math.min(8000, 1000 * Math.pow(2, attempt)))
|
||||
continue
|
||||
}
|
||||
}
|
||||
}
|
||||
active--
|
||||
setStatus(e, STATE.FAILED, { retries: maxRetries, lastError: lastErr })
|
||||
pump()
|
||||
return publicView(e)
|
||||
}
|
||||
|
||||
function pump () {
|
||||
while (active < concurrency && queue.length) {
|
||||
const id = queue.shift()
|
||||
const e = entries.get(id)
|
||||
if (!e || e.status !== STATE.QUEUED) continue
|
||||
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.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
|
||||
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) {
|
||||
const res = await fetch(url)
|
||||
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) {
|
||||
let timer = null
|
||||
const job = fetchWithProgress(url, onProgress).catch(async () => {
|
||||
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)
|
||||
@@ -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)
|
||||
@@ -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 }
|
||||
|
||||
@@ -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)
|
||||
@@ -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
@@ -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 || {}
|
||||
|
||||
@@ -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)
|
||||
@@ -33,6 +33,9 @@
|
||||
} catch (e) { /* ignore */ }
|
||||
}
|
||||
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() }
|
||||
|
||||
@@ -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,6 +74,7 @@
|
||||
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()
|
||||
@@ -76,7 +85,7 @@
|
||||
if (jsObserver || typeof global.PerformanceObserver !== 'function') return
|
||||
try {
|
||||
jsObserver = new global.PerformanceObserver(function (list) {
|
||||
for (const e of list.getEntries()) { if (!bucket) continue; bucket.js++; bucket.jsMs += Number(e.duration) || 0 }
|
||||
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 }
|
||||
@@ -89,7 +98,23 @@
|
||||
jsObserver = null
|
||||
}
|
||||
|
||||
global.IWBPerf = { tag: tag, start: start, stop: stop, recent: recent, running: () => !!raf }
|
||||
// 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' 时才开启(排查用)。
|
||||
|
||||
@@ -36,6 +36,5 @@
|
||||
} catch (_) { /* 记账本身失败绝不能影响主流程 */ }
|
||||
}
|
||||
global.IWBMetricsSwallow = swallow
|
||||
global.IWBRuntimeMetricsFactory = create
|
||||
global.IWBRuntimeMetrics = create()
|
||||
})(typeof window !== 'undefined' ? window : globalThis)
|
||||
@@ -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)
|
||||
+32
-1
@@ -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()
|
||||
@@ -1099,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 首帧即用,重复打开直接命中。
|
||||
@@ -1612,7 +1643,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 },
|
||||
|
||||
@@ -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 || {}
|
||||
|
||||
@@ -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
@@ -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
@@ -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 || '↓'),
|
||||
),
|
||||
)
|
||||
}
|
||||
|
||||
@@ -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' },
|
||||
|
||||
+126
-5
@@ -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, 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,7 @@
|
||||
combineSourcePairs = D.combineSourcePairs
|
||||
downloadUrl = D.downloadUrl
|
||||
wResolveOutSrc = D.wResolveOutputSrc
|
||||
wOutNameOf = D.wOutNameOf
|
||||
isImageProducer = D.isImageProducer
|
||||
nodePreviewRefsV2 = D.nodePreviewRefsV2
|
||||
nodeInheritOf = D.nodeInheritOf
|
||||
@@ -54,6 +59,7 @@
|
||||
resOfSize = D.resOfSize
|
||||
taskStallEndMs = D.taskStallEndMs
|
||||
wDedupeTaskIds = D.wDedupeTaskIds
|
||||
wThumbBump = D.wThumbBump
|
||||
}
|
||||
|
||||
|
||||
@@ -855,7 +861,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 }
|
||||
})
|
||||
@@ -870,6 +887,24 @@
|
||||
.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) }
|
||||
@@ -885,16 +920,102 @@
|
||||
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 // 缩略图还没好:先用本地原图,别等远程
|
||||
// 方案 A:新图还在排队/下载/失败时**不直连远程**(否则浏览器再下一次,等于双份流量);
|
||||
// 只有「没有落地记录」(旧数据)或「已 ready 但本地 URL 尚未解析」才允许远程兜底。
|
||||
if (r._awaitUrl) return r.url
|
||||
if (!ingSt || ingSt.status === 'ready') return r.url
|
||||
return undefined // 未落地:不设 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,
|
||||
)
|
||||
|
||||
@@ -733,6 +733,14 @@ 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' },
|
||||
@@ -1433,7 +1441,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 },
|
||||
webhook: { enabled: !!draft.webhook.enabled, url: (draft.webhook.url || '').trim() },
|
||||
})
|
||||
setSaving(false)
|
||||
|
||||
@@ -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*/
|
||||
@@ -1242,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,改一档全局一致。
|
||||
@@ -2266,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;
|
||||
@@ -2276,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; }
|
||||
@@ -2564,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; }
|
||||
@@ -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,
|
||||
}
|
||||
|
||||
@@ -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
@@ -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",
|
||||
|
||||
@@ -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"
|
||||
]
|
||||
@@ -0,0 +1,41 @@
|
||||
#!/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), '任务队列预览在本地无图时给出「未下载」提示')
|
||||
|
||||
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(取源本地优先 / 命名统一图库行名 / 预览不直连远程)')
|
||||
@@ -0,0 +1,169 @@
|
||||
// 结果落地管线(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)
|
||||
}
|
||||
|
||||
console.log('')
|
||||
console.log(pass + ' passed, ' + fail + ' failed')
|
||||
if (fail) process.exit(1)
|
||||
}
|
||||
|
||||
main().catch((e) => { console.error(e); process.exit(1) })
|
||||
@@ -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) })
|
||||
@@ -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: 全部通过')
|
||||
@@ -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) => {
|
||||
|
||||
@@ -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++ } })
|
||||
|
||||
@@ -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 = 9354 // +9(9,345→9,354)2026-12-03:下载命名规范 wOutNameOf + 队列预览改「只读本地」(origIdb/图库磁盘原图,未落地提示下载)。之前 +199(9,146→9,345)任务队列装配。之后只减不增。
|
||||
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 = 2687 // +1(2,686→2,687)2026-12-03:队列预览改「只读本地」(未落地提示下载)。之前 +153(2,533→2,686)任务队列装配。之后只减不增。
|
||||
// 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 只做装配(状态 + 注入 + 分派)。'
|
||||
|
||||
@@ -98,5 +98,13 @@ function loadStore(opts) {
|
||||
assert.strictEqual(r7.ok, true, '没有 navigator.locks 时仍要能工作(降级)')
|
||||
assert.deepStrictEqual(values.get(KEY).map((x) => x.name), ['z.png', 'y.png'], '降级路径也要真的写进去')
|
||||
|
||||
console.log('storage outputs mutate checks passed(跨标签锁接线 / 放弃写入 / 非法返回 / 抛错 / 串行顺序 / 无锁降级)')
|
||||
// ── 8. add 必须保留 orig 状态(2026-12-03)────────────────────────────────
|
||||
// 之前 doAdd 重建行时只保留 name/url/...,丢掉 orig;行若在 markOk 之后才创建,
|
||||
// 就会一直是「未落地」状态 → 图库按规则隐藏它,直到下次启动对账(用户实测的「丢图」)。
|
||||
values.set(KEY, [])
|
||||
const r8 = await store.add([{ name: 'g1.png', url: 'https://cdn.test/1.png', orig: 'pending' }])
|
||||
assert.strictEqual(r8.ok, true, 'add 应成功')
|
||||
assert.strictEqual(values.get(KEY)[0].orig, 'pending', 'add 必须保留 orig(否则行永远显示未落地)')
|
||||
|
||||
console.log('storage outputs mutate checks passed(跨标签锁接线 / 放弃写入 / 非法返回 / 抛错 / 串行顺序 / 无锁降级 / orig 保留)')
|
||||
})().catch((e) => { console.error(e); process.exit(1) })
|
||||
Vendored
+1
@@ -31,6 +31,7 @@ interface Window {
|
||||
IWBStorageMigrations?: any
|
||||
IWBStorageIndexedDb?: any
|
||||
IWBStorageFile?: any
|
||||
__iwbIngest?: any
|
||||
__TAURI__?: any
|
||||
__IWB_UPDATE__?: any
|
||||
IWBUIConfirm?: any
|
||||
|
||||
Reference in new issue
Block a user