@dreamboard-games/ui-sdk 0.0.42 → 0.0.45

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 (166) hide show
  1. package/dist/components/ActionButton.d.ts.map +1 -1
  2. package/dist/components/ActionButton.js +2 -1
  3. package/dist/components/Card.d.ts +1 -1
  4. package/dist/components/Card.d.ts.map +1 -1
  5. package/dist/components/DiceRoller.d.ts +3 -2
  6. package/dist/components/DiceRoller.d.ts.map +1 -1
  7. package/dist/components/DiceRoller.js +4 -13
  8. package/dist/components/ErrorBoundary.d.ts.map +1 -1
  9. package/dist/components/ErrorBoundary.js +94 -2
  10. package/dist/components/InteractionForm.d.ts +1 -1
  11. package/dist/components/InteractionForm.d.ts.map +1 -1
  12. package/dist/components/InteractionForm.js +29 -15
  13. package/dist/components/PrimaryActionButton.d.ts.map +1 -1
  14. package/dist/components/PrimaryActionButton.js +7 -6
  15. package/dist/components/ResourceCounter.d.ts +59 -25
  16. package/dist/components/ResourceCounter.d.ts.map +1 -1
  17. package/dist/components/ResourceCounter.js +106 -115
  18. package/dist/components/Toast.d.ts +13 -6
  19. package/dist/components/Toast.d.ts.map +1 -1
  20. package/dist/components/Toast.js +10 -5
  21. package/dist/components/board/HexGrid.js +6 -6
  22. package/dist/components/board/target-layer.d.ts +18 -2
  23. package/dist/components/board/target-layer.d.ts.map +1 -1
  24. package/dist/components/board/target-layer.js +20 -3
  25. package/dist/components/index.d.ts +3 -4
  26. package/dist/components/index.d.ts.map +1 -1
  27. package/dist/components/index.js +3 -4
  28. package/dist/components/surfaces/InboxSurface.d.ts.map +1 -1
  29. package/dist/components/surfaces/InboxSurface.js +2 -6
  30. package/dist/components/surfaces/PlayerCardsSurface.js +2 -2
  31. package/dist/components/surfaces/internal/CardZoneRoutedForm.d.ts +7 -0
  32. package/dist/components/surfaces/internal/CardZoneRoutedForm.d.ts.map +1 -0
  33. package/dist/components/surfaces/internal/CardZoneRoutedForm.js +9 -0
  34. package/dist/components/surfaces/internal/DefaultInteractionButton.d.ts.map +1 -1
  35. package/dist/components/surfaces/internal/DefaultInteractionButton.js +5 -8
  36. package/dist/components/surfaces/internal/useCardZoneInteractions.d.ts +2 -2
  37. package/dist/components/surfaces/internal/useCardZoneInteractions.d.ts.map +1 -1
  38. package/dist/components/surfaces/internal/useCardZoneInteractions.js +19 -43
  39. package/dist/context/InteractionDraftContext.d.ts +11 -2
  40. package/dist/context/InteractionDraftContext.d.ts.map +1 -1
  41. package/dist/context/InteractionDraftContext.js +41 -4
  42. package/dist/defaults/components.d.ts +0 -5
  43. package/dist/defaults/components.d.ts.map +1 -1
  44. package/dist/defaults/components.js +7 -11
  45. package/dist/hooks/useBoardInteractions.d.ts +35 -12
  46. package/dist/hooks/useBoardInteractions.d.ts.map +1 -1
  47. package/dist/hooks/useBoardInteractions.js +186 -82
  48. package/dist/hooks/useInteractionHandle.d.ts +1 -1
  49. package/dist/hooks/useInteractionHandle.d.ts.map +1 -1
  50. package/dist/hooks/useInteractionHandle.js +12 -27
  51. package/dist/index.d.ts +11 -17
  52. package/dist/index.d.ts.map +1 -1
  53. package/dist/index.js +5 -14
  54. package/dist/primitives/board.d.ts +53 -3
  55. package/dist/primitives/board.d.ts.map +1 -1
  56. package/dist/primitives/board.js +65 -41
  57. package/dist/primitives/dialog-lifecycle.d.ts +17 -0
  58. package/dist/primitives/dialog-lifecycle.d.ts.map +1 -0
  59. package/dist/primitives/dialog-lifecycle.js +24 -0
  60. package/dist/primitives/dice.d.ts +31 -0
  61. package/dist/primitives/dice.d.ts.map +1 -0
  62. package/dist/primitives/dice.js +33 -0
  63. package/dist/primitives/game.d.ts +55 -0
  64. package/dist/primitives/game.d.ts.map +1 -0
  65. package/dist/primitives/game.js +101 -0
  66. package/dist/primitives/index.d.ts +7 -4
  67. package/dist/primitives/index.d.ts.map +1 -1
  68. package/dist/primitives/index.js +7 -4
  69. package/dist/primitives/interaction-form-binding.d.ts +12 -0
  70. package/dist/primitives/interaction-form-binding.d.ts.map +1 -0
  71. package/dist/primitives/interaction-form-binding.js +14 -0
  72. package/dist/primitives/interaction-submit.d.ts +23 -0
  73. package/dist/primitives/interaction-submit.d.ts.map +1 -0
  74. package/dist/primitives/interaction-submit.js +41 -0
  75. package/dist/primitives/interaction.d.ts +76 -6
  76. package/dist/primitives/interaction.d.ts.map +1 -1
  77. package/dist/primitives/interaction.js +210 -26
  78. package/dist/primitives/player-roster.d.ts +2 -1
  79. package/dist/primitives/player-roster.d.ts.map +1 -1
  80. package/dist/primitives/prompt.d.ts +36 -11
  81. package/dist/primitives/prompt.d.ts.map +1 -1
  82. package/dist/primitives/prompt.js +29 -17
  83. package/dist/primitives/ui.d.ts +9 -0
  84. package/dist/primitives/ui.d.ts.map +1 -0
  85. package/dist/primitives/ui.js +7 -0
  86. package/dist/primitives/zone.d.ts +111 -5
  87. package/dist/primitives/zone.d.ts.map +1 -1
  88. package/dist/primitives/zone.js +349 -9
  89. package/dist/reducer.d.ts +2 -14
  90. package/dist/reducer.d.ts.map +1 -1
  91. package/dist/reducer.js +1 -14
  92. package/dist/runtime/createPluginRuntimeAPI.js +1 -1
  93. package/dist/types/hex-color.d.ts +7 -0
  94. package/dist/types/hex-color.d.ts.map +1 -0
  95. package/dist/types/hex-color.js +13 -0
  96. package/dist/types/player-state.d.ts +28 -14
  97. package/dist/types/player-state.d.ts.map +1 -1
  98. package/dist/types/plugin-state.d.ts +9 -3
  99. package/dist/types/plugin-state.d.ts.map +1 -1
  100. package/dist/ui-contract.d.ts +119 -14
  101. package/dist/ui-contract.d.ts.map +1 -1
  102. package/dist/ui-contract.js +4 -3
  103. package/dist/ui-sdk.d.ts +1637 -1245
  104. package/dist/utils/interaction-inputs.d.ts +8 -5
  105. package/dist/utils/interaction-inputs.d.ts.map +1 -1
  106. package/dist/utils/interaction-inputs.js +82 -14
  107. package/dist/utils/interaction-router.d.ts +31 -0
  108. package/dist/utils/interaction-router.d.ts.map +1 -0
  109. package/dist/utils/interaction-router.js +114 -0
  110. package/package.json +2 -2
  111. package/src/components/ActionButton.tsx +2 -1
  112. package/src/components/Card.tsx +1 -1
  113. package/src/components/DiceRoller.tsx +13 -22
  114. package/src/components/ErrorBoundary.test.tsx +19 -0
  115. package/src/components/ErrorBoundary.tsx +113 -24
  116. package/src/components/InteractionForm.test.tsx +24 -0
  117. package/src/components/InteractionForm.tsx +48 -23
  118. package/src/components/PrimaryActionButton.tsx +19 -5
  119. package/src/components/ResourceCounter.test.tsx +13 -13
  120. package/src/components/ResourceCounter.tsx +238 -244
  121. package/src/components/Toast.tsx +23 -10
  122. package/src/components/__fixtures__/ResourceCounter.fixture.tsx +70 -169
  123. package/src/components/board/HexGrid.tsx +6 -6
  124. package/src/components/board/target-layer.ts +44 -5
  125. package/src/components/index.ts +17 -10
  126. package/src/components/surfaces/InboxSurface.tsx +7 -5
  127. package/src/components/surfaces/PlayerCardsSurface.tsx +6 -6
  128. package/src/components/surfaces/internal/CardZoneRoutedForm.tsx +35 -0
  129. package/src/components/surfaces/internal/DefaultInteractionButton.tsx +17 -7
  130. package/src/components/surfaces/internal/useCardZoneInteractions.ts +25 -67
  131. package/src/context/InteractionDraftContext.tsx +51 -5
  132. package/src/defaults/components.tsx +12 -50
  133. package/src/defaults/defaults.test.tsx +1 -50
  134. package/src/hooks/useBoardInteractions.test.tsx +240 -17
  135. package/src/hooks/useBoardInteractions.ts +330 -105
  136. package/src/hooks/useInteractionHandle.ts +23 -28
  137. package/src/index.test.ts +60 -40
  138. package/src/index.ts +30 -36
  139. package/src/primitives/board.test.tsx +73 -0
  140. package/src/primitives/board.tsx +191 -40
  141. package/src/primitives/dialog-lifecycle.ts +58 -0
  142. package/src/primitives/dice.test.tsx +47 -0
  143. package/src/primitives/dice.tsx +79 -0
  144. package/src/primitives/game.test.tsx +98 -0
  145. package/src/primitives/game.tsx +213 -0
  146. package/src/primitives/index.ts +84 -0
  147. package/src/primitives/interaction-form-binding.tsx +56 -0
  148. package/src/primitives/interaction-submit.ts +90 -0
  149. package/src/primitives/interaction.test.tsx +396 -0
  150. package/src/primitives/interaction.tsx +451 -31
  151. package/src/primitives/player-roster.tsx +2 -1
  152. package/src/primitives/prompt.test.tsx +94 -3
  153. package/src/primitives/prompt.tsx +87 -48
  154. package/src/primitives/ui.test.tsx +131 -0
  155. package/src/primitives/ui.tsx +13 -0
  156. package/src/primitives/zone.test.tsx +305 -0
  157. package/src/primitives/zone.tsx +660 -12
  158. package/src/reducer.ts +7 -20
  159. package/src/runtime/createPluginRuntimeAPI.ts +1 -1
  160. package/src/types/hex-color.ts +20 -0
  161. package/src/types/player-state.ts +36 -18
  162. package/src/types/plugin-state.ts +10 -3
  163. package/src/ui-contract.ts +253 -21
  164. package/src/utils/interaction-inputs.test.ts +400 -0
  165. package/src/utils/interaction-inputs.ts +113 -11
  166. package/src/utils/interaction-router.ts +200 -0
@@ -1,15 +1,53 @@
1
1
  import { type ButtonHTMLAttributes, type ReactNode } from "react";
2
- import { useBoardInteractions } from "../hooks/useBoardInteractions.js";
2
+ import { type HexBoardView } from "../components/board/hex-board-view.js";
3
+ import { type HexGridBoardProps } from "../components/board/HexGrid.js";
4
+ import { type BoardInteractionsContext, type BoardSelectionResult, type BoardTargetLayerOptions } from "../hooks/useBoardInteractions.js";
5
+ import type { AnyHexBoardInput, BoardSpaceIdOf } from "../types/tiled-board.js";
3
6
  import type { BoardTargetKey } from "../ui-contract.js";
4
7
  import { type BoardTargetKind } from "../utils/interaction-inputs.js";
5
8
  import { type PrimitiveCommonProps } from "./primitive-props.js";
6
- type BoardContextValue = ReturnType<typeof useBoardInteractions>;
9
+ type BoardContextValue = BoardInteractionsContext;
7
10
  export declare function useBoardPrimitiveContext(): BoardContextValue;
8
11
  export interface BoardRootProps extends PrimitiveCommonProps {
9
12
  children: ReactNode;
10
13
  targetKinds?: readonly BoardTargetKind[];
11
14
  }
12
15
  export declare function BoardRoot({ children, targetKinds, ...props }: BoardRootProps): import("react/jsx-runtime").JSX.Element;
16
+ export interface BoardStateProps {
17
+ children: (board: BoardInteractionsContext) => ReactNode;
18
+ }
19
+ export declare function BoardState({ children }: BoardStateProps): import("react/jsx-runtime").JSX.Element;
20
+ export interface BoardHexViewProps<TBoard extends AnyHexBoardInput, TSpaceView extends {
21
+ id: BoardSpaceIdOf<TBoard>;
22
+ }> {
23
+ board: TBoard;
24
+ spaces: readonly TSpaceView[];
25
+ children: (view: HexBoardView<TBoard, TSpaceView>) => ReactNode;
26
+ }
27
+ export declare function BoardHexView<const TBoard extends AnyHexBoardInput, const TSpaceView extends {
28
+ id: BoardSpaceIdOf<TBoard>;
29
+ }>({ board, spaces, children }: BoardHexViewProps<TBoard, TSpaceView>): import("react/jsx-runtime").JSX.Element;
30
+ export interface BoardHexGridInteractions {
31
+ edge?: BoardTargetLayerOptions;
32
+ vertex?: BoardTargetLayerOptions;
33
+ space?: BoardTargetLayerOptions;
34
+ }
35
+ export type BoardHexGridInteractionFilter = "auto" | false | {
36
+ edge?: readonly string[];
37
+ vertex?: readonly string[];
38
+ space?: readonly string[];
39
+ };
40
+ type BoardHexGridView<TBoard extends AnyHexBoardInput, TSpaceView extends {
41
+ id: BoardSpaceIdOf<TBoard>;
42
+ }> = HexBoardView<TBoard, TSpaceView> & AnyHexBoardInput;
43
+ export type BoardHexGridProps<TBoard extends AnyHexBoardInput, TSpaceView extends {
44
+ id: BoardSpaceIdOf<TBoard>;
45
+ }> = Omit<HexGridBoardProps<BoardHexGridView<TBoard, TSpaceView>>, "board" | "interactiveEdges" | "interactiveVertices" | "interactiveSpaces"> & Omit<BoardHexViewProps<TBoard, TSpaceView>, "children"> & {
46
+ interactions?: BoardHexGridInteractionFilter;
47
+ };
48
+ export declare function BoardHexGrid<const TBoard extends AnyHexBoardInput, const TSpaceView extends {
49
+ id: BoardSpaceIdOf<TBoard>;
50
+ }>({ board, spaces, interactions, ...props }: BoardHexGridProps<TBoard, TSpaceView>): import("react/jsx-runtime").JSX.Element;
13
51
  export type BoardTargetExtraInputs = Record<string, unknown> | ((targetId: string) => Record<string, unknown>);
14
52
  export type BoardTargetProps<Target extends string = BoardTargetKey> = PrimitiveCommonProps & ButtonHTMLAttributes<HTMLButtonElement> & {
15
53
  kind: BoardTargetKind;
@@ -17,13 +55,25 @@ export type BoardTargetProps<Target extends string = BoardTargetKey> = Primitive
17
55
  interaction?: string;
18
56
  input?: string;
19
57
  extraInputs?: BoardTargetExtraInputs;
20
- onSelect?: (interactionKey: string | null) => void;
58
+ onSelect?: (result: BoardSelectionResult) => void;
21
59
  onSelectError?: (error: unknown) => void;
22
60
  };
23
61
  export declare function BoardTarget<Target extends string = BoardTargetKey>({ interaction, input, ...props }: BoardTargetProps<Target>): import("react/jsx-runtime").JSX.Element;
62
+ export type BoardSpaceTargetProps<Target extends string = BoardTargetKey> = Omit<BoardTargetProps<Target>, "kind">;
63
+ export declare function BoardSpaceTarget<Target extends string = BoardTargetKey>(props: BoardSpaceTargetProps<Target>): import("react/jsx-runtime").JSX.Element;
64
+ export type BoardEdgeTargetProps<Target extends string = BoardTargetKey> = Omit<BoardTargetProps<Target>, "kind">;
65
+ export declare function BoardEdgeTarget<Target extends string = BoardTargetKey>(props: BoardEdgeTargetProps<Target>): import("react/jsx-runtime").JSX.Element;
66
+ export type BoardVertexTargetProps<Target extends string = BoardTargetKey> = Omit<BoardTargetProps<Target>, "kind">;
67
+ export declare function BoardVertexTarget<Target extends string = BoardTargetKey>(props: BoardVertexTargetProps<Target>): import("react/jsx-runtime").JSX.Element;
24
68
  export declare const Board: {
25
69
  Root: typeof BoardRoot;
70
+ State: typeof BoardState;
71
+ HexGrid: typeof BoardHexGrid;
72
+ HexView: typeof BoardHexView;
26
73
  Target: typeof BoardTarget;
74
+ SpaceTarget: typeof BoardSpaceTarget;
75
+ EdgeTarget: typeof BoardEdgeTarget;
76
+ VertexTarget: typeof BoardVertexTarget;
27
77
  };
28
78
  export {};
29
79
  //# sourceMappingURL=board.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"board.d.ts","sourceRoot":"","s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AM,GAAG,cAAc,EAAE,EAClE,WAAW,EACX,KAAK,EACL,GAAG,KAAK,EACT,EAAE,gBAAgB,CAAC,MAAM,CAAC,2CAwB1B;AAED,MAAM,MAAM,qBAAqB,CAAC,MAAM,SAAS,MAAM,GAAG,cAAc,IACtE,IAAI,CAAC,gBAAgB,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC,CAAC;AAEzC,wBAAgB,gBAAgB,CAAC,MAAM,SAAS,MAAM,GAAG,cAAc,EACrE,KAAK,EAAE,qBAAqB,CAAC,MAAM,CAAC,2CAGrC;AAED,MAAM,MAAM,oBAAoB,CAAC,MAAM,SAAS,MAAM,GAAG,cAAc,IAAI,IAAI,CAC7E,gBAAgB,CAAC,MAAM,CAAC,EACxB,MAAM,CACP,CAAC;AAEF,wBAAgB,eAAe,CAAC,MAAM,SAAS,MAAM,GAAG,cAAc,EACpE,KAAK,EAAE,oBAAoB,CAAC,MAAM,CAAC,2CAGpC;AAED,MAAM,MAAM,sBAAsB,CAAC,MAAM,SAAS,MAAM,GAAG,cAAc,IACvE,IAAI,CAAC,gBAAgB,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC,CAAC;AAEzC,wBAAgB,iBAAiB,CAAC,MAAM,SAAS,MAAM,GAAG,cAAc,EACtE,KAAK,EAAE,sBAAsB,CAAC,MAAM,CAAC,2CAGtC;AA2JD,eAAO,MAAM,KAAK;;;;;;;;;CASjB,CAAC"}
@@ -1,10 +1,13 @@
1
- import { jsx as _jsx } from "react/jsx-runtime";
2
- import { createContext, useContext, } from "react";
3
- import { useBoardInteractions } from "../hooks/useBoardInteractions.js";
4
- import { useInteractionHandle } from "../hooks/useInteractionHandle.js";
1
+ import { jsx as _jsx, Fragment as _Fragment } from "react/jsx-runtime";
2
+ import { createContext, useContext, useMemo, } from "react";
3
+ import { createHexBoardView, } from "../components/board/hex-board-view.js";
4
+ import { HexGrid, } from "../components/board/HexGrid.js";
5
+ import { useBoardInteractions, } from "../hooks/useBoardInteractions.js";
5
6
  import { usePluginState } from "../context/PluginStateContext.js";
6
- import { inputByKey, inputKeyForTarget, interactionInputKeys, } from "../utils/interaction-inputs.js";
7
+ import { inputByKey, inputKeyForTarget, } from "../utils/interaction-inputs.js";
7
8
  import { composeEventHandlers, renderPrimitive, } from "./primitive-props.js";
9
+ import { runInteractionAction } from "./interaction-submit.js";
10
+ import { useGameActionError } from "./game.js";
8
11
  const BoardContext = createContext(null);
9
12
  export function useBoardPrimitiveContext() {
10
13
  const value = useContext(BoardContext);
@@ -21,6 +24,39 @@ export function BoardRoot({ children, targetKinds, ...props }) {
21
24
  children,
22
25
  }) }));
23
26
  }
27
+ export function BoardState({ children }) {
28
+ return _jsx(_Fragment, { children: children(useBoardPrimitiveContext()) });
29
+ }
30
+ export function BoardHexView({ board, spaces, children }) {
31
+ const view = useMemo(() => createHexBoardView(board, { spaces }), [board, spaces]);
32
+ return _jsx(_Fragment, { children: children(view) });
33
+ }
34
+ export function BoardHexGrid({ board, spaces, interactions = "auto", ...props }) {
35
+ const boardInteractions = useBoardPrimitiveContext();
36
+ const gameActionError = useGameActionError();
37
+ const edgeLayer = interactions === false
38
+ ? undefined
39
+ : boardInteractions.targetLayers.edge({
40
+ enabled: boardInteractions.eligible.edge.size > 0,
41
+ interactionKeys: interactions === "auto" ? undefined : interactions.edge,
42
+ onError: gameActionError ?? undefined,
43
+ });
44
+ const vertexLayer = interactions === false
45
+ ? undefined
46
+ : boardInteractions.targetLayers.vertex({
47
+ enabled: boardInteractions.eligible.vertex.size > 0,
48
+ interactionKeys: interactions === "auto" ? undefined : interactions.vertex,
49
+ onError: gameActionError ?? undefined,
50
+ });
51
+ const spaceLayer = interactions === false
52
+ ? undefined
53
+ : boardInteractions.targetLayers.space({
54
+ enabled: boardInteractions.eligible.space.size > 0,
55
+ interactionKeys: interactions === "auto" ? undefined : interactions.space,
56
+ onError: gameActionError ?? undefined,
57
+ });
58
+ return (_jsx(BoardHexView, { board: board, spaces: spaces, children: (view) => (_jsx(HexGrid, { ...props, board: view, interactiveEdges: edgeLayer, interactiveVertices: vertexLayer, interactiveSpaces: spaceLayer })) }));
59
+ }
24
60
  export function BoardTarget({ interaction, input, ...props }) {
25
61
  const descriptor = usePluginState((state) => interaction
26
62
  ? state.gameplay.availableInteractions.find((candidate) => candidate.interactionKey === interaction ||
@@ -31,8 +67,18 @@ export function BoardTarget({ interaction, input, ...props }) {
31
67
  }
32
68
  return _jsx(UnambiguousBoardTarget, { input: input, ...props });
33
69
  }
70
+ export function BoardSpaceTarget(props) {
71
+ return _jsx(BoardTarget, { kind: "space", ...props });
72
+ }
73
+ export function BoardEdgeTarget(props) {
74
+ return _jsx(BoardTarget, { kind: "edge", ...props });
75
+ }
76
+ export function BoardVertexTarget(props) {
77
+ return _jsx(BoardTarget, { kind: "vertex", ...props });
78
+ }
34
79
  function UnambiguousBoardTarget({ kind, value, extraInputs, onSelect, onSelectError, disabled, onClick, children, ...props }) {
35
80
  const board = useBoardPrimitiveContext();
81
+ const gameActionError = useGameActionError();
36
82
  const eligible = board.isEligible(value, kind);
37
83
  const ambiguous = isAmbiguousBoardTarget(board.interactions, kind, value);
38
84
  const isDisabled = disabled ?? (!eligible || ambiguous);
@@ -51,20 +97,16 @@ function UnambiguousBoardTarget({ kind, value, extraInputs, onSelect, onSelectEr
51
97
  onClick: composeEventHandlers(onClick, () => {
52
98
  if (isDisabled)
53
99
  return;
54
- void board.select[kind](value, resolveExtraInputs(extraInputs, value))
55
- .then((interactionKey) => {
56
- onSelect?.(interactionKey);
57
- })
58
- .catch((error) => {
59
- onSelectError?.(error);
60
- if (!onSelectError)
61
- throw error;
100
+ void runInteractionAction(() => board.select[kind](value, resolveExtraInputs(extraInputs, value)), {
101
+ onSuccess: onSelect,
102
+ onError: onSelectError ?? gameActionError ?? undefined,
62
103
  });
63
104
  }),
64
105
  });
65
106
  }
66
107
  function ExplicitBoardTarget({ descriptor, kind, value, input, extraInputs, onSelect, onSelectError, disabled, onClick, children, ...props }) {
67
- const handle = useInteractionHandle(descriptor);
108
+ const board = useBoardPrimitiveContext();
109
+ const gameActionError = useGameActionError();
68
110
  const inputKey = input ?? inputKeyForTarget(descriptor, kind, value);
69
111
  const inputDescriptor = inputKey
70
112
  ? inputByKey(descriptor, inputKey)
@@ -93,33 +135,9 @@ function ExplicitBoardTarget({ descriptor, kind, value, input, extraInputs, onSe
93
135
  if (isDisabled || !inputKey)
94
136
  return;
95
137
  const resolvedExtraInputs = resolveExtraInputs(extraInputs, value);
96
- for (const [key, extraValue] of Object.entries(resolvedExtraInputs)) {
97
- handle.setInput(key, extraValue);
98
- }
99
- handle.setInput(inputKey, value);
100
- if (descriptor.commit.mode !== "autoWhenReady") {
101
- handle.arm();
102
- onSelect?.(descriptor.interactionKey);
103
- return;
104
- }
105
- const params = {
106
- ...handle.draft,
107
- ...resolvedExtraInputs,
108
- [inputKey]: value,
109
- };
110
- for (const required of interactionInputKeys(descriptor)) {
111
- if (!(required in params))
112
- params[required] = null;
113
- }
114
- void handle
115
- .submit(params)
116
- .then(() => {
117
- onSelect?.(descriptor.interactionKey);
118
- })
119
- .catch((error) => {
120
- onSelectError?.(error);
121
- if (!onSelectError)
122
- throw error;
138
+ void runInteractionAction(() => board.selectTarget(descriptor, kind, value, inputKey, resolvedExtraInputs), {
139
+ onSuccess: onSelect,
140
+ onError: onSelectError ?? gameActionError ?? undefined,
123
141
  });
124
142
  }),
125
143
  });
@@ -159,5 +177,11 @@ function isAmbiguousBoardTarget(descriptors, kind, value) {
159
177
  }
160
178
  export const Board = {
161
179
  Root: BoardRoot,
180
+ State: BoardState,
181
+ HexGrid: BoardHexGrid,
182
+ HexView: BoardHexView,
162
183
  Target: BoardTarget,
184
+ SpaceTarget: BoardSpaceTarget,
185
+ EdgeTarget: BoardEdgeTarget,
186
+ VertexTarget: BoardVertexTarget,
163
187
  };
@@ -0,0 +1,17 @@
1
+ export type DialogLifecycleState = "open" | "minimized" | "dismissed";
2
+ export interface DialogLifecycleValue {
3
+ state: DialogLifecycleState;
4
+ open: boolean;
5
+ minimized: boolean;
6
+ dismissed: boolean;
7
+ setOpen: (open: boolean) => void;
8
+ restore: () => void;
9
+ minimize: () => void;
10
+ dismiss: () => void;
11
+ }
12
+ export interface DialogLifecycleOptions {
13
+ defaultOpen?: boolean;
14
+ onStateChange?: (state: DialogLifecycleState) => void;
15
+ }
16
+ export declare function useDialogLifecycle({ defaultOpen, onStateChange, }: DialogLifecycleOptions): DialogLifecycleValue;
17
+ //# sourceMappingURL=dialog-lifecycle.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dialog-lifecycle.d.ts","sourceRoot":"","sources":["../../src/primitives/dialog-lifecycle.ts"],"names":[],"mappings":"AAEA,MAAM,MAAM,oBAAoB,GAAG,MAAM,GAAG,WAAW,GAAG,WAAW,CAAC;AAEtE,MAAM,WAAW,oBAAoB;IACnC,KAAK,EAAE,oBAAoB,CAAC;IAC5B,IAAI,EAAE,OAAO,CAAC;IACd,SAAS,EAAE,OAAO,CAAC;IACnB,SAAS,EAAE,OAAO,CAAC;IACnB,OAAO,EAAE,CAAC,IAAI,EAAE,OAAO,KAAK,IAAI,CAAC;IACjC,OAAO,EAAE,MAAM,IAAI,CAAC;IACpB,QAAQ,EAAE,MAAM,IAAI,CAAC;IACrB,OAAO,EAAE,MAAM,IAAI,CAAC;CACrB;AAED,MAAM,WAAW,sBAAsB;IACrC,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,aAAa,CAAC,EAAE,CAAC,KAAK,EAAE,oBAAoB,KAAK,IAAI,CAAC;CACvD;AAED,wBAAgB,kBAAkB,CAAC,EACjC,WAAkB,EAClB,aAAa,GACd,EAAE,sBAAsB,GAAG,oBAAoB,CAkC/C"}
@@ -0,0 +1,24 @@
1
+ import { useCallback, useMemo, useState } from "react";
2
+ export function useDialogLifecycle({ defaultOpen = true, onStateChange, }) {
3
+ const [state, setState] = useState(defaultOpen ? "open" : "minimized");
4
+ const updateState = useCallback((nextState) => {
5
+ setState(nextState);
6
+ onStateChange?.(nextState);
7
+ }, [onStateChange]);
8
+ const restore = useCallback(() => updateState("open"), [updateState]);
9
+ const minimize = useCallback(() => updateState("minimized"), [updateState]);
10
+ const dismiss = useCallback(() => updateState("dismissed"), [updateState]);
11
+ const setOpen = useCallback((open) => {
12
+ updateState(open ? "open" : "minimized");
13
+ }, [updateState]);
14
+ return useMemo(() => ({
15
+ state,
16
+ open: state === "open",
17
+ minimized: state === "minimized",
18
+ dismissed: state === "dismissed",
19
+ setOpen,
20
+ restore,
21
+ minimize,
22
+ dismiss,
23
+ }), [dismiss, minimize, restore, setOpen, state]);
24
+ }
@@ -0,0 +1,31 @@
1
+ import { type ReactNode } from "react";
2
+ export type DiceValue = number | null | undefined;
3
+ export interface DiceState {
4
+ values: ReadonlyArray<number | undefined> | undefined;
5
+ /** Undefined if any die has not been rolled yet. */
6
+ sum: number | undefined;
7
+ diceCount: number;
8
+ allRolled: boolean;
9
+ }
10
+ export interface DiceRootProps {
11
+ values?: readonly DiceValue[] | null;
12
+ /** Used when values are not provided. */
13
+ count?: number;
14
+ children: ReactNode;
15
+ }
16
+ export interface DiceValuesProps {
17
+ children: (state: DiceState) => ReactNode;
18
+ }
19
+ export interface DiceComponents {
20
+ Root(props: DiceRootProps): ReactNode;
21
+ Values(props: DiceValuesProps): ReactNode;
22
+ }
23
+ export declare function normalizeDiceState({ values, count, }: {
24
+ values?: readonly DiceValue[] | null;
25
+ count?: number;
26
+ }): DiceState;
27
+ export declare function DiceRoot({ values, count, children }: DiceRootProps): import("react/jsx-runtime").JSX.Element;
28
+ export declare function useDicePrimitiveContext(): DiceState;
29
+ export declare function DiceValues({ children }: DiceValuesProps): ReactNode;
30
+ export declare const Dice: DiceComponents;
31
+ //# sourceMappingURL=dice.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dice.d.ts","sourceRoot":"","sources":["../../src/primitives/dice.tsx"],"names":[],"mappings":"AAAA,OAAO,EAA6B,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AAElE,MAAM,MAAM,SAAS,GAAG,MAAM,GAAG,IAAI,GAAG,SAAS,CAAC;AAElD,MAAM,WAAW,SAAS;IACxB,MAAM,EAAE,aAAa,CAAC,MAAM,GAAG,SAAS,CAAC,GAAG,SAAS,CAAC;IACtD,oDAAoD;IACpD,GAAG,EAAE,MAAM,GAAG,SAAS,CAAC;IACxB,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,OAAO,CAAC;CACpB;AAED,MAAM,WAAW,aAAa;IAC5B,MAAM,CAAC,EAAE,SAAS,SAAS,EAAE,GAAG,IAAI,CAAC;IACrC,yCAAyC;IACzC,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,SAAS,CAAC;CACrB;AAED,MAAM,WAAW,eAAe;IAC9B,QAAQ,EAAE,CAAC,KAAK,EAAE,SAAS,KAAK,SAAS,CAAC;CAC3C;AAED,MAAM,WAAW,cAAc;IAC7B,IAAI,CAAC,KAAK,EAAE,aAAa,GAAG,SAAS,CAAC;IACtC,MAAM,CAAC,KAAK,EAAE,eAAe,GAAG,SAAS,CAAC;CAC3C;AAID,wBAAgB,kBAAkB,CAAC,EACjC,MAAM,EACN,KAAS,GACV,EAAE;IACD,MAAM,CAAC,EAAE,SAAS,SAAS,EAAE,GAAG,IAAI,CAAC;IACrC,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB,GAAG,SAAS,CAiBZ;AAED,wBAAgB,QAAQ,CAAC,EAAE,MAAM,EAAE,KAAK,EAAE,QAAQ,EAAE,EAAE,aAAa,2CAMlE;AAED,wBAAgB,uBAAuB,IAAI,SAAS,CAMnD;AAED,wBAAgB,UAAU,CAAC,EAAE,QAAQ,EAAE,EAAE,eAAe,aAEvD;AAED,eAAO,MAAM,IAAI,EAAE,cAGlB,CAAC"}
@@ -0,0 +1,33 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { createContext, useContext } from "react";
3
+ const DiceContext = createContext(null);
4
+ export function normalizeDiceState({ values, count = 2, }) {
5
+ const normalizedValues = values?.map((value) => value ?? undefined);
6
+ const allRolled = normalizedValues?.every((value) => value !== undefined) ?? false;
7
+ const sum = allRolled
8
+ ? normalizedValues?.reduce((total, value) => total + (value ?? 0), 0)
9
+ : undefined;
10
+ return {
11
+ values: normalizedValues,
12
+ sum,
13
+ diceCount: normalizedValues?.length ?? count,
14
+ allRolled,
15
+ };
16
+ }
17
+ export function DiceRoot({ values, count, children }) {
18
+ return (_jsx(DiceContext.Provider, { value: normalizeDiceState({ values, count }), children: children }));
19
+ }
20
+ export function useDicePrimitiveContext() {
21
+ const value = useContext(DiceContext);
22
+ if (!value) {
23
+ throw new Error("Dice primitives must be rendered inside <Dice.Root>.");
24
+ }
25
+ return value;
26
+ }
27
+ export function DiceValues({ children }) {
28
+ return children(useDicePrimitiveContext());
29
+ }
30
+ export const Dice = {
31
+ Root: DiceRoot,
32
+ Values: DiceValues,
33
+ };
@@ -0,0 +1,55 @@
1
+ import { type ReactNode } from "react";
2
+ import type { PlayerId } from "@dreamboard/manifest-contract";
3
+ import { usePluginSession } from "../context/PluginSessionContext.js";
4
+ import type { Player } from "../types/player-state.js";
5
+ export type GamePlayer<PlayerIdValue extends string = PlayerId> = Omit<Player, "playerId"> & {
6
+ playerId: PlayerIdValue;
7
+ };
8
+ export type GamePlayerEntry<PlayerIdValue extends string = PlayerId> = GamePlayer<PlayerIdValue> & {
9
+ index: number;
10
+ isActive: boolean;
11
+ isCurrentPlayer: boolean;
12
+ isControllable: boolean;
13
+ };
14
+ export interface GamePlayersState<PlayerIdValue extends string = PlayerId> {
15
+ byId: ReadonlyMap<PlayerIdValue, GamePlayer<PlayerIdValue>>;
16
+ order: readonly PlayerIdValue[];
17
+ entries: ReadonlyArray<GamePlayerEntry<PlayerIdValue>>;
18
+ active: readonly PlayerIdValue[];
19
+ current: GamePlayer<PlayerIdValue> | null;
20
+ }
21
+ export interface GameMeState<PlayerIdValue extends string = PlayerId> {
22
+ playerId: PlayerIdValue | null;
23
+ player: GamePlayer<PlayerIdValue> | null;
24
+ controllablePlayerIds: readonly PlayerIdValue[];
25
+ canAct: boolean;
26
+ }
27
+ export interface GameTurnState<PlayerIdValue extends string = PlayerId, PhaseValue extends string = string> {
28
+ phase: PhaseValue | null;
29
+ stage: string | null;
30
+ activePlayerIds: readonly PlayerIdValue[];
31
+ currentPlayerId: PlayerIdValue | null;
32
+ order: readonly PlayerIdValue[];
33
+ isMine: boolean;
34
+ }
35
+ export interface GameRenderState<ViewValue = unknown, PlayerIdValue extends string = PlayerId, PhaseValue extends string = string> {
36
+ view: ViewValue;
37
+ phase: PhaseValue | null;
38
+ stage: string | null;
39
+ session: ReturnType<typeof usePluginSession>;
40
+ me: GameMeState<PlayerIdValue>;
41
+ turn: GameTurnState<PlayerIdValue, PhaseValue>;
42
+ players: GamePlayersState<PlayerIdValue>;
43
+ }
44
+ export interface GameRootProps<ViewValue = unknown, PlayerIdValue extends string = PlayerId, PhaseValue extends string = string> {
45
+ onActionError?: (error: unknown) => void;
46
+ children: (state: GameRenderState<ViewValue, PlayerIdValue, PhaseValue>) => ReactNode;
47
+ }
48
+ type GameActionErrorHandler = (error: unknown) => void;
49
+ export declare function useGameActionError(): GameActionErrorHandler | null;
50
+ export declare function GameRoot<ViewValue = unknown, PlayerIdValue extends string = PlayerId, PhaseValue extends string = string>({ children, onActionError, }: GameRootProps<ViewValue, PlayerIdValue, PhaseValue>): import("react/jsx-runtime").JSX.Element;
51
+ export declare const Game: {
52
+ Root: typeof GameRoot;
53
+ };
54
+ export {};
55
+ //# sourceMappingURL=game.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"game.d.ts","sourceRoot":"","sources":["../../src/primitives/game.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAsC,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AAC3E,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,+BAA+B,CAAC;AAE9D,OAAO,EAAE,gBAAgB,EAAE,MAAM,oCAAoC,CAAC;AAK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,UAAU,CAAC,2CAyGrD;AAED,eAAO,MAAM,IAAI;;CAEhB,CAAC"}
@@ -0,0 +1,101 @@
1
+ import { Fragment as _Fragment, jsx as _jsx } from "react/jsx-runtime";
2
+ import { createContext, useContext, useMemo } from "react";
3
+ import { usePluginState } from "../context/PluginStateContext.js";
4
+ import { usePluginSession } from "../context/PluginSessionContext.js";
5
+ import { useActivePlayers } from "../hooks/useActivePlayers.js";
6
+ import { useGameView } from "../hooks/useGameView.js";
7
+ import { usePlayerInfo } from "../hooks/usePlayerInfo.js";
8
+ import { usePlayerTurnOrder } from "../hooks/usePlayerTurnOrder.js";
9
+ const GameActionErrorContext = createContext(null);
10
+ export function useGameActionError() {
11
+ return useContext(GameActionErrorContext);
12
+ }
13
+ function fallbackPlayer(playerId) {
14
+ return {
15
+ playerId,
16
+ name: playerId,
17
+ };
18
+ }
19
+ export function GameRoot({ children, onActionError, }) {
20
+ const view = useGameView();
21
+ const session = usePluginSession();
22
+ const playerInfo = usePlayerInfo();
23
+ const activePlayers = useActivePlayers().map((playerId) => playerId);
24
+ const turnOrder = usePlayerTurnOrder().map((playerId) => playerId);
25
+ const phase = usePluginState((state) => state.gameplay.currentPhase);
26
+ const stage = usePluginState((state) => state.gameplay.currentStage);
27
+ const playersById = useMemo(() => {
28
+ const next = new Map();
29
+ playerInfo.forEach((player, key) => {
30
+ const playerId = key;
31
+ next.set(playerId, {
32
+ ...player,
33
+ playerId,
34
+ });
35
+ });
36
+ return next;
37
+ }, [playerInfo]);
38
+ const controllingPlayerId = session.controllingPlayerId == null
39
+ ? null
40
+ : session.controllingPlayerId;
41
+ const controllablePlayerIds = session.controllablePlayerIds.map((playerId) => playerId);
42
+ const currentPlayerId = activePlayers[0] ?? turnOrder[0] ?? null;
43
+ const currentPlayer = currentPlayerId
44
+ ? (playersById.get(currentPlayerId) ?? fallbackPlayer(currentPlayerId))
45
+ : null;
46
+ const mePlayer = controllingPlayerId
47
+ ? (playersById.get(controllingPlayerId) ??
48
+ fallbackPlayer(controllingPlayerId))
49
+ : null;
50
+ const entries = useMemo(() => turnOrder.map((playerId, index) => {
51
+ const player = playersById.get(playerId) ?? fallbackPlayer(playerId);
52
+ return {
53
+ ...player,
54
+ index,
55
+ isActive: activePlayers.includes(playerId),
56
+ isCurrentPlayer: playerId === controllingPlayerId,
57
+ isControllable: controllablePlayerIds.includes(playerId),
58
+ };
59
+ }), [
60
+ activePlayers,
61
+ controllablePlayerIds,
62
+ controllingPlayerId,
63
+ playersById,
64
+ turnOrder,
65
+ ]);
66
+ const rendered = (_jsx(_Fragment, { children: children({
67
+ view,
68
+ phase,
69
+ stage,
70
+ session,
71
+ me: {
72
+ playerId: controllingPlayerId,
73
+ player: mePlayer,
74
+ controllablePlayerIds,
75
+ canAct: controllingPlayerId != null &&
76
+ activePlayers.includes(controllingPlayerId),
77
+ },
78
+ turn: {
79
+ phase,
80
+ stage,
81
+ activePlayerIds: activePlayers,
82
+ currentPlayerId,
83
+ order: turnOrder,
84
+ isMine: controllingPlayerId != null &&
85
+ activePlayers.includes(controllingPlayerId),
86
+ },
87
+ players: {
88
+ byId: playersById,
89
+ order: turnOrder,
90
+ entries,
91
+ active: activePlayers,
92
+ current: currentPlayer,
93
+ },
94
+ }) }));
95
+ if (!onActionError)
96
+ return rendered;
97
+ return (_jsx(GameActionErrorContext.Provider, { value: onActionError, children: rendered }));
98
+ }
99
+ export const Game = {
100
+ Root: GameRoot,
101
+ };
@@ -1,8 +1,11 @@
1
- export { Board, BoardRoot, BoardTarget, useBoardPrimitiveContext, type BoardRootProps, type BoardTargetExtraInputs, type BoardTargetProps, } from "./board.js";
2
- export { Interaction, InteractionCardInput, InteractionDescription, InteractionInput, InteractionLabel, InteractionRoot, InteractionSubmit, InteractionTrigger, InteractionUnavailableMessage, InteractionValidationMessage, useInteractionPrimitiveContext, type InteractionCardInputProps, type InteractionInputProps, type InteractionPartProps, type InteractionRootProps, type InteractionSubmitProps, type InteractionTriggerProps, } from "./interaction.js";
1
+ export { UI, UIRoot, type UIRootProps } from "./ui.js";
2
+ export { Board, BoardEdgeTarget, BoardHexGrid, BoardHexView, BoardRoot, BoardSpaceTarget, BoardState, BoardTarget, BoardVertexTarget, useBoardPrimitiveContext, type BoardEdgeTargetProps, type BoardHexGridInteractionFilter, type BoardHexGridInteractions, type BoardHexGridProps, type BoardHexViewProps, type BoardRootProps, type BoardSpaceTargetProps, type BoardStateProps, type BoardTargetExtraInputs, type BoardTargetProps, type BoardVertexTargetProps, } from "./board.js";
3
+ export { Game, GameRoot, useGameActionError, type GameMeState, type GamePlayer, type GamePlayerEntry, type GamePlayersState, type GameRenderState, type GameRootProps, type GameTurnState, } from "./game.js";
4
+ export { Interaction, InteractionCardInput, InteractionDescription, InteractionDialog, InteractionFormPrimitive, InteractionInput, InteractionLabel, InteractionRoot, InteractionState, InteractionSubmit, InteractionSwitch, InteractionTrigger, InteractionUnavailableMessage, InteractionValidationMessage, useInteractionPrimitiveContext, type InteractionCardInputProps, type InteractionDialogProps, type InteractionDialogRenderState, type InteractionDialogState, type InteractionFieldPrimitiveProps, type InteractionFormPrimitiveProps, type InteractionInputProps, type InteractionPartProps, type InteractionRouteMap, type InteractionRootProps, type InteractionStateProps, type InteractionStateSnapshot, type InteractionSubmitProps, type InteractionSwitchProps, type InteractionSwitchRenderState, type InteractionTriggerProps, } from "./interaction.js";
3
5
  export { Phase, PhaseSwitch, type PhaseFallback, type PhaseRouteMap, type PhaseSwitchProps, } from "./phase.js";
4
6
  export { PlayerRoster, PlayerRosterBadges, PlayerRosterEmpty, PlayerRosterList, PlayerRosterName, PlayerRosterRoot, PlayerRosterScore, PlayerRosterSwitchButton, type PlayerRosterBadge, type PlayerRosterComponents, type PlayerRosterEntry, type PlayerRosterListProps, type PlayerRosterPartProps, type PlayerRosterRootProps, type PlayerRosterSwitchButtonProps, } from "./player-roster.js";
5
- export { Prompt, PromptInbox, PromptInboxEmpty, PromptInboxItems, PromptInboxRoot, PromptMessage, PromptOption, PromptOptions, PromptRoot, PromptTitle, type PromptOptionProps, type PromptRootProps, } from "./prompt.js";
7
+ export { Prompt, PromptInbox, PromptInboxEmpty, PromptInboxItems, PromptInboxRoot, PromptDialog, PromptMessage, PromptOption, PromptOptions, PromptRoot, PromptTitle, type PromptDialogProps, type PromptDialogRenderState, type PromptDialogState, type PromptInboxItemsProps, type PromptOptionRenderItem, type PromptOptionProps, type PromptOptionsProps, type PromptRootProps, } from "./prompt.js";
6
8
  export { composeEventHandlers, renderPrimitive, type PrimitiveCommonProps, type PrimitiveDataAttributes, } from "./primitive-props.js";
7
- export { Zone, ZoneItem, ZoneList, ZoneRoot, useZoneCardContext, useZonePrimitiveContext, type ZoneItemProps, type ZoneListProps, type ZoneRootProps, } from "./zone.js";
9
+ export { Dice, DiceRoot, DiceValues, normalizeDiceState, useDicePrimitiveContext, type DiceComponents, type DiceRootProps, type DiceState, type DiceValue, type DiceValuesProps, } from "./dice.js";
10
+ export { Zone, ZoneCardAt, ZoneCardAction, ZoneItem, ZoneList, ZonePileCards, ZonePileCount, ZonePileDescription, ZonePileLabel, ZonePileRoot, ZonePileTrigger, ZoneRoot, ZoneTopCard, useOptionalZonePrimitiveContext, useZoneCardContext, useZonePileContext, useZonePrimitiveContext, type ZoneCardAtProps, type ZoneCardActionExtraInputs, type ZoneCardActionProps, type ZoneCardActionResult, type ZoneCardRenderItem, type ZonePileCardsProps, type ZonePileContextValue, type ZonePileCountProps, type ZonePileDescriptionProps, type ZonePileLabelProps, type ZonePileRootProps, type ZonePileTriggerProps, type ZoneItemProps, type ZoneListProps, type ZoneRootProps, type ZoneTopCardProps, } from "./zone.js";
8
11
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/primitives/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,EACL,SAAS,EACT,WAAW,EACX,wBAAwB,EACxB,KAAK,cAAc,EACnB,KAAK,sBAAsB,EAC3B,KAAK,gBAAgB,GACtB,MA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EACZ,eAAe,EACf,QAAQ,EACR,WAAW,EACX,+BAA+B,EAC/B,kBAAkB,EAClB,kBAAkB,EAClB,uBAAuB,EACvB,KAAK,eAAe,EACpB,KAAK,yBAAyB,EAC9B,KAAK,mBAAmB,EACxB,KAAK,oBAAoB,EACzB,KAAK,kBAAkB,EACvB,KAAK,kBAAkB,EACvB,KAAK,oBAAoB,EACzB,KAAK,kBAAkB,EACvB,KAAK,wBAAwB,EAC7B,KAAK,kBAAkB,EACvB,KAAK,iBAAiB,EACtB,KAAK,oBAAoB,EACzB,KAAK,aAAa,EAClB,KAAK,aAAa,EAClB,KAAK,aAAa,EAClB,KAAK,gBAAgB,GACtB,MAAM,WAAW,CAAC"}
@@ -1,7 +1,10 @@
1
- export { Board, BoardRoot, BoardTarget, useBoardPrimitiveContext, } from "./board.js";
2
- export { Interaction, InteractionCardInput, InteractionDescription, InteractionInput, InteractionLabel, InteractionRoot, InteractionSubmit, InteractionTrigger, InteractionUnavailableMessage, InteractionValidationMessage, useInteractionPrimitiveContext, } from "./interaction.js";
1
+ export { UI, UIRoot } from "./ui.js";
2
+ export { Board, BoardEdgeTarget, BoardHexGrid, BoardHexView, BoardRoot, BoardSpaceTarget, BoardState, BoardTarget, BoardVertexTarget, useBoardPrimitiveContext, } from "./board.js";
3
+ export { Game, GameRoot, useGameActionError, } from "./game.js";
4
+ export { Interaction, InteractionCardInput, InteractionDescription, InteractionDialog, InteractionFormPrimitive, InteractionInput, InteractionLabel, InteractionRoot, InteractionState, InteractionSubmit, InteractionSwitch, InteractionTrigger, InteractionUnavailableMessage, InteractionValidationMessage, useInteractionPrimitiveContext, } from "./interaction.js";
3
5
  export { Phase, PhaseSwitch, } from "./phase.js";
4
6
  export { PlayerRoster, PlayerRosterBadges, PlayerRosterEmpty, PlayerRosterList, PlayerRosterName, PlayerRosterRoot, PlayerRosterScore, PlayerRosterSwitchButton, } from "./player-roster.js";
5
- export { Prompt, PromptInbox, PromptInboxEmpty, PromptInboxItems, PromptInboxRoot, PromptMessage, PromptOption, PromptOptions, PromptRoot, PromptTitle, } from "./prompt.js";
7
+ export { Prompt, PromptInbox, PromptInboxEmpty, PromptInboxItems, PromptInboxRoot, PromptDialog, PromptMessage, PromptOption, PromptOptions, PromptRoot, PromptTitle, } from "./prompt.js";
6
8
  export { composeEventHandlers, renderPrimitive, } from "./primitive-props.js";
7
- export { Zone, ZoneItem, ZoneList, ZoneRoot, useZoneCardContext, useZonePrimitiveContext, } from "./zone.js";
9
+ export { Dice, DiceRoot, DiceValues, normalizeDiceState, useDicePrimitiveContext, } from "./dice.js";
10
+ export { Zone, ZoneCardAt, ZoneCardAction, ZoneItem, ZoneList, ZonePileCards, ZonePileCount, ZonePileDescription, ZonePileLabel, ZonePileRoot, ZonePileTrigger, ZoneRoot, ZoneTopCard, useOptionalZonePrimitiveContext, useZoneCardContext, useZonePileContext, useZonePrimitiveContext, } from "./zone.js";
@@ -0,0 +1,12 @@
1
+ import { type InteractionFormProps } from "../components/InteractionForm.js";
2
+ import type { InteractionHandle, InteractionParamsShape } from "../hooks/useInteractionHandle.js";
3
+ import type { InteractionDescriptor } from "../types/plugin-state.js";
4
+ export type BoundInteractionFormProps<Params extends InteractionParamsShape = InteractionParamsShape, DefaultedKeys extends keyof Params & string = never> = Omit<InteractionFormProps<Params, DefaultedKeys>, "descriptor" | "handle">;
5
+ export declare function castInteractionHandle<Params extends InteractionParamsShape = InteractionParamsShape, DefaultedKeys extends keyof Params & string = never>(handle: InteractionHandle): InteractionHandle<Params, DefaultedKeys>;
6
+ export declare function castInteractionDraft<Params extends InteractionParamsShape = InteractionParamsShape, DefaultedKeys extends keyof Params & string = never>(draft: Record<string, unknown>): InteractionHandle<Params, DefaultedKeys>["draft"];
7
+ export declare function castInteractionFields<Params extends InteractionParamsShape = InteractionParamsShape>(fields: readonly string[]): ReadonlyArray<keyof Params & string>;
8
+ export declare function BoundInteractionForm<Params extends InteractionParamsShape = InteractionParamsShape, DefaultedKeys extends keyof Params & string = never>({ descriptor, handle, ...props }: BoundInteractionFormProps<Params, DefaultedKeys> & {
9
+ descriptor: InteractionDescriptor;
10
+ handle: InteractionHandle;
11
+ }): import("react/jsx-runtime").JSX.Element;
12
+ //# sourceMappingURL=interaction-form-binding.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"interaction-form-binding.d.ts","sourceRoot":"","sources":["../../src/primitives/interaction-form-binding.tsx"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,oBAAoB,EAC1B,MAAM,kCAAkC,CAAC;AAC1C,OAAO,KAAK,EACV,iBAAiB,EACjB,sBAAsB,EACvB,MAAM,kCAAkC,CAAC;AAC1C,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,0BAA0B,CAAC;AAEtE,MAAM,MAAM,yBAAyB,CACnC,MAAM,SAAS,sBAAsB,GAAG,sBAAsB,EAC9D,aAAa,SAAS,MAAM,MAAM,GAAG,MAAM,GAAG,KAAK,IACjD,IAAI,CAAC,oBAAoB,CAAC,MAAM,EAAE,aAAa,CAAC,EAAE,YAAY,GAAG,QAAQ,CAAC,CAAC;AAE/E,wBAAgB,qBAAqB,CACnC,MAAM,SAAS,sBAAsB,GAAG,sBAAsB,EAC9D,aAAa,SAAS,MAAM,MAAM,GAAG,MAAM,GAAG,KAAK,EACnD,MAAM,EAAE,iBAAiB,GAAG,iBAAiB,CAAC,MAAM,EAAE,aAAa,CAAC,CAErE;AAED,wBAAgB,oBAAoB,CAClC,MAAM,SAAS,sBAAsB,GAAG,sBAAsB,EAC9D,aAAa,SAAS,MAAM,MAAM,GAAG,MAAM,GAAG,KAAK,EAEnD,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAC7B,iBAAiB,CAAC,MAAM,EAAE,aAAa,CAAC,CAAC,OAAO,CAAC,CAEnD;AAED,wBAAgB,qBAAqB,CACnC,MAAM,SAAS,sBAAsB,GAAG,sBAAsB,EAC9D,MAAM,EAAE,SAAS,MAAM,EAAE,GAAG,aAAa,CAAC,MAAM,MAAM,GAAG,MAAM,CAAC,CAEjE;AAED,wBAAgB,oBAAoB,CAClC,MAAM,SAAS,sBAAsB,GAAG,sBAAsB,EAC9D,aAAa,SAAS,MAAM,MAAM,GAAG,MAAM,GAAG,KAAK,EACnD,EACA,UAAU,EACV,MAAM,EACN,GAAG,KAAK,EACT,EAAE,yBAAyB,CAAC,MAAM,EAAE,aAAa,CAAC,GAAG;IACpD,UAAU,EAAE,qBAAqB,CAAC;IAClC,MAAM,EAAE,iBAAiB,CAAC;CAC3B,2CAQA"}
@@ -0,0 +1,14 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { InteractionForm, } from "../components/InteractionForm.js";
3
+ export function castInteractionHandle(handle) {
4
+ return handle;
5
+ }
6
+ export function castInteractionDraft(draft) {
7
+ return draft;
8
+ }
9
+ export function castInteractionFields(fields) {
10
+ return fields;
11
+ }
12
+ export function BoundInteractionForm({ descriptor, handle, ...props }) {
13
+ return (_jsx(InteractionForm, { descriptor: descriptor, handle: castInteractionHandle(handle), ...props }));
14
+ }