asajs 4.1.13 → 4.1.15

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -32,6 +32,10 @@ export function FormatProperties(properties) {
32
32
  properties.anchor_from = properties.anchor_to = properties.anchor;
33
33
  delete properties.anchor;
34
34
  }
35
+ if (properties.fit_to_width) {
36
+ properties["$fit_to_width"] = properties.fit_to_width;
37
+ delete properties.fit_to_width;
38
+ }
35
39
  if (Object.keys(property_bag).length) {
36
40
  if (properties.property_bag) {
37
41
  properties.property_bag = { ...property_bag, ...properties.property_bag };
@@ -0,0 +1,49 @@
1
+ import { Class } from "./Class.js";
2
+ export class FactoryManager extends Class {
3
+ name;
4
+ maxChildrenSize;
5
+ factoryVariables;
6
+ controlIds;
7
+ control;
8
+ constructor(name) {
9
+ super();
10
+ this.name = name;
11
+ this.controlIds = new Map();
12
+ }
13
+ setControlId(name, element) {
14
+ if (this.control)
15
+ throw new Error("Cannot set control id after setting control");
16
+ this.controlIds.set(name, element);
17
+ return this;
18
+ }
19
+ setControlIds(...elements) {
20
+ elements.forEach(({ name, element }) => this.controlIds.set(name, element));
21
+ return this;
22
+ }
23
+ setControl(element) {
24
+ if (this.controlIds.size)
25
+ throw new Error("Cannot set control after setting control ids");
26
+ this.control = element;
27
+ return this;
28
+ }
29
+ setMaxChildrenSize(size) {
30
+ this.maxChildrenSize = size;
31
+ return this;
32
+ }
33
+ toJSON() {
34
+ const obj = { name: this.name };
35
+ if (this.maxChildrenSize)
36
+ obj.max_children_size = this.maxChildrenSize;
37
+ if (this.factoryVariables)
38
+ obj.variables = this.factoryVariables;
39
+ if (this.control)
40
+ obj.control_name = this.control.toString().slice(1);
41
+ if (this.controlIds.size) {
42
+ const controlIds = {};
43
+ this.controlIds.forEach((value, key) => (controlIds[key] = key + value.toString()));
44
+ obj.control_ids = controlIds;
45
+ }
46
+ return obj;
47
+ }
48
+ }
49
+ //# sourceMappingURL=Factory.js.map
@@ -25,6 +25,7 @@ export class UI extends Class {
25
25
  buttonMappings = [];
26
26
  anims = [];
27
27
  extendType;
28
+ factory;
28
29
  properties = {};
29
30
  bindCache = new Map();
30
31
  constructor(type, name, namespace, path, allowObfuscate) {
@@ -58,6 +59,10 @@ export class UI extends Class {
58
59
  this.properties = { ...this.properties, ...properties };
59
60
  return this;
60
61
  }
62
+ setFactory(factory) {
63
+ this.factory = factory;
64
+ return this;
65
+ }
61
66
  /**
62
67
  * Bind data (coming from the code) to this UI element to use.
63
68
  * @param bindings
@@ -105,6 +110,13 @@ export class UI extends Class {
105
110
  callback?.(childName, this);
106
111
  return this;
107
112
  }
113
+ addChilds(...childs) {
114
+ const childrenList = childs;
115
+ childrenList.forEach(({ child, properties, name, callback }) => {
116
+ this.addChild(child, properties, name, callback);
117
+ });
118
+ return this;
119
+ }
108
120
  addAnimations(...anims) {
109
121
  this.anims.push(...anims);
110
122
  return this;
@@ -143,6 +155,8 @@ export class UI extends Class {
143
155
  obj.variables = this.variables;
144
156
  if (this.buttonMappings.length)
145
157
  obj.button_mappings = this.buttonMappings;
158
+ if (this.factory)
159
+ obj.factory = this.factory;
146
160
  if (this.anims.length)
147
161
  obj.anims = this.anims.map(a => String(a));
148
162
  if (this.controls.size) {
@@ -12,6 +12,7 @@ import { MemoryModify } from "../compilers/Memory.js";
12
12
  import { Lexer } from "../compilers/bindings/Lexer.js";
13
13
  import { TokenKind, TSTokenKind } from "../compilers/bindings/types.js";
14
14
  import { allowRandomStringName, forceRandomStringLength, isNotObfuscate, namespaceCount, } from "../compilers/Configuration.js";
15
+ import { FactoryManager } from "./Factory.js";
15
16
  export function Color(hex) {
16
17
  if (typeof hex === "number") {
17
18
  return [((hex >> 16) & 0xff) / 0xff, ((hex >> 8) & 0xff) / 0xff, (hex & 0xff) / 0xff];
@@ -269,6 +270,9 @@ export function Modify(namespace, name) {
269
270
  (MemoryModify[getPath] ||= {})[name] = modifyUI;
270
271
  return modifyUI;
271
272
  }
273
+ export function Factory(name) {
274
+ return new FactoryManager(name);
275
+ }
272
276
  export function Panel(properties, namespace, name, allowObfuscate) {
273
277
  return new UI(Type.PANEL, name, namespace, undefined, allowObfuscate).setProperties(properties || {});
274
278
  }
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=TextureFileSystem.js.map
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=Dropdown.js.map
@@ -6,7 +6,7 @@ export * from "./Control.js";
6
6
  export * from "./CustomRenderer.js";
7
7
  export * from "./Cycler.js";
8
8
  export * from "./DataBinding.js";
9
- export * from "./DropdownName.js";
9
+ export * from "./Dropdown.js";
10
10
  export * from "./EditBox.js";
11
11
  export * from "./Factory.js";
12
12
  export * from "./Focus.js";
@@ -0,0 +1,15 @@
1
+ export var TextureFileSystem;
2
+ (function (TextureFileSystem) {
3
+ TextureFileSystem["IN_USER_PACKAGE"] = "InUserPackage";
4
+ TextureFileSystem["IN_APP_PACKAGE"] = "InAppPackage";
5
+ TextureFileSystem["RAW_PATH"] = "RawPath";
6
+ TextureFileSystem["RAW_PERSISTENT"] = "RawPersistent";
7
+ TextureFileSystem["IN_SETTINGS_DIR"] = "InSettingsDir";
8
+ TextureFileSystem["IN_EXTERNAL_DIR"] = "InExternalDir";
9
+ TextureFileSystem["IN_SERVER_PACKAGE"] = "InServerPackage";
10
+ TextureFileSystem["IN_DATA_DIR"] = "InDataDir";
11
+ TextureFileSystem["IN_USER_DIR"] = "InUserDir";
12
+ TextureFileSystem["IN_WORLD_DIR"] = "InWorldDir";
13
+ TextureFileSystem["STORE_CACHE"] = "StoreCache";
14
+ })(TextureFileSystem || (TextureFileSystem = {}));
15
+ //# sourceMappingURL=enum.js.map
@@ -1,6 +1,7 @@
1
1
  export * as ElementProperties from "./element/index.js";
2
2
  export * as ComponentProperties from "./components.js";
3
3
  export * as Value from "./value.js";
4
+ export * from "./enum.js";
4
5
  export { ArrayName } from "../enums/ArrayName.js";
5
6
  export { Operation } from "../enums/Operation.js";
6
7
  //# sourceMappingURL=index.js.map
@@ -1,6 +1,7 @@
1
1
  import { AnimType } from "../types/enums/AnimType.js";
2
2
  import { SmartAnimation } from "../types/enums/SmartAnimation.js";
3
3
  import { AnimationProperties } from "../types/properties/element/Animation.js";
4
+ import { Control } from "../types/properties/value.js";
4
5
  import { Class } from "./Class.js";
5
6
  import { KeyframeController } from "./KeyframeController.js";
6
7
  import util from "node:util";
@@ -18,7 +19,7 @@ export declare class Animation<T extends AnimType> extends Class {
18
19
  private transformKeyframe;
19
20
  private addKeyframes;
20
21
  setLoop(boolean: boolean): this;
21
- protected toString(): string;
22
+ toString(): Control;
22
23
  protected [util.inspect.custom]($: any, opts: any): string;
23
24
  }
24
25
  export {};
@@ -3,6 +3,7 @@ import { KeyframeAnimationProperties } from "../types/properties/element/Animati
3
3
  import { Animation } from "./Animation.js";
4
4
  import { Class } from "./Class.js";
5
5
  import util from "node:util";
6
+ import { Control } from "../types/properties/value.js";
6
7
  export declare class AnimationKeyframe<T extends AnimType> extends Class {
7
8
  readonly type: T;
8
9
  readonly properties: KeyframeAnimationProperties<T>;
@@ -88,6 +89,6 @@ export declare class AnimationKeyframe<T extends AnimType> extends Class {
88
89
  wait_until_rendered_to_play?: import("../types/properties/value.js").Value<boolean>;
89
90
  anim_type: T;
90
91
  };
91
- protected toString(): string;
92
+ toString(): Control;
92
93
  protected [util.inspect.custom]($: any, opts: any): string;
93
94
  }
@@ -0,0 +1,19 @@
1
+ import { Type } from "../types/enums/Type.js";
2
+ import { Class } from "./Class.js";
3
+ import { UI } from "./UI.js";
4
+ export declare class FactoryManager extends Class {
5
+ protected name: string;
6
+ private maxChildrenSize?;
7
+ private factoryVariables?;
8
+ private controlIds;
9
+ private control?;
10
+ constructor(name: string);
11
+ setControlId(name: string, element: UI<Type>): this;
12
+ setControlIds(...elements: {
13
+ name: string;
14
+ element: UI<Type>;
15
+ }[]): this;
16
+ setControl(element: UI<Type>): this;
17
+ setMaxChildrenSize(size: number): this;
18
+ protected toJSON(): any;
19
+ }
@@ -2,16 +2,23 @@ import { AnimType } from "../types/enums/AnimType.js";
2
2
  import { Renderer } from "../types/enums/Renderer.js";
3
3
  import { Type } from "../types/enums/Type.js";
4
4
  import { Properties } from "../types/properties/components.js";
5
- import { BindingItem, ButtonMapping, ModificationItem, VariableItem, Variables } from "../types/properties/value.js";
5
+ import { BindingItem, ButtonMapping, Control, ModificationItem, VariableItem, Variables } from "../types/properties/value.js";
6
6
  import { Animation } from "./Animation.js";
7
7
  import { AnimationKeyframe } from "./AnimationKeyframe.js";
8
8
  import { Class } from "./Class.js";
9
9
  import util from "node:util";
10
+ import { FactoryManager } from "./Factory.js";
10
11
  interface ExtendUI {
11
12
  name: string;
12
13
  namespace: string;
13
14
  toString(): string;
14
15
  }
16
+ type ChildInput<C extends UI<Type, Renderer | null>> = {
17
+ child: C;
18
+ properties?: C extends UI<infer T, infer K> ? Partial<Properties<T, K>> : never;
19
+ name?: string;
20
+ callback?: (name: string, parent: UI<Type, Renderer | null>) => void;
21
+ };
15
22
  export declare class UI<T extends Type, K extends Renderer | null = null> extends Class {
16
23
  type?: T | undefined;
17
24
  readonly path: string;
@@ -25,6 +32,7 @@ export declare class UI<T extends Type, K extends Renderer | null = null> extend
25
32
  protected readonly buttonMappings: ButtonMapping[];
26
33
  protected readonly anims: (Animation<AnimType> | AnimationKeyframe<AnimType>)[];
27
34
  protected readonly extendType?: Type;
35
+ protected factory?: FactoryManager;
28
36
  protected properties: Properties<T, K>;
29
37
  protected bindCache: Map<string, unknown>;
30
38
  constructor(type?: T | undefined, name?: string, namespace?: string, path?: string, allowObfuscate?: boolean);
@@ -34,6 +42,7 @@ export declare class UI<T extends Type, K extends Renderer | null = null> extend
34
42
  * @returns
35
43
  */
36
44
  setProperties(properties: Properties<T, K>): this;
45
+ setFactory(factory: FactoryManager): this;
37
46
  /**
38
47
  * Bind data (coming from the code) to this UI element to use.
39
48
  * @param bindings
@@ -60,6 +69,9 @@ export declare class UI<T extends Type, K extends Renderer | null = null> extend
60
69
  * @returns
61
70
  */
62
71
  addChild<T extends Type, K extends Renderer | null>(child: UI<T, K>, properties?: Properties<T, K>, name?: string, callback?: (name: string, parent: UI<T, K>) => void): this;
72
+ addChilds<UIs extends readonly UI<Type, Renderer | null>[]>(...childs: {
73
+ [K in keyof UIs]: ChildInput<UIs[K]>;
74
+ }): this;
63
75
  addAnimations(...anims: (Animation<AnimType> | AnimationKeyframe<AnimType>)[]): this;
64
76
  /**
65
77
  * Return a extend of this element
@@ -69,7 +81,7 @@ export declare class UI<T extends Type, K extends Renderer | null = null> extend
69
81
  * @returns
70
82
  */
71
83
  createExtends(properties?: Properties<T, K>, name?: string, namespace?: string): UI<T, K>;
72
- protected toString(): string;
84
+ toString(): Control;
73
85
  protected toJsonUI(): any;
74
86
  protected toJSON(): any;
75
87
  protected [util.inspect.custom]($: any, opts: any): string;
@@ -9,6 +9,7 @@ import { AnimationKeyframe } from "./AnimationKeyframe.js";
9
9
  import { AnimationProperties, KeyframeAnimationProperties } from "../types/properties/element/Animation.js";
10
10
  import { Animation } from "./Animation.js";
11
11
  import { SmartAnimation } from "../types/enums/SmartAnimation.js";
12
+ import { FactoryManager } from "./Factory.js";
12
13
  type CompileBinding = `[${string}]`;
13
14
  export declare function Color(hex: string | number): Array3<number>;
14
15
  export declare function ResolveBinding(cache: Map<string, unknown>, ...bindings: BindingItem[]): BindingItem[];
@@ -37,6 +38,7 @@ export declare function f(input: string): CompileBinding;
37
38
  */
38
39
  export declare function b(input: string): CompileBinding;
39
40
  export declare function Modify<T extends Namespace, K extends Element<T>>(namespace: T, name: K): ModifyUI<VanillaType<T, K>, VanillaElementChilds<T, K>>;
41
+ export declare function Factory(name: string): FactoryManager;
40
42
  export declare function Panel(properties?: Panel, namespace?: string, name?: string, allowObfuscate?: boolean): UI<Type.PANEL, null>;
41
43
  export declare function CollectionPanel(properties?: CollectionPanel, namespace?: string, name?: string, allowObfuscate?: boolean): UI<Type.COLLECTION_PANEL, null>;
42
44
  export declare function StackPanel(properties?: StackPanel, namespace?: string, name?: string, allowObfuscate?: boolean): UI<Type.STACK_PANEL, null>;
@@ -68,8 +70,8 @@ export declare function AlphaKeyframe(properties?: KeyframeAnimationProperties<A
68
70
  export declare function WaitKeyframe(properties?: KeyframeAnimationProperties<AnimType.WAIT>, namespace?: string, name?: string): AnimationKeyframe<AnimType.WAIT>;
69
71
  export declare function FlipBookKeyframe(properties?: KeyframeAnimationProperties<AnimType.FLIP_BOOK>, namespace?: string, name?: string): AnimationKeyframe<AnimType.FLIP_BOOK>;
70
72
  export declare function AsepriteFlipBookKeyframe(properties?: KeyframeAnimationProperties<AnimType.ASEPRITE_FLIP_BOOK>, namespace?: string, name?: string): AnimationKeyframe<AnimType.ASEPRITE_FLIP_BOOK>;
71
- type Anim<T extends AnimType> = AnimationProperties<T> | number;
72
- type AnimWithSmartAnim<T extends AnimType> = [SmartAnimation | Anim<T>, ...Anim<T>[]];
73
+ export type AnimationByType<T extends AnimType> = AnimationProperties<T> | number;
74
+ export type AnimWithSmartAnim<T extends AnimType> = [SmartAnimation | AnimationByType<T>, ...AnimationByType<T>[]];
73
75
  export declare function OffsetAnimation(...keyframes: AnimWithSmartAnim<AnimType.OFFSET>): Animation<AnimType.OFFSET>;
74
76
  export declare function SizeAnimation(...keyframes: AnimWithSmartAnim<AnimType.SIZE>): Animation<AnimType.SIZE>;
75
77
  export declare function UVAnimation(...keyframes: AnimWithSmartAnim<AnimType.UV>): Animation<AnimType.UV>;
@@ -0,0 +1 @@
1
+ export {};
@@ -25,7 +25,7 @@ export interface Button extends InputPanel, e.Button {
25
25
  }
26
26
  export interface Toggle extends InputPanel, e.Toggle {
27
27
  }
28
- export interface Dropdown extends Toggle, e.DropdownName {
28
+ export interface Dropdown extends Toggle, e.Dropdown {
29
29
  }
30
30
  export interface SelectionWheel extends InputPanel, e.SelectionWheel {
31
31
  }
@@ -4,13 +4,13 @@ export interface Control {
4
4
  ignored?: Value<boolean>;
5
5
  enabled?: Value<boolean>;
6
6
  layer?: Value<number>;
7
- z_order?: Value<number>;
8
7
  alpha?: AnimValue<number>;
9
8
  propagate_alpha?: Value<boolean>;
10
9
  clips_children?: Value<boolean>;
11
10
  allow_clipping?: Value<boolean>;
12
11
  clip_offset?: Value<Array2<number>>;
13
12
  clip_state_change_event?: Value<string>;
13
+ enable_scissor_test?: Value<boolean>;
14
14
  selected?: Value<boolean>;
15
15
  use_child_anchors?: Value<boolean>;
16
16
  contained?: Value<boolean>;
@@ -19,6 +19,9 @@ export interface Control {
19
19
  property_bag?: Value<PropertyBags>;
20
20
  collection_index?: Value<number>;
21
21
  property_bag_for_children?: Value<PropertyBags>;
22
+ disable_anim_fast_forward?: Value<boolean>;
23
+ animation_reset_name?: Value<string>;
24
+ grid_position?: Value<Array2<number>>;
22
25
  [key: Binding]: Value<any>;
23
26
  [key: Variable]: Value<any>;
24
27
  }
@@ -0,0 +1,6 @@
1
+ import { Value } from "../value.js";
2
+ export interface Dropdown {
3
+ dropdown_name?: Value<string>;
4
+ dropdown_content_control?: Value<string>;
5
+ dropdown_area?: Value<string>;
6
+ }
@@ -11,4 +11,7 @@ export interface Layout {
11
11
  anchor_from?: Value<string | Anchor>;
12
12
  anchor_to?: Value<string | Anchor>;
13
13
  anchor?: Value<string | Anchor>;
14
+ contained?: Value<boolean>;
15
+ draggable?: Value<boolean>;
16
+ follows_cursor?: Value<boolean>;
14
17
  }
@@ -3,7 +3,7 @@ export interface ScrollView {
3
3
  scrollbar_track_button?: Value<string>;
4
4
  scrollbar_touch_button?: Value<string>;
5
5
  scroll_speed?: Value<number>;
6
- gesture_control_enabled?: Value<number>;
6
+ gesture_control_enabled?: Value<boolean>;
7
7
  always_handle_scrolling?: Value<boolean>;
8
8
  touch_mode?: Value<boolean>;
9
9
  scrollbar_box?: Value<string>;
@@ -2,7 +2,7 @@ import { ButtonId } from "../../enums/ButtonId.js";
2
2
  import { CollectionName } from "../../enums/CollectionName.js";
3
3
  import { Orientation } from "../../enums/Orientation.js";
4
4
  import { SliderName } from "../../enums/SliderName.js";
5
- import { Array3, Value } from "../value.js";
5
+ import { Value } from "../value.js";
6
6
  export interface Slider {
7
7
  slider_track_button?: Value<string>;
8
8
  slider_small_decrease_button?: Value<string | ButtonId>;
@@ -20,10 +20,4 @@ export interface Slider {
20
20
  background_hover_control?: Value<string>;
21
21
  progress_control?: Value<string>;
22
22
  progress_hover_control?: Value<string>;
23
- slider_render_bar_background_color?: Value<Array3<number>>;
24
- slider_render_bar_progress_color?: Value<Array3<number>>;
25
- slider_render_bar_outline_color?: Value<Array3<number>>;
26
- slider_render_bar_background_hover_color?: Value<Array3<number>>;
27
- slider_render_bar_progress_hover_color?: Value<Array3<number>>;
28
- slider_render_bar_outline_hover_color?: Value<Array3<number>>;
29
23
  }
@@ -1,13 +1,14 @@
1
1
  import { ClipDirection } from "../../enums/ClipDirection.js";
2
+ import { TextureFileSystem } from "../enum.js";
2
3
  import { AnimValue, Array2, Array3, Array4, Value } from "../value.js";
3
4
  export interface Sprite {
4
5
  texture?: Value<string>;
5
6
  allow_debug_missing_texture?: Value<boolean>;
6
7
  uv?: AnimValue<Array2<number>>;
7
8
  uv_size?: AnimValue<Array2<number>>;
8
- texture_file_system?: Value<string>;
9
+ texture_file_system?: Value<string | TextureFileSystem>;
9
10
  nineslice_size?: AnimValue<Array2<number> | Array3<number> | Array4<number>>;
10
- tiled?: Value<boolean>;
11
+ tiled?: Value<boolean | "x" | "y">;
11
12
  tiled_scale?: Value<Array<number>>;
12
13
  clip_direction?: Value<string | ClipDirection>;
13
14
  clip_ratio?: Value<number>;
@@ -21,5 +22,4 @@ export interface Sprite {
21
22
  grayscale?: Value<boolean>;
22
23
  force_texture_reload?: Value<boolean>;
23
24
  base_size?: Value<Array2<number>>;
24
- color_corrected?: Value<boolean>;
25
25
  }
@@ -6,7 +6,7 @@ export * from "./Control.js";
6
6
  export * from "./CustomRenderer.js";
7
7
  export * from "./Cycler.js";
8
8
  export * from "./DataBinding.js";
9
- export * from "./DropdownName.js";
9
+ export * from "./Dropdown.js";
10
10
  export * from "./EditBox.js";
11
11
  export * from "./Factory.js";
12
12
  export * from "./Focus.js";
@@ -0,0 +1,13 @@
1
+ export declare enum TextureFileSystem {
2
+ IN_USER_PACKAGE = "InUserPackage",
3
+ IN_APP_PACKAGE = "InAppPackage",
4
+ RAW_PATH = "RawPath",
5
+ RAW_PERSISTENT = "RawPersistent",
6
+ IN_SETTINGS_DIR = "InSettingsDir",
7
+ IN_EXTERNAL_DIR = "InExternalDir",
8
+ IN_SERVER_PACKAGE = "InServerPackage",
9
+ IN_DATA_DIR = "InDataDir",
10
+ IN_USER_DIR = "InUserDir",
11
+ IN_WORLD_DIR = "InWorldDir",
12
+ STORE_CACHE = "StoreCache"
13
+ }
@@ -1,5 +1,6 @@
1
1
  export * as ElementProperties from "./element/index.js";
2
2
  export * as ComponentProperties from "./components.js";
3
3
  export * as Value from "./value.js";
4
+ export * from "./enum.js";
4
5
  export { ArrayName } from "../enums/ArrayName.js";
5
6
  export { Operation } from "../enums/Operation.js";
@@ -13,11 +13,12 @@ import { AnimType } from "../enums/AnimType.js";
13
13
  import { AnimationKeyframe } from "../../components/AnimationKeyframe.js";
14
14
  export type Variable = `$${string}`;
15
15
  export type Binding = `#${string}`;
16
+ export type Control = `@${string}` | `${string}@${string}`;
16
17
  export type Animation = anim.Animation<AnimType> | AnimationKeyframe<AnimType> | `@${string}`;
17
18
  export type Array2<T> = [T, T];
18
19
  export type Array3<T> = [T, T, T];
19
20
  export type Array4<T> = [T, T, T, T];
20
- export type Value<T> = Variable | Binding | T;
21
+ export type Value<T> = Variable | Binding | Control | T;
21
22
  export type AnimValue<T> = Value<T | Animation>;
22
23
  export type BindingItem = {
23
24
  ignored?: Value<boolean>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "asajs",
3
- "version": "4.1.13",
3
+ "version": "4.1.15",
4
4
  "description": "Create your Minecraft JSON-UI resource packs using JavaScript",
5
5
  "keywords": [
6
6
  "Minecraft",