asajs 4.1.10 → 4.1.12

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,6 +50,7 @@ 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);
@@ -57,8 +58,8 @@ 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
60
  export const allowRandomStringName = !(debugMode || !(config.compiler?.allowRandomStringName ?? true));
60
- export const namespaceCount = debugMode ? 5 : (config.compiler?.namespaceCount ?? 15);
61
- export const forceRandomStringLength = debugMode ? 5 : config.compiler?.forceRandomStringLength;
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) {
@@ -167,7 +167,7 @@ export function RandomBindingString(length = 16, base = 32, force) {
167
167
  return `#${StringID}_binding_${rndStrBind++}`;
168
168
  }
169
169
  let rndVarBind = 1;
170
- export function RandomVariableBinding(length = 16, base = 32, force) {
170
+ export function RandomVariableString(length = 16, base = 32, force) {
171
171
  if (force || allowRandomStringName)
172
172
  return `$${GenRandomString(length, base)}`;
173
173
  else
@@ -213,7 +213,7 @@ export function vs(input) {
213
213
  if (rndMap.has(input))
214
214
  return `${rndMap.get(input)}${mode}`;
215
215
  else {
216
- const ret = RandomVariableBinding();
216
+ const ret = RandomVariableString();
217
217
  rndMap.set(input, ret);
218
218
  return `${ret}${mode}`;
219
219
  }
@@ -10,7 +10,7 @@ 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>;
@@ -19,7 +19,7 @@ export declare function GenRandomString(length: number, base?: number): string;
19
19
  export declare function RandomNamespace(): string;
20
20
  export declare function RandomString(length: number, base?: number, force?: boolean): string;
21
21
  export declare function RandomBindingString(length?: number, base?: number, force?: boolean): Binding;
22
- export declare function RandomVariableBinding(length?: number, base?: number, force?: boolean): Variable;
22
+ export declare function RandomVariableString(length?: number, base?: number, force?: boolean): Variable;
23
23
  export declare function s(input: string): string;
24
24
  export declare function bs(input: Binding): Binding;
25
25
  export declare function vs(input: Variable): Variable;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "asajs",
3
- "version": "4.1.10",
3
+ "version": "4.1.12",
4
4
  "description": "Create your Minecraft JSON-UI resource packs using JavaScript",
5
5
  "keywords": [
6
6
  "Minecraft",