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
package/lib/util.d.ts CHANGED
@@ -1,48 +1,144 @@
1
- export type TRadarFilter =
2
- | "any"
3
- | "enemy"
4
- | "ally"
5
- | "player"
6
- | "attacker"
7
- | "flying"
8
- | "boss"
9
- | "ground";
10
-
11
- export type TRadarFilterArray =
12
- | [TRadarFilter]
13
- | [TRadarFilter, TRadarFilter]
14
- | [TRadarFilter, TRadarFilter, TRadarFilter];
15
-
16
- export type TRadarSort =
17
- | "distance"
18
- | "health"
19
- | "shield"
20
- | "armor"
21
- | "maxHealth";
22
-
23
- export type TUnitLocateBuildingGroup =
24
- | "core"
25
- | "storage"
26
- | "generator"
27
- | "turret"
28
- | "factory"
29
- | "repair"
30
- | "rally"
31
- | "battery"
32
- | "reactor";
33
-
34
- export type TUnitEffect =
35
- | "burning"
36
- | "freezing"
37
- | "unmoving"
38
- | "wet"
39
- | "melting"
40
- | "sapped"
41
- | "electrified"
42
- | "spore-slowed"
43
- | "tarred"
44
- | "overdrive"
45
- | "overclock"
46
- | "boss"
47
- | "shocked"
48
- | "blasted";
1
+ /// <reference path="./globals.d.ts" />
2
+
3
+ declare module "mlogjs:types" {
4
+ type LogicSymbols = typeof Items & typeof Liquids & typeof LAccess;
5
+
6
+ type AsSymbolRecord<T extends Record<string, unknown>> = {
7
+ -readonly [K in keyof (LogicSymbols | T) as LogicSymbols[K]]: T[K];
8
+ };
9
+
10
+ export type MutableWithSymbols<T extends Record<string, unknown>> = T &
11
+ AsSymbolRecord<T>;
12
+
13
+ export type WithSymbols<T extends Record<string, unknown>> = T &
14
+ Readonly<AsSymbolRecord<T>>;
15
+
16
+ export type TRadarFilter =
17
+ | "any"
18
+ | "enemy"
19
+ | "ally"
20
+ | "player"
21
+ | "attacker"
22
+ | "flying"
23
+ | "boss"
24
+ | "ground";
25
+
26
+ export type TRadarFilterArray =
27
+ | [TRadarFilter]
28
+ | [TRadarFilter, TRadarFilter]
29
+ | [TRadarFilter, TRadarFilter, TRadarFilter];
30
+
31
+ export type TRadarSort =
32
+ "distance" | "health" | "shield" | "armor" | "maxHealth";
33
+
34
+ export type TUnitLocateBuildingGroup =
35
+ | "core"
36
+ | "storage"
37
+ | "generator"
38
+ | "turret"
39
+ | "factory"
40
+ | "repair"
41
+ | "battery"
42
+ | "reactor"
43
+ | "drill"
44
+ | "shield";
45
+
46
+ export type TStatusEffect =
47
+ | "none"
48
+ | "burning"
49
+ | "freezing"
50
+ | "unmoving"
51
+ | "slow"
52
+ | "fast"
53
+ | "wet"
54
+ | "muddy"
55
+ | "melting"
56
+ | "sapped"
57
+ | "tarred"
58
+ | "overclock"
59
+ | "shielded"
60
+ | "shocked"
61
+ | "blasted"
62
+ | "corroded"
63
+ | "spore-slowed"
64
+ | "disarmed"
65
+ | "electrified"
66
+ | "invincible"
67
+ | "dynamic"
68
+ | TPermanentStatusEffect;
69
+
70
+ export type TPermanentStatusEffect = "boss" | "overdrive";
71
+
72
+ type CommonSettableProps = Record<keyof typeof Items, number> & {
73
+ team: TeamIdentifier;
74
+ health: number;
75
+ };
76
+
77
+ interface SettableUnit extends MutableWithSymbols<
78
+ CommonSettableProps & {
79
+ x: number;
80
+ y: number;
81
+ flag: number;
82
+ rotation: number;
83
+ payloadType?: UnitSymbol | BuildingSymbol;
84
+ speed: number;
85
+ shield: number;
86
+ armor: number;
87
+ velocityX: number;
88
+ velocityY: number;
89
+ totalPower?: number;
90
+ bulletTime?: number;
91
+ bulletLifetime?: number;
92
+ }
93
+ > {}
94
+
95
+ interface SettableBuilding extends MutableWithSymbols<
96
+ CommonSettableProps &
97
+ Record<keyof typeof Liquids, number> & {
98
+ totalPower: number;
99
+ }
100
+ > {}
101
+
102
+ interface SettableBullet extends MutableWithSymbols<{
103
+ health: number;
104
+ x: number;
105
+ y: number;
106
+ velocityX: number;
107
+ velocityY: number;
108
+ rotation: number;
109
+ team: TeamIdentifier;
110
+ speed: number;
111
+ bulletLifetime: number;
112
+ bulletTime: number;
113
+ }> {}
114
+
115
+ export type TLogicLinkNames<T extends string> =
116
+ `${TLogicLinkName<T>}${TLogicLinkDigit}`;
117
+
118
+ /**
119
+ * Converts a the name of a block into it's logic link variant.
120
+ *
121
+ * The transformation happens as follows:
122
+ *
123
+ * - If the name is all lowercase, return it.
124
+ * - If the name is a single uppercase letter followed by lowercase letters,
125
+ * return the name in lowercase form.
126
+ * - If the name has "Large" at the end, remove it and try again.
127
+ * - Else, remove one letter from the beggining and try again.
128
+ *
129
+ * Based on [the mindustry source
130
+ * code](https://github.com/Anuken/Mindustry/blob/93daa7a5dcc3fac9e5f40c3375e9f57ae4720ff4/core/src/mindustry/world/blocks/logic/LogicBlock.java#L103-L115).
131
+ */
132
+ export type TLogicLinkName<T extends string> =
133
+ T extends Lowercase<string>
134
+ ? T
135
+ : T extends `${Uppercase<string>}${Lowercase<string>}`
136
+ ? Lowercase<T>
137
+ : T extends `${infer Begin}Large`
138
+ ? TLogicLinkName<Begin>
139
+ : T extends `${string}${infer Rest}`
140
+ ? TLogicLinkName<Rest>
141
+ : never;
142
+
143
+ export type TLogicLinkDigit = 1 | 2 | 3 | 4 | 6 | 7 | 8 | 9;
144
+ }