@dreamboard-games/sdk 0.4.0-alpha.0 → 0.4.0-alpha.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.
- package/README.md +8 -1
- package/REFERENCE.md +1849 -379
- package/dist/{ResourceCounter-BTXklCEZ.d.ts → ResourceCounter-BuiNstXs.d.ts} +5 -1
- package/dist/{ThemeProvider-DvMl17Ny.d.ts → ThemeProvider-B1sIoBlX.d.ts} +1 -1
- package/dist/attributes-DbvyMbXw.d.ts +68 -0
- package/dist/authoring/index.d.ts +66 -0
- package/dist/authoring/index.js +560 -0
- package/dist/authoring/index.js.map +1 -0
- package/dist/browser-interaction.d.ts +246 -44
- package/dist/browser-interaction.js +14 -1
- package/dist/{chunk-Q5O7GPVY.js → chunk-45FI6XII.js} +630 -375
- package/dist/chunk-45FI6XII.js.map +1 -0
- package/dist/{chunk-4G7552LO.js → chunk-6JQFGSLD.js} +216 -47
- package/dist/chunk-6JQFGSLD.js.map +1 -0
- package/dist/{chunk-NBAEEHAU.js → chunk-CP35NPPY.js} +5926 -5266
- package/dist/chunk-CP35NPPY.js.map +1 -0
- package/dist/{chunk-2LDZ5C3T.js → chunk-FWVV2X74.js} +2 -2
- package/dist/{chunk-MNKDSGIA.js → chunk-HWJS3VOJ.js} +6 -2
- package/dist/chunk-HWJS3VOJ.js.map +1 -0
- package/dist/chunk-K5ZRJTZZ.js +328 -0
- package/dist/chunk-K5ZRJTZZ.js.map +1 -0
- package/dist/{chunk-U5KBV2BA.js → chunk-N6ZDIMRB.js} +444 -223
- package/dist/chunk-N6ZDIMRB.js.map +1 -0
- package/dist/chunk-O6M6PN4E.js +1225 -0
- package/dist/chunk-O6M6PN4E.js.map +1 -0
- package/dist/chunk-PF7L4BMG.js +117 -0
- package/dist/chunk-PF7L4BMG.js.map +1 -0
- package/dist/{chunk-P7F4L2FF.js → chunk-WOWFONLZ.js} +609 -1287
- package/dist/chunk-WOWFONLZ.js.map +1 -0
- package/dist/{chunk-QLG6VEMW.js → chunk-WUIVY2KE.js} +318 -21
- package/dist/chunk-WUIVY2KE.js.map +1 -0
- package/dist/chunk-ZAS2SENW.js +12 -0
- package/dist/chunk-ZAS2SENW.js.map +1 -0
- package/dist/codegen.d.ts +11 -1
- package/dist/codegen.js +1 -1
- package/dist/{components-DaIqi9QM.d.ts → components-BbWPnZCF.d.ts} +37 -70
- package/dist/{hex-board-view-UCUjMALd.d.ts → hex-board-view-Kz9Q_zsv.d.ts} +1 -1
- package/dist/index.js +2 -1
- package/dist/package-set.d.ts +2 -2
- package/dist/package-set.js +2 -1
- package/dist/player-state-Cqpyeql0.d.ts +371 -0
- package/dist/protocol-BP193lva.d.ts +267 -0
- package/dist/reducer/advanced.d.ts +2 -2
- package/dist/reducer/advanced.js +1 -1
- package/dist/reducer-contract.js +1 -1
- package/dist/reducer.d.ts +7 -7
- package/dist/reducer.js +190 -183
- package/dist/reducer.js.map +1 -1
- package/dist/runtime/primitives.d.ts +10 -9
- package/dist/runtime/primitives.js +9 -6
- package/dist/runtime/runtime-api.d.ts +2 -2
- package/dist/runtime/workspace-contract.d.ts +28 -76
- package/dist/runtime/workspace-contract.js +7 -5
- package/dist/runtime-api-BJharVaj.d.ts +198 -0
- package/dist/runtime-api-C6aWo9c0.d.ts +95 -0
- package/dist/runtime-json-CQ9QbLZ5.d.ts +5 -0
- package/dist/runtime.d.ts +80 -11
- package/dist/runtime.js +89 -445
- package/dist/runtime.js.map +1 -1
- package/dist/testing.d.ts +643 -22
- package/dist/testing.js +1371 -76
- package/dist/testing.js.map +1 -1
- package/dist/types-CYeN0wLK.d.ts +29 -0
- package/dist/{attributes-BeRyboMS.d.ts → types-DJj5MJkl.d.ts} +32 -55
- package/dist/types.d.ts +14 -7
- package/dist/ui/components.d.ts +4 -5
- package/dist/ui/components.js +19 -1
- package/dist/ui/player-state.d.ts +2 -365
- package/dist/ui/plugin-styles.css +1 -1
- package/dist/{ui-contract-BUC6iS3s.d.ts → ui-contract-CY7cxsCC.d.ts} +17 -26
- package/dist/ui.d.ts +8 -13
- package/dist/ui.js +20 -2
- package/dist/{views-B0hlW6IT.d.ts → views-fn2RuXOx.d.ts} +59 -44
- package/package.json +28 -4
- package/dist/chunk-4G7552LO.js.map +0 -1
- package/dist/chunk-MNKDSGIA.js.map +0 -1
- package/dist/chunk-NBAEEHAU.js.map +0 -1
- package/dist/chunk-P7F4L2FF.js.map +0 -1
- package/dist/chunk-Q5O7GPVY.js.map +0 -1
- package/dist/chunk-QLG6VEMW.js.map +0 -1
- package/dist/chunk-U5KBV2BA.js.map +0 -1
- package/dist/hex-color-MhOyuY-o.d.ts +0 -8
- package/dist/runtime-api-BXd70c2e.d.ts +0 -490
- /package/dist/{chunk-2LDZ5C3T.js.map → chunk-FWVV2X74.js.map} +0 -0
|
@@ -0,0 +1,371 @@
|
|
|
1
|
+
import { ViewCard } from './types.js';
|
|
2
|
+
|
|
3
|
+
type HexColor = string & {
|
|
4
|
+
readonly __brand: "HexColor";
|
|
5
|
+
};
|
|
6
|
+
declare function isHexColor(value: unknown): value is HexColor;
|
|
7
|
+
declare function parseHexColor(value: unknown): HexColor | undefined;
|
|
8
|
+
declare function hexColor(value: string): HexColor;
|
|
9
|
+
|
|
10
|
+
type PlayerId = string;
|
|
11
|
+
type CardId = string;
|
|
12
|
+
type DeckId = string;
|
|
13
|
+
type BoardBaseId = string;
|
|
14
|
+
type BoardId = string;
|
|
15
|
+
type PieceId = string;
|
|
16
|
+
type SpaceId = string;
|
|
17
|
+
type DieId = string;
|
|
18
|
+
type EdgeTypeId = string;
|
|
19
|
+
type VertexTypeId = string;
|
|
20
|
+
type PieceTypeId = string;
|
|
21
|
+
type SpaceTypeId = string;
|
|
22
|
+
type CardProperties = Record<string, unknown>;
|
|
23
|
+
type CardIdsByDeckId = Record<DeckId, readonly CardId[]>;
|
|
24
|
+
interface PerPlayer<Value> {
|
|
25
|
+
readonly __perPlayer: true;
|
|
26
|
+
readonly entries: ReadonlyArray<readonly [PlayerId, Value]>;
|
|
27
|
+
}
|
|
28
|
+
interface SharedBoardRef<BaseId extends string = BoardBaseId> {
|
|
29
|
+
readonly baseId: BaseId;
|
|
30
|
+
readonly seat?: undefined;
|
|
31
|
+
}
|
|
32
|
+
interface PerPlayerBoardRef<BaseId extends string = BoardBaseId, Id extends string = PlayerId> {
|
|
33
|
+
readonly baseId: BaseId;
|
|
34
|
+
readonly seat: Id;
|
|
35
|
+
}
|
|
36
|
+
type BoardRef<BaseId extends string = BoardBaseId, Id extends string = PlayerId> = SharedBoardRef<BaseId> | PerPlayerBoardRef<BaseId, Id>;
|
|
37
|
+
/**
|
|
38
|
+
* Hands are keyed by the authored hand id and split per seat. The per-seat
|
|
39
|
+
* entries are populated from the runtime seat list, not the static manifest
|
|
40
|
+
* upper bound, so views always match what the backend actually computed.
|
|
41
|
+
*/
|
|
42
|
+
type CardIdsByHandId = Record<string, PerPlayer<CardId[]>>;
|
|
43
|
+
type StateName = string;
|
|
44
|
+
type TilePropertiesByBoardId = Record<BoardId, Record<string, unknown>>;
|
|
45
|
+
type EdgePropertiesByBoardId = Record<BoardId, Record<string, unknown>>;
|
|
46
|
+
type VertexPropertiesByBoardId = Record<BoardId, Record<string, unknown>>;
|
|
47
|
+
interface Player {
|
|
48
|
+
/** Player ID */
|
|
49
|
+
playerId: PlayerId;
|
|
50
|
+
/** Player display name */
|
|
51
|
+
name: string;
|
|
52
|
+
/** Whether this player is the host */
|
|
53
|
+
isHost?: boolean;
|
|
54
|
+
/** Player's assigned color */
|
|
55
|
+
color?: HexColor;
|
|
56
|
+
}
|
|
57
|
+
interface HexTileState<B extends string = BoardId, SpaceIdValue extends string = SpaceId, Properties = B extends keyof TilePropertiesByBoardId ? TilePropertiesByBoardId[B] : undefined, View = unknown> {
|
|
58
|
+
/** Unique tile identifier */
|
|
59
|
+
id: SpaceIdValue;
|
|
60
|
+
/** Axial coordinate Q */
|
|
61
|
+
q: number;
|
|
62
|
+
/** Axial coordinate R */
|
|
63
|
+
r: number;
|
|
64
|
+
/** Tile type identifier for rendering */
|
|
65
|
+
typeId?: SpaceTypeId;
|
|
66
|
+
/** Display label on the tile */
|
|
67
|
+
label?: string;
|
|
68
|
+
/** Player ID who owns this tile */
|
|
69
|
+
owner?: PlayerId;
|
|
70
|
+
/** JSON-serialized custom properties */
|
|
71
|
+
properties?: Properties;
|
|
72
|
+
/**
|
|
73
|
+
* Optional view-projection overlay merged onto the static topology by
|
|
74
|
+
* component-first board helpers such as `Board.HexView`. Authored boards can
|
|
75
|
+
* also supply this directly when building tiles by hand.
|
|
76
|
+
*/
|
|
77
|
+
view?: View;
|
|
78
|
+
}
|
|
79
|
+
/** State of an edge on a reducer-projected hex board. */
|
|
80
|
+
interface HexEdgeState<B extends string = BoardId, SpaceIdValue extends string = SpaceId, EdgeIdValue extends string = string, Properties = B extends keyof EdgePropertiesByBoardId ? EdgePropertiesByBoardId[B] : undefined> {
|
|
81
|
+
/** Unique edge identifier (serialized string, e.g., "tile1-tile2") */
|
|
82
|
+
id: EdgeIdValue;
|
|
83
|
+
/** First hex tile ID this edge borders */
|
|
84
|
+
hex1: SpaceIdValue;
|
|
85
|
+
/** Second hex tile ID this edge borders */
|
|
86
|
+
hex2: SpaceIdValue;
|
|
87
|
+
/** Edge type identifier for rendering */
|
|
88
|
+
typeId?: EdgeTypeId;
|
|
89
|
+
/** Display label for setup or rendering */
|
|
90
|
+
label?: string;
|
|
91
|
+
/** Player ID who owns this edge */
|
|
92
|
+
owner?: PlayerId;
|
|
93
|
+
/** JSON-serialized custom properties */
|
|
94
|
+
properties?: Properties;
|
|
95
|
+
}
|
|
96
|
+
/** State of a vertex on a reducer-projected hex board. */
|
|
97
|
+
interface HexVertexState<B extends string = BoardId, SpaceIdValue extends string = SpaceId, VertexIdValue extends string = string, Properties = B extends keyof VertexPropertiesByBoardId ? VertexPropertiesByBoardId[B] : undefined> {
|
|
98
|
+
/** Unique vertex identifier (serialized string, e.g., "tile1-tile2-tile3") */
|
|
99
|
+
id: VertexIdValue;
|
|
100
|
+
/** The hex tile IDs this vertex touches */
|
|
101
|
+
hexes: readonly SpaceIdValue[];
|
|
102
|
+
/** Vertex type identifier for rendering */
|
|
103
|
+
typeId?: VertexTypeId;
|
|
104
|
+
/** Display label for setup or rendering */
|
|
105
|
+
label?: string;
|
|
106
|
+
/** Player ID who owns this vertex */
|
|
107
|
+
owner?: PlayerId;
|
|
108
|
+
/** JSON-serialized custom properties */
|
|
109
|
+
properties?: Properties;
|
|
110
|
+
}
|
|
111
|
+
/** Complete state of a reducer-projected hex board. */
|
|
112
|
+
interface HexBoardState<B extends string = BoardId, SpaceIdValue extends string = SpaceId, EdgeIdValue extends string = string, VertexIdValue extends string = string, TileProperties = B extends keyof TilePropertiesByBoardId ? TilePropertiesByBoardId[B] : undefined, EdgeProperties = B extends keyof EdgePropertiesByBoardId ? EdgePropertiesByBoardId[B] : undefined, VertexProperties = B extends keyof VertexPropertiesByBoardId ? VertexPropertiesByBoardId[B] : undefined> {
|
|
113
|
+
/** Unique board identifier */
|
|
114
|
+
id: B;
|
|
115
|
+
/** All tiles on the board */
|
|
116
|
+
tiles: ReadonlyArray<HexTileState<B, SpaceIdValue, TileProperties>>;
|
|
117
|
+
/** All edges on the board */
|
|
118
|
+
edges: ReadonlyArray<HexEdgeState<B, SpaceIdValue, EdgeIdValue, EdgeProperties>>;
|
|
119
|
+
/** All vertices on the board */
|
|
120
|
+
vertices: ReadonlyArray<HexVertexState<B, SpaceIdValue, VertexIdValue, VertexProperties>>;
|
|
121
|
+
}
|
|
122
|
+
/** State of a node in a reducer-projected network board. */
|
|
123
|
+
interface NetworkNodeState {
|
|
124
|
+
/** Unique node identifier */
|
|
125
|
+
id: SpaceId;
|
|
126
|
+
/** X coordinate position */
|
|
127
|
+
x: number;
|
|
128
|
+
/** Y coordinate position */
|
|
129
|
+
y: number;
|
|
130
|
+
/** Node type identifier for rendering */
|
|
131
|
+
typeId?: SpaceTypeId;
|
|
132
|
+
/** Display label on the node */
|
|
133
|
+
label?: string;
|
|
134
|
+
/** Player ID who owns this node */
|
|
135
|
+
owner?: PlayerId;
|
|
136
|
+
/** JSON-serialized custom properties */
|
|
137
|
+
properties?: string;
|
|
138
|
+
}
|
|
139
|
+
/** State of an edge connecting two nodes in a reducer-projected network board. */
|
|
140
|
+
interface NetworkEdgeState {
|
|
141
|
+
/** Unique edge identifier */
|
|
142
|
+
id: string;
|
|
143
|
+
/** Source node ID */
|
|
144
|
+
from: SpaceId;
|
|
145
|
+
/** Target node ID */
|
|
146
|
+
to: SpaceId;
|
|
147
|
+
/** Edge type identifier for rendering */
|
|
148
|
+
typeId?: string;
|
|
149
|
+
/** Display label on the edge */
|
|
150
|
+
label?: string;
|
|
151
|
+
/** Player ID who owns this edge */
|
|
152
|
+
owner?: PlayerId;
|
|
153
|
+
/** JSON-serialized custom properties */
|
|
154
|
+
properties?: string;
|
|
155
|
+
}
|
|
156
|
+
/** State of a piece placed on a reducer-projected network node. */
|
|
157
|
+
interface NetworkPieceState {
|
|
158
|
+
/** Unique piece identifier */
|
|
159
|
+
id: PieceId;
|
|
160
|
+
/** Node ID where this piece is placed */
|
|
161
|
+
nodeId: SpaceId;
|
|
162
|
+
/** Piece type identifier for rendering */
|
|
163
|
+
typeId?: PieceTypeId;
|
|
164
|
+
/** Player ID who owns this piece */
|
|
165
|
+
owner?: PlayerId;
|
|
166
|
+
/** JSON-serialized custom properties */
|
|
167
|
+
properties?: string;
|
|
168
|
+
}
|
|
169
|
+
/** Complete state of a reducer-projected network board. */
|
|
170
|
+
interface NetworkBoardState {
|
|
171
|
+
/** Unique board identifier */
|
|
172
|
+
id: BoardId;
|
|
173
|
+
/** All nodes on the board */
|
|
174
|
+
nodes: NetworkNodeState[];
|
|
175
|
+
/** All edges on the board */
|
|
176
|
+
edges: NetworkEdgeState[];
|
|
177
|
+
/** All pieces on the board */
|
|
178
|
+
pieces: NetworkPieceState[];
|
|
179
|
+
}
|
|
180
|
+
/** State of a cell on a reducer-projected square grid board. */
|
|
181
|
+
interface SquareCellState<SpaceIdValue extends string = SpaceId, Properties = Record<string, unknown>> {
|
|
182
|
+
/** Unique cell identifier */
|
|
183
|
+
id: SpaceIdValue;
|
|
184
|
+
/** Row index (0-based) */
|
|
185
|
+
row: number;
|
|
186
|
+
/** Column index (0-based) */
|
|
187
|
+
col: number;
|
|
188
|
+
/** Cell type identifier for rendering */
|
|
189
|
+
typeId?: SpaceTypeId;
|
|
190
|
+
/** Display label on the cell */
|
|
191
|
+
label?: string;
|
|
192
|
+
/** Player ID who owns this cell */
|
|
193
|
+
owner?: PlayerId;
|
|
194
|
+
/** JSON-serialized custom properties */
|
|
195
|
+
properties?: Properties;
|
|
196
|
+
}
|
|
197
|
+
/** State of an edge on a reducer-projected square grid board. */
|
|
198
|
+
interface SquareEdgeState<SpaceIdValue extends string = SpaceId, EdgeIdValue extends string = string, Properties = Record<string, unknown>> {
|
|
199
|
+
/** Unique edge identifier */
|
|
200
|
+
id: EdgeIdValue;
|
|
201
|
+
/** The cell IDs this edge borders */
|
|
202
|
+
spaceIds: readonly SpaceIdValue[];
|
|
203
|
+
/** Edge type identifier for rendering */
|
|
204
|
+
typeId?: EdgeTypeId;
|
|
205
|
+
/** Display label for setup or rendering */
|
|
206
|
+
label?: string;
|
|
207
|
+
/** Player ID who owns this edge */
|
|
208
|
+
owner?: PlayerId;
|
|
209
|
+
/** JSON-serialized custom properties */
|
|
210
|
+
properties?: Properties;
|
|
211
|
+
}
|
|
212
|
+
/** State of a vertex on a reducer-projected square grid board. */
|
|
213
|
+
interface SquareVertexState<SpaceIdValue extends string = SpaceId, VertexIdValue extends string = string, Properties = Record<string, unknown>> {
|
|
214
|
+
/** Unique vertex identifier */
|
|
215
|
+
id: VertexIdValue;
|
|
216
|
+
/** The cell IDs that touch this corner */
|
|
217
|
+
spaceIds: readonly SpaceIdValue[];
|
|
218
|
+
/** Vertex type identifier for rendering */
|
|
219
|
+
typeId?: VertexTypeId;
|
|
220
|
+
/** Display label for setup or rendering */
|
|
221
|
+
label?: string;
|
|
222
|
+
/** Player ID who owns this vertex */
|
|
223
|
+
owner?: PlayerId;
|
|
224
|
+
/** JSON-serialized custom properties */
|
|
225
|
+
properties?: Properties;
|
|
226
|
+
}
|
|
227
|
+
/** State of a piece placed on a reducer-projected square grid cell. */
|
|
228
|
+
interface SquarePieceState<PieceIdValue extends string = PieceId, Properties = Record<string, unknown>> {
|
|
229
|
+
/** Unique piece identifier */
|
|
230
|
+
id: PieceIdValue;
|
|
231
|
+
/** Row index where piece is located */
|
|
232
|
+
row: number;
|
|
233
|
+
/** Column index where piece is located */
|
|
234
|
+
col: number;
|
|
235
|
+
/** Piece type identifier for rendering */
|
|
236
|
+
typeId: PieceTypeId;
|
|
237
|
+
/** Player ID who owns this piece */
|
|
238
|
+
owner?: PlayerId;
|
|
239
|
+
/** JSON-serialized custom properties */
|
|
240
|
+
properties?: Properties;
|
|
241
|
+
}
|
|
242
|
+
/** Complete state of a reducer-projected square grid board. */
|
|
243
|
+
interface SquareBoardState<B extends string = BoardId, SpaceIdValue extends string = SpaceId, EdgeIdValue extends string = string, VertexIdValue extends string = string, PieceIdValue extends string = PieceId, CellProperties = Record<string, unknown>, EdgeProperties = Record<string, unknown>, VertexProperties = Record<string, unknown>, PieceProperties = Record<string, unknown>> {
|
|
244
|
+
/** Unique board identifier */
|
|
245
|
+
id: B;
|
|
246
|
+
/** Number of rows in the grid */
|
|
247
|
+
rows: number;
|
|
248
|
+
/** Number of columns in the grid */
|
|
249
|
+
cols: number;
|
|
250
|
+
/** All authored cells on the board */
|
|
251
|
+
cells: ReadonlyArray<SquareCellState<SpaceIdValue, CellProperties>>;
|
|
252
|
+
/** All edges on the board */
|
|
253
|
+
edges: ReadonlyArray<SquareEdgeState<SpaceIdValue, EdgeIdValue, EdgeProperties>>;
|
|
254
|
+
/** All vertices on the board */
|
|
255
|
+
vertices: ReadonlyArray<SquareVertexState<SpaceIdValue, VertexIdValue, VertexProperties>>;
|
|
256
|
+
/** All pieces on the board */
|
|
257
|
+
pieces: ReadonlyArray<SquarePieceState<PieceIdValue, PieceProperties>>;
|
|
258
|
+
}
|
|
259
|
+
/** State of a space on a reducer-projected track board. */
|
|
260
|
+
interface TrackSpaceState {
|
|
261
|
+
/** Unique space identifier */
|
|
262
|
+
id: SpaceId;
|
|
263
|
+
/** Position index in the track sequence */
|
|
264
|
+
index: number;
|
|
265
|
+
/** X coordinate for rendering */
|
|
266
|
+
x: number;
|
|
267
|
+
/** Y coordinate for rendering */
|
|
268
|
+
y: number;
|
|
269
|
+
/** Display name of the space */
|
|
270
|
+
name?: string;
|
|
271
|
+
/** Space type identifier for rendering */
|
|
272
|
+
typeId?: SpaceTypeId;
|
|
273
|
+
/** Player ID who owns this space */
|
|
274
|
+
owner?: PlayerId;
|
|
275
|
+
/** IDs of spaces that can be reached from here (for branching tracks) */
|
|
276
|
+
nextSpaces?: SpaceId[];
|
|
277
|
+
/** JSON-serialized custom properties */
|
|
278
|
+
properties?: string;
|
|
279
|
+
}
|
|
280
|
+
/** State of a piece on a reducer-projected track board. */
|
|
281
|
+
interface TrackPieceState {
|
|
282
|
+
/** Unique piece identifier */
|
|
283
|
+
id: PieceId;
|
|
284
|
+
/** ID of the space this piece occupies */
|
|
285
|
+
spaceId: SpaceId;
|
|
286
|
+
/** Player ID who owns this piece */
|
|
287
|
+
owner: PlayerId;
|
|
288
|
+
/** Piece type identifier for rendering */
|
|
289
|
+
typeId?: PieceTypeId;
|
|
290
|
+
/** JSON-serialized custom properties */
|
|
291
|
+
properties?: string;
|
|
292
|
+
}
|
|
293
|
+
/** Complete state of a reducer-projected track board. */
|
|
294
|
+
interface TrackBoardState {
|
|
295
|
+
/** Unique board identifier */
|
|
296
|
+
id: BoardId;
|
|
297
|
+
/** All spaces on the track */
|
|
298
|
+
spaces: TrackSpaceState[];
|
|
299
|
+
/** All pieces on the track */
|
|
300
|
+
pieces: TrackPieceState[];
|
|
301
|
+
}
|
|
302
|
+
/** State of a reducer-projected die component. */
|
|
303
|
+
interface DieState {
|
|
304
|
+
/** Unique die identifier */
|
|
305
|
+
id: DieId;
|
|
306
|
+
/** Number of sides on the die (e.g., 6 for standard die) */
|
|
307
|
+
sides: number;
|
|
308
|
+
/** Current face value (1 to sides, undefined if not rolled) */
|
|
309
|
+
currentValue?: number;
|
|
310
|
+
/** Optional color for visual identification */
|
|
311
|
+
color?: string;
|
|
312
|
+
}
|
|
313
|
+
/**
|
|
314
|
+
* Collection of boards of a particular kind, split into shared boards
|
|
315
|
+
* (indexed by base id, e.g. `"market-board"`) and per-player boards
|
|
316
|
+
* (indexed by base id, then by the runtime seat list via `PerPlayer<T>`).
|
|
317
|
+
*
|
|
318
|
+
* Splitting by the `BoardRef` discriminator keeps the UI types honest about
|
|
319
|
+
* what the runtime actually produced: per-player board state only exists
|
|
320
|
+
* for the seats that are currently playing, never for a static `maxPlayers`
|
|
321
|
+
* upper bound.
|
|
322
|
+
*/
|
|
323
|
+
interface BoardKindStates<State> {
|
|
324
|
+
/** Shared boards keyed by base id. */
|
|
325
|
+
shared: Record<BoardBaseId, State>;
|
|
326
|
+
/** Per-player boards keyed by base id, then by seat via `PerPlayer<T>`. */
|
|
327
|
+
perPlayer: Record<BoardBaseId, PerPlayer<State>>;
|
|
328
|
+
}
|
|
329
|
+
/**
|
|
330
|
+
* Container for all board states organized by kind.
|
|
331
|
+
* This is the strongly-typed board payload authored UIs consume from reducer views.
|
|
332
|
+
*/
|
|
333
|
+
interface BoardStates {
|
|
334
|
+
/** Hex boards split into shared vs per-player collections. */
|
|
335
|
+
hex: BoardKindStates<HexBoardState>;
|
|
336
|
+
/** Network boards split into shared vs per-player collections. */
|
|
337
|
+
network: BoardKindStates<NetworkBoardState>;
|
|
338
|
+
/** Square grid boards split into shared vs per-player collections. */
|
|
339
|
+
square: BoardKindStates<SquareBoardState>;
|
|
340
|
+
/** Track boards split into shared vs per-player collections. */
|
|
341
|
+
track: BoardKindStates<TrackBoardState>;
|
|
342
|
+
}
|
|
343
|
+
/**
|
|
344
|
+
* Container for all dice states.
|
|
345
|
+
* Maps die IDs to their die state.
|
|
346
|
+
*/
|
|
347
|
+
type DiceStates = Record<DieId, DieState>;
|
|
348
|
+
interface GameState {
|
|
349
|
+
/** All currently active players (supports MULTIPLE_ACTIVE_PLAYER states) */
|
|
350
|
+
currentPlayerIds: PlayerId[];
|
|
351
|
+
decks: CardIdsByDeckId;
|
|
352
|
+
/**
|
|
353
|
+
* Player-scoped hands keyed by the authored hand id. The inner
|
|
354
|
+
* `PerPlayer<CardId[]>` is keyed by the runtime seat list and only
|
|
355
|
+
* contains entries for players who actually hold the hand.
|
|
356
|
+
*/
|
|
357
|
+
hands: CardIdsByHandId;
|
|
358
|
+
/** Map of card IDs to their card info including type and properties */
|
|
359
|
+
cards: Record<CardId, ViewCard<CardId, string, CardProperties>>;
|
|
360
|
+
/**
|
|
361
|
+
* Per-player resource totals keyed by the runtime seat list. The inner
|
|
362
|
+
* record maps resource id → amount for that seat.
|
|
363
|
+
*/
|
|
364
|
+
playerResources: PerPlayer<Record<string, number>>;
|
|
365
|
+
currentState: StateName;
|
|
366
|
+
isMyTurn: boolean;
|
|
367
|
+
boards: BoardStates;
|
|
368
|
+
dice: DiceStates;
|
|
369
|
+
}
|
|
370
|
+
|
|
371
|
+
export { type SquarePieceState as A, type BoardBaseId as B, type CardId as C, type DeckId as D, type EdgeTypeId as E, type SquareVertexState as F, type GameState as G, type HexBoardState as H, type TrackPieceState as I, type TrackSpaceState as J, hexColor as K, isHexColor as L, parseHexColor as M, type NetworkBoardState as N, type PerPlayer as P, type SharedBoardRef as S, type TrackBoardState as T, type VertexTypeId as V, type BoardId as a, type BoardKindStates as b, type BoardRef as c, type BoardStates as d, type CardIdsByDeckId as e, type CardProperties as f, type DiceStates as g, type DieId as h, type DieState as i, type HexColor as j, type HexEdgeState as k, type HexTileState as l, type HexVertexState as m, type NetworkEdgeState as n, type NetworkNodeState as o, type NetworkPieceState as p, type PerPlayerBoardRef as q, type PieceId as r, type PieceTypeId as s, type Player as t, type PlayerId as u, type SpaceId as v, type SpaceTypeId as w, type SquareBoardState as x, type SquareCellState as y, type SquareEdgeState as z };
|
|
@@ -0,0 +1,267 @@
|
|
|
1
|
+
type RuntimeJson = null | boolean | number | string | RuntimeJson[] | {
|
|
2
|
+
[key: string]: RuntimeJson;
|
|
3
|
+
};
|
|
4
|
+
type CanonicalJson = null | boolean | number | string | CanonicalJson[] | {
|
|
5
|
+
[key: string]: CanonicalJson;
|
|
6
|
+
};
|
|
7
|
+
declare function canonicalizePluginRuntimeJson(value: unknown): CanonicalJson;
|
|
8
|
+
declare function encodeCanonicalPluginRuntimeJson(value: unknown): string;
|
|
9
|
+
declare function digestPluginRuntimeJson(value: unknown): string;
|
|
10
|
+
|
|
11
|
+
type PlayerId = string;
|
|
12
|
+
interface PluginPlayerSummary {
|
|
13
|
+
readonly playerId: PlayerId;
|
|
14
|
+
readonly displayName: string;
|
|
15
|
+
readonly color?: string;
|
|
16
|
+
}
|
|
17
|
+
interface PluginSessionDescriptor {
|
|
18
|
+
readonly sessionId: string;
|
|
19
|
+
/** Turn order is the order of this array. */
|
|
20
|
+
readonly players: readonly PluginPlayerSummary[];
|
|
21
|
+
}
|
|
22
|
+
interface InteractionCommitPolicy {
|
|
23
|
+
readonly mode: "manual" | "autoWhenReady";
|
|
24
|
+
}
|
|
25
|
+
type InputSelection = {
|
|
26
|
+
readonly mode: "single";
|
|
27
|
+
} | {
|
|
28
|
+
readonly mode: "many";
|
|
29
|
+
readonly min: number;
|
|
30
|
+
readonly max?: number;
|
|
31
|
+
readonly distinct?: boolean;
|
|
32
|
+
};
|
|
33
|
+
interface InputDomainDependencyCase {
|
|
34
|
+
readonly when: Readonly<Record<string, string>>;
|
|
35
|
+
readonly domain: InputDomain;
|
|
36
|
+
}
|
|
37
|
+
type InputDomainDependencies = {
|
|
38
|
+
readonly mode: "eager";
|
|
39
|
+
readonly dependentCases: readonly InputDomainDependencyCase[];
|
|
40
|
+
} | {
|
|
41
|
+
readonly mode: "lazy";
|
|
42
|
+
readonly dependsOn: readonly string[];
|
|
43
|
+
readonly resolver: {
|
|
44
|
+
readonly interactionKey?: string;
|
|
45
|
+
readonly inputKey: string;
|
|
46
|
+
};
|
|
47
|
+
};
|
|
48
|
+
interface InputDomain {
|
|
49
|
+
readonly type: string;
|
|
50
|
+
readonly selection?: InputSelection;
|
|
51
|
+
readonly dependencies?: InputDomainDependencies;
|
|
52
|
+
readonly [key: string]: RuntimeJson | InputSelection | InputDomainDependencies | undefined;
|
|
53
|
+
}
|
|
54
|
+
interface InteractionChoiceOption {
|
|
55
|
+
readonly value: string | null;
|
|
56
|
+
readonly label: string;
|
|
57
|
+
readonly icon?: string;
|
|
58
|
+
readonly badge?: string;
|
|
59
|
+
readonly description?: string;
|
|
60
|
+
readonly disabled?: boolean;
|
|
61
|
+
readonly disabledReason?: string;
|
|
62
|
+
}
|
|
63
|
+
interface InteractionInputDescriptor {
|
|
64
|
+
readonly key: string;
|
|
65
|
+
readonly kind: string;
|
|
66
|
+
readonly domain: InputDomain;
|
|
67
|
+
readonly defaultValue?: RuntimeJson;
|
|
68
|
+
}
|
|
69
|
+
type InteractionAvailability = {
|
|
70
|
+
readonly status: "available";
|
|
71
|
+
} | {
|
|
72
|
+
readonly status: "notYourTurn";
|
|
73
|
+
readonly reason: string;
|
|
74
|
+
} | {
|
|
75
|
+
readonly status: "insufficientResources";
|
|
76
|
+
readonly reason: string;
|
|
77
|
+
readonly missingResources: Readonly<Record<string, number>>;
|
|
78
|
+
} | {
|
|
79
|
+
readonly status: "blocked";
|
|
80
|
+
readonly reason: string;
|
|
81
|
+
readonly code?: string;
|
|
82
|
+
};
|
|
83
|
+
interface InteractionDiagnosticReason {
|
|
84
|
+
readonly ruleId: string;
|
|
85
|
+
readonly errorCode: string;
|
|
86
|
+
}
|
|
87
|
+
interface InteractionDescriptorBase<Interaction extends string = string> {
|
|
88
|
+
readonly phaseName: string;
|
|
89
|
+
readonly interactionKey: Interaction;
|
|
90
|
+
readonly interactionId: string;
|
|
91
|
+
readonly zoneId?: string;
|
|
92
|
+
readonly zoneIds?: readonly string[];
|
|
93
|
+
readonly commit: InteractionCommitPolicy;
|
|
94
|
+
readonly descriptorDigest?: string;
|
|
95
|
+
readonly actorSeat?: number;
|
|
96
|
+
readonly draftDigest?: string;
|
|
97
|
+
readonly inputs: readonly InteractionInputDescriptor[];
|
|
98
|
+
readonly cost?: Readonly<Record<string, RuntimeJson>>;
|
|
99
|
+
readonly currentResources?: Readonly<Record<string, RuntimeJson>>;
|
|
100
|
+
readonly availability: InteractionAvailability;
|
|
101
|
+
readonly reasons?: readonly InteractionDiagnosticReason[];
|
|
102
|
+
}
|
|
103
|
+
type ActionInteractionDescriptor<Interaction extends string = string> = InteractionDescriptorBase<Interaction> & {
|
|
104
|
+
readonly kind: "action";
|
|
105
|
+
};
|
|
106
|
+
interface InteractionContextOption {
|
|
107
|
+
readonly id: string;
|
|
108
|
+
readonly label?: string;
|
|
109
|
+
}
|
|
110
|
+
interface InteractionContext {
|
|
111
|
+
readonly to: string;
|
|
112
|
+
readonly title?: string;
|
|
113
|
+
readonly payload?: Readonly<Record<string, RuntimeJson>>;
|
|
114
|
+
readonly options?: readonly InteractionContextOption[];
|
|
115
|
+
}
|
|
116
|
+
type PromptInteractionDescriptor<Interaction extends string = string> = InteractionDescriptorBase<Interaction> & {
|
|
117
|
+
readonly kind: "prompt";
|
|
118
|
+
readonly context: InteractionContext;
|
|
119
|
+
};
|
|
120
|
+
type InteractionDescriptor<Interaction extends string = string> = ActionInteractionDescriptor<Interaction> | PromptInteractionDescriptor<Interaction>;
|
|
121
|
+
interface ZoneHandlesSnapshot<Interaction extends string = string> {
|
|
122
|
+
readonly cardIds: readonly string[];
|
|
123
|
+
readonly cardViewsById: Readonly<Record<string, string>>;
|
|
124
|
+
readonly playableByCardId: Readonly<Record<string, readonly InteractionDescriptor<Interaction>[]>>;
|
|
125
|
+
}
|
|
126
|
+
interface SimultaneousPhaseSnapshot {
|
|
127
|
+
readonly phaseName: string;
|
|
128
|
+
readonly interactionId: string;
|
|
129
|
+
readonly actorIds: readonly PlayerId[];
|
|
130
|
+
readonly sealedPlayerIds: readonly PlayerId[];
|
|
131
|
+
readonly pendingPlayerIds: readonly PlayerId[];
|
|
132
|
+
}
|
|
133
|
+
interface PluginGameplayFrame<View = unknown, Phase extends string = string, Stage extends string = string, Interaction extends string = string> {
|
|
134
|
+
readonly gameVersion: number;
|
|
135
|
+
readonly actionSetVersion: string;
|
|
136
|
+
readonly perspectivePlayerId: PlayerId | null;
|
|
137
|
+
readonly view: View | null;
|
|
138
|
+
readonly flow: {
|
|
139
|
+
readonly currentPhase: Phase | null;
|
|
140
|
+
readonly currentStage: Stage | null;
|
|
141
|
+
readonly activePlayers: readonly PlayerId[];
|
|
142
|
+
readonly simultaneousPhase: SimultaneousPhaseSnapshot | null;
|
|
143
|
+
};
|
|
144
|
+
readonly availableInteractions: ReadonlyArray<InteractionDescriptor<Interaction>>;
|
|
145
|
+
readonly zones: Readonly<Record<string, ZoneHandlesSnapshot<Interaction>>>;
|
|
146
|
+
}
|
|
147
|
+
interface ReducerSeatProjectionBundle {
|
|
148
|
+
readonly currentStage?: string | null;
|
|
149
|
+
readonly stageSeats?: readonly string[];
|
|
150
|
+
readonly simultaneousPhase?: SimultaneousPhaseSnapshot | null;
|
|
151
|
+
readonly interactionsByRef?: unknown;
|
|
152
|
+
readonly seats: Readonly<Record<string, {
|
|
153
|
+
readonly view?: unknown;
|
|
154
|
+
readonly availableInteractionRefs?: unknown;
|
|
155
|
+
readonly zones?: unknown;
|
|
156
|
+
}>>;
|
|
157
|
+
}
|
|
158
|
+
interface ReducerBoardStaticProjection {
|
|
159
|
+
readonly view: RuntimeJson;
|
|
160
|
+
readonly hash?: string;
|
|
161
|
+
readonly manifestVersion?: string;
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
declare const DREAMBOARD_PLUGIN_PROTOCOL: "dreamboard-plugin";
|
|
165
|
+
declare const DREAMBOARD_PLUGIN_PROTOCOL_VERSION: 3;
|
|
166
|
+
interface ValidationResult {
|
|
167
|
+
readonly valid: boolean;
|
|
168
|
+
readonly errorCode?: string;
|
|
169
|
+
readonly message?: string;
|
|
170
|
+
}
|
|
171
|
+
type SubmissionResult = {
|
|
172
|
+
readonly accepted: true;
|
|
173
|
+
} | {
|
|
174
|
+
readonly accepted: false;
|
|
175
|
+
readonly errorCode: string;
|
|
176
|
+
readonly message?: string;
|
|
177
|
+
};
|
|
178
|
+
interface PluginInteractionBasis {
|
|
179
|
+
readonly gameVersion: number;
|
|
180
|
+
readonly actionSetVersion: string;
|
|
181
|
+
readonly perspectivePlayerId: PlayerId | null;
|
|
182
|
+
}
|
|
183
|
+
interface ValidateInteractionCommand {
|
|
184
|
+
readonly type: "interaction.validate";
|
|
185
|
+
readonly requestId: string;
|
|
186
|
+
readonly basis: PluginInteractionBasis;
|
|
187
|
+
readonly interactionId: string;
|
|
188
|
+
readonly params: RuntimeJson;
|
|
189
|
+
}
|
|
190
|
+
interface SubmitInteractionCommand {
|
|
191
|
+
readonly type: "interaction.submit";
|
|
192
|
+
readonly requestId: string;
|
|
193
|
+
readonly basis: PluginInteractionBasis;
|
|
194
|
+
readonly interactionId: string;
|
|
195
|
+
readonly params: RuntimeJson;
|
|
196
|
+
}
|
|
197
|
+
type HostToPluginPayload = {
|
|
198
|
+
readonly type: "runtime.init";
|
|
199
|
+
readonly session: PluginSessionDescriptor;
|
|
200
|
+
} | {
|
|
201
|
+
readonly type: "gameplay.frame";
|
|
202
|
+
readonly frame: PluginGameplayFrame;
|
|
203
|
+
} | {
|
|
204
|
+
readonly type: "interaction.validation-result";
|
|
205
|
+
readonly requestId: string;
|
|
206
|
+
readonly result: ValidationResult;
|
|
207
|
+
} | {
|
|
208
|
+
readonly type: "interaction.submit-result";
|
|
209
|
+
readonly requestId: string;
|
|
210
|
+
readonly result: SubmissionResult;
|
|
211
|
+
};
|
|
212
|
+
type PluginToHostPayload = {
|
|
213
|
+
readonly type: "runtime.ready";
|
|
214
|
+
} | {
|
|
215
|
+
readonly type: "runtime.ack";
|
|
216
|
+
/** Echoes the host envelope sequence. It is delivery order only. */
|
|
217
|
+
readonly sequence: number;
|
|
218
|
+
readonly clientReceivedAtMs?: number;
|
|
219
|
+
readonly clientRenderedAtMs?: number;
|
|
220
|
+
} | ValidateInteractionCommand | SubmitInteractionCommand | {
|
|
221
|
+
readonly type: "runtime.error";
|
|
222
|
+
readonly message: string;
|
|
223
|
+
readonly code?: string;
|
|
224
|
+
};
|
|
225
|
+
interface PluginProtocolEnvelope<Payload> {
|
|
226
|
+
readonly protocol: typeof DREAMBOARD_PLUGIN_PROTOCOL;
|
|
227
|
+
readonly version: typeof DREAMBOARD_PLUGIN_PROTOCOL_VERSION;
|
|
228
|
+
readonly channelId: string;
|
|
229
|
+
/** Delivery order only. It is not a game revision. */
|
|
230
|
+
readonly sequence: number;
|
|
231
|
+
readonly payload: Payload;
|
|
232
|
+
}
|
|
233
|
+
type HostToPluginEnvelope = PluginProtocolEnvelope<HostToPluginPayload>;
|
|
234
|
+
type PluginToHostEnvelope = PluginProtocolEnvelope<PluginToHostPayload>;
|
|
235
|
+
interface PluginProtocolFrame {
|
|
236
|
+
readonly id: string;
|
|
237
|
+
readonly frame: PluginGameplayFrame;
|
|
238
|
+
readonly projectionDigest: string;
|
|
239
|
+
}
|
|
240
|
+
interface PluginProtocolTape {
|
|
241
|
+
readonly session: PluginSessionDescriptor;
|
|
242
|
+
readonly frames: readonly PluginProtocolFrame[];
|
|
243
|
+
readonly steps: readonly PluginProtocolStep[];
|
|
244
|
+
}
|
|
245
|
+
type PluginProtocolStep = {
|
|
246
|
+
readonly id: string;
|
|
247
|
+
readonly kind: "host.frame";
|
|
248
|
+
readonly frameId: string;
|
|
249
|
+
} | {
|
|
250
|
+
readonly id: string;
|
|
251
|
+
readonly kind: "client.validate";
|
|
252
|
+
readonly fromFrameId: string;
|
|
253
|
+
readonly requestDigest: string;
|
|
254
|
+
readonly response: ValidationResult;
|
|
255
|
+
} | {
|
|
256
|
+
readonly id: string;
|
|
257
|
+
readonly kind: "client.submit";
|
|
258
|
+
readonly fromFrameId: string;
|
|
259
|
+
readonly requestDigest: string;
|
|
260
|
+
readonly response: SubmissionResult;
|
|
261
|
+
};
|
|
262
|
+
type ActionSetVersionInput = {
|
|
263
|
+
readonly gameVersion: number;
|
|
264
|
+
readonly availableInteractions: readonly InteractionDescriptor[];
|
|
265
|
+
};
|
|
266
|
+
|
|
267
|
+
export { type ActionInteractionDescriptor as A, type RuntimeJson as B, type CanonicalJson as C, DREAMBOARD_PLUGIN_PROTOCOL as D, type SubmissionResult as E, type SubmitInteractionCommand as F, type ValidationResult as G, type HostToPluginEnvelope as H, type InputDomain as I, canonicalizePluginRuntimeJson as J, digestPluginRuntimeJson as K, encodeCanonicalPluginRuntimeJson as L, type PlayerId as P, type ReducerBoardStaticProjection as R, type SimultaneousPhaseSnapshot as S, type ValidateInteractionCommand as V, type ZoneHandlesSnapshot as Z, type ActionSetVersionInput as a, DREAMBOARD_PLUGIN_PROTOCOL_VERSION as b, type HostToPluginPayload as c, type InputDomainDependencies as d, type InputDomainDependencyCase as e, type InputSelection as f, type InteractionAvailability as g, type InteractionChoiceOption as h, type InteractionCommitPolicy as i, type InteractionContext as j, type InteractionContextOption as k, type InteractionDescriptor as l, type InteractionDiagnosticReason as m, type InteractionInputDescriptor as n, type PluginGameplayFrame as o, type PluginInteractionBasis as p, type PluginPlayerSummary as q, type PluginProtocolEnvelope as r, type PluginProtocolFrame as s, type PluginProtocolStep as t, type PluginProtocolTape as u, type PluginSessionDescriptor as v, type PluginToHostEnvelope as w, type PluginToHostPayload as x, type PromptInteractionDescriptor as y, type ReducerSeatProjectionBundle as z };
|