- beautifului.dev 组件直连:Sidebar Nav、Tool Chips、Approval Card(抽屉化)、Streaming/Thinking、Code Block、Selection Actions、Prompt Bar、Search
53 lines
1.8 KiB
JavaScript
53 lines
1.8 KiB
JavaScript
// 补抓 thinking-state + 解包全部 JSON 到暂存目录,并打印每个组件的 import / 导出签名
|
|
import { mkdir, writeFile, readFile } from 'node:fs/promises'
|
|
|
|
const jsonDir = new URL('./beautifului/', import.meta.url)
|
|
const stageDir = new URL('./beautifului/stage/', import.meta.url)
|
|
await mkdir(stageDir, { recursive: true })
|
|
|
|
// 1) 补抓 thinking-state
|
|
const tsRes = await fetch('https://www.beautifului.dev/r/thinking-state.json')
|
|
if (tsRes.ok) await writeFile(new URL('thinking-state.json', jsonDir), await tsRes.text())
|
|
else console.log('thinking-state => HTTP', tsRes.status)
|
|
|
|
// 2) 解包 + 签名摘要
|
|
const slugs = [
|
|
'foundation',
|
|
'loading-state',
|
|
'thinking-state',
|
|
'streaming-text',
|
|
'tool-chips',
|
|
'approval-card',
|
|
'button',
|
|
'glide-menu'
|
|
]
|
|
|
|
for (const s of slugs) {
|
|
let raw
|
|
try {
|
|
raw = await readFile(new URL(`${s}.json`, jsonDir), 'utf8')
|
|
} catch {
|
|
console.log(`### ${s}: JSON 缺失`)
|
|
continue
|
|
}
|
|
const j = JSON.parse(raw)
|
|
console.log(`\n### ${s} (${j.type}) deps=${JSON.stringify(j.dependencies || [])}`)
|
|
if (j.css) {
|
|
await writeFile(new URL(`${s}.css`, stageDir), j.css)
|
|
console.log(` css -> stage/${s}.css (${j.css.length} chars)`)
|
|
}
|
|
for (const f of j.files || []) {
|
|
const name = f.path.split('/').pop()
|
|
await writeFile(new URL(name, stageDir), f.content ?? '')
|
|
console.log(` ${f.path} -> stage/${name} (${(f.content ?? '').length} chars)`)
|
|
if (f.content) {
|
|
const imports = f.content
|
|
.split('\n')
|
|
.filter((l) => /^(import|export)\b/.test(l.trim()) && /from ['"]/.test(l))
|
|
for (const l of imports) console.log(' ', l.trim())
|
|
const exports = f.content.match(/^export (function|const|interface|type|default)[^\n({]*/gm) || []
|
|
for (const e of exports) console.log(' EXP:', e.trim())
|
|
}
|
|
}
|
|
}
|