asajs 4.0.0 → 4.0.2
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.
- package/dist/js/compilers/bindings/Binary.js +36 -0
- package/dist/js/compilers/bindings/Function.js +116 -66
- package/dist/js/compilers/bindings/Lexer.js +11 -6
- package/dist/js/compilers/bindings/Parser.js +8 -76
- package/dist/js/compilers/bindings/types.js +10 -9
- package/dist/js/compilers/ui/builder.js +1 -1
- package/dist/js/compilers/ui/manifest.js +1 -1
- package/dist/js/components/UI.js +1 -1
- package/dist/js/index.js +1 -1
- package/dist/types/compilers/bindings/Binary.d.ts +10 -0
- package/dist/types/compilers/bindings/Function.d.ts +86 -0
- package/dist/types/compilers/bindings/types.d.ts +10 -9
- package/dist/types/index.d.ts +1 -1
- package/dist/types/types/properties/element/Cycler.d.ts +1 -0
- package/dist/types/types/properties/element/Layout.d.ts +1 -1
- package/package.json +1 -1
- package/resources/asajs.config.cjs +2 -2
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { RandomBindingString } from "../../components/Utils.js";
|
|
2
|
+
import { defaultFunctions } from "./Function.js";
|
|
3
|
+
export function intToBin(input) {
|
|
4
|
+
const { abs, negabs } = defaultFunctions;
|
|
5
|
+
const ret = RandomBindingString(16);
|
|
6
|
+
const bindings = [];
|
|
7
|
+
// negative bit
|
|
8
|
+
bindings.push({
|
|
9
|
+
source: `(${input} < 0)`,
|
|
10
|
+
target: `${ret}0`,
|
|
11
|
+
});
|
|
12
|
+
return {
|
|
13
|
+
ret,
|
|
14
|
+
bindings,
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
export function binToInt(input) {
|
|
18
|
+
const ret = RandomBindingString(16);
|
|
19
|
+
const bindings = [];
|
|
20
|
+
const nevBind = (input + "0");
|
|
21
|
+
// Is reverse to positive
|
|
22
|
+
bindings.push({
|
|
23
|
+
source: `(-1 + ((${nevBind} = 0) * 2))`,
|
|
24
|
+
target: `${ret}0`,
|
|
25
|
+
});
|
|
26
|
+
bindings.push({
|
|
27
|
+
source: `(${Array.from({ length: 31 }, ($, i) => {
|
|
28
|
+
return `${input}${i + 1}`;
|
|
29
|
+
}).join(" + ")})`,
|
|
30
|
+
target: ret,
|
|
31
|
+
});
|
|
32
|
+
return {
|
|
33
|
+
ret,
|
|
34
|
+
bindings,
|
|
35
|
+
};
|
|
36
|
+
}
|
|
@@ -1,71 +1,121 @@
|
|
|
1
1
|
import { RandomBindingString } from "../../components/Utils.js";
|
|
2
|
-
import { Parser } from "./Parser.js";
|
|
3
2
|
export const FunctionMap = new Map();
|
|
4
3
|
function callFn(name, ...args) {
|
|
5
4
|
return FunctionMap.get(name)(...args);
|
|
6
5
|
}
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
}
|
|
71
|
-
|
|
6
|
+
export const defaultFunctions = {
|
|
7
|
+
/**
|
|
8
|
+
* Returns the absolute value of a number (the value without regard to whether it is positive or negative). For example, the absolute value of -5 is the same as the absolute value of 5.
|
|
9
|
+
* @param number
|
|
10
|
+
* @returns
|
|
11
|
+
*/
|
|
12
|
+
abs: number => {
|
|
13
|
+
const randomBinding = RandomBindingString(16);
|
|
14
|
+
return {
|
|
15
|
+
genBindings: [{ source: `((-1 + (${number} > 0) * 2) * ${number})`, target: randomBinding }],
|
|
16
|
+
value: randomBinding,
|
|
17
|
+
};
|
|
18
|
+
},
|
|
19
|
+
/**
|
|
20
|
+
* Returns the negative absolute value of a number (the value without regard to whether it is positive or negative). For example, the absolute value of 5 is the same as the negative absolute value of -5.
|
|
21
|
+
* @param number
|
|
22
|
+
* @returns
|
|
23
|
+
*/
|
|
24
|
+
negabs: number => {
|
|
25
|
+
const randomBinding = RandomBindingString(16);
|
|
26
|
+
return {
|
|
27
|
+
genBindings: [{ source: `((-1 + (${number} < 0) * 2) * ${number})`, target: randomBinding }],
|
|
28
|
+
value: randomBinding,
|
|
29
|
+
};
|
|
30
|
+
},
|
|
31
|
+
/**
|
|
32
|
+
* Generate a new binding for expression
|
|
33
|
+
* @param expression
|
|
34
|
+
* @returns
|
|
35
|
+
*/
|
|
36
|
+
new: expression => {
|
|
37
|
+
const randomBinding = RandomBindingString(16);
|
|
38
|
+
return {
|
|
39
|
+
genBindings: [{ source: expression, target: randomBinding }],
|
|
40
|
+
value: randomBinding,
|
|
41
|
+
};
|
|
42
|
+
},
|
|
43
|
+
/**
|
|
44
|
+
* Returns the square root of a number.
|
|
45
|
+
* @param number
|
|
46
|
+
* @returns
|
|
47
|
+
*/
|
|
48
|
+
sqrt: number => {
|
|
49
|
+
const rtn = RandomBindingString(16), $1 = RandomBindingString(16), $2 = RandomBindingString(16);
|
|
50
|
+
const { genBindings: absValue, value: absRtn } = callFn("abs", number);
|
|
51
|
+
return {
|
|
52
|
+
genBindings: [
|
|
53
|
+
{
|
|
54
|
+
source: `${number} * 100 / 2`,
|
|
55
|
+
target: $1,
|
|
56
|
+
},
|
|
57
|
+
...absValue,
|
|
58
|
+
{
|
|
59
|
+
source: `${absRtn} > 1`,
|
|
60
|
+
target: $2,
|
|
61
|
+
},
|
|
62
|
+
{
|
|
63
|
+
source: `(${number} < 0) * -1 + (${number} > -1) * (${$2} * ((${rtn} + ${number} / ${rtn}) / 2) + (not ${$2}) * ${rtn})`,
|
|
64
|
+
target: rtn,
|
|
65
|
+
},
|
|
66
|
+
],
|
|
67
|
+
value: rtn,
|
|
68
|
+
};
|
|
69
|
+
},
|
|
70
|
+
/**
|
|
71
|
+
* Return a translatable string
|
|
72
|
+
* @param key
|
|
73
|
+
* @returns
|
|
74
|
+
*/
|
|
75
|
+
translatable: key => {
|
|
76
|
+
return {
|
|
77
|
+
value: `'%' + ${key}`,
|
|
78
|
+
};
|
|
79
|
+
},
|
|
80
|
+
/**
|
|
81
|
+
* Return a binary of int32 number in string
|
|
82
|
+
* @param value
|
|
83
|
+
* @param bait
|
|
84
|
+
* @returns
|
|
85
|
+
*/
|
|
86
|
+
// bin: value => {
|
|
87
|
+
// const {} = intToBin(value)
|
|
88
|
+
// return {
|
|
89
|
+
// value,
|
|
90
|
+
// }
|
|
91
|
+
// },
|
|
92
|
+
/**
|
|
93
|
+
* Generate value bindings
|
|
94
|
+
* @param value
|
|
95
|
+
* @param bait
|
|
96
|
+
* @returns
|
|
97
|
+
*/
|
|
98
|
+
bind: (value, bait) => {
|
|
99
|
+
const ret = RandomBindingString(16);
|
|
100
|
+
if (!bait) {
|
|
101
|
+
throw new Error("Bait is required");
|
|
102
|
+
}
|
|
103
|
+
return {
|
|
104
|
+
genBindings: [{ source: `((${bait} - ${bait}) + ${value})`, target: ret }],
|
|
105
|
+
value: ret,
|
|
106
|
+
};
|
|
107
|
+
},
|
|
108
|
+
/**
|
|
109
|
+
* Return a int of float number, because string in JSON-UI cannot read it.
|
|
110
|
+
* @param input
|
|
111
|
+
* @returns
|
|
112
|
+
*/
|
|
113
|
+
int: input => {
|
|
114
|
+
const ret = RandomBindingString(16);
|
|
115
|
+
return {
|
|
116
|
+
genBindings: [{ source: `${input}`, target: ret }],
|
|
117
|
+
value: ret,
|
|
118
|
+
};
|
|
119
|
+
},
|
|
120
|
+
};
|
|
121
|
+
Object.entries(defaultFunctions).forEach(([key, value]) => FunctionMap.set(key, value));
|
|
@@ -64,8 +64,12 @@ export function Lexer(input, start = 0, end) {
|
|
|
64
64
|
tokens.push(makeToken(input, TokenKind.OPERATOR, index++, 2));
|
|
65
65
|
else {
|
|
66
66
|
if (input[index] === input[index + 1]) {
|
|
67
|
-
if (input[index] !== "!")
|
|
68
|
-
|
|
67
|
+
if (input[index] !== "!") {
|
|
68
|
+
if (input[++index] === input[index + 1])
|
|
69
|
+
tokens.push(makeToken(input, TokenKind.OPERATOR, index++ - 1, 3));
|
|
70
|
+
else
|
|
71
|
+
tokens.push(makeToken(input, TokenKind.OPERATOR, index - 1, 2));
|
|
72
|
+
}
|
|
69
73
|
else
|
|
70
74
|
tokens.push(makeToken(input, TokenKind.OPERATOR, index));
|
|
71
75
|
}
|
|
@@ -125,6 +129,7 @@ export function Lexer(input, start = 0, end) {
|
|
|
125
129
|
value: `'${input.slice(start, index - 1)}'`,
|
|
126
130
|
},
|
|
127
131
|
});
|
|
132
|
+
index--;
|
|
128
133
|
break;
|
|
129
134
|
}
|
|
130
135
|
}
|
|
@@ -185,14 +190,14 @@ export function Lexer(input, start = 0, end) {
|
|
|
185
190
|
console.error(`\x1b[31merror: ${input + "\n" + " ".repeat(index + 6) + "^"}\nInvalid character.\x1b[0m`);
|
|
186
191
|
throw new Error();
|
|
187
192
|
}
|
|
188
|
-
tokens.push(makeToken(input, TokenKind.
|
|
193
|
+
tokens.push(makeToken(input, TokenKind.INT, start, index - start + 1));
|
|
189
194
|
break;
|
|
190
195
|
}
|
|
191
196
|
else if (numType === "b") {
|
|
192
197
|
index += 2;
|
|
193
198
|
while (Checker.isBinaryChar(input[index + 1]))
|
|
194
199
|
index++;
|
|
195
|
-
tokens.push(makeToken(input, TokenKind.
|
|
200
|
+
tokens.push(makeToken(input, TokenKind.INT, start, index - start + 1));
|
|
196
201
|
if (start + 2 === index) {
|
|
197
202
|
console.error(`\x1b[31merror: ${input + "\n" + " ".repeat(index + 6) + "^"}\nInvalid character.\x1b[0m`);
|
|
198
203
|
throw new Error();
|
|
@@ -203,7 +208,7 @@ export function Lexer(input, start = 0, end) {
|
|
|
203
208
|
index += 2;
|
|
204
209
|
while (Checker.isOctalChar(input[index + 1]))
|
|
205
210
|
index++;
|
|
206
|
-
tokens.push(makeToken(input, TokenKind.
|
|
211
|
+
tokens.push(makeToken(input, TokenKind.INT, start, index - start + 1));
|
|
207
212
|
if (start + 2 === index) {
|
|
208
213
|
console.error(`\x1b[31merror: ${input + "\n" + " ".repeat(index + 6) + "^"}\nInvalid character.\x1b[0m`);
|
|
209
214
|
throw new Error();
|
|
@@ -224,7 +229,7 @@ export function Lexer(input, start = 0, end) {
|
|
|
224
229
|
while (Checker.isNumberChar(input[index + 1]))
|
|
225
230
|
index++;
|
|
226
231
|
}
|
|
227
|
-
tokens.push(makeToken(input, TokenKind.
|
|
232
|
+
tokens.push(makeToken(input, TokenKind.INT, start, index - start + 1));
|
|
228
233
|
}
|
|
229
234
|
else if (Checker.isWordChar(token)) {
|
|
230
235
|
while (Checker.isWordChar(input[index + 1]))
|
|
@@ -140,80 +140,12 @@ export class Parser {
|
|
|
140
140
|
return left;
|
|
141
141
|
}
|
|
142
142
|
parseBitwiseLogicExpression() {
|
|
143
|
-
|
|
144
|
-
|
|
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;
|
|
143
|
+
// TODO
|
|
144
|
+
return this.parseBitwiseShiftExpression();
|
|
188
145
|
}
|
|
189
146
|
parseBitwiseShiftExpression() {
|
|
190
|
-
|
|
191
|
-
|
|
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;
|
|
147
|
+
// TODO
|
|
148
|
+
return this.parsePrimaryExpression();
|
|
217
149
|
}
|
|
218
150
|
parsePrimaryExpression() {
|
|
219
151
|
const left = this.at();
|
|
@@ -227,7 +159,7 @@ export class Parser {
|
|
|
227
159
|
this.eat();
|
|
228
160
|
return `(${value})`;
|
|
229
161
|
}
|
|
230
|
-
case TokenKind.
|
|
162
|
+
case TokenKind.INT: {
|
|
231
163
|
const numberToken = this.eat();
|
|
232
164
|
switch (numberToken.value[1]) {
|
|
233
165
|
case "x":
|
|
@@ -292,7 +224,7 @@ export class Parser {
|
|
|
292
224
|
}
|
|
293
225
|
}
|
|
294
226
|
default:
|
|
295
|
-
this.expect(TokenKind.
|
|
227
|
+
this.expect(TokenKind.INT, "Unexpected token!");
|
|
296
228
|
}
|
|
297
229
|
return left.value;
|
|
298
230
|
}
|
|
@@ -302,14 +234,14 @@ export class Parser {
|
|
|
302
234
|
this.eat();
|
|
303
235
|
const args = [];
|
|
304
236
|
if (this.at().kind === TokenKind.COMMA) {
|
|
305
|
-
this.expect(TokenKind.
|
|
237
|
+
this.expect(TokenKind.INT, "Unexpected token!");
|
|
306
238
|
}
|
|
307
239
|
if (this.at().kind !== TokenKind.CLOSE_PARENTHESIS) {
|
|
308
240
|
args.push(this.parseExpression());
|
|
309
241
|
while (this.at().kind === TokenKind.COMMA) {
|
|
310
242
|
this.eat();
|
|
311
243
|
if (this.at().kind === TokenKind.CLOSE_PARENTHESIS) {
|
|
312
|
-
this.expect(TokenKind.
|
|
244
|
+
this.expect(TokenKind.INT, "Unexpected token!");
|
|
313
245
|
}
|
|
314
246
|
args.push(this.parseExpression());
|
|
315
247
|
}
|
|
@@ -1,15 +1,16 @@
|
|
|
1
1
|
export var TokenKind;
|
|
2
2
|
(function (TokenKind) {
|
|
3
3
|
TokenKind[TokenKind["VARIABLE"] = 0] = "VARIABLE";
|
|
4
|
-
TokenKind[TokenKind["
|
|
5
|
-
TokenKind[TokenKind["
|
|
6
|
-
TokenKind[TokenKind["
|
|
7
|
-
TokenKind[TokenKind["
|
|
8
|
-
TokenKind[TokenKind["
|
|
9
|
-
TokenKind[TokenKind["
|
|
10
|
-
TokenKind[TokenKind["
|
|
11
|
-
TokenKind[TokenKind["
|
|
12
|
-
TokenKind[TokenKind["
|
|
4
|
+
TokenKind[TokenKind["STRING"] = 1] = "STRING";
|
|
5
|
+
TokenKind[TokenKind["TEMPLATE_STRING"] = 2] = "TEMPLATE_STRING";
|
|
6
|
+
TokenKind[TokenKind["WORD"] = 3] = "WORD";
|
|
7
|
+
TokenKind[TokenKind["INT"] = 4] = "INT";
|
|
8
|
+
TokenKind[TokenKind["FLOAT"] = 5] = "FLOAT";
|
|
9
|
+
TokenKind[TokenKind["OPEN_PARENTHESIS"] = 6] = "OPEN_PARENTHESIS";
|
|
10
|
+
TokenKind[TokenKind["CLOSE_PARENTHESIS"] = 7] = "CLOSE_PARENTHESIS";
|
|
11
|
+
TokenKind[TokenKind["OPERATOR"] = 8] = "OPERATOR";
|
|
12
|
+
TokenKind[TokenKind["COMMA"] = 9] = "COMMA";
|
|
13
|
+
TokenKind[TokenKind["EOF"] = 10] = "EOF";
|
|
13
14
|
})(TokenKind || (TokenKind = {}));
|
|
14
15
|
export var TSTokenKind;
|
|
15
16
|
(function (TSTokenKind) {
|
|
@@ -48,6 +48,7 @@ if (isBuildMode) {
|
|
|
48
48
|
let first = true;
|
|
49
49
|
process.on("beforeExit", async () => {
|
|
50
50
|
if (first) {
|
|
51
|
+
first = false;
|
|
51
52
|
await createBuildFolder();
|
|
52
53
|
await buildUI();
|
|
53
54
|
if (isLinkMode)
|
|
@@ -66,7 +67,6 @@ if (isBuildMode) {
|
|
|
66
67
|
console.log("Install Path:", `\x1b[32m"${path.join(gamePath, await getBuildFolderName())}"\x1b[0m`);
|
|
67
68
|
console.log("=============================================================");
|
|
68
69
|
}
|
|
69
|
-
first = false;
|
|
70
70
|
});
|
|
71
71
|
}
|
|
72
72
|
else if (isLinkMode)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { config } from "../Configuration.js";
|
|
2
2
|
import { getUUID } from "./linker.js";
|
|
3
|
-
export const version = config.packinfo?.version || [4, 0,
|
|
3
|
+
export const version = config.packinfo?.version || [4, 0, 1];
|
|
4
4
|
export async function genManifest() {
|
|
5
5
|
const [uuid1, uuid2] = await getUUID();
|
|
6
6
|
return JSON.stringify({
|
package/dist/js/components/UI.js
CHANGED
|
@@ -137,7 +137,7 @@ export class UI extends Class {
|
|
|
137
137
|
obj.anims = this.anims.map(a => String(a));
|
|
138
138
|
if (this.controls.size) {
|
|
139
139
|
obj.controls = [];
|
|
140
|
-
this.controls.forEach((e, key) => obj.controls.push({ [key + e[0]]: e[1] }));
|
|
140
|
+
this.controls.forEach((e, key) => obj.controls.push({ [key + e[0]]: FormatProperties(e[1]) }));
|
|
141
141
|
}
|
|
142
142
|
return obj;
|
|
143
143
|
}
|
package/dist/js/index.js
CHANGED
|
@@ -10,4 +10,4 @@ export * from "./types/enums/index.js";
|
|
|
10
10
|
export * as Properties from "./types/properties/index.js";
|
|
11
11
|
export { ItemAuxID } from "./types/enums/Items.js";
|
|
12
12
|
export { ArrayName, Operation } from "./types/properties/index.js";
|
|
13
|
-
export
|
|
13
|
+
export * from "./compilers/bindings/Binary.js";
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Binding } from "../../types/properties/value.js";
|
|
2
|
+
import { GenBinding } from "./types.js";
|
|
3
|
+
export declare function intToBin(input: string): {
|
|
4
|
+
ret: `#${string}`;
|
|
5
|
+
bindings: GenBinding[];
|
|
6
|
+
};
|
|
7
|
+
export declare function binToInt(input: Binding): {
|
|
8
|
+
ret: `#${string}`;
|
|
9
|
+
bindings: GenBinding[];
|
|
10
|
+
};
|
|
@@ -4,4 +4,90 @@ type Callback = (...args: Expression[]) => {
|
|
|
4
4
|
value: Expression;
|
|
5
5
|
};
|
|
6
6
|
export declare const FunctionMap: Map<string, Callback>;
|
|
7
|
+
export declare const defaultFunctions: {
|
|
8
|
+
/**
|
|
9
|
+
* Returns the absolute value of a number (the value without regard to whether it is positive or negative). For example, the absolute value of -5 is the same as the absolute value of 5.
|
|
10
|
+
* @param number
|
|
11
|
+
* @returns
|
|
12
|
+
*/
|
|
13
|
+
abs: (number: string) => {
|
|
14
|
+
genBindings: {
|
|
15
|
+
source: string;
|
|
16
|
+
target: `#${string}`;
|
|
17
|
+
}[];
|
|
18
|
+
value: `#${string}`;
|
|
19
|
+
};
|
|
20
|
+
/**
|
|
21
|
+
* Returns the negative absolute value of a number (the value without regard to whether it is positive or negative). For example, the absolute value of 5 is the same as the negative absolute value of -5.
|
|
22
|
+
* @param number
|
|
23
|
+
* @returns
|
|
24
|
+
*/
|
|
25
|
+
negabs: (number: string) => {
|
|
26
|
+
genBindings: {
|
|
27
|
+
source: string;
|
|
28
|
+
target: `#${string}`;
|
|
29
|
+
}[];
|
|
30
|
+
value: `#${string}`;
|
|
31
|
+
};
|
|
32
|
+
/**
|
|
33
|
+
* Generate a new binding for expression
|
|
34
|
+
* @param expression
|
|
35
|
+
* @returns
|
|
36
|
+
*/
|
|
37
|
+
new: (expression: string) => {
|
|
38
|
+
genBindings: {
|
|
39
|
+
source: string;
|
|
40
|
+
target: `#${string}`;
|
|
41
|
+
}[];
|
|
42
|
+
value: `#${string}`;
|
|
43
|
+
};
|
|
44
|
+
/**
|
|
45
|
+
* Returns the square root of a number.
|
|
46
|
+
* @param number
|
|
47
|
+
* @returns
|
|
48
|
+
*/
|
|
49
|
+
sqrt: (number: string) => {
|
|
50
|
+
genBindings: GenBinding[];
|
|
51
|
+
value: `#${string}`;
|
|
52
|
+
};
|
|
53
|
+
/**
|
|
54
|
+
* Return a translatable string
|
|
55
|
+
* @param key
|
|
56
|
+
* @returns
|
|
57
|
+
*/
|
|
58
|
+
translatable: (key: string) => {
|
|
59
|
+
value: string;
|
|
60
|
+
};
|
|
61
|
+
/**
|
|
62
|
+
* Return a binary of int32 number in string
|
|
63
|
+
* @param value
|
|
64
|
+
* @param bait
|
|
65
|
+
* @returns
|
|
66
|
+
*/
|
|
67
|
+
/**
|
|
68
|
+
* Generate value bindings
|
|
69
|
+
* @param value
|
|
70
|
+
* @param bait
|
|
71
|
+
* @returns
|
|
72
|
+
*/
|
|
73
|
+
bind: (value: string, bait: string) => {
|
|
74
|
+
genBindings: {
|
|
75
|
+
source: string;
|
|
76
|
+
target: `#${string}`;
|
|
77
|
+
}[];
|
|
78
|
+
value: `#${string}`;
|
|
79
|
+
};
|
|
80
|
+
/**
|
|
81
|
+
* Return a int of float number, because string in JSON-UI cannot read it.
|
|
82
|
+
* @param input
|
|
83
|
+
* @returns
|
|
84
|
+
*/
|
|
85
|
+
int: (input: string) => {
|
|
86
|
+
genBindings: {
|
|
87
|
+
source: string;
|
|
88
|
+
target: `#${string}`;
|
|
89
|
+
}[];
|
|
90
|
+
value: `#${string}`;
|
|
91
|
+
};
|
|
92
|
+
};
|
|
7
93
|
export {};
|
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
export declare enum TokenKind {
|
|
2
2
|
VARIABLE = 0,
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
3
|
+
STRING = 1,
|
|
4
|
+
TEMPLATE_STRING = 2,
|
|
5
|
+
WORD = 3,
|
|
6
|
+
INT = 4,
|
|
7
|
+
FLOAT = 5,
|
|
8
|
+
OPEN_PARENTHESIS = 6,
|
|
9
|
+
CLOSE_PARENTHESIS = 7,
|
|
10
|
+
OPERATOR = 8,
|
|
11
|
+
COMMA = 9,
|
|
12
|
+
EOF = 10
|
|
12
13
|
}
|
|
13
14
|
export declare enum TSTokenKind {
|
|
14
15
|
STRING = 0,
|
package/dist/types/index.d.ts
CHANGED
|
@@ -10,4 +10,4 @@ export * from "./types/enums/index.js";
|
|
|
10
10
|
export * as Properties from "./types/properties/index.js";
|
|
11
11
|
export { ItemAuxID } from "./types/enums/Items.js";
|
|
12
12
|
export { ArrayName, Operation } from "./types/properties/index.js";
|
|
13
|
-
export
|
|
13
|
+
export * from "./compilers/bindings/Binary.js";
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Anchor } from "../../enums/Anchor.js";
|
|
2
2
|
import { Value, AnimValue, Array2 } from "../value.js";
|
|
3
3
|
export interface Layout {
|
|
4
|
-
offset?: AnimValue<Array2<number>>;
|
|
4
|
+
offset?: AnimValue<Array2<number | string>>;
|
|
5
5
|
size?: AnimValue<Array2<number | string>>;
|
|
6
6
|
max_size?: AnimValue<Array2<number | string>>;
|
|
7
7
|
min_size?: AnimValue<Array2<number | string>>;
|
package/package.json
CHANGED
|
@@ -4,9 +4,9 @@
|
|
|
4
4
|
*/
|
|
5
5
|
export const config = {
|
|
6
6
|
packinfo: {
|
|
7
|
-
name: "AsaJS
|
|
7
|
+
name: "AsaJS",
|
|
8
8
|
description: "Create your Minecraft JSON-UI resource packs using JavaScript.",
|
|
9
|
-
version: [4, 0,
|
|
9
|
+
version: [4, 0, 1],
|
|
10
10
|
},
|
|
11
11
|
compiler: {
|
|
12
12
|
enabled: true,
|