asajs 4.1.9 → 4.1.11

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.
@@ -50,15 +50,16 @@ if (!fs.existsSync("asajs.config.js")) {
50
50
  }
51
51
  export const config = createRequire(import.meta.url)(path.resolve(process.cwd(), "asajs.config.js")).config;
52
52
  export const debugMode = options["debug"] ?? false;
53
+ console.log(debugMode);
53
54
  export const isBuildMode = options["build"] ?? config.compiler?.enabled ?? false;
54
55
  export const isLinkMode = options["link"] ?? config.compiler?.autoImport ?? false;
55
56
  export const unLinked = options["unlink"] ?? !(config.compiler?.autoImport ?? true);
56
57
  export const buildFolder = config.compiler?.buildFolder || "build";
57
58
  export const uiBuildFolder = config.compiler?.uiBuildFolder || "asajs";
58
59
  export const isNotObfuscate = debugMode || !(config.compiler?.obfuscateStringName ?? false);
59
- export const allowRandomStringName = !debugMode || (config.compiler?.allowRandomStringName ?? true);
60
- export const namespaceCount = debugMode ? 5 : (config.compiler?.namespaceCount ?? 15);
61
- export const forceRandomStringLength = debugMode ? 10 : config.compiler?.forceRandomStringLength;
60
+ export const allowRandomStringName = !(debugMode || !(config.compiler?.allowRandomStringName ?? true));
61
+ export const namespaceCount = config.compiler?.namespaceCount ?? 15;
62
+ export const forceRandomStringLength = config.compiler?.forceRandomStringLength;
62
63
  export const bindingFuntions = config.binding_functions;
63
64
  if (!fs.existsSync(".gitignore")) {
64
65
  fs.writeFileSync(".gitignore", "node_modules\ncustom", "utf-8");
@@ -1,8 +1,15 @@
1
+ import { config, isNotObfuscate, uiBuildFolder } from "../compilers/Configuration.js";
1
2
  import { FormatAnimationProperties } from "../compilers/FormatProperties.js";
2
3
  import { Memory } from "../compilers/Memory.js";
3
4
  import { Class } from "./Class.js";
4
- import { RandomNamespace, RandomString } from "./Utils.js";
5
+ import { defaultNamespace, RandomNamespace, RandomString } from "./Utils.js";
6
+ import nodepath from "path";
5
7
  import util from "node:util";
8
+ const fileExt = config.compiler?.fileExtension
9
+ ? config.compiler.fileExtension.startsWith(".")
10
+ ? config.compiler.fileExtension
11
+ : `.${config.compiler.fileExtension}`
12
+ : ".json";
6
13
  export class AnimationKeyframe extends Class {
7
14
  type;
8
15
  properties;
@@ -10,7 +17,7 @@ export class AnimationKeyframe extends Class {
10
17
  name;
11
18
  namespace;
12
19
  extend;
13
- constructor(type, properties, name, namespace, path) {
20
+ constructor(type, properties, name, namespace, path, allowObfuscate) {
14
21
  super();
15
22
  this.type = type;
16
23
  this.properties = properties;
@@ -18,13 +25,18 @@ export class AnimationKeyframe extends Class {
18
25
  console.error("The 'namespace' cannot be used as a name");
19
26
  process.exit(1);
20
27
  }
21
- if (namespace && !/^\w+$/.test(namespace)) {
22
- console.error(`The '${namespace}' cannot be used as a namespace`);
23
- process.exit(1);
28
+ if (isNotObfuscate || !(allowObfuscate ?? true)) {
29
+ this.name = name?.match(/^(\w|\/)+/)?.[0] || RandomString(16);
30
+ this.namespace = namespace || defaultNamespace || RandomNamespace();
31
+ }
32
+ else {
33
+ this.name = RandomString(16);
34
+ this.namespace = RandomNamespace();
24
35
  }
25
- this.name = name || RandomString(16);
26
- this.namespace = namespace || RandomNamespace();
27
- this.path = path || `asajs/${this.namespace}.json`;
36
+ if (!path)
37
+ this.path = nodepath.join(uiBuildFolder, `${this.namespace}${fileExt}`);
38
+ else
39
+ this.path = path;
28
40
  Memory.add(this);
29
41
  }
30
42
  setNext(keyframe) {
@@ -171,7 +171,7 @@ export function RandomVariableBinding(length = 16, base = 32, force) {
171
171
  if (force || allowRandomStringName)
172
172
  return `$${GenRandomString(length, base)}`;
173
173
  else
174
- return `$${StringID}_binding_${rndVarBind++}`;
174
+ return `$${StringID}_variable_${rndVarBind++}`;
175
175
  }
176
176
  const rndMap = new Map();
177
177
  export function s(input) {
@@ -10,13 +10,13 @@ export declare class AnimationKeyframe<T extends AnimType> extends Class {
10
10
  readonly name: string;
11
11
  readonly namespace: string;
12
12
  readonly extend?: AnimationKeyframe<T> | Animation<T>;
13
- constructor(type: T, properties: KeyframeAnimationProperties<T>, name?: string, namespace?: string, path?: string);
13
+ constructor(type: T, properties: KeyframeAnimationProperties<T>, name?: string, namespace?: string, path?: string, allowObfuscate?: boolean);
14
14
  setNext(keyframe: AnimationKeyframe<AnimType>): this;
15
15
  clearNext(): this;
16
16
  protected toJsonUI(): KeyframeAnimationProperties<AnimType>;
17
17
  protected toJSON(): (Partial<import("../types/properties/element/Animation.js").DurationAnimation> & import("../types/properties/element/Animation.js").KeyframeAnimationPropertiesItem) | (Partial<import("../types/properties/element/Animation.js").AsepriteFlipBookAnimation> & import("../types/properties/element/Animation.js").KeyframeAnimationPropertiesItem) | {
18
- from?: import("../types/properties/value.js").Array2<string | number> | undefined;
19
- to?: import("../types/properties/value.js").Array2<string | number> | undefined;
18
+ from?: import("../types/properties/value.js").Value<number> | undefined;
19
+ to?: import("../types/properties/value.js").Value<number> | undefined;
20
20
  duration?: import("../types/properties/value.js").Value<number> | undefined;
21
21
  easing?: import("../types/properties/value.js").Value<string | import("../index.js").Easing> | undefined;
22
22
  next?: import("../types/properties/value.js").Value<string | AnimationKeyframe<AnimType> | Animation<AnimType>>;
@@ -33,8 +33,8 @@ export declare class AnimationKeyframe<T extends AnimType> extends Class {
33
33
  wait_until_rendered_to_play?: import("../types/properties/value.js").Value<boolean>;
34
34
  anim_type: T;
35
35
  } | {
36
- from?: import("../types/properties/value.js").Value<number> | undefined;
37
- to?: import("../types/properties/value.js").Value<number> | undefined;
36
+ from?: import("../types/properties/value.js").Array2<string | number> | undefined;
37
+ to?: import("../types/properties/value.js").Array2<string | number> | undefined;
38
38
  duration?: import("../types/properties/value.js").Value<number> | undefined;
39
39
  easing?: import("../types/properties/value.js").Value<string | import("../index.js").Easing> | undefined;
40
40
  next?: import("../types/properties/value.js").Value<string | AnimationKeyframe<AnimType> | Animation<AnimType>>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "asajs",
3
- "version": "4.1.9",
3
+ "version": "4.1.11",
4
4
  "description": "Create your Minecraft JSON-UI resource packs using JavaScript",
5
5
  "keywords": [
6
6
  "Minecraft",