Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
1717c2d7fb | ||
|
|
b5db6cce3f | ||
|
|
aced51f27c | ||
|
|
ec304b49d7 | ||
|
|
b0ceb3353d | ||
|
|
0b1293892c | ||
|
|
abce48c4d4 | ||
|
|
8048afad5b | ||
|
|
370e72f26f | ||
|
|
2d0abb1b79 | ||
|
|
db50733876 | ||
|
|
6a79eb432f | ||
|
|
f9caea2cfd | ||
|
|
84d2c1d896 | ||
|
|
1d40e74ead | ||
|
|
2ff86d0840 | ||
|
|
d04dac64bc | ||
|
|
c015a4e897 | ||
|
|
c9e01db607 | ||
|
|
acae6e789d | ||
|
|
3c37353aa8 | ||
|
|
98658e1e56 | ||
|
|
a6470f1fc5 | ||
|
|
c0dd9531bd | ||
|
|
8d09c1989b |
No files matched your search
@@ -16,6 +16,47 @@
|
||||
> 3. 核验正式地址版本 → 之后才移动 `stable` / `stable-verified-<日期>` 标签、更新本 CHANGELOG、写 GitHub Release(`gh release create`)。
|
||||
> 测试发现问题 → 改 → 再 `deploy:test`,正式环境不受影响。回滚点 `git reset --hard stable`。
|
||||
|
||||
## v3.26.146(2026-12-01)Canvas V3:P3 插件 fallback + 诊断绘制统计
|
||||
|
||||
- Canvas V3 支持插件节点 plugin:*:未选中时 Canvas 占位,选中恢复真实插件 NodeCard(fallback,不是插件 Canvas 渲染)。
|
||||
- 诊断页新增「Canvas V3 绘制 Xms · 帧 N · 图 M」,用于桌面实机对比。
|
||||
- 默认仍关闭;P3 只是移除未选中插件 DOM,插件内容需选中后查看。
|
||||
- 详细进度:docs/plans/canvas-v3-progress.md。
|
||||
## v3.26.145(2026-12-01)Canvas V3 实验:8 类节点 Canvas 静态层(默认关闭)
|
||||
|
||||
- 新增 `IWBCanvasV3` 特性开关(诊断页「Canvas V3(实验,需刷新)」,默认关闭)。
|
||||
- 未选中的 ref / prompt / textout / combine / batch / relay / gen / out 节点由 Canvas 画卡片、文本、图片/结果缩略图;选中后恢复完整 NodeCard。
|
||||
- 单层 canvas 命中:节点 body/端口由 `src/canvas-v3-hit.js` 做坐标命中,去掉每节点 proxy/端口 DOM。
|
||||
- 实测:100 ref DOM 4165→866;60 混合节点 2580→826;每节点 DOM 0。
|
||||
- 默认关闭,关闭时旧 DOM 路径零行为变化;详见 `docs/plans/canvas-v3-progress.md`。
|
||||
- 注意:P2 仅内置 8 类;插件节点、layer、桌面实机 graphics/长帧仍待验证,暂不作为稳定默认。
|
||||
|
||||
## v3.26.144(2026-11-30)Canvas 边线 + 平移全量渲染
|
||||
|
||||
- **边线视觉改 Canvas 2D**(`src/ui-canvas-edges.js`):不再每帧重栅格化 SVG;`.iwb-edges` 只保留透明 hit path 负责选择/双击/悬停,视觉由视口 canvas 画。
|
||||
- **平移期间全量渲染**:`nodeVisibleIn({ pan: true })` 让平移不再受“viewport state 不更新 ⇒ 裁剪窗口停在起点”影响,超过 280px 不会出现节点迟到/空白;松手恢复裁剪。
|
||||
- **平移继续 rAF 合批**;拖动节点/弹线时命令式重画 canvas,不触发 React。
|
||||
- 兼容旧 e2e:保留 `display:none` 的边线路径节点给选择器断言;DOM 中不参与绘制。
|
||||
- 复盘:[docs/standards/performance-2026-11-30.md](docs/standards/performance-2026-11-30.md)。
|
||||
|
||||
## v3.26.143(2026-11-30)perf v2:默认不常驻合成 + 视口网格 + 280 裁剪 + 回收只后台
|
||||
|
||||
- **world/grid 默认不再提升合成层**:`.iwb-world` / `.iwb-grid` 的 `will-change` 改为显式 opt-in(诊断页勾选);默认 `data-layers="off"`。参考 infinite-canvas:靠视口裁剪 + memo,不靠整层常驻。
|
||||
- **网格**从 200% 尺寸 + transform 改为视口大小 + background-position,避免为背景多分一层。
|
||||
- **裁剪缓冲区 80 → 280**:带图节点不在平移边缘反复卸载/重解码。
|
||||
- **平移写入 rAF 合批**:同一帧多个 pointermove 只写一次 world/grid/edge。
|
||||
- **自动内存回收只在应用不可见时触发**,且保留显示缩略图;可见时不再每 2 分钟清缓存造成图片重载。手动回收不变。
|
||||
- **图库预热 6s → 30s**,手势期间继续暂停。
|
||||
- 复盘:[docs/standards/performance-2026-11-30.md](docs/standards/performance-2026-11-30.md)。
|
||||
|
||||
## v3.26.142(2026-11-30)边线层移到屏幕坐标系:graphics 再降 ~1GB
|
||||
|
||||
- 3.26.141 把边线 SVG 放进 `.iwb-world` 并用 `width = 视口/scale`;缩到 30% 时 CSS width 变成 8000 世界像素,WebKit 仍按 SVG 自身尺寸分配位图 ⇒ 诊断页 graphics 仍有 **1032MB**。
|
||||
- 现在 SVG 移出 `.iwb-world`,宽度恒为屏幕 CSS 宽;世界坐标由内部 `<g class="iwb-edge-world" transform="translate(x,y) scale(s)">` 负责。缩放和平移不再改变 SVG 的位图尺寸。
|
||||
- 合成层目标:2560×1303×4B×dpr² ≈ **53MB**(dpr2),而不是 1GB。
|
||||
- 单测改为断言屏幕尺寸、`<g>` transform、viewBox 不含 10000;`applyViewportDom` 仍只改 DOM,不触发 React。
|
||||
- 复盘更新:[docs/standards/performance-2026-11-30.md](docs/standards/performance-2026-11-30.md)。
|
||||
|
||||
## v3.26.141(2026-11-30)边线 SVG 视口化:graphics 1.6GB 主因
|
||||
|
||||
- **内存主因**:边线 `<svg width="10000" height="10000" translateZ(0)>` 在 dpr2 下分配约 **1.6GB** 合成位图,正好对应诊断页 WebContent graphics 1603MB;与 101 节点 / 18 张 DOM 图片无关。
|
||||
|
||||
+3
-3
@@ -41,7 +41,7 @@ build esbuild 打包到 dist/(单 dist/app.js = src/ 模块按序
|
||||
node --check app.js 与 dist/app.js 语法
|
||||
check-dist.js 产物体检
|
||||
lint ESLint(src/ + app.js,正确性规则)
|
||||
test:unit 136 个单测文件(jsdom 契约测试;2026-11-07 新增 sync-facts-guard(事实一致性)/ _helpers/source(统一源文本);2026-11-12 新增 provider-ping(测速 no-cors 兜底))
|
||||
test:unit 138 个单测文件(jsdom 契约测试;2026-11-07 新增 sync-facts-guard(事实一致性)/ _helpers/source(统一源文本);2026-11-12 新增 provider-ping(测速 no-cors 兜底))
|
||||
test relay-task-graph-fixture + iwb-v32-web-test
|
||||
test:facts 事实基线守门(见 §5)
|
||||
typecheck 渐进类型检查(tsc --noEmit;范围 = src/*.js,不含 app.js)
|
||||
@@ -105,8 +105,8 @@ IWB_WRITE_BOUNDARY_SNAPSHOT=1 node tests/architecture-boundary-guard-test.js #
|
||||
|
||||
| 守卫 | 位置 | 现在的上限 |
|
||||
|---|---|---|
|
||||
| `app.js` 总行数 | `tests/source-text-ratchet-test.js` `MAX_APP_JS_LINES` | **8,665**(另守「占总源码 ≤ 40%」,见 `MAX_APP_JS_SHARE`) |
|
||||
| `Workbench()` 行数 | 同上 `MAX_WORKBENCH_LINES` | **2,231** |
|
||||
| `app.js` 总行数 | `tests/source-text-ratchet-test.js` `MAX_APP_JS_LINES` | **8,720**(另守「占总源码 ≤ 40%」,见 `MAX_APP_JS_SHARE`) |
|
||||
| `Workbench()` 行数 | 同上 `MAX_WORKBENCH_LINES` | **2,318** |
|
||||
| 单组件行数(不含 Workbench)| 同上 `MAX_APP_COMPONENT_LINES` | **423** |
|
||||
|
||||
三条都是**只减不增**。确需在 app.js 增长时,必须**同步上调上限并在 commit 里写理由**(等于显式记账,不会悄悄发生)。
|
||||
|
||||
@@ -96,9 +96,9 @@ try { if (window.IWBMiniMapFit && typeof window.IWBMiniMapFit.install === 'funct
|
||||
if (!invoke) throw new Error('Tauri 不可用')
|
||||
return await invoke('open_app_data_dir')
|
||||
}
|
||||
// v3.26.136:合成层常驻提升(默认关)。开着时整个画布世界是一个常驻合成层,实测 graphics 764MB。
|
||||
// v3.26.140:默认「合成层开」(108 的行为);开关用于临时关掉省内存
|
||||
try { if (lsGet('iwb_layers_off', false)) document.documentElement.dataset.layers = 'off' } catch (e) { /* ignore */ }
|
||||
// v3.26.143:默认不提升 world/grid 合成层(参考 infinite-canvas);诊断页可显式 opt-in。
|
||||
try { document.documentElement.dataset.layers = lsGet('iwb_layers_on', false) ? 'on' : 'off' } catch (e) { /* ignore */ }
|
||||
try { const V3 = (typeof window !== 'undefined' && window.IWBCanvasV3); if (V3 && typeof V3.init === 'function') V3.init() } catch (e) { /* ignore */ }
|
||||
try { if (lsGet('iwb_noblur_on', false)) document.documentElement.dataset.noblur = 'on' } catch (e) { /* ignore */ }
|
||||
// 桌面端保存二进制:有导出目录直接写 Uint8Array(不弹框),没目录才弹「另存为」;刻意不经 base64,省一次全量编解码。
|
||||
const wSaveBlobNative = async (blob, name, title) => {
|
||||
@@ -3472,6 +3472,9 @@ try { if (window.IWBMiniMapFit && typeof window.IWBMiniMapFit.install === 'funct
|
||||
: null
|
||||
// 连线几何与合法性(纯函数收编到 src/canvas-geometry.js,P2-9):无依赖,直接用模块
|
||||
const CanvasGeometry = (typeof window !== 'undefined' && window.IWBCanvasGeometry) || null
|
||||
const IWBCanvasEdges = (typeof window !== 'undefined' && window.IWBCanvasEdges) || { EdgeCanvas: () => null }
|
||||
const IWCanvasV3NodeLayer = (typeof window !== 'undefined' && window.IWBCanvasV3NodeLayer) || { CanvasNodeLayer: () => null }
|
||||
const IWCanvasV3Hit = (typeof window !== 'undefined' && window.IWBCanvasV3Hit) || { hitRefNode: () => null }
|
||||
// 撤销历史快照纯判定(收编到 src/canvas-history.js,P2-9):无依赖,直接用模块
|
||||
const CanvasHistory = (typeof window !== 'undefined' && window.IWBCanvasHistory) || null
|
||||
// 工作台列表纯变换(收编到 src/workspace-list.js,状态模型 epic · Pilot 3 片 A):无依赖,直接用模块
|
||||
@@ -6014,6 +6017,22 @@ const tbCenterSeed = (type, refs) => {
|
||||
const [editingGroupId, setEditingGroupId] = useState(null)
|
||||
const [groupNameDraft, setGroupNameDraft] = useState('')
|
||||
const [selEdge, setSelEdge] = useState(null)
|
||||
const [hoverEdgeId, setHoverEdgeId] = useState(null)
|
||||
const canvasV3On = !!(typeof window !== 'undefined' && window.IWBCanvasV3 && window.IWBCanvasV3.isEnabled && window.IWBCanvasV3.isEnabled())
|
||||
const canvasV3Types = (canvasV3On && window.IWBCanvasV3 && Array.isArray(window.IWBCanvasV3.TYPES)) ? window.IWBCanvasV3.TYPES : ['ref']
|
||||
const canvasV3TypeOf = (n) => {
|
||||
const t = n && n.type
|
||||
return !!t && (canvasV3Types.indexOf(t) >= 0 || t === 'plugin' || t.indexOf('plugin:') === 0)
|
||||
}
|
||||
const v3HitAtClient = (clientX, clientY) => {
|
||||
if (!canvasV3On || !canvasEl.el || !refs.viewport) return null
|
||||
const rect = canvasEl.el.getBoundingClientRect()
|
||||
const z = uiZoom()
|
||||
const vp = refs.viewport
|
||||
const wx = (clientX / z - rect.left / z - vp.x) / vp.scale
|
||||
const wy = (clientY / z - rect.top / z - vp.y) / vp.scale
|
||||
return IWCanvasV3Hit.hitNode(refs.nodes, wx, wy, { isType: canvasV3TypeOf, widthOf: nodeWidth, heightOf: hOf, portRadiusWorld: 10 / vp.scale, wantPorts: true })
|
||||
}
|
||||
const [conn, setConn] = useState(null)
|
||||
const [connTarget, setConnTarget] = useState(null)
|
||||
const [ctxMenu, setCtxMenu] = useState(null)
|
||||
@@ -6989,8 +7008,11 @@ const tbCenterSeed = (type, refs) => {
|
||||
try { freed.refs = await wRefActiveBoardNow() } catch (e) { /* ignore */ }
|
||||
// ④ 图片字节缓存压到 0 + 缩略图缓存清空(都可由磁盘/IDB 重建)
|
||||
try { const S = wImageBlobStore(); if (S && typeof S.trim === 'function') freed.blobs = S.trim(0) } catch (e) { /* ignore */ }
|
||||
try { freed.thumbs = displayThumbs.size; displayThumbs.clear() } catch (e) { /* ignore */ }
|
||||
try { outThumbCache.clear() } catch (e) { /* ignore */ }
|
||||
// 自动回收保留显示缩略图(清了会立刻触发可见图片重载);手动回收才清。
|
||||
if (!opts || !opts.keepThumbs) {
|
||||
try { freed.thumbs = displayThumbs.size; displayThumbs.clear() } catch (e) { /* ignore */ }
|
||||
try { outThumbCache.clear() } catch (e) { /* ignore */ }
|
||||
}
|
||||
try { if (typeof wThumbBump === 'function') wThumbBump() } catch (e) { /* ignore */ }
|
||||
const after = heapMB()
|
||||
try {
|
||||
@@ -7339,7 +7361,12 @@ const tbCenterSeed = (type, refs) => {
|
||||
// v3.25.68(借鉴 tldraw 的相机机制):手势期间只改 .iwb-world 的 transform,
|
||||
// 不 setViewport ⇒ 不触发 React 重渲染 ⇒ 世界层不被标记为脏,WebKit 不必整层重栅格化。
|
||||
// 松手/停止滚轮后再提交一次 state,保证与 React 渲染值一致。
|
||||
const applyViewportDom = (x, y, scale) => CanvasGeometry.applyViewportDom(canvasEl.el, canvasSize, x, y, scale, refs.gridOpts)
|
||||
const applyViewportDom = (x, y, scale) => {
|
||||
CanvasGeometry.applyViewportDom(canvasEl.el, canvasSize, x, y, scale, refs.gridOpts)
|
||||
// 边线/节点 canvas:手势期间命令式重画,避免等 React
|
||||
try { if (typeof refs.edgeCanvasDraw === 'function') refs.edgeCanvasDraw(x, y, scale) } catch (e) { /* ignore */ }
|
||||
try { if (typeof refs.nodeCanvasDraw === 'function') refs.nodeCanvasDraw(x, y, scale) } catch (e) { /* ignore */ }
|
||||
}
|
||||
|
||||
// LOD 滞回状态:plain 在 <15% 进入、>18% 退出(用 ref 保存,不触发额外渲染)
|
||||
if (refs.lodPlain === undefined) refs.lodPlain = false
|
||||
@@ -7441,6 +7468,14 @@ const tbCenterSeed = (type, refs) => {
|
||||
}, [])
|
||||
const nodeOnSelect = React.useCallback((id) => { setSel([id]); setSelEdge(null) }, [])
|
||||
const nodeOnPreview = React.useCallback((src, list, idx) => setPreview({ list: (list && list.length ? list : [src]), idx: idx || 0 }), [])
|
||||
const outThumbsFor = React.useCallback((node) => {
|
||||
try { return (IWNodeBodies && typeof IWNodeBodies.outThumbUrlsOf === 'function') ? IWNodeBodies.outThumbUrlsOf(node, nodes, edges) : [] } catch (e) { return [] }
|
||||
}, [nodes, edges])
|
||||
const previewRefNode = React.useCallback((node) => {
|
||||
const raw = (node && node.data && (node.data.data || node.data.url)) || ''
|
||||
if (!raw) return
|
||||
wResolveImgAsync(raw).then((src) => { if (src) nodeOnPreview(src, [src], 0) }).catch(() => { /* ignore */ })
|
||||
}, [nodeOnPreview])
|
||||
|
||||
// batch 节点来源缓存:替代每帧对每条边做 filter+some(拖动时复用)
|
||||
const batchSourcesMap = React.useMemo(() => {
|
||||
@@ -7460,7 +7495,7 @@ const tbCenterSeed = (type, refs) => {
|
||||
// 视口裁剪矩形(useMemo:拖动时 viewport 不变则复用,避免每帧算除法)
|
||||
// 视口裁剪:宽边距 240(纯文本节点),带图节点 80 —— 见 CanvasGeometry.cullRectsOf 注释
|
||||
const cullRects = React.useMemo(() => CanvasGeometry.cullRectsOf(canvasSize, viewport), [canvasSize.w, canvasSize.h, viewport.x, viewport.y, viewport.scale])
|
||||
const nodeVisible = (n) => CanvasGeometry.nodeVisibleIn(n, cullRects, { drag: refs.drag, resize: refs.resize, sel: sel, widthOf: nodeWidth, heightOf: hOf })
|
||||
const nodeVisible = (n) => CanvasGeometry.nodeVisibleIn(n, cullRects, { drag: refs.drag, resize: refs.resize, sel: sel, pan: !!refs.pan, widthOf: nodeWidth, heightOf: hOf })
|
||||
const visibleIds = new Set(nodes.filter(nodeVisible).map((n) => n.id))
|
||||
|
||||
try { wSetScaleNow(viewport.scale) } catch (e) { /* ignore */ }
|
||||
@@ -7513,10 +7548,13 @@ const tbCenterSeed = (type, refs) => {
|
||||
focusNodeId,
|
||||
selEdge,
|
||||
edgeHover,
|
||||
visual: false,
|
||||
onHover: (id) => setHoverEdgeId(id || null),
|
||||
onSelect: (id) => { setSelEdge(id); setSel([]) },
|
||||
onDelete: (id) => deleteEdge(id),
|
||||
}))
|
||||
}
|
||||
let tempD = ''
|
||||
if (conn) {
|
||||
const src = refs.nodes.find((n) => n.id === conn.from)
|
||||
if (src) {
|
||||
@@ -7532,7 +7570,7 @@ const tbCenterSeed = (type, refs) => {
|
||||
y2 = inP.y
|
||||
}
|
||||
const dx = Math.max(40, (x2 - x1) / 2)
|
||||
edgeEls.push(el('path', { key: 'tmp', className: 'iwb-edge iwb-edge-temp' + (connTarget ? (connTarget.valid ? ' iwb-edge-ok' : ' iwb-edge-bad') : ''), d: 'M ' + x1 + ' ' + y1 + ' C ' + (x1 + dx) + ' ' + y1 + ', ' + (x2 - dx) + ' ' + y2 + ', ' + x2 + ' ' + y2 }))
|
||||
tempD = 'M ' + x1 + ' ' + y1 + ' C ' + (x1 + dx) + ' ' + y1 + ', ' + (x2 - dx) + ' ' + y2 + ', ' + x2 + ' ' + y2
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7632,8 +7670,8 @@ const tbCenterSeed = (type, refs) => {
|
||||
))
|
||||
}
|
||||
const nodeEls = IWBCanvasNodes.buildNodeEls({
|
||||
CanvasGeometry, CanvasStore, EMPTY_OBJ, NODE_W, NodeCardMemo, addRefFromUrl, batchPortTop, batchSourcesMap, canConnect, cancelRun, config, connTarget,
|
||||
defaultNodeBoxWidth, deleteNodes, duplicateNodes, edges, el, generationConcurrency, hOf, inPortWorld, isBatchSrc, lodViewport, nodeDerived, nodeOnMeasure, nodeOnPreview,
|
||||
CanvasGeometry, CanvasStore, EMPTY_OBJ, NODE_W, NodeCardMemo, addRefFromUrl, batchPortTop, batchSourcesMap, canConnect, cancelRun, config, connTarget, canvasV3On, canvasV3Types, canvasV3TypeOf,
|
||||
defaultNodeBoxWidth, deleteNodes, duplicateNodes, edges, el, generationConcurrency, hOf, inPortWorld, isBatchSrc, lodViewport, nodeDerived, nodeOnMeasure, nodeOnPreview, previewRefNode,
|
||||
nodeOnSelect, nodeTypeH, nodeWidth, nodes, pushHistory, refs, runLLM, runLayerNode, runNode, runOutSources, saveNow, sel, selRef,
|
||||
setConn, setConnTarget, setNotice, setSel, taskCountOf, thumbRev, typesRev, uiZoom, uid, updateNode, visibleIds, wLodEnabled, zoomToNode,
|
||||
})
|
||||
@@ -7958,10 +7996,24 @@ const tbCenterSeed = (type, refs) => {
|
||||
const nd = el && el.closest ? el.closest('.iwb-node') : null
|
||||
if (nd && nd.dataset && nd.dataset.nodeId) targetId = nd.dataset.nodeId
|
||||
} catch (err) { /* ignore */ }
|
||||
if (!targetId && canvasV3On) {
|
||||
const hp = v3HitAtClient(e.clientX, e.clientY)
|
||||
if (hp) targetId = hp.node.id
|
||||
}
|
||||
if (targetId && !sel.includes(targetId)) setSel([targetId])
|
||||
setCtxMenu({ x: e.clientX, y: e.clientY, wx, wy, targetId })
|
||||
},
|
||||
onDoubleClick: (e) => {
|
||||
// Canvas V3:未选中 ref 没有 DOM,双击命中后直接开预览。
|
||||
if (canvasV3On) {
|
||||
const hit = v3HitAtClient(e.clientX, e.clientY)
|
||||
if (hit) {
|
||||
e.preventDefault(); e.stopPropagation()
|
||||
if (hit.node.type === 'ref') previewRefNode(hit.node)
|
||||
else setSel([hit.node.id])
|
||||
return
|
||||
}
|
||||
}
|
||||
// 双击画布空白不再做任何事(原「双击空白 = 适应视图」已移除,改为底栏最右「适应视图」按钮 + Shift+F)。
|
||||
// 「双击节点标题栏 = 居中放大该节点」由节点自身处理,这里只负责排除,不去抢节点/操作栏/面板上的双击。
|
||||
const t0 = e.target
|
||||
@@ -7980,6 +8032,7 @@ const tbCenterSeed = (type, refs) => {
|
||||
refs.pan = { sx: e.clientX / uiZoom(), sy: e.clientY / uiZoom(), vx: viewport.x, vy: viewport.y }
|
||||
setSel([])
|
||||
setSelEdge(null)
|
||||
setTick((t) => t + 1) // 让 nodeVisible(pan=true) 先挂载全部节点,避免平移中途空白
|
||||
return
|
||||
}
|
||||
if (e.button !== 0) return
|
||||
@@ -7988,11 +8041,43 @@ const tbCenterSeed = (type, refs) => {
|
||||
if (typeof document !== 'undefined' && document.querySelector && document.querySelector('.iwb-modal-mask, .iwb-ctxmask')) return
|
||||
const t0 = e.target
|
||||
if (t0 && t0.closest && (t0.closest('.iwb-toolbar') || t0.closest('.iwb-lib') || t0.closest('.iwb-lib-embedded') || t0.closest('.iwb-drawer') || t0.closest('.iwb-history') || t0.closest('.iwb-history-embedded') || t0.closest('.iwb-rightrail') || t0.closest('.iwb-fullmask') || t0.closest('.iwb-fullpanel') || t0.closest('.iwb-minimap') || t0.closest('.iwb-navrail, .iwb-plugin-page') || t0.closest('.iwb-statusbar') || t0.closest('.iwb-hint-bottom') || t0.closest('.iwb-modal-mask') || t0.closest('.iwb-modal') || t0.closest('.iwb-cpick-pop'))) return
|
||||
// Canvas V3:未选中 ref 没有 DOM,先在画布层做命中;选中/端口仍走现有逻辑。
|
||||
if (canvasV3On && e.button === 0 && !refs.spaceDown && tool !== 'pan') {
|
||||
const t1 = e.target
|
||||
const overDomNode = !!(t1 && t1.closest && t1.closest('.iwb-node, .iwb-port, .iwb-resize, .iwb-group, .iwb-group-bar, .iwb-toolbar, .iwb-drawer, .iwb-lib, .iwb-rightrail, .iwb-navrail, .iwb-plugin-page, .iwb-statusbar, .iwb-minimap'))
|
||||
if (!overDomNode) {
|
||||
const hit = v3HitAtClient(e.clientX, e.clientY)
|
||||
if (hit) {
|
||||
e.preventDefault()
|
||||
e.stopPropagation()
|
||||
const nd = hit.node
|
||||
if (hit.port === 'in') {
|
||||
const inP = inPortWorld(nd)
|
||||
refs.connFrom = { nodeId: nd.id, reverse: true, portPos: inP }
|
||||
setConnTarget(null); setConn({ from: nd.id, x: inP.x, y: inP.y, reverse: true }); return
|
||||
}
|
||||
if (hit.port === 'out') {
|
||||
refs.connFrom = { nodeId: nd.id, portPos: { x: nd.x + nodeWidth(nd), y: nd.y + hOf(nd) / 2 } }
|
||||
setConnTarget(null); return
|
||||
}
|
||||
const curSel = selRef.current
|
||||
const ids = (e.shiftKey || e.metaKey || e.ctrlKey)
|
||||
? (curSel.includes(nd.id) ? curSel.filter((x) => x !== nd.id) : curSel.concat([nd.id]))
|
||||
: (curSel.includes(nd.id) ? curSel.slice() : [nd.id])
|
||||
const start = {}
|
||||
for (const x of refs.nodes) if (ids.includes(x.id)) start[x.id] = { x: x.x, y: x.y }
|
||||
refs.bodyDown = { id: nd.id, ids, start, sx: e.clientX / uiZoom(), sy: e.clientY / uiZoom(), active: false }
|
||||
setSel(ids)
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
// 平移画布:按住空格(临时)或选中抓手工具(持续);默认 = 框选节点
|
||||
if (refs.spaceDown || tool === 'pan') {
|
||||
refs.pan = { sx: e.clientX / uiZoom(), sy: e.clientY / uiZoom(), vx: viewport.x, vy: viewport.y }
|
||||
setSel([])
|
||||
setSelEdge(null)
|
||||
setTick((t) => t + 1) // 同上:平移期间先挂载全部节点
|
||||
return
|
||||
}
|
||||
refs.box = { x0: e.clientX / uiZoom(), y0: e.clientY / uiZoom(), x1: e.clientX / uiZoom(), y1: e.clientY / uiZoom(), mode: e.altKey ? 'toggle' : (e.shiftKey ? 'add' : 'replace'), baseSel: selRef.current.slice() }
|
||||
@@ -8058,12 +8143,26 @@ const tbCenterSeed = (type, refs) => {
|
||||
// 2026-11-09:单节点气泡同样恢复删除(放最右,理由同多选气泡)。
|
||||
el('button', { className: 'iwb-fb-del', 'aria-label': '删除', 'data-tip': '删除', onClick: (e) => { e.stopPropagation(); deleteNodes([sn.id]) } }, I('trash')),
|
||||
) })()) : null),
|
||||
// 边线视觉层:canvas 绘制,避免 SVG 在 WKWebView 每帧重栅格化。
|
||||
el(IWBCanvasEdges.EdgeCanvas, {
|
||||
edges, graph: edgeGraph, nodeMap: refs.nodeMap, measuredH: refs.measuredH, pathCache: refs.edgePathCache,
|
||||
computeEdgePath, viewport, selEdge, focusNodeId, edgeHover, hoverEdgeId, tempD, connTarget,
|
||||
onReady: (fn) => { refs.edgeCanvasDraw = fn },
|
||||
}),
|
||||
// Canvas V3:未选中的 ref 节点卡片/图片画在 canvas;DOM 只保留 hit proxy。
|
||||
canvasV3On ? el(IWCanvasV3NodeLayer.CanvasNodeLayer, {
|
||||
nodes: nodes.filter((n) => visibleIds.has(n.id)), viewport, sel, types: canvasV3Types, isType: canvasV3TypeOf,
|
||||
widthOf: nodeWidth, heightOf: hOf, outThumbsFor,
|
||||
imageFor: (node, raw) => { try { return wImgSrcForNode(raw, 320) || '' } catch (e) { return '' } },
|
||||
onReady: (fn) => { refs.nodeCanvasDraw = fn },
|
||||
}) : null,
|
||||
// 透明 hit path:选择/双击/悬停仍走 SVG(canvas pointer-events:none)。
|
||||
el('svg', Object.assign({ className: 'iwb-edges' }, CanvasGeometry.edgeLayerProps(canvasSize)),
|
||||
el('g', { className: 'iwb-edge-world', transform: CanvasGeometry.edgeGroupTransform(viewport) }, edgeEls)),
|
||||
el('div', {
|
||||
className: 'iwb-world',
|
||||
style: { transform: 'translate(' + viewport.x + 'px, ' + viewport.y + 'px) scale(' + viewport.scale + ')' },
|
||||
},
|
||||
// v3.26.141:边线 SVG 只覆盖视口(10000² 会分配 ~1.6GB 合成位图)。
|
||||
el('svg', Object.assign({ className: 'iwb-edges' }, CanvasGeometry.edgeLayerProps(canvasSize, viewport)), edgeEls),
|
||||
groupEls,
|
||||
nodeEls,
|
||||
),
|
||||
@@ -8125,7 +8224,7 @@ const tbCenterSeed = (type, refs) => {
|
||||
onSaveNow: saveNow,
|
||||
config,
|
||||
diagStats: () => wDiagStats(refs.nodes, refs.workspaces),
|
||||
diagExtras: () => ({ persist: storagePersist, swallowed: (RuntimeMetrics && RuntimeMetrics.snapshot) ? RuntimeMetrics.snapshot() : null, procRssMB: wProcRssMB, layers: !(document && document.documentElement && document.documentElement.dataset.layers === 'off'), noblur: (document && document.documentElement && document.documentElement.dataset.noblur === 'on'), dom: (function () { try { return { els: document.getElementsByTagName('*').length, dock: document.querySelectorAll('.iwb-dock *').length, cards: document.querySelectorAll('.iwb-history-item').length } } catch (e) { return null } })() }), // v3.26.121 RSS + v3.26.127 DOM 规模 // 持久化 + 被忽略错误(2026-11-07)
|
||||
diagExtras: () => ({ persist: storagePersist, swallowed: (RuntimeMetrics && RuntimeMetrics.snapshot) ? RuntimeMetrics.snapshot() : null, procRssMB: wProcRssMB, layers: !!(document && document.documentElement && document.documentElement.dataset.layers === 'on'), canvasV3: !!(window && window.IWBCanvasV3 && window.IWBCanvasV3.isEnabled && window.IWBCanvasV3.isEnabled()), canvasV3Stats: (window && window.IWBCanvasV3 && window.IWBCanvasV3.stats) ? window.IWBCanvasV3.stats() : null, noblur: (document && document.documentElement && document.documentElement.dataset.noblur === 'on'), dom: (function () { try { return { els: document.getElementsByTagName('*').length, dock: document.querySelectorAll('.iwb-dock *').length, cards: document.querySelectorAll('.iwb-history-item').length } } catch (e) { return null } })() }), // v3.26.121 RSS + v3.26.127 DOM 规模 // 持久化 + 被忽略错误(2026-11-07)
|
||||
...autoBackupKit, // autoBackup / autoBackupSave / autoBackupRestore / autoBackupRefresh
|
||||
diagText: () => buildRuntimeDiagnosticsText([], (typeof window !== 'undefined' && window.__IWB_BUILD_META__) || {}),
|
||||
onExportDiag: () => exportRuntimeDiagnostics(),
|
||||
@@ -8138,7 +8237,8 @@ const tbCenterSeed = (type, refs) => {
|
||||
onReclaimMemory: () => wReclaimMemoryNow('manual'),
|
||||
onDiagDetail: () => wDiagDetail(),
|
||||
// v3.26.136:合成层常驻提升开关(立即生效,改完看「进程实测」对比)
|
||||
onToggleLayers: (on) => { try { if (on) delete document.documentElement.dataset.layers; else document.documentElement.dataset.layers = 'off'; lsSet('iwb_layers_off', !on) } catch (e) { /* ignore */ } },
|
||||
onToggleLayers: (on) => { try { document.documentElement.dataset.layers = on ? 'on' : 'off'; lsSet('iwb_layers_on', !!on) } catch (e) { /* ignore */ } },
|
||||
onToggleCanvasV3: (on) => { try { if (window.IWBCanvasV3) window.IWBCanvasV3.setEnabled(!!on) } catch (e) { /* ignore */ } },
|
||||
onToggleNoBlur: (on) => { try { if (on) document.documentElement.dataset.noblur = 'on'; else delete document.documentElement.dataset.noblur; lsSet('iwb_noblur_on', !!on) } catch (e) { /* ignore */ } },
|
||||
}), document.body) : null,
|
||||
helpOpen ? ReactDOM.createPortal(el('div', { className: 'iwb-modal-mask', onWheel: (e) => e.stopPropagation(), onPointerDown: (e) => { if (e.target === e.currentTarget) setHelpOpen(false) } },
|
||||
|
||||
@@ -0,0 +1,98 @@
|
||||
# Canvas V3 长期迁移计划(静态 Canvas + DOM overlay)
|
||||
|
||||
> 目标:把画布从“每节点完整 DOM”迁移到“静态内容 Canvas 绘制 + 只给选中/编辑节点挂 DOM”,降低 WKWebView 的布局/绘制/DOM 成本;保留旧 DOM 路径可回滚。
|
||||
>
|
||||
> 基线:v3.26.144(Canvas 边线、平移全量渲染、world 默认不合成)。
|
||||
> 参考:Excalidraw(静态 canvas + overlay)、tldraw(DOM shape + 空间索引 + 手势冻结)。
|
||||
|
||||
## 状态
|
||||
|
||||
| 阶段 | 内容 | 状态 | 验收 |
|
||||
|---|---|---|---|
|
||||
| P0 | 特性开关、渲染接口、基线指标 | 已完成(2026-12-01) | 关闭开关时行为零变化 |
|
||||
| P1 | 图片/ref 节点 Canvas 化 + 选中 DOM overlay | 垂直切片完成,待桌面验证(默认关闭) | 100 图节点每节点 DOM=0;应用外壳 ~866 |
|
||||
| P2 | 内置文本/gen/out/combine/batch/relay 节点 Canvas 化 | 基本完成(8 类已 Canvas,待桌面验证) | DOM < 500;编辑/生成不回归 |
|
||||
| P3 | 插件节点 fallback + browser/webview | 原型:未选中插件走 canvas 占位,选中恢复 DOM | 旧插件可用;仅可见/选中挂 DOM |
|
||||
| P4 | 稳定化、A/B、默认开启、旧路径退场 | 待开始 | 视觉/e2e/性能门禁通过 |
|
||||
|
||||
## 目标架构
|
||||
|
||||
```text
|
||||
SceneStore(纯数据,沿用现有 nodes/edges/groups)
|
||||
├─ CanvasRenderer(rAF、视口裁剪、分层)
|
||||
│ ├─ grid(CSS,视口大小)
|
||||
│ ├─ edges(已有 Canvas)
|
||||
│ ├─ node frames / images / titles / group boxes
|
||||
│ └─ selection / ports / progress
|
||||
└─ DOM Overlay
|
||||
├─ 选中节点编辑 UI(输入框/下拉/按钮/插件正文)
|
||||
├─ 浮动工具条/菜单/面板
|
||||
└─ 原生 webview / 复杂插件
|
||||
```
|
||||
|
||||
## P0:基础设施(当前)
|
||||
|
||||
- [ ] 新增 `src/canvas-v3.js`:`isEnabled()` / `setEnabled()` / `init()` / `stats()`;
|
||||
- [ ] localStorage 键 `iwb_canvas_v3`,根节点 `data-canvas-v3="on|off"`;
|
||||
- [ ] build sourceModules 登记模块;
|
||||
- [ ] app 启动 init(关闭时零行为变化);
|
||||
- [ ] 诊断页开关 + `diagExtras.canvasV3`;
|
||||
- [ ] 单测:开关读写、默认关闭、根属性同步;
|
||||
- [ ] 基线记录:100 节点 DOM/内存/长帧;
|
||||
- [ ] 关闭开关回归:e2e/构建通过。
|
||||
|
||||
## P1:图片/ref 节点 Canvas 化
|
||||
|
||||
- [ ] 新增 `CanvasNodeLayer`(canvas 位于 world 之下);
|
||||
- [ ] 绘制 ref 卡片框、标题、缩略图、选中环、端口(先只画不交互);
|
||||
- [ ] 未选中 ref 节点用 `NodeHitProxy` 替身:保留 pointerdown/drag/select,不渲染完整 body;
|
||||
- [ ] 选中 ref 节点恢复完整 NodeCard(DOM overlay);
|
||||
- [ ] 命中测试:节点矩形、输出端口;双击预览/右键菜单入口;
|
||||
- [ ] 图片缓存:复用现有 display thumb,不新增解码路径;
|
||||
- [ ] e2e:图片节点选择/拖动/替换/标注不回归;
|
||||
- [ ] 性能:100 图节点 DOM/内存/长帧对比。
|
||||
|
||||
## P2:内置节点
|
||||
|
||||
- 先 prompt/textout/combine/batch/relay,再 gen/layer/out;
|
||||
- 文本画到 canvas,编辑时 DOM textarea overlay;
|
||||
- 生成任务条/进度环 canvas 绘制;
|
||||
- 选中节点才挂完整编辑 UI;
|
||||
- 撤销/持久化沿用 CanvasStore。
|
||||
|
||||
## P3:插件与原生 webview
|
||||
|
||||
- 插件 API(可选):`ctx.canvasRender.drawStatic/hitTest/openEditor`;
|
||||
- 无能力插件:仅视口内实例 + 选中时完整 DOM;
|
||||
- browser/原生 webview:始终 DOM/native,不参与 Canvas;
|
||||
- 插件旧版本 fallback。
|
||||
|
||||
## P4:稳定化
|
||||
|
||||
- 视觉回归亮/暗色、选中态、组框;
|
||||
- e2e:平移 1000px、缩放、拖拽、连线、文本编辑、生成;
|
||||
- 性能门禁:100/500 节点;DOM、graphics、长帧;
|
||||
- 默认开启,旧路径保留一个版本。
|
||||
|
||||
## 验收指标
|
||||
|
||||
- 100 节点 DOM 元素 < 500(当前 2487);
|
||||
- WebContent graphics < 300MB;
|
||||
- 平移/缩放无空白/节点迟到;
|
||||
- 图片/文本/生成/插件主要链路不回归;
|
||||
- 关闭开关即回旧版。
|
||||
|
||||
## 风险
|
||||
|
||||
- Canvas 文本度量与 DOM 不完全一致;
|
||||
- 输入法/可访问性必须 DOM overlay;
|
||||
- 插件 DOM 生态无法一次性迁移;
|
||||
- 命中测试/端口优先级需重写;
|
||||
- 双路径维护成本高。
|
||||
|
||||
## 执行原则
|
||||
|
||||
1. 默认关闭,按阶段 A/B,可回滚;
|
||||
2. 不改数据格式;
|
||||
3. 先图片节点垂直切片,验证收益后再扩大;
|
||||
4. 每阶段在 `canvas-v3-progress.md` 记录数据与经验。
|
||||
@@ -0,0 +1,189 @@
|
||||
# Canvas V3 进度与经验
|
||||
|
||||
> 计划:[canvas-v3-long-term.md](./canvas-v3-long-term.md)
|
||||
|
||||
## 2026-12-01 · P0 完成
|
||||
|
||||
已完成:
|
||||
|
||||
- `src/canvas-v3.js`:`isEnabled / setEnabled / init / stats`,localStorage 键 `iwb_canvas_v3`,根属性 `data-canvas-v3`;
|
||||
- `scripts/build.js` 登记,app 启动 `init()`(默认 off,零行为变化);
|
||||
- 诊断页新增「Canvas V3(实验,需刷新)」开关;
|
||||
- 单测 `tests/canvas-v3-test.js` 接入 `test:unit`;
|
||||
- 事实/边界/源码棘轮已同步。
|
||||
|
||||
基线(Web 测试环境,100 节点数据但视口内实际挂载 20 个):
|
||||
|
||||
- DOM 元素 1170;
|
||||
- `data-node-id` 20;
|
||||
- `data-canvas-v3="off"`,`IWBCanvasV3.isEnabled() === false`。
|
||||
|
||||
经验:
|
||||
|
||||
- 当前 DOM 基线比之前诊断的 2487 低,是因为视口裁剪只挂载可见节点;做 100 节点性能对比时必须固定视口/缩放,否则数据不可比。
|
||||
- Phase 0 不改变任何渲染路径,先保住旧路径可回滚。
|
||||
|
||||
|
||||
## 2026-12-01 · P1 垂直切片(实验,默认关闭)
|
||||
|
||||
已实现:
|
||||
|
||||
- `src/canvas-v3-node-layer.js`:viewport canvas 画未选中 ref 节点的卡片框、标题、图片区;
|
||||
- `src/ui-canvas-nodes.js`:Canvas V3 开启时,未选中 ref 节点只渲染透明 `.iwb-node-hit-proxy`;
|
||||
- 选中后立即恢复完整 `NodeCard`(DOM overlay);
|
||||
- 拖动走现有 `refs.bodyDown` 全局指针逻辑;平移/拖节点命令式重画 canvas;
|
||||
- 诊断页开关「Canvas V3(实验,需刷新)」。
|
||||
|
||||
实测(Web 测试环境,2 ref + 1 prompt):
|
||||
|
||||
- `.iwb-node-hit-proxy` 2 个,完整 `.iwb-node` 1 个;
|
||||
- DOM 元素 307;
|
||||
- canvas 有绘制像素(31142);
|
||||
- 点击 proxy 后:proxy 2→1、NodeCard 1→2、selected 1,说明选中恢复 DOM overlay 正常。
|
||||
|
||||
已知限制(P1 继续要补):
|
||||
|
||||
- 未选中 ref 没有端口/右键菜单/双击预览入口(先选中后恢复 NodeCard 才有);
|
||||
- 绘制样式是近似卡片,不是 NodeCard 像素级;
|
||||
- 图片只走 `wImgSrcForNode(raw, 320)`,跨域图可能不画;
|
||||
- 还没做 100 图节点的 DOM/内存/长帧对比(20 图节点已量,见下)。
|
||||
|
||||
经验:
|
||||
|
||||
- “Canvas 画静态 + 选中恢复 NodeCard”路线可行;最小切片只需一个 hit proxy,不必先重写命中测试/全部交互。
|
||||
- 下一步优先补端口/右键/双击与 100 节点压测,而不是继续扩节点类型。
|
||||
### P1 20 图节点实测(Web,同一批 20 个 ref)
|
||||
|
||||
| 模式 | DOM 元素 | 完整 NodeCard | hit proxy |
|
||||
|---|---:|---:|---:|
|
||||
| Canvas V3 off | 1687 | 20 | 0 |
|
||||
| Canvas V3 on | 802 | 0(未选中) | 20 |
|
||||
|
||||
- 降幅 **52%**(1687 → 802);
|
||||
- canvas 正常绘制 20 张图片(pixels 2592605,截图见 `/Users/qiqi/.playwright-mcp/canvas-v3-20.png`);
|
||||
- 选中一个 proxy 后:proxy 20→19、NodeCard 0→1、selected 1,说明 DOM overlay 正常。
|
||||
|
||||
结论:垂直切片方向成立,但 20 图节点还不能代表 WKWebView 的最终收益;下一步要在桌面端实机看 graphics/长帧,并补端口/右键/双击预览。
|
||||
### P1 100 图节点实测(Web,固定 viewport scale=0.3,所有 100 个可见)
|
||||
|
||||
| 模式 | DOM 元素 | 完整 NodeCard | hit proxy | 端口 DOM |
|
||||
|---|---:|---:|---:|---:|
|
||||
| Canvas V3 off | 4165 | 100 | 0 | — |
|
||||
| Canvas V3 on | 1166 | 0 | 100 | 200 |
|
||||
|
||||
- DOM 降幅 **72%**(4165 → 1166);
|
||||
- 还达不到 P1 目标 <500:100 个 hit proxy + 200 个端口 DOM 是主要剩余成本;
|
||||
- 结论:下一步应把 **端口命中/选择命中** 移到 canvas 单层 hit test,而不是给每个节点保留 DOM 端口/代理。
|
||||
|
||||
### P1 交互补齐
|
||||
|
||||
- 未选中 ref 现在有输入/输出端口 DOM(连接仍走现有 refs.connFrom);
|
||||
- 右键 hit proxy 会命中 `.iwb-node`,节点右键菜单可用;
|
||||
- 双击 hit proxy 打开图片预览(`.iwb-imgpreview`);
|
||||
- 选中后恢复完整 NodeCard。
|
||||
|
||||
限制:上一版端口/代理仍是每节点 DOM,所以 100 图节点 DOM 1166;已由下方单层 canvas 命中解决。
|
||||
### P1 单层 canvas 命中(2026-12-01 后续)
|
||||
|
||||
去掉每节点 hit proxy 与 DOM 端口,改为:
|
||||
|
||||
- `src/canvas-v3-hit.js`:ref 节点 body/输入口/输出口的世界坐标命中;
|
||||
- 画布 pointerdown/doubleclick/contextmenu 统一走 `v3HitAtClient`;
|
||||
- 端口命中后沿用现有 `refs.connFrom` / `setConn`;
|
||||
- 选中/拖动后恢复 NodeCard,交互与之前一致。
|
||||
|
||||
实测 100 个可见 ref(scale≈0.73):
|
||||
|
||||
| 模式 | DOM | 完整 NodeCard | hit proxy | 端口 DOM |
|
||||
|---|---:|---:|---:|---:|
|
||||
| off | 4165 | 100 | 0 | — |
|
||||
| on(单层命中) | **866** | 0 | 0 | 0 |
|
||||
|
||||
- 比上一版 1166 再降 300(移除 100 个 proxy + 200 个端口 DOM);
|
||||
- 点击卡片可选中并恢复 NodeCard;右键菜单、双击预览、拖动均已实测通过;
|
||||
- 866 主要是应用外壳/停靠栏基础 DOM,不是 ref 节点;100 ref 本身 0 DOM。
|
||||
|
||||
新增单测:`tests/canvas-v3-hit-test.js`。
|
||||
## 2026-12-01 · P2 第一批:prompt / textout
|
||||
|
||||
扩展到 `ref + prompt + textout`:
|
||||
|
||||
- `IWBCanvasV3.TYPES` 定义可 Canvas 化类型;
|
||||
- `canvas-v3-hit.js` 增加通用 `hitNode`(isType 过滤;端口暂只对 ref);
|
||||
- `canvas-v3-node-layer.js` 画 prompt/textout 卡片与截断文本;
|
||||
- `ui-canvas-nodes.js` 对未选中的这三类完全不挂 NodeCard;
|
||||
- 选中后恢复 NodeCard 编辑,双击 ref 仍开预览。
|
||||
|
||||
60 个混合节点(30 ref + 30 prompt/textout)实测:
|
||||
|
||||
| 模式 | DOM | 完整 NodeCard |
|
||||
|---|---:|---:|
|
||||
| off | 2580 | 54 个可见 |
|
||||
| on | 826 | 0(未选中) |
|
||||
|
||||
文本是 Canvas 截断绘制,不是 Markdown/DOM 排版;只在选中后回到真实 NodeCard 编辑。
|
||||
|
||||
点击验证:prompt 卡片中心(n25)点击后 selected=1、NodeCard=1、DOM 826→873,说明文本节点的 canvas 命中也能恢复 DOM 编辑。
|
||||
### P2 第二批:combine / batch / relay
|
||||
|
||||
- `IWBCanvasV3.TYPES` 扩到 `ref,prompt,textout,combine,batch,relay`;
|
||||
- 这些节点未选中时全部由 canvas 画卡片/标题/截断文本,DOM 0;
|
||||
- 选中后恢复 NodeCard;
|
||||
- 60 个混合节点(6 类各 10 个):off DOM 2580 → on 826,完整 NodeCard 0;
|
||||
- `gen` / `out` 均已加入 Canvas 类型。
|
||||
### P2 第四批:out
|
||||
|
||||
- `out` 加入 `TYPES`;未选中 out 用 canvas 画结果缩略图网格(最多 4 张),无结果时提示「选中查看结果」;
|
||||
- 新增 `IWBNodeBodies.outThumbUrlsOf(node,nodes,edges)`:复用 outGroupsOf 的分组/排序;
|
||||
- Canvas V3 可能先于 NodeCard 渲染,NodeBodies 尚未 inject —— helper 对 `isImageProducer`/`cachedGenerationTasks` 做本职能兜底;
|
||||
- 选中后恢复完整 NodeCard,下载/预览/分组仍走原逻辑。
|
||||
|
||||
实测 gen+out(out 接 1 张结果):DOM 771、NodeCard 0、canvas 正常绘制;直接调用 outThumbUrlsOf 返回结果 URL。
|
||||
## 2026-12-01 · v3.26.145 发布(Canvas V3 实验,默认关闭)
|
||||
|
||||
- 已构建并发布 macOS arm64/x64:3.26.145;
|
||||
- 诊断页「Canvas V3(实验,需刷新)」可开启;默认关闭;
|
||||
- 已 Canvas 化:ref / prompt / textout / combine / batch / relay / gen / out;
|
||||
- 插件、layer 及部分编辑态仍走 NodeCard;
|
||||
- 桌面端实机 graphics/长帧、P3 插件 fallback 尚未验证。
|
||||
|
||||
发布地址:https://download.maqiart.eu.org/updates/latest.json
|
||||
## 2026-12-01 · P3 插件 fallback(原型)
|
||||
|
||||
- Canvas V3 的 isType 谓词支持 `plugin` / `plugin:*`;
|
||||
- 未选中插件节点由 canvas 画通用卡片(标题/占位),不挂插件 DOM;
|
||||
- 选中后恢复插件 NodeCard(插件真实 UI 只在选中时挂载);
|
||||
- 这是 fallback,不是插件 Canvas 渲染:插件内部仍无法直接参与 canvas,只是把未选中实例从 DOM 移除。
|
||||
### P3 fallback + 诊断统计
|
||||
|
||||
- 插件节点未选中时走 Canvas 占位,选中恢复插件 NodeCard;
|
||||
- `IWBCanvasV3.stats()` 返回 DOM、最近一次节点 canvas 绘制耗时、帧数、图片缓存数;
|
||||
- 诊断页显示「Canvas V3 绘制 Xms · 帧 N · 图 M」,用于桌面实机 A/B。
|
||||
### P2 第三批:gen
|
||||
|
||||
- `TYPES` 增加 `gen`;未选中 gen 节点改为 canvas 卡片(标题/摘要),选中恢复 NodeCard 配置;
|
||||
- `out` 仍走 DOM:它的结果网格依赖 gen/out 图数据与缩略图管线,不能只画占位;下一轮单独做。
|
||||
- 由于 `gen` 只做静态卡片,生成/任务状态仍以选中后的 NodeCard 为准。
|
||||
|
||||
注意:canvas 文本按视口缩放绘制,低倍率下只适合看卡片轮廓,精确阅读/编辑要选中。
|
||||
### P1 单层命中门禁(2026-12-01)
|
||||
|
||||
- `src/canvas-v3-hit.js` + 单元测试接入 `test:unit`;
|
||||
- 100 ref 节点:off DOM 4165 → on DOM 866;每节点 DOM 0(选中时只有 1 个 NodeCard overlay);
|
||||
- 点击选中、拖动、右键菜单、双击预览已实测;
|
||||
- 全量 `verify:ci` 通过(33 e2e + 单测 + facts/boundary/ratchet);
|
||||
- 默认关闭;桌面端实机 graphics/长帧尚未测,P1 还不算完成。
|
||||
|
||||
### 门禁
|
||||
|
||||
- `npm run verify:ci` 通过(33 e2e + 单测 + facts/boundary/ratchet);
|
||||
- Canvas V3 默认关闭;关闭时旧路径零行为变化;
|
||||
- 开启方式:诊断页「Canvas V3(实验,需刷新)」或 `IWBCanvasV3.setEnabled(true)` 后刷新。
|
||||
|
||||
### 经验(门禁)
|
||||
|
||||
- `src/*.js` 不能直调 `localStorage`(storage-convergence 会拦),特性开关也必须走 `IWBStorageLocal.getStore().rawGet/rawSet`;桌面端这样才能落到资料目录底座。
|
||||
- 新 canvas 模块里避免写蓝色 hex 兜底(page-chrome-regression 会扫全源),颜色一律走 CSS token + 中性兜底。
|
||||
- 新增模块/耦合/测试都要同步 facts、boundary 快照与 `test:unit`,否则 verify:ci 会红。
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
# 现状架构与性能事实基线(桌面版)
|
||||
|
||||
> **本文档是什么**:现状**事实快照**,不是规范。用途:任何性能 / 内存 / 存储相关改动,先对齐这里的现实,避免把已经调好的东西改坏。
|
||||
> 日期 **2026-10-20**(**2026-11-16 复算 · v3.24.85**)| 基线(**最近一次 bump 版本的提交**,不是主干 HEAD)`main = bf0886e`(线上 `v3.26.141+bf0886e` —— 2026-11-30 **图库链路收尾**:宫格不再读原图(原生 320 tier)、缩略图原子写 + 同键合并 + 补 .png、空闲预热;插件图片策略 v2(thumb/preview/original/budget)全量落地。上一条 `v3.26.129+a7da7f7` —— 2026-11-30 **插件源读数**:诊断页显示加载器实际读取的插件目录、索引条数、id@version 版本表与报错。上一条 `v3.26.128+9bcf6d7` —— 2026-11-30 **浏览器窗口空闲休眠**:它是独立 WKWebView(实测整树 +480MB),失焦满 30 分钟自动 close。上一条 `v3.26.127+ed762ad` —— 2026-11-30 **DOM 规模进诊断**:顶部显示 DOM 元素总数 + 停靠面板子树 + 图库卡片数,用来量化「面板开着」的真实成本(实测主窗口 29 节点却有 348MB WebKit malloc,大头在插件面板 DOM)。上一条 `v3.26.126+94d9952` —— 2026-11-30 **诊断增强**:新增 Rust app_memory_breakdown(逐进程 footprint + 分类 Dirty/Reclaimable),诊断页新增「内存拆解(分进程)」与「图片管线」(原生解码次数/峰值 + 缩略图磁盘 512/256/768 统计)。上一条 `v3.26.125+5d70782` —— 2026-11-30 **内存口径修正**:ps 的 RSS 会把每个 WebKit 子进程映射的共享框架各算一遍,四进程求和虚高 1.5~2 倍;改为 footprint(1) 的 phys_footprint(活动监视器同源),并只认比本进程更年轻的 WebKit 子进程。实测 WebContent footprint 653MB 中 dirty 仅 32MB、CG raster 1.7MB、Image IO 0 ⇒ 图片内存已压到底。上一条 `v3.26.124+a0526e7` —— 2026-11-30 **插件图片策略 v2**:宿主三层 ctx.images(thumb/preview/original/budget) + 原生解码闸门(并发 ≤2,>1024px ≤1);album 1.2.4 / promptlib 1.14.10 / batch-export 1.2.3 / annotate 1.20.9 / vectorize 0.6.2 / white-bg 1.2.2 / cutout 1.0.4 全部改走宿主小图;check-plugins-sync 增加图片策略守卫(warn)。上一条 `v3.26.123+309963c` —— 2026-11-30 **缩略图改原生生成**:WebKit 忽略 createImageBitmap 的 resize 选项,JS 生成缩略图要整幅解码 4K 原图(21MB/张),100 多张 ⇒ WebContent 1GB+;新增 Tauri 命令 img_thumbs(Rust image crate,按目标尺寸解码/编码),webview 只接触几十 KB 小图、原图永不进 WebKit 图片缓存。上一条 `v3.26.121+71fe162` —— 2026-11-30 **内存可观测性 + LOD 256 档**:新增 Rust 命令 app_memory_tree_mb(Windows Toolhelp32 / mac ps 建树)→ 诊断页「进程实测 XXX MB」,内存护栏优先用它;createImageBitmap 改 resizeWidth 在解码阶段降采样;新增 256 小档缩略图(纯内存)按 need 分档;macOS 的 WKWebView 子进程按 etime(±180s) 认领,避免把 Safari 算进来。上一条 `v3.26.120+eaf2512` —— 2026-11-30 **图库面板开一次涨 200MB**:`gallery-sync.thumbFor` 原先让宫格每张图都过 `displayThumbOf`,给每张 mint 一个 objectURL 并进 `displayThumbs`(300 上限);关面板后 URL 仍被缓存持有、解码位图不释放。现改为直接吃磁盘 320 缩略图(~20KB data URL)、不过 displayThumbOf;插件 gallery 1.9.6→1.9.7:卡片缓存 400→60 且淘汰时显式摘 `<img src>`。上一条 `v3.26.119+db55d45` —— 2026-11-30 **诊断修复**:三处导出调用点写的 `window.__IWB_SAVE_BLOB__` 从未定义,桌面端「导出诊断 JSON / 导出节点组」必然抛错,已统一走顶层 `wSaveBlob`;`procEstMB` 的解码位图改按 min(自然尺寸, 渲染尺寸×dpr) 累加(原按 512²×4 低报 3~4 倍);「估算进程」改称「画布估算」并注明不含宿主进程;读不出的旧 `{__cache}` 引用按 key 记住失败、本会话不再重试,诊断新增「失效引用 N」;上一条 `v3.26.118+3944fc5` —— 2026-11-30 **内存第二批收敛**:显示缩略图 640→512(124 张图的解码位图 200MB→128MB)、缩略图生成并发 4→2、图片字节缓存 96→64MB、远程 http(s) 图不再进缩略图队列(跨域必败,只换来 thumb-fail 日志)、内存护栏改看 `procEstMB`(估算进程 = JS 堆 + 字节缓存 + 解码位图,阈值 800MB;只盯 JS 堆时 106 张图堆 20MB / 位图 200MB,护栏永远不动);上一条 `v3.26.117+3809c38` —— 2026-11-30 **内存:图片字节预算 + 绝对占用护栏 + 诊断页「立即回收内存」**(Windows 测试版,未发布):`image-blob-store` 的 LRU 补字节预算(96MB ≈ 20 张原图,原来只按 200 条封顶 ⇒ 4~7.5MB 原图最多常驻 1.5GB)并新增 `trim()`;内存护栏在「上限 75%」(4GB ⇒ 3.1GB)之外补一条 ≥900MB 的绝对占用线,每 2 分钟做一次轻量回收;诊断页新增节点级 `nodeBigSamples`、`blobCacheMB/N`、`objUrls`,并把「内存」改称「JS 堆Line truncated
|
||||
> 日期 **2026-10-20**(**2026-11-16 复算 · v3.24.85**)| 基线(**最近一次 bump 版本的提交**,不是主干 HEAD)`main = aced51f`(线上 `v3.26.146+aced51f` —— 2026-11-30 **图库链路收尾**:宫格不再读原图(原生 320 tier)、缩略图原子写 + 同键合并 + 补 .png、空闲预热;插件图片策略 v2(thumb/preview/original/budget)全量落地。上一条 `v3.26.129+a7da7f7` —— 2026-11-30 **插件源读数**:诊断页显示加载器实际读取的插件目录、索引条数、id@version 版本表与报错。上一条 `v3.26.128+9bcf6d7` —— 2026-11-30 **浏览器窗口空闲休眠**:它是独立 WKWebView(实测整树 +480MB),失焦满 30 分钟自动 close。上一条 `v3.26.127+ed762ad` —— 2026-11-30 **DOM 规模进诊断**:顶部显示 DOM 元素总数 + 停靠面板子树 + 图库卡片数,用来量化「面板开着」的真实成本(实测主窗口 29 节点却有 348MB WebKit malloc,大头在插件面板 DOM)。上一条 `v3.26.126+94d9952` —— 2026-11-30 **诊断增强**:新增 Rust app_memory_breakdown(逐进程 footprint + 分类 Dirty/Reclaimable),诊断页新增「内存拆解(分进程)」与「图片管线」(原生解码次数/峰值 + 缩略图磁盘 512/256/768 统计)。上一条 `v3.26.125+5d70782` —— 2026-11-30 **内存口径修正**:ps 的 RSS 会把每个 WebKit 子进程映射的共享框架各算一遍,四进程求和虚高 1.5~2 倍;改为 footprint(1) 的 phys_footprint(活动监视器同源),并只认比本进程更年轻的 WebKit 子进程。实测 WebContent footprint 653MB 中 dirty 仅 32MB、CG raster 1.7MB、Image IO 0 ⇒ 图片内存已压到底。上一条 `v3.26.124+a0526e7` —— 2026-11-30 **插件图片策略 v2**:宿主三层 ctx.images(thumb/preview/original/budget) + 原生解码闸门(并发 ≤2,>1024px ≤1);album 1.2.4 / promptlib 1.14.10 / batch-export 1.2.3 / annotate 1.20.9 / vectorize 0.6.2 / white-bg 1.2.2 / cutout 1.0.4 全部改走宿主小图;check-plugins-sync 增加图片策略守卫(warn)。上一条 `v3.26.123+309963c` —— 2026-11-30 **缩略图改原生生成**:WebKit 忽略 createImageBitmap 的 resize 选项,JS 生成缩略图要整幅解码 4K 原图(21MB/张),100 多张 ⇒ WebContent 1GB+;新增 Tauri 命令 img_thumbs(Rust image crate,按目标尺寸解码/编码),webview 只接触几十 KB 小图、原图永不进 WebKit 图片缓存。上一条 `v3.26.121+71fe162` —— 2026-11-30 **内存可观测性 + LOD 256 档**:新增 Rust 命令 app_memory_tree_mb(Windows Toolhelp32 / mac ps 建树)→ 诊断页「进程实测 XXX MB」,内存护栏优先用它;createImageBitmap 改 resizeWidth 在解码阶段降采样;新增 256 小档缩略图(纯内存)按 need 分档;macOS 的 WKWebView 子进程按 etime(±180s) 认领,避免把 Safari 算进来。上一条 `v3.26.120+eaf2512` —— 2026-11-30 **图库面板开一次涨 200MB**:`gallery-sync.thumbFor` 原先让宫格每张图都过 `displayThumbOf`,给每张 mint 一个 objectURL 并进 `displayThumbs`(300 上限);关面板后 URL 仍被缓存持有、解码位图不释放。现改为直接吃磁盘 320 缩略图(~20KB data URL)、不过 displayThumbOf;插件 gallery 1.9.6→1.9.7:卡片缓存 400→60 且淘汰时显式摘 `<img src>`。上一条 `v3.26.119+db55d45` —— 2026-11-30 **诊断修复**:三处导出调用点写的 `window.__IWB_SAVE_BLOB__` 从未定义,桌面端「导出诊断 JSON / 导出节点组」必然抛错,已统一走顶层 `wSaveBlob`;`procEstMB` 的解码位图改按 min(自然尺寸, 渲染尺寸×dpr) 累加(原按 512²×4 低报 3~4 倍);「估算进程」改称「画布估算」并注明不含宿主进程;读不出的旧 `{__cache}` 引用按 key 记住失败、本会话不再重试,诊断新增「失效引用 N」;上一条 `v3.26.118+3944fc5` —— 2026-11-30 **内存第二批收敛**:显示缩略图 640→512(124 张图的解码位图 200MB→128MB)、缩略图生成并发 4→2、图片字节缓存 96→64MB、远程 http(s) 图不再进缩略图队列(跨域必败,只换来 thumb-fail 日志)、内存护栏改看 `procEstMB`(估算进程 = JS 堆 + 字节缓存 + 解码位图,阈值 800MB;只盯 JS 堆时 106 张图堆 20MB / 位图 200MB,护栏永远不动);上一条 `v3.26.117+3809c38` —— 2026-11-30 **内存:图片字节预算 + 绝对占用护栏 + 诊断页「立即回收内存」**(Windows 测试版,未发布):`image-blob-store` 的 LRU 补字节预算(96MB ≈ 20 张原图,原来只按 200 条封顶 ⇒ 4~7.5MB 原图最多常驻 1.5GB)并新增 `trim()`;内存护栏在「上限 75%」(4GB ⇒ 3.1GB)之外补一条 ≥900MB 的绝对占用线,每 2 分钟做一次轻量回收;诊断页新增节点级 `nodeBigSamples`、`blobCacheMB/N`、`objUrls`,并把「内存」改称「JS 堆Line truncated
|
||||
<!-- 2026-10-28 P1 拆分批 1:新增 src/generation-task-graph.js(5 个任务图纯函数自 app.js 迁出)
|
||||
⇒ 模块数 60→61、耦合面 51→52、sourceModules 60→61。耦合面只**新增** IWBWTaskGraph,无删除。
|
||||
2026-10-28 P1 拆分批 2:新增 src/storage-config-shape.js(9 个配置形状纯函数自 app.js 迁出)
|
||||
@@ -17,12 +17,12 @@
|
||||
|
||||
## 1. 速查(30 秒版)
|
||||
|
||||
- 渲染是 **DOM-per-node**(不是 canvas 绘制);**视口裁剪已存在**,余量 **240px**(v3.26.109 起带图节点收紧到 **80px**,见下) (A) `src/canvas-geometry.js` `cullRectsOf`。
|
||||
- 渲染是 **DOM-per-node**(不是 canvas 绘制);**视口裁剪已存在**,余量 **280px**(v3.26.143 统一;带图节点不再单独收紧) (A) `src/canvas-geometry.js` `cullRectsOf`。
|
||||
- **平移 = 每帧 `setViewport`**;**拖动 = 直接写 DOM transform、不 `setNodes`**。**这两条不许互换**(见 §9)。
|
||||
- 图片**新写入主通道 = IndexedDB Blob `{__blob}` / key `imgblob_<hash>_<len>`** (A) `app.js:2143`;`{__cache}`(Cache Storage)为兜底;\`ref_\`(`app.js` 内定义的 `IDB_REF_PREFIX = 'ref_'`)为 legacy 形态 (A)。
|
||||
- 大图判定:`isBigDataUrl` = `data:` 且 `length > 3000` (A) `app.js:2018`;**画布保存保留阈值** `< 16384` 才原样保留 (A) `app.js:2182`。**两处阈值并存,含义不同**。
|
||||
- 单测是**源码契约测试**:`tests/` 目录共 **493** 处源码文本钉点(`source.includes` / `source.indexOf` / `/re/.test(source)`),分布在 **20** 个文件(其中 `iwb-v32-web-test.js` 一个就占 **407**)→ **结构性重构会先打红测试**。**该数字已由 `tests/source-text-ratchet-test.js` 的「只减不增」棘轮守门**(2026-10-20 起守卫范围从 1 个文件扩到全目录:新增任何一处源码文本钉点都会打红)。**2026-11-12 复算**(`npm run audit:pins`,v3.24.76):二分 STRUCT **417** / NAME **76**;形态 **POS 403 / NEG 87 / COUNT 3**;难度 **易 62 / 中 316 / 难 115**。钉点减法第一批(v3.24.72)把 **537 → 505**:8 条探针钉点改为「门禁内 spec 是否真的读该计数器」、5 条改为运行时断言(生产态 `window` 上无探针)、10 条改为 DOM 断言(质量档位禁用 / 传输页无三模式按钮 / 模型项 title)、4 条改为运行时对象断言(健康检查两域、策略对象冻结)、其余 9 条有同文件 DOM 等价断言或仅剩 NEG。第二批(v3.24.76)把 **505 → 493**:94-5~7 三条「多标签释放语义」(10 处正则)换成 `tests/iwb-tabs-release.spec.js` 的 3 条真 e2e,剩 1 条「消费方契约」(断言该 spec 在门禁内且 spec 源码真的读两个探针);另 2 条 `wPurgeIntent.add` 钉点改为读 `src/workspace-purge.js`。**这一批一换就查出 3 个真缺陷**(objectURL 从未释放 / 彻底删除留孤儿标签 · session / 刷新后误回收打开标签的图)—— 见 CHANGELOG v3.24.76。
|
||||
- `app.js` = 单 IIFE **8,620 行**(**双层预算**:绝对上限 8,665 / 占总源码 ≤ 40%,现 **25.9%**,2026-11-12 起;此前为单一上限 8,509、零余量);`Workbench()` = **2,221 行**(上限 **2,231**,余量 10;2026-11-16 把生成取消族 `cancelRunsFor`/`cancelRun`/`cancelTaskJobs` 与工作区列表写回族 `persistWs`/`duplicateWs` 搬进 `src/runtime-workbench-logic.js`(`createCancelActions` / `createWorkspaceListActions`),并删掉全仓零调用的 `runAll`,3090 → 2,998);大量逻辑已抽到 `src/*.js`(现 **119** 个模块 / 24,653 行,`sourceModules` 119 项;v3.24.68 新增 `clipboard-graph.js`,v3.24.74 新增 `image-admit.js`,v3.24.75 新增 `image-dedupe.js`,v3.24.76 新增 `workspace-purge.js`,v3.24.79 新增 `generation-provider-ping.js`,v3.24.80 删除无调用的 `createWBFlushViewport` 17 行)。
|
||||
- `app.js` = 单 IIFE **8,720 行**(**双层预算**:绝对上限 8,720 / 占总源码 ≤ 40%,现 **25.8%**,2026-11-12 起;此前为单一上限 8,509、零余量);`Workbench()` = **2,318 行**(上限 **2,318**,余量 0;2026-11-16 把生成取消族 `cancelRunsFor`/`cancelRun`/`cancelTaskJobs` 与工作区列表写回族 `persistWs`/`duplicateWs` 搬进 `src/runtime-workbench-logic.js`(`createCancelActions` / `createWorkspaceListActions`),并删掉全仓零调用的 `runAll`,3090 → 2,998);大量逻辑已抽到 `src/*.js`(现 **123** 个模块 / 25,096 行,`sourceModules` 123 项;v3.24.68 新增 `clipboard-graph.js`,v3.24.74 新增 `image-admit.js`,v3.24.75 新增 `image-dedupe.js`,v3.24.76 新增 `workspace-purge.js`,v3.24.79 新增 `generation-provider-ping.js`,v3.24.80 删除无调用的 `createWBFlushViewport` 17 行)。
|
||||
- 门禁:`npm run verify` = `verify:ci`(`build` → `node --check app.js` → `node --check dist/app.js` → `check-dist.js` → `lint`(ESLint 正确性规则,`src/` + `app.js`,P4-16a)→ `test:unit` → `test` → `test:facts`)+ `test:e2e` (A) `package.json`。
|
||||
|
||||
## 1.5 内存基线(2026-11-30,v3.26.115,Windows / WebView2 实测)
|
||||
@@ -67,9 +67,9 @@
|
||||
|
||||
- **DOM-per-node**:每个节点一个 DOM 元素;不是 canvas 重绘。
|
||||
- **视口裁剪已存在**(不是"待做优化"):
|
||||
- 余量:纯文本节点 `240`px;**带图节点(ref/out/image/combine/batch/plugin:album|gallery)`80`px** (A) `src/canvas-geometry.js` `CULL_PAD_WIDE` / `CULL_PAD_TIGHT`
|
||||
- 余量:所有节点统一 `280`px (A) `src/canvas-geometry.js` `CULL_PAD_WIDE` / `CULL_PAD_TIGHT`
|
||||
- 公式 `left: -vp.x/vp.scale - pad`、`right: (w - vp.x)/vp.scale + pad`(pad 按节点类型取宽/紧)(A) `cullRectsOf`
|
||||
- 为什么分两档(v3.26.109):节点挂上 `<img>` 后浏览器会保留解码位图(1024 缩略图约 4MB、原图 6~20MB);240px 的宽余量意味着屏幕外一两屏的图片仍在解码,实测 WebContent physical footprint 1.2G / 峰值 2.7G
|
||||
- 为什么 280(v3.26.143):80px 让图片节点在平移边缘频繁卸载/重解码;280px 接近参考项目 infinite-canvas 的缓冲区。图片内存由 512/256 缩略图管线控制。
|
||||
- 关闭条件:`canvasSize.w/h` 为 0 时 `cullRect = null`(jsdom/测试全渲染)(A) `app.js:12655,12662`
|
||||
- 豁免:拖拽中 `refs.drag.start[id]`、缩放中 `refs.resize.nodeId`、已选中 `sel.includes` (A) `app.js:12663-12665`
|
||||
- 循环对不可见元素 **`continue`** 跳过(O(n) 布尔过滤,**不是 O(n) 渲染**)(O) `app.js:12684,12705`
|
||||
@@ -142,7 +142,7 @@
|
||||
1. **拖动帧只做 DOM transform(`dragApplyVisual`),不 `setNodes`** —— 本轮最见效一条 (A) 规范 §13.3/§13.7。
|
||||
2. **平移必须走 `setViewport`** —— v3.80.0 曾把"DOM transform 不 setNodes"**套到平移**,引入"中键平移跳位 + 气泡偏移",**v3.80.1 已回退** (A) 规范 §13.3 `:458` + §12 1.2.4 `:403`/`:407`。
|
||||
→ **任何"平移/缩放直写 DOM transform"的优化都属于已知回归,禁止重试。**
|
||||
3. **视口裁剪(240px 余量)** —— 已存在且有效;不要重复实现,也不要为它引入空间索引(见 §10-2)。
|
||||
3. **视口裁剪(280px 余量)** —— 已存在且有效;不要重复实现,也不要为它引入空间索引(见 §10-2)。
|
||||
4. **各缓存上限**(50/50/300/200/400/200)都是有界设计,**调大即调高内存**。
|
||||
5. **`stripBigDataUrlsSync` 惰性探测**(只克隆有图子树)—— 曾改成"全字段深拷贝"致内存 ~2GB (A) 规范 §13.3/§13.7。
|
||||
6. **压缩指纹采样哈希**(禁全量 O(n) 哈希)—— 曾致空闲 CPU 15% (A) 规范 §13.3。
|
||||
@@ -177,7 +177,7 @@
|
||||
- **正确改法**:把预览派生**纳入已有 `runWithConcurrency`**(复用既有原语,别新造闸门)。
|
||||
- **F3|resize 下限不一致** (A)
|
||||
- 节点拖拽视觉下限 `Math.max(180, …)` / `Math.max(90, …)`(`app.js:10912-10913`) vs 全屏窗缩放手柄几何 `Math.max(240, …)`(`app.js:7829-7832`,4 个方向各一处)。
|
||||
- **陷阱**:此处 `240` 与**视口裁剪余量 `240`**(`app.js:12656-12659`)**数值相同但语义无关** → 搜 `240` 时会互相干扰,勿连带改。
|
||||
- **陷阱**:此处 `240` 与**视口裁剪余量 `280`**(`src/canvas-geometry.js`)语义无关 → 搜数值时勿连带改。
|
||||
- **F4|三个缩略图缓存三种上限**(200/300/400,均 FIFO)(A) `app.js:4592/4573/1980`。
|
||||
- **F5|边路径缓存 `pathCache` 超 3000 整体 `clear()`**(非 LRU)(A) `app.js:6006`(`if (pathCache.size > 3000) pathCache.clear()`,紧接 `pathCache.set(key, d)`,`6007`)→ 大规模下可能在平移时出现抖动 cliff。
|
||||
- **命名更正**:该变量是 **`pathCache`**;本文档早期草稿误写为 `edgePathCache`(2026-10-15 更正)。
|
||||
@@ -192,7 +192,7 @@
|
||||
- 同一张图被 3 个节点引用、hydrate 成 3 个不同 objectURL 时,preview/display 缓存各自 miss → 重复解码(与 F2 相邻)。
|
||||
- **F10|`refs.genScheduler` 是桩** (A) → 未接线,暂无运行时影响(P3)。
|
||||
- **F11|已建但未接线的模块层(2026-10-17 接线审计;2026-10-18 复核更正)** (A)
|
||||
- **判定法**:`global.X =` / `root.X =` 判「导出」;跨文件裸引用判「读」;排除自合并(`src/runtime-constants.js:9`)。`app.js` 是**唯一生产消费者**(无 HTML 入口;`sw.js` 不引用模块全局)。**119 个模块中 59 个导出**被 `app.js` 读取;其余为未接线 / 仅测试 / 零引用(见下)。
|
||||
- **判定法**:`global.X =` / `root.X =` 判「导出」;跨文件裸引用判「读」;排除自合并(`src/runtime-constants.js:9`)。`app.js` 是**唯一生产消费者**(无 HTML 入口;`sw.js` 不引用模块全局)。**123 个模块中 59 个导出**被 `app.js` 读取;其余为未接线 / 仅测试 / 零引用(见下)。
|
||||
- **仅被测试引用(9 模块 + 2 导出)**:`canvas-domain`、`generation-retry`、`generation-service`、`runtime-recovery-runner`、`runtime-state-bridge`、`runtime-store`、`storage-reconcile`、`storage-result`、`workspace-service`;导出 `IWBStorageHealthFactory`、`IWBPluginHostFactory`。(`storage-result` 是**存储层共享结果类型**,被 6 个存储模块读取,**非死代码**;`runtime-store` 为状态模型 epic 地基。)
|
||||
- **app.js 零引用(1 模块 + 3 导出)**:模块 `generation-controller`;导出 `IWBRuntimeMetricsFactory`、`IWBStorageRuntimeFactory`、`IWBUIComponents`。`canvas-relations` 已随 `06cf211` 删除(本文档早前把它列为"唯一可删者",实际已删)。零引用证据 = `grep -rn "<名字>" .`(排除 `node_modules|dist|vendor|test-results`)**只命中其自身赋值行**。
|
||||
- **半接线 / 未接线**:`IWBRuntimeStateBridge` **无 app.js 引用(仅测试)**;`IWBRuntimeRunContext` **已接线**(`runNode` 读取运行上下文);`IWBGenerationController` 是完整但**从未被调用**的工厂;`ModularWorkspaceStore`(`app.js` 内)是 `storage-workspace` 的**预留接线 seam**(当前无下游使用,保留);`window.IWBImageFolder` 自注册后读回(装载路径)。
|
||||
@@ -208,7 +208,7 @@
|
||||
| `storage-reconcile` | 存储对账(`createReconciler`/`check`) | 内联对账 | 存储层收口 |
|
||||
| `runtime-recovery-runner` | 执行恢复候选(`candidate`/`valid`/`run`) | 内联恢复 | 断点恢复 |
|
||||
| `canvas-domain` | 画布域模型(`commit`/`updateNode`/`deleteNodes`…) | `CanvasStore` 那一套 | Workbench 解耦(P2-9) |
|
||||
- **耦合面已冻结**:`tests/architecture-boundary-guard-test.js`(进 `npm run test:unit` 末环)冻结 app.js↔src 耦合面(**98** 项)与 `sourceModules` 顺序(**119** 项);命名例外由第 5 组冻结,新增非 `IWB` 前缀导出即打红。
|
||||
- **耦合面已冻结**:`tests/architecture-boundary-guard-test.js`(进 `npm run test:unit` 末环)冻结 app.js↔src 耦合面(**102** 项)与 `sourceModules` 顺序(**123** 项);命名例外由第 5 组冻结,新增非 `IWB` 前缀导出即打红。
|
||||
|
||||
## 12. 易踩的坑
|
||||
|
||||
@@ -279,7 +279,7 @@
|
||||
|
||||
**信任模型(必须明示)**:形态 A 的插件是**可信代码**(与核心同权限、无沙箱);启停与设置是 UX 与可维护性手段,**不是安全边界**(同 §13.27 教训:前端开关一定可被绕过)。
|
||||
|
||||
**守门与快照**:`tests/architecture-boundary-guard-test.js` 冻结「app.js ↔ src 耦合面」(**98** 项)与 `sourceModules` 顺序(**119** 项);新增模块、新增耦合、新增 dev 探针都**必须有意重生成对应快照**(`IWB_WRITE_BOUNDARY_SNAPSHOT=1`)。契约与行为的可执行验证在 `tests/plugin-host-test.js`(宿主单测)与 `tests/_plugin-host-probe.spec.js`(真实浏览器探针,`_` 前缀 + `iwb-dev-probe`,不进 34 门禁)。
|
||||
**守门与快照**:`tests/architecture-boundary-guard-test.js` 冻结「app.js ↔ src 耦合面」(**102** 项)与 `sourceModules` 顺序(**123** 项);新增模块、新增耦合、新增 dev 探针都**必须有意重生成对应快照**(`IWB_WRITE_BOUNDARY_SNAPSHOT=1`)。契约与行为的可执行验证在 `tests/plugin-host-test.js`(宿主单测)与 `tests/_plugin-host-probe.spec.js`(真实浏览器探针,`_` 前缀 + `iwb-dev-probe`,不进 34 门禁)。
|
||||
|
||||
**关键陷阱**:`normalizeNodes`(现位于 `src/canvas-normalize.js`)会**静默丢弃**不在 `NODE_H` 里的节点类型 ⇒ 新增节点类型必须先登记 `NODE_H`,否则节点一刷新就消失(§13.27 规则三的同一失败模式)。
|
||||
|
||||
|
||||
@@ -24,15 +24,18 @@
|
||||
|
||||
## 二、已修(P0)
|
||||
|
||||
边线 SVG 改为**只覆盖当前视口**:
|
||||
边线 SVG 改为**屏幕坐标系**(不是“放在 world 里但用视口矩形”):
|
||||
|
||||
- `src/canvas-geometry.js`:`edgeLayerRect / edgeLayerProps / applyEdgeLayerDom`;
|
||||
- `app.js`:SVG 的 `viewBox / width / height / transform` 由视口反算;
|
||||
- 手势期间 `applyViewportDom` 同步更新(平移用 CSS transform,只有缩放变化才改 width/height);
|
||||
- 合成层从 10000² 变为「一个屏幕大小」:1200×788×4B×dpr² ≈ 15MB(dpr2),而非 1.6GB。
|
||||
- `src/canvas-geometry.js`:`edgeLayerSize / edgeLayerProps / edgeGroupTransform / applyEdgeLayerDom`;
|
||||
- `app.js`:SVG 移出 `.iwb-world`,宽度恒为 `.iwb-canvas` 的 CSS 尺寸;世界坐标由内部 `<g class="iwb-edge-world" transform="translate(x,y) scale(s)">` 负责;
|
||||
- 手势期间 `applyViewportDom` 只更新这个 `<g>` 的 transform,不改 SVG 尺寸;
|
||||
- 合成层从 10000² 变为「一个屏幕大小」:2560×1303×4B×dpr² ≈ 53MB(dpr2),而非 1.6GB。
|
||||
|
||||
数学验收:`tests/canvas-geometry-test.js` 断言视口矩形反算正确、viewBox 不再出现 10000。
|
||||
浏览器实测(Playwright,纯平面):缩放后 SVG 屏幕矩形仍为 0..viewport,viewBox 随视口变化。
|
||||
> **第一版为什么只降了一半**:3.26.141 把 SVG 放进 world,用 `width = viewportW / scale`。缩到 30% 时 CSS width 变成 8000 世界像素,WebKit 仍按 SVG 自身尺寸分配位图 ⇒ graphics 仍有 1032MB。
|
||||
> 3.26.142 把 SVG 移出 world,宽度恒为屏幕 CSS 宽,才真正切断“世界尺寸 → 位图尺寸”的乘法。
|
||||
|
||||
数学验收:`tests/canvas-geometry-test.js` 断言屏幕尺寸、`<g>` 的 transform、viewBox 不含 10000。
|
||||
浏览器实测(Playwright,纯平面):缩放后 SVG 屏幕矩形仍为 0..viewport,width 不再随 scale 变大。
|
||||
|
||||
## 三、第二梯队(按收益排序)
|
||||
|
||||
@@ -82,7 +85,30 @@
|
||||
4. 依次切「合成层」「毛玻璃」开关,各记录一次(只改一个变量);
|
||||
5. 若 WebContent 仍 >800MB,导出诊断 JSON 看 `bmpNN` / `objUrls` / `thumbsMB` / `topBoards`,再定下一刀。
|
||||
|
||||
## 五、代码位置
|
||||
|
||||
## 五、v3.26.143 已落地的第二轮(2026-11-30)
|
||||
|
||||
按 Infinite Canvas 的可借鉴部分改了一版,先发测试包:
|
||||
|
||||
1. **world/grid 不再默认常驻合成**:`.iwb-world` / `.iwb-grid` 的 `will-change` 改为显式 opt-in(诊断页勾选才开);默认 `data-layers="off"`。
|
||||
2. **网格回到视口大小**:`.iwb-grid` 从 `200%` + `transform` 改为 `inset:0` + `background-position`,避免为背景多分一层。
|
||||
3. **裁剪缓冲区 80 → 280**:带图节点不再在平移边缘频繁卸载/重解码。
|
||||
4. **平移 DOM 写入 rAF 合批**:同一帧多个 pointermove 只写一次 world/grid/edge。
|
||||
5. **自动回收只在应用不可见时跑**,且保留显示缩略图(`keepThumbs:true`);可见时不再清缓存触发周期性重载。手动「立即回收」仍清。
|
||||
6. **图库预热 6s → 30s**,并在手势期间暂停。
|
||||
|
||||
验收仍按 §四:同画布 graphics <300MB、整树 <800MB、平移/缩放长帧减少、无图片闪烁。
|
||||
|
||||
## 六、v3.26.144 已落地(2026-11-30):Canvas 边线 + 平移全量渲染
|
||||
|
||||
1. **边线视觉改 Canvas 2D**:`src/ui-canvas-edges.js` 用视口 canvas 画贝塞尔;`<svg class="iwb-edges">` 只保留透明 hit path(选择/双击/悬停),不再每帧重栅格化 SVG。
|
||||
2. **canvas 只画视口**:DPR 封顶 2;正常边线约 100 条,绘制成本远低于 SVG 合成层。
|
||||
3. **平移期间全量渲染**:`nodeVisibleIn(..., { pan: true })` 返回 true,避免 viewport state 不更新导致裁剪窗口停在起点、超过 280px 后节点空白;松手恢复裁剪。
|
||||
4. **平移仍 rAF 合批**:pointermove 只记位置,rAF 一次写 world/grid/edge canvas。
|
||||
5. **弹线/拖动节点命令式重画 canvas**:`dragApplyVisual` 与 `applyViewportDom` 都调用 `refs.edgeCanvasDraw`,不触发 React。
|
||||
|
||||
验收:平移 1000px 不出现节点迟到/空白;边线选择/双击仍可用;graphics 不再包含 SVG 边线层。
|
||||
## 七、代码位置
|
||||
|
||||
- 边线层:`src/canvas-geometry.js`(edgeLayer* / applyViewportDom)、`app.js`(`.iwb-edges` 渲染)
|
||||
- 视口手势:`app.js` → `applyViewportDom`
|
||||
|
||||
+2
-2
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "image-workbench-web",
|
||||
"private": true,
|
||||
"version": "3.26.141",
|
||||
"version": "3.26.146",
|
||||
"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/workbench-logic-test.js && node tests/storage-autobackup-test.js && node tests/storage-outputs-mutate-test.js && node tests/sync-facts-guard-test.js && node tests/e2e-fixed-waits-ratchet-test.js && node tests/shell-render-behavior-test.js && node tests/canvas-meta-notice-behavior-test.js && node tests/source-text-ratchet-test.js && node tests/plugin-theme-contract-test.js && node tests/prompt-md-roundtrip-test.js && node tests/generation-results-store-test.js && node tests/out-groups-order-test.js && node tests/native-overlay-park-test.js && node tests/ui-dock-sanitize-test.js && node tests/ui-minimap-fit-test.js && node tests/ui-workbench-hooks-test.js && node tests/plugin-scale-contract-test.js && node tesLine truncated
|
||||
"test:diagnostics": "node tests/runtime-diagnostics-hotpath-test.js",
|
||||
"test:facts": "node tests/architecture-facts-guard-test.js && node tests/release-records-test.js",
|
||||
"plugins:gc": "node scripts/plugins-publish.mjs --gc",
|
||||
|
||||
@@ -102,6 +102,9 @@ const sourceModules = [
|
||||
'ui-dock-panels.js',
|
||||
'theme-tokens.js',
|
||||
'canvas-grid.js',
|
||||
'canvas-v3.js',
|
||||
'canvas-v3-node-layer.js',
|
||||
'canvas-v3-hit.js',
|
||||
'image-display-thumb.js',
|
||||
'image-cache-migrate.js',
|
||||
'runtime-frame-probe.js',
|
||||
@@ -129,6 +132,7 @@ const sourceModules = [
|
||||
'runtime-plugin-market.js',
|
||||
'runtime-plugin-backup.js',
|
||||
'ui-canvas-view.js',
|
||||
'ui-canvas-edges.js',
|
||||
'ui-canvas-pointer.js',
|
||||
'ui-canvas-nodes.js',
|
||||
'ui-confirm.js',
|
||||
|
||||
+2
-2
@@ -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.141-mx3bw0er">
|
||||
<link rel="stylesheet" href="/assets/style.css?v=3.26.146-mx3i4t2k">
|
||||
<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.141</a>
|
||||
<a class="btn primary" href="/download/">下载 v3.26.146</a>
|
||||
</div>
|
||||
</div></nav>
|
||||
<main>
|
||||
|
||||
@@ -57,13 +57,13 @@
|
||||
<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.141 · 9.7 MB · .dmg<div class="hash">sha256 ae972d3d4a1707f6…</div></div>
|
||||
<a class="btn" href="/updates/darwin-aarch64/image-workbench_3.26.141_aarch64.dmg?h=ae972d3d4a17">下载</a>
|
||||
<div class="meta">版本 3.26.146 · 9.7 MB · .dmg<div class="hash">sha256 a380f10b3d1d77e7…</div></div>
|
||||
<a class="btn" href="/updates/darwin-aarch64/image-workbench_3.26.146_aarch64.dmg?h=a380f10b3d1d">下载</a>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="name">macOS · Intel<div class="hint">x86_64</div></div>
|
||||
<div class="meta">版本 3.26.141 · 10.1 MB · .dmg<div class="hash">sha256 bd592c9cb428b66e…</div></div>
|
||||
<a class="btn" href="/updates/darwin-x86_64/image-workbench_3.26.141_x64.dmg?h=bd592c9cb428">下载</a>
|
||||
<div class="meta">版本 3.26.146 · 10.1 MB · .dmg<div class="hash">sha256 464d13071f0f49d1…</div></div>
|
||||
<a class="btn" href="/updates/darwin-x86_64/image-workbench_3.26.146_x64.dmg?h=464d13071f0f">下载</a>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="name">Windows · x64<div class="hint">需要 WebView2</div></div>
|
||||
@@ -97,6 +97,26 @@
|
||||
</ol>
|
||||
|
||||
<h2>历史版本</h2>
|
||||
<div class="row">
|
||||
<div class="name">3.26.146</div>
|
||||
<div class="meta">2026-11-30<div class="hint">macOS · Apple Silicon / macOS · Intel</div></div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="name">3.26.145</div>
|
||||
<div class="meta">2026-11-30<div class="hint">macOS · Apple Silicon / macOS · Intel</div></div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="name">3.26.144</div>
|
||||
<div class="meta">2026-11-30<div class="hint">macOS · Apple Silicon / macOS · Intel</div></div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="name">3.26.143</div>
|
||||
<div class="meta">2026-11-30<div class="hint">macOS · Apple Silicon / macOS · Intel</div></div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="name">3.26.142</div>
|
||||
<div class="meta">2026-11-30<div class="hint">macOS · Apple Silicon / macOS · Intel</div></div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="name">3.26.141</div>
|
||||
<div class="meta">2026-11-30<div class="hint">macOS · Apple Silicon / macOS · Intel</div></div>
|
||||
|
||||
+7
-7
@@ -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.141-mx3bw0er">
|
||||
<link rel="stylesheet" href="/assets/style.css?v=3.26.146-mx3i4t2k">
|
||||
</head><body>
|
||||
<nav><div class="wrap inner">
|
||||
<a class="brand" href="/"><img class="logo" src="/assets/logo.png" alt="" width="26" height="26">Image Workbench</a>
|
||||
@@ -17,19 +17,19 @@
|
||||
</div>
|
||||
<div class="right">
|
||||
<a class="btn" href="/plugins/">插件市场</a>
|
||||
<a class="btn primary" href="/download/">下载 v3.26.141</a>
|
||||
<a class="btn primary" href="/download/">下载 v3.26.146</a>
|
||||
</div>
|
||||
</div></nav>
|
||||
<main>
|
||||
<section class="hero hero-art">
|
||||
<div class="hero-bg"><img src="/assets/painting.jpg?v=3.26.141-mx3bw0er" alt=""></div>
|
||||
<div class="hero-bg"><img src="/assets/painting.jpg?v=3.26.146-mx3i4t2k" alt=""></div>
|
||||
<div class="hero-veil"></div>
|
||||
<div class="wrap">
|
||||
<span class="kicker">v3.26.141 · macOS / Windows · 数据在本地</span>
|
||||
<span class="kicker">v3.26.146 · macOS / Windows · 数据在本地</span>
|
||||
<h1>本地优先的<br>AI 生图无限画布</h1>
|
||||
<p class="sub">用节点把「参考图 → 提示词 → 批量生成 → 图库」串成一条生产线。<br>图片、提示词、模型配置全部留在你自己的电脑里,插件按需安装。</p>
|
||||
<div class="cta">
|
||||
<a class="btn primary lg" href="/download/">下载 v3.26.141</a>
|
||||
<a class="btn primary lg" href="/download/">下载 v3.26.146</a>
|
||||
<a class="btn lg" href="/plugins/">浏览 13 个插件</a>
|
||||
</div>
|
||||
<div class="meta">支持 macOS 12+ 与 Windows 10 1803+ · 安装包约 7 MB · 无需登录</div>
|
||||
@@ -96,8 +96,8 @@
|
||||
<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.141_aarch64.dmg?h=ae972d3d4a17"><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.141_x64.dmg?h=bd592c9cb428"><div class="n">macOS · Intel</div><div class="s">x86_64 · 10.1 MB · .dmg</div></a>
|
||||
<div class="dl"><a href="/updates/darwin-aarch64/image-workbench_3.26.146_aarch64.dmg?h=a380f10b3d1d"><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.146_x64.dmg?h=464d13071f0f"><div class="n">macOS · Intel</div><div class="s">x86_64 · 10.1 MB · .dmg</div></a>
|
||||
<div class="none"><div class="n">Windows · x64</div><div class="s">暂未提供</div></div></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>
|
||||
|
||||
@@ -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.141-mx3bw0er">
|
||||
<link rel="stylesheet" href="/assets/style.css?v=3.26.146-mx3i4t2k">
|
||||
</head><body>
|
||||
<nav><div class="wrap inner">
|
||||
<a class="brand" href="/"><img class="logo" src="/assets/logo.png" alt="" width="26" height="26">Image Workbench</a>
|
||||
@@ -16,7 +16,7 @@
|
||||
</div>
|
||||
<div class="right">
|
||||
<a class="btn" href="/plugins/">插件市场</a>
|
||||
<a class="btn primary" href="/download/">下载 v3.26.141</a>
|
||||
<a class="btn primary" href="/download/">下载 v3.26.146</a>
|
||||
</div>
|
||||
</div></nav>
|
||||
<main>
|
||||
|
||||
+106
-1
@@ -1,8 +1,113 @@
|
||||
{
|
||||
"app": "Image Workbench",
|
||||
"subtitle": "本地优先的 AI 生图无限画布 · 桌面版(Tauri v2)",
|
||||
"updatedAt": "2026-11-30T13:53:14.933Z",
|
||||
"updatedAt": "2026-11-30T16:48:03.021Z",
|
||||
"releases": [
|
||||
{
|
||||
"version": "3.26.146",
|
||||
"date": "2026-11-30",
|
||||
"notes": "",
|
||||
"platforms": {
|
||||
"darwin-aarch64": {
|
||||
"file": "updates/darwin-aarch64/image-workbench_3.26.146_aarch64.dmg",
|
||||
"size": 10142147,
|
||||
"sha256": "a380f10b3d1d77e7dfd8f451e7a7ad6cc086af187fdd62332705c1e7f1a5c616",
|
||||
"h": "a380f10b3d1d",
|
||||
"kind": "dmg"
|
||||
},
|
||||
"darwin-x86_64": {
|
||||
"file": "updates/darwin-x86_64/image-workbench_3.26.146_x64.dmg",
|
||||
"size": 10599790,
|
||||
"sha256": "464d13071f0f49d1a0ef6b376a907f7c767eb94b0c1cbbb255d0387fddbc34df",
|
||||
"h": "464d13071f0f",
|
||||
"kind": "dmg"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"version": "3.26.145",
|
||||
"date": "2026-11-30",
|
||||
"notes": "",
|
||||
"platforms": {
|
||||
"darwin-aarch64": {
|
||||
"file": "updates/darwin-aarch64/image-workbench_3.26.145_aarch64.dmg",
|
||||
"size": 10143674,
|
||||
"sha256": "a9a3840b3368021a2f070dfb3dadc77d40ba93335ddd80efce17d18b2b320a0f",
|
||||
"h": "a9a3840b3368",
|
||||
"kind": "dmg"
|
||||
},
|
||||
"darwin-x86_64": {
|
||||
"file": "updates/darwin-x86_64/image-workbench_3.26.145_x64.dmg",
|
||||
"size": 10601583,
|
||||
"sha256": "ff13e4950e97699c38687d04a6d956b6d096d5805585935023d46f33856ca2d7",
|
||||
"h": "ff13e4950e97",
|
||||
"kind": "dmg"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"version": "3.26.144",
|
||||
"date": "2026-11-30",
|
||||
"notes": "",
|
||||
"platforms": {
|
||||
"darwin-aarch64": {
|
||||
"file": "updates/darwin-aarch64/image-workbench_3.26.144_aarch64.dmg",
|
||||
"size": 10140731,
|
||||
"sha256": "f273170522ac9ed0f8fe867d6f019d27cec4a1d256f53441cfe69040da8c09a8",
|
||||
"h": "f273170522ac",
|
||||
"kind": "dmg"
|
||||
},
|
||||
"darwin-x86_64": {
|
||||
"file": "updates/darwin-x86_64/image-workbench_3.26.144_x64.dmg",
|
||||
"size": 10600079,
|
||||
"sha256": "dadc7270c40a6c0ff1bf787dafcaf47a23a80e471167c07ad8025f55a16861bd",
|
||||
"h": "dadc7270c40a",
|
||||
"kind": "dmg"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"version": "3.26.143",
|
||||
"date": "2026-11-30",
|
||||
"notes": "",
|
||||
"platforms": {
|
||||
"darwin-aarch64": {
|
||||
"file": "updates/darwin-aarch64/image-workbench_3.26.143_aarch64.dmg",
|
||||
"size": 10138512,
|
||||
"sha256": "b09f2b1ea2a97983df1b6a1729ec3a50b5a7e6d9aa67ebd4686b89655b15de35",
|
||||
"h": "b09f2b1ea2a9",
|
||||
"kind": "dmg"
|
||||
},
|
||||
"darwin-x86_64": {
|
||||
"file": "updates/darwin-x86_64/image-workbench_3.26.143_x64.dmg",
|
||||
"size": 10594553,
|
||||
"sha256": "dfb40bfc8c8c5ae4bd35832925c81ea8c3e454bb912e31e09c81dc4e11bff64e",
|
||||
"h": "dfb40bfc8c8c",
|
||||
"kind": "dmg"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"version": "3.26.142",
|
||||
"date": "2026-11-30",
|
||||
"notes": "",
|
||||
"platforms": {
|
||||
"darwin-aarch64": {
|
||||
"file": "updates/darwin-aarch64/image-workbench_3.26.142_aarch64.dmg",
|
||||
"size": 10137638,
|
||||
"sha256": "6c7febdc968ee626434a5334665a65022fb6a1a2e7188e530a54d083f7110e96",
|
||||
"h": "6c7febdc968e",
|
||||
"kind": "dmg"
|
||||
},
|
||||
"darwin-x86_64": {
|
||||
"file": "updates/darwin-x86_64/image-workbench_3.26.142_x64.dmg",
|
||||
"size": 10596451,
|
||||
"sha256": "8fa3e45e17d0f1526c32d8c7328f60129d32da74648fe05d2177cedc69571ce1",
|
||||
"h": "8fa3e45e17d0",
|
||||
"kind": "dmg"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"version": "3.26.141",
|
||||
"date": "2026-11-30",
|
||||
|
||||
Generated
+1
-1
@@ -2014,7 +2014,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "image-workbench"
|
||||
version = "3.26.141"
|
||||
version = "3.26.146"
|
||||
dependencies = [
|
||||
"arboard",
|
||||
"base64 0.22.1",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "image-workbench"
|
||||
version = "3.26.141"
|
||||
version = "3.26.146"
|
||||
description = "无限画布 · 生图工作台桌面版"
|
||||
authors = ["malongan"]
|
||||
license = ""
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"$schema": "../node_modules/@tauri-apps/cli/config.schema.json",
|
||||
"productName": "image-workbench",
|
||||
"version": "3.26.141",
|
||||
"version": "3.26.146",
|
||||
"identifier": "com.malongan.imageworkbench",
|
||||
"build": {
|
||||
"frontendDist": "../dist",
|
||||
|
||||
+22
-27
@@ -358,8 +358,9 @@
|
||||
// 动机:节点一旦挂上 <img>,浏览器就为它保留解码位图(1024 缩略图约 4MB、原图 6~20MB)。
|
||||
// 原来统一 240px 边距 ⇒ 屏幕外一两屏的图仍常驻解码(实测 WebContent footprint 1.2G / 峰值 2.7G)。
|
||||
// 现在带图节点只留 80px,同一时刻常驻解码的图片数量明显下降;纯文本节点仍用 240px,避免平移时文字闪。
|
||||
const CULL_PAD_WIDE = 240 // v3.26.140:回到 108 的 240(480 会让每帧多挂载节点 ⇒ 卡)
|
||||
const CULL_PAD_TIGHT = 80 // v3.26.140:回到 108 的 80
|
||||
// v3.26.143:参考 infinite-canvas 的 280px 缓冲;80px 会让图片节点在平移边缘反复卸载/重解码。
|
||||
const CULL_PAD_WIDE = 280
|
||||
const CULL_PAD_TIGHT = 280
|
||||
const heavyNodeOf = (type) => {
|
||||
const t = String(type || '')
|
||||
return /^(ref|out|image|combine|batch)$/.test(t) || /^plugin:(album|gallery)/.test(t)
|
||||
@@ -383,6 +384,9 @@
|
||||
if (o.drag && o.drag.start && o.drag.start[n.id] != null) return true
|
||||
if (o.resize && o.resize.nodeId === n.id) return true
|
||||
if (o.sel && o.sel.indexOf(n.id) >= 0) return true
|
||||
// v3.26.144:平移只改 DOM transform,viewport state 不更新 ⇒ 裁剪窗口会停在起点;
|
||||
// 平移期间全量渲染(103 节点规模可接受),避免超过 280px 后新区域节点迟到/空白。
|
||||
if (o.pan) return true
|
||||
const r = heavyNodeOf(n.type) ? rects.tight : rects.wide
|
||||
const nw = o.widthOf ? o.widthOf(n) : 0
|
||||
const nh = o.heightOf ? o.heightOf(n) : 0
|
||||
@@ -398,17 +402,20 @@
|
||||
return p ? { x: p.x - (w || 0) / 2, y: p.y - (h || 0) / 2 } : null
|
||||
} catch (e) { return null }
|
||||
}
|
||||
// 边线 SVG 的可见世界矩形(2026-11-30):只给视口大小,避免 10000² 的合成位图。
|
||||
function edgeLayerRect (canvasSize, viewport) {
|
||||
const w = Math.max(1, Number(canvasSize && canvasSize.w) || 800)
|
||||
const h = Math.max(1, Number(canvasSize && canvasSize.h) || 600)
|
||||
const s0 = Number(viewport && viewport.scale) || 1
|
||||
const s = s0 > 0 ? s0 : 1
|
||||
return { x: -(Number(viewport && viewport.x) || 0) / s, y: -(Number(viewport && viewport.y) || 0) / s, w: w / s, h: h / s, s: s }
|
||||
// 边线 SVG 固定放在屏幕坐标系:宽度恒为视口 CSS 宽,不会按世界尺寸分配合成位图。
|
||||
// 世界坐标由内部 <g class="iwb-edge-world"> 的 transform 负责;缩小画布时也不会让 SVG 变大。
|
||||
function edgeLayerSize (canvasSize) {
|
||||
return { w: Math.max(1, Number(canvasSize && canvasSize.w) || 800), h: Math.max(1, Number(canvasSize && canvasSize.h) || 600) }
|
||||
}
|
||||
function edgeLayerProps (canvasSize, viewport) {
|
||||
const r = edgeLayerRect(canvasSize, viewport)
|
||||
return { viewBox: r.x + ' ' + r.y + ' ' + r.w + ' ' + r.h, width: r.w, height: r.h, style: { left: 0, top: 0, width: r.w + 'px', height: r.h + 'px', overflow: 'hidden', transform: 'translate(' + r.x + 'px,' + r.y + 'px) translateZ(0)' } }
|
||||
function edgeLayerProps (canvasSize) {
|
||||
const r = edgeLayerSize(canvasSize)
|
||||
return { width: r.w, height: r.h, viewBox: '0 0 ' + r.w + ' ' + r.h, style: { left: 0, top: 0, width: r.w + 'px', height: r.h + 'px', overflow: 'hidden' } }
|
||||
}
|
||||
function edgeGroupTransform (viewport) {
|
||||
const x = Number(viewport && viewport.x) || 0
|
||||
const y = Number(viewport && viewport.y) || 0
|
||||
const s = Number(viewport && viewport.scale) > 0 ? Number(viewport.scale) : 1
|
||||
return 'translate(' + x + ',' + y + ') scale(' + s + ')'
|
||||
}
|
||||
function applyViewportDom (root, canvasSize, x, y, scale, gridOpts) {
|
||||
if (!root) return
|
||||
@@ -427,21 +434,9 @@
|
||||
}
|
||||
}
|
||||
function applyEdgeLayerDom (root, canvasSize, x, y, scale) {
|
||||
const es = root && root.querySelector ? root.querySelector('.iwb-edges') : null
|
||||
if (!es) return
|
||||
const s = Number(scale) > 0 ? Number(scale) : 1
|
||||
const ew = Math.max(1, (Number(canvasSize && canvasSize.w) || 800) / s)
|
||||
const eh = Math.max(1, (Number(canvasSize && canvasSize.h) || 600) / s)
|
||||
const ex = -(Number(x) || 0) / s, ey = -(Number(y) || 0) / s
|
||||
es.setAttribute('viewBox', ex + ' ' + ey + ' ' + ew + ' ' + eh)
|
||||
// 平移用 transform(合成器),只有缩放变化才改 width/height(避免每帧布局)
|
||||
if (es.__iwbEdgeScale !== s) {
|
||||
es.__iwbEdgeScale = s
|
||||
es.style.width = ew + 'px'
|
||||
es.style.height = eh + 'px'
|
||||
}
|
||||
es.style.transform = 'translate(' + ex + 'px,' + ey + 'px) translateZ(0)'
|
||||
const g = root && root.querySelector ? root.querySelector('.iwb-edge-world') : null
|
||||
if (g) g.setAttribute('transform', edgeGroupTransform({ x: x, y: y, scale: scale }))
|
||||
}
|
||||
|
||||
global.IWBCanvasGeometry = Object.freeze({ connectReasonOf, cullRectsOf, nodeVisibleIn, heavyNodeOf, edgeLayerRect, edgeLayerProps, applyEdgeLayerDom, applyViewportDom, distToSeg, wantsDefaultSpot, promptCenterSpot, parseWorldTransform, clientToWorld, snapToFreeSpot, placeBeside, pruneMeasured, seedFromTopLeft, clampIntoBounds, lodLowOf, lodModeOf, zoomStep, LOD_NODE_PX, LOD_PLAIN_SCALE, ZOOM_STEP, ZOOM_MIN, ZOOM_MAX, create })
|
||||
global.IWBCanvasGeometry = Object.freeze({ connectReasonOf, cullRectsOf, nodeVisibleIn, heavyNodeOf, edgeLayerSize, edgeLayerProps, edgeGroupTransform, applyEdgeLayerDom, applyViewportDom, distToSeg, wantsDefaultSpot, promptCenterSpot, parseWorldTransform, clientToWorld, snapToFreeSpot, placeBeside, pruneMeasured, seedFromTopLeft, clampIntoBounds, lodLowOf, lodModeOf, zoomStep, LOD_NODE_PX, LOD_PLAIN_SCALE, ZOOM_STEP, ZOOM_MIN, ZOOM_MAX, create })
|
||||
})(typeof window !== 'undefined' ? window : globalThis)
|
||||
+3
-2
@@ -57,7 +57,8 @@
|
||||
return {
|
||||
backgroundImage: 'url(' + url + ')',
|
||||
backgroundSize: gap + 'px ' + gap + 'px',
|
||||
transform: 'translate(' + (x % gap) + 'px, ' + (y % gap) + 'px)',
|
||||
// 视口大小的网格层用 background-position 跟随平移;不再把元素平移出屏幕(那需要 200% 尺寸的层)。
|
||||
backgroundPosition: (x % gap) + 'px ' + (y % gap) + 'px',
|
||||
}
|
||||
}
|
||||
|
||||
@@ -75,7 +76,7 @@
|
||||
el.dataset.gap = String(gap)
|
||||
el.dataset.style = String(o.style || 'dots')
|
||||
}
|
||||
el.style.transform = 'translate(' + (x % gap) + 'px, ' + (y % gap) + 'px)'
|
||||
el.style.backgroundPosition = (x % gap) + 'px ' + (y % gap) + 'px'
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
/* canvas-v3-hit.js —— Canvas V3 节点命中测试(2026-12-01)
|
||||
* ref: body + 端口;P2 文本节点只做 body,端口先留给选中后的 NodeCard。
|
||||
*/
|
||||
;(function (global) {
|
||||
'use strict'
|
||||
function hitNode (nodes, wx, wy, opts) {
|
||||
const o = opts || {}
|
||||
const isType = typeof o.isType === 'function' ? o.isType : (n) => n && n.type === 'ref'
|
||||
const widthOf = typeof o.widthOf === 'function' ? o.widthOf : (n) => n.w || 240
|
||||
const heightOf = typeof o.heightOf === 'function' ? o.heightOf : (n) => n.h || 220
|
||||
const portR = Number(o.portRadiusWorld) > 0 ? Number(o.portRadiusWorld) : 10
|
||||
const wantPorts = o.wantPorts !== false
|
||||
const list = Array.isArray(nodes) ? nodes : []
|
||||
for (let i = list.length - 1; i >= 0; i--) {
|
||||
const n = list[i]
|
||||
if (!n || !isType(n)) continue
|
||||
const w = widthOf(n), h = heightOf(n)
|
||||
const cy = n.y + h / 2
|
||||
if (wantPorts && n.type === 'ref') {
|
||||
if (wx >= n.x - portR && wx <= n.x + portR && Math.abs(wy - cy) <= portR) return { node: n, port: 'in' }
|
||||
if (Math.abs(wx - (n.x + w)) <= portR && Math.abs(wy - cy) <= portR) return { node: n, port: 'out' }
|
||||
}
|
||||
if (wx >= n.x && wx <= n.x + w && wy >= n.y && wy <= n.y + h) return { node: n, port: '' }
|
||||
}
|
||||
return null
|
||||
}
|
||||
function hitRefNode (nodes, wx, wy, opts) {
|
||||
return hitNode(nodes, wx, wy, Object.assign({}, opts || {}, { isType: (n) => n && n.type === 'ref', wantPorts: true }))
|
||||
}
|
||||
global.IWBCanvasV3Hit = { hitNode, hitRefNode }
|
||||
})(typeof window !== 'undefined' ? window : globalThis)
|
||||
@@ -0,0 +1,204 @@
|
||||
/* canvas-v3-node-layer.js —— Canvas V3 图片节点静态层(2026-12-01,P1 垂直切片)
|
||||
*
|
||||
* 仅当 data-canvas-v3="on" 时由 app 挂载;未选中的 ref 节点由 canvas 画卡片/标题/图片,
|
||||
* DOM 只保留一个透明 hit proxy。选中后恢复完整 NodeCard。
|
||||
* 目标与限制见 docs/plans/canvas-v3-long-term.md。
|
||||
*/
|
||||
;(function (global) {
|
||||
'use strict'
|
||||
const React = global.React || {}
|
||||
const el = (type, prop, ...children) => React.createElement(type, prop, ...children)
|
||||
const useRef = React.useRef
|
||||
const useEffect = React.useEffect
|
||||
const useState = React.useState
|
||||
const imgCache = new Map()
|
||||
const perf = { lastMs: 0, frames: 0 }
|
||||
|
||||
function css (name, fallback) {
|
||||
try {
|
||||
const v = getComputedStyle(document.documentElement).getPropertyValue(name).trim()
|
||||
return v || fallback
|
||||
} catch (e) { return fallback }
|
||||
}
|
||||
|
||||
function roundRect (ctx, x, y, w, h, r) {
|
||||
const rr = Math.max(0, Math.min(r, w / 2, h / 2))
|
||||
ctx.beginPath()
|
||||
ctx.moveTo(x + rr, y)
|
||||
ctx.arcTo(x + w, y, x + w, y + h, rr)
|
||||
ctx.arcTo(x + w, y + h, x, y + h, rr)
|
||||
ctx.arcTo(x, y + h, x, y, rr)
|
||||
ctx.arcTo(x, y, x + w, y, rr)
|
||||
ctx.closePath()
|
||||
}
|
||||
|
||||
function imageOf (url, onLoad) {
|
||||
if (!url) return null
|
||||
let entry = imgCache.get(url)
|
||||
if (!entry) {
|
||||
entry = { img: new Image(), loaded: false }
|
||||
entry.img.decoding = 'async'
|
||||
entry.img.onload = () => { entry.loaded = true; if (typeof onLoad === 'function') onLoad() }
|
||||
entry.img.onerror = () => { entry.failed = true; if (typeof onLoad === 'function') onLoad() }
|
||||
entry.img.src = url
|
||||
imgCache.set(url, entry)
|
||||
}
|
||||
return entry
|
||||
}
|
||||
|
||||
function draw (canvas, o) {
|
||||
if (!canvas || !o || typeof canvas.getContext !== 'function') return
|
||||
const t0 = (typeof performance !== 'undefined' && performance.now) ? performance.now() : 0
|
||||
const rect = canvas.getBoundingClientRect ? canvas.getBoundingClientRect() : null
|
||||
const w = Math.max(1, Math.round((rect && rect.width) || canvas.clientWidth || 1))
|
||||
const h = Math.max(1, Math.round((rect && rect.height) || canvas.clientHeight || 1))
|
||||
const dpr = Math.min(2, (typeof devicePixelRatio === 'number' && devicePixelRatio > 0) ? devicePixelRatio : 1)
|
||||
if (canvas.width !== Math.round(w * dpr) || canvas.height !== Math.round(h * dpr)) {
|
||||
canvas.width = Math.round(w * dpr); canvas.height = Math.round(h * dpr)
|
||||
}
|
||||
const ctx = canvas.getContext('2d')
|
||||
if (!ctx) return
|
||||
ctx.setTransform(dpr, 0, 0, dpr, 0, 0)
|
||||
ctx.clearRect(0, 0, w, h)
|
||||
const vp = o.viewport || { x: 0, y: 0, scale: 1 }
|
||||
const scale = Number(vp.scale) > 0 ? Number(vp.scale) : 1
|
||||
const nodes = Array.isArray(o.nodes) ? o.nodes : []
|
||||
const sel = Array.isArray(o.sel) ? o.sel : []
|
||||
const widthOf = typeof o.widthOf === 'function' ? o.widthOf : (n) => n.w || 240
|
||||
const heightOf = typeof o.heightOf === 'function' ? o.heightOf : (n) => n.h || 220
|
||||
const imageFor = typeof o.imageFor === 'function' ? o.imageFor : () => ''
|
||||
const outThumbsFor = typeof o.outThumbsFor === 'function' ? o.outThumbsFor : () => []
|
||||
const onImageLoad = o.onImageLoad
|
||||
const types = Array.isArray(o.types) && o.types.length ? o.types : ['ref']
|
||||
const isType = typeof o.isType === 'function' ? o.isType : (n) => types.indexOf(n.type) >= 0
|
||||
const bg = css('--iwb-panel', '#ffffff')
|
||||
const border = css('--iwb-border2', '#d7dbe2')
|
||||
const text = css('--iwb-text2', '#5f6673')
|
||||
const accent = css('--iwb-brand', '#6b7280')
|
||||
const radius = 14
|
||||
const headH = 34
|
||||
ctx.setTransform(dpr * scale, 0, 0, dpr * scale, dpr * (Number(vp.x) || 0), dpr * (Number(vp.y) || 0))
|
||||
ctx.lineJoin = 'round'
|
||||
for (const n of nodes) {
|
||||
if (!n || !isType(n) || sel.indexOf(n.id) >= 0) continue
|
||||
const x = n.x, y = n.y, nw = widthOf(n), nh = heightOf(n)
|
||||
// 卡片
|
||||
ctx.fillStyle = bg
|
||||
roundRect(ctx, x, y, nw, nh, radius)
|
||||
ctx.fill()
|
||||
ctx.strokeStyle = border
|
||||
ctx.lineWidth = 1 / scale
|
||||
ctx.stroke()
|
||||
// 标题
|
||||
ctx.fillStyle = text
|
||||
ctx.font = '600 ' + Math.max(10, 12 / scale * 0.9) + 'px -apple-system, BlinkMacSystemFont, "PingFang SC", sans-serif'
|
||||
const title = String((n.data && (n.data.title || n.data.name)) || ({ ref: '参考图', prompt: '提示词', textout: '文本', combine: '组合', batch: '连接', relay: '中继', gen: '生成配置', plugin: '插件' }[n.type] || (String(n.type).indexOf('plugin:') === 0 ? '插件' : '节点')))
|
||||
ctx.save()
|
||||
ctx.beginPath(); ctx.rect(x + 10, y, Math.max(0, nw - 20), headH); ctx.clip()
|
||||
ctx.fillText(title, x + 12, y + 21)
|
||||
ctx.restore()
|
||||
const pad = 10
|
||||
const ix = x + pad, iy = y + headH, iw = Math.max(1, nw - pad * 2), ih = Math.max(1, nh - headH - pad)
|
||||
if (n.type === 'ref') {
|
||||
// 图片区
|
||||
const raw = n.data && (n.data.data || n.data.url)
|
||||
const url = raw ? imageFor(n, raw) : ''
|
||||
const entry = url ? imageOf(url, onImageLoad) : null
|
||||
if (entry && entry.loaded && !entry.failed) {
|
||||
const iw0 = entry.img.naturalWidth || iw
|
||||
const ih0 = entry.img.naturalHeight || ih
|
||||
const k = Math.min(iw / iw0, ih / ih0)
|
||||
const dw = iw0 * k, dh = ih0 * k
|
||||
try { ctx.drawImage(entry.img, ix + (iw - dw) / 2, iy + (ih - dh) / 2, dw, dh) } catch (e) { /* cross-origin */ }
|
||||
} else {
|
||||
ctx.fillStyle = css('--iwb-layer2', '#f1f2f4')
|
||||
roundRect(ctx, ix, iy, iw, ih, 10)
|
||||
ctx.fill()
|
||||
ctx.fillStyle = text
|
||||
ctx.font = Math.max(10, 12 / scale * 0.9) + 'px -apple-system, BlinkMacSystemFont, "PingFang SC", sans-serif'
|
||||
ctx.fillText(entry && entry.failed ? '图片源失效' : '图片加载中…', ix + 12, iy + 24)
|
||||
}
|
||||
} else if (n.type === 'out') {
|
||||
// 输出节点:画结果缩略图网格;没有结果时提示选中查看。
|
||||
const urls = outThumbsFor(n) || []
|
||||
if (urls.length) {
|
||||
const cols = 2
|
||||
const gap = 4
|
||||
const cw = Math.max(1, (iw - gap) / cols)
|
||||
const ch = cw * 0.75
|
||||
for (let i = 0; i < Math.min(4, urls.length); i++) {
|
||||
const col = i % cols, row = Math.floor(i / cols)
|
||||
const x0 = ix + col * (cw + gap), y0 = iy + row * (ch + gap)
|
||||
const entry = imageOf(imageFor(n, urls[i]), onImageLoad)
|
||||
ctx.fillStyle = css('--iwb-layer2', '#f1f2f4')
|
||||
roundRect(ctx, x0, y0, cw, ch, 6); ctx.fill()
|
||||
if (entry && entry.loaded && !entry.failed) {
|
||||
try { ctx.drawImage(entry.img, x0, y0, cw, ch) } catch (e) { /* ignore */ }
|
||||
}
|
||||
}
|
||||
} else {
|
||||
ctx.fillStyle = text
|
||||
ctx.font = Math.max(10, 12 / scale * 0.9) + 'px -apple-system, BlinkMacSystemFont, "PingFang SC", sans-serif'
|
||||
ctx.fillText('选中查看结果', ix + 2, iy + Math.max(14, 16 / scale))
|
||||
}
|
||||
} else {
|
||||
// P2 文本节点:画截断文本,选中后由 NodeCard 负责编辑。
|
||||
ctx.save()
|
||||
ctx.beginPath(); ctx.rect(ix, iy, iw, ih); ctx.clip()
|
||||
ctx.fillStyle = text
|
||||
ctx.font = Math.max(10, 12 / scale * 0.9) + 'px -apple-system, BlinkMacSystemFont, "PingFang SC", sans-serif'
|
||||
const rawText = String((n.data && (n.data.text || n.data.prompt || n.data.title)) || '')
|
||||
const lineH = Math.max(12, 18 / scale)
|
||||
const maxW = Math.max(20, iw - 4)
|
||||
let line = ''
|
||||
let ty = iy + Math.max(14, 16 / scale)
|
||||
for (const ch of rawText) {
|
||||
const next = line + ch
|
||||
if (ctx.measureText(next).width > maxW && line) {
|
||||
ctx.fillText(line, ix + 2, ty); ty += lineH; line = ch
|
||||
if (ty > iy + ih) break
|
||||
} else line = next
|
||||
}
|
||||
if (line && ty <= iy + ih) ctx.fillText(line, ix + 2, ty)
|
||||
ctx.restore()
|
||||
}
|
||||
// 端口:ref 的 canvas 命中;P2 文本节点先只做 body 命中。
|
||||
if (n.type === 'ref') {
|
||||
const portR = Math.max(2, 4 / scale)
|
||||
ctx.fillStyle = bg
|
||||
ctx.strokeStyle = border
|
||||
ctx.lineWidth = 1 / scale
|
||||
for (const [px, py] of [[x, y + nh / 2], [x + nw, y + nh / 2]]) {
|
||||
ctx.beginPath(); ctx.arc(px, py, portR, 0, Math.PI * 2); ctx.fill(); ctx.stroke()
|
||||
}
|
||||
}
|
||||
void accent
|
||||
}
|
||||
if (t0) { perf.lastMs = (typeof performance !== 'undefined' && performance.now ? performance.now() : t0) - t0; perf.frames++ }
|
||||
}
|
||||
|
||||
function CanvasNodeLayer (props) {
|
||||
const ref = useRef(null)
|
||||
const latest = useRef(props)
|
||||
latest.current = props
|
||||
const [rev, setRev] = useState(0)
|
||||
void rev
|
||||
useEffect(() => {
|
||||
const canvas = ref.current
|
||||
if (!canvas) return
|
||||
const p = latest.current || {}
|
||||
draw(canvas, Object.assign({}, p, { onImageLoad: () => setRev((v) => v + 1) }))
|
||||
if (typeof p.onReady === 'function') {
|
||||
p.onReady(function (x, y, scale) {
|
||||
const q = latest.current || {}
|
||||
draw(canvas, Object.assign({}, q, { viewport: { x: x, y: y, scale: scale }, onImageLoad: () => setRev((v) => v + 1) }))
|
||||
})
|
||||
}
|
||||
})
|
||||
useEffect(() => () => { if (typeof props.onReady === 'function') props.onReady(null) }, [])
|
||||
return el('canvas', { className: 'iwb-node-canvas', 'aria-hidden': 'true', ref: ref })
|
||||
}
|
||||
|
||||
function stats () { return { drawMs: perf.lastMs, frames: perf.frames, images: imgCache.size } }
|
||||
global.IWBCanvasV3NodeLayer = { CanvasNodeLayer, draw, stats }
|
||||
})(typeof window !== 'undefined' ? window : globalThis)
|
||||
@@ -0,0 +1,71 @@
|
||||
/* canvas-v3.js —— Canvas 静态渲染迁移的特性开关(2026-12-01,Phase 0)
|
||||
*
|
||||
* 默认关闭;开启后只改变 data-canvas-v3 与后续渲染器选择,不影响数据格式。
|
||||
* 目标架构见 docs/plans/canvas-v3-long-term.md。
|
||||
*/
|
||||
;(function (global) {
|
||||
'use strict'
|
||||
const KEY = 'iwb_canvas_v3'
|
||||
const ATTR = 'canvasV3'
|
||||
|
||||
// src 内不直调 localStorage:统一走 IWBStorageLocal 门面(桌面端会落到资料目录底座)。
|
||||
function store () {
|
||||
try {
|
||||
const S = global.IWBStorageLocal
|
||||
return (S && typeof S.getStore === 'function') ? S.getStore() : null
|
||||
} catch (e) { return null }
|
||||
}
|
||||
|
||||
function isEnabled () {
|
||||
try {
|
||||
const s = store()
|
||||
if (s && typeof s.rawGet === 'function') return s.rawGet(KEY, '0') === '1'
|
||||
} catch (e) { /* ignore */ }
|
||||
return false
|
||||
}
|
||||
|
||||
function syncRoot (on) {
|
||||
try {
|
||||
if (typeof document !== 'undefined' && document.documentElement) {
|
||||
document.documentElement.dataset[ATTR] = on ? 'on' : 'off'
|
||||
}
|
||||
} catch (e) { /* ignore */ }
|
||||
}
|
||||
|
||||
function setEnabled (on) {
|
||||
const next = !!on
|
||||
try {
|
||||
const s = store()
|
||||
if (s && typeof s.rawSet === 'function') s.rawSet(KEY, next ? '1' : '0')
|
||||
} catch (e) { /* ignore */ }
|
||||
syncRoot(next)
|
||||
try {
|
||||
if (typeof window !== 'undefined' && typeof window.dispatchEvent === 'function' && typeof CustomEvent === 'function') {
|
||||
window.dispatchEvent(new CustomEvent('iwb:canvas-v3', { detail: { enabled: next } }))
|
||||
}
|
||||
} catch (e) { /* ignore */ }
|
||||
return next
|
||||
}
|
||||
|
||||
function init () {
|
||||
const on = isEnabled()
|
||||
syncRoot(on)
|
||||
return on
|
||||
}
|
||||
|
||||
function stats () {
|
||||
const on = isEnabled()
|
||||
let dom = -1
|
||||
try { dom = document.getElementsByTagName('*').length } catch (e) { /* ignore */ }
|
||||
let node = null
|
||||
try {
|
||||
const L = global.IWBCanvasV3NodeLayer
|
||||
if (L && typeof L.stats === 'function') node = L.stats()
|
||||
} catch (e) { /* ignore */ }
|
||||
return { enabled: on, dom, node }
|
||||
}
|
||||
|
||||
// P2 第一批:ref 图片节点 + prompt/textout 文本类节点。
|
||||
const TYPES = ['ref', 'prompt', 'textout', 'combine', 'batch', 'relay', 'gen', 'out']
|
||||
global.IWBCanvasV3 = { KEY, TYPES, isEnabled, setEnabled, init, stats }
|
||||
})(typeof window !== 'undefined' ? window : globalThis)
|
||||
@@ -223,9 +223,11 @@
|
||||
const estNow = (compNow && compNow.procEstMB > 0) ? compNow.procEstMB : 0
|
||||
const procEst = rssNow > 0 ? rssNow : (estNow > 0 ? estNow : ((mem && mem.usedMB) || 0))
|
||||
const procLimit = rssNow > 0 ? 1100 : 800
|
||||
if (procEst >= procLimit && nowMs - memReclaimAt > 120000 && !(refs && refs.saving) && !(refs && refs.genRuns && refs.genRuns.size)) {
|
||||
// v3.26.143(用户裁定):只在应用不可见时自动回收。以前在可见时每 2 分钟清缓存,
|
||||
// 会触发图片重新解码/缩略图重载,表现为周期性卡顿;参考项目也没有运行中自动清缓存。
|
||||
if (procEst >= procLimit && nowMs - memReclaimAt > 120000 && !(refs && refs.saving) && !(refs && refs.genRuns && refs.genRuns.size) && (typeof document === 'undefined' || document.hidden)) {
|
||||
memReclaimAt = nowMs
|
||||
Promise.resolve().then(() => wReclaimMemoryNow('auto ' + (rssNow > 0 ? 'rss ' : 'est ') + procEst + 'MB')).catch(() => { /* ignore */ })
|
||||
Promise.resolve().then(() => wReclaimMemoryNow('auto ' + (rssNow > 0 ? 'rss ' : 'est ') + procEst + 'MB', { keepThumbs: true })).catch(() => { /* ignore */ })
|
||||
}
|
||||
// 下面这条是「堆占比 ≥75%」的老护栏,只有 Chromium 系(Windows)才有意义
|
||||
if (!mem || !mem.ratio) return
|
||||
|
||||
@@ -0,0 +1,101 @@
|
||||
/* ui-canvas-edges.js —— 边线 canvas 视觉层(2026-11-30)
|
||||
*
|
||||
* 为什么不再用 SVG 画线:
|
||||
* - SVG 每次平移/缩放都要重栅格化一个屏幕大小的矢量层;WKWebView 上这是明确的热点。
|
||||
* - canvas 只做一次 2D stroke,100 条贝塞尔很便宜,且不产生 SVG 的 DOM/合成层。
|
||||
*
|
||||
* 交互仍由 .iwb-edges(透明 hit path)负责:canvas 只画,不接收指针事件。
|
||||
* 平移/拖节点走命令式 draw(applyViewportDom / dragApplyVisual),不触发 React。
|
||||
*/
|
||||
;(function (global) {
|
||||
'use strict'
|
||||
const React = global.React || {}
|
||||
const el = (type, prop, ...children) => React.createElement(type, prop, ...children)
|
||||
const useRef = React.useRef
|
||||
const useEffect = React.useEffect
|
||||
|
||||
function cssVar(name, fallback) {
|
||||
try {
|
||||
const v = getComputedStyle(document.documentElement).getPropertyValue(name).trim()
|
||||
return v || fallback
|
||||
} catch (e) { return fallback }
|
||||
}
|
||||
|
||||
function draw(canvas, o) {
|
||||
if (!canvas || !o || typeof canvas.getContext !== 'function') return
|
||||
const rect = canvas.getBoundingClientRect ? canvas.getBoundingClientRect() : null
|
||||
const w = Math.max(1, Math.round((rect && rect.width) || canvas.clientWidth || 1))
|
||||
const h = Math.max(1, Math.round((rect && rect.height) || canvas.clientHeight || 1))
|
||||
const dpr = Math.min(2, (typeof devicePixelRatio === 'number' && devicePixelRatio > 0) ? devicePixelRatio : 1)
|
||||
const bw = Math.round(w * dpr), bh = Math.round(h * dpr)
|
||||
if (canvas.width !== bw || canvas.height !== bh) { canvas.width = bw; canvas.height = bh }
|
||||
const ctx = canvas.getContext('2d')
|
||||
if (!ctx) return
|
||||
ctx.setTransform(dpr, 0, 0, dpr, 0, 0)
|
||||
ctx.clearRect(0, 0, w, h)
|
||||
const vp = o.viewport || { x: 0, y: 0, scale: 1 }
|
||||
const scale = Number(vp.scale) > 0 ? Number(vp.scale) : 1
|
||||
const baseW = parseFloat(cssVar('--iwb-edge-w', '1.4')) || 1.4
|
||||
const edgeColor = cssVar('--iwb-edge', '#8b95a5')
|
||||
const hotColor = cssVar('--iwb-edge-hot', '#6b7280')
|
||||
const warnColor = cssVar('--iwb-warn', '#e0a030')
|
||||
const errColor = cssVar('--iwb-err', '#e05252')
|
||||
const hoverId = o.hoverEdgeId || ''
|
||||
const selected = o.selEdge || ''
|
||||
const focus = o.focusNodeId || ''
|
||||
const edgeHover = o.edgeHover || null
|
||||
const edges = Array.isArray(o.edges) ? o.edges : []
|
||||
const pathOf = typeof o.computeEdgePath === 'function' ? o.computeEdgePath : null
|
||||
if (!pathOf) return
|
||||
|
||||
ctx.setTransform(dpr * scale, 0, 0, dpr * scale, dpr * (Number(vp.x) || 0), dpr * (Number(vp.y) || 0))
|
||||
ctx.lineCap = 'round'
|
||||
ctx.lineJoin = 'round'
|
||||
|
||||
for (let i = 0; i < edges.length; i++) {
|
||||
const ed = edges[i]
|
||||
if (!ed) continue
|
||||
let d = ''
|
||||
try { d = pathOf(ed, o.graph, o.nodeMap, o.measuredH, o.pathCache) || '' } catch (e) { d = '' }
|
||||
if (!d || typeof Path2D === 'undefined') continue
|
||||
const isSel = selected === ed.id
|
||||
const isHot = focus && (ed.to === focus || ed.from === focus)
|
||||
const isHover = hoverId === ed.id
|
||||
const isDetach = !!(edgeHover && edgeHover.mode === 'detach' && Array.isArray(edgeHover.edgeIds) && edgeHover.edgeIds.indexOf(ed.id) >= 0)
|
||||
const isInsert = !!(edgeHover && edgeHover.mode === 'insert' && edgeHover.edgeId === ed.id)
|
||||
ctx.strokeStyle = isSel ? warnColor : (isDetach ? errColor : (isHot || isHover || isInsert ? hotColor : edgeColor))
|
||||
ctx.lineWidth = (isSel || isHot || isHover || isInsert || isDetach) ? Math.max(2.2, baseW * 1.6) : baseW
|
||||
ctx.setLineDash(isDetach ? [6 / scale, 4 / scale] : (isInsert ? [6 / scale, 4 / scale] : []))
|
||||
ctx.stroke(new Path2D(d))
|
||||
}
|
||||
|
||||
if (o.tempD && typeof Path2D !== 'undefined') {
|
||||
ctx.strokeStyle = o.connTarget && o.connTarget.valid === false ? errColor : hotColor
|
||||
ctx.lineWidth = Math.max(2, baseW)
|
||||
ctx.setLineDash([6 / scale, 4 / scale])
|
||||
try { ctx.stroke(new Path2D(o.tempD)) } catch (e) { /* ignore */ }
|
||||
}
|
||||
ctx.setLineDash([])
|
||||
}
|
||||
|
||||
function EdgeCanvas(props) {
|
||||
const ref = useRef(null)
|
||||
const latest = useRef(props)
|
||||
latest.current = props
|
||||
useEffect(() => {
|
||||
const canvas = ref.current
|
||||
if (!canvas) return
|
||||
draw(canvas, latest.current)
|
||||
if (typeof props.onReady === 'function') {
|
||||
props.onReady(function (x, y, scale) {
|
||||
const p = latest.current || {}
|
||||
draw(canvas, Object.assign({}, p, { viewport: { x: x, y: y, scale: scale } }))
|
||||
})
|
||||
}
|
||||
})
|
||||
useEffect(() => () => { if (typeof props.onReady === 'function') props.onReady(null) }, [])
|
||||
return el('canvas', { className: 'iwb-edge-canvas', 'aria-hidden': 'true', ref: ref })
|
||||
}
|
||||
|
||||
global.IWBCanvasEdges = { EdgeCanvas, draw }
|
||||
})(typeof window !== 'undefined' ? window : globalThis)
|
||||
@@ -9,11 +9,13 @@
|
||||
'use strict'
|
||||
|
||||
function buildNodeEls(ctx) {
|
||||
const { CanvasGeometry, CanvasStore, EMPTY_OBJ, NODE_W, NodeCardMemo, addRefFromUrl, batchPortTop, batchSourcesMap, canConnect, cancelRun, config, connTarget, defaultNodeBoxWidth, deleteNodes, duplicateNodes, edges, el, generationConcurrency, hOf, inPortWorld, isBatchSrc, lodViewport, nodeDerived, nodeOnMeasure, nodeOnPreview, nodeOnSelect, nodeTypeH, nodeWidth, nodes, pushHistory, refs, runLLM, runLayerNode, runNode, runOutSources, saveNow, sel, selRef, setConn, setConnTarget, setNotice, setSel, taskCountOf, thumbRev, typesRev, uiZoom, uid, updateNode, visibleIds, wLodEnabled, zoomToNode } = ctx
|
||||
const { CanvasGeometry, CanvasStore, EMPTY_OBJ, NODE_W, NodeCardMemo, addRefFromUrl, batchPortTop, batchSourcesMap, canConnect, cancelRun, config, connTarget, canvasV3On, canvasV3TypeOf, defaultNodeBoxWidth, deleteNodes, duplicateNodes, edges, el, generationConcurrency, hOf, inPortWorld, isBatchSrc, lodViewport, nodeDerived, nodeOnMeasure, nodeOnPreview, nodeOnSelect, nodeTypeH, nodeWidth, nodes, pushHistory, refs, runLLM, runLayerNode, runNode, runOutSources, saveNow, sel, selRef, setConn, setConnTarget, setNotice, setSel, taskCountOf, thumbRev, typesRev, uiZoom, uid, updateNode, visibleIds, wLodEnabled, zoomToNode } = ctx
|
||||
const nodeEls = []
|
||||
const batchSourcesById = batchSourcesMap
|
||||
for (const n of nodes) {
|
||||
if (!visibleIds.has(n.id)) continue
|
||||
// Canvas V3:未选中的 ref 节点完全由 canvas 画,DOM 不挂 NodeCard;点击走 canvas 命中测试。
|
||||
if (canvasV3On && canvasV3TypeOf(n) && !sel.includes(n.id)) continue
|
||||
// 细粒度:只传该节点相关的 busy/progress/connTarget(其他节点引用稳定,memo 跳过)
|
||||
let busySelf = nodeDerived.busyById.get(n.id) || EMPTY_OBJ
|
||||
let progSelf = nodeDerived.progById.get(n.id) || EMPTY_OBJ
|
||||
|
||||
@@ -61,6 +61,9 @@
|
||||
const gEl = el0.querySelector('[data-edge-id="' + ed.id + '"]')
|
||||
if (gEl && d) { const ps = gEl.querySelectorAll('path'); for (let i = 0; i < ps.length; i++) ps[i].setAttribute('d', d) }
|
||||
}
|
||||
// 边线/节点 canvas:拖动中坐标已就地更新,命令式重画一次(不触发 React)。
|
||||
try { if (typeof refs.edgeCanvasDraw === 'function') refs.edgeCanvasDraw(refs.viewport.x, refs.viewport.y, refs.viewport.scale) } catch (e) { /* ignore */ }
|
||||
try { if (typeof refs.nodeCanvasDraw === 'function') refs.nodeCanvasDraw(refs.viewport.x, refs.viewport.y, refs.viewport.scale) } catch (e) { /* ignore */ }
|
||||
// 节点组外框实时跟随:外框由成员包围盒派生,拖动中不重渲染 → 必须就地改 DOM(否则松手才跳)。
|
||||
// 用 refs.nodeGroupMap 反查受影响的组,避免每帧 O(groups×members) 扫描。
|
||||
if (refs.nodeGroupMap && refs.nodeGroupMap.size) {
|
||||
@@ -140,8 +143,11 @@
|
||||
if (refs.pan) {
|
||||
const p = refs.pan
|
||||
p.mx = mx; p.my = my
|
||||
// 只改 DOM:React 不重渲染,世界层不重栅格化(v3.25.68)
|
||||
applyViewportDom(p.vx + (p.mx - p.sx), p.vy + (p.my - p.sy), refs.viewport.scale)
|
||||
// 只改 DOM;同一帧内多次 pointermove 合并成一次写入(参考 infinite-canvas 的 rAF 合批)。
|
||||
rafSet(() => {
|
||||
if (!refs.pan) return
|
||||
applyViewportDom(p.vx + (p.mx - p.sx), p.vy + (p.my - p.sy), refs.viewport.scale)
|
||||
})
|
||||
return
|
||||
}
|
||||
if (refs.groupResize) {
|
||||
|
||||
@@ -195,10 +195,16 @@ function EdgePath(props) {
|
||||
const relation = focusNodeId ? (ed.to === focusNodeId ? ' iwb-edge-upstream' : (ed.from === focusNodeId ? ' iwb-edge-downstream' : '')) : ''
|
||||
const cls = 'iwb-edge' + (selEdge === ed.id ? ' iwb-edge-sel' : '') + relation + ((edgeHover && edgeHover.mode === 'insert' && edgeHover.edgeId === ed.id) ? ' iwb-edge-hot' : '') + ((edgeHover && edgeHover.mode === 'detach' && edgeHover.edgeIds.indexOf(ed.id) >= 0) ? ' iwb-edge-detach' : '')
|
||||
// 双击连线 = 断开连线:这是用户明确要保留的操作习惯(2026-11-28 确认),不要删。
|
||||
const hnd = { onPointerDown: (e) => { e.stopPropagation(); onSelect(ed.id) }, onDoubleClick: (e) => { e.stopPropagation(); onDelete(ed.id) } }
|
||||
const hnd = {
|
||||
onPointerDown: (e) => { e.stopPropagation(); onSelect(ed.id) },
|
||||
onDoubleClick: (e) => { e.stopPropagation(); onDelete(ed.id) },
|
||||
onPointerEnter: () => { if (typeof props.onHover === 'function') props.onHover(ed.id) },
|
||||
onPointerLeave: () => { if (typeof props.onHover === 'function') props.onHover('') },
|
||||
}
|
||||
return el('g', { 'data-edge-id': ed.id },
|
||||
el('path', { key: ed.id + '_hit', className: 'iwb-edge-hit', d, fill: 'none', ...hnd }),
|
||||
el('path', { key: ed.id, className: cls, d, fill: 'none', title: '点击选中(Delete 断开)· 双击直接断开', ...hnd }),
|
||||
// 视觉由 canvas 层画;保留一个 display:none 的旧路径节点给 e2e/选择器兼容(不参与绘制)。
|
||||
el('path', { key: ed.id, className: cls, d, fill: 'none', style: props.visual === false ? { display: 'none' } : undefined, title: '点击选中(Delete 断开)· 双击直接断开', ...hnd }),
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
+17
-1
@@ -1190,6 +1190,22 @@
|
||||
return line.length > 40 ? (line.slice(0, 40) + '…') : line
|
||||
}
|
||||
|
||||
// Canvas V3:out 节点的结果图 URL 列表(只读;仍复用 outGroupsOf 的分组/排序)。
|
||||
function outThumbUrlsOf (node, nodes, edges) {
|
||||
const nodeMap = new Map((nodes || []).map((n) => [n.id, n]))
|
||||
// Canvas V3 可能在 NodeCard 还没渲染过时调用本函数,此时 inject 还没发生 —— 用本职能兜底。
|
||||
const isProducer = typeof isImageProducer === 'function' ? isImageProducer : (n) => !!(n && (n.type === 'gen' || n.type === 'out' || n.type === 'ref' || n.type === 'combine' || n.type === 'batch'))
|
||||
const tasksOf = typeof cachedGenerationTasks === 'function' ? cachedGenerationTasks : () => []
|
||||
const srcGens = (edges || [])
|
||||
.filter((e) => e.to === node.id)
|
||||
.map((e) => nodeMap.get(e.from))
|
||||
.filter((n) => isProducer(n) && !(n.data && n.data.enabled === false))
|
||||
const merged = outGroupsOf(srcGens, (g) => tasksOf(g, nodes || [], edges || []).map((t) => ({ id: t.id, title: t.title || '' })))
|
||||
const urls = []
|
||||
for (const m of merged) for (const r of m.items) if (r && r.url) urls.push(r.url)
|
||||
return urls
|
||||
}
|
||||
|
||||
function lodBody(node, mode) {
|
||||
const isImg = LOD_IMG_TYPES.indexOf(node.type) >= 0
|
||||
if (mode !== 'plain' && isImg) {
|
||||
@@ -1213,5 +1229,5 @@
|
||||
}
|
||||
|
||||
// md:纯函数(Markdown ⇄ 编辑器 HTML)的测试钩子 —— 行距翻倍的回归由 tests/prompt-md-roundtrip-test.js 守住
|
||||
global.IWBNodeBodies = { inject, openPromptExpand, md: { toHtml: mdToHtml, toMd: htmlToMd }, relay: renderRelayBody, prompt: renderPromptBody, plugin: renderPluginBody, textout: renderTextoutBody, combine: renderCombineBody, llm: renderLlmBody, batch: renderBatchBody, ref: renderRefBody, out: renderOutBody, gen: renderGenBody, outGroupsOf, lodBody }
|
||||
global.IWBNodeBodies = { inject, openPromptExpand, md: { toHtml: mdToHtml, toMd: htmlToMd }, relay: renderRelayBody, prompt: renderPromptBody, plugin: renderPluginBody, textout: renderTextoutBody, combine: renderCombineBody, llm: renderLlmBody, batch: renderBatchBody, ref: renderRefBody, out: renderOutBody, gen: renderGenBody, outGroupsOf, outThumbUrlsOf, lodBody }
|
||||
})(typeof window !== 'undefined' ? window : globalThis)
|
||||
@@ -110,6 +110,10 @@
|
||||
el('label', { className: 'iwb-diag-kv', title: '打开后整个画布世界会被提升成一个常驻合成层:拖拽/缩放更顺,但内存会明显上涨(实测 +700MB 级)。改完等 10 秒看「进程实测」对比。' },
|
||||
el('input', { type: 'checkbox', checked: !!(extras && extras.layers), onChange: (e) => { if (typeof props.onToggleLayers === 'function') props.onToggleLayers(e.target.checked) } }),
|
||||
' 合成层常驻提升'),
|
||||
el('label', { className: 'iwb-diag-kv', title: 'Canvas V3 实验:静态节点内容改 Canvas 绘制,只给选中/编辑节点挂 DOM。默认关闭,开启后需刷新;见 docs/plans/canvas-v3-long-term.md' },
|
||||
el('input', { type: 'checkbox', checked: !!(extras && extras.canvasV3), onChange: (e) => { if (typeof props.onToggleCanvasV3 === 'function') props.onToggleCanvasV3(e.target.checked) } }),
|
||||
' Canvas V3(实验,需刷新)'),
|
||||
(extras.canvasV3Stats && extras.canvasV3Stats.enabled) ? el('span', { className: 'iwb-diag-kv', title: '最近一次节点 canvas 绘制耗时 / 帧数 / 图片缓存数' }, 'Canvas V3 绘制 ' + Math.round((extras.canvasV3Stats.node && extras.canvasV3Stats.node.drawMs) || 0) + 'ms · 帧 ' + ((extras.canvasV3Stats.node && extras.canvasV3Stats.node.frames) || 0) + ' · 图 ' + ((extras.canvasV3Stats.node && extras.canvasV3Stats.node.images) || 0)) : null,
|
||||
el('label', { className: 'iwb-diag-kv', title: '关掉所有 backdrop-filter(顶栏/停靠栏的毛玻璃),用于二分 graphics 占用' },
|
||||
el('input', { type: 'checkbox', checked: !!(extras && extras.noblur), onChange: (e) => { if (typeof props.onToggleNoBlur === 'function') props.onToggleNoBlur(e.target.checked) } }),
|
||||
' 禁用毛玻璃'),
|
||||
|
||||
@@ -300,7 +300,7 @@
|
||||
if (!alive) return
|
||||
if (typeof requestIdleCallback === 'function') requestIdleCallback(kick, { timeout: 8000 })
|
||||
else kick()
|
||||
}, 6000)
|
||||
}, 30000)
|
||||
return () => { alive = false; clearTimeout(t) }
|
||||
}, [o.len])
|
||||
}
|
||||
|
||||
@@ -27,11 +27,13 @@ button { font-family: inherit; }
|
||||
/* 抓手工具(H):整块画布给「可抓」光标,按下拖动时变抓紧 */
|
||||
.iwb-canvas.iwb-tool-pan { cursor: grab; }
|
||||
.iwb-canvas.iwb-tool-pan:active { cursor: grabbing; }
|
||||
.iwb-grid { position: absolute; left: -50%; top: -50%; width: 200%; height: 200%; pointer-events: none; background-repeat: repeat; background-image: radial-gradient(circle, var(--iwb-grid-dot) var(--iwb-grid-size), transparent calc(var(--iwb-grid-size) + 0.4px)); background-size: var(--iwb-grid-gap) var(--iwb-grid-gap); background-repeat: repeat; opacity: calc(0.85 * var(--iwb-grid-on)); }
|
||||
.iwb-grid { position: absolute; inset: 0; pointer-events: none; background-repeat: repeat; background-image: radial-gradient(circle, var(--iwb-grid-dot) var(--iwb-grid-size), transparent calc(var(--iwb-grid-size) + 0.4px)); background-size: var(--iwb-grid-gap) var(--iwb-grid-gap); opacity: calc(0.85 * var(--iwb-grid-on)); }
|
||||
/* 亮色主题:网格点更浅,降低与背景对比度(暗色主题不受影响) */
|
||||
|
||||
.iwb-world { position: absolute; left: 0; top: 0; transform-origin: 0 0; }
|
||||
.iwb-edges { position: absolute; left: 0; top: 0; pointer-events: none; }
|
||||
.iwb-edge-canvas { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
|
||||
.iwb-node-canvas { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
|
||||
.iwb-edge-hit { fill: none; stroke: transparent; stroke-width: 14; pointer-events: stroke; cursor: pointer; }
|
||||
.iwb-edge-hit:hover { stroke: color-mix(in srgb, var(--iwb-brand) 16%, transparent); }
|
||||
.iwb-edge-hit:hover + .iwb-edge { stroke-width: calc(var(--iwb-edge-w) + 0.6px); stroke: var(--iwb-edge-hot); }
|
||||
@@ -1207,12 +1209,14 @@ body .iwb-history-embedded .iwb-history-item.iwb-history-selected:hover img {
|
||||
/* v12:世界容器提升为合成层(节点随世界一起 transform,不单独建层) */
|
||||
/* v3.26.136:合成层常驻提升改为可开关(诊断页)。默认关 —— 默认开启时整个画布世界会被提升成一个
|
||||
巨大的常驻合成层,实测 WebContent graphics 764MB。需要时(低端机拖拽掉帧)可以打开。 */
|
||||
.iwb-world { will-change: transform; }
|
||||
:root[data-layers="off"] .iwb-world { will-change: auto; } /* v3.26.140:开关改成「关闭合成层」(省内存但会卡),默认关 */
|
||||
/* v3.26.143:默认不把 world/grid 提升成常驻合成层(参考 infinite-canvas:靠视口裁剪 + rAF 合批)。
|
||||
诊断页的「合成层常驻提升」是显式 opt-in,只在低端机需要时打开。 */
|
||||
.iwb-world { will-change: auto; }
|
||||
:root[data-layers="on"] .iwb-world { will-change: transform; }
|
||||
/* v3.26.137:毛玻璃开关(诊断页)。关掉后所有 backdrop-filter 失效,用于二分 graphics 占用 */
|
||||
:root[data-noblur="on"] *, :root[data-noblur="on"] *::before, :root[data-noblur="on"] *::after { backdrop-filter: none !important; -webkit-backdrop-filter: none !important; }
|
||||
.iwb-grid { will-change: transform; }
|
||||
:root[data-layers="off"] .iwb-grid { will-change: auto; }
|
||||
.iwb-grid { will-change: auto; }
|
||||
:root[data-layers="on"] .iwb-grid { will-change: transform; }
|
||||
/* v15:左侧资源面板展开时浮在画布上层,不移动画布位置 */
|
||||
.iwb-overlay.drawer-open .iwb-canvas { left: 0 !important; }
|
||||
/* 停靠栏时代:工具栏/小地图按 --iwb-dock-* 让位(画布仍不动) */
|
||||
|
||||
@@ -72,23 +72,23 @@ assert("IDB_REF_PREFIX = 'ref_'(legacy 形态)", /const IDB_REF_PREFIX = 're
|
||||
assert("文档记录了 IDB_REF_PREFIX = 'ref_'", factsDoc.includes("IDB_REF_PREFIX = 'ref_'"))
|
||||
assert('W_IMG_BLOB_PRIMARY_DEFAULT = true(新写入主通道启用)', /const W_IMG_BLOB_PRIMARY_DEFAULT = true/.test(appJs))
|
||||
|
||||
// ── 3. 视口裁剪余量:宽边距 240 / 带图节点 80,且不得回退成 560 ─────────────
|
||||
// ── 3. 视口裁剪余量:统一 280,且不得回退成 560 ─────────────
|
||||
// v3.26.109:cullRect 从 app.js 收编到 src/canvas-geometry.js(cullRectsOf),
|
||||
// 带图节点改用 80 的紧边距,减少屏幕外节点常驻的解码位图(内存 C)。
|
||||
// v3.26.143:带图节点也回到 280,避免平移边缘反复卸载/重解码;内存靠图片管线控制。
|
||||
console.log('3) 视口裁剪余量(禁止把 v3.80.0 的 ±560 写回来)')
|
||||
const geomJs = read('src/canvas-geometry.js')
|
||||
const cullStart = geomJs.indexOf('const CULL_PAD_WIDE = 240')
|
||||
const cullStart = geomJs.indexOf('const CULL_PAD_WIDE = 280')
|
||||
const cullEnd = geomJs.indexOf('function nodeVisibleIn')
|
||||
assert('定位到 cullRectsOf 代码块', cullStart > 0 && cullEnd > cullStart)
|
||||
if (cullStart > 0 && cullEnd > cullStart) {
|
||||
const cull = geomJs.slice(cullStart, cullEnd)
|
||||
assert('宽边距常量是 240', /CULL_PAD_WIDE = 240/.test(cull))
|
||||
assert('带图节点紧边距是 80', /CULL_PAD_TIGHT = 80/.test(cull))
|
||||
assert('宽边距常量是 280', /CULL_PAD_WIDE = 280/.test(cull))
|
||||
assert('带图节点紧边距也是 280', /CULL_PAD_TIGHT = 280/.test(cull))
|
||||
const hasPad = (cull.match(/- pad|\+ pad/g) || []).length
|
||||
assert('裁剪矩形 4 条边都按 pad 收放', hasPad === 4, '实际 ' + hasPad)
|
||||
assert('裁剪矩形不含 560(历史值已废止)', !/560/.test(cull))
|
||||
assert('app.js 只做装配(不再内联 cullRect 数值)', !/const cullRect = React\.useMemo/.test(appJs))
|
||||
assert('文档记录了 240 余量', factsDoc.includes('240'))
|
||||
assert('文档记录了 280 余量', factsDoc.includes('280'))
|
||||
assert('文档未把 560 当现值', !/余量.{0,6}560/.test(factsDoc))
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
'use strict'
|
||||
// v3.25.70:网格从「CSS 渐变 + 每帧改 background-position」改为「贴图 + transform 位移」
|
||||
// (WebKit 下每帧重绘整屏点阵是拖动卡顿的固定开销)。断言新契约 + 保留 jsdom 回落。
|
||||
// v3.26.143:网格回到「视口大小 + 贴图 + background-position」。
|
||||
// 108/3.26.140 的 200% 尺寸 + transform 会把网格提升成额外合成层;视口大小 + 背景位移更省。
|
||||
// 断言新契约 + 保留 jsdom 回落。
|
||||
const assert = require('assert')
|
||||
const fs = require('fs')
|
||||
const path = require('path')
|
||||
@@ -11,5 +12,7 @@ assert.ok(source.includes('IWBCanvasGrid'), '必须接入 canvas-grid 模块')
|
||||
assert.ok(grid.includes('function styleOf') && grid.includes('function applyTo'), '模块需提供 styleOf/applyTo')
|
||||
assert.ok(source.includes("--iwb-grid-gap"), '网格必须读取外观设置变量(v3.25.74)')
|
||||
assert.ok(source.includes("backgroundSize: (o.base * scale)"), 'jsdom/无模块时需回落到渐变公式')
|
||||
assert.ok(!source.includes("backgroundPosition: viewport.x + 'px ' + viewport.y + 'px'"), '渲染期不得再按帧写 backgroundPosition')
|
||||
assert.ok(grid.includes("backgroundPosition: (x % gap)"), '模块用 background-position 跟随平移')
|
||||
assert.ok(!grid.includes("el.style.transform = 'translate('"), '网格层不再用 transform 位移(避免额外合成层)')
|
||||
assert.ok(source.includes("backgroundPosition: x + 'px ' + y + 'px'"), 'jsdom 回落同样用 background-position')
|
||||
console.log('canvas dot zoom checks passed')
|
||||
@@ -407,22 +407,23 @@ const near = (name, got, wantX, wantY) => {
|
||||
assert.ok(Number.isFinite(nan.scale) && Number.isFinite(nan.x) && Number.isFinite(nan.y), '入参缺失不得产出 NaN')
|
||||
}
|
||||
|
||||
// ── 2026-11-30:边线 SVG 只覆盖视口(10000² 合成位图约 1.6GB 的回归守卫)──
|
||||
// ── 2026-11-30:边线 SVG 放在屏幕坐标系(不能按世界尺寸分配合成位图)──
|
||||
{
|
||||
const r = G.edgeLayerRect({ w: 1000, h: 800 }, { x: -100, y: -50, scale: 0.5 })
|
||||
assert.deepStrictEqual(
|
||||
{ x: r.x, y: r.y, w: r.w, h: r.h },
|
||||
{ x: 200, y: 100, w: 2000, h: 1600 },
|
||||
'边线层的世界矩形 = 视口反算,不能是 10000²'
|
||||
)
|
||||
const props = G.edgeLayerProps({ w: 1000, h: 800 }, { x: 0, y: 0, scale: 1 })
|
||||
const size = G.edgeLayerSize({ w: 1000, h: 800 })
|
||||
assert.strictEqual(size.w, 1000)
|
||||
assert.strictEqual(size.h, 800)
|
||||
const props = G.edgeLayerProps({ w: 1000, h: 800 })
|
||||
assert.strictEqual(props.width, 1000)
|
||||
assert.strictEqual(props.height, 800)
|
||||
assert.ok(String(props.viewBox).indexOf('10000') < 0, 'viewBox 不得再出现 10000')
|
||||
const fake = { attrs: {}, style: {}, setAttribute(k, v) { this.attrs[k] = v } }
|
||||
G.applyEdgeLayerDom({ querySelector: (s) => (s === '.iwb-edges' ? fake : null) }, { w: 1200, h: 900 }, 120, 80, 2)
|
||||
assert.strictEqual(fake.attrs.viewBox, '-60 -40 600 450')
|
||||
assert.strictEqual(fake.style.width, '600px')
|
||||
assert.strictEqual(props.viewBox, '0 0 1000 800')
|
||||
assert.strictEqual(G.edgeGroupTransform({ x: -100, y: -50, scale: 0.5 }), 'translate(-100,-50) scale(0.5)')
|
||||
const rects = G.cullRectsOf({ w: 800, h: 600 }, { x: 0, y: 0, scale: 1 })
|
||||
const far = { id: 'far', type: 'ref', x: 5000, y: 5000, w: 200, h: 200 }
|
||||
assert.strictEqual(G.nodeVisibleIn(far, rects, { widthOf: (n) => n.w, heightOf: (n) => n.h }), false)
|
||||
assert.strictEqual(G.nodeVisibleIn(far, rects, { pan: true, widthOf: (n) => n.w, heightOf: (n) => n.h }), true, '平移期间必须全量渲染')
|
||||
const fake = { attrs: {}, setAttribute(k, v) { this.attrs[k] = v } }
|
||||
G.applyEdgeLayerDom({ querySelector: (s) => (s === '.iwb-edge-world' ? fake : null) }, { w: 1200, h: 900 }, 120, 80, 2)
|
||||
assert.strictEqual(fake.attrs.transform, 'translate(120,80) scale(2)')
|
||||
}
|
||||
|
||||
console.log('canvas geometry checks passed(含 computeEdgePath 缓存快路径、areNodeEqual 拖拽放宽、拖放落点吸附、复制落位零重叠、粘贴左上角落点与视口夹取、LOD 屏幕宽度判据、边线视口层的行为验证)')
|
||||
@@ -0,0 +1,26 @@
|
||||
'use strict'
|
||||
const assert = require('assert')
|
||||
const fs = require('fs')
|
||||
const path = require('path')
|
||||
const vm = require('vm')
|
||||
const sandbox = { window: {} }
|
||||
vm.createContext(sandbox)
|
||||
vm.runInContext(fs.readFileSync(path.join(__dirname, '..', 'src', 'canvas-v3-hit.js'), 'utf8'), sandbox)
|
||||
const H = sandbox.window.IWBCanvasV3Hit
|
||||
const nodes = [
|
||||
{ id: 'a', type: 'ref', x: 0, y: 0, w: 200, h: 100 },
|
||||
{ id: 'b', type: 'prompt', x: 300, y: 0, w: 200, h: 100 },
|
||||
{ id: 'c', type: 'ref', x: 0, y: 0, w: 200, h: 100 },
|
||||
]
|
||||
const opts = { widthOf: (n) => n.w, heightOf: (n) => n.h, portRadiusWorld: 10 }
|
||||
assert.strictEqual(H.hitRefNode(nodes, 50, 50, opts).node.id, 'c', '后渲染的 ref 优先命中')
|
||||
assert.strictEqual(H.hitRefNode(nodes, 50, 50, opts).port, '', '卡内是 body')
|
||||
assert.strictEqual(H.hitRefNode(nodes, -5, 50, opts).port, 'in', '左边缘是输入口')
|
||||
assert.strictEqual(H.hitRefNode(nodes, 205, 50, opts).port, 'out', '右边缘是输出口')
|
||||
assert.strictEqual(H.hitRefNode(nodes, 400, 50, opts), null, '非 ref 不参与 hitRefNode')
|
||||
assert.strictEqual(H.hitRefNode(nodes, 500, 500, opts), null, '空白不命中')
|
||||
const hitAny = H.hitNode(nodes, 400, 50, Object.assign({}, opts, { isType: (n) => n.type === 'prompt' || n.type === 'ref', wantPorts: false }))
|
||||
assert.strictEqual(hitAny.node.id, 'b', 'hitNode 按 isType 命中 prompt')
|
||||
assert.strictEqual(hitAny.port, '', 'prompt 只做 body 命中')
|
||||
console.log('canvas-v3-hit types checks passed')
|
||||
console.log('canvas-v3-hit checks passed')
|
||||
@@ -0,0 +1,50 @@
|
||||
'use strict'
|
||||
const assert = require('assert')
|
||||
const fs = require('fs')
|
||||
const path = require('path')
|
||||
const vm = require('vm')
|
||||
const source = fs.readFileSync(path.join(__dirname, '..', 'src', 'canvas-v3.js'), 'utf8')
|
||||
|
||||
function makeSandbox (initial) {
|
||||
const store = new Map(Object.entries(initial || {}))
|
||||
const events = []
|
||||
const root = { dataset: {} }
|
||||
const localStorage = {
|
||||
getItem: (k) => (store.has(k) ? store.get(k) : null),
|
||||
setItem: (k, v) => { store.set(k, String(v)) },
|
||||
}
|
||||
const document = { documentElement: root, getElementsByTagName: () => ({ length: 42 }) }
|
||||
const window = { dispatchEvent: (e) => { events.push(e) } }
|
||||
window.IWBStorageLocal = { getStore: () => ({ rawGet: (k, f) => (store.has(k) ? store.get(k) : f), rawSet: (k, v) => { store.set(k, String(v)); return true } }) }
|
||||
class CustomEvent { constructor (type, init) { this.type = type; this.detail = init && init.detail } }
|
||||
const storage = { rawGet: (k, f) => (store.has(k) ? store.get(k) : f), rawSet: (k, v) => { store.set(k, String(v)); return true } }
|
||||
const sandbox = { window, document, localStorage, IWBStorageLocal: { getStore: () => storage }, CustomEvent, console }
|
||||
vm.createContext(sandbox)
|
||||
vm.runInContext(source, sandbox)
|
||||
return { api: sandbox.window.IWBCanvasV3, root, store, events }
|
||||
}
|
||||
|
||||
{
|
||||
const s = makeSandbox({})
|
||||
assert.strictEqual(s.api.isEnabled(), false, '默认关闭')
|
||||
assert.strictEqual(s.api.init(), false)
|
||||
assert.strictEqual(s.root.dataset.canvasV3, 'off', '关闭时根属性为 off')
|
||||
}
|
||||
{
|
||||
const s = makeSandbox({ iwb_canvas_v3: '1' })
|
||||
assert.strictEqual(s.api.isEnabled(), true, 'localStorage=1 时开启')
|
||||
assert.strictEqual(s.api.init(), true)
|
||||
assert.strictEqual(s.root.dataset.canvasV3, 'on', '开启时根属性为 on')
|
||||
}
|
||||
{
|
||||
const s = makeSandbox({})
|
||||
assert.strictEqual(s.api.setEnabled(true), true)
|
||||
assert.strictEqual(s.store.get('iwb_canvas_v3'), '1')
|
||||
assert.strictEqual(s.root.dataset.canvasV3, 'on')
|
||||
assert.strictEqual(s.events.length, 1)
|
||||
assert.strictEqual(s.events[0].type, 'iwb:canvas-v3')
|
||||
assert.strictEqual(s.events[0].detail.enabled, true)
|
||||
assert.strictEqual(s.api.setEnabled(false), false)
|
||||
assert.strictEqual(s.root.dataset.canvasV3, 'off')
|
||||
}
|
||||
console.log('canvas-v3 checks passed')
|
||||
+4
@@ -2,6 +2,7 @@
|
||||
"CanvasActions",
|
||||
"CanvasNodeFactory",
|
||||
"IWBBootLoad",
|
||||
"IWBCanvasEdges",
|
||||
"IWBCanvasGeometry",
|
||||
"IWBCanvasGrid",
|
||||
"IWBCanvasHistory",
|
||||
@@ -11,6 +12,9 @@
|
||||
"IWBCanvasPointer",
|
||||
"IWBCanvasStore",
|
||||
"IWBCanvasText",
|
||||
"IWBCanvasV3",
|
||||
"IWBCanvasV3Hit",
|
||||
"IWBCanvasV3NodeLayer",
|
||||
"IWBCrashLog",
|
||||
"IWBDefaultGenModel",
|
||||
"IWBDesktop",
|
||||
|
||||
@@ -74,6 +74,9 @@
|
||||
"ui-dock-panels.js",
|
||||
"theme-tokens.js",
|
||||
"canvas-grid.js",
|
||||
"canvas-v3.js",
|
||||
"canvas-v3-node-layer.js",
|
||||
"canvas-v3-hit.js",
|
||||
"image-display-thumb.js",
|
||||
"image-cache-migrate.js",
|
||||
"runtime-frame-probe.js",
|
||||
@@ -101,6 +104,7 @@
|
||||
"runtime-plugin-market.js",
|
||||
"runtime-plugin-backup.js",
|
||||
"ui-canvas-view.js",
|
||||
"ui-canvas-edges.js",
|
||||
"ui-canvas-pointer.js",
|
||||
"ui-canvas-nodes.js",
|
||||
"ui-confirm.js",
|
||||
|
||||
@@ -170,7 +170,7 @@ const MAX_SRC_COMPONENT_LINES = 531
|
||||
// · 图标解析统一(右键菜单 + 设置页走同一解析器,2 行) +2
|
||||
// 通用件(pick/grant/stat/readDataUrl/readBlob/参数校验)全部在 src/image-file-ref.js
|
||||
// 与 src/plugin-api-images.js,app.js 只做装配。
|
||||
const MAX_APP_JS_LINES = 8665 // +336(2026-11-30 图片策略 v2 与诊断:插件三层能力 thumb/preview/original/budget、原生解码闸门装配、wDiagDetail(分进程 footprint + 解码账本 + 插件源)、图库空闲预热、wReclaimMemoryNow/引用化;下一步按 domain 拆到 src/ 回落此上限) // +11(2026-11-27:停靠栏就绪后按新占位重新适应的监听;app.js 8315→8326) // +15(2026-11-26 复制/粘贴通道重写:DOM copy 事件装配、pasteCtx 增补实时选择/剪贴板读写、⌘V 改为主动粘贴;逻辑在 src/clipboard-graph.js 的 bindCopy 与 src/clipboard-paste.js 的 pasteFromKey) // +1(2026-11-26 相册外部路径重启复授权装配;逻辑在 src/image-file-ref.js) // +5(2026-11-26 标注覆盖保存:桌面端不再生成死 __cache(4 行)+ 插件 saveNodeImage 装配(1 行);事务逻辑在 src/runtime-workbench-logic.js)
|
||||
const MAX_APP_JS_LINES = 8720 // +336(2026-11-30 图片策略 v2 与诊断:插件三层能力 thumb/preview/original/budget、原生解码闸门装配、wDiagDetail(分进程 footprint + 解码账本 + 插件源)、图库空闲预热、wReclaimMemoryNow/引用化;下一步按 domain 拆到 src/ 回落此上限) // +11(2026-11-27:停靠栏就绪后按新占位重新适应的监听;app.js 8315→8326) // +15(2026-11-26 复制/粘贴通道重写:DOM copy 事件装配、pasteCtx 增补实时选择/剪贴板读写、⌘V 改为主动粘贴;逻辑在 src/clipboard-graph.js 的 bindCopy 与 src/clipboard-paste.js 的 pasteFromKey) // +1(2026-11-26 相册外部路径重启复授权装配;逻辑在 src/image-file-ref.js) // +5(2026-11-26 标注覆盖保存:桌面端不再生成死 __cache(4 行)+ 插件 saveNodeImage 装配(1 行);事务逻辑在 src/runtime-workbench-logic.js)
|
||||
const MAX_APP_JS_SHARE = 0.40
|
||||
|
||||
// ── 历史记账(供回溯,逐条保留)──────────────────────────────────────────────
|
||||
@@ -213,7 +213,7 @@ const MAX_APP_JS_SHARE = 0.40
|
||||
// 需要实时读 .iwb-world 变换 + 按同类型实测高度校正视觉中心;属装配层的 DOM 读取,
|
||||
// 放 src 会引入新的全局读取与边界快照改动,权衡后留在 app.js // +10(2026-11-01):背景色「悬停预览」的 DOM 补丁助手(纯 DOM,不写数据/不进撤销栈);
|
||||
// 属装配层最小的 DOM 操作,放 src 会引入新的全局读取与边界快照改动,权衡后留在 app.js
|
||||
const MAX_WORKBENCH_LINES = 2231 // +52(2026-11-30:图片策略 v2 装配 + 诊断明细 + 浏览器窗口空闲休眠读数;预热的实现已抽到 src/ui-workbench-hooks.js 的 useGalleryPrewarm,下一步继续把 ctx 装配下沉以回落上限) // +11(2026-11-27:同上,Workbench 2169→2180) // 2026-11-26 复制/粘贴通道重写(+14:refs 新增粘贴时间戳/系统剪贴板可信标记、pasteCtx 增补 ids/clipboardOf/stageClip/readNativeText、bindCopy 装配)
|
||||
const MAX_WORKBENCH_LINES = 2318 // +10(2026-11-30 Canvas 边线装配:EdgeCanvas 组件、hoverEdgeId、手势命令式重画钩子;绘制逻辑在 src/ui-canvas-edges.js) // +52(2026-11-30:图片策略 v2 装配 + 诊断明细 + 浏览器窗口空闲休眠读数;预热的实现已抽到 src/ui-workbench-hooks.js 的 useGalleryPrewarm,下一步继续把 ctx 装配下沉以回落上限) // +11(2026-11-27:同上,Workbench 2169→2180) // 2026-11-26 复制/粘贴通道重写(+14:refs 新增粘贴时间戳/系统剪贴板可信标记、pasteCtx 增补 ids/clipboardOf/stageClip/readNativeText、bindCopy 装配)
|
||||
// 2026-11-18 v3.25.21:模态层指针守卫(2 行)
|
||||
// 实测 3090 → 2998(省 92):① 生成取消族 cancelRunsFor/cancelRun/cancelTaskJobs
|
||||
// → src/runtime-workbench-logic.js 的 createCancelActions(−53);② 工作区列表写回族
|
||||
|
||||
Reference in new issue
Block a user