From e2be9892dc7d77edc39478c3f26108f47bfb3345 Mon Sep 17 00:00:00 2001 From: Asaki Yuki Date: Tue, 24 Feb 2026 14:24:43 +0700 Subject: [PATCH] public toString method --- package.json | 2 +- src/components/Animation.ts | 5 +++-- src/components/AnimationKeyframe.ts | 3 ++- src/components/UI.ts | 11 +++++++++-- src/types/properties/element/Sprite.ts | 2 +- src/types/properties/value.ts | 3 ++- 6 files changed, 18 insertions(+), 8 deletions(-) diff --git a/package.json b/package.json index 0153208..7df1958 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "asajs", - "version": "4.1.13", + "version": "4.1.14", "description": "Create your Minecraft JSON-UI resource packs using JavaScript", "keywords": [ "Minecraft", diff --git a/src/components/Animation.ts b/src/components/Animation.ts index 39c5ce7..2dced74 100644 --- a/src/components/Animation.ts +++ b/src/components/Animation.ts @@ -1,6 +1,7 @@ import { AnimType } from "../types/enums/AnimType.js" import { SmartAnimation } from "../types/enums/SmartAnimation.js" import { AnimationProperties } from "../types/properties/element/Animation.js" +import { Control } from "../types/properties/value.js" import { Class } from "./Class.js" import { KeyframeController } from "./KeyframeController.js" @@ -138,8 +139,8 @@ export class Animation extends Class { return this } - protected toString() { - return String(this.firstKey()) + toString(): Control { + return String(this.firstKey()) } protected [util.inspect.custom]($: any, opts: any) { diff --git a/src/components/AnimationKeyframe.ts b/src/components/AnimationKeyframe.ts index 6e702e2..6b3368e 100644 --- a/src/components/AnimationKeyframe.ts +++ b/src/components/AnimationKeyframe.ts @@ -9,6 +9,7 @@ import { defaultNamespace, RandomNamespace, RandomString } from "./Utils.js" import nodepath from "path" import util from "node:util" +import { Control } from "../types/properties/value.js" const fileExt = config.compiler?.fileExtension ? config.compiler.fileExtension.startsWith(".") @@ -77,7 +78,7 @@ export class AnimationKeyframe extends Class { } } - protected toString() { + toString(): Control { return `@${this.namespace}.${this.name}` } diff --git a/src/components/UI.ts b/src/components/UI.ts index 43a4256..3699b02 100644 --- a/src/components/UI.ts +++ b/src/components/UI.ts @@ -6,7 +6,14 @@ import { Operation } from "../types/enums/Operation.js" import { Renderer } from "../types/enums/Renderer.js" import { Type } from "../types/enums/Type.js" import { Properties } from "../types/properties/components.js" -import { BindingItem, ButtonMapping, ModificationItem, VariableItem, Variables } from "../types/properties/value.js" +import { + BindingItem, + ButtonMapping, + Control, + ModificationItem, + VariableItem, + Variables, +} from "../types/properties/value.js" import { Animation } from "./Animation.js" import { AnimationKeyframe } from "./AnimationKeyframe.js" import { Class } from "./Class.js" @@ -165,7 +172,7 @@ export class UI extends Class return ui } - protected toString() { + toString(): Control { return `@${this.namespace}.${this.name}` } diff --git a/src/types/properties/element/Sprite.ts b/src/types/properties/element/Sprite.ts index 363e65f..21d9b7f 100644 --- a/src/types/properties/element/Sprite.ts +++ b/src/types/properties/element/Sprite.ts @@ -8,7 +8,7 @@ export interface Sprite { uv_size?: AnimValue> texture_file_system?: Value nineslice_size?: AnimValue | Array3 | Array4> - tiled?: Value + tiled?: Value tiled_scale?: Value> clip_direction?: Value clip_ratio?: Value diff --git a/src/types/properties/value.ts b/src/types/properties/value.ts index ab6f16d..5fc2d81 100644 --- a/src/types/properties/value.ts +++ b/src/types/properties/value.ts @@ -14,13 +14,14 @@ import { AnimationKeyframe } from "../../components/AnimationKeyframe.js" export type Variable = `$${string}` export type Binding = `#${string}` +export type Control = `@${string}` | `${string}@${string}` export type Animation = anim.Animation | AnimationKeyframe | `@${string}` export type Array2 = [T, T] export type Array3 = [T, T, T] export type Array4 = [T, T, T, T] -export type Value = Variable | Binding | T +export type Value = Variable | Binding | Control | T export type AnimValue = Value export type BindingItem = {