screeps-connectivity 0.7.0 → 0.8.1

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/CHANGELOG.md CHANGED
@@ -1,5 +1,21 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.8.1
4
+
5
+ ### Patch Changes
6
+
7
+ - f29f9a8: Fix world bounds calculation for single-quadrant maps (e.g. E/S-only servers) — previously the client assumed a symmetric world and mapped e.g. E0S0–E11S11 to W6N6–E5S5.
8
+
9
+ ## 0.8.0
10
+
11
+ ### Minor Changes
12
+
13
+ - fb4ab0a: Add a read-only Market section — all orders, my orders, and history — matching the vanilla client.
14
+
15
+ ### Patch Changes
16
+
17
+ - 620f551: Add Power Creeps pages — list, create, and per-creep power upgrades — from the Overview page.
18
+
3
19
  ## 0.7.0
4
20
 
5
21
  ### Minor Changes
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "screeps-connectivity",
3
- "version": "0.7.0",
3
+ "version": "0.8.1",
4
4
  "license": "ISC",
5
5
  "type": "module",
6
6
  "repository": {
@@ -15,6 +15,10 @@ import type {
15
15
  ApiGameTickResponse,
16
16
  RoomHistoryChunk,
17
17
  ApiRoomDecorationsResponse,
18
+ ApiMarketOrdersIndexResponse,
19
+ ApiMarketOrdersResponse,
20
+ ApiMarketMyOrdersResponse,
21
+ ApiMarketStatsResponse,
18
22
  } from '../../types/api.js'
19
23
  import { createPowerCreepsEndpoints, type PowerCreepsEndpoints } from './power-creeps.js'
20
24
 
@@ -49,10 +53,10 @@ export interface GameEndpoints {
49
53
  removeInvader(id: string): Promise<{ ok: number }>
50
54
  powerCreeps: PowerCreepsEndpoints
51
55
  market: {
52
- ordersIndex(shard?: string | null): Promise<unknown>
53
- myOrders(): Promise<unknown>
54
- orders(resourceType: string, shard?: string | null): Promise<unknown>
55
- stats(resourceType: string, shard?: string | null): Promise<unknown>
56
+ ordersIndex(shard?: string | null): Promise<ApiMarketOrdersIndexResponse>
57
+ myOrders(): Promise<ApiMarketMyOrdersResponse>
58
+ orders(resourceType: string, shard?: string | null): Promise<ApiMarketOrdersResponse>
59
+ stats(resourceType: string, shard?: string | null): Promise<ApiMarketStatsResponse>
56
60
  }
57
61
  shards: {
58
62
  info(): Promise<ApiShardsInfoResponse>
package/src/index.ts CHANGED
@@ -40,7 +40,7 @@ export type {
40
40
 
41
41
  export { fetchServerVersion, fetchAuthModInfo, checkUsername, checkEmail, registerUser, getServerFeature, getScreepsmodAuth } from './http/fetchServerVersion.js'
42
42
  export type { ApiAuthModInfoResponse } from './http/fetchServerVersion.js'
43
- export type { RoomHistoryChunk, ApiRoomDecorationsResponse, ApiRoomDecorationItem, ApiRoomDecorationDef, ApiRoomDecorationGraphic, ApiRoomDecorationActive, ApiUserOverviewResponse, ApiUserOverviewTotals, ApiUserRoomsResponse } from './types/api.js'
43
+ export type { RoomHistoryChunk, ApiRoomDecorationsResponse, ApiRoomDecorationItem, ApiRoomDecorationDef, ApiRoomDecorationGraphic, ApiRoomDecorationActive, ApiUserOverviewResponse, ApiUserOverviewTotals, ApiUserRoomsResponse, ApiUserMoneyHistoryResponse, ApiMarketOrder, ApiMarketOrdersIndexResponse, ApiMarketOrdersResponse, ApiMarketMyOrdersResponse, ApiMarketStat, ApiMarketStatsResponse, ApiPowerCreep, ApiPowerCreepsListResponse } from './types/api.js'
44
44
  export { ROOM_DECORATIONS_MOCK } from './mocks/roomDecorations.js'
45
45
 
46
46
  export { badgeToSvg } from './badge/index.js'
@@ -102,16 +102,30 @@ export class ServerStore extends TypedStore<ServerStoreEvents> {
102
102
  const stats = probe.stats ?? {}
103
103
  const found = (['W0N0', 'E0N0', 'W0S0', 'E0S0'] as const).filter(r => r in stats)
104
104
  this.logger.log(`worldInfo corner probe — found: [${found.length ? found.join(', ') : 'none'}]`)
105
- if ('E0N0' in stats || 'E0S0' in stats) {
106
- // E quadrant exists: width spans both W and E sides, split evenly
105
+ const hasEast = 'E0N0' in stats || 'E0S0' in stats
106
+ const hasWest = 'W0N0' in stats || 'W0S0' in stats
107
+ const hasSouth = 'W0S0' in stats || 'E0S0' in stats
108
+ const hasNorth = 'W0N0' in stats || 'E0N0' in stats
109
+ if (hasEast && hasWest) {
110
+ // Both E and W quadrants exist: split width evenly around E0/W0
107
111
  minX = -Math.ceil(width / 2)
108
112
  maxX = Math.floor(width / 2) - 1
113
+ } else if (hasEast) {
114
+ // Only E quadrant: all rooms are east of E0
115
+ minX = 0
116
+ maxX = width - 1
109
117
  }
110
- if ('W0S0' in stats || 'E0S0' in stats) {
111
- // S quadrant exists: height spans both N and S sides, split evenly
118
+ // else: W-only keeps default (minX=-width, maxX=-1)
119
+ if (hasSouth && hasNorth) {
120
+ // Both S and N quadrants exist: split height evenly around S0/N0
112
121
  minY = -Math.ceil(height / 2)
113
122
  maxY = Math.floor(height / 2) - 1
123
+ } else if (hasSouth) {
124
+ // Only S quadrant: all rooms are south of S0
125
+ minY = 0
126
+ maxY = height - 1
114
127
  }
128
+ // else: N-only keeps default (minY=-height, maxY=-1)
115
129
  } catch (e) {
116
130
  this.logger.log('worldInfo corner probe failed — keeping W/N defaults:', e)
117
131
  }
package/src/types/api.ts CHANGED
@@ -245,6 +245,8 @@ export interface ApiUserFindResponse {
245
245
  export interface ApiUserMoneyHistoryResponse {
246
246
  ok: number
247
247
  page: number
248
+ // True when an older page exists; drives the History "Older" pager.
249
+ hasMore?: boolean
248
250
  list: Array<{
249
251
  _id: string
250
252
  date: string
@@ -252,10 +254,64 @@ export interface ApiUserMoneyHistoryResponse {
252
254
  type: string
253
255
  balance: number
254
256
  change: number
257
+ // Shard the transaction occurred on (official multi-shard servers only).
258
+ shard?: string
255
259
  market?: unknown
256
260
  }>
257
261
  }
258
262
 
263
+ // Market — a single order from game/market/orders (public) or my-orders (own).
264
+ // `active`/`totalAmount` are returned only for your own orders. `range` is not
265
+ // part of the API response — the client computes it as the room distance to a
266
+ // chosen target room.
267
+ export interface ApiMarketOrder {
268
+ _id: string
269
+ type: 'sell' | 'buy'
270
+ resourceType: string
271
+ price: number
272
+ amount: number
273
+ remainingAmount: number
274
+ /** Original order size — own orders only. */
275
+ totalAmount?: number
276
+ /** Whether the order is currently funded/stocked — own orders only. */
277
+ active?: boolean
278
+ /** Source/target room; absent for token and other roomless orders. */
279
+ roomName?: string
280
+ created?: number
281
+ }
282
+
283
+ export interface ApiMarketOrdersIndexResponse {
284
+ ok: number
285
+ // One entry per resource type that has open orders; `_id` is the resource type.
286
+ list: Array<{ _id: string; count: number }>
287
+ }
288
+
289
+ export interface ApiMarketOrdersResponse {
290
+ ok: number
291
+ list: ApiMarketOrder[]
292
+ }
293
+
294
+ // Own orders: multi-shard servers return `shards` keyed by shard name;
295
+ // single-shard servers return a flat `list` instead.
296
+ export interface ApiMarketMyOrdersResponse {
297
+ ok: number
298
+ shards?: Record<string, ApiMarketOrder[]>
299
+ list?: ApiMarketOrder[]
300
+ }
301
+
302
+ export interface ApiMarketStat {
303
+ date: string
304
+ transactions: number
305
+ volume: number
306
+ avgPrice: number
307
+ stddevPrice: number
308
+ }
309
+
310
+ export interface ApiMarketStatsResponse {
311
+ ok: number
312
+ stats: ApiMarketStat[]
313
+ }
314
+
259
315
  export interface ApiUserMessage {
260
316
  _id: string
261
317
  date: string