fix(plugin): 外置旧版本不再盖住内置升级(高版本胜)v3.25.44

真实事故:资料目录 plugins/ 残留 browser 1.6.0,内置已有 1.7.0,但合并规则是外置无条件覆盖
⇒ 设置里永远显示 1.6.0 且无更新入口。

- loader 新增 compareVersions(数字分段、缺段补 0)
- 合并规则:ext / 目录插件 只在版本 >= 当前时覆盖(同版本外置胜,允许本地打补丁)
- 新增 tests/plugin-loader-test.js(1.6<1.7 / 1.10>1.9 / 1.20.6>1.9.0 / 空版本)
This commit is contained in:
qiqi committed 2026-11-20 10:00:25 +08:00
1 parent f6e4441504
commit 3211beb706
8 files changed
+59 -7

No files matched your search

+8
View File
@@ -14,6 +14,14 @@
> 3. 核验正式地址版本 → 之后才移动 `stable` / `stable-verified-<日期>` 标签、更新本 CHANGELOG、写 GitHub Release(`gh release create`)。
> 测试发现问题 → 改 → 再 `deploy:test`,正式环境不受影响。回滚点 `git reset --hard stable`。
## v3.25.44(2026-11-20)修:资料目录里的旧外置插件会盖住内置升级
- 症状:客户端升到 3.25.43,设置里浏览器插件仍显示 **1.6.0**;资料目录 `plugins/` 下残留的外置 1.6.0 覆盖了随包的内置 1.7.0,且**没有任何更新入口**。
- 原因:v3.25.41 的合并规则是「外置无条件覆盖内置」(同 id 直接 `set`),旧外置副本永久压制内置升级。
- 修复:改为**高版本胜**;同版本时外置胜(允许用户本地打补丁)。目录插件扫描同理。
- 新增 `compareVersions`(数字分段比较、缺段补 0)与 `tests/plugin-loader-test.js`(1.6<1.7、1.10>1.9、1.20.6>1.9.0、空版本等)。
- 说明:不做自动删除——资料目录里的旧文件保留,只是不再生效;用户可自行清理。
## v3.25.43(2026-11-20)插件数据层首个真实用例:浏览器「最近访问」
- 浏览器插件 1.7.0:面板地址栏挂 `<datalist>`,提交地址时记录**最近 12 条**(去重、新的在前),下拉可直接选。
+3 -2
View File
@@ -8679,9 +8679,10 @@ items.push(el('button', { key: 'bgc', className: 'iwb-ctx-item', onClick: (e) =>
for (const l of locals) { if (l && l.id) byId.set(String(l.id), { id: String(l.id), file: 'plugin.js', version: 'dev', source: 'local', code: l.code }) }
}
} catch (e) { /* 开发者模式读取失败不影响启动 */ }
for (const e of ext) { const id = String((e && e.id) || ''); if (id) byId.set(id, Object.assign({}, e, { source: 'external' })) }
const VC = (a, b) => { const L = wPluginLoader(); return (L && L.compareVersions) ? L.compareVersions(a, b) : 0 }
for (const e of ext) { const id = String((e && e.id) || ''); if (id) { const cur = byId.get(id); if (!cur || VC(e.version, cur.version) >= 0) byId.set(id, Object.assign({}, e, { source: 'external' })) } }
// 目录插件(v3.25.41):扫描 <资料目录>/plugins/*/manifest.json;与单文件同 id 时目录优先
try { const L0 = wPluginLoader(); if (L0 && L0.listFolderEntries) for (const e of await L0.listFolderEntries()) if (!byId.has(e.id)) byId.set(e.id, e) } catch (e2) { /* 目录扫描失败不影响内置加载 */ }
try { const L0 = wPluginLoader(); if (L0 && L0.listFolderEntries) for (const e of await L0.listFolderEntries()) { const cur = byId.get(e.id); if (!cur || (L0.compareVersions && L0.compareVersions(e.version, cur.version) >= 0)) byId.set(e.id, e) } } catch (e2) { /* 目录扫描失败不影响内置加载 */ }
// 关键:加载前先快照「用户关掉过哪些插件」,加载过程绝不能覆盖这个状态
let persistedState = {}
try {
+2 -2
View File
@@ -1,7 +1,7 @@
{
"name": "image-workbench-web",
"private": true,
"version": "3.25.43",
"version": "3.25.44",
"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/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/storage-config-shape-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/image-blob-store-test.js && node tests/image-preview-derive-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/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/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/ui-groups-sidebar-test.js && node tests/ui-lib-sidebar-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/prompt-md-roundtrip-test.js && node tests/generation-results-store-test.js && node tests/out-groups-order-test.js && node tests/ui-workbench-hooks-test.js",
"test:unit": "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/storage-config-shape-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/image-blob-store-test.js && node tests/image-preview-derive-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/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/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/ui-groups-sidebar-test.js && node tests/ui-lib-sidebar-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/prompt-md-roundtrip-test.js && node tests/generation-results-store-test.js && node tests/out-groups-order-test.js && node tests/ui-workbench-hooks-test.js",
"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",
+1 -1
View File
@@ -1983,7 +1983,7 @@ dependencies = [
[[package]]
name = "image-workbench"
version = "3.25.43"
version = "3.25.44"
dependencies = [
"arboard",
"base64 0.22.1",
+1 -1
View File
@@ -1,6 +1,6 @@
[package]
name = "image-workbench"
version = "3.25.43"
version = "3.25.44"
description = "无限画布 · 生图工作台桌面版"
authors = ["malongan"]
license = ""
+1 -1
View File
@@ -1,7 +1,7 @@
{
"$schema": "../node_modules/@tauri-apps/cli/config.schema.json",
"productName": "image-workbench",
"version": "3.25.43",
"version": "3.25.44",
"identifier": "com.malongan.imageworkbench",
"build": {
"frontendDist": "../dist",
+15
View File
@@ -29,6 +29,20 @@
return global.btoa(bin) === expect
}
// 版本比较(v3.25.44):外置插件不再无条件覆盖内置 —— 高版本胜,同版本外置胜(允许本地打补丁)。
// 否则用户资料目录里残留的旧外置插件会永久盖住随包升级后的内置插件(browser 1.6.0 盖 1.7.0 的真实案例)。
function compareVersions (a, b) {
const pa = String(a || '0').split('.').map(function (x) { return parseInt(x, 10) || 0 })
const pb = String(b || '0').split('.').map(function (x) { return parseInt(x, 10) || 0 })
const n = Math.max(pa.length, pb.length)
for (let i = 0; i < n; i++) {
const x = pa[i] || 0
const y = pb[i] || 0
if (x !== y) return x > y ? 1 : -1
}
return 0
}
async function sha256Hex (text) {
const buf = await global.crypto.subtle.digest('SHA-256', new global.TextEncoder().encode(String(text)))
return Array.from(new Uint8Array(buf)).map(function (b) { return b.toString(16).padStart(2, '0') }).join('')
@@ -217,6 +231,7 @@
source: source,
verifyCode: verifyCode,
sha256Hex: sha256Hex,
compareVersions: compareVersions,
loadBuiltin: loadBuiltin,
loadExternal: loadExternal,
loadLocal: loadLocal,
+28
View File
@@ -0,0 +1,28 @@
'use strict'
// 插件加载器纯函数测试(src/runtime-plugin-loader.js,v3.25.44)
//
// 为什么要有:外置插件与内置同 id 时按版本取高者。
// 若比较写错(字符串比较 / 少段位 / 预发布后缀),会出现「用户资料目录里的旧插件永久盖住内置升级」——
// browser 1.6.0 盖住内置 1.7.0 的真实事故就是这条规则缺失导致的。
const assert = require('assert')
const fs = require('fs')
const path = require('path')
const vm = require('vm')
const root = path.resolve(__dirname, '..')
const sandbox = { crypto: require('crypto').webcrypto, TextEncoder, btoa: (s) => Buffer.from(s, 'binary').toString('base64') }
vm.runInNewContext(fs.readFileSync(path.join(root, 'src', 'runtime-plugin-loader.js'), 'utf8'), sandbox)
const L = sandbox.IWBRuntimePluginLoader
assert.ok(L && typeof L.compareVersions === 'function', 'compareVersions 未导出')
const cmp = L.compareVersions
assert.strictEqual(cmp('1.6.0', '1.7.0'), -1, '1.6.0 < 1.7.0')
assert.strictEqual(cmp('1.7.0', '1.6.0'), 1)
assert.strictEqual(cmp('1.7.0', '1.7.0'), 0)
assert.strictEqual(cmp('1.10.0', '1.9.9'), 1, '按数字比较而非字符串(1.10 > 1.9)')
assert.strictEqual(cmp('2', '2.0.0'), 0, '缺段按 0 补齐')
assert.strictEqual(cmp('', '1.0.0'), -1, '空版本视为 0')
assert.strictEqual(cmp('1.20.6', '1.9.0'), 1, 'annotate 这类两位数版本也要正确')
assert.strictEqual(cmp('1.0.0', '1.0'), 0)
console.log('plugin-loader checks passed(版本比较:数字分段 / 缺段补齐 / 两位数)')