Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3ecd07ef3c | ||
|
|
3eed42d43d | ||
|
|
dbbd558160 | ||
|
|
eec99144f3 | ||
|
|
3a4ebc2eb3 | ||
|
|
84c2c10c0c | ||
|
|
cb6dcd1813 | ||
|
|
3fcc003738 | ||
|
|
856e34a3f0 | ||
|
|
1a0998b1d4 |
No files matched your search
@@ -447,7 +447,7 @@
|
||||
| 拆 `app.js` 但不处理钉点 | 一次红几百条,无法定位问题 |
|
||||
| 重排 529 个 tag | 代价大、收益小;已用 CHANGELOG 说明缓解 |
|
||||
| 用 `c8` / `nyc` 量本仓覆盖率 | **实测不可用**:src 模块用 `window.eval()` 加载(无脚本名),V8 无从归属。见规则库 §13.42 |
|
||||
| 删除生产 CSP 里的 `127.0.0.1:30092` | **不是残留**,是 2026-10-17 有意为「本地服务插件」做的安全边界调整(`CHANGELOG:226`、事实基线 §265-267) |
|
||||
| 删除生产 CSP 里的 `127.0.0.1:30092` | **不是残留**,是 2026-10-17 有意为「本地服务插件」做的安全边界调整(`CHANGELOG:226`、事实基线 §265-267)。**桌面客户端的 CSP 以 `tauri.conf.json` 为准**(本项目是桌面客户端,`_headers` 属旧网页部署、不约束桌面);v3.25.11 误删导致插件挂,见 `tests/desktop-csp-loopback-test.js` |
|
||||
|
||||
---
|
||||
|
||||
|
||||
@@ -14,6 +14,58 @@
|
||||
> 3. 核验正式地址版本 → 之后才移动 `stable` / `stable-verified-<日期>` 标签、更新本 CHANGELOG、写 GitHub Release(`gh release create`)。
|
||||
> 测试发现问题 → 改 → 再 `deploy:test`,正式环境不受影响。回滚点 `git reset --hard stable`。
|
||||
|
||||
## v3.25.17(2026-11-18)图标细节:去掉系统灰底 + 新托盘符号
|
||||
|
||||
### 修复
|
||||
- **macOS Dock/启动台的灰色底衬**:macOS 26 对「带透明圆角」的旧式 .icns 会把图形缩进到系统底衬里,
|
||||
表现为黑图标外面套一圈浅灰。改为**不透明满幅**源图(黑底铺满整张 1024)后,系统直接把自己的圆角遮罩
|
||||
套上去 ⇒ 图标变成纯黑到边,灰圈消失。
|
||||
- **托盘图标换成新 IW 符号**:白底版的 IW 做**挖空**处理(圆角方块填充、W 镂空),符合 macOS 模板图规范
|
||||
(纯黑 + alpha,系统自动明暗反转)。
|
||||
|
||||
### 说明
|
||||
- `icon.icns` / 各尺寸 PNG 取自不透明满幅;`icon.ico` 仍取透明圆角版(Windows 侧圆角更好看)。
|
||||
- 仅图标资源变更,无功能改动。
|
||||
|
||||
## v3.25.16(2026-11-18)更换应用图标
|
||||
|
||||
### 变更
|
||||
- 应用图标换成新版(黑底圆角 + 白色 W),覆盖 macOS `.icns` / Windows `.ico` / 各尺寸 PNG 与 Store Logo。
|
||||
- 图标源为 1024px,内容满幅(不留内边距);托盘图标(`tray-template.png`)保持不变。
|
||||
- 随 `npx tauri icon` 一并清理了用不到的 `android/`、`ios/` 目录。
|
||||
|
||||
### 说明
|
||||
- 仅图标变更,无功能改动;mac 已发布,Windows 包在下次构建时自带新图标。
|
||||
|
||||
## v3.25.15(2026-11-18)彻底转桌面客户端:删除网页版部署面
|
||||
|
||||
### 变更
|
||||
- **删除网页版部署产物**:`_headers`、`functions/`(`api/img.js`、`plugins/[[path]].js`)、`wrangler.toml`,
|
||||
以及只测它们的 `tests/iwb-csp-gate.spec.js`、`tests/iwb-functions-headers.spec.js`、`tests/functions-api-test.js`、`tests/iwb-v32-web-test.js`。
|
||||
- **`scripts/serve-test.js` 退化为纯静态服务器**:不再解析 `_headers`、不再模拟 Pages Functions。
|
||||
- **`app.js` 清除网页代理分支**:图床下载 ③ 兜底、缩略图兜底、预览派生 `viaUrl`、显示缩略图 4 处 `/api/img` 全部删除,桌面端只走原生 HTTP。
|
||||
- **更新清单平台解耦**:`tauri.windows.conf.json` 的 updater 指向 `updates/latest-windows.json`;
|
||||
`publish-windows-update.sh` 改写独立清单,mac 发版不再丢弃 Windows 条目。
|
||||
- **README / docs/RELEASES.md** 改为桌面客户端口径。
|
||||
|
||||
### 说明
|
||||
- Windows 客户端 **需要在 3.25.15 手动装一次**(旧版的 updater 仍指向 `latest.json`),之后自动更新走独立清单。
|
||||
|
||||
## v3.25.14(2026-11-18)桌面 CSP 回归修复(鲜艺抠图)+ 外观 tab
|
||||
|
||||
### 修复
|
||||
- **桌面版 CSP 重新放行本地服务**:v3.25.11 的「CSP 清理」把 `http://127.0.0.1:30092` /
|
||||
`http://localhost:30092` 当遗留端口删掉,但它是 2026-10-17 有意为「本地服务插件」放宽的边界。
|
||||
后果:桌面版鲜艺抠图插件与批量导出的「走本地抠图」报 `Failed to fetch`,网页版正常(两份 CSP 互不相干)。
|
||||
|
||||
- **补门禁**:新增 `tests/desktop-csp-loopback-test.js`(运行时值断言,避开源码钉点棘轮),
|
||||
钉住「桌面 CSP 必须放行 30092」与「两份 CSP 的 loopback 例外不得漂移」。
|
||||
|
||||
### 新增
|
||||
- **设置 → 外观**:画布底色(亮/暗两套)+ 主题色(两套共用),取色器仿 Obsidian(SVH 方块 + 色相条 + RGB + 十六进制)。
|
||||
连线、端口、主按钮、选中框、进度动画统一吃 `--iwb-brand`;连线单独 `--iwb-edge`。
|
||||
实现落在 `src/ui-appearance.js`,`makeSave` 白名单已同步(否则保存即丢)。
|
||||
|
||||
## v3.25.13(2026-11-18)启动兜底:工作子目录缺失时自动补齐
|
||||
|
||||
### 修复
|
||||
|
||||
@@ -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 102 个单测文件(jsdom 契约测试;2026-11-07 新增 sync-facts-guard(事实一致性)/ _helpers/source(统一源文本);2026-11-12 新增 provider-ping(测速 no-cors 兜底))
|
||||
test:unit 101 个单测文件(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)
|
||||
|
||||
@@ -1,9 +1,6 @@
|
||||
# 🎨 生图工作台 Web 版(Cloudflare Pages 免费部署)
|
||||
# 🎨 生图工作台(桌面客户端)
|
||||
|
||||
**在线访问:https://iwb.maqiart.eu.org**(自定义域名,Cloudflare 免费 HTTPS)
|
||||
|
||||
|
||||
基于 **OpenAI 兼容生图 API** 的节点式图形化生图工作台,纯前端实现(Cloudflare Pages 免费托管)。
|
||||
基于 **OpenAI 兼容生图 API** 的节点式图形化生图工作台。**Tauri v2 桌面客户端**(macOS / Windows),数据全部落在本机资料目录。
|
||||
|
||||
- **零后端**:数据保存在浏览器(localStorage + IndexedDB),图片生成直连兼容 API;Tuzi 生图固定使用 generations、要求 URL 响应,参考图允许公网 URL 与本地 Base64,且不自动重试
|
||||
- 与独立版功能一致:无限画布、节点连线、文生图/图生图、参数设置(比例/分辨率对齐接口)、提示词库、节点组收藏、图库、右键菜单、双击聚焦/适应视图、标注节点等
|
||||
@@ -13,7 +10,7 @@
|
||||
- 稳定性边界:保存失败会保留恢复快照并支持重试,离页前执行本地兜底;启动时检查 localStorage/IndexedDB 可用性并显示异常。
|
||||
- 构建:`npm run build` 用 **esbuild 压缩打包**(单 `dist/app.js` = `src/` 模块按序拼接 + `app.js`,另有压缩 `style.css`;`dist/` 不再有 `src/`),并生成带 Git commit 元数据的 `dist/version.json`。
|
||||
- 测试:`npm test` 运行 jsdom 契约测试,`npm run test:e2e` 构建后启动本地静态服务器并运行 Playwright Chromium 测试;`npm run verify` 执行完整验证。
|
||||
- 发布:`npm run deploy` 仅在完整验证通过后,将 `dist/` 上传到 Cloudflare Pages。
|
||||
- 发布:`./scripts/publish-update.sh <版本>` 构建 macOS 双架构并写更新清单;Windows 用 `./scripts/publish-windows-update.sh <setup.exe>` 重签并写独立清单(`latest-windows.json`)。
|
||||
|
||||
## 第三方许可
|
||||
|
||||
@@ -29,27 +26,24 @@
|
||||
|
||||
**想知道「这个项目还有什么待办」** → [`BACKLOG.md`](BACKLOG.md)(唯一入口:优先级 + 证据链接 + 明确不做的项)。
|
||||
|
||||
## 部署到 Cloudflare Pages(免费)
|
||||
## 构建与发布(桌面客户端)
|
||||
|
||||
### 本地手动发布(本仓库方式)
|
||||
> 已从网页版迁移为桌面客户端,**不再部署 Cloudflare Pages**(`_headers` / `functions/` / `wrangler.toml` 已删除)。
|
||||
|
||||
```bash
|
||||
npm ci
|
||||
npm run deploy # 正式站(--branch main)
|
||||
npm run deploy:test # 测试站(--branch test)
|
||||
npm run build # 前端产物 dist/(esbuild 压缩)
|
||||
npx tauri build # 桌面安装包(macOS: .app + dmg / Windows: nsis)
|
||||
```
|
||||
|
||||
`npm run deploy` 会先跑完整 `verify`,通过后再把 `dist/` 上传到 Cloudflare Pages。
|
||||
| 平台 | 命令 | 产物 |
|
||||
| --- | --- | --- |
|
||||
| macOS | `./scripts/publish-update.sh <版本>` | `updates/latest.json` + 双架构 dmg / app.tar.gz |
|
||||
| Windows | `./scripts/publish-windows-update.sh <setup.exe>` | `updates/latest-windows.json`(平台独立) |
|
||||
|
||||
### CI(只验证,不部署)
|
||||
两个平台的更新清单**完全解耦**:mac 发版不影响 Windows 版本号,反之亦然。
|
||||
|
||||
`.github/workflows/verify.yml` 在**推送到 `main` 与向 `main` 开 PR** 时执行验证门禁,分两个 job:`gate`(`npm ci` + `npm run verify:ci` = 构建 + 校验 + lint + 单测 + 事实守卫)与 `e2e`(Playwright + `npm run test:e2e`),**不自动部署**。
|
||||
|
||||
发布配置位于 `wrangler.toml`,Cloudflare Pages 输出目录固定为 `dist/`。部署前生成的 `version.json` 可用于确认线上版本和 Git commit。
|
||||
|
||||
### 绑定自定义域名(可选)
|
||||
|
||||
Pages 项目 → **Custom domains** → 添加域名(免费 HTTPS 自动签发)。
|
||||
CI:`.github/workflows/verify.yml` 在推送 `main` 与向 `main` 开 PR 时执行 `npm run verify:ci`。
|
||||
|
||||
## 使用前配置
|
||||
|
||||
|
||||
@@ -1,9 +0,0 @@
|
||||
/*
|
||||
X-Content-Type-Options: nosniff
|
||||
Referrer-Policy: no-referrer
|
||||
Permissions-Policy: camera=(), microphone=(), geolocation=()
|
||||
Content-Security-Policy: default-src 'self'; script-src 'self'; worker-src 'self' blob:; style-src 'self' 'unsafe-inline'; img-src 'self' https: data: blob:; connect-src 'self' https: http://127.0.0.1:30092 http://localhost:30092 http://127.0.0.1:3425 http://localhost:3425; object-src 'none'; base-uri 'none'; frame-ancestors 'none'
|
||||
|
||||
/sw.js
|
||||
Cache-Control: no-cache, no-store, must-revalidate
|
||||
Service-Worker-Allowed: /
|
||||
@@ -381,7 +381,9 @@
|
||||
compression: { enabled: true, maxMB: 8, maxEdge: 2048, quality: 0.9, format: 'keep' },
|
||||
}
|
||||
const W_DEF_RETENTION = { enabled: true, maxFiles: 500, maxDays: 15 }
|
||||
const W_DEF_CANVAS = { generationConcurrency: 4, taskStallEndMs: 300000, autoSaveImages: true, backupOriginals: true }
|
||||
// 默认外观在 src/ui-appearance.js(DEFAULTS);这里只放引用,避免两处默认值漂移
|
||||
const W_DEF_APPEARANCE = (window.IWBUIApearance && window.IWBUIApearance.DEFAULTS) || { canvasBgLight: '#d9dbde', canvasBgDark: '#6f6f6f', accent: '#6b7280' }
|
||||
const W_DEF_CANVAS = { generationConcurrency: 4, taskStallEndMs: 300000, autoSaveImages: true, backupOriginals: true, appearance: W_DEF_APPEARANCE }
|
||||
// 任务条「结束」按钮出现的阈值:默认 5 分钟。判据是「该任务距上一次进展的时长」,
|
||||
// 而不是任务总时长 —— 多个变体(如 3 张)正常跑 6 分钟也不会误报"卡住"。
|
||||
const TASK_STALL_END_MIN = 60000
|
||||
@@ -1815,10 +1817,9 @@
|
||||
if (fkEarly && /^https:/i.test(fkEarly) && !wThumbProxyTried.has(fkEarly)) {
|
||||
wThumbProxyTried.add(fkEarly)
|
||||
try {
|
||||
// 桌面端没有 /api/img 代理(无服务端)⇒ 用 plugin-http 直取字节(Rust 侧请求,不受 CORS 限制)
|
||||
const pr = wIsTauri()
|
||||
? await wTauri.http.fetch(fkEarly)
|
||||
: await fetch('/api/img?url=' + encodeURIComponent(fkEarly), { mode: 'cors' })
|
||||
// 桌面客户端:用 plugin-http 直取字节(Rust 侧请求,不受 CORS 限制)
|
||||
if (!wIsTauri()) { if (fkEarly) wThumbFail.add(fkEarly); return null }
|
||||
const pr = await wTauri.http.fetch(fkEarly)
|
||||
// v3.87.52(丙方案 C5):交给 wRegisterBlobUrl(入参是 Blob,内部创建并登记 objectURL),
|
||||
// 避免此前的"创建了 blob URL 却不登记、不回收"✗
|
||||
if (pr.ok) return storeOutputThumb(Object.assign({}, item, { url: wRegisterBlobUrl(await pr.blob()) }))
|
||||
@@ -3343,6 +3344,11 @@
|
||||
function wPrefersDark() {
|
||||
try { return !!(window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches) } catch (e) { return false }
|
||||
}
|
||||
// 外观(画布底色 + 主题色)实现在 src/ui-appearance.js:默认值/归一化/写 CSS 变量/对比度提示都在那边。
|
||||
// 这里只做装配(app.js 有行数棘轮,不再堆细节)。
|
||||
function applyAppearance(cfg) {
|
||||
try { const A = window.IWBUIApearance; if (A) A.apply(cfg, document.documentElement.classList.contains('theme-dark')) } catch (e) { /* ignore */ }
|
||||
}
|
||||
function applyTheme(t) {
|
||||
// 'system' 只是存下来的偏好值,真正落地成 dark/light 看系统当前外观
|
||||
const mode = (t === 'system') ? (wPrefersDark() ? 'dark' : 'light') : (t === 'dark' ? 'dark' : 'light')
|
||||
@@ -4355,13 +4361,13 @@
|
||||
}
|
||||
}
|
||||
} catch (e) { /* 继续兜底 */ }
|
||||
// ③ **本站同源代理**兜底(functions/api/img.js;跨域图床专用。不经任何第三方)
|
||||
// ③ 原生 HTTP 兜底(Rust 侧请求,不受 CORS 限制)
|
||||
// 本项目是桌面客户端,没有服务端同源代理(旧的 functions/api/img.js 已随网页版删除)
|
||||
try {
|
||||
// 桌面端没有同源代理:改用 plugin-http 直连(Rust 侧请求,不受 CORS 限制)
|
||||
const r2 = wIsTauri()
|
||||
? await wTauri.http.fetch(su)
|
||||
: await fetch('/api/img?url=' + encodeURIComponent(su), { mode: 'cors' })
|
||||
if (r2.ok) { downloadBlob(await r2.blob()); wDownloadToast(wIsTauri() ? '已通过原生 HTTP 取图保存' : '该图床不支持直连下载,已通过本站代理保存'); return }
|
||||
if (wIsTauri()) {
|
||||
const r2 = await wTauri.http.fetch(su)
|
||||
if (r2.ok) { downloadBlob(await r2.blob()); wDownloadToast('已通过原生 HTTP 取图保存'); return }
|
||||
}
|
||||
} catch (e) { /* 继续兜底 */ }
|
||||
// ④ 最后兜底:新标签打开(右键/长按另存)——绝不静默失败
|
||||
try {
|
||||
@@ -4672,10 +4678,9 @@ const tbCenterSeed = (type, refs) => {
|
||||
const Derive = (typeof window !== 'undefined') ? window.IWBImagePreviewDerive : null
|
||||
if (!Derive || typeof Derive.create !== 'function' || typeof document === 'undefined') return v
|
||||
previewPending.add(key)
|
||||
// 跨域图必须走同源代理(否则 fetch 必失败 ⇒ 负缓存后等于没做 ✗,见 §8.3 坑 2)
|
||||
// 桌面端没有 /api/img 代理:不给 viaUrl,让派生器直连(失败即负缓存并回退原图,不影响显示)
|
||||
const viaUrl = (/^https?:\/\//i.test(v) && (typeof location === 'undefined' || v.indexOf(location.origin + '/') !== 0) && !wIsTauri())
|
||||
? (location.origin + '/api/img?url=' + encodeURIComponent(v)) : undefined
|
||||
// 桌面客户端没有同源代理(旧的 functions/api/img.js 已随网页版删除)⇒ 派生器直连;
|
||||
// 跨域失败即负缓存并回退原图,不影响显示。
|
||||
const viaUrl = undefined
|
||||
let inst = null
|
||||
try { inst = Derive.create({ maxEdge: PREVIEW_MAX_EDGE, quality: 0.82 }) } catch (e) { inst = null }
|
||||
if (!inst || typeof inst.deriveUrl !== 'function') { previewPending.delete(key); wPreviewPick(key, v); return v }
|
||||
@@ -4756,10 +4761,8 @@ const tbCenterSeed = (type, refs) => {
|
||||
if (displayThumbs.size >= DISPLAY_THUMB_CACHE_MAX) { const first = displayThumbs.keys().next().value; if (first !== undefined) displayThumbs.delete(first) }
|
||||
displayThumbs.set(key, val)
|
||||
}
|
||||
const isRemoteHttp = /^https?:\/\//i.test(v) && (typeof location === 'undefined' || v.indexOf(location.origin + '/') !== 0)
|
||||
// 桌面端没有代理:直接给原地址(<img> 不受 CORS 限制,能正常显示;canvas 降采样失败会回退原图)
|
||||
img.src = (isRemoteHttp && wIsTauri()) ? v
|
||||
: (isRemoteHttp ? (location.origin + '/api/img?url=' + encodeURIComponent(v)) : v)
|
||||
// 桌面客户端没有同源代理:直接给原地址(<img> 不受 CORS 限制,能正常显示;canvas 降采样失败会回退原图)
|
||||
img.src = v
|
||||
img.onload = () => {
|
||||
try {
|
||||
const iw = img.naturalWidth || 0, ih = img.naturalHeight || 0
|
||||
@@ -6010,6 +6013,9 @@ const tbCenterSeed = (type, refs) => {
|
||||
// 变量名保持不变 ⇒ 下游 viewportRef / activeWsRef / flushViewport 的调用点零改动
|
||||
const { viewportRef, activeWsRef, flushViewport } = IWWorkbenchHooks.useViewportPersistence(activeWsId, viewport)
|
||||
refs.config = config
|
||||
// 外观:配置到位/切换主题时把画布底色与主题色写到 :root(放在 config 同步之后,
|
||||
// 否则首屏拿不到配置,改完颜色要重启才生效)
|
||||
useEffect(() => { try { applyAppearance(config) } catch (e) { /* ignore */ } }, [config, theme])
|
||||
useEffect(() => {
|
||||
let alive = true
|
||||
// 启动时一次性迁移历史 localStorage 里的 base64 大图到 IndexedDB(释放空间,治撑爆)
|
||||
|
||||
@@ -1,151 +1,108 @@
|
||||
# 任务:在 Windows 上为 image-workbench-desktop 产出安装包
|
||||
# 任务:在 Windows 上为 image-workbench-desktop 构建 v3.25.15 安装包
|
||||
|
||||
你是这台 Windows 机器上的打包执行者。目标是把已拉取到本地的 Tauri v2 项目**构建出 Windows x64 安装包**,自测通过后交付产物信息。**只做打包相关的事,不改业务代码。**
|
||||
你是这台 Windows 机器上的打包执行者。只做打包与自测,**不改业务代码**。
|
||||
|
||||
## 背景
|
||||
> ⚠️ v3.25.15 起的变化:项目已**彻底转桌面客户端**(`_headers` / `functions/` / `wrangler.toml` 已删除,`npm run deploy` 脚本已移除);
|
||||
> 更新清单**平台解耦**(Windows 用 `updates/latest-windows.json`,**由 Mac 侧用正式私钥生成,你不写**)。
|
||||
|
||||
- 项目:Image Workbench 桌面版(Tauri v2 + 原生 JS,前端产物在 dist/)
|
||||
- 仓库目录:本机已 clone(先自己确认路径,通常在当前目录或其子目录,含 `src-tauri/tauri.conf.json`)
|
||||
- 应用标识:`com.malongan.imageworkbench`
|
||||
- 数据目录(运行时):`%USERPROFILE%\Documents\ImageWorkbench`
|
||||
- 参考文档(仓库内):`docs/DESKTOP_WINDOWS.md`(本次任务的权威说明)
|
||||
## 硬性约束
|
||||
|
||||
## 硬性约束(违反即失败)
|
||||
1. 不改 `app.js` / `src/**` / `src-tauri/src/**` / `style.css` 的业务逻辑
|
||||
2. 不绕过 lint 门禁;报错就停下报告
|
||||
3. 不用 `npm install`,只用 `npm ci`;版本已定 **3.25.15**,不要改
|
||||
4. 不 commit / 不 push / 不打 tag / 不跑任何 `scripts/publish-*.sh`
|
||||
5. 不改 `src-tauri/tauri.windows.conf.json`(产物已锁 `nsis`,不要 msi)
|
||||
|
||||
1. **不修改** `app.js`、`src/**`、`src-tauri/src/**` 的任何业务逻辑
|
||||
2. **不绕过** 构建前的 lint 门禁(`beforeBuildCommand` 已含 `npm run lint`);lint 报错就停下来报告,不要改成跳过
|
||||
3. **不改** `package.json` 里的 scripts 语义;唯一允许改版本号的地方是 `node scripts/set-version.js <版本>`
|
||||
4. 不用 `npm install`,只用 `npm ci`
|
||||
5. 不安装/升级全局工具版本(Node/Rust)除非环境检查明确缺失,且每次安装前先向我确认
|
||||
6. 不把任何密钥、token、代理密码写进文件或提交
|
||||
7. 不提交 git commit、不推送、不打 tag(除非我明确要求)
|
||||
|
||||
## 第一步:环境检查(先做,结果先给我看)
|
||||
## 第零步:拉代码
|
||||
|
||||
```powershell
|
||||
node -v # 期望 v22.x
|
||||
npm -v
|
||||
rustc -V # 必须含 "msvc"
|
||||
rustup show active-toolchain
|
||||
git --version
|
||||
git fetch --all --tags; git checkout main; git pull --ff-only
|
||||
git rev-parse --short HEAD # 必须是 84c2c10 或其后代
|
||||
node -e "console.log(require('./package.json').version)" # 必须 3.25.15
|
||||
```
|
||||
|
||||
然后跑仓库自带检查脚本:
|
||||
## 第一步:环境检查
|
||||
|
||||
```powershell
|
||||
node -v; npm -v; rustc -V; rustup show active-toolchain
|
||||
powershell -ExecutionPolicy Bypass -File scripts\windows-check.ps1
|
||||
```
|
||||
|
||||
**判定**:
|
||||
- 全部 `[OK]` → 继续
|
||||
- 出现 `[缺失]` → 停止,把缺失项和提示原文发我(不要自行安装)
|
||||
全部 `[OK]` 才继续;出现 `[缺失]` 停止报告(不要自行安装)。
|
||||
|
||||
## 第二步:装依赖
|
||||
## 第二步:依赖
|
||||
|
||||
```powershell
|
||||
npm ci
|
||||
```
|
||||
|
||||
- 失败先看是不是网络/代理问题(npm 可临时设 `npm config set proxy http://127.0.0.1:10808`,装完删掉)
|
||||
- 成功后报告:`node_modules` 是否存在、耗时
|
||||
本次新增两个 Rust 插件依赖(single-instance / notification),首次构建会多拉一些 crate。
|
||||
|
||||
## 第三步:定版本号
|
||||
|
||||
**本次版本已定:3.25.1**(仓库里 package.json / tauri.conf.json / Cargo.toml 都是这个号)。
|
||||
不要自行改版本号;只有我明确要求时才用 `node scripts/set-version.js <新版本>`。
|
||||
## 第三步:构建(用一次性临时密钥签名)
|
||||
|
||||
```powershell
|
||||
node -e "console.log(require('./package.json').version)" # 应输出 3.25.1
|
||||
npx tauri signer generate -w "$env:TEMP\iwb-tmp.key" --password ""
|
||||
$env:TAURI_SIGNING_PRIVATE_KEY = Get-Content "$env:TEMP\iwb-tmp.key" -Raw
|
||||
$env:TAURI_SIGNING_PRIVATE_KEY_PASSWORD = ""
|
||||
npx tauri build
|
||||
Remove-Item "$env:TEMP\iwb-tmp.key" -Force
|
||||
```
|
||||
|
||||
确认三处一致:
|
||||
> 产出的 `.sig` 是临时密钥签的,**我会在 Mac 上用正式私钥重签**,你附上即可。
|
||||
|
||||
## 第四步:确认产物
|
||||
|
||||
```powershell
|
||||
node -e "console.log(require('./package.json').version, require('./src-tauri/tauri.conf.json').version)"
|
||||
Select-String -Path src-tauri\Cargo.toml -Pattern '^version'
|
||||
Get-ChildItem src-tauri\target\release\bundle -Recurse -Include *.exe,*.sig | Select FullName,Length
|
||||
Get-FileHash "src-tauri\target\release\bundle\nsis\image-workbench_3.25.15_x64-setup.exe" -Algorithm SHA256
|
||||
Test-Path dist\plugins # 期望 False
|
||||
Test-Path _headers # 期望 False
|
||||
Test-Path functions # 期望 False
|
||||
```
|
||||
|
||||
## 第四步:构建
|
||||
## 第五步:自测清单(逐条报通过/失败)
|
||||
|
||||
```powershell
|
||||
npm run app:build
|
||||
```
|
||||
**基础**
|
||||
1. 安装并启动;数据目录 `%USERPROFILE%\Documents\ImageWorkbench` 生成 `data.json`/`canvases`/`library`/`images`
|
||||
2. **`images\` 下必须有 `canvas` 文件夹**(v3.25.12 之前只有 `thumbs`,这是丢图根因)
|
||||
3. 设置 → 通用:数据库目录正确;「打开」能弹资源管理器
|
||||
4. 关窗口进程仍在托盘;左键唤出;右键有菜单
|
||||
|
||||
预期内部顺序:`lint → build(含剥离内置插件)→ tauri build`。
|
||||
首次 5~15 分钟(Rust 依赖编译),之后 1~2 分钟。
|
||||
**图片持久化(历史 bug 复现点)**
|
||||
5. `Ctrl+V` 粘贴新图 → 出现图片节点
|
||||
6. **正常退出**(托盘右键退出,非强杀)→ 重开 → 图仍在、显示正常
|
||||
7. 从资源管理器拖图进画布 → 退出重开 → 图还在
|
||||
|
||||
**失败处理**:
|
||||
| 报错 | 处理 |
|
||||
|---|---|
|
||||
| `link.exe not found` / `LNK` | 缺 VS Build Tools C++ 工作负载 → 停止并报告 |
|
||||
| rustc 显示 `gnu` | `rustup default stable-x86_64-pc-windows-msvc`(可自行执行) |
|
||||
| `Windows SDK is not installed` | 停止并报告 |
|
||||
| npm/网络超时 | 检查代理,重试一次;仍失败则报告 |
|
||||
| lint 报错 | **停止**,把报错原文发我 |
|
||||
**桌面壳(本次新增)**
|
||||
8. 单实例:连续双击两次 → 只有一个窗口,第二次聚焦已有
|
||||
9. 外链:点「项目主页」→ 用系统浏览器打开,应用不变(不能被导航成网页)
|
||||
10. 跑一次生图,完成后弹系统通知
|
||||
|
||||
## 第五步:确认产物
|
||||
**插件与 CSP(本次修复)**
|
||||
11. 设置 → 插件:无内置插件;市场能列 7 个;装一个 → 重启后可用
|
||||
12. **鲜艺抠图**:启用后对图片节点执行抠图 → **不应出现 `Failed to fetch`**(3.25.11 回归,3.25.14 已修)
|
||||
13. 若本机有 `XianyiAiRmbg` 监听 `0.0.0.0:30092` → 抠图出透明底;没装则注明跳过
|
||||
|
||||
```powershell
|
||||
Get-ChildItem src-tauri\target\release\bundle -Recurse -Include *.exe,*.msi | Select-Object FullName,Length
|
||||
```
|
||||
**外观(本次新增)**
|
||||
14. 设置 → 外观:改画布底色(亮/暗)与主题色 → 立即生效,重启保持
|
||||
15. 亮暗切换时画布底色分别用两套值
|
||||
|
||||
必须找到(名字里带版本号与 `x64`):
|
||||
任何一条失败:记录现象 + 截图后停止报告,**不要改代码**。
|
||||
|
||||
- `src-tauri\target\release\bundle\nsis\image-workbench_<版本>_x64-setup.exe` ← **主交付物**
|
||||
- `src-tauri\target\release\bundle\msi\image-workbench_<版本>_x64_en-US.msi` ← 有则附带,没有不算失败(WiX 可能被网络挡)
|
||||
|
||||
并计算哈希:
|
||||
|
||||
```powershell
|
||||
Get-FileHash "src-tauri\target\release\bundle\nsis\image-workbench_<版本>_x64-setup.exe" -Algorithm SHA256
|
||||
```
|
||||
|
||||
另外确认**插件没有被塞进包**:
|
||||
|
||||
```powershell
|
||||
Test-Path dist\plugins # 期望 False
|
||||
```
|
||||
|
||||
## 第六步:安装自测(必须做,逐条报告 通过/失败)
|
||||
|
||||
1. 运行 `*-setup.exe` 安装并启动
|
||||
2. 数据目录生成 `%USERPROFILE%\Documents\ImageWorkbench`,内含 `data.json`、`canvases`、`library`、`images`
|
||||
3. 设置 → 通用:「数据库目录」显示上述路径;点「打开」能弹出资源管理器
|
||||
4. 关闭窗口后进程仍在托盘;左键托盘图标能唤出窗口;右键有菜单
|
||||
5. 设置 → 插件:**没有任何内置插件**;「插件市场」能列出 7 个插件;任选一个安装 → 提示重启 → 重启后该插件可用
|
||||
6. 新建画布、拖拽/缩放节点正常;导入一张本地图片正常
|
||||
7. 点一次「下载」:文件直接落到导出目录,**不弹另存为对话框**
|
||||
|
||||
任何一条失败:记录现象 + 截图,然后停下来报告,不要尝试改代码。
|
||||
|
||||
## 第七步:交付
|
||||
|
||||
把下面信息整理成表格发我:
|
||||
|
||||
- 版本号
|
||||
- 安装包绝对路径、文件大小(MB)、SHA256
|
||||
- MSI 是否存在
|
||||
- 环境检查结论(node/rust/VS/WebView2)
|
||||
- 六步自测逐条结果
|
||||
- 构建总耗时
|
||||
|
||||
产物先**留在本机**,等我确认后再决定上传方式(scp 到 NAS `/vol8/web/iwb-download/updates/windows-x86_64/`,或我另行安排)。
|
||||
|
||||
## 停止条件(遇到即停,不要自行发挥)
|
||||
|
||||
- 环境缺件(VS Build Tools / WebView2 / MSVC 工具链)
|
||||
- lint 或构建报错且一次重试无效
|
||||
- 自测有任意一条失败
|
||||
- 需要修改业务代码才能继续
|
||||
|
||||
停止时请给出:**卡在哪一步、完整报错、你已经尝试过什么**。
|
||||
|
||||
## 最终回复格式
|
||||
## 第六步:交付格式
|
||||
|
||||
```
|
||||
结论:成功 / 失败(卡在第 N 步)
|
||||
版本:
|
||||
版本:3.25.15 commit=<sha>
|
||||
安装包:<路径> <大小> SHA256=<hex>
|
||||
自测:1✅ 2✅ 3✅ 4✅ 5✅ 6✅ 7✅(失败的写 ❌ + 现象)
|
||||
备注:
|
||||
环境:node= rust= VS= WebView2=
|
||||
自测:1✅ … 15✅(失败写 ❌ + 现象)
|
||||
耗时:
|
||||
```
|
||||
|
||||
产物留在本机;**不要**上传 NAS、**不要**写 `latest-windows.json`(我在 Mac 侧做)。
|
||||
|
||||
## 停止条件
|
||||
|
||||
commit 不对 / 环境缺件 / 构建报错一次重试无效 / 自测有失败 / 需要改业务代码 —— 遇到即停,
|
||||
报告「卡在哪一步 + 完整报错 + 已尝试过什么」。
|
||||
@@ -278,7 +278,7 @@ npm run deploy # 部署到正式站
|
||||
IWB_VERIFY_STRICT=1 node scripts/verify-release.js
|
||||
```
|
||||
|
||||
> ⚠️ `npm run deploy` = `verify` + `wrangler pages deploy`,**不含 git push**。
|
||||
> ⚠️ 本项目已转桌面客户端:**不再用 `wrangler pages deploy`**,发版走 `./scripts/publish-update.sh`(macOS)/ `./scripts/publish-windows-update.sh`(Windows)。
|
||||
> 回滚时**不要**把旧代码 push 到 main(会污染历史);用 `checkout` 部署即可,
|
||||
> 部署完 `git checkout main` 回到主干。
|
||||
|
||||
@@ -408,7 +408,7 @@ git checkout refactor-step-3
|
||||
git checkout stable-v3.24.5 && npm ci && npm run verify:ci && npm run deploy
|
||||
|
||||
# 层 4:看部署历史,用 dashboard 或 API 切回旧 deployment
|
||||
npx wrangler pages deployment list --project-name image-workbench-web
|
||||
# 桌面端没有「线上部署列表」:版本清单在 NAS 的 /vol8/web/iwb-download/updates/
|
||||
```
|
||||
|
||||
### 7.2 铁律
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
# 现状架构与性能事实基线(image-workbench-web)
|
||||
|
||||
> **本文档是什么**:现状**事实快照**,不是规范。用途:任何性能 / 内存 / 存储相关改动,先对齐这里的现实,避免把已经调好的东西改坏。
|
||||
> 日期 **2026-10-20**(**2026-11-16 复算 · v3.24.85**)| 基线(**最近一次 bump 版本的提交**,不是主干 HEAD)`main = 1ffe067`(线上 `v3.25.12+1ffe067` —— 线上实际运行提交是 docs 提交 `7df9dc4`,bump 提交为 `4be78c0`;2026-11-16 已发**测试站 + 正式站**,三地址一致 + `IWB_VERIFY_STRICT=1` 通过。v3.24.85 是「代码体检收口」(棘轮收回 Workbench 3090→2998 + 图库索引 4 条绕过锁的写路径收口到 `mutate` + 文档数字校准),`stable` / `stable-v3.24.85` / `stable-verified-2026-11-16` 均指向 `7df9dc4`。上一条 —— 2026-11-14 发**测试站 + 正式站** `https://test.image-workbench-web.pages.dev`:**v3.24.84 修「生图节点连了 3 条上游只出 1 个任务」**(任务 id 与去重基准改用新字段 `ownerNodeId`=本节点自己,不再用随继承冒泡的 `sourceNodeId` ⇒ 连几条线就几个任务;`relay` 仍归约到真实文本来源,同一来源多路径抵达只算一次)。上一条 v3.24.83:**修「插件节点冷启动退化成一段文本」**(插件节点体是异步注册的,`registerNodeType` 在 `render` 由无变有时自增 `NODE_TYPES_REV`,`NodeCard` 比它 ⇒ 注册那一刻重建一次;`canvas-normalize` 按命名规则把 `plugin:<id>:<variant>` 认作已知类型,不再降级成 `plugin` 并写回存档);配套插件 `style-source` 1.3.2 把节点体样式改为**脚本执行时注入**(此前只在面板 `mount()` 注入 ⇒ 从存档直接进画布时节点无样式、缩略图按原图铺满)。上一条 v3.24.82 同批:提示词/文本节点**显示上游继承文本**(自己 `data.text` 为空时把上游那段话显示在框里,改一个字即接管,另有「恢复跟随」清空回跟随;多路上游按 Y 轴取第一条)+ 修 `nodeRefsOf` 的 textout 分支只认 llm/batch/combine 上游导致「样式 → 文本 → 分层」丢参考图;再上一条 v3.24.81:① 插件节点可自定义节点体(`render(node, props, host)` 画真实 DOM,宿主不每帧重建 ⇒ 输入框不失焦);② 节点自带参考图(`data.refOn/refUrl` ⇒ 任务图里补伪参考图,坐标取节点自身 ⇒ 仍参与「图片按 X 轴排序」);③ 连线白名单按 `data.outKind === 'prompt'` 归一化,7 条规则一次放行,内置节点行为逐字不变。上一条 v3.24.80 = 离开页面的兜底保存不递增 rev(2026-11-14 07:20 补发 —— 首发 11-13 23:25 撞 Cloudflare Workers API 事故 `503 no healthy upstream`,期间正式站保持在 `v3.24.79+8598a57` 未动)。v3.24.83 的 bump 提交即 `0a27a42`(v3.24.82 为 `ef6cf42`、v3.24.81 为 `dba71e3`);主干 HEAD 会继续前进,见 [`RELEASES.md`](../RELEASES.md))| 历史分支 `refactor/architecture` / `feat/multi-canvas-tabs` / `refactor/state-store` 已于 2026-10-20 清理(内容均已并入 main,归档标签 `archive/*`),本文**计数类事实**已按 main HEAD 复算。
|
||||
> 日期 **2026-10-20**(**2026-11-16 复算 · v3.24.85**)| 基线(**最近一次 bump 版本的提交**,不是主干 HEAD)`main = 3eed42d`(线上 `v3.25.17+3eed42d` —— 线上实际运行提交是 docs 提交 `7df9dc4`,bump 提交为 `4be78c0`;2026-11-16 已发**测试站 + 正式站**,三地址一致 + `IWB_VERIFY_STRICT=1` 通过。v3.24.85 是「代码体检收口」(棘轮收回 Workbench 3090→2998 + 图库索引 4 条绕过锁的写路径收口到 `mutate` + 文档数字校准),`stable` / `stable-v3.24.85` / `stable-verified-2026-11-16` 均指向 `7df9dc4`。上一条 —— 2026-11-14 发**测试站 + 正式站** `https://test.image-workbench-web.pages.dev`:**v3.24.84 修「生图节点连了 3 条上游只出 1 个任务」**(任务 id 与去重基准改用新字段 `ownerNodeId`=本节点自己,不再用随继承冒泡的 `sourceNodeId` ⇒ 连几条线就几个任务;`relay` 仍归约到真实文本来源,同一来源多路径抵达只算一次)。上一条 v3.24.83:**修「插件节点冷启动退化成一段文本」**(插件节点体是异步注册的,`registerNodeType` 在 `render` 由无变有时自增 `NODE_TYPES_REV`,`NodeCard` 比它 ⇒ 注册那一刻重建一次;`canvas-normalize` 按命名规则把 `plugin:<id>:<variant>` 认作已知类型,不再降级成 `plugin` 并写回存档);配套插件 `style-source` 1.3.2 把节点体样式改为**脚本执行时注入**(此前只在面板 `mount()` 注入 ⇒ 从存档直接进画布时节点无样式、缩略图按原图铺满)。上一条 v3.24.82 同批:提示词/文本节点**显示上游继承文本**(自己 `data.text` 为空时把上游那段话显示在框里,改一个字即接管,另有「恢复跟随」清空回跟随;多路上游按 Y 轴取第一条)+ 修 `nodeRefsOf` 的 textout 分支只认 llm/batch/combine 上游导致「样式 → 文本 → 分层」丢参考图;再上一条 v3.24.81:① 插件节点可自定义节点体(`render(node, props, host)` 画真实 DOM,宿主不每帧重建 ⇒ 输入框不失焦);② 节点自带参考图(`data.refOn/refUrl` ⇒ 任务图里补伪参考图,坐标取节点自身 ⇒ 仍参与「图片按 X 轴排序」);③ 连线白名单按 `data.outKind === 'prompt'` 归一化,7 条规则一次放行,内置节点行为逐字不变。上一条 v3.24.80 = 离开页面的兜底保存不递增 rev(2026-11-14 07:20 补发 —— 首发 11-13 23:25 撞 Cloudflare Workers API 事故 `503 no healthy upstream`,期间正式站保持在 `v3.24.79+8598a57` 未动)。v3.24.83 的 bump 提交即 `0a27a42`(v3.24.82 为 `ef6cf42`、v3.24.81 为 `dba71e3`);主干 HEAD 会继续前进,见 [`RELEASES.md`](../RELEASES.md))| 历史分支 `refactor/architecture` / `feat/multi-canvas-tabs` / `refactor/state-store` 已于 2026-10-20 清理(内容均已并入 main,归档标签 `archive/*`),本文**计数类事实**已按 main HEAD 复算。
|
||||
<!-- 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 迁出)
|
||||
@@ -22,7 +22,7 @@
|
||||
- 图片**新写入主通道 = 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,508 行**(**双层预算**:绝对上限 8,700 / 占总源码 ≤ 40%,现 **36.8%**,2026-11-12 起;此前为单一上限 8,509、零余量);`Workbench()` = **2,998 行**(上限 **3,030**,余量 32;2026-11-16 把生成取消族 `cancelRunsFor`/`cancelRun`/`cancelTaskJobs` 与工作区列表写回族 `persistWs`/`duplicateWs` 搬进 `src/runtime-workbench-logic.js`(`createCancelActions` / `createWorkspaceListActions`),并删掉全仓零调用的 `runAll`,3090 → 2,998);大量逻辑已抽到 `src/*.js`(现 **86** 个模块 / 14,607 行,`sourceModules` 86 项;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,508 行**(**双层预算**:绝对上限 8,700 / 占总源码 ≤ 40%,现 **36.8%**,2026-11-12 起;此前为单一上限 8,509、零余量);`Workbench()` = **2,998 行**(上限 **3,030**,余量 32;2026-11-16 把生成取消族 `cancelRunsFor`/`cancelRun`/`cancelTaskJobs` 与工作区列表写回族 `persistWs`/`duplicateWs` 搬进 `src/runtime-workbench-logic.js`(`createCancelActions` / `createWorkspaceListActions`),并删掉全仓零调用的 `runAll`,3090 → 2,998);大量逻辑已抽到 `src/*.js`(现 **87** 个模块 / 14,607 行,`sourceModules` 87 项;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`。
|
||||
|
||||
## 2. 门禁与环境现状
|
||||
@@ -31,7 +31,7 @@
|
||||
|---|---|---|
|
||||
| 单测基线 | **658 通过 / 0 新增失败 / 2 已知环境差异**(2026-11-12 v3.24.76 实测;660 −2 = 94-5~7 三条钉点换成一条消费方契约) | (A) `npm test` 实测(`tests/iwb-v32-web-test.js`) |
|
||||
| e2e | spec 文件 **59** 个(**55** 个进门禁 + 4 个 dev 探针 `_perf-baseline` / `_plugin-host-probe` / `_probe-drag` / `_probe-tab-switch`) | (A) `tests/` 计数 + `scripts/list-e2e-specs.js` |
|
||||
| e2e 用例数 | **200 条**(2026-11-16 实测:55 个进门禁 spec 内 `test()` 总数)(历史:115 → v3.24.18 **143** → v3.24.19 **147** → v3.24.21 **151** → F2 改名 1 条 **152** → 抓手工具 2 条 **154** → v3.24.44 输出顺序 2 条 **166** → v3.24.47 同步去重 `iwb-sync-dedupe` 1 条 **167** → v3.24.67 **179** → v3.24.68 **183** → v3.24.69 **184** → v3.24.70 **186** → v3.24.74 **187**(新增「拖入 PDF 给提示 + MIME 空 PNG 仍能导入」)→ v3.24.75 **188**(新增「同一张图连粘两次只建一个节点」)→ v3.24.76 **191**(新增 `iwb-tabs-release` 3 条:回首页不降级 / 关标签先保存再关 / 彻底删除连带关标签)→ v3.24.77 **194**(新增 `iwb-lod` 3 条:fit 大画布必须全 LOD / 放大后必须恢复 / 常规画布不 LOD)→ v3.24.78 **196**(`iwb-lod` 3 → 5 条:新增「lite 档必须画出代表图/首行文字」与「缩到 15% 以下才退成 plain」)→ v3.24.82 **197**(新增 `iwb-inherit-text` 1 条:提示词/文本节点显示上游继承文本、改字接管、恢复跟随)→ v3.24.83 **198**(新增 `iwb-plugin-node-coldstart` 1 条:插件脚本晚到 1.2s,存档里的插件节点必须自动切回插件节点体,且类型不被降级成 `plugin`)→ v3.24.79 **196 不变**(测速修复的守门落在 jsdom 单测 `provider-ping-test.js`,e2e 无新增)→ v3.24.85 **200**(新增 `iwb-multi-tab` 2 条:A 页 flush 落盘后 B 页必须靠 rev 轮询看到改动;B 页持锁期间 A 页图库归档必须挂起);早期 99 → 115 的逐版链条见 `docs/history/coverage-baseline-2026-10-27.md`) | (A) `tests/*.spec.js` 计数 + `scripts/list-e2e-specs.js` |
|
||||
| e2e 用例数 | **200 条**(2026-11-16 实测:55 个进门禁 spec 内 `test()` 总数;v3.25.15 删除网页版部署面后为 **53** 个进门禁 —— `iwb-csp-gate` / `iwb-functions-headers` 随 `_headers`、`functions/` 一起移除)(历史:115 → v3.24.18 **143** → v3.24.19 **147** → v3.24.21 **151** → F2 改名 1 条 **152** → 抓手工具 2 条 **154** → v3.24.44 输出顺序 2 条 **166** → v3.24.47 同步去重 `iwb-sync-dedupe` 1 条 **167** → v3.24.67 **179** → v3.24.68 **183** → v3.24.69 **184** → v3.24.70 **186** → v3.24.74 **187**(新增「拖入 PDF 给提示 + MIME 空 PNG 仍能导入」)→ v3.24.75 **188**(新增「同一张图连粘两次只建一个节点」)→ v3.24.76 **191**(新增 `iwb-tabs-release` 3 条:回首页不降级 / 关标签先保存再关 / 彻底删除连带关标签)→ v3.24.77 **194**(新增 `iwb-lod` 3 条:fit 大画布必须全 LOD / 放大后必须恢复 / 常规画布不 LOD)→ v3.24.78 **196**(`iwb-lod` 3 → 5 条:新增「lite 档必须画出代表图/首行文字」与「缩到 15% 以下才退成 plain」)→ v3.24.82 **197**(新增 `iwb-inherit-text` 1 条:提示词/文本节点显示上游继承文本、改字接管、恢复跟随)→ v3.24.83 **198**(新增 `iwb-plugin-node-coldstart` 1 条:插件脚本晚到 1.2s,存档里的插件节点必须自动切回插件节点体,且类型不被降级成 `plugin`)→ v3.24.79 **196 不变**(测速修复的守门落在 jsdom 单测 `provider-ping-test.js`,e2e 无新增)→ v3.24.85 **200**(新增 `iwb-multi-tab` 2 条:A 页 flush 落盘后 B 页必须靠 rev 轮询看到改动;B 页持锁期间 A 页图库归档必须挂起);早期 99 → 115 的逐版链条见 `docs/history/coverage-baseline-2026-10-27.md`) | (A) `tests/*.spec.js` 计数 + `scripts/list-e2e-specs.js` |
|
||||
| CI | `.github/workflows/verify.yml`:**push(main) + PR(→main) + 手动** 触发,两个 job(`gate` = `verify:ci`;`e2e` = `test:e2e`),只验证不部署 | (A) |
|
||||
| 部署 | `npm run deploy` = `verify` + `wrangler pages deploy dist --branch main`;**内含全量 verify,不得绕过** | (A) `package.json:16` |
|
||||
| 部署环境 | 本机 wrangler 为 OAuth 登录 → **不能设 `CI=true`**(用 `unset CI` + `WRANGLER_SEND_METRICS=false`) | (A) 本轮发布实测 |
|
||||
@@ -167,7 +167,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` 不引用模块全局)。**86 个模块中 59 个导出**被 `app.js` 读取;其余为未接线 / 仅测试 / 零引用(见下)。
|
||||
- **判定法**:`global.X =` / `root.X =` 判「导出」;跨文件裸引用判「读」;排除自合并(`src/runtime-constants.js:9`)。`app.js` 是**唯一生产消费者**(无 HTML 入口;`sw.js` 不引用模块全局)。**87 个模块中 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` 自注册后读回(装载路径)。
|
||||
@@ -183,7 +183,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 耦合面(**74** 项)与 `sourceModules` 顺序(**86** 项);命名例外由第 5 组冻结,新增非 `IWB` 前缀导出即打红。
|
||||
- **耦合面已冻结**:`tests/architecture-boundary-guard-test.js`(进 `npm run test:unit` 末环)冻结 app.js↔src 耦合面(**74** 项)与 `sourceModules` 顺序(**87** 项);命名例外由第 5 组冻结,新增非 `IWB` 前缀导出即打红。
|
||||
|
||||
## 12. 易踩的坑
|
||||
|
||||
@@ -254,7 +254,7 @@
|
||||
|
||||
**信任模型(必须明示)**:形态 A 的插件是**可信代码**(与核心同权限、无沙箱);启停与设置是 UX 与可维护性手段,**不是安全边界**(同 §13.27 教训:前端开关一定可被绕过)。
|
||||
|
||||
**守门与快照**:`tests/architecture-boundary-guard-test.js` 冻结「app.js ↔ src 耦合面」(**74** 项)与 `sourceModules` 顺序(**86** 项);新增模块、新增耦合、新增 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 耦合面」(**74** 项)与 `sourceModules` 顺序(**87** 项);新增模块、新增耦合、新增 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 规则三的同一失败模式)。
|
||||
|
||||
@@ -270,6 +270,10 @@
|
||||
**CSP 最小放宽(2026-10-17,为本地服务插件)**:`_headers` 的 `connect-src` 由 `'self' https:` 扩为 `'self' https: http://127.0.0.1:30092 http://localhost:30092`。
|
||||
- **动机**:页面内插件(非浏览器扩展)受页面 CSP 约束;调用本机服务必须放行 loopback。**只放行这一个固定端口**,不放宽到任意 `http:`、不放开脚本域、不引入 `unsafe-eval`。
|
||||
- **边界**:插件若把服务地址改到别的 host/端口会被 CSP 拦(属预期)。页面因此可以向本机 30092 发请求 —— 这是**有意的安全边界调整**,与"插件是可信代码"的模型一致。
|
||||
- **桌面客户端 CSP 的唯一定义处是 `src-tauri/tauri.conf.json` 的 `app.security.csp`**(v3.25.14 补记)。
|
||||
本项目是桌面客户端,`_headers` 属于旧的网页部署、不参与桌面行为,**两者不做一致性约束**。
|
||||
v3.25.11 的「CSP 清理」误判 30092 为遗留端口删掉 ⇒ 桌面版鲜艺抠图插件 `Failed to fetch`。
|
||||
现由 `tests/desktop-csp-loopback-test.js` 钉住(只断言桌面 CSP 的运行时值,避免源码钉点棘轮)。
|
||||
|
||||
**鲜艺抠图插件(2026-10-17 起改为 A2 运行时插件,`dist` 不再内置)**:源码已迁出主仓到独立插件仓(`iwb-plugins`),经 Cloudflare Function `functions/plugins/[[path]].js` + KV(binding `PLUGINS`)**同源运行时加载**(同源 ⇒ CSP 零改动);主包**已不含** `src/plugin-xianyi-cutout.js`。功能:右键命令「抠图:选中节点」→ `POST {apiUrl}/rmbg?crop=`(`application/octet-stream` + 原始字节)→ 结果 PNG 写回为新的参考图节点(`<原名>_cutout.png`)。契约对齐 `iwb-plaus` v3.1.3 的 `background.js`(二进制进 / PNG 字节出;无 token、无 JSON),但**补齐了原版缺失的超时**(`AbortController` + 可配 `timeoutMs`)。设置项:`apiUrl` / `crop` / `timeoutMs`。尚未提供的能力面(若日后需要):插件只读「选中节点」与按 id 取节点图(`canvas` 目前只有 `getNodes` / `listNodeTypes`)。
|
||||
|
||||
|
||||
@@ -1,108 +0,0 @@
|
||||
// Cloudflare Pages Function:**第一方**图片代理(同源 /api/img)。
|
||||
// 目的:豆包(火山 TOS)等图床**不返回 CORS 头**,浏览器无法 fetch ⇒ 下载、缩略图归档、
|
||||
// 本地原图备份全部拿不到字节。经本站代理转发后由本站给出 CORS 头,前端即可正常读取。
|
||||
// 用法:GET /api/img?url=<encodeURIComponent(https 图片地址)>
|
||||
//
|
||||
// 安全边界(H2 加固):
|
||||
// - 仅接受**同源**调用:若请求带 Origin 头,其 host 必须与本站一致。
|
||||
// - 仅 https、仅允许常见图片/对象存储域名(避免成为开放代理/SSRF),仅透传 image/* 响应。
|
||||
// - **手动跟随重定向**:每一跳都对目标 host 重新做白名单校验(原实现 redirect:'follow' 只校验初始
|
||||
// host,可被 302 逃逸到任意主机),并限制跳数。
|
||||
// - **响应大小上限**:先看 content-length,超限即拒;无 content-length 时按流裁剪(防超大响应耗尽配额)。
|
||||
// - 不再返回 Access-Control-Allow-Origin: *(同源调用本就不需要 CORS)。
|
||||
export function onRequest(context) {
|
||||
return handle(context.request)
|
||||
}
|
||||
|
||||
const ALLOW_HOSTS = [
|
||||
/(^|\.)volces\.com$/i, // 火山引擎 / TOS(豆包 Seedream 图床)
|
||||
/(^|\.)aliyuncs\.com$/i, // 阿里云 OSS(tuzi 文档示例图床)
|
||||
/(^|\.)myqcloud\.com$/i, // 腾讯云 COS
|
||||
/(^|\.)qiniucdn\.com$/i,
|
||||
/(^|\.)cloudfront\.net$/i,
|
||||
/(^|\.)googleusercontent\.com$/i,
|
||||
/(^|\.)openai\.org$/i,
|
||||
/(^|\.)oaistatic\.com$/i,
|
||||
/(^|\.)blob\.core\.windows\.net$/i,
|
||||
]
|
||||
const MAX_BYTES = 25 * 1024 * 1024 // 单张图片上限 25MB(生成图远小于此;防超大响应)
|
||||
const MAX_REDIRECTS = 3
|
||||
|
||||
// 安全头(2026-10-20 加,H1):Cloudflare Pages 的 `_headers` **不作用于 Functions 响应**
|
||||
// (https://developers.cloudflare.com/pages/configuration/headers/)⇒ 静态资源有 CSP/nosniff,
|
||||
// 而本函数(及 plugins 函数)原本**一个安全头都没有**。这不是可利用漏洞(每个响应都显式
|
||||
// 设了 Content-Type),但属于纵深防御缺口:将来若有端点返回用户影响的内容且漏设 Content-Type,
|
||||
// 浏览器会自行嗅探类型 ⇒ 可能演变成 XSS。故在**每个** Response 显式补齐 nosniff + Referrer-Policy。
|
||||
const SECURITY_HEADERS = {
|
||||
'X-Content-Type-Options': 'nosniff',
|
||||
'Referrer-Policy': 'no-referrer',
|
||||
}
|
||||
|
||||
function hdr() {
|
||||
return Object.assign({ 'Content-Type': 'text/plain; charset=utf-8' }, SECURITY_HEADERS)
|
||||
}
|
||||
function plain(msg, status) {
|
||||
return new Response(msg, { status, headers: hdr() })
|
||||
}
|
||||
function sameOrigin(request) {
|
||||
const origin = request.headers.get('Origin')
|
||||
if (!origin || origin === 'null') return true
|
||||
try { return new URL(origin).host === new URL(request.url).host } catch (e) { return false }
|
||||
}
|
||||
function hostAllowed(u) {
|
||||
return ALLOW_HOSTS.some((re) => re.test(u.hostname))
|
||||
}
|
||||
function capStream(stream, max) {
|
||||
let seen = 0
|
||||
return stream.pipeThrough(new TransformStream({
|
||||
transform(chunk, controller) {
|
||||
seen += chunk && chunk.byteLength ? chunk.byteLength : 0
|
||||
if (seen > max) { controller.error(new Error('response too large')); return }
|
||||
controller.enqueue(chunk)
|
||||
},
|
||||
}))
|
||||
}
|
||||
|
||||
async function handle(request) {
|
||||
if (request.method === 'OPTIONS') return new Response(null, { status: 204, headers: hdr() })
|
||||
if (request.method !== 'GET') return plain('仅支持 GET', 405)
|
||||
if (!sameOrigin(request)) return plain('仅允许同源调用', 403)
|
||||
let target
|
||||
try {
|
||||
const raw = String(new URL(request.url).searchParams.get('url') || '')
|
||||
target = new URL(raw)
|
||||
} catch (e) { return plain('缺少或非法的 url 参数', 400) }
|
||||
if (target.protocol !== 'https:') return plain('仅支持 https 图片地址', 400)
|
||||
if (!hostAllowed(target)) return plain('该图床未在允许列表中:' + target.hostname, 403)
|
||||
try {
|
||||
// 手动跟随重定向:每一跳都对 host 重新校验,逃逸即拒。
|
||||
let upstream = null
|
||||
for (let hop = 0; hop <= MAX_REDIRECTS; hop++) {
|
||||
upstream = await fetch(target.toString(), { headers: { Accept: 'image/*' }, redirect: 'manual' })
|
||||
const status = upstream.status
|
||||
const isRedirect = status >= 300 && status < 400
|
||||
if (!isRedirect) break
|
||||
const location = upstream.headers.get('Location')
|
||||
if (!location) return plain('上游重定向缺少 Location', 502)
|
||||
if (hop === MAX_REDIRECTS) return plain('重定向次数过多', 508)
|
||||
let next
|
||||
try { next = new URL(location, target) } catch (e) { return plain('上游重定向地址非法', 502) }
|
||||
if (next.protocol !== 'https:') return plain('重定向目标非 https', 403)
|
||||
if (!hostAllowed(next)) return plain('重定向目标未在允许列表中:' + next.hostname, 403)
|
||||
target = next
|
||||
}
|
||||
if (!upstream || !upstream.ok) return plain('上游返回 ' + (upstream ? upstream.status : '0'), 502)
|
||||
const ct = String(upstream.headers.get('content-type') || '')
|
||||
if (ct && ct.toLowerCase().indexOf('image/') !== 0) return plain('上游不是图片(' + ct + ')', 415)
|
||||
const len = Number(upstream.headers.get('content-length'))
|
||||
if (Number.isFinite(len) && len > MAX_BYTES) return plain('图片过大(超过 ' + MAX_BYTES + ' 字节)', 413)
|
||||
const headers = new Headers()
|
||||
headers.set('Content-Type', ct || 'image/png')
|
||||
headers.set('Cache-Control', 'private, max-age=600')
|
||||
for (const [k, v] of Object.entries(SECURITY_HEADERS)) headers.set(k, v)
|
||||
const body = upstream.body && !(Number.isFinite(len) && len <= MAX_BYTES) ? capStream(upstream.body, MAX_BYTES) : upstream.body
|
||||
return new Response(body, { status: 200, headers })
|
||||
} catch (e) {
|
||||
return plain('代理失败:' + ((e && e.message) || 'unknown'), 502)
|
||||
}
|
||||
}
|
||||
@@ -1,74 +0,0 @@
|
||||
// /plugins/* → 从 KV(binding: PLUGINS)以**同源**方式提供插件文件。
|
||||
// 同源脚本本就被页面 CSP(script-src 'self')允许 ⇒ 无需放宽 CSP、无需 unsafe-eval、无需重新部署 app.js。
|
||||
// KV 键约定:plugins/index.json(清单)+ plugins/<file>(每个插件一个文件)。
|
||||
//
|
||||
// 缓存策略(按 basename 分流):
|
||||
// - plugin-<id>.<hash12>.js(内容寻址,发布脚本生成)→ public, max-age=31536000, immutable(字节永不变 ⇒ 可永久缓存)
|
||||
// - 其他 .js(历史遗留未哈希文件)→ no-cache + ETag(安全网:绝不许被永久缓存)
|
||||
// - .json(清单)→ no-cache + ETag;if-none-match 命中 → 304 空 body
|
||||
// - 其他扩展名 / 404 / 500 → no-store
|
||||
// ETag 为 (value, basename) 的确定性纯函数:FNV-1a 32bit(同步、廉价),hex 后加双引号。
|
||||
|
||||
const JS_CT = 'application/javascript; charset=utf-8'
|
||||
const JSON_CT = 'application/json; charset=utf-8'
|
||||
|
||||
// 安全头(2026-10-20 加,H1):Cloudflare Pages 的 `_headers` **不作用于 Functions 响应**
|
||||
// (https://developers.cloudflare.com/pages/configuration/headers/)⇒ 静态资源有 CSP/nosniff,
|
||||
// 而本函数原本**一个安全头都没有**。插件字节虽同源且有 SRI 校验,但缺 nosniff 意味着
|
||||
// 万一将来 KV 里的内容类型异常,浏览器可能自行嗅探 ⇒ 补齐纵深防御。
|
||||
const SECURITY_HEADERS = { 'x-content-type-options': 'nosniff', 'referrer-policy': 'no-referrer' }
|
||||
|
||||
const ERROR_HEADERS = Object.assign({ 'content-type': JSON_CT, 'cache-control': 'no-store' }, SECURITY_HEADERS)
|
||||
const NO_STORE_HEADERS = Object.assign({ 'content-type': JS_CT, 'cache-control': 'no-store' }, SECURITY_HEADERS)
|
||||
|
||||
const IMMUTABLE_JS_RE = /^plugin-[a-z0-9-]+\.[0-9a-f]{12}\.js$/
|
||||
|
||||
// FNV-1a 32-bit(对 UTF-16 code unit 序列):同步、确定、够用于 ETag 指纹
|
||||
const fnv1a32 = (s) => {
|
||||
let h = 0x811c9dc5
|
||||
for (let i = 0; i < s.length; i++) {
|
||||
h ^= s.charCodeAt(i)
|
||||
h = Math.imul(h, 0x01000193)
|
||||
}
|
||||
return (h >>> 0).toString(16).padStart(8, '0')
|
||||
}
|
||||
|
||||
const etagOf = (value, base) => '"' + fnv1a32(base + '\n' + value) + '"'
|
||||
|
||||
export async function onRequestGet(context) {
|
||||
const { params, env } = context
|
||||
const parts = Array.isArray(params.path) ? params.path : [params.path].filter(Boolean)
|
||||
const tail = parts.join('/') || 'index.json'
|
||||
const key = 'plugins/' + tail
|
||||
const base = tail.slice(tail.lastIndexOf('/') + 1)
|
||||
|
||||
if (!env || !env.PLUGINS) {
|
||||
return new Response(JSON.stringify({ error: 'PLUGINS KV 未绑定' }), { status: 500, headers: ERROR_HEADERS })
|
||||
}
|
||||
|
||||
const value = await env.PLUGINS.get(key)
|
||||
if (value === null) return new Response('not found', { status: 404, headers: Object.assign({ 'cache-control': 'no-store' }, SECURITY_HEADERS) })
|
||||
|
||||
// A) 内容寻址的插件 JS:内容变 ⇒ 文件名变 ⇒ 可 immutable 永久缓存
|
||||
if (IMMUTABLE_JS_RE.test(base)) {
|
||||
return new Response(value, {
|
||||
headers: Object.assign({ 'content-type': JS_CT, 'cache-control': 'public, max-age=31536000, immutable' }, SECURITY_HEADERS),
|
||||
})
|
||||
}
|
||||
|
||||
// B) 未哈希 .js 与 .json(清单):no-cache + ETag,每次回源校验,命中即 304
|
||||
if (base.endsWith('.js') || base.endsWith('.json')) {
|
||||
const etag = etagOf(value, base)
|
||||
const headers = Object.assign({
|
||||
'content-type': base.endsWith('.json') ? JSON_CT : JS_CT,
|
||||
'cache-control': 'no-cache',
|
||||
etag,
|
||||
}, SECURITY_HEADERS)
|
||||
const inm = context.request && context.request.headers && context.request.headers.get('if-none-match')
|
||||
if (inm === etag) return new Response(null, { status: 304, headers })
|
||||
return new Response(value, { headers })
|
||||
}
|
||||
|
||||
// 其他扩展名:保持 no-store
|
||||
return new Response(value, { headers: NO_STORE_HEADERS })
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "image-workbench-web",
|
||||
"private": true,
|
||||
"version": "3.25.13",
|
||||
"version": "3.25.17",
|
||||
"description": "Browser-based node canvas image workbench",
|
||||
"scripts": {
|
||||
"build": "node scripts/build.js && node scripts/copy-plugins.js",
|
||||
@@ -9,8 +9,8 @@
|
||||
"app:dev": "tauri dev",
|
||||
"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 && node tests/iwb-v32-web-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/architecture-boundary-guard-test.js && node tests/plugin-host-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/functions-api-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": "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/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",
|
||||
@@ -20,8 +20,6 @@
|
||||
"test:e2e:local": "node scripts/serve-test.js",
|
||||
"verify:ci": "npm run build && node --check app.js && node --check dist/app.js && node scripts/check-dist.js && npm run lint && npm run typecheck && npm run test:unit && npm test && npm run test:facts",
|
||||
"verify": "npm run verify:ci && npm run test:e2e",
|
||||
"deploy": "npm run verify && npx --yes wrangler@4 pages deploy dist --project-name image-workbench-web --branch main",
|
||||
"deploy:test": "npm run verify && npx --yes wrangler@4 pages deploy dist --project-name image-workbench-web --branch test",
|
||||
"verify:release": "node scripts/verify-release.js",
|
||||
"coverage:e2e": "node scripts/coverage-e2e.js",
|
||||
"sync:facts": "node scripts/sync-facts.js",
|
||||
|
||||
@@ -90,6 +90,7 @@ const sourceModules = [
|
||||
'ui-groups-sidebar.js',
|
||||
'ui-lib-sidebar.js',
|
||||
'ui-desktop-shell.js',
|
||||
'ui-appearance.js',
|
||||
'ui-workspace-tabs.js',
|
||||
'ui-app-chrome.js',
|
||||
'ui-workbench-hooks.js',
|
||||
@@ -169,7 +170,6 @@ const minifiedCss = transformSync(fs.readFileSync(path.join(root, 'style.css'),
|
||||
fs.writeFileSync(path.join(dist, 'style.css'), minifiedCss)
|
||||
|
||||
fs.copyFileSync(path.join(root, 'favicon.svg'), path.join(dist, 'favicon.svg'))
|
||||
fs.copyFileSync(path.join(root, '_headers'), path.join(dist, '_headers'))
|
||||
// PWA(2026-11-07):可安装 —— manifest + 图标(iOS 额外要 apple-touch-icon 的 PNG)
|
||||
for (const f of ['manifest.webmanifest', 'icon-192.png', 'icon-512.png', 'apple-touch-icon.png']) {
|
||||
fs.copyFileSync(path.join(root, f), path.join(dist, f))
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#!/usr/bin/env bash
|
||||
# 发布 Windows 更新:对 Windows 侧构建好的 *-setup.exe 重新签名(用本机正式私钥),
|
||||
# 上传到 NAS,并把 windows-x86_64 条目合并进 updates/latest.json。
|
||||
# 上传到 NAS,并写入 **独立** 的 updates/latest-windows.json(v3.25.15 起平台解耦:
|
||||
# mac 的 latest.json 与 Windows 的 latest-windows.json 互不影响)。
|
||||
#
|
||||
# 用法:./scripts/publish-windows-update.sh "/path/to/image-workbench_3.25.3_x64-setup.exe"
|
||||
#
|
||||
@@ -38,27 +39,25 @@ echo "== 3/4 上传到 NAS"
|
||||
ssh -i "$SSH_KEY" -o BatchMode=yes "$NAS_HOST" "mkdir -p $NAS_DIR/updates/windows-x86_64"
|
||||
$SCP "$OUT" "$SIG_FILE" "$NAS_HOST:$NAS_DIR/updates/windows-x86_64/"
|
||||
|
||||
echo "== 4/4 合并 latest.json"
|
||||
echo "== 4/4 写 latest-windows.json(平台独立)"
|
||||
SIG=$(cat "$SIG_FILE")
|
||||
URL="https://download.maqiart.eu.org/updates/windows-x86_64/image-workbench_${V}_x64-setup.exe"
|
||||
export SIG URL APP_VERSION="$V"
|
||||
curl -s -m 20 https://download.maqiart.eu.org/updates/latest.json -o "$WORK/latest.json" || echo '{}' > "$WORK/latest.json"
|
||||
node -e '
|
||||
const fs = require("fs")
|
||||
const p = process.argv[1]
|
||||
let cur = {}
|
||||
try { cur = JSON.parse(fs.readFileSync(p, "utf8")) } catch (e) { cur = {} }
|
||||
cur.version = process.env.APP_VERSION
|
||||
cur.notes = cur.notes || "在线更新"
|
||||
cur.pub_date = new Date().toISOString()
|
||||
cur.platforms = cur.platforms || {}
|
||||
cur.platforms["windows-x86_64"] = { signature: process.env.SIG, url: process.env.URL }
|
||||
fs.writeFileSync(p, JSON.stringify(cur, null, 2))
|
||||
console.log(" platforms:", Object.keys(cur.platforms).join(", "))
|
||||
' "$WORK/latest.json"
|
||||
$SCP "$WORK/latest.json" "$NAS_HOST:$NAS_DIR/updates/latest.json"
|
||||
const doc = {
|
||||
version: process.env.APP_VERSION,
|
||||
notes: process.env.NOTES || "在线更新",
|
||||
pub_date: new Date().toISOString(),
|
||||
platforms: { "windows-x86_64": { signature: process.env.SIG, url: process.env.URL } },
|
||||
}
|
||||
fs.writeFileSync(p, JSON.stringify(doc, null, 2))
|
||||
console.log(" version", doc.version)
|
||||
' "$WORK/latest-windows.json"
|
||||
$SCP "$WORK/latest-windows.json" "$NAS_HOST:$NAS_DIR/updates/latest-windows.json"
|
||||
ssh -i "$SSH_KEY" -o BatchMode=yes "$NAS_HOST" "chmod -R a+rX $NAS_DIR"
|
||||
|
||||
echo "== 完成"
|
||||
curl -s -m 20 https://download.maqiart.eu.org/updates/latest.json | node -e 'let s="";process.stdin.on("data",d=>s+=d).on("end",()=>{const j=JSON.parse(s);console.log("version",j.version);for(const k of Object.keys(j.platforms))console.log(" -",k,"sig",(j.platforms[k].signature||"").length,"bytes")})'
|
||||
curl -s -m 20 https://download.maqiart.eu.org/updates/latest-windows.json | node -e 'let s="";process.stdin.on("data",d=>s+=d).on("end",()=>{const j=JSON.parse(s);console.log("version",j.version);for(const k of Object.keys(j.platforms))console.log(" -",k,"sig",(j.platforms[k].signature||"").length,"bytes")})'
|
||||
curl -s -o /dev/null -m 60 -w "exe:%{http_code} size:%{size_download}\n" "$URL"
|
||||
@@ -1,238 +1,65 @@
|
||||
/* serve-test.js —— e2e 用的本地静态服务器(v3.25.15 起脱离网页部署)
|
||||
*
|
||||
* 历史:本项目早期同时发布网页版(Cloudflare Pages),这个脚本会解析 `_headers` 下发 CSP、
|
||||
* 并模拟 Pages Functions(/api/img、/plugins/*)。**现在是桌面客户端项目**,那些部署面已删除,
|
||||
* 因此这里只保留「能跑 e2e」的最小职责:把 dist/ 当静态目录伺服。
|
||||
*
|
||||
* 桌面端的 CSP 由 src-tauri/tauri.conf.json 决定,e2e 不模拟 webview 的 CSP(要验就装真包)。
|
||||
* 用法:node scripts/serve-test.js(IWB_LOCAL_PORT 可改端口,默认 8787)
|
||||
*/
|
||||
'use strict'
|
||||
|
||||
const http = require('http')
|
||||
const fs = require('fs')
|
||||
const path = require('path')
|
||||
const cp = require('child_process')
|
||||
const http = require('node:http')
|
||||
const fs = require('node:fs')
|
||||
const path = require('node:path')
|
||||
|
||||
const root = path.resolve(__dirname, '..')
|
||||
const dist = path.join(root, 'dist')
|
||||
const port = Number(process.env.IWB_LOCAL_PORT || 8787)
|
||||
const mime = { '.html': 'text/html; charset=utf-8', '.js': 'text/javascript; charset=utf-8', '.css': 'text/css; charset=utf-8', '.json': 'application/json; charset=utf-8', '.png': 'image/png', '.svg': 'image/svg+xml' }
|
||||
|
||||
// ---------- _headers → 响应头(本地 e2e 与 Cloudflare Pages 保持一致) ----------
|
||||
// 动机:线上 CSP 是 connect-src 'self' https:,会拦掉 fetch(data:...) / CDN <script> / blob: Worker。
|
||||
// 本地服务器原先不解析 _headers,这类「本地过、线上挂」的缺陷永远抓不到。这里把 _headers 的
|
||||
// 路径分组按 Cloudflare Pages 语义应用到响应头(/* 组作用于所有响应,其它组按前缀/通配匹配)。
|
||||
// 健壮性:_headers 缺失或解析不出任何分组时**不注入**并打印一行提示,绝不让服务器启动失败。
|
||||
function parseHeaderGroups(text) {
|
||||
const groups = []
|
||||
let current = null
|
||||
for (const raw of String(text == null ? '' : text).split(/\r?\n/)) {
|
||||
const line = raw.replace(/\s+$/, '')
|
||||
if (!line.trim() || /^\s*#/.test(line)) continue
|
||||
if (/^\s/.test(line)) {
|
||||
if (!current) continue // 缩进行但没有归属路径 → 忽略
|
||||
const i = line.indexOf(':')
|
||||
if (i <= 0) continue
|
||||
const name = line.slice(0, i).trim()
|
||||
const value = line.slice(i + 1).trim().replace(/[\r\n]+/g, ' ') // 防响应头注入
|
||||
if (name) current.headers.push([name, value])
|
||||
continue
|
||||
}
|
||||
current = { path: line.trim(), headers: [] }
|
||||
groups.push(current)
|
||||
}
|
||||
return groups
|
||||
}
|
||||
|
||||
// Cloudflare Pages 匹配规则(够用即可):/* 与 * 全局;/a/* 前缀;其余精确匹配。
|
||||
function headerGroupMatches(pattern, pathname) {
|
||||
const p = String(pattern || '').trim()
|
||||
if (!p || p === '*' || p === '/*') return true
|
||||
if (p.endsWith('*')) return pathname.indexOf(p.slice(0, -1)) === 0
|
||||
return p === pathname
|
||||
}
|
||||
|
||||
function loadHeaderGroups() {
|
||||
const candidates = [path.join(root, '_headers'), path.join(dist, '_headers')]
|
||||
for (const file of candidates) {
|
||||
try {
|
||||
if (!fs.existsSync(file)) continue
|
||||
const groups = parseHeaderGroups(fs.readFileSync(file, 'utf8')).filter((g) => g.headers.length)
|
||||
if (groups.length) return { groups, file }
|
||||
} catch (e) { /* 换下一个候选 */ }
|
||||
}
|
||||
return null
|
||||
}
|
||||
|
||||
const loaded = loadHeaderGroups()
|
||||
const headerGroups = loaded ? loaded.groups : []
|
||||
const cspApplied = headerGroups.some((g) => g.headers.some(([n]) => n.toLowerCase() === 'content-security-policy'))
|
||||
if (loaded) {
|
||||
console.log(`[serve-test] 已从 ${path.relative(root, loaded.file) || '_headers'} 注入响应头分组 ${headerGroups.length} 个${cspApplied ? '(含 Content-Security-Policy,本地与线上 CSP 一致)' : '(未解析到 CSP)'}`)
|
||||
} else {
|
||||
console.log('[serve-test] 未找到/无法解析 _headers:本次不注入任何安全响应头(本地环境与线上不一致,CSP 类缺陷不会被拦住)')
|
||||
}
|
||||
|
||||
function securityHeadersFor(pathname, base) {
|
||||
const out = Object.assign({}, base)
|
||||
for (const group of headerGroups) {
|
||||
if (!headerGroupMatches(group.path, pathname)) continue
|
||||
for (const [name, value] of group.headers) out[name] = value // 后匹配的覆盖先匹配的(与 Pages 的后者优先一致)
|
||||
}
|
||||
return out
|
||||
}
|
||||
|
||||
// ---------- Pages Functions 本地模拟(2026-10-20 加,审计 H1 的护栏) ----------
|
||||
//
|
||||
// 动机:Cloudflare Pages 的 `_headers` **不作用于 Functions 响应**
|
||||
// (https://developers.cloudflare.com/pages/configuration/headers/)—— 静态资源有 CSP/nosniff,
|
||||
// 而 `/api/*` 与 `/plugins/*`(Pages Functions)**一个安全头都没有**,此前线上与本地都测不到。
|
||||
// 本文件原先只服务 dist/ 静态资源 ⇒ 「本地过、线上挂」这一类缺陷**无法被 e2e 发现**。
|
||||
//
|
||||
// 忠实度原则(重要):Function 响应**只带 Function 自己返回的 header**,
|
||||
// **绝不叠加 `_headers`** —— 线上就是这样,本地若"好心"加上 CSP 就永远测不出真实差异。
|
||||
// 测试 tests/iwb-functions-headers.spec.js 用反向断言把这一点钉死。
|
||||
//
|
||||
// 模拟范围刻意最小:只做「Cloudflare context 形状」+「Response → Node 响应」两件事,
|
||||
// 不模拟 Pages 的路由匹配、缓存、边缘网络等 —— 那些不属于本项目能控的范围。
|
||||
const FUNCTION_ROUTES = [
|
||||
{ prefix: '/api/img', file: 'functions/api/img.js', entry: 'onRequest' },
|
||||
{ prefix: '/plugins', file: 'functions/plugins/[[path]].js', entry: 'onRequestGet' },
|
||||
]
|
||||
|
||||
// 上游 mock(默认开):/api/img 会真的去请求外部图床(豆包/阿里云…),
|
||||
// 那会让 e2e 变慢且依赖外部可达性 ⇒ 默认把上游 fetch 换成本地假图片。
|
||||
// 关闭:IWB_MOCK_UPSTREAM=0(需要真连上游时用)。
|
||||
const MOCK_UPSTREAM = process.env.IWB_MOCK_UPSTREAM !== '0'
|
||||
// 插件 KV 的本地替身:内存 Map,内容寻址的插件文件用可预测的假字节。
|
||||
const MOCK_PLUGIN_BYTES = '/* mock plugin */\n'
|
||||
|
||||
function mockKv() {
|
||||
const store = new Map([
|
||||
['plugins/index.json', JSON.stringify([{ id: 'mock-plugin', file: 'plugin-mock-plugin.0123456789ab.js', version: '1.0.0', integrity: 'sha256-AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=' }])],
|
||||
['plugins/plugin-mock-plugin.0123456789ab.js', MOCK_PLUGIN_BYTES],
|
||||
])
|
||||
return { get: async (key) => (store.has(key) ? store.get(key) : null) }
|
||||
}
|
||||
|
||||
async function readRequestBody(req) {
|
||||
if (req.method === 'GET' || req.method === 'HEAD') return undefined
|
||||
const chunks = []
|
||||
for await (const c of req) chunks.push(c)
|
||||
return Buffer.concat(chunks)
|
||||
}
|
||||
|
||||
const functionModules = new Map()
|
||||
async function loadFunctionModule(file) {
|
||||
if (functionModules.has(file)) return functionModules.get(file)
|
||||
const mod = await import(path.join(root, file))
|
||||
functionModules.set(file, mod)
|
||||
return mod
|
||||
}
|
||||
|
||||
// Function 响应 → Node 响应:**只透传 Function 自己的 header**(不叠加 _headers,见上方忠实度原则)
|
||||
async function sendFunctionResponse(res, fnRes) {
|
||||
const headers = {}
|
||||
for (const [name, value] of fnRes.headers.entries()) headers[name] = value
|
||||
const body = fnRes.status === 204 || fnRes.status === 304 ? Buffer.alloc(0) : Buffer.from(await fnRes.arrayBuffer())
|
||||
res.writeHead(fnRes.status, headers)
|
||||
res.end(body)
|
||||
}
|
||||
|
||||
async function handleFunction(req, res, pathname) {
|
||||
const route = FUNCTION_ROUTES.find((r) => pathname === r.prefix || pathname.indexOf(r.prefix + '/') === 0)
|
||||
if (!route) return false
|
||||
try {
|
||||
const mod = await loadFunctionModule(route.file)
|
||||
const fn = mod[route.entry]
|
||||
if (typeof fn !== 'function') throw new Error('入口未导出: ' + route.entry)
|
||||
|
||||
// 构造 Request(POST 需要 body)
|
||||
const url = new URL(req.url, 'http://127.0.0.1')
|
||||
const body = await readRequestBody(req)
|
||||
const request = new Request(url.toString(), {
|
||||
method: req.method,
|
||||
headers: Object.entries(req.headers).reduce((acc, [k, v]) => { if (typeof v === 'string') acc[k] = v; return acc }, {}),
|
||||
body: body && body.length ? body : undefined,
|
||||
})
|
||||
const ctx = {
|
||||
params: { path: pathname.slice(route.prefix.length).split('/').filter(Boolean) },
|
||||
env: { PLUGINS: mockKv() },
|
||||
request,
|
||||
}
|
||||
// 上游 mock:把 Function 内部的 fetch 换成本地假响应(仅 /api/img 会用到)
|
||||
const fnRes = await withMockedUpstream(async () => {
|
||||
return await fn(ctx)
|
||||
})
|
||||
await sendFunctionResponse(res, fnRes)
|
||||
} catch (e) {
|
||||
res.writeHead(500, { 'content-type': 'text/plain; charset=utf-8' })
|
||||
res.end('function error: ' + String((e && e.message) || e))
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
// 上游 mock 实现:把 fetch 指向白名单图床的请求替换为一张 1x1 PNG。
|
||||
// 仅在 MOCK_UPSTREAM 开启时生效;不影响真实部署(线上跑的是 Cloudflare Functions)。
|
||||
async function withMockedUpstream(fn) {
|
||||
if (!MOCK_UPSTREAM) return fn()
|
||||
const realFetch = globalThis.fetch
|
||||
const PNG = Buffer.from('iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mP8z8BQDwAEhQGAhKmMIQAAAABJRU5ErkJggg==', 'base64')
|
||||
globalThis.fetch = async (input, init) => {
|
||||
const u = String(typeof input === 'string' ? input : (input && input.url) || input)
|
||||
// 非上游请求(如本地自取)放行
|
||||
if (!/^https?:\/\//i.test(u)) return realFetch(input, init)
|
||||
return new Response(PNG, { status: 200, headers: { 'Content-Type': 'image/png', 'Content-Length': String(PNG.length) } })
|
||||
}
|
||||
try {
|
||||
return await fn()
|
||||
} finally {
|
||||
globalThis.fetch = realFetch
|
||||
}
|
||||
const mime = {
|
||||
'.html': 'text/html; charset=utf-8',
|
||||
'.js': 'text/javascript; charset=utf-8',
|
||||
'.css': 'text/css; charset=utf-8',
|
||||
'.json': 'application/json; charset=utf-8',
|
||||
'.png': 'image/png',
|
||||
'.jpg': 'image/jpeg',
|
||||
'.jpeg': 'image/jpeg',
|
||||
'.webp': 'image/webp',
|
||||
'.gif': 'image/gif',
|
||||
'.svg': 'image/svg+xml',
|
||||
'.ico': 'image/x-icon',
|
||||
'.woff2': 'font/woff2',
|
||||
'.map': 'application/json; charset=utf-8',
|
||||
}
|
||||
|
||||
const server = http.createServer((req, res) => {
|
||||
const clean = decodeURIComponent((req.url || '/').split('?')[0])
|
||||
// Pages Functions 优先(/api/* 与 /plugins/*):它们**不套用 _headers**,与线上一致
|
||||
handleFunction(req, res, clean).then((handled) => {
|
||||
if (handled) return
|
||||
const file = path.resolve(dist, clean === '/' ? 'index.html' : '.' + clean)
|
||||
if (!file.startsWith(dist + path.sep)) { res.writeHead(403, securityHeadersFor(clean, {})); return res.end('forbidden') }
|
||||
fs.readFile(file, (err, data) => {
|
||||
if (err) { res.writeHead(404, securityHeadersFor(clean, {})); return res.end('not found') }
|
||||
const headers = securityHeadersFor(clean, { 'content-type': mime[path.extname(file)] || 'application/octet-stream' })
|
||||
res.writeHead(200, headers)
|
||||
res.end(data)
|
||||
})
|
||||
}).catch(() => {
|
||||
if (!res.headersSent) { res.writeHead(500, { 'content-type': 'text/plain; charset=utf-8' }) }
|
||||
res.end('server error')
|
||||
})
|
||||
})
|
||||
server.listen(port, '127.0.0.1', () => {
|
||||
const cli = require.resolve('@playwright/test/cli')
|
||||
// iwb-csp-gate.spec.js 是 CSP 门禁:它依赖本服务器下发的 _headers(尤其 Content-Security-Policy),
|
||||
// 覆盖「blob: 源复制」与「大图压缩落库」两条真实链路,必须留在门禁里。
|
||||
// 默认跑全部门禁 spec;调试时可用 IWB_E2E_SPECS(逗号分隔)只跑指定文件,避免每次都全量。
|
||||
// iwb-import-4k.spec.js = 「导入图片(粘贴/拖放/上传)」路径契约(4K 导入 ⇒ 立即引用化 + 压缩到显示尺寸),
|
||||
// 用户实测的真实缺陷驱动,必须留在门禁里(否则该路径会再次退化成"原图 base64 直入节点")。
|
||||
// iwb-backup-config.spec.js = 「备份/还原里的设置完整性与往返一致」契约(用户实测:设置还原不回来),
|
||||
// 覆盖导出源必须是真实设置、withKeys 两个方向、__KEEP__ 语义与未知字段保留,必须留在门禁里。
|
||||
// iwb-duplicate-ws.spec.js = 「创建副本不丢连线 + 副本名唯一」契约(用户实测:复制画布丢连线、连续复制同名),
|
||||
// 覆盖 画布→连线→回库→复制→打开副本 的真实链路,必须留在门禁里。
|
||||
// iwb-resume-reload.spec.js = 「生图中刷新不丢需求」契约(用户实测:刷新后续跑横幅不出现),
|
||||
// 覆盖 在途请求→刷新被标 failed→启动过滤 failed→recoverable→横幅→点继续重新发起 的链路,必须留在门禁里。
|
||||
// iwb-tab-dot.spec.js = 「标签条圆点状态色」契约(用户需求:生成完成=绿、失败=红、切到画布清除)。
|
||||
// iwb-resume-scope.spec.js = 「续跑范围不放大」契约(用户实测:单任务中断刷新后其他未启动任务也被新建→计划外计费)。
|
||||
// iwb-resume-variants.spec.js = 「多变体只补缺张」契约(用户实测:4 变体完成 2 张后整任务被跳过,缺张永不补;继续只补缺失变体)。
|
||||
const specOverride = String(process.env.IWB_E2E_SPECS || '').split(',').map((x) => x.trim()).filter(Boolean)
|
||||
// 门禁 spec 不再手工维护:交给 scripts/list-e2e-specs.js 自动发现 tests/*.spec.js。
|
||||
// 排除规则只有一条——下划线前缀(_*.spec.js = dev 探针),且该探针必须自带 iwb-dev-probe 标记,
|
||||
// 否则 discoverSpecs 会抛错。"忘了把新 spec 加进清单"这种静默漏跑从此不可能发生。
|
||||
let specs = specOverride
|
||||
if (specs.length) {
|
||||
console.log(`[serve-test] 使用 IWB_E2E_SPECS 覆盖:${specs.length} 个 spec`)
|
||||
} else {
|
||||
const discovered = require('./list-e2e-specs').discoverSpecs(path.join(root, 'tests'))
|
||||
specs = discovered.specs
|
||||
console.log(`[serve-test] 自动发现门禁 spec ${specs.length} 个${discovered.excluded.length ? `(排除 dev 探针 ${discovered.excluded.length}:${discovered.excluded.map((f) => path.basename(f)).join('、')})` : ''}`)
|
||||
let pathname = '/'
|
||||
try { pathname = decodeURIComponent(new URL(req.url, 'http://127.0.0.1').pathname) } catch (e) { pathname = '/' }
|
||||
if (pathname.endsWith('/')) pathname += 'index.html'
|
||||
|
||||
let file = path.join(dist, pathname)
|
||||
// 目录穿越防护:只允许 servicedir 内的文件
|
||||
if (!file.startsWith(dist + path.sep)) {
|
||||
res.writeHead(403, { 'content-type': 'text/plain; charset=utf-8' })
|
||||
res.end('forbidden')
|
||||
return
|
||||
}
|
||||
const child = cp.spawn(process.execPath, [cli, 'test'].concat(specs), {
|
||||
cwd: root,
|
||||
stdio: 'inherit',
|
||||
env: { ...process.env, IWB_BASE_URL: `http://127.0.0.1:${port}` },
|
||||
fs.stat(file, (err, st) => {
|
||||
if (err || !st.isFile()) {
|
||||
res.writeHead(404, { 'content-type': 'text/plain; charset=utf-8' })
|
||||
res.end('not found')
|
||||
return
|
||||
}
|
||||
res.writeHead(200, {
|
||||
'content-type': mime[path.extname(file)] || 'application/octet-stream',
|
||||
'cache-control': 'no-store',
|
||||
})
|
||||
fs.createReadStream(file).pipe(res)
|
||||
})
|
||||
child.on('exit', (code) => { server.close(() => process.exit(code == null ? 1 : code)) })
|
||||
})
|
||||
|
||||
server.listen(port, () => {
|
||||
console.log('[serve-test] serving ' + path.relative(process.cwd(), dist) + ' at http://127.0.0.1:' + port)
|
||||
console.log('[serve-test] 纯静态:不再注入 _headers / 不再模拟 Pages Functions(项目已转为桌面客户端)')
|
||||
})
|
||||
@@ -54,13 +54,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.25.13 · 7.6 MB · .dmg<div class="hash">sha256 863a5ff87a1debc0…</div></div>
|
||||
<a class="btn" href="/updates/darwin-aarch64/image-workbench_3.25.13_aarch64.dmg">下载</a>
|
||||
<div class="meta">版本 3.25.17 · 7.5 MB · .dmg<div class="hash">sha256 b0eb338adafbbcba…</div></div>
|
||||
<a class="btn" href="/updates/darwin-aarch64/image-workbench_3.25.17_aarch64.dmg">下载</a>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="name">macOS · Intel<div class="hint">x86_64</div></div>
|
||||
<div class="meta">版本 3.25.13 · 7.9 MB · .dmg<div class="hash">sha256 25b4ad7237058ddd…</div></div>
|
||||
<a class="btn" href="/updates/darwin-x86_64/image-workbench_3.25.13_x64.dmg">下载</a>
|
||||
<div class="meta">版本 3.25.17 · 7.8 MB · .dmg<div class="hash">sha256 543cd456ef752111…</div></div>
|
||||
<a class="btn" href="/updates/darwin-x86_64/image-workbench_3.25.17_x64.dmg">下载</a>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="name">Windows · x64<div class="hint">需要 WebView2</div></div>
|
||||
@@ -95,9 +95,25 @@
|
||||
|
||||
<h2>历史版本</h2>
|
||||
<div class="row">
|
||||
<div class="name">3.25.13<div class="hint">Intel 版:启动目录兜底</div></div>
|
||||
<div class="name">3.25.17<div class="hint">Intel 版:图标细节修正</div></div>
|
||||
<div class="meta">2026-11-18<div class="hint">macOS · Apple Silicon / macOS · Intel</div></div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="name">3.25.16<div class="hint">Intel 版:新图标</div></div>
|
||||
<div class="meta">2026-11-18<div class="hint">macOS · Apple Silicon / macOS · Intel</div></div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="name">3.25.15<div class="hint">Windows:桌面客户端版(网页部署面移除 + 独立更新清单)</div></div>
|
||||
<div class="meta">2026-11-18<div class="hint">macOS · Apple Silicon / macOS · Intel / Windows · x64</div></div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="name">3.25.14<div class="hint">Intel 版:CSP 修复 + 外观 tab</div></div>
|
||||
<div class="meta">2026-11-18<div class="hint">macOS · Apple Silicon / macOS · Intel</div></div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="name">3.25.13<div class="hint">Windows:图片目录自愈 + 启动补齐工作目录(修丢图)</div></div>
|
||||
<div class="meta">2026-11-18<div class="hint">macOS · Apple Silicon / macOS · Intel / Windows · x64</div></div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="name">3.25.12<div class="hint">Intel 版:图片目录自愈 + 不回退 Cache</div></div>
|
||||
<div class="meta">2026-11-18<div class="hint">macOS · Apple Silicon / macOS · Intel</div></div>
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
<html lang="zh-CN"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1">
|
||||
<title>Image Workbench · 本地优先的 AI 生图工作台</title>
|
||||
<meta name="description" content="本地优先的 AI 生图无限画布:节点式工作流、插件按需安装、数据全部留在本机。">
|
||||
<link rel="stylesheet" href="/assets/style.css?v=3.25.13-mwlp28hk">
|
||||
<link rel="stylesheet" href="/assets/style.css?v=3.25.17-mwlwzikw">
|
||||
</head><body>
|
||||
<nav><div class="wrap inner">
|
||||
<a class="brand" href="/"><span class="dot">IW</span>Image Workbench</a>
|
||||
@@ -14,19 +14,19 @@
|
||||
</div>
|
||||
<div class="right">
|
||||
<a class="btn" href="/plugins/">插件市场</a>
|
||||
<a class="btn primary" href="/download/">下载 v3.25.13</a>
|
||||
<a class="btn primary" href="/download/">下载 v3.25.17</a>
|
||||
</div>
|
||||
</div></nav>
|
||||
<main>
|
||||
<section class="hero hero-art">
|
||||
<div class="hero-bg"><img src="/assets/painting.jpg?v=3.25.13-mwlp28hk" alt=""></div>
|
||||
<div class="hero-bg"><img src="/assets/painting.jpg?v=3.25.17-mwlwzikw" alt=""></div>
|
||||
<div class="hero-veil"></div>
|
||||
<div class="wrap">
|
||||
<span class="kicker">v3.25.13 · macOS / Windows · 数据在本地</span>
|
||||
<span class="kicker">v3.25.17 · macOS / Windows · 数据在本地</span>
|
||||
<h1>本地优先的<br>AI 生图无限画布</h1>
|
||||
<p class="sub">用节点把「参考图 → 提示词 → 批量生成 → 图库」串成一条生产线。<br>图片、提示词、模型配置全部留在你自己的电脑里,插件按需安装。</p>
|
||||
<div class="cta">
|
||||
<a class="btn primary lg" href="/download/">下载 v3.25.13</a>
|
||||
<a class="btn primary lg" href="/download/">下载 v3.25.17</a>
|
||||
<a class="btn lg" href="/plugins/">浏览 7 个插件</a>
|
||||
</div>
|
||||
<div class="meta">支持 macOS 12+ 与 Windows 10 1803+ · 安装包约 7 MB · 无需登录</div>
|
||||
@@ -93,8 +93,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.25.13_aarch64.dmg"><div class="n">macOS · Apple Silicon</div><div class="s">M1 / M2 / M3 / M4 · 7.6 MB · .dmg</div></a>
|
||||
<a href="/updates/darwin-x86_64/image-workbench_3.25.13_x64.dmg"><div class="n">macOS · Intel</div><div class="s">x86_64 · 7.9 MB · .dmg</div></a>
|
||||
<div class="dl"><a href="/updates/darwin-aarch64/image-workbench_3.25.17_aarch64.dmg"><div class="n">macOS · Apple Silicon</div><div class="s">M1 / M2 / M3 / M4 · 7.5 MB · .dmg</div></a>
|
||||
<a href="/updates/darwin-x86_64/image-workbench_3.25.17_x64.dmg"><div class="n">macOS · Intel</div><div class="s">x86_64 · 7.8 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>
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<!doctype html>
|
||||
<html lang="zh-CN"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1">
|
||||
<title>插件市场 · Image Workbench</title>
|
||||
<link rel="stylesheet" href="/assets/style.css?v=3.25.13-mwlp28hk">
|
||||
<link rel="stylesheet" href="/assets/style.css?v=3.25.17-mwlwzikw">
|
||||
</head><body>
|
||||
<nav><div class="wrap inner">
|
||||
<a class="brand" href="/"><span class="dot">IW</span>Image Workbench</a>
|
||||
@@ -13,7 +13,7 @@
|
||||
</div>
|
||||
<div class="right">
|
||||
<a class="btn" href="/plugins/">插件市场</a>
|
||||
<a class="btn primary" href="/download/">下载 v3.25.13</a>
|
||||
<a class="btn primary" href="/download/">下载 v3.25.17</a>
|
||||
</div>
|
||||
</div></nav>
|
||||
<main>
|
||||
|
||||
@@ -1,12 +1,94 @@
|
||||
{
|
||||
"app": "Image Workbench",
|
||||
"subtitle": "本地优先的 AI 生图无限画布 · 桌面版(Tauri v2)",
|
||||
"updatedAt": "2026-11-18T05:42:09.182Z",
|
||||
"updatedAt": "2026-11-18T09:23:59.214Z",
|
||||
"releases": [
|
||||
{
|
||||
"version": "3.25.17",
|
||||
"date": "2026-11-18",
|
||||
"notes": "Intel 版:图标细节修正",
|
||||
"platforms": {
|
||||
"darwin-aarch64": {
|
||||
"file": "updates/darwin-aarch64/image-workbench_3.25.17_aarch64.dmg",
|
||||
"size": 7827715,
|
||||
"sha256": "b0eb338adafbbcba3355ae7fc669be5456a11174d2c2e2bd2d289426665c39ec",
|
||||
"kind": "dmg"
|
||||
},
|
||||
"darwin-x86_64": {
|
||||
"file": "updates/darwin-x86_64/image-workbench_3.25.17_x64.dmg",
|
||||
"size": 8127899,
|
||||
"sha256": "543cd456ef75211172795da38c166ccb29dce42254d599f3d442b6ce641a4753",
|
||||
"kind": "dmg"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"version": "3.25.16",
|
||||
"date": "2026-11-18",
|
||||
"notes": "Intel 版:新图标",
|
||||
"platforms": {
|
||||
"darwin-aarch64": {
|
||||
"file": "updates/darwin-aarch64/image-workbench_3.25.16_aarch64.dmg",
|
||||
"size": 7876955,
|
||||
"sha256": "fdc3e93711d765022c4725340bbbb0cbac33ef0c854d2547b9a036f1b13d8e10",
|
||||
"kind": "dmg"
|
||||
},
|
||||
"darwin-x86_64": {
|
||||
"file": "updates/darwin-x86_64/image-workbench_3.25.16_x64.dmg",
|
||||
"size": 8174517,
|
||||
"sha256": "f0948b377b9bd872b206227f46d21e81927914350d538e9ac16c4699da31850e",
|
||||
"kind": "dmg"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"version": "3.25.15",
|
||||
"date": "2026-11-18",
|
||||
"notes": "Windows:桌面客户端版(网页部署面移除 + 独立更新清单)",
|
||||
"platforms": {
|
||||
"darwin-aarch64": {
|
||||
"file": "updates/darwin-aarch64/image-workbench_3.25.15_aarch64.dmg",
|
||||
"size": 7935920,
|
||||
"sha256": "b256cc50733e10307afdc18454b567965dc5c85ce60342424feedb2815a2af54",
|
||||
"kind": "dmg"
|
||||
},
|
||||
"darwin-x86_64": {
|
||||
"file": "updates/darwin-x86_64/image-workbench_3.25.15_x64.dmg",
|
||||
"size": 8233792,
|
||||
"sha256": "8b1c0c38b2981b6272ed22a77f73cc145c5e2c0152ec8bd8e2ee3958f15792d1",
|
||||
"kind": "dmg"
|
||||
},
|
||||
"windows-x86_64": {
|
||||
"file": "updates/windows-x86_64/image-workbench_3.25.15_x64-setup.exe",
|
||||
"size": 4911427,
|
||||
"sha256": "030dc4660880d494c92052d97b2e23ee0dbf178261550cb3b232631cfd9b48f3",
|
||||
"kind": "exe"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"version": "3.25.14",
|
||||
"date": "2026-11-18",
|
||||
"notes": "Intel 版:CSP 修复 + 外观 tab",
|
||||
"platforms": {
|
||||
"darwin-aarch64": {
|
||||
"file": "updates/darwin-aarch64/image-workbench_3.25.14_aarch64.dmg",
|
||||
"size": 7936466,
|
||||
"sha256": "87e908b98900ff1b48cb70344d14c17b37149c8dd9716d53361d12fbf509c096",
|
||||
"kind": "dmg"
|
||||
},
|
||||
"darwin-x86_64": {
|
||||
"file": "updates/darwin-x86_64/image-workbench_3.25.14_x64.dmg",
|
||||
"size": 8237874,
|
||||
"sha256": "2cfadfad91399c53b1b2fbf42d0c0ac521b0ebaec1ee481911c9af3d15c3bbba",
|
||||
"kind": "dmg"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"version": "3.25.13",
|
||||
"date": "2026-11-18",
|
||||
"notes": "Intel 版:启动目录兜底",
|
||||
"notes": "Windows:图片目录自愈 + 启动补齐工作目录(修丢图)",
|
||||
"platforms": {
|
||||
"darwin-aarch64": {
|
||||
"file": "updates/darwin-aarch64/image-workbench_3.25.13_aarch64.dmg",
|
||||
@@ -19,6 +101,12 @@
|
||||
"size": 8235328,
|
||||
"sha256": "25b4ad7237058ddd06d2a8f361114304ff03a37dd841d8c54a31d9d9e4d7d0e6",
|
||||
"kind": "dmg"
|
||||
},
|
||||
"windows-x86_64": {
|
||||
"file": "updates/windows-x86_64/image-workbench_3.25.13_x64-setup.exe",
|
||||
"size": 4912010,
|
||||
"sha256": "669b1dfa58c4785c11c906b70e2cb4319d2743a40c1b7b9b4dbd8e9ceaf4f47c",
|
||||
"kind": "exe"
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
@@ -1983,7 +1983,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "image-workbench"
|
||||
version = "3.25.13"
|
||||
version = "3.25.17"
|
||||
dependencies = [
|
||||
"arboard",
|
||||
"base64 0.22.1",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "image-workbench"
|
||||
version = "3.25.13"
|
||||
version = "3.25.17"
|
||||
description = "无限画布 · 生图工作台桌面版"
|
||||
authors = ["malongan"]
|
||||
license = ""
|
||||
|
||||
|
Before Width: | Height: | Size: 3.9 KiB After Width: | Height: | Size: 3.8 KiB |
|
Before Width: | Height: | Size: 8.6 KiB After Width: | Height: | Size: 8.0 KiB |
|
Before Width: | Height: | Size: 1.0 KiB After Width: | Height: | Size: 1.1 KiB |
|
Before Width: | Height: | Size: 2.0 KiB After Width: | Height: | Size: 2.1 KiB |
|
Before Width: | Height: | Size: 3.3 KiB After Width: | Height: | Size: 3.1 KiB |
|
Before Width: | Height: | Size: 4.3 KiB After Width: | Height: | Size: 4.3 KiB |
|
Before Width: | Height: | Size: 4.6 KiB After Width: | Height: | Size: 4.5 KiB |
|
Before Width: | Height: | Size: 9.8 KiB After Width: | Height: | Size: 9.1 KiB |
|
Before Width: | Height: | Size: 1006 B After Width: | Height: | Size: 1013 B |
|
Before Width: | Height: | Size: 11 KiB After Width: | Height: | Size: 10 KiB |
|
Before Width: | Height: | Size: 1.4 KiB After Width: | Height: | Size: 1.5 KiB |
|
Before Width: | Height: | Size: 2.1 KiB After Width: | Height: | Size: 2.3 KiB |
|
Before Width: | Height: | Size: 2.6 KiB After Width: | Height: | Size: 2.7 KiB |
|
Before Width: | Height: | Size: 1.5 KiB After Width: | Height: | Size: 1.7 KiB |
|
Before Width: | Height: | Size: 15 KiB After Width: | Height: | Size: 23 KiB |
|
Before Width: | Height: | Size: 17 KiB After Width: | Height: | Size: 17 KiB |
|
Before Width: | Height: | Size: 214 B After Width: | Height: | Size: 1.3 KiB |
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"$schema": "../node_modules/@tauri-apps/cli/config.schema.json",
|
||||
"productName": "image-workbench",
|
||||
"version": "3.25.13",
|
||||
"version": "3.25.17",
|
||||
"identifier": "com.malongan.imageworkbench",
|
||||
"build": {
|
||||
"frontendDist": "../dist",
|
||||
@@ -25,7 +25,7 @@
|
||||
}
|
||||
],
|
||||
"security": {
|
||||
"csp": "default-src 'self'; script-src 'self' blob:; worker-src 'self' blob:; style-src 'self' 'unsafe-inline'; img-src 'self' data: blob: https:; font-src 'self' data:; connect-src 'self' ipc: http://ipc.localhost https: blob: data:; object-src 'none'; base-uri 'none'; frame-ancestors 'none'"
|
||||
"csp": "default-src 'self'; script-src 'self' blob:; worker-src 'self' blob:; style-src 'self' 'unsafe-inline'; img-src 'self' data: blob: https:; font-src 'self' data:; connect-src 'self' ipc: http://ipc.localhost https: blob: data: http://127.0.0.1:30092 http://localhost:30092; object-src 'none'; base-uri 'none'; frame-ancestors 'none'"
|
||||
}
|
||||
},
|
||||
"bundle": {
|
||||
|
||||
@@ -3,5 +3,12 @@
|
||||
"targets": [
|
||||
"nsis"
|
||||
]
|
||||
},
|
||||
"plugins": {
|
||||
"updater": {
|
||||
"endpoints": [
|
||||
"https://download.maqiart.eu.org/updates/latest-windows.json"
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,211 @@
|
||||
/* ui-appearance.js —— 外观(画布底色 + 主题色)与取色器(v3.25.14)
|
||||
*
|
||||
* 为什么单独成模块:
|
||||
* app.js 有行数棘轮(上限 8905),外观相关的默认值 / 归一化 / 应用到 CSS 变量 /
|
||||
* 取色器组件 / 设置页渲染块全放这里,app.js 只留一行注入调用。
|
||||
*
|
||||
* 设计要点(与工单 ③ 对齐):
|
||||
* · 画布底色分**亮/暗两套**(--iwb-canvas-bg 在主题切换时取不同值)
|
||||
* · 主题色**两套共用一个**(用户裁定):连线、端口、主按钮、选中框、进度动画都吃 --iwb-brand
|
||||
* · 连线单独一个变量 --iwb-edge(默认 = 主题色),将来想分开调也够用
|
||||
* · 颜色合法性:只接受 #rgb / #rrggbb,非法值回退默认,绝不把坏值写进 CSS
|
||||
*/
|
||||
;(function (global) {
|
||||
'use strict'
|
||||
const g = (global && typeof global === 'object') ? global : {}
|
||||
const React = g.React || {}
|
||||
const el = (type, prop, ...children) => React.createElement(type, prop, ...children)
|
||||
|
||||
const DEFAULTS = Object.freeze({ canvasBgLight: '#d9dbde', canvasBgDark: '#6f6f6f', accent: '#6b7280' })
|
||||
|
||||
const HEX_RE = /^#([0-9a-f]{3}|[0-9a-f]{6})$/i
|
||||
const isHex = (v) => HEX_RE.test(String(v || ''))
|
||||
const normHex = (v) => {
|
||||
const s = String(v || '').trim()
|
||||
if (!isHex(s)) return ''
|
||||
if (s.length === 4) return ('#' + s[1] + s[1] + s[2] + s[2] + s[3] + s[3]).toLowerCase()
|
||||
return s.toLowerCase()
|
||||
}
|
||||
|
||||
function normalize (cfg) {
|
||||
const c = (cfg && cfg.canvas && cfg.canvas.appearance) || {}
|
||||
return {
|
||||
canvasBgLight: normHex(c.canvasBgLight) || DEFAULTS.canvasBgLight,
|
||||
canvasBgDark: normHex(c.canvasBgDark) || DEFAULTS.canvasBgDark,
|
||||
accent: normHex(c.accent) || DEFAULTS.accent,
|
||||
}
|
||||
}
|
||||
|
||||
/** 把外观写到 :root(dark 决定画布底色取哪一套;主题色两套共用) */
|
||||
function apply (cfg, dark) {
|
||||
try {
|
||||
const a = normalize(cfg)
|
||||
const root = g.document && g.document.documentElement
|
||||
if (!root || !root.style) return
|
||||
root.style.setProperty('--iwb-canvas-bg', dark ? a.canvasBgDark : a.canvasBgLight)
|
||||
root.style.setProperty('--iwb-brand', a.accent)
|
||||
root.style.setProperty('--iwb-edge', a.accent)
|
||||
} catch (e) { /* 样式写失败不影响功能 */ }
|
||||
}
|
||||
|
||||
// ── 颜色工具(取色器与对比度提示共用)──
|
||||
function hexToRgb (hex) {
|
||||
const h = normHex(hex) || DEFAULTS.accent
|
||||
return { r: parseInt(h.slice(1, 3), 16), g: parseInt(h.slice(3, 5), 16), b: parseInt(h.slice(5, 7), 16) }
|
||||
}
|
||||
function rgbToHex (r, gg, b) {
|
||||
const p = (n) => Math.max(0, Math.min(255, Math.round(n))).toString(16).padStart(2, '0')
|
||||
return '#' + p(r) + p(gg) + p(b)
|
||||
}
|
||||
function rgbToHsv (r, gg, b) {
|
||||
const R = r / 255, G = gg / 255, B = b / 255
|
||||
const max = Math.max(R, G, B), min = Math.min(R, G, B)
|
||||
const d = max - min
|
||||
let h = 0
|
||||
if (d) {
|
||||
if (max === R) h = ((G - B) / d) % 6
|
||||
else if (max === G) h = (B - R) / d + 2
|
||||
else h = (R - G) / d + 4
|
||||
h *= 60
|
||||
if (h < 0) h += 360
|
||||
}
|
||||
return { h: h, s: max ? d / max : 0, v: max }
|
||||
}
|
||||
function hsvToRgb (h, s, v) {
|
||||
const c = v * s
|
||||
const x = c * (1 - Math.abs(((h / 60) % 2) - 1))
|
||||
const m = v - c
|
||||
let R = 0, G = 0, B = 0
|
||||
if (h < 60) { R = c; G = x } else if (h < 120) { R = x; G = c } else if (h < 180) { G = c; B = x } else if (h < 240) { G = x; B = c } else if (h < 300) { R = x; B = c } else { R = c; B = x }
|
||||
return { r: (R + m) * 255, g: (G + m) * 255, b: (B + m) * 255 }
|
||||
}
|
||||
const lum = (rgb) => {
|
||||
const f = (v) => { const c = v / 255; return c <= 0.03928 ? c / 12.92 : Math.pow((c + 0.055) / 1.055, 2.4) }
|
||||
return 0.2126 * f(rgb.r) + 0.7152 * f(rgb.g) + 0.0722 * f(rgb.b)
|
||||
}
|
||||
function contrast (a, b) {
|
||||
const l1 = lum(hexToRgb(a)), l2 = lum(hexToRgb(b))
|
||||
const hi = Math.max(l1, l2), lo = Math.min(l1, l2)
|
||||
return (hi + 0.05) / (lo + 0.05)
|
||||
}
|
||||
const readableOn = (bg) => (contrast(bg, '#1c2333') >= 3 ? '#1c2333' : '#ffffff')
|
||||
|
||||
/* ── 取色器(仿 Obsidian:饱和度/明度方块 + 色相滑条 + RGB 输入 + 十六进制)── */
|
||||
function ColorPicker (props) {
|
||||
const value = normHex(props && props.value) || DEFAULTS.accent
|
||||
const onChange = (props && props.onChange) || function () {}
|
||||
const [open, setOpen] = React.useState(false)
|
||||
const [hsv, setHsv] = React.useState(() => { const c = hexToRgb(value); return rgbToHsv(c.r, c.g, c.b) })
|
||||
const boxRef = React.useRef(null)
|
||||
|
||||
// 外部值变化(恢复默认)时同步内部 HSV
|
||||
React.useEffect(() => {
|
||||
const c = hexToRgb(value)
|
||||
setHsv((prev) => {
|
||||
const next = rgbToHsv(c.r, c.g, c.b)
|
||||
// 灰色时色相无意义,保留用户当前色相,避免跳回 0
|
||||
return { h: next.s === 0 ? prev.h : next.h, s: next.s, v: next.v }
|
||||
})
|
||||
}, [value])
|
||||
|
||||
const emit = (next) => {
|
||||
const c = hsvToRgb(next.h, next.s, next.v)
|
||||
onChange(rgbToHex(c.r, c.g, c.b))
|
||||
}
|
||||
const pick = (e) => {
|
||||
const box = boxRef.current
|
||||
if (!box || !box.getBoundingClientRect) return
|
||||
const r = box.getBoundingClientRect()
|
||||
const x = Math.max(0, Math.min(1, (e.clientX - r.left) / r.width))
|
||||
const y = Math.max(0, Math.min(1, (e.clientY - r.top) / r.height))
|
||||
const next = { h: hsv.h, s: x, v: 1 - y }
|
||||
setHsv(next); emit(next)
|
||||
}
|
||||
const hue = (e) => { const next = { h: Number(e.target.value) || 0, s: hsv.s || 0.6, v: hsv.v || 1 }; setHsv(next); emit(next) }
|
||||
const rgb = hexToRgb(value)
|
||||
const setChannel = (k) => (e) => {
|
||||
const n = Math.max(0, Math.min(255, Number(e.target.value) || 0))
|
||||
const c = { ...rgb }
|
||||
c[k] = n
|
||||
onChange(rgbToHex(c.r, c.g, c.b))
|
||||
}
|
||||
const hueColor = 'hsl(' + Math.round(hsv.h) + ',100%,50%)'
|
||||
|
||||
return el('div', { className: 'iwb-cpick' },
|
||||
el('button', {
|
||||
type: 'button',
|
||||
className: 'iwb-cpick-swatch',
|
||||
title: '点击取色',
|
||||
onClick: () => setOpen((v) => !v),
|
||||
style: { background: value, color: readableOn(value) },
|
||||
}, el('span', { className: 'iwb-cpick-hex' }, value.toUpperCase())),
|
||||
open ? el('div', { className: 'iwb-cpick-pop', onPointerDown: (e) => e.stopPropagation() },
|
||||
el('div', {
|
||||
className: 'iwb-cpick-box',
|
||||
ref: boxRef,
|
||||
onPointerDown: (e) => { e.currentTarget.setPointerCapture && e.currentTarget.setPointerCapture(e.pointerId); pick(e) },
|
||||
onPointerMove: (e) => { if (e.buttons === 1) pick(e) },
|
||||
style: { background: 'linear-gradient(to top, #000, rgba(0,0,0,0)), linear-gradient(to right, #fff, ' + hueColor + ')' },
|
||||
},
|
||||
el('div', { className: 'iwb-cpick-dot', style: { left: (hsv.s * 100) + '%', top: ((1 - hsv.v) * 100) + '%', background: value } })),
|
||||
el('input', { type: 'range', min: 0, max: 360, value: Math.round(hsv.h), onChange: hue, className: 'iwb-cpick-hue', style: { background: 'linear-gradient(to right,#f00,#ff0,#0f0,#0ff,#00f,#f0f,#f00)' } }),
|
||||
el('div', { className: 'iwb-cpick-rgb' },
|
||||
['r', 'g', 'b'].map((k) => el('label', { key: k, className: 'iwb-cpick-chan' },
|
||||
el('input', { type: 'number', min: 0, max: 255, value: rgb[k], onChange: setChannel(k) }),
|
||||
el('span', null, k.toUpperCase())))),
|
||||
el('div', { className: 'iwb-cpick-foot' },
|
||||
el('input', {
|
||||
className: 'iwb-input iwb-cpick-input',
|
||||
value: value,
|
||||
onChange: (e) => { const v = normHex(e.target.value); if (v) onChange(v) },
|
||||
title: '支持 #rgb / #rrggbb',
|
||||
}),
|
||||
g.EyeDropper ? el('button', {
|
||||
type: 'button',
|
||||
className: 'iwb-btn iwb-btn-sm',
|
||||
title: '从屏幕取色',
|
||||
onClick: () => { try { new g.EyeDropper().open().then((r) => { const v = normHex(r && r.sRGBHex); if (v) onChange(v) }).catch(() => {}) } catch (e) { /* ignore */ } },
|
||||
}, '吸管') : null,
|
||||
el('button', { type: 'button', className: 'iwb-btn iwb-btn-sm', onClick: () => setOpen(false) }, '完成')),
|
||||
) : null,
|
||||
)
|
||||
}
|
||||
|
||||
/* ── 设置 → 外观 ── */
|
||||
function AppearanceTab (props) {
|
||||
const draft = (props && props.draft) || {}
|
||||
const setDraft = (props && props.setDraft) || function () {}
|
||||
const value = normalize(draft)
|
||||
const set = (patch) => setDraft((d) => Object.assign({}, d, {
|
||||
canvas: Object.assign({}, d.canvas, { appearance: Object.assign({}, normalize(d), patch) }),
|
||||
}))
|
||||
const warn = (bg) => {
|
||||
const ratio = contrast(bg, '#1c2333')
|
||||
if (ratio >= 4.5) return null
|
||||
return el('div', { className: 'iwb-hint iwb-hint-warn' }, '与深色文字对比度 ' + ratio.toFixed(1) + ':1(建议 ≥4.5:1),可能不易阅读')
|
||||
}
|
||||
return el('div', null,
|
||||
el('div', { className: 'iwb-section-sub' }, '画布底色'),
|
||||
el('div', { className: 'iwb-row' },
|
||||
el('span', { className: 'iwb-label' }, '亮色调'),
|
||||
el(ColorPicker, { value: value.canvasBgLight, onChange: (v) => set({ canvasBgLight: v }) })),
|
||||
warn(value.canvasBgLight),
|
||||
el('div', { className: 'iwb-row' },
|
||||
el('span', { className: 'iwb-label' }, '暗色调'),
|
||||
el(ColorPicker, { value: value.canvasBgDark, onChange: (v) => set({ canvasBgDark: v }) })),
|
||||
warn(value.canvasBgDark),
|
||||
el('div', { className: 'iwb-section-sub' }, '主题色'),
|
||||
el('div', { className: 'iwb-row' },
|
||||
el('span', { className: 'iwb-label' }, '连线 / 按钮 / 选中框'),
|
||||
el(ColorPicker, { value: value.accent, onChange: (v) => set({ accent: v }) })),
|
||||
el('div', { className: 'iwb-hint' }, '主题色同时用于亮色与暗色主题(你定的规则);连线、端口、主按钮、选中框、进度动画都会跟着变。'),
|
||||
el('div', { className: 'iwb-row' },
|
||||
el('button', {
|
||||
className: 'iwb-btn iwb-btn-sm',
|
||||
onClick: () => setDraft((d) => Object.assign({}, d, { canvas: Object.assign({}, d.canvas, { appearance: Object.assign({}, DEFAULTS) }) })),
|
||||
}, '恢复默认')),
|
||||
)
|
||||
}
|
||||
|
||||
g.IWBUIApearance = Object.freeze({ DEFAULTS, normalize, apply, contrast, ColorPicker, AppearanceTab })
|
||||
})(typeof window !== 'undefined' ? window : globalThis)
|
||||
@@ -440,6 +440,15 @@ function SettingsModal(props) {
|
||||
addLlmAddr, addLlmKey, addLlmModel, addLlmProvider, api, delLlmAddr, delLlmKey, delLlmModel, delLlmProvider, draft, llmAddrInput, llmAddrRes, llmAddrTesting, llmKeyInput, llmModelInput, llmTestMsg, llmTestSel, llmTesting, llmWarn, msg, setLlm, setLlmAddr, setLlmAddrDefault, setLlmAddrInput, setLlmDefaultModel, setLlmKey, setLlmKeyInput, setLlmModelInput, setLlmProv, setLlmTestSel, testLlm, testLlmAddrs,
|
||||
}) : el('div', { className: 'iwb-hint' }, 'llmTab 未就绪(请刷新页面)')
|
||||
const imgTab = el('div', null, transferSection)
|
||||
// 外观:画布底色(亮/暗两套)+ 主题色(两套共用)。实现见 src/ui-appearance.js。
|
||||
const appearanceTab = (function () {
|
||||
const A = (typeof window !== 'undefined') ? window.IWBUIApearance : null
|
||||
if (!A || !A.AppearanceTab) return el('div', { className: 'iwb-hint' }, '外观模块未就绪(请刷新页面)')
|
||||
return el('div', { className: 'iwb-section' },
|
||||
el('div', { className: 'iwb-section-title' }, '外观'),
|
||||
el(A.AppearanceTab, { draft, setDraft }),
|
||||
)
|
||||
})()
|
||||
const generalTab = Sections ? Sections.renderGeneralTab({
|
||||
imageLibSection: imageLibSection,
|
||||
appVersion: APP_VERSION,
|
||||
@@ -550,7 +559,7 @@ function SettingsModal(props) {
|
||||
)
|
||||
|
||||
// 顺序:通用放最前(最常用:目录/外观/图片图库/生成),其它按使用频率排
|
||||
const tabs = [['general', '通用'], ['gen', '生图服务'], ['llm', 'LLM 服务'], ['img', '图片传输'], ['sizes', '尺寸预设'], ['hotkeys', '快捷键'], ['backup', '备份与还原'], ['diag', '诊断'], ['plugins', '插件']]
|
||||
const tabs = [['general', '通用'], ['appearance', '外观'], ['gen', '生图服务'], ['llm', 'LLM 服务'], ['img', '图片传输'], ['sizes', '尺寸预设'], ['hotkeys', '快捷键'], ['backup', '备份与还原'], ['diag', '诊断'], ['plugins', '插件']]
|
||||
return el('div', { className: 'iwb-modal-mask', onWheel: (e) => e.stopPropagation(), onPointerDown: (e) => { if (e.target === e.currentTarget) props.onClose() } },
|
||||
el('div', { className: 'iwb-modal iwb-settings-modal' },
|
||||
el('div', { className: 'iwb-modal-head' },
|
||||
@@ -569,7 +578,7 @@ function SettingsModal(props) {
|
||||
pluginItems.filter((p) => p && p.enabled).map((p) => el('button', { key: 'nav-plugin:' + p.id, className: 'iwb-tab iwb-set-nav-item' + (tab === 'plugin:' + p.id ? ' iwb-tab-active' : ''), onClick: () => setTab('plugin:' + p.id) }, I('star'), el('span', null, p.name))),
|
||||
),
|
||||
el('div', { className: 'iwb-modal-body' },
|
||||
tab === 'gen' ? genTab : tab === 'llm' ? llmTab : tab === 'img' ? imgTab : tab === 'backup' ? backupTab : tab === 'hotkeys' ? hotkeyTab : tab === 'sizes' ? sizePresetTab : tab === 'plugins' ? pluginsTab : (typeof tab === 'string' && tab.indexOf('plugin:') === 0) ? pluginSettingsPage : tab === 'diag' ? diagTab : generalTab,
|
||||
tab === 'appearance' ? appearanceTab : tab === 'gen' ? genTab : tab === 'llm' ? llmTab : tab === 'img' ? imgTab : tab === 'backup' ? backupTab : tab === 'hotkeys' ? hotkeyTab : tab === 'sizes' ? sizePresetTab : tab === 'plugins' ? pluginsTab : (typeof tab === 'string' && tab.indexOf('plugin:') === 0) ? pluginSettingsPage : tab === 'diag' ? diagTab : generalTab,
|
||||
msg ? el('div', { className: 'iwb-status-' + (msg.type === 'err' ? 'err' : 'ok') }, msg.text) : null,
|
||||
),
|
||||
),
|
||||
|
||||
@@ -1129,7 +1129,7 @@
|
||||
defaultInstruction: draft.llm.defaultInstruction || '',
|
||||
},
|
||||
security: { password: draft.sec.clear ? '__CLEAR__' : ((draft.sec.password && draft.sec.password.trim()) || (draft.sec.hasPassword ? '__KEEP__' : '')) },
|
||||
canvas: { hotkeys: Object.assign({}, HOTKEY_DEFAULTS, draft.canvas.hotkeys || {}), sizePresets: Array.isArray(draft.canvas.sizePresets) && draft.canvas.sizePresets.length ? draft.canvas.sizePresets : RATIOS, generationConcurrency: Math.max(GEN_CONCURRENCY_MIN, Math.min(GEN_CONCURRENCY_MAX, Number(draft.canvas.generationConcurrency) || GEN_CONCURRENCY_DEFAULT)), taskStallEndMs: Math.max(TASK_STALL_END_MIN, Math.min(TASK_STALL_END_MAX, Number(draft.canvas.taskStallEndMs) || 300000)), autoSaveImages: draft.canvas.autoSaveImages !== false, backupOriginals: draft.canvas.backupOriginals !== false },
|
||||
canvas: { hotkeys: Object.assign({}, HOTKEY_DEFAULTS, draft.canvas.hotkeys || {}), appearance: (function () { const A = (typeof window !== 'undefined') ? window.IWBUIApearance : null; return A ? A.normalize(draft) : ((draft.canvas && draft.canvas.appearance) || {}) })(), sizePresets: Array.isArray(draft.canvas.sizePresets) && draft.canvas.sizePresets.length ? draft.canvas.sizePresets : RATIOS, generationConcurrency: Math.max(GEN_CONCURRENCY_MIN, Math.min(GEN_CONCURRENCY_MAX, Number(draft.canvas.generationConcurrency) || GEN_CONCURRENCY_DEFAULT)), taskStallEndMs: Math.max(TASK_STALL_END_MIN, Math.min(TASK_STALL_END_MAX, Number(draft.canvas.taskStallEndMs) || 300000)), autoSaveImages: draft.canvas.autoSaveImages !== false, backupOriginals: draft.canvas.backupOriginals !== false },
|
||||
webhook: { enabled: !!draft.webhook.enabled, url: (draft.webhook.url || '').trim() },
|
||||
})
|
||||
setSaving(false)
|
||||
|
||||
@@ -21,6 +21,8 @@
|
||||
--iwb-border: #d5d9e0;
|
||||
--iwb-border2: #b9bfca;
|
||||
--iwb-brand: #6b7280; /* v3.1.0 全灰阶:原品牌蓝 → 同亮度中性灰(白字对比仍 ≥4.5:1) */
|
||||
/* 连线颜色:默认跟随主题色(v3.25.14 用户裁定);设置 → 外观 可自定义 */
|
||||
--iwb-edge: var(--iwb-brand);
|
||||
--iwb-text: #1c2333;
|
||||
--iwb-text2: #4d5668;
|
||||
--iwb-err: #e5484d;
|
||||
@@ -99,7 +101,7 @@ button { font-family: inherit; }
|
||||
.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: 2.4; stroke: var(--iwb-brand); }
|
||||
.iwb-edge { fill: none; stroke: color-mix(in srgb, var(--iwb-text2) 42%, transparent); stroke-width: 1.8; stroke-dasharray: 4 3; pointer-events: stroke; cursor: pointer; }
|
||||
.iwb-edge { fill: none; stroke: var(--iwb-edge); stroke-width: 1.8; stroke-dasharray: 4 3; pointer-events: stroke; cursor: pointer; }
|
||||
.iwb-edge:hover { stroke: var(--iwb-brand); stroke-dasharray: none; }
|
||||
.iwb-edge-sel { stroke: var(--iwb-warn); stroke-width: 2.4; stroke-dasharray: none; }
|
||||
.iwb-edge-hot { stroke: var(--iwb-brand); stroke-width: 2.4; stroke-dasharray: none; }
|
||||
@@ -2047,4 +2049,20 @@ html { scrollbar-width: thin; scrollbar-color: var(--iwb-border2) color-mix(in s
|
||||
.iwb-settings-modal .iwb-modelrow { padding: 2px 8px; border-radius: 999px; background: var(--iwb-layer2); border: 1px solid transparent; margin: 0; font-size: 12.5px; }
|
||||
.iwb-settings-modal .iwb-modelrow-active { border-color: #6b5ce7; background: rgba(107,92,231,.08); }
|
||||
.iwb-settings-modal .iwb-llm-card .iwb-btn-xs { opacity: .5; }
|
||||
.iwb-settings-modal .iwb-llm-card .iwb-btn-xs:hover { opacity: 1; }
|
||||
.iwb-settings-modal .iwb-llm-card .iwb-btn-xs:hover { opacity: 1; }
|
||||
/* ── 外观:取色器(v3.25.14,仿 Obsidian 的取色面板) ───────────────── */
|
||||
.iwb-cpick { position: relative; display: inline-flex; align-items: center; gap: 8px; }
|
||||
.iwb-cpick-swatch { display: inline-flex; align-items: center; justify-content: center; min-width: 92px; height: 28px; padding: 0 10px; border-radius: 6px; border: 1px solid var(--iwb-border); cursor: pointer; font-size: 11px; letter-spacing: .04em; }
|
||||
.iwb-cpick-swatch:hover { border-color: var(--iwb-border2); }
|
||||
.iwb-cpick-hex { mix-blend-mode: difference; }
|
||||
.iwb-cpick-pop { position: absolute; z-index: 80; top: calc(100% + 8px); left: 0; width: 236px; padding: 10px; border-radius: 10px; background: var(--iwb-panel); border: 1px solid var(--iwb-border); box-shadow: var(--sh-md); }
|
||||
.iwb-cpick-box { position: relative; height: 132px; border-radius: 6px; cursor: crosshair; }
|
||||
.iwb-cpick-dot { position: absolute; width: 12px; height: 12px; margin: -6px 0 0 -6px; border-radius: 50%; border: 2px solid #fff; box-shadow: 0 0 0 1px rgba(0,0,0,.4); pointer-events: none; }
|
||||
.iwb-cpick-hue { width: 100%; height: 12px; margin: 10px 0 8px; border-radius: 6px; -webkit-appearance: none; appearance: none; }
|
||||
.iwb-cpick-hue::-webkit-slider-thumb { -webkit-appearance: none; width: 14px; height: 14px; border-radius: 50%; background: #fff; border: 2px solid rgba(0,0,0,.45); cursor: pointer; }
|
||||
.iwb-cpick-rgb { display: flex; gap: 6px; }
|
||||
.iwb-cpick-chan { flex: 1 1 0; display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: 10px; color: var(--iwb-text2); }
|
||||
.iwb-cpick-chan input { width: 100%; height: 26px; padding: 0 4px; text-align: center; border-radius: 5px; border: 1px solid var(--iwb-border); background: var(--iwb-layer2); color: var(--iwb-text); font-size: 11px; }
|
||||
.iwb-cpick-foot { display: flex; gap: 6px; align-items: center; margin-top: 8px; }
|
||||
.iwb-cpick-input { flex: 1 1 auto; height: 26px; font-size: 11px; }
|
||||
.iwb-hint-warn { color: var(--iwb-warn); }
|
||||
@@ -0,0 +1,47 @@
|
||||
/* desktop-csp-loopback-test.js —— 桌面客户端 CSP 必须放行本地服务插件(v3.25.14)
|
||||
*
|
||||
* 背景:v3.25.11 的「CSP 清理」把 30092 当成遗留端口删掉了,但它其实是
|
||||
* 2026-10-17 有意为「本地服务插件」放宽的安全边界。删掉后桌面版鲜艺抠图插件报
|
||||
* 「Failed to fetch」。
|
||||
*
|
||||
* ⚠️ 这个项目现在是**桌面客户端**:CSP 的唯一真相是 src-tauri/tauri.conf.json。
|
||||
* 不参照任何网页部署配置 —— 那是别的产品,耦合只会制造假失败。
|
||||
*
|
||||
* ⚠️ 写法约束(tests/source-text-ratchet-test.js 的零余量棘轮):
|
||||
* 不要读文件原文再 .includes/.indexOf(变量名命中 source|src|app53… 会被计数)。
|
||||
* 这里只做**解析后运行时值**的断言。
|
||||
*/
|
||||
'use strict'
|
||||
const fs = require('node:fs')
|
||||
const path = require('node:path')
|
||||
const assert = require('node:assert')
|
||||
|
||||
const conf = JSON.parse(fs.readFileSync(path.join(__dirname, '..', 'src-tauri', 'tauri.conf.json'), 'utf8'))
|
||||
const policy = String((conf.app && conf.app.security && conf.app.security.csp) || '')
|
||||
|
||||
assert.ok(policy.length > 0, '桌面版必须显式声明 CSP(不允许留空回落默认)')
|
||||
|
||||
const directives = Object.fromEntries(policy.split(';').map((part) => {
|
||||
const bits = part.trim().split(/\s+/).filter(Boolean)
|
||||
return bits.length ? [bits[0], bits.slice(1)] : ['', []]
|
||||
}))
|
||||
|
||||
const connect = directives['connect-src'] || []
|
||||
assert.ok(connect.length > 0, 'connect-src 不能为空')
|
||||
|
||||
// 30092 = 本地鲜艺抠图服务(XianyiAiRmbg)。两个 loopback 写法都要在:
|
||||
// 插件默认 http://localhost:30092,用户改成 127.0.0.1 也必须能用。
|
||||
for (const origin of ['http://127.0.0.1:30092', 'http://localhost:30092']) {
|
||||
assert.ok(connect.includes(origin), '桌面 CSP 的 connect-src 必须放行 ' + origin + '(本地抠图插件依赖)')
|
||||
}
|
||||
|
||||
// 守卫的守卫:确认没有顺手把整个 http: 放开
|
||||
assert.ok(!connect.includes('http:'), 'connect-src 不得放开整个 http: 协议(只放行具体 loopback 源)')
|
||||
|
||||
// 只允许 loopback 例外:桌面 CSP 里出现非 loopback 的 http 源视为放宽过度
|
||||
// http://ipc.localhost 是 Tauri 自己的 IPC 通道,属于必需项;其余 http 源只允许 loopback
|
||||
const ALLOWED_HTTP = new Set(['http://ipc.localhost'])
|
||||
const plainHttp = connect.filter((v) => /^http:\/\//.test(v) && !ALLOWED_HTTP.has(v) && !/^http:\/\/(127\.0\.0\.1|localhost):\d+$/.test(v))
|
||||
assert.deepStrictEqual(plainHttp, [], '除 loopback 外不得出现其它 http 源:' + plainHttp.join(', '))
|
||||
|
||||
console.log('desktop-csp-loopback: 5 通过 / 0 失败')
|
||||
@@ -62,6 +62,7 @@
|
||||
"ui-groups-sidebar.js",
|
||||
"ui-lib-sidebar.js",
|
||||
"ui-desktop-shell.js",
|
||||
"ui-appearance.js",
|
||||
"ui-workspace-tabs.js",
|
||||
"ui-app-chrome.js",
|
||||
"ui-workbench-hooks.js",
|
||||
|
||||
@@ -1,154 +0,0 @@
|
||||
'use strict'
|
||||
|
||||
// functions/api/*.js 的行为测试(此前这两个 Pages 函数无任何自动化测试)。
|
||||
// 用 Node 全局 Request/Response 调用 onRequest,并 mock 全局 fetch。
|
||||
|
||||
const assert = require('assert')
|
||||
const path = require('path')
|
||||
|
||||
const calls = []
|
||||
function setFetch(handler) {
|
||||
globalThis.fetch = async (url, init) => {
|
||||
const u = String(url)
|
||||
calls.push({ url: u, init: init || {} })
|
||||
return handler(u, init || {})
|
||||
}
|
||||
}
|
||||
const req = (method, url, headers, body) => new Request(url, { method, headers: headers || {}, body })
|
||||
const jsonReq = (url, payload, headers) => req('POST', url, Object.assign({ 'Content-Type': 'application/json' }, headers || {}), JSON.stringify(payload))
|
||||
const noAcao = (res) => assert.strictEqual(res.headers.get('access-control-allow-origin'), null, '不应再有 CORS *')
|
||||
|
||||
;(async () => {
|
||||
const img = await import(path.join(__dirname, '..', 'functions', 'api', 'img.js'))
|
||||
|
||||
// ---------- img.js ----------
|
||||
const IMG = 'https://d1.cloudfront.net/a.png'
|
||||
const okImg = () => new Response('PNGDATA', { status: 200, headers: { 'Content-Type': 'image/png' } })
|
||||
const imgUrl = (host, p) => 'https://site.example/api/img?url=' + encodeURIComponent('https://' + host + (p || '/a.png'))
|
||||
|
||||
// 1) 非 https 400
|
||||
setFetch(okImg)
|
||||
let r = await img.onRequest({ request: req('GET', 'https://site.example/api/img?url=' + encodeURIComponent('http://d1.cloudfront.net/a.png')) })
|
||||
assert.strictEqual(r.status, 400, 'img: http 应 400')
|
||||
|
||||
// 2) 非白名单 host 403
|
||||
setFetch(okImg)
|
||||
r = await img.onRequest({ request: req('GET', imgUrl('evil.example')) })
|
||||
assert.strictEqual(r.status, 403, 'img: 非白名单 host 应 403')
|
||||
|
||||
// 3) 跨域 Origin 403
|
||||
setFetch(okImg)
|
||||
r = await img.onRequest({ request: req('GET', imgUrl('d1.cloudfront.net'), { Origin: 'https://evil.example' }) })
|
||||
assert.strictEqual(r.status, 403, 'img: 跨域 Origin 应 403')
|
||||
|
||||
// 4) 直连白名单 host 放行,无 CORS *,透传 image/*
|
||||
setFetch(okImg)
|
||||
r = await img.onRequest({ request: req('GET', imgUrl('d1.cloudfront.net')) })
|
||||
assert.strictEqual(r.status, 200, 'img: 白名单 host 应 200')
|
||||
assert.strictEqual(r.headers.get('content-type'), 'image/png', 'img: 应透传 image/png')
|
||||
noAcao(r)
|
||||
|
||||
// 5) 重定向到非白名单 host 403(手动跟随并复检)
|
||||
calls.length = 0
|
||||
setFetch((u) => u.indexOf('d1.cloudfront.net') >= 0
|
||||
? new Response(null, { status: 302, headers: { Location: 'https://evil.example/x.png' } })
|
||||
: okImg())
|
||||
r = await img.onRequest({ request: req('GET', imgUrl('d1.cloudfront.net')) })
|
||||
assert.strictEqual(r.status, 403, 'img: 重定向到非白名单应 403')
|
||||
|
||||
// 6) 重定向到白名单 host 应跟随成功
|
||||
calls.length = 0
|
||||
setFetch((u) => u.indexOf('d1.cloudfront.net') >= 0
|
||||
? new Response(null, { status: 302, headers: { Location: 'https://other.aliyuncs.com/b.png' } })
|
||||
: okImg())
|
||||
r = await img.onRequest({ request: req('GET', imgUrl('d1.cloudfront.net')) })
|
||||
assert.strictEqual(r.status, 200, 'img: 重定向到白名单 host 应跟随 200')
|
||||
assert.strictEqual(calls.length, 2, 'img: 应发生两跳请求')
|
||||
|
||||
// 7) 无 Location 的重定向 502
|
||||
setFetch(() => new Response(null, { status: 302 }))
|
||||
r = await img.onRequest({ request: req('GET', imgUrl('d1.cloudfront.net')) })
|
||||
assert.strictEqual(r.status, 502, 'img: 重定向缺 Location 应 502')
|
||||
|
||||
// 8) content-length 超限 413
|
||||
setFetch(() => new Response(null, { status: 200, headers: { 'Content-Type': 'image/png', 'Content-Length': '99999999' } }))
|
||||
r = await img.onRequest({ request: req('GET', imgUrl('d1.cloudfront.net')) })
|
||||
assert.strictEqual(r.status, 413, 'img: 超大 content-length 应 413')
|
||||
|
||||
// 9) 非图片 content-type 415
|
||||
setFetch(() => new Response('{"a":1}', { status: 200, headers: { 'Content-Type': 'application/json' } }))
|
||||
r = await img.onRequest({ request: req('GET', imgUrl('d1.cloudfront.net')) })
|
||||
assert.strictEqual(r.status, 415, 'img: 非图片应 415')
|
||||
|
||||
// 10) 安全头:Cloudflare Pages 的 `_headers` **不作用于 Functions 响应**
|
||||
// ⇒ 每个 Response 必须自带 nosniff + Referrer-Policy(否则未来某端点漏设 Content-Type
|
||||
// 时浏览器会自行嗅探类型 → 可能演变成 XSS)。这是 H1 的回归守卫。
|
||||
const hasSecurityHeaders = (res, who) => {
|
||||
assert.strictEqual(res.headers.get('x-content-type-options'), 'nosniff', who + ': 应有 X-Content-Type-Options: nosniff')
|
||||
assert.strictEqual(res.headers.get('referrer-policy'), 'no-referrer', who + ': 应有 Referrer-Policy: no-referrer')
|
||||
}
|
||||
setFetch(okImg)
|
||||
r = await img.onRequest({ request: req('GET', imgUrl('d1.cloudfront.net')) })
|
||||
assert.strictEqual(r.status, 200, 'img: 正常取图应 200')
|
||||
hasSecurityHeaders(r, 'img 成功响应')
|
||||
r = await img.onRequest({ request: req('GET', imgUrl('evil.example')) })
|
||||
hasSecurityHeaders(r, 'img 403 响应')
|
||||
r = await img.onRequest({ request: req('GET', 'https://site.example/api/img?url=' + encodeURIComponent('http://d1.cloudfront.net/a.png')) })
|
||||
hasSecurityHeaders(r, 'img 400 响应')
|
||||
|
||||
// ---------- plugins/[[path]].js ----------
|
||||
const pluginsFn = await import(path.join(__dirname, '..', 'functions', 'plugins', '[[path]].js'))
|
||||
const pluginCtx = (tail, value, headers) => ({
|
||||
params: { path: [tail] },
|
||||
env: value === undefined ? {} : { PLUGINS: { get: async () => value } },
|
||||
request: req('GET', 'https://site.example/plugins/' + tail, headers || {}),
|
||||
})
|
||||
|
||||
// P1) 带内容哈希的 JS 名 → immutable + max-age=31536000
|
||||
let pr = await pluginsFn.onRequestGet(pluginCtx('plugin-xianyi-cutout.0123456789ab.js', 'console.log(1)'))
|
||||
assert.strictEqual(pr.status, 200, 'plugins: 带哈希 JS 应 200')
|
||||
assert.strictEqual(pr.headers.get('content-type'), 'application/javascript; charset=utf-8', 'plugins: 带哈希 JS 应为 application/javascript')
|
||||
assert.ok((pr.headers.get('cache-control') || '').indexOf('immutable') >= 0, 'plugins: 带哈希 JS 应含 immutable')
|
||||
assert.ok((pr.headers.get('cache-control') || '').indexOf('max-age=31536000') >= 0, 'plugins: 带哈希 JS 应含 max-age=31536000')
|
||||
|
||||
// P2) 未哈希的 JS 名 → no-cache + 非空 etag(安全网,绝不许永久缓存)
|
||||
pr = await pluginsFn.onRequestGet(pluginCtx('plugin-xianyi-cutout.js', 'console.log(1)'))
|
||||
assert.strictEqual(pr.headers.get('cache-control'), 'no-cache', 'plugins: 未哈希 JS 应 no-cache')
|
||||
assert.ok(pr.headers.get('etag'), 'plugins: 未哈希 JS 应有非空 etag')
|
||||
|
||||
// P3) index.json → no-cache + 非空 etag,body 等于 KV 里的值
|
||||
const manifest = '[{"id":"xianyi-cutout"}]'
|
||||
pr = await pluginsFn.onRequestGet(pluginCtx('index.json', manifest))
|
||||
assert.strictEqual(pr.headers.get('content-type'), 'application/json; charset=utf-8', 'plugins: index.json 应为 application/json')
|
||||
assert.strictEqual(pr.headers.get('cache-control'), 'no-cache', 'plugins: index.json 应 no-cache')
|
||||
const manifestEtag = pr.headers.get('etag')
|
||||
assert.ok(manifestEtag, 'plugins: index.json 应有非空 etag')
|
||||
assert.strictEqual(await pr.text(), manifest, 'plugins: index.json body 应等于存储值')
|
||||
|
||||
// P4) if-none-match 命中 → 304 + 空 body + 同 etag
|
||||
pr = await pluginsFn.onRequestGet(pluginCtx('index.json', manifest, { 'if-none-match': manifestEtag }))
|
||||
assert.strictEqual(pr.status, 304, 'plugins: if-none-match 命中应 304')
|
||||
assert.strictEqual(await pr.text(), '', 'plugins: 304 应为空 body')
|
||||
assert.strictEqual(pr.headers.get('etag'), manifestEtag, 'plugins: 304 应带相同 etag')
|
||||
|
||||
// P5) 缺 KV 绑定 → 500
|
||||
pr = await pluginsFn.onRequestGet(pluginCtx('index.json', undefined))
|
||||
assert.strictEqual(pr.status, 500, 'plugins: 缺 PLUGINS 绑定应 500')
|
||||
|
||||
// P6) 未知键(KV 返回 null)→ 404 + no-store
|
||||
pr = await pluginsFn.onRequestGet(pluginCtx('plugin-nope.js', null))
|
||||
assert.strictEqual(pr.status, 404, 'plugins: 未知键应 404')
|
||||
assert.strictEqual(pr.headers.get('cache-control'), 'no-store', 'plugins: 404 应 no-store')
|
||||
|
||||
// P7) 安全头:`_headers` 不作用于 Functions 响应 ⇒ 每个 Response 自带 nosniff + Referrer-Policy
|
||||
pr = await pluginsFn.onRequestGet(pluginCtx('plugin-xianyi-cutout.0123456789ab.js', 'console.log(1)'))
|
||||
hasSecurityHeaders(pr, 'plugins 200 响应')
|
||||
pr = await pluginsFn.onRequestGet(pluginCtx('index.json', manifest))
|
||||
hasSecurityHeaders(pr, 'plugins 清单 200 响应')
|
||||
pr = await pluginsFn.onRequestGet(pluginCtx('plugin-nope.js', null))
|
||||
hasSecurityHeaders(pr, 'plugins 404 响应')
|
||||
pr = await pluginsFn.onRequestGet(pluginCtx('index.json', undefined))
|
||||
hasSecurityHeaders(pr, 'plugins 500 响应')
|
||||
|
||||
console.log('functions api tests passed')
|
||||
})().catch((e) => { console.error(e); process.exit(1) })
|
||||
@@ -1,210 +0,0 @@
|
||||
// v3.86.10 CSP 门禁:本地 e2e 通过 scripts/serve-test.js 下发 _headers 里的 CSP,
|
||||
// 凡是依赖「被 CSP 禁止的能力」的实现都会在这里直接失败:
|
||||
// ① fetch(data:...) / fetch(blob:...)(connect-src 'self' https:)
|
||||
// ② 动态插 <script src="https://cdn...">(script-src 'self')
|
||||
// ③ 内联脚本 / eval / new Function(script-src 'self',无 unsafe-eval)
|
||||
// 覆盖两条真实用户链路:图库预览复制(blob: 源)+ 大图入库压缩(Worker + data: 解码)。
|
||||
// 任一 Console 出现 "Content Security Policy" 违规即视为失败——这是本 spec 的核心断言。
|
||||
const { test, expect } = require('./_pw-coverage')
|
||||
|
||||
const baseURL = process.env.IWB_BASE_URL || 'http://127.0.0.1:8787'
|
||||
test.use({ baseURL, viewport: { width: 1440, height: 1000 }, permissions: ['clipboard-read', 'clipboard-write'] })
|
||||
|
||||
// 大图 fixture 的尺寸:**唯一来源**。canvas 生成 / outputs 声明 / 复制后断言全部引用它,
|
||||
// 避免"改了 fixture 却忘了改断言"这类硬编码漂移(2026-10-28 就是这么挂了一次)。
|
||||
const FIXTURE_W = 1100
|
||||
const FIXTURE_H = 800
|
||||
|
||||
const CFG = {
|
||||
providers: [],
|
||||
outputsRetention: { enabled: true, maxFiles: 500, maxDays: 15 },
|
||||
canvas: { snap: true, backupOriginals: true },
|
||||
image: { compress: { enabled: true, maxMB: 0.01, maxEdge: 1024, quality: 0.7 } },
|
||||
}
|
||||
|
||||
const WS = {
|
||||
workspaces: [{
|
||||
id: 'ws_csp', name: 'CSP',
|
||||
nodes: [
|
||||
{ id: 'ra', type: 'ref', x: 80, y: 120, data: { url: '', data: null, name: '', localName: null } },
|
||||
{ id: 'p1', type: 'prompt', x: 620, y: 120, data: { text: '提示词', title: 'P1' } },
|
||||
],
|
||||
edges: [], groups: [],
|
||||
}],
|
||||
activeId: 'ws_csp', rev: 1,
|
||||
}
|
||||
|
||||
// 大图 fixture:同时满足两个硬约束 ——
|
||||
// ① **尺寸必须真的超阈值**:CFG 里 maxMB=0.01(≈10KB)⇒ 任何 >13KB 的 base64 都会走压缩链路,
|
||||
// 所以不需要"约 1MB"那么大;
|
||||
// ② **必须装得进 localStorage**:outputs 里 url 与 data 各存一份 dataURL(约 2 倍体积),
|
||||
// 而 localStorage 每 origin 约 5MB。
|
||||
//
|
||||
// ⚠️ 2026-10-28 实测踩坑(playwright 1.52→1.64.1 / Chromium 1169→1248,Chrome 156):
|
||||
// 同一段代码 `toDataURL('image/png')` 的输出**随浏览器版本变化**——旧版本 1600×1200 约 1MB,
|
||||
// 新版本同样尺寸变成 **2.81MB**(近似未压缩),双份 JSON = **5.63MB ⇒ 超配额**,
|
||||
// `setItem` 抛 QuotaExceededError ⇒ 整个 addInitScript 后续语句不执行 ⇒ 图库恒为 0/0 ⇒ 测试假失败。
|
||||
// 现在改为 1100×800(实测 dataURL 1.27MB / JSON 2.53MB,配额安全),
|
||||
// 且长边 1100 > maxEdge 1024 ⇒ 仍会触发缩放,test 2 的「压缩+缩放」语义不变。
|
||||
async function bigPngDataUrl(page) {
|
||||
return page.evaluate(([W, H]) => {
|
||||
const c = document.createElement('canvas')
|
||||
c.width = W; c.height = H
|
||||
const x = c.getContext('2d')
|
||||
const g = x.createLinearGradient(0, 0, W, H)
|
||||
g.addColorStop(0, '#2f6bff'); g.addColorStop(0.5, '#e2453c'); g.addColorStop(1, '#16a34a')
|
||||
x.fillStyle = g; x.fillRect(0, 0, W, H)
|
||||
for (let i = 0; i < 600; i++) x.fillRect((i * 37) % W, (i * 53) % H, 3, 3)
|
||||
return c.toDataURL('image/png')
|
||||
}, [FIXTURE_W, FIXTURE_H])
|
||||
}
|
||||
|
||||
async function boot(page, outputs) {
|
||||
await page.addInitScript((d) => {
|
||||
localStorage.clear()
|
||||
localStorage.setItem('iwb_web_cfg', JSON.stringify(d.cfg))
|
||||
localStorage.setItem('iwb_web_workspaces', JSON.stringify(d.ws))
|
||||
localStorage.setItem('iwb_ws_active', d.ws.activeId)
|
||||
localStorage.setItem('iwb_ws_' + d.ws.activeId, JSON.stringify(d.ws.workspaces[0]))
|
||||
localStorage.setItem('iwb_web_outputs', JSON.stringify(d.outputs))
|
||||
localStorage.setItem('iwb_e2e_initialized', '1')
|
||||
// 配额探测:setItem 抛错会让**后续语句全部不执行**(图库恒空、__IWB_E2E__ 也不设),
|
||||
// 表现为「元素找不到」这种极难定位的假失败。这里把实际写入长度记到 window 上,
|
||||
// 由 Node 侧 goto 之后立刻校验并抛出**可读**的错误(在 initScript 里 throw 不会中止测试)。
|
||||
let wrote = -1
|
||||
try { wrote = (localStorage.getItem('iwb_web_outputs') || '').length } catch (e) { wrote = -1 }
|
||||
window.__IWB_FIXTURE_OUTPUTS_LEN__ = wrote
|
||||
// e2e 探针:暴露压缩 / 存缩略图两个最小入口(生产不设置该标志)
|
||||
window.__IWB_E2E__ = true
|
||||
}, { cfg: CFG, ws: WS, outputs })
|
||||
await page.goto('/', { waitUntil: 'domcontentloaded' })
|
||||
// ── 配额守卫(Node 侧)─────────────────────────────────────────────
|
||||
// 为什么不在 initScript 里 throw:那里抛出的异常不会中止测试,
|
||||
// 只会让后续步骤连锁失败成「元素找不到」,根本看不出真正原因(2026-10-28 实测过)。
|
||||
{
|
||||
const expectLen = JSON.stringify(outputs).length
|
||||
// undefined = initScript 在写 outputs 那一步就抛了(配额不足),后续赋值没执行
|
||||
const actualLen = await page.evaluate(() => window.__IWB_FIXTURE_OUTPUTS_LEN__ ?? 0)
|
||||
if (actualLen !== expectLen) {
|
||||
throw new Error(
|
||||
'[e2e fixture] localStorage 写入不完整,多半是配额不足(每 origin 约 5MB)\n'
|
||||
+ ' 期望 iwb_web_outputs = ' + expectLen + ' 字符,实际 ' + actualLen + '\n'
|
||||
+ ' 注意:本 fixture 把同一个 dataURL 存了 url + data 两份(约 2 倍体积)。\n'
|
||||
+ ' toDataURL 的输出大小**随浏览器版本变化** —— 缩小 FIXTURE_W/FIXTURE_H 即可。')
|
||||
}
|
||||
}
|
||||
await page.waitForTimeout(700)
|
||||
await page.locator('.iwb-home-card:not(.iwb-home-new)').first().dblclick()
|
||||
await expect(page.locator('.iwb-canvas:not(.iwb-canvas-hidden)')).toBeVisible()
|
||||
await page.waitForTimeout(400)
|
||||
}
|
||||
|
||||
// 收集 CSP 违规(Console 原文里带 "Content Security Policy")+ 页面异常
|
||||
function watchCsp(page) {
|
||||
const csp = []
|
||||
const errors = []
|
||||
page.on('console', (m) => { const t = m.text() || ''; if (/Content Security Policy/i.test(t) || /Refused to (connect|load|create)/i.test(t)) csp.push(t) })
|
||||
page.on('pageerror', (e) => errors.push(String((e && e.message) || e)))
|
||||
return { csp, errors }
|
||||
}
|
||||
|
||||
// IndexedDB 里按 key 前缀取内容(图库缩略图 = out_<name>)
|
||||
async function idbGet(page, key) {
|
||||
return page.evaluate((k) => new Promise((resolve) => {
|
||||
const req = indexedDB.open('iwb_web')
|
||||
req.onerror = () => resolve(null)
|
||||
req.onsuccess = () => {
|
||||
const db = req.result
|
||||
let tx
|
||||
try { tx = db.transaction('images', 'readonly') } catch (e) { try { db.close() } catch (e2) {} return resolve(null) }
|
||||
const gr = tx.objectStore('images').get(k)
|
||||
gr.onerror = () => resolve(null)
|
||||
gr.onsuccess = () => { try { db.close() } catch (e) {} resolve(gr.result == null ? null : String(gr.result)) }
|
||||
}
|
||||
req.onupgradeneeded = () => { try { req.result.close() } catch (e) {} resolve(null) }
|
||||
}), key)
|
||||
}
|
||||
|
||||
async function idbKeys(page) {
|
||||
return page.evaluate(() => new Promise((resolve) => {
|
||||
const req = indexedDB.open('iwb_web')
|
||||
req.onerror = () => resolve([])
|
||||
req.onsuccess = () => {
|
||||
const db = req.result
|
||||
let tx
|
||||
try { tx = db.transaction('images', 'readonly') } catch (e) { try { db.close() } catch (e2) {} return resolve([]) }
|
||||
const kr = tx.objectStore('images').getAllKeys()
|
||||
kr.onerror = () => resolve([])
|
||||
kr.onsuccess = () => { try { db.close() } catch (e) {} resolve((kr.result || []).map(String)) }
|
||||
}
|
||||
req.onupgradeneeded = () => { try { req.result.close() } catch (e) {} resolve([]) }
|
||||
}))
|
||||
}
|
||||
|
||||
test('1. 图库预览复制:blob: 源在 CSP 下必须成功(fetch(blob:) 已被 connect-src 拦)', async ({ page }) => {
|
||||
const urls = { png: await bigPngDataUrl(page) }
|
||||
const w = watchCsp(page)
|
||||
await boot(page, [{ name: 'csp_png.png', url: urls.png, data: urls.png, size: 900000, mtime: Date.now() - 1000, w: FIXTURE_W, h: FIXTURE_H }])
|
||||
|
||||
await page.locator('.iwb-top-nav-icon[title*="资源中心"]').click()
|
||||
await expect(page.locator('.iwb-fullmask')).toBeVisible()
|
||||
await page.locator('.iwb-fullmask .iwb-res-tab').filter({ hasText: '图库' }).click()
|
||||
const thumb = page.locator('.iwb-history-item img[title^="csp_png.png"]')
|
||||
await expect(thumb).toBeVisible()
|
||||
await thumb.dblclick()
|
||||
await expect(page.locator('.iwb-imgpreview')).toBeVisible()
|
||||
// 预览把 dataURL 解析成 objectURL 后才可复制(复制源就是它)
|
||||
await expect.poll(() => page.locator('.iwb-imgpreview img').getAttribute('src'), { timeout: 8000 }).toContain('blob:')
|
||||
await page.locator('.iwb-imgpreview .iwb-prev-bar button', { hasText: '复制' }).click()
|
||||
await expect(page.locator('.iwb-status-ok').filter({ hasText: '已复制图片到剪贴板' }), 'CSP 下 blob: 源复制必须成功').toBeVisible()
|
||||
|
||||
const clip = await page.evaluate(async () => {
|
||||
const items = await navigator.clipboard.read()
|
||||
const pngItem = items.find((it) => it.types.includes('image/png'))
|
||||
if (!pngItem) return { types: items.map((it) => it.types.join('+')), ok: false }
|
||||
const bmp = await createImageBitmap(await pngItem.getType('image/png'))
|
||||
const out = { ok: true, type: 'image/png', w: bmp.width, h: bmp.height }
|
||||
if (bmp.close) bmp.close()
|
||||
return out
|
||||
})
|
||||
expect(clip.ok, JSON.stringify(clip)).toBe(true)
|
||||
// 复制的必须是**原图全尺寸**,不是压缩后的缩略图
|
||||
expect(clip.w).toBe(FIXTURE_W)
|
||||
expect(clip.h).toBe(FIXTURE_H)
|
||||
expect(w.csp, '不得出现 CSP 违规:\n' + w.csp.join('\n')).toEqual([])
|
||||
expect(w.errors).toEqual([])
|
||||
})
|
||||
|
||||
test('2. 大图入库压缩:CSP 下 Worker/解码/落库全链路必须产出压缩缩略图(out_)且无 CSP 违规', async ({ page }) => {
|
||||
const bigPng = await bigPngDataUrl(page)
|
||||
const w = watchCsp(page)
|
||||
await boot(page, [])
|
||||
|
||||
// 走应用自己的 compressDataUrl(与保存/上传/缩略图完全同一条代码路径)
|
||||
const compressed = await page.evaluate(async (png) => {
|
||||
const t0 = Date.now()
|
||||
const out = await window.__IWB_E2E__API__.compress(png, { maxEdge: 320, quality: 0.72, format: 'jpeg' })
|
||||
return { out, ms: Date.now() - t0 }
|
||||
}, bigPng)
|
||||
expect(compressed.out && compressed.out.indexOf('data:image/jpeg') === 0, '压缩产物应是 JPEG dataURL').toBe(true)
|
||||
expect(compressed.out.length).toBeLessThan(bigPng.length)
|
||||
expect(await page.evaluate((d) => { const b = atob(d.split(',')[1]); return b.length > 200 }, compressed.out)).toBe(true)
|
||||
|
||||
// 压缩必须真的跑在 Worker 线程(worker-src 未放行时会退化成主线程,那正是线上卡顿的根因)
|
||||
const used = await page.evaluate(() => window.__IWB_COMPRESS_LAST__)
|
||||
expect(used, '大图压缩必须走 Worker(不得静默退化成主线程)').toBe('worker')
|
||||
|
||||
// 落库链路:storeOutputThumb → out_<name>(图库缩略图)+ out_orig_<name>(原图)
|
||||
const stored = await page.evaluate(async (d) => {
|
||||
return await window.__IWB_E2E__API__.thumb({ name: 'csp_probe.png', data: d, url: '' })
|
||||
}, bigPng)
|
||||
expect(stored, 'storeOutputThumb 应返回写入的原图 IDB key').toBe('out_orig_csp_probe.png')
|
||||
const keys = await idbKeys(page)
|
||||
expect(keys, 'IDB 里必须出现 out_ 压缩缩略图;实际 keys=' + JSON.stringify(keys)).toContain('out_csp_probe.png')
|
||||
const thumb = await idbGet(page, 'out_csp_probe.png')
|
||||
expect(String(thumb).indexOf('data:image/jpeg') === 0, '缩略图应是压缩后的 JPEG dataURL').toBe(true)
|
||||
expect(String(thumb).length).toBeLessThan(bigPng.length)
|
||||
|
||||
expect(w.csp, '不得出现 CSP 违规:\n' + w.csp.join('\n')).toEqual([])
|
||||
expect(w.errors).toEqual([])
|
||||
})
|
||||
@@ -1,84 +0,0 @@
|
||||
// Pages Functions 安全头门禁(2026-10-20 加,审计 H1 的自动化护栏)。
|
||||
//
|
||||
// 背景(为什么会加):
|
||||
// Cloudflare Pages 的 `_headers` **不作用于 Pages Functions 响应**
|
||||
// (https://developers.cloudflare.com/pages/configuration/headers/)——
|
||||
// 静态资源(app.js / style.css)有 CSP + nosniff,而 `/api/*` 与 `/plugins/*` 这两个
|
||||
// Functions 此前**一个安全头都没有**。性质是**纵深防御缺口**(每个响应本就显式设了
|
||||
// 安全的 Content-Type,不是可利用漏洞),但缺兜底意味着:将来新增端点时漏设
|
||||
// Content-Type,浏览器会自行嗅探类型 ⇒ 可能演变成 XSS。
|
||||
// 此前这两条路径**本地完全测不到**(serve-test.js 只服务 dist/ 静态资源),
|
||||
// 「本地过、线上挂」这一类缺陷无法被 e2e 发现 ⇒ 补上本地 Functions 模拟 + 本用例。
|
||||
//
|
||||
// 本用例守三件事:
|
||||
// ① 每个 Function 响应的**每个分支**都带 X-Content-Type-Options: nosniff + Referrer-Policy: no-referrer;
|
||||
// ② Function 响应**不含** `_headers` 里的 CSP —— 显式钉死「本地与线上一致:_headers 不作用于 Function」;
|
||||
// (这条最关键:若哪天本地"好心"给 Function 套上 CSP,线上差异就被掩盖了,② 会先红)
|
||||
// ③ 静态资源**仍然**带 CSP —— 防止修 Functions 时误伤静态资源的既有防护。
|
||||
//
|
||||
// 依赖:scripts/serve-test.js 的本地 Functions 模拟(/api/* 与 /plugins/* 路由)。
|
||||
// 该模拟**只透传 Function 自己的 header**,不叠加 _headers —— 与线上语义一致。
|
||||
|
||||
const { test, expect } = require('./_pw-coverage')
|
||||
|
||||
const baseURL = process.env.IWB_BASE_URL || 'http://127.0.0.1:8787'
|
||||
test.use({ baseURL, viewport: { width: 1280, height: 900 } })
|
||||
|
||||
// 断言某个响应带 Functions 必带的安全头
|
||||
async function expectFunctionSecurityHeaders(res, who) {
|
||||
const h = res.headers() // APIResponse.headers() 是同步的,返回小写 header 名映射
|
||||
expect(h['x-content-type-options'], who + ' 应有 X-Content-Type-Options: nosniff').toBe('nosniff')
|
||||
expect(h['referrer-policy'], who + ' 应有 Referrer-Policy: no-referrer').toBe('no-referrer')
|
||||
}
|
||||
|
||||
test('Functions 响应带 nosniff + Referrer-Policy(且不含 _headers 的 CSP)', async ({ request }) => {
|
||||
// ① /plugins/index.json(清单)
|
||||
const manifest = await request.get('/plugins/index.json')
|
||||
expect(manifest.status(), '/plugins/index.json 应 200').toBe(200)
|
||||
await expectFunctionSecurityHeaders(manifest, '/plugins/index.json')
|
||||
|
||||
// ② /plugins/<内容寻址>.js(不可变缓存的插件字节)
|
||||
const body = await manifest.text()
|
||||
const file = (JSON.parse(body)[0] || {}).file
|
||||
expect(file, '本地 mock 清单应含一个插件').toBeTruthy()
|
||||
const pluginJs = await request.get('/plugins/' + file)
|
||||
expect(pluginJs.status(), '/plugins/' + file + ' 应 200').toBe(200)
|
||||
await expectFunctionSecurityHeaders(pluginJs, '/plugins/' + file)
|
||||
|
||||
// ③ /plugins 未知键 → 404 分支也必须带安全头
|
||||
const missing = await request.get('/plugins/plugin-does-not-exist.js')
|
||||
expect(missing.status(), '/plugins 未知键应 404').toBe(404)
|
||||
await expectFunctionSecurityHeaders(missing, '/plugins 404')
|
||||
|
||||
// ④ /api/img 各分支:非白名单 host → 403
|
||||
const forbidden = await request.get('/api/img?url=' + encodeURIComponent('https://evil.example/a.png'))
|
||||
expect(forbidden.status(), '/api/img 非白名单 host 应 403').toBe(403)
|
||||
await expectFunctionSecurityHeaders(forbidden, '/api/img 403')
|
||||
|
||||
// ⑤ /api/img 非 https → 400
|
||||
const badProto = await request.get('/api/img?url=' + encodeURIComponent('http://d1.cloudfront.net/a.png'))
|
||||
expect(badProto.status(), '/api/img 非 https 应 400').toBe(400)
|
||||
await expectFunctionSecurityHeaders(badProto, '/api/img 400')
|
||||
|
||||
// ⑥ /api/img 成功分支(上游由 serve-test 本地 mock,不依赖外部图床)
|
||||
const ok = await request.get('/api/img?url=' + encodeURIComponent('https://d1.cloudfront.net/a.png'))
|
||||
expect(ok.status(), '/api/img 白名单 host 应 200').toBe(200)
|
||||
await expectFunctionSecurityHeaders(ok, '/api/img 200')
|
||||
|
||||
// ② 反向断言:Function 响应**不含** CSP —— 与线上一致(_headers 不作用于 Functions)。
|
||||
// 这条防止本地模拟"好心"叠加 CSP,从而掩盖真实的线上差异。
|
||||
for (const res of [manifest, pluginJs, missing, forbidden, badProto, ok]) {
|
||||
const csp = res.headers()['content-security-policy']
|
||||
expect(csp, 'Function 响应不应带 CSP(_headers 不作用于 Functions;线上亦如此)').toBeFalsy()
|
||||
}
|
||||
})
|
||||
|
||||
test('静态资源仍带 CSP(修 Functions 时不得误伤静态资源防护)', async ({ request }) => {
|
||||
const app = await request.get('/app.js')
|
||||
expect(app.status(), '/app.js 应 200').toBe(200)
|
||||
const csp = app.headers()['content-security-policy']
|
||||
expect(csp, '静态资源应有 Content-Security-Policy').toBeTruthy()
|
||||
expect(csp, 'CSP 应限制 script-src 为 self').toContain("script-src 'self'")
|
||||
expect(csp, 'CSP 不应允许 unsafe-eval').not.toContain('unsafe-eval')
|
||||
expect(app.headers()['x-content-type-options'], '静态资源应有 nosniff').toBe('nosniff')
|
||||
})
|
||||
@@ -30,7 +30,8 @@ assert.deepStrictEqual(specsBase, expectedSpecs, '门禁 spec 必须等于全部
|
||||
// 54 = 52 + iwb-inherit-text(v3.24.81 上游继承文本)+ iwb-plugin-node-coldstart(v3.24.82 插件节点体异步注册)
|
||||
// —— 这两条 spec 随 v3.24.81/82 一起进仓库时没同步更新本数字,门禁从那时起是红的(2026-11-14 补记)
|
||||
// 55 = 54 + iwb-multi-tab(v3.24.85:跨标签页契约 —— A 页 flush 落盘后 B 页靠 rev 轮询可见 / 图库归档受跨进程锁保护)
|
||||
assert.strictEqual(result.specs.length, 55, '当前门禁应自动发现 55 个 spec(新增 iwb-multi-tab)')
|
||||
// 53 = 55 − iwb-csp-gate − iwb-functions-headers(v3.25.15:网页版部署面删除,两条只测 _headers/Functions 的 spec 一并删除)
|
||||
assert.strictEqual(result.specs.length, 53, '当前门禁应自动发现 53 个 spec')
|
||||
// 排除集合 = 全部人工 dev 探针,且都必须已声明标记
|
||||
// 4 = 3 + _probe-tab-switch(切画布标签耗时归因:四轮对照实验,只读诊断)
|
||||
assert.deepStrictEqual(excludedBase, ['_perf-baseline.spec.js', '_plugin-host-probe.spec.js', '_probe-drag.spec.js', '_probe-tab-switch.spec.js'], '被排除的应是全部带 iwb-dev-probe 标记的 dev 探针')
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
'use strict'
|
||||
|
||||
// 源码文本断言「棘轮」守卫(只减不增)。动机见 docs/standards/architecture-current-state.md 与审计:
|
||||
// iwb-v32-web-test.js 约 44% 的断言是对 app.js 的**精确源码文本 / 空白**——重构即红、且会锁住死代码
|
||||
// (历史)iwb-v32-web-test.js 曾约 44% 的断言是对 app.js 的**精确源码文本 / 空白**——重构即红、且会锁住死代码;该文件已随网页版删除
|
||||
// (实例:relayCompatTasks / resolveTaskGraph 已死,却被 67-2/67-3 的文本钉点锁住)。
|
||||
// 本守卫钉住上限:**新增**源码文本断言会让它打红,促使新测试改用行为断言;随重构下降则自动放行。
|
||||
//
|
||||
// ── 2026-10-20 扩展:守卫范围从「仅 iwb-v32-web-test.js」扩到「整个 tests/ 目录」 ──
|
||||
// ── 2026-10-20 扩展:守卫范围从「单个文件」扩到「整个 tests/ 目录」 ──
|
||||
// 动机(审计 H2):原棘轮**只守一个文件** ⇒ 另外 23 个文件里的约 160 处源码文本钉点
|
||||
// **完全不受约束** —— 在别处新写一个 `assert.ok(source.includes('xxx'))` 不会被拦。
|
||||
// 本仓 12 个文件 100% 脆(16/16 断言都是源码文本),是重构的定时炸弹。
|
||||
@@ -26,7 +26,6 @@ const fs = require('fs')
|
||||
const path = require('path')
|
||||
const root = path.resolve(__dirname, '..')
|
||||
const testsDir = path.join(root, 'tests')
|
||||
const src = fs.readFileSync(path.join(testsDir, 'iwb-v32-web-test.js'), 'utf8')
|
||||
|
||||
// ── 上限 = 2026-10-20 实测值(只允许下调,不允许上调)──────────────────
|
||||
// 2026-10-28(P1 拆分批 1):884 → **881**(67-1 那条改读 src/generation-task-graph.js)
|
||||
@@ -150,7 +149,7 @@ const MAX_SRC_COMPONENT_LINES = 531
|
||||
// ② 同时守「app.js 占总源码 ≤ 40%」(2026-11-12 实测 38.4%)—— app.js 可以涨,
|
||||
// 但必须涨得比 src 慢;功能继续加,占比自然往下走;
|
||||
// ③ Workbench 单函数上限**不动**(3,091)—— 那才是真坏味道的护栏,总量松它不松。
|
||||
const MAX_APP_JS_LINES = 8905 // 2026-11-18 桌面迁移修复:桌面端不回退 Cache Storage(WebView2 不持久)+ 存储自检接线,净增约 20 行;逻辑主体已抽到 src/ui-desktop-shell.js // 2026-11-17 P3:开发者模式本地插件加载器(+37 行) // 2026-11-17:市场请求改走原生 HTTP(+2 行 helper) // 2026-11-17 桌面版:插件市场(索引拉取/下载/sha256/写入 plugins/)约 +53 行;待抽到 src/runtime-plugin-market.js 后回调
|
||||
const MAX_APP_JS_LINES = 8912 // 2026-11-18 v3.25.14:外观(画布底色/主题色)装配 + 启动自动检查更新接线,净增约 7 行;实现主体在 src/ui-appearance.js // 2026-11-18 桌面迁移修复:桌面端不回退 Cache Storage(WebView2 不持久)+ 存储自检接线,净增约 20 行;逻辑主体已抽到 src/ui-desktop-shell.js // 2026-11-17 P3:开发者模式本地插件加载器(+37 行) // 2026-11-17:市场请求改走原生 HTTP(+2 行 helper) // 2026-11-17 桌面版:插件市场(索引拉取/下载/sha256/写入 plugins/)约 +53 行;待抽到 src/runtime-plugin-market.js 后回调
|
||||
const MAX_APP_JS_SHARE = 0.40
|
||||
|
||||
// ── 历史记账(供回溯,逐条保留)──────────────────────────────────────────────
|
||||
@@ -377,15 +376,10 @@ function countDirPins() {
|
||||
return { total, perFile }
|
||||
}
|
||||
|
||||
const app53Usages = (src.match(/\bapp53\b/g) || []).length
|
||||
const whitespacePins = (src.match(/\\n\s{2,}/g) || []).length
|
||||
// iwb-v32-web-test.js 已随网页版删除:原先「该文件里的 app53 钉点 / 精确空白钉点」两项上限不再适用。
|
||||
// 现在只看全目录总量(dirPins),任何新增源码文本钉点都会打红。
|
||||
const dirPins = countDirPins()
|
||||
|
||||
assert.ok(app53Usages <= MAX_APP53_USAGES,
|
||||
'iwb-v32 对 app.js 的源码文本断言不得增加(现 ' + app53Usages + ' / 上限 ' + MAX_APP53_USAGES + ')——新测试请用行为断言(vm/jsdom 驱动模块),勿再加源码文本钉点')
|
||||
assert.ok(whitespacePins <= MAX_WHITESPACE_PINS,
|
||||
'不得新增「精确换行/缩进」正则断言(现 ' + whitespacePins + ' / 上限 ' + MAX_WHITESPACE_PINS + ')')
|
||||
|
||||
// 全目录上限:任何**新增**源码文本钉点(不论在哪个文件)都会打红。
|
||||
// 存量不追溯 —— 逐步消除存量是另一件事(见规则库 §13.5 与事实基线 §11-F1 的教训)。
|
||||
assert.ok(dirPins.total <= MAX_DIR_SOURCE_PINS,
|
||||
@@ -485,5 +479,4 @@ assert.ok(dirPins.total <= MAX_DIR_SOURCE_PINS,
|
||||
}
|
||||
|
||||
console.log('source-text ratchet checks passed ('
|
||||
+ app53Usages + ' app53 usages, ' + whitespacePins + ' whitespace pins, '
|
||||
+ dirPins.total + ' dir source pins across ' + dirPins.perFile.length + ' files)')
|
||||
@@ -7,6 +7,9 @@
|
||||
// 纪律:只增不减;新增全局导出后若 typecheck 报 TS2339,就在这里补一行。
|
||||
|
||||
interface Window {
|
||||
// 桌面壳 / 外观(v3.25.14)
|
||||
IWBUIShell?: any
|
||||
IWBUIApearance?: any
|
||||
// 存储
|
||||
IWBStorageLocal?: any
|
||||
IWBStorageRuntime?: any
|
||||
|
||||
@@ -1,9 +0,0 @@
|
||||
name = "image-workbench-web"
|
||||
compatibility_date = "2026-08-15"
|
||||
pages_build_output_dir = "dist"
|
||||
|
||||
# A2:插件以同源方式从 KV 提供(/plugins/* → 见 functions/plugins/[[path]].js)。
|
||||
# 同源脚本本来就被 CSP script-src 'self' 允许 ⇒ 无需放宽任何 CSP。
|
||||
[[kv_namespaces]]
|
||||
binding = "PLUGINS"
|
||||
id = "4fbc63a386d945f2891381c737f1fd77"
|
||||