@dreamboard-games/sdk 0.5.0-alpha.3 → 0.5.0-alpha.5
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 +55 -4
- package/dist/board-target-B0QG6OYx.d.ts +8 -0
- package/dist/chunk-3JXUL4VN.js +139 -0
- package/dist/chunk-3JXUL4VN.js.map +1 -0
- package/dist/{chunk-SP234IY4.js → chunk-7RGMPJQG.js} +340 -248
- package/dist/chunk-7RGMPJQG.js.map +1 -0
- package/dist/{chunk-FMM5LVJW.js → chunk-K75F5UIJ.js} +27 -12
- package/dist/chunk-K75F5UIJ.js.map +1 -0
- package/dist/{chunk-ZPRKWPEP.js → chunk-N37D7NPB.js} +116 -29
- package/dist/chunk-N37D7NPB.js.map +1 -0
- package/dist/{chunk-LRILEVKC.js → chunk-UESVBUPU.js} +473 -496
- package/dist/chunk-UESVBUPU.js.map +1 -0
- package/dist/{diagnostics-B0lgnuZ6.d.ts → diagnostics-9gJgI85c.d.ts} +2 -2
- package/dist/{definition-BaHNPZol.d.ts → extract-Bjuw_gdF.d.ts} +2513 -2390
- package/dist/index.d.ts +524 -185
- package/dist/index.js +280 -226
- package/dist/index.js.map +1 -1
- package/dist/model-BCl8WsB6.d.ts +551 -0
- package/dist/react.d.ts +35 -7
- package/dist/react.js +137 -11
- package/dist/react.js.map +1 -1
- package/dist/reducer.d.ts +227 -151
- package/dist/reducer.js +343 -569
- package/dist/reducer.js.map +1 -1
- package/dist/testing.d.ts +54 -42
- package/dist/testing.js +120 -69
- package/dist/testing.js.map +1 -1
- package/dist/{types-DimqnJBq.d.ts → types-B3kIhBWb.d.ts} +41 -10
- package/package.json +20 -17
- package/dist/chunk-FMM5LVJW.js.map +0 -1
- package/dist/chunk-LRILEVKC.js.map +0 -1
- package/dist/chunk-SP234IY4.js.map +0 -1
- package/dist/chunk-VUWNJXLJ.js +0 -52
- package/dist/chunk-VUWNJXLJ.js.map +0 -1
- package/dist/chunk-ZPRKWPEP.js.map +0 -1
- package/dist/model-BHro6yXu.d.ts +0 -288
package/README.md
CHANGED
|
@@ -13,7 +13,7 @@ pnpm add @dreamboard-games/sdk
|
|
|
13
13
|
The package declarations and export map are the API authority. There are four entry points:
|
|
14
14
|
|
|
15
15
|
- `@dreamboard-games/sdk`: framework-free instances, sources, features and canonical host protocol schemas.
|
|
16
|
-
- `@dreamboard-games/sdk/react`: typed React provider,
|
|
16
|
+
- `@dreamboard-games/sdk/react`: typed React provider, selectors, subscriptions, and dnd-kit card/drop hooks.
|
|
17
17
|
- `@dreamboard-games/sdk/reducer`: game authoring, manifest compilation, execution and trusted worker admission.
|
|
18
18
|
- `@dreamboard-games/sdk/testing`: browser-safe local/scenario sources, replay, inspection and bounded exploration.
|
|
19
19
|
|
|
@@ -188,18 +188,60 @@ and pass a source to its `GameProvider`. The hosted UI imports `Game` only as a
|
|
|
188
188
|
`iframeSource()` supplies authoritative frames and handles commands.
|
|
189
189
|
No authoring generation step or shared workspace files are needed.
|
|
190
190
|
|
|
191
|
+
Manifest card counts and explicit piece/die seed counts must be positive safe
|
|
192
|
+
integers. Omitted seed counts mean one copy. Zero, negative, fractional, non-finite,
|
|
193
|
+
and unsafe counts fail before ID expansion; negative, zero, and fractional literals
|
|
194
|
+
also fail typechecking. Widened `number` values still require runtime validation.
|
|
195
|
+
Player bounds must be positive safe integers with `minPlayers <= maxPlayers`.
|
|
196
|
+
|
|
197
|
+
`defineTopologyManifest` returns `ValidatedManifest<M>` after semantic validation.
|
|
198
|
+
`compileManifest` returns a branded `CompiledManifest<M>` after validation and table
|
|
199
|
+
materialization. Both snapshot the authored input so later source edits do not
|
|
200
|
+
change the validated value or future initial tables. Literal IDs remain inferred.
|
|
201
|
+
|
|
202
|
+
`ReducerGameDefinitionInput` describes the authored assembly fields. The assembled
|
|
203
|
+
`ReducerGameDefinition` adds the bound contract and validation brand; authors never
|
|
204
|
+
supply those output-only fields.
|
|
205
|
+
|
|
206
|
+
`game.assemble` checks phase names, the initial phase, interaction declarations,
|
|
207
|
+
and simultaneous-phase requirements, then returns a branded `ReducerGameDefinition`.
|
|
208
|
+
Runtime consumers such as `createReducerBundle` require that assembled type;
|
|
209
|
+
handwritten structural lookalikes do not satisfy it. These brands record SDK
|
|
210
|
+
construction checks, not correctness of arbitrary reducer callbacks, and do not
|
|
211
|
+
replace validation of runtime commands or state. As with other TypeScript types,
|
|
212
|
+
explicit assertions can bypass them; treat constructed definitions as immutable.
|
|
213
|
+
Each card in a manual card set requires `id` for its definition and `cardType`
|
|
214
|
+
for its category:
|
|
215
|
+
|
|
216
|
+
```ts
|
|
217
|
+
cards: [
|
|
218
|
+
{ id: "ace", cardType: "ranked", name: "Ace", count: 2, properties: {} },
|
|
219
|
+
{ id: "king", cardType: "ranked", name: "King", count: 1, properties: {} },
|
|
220
|
+
];
|
|
221
|
+
```
|
|
222
|
+
|
|
223
|
+
These definitions create runtime IDs `ace-1`, `ace-2`, and `king`, all in the
|
|
224
|
+
`ranked` category. When the card schema has `variants`, every `cardType` must
|
|
225
|
+
name one of them; `compileManifest` and `createGame` reject unknown categories.
|
|
226
|
+
The inferred table narrows a card lookup by its runtime ID to that definition's
|
|
227
|
+
card set, category, and properties. A variant property overrides a shared
|
|
228
|
+
property of the same name in both the runtime schema and inferred type.
|
|
229
|
+
To migrate an older manifest, replace each card's `type` with `id` and set
|
|
230
|
+
`cardType` explicitly (often to the former `type` value).
|
|
231
|
+
|
|
191
232
|
## Reducer runner contract
|
|
192
233
|
|
|
193
234
|
`createReducerBundle(game)` returns exactly the contract version and four
|
|
194
235
|
operations: `boardStatic()`, `initialize(input)`, `dispatch({ state, input })`,
|
|
195
|
-
and `project({ state, playerIds })`. The runner contract is `0.
|
|
236
|
+
and `project({ state, playerIds })`. The runner contract is `0.8.0`; hosts must
|
|
196
237
|
require that exact version. Dispatch includes validation, direct transaction mutations, and phase entry.
|
|
197
238
|
Initialization returns
|
|
198
239
|
`{ state, terminal?, events? }`, preserving outcomes and events from initial
|
|
199
240
|
phase entry and returned transitions.
|
|
200
241
|
|
|
201
|
-
Mutation callbacks use `tx.roll(dieId)`, `tx.shuffle({ zoneId, playerId? })`,
|
|
202
|
-
`tx.deal({ fromZoneId, toZoneId, playerId, count })`
|
|
242
|
+
Mutation callbacks use `tx.roll(dieId)`, `tx.shuffle({ zoneId, playerId? })`,
|
|
243
|
+
`tx.deal({ fromZoneId, toZoneId, playerId, count })` and
|
|
244
|
+
`tx.flipCard({ cardId, faceUp })` directly. Return
|
|
203
245
|
`tx.transition(phaseName)` to enter a phase, including reentering the current
|
|
204
246
|
phase. An unreturned outcome schedules no work. Entry chains are bounded to
|
|
205
247
|
1,000 entries per dispatch. `tx.endGame(outcome, { transition })` enters the
|
|
@@ -255,6 +297,11 @@ pnpm add @dreamboard-games/sdk react@^19 react-dom@^19 @tanstack/react-store@0.1
|
|
|
255
297
|
install the React adapter. The `/react` entry delegates selectors to that package;
|
|
256
298
|
the application bundler resolves its supported React subscription dependencies.
|
|
257
299
|
|
|
300
|
+
The SDK includes dnd-kit for `/react` drag and drop. Enable `dragFeature`, export
|
|
301
|
+
`useCardDrag` and `useBoardDrop` from the binding, and use the copied Hand and
|
|
302
|
+
BoardTargets components or your own renderer. GameProvider owns the drag provider.
|
|
303
|
+
Headless `game.drag` remains browser-free and handles atomic domain routing.
|
|
304
|
+
|
|
258
305
|
## Local development and tests
|
|
259
306
|
|
|
260
307
|
`localSource(game, { players, seed, as, options })` executes the production reducer
|
|
@@ -273,3 +320,7 @@ Hosts import `assertReducerBundleContract`, `REDUCER_CONTRACT_VERSION`,
|
|
|
273
320
|
and gameplay websocket schemas plus `materializePluginGameplayFrame` live at the
|
|
274
321
|
root. Materialize the seat projection with static board data before publishing it;
|
|
275
322
|
sources publish the canonical seat view and keep command bases private.
|
|
323
|
+
|
|
324
|
+
Card sets contain their authored `cards`, `cardSchema`, and `defaultHome` directly.
|
|
325
|
+
Standard playing cards are game-owned definitions with ordinary suit/rank
|
|
326
|
+
properties; the SDK does not synthesize inventories or assign built-in rules.
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/** A space on one player's board; boardId is the base manifest board ID. */
|
|
2
|
+
type PlayerBoardSpaceTarget<BoardId extends string = string, SpaceId extends string = string, PlayerId extends string = string> = {
|
|
3
|
+
readonly boardId: BoardId;
|
|
4
|
+
readonly playerId: PlayerId;
|
|
5
|
+
readonly spaceId: SpaceId;
|
|
6
|
+
};
|
|
7
|
+
|
|
8
|
+
export type { PlayerBoardSpaceTarget as P };
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __export = (target, all) => {
|
|
3
|
+
for (var name in all)
|
|
4
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
5
|
+
};
|
|
6
|
+
|
|
7
|
+
// src/shared/lookup.ts
|
|
8
|
+
function requireLookup(value, kind, id) {
|
|
9
|
+
if (value === void 0) throw new Error(`${kind} "${id}" is not present.`);
|
|
10
|
+
return value;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
// src/shared/board-target.ts
|
|
14
|
+
import { z } from "zod";
|
|
15
|
+
var PlayerBoardSpaceTargetSchema = z.strictObject({
|
|
16
|
+
boardId: z.string(),
|
|
17
|
+
playerId: z.string(),
|
|
18
|
+
spaceId: z.string()
|
|
19
|
+
});
|
|
20
|
+
function isPlayerBoardSpaceTarget(value) {
|
|
21
|
+
return typeof value === "object" && value !== null && Object.keys(value).length === 3 && "boardId" in value && typeof value.boardId === "string" && "playerId" in value && typeof value.playerId === "string" && "spaceId" in value && typeof value.spaceId === "string";
|
|
22
|
+
}
|
|
23
|
+
function samePlayerBoardSpaceTarget(left, right) {
|
|
24
|
+
return left.boardId === right.boardId && left.playerId === right.playerId && left.spaceId === right.spaceId;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
// src/shared/input-domain.ts
|
|
28
|
+
function inputDomainErrors(domain, value, selection, options = {}) {
|
|
29
|
+
if (selection?.mode === "many") {
|
|
30
|
+
if (!Array.isArray(value)) return ["Expected a list of values."];
|
|
31
|
+
const errors = cardinalityErrors(
|
|
32
|
+
value,
|
|
33
|
+
selection.min,
|
|
34
|
+
selection.max,
|
|
35
|
+
"value",
|
|
36
|
+
options.ignoreMinimum
|
|
37
|
+
);
|
|
38
|
+
if (selection.distinct && new Set(value.map(inputValueKey)).size !== value.length)
|
|
39
|
+
errors.push("Choose each value only once.");
|
|
40
|
+
if (value.some(
|
|
41
|
+
(item) => inputDomainErrors(domain, item, void 0, options).length > 0
|
|
42
|
+
))
|
|
43
|
+
errors.push(ineligibleMessage(domain));
|
|
44
|
+
return errors;
|
|
45
|
+
}
|
|
46
|
+
switch (domain.type) {
|
|
47
|
+
case "choice":
|
|
48
|
+
return inputTargetInDomain(domain, value) ? [] : [ineligibleMessage(domain)];
|
|
49
|
+
case "choiceList": {
|
|
50
|
+
if (!Array.isArray(value)) return ["Expected a list of choices."];
|
|
51
|
+
const errors = cardinalityErrors(
|
|
52
|
+
value,
|
|
53
|
+
domain.min ?? 0,
|
|
54
|
+
domain.max ?? domain.choices.length,
|
|
55
|
+
"option",
|
|
56
|
+
options.ignoreMinimum
|
|
57
|
+
);
|
|
58
|
+
if (value.some((item) => !inputTargetInDomain(domain, item)))
|
|
59
|
+
errors.push(ineligibleMessage(domain));
|
|
60
|
+
return errors;
|
|
61
|
+
}
|
|
62
|
+
case "cardTarget":
|
|
63
|
+
case "boardTarget":
|
|
64
|
+
return inputTargetInDomain(domain, value) ? [] : [ineligibleMessage(domain)];
|
|
65
|
+
case "boundedNumber":
|
|
66
|
+
return typeof value === "number" && value >= domain.min && value <= domain.max && Math.abs(
|
|
67
|
+
(value - domain.min) / (domain.step ?? 1) - Math.round((value - domain.min) / (domain.step ?? 1))
|
|
68
|
+
) < 1e-9 ? [] : ["Value is outside the current input domain."];
|
|
69
|
+
case "resourceMap":
|
|
70
|
+
return typeof value === "object" && value !== null && !Array.isArray(value) && Object.keys(value).every(
|
|
71
|
+
(key) => domain.resources.some((entry) => entry.resourceId === key)
|
|
72
|
+
) && domain.resources.every((entry) => {
|
|
73
|
+
const amount = value[entry.resourceId] ?? 0;
|
|
74
|
+
return typeof amount === "number" && Number.isInteger(amount) && amount >= (entry.min ?? 0) && amount <= (entry.max ?? Infinity);
|
|
75
|
+
}) ? [] : ["Value is outside the current input domain."];
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
function inputValueInDomain(domain, value, selection, options = {}) {
|
|
79
|
+
return inputDomainErrors(domain, value, selection, options).length === 0;
|
|
80
|
+
}
|
|
81
|
+
function inputTargetInDomain(domain, value) {
|
|
82
|
+
switch (domain.type) {
|
|
83
|
+
case "choice":
|
|
84
|
+
case "choiceList":
|
|
85
|
+
return domain.choices.some(
|
|
86
|
+
(choice) => !choice.disabled && Object.is(choice.value, value)
|
|
87
|
+
);
|
|
88
|
+
case "cardTarget":
|
|
89
|
+
return typeof value === "string" && domain.eligibleTargets.includes(value);
|
|
90
|
+
case "boardTarget":
|
|
91
|
+
return domain.valueKind === "player-board-space" ? isPlayerBoardSpaceTarget(value) && domain.eligibleTargets.some(
|
|
92
|
+
(candidate) => samePlayerBoardSpaceTarget(candidate, value)
|
|
93
|
+
) : typeof value === "string" && domain.eligibleTargets.includes(value);
|
|
94
|
+
default:
|
|
95
|
+
return inputValueInDomain(domain, value);
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
function cardinalityErrors(value, min, max, unit, ignoreMinimum = false) {
|
|
99
|
+
const errors = [];
|
|
100
|
+
if (!ignoreMinimum && value.length < min)
|
|
101
|
+
errors.push(`Choose at least ${min} ${pluralize(unit, min)}.`);
|
|
102
|
+
if (max !== void 0 && value.length > max)
|
|
103
|
+
errors.push(`Choose at most ${max} ${pluralize(unit, max)}.`);
|
|
104
|
+
return errors;
|
|
105
|
+
}
|
|
106
|
+
function ineligibleMessage(domain) {
|
|
107
|
+
return domain.type === "choice" || domain.type === "choiceList" ? "Selected choice is not eligible." : domain.type === "cardTarget" || domain.type === "boardTarget" ? "Selected target is not eligible." : "Value is outside the current input domain.";
|
|
108
|
+
}
|
|
109
|
+
function inputValueKey(value) {
|
|
110
|
+
if (value === null) return "null";
|
|
111
|
+
if (isPlayerBoardSpaceTarget(value))
|
|
112
|
+
return `player-board-space:${JSON.stringify([value.boardId, value.playerId, value.spaceId])}`;
|
|
113
|
+
switch (typeof value) {
|
|
114
|
+
case "string":
|
|
115
|
+
return `string:${value}`;
|
|
116
|
+
case "number":
|
|
117
|
+
case "boolean":
|
|
118
|
+
case "undefined":
|
|
119
|
+
return `${typeof value}:${String(value)}`;
|
|
120
|
+
default:
|
|
121
|
+
return `json:${JSON.stringify(value)}`;
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
function pluralize(word, count) {
|
|
125
|
+
return count === 1 ? word : `${word}s`;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
export {
|
|
129
|
+
__export,
|
|
130
|
+
requireLookup,
|
|
131
|
+
PlayerBoardSpaceTargetSchema,
|
|
132
|
+
isPlayerBoardSpaceTarget,
|
|
133
|
+
samePlayerBoardSpaceTarget,
|
|
134
|
+
inputDomainErrors,
|
|
135
|
+
inputValueInDomain,
|
|
136
|
+
inputTargetInDomain,
|
|
137
|
+
inputValueKey
|
|
138
|
+
};
|
|
139
|
+
//# sourceMappingURL=chunk-3JXUL4VN.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/shared/lookup.ts","../src/shared/board-target.ts","../src/shared/input-domain.ts"],"sourcesContent":["/** Assert presence at a mutable table or projected-snapshot lookup boundary. */\nexport function requireLookup<T>(\n value: T | undefined,\n kind: string,\n id: string,\n): T {\n if (value === undefined) throw new Error(`${kind} \"${id}\" is not present.`);\n return value;\n}\n","import { z } from \"zod\";\n\n/** A space on one player's board; boardId is the base manifest board ID. */\nexport type PlayerBoardSpaceTarget<\n BoardId extends string = string,\n SpaceId extends string = string,\n PlayerId extends string = string,\n> = {\n readonly boardId: BoardId;\n readonly playerId: PlayerId;\n readonly spaceId: SpaceId;\n};\n\nexport const PlayerBoardSpaceTargetSchema = z.strictObject({\n boardId: z.string(),\n playerId: z.string(),\n spaceId: z.string(),\n});\n\nexport function isPlayerBoardSpaceTarget(\n value: unknown,\n): value is PlayerBoardSpaceTarget {\n return (\n typeof value === \"object\" &&\n value !== null &&\n Object.keys(value).length === 3 &&\n \"boardId\" in value &&\n typeof value.boardId === \"string\" &&\n \"playerId\" in value &&\n typeof value.playerId === \"string\" &&\n \"spaceId\" in value &&\n typeof value.spaceId === \"string\"\n );\n}\n\nexport function samePlayerBoardSpaceTarget(\n left: PlayerBoardSpaceTarget,\n right: PlayerBoardSpaceTarget,\n): boolean {\n return (\n left.boardId === right.boardId &&\n left.playerId === right.playerId &&\n left.spaceId === right.spaceId\n );\n}\n","import {\n isPlayerBoardSpaceTarget,\n samePlayerBoardSpaceTarget,\n} from \"./board-target\";\nimport type {\n InputDomainDescriptor,\n InputSelectionDescriptor,\n} from \"../reducer/model/spec/inputs\";\n\n/** Projected domain rules only; schemas and authored target checks remain server-owned. */\nexport function inputDomainErrors(\n domain: InputDomainDescriptor,\n value: unknown,\n selection?: InputSelectionDescriptor,\n options: { ignoreMinimum?: boolean } = {},\n): string[] {\n if (selection?.mode === \"many\") {\n if (!Array.isArray(value)) return [\"Expected a list of values.\"];\n const errors = cardinalityErrors(\n value,\n selection.min,\n selection.max,\n \"value\",\n options.ignoreMinimum,\n );\n if (\n selection.distinct &&\n new Set(value.map(inputValueKey)).size !== value.length\n )\n errors.push(\"Choose each value only once.\");\n if (\n value.some(\n (item) =>\n inputDomainErrors(domain, item, undefined, options).length > 0,\n )\n )\n errors.push(ineligibleMessage(domain));\n return errors;\n }\n switch (domain.type) {\n case \"choice\":\n return inputTargetInDomain(domain, value)\n ? []\n : [ineligibleMessage(domain)];\n case \"choiceList\": {\n if (!Array.isArray(value)) return [\"Expected a list of choices.\"];\n const errors = cardinalityErrors(\n value,\n domain.min ?? 0,\n domain.max ?? domain.choices.length,\n \"option\",\n options.ignoreMinimum,\n );\n if (value.some((item) => !inputTargetInDomain(domain, item)))\n errors.push(ineligibleMessage(domain));\n return errors;\n }\n case \"cardTarget\":\n case \"boardTarget\":\n return inputTargetInDomain(domain, value)\n ? []\n : [ineligibleMessage(domain)];\n case \"boundedNumber\":\n return typeof value === \"number\" &&\n value >= domain.min &&\n value <= domain.max &&\n Math.abs(\n (value - domain.min) / (domain.step ?? 1) -\n Math.round((value - domain.min) / (domain.step ?? 1)),\n ) < 1e-9\n ? []\n : [\"Value is outside the current input domain.\"];\n case \"resourceMap\":\n return typeof value === \"object\" &&\n value !== null &&\n !Array.isArray(value) &&\n Object.keys(value).every((key) =>\n domain.resources.some((entry) => entry.resourceId === key),\n ) &&\n domain.resources.every((entry) => {\n const amount =\n (value as Record<string, unknown>)[entry.resourceId] ?? 0;\n return (\n typeof amount === \"number\" &&\n Number.isInteger(amount) &&\n amount >= (entry.min ?? 0) &&\n amount <= (entry.max ?? Infinity)\n );\n })\n ? []\n : [\"Value is outside the current input domain.\"];\n }\n}\n\nexport function inputValueInDomain(\n domain: InputDomainDescriptor,\n value: unknown,\n selection?: InputSelectionDescriptor,\n options: { ignoreMinimum?: boolean } = {},\n): boolean {\n return inputDomainErrors(domain, value, selection, options).length === 0;\n}\n\n/** One selectable option, including an option within a choiceList or many input. */\nexport function inputTargetInDomain(\n domain: InputDomainDescriptor,\n value: unknown,\n): boolean {\n switch (domain.type) {\n case \"choice\":\n case \"choiceList\":\n return domain.choices.some(\n (choice) => !choice.disabled && Object.is(choice.value, value),\n );\n case \"cardTarget\":\n return (\n typeof value === \"string\" && domain.eligibleTargets.includes(value)\n );\n case \"boardTarget\":\n return domain.valueKind === \"player-board-space\"\n ? isPlayerBoardSpaceTarget(value) &&\n domain.eligibleTargets.some((candidate) =>\n samePlayerBoardSpaceTarget(candidate, value),\n )\n : typeof value === \"string\" && domain.eligibleTargets.includes(value);\n default:\n return inputValueInDomain(domain, value);\n }\n}\n\nfunction cardinalityErrors(\n value: readonly unknown[],\n min: number,\n max: number | undefined,\n unit: string,\n ignoreMinimum = false,\n): string[] {\n const errors: string[] = [];\n if (!ignoreMinimum && value.length < min)\n errors.push(`Choose at least ${min} ${pluralize(unit, min)}.`);\n if (max !== undefined && value.length > max)\n errors.push(`Choose at most ${max} ${pluralize(unit, max)}.`);\n return errors;\n}\n\nfunction ineligibleMessage(domain: InputDomainDescriptor): string {\n return domain.type === \"choice\" || domain.type === \"choiceList\"\n ? \"Selected choice is not eligible.\"\n : domain.type === \"cardTarget\" || domain.type === \"boardTarget\"\n ? \"Selected target is not eligible.\"\n : \"Value is outside the current input domain.\";\n}\n\n/** Matches the reducer's JSON value identity for projected distinct selections. */\nexport function inputValueKey(value: unknown): string {\n if (value === null) return \"null\";\n if (isPlayerBoardSpaceTarget(value))\n return `player-board-space:${JSON.stringify([value.boardId, value.playerId, value.spaceId])}`;\n switch (typeof value) {\n case \"string\":\n return `string:${value}`;\n case \"number\":\n case \"boolean\":\n case \"undefined\":\n return `${typeof value}:${String(value)}`;\n default:\n return `json:${JSON.stringify(value)}`;\n }\n}\n\nfunction pluralize(word: string, count: number): string {\n return count === 1 ? word : `${word}s`;\n}\n"],"mappings":";;;;;;;AACO,SAAS,cACd,OACA,MACA,IACG;AACH,MAAI,UAAU,OAAW,OAAM,IAAI,MAAM,GAAG,IAAI,KAAK,EAAE,mBAAmB;AAC1E,SAAO;AACT;;;ACRA,SAAS,SAAS;AAaX,IAAM,+BAA+B,EAAE,aAAa;AAAA,EACzD,SAAS,EAAE,OAAO;AAAA,EAClB,UAAU,EAAE,OAAO;AAAA,EACnB,SAAS,EAAE,OAAO;AACpB,CAAC;AAEM,SAAS,yBACd,OACiC;AACjC,SACE,OAAO,UAAU,YACjB,UAAU,QACV,OAAO,KAAK,KAAK,EAAE,WAAW,KAC9B,aAAa,SACb,OAAO,MAAM,YAAY,YACzB,cAAc,SACd,OAAO,MAAM,aAAa,YAC1B,aAAa,SACb,OAAO,MAAM,Y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