public toString method
This commit is contained in:
parent
3dba9225e7
commit
e2be9892dc
6 changed files with 18 additions and 8 deletions
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "asajs",
|
"name": "asajs",
|
||||||
"version": "4.1.13",
|
"version": "4.1.14",
|
||||||
"description": "Create your Minecraft JSON-UI resource packs using JavaScript",
|
"description": "Create your Minecraft JSON-UI resource packs using JavaScript",
|
||||||
"keywords": [
|
"keywords": [
|
||||||
"Minecraft",
|
"Minecraft",
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
import { AnimType } from "../types/enums/AnimType.js"
|
import { AnimType } from "../types/enums/AnimType.js"
|
||||||
import { SmartAnimation } from "../types/enums/SmartAnimation.js"
|
import { SmartAnimation } from "../types/enums/SmartAnimation.js"
|
||||||
import { AnimationProperties } from "../types/properties/element/Animation.js"
|
import { AnimationProperties } from "../types/properties/element/Animation.js"
|
||||||
|
import { Control } from "../types/properties/value.js"
|
||||||
import { Class } from "./Class.js"
|
import { Class } from "./Class.js"
|
||||||
import { KeyframeController } from "./KeyframeController.js"
|
import { KeyframeController } from "./KeyframeController.js"
|
||||||
|
|
||||||
|
|
@ -138,8 +139,8 @@ export class Animation<T extends AnimType> extends Class {
|
||||||
return this
|
return this
|
||||||
}
|
}
|
||||||
|
|
||||||
protected toString() {
|
toString(): Control {
|
||||||
return String(this.firstKey())
|
return <Control>String(this.firstKey())
|
||||||
}
|
}
|
||||||
|
|
||||||
protected [util.inspect.custom]($: any, opts: any) {
|
protected [util.inspect.custom]($: any, opts: any) {
|
||||||
|
|
|
||||||
|
|
@ -9,6 +9,7 @@ import { defaultNamespace, RandomNamespace, RandomString } from "./Utils.js"
|
||||||
import nodepath from "path"
|
import nodepath from "path"
|
||||||
|
|
||||||
import util from "node:util"
|
import util from "node:util"
|
||||||
|
import { Control } from "../types/properties/value.js"
|
||||||
|
|
||||||
const fileExt = config.compiler?.fileExtension
|
const fileExt = config.compiler?.fileExtension
|
||||||
? config.compiler.fileExtension.startsWith(".")
|
? config.compiler.fileExtension.startsWith(".")
|
||||||
|
|
@ -77,7 +78,7 @@ export class AnimationKeyframe<T extends AnimType> extends Class {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected toString() {
|
toString(): Control {
|
||||||
return `@${this.namespace}.${this.name}`
|
return `@${this.namespace}.${this.name}`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,14 @@ import { Operation } from "../types/enums/Operation.js"
|
||||||
import { Renderer } from "../types/enums/Renderer.js"
|
import { Renderer } from "../types/enums/Renderer.js"
|
||||||
import { Type } from "../types/enums/Type.js"
|
import { Type } from "../types/enums/Type.js"
|
||||||
import { Properties } from "../types/properties/components.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 { Animation } from "./Animation.js"
|
||||||
import { AnimationKeyframe } from "./AnimationKeyframe.js"
|
import { AnimationKeyframe } from "./AnimationKeyframe.js"
|
||||||
import { Class } from "./Class.js"
|
import { Class } from "./Class.js"
|
||||||
|
|
@ -165,7 +172,7 @@ export class UI<T extends Type, K extends Renderer | null = null> extends Class
|
||||||
return ui
|
return ui
|
||||||
}
|
}
|
||||||
|
|
||||||
protected toString() {
|
toString(): Control {
|
||||||
return `@${this.namespace}.${this.name}`
|
return `@${this.namespace}.${this.name}`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,7 @@ export interface Sprite {
|
||||||
uv_size?: AnimValue<Array2<number>>
|
uv_size?: AnimValue<Array2<number>>
|
||||||
texture_file_system?: Value<string>
|
texture_file_system?: Value<string>
|
||||||
nineslice_size?: AnimValue<Array2<number> | Array3<number> | Array4<number>>
|
nineslice_size?: AnimValue<Array2<number> | Array3<number> | Array4<number>>
|
||||||
tiled?: Value<boolean>
|
tiled?: Value<boolean | { x: number; y: number }>
|
||||||
tiled_scale?: Value<Array<number>>
|
tiled_scale?: Value<Array<number>>
|
||||||
clip_direction?: Value<string | ClipDirection>
|
clip_direction?: Value<string | ClipDirection>
|
||||||
clip_ratio?: Value<number>
|
clip_ratio?: Value<number>
|
||||||
|
|
|
||||||
|
|
@ -14,13 +14,14 @@ import { AnimationKeyframe } from "../../components/AnimationKeyframe.js"
|
||||||
|
|
||||||
export type Variable = `$${string}`
|
export type Variable = `$${string}`
|
||||||
export type Binding = `#${string}`
|
export type Binding = `#${string}`
|
||||||
|
export type Control = `@${string}` | `${string}@${string}`
|
||||||
export type Animation = anim.Animation<AnimType> | AnimationKeyframe<AnimType> | `@${string}`
|
export type Animation = anim.Animation<AnimType> | AnimationKeyframe<AnimType> | `@${string}`
|
||||||
|
|
||||||
export type Array2<T> = [T, T]
|
export type Array2<T> = [T, T]
|
||||||
export type Array3<T> = [T, T, T]
|
export type Array3<T> = [T, T, T]
|
||||||
export type Array4<T> = [T, T, T, T]
|
export type Array4<T> = [T, T, T, T]
|
||||||
|
|
||||||
export type Value<T> = Variable | Binding | T
|
export type Value<T> = Variable | Binding | Control | T
|
||||||
export type AnimValue<T> = Value<T | Animation>
|
export type AnimValue<T> = Value<T | Animation>
|
||||||
|
|
||||||
export type BindingItem = {
|
export type BindingItem = {
|
||||||
|
|
|
||||||
Reference in a new issue