Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ docs/public/webapp
docs/public/webapp-dev
docs/public/webapp-beta
docs/public/webapp-alpha
docs/public/dweb
docs/public/dweb-dev
docs/public/dweb-beta
docs/public/dweb-alpha

# dependencies
node_modules
Expand Down
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# 更新日志

## [0.3.0] - 2026-01-27

DWEB 路由与打包优化

<!-- last-commit: 4ce13102056c2879f39fd47740c660628e193446 -->

## [0.2.0] - 2026-01-26

DWEB 安装资源与发布流程优化
Expand Down
1 change: 1 addition & 0 deletions deno.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

57 changes: 48 additions & 9 deletions docs/.vitepress/plugins/webapp-loader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,12 +58,21 @@ function copyDirContents(src: string, dest: string) {
}
}

function commandExists(command: string): boolean {
function resolvePlaocBin(): string | null {
try {
execSync(`${command} --version`, { stdio: 'ignore' })
return true
execSync('plaoc --version', { stdio: 'ignore' })
return 'plaoc'
} catch {
return false
const voltaHome = process.env.VOLTA_HOME ?? (process.env.HOME ? join(process.env.HOME, '.volta') : null)
if (!voltaHome) return null
const plaocPath = join(voltaHome, 'bin', 'plaoc')
if (!existsSync(plaocPath)) return null
try {
execSync(`${plaocPath} --version`, { stdio: 'ignore' })
return plaocPath
} catch {
return null
}
}
}

Expand Down Expand Up @@ -287,7 +296,8 @@ function ensureDwebBundle(): boolean {
return false
}

if (!commandExists('plaoc')) {
const plaocBin = resolvePlaocBin()
if (!plaocBin) {
log.warn('plaoc CLI 未安装,无法生成 DWEB metadata.json')
return false
}
Expand All @@ -296,21 +306,50 @@ function ensureDwebBundle(): boolean {
if (existsSync(DISTS_DIR)) {
rmSync(DISTS_DIR, { recursive: true, force: true })
}
execSync(`plaoc bundle "${DIST_DWEB_DIR}" -c ./ -o "${DISTS_DIR}"`, { cwd: ROOT, stdio: 'inherit' })
execSync(`${plaocBin} bundle "${DIST_DWEB_DIR}" -c ./ -o "${DISTS_DIR}"`, { cwd: ROOT, stdio: 'inherit' })
return existsSync(metadataPath)
} catch {
return false
}
}

function isPlaocMetadata(
metadata: { id?: string; server?: { root?: string }; bundle_url?: string },
channel: 'stable' | 'beta',
): boolean {
if (!metadata?.server?.root) return false
if (!metadata?.bundle_url || !metadata.bundle_url.includes('.dweb-')) return false
if (channel === 'beta' && !String(metadata.id ?? '').startsWith('dev.')) return false
return true
}

async function prepareDwebAssets(channel: 'stable' | 'beta', outputDir: string, dwebPath: string): Promise<void> {
const zipName = channel === 'stable' ? 'bfmpay-dweb.zip' : 'bfmpay-dweb-beta.zip'
const logoFileName = 'logo-256.webp'
const absoluteBaseUrl = resolveAbsoluteBaseUrl()

if (existsSync(outputDir) && existsSync(join(outputDir, 'metadata.json'))) {
log.info(`${channel} dweb 已存在,跳过`)
return
if (channel === 'beta') {
if (existsSync(outputDir)) {
rmSync(outputDir, { recursive: true, force: true })
log.info('beta dweb 强制刷新')
}
} else if (existsSync(outputDir)) {
const metadataPath = join(outputDir, 'metadata.json')
if (existsSync(metadataPath)) {
try {
const metadata = JSON.parse(readFileSync(metadataPath, 'utf-8')) as {
id?: string
server?: { root?: string }
bundle_url?: string
}
if (isPlaocMetadata(metadata, channel)) {
log.info(`${channel} dweb 已存在,跳过`)
return
}
} catch {
// fall through to regenerate
}
}
}

if (!existsSync(DIST_DWEB_DIR)) {
Expand Down
4 changes: 2 additions & 2 deletions manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"short_name": "BFM Pay",
"description": "BFM Pay - 多链钱包应用",
"logo": "logos/logo-256.webp",
"change_log": "DWEB 安装资源与发布流程优化",
"change_log": "DWEB 路由与打包优化",
"icons": [
{
"src": "logos/logo-256.webp",
Expand All @@ -19,7 +19,7 @@
"author": [
"@bfmeta.info"
],
"version": "0.2.0",
"version": "0.3.0",
"categories": [
"application",
"wallet"
Expand Down
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@biochain/keyapp",
"private": true,
"version": "0.2.0",
"version": "0.3.0",
"type": "module",
"packageManager": "pnpm@10.28.0",
"scripts": {
Expand Down Expand Up @@ -143,6 +143,7 @@
"@biochain/e2e-tools": "workspace:*",
"@inquirer/prompts": "^8.0.2",
"@playwright/test": "^1.57.0",
"@plaoc/cli": "^1.2.2",
"@storybook/addon-docs": "^10.1.4",
"@storybook/addon-vitest": "^10.1.4",
"@storybook/react": "^10.1.4",
Expand Down Expand Up @@ -208,5 +209,5 @@
"packages/*",
"miniapps/*"
],
"lastChangelogCommit": "7cddd6e285c9bf0c16d7061521d7dc429bb808d7"
"lastChangelogCommit": "4ce13102056c2879f39fd47740c660628e193446"
}
66 changes: 66 additions & 0 deletions plaoc.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,17 @@
"removeHeaders": []
}
},
{
"matchMethod": ["*"],
"matchUrl": {
"pathname": "/plaoc.json"
},
"to": {
"url": "/plaoc.json",
"appendHeaders": {},
"removeHeaders": []
}
},
{
"matchMethod": ["*"],
"matchUrl": {
Expand All @@ -26,6 +37,61 @@
"removeHeaders": []
}
},
{
"matchMethod": ["*"],
"matchUrl": {
"pathname": "{/}configs/*"
},
"to": {
"url": "/{{pattern.pathname.input}}",
"appendHeaders": {},
"removeHeaders": []
}
},
{
"matchMethod": ["*"],
"matchUrl": {
"pathname": "{/}icons/*"
},
"to": {
"url": "/{{pattern.pathname.input}}",
"appendHeaders": {},
"removeHeaders": []
}
},
{
"matchMethod": ["*"],
"matchUrl": {
"pathname": "{/}logos/*"
},
"to": {
"url": "/{{pattern.pathname.input}}",
"appendHeaders": {},
"removeHeaders": []
}
},
{
"matchMethod": ["*"],
"matchUrl": {
"pathname": "{/}miniapps/*/"
},
"to": {
"url": "/{{pattern.pathname.input}}index.html",
"appendHeaders": {},
"removeHeaders": []
}
},
{
"matchMethod": ["*"],
"matchUrl": {
"pathname": "{/}miniapps/*"
},
"to": {
"url": "/{{pattern.pathname.input}}",
"appendHeaders": {},
"removeHeaders": []
}
},
{
"matchMethod": ["*"],
"matchUrl": {
Expand Down
Loading