fix somebug

This commit is contained in:
Asaki Yuki 2026-02-23 01:43:23 +07:00
parent d02d0469c3
commit be4ceb4afe
3 changed files with 5 additions and 9 deletions

View file

@ -1,6 +1,7 @@
import path from "node:path"
import fs from "fs"
import { config } from "../compilers/Configuration.js"
import { Type } from "../types/enums/Type.js"
interface Element {
file: string
@ -37,7 +38,9 @@ export function genCustomCode(pack_folder: string) {
`type ${typeName} = {`,
...Object.entries(element).map(([elementPath, elementData]) => {
filepaths[elementPath] = elementData.file
return ` "${elementPath}": {\n type: Type.${elementData.type.toUpperCase()},\n children: ${elementData.children ? elementData.children.map(c => `"${c}"`).join(" | ") : "string"}\n },`
const type = elementData.type.toUpperCase()
// @ts-ignore
return ` "${elementPath}": {\n type: Type.${Type[type] ? type : "PANEL"},\n children: ${elementData.children ? elementData.children.map(c => `"${c}"`).join(" | ") : "string"}\n },`
}),
"}",
].join("\n"),

View file

@ -28,9 +28,7 @@ export function rebaseUIFiles(pack_folder: string) {
const relativePath = fullPath.replace(targetDir + path.sep, "")
const normalizedPath = relativePath.split(path.sep).join("/")
if (!ui.has(normalizedPath)) {
fs.rmSync(fullPath, { force: true })
} else {
if (ui.has(normalizedPath)) {
try {
const fileContent = fs.readFileSync(fullPath, "utf-8")
const parsedData = parse(fileContent)

View file

@ -53,11 +53,6 @@ export class UI<T extends Type, K extends Renderer | null = null> extends Class
process.exit(1)
}
if (namespace && !/^\w+$/.test(namespace)) {
console.error(`The '${namespace}' cannot be used as a namespace`)
process.exit(1)
}
this.name = name?.match(/^(\w|\/)+/)?.[0] || RandomString(16)
this.namespace = namespace || RandomNamespace()