pw-js-api 0.3.14 → 0.3.15

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/README.md CHANGED
@@ -33,18 +33,18 @@ NOTE: installing pw-js-api#dev is also available if you wish, there may be no di
33
33
  You could use a CDN like jsdelivr or unpkg. You can put this in your HTML page:
34
34
 
35
35
  ```html
36
- <script src="https://cdn.jsdelivr.net/npm/pw-js-api@0.1.1/browser/pw.prod.js"></script>
36
+ <script src="https://cdn.jsdelivr.net/npm/pw-js-api@0.3.15/browser/pw.prod.js"></script>
37
37
  ```
38
38
 
39
39
  ```html
40
- <script src="https://cdn.jsdelivr.net/npm/pw-js-api@0.1.1/browser/pw.dev.js"></script>
40
+ <script src="https://cdn.jsdelivr.net/npm/pw-js-api@0.3.15/browser/pw.dev.js"></script>
41
41
  ```
42
42
 
43
43
  When you have these scripts in your HTML file, you will be able to use the global variable PW which contains PWGameClient, PWApiClient and Constants.
44
44
 
45
45
  ## Example
46
46
 
47
- Feel free to take a look at the [source code for an example bot](https://github.com/doomestee/PW-JS-Api/blob/main/examples/) that only does snake and listen to certain chat commands (.ping, .say and .disconnect)
47
+ Feel free to take a look at the [source code for an example bot](/examples/index.mjs) that only does snake and listen to certain chat commands (.ping, .say and .disconnect)
48
48
 
49
49
  ## Why?
50
50
 
@@ -177,16 +177,14 @@ export interface ListBlockResult {
177
177
  */
178
178
  MinimapColor?: number;
179
179
  /**
180
- * EELVL ID.
181
- */
182
- LegacyId?: number;
183
- /**
184
- * Maps to a block in EE that might be identical, its value will either be null or a list of argument types.
180
+ * Maps to block(s) in EE that might be identical, its value will either be null or a list of argument types.
181
+ *
182
+ * NOTE: The object will be empty if there isnt a corresponding block, it will not be undefined still.
185
183
  */
186
- LegacyMorph?: { [blockId: number]: null | number[] }[];
184
+ LegacyMorphs: { [blockId: number]: null | number[] };
187
185
  }
188
186
 
189
- export interface BlockField<T extends string = string> {
187
+ export interface BlockField<T extends string, TypeOf> {
190
188
  /**
191
189
  * Name of the field, used for identifying the field.
192
190
  */
@@ -199,20 +197,26 @@ export interface BlockField<T extends string = string> {
199
197
  * Description describing what this field is for.
200
198
  */
201
199
  Description: string;
200
+ /**
201
+ * The default value set for this field.
202
+ *
203
+ * If applicable.
204
+ */
205
+ DefaultValue?: TypeOf;
202
206
  /**
203
207
  * Whether if this field is required.
204
208
  */
205
209
  Required: boolean
206
210
  }
207
211
 
208
- export interface TextBlockField extends BlockField<"String"> {
212
+ export interface TextBlockField extends BlockField<"String", string> {
209
213
  /**
210
- * May not be included, if so, this will be a regex string which validates the input.
214
+ * This will be a regex string which validates the input if not undefined.
211
215
  */
212
216
  Pattern?: string;
213
217
  }
214
218
 
215
- export interface NumberBlockField extends BlockField<"Int32" | "UInt32"> {
219
+ export interface NumberBlockField extends BlockField<"Int32" | "UInt32", number> {
216
220
  /**
217
221
  * The minimum possible value for this field.
218
222
  */
@@ -221,39 +225,30 @@ export interface NumberBlockField extends BlockField<"Int32" | "UInt32"> {
221
225
  * The maximum possible value for this field.
222
226
  */
223
227
  MaxValue: number;
224
- /**
225
- * The default value set for this number field.
226
- */
227
- DefaultValue: number;
228
-
229
228
  /**
230
229
  * May not be included, if so, this will be a list of numbers whose values cannot be given for this field.
231
230
  */
232
231
  ExcludedValues?: number[]
233
232
  }
234
233
 
235
- export interface BoolBlockField extends BlockField<"Boolean"> {
236
- /**
237
- * The default value set for this boolean field.
238
- */
239
- DefaultValue: boolean;
234
+ export interface BoolBlockField extends BlockField<"Boolean", boolean> {
240
235
  }
241
236
 
242
237
  /**
243
238
  * Block field special for Note blocks.
244
239
  */
245
- export interface NoteBlockField extends BlockField<"DrumNote[]" | "PianoNote[]" | "GuitarNote[]"> {
240
+ export interface NoteBlockField extends BlockField<"DrumNote[]" | "PianoNote[]" | "GuitarNote[]", never> {
246
241
  /**
247
- * Usually 1
242
+ * For note fields, it's currently just 1 for now.
248
243
  */
249
244
  MinLength: number;
250
245
  /**
251
- * Usually 6
246
+ * For note fields, it's currently just 6 for now.
252
247
  */
253
248
  MaxLength: number;
254
249
  }
255
250
 
256
- export type AnyBlockField = BlockField | TextBlockField | NumberBlockField | BoolBlockField | NoteBlockField;
251
+ export type AnyBlockField = TextBlockField | NumberBlockField | BoolBlockField | NoteBlockField;
257
252
 
258
253
 
259
254
  export interface ApiClientOptions {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pw-js-api",
3
- "version": "0.3.14",
3
+ "version": "0.3.15",
4
4
  "description": "A PixelWalker Library, aims to be minimal with support for browsers.",
5
5
  "exports": {
6
6
  "types": "./esm/index.js",