asajs 4.1.7 → 4.1.8
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/FormatProperties.js +13 -0
- package/dist/js/compilers/bindings/Checker.js +3 -0
- package/dist/js/compilers/bindings/Function.js +10 -2
- package/dist/js/components/Utils.js +9 -3
- package/dist/types/compilers/bindings/Checker.d.ts +1 -0
- package/dist/types/compilers/bindings/Function.d.ts +4 -0
- package/dist/types/types/properties/value.d.ts +1 -1
- package/package.json +1 -1
|
@@ -9,6 +9,19 @@ export function FormatProperties(properties) {
|
|
|
9
9
|
property_bag[key] = value;
|
|
10
10
|
delete properties[key];
|
|
11
11
|
}
|
|
12
|
+
if (key.startsWith("$")) {
|
|
13
|
+
const [varName, varType] = key.split("|");
|
|
14
|
+
switch (varType) {
|
|
15
|
+
case "d":
|
|
16
|
+
properties[`${varName}|default`] = value;
|
|
17
|
+
delete properties[key];
|
|
18
|
+
break;
|
|
19
|
+
case "default":
|
|
20
|
+
break;
|
|
21
|
+
default:
|
|
22
|
+
throw new Error("Invalid variable type");
|
|
23
|
+
}
|
|
24
|
+
}
|
|
12
25
|
}
|
|
13
26
|
if (config.compiler?.fixInventoryItemRenderer && property_bag[BagBinding.ITEM_ID_AUX]) {
|
|
14
27
|
property_bag[BagBinding.ITEM_ID_AUX] = `(${property_bag[BagBinding.ITEM_ID_AUX]} / 1)`;
|
|
@@ -25,6 +25,9 @@ export function isHasBinding(input) {
|
|
|
25
25
|
export function isBinding(input) {
|
|
26
26
|
return /^#\w+$/.test(input);
|
|
27
27
|
}
|
|
28
|
+
export function isVariable(input) {
|
|
29
|
+
return /^\$\w+$/.test(input);
|
|
30
|
+
}
|
|
28
31
|
export function isNumber(input) {
|
|
29
32
|
return /^[+-]?(?:\d+|\d+\.\d*|\.\d+)(?:[eE][+-]?\d+)?$/.test(input);
|
|
30
33
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { bs, RandomBindingString, RandomString, ResolveBinding } from "../../components/Utils.js";
|
|
1
|
+
import { bs, RandomBindingString, RandomString, ResolveBinding, vs } from "../../components/Utils.js";
|
|
2
2
|
import { bindingFuntions } from "../Configuration.js";
|
|
3
|
-
import { isBinding, isNumber, isString } from "./Checker.js";
|
|
3
|
+
import { isBinding, isNumber, isString, isVariable } from "./Checker.js";
|
|
4
4
|
export const FunctionMap = new Map();
|
|
5
5
|
export const defaultFunctions = {
|
|
6
6
|
/**
|
|
@@ -224,6 +224,14 @@ export const defaultFunctions = {
|
|
|
224
224
|
value: bs(input_binding),
|
|
225
225
|
};
|
|
226
226
|
},
|
|
227
|
+
vs: input_variable => {
|
|
228
|
+
if (!isVariable(input_variable))
|
|
229
|
+
throw new Error("Invalid input binding");
|
|
230
|
+
return {
|
|
231
|
+
doNotAddParentesis: true,
|
|
232
|
+
value: vs(input_variable),
|
|
233
|
+
};
|
|
234
|
+
},
|
|
227
235
|
/**
|
|
228
236
|
* Return a translatable string
|
|
229
237
|
* @param key
|
|
@@ -201,15 +201,21 @@ export function bs(input) {
|
|
|
201
201
|
}
|
|
202
202
|
}
|
|
203
203
|
export function vs(input) {
|
|
204
|
+
let [name, mode] = input.split("|");
|
|
205
|
+
input = name;
|
|
206
|
+
if (mode)
|
|
207
|
+
mode = "|" + mode;
|
|
208
|
+
else
|
|
209
|
+
mode = "";
|
|
204
210
|
if (isNotObfuscate)
|
|
205
|
-
return
|
|
211
|
+
return `${name}${mode}`;
|
|
206
212
|
else {
|
|
207
213
|
if (rndMap.has(input))
|
|
208
|
-
return rndMap.get(input)
|
|
214
|
+
return `${rndMap.get(input)}${mode}`;
|
|
209
215
|
else {
|
|
210
216
|
const ret = RandomVariableBinding();
|
|
211
217
|
rndMap.set(input, ret);
|
|
212
|
-
return ret
|
|
218
|
+
return `${ret}${mode}`;
|
|
213
219
|
}
|
|
214
220
|
}
|
|
215
221
|
}
|
|
@@ -7,5 +7,6 @@ export declare function isOctalChar(char: string): boolean;
|
|
|
7
7
|
export declare function isCompileBinding(input: string): boolean;
|
|
8
8
|
export declare function isHasBinding(input: string): boolean;
|
|
9
9
|
export declare function isBinding(input: string): boolean;
|
|
10
|
+
export declare function isVariable(input: string): boolean;
|
|
10
11
|
export declare function isNumber(input: string): boolean;
|
|
11
12
|
export declare function isString(input: string): boolean;
|
|
@@ -17,7 +17,7 @@ export type Animation = anim.Animation<AnimType> | AnimationKeyframe<AnimType> |
|
|
|
17
17
|
export type Array2<T> = [T, T];
|
|
18
18
|
export type Array3<T> = [T, T, T];
|
|
19
19
|
export type Array4<T> = [T, T, T, T];
|
|
20
|
-
export type Value<T> = Variable | T;
|
|
20
|
+
export type Value<T> = Variable | Binding | T;
|
|
21
21
|
export type AnimValue<T> = Value<T | Animation>;
|
|
22
22
|
export type BindingItem = {
|
|
23
23
|
ignored?: Value<boolean>;
|