feat(splash): 启动加载改成真实进度条(局域网资料目录也能看到进度)
Verify (Gitea) / gate (build · unit · facts) (push) Failing after 1m0s
Verify (Gitea) / gate (build · unit · facts) (push) Failing after 1m0s
用户把资料目录放在局域网/NAS 上,启动要逐个读 canvases/*.json,原来是无限跑马灯, 不知道在读什么、还要多久。 - src/runtime-boot-progress.js(新增):进度总线,按阶段分配权重 prepare 0-6 / data 6-10 / canvases 10-70 / library 70-80 / finalize 80-96,完成收口 100; 百分比单调不减,并发分支晚回来不会回退 - src/storage-file.js:loadInto 读 data.json / 逐个画布 / 资源库文件时按文件数上报 - src/runtime-boot-load.js:进入"恢复会话"阶段上报一次 - src/ui-splash.js(新增):启动屏搬到独立模块(app.js 由 8327 行降到 8322), 细进度条 + 流光 + 阶段文字 + 右侧百分比 + aria progressbar - style.css:进度条重做(圆角全用 token、渐变语义色、流光动画、减少动效时关闭动画) - tests/boot-progress-test.js:16 项钉住换算规则(起点/中途/收口/单调/订阅)
This commit is contained in:
1 parent
64b6652bb1
commit
e3c7a3ff9b
14 files changed
+223
-18
No files matched your search
+1
-1
@@ -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 134 个单测文件(jsdom 契约测试;2026-11-07 新增 sync-facts-guard(事实一致性)/ _helpers/source(统一源文本);2026-11-12 新增 provider-ping(测速 no-cors 兜底))
|
||||
test:unit 135 个单测文件(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)
|
||||
|
||||
@@ -7532,13 +7532,8 @@ const tbCenterSeed = (type, refs) => {
|
||||
? window.IWBUIDockPanels.build(PluginHost, wPluginPanels)
|
||||
: {}
|
||||
return el('div', { className: 'iwb-overlay' + (shellView === 'landing' ? ' iwb-view-landing' : shellView === 'home' ? ' iwb-view-home' : (shellView === 'plugins' ? ' iwb-view-plugins' : ' iwb-view-canvas')) + (drawerOpen ? ' drawer-open' : '') + ((nodes.length && loaded) ? ' has-minimap' : '') },
|
||||
// 页面加载动画(加载完成后淡出)
|
||||
!splashDone ? el('div', { className: 'iwb-splash' + (loaded ? ' iwb-splash-fade' : '') },
|
||||
el('div', { className: 'iwb-splash-logo' }, I('palette')),
|
||||
el('div', { className: 'iwb-splash-title' }, '生图工作台'),
|
||||
el('div', { className: 'iwb-splash-bar' }, el('div', { className: 'iwb-splash-bar-fill' }, null)),
|
||||
el('div', { className: 'iwb-splash-sub' }, loaded ? '加载完成' : '正在加载…'),
|
||||
) : null,
|
||||
// 页面加载动画(真实进度条:src/ui-splash.js + src/boot-progress.js,加载完成后淡出)
|
||||
!splashDone && window.IWBUISplash ? el(window.IWBUISplash.Splash, { fade: loaded, icon: I('palette') }) : null,
|
||||
shellView === 'home' ? el('div', { className: 'iwb-home-panel' },
|
||||
el('div', { className: 'iwb-home-side' },
|
||||
el('div', { className: 'iwb-home-side-head' }, el('span', null, '无限画布'),
|
||||
|
||||
@@ -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,328 行**(**双层预算**:绝对上限 8,329 / 占总源码 ≤ 40%,现 **26.3%**,2026-11-12 起;此前为单一上限 8,509、零余量);`Workbench()` = **2,179 行**(上限 **2,179**,余量 0;2026-11-16 把生成取消族 `cancelRunsFor`/`cancelRun`/`cancelTaskJobs` 与工作区列表写回族 `persistWs`/`duplicateWs` 搬进 `src/runtime-workbench-logic.js`(`createCancelActions` / `createWorkspaceListActions`),并删掉全仓零调用的 `runAll`,3090 → 2,998);大量逻辑已抽到 `src/*.js`(现 **115** 个模块 / 23,333 行,`sourceModules` 115 项;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,323 行**(**双层预算**:绝对上限 8,329 / 占总源码 ≤ 40%,现 **26.2%**,2026-11-12 起;此前为单一上限 8,509、零余量);`Workbench()` = **2,174 行**(上限 **2,179**,余量 5;2026-11-16 把生成取消族 `cancelRunsFor`/`cancelRun`/`cancelTaskJobs` 与工作区列表写回族 `persistWs`/`duplicateWs` 搬进 `src/runtime-workbench-logic.js`(`createCancelActions` / `createWorkspaceListActions`),并删掉全仓零调用的 `runAll`,3090 → 2,998);大量逻辑已抽到 `src/*.js`(现 **117** 个模块 / 23,462 行,`sourceModules` 117 项;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. 门禁与环境现状
|
||||
@@ -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` 不引用模块全局)。**115 个模块中 59 个导出**被 `app.js` 读取;其余为未接线 / 仅测试 / 零引用(见下)。
|
||||
- **判定法**:`global.X =` / `root.X =` 判「导出」;跨文件裸引用判「读」;排除自合并(`src/runtime-constants.js:9`)。`app.js` 是**唯一生产消费者**(无 HTML 入口;`sw.js` 不引用模块全局)。**117 个模块中 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 耦合面(**95** 项)与 `sourceModules` 顺序(**115** 项);命名例外由第 5 组冻结,新增非 `IWB` 前缀导出即打红。
|
||||
- **耦合面已冻结**:`tests/architecture-boundary-guard-test.js`(进 `npm run test:unit` 末环)冻结 app.js↔src 耦合面(**96** 项)与 `sourceModules` 顺序(**117** 项);命名例外由第 5 组冻结,新增非 `IWB` 前缀导出即打红。
|
||||
|
||||
## 12. 易踩的坑
|
||||
|
||||
@@ -254,7 +254,7 @@
|
||||
|
||||
**信任模型(必须明示)**:形态 A 的插件是**可信代码**(与核心同权限、无沙箱);启停与设置是 UX 与可维护性手段,**不是安全边界**(同 §13.27 教训:前端开关一定可被绕过)。
|
||||
|
||||
**守门与快照**:`tests/architecture-boundary-guard-test.js` 冻结「app.js ↔ src 耦合面」(**95** 项)与 `sourceModules` 顺序(**115** 项);新增模块、新增耦合、新增 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 耦合面」(**96** 项)与 `sourceModules` 顺序(**117** 项);新增模块、新增耦合、新增 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 规则三的同一失败模式)。
|
||||
|
||||
|
||||
+1
-1
@@ -10,7 +10,7 @@
|
||||
"app:build": "tauri build",
|
||||
"lint": "eslint src app.js",
|
||||
"test": "node tests/relay-task-graph-fixture-test.js && node tests/plugin-style-node-test.js && node tests/inherit-text-test.js",
|
||||
"test:unit": "node tests/result-img-doubleclick-test.js && node tests/gallery-audit-test.js && node tests/plugin-files-policy-test.js && node tests/theme-plugin-tokens-test.js && node tests/design-tokens-component-doc-test.js && node tests/theme-static-snapshot-test.js && node tests/overlay-layer-test.js && node tests/settings-scope-test.js && node tests/node-scope-test.js && node tests/appearance-v2-test.js && node tests/image-prompt-cover-test.js && 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/album-task-graph-test.js && node tests/generation-endpoint-test.js && node tests/storage-config-shape-test.js && node tests/generation-default-model-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/gallery-sync-test.js && node tests/image-blob-store-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/clipboard-native-test.js && node tests/paste-once-test.js && node tests/list-e2e-specs-test.js && node tests/desktop-csp-loopback-test.js && node tests/architecture-boundary-guard-test.js && node tests/plugin-host-test.js && node tests/plugin-data-test.js && node tests/plugin-loader-test.js && node tests/plugin-bundle-test.js && node tests/plugin-install-test.js && node tests/plugin-gallery-render-test.js && node tests/plugin-gallery-recovery-test.js && node tests/plugin-gallery-ux-test.js && node tests/plugin-grouplib-render-test.js && node tests/plugin-promptlib-render-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/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/plugin-theme-contract-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/native-overlay-park-test.js && node tests/ui-dock-sanitize-test.js && node tests/ui-minimap-fit-test.js && node tests/ui-workbench-hooks-test.js && node tests/plugin-scale-contract-test.js && node tesLine truncated
|
||||
"test:unit": "node tests/result-img-doubleclick-test.js && node tests/gallery-audit-test.js && node tests/plugin-files-policy-test.js && node tests/theme-plugin-tokens-test.js && node tests/design-tokens-component-doc-test.js && node tests/theme-static-snapshot-test.js && node tests/overlay-layer-test.js && node tests/settings-scope-test.js && node tests/node-scope-test.js && node tests/appearance-v2-test.js && node tests/image-prompt-cover-test.js && 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/album-task-graph-test.js && node tests/generation-endpoint-test.js && node tests/storage-config-shape-test.js && node tests/generation-default-model-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/gallery-sync-test.js && node tests/image-blob-store-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/clipboard-native-test.js && node tests/paste-once-test.js && node tests/list-e2e-specs-test.js && node tests/desktop-csp-loopback-test.js && node tests/architecture-boundary-guard-test.js && node tests/plugin-host-test.js && node tests/plugin-data-test.js && node tests/plugin-loader-test.js && node tests/plugin-bundle-test.js && node tests/plugin-install-test.js && node tests/plugin-gallery-render-test.js && node tests/plugin-gallery-recovery-test.js && node tests/plugin-gallery-ux-test.js && node tests/plugin-grouplib-render-test.js && node tests/plugin-promptlib-render-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/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/plugin-theme-contract-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/native-overlay-park-test.js && node tests/ui-dock-sanitize-test.js && node tests/ui-minimap-fit-test.js && node tests/ui-workbench-hooks-test.js && node tests/plugin-scale-contract-test.js && node tesLine truncated
|
||||
"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",
|
||||
|
||||
@@ -43,6 +43,7 @@ const sourceModules = [
|
||||
'canvas-actions.js',
|
||||
'canvas-node-factory.js',
|
||||
'storage-contract.js',
|
||||
'runtime-boot-progress.js',
|
||||
'storage-file.js',
|
||||
'storage-runtime.js',
|
||||
'storage-migrations.js',
|
||||
@@ -129,6 +130,7 @@ const sourceModules = [
|
||||
'ui-canvas-pointer.js',
|
||||
'ui-canvas-nodes.js',
|
||||
'ui-confirm.js',
|
||||
'ui-splash.js',
|
||||
'ui-settings-sections.js',
|
||||
'ui-settings-tab-diag.js',
|
||||
'ui-settings-modal.js',
|
||||
|
||||
@@ -24,6 +24,7 @@
|
||||
if (!curOk) lsRawSet('iwb_web_workspaces', legacy)
|
||||
}
|
||||
} catch (e) { /* ignore */ }
|
||||
if (window.IWBBootProgress) window.IWBBootProgress.report('finalize', 1, 1)
|
||||
api('config').then((r) => { if (r && Array.isArray(r.providers)) setConfig(r) }).catch(() => setServer({ ok: false }))
|
||||
api('prompts').then((r) => {
|
||||
if (r && Array.isArray(r.prompts)) setPrompts(r.prompts)
|
||||
|
||||
@@ -0,0 +1,69 @@
|
||||
/* boot-progress.js —— 启动加载进度总线(v3.26.109)
|
||||
*
|
||||
* 为什么要它:资料目录放在局域网/NAS 上时,读取是"每个文件一次网络往返",
|
||||
* canvases/ 里有几十个文件就要等几十次。原来的启动屏只有一条不定长动画,
|
||||
* 用户不知道在读什么、还要多久。
|
||||
*
|
||||
* 这里把"读到第几个文件"换算成真实百分比(按阶段分配权重),启动屏只负责渲染。
|
||||
* 百分比单调不减:并发分支回来的慢结果不会让进度条倒退。
|
||||
*/
|
||||
;(function (global) {
|
||||
'use strict'
|
||||
const PHASES = {
|
||||
prepare: { from: 0, to: 6, label: '准备资料目录' },
|
||||
data: { from: 6, to: 10, label: '读取 data.json' },
|
||||
canvases: { from: 10, to: 70, label: '读取画布' },
|
||||
library: { from: 70, to: 80, label: '读取资源库' },
|
||||
finalize: { from: 80, to: 96, label: '恢复会话' },
|
||||
}
|
||||
const state = { pct: 0, label: '正在启动…', detail: '', indeterminate: true, done: false }
|
||||
const subs = new Set()
|
||||
|
||||
const snapshot = () => ({ pct: state.pct, label: state.label, detail: state.detail, indeterminate: state.indeterminate, done: state.done })
|
||||
|
||||
function emit () {
|
||||
const s = snapshot()
|
||||
subs.forEach((fn) => { try { fn(s) } catch (e) { /* 单个订阅者出错不影响其它 */ } })
|
||||
}
|
||||
|
||||
// report(阶段, 已完成, 总数):total 缺省/0 时该阶段仍算"不定长"
|
||||
function report (phase, done, total, detail) {
|
||||
const p = PHASES[phase]
|
||||
if (p) {
|
||||
const d = Number(done) || 0
|
||||
const t = Number(total) || 0
|
||||
const k = t > 0 ? Math.max(0, Math.min(1, d / t)) : 0
|
||||
const pct = Math.round(p.from + (p.to - p.from) * k)
|
||||
if (pct > state.pct) state.pct = pct
|
||||
state.indeterminate = !(t > 0)
|
||||
state.label = p.label
|
||||
state.detail = detail || (t > 0 ? d + ' / ' + t : '')
|
||||
}
|
||||
if (detail) state.detail = String(detail)
|
||||
emit()
|
||||
}
|
||||
|
||||
function note (text) {
|
||||
if (text) state.detail = String(text)
|
||||
emit()
|
||||
}
|
||||
|
||||
function finish () {
|
||||
if (state.done) return
|
||||
state.pct = 100
|
||||
state.indeterminate = false
|
||||
state.done = true
|
||||
state.label = '加载完成'
|
||||
state.detail = ''
|
||||
emit()
|
||||
}
|
||||
|
||||
function subscribe (fn) {
|
||||
if (typeof fn !== 'function') return function () {}
|
||||
subs.add(fn)
|
||||
try { fn(snapshot()) } catch (e) { /* ignore */ }
|
||||
return function () { subs.delete(fn) }
|
||||
}
|
||||
|
||||
global.IWBBootProgress = { report, note, finish, subscribe, snapshot, phases: PHASES }
|
||||
})(typeof window !== 'undefined' ? window : globalThis)
|
||||
+17
-3
@@ -691,11 +691,17 @@
|
||||
return out
|
||||
}
|
||||
|
||||
// 启动加载进度(v3.26.109):局域网资料目录下这里就是最慢的一段,按文件数上报真实百分比
|
||||
const bp = () => (typeof global !== 'undefined' && global.IWBBootProgress) || null
|
||||
const bpReport = (phase, done, total, detail) => { const b = bp(); if (b) b.report(phase, done, total, detail) }
|
||||
|
||||
async function loadInto() {
|
||||
// data.json 不存在 ⇒ 把当前 WebView 里的数据迁过去(只做一次)
|
||||
const target = await join(dir, DATA_FILE)
|
||||
bpReport('prepare', 1, 1)
|
||||
let parsed = null
|
||||
try { const txt = await fs().readTextFile(target); parsed = JSON.parse(txt) } catch (e) { parsed = null }
|
||||
bpReport('data', 1, 1)
|
||||
const fromDataJson = !!(parsed && parsed.keys)
|
||||
if (fromDataJson) {
|
||||
mem = parsed.keys || {}
|
||||
@@ -715,24 +721,32 @@
|
||||
const cdir = await join(dir, CANVAS_DIR)
|
||||
try { await fs().mkdir(cdir, { recursive: true }) } catch (e) { /* 已存在 */ }
|
||||
const entries = await fs().readDir(cdir)
|
||||
for (const e of entries) {
|
||||
if (!e || e.isDirectory || !/\.json$/.test(e.name)) continue
|
||||
const wsFiles = entries.filter((e) => e && !e.isDirectory && /\.json$/.test(e.name))
|
||||
bpReport('canvases', 0, wsFiles.length)
|
||||
let wsRead = 0
|
||||
for (const e of wsFiles) {
|
||||
try {
|
||||
const text = await fs().readTextFile(await join(cdir, e.name))
|
||||
mem['iwb_ws_' + e.name.replace(/\.json$/, '')] = text
|
||||
} catch (e) { /* 单个画布读失败不影响其它 */ }
|
||||
wsRead++
|
||||
bpReport('canvases', wsRead, wsFiles.length)
|
||||
}
|
||||
} catch (e) { /* 目录还没有 */ }
|
||||
// 资源库分类文件(library/*.json):文件比 data.json 新,直接覆盖同名键
|
||||
try {
|
||||
const ldir = await join(dir, LIB_DIR)
|
||||
for (const key of Object.keys(LIB_FILES)) {
|
||||
const libKeys = Object.keys(LIB_FILES)
|
||||
let libDone = 0
|
||||
for (const key of libKeys) {
|
||||
try { mem[key] = await fs().readTextFile(await join(ldir, LIB_FILES[key])) } catch (err) {
|
||||
// 兼容旧布局:library/gallery.json(平铺);读到就沿用,flush 会写到新位置
|
||||
if (key === 'iwb_web_outputs') {
|
||||
try { mem[key] = await fs().readTextFile(await join(ldir, 'gallery.json')) } catch (err2) { /* 也没有 */ }
|
||||
}
|
||||
}
|
||||
libDone++
|
||||
bpReport('library', libDone, libKeys.length)
|
||||
}
|
||||
} catch (e) { /* 目录还没有 */ }
|
||||
// 旧格式:画布还压在 data.json 里 ⇒ 标脏,下一次 flush 拆成单文件
|
||||
|
||||
@@ -0,0 +1,43 @@
|
||||
/* ui-splash.js —— 启动加载屏(v3.26.109 从 app.js 的 JSX 里搬出来)
|
||||
*
|
||||
* 设计:图标轻浮动 + 标题 + 细进度条(真实百分比,带流光)+ 阶段文字 + 右侧百分比。
|
||||
* 数据来自 src/boot-progress.js(读取阶段上报真实进度),未知总量时退回不定长流光。
|
||||
*/
|
||||
;(function (global) {
|
||||
'use strict'
|
||||
const React = global.React
|
||||
const el = React.createElement
|
||||
const NOOP = function () {}
|
||||
|
||||
function Splash (props) {
|
||||
const p = props || {}
|
||||
const bp = global.IWBBootProgress
|
||||
const [s, setS] = React.useState(() => (bp ? bp.snapshot() : { pct: 0, label: '正在启动…', detail: '', indeterminate: true }))
|
||||
React.useEffect(() => {
|
||||
const un = bp ? bp.subscribe(setS) : NOOP
|
||||
return function () { try { un() } catch (e) { /* ignore */ } }
|
||||
}, [])
|
||||
// 进入淡出即视为加载完成:进度收口到 100%,避免最后停在 96%
|
||||
React.useEffect(() => { if (p.fade && bp) bp.finish() }, [p.fade])
|
||||
const pct = Math.max(0, Math.min(100, Number(s.pct) || 0))
|
||||
const indet = !!s.indeterminate
|
||||
const label = s.detail ? s.label + ' · ' + s.detail : s.label
|
||||
return el('div', { className: 'iwb-splash' + (p.fade ? ' iwb-splash-fade' : '') },
|
||||
el('div', { className: 'iwb-splash-logo' }, p.icon || null),
|
||||
el('div', { className: 'iwb-splash-title' }, '生图工作台'),
|
||||
el('div', {
|
||||
className: 'iwb-splash-bar' + (indet ? ' is-indeterminate' : ''),
|
||||
role: 'progressbar',
|
||||
'aria-valuemin': 0,
|
||||
'aria-valuemax': 100,
|
||||
'aria-valuenow': indet ? undefined : pct,
|
||||
}, el('div', { className: 'iwb-splash-bar-fill', style: indet ? null : { width: pct + '%' } }, null)),
|
||||
el('div', { className: 'iwb-splash-meta' },
|
||||
el('span', { className: 'iwb-splash-sub' }, p.fade ? '加载完成' : label),
|
||||
el('span', { className: 'iwb-splash-pct' }, p.fade || indet ? '' : pct + '%'),
|
||||
),
|
||||
)
|
||||
}
|
||||
|
||||
global.IWBUISplash = { Splash }
|
||||
})(typeof window !== 'undefined' ? window : globalThis)
|
||||
@@ -492,9 +492,22 @@ button { font-family: inherit; }
|
||||
.iwb-splash-logo { width: 54px; height: 54px; color: var(--iwb-brand-text, var(--iwb-brand)); animation: iwb-splash-bounce 1.2s ease-in-out infinite; }
|
||||
.iwb-splash-title { font-size: 18px; font-weight: 700; color: var(--iwb-text); letter-spacing: 1px; }
|
||||
.iwb-splash-sub { font-size: 12px; color: var(--iwb-text2); }
|
||||
.iwb-splash-bar { width: 240px; height: 5px; border-radius: 3px; background: var(--iwb-layer); overflow: hidden; position: relative; border: 1px solid var(--iwb-border); }
|
||||
.iwb-splash-bar-fill { position: absolute; top: 0; bottom: 0; width: 38%; border-radius: 3px; background: linear-gradient(90deg, var(--iwb-brand), color-mix(in srgb, var(--iwb-brand) 55%, #ffffff)); animation: iwb-splash-load 1.1s ease-in-out infinite; }
|
||||
/* v3.26.109 加载进度:宽度由真实进度驱动(局域网资料目录读文件时不再只有一条跑马灯) */
|
||||
.iwb-splash-bar { width: 300px; height: 6px; border-radius: var(--iwb-radius-full); background: var(--iwb-layer); overflow: hidden; position: relative; border: 1px solid var(--iwb-border); }
|
||||
.iwb-splash-bar-fill { position: absolute; left: 0; top: 0; bottom: 0; width: 0; border-radius: var(--iwb-radius-full); overflow: hidden;
|
||||
background: linear-gradient(90deg, var(--iwb-brand), var(--iwb-brand-text));
|
||||
transition: width var(--iwb-motion-slow) var(--iwb-ease-out, cubic-bezier(.2,.7,.3,1)); }
|
||||
/* 流光:进度条内一条高光循环扫过,静止时也能看出「在干活」 */
|
||||
.iwb-splash-bar-fill::after { content: ''; position: absolute; inset: 0; transform: translateX(-100%);
|
||||
background: linear-gradient(90deg, transparent, var(--iwb-on-brand), transparent);
|
||||
animation: iwb-splash-sheen 1.5s ease-in-out infinite; }
|
||||
.iwb-splash-bar.is-indeterminate .iwb-splash-bar-fill { width: 38%; animation: iwb-splash-load 1.1s ease-in-out infinite; }
|
||||
.iwb-splash-meta { width: 300px; display: flex; align-items: baseline; justify-content: space-between; gap: var(--iwb-space-12);
|
||||
font-size: var(--iwb-font-sm); color: var(--iwb-text2); }
|
||||
.iwb-splash-pct { font-variant-numeric: tabular-nums; color: var(--iwb-text); font-weight: 600; letter-spacing: .2px; }
|
||||
@keyframes iwb-splash-load { 0% { transform: translateX(-120%); } 100% { transform: translateX(380%); } }
|
||||
@keyframes iwb-splash-sheen { 0% { transform: translateX(-100%); } 100% { transform: translateX(100%); } }
|
||||
@media (prefers-reduced-motion: reduce) { .iwb-splash-bar-fill::after, .iwb-splash-logo { animation: none; } }
|
||||
@keyframes iwb-splash-bounce { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-9px); } }
|
||||
|
||||
/* 节点停用(M 键):不参与执行,半透明 + 灰色虚线边 */
|
||||
|
||||
@@ -0,0 +1,63 @@
|
||||
'use strict'
|
||||
// 启动加载进度总线:真实百分比、单调不减、阶段文字、收口到 100%
|
||||
// 背景(v3.26.109):资料目录放局域网时读 canvases/*.json 是一堆网络往返,
|
||||
// 启动屏只有跑马灯,用户不知道在读什么。进度必须可信,所以这里钉住换算规则。
|
||||
const fs = require('fs')
|
||||
const path = require('path')
|
||||
const vm = require('vm')
|
||||
|
||||
let pass = 0
|
||||
let fail = 0
|
||||
function ok (name, cond, extra) {
|
||||
if (cond) { pass++; console.log(' ✅ ' + name) } else { fail++; console.log(' ❌ ' + name + (extra ? ' —— ' + extra : '')) }
|
||||
}
|
||||
|
||||
const code = fs.readFileSync(path.join(__dirname, '..', 'src', 'runtime-boot-progress.js'), 'utf8')
|
||||
const sandbox = { window: {}, console }
|
||||
sandbox.globalThis = sandbox.window
|
||||
vm.createContext(sandbox)
|
||||
vm.runInContext(code, sandbox)
|
||||
const BP = sandbox.window.IWBBootProgress
|
||||
|
||||
console.log('===== boot-progress:加载进度换算 =====')
|
||||
ok('模块已注册到 window', !!BP && typeof BP.report === 'function')
|
||||
const s0 = BP.snapshot()
|
||||
ok('初始为不定长(还没拿到文件数)', s0.indeterminate === true && s0.pct === 0, JSON.stringify(s0))
|
||||
|
||||
BP.report('canvases', 0, 10)
|
||||
const s1 = BP.snapshot()
|
||||
ok('知道总量后切成确定进度', s1.indeterminate === false)
|
||||
ok('canvases 起点 = 10%', s1.pct === 10, 'pct=' + s1.pct)
|
||||
ok('阶段文字是「读取画布」', s1.label === '读取画布', s1.label)
|
||||
ok('明细显示已读/总数', s1.detail === '0 / 10', s1.detail)
|
||||
|
||||
BP.report('canvases', 5, 10)
|
||||
ok('读到一半 = 10 + 60*0.5 = 40%', BP.snapshot().pct === 40, 'pct=' + BP.snapshot().pct)
|
||||
|
||||
BP.report('canvases', 10, 10)
|
||||
ok('读完 canvases 到 70%', BP.snapshot().pct === 70, 'pct=' + BP.snapshot().pct)
|
||||
|
||||
BP.report('library', 4, 4)
|
||||
ok('资源库读完到 80%', BP.snapshot().pct === 80, 'pct=' + BP.snapshot().pct)
|
||||
|
||||
// 并发分支晚回来(比如 data 阶段)不得把进度拉回去
|
||||
BP.report('data', 1, 1)
|
||||
ok('晚到的低阶段结果不回退进度', BP.snapshot().pct === 80, 'pct=' + BP.snapshot().pct)
|
||||
|
||||
const seen = []
|
||||
const un = BP.subscribe((s) => seen.push(s.pct))
|
||||
ok('订阅时立即回调一次', seen.length === 1 && seen[0] === 80, JSON.stringify(seen))
|
||||
BP.note('准备首帧')
|
||||
ok('note 只改文字不改百分比', BP.snapshot().pct === 80 && BP.snapshot().detail === '准备首帧')
|
||||
BP.finish()
|
||||
const sf = BP.snapshot()
|
||||
ok('finish 收口到 100%', sf.pct === 100 && sf.done === true && sf.label === '加载完成', JSON.stringify(sf))
|
||||
ok('订阅者收到推送', seen.length >= 3, JSON.stringify(seen))
|
||||
un()
|
||||
const before = seen.length
|
||||
BP.finish()
|
||||
ok('重复 finish 不重复推送', seen.length === before)
|
||||
ok('取消订阅后不再回调', (() => { BP.note('x'); return seen.length === before })())
|
||||
|
||||
console.log('\nboot-progress checks: ' + pass + ' 通过 / ' + fail + ' 失败')
|
||||
process.exit(fail ? 1 : 0)
|
||||
+1
@@ -88,6 +88,7 @@
|
||||
"IWBUIProductNav",
|
||||
"IWBUISettingsModal",
|
||||
"IWBUISettingsSections",
|
||||
"IWBUISplash",
|
||||
"IWBUIWorkspaceTabs",
|
||||
"IWBWTaskGraph",
|
||||
"IWBWorkbenchHooks",
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
"canvas-actions.js",
|
||||
"canvas-node-factory.js",
|
||||
"storage-contract.js",
|
||||
"runtime-boot-progress.js",
|
||||
"storage-file.js",
|
||||
"storage-runtime.js",
|
||||
"storage-migrations.js",
|
||||
@@ -101,6 +102,7 @@
|
||||
"ui-canvas-pointer.js",
|
||||
"ui-canvas-nodes.js",
|
||||
"ui-confirm.js",
|
||||
"ui-splash.js",
|
||||
"ui-settings-sections.js",
|
||||
"ui-settings-tab-diag.js",
|
||||
"ui-settings-modal.js",
|
||||
|
||||
Vendored
+2
@@ -53,6 +53,8 @@ interface Window {
|
||||
CanvasText?: any
|
||||
IWBCanvasView?: any
|
||||
IWBBootLoad?: any
|
||||
IWBBootProgress?: any // 启动加载进度总线(v3.26.109)
|
||||
IWBUISplash?: any // 启动加载屏(v3.26.109)
|
||||
IWBCanvasNodes?: any
|
||||
IWBUIWorkspaceTabs?: any
|
||||
IWBUICanvasTopBar?: any
|
||||
|
||||
Reference in new issue
Block a user