sync(gallery,promptlib): 把桌面仓产物层的改动回写为源码(gallery 1.9.5 / promptlib 1.14.9)
validate / validate (push) Canceled after 0s

背景:11-28 的图库性能改造与提示词库参考图开关/勾选框/暗色对比度,是直接改在桌面仓
plugins/<id>/main.js 上的(产物层),本仓源码没跟上,导致本仓停在 gallery 1.7.5 / promptlib 1.13.1。

- gallery/src/index.js、styles.css ← 桌面仓 plugins/gallery(虚拟列表、拖动只改列宽、按宽高比占位等)
- promptlib/src/index.js、styles.css ← 桌面仓 plugins/promptlib(参考图上移、自绘蓝勾、accent token、兜底)
- 两处 package.json 版本与 entry 内 register manifest 的 version 同步到 1.9.5 / 1.14.9
  (此前 entry 内还是 1.7.5 / 1.14.0,被 validate 判为不一致)

scripts/validate.mjs:字段扫描改为「优先 register( 之后,找不到再回退整份源码」。
旧逻辑在整份源码里找第一个 id:/version:,会被 promptlib 业务代码里的 { id: 'q' + Date.now() } 误命中,
误报「entry 内 id (q) 与 ibwPlugin.id 不一致」;反过来只扫 register 之后又会让 __IWB_ANNOTATE_MANIFEST__ 这类
构建产物插件找不到字段。现在两段扫描,validate 15/15 通过。
This commit is contained in:
qiqi committed 2026-11-29 12:16:06 +08:00
1 parent 6e6bc3389d
commit 23cba0ccf3
7 files changed
+311 -45

No files matched your search

+14 -5
View File
@@ -37,19 +37,28 @@ export const checkPlugin = (dir) => {
if (src.indexOf('IWBPluginHost.register(') < 0) errors.push('entry 未调用 IWBPluginHost.register(manifest, factory)')
const idMatch = /(?:^|[\s{,])id:\s*'([^']+)'/.exec(src)
// v1.0.2:只在 register(...) 的 manifest 块里找字段。
// 旧写法在整份源码里找第一个 id:/version:,会被业务代码里的 { id: 'q' + Date.now() } 误命中
// (promptlib 就因此被判「entry 内 id (q) 与 ibwPlugin.id 不一致」)。
const regAt = src.indexOf('IWBPluginHost.register(')
// 从 register( 开始截到文件末尾:manifest 一定在 factory 之前,而业务代码里的同名键都在 register 之前
const regBlock = regAt >= 0 ? src.slice(regAt) : src
// 两段扫描:优先 register( 之后(避开业务代码里的同名键),找不到字面量再回退整份源码——
// image-annotate / image-vectorize 是构建产物,manifest 用 __IWB_XXX_MANIFEST__ 常量传入。
const pick = (re) => re.exec(regBlock) || re.exec(src)
const idMatch = pick(/(?:^|[\s{,])id:\s*'([^']+)'/)
if (!idMatch) errors.push("entry 内未找到 id: '<id>' 字面量(manifest 必须显式声明 id)")
else if (idMatch[1] !== id) errors.push('entry 内 id (' + idMatch[1] + ') 与 ibwPlugin.id (' + id + ') 不一致')
const apiMatch = /apiVersion:\s*(\d+)/.exec(src)
const apiMatch = pick(/apiVersion:\s*(\d+)/)
if (!apiMatch) errors.push('entry 内未找到 apiVersion 字面量')
else if (Number(apiMatch[1]) !== meta.apiVersion) errors.push('entry 内 apiVersion (' + apiMatch[1] + ') 与 ibwPlugin.apiVersion (' + meta.apiVersion + ') 不一致')
const versionMatch = /version:\s*'([^']+)'/.exec(src)
const versionMatch = pick(/version:\s*'([^']+)'/)
if (!versionMatch) errors.push("entry 内未找到 version: '<ver>' 字面量")
else if (versionMatch[1] !== String(pkg.version)) errors.push('entry 内 version (' + versionMatch[1] + ') 与 package.json version (' + pkg.version + ') 不一致')
if (!/name:\s*'[^']+'/.test(src)) errors.push("entry 内未找到 name: '<name>' 字面量")
if (!/capabilities:\s*\[/.test(src)) errors.push('entry 内未找到 capabilities 数组')
if (!/name:\s*'[^']+'/.test(regBlock) && !/name:\s*'[^']+'/.test(src)) errors.push("entry 内未找到 name: '<name>' 字面量")
if (!/capabilities:\s*\[/.test(regBlock) && !/capabilities:\s*\[/.test(src)) errors.push('entry 内未找到 capabilities 数组')
return errors
}