@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.
- package/README.md +136 -45
- package/dist/chunk-DMFVAZI2.js +16 -0
- package/dist/chunk-DMFVAZI2.js.map +1 -0
- package/dist/chunk-FMM5LVJW.js +833 -0
- package/dist/chunk-FMM5LVJW.js.map +1 -0
- package/dist/{chunk-S2JEDVWH.js → chunk-LRILEVKC.js} +6113 -6489
- package/dist/chunk-LRILEVKC.js.map +1 -0
- package/dist/chunk-SP234IY4.js +1363 -0
- package/dist/chunk-SP234IY4.js.map +1 -0
- package/dist/chunk-VUWNJXLJ.js +52 -0
- package/dist/chunk-VUWNJXLJ.js.map +1 -0
- package/dist/chunk-ZPRKWPEP.js +511 -0
- package/dist/chunk-ZPRKWPEP.js.map +1 -0
- package/dist/definition-BaHNPZol.d.ts +4639 -0
- package/dist/diagnostics-B0lgnuZ6.d.ts +65 -0
- package/dist/index.d.ts +3553 -1
- package/dist/index.js +1045 -6
- package/dist/index.js.map +1 -1
- package/dist/model-BHro6yXu.d.ts +288 -0
- package/dist/react.d.ts +32 -0
- package/dist/react.js +80 -0
- package/dist/react.js.map +1 -0
- package/dist/reducer.d.ts +1194 -79
- package/dist/reducer.js +4326 -121
- package/dist/reducer.js.map +1 -1
- package/dist/testing.d.ts +518 -564
- package/dist/testing.js +2448 -915
- package/dist/testing.js.map +1 -1
- package/dist/types-DimqnJBq.d.ts +86 -0
- package/package.json +26 -131
- package/dist/HandView-Bi2lxzQP.d.ts +0 -79
- package/dist/ResourceCounter-BFxJknqp.d.ts +0 -98
- package/dist/ThemeProvider-CElaL2ik.d.ts +0 -99
- package/dist/attributes-DbvyMbXw.d.ts +0 -68
- package/dist/browser-interaction.d.ts +0 -910
- package/dist/browser-interaction.js +0 -119
- package/dist/browser-interaction.js.map +0 -1
- package/dist/chunk-32PFKDV7.js +0 -11705
- package/dist/chunk-32PFKDV7.js.map +0 -1
- package/dist/chunk-3BAD4VC2.js +0 -263
- package/dist/chunk-3BAD4VC2.js.map +0 -1
- package/dist/chunk-3SKDNDPG.js +0 -104
- package/dist/chunk-3SKDNDPG.js.map +0 -1
- package/dist/chunk-5YV2WHJ4.js +0 -25
- package/dist/chunk-5YV2WHJ4.js.map +0 -1
- package/dist/chunk-ANRB4XKA.js +0 -90
- package/dist/chunk-ANRB4XKA.js.map +0 -1
- package/dist/chunk-BI4G3PM2.js +0 -1864
- package/dist/chunk-BI4G3PM2.js.map +0 -1
- package/dist/chunk-EVCLTY4Q.js +0 -935
- package/dist/chunk-EVCLTY4Q.js.map +0 -1
- package/dist/chunk-GDPKTBUR.js +0 -564
- package/dist/chunk-GDPKTBUR.js.map +0 -1
- package/dist/chunk-H6VDGFL5.js +0 -2903
- package/dist/chunk-H6VDGFL5.js.map +0 -1
- package/dist/chunk-LR3ZTWQF.js +0 -5960
- package/dist/chunk-LR3ZTWQF.js.map +0 -1
- package/dist/chunk-PF7L4BMG.js +0 -117
- package/dist/chunk-PF7L4BMG.js.map +0 -1
- package/dist/chunk-PN5O6GG2.js +0 -32
- package/dist/chunk-PN5O6GG2.js.map +0 -1
- package/dist/chunk-PZ5AY32C.js +0 -10
- package/dist/chunk-PZ5AY32C.js.map +0 -1
- package/dist/chunk-S2JEDVWH.js.map +0 -1
- package/dist/chunk-T3ZKNUZ7.js +0 -1
- package/dist/chunk-T3ZKNUZ7.js.map +0 -1
- package/dist/chunk-UGH54WZ2.js +0 -223
- package/dist/chunk-UGH54WZ2.js.map +0 -1
- package/dist/chunk-VCDWP5VL.js +0 -746
- package/dist/chunk-VCDWP5VL.js.map +0 -1
- package/dist/chunk-VDXOF4FW.js +0 -69
- package/dist/chunk-VDXOF4FW.js.map +0 -1
- package/dist/chunk-WHR5UW3F.js +0 -1988
- package/dist/chunk-WHR5UW3F.js.map +0 -1
- package/dist/chunk-Y75CFE77.js +0 -17
- package/dist/chunk-Y75CFE77.js.map +0 -1
- package/dist/chunk-Z7QCREWI.js +0 -3435
- package/dist/chunk-Z7QCREWI.js.map +0 -1
- package/dist/chunk-ZZGN2ATS.js +0 -1941
- package/dist/chunk-ZZGN2ATS.js.map +0 -1
- package/dist/components-gAbIz7hK.d.ts +0 -1284
- package/dist/definitions-BgmV_GhC.d.ts +0 -300
- package/dist/diagnostics-DIi3ina7.d.ts +0 -50
- package/dist/digest.d.ts +0 -8
- package/dist/game-CsZScpcn.d.ts +0 -763
- package/dist/hex-board-view-aKkblDp6.d.ts +0 -1228
- package/dist/index-CcT9Q7N7.d.ts +0 -193
- package/dist/index.d-DjzoK7zn.d.ts +0 -2101
- package/dist/package-set.d.ts +0 -13
- package/dist/package-set.js +0 -12
- package/dist/package-set.js.map +0 -1
- package/dist/player-state-Cqpyeql0.d.ts +0 -371
- package/dist/plugin-runtime-contract.d.ts +0 -17
- package/dist/plugin-runtime-contract.js +0 -92
- package/dist/plugin-runtime-contract.js.map +0 -1
- package/dist/primitive-props-BNHDkgd7.d.ts +0 -16
- package/dist/protocol-dYgafTYY.d.ts +0 -314
- package/dist/reducer/advanced.d.ts +0 -82
- package/dist/reducer/advanced.js +0 -51
- package/dist/reducer/advanced.js.map +0 -1
- package/dist/reducer-contract.d.ts +0 -11
- package/dist/reducer-contract.js +0 -16
- package/dist/reducer-contract.js.map +0 -1
- package/dist/reference-games/index.d.ts +0 -31
- package/dist/reference-games/index.js +0 -48
- package/dist/reference-games/index.js.map +0 -1
- package/dist/runtime/primitives.d.ts +0 -250
- package/dist/runtime/primitives.js +0 -189
- package/dist/runtime/primitives.js.map +0 -1
- package/dist/runtime/runtime-api.d.ts +0 -2
- package/dist/runtime/runtime-api.js +0 -1
- package/dist/runtime/runtime-api.js.map +0 -1
- package/dist/runtime/workspace-contract.d.ts +0 -392
- package/dist/runtime/workspace-contract.js +0 -28
- package/dist/runtime/workspace-contract.js.map +0 -1
- package/dist/runtime-RJ5orDJU.d.ts +0 -1699
- package/dist/runtime-api-Bz5pwNU_.d.ts +0 -296
- package/dist/runtime-json-CQ9QbLZ5.d.ts +0 -5
- package/dist/runtime.d.ts +0 -83
- package/dist/runtime.js +0 -242
- package/dist/runtime.js.map +0 -1
- package/dist/schema.d.ts +0 -379
- package/dist/stale-contract-artifact-error-XLaweZtF.d.ts +0 -18
- package/dist/testing-compiler.d.ts +0 -37
- package/dist/testing-compiler.js +0 -272
- package/dist/testing-compiler.js.map +0 -1
- package/dist/testing-runtime.d.ts +0 -119
- package/dist/testing-runtime.js +0 -212
- package/dist/testing-runtime.js.map +0 -1
- package/dist/types-DJj5MJkl.d.ts +0 -256
- package/dist/types-DR7DoB1x.d.ts +0 -28
- package/dist/types-JWCYHmu7.d.ts +0 -122
- package/dist/types.d.ts +0 -1958
- package/dist/types.js +0 -14
- package/dist/types.js.map +0 -1
- package/dist/ui/components.d.ts +0 -17
- package/dist/ui/components.js +0 -216
- package/dist/ui/components.js.map +0 -1
- package/dist/ui/defaults.d.ts +0 -19
- package/dist/ui/defaults.js +0 -104
- package/dist/ui/defaults.js.map +0 -1
- package/dist/ui/player-state.d.ts +0 -2
- package/dist/ui/player-state.js +0 -1
- package/dist/ui/player-state.js.map +0 -1
- package/dist/ui/plugin-styles.css +0 -2
- package/dist/ui-contract-GTUPkf8z.d.ts +0 -1168
- package/dist/ui.d.ts +0 -317
- package/dist/ui.js +0 -277
- package/dist/ui.js.map +0 -1
- package/dist/views-BpuWcOyN.d.ts +0 -1641
|
@@ -0,0 +1,833 @@
|
|
|
1
|
+
import {
|
|
2
|
+
__export
|
|
3
|
+
} from "./chunk-VUWNJXLJ.js";
|
|
4
|
+
|
|
5
|
+
// src/shared/runtime-json.ts
|
|
6
|
+
import { z } from "zod";
|
|
7
|
+
var RuntimeJsonSchema = z.json();
|
|
8
|
+
|
|
9
|
+
// src/shared/interaction-schema.ts
|
|
10
|
+
import { z as z2 } from "zod";
|
|
11
|
+
var InteractionCommitPolicySchema = z2.discriminatedUnion("mode", [
|
|
12
|
+
z2.object({ mode: z2.literal("manual") }).strict(),
|
|
13
|
+
z2.object({ mode: z2.literal("autoWhenReady") }).strict()
|
|
14
|
+
]);
|
|
15
|
+
var InputSelectionSchema = z2.discriminatedUnion("mode", [
|
|
16
|
+
z2.object({ mode: z2.literal("single") }).strict(),
|
|
17
|
+
z2.object({
|
|
18
|
+
mode: z2.literal("many"),
|
|
19
|
+
min: z2.number().int(),
|
|
20
|
+
max: z2.number().int().optional(),
|
|
21
|
+
distinct: z2.boolean().optional()
|
|
22
|
+
}).strict()
|
|
23
|
+
]);
|
|
24
|
+
var InteractionChoiceOptionSchema = z2.object({
|
|
25
|
+
value: z2.string().nullable(),
|
|
26
|
+
label: z2.string(),
|
|
27
|
+
icon: z2.string().optional(),
|
|
28
|
+
badge: z2.string().optional(),
|
|
29
|
+
description: z2.string().optional(),
|
|
30
|
+
disabled: z2.boolean().optional(),
|
|
31
|
+
disabledReason: z2.string().optional()
|
|
32
|
+
}).strict();
|
|
33
|
+
var selection = { selection: InputSelectionSchema.optional() };
|
|
34
|
+
var InputDomainSchema = z2.discriminatedUnion("type", [
|
|
35
|
+
z2.strictObject({
|
|
36
|
+
type: z2.literal("cardTarget"),
|
|
37
|
+
projection: z2.literal("resolved"),
|
|
38
|
+
targetKind: z2.literal("card"),
|
|
39
|
+
zoneIds: z2.array(z2.string()),
|
|
40
|
+
eligibleTargets: z2.array(z2.string()),
|
|
41
|
+
...selection
|
|
42
|
+
}),
|
|
43
|
+
z2.strictObject({
|
|
44
|
+
type: z2.literal("boardTarget"),
|
|
45
|
+
projection: z2.literal("resolved"),
|
|
46
|
+
targetKind: z2.enum(["edge", "vertex", "space", "tile"]),
|
|
47
|
+
boardId: z2.string(),
|
|
48
|
+
valueKind: z2.enum(["board-id", "player-board-space"]).optional(),
|
|
49
|
+
eligibleTargets: z2.array(z2.string()),
|
|
50
|
+
...selection
|
|
51
|
+
}),
|
|
52
|
+
z2.strictObject({
|
|
53
|
+
type: z2.literal("resourceMap"),
|
|
54
|
+
resources: z2.array(
|
|
55
|
+
z2.strictObject({
|
|
56
|
+
resourceId: z2.string(),
|
|
57
|
+
label: z2.string().optional(),
|
|
58
|
+
icon: z2.string().optional(),
|
|
59
|
+
min: z2.number(),
|
|
60
|
+
max: z2.number()
|
|
61
|
+
})
|
|
62
|
+
),
|
|
63
|
+
...selection
|
|
64
|
+
}),
|
|
65
|
+
z2.strictObject({
|
|
66
|
+
type: z2.literal("boundedNumber"),
|
|
67
|
+
min: z2.number(),
|
|
68
|
+
max: z2.number(),
|
|
69
|
+
step: z2.number().optional(),
|
|
70
|
+
...selection
|
|
71
|
+
}),
|
|
72
|
+
z2.strictObject({
|
|
73
|
+
type: z2.literal("choice"),
|
|
74
|
+
choices: z2.array(InteractionChoiceOptionSchema),
|
|
75
|
+
...selection
|
|
76
|
+
}),
|
|
77
|
+
z2.strictObject({
|
|
78
|
+
type: z2.literal("choiceList"),
|
|
79
|
+
choices: z2.array(
|
|
80
|
+
InteractionChoiceOptionSchema.extend({ value: z2.string() })
|
|
81
|
+
),
|
|
82
|
+
min: z2.number().int().optional(),
|
|
83
|
+
max: z2.number().int().optional(),
|
|
84
|
+
...selection
|
|
85
|
+
})
|
|
86
|
+
]);
|
|
87
|
+
var InteractionInputDescriptorSchema = z2.object({
|
|
88
|
+
key: z2.string().min(1),
|
|
89
|
+
kind: z2.enum([
|
|
90
|
+
"form",
|
|
91
|
+
"board-vertex",
|
|
92
|
+
"board-edge",
|
|
93
|
+
"board-tile",
|
|
94
|
+
"board-space",
|
|
95
|
+
"card",
|
|
96
|
+
"rng"
|
|
97
|
+
]),
|
|
98
|
+
domain: InputDomainSchema,
|
|
99
|
+
defaultValue: RuntimeJsonSchema.optional()
|
|
100
|
+
}).strict();
|
|
101
|
+
var InteractionAvailabilitySchema = z2.discriminatedUnion("status", [
|
|
102
|
+
z2.object({ status: z2.literal("available") }).strict(),
|
|
103
|
+
z2.object({ status: z2.literal("notYourTurn"), reason: z2.string() }).strict(),
|
|
104
|
+
z2.object({
|
|
105
|
+
status: z2.literal("blocked"),
|
|
106
|
+
reason: z2.string(),
|
|
107
|
+
code: z2.string().optional()
|
|
108
|
+
}).strict()
|
|
109
|
+
]);
|
|
110
|
+
var InteractionBaseSchema = z2.object({
|
|
111
|
+
phaseName: z2.string().min(1),
|
|
112
|
+
interactionKey: z2.string().min(1),
|
|
113
|
+
interactionId: z2.string().min(1),
|
|
114
|
+
label: z2.string().min(1),
|
|
115
|
+
help: z2.string().optional(),
|
|
116
|
+
zoneId: z2.string().optional(),
|
|
117
|
+
zoneIds: z2.array(z2.string()).optional(),
|
|
118
|
+
commit: InteractionCommitPolicySchema,
|
|
119
|
+
descriptorDigest: z2.string().optional(),
|
|
120
|
+
actorSeat: z2.number().int().optional(),
|
|
121
|
+
draftDigest: z2.string().optional(),
|
|
122
|
+
inputs: z2.array(InteractionInputDescriptorSchema),
|
|
123
|
+
step: z2.object({
|
|
124
|
+
index: z2.number().int().nonnegative(),
|
|
125
|
+
total: z2.number().int().positive(),
|
|
126
|
+
selected: z2.record(z2.string(), RuntimeJsonSchema),
|
|
127
|
+
canCancel: z2.boolean()
|
|
128
|
+
}).strict().optional(),
|
|
129
|
+
availability: InteractionAvailabilitySchema,
|
|
130
|
+
reasons: z2.array(
|
|
131
|
+
z2.object({
|
|
132
|
+
ruleId: z2.string(),
|
|
133
|
+
errorCode: z2.string()
|
|
134
|
+
}).strict()
|
|
135
|
+
).optional()
|
|
136
|
+
}).strict();
|
|
137
|
+
var InteractionDescriptorSchema = InteractionBaseSchema.extend({
|
|
138
|
+
kind: z2.literal("action")
|
|
139
|
+
}).strict();
|
|
140
|
+
var ZoneInteractionRefsSchema = z2.strictObject({
|
|
141
|
+
cardIds: z2.array(z2.string()),
|
|
142
|
+
cardViewsById: z2.record(z2.string(), z2.string()),
|
|
143
|
+
playableByCardId: z2.record(z2.string(), z2.array(z2.string()))
|
|
144
|
+
});
|
|
145
|
+
|
|
146
|
+
// src/shared/runtime-schema.ts
|
|
147
|
+
var runtime_schema_exports = {};
|
|
148
|
+
__export(runtime_schema_exports, {
|
|
149
|
+
AuthoredViewSchema: () => AuthoredViewSchema,
|
|
150
|
+
BoardStaticProjectionSchema: () => BoardStaticProjectionSchema,
|
|
151
|
+
DispatchRequestSchema: () => DispatchRequestSchema,
|
|
152
|
+
DispatchResultAcceptSchema: () => DispatchResultAcceptSchema,
|
|
153
|
+
DispatchResultRejectSchema: () => DispatchResultRejectSchema,
|
|
154
|
+
DispatchResultSchema: () => DispatchResultSchema,
|
|
155
|
+
DispatchTraceAcceptedClientInputSchema: () => DispatchTraceAcceptedClientInputSchema,
|
|
156
|
+
DispatchTracePhaseEnteredSchema: () => DispatchTracePhaseEnteredSchema,
|
|
157
|
+
DispatchTraceRngConsumptionSchema: () => DispatchTraceRngConsumptionSchema,
|
|
158
|
+
DispatchTraceSchema: () => DispatchTraceSchema,
|
|
159
|
+
GameEventDetailSchema: () => GameEventDetailSchema,
|
|
160
|
+
GameEventSchema: () => GameEventSchema,
|
|
161
|
+
GameInputCancelSchema: () => GameInputCancelSchema,
|
|
162
|
+
GameInputInteractionSchema: () => GameInputInteractionSchema,
|
|
163
|
+
GameInputSchema: () => GameInputSchema,
|
|
164
|
+
GameOutcomeReasonSchema: () => GameOutcomeReasonSchema,
|
|
165
|
+
GameOutcomeSchema: () => GameOutcomeSchema,
|
|
166
|
+
InitializeRequestSchema: () => InitializeRequestSchema,
|
|
167
|
+
InitializeResultSchema: () => InitializeResultSchema,
|
|
168
|
+
OutcomeResultSchema: () => OutcomeResultSchema,
|
|
169
|
+
OutcomeScoreComponentSchema: () => OutcomeScoreComponentSchema,
|
|
170
|
+
OutcomeStandingSchema: () => OutcomeStandingSchema,
|
|
171
|
+
OutcomeTieBreakSchema: () => OutcomeTieBreakSchema,
|
|
172
|
+
ProjectRequestSchema: () => ProjectRequestSchema,
|
|
173
|
+
ProjectionTimingMetadataSchema: () => ProjectionTimingMetadataSchema,
|
|
174
|
+
ReducerContractVersionSchema: () => ReducerContractVersionSchema,
|
|
175
|
+
ReducerDomainStateSchema: () => ReducerDomainStateSchema,
|
|
176
|
+
ReducerFlowStateSchema: () => ReducerFlowStateSchema,
|
|
177
|
+
ReducerRuntimeLogEntryAcceptedClientInputSchema: () => ReducerRuntimeLogEntryAcceptedClientInputSchema,
|
|
178
|
+
ReducerRuntimeLogEntryPhaseEnteredSchema: () => ReducerRuntimeLogEntryPhaseEnteredSchema,
|
|
179
|
+
ReducerRuntimeLogEntryRngConsumptionSchema: () => ReducerRuntimeLogEntryRngConsumptionSchema,
|
|
180
|
+
ReducerRuntimeLogEntrySchema: () => ReducerRuntimeLogEntrySchema,
|
|
181
|
+
ReducerRuntimeLogEntryStateCommitSchema: () => ReducerRuntimeLogEntryStateCommitSchema,
|
|
182
|
+
ReducerRuntimeStateSchema: () => ReducerRuntimeStateSchema,
|
|
183
|
+
ReducerSessionStateSchema: () => ReducerSessionStateSchema,
|
|
184
|
+
RngDrawSchema: () => RngDrawSchema,
|
|
185
|
+
RngOperationParameterSchema: () => RngOperationParameterSchema,
|
|
186
|
+
RngOperationSchema: () => RngOperationSchema,
|
|
187
|
+
RngStateSchema: () => RngStateSchema,
|
|
188
|
+
RuntimePendingInteractionSchema: () => RuntimePendingInteractionSchema,
|
|
189
|
+
RuntimeSimultaneousCurrentSchema: () => RuntimeSimultaneousCurrentSchema,
|
|
190
|
+
RuntimeSimultaneousStateSchema: () => RuntimeSimultaneousStateSchema,
|
|
191
|
+
RuntimeSimultaneousSubmissionSchema: () => RuntimeSimultaneousSubmissionSchema,
|
|
192
|
+
SchedulerContinuationDependencySchema: () => SchedulerContinuationDependencySchema,
|
|
193
|
+
SchedulerFlowAuthorityProjectionSchema: () => SchedulerFlowAuthorityProjectionSchema,
|
|
194
|
+
SeatProjectionBundleSchema: () => SeatProjectionBundleSchema,
|
|
195
|
+
SeatProjectionSchema: () => SeatProjectionSchema,
|
|
196
|
+
SimultaneousPhaseProjectionSchema: () => SimultaneousPhaseProjectionSchema,
|
|
197
|
+
SystemActionEventSchema: () => SystemActionEventSchema,
|
|
198
|
+
TransitionRecordSchema: () => TransitionRecordSchema
|
|
199
|
+
});
|
|
200
|
+
import { z as z3 } from "zod";
|
|
201
|
+
var ReducerContractVersionSchema = z3.string().regex(new RegExp("^[0-9]+\\.[0-9]+\\.[0-9]+$"));
|
|
202
|
+
var RngOperationParameterSchema = z3.union([
|
|
203
|
+
z3.string(),
|
|
204
|
+
z3.number().finite(),
|
|
205
|
+
z3.boolean()
|
|
206
|
+
]);
|
|
207
|
+
var RngOperationSchema = z3.strictObject({
|
|
208
|
+
kind: z3.string().min(1),
|
|
209
|
+
parameters: z3.record(z3.string(), RngOperationParameterSchema)
|
|
210
|
+
});
|
|
211
|
+
var RngDrawSchema = z3.strictObject({
|
|
212
|
+
index: z3.number().int().gte(0),
|
|
213
|
+
cursorBefore: z3.number().int().gte(0),
|
|
214
|
+
cursorAfter: z3.number().int().gte(0),
|
|
215
|
+
operation: RngOperationSchema
|
|
216
|
+
});
|
|
217
|
+
var RngStateSchema = z3.strictObject({
|
|
218
|
+
seed: z3.union([
|
|
219
|
+
z3.number().refine(Number.isInteger, { message: "Expected integer" }),
|
|
220
|
+
z3.null()
|
|
221
|
+
]),
|
|
222
|
+
cursor: z3.number().int(),
|
|
223
|
+
trace: z3.array(z3.string()),
|
|
224
|
+
draws: z3.array(RngDrawSchema).optional()
|
|
225
|
+
});
|
|
226
|
+
var ReducerFlowStateSchema = z3.strictObject({
|
|
227
|
+
currentPhase: z3.string().min(1),
|
|
228
|
+
turn: z3.number().int(),
|
|
229
|
+
round: z3.number().int(),
|
|
230
|
+
activePlayers: z3.array(z3.string().min(1))
|
|
231
|
+
});
|
|
232
|
+
var RuntimeSimultaneousSubmissionSchema = z3.strictObject({
|
|
233
|
+
interactionId: z3.string().min(1),
|
|
234
|
+
params: RuntimeJsonSchema
|
|
235
|
+
});
|
|
236
|
+
var RuntimeSimultaneousCurrentSchema = z3.strictObject({
|
|
237
|
+
phaseName: z3.string().min(1),
|
|
238
|
+
actors: z3.array(z3.string().min(1)),
|
|
239
|
+
submissions: z3.record(z3.string(), RuntimeSimultaneousSubmissionSchema)
|
|
240
|
+
});
|
|
241
|
+
var RuntimeSimultaneousStateSchema = z3.strictObject({
|
|
242
|
+
current: z3.union([RuntimeSimultaneousCurrentSchema, z3.null()])
|
|
243
|
+
});
|
|
244
|
+
var TransitionRecordSchema = z3.strictObject({
|
|
245
|
+
from: z3.string().min(1),
|
|
246
|
+
to: z3.string().min(1)
|
|
247
|
+
});
|
|
248
|
+
var RuntimePendingInteractionSchema = z3.strictObject({
|
|
249
|
+
phaseName: z3.string().min(1),
|
|
250
|
+
interactionId: z3.string().min(1),
|
|
251
|
+
values: z3.array(RuntimeJsonSchema).min(1)
|
|
252
|
+
});
|
|
253
|
+
var GameEventDetailSchema = z3.strictObject({
|
|
254
|
+
label: z3.string().min(1),
|
|
255
|
+
value: z3.union([z3.string(), z3.number().finite(), z3.boolean()])
|
|
256
|
+
});
|
|
257
|
+
var SystemActionEventSchema = z3.strictObject({
|
|
258
|
+
kind: z3.literal("systemAction"),
|
|
259
|
+
procedureId: z3.string().min(1),
|
|
260
|
+
title: z3.string().min(1),
|
|
261
|
+
summary: z3.string().min(1).optional(),
|
|
262
|
+
details: z3.array(GameEventDetailSchema).max(16).optional()
|
|
263
|
+
});
|
|
264
|
+
var GameEventSchema = z3.discriminatedUnion("kind", [
|
|
265
|
+
SystemActionEventSchema
|
|
266
|
+
]);
|
|
267
|
+
var ReducerRuntimeStateSchema = z3.strictObject({
|
|
268
|
+
events: z3.array(GameEventSchema).max(32),
|
|
269
|
+
rng: RngStateSchema,
|
|
270
|
+
pending: z3.record(z3.string(), RuntimePendingInteractionSchema),
|
|
271
|
+
simultaneous: RuntimeSimultaneousStateSchema,
|
|
272
|
+
lastTransition: z3.union([TransitionRecordSchema, z3.null()]),
|
|
273
|
+
options: z3.record(z3.string(), RuntimeJsonSchema)
|
|
274
|
+
});
|
|
275
|
+
var ReducerDomainStateSchema = z3.strictObject({
|
|
276
|
+
table: RuntimeJsonSchema,
|
|
277
|
+
publicState: RuntimeJsonSchema,
|
|
278
|
+
privateState: z3.record(z3.string(), RuntimeJsonSchema),
|
|
279
|
+
hiddenState: RuntimeJsonSchema,
|
|
280
|
+
flow: ReducerFlowStateSchema,
|
|
281
|
+
phase: RuntimeJsonSchema
|
|
282
|
+
});
|
|
283
|
+
var ReducerSessionStateSchema = z3.strictObject({
|
|
284
|
+
domain: ReducerDomainStateSchema,
|
|
285
|
+
runtime: ReducerRuntimeStateSchema
|
|
286
|
+
});
|
|
287
|
+
var GameInputInteractionSchema = z3.strictObject({
|
|
288
|
+
kind: z3.literal("interaction"),
|
|
289
|
+
playerId: z3.string().min(1),
|
|
290
|
+
interactionId: z3.string().min(1),
|
|
291
|
+
params: RuntimeJsonSchema
|
|
292
|
+
});
|
|
293
|
+
var GameInputCancelSchema = z3.strictObject({
|
|
294
|
+
kind: z3.literal("interaction.cancel"),
|
|
295
|
+
playerId: z3.string().min(1),
|
|
296
|
+
interactionId: z3.string().min(1)
|
|
297
|
+
});
|
|
298
|
+
var GameInputSchema = z3.discriminatedUnion("kind", [
|
|
299
|
+
GameInputInteractionSchema,
|
|
300
|
+
GameInputCancelSchema
|
|
301
|
+
]);
|
|
302
|
+
var GameOutcomeReasonSchema = z3.strictObject({
|
|
303
|
+
code: z3.string().min(1),
|
|
304
|
+
message: z3.string().min(1).optional()
|
|
305
|
+
});
|
|
306
|
+
var OutcomeResultSchema = z3.enum([
|
|
307
|
+
"win",
|
|
308
|
+
"draw",
|
|
309
|
+
"loss",
|
|
310
|
+
"eliminated"
|
|
311
|
+
]);
|
|
312
|
+
var OutcomeScoreComponentSchema = z3.strictObject({
|
|
313
|
+
id: z3.string().min(1),
|
|
314
|
+
label: z3.string().min(1),
|
|
315
|
+
value: z3.number().finite()
|
|
316
|
+
});
|
|
317
|
+
var OutcomeTieBreakSchema = z3.strictObject({
|
|
318
|
+
id: z3.string().min(1),
|
|
319
|
+
label: z3.string().min(1),
|
|
320
|
+
value: z3.union([z3.number().finite(), z3.string()])
|
|
321
|
+
});
|
|
322
|
+
var OutcomeStandingSchema = z3.strictObject({
|
|
323
|
+
playerId: z3.string().min(1),
|
|
324
|
+
rank: z3.number().int().gte(1),
|
|
325
|
+
result: OutcomeResultSchema,
|
|
326
|
+
score: z3.number().finite().optional(),
|
|
327
|
+
scoreBreakdown: z3.array(OutcomeScoreComponentSchema).optional(),
|
|
328
|
+
tieBreaks: z3.array(OutcomeTieBreakSchema).optional()
|
|
329
|
+
});
|
|
330
|
+
var GameOutcomeSchema = z3.strictObject({
|
|
331
|
+
reason: GameOutcomeReasonSchema,
|
|
332
|
+
standings: z3.array(OutcomeStandingSchema).min(1)
|
|
333
|
+
});
|
|
334
|
+
var InitializeResultSchema = z3.strictObject({
|
|
335
|
+
state: ReducerSessionStateSchema,
|
|
336
|
+
terminal: GameOutcomeSchema.optional(),
|
|
337
|
+
events: z3.array(GameEventSchema).optional()
|
|
338
|
+
});
|
|
339
|
+
var InitializeRequestSchema = z3.strictObject({
|
|
340
|
+
table: RuntimeJsonSchema,
|
|
341
|
+
playerIds: z3.array(z3.string().min(1)),
|
|
342
|
+
rngSeed: z3.union([
|
|
343
|
+
z3.number().refine(Number.isInteger, { message: "Expected integer" }),
|
|
344
|
+
z3.null()
|
|
345
|
+
]).optional(),
|
|
346
|
+
options: z3.record(z3.string(), RuntimeJsonSchema).optional()
|
|
347
|
+
});
|
|
348
|
+
var DispatchRequestSchema = z3.strictObject({
|
|
349
|
+
state: ReducerSessionStateSchema,
|
|
350
|
+
input: GameInputSchema
|
|
351
|
+
});
|
|
352
|
+
var DispatchTraceAcceptedClientInputSchema = z3.strictObject({
|
|
353
|
+
kind: z3.literal("acceptedClientInput"),
|
|
354
|
+
input: GameInputSchema
|
|
355
|
+
});
|
|
356
|
+
var DispatchTracePhaseEnteredSchema = z3.strictObject({
|
|
357
|
+
kind: z3.literal("phaseEntered"),
|
|
358
|
+
from: z3.string(),
|
|
359
|
+
to: z3.string()
|
|
360
|
+
});
|
|
361
|
+
var DispatchTraceRngConsumptionSchema = z3.strictObject({
|
|
362
|
+
kind: z3.literal("rngConsumption"),
|
|
363
|
+
version: z3.literal(2),
|
|
364
|
+
operation: z3.string().min(1),
|
|
365
|
+
drawIndex: z3.number().int().gte(0),
|
|
366
|
+
traceEntry: z3.string()
|
|
367
|
+
});
|
|
368
|
+
var DispatchTraceSchema = z3.discriminatedUnion("kind", [
|
|
369
|
+
DispatchTraceAcceptedClientInputSchema,
|
|
370
|
+
DispatchTracePhaseEnteredSchema,
|
|
371
|
+
DispatchTraceRngConsumptionSchema
|
|
372
|
+
]);
|
|
373
|
+
var DispatchResultRejectSchema = z3.strictObject({
|
|
374
|
+
kind: z3.literal("reject"),
|
|
375
|
+
errorCode: z3.string().min(1),
|
|
376
|
+
message: z3.string().optional()
|
|
377
|
+
});
|
|
378
|
+
var DispatchResultAcceptSchema = z3.strictObject({
|
|
379
|
+
kind: z3.literal("accept"),
|
|
380
|
+
state: ReducerSessionStateSchema,
|
|
381
|
+
terminal: GameOutcomeSchema.optional(),
|
|
382
|
+
trace: z3.array(DispatchTraceSchema),
|
|
383
|
+
events: z3.array(GameEventSchema).max(32)
|
|
384
|
+
});
|
|
385
|
+
var DispatchResultSchema = z3.discriminatedUnion("kind", [
|
|
386
|
+
DispatchResultRejectSchema,
|
|
387
|
+
DispatchResultAcceptSchema
|
|
388
|
+
]);
|
|
389
|
+
var ReducerRuntimeLogEntryAcceptedClientInputSchema = z3.strictObject({
|
|
390
|
+
kind: z3.literal("acceptedClientInput"),
|
|
391
|
+
version: z3.number().int(),
|
|
392
|
+
input: GameInputSchema
|
|
393
|
+
});
|
|
394
|
+
var ReducerRuntimeLogEntryPhaseEnteredSchema = z3.strictObject({
|
|
395
|
+
kind: z3.literal("phaseEntered"),
|
|
396
|
+
from: z3.string(),
|
|
397
|
+
to: z3.string(),
|
|
398
|
+
version: z3.number().int()
|
|
399
|
+
});
|
|
400
|
+
var ReducerRuntimeLogEntryRngConsumptionSchema = z3.strictObject({
|
|
401
|
+
kind: z3.literal("rngConsumption"),
|
|
402
|
+
version: z3.number().int(),
|
|
403
|
+
operation: z3.string().min(1),
|
|
404
|
+
drawIndex: z3.number().int().gte(0).optional(),
|
|
405
|
+
traceEntry: z3.string()
|
|
406
|
+
});
|
|
407
|
+
var ReducerRuntimeLogEntryStateCommitSchema = z3.strictObject({
|
|
408
|
+
kind: z3.literal("stateCommit"),
|
|
409
|
+
version: z3.number().int(),
|
|
410
|
+
state: ReducerSessionStateSchema
|
|
411
|
+
});
|
|
412
|
+
var ReducerRuntimeLogEntrySchema = z3.discriminatedUnion("kind", [
|
|
413
|
+
ReducerRuntimeLogEntryAcceptedClientInputSchema,
|
|
414
|
+
ReducerRuntimeLogEntryPhaseEnteredSchema,
|
|
415
|
+
ReducerRuntimeLogEntryRngConsumptionSchema,
|
|
416
|
+
ReducerRuntimeLogEntryStateCommitSchema
|
|
417
|
+
]);
|
|
418
|
+
var AuthoredViewSchema = z3.object({
|
|
419
|
+
boards: z3.never({
|
|
420
|
+
error: "The view field 'boards' is reserved for manifest geometry."
|
|
421
|
+
}).optional()
|
|
422
|
+
}).catchall(RuntimeJsonSchema);
|
|
423
|
+
var SeatProjectionSchema = z3.strictObject({
|
|
424
|
+
view: AuthoredViewSchema.nullable().optional(),
|
|
425
|
+
availableInteractionRefs: z3.array(z3.string()).optional(),
|
|
426
|
+
zones: z3.record(z3.string(), ZoneInteractionRefsSchema).optional()
|
|
427
|
+
});
|
|
428
|
+
var SimultaneousPhaseProjectionSchema = z3.strictObject({
|
|
429
|
+
phaseName: z3.string().min(1),
|
|
430
|
+
interactionId: z3.string().min(1),
|
|
431
|
+
actorIds: z3.array(z3.string().min(1)),
|
|
432
|
+
sealedPlayerIds: z3.array(z3.string().min(1)),
|
|
433
|
+
pendingPlayerIds: z3.array(z3.string().min(1))
|
|
434
|
+
});
|
|
435
|
+
var SchedulerContinuationDependencySchema = z3.strictObject({
|
|
436
|
+
waiterPlayerId: z3.string().min(1),
|
|
437
|
+
blockerPlayerIds: z3.array(z3.string().min(1))
|
|
438
|
+
});
|
|
439
|
+
var SchedulerFlowAuthorityProjectionSchema = z3.strictObject({
|
|
440
|
+
version: z3.literal(1),
|
|
441
|
+
activePlayerIds: z3.array(z3.string().min(1)),
|
|
442
|
+
pendingPlayerIds: z3.array(z3.string().min(1)),
|
|
443
|
+
continuationDependencies: z3.array(SchedulerContinuationDependencySchema)
|
|
444
|
+
});
|
|
445
|
+
var ProjectionTimingMetadataSchema = z3.strictObject({
|
|
446
|
+
resolveAvailableInteractionsMs: z3.number().finite().gte(0),
|
|
447
|
+
resolveViewMs: z3.number().finite().gte(0),
|
|
448
|
+
resolveZoneHandlesMs: z3.number().finite().gte(0),
|
|
449
|
+
descriptorHashMs: z3.number().finite().gte(0)
|
|
450
|
+
});
|
|
451
|
+
var SeatProjectionBundleSchema = z3.strictObject({
|
|
452
|
+
events: z3.array(GameEventSchema).max(32),
|
|
453
|
+
simultaneousPhase: z3.union([SimultaneousPhaseProjectionSchema, z3.null()]).optional(),
|
|
454
|
+
schedulerFlow: SchedulerFlowAuthorityProjectionSchema.optional(),
|
|
455
|
+
interactionsByRef: z3.record(z3.string(), InteractionDescriptorSchema).optional(),
|
|
456
|
+
seats: z3.record(z3.string(), SeatProjectionSchema),
|
|
457
|
+
timing: ProjectionTimingMetadataSchema.optional()
|
|
458
|
+
});
|
|
459
|
+
var ProjectRequestSchema = z3.strictObject({
|
|
460
|
+
state: ReducerSessionStateSchema,
|
|
461
|
+
playerIds: z3.array(z3.string().min(1))
|
|
462
|
+
});
|
|
463
|
+
var BoardStaticProjectionSchema = z3.strictObject({
|
|
464
|
+
view: z3.record(z3.string(), RuntimeJsonSchema),
|
|
465
|
+
hash: z3.string().min(1),
|
|
466
|
+
manifestVersion: z3.string()
|
|
467
|
+
});
|
|
468
|
+
|
|
469
|
+
// src/shared/hex-board.ts
|
|
470
|
+
import {
|
|
471
|
+
defineHex,
|
|
472
|
+
Grid,
|
|
473
|
+
Orientation,
|
|
474
|
+
fromCoordinates as coordinatesTraversal,
|
|
475
|
+
rectangle as rectangleTraversal,
|
|
476
|
+
ring as ringTraversal,
|
|
477
|
+
spiral as spiralTraversal,
|
|
478
|
+
line as lineTraversal
|
|
479
|
+
} from "honeycomb-grid";
|
|
480
|
+
var hexagon = (options) => ({ kind: "hexagon", ...options });
|
|
481
|
+
var spiral = (options) => ({ kind: "spiral", ...options });
|
|
482
|
+
var ring = (options) => ({ kind: "ring", ...options });
|
|
483
|
+
var rectangle = (options) => ({ kind: "rectangle", ...options });
|
|
484
|
+
var fromCoordinates = (coordinates) => ({ kind: "coordinates", coordinates });
|
|
485
|
+
var coordinateKey = ({ q, r }) => `${q},${r}`;
|
|
486
|
+
var pointKey = ({ x, y }) => `${Math.round(x * 1e9)},${Math.round(y * 1e9)}`;
|
|
487
|
+
var compare = (a, b) => a < b ? -1 : a > b ? 1 : 0;
|
|
488
|
+
function hexClass(orientation, dimensions = 1) {
|
|
489
|
+
return defineHex({
|
|
490
|
+
dimensions,
|
|
491
|
+
orientation: orientation === "flat" ? Orientation.FLAT : Orientation.POINTY,
|
|
492
|
+
origin: { x: 0, y: 0 }
|
|
493
|
+
});
|
|
494
|
+
}
|
|
495
|
+
function hexShapeCoordinates(shape, orientation = "pointy") {
|
|
496
|
+
const integer = (value, name, minimum) => {
|
|
497
|
+
if (!Number.isSafeInteger(value) || value < minimum)
|
|
498
|
+
throw new Error(`${name} must be a safe integer >= ${minimum}.`);
|
|
499
|
+
};
|
|
500
|
+
const coordinate = (value) => {
|
|
501
|
+
integer(value.q, "q", Number.MIN_SAFE_INTEGER);
|
|
502
|
+
integer(value.r, "r", Number.MIN_SAFE_INTEGER);
|
|
503
|
+
};
|
|
504
|
+
if (shape.kind === "coordinates") {
|
|
505
|
+
shape.coordinates.forEach(coordinate);
|
|
506
|
+
if (new Set(shape.coordinates.map(coordinateKey)).size !== shape.coordinates.length)
|
|
507
|
+
throw new Error("Hex shape contains duplicate coordinates.");
|
|
508
|
+
} else if (shape.kind === "rectangle") {
|
|
509
|
+
integer(shape.width, "width", 1);
|
|
510
|
+
integer(shape.height, "height", 1);
|
|
511
|
+
if (shape.start) coordinate(shape.start);
|
|
512
|
+
} else {
|
|
513
|
+
integer(shape.radius, "radius", 0);
|
|
514
|
+
if (shape.center) coordinate(shape.center);
|
|
515
|
+
}
|
|
516
|
+
const Tile = hexClass(orientation);
|
|
517
|
+
const traversal = shape.kind === "coordinates" ? coordinatesTraversal(...shape.coordinates) : shape.kind === "rectangle" ? rectangleTraversal(shape) : shape.kind === "ring" ? ringTraversal({
|
|
518
|
+
radius: shape.radius,
|
|
519
|
+
center: shape.center ?? { q: 0, r: 0 }
|
|
520
|
+
}) : spiralTraversal({ radius: shape.radius, start: shape.center });
|
|
521
|
+
return new Grid(Tile, traversal).toArray().map(({ q, r }) => ({ q, r }));
|
|
522
|
+
}
|
|
523
|
+
function createHexBoardGeometry(board) {
|
|
524
|
+
const spaces = board.spaces.map(({ id, q, r }) => ({ id, q, r })).sort((a, b) => compare(a.id, b.id));
|
|
525
|
+
const orientation = board.orientation ?? "pointy";
|
|
526
|
+
const grid = new Grid(hexClass(orientation), spaces);
|
|
527
|
+
const spacesById = new Map(spaces.map((space) => [space.id, space]));
|
|
528
|
+
if (spacesById.size !== spaces.length || grid.size !== spaces.length)
|
|
529
|
+
throw new Error(
|
|
530
|
+
`Hex board '${board.id}' contains duplicate space IDs or coordinates.`
|
|
531
|
+
);
|
|
532
|
+
const spacesByCoordinate = new Map(
|
|
533
|
+
spaces.map((space) => [coordinateKey(space), space])
|
|
534
|
+
);
|
|
535
|
+
const cornerOwners = /* @__PURE__ */ new Map();
|
|
536
|
+
const edgeOwners = /* @__PURE__ */ new Map();
|
|
537
|
+
const cornersBySpace = /* @__PURE__ */ new Map();
|
|
538
|
+
const edgesBySpace = /* @__PURE__ */ new Map();
|
|
539
|
+
for (const space of spaces) {
|
|
540
|
+
const corners = grid.getHex(space).corners;
|
|
541
|
+
const cornerKeys = corners.map(pointKey);
|
|
542
|
+
cornersBySpace.set(space.id, cornerKeys);
|
|
543
|
+
const edgeKeys = [];
|
|
544
|
+
corners.forEach((point, corner) => {
|
|
545
|
+
const key = cornerKeys[corner];
|
|
546
|
+
const vertex = cornerOwners.get(key) ?? { point, owners: [] };
|
|
547
|
+
vertex.owners.push({ id: space.id, corner });
|
|
548
|
+
cornerOwners.set(key, vertex);
|
|
549
|
+
const pair = [key, cornerKeys[(corner + 1) % 6]];
|
|
550
|
+
const edgeKey = [...pair].sort(compare).join("|");
|
|
551
|
+
const edge = edgeOwners.get(edgeKey) ?? { corners: pair, owners: [] };
|
|
552
|
+
edge.owners.push({ id: space.id, side: corner });
|
|
553
|
+
edgeOwners.set(edgeKey, edge);
|
|
554
|
+
edgeKeys.push(edgeKey);
|
|
555
|
+
});
|
|
556
|
+
edgesBySpace.set(space.id, edgeKeys);
|
|
557
|
+
}
|
|
558
|
+
const vertexIds = new Map(
|
|
559
|
+
[...cornerOwners].map(([key, vertex]) => {
|
|
560
|
+
const owners = [...vertex.owners].sort((a, b) => compare(a.id, b.id));
|
|
561
|
+
return [
|
|
562
|
+
key,
|
|
563
|
+
`${board.id}:vertex:${owners.map((owner) => encodeURIComponent(owner.id)).join("|")}${owners.length < 3 ? `:${owners[0].corner}` : ""}`
|
|
564
|
+
];
|
|
565
|
+
})
|
|
566
|
+
);
|
|
567
|
+
const edgeIds = new Map(
|
|
568
|
+
[...edgeOwners].map(([key, edge]) => {
|
|
569
|
+
const owners = [...edge.owners].sort((a, b) => compare(a.id, b.id));
|
|
570
|
+
return [
|
|
571
|
+
key,
|
|
572
|
+
`${board.id}:edge:${owners.map((owner) => encodeURIComponent(owner.id)).join("|")}${owners.length === 1 ? `:${owners[0].side}` : ""}`
|
|
573
|
+
];
|
|
574
|
+
})
|
|
575
|
+
);
|
|
576
|
+
const edges = [...edgeOwners].map(([key, edge]) => ({
|
|
577
|
+
id: edgeIds.get(key),
|
|
578
|
+
spaceIds: edge.owners.map((owner) => owner.id).sort(compare),
|
|
579
|
+
vertexIds: edge.corners.map((key2) => vertexIds.get(key2)).sort(compare)
|
|
580
|
+
})).sort((a, b) => compare(a.id, b.id));
|
|
581
|
+
const vertices = [...cornerOwners].map(([key, vertex]) => ({
|
|
582
|
+
id: vertexIds.get(key),
|
|
583
|
+
spaceIds: vertex.owners.map((owner) => owner.id).sort(compare),
|
|
584
|
+
edgeIds: edges.filter((edge) => edge.vertexIds.includes(vertexIds.get(key))).map((edge) => edge.id)
|
|
585
|
+
})).sort((a, b) => compare(a.id, b.id));
|
|
586
|
+
const requireSpace = (id) => {
|
|
587
|
+
const space = spacesById.get(id);
|
|
588
|
+
if (!space)
|
|
589
|
+
throw new Error(`Unknown space '${id}' on board '${board.id}'.`);
|
|
590
|
+
return space;
|
|
591
|
+
};
|
|
592
|
+
const selectedIds = (coordinates) => Array.from(coordinates).flatMap((coordinate) => {
|
|
593
|
+
const space = spacesByCoordinate.get(coordinateKey(coordinate));
|
|
594
|
+
return space ? [space.id] : [];
|
|
595
|
+
});
|
|
596
|
+
return {
|
|
597
|
+
edges,
|
|
598
|
+
vertices,
|
|
599
|
+
neighbors(id) {
|
|
600
|
+
requireSpace(id);
|
|
601
|
+
return edges.filter((edge) => edge.spaceIds.includes(id)).flatMap(
|
|
602
|
+
(edge) => edge.spaceIds.filter((other) => other !== id)
|
|
603
|
+
);
|
|
604
|
+
},
|
|
605
|
+
distance(from, to) {
|
|
606
|
+
return grid.distance(requireSpace(from), requireSpace(to));
|
|
607
|
+
},
|
|
608
|
+
ring(id, radius) {
|
|
609
|
+
return selectedIds(
|
|
610
|
+
new Grid(
|
|
611
|
+
hexClass(orientation),
|
|
612
|
+
ringTraversal({ center: requireSpace(id), radius })
|
|
613
|
+
)
|
|
614
|
+
);
|
|
615
|
+
},
|
|
616
|
+
line(from, to) {
|
|
617
|
+
return selectedIds(
|
|
618
|
+
new Grid(
|
|
619
|
+
hexClass(orientation),
|
|
620
|
+
lineTraversal({ start: requireSpace(from), stop: requireSpace(to) })
|
|
621
|
+
)
|
|
622
|
+
);
|
|
623
|
+
},
|
|
624
|
+
edgesOf(id) {
|
|
625
|
+
requireSpace(id);
|
|
626
|
+
return edgesBySpace.get(id).map((key) => edgeIds.get(key));
|
|
627
|
+
},
|
|
628
|
+
verticesOf(id) {
|
|
629
|
+
requireSpace(id);
|
|
630
|
+
return cornersBySpace.get(id).map((key) => vertexIds.get(key));
|
|
631
|
+
},
|
|
632
|
+
edgeAt(id, side) {
|
|
633
|
+
requireSpace(id);
|
|
634
|
+
const key = edgesBySpace.get(id)[side];
|
|
635
|
+
if (!key)
|
|
636
|
+
throw new Error("Hex side must be an integer from 0 through 5.");
|
|
637
|
+
return edgeIds.get(key);
|
|
638
|
+
},
|
|
639
|
+
vertexAt(id, corner) {
|
|
640
|
+
requireSpace(id);
|
|
641
|
+
const key = cornersBySpace.get(id)[corner];
|
|
642
|
+
if (!key)
|
|
643
|
+
throw new Error("Hex corner must be an integer from 0 through 5.");
|
|
644
|
+
return vertexIds.get(key);
|
|
645
|
+
},
|
|
646
|
+
edge(a, b) {
|
|
647
|
+
requireSpace(a);
|
|
648
|
+
requireSpace(b);
|
|
649
|
+
const edge = edges.find(
|
|
650
|
+
(edge2) => edge2.spaceIds.length === 2 && edge2.spaceIds.includes(a) && edge2.spaceIds.includes(b)
|
|
651
|
+
);
|
|
652
|
+
if (!edge || a === b)
|
|
653
|
+
throw new Error(`Spaces '${a}' and '${b}' do not share an edge.`);
|
|
654
|
+
return edge.id;
|
|
655
|
+
},
|
|
656
|
+
vertex(a, b, c) {
|
|
657
|
+
requireSpace(a);
|
|
658
|
+
requireSpace(b);
|
|
659
|
+
requireSpace(c);
|
|
660
|
+
const vertex = vertices.find(
|
|
661
|
+
(vertex2) => vertex2.spaceIds.length === 3 && [a, b, c].every((id) => vertex2.spaceIds.includes(id))
|
|
662
|
+
);
|
|
663
|
+
if (!vertex || (/* @__PURE__ */ new Set([a, b, c])).size !== 3)
|
|
664
|
+
throw new Error("Spaces do not share exactly one vertex.");
|
|
665
|
+
return vertex.id;
|
|
666
|
+
},
|
|
667
|
+
incidentEdges(vertexId) {
|
|
668
|
+
const vertex = vertices.find((vertex2) => vertex2.id === vertexId);
|
|
669
|
+
if (!vertex) throw new Error(`Unknown vertex '${vertexId}'.`);
|
|
670
|
+
return vertex.edgeIds;
|
|
671
|
+
},
|
|
672
|
+
incidentVertices(edgeId) {
|
|
673
|
+
const edge = edges.find((edge2) => edge2.id === edgeId);
|
|
674
|
+
if (!edge) throw new Error(`Unknown edge '${edgeId}'.`);
|
|
675
|
+
return edge.vertexIds;
|
|
676
|
+
},
|
|
677
|
+
spacesAt(vertexId) {
|
|
678
|
+
const vertex = vertices.find((vertex2) => vertex2.id === vertexId);
|
|
679
|
+
if (!vertex) throw new Error(`Unknown vertex '${vertexId}'.`);
|
|
680
|
+
return vertex.spaceIds;
|
|
681
|
+
},
|
|
682
|
+
spacesAlong(edgeId) {
|
|
683
|
+
const edge = edges.find((edge2) => edge2.id === edgeId);
|
|
684
|
+
if (!edge) throw new Error(`Unknown edge '${edgeId}'.`);
|
|
685
|
+
return edge.spaceIds;
|
|
686
|
+
},
|
|
687
|
+
getLayout({
|
|
688
|
+
hexSize,
|
|
689
|
+
origin = { x: 0, y: 0 }
|
|
690
|
+
}) {
|
|
691
|
+
if (!Number.isFinite(hexSize) || hexSize <= 0)
|
|
692
|
+
throw new Error("hexSize must be positive and finite.");
|
|
693
|
+
const scaled = new Grid(hexClass(orientation, hexSize), spaces);
|
|
694
|
+
const layoutSpaces = spaces.map((space) => {
|
|
695
|
+
const hex = scaled.getHex(space);
|
|
696
|
+
return {
|
|
697
|
+
id: space.id,
|
|
698
|
+
center: { x: hex.x + origin.x, y: hex.y + origin.y },
|
|
699
|
+
corners: hex.corners.map((point) => ({
|
|
700
|
+
x: point.x + origin.x,
|
|
701
|
+
y: point.y + origin.y
|
|
702
|
+
}))
|
|
703
|
+
};
|
|
704
|
+
});
|
|
705
|
+
const points = layoutSpaces.flatMap((space) => space.corners);
|
|
706
|
+
const minX = points.length ? Math.min(...points.map((point) => point.x)) : 0;
|
|
707
|
+
const minY = points.length ? Math.min(...points.map((point) => point.y)) : 0;
|
|
708
|
+
const maxX = points.length ? Math.max(...points.map((point) => point.x)) : 0;
|
|
709
|
+
const maxY = points.length ? Math.max(...points.map((point) => point.y)) : 0;
|
|
710
|
+
const vertexPoints = new Map(
|
|
711
|
+
[...cornerOwners].map(([key, vertex]) => [
|
|
712
|
+
vertexIds.get(key),
|
|
713
|
+
{
|
|
714
|
+
x: vertex.point.x * hexSize + origin.x,
|
|
715
|
+
y: vertex.point.y * hexSize + origin.y
|
|
716
|
+
}
|
|
717
|
+
])
|
|
718
|
+
);
|
|
719
|
+
return {
|
|
720
|
+
viewBox: { x: minX, y: minY, width: maxX - minX, height: maxY - minY },
|
|
721
|
+
spaces: layoutSpaces,
|
|
722
|
+
edges: edges.map((edge) => ({
|
|
723
|
+
id: edge.id,
|
|
724
|
+
from: vertexPoints.get(edge.vertexIds[0]),
|
|
725
|
+
to: vertexPoints.get(edge.vertexIds[1])
|
|
726
|
+
})),
|
|
727
|
+
vertices: vertices.map((vertex) => ({
|
|
728
|
+
id: vertex.id,
|
|
729
|
+
center: vertexPoints.get(vertex.id)
|
|
730
|
+
})),
|
|
731
|
+
pointToSpace(point) {
|
|
732
|
+
const hex = scaled.pointToHex(
|
|
733
|
+
{ x: point.x - origin.x, y: point.y - origin.y },
|
|
734
|
+
{ allowOutside: false }
|
|
735
|
+
);
|
|
736
|
+
return hex ? spacesByCoordinate.get(coordinateKey(hex))?.id : void 0;
|
|
737
|
+
}
|
|
738
|
+
};
|
|
739
|
+
}
|
|
740
|
+
};
|
|
741
|
+
}
|
|
742
|
+
function resolveHexSpaces(board) {
|
|
743
|
+
const excluded = new Set((board.exclude ?? []).map(coordinateKey));
|
|
744
|
+
const coordinates = hexShapeCoordinates(
|
|
745
|
+
board.shape,
|
|
746
|
+
board.orientation
|
|
747
|
+
).filter((coordinate) => !excluded.has(coordinateKey(coordinate)));
|
|
748
|
+
const known = new Set(coordinates.map(coordinateKey));
|
|
749
|
+
for (const key of Object.keys(board.spaces ?? {})) {
|
|
750
|
+
if (!known.has(key))
|
|
751
|
+
throw new Error(
|
|
752
|
+
`Hex board '${board.id}' overrides coordinate '${key}' outside its shape.`
|
|
753
|
+
);
|
|
754
|
+
}
|
|
755
|
+
return coordinates.map((coordinate) => {
|
|
756
|
+
const key = coordinateKey(coordinate);
|
|
757
|
+
return {
|
|
758
|
+
...coordinate,
|
|
759
|
+
...board.spaces?.[key],
|
|
760
|
+
id: board.spaces?.[key]?.id ?? key
|
|
761
|
+
};
|
|
762
|
+
}).sort((a, b) => compare(a.id, b.id));
|
|
763
|
+
}
|
|
764
|
+
|
|
765
|
+
// src/shared/protocol/json.ts
|
|
766
|
+
import { sha256 } from "@noble/hashes/sha2.js";
|
|
767
|
+
import { bytesToHex, utf8ToBytes } from "@noble/hashes/utils.js";
|
|
768
|
+
function canonicalizePluginRuntimeJson(value) {
|
|
769
|
+
return canonicalizeJson(
|
|
770
|
+
RuntimeJsonSchema.parse(omitOptionalProperties(value))
|
|
771
|
+
);
|
|
772
|
+
}
|
|
773
|
+
function encodeCanonicalPluginRuntimeJson(value) {
|
|
774
|
+
return JSON.stringify(canonicalizePluginRuntimeJson(value));
|
|
775
|
+
}
|
|
776
|
+
function digestPluginRuntimeJson(value) {
|
|
777
|
+
return `sha256:${sha256Hex(encodeCanonicalPluginRuntimeJson(value))}`;
|
|
778
|
+
}
|
|
779
|
+
function canonicalizeJson(value) {
|
|
780
|
+
if (value === null || typeof value === "boolean" || typeof value === "string") {
|
|
781
|
+
return value;
|
|
782
|
+
}
|
|
783
|
+
if (typeof value === "number") return value;
|
|
784
|
+
if (Array.isArray(value)) {
|
|
785
|
+
return value.map((item) => canonicalizeJson(item));
|
|
786
|
+
}
|
|
787
|
+
return Object.fromEntries(
|
|
788
|
+
Object.entries(value).sort(([left], [right]) => left < right ? -1 : left > right ? 1 : 0).map(([key, item]) => [key, canonicalizeJson(item)])
|
|
789
|
+
);
|
|
790
|
+
}
|
|
791
|
+
function omitOptionalProperties(value) {
|
|
792
|
+
if (Array.isArray(value)) return value.map(omitOptionalProperties);
|
|
793
|
+
if (value !== null && typeof value === "object" && (Object.getPrototypeOf(value) === Object.prototype || Object.getPrototypeOf(value) === null)) {
|
|
794
|
+
return Object.fromEntries(
|
|
795
|
+
Object.entries(value).filter(([, item]) => item !== void 0).map(([key, item]) => [key, omitOptionalProperties(item)])
|
|
796
|
+
);
|
|
797
|
+
}
|
|
798
|
+
return value;
|
|
799
|
+
}
|
|
800
|
+
function sha256Hex(input) {
|
|
801
|
+
return bytesToHex(sha256(utf8ToBytes(input)));
|
|
802
|
+
}
|
|
803
|
+
|
|
804
|
+
export {
|
|
805
|
+
RuntimeJsonSchema,
|
|
806
|
+
InteractionCommitPolicySchema,
|
|
807
|
+
InputDomainSchema,
|
|
808
|
+
InteractionInputDescriptorSchema,
|
|
809
|
+
InteractionAvailabilitySchema,
|
|
810
|
+
InteractionDescriptorSchema,
|
|
811
|
+
RngDrawSchema,
|
|
812
|
+
GameEventDetailSchema,
|
|
813
|
+
SystemActionEventSchema,
|
|
814
|
+
GameEventSchema,
|
|
815
|
+
ReducerSessionStateSchema,
|
|
816
|
+
GameInputSchema,
|
|
817
|
+
GameOutcomeSchema,
|
|
818
|
+
SimultaneousPhaseProjectionSchema,
|
|
819
|
+
SeatProjectionBundleSchema,
|
|
820
|
+
BoardStaticProjectionSchema,
|
|
821
|
+
runtime_schema_exports,
|
|
822
|
+
hexagon,
|
|
823
|
+
spiral,
|
|
824
|
+
ring,
|
|
825
|
+
rectangle,
|
|
826
|
+
fromCoordinates,
|
|
827
|
+
createHexBoardGeometry,
|
|
828
|
+
resolveHexSpaces,
|
|
829
|
+
canonicalizePluginRuntimeJson,
|
|
830
|
+
encodeCanonicalPluginRuntimeJson,
|
|
831
|
+
digestPluginRuntimeJson
|
|
832
|
+
};
|
|
833
|
+
//# sourceMappingURL=chunk-FMM5LVJW.js.map
|