@dreamboard-games/sdk 0.4.0-alpha.1 → 0.4.0-alpha.3
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/REFERENCE.md +1318 -201
- 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-BrZtP9az.d.ts → attributes-DbvyMbXw.d.ts} +17 -2
- 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 +205 -5
- package/dist/browser-interaction.js +14 -2
- package/dist/{chunk-7W6TQO3X.js → chunk-45FI6XII.js} +613 -366
- package/dist/chunk-45FI6XII.js.map +1 -0
- package/dist/{chunk-3K362ZKR.js → chunk-6JQFGSLD.js} +202 -38
- package/dist/chunk-6JQFGSLD.js.map +1 -0
- package/dist/{chunk-IUGKW2GS.js → chunk-BKD7XAWB.js} +6 -2
- package/dist/chunk-BKD7XAWB.js.map +1 -0
- package/dist/{chunk-XXBSIPJX.js → chunk-CP35NPPY.js} +131 -59
- package/dist/chunk-CP35NPPY.js.map +1 -0
- package/dist/chunk-DQ7GCD6C.js +12 -0
- package/dist/chunk-DQ7GCD6C.js.map +1 -0
- package/dist/{chunk-XJYUSD5F.js → chunk-FWVV2X74.js} +2 -2
- package/dist/chunk-K5ZRJTZZ.js +328 -0
- package/dist/chunk-K5ZRJTZZ.js.map +1 -0
- package/dist/{chunk-7LZZEI25.js → chunk-N6ZDIMRB.js} +1 -1
- 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-AEUXCFGM.js → chunk-PF7L4BMG.js} +1 -8
- package/dist/{chunk-AEUXCFGM.js.map → chunk-PF7L4BMG.js.map} +1 -1
- package/dist/{chunk-CZMFAS3E.js → chunk-WOWFONLZ.js} +517 -1274
- package/dist/chunk-WOWFONLZ.js.map +1 -0
- package/dist/{chunk-MALRKLRR.js → chunk-WUIVY2KE.js} +301 -12
- package/dist/chunk-WUIVY2KE.js.map +1 -0
- package/dist/codegen.d.ts +11 -3
- package/dist/codegen.js +1 -1
- package/dist/{components-Dqr_LuZJ.d.ts → components-BbWPnZCF.d.ts} +37 -6
- package/dist/{hex-board-view-UCUjMALd.d.ts → hex-board-view-Kz9Q_zsv.d.ts} +1 -1
- package/dist/index-BLwlj7mO.d.ts +191 -0
- 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.js +1 -1
- package/dist/reducer-contract.js +1 -1
- package/dist/reducer.js +2 -2
- package/dist/reducer.js.map +1 -1
- package/dist/runtime/primitives.d.ts +10 -10
- package/dist/runtime/primitives.js +9 -7
- package/dist/runtime/runtime-api.d.ts +2 -2
- package/dist/runtime/workspace-contract.d.ts +21 -167
- package/dist/runtime/workspace-contract.js +7 -6
- package/dist/runtime-api-BJharVaj.d.ts +198 -0
- package/dist/runtime-api-C6aWo9c0.d.ts +95 -0
- package/dist/runtime.d.ts +36 -32
- package/dist/runtime.js +87 -797
- package/dist/runtime.js.map +1 -1
- package/dist/testing.d.ts +254 -140
- package/dist/testing.js +964 -149
- package/dist/testing.js.map +1 -1
- package/dist/types-CYeN0wLK.d.ts +29 -0
- package/dist/{types-BqzHkNMA.d.ts → types-DJj5MJkl.d.ts} +32 -5
- package/dist/types.d.ts +13 -8
- 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-contract-W2-kxObe.d.ts → ui-contract-CY7cxsCC.d.ts} +16 -26
- package/dist/ui.d.ts +7 -8
- package/dist/ui.js +20 -2
- package/package.json +25 -19
- package/dist/chunk-3K362ZKR.js.map +0 -1
- package/dist/chunk-7LZZEI25.js.map +0 -1
- package/dist/chunk-7W6TQO3X.js.map +0 -1
- package/dist/chunk-CZMFAS3E.js.map +0 -1
- package/dist/chunk-IUGKW2GS.js.map +0 -1
- package/dist/chunk-MALRKLRR.js.map +0 -1
- package/dist/chunk-XXBSIPJX.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-XJYUSD5F.js.map → chunk-FWVV2X74.js.map} +0 -0
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
import { ReactNode, ReactElement, ButtonHTMLAttributes } from 'react';
|
|
2
|
+
import { l as BoardSpaceTargetProps, bh as ZoneListProps, b1 as UIContract } from './ui-contract-CY7cxsCC.js';
|
|
3
|
+
import { H as HandRole } from './ResourceCounter-BuiNstXs.js';
|
|
4
|
+
|
|
5
|
+
interface ClientParamSchema {
|
|
6
|
+
safeParse: (value: unknown) => {
|
|
7
|
+
success: true;
|
|
8
|
+
data: Record<string, unknown>;
|
|
9
|
+
} | {
|
|
10
|
+
success: false;
|
|
11
|
+
error: {
|
|
12
|
+
issues: ReadonlyArray<{
|
|
13
|
+
path: readonly PropertyKey[];
|
|
14
|
+
message: string;
|
|
15
|
+
}>;
|
|
16
|
+
};
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
type ClientParamSchemaMap = Readonly<Record<string, Readonly<Record<string, ClientParamSchema>>>>;
|
|
20
|
+
|
|
21
|
+
type WorkspaceInteractionSlotComponent<Props = object> = (props: Props extends {
|
|
22
|
+
children: unknown;
|
|
23
|
+
} ? Props : Props & {
|
|
24
|
+
children?: ReactNode;
|
|
25
|
+
}) => ReactElement | null;
|
|
26
|
+
interface WorkspaceFormInputSlot<Input extends string = string> {
|
|
27
|
+
readonly Field: WorkspaceInteractionSlotComponent;
|
|
28
|
+
readonly Options: WorkspaceInteractionSlotComponent<{
|
|
29
|
+
children?: (option: {
|
|
30
|
+
value: unknown;
|
|
31
|
+
label: string;
|
|
32
|
+
}) => ReactNode;
|
|
33
|
+
}>;
|
|
34
|
+
readonly Value: WorkspaceInteractionSlotComponent<{
|
|
35
|
+
children: (value: unknown | undefined) => ReactNode;
|
|
36
|
+
}>;
|
|
37
|
+
readonly Default: WorkspaceInteractionSlotComponent;
|
|
38
|
+
readonly __input?: Input;
|
|
39
|
+
}
|
|
40
|
+
interface WorkspaceCardInputSlot<Card extends string = string> {
|
|
41
|
+
readonly Card: WorkspaceInteractionSlotComponent<{
|
|
42
|
+
value: Card;
|
|
43
|
+
} & Omit<ButtonHTMLAttributes<HTMLButtonElement>, "children" | "disabled" | "aria-disabled" | "aria-pressed" | "onClick" | "type" | "value">>;
|
|
44
|
+
readonly Cards: WorkspaceInteractionSlotComponent<{
|
|
45
|
+
children: (card: {
|
|
46
|
+
id: Card;
|
|
47
|
+
}) => ReactNode;
|
|
48
|
+
}>;
|
|
49
|
+
readonly Value: WorkspaceInteractionSlotComponent<{
|
|
50
|
+
children: (value: unknown | undefined) => ReactNode;
|
|
51
|
+
}>;
|
|
52
|
+
readonly Default: WorkspaceInteractionSlotComponent;
|
|
53
|
+
}
|
|
54
|
+
interface WorkspaceBoardTargetInputSlot<Kind extends "space" | "edge" | "vertex" | "tile", Target extends string = string> {
|
|
55
|
+
readonly Target: WorkspaceInteractionSlotComponent<{
|
|
56
|
+
value: Target;
|
|
57
|
+
} & Omit<ButtonHTMLAttributes<HTMLButtonElement>, "children" | "disabled" | "aria-disabled" | "aria-pressed" | "onClick" | "type" | "value">>;
|
|
58
|
+
readonly Value: WorkspaceInteractionSlotComponent<{
|
|
59
|
+
children: (value: unknown | undefined) => ReactNode;
|
|
60
|
+
}>;
|
|
61
|
+
readonly Default: WorkspaceInteractionSlotComponent;
|
|
62
|
+
readonly __kind?: Kind;
|
|
63
|
+
}
|
|
64
|
+
interface WorkspaceBoardSurface<Space extends string = string, Edge extends string = string, Vertex extends string = string, Tile extends string = string> {
|
|
65
|
+
readonly Root: WorkspaceInteractionSlotComponent;
|
|
66
|
+
readonly Space: <Target extends Space>(props: BoardSpaceTargetProps<Target>) => ReactElement | null;
|
|
67
|
+
readonly slot: {
|
|
68
|
+
readonly space: WorkspaceBoardTargetInputSlot<"space", Space>;
|
|
69
|
+
readonly playerSpace: WorkspaceBoardTargetInputSlot<"space", Space>;
|
|
70
|
+
readonly edge: WorkspaceBoardTargetInputSlot<"edge", Edge>;
|
|
71
|
+
readonly vertex: WorkspaceBoardTargetInputSlot<"vertex", Vertex>;
|
|
72
|
+
readonly tile: WorkspaceBoardTargetInputSlot<"tile", Tile>;
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
type WorkspaceZoneCardsComponent<Card> = WorkspaceInteractionSlotComponent<Omit<ZoneListProps, "children" | "empty"> & {
|
|
76
|
+
empty?: ReactNode;
|
|
77
|
+
children: (card: Card) => ReactNode;
|
|
78
|
+
}>;
|
|
79
|
+
type WorkspaceZoneCardComponent<Card> = WorkspaceInteractionSlotComponent<Omit<ButtonHTMLAttributes<HTMLButtonElement>, "type" | "value"> & {
|
|
80
|
+
card: Card;
|
|
81
|
+
}>;
|
|
82
|
+
type WorkspaceZoneStagingComponent<Card> = WorkspaceInteractionSlotComponent<{
|
|
83
|
+
children: (card: Card) => ReactNode;
|
|
84
|
+
label?: ReactNode;
|
|
85
|
+
renderEmptySlot?: (index: number) => ReactNode;
|
|
86
|
+
cardSize?: "sm" | "md" | "lg";
|
|
87
|
+
ariaLabel?: string;
|
|
88
|
+
className?: string;
|
|
89
|
+
}>;
|
|
90
|
+
type WorkspaceHandCardsComponent<Card> = WorkspaceInteractionSlotComponent<{
|
|
91
|
+
children: (card: Card, state: unknown) => ReactNode;
|
|
92
|
+
}>;
|
|
93
|
+
type WorkspaceHandSummaryComponent = WorkspaceInteractionSlotComponent<{
|
|
94
|
+
children?: ReactNode | ((summary: unknown) => ReactNode);
|
|
95
|
+
}>;
|
|
96
|
+
interface WorkspaceHandSurface<Zone extends string, Card> {
|
|
97
|
+
readonly Hand: WorkspaceInteractionSlotComponent<{
|
|
98
|
+
children: ReactNode;
|
|
99
|
+
}>;
|
|
100
|
+
readonly Cards: WorkspaceHandCardsComponent<Card>;
|
|
101
|
+
readonly Summary: WorkspaceHandSummaryComponent;
|
|
102
|
+
readonly Actions: WorkspaceHandSummaryComponent;
|
|
103
|
+
readonly Card: WorkspaceZoneCardComponent<Card>;
|
|
104
|
+
readonly Staging: WorkspaceZoneStagingComponent<Card>;
|
|
105
|
+
readonly slot: {
|
|
106
|
+
readonly card: WorkspaceCardInputSlot<Zone>;
|
|
107
|
+
};
|
|
108
|
+
}
|
|
109
|
+
interface WorkspacePileSurface<Card> {
|
|
110
|
+
readonly Pile: WorkspaceZoneCardsComponent<Card>;
|
|
111
|
+
readonly Card: WorkspaceZoneCardComponent<Card>;
|
|
112
|
+
}
|
|
113
|
+
interface WorkspaceCardCollectionSurface<Zone extends string, Card> {
|
|
114
|
+
readonly Collection: WorkspaceZoneCardsComponent<Card>;
|
|
115
|
+
readonly Card: WorkspaceZoneCardComponent<Card>;
|
|
116
|
+
readonly slot: {
|
|
117
|
+
readonly card: WorkspaceCardInputSlot<Zone>;
|
|
118
|
+
};
|
|
119
|
+
}
|
|
120
|
+
interface WorkspaceBoardSurfaceDescriptor<Board extends string = string> {
|
|
121
|
+
readonly kind: "board";
|
|
122
|
+
readonly board: Board;
|
|
123
|
+
}
|
|
124
|
+
interface WorkspaceHandSurfaceDescriptor<Zone extends string = string> {
|
|
125
|
+
readonly kind: "hand";
|
|
126
|
+
readonly zone: Zone;
|
|
127
|
+
readonly role: HandRole;
|
|
128
|
+
readonly label: string;
|
|
129
|
+
readonly order?: number;
|
|
130
|
+
}
|
|
131
|
+
interface WorkspacePileSurfaceDescriptor<Zone extends string = string> {
|
|
132
|
+
readonly kind: "pile";
|
|
133
|
+
readonly zone: Zone;
|
|
134
|
+
}
|
|
135
|
+
interface WorkspacePilesSurfaceDescriptor<Zones extends readonly string[] = readonly string[]> {
|
|
136
|
+
readonly kind: "piles";
|
|
137
|
+
readonly zones: Zones;
|
|
138
|
+
}
|
|
139
|
+
interface WorkspaceCardCollectionSurfaceDescriptor<Zones extends readonly string[] = readonly string[]> {
|
|
140
|
+
readonly kind: "cardCollection";
|
|
141
|
+
readonly zones: Zones;
|
|
142
|
+
readonly mode?: "all" | "top-card";
|
|
143
|
+
}
|
|
144
|
+
interface WorkspaceInteractionFormsDescriptor<Interactions extends Readonly<Record<string, string>> = Readonly<Record<string, string>>> {
|
|
145
|
+
readonly kind: "forms";
|
|
146
|
+
readonly interactions: Interactions;
|
|
147
|
+
}
|
|
148
|
+
interface WorkspaceInteractionFormDescriptor<Interaction extends string = string> {
|
|
149
|
+
readonly kind: "form";
|
|
150
|
+
readonly interaction: Interaction;
|
|
151
|
+
}
|
|
152
|
+
type WorkspaceSurfaceDescriptor = WorkspaceBoardSurfaceDescriptor | WorkspaceHandSurfaceDescriptor | WorkspacePileSurfaceDescriptor | WorkspacePilesSurfaceDescriptor | WorkspaceCardCollectionSurfaceDescriptor | WorkspaceInteractionFormDescriptor | WorkspaceInteractionFormsDescriptor;
|
|
153
|
+
interface WorkspaceSurfaceSpec {
|
|
154
|
+
readonly [key: string]: WorkspaceSurfaceDescriptor | WorkspaceSurfaceSpec;
|
|
155
|
+
}
|
|
156
|
+
interface WorkspaceContractOptions<Contract extends UIContract, Resource extends string, Card, HexBoards extends Record<string, unknown>> {
|
|
157
|
+
readonly uiContract: Contract;
|
|
158
|
+
readonly clientParamSchemasByPhase?: ClientParamSchemaMap;
|
|
159
|
+
readonly formInputKeysForInteraction: (interaction: string) => ReadonlySet<string>;
|
|
160
|
+
readonly resourceIds: readonly Resource[];
|
|
161
|
+
readonly resourcePresentationById?: Partial<Record<string, {
|
|
162
|
+
label?: string;
|
|
163
|
+
icon?: string;
|
|
164
|
+
}>>;
|
|
165
|
+
readonly hexStaticBoards: HexBoards;
|
|
166
|
+
readonly cardIdFromZoneCard: (card: Card) => string;
|
|
167
|
+
readonly zoneIdFromZoneCard: (card: Card) => string;
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
interface DefineGameUIConfig<GameState, Surfaces> {
|
|
171
|
+
useSurfaces: () => Surfaces;
|
|
172
|
+
interactionRoutes?: (context: {
|
|
173
|
+
game: GameState;
|
|
174
|
+
surfaces: Surfaces;
|
|
175
|
+
}) => Record<string, {
|
|
176
|
+
collect: Record<string, unknown>;
|
|
177
|
+
}>;
|
|
178
|
+
phases: Record<string, (context: {
|
|
179
|
+
game: GameState;
|
|
180
|
+
surfaces: Surfaces;
|
|
181
|
+
}) => ReactNode>;
|
|
182
|
+
renderInteractions?: (context: {
|
|
183
|
+
game: GameState;
|
|
184
|
+
surfaces: Surfaces;
|
|
185
|
+
}) => ReactNode;
|
|
186
|
+
fallback?: ReactNode | ((phase: string | null) => ReactNode);
|
|
187
|
+
includeUnavailableInteractions?: boolean | null;
|
|
188
|
+
}
|
|
189
|
+
declare function createWorkspaceUIContract<WorkspaceUI, Contract extends UIContract, Resource extends string, Card, HexBoards extends Record<string, unknown>>(options: WorkspaceContractOptions<Contract, Resource, Card, HexBoards>): WorkspaceUI;
|
|
190
|
+
|
|
191
|
+
export { type ClientParamSchemaMap as C, type DefineGameUIConfig as D, type WorkspaceBoardSurface as W, type WorkspaceBoardSurfaceDescriptor as a, type WorkspaceBoardTargetInputSlot as b, type WorkspaceCardCollectionSurface as c, type WorkspaceCardCollectionSurfaceDescriptor as d, type WorkspaceCardInputSlot as e, type WorkspaceFormInputSlot as f, type WorkspaceHandSurface as g, type WorkspaceHandSurfaceDescriptor as h, type WorkspaceInteractionFormDescriptor as i, type WorkspaceInteractionFormsDescriptor as j, type WorkspaceInteractionSlotComponent as k, type WorkspacePileSurface as l, type WorkspacePileSurfaceDescriptor as m, type WorkspacePilesSurfaceDescriptor as n, type WorkspaceSurfaceSpec as o, createWorkspaceUIContract as p };
|
package/dist/index.js
CHANGED
package/dist/package-set.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
declare const DREAMBOARD_SDK_VERSION
|
|
1
|
+
declare const DREAMBOARD_SDK_VERSION: "0.4.0-alpha.3";
|
|
2
2
|
declare const DREAMBOARD_SDK_PACKAGES: {
|
|
3
|
-
readonly "@dreamboard-games/sdk": "0.4.0-alpha.
|
|
3
|
+
readonly "@dreamboard-games/sdk": "0.4.0-alpha.3";
|
|
4
4
|
};
|
|
5
5
|
type DreamboardSdkPackageName = keyof typeof DREAMBOARD_SDK_PACKAGES;
|
|
6
6
|
type DreamboardSdkPackageSet = {
|
package/dist/package-set.js
CHANGED
|
@@ -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 };
|