feat: animation system

This commit is contained in:
Asaki Yuki 2026-01-26 13:27:54 +07:00
parent 406e71575f
commit 7534a613cb
22 changed files with 19733 additions and 19122 deletions

View file

@ -10,7 +10,12 @@ const intelliSense: string[] = [
'import { Type as T } from "../enums/Type.js"\n',
"export type Namespace = keyof IntelliSense;",
"export type Element<T extends Namespace> = Extract<keyof IntelliSense[T], string>",
"export type VanillaType<T extends Namespace, K extends Element<T>> = IntelliSense[T][K]\n",
"export type VanillaElementInfo<T extends Namespace, K extends Element<T>> = IntelliSense[T][K]",
"// @ts-ignore",
'export type VanillaType<T extends Namespace, K extends Element<T>> = VanillaElementInfo<T, K>["type"]',
"// @ts-ignore",
'export type VanillaElementChilds<T extends Namespace, K extends Element<T>> = VanillaElementInfo<T, K>["children"]',
"\n",
"export type IntelliSense = {",
]
@ -27,9 +32,12 @@ for (const [namespace, element] of Object.entries(data)) {
ePaths: string[] = [` "${namespace}": {`]
for (const [ePath, info] of Object.entries(<any>element)) {
const { file, type, extend } = <any>info
const { file, type, extend, children } = <any>info
const childType = children?.map((v: string) => `'${v}'`).join(" | ") || "string"
eType.push(`"${ePath}"`)
eType3.push(` "${ePath}": T.${type.toUpperCase()},`)
eType3.push(` "${ePath}": { type: T.${type.toUpperCase()}, children: ${childType} },`)
ePaths.push(` "${ePath}": "${file}",`)
}

View file

@ -6,6 +6,8 @@ const vanilla: NamespaceMap = new Map()
function readControls(namespace: string, file: string, elements: ElementMap, data: any[], prefix: string) {
prefix += "/"
const childs: string[] = []
for (const element of data) {
const [fullname, properties] = Object.entries(element)[0]
@ -17,6 +19,7 @@ function readControls(namespace: string, file: string, elements: ElementMap, dat
const [name, $2] = fullname.split("@")
if (name.startsWith("$")) continue
childs.push(name)
if ($2 && !$2.startsWith("$")) {
const [$3, $4] = $2.split(".")
@ -37,9 +40,12 @@ function readControls(namespace: string, file: string, elements: ElementMap, dat
const controls = (<any>properties).controls
if (controls) {
readControls(namespace, file, elements, controls, prefix + name)
const childs = readControls(namespace, file, elements, controls, prefix + name)
if (childs.length) data.children = childs
}
}
return childs
}
function readData(namespace: string, file: string, elements: ElementMap, data: any) {
@ -73,7 +79,8 @@ function readData(namespace: string, file: string, elements: ElementMap, data: a
const controls = (<any>properties).controls
if (controls) {
readControls(namespace, file, elements, controls, name)
const childs = readControls(namespace, file, elements, controls, name)
if (childs.length) data.children = childs
}
}
}
@ -148,6 +155,7 @@ interface VanillaElement {
namespace: string
}
anim_type?: string
children?: string[]
type: string
file: string
}