asajs 3.0.2 → 3.0.4
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/cjs/compilers/BindingCompiler.js +458 -0
- package/dist/cjs/compilers/BindingFunctions.js +267 -0
- package/dist/cjs/compilers/Compiler.js +158 -0
- package/dist/cjs/compilers/Compress.js +55 -0
- package/dist/cjs/compilers/Config.js +138 -0
- package/dist/cjs/compilers/Encoder.js +90 -0
- package/dist/cjs/compilers/Installer.js +123 -0
- package/dist/cjs/compilers/PreCompile.js +86 -0
- package/dist/cjs/compilers/generator/GenerateDir.js +51 -0
- package/dist/cjs/compilers/generator/JsonBuilder.js +66 -0
- package/dist/cjs/compilers/generator/LangBuilder.js +65 -0
- package/dist/cjs/compilers/generator/Log.js +45 -0
- package/dist/cjs/compilers/generator/Manifest.js +63 -0
- package/dist/cjs/compilers/generator/Save.js +87 -0
- package/dist/cjs/compilers/generator/SearchFiles.js +70 -0
- package/dist/cjs/compilers/generator/Sounds.js +91 -0
- package/dist/cjs/compilers/generator/Template.js +54 -0
- package/dist/cjs/compilers/generator/UIBuilder.js +123 -0
- package/dist/cjs/compilers/reader/Audio.js +81 -0
- package/dist/cjs/compilers/reader/Color.js +65 -0
- package/dist/cjs/compilers/reader/CurrentLine.js +36 -0
- package/dist/cjs/compilers/reader/Env.js +21 -0
- package/dist/cjs/compilers/reader/GlobalVariables.js +23 -0
- package/dist/cjs/compilers/reader/Object.js +44 -0
- package/dist/cjs/compilers/reader/ReadBinding.js +67 -0
- package/dist/cjs/compilers/reader/ReadProperties.js +118 -0
- package/dist/cjs/components/AddCollectionChill.js +41 -0
- package/dist/cjs/components/Animation.js +127 -0
- package/dist/cjs/components/AnimationKeyFrame.js +49 -0
- package/dist/cjs/components/Class.js +95 -0
- package/dist/cjs/components/LocalizeText.js +59 -0
- package/dist/cjs/components/Modify.js +377 -0
- package/dist/cjs/components/Random.js +104 -0
- package/dist/cjs/components/UI.js +387 -0
- package/dist/cjs/components/Vanilla.js +57915 -0
- package/dist/cjs/index.js +291 -0
- package/dist/cjs/package.json +1 -0
- package/dist/cjs/template.js +37 -0
- package/dist/cjs/types/components/ChildIdentifier.js +16 -0
- package/dist/cjs/types/components/Identifier.js +17 -0
- package/dist/cjs/types/components/NameCallback.js +16 -0
- package/dist/cjs/types/components/UIIdentifier.js +16 -0
- package/dist/cjs/types/components/UIInterface.js +16 -0
- package/dist/cjs/types/enums/Anchor.js +39 -0
- package/dist/cjs/types/enums/AnimTypes.js +39 -0
- package/dist/cjs/types/enums/BindingCondition.js +36 -0
- package/dist/cjs/types/enums/BindingName.js +4208 -0
- package/dist/cjs/types/enums/BindingType.js +35 -0
- package/dist/cjs/types/enums/ClipDirecion.js +35 -0
- package/dist/cjs/types/enums/Collection.js +202 -0
- package/dist/cjs/types/enums/Direction.js +33 -0
- package/dist/cjs/types/enums/EasingTypes.js +62 -0
- package/dist/cjs/types/enums/EnumColor.js +37 -0
- package/dist/cjs/types/enums/FocusNavigationMode.js +34 -0
- package/dist/cjs/types/enums/FontSize.js +34 -0
- package/dist/cjs/types/enums/FontType.js +35 -0
- package/dist/cjs/types/enums/GlobalVariables.js +345 -0
- package/dist/cjs/types/enums/InputModeCondition.js +33 -0
- package/dist/cjs/types/enums/ItemAuxID.js +31 -0
- package/dist/cjs/types/enums/JsonUIArrayName.js +36 -0
- package/dist/cjs/types/enums/MappingFrom.js +81 -0
- package/dist/cjs/types/enums/MappingTo.js +248 -0
- package/dist/cjs/types/enums/MappingTypes.js +34 -0
- package/dist/cjs/types/enums/Orientation.js +32 -0
- package/dist/cjs/types/enums/Renderer.js +68 -0
- package/dist/cjs/types/enums/Rotation.js +33 -0
- package/dist/cjs/types/enums/Scope.js +32 -0
- package/dist/cjs/types/enums/TextTypes.js +33 -0
- package/dist/cjs/types/enums/TextureFileSystem.js +41 -0
- package/dist/cjs/types/enums/Types.js +57 -0
- package/dist/cjs/types/objects/Animation.js +16 -0
- package/dist/cjs/types/objects/BindingHook.js +16 -0
- package/dist/cjs/types/objects/BindingInterface.js +16 -0
- package/dist/cjs/types/objects/ButtonMapping.js +16 -0
- package/dist/cjs/types/objects/Factory.js +16 -0
- package/dist/cjs/types/objects/Installer.js +53 -0
- package/dist/cjs/types/objects/Manifest.js +56 -0
- package/dist/cjs/types/objects/Modify.js +16 -0
- package/dist/cjs/types/objects/PropertyBag.js +16 -0
- package/dist/cjs/types/objects/Sound.js +16 -0
- package/dist/cjs/types/objects/Variables.js +16 -0
- package/dist/cjs/types/objects/elements/Button.js +17 -0
- package/dist/cjs/types/objects/elements/CollectionPanel.js +17 -0
- package/dist/cjs/types/objects/elements/Custom.js +17 -0
- package/dist/cjs/types/objects/elements/Dropdown.js +17 -0
- package/dist/cjs/types/objects/elements/EditBox.js +17 -0
- package/dist/cjs/types/objects/elements/Grid.js +16 -0
- package/dist/cjs/types/objects/elements/Image.js +17 -0
- package/dist/cjs/types/objects/elements/InputPanel.js +16 -0
- package/dist/cjs/types/objects/elements/Label.js +17 -0
- package/dist/cjs/types/objects/elements/PropertiesType.js +17 -0
- package/dist/cjs/types/objects/elements/Screen.js +17 -0
- package/dist/cjs/types/objects/elements/ScrollView.js +17 -0
- package/dist/cjs/types/objects/elements/ScrollbarBox.js +17 -0
- package/dist/cjs/types/objects/elements/ScrollbarTrack.js +17 -0
- package/dist/cjs/types/objects/elements/SelectionWheel.js +17 -0
- package/dist/cjs/types/objects/elements/Slider.js +17 -0
- package/dist/cjs/types/objects/elements/SliderBox.js +17 -0
- package/dist/cjs/types/objects/elements/StackPanel.js +16 -0
- package/dist/cjs/types/objects/elements/Toggle.js +17 -0
- package/dist/cjs/types/objects/elements/TooltipTrigger.js +16 -0
- package/dist/cjs/types/objects/elements/panel.js +16 -0
- package/dist/cjs/types/objects/properties/Buttons.js +16 -0
- package/dist/cjs/types/objects/properties/CollectionIndexs.js +16 -0
- package/dist/cjs/types/objects/properties/Collections.js +16 -0
- package/dist/cjs/types/objects/properties/Controls.js +16 -0
- package/dist/cjs/types/objects/properties/Dropdowns.js +16 -0
- package/dist/cjs/types/objects/properties/Focus.js +16 -0
- package/dist/cjs/types/objects/properties/FocusContainerCustom.js +16 -0
- package/dist/cjs/types/objects/properties/Grids.js +16 -0
- package/dist/cjs/types/objects/properties/Inputs.js +16 -0
- package/dist/cjs/types/objects/properties/Layouts.js +16 -0
- package/dist/cjs/types/objects/properties/Properties.js +16 -0
- package/dist/cjs/types/objects/properties/Renderers.js +16 -0
- package/dist/cjs/types/objects/properties/Screens.js +16 -0
- package/dist/cjs/types/objects/properties/ScrollViews.js +16 -0
- package/dist/cjs/types/objects/properties/SelectionWheels.js +16 -0
- package/dist/cjs/types/objects/properties/SliderBoxs.js +16 -0
- package/dist/cjs/types/objects/properties/Sliders.js +16 -0
- package/dist/cjs/types/objects/properties/Sounds.js +16 -0
- package/dist/cjs/types/objects/properties/Specials.js +16 -0
- package/dist/cjs/types/objects/properties/Sprites.js +16 -0
- package/dist/cjs/types/objects/properties/StackPanels.js +16 -0
- package/dist/cjs/types/objects/properties/TTS.js +16 -0
- package/dist/cjs/types/objects/properties/TextEdits.js +16 -0
- package/dist/cjs/types/objects/properties/Texts.js +16 -0
- package/dist/cjs/types/objects/properties/Toggles.js +16 -0
- package/dist/cjs/types/objects/properties/TooltipTriggers.js +16 -0
- package/dist/cjs/types/objects/properties/Variables.js +16 -0
- package/dist/cjs/types/values/Any.js +16 -0
- package/dist/cjs/types/values/Binding.js +16 -0
- package/dist/cjs/types/values/Bool.js +16 -0
- package/dist/cjs/types/values/ColorVector.js +16 -0
- package/dist/cjs/types/values/ElementPath.js +16 -0
- package/dist/cjs/types/values/Hex.js +16 -0
- package/dist/cjs/types/values/Number.js +16 -0
- package/dist/cjs/types/values/RangeVector.js +16 -0
- package/dist/cjs/types/values/Str.js +16 -0
- package/dist/cjs/types/values/StringVector.js +16 -0
- package/dist/cjs/types/values/TargetElementPath.js +16 -0
- package/dist/cjs/types/values/Variable.js +16 -0
- package/dist/cjs/types/values/Vector.js +16 -0
- package/dist/esm/index.js +68470 -0
- package/dist/esm/package.json +1 -0
- package/dist/types/compilers/BindingCompiler.d.ts +44 -0
- package/dist/types/compilers/BindingFunctions.d.ts +10 -0
- package/dist/types/compilers/Compiler.d.ts +3 -0
- package/dist/types/compilers/Compress.d.ts +1 -0
- package/dist/types/compilers/Config.d.ts +95 -0
- package/dist/types/compilers/Encoder.d.ts +11 -0
- package/dist/types/compilers/Installer.d.ts +14 -0
- package/dist/types/compilers/PreCompile.d.ts +4 -0
- package/dist/types/compilers/generator/GenerateDir.d.ts +1 -0
- package/dist/types/compilers/generator/JsonBuilder.d.ts +28 -0
- package/dist/types/compilers/generator/LangBuilder.d.ts +4 -0
- package/dist/types/compilers/generator/Log.d.ts +9 -0
- package/dist/types/compilers/generator/Manifest.d.ts +21 -0
- package/dist/types/compilers/generator/Save.d.ts +16 -0
- package/dist/types/compilers/generator/SearchFiles.d.ts +11 -0
- package/dist/types/compilers/generator/Sounds.d.ts +5 -0
- package/dist/types/compilers/generator/Template.d.ts +1 -0
- package/dist/types/compilers/generator/UIBuilder.d.ts +9 -0
- package/dist/types/compilers/reader/Audio.d.ts +1 -0
- package/dist/types/compilers/reader/Color.d.ts +5 -0
- package/dist/types/compilers/reader/CurrentLine.d.ts +1 -0
- package/dist/types/compilers/reader/Env.d.ts +1 -0
- package/dist/types/compilers/reader/GlobalVariables.d.ts +1 -0
- package/dist/types/compilers/reader/Object.d.ts +11 -0
- package/dist/types/compilers/reader/ReadBinding.d.ts +6 -0
- package/dist/types/compilers/reader/ReadProperties.d.ts +3 -0
- package/dist/types/components/AddCollectionChill.d.ts +6 -0
- package/dist/types/components/Animation.d.ts +15 -0
- package/dist/types/components/AnimationKeyFrame.d.ts +10 -0
- package/dist/types/components/Class.d.ts +68 -0
- package/dist/types/components/LocalizeText.d.ts +21 -0
- package/dist/types/components/Modify.d.ts +30 -0
- package/dist/types/components/Random.d.ts +20 -0
- package/dist/types/components/UI.d.ts +89 -0
- package/dist/types/components/Vanilla.d.ts +19729 -0
- package/dist/types/index.d.ts +136 -0
- package/dist/types/template.d.ts +4 -0
- package/dist/types/types/components/ChildIdentifier.d.ts +11 -0
- package/dist/types/types/components/Identifier.d.ts +4 -0
- package/dist/types/types/components/NameCallback.d.ts +3 -0
- package/dist/types/types/components/UIIdentifier.d.ts +4 -0
- package/dist/types/types/components/UIInterface.d.ts +16 -0
- package/dist/types/types/enums/Anchor.d.ts +11 -0
- package/dist/types/types/enums/AnimTypes.d.ts +11 -0
- package/dist/types/types/enums/BindingCondition.d.ts +8 -0
- package/dist/types/types/enums/BindingName.d.ts +4180 -0
- package/dist/types/types/enums/BindingType.d.ts +7 -0
- package/dist/types/types/enums/ClipDirecion.d.ts +7 -0
- package/dist/types/types/enums/Collection.d.ts +174 -0
- package/dist/types/types/enums/Direction.d.ts +5 -0
- package/dist/types/types/enums/EasingTypes.d.ts +34 -0
- package/dist/types/types/enums/EnumColor.d.ts +9 -0
- package/dist/types/types/enums/FocusNavigationMode.d.ts +6 -0
- package/dist/types/types/enums/FontSize.d.ts +6 -0
- package/dist/types/types/enums/FontType.d.ts +7 -0
- package/dist/types/types/enums/GlobalVariables.d.ts +317 -0
- package/dist/types/types/enums/InputModeCondition.d.ts +5 -0
- package/dist/types/types/enums/ItemAuxID.d.ts +3 -0
- package/dist/types/types/enums/JsonUIArrayName.d.ts +7 -0
- package/dist/types/types/enums/MappingFrom.d.ts +53 -0
- package/dist/types/types/enums/MappingTo.d.ts +220 -0
- package/dist/types/types/enums/MappingTypes.d.ts +6 -0
- package/dist/types/types/enums/Orientation.d.ts +4 -0
- package/dist/types/types/enums/Renderer.d.ts +40 -0
- package/dist/types/types/enums/Rotation.d.ts +5 -0
- package/dist/types/types/enums/Scope.d.ts +4 -0
- package/dist/types/types/enums/TextTypes.d.ts +5 -0
- package/dist/types/types/enums/TextureFileSystem.d.ts +13 -0
- package/dist/types/types/enums/Types.d.ts +29 -0
- package/dist/types/types/objects/Animation.d.ts +36 -0
- package/dist/types/types/objects/BindingHook.d.ts +1 -0
- package/dist/types/types/objects/BindingInterface.d.ts +21 -0
- package/dist/types/types/objects/ButtonMapping.d.ts +18 -0
- package/dist/types/types/objects/Factory.d.ts +2 -0
- package/dist/types/types/objects/Installer.d.ts +26 -0
- package/dist/types/types/objects/Manifest.d.ts +74 -0
- package/dist/types/types/objects/Modify.d.ts +52 -0
- package/dist/types/types/objects/PropertyBag.d.ts +2 -0
- package/dist/types/types/objects/Sound.d.ts +8 -0
- package/dist/types/types/objects/Variables.d.ts +1 -0
- package/dist/types/types/objects/elements/Button.d.ts +4 -0
- package/dist/types/types/objects/elements/CollectionPanel.d.ts +4 -0
- package/dist/types/types/objects/elements/Custom.d.ts +5 -0
- package/dist/types/types/objects/elements/Dropdown.d.ts +4 -0
- package/dist/types/types/objects/elements/EditBox.d.ts +4 -0
- package/dist/types/types/objects/elements/Grid.d.ts +4 -0
- package/dist/types/types/objects/elements/Image.d.ts +4 -0
- package/dist/types/types/objects/elements/InputPanel.d.ts +7 -0
- package/dist/types/types/objects/elements/Label.d.ts +4 -0
- package/dist/types/types/objects/elements/PropertiesType.d.ts +45 -0
- package/dist/types/types/objects/elements/Screen.d.ts +4 -0
- package/dist/types/types/objects/elements/ScrollView.d.ts +5 -0
- package/dist/types/types/objects/elements/ScrollbarBox.d.ts +4 -0
- package/dist/types/types/objects/elements/ScrollbarTrack.d.ts +4 -0
- package/dist/types/types/objects/elements/SelectionWheel.d.ts +4 -0
- package/dist/types/types/objects/elements/Slider.d.ts +4 -0
- package/dist/types/types/objects/elements/SliderBox.d.ts +5 -0
- package/dist/types/types/objects/elements/StackPanel.d.ts +7 -0
- package/dist/types/types/objects/elements/Toggle.d.ts +4 -0
- package/dist/types/types/objects/elements/TooltipTrigger.d.ts +8 -0
- package/dist/types/types/objects/elements/panel.d.ts +6 -0
- package/dist/types/types/objects/properties/Buttons.d.ts +5 -0
- package/dist/types/types/objects/properties/CollectionIndexs.d.ts +4 -0
- package/dist/types/types/objects/properties/Collections.d.ts +6 -0
- package/dist/types/types/objects/properties/Controls.d.ts +27 -0
- package/dist/types/types/objects/properties/Dropdowns.d.ts +6 -0
- package/dist/types/types/objects/properties/Focus.d.ts +28 -0
- package/dist/types/types/objects/properties/FocusContainerCustom.d.ts +5 -0
- package/dist/types/types/objects/properties/Grids.d.ts +15 -0
- package/dist/types/types/objects/properties/Inputs.d.ts +13 -0
- package/dist/types/types/objects/properties/Layouts.d.ts +35 -0
- package/dist/types/types/objects/properties/Properties.d.ts +27 -0
- package/dist/types/types/objects/properties/Renderers.d.ts +5 -0
- package/dist/types/types/objects/properties/Screens.d.ts +23 -0
- package/dist/types/types/objects/properties/ScrollViews.d.ts +17 -0
- package/dist/types/types/objects/properties/SelectionWheels.d.ts +13 -0
- package/dist/types/types/objects/properties/SliderBoxs.d.ts +6 -0
- package/dist/types/types/objects/properties/Sliders.d.ts +23 -0
- package/dist/types/types/objects/properties/Sounds.d.ts +10 -0
- package/dist/types/types/objects/properties/Specials.d.ts +60 -0
- package/dist/types/types/objects/properties/Sprites.d.ts +33 -0
- package/dist/types/types/objects/properties/StackPanels.d.ts +5 -0
- package/dist/types/types/objects/properties/TTS.d.ts +24 -0
- package/dist/types/types/objects/properties/TextEdits.d.ts +19 -0
- package/dist/types/types/objects/properties/Texts.d.ts +26 -0
- package/dist/types/types/objects/properties/Toggles.d.ts +24 -0
- package/dist/types/types/objects/properties/TooltipTriggers.d.ts +7 -0
- package/dist/types/types/objects/properties/Variables.d.ts +3 -0
- package/dist/types/types/values/Any.d.ts +4 -0
- package/dist/types/types/values/Binding.d.ts +2 -0
- package/dist/types/types/values/Bool.d.ts +2 -0
- package/dist/types/types/values/ColorVector.d.ts +6 -0
- package/dist/types/types/values/ElementPath.d.ts +2 -0
- package/dist/types/types/values/Hex.d.ts +1 -0
- package/dist/types/types/values/Number.d.ts +4 -0
- package/dist/types/types/values/RangeVector.d.ts +5 -0
- package/dist/types/types/values/Str.d.ts +2 -0
- package/dist/types/types/values/StringVector.d.ts +6 -0
- package/dist/types/types/values/TargetElementPath.d.ts +1 -0
- package/dist/types/types/values/Variable.d.ts +1 -0
- package/dist/types/types/values/Vector.d.ts +5 -0
- package/package.json +4 -4
|
@@ -0,0 +1,458 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var BindingCompiler_exports = {};
|
|
20
|
+
__export(BindingCompiler_exports, {
|
|
21
|
+
BindingCompiler: () => BindingCompiler
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(BindingCompiler_exports);
|
|
24
|
+
var import_Random = require("../components/Random");
|
|
25
|
+
var import_BindingFunctions = require("./BindingFunctions");
|
|
26
|
+
var import_Log = require("./generator/Log");
|
|
27
|
+
var import_CurrentLine = require("./reader/CurrentLine");
|
|
28
|
+
class BindingCompiler {
|
|
29
|
+
static compile(propertyName, arg) {
|
|
30
|
+
return this.build(this.getCompilePart(propertyName), arg).replace(/__BREAK_LINE__/g, "\n");
|
|
31
|
+
}
|
|
32
|
+
static getCompilePart(propertyName) {
|
|
33
|
+
return Array.isArray(propertyName) ? propertyName[0] : propertyName.slice(1, propertyName.length - 1);
|
|
34
|
+
}
|
|
35
|
+
static build(propertyName, arg) {
|
|
36
|
+
const tokens = this.lexer(propertyName, arg);
|
|
37
|
+
let build = "(";
|
|
38
|
+
for (let index = 0; index < tokens.length; index++) {
|
|
39
|
+
let token = tokens[index];
|
|
40
|
+
if (this.isScientificNotation(token)) {
|
|
41
|
+
const [left, right] = token.split("e");
|
|
42
|
+
token = "" + Number(left) * Math.pow(10, Number(right));
|
|
43
|
+
}
|
|
44
|
+
if (token === "!") build += "not ";
|
|
45
|
+
else {
|
|
46
|
+
if (this.isNegativeNumber(token) && !this.isOperator(tokens[index - 1]) && tokens[index - 1] !== void 0) {
|
|
47
|
+
build += "- ".concat(token.slice(1), " ");
|
|
48
|
+
} else build += "".concat(token, " ");
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
build = "".concat(build.slice(0, build.length - 1), ")");
|
|
52
|
+
return build;
|
|
53
|
+
}
|
|
54
|
+
static buildNewPropertyBag(token, arg) {
|
|
55
|
+
const bindingName = import_Random.Random.bindingName();
|
|
56
|
+
arg.setProperties({
|
|
57
|
+
property_bag: {
|
|
58
|
+
[bindingName]: BindingCompiler.build(token, arg)
|
|
59
|
+
}
|
|
60
|
+
});
|
|
61
|
+
return bindingName;
|
|
62
|
+
}
|
|
63
|
+
static checkAndBuild(token, arg) {
|
|
64
|
+
return this.isHasBinding(token) ? this.build(token, arg) : this.buildNewPropertyBag(token, arg);
|
|
65
|
+
}
|
|
66
|
+
static compileSpecialOperator(tokens, arg) {
|
|
67
|
+
let firstTokens = [];
|
|
68
|
+
if (tokens.includes("?")) {
|
|
69
|
+
const startIndex = tokens.indexOf("?");
|
|
70
|
+
firstTokens.push(...tokens.slice(0, startIndex));
|
|
71
|
+
let elseCount = 0;
|
|
72
|
+
const secondTokens = [];
|
|
73
|
+
const thirdTokens = [];
|
|
74
|
+
let questionCount = 1;
|
|
75
|
+
let endIndex = -1;
|
|
76
|
+
for (let index = startIndex + 1; index < tokens.length; index++) {
|
|
77
|
+
const token = tokens[index];
|
|
78
|
+
if (token === "?") questionCount++;
|
|
79
|
+
else if (token === ":" && --questionCount == 0) {
|
|
80
|
+
endIndex = index;
|
|
81
|
+
elseCount++;
|
|
82
|
+
break;
|
|
83
|
+
}
|
|
84
|
+
secondTokens.push(token);
|
|
85
|
+
}
|
|
86
|
+
thirdTokens.push(...tokens.slice(endIndex + 1));
|
|
87
|
+
const generateBindingName = import_Random.Random.bindingName();
|
|
88
|
+
const firstBinding = this.checkAndBuild(firstTokens.join(""), arg);
|
|
89
|
+
const secondBinding = "".concat(generateBindingName, "true");
|
|
90
|
+
const thirdBinding = "".concat(generateBindingName, "false");
|
|
91
|
+
arg.addBindings([
|
|
92
|
+
{
|
|
93
|
+
source_property_name: this.checkAndBuild(secondTokens.join(""), arg),
|
|
94
|
+
target_property_name: secondBinding
|
|
95
|
+
},
|
|
96
|
+
{
|
|
97
|
+
source_property_name: ["'".concat(generateBindingName, "{").concat(firstBinding, "}'")],
|
|
98
|
+
target_property_name: generateBindingName
|
|
99
|
+
}
|
|
100
|
+
]);
|
|
101
|
+
if (elseCount !== 0) {
|
|
102
|
+
arg.addBindings({
|
|
103
|
+
source_property_name: this.checkAndBuild(thirdTokens.join(""), arg),
|
|
104
|
+
target_property_name: thirdBinding
|
|
105
|
+
});
|
|
106
|
+
}
|
|
107
|
+
return [generateBindingName];
|
|
108
|
+
} else if (tokens.includes("==")) {
|
|
109
|
+
const preBuild = [];
|
|
110
|
+
let strToken = [];
|
|
111
|
+
for (const token of tokens) {
|
|
112
|
+
if (token === "==") {
|
|
113
|
+
const binding = this.buildNewBinding(strToken.join(""), arg);
|
|
114
|
+
strToken = [];
|
|
115
|
+
preBuild.push(...[binding, "="]);
|
|
116
|
+
} else {
|
|
117
|
+
strToken.push(token);
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
preBuild.push(this.buildNewBinding(strToken.join(""), arg));
|
|
121
|
+
strToken = [];
|
|
122
|
+
const build = [];
|
|
123
|
+
for (let i = 0; i < preBuild.length; i++) {
|
|
124
|
+
if (preBuild[i] === "=") {
|
|
125
|
+
if (build.length > 0) build.push("&");
|
|
126
|
+
const [preToken, token, nextToken] = [
|
|
127
|
+
preBuild[i - 1],
|
|
128
|
+
preBuild[i],
|
|
129
|
+
preBuild[i + 1]
|
|
130
|
+
];
|
|
131
|
+
build.push(this.buildNewBinding("".concat(preToken, " ").concat(token, " ").concat(nextToken), arg));
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
return build;
|
|
135
|
+
} else {
|
|
136
|
+
for (let index = 0; index < tokens.length; index++) {
|
|
137
|
+
const token = tokens[index];
|
|
138
|
+
if (["&&", "||", "&", "|"].includes(token)) {
|
|
139
|
+
const secondTokens = tokens.slice(index + 1);
|
|
140
|
+
const firstBinding = firstTokens.length === 1 ? firstTokens[0] : this.buildNewBinding(firstTokens.join(" "), arg);
|
|
141
|
+
const secondBinding = secondTokens.length === 1 ? secondTokens[0] : this.buildNewBinding(tokens.slice(index + 1).join(" "), arg);
|
|
142
|
+
return [
|
|
143
|
+
firstBinding,
|
|
144
|
+
["&&", "&"].includes(token) ? "and" : "or",
|
|
145
|
+
secondBinding
|
|
146
|
+
];
|
|
147
|
+
} else firstTokens.push(token);
|
|
148
|
+
}
|
|
149
|
+
firstTokens = firstTokens.slice(firstTokens.length);
|
|
150
|
+
for (let index = 0; index < tokens.length; index++) {
|
|
151
|
+
const token = tokens[index];
|
|
152
|
+
if (["%", ">=", "<=", "!="].includes(token)) {
|
|
153
|
+
const secondTokens = tokens.slice(index + 1);
|
|
154
|
+
const firstBinding = firstTokens.length === 1 ? firstTokens[0] : this.buildNewBinding(firstTokens.join(""), arg);
|
|
155
|
+
const secondBinding = secondTokens.length === 1 ? secondTokens[0] : this.buildNewBinding(tokens.slice(index + 1).join(""), arg);
|
|
156
|
+
switch (token) {
|
|
157
|
+
case ">=": {
|
|
158
|
+
return [
|
|
159
|
+
"(",
|
|
160
|
+
firstBinding,
|
|
161
|
+
">",
|
|
162
|
+
secondBinding,
|
|
163
|
+
")",
|
|
164
|
+
"or",
|
|
165
|
+
"(",
|
|
166
|
+
firstBinding,
|
|
167
|
+
"=",
|
|
168
|
+
secondBinding,
|
|
169
|
+
")"
|
|
170
|
+
];
|
|
171
|
+
}
|
|
172
|
+
case "<=": {
|
|
173
|
+
return [
|
|
174
|
+
"(",
|
|
175
|
+
firstBinding,
|
|
176
|
+
"<",
|
|
177
|
+
secondBinding,
|
|
178
|
+
")",
|
|
179
|
+
"or",
|
|
180
|
+
"(",
|
|
181
|
+
firstBinding,
|
|
182
|
+
"=",
|
|
183
|
+
secondBinding,
|
|
184
|
+
")"
|
|
185
|
+
];
|
|
186
|
+
}
|
|
187
|
+
case "!=": {
|
|
188
|
+
return [
|
|
189
|
+
"not",
|
|
190
|
+
this.buildNewBinding("".concat(firstBinding, " = ").concat(secondBinding), arg)
|
|
191
|
+
];
|
|
192
|
+
}
|
|
193
|
+
case "%": {
|
|
194
|
+
return [
|
|
195
|
+
firstBinding,
|
|
196
|
+
"-",
|
|
197
|
+
firstBinding,
|
|
198
|
+
"/",
|
|
199
|
+
secondBinding,
|
|
200
|
+
"*",
|
|
201
|
+
secondBinding
|
|
202
|
+
];
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
} else firstTokens.push(token);
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
return firstTokens;
|
|
209
|
+
}
|
|
210
|
+
static lexer(propertyName, arg) {
|
|
211
|
+
const getTokens = this.compileSpecialOperator(
|
|
212
|
+
this.readTokens(this.getTokens(this.splitString(propertyName))).map((token) => {
|
|
213
|
+
if (this.isCodeBlock(token))
|
|
214
|
+
return this.buildNewBinding(token.slice(1, token.length - 1), arg);
|
|
215
|
+
else if (this.isFunction(token)) {
|
|
216
|
+
return this.functionHandler(token, arg);
|
|
217
|
+
} else if (this.isString(token)) {
|
|
218
|
+
return this.stringHandler(token, arg);
|
|
219
|
+
} else return token;
|
|
220
|
+
}),
|
|
221
|
+
arg
|
|
222
|
+
);
|
|
223
|
+
return getTokens;
|
|
224
|
+
}
|
|
225
|
+
static splitString(propertyName) {
|
|
226
|
+
const tokens = [];
|
|
227
|
+
let token = "", openFormatCount = 0, isString = false;
|
|
228
|
+
for (const char of propertyName) {
|
|
229
|
+
if (char === "'" && openFormatCount === 0) {
|
|
230
|
+
isString = !isString;
|
|
231
|
+
if (token !== "" || !isString) tokens.push(isString ? token : "'".concat(token, "'"));
|
|
232
|
+
token = "";
|
|
233
|
+
} else if (char === "\n" && isString) {
|
|
234
|
+
token += "__BREAK_LINE__";
|
|
235
|
+
} else if (char === "{" && isString) {
|
|
236
|
+
openFormatCount++;
|
|
237
|
+
token += "{";
|
|
238
|
+
} else if (char === "}" && isString) {
|
|
239
|
+
openFormatCount--;
|
|
240
|
+
token += "}";
|
|
241
|
+
} else if (char !== " " || isString) {
|
|
242
|
+
token += char;
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
if (token !== "") tokens.push(token);
|
|
246
|
+
return tokens;
|
|
247
|
+
}
|
|
248
|
+
static stringHandler(token, arg) {
|
|
249
|
+
const tokens = this.getStringTokens(token.slice(1, token.length - 1)).map((token2) => {
|
|
250
|
+
if (this.isStringCode(token2))
|
|
251
|
+
return BindingCompiler.build(token2.slice(1, token2.length - 1), arg);
|
|
252
|
+
else return "'".concat(token2, "'");
|
|
253
|
+
}).filter((token2) => !["'{}'", ")"].includes(token2));
|
|
254
|
+
return tokens.length > 1 ? "(".concat(tokens.join(" + "), ")") : tokens[0] || "''";
|
|
255
|
+
}
|
|
256
|
+
static getStringTokens(token) {
|
|
257
|
+
const tokens = [];
|
|
258
|
+
let bracketsCount = 0, strToken = "";
|
|
259
|
+
for (const char of token) {
|
|
260
|
+
if (char === "{") {
|
|
261
|
+
if (bracketsCount++ === 0 && strToken !== "") {
|
|
262
|
+
tokens.push(strToken);
|
|
263
|
+
strToken = "";
|
|
264
|
+
}
|
|
265
|
+
strToken += char;
|
|
266
|
+
} else if (char === "}") {
|
|
267
|
+
strToken += char;
|
|
268
|
+
if (--bracketsCount === 0 && strToken !== "") {
|
|
269
|
+
tokens.push(strToken);
|
|
270
|
+
strToken = "";
|
|
271
|
+
}
|
|
272
|
+
} else strToken += char;
|
|
273
|
+
}
|
|
274
|
+
if (strToken !== "") tokens.push(strToken);
|
|
275
|
+
return tokens;
|
|
276
|
+
}
|
|
277
|
+
static functionHandler(token, arg) {
|
|
278
|
+
const func = this.readFunctionFromToken(this.getTokens(this.splitString(token)), arg);
|
|
279
|
+
let str = "";
|
|
280
|
+
if (import_BindingFunctions.funcObj[func.name]) {
|
|
281
|
+
str = import_BindingFunctions.funcObj[func.name](
|
|
282
|
+
arg,
|
|
283
|
+
func.params.map((token2) => {
|
|
284
|
+
token2 = token2.replace(/__BREAK_LINE__/g, "\n");
|
|
285
|
+
return this.isStringPattern(token2) ? this.build("(".concat(token2, ")"), arg) : token2;
|
|
286
|
+
})
|
|
287
|
+
);
|
|
288
|
+
} else {
|
|
289
|
+
import_Log.Log.error("".concat((0, import_CurrentLine.CurrentLine)(), " binding function '").concat(func.name, "' does not exist!"));
|
|
290
|
+
str = "'[Compile Error]: function >>".concat(func.name, "<< not found!'");
|
|
291
|
+
}
|
|
292
|
+
return str;
|
|
293
|
+
}
|
|
294
|
+
static readFunctionFromToken(tokens, arg) {
|
|
295
|
+
const name = tokens[0];
|
|
296
|
+
tokens = tokens.slice(2, tokens.length - 1);
|
|
297
|
+
const params = [];
|
|
298
|
+
let param = "", $ = 0;
|
|
299
|
+
for (const token of tokens) {
|
|
300
|
+
if (token === "," && !$) {
|
|
301
|
+
params.push(param);
|
|
302
|
+
param = "";
|
|
303
|
+
} else if (token === "(") {
|
|
304
|
+
$++;
|
|
305
|
+
param += token;
|
|
306
|
+
} else if (token === ")") {
|
|
307
|
+
$--;
|
|
308
|
+
param += token;
|
|
309
|
+
} else param += token;
|
|
310
|
+
}
|
|
311
|
+
if (param !== "") params.push(param);
|
|
312
|
+
return {
|
|
313
|
+
name,
|
|
314
|
+
params: params.map((token) => {
|
|
315
|
+
if (this.getTokens(this.splitString(token)).length > 1)
|
|
316
|
+
return this.build(this.isCodeBlock(token) ? token : "(".concat(token, ")"), arg);
|
|
317
|
+
else return token;
|
|
318
|
+
})
|
|
319
|
+
};
|
|
320
|
+
}
|
|
321
|
+
static readTokens(strTokens) {
|
|
322
|
+
const tokens = [];
|
|
323
|
+
let strToken = "";
|
|
324
|
+
let functionName = null, brackets = 0;
|
|
325
|
+
for (const token of strTokens) {
|
|
326
|
+
if (this.maybeFunctionName(token) && !brackets) {
|
|
327
|
+
if (functionName) tokens.push(functionName);
|
|
328
|
+
functionName = token;
|
|
329
|
+
} else if (["(", ")"].includes(token)) {
|
|
330
|
+
if (functionName) {
|
|
331
|
+
strToken += functionName;
|
|
332
|
+
functionName = null;
|
|
333
|
+
}
|
|
334
|
+
if (token === "(") brackets++;
|
|
335
|
+
else brackets--;
|
|
336
|
+
strToken += token;
|
|
337
|
+
if (brackets === 0) {
|
|
338
|
+
tokens.push(strToken);
|
|
339
|
+
strToken = "";
|
|
340
|
+
}
|
|
341
|
+
} else {
|
|
342
|
+
if (brackets) strToken += token;
|
|
343
|
+
else if (functionName) {
|
|
344
|
+
tokens.push(functionName);
|
|
345
|
+
functionName = null;
|
|
346
|
+
tokens.push(token);
|
|
347
|
+
} else tokens.push(token);
|
|
348
|
+
}
|
|
349
|
+
}
|
|
350
|
+
if (functionName) tokens.push(functionName);
|
|
351
|
+
return tokens;
|
|
352
|
+
}
|
|
353
|
+
static getTokens(strTokens) {
|
|
354
|
+
var _a;
|
|
355
|
+
const tokens = [];
|
|
356
|
+
for (const token of strTokens) {
|
|
357
|
+
if (this.isString(token)) tokens.push(token);
|
|
358
|
+
else
|
|
359
|
+
tokens.push(
|
|
360
|
+
...(_a = token.match(
|
|
361
|
+
/-?((\d+\.)?\d+)(e-?\d+)?|[#$]?\w+|[><=!]?=|(&&|\|\|)|[\[\]()+\-*\/=><!,&%|?:]/gm
|
|
362
|
+
)) != null ? _a : []
|
|
363
|
+
);
|
|
364
|
+
}
|
|
365
|
+
return tokens;
|
|
366
|
+
}
|
|
367
|
+
static buildNewBinding(token, arg) {
|
|
368
|
+
const rndName = import_Random.Random.bindingName();
|
|
369
|
+
if (this.isHasBinding(token)) {
|
|
370
|
+
if (this.isBindingOrVariable(token)) return token;
|
|
371
|
+
arg.addBindings({
|
|
372
|
+
source_property_name: [token],
|
|
373
|
+
target_property_name: rndName
|
|
374
|
+
});
|
|
375
|
+
} else {
|
|
376
|
+
arg.setProperties({
|
|
377
|
+
property_bag: {
|
|
378
|
+
[rndName]: this.compile(token, arg)
|
|
379
|
+
}
|
|
380
|
+
});
|
|
381
|
+
}
|
|
382
|
+
return rndName;
|
|
383
|
+
}
|
|
384
|
+
static findSourceBindings(token, sourceControlsName, lastResourceBindings) {
|
|
385
|
+
const reSourceBindings = lastResourceBindings || {};
|
|
386
|
+
const newTokens = [];
|
|
387
|
+
this.getTokens(this.splitString(token)).forEach((token2) => {
|
|
388
|
+
var _a;
|
|
389
|
+
if (this.isBindingOrVariable(token2)) {
|
|
390
|
+
newTokens.push(
|
|
391
|
+
reSourceBindings[_a = "".concat(token2, ":").concat(sourceControlsName)] || (reSourceBindings[_a] = import_Random.Random.bindingName())
|
|
392
|
+
);
|
|
393
|
+
} else if (this.isString(token2)) {
|
|
394
|
+
newTokens.push(
|
|
395
|
+
this.getStringTokens(token2).map((token3) => {
|
|
396
|
+
if (this.isStringCode(token3)) {
|
|
397
|
+
const sourceBindings = this.findSourceBindings(
|
|
398
|
+
token3.slice(1, token3.length - 1),
|
|
399
|
+
sourceControlsName,
|
|
400
|
+
reSourceBindings
|
|
401
|
+
);
|
|
402
|
+
for (const key in sourceBindings.reSourceBindings)
|
|
403
|
+
reSourceBindings[key] = sourceBindings.reSourceBindings[key];
|
|
404
|
+
return "{".concat(sourceBindings.newTokens.join(""), "}");
|
|
405
|
+
} else return token3;
|
|
406
|
+
}).join("")
|
|
407
|
+
);
|
|
408
|
+
} else newTokens.push(token2);
|
|
409
|
+
});
|
|
410
|
+
return { reSourceBindings, newTokens };
|
|
411
|
+
}
|
|
412
|
+
static isCanCompile(token) {
|
|
413
|
+
return Array.isArray(token) || token.startsWith("[") && token.endsWith("]");
|
|
414
|
+
}
|
|
415
|
+
static isString(token) {
|
|
416
|
+
return /^'.+'$/.test(token) || token === "''";
|
|
417
|
+
}
|
|
418
|
+
static isStringCode(token) {
|
|
419
|
+
return /^{.+}$/.test(token);
|
|
420
|
+
}
|
|
421
|
+
static isStringPattern(token) {
|
|
422
|
+
return this.isString(token) && /\{.+\}/.test(token);
|
|
423
|
+
}
|
|
424
|
+
static isNegativeNumber(token) {
|
|
425
|
+
return /^-((\d+\.)?\d+)$/.test(token);
|
|
426
|
+
}
|
|
427
|
+
static isScientificNotation(token) {
|
|
428
|
+
return /^-?((\d+\.)?\d+)(e-?\d+)$/.test(token);
|
|
429
|
+
}
|
|
430
|
+
static isFunction(token) {
|
|
431
|
+
return /^\w+\(.*\)$/.test(token);
|
|
432
|
+
}
|
|
433
|
+
static isArray(token) {
|
|
434
|
+
return /^\[.*\]$/.test(token);
|
|
435
|
+
}
|
|
436
|
+
static isCodeBlock(token) {
|
|
437
|
+
return /^\(.+\)$/.test(token);
|
|
438
|
+
}
|
|
439
|
+
static maybeFunctionName(token) {
|
|
440
|
+
return /^\w+$/.test(token);
|
|
441
|
+
}
|
|
442
|
+
static isBindingOrVariable(token) {
|
|
443
|
+
return /^[#$]\w+$/.test(token);
|
|
444
|
+
}
|
|
445
|
+
static isOperator(token) {
|
|
446
|
+
return /^[+\-*\/%><=!&|]$|^[><=!]=$/.test(token);
|
|
447
|
+
}
|
|
448
|
+
static isHasBinding(token) {
|
|
449
|
+
return /#\w+/.test(token);
|
|
450
|
+
}
|
|
451
|
+
static isNumber(value) {
|
|
452
|
+
return /^(\d+|\d+\.\d+|-\d+|-\d+\.\d+)$/.test(value);
|
|
453
|
+
}
|
|
454
|
+
}
|
|
455
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
456
|
+
0 && (module.exports = {
|
|
457
|
+
BindingCompiler
|
|
458
|
+
});
|