@dreamboard-games/sdk 0.5.0-alpha.2 → 0.5.0-alpha.21

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 +462 -53
  2. package/dist/board-element-CqtxU5VZ.d.ts +13 -0
  3. package/dist/chunk-3RFGPBES.js +1792 -0
  4. package/dist/chunk-3RFGPBES.js.map +1 -0
  5. package/dist/chunk-CZRPUWCT.js +1602 -0
  6. package/dist/chunk-CZRPUWCT.js.map +1 -0
  7. package/dist/chunk-DMSXVMYY.js +7199 -0
  8. package/dist/chunk-DMSXVMYY.js.map +1 -0
  9. package/dist/chunk-U6R7FAH4.js +630 -0
  10. package/dist/chunk-U6R7FAH4.js.map +1 -0
  11. package/dist/chunk-YT3RPO5J.js +635 -0
  12. package/dist/chunk-YT3RPO5J.js.map +1 -0
  13. package/dist/diagnostics-ZAPEBlJP.d.ts +64 -0
  14. package/dist/extract-CwJWDrSD.d.ts +6850 -0
  15. package/dist/index.d.ts +5177 -1
  16. package/dist/index.js +1990 -6
  17. package/dist/index.js.map +1 -1
  18. package/dist/react.d.ts +158 -0
  19. package/dist/react.js +1119 -0
  20. package/dist/react.js.map +1 -0
  21. package/dist/reducer.d.ts +1028 -97
  22. package/dist/reducer.js +4892 -125
  23. package/dist/reducer.js.map +1 -1
  24. package/dist/shortcuts-B_RrufOM.d.ts +822 -0
  25. package/dist/testing.d.ts +529 -569
  26. package/dist/testing.js +2588 -934
  27. package/dist/testing.js.map +1 -1
  28. package/dist/types-BxXRINRF.d.ts +118 -0
  29. package/package.json +39 -144
  30. package/dist/HandView-Bi2lxzQP.d.ts +0 -79
  31. package/dist/ResourceCounter-BFxJknqp.d.ts +0 -98
  32. package/dist/ThemeProvider-CElaL2ik.d.ts +0 -99
  33. package/dist/attributes-DbvyMbXw.d.ts +0 -68
  34. package/dist/browser-interaction.d.ts +0 -910
  35. package/dist/browser-interaction.js +0 -119
  36. package/dist/browser-interaction.js.map +0 -1
  37. package/dist/chunk-32PFKDV7.js +0 -11705
  38. package/dist/chunk-32PFKDV7.js.map +0 -1
  39. package/dist/chunk-3BAD4VC2.js +0 -263
  40. package/dist/chunk-3BAD4VC2.js.map +0 -1
  41. package/dist/chunk-3SKDNDPG.js +0 -104
  42. package/dist/chunk-3SKDNDPG.js.map +0 -1
  43. package/dist/chunk-5YV2WHJ4.js +0 -25
  44. package/dist/chunk-5YV2WHJ4.js.map +0 -1
  45. package/dist/chunk-ANRB4XKA.js +0 -90
  46. package/dist/chunk-ANRB4XKA.js.map +0 -1
  47. package/dist/chunk-BI4G3PM2.js +0 -1864
  48. package/dist/chunk-BI4G3PM2.js.map +0 -1
  49. package/dist/chunk-EVCLTY4Q.js +0 -935
  50. package/dist/chunk-EVCLTY4Q.js.map +0 -1
  51. package/dist/chunk-GDPKTBUR.js +0 -564
  52. package/dist/chunk-GDPKTBUR.js.map +0 -1
  53. package/dist/chunk-H6VDGFL5.js +0 -2903
  54. package/dist/chunk-H6VDGFL5.js.map +0 -1
  55. package/dist/chunk-LR3ZTWQF.js +0 -5960
  56. package/dist/chunk-LR3ZTWQF.js.map +0 -1
  57. package/dist/chunk-PF7L4BMG.js +0 -117
  58. package/dist/chunk-PF7L4BMG.js.map +0 -1
  59. package/dist/chunk-PN5O6GG2.js +0 -32
  60. package/dist/chunk-PN5O6GG2.js.map +0 -1
  61. package/dist/chunk-PZ5AY32C.js +0 -10
  62. package/dist/chunk-PZ5AY32C.js.map +0 -1
  63. package/dist/chunk-S2JEDVWH.js +0 -7165
  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,18 +1,259 @@
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';
7
- 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';
14
-
15
- type CardTargetPredicate<State extends CollectorState, Id extends string> = TargetPredicate<State, Id>;
1
+ import { ae as ManifestIdSchema, aV as SchemaLike, t as CollectorState, S as InputCollector, as as PlayerIdOfState, b6 as TableQueriesOfState, aM as ResourceMapDomainDescriptor, p as BoundedNumberDomainDescriptor, q as ChoiceDomainDescriptor, r as ChoiceListDomainDescriptor, bh as TopologyDefinitions, v as CollectorValueWitness, u as CollectorValueOf, X as InputSelectionDescriptor, aH as ReducerManifestContractLike, aT as RuntimeTableRecord, aS as RuntimeRecord, b2 as StateDefinition, ac as ManifestContractOf, B as BaseGameStateOfContract, E as ErrorCodeOfContract, be as TiledBoardIdOfTable, b4 as TableOfManifest, bg as TiledVertexIdOfTable, bf as TiledEdgeIdOfTable, h as BoardIdOfTable, b0 as SpaceIdOfTable, j as BoardSpaceTarget, an as PerPlayerInstanceId, bs as ZoneIdOfTable, C as CardIdOfManifest, au as PositionTargetSchema, at as PositionTarget, b9 as TileIdOfTable, ah as OptionsOfContract, aJ as ReducerTransaction, bn as ViewData, bo as ViewDefinition, ap as PhaseMapOf, bp as ViewOfContract, aF as ReducerGameDefinitionInput, aE as ReducerGameDefinition, ab as InteractionSteps, aW as ScopedPhaseState, a9 as InteractionSpec, a8 as InteractionRule, a7 as InteractionMap, ao as PhaseDefinition, aG as ReducerManifestContract, aC as ReducerGameContract, x as CompiledManifestWitness, w as CompiledManifest, b3 as SystemActionEvent, aD as ReducerGameContractLike, aR as RuntimeQueryTable, br as ZoneDefinitions, b5 as TableQueries, aU as SchemaAuthoring, O as GameTopologyManifest$1, z as FieldsInput, c as AuthoredTileDisclosure, aO as RuntimeIdsFromCount, bc as TileSpaceIds, g as BoardEdgeRef, o as BoardVertexRef, ad as ManifestCountValidation, bi as ValidatedManifest, a as AuthoredManifest, aA as ReadonlyRuntimeData, b as AuthoredOf } from './extract-CwJWDrSD.js';
2
+ export { d as AuthoredTileFaceAudience, f as BoardEdgeId, i as BoardSpaceHostId, n as BoardVertexId, F as FieldSchema, G as FieldsOutput, H as FrameworkErrorCodes, I as GameEvent, J as GameEventDetail, L as GameOutcome, af as ManifestIdsOf, ag as ManifestTable, ai as OutcomeResult, aj as OutcomeScoreComponent, ak as OutcomeStanding, al as OutcomeTieBreak, am as PerPlayerInstanceFamily, ar as PlayerId, az as PublicTileAppearance, aK as ReducerTransactionOutcome, aL as ReducerValidationResult, bD as ReducerWire, bC as ReducerWireZod, aN as RotateZoneArgs, aZ as SeatSpaceRef, a_ as SeatTileRef, b1 as SquareBoardSpec, b7 as TileDisclosure, b8 as TileFaceAudience, ba as TileSeedSpec, bb as TileSpaceId, bd as TileTypeSpec, bj as ValidationIssue, bu as asPlayerId, bv as boardSpaceHostId, bw as isPlayerId, bx as parseBoardSpaceHostId, by as parsePerPlayerInstanceId, bz as parseTileSpaceId, bA as perPlayerInstanceId, bB as ref, bE as tileSpaceId } from './extract-CwJWDrSD.js';
3
+ import * as z from 'zod';
4
+ import { z as z$1 } from 'zod';
5
+ export { z };
6
+ import { a as ReducerBundleContract, c as ReducerDiagnosticsSink } from './diagnostics-ZAPEBlJP.js';
7
+ export { D as DispatchTraceSummaryEntry, M as MaybePromise, R as REDUCER_CONTRACT_VERSION, b as ReducerDiagnosticEvent, d as assertReducerBundleContract, n as noopDiagnosticsSink } from './diagnostics-ZAPEBlJP.js';
8
+ export { b as boardEdgeId, a as boardVertexId, p as parseBoardElementId } from './board-element-CqtxU5VZ.js';
9
+ import 'honeycomb-grid';
10
+
11
+ type DomainContext<State extends CollectorState> = {
12
+ state: State;
13
+ playerId: PlayerIdOfState<State>;
14
+ q: TableQueriesOfState<State>;
15
+ };
16
+ type ManifestFormInputSchema = ManifestIdSchema<unknown> | z.ZodOptional<ManifestIdSchema<unknown>> | z.ZodNullable<ManifestIdSchema<unknown>>;
17
+ type DomainNumber<State extends CollectorState> = number | ((context: DomainContext<State>) => number);
18
+ type ResourceMapInputOptions<State extends CollectorState> = {
19
+ resources: ReadonlyArray<{
20
+ resourceId: string;
21
+ label?: string;
22
+ icon?: string;
23
+ min?: DomainNumber<State>;
24
+ max: DomainNumber<State>;
25
+ }>;
26
+ };
27
+ type ChoiceValue = string | null;
28
+ type FormCollector<Schema extends SchemaLike<unknown>, State extends CollectorState, Domain extends ResourceMapDomainDescriptor | BoundedNumberDomainDescriptor | ChoiceDomainDescriptor | ChoiceListDomainDescriptor, Value = z.infer<Schema>> = Omit<InputCollector<Schema, State, "form", Value>, "domain"> & {
29
+ readonly domain: (state: CollectorState, playerId: string, q: unknown) => Domain;
30
+ };
31
+ type DomainChoice<Value extends ChoiceValue> = {
32
+ value: Value;
33
+ label: string;
34
+ icon?: string;
35
+ badge?: string;
36
+ description?: string;
37
+ disabled?: boolean;
38
+ disabledReason?: string;
39
+ };
40
+ type DomainChoicePresentation = {
41
+ badge?: string;
42
+ description?: string;
43
+ disabled?: boolean;
44
+ disabledReason?: string;
45
+ };
46
+ type ResourceMapChoiceDecorator<State extends CollectorState> = (context: DomainContext<State> & {
47
+ resourceId: string;
48
+ label: string;
49
+ icon?: string;
50
+ }) => DomainChoicePresentation | null | undefined;
51
+ type ResourceMapChoiceSource<State extends CollectorState> = "resourceMap" | {
52
+ source: "resourceMap";
53
+ decorate?: ResourceMapChoiceDecorator<State>;
54
+ };
55
+ type DomainChoices<Value extends ChoiceValue, State extends CollectorState> = ReadonlyArray<DomainChoice<Value>> | ResourceMapChoiceSource<State> | ((context: DomainContext<State>) => ReadonlyArray<DomainChoice<Value>>);
56
+ type ChoiceListDefaultValue<Value extends string, State extends CollectorState> = Value[] | "all" | ((context: DomainContext<State> & {
57
+ choices: ReadonlyArray<DomainChoice<Value>>;
58
+ }) => Value[]);
59
+ type ChoiceDefaultResolver<Value extends ChoiceValue, State extends CollectorState> = (context: DomainContext<State> & {
60
+ choices: ReadonlyArray<DomainChoice<Value>>;
61
+ }) => Value | undefined;
62
+ declare function baseFormInput<Schema extends ManifestFormInputSchema & SchemaLike<unknown>, State extends CollectorState = CollectorState>(schema: Schema): InputCollector<Schema, State, "form">;
63
+ declare function baseFormInput<Schema extends ManifestFormInputSchema & SchemaLike<unknown>, State extends CollectorState = CollectorState>(schema: Schema, options: {
64
+ defaultValue: z.infer<Schema>;
65
+ }): InputCollector<Schema, State, "form"> & {
66
+ readonly defaultValue: z.infer<Schema>;
67
+ };
68
+ declare function resourceMapInput<State extends CollectorState = CollectorState>(options: ResourceMapInputOptions<State>): FormCollector<z.ZodRecord<z.ZodString, z.ZodNumber>, State, ResourceMapDomainDescriptor>;
69
+ declare function resourceMapInput<State extends CollectorState = CollectorState>(options: ResourceMapInputOptions<State> & {
70
+ defaultValue: Record<string, number>;
71
+ }): FormCollector<z.ZodRecord<z.ZodString, z.ZodNumber>, State, ResourceMapDomainDescriptor> & {
72
+ readonly defaultValue: Record<string, number>;
73
+ };
74
+ declare function numberInput<State extends CollectorState = CollectorState>(options: {
75
+ min: DomainNumber<State>;
76
+ max: DomainNumber<State>;
77
+ step?: DomainNumber<State>;
78
+ }): FormCollector<z.ZodNumber, State, BoundedNumberDomainDescriptor>;
79
+ declare function numberInput<State extends CollectorState = CollectorState>(options: {
80
+ min: DomainNumber<State>;
81
+ max: DomainNumber<State>;
82
+ step?: DomainNumber<State>;
83
+ defaultValue: number;
84
+ }): FormCollector<z.ZodNumber, State, BoundedNumberDomainDescriptor> & {
85
+ readonly defaultValue: number;
86
+ };
87
+ declare function choiceInput<Value extends ChoiceValue, State extends CollectorState = CollectorState>(options: {
88
+ choices: ReadonlyArray<DomainChoice<Value>>;
89
+ defaultValue: Value;
90
+ }): FormCollector<SchemaLike<Value>, State, ChoiceDomainDescriptor, Value> & {
91
+ readonly defaultValue: Value;
92
+ };
93
+ declare function choiceInput<Value extends ChoiceValue, State extends CollectorState = CollectorState>(options: {
94
+ choices: DomainChoices<Value, State>;
95
+ defaultValue: Value;
96
+ }): FormCollector<SchemaLike<ChoiceValue>, State, ChoiceDomainDescriptor, Value> & {
97
+ readonly defaultValue: Value;
98
+ };
99
+ declare function choiceInput<Value extends ChoiceValue, State extends CollectorState = CollectorState>(options: {
100
+ choices: ReadonlyArray<DomainChoice<Value>>;
101
+ defaultValue: ChoiceDefaultResolver<Value, State>;
102
+ }): FormCollector<SchemaLike<Value>, State, ChoiceDomainDescriptor, Value>;
103
+ declare function choiceInput<Value extends ChoiceValue, State extends CollectorState = CollectorState>(options: {
104
+ choices: DomainChoices<Value, State>;
105
+ defaultValue: ChoiceDefaultResolver<Value, State>;
106
+ }): FormCollector<SchemaLike<ChoiceValue>, State, ChoiceDomainDescriptor, Value>;
107
+ type ChoiceListCollector<Value extends string, State extends CollectorState> = InputCollector<z.ZodArray<z.ZodString>, State, "form", Value[]> & {
108
+ readonly domain: (state: CollectorState, playerId: string, q: unknown) => ChoiceListDomainDescriptor;
109
+ };
110
+ declare function choiceListInput<Value extends string, State extends CollectorState = CollectorState>(options: {
111
+ choices: DomainChoices<Value, State>;
112
+ min?: DomainNumber<State>;
113
+ max?: DomainNumber<State>;
114
+ defaultValue: Value[];
115
+ }): ChoiceListCollector<Value, State> & {
116
+ readonly defaultValue: Value[];
117
+ };
118
+ declare function choiceListInput<Value extends string, State extends CollectorState = CollectorState>(options: {
119
+ choices: DomainChoices<Value, State>;
120
+ min?: DomainNumber<State>;
121
+ max?: DomainNumber<State>;
122
+ defaultValue?: ChoiceListDefaultValue<Value, State>;
123
+ }): ChoiceListCollector<Value, State>;
124
+ type FormInputForState<State extends CollectorState> = {
125
+ <Schema extends ManifestFormInputSchema & SchemaLike<unknown>>(schema: Schema): InputCollector<Schema, State, "form">;
126
+ <Schema extends ManifestFormInputSchema & SchemaLike<unknown>>(schema: Schema, options: {
127
+ defaultValue: z.infer<Schema>;
128
+ }): InputCollector<Schema, State, "form"> & {
129
+ readonly defaultValue: z.infer<Schema>;
130
+ };
131
+ resourceMap(options: ResourceMapInputOptions<State>): FormCollector<z.ZodRecord<z.ZodString, z.ZodNumber>, State, ResourceMapDomainDescriptor>;
132
+ resourceMap(options: ResourceMapInputOptions<State> & {
133
+ defaultValue: Record<string, number>;
134
+ }): FormCollector<z.ZodRecord<z.ZodString, z.ZodNumber>, State, ResourceMapDomainDescriptor> & {
135
+ readonly defaultValue: Record<string, number>;
136
+ };
137
+ resourceChoices(options?: {
138
+ decorate?: ResourceMapChoiceDecorator<State>;
139
+ }): ResourceMapChoiceSource<State>;
140
+ number: typeof numberInput<State>;
141
+ choice<Value extends ChoiceValue>(options: {
142
+ choices: ReadonlyArray<DomainChoice<Value>>;
143
+ defaultValue: Value;
144
+ }): FormCollector<SchemaLike<Value>, State, ChoiceDomainDescriptor, Value> & {
145
+ readonly defaultValue: Value;
146
+ };
147
+ choice<Value extends ChoiceValue>(options: {
148
+ choices: DomainChoices<Value, State>;
149
+ defaultValue: Value;
150
+ }): FormCollector<SchemaLike<ChoiceValue>, State, ChoiceDomainDescriptor, Value> & {
151
+ readonly defaultValue: Value;
152
+ };
153
+ choice<Value extends ChoiceValue>(options: {
154
+ choices: ReadonlyArray<DomainChoice<Value>>;
155
+ defaultValue: ChoiceDefaultResolver<Value, State>;
156
+ }): FormCollector<SchemaLike<Value>, State, ChoiceDomainDescriptor, Value>;
157
+ choice<Value extends ChoiceValue>(options: {
158
+ choices: DomainChoices<Value, State>;
159
+ defaultValue: ChoiceDefaultResolver<Value, State>;
160
+ }): FormCollector<SchemaLike<ChoiceValue>, State, ChoiceDomainDescriptor, Value>;
161
+ choiceList<Value extends string>(options: {
162
+ choices: DomainChoices<Value, State>;
163
+ min?: DomainNumber<State>;
164
+ max?: DomainNumber<State>;
165
+ defaultValue: Value[];
166
+ }): ChoiceListCollector<Value, State> & {
167
+ readonly defaultValue: Value[];
168
+ };
169
+ choiceList<Value extends string>(options: {
170
+ choices: DomainChoices<Value, State>;
171
+ min?: DomainNumber<State>;
172
+ max?: DomainNumber<State>;
173
+ defaultValue?: ChoiceListDefaultValue<Value, State>;
174
+ }): ChoiceListCollector<Value, State>;
175
+ };
176
+ declare function formInputForState<State extends CollectorState>(): FormInputForState<State>;
177
+ /**
178
+ * Manifest-backed id input. Free-form Zod schemas are intentionally explicit:
179
+ * if the runtime cannot disclose valid values or numeric bounds through a
180
+ * manifest id or domain helper, use a custom interaction surface with an
181
+ * explicit `paramsSchema` instead of the default form renderer.
182
+ */
183
+ declare const formInput: typeof baseFormInput & {
184
+ resourceMap: typeof resourceMapInput;
185
+ resourceChoices: <State extends CollectorState = CollectorState>(options?: {
186
+ decorate?: ResourceMapChoiceDecorator<State>;
187
+ }) => ResourceMapChoiceSource<State>;
188
+ number: typeof numberInput;
189
+ choice: typeof choiceInput;
190
+ choiceList: typeof choiceListInput;
191
+ forState: typeof formInputForState;
192
+ };
193
+
194
+ type TargetContext<State extends CollectorState, Definitions extends TopologyDefinitions = TopologyDefinitions> = {
195
+ state: State;
196
+ playerId: PlayerIdOfState<State>;
197
+ q: TableQueriesOfState<State, Definitions>;
198
+ };
199
+ type TargetPredicateArgs<State extends CollectorState, Target, Definitions extends TopologyDefinitions = TopologyDefinitions> = TargetContext<State, Definitions> & {
200
+ targetId: Target;
201
+ };
202
+ type TargetPredicate<State extends CollectorState, Target, Definitions extends TopologyDefinitions = TopologyDefinitions> = {
203
+ id: string;
204
+ errorCode: string;
205
+ message?: string;
206
+ test: (args: TargetPredicateArgs<State, Target, Definitions>) => boolean;
207
+ };
208
+
209
+ type BoardTargetPredicate<State extends CollectorState, Target, Definitions extends TopologyDefinitions = TopologyDefinitions> = TargetPredicate<State, Target, Definitions>;
210
+
211
+ type BoardSpaceInputSchema = z.ZodObject<{
212
+ boardId: ManifestIdSchema<string, "boardId">;
213
+ spaceId: z.ZodString;
214
+ }>;
215
+
216
+ type CardTargetPredicate<State extends CollectorState, Id extends string, Definitions extends TopologyDefinitions = TopologyDefinitions> = TargetPredicate<State, Id, Definitions>;
217
+
218
+ type ChoiceTargetOption<Id extends string> = {
219
+ id: Id;
220
+ label?: string;
221
+ };
222
+ type ChoiceOptionsFactory<State extends CollectorState, Id extends string> = (state: State, playerId: PlayerIdOfState<State>, q: TableQueriesOfState<State>) => ReadonlyArray<ChoiceTargetOption<Id>>;
223
+ type ChoiceTargetPredicate<State extends CollectorState, Id extends string> = TargetPredicate<State, Id>;
224
+
225
+ /**
226
+ * `rngInput.*` helpers produce collectors whose value is *sampled by the
227
+ * engine on submit* rather than supplied by the client. The schema pins
228
+ * the exact output shape so `ParamsOf<Collectors>` sees precisely typed
229
+ * results.
230
+ *
231
+ * Determinism:
232
+ * Sampling happens inside `submitInteraction` only, never inside
233
+ * reducer validation. This lets clients check a submission without
234
+ * burning RNG state.
235
+ */
236
+ type DieRoll = z.ZodObject<{
237
+ values: z.ZodArray<z.ZodNumber>;
238
+ }>;
239
+ type CoinFlip = z.ZodObject<{
240
+ value: z.ZodEnum<{
241
+ heads: "heads";
242
+ tails: "tails";
243
+ }>;
244
+ }>;
245
+ type RngCollector<Schema extends DieRoll | CoinFlip, State extends CollectorState> = InputCollector<Schema, State, "rng">;
246
+ /**
247
+ * Roll `count` d6s. The submitted value is `{ values: number[] }` with
248
+ * `values.length === count` and each face `1..6`.
249
+ */
250
+ declare function d6<State extends CollectorState = CollectorState>(count?: number): RngCollector<DieRoll, State>;
251
+ /** Flip a coin. The submitted value is `{ value: "heads" | "tails" }`. */
252
+ declare function coin<State extends CollectorState = CollectorState>(): RngCollector<CoinFlip, State>;
253
+ declare const rngInput: {
254
+ d6: typeof d6;
255
+ coin: typeof coin;
256
+ };
16
257
 
17
258
  type ManyOptions = {
18
259
  count: number;
@@ -25,48 +266,208 @@ type ManyOptions = {
25
266
  type NonRngCollector = InputCollector<SchemaLike<unknown>, CollectorState> & {
26
267
  readonly kind: Exclude<InputCollector["kind"], "rng">;
27
268
  };
28
- type CollectorSchema<Collector extends NonRngCollector> = [Collector] extends [
29
- InputCollector<infer Schema, CollectorState>
30
- ] ? Schema : never;
31
- type CollectorStateOf<Collector extends NonRngCollector> = [Collector] extends [
32
- InputCollector<SchemaLike<unknown>, infer State>
33
- ] ? State : never;
34
- type CollectorKindOf<Collector extends NonRngCollector> = [Collector] extends [
35
- {
36
- readonly kind: infer Kind extends Exclude<InputCollector["kind"], "rng">;
37
- }
38
- ] ? Kind : never;
39
- type ManyInputCollector<Schema extends SchemaLike<unknown> = SchemaLike<unknown>, State extends CollectorState = CollectorState, Kind extends Exclude<InputCollector["kind"], "rng"> = Exclude<InputCollector["kind"], "rng">> = InputCollector<z.ZodArray<Schema>, State, Kind> & {
269
+ /** Lift the value schema while retaining the collector's exact domain and routing. */
270
+ type ManyInputCollector<Collector extends NonRngCollector> = Omit<Collector, "schema" | "selection" | "defaultValue" | "resolveDefaultValue" | keyof CollectorValueWitness<unknown>> & CollectorValueWitness<CollectorValueOf<Collector>[]> & {
271
+ readonly schema: z.ZodArray<Collector["schema"]>;
40
272
  readonly selection: Extract<InputSelectionDescriptor, {
41
273
  mode: "many";
42
274
  }>;
43
275
  };
44
- declare function many<Collector extends NonRngCollector>(collector: Collector, options: ManyOptions): ManyInputCollector<CollectorSchema<Collector>, CollectorStateOf<Collector>, CollectorKindOf<Collector>> & Pick<Collector, "meta">;
276
+ declare function many<Collector extends NonRngCollector>(collector: Collector, options: ManyOptions): ManyInputCollector<Collector>;
45
277
 
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"];
278
+ type TileTargetPredicate<State extends CollectorState, Id extends string, Definitions extends TopologyDefinitions = TopologyDefinitions> = TargetPredicate<State, Id, Definitions>;
279
+
280
+ type AnyReducerGameContract = {
281
+ manifest: ReducerManifestContractLike<RuntimeTableRecord>;
282
+ options: SchemaLike<RuntimeRecord>;
283
+ state: StateDefinition<SchemaLike<object>, SchemaLike<object>, SchemaLike<object>>;
51
284
  };
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"];
285
+ type ContractState<Contract extends AnyReducerGameContract> = BaseGameStateOfContract<Contract>;
286
+ type ContractManifest<Contract extends AnyReducerGameContract> = ManifestContractOf<Contract>;
287
+ type ContractErrorCode<Contract extends AnyReducerGameContract> = ErrorCodeOfContract<Contract>;
288
+
289
+ type ContractWithPhases = AnyReducerGameContract & {
290
+ readonly phases: Record<string, SchemaLike<object>>;
57
291
  };
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"];
292
+ type BoundState<Contract extends ContractWithPhases> = ContractState<Contract>;
293
+ type BoundManifest<Contract extends ContractWithPhases> = ContractManifest<Contract>;
294
+ type BoundTable<Contract extends ContractWithPhases> = TableOfManifest<BoundManifest<Contract>>;
295
+ type BoundPhaseState<Contract extends ContractWithPhases, PhaseStateSchema extends SchemaLike<object>> = ScopedPhaseState<BoundState<Contract>, z$1.infer<PhaseStateSchema>>;
296
+ type BoundFormInputs<Contract extends ContractWithPhases> = ReturnType<typeof formInput.forState<BoundState<Contract>>>;
297
+ /** The selected board owns the element namespace, including generic spaces. */
298
+ type BoundBoardInputOptions<Contract extends ContractWithPhases, BoardId, Id> = {
299
+ boardId: BoardId;
300
+ where?: BoundWhere<Contract, Id>;
301
+ };
302
+ type PlayerBoardBaseId<Contract extends ContractWithPhases> = {
303
+ [B in keyof BoundManifest<Contract>["boardDefinitions"] & string]: BoundManifest<Contract>["boardDefinitions"][B] extends {
304
+ scope: "perPlayer";
305
+ } ? B : never;
306
+ }[keyof BoundManifest<Contract>["boardDefinitions"] & string];
307
+ type PlayerBoardRuntimeId<Table, Base extends string> = Extract<BoardIdOfTable<Table>, PerPlayerInstanceId<"board", Base>>;
308
+ type BoundBoardInputs<Contract extends ContractWithPhases> = {
309
+ vertex<B extends TiledBoardIdOfTable<BoundTable<Contract>, BoundManifest<Contract>>>(options: BoundBoardInputOptions<Contract, B, TiledVertexIdOfTable<BoundTable<Contract>, NoInfer<B>, BoundManifest<Contract>>>): InputCollector<z$1.ZodString, BoundState<Contract>, "board-vertex", TiledVertexIdOfTable<BoundTable<Contract>, B, BoundManifest<Contract>>>;
310
+ edge<B extends TiledBoardIdOfTable<BoundTable<Contract>, BoundManifest<Contract>>>(options: BoundBoardInputOptions<Contract, B, TiledEdgeIdOfTable<BoundTable<Contract>, NoInfer<B>, BoundManifest<Contract>>>): InputCollector<z$1.ZodString, BoundState<Contract>, "board-edge", TiledEdgeIdOfTable<BoundTable<Contract>, B, BoundManifest<Contract>>>;
311
+ space<B extends BoardIdOfTable<BoundTable<Contract>>>(options: BoundBoardInputOptions<Contract, B, SpaceIdOfTable<BoundTable<Contract>, NoInfer<B>, BoundManifest<Contract>>>): InputCollector<z$1.ZodString, BoundState<Contract>, "board-space", SpaceIdOfTable<BoundTable<Contract>, B, BoundManifest<Contract>>>;
312
+ playerSpace<B extends PlayerBoardBaseId<Contract>>(options: {
313
+ boardId: B;
314
+ where?: BoundWhere<Contract, BoardSpaceTarget<PerPlayerInstanceId<"board", NoInfer<B>>, SpaceIdOfTable<BoundTable<Contract>, PlayerBoardRuntimeId<BoundTable<Contract>, NoInfer<B>>, BoundManifest<Contract>>>>;
315
+ }): InputCollector<BoardSpaceInputSchema, BoundState<Contract>, "board-space", BoardSpaceTarget<PerPlayerInstanceId<"board", B>, SpaceIdOfTable<BoundTable<Contract>, PlayerBoardRuntimeId<BoundTable<Contract>, B>, BoundManifest<Contract>>>>;
316
+ };
317
+ /**
318
+ * An eligibility predicate whose `errorCode` is checked against the model's
319
+ * declared error codes. The unbound `TargetPredicate` accepts any string.
320
+ */
321
+ type BoundTargetPredicate<Contract extends ContractWithPhases, Target> = Omit<TargetPredicate<BoundState<Contract>, Target, BoundManifest<Contract>>, "errorCode"> & {
322
+ errorCode: ContractErrorCode<Contract>;
63
323
  };
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>>;
324
+ type BoundWhere<Contract extends ContractWithPhases, Target> = BoundTargetPredicate<Contract, Target> | readonly BoundTargetPredicate<Contract, Target>[];
325
+ type BoundCardCollector<Contract extends ContractWithPhases, Id extends string, ZoneIds extends readonly string[]> = InputCollector<z$1.ZodString, BoundState<Contract>, "card", Id> & {
326
+ readonly meta: {
327
+ readonly zoneId: ZoneIds[number];
328
+ readonly zoneIds: ZoneIds;
329
+ readonly targetKind: "card";
330
+ };
331
+ };
332
+ /**
333
+ * Card collector: the zones to draw candidates from and the predicates that
334
+ * filter them. The target rule is built internally.
335
+ */
336
+ type BoundCardInput<Contract extends ContractWithPhases> = <const ZoneIds extends readonly ZoneIdOfTable<BoundTable<Contract>>[]>(options: {
337
+ from: ZoneIds;
338
+ where?: BoundWhere<Contract, CardIdOfManifest<BoundManifest<Contract>>>;
339
+ }) => BoundCardCollector<Contract, CardIdOfManifest<BoundManifest<Contract>>, ZoneIds>;
340
+ /** Tile instances in authored zones or exact runtime boards. */
341
+ type BoundTileInput<Contract extends ContractWithPhases> = (options: ({
342
+ from: readonly ZoneIdOfTable<BoundTable<Contract>>[];
343
+ boards?: never;
344
+ } | {
345
+ boards: readonly TiledBoardIdOfTable<BoundTable<Contract>, BoundManifest<Contract>>[];
346
+ from?: never;
347
+ }) & {
348
+ where?: BoundWhere<Contract, TileIdOfTable<BoundTable<Contract>>>;
349
+ }) => InputCollector<z$1.ZodType<TileIdOfTable<BoundTable<Contract>>>, BoundState<Contract>, "tile", TileIdOfTable<BoundTable<Contract>>>;
350
+ /**
351
+ * An insertion point in one of the zones, in each host the player may reach.
352
+ * `tx.moveComponentToPosition` places a card there.
353
+ */
354
+ type BoundPositionInput<Contract extends ContractWithPhases> = <const ZoneIds extends readonly ZoneIdOfTable<BoundTable<Contract>>[]>(options: {
355
+ zones: ZoneIds;
356
+ }) => InputCollector<typeof PositionTargetSchema, BoundState<Contract>, "position", PositionTarget<ZoneIds[number]>> & {
357
+ readonly meta: {
358
+ readonly zoneIds: ZoneIds;
359
+ };
360
+ };
361
+ type BoundRngInputs<Contract extends ContractWithPhases> = {
362
+ d6(count?: number): ReturnType<typeof rngInput.d6<BoundState<Contract>>>;
363
+ coin(): ReturnType<typeof rngInput.coin<BoundState<Contract>>>;
364
+ };
365
+ type BoundInputBuilders<Contract extends ContractWithPhases> = {
366
+ readonly board: BoundBoardInputs<Contract>;
367
+ readonly card: BoundCardInput<Contract>;
368
+ readonly position: BoundPositionInput<Contract>;
369
+ readonly tile: BoundTileInput<Contract>;
370
+ readonly form: BoundFormInputs<Contract>;
371
+ readonly rng: BoundRngInputs<Contract>;
372
+ };
373
+ /** Preserve each phase kind's required fields while binding its state schema. */
374
+ type PhaseDefinitionWithoutState<Definition> = Definition extends unknown ? Omit<Definition, "state"> : never;
375
+ type PhaseAuthoring<Contract extends ContractWithPhases, PhaseStateSchema extends SchemaLike<object>> = {
376
+ steps(): InteractionSteps<BoundPhaseState<Contract, PhaseStateSchema>, Record<never, never>, BoundManifest<Contract>>;
377
+ interaction<Collectors extends Record<string, InputCollector>>(spec: Extract<InteractionSpec<Collectors, BoundPhaseState<Contract, PhaseStateSchema>, BoundManifest<Contract>, ContractErrorCode<Contract>>, {
378
+ steps: unknown;
379
+ }>): Extract<InteractionSpec<Collectors, BoundPhaseState<Contract, PhaseStateSchema>, BoundManifest<Contract>, ContractErrorCode<Contract>>, {
380
+ steps: unknown;
381
+ }>;
382
+ interaction<Collectors extends Record<string, InputCollector>>(spec: Extract<InteractionSpec<Collectors, BoundPhaseState<Contract, PhaseStateSchema>, BoundManifest<Contract>, ContractErrorCode<Contract>>, {
383
+ inputs: unknown;
384
+ }>): Extract<InteractionSpec<Collectors, BoundPhaseState<Contract, PhaseStateSchema>, BoundManifest<Contract>, ContractErrorCode<Contract>>, {
385
+ inputs: unknown;
386
+ }>;
387
+ 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>>;
388
+ 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: PhaseDefinitionWithoutState<PhaseDefinition<PhaseStateSchema, BoundState<Contract>, BoundManifest<Contract>, SubmitCollectors, Interactions, OptionsOfContract<Contract>, ContractErrorCode<Contract>>> & {
389
+ kind: Kind;
390
+ }): PhaseDefinition<PhaseStateSchema, BoundState<Contract>, BoundManifest<Contract>, SubmitCollectors, Interactions, OptionsOfContract<Contract>, ContractErrorCode<Contract>> & {
391
+ kind: Kind;
392
+ };
393
+ readonly inputs: BoundInputBuilders<Contract>;
394
+ /** Compile-time only. Reading any member at runtime throws. */
395
+ readonly types: PhaseTypes<Contract, PhaseStateSchema>;
396
+ };
397
+ /**
398
+ * Phantom type carriers for one phase: `typeof playing.types.State` is the
399
+ * phase-scoped game state (`state.phase` narrowed to this phase's schema).
400
+ */
401
+ type PhaseTypes<Contract extends ContractWithPhases, PhaseStateSchema extends SchemaLike<object>> = {
402
+ readonly State: BoundPhaseState<Contract, PhaseStateSchema>;
403
+ readonly PhaseState: z$1.infer<PhaseStateSchema>;
404
+ readonly Tx: ReducerTransaction<BoundPhaseState<Contract, PhaseStateSchema>, ContractErrorCode<Contract>, BoundManifest<Contract>>;
405
+ };
406
+ /**
407
+ * Phantom type carriers for the whole game. These replace the
408
+ * `GameStateOf<GameContractOf<typeof model>>` chain: a module that has the
409
+ * bound game value can write `typeof game.types.State` and stop there.
410
+ */
411
+ type ContractTypes<Contract extends ContractWithPhases> = {
412
+ readonly Contract: Contract;
413
+ readonly Options: OptionsOfContract<Contract>;
414
+ readonly State: BoundState<Contract>;
415
+ readonly Manifest: BoundManifest<Contract>;
416
+ readonly ErrorCode: ContractErrorCode<Contract>;
417
+ readonly PlayerId: PlayerIdOfState<BoundState<Contract>>;
418
+ readonly Queries: TableQueriesOfState<BoundState<Contract>, BoundManifest<Contract>>;
419
+ readonly Tx: ReducerTransaction<BoundState<Contract>, ContractErrorCode<Contract>, BoundManifest<Contract>>;
420
+ };
421
+ type GameAuthoring<Contract extends ContractWithPhases> = {
422
+ readonly contract: Contract;
423
+ view<Projection extends ViewData>(view: ViewDefinition<BoundState<Contract>, BoundManifest<Contract>, Projection>): ViewDefinition<BoundState<Contract>, BoundManifest<Contract>, Projection>;
424
+ /** Compile-time only. Reading any member at runtime throws. */
425
+ readonly types: ContractTypes<Contract>;
426
+ /** Assemble the final game definition from phases and the seat view. */
427
+ assemble<Definitions extends PhaseMapOf<Contract>, View extends ViewOfContract<Contract>>(definition: ReducerGameDefinitionInput<Contract, Definitions, View>): ReducerGameDefinition<Contract, Definitions, View>;
428
+ phase<Name extends keyof Contract["phases"] & string>(name: Name): PhaseAuthoring<Contract, Contract["phases"][Name]>;
68
429
  };
69
430
 
431
+ /**
432
+ * Narrows a manifest's `literals.phaseNames` and `ids.phaseName` to the
433
+ * author-supplied phase-name tuple. Lets `defineGameContract` override the
434
+ * codegen-emitted `phaseNames: readonly string[]` / `phaseName: z.string()`
435
+ * placeholders so `PhaseNameOfContract<Contract>` resolves to a literal
436
+ * union and flows through `tx.transition`, `PhaseMapOf`, and the flow
437
+ * state's `currentPhase`.
438
+ */
439
+ type NarrowManifestPhaseNames<Manifest, PhaseNames extends readonly string[]> = Manifest & {
440
+ literals: Manifest extends {
441
+ literals: infer L;
442
+ } ? Omit<L, "phaseNames"> & {
443
+ phaseNames: PhaseNames;
444
+ } : {
445
+ phaseNames: PhaseNames;
446
+ };
447
+ ids: Manifest extends {
448
+ ids: infer I;
449
+ } ? Omit<I, "phaseName"> & {
450
+ phaseName: z.ZodType<PhaseNames[number]>;
451
+ } : {
452
+ phaseName: z.ZodType<PhaseNames[number]>;
453
+ };
454
+ };
455
+ type ReducerGameContractInput<Table extends RuntimeTableRecord, Manifest extends ReducerManifestContract<Table, 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> = SchemaLike<Record<string, never>>> = {
456
+ manifest: Manifest;
457
+ state: StateDefinition<PublicSchema, PrivateSchema, HiddenSchema>;
458
+ phases: Phases;
459
+ errors?: Errors;
460
+ options?: OptionsSchema;
461
+ };
462
+ type DefinedGameContract<Table extends RuntimeTableRecord, Manifest extends ReducerManifestContract<Table, 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> = SchemaLike<Record<string, never>>> = ReducerGameContract<Table, NarrowManifestPhaseNames<Manifest, readonly (keyof Phases & string)[]>, PublicSchema, PrivateSchema, HiddenSchema, Phases, Errors, OptionsSchema> & {
463
+ readonly phases: Phases;
464
+ readonly errors: Errors;
465
+ readonly phaseNames: readonly (keyof Phases & string)[];
466
+ };
467
+
468
+ /** Bind a compiler-produced manifest to state schemas, phases and game assembly. */
469
+ declare function createGame<Table extends RuntimeTableRecord, const Manifest extends ReducerManifestContract<Table, string, string, string, string> & CompiledManifestWitness<CompiledManifest<unknown>>, 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> = SchemaLike<Record<string, never>>>(model: ReducerGameContractInput<Table, Manifest, PublicSchema, PrivateSchema, HiddenSchema, Phases, Errors, OptionsSchema>): GameAuthoring<DefinedGameContract<Table, Manifest, PublicSchema, PrivateSchema, HiddenSchema, Phases, Errors, OptionsSchema>>;
470
+
70
471
  declare const gameEvent: {
71
472
  systemAction(event: Omit<SystemActionEvent, "kind">): SystemActionEvent;
72
473
  };
@@ -77,71 +478,601 @@ declare function sparseMap<KeySchema extends z.ZodType<string>, ValueSchema exte
77
478
  declare function sparseCounts<KeySchema extends z.ZodType<string>>(keySchema: KeySchema): z.ZodType<SparseCounts<z.infer<KeySchema>>>;
78
479
  declare function normalizeCommandParams<Output>(schema: SchemaLike<Output>, input: unknown): Output;
79
480
 
80
- declare function createTableQueries<Table extends RuntimeTableRecord>(table: Table): TableQueries<Table>;
81
- declare function createStateQueries<State extends {
82
- table: RuntimeTableRecord;
83
- }>(state: State): TableQueriesOfState<State>;
84
-
85
481
  type InteractionDiagnosticsMode = "verbose" | undefined;
86
482
 
87
483
  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
484
  diagnostics?: ReducerDiagnosticsSink | InteractionDiagnosticsMode;
96
485
  descriptorDiagnostics?: InteractionDiagnosticsMode;
97
486
  };
98
487
  type ReducerBundle = ReducerBundleContract;
99
488
 
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;
489
+ /** The single validated production execution and projection boundary. */
490
+ declare function createReducerBundle<Contract extends ReducerGameContractLike, Definitions extends PhaseMapOf<Contract>, View extends ViewOfContract<Contract>>(definition: ReducerGameDefinition<Contract, Definitions, View>, options?: ReducerBundleOptions): ReducerBundle;
491
+
492
+ /** Cache a pure calculation by immutable object identity. Do not pass a mutable draft. */
493
+ declare function memoize<A extends object, R>(fn: (a: A) => R): (a: A) => R;
102
494
 
103
- type FingerprintableContract = ReducerGameContractLike & {
104
- phases?: Record<string, z.ZodTypeAny>;
105
- errors?: Record<string, string> | undefined;
495
+ declare function createTableQueries<Table extends RuntimeQueryTable, Definitions extends ZoneDefinitions>(table: Table, definitions: Definitions): TableQueries<Table, Definitions>;
496
+ declare function createStateQueries<State extends {
497
+ table: RuntimeQueryTable;
498
+ }, Definitions extends ZoneDefinitions>(state: State, definitions: Definitions): TableQueriesOfState<State, Definitions>;
499
+
500
+ type GameTopologyManifest = SchemaAuthoring<GameTopologyManifest$1>;
501
+ type ArrayItem<T> = T extends readonly (infer Item)[] ? Item : never;
502
+ type EntryId<T> = T extends {
503
+ id: infer Id extends string;
504
+ } ? Id : never;
505
+ type IdsOf<T> = EntryId<ArrayItem<NonNullable<T>>>;
506
+ type CardSetId<Manifest extends GameTopologyManifest> = IdsOf<Manifest["cardSets"]>;
507
+ type BoardId<Manifest extends GameTopologyManifest> = IdsOf<Manifest["boards"]>;
508
+ type PerPlayerBoardId<Manifest extends GameTopologyManifest> = EntryId<Extract<ArrayItem<NonNullable<Manifest["boards"]>>, {
509
+ scope: "perPlayer";
510
+ }>>;
511
+ type SharedBoardId<Manifest extends GameTopologyManifest> = Exclude<BoardId<Manifest>, PerPlayerBoardId<Manifest>>;
512
+ type PieceTypeId<Manifest extends GameTopologyManifest> = IdsOf<Manifest["pieceTypes"]>;
513
+ type DieTypeId<Manifest extends GameTopologyManifest> = IdsOf<Manifest["dieTypes"]>;
514
+ type PieceSeedOf<Manifest extends GameTopologyManifest> = ArrayItem<NonNullable<Manifest["pieceSeeds"]>>;
515
+ type DieSeedOf<Manifest extends GameTopologyManifest> = ArrayItem<NonNullable<Manifest["dieSeeds"]>>;
516
+ type BoardOf<Manifest extends GameTopologyManifest, CurrentBoardId extends BoardId<Manifest>> = Extract<ArrayItem<NonNullable<Manifest["boards"]>>, {
517
+ id: CurrentBoardId;
518
+ }>;
519
+ type SpaceIdOf<BoardLike, Manifest> = BoardLike extends {
520
+ layout: "hex" | "square";
521
+ } ? TileSpaceIds<Manifest, BoardLike["layout"]> : IdsOf<BoardLike extends {
522
+ spaces?: infer Spaces;
523
+ } ? Spaces : never>;
524
+ type SpaceIdForBoard<Manifest extends GameTopologyManifest, CurrentBoardId extends BoardId<Manifest>> = SpaceIdOf<BoardOf<Manifest, CurrentBoardId>, Manifest>;
525
+ type PieceTypeOf<Manifest extends GameTopologyManifest, T extends PieceTypeId<Manifest>> = Extract<ArrayItem<NonNullable<Manifest["pieceTypes"]>>, {
526
+ id: T;
527
+ }>;
528
+ type DieTypeOf<Manifest extends GameTopologyManifest, T extends DieTypeId<Manifest>> = Extract<ArrayItem<NonNullable<Manifest["dieTypes"]>>, {
529
+ id: T;
530
+ }>;
531
+ type TypedSharedSpaceHomeSpec<Manifest extends GameTopologyManifest> = {
532
+ [CurrentBoardId in SharedBoardId<Manifest>]: {
533
+ type: "space";
534
+ boardId: CurrentBoardId;
535
+ spaceId: SpaceIdForBoard<Manifest, CurrentBoardId>;
536
+ };
537
+ }[SharedBoardId<Manifest>];
538
+ type TypedPerPlayerSpaceHomeSpec<Manifest extends GameTopologyManifest> = {
539
+ [CurrentBoardId in PerPlayerBoardId<Manifest>]: {
540
+ type: "space";
541
+ boardId: CurrentBoardId;
542
+ spaceId: SpaceIdForBoard<Manifest, CurrentBoardId>;
543
+ };
544
+ }[PerPlayerBoardId<Manifest>];
545
+ type TypedSharedEdgeHomeSpec<Manifest extends GameTopologyManifest> = {
546
+ [CurrentBoardId in SharedBoardId<Manifest>]: {
547
+ type: "edge";
548
+ boardId: CurrentBoardId;
549
+ ref: SchemaAuthoring<BoardEdgeRef>;
550
+ };
551
+ }[SharedBoardId<Manifest>];
552
+ type TypedPerPlayerEdgeHomeSpec<Manifest extends GameTopologyManifest> = {
553
+ [CurrentBoardId in PerPlayerBoardId<Manifest>]: {
554
+ type: "edge";
555
+ boardId: CurrentBoardId;
556
+ ref: SchemaAuthoring<BoardEdgeRef>;
557
+ };
558
+ }[PerPlayerBoardId<Manifest>];
559
+ type TypedSharedVertexHomeSpec<Manifest extends GameTopologyManifest> = {
560
+ [CurrentBoardId in SharedBoardId<Manifest>]: {
561
+ type: "vertex";
562
+ boardId: CurrentBoardId;
563
+ ref: SchemaAuthoring<BoardVertexRef>;
564
+ };
565
+ }[SharedBoardId<Manifest>];
566
+ type TypedPerPlayerVertexHomeSpec<Manifest extends GameTopologyManifest> = {
567
+ [CurrentBoardId in PerPlayerBoardId<Manifest>]: {
568
+ type: "vertex";
569
+ boardId: CurrentBoardId;
570
+ ref: SchemaAuthoring<BoardVertexRef>;
571
+ };
572
+ }[PerPlayerBoardId<Manifest>];
573
+ type ExpandedSeedId<Seed> = Seed extends {
574
+ typeId: infer T extends string;
575
+ } ? RuntimeIdsFromCount<Seed extends {
576
+ id: infer I extends string;
577
+ } ? I : T, Seed extends {
578
+ count: infer C;
579
+ } ? C : never> : never;
580
+ type ZoneHomeFor<Zone, Manifest extends GameTopologyManifest, Shared extends boolean> = Zone extends {
581
+ id: infer Z extends string;
582
+ } ? Zone extends {
583
+ scope: "shared";
584
+ } ? {
585
+ type: "zone";
586
+ zoneId: Z;
587
+ component?: never;
588
+ } : Zone extends {
589
+ scope: "perPlayer";
590
+ } ? Shared extends true ? never : {
591
+ type: "zone";
592
+ zoneId: Z;
593
+ component?: never;
594
+ } : Zone extends {
595
+ attachedTo: {
596
+ board: infer B;
597
+ };
598
+ } ? B extends SharedBoardId<Manifest> ? {
599
+ type: "zone";
600
+ zoneId: Z;
601
+ component?: never;
602
+ } : Shared extends true ? never : {
603
+ type: "zone";
604
+ zoneId: Z;
605
+ component?: never;
606
+ } : Zone extends {
607
+ attachedTo: {
608
+ pieceType: infer T;
609
+ };
610
+ } ? ComponentZoneHome<Z, Extract<PieceSeedOf<Manifest>, {
611
+ typeId: T;
612
+ }>, Shared> : Zone extends {
613
+ attachedTo: {
614
+ dieType: infer T;
615
+ };
616
+ } ? ComponentZoneHome<Z, Extract<DieSeedOf<Manifest>, {
617
+ typeId: T;
618
+ }>, Shared> : Zone extends {
619
+ attachedTo: {
620
+ tileType: infer T;
621
+ };
622
+ } ? ComponentZoneHome<Z, Extract<ArrayItem<Manifest["tileSeeds"]>, {
623
+ typeId: T;
624
+ }>, Shared> : never : never;
625
+ type ComponentZoneHome<Z extends string, Seed, Shared extends boolean> = (Shared extends true ? Exclude<Seed, {
626
+ scope: "perPlayer";
627
+ }> : Seed) extends infer Host ? Host extends object ? {
628
+ type: "zone";
629
+ zoneId: Z;
630
+ component: ExpandedSeedId<Host>;
631
+ } : never : never;
632
+ type TypedSharedZoneHomeSpec<Manifest extends GameTopologyManifest> = ZoneHomeFor<ArrayItem<NonNullable<Manifest["zones"]>>, Manifest, true>;
633
+ type TypedPerPlayerZoneHomeSpec<Manifest extends GameTopologyManifest> = ZoneHomeFor<ArrayItem<NonNullable<Manifest["zones"]>>, Manifest, false>;
634
+ type TypedPlayerScopedComponentHomeSpec<Manifest extends GameTopologyManifest> = TypedPerPlayerZoneHomeSpec<Manifest> | TypedPerPlayerSpaceHomeSpec<Manifest> | TypedPerPlayerEdgeHomeSpec<Manifest> | TypedPerPlayerVertexHomeSpec<Manifest>;
635
+ type TypedSharedComponentHomeSpec<Manifest extends GameTopologyManifest> = {
636
+ type: "detached";
637
+ } | TypedSharedZoneHomeSpec<Manifest> | TypedSharedSpaceHomeSpec<Manifest> | TypedSharedEdgeHomeSpec<Manifest> | TypedSharedVertexHomeSpec<Manifest>;
638
+ type TypedComponentHomeSpec<Manifest extends GameTopologyManifest> = TypedSharedComponentHomeSpec<Manifest> | TypedPlayerScopedComponentHomeSpec<Manifest>;
639
+ type TypedSeedLocationSpec<Seed, Manifest extends GameTopologyManifest> = Omit<Seed, "home"> & {
640
+ home?: Seed extends {
641
+ scope: "perPlayer";
642
+ } ? TypedComponentHomeSpec<Manifest> : TypedSharedComponentHomeSpec<Manifest>;
643
+ };
644
+ type AuthoredComponent<T> = Omit<T, "ownerId" | "visibility"> & {
645
+ ownerId?: never;
646
+ visibility?: {
647
+ faceUp?: boolean;
648
+ visibleTo?: never;
649
+ };
106
650
  };
107
- type FingerprintableDefinition = {
108
- contract: FingerprintableContract;
109
- phases?: Record<string, z.ZodTypeAny | {
110
- state?: z.ZodTypeAny;
651
+ type TypedFields<T, Schema, Manifest extends GameTopologyManifest, BoardLike = never> = T extends {
652
+ fields?: unknown;
653
+ } ? Omit<T, "fields"> & {
654
+ fields?: FieldsInput<Schema, Manifest, BoardLike>;
655
+ } : T;
656
+ type TypedBoardRelation<Relation, Manifest extends GameTopologyManifest, BoardLike, RelationSchema> = Relation extends object ? Omit<TypedFields<Relation, RelationSchema, Manifest, BoardLike>, "fromSpaceId" | "toSpaceId"> & {
657
+ fromSpaceId: SpaceIdOf<BoardLike, Manifest>;
658
+ toSpaceId: SpaceIdOf<BoardLike, Manifest>;
659
+ } : Relation;
660
+ type TypedOptionalArray<Base, Source, Key extends string, Item> = Source extends {
661
+ [Property in Key]?: readonly unknown[];
662
+ } ? Base & {
663
+ [Property in Key]?: ReadonlyArray<Item>;
664
+ } : Base;
665
+ type SchemaForEntry<Entry, Key extends string> = Key extends keyof Entry ? Entry[Key] : undefined;
666
+ type TypedGenericBoardLike<Entry, Manifest extends GameTopologyManifest, BoardLike> = TypedOptionalArray<TypedOptionalArray<TypedFields<Omit<Entry, "spaces" | "relations">, SchemaForEntry<Entry, "boardFieldsSchema">, Manifest, BoardLike>, Entry, "spaces", TypedFields<ArrayItem<NonNullable<Entry extends {
667
+ spaces?: infer S;
668
+ } ? S : never>>, SchemaForEntry<Entry, "spaceFieldsSchema">, Manifest, BoardLike>>, Entry, "relations", TypedBoardRelation<ArrayItem<NonNullable<Entry extends {
669
+ relations?: infer R;
670
+ } ? R : never>>, Manifest, BoardLike, SchemaForEntry<Entry, "relationFieldsSchema">>>;
671
+ type AuthoredKeys<T> = {
672
+ [K in keyof T]-?: Record<never, never> extends Pick<T, K> ? [Exclude<T[K], undefined>] extends [never] ? never : K : K;
673
+ }[keyof T];
674
+ type TypedBoardLikeEntry<Entry, Manifest extends GameTopologyManifest> = "containers" | "containerFieldsSchema" | "shape" | "exclude" | "edges" | "vertices" | "edgeFieldsSchema" | "vertexFieldsSchema" extends infer Legacy ? Extract<Legacy, AuthoredKeys<Entry>> extends never ? Entry extends {
675
+ layout: "generic";
676
+ } ? TypedGenericBoardLike<Entry, Manifest, Entry> : "spaces" | "spaceFieldsSchema" extends infer Geometry ? Extract<Geometry, AuthoredKeys<Entry>> extends never ? TypedFields<Entry, SchemaForEntry<Entry, "boardFieldsSchema">, Manifest, Entry> : never : never : never : never;
677
+ type AuthoredCardType<Card> = Card extends {
678
+ cardType: infer Category extends string;
679
+ } ? Category : never;
680
+ type TypedCard<Card, Manifest extends GameTopologyManifest, CardSchema> = Card extends {
681
+ id: string;
682
+ cardType: string;
683
+ } ? Omit<AuthoredComponent<Card>, "home" | "properties"> & {
684
+ home?: Card extends {
685
+ scope: "perPlayer";
686
+ } ? TypedComponentHomeSpec<Manifest> : TypedSharedComponentHomeSpec<Manifest>;
687
+ properties: CardSchema extends {
688
+ byCardType: infer Variants extends Record<string, unknown>;
689
+ } ? AuthoredCardType<Card> extends keyof Variants ? FieldsInput<Variants[AuthoredCardType<Card>], Manifest> : never : FieldsInput<CardSchema, Manifest>;
690
+ } : Card;
691
+ type TypedCardSet<CardSet, Manifest extends GameTopologyManifest> = CardSet extends {
692
+ cardSchema: infer CardSchema;
693
+ cards: infer Cards extends readonly unknown[];
694
+ } ? Omit<CardSet, "cards" | "defaultHome"> & {
695
+ defaultHome: TypedComponentHomeSpec<Manifest>;
696
+ cards: ReadonlyArray<TypedCard<ArrayItem<Cards>, Manifest, CardSchema>>;
697
+ } : CardSet;
698
+ type TypedAllowedCardSetIds<T, Manifest extends GameTopologyManifest> = T extends object ? Omit<T, "allowedCardSetIds"> & {
699
+ allowedCardSetIds?: readonly CardSetId<Manifest>[];
700
+ } : T;
701
+ type TypedZone<Zone, Manifest extends GameTopologyManifest> = TypedAllowedCardSetIds<Zone, Manifest> & (Zone extends {
702
+ attachedTo: infer A;
703
+ } ? {
704
+ attachedTo: A extends {
705
+ board: infer B;
706
+ } ? B extends BoardId<Manifest> ? A extends {
707
+ space: unknown;
708
+ } ? BoardOf<Manifest, B> extends {
709
+ layout: "generic";
710
+ } ? {
711
+ board: B;
712
+ space: SpaceIdForBoard<Manifest, B>;
713
+ } : never : {
714
+ board: B;
715
+ } : never : A extends {
716
+ pieceType: unknown;
717
+ } ? {
718
+ pieceType: PieceTypeId<Manifest>;
719
+ } : A extends {
720
+ dieType: unknown;
721
+ } ? {
722
+ dieType: DieTypeId<Manifest>;
723
+ } : A extends {
724
+ tileType: infer T;
725
+ } ? {
726
+ tileType: T;
727
+ cell: IdsOf<Extract<ArrayItem<Manifest["tileTypes"]>, {
728
+ id: T;
729
+ }>["cells"]>;
730
+ } : never;
731
+ } : unknown);
732
+ type TypedPieceSeed<Seed, Manifest extends GameTopologyManifest> = Seed extends {
733
+ typeId: infer CurrentTypeId;
734
+ } ? CurrentTypeId extends PieceTypeId<Manifest> ? Omit<TypedSeedLocationSpec<AuthoredComponent<Seed>, Manifest>, "typeId" | "home" | "fields"> & {
735
+ typeId: CurrentTypeId;
736
+ fields?: FieldsInput<PieceTypeOf<Manifest, CurrentTypeId> extends {
737
+ fieldsSchema?: infer FieldsSchema;
738
+ } ? FieldsSchema : undefined, Manifest>;
739
+ } & Pick<TypedSeedLocationSpec<AuthoredComponent<Seed>, Manifest>, "home"> : Omit<Seed, "typeId"> & {
740
+ typeId: PieceTypeId<Manifest>;
741
+ } : never;
742
+ type TypedDieSeed<Seed, Manifest extends GameTopologyManifest> = Seed extends {
743
+ typeId: infer CurrentTypeId;
744
+ } ? CurrentTypeId extends DieTypeId<Manifest> ? Omit<TypedSeedLocationSpec<AuthoredComponent<Seed>, Manifest>, "typeId" | "home" | "fields"> & {
745
+ typeId: CurrentTypeId;
746
+ fields?: FieldsInput<DieTypeOf<Manifest, CurrentTypeId> extends {
747
+ fieldsSchema?: infer FieldsSchema;
748
+ } ? FieldsSchema : undefined, Manifest>;
749
+ } & Pick<TypedSeedLocationSpec<AuthoredComponent<Seed>, Manifest>, "home"> : Omit<Seed, "typeId"> & {
750
+ typeId: DieTypeId<Manifest>;
751
+ } : never;
752
+ type TileTypeId<Manifest extends GameTopologyManifest> = IdsOf<Manifest["tileTypes"]>;
753
+ type TypedTileType<T, Manifest extends GameTopologyManifest> = T extends object ? Omit<TypedFields<T, SchemaForEntry<T, "fieldsSchema">, Manifest>, "cells" | "edges" | "vertices"> & {
754
+ cells: ReadonlyArray<TypedFields<ArrayItem<T extends {
755
+ cells: infer C;
756
+ } ? C : never>, SchemaForEntry<T, "cellFieldsSchema">, Manifest>>;
757
+ edges?: ReadonlyArray<TypedFields<ArrayItem<T extends {
758
+ edges?: infer E;
759
+ } ? E : never>, SchemaForEntry<T, "edgeFieldsSchema">, Manifest> & {
760
+ cellId: IdsOf<T extends {
761
+ cells: infer C;
762
+ } ? C : never>;
111
763
  }>;
764
+ vertices?: ReadonlyArray<TypedFields<ArrayItem<T extends {
765
+ vertices?: infer V;
766
+ } ? V : never>, SchemaForEntry<T, "vertexFieldsSchema">, Manifest> & {
767
+ cellId: IdsOf<T extends {
768
+ cells: infer C;
769
+ } ? C : never>;
770
+ }>;
771
+ } : never;
772
+ type TileBoardHome<Seed, Manifest extends GameTopologyManifest, T> = ArrayItem<Manifest["boards"]> extends infer B ? B extends {
773
+ id: infer I;
774
+ layout: infer L extends "hex" | "square";
775
+ } ? Extract<ArrayItem<Manifest["tileTypes"]>, {
776
+ id: T;
777
+ }> extends {
778
+ layout: L;
779
+ } ? Seed extends {
780
+ scope: "perPlayer";
781
+ } ? TileBoardCoordinates<L> & {
782
+ type: "board";
783
+ boardId: I;
784
+ layout: L;
785
+ } : B extends {
786
+ scope: "shared";
787
+ } ? TileBoardCoordinates<L> & {
788
+ type: "board";
789
+ boardId: I;
790
+ layout: L;
791
+ } : never : never : never : never;
792
+ type TileBoardCoordinates<L> = L extends "hex" ? {
793
+ q: number;
794
+ r: number;
795
+ rotation: 0 | 1 | 2 | 3 | 4 | 5;
796
+ } : {
797
+ col: number;
798
+ row: number;
799
+ rotation: 0 | 1 | 2 | 3;
112
800
  };
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
- };
801
+ type TypedTileSeed<Seed, Manifest extends GameTopologyManifest> = Seed extends {
802
+ typeId: infer T;
803
+ } ? Omit<Seed, "typeId" | "properties" | "home" | "ownerId" | "visibility" | "disclosure"> & {
804
+ ownerId?: never;
805
+ visibility?: never;
806
+ disclosure?: SchemaAuthoring<AuthoredTileDisclosure>;
807
+ typeId: TileTypeId<Manifest>;
808
+ properties?: FieldsInput<SchemaForEntry<Extract<ArrayItem<Manifest["tileTypes"]>, {
809
+ id: T;
810
+ }>, "propertiesSchema">, Manifest>;
811
+ home?: {
812
+ type: "detached";
813
+ } | TileBoardHome<Seed, Manifest, T> | ZoneHomeFor<ArrayItem<NonNullable<Manifest["zones"]>>, Manifest, Seed extends {
814
+ scope: "perPlayer";
815
+ } ? false : true>;
816
+ } : never;
817
+ type TypedTopologyManifest<Manifest extends GameTopologyManifest> = Omit<Manifest, "cardSets" | "zones" | "boards" | "pieceTypes" | "dieTypes" | "pieceSeeds" | "dieSeeds" | "tileTypes" | "tileSeeds"> & {
818
+ tileTypes?: ReadonlyArray<TypedTileType<ArrayItem<Manifest["tileTypes"]>, Manifest>>;
819
+ tileSeeds?: ReadonlyArray<TypedTileSeed<ArrayItem<Manifest["tileSeeds"]>, Manifest>>;
820
+ pieceTypes?: ReadonlyArray<ArrayItem<Manifest["pieceTypes"]> extends infer T ? "slots" extends keyof T ? never : T : never>;
821
+ dieTypes?: ReadonlyArray<ArrayItem<Manifest["dieTypes"]> extends infer T ? "slots" extends keyof T ? never : T : never>;
822
+ cardSets: ReadonlyArray<TypedCardSet<ArrayItem<Manifest["cardSets"]>, Manifest>>;
823
+ zones?: Manifest["zones"] extends readonly unknown[] ? ReadonlyArray<TypedZone<ArrayItem<Manifest["zones"]>, Manifest>> : Manifest["zones"];
824
+ boards?: Manifest["boards"] extends readonly unknown[] ? ReadonlyArray<TypedBoardLikeEntry<ArrayItem<Manifest["boards"]>, Manifest>> : Manifest["boards"];
825
+ pieceSeeds?: Manifest["pieceSeeds"] extends readonly unknown[] ? ReadonlyArray<TypedPieceSeed<ArrayItem<Manifest["pieceSeeds"]>, Manifest>> : Manifest["pieceSeeds"];
826
+ dieSeeds?: Manifest["dieSeeds"] extends readonly unknown[] ? ReadonlyArray<TypedDieSeed<ArrayItem<Manifest["dieSeeds"]>, Manifest>> : Manifest["dieSeeds"];
125
827
  };
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;
828
+ type TopologyManifestValidation<Manifest> = Manifest extends GameTopologyManifest ? TypedTopologyManifest<Manifest> : GameTopologyManifest;
829
+ declare function defineTopologyManifest<const Manifest>(manifest: Manifest & TopologyManifestValidation<NoInfer<Manifest>> & ManifestCountValidation<NoInfer<Manifest>>): ValidatedManifest<Manifest>;
830
+
831
+ type JsonManifestInput = ReadonlyRuntimeData<GameTopologyManifest$1>;
832
+ type ManifestDocumentInput = AuthoredManifest | ValidatedManifest | JsonManifestInput;
833
+ type ManifestAdmission<M> = [M] extends [ValidatedManifest<unknown>] ? unknown : [M] extends [ManifestDocumentInput] ? AuthoredManifest extends M ? unknown : M extends AuthoredManifest ? TypedTopologyManifest<M> : unknown : ManifestDocumentInput;
834
+ type ManifestInput<M> = M & ManifestCountValidation<NoInfer<M>> & ManifestAdmission<NoInfer<M>>;
835
+ /** Compile authored topology once, in memory, with the same validation used by initialization. */
836
+ declare function compileManifest<const M>(manifest: ManifestInput<M>): CompiledManifest<AuthoredOf<M>>;
135
837
 
136
- 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;
838
+ /** Admit an external JSON document using the SDK's structural and semantic contract. */
839
+ declare function parseTopologyManifestJson(value: unknown): GameTopologyManifest$1;
137
840
 
138
- declare function setActivePlayers<State extends {
139
- flow: {
140
- activePlayers: PlayerIdOfState<State>[];
841
+ type Coordinate = {
842
+ readonly q: number;
843
+ readonly r: number;
844
+ };
845
+ type TileIdentity = {
846
+ readonly boardId: string;
847
+ readonly tileTypeId: string;
848
+ readonly tileId: string;
849
+ readonly name?: string;
850
+ };
851
+ type CoordinateCell<C extends Coordinate> = C extends Coordinate ? {
852
+ id: `${C["q"]},${C["r"]}`;
853
+ at: {
854
+ q: C["q"];
855
+ r: C["r"];
141
856
  };
142
- }>(state: State, activePlayers: PlayerIdOfState<State>[]): State;
857
+ } : never;
858
+ /** Fixed boards use the same definitions and seeded placements as movable inventory. */
859
+ declare function fromCoordinates<const Options extends TileIdentity & {
860
+ readonly coordinates: readonly Coordinate[];
861
+ }>(options: Options): {
862
+ tileTypes: {
863
+ id: Options["tileTypeId"];
864
+ name: string;
865
+ layout: "hex";
866
+ cells: CoordinateCell<Options["coordinates"][number]>[];
867
+ }[];
868
+ tileSeeds: {
869
+ id: Options["tileId"];
870
+ typeId: Options["tileTypeId"];
871
+ home: {
872
+ type: "board";
873
+ boardId: Options["boardId"];
874
+ layout: "hex";
875
+ q: number;
876
+ r: number;
877
+ rotation: 0;
878
+ };
879
+ }[];
880
+ };
881
+ type RadiusOptions = TileIdentity & {
882
+ readonly radius: number;
883
+ readonly center?: Coordinate;
884
+ };
885
+ declare function hexagon<const Options extends RadiusOptions>(options: Options): {
886
+ tileTypes: {
887
+ id: (Options & {
888
+ readonly coordinates: {
889
+ q: number;
890
+ r: number;
891
+ }[];
892
+ })["tileTypeId"];
893
+ name: string;
894
+ layout: "hex";
895
+ cells: CoordinateCell<(Options & {
896
+ readonly coordinates: {
897
+ q: number;
898
+ r: number;
899
+ }[];
900
+ })["coordinates"][number]>[];
901
+ }[];
902
+ tileSeeds: {
903
+ id: (Options & {
904
+ readonly coordinates: {
905
+ q: number;
906
+ r: number;
907
+ }[];
908
+ })["tileId"];
909
+ typeId: (Options & {
910
+ readonly coordinates: {
911
+ q: number;
912
+ r: number;
913
+ }[];
914
+ })["tileTypeId"];
915
+ home: {
916
+ type: "board";
917
+ boardId: (Options & {
918
+ readonly coordinates: {
919
+ q: number;
920
+ r: number;
921
+ }[];
922
+ })["boardId"];
923
+ layout: "hex";
924
+ q: number;
925
+ r: number;
926
+ rotation: 0;
927
+ };
928
+ }[];
929
+ };
930
+ declare function spiral<const Options extends RadiusOptions>(options: Options): {
931
+ tileTypes: {
932
+ id: (Options & {
933
+ readonly coordinates: {
934
+ q: number;
935
+ r: number;
936
+ }[];
937
+ })["tileTypeId"];
938
+ name: string;
939
+ layout: "hex";
940
+ cells: CoordinateCell<(Options & {
941
+ readonly coordinates: {
942
+ q: number;
943
+ r: number;
944
+ }[];
945
+ })["coordinates"][number]>[];
946
+ }[];
947
+ tileSeeds: {
948
+ id: (Options & {
949
+ readonly coordinates: {
950
+ q: number;
951
+ r: number;
952
+ }[];
953
+ })["tileId"];
954
+ typeId: (Options & {
955
+ readonly coordinates: {
956
+ q: number;
957
+ r: number;
958
+ }[];
959
+ })["tileTypeId"];
960
+ home: {
961
+ type: "board";
962
+ boardId: (Options & {
963
+ readonly coordinates: {
964
+ q: number;
965
+ r: number;
966
+ }[];
967
+ })["boardId"];
968
+ layout: "hex";
969
+ q: number;
970
+ r: number;
971
+ rotation: 0;
972
+ };
973
+ }[];
974
+ };
975
+ declare function ring<const Options extends RadiusOptions>(options: Options): {
976
+ tileTypes: {
977
+ id: (Options & {
978
+ readonly coordinates: {
979
+ q: number;
980
+ r: number;
981
+ }[];
982
+ })["tileTypeId"];
983
+ name: string;
984
+ layout: "hex";
985
+ cells: CoordinateCell<(Options & {
986
+ readonly coordinates: {
987
+ q: number;
988
+ r: number;
989
+ }[];
990
+ })["coordinates"][number]>[];
991
+ }[];
992
+ tileSeeds: {
993
+ id: (Options & {
994
+ readonly coordinates: {
995
+ q: number;
996
+ r: number;
997
+ }[];
998
+ })["tileId"];
999
+ typeId: (Options & {
1000
+ readonly coordinates: {
1001
+ q: number;
1002
+ r: number;
1003
+ }[];
1004
+ })["tileTypeId"];
1005
+ home: {
1006
+ type: "board";
1007
+ boardId: (Options & {
1008
+ readonly coordinates: {
1009
+ q: number;
1010
+ r: number;
1011
+ }[];
1012
+ })["boardId"];
1013
+ layout: "hex";
1014
+ q: number;
1015
+ r: number;
1016
+ rotation: 0;
1017
+ };
1018
+ }[];
1019
+ };
1020
+ declare function rectangle<const Options extends TileIdentity & {
1021
+ readonly width: number;
1022
+ readonly height: number;
1023
+ readonly start?: Coordinate;
1024
+ }>(options: Options): {
1025
+ tileTypes: {
1026
+ id: (Options & {
1027
+ readonly coordinates: {
1028
+ q: number;
1029
+ r: number;
1030
+ }[];
1031
+ })["tileTypeId"];
1032
+ name: string;
1033
+ layout: "hex";
1034
+ cells: CoordinateCell<(Options & {
1035
+ readonly coordinates: {
1036
+ q: number;
1037
+ r: number;
1038
+ }[];
1039
+ })["coordinates"][number]>[];
1040
+ }[];
1041
+ tileSeeds: {
1042
+ id: (Options & {
1043
+ readonly coordinates: {
1044
+ q: number;
1045
+ r: number;
1046
+ }[];
1047
+ })["tileId"];
1048
+ typeId: (Options & {
1049
+ readonly coordinates: {
1050
+ q: number;
1051
+ r: number;
1052
+ }[];
1053
+ })["tileTypeId"];
1054
+ home: {
1055
+ type: "board";
1056
+ boardId: (Options & {
1057
+ readonly coordinates: {
1058
+ q: number;
1059
+ r: number;
1060
+ }[];
1061
+ })["boardId"];
1062
+ layout: "hex";
1063
+ q: number;
1064
+ r: number;
1065
+ rotation: 0;
1066
+ };
1067
+ }[];
1068
+ };
143
1069
 
144
- /** Compile authored topology once, in memory, with the same validation used by initialization. */
145
- declare function compileManifest<const M extends AuthoredManifest>(manifest: M): CompiledManifest<M>;
1070
+ type MaterializeOptions = {
1071
+ manifest: GameTopologyManifest$1;
1072
+ playerIds: readonly string[];
1073
+ shuffleItems: <Value>(values: readonly Value[]) => Value[];
1074
+ };
1075
+ /** Construct actual session inventory; references use the supplied live roster. */
1076
+ declare function materializeManifestTable(options: MaterializeOptions): Record<string, unknown>;
146
1077
 
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 };
1078
+ export { AuthoredManifest, AuthoredTileDisclosure, BoardSpaceTarget, type BoardTargetPredicate, type BoundInputBuilders, type BoundTargetPredicate, type CardTargetPredicate, type ChoiceOptionsFactory, type ChoiceTargetOption, type ChoiceTargetPredicate, CompiledManifest, type ContractTypes, FieldsInput, type GameAuthoring, GameTopologyManifest$1 as GameTopologyManifest, InteractionRule, type ManyOptions, PerPlayerInstanceId, type PhaseAuthoring, type PhaseTypes, PositionTarget, type ReducerBundle, ReducerBundleContract, type ReducerBundleOptions, ReducerDiagnosticsSink, ReducerGameDefinition, ReducerGameDefinitionInput, ReducerTransaction, type SparseCounts, type SparseMap, SystemActionEvent, TableQueries, TableQueriesOfState, type TargetContext, type TargetPredicate, type TargetPredicateArgs, type TileTargetPredicate, type TypedTopologyManifest, ValidatedManifest, compileManifest, createGame, createReducerBundle, createStateQueries, createTableQueries, defineTopologyManifest, fromCoordinates, gameEvent, hexagon, many, materializeManifestTable, memoize, normalizeCommandParams, parseTopologyManifestJson, rectangle, ring, sparseCounts, sparseMap, spiral };