screeps-clockwork 0.7.1 → 0.7.2

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.
Binary file
@@ -1,14 +1,10 @@
1
1
  /* tslint:disable */
2
2
  /* eslint-disable */
3
- export function js_astar_multiroom_distance_map(start_packed: Uint32Array, get_cost_matrix: Function, max_rooms: number, max_ops: number, max_path_cost: number, any_of_destinations?: Uint32Array | null, all_of_destinations?: Uint32Array | null): SearchResult;
4
- export function js_path_to_multiroom_mono_flow_field_origin(start: number, flow_field: MultiroomMonoFlowField): Path;
5
- export function js_path_to_multiroom_flow_field_origin(start: number, flow_field: MultiroomFlowField): Path;
6
- export function get_terrain_cost_matrix(room_name: number, plain_cost?: number | null, swamp_cost?: number | null, wall_cost?: number | null): ClockworkCostMatrix;
3
+ export function version(): string;
7
4
  /**
8
- * Creates a flow field for the given distance map.
5
+ * Exports the global range calculation between two positions.
9
6
  */
10
- export function multiroomFlowField(distance_map: MultiroomDistanceMap): MultiroomFlowField;
11
- export function js_dijkstra_multiroom_distance_map(start_packed: Uint32Array, get_cost_matrix: Function, max_ops: number, max_rooms: number, max_path_cost: number, any_of_destinations?: Uint32Array | null, all_of_destinations?: Uint32Array | null): SearchResult;
7
+ export function get_range(packed_pos_1: number, packed_pos_2: number): number;
12
8
  /**
13
9
  * WASM wrapper for the BFS multiroom distance map function.
14
10
  *
@@ -26,16 +22,20 @@ export function js_dijkstra_multiroom_distance_map(start_packed: Uint32Array, ge
26
22
  * A `MultiroomDistanceMap` containing the distances from the start positions
27
23
  */
28
24
  export function js_bfs_multiroom_distance_map(start_packed: Uint32Array, get_cost_matrix: Function, max_ops: number, max_rooms: number, max_path_cost: number, any_of_destinations?: Uint32Array | null, all_of_destinations?: Uint32Array | null): SearchResult;
29
- export function version(): string;
30
- /**
31
- * Exports the global range calculation between two positions.
32
- */
33
- export function get_range(packed_pos_1: number, packed_pos_2: number): number;
25
+ export function js_dijkstra_multiroom_distance_map(start_packed: Uint32Array, get_cost_matrix: Function, max_ops: number, max_rooms: number, max_path_cost: number, any_of_destinations?: Uint32Array | null, all_of_destinations?: Uint32Array | null): SearchResult;
26
+ export function js_path_to_multiroom_mono_flow_field_origin(start: number, flow_field: MultiroomMonoFlowField): Path;
34
27
  /**
35
28
  * Creates a monodirectional flow field for the given distance map.
36
29
  */
37
30
  export function multiroomMonoFlowField(distance_map: MultiroomDistanceMap): MultiroomMonoFlowField;
31
+ export function get_terrain_cost_matrix(room_name: number, plain_cost?: number | null, swamp_cost?: number | null, wall_cost?: number | null): ClockworkCostMatrix;
32
+ /**
33
+ * Creates a flow field for the given distance map.
34
+ */
35
+ export function multiroomFlowField(distance_map: MultiroomDistanceMap): MultiroomFlowField;
36
+ export function js_path_to_multiroom_flow_field_origin(start: number, flow_field: MultiroomFlowField): Path;
38
37
  export function js_path_to_multiroom_distance_map_origin(start: number, distance_map: MultiroomDistanceMap): Path;
38
+ export function js_astar_multiroom_distance_map(start_packed: Uint32Array, get_cost_matrix: Function, max_rooms: number, max_ops: number, max_path_cost: number, any_of_destinations?: Uint32Array | null, all_of_destinations?: Uint32Array | null): SearchResult;
39
39
  /**
40
40
  * Translates `COLOR_*` and `COLORS_ALL` constants.
41
41
  */
@@ -205,10 +205,6 @@ export class ClockworkCostMatrix {
205
205
  export class DistanceMap {
206
206
  private constructor();
207
207
  free(): void;
208
- /**
209
- * Converts the distance map into a flat array of distances.
210
- */
211
- toArray(): Uint32Array;
212
208
  /**
213
209
  * Gets the distance value at a given position.
214
210
  */
@@ -217,6 +213,10 @@ export class DistanceMap {
217
213
  * Sets the distance value at a given position.
218
214
  */
219
215
  set(x: number, y: number, value: number): void;
216
+ /**
217
+ * Converts the distance map into a flat array of distances.
218
+ */
219
+ toArray(): Uint32Array;
220
220
  }
221
221
  /**
222
222
  * A flow field is a 50x50 grid (representing a room), representing viable directions
@@ -228,13 +228,9 @@ export class FlowField {
228
228
  private constructor();
229
229
  free(): void;
230
230
  /**
231
- * Get the internal value for a given coordinate.
232
- */
233
- get(x: number, y: number): number;
234
- /**
235
- * Set the internal value for a given coordinate.
231
+ * Add a direction to the list of valid directions for a given coordinate.
236
232
  */
237
- set(x: number, y: number, value: number): void;
233
+ addDirection(x: number, y: number, direction: Direction): void;
238
234
  /**
239
235
  * Get the list of valid directions for a given coordinate.
240
236
  */
@@ -244,9 +240,13 @@ export class FlowField {
244
240
  */
245
241
  setDirections(x: number, y: number, directions: any[]): void;
246
242
  /**
247
- * Add a direction to the list of valid directions for a given coordinate.
243
+ * Get the internal value for a given coordinate.
248
244
  */
249
- addDirection(x: number, y: number, direction: Direction): void;
245
+ get(x: number, y: number): number;
246
+ /**
247
+ * Set the internal value for a given coordinate.
248
+ */
249
+ set(x: number, y: number, value: number): void;
250
250
  }
251
251
  /**
252
252
  * A flow field is a 50x50 grid (representing a room), representing viable directions
@@ -272,25 +272,25 @@ export class MonoFlowField {
272
272
  export class MultiroomDistanceMap {
273
273
  free(): void;
274
274
  /**
275
- * Creates a new empty multiroom distance map (JavaScript constructor)
275
+ * Gets the DistanceMap for a given room
276
276
  */
277
- constructor();
277
+ get_room(room_name: number): DistanceMap | undefined;
278
278
  /**
279
- * Gets the distance value at a given position
279
+ * Gets the list of rooms in the map
280
280
  */
281
- get(packed_pos: number): number;
281
+ get_rooms(): Uint16Array;
282
282
  /**
283
- * Sets the distance value at a given position
283
+ * Gets the distance value at a given position
284
284
  */
285
- set(packed_pos: number, value: number): void;
285
+ get(packed_pos: number): number;
286
286
  /**
287
- * Gets the list of rooms in the map
287
+ * Creates a new empty multiroom distance map (JavaScript constructor)
288
288
  */
289
- get_rooms(): Uint16Array;
289
+ constructor();
290
290
  /**
291
- * Gets the DistanceMap for a given room
291
+ * Sets the distance value at a given position
292
292
  */
293
- get_room(room_name: number): DistanceMap | undefined;
293
+ set(packed_pos: number, value: number): void;
294
294
  }
295
295
  /**
296
296
  * Maps flow field values across multiple rooms, storing a FlowField for each room
@@ -298,25 +298,17 @@ export class MultiroomDistanceMap {
298
298
  export class MultiroomFlowField {
299
299
  free(): void;
300
300
  /**
301
- * Creates a new empty multiroom flow field (JavaScript constructor)
302
- */
303
- constructor();
304
- /**
305
- * Gets the flow field value at a given position
306
- */
307
- get(packed_pos: number): number;
308
- /**
309
- * Sets the flow field value at a given position
301
+ * Gets the FlowField for a given room
310
302
  */
311
- set(packed_pos: number, value: number): void;
303
+ getRoom(room_name: number): FlowField | undefined;
312
304
  /**
313
305
  * Gets the list of rooms in the flow field
314
306
  */
315
307
  getRooms(): Uint16Array;
316
308
  /**
317
- * Gets the FlowField for a given room
309
+ * Adds a direction to the list of valid directions at a given position (JavaScript)
318
310
  */
319
- getRoom(room_name: number): FlowField | undefined;
311
+ addDirection(packed_pos: number, direction: Direction): void;
320
312
  /**
321
313
  * Gets the list of valid directions at a given position (JavaScript)
322
314
  */
@@ -326,9 +318,17 @@ export class MultiroomFlowField {
326
318
  */
327
319
  setDirections(packed_pos: number, directions: any[]): void;
328
320
  /**
329
- * Adds a direction to the list of valid directions at a given position (JavaScript)
321
+ * Gets the flow field value at a given position
330
322
  */
331
- addDirection(packed_pos: number, direction: Direction): void;
323
+ get(packed_pos: number): number;
324
+ /**
325
+ * Creates a new empty multiroom flow field (JavaScript constructor)
326
+ */
327
+ constructor();
328
+ /**
329
+ * Sets the flow field value at a given position
330
+ */
331
+ set(packed_pos: number, value: number): void;
332
332
  }
333
333
  /**
334
334
  * Maps monodirectional flow field values across multiple rooms, storing a MonoFlowField for each room
@@ -336,25 +336,25 @@ export class MultiroomFlowField {
336
336
  export class MultiroomMonoFlowField {
337
337
  free(): void;
338
338
  /**
339
- * Creates a new empty multiroom monodirectional flow field (JavaScript constructor)
339
+ * Gets the MonoFlowField for a given room
340
340
  */
341
- constructor();
341
+ getRoom(room_name: number): MonoFlowField | undefined;
342
342
  /**
343
- * Gets the direction at a given position
343
+ * Gets the list of rooms in the flow field
344
344
  */
345
- get(packed_pos: number): Direction | undefined;
345
+ getRooms(): Uint16Array;
346
346
  /**
347
- * Sets the direction at a given position
347
+ * Gets the direction at a given position
348
348
  */
349
- set(packed_pos: number, direction?: Direction | null): void;
349
+ get(packed_pos: number): Direction | undefined;
350
350
  /**
351
- * Gets the list of rooms in the flow field
351
+ * Creates a new empty multiroom monodirectional flow field (JavaScript constructor)
352
352
  */
353
- getRooms(): Uint16Array;
353
+ constructor();
354
354
  /**
355
- * Gets the MonoFlowField for a given room
355
+ * Sets the direction at a given position
356
356
  */
357
- getRoom(room_name: number): MonoFlowField | undefined;
357
+ set(packed_pos: number, direction?: Direction | null): void;
358
358
  }
359
359
  /**
360
360
  * A list of positions representing a path.
@@ -362,9 +362,7 @@ export class MultiroomMonoFlowField {
362
362
  export class Path {
363
363
  private constructor();
364
364
  free(): void;
365
- add(packed_position: number): void;
366
- get(index: number): number | undefined;
367
- len(): number;
365
+ to_array(): Uint32Array;
368
366
  /**
369
367
  * Given a position, find the index of the next adjacent position
370
368
  * in the path. If the position is not in the path, the target is
@@ -372,8 +370,10 @@ export class Path {
372
370
  * the position is neither on nor adjacent to the path, return None.
373
371
  */
374
372
  find_next_index(packed_position: number): number | undefined;
375
- to_array(): Uint32Array;
376
373
  to_array_reversed(): Uint32Array;
374
+ add(packed_position: number): void;
375
+ get(index: number): number | undefined;
376
+ len(): number;
377
377
  }
378
378
  /**
379
379
  * Tracks fatigue cost for each position in a path. Used to calculate move time
@@ -381,6 +381,7 @@ export class Path {
381
381
  */
382
382
  export class PathFatigue {
383
383
  free(): void;
384
+ len(): number;
384
385
  constructor(path: Path);
385
386
  /**
386
387
  * Refreshes fatigue cost for each position in the path. If the PathFatigue
@@ -391,7 +392,6 @@ export class PathFatigue {
391
392
  * When there is vision, this also accounts for roads at the position.
392
393
  */
393
394
  refresh(path: Path): void;
394
- len(): number;
395
395
  /**
396
396
  * Calculates the total move time for the path, given a fatigue ratio.
397
397
  *
@@ -427,71 +427,71 @@ export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembl
427
427
 
428
428
  export interface InitOutput {
429
429
  readonly memory: WebAssembly.Memory;
430
- readonly js_astar_multiroom_distance_map: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number, j: number) => number;
431
- readonly __wbg_clockworkcostmatrix_free: (a: number, b: number) => void;
432
- readonly clockworkcostmatrix_new: (a: number) => number;
433
- readonly clockworkcostmatrix_get: (a: number, b: number, c: number) => number;
434
- readonly clockworkcostmatrix_set: (a: number, b: number, c: number, d: number) => void;
435
- readonly __wbg_searchresult_free: (a: number, b: number) => void;
436
- readonly searchresult_distance_map: (a: number) => number;
437
- readonly searchresult_found_targets: (a: number, b: number) => void;
438
- readonly searchresult_ops: (a: number) => number;
439
- readonly js_path_to_multiroom_mono_flow_field_origin: (a: number, b: number) => number;
440
- readonly __wbg_multiroommonoflowfield_free: (a: number, b: number) => void;
441
- readonly multiroommonoflowfield_js_new: () => number;
442
- readonly multiroommonoflowfield_get: (a: number, b: number) => number;
443
- readonly multiroommonoflowfield_set: (a: number, b: number, c: number) => void;
444
- readonly multiroommonoflowfield_getRooms: (a: number, b: number) => void;
445
- readonly multiroommonoflowfield_getRoom: (a: number, b: number) => number;
446
- readonly js_path_to_multiroom_flow_field_origin: (a: number, b: number) => number;
447
- readonly __wbg_multiroomflowfield_free: (a: number, b: number) => void;
448
- readonly multiroomflowfield_js_new: () => number;
449
- readonly multiroomflowfield_get: (a: number, b: number) => number;
450
- readonly multiroomflowfield_set: (a: number, b: number, c: number) => void;
451
- readonly multiroomflowfield_getRooms: (a: number, b: number) => void;
452
- readonly multiroomflowfield_getRoom: (a: number, b: number) => number;
453
- readonly multiroomflowfield_getDirections: (a: number, b: number, c: number) => void;
454
- readonly multiroomflowfield_setDirections: (a: number, b: number, c: number, d: number) => void;
455
- readonly multiroomflowfield_addDirection: (a: number, b: number, c: number) => void;
456
- readonly get_terrain_cost_matrix: (a: number, b: number, c: number, d: number) => number;
457
- readonly multiroomFlowField: (a: number) => number;
430
+ readonly get_range: (a: number, b: number) => number;
431
+ readonly js_bfs_multiroom_distance_map: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number, j: number) => number;
458
432
  readonly js_dijkstra_multiroom_distance_map: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number, j: number) => number;
433
+ readonly js_path_to_multiroom_mono_flow_field_origin: (a: number, b: number) => number;
434
+ readonly version: (a: number) => void;
459
435
  readonly __wbg_distancemap_free: (a: number, b: number) => void;
460
- readonly distancemap_toArray: (a: number, b: number) => void;
436
+ readonly __wbg_flowfield_free: (a: number, b: number) => void;
461
437
  readonly distancemap_get: (a: number, b: number, c: number) => number;
462
438
  readonly distancemap_set: (a: number, b: number, c: number, d: number) => void;
463
- readonly __wbg_flowfield_free: (a: number, b: number) => void;
439
+ readonly distancemap_toArray: (a: number, b: number) => void;
440
+ readonly flowfield_addDirection: (a: number, b: number, c: number, d: number) => void;
464
441
  readonly flowfield_get: (a: number, b: number, c: number) => number;
465
- readonly flowfield_set: (a: number, b: number, c: number, d: number) => void;
466
442
  readonly flowfield_getDirections: (a: number, b: number, c: number, d: number) => void;
443
+ readonly flowfield_set: (a: number, b: number, c: number, d: number) => void;
467
444
  readonly flowfield_setDirections: (a: number, b: number, c: number, d: number, e: number) => void;
468
- readonly flowfield_addDirection: (a: number, b: number, c: number, d: number) => void;
469
- readonly js_bfs_multiroom_distance_map: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number, j: number) => number;
445
+ readonly multiroomMonoFlowField: (a: number) => number;
446
+ readonly __wbg_clockworkcostmatrix_free: (a: number, b: number) => void;
447
+ readonly clockworkcostmatrix_get: (a: number, b: number, c: number) => number;
448
+ readonly clockworkcostmatrix_new: (a: number) => number;
449
+ readonly clockworkcostmatrix_set: (a: number, b: number, c: number, d: number) => void;
470
450
  readonly __wbg_monoflowfield_free: (a: number, b: number) => void;
451
+ readonly __wbg_multiroommonoflowfield_free: (a: number, b: number) => void;
452
+ readonly get_terrain_cost_matrix: (a: number, b: number, c: number, d: number) => number;
471
453
  readonly monoflowfield_get: (a: number, b: number, c: number) => number;
472
454
  readonly monoflowfield_set: (a: number, b: number, c: number, d: number) => void;
473
- readonly version: (a: number) => void;
474
- readonly get_range: (a: number, b: number) => number;
455
+ readonly multiroomFlowField: (a: number) => number;
456
+ readonly multiroommonoflowfield_get: (a: number, b: number) => number;
457
+ readonly multiroommonoflowfield_getRoom: (a: number, b: number) => number;
458
+ readonly multiroommonoflowfield_getRooms: (a: number, b: number) => void;
459
+ readonly multiroommonoflowfield_js_new: () => number;
460
+ readonly multiroommonoflowfield_set: (a: number, b: number, c: number) => void;
461
+ readonly __wbg_multiroomdistancemap_free: (a: number, b: number) => void;
462
+ readonly __wbg_multiroomflowfield_free: (a: number, b: number) => void;
463
+ readonly __wbg_searchresult_free: (a: number, b: number) => void;
464
+ readonly js_path_to_multiroom_distance_map_origin: (a: number, b: number) => number;
465
+ readonly js_path_to_multiroom_flow_field_origin: (a: number, b: number) => number;
466
+ readonly multiroomdistancemap_get: (a: number, b: number) => number;
467
+ readonly multiroomdistancemap_get_room: (a: number, b: number) => number;
468
+ readonly multiroomdistancemap_get_rooms: (a: number, b: number) => void;
469
+ readonly multiroomdistancemap_js_new: () => number;
470
+ readonly multiroomdistancemap_set: (a: number, b: number, c: number) => void;
471
+ readonly multiroomflowfield_addDirection: (a: number, b: number, c: number) => void;
472
+ readonly multiroomflowfield_get: (a: number, b: number) => number;
473
+ readonly multiroomflowfield_getDirections: (a: number, b: number, c: number) => void;
474
+ readonly multiroomflowfield_getRoom: (a: number, b: number) => number;
475
+ readonly multiroomflowfield_getRooms: (a: number, b: number) => void;
476
+ readonly multiroomflowfield_set: (a: number, b: number, c: number) => void;
477
+ readonly multiroomflowfield_setDirections: (a: number, b: number, c: number, d: number) => void;
478
+ readonly searchresult_distance_map: (a: number) => number;
479
+ readonly searchresult_found_targets: (a: number, b: number) => void;
480
+ readonly searchresult_ops: (a: number) => number;
481
+ readonly multiroomflowfield_js_new: () => number;
482
+ readonly js_astar_multiroom_distance_map: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number, j: number) => number;
475
483
  readonly __wbg_path_free: (a: number, b: number) => void;
476
484
  readonly __wbg_pathfatigue_free: (a: number, b: number) => void;
477
485
  readonly path_add: (a: number, b: number) => void;
486
+ readonly path_find_next_index: (a: number, b: number) => number;
478
487
  readonly path_get: (a: number, b: number) => number;
479
488
  readonly path_len: (a: number) => number;
480
- readonly path_find_next_index: (a: number, b: number) => number;
481
489
  readonly path_to_array: (a: number, b: number) => void;
482
490
  readonly path_to_array_reversed: (a: number, b: number) => void;
483
- readonly pathfatigue_new: (a: number) => number;
484
- readonly pathfatigue_refresh: (a: number, b: number) => void;
485
491
  readonly pathfatigue_len: (a: number) => number;
486
492
  readonly pathfatigue_moveTime: (a: number, b: number) => number;
487
- readonly multiroomMonoFlowField: (a: number) => number;
488
- readonly js_path_to_multiroom_distance_map_origin: (a: number, b: number) => number;
489
- readonly __wbg_multiroomdistancemap_free: (a: number, b: number) => void;
490
- readonly multiroomdistancemap_js_new: () => number;
491
- readonly multiroomdistancemap_get: (a: number, b: number) => number;
492
- readonly multiroomdistancemap_set: (a: number, b: number, c: number) => void;
493
- readonly multiroomdistancemap_get_rooms: (a: number, b: number) => void;
494
- readonly multiroomdistancemap_get_room: (a: number, b: number) => number;
493
+ readonly pathfatigue_new: (a: number) => number;
494
+ readonly pathfatigue_refresh: (a: number, b: number) => void;
495
495
  readonly __wbg_searchgoal_free: (a: number, b: number) => void;
496
496
  readonly searchgoal_pos: (a: number) => number;
497
497
  readonly searchgoal_range: (a: number) => number;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "screeps-clockwork",
3
- "version": "0.7.1",
3
+ "version": "0.7.2",
4
4
  "description": "A WASM movement library for Screeps",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/src/index.d.ts",
@@ -37,7 +37,7 @@
37
37
  "@rollup/plugin-node-resolve": "^16.0.0",
38
38
  "@rollup/plugin-typescript": "^12.1.1",
39
39
  "@rollup/plugin-wasm": "^6.2.2",
40
- "@types/node": "^22.10.1",
40
+ "@types/node": "^24.0.3",
41
41
  "@types/screeps": "^3.3.0",
42
42
  "@typescript-eslint/eslint-plugin": "^8.17.0",
43
43
  "@typescript-eslint/parser": "^8.17.0",
@@ -50,7 +50,7 @@
50
50
  "rollup-plugin-screeps": "^1.0.1",
51
51
  "source-map": "0.6.1",
52
52
  "tslib": "^2.8.1",
53
- "typedoc": "^0.27.3",
53
+ "typedoc": "^0.28.5",
54
54
  "typescript": "^5.7.2"
55
55
  },
56
56
  "dependencies": {
@@ -1,24 +0,0 @@
1
- import { DistanceMap } from '../wasm/screeps_clockwork';
2
- /**
3
- * A distance map for a single room.
4
- */
5
- export declare class ClockworkDistanceMap {
6
- private _map;
7
- constructor(_map: DistanceMap);
8
- /**
9
- * Gets the distance value at a given position.
10
- */
11
- get(x: number, y: number): number;
12
- /**
13
- * Sets the distance value at a given position.
14
- */
15
- set(x: number, y: number, value: number): void;
16
- /**
17
- * Converts the distance map into a flat array of distances.
18
- */
19
- toArray(): Uint32Array;
20
- /**
21
- * Frees the memory allocated for this distance map.
22
- */
23
- free(): void;
24
- }