@spacemolt/lib 12.2.2 → 13.0.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.
- package/COMMANDS.md +34 -26
- package/README.md +8 -2
- package/dist/account.d.ts +17 -0
- package/dist/data/catalog.d.ts +25 -5
- package/dist/data/map.d.ts +12 -11
- package/dist/data/mobile-base.d.ts +13 -0
- package/dist/data/stations.d.ts +10 -0
- package/dist/generated/actions.gen.d.ts +2 -2
- package/dist/generated/commands.gen.d.ts +166 -71
- package/dist/generated/notifications.gen.d.ts +14 -3
- package/dist/generated/openapi/types.gen.d.ts +2085 -717
- package/dist/index.d.ts +2 -1
- package/dist/index.js +304 -113
- package/dist/protocol.d.ts +33 -26
- package/dist/state/cache.d.ts +9 -1
- package/package.json +1 -1
package/dist/protocol.d.ts
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
* spec instead (see src/generated/). Endpoint: `/ws/v2`.
|
|
8
8
|
*/
|
|
9
9
|
import type { NotificationPayloads, TypedNotificationType } from './generated/notifications.gen.js';
|
|
10
|
-
import type { V2GameState } from './generated/openapi/types.gen.js';
|
|
10
|
+
import type { LoggedInPayload, RegisteredPayload, V2GameState, WelcomePayload } from './generated/openapi/types.gen.js';
|
|
11
11
|
/** Inbound frame: client -> server. `payload` is omitted when an action takes none. */
|
|
12
12
|
export interface InboundFrame {
|
|
13
13
|
tool: string;
|
|
@@ -70,38 +70,31 @@ export interface ErrorFrame {
|
|
|
70
70
|
pending_command?: string;
|
|
71
71
|
};
|
|
72
72
|
}
|
|
73
|
-
/**
|
|
73
|
+
/**
|
|
74
|
+
* Unsolicited frame sent immediately after the socket upgrade. No request_id.
|
|
75
|
+
*
|
|
76
|
+
* The three auth/handshake payloads below are the server's published schemas
|
|
77
|
+
* rather than hand-written mirrors, so a server-side field change breaks
|
|
78
|
+
* `typecheck` here instead of silently rotting a copy (gameserver-todo #2/#5).
|
|
79
|
+
*/
|
|
74
80
|
export interface WelcomeFrame {
|
|
75
81
|
type: 'welcome';
|
|
76
|
-
payload:
|
|
77
|
-
version: string;
|
|
78
|
-
release_date: string;
|
|
79
|
-
release_notes: string[];
|
|
80
|
-
tick_rate: number;
|
|
81
|
-
current_tick: number;
|
|
82
|
-
server_time: number;
|
|
83
|
-
motd?: string;
|
|
84
|
-
game_info: string;
|
|
85
|
-
website: string;
|
|
86
|
-
help_text: string;
|
|
87
|
-
terms: string;
|
|
88
|
-
};
|
|
82
|
+
payload: WelcomePayload;
|
|
89
83
|
}
|
|
90
84
|
/** Auth success frame carrying the full initial session state. */
|
|
91
85
|
export interface LoggedInFrame {
|
|
92
86
|
type: 'logged_in';
|
|
93
87
|
request_id?: string;
|
|
94
|
-
payload:
|
|
88
|
+
payload: LoggedInPayload;
|
|
95
89
|
}
|
|
96
|
-
/**
|
|
90
|
+
/**
|
|
91
|
+
* Auth success frame after `register`, carrying generated credentials.
|
|
92
|
+
* `password` is a 256-bit hex credential — this is the only chance to capture it.
|
|
93
|
+
*/
|
|
97
94
|
export interface RegisteredFrame {
|
|
98
95
|
type: 'registered';
|
|
99
96
|
request_id?: string;
|
|
100
|
-
payload:
|
|
101
|
-
/** 256-bit hex credential — only chance to capture it. */
|
|
102
|
-
password: string;
|
|
103
|
-
player_id: string;
|
|
104
|
-
};
|
|
97
|
+
payload: RegisteredPayload;
|
|
105
98
|
}
|
|
106
99
|
/**
|
|
107
100
|
* A server-initiated push frame whose msg_type has a published payload schema.
|
|
@@ -133,15 +126,29 @@ export declare function isWelcomeFrame(frame: RawFrame): frame is WelcomeFrame;
|
|
|
133
126
|
export declare function isLoggedInFrame(frame: RawFrame): frame is LoggedInFrame;
|
|
134
127
|
export declare function isRegisteredFrame(frame: RawFrame): frame is RegisteredFrame;
|
|
135
128
|
/**
|
|
136
|
-
* The cacheable game-state sections — the
|
|
129
|
+
* The cacheable game-state sections — the nine independently-tracked sections
|
|
137
130
|
* the server emits deltas for. Section shapes are derived from the spec's
|
|
138
131
|
* `V2GameState`, so they stay correct as the spec evolves.
|
|
132
|
+
*
|
|
133
|
+
* The list itself is not spec-derived, so it has to be kept in step by hand:
|
|
134
|
+
* the authority is the `x-state-sections` a mutation operation declares (from
|
|
135
|
+
* the server's `StateSections` bitmask in `internal/handlers/delta_wrapper.go`).
|
|
136
|
+
* A section missing here is silently dropped from every delta, so
|
|
137
|
+
* `tests/generated.test.ts` cross-checks this list against the spec.
|
|
138
|
+
*
|
|
139
|
+
* `V2GameState` carries further keys that are *not* delta sections and so are
|
|
140
|
+
* deliberately absent from the cache — read them off the query response that
|
|
141
|
+
* returns them: `riding` (`get_status`, when riding as a passenger with no ship
|
|
142
|
+
* of your own), `drone_bay` (`get_ship`), `carried_ships`/`bay_used`/
|
|
143
|
+
* `bay_capacity` (`get_cargo`, carriers only), and `version` (`get_status`).
|
|
144
|
+
* Note `fleet/board` and `fleet/disembark` declare no state sections at all, so
|
|
145
|
+
* boarding emits no delta: call `refresh()` after one.
|
|
139
146
|
*/
|
|
140
|
-
export type GameState = Pick<V2GameState, 'player' | 'ship' | 'modules' | 'cargo' | 'location' | 'missions' | 'queue' | 'skills'>;
|
|
147
|
+
export type GameState = Pick<V2GameState, 'player' | 'ship' | 'modules' | 'cargo' | 'location' | 'missions' | 'queue' | 'skills' | 'prize_recoveries'>;
|
|
141
148
|
/**
|
|
142
149
|
* A `V2GameState` delta carried on `action_result`. Only changed sections are
|
|
143
150
|
* present; an absent section means unchanged (keep prior local state). Carries
|
|
144
|
-
* the same
|
|
151
|
+
* the same nine sections as `GameState` plus the per-action convenience fields.
|
|
145
152
|
*/
|
|
146
153
|
export type StateDelta = GameState & Pick<V2GameState, 'message' | 'details' | 'credits'>;
|
|
147
154
|
/**
|
|
@@ -181,5 +188,5 @@ export interface MutationResult<TDetails = Record<string, unknown>> {
|
|
|
181
188
|
autoDocked?: boolean;
|
|
182
189
|
autoUndocked?: boolean;
|
|
183
190
|
}
|
|
184
|
-
export declare const STATE_SECTIONS: readonly ["player", "ship", "modules", "cargo", "location", "missions", "queue", "skills"];
|
|
191
|
+
export declare const STATE_SECTIONS: readonly ["player", "ship", "modules", "cargo", "location", "missions", "queue", "skills", "prize_recoveries"];
|
|
185
192
|
export type StateSection = (typeof STATE_SECTIONS)[number];
|
package/dist/state/cache.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Per-account local cache of the
|
|
2
|
+
* Per-account local cache of the nine game-state sections.
|
|
3
3
|
*
|
|
4
4
|
* Seeded canonically from a full `V2GameState` snapshot (the `get_status`
|
|
5
5
|
* query returns exactly this shape) and kept current by applying the section
|
|
@@ -37,6 +37,14 @@ export declare class StateCache {
|
|
|
37
37
|
get modules(): GameState['modules'];
|
|
38
38
|
get missions(): GameState['missions'];
|
|
39
39
|
get skills(): GameState['skills'];
|
|
40
|
+
/**
|
|
41
|
+
* Active intact-ship recovery operations assigned to this player, including
|
|
42
|
+
* prizes in transit or stalled outside the current POI. Refreshed by the
|
|
43
|
+
* deltas of the player's own prize commands (`claim_prize`, `service_prize`)
|
|
44
|
+
* and by `refresh()` — the `prize_update`/`ship_captured` pushes do not carry
|
|
45
|
+
* a delta, so this is not a live feed.
|
|
46
|
+
*/
|
|
47
|
+
get prizeRecoveries(): GameState['prize_recoveries'];
|
|
40
48
|
/** True when a tick-deferred action is queued for this account. */
|
|
41
49
|
get hasPendingAction(): boolean;
|
|
42
50
|
get credits(): number | undefined;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@spacemolt/lib",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "13.0.0",
|
|
4
4
|
"description": "The definitive TypeScript library for SpaceMolt. WebSocket-v2-first, multi-account, with local state caches. Internals are regenerated from the server's OpenAPI spec.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"module": "./dist/index.js",
|