asajs 4.0.0-indev-2 → 4.0.0-indev-3

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.
Files changed (34) hide show
  1. package/config.d.ts +26 -0
  2. package/dist/js/compilers/Configuration.js +20 -1
  3. package/dist/js/compilers/bindings/Checker.js +9 -0
  4. package/dist/js/compilers/bindings/Function.js +71 -0
  5. package/dist/js/compilers/bindings/Funtion.js +30 -6
  6. package/dist/js/compilers/bindings/Lexer.js +49 -6
  7. package/dist/js/compilers/bindings/Parser.js +152 -12
  8. package/dist/js/compilers/ui/builder.js +17 -11
  9. package/dist/js/compilers/ui/linker.js +12 -3
  10. package/dist/js/compilers/ui/manifest.js +7 -4
  11. package/dist/js/compilers/ui/prevdata.js +1 -1
  12. package/dist/js/components/AnimationKeyframe.js +1 -1
  13. package/dist/js/components/UI.js +4 -3
  14. package/dist/js/components/Utils.js +83 -20
  15. package/dist/js/config..js +1 -0
  16. package/dist/js/config.js +1 -0
  17. package/dist/js/index.js +3 -0
  18. package/dist/js/types/config.js +1 -0
  19. package/dist/types/compilers/Configuration.d.ts +5 -1
  20. package/dist/types/compilers/bindings/Checker.d.ts +3 -0
  21. package/dist/types/compilers/bindings/Function.d.ts +7 -0
  22. package/dist/types/compilers/bindings/Funtion.d.ts +1 -1
  23. package/dist/types/compilers/bindings/Parser.d.ts +12 -3
  24. package/dist/types/compilers/ui/linker.d.ts +1 -0
  25. package/dist/types/components/AnimationKeyframe.d.ts +4 -4
  26. package/dist/types/components/UI.d.ts +1 -0
  27. package/dist/types/components/Utils.d.ts +16 -16
  28. package/dist/types/config..d.ts +2 -0
  29. package/dist/types/config.d.ts +13 -0
  30. package/dist/types/index.d.ts +3 -0
  31. package/dist/types/types/config.d.ts +13 -0
  32. package/dist/types/types/enums/index.d.ts +0 -1
  33. package/package.json +1 -1
  34. package/resources/asajs.config.cjs +14 -0
package/config.d.ts ADDED
@@ -0,0 +1,26 @@
1
+ import { Variable } from "./src/types/properties/value.ts"
2
+
3
+ export interface Config {
4
+ compiler?: {
5
+ enabled?: boolean
6
+ linked?: boolean
7
+ }
8
+ packinfo?: {
9
+ name?: string
10
+ description?: string
11
+ version?: [number, number, number]
12
+
13
+ metadata?: {
14
+ authors?: string[]
15
+ license?: string
16
+ url?: string
17
+ }
18
+
19
+ subpacks?: {
20
+ folder_name?: string
21
+ name?: string
22
+ memory_performance_tier?: number
23
+ }[]
24
+ }
25
+ global_variables?: Record<Variable, string>
26
+ }
@@ -1 +1,20 @@
1
- export const isBuildMode = process.argv.includes("--build");
1
+ import fs from "fs";
2
+ import path from "path";
3
+ if (!fs.existsSync("asajs.config.cjs")) {
4
+ fs.copyFileSync("node_modules/asajs/resources/asajs.config.cjs", "asajs.config.cjs");
5
+ }
6
+ if (!fs.existsSync(".gitignore")) {
7
+ fs.writeFileSync(".gitignore", `node_modules`, "utf-8");
8
+ }
9
+ export const config = require(path.resolve(process.cwd(), "asajs.config.cjs")).config;
10
+ export let isBuildMode = config.compiler?.enabled ?? false;
11
+ export let isLinkMode = config.compiler?.linked ?? false;
12
+ export let unLinked = !(config.compiler?.linked ?? true);
13
+ for (const arg of process.argv) {
14
+ if (arg === "--build")
15
+ isBuildMode = true;
16
+ if (arg === "--link")
17
+ isLinkMode = true;
18
+ else if (arg === "--unlink")
19
+ unLinked = true;
20
+ }
@@ -7,6 +7,15 @@ export function isWordChar(char) {
7
7
  export function isNumberChar(char) {
8
8
  return /\d/.test(char);
9
9
  }
10
+ export function isHexChar(char) {
11
+ return /[0-9a-fA-F]/.test(char);
12
+ }
13
+ export function isBinaryChar(char) {
14
+ return /[01]/.test(char);
15
+ }
16
+ export function isOctalChar(char) {
17
+ return /[0-7]/.test(char);
18
+ }
10
19
  export function isCompileBinding(input) {
11
20
  return input.startsWith("[") && input.endsWith("]");
12
21
  }
@@ -0,0 +1,71 @@
1
+ import { RandomBindingString } from "../../components/Utils.js";
2
+ import { Parser } from "./Parser.js";
3
+ export const FunctionMap = new Map();
4
+ function callFn(name, ...args) {
5
+ return FunctionMap.get(name)(...args);
6
+ }
7
+ // Default Functions
8
+ FunctionMap.set("abs", number => {
9
+ const randomBinding = RandomBindingString(16);
10
+ return {
11
+ genBindings: [{ source: `((-1 + (${number} > 0) * 2) * ${number})`, target: randomBinding }],
12
+ value: randomBinding,
13
+ };
14
+ });
15
+ FunctionMap.set("new", expression => {
16
+ const randomBinding = RandomBindingString(16);
17
+ return {
18
+ genBindings: [{ source: expression, target: randomBinding }],
19
+ value: randomBinding,
20
+ };
21
+ });
22
+ FunctionMap.set("sqrt", number => {
23
+ const rtn = RandomBindingString(16), $1 = RandomBindingString(16), $2 = RandomBindingString(16);
24
+ const { genBindings: absValue, value: absRtn } = callFn("abs", number);
25
+ return {
26
+ genBindings: [
27
+ {
28
+ source: `${number} * 100 / 2`,
29
+ target: $1,
30
+ },
31
+ ...absValue,
32
+ {
33
+ source: `${absRtn} > 1`,
34
+ target: $2,
35
+ },
36
+ {
37
+ source: `(${number} < 0) * -1 + (${number} > -1) * (${$2} * ((${rtn} + ${number} / ${rtn}) / 2) + (not ${$2}) * ${rtn})`,
38
+ target: rtn,
39
+ },
40
+ ],
41
+ value: rtn,
42
+ };
43
+ });
44
+ FunctionMap.set("translatable", key => {
45
+ return {
46
+ value: `'%' + ${key}`,
47
+ };
48
+ });
49
+ FunctionMap.set("bin", input => {
50
+ const { ret, bindings } = Parser.intToBin(input);
51
+ bindings.push({
52
+ source: `'§z' + ${Array.from({ length: 30 }, (_, i) => `${ret}${30 - i - 1}`).join(" + ")}`,
53
+ target: ret,
54
+ });
55
+ return { genBindings: bindings, value: ret };
56
+ });
57
+ FunctionMap.set("bind", (value, bait) => {
58
+ const ret = RandomBindingString(16);
59
+ if (!bait) {
60
+ throw new Error("Bait is required");
61
+ }
62
+ return {
63
+ genBindings: [{ source: `((${bait} - ${bait}) + ${value})`, target: ret }],
64
+ value: ret,
65
+ };
66
+ });
67
+ FunctionMap.set("int", input => {
68
+ return {
69
+ value: input,
70
+ };
71
+ });
@@ -1,24 +1,25 @@
1
1
  import { RandomBindingString } from "../../components/Utils.js";
2
- export const FuntionMap = new Map();
2
+ import { Parser } from "./Parser.js";
3
+ export const FunctionMap = new Map();
3
4
  function callFn(name, ...args) {
4
- return FuntionMap.get(name)(...args);
5
+ return FunctionMap.get(name)(...args);
5
6
  }
6
7
  // Default Functions
7
- FuntionMap.set("abs", number => {
8
+ FunctionMap.set("abs", number => {
8
9
  const randomBinding = RandomBindingString(16);
9
10
  return {
10
11
  genBindings: [{ source: `((-1 + (${number} > 0) * 2) * ${number})`, target: randomBinding }],
11
12
  value: randomBinding,
12
13
  };
13
14
  });
14
- FuntionMap.set("new", expression => {
15
+ FunctionMap.set("new", expression => {
15
16
  const randomBinding = RandomBindingString(16);
16
17
  return {
17
18
  genBindings: [{ source: expression, target: randomBinding }],
18
19
  value: randomBinding,
19
20
  };
20
21
  });
21
- FuntionMap.set("sqrt", number => {
22
+ FunctionMap.set("sqrt", number => {
22
23
  const rtn = RandomBindingString(16), $1 = RandomBindingString(16), $2 = RandomBindingString(16);
23
24
  const { genBindings: absValue, value: absRtn } = callFn("abs", number);
24
25
  return {
@@ -40,8 +41,31 @@ FuntionMap.set("sqrt", number => {
40
41
  value: rtn,
41
42
  };
42
43
  });
43
- FuntionMap.set("translatable", key => {
44
+ FunctionMap.set("translatable", key => {
44
45
  return {
45
46
  value: `'%' + ${key}`,
46
47
  };
47
48
  });
49
+ FunctionMap.set("bin", input => {
50
+ const { ret, bindings } = Parser.intToBin(input);
51
+ bindings.push({
52
+ source: `'§z' + ${Array.from({ length: 30 }, (_, i) => `${ret}${30 - i - 1}`).join(" + ")}`,
53
+ target: ret,
54
+ });
55
+ return { genBindings: bindings, value: ret };
56
+ });
57
+ FunctionMap.set("bind", (value, bait) => {
58
+ const ret = RandomBindingString(16);
59
+ if (!bait) {
60
+ throw new Error("Bait is required");
61
+ }
62
+ return {
63
+ genBindings: [{ source: `((${bait} - ${bait}) + ${value})`, target: ret }],
64
+ value: ret,
65
+ };
66
+ });
67
+ FunctionMap.set("int", input => {
68
+ return {
69
+ value: input,
70
+ };
71
+ });
@@ -39,6 +39,7 @@ export function Lexer(input, start = 0, end) {
39
39
  case "*":
40
40
  case "/":
41
41
  case "%":
42
+ case "^":
42
43
  tokens.push(makeToken(input, TokenKind.OPERATOR, index));
43
44
  break;
44
45
  case "(":
@@ -53,18 +54,24 @@ export function Lexer(input, start = 0, end) {
53
54
  case "=":
54
55
  if (input[index + 1] === input[index])
55
56
  tokens.push(makeToken(input, TokenKind.OPERATOR, index++, 2));
56
- else {
57
- console.error(`\x1b[31merror: ${input + "\n" + " ".repeat(index + 7) + "^"}\nInvalid character.\x1b[0m`);
58
- throw new Error();
59
- }
57
+ else
58
+ tokens.push(makeToken(input, TokenKind.OPERATOR, index));
60
59
  break;
61
60
  case "!":
62
61
  case ">":
63
62
  case "<":
64
63
  if (input[index + 1] === "=")
65
64
  tokens.push(makeToken(input, TokenKind.OPERATOR, index++, 2));
66
- else
67
- tokens.push(makeToken(input, TokenKind.OPERATOR, index));
65
+ else {
66
+ if (input[index] === input[index + 1]) {
67
+ if (input[index] !== "!")
68
+ tokens.push(makeToken(input, TokenKind.OPERATOR, index++, 2));
69
+ else
70
+ tokens.push(makeToken(input, TokenKind.OPERATOR, index));
71
+ }
72
+ else
73
+ tokens.push(makeToken(input, TokenKind.OPERATOR, index));
74
+ }
68
75
  break;
69
76
  // string
70
77
  case "'": {
@@ -168,6 +175,42 @@ export function Lexer(input, start = 0, end) {
168
175
  default: {
169
176
  let start = index;
170
177
  if (Checker.isNumberChar(token)) {
178
+ if (token === "0") {
179
+ const numType = input[index + 1];
180
+ if (numType === "x") {
181
+ index += 2;
182
+ while (Checker.isHexChar(input[index + 1]))
183
+ index++;
184
+ if (start + 2 === index) {
185
+ console.error(`\x1b[31merror: ${input + "\n" + " ".repeat(index + 6) + "^"}\nInvalid character.\x1b[0m`);
186
+ throw new Error();
187
+ }
188
+ tokens.push(makeToken(input, TokenKind.NUMBER, start, index - start + 1));
189
+ break;
190
+ }
191
+ else if (numType === "b") {
192
+ index += 2;
193
+ while (Checker.isBinaryChar(input[index + 1]))
194
+ index++;
195
+ tokens.push(makeToken(input, TokenKind.NUMBER, start, index - start + 1));
196
+ if (start + 2 === index) {
197
+ console.error(`\x1b[31merror: ${input + "\n" + " ".repeat(index + 6) + "^"}\nInvalid character.\x1b[0m`);
198
+ throw new Error();
199
+ }
200
+ break;
201
+ }
202
+ else if (numType === "o") {
203
+ index += 2;
204
+ while (Checker.isOctalChar(input[index + 1]))
205
+ index++;
206
+ tokens.push(makeToken(input, TokenKind.NUMBER, start, index - start + 1));
207
+ if (start + 2 === index) {
208
+ console.error(`\x1b[31merror: ${input + "\n" + " ".repeat(index + 6) + "^"}\nInvalid character.\x1b[0m`);
209
+ throw new Error();
210
+ }
211
+ break;
212
+ }
213
+ }
171
214
  while (Checker.isNumberChar(input[index + 1]))
172
215
  index++;
173
216
  if (input[index + 1] === "e") {
@@ -1,21 +1,55 @@
1
1
  import { TokenKind, TSTokenKind } from "./types.js";
2
2
  import { BindingType } from "../../types/enums/BindingType.js";
3
- import { FuntionMap } from "./Funtion.js";
3
+ import { FunctionMap } from "./Function.js";
4
4
  import { Lexer } from "./Lexer.js";
5
+ import { RandomBindingString } from "../../components/Utils.js";
5
6
  export class Parser {
6
7
  input;
8
+ cache;
7
9
  position = 0;
8
- tokens;
9
10
  genBindings = [];
10
11
  output;
11
- constructor(input) {
12
+ tokens;
13
+ constructor(input, cache = new Map(), tokens) {
12
14
  this.input = input;
13
- this.tokens = Lexer(this.input);
15
+ this.cache = cache;
16
+ if (tokens) {
17
+ this.tokens = tokens;
18
+ tokens = undefined;
19
+ }
20
+ else
21
+ this.tokens = Lexer(input);
14
22
  this.output = this.parseExpression();
15
23
  if (this.at()) {
16
24
  this.expect(TokenKind.EOF, "Unexpected token!");
17
25
  }
18
26
  }
27
+ static intToBin(input) {
28
+ const bindings = [];
29
+ const rtn = RandomBindingString(16);
30
+ for (let i = 0; i < 30; i++) {
31
+ bindings.push({
32
+ source: `(${input} / ${2 ** i} - (${input} / ${2 ** (i + 1)}) * 2)`,
33
+ target: `${rtn}${i}`,
34
+ });
35
+ }
36
+ return {
37
+ ret: rtn,
38
+ bindings,
39
+ };
40
+ }
41
+ intToBin(input) {
42
+ const inStr = `expr:${input}`;
43
+ if (this.cache.has(inStr)) {
44
+ return this.cache.get(inStr);
45
+ }
46
+ else {
47
+ const { ret, bindings } = Parser.intToBin(input);
48
+ this.cache.set(inStr, ret);
49
+ this.genBindings.push(...bindings);
50
+ return ret;
51
+ }
52
+ }
19
53
  at() {
20
54
  return this.tokens[this.position];
21
55
  }
@@ -81,19 +115,106 @@ export class Parser {
81
115
  return left;
82
116
  }
83
117
  parseMultiplicativeExpression() {
84
- let left = this.parsePrimaryExpression(), current;
118
+ let left = this.parseBitwiseLogicExpression(), current;
85
119
  while ((current = this.at()) &&
86
120
  this.at()?.kind === TokenKind.OPERATOR &&
87
121
  ["*", "/", "%"].includes(current.value)) {
88
122
  const operator = this.eat();
89
123
  const right = this.parsePrimaryExpression();
90
- if (current.value === "%")
91
- left = `(${left} - (${left} / ${right} * ${right}))`;
124
+ if (current.value === "%") {
125
+ const cacheStr = `expr:${left}${operator.value}${right}`;
126
+ if (this.cache.has(cacheStr)) {
127
+ return (left = this.cache.get(cacheStr));
128
+ }
129
+ const ret = RandomBindingString(16);
130
+ this.genBindings.push({
131
+ source: `(${left} - (${left} / ${right} * ${right}))`,
132
+ target: ret,
133
+ });
134
+ this.cache.set(cacheStr, ret);
135
+ left = ret;
136
+ }
92
137
  else
93
138
  left = `(${left} ${operator.value} ${right})`;
94
139
  }
95
140
  return left;
96
141
  }
142
+ parseBitwiseLogicExpression() {
143
+ let left = this.parseBitwiseShiftExpression(), current;
144
+ while ((current = this.at()) &&
145
+ this.at()?.kind === TokenKind.OPERATOR &&
146
+ ["&", "|", "^"].includes(current.value)) {
147
+ const operator = this.eat();
148
+ const right = this.parsePrimaryExpression();
149
+ const cacheStr = `expr:${left}${operator.value}${right}`;
150
+ if (this.cache.has(cacheStr)) {
151
+ return (left = this.cache.get(cacheStr));
152
+ }
153
+ const ret = RandomBindingString(16);
154
+ this.cache.set(cacheStr, ret);
155
+ const leftBin = this.intToBin(left);
156
+ const rightBin = this.intToBin(right);
157
+ if (operator.value === "&") {
158
+ this.genBindings.push(...Array.from({ length: 30 }, (_, i) => {
159
+ return {
160
+ source: `(${leftBin}${i} * ${rightBin}${i})`,
161
+ target: `${ret}${i}`,
162
+ };
163
+ }));
164
+ }
165
+ else if (operator.value === "|") {
166
+ this.genBindings.push(...Array.from({ length: 30 }, (_, i) => {
167
+ return {
168
+ source: `(${leftBin}${i} + ${rightBin}${i} - (${leftBin}${i} * ${rightBin}${i}))`,
169
+ target: `${ret}${i}`,
170
+ };
171
+ }));
172
+ }
173
+ else {
174
+ this.genBindings.push(...Array.from({ length: 30 }, (_, i) => {
175
+ return {
176
+ source: `(${leftBin}${i} + ${rightBin}${i} - 2 * (${leftBin}${i} * ${rightBin}${i}))`,
177
+ target: `${ret}${i}`,
178
+ };
179
+ }));
180
+ }
181
+ this.genBindings.push({
182
+ source: `(${Array.from({ length: 30 }, (_, i) => `(${ret}${i} * ${2 ** i})`).join(" + ")})`,
183
+ target: ret,
184
+ });
185
+ left = ret;
186
+ }
187
+ return left;
188
+ }
189
+ parseBitwiseShiftExpression() {
190
+ let left = this.parsePrimaryExpression(), current;
191
+ while ((current = this.at()) &&
192
+ this.at()?.kind === TokenKind.OPERATOR &&
193
+ [">>", "<<"].includes(current.value)) {
194
+ const operator = this.eat();
195
+ const right = this.parsePrimaryExpression();
196
+ const cacheStr = `expr:${left}${operator.value}${right}`;
197
+ if (this.cache.has(cacheStr)) {
198
+ return (left = this.cache.get(cacheStr));
199
+ }
200
+ const ret = RandomBindingString(16);
201
+ this.cache.set(cacheStr, ret);
202
+ const leftBind = this.intToBin(left);
203
+ const op = operator.value === "<<" ? "-" : "+";
204
+ this.genBindings.push(...Array.from({ length: 30 }, (_, i) => {
205
+ return {
206
+ source: `((0 * ${left}) + ('${leftBind}' + (${i} ${op} ${right})))`,
207
+ target: `${ret}${i}`,
208
+ };
209
+ }));
210
+ this.genBindings.push({
211
+ source: `(${Array.from({ length: 30 }, (_, i) => `(${ret}${i} * ${2 ** i})`).join(" + ")})`,
212
+ target: ret,
213
+ });
214
+ left = ret;
215
+ }
216
+ return left;
217
+ }
97
218
  parsePrimaryExpression() {
98
219
  const left = this.at();
99
220
  switch (left?.kind) {
@@ -107,8 +228,18 @@ export class Parser {
107
228
  return `(${value})`;
108
229
  }
109
230
  case TokenKind.NUMBER: {
110
- const [num, exp] = this.eat().value.split("e");
111
- return "" + (exp ? +num * 10 ** +exp : num);
231
+ const numberToken = this.eat();
232
+ switch (numberToken.value[1]) {
233
+ case "x":
234
+ return "" + parseInt(numberToken.value.slice(2), 16);
235
+ case "o":
236
+ return "" + parseInt(numberToken.value.slice(2), 8);
237
+ case "b":
238
+ return "" + parseInt(numberToken.value.slice(2), 2);
239
+ default:
240
+ const [num, exp] = numberToken.value.split("e");
241
+ return "" + (exp ? +num * 10 ** +exp : num);
242
+ }
112
243
  }
113
244
  case TokenKind.VARIABLE:
114
245
  case TokenKind.STRING:
@@ -184,7 +315,15 @@ export class Parser {
184
315
  }
185
316
  }
186
317
  this.eat();
187
- return this.funtionCall(callerToken.value, ...args);
318
+ const inputStr = `func:${callerToken.value}(${args.join(", ")})`;
319
+ if (this.cache.has(inputStr)) {
320
+ return this.cache.get(inputStr);
321
+ }
322
+ else {
323
+ const ret = this.functionCall(callerToken.value, ...args);
324
+ this.cache.set(inputStr, ret);
325
+ return ret;
326
+ }
188
327
  }
189
328
  else if (left?.kind === TokenKind.OPERATOR) {
190
329
  this.warn(`Implicit string literal '${callerToken.value}'. Use quoted string ('${callerToken.value}') for clarity!`, callerToken);
@@ -198,8 +337,8 @@ export class Parser {
198
337
  return callerToken.value;
199
338
  }
200
339
  }
201
- funtionCall(name, ...params) {
202
- const func = FuntionMap.get(name.toLowerCase());
340
+ functionCall(name, ...params) {
341
+ const func = FunctionMap.get(name.toLowerCase());
203
342
  if (!func) {
204
343
  return this.expect(TokenKind.WORD, "Function not found!");
205
344
  }
@@ -226,6 +365,7 @@ export class Parser {
226
365
  out() {
227
366
  return {
228
367
  out: `(${this.output})`,
368
+ cache: this.cache,
229
369
  gen: this.genBindings.map(({ source, target }) => ({
230
370
  binding_type: BindingType.VIEW,
231
371
  source_property_name: `(${source})`,
@@ -1,18 +1,18 @@
1
- import { isBuildMode } from "../Configuration.js";
1
+ import { config, isBuildMode, isLinkMode, unLinked } from "../Configuration.js";
2
2
  import { Memory } from "../Memory.js";
3
- import { createBuildFolder, linkToGame } from "./linker.js";
3
+ import { createBuildFolder, linkToGame, unlink } from "./linker.js";
4
4
  import { genManifest } from "./manifest.js";
5
5
  import fs from "fs/promises";
6
+ import { BuildCache } from "./buildcache.js";
6
7
  async function buildUI() {
7
8
  const build = Memory.build();
8
9
  build.set("ui/_ui_defs.json", {
9
10
  ui_defs: Array.from(build.keys()),
10
11
  });
11
- build.set("build.json", {
12
- files: Array.from(build.keys()),
13
- });
12
+ if (config.global_variables)
13
+ build.set("ui/_global_variables.json", config.global_variables);
14
14
  const out = await Promise.all(build.entries().map(async ([file, value]) => {
15
- const outFile = `build/build/${file}`;
15
+ const outFile = `build/${file}`;
16
16
  await fs
17
17
  .stat(outFile.split(/\\|\//g).slice(0, -1).join("/"))
18
18
  .catch(async () => await fs.mkdir(outFile.split(/\\|\//g).slice(0, -1).join("/"), { recursive: true }));
@@ -24,11 +24,12 @@ async function buildUI() {
24
24
  return file;
25
25
  }));
26
26
  await Promise.all([
27
- fs.writeFile("build/build/manifest.json", await genManifest(), "utf-8"),
28
- fs.writeFile("build/build/.gitignore", [...out, "manifest.json"].join("\n"), "utf-8"),
27
+ fs.writeFile("build/manifest.json", await genManifest(), "utf-8"),
28
+ fs.writeFile("build/.gitignore", [...out, "manifest.json"].join("\n"), "utf-8"),
29
+ BuildCache.set("build-files", [...out, "manifest.json"]),
29
30
  fs
30
- .stat("build/build/pack_icon.png")
31
- .catch(() => fs.copyFile("node_modules/asajs/resources/pack_icon.png", "build/build/pack_icon.png")),
31
+ .stat("build/pack_icon.png")
32
+ .catch(() => fs.copyFile("node_modules/asajs/resources/pack_icon.png", "build/pack_icon.png")),
32
33
  ]);
33
34
  return out.length;
34
35
  }
@@ -38,8 +39,13 @@ if (isBuildMode) {
38
39
  if (first) {
39
40
  await createBuildFolder();
40
41
  await buildUI();
41
- await linkToGame();
42
+ if (isLinkMode)
43
+ await linkToGame();
42
44
  }
43
45
  first = false;
44
46
  });
45
47
  }
48
+ else if (isLinkMode)
49
+ linkToGame();
50
+ else if (unLinked)
51
+ unlink();
@@ -1,7 +1,6 @@
1
1
  import fs from "fs/promises";
2
2
  import { BuildCache } from "./buildcache.js";
3
3
  import { RandomString } from "../../components/Utils.js";
4
- import { prevData } from "./prevdata.js";
5
4
  import path from "path";
6
5
  import { getGamedataPath } from "./installer.js";
7
6
  const HEX = Array.from({ length: 256 }, (_, i) => i.toString(16).padStart(2, "0"));
@@ -18,7 +17,8 @@ function genUUID() {
18
17
  `${HEX[b[10]]}${HEX[b[11]]}${HEX[b[12]]}${HEX[b[13]]}${HEX[b[14]]}${HEX[b[15]]}`);
19
18
  }
20
19
  export async function clearBuild() {
21
- await Promise.all(prevData.files.map(file => fs.rm(`build/build/${file}`).catch(() => null)));
20
+ const files = (await BuildCache.get("build-files")) || [];
21
+ await Promise.all(files.map(file => fs.rm(`build/${file}`).catch(() => null)));
22
22
  }
23
23
  export async function createBuildFolder() {
24
24
  return fs
@@ -30,12 +30,21 @@ export async function getBuildFolderName() {
30
30
  return await BuildCache.getWithSetDefault("build-key", () => RandomString(16));
31
31
  }
32
32
  export async function linkToGame() {
33
- const sourcePath = path.resolve("build/build");
33
+ const sourcePath = path.resolve("build");
34
34
  const targetPath = path.resolve(getGamedataPath(), "development_resource_packs", await getBuildFolderName());
35
35
  await fs.stat(targetPath).catch(async () => {
36
36
  await fs.symlink(sourcePath, targetPath, "junction");
37
37
  });
38
38
  }
39
+ export async function unlink() {
40
+ const targetPath = path.resolve(getGamedataPath(), "development_resource_packs", await getBuildFolderName());
41
+ try {
42
+ await fs.unlink(targetPath);
43
+ }
44
+ catch (error) {
45
+ console.error(error);
46
+ }
47
+ }
39
48
  export async function getUUID() {
40
49
  return await BuildCache.getWithSetDefault("uuid", () => {
41
50
  return [genUUID(), genUUID()];
@@ -1,14 +1,15 @@
1
+ import { config } from "../Configuration.js";
1
2
  import { getUUID } from "./linker.js";
2
3
  export async function genManifest() {
3
4
  const [uuid1, uuid2] = await getUUID();
4
5
  return JSON.stringify({
5
6
  format_version: 2,
6
7
  header: {
7
- name: "AsaJS UI",
8
- description: "A framework for creating UIs for AsaJS.",
8
+ name: config.packinfo?.name || "AsaJS",
9
+ description: config.packinfo?.description || "Create your Minecraft JSON-UI resource packs using JavaScript.",
9
10
  uuid: uuid1,
10
- version: [4, 0, 0],
11
- min_engine_version: [1, 21, 132],
11
+ version: config.packinfo?.version || [4, 0, 0],
12
+ min_engine_version: [1, 21, 80],
12
13
  },
13
14
  modules: [
14
15
  {
@@ -18,5 +19,7 @@ export async function genManifest() {
18
19
  version: [4, 0, 0],
19
20
  },
20
21
  ],
22
+ subpacks: config.packinfo?.subpacks,
23
+ metadata: config.packinfo?.metadata,
21
24
  });
22
25
  }
@@ -1,7 +1,7 @@
1
1
  import fs from "fs";
2
2
  export let prevData;
3
3
  try {
4
- prevData = JSON.parse(fs.readFileSync("build/build/build.json", "utf-8"));
4
+ prevData = JSON.parse(fs.readFileSync("build/build.json", "utf-8"));
5
5
  }
6
6
  catch (error) {
7
7
  prevData = { files: [] };
@@ -25,7 +25,7 @@ export class AnimationKeyframe extends Class {
25
25
  }
26
26
  this.name = name || RandomString(16);
27
27
  this.namespace = namespace || RandomNamespace();
28
- this.path = path || `@/${this.namespace}.json`;
28
+ this.path = path || `asajs/${this.namespace}.json`;
29
29
  Memory.add(this);
30
30
  }
31
31
  setNext(keyframe) {
@@ -20,6 +20,7 @@ export class UI extends Class {
20
20
  anims = [];
21
21
  extendType;
22
22
  properties = {};
23
+ bindCache = new Map();
23
24
  constructor(type, name, namespace, path) {
24
25
  super();
25
26
  this.type = type;
@@ -55,7 +56,7 @@ export class UI extends Class {
55
56
  * @returns
56
57
  */
57
58
  addBindings(...bindings) {
58
- this.bindings.push(...ResolveBinding(...bindings));
59
+ this.bindings.push(...ResolveBinding(this.bindCache, ...bindings));
59
60
  return this;
60
61
  }
61
62
  /**
@@ -270,14 +271,14 @@ export class ModifyUI extends UI {
270
271
  return this.addModifications({
271
272
  array_name: ArrayName.BINDINGS,
272
273
  operation: Operation.INSERT_BACK,
273
- value: ResolveBinding(...bindings),
274
+ value: ResolveBinding(this.bindCache, ...bindings),
274
275
  });
275
276
  }
276
277
  insertFrontBindings(...bindings) {
277
278
  return this.addModifications({
278
279
  array_name: ArrayName.BINDINGS,
279
280
  operation: Operation.INSERT_FRONT,
280
- value: ResolveBinding(...bindings),
281
+ value: ResolveBinding(this.bindCache, ...bindings),
281
282
  });
282
283
  }
283
284
  insertBindings(...bindings) {
@@ -9,6 +9,8 @@ import { AnimType } from "../types/enums/AnimType.js";
9
9
  import { AnimationKeyframe } from "./AnimationKeyframe.js";
10
10
  import { Animation } from "./Animation.js";
11
11
  import { MemoryModify } from "../compilers/Memory.js";
12
+ import { Lexer } from "../compilers/bindings/Lexer.js";
13
+ import { TokenKind, TSTokenKind } from "../compilers/bindings/types.js";
12
14
  export function Color(hex) {
13
15
  if (typeof hex === "number") {
14
16
  return [((hex >> 16) & 0xff) / 0xff, ((hex >> 8) & 0xff) / 0xff, (hex & 0xff) / 0xff];
@@ -36,15 +38,69 @@ export function Color(hex) {
36
38
  }
37
39
  }
38
40
  }
39
- export function ResolveBinding(...bindings) {
41
+ export function ResolveBinding(cache, ...bindings) {
40
42
  const result = [];
41
43
  for (const binding of bindings) {
42
44
  if (binding.source_property_name) {
43
45
  if (isCompileBinding(binding.source_property_name)) {
44
- const { gen, out } = new Parser(binding.source_property_name.slice(1, -1)).out();
45
- if (gen)
46
- result.push(...gen);
47
- binding.source_property_name = out;
46
+ const inputBindings = binding.source_property_name.slice(1, -1);
47
+ if (binding.source_control_name) {
48
+ // @ts-ignore
49
+ const tokensMapping = (token) => {
50
+ if (token.kind === TokenKind.VARIABLE) {
51
+ const mapkey = `mapping:${binding.source_control_name}:${token.value}`;
52
+ if (cache.has(mapkey)) {
53
+ return {
54
+ ...token,
55
+ value: cache.get(mapkey),
56
+ };
57
+ }
58
+ else {
59
+ const ret = RandomBindingString(16);
60
+ cache.set(mapkey, ret);
61
+ result.push({
62
+ source_property_name: token.value,
63
+ source_control_name: binding.source_control_name,
64
+ target_property_name: ret,
65
+ binding_type: BindingType.VIEW,
66
+ });
67
+ return {
68
+ ...token,
69
+ value: ret,
70
+ };
71
+ }
72
+ }
73
+ else if (token.kind === TokenKind.TEMPLATE_STRING) {
74
+ return {
75
+ ...token,
76
+ // @ts-ignore
77
+ value: token.value.map((tstoken) => {
78
+ if (tstoken.kind === TSTokenKind.STRING)
79
+ return tstoken;
80
+ else {
81
+ return {
82
+ ...tstoken,
83
+ tokens: tstoken.tokens.map(tokensMapping),
84
+ };
85
+ }
86
+ }),
87
+ };
88
+ }
89
+ else
90
+ return token;
91
+ };
92
+ const { gen, out } = new Parser(inputBindings, cache, Lexer(inputBindings).map(tokensMapping)).out();
93
+ delete binding.source_control_name;
94
+ if (gen)
95
+ result.push(...gen);
96
+ binding.source_property_name = out;
97
+ }
98
+ else {
99
+ const { gen, out } = new Parser(inputBindings, cache).out();
100
+ if (gen)
101
+ result.push(...gen);
102
+ binding.source_property_name = out;
103
+ }
48
104
  }
49
105
  binding.binding_type = BindingType.VIEW;
50
106
  if (!binding.target_property_name)
@@ -107,6 +163,13 @@ export function Modify(namespace, name) {
107
163
  // @ts-ignore
108
164
  if (memoryUI)
109
165
  return memoryUI;
166
+ if (!paths[namespace]) {
167
+ throw new Error(`Namespace '${namespace}' does not exist`);
168
+ // @ts-ignore
169
+ }
170
+ else if (!paths[namespace][name]) {
171
+ throw new Error(`Element '${name}' does not exist in namespace '${namespace}'`);
172
+ }
110
173
  // @ts-ignore
111
174
  const modifyUI = new ModifyUI(namespace, name,
112
175
  // @ts-ignore
@@ -205,49 +268,49 @@ properties, namespace, name) {
205
268
  return ui;
206
269
  }
207
270
  // Quick Keyframe
208
- export function KeyframeOffset(properties, namespace, name) {
271
+ export function OffsetKeyframe(properties, namespace, name) {
209
272
  return new AnimationKeyframe(AnimType.OFFSET, properties || {}, name, namespace);
210
273
  }
211
- export function KeyframeSize(properties, namespace, name) {
274
+ export function SizeKeyframe(properties, namespace, name) {
212
275
  return new AnimationKeyframe(AnimType.SIZE, properties || {}, name, namespace);
213
276
  }
214
- export function KeyframeUV(properties, namespace, name) {
277
+ export function UVKeyframe(properties, namespace, name) {
215
278
  return new AnimationKeyframe(AnimType.UV, properties || {}, name, namespace);
216
279
  }
217
- export function KeyframeClip(properties, namespace, name) {
280
+ export function ClipKeyframe(properties, namespace, name) {
218
281
  return new AnimationKeyframe(AnimType.CLIP, properties || {}, name, namespace);
219
282
  }
220
- export function KeyframeColor(properties, namespace, name) {
283
+ export function ColorKeyframe(properties, namespace, name) {
221
284
  return new AnimationKeyframe(AnimType.COLOR, properties || {}, name, namespace);
222
285
  }
223
- export function KeyframeAlpha(properties, namespace, name) {
286
+ export function AlphaKeyframe(properties, namespace, name) {
224
287
  return new AnimationKeyframe(AnimType.ALPHA, properties || {}, name, namespace);
225
288
  }
226
- export function KeyframeWait(properties, namespace, name) {
289
+ export function WaitKeyframe(properties, namespace, name) {
227
290
  return new AnimationKeyframe(AnimType.WAIT, properties || {}, name, namespace);
228
291
  }
229
- export function KeyframeFlipBook(properties, namespace, name) {
292
+ export function FlipBookKeyframe(properties, namespace, name) {
230
293
  return new AnimationKeyframe(AnimType.FLIP_BOOK, properties || {}, name, namespace);
231
294
  }
232
- export function KeyframeAsepriteFlipBook(properties, namespace, name) {
295
+ export function AsepriteFlipBookKeyframe(properties, namespace, name) {
233
296
  return new AnimationKeyframe(AnimType.ASEPRITE_FLIP_BOOK, properties || {}, name, namespace);
234
297
  }
235
- export function AnimationOffset(...keyframes) {
298
+ export function OffsetAnimation(...keyframes) {
236
299
  return new Animation(AnimType.OFFSET, ...keyframes);
237
300
  }
238
- export function AnimationSize(...keyframes) {
301
+ export function SizeAnimation(...keyframes) {
239
302
  return new Animation(AnimType.SIZE, ...keyframes);
240
303
  }
241
- export function AnimationUV(...keyframes) {
304
+ export function UVAnimation(...keyframes) {
242
305
  return new Animation(AnimType.UV, ...keyframes);
243
306
  }
244
- export function AnimationClip(...keyframes) {
307
+ export function ClipAnimation(...keyframes) {
245
308
  return new Animation(AnimType.CLIP, ...keyframes);
246
309
  }
247
- export function AnimationColor(...keyframes) {
310
+ export function ColorAnimation(...keyframes) {
248
311
  return new Animation(AnimType.COLOR, ...keyframes);
249
312
  }
250
- export function AnimationAlpha(...keyframes) {
313
+ export function AlphaAnimation(...keyframes) {
251
314
  return new Animation(AnimType.ALPHA, ...keyframes);
252
315
  }
253
316
  // Animation ExtendsOf
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
package/dist/js/index.js CHANGED
@@ -1,3 +1,4 @@
1
+ import "./compilers/Configuration.js";
1
2
  import "./compilers/PreCompile.js";
2
3
  import "./compilers/ui/builder.js";
3
4
  import "./compilers/ui/installer.js";
@@ -8,3 +9,5 @@ export * from "./components/Utils.js";
8
9
  export * from "./types/enums/index.js";
9
10
  export * as Properties from "./types/properties/index.js";
10
11
  export { ItemAuxID } from "./types/enums/Items.js";
12
+ export { ArrayName, Operation } from "./types/properties/index.js";
13
+ export { Lexer } from "./compilers/bindings/Lexer.js";
@@ -0,0 +1 @@
1
+ export {};
@@ -1 +1,5 @@
1
- export declare const isBuildMode: boolean;
1
+ import { Config } from "../../config.js";
2
+ export declare const config: Config;
3
+ export declare let isBuildMode: boolean;
4
+ export declare let isLinkMode: boolean;
5
+ export declare let unLinked: boolean;
@@ -1,4 +1,7 @@
1
1
  export declare function isBlankChar(char: string): boolean;
2
2
  export declare function isWordChar(char: string): boolean | "";
3
3
  export declare function isNumberChar(char: string): boolean;
4
+ export declare function isHexChar(char: string): boolean;
5
+ export declare function isBinaryChar(char: string): boolean;
6
+ export declare function isOctalChar(char: string): boolean;
4
7
  export declare function isCompileBinding(input: string): boolean;
@@ -0,0 +1,7 @@
1
+ import { Expression, GenBinding } from "./types.js";
2
+ type Callback = (...args: Expression[]) => {
3
+ genBindings?: GenBinding[];
4
+ value: Expression;
5
+ };
6
+ export declare const FunctionMap: Map<string, Callback>;
7
+ export {};
@@ -3,5 +3,5 @@ type Callback = (...args: Expression[]) => {
3
3
  genBindings?: GenBinding[];
4
4
  value: Expression;
5
5
  };
6
- export declare const FuntionMap: Map<string, Callback>;
6
+ export declare const FunctionMap: Map<string, Callback>;
7
7
  export {};
@@ -2,11 +2,17 @@ import { Expression, GenBinding, Token } from "./types.js";
2
2
  import { BindingItem } from "../../types/properties/value.js";
3
3
  export declare class Parser {
4
4
  private input;
5
+ private cache;
5
6
  position: number;
6
- tokens: Token[];
7
7
  genBindings: GenBinding[];
8
8
  output: Expression;
9
- constructor(input: string);
9
+ tokens: Token[];
10
+ constructor(input: string, cache?: Map<string, unknown>, tokens?: Token[]);
11
+ static intToBin(input: string): {
12
+ ret: `#${string}`;
13
+ bindings: GenBinding[];
14
+ };
15
+ intToBin(input: string): string;
10
16
  at(): Token;
11
17
  eat(): Token;
12
18
  last(): Token;
@@ -16,14 +22,17 @@ export declare class Parser {
16
22
  private parseComparisonExpression;
17
23
  private parseAdditiveExpression;
18
24
  private parseMultiplicativeExpression;
25
+ private parseBitwiseLogicExpression;
26
+ private parseBitwiseShiftExpression;
19
27
  private parsePrimaryExpression;
20
28
  private parseCallableOrLiteral;
21
- private funtionCall;
29
+ private functionCall;
22
30
  private expect;
23
31
  private warn;
24
32
  private getPointer;
25
33
  out(): {
26
34
  gen?: BindingItem[];
27
35
  out: Expression;
36
+ cache: Map<string, unknown>;
28
37
  };
29
38
  }
@@ -2,4 +2,5 @@ export declare function clearBuild(): Promise<void>;
2
2
  export declare function createBuildFolder(): Promise<void>;
3
3
  export declare function getBuildFolderName(): Promise<string>;
4
4
  export declare function linkToGame(): Promise<void>;
5
+ export declare function unlink(): Promise<void>;
5
6
  export declare function getUUID(): Promise<[string, string]>;
@@ -15,8 +15,8 @@ export declare class AnimationKeyframe<T extends AnimType> extends Class {
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>>;
@@ -26,6 +26,7 @@ export declare class UI<T extends Type, K extends Renderer | null = null> extend
26
26
  protected readonly anims: (Animation<AnimType> | AnimationKeyframe<AnimType>)[];
27
27
  protected readonly extendType?: Type;
28
28
  protected properties: Properties<T, K>;
29
+ protected bindCache: Map<string, unknown>;
29
30
  constructor(type?: T | undefined, name?: string, namespace?: string, path?: string);
30
31
  /**
31
32
  * Set properties for this element
@@ -11,7 +11,7 @@ import { Animation } from "./Animation.js";
11
11
  import { SmartAnimation } from "../types/enums/SmartAnimation.js";
12
12
  type CompileBinding = `[${string}]`;
13
13
  export declare function Color(hex: string | number): Array3<number>;
14
- export declare function ResolveBinding(...bindings: BindingItem[]): BindingItem[];
14
+ export declare function ResolveBinding(cache: Map<string, unknown>, ...bindings: BindingItem[]): BindingItem[];
15
15
  export declare function RandomString(length: number, base?: number): string;
16
16
  export declare function RandomBindingString(length: number, base?: number): Binding;
17
17
  export declare function GetItemByAuxID(auxID: number): string | undefined;
@@ -50,22 +50,22 @@ export declare function Slider(properties?: Slider, namespace?: string, name?: s
50
50
  export declare function SliderBox(properties?: SliderBox, namespace?: string, name?: string): UI<Type.SLIDER_BOX, null>;
51
51
  export declare function ExtendsOf<T extends Type, K extends Renderer | null>(element: UI<T, K>, properties?: Properties<T, K>, namespace?: string, name?: string): typeof element;
52
52
  export declare function VanillaExtendsOf<T extends Namespace, K extends Exclude<Element<T>, `${string}/${string}`>>(originNamespace: T, originName: K, properties?: Properties<VanillaType<T, K>, null>, namespace?: string, name?: string): UI<VanillaType<T, K>, null>;
53
- export declare function KeyframeOffset(properties?: KeyframeAnimationProperties<AnimType.OFFSET>, namespace?: string, name?: string): AnimationKeyframe<AnimType.OFFSET>;
54
- export declare function KeyframeSize(properties?: KeyframeAnimationProperties<AnimType.SIZE>, namespace?: string, name?: string): AnimationKeyframe<AnimType.SIZE>;
55
- export declare function KeyframeUV(properties?: KeyframeAnimationProperties<AnimType.UV>, namespace?: string, name?: string): AnimationKeyframe<AnimType.UV>;
56
- export declare function KeyframeClip(properties?: KeyframeAnimationProperties<AnimType.CLIP>, namespace?: string, name?: string): AnimationKeyframe<AnimType.CLIP>;
57
- export declare function KeyframeColor(properties?: KeyframeAnimationProperties<AnimType.COLOR>, namespace?: string, name?: string): AnimationKeyframe<AnimType.COLOR>;
58
- export declare function KeyframeAlpha(properties?: KeyframeAnimationProperties<AnimType.ALPHA>, namespace?: string, name?: string): AnimationKeyframe<AnimType.ALPHA>;
59
- export declare function KeyframeWait(properties?: KeyframeAnimationProperties<AnimType.WAIT>, namespace?: string, name?: string): AnimationKeyframe<AnimType.WAIT>;
60
- export declare function KeyframeFlipBook(properties?: KeyframeAnimationProperties<AnimType.FLIP_BOOK>, namespace?: string, name?: string): AnimationKeyframe<AnimType.FLIP_BOOK>;
61
- export declare function KeyframeAsepriteFlipBook(properties?: KeyframeAnimationProperties<AnimType.ASEPRITE_FLIP_BOOK>, namespace?: string, name?: string): AnimationKeyframe<AnimType.ASEPRITE_FLIP_BOOK>;
53
+ export declare function OffsetKeyframe(properties?: KeyframeAnimationProperties<AnimType.OFFSET>, namespace?: string, name?: string): AnimationKeyframe<AnimType.OFFSET>;
54
+ export declare function SizeKeyframe(properties?: KeyframeAnimationProperties<AnimType.SIZE>, namespace?: string, name?: string): AnimationKeyframe<AnimType.SIZE>;
55
+ export declare function UVKeyframe(properties?: KeyframeAnimationProperties<AnimType.UV>, namespace?: string, name?: string): AnimationKeyframe<AnimType.UV>;
56
+ export declare function ClipKeyframe(properties?: KeyframeAnimationProperties<AnimType.CLIP>, namespace?: string, name?: string): AnimationKeyframe<AnimType.CLIP>;
57
+ export declare function ColorKeyframe(properties?: KeyframeAnimationProperties<AnimType.COLOR>, namespace?: string, name?: string): AnimationKeyframe<AnimType.COLOR>;
58
+ export declare function AlphaKeyframe(properties?: KeyframeAnimationProperties<AnimType.ALPHA>, namespace?: string, name?: string): AnimationKeyframe<AnimType.ALPHA>;
59
+ export declare function WaitKeyframe(properties?: KeyframeAnimationProperties<AnimType.WAIT>, namespace?: string, name?: string): AnimationKeyframe<AnimType.WAIT>;
60
+ export declare function FlipBookKeyframe(properties?: KeyframeAnimationProperties<AnimType.FLIP_BOOK>, namespace?: string, name?: string): AnimationKeyframe<AnimType.FLIP_BOOK>;
61
+ export declare function AsepriteFlipBookKeyframe(properties?: KeyframeAnimationProperties<AnimType.ASEPRITE_FLIP_BOOK>, namespace?: string, name?: string): AnimationKeyframe<AnimType.ASEPRITE_FLIP_BOOK>;
62
62
  type Anim<T extends AnimType> = AnimationProperties<T> | number;
63
63
  type AnimWithSmartAnim<T extends AnimType> = [SmartAnimation | Anim<T>, ...Anim<T>[]];
64
- export declare function AnimationOffset(...keyframes: AnimWithSmartAnim<AnimType.OFFSET>): Animation<AnimType.OFFSET>;
65
- export declare function AnimationSize(...keyframes: AnimWithSmartAnim<AnimType.SIZE>): Animation<AnimType.SIZE>;
66
- export declare function AnimationUV(...keyframes: AnimWithSmartAnim<AnimType.UV>): Animation<AnimType.UV>;
67
- export declare function AnimationClip(...keyframes: AnimWithSmartAnim<AnimType.CLIP>): Animation<AnimType.CLIP>;
68
- export declare function AnimationColor(...keyframes: AnimWithSmartAnim<AnimType.COLOR>): Animation<AnimType.COLOR>;
69
- export declare function AnimationAlpha(...keyframes: AnimWithSmartAnim<AnimType.ALPHA>): Animation<AnimType.ALPHA>;
64
+ export declare function OffsetAnimation(...keyframes: AnimWithSmartAnim<AnimType.OFFSET>): Animation<AnimType.OFFSET>;
65
+ export declare function SizeAnimation(...keyframes: AnimWithSmartAnim<AnimType.SIZE>): Animation<AnimType.SIZE>;
66
+ export declare function UVAnimation(...keyframes: AnimWithSmartAnim<AnimType.UV>): Animation<AnimType.UV>;
67
+ export declare function ClipAnimation(...keyframes: AnimWithSmartAnim<AnimType.CLIP>): Animation<AnimType.CLIP>;
68
+ export declare function ColorAnimation(...keyframes: AnimWithSmartAnim<AnimType.COLOR>): Animation<AnimType.COLOR>;
69
+ export declare function AlphaAnimation(...keyframes: AnimWithSmartAnim<AnimType.ALPHA>): Animation<AnimType.ALPHA>;
70
70
  export declare function AnimationExtendsOf<T extends AnimType>(animation: AnimationKeyframe<T> | Animation<T>, properties?: AnimationProperties<T>): AnimationKeyframe<T>;
71
71
  export {};
@@ -0,0 +1,2 @@
1
+ export interface Config {
2
+ }
@@ -0,0 +1,13 @@
1
+ import { Variable } from "./src/types/properties/value.js";
2
+ export interface Config {
3
+ compiler?: {
4
+ enabled?: boolean;
5
+ linked?: boolean;
6
+ };
7
+ packinfo?: {
8
+ name?: string;
9
+ description?: string;
10
+ version?: [number, number, number];
11
+ };
12
+ global_variables?: Record<Variable, string>;
13
+ }
@@ -1,3 +1,4 @@
1
+ import "./compilers/Configuration.js";
1
2
  import "./compilers/PreCompile.js";
2
3
  import "./compilers/ui/builder.js";
3
4
  import "./compilers/ui/installer.js";
@@ -8,3 +9,5 @@ export * from "./components/Utils.js";
8
9
  export * from "./types/enums/index.js";
9
10
  export * as Properties from "./types/properties/index.js";
10
11
  export { ItemAuxID } from "./types/enums/Items.js";
12
+ export { ArrayName, Operation } from "./types/properties/index.js";
13
+ export { Lexer } from "./compilers/bindings/Lexer.js";
@@ -0,0 +1,13 @@
1
+ import { Variable } from "./properties/value.js";
2
+ export interface Config {
3
+ compiler?: {
4
+ enabled?: boolean;
5
+ linked?: boolean;
6
+ };
7
+ packinfo?: {
8
+ name?: string;
9
+ description?: string;
10
+ version?: [number, number, number];
11
+ };
12
+ global_variables?: Record<Variable, string>;
13
+ }
@@ -28,4 +28,3 @@ export { SliderName } from "./SliderName.js";
28
28
  export { ToggleName } from "./ToggleName.js";
29
29
  export { BagBinding } from "./BagBinding.js";
30
30
  export { Binding } from "./Binding.js";
31
- export { SmartAnimation } from "./SmartAnimation.js";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "asajs",
3
- "version": "4.0.0-indev-2",
3
+ "version": "4.0.0-indev-3",
4
4
  "description": "Create your Minecraft JSON-UI resource packs using JavaScript",
5
5
  "keywords": [
6
6
  "Minecraft",
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Configuration object for the AsaJS build process.
3
+ * @type {import('asajs/config.d.ts').Config}
4
+ */
5
+ export const config = {
6
+ packinfo: {
7
+ name: "AsaJS",
8
+ description: "Create your Minecraft JSON-UI resource packs using JavaScript.",
9
+ },
10
+ compiler: {
11
+ enabled: true,
12
+ linked: false,
13
+ },
14
+ }