├── .gitignore ├── .npmignore ├── .prettierrc ├── .tsbuildinfo ├── LICENSE ├── README.md ├── bun.lockb ├── package-lock.json ├── package.json ├── resources ├── example_1.png ├── logo.png └── logo_no_bg.png ├── scripts ├── build.ts ├── index.js ├── items.js ├── lib │ ├── github.ts │ └── writeFile.ts ├── scanner │ ├── index.ts │ └── scan.ts └── utils.ts ├── src ├── compilers │ ├── BindingCompiler.ts │ ├── BindingFunctions.ts │ ├── Compiler.ts │ ├── Compress.ts │ ├── Config.ts │ ├── Encoder.ts │ ├── Installer.ts │ ├── PreCompile.ts │ ├── generator │ │ ├── GenerateDir.ts │ │ ├── JsonBuilder.ts │ │ ├── LangBuilder.ts │ │ ├── Log.ts │ │ ├── Manifest.ts │ │ ├── Save.ts │ │ ├── SearchFiles.ts │ │ ├── Sounds.ts │ │ ├── Template.ts │ │ └── UIBuilder.ts │ └── reader │ │ ├── Audio.ts │ │ ├── Color.ts │ │ ├── CurrentLine.ts │ │ ├── Env.ts │ │ ├── GlobalVariables.ts │ │ ├── Object.ts │ │ ├── ReadBinding.ts │ │ └── ReadProperties.ts ├── components │ ├── AddCollectionChill.ts │ ├── Animation.ts │ ├── AnimationKeyFrame.ts │ ├── Class.ts │ ├── ItemDatas.ts │ ├── LocalizeText.ts │ ├── Modify.ts │ ├── Random.ts │ ├── UI.ts │ └── Vanilla.ts ├── index.ts ├── template.ts └── types │ ├── components │ ├── ChildIdentifier.ts │ ├── Identifier.ts │ ├── NameCallback.ts │ ├── UIIdentifier.ts │ └── UIInterface.ts │ ├── enums │ ├── Anchor.ts │ ├── AnimTypes.ts │ ├── BindingCondition.ts │ ├── BindingName.ts │ ├── BindingType.ts │ ├── ClipDirecion.ts │ ├── Collection.ts │ ├── Direction.ts │ ├── EasingTypes.ts │ ├── EnumColor.ts │ ├── FocusNavigationMode.ts │ ├── FontSize.ts │ ├── FontType.ts │ ├── GlobalVariables.ts │ ├── InputModeCondition.ts │ ├── ItemAuxID.ts │ ├── JsonUIArrayName.ts │ ├── MappingFrom.ts │ ├── MappingTo.ts │ ├── MappingTypes.ts │ ├── Orientation.ts │ ├── Renderer.ts │ ├── Rotation.ts │ ├── Scope.ts │ ├── TextTypes.ts │ ├── TextureFileSystem.ts │ └── Types.ts │ ├── objects │ ├── Animation.ts │ ├── BindingHook.ts │ ├── BindingInterface.ts │ ├── ButtonMapping.ts │ ├── Factory.ts │ ├── Manifest.ts │ ├── PropertyBag.ts │ ├── Sound.ts │ ├── Variables.ts │ ├── elements │ │ ├── Button.ts │ │ ├── CollectionPanel.ts │ │ ├── Custom.ts │ │ ├── Dropdown.ts │ │ ├── EditBox.ts │ │ ├── Grid.ts │ │ ├── Image.ts │ │ ├── InputPanel.ts │ │ ├── Label.ts │ │ ├── PropertiesType.ts │ │ ├── Screen.ts │ │ ├── ScrollView.ts │ │ ├── ScrollbarBox.ts │ │ ├── ScrollbarTrack.ts │ │ ├── SelectionWheel.ts │ │ ├── Slider.ts │ │ ├── SliderBox.ts │ │ ├── StackPanel.ts │ │ ├── Toggle.ts │ │ ├── TooltipTrigger.ts │ │ └── panel.ts │ └── properties │ │ ├── Buttons.ts │ │ ├── CollectionIndexs.ts │ │ ├── Collections.ts │ │ ├── Controls.ts │ │ ├── Dropdowns.ts │ │ ├── Focus.ts │ │ ├── FocusContainerCustom.ts │ │ ├── Grids.ts │ │ ├── Inputs.ts │ │ ├── Layouts.ts │ │ ├── Properties.ts │ │ ├── Renderers.ts │ │ ├── Screens.ts │ │ ├── ScrollViews.ts │ │ ├── SelectionWheels.ts │ │ ├── SliderBoxs.ts │ │ ├── Sliders.ts │ │ ├── Sounds.ts │ │ ├── Specials.ts │ │ ├── Sprites.ts │ │ ├── StackPanels.ts │ │ ├── TTS.ts │ │ ├── TextEdits.ts │ │ ├── Texts.ts │ │ ├── Toggles.ts │ │ ├── TooltipTriggers.ts │ │ └── Variables.ts │ └── values │ ├── Any.ts │ ├── Binding.ts │ ├── Bool.ts │ ├── ColorVector.ts │ ├── ElementPath.ts │ ├── Hex.ts │ ├── Number.ts │ ├── RangeVector.ts │ ├── Str.ts │ ├── StringVector.ts │ ├── TargetElementPath.ts │ ├── Variable.ts │ └── Vector.ts ├── tsconfig.json └── yarn.lock /.gitignore: -------------------------------------------------------------------------------- 1 | ui.d.json 2 | dist 3 | node_modules 4 | .Vanilla 5 | .gitignore -------------------------------------------------------------------------------- /.npmignore: -------------------------------------------------------------------------------- 1 | .Vanilla 2 | node_modules 3 | resources 4 | scripts 5 | src 6 | ui.d.json 7 | tsconfig.json -------------------------------------------------------------------------------- /.prettierrc: -------------------------------------------------------------------------------- 1 | { 2 | "semi": true, 3 | "printWidth": 100, 4 | "arrowParens": "avoid", 5 | "tabWidth": 4 6 | } 7 | -------------------------------------------------------------------------------- /.tsbuildinfo: -------------------------------------------------------------------------------- 1 | {"version":"5.7.3"} -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2024 Asaki Yuki 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # JsonUI Scripting 2 | 3 | 4 | 5 |

JsonUI Scripting is an open-source library that uses the JavaScript programming language to build a JsonUI pack with class structures that make it easy to manipulate and edit the UI of Minecraft: Bedrock Edition.

6 | 7 |

This library also includes a built-in Binding compiler, enabling the use of operators and functions that JsonUI lacks, making binding code more convenient and easier to code!

8 | 9 | # Installation 10 | 11 |

To install it into your project, you need to have Node.js pre-installed to use it!

12 | 13 |

You also need to create a project and use the following command to start using JsonUI Scripting:

14 | 15 | ```batch 16 | npm install jsonui-scripting 17 | ``` 18 | 19 |

That command will add the JsonUI Scripting library to your project, and you can start using it.

20 | 21 | # How to use 22 | 23 |

The syntax is very simple. If you just want to display the text "Hello World" on the main screen, here is the code for that:

24 | 25 | ```javascript 26 | const { UI, Vanilla, Anchor } = require("jsonui-scripting"); 27 | 28 | const label = UI.label({ 29 | text: "Hello World!", 30 | anchor: Anchor.TopMiddle, 31 | y: 15, 32 | layer: 50, 33 | }); 34 | 35 | Vanilla.start.startScreenContent().addChild(label); 36 | ``` 37 | 38 |

And you just need to run the code you wrote, and here is the result:

39 | 40 |

41 | 42 |

43 | -------------------------------------------------------------------------------- /bun.lockb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AsakiYuki/JsonUI-Scripting/c314abb8cd41706c8b65a3222000b64cfa542fd3/bun.lockb -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "devDependencies": { 3 | "@types/adm-zip": "^0.5.7", 4 | "@types/fs-extra": "^11.0.4", 5 | "@types/node": "^22.10.5", 6 | "debounce-fn": "^6.0.0", 7 | "esbuild": "^0.25.0", 8 | "tiny-glob": "^0.2.9", 9 | "typescript": "^5.7.3" 10 | }, 11 | "dependencies": { 12 | "adm-zip": "^0.5.16", 13 | "jsonc-parser": "^3.3.1" 14 | }, 15 | "name": "jsonui-scripting", 16 | "version": "2.3.3", 17 | "description": "Make your Minecraft JsonUI with ScriptingAPI", 18 | "main": "./dist/cjs/index.js", 19 | "module": "./dist/esm/index.js", 20 | "types": "./dist/types/index.d.ts", 21 | "scripts": { 22 | "build": "bun run ./scripts/build.ts --types", 23 | "dev": "bun run ./scripts/build.ts --watch --sourcemap", 24 | "ui-pull": "bun scripts/scanner/scan.ts", 25 | "ui-build": "bun scripts/scanner/index.ts", 26 | "import": "bun scripts/index.js", 27 | "items": "bun scripts/items.js", 28 | "stable": "yarn run ui-pull && yarn run ui-build && yarn run import && yarn run build", 29 | "preview": "yarn run stable --preview" 30 | }, 31 | "repository": { 32 | "type": "git", 33 | "url": "git+https://github.com/asakiyuki/jsonui-scripting.git" 34 | }, 35 | "keywords": [ 36 | "Minecraft", 37 | "JsonUI" 38 | ], 39 | "author": "AsakiYuki", 40 | "contributors": [ 41 | "NguyenDuck" 42 | ], 43 | "license": "MIT", 44 | "bugs": { 45 | "url": "https://github.com/asakiyuki/jsonui-scripting/issues" 46 | }, 47 | "homepage": "https://github.com/asakiyuki/jsonui-scripting#readme" 48 | } 49 | -------------------------------------------------------------------------------- /resources/example_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AsakiYuki/JsonUI-Scripting/c314abb8cd41706c8b65a3222000b64cfa542fd3/resources/example_1.png -------------------------------------------------------------------------------- /resources/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AsakiYuki/JsonUI-Scripting/c314abb8cd41706c8b65a3222000b64cfa542fd3/resources/logo.png -------------------------------------------------------------------------------- /resources/logo_no_bg.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AsakiYuki/JsonUI-Scripting/c314abb8cd41706c8b65a3222000b64cfa542fd3/resources/logo_no_bg.png -------------------------------------------------------------------------------- /scripts/build.ts: -------------------------------------------------------------------------------- 1 | import debounceFn from "debounce-fn"; 2 | import { buildSync } from "esbuild"; 3 | import { rmSync, watch, writeFileSync } from "fs"; 4 | import path from "path"; 5 | import { performance } from "perf_hooks"; 6 | import glob from "tiny-glob"; 7 | import ts, { CompilerOptions } from "typescript"; 8 | import { DateUtils } from "./utils"; 9 | 10 | const buildTypes = process.argv.includes("--types"); 11 | const sourcemap = process.argv.includes("--sourcemap"); 12 | const watchMode = process.argv.includes("--watch"); 13 | 14 | async function build() { 15 | console.clear(); 16 | const startTime = performance.now(); 17 | 18 | console.log("\x1b[32mCleaning dist directory\x1b[0m"); 19 | rmSync("dist/cjs", { 20 | force: true, 21 | recursive: true, 22 | }); 23 | rmSync("dist/esm", { 24 | force: true, 25 | recursive: true, 26 | }); 27 | 28 | const target = ["ESNext", "node8.17"]; 29 | const entryPoints = await glob("./src/**/*.ts"); 30 | 31 | console.log("\x1b[34mBuilding dist for node (cjs)...\x1b[0m"); 32 | buildSync({ 33 | entryPoints, 34 | outdir: "./dist/cjs", 35 | bundle: false, 36 | sourcemap, 37 | minify: false, 38 | format: "cjs", 39 | platform: "node", 40 | target, 41 | }); 42 | writeFileSync("./dist/cjs/package.json", '{"type": "commonjs"}', { 43 | flag: "w", 44 | }); 45 | 46 | console.log("\x1b[34mBuilding dist for node type=module (esm)...\x1b[0m"); 47 | buildSync({ 48 | entryPoints: ["./src/index.ts"], 49 | outdir: "./dist/esm", 50 | bundle: true, 51 | sourcemap, 52 | minify: false, 53 | splitting: true, 54 | format: "esm", 55 | platform: "node", 56 | target, 57 | }); 58 | writeFileSync("./dist/esm/package.json", '{"type": "module"}', { 59 | flag: "w", 60 | }); 61 | 62 | const endTime = performance.now(); 63 | const executionTime = (endTime - startTime) / 1000; 64 | console.log(`\x1b[32mBuild Success with execution time ${executionTime.toFixed(2)}s\x1b[0m`); 65 | } 66 | 67 | const compilerOptions: CompilerOptions = { 68 | declaration: true, 69 | emitDeclarationOnly: true, 70 | declarationDir: "./dist/types/", 71 | }; 72 | 73 | let program: ts.Program | undefined; 74 | 75 | async function setupCompiler() { 76 | const configPath = ts.findConfigFile("../", ts.sys.fileExists, "tsconfig.json"); 77 | if (!configPath) { 78 | throw new Error("tsconfig.json not found"); 79 | } 80 | 81 | const configFile = ts.readConfigFile(configPath, ts.sys.readFile); 82 | const parsedConfig = ts.parseJsonConfigFileContent( 83 | configFile.config, 84 | ts.sys, 85 | path.dirname(configPath) 86 | ); 87 | 88 | return ts.createProgram(parsedConfig.fileNames, { 89 | ...parsedConfig.options, 90 | ...compilerOptions, 91 | }); 92 | } 93 | 94 | async function generateTypes() { 95 | const start = performance.now(); 96 | console.log(`\x1b[34mGenerating declaration types...\x1b[0m`); 97 | 98 | if (!program) program = await setupCompiler(); 99 | 100 | const emitResult = program.emit(); 101 | 102 | const allDiagnostics = ts.getPreEmitDiagnostics(program).concat(emitResult.diagnostics); 103 | 104 | if (allDiagnostics.length) 105 | console.log( 106 | ts.formatDiagnosticsWithColorAndContext(allDiagnostics, { 107 | getCanonicalFileName: n => n, 108 | getCurrentDirectory: () => process.cwd(), 109 | getNewLine: () => "\n", 110 | }) 111 | ); 112 | console.log( 113 | "\x1b[34mBuild types completed in", 114 | DateUtils.greatestFormat(performance.now() - start), 115 | "\x1b[0m" 116 | ); 117 | } 118 | 119 | function run() { 120 | build(); 121 | buildTypes && generateTypes(); 122 | } 123 | 124 | run(); 125 | 126 | if (watchMode) { 127 | watch("./src", { recursive: true }, debounceFn(run, { wait: 300 })); 128 | } 129 | -------------------------------------------------------------------------------- /scripts/index.js: -------------------------------------------------------------------------------- 1 | const fs = require("fs"); 2 | function searchFilePaths(path = "", isStart = true) { 3 | const importArr = []; 4 | for (const folder of fs.readdirSync(`./src/${path}`)) { 5 | if ( 6 | [ 7 | "index.ts", 8 | "Class.ts", 9 | "Config.ts", 10 | "items.json", 11 | "Files", 12 | "Env.ts", 13 | "GlobalVariables.ts", 14 | "API", 15 | "Template.ts", 16 | "PreCompile.ts", 17 | "template.ts", 18 | "create-app.ts", 19 | 20 | // Bug 21 | "ItemAuxID.ts", 22 | "ItemDatas.ts", 23 | ].includes(folder) 24 | ) { 25 | continue; 26 | } else { 27 | if (folder.split(".").length === 2) 28 | importArr.push(`export * from "./${path}${folder.replace(".ts", "")}";`); 29 | else importArr.push(...searchFilePaths(`${path}${folder}/`, false)); 30 | } 31 | } 32 | return isStart 33 | ? [ 34 | `import "./compilers/PreCompile";`, 35 | `import "./compilers/generator/Template";`, 36 | `export * from "./compilers/Config";`, 37 | ...importArr, 38 | ].join("\n") 39 | : importArr; 40 | } 41 | fs.writeFileSync( 42 | "./src/index.ts", 43 | `console.time("COMPILER"); 44 | ${searchFilePaths()} 45 | export * from "./compilers/reader/Env"; 46 | export * from "./compilers/reader/GlobalVariables";`, 47 | "utf-8" 48 | ); 49 | -------------------------------------------------------------------------------- /scripts/items.js: -------------------------------------------------------------------------------- 1 | const fs = require("fs"); 2 | (async () => { 3 | const itemsList = await fetch("https://api.asakiyuki.com/games/minecraft/item-ids").then(v => 4 | v.json() 5 | ); 6 | 7 | const list = []; 8 | 9 | for (const key in itemsList) { 10 | const id = itemsList[key]; 11 | list.push(` '${key}' = ${id * 65536}`); 12 | } 13 | 14 | fs.writeFileSync( 15 | "src/types/enums/ItemAuxID.ts", 16 | `export enum ItemAuxID {\n${list.join(",\n")}\n}`, 17 | "utf-8" 18 | ); 19 | })(); 20 | -------------------------------------------------------------------------------- /scripts/lib/github.ts: -------------------------------------------------------------------------------- 1 | export async function readGithubFile( 2 | user: string, 3 | project: string, 4 | branches: string, 5 | path: string 6 | ) { 7 | const data = await fetch( 8 | `https://raw.githubusercontent.com/${user}/${project}/refs/heads/${branches}/${path}` 9 | ).then((v) => v.text()); 10 | return data; 11 | } 12 | -------------------------------------------------------------------------------- /scripts/lib/writeFile.ts: -------------------------------------------------------------------------------- 1 | import fs from "fs"; 2 | import path from "path"; 3 | 4 | export function safeWriteFile(filePath: string, data: string) { 5 | const dir = path.dirname(filePath); 6 | 7 | if (!fs.existsSync(dir)) { 8 | fs.mkdirSync(dir, { recursive: true }); 9 | } 10 | 11 | try { 12 | fs.writeFileSync(filePath, data, { encoding: "utf-8" }); 13 | } catch (error) { 14 | console.error(`Error writing file: ${filePath}`, error); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /scripts/scanner/scan.ts: -------------------------------------------------------------------------------- 1 | import { parse } from "jsonc-parser"; 2 | import { readGithubFile } from "../lib/github"; 3 | import { safeWriteFile } from "../lib/writeFile"; 4 | 5 | const userName = "mojang"; 6 | const project = "bedrock-samples"; 7 | const branches = process.argv.includes("--preview") ? "preview" : "main"; 8 | 9 | async function getMCJsonFile(path: string) { 10 | try { 11 | return parse(await readGithubFile(userName, project, branches, path)); 12 | } catch (error) {} 13 | } 14 | 15 | (async () => { 16 | const { ui_defs }: { ui_defs: string[] } = await getMCJsonFile( 17 | "resource_pack/ui/_ui_defs.json" 18 | ); 19 | 20 | let count = 0; 21 | 22 | await Promise.all( 23 | ui_defs.map(async path => { 24 | const data = await getMCJsonFile(`resource_pack/${path}`); 25 | if (data !== undefined) safeWriteFile(`.Vanilla/${path}`, JSON.stringify(data)); 26 | console.log(`[${++count}/${ui_defs.length}] Writed: rsp/${path} -> .Vanilla/${path}`); 27 | }) 28 | ); 29 | })(); 30 | -------------------------------------------------------------------------------- /scripts/utils.ts: -------------------------------------------------------------------------------- 1 | export class DateUtils { 2 | public static greatestFormat(time: number): string { 3 | const units = new Map([ 4 | ["ms", 1000], 5 | ["s", 60], 6 | ["m", 60], 7 | ]); 8 | 9 | const values: number[] = []; 10 | 11 | units.forEach(v => { 12 | if (time == 0) return; 13 | 14 | if (time >= v) { 15 | values.push(time % v); 16 | time /= v; 17 | } else { 18 | values.push(time); 19 | time = 0; 20 | } 21 | }); 22 | 23 | const unitsArray = Array.from(units.keys()); 24 | 25 | return values.reduce((a, c, i) => { 26 | return `${c.toFixed(i <= 1 ? 2 : 0)}${unitsArray[i]}${i <= 1 ? "" : " " + a}`; 27 | }, ""); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /src/compilers/Compiler.ts: -------------------------------------------------------------------------------- 1 | import fs from "fs"; 2 | import { Manifest } from "./generator/Manifest"; 3 | import { UIBuilder } from "./generator/UIBuilder"; 4 | import { ResourcePacks, Minecraft, ResourcePack } from "./Installer"; 5 | import { Configs } from "./Config"; 6 | import { CompressPack } from "./Compress"; 7 | import { SoundHandler as Sounds } from "./generator/Sounds"; 8 | import { FormatAudio } from "./reader/Audio"; 9 | import { Logs } from "./generator/Log"; 10 | import { Encoder } from "./Encoder"; 11 | import { UIWriteJson } from "./PreCompile"; 12 | import { localizeText } from "../components/LocalizeText"; 13 | import { LangBuilder } from "./generator/LangBuilder"; 14 | 15 | // Retrieve the configuration settings 16 | const config = Configs.getConfig(); 17 | 18 | /** 19 | * Installs the resource pack using the provided configuration and paths. 20 | * The installer uses either the Minecraft Preview or Stable version based on the config settings. 21 | * It also installs to either the development or production environment based on the config. 22 | */ 23 | export const installer = new ResourcePacks({ 24 | installGame: config.installer.previewVersion ? Minecraft.Preview : Minecraft.Stable, 25 | installFolder: config.installer.developEvironment 26 | ? ResourcePack.Development 27 | : ResourcePack.Production, 28 | }); 29 | 30 | /** 31 | * Builds the manifest file for the resource pack and writes it to the specified installation path. 32 | * 33 | * @param {string} installPath - The directory path where the manifest file will be saved. 34 | * 35 | * @returns {void} - This function does not return any value. 36 | */ 37 | function manifestBuild(installPath: string): void { 38 | const { name, description, uuid, version, baseGameVersion } = config.manifest; 39 | const manifest = new Manifest({ name, description, uuid, version }); 40 | manifest.manifest.header.min_engine_version = baseGameVersion; 41 | 42 | UIWriteJson(`${installPath}/manifest.json`, manifest.manifest, "utf-8"); 43 | } 44 | 45 | let isRunned = false; 46 | process.on("beforeExit", () => { 47 | if (isRunned) return; 48 | isRunned = true; 49 | 50 | const installPath = installer.getInstallPath(); 51 | 52 | config.installer.autoInstall = 53 | config.installer.autoInstall && fs.existsSync(installer.installPath); 54 | 55 | const buildPath = config.installer.autoInstall ? installPath : ".build"; 56 | 57 | // Clean up temporary build directories 58 | UIBuilder.delete(buildPath); 59 | if (fs.existsSync(".build")) fs.rmSync(".build", { recursive: true }); 60 | if (fs.existsSync(".minecraft")) fs.unlinkSync(".minecraft"); 61 | 62 | // Create necessary directories if they do not exist 63 | if (!fs.existsSync(`.bedrock`)) fs.mkdirSync(".bedrock"); 64 | if (!fs.existsSync(`${buildPath}`)) fs.mkdirSync(`${buildPath}`); 65 | if (!fs.existsSync(`${buildPath}/@`)) fs.mkdirSync(`${buildPath}/@`); 66 | 67 | try { 68 | console.log("---------- COMPILING ----------"); 69 | 70 | FormatAudio(); 71 | 72 | // Perform actions depending on whether the build is within the project or external 73 | if (config.installer.autoInstall) { 74 | installer.packLink(); 75 | console.timeLog("COMPILER", "Symlink completed!"); 76 | console.log(); 77 | } 78 | 79 | // Copy bedrock resources to build path 80 | fs.cpSync(".bedrock", buildPath, { recursive: true }); 81 | console.timeLog("COMPILER", "Copy bedrock resources completed!"); 82 | console.log(); 83 | 84 | // Compile various UI files 85 | console.timeLog("COMPILER", `${UIBuilder.jsonUI(buildPath)} custom file(s) compiled!`); 86 | console.log(); 87 | console.timeLog("COMPILER", `${UIBuilder.modify(buildPath)} modify file(s) compiled!`); 88 | console.log(); 89 | if (Object.keys(localizeText).length) { 90 | console.timeLog("COMPILER", `${LangBuilder.build(buildPath)} lang file(s) compiled!`); 91 | console.log(); 92 | } 93 | 94 | // Generate and save the manifest 95 | manifestBuild(buildPath); 96 | console.timeLog("COMPILER", `Manifest file has been compiled!`); 97 | 98 | // Compile UI and other required resources 99 | console.timeLog( 100 | "COMPILER", 101 | `ui/_ui_defs.json ${UIBuilder.uiDefs(buildPath)} files path(s) found!` 102 | ); 103 | console.timeLog( 104 | "COMPILER", 105 | `ui/_global_variables.json ${UIBuilder.globalVariables( 106 | buildPath 107 | )} variable(s) compiled!` 108 | ); 109 | console.timeLog( 110 | "COMPILER", 111 | `textures/textures_list.json ${UIBuilder.texturesList(buildPath)} files path(s) found!` 112 | ); 113 | 114 | const soundLength = Sounds.compile(buildPath); 115 | if (soundLength) 116 | console.timeLog( 117 | "COMPILER", 118 | `sounds/sound_definitions.json ${soundLength} sound id has regisrer!` 119 | ); 120 | 121 | console.timeLog( 122 | "COMPILER", 123 | `contents.json ${UIBuilder.contents(buildPath)} file path(s) found!` 124 | ); 125 | 126 | // Install the resource pack if not building within the project 127 | if (config.installer.autoInstall) { 128 | installer.installPack(config.manifest.uuid, config.manifest.version); 129 | console.timeLog("COMPILER", `Resource Pack has been installed!`); 130 | } 131 | 132 | // Compress the pack if enabled in the config 133 | if (config.compiler.autoCompress) { 134 | CompressPack(buildPath); 135 | console.timeLog("COMPILER", "Minecraft-UIBuild.mcpack Pack compress completed!"); 136 | } 137 | 138 | // Encode json code 139 | if (config.compiler.encodeJson) { 140 | Encoder.start(); 141 | console.timeLog("COMPILER", `Encoded ${Encoder.count} JSON file(s) successfully!`); 142 | } 143 | 144 | // Final log of compilation completion 145 | console.log(); 146 | console.timeLog("COMPILER", "Compile completed!"); 147 | 148 | // Warning log 149 | if (Logs.length) { 150 | console.log("\n---------- Build Log ----------"); 151 | 152 | for (const log of Logs) { 153 | if (log.type === "warning") console.warn(log.message); 154 | else if (log.type === "error") console.error(log.message); 155 | } 156 | } 157 | 158 | // Display relevant information 159 | console.log("\n---------- INFO ----------"); 160 | console.log(`Name: \x1b[96m${config.manifest.name}\x1b[0m`); 161 | console.log(`Description: \x1b[96m${config.manifest.description}\x1b[0m`); 162 | console.log(`UUID: \x1b[96m${config.manifest.uuid}\x1b[0m`); 163 | console.log( 164 | `Pack Version: \x1b[96m${config.manifest.version[0]}.${config.manifest.version[1]}.${config.manifest.version[2]}\x1b[0m` 165 | ); 166 | console.log( 167 | `Base Game Version: \x1b[96m${config.manifest.baseGameVersion[0]}.${config.manifest.baseGameVersion[1]}.${config.manifest.baseGameVersion[2]}\x1b[0m` 168 | ); 169 | 170 | // Print install path if not building within the project 171 | if (config.installer.autoInstall) 172 | console.log(`Install Path: \x1b[96m${installPath}\x1b[0m`); 173 | } catch (error) { 174 | // Handle any errors during the compilation process 175 | console.timeLog("COMPILER", "An error occurred while compiling!"); 176 | console.error(error); 177 | } 178 | }); 179 | 180 | export { }; 181 | -------------------------------------------------------------------------------- /src/compilers/Compress.ts: -------------------------------------------------------------------------------- 1 | import fs from "fs"; 2 | import AdmZip from "adm-zip"; 3 | import { SearchFiles } from "./generator/SearchFiles"; 4 | 5 | /** 6 | * Compresses the specified build directory into a `.mcpack` file. 7 | * 8 | * This function checks if a file named `Minecraft-UIBuild.mcpack` already exists and deletes it. 9 | * It then creates a new zip archive, adding files from the provided `buildPath` using the 10 | * `SearchFiles` generator. The resulting zip file is written as `Minecraft-UIBuild.mcpack`. 11 | * 12 | * @param {string} buildPath - The path to the directory containing the files to be compressed. 13 | * 14 | * @returns {void} - This function does not return any value. 15 | */ 16 | export function CompressPack(buildPath: string): void { 17 | if (fs.existsSync("Minecraft-UIBuild.mcpack")) 18 | fs.rmSync("Minecraft-UIBuild.mcpack"); 19 | 20 | const zip = new AdmZip(undefined, { 21 | fs, 22 | }); 23 | 24 | SearchFiles.forEach(buildPath, (path) => { 25 | const pathSplit = path.path.split("/"); 26 | zip.addLocalFile( 27 | `${buildPath}/${path.path}`, 28 | pathSplit.length !== 1 29 | ? pathSplit.slice(0, pathSplit.length - 1).join("/") 30 | : undefined 31 | ); 32 | }); 33 | 34 | zip.writeZip("Minecraft-UIBuild.mcpack"); 35 | } 36 | -------------------------------------------------------------------------------- /src/compilers/Config.ts: -------------------------------------------------------------------------------- 1 | import { UUID } from "crypto"; 2 | import { Save } from "./generator/Save"; 3 | import { Obj } from "./reader/Object"; 4 | import { firstRun } from "./generator/Template"; 5 | import { SemverString, Version } from "../types/objects/Manifest"; 6 | 7 | firstRun(); 8 | 9 | const defaultConfig: Config = { 10 | compiler: { 11 | encodeJson: false, 12 | autoCompress: false, 13 | fileExtension: "json", 14 | UI: { 15 | nameLength: 32, 16 | namespaceAmount: 16, 17 | namespaceLength: 32, 18 | obfuscateName: false, 19 | obfuscateType: false, 20 | }, 21 | }, 22 | installer: { 23 | autoInstall: true, 24 | developEvironment: true, 25 | previewVersion: false, 26 | customPath: false, 27 | installPath: undefined, 28 | }, 29 | manifest: { 30 | name: "JsonUI Scripting", 31 | description: "Build with JsonUI Scripting <3", 32 | uuid: Save.uuid()[0], 33 | version: [1, 0, 0], 34 | baseGameVersion: [1, 21, 80], 35 | }, 36 | }; 37 | 38 | /** 39 | * Interface representing the structure of a config manifest. 40 | * This is used to define the metadata of the resource pack. 41 | */ 42 | interface ConfigManifest { 43 | name: string; 44 | description: string; 45 | version: Version | SemverString; 46 | baseGameVersion: Version; 47 | uuid: UUID; 48 | } 49 | 50 | interface ConfigCompilerUI { 51 | obfuscateName: boolean; 52 | obfuscateType: boolean; 53 | nameLength: number; 54 | namespaceLength: number; 55 | namespaceAmount: number; 56 | } 57 | 58 | interface ConfigCompiler { 59 | UI: ConfigCompilerUI; 60 | autoCompress: boolean; 61 | fileExtension: string; 62 | encodeJson: boolean; 63 | } 64 | 65 | interface ConfigInstaller { 66 | autoInstall: boolean; 67 | developEvironment: boolean; 68 | previewVersion: boolean; 69 | customPath: boolean; 70 | installPath?: string; 71 | } 72 | 73 | export interface Config { 74 | installer: ConfigInstaller; 75 | compiler: ConfigCompiler; 76 | manifest: ConfigManifest; 77 | } 78 | 79 | /** 80 | * Reads an object and applies default values where necessary. 81 | * 82 | * This function allows deeply nested objects to be filled with default values when they are undefined. 83 | * 84 | * @param {object} [obj] - The object to read and apply the default values to. 85 | * @param {object} [defaultObjValue] - The default values to use if any properties in `obj` are undefined. 86 | * @returns {object} - The object with default values applied. 87 | */ 88 | export function readObject(obj?: object, defaultObjValue?: object) { 89 | if (Array.isArray(defaultObjValue)) { 90 | if (!obj) obj = []; 91 | defaultObjValue.forEach((value, index) => { 92 | (obj)[index] = (obj)[index] ?? value; 93 | }); 94 | return obj; 95 | } else { 96 | if (!obj) obj = {}; 97 | Obj.forEach(defaultObjValue || {}, (key, value) => { 98 | if (typeof value === "object") { 99 | (obj)[key] = readObject((obj)[key], (defaultObjValue)[key]); 100 | } else { 101 | (obj)[key] = (obj)[key] ?? (defaultObjValue)[key]; 102 | } 103 | }); 104 | return obj; 105 | } 106 | } 107 | 108 | /** 109 | * A class to manage and load configuration settings. 110 | * 111 | * The class allows reading from a configuration file and merging the saved configuration 112 | * with default values when necessary. 113 | */ 114 | export class Configs { 115 | /** 116 | * The current loaded configuration saved to disk. 117 | */ 118 | save: Config; 119 | 120 | /** 121 | * The statically cached configuration. 122 | */ 123 | static config: Config; 124 | 125 | /** 126 | * Loads the configuration file and parses it into the `save` property. 127 | */ 128 | constructor() { 129 | this.save = require(`${process.cwd()}/asakiyuki.config.cjs`).config; 130 | } 131 | 132 | /** 133 | * Retrieves the current configuration, either from the saved configuration or the default values. 134 | * 135 | * @returns {Config} - The configuration object. 136 | */ 137 | static getConfig(): Config { 138 | if (Configs.config === undefined) { 139 | const defaultConfig = Configs.getDefaultConfig(); 140 | const saveConfig = new Configs().save; 141 | return readObject(saveConfig, defaultConfig) as Config; 142 | } else return Configs.config; 143 | } 144 | 145 | /** 146 | * Retrieves the default configuration values. 147 | * 148 | * @returns {Config} - The default configuration object. 149 | */ 150 | static getDefaultConfig(): Config { 151 | return defaultConfig; 152 | } 153 | 154 | // Static helper methods not directly related to config loading/handling. 155 | private static apply() { } 156 | private static arguments = ""; 157 | private static bind() { } 158 | private static call() { } 159 | private static caller = ""; 160 | private static length = ""; 161 | private static name = ""; 162 | private static toString() { } 163 | } 164 | 165 | /** 166 | * Exporting the Configs class to be used globally. 167 | * 168 | * This allows other modules to access the configuration settings through `config`. 169 | */ 170 | export const config = Configs; 171 | 172 | Configs.getConfig(); 173 | -------------------------------------------------------------------------------- /src/compilers/Encoder.ts: -------------------------------------------------------------------------------- 1 | import fs from "fs"; 2 | import { Class } from "../components/Class"; 3 | import { jsonFilePath, WritePreComment } from "./PreCompile"; 4 | import { Obj } from "./reader/Object"; 5 | 6 | export class Encoder extends Class { 7 | static count: number = 0; 8 | 9 | static start() { 10 | for (const path of jsonFilePath) { 11 | const code = Encoder.readCode(path); 12 | const encode = Encoder.encode(code); 13 | Encoder.replaceCode(path, encode); 14 | Encoder.count++; 15 | } 16 | } 17 | 18 | static replaceCode(path: string, code: any) { 19 | fs.writeFileSync(path, WritePreComment(code).replaceAll("\\\\", "\\"), "utf-8"); 20 | } 21 | 22 | static encode(code: any): any { 23 | return Array.isArray(code) ? Encoder.encodeArray(code) : Encoder.encodeObject(code); 24 | } 25 | 26 | static encodeArray(code: any[]): any[] { 27 | return code.map(value => { 28 | const valueType = typeof value; 29 | 30 | if (valueType === "object") { 31 | return Encoder.encode(value); 32 | } else if (valueType === "string") return Encoder.encodeString(value); 33 | else return value; 34 | }); 35 | } 36 | 37 | static encodeObject(code: any): object { 38 | return Obj.map(code, (key, value): any => { 39 | const valueType = typeof value; 40 | key = Encoder.encodeString(key); 41 | 42 | if (valueType === "object") { 43 | return { 44 | key, 45 | value: Encoder.encode(value), 46 | }; 47 | } else if (valueType === "string") { 48 | return { key, value: Encoder.encodeString(value) }; 49 | } else return { key, value }; 50 | }); 51 | } 52 | 53 | static encodeString(code: string) { 54 | return Array.from(code) 55 | .map(char => `\\u${char.charCodeAt(0).toString(16).padStart(4, "0")}`) 56 | .join(""); 57 | } 58 | 59 | static readCode(path: string) { 60 | return JSON.parse(fs.readFileSync(path, "utf-8")); 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /src/compilers/PreCompile.ts: -------------------------------------------------------------------------------- 1 | import fs from "fs"; 2 | import { Configs } from "./Config"; 3 | 4 | if (!fs.existsSync("comment.txt")) { 5 | fs.writeFileSync("comment.txt", "", "utf-8"); 6 | } 7 | 8 | const timeMap: Record = {}; 9 | 10 | console.time = function (label: string) { 11 | timeMap[label] = performance.now(); 12 | }; 13 | 14 | console.timeLog = function (tag: string, ...data) { 15 | const now = performance.now(); 16 | const time = now - timeMap[tag]; 17 | console.log( 18 | `\x1b[90m[${time.toFixed(2)}ms]`, 19 | `\x1b[32m[${tag}]\x1b[0m`, 20 | ">>", 21 | ...data, 22 | "\x1b[0m" 23 | ); 24 | }; 25 | 26 | console.timeEnd = function (label: string) { 27 | delete timeMap[label]; 28 | }; 29 | 30 | export function WritePreComment(data: any) { 31 | const comment = 32 | "This file is generated by the JSONUI SCRIPTING compiler. Do not edit it directly."; 33 | 34 | if (fs.readFileSync("comment.txt", "utf-8").trim() !== "") { 35 | const info = fs.readFileSync("comment.txt", "utf-8").replaceAll("\n", "\n * "); 36 | return `/*\n * ${comment}\n * ----------------------------------------------------------------------\n * ${info}\n */\n${JSON.stringify( 37 | data 38 | )}`; 39 | } else { 40 | return `// ${comment}\n${JSON.stringify(data)}`; 41 | } 42 | } 43 | 44 | export const jsonFilePath: string[] = []; 45 | export function UIWriteJson(file: string, data: any, options?: fs.WriteFileOptions) { 46 | if (Configs.getConfig().compiler.encodeJson) { 47 | fs.writeFileSync(file, JSON.stringify(data), options); 48 | } else { 49 | fs.writeFileSync(file, WritePreComment(data), options); 50 | } 51 | jsonFilePath.push(file); 52 | } 53 | -------------------------------------------------------------------------------- /src/compilers/generator/GenerateDir.ts: -------------------------------------------------------------------------------- 1 | import fs from "fs"; 2 | 3 | /** 4 | * Creates the necessary directories (folders) in the specified path before placing files in them. 5 | * This ensures that no errors occur due to missing directories. 6 | * 7 | * @param {string} installPath - The root installation path where the folders will be created. 8 | * @param {string} path - The relative folder path to be created within the `installPath`. 9 | * 10 | * @returns {void} 11 | * 12 | * @example 13 | * // Example usage: 14 | * // Generates the folder structure for "folder1/folder2" inside "/install/path". 15 | * GenerateDir("/install/path", "folder1/folder2"); 16 | */ 17 | export function GenerateDir(installPath: string, path?: string): void { 18 | path = path ? `${installPath}/${path}` : installPath; 19 | 20 | if (!fs.existsSync(path)) { 21 | let lastPath = ""; 22 | const folderPath = path.split("/") || []; 23 | folderPath.pop(); 24 | for (const folder of folderPath) { 25 | if (!(folder === "" || fs.existsSync(`${lastPath}${folder}`))) 26 | fs.mkdirSync(`${lastPath}${folder}`); 27 | lastPath = `${lastPath}${folder}/`; 28 | } 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /src/compilers/generator/JsonBuilder.ts: -------------------------------------------------------------------------------- 1 | import { AnimationKeyFrame } from "../../components/AnimationKeyFrame"; 2 | import { Class } from "../../components/Class"; 3 | import { Modify } from "../../components/Modify"; 4 | import { UI } from "../../components/UI"; 5 | import { Configs } from "../Config"; 6 | import { CurrentLine } from "../reader/CurrentLine"; 7 | import { Log } from "./Log"; 8 | 9 | interface JsonObject { 10 | build: { 11 | [file: string]: { 12 | namespace: string; 13 | [element: string]: any; 14 | }; 15 | }; 16 | modify: { 17 | [modifyFilePath: string]: { 18 | [path: string]: Modify; 19 | }; 20 | }; 21 | globalVariables: { 22 | [key: `$${string}`]: any; 23 | }; 24 | } 25 | 26 | /** 27 | * A utility class responsible for registering and processing JSON blocks, such as global variables, UI elements, and modifications to UI elements. 28 | * It provides functionality to register, modify, and retrieve elements that are later used for UI construction or modification. 29 | * 30 | * @class JsonBuilder 31 | */ 32 | export class JsonBuilder extends Class { 33 | /** 34 | * A static object that holds the state of saved JSON blocks. 35 | * - `build`: Contains the registered UI elements and animation keyframes. 36 | * - `globalVariables`: Contains global variables for the UI. 37 | * - `modify`: Contains elements that will be modified. 38 | * 39 | * @static 40 | * @type {JsonObject} 41 | */ 42 | static save: JsonObject = { 43 | build: {}, 44 | globalVariables: {}, 45 | modify: {}, 46 | }; 47 | 48 | /** 49 | * Registers a global variable with a given key and value. 50 | * The global variable is stored in the `globalVariables` block under the specified key. 51 | * 52 | * @param {string} key - The key under which the global variable will be stored. 53 | * @param {any} value - The value of the global variable to be stored. 54 | * @returns {void} 55 | * @static 56 | */ 57 | static registerGlobalVariable(key: string, value: any): void { 58 | this.save.globalVariables[`$${key}`] = value; 59 | } 60 | 61 | /** 62 | * Registers a UI element or animation keyframe under a specified namespace. 63 | * The element is stored in the `build` block, with its full path as the key and the element as the value. 64 | * 65 | * @param {string} namespace - The namespace under which the element will be registered. 66 | * @param {UI | AnimationKeyFrame} element - The UI element or animation keyframe to be registered. 67 | * @returns {void} 68 | * @static 69 | */ 70 | static registerElement(namespace: string, element: UI | AnimationKeyFrame): void { 71 | const extension = Configs.getConfig().compiler.fileExtension; 72 | const buildFile = (this.save.build[ 73 | `${namespace}${extension === "" ? "" : `.${extension}`}` 74 | ] ||= { namespace }); 75 | 76 | for (const e in buildFile) { 77 | if (e.split("@")[0] === element.getFullPath().split("@")[0]) { 78 | Log.error( 79 | `${CurrentLine()} element has a duplicate name and namespace, which can be override.` 80 | ); 81 | break; 82 | } 83 | } 84 | 85 | buildFile[element.getFullPath()] = element; 86 | } 87 | 88 | /** 89 | * Retrieves a registered modify element from the `modify` block. 90 | * The modify element corresponds to a specific file and UI element that needs to be modified. 91 | * 92 | * @param {string} modifyFile - The name of the file that contains the modify element. 93 | * @param {string} modifyElement - The name of the UI element that will be modified. 94 | * @returns {Modify} The modify element that corresponds to the given file and element. 95 | * @static 96 | */ 97 | static getModify(modifyFile: string, modifyElement: string): Modify { 98 | return this.save.modify[modifyFile]?.[modifyElement]; 99 | } 100 | 101 | /** 102 | * Registers a UI element for modification. This element will be stored in the `modify` block under the specified file and element name. 103 | * 104 | * @param {string} modifyFile - The name of the file to be modified. 105 | * @param {string} modifyElement - The name of the UI element to be modified. 106 | * @param {Modify} modify - The modification data for the element. 107 | * @returns {Modify} The modified element that has been registered. 108 | * @static 109 | */ 110 | static registerModify(modifyFile: string, modifyElement: string, modify: Modify): Modify { 111 | const modifyFileSave = (this.save.modify[modifyFile] ??= {}); 112 | return (modifyFileSave[modifyElement] = modify); 113 | } 114 | } 115 | -------------------------------------------------------------------------------- /src/compilers/generator/LangBuilder.ts: -------------------------------------------------------------------------------- 1 | import fs from "fs"; 2 | import { Class } from "../../components/Class"; 3 | import { localizeText } from "../../components/LocalizeText"; 4 | 5 | export class LangBuilder extends Class { 6 | static build(buildPath: string) { 7 | fs.mkdirSync(`${buildPath}/texts`, { recursive: true }); 8 | 9 | for (const langFile in localizeText) { 10 | const langContent: Record = localizeText[langFile]; 11 | let text = "## The entire text below is built entirely using JSONUI SCRIPTING!"; 12 | 13 | for (const key in langContent) { 14 | text += `\n${key}=${langContent[key]}`; 15 | } 16 | 17 | if (fs.existsSync(`.bedrock/texts/${langFile}.lang`)) { 18 | const content = fs.readFileSync(`.bedrock/texts/${langFile}.lang`, "utf-8"); 19 | fs.writeFileSync( 20 | `${buildPath}/texts/${langFile}.lang`, 21 | `${content}\n\n${text}`, 22 | "utf-8" 23 | ); 24 | console.timeLog("COMPILER", `${langFile}.lang has been updated!`); 25 | } else { 26 | fs.writeFileSync(`${buildPath}/texts/${langFile}.lang`, text, "utf-8"); 27 | console.timeLog("COMPILER", `${langFile}.lang has been generated!`); 28 | } 29 | } 30 | 31 | return Object.keys(localizeText).length; 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /src/compilers/generator/Log.ts: -------------------------------------------------------------------------------- 1 | import { Class } from "../../components/Class"; 2 | 3 | export const Logs: Array<{ type: "warning" | "error"; message: string }> = []; 4 | 5 | export class Log extends Class { 6 | static warning(message: string) { 7 | Logs.push({ 8 | type: "warning", 9 | message: `\x1b[93m[Warning]\x1b[0m >> ${message}`, 10 | }); 11 | } 12 | 13 | static error(message: string) { 14 | Logs.push({ 15 | type: "error", 16 | message: `\x1b[31m[Error]\x1b[0m >> ${message}`, 17 | }); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/compilers/generator/Manifest.ts: -------------------------------------------------------------------------------- 1 | import { UUID } from "crypto"; 2 | import { 3 | ManifestInterface, 4 | SemverString, 5 | Type, 6 | Version, 7 | } from "../../types/objects/Manifest"; 8 | import { Save } from "./Save"; 9 | 10 | interface ManifestHeader { 11 | name: string; 12 | description?: string; 13 | uuid?: UUID; 14 | version?: Version | SemverString; 15 | } 16 | 17 | interface ManifestMetadata { 18 | authors?: Array; 19 | license?: string; 20 | url?: string; 21 | producType?: string; 22 | generatedWith?: object; 23 | } 24 | 25 | /** 26 | * Represents a manifest object. 27 | * 28 | * @class Manifest 29 | */ 30 | export class Manifest { 31 | /** 32 | * The manifest data. 33 | * 34 | * @type {ManifestInterface} 35 | */ 36 | manifest: ManifestInterface; 37 | 38 | /** 39 | * Creates an instance of a Manifest. 40 | * 41 | * @param {ManifestHeader} header - The header for the manifest. 42 | * @param {Type} [type=Type.Resources] - The type of the module (defaults to `Type.Resources`). 43 | * @param {ManifestMetadata} [metadata] - Optional metadata for the manifest. 44 | */ 45 | constructor( 46 | header: ManifestHeader, 47 | type: Type = Type.Resources, 48 | metadata?: ManifestMetadata 49 | ) { 50 | const uuid = Save.uuid(); 51 | 52 | this.manifest = { 53 | format_version: 2, 54 | header: { 55 | name: header.name, 56 | uuid: header.uuid || uuid[0], 57 | description: header.description, 58 | version: header.version || [1, 0, 0], 59 | }, 60 | modules: [ 61 | { 62 | type: type, 63 | uuid: uuid[1], 64 | version: [1, 0, 0], 65 | }, 66 | ], 67 | metadata: metadata && { 68 | authors: metadata.authors, 69 | license: metadata.license, 70 | url: metadata.url, 71 | product_type: metadata.producType, 72 | generated_with: metadata.generatedWith, 73 | }, 74 | }; 75 | } 76 | 77 | /** 78 | * Converts the manifest to a JSON string. 79 | * 80 | * @returns {string} The manifest as a formatted JSON string. 81 | */ 82 | buildJson() { 83 | return JSON.stringify(this.manifest, null, 4); 84 | } 85 | } 86 | -------------------------------------------------------------------------------- /src/compilers/generator/Save.ts: -------------------------------------------------------------------------------- 1 | import fs from "fs"; 2 | import { Class } from "../../components/Class"; 3 | import { Random } from "../../components/Random"; 4 | import { UUID } from "../../types/objects/Manifest"; 5 | type ReturnValue = () => any; 6 | 7 | 8 | export class Save extends Class { 9 | static isSaveCreated: boolean = false; 10 | 11 | private static write(file: fs.PathOrFileDescriptor, data: string | NodeJS.ArrayBufferView, options?: fs.WriteFileOptions) { 12 | fs.writeFileSync(file, JSON.stringify(data), options); 13 | } 14 | 15 | private static read(path: fs.PathOrFileDescriptor, options?: { 16 | encoding?: null | undefined; 17 | flag?: string | undefined; 18 | } | null) { 19 | return JSON.parse(fs.readFileSync(path, options) as any); 20 | } 21 | 22 | static createFile( 23 | path: string, 24 | data: ReturnValue, 25 | write: Function = fs.writeFileSync, 26 | read: Function = fs.readFileSync 27 | ) { 28 | if (!Save.isSaveCreated && !fs.existsSync(".save")) fs.mkdirSync(".save"); 29 | Save.isSaveCreated = true; 30 | if (!fs.existsSync(`.save/${path}`)) { 31 | const $ = data(); 32 | write(`.save/${path}`, $, "utf-8"); 33 | return $; 34 | } else return read(`.save/${path}`, "utf-8"); 35 | } 36 | 37 | static createJson(path: string, data: ReturnValue) { 38 | return Save.createFile(path, data, this.write, this.read); 39 | } 40 | 41 | static updateFile( 42 | path: string, 43 | data: ReturnValue, 44 | write: Function = fs.writeFileSync, 45 | read: Function = fs.readFileSync 46 | ) { 47 | if (!Save.isSaveCreated && !fs.existsSync(".save")) fs.mkdirSync(".save"); 48 | const backup = read(`.save/${path}`, "utf-8"); 49 | write(`.save/${path}`, data()); 50 | return backup; 51 | } 52 | 53 | static updateJson(path: string, data: ReturnValue) { 54 | return Save.updateFile(path, data, fs.read, fs.readFileSync); 55 | } 56 | 57 | static uuid(): [UUID, UUID] { 58 | return <[UUID, UUID]>Save.createJson("uuid", () => ({ 59 | uuid: [Random.getUUID(), Random.getUUID()], 60 | })).uuid; 61 | } 62 | 63 | static resource(mcVersion: "stable" | "preview" = "stable") { 64 | return Save.createJson(`compile-${mcVersion}`, () => ({ 65 | isDevelopment: true, 66 | folderName: Random.getName(), 67 | })); 68 | } 69 | 70 | static getBuildID() { 71 | return Save.createJson("buildID", () => [Random.genString(16)])[0]; 72 | } 73 | } 74 | -------------------------------------------------------------------------------- /src/compilers/generator/SearchFiles.ts: -------------------------------------------------------------------------------- 1 | import { Class } from "../../components/Class"; 2 | import fs from "fs"; 3 | 4 | interface CallbackValue { 5 | folder?: string; 6 | file: string; 7 | path: string; 8 | } 9 | 10 | 11 | function searchForEachFileRecursion( 12 | path: string, 13 | callback: (value: CallbackValue) => void, 14 | $1: string = "", 15 | $2: string = "", 16 | $3: string = "" 17 | ) { 18 | if (fs.statSync(path).isDirectory()) 19 | for (const file of fs.readdirSync(path)) 20 | searchForEachFileRecursion( 21 | `${path}/${file}`, 22 | callback, 23 | file, 24 | `${$2}/${file}`, 25 | $2.match(/(?<=\/)\w+$/)?.[0] 26 | ); 27 | else 28 | callback({ 29 | file: $1, 30 | folder: $3 === "" ? undefined : $3, 31 | path: $2.slice(1), 32 | }); 33 | } 34 | 35 | 36 | export class SearchFiles extends Class { 37 | static array(folderPath: string, prefix?: string): Array { 38 | const paths: Array = []; 39 | SearchFiles.forEach(folderPath, value => 40 | paths.push(`${prefix ? `${prefix}/` : ""}${value.path}`) 41 | ); 42 | return paths; 43 | } 44 | 45 | static forEach(folderPath: string, callback: (value: CallbackValue) => void): void { 46 | searchForEachFileRecursion(folderPath, callback); 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /src/compilers/generator/Sounds.ts: -------------------------------------------------------------------------------- 1 | import fs from "fs"; 2 | import { parse } from "jsonc-parser"; 3 | import { Class } from "../../components/Class"; 4 | import { Random } from "../../components/Random"; 5 | import { UIWriteJson } from "../PreCompile"; 6 | 7 | interface SoundID { 8 | [path: string]: string; 9 | } 10 | 11 | const sounds: SoundID = {}; 12 | 13 | export class SoundHandler extends Class { 14 | static get(path: string) { 15 | if (sounds[path]) { 16 | return sounds[path]; 17 | } else { 18 | return (sounds[path] = `jsonui_scripting.${Random.getName()}`); 19 | } 20 | } 21 | 22 | static compile(installPath: string) { 23 | const soundIds = Object.keys(sounds); 24 | 25 | if (soundIds.length) { 26 | if (!fs.existsSync(`${installPath}/sounds`)) fs.mkdirSync(`${installPath}/sounds`); 27 | 28 | const soundDefinitions: any = {}; 29 | 30 | for (const soundPath of soundIds) { 31 | const soundId = sounds[soundPath]; 32 | 33 | soundDefinitions[soundId] = { 34 | category: "ui", 35 | sounds: [ 36 | { 37 | load_on_low_memory: true, 38 | name: soundPath, 39 | stream: true, 40 | volume: 1, 41 | }, 42 | ], 43 | }; 44 | } 45 | 46 | let bak; 47 | if (fs.existsSync(`.bedrock/sounds/sound_definitions.json`)) { 48 | bak = parse( 49 | fs.readFileSync(`.bedrock/sounds/sound_definitions.json`, "utf-8") 50 | ).sound_definitions; 51 | } 52 | 53 | UIWriteJson( 54 | `${installPath}/sounds/sound_definitions.json`, 55 | { 56 | format_version: "1.20.20", 57 | sound_definitions: { 58 | ...bak, 59 | ...soundDefinitions, 60 | }, 61 | }, 62 | "utf-8" 63 | ); 64 | } 65 | 66 | return soundIds.length; 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /src/compilers/generator/Template.ts: -------------------------------------------------------------------------------- 1 | import { config, env, globalVariables, gitignore } from "../../template"; 2 | import { GenerateDir } from "./GenerateDir"; 3 | import fs from "fs"; 4 | 5 | export function firstRun() { 6 | // Template Object 7 | const template: { [file: string]: string } = { 8 | ".gitignore": gitignore, 9 | "asakiyuki.config.cjs": config 10 | .replace("{packname}", "JsonUI Scripting") 11 | .replace("{packdescription}", "Build with JsonUI Scripting <3") 12 | .replace("{autoinstall}", "true") 13 | .replace("{development}", "true") 14 | .replace("{preview}", "false"), 15 | "asakiyuki.global_variables.cjs": globalVariables, 16 | "asakiyuki.env.cjs": env, 17 | }; 18 | 19 | // Generator 20 | for (const file in template) { 21 | if (!fs.existsSync(file)) { 22 | GenerateDir(file); 23 | fs.writeFileSync(file, template[file], "utf-8"); 24 | } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/compilers/generator/UIBuilder.ts: -------------------------------------------------------------------------------- 1 | import fs from "fs"; 2 | import { parse } from "jsonc-parser"; 3 | import { JsonBuilder } from "./JsonBuilder"; 4 | import { SearchFiles } from "./SearchFiles"; 5 | import { GenerateDir } from "./GenerateDir"; 6 | import { UIWriteJson } from "../PreCompile"; 7 | 8 | /** 9 | * A utility class for managing UI files, including deletion, generation, modification, and saving of UI-related data. 10 | * 11 | * @class UIBuilder 12 | */ 13 | export class UIBuilder { 14 | /** 15 | * Deletes a file or folder at the specified path. 16 | * If the path exists, it will be removed. If it is a file, it will be unlinked. 17 | * If it's a directory, it will be removed recursively. 18 | * 19 | * @param {string} installPath - The path to the file or folder to be deleted. 20 | * @returns {void} 21 | * @static 22 | */ 23 | static delete(installPath: string): void { 24 | try { 25 | fs.unlinkSync(installPath); 26 | } catch (error) { 27 | if (fs.existsSync(installPath)) fs.rmSync(installPath, { recursive: true }); 28 | } 29 | } 30 | 31 | /** 32 | * Generates JSON UI files based on the saved build data and writes them to the specified path. 33 | * The function logs the number of elements generated for each file. 34 | * 35 | * @param {string} installPath - The path where the generated JSON files will be saved. 36 | * @returns {number} The number of files that were generated. 37 | * @static 38 | */ 39 | static jsonUI(installPath: string): number { 40 | const build = JsonBuilder.save.build; 41 | let count = 0; 42 | for (const file in build) { 43 | const namespace = build[file].namespace; 44 | delete build[file].namespace; 45 | for (const jsonUI in build[file]) build[file][jsonUI] = build[file][jsonUI].getUI(); 46 | 47 | console.timeLog( 48 | "COMPILER", 49 | `${file} ${Object.keys(build[file]).length} elements has generated!` 50 | ); 51 | 52 | build[file].namespace = namespace; 53 | UIWriteJson(`${installPath}/@/${file}`, build[file], "utf-8"); 54 | delete build[file]; 55 | count++; 56 | } 57 | return count; 58 | } 59 | 60 | /** 61 | * Modifies UI files based on the saved modification data and writes them to the specified path. 62 | * It also creates necessary directories if they do not exist. 63 | * 64 | * @param {string} installPath - The path where the modified UI files will be saved. 65 | * @returns {number} The number of modified files generated. 66 | * @static 67 | */ 68 | static modify(installPath: string): number { 69 | if (!fs.existsSync(`${installPath}/ui`)) fs.mkdirSync(`${installPath}/ui`); 70 | let count = 0; 71 | const modify = JsonBuilder.save.modify; 72 | for (const key in modify) { 73 | GenerateDir(installPath, key); 74 | for (const element in modify[key]) modify[key][element] = modify[key][element].getUI(); 75 | 76 | console.timeLog( 77 | "COMPILER", 78 | `${key} ${Object.keys(modify[key]).length} modify element(s) has generated!` 79 | ); 80 | 81 | UIWriteJson(`${installPath}/${key}`, modify[key], "utf-8"); 82 | delete modify[key]; 83 | count++; 84 | } 85 | return count; 86 | } 87 | 88 | /** 89 | * Generates a UI definitions file and writes it to the specified path. 90 | * The UI definitions are gathered from the specified folder and saved in `_ui_defs.json`. 91 | * 92 | * @param {string} installPath - The path where the UI definitions file will be saved. 93 | * @returns {number} The number of UI definitions that were generated. 94 | * @static 95 | */ 96 | static uiDefs(installPath: string): number { 97 | const arr = SearchFiles.array(`${installPath}/@`, "@"); 98 | UIWriteJson(`${installPath}/ui/_ui_defs.json`, { ui_defs: arr }, "utf-8"); 99 | return arr.length; 100 | } 101 | 102 | /** 103 | * Generates a contents JSON file, listing all paths of files in the specified folder. 104 | * 105 | * @param {string} installPath - The path where the contents JSON file will be saved. 106 | * @returns {number} The number of files listed in the contents file. 107 | * @static 108 | */ 109 | static contents(installPath: string): number { 110 | const arr = SearchFiles.array(installPath); 111 | 112 | UIWriteJson( 113 | `${installPath}/contents.json`, 114 | { 115 | content: arr.map(v => ({ path: v })), 116 | }, 117 | "utf-8" 118 | ); 119 | 120 | return arr.length; 121 | } 122 | 123 | /** 124 | * Generates a textures list and writes it to the specified path. 125 | * It filters out PNG, JPG, and JPEG files, adds them to a list, and then writes the list to `textures_list.json`. 126 | * It also merges the generated list with any existing textures list. 127 | * 128 | * @param {string} installPath - The path where the textures list will be saved. 129 | * @returns {number} The number of textures found and added to the list. 130 | * @static 131 | */ 132 | static texturesList(installPath: string): number { 133 | const arr = SearchFiles.array(installPath) 134 | .filter(v => /\.(png|jpg|jpeg)$/.test(v)) 135 | .map(v => v.replace(/\.(png|jpg|jpeg)$/, "")); 136 | 137 | let textureList: Array = []; 138 | 139 | if (fs.existsSync(`.bedrock/textures/textures_list.json`)) { 140 | const texturesList = fs.readFileSync(`.bedrock/textures/textures_list.json`, "utf-8"); 141 | textureList = parse(texturesList); 142 | } 143 | 144 | if (!fs.existsSync(`${installPath}/textures`)) fs.mkdirSync(`${installPath}/textures`); 145 | UIWriteJson( 146 | `${installPath}/textures/textures_list.json`, 147 | [...arr, ...textureList], 148 | "utf-8" 149 | ); 150 | 151 | return arr.length; 152 | } 153 | 154 | /** 155 | * Generates a global variables file and writes it to the specified path. 156 | * 157 | * @param {string} installPath - The path where the global variables file will be saved. 158 | * @returns {number} The number of global variables written to the file. 159 | * @static 160 | */ 161 | static globalVariables(installPath: string): number { 162 | const globalVariables = JsonBuilder.save.globalVariables; 163 | 164 | UIWriteJson(`${installPath}/ui/_global_variables.json`, globalVariables, "utf-8"); 165 | 166 | return Object.keys(globalVariables).length; 167 | } 168 | } 169 | -------------------------------------------------------------------------------- /src/compilers/reader/Audio.ts: -------------------------------------------------------------------------------- 1 | import fs from "fs"; 2 | import { SearchFiles } from "../generator/SearchFiles"; 3 | import { spawnSync, execSync } from "child_process"; 4 | import { Log } from "../generator/Log"; 5 | 6 | export function FormatAudio() { 7 | const reg = /\.(mp3|m4a|mp4|mov|opus|acc|flac)$/; 8 | const files = SearchFiles.array(".bedrock", ".bedrock").filter((path) => 9 | reg.test(path) 10 | ); 11 | 12 | if (!files.length) return; 13 | 14 | try { 15 | spawnSync("ffmpeg", ["-version"], { 16 | stdio: ["ignore", "ignore", "ignore"], 17 | }).error; 18 | 19 | console.timeLog( 20 | "Compiler", 21 | ">> Starting to convert all found audio files to WAV format" 22 | ); 23 | 24 | for (const file of files) { 25 | const out = file.replace(reg, ".wav"); 26 | execSync(`ffmpeg -i ${file} ${out}`, { 27 | stdio: "ignore", 28 | }); 29 | fs.rmSync(file); 30 | 31 | console.timeLog( 32 | "Compiler", 33 | `>> Reformatting of ${file.replace( 34 | /^\.bedrock\//, 35 | "" 36 | )} is complete.` 37 | ); 38 | } 39 | 40 | console.timeLog( 41 | "Compiler", 42 | `>> Successfully reformatted ${files.length} audio file(s).` 43 | ); 44 | console.log(); 45 | } catch (error) { 46 | Log.warning( 47 | "You need to install 'ffmpeg' to your system environment variables to automatic convert all audio files to a format minecraft can read." 48 | ); 49 | console.log(); 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /src/compilers/reader/Color.ts: -------------------------------------------------------------------------------- 1 | import { Class } from "../../components/Class"; 2 | import { Vector3, Vector4 } from "../../types/values/Vector"; 3 | 4 | /** 5 | * A utility class for parsing color values from hexadecimal strings into `Vector3` or `Vector4` formats. 6 | * The `parse` method interprets hex color strings with different lengths (3, 6, 4, or 8 characters) 7 | * and returns the corresponding normalized color values as either a `Vector3` (RGB) or `Vector4` (RGBA). 8 | * 9 | * @class ColorHandler 10 | */ 11 | export class ColorHandler extends Class { 12 | /** 13 | * Parses a hexadecimal color string and returns a normalized color vector. 14 | * 15 | * The method supports: 16 | * - 3-character hexadecimal color (e.g., "#rgb" → Vector3) 17 | * - 6-character hexadecimal color (e.g., "#rrggbb" → Vector3) 18 | * - 4-character RGBA color (e.g., "#rgba" → Vector4) 19 | * - 8-character RGBA color (e.g., "#aarrggbb" → Vector4) 20 | * 21 | * @param {string} data - The hexadecimal color string to parse, possibly prefixed with '#'. 22 | * @returns {Vector3 | Vector4 | null} A normalized `Vector3` (RGB) or `Vector4` (RGBA) or `null` if the input is invalid. 23 | * 24 | * @example 25 | * // Example usage: 26 | * const rgb = ColorHandler.parse("#ff5733"); // Returns Vector3 [1, 0.341, 0.2] 27 | * const rgba = ColorHandler.parse("#ff5733cc"); // Returns Vector4 [1, 0.341, 0.2, 0.8] 28 | */ 29 | static parse(data: string): Vector3 | Vector4 | null { 30 | if (data.startsWith("#")) data = data.slice(1); 31 | 32 | try { 33 | const color = parseInt(data, 16); 34 | switch (data.length) { 35 | case 3: 36 | return [((color >> 8) & 15) / 15, ((color >> 4) & 15) / 15, (color & 15) / 15]; 37 | case 6: 38 | return [ 39 | ((color >> 16) & 255) / 255, 40 | ((color >> 8) & 255) / 255, 41 | (color & 255) / 255, 42 | ]; 43 | case 4: 44 | return [ 45 | ((color >> 16) & 15) / 15, 46 | ((color >> 8) & 15) / 15, 47 | ((color >> 4) & 15) / 15, 48 | (color & 15) / 15, 49 | ]; 50 | case 8: 51 | return [ 52 | ((color >> 24) & 255) / 255, 53 | ((color >> 16) & 255) / 255, 54 | ((color >> 8) & 255) / 255, 55 | (color & 255) / 255, 56 | ]; 57 | default: 58 | return null; 59 | } 60 | } catch (error) { 61 | console.error(error); 62 | return null; 63 | } 64 | } 65 | } 66 | -------------------------------------------------------------------------------- /src/compilers/reader/CurrentLine.ts: -------------------------------------------------------------------------------- 1 | const regex: any = { 2 | win32: /[A-Z]:(.+):\d+:\d+/g, 3 | linux: /\/(.+):\d+:\d+/g, 4 | }; 5 | 6 | export function CurrentLine() { 7 | const lines = new Error("Code Line").stack?.match(regex[process.platform]); 8 | return lines ? lines[lines.length - 1] : "Unknown"; 9 | } 10 | -------------------------------------------------------------------------------- /src/compilers/reader/Env.ts: -------------------------------------------------------------------------------- 1 | import { Obj } from "./Object"; 2 | 3 | Obj.forEach( 4 | require(`${process.cwd()}/asakiyuki.env.cjs`).env, 5 | (key, value) => (process.env[key] = value) 6 | ); 7 | 8 | export {}; 9 | -------------------------------------------------------------------------------- /src/compilers/reader/GlobalVariables.ts: -------------------------------------------------------------------------------- 1 | import { Obj } from "./Object"; 2 | import { JsonBuilder } from "../generator/JsonBuilder"; 3 | import { ReadValue } from "./ReadProperties"; 4 | 5 | Obj.forEach(require(`${process.cwd()}/asakiyuki.global_variables.cjs`).global_variables, (key, value) => 6 | JsonBuilder.registerGlobalVariable(key, ReadValue(value)) 7 | ); 8 | 9 | export { }; 10 | -------------------------------------------------------------------------------- /src/compilers/reader/Object.ts: -------------------------------------------------------------------------------- 1 | import { Class } from "../../components/Class"; 2 | 3 | type CallbackObject = (key: string, value: any) => void; 4 | type CallbackObjectMap = (key: string, value: any) => { key: string; value: any }; 5 | 6 | /** 7 | * A utility class for performing operations on objects. 8 | * Provides methods to iterate over object properties or transform them. 9 | * 10 | * @class Obj 11 | */ 12 | export class Obj extends Class { 13 | /** 14 | * Iterates over the properties of an object and applies a callback function to each key-value pair. 15 | * 16 | * @param {object} data - The object to iterate over. 17 | * @param {CallbackObject} callback - A function that will be called for each key-value pair. 18 | * The callback will receive the key and the corresponding value of the object. 19 | * 20 | * @returns {void} 21 | * 22 | * @example 23 | * // Example usage: 24 | * Obj.forEach({ a: 1, b: 2 }, (key, value) => { 25 | * console.log(key, value); 26 | * }); 27 | * // Output: 28 | * // a 1 29 | * // b 2 30 | */ 31 | static forEach(data: object, callback: CallbackObject): void { 32 | for (const key in data) { 33 | const element = (data)[key]; 34 | callback(key, element); 35 | } 36 | } 37 | 38 | /** 39 | * Maps the properties of an object and returns a new object with modified key-value pairs. 40 | * 41 | * The callback function can change the key or value, and the resulting object will reflect these changes. 42 | * 43 | * @param {object} data - The object to transform. 44 | * @param {CallbackObjectMap} callback - A function that will be called for each key-value pair. 45 | * The callback must return an object with `key` and `value` properties to modify the object. 46 | * 47 | * @returns {object} - A new object with the transformed key-value pairs. 48 | * 49 | * @example 50 | * // Example usage: 51 | * const result = Obj.map({ a: 1, b: 2 }, (key, value) => { 52 | * return { key: key.toUpperCase(), value: value * 2 }; 53 | * }); 54 | * console.log(result); // { A: 2, B: 4 } 55 | */ 56 | static map(data: object, callback: CallbackObjectMap): object { 57 | for (const key in data) { 58 | const getdata = callback(key, (data)[key]); 59 | delete (data)[key]; 60 | (data)[getdata.key] = getdata.value; 61 | } 62 | return data; 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /src/compilers/reader/ReadBinding.ts: -------------------------------------------------------------------------------- 1 | import { OverrideInterface } from "../../components/Modify"; 2 | import { UI } from "../../components/UI"; 3 | import { BindingName } from "../../types/enums/BindingName"; 4 | import { BindingType } from "../../types/enums/BindingType"; 5 | import { BindingInterface } from "../../types/objects/BindingInterface"; 6 | import { Var } from "../../types/values/Variable"; 7 | import { BindingCompiler } from "../BindingCompiler"; 8 | import { Log } from "../generator/Log"; 9 | import { CurrentLine } from "./CurrentLine"; 10 | 11 | /** 12 | * Reads and processes a binding object or name and returns a properly structured binding object. 13 | * 14 | * This function checks the type of the provided `binding` argument and processes it accordingly: 15 | * - If the `binding` is a string, it returns an object with a `binding_name` property. 16 | * - If the `binding` is an object (either `BindingName | Var | BindingInterface`), it checks for specific properties like `source_property_name` 17 | * or `binding_collection_name` and adjusts the binding accordingly. 18 | * - If the `source_property_name` is an array, it compiles it using the `BindingCompiler.compile` method. 19 | * 20 | * @param {BindingName | Var | BindingInterface} binding - The binding to be read. Can be a string or an object of type `BindingName`, `Var`, or `BindingInterface`. 21 | * @param {UI | OverrideInterface} arg - An additional argument used in the processing of the `binding` object. 22 | * 23 | * @returns {BindingInterface} The processed binding object. 24 | * 25 | * @example 26 | * // Example usage: 27 | * const result = ReadBinding("myBindingName", someUIObject); 28 | * console.log(result); // { binding_name: "myBindingName" } 29 | * 30 | * const bindingObj = { source_property_name: ["property1"], source_control_name: "control1" }; 31 | * const result = ReadBinding(bindingObj, someOverrideObject); 32 | * console.log(result); // Processed binding object with necessary adjustments 33 | */ 34 | export function ReadBinding( 35 | binding: BindingName | Var | BindingInterface, 36 | arg: UI | OverrideInterface 37 | ): BindingInterface { 38 | if (typeof binding === "string") 39 | return { 40 | binding_name: binding, 41 | }; 42 | else { 43 | const bindingObject: BindingInterface = binding; 44 | 45 | if (bindingObject.source_property_name) { 46 | bindingObject.binding_type ||= BindingType.View; 47 | 48 | const srcBin = bindingObject.source_property_name; 49 | 50 | if (srcBin && !bindingObject.source_control_name) { 51 | if (Array.isArray(srcBin)) 52 | bindingObject.source_property_name = ( 53 | BindingCompiler.compile(srcBin[0], arg) 54 | ); 55 | else if (srcBin.startsWith("[") && srcBin.endsWith("]")) { 56 | bindingObject.source_property_name = BindingCompiler.compile( 57 | srcBin.slice(1, srcBin.length - 1), 58 | arg 59 | ); 60 | } 61 | } 62 | 63 | if (!bindingObject.target_property_name) { 64 | Log.error(`${CurrentLine()} missing target_property_name.`); 65 | } 66 | } else if (bindingObject.binding_collection_name) { 67 | bindingObject.binding_type ||= BindingType.Collection; 68 | } 69 | 70 | return bindingObject; 71 | } 72 | } 73 | -------------------------------------------------------------------------------- /src/compilers/reader/ReadProperties.ts: -------------------------------------------------------------------------------- 1 | import { Animation } from "../../components/Animation"; 2 | import { LocalizeText } from "../../components/LocalizeText"; 3 | import { Properties } from "../../types/objects/properties/Properties"; 4 | import { Log } from "../generator/Log"; 5 | import { SoundHandler as Sounds } from "../generator/Sounds"; 6 | import { ColorHandler } from "./Color"; 7 | import { Obj } from "./Object"; 8 | 9 | /** 10 | * Processes a value and applies transformations based on its type. 11 | * 12 | * This function checks if the provided `value` is an array or an instance of `Animation` and handles it accordingly. 13 | * - If `value` is an array, it checks if the first element is a string and, if so, processes it as a color (using `ColorHandler.parse`) or as a variable (if it starts with `$`). 14 | * - If `value` is an instance of `Animation`, it returns the key index of the animation. 15 | * 16 | * @param {any} value - The value to process, which can be an array, an `Animation`, or any other type. 17 | * @param {((type: string) => any) | undefined} callback - An optional callback function that is called when a variable (`$`) is detected in the array. 18 | * 19 | * @returns {any} The processed value, which could be a parsed color, variable, or the original value. 20 | * 21 | * @example 22 | * // Example usage: 23 | * const color = ReadValue(["#FF5733"]); 24 | * console.log(color); // Parsed color array [1, 0.341, 0.2] 25 | * 26 | * const animationValue = ReadValue(new Animation()); 27 | * console.log(animationValue); // Returns the key index of the animation 28 | */ 29 | export function ReadValue(value: any, callback?: (type: string) => any) { 30 | if (Array.isArray(value)) { 31 | if (typeof value[0] === "string") { 32 | if (value[0].startsWith("#") || value[0].startsWith("0x")) 33 | value = ColorHandler.parse(value[0]); 34 | else if (value[0].startsWith("$")) return callback?.("var"); 35 | } 36 | } else if (value instanceof Animation) return value.getKeyIndex(0); 37 | else if (value instanceof LocalizeText) return value.get(); 38 | 39 | return value; 40 | } 41 | 42 | /** 43 | * Processes and normalizes properties related to size, offset, and anchoring. 44 | * 45 | * This function takes a `properties` object and adjusts its properties to ensure consistency: 46 | * - It normalizes properties like `x`, `y`, `min_w`, `min_h`, `max_w`, `max_h`, and `w`, `h` into `offset` or `size` arrays. 47 | * - It processes properties that are not arrays (e.g., `min_size`, `max_size`) and converts them to arrays if necessary. 48 | * - It handles `anchor` properties and creates `anchor_from` and `anchor_to` properties. 49 | * - It also processes values for variables (denoted by `$`), modifying certain properties accordingly. 50 | * 51 | * @param {Properties} properties - The properties object to process, which may include size, offset, and other related values. 52 | * 53 | * @returns {Properties} The processed properties object with normalized size, offset, and anchoring information. 54 | * 55 | * @example 56 | * // Example usage: 57 | * const properties = { x: 10, y: 20, min_w: 100 }; 58 | * const normalizedProperties = ReadProperties(properties); 59 | * console.log(normalizedProperties); // { offset: [10, 20], min_size: [100, 100] } 60 | */ 61 | export function ReadProperties(properties: Properties) { 62 | if (properties.x || properties.y) { 63 | properties.offset = [properties.x || 0, properties.y || 0]; 64 | delete properties.x; 65 | delete properties.y; 66 | } 67 | 68 | if (properties.min_w || properties.min_h) { 69 | properties.min_size = [properties.min_w || 0, properties.min_h || 0]; 70 | delete properties.min_w; 71 | delete properties.min_h; 72 | } else if ( 73 | properties.min_size !== undefined && 74 | !Array.isArray(properties.min_size) && 75 | typeof properties.min_size === "string" && 76 | !properties.min_size.startsWith("$") 77 | ) 78 | (properties.min_size) = [properties.min_size, properties.min_size]; 79 | 80 | if (properties.max_w || properties.max_h) { 81 | properties.max_size = [properties.max_w || 0, properties.max_h || 0]; 82 | delete properties.max_w; 83 | delete properties.max_h; 84 | } else if ( 85 | properties.max_size !== undefined && 86 | !Array.isArray(properties.max_size) && 87 | typeof properties.max_size === "string" && 88 | !properties.max_size.startsWith("$") 89 | ) 90 | (properties.max_size) = [properties.max_size, properties.max_size]; 91 | 92 | if (properties.w || properties.h) { 93 | properties.size = [properties.w || 0, properties.h || 0]; 94 | delete properties.w; 95 | delete properties.h; 96 | } else if ( 97 | properties.size !== undefined && 98 | !Array.isArray(properties.size) && 99 | typeof properties.size === "string" && 100 | !properties.size.startsWith("$") 101 | ) 102 | (properties.size) = [properties.size, properties.size]; 103 | 104 | if (properties.sound_path) { 105 | properties.sound_name = Sounds.get(properties.sound_path); 106 | delete properties.sound_path; 107 | } 108 | 109 | if (properties.sounds) { 110 | properties.sounds = properties.sounds.map(sound => { 111 | if (sound.sound_path) { 112 | const soundId = Sounds.get(sound.sound_path); 113 | delete sound.sound_path; 114 | return { 115 | sound_name: soundId, 116 | }; 117 | } else return sound; 118 | }); 119 | } 120 | 121 | Obj.forEach(properties, (key, value) => { 122 | if (key.startsWith("#")) { 123 | if (["string", "number", "boolean"].includes(typeof value)) { 124 | ((properties.property_bag ||= {}))[key] = value; 125 | } else Log.error(`Invalid value for property "${key}"`); 126 | delete (properties)[key]; 127 | } else { 128 | (properties)[key] = ReadValue(value, type => { 129 | if (type === "var") { 130 | const isSpecialProperty = ["size", "min_size", "max_size"].includes(key); 131 | 132 | const disableDefault = value[2]; 133 | const propertyName = disableDefault ? value[0] : `${value[0]}|default`; 134 | 135 | if (isSpecialProperty) { 136 | if (Array.isArray(value[1])) properties[propertyName] = value[1]; 137 | else properties[propertyName] = [value[1], value[1]]; 138 | } else { 139 | properties[propertyName] = ReadValue(value[1]); 140 | } 141 | 142 | return value[0]; 143 | } 144 | }); 145 | } 146 | }); 147 | 148 | if (properties.anchor) { 149 | properties.anchor_from = properties.anchor; 150 | properties.anchor_to = properties.anchor; 151 | delete properties.anchor; 152 | } 153 | 154 | return properties; 155 | } 156 | -------------------------------------------------------------------------------- /src/components/AddCollectionChill.ts: -------------------------------------------------------------------------------- 1 | import { UIChildNameCallback } from "../types/components/NameCallback"; 2 | import { Properties } from "../types/objects/properties/Properties"; 3 | import { UI } from "./UI"; 4 | 5 | /** 6 | * Callback function type for setting the name of a child element based on its index. 7 | * 8 | * @param {number} index - The index of the child element in the collection. 9 | * @returns {string} - The name of the child element. 10 | */ 11 | type setNameCallback = (index: number) => string; 12 | 13 | /** 14 | * Adds child elements to a parent UI component based on the provided collection length and index range. 15 | * Each child element can optionally have additional properties and a dynamic name based on its index. 16 | * 17 | * @param {UI} parent - The parent UI component to which the child elements will be added. 18 | * @param {UI} child - The UI child component to be added to the parent. 19 | * @param {number} collectionLength - The total number of child elements to be added. 20 | * @param {number} [startIndex=0] - The starting index from which to begin adding child elements. Defaults to 0. 21 | * @param {Properties} [properties] - Optional properties to apply to each child element. 22 | * @param {setNameCallback} [setName] - Optional callback function to dynamically set the name of each child element based on its index. 23 | * @param {UIChildNameCallback} [callback] - Optional callback function to be invoked after adding each child element. 24 | * 25 | * @returns {void} 26 | * 27 | * @example 28 | * // Adds 5 child elements to the parent UI, starting from index 0. 29 | * AddCollectionChild(parentUI, childUI, 5, 0, { color: 'red' }, (index) => `child-${index}`); 30 | */ 31 | export function AddCollectionChild( 32 | parent: UI, 33 | child: UI, 34 | collectionLength: number, 35 | startIndex: number = 0, 36 | properties?: Properties, 37 | setName?: setNameCallback, 38 | callback?: UIChildNameCallback 39 | ) { 40 | for (let index = startIndex; index < collectionLength; index++) { 41 | const name = setName?.(index); 42 | parent.addChild( 43 | child, 44 | { 45 | ...properties, 46 | collection_index: index, 47 | }, 48 | name, 49 | callback 50 | ); 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /src/components/Animation.ts: -------------------------------------------------------------------------------- 1 | import { Configs } from "../compilers/Config"; 2 | import { Identifier } from "../types/components/Identifier"; 3 | import { AnimationTypes } from "../types/enums/AnimTypes"; 4 | import { AnimationInterface } from "../types/objects/Animation"; 5 | import { AnimationKeyFrame } from "./AnimationKeyFrame"; 6 | import { Random } from "./Random"; 7 | 8 | /** 9 | * Represents an animation, which includes a series of keyframes, type, and loop behavior. 10 | * Provides methods to build the animation and access keyframes. 11 | * 12 | * @class Animation 13 | */ 14 | export class Animation { 15 | private keyFrames: Array = []; 16 | 17 | /** 18 | * Registers a new animation with an optional identifier. 19 | * 20 | * @param {AnimationInterface} animation - The animation data to be registered. 21 | * @param {Identifier} [identifier] - The optional identifier for the animation. 22 | * @returns {Animation} - The newly created animation instance. 23 | */ 24 | static register(animation: AnimationInterface, identifier?: Identifier): Animation { 25 | return new Animation(animation, identifier); 26 | } 27 | 28 | /** 29 | * Creates an instance of the Animation class, initializing keyframes and setting up the animation. 30 | * 31 | * @param {AnimationInterface} animation - The animation data including the keyframes, type, and other settings. 32 | * @param {Identifier} [identifier] - The optional identifier for the animation. 33 | * @constructor 34 | */ 35 | constructor(animation: AnimationInterface, identifier?: Identifier) { 36 | const config = Configs.getConfig(); 37 | 38 | if (!(identifier && !config.compiler.UI.obfuscateName)) 39 | identifier = { 40 | name: Random.getAnimationName(), 41 | namespace: Random.getNamespace(), 42 | }; 43 | else { 44 | if (!identifier.name) identifier.name = Random.getAnimationName(); 45 | if (!identifier.namespace) identifier.namespace = Random.getAnimationName(); 46 | } 47 | 48 | this.buildAnimation(animation, identifier); 49 | } 50 | 51 | /** 52 | * Retrieves the key index for a given keyframe index, ensuring the index is within valid bounds. 53 | * 54 | * @param {number} index - The index of the keyframe. 55 | * @returns {string} - The formatted key for the given index. 56 | */ 57 | getKeyIndex(index: number): string { 58 | let i = index < 0 ? 0 : Math.min(index, this.keyFrames.length); 59 | return `@${this.keyFrames[index]}`; 60 | } 61 | 62 | /** 63 | * Builds the animation by processing the keyframes and creating animation keyframes. 64 | * 65 | * @param {AnimationInterface} animation - The animation data, including from, keyframes, loop, and type. 66 | * @param {Identifier} identifier - The identifier for the animation, including name and namespace. 67 | * @private 68 | */ 69 | private buildAnimation( 70 | { from, keyFrames, loop, type, durationPerKeyFrame = 1 }: AnimationInterface, 71 | identifier: Identifier 72 | ) { 73 | const frameLength = keyFrames.length - 1; 74 | 75 | keyFrames.forEach((keyFrame, index) => { 76 | this.keyFrames.push(`${identifier.namespace}.${identifier.name}`); 77 | const currentIdentifier = identifier; 78 | 79 | let next; 80 | 81 | if (index === frameLength) { 82 | if (loop) next = this.getKeyIndex(0); 83 | } else { 84 | identifier = this.generateIdentifier(); 85 | next = this.getFrameKeyByIdentifier(identifier); 86 | } 87 | 88 | if (typeof keyFrame == "number") { 89 | new AnimationKeyFrame( 90 | { 91 | next, 92 | anim_type: AnimationTypes.Wait, 93 | duration: keyFrame, 94 | }, 95 | currentIdentifier 96 | ); 97 | } else { 98 | new AnimationKeyFrame( 99 | { 100 | next, 101 | anim_type: type, 102 | from, 103 | duration: (keyFrame).duration ?? durationPerKeyFrame, 104 | ...(keyFrame), 105 | }, 106 | currentIdentifier 107 | ); 108 | } 109 | 110 | if (typeof keyFrame === "object") from = (keyFrame).to; 111 | }); 112 | } 113 | 114 | /** 115 | * Generates a new identifier with random name and namespace. 116 | * 117 | * @returns {Identifier} - A newly generated identifier with random name and namespace. 118 | * @private 119 | */ 120 | private generateIdentifier() { 121 | return { 122 | name: Random.getAnimationName(), 123 | namespace: Random.getNamespace(), 124 | }; 125 | } 126 | 127 | /** 128 | * Retrieves the frame key by the provided identifier in a formatted string. 129 | * 130 | * @param {Identifier} identifier - The identifier containing the namespace and name. 131 | * @returns {string} - The formatted key string based on the identifier. 132 | * @private 133 | */ 134 | private getFrameKeyByIdentifier(identifier: Identifier) { 135 | return `@${identifier.namespace}.${identifier.name}`; 136 | } 137 | 138 | /** 139 | * A static method that seems to serve as a placeholder, but has no functionality as of now. 140 | * 141 | * @private 142 | * @static 143 | */ 144 | private static apply() { } 145 | 146 | /** 147 | * A static property initialized to an empty string, likely intended to hold arguments or be overridden in the future. 148 | * 149 | * @private 150 | * @static 151 | * @type {string} 152 | */ 153 | private static arguments = ""; 154 | 155 | /** 156 | * A static method that seems to serve as a placeholder, but has no functionality as of now. 157 | * 158 | * @private 159 | * @static 160 | */ 161 | private static bind() { } 162 | 163 | /** 164 | * A static method that seems to serve as a placeholder, but has no functionality as of now. 165 | * 166 | * @private 167 | * @static 168 | */ 169 | private static call() { } 170 | 171 | /** 172 | * A static property initialized to an empty string, likely intended to hold caller information or be overridden in the future. 173 | * 174 | * @private 175 | * @static 176 | * @type {string} 177 | */ 178 | private static caller = ""; 179 | 180 | /** 181 | * A static property initialized to an empty string, likely intended to hold length-related data or be overridden in the future. 182 | * 183 | * @private 184 | * @static 185 | * @type {string} 186 | */ 187 | private static length = ""; 188 | 189 | /** 190 | * A static property initialized to an empty string, likely intended to hold a name or be overridden in the future. 191 | * 192 | * @private 193 | * @static 194 | * @type {string} 195 | */ 196 | private static name = ""; 197 | 198 | /** 199 | * A static method that seems to serve as a placeholder, but has no functionality as of now. 200 | * 201 | * @private 202 | * @static 203 | */ 204 | private static toString() { } 205 | } 206 | -------------------------------------------------------------------------------- /src/components/AnimationKeyFrame.ts: -------------------------------------------------------------------------------- 1 | import { JsonBuilder } from "../compilers/generator/JsonBuilder"; 2 | import { ReadValue } from "../compilers/reader/ReadProperties"; 3 | import { Identifier } from "../types/components/Identifier"; 4 | import { AnimationKeyFrameInterface } from "../types/objects/Animation"; 5 | 6 | /** 7 | * Represents a keyframe in an animation, including its properties such as "from", "to", and other settings. 8 | * Handles the processing of the keyframe properties and registers it in the `JsonBuilder`. 9 | * 10 | * @class AnimationKeyFrame 11 | */ 12 | export class AnimationKeyFrame { 13 | private properties: AnimationKeyFrameInterface; 14 | 15 | /** 16 | * Creates an instance of the `AnimationKeyFrame` class and processes its properties. 17 | * 18 | * @param {AnimationKeyFrameInterface} keyFrame - The keyframe data, including the properties "from" and "to". 19 | * @param {Identifier} identifier - The identifier for the keyframe. 20 | * @constructor 21 | */ 22 | constructor(keyFrame: AnimationKeyFrameInterface, private identifier: Identifier) { 23 | this.properties = keyFrame; 24 | if (this.properties.from) this.properties.from = ReadValue(this.properties.from); 25 | if (this.properties.to) this.properties.to = ReadValue(this.properties.to); 26 | JsonBuilder.registerElement(identifier.namespace || "", this); 27 | } 28 | 29 | /** 30 | * Retrieves the full path of the keyframe using its identifier. 31 | * 32 | * @returns {string} - The full path of the keyframe, represented by the identifier's name. 33 | */ 34 | getFullPath() { 35 | return this.identifier.name || ""; 36 | } 37 | 38 | /** 39 | * Retrieves the properties of the keyframe, including "from", "to", and other settings. 40 | * 41 | * @returns {AnimationKeyFrameInterface} - The properties of the keyframe. 42 | */ 43 | getUI() { 44 | return this.properties; 45 | } 46 | 47 | /** 48 | * A static method that seems to serve as a placeholder, but has no functionality as of now. 49 | * 50 | * @private 51 | * @static 52 | */ 53 | private static apply() {} 54 | 55 | /** 56 | * A static property initialized to an empty string, likely intended to hold arguments or be overridden in the future. 57 | * 58 | * @private 59 | * @static 60 | * @type {string} 61 | */ 62 | private static arguments = ""; 63 | 64 | /** 65 | * A static method that seems to serve as a placeholder, but has no functionality as of now. 66 | * 67 | * @private 68 | * @static 69 | */ 70 | private static bind() {} 71 | 72 | /** 73 | * A static method that seems to serve as a placeholder, but has no functionality as of now. 74 | * 75 | * @private 76 | * @static 77 | */ 78 | private static call() {} 79 | 80 | /** 81 | * A static property initialized to an empty string, likely intended to hold caller information or be overridden in the future. 82 | * 83 | * @private 84 | * @static 85 | * @type {string} 86 | */ 87 | private static caller = ""; 88 | 89 | /** 90 | * A static property initialized to an empty string, likely intended to hold length-related data or be overridden in the future. 91 | * 92 | * @private 93 | * @static 94 | * @type {string} 95 | */ 96 | private static length = ""; 97 | 98 | /** 99 | * A static property initialized to an empty string, likely intended to hold a name or be overridden in the future. 100 | * 101 | * @private 102 | * @static 103 | * @type {string} 104 | */ 105 | private static name = ""; 106 | 107 | /** 108 | * A static method that seems to serve as a placeholder, but has no functionality as of now. 109 | * 110 | * @private 111 | * @static 112 | */ 113 | private static toString() {} 114 | } 115 | -------------------------------------------------------------------------------- /src/components/Class.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Represents a class with several static methods and properties that appear to serve as placeholders or utilities. 3 | * The methods in this class are defined but not yet implemented, potentially for future extensions or overriding. 4 | * 5 | * @class Class 6 | */ 7 | export class Class { 8 | /** 9 | * A static method that seems to serve as a placeholder, but has no functionality as of now. 10 | * 11 | * @private 12 | * @static 13 | */ 14 | private static apply() {} 15 | 16 | /** 17 | * A static property initialized to an empty string, likely intended to hold arguments or be overridden in the future. 18 | * 19 | * @private 20 | * @static 21 | * @type {string} 22 | */ 23 | private static arguments = ""; 24 | 25 | /** 26 | * A static method that seems to serve as a placeholder, but has no functionality as of now. 27 | * 28 | * @private 29 | * @static 30 | */ 31 | private static bind() {} 32 | 33 | /** 34 | * A static method that seems to serve as a placeholder, but has no functionality as of now. 35 | * 36 | * @private 37 | * @static 38 | */ 39 | private static call() {} 40 | 41 | /** 42 | * A static property initialized to an empty string, likely intended to hold caller information or be overridden in the future. 43 | * 44 | * @private 45 | * @static 46 | * @type {string} 47 | */ 48 | private static caller = ""; 49 | 50 | /** 51 | * A static property initialized to an empty string, likely intended to hold length-related data or be overridden in the future. 52 | * 53 | * @private 54 | * @static 55 | * @type {string} 56 | */ 57 | private static length = ""; 58 | 59 | /** 60 | * A static property initialized to an empty string, likely intended to hold a name or be overridden in the future. 61 | * 62 | * @private 63 | * @static 64 | * @type {string} 65 | */ 66 | private static name = ""; 67 | 68 | /** 69 | * A static method that seems to serve as a placeholder, but has no functionality as of now. 70 | * 71 | * @private 72 | * @static 73 | */ 74 | private static toString() {} 75 | } 76 | -------------------------------------------------------------------------------- /src/components/ItemDatas.ts: -------------------------------------------------------------------------------- 1 | import { ItemAuxID } from "../types/enums/ItemAuxID"; 2 | import { Class } from "./Class"; 3 | 4 | /** 5 | * Represents a collection of item-related utilities, extending from the `Class` class. 6 | * This class provides static methods for retrieving item IDs and auxiliary IDs based on item identifiers. 7 | * 8 | * @class Items 9 | * @extends Class 10 | */ 11 | export class Items extends Class { 12 | /** 13 | * Retrieves the item ID from the given item identifier string. 14 | * The ID is calculated by dividing the auxiliary ID by `65536`. 15 | * 16 | * @param {string} identification - The item identifier, potentially in the format of `minecraft:itemName` or `itemName`. 17 | * @returns {number} The item ID extracted from the identification string. 18 | * @static 19 | */ 20 | static getID(identification: string): number { 21 | return this.getAuxID(identification) / 65536; 22 | } 23 | 24 | /** 25 | * Retrieves the auxiliary ID for the specified item identifier. 26 | * If the identifier doesn't include a namespace, it defaults to `minecraft:`. 27 | * 28 | * @param {string} identification - The item identifier, potentially in the format of `minecraft:itemName` or `itemName`. 29 | * @returns {number} The auxiliary ID for the item. 30 | * @static 31 | */ 32 | static getAuxID(identification: string): number { 33 | // If the identifier doesn't contain a namespace, prepend "minecraft:" 34 | if (identification.split(":").length === 1) 35 | identification = `minecraft:${identification}`; 36 | 37 | // Return the corresponding auxiliary ID from the ItemAuxID enum 38 | return (ItemAuxID)[identification]; 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /src/components/LocalizeText.ts: -------------------------------------------------------------------------------- 1 | import { StaticUIInterface } from "../types/components/UIInterface"; 2 | import { Label } from "../types/objects/elements/Label"; 3 | import { UI } from "./UI"; 4 | 5 | interface LocalizeTextInterface { 6 | [language: string]: { 7 | [key: string]: string; 8 | }; 9 | } 10 | 11 | interface SetLocalizeTextInterface { 12 | [language: string]: string; 13 | } 14 | 15 | export const localizeText: LocalizeTextInterface = {}; 16 | 17 | export class LocalizeText { 18 | constructor(public key: string, value: string | SetLocalizeTextInterface) { 19 | if (typeof value === "string") { 20 | this.set({ en_US: value }); 21 | } else { 22 | this.set(value); 23 | } 24 | } 25 | 26 | createLabel(properties?: Omit, identifier?: StaticUIInterface) { 27 | const label = UI.label(properties, identifier); 28 | 29 | label.setProperties({ 30 | text: this.key, 31 | }); 32 | 33 | return label; 34 | } 35 | 36 | set(texts: SetLocalizeTextInterface) { 37 | for (const language in texts) { 38 | (localizeText[language] ||= {})[this.key] = texts[language]; 39 | } 40 | } 41 | 42 | get() { 43 | return this.key; 44 | } 45 | 46 | static register(key: string, value: string | SetLocalizeTextInterface) { 47 | return new LocalizeText(key, value); 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /src/components/Random.ts: -------------------------------------------------------------------------------- 1 | import { UUID } from "../types/objects/Manifest"; 2 | import { Class } from "./Class"; 3 | import { Configs } from "../compilers/Config"; 4 | import { Binding } from "../types/values/Binding"; 5 | 6 | export class Random extends Class { 7 | private static namespaces?: Array; 8 | 9 | private static isObfuscate?: boolean; 10 | private static uniqueKey = Random.genString(5, 16).toUpperCase(); 11 | private static counter = { element: 0, animation: 0, binding: 0 }; 12 | 13 | static genString(length: number, base: number = 32) { 14 | return Array.from({ length }, v => Math.floor(Math.random() * base).toString(base)).join(""); 15 | } 16 | 17 | static getName(length: number = Configs.getConfig().compiler.UI.nameLength) { 18 | if (Random.isObfuscate ?? Configs.getConfig().compiler.UI.obfuscateName) return Random.genString(length); 19 | const counter = ++Random.counter.element; 20 | return `${Random.uniqueKey}_ELEMENT_${counter.toString(16).toUpperCase()}`; 21 | } 22 | 23 | static getAnimationName(length: number = Configs.getConfig().compiler.UI.nameLength) { 24 | if (Random.isObfuscate ?? Configs.getConfig().compiler.UI.obfuscateName) return Random.genString(length); 25 | const counter = ++Random.counter.animation; 26 | return `${Random.uniqueKey}_ANIMATION_${counter.toString(16).toUpperCase()}`; 27 | } 28 | 29 | static getNamespace() { 30 | if (!Random.namespaces) { 31 | Random.namespaces = (Random.isObfuscate ?? Configs.getConfig().compiler.UI.obfuscateName) ? 32 | Array.from({ length: Configs.getConfig().compiler.UI.namespaceAmount }, () => Random.genString(Configs.getConfig().compiler.UI.namespaceLength)) : 33 | Array.from({ length: Configs.getConfig().compiler.UI.namespaceAmount }, ($, index) => `${Random.uniqueKey}_NAMESPACE_${(index + 1).toString(16).toUpperCase()}`); 34 | } 35 | 36 | const randomIndex = Math.floor(Math.random() * Random.namespaces.length); 37 | return Random.namespaces[randomIndex]; 38 | } 39 | 40 | static getUUID(): UUID { 41 | return ( 42 | "$$$$$$$$-$$$$-$$$$-$$$$-$$$$$$$$$$$$".replaceAll(/\$/g, () => 43 | Math.floor(Math.random() * 16).toString(16) 44 | ) 45 | ); 46 | } 47 | 48 | static bindingName(): Binding { 49 | if (Random.isObfuscate ?? Configs.getConfig().compiler.UI.obfuscateName) return `#${Random.getName()}`; 50 | const counter = ++Random.counter.binding; 51 | return `#${Random.uniqueKey}_BINDING_${counter.toString(16).toUpperCase()}`; 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /src/index.ts: -------------------------------------------------------------------------------- 1 | console.time("COMPILER"); 2 | import "./compilers/PreCompile"; 3 | import "./compilers/generator/Template"; 4 | export * from "./compilers/Config"; 5 | export * from "./components/AddCollectionChill"; 6 | export * from "./components/Random"; 7 | export * from "./components/Animation"; 8 | export * from "./components/Modify"; 9 | export * from "./components/Vanilla"; 10 | export * from "./components/AnimationKeyFrame"; 11 | export * from "./components/UI"; 12 | export * from "./components/LocalizeText"; 13 | export * from "./types/components/Identifier"; 14 | export * from "./types/components/UIInterface"; 15 | export * from "./types/components/ChildIdentifier"; 16 | export * from "./types/components/UIIdentifier"; 17 | export * from "./types/components/NameCallback"; 18 | export * from "./types/enums/MappingTo"; 19 | export * from "./types/enums/Types"; 20 | export * from "./types/enums/FontType"; 21 | export * from "./types/enums/BindingType"; 22 | export * from "./types/enums/EasingTypes"; 23 | export * from "./types/enums/Rotation"; 24 | export * from "./types/enums/Direction"; 25 | export * from "./types/enums/InputModeCondition"; 26 | export * from "./types/enums/BindingName"; 27 | export * from "./types/enums/Scope"; 28 | export * from "./types/enums/FocusNavigationMode"; 29 | export * from "./types/enums/JsonUIArrayName"; 30 | export * from "./types/enums/TextTypes"; 31 | export * from "./types/enums/Collection"; 32 | export * from "./types/enums/EnumColor"; 33 | export * from "./types/enums/BindingCondition"; 34 | export * from "./types/enums/Orientation"; 35 | export * from "./types/enums/MappingTypes"; 36 | export * from "./types/enums/FontSize"; 37 | export * from "./types/enums/ClipDirecion"; 38 | export * from "./types/enums/TextureFileSystem"; 39 | export * from "./types/enums/Renderer"; 40 | export * from "./types/enums/MappingFrom"; 41 | export * from "./types/enums/Anchor"; 42 | export * from "./types/enums/AnimTypes"; 43 | export * from "./types/objects/Manifest"; 44 | export * from "./types/objects/Factory"; 45 | export * from "./types/objects/properties/Sliders"; 46 | export * from "./types/objects/properties/TooltipTriggers"; 47 | export * from "./types/objects/properties/StackPanels"; 48 | export * from "./types/objects/properties/CollectionIndexs"; 49 | export * from "./types/objects/properties/Sounds"; 50 | export * from "./types/objects/properties/Screens"; 51 | export * from "./types/objects/properties/Collections"; 52 | export * from "./types/objects/properties/Inputs"; 53 | export * from "./types/objects/properties/ScrollViews"; 54 | export * from "./types/objects/properties/Focus"; 55 | export * from "./types/objects/properties/Properties"; 56 | export * from "./types/objects/properties/SelectionWheels"; 57 | export * from "./types/objects/properties/Texts"; 58 | export * from "./types/objects/properties/Grids"; 59 | export * from "./types/objects/properties/Specials"; 60 | export * from "./types/objects/properties/FocusContainerCustom"; 61 | export * from "./types/objects/properties/TTS"; 62 | export * from "./types/objects/properties/Renderers"; 63 | export * from "./types/objects/properties/SliderBoxs"; 64 | export * from "./types/objects/properties/Sprites"; 65 | export * from "./types/objects/properties/Layouts"; 66 | export * from "./types/objects/properties/Variables"; 67 | export * from "./types/objects/properties/Buttons"; 68 | export * from "./types/objects/properties/Toggles"; 69 | export * from "./types/objects/properties/Controls"; 70 | export * from "./types/objects/properties/Dropdowns"; 71 | export * from "./types/objects/properties/TextEdits"; 72 | export * from "./types/objects/Animation"; 73 | export * from "./types/objects/ButtonMapping"; 74 | export * from "./types/objects/BindingInterface"; 75 | export * from "./types/objects/elements/Label"; 76 | export * from "./types/objects/elements/EditBox"; 77 | export * from "./types/objects/elements/Grid"; 78 | export * from "./types/objects/elements/Screen"; 79 | export * from "./types/objects/elements/TooltipTrigger"; 80 | export * from "./types/objects/elements/Slider"; 81 | export * from "./types/objects/elements/PropertiesType"; 82 | export * from "./types/objects/elements/Button"; 83 | export * from "./types/objects/elements/InputPanel"; 84 | export * from "./types/objects/elements/ScrollView"; 85 | export * from "./types/objects/elements/StackPanel"; 86 | export * from "./types/objects/elements/panel"; 87 | export * from "./types/objects/elements/ScrollbarTrack"; 88 | export * from "./types/objects/elements/SelectionWheel"; 89 | export * from "./types/objects/elements/SliderBox"; 90 | export * from "./types/objects/elements/Toggle"; 91 | export * from "./types/objects/elements/Custom"; 92 | export * from "./types/objects/elements/ScrollbarBox"; 93 | export * from "./types/objects/elements/Dropdown"; 94 | export * from "./types/objects/elements/CollectionPanel"; 95 | export * from "./types/objects/elements/Image"; 96 | export * from "./types/objects/PropertyBag"; 97 | export * from "./types/objects/Variables"; 98 | export * from "./types/objects/Sound"; 99 | export * from "./types/objects/BindingHook"; 100 | export * from "./types/values/Number"; 101 | export * from "./types/values/Binding"; 102 | export * from "./types/values/TargetElementPath"; 103 | export * from "./types/values/Variable"; 104 | export * from "./types/values/Hex"; 105 | export * from "./types/values/Str"; 106 | export * from "./types/values/ElementPath"; 107 | export * from "./types/values/ColorVector"; 108 | export * from "./types/values/Bool"; 109 | export * from "./types/values/RangeVector"; 110 | export * from "./types/values/Any"; 111 | export * from "./types/values/StringVector"; 112 | export * from "./types/values/Vector"; 113 | export * from "./compilers/reader/ReadProperties"; 114 | export * from "./compilers/reader/CurrentLine"; 115 | export * from "./compilers/reader/ReadBinding"; 116 | export * from "./compilers/reader/Object"; 117 | export * from "./compilers/reader/Color"; 118 | export * from "./compilers/reader/Audio"; 119 | export * from "./compilers/BindingCompiler"; 120 | export * from "./compilers/Compiler"; 121 | export * from "./compilers/BindingFunctions"; 122 | export * from "./compilers/Compress"; 123 | export * from "./compilers/Encoder"; 124 | export * from "./compilers/Installer"; 125 | export * from "./compilers/generator/Manifest"; 126 | export * from "./compilers/generator/Sounds"; 127 | export * from "./compilers/generator/GenerateDir"; 128 | export * from "./compilers/generator/Save"; 129 | export * from "./compilers/generator/LangBuilder"; 130 | export * from "./compilers/generator/UIBuilder"; 131 | export * from "./compilers/generator/Log"; 132 | export * from "./compilers/generator/JsonBuilder"; 133 | export * from "./compilers/generator/SearchFiles"; 134 | export * from "./compilers/reader/Env"; 135 | export * from "./compilers/reader/GlobalVariables"; -------------------------------------------------------------------------------- /src/template.ts: -------------------------------------------------------------------------------- 1 | // Env 2 | export const env = `const env = {}; 3 | 4 | module.exports = { env };`; 5 | 6 | // Global variables 7 | export const globalVariables = `const {} = require("jsonui-scripting"); 8 | 9 | const global_variables = {}; 10 | 11 | module.exports = { global_variables };`; 12 | 13 | // Config 14 | export const config = `/** 15 | * Configuration object for the JsonUI Scripting build process. 16 | * @type {import('jsonui-scripting').Config} 17 | */ 18 | const config = { 19 | compiler: { 20 | autoCompress: false, 21 | fileExtension: "json", 22 | encodeJson: false, 23 | UI: { 24 | nameLength: 32, 25 | namespaceAmount: 16, 26 | namespaceLength: 32, 27 | obfuscateName: false, 28 | obfuscateType: false, 29 | }, 30 | }, 31 | installer: { 32 | autoInstall: true, 33 | developEvironment: true, 34 | previewVersion: false, 35 | customPath: false, 36 | installPath: "/your/minecraft/data/path", 37 | }, 38 | manifest: { 39 | name: "JsonUI Scripting", 40 | description: "Build with JsonUI Scripting <3", 41 | }, 42 | }; 43 | 44 | module.exports = { config }`; 45 | 46 | // Gitignore 47 | export const gitignore = `# Node packages 48 | node_modules 49 | 50 | # Build Folders 51 | .minecraft 52 | .build 53 | .save 54 | 55 | # Build variables 56 | asakiyuki.env.cjs 57 | 58 | # Compress package 59 | Minecraft-UIBuild.mcpack`; 60 | -------------------------------------------------------------------------------- /src/types/components/ChildIdentifier.ts: -------------------------------------------------------------------------------- 1 | import { UI } from "../../components/UI"; 2 | import { Properties } from "../objects/properties/Properties"; 3 | import { Identifier } from "./Identifier"; 4 | 5 | export interface ChildIdentifier { 6 | name?: string; 7 | properties?: Properties; 8 | extend?: string | UI | Identifier; 9 | } 10 | 11 | export interface ChildElement { 12 | [key: string]: Properties | {}; 13 | } 14 | -------------------------------------------------------------------------------- /src/types/components/Identifier.ts: -------------------------------------------------------------------------------- 1 | export interface Identifier { 2 | name?: string 3 | namespace?: string 4 | }; -------------------------------------------------------------------------------- /src/types/components/NameCallback.ts: -------------------------------------------------------------------------------- 1 | import { Modify } from "../../components/Modify"; 2 | import { UI } from "../../components/UI"; 3 | 4 | export type UIChildNameCallback = (arg: UI | Modify, name: string) => void; 5 | -------------------------------------------------------------------------------- /src/types/components/UIIdentifier.ts: -------------------------------------------------------------------------------- 1 | export interface UIIdentifier { 2 | name?: string, 3 | namespace?: string 4 | } -------------------------------------------------------------------------------- /src/types/components/UIInterface.ts: -------------------------------------------------------------------------------- 1 | import { UI } from "../../components/UI"; 2 | import { Types } from "../enums/Types"; 3 | import { Properties } from "../objects/properties/Properties"; 4 | import { Identifier } from "./Identifier"; 5 | 6 | export interface UIInterface extends StaticUIInterface { 7 | type?: Types; 8 | extends?: string | Identifier | UI; 9 | } 10 | 11 | export interface StaticUIInterface extends ExtendInterface { 12 | properties?: Properties; 13 | } 14 | 15 | export interface ExtendInterface { 16 | name?: string; 17 | namespace?: string; 18 | } 19 | -------------------------------------------------------------------------------- /src/types/enums/Anchor.ts: -------------------------------------------------------------------------------- 1 | export enum Anchor { 2 | TopLeft = "top_left", 3 | TopMiddle = "top_middle", 4 | TopRight = "top_right", 5 | LeftMiddle = "left_middle", 6 | Center = "center", 7 | RightMiddle = "right_middle", 8 | BottomLeft = "bottom_left", 9 | BottomMiddle = "bottom_middle", 10 | BottomRight = "bottom_right" 11 | } -------------------------------------------------------------------------------- /src/types/enums/AnimTypes.ts: -------------------------------------------------------------------------------- 1 | export enum AnimationTypes { 2 | Alpha = "alpha", 3 | Clip = "clip", 4 | Color = "color", 5 | FlipBook = "flip_book", 6 | Offset = "offset", 7 | Size = "size", 8 | Uv = "uv", 9 | Wait = "wait", 10 | AsepriteFlipBook = "aseprite_flip_book", 11 | } 12 | -------------------------------------------------------------------------------- /src/types/enums/BindingCondition.ts: -------------------------------------------------------------------------------- 1 | export enum BindingCondition { 2 | Always = 'always', 3 | AlwaysWhenVisible = 'always_when_visible', 4 | Visible = 'visible', 5 | Once = 'once', 6 | None = 'none', 7 | VisibilityChanged = 'visibility_changed' 8 | } -------------------------------------------------------------------------------- /src/types/enums/BindingType.ts: -------------------------------------------------------------------------------- 1 | export enum BindingType { 2 | Global = 'global', 3 | View = 'view', 4 | Collection = 'collection', 5 | CollectionDetails = 'collection_details', 6 | None = 'none' 7 | } -------------------------------------------------------------------------------- /src/types/enums/ClipDirecion.ts: -------------------------------------------------------------------------------- 1 | export enum ClipDirection { 2 | Left = "left", 3 | Right = "right", 4 | Up = "up", 5 | Down = "down", 6 | Center = "center" 7 | } -------------------------------------------------------------------------------- /src/types/enums/Direction.ts: -------------------------------------------------------------------------------- 1 | export enum Direction { 2 | Vertical = "vertical", 3 | Horizontal = "horizontal", 4 | Both = "both" 5 | } -------------------------------------------------------------------------------- /src/types/enums/EasingTypes.ts: -------------------------------------------------------------------------------- 1 | export enum EasingTypes { 2 | Linear = "linear", 3 | Spring = "spring", 4 | InQuad = "in_quad", 5 | OutQuad = "out_quad", 6 | InOutQuad = "in_out_quad", 7 | InCuic = "in_cubic", 8 | OutCubic = "out_cubic", 9 | InOutCubic = "in_out_cubic", 10 | InQuart = "in_quart", 11 | OutQuart = "out_quart", 12 | InOutQuart = "in_out_quart", 13 | InQuint = "in_quint", 14 | OutQuint = "out_quint", 15 | InOutQuint = "in_out_quint", 16 | InSine = "in_sine", 17 | OutSine = "out_sine", 18 | InOutSine = "in_out_sine", 19 | InExpo = "in_expo", 20 | OutExpo = "out_expo", 21 | InOutExpo = "in_out_expo", 22 | InCirc = "in_circ", 23 | OutCirc = "out_circ", 24 | InOutCirc = "in_out_circ", 25 | InBounce = "in_bounce", 26 | OutBounce = "out_bounce", 27 | InOutBounce = "in_out_bounce", 28 | InBack = "in_back", 29 | OutBack = "out_back", 30 | InOutBack = "in_out_back", 31 | InElastic = "in_elastic", 32 | OutElastic = "out_elastic", 33 | InOutElastic = "in_out_elastic" 34 | } -------------------------------------------------------------------------------- /src/types/enums/EnumColor.ts: -------------------------------------------------------------------------------- 1 | export enum Color { 2 | White = "white", 3 | Black = "black", 4 | Red = "red", 5 | Green = "green", 6 | Yellow = "yellow", 7 | Blue = "blue", 8 | Gray = "gray" 9 | } -------------------------------------------------------------------------------- /src/types/enums/FocusNavigationMode.ts: -------------------------------------------------------------------------------- 1 | export enum FocusNavigationMode { 2 | None = "none", 3 | Stop = "stop", 4 | Custom = "custom", 5 | Contained = "contained" 6 | } -------------------------------------------------------------------------------- /src/types/enums/FontSize.ts: -------------------------------------------------------------------------------- 1 | export enum FontSize { 2 | Small = "small", 3 | Normal = "normal", 4 | Large = "large", 5 | ExtraLarge = "extra_large" 6 | } -------------------------------------------------------------------------------- /src/types/enums/FontType.ts: -------------------------------------------------------------------------------- 1 | export enum FontType { 2 | Default = "default", 3 | Rune = "rune", 4 | Unicode = "unicode", 5 | Smooth = "smooth", 6 | MinecraftTen = "MinecraftTen" 7 | } -------------------------------------------------------------------------------- /src/types/enums/InputModeCondition.ts: -------------------------------------------------------------------------------- 1 | export enum InputModeCondition { 2 | NotGaze = "not_gaze", 3 | NotGamepad = "not_gamepad", 4 | GamePadNadNotGaze = "gamepad_and_not_gaze" 5 | } -------------------------------------------------------------------------------- /src/types/enums/ItemAuxID.ts: -------------------------------------------------------------------------------- 1 | export enum ItemAuxID { 2 | ': Not Found' = 0 3 | } -------------------------------------------------------------------------------- /src/types/enums/JsonUIArrayName.ts: -------------------------------------------------------------------------------- 1 | export enum ArrayName { 2 | Controls = "controls", 3 | Bindings = "bindings", 4 | Anims = "anims", 5 | Variables = "variables", 6 | ButtonMappings = "button_mappings" 7 | }; -------------------------------------------------------------------------------- /src/types/enums/MappingFrom.ts: -------------------------------------------------------------------------------- 1 | export enum MappingFrom { 2 | MenuExit = "button.menu_exit", 3 | MenuCancel = "button.menu_cancel", 4 | MenuInventoryCancel = "button.menu_inventory_cancel ", 5 | MenuOk = "button.menu_ok", 6 | MenuSelect = "button.menu_select", 7 | ControllerSelect = "button.controller_select", 8 | MenuSecondarySelect = "button.menu_secondary_select", 9 | ControllerSecondarySelect = "button.controller_secondary_select", 10 | ControllerSecondarySelectLeft = "button.controller_secondary_select_left", 11 | ControllerSecondarySelectRight = "button.controller_secondary_select_right", 12 | ControllerStart = "button.controller_start", 13 | MenuUp = "button.menu_up", 14 | MenuDown = "button.menu_down", 15 | MenuLeft = "button.menu_left", 16 | MenuRight = "button.menu_right", 17 | MenuTabLeft = "button.menu_tab_left", 18 | MenuTabRight = "button.menu_tab_right", 19 | MenuAlternateTabLeft = "button.menu_alternate_tab_left", 20 | MenuAlternateTabRight = "button.menu_alternate_tab_right", 21 | MenuAutocomplete = "button.menu_autocomplete", 22 | MenuAutocompleteBack = "button.menu_autocomplete_back", 23 | ControllerAutocomplete = "button.controller_autocomplete", 24 | ControllerAutocompleteBack = "button.controller_autocomplete_back", 25 | MenuEditUp = "button.menu_textedit_up", 26 | MenuEditDown = "button.menu_textedit_down", 27 | ControllerEditUp = "button.controller_textedit_u", 28 | ControllerEditDown = "button.controller_textedit_down", 29 | MenuAutoPlace = "button.menu_auto_place", 30 | MenuInventoryDrop = "button.menu_inventory_drop", 31 | MenuInventoryDropAll = "button.menu_inventory_drop_all", 32 | MenuClear = "button.menu_clear", 33 | Chat = "button.chat", 34 | MobEffects = "button.mobeffects", 35 | keyEmote = "key.emote", 36 | Slot0 = "button.slot0", 37 | Slot1 = "button.slot1", 38 | Slot2 = "button.slot2", 39 | Slot3 = "button.slot3", 40 | Slot4 = "button.slot4", 41 | Slot5 = "button.slot5", 42 | Slot6 = "button.slot6", 43 | Slot7 = "button.slot7", 44 | Slot8 = "button.slot8", 45 | Slot9 = "button.slot9", 46 | InventoryRight = "button.inventory_right", 47 | InventoryLeft = "button.inventory_left", 48 | Scoreboard = "button.scoreboard", 49 | HideGui = "button.hide_gui", 50 | HideTooltips = "button.hide_tooltips", 51 | HidePaperdoll = "button.hide_paperdoll", 52 | MenuVRRealign = "button.menu_vr_realign" 53 | } -------------------------------------------------------------------------------- /src/types/enums/MappingTypes.ts: -------------------------------------------------------------------------------- 1 | export enum MappingType { 2 | Global = "global", 3 | Pressed = "pressed", 4 | DoublePressed = "double_pressed", 5 | Focused = "forcused" 6 | } -------------------------------------------------------------------------------- /src/types/enums/Orientation.ts: -------------------------------------------------------------------------------- 1 | export enum Orientation { 2 | Vertical = "vertical", 3 | Horizontal = "horizontal" 4 | } -------------------------------------------------------------------------------- /src/types/enums/Renderer.ts: -------------------------------------------------------------------------------- 1 | export enum Renderer { 2 | HoverText = "hover_text_renderer", 3 | Structure3D = "3d_structure_renderer", 4 | SplashText = "splash_text_renderer", 5 | UIHoloCursor = "ui_holo_cursor", 6 | TrialTime = "trial_time_renderer", 7 | Panorama = "panorama_renderer", 8 | ActorPortrain = "actor_portrait_renderer", 9 | BannerPattern = "banner_pattern_renderer", 10 | LivePlayer = "live_player_renderer", 11 | WebView = "web_view_renderer", 12 | Hunger = "hunger_renderer", 13 | Bubbles = "bubbles_renderer", 14 | MobEffects = "mob_effects_renderer", 15 | Curson = "cursor_renderer", 16 | ProgressIndicator = "progress_indicator_renderer", 17 | Camera = "camera_renderer", 18 | HorseJump = "horse_jump_renderer", 19 | Armor = "armor_renderer", 20 | HorseHeart = "horse_heart_renderer", 21 | Heart = "heart_renderer", 22 | HotbarCooldown = "hotbar_cooldown_renderer", 23 | Hotbar = "hotbar_renderer", 24 | HudPlayer = "hud_player_renderer", 25 | LiveHorse = "live_horse_renderer", 26 | HolographucPost = "holographic_postrenderer", 27 | EnchantingBook = "enchanting_book_renderer", 28 | DebugScreen = "debug_screen_renderer", 29 | Gradient = "gradient_renderer", 30 | PaperDoll = "paper_doll_renderer", 31 | NameTag = "name_tag_renderer", 32 | FlyingItem = "flying_item_renderer", 33 | InventoryItem = "inventory_item_renderer", 34 | Credits = "credits_renderer", 35 | Vignette = "vignette_renderer", 36 | ProgressBar = "progress_bar_renderer", 37 | DebugOverlay = "debug_overlay_renderer", 38 | Background = "background_renderer", 39 | BohrModel = "bohr_model_renderer" 40 | } -------------------------------------------------------------------------------- /src/types/enums/Rotation.ts: -------------------------------------------------------------------------------- 1 | export enum Rotation { 2 | Auto = "auto", 3 | GestureX = "gesture_x", 4 | CustomY = "custom_y" 5 | } -------------------------------------------------------------------------------- /src/types/enums/Scope.ts: -------------------------------------------------------------------------------- 1 | export enum Scope { 2 | View = "view", 3 | Controller = "controller" 4 | } -------------------------------------------------------------------------------- /src/types/enums/TextTypes.ts: -------------------------------------------------------------------------------- 1 | export enum TextType { 2 | ExtendedASCII = "ExtendedASCII", 3 | IdentifierChars = "IdentifierChars", 4 | NumberChars = "NumberChars" 5 | } -------------------------------------------------------------------------------- /src/types/enums/TextureFileSystem.ts: -------------------------------------------------------------------------------- 1 | export enum TextureFileSystem { 2 | InUserPackage = "InUserPackage", 3 | InAppPackage = "InAppPackage", 4 | RawPath = "RawPath", 5 | RawPersistent = "RawPersistent", 6 | InSettingsDir = "InSettingsDir", 7 | InExternalDir = "InExternalDir", 8 | InServerPackage = "InServerPackage", 9 | InDataDir = "InDataDir", 10 | InUserDir = "InUserDir", 11 | InWorldDir = "InWorldDir", 12 | StoreCache = "StoreCache" 13 | } 14 | -------------------------------------------------------------------------------- /src/types/enums/Types.ts: -------------------------------------------------------------------------------- 1 | export enum Types { 2 | Panel = "panel", 3 | StackPanel = "stack_panel", 4 | CollectionPanel = "collection_panel", 5 | InputPanel = "input_panel", 6 | Grid = "grid", 7 | Button = "button", 8 | Toggle = "toggle", 9 | Label = "label", 10 | Image = "image", 11 | Dropdown = "dropdown", 12 | Slider = "slider", 13 | SliderBox = "slider_box", 14 | EditBox = "edit_box", 15 | ScrollView = "scroll_view", 16 | ScrollbarTrack = "scrollbar_track", 17 | ScrollbarBox = "scrollbar_box", 18 | Screen = "screen", 19 | Custom = "custom", 20 | SelectionWheel = "selection_wheel", 21 | TooltipTrigger = "tooltip_trigger", 22 | 23 | // Special 24 | Factory = "Any", 25 | LabelCycler = "Any", 26 | ImageCycler = "Any", 27 | GridPageIndicator = "Any", 28 | CarouselLabel = "Any", 29 | ScrollTrack = "Any", 30 | Any = "Any", 31 | } 32 | -------------------------------------------------------------------------------- /src/types/objects/Animation.ts: -------------------------------------------------------------------------------- 1 | import { AnimationTypes } from "../enums/AnimTypes"; 2 | import { EasingTypes } from "../enums/EasingTypes"; 3 | import { Float, Int } from "../values/Number"; 4 | import { Vector2, Vector3, Vector4 } from "../values/Vector"; 5 | 6 | /** 7 | * Interface representing the main structure of an animation. 8 | */ 9 | export interface AnimationInterface { 10 | /** 11 | * The starting value of the animation, which can be a single float or a vector (2D, 3D, or 4D). 12 | */ 13 | from: Float | Vector2 | Vector3 | Vector4; 14 | 15 | /** 16 | * The type of the animation (e.g., linear, ease-in, etc.). 17 | */ 18 | type: AnimationTypes; 19 | 20 | /** 21 | * Optional flag to define if the animation should loop. 22 | * @default false 23 | */ 24 | loop?: boolean; 25 | 26 | durationPerKeyFrame?: number; 27 | 28 | /** 29 | * An array of keyframes, where each keyframe can either be an AnimationKey object or a float. 30 | */ 31 | keyFrames: Array; 32 | } 33 | 34 | /** 35 | * Interface representing a single keyframe in an animation. 36 | */ 37 | export interface AnimationKey { 38 | /** 39 | * The starting value of the keyframe, which can be a float or a vector (2D, 3D, or 4D). 40 | */ 41 | from?: Float | Vector2 | Vector3 | Vector4; 42 | 43 | /** 44 | * The ending value of the keyframe, which can be a float or a vector (2D, 3D, or 4D). 45 | */ 46 | to?: Float | Vector2 | Vector3 | Vector4; 47 | 48 | /** 49 | * The duration of the keyframe, in seconds. 50 | */ 51 | duration?: Float; 52 | 53 | /** 54 | * The easing function to use for the animation (e.g., ease-out, ease-in). 55 | */ 56 | easing?: EasingTypes; 57 | 58 | /** 59 | * The initial UV coordinates for texture animations. 60 | */ 61 | initial_uv?: Vector2; 62 | 63 | /** 64 | * The frames per second (FPS) for the animation. 65 | */ 66 | fps?: Int; 67 | 68 | /** 69 | * The number of frames for the keyframe. 70 | */ 71 | frame_count?: Int; 72 | 73 | /** 74 | * The frame step for the animation. 75 | */ 76 | frame_step?: Float; 77 | 78 | /** 79 | * If true, the animation will reverse after reaching the end. 80 | * @default false 81 | */ 82 | reversible?: boolean; 83 | 84 | /** 85 | * If true, the animation can be reset to its initial state. 86 | * @default false 87 | */ 88 | resettable?: boolean; 89 | 90 | /** 91 | * If true, the animation's starting alpha will be scaled. 92 | * @default false 93 | */ 94 | scale_from_starting_alpha?: boolean; 95 | 96 | /** 97 | * If true, the animation will be activated. 98 | * @default false 99 | */ 100 | activated?: boolean; 101 | 102 | /** 103 | * Defines whether to destroy the object at the end of the animation. 104 | */ 105 | destroy_at_end?: string; 106 | 107 | /** 108 | * The name of the event to trigger when the animation plays. 109 | */ 110 | play_event?: string; 111 | 112 | /** 113 | * The name of the event to trigger when the animation starts. 114 | */ 115 | start_event?: string; 116 | 117 | /** 118 | * The name of the event to trigger when the animation ends. 119 | */ 120 | end_event?: string; 121 | 122 | /** 123 | * The name of the event to trigger when the animation resets. 124 | */ 125 | reset_event?: string; 126 | } 127 | 128 | /** 129 | * Interface representing a keyframe in the animation, extending from AnimationKey with additional properties. 130 | */ 131 | export interface AnimationKeyFrameInterface extends AnimationKey { 132 | /** 133 | * The type of the animation (e.g., linear, ease-in, etc.). 134 | */ 135 | type: AnimationTypes; 136 | 137 | /** 138 | * The name of the next keyframe to trigger, if applicable. 139 | */ 140 | next?: string; 141 | } 142 | -------------------------------------------------------------------------------- /src/types/objects/BindingHook.ts: -------------------------------------------------------------------------------- 1 | export type BindingHook = [string, string, string]; 2 | -------------------------------------------------------------------------------- /src/types/objects/BindingInterface.ts: -------------------------------------------------------------------------------- 1 | import { BindingType } from "../enums/BindingType"; 2 | import { BindingName } from "../enums/BindingName"; 3 | import { Collection } from "../enums/Collection"; 4 | import { BindingCondition } from "../enums/BindingCondition"; 5 | import { Var } from "../values/Variable"; 6 | import { Binding } from "../values/Binding"; 7 | 8 | /** 9 | * Interface representing the binding settings between source and target properties. 10 | */ 11 | export interface BindingInterface { 12 | /** 13 | * A value that can be ignored, either as a variable or a boolean. 14 | * If true, the binding will be ignored. 15 | */ 16 | ignored?: Var | boolean; 17 | 18 | /** 19 | * The type of the binding, either a variable or a predefined binding type. 20 | */ 21 | binding_type?: Var | BindingType; 22 | 23 | /** 24 | * The name of the binding, either a variable or a predefined binding name. 25 | */ 26 | binding_name?: Var | BindingName; 27 | 28 | /** 29 | * An optional override for the binding name. Can be a variable, a binding name, or a string. 30 | */ 31 | binding_name_override?: Var | BindingName | string; 32 | 33 | /** 34 | * The name of the collection that the binding belongs to, either as a variable or a collection object. 35 | */ 36 | binding_collection_name?: Var | Collection; 37 | 38 | /** 39 | * The prefix to use for the binding collection, which can be a variable or a string. 40 | */ 41 | binding_collection_prefix?: Var | string; 42 | 43 | /** 44 | * A condition that determines whether the binding should be applied. This can be a variable or a predefined binding condition. 45 | */ 46 | binding_condition?: Var | BindingCondition; 47 | 48 | /** 49 | * The name of the source control, either as a variable or a string. 50 | */ 51 | source_control_name?: Var | string; 52 | 53 | /** 54 | * The name(s) of the source property, which could be a single string or an array of strings. 55 | */ 56 | source_property_name?: string | [string]; 57 | 58 | /** 59 | * The name of the target property, which could be a variable, binding name, or binding. 60 | */ 61 | target_property_name?: Var | BindingName | Binding; 62 | 63 | /** 64 | * A flag indicating if sibling scope resolution should be applied. 65 | * If true, the sibling scope will be resolved. 66 | */ 67 | resolve_sibling_scope?: Var | boolean; 68 | } 69 | -------------------------------------------------------------------------------- /src/types/objects/ButtonMapping.ts: -------------------------------------------------------------------------------- 1 | import { InputModeCondition, Scope } from "../.."; 2 | import { MappingFrom } from "../enums/MappingFrom"; 3 | import { MappingTo } from "../enums/MappingTo"; 4 | import { MappingType } from "../enums/MappingTypes"; 5 | import { Bool } from "../values/Bool"; 6 | 7 | export interface ButtonMapping { 8 | ignored?: Bool; 9 | from_button_id?: string | MappingFrom; 10 | to_button_id?: string | MappingTo; 11 | mapping_type?: MappingType; 12 | scope?: Scope; 13 | input_mode_condition?: InputModeCondition; 14 | ignore_input_scope?: Bool; 15 | consume_event?: Bool; 16 | handle_select?: Bool; 17 | handle_deselect?: Bool; 18 | button_up_right_of_first_refusal?: Bool; 19 | } 20 | -------------------------------------------------------------------------------- /src/types/objects/Factory.ts: -------------------------------------------------------------------------------- 1 | import { Any } from "../values/Any"; 2 | 3 | export interface Factory { 4 | [key: string]: Any 5 | } -------------------------------------------------------------------------------- /src/types/objects/Manifest.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Represents the format version of the manifest. 3 | */ 4 | export type FormatVerson = 1 | 2; 5 | 6 | /** 7 | * Represents a version as a tuple of three numbers. 8 | * Example: [1, 0, 0] 9 | */ 10 | export type Version = [number, number, number]; 11 | 12 | /** 13 | * Represents a semantic versioning string, including optional pre-release and build metadata. 14 | * Examples: 15 | * - "1.0.0" 16 | * - "1.0.0-1" 17 | * - "1.0.0+123" 18 | */ 19 | export type SemverString = 20 | | `${number}.${number}.${number}` 21 | | `${number}.${number}.${number}-${number}` 22 | | `${number}.${number}.${number}+${number}`; 23 | 24 | /** 25 | * Represents a universally unique identifier (UUID) in the standard format. 26 | * Example: "123e4567-e89b-12d3-a456-426614174000" 27 | */ 28 | export type UUID = `${string}-${string}-${string}-${string}-${string}`; 29 | 30 | /** 31 | * Enum representing various types of modules. 32 | */ 33 | export enum Type { 34 | Resources = "resources", 35 | Data = "data", 36 | WorldTemplate = "world_template", 37 | Script = "script", 38 | } 39 | 40 | /** 41 | * Enum representing available scripting languages. 42 | */ 43 | export enum Language { 44 | JavaScript = "javascript", 45 | } 46 | 47 | /** 48 | * Enum for module names that are used in Minecraft-related modules. 49 | */ 50 | export enum ModuleName { 51 | Server = "@minecraft/server", 52 | ServerUI = "@minecraft/server-ui", 53 | ServerGametest = "@minecraft/server-gametest", 54 | ServerNet = "@minecraft/server-net", 55 | ServerAdmin = "@minecraft/server-admin", 56 | } 57 | 58 | /** 59 | * The major version is fixed at 1. 60 | */ 61 | type Major = 1; 62 | 63 | /** 64 | * The minor version, which can range from 0 to 14. 65 | */ 66 | type Minor = 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14; 67 | 68 | /** 69 | * The patch version is fixed at 0. 70 | */ 71 | type Patch = 0; 72 | 73 | /** 74 | * Represents the optional pre-release part of a version (e.g., "-beta" or "-rc"). 75 | */ 76 | type PreRelease = "" | "-beta" | "-rc"; 77 | 78 | /** 79 | * A custom type for scripting version, combining the major, minor, patch, and optional pre-release. 80 | * Example: "1.0.0-beta" 81 | */ 82 | export type ScriptingVersion = `${Major}.${Minor}.${Patch}${PreRelease}`; 83 | 84 | /** 85 | * Interface representing the header of a manifest, which contains metadata about the pack. 86 | */ 87 | export interface Header { 88 | /** 89 | * If true, allows the use of a random seed for the world. 90 | * @default false 91 | */ 92 | allow_random_seed?: boolean; 93 | 94 | /** 95 | * The version of the base game. 96 | */ 97 | base_game_version?: Version; 98 | 99 | /** 100 | * A brief description of the pack. 101 | */ 102 | description?: string; 103 | 104 | /** 105 | * If true, locks template options to prevent modification. 106 | * @default false 107 | */ 108 | lock_template_options?: boolean; 109 | 110 | /** 111 | * The minimum required engine version for the pack. 112 | */ 113 | min_engine_version?: Version; 114 | 115 | /** 116 | * The name of the pack. 117 | */ 118 | name: string; 119 | 120 | /** 121 | * The scope of the pack (e.g., for which environment or platform it is intended). 122 | */ 123 | pack_scope?: string; 124 | 125 | /** 126 | * The UUID of the pack. 127 | */ 128 | uuid: UUID; 129 | 130 | /** 131 | * The version of the pack, which can either be a version tuple or a semantic versioning string. 132 | */ 133 | version: Version | SemverString; 134 | } 135 | 136 | /** 137 | * Interface representing a module, including metadata and version information. 138 | */ 139 | export interface Modules { 140 | /** 141 | * A description of the module. 142 | */ 143 | description?: string; 144 | 145 | /** 146 | * The type of module (e.g., resources, data, world template, etc.). 147 | */ 148 | type: Type; 149 | 150 | /** 151 | * The UUID of the module. 152 | */ 153 | uuid: UUID; 154 | 155 | /** 156 | * The version of the module, either as a version tuple or semantic versioning string. 157 | */ 158 | version: Version | SemverString; 159 | 160 | /** 161 | * The scripting language of the module (if applicable). 162 | */ 163 | language?: Language; 164 | } 165 | 166 | /** 167 | * Interface representing dependencies for the manifest, including module UUIDs, names, and versions. 168 | */ 169 | export interface Dependencies { 170 | /** 171 | * The UUID of the dependent module. 172 | */ 173 | uuid?: UUID; 174 | 175 | /** 176 | * The name of the dependent module (e.g., "@minecraft/server"). 177 | */ 178 | module_name?: ModuleName; 179 | 180 | /** 181 | * The version of the dependent module, which can either be a version tuple or a scripting version. 182 | */ 183 | version?: Version | ScriptingVersion; 184 | } 185 | 186 | /** 187 | * Interface representing optional capabilities available in the manifest, such as experimental features. 188 | */ 189 | export interface CapabilitiesObject { 190 | /** 191 | * Optional feature for chemistry-related capabilities. 192 | */ 193 | chemistry?: any; 194 | 195 | /** 196 | * Optional feature for editor extensions. 197 | */ 198 | editorExtension?: any; 199 | 200 | /** 201 | * Optional feature for experimental custom UI support. 202 | */ 203 | experimental_custom_ui?: any; 204 | 205 | /** 206 | * Optional feature for ray tracing support. 207 | */ 208 | raytraced?: any; 209 | } 210 | 211 | /** 212 | * Enum representing predefined capabilities that can be enabled in the manifest. 213 | */ 214 | export enum Capabilities { 215 | ScriptEval = "script_eval", 216 | } 217 | 218 | /** 219 | * Type representing the authors of the pack. 220 | */ 221 | export type Authors = Array; 222 | 223 | /** 224 | * Interface for metadata related to the pack, including authors, license, and URL. 225 | */ 226 | export interface Metadata { 227 | /** 228 | * A list of authors who contributed to the pack. 229 | */ 230 | authors?: Authors; 231 | 232 | /** 233 | * The license under which the pack is distributed. 234 | */ 235 | license?: string; 236 | 237 | /** 238 | * Information on what generated the pack. 239 | */ 240 | generated_with?: object; 241 | 242 | /** 243 | * The product type of the pack (e.g., "game", "mod"). 244 | */ 245 | product_type?: string; 246 | 247 | /** 248 | * A URL related to the pack (e.g., documentation or project site). 249 | */ 250 | url?: string; 251 | } 252 | 253 | /** 254 | * Interface representing the manifest structure of the pack, combining all information into a single object. 255 | */ 256 | export interface ManifestInterface { 257 | /** 258 | * The format version of the manifest. 259 | */ 260 | format_version: FormatVerson; 261 | 262 | /** 263 | * The header information of the manifest. 264 | */ 265 | header: Header; 266 | 267 | /** 268 | * The list of modules included in the pack. 269 | */ 270 | modules: Modules[]; 271 | 272 | /** 273 | * The list of dependencies for the pack. 274 | */ 275 | dependencies?: Dependencies[]; 276 | 277 | /** 278 | * A list of capabilities enabled in the pack. 279 | */ 280 | capabilities?: (CapabilitiesObject | Capabilities)[]; 281 | 282 | /** 283 | * Additional metadata about the pack. 284 | */ 285 | metadata?: Metadata; 286 | } 287 | -------------------------------------------------------------------------------- /src/types/objects/PropertyBag.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Interface representing a property bag, where keys are dynamically generated strings starting with `#`. 3 | * The value associated with each key can be of any type. 4 | * 5 | * Example: 6 | * ```typescript 7 | * const myProperties: PropertyBag = { 8 | * "#property1": 42, 9 | * "#property2": "example", 10 | * }; 11 | * ``` 12 | */ 13 | export interface BindingPropertyBag { 14 | /** 15 | * A dynamic property where the key is a string that starts with `#`, and the value can be any type. 16 | * The key must follow the pattern `#`. 17 | */ 18 | [key: `#${string}`]: string | number | boolean; 19 | } 20 | 21 | export interface PropertyBag { 22 | [key: string]: string | number | boolean; 23 | } 24 | -------------------------------------------------------------------------------- /src/types/objects/Sound.ts: -------------------------------------------------------------------------------- 1 | import { Float } from "../values/Number"; 2 | 3 | /** 4 | * Interface representing sound settings for a particular sound effect. 5 | */ 6 | export interface Sound { 7 | /** 8 | * The path of the sound, which can automatically register usable sounds. 9 | */ 10 | sound_path?: string; 11 | 12 | /** 13 | * The name of the sound. This could be the name of an asset or identifier for the sound. 14 | */ 15 | sound_name?: string; 16 | 17 | /** 18 | * The volume of the sound, typically ranging from 0.0 (silent) to 1.0 (full volume). 19 | * Default value is usually 1.0 (full volume) if not provided. 20 | */ 21 | sound_volume?: Float; 22 | 23 | /** 24 | * The pitch of the sound, typically ranging from 0.0 (lowest pitch) to 2.0 (double speed). 25 | * Default value is usually 1.0 (normal pitch) if not provided. 26 | */ 27 | sound_pitch?: Float; 28 | 29 | /** 30 | * The minimum time in seconds between consecutive plays of the same sound. 31 | * This helps prevent the sound from being played too frequently in a short period. 32 | */ 33 | min_seconds_between_plays?: Float; 34 | } 35 | -------------------------------------------------------------------------------- /src/types/objects/Variables.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Interface representing a collection of variables, where keys are dynamically generated strings. 3 | * The keys can either start with `$` or be enclosed in parentheses `()`. 4 | * The value for each key is an object, where each key within that object is a variable starting with `$` and the value can be of any type. 5 | * 6 | * Example: 7 | * ```typescript 8 | * const variables: VariablesInterface = { 9 | * "$variable1": { 10 | * "$subVariable1": "value1", 11 | * "$subVariable2": 42, 12 | * }, 13 | * "(group1)": { 14 | * "$subGroup1": true, 15 | * }, 16 | * }; 17 | * ``` 18 | */ 19 | export interface VariablesInterface { 20 | /** 21 | * A dynamic property where the key can either start with `$` (for regular variables) or be enclosed in parentheses `()` (for groupings or special cases). 22 | * Each key within this object represents a variable starting with `$` and can have any type of value. 23 | */ 24 | [key: `$${string}` | `(${string})`]: { 25 | /** 26 | * A dynamic property within the object, where the key starts with `$` and the value can be of any type. 27 | */ 28 | [key: `$${string}`]: any; 29 | }; 30 | } 31 | -------------------------------------------------------------------------------- /src/types/objects/elements/Button.ts: -------------------------------------------------------------------------------- 1 | import { Buttons } from "../properties/Buttons"; 2 | import { InputPanel } from "./InputPanel"; 3 | 4 | export interface Button extends InputPanel, Buttons { }; -------------------------------------------------------------------------------- /src/types/objects/elements/CollectionPanel.ts: -------------------------------------------------------------------------------- 1 | import { Collections } from "../properties/Collections"; 2 | import { Panel } from "./panel"; 3 | 4 | export interface CollectionPanel extends Panel, Collections { }; -------------------------------------------------------------------------------- /src/types/objects/elements/Custom.ts: -------------------------------------------------------------------------------- 1 | import { Renderers } from "../properties/Renderers"; 2 | import { Special } from "../properties/Specials"; 3 | import { Panel } from "./panel"; 4 | 5 | export interface Custom extends Panel, Renderers, Special { }; -------------------------------------------------------------------------------- /src/types/objects/elements/Dropdown.ts: -------------------------------------------------------------------------------- 1 | import { Dropdowns } from "../properties/Dropdowns"; 2 | import { Toggle } from "./Toggle"; 3 | 4 | export interface Dropdown extends Toggle, Dropdowns { }; -------------------------------------------------------------------------------- /src/types/objects/elements/EditBox.ts: -------------------------------------------------------------------------------- 1 | import { TextEdits } from "../properties/TextEdits"; 2 | import { Button } from "./Button"; 3 | 4 | export interface EditBox extends Button, TextEdits { }; -------------------------------------------------------------------------------- /src/types/objects/elements/Grid.ts: -------------------------------------------------------------------------------- 1 | import { Grids } from "../properties/Grids"; 2 | import { CollectionPanel } from "./CollectionPanel"; 3 | 4 | export interface Grid extends CollectionPanel, Grids {} 5 | -------------------------------------------------------------------------------- /src/types/objects/elements/Image.ts: -------------------------------------------------------------------------------- 1 | import { Sprites } from "../properties/Sprites"; 2 | import { Panel } from "./panel"; 3 | 4 | export interface Image extends Panel, Sprites { }; -------------------------------------------------------------------------------- /src/types/objects/elements/InputPanel.ts: -------------------------------------------------------------------------------- 1 | import { Collections } from "../properties/Collections"; 2 | import { Focus } from "../properties/Focus"; 3 | import { Inputs } from "../properties/Inputs"; 4 | import { Sounds } from "../properties/Sounds"; 5 | import { Panel } from "./panel"; 6 | 7 | export interface InputPanel extends Panel, Collections, Inputs, Sounds, Focus { } -------------------------------------------------------------------------------- /src/types/objects/elements/Label.ts: -------------------------------------------------------------------------------- 1 | import { Texts } from "../properties/Texts"; 2 | import { Panel } from "./panel"; 3 | 4 | export interface Label extends Panel, Texts { }; -------------------------------------------------------------------------------- /src/types/objects/elements/PropertiesType.ts: -------------------------------------------------------------------------------- 1 | import { Types } from "../../enums/Types"; 2 | import { Properties } from "../properties/Properties"; 3 | import { Button } from "./Button"; 4 | import { CollectionPanel } from "./CollectionPanel"; 5 | import { Custom } from "./Custom"; 6 | import { Dropdown } from "./Dropdown"; 7 | import { EditBox } from "./EditBox"; 8 | import { Grid } from "./Grid"; 9 | import { Image } from "./Image"; 10 | import { InputPanel } from "./InputPanel"; 11 | import { Label } from "./Label"; 12 | import { Panel } from "./panel"; 13 | import { Screen } from "./Screen"; 14 | import { ScrollbarBox } from "./ScrollbarBox"; 15 | import { ScrollbarTrack } from "./ScrollbarTrack"; 16 | import { ScrollView } from "./ScrollView"; 17 | import { SelectionWheel } from "./SelectionWheel"; 18 | import { Slider } from "./Slider"; 19 | import { SliderBox } from "./SliderBox"; 20 | import { StackPanel } from "./StackPanel"; 21 | import { Toggle } from "./Toggle"; 22 | import { TooltipTrigger } from "./TooltipTrigger"; 23 | 24 | export interface PropertiesType { 25 | [Types.Panel]: Panel; 26 | [Types.StackPanel]: StackPanel; 27 | [Types.InputPanel]: InputPanel; 28 | [Types.CollectionPanel]: CollectionPanel; 29 | [Types.Button]: Button; 30 | [Types.Custom]: Custom; 31 | [Types.Dropdown]: Dropdown; 32 | [Types.EditBox]: EditBox; 33 | [Types.Grid]: Grid; 34 | [Types.Image]: Image; 35 | [Types.Label]: Label; 36 | [Types.Screen]: Screen; 37 | [Types.ScrollView]: ScrollView; 38 | [Types.ScrollbarBox]: ScrollbarBox; 39 | [Types.ScrollbarTrack]: ScrollbarTrack; 40 | [Types.SelectionWheel]: SelectionWheel; 41 | [Types.Slider]: Slider; 42 | [Types.SliderBox]: SliderBox; 43 | [Types.Toggle]: Toggle; 44 | [Types.TooltipTrigger]: TooltipTrigger; 45 | [Types.Any]: Properties; 46 | }; 47 | -------------------------------------------------------------------------------- /src/types/objects/elements/Screen.ts: -------------------------------------------------------------------------------- 1 | import {Screens} from "../properties/Screens"; 2 | import { Panel } from "./panel"; 3 | 4 | export interface Screen extends Panel, Screens { }; -------------------------------------------------------------------------------- /src/types/objects/elements/ScrollView.ts: -------------------------------------------------------------------------------- 1 | import { Inputs } from "../properties/Inputs"; 2 | import { ScrollViews } from "../properties/ScrollViews"; 3 | import { Panel } from "./panel"; 4 | 5 | export interface ScrollView extends Panel, Inputs, ScrollViews { }; -------------------------------------------------------------------------------- /src/types/objects/elements/ScrollbarBox.ts: -------------------------------------------------------------------------------- 1 | import { Inputs } from "../properties/Inputs"; 2 | import { Panel } from "./panel"; 3 | 4 | export interface ScrollbarBox extends Panel, Inputs { }; -------------------------------------------------------------------------------- /src/types/objects/elements/ScrollbarTrack.ts: -------------------------------------------------------------------------------- 1 | import { Inputs } from "../properties/Inputs"; 2 | import { Panel } from "./panel"; 3 | 4 | export interface ScrollbarTrack extends Panel, Inputs { }; -------------------------------------------------------------------------------- /src/types/objects/elements/SelectionWheel.ts: -------------------------------------------------------------------------------- 1 | import { SelectionWheels } from "../properties/SelectionWheels"; 2 | import { InputPanel } from "./InputPanel"; 3 | 4 | export interface SelectionWheel extends InputPanel, SelectionWheels { }; -------------------------------------------------------------------------------- /src/types/objects/elements/Slider.ts: -------------------------------------------------------------------------------- 1 | import { Sliders } from "../properties/Sliders"; 2 | import { InputPanel } from "./InputPanel"; 3 | 4 | export interface Slider extends InputPanel, Sliders { }; -------------------------------------------------------------------------------- /src/types/objects/elements/SliderBox.ts: -------------------------------------------------------------------------------- 1 | import { Inputs } from "../properties/Inputs"; 2 | import { SliderBoxs } from "../properties/SliderBoxs"; 3 | import { Panel } from "./panel"; 4 | 5 | export interface SliderBox extends Panel, Inputs, SliderBoxs { }; -------------------------------------------------------------------------------- /src/types/objects/elements/StackPanel.ts: -------------------------------------------------------------------------------- 1 | import { Str } from "../../values/Str"; 2 | import { Collections } from "../properties/Collections"; 3 | import { StackPanels } from "../properties/StackPanels"; 4 | import { Panel } from "./panel"; 5 | 6 | export interface StackPanel extends Panel, StackPanels, Collections { 7 | control_name?: Str; 8 | } 9 | -------------------------------------------------------------------------------- /src/types/objects/elements/Toggle.ts: -------------------------------------------------------------------------------- 1 | import { Toggles } from "../properties/Toggles"; 2 | import { InputPanel } from "./InputPanel"; 3 | 4 | export interface Toggle extends InputPanel, Toggles { }; -------------------------------------------------------------------------------- /src/types/objects/elements/TooltipTrigger.ts: -------------------------------------------------------------------------------- 1 | import { Controls } from "../properties/Controls"; 2 | import { Focus } from "../properties/Focus"; 3 | import { Inputs } from "../properties/Inputs"; 4 | import { Layouts } from "../properties/Layouts"; 5 | import { TooltipTriggers } from "../properties/TooltipTriggers"; 6 | import { TTS } from "../properties/TTS"; 7 | 8 | export interface TooltipTrigger extends TooltipTriggers, Controls, Layouts, Focus, Inputs, TTS { } -------------------------------------------------------------------------------- /src/types/objects/elements/panel.ts: -------------------------------------------------------------------------------- 1 | import { Controls } from "../properties/Controls"; 2 | import { Layouts } from "../properties/Layouts"; 3 | import { Variables } from "../properties/Variables"; 4 | import { BindingPropertyBag } from "../PropertyBag"; 5 | 6 | export interface Panel extends Variables, Controls, Layouts, BindingPropertyBag {} 7 | -------------------------------------------------------------------------------- /src/types/objects/properties/Buttons.ts: -------------------------------------------------------------------------------- 1 | import { Str } from "../../values/Str"; 2 | import { SliderBoxs } from "./SliderBoxs"; 3 | 4 | /** 5 | * Represents a Button UI element that extends SliderBoxs and includes optional properties specific to button behavior. 6 | */ 7 | export interface Buttons extends SliderBoxs { 8 | /** 9 | * The name of the control that is pressed. 10 | * This property is optional and can be used to track which control has been pressed within the button. 11 | */ 12 | pressed_control?: Str; 13 | } 14 | -------------------------------------------------------------------------------- /src/types/objects/properties/CollectionIndexs.ts: -------------------------------------------------------------------------------- 1 | import { Int } from "../../values/Number"; 2 | 3 | /** 4 | * Represents an index for a collection, typically used for identifying an element's position within a collection. 5 | */ 6 | export interface CollectionIndexs { 7 | /** 8 | * The index of the collection item. 9 | * This property is optional and can be used to specify the position of an element within a collection. 10 | */ 11 | collection_index?: Int; 12 | } 13 | -------------------------------------------------------------------------------- /src/types/objects/properties/Collections.ts: -------------------------------------------------------------------------------- 1 | import { Collection } from "../../enums/Collection"; 2 | import { Var } from "../../values/Variable"; 3 | 4 | /** 5 | * Represents a collection, which can be a variable, string, or another collection. 6 | * This interface can be used to define a collection by either a reference to a variable, 7 | * a collection name as a string, or a nested collection. 8 | */ 9 | export interface Collections { 10 | /** 11 | * The collection itself, which can be a variable, string, or another collection. 12 | * This property is optional and can be used to define or reference a collection. 13 | */ 14 | collection?: Var | string | Collection; 15 | 16 | /** 17 | * The name of the collection, which can also be a variable, string, or another collection. 18 | * This property is optional and can be used to refer to the name of the collection. 19 | */ 20 | collection_name?: Var | string | Collection; 21 | } 22 | -------------------------------------------------------------------------------- /src/types/objects/properties/Controls.ts: -------------------------------------------------------------------------------- 1 | import { Bool } from "../../values/Bool"; 2 | import { Int, RangeFloat } from "../../values/Number"; 3 | import { Str } from "../../values/Str"; 4 | import { Vector2 } from "../../values/Vector"; 5 | import { Factory } from "../Factory"; 6 | import { PropertyBag } from "../PropertyBag"; 7 | 8 | /** 9 | * Represents the properties of a control in a UI system, allowing customization of its appearance, 10 | * behavior, and interactions. This interface includes options for visibility, interactivity, 11 | * clipping, and more. 12 | */ 13 | export interface Controls { 14 | /** 15 | * Determines whether the control is visible. If `false`, the control will not be rendered. 16 | * This property is optional and defaults to `true` if not specified. 17 | */ 18 | visible?: Bool; 19 | 20 | /** 21 | * Specifies whether the control is enabled. If `false`, the control cannot be interacted with. 22 | * This property is optional and defaults to `true` if not specified. 23 | */ 24 | enabled?: Bool; 25 | 26 | /** 27 | * Defines the layer index for the control. Controls with higher layer values are rendered on top of those 28 | * with lower values. This property is optional. 29 | */ 30 | layer?: Int; 31 | 32 | /** 33 | * Controls the opacity (alpha) of the control. A value between 0 and 1, where 0 is fully transparent 34 | * and 1 is fully opaque. This property is optional. 35 | */ 36 | alpha?: RangeFloat; 37 | 38 | /** 39 | * Indicates whether the alpha value should be propagated to child controls. This property is optional. 40 | */ 41 | propagate_alpha?: Bool; 42 | 43 | /** 44 | * Specifies whether the control clips its children. If `true`, child elements that extend outside 45 | * the control's boundaries will be clipped. This property is optional. 46 | */ 47 | clips_children?: Bool; 48 | 49 | /** 50 | * Determines whether clipping is allowed within the control's boundaries. This property is optional. 51 | */ 52 | allow_clipping?: Bool; 53 | 54 | /** 55 | * Defines an offset for clipping. If clipping is enabled, this value determines how the clipped content 56 | * will be adjusted. This property is optional. 57 | */ 58 | clip_offset?: Vector2; 59 | 60 | /** 61 | * Event name that will be triggered when the clip state of the control changes. This property is optional. 62 | */ 63 | clip_state_change_event?: Str; 64 | 65 | /** 66 | * Enables scissor testing for the control, which limits the drawing of content to a specific area. 67 | * This property is optional. 68 | */ 69 | enable_scissor_test?: Bool; 70 | 71 | /** 72 | * A property bag for storing additional custom properties related to the control. This property is optional. 73 | */ 74 | property_bag?: PropertyBag; 75 | 76 | /** 77 | * Specifies whether the control is selected. This property is optional. 78 | */ 79 | selected?: Bool; 80 | 81 | /** 82 | * Specifies whether to use child anchors for positioning the control’s children. This property is optional. 83 | */ 84 | use_child_anchors?: Bool; 85 | 86 | /** 87 | * Disables fast forwarding of animations for this control. This property is optional. 88 | */ 89 | disable_anim_fast_forward?: Bool; 90 | 91 | /** 92 | * The name of an animation to reset when the control is reset. This property is optional. 93 | */ 94 | animation_reset_name?: Str; 95 | 96 | /** 97 | * Specifies whether the control is ignored by the system, preventing it from being rendered or interacted with. 98 | * This property is optional. 99 | */ 100 | ignored?: Bool; 101 | 102 | /** 103 | * Defines the grid position of the control. This property is optional. 104 | */ 105 | grid_position?: Vector2; 106 | 107 | /** 108 | * Defines the index of the control within a collection. This property is optional. 109 | */ 110 | collection_index?: Int; 111 | 112 | /** 113 | * factory is not supported yet! 114 | */ 115 | factory?: Factory; 116 | } 117 | -------------------------------------------------------------------------------- /src/types/objects/properties/Dropdowns.ts: -------------------------------------------------------------------------------- 1 | import { Str } from "../../values/Str"; 2 | 3 | /** 4 | * Represents the properties of a dropdown control in a UI system, including the name, content, and area 5 | * where the dropdown is displayed. This interface allows customization of the dropdown's behavior and layout. 6 | */ 7 | export interface Dropdowns { 8 | /** 9 | * Specifies the name of the dropdown. This property is optional. 10 | * It helps in identifying the dropdown control. 11 | */ 12 | dropdown_name?: Str; 13 | 14 | /** 15 | * Defines the control that holds the content of the dropdown. This property is optional. 16 | * It typically refers to the control that will display the dropdown's items. 17 | */ 18 | dropdown_content_control?: Str; 19 | 20 | /** 21 | * Specifies the area or region where the dropdown will appear. This property is optional. 22 | * It can define the visual placement or container for the dropdown. 23 | */ 24 | dropdown_area?: Str; 25 | } 26 | -------------------------------------------------------------------------------- /src/types/objects/properties/Focus.ts: -------------------------------------------------------------------------------- 1 | import { FocusContainerCustom } from "./FocusContainerCustom"; 2 | import { FocusNavigationMode } from "../../enums/FocusNavigationMode"; 3 | import { Bool } from "../../values/Bool"; 4 | import { Int } from "../../values/Number"; 5 | import { Var } from "../../values/Variable"; 6 | import { Str } from "../../values/Str"; 7 | 8 | /** 9 | * Represents the focus management properties for a UI element, including focus precedence, 10 | * navigation modes, and custom focus behavior for different directions. This interface is used 11 | * to manage focus interactions and ensure smooth navigation within a UI system. 12 | */ 13 | export interface Focus { 14 | /** 15 | * Defines the precedence or priority for the element when determining the default focus. 16 | * This property is optional and allows customization of which element should receive focus first. 17 | */ 18 | default_focus_precedence?: Int; 19 | 20 | /** 21 | * Specifies whether the element can receive focus. This property is optional. 22 | * When set to `true`, the element is focusable; otherwise, it is not. 23 | */ 24 | focus_enabled?: Bool; 25 | 26 | /** 27 | * Indicates whether focus wrapping is enabled. This property is optional. 28 | * When enabled, focus will cycle back to the first element after reaching the last focusable element. 29 | */ 30 | focus_wrap_enabled?: Bool; 31 | 32 | /** 33 | * Specifies whether a "magnet" effect is applied to the focus. This property is optional. 34 | * When enabled, it allows the focus to magnetically snap to nearby focusable elements. 35 | */ 36 | focus_magnet_enabled?: Bool; 37 | 38 | /** 39 | * A unique identifier for the focus behavior of the element. This property is optional. 40 | * It is used for identifying the focus interaction mapping. 41 | */ 42 | focus_identifier?: Str; 43 | 44 | /** 45 | * Defines the control or action to take when moving focus down. This property is optional. 46 | */ 47 | focus_change_down?: Str; 48 | 49 | /** 50 | * Defines the control or action to take when moving focus up. This property is optional. 51 | */ 52 | focus_change_up?: Str; 53 | 54 | /** 55 | * Defines the control or action to take when moving focus left. This property is optional. 56 | */ 57 | focus_change_left?: Str; 58 | 59 | /** 60 | * Defines the control or action to take when moving focus right. This property is optional. 61 | */ 62 | focus_change_right?: Str; 63 | 64 | /** 65 | * Specifies the focus mapping for this element. This can be a single value or an array of mappings. 66 | * This property is optional and can define multiple behaviors for focus navigation. 67 | */ 68 | focus_mapping?: Var | Array; 69 | 70 | /** 71 | * Indicates whether the element is a focus container. This property is optional. 72 | * If true, it can hold other focusable elements and manage focus within them. 73 | */ 74 | focus_container?: Bool; 75 | 76 | /** 77 | * Specifies whether to use the last focused element. This property is optional. 78 | * When enabled, the system will remember the last focused element and restore focus to it. 79 | */ 80 | use_last_focus?: Bool; 81 | 82 | /** 83 | * Defines the navigation mode for moving focus left. This property is optional. 84 | * It can be set to a specific mode, such as `FocusNavigationMode`. 85 | */ 86 | focus_navigation_mode_left?: Var | FocusNavigationMode; 87 | 88 | /** 89 | * Defines the navigation mode for moving focus right. This property is optional. 90 | * It can be set to a specific mode, such as `FocusNavigationMode`. 91 | */ 92 | focus_navigation_mode_right?: Var | FocusNavigationMode; 93 | 94 | /** 95 | * Defines the navigation mode for moving focus down. This property is optional. 96 | * It can be set to a specific mode, such as `FocusNavigationMode`. 97 | */ 98 | focus_navigation_mode_down?: Var | FocusNavigationMode; 99 | 100 | /** 101 | * Defines the navigation mode for moving focus up. This property is optional. 102 | * It can be set to a specific mode, such as `FocusNavigationMode`. 103 | */ 104 | focus_navigation_mode_up?: Var | FocusNavigationMode; 105 | 106 | /** 107 | * Custom focus container behavior for the left direction. This property is optional. 108 | * It can define custom interactions when focus moves left within a container. 109 | */ 110 | focus_container_custom_left?: FocusContainerCustom[]; 111 | 112 | /** 113 | * Custom focus container behavior for the right direction. This property is optional. 114 | * It can define custom interactions when focus moves right within a container. 115 | */ 116 | focus_container_custom_right?: FocusContainerCustom[]; 117 | 118 | /** 119 | * Custom focus container behavior for the down direction. This property is optional. 120 | * It can define custom interactions when focus moves down within a container. 121 | */ 122 | focus_container_custom_down?: FocusContainerCustom[]; 123 | 124 | /** 125 | * Custom focus container behavior for the up direction. This property is optional. 126 | * It can define custom interactions when focus moves up within a container. 127 | */ 128 | focus_container_custom_up?: FocusContainerCustom[]; 129 | } 130 | -------------------------------------------------------------------------------- /src/types/objects/properties/FocusContainerCustom.ts: -------------------------------------------------------------------------------- 1 | import { Str } from "../../values/Str"; 2 | 3 | /** 4 | * Represents custom focus container behavior for navigating focus inside a specific container. 5 | * This interface allows customization of how focus behaves within a focus container in different directions. 6 | */ 7 | export interface FocusContainerCustom { 8 | /** 9 | * Specifies the name of another focus container. This property is optional. 10 | * It is used to refer to other containers for custom focus navigation. 11 | */ 12 | other_focus_container_name?: Str; 13 | 14 | /** 15 | * Defines the focus ID inside the container. This property is optional. 16 | * It specifies which focus element inside the container should be targeted. 17 | */ 18 | focus_id_inside?: Str; 19 | } 20 | -------------------------------------------------------------------------------- /src/types/objects/properties/Grids.ts: -------------------------------------------------------------------------------- 1 | import { Direction } from "readline"; 2 | import { Binding } from "../../values/Binding"; 3 | import { Int } from "../../values/Number"; 4 | import { Var } from "../../values/Variable"; 5 | import { Vector2 } from "../../values/Vector"; 6 | import { ElementPath } from "../../values/ElementPath"; 7 | 8 | /** 9 | * Represents the configuration options for a grid layout. 10 | * This interface defines properties for managing the dimensions, item arrangement, and behavior of a grid. 11 | */ 12 | export interface Grids { 13 | /** 14 | * Specifies the dimensions of the grid in terms of width and height. 15 | * The value is represented as a `Vector2`, where the `x` value represents the number of columns, 16 | * and the `y` value represents the number of rows. 17 | */ 18 | grid_dimensions?: Vector2; 19 | 20 | /** 21 | * Specifies the maximum number of items allowed in the grid. 22 | * If the number of items exceeds this value, it may be handled according to the layout's rules. 23 | */ 24 | maximum_grid_items?: Int; 25 | 26 | /** 27 | * Defines a binding for the grid's dimension. This allows dynamic control over the grid's size, 28 | * based on the bound value or condition. 29 | */ 30 | grid_dimension_binding?: Binding; 31 | 32 | /** 33 | * Specifies the type of grid rescaling. This can be used to adjust the grid layout dynamically. 34 | * The value can be a variable or a specific direction (`Var` | `Direction`). 35 | */ 36 | grid_rescaling_type?: Var | Direction; 37 | 38 | /** 39 | * Defines the direction in which the grid is filled with items. It can be set to a variable or a specific direction (`Var` | `Direction`). 40 | */ 41 | grid_fill_direction?: Var | Direction; 42 | 43 | /** 44 | * Specifies a template for the grid items. This template is used to generate new items for the grid layout. 45 | * It is defined as an `ElementPath`, which points to an existing element or structure. 46 | */ 47 | grid_item_template?: ElementPath; 48 | 49 | /** 50 | * Defines the number of grid items to be precached for faster performance. 51 | * This can be useful to optimize the rendering of grid items when dealing with large datasets. 52 | */ 53 | precached_grid_item_count?: Int; 54 | } 55 | -------------------------------------------------------------------------------- /src/types/objects/properties/Inputs.ts: -------------------------------------------------------------------------------- 1 | import { Bool } from "../../values/Bool"; 2 | 3 | /** 4 | * Represents configuration options related to input handling and interaction with the UI elements. 5 | * This interface allows fine-grained control over how inputs are processed, including touch, pointer, and gesture events. 6 | */ 7 | export interface Inputs { 8 | /** 9 | * If true, enables the modal behavior for inputs, preventing other interactions while the modal is active. 10 | * This is typically used for fullscreen or overlay elements that block user interaction outside of the modal. 11 | */ 12 | modal?: Bool; 13 | 14 | /** 15 | * If true, enables inline modal behavior, which allows interactions within the modal but still shows the underlying content. 16 | * This allows for a less disruptive input experience compared to a full modal. 17 | */ 18 | inline_modal?: Bool; 19 | 20 | /** 21 | * If true, the element will always listen for input events, regardless of its state or visibility. 22 | * This is useful for background processes that need to capture user inputs continuously. 23 | */ 24 | always_listen_to_input?: Bool; 25 | 26 | /** 27 | * If true, the element will always handle pointer (mouse or touch) events, regardless of its focus or visibility. 28 | * This is helpful in cases where the UI element should always be responsive to pointer events. 29 | */ 30 | always_handle_pointer?: Bool; 31 | 32 | /** 33 | * If true, the element will always handle controller direction inputs, even when it's not actively focused. 34 | * This is useful for game-like or controller-driven UIs where directional input needs to be always considered. 35 | */ 36 | always_handle_controller_direction?: Bool; 37 | 38 | /** 39 | * If true, enables hover interactions, allowing the element to respond to pointer hover events. 40 | * This can be used to trigger hover states or display hover-specific information. 41 | */ 42 | hover_enabled?: Bool; 43 | 44 | /** 45 | * If true, prevents touch input events from being handled by the element, blocking any touch-based interactions. 46 | * This is useful for disabling touch interactions in certain areas of the UI. 47 | */ 48 | prevent_touch_input?: Bool; 49 | 50 | /** 51 | * If true, consumes the event, preventing it from propagating further or being handled by other elements. 52 | * This can be useful for stopping event bubbling in certain cases. 53 | */ 54 | consume_event?: Bool; 55 | 56 | /** 57 | * If true, consumes hover events, preventing them from being passed on to other UI elements. 58 | * This can be useful when you want to isolate hover interactions to the current element. 59 | */ 60 | consume_hover_events?: Bool; 61 | 62 | /** 63 | * If true, enables tracking of gesture events associated with the element. 64 | * This is typically used for detecting multi-touch gestures, such as pinch, swipe, etc. 65 | */ 66 | gesture_tracking_button?: Bool; 67 | } 68 | -------------------------------------------------------------------------------- /src/types/objects/properties/Layouts.ts: -------------------------------------------------------------------------------- 1 | import { Direction } from "readline"; 2 | import { Anchor } from "../../enums/Anchor"; 3 | import { Color } from "../../enums/EnumColor"; 4 | import { Bool } from "../../values/Bool"; 5 | import { StringVector2 } from "../../values/StringVector"; 6 | import { Float, Int } from "../../values/Number"; 7 | import { Var } from "../../values/Variable"; 8 | import { Str } from "../../values/Str"; 9 | import { Any } from "../../values/Any"; 10 | 11 | /** 12 | * Represents configuration options related to the layout and positioning of UI elements. 13 | * This interface allows the adjustment of sizes, visibility, alignment, and behavior of elements within their containers. 14 | */ 15 | export interface Layouts { 16 | /** 17 | * Specifies the size of the element. Can be a string (e.g., 'auto'), a floating-point number for pixel value, or a `StringVector2` for both width and height. 18 | * This determines the element's dimension in its layout. 19 | */ 20 | size?: Str | Float | StringVector2; 21 | 22 | /** 23 | * If true, the element will be visible in the UI. 24 | * If false, the element is hidden but still part of the layout. 25 | */ 26 | visible?: Bool; 27 | 28 | /** 29 | * If true, the element is ignored in layout calculations. 30 | * It will not affect the position or size of other elements in the layout. 31 | */ 32 | ignored?: Bool; 33 | 34 | /** 35 | * Defines the layer on which the element resides. Higher values typically represent elements that are visually on top. 36 | */ 37 | layer?: Int; 38 | 39 | /** 40 | * Specifies the maximum size of the element, which can be a string (e.g., 'auto'), a floating-point number, or a `StringVector2`. 41 | * This limits the element's size in the layout. 42 | */ 43 | max_size?: Str | Float | StringVector2; 44 | 45 | /** 46 | * Specifies the minimum size of the element, which can be a string (e.g., 'auto'), a floating-point number, or a `StringVector2`. 47 | * This defines the smallest possible size for the element. 48 | */ 49 | min_size?: Str | Float | StringVector2; 50 | 51 | /** 52 | * Defines the offset of the element relative to its parent container. This can be a `StringVector2` representing the X and Y offset values. 53 | */ 54 | offset?: StringVector2; 55 | 56 | /** 57 | * Defines the anchor point for the element's position, used to control the alignment with respect to other UI elements. 58 | * This can either be a `Var` (such as a string) or an `Anchor` value. 59 | */ 60 | anchor?: Var | Anchor; 61 | 62 | /** 63 | * Defines the reference anchor point from which the element’s position is calculated. 64 | * This can either be a `Var` (such as a string) or an `Anchor` value. 65 | */ 66 | anchor_from?: Var | Anchor; 67 | 68 | /** 69 | * Defines the target anchor point that the element should align to. 70 | * This can either be a `Var` (such as a string) or an `Anchor` value. 71 | */ 72 | anchor_to?: Var | Anchor; 73 | 74 | /** 75 | * If true, the element inherits the maximum width from its sibling elements. 76 | * This allows it to automatically adjust to the width of neighboring elements. 77 | */ 78 | inherit_max_sibling_width?: Bool; 79 | 80 | /** 81 | * If true, the element inherits the maximum height from its sibling elements. 82 | * This allows it to automatically adjust to the height of neighboring elements. 83 | */ 84 | inherit_max_sibling_height?: Bool; 85 | 86 | /** 87 | * If true, the element's offset is calculated based on its anchored position. 88 | * This determines whether the offset will be affected by the anchor properties. 89 | */ 90 | use_anchored_offset?: Bool; 91 | 92 | /** 93 | * If true, the element is considered as a contained item within a parent container. 94 | * This indicates that the element is nested within another UI element. 95 | */ 96 | contained?: Bool; 97 | 98 | /** 99 | * Specifies whether the element is draggable. Can be set to a `Var` or `Direction` value to determine the drag behavior. 100 | */ 101 | draggable?: Var | Direction; 102 | 103 | /** 104 | * If true, the element will follow the cursor or pointer during interaction. 105 | * This is typically used for draggable or floating UI elements that follow user movement. 106 | */ 107 | follows_cursor?: Bool; 108 | 109 | /** 110 | * Specifies the debug color or mode for the element. This can be a `Var` or `Color` value to help with visual debugging of the element’s layout. 111 | */ 112 | debug?: Var | Color; 113 | 114 | /** 115 | * Specifies the minimum width of the element as a floating-point number. 116 | * This is the smallest allowable width for the element. 117 | */ 118 | min_w?: Float | Str; 119 | 120 | /** 121 | * Specifies the minimum height of the element as a floating-point number. 122 | * This is the smallest allowable height for the element. 123 | */ 124 | min_h?: Float | Str; 125 | 126 | /** 127 | * Specifies the maximum width of the element as a floating-point number. 128 | * This is the largest allowable width for the element. 129 | */ 130 | max_w?: Float | Str; 131 | 132 | /** 133 | * Specifies the maximum height of the element as a floating-point number. 134 | * This is the largest allowable height for the element. 135 | */ 136 | max_h?: Float | Str; 137 | 138 | /** 139 | * Specifies the width of the element as a floating-point number. 140 | * This value represents the actual width of the element. 141 | */ 142 | w?: Float | Str; 143 | 144 | /** 145 | * Specifies the height of the element as a floating-point number. 146 | * This value represents the actual height of the element. 147 | */ 148 | h?: Float | Str; 149 | 150 | /** 151 | * Specifies the X position of the element as a floating-point number. 152 | * This determines the horizontal placement of the element in its parent container. 153 | */ 154 | x?: Float | Str; 155 | 156 | /** 157 | * Specifies the Y position of the element as a floating-point number. 158 | * This determines the vertical placement of the element in its parent container. 159 | */ 160 | y?: Float | Str; 161 | } 162 | -------------------------------------------------------------------------------- /src/types/objects/properties/Properties.ts: -------------------------------------------------------------------------------- 1 | import { Buttons } from "./Buttons"; 2 | import { CollectionIndexs } from "./CollectionIndexs"; 3 | import { Collections } from "./Collections"; 4 | import { Controls } from "./Controls"; 5 | import { Dropdowns } from "./Dropdowns"; 6 | import { Focus } from "./Focus"; 7 | import { Grids } from "./Grids"; 8 | import { Inputs } from "./Inputs"; 9 | import { Layouts } from "./Layouts"; 10 | import { Renderers } from "./Renderers"; 11 | import { Screens } from "./Screens"; 12 | import { ScrollViews } from "./ScrollViews"; 13 | import { SelectionWheels } from "./SelectionWheels"; 14 | import { SliderBoxs } from "./SliderBoxs"; 15 | import { Sliders } from "./Sliders"; 16 | import { Sounds } from "./Sounds"; 17 | import { Special } from "./Specials"; 18 | import { Sprites } from "./Sprites"; 19 | import { StackPanels } from "./StackPanels"; 20 | import { TextEdits } from "./TextEdits"; 21 | import { Texts } from "./Texts"; 22 | import { Toggles } from "./Toggles"; 23 | import { TooltipTriggers } from "./TooltipTriggers"; 24 | import { TTS } from "./TTS"; 25 | import { Variables } from "./Variables"; 26 | 27 | export interface Properties 28 | extends Buttons, 29 | CollectionIndexs, 30 | Collections, 31 | Controls, 32 | Dropdowns, 33 | Focus, 34 | Grids, 35 | Inputs, 36 | Renderers, 37 | Screens, 38 | ScrollViews, 39 | SelectionWheels, 40 | SliderBoxs, 41 | Sliders, 42 | Sounds, 43 | Special, 44 | Sprites, 45 | StackPanels, 46 | TextEdits, 47 | Texts, 48 | Toggles, 49 | Layouts, 50 | TooltipTriggers, 51 | TTS, 52 | Variables { } 53 | -------------------------------------------------------------------------------- /src/types/objects/properties/Renderers.ts: -------------------------------------------------------------------------------- 1 | import { Renderer } from "../../enums/Renderer"; 2 | import { Var } from "../../values/Variable"; 3 | 4 | /** 5 | * Represents the configuration options related to the renderer for a UI element. 6 | * This interface allows specifying a custom renderer or using a default renderer for UI elements. 7 | */ 8 | export interface Renderers { 9 | /** 10 | * Specifies the renderer to use for the UI element. 11 | * This can either be a `Var` (such as a string or identifier) or a `Renderer` value. 12 | * The renderer defines how the element will be visually rendered and interacted with in the UI. 13 | */ 14 | renderer?: Var | Renderer; 15 | } 16 | -------------------------------------------------------------------------------- /src/types/objects/properties/Screens.ts: -------------------------------------------------------------------------------- 1 | import { Bool } from "../../values/Bool"; 2 | import { StackPanels } from "./StackPanels"; 3 | 4 | /** 5 | * Represents the configuration options for a screen in the UI, inheriting from `StackPanels`. 6 | * This interface adds additional properties specific to screen behavior and rendering. 7 | */ 8 | export interface Screens extends StackPanels { 9 | /** 10 | * If `true`, the screen will only render when it is the topmost screen. 11 | */ 12 | render_only_when_topmost?: Bool; 13 | 14 | /** 15 | * If `true`, the screen cannot be flushed (removed from rendering). 16 | */ 17 | screen_not_flushable?: Bool; 18 | 19 | /** 20 | * If `true`, the screen will always accept input, even if other UI elements are visible. 21 | */ 22 | always_accepts_input?: Bool; 23 | 24 | /** 25 | * If `true`, the screen allows rendering the game in the background while the screen is active. 26 | */ 27 | render_game_behind?: Bool; 28 | 29 | /** 30 | * If `true`, the screen absorbs input, preventing interaction with other elements beneath it. 31 | */ 32 | absorbs_input?: Bool; 33 | 34 | /** 35 | * If `true`, the screen is marked as showing a menu. 36 | */ 37 | is_showing_menu?: Bool; 38 | 39 | /** 40 | * If `true`, the screen is modal and will block interaction with other screens. 41 | */ 42 | is_modal?: Bool; 43 | 44 | /** 45 | * If `true`, the screen should steal mouse control from other UI elements. 46 | */ 47 | should_steal_mouse?: Bool; 48 | 49 | /** 50 | * If `true`, the screen will use low-frequency rendering to optimize performance. 51 | */ 52 | low_frequency_rendering?: Bool; 53 | 54 | /** 55 | * If `true`, this screen will be the last to draw in the rendering order. 56 | */ 57 | screen_draws_last?: Bool; 58 | 59 | /** 60 | * If `true`, the screen supports VR (Virtual Reality) mode. 61 | */ 62 | vr_mode?: Bool; 63 | 64 | /** 65 | * If `true`, the screen will render below other elements even when it's active. 66 | */ 67 | force_render_below?: Bool; 68 | 69 | /** 70 | * If `true`, telemetry data will be sent while the screen is active. 71 | */ 72 | send_telemetry?: Bool; 73 | 74 | /** 75 | * If `true`, the screen will automatically close when the player is hurt. 76 | */ 77 | close_on_player_hurt?: Bool; 78 | 79 | /** 80 | * If `true`, the screen will be cached for faster loading. 81 | */ 82 | cache_screen?: Bool; 83 | 84 | /** 85 | * If `true`, the screen will load immediately upon activation. 86 | */ 87 | load_screen_immediately?: Bool; 88 | 89 | /** 90 | * If `true`, a gamepad cursor will be used for navigation on the screen. 91 | */ 92 | gamepad_cursor?: Bool; 93 | 94 | /** 95 | * If `true`, the gamepad cursor will have deflection mode enabled. 96 | */ 97 | gamepad_cursor_deflection_mode?: Bool; 98 | 99 | /** 100 | * If `true`, the screen should be skipped during automated processes like testing or scripting. 101 | */ 102 | should_be_skipped_during_automation?: Bool; 103 | } 104 | -------------------------------------------------------------------------------- /src/types/objects/properties/ScrollViews.ts: -------------------------------------------------------------------------------- 1 | import { Bool } from "../../values/Bool"; 2 | import { Float } from "../../values/Number"; 3 | import { Str } from "../../values/Str"; 4 | 5 | /** 6 | * Represents the configuration options for a scrollable view in the UI. 7 | * This interface allows for customization of the scrollbar, touch behavior, and scrolling controls. 8 | */ 9 | export interface ScrollViews { 10 | /** 11 | * The name of the button used for the scrollbar track. 12 | */ 13 | scrollbar_track_button?: Str; 14 | 15 | /** 16 | * The name of the button used for touch-based scrolling. 17 | */ 18 | scrollbar_touch_button?: Str; 19 | 20 | /** 21 | * The speed at which the content scrolls. 22 | * A higher value results in faster scrolling. 23 | */ 24 | scroll_speed?: Float; 25 | 26 | /** 27 | * If `true`, gesture-based scrolling is enabled. 28 | */ 29 | gesture_control_enabled?: Bool; 30 | 31 | /** 32 | * If `true`, scrolling will be always handled, even when the input device is not actively interacting with the scroll view. 33 | */ 34 | always_handle_scrolling?: Bool; 35 | 36 | /** 37 | * If `true`, the scroll view will be in touch mode, optimizing for touch input interactions. 38 | */ 39 | touch_mode?: Bool; 40 | 41 | /** 42 | * The name of the scrollbar box element. 43 | */ 44 | scrollbar_box?: Str; 45 | 46 | /** 47 | * The name of the scrollbar track element. 48 | */ 49 | scrollbar_track?: Str; 50 | 51 | /** 52 | * The name of the scroll view port, which contains the content to be scrolled. 53 | */ 54 | scroll_view_port?: Str; 55 | 56 | /** 57 | * The name of the content inside the scroll view. 58 | */ 59 | scroll_content?: Str; 60 | 61 | /** 62 | * The name of the panel that contains both the scroll box and the track for the scrollbar. 63 | */ 64 | scroll_box_and_track_panel?: Str; 65 | 66 | /** 67 | * If `true`, the view will automatically jump to the bottom when the content is updated. 68 | */ 69 | jump_to_bottom_on_update?: Bool; 70 | } 71 | -------------------------------------------------------------------------------- /src/types/objects/properties/SelectionWheels.ts: -------------------------------------------------------------------------------- 1 | import { Float } from "../../values/Number"; 2 | import { Str } from "../../values/Str"; 3 | import { Var } from "../../values/Variable"; 4 | 5 | /** 6 | * Represents the configuration for a selection wheel UI element. 7 | * A selection wheel is typically used for menu navigation or radial selection. 8 | */ 9 | export interface SelectionWheels { 10 | /** 11 | * The inner radius of the selection wheel. 12 | * Defines the size of the central area where the wheel's controls may be located. 13 | */ 14 | inner_radius?: Float; 15 | 16 | /** 17 | * The outer radius of the selection wheel. 18 | * Defines the size of the outer boundary where the selectable options are placed. 19 | */ 20 | outer_radius?: Float; 21 | 22 | /** 23 | * The state controls that are associated with the selection wheel. 24 | * Can be a single variable or an array of strings representing the controls used for interaction. 25 | */ 26 | state_controls?: Var | Array; 27 | 28 | /** 29 | * The number of slices or segments in the selection wheel. 30 | * Each slice represents an option or action. 31 | */ 32 | slice_count?: Float; 33 | 34 | /** 35 | * The name of the button associated with the selection wheel. 36 | * This button typically activates the wheel or initiates a selection. 37 | */ 38 | button_name?: Str; 39 | 40 | /** 41 | * The name of the button that iterates the selection wheel in the left direction. 42 | */ 43 | iterate_left_button_name?: Str; 44 | 45 | /** 46 | * The name of the button that iterates the selection wheel in the right direction. 47 | */ 48 | iterate_right_button_name?: Str; 49 | 50 | /** 51 | * The initial button slice or starting position for the selection wheel. 52 | * Determines the slice selected when the wheel is first activated. 53 | */ 54 | initial_button_slice?: Float; 55 | } 56 | -------------------------------------------------------------------------------- /src/types/objects/properties/SliderBoxs.ts: -------------------------------------------------------------------------------- 1 | import { Str } from "../../values/Str"; 2 | 3 | /** 4 | * Represents the configuration for a Slider Box UI element. 5 | * A Slider Box typically allows users to select values within a range by sliding a control. 6 | */ 7 | export interface SliderBoxs { 8 | /** 9 | * The default control for the Slider Box. 10 | * Specifies the control that will be initially selected or displayed when the Slider Box is rendered. 11 | */ 12 | default_control?: Str; 13 | 14 | /** 15 | * The control that appears when the Slider Box is hovered over. 16 | * This could be a different visual state or a control to highlight interactions. 17 | */ 18 | hover_control?: Str; 19 | 20 | /** 21 | * The control that appears when the Slider Box is locked. 22 | * A locked control could indicate that the user can no longer interact with the Slider Box. 23 | */ 24 | locked_control?: Str; 25 | } 26 | -------------------------------------------------------------------------------- /src/types/objects/properties/Sliders.ts: -------------------------------------------------------------------------------- 1 | import { Orientation } from "../../enums/Orientation"; 2 | import { Bool } from "../../values/Bool"; 3 | import { Float } from "../../values/Number"; 4 | import { Str } from "../../values/Str"; 5 | import { Var } from "../../values/Variable"; 6 | 7 | /** 8 | * Represents the configuration for a Slider UI element. 9 | * A Slider typically allows users to select a value within a defined range, either by dragging a control or clicking buttons. 10 | */ 11 | export interface Sliders { 12 | /** 13 | * The button control used for adjusting the track of the slider. 14 | * This button allows users to move along the slider track. 15 | */ 16 | slider_track_button?: Str; 17 | 18 | /** 19 | * The button used to decrease the slider value by a small increment. 20 | * This button typically allows fine-grained adjustments. 21 | */ 22 | slider_small_decrease_button?: Str; 23 | 24 | /** 25 | * The button used to increase the slider value by a small increment. 26 | * Similar to `slider_small_decrease_button`, this is for precise value adjustments. 27 | */ 28 | slider_small_increase_button?: Str; 29 | 30 | /** 31 | * The number of steps the slider is divided into. 32 | * This defines how granular the slider’s value can be. 33 | */ 34 | slider_steps?: Float; 35 | 36 | /** 37 | * The direction of the slider. 38 | * This defines whether the slider is oriented horizontally or vertically. 39 | */ 40 | slider_direction?: Var | Orientation; 41 | 42 | /** 43 | * The time in milliseconds before the slider action times out. 44 | * It could be used to control the responsiveness or delay in slider interaction. 45 | */ 46 | slider_timeout?: Float; 47 | 48 | /** 49 | * The name of the collection to which the slider belongs. 50 | * This could be useful for grouping sliders within a larger collection. 51 | */ 52 | slider_collection_name?: Str; 53 | 54 | /** 55 | * The name of the slider element itself. 56 | * This could be used for identifying or referencing the slider in a larger system. 57 | */ 58 | slider_name?: Str; 59 | 60 | /** 61 | * Whether the slider should be selected when hovered over. 62 | * This can provide a more interactive experience for users. 63 | */ 64 | slider_select_on_hover?: Bool; 65 | 66 | /** 67 | * The button control that represents the selected state of the slider. 68 | * This button can be visually different from other buttons to show that the slider is in use. 69 | */ 70 | slider_selected_button?: Str; 71 | 72 | /** 73 | * The button control that represents the deselected state of the slider. 74 | * This button can return to its default state when the slider is not in use. 75 | */ 76 | slider_deselected_button?: Str; 77 | 78 | /** 79 | * The control for the slider box, which might be used to visually encapsulate the slider and its components. 80 | */ 81 | slider_box_control?: Str; 82 | 83 | /** 84 | * The background control for the slider, defining the base layer or background visuals. 85 | */ 86 | background_control?: Str; 87 | 88 | /** 89 | * The hover state of the background control, typically used for visual feedback when users interact with the slider. 90 | */ 91 | background_hover_control?: Str; 92 | 93 | /** 94 | * The progress control of the slider, used to show the user's current position or value within the slider's range. 95 | */ 96 | progress_control?: Str; 97 | 98 | /** 99 | * The hover state of the progress control, giving feedback when users hover over the progress portion of the slider. 100 | */ 101 | progress_hover_control?: Str; 102 | } 103 | -------------------------------------------------------------------------------- /src/types/objects/properties/Sounds.ts: -------------------------------------------------------------------------------- 1 | import { Float } from "../../values/Number"; 2 | import { Str } from "../../values/Str"; 3 | import { Sound } from "../Sound"; 4 | 5 | /** 6 | * Represents the configuration for a sound element. 7 | * A Sound element is used for defining various audio properties, such as the sound file, volume, pitch, and other related settings. 8 | */ 9 | export interface Sounds { 10 | /** 11 | * The path of the sound, which can automatically register usable sounds. 12 | */ 13 | sound_path?: string; 14 | 15 | /** 16 | * The name of the sound element. 17 | * This can be used to reference or identify the sound in the system. 18 | */ 19 | sound_name?: Str; 20 | 21 | /** 22 | * The volume level of the sound. 23 | * A float value typically ranging from 0.0 (mute) to 1.0 (full volume). 24 | */ 25 | sound_volume?: Float; 26 | 27 | /** 28 | * The pitch of the sound. 29 | * A float value that can modify the frequency of the sound, altering its tone. 30 | */ 31 | sound_pitch?: Float; 32 | 33 | /** 34 | * An array of other sound elements. 35 | * This allows the grouping of multiple sounds, which can be useful for creating sound effects with multiple components or variations. 36 | */ 37 | sounds?: Array; 38 | } 39 | -------------------------------------------------------------------------------- /src/types/objects/properties/Specials.ts: -------------------------------------------------------------------------------- 1 | import { Orientation } from "../../enums/Orientation"; 2 | import { Renderer } from "../../enums/Renderer"; 3 | import { Rotation } from "../../enums/Rotation"; 4 | import { Bool } from "../../values/Bool"; 5 | import { ColorVector4 } from "../../values/ColorVector"; 6 | import { Float } from "../../values/Number"; 7 | import { Var } from "../../values/Variable"; 8 | import { Vector4 } from "../../values/Vector"; 9 | 10 | /** 11 | * Interface representing special settings for different renderers. 12 | */ 13 | export interface Special { 14 | /** 15 | * The direction of the gradient, defined by a variable (`Var`) or an `Orientation`. 16 | */ 17 | gradient_direction?: Var | Orientation; 18 | 19 | /** 20 | * The first color of the gradient, represented as a `ColorVector4` (RGBA). 21 | */ 22 | color1?: ColorVector4; 23 | 24 | /** 25 | * The second color of the gradient, represented as a `ColorVector4` (RGBA). 26 | */ 27 | color2?: ColorVector4; 28 | 29 | /** 30 | * The color of the text, represented as a `ColorVector4` (RGBA). 31 | */ 32 | text_color?: ColorVector4; 33 | 34 | /** 35 | * The background color, represented as a `ColorVector4` (RGBA). 36 | */ 37 | background_color?: ColorVector4; 38 | 39 | /** 40 | * The primary color, represented as a `ColorVector4` (RGBA). 41 | */ 42 | primary_color?: ColorVector4; 43 | 44 | /** 45 | * The secondary color, represented as a `ColorVector4` (RGBA). 46 | */ 47 | secondary_color?: ColorVector4; 48 | 49 | /** 50 | * The degree of camera tilt, represented as a floating-point value. 51 | */ 52 | camera_tilt_degrees?: Float; 53 | 54 | /** 55 | * A flag to indicate if rotation starts immediately (`true` for starting rotation). 56 | */ 57 | starting_rotation?: Bool; 58 | 59 | /** 60 | * A flag indicating whether a UUID should be used (`true` for UUID usage). 61 | */ 62 | use_uuid?: Bool; 63 | 64 | /** 65 | * A flag to determine if the skin's GUI scale should be used (`true` for scaling). 66 | */ 67 | use_skin_gui_scale?: Bool; 68 | 69 | /** 70 | * A flag to determine if the player paperdoll should be used (`true` for using paperdoll). 71 | */ 72 | use_player_paperdoll?: Bool; 73 | 74 | /** 75 | * The rotation setting, defined by a variable (`Var`) or a `Rotation`. 76 | */ 77 | rotation?: Var | Rotation; 78 | 79 | /** 80 | * The event triggered at the end, defined as a string. 81 | */ 82 | end_event?: string; 83 | } 84 | 85 | /** 86 | * Interface representing a gradient with direction and two colors. 87 | */ 88 | interface Gradient { 89 | /** 90 | * The direction of the gradient, defined by a variable (`Var`) or an `Orientation`. 91 | */ 92 | gradient_direction?: Var | Orientation; 93 | 94 | /** 95 | * The first color of the gradient, represented as a `ColorVector4` (RGBA). 96 | */ 97 | color1?: ColorVector4; 98 | 99 | /** 100 | * The second color of the gradient, represented as a `ColorVector4` (RGBA). 101 | */ 102 | color2?: ColorVector4; 103 | } 104 | 105 | /** 106 | * Interface representing a nametag with text and background colors. 107 | */ 108 | interface Nametag { 109 | /** 110 | * The color of the text, represented as a `ColorVector4` (RGBA). 111 | */ 112 | text_color?: ColorVector4; 113 | 114 | /** 115 | * The background color, represented as a `ColorVector4` (RGBA). 116 | */ 117 | background_color?: ColorVector4; 118 | } 119 | 120 | /** 121 | * Interface representing a progress bar with primary and secondary colors. 122 | */ 123 | interface ProgessBar { 124 | /** 125 | * The primary color of the progress bar, represented as a `ColorVector4` (RGBA). 126 | */ 127 | primary_color?: ColorVector4; 128 | 129 | /** 130 | * The secondary color of the progress bar, represented as a `ColorVector4` (RGBA). 131 | */ 132 | secondary_color?: ColorVector4; 133 | } 134 | 135 | /** 136 | * Interface representing a paperdoll with camera tilt, rotation, and scaling options. 137 | */ 138 | interface PaperDoll { 139 | /** 140 | * The degree of camera tilt, represented as a floating-point value. 141 | */ 142 | camera_tilt_degrees?: Float; 143 | 144 | /** 145 | * A flag to indicate if rotation starts immediately (`true` for starting rotation). 146 | */ 147 | starting_rotation?: Bool; 148 | 149 | /** 150 | * A flag indicating whether a UUID should be used (`true` for UUID usage). 151 | */ 152 | use_uuid?: Bool; 153 | 154 | /** 155 | * A flag to determine if the skin's GUI scale should be used (`true` for scaling). 156 | */ 157 | use_skin_gui_scale?: Bool; 158 | 159 | /** 160 | * A flag to determine if the player paperdoll should be used (`true` for using paperdoll). 161 | */ 162 | use_player_paperdoll?: Bool; 163 | 164 | /** 165 | * The rotation setting, defined by a variable (`Var`) or a `Rotation`. 166 | */ 167 | rotation?: Var | Rotation; 168 | } 169 | 170 | /** 171 | * Interface representing a panorama with rotation settings. 172 | */ 173 | interface Panorama { 174 | /** 175 | * The rotation setting, defined by a variable (`Var`) or a `Rotation`. 176 | */ 177 | rotation?: Var | Rotation; 178 | } 179 | 180 | /** 181 | * Interface representing credits with an optional end event. 182 | */ 183 | interface Credits { 184 | /** 185 | * The event triggered at the end, defined as a string. 186 | */ 187 | end_event?: string; 188 | } 189 | 190 | /** 191 | * A type representing a collection of special renderer settings, keyed by the renderer type. 192 | */ 193 | export type Specials = { 194 | /** 195 | * The gradient renderer settings. 196 | */ 197 | [Renderer.Gradient]: Gradient; 198 | 199 | /** 200 | * The nametag renderer settings. 201 | */ 202 | [Renderer.NameTag]: Nametag; 203 | 204 | /** 205 | * The progress bar renderer settings. 206 | */ 207 | [Renderer.ProgressBar]: ProgessBar; 208 | 209 | /** 210 | * The paperdoll renderer settings. 211 | */ 212 | [Renderer.PaperDoll]: PaperDoll; 213 | 214 | /** 215 | * The panorama renderer settings. 216 | */ 217 | [Renderer.Panorama]: Panorama; 218 | 219 | /** 220 | * The credits renderer settings. 221 | */ 222 | [Renderer.Credits]: Credits; 223 | 224 | /** 225 | * Any additional renderer settings can be added with a string key and object value. 226 | */ 227 | [key: string]: object; 228 | }; 229 | -------------------------------------------------------------------------------- /src/types/objects/properties/Sprites.ts: -------------------------------------------------------------------------------- 1 | import { ClipDirection } from "../../enums/ClipDirecion"; 2 | import { FontType } from "../../enums/FontType"; 3 | import { TextureFileSystem } from "../../enums/TextureFileSystem"; 4 | import { Bool } from "../../values/Bool"; 5 | import { ColorVector3 } from "../../values/ColorVector"; 6 | import { Float, Int } from "../../values/Number"; 7 | import { Str } from "../../values/Str"; 8 | import { Var } from "../../values/Variable"; 9 | import { Vector2, Vector4 } from "../../values/Vector"; 10 | 11 | /** 12 | * Represents the configuration options for sprites used in rendering. 13 | * This interface includes settings for textures, colors, UV mapping, tiling, and various other sprite-specific properties. 14 | */ 15 | export interface Sprites { 16 | /** 17 | * The texture file used for the sprite. 18 | * This can be a string representing the texture's path or a more complex texture system configuration. 19 | */ 20 | texture?: Str; 21 | 22 | /** 23 | * If true, enables debugging for missing textures. 24 | * Allows the system to provide debug information when the texture is missing or not found. 25 | */ 26 | allow_debug_missing_texture?: Bool; 27 | 28 | /** 29 | * The color applied to the sprite. 30 | * This is a vector of 3 components (RGB) representing the color. 31 | */ 32 | color?: ColorVector3; 33 | 34 | /** 35 | * The locked color applied to the sprite, used when the sprite's color is locked and cannot be changed. 36 | * This is also a vector of 3 components (RGB). 37 | */ 38 | locked_color?: ColorVector3; 39 | 40 | /** 41 | * The UV coordinates for the sprite's texture. 42 | * Represented as a vector of 2 components (x, y). 43 | */ 44 | uv?: Vector2; 45 | 46 | /** 47 | * The size of the UV coordinates for the sprite's texture. 48 | * Represented as a vector of 2 components (width, height). 49 | */ 50 | uv_size?: Vector2; 51 | 52 | /** 53 | * The file system location of the texture file. 54 | * This can be either a `Var` (variable) or a specific texture file system. 55 | */ 56 | texture_file_system?: Var | TextureFileSystem; 57 | 58 | /** 59 | * The size of the sprite in nineslice mode, which allows for stretching and scaling of the sprite's corners. 60 | * This can be a 2D vector (Vector2), a 4-component vector (Vector4), or an integer value (Int). 61 | */ 62 | nineslice_size?: Vector2 | Vector4 | Int; 63 | 64 | /** 65 | * Whether the sprite should be tiled. 66 | * This can be a boolean or a vector indicating tiling in the x and y directions. 67 | */ 68 | tiled?: Bool | Vector2; 69 | 70 | /** 71 | * The scaling factor for the tiled sprite. 72 | * This is a vector of 2 components (x, y) that determines how the tiles are scaled. 73 | */ 74 | tiled_scale?: Vector2; 75 | 76 | /** 77 | * The direction for clipping the sprite's texture. 78 | * This could represent the direction in which the texture is clipped. 79 | */ 80 | clip_direction?: Var | ClipDirection; 81 | 82 | /** 83 | * The ratio for clipping the sprite's texture. 84 | * A floating point value that determines how much of the sprite is clipped. 85 | */ 86 | clip_ratio?: Float; 87 | 88 | /** 89 | * If true, enables pixel-perfect clipping. 90 | * Ensures that the clipping of the sprite's texture is aligned with pixel boundaries. 91 | */ 92 | clip_pixelperfect?: Bool; 93 | 94 | /** 95 | * If true, keeps the sprite's aspect ratio intact when scaling. 96 | * Ensures that the sprite does not get distorted when resized. 97 | */ 98 | keep_ratio?: Bool; 99 | 100 | /** 101 | * If true, enables bilinear filtering for the sprite's texture. 102 | * This smooths the texture by interpolating between pixels when the sprite is resized. 103 | */ 104 | bilinear?: Bool; 105 | 106 | /** 107 | * If true, the sprite will fill the available space. 108 | * This can make the sprite stretch to fill its container or bounding box. 109 | */ 110 | fill?: Bool; 111 | 112 | /** 113 | * The font type for the sprite, if applicable. 114 | * This can be a `Var` or a specific `FontType` configuration. 115 | */ 116 | font_type?: Var | FontType; 117 | 118 | /** 119 | * If true, fits the sprite to the width of its container. 120 | * This scales the sprite's width to match the container's width while maintaining the aspect ratio. 121 | */ 122 | $fit_to_width?: Bool; 123 | 124 | /** 125 | * The folder containing textures in a zip file. 126 | * This can be a string representing the path to the zip folder containing the textures. 127 | */ 128 | zip_folder?: Str; 129 | 130 | /** 131 | * If true, converts the sprite's colors to grayscale. 132 | * This will desaturate the sprite's colors and make them appear in grayscale. 133 | */ 134 | grayscale?: Bool; 135 | 136 | /** 137 | * If true, forces the sprite's texture to reload. 138 | * This can be useful when the texture has been updated or changed and needs to be reloaded into memory. 139 | */ 140 | force_texture_reload?: Bool; 141 | 142 | /** 143 | * The base size of the sprite. 144 | * Represented as a vector of 2 components (width, height) that defines the initial size of the sprite. 145 | */ 146 | base_size?: Vector2; 147 | } 148 | -------------------------------------------------------------------------------- /src/types/objects/properties/StackPanels.ts: -------------------------------------------------------------------------------- 1 | import { Orientation } from "../../enums/Orientation"; 2 | import { Var } from "../../values/Variable"; 3 | 4 | /** 5 | * Represents the configuration for stack panels, which are typically used to arrange items in a stack with a specific orientation. 6 | * The orientation determines whether the items are stacked vertically or horizontally. 7 | */ 8 | export interface StackPanels { 9 | /** 10 | * The orientation of the stack panel. 11 | * This can be either a variable (`Var`) or a specific `Orientation` value. 12 | * It defines whether the items inside the stack panel are arranged in a horizontal or vertical layout. 13 | * Possible values could include: 14 | * - Horizontal: Items are stacked from left to right. 15 | * - Vertical: Items are stacked from top to bottom. 16 | */ 17 | orientation?: Var | Orientation; 18 | } 19 | -------------------------------------------------------------------------------- /src/types/objects/properties/TTS.ts: -------------------------------------------------------------------------------- 1 | import { Bool } from "../../values/Bool"; 2 | import { Int } from "../../values/Number"; 3 | import { Str } from "../../values/Str"; 4 | 5 | /** 6 | * Interface representing text-to-speech (TTS) settings and configurations. 7 | */ 8 | export interface TTS { 9 | /** 10 | * The name of the TTS configuration. 11 | */ 12 | tts_name?: string; 13 | 14 | /** 15 | * The header text for the TTS control section. 16 | */ 17 | tts_control_header?: string; 18 | 19 | /** 20 | * The header text for the TTS section. 21 | */ 22 | tts_section_header?: string; 23 | 24 | /** 25 | * Defines the order priority for TTS control types. 26 | * Lower values indicate higher priority. 27 | */ 28 | tts_control_type_order_priority?: number; 29 | 30 | /** 31 | * Defines the index priority for TTS elements. 32 | * Lower values indicate higher priority. 33 | */ 34 | tts_index_priority?: number; 35 | 36 | /** 37 | * The value or CSS class to apply when the TTS toggle is in the "on" state. 38 | */ 39 | tts_toggle_on?: string; 40 | 41 | /** 42 | * The value or CSS class to apply when the TTS toggle is in the "off" state. 43 | */ 44 | tts_toggle_off?: string; 45 | 46 | /** 47 | * A value to override the control value for TTS. 48 | */ 49 | tts_override_control_value?: string; 50 | 51 | /** 52 | * If true, TTS will inherit settings from sibling elements. 53 | */ 54 | tts_inherit_siblings?: boolean; 55 | 56 | /** 57 | * The action or message to trigger when the TTS value changes. 58 | */ 59 | tts_value_changed?: string; 60 | 61 | /** 62 | * If true, the TTS section is treated as a container. 63 | */ 64 | ttsSectionContainer?: boolean; 65 | 66 | /** 67 | * If true, TTS will ignore count-based settings. 68 | */ 69 | tts_ignore_count?: boolean; 70 | 71 | /** 72 | * If true, the TTS will skip the message. 73 | */ 74 | tts_skip_message?: boolean; 75 | 76 | /** 77 | * Defines the order priority for TTS value changes. 78 | * Lower values indicate higher priority. 79 | */ 80 | tts_value_order_priority?: number; 81 | 82 | /** 83 | * If true, the TTS will play when the focus control remains unchanged. 84 | */ 85 | tts_play_on_unchanged_focus_control?: boolean; 86 | 87 | /** 88 | * If true, the TTS will ignore subsections. 89 | */ 90 | tts_ignore_subsections?: boolean; 91 | 92 | /** 93 | * The text or value to be used for the TTS. 94 | */ 95 | text_tts?: string; 96 | 97 | /** 98 | * If true, the TTS will use priority settings. 99 | */ 100 | use_priority?: boolean; 101 | 102 | /** 103 | * A boolean to set whether the TTS should have priority or not. 104 | */ 105 | priority?: boolean; 106 | } 107 | -------------------------------------------------------------------------------- /src/types/objects/properties/TextEdits.ts: -------------------------------------------------------------------------------- 1 | import { Collection } from "../../enums/Collection"; 2 | import { TextType } from "../../enums/TextTypes"; 3 | import { Bool } from "../../values/Bool"; 4 | import { Int } from "../../values/Number"; 5 | import { Str } from "../../values/Str"; 6 | import { Var } from "../../values/Variable"; 7 | 8 | /** 9 | * Represents the configuration for text editing controls, typically used in UI components 10 | * where users can input and edit text. This configuration allows customization of text input fields, 11 | * including behaviors like enabling new lines, setting maximum text length, and adding placeholder controls. 12 | */ 13 | export interface TextEdits { 14 | /** 15 | * The name of the text box used for text editing. 16 | * This can be a reference to a specific text box in the UI. 17 | */ 18 | text_box_name?: Str; 19 | 20 | /** 21 | * The name of the grid collection associated with the text edit box. 22 | * This can be a variable or a collection object that organizes the text edit box within a grid. 23 | */ 24 | text_edit_box_grid_collection_name?: Var | Collection; 25 | 26 | /** 27 | * A flag that indicates whether the text box should be constrained to a rectangular area. 28 | * When set to true, the text input will be restricted to fit within the specified bounds. 29 | */ 30 | constrain_to_rect?: Bool; 31 | 32 | /** 33 | * A flag that enables or disables new lines within the text box. 34 | * When enabled, users can press Enter to add new lines of text. 35 | */ 36 | enabled_newline?: Bool; 37 | 38 | /** 39 | * The type of text that can be entered into the text box. 40 | * This can be a specific type such as `TextType`, which might include options like plain text or password input. 41 | */ 42 | text_type?: TextType; 43 | 44 | /** 45 | * The maximum length of text that can be entered into the text box. 46 | * This value limits the number of characters a user can input. 47 | */ 48 | max_length?: Int; 49 | 50 | /** 51 | * The name of the control used for displaying or interacting with text. 52 | * This could be the name of a text control that manages text input or editing. 53 | */ 54 | text_control?: Str; 55 | 56 | /** 57 | * The name of the control used for displaying the placeholder text. 58 | * This is often used when no text is present in the input field and provides a hint to the user. 59 | */ 60 | place_holder_control?: Str; 61 | 62 | /** 63 | * A flag that determines whether the text box can be deselected. 64 | * When enabled, users can deselect the text box and stop editing the text. 65 | */ 66 | can_be_deselected?: Bool; 67 | 68 | /** 69 | * A flag indicating whether the text box should always listen for user input. 70 | * When enabled, the text box is constantly listening for changes or input events. 71 | */ 72 | always_listening?: Bool; 73 | 74 | /** 75 | * The control associated with the virtual keyboard buffer. 76 | * This is used when managing virtual keyboards, allowing users to input text using on-screen keyboards. 77 | */ 78 | virtual_keyboard_buffer_control?: Str; 79 | } 80 | -------------------------------------------------------------------------------- /src/types/objects/properties/Texts.ts: -------------------------------------------------------------------------------- 1 | import { LocalizeText } from "../../../components/LocalizeText"; 2 | import { Anchor } from "../../enums/Anchor"; 3 | import { FontSize } from "../../enums/FontSize"; 4 | import { FontType } from "../../enums/FontType"; 5 | import { Bool } from "../../values/Bool"; 6 | import { ColorVector3 } from "../../values/ColorVector"; 7 | import { Float } from "../../values/Number"; 8 | import { Str } from "../../values/Str"; 9 | import { Var } from "../../values/Variable"; 10 | 11 | /** 12 | * Represents configuration options for text display controls, allowing customization of text appearance, 13 | * behaviors, and formatting options in UI components. 14 | */ 15 | export interface Texts { 16 | /** 17 | * The text content to be displayed. This can be a string that is shown in a text control. 18 | */ 19 | text?: Str | LocalizeText; 20 | 21 | /** 22 | * The color of the text, represented as a color vector (RGB). 23 | * This defines the color that the text will be displayed in. 24 | */ 25 | color?: ColorVector3; 26 | 27 | /** 28 | * The locked color of the text, represented as a color vector (RGB). 29 | * This is the color of the text that cannot be changed dynamically. 30 | */ 31 | locked_color?: ColorVector3; 32 | 33 | /** 34 | * A flag that determines whether the text should have a shadow. 35 | * When enabled, a shadow effect will be applied to the text. 36 | */ 37 | shadow?: Bool; 38 | 39 | /** 40 | * A flag that determines whether hyphens should be hidden in the text. 41 | * When enabled, hyphens will not be shown in the text. 42 | */ 43 | hide_hyphen?: Bool; 44 | 45 | /** 46 | * A notification or event triggered when text is truncated with ellipses ("..."). 47 | * This can be a string or an array of strings that indicate the action when ellipses are shown. 48 | */ 49 | notify_on_ellipses?: Str | Array; 50 | 51 | /** 52 | * A flag that enables or disables the profanity filter for the text. 53 | * When enabled, the text will be filtered for profane language. 54 | */ 55 | enable_profanity_filter?: Bool; 56 | 57 | /** 58 | * The locked alpha value of the text, controlling the transparency. 59 | * This value determines the opacity of the text and cannot be changed dynamically. 60 | */ 61 | locked_alpha?: Float; 62 | 63 | /** 64 | * The font scale factor, which allows scaling the font size. 65 | * This factor is multiplied by the default font size to adjust the size of the text. 66 | */ 67 | font_scale_factor?: Float; 68 | 69 | /** 70 | * A flag that enables or disables localization for the text. 71 | * When enabled, the text will be localized based on the user's language settings. 72 | */ 73 | localize?: Bool; 74 | 75 | /** 76 | * The padding between lines of text, which can be used to adjust the spacing between lines. 77 | */ 78 | line_padding?: Float; 79 | 80 | /** 81 | * The font size of the text. This can be a variable or a predefined font size value. 82 | */ 83 | font_size?: Var | FontSize; 84 | 85 | /** 86 | * The type of font to use for displaying the text. 87 | * This can be a variable or a specific font type. 88 | */ 89 | font_type?: Var | FontType; 90 | 91 | /** 92 | * The backup font type to be used if the primary font is unavailable. 93 | */ 94 | backup_font_type?: Var | FontType; 95 | 96 | /** 97 | * The alignment of the text. This can define how the text is aligned within its container (e.g., left, center, right). 98 | */ 99 | text_alignment?: Var | Anchor; 100 | } 101 | -------------------------------------------------------------------------------- /src/types/objects/properties/Toggles.ts: -------------------------------------------------------------------------------- 1 | import { Bool } from "../../values/Bool"; 2 | import { Int } from "../../values/Number"; 3 | import { Str } from "../../values/Str"; 4 | 5 | /** 6 | * Interface representing toggle settings and states. 7 | */ 8 | export interface Toggles { 9 | /** 10 | * Defines whether the toggle is part of a radio button group. 11 | * @default false 12 | */ 13 | radio_toggle_group?: boolean; 14 | 15 | /** 16 | * The name of the toggle. 17 | */ 18 | toggle_name?: string; 19 | 20 | /** 21 | * The default state of the toggle (true = on, false = off). 22 | * @default false 23 | */ 24 | toggle_default_state?: boolean; 25 | 26 | /** 27 | * The forced index for the toggle group when selecting toggles. 28 | */ 29 | toggle_group_forced_index?: number; 30 | 31 | /** 32 | * The default selected index in the toggle group. 33 | * @default 0 34 | */ 35 | toggle_group_default_selected?: number; 36 | 37 | /** 38 | * If true, the toggle resets when focus is lost. 39 | * @default false 40 | */ 41 | reset_on_focus_lost?: boolean; 42 | 43 | /** 44 | * The Child Element to apply when hovering over the toggle. 45 | */ 46 | toggle_on_hover?: string; 47 | 48 | /** 49 | * The Child Element to apply to the toggle when it is in the "on" state. 50 | */ 51 | toggle_on_button?: string; 52 | 53 | /** 54 | * The Child Element to apply to the toggle when it is in the "off" state. 55 | */ 56 | toggle_off_button?: string; 57 | 58 | /** 59 | * If true, enables directional toggling (e.g., using arrow keys). 60 | * @default false 61 | */ 62 | enable_directional_toggling?: boolean; 63 | 64 | /** 65 | * The name of the toggle grid collection. 66 | */ 67 | toggle_grid_collection_name?: string; 68 | 69 | /** 70 | * The Child Element for the unchecked state control. 71 | */ 72 | unchecked_control?: string; 73 | 74 | /** 75 | * The Child Element for the checked state control. 76 | */ 77 | checked_control?: string; 78 | 79 | /** 80 | * The Child Element for the unchecked state control when hovered. 81 | */ 82 | unchecked_hover_control?: string; 83 | 84 | /** 85 | * The Child Element for the checked state control when hovered. 86 | */ 87 | checked_hover_control?: string; 88 | 89 | /** 90 | * The Child Element for the unchecked state control when locked. 91 | */ 92 | unchecked_locked_control?: string; 93 | 94 | /** 95 | * The Child Element for the checked state control when locked. 96 | */ 97 | checked_locked_control?: string; 98 | 99 | /** 100 | * The Child Element for the unchecked state control when locked and hovered. 101 | */ 102 | unchecked_locked_hover_control?: string; 103 | 104 | /** 105 | * The Child Element for the checked state control when locked and hovered. 106 | */ 107 | checked_locked_hover_control?: string; 108 | } 109 | -------------------------------------------------------------------------------- /src/types/objects/properties/TooltipTriggers.ts: -------------------------------------------------------------------------------- 1 | import { Str } from "../../values/Str"; 2 | 3 | export interface TooltipTriggers { 4 | tooltip_name?: Str, 5 | tooltip_top_content_control?: Str, 6 | tooltip_bottom_content_control?: Str, 7 | tooltip_area?: Str, 8 | } -------------------------------------------------------------------------------- /src/types/objects/properties/Variables.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Interface representing a collection of dynamic variables. 3 | * 4 | * This interface allows any string prefixed with `$` as a key, and its associated value can be of any type. 5 | */ 6 | export interface Variables { 7 | /** 8 | * A dynamic key-value pair where the key is a string starting with the `$` symbol, 9 | * and the value can be of any type. 10 | * 11 | * Example: 12 | * ```typescript 13 | * const vars: Variables = { $userName: "John", $isActive: true }; 14 | * ``` 15 | */ 16 | [key: `$${string}`]: any; 17 | } 18 | -------------------------------------------------------------------------------- /src/types/values/Any.ts: -------------------------------------------------------------------------------- 1 | import { RangeVector } from "./RangeVector"; 2 | import { StringVector } from "./StringVector"; 3 | import { Vector } from "./Vector"; 4 | 5 | export type Any = string | number | Vector | RangeVector | StringVector; -------------------------------------------------------------------------------- /src/types/values/Binding.ts: -------------------------------------------------------------------------------- 1 | import { Var } from "./Variable"; 2 | 3 | export type Binding = Var | `#${string}`; -------------------------------------------------------------------------------- /src/types/values/Bool.ts: -------------------------------------------------------------------------------- 1 | import { Var } from "./Variable"; 2 | 3 | export type Bool = Var | boolean; -------------------------------------------------------------------------------- /src/types/values/ColorVector.ts: -------------------------------------------------------------------------------- 1 | import { RangeVector3, RangeVector4 } from "./RangeVector"; 2 | import { Var } from "./Variable"; 3 | 4 | export type ColorHeximal = `#${string}`; 5 | export type ColorVector3 = Var | [ColorHeximal] | RangeVector3; 6 | export type ColorVector4 = Var | [ColorHeximal] | RangeVector4; 7 | 8 | export type ColorVector = ColorVector3 | ColorVector4; 9 | -------------------------------------------------------------------------------- /src/types/values/ElementPath.ts: -------------------------------------------------------------------------------- 1 | import { Var } from "./Variable"; 2 | 3 | export type ElementPath = Var | `${string}.${string}`; -------------------------------------------------------------------------------- /src/types/values/Hex.ts: -------------------------------------------------------------------------------- 1 | export type HexChar = 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 'a' | 'A' | 'b' | 'B' | 'c' | 'C' | 'd' | 'D' | 'e' | 'E' | 'f' | 'F'; -------------------------------------------------------------------------------- /src/types/values/Number.ts: -------------------------------------------------------------------------------- 1 | import { Var } from "./Variable"; 2 | 3 | export type Int = Var | number; 4 | export type Float = Var | number; 5 | export type RangeFloat = Var | number; -------------------------------------------------------------------------------- /src/types/values/RangeVector.ts: -------------------------------------------------------------------------------- 1 | import { RangeFloat } from "./Number"; 2 | import { Var } from "./Variable"; 3 | 4 | export type RangeVector3 = Var | [RangeFloat, RangeFloat, RangeFloat]; 5 | export type RangeVector4 = Var | [RangeFloat, RangeFloat, RangeFloat, RangeFloat]; 6 | 7 | export type RangeVector = RangeVector3 | RangeVector4; -------------------------------------------------------------------------------- /src/types/values/Str.ts: -------------------------------------------------------------------------------- 1 | import { Var } from "./Variable"; 2 | 3 | export type Str = Var | string; -------------------------------------------------------------------------------- /src/types/values/StringVector.ts: -------------------------------------------------------------------------------- 1 | import { Float } from "./Number"; 2 | import { Var } from "./Variable"; 3 | 4 | export type StringVector2 = Var | [Float | string, Float | string]; 5 | export type StringVector3 = Var | [Float | string, Float | string, Float | string]; 6 | export type StringVector4 = Var | [Float | string, Float | string, Float | string, Float | string]; 7 | 8 | export type StringVector = StringVector2 | StringVector3 | StringVector4; -------------------------------------------------------------------------------- /src/types/values/TargetElementPath.ts: -------------------------------------------------------------------------------- 1 | export type TargetElementPath = `@${string}.${string}`; -------------------------------------------------------------------------------- /src/types/values/Variable.ts: -------------------------------------------------------------------------------- 1 | export type Var = `$${string}` | `(${string})` | [`$${string}`, any]; 2 | -------------------------------------------------------------------------------- /src/types/values/Vector.ts: -------------------------------------------------------------------------------- 1 | import { Var } from "./Variable"; 2 | 3 | export type Vector2 = Var | [number | string, number | string]; 4 | export type Vector3 = Var | [number | string, number | string, number | string]; 5 | export type Vector4 = 6 | | Var 7 | | [number | string, number | string, number | string, number | string]; 8 | 9 | export type Vector = Vector2 | Vector3 | Vector4; 10 | -------------------------------------------------------------------------------- /tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "ESNext", 4 | "module": "NodeNext", 5 | "moduleResolution": "NodeNext", 6 | "esModuleInterop": true, 7 | "forceConsistentCasingInFileNames": true, 8 | "strict": true, 9 | "incremental": true, 10 | "tsBuildInfoFile": ".tsbuildinfo" 11 | }, 12 | "include": ["src/**/*"], 13 | "exclude": ["node_modules", "dist"] 14 | } 15 | --------------------------------------------------------------------------------