@dreamboard-games/ui-sdk 0.0.41
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +89 -0
- package/NOTICE +1 -0
- package/README.md +154 -0
- package/dist/components/ActionButton.d.ts +13 -0
- package/dist/components/ActionButton.d.ts.map +1 -0
- package/dist/components/ActionButton.js +14 -0
- package/dist/components/ActionPanel.d.ts +33 -0
- package/dist/components/ActionPanel.d.ts.map +1 -0
- package/dist/components/ActionPanel.js +148 -0
- package/dist/components/Card.d.ts +29 -0
- package/dist/components/Card.d.ts.map +1 -0
- package/dist/components/Card.js +220 -0
- package/dist/components/ChromeSuppressionContext.d.ts +7 -0
- package/dist/components/ChromeSuppressionContext.d.ts.map +1 -0
- package/dist/components/ChromeSuppressionContext.js +34 -0
- package/dist/components/CostDisplay.d.ts +22 -0
- package/dist/components/CostDisplay.d.ts.map +1 -0
- package/dist/components/CostDisplay.js +41 -0
- package/dist/components/DiceRoller.d.ts +30 -0
- package/dist/components/DiceRoller.d.ts.map +1 -0
- package/dist/components/DiceRoller.js +319 -0
- package/dist/components/Drawer.d.ts +19 -0
- package/dist/components/Drawer.d.ts.map +1 -0
- package/dist/components/Drawer.js +55 -0
- package/dist/components/ErrorBoundary.d.ts +24 -0
- package/dist/components/ErrorBoundary.d.ts.map +1 -0
- package/dist/components/ErrorBoundary.js +37 -0
- package/dist/components/GameEndDisplay.d.ts +27 -0
- package/dist/components/GameEndDisplay.d.ts.map +1 -0
- package/dist/components/GameEndDisplay.js +185 -0
- package/dist/components/GameSkeleton.d.ts +12 -0
- package/dist/components/GameSkeleton.d.ts.map +1 -0
- package/dist/components/GameSkeleton.js +54 -0
- package/dist/components/Hand.d.ts +99 -0
- package/dist/components/Hand.d.ts.map +1 -0
- package/dist/components/Hand.js +162 -0
- package/dist/components/HandDock.d.ts +35 -0
- package/dist/components/HandDock.d.ts.map +1 -0
- package/dist/components/HandDock.js +124 -0
- package/dist/components/InteractionForm.d.ts +50 -0
- package/dist/components/InteractionForm.d.ts.map +1 -0
- package/dist/components/InteractionForm.js +402 -0
- package/dist/components/MoreActions.d.ts +49 -0
- package/dist/components/MoreActions.d.ts.map +1 -0
- package/dist/components/MoreActions.js +64 -0
- package/dist/components/PhaseIndicator.d.ts +35 -0
- package/dist/components/PhaseIndicator.d.ts.map +1 -0
- package/dist/components/PhaseIndicator.js +212 -0
- package/dist/components/PlayArea.d.ts +28 -0
- package/dist/components/PlayArea.d.ts.map +1 -0
- package/dist/components/PlayArea.js +48 -0
- package/dist/components/PluginRuntime.d.ts +37 -0
- package/dist/components/PluginRuntime.d.ts.map +1 -0
- package/dist/components/PluginRuntime.js +47 -0
- package/dist/components/PrimaryActionButton.d.ts +98 -0
- package/dist/components/PrimaryActionButton.d.ts.map +1 -0
- package/dist/components/PrimaryActionButton.js +183 -0
- package/dist/components/PrimaryButton.d.ts +20 -0
- package/dist/components/PrimaryButton.d.ts.map +1 -0
- package/dist/components/PrimaryButton.js +5 -0
- package/dist/components/PromptDialogHost.d.ts +15 -0
- package/dist/components/PromptDialogHost.d.ts.map +1 -0
- package/dist/components/PromptDialogHost.js +22 -0
- package/dist/components/ResourceCounter.d.ts +38 -0
- package/dist/components/ResourceCounter.d.ts.map +1 -0
- package/dist/components/ResourceCounter.js +118 -0
- package/dist/components/ThemedButton.d.ts +12 -0
- package/dist/components/ThemedButton.d.ts.map +1 -0
- package/dist/components/ThemedButton.js +38 -0
- package/dist/components/Toast.d.ts +35 -0
- package/dist/components/Toast.d.ts.map +1 -0
- package/dist/components/Toast.js +116 -0
- package/dist/components/board/HexGrid.d.ts +344 -0
- package/dist/components/board/HexGrid.d.ts.map +1 -0
- package/dist/components/board/HexGrid.js +340 -0
- package/dist/components/board/NetworkGraph.d.ts +100 -0
- package/dist/components/board/NetworkGraph.d.ts.map +1 -0
- package/dist/components/board/NetworkGraph.js +123 -0
- package/dist/components/board/SlotSystem.d.ts +71 -0
- package/dist/components/board/SlotSystem.d.ts.map +1 -0
- package/dist/components/board/SlotSystem.js +87 -0
- package/dist/components/board/SquareGrid.d.ts +188 -0
- package/dist/components/board/SquareGrid.d.ts.map +1 -0
- package/dist/components/board/SquareGrid.js +328 -0
- package/dist/components/board/TrackBoard.d.ts +113 -0
- package/dist/components/board/TrackBoard.d.ts.map +1 -0
- package/dist/components/board/TrackBoard.js +135 -0
- package/dist/components/board/ZoneMap.d.ts +88 -0
- package/dist/components/board/ZoneMap.d.ts.map +1 -0
- package/dist/components/board/ZoneMap.js +133 -0
- package/dist/components/board/hex-board-view.d.ts +69 -0
- package/dist/components/board/hex-board-view.d.ts.map +1 -0
- package/dist/components/board/hex-board-view.js +60 -0
- package/dist/components/board/index.d.ts +23 -0
- package/dist/components/board/index.d.ts.map +1 -0
- package/dist/components/board/index.js +40 -0
- package/dist/components/board/interaction-accessibility.d.ts +5 -0
- package/dist/components/board/interaction-accessibility.d.ts.map +1 -0
- package/dist/components/board/interaction-accessibility.js +13 -0
- package/dist/components/board/target-layer.d.ts +13 -0
- package/dist/components/board/target-layer.d.ts.map +1 -0
- package/dist/components/board/target-layer.js +10 -0
- package/dist/components/card-render-content.type-test.d.ts +2 -0
- package/dist/components/card-render-content.type-test.d.ts.map +1 -0
- package/dist/components/card-render-content.type-test.js +1 -0
- package/dist/components/index.d.ts +34 -0
- package/dist/components/index.d.ts.map +1 -0
- package/dist/components/index.js +35 -0
- package/dist/components/interaction-dialog-behavior.d.ts +15 -0
- package/dist/components/interaction-dialog-behavior.d.ts.map +1 -0
- package/dist/components/interaction-dialog-behavior.js +9 -0
- package/dist/components/surfaces/BlockerSurface.d.ts +27 -0
- package/dist/components/surfaces/BlockerSurface.d.ts.map +1 -0
- package/dist/components/surfaces/BlockerSurface.js +38 -0
- package/dist/components/surfaces/BoardSurface.d.ts +77 -0
- package/dist/components/surfaces/BoardSurface.d.ts.map +1 -0
- package/dist/components/surfaces/BoardSurface.js +180 -0
- package/dist/components/surfaces/ChromeSurface.d.ts +29 -0
- package/dist/components/surfaces/ChromeSurface.d.ts.map +1 -0
- package/dist/components/surfaces/ChromeSurface.js +34 -0
- package/dist/components/surfaces/ExhaustivenessAudit.d.ts +32 -0
- package/dist/components/surfaces/ExhaustivenessAudit.d.ts.map +1 -0
- package/dist/components/surfaces/ExhaustivenessAudit.js +65 -0
- package/dist/components/surfaces/InboxSurface.d.ts +40 -0
- package/dist/components/surfaces/InboxSurface.d.ts.map +1 -0
- package/dist/components/surfaces/InboxSurface.js +99 -0
- package/dist/components/surfaces/MarketSurface.d.ts +62 -0
- package/dist/components/surfaces/MarketSurface.d.ts.map +1 -0
- package/dist/components/surfaces/MarketSurface.js +242 -0
- package/dist/components/surfaces/PanelSurface.d.ts +111 -0
- package/dist/components/surfaces/PanelSurface.d.ts.map +1 -0
- package/dist/components/surfaces/PanelSurface.js +180 -0
- package/dist/components/surfaces/PlayerCardsSurface.d.ts +104 -0
- package/dist/components/surfaces/PlayerCardsSurface.d.ts.map +1 -0
- package/dist/components/surfaces/PlayerCardsSurface.js +178 -0
- package/dist/components/surfaces/internal/CardZoneFollowUpForm.d.ts +7 -0
- package/dist/components/surfaces/internal/CardZoneFollowUpForm.d.ts.map +1 -0
- package/dist/components/surfaces/internal/CardZoneFollowUpForm.js +9 -0
- package/dist/components/surfaces/internal/DefaultInteractionButton.d.ts +71 -0
- package/dist/components/surfaces/internal/DefaultInteractionButton.d.ts.map +1 -0
- package/dist/components/surfaces/internal/DefaultInteractionButton.js +82 -0
- package/dist/components/surfaces/internal/useCardZoneInteractions.d.ts +21 -0
- package/dist/components/surfaces/internal/useCardZoneInteractions.d.ts.map +1 -0
- package/dist/components/surfaces/internal/useCardZoneInteractions.js +202 -0
- package/dist/components/surfaces/types.d.ts +59 -0
- package/dist/components/surfaces/types.d.ts.map +1 -0
- package/dist/components/surfaces/types.js +1 -0
- package/dist/context/ClientParamSchemaContext.d.ts +21 -0
- package/dist/context/ClientParamSchemaContext.d.ts.map +1 -0
- package/dist/context/ClientParamSchemaContext.js +12 -0
- package/dist/context/InteractionDraftContext.d.ts +69 -0
- package/dist/context/InteractionDraftContext.d.ts.map +1 -0
- package/dist/context/InteractionDraftContext.js +145 -0
- package/dist/context/PluginSessionContext.d.ts +33 -0
- package/dist/context/PluginSessionContext.d.ts.map +1 -0
- package/dist/context/PluginSessionContext.js +38 -0
- package/dist/context/PluginStateContext.d.ts +116 -0
- package/dist/context/PluginStateContext.d.ts.map +1 -0
- package/dist/context/PluginStateContext.js +186 -0
- package/dist/context/RuntimeContext.d.ts +49 -0
- package/dist/context/RuntimeContext.d.ts.map +1 -0
- package/dist/context/RuntimeContext.js +67 -0
- package/dist/defaults/components.d.ts +52 -0
- package/dist/defaults/components.d.ts.map +1 -0
- package/dist/defaults/components.js +159 -0
- package/dist/defaults/index.d.ts +2 -0
- package/dist/defaults/index.d.ts.map +1 -0
- package/dist/defaults/index.js +1 -0
- package/dist/errors/ValidationError.d.ts +10 -0
- package/dist/errors/ValidationError.d.ts.map +1 -0
- package/dist/errors/ValidationError.js +23 -0
- package/dist/helpers/cards.d.ts +3 -0
- package/dist/helpers/cards.d.ts.map +1 -0
- package/dist/helpers/cards.js +11 -0
- package/dist/helpers/track-board.d.ts +79 -0
- package/dist/helpers/track-board.d.ts.map +1 -0
- package/dist/helpers/track-board.js +56 -0
- package/dist/hooks/useActivePlayers.d.ts +16 -0
- package/dist/hooks/useActivePlayers.d.ts.map +1 -0
- package/dist/hooks/useActivePlayers.js +17 -0
- package/dist/hooks/useBoardInteractions.d.ts +110 -0
- package/dist/hooks/useBoardInteractions.d.ts.map +1 -0
- package/dist/hooks/useBoardInteractions.js +248 -0
- package/dist/hooks/useBoardTopology.d.ts +23 -0
- package/dist/hooks/useBoardTopology.d.ts.map +1 -0
- package/dist/hooks/useBoardTopology.js +128 -0
- package/dist/hooks/useCards.d.ts +3 -0
- package/dist/hooks/useCards.d.ts.map +1 -0
- package/dist/hooks/useCards.js +5 -0
- package/dist/hooks/useGameSelector.d.ts +13 -0
- package/dist/hooks/useGameSelector.d.ts.map +1 -0
- package/dist/hooks/useGameSelector.js +67 -0
- package/dist/hooks/useGameView.d.ts +6 -0
- package/dist/hooks/useGameView.d.ts.map +1 -0
- package/dist/hooks/useGameView.js +7 -0
- package/dist/hooks/useHandLayout.d.ts +120 -0
- package/dist/hooks/useHandLayout.d.ts.map +1 -0
- package/dist/hooks/useHandLayout.js +235 -0
- package/dist/hooks/useHexBoard.d.ts +19 -0
- package/dist/hooks/useHexBoard.d.ts.map +1 -0
- package/dist/hooks/useHexBoard.js +28 -0
- package/dist/hooks/useHexGrid.d.ts +56 -0
- package/dist/hooks/useHexGrid.d.ts.map +1 -0
- package/dist/hooks/useHexGrid.js +112 -0
- package/dist/hooks/useInteractionByKey.d.ts +29 -0
- package/dist/hooks/useInteractionByKey.d.ts.map +1 -0
- package/dist/hooks/useInteractionByKey.js +263 -0
- package/dist/hooks/useInteractionHandle.d.ts +103 -0
- package/dist/hooks/useInteractionHandle.d.ts.map +1 -0
- package/dist/hooks/useInteractionHandle.js +254 -0
- package/dist/hooks/useIsMobile.d.ts +7 -0
- package/dist/hooks/useIsMobile.d.ts.map +1 -0
- package/dist/hooks/useIsMobile.js +29 -0
- package/dist/hooks/useIsMyTurn.d.ts +6 -0
- package/dist/hooks/useIsMyTurn.d.ts.map +1 -0
- package/dist/hooks/useIsMyTurn.js +11 -0
- package/dist/hooks/useLobby.d.ts +28 -0
- package/dist/hooks/useLobby.d.ts.map +1 -0
- package/dist/hooks/useLobby.js +60 -0
- package/dist/hooks/useMe.d.ts +11 -0
- package/dist/hooks/useMe.d.ts.map +1 -0
- package/dist/hooks/useMe.js +32 -0
- package/dist/hooks/usePanZoom.d.ts +113 -0
- package/dist/hooks/usePanZoom.d.ts.map +1 -0
- package/dist/hooks/usePanZoom.js +165 -0
- package/dist/hooks/usePlayerInfo.d.ts +4 -0
- package/dist/hooks/usePlayerInfo.d.ts.map +1 -0
- package/dist/hooks/usePlayerInfo.js +21 -0
- package/dist/hooks/usePlayerTurnOrder.d.ts +15 -0
- package/dist/hooks/usePlayerTurnOrder.d.ts.map +1 -0
- package/dist/hooks/usePlayerTurnOrder.js +22 -0
- package/dist/hooks/usePluginRuntime.d.ts +45 -0
- package/dist/hooks/usePluginRuntime.d.ts.map +1 -0
- package/dist/hooks/usePluginRuntime.js +92 -0
- package/dist/hooks/useSeatInbox.d.ts +22 -0
- package/dist/hooks/useSeatInbox.d.ts.map +1 -0
- package/dist/hooks/useSeatInbox.js +43 -0
- package/dist/hooks/useSimultaneousPhase.d.ts +7 -0
- package/dist/hooks/useSimultaneousPhase.d.ts.map +1 -0
- package/dist/hooks/useSimultaneousPhase.js +8 -0
- package/dist/hooks/useSquareBoard.d.ts +21 -0
- package/dist/hooks/useSquareBoard.d.ts.map +1 -0
- package/dist/hooks/useSquareBoard.js +67 -0
- package/dist/hooks/useSquareGrid.d.ts +96 -0
- package/dist/hooks/useSquareGrid.d.ts.map +1 -0
- package/dist/hooks/useSquareGrid.js +152 -0
- package/dist/index.d.ts +30 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +20 -0
- package/dist/internal/ui/alert.d.ts +8 -0
- package/dist/internal/ui/alert.d.ts.map +1 -0
- package/dist/internal/ui/alert.js +11 -0
- package/dist/internal/ui/button.d.ts +10 -0
- package/dist/internal/ui/button.d.ts.map +1 -0
- package/dist/internal/ui/button.js +21 -0
- package/dist/internal/ui/dialog.d.ts +16 -0
- package/dist/internal/ui/dialog.d.ts.map +1 -0
- package/dist/internal/ui/dialog.js +35 -0
- package/dist/internal/ui/input.d.ts +3 -0
- package/dist/internal/ui/input.d.ts.map +1 -0
- package/dist/internal/ui/input.js +5 -0
- package/dist/internal/ui/label.d.ts +4 -0
- package/dist/internal/ui/label.d.ts.map +1 -0
- package/dist/internal/ui/label.js +7 -0
- package/dist/internal/ui/select.d.ts +9 -0
- package/dist/internal/ui/select.d.ts.map +1 -0
- package/dist/internal/ui/select.js +23 -0
- package/dist/internal/ui/tooltip.d.ts +7 -0
- package/dist/internal/ui/tooltip.d.ts.map +1 -0
- package/dist/internal/ui/tooltip.js +16 -0
- package/dist/internal/ui/utils.d.ts +3 -0
- package/dist/internal/ui/utils.d.ts.map +1 -0
- package/dist/internal/ui/utils.js +4 -0
- package/dist/internal.d.ts +7 -0
- package/dist/internal.d.ts.map +1 -0
- package/dist/internal.js +4 -0
- package/dist/plugin-styles.css +246 -0
- package/dist/primitives/board.d.ts +29 -0
- package/dist/primitives/board.d.ts.map +1 -0
- package/dist/primitives/board.js +163 -0
- package/dist/primitives/game-ui-provider.d.ts +12 -0
- package/dist/primitives/game-ui-provider.d.ts.map +1 -0
- package/dist/primitives/game-ui-provider.js +7 -0
- package/dist/primitives/index.d.ts +8 -0
- package/dist/primitives/index.d.ts.map +1 -0
- package/dist/primitives/index.js +7 -0
- package/dist/primitives/interaction.d.ts +52 -0
- package/dist/primitives/interaction.d.ts.map +1 -0
- package/dist/primitives/interaction.js +250 -0
- package/dist/primitives/phase.d.ts +15 -0
- package/dist/primitives/phase.d.ts.map +1 -0
- package/dist/primitives/phase.js +18 -0
- package/dist/primitives/player-roster.d.ts +64 -0
- package/dist/primitives/player-roster.d.ts.map +1 -0
- package/dist/primitives/player-roster.js +149 -0
- package/dist/primitives/primitive-props.d.ts +15 -0
- package/dist/primitives/primitive-props.d.ts.map +1 -0
- package/dist/primitives/primitive-props.js +39 -0
- package/dist/primitives/prompt.d.ts +44 -0
- package/dist/primitives/prompt.d.ts.map +1 -0
- package/dist/primitives/prompt.js +101 -0
- package/dist/primitives/zone.d.ts +31 -0
- package/dist/primitives/zone.d.ts.map +1 -0
- package/dist/primitives/zone.js +58 -0
- package/dist/reducer.d.ts +21 -0
- package/dist/reducer.d.ts.map +1 -0
- package/dist/reducer.js +14 -0
- package/dist/runtime/createPluginRuntimeAPI.d.ts +67 -0
- package/dist/runtime/createPluginRuntimeAPI.d.ts.map +1 -0
- package/dist/runtime/createPluginRuntimeAPI.js +419 -0
- package/dist/theme/ThemeProvider.d.ts +98 -0
- package/dist/theme/ThemeProvider.d.ts.map +1 -0
- package/dist/theme/ThemeProvider.js +148 -0
- package/dist/theme/board.d.ts +42 -0
- package/dist/theme/board.d.ts.map +1 -0
- package/dist/theme/board.js +34 -0
- package/dist/theme/css-vars.d.ts +31 -0
- package/dist/theme/css-vars.d.ts.map +1 -0
- package/dist/theme/css-vars.js +88 -0
- package/dist/theme/derive.d.ts +66 -0
- package/dist/theme/derive.d.ts.map +1 -0
- package/dist/theme/derive.js +161 -0
- package/dist/theme/index.d.ts +22 -0
- package/dist/theme/index.d.ts.map +1 -0
- package/dist/theme/index.js +20 -0
- package/dist/theme/presets/arcade.d.ts +10 -0
- package/dist/theme/presets/arcade.d.ts.map +1 -0
- package/dist/theme/presets/arcade.js +257 -0
- package/dist/theme/presets/studio.d.ts +10 -0
- package/dist/theme/presets/studio.d.ts.map +1 -0
- package/dist/theme/presets/studio.js +257 -0
- package/dist/theme/presets/tabletop.d.ts +15 -0
- package/dist/theme/presets/tabletop.d.ts.map +1 -0
- package/dist/theme/presets/tabletop.js +262 -0
- package/dist/theme/tokens.d.ts +345 -0
- package/dist/theme/tokens.d.ts.map +1 -0
- package/dist/theme/tokens.js +57 -0
- package/dist/types/player-state.d.ts +337 -0
- package/dist/types/player-state.d.ts.map +1 -0
- package/dist/types/player-state.js +1 -0
- package/dist/types/plugin-state.d.ts +324 -0
- package/dist/types/plugin-state.d.ts.map +1 -0
- package/dist/types/plugin-state.js +1 -0
- package/dist/types/reducer-state.d.ts +10 -0
- package/dist/types/reducer-state.d.ts.map +1 -0
- package/dist/types/reducer-state.js +1 -0
- package/dist/types/runtime-api.d.ts +99 -0
- package/dist/types/runtime-api.d.ts.map +1 -0
- package/dist/types/runtime-api.js +1 -0
- package/dist/types/tiled-board.d.ts +187 -0
- package/dist/types/tiled-board.d.ts.map +1 -0
- package/dist/types/tiled-board.js +226 -0
- package/dist/ui-contract.d.ts +78 -0
- package/dist/ui-contract.d.ts.map +1 -0
- package/dist/ui-contract.js +15 -0
- package/dist/ui-sdk.d.ts +3409 -0
- package/dist/utils/interaction-inputs.d.ts +22 -0
- package/dist/utils/interaction-inputs.d.ts.map +1 -0
- package/dist/utils/interaction-inputs.js +219 -0
- package/dist/utils/interaction-labels.d.ts +4 -0
- package/dist/utils/interaction-labels.d.ts.map +1 -0
- package/dist/utils/interaction-labels.js +18 -0
- package/dist/utils/interaction-status.d.ts +15 -0
- package/dist/utils/interaction-status.d.ts.map +1 -0
- package/dist/utils/interaction-status.js +31 -0
- package/package.json +101 -0
- package/src/components/ActionButton.tsx +48 -0
- package/src/components/ActionPanel.tsx +310 -0
- package/src/components/Card.tsx +385 -0
- package/src/components/ChromeSuppressionContext.tsx +70 -0
- package/src/components/CostDisplay.test.tsx +23 -0
- package/src/components/CostDisplay.tsx +145 -0
- package/src/components/DiceRoller.tsx +601 -0
- package/src/components/Drawer.tsx +179 -0
- package/src/components/ErrorBoundary.tsx +119 -0
- package/src/components/GameEndDisplay.test.tsx +19 -0
- package/src/components/GameEndDisplay.tsx +398 -0
- package/src/components/GameSkeleton.tsx +260 -0
- package/src/components/Hand.tsx +387 -0
- package/src/components/HandDock.tsx +257 -0
- package/src/components/InteractionForm.test.tsx +303 -0
- package/src/components/InteractionForm.tsx +1029 -0
- package/src/components/MoreActions.test.tsx +93 -0
- package/src/components/MoreActions.tsx +143 -0
- package/src/components/PhaseIndicator.tsx +341 -0
- package/src/components/PlayArea.tsx +125 -0
- package/src/components/PluginRuntime.tsx +92 -0
- package/src/components/PrimaryActionButton.test.tsx +138 -0
- package/src/components/PrimaryActionButton.tsx +351 -0
- package/src/components/PrimaryButton.tsx +44 -0
- package/src/components/PromptDialogHost.tsx +92 -0
- package/src/components/ResourceCounter.test.tsx +29 -0
- package/src/components/ResourceCounter.tsx +275 -0
- package/src/components/ThemedButton.tsx +78 -0
- package/src/components/Toast.tsx +251 -0
- package/src/components/__fixtures__/ActionButton.fixture.tsx +234 -0
- package/src/components/__fixtures__/ActionPanel.fixture.tsx +298 -0
- package/src/components/__fixtures__/Card.fixture.tsx +185 -0
- package/src/components/__fixtures__/CostDisplay.fixture.tsx +156 -0
- package/src/components/__fixtures__/DiceRoller.fixture.tsx +435 -0
- package/src/components/__fixtures__/Drawer.fixture.tsx +113 -0
- package/src/components/__fixtures__/ErrorBoundary.fixture.tsx +82 -0
- package/src/components/__fixtures__/GameEndDisplay.fixture.tsx +188 -0
- package/src/components/__fixtures__/GameSkeleton.fixture.tsx +46 -0
- package/src/components/__fixtures__/Hand.fixture.tsx +522 -0
- package/src/components/__fixtures__/HexGrid.fixture.tsx +1181 -0
- package/src/components/__fixtures__/NetworkGraph.fixture.tsx +599 -0
- package/src/components/__fixtures__/PhaseIndicator.fixture.tsx +181 -0
- package/src/components/__fixtures__/PlayArea.fixture.tsx +221 -0
- package/src/components/__fixtures__/ResourceCounter.fixture.tsx +227 -0
- package/src/components/__fixtures__/SlotSystem.fixture.tsx +824 -0
- package/src/components/__fixtures__/SquareGrid.fixture.tsx +764 -0
- package/src/components/__fixtures__/Toast.fixture.tsx +97 -0
- package/src/components/__fixtures__/TrackBoard.fixture.tsx +685 -0
- package/src/components/__fixtures__/ZoneMap.fixture.tsx +754 -0
- package/src/components/board/HexGrid.tsx +1294 -0
- package/src/components/board/NetworkGraph.tsx +476 -0
- package/src/components/board/SlotSystem.tsx +339 -0
- package/src/components/board/SquareGrid.tsx +1165 -0
- package/src/components/board/TrackBoard.tsx +496 -0
- package/src/components/board/ZoneMap.tsx +448 -0
- package/src/components/board/hex-board-view.test.tsx +114 -0
- package/src/components/board/hex-board-view.ts +123 -0
- package/src/components/board/index.ts +142 -0
- package/src/components/board/interaction-accessibility.ts +21 -0
- package/src/components/board/target-layer-grids.test.tsx +420 -0
- package/src/components/board/target-layer.ts +30 -0
- package/src/components/card-render-content.type-test.ts +27 -0
- package/src/components/index.ts +208 -0
- package/src/components/interaction-dialog-behavior.test.ts +23 -0
- package/src/components/interaction-dialog-behavior.ts +22 -0
- package/src/components/surfaces/BlockerSurface.test.tsx +158 -0
- package/src/components/surfaces/BlockerSurface.tsx +127 -0
- package/src/components/surfaces/BoardSurface.tsx +340 -0
- package/src/components/surfaces/ChromeSurface.tsx +123 -0
- package/src/components/surfaces/ExhaustivenessAudit.tsx +91 -0
- package/src/components/surfaces/InboxSurface.test.tsx +149 -0
- package/src/components/surfaces/InboxSurface.tsx +245 -0
- package/src/components/surfaces/MarketSurface.tsx +544 -0
- package/src/components/surfaces/PanelSurface.test.tsx +496 -0
- package/src/components/surfaces/PanelSurface.tsx +458 -0
- package/src/components/surfaces/PlayerCardsSurface.tsx +525 -0
- package/src/components/surfaces/internal/CardZoneFollowUpForm.tsx +35 -0
- package/src/components/surfaces/internal/DefaultInteractionButton.tsx +219 -0
- package/src/components/surfaces/internal/useCardZoneInteractions.ts +311 -0
- package/src/components/surfaces/types.ts +100 -0
- package/src/context/ClientParamSchemaContext.tsx +44 -0
- package/src/context/InteractionDraftContext.tsx +204 -0
- package/src/context/PluginSessionContext.tsx +47 -0
- package/src/context/PluginStateContext.tsx +254 -0
- package/src/context/RuntimeContext.tsx +96 -0
- package/src/defaults/components.tsx +442 -0
- package/src/defaults/defaults.test.tsx +230 -0
- package/src/defaults/index.ts +1 -0
- package/src/errors/ValidationError.ts +29 -0
- package/src/helpers/cards.ts +19 -0
- package/src/helpers/track-board.ts +211 -0
- package/src/hooks/useActivePlayers.ts +19 -0
- package/src/hooks/useBoardInteractions.test.tsx +622 -0
- package/src/hooks/useBoardInteractions.ts +434 -0
- package/src/hooks/useBoardTopology.ts +316 -0
- package/src/hooks/useCards.test.tsx +129 -0
- package/src/hooks/useCards.ts +10 -0
- package/src/hooks/useGameSelector.ts +105 -0
- package/src/hooks/useGameView.ts +9 -0
- package/src/hooks/useHandLayout.ts +349 -0
- package/src/hooks/useHexBoard.ts +74 -0
- package/src/hooks/useHexGrid.ts +185 -0
- package/src/hooks/useInteractionByKey.ts +349 -0
- package/src/hooks/useInteractionHandle.ts +437 -0
- package/src/hooks/useIsMobile.ts +35 -0
- package/src/hooks/useIsMyTurn.test.tsx +99 -0
- package/src/hooks/useIsMyTurn.ts +15 -0
- package/src/hooks/useLobby.ts +76 -0
- package/src/hooks/useMe.ts +48 -0
- package/src/hooks/usePanZoom.ts +278 -0
- package/src/hooks/usePlayerInfo.ts +28 -0
- package/src/hooks/usePlayerTurnOrder.ts +23 -0
- package/src/hooks/usePluginRuntime.test.tsx +102 -0
- package/src/hooks/usePluginRuntime.ts +130 -0
- package/src/hooks/useSeatInbox.ts +61 -0
- package/src/hooks/useSimultaneousPhase.ts +10 -0
- package/src/hooks/useSquareBoard.ts +124 -0
- package/src/hooks/useSquareGrid.ts +328 -0
- package/src/index.test.ts +474 -0
- package/src/index.ts +148 -0
- package/src/internal/ui/alert.tsx +51 -0
- package/src/internal/ui/button.tsx +58 -0
- package/src/internal/ui/dialog.tsx +134 -0
- package/src/internal/ui/input.tsx +21 -0
- package/src/internal/ui/label.tsx +21 -0
- package/src/internal/ui/select.tsx +129 -0
- package/src/internal/ui/tooltip.tsx +54 -0
- package/src/internal/ui/utils.ts +5 -0
- package/src/internal.ts +18 -0
- package/src/plugin-styles.css +246 -0
- package/src/primitives/board.test.tsx +139 -0
- package/src/primitives/board.tsx +267 -0
- package/src/primitives/game-ui-provider.tsx +35 -0
- package/src/primitives/index.ts +83 -0
- package/src/primitives/interaction.test.tsx +420 -0
- package/src/primitives/interaction.tsx +405 -0
- package/src/primitives/phase.test.tsx +82 -0
- package/src/primitives/phase.tsx +43 -0
- package/src/primitives/player-roster.test.tsx +168 -0
- package/src/primitives/player-roster.tsx +301 -0
- package/src/primitives/primitive-props.tsx +82 -0
- package/src/primitives/prompt.test.tsx +159 -0
- package/src/primitives/prompt.tsx +203 -0
- package/src/primitives/zone.tsx +113 -0
- package/src/reducer.ts +42 -0
- package/src/runtime/createPluginRuntimeAPI.ts +605 -0
- package/src/theme/ThemeProvider.test.tsx +36 -0
- package/src/theme/ThemeProvider.tsx +252 -0
- package/src/theme/board.ts +61 -0
- package/src/theme/css-vars.ts +105 -0
- package/src/theme/derive.ts +240 -0
- package/src/theme/index.ts +61 -0
- package/src/theme/presets/arcade.ts +261 -0
- package/src/theme/presets/studio.ts +261 -0
- package/src/theme/presets/tabletop.ts +266 -0
- package/src/theme/theme.test.ts +258 -0
- package/src/theme/tokens.ts +392 -0
- package/src/types/player-state.ts +445 -0
- package/src/types/plugin-state.ts +407 -0
- package/src/types/reducer-state.ts +24 -0
- package/src/types/runtime-api.ts +114 -0
- package/src/types/tiled-board.ts +785 -0
- package/src/ui-contract.ts +168 -0
- package/src/utils/interaction-inputs.test.ts +109 -0
- package/src/utils/interaction-inputs.ts +331 -0
- package/src/utils/interaction-labels.ts +23 -0
- package/src/utils/interaction-status.ts +59 -0
|
@@ -0,0 +1,340 @@
|
|
|
1
|
+
import { useCallback, useEffect, useMemo, type ReactNode } from "react";
|
|
2
|
+
import { useStore } from "zustand";
|
|
3
|
+
import { useInteractionUiStore } from "../../context/InteractionDraftContext.js";
|
|
4
|
+
import {
|
|
5
|
+
useInteractionHandle,
|
|
6
|
+
type InteractionHandle,
|
|
7
|
+
} from "../../hooks/useInteractionHandle.js";
|
|
8
|
+
import { usePluginState } from "../../context/PluginStateContext.js";
|
|
9
|
+
import type { InteractionDescriptor } from "../../types/plugin-state.js";
|
|
10
|
+
import {
|
|
11
|
+
eligibleTargetsByInput,
|
|
12
|
+
eligibleTargetsByBoardKind,
|
|
13
|
+
hasBoardTargetInput,
|
|
14
|
+
interactionArmScope,
|
|
15
|
+
interactionInputKeys,
|
|
16
|
+
type BoardTargetKind,
|
|
17
|
+
} from "../../utils/interaction-inputs.js";
|
|
18
|
+
|
|
19
|
+
/** Standard board surface tags produced by the trusted bundle. */
|
|
20
|
+
export type BoardSurfaceTag =
|
|
21
|
+
| "board-vertex"
|
|
22
|
+
| "board-edge"
|
|
23
|
+
| "board-tile"
|
|
24
|
+
| "board-space";
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Context handed to the `<BoardSurface>` children render-prop. Covers
|
|
28
|
+
* everything callers need to route hex/vertex/edge/space clicks into the
|
|
29
|
+
* correct interaction with a single `select(targetId)` call.
|
|
30
|
+
*/
|
|
31
|
+
export interface BoardSurfaceContext<I extends string = string> {
|
|
32
|
+
/** All available board-* interactions (armed and unarmed). */
|
|
33
|
+
interactions: ReadonlyArray<InteractionDescriptor<I>>;
|
|
34
|
+
/** Key of the currently armed interaction, or null. */
|
|
35
|
+
armedId: string | null;
|
|
36
|
+
/** Handle of the armed interaction, or null when nothing is armed. */
|
|
37
|
+
armed: InteractionHandle | null;
|
|
38
|
+
/**
|
|
39
|
+
* Eligible target ids for the armed interaction, keyed by
|
|
40
|
+
* input-collector name (e.g. `{ vertexId: Set(['v-1','v-2']) }`).
|
|
41
|
+
*/
|
|
42
|
+
eligible: Readonly<Record<string, ReadonlySet<string>>>;
|
|
43
|
+
/** Arm a specific interaction key on its surface (or disarm when null). */
|
|
44
|
+
arm: (interactionKey: string | null) => void;
|
|
45
|
+
/**
|
|
46
|
+
* Commit a target click. Writes `targetId` into the first draft input
|
|
47
|
+
* whose eligible-set includes it (preferring inputs that are still
|
|
48
|
+
* empty) and submits as soon as every required input is filled.
|
|
49
|
+
*/
|
|
50
|
+
select: (targetId: string) => Promise<void>;
|
|
51
|
+
/**
|
|
52
|
+
* Whether `targetId` is eligible under the armed interaction.
|
|
53
|
+
* Pass `inputKey` to scope the check to a specific input.
|
|
54
|
+
*/
|
|
55
|
+
isEligible: (targetId: string, inputKey?: string) => boolean;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
export interface BoardSurfaceProps<I extends string = string> {
|
|
59
|
+
/**
|
|
60
|
+
* Required children-as-function. Receives a
|
|
61
|
+
* {@link BoardSurfaceContext} with the armed interaction, eligible
|
|
62
|
+
* targets and a click-routing `select(targetId)` helper.
|
|
63
|
+
*/
|
|
64
|
+
children: (ctx: BoardSurfaceContext<I>) => ReactNode;
|
|
65
|
+
/** Rendered when no board-* interactions are available. */
|
|
66
|
+
empty?: ReactNode;
|
|
67
|
+
/**
|
|
68
|
+
* When true (default), auto-arm the single available interaction so
|
|
69
|
+
* single-choice boards don't need explicit arming UI.
|
|
70
|
+
*/
|
|
71
|
+
autoArmSingle?: boolean;
|
|
72
|
+
/** Surface tags included in this instance. Defaults to all four. */
|
|
73
|
+
surfaces?: readonly BoardSurfaceTag[];
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* Surface for any interaction tagged `board-vertex`, `board-edge`,
|
|
78
|
+
* `board-tile` or `board-space`.
|
|
79
|
+
*
|
|
80
|
+
* `BoardSurface` does **not** render board geometry (that stays with
|
|
81
|
+
* the app). Instead it exposes an opinionated click-routing context so
|
|
82
|
+
* that a plain SVG/canvas board wired via `select(targetId)`
|
|
83
|
+
* automatically participates in arming, eligibility highlighting, and
|
|
84
|
+
* submission.
|
|
85
|
+
*
|
|
86
|
+
* ```tsx
|
|
87
|
+
* <BoardSurface>
|
|
88
|
+
* {({ eligible, select, armedId }) => (
|
|
89
|
+
* <HexBoard
|
|
90
|
+
* highlightedVertices={eligible.vertexId}
|
|
91
|
+
* onVertexClick={(id) => select(id)}
|
|
92
|
+
* armedInteractionId={armedId}
|
|
93
|
+
* />
|
|
94
|
+
* )}
|
|
95
|
+
* </BoardSurface>
|
|
96
|
+
* ```
|
|
97
|
+
*/
|
|
98
|
+
export function BoardSurface<I extends string = string>({
|
|
99
|
+
children,
|
|
100
|
+
empty = null,
|
|
101
|
+
autoArmSingle = true,
|
|
102
|
+
surfaces = ["board-vertex", "board-edge", "board-tile", "board-space"],
|
|
103
|
+
}: BoardSurfaceProps<I>) {
|
|
104
|
+
const store = useInteractionUiStore();
|
|
105
|
+
const subscribedArmedBySurface = useStore(store, (state) => state.arms);
|
|
106
|
+
const armedBySurface = store.getState().arms ?? subscribedArmedBySurface;
|
|
107
|
+
const descriptors = usePluginState(
|
|
108
|
+
(state) => state.gameplay.availableInteractions ?? [],
|
|
109
|
+
);
|
|
110
|
+
|
|
111
|
+
const armedIds = useMemo(
|
|
112
|
+
() => new Set(Object.values(armedBySurface)),
|
|
113
|
+
[armedBySurface],
|
|
114
|
+
);
|
|
115
|
+
const interactions = useMemo(() => {
|
|
116
|
+
const targetKinds = new Set(surfaces.map(boardTargetKindForSurface));
|
|
117
|
+
return descriptors.filter(
|
|
118
|
+
(descriptor) =>
|
|
119
|
+
armedIds.has(descriptor.interactionKey) ||
|
|
120
|
+
(hasBoardTargetInput(descriptor) &&
|
|
121
|
+
(targetKinds.size === 0 ||
|
|
122
|
+
(
|
|
123
|
+
Object.keys(
|
|
124
|
+
eligibleTargetsByBoardKind(descriptor),
|
|
125
|
+
) as BoardTargetKind[]
|
|
126
|
+
).some((kind) => targetKinds.has(kind)))),
|
|
127
|
+
) as unknown as ReadonlyArray<InteractionDescriptor<I>>;
|
|
128
|
+
}, [armedIds, descriptors, surfaces]);
|
|
129
|
+
|
|
130
|
+
const armedId = useMemo(() => {
|
|
131
|
+
const interactionKeys = new Set<string>(
|
|
132
|
+
interactions.map((descriptor) => descriptor.interactionKey),
|
|
133
|
+
);
|
|
134
|
+
return (
|
|
135
|
+
Object.values(armedBySurface).find((id) => interactionKeys.has(id)) ??
|
|
136
|
+
null
|
|
137
|
+
);
|
|
138
|
+
}, [armedBySurface, interactions]);
|
|
139
|
+
const armedDescriptor = useMemo(
|
|
140
|
+
() =>
|
|
141
|
+
interactions.find(
|
|
142
|
+
(descriptor) => descriptor.interactionKey === armedId,
|
|
143
|
+
) ??
|
|
144
|
+
interactions.find((descriptor) =>
|
|
145
|
+
armedIds.has(descriptor.interactionKey),
|
|
146
|
+
) ??
|
|
147
|
+
null,
|
|
148
|
+
[armedIds, interactions, armedId],
|
|
149
|
+
);
|
|
150
|
+
|
|
151
|
+
useEffect(() => {
|
|
152
|
+
if (!autoArmSingle) return;
|
|
153
|
+
if (interactions.length !== 1) return;
|
|
154
|
+
const only = interactions[0];
|
|
155
|
+
if (!only || !only.available) return;
|
|
156
|
+
const scope = interactionArmScope(only);
|
|
157
|
+
if (store.getArmed(scope) === only.interactionKey) return;
|
|
158
|
+
store.arm(scope, only.interactionKey);
|
|
159
|
+
}, [autoArmSingle, interactions, store]);
|
|
160
|
+
|
|
161
|
+
// Disarm stale ids (interaction disappeared from the inbox).
|
|
162
|
+
useEffect(() => {
|
|
163
|
+
for (const [surface, interactionKey] of Object.entries(armedBySurface)) {
|
|
164
|
+
const stillPresent = interactions.some(
|
|
165
|
+
(descriptor) => descriptor.interactionKey === interactionKey,
|
|
166
|
+
);
|
|
167
|
+
if (!stillPresent) {
|
|
168
|
+
store.arm(surface, null);
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
}, [armedBySurface, interactions, store]);
|
|
172
|
+
|
|
173
|
+
if (interactions.length === 0) {
|
|
174
|
+
return <>{empty}</>;
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
if (armedDescriptor) {
|
|
178
|
+
return (
|
|
179
|
+
<ArmedBoardBody<I>
|
|
180
|
+
interactions={interactions}
|
|
181
|
+
armedDescriptor={armedDescriptor}
|
|
182
|
+
>
|
|
183
|
+
{children}
|
|
184
|
+
</ArmedBoardBody>
|
|
185
|
+
);
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
return (
|
|
189
|
+
<UnarmedBoardBody<I> interactions={interactions}>
|
|
190
|
+
{children}
|
|
191
|
+
</UnarmedBoardBody>
|
|
192
|
+
);
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
function ArmedBoardBody<I extends string>({
|
|
196
|
+
interactions,
|
|
197
|
+
armedDescriptor,
|
|
198
|
+
children,
|
|
199
|
+
}: {
|
|
200
|
+
interactions: ReadonlyArray<InteractionDescriptor<I>>;
|
|
201
|
+
armedDescriptor: InteractionDescriptor<I>;
|
|
202
|
+
children: (ctx: BoardSurfaceContext<I>) => ReactNode;
|
|
203
|
+
}) {
|
|
204
|
+
const armed = useInteractionHandle(armedDescriptor);
|
|
205
|
+
const store = useInteractionUiStore();
|
|
206
|
+
|
|
207
|
+
const eligible = useMemo<
|
|
208
|
+
Readonly<Record<string, ReadonlySet<string>>>
|
|
209
|
+
>(() => {
|
|
210
|
+
const result: Record<string, ReadonlySet<string>> = {};
|
|
211
|
+
const raw = eligibleTargetsByInput(armed.descriptor);
|
|
212
|
+
for (const [key, values] of Object.entries(raw)) {
|
|
213
|
+
result[key] = new Set(values ?? []);
|
|
214
|
+
}
|
|
215
|
+
return result;
|
|
216
|
+
}, [armed.descriptor]);
|
|
217
|
+
|
|
218
|
+
const arm = useCallback(
|
|
219
|
+
(interactionKey: string | null) => {
|
|
220
|
+
if (interactionKey === null) {
|
|
221
|
+
store.arm(interactionArmScope(armedDescriptor), null);
|
|
222
|
+
return;
|
|
223
|
+
}
|
|
224
|
+
const target = interactions.find(
|
|
225
|
+
(d) => d.interactionKey === interactionKey,
|
|
226
|
+
);
|
|
227
|
+
if (!target) return;
|
|
228
|
+
store.arm(interactionArmScope(target), interactionKey);
|
|
229
|
+
},
|
|
230
|
+
[armedDescriptor, interactions, store],
|
|
231
|
+
);
|
|
232
|
+
|
|
233
|
+
const isEligible = useCallback(
|
|
234
|
+
(targetId: string, inputKey?: string) => {
|
|
235
|
+
if (inputKey !== undefined) {
|
|
236
|
+
return eligible[inputKey]?.has(targetId) ?? false;
|
|
237
|
+
}
|
|
238
|
+
return Object.values(eligible).some((set) => set.has(targetId));
|
|
239
|
+
},
|
|
240
|
+
[eligible],
|
|
241
|
+
);
|
|
242
|
+
|
|
243
|
+
const select = useCallback(
|
|
244
|
+
async (targetId: string) => {
|
|
245
|
+
const keys = Object.keys(eligible);
|
|
246
|
+
if (keys.length === 0) return;
|
|
247
|
+
const currentDraft = armed.draft;
|
|
248
|
+
const emptyMatch = keys.find(
|
|
249
|
+
(k) =>
|
|
250
|
+
eligible[k]?.has(targetId) &&
|
|
251
|
+
(currentDraft[k] === undefined || currentDraft[k] === null),
|
|
252
|
+
);
|
|
253
|
+
const fallback = keys.find((k) => eligible[k]?.has(targetId));
|
|
254
|
+
const match = emptyMatch ?? fallback;
|
|
255
|
+
if (!match) return;
|
|
256
|
+
armed.setInput(match, targetId);
|
|
257
|
+
const nextDraft: Record<string, unknown> = {
|
|
258
|
+
...currentDraft,
|
|
259
|
+
[match]: targetId,
|
|
260
|
+
};
|
|
261
|
+
const required = interactionInputKeys(armed.descriptor);
|
|
262
|
+
const ready = required.every(
|
|
263
|
+
(key) => nextDraft[key] !== undefined && nextDraft[key] !== null,
|
|
264
|
+
);
|
|
265
|
+
if (ready) {
|
|
266
|
+
await armed.submit(nextDraft);
|
|
267
|
+
}
|
|
268
|
+
},
|
|
269
|
+
[armed, eligible],
|
|
270
|
+
);
|
|
271
|
+
|
|
272
|
+
const ctx: BoardSurfaceContext<I> = {
|
|
273
|
+
interactions,
|
|
274
|
+
armedId: armed.descriptor.interactionKey,
|
|
275
|
+
armed,
|
|
276
|
+
eligible,
|
|
277
|
+
arm,
|
|
278
|
+
select,
|
|
279
|
+
isEligible,
|
|
280
|
+
};
|
|
281
|
+
|
|
282
|
+
return <>{children(ctx)}</>;
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
function UnarmedBoardBody<I extends string>({
|
|
286
|
+
interactions,
|
|
287
|
+
children,
|
|
288
|
+
}: {
|
|
289
|
+
interactions: ReadonlyArray<InteractionDescriptor<I>>;
|
|
290
|
+
children: (ctx: BoardSurfaceContext<I>) => ReactNode;
|
|
291
|
+
}) {
|
|
292
|
+
const store = useInteractionUiStore();
|
|
293
|
+
|
|
294
|
+
const arm = useCallback(
|
|
295
|
+
(interactionKey: string | null) => {
|
|
296
|
+
if (interactionKey === null) {
|
|
297
|
+
for (const descriptor of interactions) {
|
|
298
|
+
store.arm(interactionArmScope(descriptor), null);
|
|
299
|
+
}
|
|
300
|
+
return;
|
|
301
|
+
}
|
|
302
|
+
const target = interactions.find(
|
|
303
|
+
(d) => d.interactionKey === interactionKey,
|
|
304
|
+
);
|
|
305
|
+
if (!target) return;
|
|
306
|
+
store.arm(interactionArmScope(target), interactionKey);
|
|
307
|
+
},
|
|
308
|
+
[interactions, store],
|
|
309
|
+
);
|
|
310
|
+
|
|
311
|
+
const noop = useCallback(async () => {}, []);
|
|
312
|
+
const never = useCallback(() => false, []);
|
|
313
|
+
|
|
314
|
+
const ctx: BoardSurfaceContext<I> = {
|
|
315
|
+
interactions,
|
|
316
|
+
armedId: null,
|
|
317
|
+
armed: null,
|
|
318
|
+
eligible: EMPTY_ELIGIBLE,
|
|
319
|
+
arm,
|
|
320
|
+
select: noop,
|
|
321
|
+
isEligible: never,
|
|
322
|
+
};
|
|
323
|
+
|
|
324
|
+
return <>{children(ctx)}</>;
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
const EMPTY_ELIGIBLE: Readonly<Record<string, ReadonlySet<string>>> = {};
|
|
328
|
+
|
|
329
|
+
function boardTargetKindForSurface(surface: BoardSurfaceTag): BoardTargetKind {
|
|
330
|
+
switch (surface) {
|
|
331
|
+
case "board-edge":
|
|
332
|
+
return "edge";
|
|
333
|
+
case "board-space":
|
|
334
|
+
return "space";
|
|
335
|
+
case "board-tile":
|
|
336
|
+
return "tile";
|
|
337
|
+
case "board-vertex":
|
|
338
|
+
return "vertex";
|
|
339
|
+
}
|
|
340
|
+
}
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
import type { ReactNode } from "react";
|
|
2
|
+
import { useSeatInbox } from "../../hooks/useSeatInbox.js";
|
|
3
|
+
import {
|
|
4
|
+
useInteractionHandle,
|
|
5
|
+
type InteractionHandle,
|
|
6
|
+
} from "../../hooks/useInteractionHandle.js";
|
|
7
|
+
import { useTheme } from "../../theme/ThemeProvider.js";
|
|
8
|
+
import type { InteractionDescriptor } from "../../types/plugin-state.js";
|
|
9
|
+
import { DefaultInteractionButton } from "./internal/DefaultInteractionButton.js";
|
|
10
|
+
import type {
|
|
11
|
+
InteractionDefaultedKeysOf,
|
|
12
|
+
InteractionParamsByKeyShape,
|
|
13
|
+
InteractionParamsOf,
|
|
14
|
+
SurfaceRenderMap,
|
|
15
|
+
} from "./types.js";
|
|
16
|
+
|
|
17
|
+
export interface ChromeSurfaceProps<
|
|
18
|
+
I extends string = never,
|
|
19
|
+
ParamsByKey extends Partial<InteractionParamsByKeyShape> = {},
|
|
20
|
+
> {
|
|
21
|
+
/**
|
|
22
|
+
* Optional per-interaction overrides. Omit to fall back to the default
|
|
23
|
+
* `DefaultInteractionButton` for every chrome interaction.
|
|
24
|
+
*/
|
|
25
|
+
render?: SurfaceRenderMap<I, ParamsByKey>;
|
|
26
|
+
/**
|
|
27
|
+
* Fallback renderer for chrome interactions without a `render` entry.
|
|
28
|
+
* Defaults to the built-in `DefaultInteractionButton`.
|
|
29
|
+
*/
|
|
30
|
+
renderItem?: (
|
|
31
|
+
descriptor: InteractionDescriptor<I>,
|
|
32
|
+
handle: InteractionHandle<
|
|
33
|
+
InteractionParamsOf<ParamsByKey, I>,
|
|
34
|
+
InteractionDefaultedKeysOf<ParamsByKey, I>
|
|
35
|
+
>,
|
|
36
|
+
) => ReactNode;
|
|
37
|
+
/** Interaction keys intentionally rendered elsewhere, such as auto primary actions. */
|
|
38
|
+
excludeInteractionKeys?: readonly string[];
|
|
39
|
+
/** Shown when no chrome interactions are available. */
|
|
40
|
+
empty?: ReactNode;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* Default renderer for legacy chrome interactions — persistent controls like
|
|
45
|
+
* menu buttons or status indicators. Renders a layout-less horizontal flex row
|
|
46
|
+
* so callers can own positioning and spacing.
|
|
47
|
+
*
|
|
48
|
+
* Visual styling is sourced entirely from the active {@link useTheme}.
|
|
49
|
+
*/
|
|
50
|
+
export function ChromeSurface<
|
|
51
|
+
I extends string = never,
|
|
52
|
+
ParamsByKey extends Partial<InteractionParamsByKeyShape> = {},
|
|
53
|
+
>({
|
|
54
|
+
render,
|
|
55
|
+
renderItem,
|
|
56
|
+
excludeInteractionKeys,
|
|
57
|
+
empty = null,
|
|
58
|
+
}: ChromeSurfaceProps<I, ParamsByKey>) {
|
|
59
|
+
const theme = useTheme();
|
|
60
|
+
const inbox = useSeatInbox();
|
|
61
|
+
const excluded = new Set(excludeInteractionKeys ?? []);
|
|
62
|
+
const items = (
|
|
63
|
+
(inbox.bySurface.chrome ?? []) as ReadonlyArray<InteractionDescriptor<I>>
|
|
64
|
+
).filter((descriptor) => !excluded.has(descriptor.interactionKey));
|
|
65
|
+
if (items.length === 0) return <>{empty}</>;
|
|
66
|
+
return (
|
|
67
|
+
<div
|
|
68
|
+
role="toolbar"
|
|
69
|
+
aria-label="Chrome actions"
|
|
70
|
+
data-surface="chrome"
|
|
71
|
+
style={{
|
|
72
|
+
display: "flex",
|
|
73
|
+
gap: theme.space[2],
|
|
74
|
+
alignItems: "center",
|
|
75
|
+
}}
|
|
76
|
+
>
|
|
77
|
+
{items.map((descriptor) => (
|
|
78
|
+
<ChromeItem<I, ParamsByKey>
|
|
79
|
+
key={descriptor.interactionKey}
|
|
80
|
+
descriptor={descriptor}
|
|
81
|
+
render={render}
|
|
82
|
+
renderItem={renderItem}
|
|
83
|
+
/>
|
|
84
|
+
))}
|
|
85
|
+
</div>
|
|
86
|
+
);
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
function ChromeItem<
|
|
90
|
+
I extends string,
|
|
91
|
+
ParamsByKey extends Partial<InteractionParamsByKeyShape> = {},
|
|
92
|
+
>({
|
|
93
|
+
descriptor,
|
|
94
|
+
render,
|
|
95
|
+
renderItem,
|
|
96
|
+
}: {
|
|
97
|
+
descriptor: InteractionDescriptor<I>;
|
|
98
|
+
render?: SurfaceRenderMap<I, ParamsByKey>;
|
|
99
|
+
renderItem?: (
|
|
100
|
+
descriptor: InteractionDescriptor<I>,
|
|
101
|
+
handle: InteractionHandle<
|
|
102
|
+
InteractionParamsOf<ParamsByKey, I>,
|
|
103
|
+
InteractionDefaultedKeysOf<ParamsByKey, I>
|
|
104
|
+
>,
|
|
105
|
+
) => ReactNode;
|
|
106
|
+
}) {
|
|
107
|
+
const handle = useInteractionHandle<
|
|
108
|
+
InteractionParamsOf<ParamsByKey, I>,
|
|
109
|
+
InteractionDefaultedKeysOf<ParamsByKey, I>
|
|
110
|
+
>(descriptor);
|
|
111
|
+
const override = render?.[descriptor.interactionKey] as
|
|
112
|
+
| ((
|
|
113
|
+
descriptor: InteractionDescriptor<I>,
|
|
114
|
+
handle: InteractionHandle<
|
|
115
|
+
InteractionParamsOf<ParamsByKey, I>,
|
|
116
|
+
InteractionDefaultedKeysOf<ParamsByKey, I>
|
|
117
|
+
>,
|
|
118
|
+
) => ReactNode)
|
|
119
|
+
| undefined;
|
|
120
|
+
if (override) return <>{override(descriptor, handle)}</>;
|
|
121
|
+
if (renderItem) return <>{renderItem(descriptor, handle)}</>;
|
|
122
|
+
return <DefaultInteractionButton descriptor={descriptor} handle={handle} />;
|
|
123
|
+
}
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import { useEffect } from "react";
|
|
2
|
+
import { useSeatInbox } from "../../hooks/useSeatInbox.js";
|
|
3
|
+
import type { SurfaceRenderMap } from "./types.js";
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Per-surface renderer maps the shell is currently using. `undefined`
|
|
7
|
+
* values are treated as "use the surface's default renderer".
|
|
8
|
+
*/
|
|
9
|
+
export interface ExhaustivenessAuditProps {
|
|
10
|
+
panel?: SurfaceRenderMap<string>;
|
|
11
|
+
handledInteractionKeys?: readonly string[];
|
|
12
|
+
inbox?: SurfaceRenderMap<string>;
|
|
13
|
+
chrome?: SurfaceRenderMap<string>;
|
|
14
|
+
blocker?: SurfaceRenderMap<string>;
|
|
15
|
+
board?: SurfaceRenderMap<string>;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
type SurfaceBucket = keyof ExhaustivenessAuditProps;
|
|
19
|
+
|
|
20
|
+
const AUDITED_BUCKETS: ReadonlyArray<
|
|
21
|
+
Exclude<SurfaceBucket, "handledInteractionKeys">
|
|
22
|
+
> = ["panel", "inbox", "chrome", "blocker", "board"];
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Development-only runtime audit that logs a single grouped warning per
|
|
26
|
+
* mount describing which interaction ids are currently projected onto the
|
|
27
|
+
* seat's inbox but do not have an explicit renderer override in the
|
|
28
|
+
* supplied render maps. Useful for catching "oops, I wired a new
|
|
29
|
+
* interaction but forgot to render it" regressions before CI notices.
|
|
30
|
+
*
|
|
31
|
+
* In production builds (`process.env.NODE_ENV === "production"`) this
|
|
32
|
+
* component is a no-op.
|
|
33
|
+
*
|
|
34
|
+
* ```tsx
|
|
35
|
+
* <ExhaustivenessAudit
|
|
36
|
+
* panel={panelRenderers}
|
|
37
|
+
* inbox={inboxRenderers}
|
|
38
|
+
* />
|
|
39
|
+
* ```
|
|
40
|
+
*/
|
|
41
|
+
export function ExhaustivenessAudit(props: ExhaustivenessAuditProps) {
|
|
42
|
+
const inbox = useSeatInbox();
|
|
43
|
+
|
|
44
|
+
useEffect(() => {
|
|
45
|
+
const proc = (globalThis as { process?: { env?: { NODE_ENV?: string } } })
|
|
46
|
+
.process;
|
|
47
|
+
if (!proc) return;
|
|
48
|
+
if (proc.env?.NODE_ENV === "production") return;
|
|
49
|
+
|
|
50
|
+
const unhandled: Array<{ surface: SurfaceBucket; interactionId: string }> =
|
|
51
|
+
[];
|
|
52
|
+
const handledInteractionKeys = new Set(props.handledInteractionKeys ?? []);
|
|
53
|
+
|
|
54
|
+
for (const bucket of AUDITED_BUCKETS) {
|
|
55
|
+
const bySurface =
|
|
56
|
+
bucket === "board"
|
|
57
|
+
? [
|
|
58
|
+
...(inbox.bySurface["board-vertex"] ?? []),
|
|
59
|
+
...(inbox.bySurface["board-edge"] ?? []),
|
|
60
|
+
...(inbox.bySurface["board-tile"] ?? []),
|
|
61
|
+
...(inbox.bySurface["board-space"] ?? []),
|
|
62
|
+
]
|
|
63
|
+
: (inbox.bySurface[bucket] ?? []);
|
|
64
|
+
const map = props[bucket];
|
|
65
|
+
for (const descriptor of bySurface) {
|
|
66
|
+
if (handledInteractionKeys.has(descriptor.interactionKey)) continue;
|
|
67
|
+
if (!map || !(descriptor.interactionKey in map)) {
|
|
68
|
+
unhandled.push({
|
|
69
|
+
surface: bucket,
|
|
70
|
+
interactionId: descriptor.interactionId,
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
if (unhandled.length === 0) return;
|
|
77
|
+
|
|
78
|
+
// eslint-disable-next-line no-console -- dev-only audit
|
|
79
|
+
console.groupCollapsed(
|
|
80
|
+
`[dreamboard/ui-sdk] ExhaustivenessAudit: ${unhandled.length} interaction(s) fell through to the default renderer`,
|
|
81
|
+
);
|
|
82
|
+
for (const entry of unhandled) {
|
|
83
|
+
// eslint-disable-next-line no-console -- dev-only audit
|
|
84
|
+
console.warn(`${entry.surface} · ${entry.interactionId}`);
|
|
85
|
+
}
|
|
86
|
+
// eslint-disable-next-line no-console -- dev-only audit
|
|
87
|
+
console.groupEnd();
|
|
88
|
+
}, [inbox, props]);
|
|
89
|
+
|
|
90
|
+
return null;
|
|
91
|
+
}
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
import { expect, test } from "bun:test";
|
|
2
|
+
import { renderToString } from "react-dom/server";
|
|
3
|
+
import { RuntimeContext } from "../../context/RuntimeContext.js";
|
|
4
|
+
import { PluginSessionContext } from "../../context/PluginSessionContext.js";
|
|
5
|
+
import type {
|
|
6
|
+
InteractionDescriptor,
|
|
7
|
+
PluginStateSnapshot,
|
|
8
|
+
} from "../../types/plugin-state.js";
|
|
9
|
+
import type {
|
|
10
|
+
PluginSessionState,
|
|
11
|
+
RuntimeAPI,
|
|
12
|
+
} from "../../types/runtime-api.js";
|
|
13
|
+
import { InboxSurface } from "./InboxSurface.js";
|
|
14
|
+
|
|
15
|
+
function createSessionState(): PluginSessionState {
|
|
16
|
+
return {
|
|
17
|
+
status: "ready",
|
|
18
|
+
sessionId: "session-1",
|
|
19
|
+
controllablePlayerIds: ["player-1"],
|
|
20
|
+
controllingPlayerId: "player-1",
|
|
21
|
+
userId: "user-1",
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
function createInboxDescriptor(
|
|
26
|
+
id: string,
|
|
27
|
+
overrides: Partial<InteractionDescriptor> = {},
|
|
28
|
+
): InteractionDescriptor {
|
|
29
|
+
return {
|
|
30
|
+
phaseName: "respond",
|
|
31
|
+
interactionKey: `respond.${id}`,
|
|
32
|
+
interactionId: id,
|
|
33
|
+
kind: "action",
|
|
34
|
+
inputs: [],
|
|
35
|
+
commit: { mode: "manual" },
|
|
36
|
+
available: true,
|
|
37
|
+
...overrides,
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
function createSnapshot(
|
|
42
|
+
session: PluginSessionState,
|
|
43
|
+
descriptors: InteractionDescriptor[],
|
|
44
|
+
): PluginStateSnapshot {
|
|
45
|
+
return {
|
|
46
|
+
view: null,
|
|
47
|
+
gameplay: {
|
|
48
|
+
currentPhase: "respond",
|
|
49
|
+
currentStage: null,
|
|
50
|
+
activePlayers: ["player-1"],
|
|
51
|
+
availableInteractions: descriptors,
|
|
52
|
+
zones: {},
|
|
53
|
+
},
|
|
54
|
+
lobby: null,
|
|
55
|
+
notifications: [],
|
|
56
|
+
session,
|
|
57
|
+
history: null,
|
|
58
|
+
syncId: 1,
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
function createRuntime(snapshot: PluginStateSnapshot): RuntimeAPI & {
|
|
63
|
+
getSnapshot: () => PluginStateSnapshot;
|
|
64
|
+
subscribeToState: (
|
|
65
|
+
listener: (state: PluginStateSnapshot) => void,
|
|
66
|
+
) => () => void;
|
|
67
|
+
} {
|
|
68
|
+
return {
|
|
69
|
+
validateInteraction: async () => ({ valid: true }),
|
|
70
|
+
submitInteraction: async () => undefined,
|
|
71
|
+
getSessionState: () => snapshot.session,
|
|
72
|
+
disconnect: () => undefined,
|
|
73
|
+
getSnapshot: () => snapshot,
|
|
74
|
+
subscribeToState: () => () => undefined,
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
function renderShell(snapshot: PluginStateSnapshot): string {
|
|
79
|
+
const runtime = createRuntime(snapshot);
|
|
80
|
+
return renderToString(
|
|
81
|
+
<RuntimeContext.Provider value={runtime}>
|
|
82
|
+
<PluginSessionContext.Provider value={snapshot.session}>
|
|
83
|
+
<InboxSurface />
|
|
84
|
+
</PluginSessionContext.Provider>
|
|
85
|
+
</RuntimeContext.Provider>,
|
|
86
|
+
);
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
test("InboxSurface renders prompt options as immediate response buttons", () => {
|
|
90
|
+
const session = createSessionState();
|
|
91
|
+
const snapshot = createSnapshot(session, [
|
|
92
|
+
createInboxDescriptor("respondToTrade", {
|
|
93
|
+
kind: "prompt",
|
|
94
|
+
inputs: [
|
|
95
|
+
{
|
|
96
|
+
key: "response",
|
|
97
|
+
kind: "form",
|
|
98
|
+
domain: {
|
|
99
|
+
type: "choice",
|
|
100
|
+
choices: [
|
|
101
|
+
{ value: "accept", label: "Accept" },
|
|
102
|
+
{ value: "decline", label: "Decline" },
|
|
103
|
+
],
|
|
104
|
+
},
|
|
105
|
+
},
|
|
106
|
+
],
|
|
107
|
+
context: {
|
|
108
|
+
to: "player-1",
|
|
109
|
+
title: "Trade offer",
|
|
110
|
+
options: [
|
|
111
|
+
{ id: "accept", label: "Accept" },
|
|
112
|
+
{ id: "decline", label: "Decline" },
|
|
113
|
+
],
|
|
114
|
+
},
|
|
115
|
+
}),
|
|
116
|
+
]);
|
|
117
|
+
|
|
118
|
+
const html = renderShell(snapshot);
|
|
119
|
+
|
|
120
|
+
expect(html).toContain('data-surface="inbox"');
|
|
121
|
+
expect(html).toContain("Trade offer");
|
|
122
|
+
expect(html).toContain('data-option-id="accept"');
|
|
123
|
+
expect(html).toContain('data-option-id="decline"');
|
|
124
|
+
});
|
|
125
|
+
|
|
126
|
+
test("InboxSurface does not infer action-kind form interactions as inbox items", () => {
|
|
127
|
+
const session = createSessionState();
|
|
128
|
+
const snapshot = createSnapshot(session, [
|
|
129
|
+
createInboxDescriptor("counterOffer", {
|
|
130
|
+
inputs: [
|
|
131
|
+
{
|
|
132
|
+
key: "give",
|
|
133
|
+
kind: "form",
|
|
134
|
+
domain: {
|
|
135
|
+
type: "resourceMap",
|
|
136
|
+
resources: [{ resourceId: "wood", label: "Wood", min: 0, max: 2 }],
|
|
137
|
+
},
|
|
138
|
+
},
|
|
139
|
+
],
|
|
140
|
+
}),
|
|
141
|
+
]);
|
|
142
|
+
|
|
143
|
+
const html = renderShell(snapshot);
|
|
144
|
+
|
|
145
|
+
expect(html).not.toContain("Counter Offer");
|
|
146
|
+
expect(html).not.toContain("data-default-interaction");
|
|
147
|
+
expect(html).not.toContain('aria-expanded="false"');
|
|
148
|
+
expect(html).not.toContain("Wood");
|
|
149
|
+
});
|