Skip to content

v2.0.1

Latest

Choose a tag to compare

@DocDvorak DocDvorak released this 16 Jun 23:04
· 3 commits to master since this release
3bea78b

This is a re-release of v2.0.0 that fixes a packaging issue. Original release notes follow:


Please see the v2 Migration Guide for tips and examples for migrating from v1.x.

Breaking Changes

General:

  • Bumped minimum supported Node.js version to v22 (target version is v24)
    • Earlier versions may still work, but they are not explicitly supported
  • Updated package to ESM format, which breaks compatibility with CJS projects

HTTP API:

  • Renamed ScreepsAPI class to ScreepsHttpClient
  • ScreepsHttpClient.fromConfig() parameters have been changed
    • Server name is now required; it no longer defaults to 'main' to prevent accidental usage of the 'main' server
    • See docblock for other changes
  • Flattened the endpoint method structure on ScreepsHttpClient:
    • Almost every endpoint method has been renamed; see v2 Migration Guide for details
  • Added name: string parameter to ScreepsHttpClient.changeFlagColor()
  • Added _id: string parameter to ScreepsHttpClient.gameAddObjectIntent()
  • Removed encoded parameter from ScreepsHttpClient.gameRoomTerrain()
    • To get unencoded results, use ScreepsHttpClient.gameRoomTerrainUnencoded()
  • Refactored ScreepsHttpClient.userCodeSet() request params into an object so they could share types with ScreepsHttpClient.userCodeGet() responses
  • Endpoints that require a shard argument will now throw an error if the argument is not defined and if ScreepsClientConfig.defaultShard is not defined
    • 'shard0' is no longer used as a default to prevent accidental operations on the wrong shard
  • ScreepsHttpClient now only fires the rateLimit event when a rate limit is exceeded.
  • experimentalRetry429 option:
    • Renamed this option to retry429Global
    • It is now specified as a ScreepsClientConfig option instead of being part of the server config
    • This option is now enabled by default

WebSocket API:

  • connect() no longer accepts ScreepsSocketConfig options
    • These events are loaded/set in appConfig like they are for the HTTP client (see related change in "New Features")
  • resubscribe() no longer subscribes to events that were fully unsubscribed before disconnecting
  • subscribe() no longer registers duplicate instances of the same callback to the same events
    • Legacy behavior can be triggered by passing true for new force param
  • ScreepsHttpClient.setServer() now triggers disconnect()
  • authed, connected, and reconnecting properties now have private setters
  • ws and http properties are now protected

CLI:

  • Changed error-handling behavior:
    • Help is now printed after usage errors (ex: invalid raw command)
    • Non-zero exit status is now returned on all errors
  • Changed memory output format:
    • Nothing is emitted if the Memory path does not exist
    • JSON output is serialized before being emitted to stdout to allow the full contents to be inspected

New Features and Improvements

General:

HTTP API:

  • ScreepsHttpClient now authenticates automatically as needed
  • Added ScreepsHttpClient.userCpuShards endpoint
  • Added ScreepsHttpClient.seasonsCurrent endpoint
  • Added ScreepsHttpClient.userActivatePtr endpoint
  • Added support for automatic retries on HTTP 429 errors due to endpoint-specific rate limits

WebSocket API:

  • ScreepsSocketClient now authenticates automatically as needed
  • Added event-specific subscribe___()/unsubscribe____() methods:
    • These new variants of subscribe()/unsubscribe() automatically determine the eventSpec argument and enforce appropriate type constraints on callback arguments
    • These are equivalent to the endpoint methods on ScreepsHttpClient
  • ScreepsSocketClient options can now be loaded from config files

CLI:

  • Added memory --pretty option to pretty-print output to files or stdout

Fixes

WebSocket API:

  • Fixed ScreepsSocketClient async bug when trying to process gzipped data
  • Fixed bug that emitted queued messages as events instead of sending them

CLI:

  • Fixed async bug when trying to write memory to disk via memory -f <file>
  • Fixed ReferenceError when trying to write a single memory segment to disk via segment -d <dir> <segmentNumber>

Full Changelog: 8b6ad48...v2.0

Please see the this package's npm versions page for releases between v1.0.0 and v2.0.0: https://www.npmjs.com/package/screeps-api?activeTab=versions