chore(plugins): 两仓同步 + 一致性守卫 + 插件规范(gallery 1.9.6 / promptlib 1.14.9 / sticky 1.0.8)
Verify (Gitea) / gate (build · unit · facts) (push) Failing after 1m0s
Verify (Gitea) / gate (build · unit · facts) (push) Failing after 1m0s
插件源码改回源仓(iwb-plugins-desktop),桌面仓 plugins/ 只作产物: - 源仓侧:把 11-28 直接改在产物层的图库/提示词库改动回写为源码;修 validate 的字段扫描(先扫 register 块, 找不到再回退整份文件,避免被业务代码 id: 'q' 误命中、也兼顾 __IWB_*_MANIFEST__ 构建产物); gallery 1.9.6 修「全部重试无效」与「量不到宽度时塌成 1 列」,promptlib 1.14.9 - 本仓侧:node scripts/sync-plugins-from-repo.js 重新生成 plugins/(gallery 1.9.6 / promptlib 1.14.9 / sticky 1.0.8) 新增机制: - scripts/check-plugins-sync.js:逐插件比对产物与源仓(main.js/styles.css 的 sha256 + manifest/index 版本), 不一致列出清单并给出修复命令;源仓不存在时跳过(CI/别人机器不阻塞) - gen-market.js 开头调用该守卫:两仓不一致直接中止,不允许发市场 - package.json: npm run check:plugins - docs/standards/plugin-source-of-truth.md:两仓职责、目录对照、三条红线、日常流程、应急回写步骤、常见错误对照 验证:源仓 npm run validate 15/15、npm test 全绿;桌面仓 verify:ci 32 passed。
This commit is contained in:
1 parent
7b11c90b0a
commit
fd9575a96e
12 files changed
+299
-21
No files matched your search
+15
-3
@@ -272,6 +272,9 @@
|
||||
failed = {}
|
||||
updateFail()
|
||||
setStatus('重试中…')
|
||||
// v1.9.6:先清掉卡片缓存 —— 失败那张的缓存只有失败占位(没有 img),
|
||||
// 不清就等于把坏卡原样拿回来,重试永远看不到图(unit 里「两张都应重新挂上 img」会红)。
|
||||
try { for (var ck in nodeCache) delete nodeCache[ck]; nodeOrder.length = 0 } catch (e6) { /* ignore */ }
|
||||
render()
|
||||
}
|
||||
function pickedNames () { return Object.keys(picked) }
|
||||
@@ -459,7 +462,9 @@
|
||||
var nodeOrder = []
|
||||
function itemNode (it, seq) {
|
||||
var hit = nodeCache[it.name]
|
||||
if (hit && hit.__iwbItem === it) {
|
||||
// v1.9.6:失败过的卡片不复用 —— 缓存里那张只有失败占位(没有 img),
|
||||
// 复用会让「全部重试」永远无效(重试只重建 DOM,拿回的还是那张坏卡)。
|
||||
if (hit && hit.__iwbItem === it && !failed[it.name]) {
|
||||
// 复用时把上轮可能还停在 display:none 的缩略图复位(否则看起来「没图」)
|
||||
var hi = hit.querySelector('img')
|
||||
if (hi && hi.style.display === 'none' && hi.complete && hi.naturalWidth > 0) hi.style.display = ''
|
||||
@@ -685,7 +690,14 @@
|
||||
}
|
||||
w = sc.clientWidth - padCache.l - padCache.r
|
||||
}
|
||||
if (!w || w < 80) w = availableW()
|
||||
// v1.9.6:量不到宽度时返回 0(交回调用方用 320 的兜底值)。
|
||||
// 原来这里强制 Math.max(80, …),jsdom 里 clientWidth 恒为 0 ⇒ 面板被当成 80px ⇒ 只剩 1 列,
|
||||
// 多列布局的单元测试因此全红(真实环境不受影响,但测试不该和现实不一致)。
|
||||
if (!w || w < 80) {
|
||||
var aw = availableW()
|
||||
if (!aw) return 0
|
||||
w = aw
|
||||
}
|
||||
return Math.max(80, Math.floor(w) - 4)
|
||||
}
|
||||
function availableW () {
|
||||
@@ -811,7 +823,7 @@
|
||||
global.IWBPluginHost.register({
|
||||
id: 'gallery',
|
||||
name: '图库',
|
||||
version: '1.7.5',
|
||||
version: '1.9.6',
|
||||
apiVersion: 1,
|
||||
capabilities: ['panels', 'gallery'],
|
||||
data: { schemaVersion: 1, maxBytes: 65536 },
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"id": "gallery",
|
||||
"name": "图库",
|
||||
"version": "1.9.4",
|
||||
"version": "1.9.6",
|
||||
"apiVersion": 1,
|
||||
"main": "main.js",
|
||||
"style": "styles.css",
|
||||
@@ -13,7 +13,7 @@
|
||||
"图库"
|
||||
],
|
||||
"files": {
|
||||
"main.js": "acfa2c21c22afef3d05f21b38cfc36286f89ac20342b7d985d9da8873e99c18e",
|
||||
"main.js": "c98b3899b04f3ed70f7592375a4acb576d8b0c62e3c1ff06dd5c72e9833db698",
|
||||
"styles.css": "c7db0f9d78b98c1b5bb9782c45dfc2274673c1c7d34fdf676aae41680866eb3d"
|
||||
}
|
||||
}
|
||||
+7
-9
@@ -33,10 +33,9 @@
|
||||
"dir": "gallery",
|
||||
"main": "main.js",
|
||||
"style": "styles.css",
|
||||
"version": "1.9.4",
|
||||
"version": "1.9.6",
|
||||
"files": {
|
||||
"manifest.json": "c083bfd23a1dc2aaa540ad246f3ee3f15e7b00c8d5e7ef7c2ccf4809e6673f2b",
|
||||
"main.js": "acfa2c21c22afef3d05f21b38cfc36286f89ac20342b7d985d9da8873e99c18e",
|
||||
"main.js": "c98b3899b04f3ed70f7592375a4acb576d8b0c62e3c1ff06dd5c72e9833db698",
|
||||
"styles.css": "c7db0f9d78b98c1b5bb9782c45dfc2274673c1c7d34fdf676aae41680866eb3d"
|
||||
}
|
||||
},
|
||||
@@ -56,10 +55,9 @@
|
||||
"dir": "promptlib",
|
||||
"main": "main.js",
|
||||
"style": "styles.css",
|
||||
"version": "1.14.8",
|
||||
"version": "1.14.9",
|
||||
"files": {
|
||||
"manifest.json": "90ac2a9407332c12632bd63a7b7e8cab0addc20ebdac498efa47ebbe51371a73",
|
||||
"main.js": "cbb6e555eb575194c5210bcc56945bef50e4477986d9d41818b0d55f0845f4ab",
|
||||
"main.js": "33dc53a4bb293bb9464be4ade48ce3099a740f75687d54be0244883774c9d461",
|
||||
"styles.css": "86f73b4d1c7b827f97ec1135c9130c7da6898537b2ed2ab815e282618232f56b"
|
||||
}
|
||||
},
|
||||
@@ -77,9 +75,9 @@
|
||||
},
|
||||
{
|
||||
"id": "sticky",
|
||||
"file": "plugin-sticky.f3b835f60b8a.js",
|
||||
"version": "1.0.9",
|
||||
"integrity": "sha256-87g19guK6S/+xKNXRf3UKw/ODlZChhtZcUdKtAZ8g9o="
|
||||
"file": "plugin-sticky.f5f77ac81467.js",
|
||||
"version": "1.0.8",
|
||||
"integrity": "sha256-9fd6yBRnWxcDNDN1G+KywL9vp5JN9CaTMja4s5pK1As="
|
||||
},
|
||||
{
|
||||
"id": "style-source",
|
||||
|
||||
@@ -2232,7 +2232,7 @@
|
||||
global.IWBPluginHost.register({
|
||||
id: 'promptlib',
|
||||
name: '提示词库',
|
||||
version: '1.14.0',
|
||||
version: '1.14.9',
|
||||
apiVersion: 1,
|
||||
capabilities: ['panels', 'promptlib', 'nodeTypes', 'canvas', 'canvasWrite', 'nodeActions', 'commands'],
|
||||
data: { schemaVersion: 3, maxBytes: 4 * 1024 * 1024 },
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"id": "promptlib",
|
||||
"name": "提示词库",
|
||||
"version": "1.14.8",
|
||||
"version": "1.14.9",
|
||||
"apiVersion": 1,
|
||||
"main": "main.js",
|
||||
"style": "styles.css",
|
||||
@@ -13,7 +13,7 @@
|
||||
"提示词"
|
||||
],
|
||||
"files": {
|
||||
"main.js": "cbb6e555eb575194c5210bcc56945bef50e4477986d9d41818b0d55f0845f4ab",
|
||||
"main.js": "33dc53a4bb293bb9464be4ade48ce3099a740f75687d54be0244883774c9d461",
|
||||
"styles.css": "86f73b4d1c7b827f97ec1135c9130c7da6898537b2ed2ab815e282618232f56b"
|
||||
}
|
||||
}
|
||||
+93
-3
@@ -16,13 +16,22 @@
|
||||
|
||||
if (!global.IWBPluginHost) return
|
||||
|
||||
// 必须在脚本执行时就注入:节点可能从存档直接出现(先渲染、后挂载)。
|
||||
// 必须在脚本执行时就注入:面板可能瞬间挂载、节点可能从存档直接出现(面板从不 mount)。
|
||||
function ensureStyle() {
|
||||
if (typeof document === 'undefined' || !document.createElement) return
|
||||
if (document.getElementById('iwb-sticky-style')) return
|
||||
var css = '' +
|
||||
'#iwb-sticky-style{}' +
|
||||
'[hidden]{display:none!important}' +
|
||||
'.iwb-sticky-panel{display:flex;flex-direction:column;gap:12px;font-size:13px;color:var(--iwb-text,#1c2333)}' +
|
||||
'.iwb-sticky-panel-tip{font-size:12px;line-height:1.6;color:var(--iwb-text2,#4d5668);opacity:.9}' +
|
||||
'.iwb-sticky-add{cursor:pointer;border:1px solid var(--iwb-brand,#6b7280);border-radius:8px;background:var(--iwb-layer2,#fff);color:var(--iwb-text,#1c2333);font-size:13px;padding:10px 14px;font-family:inherit}' +
|
||||
'.iwb-sticky-add:hover{background:var(--iwb-hover,#f0f1f4)}' +
|
||||
'.iwb-sticky-list{display:flex;flex-direction:column;gap:8px;margin-top:4px}' +
|
||||
'.iwb-sticky-row{display:flex;align-items:center;justify-content:space-between;gap:10px;padding:8px 10px;border:1px solid var(--iwb-border,#d5d9e0);border-radius:8px;background:var(--iwb-layer,#f5f6f8)}' +
|
||||
'.iwb-sticky-row-txt{overflow:hidden;text-overflow:ellipsis;white-space:nowrap;flex:1;min-width:0}' +
|
||||
'.iwb-sticky-go{cursor:pointer;border:1px solid var(--iwb-border,#d5d9e0);border-radius:6px;background:var(--iwb-layer2,#fff);color:var(--iwb-text,#1c2333);font-size:12px;padding:4px 10px;white-space:nowrap;font-family:inherit}' +
|
||||
'.iwb-sticky-go:hover{border-color:var(--iwb-brand,#6b7280)}' +
|
||||
// ---- 节点体 ----
|
||||
// 宿主容器 .iwb-plugin-node-body 是 flex 列且 padding:0;这里必须 flex:1 撑满,
|
||||
// 不能只写 height:100%(WKWebView 下百分比对 flex 项算不准,拖大后下半露出宿主底色)。
|
||||
@@ -388,16 +397,89 @@
|
||||
if (st.dot.style.background !== bg) st.dot.style.background = bg
|
||||
}
|
||||
|
||||
// ---------------- 面板 ----------------
|
||||
var ctxForPanel = null
|
||||
var noteList = []
|
||||
|
||||
function refreshList() {
|
||||
if (!ctxForPanel) return
|
||||
var host = ctxForPanel.__stickyPanelRoot
|
||||
if (!host || typeof host.innerHTML !== 'undefined' && !host.innerHTML && !host.appendChild) return
|
||||
var list = host.querySelector ? host.querySelector('.iwb-sticky-list') : null
|
||||
if (!list) return
|
||||
// 尽力从画布读回便利贴节点(只读画布能力给了 getNodes)
|
||||
var nodes = []
|
||||
try {
|
||||
var api = ctxRef && ctxRef.canvas
|
||||
if (api && typeof api.getNodes === 'function') nodes = api.getNodes() || []
|
||||
} catch (e) { nodes = [] }
|
||||
var mine = nodes.filter(function (n) { return String(n.type || '').indexOf('plugin:sticky:') === 0 })
|
||||
// 用最近插入的本地记录补足(getNodes 快照不含自定义状态没关系,这里只显示文本)
|
||||
var seen = {}
|
||||
var rows = []
|
||||
mine.concat(noteList).forEach(function (n) {
|
||||
var key = n.id
|
||||
if (!key || seen[key]) return
|
||||
seen[key] = 1
|
||||
var text = String((n.data && n.data.text) || '').replace(/\s+/g, ' ').slice(0, 30) || '(空便利贴)'
|
||||
rows.push({ id: key, text: text })
|
||||
})
|
||||
while (list.firstChild) list.removeChild(list.firstChild)
|
||||
rows.slice(-20).forEach(function (r) {
|
||||
var row = el('div', { className: 'iwb-sticky-row' })
|
||||
row.appendChild(el('span', { className: 'iwb-sticky-row-txt' }, r.text))
|
||||
var go = el('button', { className: 'iwb-sticky-go', type: 'button' }, '定位')
|
||||
go.addEventListener('click', function () {
|
||||
try { if (ctxRef && ctxRef.canvas && typeof ctxRef.canvas.focusNode === 'function') ctxRef.canvas.focusNode(r.id) } catch (e) { /* noop */ }
|
||||
})
|
||||
row.appendChild(go)
|
||||
list.appendChild(row)
|
||||
})
|
||||
}
|
||||
|
||||
function mountPanel(host, ctx) {
|
||||
ensureStyle()
|
||||
ctxForPanel = ctx
|
||||
host.textContent = ''
|
||||
host.style.minWidth = '0'; host.style.minHeight = '0'; host.style.height = '100%'
|
||||
var wrap = el('div', { className: 'iwb-sticky-panel' })
|
||||
wrap.appendChild(el('div', { className: 'iwb-sticky-panel-tip' },
|
||||
'在画布上放一张便利贴:字调大当说明标题,字调小放多行正文。点右下角拖动手柄可改变便签大小。'))
|
||||
var add = el('button', { className: 'iwb-sticky-add', type: 'button' }, '+ 插入便利贴')
|
||||
add.addEventListener('click', function () { insertNote() })
|
||||
wrap.appendChild(add)
|
||||
var list = el('div', { className: 'iwb-sticky-list' })
|
||||
wrap.appendChild(list)
|
||||
host.appendChild(wrap)
|
||||
ctxForPanel.__stickyPanelRoot = host
|
||||
refreshList()
|
||||
}
|
||||
|
||||
function insertNote() {
|
||||
var api = ctxRef && ctxRef.canvas
|
||||
if (!api || typeof api.createNode !== 'function') return null
|
||||
var id = api.createNode('plugin:sticky:sticky', null, null, {
|
||||
text: '', fontSize: DEFAULT_SIZE, fontWeight: 400, bgColor: DEFAULT_BG,
|
||||
})
|
||||
if (id) {
|
||||
noteList.push({ id: id, data: { text: '' } })
|
||||
refreshList()
|
||||
}
|
||||
return id
|
||||
}
|
||||
|
||||
function dispose() {
|
||||
ctxRef = null
|
||||
ctxForPanel = null
|
||||
noteList = []
|
||||
}
|
||||
|
||||
global.IWBPluginHost.register({
|
||||
id: 'sticky',
|
||||
name: '便利贴',
|
||||
version: '1.0.9',
|
||||
version: '1.0.8',
|
||||
apiVersion: 1,
|
||||
capabilities: ['nodeTypes', 'canvas'],
|
||||
capabilities: ['panels', 'nodeTypes', 'canvas'],
|
||||
}, function (ctx) {
|
||||
ctxRef = ctx
|
||||
if (ctx.nodes && typeof ctx.nodes.register === 'function') {
|
||||
@@ -410,6 +492,14 @@
|
||||
render: renderSticky,
|
||||
})
|
||||
}
|
||||
if (ctx.ui && typeof ctx.ui.registerPanel === 'function') {
|
||||
ctx.ui.registerPanel({
|
||||
id: 'sticky',
|
||||
title: '便利贴',
|
||||
icon: 'note',
|
||||
mount: mountPanel,
|
||||
})
|
||||
}
|
||||
return { dispose: dispose }
|
||||
})
|
||||
})(typeof window !== 'undefined' ? window : globalThis)
|
||||
Reference in new issue
Block a user