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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (150) hide show
  1. package/README.md +136 -45
  2. package/dist/chunk-DMFVAZI2.js +16 -0
  3. package/dist/chunk-DMFVAZI2.js.map +1 -0
  4. package/dist/chunk-FMM5LVJW.js +833 -0
  5. package/dist/chunk-FMM5LVJW.js.map +1 -0
  6. package/dist/{chunk-S2JEDVWH.js → chunk-LRILEVKC.js} +6113 -6489
  7. package/dist/chunk-LRILEVKC.js.map +1 -0
  8. package/dist/chunk-SP234IY4.js +1363 -0
  9. package/dist/chunk-SP234IY4.js.map +1 -0
  10. package/dist/chunk-VUWNJXLJ.js +52 -0
  11. package/dist/chunk-VUWNJXLJ.js.map +1 -0
  12. package/dist/chunk-ZPRKWPEP.js +511 -0
  13. package/dist/chunk-ZPRKWPEP.js.map +1 -0
  14. package/dist/definition-BaHNPZol.d.ts +4639 -0
  15. package/dist/diagnostics-B0lgnuZ6.d.ts +65 -0
  16. package/dist/index.d.ts +3553 -1
  17. package/dist/index.js +1045 -6
  18. package/dist/index.js.map +1 -1
  19. package/dist/model-BHro6yXu.d.ts +288 -0
  20. package/dist/react.d.ts +32 -0
  21. package/dist/react.js +80 -0
  22. package/dist/react.js.map +1 -0
  23. package/dist/reducer.d.ts +1194 -79
  24. package/dist/reducer.js +4326 -121
  25. package/dist/reducer.js.map +1 -1
  26. package/dist/testing.d.ts +518 -564
  27. package/dist/testing.js +2448 -915
  28. package/dist/testing.js.map +1 -1
  29. package/dist/types-DimqnJBq.d.ts +86 -0
  30. package/package.json +26 -131
  31. package/dist/HandView-Bi2lxzQP.d.ts +0 -79
  32. package/dist/ResourceCounter-BFxJknqp.d.ts +0 -98
  33. package/dist/ThemeProvider-CElaL2ik.d.ts +0 -99
  34. package/dist/attributes-DbvyMbXw.d.ts +0 -68
  35. package/dist/browser-interaction.d.ts +0 -910
  36. package/dist/browser-interaction.js +0 -119
  37. package/dist/browser-interaction.js.map +0 -1
  38. package/dist/chunk-32PFKDV7.js +0 -11705
  39. package/dist/chunk-32PFKDV7.js.map +0 -1
  40. package/dist/chunk-3BAD4VC2.js +0 -263
  41. package/dist/chunk-3BAD4VC2.js.map +0 -1
  42. package/dist/chunk-3SKDNDPG.js +0 -104
  43. package/dist/chunk-3SKDNDPG.js.map +0 -1
  44. package/dist/chunk-5YV2WHJ4.js +0 -25
  45. package/dist/chunk-5YV2WHJ4.js.map +0 -1
  46. package/dist/chunk-ANRB4XKA.js +0 -90
  47. package/dist/chunk-ANRB4XKA.js.map +0 -1
  48. package/dist/chunk-BI4G3PM2.js +0 -1864
  49. package/dist/chunk-BI4G3PM2.js.map +0 -1
  50. package/dist/chunk-EVCLTY4Q.js +0 -935
  51. package/dist/chunk-EVCLTY4Q.js.map +0 -1
  52. package/dist/chunk-GDPKTBUR.js +0 -564
  53. package/dist/chunk-GDPKTBUR.js.map +0 -1
  54. package/dist/chunk-H6VDGFL5.js +0 -2903
  55. package/dist/chunk-H6VDGFL5.js.map +0 -1
  56. package/dist/chunk-LR3ZTWQF.js +0 -5960
  57. package/dist/chunk-LR3ZTWQF.js.map +0 -1
  58. package/dist/chunk-PF7L4BMG.js +0 -117
  59. package/dist/chunk-PF7L4BMG.js.map +0 -1
  60. package/dist/chunk-PN5O6GG2.js +0 -32
  61. package/dist/chunk-PN5O6GG2.js.map +0 -1
  62. package/dist/chunk-PZ5AY32C.js +0 -10
  63. package/dist/chunk-PZ5AY32C.js.map +0 -1
  64. package/dist/chunk-S2JEDVWH.js.map +0 -1
  65. package/dist/chunk-T3ZKNUZ7.js +0 -1
  66. package/dist/chunk-T3ZKNUZ7.js.map +0 -1
  67. package/dist/chunk-UGH54WZ2.js +0 -223
  68. package/dist/chunk-UGH54WZ2.js.map +0 -1
  69. package/dist/chunk-VCDWP5VL.js +0 -746
  70. package/dist/chunk-VCDWP5VL.js.map +0 -1
  71. package/dist/chunk-VDXOF4FW.js +0 -69
  72. package/dist/chunk-VDXOF4FW.js.map +0 -1
  73. package/dist/chunk-WHR5UW3F.js +0 -1988
  74. package/dist/chunk-WHR5UW3F.js.map +0 -1
  75. package/dist/chunk-Y75CFE77.js +0 -17
  76. package/dist/chunk-Y75CFE77.js.map +0 -1
  77. package/dist/chunk-Z7QCREWI.js +0 -3435
  78. package/dist/chunk-Z7QCREWI.js.map +0 -1
  79. package/dist/chunk-ZZGN2ATS.js +0 -1941
  80. package/dist/chunk-ZZGN2ATS.js.map +0 -1
  81. package/dist/components-gAbIz7hK.d.ts +0 -1284
  82. package/dist/definitions-BgmV_GhC.d.ts +0 -300
  83. package/dist/diagnostics-DIi3ina7.d.ts +0 -50
  84. package/dist/digest.d.ts +0 -8
  85. package/dist/game-CsZScpcn.d.ts +0 -763
  86. package/dist/hex-board-view-aKkblDp6.d.ts +0 -1228
  87. package/dist/index-CcT9Q7N7.d.ts +0 -193
  88. package/dist/index.d-DjzoK7zn.d.ts +0 -2101
  89. package/dist/package-set.d.ts +0 -13
  90. package/dist/package-set.js +0 -12
  91. package/dist/package-set.js.map +0 -1
  92. package/dist/player-state-Cqpyeql0.d.ts +0 -371
  93. package/dist/plugin-runtime-contract.d.ts +0 -17
  94. package/dist/plugin-runtime-contract.js +0 -92
  95. package/dist/plugin-runtime-contract.js.map +0 -1
  96. package/dist/primitive-props-BNHDkgd7.d.ts +0 -16
  97. package/dist/protocol-dYgafTYY.d.ts +0 -314
  98. package/dist/reducer/advanced.d.ts +0 -82
  99. package/dist/reducer/advanced.js +0 -51
  100. package/dist/reducer/advanced.js.map +0 -1
  101. package/dist/reducer-contract.d.ts +0 -11
  102. package/dist/reducer-contract.js +0 -16
  103. package/dist/reducer-contract.js.map +0 -1
  104. package/dist/reference-games/index.d.ts +0 -31
  105. package/dist/reference-games/index.js +0 -48
  106. package/dist/reference-games/index.js.map +0 -1
  107. package/dist/runtime/primitives.d.ts +0 -250
  108. package/dist/runtime/primitives.js +0 -189
  109. package/dist/runtime/primitives.js.map +0 -1
  110. package/dist/runtime/runtime-api.d.ts +0 -2
  111. package/dist/runtime/runtime-api.js +0 -1
  112. package/dist/runtime/runtime-api.js.map +0 -1
  113. package/dist/runtime/workspace-contract.d.ts +0 -392
  114. package/dist/runtime/workspace-contract.js +0 -28
  115. package/dist/runtime/workspace-contract.js.map +0 -1
  116. package/dist/runtime-RJ5orDJU.d.ts +0 -1699
  117. package/dist/runtime-api-Bz5pwNU_.d.ts +0 -296
  118. package/dist/runtime-json-CQ9QbLZ5.d.ts +0 -5
  119. package/dist/runtime.d.ts +0 -83
  120. package/dist/runtime.js +0 -242
  121. package/dist/runtime.js.map +0 -1
  122. package/dist/schema.d.ts +0 -379
  123. package/dist/stale-contract-artifact-error-XLaweZtF.d.ts +0 -18
  124. package/dist/testing-compiler.d.ts +0 -37
  125. package/dist/testing-compiler.js +0 -272
  126. package/dist/testing-compiler.js.map +0 -1
  127. package/dist/testing-runtime.d.ts +0 -119
  128. package/dist/testing-runtime.js +0 -212
  129. package/dist/testing-runtime.js.map +0 -1
  130. package/dist/types-DJj5MJkl.d.ts +0 -256
  131. package/dist/types-DR7DoB1x.d.ts +0 -28
  132. package/dist/types-JWCYHmu7.d.ts +0 -122
  133. package/dist/types.d.ts +0 -1958
  134. package/dist/types.js +0 -14
  135. package/dist/types.js.map +0 -1
  136. package/dist/ui/components.d.ts +0 -17
  137. package/dist/ui/components.js +0 -216
  138. package/dist/ui/components.js.map +0 -1
  139. package/dist/ui/defaults.d.ts +0 -19
  140. package/dist/ui/defaults.js +0 -104
  141. package/dist/ui/defaults.js.map +0 -1
  142. package/dist/ui/player-state.d.ts +0 -2
  143. package/dist/ui/player-state.js +0 -1
  144. package/dist/ui/player-state.js.map +0 -1
  145. package/dist/ui/plugin-styles.css +0 -2
  146. package/dist/ui-contract-GTUPkf8z.d.ts +0 -1168
  147. package/dist/ui.d.ts +0 -317
  148. package/dist/ui.js +0 -277
  149. package/dist/ui.js.map +0 -1
  150. package/dist/views-BpuWcOyN.d.ts +0 -1641
@@ -1,935 +0,0 @@
1
- import {
2
- createClientParamSchemasByPhase
3
- } from "./chunk-PN5O6GG2.js";
4
- import {
5
- Board,
6
- ClientParamSchemaProvider,
7
- Dice,
8
- Game,
9
- HandStagingView,
10
- HandSurfaceView,
11
- Interaction,
12
- Phase,
13
- PlayerRoster,
14
- Prompt,
15
- PromptInbox,
16
- UI,
17
- Zone,
18
- dropTargetIdFor,
19
- isInteractionAvailable,
20
- useResolvedCardTargetValue,
21
- useZoneCards
22
- } from "./chunk-LR3ZTWQF.js";
23
- import {
24
- useAuthoredPluginGameplayFrameSelector
25
- } from "./chunk-GDPKTBUR.js";
26
- import {
27
- CardFace,
28
- Dialog,
29
- DialogContent,
30
- DialogDescription,
31
- DialogHeader,
32
- DialogTitle,
33
- DialogTrigger,
34
- MobileHandTrayProvider,
35
- ToastProvider,
36
- createResourceCounter,
37
- useIsMobile,
38
- useRegisterMobileHand
39
- } from "./chunk-32PFKDV7.js";
40
-
41
- // src/runtime/workspace-contract/index.ts
42
- import { Fragment, createElement as createElement6 } from "react";
43
-
44
- // src/runtime/ui-contract.ts
45
- function createDreamboardUI(contract) {
46
- return {
47
- contract,
48
- Root: UI.Root,
49
- Game,
50
- Interaction,
51
- Prompt,
52
- PromptInbox,
53
- PlayerRoster,
54
- Dice,
55
- Phase,
56
- Zone,
57
- Board
58
- };
59
- }
60
-
61
- // src/runtime/workspace-contract/board.ts
62
- import { createElement as createElement2 } from "react";
63
-
64
- // src/runtime/workspace-contract/slots.ts
65
- import { Fragment as ReactFragment, createElement } from "react";
66
- function CardSlotValue({
67
- children
68
- }) {
69
- const value = useResolvedCardTargetValue();
70
- return createElement(ReactFragment, null, children(value));
71
- }
72
- function createFormInputSlot(ctx, input, interaction) {
73
- const { baseUI, withInteractionRoot } = ctx;
74
- return {
75
- Field: (props) => {
76
- const field = createElement(baseUI.Interaction.Field, {
77
- ...props,
78
- input
79
- });
80
- return interaction ? withInteractionRoot(interaction, field) : field;
81
- },
82
- Options: () => null,
83
- Value: ({
84
- children
85
- }) => createElement(ReactFragment, null, children(void 0)),
86
- Default: ({ children }) => createElement(ReactFragment, null, children)
87
- };
88
- }
89
- function createCardInputSlot(ctx) {
90
- const { runtimeInteraction } = ctx;
91
- return {
92
- Card: ({ value, ...props }) => createElement(runtimeInteraction.CardInput, {
93
- ...props,
94
- input: "cardId",
95
- unsafeCardId: value
96
- }),
97
- Cards: () => null,
98
- Value: ({
99
- children
100
- }) => createElement(CardSlotValue, { children }),
101
- Default: ({ children }) => createElement(ReactFragment, null, children)
102
- };
103
- }
104
- function createBoardTargetInputSlot(ctx, kind) {
105
- const { runtimeBoard } = ctx;
106
- const Target = ({
107
- value,
108
- ...props
109
- }) => {
110
- if (kind === "edge") {
111
- return createElement(runtimeBoard.EdgeTarget, { ...props, value });
112
- }
113
- if (kind === "vertex") {
114
- return createElement(runtimeBoard.VertexTarget, { ...props, value });
115
- }
116
- return createElement(runtimeBoard.SpaceTarget, { ...props, value });
117
- };
118
- return {
119
- Target,
120
- Value: ({
121
- children
122
- }) => createElement(ReactFragment, null, children(void 0)),
123
- Default: ({ children }) => createElement(ReactFragment, null, children)
124
- };
125
- }
126
-
127
- // src/runtime/workspace-contract/board.ts
128
- function createUseBoardSurface(ctx) {
129
- const { baseUI, runtimeBoard } = ctx;
130
- return function useBoardSurface() {
131
- return {
132
- Root: ({ children }) => createElement2(baseUI.Board.Root, { children }),
133
- Space: (props) => createElement2(runtimeBoard.SpaceTarget, props),
134
- slot: {
135
- space: createBoardTargetInputSlot(ctx, "space"),
136
- playerSpace: createBoardTargetInputSlot(ctx, "space"),
137
- edge: createBoardTargetInputSlot(ctx, "edge"),
138
- vertex: createBoardTargetInputSlot(ctx, "vertex"),
139
- tile: createBoardTargetInputSlot(ctx, "tile")
140
- }
141
- };
142
- };
143
- }
144
- function createBoardNamespace(ctx) {
145
- const { options, baseUI } = ctx;
146
- const useBoardSurface = createUseBoardSurface(ctx);
147
- return {
148
- surface(board) {
149
- return { kind: "board", board };
150
- },
151
- useSurface: useBoardSurface,
152
- HexView({ board: boardId, ...props }) {
153
- return createElement2(
154
- baseUI.Board.HexView,
155
- {
156
- ...props,
157
- board: options.hexStaticBoards[boardId]
158
- }
159
- );
160
- },
161
- HexGrid({ board: boardId, ...props }) {
162
- return createElement2(
163
- baseUI.Board.HexGrid,
164
- {
165
- ...props,
166
- board: options.hexStaticBoards[boardId]
167
- }
168
- );
169
- },
170
- SquareGrid({ board: boardId, ...props }) {
171
- return createElement2(
172
- baseUI.Board.SquareGrid,
173
- {
174
- ...props,
175
- board: options.squareStaticBoards?.[boardId]
176
- }
177
- );
178
- }
179
- };
180
- }
181
-
182
- // src/runtime/workspace-contract/forms.ts
183
- import { createElement as createElement3 } from "react";
184
- function createInteractionForms(ctx) {
185
- const { options, baseUI, runtimeInteraction, withInteractionRoot } = ctx;
186
- function InteractionRoutes({
187
- routes,
188
- fallback,
189
- includeUnavailable
190
- }) {
191
- return createElement3(runtimeInteraction.Routes, {
192
- routes,
193
- fallback,
194
- includeUnavailable
195
- });
196
- }
197
- function GeneratedFormDialog({
198
- title,
199
- description,
200
- trigger,
201
- children,
202
- contentClassName,
203
- overlayClassName,
204
- showCloseButton,
205
- defaultOpen,
206
- onStateChange
207
- }) {
208
- return createElement3(baseUI.Interaction.Dialog, {
209
- defaultOpen,
210
- onStateChange,
211
- children: (state) => createElement3(
212
- Dialog,
213
- { open: state.open, onOpenChange: state.setOpen },
214
- trigger ? createElement3(DialogTrigger, {
215
- asChild: true,
216
- children: trigger
217
- }) : null,
218
- createElement3(
219
- DialogContent,
220
- {
221
- className: contentClassName,
222
- overlayClassName,
223
- showCloseButton
224
- },
225
- createElement3(
226
- DialogHeader,
227
- null,
228
- createElement3(DialogTitle, null, title),
229
- description ? createElement3(DialogDescription, null, description) : null
230
- ),
231
- children
232
- )
233
- )
234
- });
235
- }
236
- function useInteractionFormSurface(interaction) {
237
- const validInputs = options.formInputKeysForInteraction(interaction);
238
- const slot = Object.fromEntries(
239
- [...validInputs].map((input) => [
240
- input,
241
- createFormInputSlot(ctx, input, interaction)
242
- ])
243
- );
244
- return {
245
- Root: ({ children }) => withInteractionRoot(interaction, children),
246
- Form: (props) => withInteractionRoot(
247
- interaction,
248
- createElement3(baseUI.Interaction.Form, props)
249
- ),
250
- Dialog: (props) => withInteractionRoot(
251
- interaction,
252
- createElement3(GeneratedFormDialog, props)
253
- ),
254
- State: (props) => withInteractionRoot(
255
- interaction,
256
- createElement3(baseUI.Interaction.State, props)
257
- ),
258
- Arm: (props) => withInteractionRoot(
259
- interaction,
260
- createElement3(baseUI.Interaction.Trigger, props)
261
- ),
262
- Submit: (props) => withInteractionRoot(
263
- interaction,
264
- createElement3(baseUI.Interaction.Submit, props)
265
- ),
266
- Field: ({ input, ...props }) => withInteractionRoot(
267
- interaction,
268
- createElement3(baseUI.Interaction.Field, {
269
- ...props,
270
- input
271
- })
272
- ),
273
- slot
274
- };
275
- }
276
- const Interaction2 = {
277
- State: baseUI.Interaction.State,
278
- Dialog: baseUI.Interaction.Dialog,
279
- useForm: useInteractionFormSurface,
280
- form(interaction) {
281
- return { kind: "form", interaction };
282
- },
283
- forms(interactions) {
284
- return { kind: "forms", interactions };
285
- },
286
- Routes: InteractionRoutes
287
- };
288
- return { Interaction: Interaction2, useInteractionFormSurface };
289
- }
290
-
291
- // src/runtime/workspace-contract/surfaces.ts
292
- function isPlainObject(value) {
293
- return !!value && typeof value === "object" && !Array.isArray(value);
294
- }
295
- function isSurfaceDescriptor(value) {
296
- return isPlainObject(value) && typeof value.kind === "string";
297
- }
298
- function createSurfaceResolvers({
299
- Board: Board2,
300
- Zone: Zone2,
301
- useInteractionFormSurface
302
- }) {
303
- const boardSurface = Board2.useSurface;
304
- const zoneHandSurface = Zone2.useHand;
305
- const zonePileSurface = Zone2.usePile;
306
- const zoneCardCollectionSurface = Zone2.useCardCollection;
307
- const interactionFormSurface = useInteractionFormSurface;
308
- function resolveSurfaceDescriptor(name, descriptor) {
309
- switch (descriptor.kind) {
310
- case "board":
311
- return boardSurface(name);
312
- case "hand":
313
- return zoneHandSurface(name, {
314
- zone: descriptor.zone,
315
- role: descriptor.role,
316
- label: descriptor.label,
317
- order: descriptor.order
318
- });
319
- case "pile":
320
- return zonePileSurface(name, { zone: descriptor.zone });
321
- case "piles":
322
- return Object.fromEntries(
323
- descriptor.zones.map((zone) => [
324
- zone,
325
- zonePileSurface(String(zone), { zone })
326
- ])
327
- );
328
- case "cardCollection":
329
- return zoneCardCollectionSurface(name, {
330
- zones: descriptor.zones,
331
- mode: descriptor.mode
332
- });
333
- case "form":
334
- return interactionFormSurface(descriptor.interaction);
335
- case "forms":
336
- return Object.fromEntries(
337
- Object.entries(descriptor.interactions).map(([key, interaction]) => [
338
- key,
339
- interactionFormSurface(interaction)
340
- ])
341
- );
342
- }
343
- }
344
- function resolveSurfaceSpec(spec) {
345
- return Object.fromEntries(
346
- Object.entries(spec).map(([key, value]) => [
347
- key,
348
- isSurfaceDescriptor(value) ? resolveSurfaceDescriptor(key, value) : resolveSurfaceSpec(value)
349
- ])
350
- );
351
- }
352
- function defineSurfaces(spec) {
353
- return function useDefinedSurfaces() {
354
- return resolveSurfaceSpec(spec);
355
- };
356
- }
357
- return { defineSurfaces, resolveSurfaceSpec, resolveSurfaceDescriptor };
358
- }
359
-
360
- // src/runtime/workspace-contract/zones.ts
361
- import { Fragment as ReactFragment2, createElement as createElement5 } from "react";
362
- import { clsx as clsx2 } from "clsx";
363
-
364
- // src/runtime/workspace-contract/hand.ts
365
- import { Children, createElement as createElement4, isValidElement, useMemo } from "react";
366
- import { clsx } from "clsx";
367
- function createHandPieces(ctx) {
368
- const { baseUI } = ctx;
369
- function HandCardsSlot({
370
- children
371
- }) {
372
- void children;
373
- return createElement4("template", { "data-dreamboard-hand-cards-slot": "" });
374
- }
375
- function HandSummarySlot({
376
- children
377
- }) {
378
- void children;
379
- return createElement4("template", {
380
- "data-dreamboard-hand-summary-slot": ""
381
- });
382
- }
383
- function HandActionsSlot({
384
- children
385
- }) {
386
- void children;
387
- return createElement4("template", {
388
- "data-dreamboard-hand-actions-slot": ""
389
- });
390
- }
391
- function renderHandSlot(slot, summary) {
392
- return typeof slot === "function" ? slot(summary) : slot;
393
- }
394
- function createHandCardsComponent(options) {
395
- return ({
396
- empty,
397
- children,
398
- className,
399
- layout,
400
- mobileInteraction,
401
- cardSize,
402
- ariaLabel,
403
- dropTargets,
404
- renderDropTargets,
405
- onCardIntent,
406
- onSelectionSummary,
407
- ...props
408
- }) => {
409
- const slots = collectHandSlots(children);
410
- const renderCard = typeof children === "function" ? children : slots.cards?.children;
411
- if (!renderCard) {
412
- throw new Error(
413
- "Generated hand surfaces require exactly one <hand.Cards> slot."
414
- );
415
- }
416
- const summaryRenderer = slots.summary ? (summary) => renderHandSlot(slots.summary.children, summary) : void 0;
417
- const actionsRenderer = slots.actions ? (summary) => renderHandSlot(slots.actions.children, summary) : void 0;
418
- return createElement4(baseUI.Zone.Root, {
419
- zone: options.zone,
420
- // Fill the author's container instead of shrink-wrapping to the fan's
421
- // own measured width. Without a definite width here, a centering parent
422
- // sizes to the cards row, the hand measures that, recomputes a new fan
423
- // width, and the layout chases itself (a ResizeObserver loop). `w-full`
424
- // pins the outermost hand element to the available width and breaks the
425
- // cycle for every author layout.
426
- className: "w-full min-w-0",
427
- children: createElement4(GeneratedHandCards, {
428
- ...props,
429
- hand: options,
430
- className,
431
- empty,
432
- children: renderCard,
433
- layout,
434
- mobileInteraction,
435
- cardSize,
436
- ariaLabel,
437
- dropTargets,
438
- renderDropTargets,
439
- onCardIntent,
440
- summarySlot: summaryRenderer,
441
- actionsSlot: actionsRenderer,
442
- onSelectionSummary
443
- })
444
- });
445
- };
446
- }
447
- function collectHandSlots(children) {
448
- const slots = {};
449
- if (typeof children === "function") return slots;
450
- for (const child of Children.toArray(children)) {
451
- if (!isValidElement(child)) continue;
452
- if (child.type === HandCardsSlot) {
453
- if (slots.cards) {
454
- throw new Error("Only one <hand.Cards> slot may be rendered.");
455
- }
456
- slots.cards = child.props;
457
- } else if (child.type === HandSummarySlot) {
458
- if (slots.summary) {
459
- throw new Error("Only one <hand.Summary> slot may be rendered.");
460
- }
461
- slots.summary = child.props;
462
- } else if (child.type === HandActionsSlot) {
463
- if (slots.actions) {
464
- throw new Error("Only one <hand.Actions> slot may be rendered.");
465
- }
466
- slots.actions = child.props;
467
- }
468
- }
469
- return slots;
470
- }
471
- function GeneratedHandCards({
472
- hand,
473
- empty,
474
- children,
475
- className,
476
- sort,
477
- layout,
478
- mobileInteraction,
479
- cardSize,
480
- ariaLabel,
481
- dropTargets,
482
- renderDropTargets,
483
- onCardIntent,
484
- summarySlot,
485
- actionsSlot,
486
- onSelectionSummary
487
- }) {
488
- const isMobile = useIsMobile();
489
- const { items, count } = useZoneCards({ sort });
490
- const handClassName = clsx("min-h-[112px]", className);
491
- const resolvedDropTargets = useMemo(() => {
492
- if (!dropTargets || dropTargets.length === 0) return void 0;
493
- return dropTargets.map((dt) => {
494
- const value = dt.target.kind === "card" ? dt.target.card : dt.target.target;
495
- return {
496
- targetId: dropTargetIdFor(dt.target.kind, value),
497
- label: dt.label,
498
- render: dt.render,
499
- className: dt.className,
500
- role: dt.role,
501
- order: dt.order
502
- };
503
- });
504
- }, [dropTargets]);
505
- const content = useMemo(
506
- () => createElement4(HandSurfaceView, {
507
- zone: hand.zone,
508
- cards: items,
509
- renderCard: (card, state) => children(card, state),
510
- layout,
511
- mobileInteraction,
512
- dropTargets: resolvedDropTargets,
513
- renderDropTargets,
514
- cardSize,
515
- renderEmpty: empty !== void 0 ? () => empty : void 0,
516
- ariaLabel,
517
- onIntentRouted: onCardIntent ? (intent) => onCardIntent(intent) : void 0,
518
- summarySlot,
519
- actionsSlot,
520
- onSelectionSummary,
521
- className: handClassName
522
- }),
523
- [
524
- ariaLabel,
525
- cardSize,
526
- children,
527
- empty,
528
- hand.zone,
529
- handClassName,
530
- items,
531
- layout,
532
- mobileInteraction,
533
- onCardIntent,
534
- onSelectionSummary,
535
- actionsSlot,
536
- renderDropTargets,
537
- summarySlot,
538
- resolvedDropTargets
539
- ]
540
- );
541
- const active = items.some(
542
- (item) => !item.hidden && item.interactions.some(
543
- (descriptor) => isInteractionAvailable(descriptor)
544
- )
545
- );
546
- const autoOpen = items.some(
547
- (item) => !item.hidden && item.interactions.some(
548
- (descriptor) => isInteractionAvailable(descriptor) && descriptor.inputs.some(
549
- (input) => input.domain.type === "cardTarget" && input.domain.selection?.mode === "many"
550
- )
551
- )
552
- );
553
- const version = items.map(
554
- (item) => item.hidden ? `${item.id}:hidden` : `${item.id}:${item.cardType}:${JSON.stringify(item.properties)}`
555
- ).join("|");
556
- const registration = useMemo(
557
- () => ({
558
- id: `${hand.name}:${hand.zone}`,
559
- zone: hand.zone,
560
- label: hand.label,
561
- role: hand.role,
562
- order: hand.order,
563
- version,
564
- count,
565
- active,
566
- autoOpen,
567
- content: createElement4(baseUI.Zone.Root, {
568
- zone: hand.zone,
569
- children: content
570
- })
571
- }),
572
- [
573
- active,
574
- autoOpen,
575
- content,
576
- count,
577
- hand.label,
578
- hand.name,
579
- hand.order,
580
- hand.role,
581
- hand.zone,
582
- version
583
- ]
584
- );
585
- useRegisterMobileHand(registration);
586
- return isMobile ? null : content;
587
- }
588
- function createStagingComponent(options) {
589
- return ({
590
- children,
591
- label,
592
- renderEmptySlot,
593
- cardSize,
594
- ariaLabel,
595
- className
596
- }) => createElement4(HandStagingView, {
597
- zone: options.zone,
598
- renderCard: (card) => children(card),
599
- renderEmptySlot,
600
- label,
601
- cardSize,
602
- ariaLabel,
603
- className
604
- });
605
- }
606
- return {
607
- createHandCardsComponent,
608
- createStagingComponent,
609
- HandCardsSlot,
610
- HandSummarySlot,
611
- HandActionsSlot
612
- };
613
- }
614
-
615
- // src/runtime/workspace-contract/zones.ts
616
- var DEFAULT_ZONE_CARD_CLASS = "group relative border-0 bg-transparent p-0 transition-transform enabled:cursor-pointer enabled:hover:-translate-y-2 data-[selected=true]:-translate-y-3 disabled:cursor-not-allowed data-[eligible=false]:opacity-45 data-[eligible=false]:grayscale data-[eligible=false]:hover:translate-y-0 data-[card-available=false]:opacity-45 data-[card-available=false]:grayscale";
617
- function cardRenderItemToViewCard(card, cardId) {
618
- if (card && typeof card === "object" && "hidden" in card && card.hidden === false) {
619
- return card;
620
- }
621
- return {
622
- id: cardId,
623
- cardType: "hidden",
624
- name: "Hidden card",
625
- properties: {}
626
- };
627
- }
628
- function createZoneCardsComponent(ctx, zones) {
629
- const { baseUI, runtimeZone } = ctx;
630
- return ({
631
- empty,
632
- children,
633
- ...props
634
- }) => createElement5(
635
- ReactFragment2,
636
- null,
637
- ...zones.map(
638
- (zone) => createElement5(baseUI.Zone.Root, {
639
- key: zone,
640
- zone,
641
- children: createElement5(runtimeZone.List, {
642
- ...props,
643
- empty,
644
- children
645
- })
646
- })
647
- )
648
- );
649
- }
650
- function createZoneCardComponent(ctx) {
651
- const { options, baseUI, runtimeInteraction } = ctx;
652
- return ({
653
- card,
654
- children,
655
- className,
656
- ...props
657
- }) => {
658
- const cardId = options.cardIdFromZoneCard(card);
659
- const zone = options.zoneIdFromZoneCard(card);
660
- const viewCard = cardRenderItemToViewCard(card, cardId);
661
- const faceDown = !!card && typeof card === "object" && "hidden" in card && card.hidden === true;
662
- const renderCardFace = (state) => createElement5(CardFace, {
663
- card: viewCard,
664
- selected: state.selected,
665
- disabled: state.disabled || !state.eligible,
666
- faceDown,
667
- size: "sm",
668
- children
669
- });
670
- const match = useAuthoredPluginGameplayFrameSelector((frame) => {
671
- const candidates = frame.zones[zone]?.playableByCardId[cardId] ?? [];
672
- const orderedCandidates = [...candidates].sort((left, right) => {
673
- const leftAvailable = left.availability.status === "available";
674
- const rightAvailable = right.availability.status === "available";
675
- return leftAvailable === rightAvailable ? 0 : leftAvailable ? -1 : 1;
676
- });
677
- for (const descriptor of orderedCandidates) {
678
- const input = descriptor.inputs.find(
679
- (candidateInput) => candidateInput.domain.type === "cardTarget" && candidateInput.domain.projection === "resolved" && candidateInput.domain.eligibleTargets.includes(cardId)
680
- );
681
- if (input) return { descriptor, input };
682
- }
683
- return null;
684
- });
685
- if (!match) {
686
- return createElement5(
687
- "div",
688
- {
689
- ...props,
690
- className: clsx2("relative inline-flex", className),
691
- "data-dreamboard-zone-card": "",
692
- "data-card-id": cardId,
693
- "data-zone": zone,
694
- "data-interactive": false
695
- },
696
- createElement5(CardFace, {
697
- card: viewCard,
698
- faceDown,
699
- size: "sm",
700
- children
701
- })
702
- );
703
- }
704
- return createElement5(baseUI.Zone.Root, {
705
- zone,
706
- children: createElement5(runtimeInteraction.Root, {
707
- interaction: match.descriptor.interactionKey,
708
- children: createElement5(runtimeInteraction.CardInput, {
709
- ...props,
710
- className: clsx2(DEFAULT_ZONE_CARD_CLASS, className),
711
- input: match.input.key,
712
- unsafeCardId: cardId,
713
- children: renderCardFace
714
- })
715
- })
716
- });
717
- };
718
- }
719
- function createZoneNamespace(ctx) {
720
- const {
721
- createHandCardsComponent,
722
- createStagingComponent,
723
- HandCardsSlot,
724
- HandSummarySlot,
725
- HandActionsSlot
726
- } = createHandPieces(ctx);
727
- return {
728
- hand(zone, options) {
729
- return { kind: "hand", zone, ...options };
730
- },
731
- pile(zone) {
732
- return { kind: "pile", zone };
733
- },
734
- piles(zones) {
735
- return { kind: "piles", zones };
736
- },
737
- collection(zones, options = {}) {
738
- return { kind: "cardCollection", zones, mode: options.mode };
739
- },
740
- useHand(_name, zoneOptions) {
741
- const handComponentOptions = {
742
- name: _name,
743
- zone: zoneOptions.zone,
744
- role: zoneOptions.role,
745
- label: zoneOptions.label,
746
- order: zoneOptions.order
747
- };
748
- return {
749
- Hand: createHandCardsComponent(handComponentOptions),
750
- Cards: HandCardsSlot,
751
- Summary: HandSummarySlot,
752
- Actions: HandActionsSlot,
753
- Card: createZoneCardComponent(ctx),
754
- Staging: createStagingComponent(handComponentOptions),
755
- slot: { card: createCardInputSlot(ctx) }
756
- };
757
- },
758
- usePile(_name, zoneOptions) {
759
- return {
760
- Pile: createZoneCardsComponent(ctx, [zoneOptions.zone]),
761
- Card: createZoneCardComponent(ctx)
762
- };
763
- },
764
- useCardCollection(_name, zoneOptions) {
765
- void zoneOptions.mode;
766
- return {
767
- Collection: createZoneCardsComponent(ctx, zoneOptions.zones),
768
- Card: createZoneCardComponent(ctx),
769
- slot: { card: createCardInputSlot(ctx) }
770
- };
771
- }
772
- };
773
- }
774
-
775
- // src/runtime/workspace-contract/game-ui-contract.ts
776
- function createGameUiContract(options) {
777
- const uiContract = {
778
- interactions: {},
779
- inputs: {},
780
- prompts: {},
781
- promptOptions: {},
782
- players: {},
783
- zones: {},
784
- cards: {},
785
- phases: {},
786
- boardTargets: {}
787
- };
788
- const clientParamSchemasByPhase = createClientParamSchemasByPhase(
789
- options.game
790
- );
791
- const formInputKeysForInteraction = (interaction) => {
792
- const [phase, id] = interaction.split(".", 2);
793
- const phaseSpec = phase ? options.game.phases?.[phase] : void 0;
794
- const phaseRecord = phaseSpec;
795
- const spec = (id ? phaseRecord?.interactions?.[id] : void 0) ?? (id ? phaseRecord?.cardActions?.[id] : void 0) ?? (id === "submit" ? phaseRecord?.submit : void 0);
796
- return new Set(
797
- Object.entries(spec?.inputs ?? {}).filter(
798
- ([, collector]) => collector.kind === "form" || collector.kind === "prompt"
799
- ).map(([input]) => input)
800
- );
801
- };
802
- const UI2 = createWorkspaceUIContract({
803
- uiContract,
804
- clientParamSchemasByPhase,
805
- formInputKeysForInteraction,
806
- resourceIds: options.resourceIds,
807
- resourcePresentationById: options.resourcePresentationById,
808
- hexStaticBoards: options.hexStaticBoards,
809
- squareStaticBoards: options.squareStaticBoards,
810
- cardIdFromZoneCard: (card) => card.id,
811
- zoneIdFromZoneCard: (card) => card.zone
812
- });
813
- return { uiContract, UI: UI2, clientParamSchemasByPhase };
814
- }
815
-
816
- // src/runtime/workspace-contract/index.ts
817
- function createWorkspaceUIContract(options) {
818
- const baseUI = createDreamboardUI(options.uiContract);
819
- const runtimeInteraction = baseUI.Interaction;
820
- const runtimeBoard = baseUI.Board;
821
- const runtimeZone = baseUI.Zone;
822
- const runtimeGameRoot = baseUI.Game.Root;
823
- const runtimePhaseSwitch = baseUI.Phase.Switch;
824
- const ctx = {
825
- options,
826
- // The context carries the contract-erased view of the UI: every consumer
827
- // already neutralizes key genericity (`as never` inputs/zones), exactly as
828
- // the original single-file factory did with its `Runtime*` casts.
829
- baseUI,
830
- runtimeInteraction,
831
- runtimeBoard,
832
- runtimeZone,
833
- withInteractionRoot: (interaction, children) => createElement6(runtimeInteraction.Root, {
834
- interaction,
835
- children
836
- })
837
- };
838
- const resourceDisplayConfig = options.resourceIds.map((resource) => {
839
- const presentation = options.resourcePresentationById?.[resource];
840
- return {
841
- type: resource,
842
- label: presentation?.label ?? resource,
843
- icon: presentation?.icon ?? resource
844
- };
845
- });
846
- const resourceCounter = createResourceCounter(
847
- resourceDisplayConfig
848
- );
849
- const { Interaction: Interaction2, useInteractionFormSurface } = createInteractionForms(ctx);
850
- const Board2 = createBoardNamespace(ctx);
851
- const Zone2 = createZoneNamespace(ctx);
852
- const { defineSurfaces } = createSurfaceResolvers({
853
- Board: Board2,
854
- Zone: Zone2,
855
- useInteractionFormSurface
856
- });
857
- const UI2 = {
858
- ...baseUI,
859
- Root: ({ children, ...props }) => createElement6(ClientParamSchemaProvider, {
860
- schemas: options.clientParamSchemasByPhase,
861
- children: createElement6(ToastProvider, {
862
- children: createElement6(MobileHandTrayProvider, {
863
- children: createElement6(baseUI.Root, { ...props, children })
864
- })
865
- })
866
- }),
867
- defineSurfaces,
868
- defineGameUI({
869
- useSurfaces,
870
- interactionRoutes,
871
- phases,
872
- renderInteractions,
873
- fallback,
874
- includeUnavailableInteractions
875
- }) {
876
- function DefinedGameUIFrame({ game }) {
877
- const surfaces = useSurfaces();
878
- const phaseRoutes = Object.fromEntries(
879
- Object.entries(phases).map(([phase, render]) => [
880
- phase,
881
- () => render({ game, surfaces })
882
- ])
883
- );
884
- const routeMap = interactionRoutes?.({ game, surfaces });
885
- return createElement6(
886
- Fragment,
887
- null,
888
- routeMap ? createElement6(runtimeInteraction.Routes, {
889
- routes: routeMap,
890
- includeUnavailable: includeUnavailableInteractions
891
- }) : null,
892
- createElement6(runtimePhaseSwitch, {
893
- routes: phaseRoutes,
894
- fallback
895
- }),
896
- renderInteractions?.({ game, surfaces }) ?? null
897
- );
898
- }
899
- return function DefinedGameUI(props) {
900
- return createElement6(UI2.Root, {
901
- ...props,
902
- children: createElement6(runtimeGameRoot, {
903
- children: (rawGame) => createElement6(DefinedGameUIFrame, {
904
- game: rawGame
905
- })
906
- })
907
- });
908
- };
909
- },
910
- Interaction: Interaction2,
911
- Board: Board2,
912
- Zone: Zone2,
913
- ResourceCounter: resourceCounter
914
- };
915
- return UI2;
916
- }
917
-
918
- // src/runtime/workspace-contract/create-game-ui.ts
919
- function createGameUi(game) {
920
- const manifest = game.contract.manifest;
921
- return createGameUiContract({
922
- game,
923
- resourceIds: manifest.literals.resourceIds,
924
- resourcePresentationById: manifest.literals.resourcePresentationById,
925
- hexStaticBoards: manifest.staticBoards?.hex ?? {},
926
- squareStaticBoards: manifest.staticBoards?.square ?? {}
927
- });
928
- }
929
-
930
- export {
931
- createGameUiContract,
932
- createWorkspaceUIContract,
933
- createGameUi
934
- };
935
- //# sourceMappingURL=chunk-EVCLTY4Q.js.map