asajs 4.0.5-indev → 4.0.6-indev

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.
@@ -19,3 +19,6 @@ export function isOctalChar(char) {
19
19
  export function isCompileBinding(input) {
20
20
  return input.startsWith("[") && input.endsWith("]");
21
21
  }
22
+ export function isHasBinding(input) {
23
+ return /#\w+/.test(input);
24
+ }
@@ -40,6 +40,8 @@ export function Lexer(input, start = 0, end) {
40
40
  case "/":
41
41
  case "%":
42
42
  case "^":
43
+ case "?":
44
+ case ":":
43
45
  tokens.push(makeToken(input, TokenKind.OPERATOR, index));
44
46
  break;
45
47
  case "(":
@@ -3,6 +3,7 @@ import { BindingType } from "../../types/enums/BindingType.js";
3
3
  import { FunctionMap } from "./Function.js";
4
4
  import { Lexer } from "./Lexer.js";
5
5
  import { RandomBindingString } from "../../components/Utils.js";
6
+ import { isHasBinding } from "./Checker.js";
6
7
  export class Parser {
7
8
  input;
8
9
  cache;
@@ -60,11 +61,56 @@ export class Parser {
60
61
  return this.tokens[this.tokens.length - 1];
61
62
  }
62
63
  parseExpression() {
63
- return this.parseOrExpression();
64
+ return this.parseBinaryExpression();
65
+ }
66
+ parseBinaryExpression() {
67
+ let left = this.parseOrExpression(), current;
68
+ while ((current = this.at()) && current.kind === TokenKind.OPERATOR && current.value === "?") {
69
+ this.eat();
70
+ let middle = this.parseExpression(), right;
71
+ if ((current = this.at()) && current.kind === TokenKind.OPERATOR && current.value === ":") {
72
+ this.eat();
73
+ right = this.parseExpression();
74
+ }
75
+ else
76
+ this.expect(TokenKind.OPERATOR, "Unexpected token!");
77
+ let leftBind, middleBind, rightBind;
78
+ if (isHasBinding(left)) {
79
+ leftBind = RandomBindingString();
80
+ this.genBindings.push({
81
+ source: `((0 + ${left}) > 0)`,
82
+ target: leftBind,
83
+ });
84
+ }
85
+ else
86
+ this.expect(TokenKind.WORD, "Unexpected token!");
87
+ if (isHasBinding(middle)) {
88
+ middleBind = RandomBindingString();
89
+ this.genBindings.push({
90
+ source: middle,
91
+ target: middleBind,
92
+ });
93
+ }
94
+ else
95
+ this.expect(TokenKind.WORD, "Unexpected token!");
96
+ if (isHasBinding(right)) {
97
+ rightBind = RandomBindingString();
98
+ this.genBindings.push({
99
+ source: right,
100
+ target: rightBind,
101
+ });
102
+ }
103
+ else
104
+ this.expect(TokenKind.WORD, "Unexpected token!");
105
+ const ifTrueExpression = `(('prefix' + ${leftBind} + ${middleBind}) - ('prefixfalse' + ${middleBind})) - 'prefixtrue')`;
106
+ const ifFalseExpression = `(('prefix' + ${leftBind} + ${rightBind}) - ('prefixtrue' + ${rightBind})) - 'prefixfalse')`;
107
+ return `(${ifTrueExpression} + ${ifFalseExpression})`;
108
+ }
109
+ return left;
64
110
  }
65
111
  parseOrExpression() {
66
112
  let left = this.parseAndExpression(), current;
67
- while ((current = this.at()) && this.at().kind === TokenKind.OPERATOR && current.value === "||") {
113
+ while ((current = this.at()) && current.kind === TokenKind.OPERATOR && current.value === "||") {
68
114
  this.eat();
69
115
  left = `(${left} or ${this.parseAndExpression()})`;
70
116
  }
@@ -72,7 +118,7 @@ export class Parser {
72
118
  }
73
119
  parseAndExpression() {
74
120
  let left = this.parseComparisonExpression(), current;
75
- while ((current = this.at()) && this.at().kind === TokenKind.OPERATOR && current.value === "&&") {
121
+ while ((current = this.at()) && current.kind === TokenKind.OPERATOR && current.value === "&&") {
76
122
  this.eat();
77
123
  left = `(${left} and ${this.parseComparisonExpression()})`;
78
124
  }
@@ -81,7 +127,7 @@ export class Parser {
81
127
  parseComparisonExpression() {
82
128
  let left = this.parseAdditiveExpression(), current;
83
129
  while ((current = this.at()) &&
84
- this.at().kind === TokenKind.OPERATOR &&
130
+ current.kind === TokenKind.OPERATOR &&
85
131
  ["==", ">", "<", ">=", "<=", "!="].includes(current.value)) {
86
132
  const operator = this.eat();
87
133
  const right = this.parseAdditiveExpression();
@@ -106,7 +152,7 @@ export class Parser {
106
152
  parseAdditiveExpression() {
107
153
  let left = this.parseMultiplicativeExpression(), current;
108
154
  while ((current = this.at()) &&
109
- this.at()?.kind === TokenKind.OPERATOR &&
155
+ current?.kind === TokenKind.OPERATOR &&
110
156
  ["+", "-"].includes(current.value)) {
111
157
  const operator = this.eat();
112
158
  const right = this.parseMultiplicativeExpression();
@@ -117,7 +163,7 @@ export class Parser {
117
163
  parseMultiplicativeExpression() {
118
164
  let left = this.parseBitwiseLogicExpression(), current;
119
165
  while ((current = this.at()) &&
120
- this.at()?.kind === TokenKind.OPERATOR &&
166
+ current?.kind === TokenKind.OPERATOR &&
121
167
  ["*", "/", "%"].includes(current.value)) {
122
168
  const operator = this.eat();
123
169
  const right = this.parsePrimaryExpression();
@@ -143,6 +143,14 @@ export function getGamedataPath() {
143
143
  }
144
144
  }
145
145
  }
146
+ case "linux": {
147
+ const gamedata = path.join(process.env.HOME, "\\.local\\share\\mcpelauncher\\games\\com.mojang");
148
+ if (fs.existsSync(gamedata))
149
+ return (pathinfo.gamepath = gamedata);
150
+ else {
151
+ return (pathinfo.gamepath = path.join(process.env.HOME, "\\.var\\app\\io.mrarm.mcpelauncher\\data\\mcpelauncher\\games\\com.mojang"));
152
+ }
153
+ }
146
154
  default: {
147
155
  console.warn(`Your platform is not supported the install feature yet! \nYour OS version: ${os.version()}`);
148
156
  }
@@ -5,3 +5,4 @@ export declare function isHexChar(char: string): boolean;
5
5
  export declare function isBinaryChar(char: string): boolean;
6
6
  export declare function isOctalChar(char: string): boolean;
7
7
  export declare function isCompileBinding(input: string): boolean;
8
+ export declare function isHasBinding(input: string): boolean;
@@ -17,6 +17,7 @@ export declare class Parser {
17
17
  eat(): Token;
18
18
  last(): Token;
19
19
  private parseExpression;
20
+ private parseBinaryExpression;
20
21
  private parseOrExpression;
21
22
  private parseAndExpression;
22
23
  private parseComparisonExpression;
@@ -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").Value<number> | undefined;
19
- to?: import("../types/properties/value.js").Value<number> | undefined;
18
+ from?: import("../types/properties/value.js").Array2<string | number> | undefined;
19
+ to?: import("../types/properties/value.js").Array2<string | 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").Array2<string | number> | undefined;
37
- to?: import("../types/properties/value.js").Array2<string | number> | undefined;
36
+ from?: import("../types/properties/value.js").Value<number> | undefined;
37
+ to?: import("../types/properties/value.js").Value<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>>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "asajs",
3
- "version": "4.0.5-indev",
3
+ "version": "4.0.6-indev",
4
4
  "description": "Create your Minecraft JSON-UI resource packs using JavaScript",
5
5
  "keywords": [
6
6
  "Minecraft",