@dreamboard-games/ui-sdk 0.0.43 → 0.0.45
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/dist/components/ActionButton.d.ts.map +1 -1
- package/dist/components/ActionButton.js +2 -1
- package/dist/components/Card.d.ts +1 -1
- package/dist/components/Card.d.ts.map +1 -1
- package/dist/components/DiceRoller.d.ts +3 -2
- package/dist/components/DiceRoller.d.ts.map +1 -1
- package/dist/components/DiceRoller.js +4 -13
- package/dist/components/ErrorBoundary.d.ts.map +1 -1
- package/dist/components/ErrorBoundary.js +94 -2
- package/dist/components/InteractionForm.d.ts +1 -1
- package/dist/components/InteractionForm.d.ts.map +1 -1
- package/dist/components/InteractionForm.js +29 -15
- package/dist/components/PrimaryActionButton.d.ts.map +1 -1
- package/dist/components/PrimaryActionButton.js +7 -6
- package/dist/components/ResourceCounter.d.ts +59 -25
- package/dist/components/ResourceCounter.d.ts.map +1 -1
- package/dist/components/ResourceCounter.js +106 -115
- package/dist/components/Toast.d.ts +13 -6
- package/dist/components/Toast.d.ts.map +1 -1
- package/dist/components/Toast.js +10 -5
- package/dist/components/board/HexGrid.js +6 -6
- package/dist/components/board/target-layer.d.ts +18 -2
- package/dist/components/board/target-layer.d.ts.map +1 -1
- package/dist/components/board/target-layer.js +20 -3
- package/dist/components/index.d.ts +3 -4
- package/dist/components/index.d.ts.map +1 -1
- package/dist/components/index.js +3 -4
- package/dist/components/surfaces/InboxSurface.d.ts.map +1 -1
- package/dist/components/surfaces/InboxSurface.js +2 -6
- package/dist/components/surfaces/PlayerCardsSurface.js +2 -2
- package/dist/components/surfaces/internal/CardZoneRoutedForm.d.ts +7 -0
- package/dist/components/surfaces/internal/CardZoneRoutedForm.d.ts.map +1 -0
- package/dist/components/surfaces/internal/CardZoneRoutedForm.js +9 -0
- package/dist/components/surfaces/internal/DefaultInteractionButton.d.ts.map +1 -1
- package/dist/components/surfaces/internal/DefaultInteractionButton.js +5 -8
- package/dist/components/surfaces/internal/useCardZoneInteractions.d.ts +2 -2
- package/dist/components/surfaces/internal/useCardZoneInteractions.d.ts.map +1 -1
- package/dist/components/surfaces/internal/useCardZoneInteractions.js +19 -43
- package/dist/context/InteractionDraftContext.d.ts +11 -2
- package/dist/context/InteractionDraftContext.d.ts.map +1 -1
- package/dist/context/InteractionDraftContext.js +41 -4
- package/dist/defaults/components.d.ts +0 -5
- package/dist/defaults/components.d.ts.map +1 -1
- package/dist/defaults/components.js +7 -11
- package/dist/hooks/useBoardInteractions.d.ts +35 -12
- package/dist/hooks/useBoardInteractions.d.ts.map +1 -1
- package/dist/hooks/useBoardInteractions.js +186 -82
- package/dist/hooks/useInteractionHandle.d.ts +1 -1
- package/dist/hooks/useInteractionHandle.d.ts.map +1 -1
- package/dist/hooks/useInteractionHandle.js +12 -27
- package/dist/index.d.ts +11 -17
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5 -14
- package/dist/primitives/board.d.ts +53 -3
- package/dist/primitives/board.d.ts.map +1 -1
- package/dist/primitives/board.js +65 -41
- package/dist/primitives/dialog-lifecycle.d.ts +17 -0
- package/dist/primitives/dialog-lifecycle.d.ts.map +1 -0
- package/dist/primitives/dialog-lifecycle.js +24 -0
- package/dist/primitives/dice.d.ts +31 -0
- package/dist/primitives/dice.d.ts.map +1 -0
- package/dist/primitives/dice.js +33 -0
- package/dist/primitives/game.d.ts +55 -0
- package/dist/primitives/game.d.ts.map +1 -0
- package/dist/primitives/game.js +101 -0
- package/dist/primitives/index.d.ts +7 -4
- package/dist/primitives/index.d.ts.map +1 -1
- package/dist/primitives/index.js +7 -4
- package/dist/primitives/interaction-form-binding.d.ts +12 -0
- package/dist/primitives/interaction-form-binding.d.ts.map +1 -0
- package/dist/primitives/interaction-form-binding.js +14 -0
- package/dist/primitives/interaction-submit.d.ts +23 -0
- package/dist/primitives/interaction-submit.d.ts.map +1 -0
- package/dist/primitives/interaction-submit.js +41 -0
- package/dist/primitives/interaction.d.ts +76 -6
- package/dist/primitives/interaction.d.ts.map +1 -1
- package/dist/primitives/interaction.js +210 -26
- package/dist/primitives/player-roster.d.ts +2 -1
- package/dist/primitives/player-roster.d.ts.map +1 -1
- package/dist/primitives/prompt.d.ts +36 -11
- package/dist/primitives/prompt.d.ts.map +1 -1
- package/dist/primitives/prompt.js +29 -17
- package/dist/primitives/ui.d.ts +9 -0
- package/dist/primitives/ui.d.ts.map +1 -0
- package/dist/primitives/ui.js +7 -0
- package/dist/primitives/zone.d.ts +111 -5
- package/dist/primitives/zone.d.ts.map +1 -1
- package/dist/primitives/zone.js +349 -9
- package/dist/reducer.d.ts +2 -14
- package/dist/reducer.d.ts.map +1 -1
- package/dist/reducer.js +1 -14
- package/dist/runtime/createPluginRuntimeAPI.js +1 -1
- package/dist/types/hex-color.d.ts +7 -0
- package/dist/types/hex-color.d.ts.map +1 -0
- package/dist/types/hex-color.js +13 -0
- package/dist/types/player-state.d.ts +28 -14
- package/dist/types/player-state.d.ts.map +1 -1
- package/dist/types/plugin-state.d.ts +9 -3
- package/dist/types/plugin-state.d.ts.map +1 -1
- package/dist/ui-contract.d.ts +119 -14
- package/dist/ui-contract.d.ts.map +1 -1
- package/dist/ui-contract.js +4 -3
- package/dist/ui-sdk.d.ts +1637 -1245
- package/dist/utils/interaction-inputs.d.ts +8 -5
- package/dist/utils/interaction-inputs.d.ts.map +1 -1
- package/dist/utils/interaction-inputs.js +82 -14
- package/dist/utils/interaction-router.d.ts +31 -0
- package/dist/utils/interaction-router.d.ts.map +1 -0
- package/dist/utils/interaction-router.js +114 -0
- package/package.json +1 -1
- package/src/components/ActionButton.tsx +2 -1
- package/src/components/Card.tsx +1 -1
- package/src/components/DiceRoller.tsx +13 -22
- package/src/components/ErrorBoundary.test.tsx +19 -0
- package/src/components/ErrorBoundary.tsx +113 -24
- package/src/components/InteractionForm.test.tsx +24 -0
- package/src/components/InteractionForm.tsx +48 -23
- package/src/components/PrimaryActionButton.tsx +19 -5
- package/src/components/ResourceCounter.test.tsx +13 -13
- package/src/components/ResourceCounter.tsx +238 -244
- package/src/components/Toast.tsx +23 -10
- package/src/components/__fixtures__/ResourceCounter.fixture.tsx +70 -169
- package/src/components/board/HexGrid.tsx +6 -6
- package/src/components/board/target-layer.ts +44 -5
- package/src/components/index.ts +17 -10
- package/src/components/surfaces/InboxSurface.tsx +7 -5
- package/src/components/surfaces/PlayerCardsSurface.tsx +6 -6
- package/src/components/surfaces/internal/CardZoneRoutedForm.tsx +35 -0
- package/src/components/surfaces/internal/DefaultInteractionButton.tsx +17 -7
- package/src/components/surfaces/internal/useCardZoneInteractions.ts +25 -67
- package/src/context/InteractionDraftContext.tsx +51 -5
- package/src/defaults/components.tsx +12 -50
- package/src/defaults/defaults.test.tsx +1 -50
- package/src/hooks/useBoardInteractions.test.tsx +240 -17
- package/src/hooks/useBoardInteractions.ts +330 -105
- package/src/hooks/useInteractionHandle.ts +23 -28
- package/src/index.test.ts +60 -40
- package/src/index.ts +30 -36
- package/src/primitives/board.test.tsx +73 -0
- package/src/primitives/board.tsx +191 -40
- package/src/primitives/dialog-lifecycle.ts +58 -0
- package/src/primitives/dice.test.tsx +47 -0
- package/src/primitives/dice.tsx +79 -0
- package/src/primitives/game.test.tsx +98 -0
- package/src/primitives/game.tsx +213 -0
- package/src/primitives/index.ts +84 -0
- package/src/primitives/interaction-form-binding.tsx +56 -0
- package/src/primitives/interaction-submit.ts +90 -0
- package/src/primitives/interaction.test.tsx +396 -0
- package/src/primitives/interaction.tsx +451 -31
- package/src/primitives/player-roster.tsx +2 -1
- package/src/primitives/prompt.test.tsx +94 -3
- package/src/primitives/prompt.tsx +87 -48
- package/src/primitives/ui.test.tsx +131 -0
- package/src/primitives/ui.tsx +13 -0
- package/src/primitives/zone.test.tsx +305 -0
- package/src/primitives/zone.tsx +660 -12
- package/src/reducer.ts +7 -20
- package/src/runtime/createPluginRuntimeAPI.ts +1 -1
- package/src/types/hex-color.ts +20 -0
- package/src/types/player-state.ts +36 -18
- package/src/types/plugin-state.ts +10 -3
- package/src/ui-contract.ts +253 -21
- package/src/utils/interaction-inputs.test.ts +400 -0
- package/src/utils/interaction-inputs.ts +113 -11
- package/src/utils/interaction-router.ts +200 -0
package/dist/primitives/zone.js
CHANGED
|
@@ -1,9 +1,17 @@
|
|
|
1
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import { createContext, useContext, useMemo } from "react";
|
|
1
|
+
import { jsx as _jsx, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
+
import { createContext, useContext, useMemo, } from "react";
|
|
3
|
+
import { useInteractionUiStore } from "../context/InteractionDraftContext.js";
|
|
4
|
+
import { usePluginSession } from "../context/PluginSessionContext.js";
|
|
3
5
|
import { usePluginState } from "../context/PluginStateContext.js";
|
|
4
|
-
import {
|
|
6
|
+
import { useRuntimeContext } from "../context/RuntimeContext.js";
|
|
7
|
+
import { inputByTarget, interactionInputKeys, } from "../utils/interaction-inputs.js";
|
|
8
|
+
import { claimInteractionSubmit, clearInteractionRoute, markInteractionPending, routeInteractionTarget, shouldRouteInteractionPending, } from "../utils/interaction-router.js";
|
|
9
|
+
import { useGameActionError } from "./game.js";
|
|
10
|
+
import { runInteractionAction } from "./interaction-submit.js";
|
|
11
|
+
import { composeEventHandlers, renderPrimitive, } from "./primitive-props.js";
|
|
5
12
|
const ZoneContext = createContext(null);
|
|
6
13
|
const ZoneCardContext = createContext(null);
|
|
14
|
+
const ZonePileContext = createContext(null);
|
|
7
15
|
export function useZonePrimitiveContext() {
|
|
8
16
|
const value = useContext(ZoneContext);
|
|
9
17
|
if (!value) {
|
|
@@ -11,9 +19,19 @@ export function useZonePrimitiveContext() {
|
|
|
11
19
|
}
|
|
12
20
|
return value;
|
|
13
21
|
}
|
|
22
|
+
export function useOptionalZonePrimitiveContext() {
|
|
23
|
+
return useContext(ZoneContext);
|
|
24
|
+
}
|
|
14
25
|
export function useZoneCardContext() {
|
|
15
26
|
return useContext(ZoneCardContext);
|
|
16
27
|
}
|
|
28
|
+
export function useZonePileContext() {
|
|
29
|
+
const value = useContext(ZonePileContext);
|
|
30
|
+
if (!value) {
|
|
31
|
+
throw new Error("Zone pile primitives must be rendered inside <Zone.PileRoot>.");
|
|
32
|
+
}
|
|
33
|
+
return value;
|
|
34
|
+
}
|
|
17
35
|
export function ZoneRoot({ zone, children, ...props }) {
|
|
18
36
|
const snapshot = usePluginState((state) => state.gameplay.zones[zone]) ?? null;
|
|
19
37
|
const value = useMemo(() => ({ zone, snapshot }), [snapshot, zone]);
|
|
@@ -25,34 +43,356 @@ export function ZoneRoot({ zone, children, ...props }) {
|
|
|
25
43
|
children,
|
|
26
44
|
}) }));
|
|
27
45
|
}
|
|
28
|
-
export function ZoneList({ children, ...props }) {
|
|
46
|
+
export function ZoneList({ children, empty, sort, ...props }) {
|
|
29
47
|
const { zone, snapshot } = useZonePrimitiveContext();
|
|
48
|
+
const cards = (snapshot?.cardIds ?? []).map((cardId, index) => createZoneCardRenderItem(zone, snapshot, cardId, index));
|
|
49
|
+
const items = sort ? [...cards].sort(sort) : cards;
|
|
30
50
|
const isEmpty = (snapshot?.cardIds.length ?? 0) === 0;
|
|
51
|
+
const renderedChildren = typeof children === "function"
|
|
52
|
+
? isEmpty
|
|
53
|
+
? empty
|
|
54
|
+
: items.map((item) => (_jsx(ZoneItem, { card: item, children: children(item) }, item.id)))
|
|
55
|
+
: isEmpty && empty !== undefined
|
|
56
|
+
? empty
|
|
57
|
+
: children;
|
|
31
58
|
return renderPrimitive("div", {
|
|
32
59
|
...props,
|
|
33
60
|
role: props.role ?? "list",
|
|
34
61
|
"data-dreamboard-zone-list": "",
|
|
35
62
|
"data-zone": zone,
|
|
36
63
|
"data-empty": isEmpty || undefined,
|
|
37
|
-
children,
|
|
64
|
+
children: renderedChildren,
|
|
38
65
|
});
|
|
39
66
|
}
|
|
40
67
|
export function ZoneItem({ card, children, ...props }) {
|
|
41
68
|
const { zone, snapshot } = useZonePrimitiveContext();
|
|
42
|
-
const
|
|
43
|
-
|
|
69
|
+
const item = typeof card === "string"
|
|
70
|
+
? createZoneCardRenderItem(zone, snapshot, card, indexOfCard(snapshot, card))
|
|
71
|
+
: card;
|
|
72
|
+
const cardContext = useMemo(() => ({ zone, cardId: item.id }), [item.id, zone]);
|
|
44
73
|
return (_jsx(ZoneCardContext.Provider, { value: cardContext, children: renderPrimitive("div", {
|
|
45
74
|
...props,
|
|
46
75
|
role: props.role ?? "listitem",
|
|
47
76
|
"data-dreamboard-zone-item": "",
|
|
48
77
|
"data-zone": zone,
|
|
49
|
-
"data-card-id":
|
|
50
|
-
"data-
|
|
78
|
+
"data-card-id": item.id,
|
|
79
|
+
"data-card-type": item.hidden ? undefined : item.cardType,
|
|
80
|
+
"data-card-index": item.index,
|
|
81
|
+
"data-card-hidden": item.hidden || undefined,
|
|
82
|
+
"data-playable": item.hidden ? undefined : item.playable || undefined,
|
|
51
83
|
children,
|
|
52
84
|
}) }));
|
|
53
85
|
}
|
|
86
|
+
function ZoneCardAtContent({ index, children, empty = null, ...props }) {
|
|
87
|
+
const { zone, snapshot } = useZonePrimitiveContext();
|
|
88
|
+
const cardIndex = resolveZoneCardIndex(snapshot, index);
|
|
89
|
+
if (cardIndex === null)
|
|
90
|
+
return _jsx(_Fragment, { children: empty });
|
|
91
|
+
const cardId = snapshot?.cardIds[cardIndex];
|
|
92
|
+
if (!cardId)
|
|
93
|
+
return _jsx(_Fragment, { children: empty });
|
|
94
|
+
const card = createZoneCardRenderItem(zone, snapshot, cardId, cardIndex);
|
|
95
|
+
return (_jsx(ZoneItem, { card: card, ...props, children: typeof children === "function" ? children(card) : children }));
|
|
96
|
+
}
|
|
97
|
+
export function ZoneCardAt({ zone, ...props }) {
|
|
98
|
+
if (zone) {
|
|
99
|
+
return (_jsx(ZoneRoot, { zone: zone, children: _jsx(ZoneCardAtContent, { ...props }) }));
|
|
100
|
+
}
|
|
101
|
+
return _jsx(ZoneCardAtContent, { ...props });
|
|
102
|
+
}
|
|
103
|
+
export function ZoneTopCard(props) {
|
|
104
|
+
return _jsx(ZoneCardAt, { ...props, index: 0 });
|
|
105
|
+
}
|
|
106
|
+
export function ZoneCardAction({ card, interaction, input, extraInputs, onSelect, onSelectError, disabled, onClick, children, ...props }) {
|
|
107
|
+
const { controllingPlayerId } = usePluginSession();
|
|
108
|
+
const runtime = useRuntimeContext();
|
|
109
|
+
const store = useInteractionUiStore();
|
|
110
|
+
const contextCard = useZoneCardContext();
|
|
111
|
+
const { snapshot } = useZonePrimitiveContext();
|
|
112
|
+
const gameActionError = useGameActionError();
|
|
113
|
+
const cardId = card ?? contextCard?.cardId;
|
|
114
|
+
const route = useZoneCardActionRoute(cardId, snapshot, interaction, input);
|
|
115
|
+
const isDisabled = disabled ??
|
|
116
|
+
(!cardId ||
|
|
117
|
+
!route.descriptor ||
|
|
118
|
+
!route.inputKey ||
|
|
119
|
+
route.ambiguous ||
|
|
120
|
+
!route.descriptor.available);
|
|
121
|
+
return renderPrimitive("button", {
|
|
122
|
+
type: "button",
|
|
123
|
+
...props,
|
|
124
|
+
children,
|
|
125
|
+
disabled: isDisabled,
|
|
126
|
+
"aria-disabled": isDisabled,
|
|
127
|
+
"data-dreamboard-zone-card-action": "",
|
|
128
|
+
"data-card-id": cardId,
|
|
129
|
+
"data-interaction-id": route.descriptor?.interactionId,
|
|
130
|
+
"data-interaction-key": route.descriptor?.interactionKey ?? interaction,
|
|
131
|
+
"data-input-name": route.inputKey ?? input,
|
|
132
|
+
"data-eligible": Boolean(route.descriptor && route.inputKey),
|
|
133
|
+
"data-ambiguous": route.ambiguous || undefined,
|
|
134
|
+
"data-disabled": isDisabled || undefined,
|
|
135
|
+
onClick: composeEventHandlers(onClick, () => {
|
|
136
|
+
if (isDisabled ||
|
|
137
|
+
!cardId ||
|
|
138
|
+
!route.descriptor ||
|
|
139
|
+
!route.inputKey ||
|
|
140
|
+
!controllingPlayerId) {
|
|
141
|
+
return;
|
|
142
|
+
}
|
|
143
|
+
const descriptor = route.descriptor;
|
|
144
|
+
const inputKey = route.inputKey;
|
|
145
|
+
void runInteractionAction(async () => {
|
|
146
|
+
const { params, readiness } = routeInteractionTarget(store, descriptor, {
|
|
147
|
+
inputKey,
|
|
148
|
+
value: cardId,
|
|
149
|
+
extraInputs: resolveCardActionExtraInputs(extraInputs, cardId),
|
|
150
|
+
});
|
|
151
|
+
if (shouldRouteInteractionPending(descriptor, readiness)) {
|
|
152
|
+
markInteractionPending(store, descriptor);
|
|
153
|
+
return {
|
|
154
|
+
status: "pending",
|
|
155
|
+
interactionKey: descriptor.interactionKey,
|
|
156
|
+
descriptor,
|
|
157
|
+
missingInputs: readiness.missingInputs,
|
|
158
|
+
};
|
|
159
|
+
}
|
|
160
|
+
if (!claimInteractionSubmit(store, descriptor)) {
|
|
161
|
+
return {
|
|
162
|
+
status: "submitted",
|
|
163
|
+
interactionKey: descriptor.interactionKey,
|
|
164
|
+
descriptor,
|
|
165
|
+
};
|
|
166
|
+
}
|
|
167
|
+
try {
|
|
168
|
+
await runtime.submitInteraction(controllingPlayerId, descriptor.interactionId, params);
|
|
169
|
+
clearInteractionRoute(store, descriptor);
|
|
170
|
+
return {
|
|
171
|
+
status: "submitted",
|
|
172
|
+
interactionKey: descriptor.interactionKey,
|
|
173
|
+
descriptor,
|
|
174
|
+
};
|
|
175
|
+
}
|
|
176
|
+
finally {
|
|
177
|
+
store.setSubmitting(descriptor.interactionKey, false);
|
|
178
|
+
}
|
|
179
|
+
}, {
|
|
180
|
+
onSuccess: onSelect,
|
|
181
|
+
onError: onSelectError ?? gameActionError ?? undefined,
|
|
182
|
+
});
|
|
183
|
+
}),
|
|
184
|
+
});
|
|
185
|
+
}
|
|
186
|
+
export function ZonePileRoot({ zone, label, hiddenDescription = null, emptyDescription = null, visibleDescription = null, children, ...props }) {
|
|
187
|
+
return (_jsx(ZoneRoot, { zone: zone, ...props, children: _jsx(ZonePileProvider, { emptyDescription: emptyDescription, hiddenDescription: hiddenDescription, label: label, visibleDescription: visibleDescription, children: children }) }));
|
|
188
|
+
}
|
|
189
|
+
function ZonePileProvider({ label, hiddenDescription, emptyDescription, visibleDescription, children, }) {
|
|
190
|
+
const { zone, snapshot } = useZonePrimitiveContext();
|
|
191
|
+
// Snapshot is the single source of truth for what's in a pile. A zone that
|
|
192
|
+
// isn't in the current phase's projection scope (snapshot === null) is
|
|
193
|
+
// treated as hidden — author should change the reducer projection rather
|
|
194
|
+
// than inject ids in the UI.
|
|
195
|
+
const cards = snapshot?.cardIds ?? [];
|
|
196
|
+
const items = cards.map((cardId, index) => createZoneCardRenderItem(zone, snapshot, cardId, index));
|
|
197
|
+
const count = cards.length;
|
|
198
|
+
const isHidden = snapshot === null;
|
|
199
|
+
// PileCards iterates whatever the snapshot exposes. Items are tagged
|
|
200
|
+
// `hidden: true | false` so the author's `renderCard` discriminates on
|
|
201
|
+
// honest data — including the "id without contents" case — rather than
|
|
202
|
+
// receiving a lying ViewCard with `cardType: "unknown"`.
|
|
203
|
+
const hasVisibleCards = items.length > 0;
|
|
204
|
+
const description = isHidden
|
|
205
|
+
? hiddenDescription
|
|
206
|
+
: hasVisibleCards
|
|
207
|
+
? (visibleDescription?.(count) ?? null)
|
|
208
|
+
: emptyDescription;
|
|
209
|
+
const value = useMemo(() => ({
|
|
210
|
+
zone,
|
|
211
|
+
label,
|
|
212
|
+
count,
|
|
213
|
+
cards,
|
|
214
|
+
items,
|
|
215
|
+
hasVisibleCards,
|
|
216
|
+
isHidden,
|
|
217
|
+
description,
|
|
218
|
+
}), [cards, count, description, hasVisibleCards, isHidden, items, label, zone]);
|
|
219
|
+
return (_jsx(ZonePileContext.Provider, { value: value, children: children }));
|
|
220
|
+
}
|
|
221
|
+
export function ZonePileTrigger({ children, ...props }) {
|
|
222
|
+
const pile = useZonePileContext();
|
|
223
|
+
return renderPrimitive("button", {
|
|
224
|
+
type: "button",
|
|
225
|
+
...props,
|
|
226
|
+
"aria-label": props["aria-label"] ?? `Show ${pile.label} pile`,
|
|
227
|
+
"data-dreamboard-zone-pile-trigger": "",
|
|
228
|
+
"data-zone": pile.zone,
|
|
229
|
+
"data-card-count": pile.count,
|
|
230
|
+
"data-hidden": pile.isHidden || undefined,
|
|
231
|
+
children,
|
|
232
|
+
});
|
|
233
|
+
}
|
|
234
|
+
export function ZonePileLabel({ children, ...props }) {
|
|
235
|
+
const pile = useZonePileContext();
|
|
236
|
+
return renderPrimitive("span", {
|
|
237
|
+
...props,
|
|
238
|
+
"data-dreamboard-zone-pile-label": "",
|
|
239
|
+
"data-zone": pile.zone,
|
|
240
|
+
children: children ?? pile.label,
|
|
241
|
+
});
|
|
242
|
+
}
|
|
243
|
+
export function ZonePileCount({ children, ...props }) {
|
|
244
|
+
const pile = useZonePileContext();
|
|
245
|
+
return renderPrimitive("span", {
|
|
246
|
+
...props,
|
|
247
|
+
"data-dreamboard-zone-pile-count": "",
|
|
248
|
+
"data-zone": pile.zone,
|
|
249
|
+
"data-card-count": pile.count,
|
|
250
|
+
children: children ?? `${pile.count} cards`,
|
|
251
|
+
});
|
|
252
|
+
}
|
|
253
|
+
export function ZonePileDescription({ children, ...props }) {
|
|
254
|
+
const pile = useZonePileContext();
|
|
255
|
+
const description = children ?? pile.description;
|
|
256
|
+
if (description === null || description === undefined)
|
|
257
|
+
return null;
|
|
258
|
+
return renderPrimitive("span", {
|
|
259
|
+
...props,
|
|
260
|
+
"data-dreamboard-zone-pile-description": "",
|
|
261
|
+
"data-zone": pile.zone,
|
|
262
|
+
children: description,
|
|
263
|
+
});
|
|
264
|
+
}
|
|
265
|
+
export function ZonePileCards({ renderCard, ...props }) {
|
|
266
|
+
const pile = useZonePileContext();
|
|
267
|
+
if (!pile.hasVisibleCards)
|
|
268
|
+
return null;
|
|
269
|
+
return (_jsx(ZoneList, { ...props, children: pile.items.map((card) => (_jsx(ZoneItem, { card: card, children: renderCard(card) }, card.id))) }));
|
|
270
|
+
}
|
|
271
|
+
function indexOfCard(snapshot, cardId) {
|
|
272
|
+
return snapshot?.cardIds.indexOf(cardId) ?? -1;
|
|
273
|
+
}
|
|
274
|
+
function resolveZoneCardIndex(snapshot, index) {
|
|
275
|
+
const count = snapshot?.cardIds.length ?? 0;
|
|
276
|
+
const resolved = index < 0 ? count + index : index;
|
|
277
|
+
return resolved >= 0 && resolved < count ? resolved : null;
|
|
278
|
+
}
|
|
279
|
+
function createZoneCardRenderItem(zone, snapshot, cardId, index) {
|
|
280
|
+
const card = parseViewCard(snapshot?.cardsById[cardId]);
|
|
281
|
+
if (card === null) {
|
|
282
|
+
// The snapshot exposes this card id but not its contents. Surface that
|
|
283
|
+
// honestly via the `hidden: true` variant instead of fabricating a
|
|
284
|
+
// ViewCard with a fake `cardType: "unknown"`.
|
|
285
|
+
return { id: cardId, zone, index, hidden: true };
|
|
286
|
+
}
|
|
287
|
+
const interactions = snapshot?.playableByCardId[cardId] ?? [];
|
|
288
|
+
return {
|
|
289
|
+
...card,
|
|
290
|
+
id: cardId,
|
|
291
|
+
zone,
|
|
292
|
+
index,
|
|
293
|
+
hidden: false,
|
|
294
|
+
playable: interactions.some((descriptor) => descriptor.available),
|
|
295
|
+
interactions,
|
|
296
|
+
};
|
|
297
|
+
}
|
|
298
|
+
function useZoneCardActionRoute(cardId, snapshot, interaction, input) {
|
|
299
|
+
return useMemo(() => {
|
|
300
|
+
if (!cardId || !snapshot) {
|
|
301
|
+
return { descriptor: null, inputKey: null, ambiguous: false };
|
|
302
|
+
}
|
|
303
|
+
const interactions = snapshot.playableByCardId[cardId] ?? [];
|
|
304
|
+
if (interaction) {
|
|
305
|
+
const descriptor = interactions.find((candidate) => candidate.interactionKey === interaction ||
|
|
306
|
+
candidate.interactionId === interaction) ?? null;
|
|
307
|
+
return {
|
|
308
|
+
descriptor,
|
|
309
|
+
inputKey: descriptor
|
|
310
|
+
? inputKeyForCardAction(descriptor, cardId, input)
|
|
311
|
+
: null,
|
|
312
|
+
ambiguous: false,
|
|
313
|
+
};
|
|
314
|
+
}
|
|
315
|
+
const matches = interactions.flatMap((descriptor) => {
|
|
316
|
+
if (!descriptor.available)
|
|
317
|
+
return [];
|
|
318
|
+
const inputKey = inputKeyForCardAction(descriptor, cardId, input);
|
|
319
|
+
return inputKey ? [{ descriptor, inputKey }] : [];
|
|
320
|
+
});
|
|
321
|
+
if (matches.length !== 1) {
|
|
322
|
+
return {
|
|
323
|
+
descriptor: matches[0]?.descriptor ?? null,
|
|
324
|
+
inputKey: matches[0]?.inputKey ?? null,
|
|
325
|
+
ambiguous: matches.length > 1,
|
|
326
|
+
};
|
|
327
|
+
}
|
|
328
|
+
const match = matches[0];
|
|
329
|
+
if (!match) {
|
|
330
|
+
return { descriptor: null, inputKey: null, ambiguous: false };
|
|
331
|
+
}
|
|
332
|
+
return {
|
|
333
|
+
descriptor: match.descriptor,
|
|
334
|
+
inputKey: match.inputKey,
|
|
335
|
+
ambiguous: false,
|
|
336
|
+
};
|
|
337
|
+
}, [cardId, input, interaction, snapshot]);
|
|
338
|
+
}
|
|
339
|
+
function inputKeyForCardAction(descriptor, cardId, explicitInput) {
|
|
340
|
+
if (explicitInput) {
|
|
341
|
+
const input = descriptor.inputs.find((candidate) => candidate.key === explicitInput);
|
|
342
|
+
return input?.domain.type === "target" &&
|
|
343
|
+
input.domain.targetKind === "card" &&
|
|
344
|
+
(input.domain.eligibleTargets === undefined ||
|
|
345
|
+
input.domain.eligibleTargets.includes(cardId))
|
|
346
|
+
? input.key
|
|
347
|
+
: null;
|
|
348
|
+
}
|
|
349
|
+
const targetInput = inputByTarget(descriptor, "card", cardId);
|
|
350
|
+
if (targetInput)
|
|
351
|
+
return targetInput.key;
|
|
352
|
+
if (interactionInputKeys(descriptor).includes("cardId")) {
|
|
353
|
+
return descriptor.inputs.find((candidate) => candidate.key === "cardId")
|
|
354
|
+
? "cardId"
|
|
355
|
+
: null;
|
|
356
|
+
}
|
|
357
|
+
return null;
|
|
358
|
+
}
|
|
359
|
+
function resolveCardActionExtraInputs(extraInputs, cardId) {
|
|
360
|
+
return typeof extraInputs === "function"
|
|
361
|
+
? extraInputs(cardId)
|
|
362
|
+
: (extraInputs ?? {});
|
|
363
|
+
}
|
|
364
|
+
function parseViewCard(serialized) {
|
|
365
|
+
if (!serialized)
|
|
366
|
+
return null;
|
|
367
|
+
try {
|
|
368
|
+
const parsed = JSON.parse(serialized);
|
|
369
|
+
if (typeof parsed.id !== "string" || typeof parsed.cardType !== "string") {
|
|
370
|
+
return null;
|
|
371
|
+
}
|
|
372
|
+
return {
|
|
373
|
+
...parsed,
|
|
374
|
+
id: parsed.id,
|
|
375
|
+
cardType: parsed.cardType,
|
|
376
|
+
properties: parsed.properties && typeof parsed.properties === "object"
|
|
377
|
+
? parsed.properties
|
|
378
|
+
: {},
|
|
379
|
+
};
|
|
380
|
+
}
|
|
381
|
+
catch {
|
|
382
|
+
return null;
|
|
383
|
+
}
|
|
384
|
+
}
|
|
54
385
|
export const Zone = {
|
|
55
386
|
Root: ZoneRoot,
|
|
56
387
|
List: ZoneList,
|
|
57
388
|
Item: ZoneItem,
|
|
389
|
+
CardAt: ZoneCardAt,
|
|
390
|
+
TopCard: ZoneTopCard,
|
|
391
|
+
CardAction: ZoneCardAction,
|
|
392
|
+
PileRoot: ZonePileRoot,
|
|
393
|
+
PileTrigger: ZonePileTrigger,
|
|
394
|
+
PileLabel: ZonePileLabel,
|
|
395
|
+
PileCount: ZonePileCount,
|
|
396
|
+
PileDescription: ZonePileDescription,
|
|
397
|
+
PileCards: ZonePileCards,
|
|
58
398
|
};
|
package/dist/reducer.d.ts
CHANGED
|
@@ -1,21 +1,9 @@
|
|
|
1
|
-
export { useActivePlayers } from "./hooks/useActivePlayers.js";
|
|
2
|
-
export { useSimultaneousPhase } from "./hooks/useSimultaneousPhase.js";
|
|
3
|
-
export { usePlayerTurnOrder } from "./hooks/usePlayerTurnOrder.js";
|
|
4
|
-
export { useGameSelector } from "./hooks/useGameSelector.js";
|
|
5
|
-
export { useIsMyTurn } from "./hooks/useIsMyTurn.js";
|
|
6
|
-
export { useCards } from "./hooks/useCards.js";
|
|
7
|
-
export { useGameView } from "./hooks/useGameView.js";
|
|
8
|
-
export { useLobby } from "./hooks/useLobby.js";
|
|
9
|
-
export { useMe } from "./hooks/useMe.js";
|
|
10
|
-
export { usePlayerInfo } from "./hooks/usePlayerInfo.js";
|
|
11
|
-
export { useSeatInbox, type SeatInbox } from "./hooks/useSeatInbox.js";
|
|
12
|
-
export { useInteractionHandle, type InteractionHandle, type InteractionHandleStatus, type DraftValidation, type InteractionParamsShape, } from "./hooks/useInteractionHandle.js";
|
|
13
|
-
export { useInteractionByKey } from "./hooks/useInteractionByKey.js";
|
|
14
|
-
export { usePluginSession } from "./context/PluginSessionContext.js";
|
|
15
1
|
export { type ClientParamSchema, type ClientParamSchemaMap, } from "./context/ClientParamSchemaContext.js";
|
|
16
2
|
export type { GameplayPromptOption, GameplaySnapshot, PluginStateSnapshot, } from "./types/reducer-state.js";
|
|
17
3
|
export type { InteractionDescriptor, InteractionContext, InteractionContextOption, } from "./types/plugin-state.js";
|
|
18
4
|
export type { LobbyState } from "./hooks/useLobby.js";
|
|
19
5
|
export type { Player } from "./hooks/useMe.js";
|
|
6
|
+
export type { SeatInbox } from "./hooks/useSeatInbox.js";
|
|
7
|
+
export type { DraftValidation, InteractionHandle, InteractionHandleStatus, InteractionParamsShape, } from "./hooks/useInteractionHandle.js";
|
|
20
8
|
export type { CardCollection, ViewCard, ViewSlotOccupant, } from "@dreamboard/sdk-types";
|
|
21
9
|
//# sourceMappingURL=reducer.d.ts.map
|
package/dist/reducer.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"reducer.d.ts","sourceRoot":"","sources":["../src/reducer.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"reducer.d.ts","sourceRoot":"","sources":["../src/reducer.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,iBAAiB,EACtB,KAAK,oBAAoB,GAC1B,MAAM,uCAAuC,CAAC;AAE/C,YAAY,EACV,oBAAoB,EACpB,gBAAgB,EAChB,mBAAmB,GACpB,MAAM,0BAA0B,CAAC;AAClC,YAAY,EACV,qBAAqB,EACrB,kBAAkB,EAClB,wBAAwB,GACzB,MAAM,yBAAyB,CAAC;AACjC,YAAY,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AACtD,YAAY,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAC/C,YAAY,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AACzD,YAAY,EACV,eAAe,EACf,iBAAiB,EACjB,uBAAuB,EACvB,sBAAsB,GACvB,MAAM,iCAAiC,CAAC;AACzC,YAAY,EACV,cAAc,EACd,QAAQ,EACR,gBAAgB,GACjB,MAAM,uBAAuB,CAAC"}
|
package/dist/reducer.js
CHANGED
|
@@ -1,14 +1 @@
|
|
|
1
|
-
export {
|
|
2
|
-
export { useSimultaneousPhase } from "./hooks/useSimultaneousPhase.js";
|
|
3
|
-
export { usePlayerTurnOrder } from "./hooks/usePlayerTurnOrder.js";
|
|
4
|
-
export { useGameSelector } from "./hooks/useGameSelector.js";
|
|
5
|
-
export { useIsMyTurn } from "./hooks/useIsMyTurn.js";
|
|
6
|
-
export { useCards } from "./hooks/useCards.js";
|
|
7
|
-
export { useGameView } from "./hooks/useGameView.js";
|
|
8
|
-
export { useLobby } from "./hooks/useLobby.js";
|
|
9
|
-
export { useMe } from "./hooks/useMe.js";
|
|
10
|
-
export { usePlayerInfo } from "./hooks/usePlayerInfo.js";
|
|
11
|
-
export { useSeatInbox } from "./hooks/useSeatInbox.js";
|
|
12
|
-
export { useInteractionHandle, } from "./hooks/useInteractionHandle.js";
|
|
13
|
-
export { useInteractionByKey } from "./hooks/useInteractionByKey.js";
|
|
14
|
-
export { usePluginSession } from "./context/PluginSessionContext.js";
|
|
1
|
+
export {};
|
|
@@ -241,7 +241,7 @@ export function createPluginRuntimeAPI() {
|
|
|
241
241
|
}, "*");
|
|
242
242
|
// Tier-0 perf: after notifyStateListeners has kicked React's
|
|
243
243
|
// render, schedule a post-commit microtask + rAF chain so the
|
|
244
|
-
//
|
|
244
|
+
// paired `state-rendered` message lands close to when the
|
|
245
245
|
// plugin's DOM would have been painted. `queueMicrotask` is
|
|
246
246
|
// used first because most React listeners finish synchronously;
|
|
247
247
|
// `requestAnimationFrame` then bounces to the next paint tick.
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export type HexColor = string & {
|
|
2
|
+
readonly __brand: "HexColor";
|
|
3
|
+
};
|
|
4
|
+
export declare function isHexColor(value: unknown): value is HexColor;
|
|
5
|
+
export declare function parseHexColor(value: unknown): HexColor | undefined;
|
|
6
|
+
export declare function hexColor(value: string): HexColor;
|
|
7
|
+
//# sourceMappingURL=hex-color.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hex-color.d.ts","sourceRoot":"","sources":["../../src/types/hex-color.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,QAAQ,GAAG,MAAM,GAAG;IAAE,QAAQ,CAAC,OAAO,EAAE,UAAU,CAAA;CAAE,CAAC;AAIjE,wBAAgB,UAAU,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,QAAQ,CAE5D;AAED,wBAAgB,aAAa,CAAC,KAAK,EAAE,OAAO,GAAG,QAAQ,GAAG,SAAS,CAElE;AAED,wBAAgB,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,QAAQ,CAOhD"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
const HEX_COLOR_PATTERN = /^#[0-9A-Fa-f]{6}$/;
|
|
2
|
+
export function isHexColor(value) {
|
|
3
|
+
return typeof value === "string" && HEX_COLOR_PATTERN.test(value);
|
|
4
|
+
}
|
|
5
|
+
export function parseHexColor(value) {
|
|
6
|
+
return isHexColor(value) ? value : undefined;
|
|
7
|
+
}
|
|
8
|
+
export function hexColor(value) {
|
|
9
|
+
if (!isHexColor(value)) {
|
|
10
|
+
throw new Error(`Expected a 6-digit hex color such as #E53935, received '${value}'.`);
|
|
11
|
+
}
|
|
12
|
+
return value;
|
|
13
|
+
}
|
|
@@ -1,6 +1,19 @@
|
|
|
1
1
|
import type { ViewCard } from "@dreamboard/sdk-types";
|
|
2
|
-
import type { PlayerId, CardId, CardIdsByDeckId, CardProperties, EdgeTypeId, VertexTypeId, BoardBaseId, BoardId,
|
|
3
|
-
|
|
2
|
+
import type { PlayerId, CardId, CardIdsByDeckId, CardProperties, EdgeTypeId, VertexTypeId, BoardBaseId, BoardId, PieceId, PieceTypeId, SpaceId, SpaceTypeId, DieId } from "@dreamboard/manifest-contract";
|
|
3
|
+
import type { HexColor } from "./hex-color.js";
|
|
4
|
+
export interface PerPlayer<Value> {
|
|
5
|
+
readonly __perPlayer: true;
|
|
6
|
+
readonly entries: ReadonlyArray<readonly [PlayerId, Value]>;
|
|
7
|
+
}
|
|
8
|
+
export interface SharedBoardRef<BaseId extends string = BoardBaseId> {
|
|
9
|
+
readonly baseId: BaseId;
|
|
10
|
+
readonly seat?: undefined;
|
|
11
|
+
}
|
|
12
|
+
export interface PerPlayerBoardRef<BaseId extends string = BoardBaseId, Id extends string = PlayerId> {
|
|
13
|
+
readonly baseId: BaseId;
|
|
14
|
+
readonly seat: Id;
|
|
15
|
+
}
|
|
16
|
+
export type BoardRef<BaseId extends string = BoardBaseId, Id extends string = PlayerId> = SharedBoardRef<BaseId> | PerPlayerBoardRef<BaseId, Id>;
|
|
4
17
|
/**
|
|
5
18
|
* Hands are keyed by the authored hand id and split per seat. The per-seat
|
|
6
19
|
* entries are populated from the runtime seat list, not the static manifest
|
|
@@ -19,9 +32,9 @@ export interface Player {
|
|
|
19
32
|
/** Whether this player is the host */
|
|
20
33
|
isHost?: boolean;
|
|
21
34
|
/** Player's assigned color */
|
|
22
|
-
color?:
|
|
35
|
+
color?: HexColor;
|
|
23
36
|
}
|
|
24
|
-
export interface HexTileState<B extends string = BoardId, SpaceIdValue extends
|
|
37
|
+
export interface HexTileState<B extends string = BoardId, SpaceIdValue extends string = SpaceId, Properties = B extends keyof TilePropertiesByBoardId ? TilePropertiesByBoardId[B] : undefined, View = unknown> {
|
|
25
38
|
/** Unique tile identifier */
|
|
26
39
|
id: SpaceIdValue;
|
|
27
40
|
/** Axial coordinate Q */
|
|
@@ -38,13 +51,13 @@ export interface HexTileState<B extends string = BoardId, SpaceIdValue extends S
|
|
|
38
51
|
properties?: Properties;
|
|
39
52
|
/**
|
|
40
53
|
* Optional view-projection overlay merged onto the static topology by
|
|
41
|
-
*
|
|
42
|
-
* supply this directly when building tiles by hand.
|
|
54
|
+
* component-first board helpers such as `Board.HexView`. Authored boards can
|
|
55
|
+
* also supply this directly when building tiles by hand.
|
|
43
56
|
*/
|
|
44
57
|
view?: View;
|
|
45
58
|
}
|
|
46
59
|
/** State of an edge on a reducer-projected hex board. */
|
|
47
|
-
export interface HexEdgeState<B extends string = BoardId, SpaceIdValue extends
|
|
60
|
+
export interface HexEdgeState<B extends string = BoardId, SpaceIdValue extends string = SpaceId, EdgeIdValue extends string = string, Properties = B extends keyof EdgePropertiesByBoardId ? EdgePropertiesByBoardId[B] : undefined> {
|
|
48
61
|
/** Unique edge identifier (serialized string, e.g., "tile1-tile2") */
|
|
49
62
|
id: EdgeIdValue;
|
|
50
63
|
/** First hex tile ID this edge borders */
|
|
@@ -61,7 +74,7 @@ export interface HexEdgeState<B extends string = BoardId, SpaceIdValue extends S
|
|
|
61
74
|
properties?: Properties;
|
|
62
75
|
}
|
|
63
76
|
/** State of a vertex on a reducer-projected hex board. */
|
|
64
|
-
export interface HexVertexState<B extends string = BoardId, SpaceIdValue extends
|
|
77
|
+
export interface HexVertexState<B extends string = BoardId, SpaceIdValue extends string = SpaceId, VertexIdValue extends string = string, Properties = B extends keyof VertexPropertiesByBoardId ? VertexPropertiesByBoardId[B] : undefined> {
|
|
65
78
|
/** Unique vertex identifier (serialized string, e.g., "tile1-tile2-tile3") */
|
|
66
79
|
id: VertexIdValue;
|
|
67
80
|
/** The hex tile IDs this vertex touches */
|
|
@@ -76,7 +89,7 @@ export interface HexVertexState<B extends string = BoardId, SpaceIdValue extends
|
|
|
76
89
|
properties?: Properties;
|
|
77
90
|
}
|
|
78
91
|
/** Complete state of a reducer-projected hex board. */
|
|
79
|
-
export interface HexBoardState<B extends string = BoardId, SpaceIdValue extends
|
|
92
|
+
export 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> {
|
|
80
93
|
/** Unique board identifier */
|
|
81
94
|
id: B;
|
|
82
95
|
/** All tiles on the board */
|
|
@@ -145,7 +158,7 @@ export interface NetworkBoardState {
|
|
|
145
158
|
pieces: NetworkPieceState[];
|
|
146
159
|
}
|
|
147
160
|
/** State of a cell on a reducer-projected square grid board. */
|
|
148
|
-
export interface SquareCellState<SpaceIdValue extends
|
|
161
|
+
export interface SquareCellState<SpaceIdValue extends string = SpaceId, Properties = Record<string, unknown>> {
|
|
149
162
|
/** Unique cell identifier */
|
|
150
163
|
id: SpaceIdValue;
|
|
151
164
|
/** Row index (0-based) */
|
|
@@ -162,7 +175,7 @@ export interface SquareCellState<SpaceIdValue extends SpaceId = SpaceId, Propert
|
|
|
162
175
|
properties?: Properties;
|
|
163
176
|
}
|
|
164
177
|
/** State of an edge on a reducer-projected square grid board. */
|
|
165
|
-
export interface SquareEdgeState<SpaceIdValue extends
|
|
178
|
+
export interface SquareEdgeState<SpaceIdValue extends string = SpaceId, EdgeIdValue extends string = string, Properties = Record<string, unknown>> {
|
|
166
179
|
/** Unique edge identifier */
|
|
167
180
|
id: EdgeIdValue;
|
|
168
181
|
/** The cell IDs this edge borders */
|
|
@@ -177,7 +190,7 @@ export interface SquareEdgeState<SpaceIdValue extends SpaceId = SpaceId, EdgeIdV
|
|
|
177
190
|
properties?: Properties;
|
|
178
191
|
}
|
|
179
192
|
/** State of a vertex on a reducer-projected square grid board. */
|
|
180
|
-
export interface SquareVertexState<SpaceIdValue extends
|
|
193
|
+
export interface SquareVertexState<SpaceIdValue extends string = SpaceId, VertexIdValue extends string = string, Properties = Record<string, unknown>> {
|
|
181
194
|
/** Unique vertex identifier */
|
|
182
195
|
id: VertexIdValue;
|
|
183
196
|
/** The cell IDs that touch this corner */
|
|
@@ -192,7 +205,7 @@ export interface SquareVertexState<SpaceIdValue extends SpaceId = SpaceId, Verte
|
|
|
192
205
|
properties?: Properties;
|
|
193
206
|
}
|
|
194
207
|
/** State of a piece placed on a reducer-projected square grid cell. */
|
|
195
|
-
export interface SquarePieceState<PieceIdValue extends
|
|
208
|
+
export interface SquarePieceState<PieceIdValue extends string = PieceId, Properties = Record<string, unknown>> {
|
|
196
209
|
/** Unique piece identifier */
|
|
197
210
|
id: PieceIdValue;
|
|
198
211
|
/** Row index where piece is located */
|
|
@@ -207,7 +220,7 @@ export interface SquarePieceState<PieceIdValue extends PieceId = PieceId, Proper
|
|
|
207
220
|
properties?: Properties;
|
|
208
221
|
}
|
|
209
222
|
/** Complete state of a reducer-projected square grid board. */
|
|
210
|
-
export interface SquareBoardState<B extends string = BoardId, SpaceIdValue extends
|
|
223
|
+
export 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>> {
|
|
211
224
|
/** Unique board identifier */
|
|
212
225
|
id: B;
|
|
213
226
|
/** Number of rows in the grid */
|
|
@@ -334,4 +347,5 @@ export interface GameState {
|
|
|
334
347
|
boards: BoardStates;
|
|
335
348
|
dice: DiceStates;
|
|
336
349
|
}
|
|
350
|
+
export {};
|
|
337
351
|
//# sourceMappingURL=player-state.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"player-state.d.ts","sourceRoot":"","sources":["../../src/types/player-state.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AACtD,OAAO,KAAK,EACV,QAAQ,EACR,MAAM,EACN,eAAe,EACf,cAAc,EACd,UAAU,EACV,YAAY,EACZ,WAAW,EACX,OAAO,EACP,
|
|
1
|
+
{"version":3,"file":"player-state.d.ts","sourceRoot":"","sources":["../../src/types/player-state.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AACtD,OAAO,KAAK,EACV,QAAQ,EACR,MAAM,EACN,eAAe,EACf,cAAc,EACd,UAAU,EACV,YAAY,EACZ,WAAW,EACX,OAAO,EACP,OAAO,EACP,WAAW,EACX,OAAO,EACP,WAAW,EACX,KAAK,EACN,MAAM,+BAA+B,CAAC;AACvC,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAE/C,MAAM,WAAW,SAAS,CAAC,KAAK;IAC9B,QAAQ,CAAC,WAAW,EAAE,IAAI,CAAC;IAC3B,QAAQ,CAAC,OAAO,EAAE,aAAa,CAAC,SAAS,CAAC,QAAQ,EAAE,KAAK,CAAC,CAAC,CAAC;CAC7D;AAED,MAAM,WAAW,cAAc,CAAC,MAAM,SAAS,MAAM,GAAG,WAAW;IACjE,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,IAAI,CAAC,EAAE,SAAS,CAAC;CAC3B;AAED,MAAM,WAAW,iBAAiB,CAChC,MAAM,SAAS,MAAM,GAAG,WAAW,EACnC,EAAE,SAAS,MAAM,GAAG,QAAQ;IAE5B,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,IAAI,EAAE,EAAE,CAAC;CACnB;AAED,MAAM,MAAM,QAAQ,CAClB,MAAM,SAAS,MAAM,GAAG,WAAW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