optimize paths

This commit is contained in:
Asaki Yuki 2026-02-22 16:04:31 +07:00
parent 85d60e5db1
commit d1a7399e2f
14 changed files with 144113 additions and 19607 deletions

16
scripts/paths-optimize.ts Normal file
View file

@ -0,0 +1,16 @@
import { writeFileSync } from "fs"
import { paths } from "../src/types/vanilla/paths"
const newPaths: Record<string, any> = {}
Object.entries(paths).forEach(([key, values]) => {
const paths = Array.from(new Set(Object.values(values)))
console.log(key)
if (paths.length === 1) {
newPaths[key] = paths[0]
} else {
newPaths[key] = values
}
})
writeFileSync("src/types/vanilla/paths.ts", `export const paths = ${JSON.stringify(newPaths, null, 4)}`, "utf-8")

View file

@ -146,7 +146,27 @@ for (const [namespace, elements] of vanilla) {
}
}
const prefix = `interface Element {
file: string
type: string
children?: string[]
extend?: {
name: string
namespace: string
}
}
interface VanillaDefs {
[key: string]: {
[key: string]: Element
}
}`
fs.writeFileSync("cache/vanilla-defs.json", JSON.stringify(json, null, 4))
fs.writeFileSync(
"src/analyzer/vanilladefs.ts",
`${prefix}\n\nexport const vanilladefs: VanillaDefs = ${JSON.stringify(json, null, 4)}`,
)
// Types
interface VanillaElement {