@dreamboard-games/sdk 0.5.0-alpha.2 → 0.5.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.
Files changed (150) hide show
  1. package/README.md +136 -45
  2. package/dist/chunk-DMFVAZI2.js +16 -0
  3. package/dist/chunk-DMFVAZI2.js.map +1 -0
  4. package/dist/chunk-FMM5LVJW.js +833 -0
  5. package/dist/chunk-FMM5LVJW.js.map +1 -0
  6. package/dist/{chunk-S2JEDVWH.js → chunk-LRILEVKC.js} +6113 -6489
  7. package/dist/chunk-LRILEVKC.js.map +1 -0
  8. package/dist/chunk-SP234IY4.js +1363 -0
  9. package/dist/chunk-SP234IY4.js.map +1 -0
  10. package/dist/chunk-VUWNJXLJ.js +52 -0
  11. package/dist/chunk-VUWNJXLJ.js.map +1 -0
  12. package/dist/chunk-ZPRKWPEP.js +511 -0
  13. package/dist/chunk-ZPRKWPEP.js.map +1 -0
  14. package/dist/definition-BaHNPZol.d.ts +4639 -0
  15. package/dist/diagnostics-B0lgnuZ6.d.ts +65 -0
  16. package/dist/index.d.ts +3553 -1
  17. package/dist/index.js +1045 -6
  18. package/dist/index.js.map +1 -1
  19. package/dist/model-BHro6yXu.d.ts +288 -0
  20. package/dist/react.d.ts +32 -0
  21. package/dist/react.js +80 -0
  22. package/dist/react.js.map +1 -0
  23. package/dist/reducer.d.ts +1194 -79
  24. package/dist/reducer.js +4326 -121
  25. package/dist/reducer.js.map +1 -1
  26. package/dist/testing.d.ts +518 -564
  27. package/dist/testing.js +2448 -915
  28. package/dist/testing.js.map +1 -1
  29. package/dist/types-DimqnJBq.d.ts +86 -0
  30. package/package.json +26 -131
  31. package/dist/HandView-Bi2lxzQP.d.ts +0 -79
  32. package/dist/ResourceCounter-BFxJknqp.d.ts +0 -98
  33. package/dist/ThemeProvider-CElaL2ik.d.ts +0 -99
  34. package/dist/attributes-DbvyMbXw.d.ts +0 -68
  35. package/dist/browser-interaction.d.ts +0 -910
  36. package/dist/browser-interaction.js +0 -119
  37. package/dist/browser-interaction.js.map +0 -1
  38. package/dist/chunk-32PFKDV7.js +0 -11705
  39. package/dist/chunk-32PFKDV7.js.map +0 -1
  40. package/dist/chunk-3BAD4VC2.js +0 -263
  41. package/dist/chunk-3BAD4VC2.js.map +0 -1
  42. package/dist/chunk-3SKDNDPG.js +0 -104
  43. package/dist/chunk-3SKDNDPG.js.map +0 -1
  44. package/dist/chunk-5YV2WHJ4.js +0 -25
  45. package/dist/chunk-5YV2WHJ4.js.map +0 -1
  46. package/dist/chunk-ANRB4XKA.js +0 -90
  47. package/dist/chunk-ANRB4XKA.js.map +0 -1
  48. package/dist/chunk-BI4G3PM2.js +0 -1864
  49. package/dist/chunk-BI4G3PM2.js.map +0 -1
  50. package/dist/chunk-EVCLTY4Q.js +0 -935
  51. package/dist/chunk-EVCLTY4Q.js.map +0 -1
  52. package/dist/chunk-GDPKTBUR.js +0 -564
  53. package/dist/chunk-GDPKTBUR.js.map +0 -1
  54. package/dist/chunk-H6VDGFL5.js +0 -2903
  55. package/dist/chunk-H6VDGFL5.js.map +0 -1
  56. package/dist/chunk-LR3ZTWQF.js +0 -5960
  57. package/dist/chunk-LR3ZTWQF.js.map +0 -1
  58. package/dist/chunk-PF7L4BMG.js +0 -117
  59. package/dist/chunk-PF7L4BMG.js.map +0 -1
  60. package/dist/chunk-PN5O6GG2.js +0 -32
  61. package/dist/chunk-PN5O6GG2.js.map +0 -1
  62. package/dist/chunk-PZ5AY32C.js +0 -10
  63. package/dist/chunk-PZ5AY32C.js.map +0 -1
  64. package/dist/chunk-S2JEDVWH.js.map +0 -1
  65. package/dist/chunk-T3ZKNUZ7.js +0 -1
  66. package/dist/chunk-T3ZKNUZ7.js.map +0 -1
  67. package/dist/chunk-UGH54WZ2.js +0 -223
  68. package/dist/chunk-UGH54WZ2.js.map +0 -1
  69. package/dist/chunk-VCDWP5VL.js +0 -746
  70. package/dist/chunk-VCDWP5VL.js.map +0 -1
  71. package/dist/chunk-VDXOF4FW.js +0 -69
  72. package/dist/chunk-VDXOF4FW.js.map +0 -1
  73. package/dist/chunk-WHR5UW3F.js +0 -1988
  74. package/dist/chunk-WHR5UW3F.js.map +0 -1
  75. package/dist/chunk-Y75CFE77.js +0 -17
  76. package/dist/chunk-Y75CFE77.js.map +0 -1
  77. package/dist/chunk-Z7QCREWI.js +0 -3435
  78. package/dist/chunk-Z7QCREWI.js.map +0 -1
  79. package/dist/chunk-ZZGN2ATS.js +0 -1941
  80. package/dist/chunk-ZZGN2ATS.js.map +0 -1
  81. package/dist/components-gAbIz7hK.d.ts +0 -1284
  82. package/dist/definitions-BgmV_GhC.d.ts +0 -300
  83. package/dist/diagnostics-DIi3ina7.d.ts +0 -50
  84. package/dist/digest.d.ts +0 -8
  85. package/dist/game-CsZScpcn.d.ts +0 -763
  86. package/dist/hex-board-view-aKkblDp6.d.ts +0 -1228
  87. package/dist/index-CcT9Q7N7.d.ts +0 -193
  88. package/dist/index.d-DjzoK7zn.d.ts +0 -2101
  89. package/dist/package-set.d.ts +0 -13
  90. package/dist/package-set.js +0 -12
  91. package/dist/package-set.js.map +0 -1
  92. package/dist/player-state-Cqpyeql0.d.ts +0 -371
  93. package/dist/plugin-runtime-contract.d.ts +0 -17
  94. package/dist/plugin-runtime-contract.js +0 -92
  95. package/dist/plugin-runtime-contract.js.map +0 -1
  96. package/dist/primitive-props-BNHDkgd7.d.ts +0 -16
  97. package/dist/protocol-dYgafTYY.d.ts +0 -314
  98. package/dist/reducer/advanced.d.ts +0 -82
  99. package/dist/reducer/advanced.js +0 -51
  100. package/dist/reducer/advanced.js.map +0 -1
  101. package/dist/reducer-contract.d.ts +0 -11
  102. package/dist/reducer-contract.js +0 -16
  103. package/dist/reducer-contract.js.map +0 -1
  104. package/dist/reference-games/index.d.ts +0 -31
  105. package/dist/reference-games/index.js +0 -48
  106. package/dist/reference-games/index.js.map +0 -1
  107. package/dist/runtime/primitives.d.ts +0 -250
  108. package/dist/runtime/primitives.js +0 -189
  109. package/dist/runtime/primitives.js.map +0 -1
  110. package/dist/runtime/runtime-api.d.ts +0 -2
  111. package/dist/runtime/runtime-api.js +0 -1
  112. package/dist/runtime/runtime-api.js.map +0 -1
  113. package/dist/runtime/workspace-contract.d.ts +0 -392
  114. package/dist/runtime/workspace-contract.js +0 -28
  115. package/dist/runtime/workspace-contract.js.map +0 -1
  116. package/dist/runtime-RJ5orDJU.d.ts +0 -1699
  117. package/dist/runtime-api-Bz5pwNU_.d.ts +0 -296
  118. package/dist/runtime-json-CQ9QbLZ5.d.ts +0 -5
  119. package/dist/runtime.d.ts +0 -83
  120. package/dist/runtime.js +0 -242
  121. package/dist/runtime.js.map +0 -1
  122. package/dist/schema.d.ts +0 -379
  123. package/dist/stale-contract-artifact-error-XLaweZtF.d.ts +0 -18
  124. package/dist/testing-compiler.d.ts +0 -37
  125. package/dist/testing-compiler.js +0 -272
  126. package/dist/testing-compiler.js.map +0 -1
  127. package/dist/testing-runtime.d.ts +0 -119
  128. package/dist/testing-runtime.js +0 -212
  129. package/dist/testing-runtime.js.map +0 -1
  130. package/dist/types-DJj5MJkl.d.ts +0 -256
  131. package/dist/types-DR7DoB1x.d.ts +0 -28
  132. package/dist/types-JWCYHmu7.d.ts +0 -122
  133. package/dist/types.d.ts +0 -1958
  134. package/dist/types.js +0 -14
  135. package/dist/types.js.map +0 -1
  136. package/dist/ui/components.d.ts +0 -17
  137. package/dist/ui/components.js +0 -216
  138. package/dist/ui/components.js.map +0 -1
  139. package/dist/ui/defaults.d.ts +0 -19
  140. package/dist/ui/defaults.js +0 -104
  141. package/dist/ui/defaults.js.map +0 -1
  142. package/dist/ui/player-state.d.ts +0 -2
  143. package/dist/ui/player-state.js +0 -1
  144. package/dist/ui/player-state.js.map +0 -1
  145. package/dist/ui/plugin-styles.css +0 -2
  146. package/dist/ui-contract-GTUPkf8z.d.ts +0 -1168
  147. package/dist/ui.d.ts +0 -317
  148. package/dist/ui.js +0 -277
  149. package/dist/ui.js.map +0 -1
  150. package/dist/views-BpuWcOyN.d.ts +0 -1641
package/dist/reducer.d.ts CHANGED
@@ -1,19 +1,238 @@
1
- import { c2 as SchemaLike, a as AnySchema, cH as SystemActionEvent, bW as RuntimeTableRecord, cL as TableQueriesOfState, cK as TableQueries, e as BoardIdOfTable, c as BoardContainerIdOfTable, aF as PlayerIdOfState } from './runtime-RJ5orDJU.js';
2
- export { h as BoardRef, R as FrameworkErrorCodes, S as GameEvent, T as GameEventDetail, U as GameOutcome, ak as OutcomeResult, al as OutcomeScoreComponent, am as OutcomeStanding, an as OutcomeTieBreak, ao as PerPlayer, ap as PerPlayerBoardRef, aq as PerPlayerSchemaOptions, aD as PlayerId, aO as ReducerAccept, aU as ReducerReject, aV as ReducerResult, aY as ReducerValidationResult, cl as SharedBoardRef, cZ as asPlayerId, c$ as boardRef, d0 as boardRefKey, d1 as boardRefSchema, d7 as isPerPlayer, d8 as isPerPlayerBoardRef, d9 as isPlayerId, da as isSharedBoardRef, dd as parseBoardRefKey, de as perPlayer, df as perPlayerBoardRef, dg as perPlayerEntries, dh as perPlayerGet, di as perPlayerHas, dj as perPlayerKeys, dk as perPlayerMap, dl as perPlayerRequire, dm as perPlayerSchema, dn as perPlayerSet, dp as perPlayerSize, dq as perPlayerValues, ds as sharedBoardRef } from './runtime-RJ5orDJU.js';
3
- import { y as CollectorState, Z as InputCollector, a4 as InputSelectionDescriptor, z as ContinuationCallable, T as EffectRollDieDefinition, U as EffectShuffleDefinition, V as EffectShufflePlayerZoneDefinition, aH as ReducerGameContractLike, au as PhaseMapOf, bc as ViewMapOf, aI as ReducerGameDefinition } from './views-BpuWcOyN.js';
4
- export { J as DerivedDefinition, K as DerivedResolver, ad as InteractionRule, an as Op, aJ as ReducerOps, aL as ReducerStateBase, aN as ReducerTransaction, aO as ReducerTransactionOutcome, aX as RotatePlayerZoneArgs, ba as ValidationIssue, bh as createDerivedResolver, bi as createReducerOps, bj as defineDerived, bk as pipe } from './views-BpuWcOyN.js';
5
- import { o as TargetPredicate, A as AnyReducerGameContract, i as ContractState, h as ContractManifest, a as AuthoredManifest, g as CompiledManifest } from './game-CsZScpcn.js';
6
- export { B as BoardTargetPredicate, b as BoundInputBuilders, c as BoundTargetPredicate, d as BoundViewBuilders, C as ChoiceOptionsFactory, e as ChoiceTargetOption, f as ChoiceTargetPredicate, j as ContractTypes, D as DefinedInputs, k as DependencyValues, G as GameAuthoring, I as InputFieldRef, M as ManifestIdsOf, l as ManifestTable, P as PhaseAuthoring, m as PhaseTypes, n as PlayerBoardSpaceTarget, T as TargetContext, p as TargetPredicateArgs, q as createGame, s as defineInputs } from './game-CsZScpcn.js';
1
+ import { Y as ManifestIdSchema, aF as SchemaLike, h as CollectorState, t as InputCollector, a8 as PlayerIdOfState, aO as TableQueriesOfState, x as InputSelectionDescriptor, ah as ReducerManifestContractLike, aC as RuntimeTableRecord, az as RuntimeRecord$1, aK as StateDefinition, X as ManifestContractOf, B as BaseGameStateOfContract, E as ErrorCodeOfContract, aS as TiledVertexIdOfTable, aM as TableOfManifest, aP as TiledBoardIdOfTable, aQ as TiledEdgeIdOfTable, aR as TiledSpaceIdOfTable, C as CardIdOfManifest, _ as OptionsOfContract, al as ReducerTransaction, aV as ViewData, aW as ViewDefinition, a4 as PhaseMapOf, aX as ViewOfContract, af as ReducerGameDefinition, a5 as PhaseNameOfContract, V as InteractionSteps, aG as ScopedPhaseState, T as InteractionSpec, S as InteractionRule, R as InteractionMap, a3 as PhaseDefinition, a7 as PhaseSchemasOfContract, p as GameTopologyManifest$2, D as DieTypeSpec$2, f as Brand, ag as ReducerManifestContract, at as RuntimeHexBoardState, Z as ObjectSchema, aa as PropertySchema, ax as RuntimePayload, H as HexEdgeId, r as HexVertexId, q as HexSpaceId, aA as RuntimeSquareBoardState, as as RuntimeGenericBoardState, ap as RuntimeBoardState, aq as RuntimeCardData, ay as RuntimePieceData, ar as RuntimeDieData, ad as ReducerGameContract, aL as SystemActionEvent, aN as TableQueries, ae as ReducerGameContractLike, c as BoardIdOfTable, a as BoardContainerIdOfTable, b as BoardEdgeRef, e as BoardVertexRef, W as JsonValue } from './definition-BaHNPZol.js';
2
+ export { F as FrameworkErrorCodes, G as GameEvent, k as GameEventDetail, m as GameOutcome, $ as OutcomeResult, a0 as OutcomeScoreComponent, a1 as OutcomeStanding, a2 as OutcomeTieBreak, ab as ReducerAccept, ai as ReducerReject, aj as ReducerResult, am as ReducerTransactionOutcome, an as ReducerValidationResult, b2 as ReducerWire, b1 as ReducerWireZod, ao as RotatePlayerZoneArgs, aJ as SquareBoardSpec, aT as ValidationIssue, aZ as fromCoordinates, a_ as hexagon, a$ as rectangle, b0 as ring, b3 as spiral } from './definition-BaHNPZol.js';
7
3
  import { z } from 'zod';
8
- import { a as ReducerBundleContract } from './index.d-DjzoK7zn.js';
9
- import { a as ReducerDiagnosticsSink } from './diagnostics-DIi3ina7.js';
10
- export { D as DispatchTraceSummaryEntry, R as ReducerDiagnosticEvent, n as noopDiagnosticsSink } from './diagnostics-DIi3ina7.js';
11
- export { S as StaleContractArtifactError, a as StaleContractArtifactErrorOptions, b as StaleContractArtifactKind, i as isStaleContractArtifactError } from './stale-contract-artifact-error-XLaweZtF.js';
12
- import './types.js';
13
- import './protocol-dYgafTYY.js';
4
+ import { a as ReducerBundleContract, c as ReducerDiagnosticsSink } from './diagnostics-B0lgnuZ6.js';
5
+ export { D as DispatchTraceSummaryEntry, M as MaybePromise, R as REDUCER_CONTRACT_VERSION, b as ReducerDiagnosticEvent, d as assertReducerBundleContract, n as noopDiagnosticsSink } from './diagnostics-B0lgnuZ6.js';
6
+ import 'honeycomb-grid';
7
+
8
+ type DomainContext<State extends CollectorState> = {
9
+ state: State;
10
+ playerId: PlayerIdOfState<State>;
11
+ q: TableQueriesOfState<State>;
12
+ };
13
+ type ManifestFormInputSchema = ManifestIdSchema<unknown> | z.ZodOptional<ManifestIdSchema<unknown>> | z.ZodNullable<ManifestIdSchema<unknown>>;
14
+ type DomainNumber<State extends CollectorState> = number | ((context: DomainContext<State>) => number);
15
+ type ResourceMapInputOptions<State extends CollectorState> = {
16
+ resources: ReadonlyArray<{
17
+ resourceId: string;
18
+ label?: string;
19
+ icon?: string;
20
+ min?: DomainNumber<State>;
21
+ max: DomainNumber<State>;
22
+ }>;
23
+ };
24
+ type ChoiceValue = string | null;
25
+ type DomainChoice<Value extends ChoiceValue> = {
26
+ value: Value;
27
+ label: string;
28
+ icon?: string;
29
+ badge?: string;
30
+ description?: string;
31
+ disabled?: boolean;
32
+ disabledReason?: string;
33
+ };
34
+ type DomainChoicePresentation = {
35
+ badge?: string;
36
+ description?: string;
37
+ disabled?: boolean;
38
+ disabledReason?: string;
39
+ };
40
+ type ResourceMapChoiceDecorator<State extends CollectorState> = (context: DomainContext<State> & {
41
+ resourceId: string;
42
+ label: string;
43
+ icon?: string;
44
+ }) => DomainChoicePresentation | null | undefined;
45
+ type ResourceMapChoiceSource<State extends CollectorState> = "resourceMap" | {
46
+ source: "resourceMap";
47
+ decorate?: ResourceMapChoiceDecorator<State>;
48
+ };
49
+ type DomainChoices<Value extends ChoiceValue, State extends CollectorState> = ReadonlyArray<DomainChoice<Value>> | ResourceMapChoiceSource<State> | ((context: DomainContext<State>) => ReadonlyArray<DomainChoice<Value>>);
50
+ type ChoiceListDefaultValue<Value extends string, State extends CollectorState> = Value[] | "all" | ((context: DomainContext<State> & {
51
+ choices: ReadonlyArray<DomainChoice<Value>>;
52
+ }) => Value[]);
53
+ type ChoiceDefaultResolver<Value extends ChoiceValue, State extends CollectorState> = (context: DomainContext<State> & {
54
+ choices: ReadonlyArray<DomainChoice<Value>>;
55
+ }) => Value | undefined;
56
+ declare function baseFormInput<Schema extends ManifestFormInputSchema & SchemaLike<unknown>, State extends CollectorState = CollectorState>(schema: Schema): InputCollector<Schema, State, "form">;
57
+ declare function baseFormInput<Schema extends ManifestFormInputSchema & SchemaLike<unknown>, State extends CollectorState = CollectorState>(schema: Schema, options: {
58
+ defaultValue: z.infer<Schema>;
59
+ }): InputCollector<Schema, State, "form"> & {
60
+ readonly defaultValue: z.infer<Schema>;
61
+ };
62
+ declare function resourceMapInput<State extends CollectorState = CollectorState>(options: ResourceMapInputOptions<State>): InputCollector<z.ZodRecord<z.ZodString, z.ZodNumber>, State, "form">;
63
+ declare function resourceMapInput<State extends CollectorState = CollectorState>(options: ResourceMapInputOptions<State> & {
64
+ defaultValue: Record<string, number>;
65
+ }): InputCollector<z.ZodRecord<z.ZodString, z.ZodNumber>, State, "form"> & {
66
+ readonly defaultValue: Record<string, number>;
67
+ };
68
+ declare function numberInput<State extends CollectorState = CollectorState>(options: {
69
+ min: DomainNumber<State>;
70
+ max: DomainNumber<State>;
71
+ step?: DomainNumber<State>;
72
+ }): InputCollector<z.ZodNumber, State, "form">;
73
+ declare function numberInput<State extends CollectorState = CollectorState>(options: {
74
+ min: DomainNumber<State>;
75
+ max: DomainNumber<State>;
76
+ step?: DomainNumber<State>;
77
+ defaultValue: number;
78
+ }): InputCollector<z.ZodNumber, State, "form"> & {
79
+ readonly defaultValue: number;
80
+ };
81
+ declare function choiceInput<Value extends ChoiceValue, State extends CollectorState = CollectorState>(options: {
82
+ choices: DomainChoices<Value, State>;
83
+ defaultValue: Value;
84
+ }): InputCollector<SchemaLike<Value>, State, "form"> & {
85
+ readonly defaultValue: Value;
86
+ };
87
+ declare function choiceInput<Value extends ChoiceValue, State extends CollectorState = CollectorState>(options: {
88
+ choices: DomainChoices<Value, State>;
89
+ defaultValue: ChoiceDefaultResolver<Value, State>;
90
+ }): InputCollector<SchemaLike<Value>, State, "form">;
91
+ declare function choiceListInput<Value extends string, State extends CollectorState = CollectorState>(options: {
92
+ choices: DomainChoices<Value, State>;
93
+ min?: DomainNumber<State>;
94
+ max?: DomainNumber<State>;
95
+ defaultValue: Value[];
96
+ }): InputCollector<SchemaLike<Value[]>, State, "form"> & {
97
+ readonly defaultValue: Value[];
98
+ };
99
+ declare function choiceListInput<Value extends string, State extends CollectorState = CollectorState>(options: {
100
+ choices: DomainChoices<Value, State>;
101
+ min?: DomainNumber<State>;
102
+ max?: DomainNumber<State>;
103
+ defaultValue?: ChoiceListDefaultValue<Value, State>;
104
+ }): InputCollector<SchemaLike<Value[]>, State, "form">;
105
+ type FormInputForState<State extends CollectorState> = {
106
+ <Schema extends ManifestFormInputSchema & SchemaLike<unknown>>(schema: Schema): InputCollector<Schema, State, "form">;
107
+ <Schema extends ManifestFormInputSchema & SchemaLike<unknown>>(schema: Schema, options: {
108
+ defaultValue: z.infer<Schema>;
109
+ }): InputCollector<Schema, State, "form"> & {
110
+ readonly defaultValue: z.infer<Schema>;
111
+ };
112
+ resourceMap(options: ResourceMapInputOptions<State>): InputCollector<z.ZodRecord<z.ZodString, z.ZodNumber>, State, "form">;
113
+ resourceMap(options: ResourceMapInputOptions<State> & {
114
+ defaultValue: Record<string, number>;
115
+ }): InputCollector<z.ZodRecord<z.ZodString, z.ZodNumber>, State, "form"> & {
116
+ readonly defaultValue: Record<string, number>;
117
+ };
118
+ resourceChoices(options?: {
119
+ decorate?: ResourceMapChoiceDecorator<State>;
120
+ }): ResourceMapChoiceSource<State>;
121
+ number(options: Parameters<typeof numberInput<State>>[0]): ReturnType<typeof numberInput<State>>;
122
+ choice<Value extends ChoiceValue>(options: {
123
+ choices: DomainChoices<Value, State>;
124
+ defaultValue: Value;
125
+ }): InputCollector<SchemaLike<Value>, State, "form"> & {
126
+ readonly defaultValue: Value;
127
+ };
128
+ choice<Value extends ChoiceValue>(options: {
129
+ choices: DomainChoices<Value, State>;
130
+ defaultValue: ChoiceDefaultResolver<Value, State>;
131
+ }): InputCollector<SchemaLike<Value>, State, "form">;
132
+ choiceList<Value extends string>(options: {
133
+ choices: DomainChoices<Value, State>;
134
+ min?: DomainNumber<State>;
135
+ max?: DomainNumber<State>;
136
+ defaultValue: Value[];
137
+ }): InputCollector<SchemaLike<Value[]>, State, "form"> & {
138
+ readonly defaultValue: Value[];
139
+ };
140
+ choiceList<Value extends string>(options: {
141
+ choices: DomainChoices<Value, State>;
142
+ min?: DomainNumber<State>;
143
+ max?: DomainNumber<State>;
144
+ defaultValue?: ChoiceListDefaultValue<Value, State>;
145
+ }): InputCollector<SchemaLike<Value[]>, State, "form">;
146
+ };
147
+ declare function formInputForState<State extends CollectorState>(): FormInputForState<State>;
148
+ /**
149
+ * Manifest-backed id input. Free-form Zod schemas are intentionally explicit:
150
+ * if the runtime cannot disclose valid values or numeric bounds through a
151
+ * manifest id or domain helper, use a custom interaction surface with an
152
+ * explicit `paramsSchema` instead of the default form renderer.
153
+ */
154
+ declare const formInput: typeof baseFormInput & {
155
+ resourceMap: typeof resourceMapInput;
156
+ resourceChoices: <State extends CollectorState = CollectorState>(options?: {
157
+ decorate?: ResourceMapChoiceDecorator<State>;
158
+ }) => ResourceMapChoiceSource<State>;
159
+ number: typeof numberInput;
160
+ choice: typeof choiceInput;
161
+ choiceList: typeof choiceListInput;
162
+ forState: typeof formInputForState;
163
+ };
164
+
165
+ type TargetContext<State extends CollectorState> = {
166
+ state: State;
167
+ playerId: PlayerIdOfState<State>;
168
+ q: TableQueriesOfState<State>;
169
+ };
170
+ type TargetPredicateArgs<State extends CollectorState, Target> = TargetContext<State> & {
171
+ targetId: Target;
172
+ target: Target;
173
+ };
174
+ type TargetPredicate<State extends CollectorState, Target> = {
175
+ id: string;
176
+ errorCode: string;
177
+ message?: string;
178
+ test: (args: TargetPredicateArgs<State, Target>) => boolean;
179
+ };
180
+
181
+ type BoardTargetPredicate<State extends CollectorState, Target> = TargetPredicate<State, Target>;
182
+ type PlayerBoardSpaceTarget<BoardId extends string, SpaceId extends string, PlayerId extends string> = {
183
+ readonly boardId: BoardId;
184
+ readonly playerId: PlayerId;
185
+ readonly spaceId: SpaceId;
186
+ };
187
+
188
+ type PlayerSpaceInputSchema<BoardId extends string, SpaceId extends string, PlayerId extends string> = z.ZodObject<{
189
+ boardId: z.ZodLiteral<BoardId>;
190
+ playerId: ManifestIdSchema<PlayerId, "playerId">;
191
+ spaceId: z.ZodType<SpaceId>;
192
+ }>;
14
193
 
15
194
  type CardTargetPredicate<State extends CollectorState, Id extends string> = TargetPredicate<State, Id>;
16
195
 
196
+ type ChoiceTargetOption<Id extends string> = {
197
+ id: Id;
198
+ label?: string;
199
+ };
200
+ type ChoiceOptionsFactory<State extends CollectorState, Id extends string> = (state: State, playerId: PlayerIdOfState<State>, q: TableQueriesOfState<State>) => ReadonlyArray<ChoiceTargetOption<Id>>;
201
+ type ChoiceTargetPredicate<State extends CollectorState, Id extends string> = TargetPredicate<State, Id>;
202
+
203
+ /**
204
+ * `rngInput.*` helpers produce collectors whose value is *sampled by the
205
+ * engine on submit* rather than supplied by the client. The schema pins
206
+ * the exact output shape so `ParamsOf<Collectors>` sees precisely typed
207
+ * results.
208
+ *
209
+ * Determinism:
210
+ * Sampling happens inside `submitInteraction` only, never inside
211
+ * reducer validation. This lets clients check a submission without
212
+ * burning RNG state.
213
+ */
214
+ type DieRoll = z.ZodObject<{
215
+ values: z.ZodArray<z.ZodNumber>;
216
+ }>;
217
+ type CoinFlip = z.ZodObject<{
218
+ value: z.ZodEnum<{
219
+ heads: "heads";
220
+ tails: "tails";
221
+ }>;
222
+ }>;
223
+ type RngCollector<Schema extends DieRoll | CoinFlip, State extends CollectorState> = InputCollector<Schema, State, "rng">;
224
+ /**
225
+ * Roll `count` d6s. The submitted value is `{ values: number[] }` with
226
+ * `values.length === count` and each face `1..6`.
227
+ */
228
+ declare function d6<State extends CollectorState = CollectorState>(count?: number): RngCollector<DieRoll, State>;
229
+ /** Flip a coin. The submitted value is `{ value: "heads" | "tails" }`. */
230
+ declare function coin<State extends CollectorState = CollectorState>(): RngCollector<CoinFlip, State>;
231
+ declare const rngInput: {
232
+ d6: typeof d6;
233
+ coin: typeof coin;
234
+ };
235
+
17
236
  type ManyOptions = {
18
237
  count: number;
19
238
  distinct?: boolean;
@@ -43,30 +262,517 @@ type ManyInputCollector<Schema extends SchemaLike<unknown> = SchemaLike<unknown>
43
262
  };
44
263
  declare function many<Collector extends NonRngCollector>(collector: Collector, options: ManyOptions): ManyInputCollector<CollectorSchema<Collector>, CollectorStateOf<Collector>, CollectorKindOf<Collector>> & Pick<Collector, "meta">;
45
264
 
46
- type EffectRollDieInput<Contract extends AnyReducerGameContract, Id extends string, ContextSchema extends AnySchema> = {
47
- type: "rollDie";
48
- id: Id;
49
- context?: ContextSchema;
50
- reduce?: ContinuationCallable<ContextSchema, ContractState<Contract>, ContractManifest<Contract>, Id, "rollDie">["reduce"];
265
+ type AnyReducerGameContract = {
266
+ manifest: ReducerManifestContractLike<RuntimeTableRecord>;
267
+ options: SchemaLike<RuntimeRecord$1>;
268
+ state: StateDefinition<SchemaLike<object>, SchemaLike<object>, SchemaLike<object>>;
51
269
  };
52
- type EffectShuffleInput<Contract extends AnyReducerGameContract, Id extends string, ContextSchema extends AnySchema> = {
53
- type: "shuffleSharedZone";
54
- id: Id;
55
- context?: ContextSchema;
56
- reduce?: ContinuationCallable<ContextSchema, ContractState<Contract>, ContractManifest<Contract>, Id, "shuffleSharedZone">["reduce"];
270
+ type ContractState<Contract extends AnyReducerGameContract> = BaseGameStateOfContract<Contract>;
271
+ type ContractManifest<Contract extends AnyReducerGameContract> = ManifestContractOf<Contract>;
272
+ type ContractErrorCode<Contract extends AnyReducerGameContract> = ErrorCodeOfContract<Contract>;
273
+
274
+ type ContractWithPhases = AnyReducerGameContract & {
275
+ readonly phases: Record<string, SchemaLike<object>>;
57
276
  };
58
- type EffectShufflePlayerZoneInput<Contract extends AnyReducerGameContract, Id extends string, ContextSchema extends AnySchema> = {
59
- type: "shufflePlayerZone";
60
- id: Id;
61
- context?: ContextSchema;
62
- reduce?: ContinuationCallable<ContextSchema, ContractState<Contract>, ContractManifest<Contract>, Id, "shufflePlayerZone">["reduce"];
277
+ type BoundState<Contract extends ContractWithPhases> = ContractState<Contract>;
278
+ type BoundManifest<Contract extends ContractWithPhases> = ContractManifest<Contract>;
279
+ type BoundTable<Contract extends ContractWithPhases> = TableOfManifest<BoundManifest<Contract>>;
280
+ type BoundPhaseState<Contract extends ContractWithPhases, PhaseStateSchema extends SchemaLike<object>> = ScopedPhaseState<BoundState<Contract>, z.infer<PhaseStateSchema>>;
281
+ type BoundFormInputs<Contract extends ContractWithPhases> = ReturnType<typeof formInput.forState<BoundState<Contract>>>;
282
+ /** Board element collector options: the board and the predicates that filter it. */
283
+ type BoundBoardInputOptions<Contract extends ContractWithPhases, Id> = {
284
+ boardId: string;
285
+ where?: BoundWhere<Contract, Id>;
286
+ };
287
+ type BoundBoardInputs<Contract extends ContractWithPhases> = {
288
+ vertex<Id extends string = TiledVertexIdOfTable<BoundTable<Contract>, TiledBoardIdOfTable<BoundTable<Contract>>>>(options: BoundBoardInputOptions<Contract, Id>): InputCollector<z.ZodType<Id>, BoundState<Contract>, "board-vertex">;
289
+ edge<Id extends string = TiledEdgeIdOfTable<BoundTable<Contract>, TiledBoardIdOfTable<BoundTable<Contract>>>>(options: BoundBoardInputOptions<Contract, Id>): InputCollector<z.ZodType<Id>, BoundState<Contract>, "board-edge">;
290
+ tile<Id extends string = string>(options: BoundBoardInputOptions<Contract, Id>): InputCollector<z.ZodType<Id>, BoundState<Contract>, "board-tile">;
291
+ space<Id extends string = TiledSpaceIdOfTable<BoundTable<Contract>, TiledBoardIdOfTable<BoundTable<Contract>>>>(options: BoundBoardInputOptions<Contract, Id>): InputCollector<z.ZodType<Id>, BoundState<Contract>, "board-space">;
292
+ playerSpace<BoardId extends string = string, SpaceId extends string = string, PlayerId extends string = PlayerIdOfState<BoundState<Contract>>>(options: {
293
+ boardId: BoardId;
294
+ where?: BoundWhere<Contract, PlayerBoardSpaceTarget<BoardId, SpaceId, PlayerId>>;
295
+ }): InputCollector<PlayerSpaceInputSchema<BoardId, SpaceId, PlayerId>, BoundState<Contract>, "board-space">;
296
+ };
297
+ /**
298
+ * An eligibility predicate whose `errorCode` is checked against the model's
299
+ * declared error codes. The unbound `TargetPredicate` accepts any string.
300
+ */
301
+ type BoundTargetPredicate<Contract extends ContractWithPhases, Target> = Omit<TargetPredicate<BoundState<Contract>, Target>, "errorCode"> & {
302
+ errorCode: ContractErrorCode<Contract>;
303
+ };
304
+ type BoundWhere<Contract extends ContractWithPhases, Target> = BoundTargetPredicate<Contract, Target> | readonly BoundTargetPredicate<Contract, Target>[];
305
+ type BoundCardCollector<Contract extends ContractWithPhases, Id extends string, ZoneIds extends readonly string[]> = InputCollector<z.ZodType<Id>, BoundState<Contract>, "card"> & {
306
+ readonly meta: {
307
+ readonly zoneId: ZoneIds[number];
308
+ readonly zoneIds: ZoneIds;
309
+ readonly targetKind: "card";
310
+ };
311
+ };
312
+ /**
313
+ * Card collector: the zones to draw candidates from and the predicates that
314
+ * filter them. The target rule is built internally.
315
+ */
316
+ type BoundCardInput<Contract extends ContractWithPhases> = <Id extends string = CardIdOfManifest<BoundManifest<Contract>>, const ZoneIds extends readonly string[] = readonly string[]>(options: {
317
+ from: ZoneIds;
318
+ where?: BoundWhere<Contract, Id>;
319
+ }) => BoundCardCollector<Contract, Id, ZoneIds>;
320
+ type BoundRngInputs<Contract extends ContractWithPhases> = {
321
+ d6(count?: number): ReturnType<typeof rngInput.d6<BoundState<Contract>>>;
322
+ coin(): ReturnType<typeof rngInput.coin<BoundState<Contract>>>;
323
+ };
324
+ type BoundInputBuilders<Contract extends ContractWithPhases> = {
325
+ readonly board: BoundBoardInputs<Contract>;
326
+ readonly card: BoundCardInput<Contract>;
327
+ readonly form: BoundFormInputs<Contract>;
328
+ readonly rng: BoundRngInputs<Contract>;
329
+ };
330
+ type PhaseAuthoring<Contract extends ContractWithPhases, PhaseStateSchema extends SchemaLike<object>> = {
331
+ steps(): InteractionSteps<BoundPhaseState<Contract, PhaseStateSchema>>;
332
+ interaction<Collectors extends Record<string, InputCollector>>(spec: Extract<InteractionSpec<Collectors, BoundPhaseState<Contract, PhaseStateSchema>, BoundManifest<Contract>, ContractErrorCode<Contract>>, {
333
+ steps: unknown;
334
+ }>): Extract<InteractionSpec<Collectors, BoundPhaseState<Contract, PhaseStateSchema>, BoundManifest<Contract>, ContractErrorCode<Contract>>, {
335
+ steps: unknown;
336
+ }>;
337
+ interaction<Collectors extends Record<string, InputCollector>>(spec: Extract<InteractionSpec<Collectors, BoundPhaseState<Contract, PhaseStateSchema>, BoundManifest<Contract>, ContractErrorCode<Contract>>, {
338
+ inputs: unknown;
339
+ }>): Extract<InteractionSpec<Collectors, BoundPhaseState<Contract, PhaseStateSchema>, BoundManifest<Contract>, ContractErrorCode<Contract>>, {
340
+ inputs: unknown;
341
+ }>;
342
+ rule<Collectors extends Record<string, InputCollector> = Record<string, InputCollector>>(rule: InteractionRule<Collectors, BoundPhaseState<Contract, PhaseStateSchema>, BoundManifest<Contract>, ContractErrorCode<Contract>>): InteractionRule<Collectors, BoundPhaseState<Contract, PhaseStateSchema>, BoundManifest<Contract>, ContractErrorCode<Contract>>;
343
+ define<SubmitCollectors extends Record<string, InputCollector> = Record<string, InputCollector>, Interactions extends InteractionMap<BoundPhaseState<Contract, PhaseStateSchema>, BoundManifest<Contract>> = Record<string, never>, const Kind extends "player" | "simultaneousPlayer" | "auto" = "player" | "simultaneousPlayer" | "auto">(definition: Omit<PhaseDefinition<PhaseStateSchema, BoundState<Contract>, BoundManifest<Contract>, SubmitCollectors, Interactions, OptionsOfContract<Contract>, ContractErrorCode<Contract>>, "state"> & {
344
+ kind: Kind;
345
+ }): PhaseDefinition<PhaseStateSchema, BoundState<Contract>, BoundManifest<Contract>, SubmitCollectors, Interactions, OptionsOfContract<Contract>, ContractErrorCode<Contract>> & {
346
+ kind: Kind;
347
+ };
348
+ readonly inputs: BoundInputBuilders<Contract>;
349
+ /** Compile-time only. Reading any member at runtime throws. */
350
+ readonly types: PhaseTypes<Contract, PhaseStateSchema>;
351
+ };
352
+ /**
353
+ * Phantom type carriers for one phase: `typeof playing.types.State` is the
354
+ * phase-scoped game state (`state.phase` narrowed to this phase's schema).
355
+ */
356
+ type PhaseTypes<Contract extends ContractWithPhases, PhaseStateSchema extends SchemaLike<object>> = {
357
+ readonly State: BoundPhaseState<Contract, PhaseStateSchema>;
358
+ readonly PhaseState: z.infer<PhaseStateSchema>;
359
+ readonly Tx: ReducerTransaction<BoundPhaseState<Contract, PhaseStateSchema>, ContractErrorCode<Contract>>;
360
+ };
361
+ /**
362
+ * Phantom type carriers for the whole game. These replace the
363
+ * `GameStateOf<GameContractOf<typeof model>>` chain: a module that has the
364
+ * bound game value can write `typeof game.types.State` and stop there.
365
+ */
366
+ type ContractTypes<Contract extends ContractWithPhases> = {
367
+ readonly Contract: Contract;
368
+ readonly Options: OptionsOfContract<Contract>;
369
+ readonly State: BoundState<Contract>;
370
+ readonly Manifest: BoundManifest<Contract>;
371
+ readonly ErrorCode: ContractErrorCode<Contract>;
372
+ readonly PlayerId: PlayerIdOfState<BoundState<Contract>>;
373
+ readonly Queries: TableQueriesOfState<BoundState<Contract>>;
374
+ readonly Tx: ReducerTransaction<BoundState<Contract>, ContractErrorCode<Contract>>;
375
+ };
376
+ /**
377
+ * Rejects phase keys the model did not declare. `PhaseMapOf<Contract>` already
378
+ * requires every declared phase; this closes the other direction so an extra
379
+ * key fails at `assemble` instead of at runtime.
380
+ */
381
+ type NoUndeclaredPhases<Contract, Definitions> = {
382
+ [Name in Exclude<keyof Definitions, PhaseNameOfContract<Contract>>]: `Phase '${Name & string}' is not declared in model.phases`;
383
+ };
384
+ type GameAuthoring<Contract extends ContractWithPhases> = {
385
+ readonly contract: Contract;
386
+ view<Projection extends ViewData>(view: ViewDefinition<BoundState<Contract>, BoundManifest<Contract>, Projection>): ViewDefinition<BoundState<Contract>, BoundManifest<Contract>, Projection>;
387
+ /** Compile-time only. Reading any member at runtime throws. */
388
+ readonly types: ContractTypes<Contract>;
389
+ /** Assemble the final game definition from phases and the seat view. */
390
+ assemble<Definitions extends PhaseMapOf<Contract>, View extends ViewOfContract<Contract>>(definition: Omit<ReducerGameDefinition<Contract, Definitions, View>, "contract"> & {
391
+ phases: NoUndeclaredPhases<Contract, Definitions>;
392
+ }): ReducerGameDefinition<Contract, Definitions, View>;
393
+ phase<Name extends PhaseNameOfContract<Contract>>(name: Name): PhaseAuthoring<Contract, PhaseSchemasOfContract<Contract>[Name]>;
394
+ };
395
+
396
+ type DieTypeSpec$1 = Omit<DieTypeSpec$2, "sides"> & {
397
+ sides?: DieTypeSpec$2["sides"];
398
+ };
399
+ type GameTopologyManifest$1 = Omit<GameTopologyManifest$2, "dieTypes"> & {
400
+ dieTypes?: Array<DieTypeSpec$1>;
401
+ };
402
+
403
+ /**
404
+ * Opaque brand applied to a runtime player identifier.
405
+ *
406
+ * The reducer owns the branded `PlayerId` identity. Authors
407
+ * obtain `PlayerId` values only through:
408
+ * - `q.player.order()` / `q.player.current()` (reducer queries),
409
+ * - engine-injected interaction and phase callback arguments,
410
+ * - `asPlayerId(raw)` as an explicit escape hatch (e.g. ingress parsing).
411
+ *
412
+ * The brand is a phantom type: at runtime a `PlayerId` is just a string.
413
+ * Do not JSON-serialize the brand marker; it exists purely at the type
414
+ * level to block accidental literal comparisons such as
415
+ * `playerId === "player-1"`.
416
+ */
417
+ type PlayerId$1 = Brand<string, "PlayerId">;
418
+ /**
419
+ * Explicit conversion from a raw string to a branded `PlayerId`.
420
+ *
421
+ * Use at trust boundaries only (wire ingress, tests, fixtures). Inside
422
+ * reducer logic, obtain `PlayerId` values from the engine instead of
423
+ * constructing them yourself.
424
+ */
425
+ declare function asPlayerId(raw: string): PlayerId$1;
426
+ /**
427
+ * Type guard that narrows `unknown` to `PlayerId` when the value is a
428
+ * non-empty string. Does not validate against a specific player roster;
429
+ * use manifest/ingress parsing for that.
430
+ */
431
+ declare function isPlayerId(value: unknown): value is PlayerId$1;
432
+ /**
433
+ * Reference to a board by its authored `baseId`, plus an optional seat
434
+ * for per-player boards.
435
+ *
436
+ * Replaces the old generated `"ring:player-1" | "ring:player-2" | ...`
437
+ * flat unions whose keys pretended to be static but were actually
438
+ * derived from `maxPlayers` and therefore misaligned with the runtime
439
+ * seat list.
440
+ *
441
+ * The discriminant is the *presence* of `seat`, not a `scope` field, so
442
+ * authors can destructure and pass the ref directly without needing a
443
+ * discriminator check for shared boards.
444
+ */
445
+ type BoardRef<BaseId extends string = string, Id extends PlayerId$1 = PlayerId$1> = SharedBoardRef<BaseId> | PerPlayerBoardRef<BaseId, Id>;
446
+ interface SharedBoardRef<BaseId extends string = string> {
447
+ readonly baseId: BaseId;
448
+ readonly seat?: undefined;
449
+ }
450
+ interface PerPlayerBoardRef<BaseId extends string = string, Id extends PlayerId$1 = PlayerId$1> {
451
+ readonly baseId: BaseId;
452
+ readonly seat: Id;
453
+ }
454
+ /** Construct a shared board ref. */
455
+ declare function sharedBoardRef<BaseId extends string>(baseId: BaseId): SharedBoardRef<BaseId>;
456
+ /** Construct a per-player board ref. */
457
+ declare function perPlayerBoardRef<BaseId extends string, Id extends PlayerId$1>(baseId: BaseId, seat: Id): PerPlayerBoardRef<BaseId, Id>;
458
+ /**
459
+ * Construct a `BoardRef` without knowing the scope ahead of time. Pass
460
+ * `seat` for per-player boards; omit for shared boards.
461
+ */
462
+ declare function boardRef<BaseId extends string, Id extends PlayerId$1>(baseId: BaseId, seat?: Id): BoardRef<BaseId, Id>;
463
+ /** Stable string key for Maps/Records keyed by a `BoardRef`. */
464
+ declare function boardRefKey(ref: BoardRef): string;
465
+ /**
466
+ * Inverse of `boardRefKey`. Parses `"base"` as a shared ref and
467
+ * `"base:player-N"` as a per-player ref. Returns `null` for malformed
468
+ * input.
469
+ */
470
+ declare function parseBoardRefKey(key: string): BoardRef | null;
471
+ /**
472
+ * Zod schema for a `BoardRef` with free-form base and seat ids.
473
+ *
474
+ * Feed a manifest-scoped `baseIdSchema` and `playerIdSchema` to bind
475
+ * the ref to a specific workspace.
476
+ */
477
+ declare function boardRefSchema<BaseId extends string = string, Id extends PlayerId$1 = PlayerId$1>(options?: {
478
+ readonly baseIdSchema?: z.ZodType<BaseId>;
479
+ readonly playerIdSchema?: z.ZodType<Id>;
480
+ }): z.ZodType<BoardRef<BaseId, Id>>;
481
+ /** True when `ref` targets a shared board (no seat). */
482
+ declare function isSharedBoardRef<BaseId extends string>(ref: BoardRef<BaseId, PlayerId$1>): ref is SharedBoardRef<BaseId>;
483
+ /** True when `ref` targets a per-player board (has a seat). */
484
+ declare function isPerPlayerBoardRef<BaseId extends string, Id extends PlayerId$1>(ref: BoardRef<BaseId, Id>): ref is PerPlayerBoardRef<BaseId, Id>;
485
+
486
+ type ReadonlyValue<T> = T extends readonly (infer V)[] ? readonly ReadonlyValue<V>[] : T extends object ? {
487
+ readonly [K in keyof T]: ReadonlyValue<T[K]>;
488
+ } : T;
489
+ type AuthoredManifest = ReadonlyValue<GameTopologyManifest$1>;
490
+ type Entry<T> = T extends readonly (infer V)[] ? V : never;
491
+ type Get<T, K extends PropertyKey> = T extends unknown ? K extends keyof T ? T[K] : never : never;
492
+ type Entries<M, K extends PropertyKey> = Entry<Get<M, K>>;
493
+ type Id<T> = T extends {
494
+ id: infer I extends string;
495
+ } ? I : never;
496
+ type NumberRange<N extends number, A extends number[] = []> = number extends N ? number : A["length"] extends 64 ? number : A["length"] extends N ? A[number] | N : NumberRange<N, [...A, A["length"]]>;
497
+ type InstanceIds<Base extends string, Count> = [Count] extends [never] ? Base : Count extends number ? number extends Count ? Base | `${Base}-${number}` : Count extends 0 | 1 ? Base : `${Base}-${Exclude<NumberRange<Count>, 0>}` : Base;
498
+ type SeedIds<S> = S extends {
499
+ typeId: infer T extends string;
500
+ } ? InstanceIds<S extends {
501
+ id: infer I extends string;
502
+ } ? I : T, Get<S, "count">> : never;
503
+ type CardIds<C> = C extends {
504
+ type: infer T extends string;
505
+ } ? InstanceIds<T, Get<C, "count">> : never;
506
+ type StandardSuit = "SPADES" | "HEARTS" | "CLUBS" | "DIAMONDS";
507
+ type StandardRank = "2" | "3" | "4" | "5" | "6" | "7" | "8" | "9" | "10" | "J" | "Q" | "K" | "A";
508
+ type ResolvedCardSet<S> = S extends {
509
+ type: "preset";
510
+ presetId: "standard_52_deck";
511
+ } ? Omit<S, "type"> & {
512
+ type: "manual";
513
+ cards: readonly {
514
+ type: `${StandardSuit}_${StandardRank}`;
515
+ count: 1;
516
+ }[];
517
+ cardSchema: {
518
+ properties: {
519
+ suit: {
520
+ type: "enum";
521
+ enums: readonly StandardSuit[];
522
+ };
523
+ rank: {
524
+ type: "string";
525
+ };
526
+ };
527
+ };
528
+ } : S;
529
+ type CardSets<M> = ResolvedCardSet<Entries<M, "cardSets">>;
530
+ type Cards<M> = CardSets<M> extends infer S ? S extends {
531
+ cards: infer C;
532
+ } ? Entry<C> : never : never;
533
+ type Zone<M, Scope> = Id<Extract<Entries<M, "zones">, {
534
+ scope: Scope;
535
+ }>>;
536
+ type Boards<M> = Entries<M, "boards">;
537
+ type RuntimeBoardId<B> = B extends {
538
+ id: infer I extends string;
539
+ } ? B extends {
540
+ scope: "perPlayer";
541
+ } ? `${I}:${string}` : I : never;
542
+ type CardTypeOf<C> = C extends {
543
+ cardType: infer T extends string;
544
+ } ? T : Extract<Get<C, "type">, string>;
545
+ type ManifestIdsOf<M> = {
546
+ playerId: PlayerId$1;
547
+ phaseName: string;
548
+ boardLayout: "generic" | "hex" | "square";
549
+ cardSetId: Id<Entries<M, "cardSets">>;
550
+ cardType: CardTypeOf<Cards<M>>;
551
+ cardId: CardIds<Cards<M>>;
552
+ deckId: Zone<M, "shared">;
553
+ handId: Zone<M, "perPlayer">;
554
+ sharedZoneId: Zone<M, "shared">;
555
+ playerZoneId: Zone<M, "perPlayer">;
556
+ zoneId: Id<Entries<M, "zones">>;
557
+ resourceId: Id<Entries<M, "resources">>;
558
+ pieceTypeId: Id<Entries<M, "pieceTypes">>;
559
+ pieceId: SeedIds<Entries<M, "pieceSeeds">>;
560
+ dieTypeId: Id<Entries<M, "dieTypes">>;
561
+ dieId: SeedIds<Entries<M, "dieSeeds">>;
562
+ boardTypeId: Extract<Get<Boards<M>, "typeId">, string>;
563
+ boardBaseId: Id<Boards<M>>;
564
+ boardId: RuntimeBoardId<Boards<M>>;
565
+ boardContainerId: Id<Entry<Get<Boards<M>, "containers">>>;
566
+ relationTypeId: Extract<Get<Entry<Get<Boards<M>, "relations">>, "typeId">, string>;
567
+ edgeId: HexEdgeId<Extract<Id<Extract<Boards<M>, {
568
+ layout: "hex";
569
+ }>>, string>> | (Extract<Boards<M>, {
570
+ layout: "square";
571
+ }> extends never ? never : `square-edge:${string}`);
572
+ edgeTypeId: Extract<Get<Entry<Get<Boards<M>, "edges">>, "typeId">, string>;
573
+ vertexId: HexVertexId<Extract<Id<Extract<Boards<M>, {
574
+ layout: "hex";
575
+ }>>, string>> | (Extract<Boards<M>, {
576
+ layout: "square";
577
+ }> extends never ? never : `square-vertex:${string}`);
578
+ vertexTypeId: Extract<Get<Entry<Get<Boards<M>, "vertices">>, "typeId">, string>;
579
+ spaceId: BoardSpaceId<Boards<M>>;
580
+ spaceTypeId: Extract<Get<BoardSpaceEntry<Boards<M>>, "typeId">, string>;
581
+ };
582
+ type PropertyValue<P, M> = PropertySchema extends P ? RuntimePayload : P extends {
583
+ type: infer T;
584
+ } ? T extends keyof ManifestIdsOf<M> ? ManifestIdsOf<M>[T] : T extends "string" ? string : T extends "number" | "integer" ? number : T extends "boolean" ? boolean : T extends "enum" ? Entry<Get<P, "enums">> : T extends "array" ? PropertyOutput<Get<P, "items">, M>[] : T extends "record" ? Record<string, PropertyOutput<Get<P, "values">, M>> : T extends "object" ? ObjectProperties<Get<P, "properties">, M> : never : never;
585
+ type PropertyOutput<P, M> = PropertyValue<P, M> | (P extends {
586
+ nullable: true;
587
+ } ? null : never);
588
+ type OptionalKeys<P> = {
589
+ [K in keyof P]: P[K] extends {
590
+ optional: true;
591
+ } ? P[K] extends {
592
+ default: unknown;
593
+ } ? never : K : never;
594
+ }[keyof P];
595
+ type ObjectProperties<P, M> = {
596
+ [K in Exclude<keyof P, OptionalKeys<P>>]: PropertyOutput<P[K], M>;
597
+ } & {
598
+ [K in OptionalKeys<P>]?: PropertyOutput<P[K], M>;
63
599
  };
64
- declare function defineEffect<Contract extends AnyReducerGameContract>(): {
65
- <Id extends string, ContextSchema extends AnySchema = z.ZodObject<Record<string, never>, z.core.$strip>>(definition: EffectRollDieInput<Contract, Id, ContextSchema>): EffectRollDieDefinition<Id, ContextSchema, ContractState<Contract>, ContractManifest<Contract>>;
66
- <Id extends string, ContextSchema extends AnySchema = z.ZodObject<Record<string, never>, z.core.$strip>>(definition: EffectShuffleInput<Contract, Id, ContextSchema>): EffectShuffleDefinition<Id, ContextSchema, ContractState<Contract>, ContractManifest<Contract>>;
67
- <Id extends string, ContextSchema extends AnySchema = z.ZodObject<Record<string, never>, z.core.$strip>>(definition: EffectShufflePlayerZoneInput<Contract, Id, ContextSchema>): EffectShufflePlayerZoneDefinition<Id, ContextSchema, ContractState<Contract>, ContractManifest<Contract>>;
600
+ type ObjectFields<S, M> = [S] extends [never] ? RuntimeRecord$1 : ObjectSchema extends S ? RuntimeRecord$1 : S extends {
601
+ properties: infer P;
602
+ } ? ObjectProperties<P, M> : RuntimeRecord$1;
603
+ type CardFields<S, M> = S extends {
604
+ variants: infer V;
605
+ } ? ObjectProperties<Get<S, "shared">, M> & ObjectFields<V[keyof V], M> : ObjectFields<S, M>;
606
+ type CardState<M> = CardSets<M> extends infer S ? S extends {
607
+ id: infer I;
608
+ cards: unknown;
609
+ } ? Omit<RuntimeCardData, "id" | "cardSetId" | "cardType" | "properties"> & {
610
+ id: ManifestIdsOf<M>["cardId"];
611
+ cardSetId: I;
612
+ cardType: ManifestIdsOf<M>["cardType"];
613
+ properties: CardFields<Get<S, "cardSchema">, M>;
614
+ } : never : never;
615
+ type BoardField<B, K extends PropertyKey, M> = ObjectFields<Get<B, K>, M>;
616
+ type BoardSpaceEntry<B> = B extends {
617
+ layout: "hex";
618
+ spaces: infer Spaces;
619
+ } ? Spaces[keyof Spaces] : Entry<Get<B, "spaces">>;
620
+ type BoardSpaceId<B> = B extends {
621
+ layout: "hex";
622
+ } ? HexSpaceId<B> : Id<Entry<Get<B, "spaces">>>;
623
+ type BoardParts<M, B> = {
624
+ id: RuntimeBoardId<B>;
625
+ baseId: Id<B>;
626
+ fields: BoardField<B, "boardFieldsSchema", M>;
627
+ relations: (Omit<RuntimeHexBoardState["relations"][number], "typeId"> & {
628
+ typeId: Extract<Get<Entry<Get<B, "relations">>, "typeId">, string> | (B extends {
629
+ layout: "hex" | "square";
630
+ } ? "adjacent" : never);
631
+ })[];
632
+ spaces: Record<BoardSpaceId<B>, (B extends {
633
+ layout: "hex";
634
+ } ? {
635
+ q: number;
636
+ r: number;
637
+ } : B extends {
638
+ layout: "square";
639
+ } ? {
640
+ row: number;
641
+ col: number;
642
+ } : unknown) & {
643
+ id: BoardSpaceId<B>;
644
+ name?: string | null;
645
+ typeId?: Extract<Get<BoardSpaceEntry<B>, "typeId">, string> | null;
646
+ fields: BoardField<B, "spaceFieldsSchema", M>;
647
+ zoneId?: string | null;
648
+ }>;
649
+ };
650
+ type BoardState<M, B> = B extends {
651
+ layout: "hex";
652
+ } ? Omit<RuntimeHexBoardState, "id" | "baseId" | "fields" | "spaces" | "edges" | "vertices" | "relations"> & BoardParts<M, B> & {
653
+ edges: (Omit<RuntimeHexBoardState["edges"][number], "id" | "spaceIds"> & {
654
+ id: HexEdgeId<Extract<Id<B>, string>>;
655
+ spaceIds: BoardSpaceId<B>[];
656
+ })[];
657
+ vertices: (Omit<RuntimeHexBoardState["vertices"][number], "id" | "spaceIds"> & {
658
+ id: HexVertexId<Extract<Id<B>, string>>;
659
+ spaceIds: BoardSpaceId<B>[];
660
+ })[];
661
+ } : B extends {
662
+ layout: "square";
663
+ } ? Omit<RuntimeSquareBoardState, "id" | "baseId" | "fields" | "spaces" | "relations"> & BoardParts<M, B> : Omit<RuntimeGenericBoardState, "id" | "baseId" | "fields" | "spaces" | "relations"> & BoardParts<M, B>;
664
+ type BoardMap<M> = {
665
+ [B in Boards<M> as RuntimeBoardId<B>]: Extract<BoardState<M, B>, RuntimeBoardState>;
666
+ };
667
+ type InferredBoards<M> = {
668
+ byId: BoardMap<M>;
669
+ hex: {
670
+ [B in Extract<Boards<M>, {
671
+ layout: "hex";
672
+ }> as RuntimeBoardId<B>]: Extract<BoardState<M, B>, RuntimeHexBoardState>;
673
+ };
674
+ square: {
675
+ [B in Extract<Boards<M>, {
676
+ layout: "square";
677
+ }> as RuntimeBoardId<B>]: Extract<BoardState<M, B>, RuntimeSquareBoardState>;
678
+ };
679
+ network: Record<string, RuntimeRecord$1>;
680
+ track: Record<string, RuntimeRecord$1>;
681
+ };
682
+ type ManifestTable<M> = AuthoredManifest extends M ? RuntimeTableRecord : Omit<RuntimeTableRecord, "playerOrder" | "decks" | "hands" | "cards" | "pieces" | "dice" | "boards" | "resources"> & {
683
+ boards: InferredBoards<M>;
684
+ playerOrder: PlayerId$1[];
685
+ decks: Record<ManifestIdsOf<M>["deckId"], ManifestIdsOf<M>["cardId"][]>;
686
+ hands: Record<ManifestIdsOf<M>["handId"], Record<PlayerId$1, ManifestIdsOf<M>["cardId"][]>>;
687
+ cards: Record<ManifestIdsOf<M>["cardId"], CardState<M>>;
688
+ pieces: Record<ManifestIdsOf<M>["pieceId"], RuntimePieceData>;
689
+ dice: Record<ManifestIdsOf<M>["dieId"], RuntimeDieData>;
690
+ resources: Record<PlayerId$1, Record<ManifestIdsOf<M>["resourceId"], number>>;
691
+ };
692
+ type CompiledManifest<M extends AuthoredManifest> = Omit<ReducerManifestContract<ManifestTable<M>, string, PlayerId$1, ManifestIdsOf<M>["deckId"], ManifestIdsOf<M>["handId"], ManifestIdsOf<M>["cardId"]>, "ids" | "literals" | "records" | "staticBoards"> & {
693
+ staticBoards: Pick<InferredBoards<M>, "byId" | "hex" | "square">;
694
+ literals: Omit<ReducerManifestContract<RuntimeTableRecord, string, string, string, string, string>["literals"], `${keyof ManifestIdsOf<M>}s`> & {
695
+ [K in keyof ManifestIdsOf<M> as `${K}s`]: readonly ManifestIdsOf<M>[K][];
696
+ };
697
+ records: {
698
+ [K in Exclude<keyof ManifestIdsOf<M>, "playerId"> as `${K}s`]: <V>(initial: V | ((id: ManifestIdsOf<M>[K]) => V)) => Record<ManifestIdsOf<M>[K], V>;
699
+ };
700
+ ids: {
701
+ [K in keyof ManifestIdsOf<M>]: ManifestIdSchema<ManifestIdsOf<M>[K], K>;
702
+ };
703
+ schemas: {
704
+ table: z.ZodType<ManifestTable<M>>;
705
+ runtime: z.ZodTypeAny;
706
+ };
707
+ createInitialTable(options?: {
708
+ playerIds?: readonly string[];
709
+ shuffleItems?: <V>(values: readonly V[]) => V[];
710
+ }): ManifestTable<M>;
711
+ };
712
+
713
+ type ManifestIdSchemasOf<Ids extends Record<string, SchemaLike<unknown>>> = {
714
+ readonly [Key in keyof Ids]: Ids[Key] extends SchemaLike<infer Output> ? Ids[Key] & ManifestIdSchema<Output> : Ids[Key];
68
715
  };
69
716
 
717
+ /**
718
+ * Narrows a manifest's `literals.phaseNames` and `ids.phaseName` to the
719
+ * author-supplied phase-name tuple. Lets `defineGameContract` override the
720
+ * codegen-emitted `phaseNames: readonly string[]` / `phaseName: z.string()`
721
+ * placeholders so `PhaseNameOfContract<Contract>` resolves to a literal
722
+ * union and flows through `tx.transition`, `PhaseMapOf`, and the flow
723
+ * state's `currentPhase`.
724
+ */
725
+ type NarrowManifestPhaseNames<Manifest, PhaseNames extends readonly string[]> = Manifest & {
726
+ literals: Manifest extends {
727
+ literals: infer L;
728
+ } ? Omit<L, "phaseNames"> & {
729
+ phaseNames: PhaseNames;
730
+ } : {
731
+ phaseNames: PhaseNames;
732
+ };
733
+ ids: Manifest extends {
734
+ ids: infer I;
735
+ } ? Omit<I, "phaseName"> & {
736
+ phaseName: z.ZodType<PhaseNames[number]>;
737
+ } : {
738
+ phaseName: z.ZodType<PhaseNames[number]>;
739
+ };
740
+ };
741
+ type ReducerGameContractInput<Table extends RuntimeTableRecord, Manifest extends ReducerManifestContract<Table, string, string, string, string, string>, PublicSchema extends SchemaLike<object>, PrivateSchema extends SchemaLike<object>, HiddenSchema extends SchemaLike<object>, Phases extends Record<string, SchemaLike<object>>, Errors extends Record<string, string> | undefined = undefined, OptionsSchema extends SchemaLike<RuntimeRecord$1> = SchemaLike<Record<string, never>>> = {
742
+ manifest: Manifest;
743
+ state: StateDefinition<PublicSchema, PrivateSchema, HiddenSchema>;
744
+ phases: Phases;
745
+ errors?: Errors;
746
+ options?: OptionsSchema;
747
+ };
748
+ type DefinedGameContract<Table extends RuntimeTableRecord, Manifest extends ReducerManifestContract<Table, string, string, string, string, string>, PublicSchema extends SchemaLike<object>, PrivateSchema extends SchemaLike<object>, HiddenSchema extends SchemaLike<object>, Phases extends Record<string, SchemaLike<object>>, Errors extends Record<string, string> | undefined = undefined, OptionsSchema extends SchemaLike<RuntimeRecord$1> = SchemaLike<Record<string, never>>> = ReducerGameContract<Table, NarrowManifestPhaseNames<Manifest, readonly (keyof Phases & string)[]>, PublicSchema, PrivateSchema, HiddenSchema, Phases, Errors, OptionsSchema> & {
749
+ readonly phases: Phases;
750
+ readonly errors: Errors;
751
+ readonly phaseNames: readonly (keyof Phases & string)[];
752
+ readonly schemas: ManifestIdSchemasOf<NarrowManifestPhaseNames<Manifest, readonly (keyof Phases & string)[]>["ids"]>;
753
+ };
754
+
755
+ /**
756
+ * Creates the bound authoring object for a model without assembling the game.
757
+ *
758
+ * The returned value is the type leaf (`typeof game.types.State`), the factory namespace
759
+ * (`game.phase(name)`, `game.view`), and the assembler (`game.assemble`).
760
+ * Phase files import it directly, so no factory wrappers or `*AuthoringOf`
761
+ * parameter types are needed.
762
+ */
763
+ declare function createGame<const Manifest extends AuthoredManifest, PublicSchema extends SchemaLike<object>, PrivateSchema extends SchemaLike<object>, HiddenSchema extends SchemaLike<object>, const Phases extends Record<string, SchemaLike<object>>, const Errors extends Record<string, string> | undefined = undefined, OptionsSchema extends SchemaLike<RuntimeRecord$1> = SchemaLike<Record<string, never>>>(model: {
764
+ manifest: Manifest;
765
+ state: {
766
+ public: PublicSchema;
767
+ private: PrivateSchema;
768
+ hidden: HiddenSchema;
769
+ };
770
+ phases: Phases;
771
+ errors?: Errors;
772
+ options?: OptionsSchema;
773
+ }): GameAuthoring<DefinedGameContract<ManifestTable<Manifest>, CompiledManifest<Manifest>, PublicSchema, PrivateSchema, HiddenSchema, Phases, Errors, OptionsSchema>>;
774
+ declare function createGame<Table extends RuntimeTableRecord, const Manifest extends ReducerManifestContract<Table, string, string, string, string, string>, PublicSchema extends SchemaLike<object>, PrivateSchema extends SchemaLike<object>, HiddenSchema extends SchemaLike<object>, const Phases extends Record<string, SchemaLike<object>>, const Errors extends Record<string, string> | undefined = undefined, OptionsSchema extends SchemaLike<RuntimeRecord$1> = SchemaLike<Record<string, never>>>(model: ReducerGameContractInput<Table, Manifest, PublicSchema, PrivateSchema, HiddenSchema, Phases, Errors, OptionsSchema>): GameAuthoring<DefinedGameContract<Table, Manifest, PublicSchema, PrivateSchema, HiddenSchema, Phases, Errors, OptionsSchema>>;
775
+
70
776
  declare const gameEvent: {
71
777
  systemAction(event: Omit<SystemActionEvent, "kind">): SystemActionEvent;
72
778
  };
@@ -85,63 +791,472 @@ declare function createStateQueries<State extends {
85
791
  type InteractionDiagnosticsMode = "verbose" | undefined;
86
792
 
87
793
  type ReducerBundleOptions = {
88
- /**
89
- * Host-owned reducer diagnostics sink. Events are summarized and must not
90
- * contain reducer state.
91
- *
92
- * The legacy `"verbose"` value is retained as an additive alias for
93
- * descriptorDiagnostics while existing callers migrate.
94
- */
95
794
  diagnostics?: ReducerDiagnosticsSink | InteractionDiagnosticsMode;
96
795
  descriptorDiagnostics?: InteractionDiagnosticsMode;
97
796
  };
98
797
  type ReducerBundle = ReducerBundleContract;
99
798
 
100
- /** The complete runner boundary. Authoring inspection stays SDK-owned. */
101
- declare function createReducerBundle<Contract extends ReducerGameContractLike, Definitions extends PhaseMapOf<Contract>, Views extends ViewMapOf<Contract>>(definition: ReducerGameDefinition<Contract, Definitions, Views>, options?: ReducerBundleOptions): ReducerBundle;
799
+ /** The single validated production execution and projection boundary. */
800
+ declare function createReducerBundle<Contract extends ReducerGameContractLike, Definitions extends PhaseMapOf<Contract>, View extends ViewOfContract<Contract>>(definition: ReducerGameDefinition<Contract, Definitions, View>, options?: ReducerBundleOptions): ReducerBundle;
102
801
 
103
- type FingerprintableContract = ReducerGameContractLike & {
104
- phases?: Record<string, z.ZodTypeAny>;
105
- errors?: Record<string, string> | undefined;
106
- };
107
- type FingerprintableDefinition = {
108
- contract: FingerprintableContract;
109
- phases?: Record<string, z.ZodTypeAny | {
110
- state?: z.ZodTypeAny;
111
- }>;
112
- };
113
- type ContractFingerprint = {
114
- /** "cfp1:" + first 16 hex chars of sha256 over the canonical payload. */
115
- value: string;
116
- /** Component hashes that fed the final fingerprint. */
117
- parts: {
118
- manifest: string;
119
- publicState: string;
120
- privateState: string;
121
- hiddenState: string;
122
- phases: Record<string, string>;
123
- errors: string;
124
- };
125
- };
126
- /**
127
- * Compute a stable shape fingerprint for stale generated artifacts.
128
- *
129
- * The fingerprint intentionally tracks decoded shape, not semantic refinements:
130
- * Zod schemas are converted with `unrepresentable: "any"`, so refinements and
131
- * custom validators that do not affect the JSON shape do not invalidate stored
132
- * sessions or generated base states.
133
- */
134
- declare function contractFingerprint(source: FingerprintableContract | FingerprintableDefinition): ContractFingerprint;
802
+ /** Cache a pure calculation by immutable object identity. Do not pass a mutable draft. */
803
+ declare function memoize<A extends object, R>(fn: (a: A) => R): (a: A) => R;
135
804
 
136
805
  declare function assertCardAllowedInContainer<Table extends RuntimeTableRecord, BoardId extends BoardIdOfTable<NoInfer<Table>>, ContainerId extends BoardContainerIdOfTable<NoInfer<Table>, BoardId>>(table: Table, boardId: BoardId, containerId: ContainerId, componentId: string): void;
137
806
 
138
- declare function setActivePlayers<State extends {
139
- flow: {
140
- activePlayers: PlayerIdOfState<State>[];
141
- };
142
- }>(state: State, activePlayers: PlayerIdOfState<State>[]): State;
143
-
144
807
  /** Compile authored topology once, in memory, with the same validation used by initialization. */
145
808
  declare function compileManifest<const M extends AuthoredManifest>(manifest: M): CompiledManifest<M>;
146
809
 
147
- export { AuthoredManifest, type CardTargetPredicate, CompiledManifest, type ContractFingerprint, type ManyOptions, type ReducerBundle, type ReducerBundleOptions, ReducerDiagnosticsSink, ReducerGameDefinition, type SparseCounts, type SparseMap, SystemActionEvent, TableQueries, TableQueriesOfState, TargetPredicate, assertCardAllowedInContainer, compileManifest, contractFingerprint, createReducerBundle, createStateQueries, createTableQueries, defineEffect, gameEvent, many, normalizeCommandParams, setActivePlayers, sparseCounts, sparseMap };
810
+ declare function materializeManifestTable(options: {
811
+ manifest: GameTopologyManifest$1;
812
+ playerIds: readonly string[];
813
+ shuffleItems: <Value>(values: readonly Value[]) => Value[];
814
+ }): Record<string, unknown>;
815
+
816
+ type DieTypeSpec = Omit<DieTypeSpec$2, "sides"> & {
817
+ sides?: DieTypeSpec$2["sides"];
818
+ };
819
+ type DeepReadonly<T> = T extends (...args: readonly unknown[]) => unknown ? T : T extends readonly (infer Item)[] ? ReadonlyArray<DeepReadonly<Item>> : T extends object ? {
820
+ readonly [Key in keyof T]: DeepReadonly<T[Key]>;
821
+ } : T;
822
+ type GameTopologyManifest = DeepReadonly<Omit<GameTopologyManifest$2, "dieTypes"> & {
823
+ dieTypes?: readonly DieTypeSpec[];
824
+ }>;
825
+ type ArrayItem<T> = T extends readonly (infer Item)[] ? Item : never;
826
+ type EntryId<T> = T extends {
827
+ id: infer Id extends string;
828
+ } ? Id : never;
829
+ type IdsOf<T> = EntryId<ArrayItem<NonNullable<T>>>;
830
+ type RuntimeRecord = Record<string, JsonValue>;
831
+ type CardSetId<Manifest extends GameTopologyManifest> = IdsOf<Manifest["cardSets"]>;
832
+ type ZoneId<Manifest extends GameTopologyManifest> = IdsOf<Manifest["zones"]>;
833
+ type BoardId<Manifest extends GameTopologyManifest> = IdsOf<Manifest["boards"]>;
834
+ type PerPlayerZoneId<Manifest extends GameTopologyManifest> = EntryId<Extract<ArrayItem<NonNullable<Manifest["zones"]>>, {
835
+ scope: "perPlayer";
836
+ }>>;
837
+ type SharedZoneId<Manifest extends GameTopologyManifest> = Exclude<ZoneId<Manifest>, PerPlayerZoneId<Manifest>>;
838
+ type PerPlayerBoardId<Manifest extends GameTopologyManifest> = EntryId<Extract<ArrayItem<NonNullable<Manifest["boards"]>>, {
839
+ scope: "perPlayer";
840
+ }>>;
841
+ type SharedBoardId<Manifest extends GameTopologyManifest> = Exclude<BoardId<Manifest>, PerPlayerBoardId<Manifest>>;
842
+ type ResourceId<Manifest extends GameTopologyManifest> = IdsOf<Manifest["resources"]>;
843
+ type PieceTypeId<Manifest extends GameTopologyManifest> = IdsOf<Manifest["pieceTypes"]>;
844
+ type DieTypeId<Manifest extends GameTopologyManifest> = IdsOf<Manifest["dieTypes"]>;
845
+ type PieceSeedOf<Manifest extends GameTopologyManifest> = ArrayItem<NonNullable<Manifest["pieceSeeds"]>>;
846
+ type DieSeedOf<Manifest extends GameTopologyManifest> = ArrayItem<NonNullable<Manifest["dieSeeds"]>>;
847
+ type ManualCardSetOf<Manifest extends GameTopologyManifest> = Extract<ArrayItem<NonNullable<Manifest["cardSets"]>>, {
848
+ type: "manual";
849
+ }>;
850
+ type CardOf<Manifest extends GameTopologyManifest> = ManualCardSetOf<Manifest> extends infer CardSet ? CardSet extends {
851
+ cards: infer Cards extends readonly unknown[];
852
+ } ? ArrayItem<Cards> : never : never;
853
+ type BoardOf<Manifest extends GameTopologyManifest, CurrentBoardId extends BoardId<Manifest>> = Extract<ArrayItem<NonNullable<Manifest["boards"]>>, {
854
+ id: CurrentBoardId;
855
+ }>;
856
+ type SpaceIdOf<BoardLike> = BoardLike extends {
857
+ layout: "hex";
858
+ } ? HexSpaceId<BoardLike> : IdsOf<BoardLike extends {
859
+ spaces?: infer Spaces;
860
+ } ? Spaces : never>;
861
+ type ContainerIdOf<BoardLike> = IdsOf<BoardLike extends {
862
+ containers?: infer Containers;
863
+ } ? Containers : never>;
864
+ type SpaceOf<BoardLike> = ArrayItem<NonNullable<BoardLike extends {
865
+ spaces?: infer Spaces;
866
+ } ? Spaces : never>>;
867
+ type SquareSpaceOf<BoardLike> = Extract<SpaceOf<BoardLike>, {
868
+ row: number;
869
+ col: number;
870
+ }>;
871
+ type SpaceIdForBoard<Manifest extends GameTopologyManifest, CurrentBoardId extends BoardId<Manifest>> = SpaceIdOf<BoardOf<Manifest, CurrentBoardId>>;
872
+ type ContainerIdForBoard<Manifest extends GameTopologyManifest, CurrentBoardId extends BoardId<Manifest>> = ContainerIdOf<BoardOf<Manifest, CurrentBoardId>>;
873
+ type RuntimeIdsFromCount<BaseId extends string, Count> = Count extends number ? number extends Count ? BaseId | `${BaseId}-${number}` : Count extends 1 ? BaseId : `${BaseId}-${OneTo<Count>}` : BaseId;
874
+ type CardRuntimeId<Card> = Card extends {
875
+ type: infer TypeId extends string;
876
+ } ? RuntimeIdsFromCount<TypeId, Card extends {
877
+ count: infer Count extends number;
878
+ } ? Count : never> : never;
879
+ type SeedRuntimeId<Seed> = Seed extends {
880
+ typeId: infer TypeId extends string;
881
+ } ? RuntimeIdsFromCount<Seed extends {
882
+ id: infer Id extends string;
883
+ } ? Id : TypeId, Seed extends {
884
+ count: infer Count extends number;
885
+ } ? Count : never> : never;
886
+ type CardId<Manifest extends GameTopologyManifest> = CardRuntimeId<CardOf<Manifest>>;
887
+ type PieceId<Manifest extends GameTopologyManifest> = SeedRuntimeId<PieceSeedOf<Manifest>>;
888
+ type DieId<Manifest extends GameTopologyManifest> = SeedRuntimeId<DieSeedOf<Manifest>>;
889
+ type PieceTypeOf<Manifest extends GameTopologyManifest, CurrentTypeId extends PieceTypeId<Manifest>> = Extract<ArrayItem<NonNullable<Manifest["pieceTypes"]>>, {
890
+ id: CurrentTypeId;
891
+ }>;
892
+ type DieTypeOf<Manifest extends GameTopologyManifest, CurrentTypeId extends DieTypeId<Manifest>> = Extract<ArrayItem<NonNullable<Manifest["dieTypes"]>>, {
893
+ id: CurrentTypeId;
894
+ }>;
895
+ type SlotIdOf<TypeSpec> = IdsOf<TypeSpec extends {
896
+ slots?: infer Slots;
897
+ } ? Slots : never>;
898
+ type SlotIdForPieceType<Manifest extends GameTopologyManifest, CurrentTypeId extends PieceTypeId<Manifest>> = SlotIdOf<PieceTypeOf<Manifest, CurrentTypeId>>;
899
+ type SlotIdForDieType<Manifest extends GameTopologyManifest, CurrentTypeId extends DieTypeId<Manifest>> = SlotIdOf<DieTypeOf<Manifest, CurrentTypeId>>;
900
+ type SingletonExplicitSeed<Seed> = Seed extends {
901
+ id: string;
902
+ } ? Seed extends {
903
+ count: infer Count extends number;
904
+ } ? Count extends 1 ? Seed : never : Seed : never;
905
+ type TypedPieceSlotHostSeed<Manifest extends GameTopologyManifest> = SingletonExplicitSeed<PieceSeedOf<Manifest>> extends infer Seed ? Seed extends {
906
+ typeId: infer CurrentTypeId extends PieceTypeId<Manifest>;
907
+ } ? [SlotIdForPieceType<Manifest, CurrentTypeId>] extends [never] ? never : Seed : never : never;
908
+ type TypedDieSlotHostSeed<Manifest extends GameTopologyManifest> = SingletonExplicitSeed<DieSeedOf<Manifest>> extends infer Seed ? Seed extends {
909
+ typeId: infer CurrentTypeId extends DieTypeId<Manifest>;
910
+ } ? [SlotIdForDieType<Manifest, CurrentTypeId>] extends [never] ? never : Seed : never : never;
911
+ type TypedPieceSlotHomeSpec<Manifest extends GameTopologyManifest> = TypedPieceSlotHostSeed<Manifest> extends infer Seed ? Seed extends {
912
+ id: infer HostId extends string;
913
+ typeId: infer CurrentTypeId extends PieceTypeId<Manifest>;
914
+ } ? {
915
+ type: "slot";
916
+ host: {
917
+ kind: "piece";
918
+ id: HostId;
919
+ };
920
+ slotId: SlotIdForPieceType<Manifest, CurrentTypeId>;
921
+ } : never : never;
922
+ type TypedDieSlotHomeSpec<Manifest extends GameTopologyManifest> = TypedDieSlotHostSeed<Manifest> extends infer Seed ? Seed extends {
923
+ id: infer HostId extends string;
924
+ typeId: infer CurrentTypeId extends DieTypeId<Manifest>;
925
+ } ? {
926
+ type: "slot";
927
+ host: {
928
+ kind: "die";
929
+ id: HostId;
930
+ };
931
+ slotId: SlotIdForDieType<Manifest, CurrentTypeId>;
932
+ } : never : never;
933
+ type RequiredSchemaKeys<Properties extends Readonly<Record<string, unknown>>> = {
934
+ [Key in keyof Properties]: Properties[Key] extends {
935
+ optional: true;
936
+ } ? never : Properties[Key] extends {
937
+ default: unknown;
938
+ } ? never : Key;
939
+ }[keyof Properties];
940
+ type OptionalSchemaKeys<Properties extends Readonly<Record<string, unknown>>> = {
941
+ [Key in keyof Properties]: Properties[Key] extends {
942
+ optional: true;
943
+ } ? Key : Properties[Key] extends {
944
+ default: unknown;
945
+ } ? Key : never;
946
+ }[keyof Properties];
947
+ type SchemaValueFromObjectProperties<Properties extends Readonly<Record<string, unknown>>, Manifest extends GameTopologyManifest, BoardLike = never> = keyof Properties extends never ? RuntimeRecord : {
948
+ [Key in RequiredSchemaKeys<Properties>]: SchemaValueForProperty<Properties[Key], Manifest, BoardLike>;
949
+ } & {
950
+ [Key in OptionalSchemaKeys<Properties>]?: SchemaValueForProperty<Properties[Key], Manifest, BoardLike>;
951
+ };
952
+ type SchemaValueForObjectSchema<Schema, Manifest extends GameTopologyManifest, BoardLike = never> = Schema extends {
953
+ properties: infer Properties extends Readonly<Record<string, unknown>>;
954
+ } ? SchemaValueFromObjectProperties<Properties, Manifest, BoardLike> : RuntimeRecord;
955
+ type MergeSharedProperties<Variant, Shared> = Variant extends {
956
+ properties: infer VariantProperties extends Readonly<Record<string, unknown>>;
957
+ } ? {
958
+ properties: Shared extends Readonly<Record<string, unknown>> ? Omit<Shared, keyof VariantProperties> & VariantProperties : VariantProperties;
959
+ } : Variant;
960
+ type BaseSchemaValueForProperty<Schema, Manifest extends GameTopologyManifest, BoardLike = never> = Schema extends {
961
+ type: "string";
962
+ } ? string : Schema extends {
963
+ type: "integer" | "number";
964
+ } ? number : Schema extends {
965
+ type: "boolean";
966
+ } ? boolean : Schema extends {
967
+ type: "zoneId";
968
+ } ? ZoneId<Manifest> : Schema extends {
969
+ type: "cardId";
970
+ } ? CardId<Manifest> : Schema extends {
971
+ type: "playerId";
972
+ } ? PlayerId<Manifest> : Schema extends {
973
+ type: "boardId";
974
+ } ? BoardId<Manifest> : Schema extends {
975
+ type: "spaceId";
976
+ } ? [BoardLike] extends [never] ? string : SpaceIdOf<BoardLike> : Schema extends {
977
+ type: "edgeId";
978
+ } ? [BoardLike] extends [never] ? string : DerivedEdgeIdOf<BoardLike> : Schema extends {
979
+ type: "vertexId";
980
+ } ? [BoardLike] extends [never] ? string : DerivedVertexIdOf<BoardLike> : Schema extends {
981
+ type: "pieceId";
982
+ } ? PieceId<Manifest> : Schema extends {
983
+ type: "dieId";
984
+ } ? DieId<Manifest> : Schema extends {
985
+ type: "resourceId";
986
+ } ? ResourceId<Manifest> : Schema extends {
987
+ type: "enum";
988
+ } ? Schema extends {
989
+ enums: infer Values extends readonly string[];
990
+ } ? Values[number] : string : Schema extends {
991
+ type: "array";
992
+ } ? ReadonlyArray<SchemaValueForProperty<Schema extends {
993
+ items?: infer Items;
994
+ } ? Items : undefined, Manifest, BoardLike>> : Schema extends {
995
+ type: "object";
996
+ } ? SchemaValueForObjectSchema<Schema extends {
997
+ properties?: infer Properties extends Record<string, unknown>;
998
+ } ? {
999
+ properties: Properties;
1000
+ } : undefined, Manifest, BoardLike> : Schema extends {
1001
+ type: "record";
1002
+ } ? Record<string, SchemaValueForProperty<Schema extends {
1003
+ values?: infer Values;
1004
+ } ? Values : undefined, Manifest, BoardLike>> : RuntimeRecord;
1005
+ type SchemaValueForProperty<Schema, Manifest extends GameTopologyManifest, BoardLike = never> = Schema extends {
1006
+ nullable: true;
1007
+ } ? BaseSchemaValueForProperty<Schema, Manifest, BoardLike> | null : BaseSchemaValueForProperty<Schema, Manifest, BoardLike>;
1008
+ type BuildTuple<Length extends number, Accumulator extends unknown[] = []> = Accumulator["length"] extends Length ? Accumulator : BuildTuple<Length, [...Accumulator, unknown]>;
1009
+ type EnumerateInternal<Length extends number, Accumulator extends number[] = []> = Accumulator["length"] extends Length ? Accumulator[number] : EnumerateInternal<Length, [...Accumulator, Accumulator["length"]]>;
1010
+ type AddOne<Count extends number> = [...BuildTuple<Count>, unknown]["length"] & number;
1011
+ type OneTo<Count extends number> = Exclude<EnumerateInternal<AddOne<Count>>, 0>;
1012
+ type PlayerId<Manifest extends GameTopologyManifest> = Manifest["players"]["maxPlayers"] extends infer MaxPlayers extends number ? `player-${OneTo<MaxPlayers>}` : `player-${number}`;
1013
+ type ToNumber<Input extends string> = Input extends `${infer Value extends number}` ? Value : never;
1014
+ type AbsoluteNumber<Count extends number> = `${Count}` extends `-${infer Value extends number}` ? Value : Count;
1015
+ type IsNegative<Count extends number> = `${Count}` extends `-${string}` ? true : false;
1016
+ type Negate<Count extends number> = Count extends 0 ? 0 : ToNumber<`${`${Count}` extends `-${infer Value extends number}` ? Value : `-${Count}`}`>;
1017
+ type AddPositive<Left extends number, Right extends number> = number extends Left | Right ? number : [...BuildTuple<Left>, ...BuildTuple<Right>]["length"] & number;
1018
+ type ComparePositive<Left extends number, Right extends number> = Left extends Right ? "equal" : number extends Left | Right ? "unknown" : BuildTuple<Left> extends [...BuildTuple<Right>, ...infer Rest] ? Rest extends [] ? "equal" : "greater" : "less";
1019
+ type SubtractPositive<Left extends number, Right extends number> = number extends Left | Right ? number : BuildTuple<Left> extends [...BuildTuple<Right>, ...infer Rest] ? Rest["length"] & number : never;
1020
+ type AddSigned<Left extends number, Right extends number> = number extends Left | Right ? number : IsNegative<Left> extends IsNegative<Right> ? IsNegative<Left> extends true ? Negate<AddPositive<AbsoluteNumber<Left>, AbsoluteNumber<Right>>> : AddPositive<AbsoluteNumber<Left>, AbsoluteNumber<Right>> : ComparePositive<AbsoluteNumber<Left>, AbsoluteNumber<Right>> extends "equal" ? 0 : ComparePositive<AbsoluteNumber<Left>, AbsoluteNumber<Right>> extends "greater" ? IsNegative<Left> extends true ? Negate<SubtractPositive<AbsoluteNumber<Left>, AbsoluteNumber<Right>>> : SubtractPositive<AbsoluteNumber<Left>, AbsoluteNumber<Right>> : IsNegative<Right> extends true ? Negate<SubtractPositive<AbsoluteNumber<Right>, AbsoluteNumber<Left>>> : SubtractPositive<AbsoluteNumber<Right>, AbsoluteNumber<Left>>;
1021
+ type SquareCornerGeometryKey<Space extends {
1022
+ row: number;
1023
+ col: number;
1024
+ }, Corner extends "nw" | "ne" | "se" | "sw"> = Corner extends "nw" ? `${Space["col"]},${Space["row"]}` : Corner extends "ne" ? `${AddSigned<Space["col"], 1>},${Space["row"]}` : Corner extends "se" ? `${AddSigned<Space["col"], 1>},${AddSigned<Space["row"], 1>}` : `${Space["col"]},${AddSigned<Space["row"], 1>}`;
1025
+ type SquareEdgeGeometryKey<Space extends {
1026
+ row: number;
1027
+ col: number;
1028
+ }, Side extends "north" | "east" | "south" | "west"> = Side extends "north" ? `${Space["col"]},${Space["row"]}::${AddSigned<Space["col"], 1>},${Space["row"]}` : Side extends "east" ? `${AddSigned<Space["col"], 1>},${Space["row"]}::${AddSigned<Space["col"], 1>},${AddSigned<Space["row"], 1>}` : Side extends "south" ? `${Space["col"]},${AddSigned<Space["row"], 1>}::${AddSigned<Space["col"], 1>},${AddSigned<Space["row"], 1>}` : `${Space["col"]},${Space["row"]}::${Space["col"]},${AddSigned<Space["row"], 1>}`;
1029
+ type DerivedSquareEdgeIdOf<BoardLike> = SquareSpaceOf<BoardLike> extends infer Space ? Space extends {
1030
+ row: number;
1031
+ col: number;
1032
+ } ? `square-edge:${SquareEdgeGeometryKey<Space, "north">}` | `square-edge:${SquareEdgeGeometryKey<Space, "east">}` | `square-edge:${SquareEdgeGeometryKey<Space, "south">}` | `square-edge:${SquareEdgeGeometryKey<Space, "west">}` : never : never;
1033
+ type DerivedSquareVertexIdOf<BoardLike> = SquareSpaceOf<BoardLike> extends infer Space ? Space extends {
1034
+ row: number;
1035
+ col: number;
1036
+ } ? `square-vertex:${SquareCornerGeometryKey<Space, "nw">}` | `square-vertex:${SquareCornerGeometryKey<Space, "ne">}` | `square-vertex:${SquareCornerGeometryKey<Space, "se">}` | `square-vertex:${SquareCornerGeometryKey<Space, "sw">}` : never : never;
1037
+ type DerivedHexEdgeIdOf<BoardLike> = BoardLike extends {
1038
+ id: infer Id extends string;
1039
+ } ? HexEdgeId<Id> : never;
1040
+ type DerivedHexVertexIdOf<BoardLike> = BoardLike extends {
1041
+ id: infer Id extends string;
1042
+ } ? HexVertexId<Id> : never;
1043
+ type DerivedEdgeIdOf<BoardLike> = BoardLike extends {
1044
+ layout: "square";
1045
+ } ? DerivedSquareEdgeIdOf<BoardLike> : BoardLike extends {
1046
+ layout: "hex";
1047
+ } ? DerivedHexEdgeIdOf<BoardLike> : never;
1048
+ type DerivedVertexIdOf<BoardLike> = BoardLike extends {
1049
+ layout: "square";
1050
+ } ? DerivedSquareVertexIdOf<BoardLike> : BoardLike extends {
1051
+ layout: "hex";
1052
+ } ? DerivedHexVertexIdOf<BoardLike> : never;
1053
+ type TypedSharedSpaceHomeSpec<Manifest extends GameTopologyManifest> = {
1054
+ [CurrentBoardId in SharedBoardId<Manifest>]: {
1055
+ type: "space";
1056
+ boardId: CurrentBoardId;
1057
+ spaceId: SpaceIdForBoard<Manifest, CurrentBoardId>;
1058
+ };
1059
+ }[SharedBoardId<Manifest>];
1060
+ type TypedPerPlayerSpaceHomeSpec<Manifest extends GameTopologyManifest> = {
1061
+ [CurrentBoardId in PerPlayerBoardId<Manifest>]: {
1062
+ type: "space";
1063
+ boardId: CurrentBoardId;
1064
+ spaceId: SpaceIdForBoard<Manifest, CurrentBoardId>;
1065
+ };
1066
+ }[PerPlayerBoardId<Manifest>];
1067
+ type TypedSharedContainerHomeSpec<Manifest extends GameTopologyManifest> = {
1068
+ [CurrentBoardId in SharedBoardId<Manifest>]: {
1069
+ type: "container";
1070
+ boardId: CurrentBoardId;
1071
+ containerId: ContainerIdForBoard<Manifest, CurrentBoardId>;
1072
+ };
1073
+ }[SharedBoardId<Manifest>];
1074
+ type TypedPerPlayerContainerHomeSpec<Manifest extends GameTopologyManifest> = {
1075
+ [CurrentBoardId in PerPlayerBoardId<Manifest>]: {
1076
+ type: "container";
1077
+ boardId: CurrentBoardId;
1078
+ containerId: ContainerIdForBoard<Manifest, CurrentBoardId>;
1079
+ };
1080
+ }[PerPlayerBoardId<Manifest>];
1081
+ type TypedSharedEdgeHomeSpec<Manifest extends GameTopologyManifest> = {
1082
+ [CurrentBoardId in SharedBoardId<Manifest>]: {
1083
+ type: "edge";
1084
+ boardId: CurrentBoardId;
1085
+ ref: BoardEdgeRef;
1086
+ };
1087
+ }[SharedBoardId<Manifest>];
1088
+ type TypedPerPlayerEdgeHomeSpec<Manifest extends GameTopologyManifest> = {
1089
+ [CurrentBoardId in PerPlayerBoardId<Manifest>]: {
1090
+ type: "edge";
1091
+ boardId: CurrentBoardId;
1092
+ ref: BoardEdgeRef;
1093
+ };
1094
+ }[PerPlayerBoardId<Manifest>];
1095
+ type TypedSharedVertexHomeSpec<Manifest extends GameTopologyManifest> = {
1096
+ [CurrentBoardId in SharedBoardId<Manifest>]: {
1097
+ type: "vertex";
1098
+ boardId: CurrentBoardId;
1099
+ ref: BoardVertexRef;
1100
+ };
1101
+ }[SharedBoardId<Manifest>];
1102
+ type TypedPerPlayerVertexHomeSpec<Manifest extends GameTopologyManifest> = {
1103
+ [CurrentBoardId in PerPlayerBoardId<Manifest>]: {
1104
+ type: "vertex";
1105
+ boardId: CurrentBoardId;
1106
+ ref: BoardVertexRef;
1107
+ };
1108
+ }[PerPlayerBoardId<Manifest>];
1109
+ type TypedSharedZoneHomeSpec<Manifest extends GameTopologyManifest> = {
1110
+ type: "zone";
1111
+ zoneId: SharedZoneId<Manifest>;
1112
+ };
1113
+ type TypedPerPlayerZoneHomeSpec<Manifest extends GameTopologyManifest> = {
1114
+ type: "zone";
1115
+ zoneId: PerPlayerZoneId<Manifest>;
1116
+ };
1117
+ type TypedPlayerScopedComponentHomeSpec<Manifest extends GameTopologyManifest> = TypedPerPlayerZoneHomeSpec<Manifest> | TypedPerPlayerSpaceHomeSpec<Manifest> | TypedPerPlayerContainerHomeSpec<Manifest> | TypedPerPlayerEdgeHomeSpec<Manifest> | TypedPerPlayerVertexHomeSpec<Manifest>;
1118
+ type TypedSharedComponentHomeSpec<Manifest extends GameTopologyManifest> = {
1119
+ type: "detached";
1120
+ } | TypedSharedZoneHomeSpec<Manifest> | TypedSharedSpaceHomeSpec<Manifest> | TypedSharedContainerHomeSpec<Manifest> | TypedSharedEdgeHomeSpec<Manifest> | TypedSharedVertexHomeSpec<Manifest> | TypedPieceSlotHomeSpec<Manifest> | TypedDieSlotHomeSpec<Manifest>;
1121
+ type TypedComponentHomeSpec<Manifest extends GameTopologyManifest> = TypedSharedComponentHomeSpec<Manifest> | TypedPlayerScopedComponentHomeSpec<Manifest>;
1122
+ type TypedSeedLocationSpec<Seed, Manifest extends GameTopologyManifest> = Seed extends {
1123
+ home: infer Home;
1124
+ } ? Home extends TypedPlayerScopedComponentHomeSpec<Manifest> ? Omit<Seed, "ownerId" | "home"> & {
1125
+ ownerId: PlayerId<Manifest>;
1126
+ home: TypedPlayerScopedComponentHomeSpec<Manifest>;
1127
+ } : Omit<Seed, "ownerId" | "home"> & {
1128
+ ownerId?: PlayerId<Manifest>;
1129
+ home?: TypedComponentHomeSpec<Manifest>;
1130
+ } : Omit<Seed, "ownerId" | "home"> & {
1131
+ ownerId?: PlayerId<Manifest>;
1132
+ home?: TypedComponentHomeSpec<Manifest>;
1133
+ };
1134
+ type TypedVisibilitySpec<Manifest extends GameTopologyManifest> = {
1135
+ faceUp?: boolean;
1136
+ visibleTo?: readonly PlayerId<Manifest>[];
1137
+ };
1138
+ type TypedVisibility<T, Manifest extends GameTopologyManifest> = T extends {
1139
+ visibility?: unknown;
1140
+ } ? Omit<T, "visibility"> & {
1141
+ visibility?: TypedVisibilitySpec<Manifest>;
1142
+ } : T;
1143
+ type TypedFields<T, Schema, Manifest extends GameTopologyManifest, BoardLike = never> = T extends {
1144
+ fields?: unknown;
1145
+ } ? Omit<T, "fields"> & {
1146
+ fields?: SchemaValueForObjectSchema<Schema, Manifest, BoardLike>;
1147
+ } : T;
1148
+ type TypedBoardContainerHost<Host, BoardLike> = Host extends {
1149
+ type: "space";
1150
+ spaceId: string;
1151
+ } ? Omit<Host, "spaceId"> & {
1152
+ spaceId: SpaceIdOf<BoardLike>;
1153
+ } : Host;
1154
+ type TypedBoardContainer<Container, Manifest extends GameTopologyManifest, BoardLike, ContainerSchema> = Container extends {
1155
+ host: infer Host;
1156
+ } ? Omit<TypedFields<TypedAllowedCardSetIds<Container, Manifest>, ContainerSchema, Manifest, BoardLike>, "host"> & {
1157
+ host: TypedBoardContainerHost<Host, BoardLike>;
1158
+ } : TypedFields<TypedAllowedCardSetIds<Container, Manifest>, ContainerSchema, Manifest, BoardLike>;
1159
+ type TypedBoardRelation<Relation, Manifest extends GameTopologyManifest, BoardLike, RelationSchema> = Relation extends object ? Omit<TypedFields<Relation, RelationSchema, Manifest, BoardLike>, "fromSpaceId" | "toSpaceId"> & {
1160
+ fromSpaceId: SpaceIdOf<BoardLike>;
1161
+ toSpaceId: SpaceIdOf<BoardLike>;
1162
+ } : Relation;
1163
+ type TypedOptionalArray<Base, Source, Key extends string, Item> = Source extends {
1164
+ [Property in Key]?: readonly unknown[];
1165
+ } ? Base & {
1166
+ [Property in Key]?: ReadonlyArray<Item>;
1167
+ } : Base;
1168
+ type SchemaForEntry<Entry, Key extends string> = Key extends keyof Entry ? Entry[Key] : undefined;
1169
+ type TypedGenericBoardLike<Entry, Manifest extends GameTopologyManifest, BoardLike> = TypedOptionalArray<TypedOptionalArray<TypedOptionalArray<TypedFields<Omit<Entry, "spaces" | "relations" | "containers">, SchemaForEntry<Entry, "boardFieldsSchema">, Manifest, BoardLike>, Entry, "spaces", TypedFields<ArrayItem<NonNullable<Entry extends {
1170
+ spaces?: infer Spaces;
1171
+ } ? Spaces : never>>, SchemaForEntry<Entry, "spaceFieldsSchema">, Manifest, BoardLike>>, Entry, "relations", TypedBoardRelation<ArrayItem<NonNullable<Entry extends {
1172
+ relations?: infer Relations;
1173
+ } ? Relations : never>>, Manifest, BoardLike, SchemaForEntry<Entry, "relationFieldsSchema">>>, Entry, "containers", TypedBoardContainer<ArrayItem<NonNullable<Entry extends {
1174
+ containers?: infer Containers;
1175
+ } ? Containers : never>>, Manifest, BoardLike, SchemaForEntry<Entry, "containerFieldsSchema">>>;
1176
+ type TypedHexBoardLike<Entry, Manifest extends GameTopologyManifest, BoardLike> = TypedOptionalArray<TypedOptionalArray<TypedFields<Omit<Entry, "spaces" | "edges" | "vertices">, SchemaForEntry<Entry, "boardFieldsSchema">, Manifest, BoardLike> & (Entry extends {
1177
+ spaces: infer Spaces;
1178
+ } ? {
1179
+ spaces: {
1180
+ [Key in keyof Spaces]: TypedFields<Spaces[Key], SchemaForEntry<Entry, "spaceFieldsSchema">, Manifest, BoardLike>;
1181
+ };
1182
+ } : unknown), Entry, "edges", TypedFields<ArrayItem<NonNullable<Entry extends {
1183
+ edges?: infer Edges;
1184
+ } ? Edges : never>>, SchemaForEntry<Entry, "edgeFieldsSchema">, Manifest, BoardLike>>, Entry, "vertices", TypedFields<ArrayItem<NonNullable<Entry extends {
1185
+ vertices?: infer Vertices;
1186
+ } ? Vertices : never>>, SchemaForEntry<Entry, "vertexFieldsSchema">, Manifest, BoardLike>>;
1187
+ type TypedSquareBoardLike<Entry, Manifest extends GameTopologyManifest, BoardLike> = TypedOptionalArray<TypedOptionalArray<TypedOptionalArray<TypedOptionalArray<TypedOptionalArray<TypedFields<Omit<Entry, "spaces" | "relations" | "containers" | "edges" | "vertices">, SchemaForEntry<Entry, "boardFieldsSchema">, Manifest, BoardLike>, Entry, "spaces", TypedFields<ArrayItem<NonNullable<Entry extends {
1188
+ spaces?: infer Spaces;
1189
+ } ? Spaces : never>>, SchemaForEntry<Entry, "spaceFieldsSchema">, Manifest, BoardLike>>, Entry, "relations", TypedBoardRelation<ArrayItem<NonNullable<Entry extends {
1190
+ relations?: infer Relations;
1191
+ } ? Relations : never>>, Manifest, BoardLike, SchemaForEntry<Entry, "relationFieldsSchema">>>, Entry, "containers", TypedBoardContainer<ArrayItem<NonNullable<Entry extends {
1192
+ containers?: infer Containers;
1193
+ } ? Containers : never>>, Manifest, BoardLike, SchemaForEntry<Entry, "containerFieldsSchema">>>, Entry, "edges", TypedFields<ArrayItem<NonNullable<Entry extends {
1194
+ edges?: infer Edges;
1195
+ } ? Edges : never>>, SchemaForEntry<Entry, "edgeFieldsSchema">, Manifest, BoardLike>>, Entry, "vertices", TypedFields<ArrayItem<NonNullable<Entry extends {
1196
+ vertices?: infer Vertices;
1197
+ } ? Vertices : never>>, SchemaForEntry<Entry, "vertexFieldsSchema">, Manifest, BoardLike>>;
1198
+ type TypedBoardLikeEntry<Entry, Manifest extends GameTopologyManifest> = Entry extends {
1199
+ layout: "generic";
1200
+ } ? TypedGenericBoardLike<Entry, Manifest, Entry> : Entry extends {
1201
+ layout: "hex";
1202
+ } ? TypedHexBoardLike<Entry, Manifest, Entry> : Entry extends {
1203
+ layout: "square";
1204
+ } ? TypedSquareBoardLike<Entry, Manifest, Entry> : Entry;
1205
+ type AuthoredCardType<Card> = Card extends {
1206
+ cardType: infer Category extends string;
1207
+ } ? Category : Card extends {
1208
+ type: infer Type extends string;
1209
+ } ? Type : never;
1210
+ type TypedCard<Card, Manifest extends GameTopologyManifest, CardSchema> = Card extends {
1211
+ type: string;
1212
+ } ? Omit<TypedVisibility<Card, Manifest>, "home" | "properties"> & {
1213
+ home?: TypedComponentHomeSpec<Manifest>;
1214
+ properties: CardSchema extends {
1215
+ variants: infer Variants extends Record<string, unknown>;
1216
+ shared?: infer Shared;
1217
+ } ? AuthoredCardType<Card> extends keyof Variants ? SchemaValueForObjectSchema<MergeSharedProperties<Variants[AuthoredCardType<Card>], Shared>, Manifest> : never : SchemaValueForObjectSchema<CardSchema, Manifest>;
1218
+ } : Card;
1219
+ type TypedCardSet<CardSet, Manifest extends GameTopologyManifest> = CardSet extends {
1220
+ type: "manual";
1221
+ cardSchema: infer CardSchema;
1222
+ cards: infer Cards extends readonly unknown[];
1223
+ } ? Omit<CardSet, "cards" | "defaultHome"> & {
1224
+ defaultHome: TypedComponentHomeSpec<Manifest>;
1225
+ cards: ReadonlyArray<TypedCard<ArrayItem<Cards>, Manifest, CardSchema>>;
1226
+ } : CardSet;
1227
+ type TypedAllowedCardSetIds<T, Manifest extends GameTopologyManifest> = T extends object ? Omit<T, "allowedCardSetIds"> & {
1228
+ allowedCardSetIds?: readonly CardSetId<Manifest>[];
1229
+ } : T;
1230
+ type TypedZone<Zone, Manifest extends GameTopologyManifest> = TypedAllowedCardSetIds<Zone, Manifest>;
1231
+ type TypedPieceSeed<Seed, Manifest extends GameTopologyManifest> = Seed extends {
1232
+ typeId: infer CurrentTypeId;
1233
+ } ? CurrentTypeId extends PieceTypeId<Manifest> ? Omit<TypedSeedLocationSpec<TypedVisibility<Seed, Manifest>, Manifest>, "typeId" | "ownerId" | "home" | "fields"> & {
1234
+ typeId: CurrentTypeId;
1235
+ fields?: SchemaValueForObjectSchema<PieceTypeOf<Manifest, CurrentTypeId> extends {
1236
+ fieldsSchema?: infer FieldsSchema;
1237
+ } ? FieldsSchema : undefined, Manifest>;
1238
+ } & Pick<TypedSeedLocationSpec<TypedVisibility<Seed, Manifest>, Manifest>, "ownerId" | "home"> : Omit<Seed, "typeId"> & {
1239
+ typeId: PieceTypeId<Manifest>;
1240
+ } : never;
1241
+ type TypedDieSeed<Seed, Manifest extends GameTopologyManifest> = Seed extends {
1242
+ typeId: infer CurrentTypeId;
1243
+ } ? CurrentTypeId extends DieTypeId<Manifest> ? Omit<TypedSeedLocationSpec<TypedVisibility<Seed, Manifest>, Manifest>, "typeId" | "ownerId" | "home" | "fields"> & {
1244
+ typeId: CurrentTypeId;
1245
+ fields?: SchemaValueForObjectSchema<DieTypeOf<Manifest, CurrentTypeId> extends {
1246
+ fieldsSchema?: infer FieldsSchema;
1247
+ } ? FieldsSchema : undefined, Manifest>;
1248
+ } & Pick<TypedSeedLocationSpec<TypedVisibility<Seed, Manifest>, Manifest>, "ownerId" | "home"> : Omit<Seed, "typeId"> & {
1249
+ typeId: DieTypeId<Manifest>;
1250
+ } : never;
1251
+ type TypedTopologyManifest<Manifest extends GameTopologyManifest> = Omit<Manifest, "cardSets" | "zones" | "boards" | "pieceSeeds" | "dieSeeds"> & {
1252
+ cardSets: ReadonlyArray<TypedCardSet<ArrayItem<Manifest["cardSets"]>, Manifest>>;
1253
+ zones?: Manifest["zones"] extends readonly unknown[] ? ReadonlyArray<TypedZone<ArrayItem<Manifest["zones"]>, Manifest>> : Manifest["zones"];
1254
+ boards: Manifest["boards"] extends readonly unknown[] ? ReadonlyArray<TypedBoardLikeEntry<ArrayItem<Manifest["boards"]>, Manifest>> : Manifest["boards"];
1255
+ pieceSeeds?: Manifest["pieceSeeds"] extends readonly unknown[] ? ReadonlyArray<TypedPieceSeed<ArrayItem<Manifest["pieceSeeds"]>, Manifest>> : Manifest["pieceSeeds"];
1256
+ dieSeeds?: Manifest["dieSeeds"] extends readonly unknown[] ? ReadonlyArray<TypedDieSeed<ArrayItem<Manifest["dieSeeds"]>, Manifest>> : Manifest["dieSeeds"];
1257
+ };
1258
+ type TopologyManifestValidation<Manifest> = Manifest extends GameTopologyManifest ? TypedTopologyManifest<Manifest> : GameTopologyManifest;
1259
+ type DefinedTopologyManifest<Manifest> = Manifest extends GameTopologyManifest ? Manifest : GameTopologyManifest;
1260
+ declare function defineTopologyManifest<const Manifest>(manifest: Manifest & TopologyManifestValidation<NoInfer<Manifest>>): DefinedTopologyManifest<Manifest>;
1261
+
1262
+ export { type AuthoredManifest, type BoardRef, type BoardTargetPredicate, type BoundInputBuilders, type BoundTargetPredicate, type CardTargetPredicate, type ChoiceOptionsFactory, type ChoiceTargetOption, type ChoiceTargetPredicate, type CompiledManifest, type ContractTypes, type GameAuthoring, type GameTopologyManifest$1 as GameTopologyManifest, InteractionRule, type ManifestIdsOf, type ManifestTable, type ManyOptions, type PerPlayerBoardRef, type PhaseAuthoring, type PhaseTypes, type PlayerBoardSpaceTarget, type PlayerId$1 as PlayerId, type ReducerBundle, ReducerBundleContract, type ReducerBundleOptions, ReducerDiagnosticsSink, ReducerGameDefinition, ReducerTransaction, type SharedBoardRef, type SparseCounts, type SparseMap, SystemActionEvent, TableQueries, TableQueriesOfState, type TargetContext, type TargetPredicate, type TargetPredicateArgs, type TypedTopologyManifest, asPlayerId, assertCardAllowedInContainer, boardRef, boardRefKey, boardRefSchema, compileManifest, createGame, createReducerBundle, createStateQueries, createTableQueries, defineTopologyManifest, gameEvent, isPerPlayerBoardRef, isPlayerId, isSharedBoardRef, many, materializeManifestTable, memoize, normalizeCommandParams, parseBoardRefKey, perPlayerBoardRef, sharedBoardRef, sparseCounts, sparseMap };