chore: v3.26.238(图片读取/下载本地优先 + 命名统一图库行名)
This commit is contained in:
1 parent
ec9ca02a82
commit
48a68a7e8a
12 files changed
+173
-27
No files matched your search
@@ -20,6 +20,14 @@
|
||||
|
||||
- 历史条目补录:该 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%}`),宿主不再整页滚动;只有列表自己滚。
|
||||
|
||||
@@ -2465,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
|
||||
@@ -2475,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) {
|
||||
@@ -5717,7 +5725,7 @@ 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,
|
||||
@@ -6142,7 +6150,7 @@ const tbCenterSeed = (type, refs) => {
|
||||
|
||||
// 依赖注入点:放在 Workbench 之前 —— 此处 ICONS / computeEdgePath / downloadUrl / IDB 等全部已定义。
|
||||
_mod.inject({
|
||||
ICONS, IDB, computeEdgePath, copyImageToClipboard, downloadUrl,
|
||||
ICONS, IDB, computeEdgePath, copyImageToClipboard, downloadUrl, wOutNameOf,
|
||||
nodeTypeColor, nodeTypeH, nodeWidth, wBlobFromDataUrl, wRegisterBlobUrl,
|
||||
})
|
||||
|
||||
@@ -8349,19 +8357,20 @@ const tbCenterSeed = (type, refs) => {
|
||||
const idx = all.findIndex((x) => x.id === id)
|
||||
if (idx < 0) return { ok: false, error: 'record-missing' }
|
||||
const idxNow = lsGet(OUT_KEY, []) || []
|
||||
const list = []
|
||||
for (const x of all) {
|
||||
const row = idxNow.find((f) => f && String(f.url) === String(x.url))
|
||||
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) || ''
|
||||
let url = (x.id === id) ? '' : x.url
|
||||
if (x.id === id) {
|
||||
// 2026-12-03:老记录没有 origIdb,上一版先取 idb(320 缩略图)⇒ 全屏预览被放大发糊;改回原图优先、缩略图只兜底
|
||||
if (row && row.origIdb) { try { url = (await IDB.get(row.origIdb)) || '' } catch (e) { /* ignore */ } }
|
||||
if (!url) { const v = qView(x.url); url = /^https?:/i.test(String(x.url || '')) ? x.url : ((v && v.localUrl) || String(x.url || '')) }
|
||||
if (!url && row && row.idb) { try { url = (await IDB.get(row.idb)) || '' } catch (e) { /* ignore */ } }
|
||||
}
|
||||
list.push({ url, thumb: thumb || undefined, w: Number(x.w) || 0, h: Number(x.h) || 0, name: String((x.meta && (x.meta.promptText || x.meta.prompt)) || '') })
|
||||
}
|
||||
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 }
|
||||
},
|
||||
@@ -8721,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(),
|
||||
|
||||
@@ -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}`
|
||||
+2
-2
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "image-workbench-web",
|
||||
"private": true,
|
||||
"version": "3.26.237",
|
||||
"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/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: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",
|
||||
|
||||
Generated
+1
-1
@@ -2014,7 +2014,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "image-workbench"
|
||||
version = "3.26.237"
|
||||
version = "3.26.238"
|
||||
dependencies = [
|
||||
"arboard",
|
||||
"base64 0.22.1",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "image-workbench"
|
||||
version = "3.26.237"
|
||||
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.237",
|
||||
"version": "3.26.238",
|
||||
"identifier": "com.malongan.imageworkbench",
|
||||
"build": {
|
||||
"frontendDist": "../dist",
|
||||
|
||||
+31
-1
@@ -1100,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 首帧即用,重复打开直接命中。
|
||||
@@ -1613,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 },
|
||||
|
||||
+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'), ' 下载'),
|
||||
),
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
// · ctx = { onUpdate, busy, progress, h, stop, refMini },由调用方 renderBodyInner 组装。
|
||||
|
||||
// ── 注入依赖(app.js 在首次渲染时调用 inject 注入)─────────────────────────
|
||||
let ingestView, 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, wThumbBump
|
||||
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()
|
||||
@@ -29,6 +29,7 @@
|
||||
combineSourcePairs = D.combineSourcePairs
|
||||
downloadUrl = D.downloadUrl
|
||||
wResolveOutSrc = D.wResolveOutputSrc
|
||||
wOutNameOf = D.wOutNameOf
|
||||
isImageProducer = D.isImageProducer
|
||||
nodePreviewRefsV2 = D.nodePreviewRefsV2
|
||||
nodeInheritOf = D.nodeInheritOf
|
||||
@@ -919,7 +920,8 @@
|
||||
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')
|
||||
}
|
||||
// 生成中(2026-12-02,用户裁定「方案 1」):某一轮还在跑时,旧图压暗 + 角标「生成中」,
|
||||
// 但不改 data.result —— 失败时旧图原样保留,不会出现「图没了」。
|
||||
|
||||
@@ -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(取源本地优先 / 命名统一图库行名 / 预览不直连远程)')
|
||||
@@ -175,7 +175,7 @@ const MAX_SRC_GLOBALS = 124 // 2026-12-03 +1(123→124):新增 IWBPlugin
|
||||
// · 图标解析统一(右键菜单 + 设置页走同一解析器,2 行) +2
|
||||
// 通用件(pick/grant/stat/readDataUrl/readBlob/参数校验)全部在 src/image-file-ref.js
|
||||
// 与 src/plugin-api-images.js,app.js 只做装配。
|
||||
const MAX_APP_JS_LINES = 9345 // +199(9,146→9,345)2026-12-03:任务队列(queue/pages、缩略图/状态/定位/滚动/卡住检测装配)。之后只减不增。
|
||||
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
|
||||
|
||||
// ── 历史记账(供回溯,逐条保留)──────────────────────────────────────────────
|
||||
@@ -218,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 = 2686 // +153(2,533→2,686)2026-12-03:同上(任务队列装配与页面容器)。之后只减不增。
|
||||
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);② 工作区列表写回族
|
||||
|
||||
Reference in new issue
Block a user