asajs 4.1.6 → 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 +26 -0
- package/dist/types/compilers/bindings/Checker.d.ts +1 -0
- package/dist/types/compilers/bindings/Function.d.ts +4 -0
- package/dist/types/components/Utils.d.ts +4 -2
- 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
|
|
@@ -166,6 +166,13 @@ export function RandomBindingString(length = 16, base = 32, force) {
|
|
|
166
166
|
else
|
|
167
167
|
return `#${StringID}_binding_${rndStrBind++}`;
|
|
168
168
|
}
|
|
169
|
+
let rndVarBind = 1;
|
|
170
|
+
export function RandomVariableBinding(length = 16, base = 32, force) {
|
|
171
|
+
if (force || allowRandomStringName)
|
|
172
|
+
return `$${GenRandomString(length, base)}`;
|
|
173
|
+
else
|
|
174
|
+
return `$${StringID}_binding_${rndVarBind++}`;
|
|
175
|
+
}
|
|
169
176
|
const rndMap = new Map();
|
|
170
177
|
export function s(input) {
|
|
171
178
|
if (isNotObfuscate)
|
|
@@ -193,6 +200,25 @@ export function bs(input) {
|
|
|
193
200
|
}
|
|
194
201
|
}
|
|
195
202
|
}
|
|
203
|
+
export function vs(input) {
|
|
204
|
+
let [name, mode] = input.split("|");
|
|
205
|
+
input = name;
|
|
206
|
+
if (mode)
|
|
207
|
+
mode = "|" + mode;
|
|
208
|
+
else
|
|
209
|
+
mode = "";
|
|
210
|
+
if (isNotObfuscate)
|
|
211
|
+
return `${name}${mode}`;
|
|
212
|
+
else {
|
|
213
|
+
if (rndMap.has(input))
|
|
214
|
+
return `${rndMap.get(input)}${mode}`;
|
|
215
|
+
else {
|
|
216
|
+
const ret = RandomVariableBinding();
|
|
217
|
+
rndMap.set(input, ret);
|
|
218
|
+
return `${ret}${mode}`;
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
}
|
|
196
222
|
export function GetItemByAuxID(auxID) {
|
|
197
223
|
const item = ItemAuxID[auxID];
|
|
198
224
|
if (item)
|
|
@@ -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;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Type } from "../types/enums/Type.js";
|
|
2
|
-
import { Array3, Binding, BindingItem } from "../types/properties/value.js";
|
|
2
|
+
import { Array3, Binding, BindingItem, Variable } from "../types/properties/value.js";
|
|
3
3
|
import { ModifyUI, UI } from "./UI.js";
|
|
4
4
|
import { Renderer } from "../types/enums/Renderer.js";
|
|
5
5
|
import { Properties, CollectionPanel, Grid, Image, InputPanel, Label, Panel, Screen, StackPanel, TooltipTrigger, Button, Toggle, Dropdown, SelectionWheel, EditBox, ScrollbarBox, ScrollbarTrack, ScrollView, Slider, SliderBox } from "../types/properties/components.js";
|
|
@@ -19,8 +19,10 @@ 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
23
|
export declare function s(input: string): string;
|
|
23
|
-
export declare function bs(input:
|
|
24
|
+
export declare function bs(input: Binding): Binding;
|
|
25
|
+
export declare function vs(input: Variable): Variable;
|
|
24
26
|
export declare function GetItemByAuxID(auxID: number): string | undefined;
|
|
25
27
|
/**
|
|
26
28
|
* Return format string binding input
|
|
@@ -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>;
|