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

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 (113) hide show
  1. package/README.md +127 -0
  2. package/dist/browser-interaction.d.ts +22 -22
  3. package/dist/{chunk-VRRR6QZT.js → chunk-32PFKDV7.js} +170 -406
  4. package/dist/chunk-32PFKDV7.js.map +1 -0
  5. package/dist/{chunk-N33CGX2F.js → chunk-3BAD4VC2.js} +3 -3
  6. package/dist/{chunk-LMHCGCA6.js → chunk-3SKDNDPG.js} +2 -2
  7. package/dist/chunk-5YV2WHJ4.js +25 -0
  8. package/dist/chunk-5YV2WHJ4.js.map +1 -0
  9. package/dist/{chunk-VWTKGIYF.js → chunk-ANRB4XKA.js} +1 -1
  10. package/dist/chunk-ANRB4XKA.js.map +1 -0
  11. package/dist/{chunk-EOEA3I64.js → chunk-BI4G3PM2.js} +7 -7
  12. package/dist/chunk-BI4G3PM2.js.map +1 -0
  13. package/dist/{chunk-KRJPRYEA.js → chunk-EVCLTY4Q.js} +21 -8
  14. package/dist/chunk-EVCLTY4Q.js.map +1 -0
  15. package/dist/{chunk-DQS2EG5E.js → chunk-GDPKTBUR.js} +2 -2
  16. package/dist/{chunk-FL67RDID.js → chunk-H6VDGFL5.js} +128 -128
  17. package/dist/chunk-H6VDGFL5.js.map +1 -0
  18. package/dist/{chunk-6LMESVGT.js → chunk-LR3ZTWQF.js} +3 -3
  19. package/dist/chunk-LR3ZTWQF.js.map +1 -0
  20. package/dist/{chunk-TXELBVTG.js → chunk-PN5O6GG2.js} +2 -2
  21. package/dist/{chunk-533O7C4L.js → chunk-S2JEDVWH.js} +500 -430
  22. package/dist/chunk-S2JEDVWH.js.map +1 -0
  23. package/dist/{chunk-2GQIALJL.js → chunk-UGH54WZ2.js} +6 -2
  24. package/dist/chunk-UGH54WZ2.js.map +1 -0
  25. package/dist/chunk-VCDWP5VL.js +746 -0
  26. package/dist/chunk-VCDWP5VL.js.map +1 -0
  27. package/dist/{chunk-ZSTCUJKZ.js → chunk-Y75CFE77.js} +2 -6
  28. package/dist/chunk-Y75CFE77.js.map +1 -0
  29. package/dist/chunk-Z7QCREWI.js +3435 -0
  30. package/dist/chunk-Z7QCREWI.js.map +1 -0
  31. package/dist/chunk-ZZGN2ATS.js +1941 -0
  32. package/dist/chunk-ZZGN2ATS.js.map +1 -0
  33. package/dist/{components-CNAt5J1p.d.ts → components-gAbIz7hK.d.ts} +2 -18
  34. package/dist/{definitions-bZSBaPjj.d.ts → definitions-BgmV_GhC.d.ts} +3 -3
  35. package/dist/digest.d.ts +2 -2
  36. package/dist/game-CsZScpcn.d.ts +763 -0
  37. package/dist/{index-CR69MyWr.d.ts → index-CcT9Q7N7.d.ts} +1 -1
  38. package/dist/{index.d-Bw8AOcgp.d.ts → index.d-DjzoK7zn.d.ts} +67 -2
  39. package/dist/index.js +1 -2
  40. package/dist/package-set.js +1 -2
  41. package/dist/plugin-runtime-contract.d.ts +4 -4
  42. package/dist/plugin-runtime-contract.js +13 -15
  43. package/dist/{protocol-CVaSqPgX.d.ts → protocol-dYgafTYY.d.ts} +1 -7
  44. package/dist/reducer/advanced.d.ts +12 -11
  45. package/dist/reducer/advanced.js +10 -4
  46. package/dist/reducer-contract.d.ts +10 -2
  47. package/dist/reducer-contract.js +4 -4
  48. package/dist/reducer.d.ts +12 -689
  49. package/dist/reducer.js +19 -1293
  50. package/dist/reducer.js.map +1 -1
  51. package/dist/runtime/primitives.d.ts +4 -4
  52. package/dist/runtime/primitives.js +5 -5
  53. package/dist/runtime/runtime-api.d.ts +2 -2
  54. package/dist/runtime/workspace-contract.d.ts +50 -17
  55. package/dist/runtime/workspace-contract.js +15 -10
  56. package/dist/{runtime-C7Z2acNU.d.ts → runtime-RJ5orDJU.d.ts} +23 -30
  57. package/dist/{plugin-state-BRH3UiUp.d.ts → runtime-api-Bz5pwNU_.d.ts} +86 -4
  58. package/dist/runtime.d.ts +8 -8
  59. package/dist/runtime.js +19 -17
  60. package/dist/runtime.js.map +1 -1
  61. package/dist/schema.d.ts +2 -28
  62. package/dist/testing-compiler.d.ts +4 -4
  63. package/dist/testing-runtime.d.ts +7 -7
  64. package/dist/testing-runtime.js +6 -6
  65. package/dist/testing.d.ts +17 -17
  66. package/dist/testing.js +14 -14
  67. package/dist/{types-q1Guidm5.d.ts → types-DR7DoB1x.d.ts} +1 -1
  68. package/dist/{types-DN4O7kH_.d.ts → types-JWCYHmu7.d.ts} +2 -2
  69. package/dist/types.js +6 -18
  70. package/dist/types.js.map +1 -1
  71. package/dist/ui/components.d.ts +3 -4
  72. package/dist/ui/components.js +1 -5
  73. package/dist/{ui-contract-BC4JpysE.d.ts → ui-contract-GTUPkf8z.d.ts} +175 -176
  74. package/dist/ui.d.ts +4 -5
  75. package/dist/ui.js +2 -6
  76. package/dist/{views-D2Cfzr3h.d.ts → views-BpuWcOyN.d.ts} +101 -48
  77. package/package.json +3 -22
  78. package/dist/authoring/index.d.ts +0 -59
  79. package/dist/authoring/index.js +0 -24
  80. package/dist/authoring/index.js.map +0 -1
  81. package/dist/authoring-compiler.d.ts +0 -27
  82. package/dist/authoring-compiler.js +0 -11
  83. package/dist/authoring-compiler.js.map +0 -1
  84. package/dist/authoring-materialize-cli.d.ts +0 -1
  85. package/dist/authoring-materialize-cli.js +0 -45
  86. package/dist/authoring-materialize-cli.js.map +0 -1
  87. package/dist/chunk-2GQIALJL.js.map +0 -1
  88. package/dist/chunk-533O7C4L.js.map +0 -1
  89. package/dist/chunk-6LMESVGT.js.map +0 -1
  90. package/dist/chunk-EOEA3I64.js.map +0 -1
  91. package/dist/chunk-FL67RDID.js.map +0 -1
  92. package/dist/chunk-HIH6Y4FA.js +0 -7802
  93. package/dist/chunk-HIH6Y4FA.js.map +0 -1
  94. package/dist/chunk-HUK4234C.js +0 -166
  95. package/dist/chunk-HUK4234C.js.map +0 -1
  96. package/dist/chunk-KGV2EUNN.js +0 -532
  97. package/dist/chunk-KGV2EUNN.js.map +0 -1
  98. package/dist/chunk-KRJPRYEA.js.map +0 -1
  99. package/dist/chunk-KWHOFBDM.js +0 -9
  100. package/dist/chunk-KWHOFBDM.js.map +0 -1
  101. package/dist/chunk-VRRR6QZT.js.map +0 -1
  102. package/dist/chunk-VWTKGIYF.js.map +0 -1
  103. package/dist/chunk-XFMSLL3P.js +0 -637
  104. package/dist/chunk-XFMSLL3P.js.map +0 -1
  105. package/dist/chunk-ZSTCUJKZ.js.map +0 -1
  106. package/dist/codegen.d.ts +0 -941
  107. package/dist/codegen.js +0 -44
  108. package/dist/codegen.js.map +0 -1
  109. package/dist/runtime-api-CgPuEVeF.d.ts +0 -86
  110. /package/dist/{chunk-N33CGX2F.js.map → chunk-3BAD4VC2.js.map} +0 -0
  111. /package/dist/{chunk-LMHCGCA6.js.map → chunk-3SKDNDPG.js.map} +0 -0
  112. /package/dist/{chunk-DQS2EG5E.js.map → chunk-GDPKTBUR.js.map} +0 -0
  113. /package/dist/{chunk-TXELBVTG.js.map → chunk-PN5O6GG2.js.map} +0 -0
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/reducer/setup-bootstrap-helpers.ts"],"sourcesContent":["import type {\n CardIdOfManifest,\n DieIdOfManifest,\n GeneratedManifestContractLike,\n PieceIdOfManifest,\n PlayerIdOfManifest,\n SetupBootstrapContainerRef,\n SetupBootstrapPerPlayerContainerTemplateRef,\n SetupBootstrapStep,\n SetupBootstrapDestinationRef,\n} from \"./model\";\n\nexport function shuffle<\n Manifest extends GeneratedManifestContractLike =\n GeneratedManifestContractLike,\n>(\n container: SetupBootstrapContainerRef<Manifest>,\n): SetupBootstrapStep<Manifest> {\n return {\n type: \"shuffle\",\n container,\n };\n}\n\nexport function dealToPlayerZone<\n Manifest extends GeneratedManifestContractLike =\n GeneratedManifestContractLike,\n>({\n from,\n zoneId,\n count,\n playerIds,\n}: {\n from: Extract<\n SetupBootstrapContainerRef<Manifest>,\n { type: \"sharedZone\" | \"sharedBoardContainer\" }\n >;\n zoneId: Extract<\n SetupBootstrapPerPlayerContainerTemplateRef<Manifest>,\n { type: \"playerZone\" }\n >[\"zoneId\"];\n count: number;\n playerIds?: readonly PlayerIdOfManifest<Manifest>[];\n}): SetupBootstrapStep<Manifest> {\n return {\n type: \"deal\",\n from,\n to: {\n type: \"playerZone\",\n zoneId,\n } as SetupBootstrapPerPlayerContainerTemplateRef<Manifest>,\n count,\n playerIds,\n };\n}\n\nexport function dealToPlayerBoardContainer<\n Manifest extends GeneratedManifestContractLike =\n GeneratedManifestContractLike,\n>({\n from,\n boardId,\n containerId,\n count,\n playerIds,\n}: {\n from: Extract<\n SetupBootstrapContainerRef<Manifest>,\n { type: \"sharedZone\" | \"sharedBoardContainer\" }\n >;\n boardId: Extract<\n SetupBootstrapPerPlayerContainerTemplateRef<Manifest>,\n { type: \"playerBoardContainer\" }\n >[\"boardId\"];\n containerId: Extract<\n SetupBootstrapPerPlayerContainerTemplateRef<Manifest>,\n { type: \"playerBoardContainer\" }\n >[\"containerId\"];\n count: number;\n playerIds?: readonly PlayerIdOfManifest<Manifest>[];\n}): SetupBootstrapStep<Manifest> {\n return {\n type: \"deal\",\n from,\n to: {\n type: \"playerBoardContainer\",\n boardId,\n containerId,\n } as SetupBootstrapPerPlayerContainerTemplateRef<Manifest>,\n count,\n playerIds,\n };\n}\n\nexport function seedSharedBoardContainer<\n Manifest extends GeneratedManifestContractLike =\n GeneratedManifestContractLike,\n>({\n from,\n boardId,\n containerId,\n count,\n componentIds,\n}: {\n from: SetupBootstrapContainerRef<Manifest>;\n boardId: Extract<\n SetupBootstrapDestinationRef<Manifest>,\n { type: \"sharedBoardContainer\" }\n >[\"boardId\"];\n containerId: Extract<\n SetupBootstrapDestinationRef<Manifest>,\n { type: \"sharedBoardContainer\" }\n >[\"containerId\"];\n count?: number;\n componentIds?: readonly (\n | CardIdOfManifest<Manifest>\n | PieceIdOfManifest<Manifest>\n | DieIdOfManifest<Manifest>\n )[];\n}): SetupBootstrapStep<Manifest> {\n return {\n type: \"move\",\n from,\n to: {\n type: \"sharedBoardContainer\",\n boardId,\n containerId,\n } as SetupBootstrapDestinationRef<Manifest>,\n count,\n componentIds,\n };\n}\n\nexport function seedSharedBoardSpace<\n Manifest extends GeneratedManifestContractLike =\n GeneratedManifestContractLike,\n>({\n from,\n boardId,\n spaceId,\n count,\n componentIds,\n}: {\n from: SetupBootstrapContainerRef<Manifest>;\n boardId: Extract<\n SetupBootstrapDestinationRef<Manifest>,\n { type: \"sharedBoardSpace\" }\n >[\"boardId\"];\n spaceId: Extract<\n SetupBootstrapDestinationRef<Manifest>,\n { type: \"sharedBoardSpace\" }\n >[\"spaceId\"];\n count?: number;\n componentIds?: readonly (\n | CardIdOfManifest<Manifest>\n | PieceIdOfManifest<Manifest>\n | DieIdOfManifest<Manifest>\n )[];\n}): SetupBootstrapStep<Manifest> {\n return {\n type: \"move\",\n from,\n to: {\n type: \"sharedBoardSpace\",\n boardId,\n spaceId,\n } as SetupBootstrapDestinationRef<Manifest>,\n count,\n componentIds,\n };\n}\n"],"mappings":";AAYO,SAAS,QAId,WAC8B;AAC9B,SAAO;AAAA,IACL,MAAM;AAAA,IACN;AAAA,EACF;AACF;AAEO,SAAS,iBAGd;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,GAWiC;AAC/B,SAAO;AAAA,IACL,MAAM;AAAA,IACN;AAAA,IACA,IAAI;AAAA,MACF,MAAM;AAAA,MACN;AAAA,IACF;AAAA,IACA;AAAA,IACA;AAAA,EACF;AACF;AAEO,SAAS,2BAGd;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,GAeiC;AAC/B,SAAO;AAAA,IACL,MAAM;AAAA,IACN;AAAA,IACA,IAAI;AAAA,MACF,MAAM;AAAA,MACN;AAAA,MACA;AAAA,IACF;AAAA,IACA;AAAA,IACA;AAAA,EACF;AACF;AAEO,SAAS,yBAGd;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,GAgBiC;AAC/B,SAAO;AAAA,IACL,MAAM;AAAA,IACN;AAAA,IACA,IAAI;AAAA,MACF,MAAM;AAAA,MACN;AAAA,MACA;AAAA,IACF;AAAA,IACA;AAAA,IACA;AAAA,EACF;AACF;AAEO,SAAS,qBAGd;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,GAgBiC;AAC/B,SAAO;AAAA,IACL,MAAM;AAAA,IACN;AAAA,IACA,IAAI;AAAA,MACF,MAAM;AAAA,MACN;AAAA,MACA;AAAA,IACF;AAAA,IACA;AAAA,IACA;AAAA,EACF;AACF;","names":[]}
@@ -1,637 +0,0 @@
1
- // ../plugin-runtime-contract/dist/chunk-XS3PILAY.js
2
- import { sha256 } from "@noble/hashes/sha2.js";
3
- import { bytesToHex, utf8ToBytes } from "@noble/hashes/utils.js";
4
- function canonicalizePluginRuntimeJson(value) {
5
- assertRuntimeJson(value);
6
- return canonicalizeJson(value);
7
- }
8
- function encodeCanonicalPluginRuntimeJson(value) {
9
- return JSON.stringify(canonicalizePluginRuntimeJson(value));
10
- }
11
- function digestPluginRuntimeJson(value) {
12
- return `sha256:${sha256Hex(encodeCanonicalPluginRuntimeJson(value))}`;
13
- }
14
- function canonicalizeJson(value) {
15
- if (value === null || typeof value === "boolean" || typeof value === "string") {
16
- return value;
17
- }
18
- if (typeof value === "number") {
19
- if (!Number.isFinite(value)) {
20
- throw new Error("canonical JSON contains a non-finite number");
21
- }
22
- return value;
23
- }
24
- if (Array.isArray(value)) {
25
- return value.map((item) => canonicalizeJson(item));
26
- }
27
- return Object.fromEntries(
28
- Object.entries(value).filter(([, item]) => item !== void 0).sort(([left], [right]) => left < right ? -1 : left > right ? 1 : 0).map(([key, item]) => [key, canonicalizeJson(item)])
29
- );
30
- }
31
- function assertRuntimeJson(value) {
32
- if (value === null || typeof value === "boolean" || typeof value === "string") {
33
- return;
34
- }
35
- if (typeof value === "number") {
36
- if (!Number.isFinite(value)) {
37
- throw new Error("runtime JSON contains a non-finite number");
38
- }
39
- return;
40
- }
41
- if (Array.isArray(value)) {
42
- value.forEach(assertRuntimeJson);
43
- return;
44
- }
45
- if (typeof value === "object") {
46
- Object.values(value).forEach((item) => {
47
- if (item !== void 0) {
48
- assertRuntimeJson(item);
49
- }
50
- });
51
- return;
52
- }
53
- throw new Error(`runtime JSON contains unsupported ${typeof value} value`);
54
- }
55
- function sha256Hex(input) {
56
- return bytesToHex(sha256(utf8ToBytes(input)));
57
- }
58
- function computePluginActionSetVersion(input) {
59
- return digestPluginRuntimeJson({
60
- digestVersion: "plugin-action-set@4",
61
- version: input.version,
62
- availableInteractions: input.availableInteractions
63
- });
64
- }
65
- function digestPluginGameplayFrame(frame) {
66
- return digestPluginRuntimeJson({
67
- digestVersion: "plugin-gameplay-frame@4",
68
- frame
69
- });
70
- }
71
- function digestPluginCommandRequest(command) {
72
- return digestPluginRuntimeJson({
73
- digestVersion: "plugin-command-request@4",
74
- command
75
- });
76
- }
77
-
78
- // ../plugin-runtime-contract/dist/chunk-T75JHL5B.js
79
- import { z } from "zod";
80
- var DREAMBOARD_PLUGIN_PROTOCOL = "dreamboard-plugin";
81
- var DREAMBOARD_PLUGIN_PROTOCOL_VERSION = 4;
82
- var RuntimeJsonSchema = z.lazy(
83
- () => z.union([
84
- z.null(),
85
- z.boolean(),
86
- z.number().finite(),
87
- z.string(),
88
- z.array(RuntimeJsonSchema),
89
- z.record(z.string(), RuntimeJsonSchema)
90
- ])
91
- );
92
- var BoardStaticProjectionSchema = z.object({
93
- view: RuntimeJsonSchema,
94
- hash: z.string().optional(),
95
- manifestVersion: z.string().optional()
96
- }).strict();
97
- var SetupGuidanceStepSchema = z.object({
98
- id: z.string().min(1),
99
- label: z.string().min(1),
100
- description: z.string().optional()
101
- }).strict();
102
- var GameGuidanceProjectionSchema = z.object({
103
- phase: z.object({
104
- id: z.string().min(1),
105
- label: z.string().min(1),
106
- summary: z.string().optional(),
107
- objective: z.string().optional()
108
- }).strict(),
109
- setup: z.object({
110
- profileId: z.string().min(1),
111
- name: z.string().min(1),
112
- summary: z.string().optional(),
113
- steps: z.array(SetupGuidanceStepSchema)
114
- }).strict().optional()
115
- }).strict();
116
- var GameEventDetailSchema = z.object({
117
- label: z.string().min(1),
118
- value: z.union([z.string(), z.number().finite(), z.boolean()])
119
- }).strict();
120
- var SystemActionEventSchema = z.object({
121
- kind: z.literal("systemAction"),
122
- procedureId: z.string().min(1),
123
- title: z.string().min(1),
124
- summary: z.string().optional(),
125
- details: z.array(GameEventDetailSchema).optional()
126
- }).strict();
127
- var GameEventSchema = z.discriminatedUnion("kind", [
128
- SystemActionEventSchema
129
- ]);
130
- var ProjectedGameEventSchema = GameEventSchema.and(
131
- z.object({
132
- version: z.number().int().nonnegative(),
133
- index: z.number().int().nonnegative()
134
- }).strict()
135
- );
136
- var SeatProjectionBundleSchema = z.object({
137
- currentStage: z.string().nullable().optional(),
138
- stageSeats: z.array(z.string()).optional(),
139
- simultaneousPhase: z.unknown().nullable().optional(),
140
- schedulerFlow: z.object({
141
- version: z.literal(1),
142
- activePlayerIds: z.array(z.string()),
143
- pendingPlayerIds: z.array(z.string()),
144
- continuationDependencies: z.array(
145
- z.object({
146
- waiterPlayerId: z.string(),
147
- blockerPlayerIds: z.array(z.string())
148
- }).strict()
149
- )
150
- }).strict().optional(),
151
- guidance: GameGuidanceProjectionSchema.nullable().optional(),
152
- recentEvents: z.array(ProjectedGameEventSchema).optional(),
153
- sharedView: z.unknown().optional(),
154
- interactionsByRef: z.record(z.string(), z.unknown()).optional(),
155
- seats: z.record(
156
- z.string(),
157
- z.object({
158
- view: z.unknown().optional(),
159
- availableInteractionRefs: z.array(z.string()).optional(),
160
- zones: z.unknown().optional()
161
- }).strict()
162
- )
163
- }).strict();
164
- var PlayerIdSchema = z.string().min(1);
165
- var PluginPlayerSummarySchema = z.object({
166
- playerId: PlayerIdSchema,
167
- displayName: z.string(),
168
- color: z.string().optional()
169
- }).strict();
170
- var PluginSessionDescriptorSchema = z.object({
171
- sessionId: z.string().min(1),
172
- players: z.array(PluginPlayerSummarySchema)
173
- }).strict();
174
- var InteractionCommitPolicySchema = z.discriminatedUnion("mode", [
175
- z.object({ mode: z.literal("manual") }).strict(),
176
- z.object({ mode: z.literal("autoWhenReady") }).strict()
177
- ]);
178
- var InputSelectionSchema = z.discriminatedUnion("mode", [
179
- z.object({ mode: z.literal("single") }).strict(),
180
- z.object({
181
- mode: z.literal("many"),
182
- min: z.number().int(),
183
- max: z.number().int().optional(),
184
- distinct: z.boolean().optional()
185
- }).strict()
186
- ]);
187
- var InputDomainDependencyCaseSchema = z.lazy(
188
- () => z.object({
189
- when: z.record(z.string(), z.string()),
190
- domain: InputDomainSchema
191
- }).strict()
192
- );
193
- var InputDomainDependenciesSchema = z.discriminatedUnion("mode", [
194
- z.object({
195
- mode: z.literal("eager"),
196
- dependentCases: z.array(InputDomainDependencyCaseSchema)
197
- }).strict(),
198
- z.object({
199
- mode: z.literal("lazy"),
200
- dependsOn: z.array(z.string()),
201
- resolver: z.object({
202
- interactionKey: z.string().optional(),
203
- inputKey: z.string()
204
- }).strict()
205
- }).strict()
206
- ]);
207
- var InputDomainSchema = z.object({
208
- type: z.string(),
209
- selection: InputSelectionSchema.optional(),
210
- dependencies: InputDomainDependenciesSchema.optional()
211
- }).catchall(RuntimeJsonSchema);
212
- var InteractionChoiceOptionSchema = z.object({
213
- value: z.string().nullable(),
214
- label: z.string(),
215
- icon: z.string().optional(),
216
- badge: z.string().optional(),
217
- description: z.string().optional(),
218
- disabled: z.boolean().optional(),
219
- disabledReason: z.string().optional()
220
- }).strict();
221
- var InteractionInputDescriptorSchema = z.object({
222
- key: z.string().min(1),
223
- kind: z.string().min(1),
224
- domain: InputDomainSchema,
225
- defaultValue: RuntimeJsonSchema.optional()
226
- }).strict();
227
- var InteractionAvailabilitySchema = z.discriminatedUnion("status", [
228
- z.object({ status: z.literal("available") }).strict(),
229
- z.object({ status: z.literal("notYourTurn"), reason: z.string() }).strict(),
230
- z.object({
231
- status: z.literal("insufficientResources"),
232
- reason: z.string(),
233
- missingResources: z.record(z.string(), z.number().finite())
234
- }).strict(),
235
- z.object({
236
- status: z.literal("blocked"),
237
- reason: z.string(),
238
- code: z.string().optional()
239
- }).strict()
240
- ]);
241
- var InteractionBaseSchema = z.object({
242
- phaseName: z.string().min(1),
243
- interactionKey: z.string().min(1),
244
- interactionId: z.string().min(1),
245
- label: z.string().min(1),
246
- help: z.string().optional(),
247
- zoneId: z.string().optional(),
248
- zoneIds: z.array(z.string()).optional(),
249
- commit: InteractionCommitPolicySchema,
250
- descriptorDigest: z.string().optional(),
251
- actorSeat: z.number().int().optional(),
252
- draftDigest: z.string().optional(),
253
- inputs: z.array(InteractionInputDescriptorSchema),
254
- cost: z.record(z.string(), RuntimeJsonSchema).optional(),
255
- currentResources: z.record(z.string(), RuntimeJsonSchema).optional(),
256
- availability: InteractionAvailabilitySchema,
257
- reasons: z.array(
258
- z.object({
259
- ruleId: z.string(),
260
- errorCode: z.string()
261
- }).strict()
262
- ).optional()
263
- }).strict();
264
- var InteractionContextSchema = z.object({
265
- to: z.string().min(1),
266
- title: z.string().optional(),
267
- payload: z.record(z.string(), RuntimeJsonSchema).optional(),
268
- options: z.array(
269
- z.object({
270
- id: z.string(),
271
- label: z.string().optional()
272
- }).strict()
273
- ).optional()
274
- }).strict();
275
- var InteractionDescriptorSchema = z.discriminatedUnion("kind", [
276
- InteractionBaseSchema.extend({ kind: z.literal("action") }).strict(),
277
- InteractionBaseSchema.extend({
278
- kind: z.literal("prompt"),
279
- context: InteractionContextSchema
280
- }).strict()
281
- ]);
282
- var ZoneHandlesSnapshotSchema = z.object({
283
- cardIds: z.array(z.string()),
284
- cardViewsById: z.record(z.string(), z.string()),
285
- playableByCardId: z.record(
286
- z.string(),
287
- z.array(InteractionDescriptorSchema)
288
- )
289
- }).strict();
290
- var SimultaneousPhaseSnapshotSchema = z.object({
291
- phaseName: z.string().min(1),
292
- interactionId: z.string().min(1),
293
- actorIds: z.array(PlayerIdSchema),
294
- sealedPlayerIds: z.array(PlayerIdSchema),
295
- pendingPlayerIds: z.array(PlayerIdSchema)
296
- }).strict();
297
- var GameplayBasisSchema = z.object({
298
- version: z.number().int().nonnegative(),
299
- actionSetVersion: z.string().min(1),
300
- perspectivePlayerId: PlayerIdSchema
301
- }).strict();
302
- var GameOutcomeSchema = z.object({
303
- reason: z.object({
304
- code: z.string().min(1),
305
- message: z.string().optional()
306
- }).strict(),
307
- standings: z.array(
308
- z.object({
309
- playerId: PlayerIdSchema,
310
- rank: z.number().int().positive(),
311
- result: z.enum(["win", "draw", "loss", "eliminated"]),
312
- score: z.number().finite().optional(),
313
- scoreBreakdown: z.array(
314
- z.object({
315
- id: z.string().min(1),
316
- label: z.string().min(1),
317
- value: z.number().finite()
318
- }).strict()
319
- ).optional(),
320
- tieBreaks: z.array(
321
- z.object({
322
- id: z.string().min(1),
323
- label: z.string().min(1),
324
- value: z.union([z.number().finite(), z.string()])
325
- }).strict()
326
- ).optional()
327
- }).strict()
328
- )
329
- }).strict();
330
- var PluginGameplayFrameSchema = z.object({
331
- basis: GameplayBasisSchema,
332
- view: RuntimeJsonSchema.nullable(),
333
- flow: z.object({
334
- currentPhase: z.string().nullable(),
335
- currentStage: z.string().nullable(),
336
- activePlayers: z.array(PlayerIdSchema),
337
- simultaneousPhase: SimultaneousPhaseSnapshotSchema.nullable()
338
- }).strict(),
339
- availableInteractions: z.array(InteractionDescriptorSchema),
340
- guidance: GameGuidanceProjectionSchema.nullable().optional(),
341
- recentEvents: z.array(ProjectedGameEventSchema),
342
- zones: z.record(z.string(), ZoneHandlesSnapshotSchema)
343
- }).strict();
344
- var InteractionResultSchema = z.discriminatedUnion("accepted", [
345
- z.object({
346
- type: z.literal("interaction.result"),
347
- clientActionId: z.string().min(1),
348
- accepted: z.literal(true)
349
- }).strict(),
350
- z.object({
351
- type: z.literal("interaction.result"),
352
- clientActionId: z.string().min(1),
353
- accepted: z.literal(false),
354
- errorCode: z.string().min(1),
355
- message: z.string().optional()
356
- }).strict()
357
- ]);
358
- var SubmitInteractionCommandSchema = z.object({
359
- type: z.literal("interaction.submit"),
360
- clientActionId: z.string().min(1),
361
- basis: GameplayBasisSchema,
362
- interactionId: z.string().min(1),
363
- params: RuntimeJsonSchema
364
- }).strict();
365
- var HostToPluginPayloadSchema = z.discriminatedUnion("type", [
366
- z.object({
367
- type: z.literal("runtime.init"),
368
- session: PluginSessionDescriptorSchema
369
- }).strict(),
370
- z.object({
371
- type: z.literal("gameplay.frame"),
372
- frame: PluginGameplayFrameSchema
373
- }).strict(),
374
- InteractionResultSchema
375
- ]);
376
- var PluginToHostPayloadSchema = z.discriminatedUnion("type", [
377
- z.object({ type: z.literal("runtime.ready") }).strict(),
378
- z.object({
379
- type: z.literal("runtime.ack"),
380
- sequence: z.number().int().nonnegative(),
381
- clientReceivedAtMs: z.number().finite().optional(),
382
- clientRenderedAtMs: z.number().finite().optional()
383
- }).strict(),
384
- SubmitInteractionCommandSchema,
385
- z.object({
386
- type: z.literal("runtime.error"),
387
- message: z.string(),
388
- code: z.string().optional()
389
- }).strict()
390
- ]);
391
- function createPluginProtocolEnvelopeSchema(payloadSchema) {
392
- return z.object({
393
- protocol: z.literal(DREAMBOARD_PLUGIN_PROTOCOL),
394
- version: z.literal(DREAMBOARD_PLUGIN_PROTOCOL_VERSION),
395
- channelId: z.string().min(1),
396
- sequence: z.number().int().nonnegative(),
397
- payload: payloadSchema
398
- }).strict();
399
- }
400
- var HostToPluginEnvelopeSchema = createPluginProtocolEnvelopeSchema(
401
- HostToPluginPayloadSchema
402
- );
403
- var PluginToHostEnvelopeSchema = createPluginProtocolEnvelopeSchema(
404
- PluginToHostPayloadSchema
405
- );
406
- var PluginProtocolFrameSchema = z.object({
407
- id: z.string().min(1),
408
- frame: PluginGameplayFrameSchema,
409
- projectionDigest: z.string().regex(/^sha256:[a-f0-9]{64}$/)
410
- }).strict();
411
- var PluginProtocolStepSchema = z.discriminatedUnion("kind", [
412
- z.object({
413
- id: z.string().min(1),
414
- kind: z.literal("host.frame"),
415
- frameId: z.string().min(1)
416
- }).strict(),
417
- z.object({
418
- id: z.string().min(1),
419
- kind: z.literal("client.submit"),
420
- fromFrameId: z.string().min(1),
421
- requestDigest: z.string().regex(/^sha256:[a-f0-9]{64}$/),
422
- response: InteractionResultSchema
423
- }).strict()
424
- ]);
425
- var PluginProtocolTapeSchema = z.object({
426
- session: PluginSessionDescriptorSchema,
427
- frames: z.array(PluginProtocolFrameSchema),
428
- steps: z.array(PluginProtocolStepSchema)
429
- }).strict();
430
- function parsePluginSessionDescriptor(value) {
431
- return PluginSessionDescriptorSchema.parse(value);
432
- }
433
- function parsePluginGameplayFrame(value) {
434
- return PluginGameplayFrameSchema.parse(value);
435
- }
436
- function parseHostToPluginEnvelope(value) {
437
- return HostToPluginEnvelopeSchema.parse(value);
438
- }
439
- function parsePluginToHostEnvelope(value) {
440
- return PluginToHostEnvelopeSchema.parse(value);
441
- }
442
-
443
- // ../plugin-runtime-contract/dist/index.js
444
- function materializePluginGameplayFrame(input) {
445
- const dynamicProjection = SeatProjectionBundleSchema.parse(
446
- canonicalizeReducerProjection(input.dynamicProjection)
447
- );
448
- const staticProjection = input.staticProjection == null ? null : BoardStaticProjectionSchema.parse(
449
- canonicalizeReducerProjection(input.staticProjection)
450
- );
451
- const registry = parseInteractionRegistry(
452
- dynamicProjection.interactionsByRef
453
- );
454
- const seat = dynamicProjection.seats[input.perspectivePlayerId] ?? null;
455
- const availableInteractions = seat == null ? [] : hydrateInteractionRefs(
456
- registry,
457
- seat.availableInteractionRefs,
458
- "availableInteractionRefs"
459
- );
460
- const zones = seat?.zones == null ? {} : hydrateZones(registry, seat.zones, "zones");
461
- const frame = {
462
- basis: {
463
- version: input.version,
464
- actionSetVersion: input.actionSetVersion,
465
- perspectivePlayerId: input.perspectivePlayerId
466
- },
467
- view: materializeView(staticProjection, dynamicProjection, seat?.view),
468
- flow: {
469
- currentPhase: input.currentPhase,
470
- currentStage: dynamicProjection.currentStage ?? null,
471
- activePlayers: [...input.activePlayers],
472
- simultaneousPhase: dynamicProjection.simultaneousPhase ?? null
473
- },
474
- availableInteractions,
475
- guidance: dynamicProjection.guidance ?? null,
476
- recentEvents: [...dynamicProjection.recentEvents ?? []],
477
- zones
478
- };
479
- return PluginGameplayFrameSchema.parse(frame);
480
- }
481
- function materializeView(staticProjection, dynamicProjection, seatView) {
482
- const parts = [
483
- staticProjection?.view,
484
- dynamicProjection.sharedView,
485
- seatView
486
- ].filter((part) => part !== void 0 && part !== null);
487
- if (parts.length === 0) return null;
488
- if (parts.every(isRecord)) {
489
- return Object.assign({}, ...parts);
490
- }
491
- return seatView ?? dynamicProjection.sharedView ?? staticProjection?.view ?? null;
492
- }
493
- function canonicalizeReducerProjection(value) {
494
- return canonicalizePluginRuntimeJson(value);
495
- }
496
- function parseInteractionRegistry(value) {
497
- if (value == null) return {};
498
- if (!isRecord(value)) {
499
- throw new Error("Seat projection interactionsByRef must be an object.");
500
- }
501
- return Object.fromEntries(
502
- Object.entries(value).map(([ref, descriptor]) => [
503
- ref,
504
- InteractionDescriptorSchema.parse(descriptor)
505
- ])
506
- );
507
- }
508
- function hydrateZones(registry, value, path) {
509
- if (!isRecord(value)) {
510
- throw new Error(`Seat projection ${path} must be an object.`);
511
- }
512
- return Object.fromEntries(
513
- Object.entries(value).map(([zoneId, zoneValue]) => [
514
- zoneId,
515
- hydrateZone(registry, zoneValue, `${path}.${zoneId}`)
516
- ])
517
- );
518
- }
519
- function hydrateZone(registry, value, path) {
520
- if (!isRecord(value)) {
521
- throw new Error(`Seat projection ${path} must be an object.`);
522
- }
523
- const cardIds = arrayOfStrings(value.cardIds, `${path}.cardIds`);
524
- const cardViewsById = stringRecord(
525
- value.cardViewsById,
526
- `${path}.cardViewsById`
527
- );
528
- if (!isRecord(value.playableByCardId)) {
529
- throw new Error(
530
- `Seat projection ${path}.playableByCardId must be an object.`
531
- );
532
- }
533
- const playableByCardId = Object.fromEntries(
534
- Object.entries(value.playableByCardId).map(([cardId, refs]) => [
535
- cardId,
536
- hydrateInteractionRefs(
537
- registry,
538
- refs,
539
- `${path}.playableByCardId.${cardId}`
540
- )
541
- ])
542
- );
543
- return ZoneHandlesSnapshotSchema.parse({
544
- cardIds,
545
- cardViewsById,
546
- playableByCardId
547
- });
548
- }
549
- function hydrateInteractionRefs(registry, value, path) {
550
- if (!Array.isArray(value)) {
551
- throw new Error(`Seat projection ${path} must be an array of refs.`);
552
- }
553
- return value.map((ref, index) => {
554
- if (typeof ref !== "string") {
555
- throw new Error(
556
- `Seat projection ${path}[${index}] must be a ref string.`
557
- );
558
- }
559
- const descriptor = registry[ref];
560
- if (!descriptor) {
561
- throw new Error(
562
- `Seat projection ${path}[${index}] references '${ref}', which is missing from interactionsByRef.`
563
- );
564
- }
565
- return descriptor;
566
- });
567
- }
568
- function arrayOfStrings(value, path) {
569
- if (!Array.isArray(value) || value.some((item) => typeof item !== "string")) {
570
- throw new Error(`Seat projection ${path} must be an array of strings.`);
571
- }
572
- return value;
573
- }
574
- function stringRecord(value, path) {
575
- if (!isRecord(value)) {
576
- throw new Error(`Seat projection ${path} must be an object.`);
577
- }
578
- const result = {};
579
- for (const [key, item] of Object.entries(value)) {
580
- if (typeof item !== "string") {
581
- throw new Error(`Seat projection ${path}.${key} must be a string.`);
582
- }
583
- result[key] = item;
584
- }
585
- return result;
586
- }
587
- function isRecord(value) {
588
- return value !== null && typeof value === "object" && !Array.isArray(value) && (Object.getPrototypeOf(value) === Object.prototype || Object.getPrototypeOf(value) === null);
589
- }
590
-
591
- export {
592
- canonicalizePluginRuntimeJson,
593
- encodeCanonicalPluginRuntimeJson,
594
- digestPluginRuntimeJson,
595
- computePluginActionSetVersion,
596
- digestPluginGameplayFrame,
597
- digestPluginCommandRequest,
598
- DREAMBOARD_PLUGIN_PROTOCOL,
599
- DREAMBOARD_PLUGIN_PROTOCOL_VERSION,
600
- RuntimeJsonSchema,
601
- BoardStaticProjectionSchema,
602
- GameEventDetailSchema,
603
- SystemActionEventSchema,
604
- GameEventSchema,
605
- ProjectedGameEventSchema,
606
- SeatProjectionBundleSchema,
607
- PluginPlayerSummarySchema,
608
- PluginSessionDescriptorSchema,
609
- InteractionCommitPolicySchema,
610
- InputDomainDependenciesSchema,
611
- InputDomainSchema,
612
- InteractionInputDescriptorSchema,
613
- InteractionAvailabilitySchema,
614
- InteractionContextSchema,
615
- InteractionDescriptorSchema,
616
- ZoneHandlesSnapshotSchema,
617
- SimultaneousPhaseSnapshotSchema,
618
- GameplayBasisSchema,
619
- GameOutcomeSchema,
620
- PluginGameplayFrameSchema,
621
- InteractionResultSchema,
622
- SubmitInteractionCommandSchema,
623
- HostToPluginPayloadSchema,
624
- PluginToHostPayloadSchema,
625
- createPluginProtocolEnvelopeSchema,
626
- HostToPluginEnvelopeSchema,
627
- PluginToHostEnvelopeSchema,
628
- PluginProtocolFrameSchema,
629
- PluginProtocolStepSchema,
630
- PluginProtocolTapeSchema,
631
- parsePluginSessionDescriptor,
632
- parsePluginGameplayFrame,
633
- parseHostToPluginEnvelope,
634
- parsePluginToHostEnvelope,
635
- materializePluginGameplayFrame
636
- };
637
- //# sourceMappingURL=chunk-XFMSLL3P.js.map