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
@@ -16,6 +16,7 @@
|
||||
- [项目工程与设计规范](standards/project-engineering-standards.md) —— 核心规则:排序 / 任务图 / API / 持久化 / 测试 / 发布 / 分层边界 / 交互契约 / 性能铁律
|
||||
- [工程规则库](standards/engineering-rulebook.md) —— 从实战沉淀的逐条工程规则(按主题聚类),实现与评审引用
|
||||
- [**设计 Token 规范**](standards/design-tokens.md) —— UI 设计语言的**唯一数值来源**:颜色/间距/字号/圆角/阴影/层级/动效 + 新增流程 + 现状审计(`node scripts/token-audit.js` 可复核)
|
||||
- [**插件两仓分工与同步规范**](standards/plugin-source-of-truth.md) —— 插件源码只在 `iwb-plugins-desktop` 改,桌面仓 `plugins/` 是产物;发市场前 `npm run check:plugins`(`gen-market` 已内置)
|
||||
- [**画布右键菜单规范**](standards/ctx-menu.md) —— 菜单该有哪些项、排除名单放在哪、增删流程与验证(`node scripts/ctx-menu-audit.js`,已在 `verify:ci` 里)
|
||||
- [**现状架构与性能事实基线**](standards/architecture-current-state.md) —— 改性能/内存/存储前的**首读**:逐条带 `file:line` 的现状事实 + 「别乱动 / 别重试」清单
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
# 现状架构与性能事实基线(桌面版)
|
||||
|
||||
> **本文档是什么**:现状**事实快照**,不是规范。用途:任何性能 / 内存 / 存储相关改动,先对齐这里的现实,避免把已经调好的东西改坏。
|
||||
> 日期 **2026-10-20**(**2026-11-16 复算 · v3.24.85**)| 基线(**最近一次 bump 版本的提交**,不是主干 HEAD)`main = af86fa5`(线上 `v3.26.108+af86fa5` —— 2026-11-27 **画布取景避开停靠栏**:新增 canvasSafeInsets 供 doFit / copyOffset 使用(读 --iwb-dock-l/-r 与工具条、底栏边距),停靠栏占位就绪或变化后按新占位重新取景(仅当视口仍是自动适应产物,不覆盖用户操作),初始默认视口不再落盘;**暗色自定义底色改用近黑文字**(对比度 1.4 → 约 9.4);**插件面板进停靠栏**(registerPanel 恢复落点,key = plugin:<插件id>:<面板id>,新增 side 偏好);便利贴 1.0.9 移除边栏面板;e2e 从 128 红归零并新增冒烟门禁;上一条 `v3.26.107+a9af024` —— 2026-11-24 **图库:出图即入图库 + 插入落本地副本(能标注)**:每张生成完成即归档并通知插件(此前只在整轮结束写一次 ⇒ 生成中图库一直空)、插入取源改本地字节优先并引用化(抓不到才留原链接 + 提示)、`getNodeImage` 补 `data.localRef` 候选(远程缓存命中却仍判「不支持标注」的直接成因)、批量插入改 4 列栅格(旧实现同批全叠一处),逻辑落 `src/gallery-sync.js`,app.js 只装配;上一条 `v3.26.60+cf0e9a0` —— **浮层字号上调一档**:「模型设置」「图像设置」选择项 11→13px、高 22→28、左右内距 6→10、间距 4→6、标题 12→14、面板 328→360,改动全落在 `.iwb-pop` 的 6 个 token(两面板共用一套);上一条 `v3.26.59+e966b34` —— 备份新增 `plugin-files/` 通道,提示词封面换机不再丢;再上一条 2026-11-23 **节点正文文本区修复**:提示词/文本节点正文透明继承卡片底色(白卡片消失)、编辑态三层框(控件 border / 聚焦光晕 / D8 焦点环)全去掉,规范补表面角色三分法与 `node-scope-test` 第 5 条守卫,8 张基线重录;上一条 `v3.26.51+21554b0` —— **M6 延展验证**:插件面板两段六次叠加样式合并重写、133 行新增零裸值;补 `--iwb-font-base`(14px) 第 8 档与亮色状态色调深(对浅页面 2.13 → ≥4.6),对比度守卫 114→138 对;新增 ⑦⑧ 组件夹具基线共 16 张;`batch-export` 1.2.2 状态色走宿主 token、去掉纯蓝主按钮;棘轮基线首次下调。M1–M6 全部完成;上一条 `v3.26.50+cab473c` —— **M5 闸门**:新增 `scripts/token-lint.js`(只查 diff 新增行,CSS 与 JS 内联样式两套判据、四类白名单)+ `tests/design-token-ratchet-test.js`(13 项计数只降不升)+ `tests/theme-contrast-test.js`(亮/暗 × 文字 × 表面 114 对),三条各做一次打红验证后接进 `verify:ci`;顺手把首启动「选择资料目录」弹窗 token 化(全仓最后一个完全未 token 化的界面);上一条 `v3.26.49+1743453` —— **M4-B6 收尾**:`style.css` 剩余 16 处半像素字号全清零(守卫收紧为全文件断言)、`--iwb-control-h` 裁定不扩到全局控件(并排表单 vs 成组紧凑控件);插件主题契约重写,`ALLOW_FILES` 文件级豁免 **6 → 0** —— 改为「私有皮肤 manifest 自声明 `skin` + chroma 强调色判据 + 内容色行内标记」,声明私有皮肤的插件不得引用宿主颜色 token;同步 4 个插件版本,插件侧中性色写死归零;视觉基线 8 张因字号栅格化变化更新,A/B 回退确认非环境噪声;上一条 `v3.26.48+cb9cb9c` —— **M4-B5 节点**:节点卡内部表面统一 `--iwb-field` —— 端口底色从 `#161616`(暗色对卡片差 39 级,一颗黑洞)改 `#494949`(差 12 级),同病灶另 6 处(ref-img/ref-single/upload-link/refmini-empty/task-result-img/node-head:hover)一并改;浮条与任务卡 hover 改 `color-mix(text 10%)`(原来 panel 与 layer2 深色同色,hover 无反馈);字号 12/15/11/13 全归档位、圆角 8/6/5/14 归并、间距 52 处等值 + 13 处 1px 级微调;删 6 个死类名;新增 `tests/node-scope-test.js` 钉「节点内禁用面板表面色」;上一条 `v3.26.47+f5c8174` —— **M4-B4 设置/外观**:新增 `--iwb-control-h`(30px) 修「同行输入框 33px / 按钮 24px」的 9px 落差;设置页正文 14→13、标题 16→15,范围内半像素字号清零;删 21 条死规则(setcell/setgrid/set-row/appear-val 等);新增 `tests/settings-scope-test.js` 钉「控件等高 / 死类名不复现 / 引用的 token 必须存在」;上一条 `v3.26.46+9f29996` —— 2026-11-23 **M4-B3 首页/库**:删 30 条零生产者规则(25 个类名在产物里 0 次)+ 4 条被 specificity 覆盖的死声明,`style.css` 2391→2339 行;首页/库 106 条规则换 token,间距写死 91→5(只剩版心与导航让位的布局值)、字号写死清零,新增 `--iwb-font-display:24px` 第 7 档;验收改为「计算样式逐元Line truncated
|
||||
> 日期 **2026-10-20**(**2026-11-16 复算 · v3.24.85**)| 基线(**最近一次 bump 版本的提交**,不是主干 HEAD)`main = 7c57668`(线上 `v3.26.108+7c57668` —— 2026-11-27 **画布取景避开停靠栏**:新增 canvasSafeInsets 供 doFit / copyOffset 使用(读 --iwb-dock-l/-r 与工具条、底栏边距),停靠栏占位就绪或变化后按新占位重新取景(仅当视口仍是自动适应产物,不覆盖用户操作),初始默认视口不再落盘;**暗色自定义底色改用近黑文字**(对比度 1.4 → 约 9.4);**插件面板进停靠栏**(registerPanel 恢复落点,key = plugin:<插件id>:<面板id>,新增 side 偏好);便利贴 1.0.9 移除边栏面板;e2e 从 128 红归零并新增冒烟门禁;上一条 `v3.26.107+a9af024` —— 2026-11-24 **图库:出图即入图库 + 插入落本地副本(能标注)**:每张生成完成即归档并通知插件(此前只在整轮结束写一次 ⇒ 生成中图库一直空)、插入取源改本地字节优先并引用化(抓不到才留原链接 + 提示)、`getNodeImage` 补 `data.localRef` 候选(远程缓存命中却仍判「不支持标注」的直接成因)、批量插入改 4 列栅格(旧实现同批全叠一处),逻辑落 `src/gallery-sync.js`,app.js 只装配;上一条 `v3.26.60+cf0e9a0` —— **浮层字号上调一档**:「模型设置」「图像设置」选择项 11→13px、高 22→28、左右内距 6→10、间距 4→6、标题 12→14、面板 328→360,改动全落在 `.iwb-pop` 的 6 个 token(两面板共用一套);上一条 `v3.26.59+e966b34` —— 备份新增 `plugin-files/` 通道,提示词封面换机不再丢;再上一条 2026-11-23 **节点正文文本区修复**:提示词/文本节点正文透明继承卡片底色(白卡片消失)、编辑态三层框(控件 border / 聚焦光晕 / D8 焦点环)全去掉,规范补表面角色三分法与 `node-scope-test` 第 5 条守卫,8 张基线重录;上一条 `v3.26.51+21554b0` —— **M6 延展验证**:插件面板两段六次叠加样式合并重写、133 行新增零裸值;补 `--iwb-font-base`(14px) 第 8 档与亮色状态色调深(对浅页面 2.13 → ≥4.6),对比度守卫 114→138 对;新增 ⑦⑧ 组件夹具基线共 16 张;`batch-export` 1.2.2 状态色走宿主 token、去掉纯蓝主按钮;棘轮基线首次下调。M1–M6 全部完成;上一条 `v3.26.50+cab473c` —— **M5 闸门**:新增 `scripts/token-lint.js`(只查 diff 新增行,CSS 与 JS 内联样式两套判据、四类白名单)+ `tests/design-token-ratchet-test.js`(13 项计数只降不升)+ `tests/theme-contrast-test.js`(亮/暗 × 文字 × 表面 114 对),三条各做一次打红验证后接进 `verify:ci`;顺手把首启动「选择资料目录」弹窗 token 化(全仓最后一个完全未 token 化的界面);上一条 `v3.26.49+1743453` —— **M4-B6 收尾**:`style.css` 剩余 16 处半像素字号全清零(守卫收紧为全文件断言)、`--iwb-control-h` 裁定不扩到全局控件(并排表单 vs 成组紧凑控件);插件主题契约重写,`ALLOW_FILES` 文件级豁免 **6 → 0** —— 改为「私有皮肤 manifest 自声明 `skin` + chroma 强调色判据 + 内容色行内标记」,声明私有皮肤的插件不得引用宿主颜色 token;同步 4 个插件版本,插件侧中性色写死归零;视觉基线 8 张因字号栅格化变化更新,A/B 回退确认非环境噪声;上一条 `v3.26.48+cb9cb9c` —— **M4-B5 节点**:节点卡内部表面统一 `--iwb-field` —— 端口底色从 `#161616`(暗色对卡片差 39 级,一颗黑洞)改 `#494949`(差 12 级),同病灶另 6 处(ref-img/ref-single/upload-link/refmini-empty/task-result-img/node-head:hover)一并改;浮条与任务卡 hover 改 `color-mix(text 10%)`(原来 panel 与 layer2 深色同色,hover 无反馈);字号 12/15/11/13 全归档位、圆角 8/6/5/14 归并、间距 52 处等值 + 13 处 1px 级微调;删 6 个死类名;新增 `tests/node-scope-test.js` 钉「节点内禁用面板表面色」;上一条 `v3.26.47+f5c8174` —— **M4-B4 设置/外观**:新增 `--iwb-control-h`(30px) 修「同行输入框 33px / 按钮 24px」的 9px 落差;设置页正文 14→13、标题 16→15,范围内半像素字号清零;删 21 条死规则(setcell/setgrid/set-row/appear-val 等);新增 `tests/settings-scope-test.js` 钉「控件等高 / 死类名不复现 / 引用的 token 必须存在」;上一条 `v3.26.46+9f29996` —— 2026-11-23 **M4-B3 首页/库**:删 30 条零生产者规则(25 个类名在产物里 0 次)+ 4 条被 specificity 覆盖的死声明,`style.css` 2391→2339 行;首页/库 106 条规则换 token,间距写死 91→5(只剩版心与导航让位的布局值)、字号写死清零,新增 `--iwb-font-display:24px` 第 7 档;验收改为「计算样式逐元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 迁出)
|
||||
|
||||
@@ -0,0 +1,90 @@
|
||||
# 插件两仓分工与同步规范(2026-11-29 定稿)
|
||||
|
||||
> 背景:2026-11-28 的图库/提示词库改动**直接改在桌面仓的产物层**,插件源仓没跟上,
|
||||
> 于是源仓停在 gallery 1.7.5 / promptlib 1.13.1,市场却发了 1.9.x / 1.14.x —— 两仓分叉。
|
||||
> 这份文档把「谁是真源、改哪、怎么发、怎么拦」写死,配套一条自动化守卫。
|
||||
|
||||
## 1. 两个仓库,各管什么
|
||||
|
||||
| 仓库 | 角色 | 可以手改吗 |
|
||||
| --- | --- | --- |
|
||||
| `iwb-plugins-desktop`(git.maqiart.eu.org/malongan/iwb-plugins-desktop) | **插件源码仓,唯一真源** | ✅ 只能改这里 |
|
||||
| `image-workbench-desktop`(`plugins/`、`market/`) | 宿主 + 插件**构建产物** | ❌ 不要手改,会被下一次同步覆盖 |
|
||||
|
||||
目录对照(一个插件 = 源仓三件套 → 桌面仓两种产物形态):
|
||||
|
||||
| 源仓 | 桌面仓(目录形态,带 styles.css 的插件) | 桌面仓(单文件形态) |
|
||||
| --- | --- | --- |
|
||||
| `<id>/src/index.js` | `plugins/<id>/main.js` | `plugins/runtime/plugin-<id>.<sha12>.js` |
|
||||
| `<id>/styles.css` | `plugins/<id>/styles.css` | (无) |
|
||||
| `<id>/package.json` 的 `version` | `plugins/<id>/manifest.json` 的 `version` + `plugins/index.json` 的 `version` | 同上(index.json 条目) |
|
||||
|
||||
当前走目录形态的:`gallery`、`promptlib`(有 styles.css 会自动走目录形态)。
|
||||
|
||||
## 2. 三条红线
|
||||
|
||||
1. **插件代码只在源仓改**。桌面仓 `plugins/**` 是构建产物,手改等于改 dist,下一次 `sync-plugins-from-repo.js` 会覆盖。
|
||||
2. **版本号成对**:源仓 `package.json.version` 与 `src/index.js` 里 `IWBPluginHost.register({ version })` 必须相等
|
||||
(源仓 `npm run validate` 会拦;只在两处写,不要第三处)。
|
||||
3. **发市场前必须过一致性守卫**:`npm run check:plugins`(`gen-market.js` 已内置,不一致直接中止)。
|
||||
|
||||
## 3. 日常流程:改一个插件
|
||||
|
||||
```bash
|
||||
cd ../iwb-plugins-desktop
|
||||
# 1) 改 <id>/src/index.js 与 <id>/styles.css,然后:
|
||||
npm run validate # 13~15 个插件必须全绿(含版本/字段一致性)
|
||||
npm run test:<id> # 有 harness 的跑一下(gallery / promptlib / album)
|
||||
git commit -am 'fix(<id>): x.y.z …' && git push gitea main
|
||||
|
||||
cd ../image-workbench-desktop
|
||||
# 2) 同步产物(幂等,内容不变时零 diff)
|
||||
node scripts/sync-plugins-from-repo.js
|
||||
npm run check:plugins # 期望:通过
|
||||
git diff --stat # 只应有该插件相关的文件变化
|
||||
|
||||
# 3) 发市场
|
||||
node scripts/gen-market.js && node scripts/gen-market-page.js
|
||||
# 备份远端索引 → scp index.json / <id>-<ver>.zip / index.html → chmod -R a+rX → 回读校验
|
||||
|
||||
# 4) 提交(提交信息写「同步插件 <id>@<ver>」)
|
||||
```
|
||||
|
||||
## 4. 门禁与命令
|
||||
|
||||
| 命令 | 作用 | 谁在用 |
|
||||
| --- | --- | --- |
|
||||
| `npm run validate`(源仓) | 源仓内部一致性:id/apiVersion/version 与 package.json 对齐 | 改插件的必跑 |
|
||||
| `npm run check:plugins`(桌面仓) | 桌面仓产物 == 源仓源码,且版本一致 | 手动 / gen-market 内自动 |
|
||||
| `node scripts/gen-market.js` | 生成市场索引与 zip,**开头先跑一致性检查** | 发市场时 |
|
||||
|
||||
`check-plugins-sync.js` 的行为:源仓不存在(CI、别人机器)时打印一行并跳过,不阻塞;存在时逐插件比对
|
||||
`main.js`/`styles.css` 的 sha256、`manifest.json`/`index.json` 的版本,任何一项不符即非 0 退出并给出修复命令。
|
||||
|
||||
## 5. 应急:产物层已经被改过(真实案例)
|
||||
|
||||
2026-11-28 的情况就是这一类。补回源仓的做法:
|
||||
|
||||
1. 先看清「产物相对源仓多了什么、少了什么」:
|
||||
`diff <(cat ../iwb-plugins-desktop/<id>/src/index.js) <(cat plugins/<id>/main.js)`
|
||||
只用 `<` 开头的是源仓旧代码(正常,被新实现替换),用 `>` 的是产物新增实现。**确认没有源仓独有功能被覆盖**。
|
||||
2. 反向同步:产物 → 源仓 `<id>/src/index.js` + `<id>/styles.css`;同时把 `package.json.version` 与 entry 内
|
||||
`register({ version })` 一起升到新版本(升版本而不是原地改字节:市场按版本判断更新,同版本换字节客户端不会重下)。
|
||||
3. 源仓 `npm run validate` 全绿 → commit/push。
|
||||
4. 桌面仓 `node scripts/sync-plugins-from-repo.js` 重新生成产物(**不要**继续手改产物)+ `npm run check:plugins`。
|
||||
5. 重新发市场。
|
||||
|
||||
## 6. 常见错误对照(都真实发生过)
|
||||
|
||||
| 现象 | 根因 | 正确做法 |
|
||||
| --- | --- | --- |
|
||||
| 源仓显示「最近更新 3 天前」,但市场已发新版 | 改动只在桌面仓产物层 | 按 §5 回写源仓,或按 §3 从源仓改起 |
|
||||
| `validate` 报「entry 内 version 与 package.json 不一致」 | 只改了 package.json 或只改了 register 里的 version | 两处一起改 |
|
||||
| `validate` 报「entry 内 id (q) 与 ibwPlugin.id 不一致」 | 校验器在整份源码里找第一个 `id:`,命中业务代码 `{ id: 'q' + Date.now() }` | 已修:先扫 `register(` 之后的 manifest 块,找不到再回退整份文件 |
|
||||
| 市场装完插件样式丢失 | 插件带 styles.css 但被当单文件同步 | 源仓放 `styles.css` 会自动走目录形态,不要手工拼单文件 |
|
||||
|
||||
## 7. 版本与发布的关系
|
||||
|
||||
- 插件版本独立于客户端版本:客户端 3.26.x 与插件 1.9.x/1.14.x 互不绑定。
|
||||
- 插件改动**不需要**重打客户端(桌面包不含插件);发完市场,用户重启客户端即生效。
|
||||
- 客户端需要新插件能力(新宿主 API)时,先在桌面仓实现并发布客户端,再升插件版本依赖它——顺序不能反。
|
||||
@@ -14,6 +14,7 @@
|
||||
"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",
|
||||
"check:plugins": "node scripts/check-plugins-sync.js",
|
||||
"coverage:browser": "npm run build && node scripts/coverage-browser.js",
|
||||
"audit:pins": "node scripts/audit-source-pins.js",
|
||||
"tokens:write": "node scripts/gen-tokens.js --write",
|
||||
|
||||
+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)
|
||||
@@ -0,0 +1,77 @@
|
||||
'use strict'
|
||||
// 插件两仓一致性守卫(v3.26.109)
|
||||
//
|
||||
// 约定:插件源码只在 iwb-plugins-desktop 改,桌面仓 plugins/ 是**产物**。
|
||||
// 但 2026-11-28 出现过「直接改桌面仓产物层、源仓没跟上」:源仓停在 gallery 1.7.5 / promptlib 1.13.1,
|
||||
// 而市场已经发了 1.9.x / 1.14.x,两边内容与版本分叉。
|
||||
//
|
||||
// 这个脚本把「产物是否等于源仓 + 版本是否一致」变成一条命令;gen-market 前会自动跑。
|
||||
// node scripts/check-plugins-sync.js # 默认源仓 ../iwb-plugins-desktop
|
||||
// node scripts/check-plugins-sync.js <源仓路径>
|
||||
// 源仓不存在时跳过(CI / 别人机器上不阻塞),打印一行提示。
|
||||
const fs = require('fs')
|
||||
const path = require('path')
|
||||
const crypto = require('crypto')
|
||||
|
||||
const root = path.resolve(__dirname, '..')
|
||||
const srcRoot = process.argv[2] ? path.resolve(process.argv[2]) : path.resolve(root, '..', 'iwb-plugins-desktop')
|
||||
const sha = (buf) => crypto.createHash('sha256').update(buf).digest('hex')
|
||||
|
||||
if (!fs.existsSync(srcRoot)) {
|
||||
console.log('[check-plugins] 跳过:找不到插件源仓 ' + srcRoot + '(只在有源仓的机器上校验)')
|
||||
process.exit(0)
|
||||
}
|
||||
|
||||
const index = JSON.parse(fs.readFileSync(path.join(root, 'plugins', 'index.json'), 'utf8'))
|
||||
const byId = new Map(index.map((e) => [e.id, e]))
|
||||
const problems = []
|
||||
|
||||
for (const id of fs.readdirSync(srcRoot)) {
|
||||
const dir = path.join(srcRoot, id)
|
||||
if (!fs.statSync(dir).isDirectory()) continue
|
||||
const pkgPath = path.join(dir, 'package.json')
|
||||
const entry = path.join(dir, 'src', 'index.js')
|
||||
if (!fs.existsSync(pkgPath) || !fs.existsSync(entry)) continue // template / node_modules / ai-chat 等
|
||||
const pkg = JSON.parse(fs.readFileSync(pkgPath, 'utf8'))
|
||||
const meta = pkg.ibwPlugin || {}
|
||||
if (!meta.id || meta.id !== id) continue
|
||||
// 只写不发市场的插件(ai-chat 需本机 Magpie;template 是脚手架样例)不参与一致性比对
|
||||
if (id === 'ai-chat' || id === 'template') continue
|
||||
const idx = byId.get(id)
|
||||
if (!idx) { problems.push(id + ':源仓有、桌面仓 plugins/index.json 没有(漏同步)'); continue }
|
||||
if (String(idx.version) !== String(pkg.version)) {
|
||||
problems.push(id + ':版本不一致(源仓 ' + pkg.version + ' / 桌面 ' + idx.version + ')')
|
||||
}
|
||||
const srcBytes = fs.readFileSync(entry)
|
||||
const styleSrc = path.join(dir, 'styles.css')
|
||||
const folderMode = fs.existsSync(styleSrc) || !!idx.dir
|
||||
if (folderMode) {
|
||||
const out = path.join(root, 'plugins', idx.dir || id, idx.main || 'main.js')
|
||||
if (!fs.existsSync(out)) { problems.push(id + ':缺少产物 ' + path.relative(root, out)); continue }
|
||||
if (sha(fs.readFileSync(out)) !== sha(srcBytes)) problems.push(id + ':产物 main.js 与源仓 src/index.js 不一致')
|
||||
if (fs.existsSync(styleSrc)) {
|
||||
const outStyle = path.join(root, 'plugins', idx.dir || id, idx.style || 'styles.css')
|
||||
if (!fs.existsSync(outStyle) || sha(fs.readFileSync(outStyle)) !== sha(fs.readFileSync(styleSrc))) {
|
||||
problems.push(id + ':产物 styles.css 与源仓不一致')
|
||||
}
|
||||
}
|
||||
const man = path.join(root, 'plugins', idx.dir || id, 'manifest.json')
|
||||
if (fs.existsSync(man)) {
|
||||
const m = JSON.parse(fs.readFileSync(man, 'utf8'))
|
||||
if (String(m.version) !== String(pkg.version)) problems.push(id + ':manifest.json 版本 ' + m.version + ' ≠ 源仓 ' + pkg.version)
|
||||
}
|
||||
} else {
|
||||
const expected = 'plugin-' + id + '.' + sha(srcBytes).slice(0, 12) + '.js'
|
||||
const out = path.join(root, 'plugins', 'runtime', expected)
|
||||
if (!fs.existsSync(out)) problems.push(id + ':缺少产物 plugins/runtime/' + expected + '(源仓内容变了但没同步)')
|
||||
}
|
||||
}
|
||||
|
||||
if (problems.length) {
|
||||
console.error('[check-plugins] 两仓不一致(' + problems.length + ' 项):')
|
||||
for (const p of problems) console.error(' - ' + p)
|
||||
console.error('[check-plugins] 修法:在 ' + srcRoot + ' 改源码 → 本仓 node scripts/sync-plugins-from-repo.js → 再发市场')
|
||||
console.error('[check-plugins] 禁止直接改本仓 plugins/ 里的产物(那是构建输出,会被下一次 sync 覆盖)')
|
||||
process.exit(1)
|
||||
}
|
||||
console.log('[check-plugins] 通过:桌面仓 plugins/ 与插件源仓一致(' + index.length + ' 个插件)')
|
||||
@@ -14,6 +14,15 @@ const path = require('path')
|
||||
const crypto = require('crypto')
|
||||
const { zipStore } = require('./plugin-zip')
|
||||
|
||||
// v3.26.109:发市场前先确认「桌面仓 plugins/ == 插件源仓」(源仓不存在则跳过)。
|
||||
// 2026-11-28 出现过直接改产物层、源仓停在旧版本,两仓分叉;这条守卫把问题挡在发市场之前。
|
||||
try {
|
||||
require('child_process').execFileSync(process.execPath, [path.join(__dirname, 'check-plugins-sync.js')], { stdio: 'inherit' })
|
||||
} catch (e) {
|
||||
console.error('[gen-market] 插件两仓不一致,已中止(先同步源码再发市场)')
|
||||
process.exit(1)
|
||||
}
|
||||
|
||||
const root = path.resolve(__dirname, '..')
|
||||
const man = JSON.parse(fs.readFileSync(path.join(root, 'plugins', 'index.json'), 'utf8'))
|
||||
const meta = JSON.parse(fs.readFileSync(path.join(root, 'plugins', 'meta.json'), 'utf8'))
|
||||
|
||||
Reference in new issue
Block a user