idk
This commit is contained in:
parent
7a43d233e3
commit
3158c3cec8
5 changed files with 35 additions and 21 deletions
|
|
@ -2,16 +2,16 @@ import { isBuildMode } from "../Configuration.js"
|
|||
import { Memory } from "../Memory.js"
|
||||
import { createBuildFolder } from "./linker.js"
|
||||
import fs from "fs/promises"
|
||||
import { genManifest } from "./manifest.js"
|
||||
|
||||
async function buildUI() {
|
||||
const build = Memory.build()
|
||||
let i = 0
|
||||
|
||||
build.set("ui/ui_defs.json", {
|
||||
build.set("ui/_ui_defs.json", {
|
||||
ui_defs: Array.from(build.keys()),
|
||||
})
|
||||
|
||||
await Promise.all(
|
||||
const out = await Promise.all(
|
||||
build.entries().map(async ([file, value]) => {
|
||||
const outFile = `build/build/${file}`
|
||||
await fs
|
||||
|
|
@ -20,11 +20,12 @@ async function buildUI() {
|
|||
|
||||
await fs.writeFile(outFile, JSON.stringify(value), "utf-8")
|
||||
build.delete(file)
|
||||
i++
|
||||
}),
|
||||
)
|
||||
|
||||
return i - 1
|
||||
await fs.writeFile("build/build/manifest.json", await genManifest(), "utf-8")
|
||||
|
||||
return out.length
|
||||
}
|
||||
|
||||
if (isBuildMode) {
|
||||
|
|
|
|||
|
|
@ -2,14 +2,23 @@ import fs from "fs/promises"
|
|||
import { BuildCache } from "./buildcache.js"
|
||||
import { RandomString } from "../../components/Utils.js"
|
||||
|
||||
const HEX: string[] = Array.from({ length: 256 }, (_, i) => i.toString(16).toUpperCase().padStart(2, "0"))
|
||||
function genUUID() {
|
||||
const HEX: string[] = Array.from({ length: 256 }, (_, i) => i.toString(16).padStart(2, "0"))
|
||||
|
||||
function genUUID(): string {
|
||||
const b = Array.from({ length: 16 }, () => Math.floor(Math.random() * 256))
|
||||
return `${HEX[b[0]]}${HEX[b[1]]}${HEX[b[2]]}${HEX[b[3]]}-${HEX[b[4]]}${HEX[b[5]]}-${
|
||||
HEX[b[6]]
|
||||
}${HEX[b[7]]}-${HEX[b[8]]}${HEX[b[9]]}-${HEX[b[10]]}${HEX[b[11]]}${HEX[b[12]]}${
|
||||
HEX[b[13]]
|
||||
}${HEX[b[14]]}${HEX[b[15]]}`
|
||||
|
||||
// version 4
|
||||
b[6] = (b[6] & 0x0f) | 0x40
|
||||
// variant 10xx
|
||||
b[8] = (b[8] & 0x3f) | 0x80
|
||||
|
||||
return (
|
||||
`${HEX[b[0]]}${HEX[b[1]]}${HEX[b[2]]}${HEX[b[3]]}-` +
|
||||
`${HEX[b[4]]}${HEX[b[5]]}-` +
|
||||
`${HEX[b[6]]}${HEX[b[7]]}-` +
|
||||
`${HEX[b[8]]}${HEX[b[9]]}-` +
|
||||
`${HEX[b[10]]}${HEX[b[11]]}${HEX[b[12]]}${HEX[b[13]]}${HEX[b[14]]}${HEX[b[15]]}`
|
||||
)
|
||||
}
|
||||
|
||||
export async function clearBuild() {
|
||||
|
|
|
|||
|
|
@ -6,12 +6,14 @@ export async function genManifest() {
|
|||
format_version: 2,
|
||||
header: {
|
||||
name: "AsaJS UI",
|
||||
uuid: uuid1,
|
||||
description: "A framework for creating UIs for AsaJS.",
|
||||
uuid: uuid1,
|
||||
version: [4, 0, 0],
|
||||
min_engine_version: [1, 21, 132],
|
||||
},
|
||||
modules: [
|
||||
{
|
||||
description: "This resource pack generate by AsaJS.",
|
||||
type: "resources",
|
||||
uuid: uuid2,
|
||||
version: [4, 0, 0],
|
||||
|
|
|
|||
|
|
@ -37,7 +37,7 @@ export class AnimationKeyframe<T extends AnimType> extends Class {
|
|||
|
||||
this.name = name || RandomString(16)
|
||||
this.namespace = namespace || RandomNamespace()
|
||||
this.path = path || `@/${this.namespace}`
|
||||
this.path = path || `@/${this.namespace}.json`
|
||||
|
||||
Memory.add(this)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -53,7 +53,7 @@ export class UI<T extends Type, K extends Renderer | null = null> extends Class
|
|||
this.name = name?.match(/^(\w|\/)+/)?.[0] || RandomString(16)
|
||||
this.namespace = namespace || RandomNamespace()
|
||||
|
||||
if (!path) this.path = `@/${this.namespace}`
|
||||
if (!path) this.path = `@/${this.namespace}.json`
|
||||
else this.path = path
|
||||
|
||||
this.extendable = this.name.search("/") === -1
|
||||
|
|
@ -247,9 +247,11 @@ export class ModifyUI<T extends Type = Type.PANEL, S extends string = string> ex
|
|||
return this.addModifications({
|
||||
array_name: ArrayName.CONTROLS,
|
||||
operation: Operation.INSERT_FRONT,
|
||||
value: {
|
||||
value: [
|
||||
{
|
||||
[`${name}${child}`]: properties || {},
|
||||
},
|
||||
],
|
||||
})
|
||||
}
|
||||
|
||||
|
|
@ -292,7 +294,7 @@ export class ModifyUI<T extends Type = Type.PANEL, S extends string = string> ex
|
|||
}
|
||||
|
||||
insertChild<T extends Type, K extends Renderer | null>(child: UI<T, K>, properties?: Properties<T, K>) {
|
||||
return this.insertBackChild(child, properties)
|
||||
return this.insertFrontChild(child, properties)
|
||||
}
|
||||
|
||||
replaceChild<T extends Type, K extends Renderer | null>(where: S, child: UI<T, K>, properties?: Properties<T, K>) {
|
||||
|
|
@ -334,7 +336,7 @@ export class ModifyUI<T extends Type = Type.PANEL, S extends string = string> ex
|
|||
}
|
||||
|
||||
insertBindings(...bindings: BindingItem[]) {
|
||||
return this.insertBackBindings(...bindings)
|
||||
return this.insertFrontBindings(...bindings)
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -366,7 +368,7 @@ export class ModifyUI<T extends Type = Type.PANEL, S extends string = string> ex
|
|||
}
|
||||
|
||||
insertButtonMappings(...buttonMappings: ButtonMapping[]) {
|
||||
return this.insertBackButtonMappings(...buttonMappings)
|
||||
return this.insertFrontButtonMappings(...buttonMappings)
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
Reference in a new issue