Verify (Gitea) / gate (build · unit · facts) (push) Failing after 1m24s
用户把资料目录放局域网:点开后先有 15s 纯白板,然后进度条 1s 闪过。 原因有两层: 1) app.js 顶部 `await IWBStorageFile.ready()` 在 React 首次渲染之前,存储装载多久白板就多久; 而 index.html 里没有任何静态画面,WebView 只能显示空白。 2) 那段装载里有一串串行网络往返:串行建 9 个子目录、读 data.json、逐个读画布、 再加 5 个一次性维护(migrateBlobs/backfillGalleryThumbs/stripInlineGalleryThumbs/ rotateTrash/dropLegacyDisplayThumbs),局域网下每次往返几百毫秒就是十几秒。 - scripts/boot-splash.js(新增)+ scripts/build.js:index.html 内联静态启动屏 (logo/标题/进度条/阶段文字/已等待秒数),不依赖脚本即可出画面;React 启动屏挂载时顶掉它 - src/storage-file.js:ensureDirs 改并发(9 次往返 → 1 次);一次性维护延后到首屏后 1.2s; prepare 阶段按 4 步上报(授权 / 建目录 / 整理文件名 / 完成) - src/runtime-boot-progress.js:阶段权重改为 prepare 0-10 / data 10-16 / canvases 16-70 / library 70-80 / finalize 80-96,进度条从第一秒起覆盖整段装载 - scripts/check-dist.js:index.html script 数 3→4(含内联启动屏),并断言启动屏存在 - tests/boot-progress-test.js:同步新的阶段边界
73 lines
3.4 KiB
JavaScript
73 lines
3.4 KiB
JavaScript
#!/usr/bin/env node
|
||
'use strict'
|
||
|
||
const fs = require('fs')
|
||
const path = require('path')
|
||
|
||
const root = path.resolve(__dirname, '..')
|
||
const dist = path.join(root, 'dist')
|
||
|
||
function fail(reason) {
|
||
console.log('FAIL ' + reason)
|
||
process.exit(1)
|
||
}
|
||
|
||
function pass(msg) {
|
||
console.log('PASS ' + msg)
|
||
}
|
||
|
||
const versionJsonPath = path.join(dist, 'version.json')
|
||
if (!fs.existsSync(versionJsonPath)) fail('dist/version.json 不存在')
|
||
let meta
|
||
try {
|
||
meta = JSON.parse(fs.readFileSync(versionJsonPath, 'utf8'))
|
||
} catch (e) {
|
||
fail('dist/version.json 解析失败: ' + e.message)
|
||
}
|
||
|
||
// 1. dist/app.js 以 banner `/*! IWB <version> */` 开头,且 <version> 与 version.json.version 一致
|
||
const appPath = path.join(dist, 'app.js')
|
||
if (!fs.existsSync(appPath)) fail('dist/app.js 不存在')
|
||
const app = fs.readFileSync(appPath, 'utf8')
|
||
const expectedBanner = '/*! IWB ' + meta.version + ' */'
|
||
if (!app.startsWith(expectedBanner)) {
|
||
fail('dist/app.js 未以 banner 开头(期望: ' + JSON.stringify(expectedBanner) + ',实际前 48 字符: ' + JSON.stringify(app.slice(0, 48)) + ')')
|
||
}
|
||
pass('dist/app.js banner 与 version.json.version 一致: ' + expectedBanner)
|
||
|
||
// 2. dist/index.html 含 `app.js?v=`,恰好 3 个 <script,且不含 src/
|
||
const htmlPath = path.join(dist, 'index.html')
|
||
if (!fs.existsSync(htmlPath)) fail('dist/index.html 不存在')
|
||
const html = fs.readFileSync(htmlPath, 'utf8')
|
||
if (!html.includes('app.js?v=')) fail('dist/index.html 缺少 app.js?v=')
|
||
const scriptCount = (html.match(/<script/g) || []).length
|
||
if (scriptCount !== 4) fail('dist/index.html <script 数量应为 4(React/ReactDOM/app.js + 内联启动屏),实际 ' + scriptCount)
|
||
if (!html.includes('iwb-boot-static')) fail('dist/index.html 缺少静态启动屏(局域网资料目录启动时的白屏兜底)')
|
||
if (html.includes('src/')) fail('dist/index.html 仍含 src/ 引用')
|
||
pass('dist/index.html 含 app.js?v=、静态启动屏,<script 数量为 4,无 src/ 引用')
|
||
|
||
// 3. dist/app.js 含无引号标记子串,证明内联压缩 worker 字面量在 minify 后仍存活
|
||
if (!app.includes('self.onmessage=async function(ev)')) {
|
||
fail('dist/app.js 缺少 self.onmessage=async function(ev)(内联压缩 worker 未存活)')
|
||
}
|
||
pass('dist/app.js 保留内联压缩 worker 标记 self.onmessage=async function(ev)')
|
||
|
||
// 4. dist/src 目录不应存在
|
||
if (fs.existsSync(path.join(dist, 'src'))) fail('dist/src 目录仍存在')
|
||
pass('dist/src 目录不存在')
|
||
|
||
// 5. dist/version.json 可解析且 version/packageVersion/commit 均非空
|
||
for (const key of ['version', 'packageVersion', 'commit']) {
|
||
if (!meta[key] || String(meta[key]).length === 0) fail('dist/version.json.' + key + ' 为空')
|
||
}
|
||
pass('dist/version.json 的 version/packageVersion/commit 均非空')
|
||
|
||
// 6. PWA 安装面已移除(2026-11-26):根图标/manifest 不再进 dist,也不能再被 index.html 引用。
|
||
// sw.js 必须保留:它负责更新检测和 /__iwb_cache__ 图片直出,不是纯 PWA 安装面。
|
||
for (const f of ['favicon.svg', 'manifest.webmanifest', 'icon-192.png', 'icon-512.png', 'apple-touch-icon.png']) {
|
||
if (fs.existsSync(path.join(dist, f))) fail('dist/' + f + ' 不应存在(PWA 安装面已移除)')
|
||
if (html.includes(f)) fail('dist/index.html 仍引用已删除的 ' + f)
|
||
}
|
||
if (!fs.existsSync(path.join(dist, 'sw.js'))) fail('dist/sw.js 必须保留(更新检测 + 图片缓存)')
|
||
pass('PWA 图标/manifest 未进 dist,index.html 无引用;sw.js 保留')
|