mlogjs 0.5.2 → 0.6.0

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.
Files changed (79) hide show
  1. package/README.md +2 -2
  2. package/dist/{index.cjs → Compiler-7GMG4MDr.js} +1746 -452
  3. package/dist/Compiler.d.ts +8 -12
  4. package/dist/CompilerError.d.ts +13 -3
  5. package/dist/Scope.d.ts +8 -8
  6. package/dist/bin/files.d.ts +18 -0
  7. package/dist/bin.mjs +170 -0
  8. package/dist/handlers/Import.d.ts +5 -0
  9. package/dist/handlers/Literal.d.ts +2 -2
  10. package/dist/handlers/Typescript.d.ts +2 -2
  11. package/dist/handlers/index.d.ts +1 -0
  12. package/dist/index.mjs +3 -4267
  13. package/dist/instructions/AddressResolver.d.ts +4 -4
  14. package/dist/instructions/ControlInstructions.d.ts +3 -3
  15. package/dist/instructions/InstructionBase.d.ts +1 -0
  16. package/dist/instructions/JumpInstruction.d.ts +5 -5
  17. package/dist/instructions/index.d.ts +0 -1
  18. package/dist/macros/DynamicArray.d.ts +4 -4
  19. package/dist/macros/Function.d.ts +2 -2
  20. package/dist/macros/GetBuildings.d.ts +4 -0
  21. package/dist/macros/GetColor.d.ts +4 -0
  22. package/dist/macros/Marker.d.ts +4 -0
  23. package/dist/macros/Namespace.d.ts +16 -0
  24. package/dist/macros/Queries.d.ts +10 -0
  25. package/dist/macros/StringView.d.ts +4 -0
  26. package/dist/macros/commands/Effect.d.ts +4 -0
  27. package/dist/macros/commands/Format.d.ts +4 -0
  28. package/dist/macros/commands/LocalePrint.d.ts +4 -0
  29. package/dist/macros/commands/PlayMusic.d.ts +4 -0
  30. package/dist/macros/commands/PlaySound.d.ts +4 -0
  31. package/dist/macros/commands/PrintChar.d.ts +4 -0
  32. package/dist/macros/commands/Query.d.ts +4 -0
  33. package/dist/macros/commands/SetProp.d.ts +4 -0
  34. package/dist/macros/commands/SpawnBullet.d.ts +4 -0
  35. package/dist/macros/commands/Sync.d.ts +6 -0
  36. package/dist/macros/commands/UnpackColor.d.ts +4 -0
  37. package/dist/macros/commands/WeatherSense.d.ts +4 -0
  38. package/dist/macros/commands/WeatherSet.d.ts +4 -0
  39. package/dist/macros/commands/index.d.ts +13 -0
  40. package/dist/macros/index.d.ts +7 -1
  41. package/dist/macros/util.d.ts +5 -2
  42. package/dist/modules.d.ts +8 -0
  43. package/dist/operators.d.ts +1 -1
  44. package/dist/types.d.ts +84 -59
  45. package/dist/utils/constants.d.ts +9 -4
  46. package/dist/utils/general.d.ts +8 -9
  47. package/dist/utils/instruction.d.ts +5 -1
  48. package/dist/utils/value.d.ts +14 -5
  49. package/dist/values/AssignmentValue.d.ts +1 -1
  50. package/dist/values/BaseValue.d.ts +4 -2
  51. package/dist/values/DestructuringValue.d.ts +5 -7
  52. package/dist/values/FunctionValue.d.ts +8 -6
  53. package/dist/values/JumpOutValue.d.ts +4 -4
  54. package/dist/values/LazyValue.d.ts +3 -3
  55. package/dist/values/LiteralValue.d.ts +2 -3
  56. package/dist/values/ObjectValue.d.ts +6 -11
  57. package/dist/values/StoreValue.d.ts +10 -5
  58. package/dist/values/VoidValue.d.ts +2 -1
  59. package/dist/values/index.d.ts +0 -1
  60. package/lib/commands.d.ts +776 -730
  61. package/lib/eslib/lib.es2015.collection.d.ts +50 -39
  62. package/lib/eslib/lib.es2015.core.d.ts +59 -0
  63. package/lib/eslib/lib.es2015.d.ts +0 -3
  64. package/lib/eslib/lib.es2015.generator.d.ts +54 -53
  65. package/lib/eslib/lib.es2015.iterable.d.ts +9 -6
  66. package/lib/eslib/lib.es5.d.ts +53 -6
  67. package/lib/globals.d.ts +309 -18
  68. package/lib/helpers.d.ts +86 -52
  69. package/lib/kinds.d.ts +42 -7
  70. package/lib/macros.d.ts +53 -18
  71. package/lib/traits.d.ts +308 -146
  72. package/lib/util.d.ts +144 -48
  73. package/lib/world.d.ts +1197 -0
  74. package/package.json +27 -35
  75. package/dist/bin.cjs +0 -111
  76. package/dist/initScope.d.ts +0 -5
  77. package/dist/instructions/ZeroSpaceInstruction.d.ts +0 -4
  78. package/dist/values/SenseableValue.d.ts +0 -24
  79. /package/dist/{bin.d.ts → bin/index.d.ts} +0 -0
@@ -13,77 +13,88 @@ See the Apache Version 2.0 License for specific language governing permissions
13
13
  and limitations under the License.
14
14
  ***************************************************************************** */
15
15
 
16
-
17
-
18
16
  /// <reference no-default-lib="true"/>
19
17
 
20
-
21
18
  interface Map<K, V> {
22
- clear(): void;
23
- delete(key: K): boolean;
24
- forEach(callbackfn: (value: V, key: K, map: Map<K, V>) => void, thisArg?: any): void;
25
- get(key: K): V | undefined;
26
- has(key: K): boolean;
27
- set(key: K, value: V): this;
28
- readonly size: number;
19
+ clear(): void;
20
+ delete(key: K): boolean;
21
+ forEach(
22
+ callbackfn: (value: V, key: K, map: Map<K, V>) => void,
23
+ thisArg?: any,
24
+ ): void;
25
+ get(key: K): V | undefined;
26
+ has(key: K): boolean;
27
+ set(key: K, value: V): this;
28
+ readonly size: number;
29
29
  }
30
30
 
31
31
  interface MapConstructor {
32
- new(): Map<any, any>;
33
- new<K, V>(entries?: readonly (readonly [K, V])[] | null): Map<K, V>;
34
- readonly prototype: Map<any, any>;
32
+ new (): Map<any, any>;
33
+ new <K, V>(entries?: readonly (readonly [K, V])[] | null): Map<K, V>;
34
+ readonly prototype: Map<any, any>;
35
35
  }
36
36
  declare var Map: MapConstructor;
37
37
 
38
38
  interface ReadonlyMap<K, V> {
39
- forEach(callbackfn: (value: V, key: K, map: ReadonlyMap<K, V>) => void, thisArg?: any): void;
40
- get(key: K): V | undefined;
41
- has(key: K): boolean;
42
- readonly size: number;
39
+ forEach(
40
+ callbackfn: (value: V, key: K, map: ReadonlyMap<K, V>) => void,
41
+ thisArg?: any,
42
+ ): void;
43
+ get(key: K): V | undefined;
44
+ has(key: K): boolean;
45
+ readonly size: number;
43
46
  }
44
47
 
45
48
  interface WeakMap<K extends object, V> {
46
- delete(key: K): boolean;
47
- get(key: K): V | undefined;
48
- has(key: K): boolean;
49
- set(key: K, value: V): this;
49
+ delete(key: K): boolean;
50
+ get(key: K): V | undefined;
51
+ has(key: K): boolean;
52
+ set(key: K, value: V): this;
50
53
  }
51
54
 
52
55
  interface WeakMapConstructor {
53
- new <K extends object = object, V = any>(entries?: readonly [K, V][] | null): WeakMap<K, V>;
54
- readonly prototype: WeakMap<object, any>;
56
+ new <K extends object = object, V = any>(
57
+ entries?: readonly [K, V][] | null,
58
+ ): WeakMap<K, V>;
59
+ readonly prototype: WeakMap<object, any>;
55
60
  }
56
61
  declare var WeakMap: WeakMapConstructor;
57
62
 
58
63
  interface Set<T> {
59
- add(value: T): this;
60
- clear(): void;
61
- delete(value: T): boolean;
62
- forEach(callbackfn: (value: T, value2: T, set: Set<T>) => void, thisArg?: any): void;
63
- has(value: T): boolean;
64
- readonly size: number;
64
+ add(value: T): this;
65
+ clear(): void;
66
+ delete(value: T): boolean;
67
+ forEach(
68
+ callbackfn: (value: T, value2: T, set: Set<T>) => void,
69
+ thisArg?: any,
70
+ ): void;
71
+ has(value: T): boolean;
72
+ readonly size: number;
65
73
  }
66
74
 
67
75
  interface SetConstructor {
68
- new <T = any>(values?: readonly T[] | null): Set<T>;
69
- readonly prototype: Set<any>;
76
+ new <T = any>(values?: readonly T[] | null): Set<T>;
77
+ readonly prototype: Set<any>;
70
78
  }
71
79
  declare var Set: SetConstructor;
72
80
 
73
81
  interface ReadonlySet<T> {
74
- forEach(callbackfn: (value: T, value2: T, set: ReadonlySet<T>) => void, thisArg?: any): void;
75
- has(value: T): boolean;
76
- readonly size: number;
82
+ forEach(
83
+ callbackfn: (value: T, value2: T, set: ReadonlySet<T>) => void,
84
+ thisArg?: any,
85
+ ): void;
86
+ has(value: T): boolean;
87
+ readonly size: number;
77
88
  }
78
89
 
79
90
  interface WeakSet<T extends object> {
80
- add(value: T): this;
81
- delete(value: T): boolean;
82
- has(value: T): boolean;
91
+ add(value: T): this;
92
+ delete(value: T): boolean;
93
+ has(value: T): boolean;
83
94
  }
84
95
 
85
96
  interface WeakSetConstructor {
86
- new <T extends object = object>(values?: readonly T[] | null): WeakSet<T>;
87
- readonly prototype: WeakSet<object>;
97
+ new <T extends object = object>(values?: readonly T[] | null): WeakSet<T>;
98
+ readonly prototype: WeakSet<object>;
88
99
  }
89
100
  declare var WeakSet: WeakSetConstructor;
@@ -17,3 +17,62 @@ and limitations under the License.
17
17
 
18
18
  /** Does not exist. It's only here because typescript needs it */
19
19
  interface RegExp {}
20
+
21
+ interface Math {
22
+ /**
23
+ * Returns the sign of the x, indicating whether x is positive, negative or zero.
24
+ * @param x The numeric expression to test
25
+ */
26
+ sign(x: number): number;
27
+
28
+ /**
29
+ * Returns the result of (e^x - 1), which is an implementation-dependent approximation to
30
+ * subtracting 1 from the exponential function of x (e raised to the power of x, where e
31
+ * is the base of the natural logarithms).
32
+ * @param x A numeric expression.
33
+ */
34
+ expm1(x: number): number;
35
+
36
+ /**
37
+ * Returns the hyperbolic cosine of a number.
38
+ * @param x A numeric expression that contains an angle measured in degrees.
39
+ */
40
+ cosh(x: number): number;
41
+
42
+ /**
43
+ * Returns the hyperbolic sine of a number.
44
+ * @param x A numeric expression that contains an angle measured in degrees.
45
+ */
46
+ sinh(x: number): number;
47
+
48
+ /**
49
+ * Returns the hyperbolic tangent of a number.
50
+ * @param x A numeric expression that contains an angle measured in degrees.
51
+ */
52
+ tanh(x: number): number;
53
+
54
+ /**
55
+ * Returns the inverse hyperbolic cosine of a number.
56
+ * @param x A numeric expression that contains an angle measured in degrees.
57
+ */
58
+ acosh(x: number): number;
59
+
60
+ /**
61
+ * Returns the inverse hyperbolic sine of a number.
62
+ * @param x A numeric expression that contains an angle measured in degrees.
63
+ */
64
+ asinh(x: number): number;
65
+
66
+ /**
67
+ * Returns the inverse hyperbolic tangent of a number.
68
+ * @param x A numeric expression that contains an angle measured in degrees.
69
+ */
70
+ atanh(x: number): number;
71
+
72
+ /**
73
+ * Returns the integral part of the a numeric expression, x, removing any fractional digits.
74
+ * If x is already an integer, the result is x.
75
+ * @param x A numeric expression.
76
+ */
77
+ trunc(x: number): number;
78
+ }
@@ -13,11 +13,8 @@ See the Apache Version 2.0 License for specific language governing permissions
13
13
  and limitations under the License.
14
14
  ***************************************************************************** */
15
15
 
16
-
17
-
18
16
  /// <reference no-default-lib="true"/>
19
17
 
20
-
21
18
  /// <reference lib="es5" />
22
19
  /// <reference lib="es2015.core" />
23
20
  /// <reference lib="es2015.collection" />
@@ -13,67 +13,68 @@ See the Apache Version 2.0 License for specific language governing permissions
13
13
  and limitations under the License.
14
14
  ***************************************************************************** */
15
15
 
16
-
17
-
18
16
  /// <reference no-default-lib="true"/>
19
17
 
20
-
21
18
  /// <reference lib="es2015.iterable" />
22
19
 
23
- interface Generator<T = unknown, TReturn = any, TNext = unknown> extends Iterator<T, TReturn, TNext> {
24
- // NOTE: 'next' is defined using a tuple to ensure we report the correct assignability errors in all places.
25
- next(...args: [] | [TNext]): IteratorResult<T, TReturn>;
26
- return(value: TReturn): IteratorResult<T, TReturn>;
27
- throw(e: any): IteratorResult<T, TReturn>;
28
- [Symbol.iterator](): Generator<T, TReturn, TNext>;
20
+ interface Generator<
21
+ T = unknown,
22
+ TReturn = any,
23
+ TNext = unknown,
24
+ > extends Iterator<T, TReturn, TNext> {
25
+ // NOTE: 'next' is defined using a tuple to ensure we report the correct assignability errors in all places.
26
+ next(...args: [] | [TNext]): IteratorResult<T, TReturn>;
27
+ return(value: TReturn): IteratorResult<T, TReturn>;
28
+ throw(e: any): IteratorResult<T, TReturn>;
29
+ [Symbol.iterator](): Generator<T, TReturn, TNext>;
29
30
  }
30
31
 
31
32
  interface GeneratorFunction {
32
- /**
33
- * Creates a new Generator object.
34
- * @param args A list of arguments the function accepts.
35
- */
36
- new (...args: any[]): Generator;
37
- /**
38
- * Creates a new Generator object.
39
- * @param args A list of arguments the function accepts.
40
- */
41
- (...args: any[]): Generator;
42
- /**
43
- * The length of the arguments.
44
- */
45
- readonly length: number;
46
- /**
47
- * Returns the name of the function.
48
- */
49
- readonly name: string;
50
- /**
51
- * A reference to the prototype.
52
- */
53
- readonly prototype: Generator;
33
+ /**
34
+ * Creates a new Generator object.
35
+ * @param args A list of arguments the function accepts.
36
+ */
37
+ new (...args: any[]): Generator;
38
+ /**
39
+ * Creates a new Generator object.
40
+ * @param args A list of arguments the function accepts.
41
+ */
42
+ (...args: any[]): Generator;
43
+ /**
44
+ * The length of the arguments.
45
+ */
46
+ readonly length: number;
47
+ /**
48
+ * Returns the name of the function.
49
+ */
50
+ readonly name: string;
51
+ /**
52
+ * A reference to the prototype.
53
+ */
54
+ readonly prototype: Generator;
54
55
  }
55
56
 
56
57
  interface GeneratorFunctionConstructor {
57
- /**
58
- * Creates a new Generator function.
59
- * @param args A list of arguments the function accepts.
60
- */
61
- new (...args: string[]): GeneratorFunction;
62
- /**
63
- * Creates a new Generator function.
64
- * @param args A list of arguments the function accepts.
65
- */
66
- (...args: string[]): GeneratorFunction;
67
- /**
68
- * The length of the arguments.
69
- */
70
- readonly length: number;
71
- /**
72
- * Returns the name of the function.
73
- */
74
- readonly name: string;
75
- /**
76
- * A reference to the prototype.
77
- */
78
- readonly prototype: GeneratorFunction;
58
+ /**
59
+ * Creates a new Generator function.
60
+ * @param args A list of arguments the function accepts.
61
+ */
62
+ new (...args: string[]): GeneratorFunction;
63
+ /**
64
+ * Creates a new Generator function.
65
+ * @param args A list of arguments the function accepts.
66
+ */
67
+ (...args: string[]): GeneratorFunction;
68
+ /**
69
+ * The length of the arguments.
70
+ */
71
+ readonly length: number;
72
+ /**
73
+ * Returns the name of the function.
74
+ */
75
+ readonly name: string;
76
+ /**
77
+ * A reference to the prototype.
78
+ */
79
+ readonly prototype: GeneratorFunction;
79
80
  }
@@ -36,8 +36,7 @@ interface IteratorReturnResult<TReturn> {
36
36
  }
37
37
 
38
38
  type IteratorResult<T, TReturn = any> =
39
- | IteratorYieldResult<T>
40
- | IteratorReturnResult<TReturn>;
39
+ IteratorYieldResult<T> | IteratorReturnResult<TReturn>;
41
40
 
42
41
  interface Iterator<T, TReturn = any, TNext = undefined> {
43
42
  // NOTE: 'next' is defined using a tuple to ensure we report the correct assignability errors in all places.
@@ -46,12 +45,16 @@ interface Iterator<T, TReturn = any, TNext = undefined> {
46
45
  throw?(e?: any): IteratorResult<T, TReturn>;
47
46
  }
48
47
 
49
- interface Iterable<T> {
50
- [Symbol.iterator](): Iterator<T>;
48
+ interface Iterable<T, TReturn = any, TNext = any> {
49
+ [Symbol.iterator](): Iterator<T, TReturn, TNext>;
51
50
  }
52
51
 
53
- interface IterableIterator<T> extends Iterator<T> {
54
- [Symbol.iterator](): IterableIterator<T>;
52
+ interface IterableIterator<T, TReturn = any, TNext = any> extends Iterator<
53
+ T,
54
+ TReturn,
55
+ TNext
56
+ > {
57
+ [Symbol.iterator](): IterableIterator<T, TReturn, TNext>;
55
58
  }
56
59
 
57
60
  interface Array<T> {
@@ -1,6 +1,17 @@
1
1
  /// <reference no-default-lib="true"/>
2
2
 
3
- interface Symbol {}
3
+ interface Symbol {
4
+ /**
5
+ * The `lookup` id of this symbol.
6
+ *
7
+ * Due to typescript's limitations, this property has been
8
+ * declared for all symbols, even ones that shouldn't have it.
9
+ *
10
+ * If a symbol is not part of `ItemSymbol`, `LiquidSymbol`,
11
+ * `UnitSymbol`, or `BlockSymbol`, it likely does not have an id.
12
+ */
13
+ readonly id: number;
14
+ }
4
15
 
5
16
  interface SymbolConstructor {}
6
17
 
@@ -22,11 +33,12 @@ type ThisParameterType<T> = T extends (this: infer U, ...args: any[]) => any
22
33
  /**
23
34
  * Removes the 'this' parameter from a function type.
24
35
  */
25
- type OmitThisParameter<T> = unknown extends ThisParameterType<T>
26
- ? T
27
- : T extends (...args: infer A) => infer R
28
- ? (...args: A) => R
29
- : T;
36
+ type OmitThisParameter<T> =
37
+ unknown extends ThisParameterType<T>
38
+ ? T
39
+ : T extends (...args: infer A) => infer R
40
+ ? (...args: A) => R
41
+ : T;
30
42
 
31
43
  interface CallableFunction extends Function {}
32
44
 
@@ -100,6 +112,13 @@ interface Math {
100
112
  */
101
113
  angle(a: number, b: number): number;
102
114
 
115
+ /**
116
+ * Returns the absolute distance between two angles in degrees.
117
+ * @param a
118
+ * @param b
119
+ */
120
+ angleDiff(a: number, b: number): number;
121
+
103
122
  /**
104
123
  * Returns the length of a vector
105
124
  * @param a
@@ -129,6 +148,13 @@ interface Math {
129
148
  */
130
149
  log(x: number): number;
131
150
 
151
+ /**
152
+ * Returns the logarithm of a number with a specified base.
153
+ * @param x The value to compute the logarithm of.
154
+ * @param base The base of the logarithm.
155
+ */
156
+ logn(x: number, base: number): number;
157
+
132
158
  /**
133
159
  * Returns the logarithm (base 10) of a number
134
160
  * @param x
@@ -176,6 +202,15 @@ interface Math {
176
202
  */
177
203
  idiv(x: number, y: number): number;
178
204
 
205
+ /**
206
+ * Returns the Euclidean modulus of `x` and `y`. This is similar to the modulo operator (`%`), but
207
+ * ensures a non-negative result.
208
+ *
209
+ * @param x
210
+ * @param y
211
+ */
212
+ emod(x: number, y: number): number;
213
+
179
214
  /**
180
215
  * Returns the value of a base expression taken to a specified power.
181
216
  *
@@ -183,6 +218,18 @@ interface Math {
183
218
  * @param y The exponent value of the expression.
184
219
  */
185
220
  pow(x: number, y: number): number;
221
+
222
+ /**
223
+ * Returns a supplied numeric expression rounded to the nearest integer.
224
+ * @param x The value to be rounded to the nearest integer.
225
+ */
226
+ round(x: number): number;
227
+
228
+ /**
229
+ * Returns e (the base of natural logarithms) raised to a power.
230
+ * @param x A numeric expression representing the power of e.
231
+ */
232
+ exp(x: number): number;
186
233
  }
187
234
  declare const Math: Math;
188
235