@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,149 @@
|
|
|
1
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { createContext, Fragment, useContext, useMemo, } from "react";
|
|
3
|
+
import { useActivePlayers } from "../hooks/useActivePlayers.js";
|
|
4
|
+
import { usePlayerInfo } from "../hooks/usePlayerInfo.js";
|
|
5
|
+
import { usePlayerTurnOrder } from "../hooks/usePlayerTurnOrder.js";
|
|
6
|
+
import { usePluginActions } from "../context/PluginStateContext.js";
|
|
7
|
+
import { usePluginSession } from "../context/PluginSessionContext.js";
|
|
8
|
+
import { composeEventHandlers, renderPrimitive, } from "./primitive-props.js";
|
|
9
|
+
const PlayerRosterContext = createContext(null);
|
|
10
|
+
function usePlayerRosterContext() {
|
|
11
|
+
const value = useContext(PlayerRosterContext);
|
|
12
|
+
if (!value) {
|
|
13
|
+
throw new Error("PlayerRoster primitives must be rendered inside <PlayerRoster.Root>.");
|
|
14
|
+
}
|
|
15
|
+
return value;
|
|
16
|
+
}
|
|
17
|
+
function projectBadges(badges, playerId) {
|
|
18
|
+
return (badges?.(playerId) ?? []).filter((badge) => Boolean(badge));
|
|
19
|
+
}
|
|
20
|
+
export function PlayerRosterRoot({ children, order = "turn", include = "all", score, scoreLabel, badges, metadata, }) {
|
|
21
|
+
const playerInfo = usePlayerInfo();
|
|
22
|
+
const activePlayers = useActivePlayers();
|
|
23
|
+
const turnOrder = usePlayerTurnOrder();
|
|
24
|
+
const { controllingPlayerId, controllablePlayerIds } = usePluginSession();
|
|
25
|
+
const players = useMemo(() => {
|
|
26
|
+
const orderedPlayerIds = order === "self-first" && controllingPlayerId
|
|
27
|
+
? [
|
|
28
|
+
...turnOrder.filter((pid) => pid === controllingPlayerId),
|
|
29
|
+
...turnOrder.filter((pid) => pid !== controllingPlayerId),
|
|
30
|
+
]
|
|
31
|
+
: turnOrder;
|
|
32
|
+
return orderedPlayerIds
|
|
33
|
+
.map((playerId, index) => {
|
|
34
|
+
const player = playerInfo.get(playerId);
|
|
35
|
+
const isCurrentPlayer = playerId === controllingPlayerId;
|
|
36
|
+
const isControllable = controllablePlayerIds.includes(playerId);
|
|
37
|
+
const resolvedScoreLabel = typeof scoreLabel === "function" ? scoreLabel(playerId) : scoreLabel;
|
|
38
|
+
return {
|
|
39
|
+
playerId,
|
|
40
|
+
name: player?.name ?? playerId,
|
|
41
|
+
color: player?.color,
|
|
42
|
+
index,
|
|
43
|
+
isActive: activePlayers.includes(playerId),
|
|
44
|
+
isCurrentPlayer,
|
|
45
|
+
isControllable,
|
|
46
|
+
canSwitchToPlayer: controllablePlayerIds.length > 1 &&
|
|
47
|
+
isControllable &&
|
|
48
|
+
!isCurrentPlayer,
|
|
49
|
+
score: score?.(playerId),
|
|
50
|
+
scoreLabel: resolvedScoreLabel,
|
|
51
|
+
badges: projectBadges(badges, playerId),
|
|
52
|
+
metadata: metadata?.(playerId),
|
|
53
|
+
};
|
|
54
|
+
})
|
|
55
|
+
.filter((player) => {
|
|
56
|
+
if (include === "self")
|
|
57
|
+
return player.isCurrentPlayer;
|
|
58
|
+
if (include === "opponents")
|
|
59
|
+
return !player.isCurrentPlayer;
|
|
60
|
+
return true;
|
|
61
|
+
});
|
|
62
|
+
}, [
|
|
63
|
+
activePlayers,
|
|
64
|
+
badges,
|
|
65
|
+
controllablePlayerIds,
|
|
66
|
+
controllingPlayerId,
|
|
67
|
+
include,
|
|
68
|
+
metadata,
|
|
69
|
+
order,
|
|
70
|
+
playerInfo,
|
|
71
|
+
score,
|
|
72
|
+
scoreLabel,
|
|
73
|
+
turnOrder,
|
|
74
|
+
]);
|
|
75
|
+
const value = useMemo(() => ({ players }), [players]);
|
|
76
|
+
return (_jsx(PlayerRosterContext.Provider, { value: value, children: children }));
|
|
77
|
+
}
|
|
78
|
+
export function PlayerRosterList({ children, ...props }) {
|
|
79
|
+
const { players } = usePlayerRosterContext();
|
|
80
|
+
return renderPrimitive("div", {
|
|
81
|
+
...props,
|
|
82
|
+
"data-dreamboard-player-roster-list": "",
|
|
83
|
+
children: players.map((player) => (_jsx(Fragment, { children: children ? children(player) : _jsx(PlayerRosterName, { player: player }) }, player.playerId))),
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
export function PlayerRosterEmpty({ children }) {
|
|
87
|
+
const { players } = usePlayerRosterContext();
|
|
88
|
+
if (players.length > 0)
|
|
89
|
+
return null;
|
|
90
|
+
return _jsx(_Fragment, { children: children });
|
|
91
|
+
}
|
|
92
|
+
export function PlayerRosterSwitchButton({ player, disabled, onClick, ...props }) {
|
|
93
|
+
const { switchPlayer } = usePluginActions();
|
|
94
|
+
const isDisabled = disabled === true || !player.canSwitchToPlayer;
|
|
95
|
+
return renderPrimitive("button", {
|
|
96
|
+
type: "button",
|
|
97
|
+
...props,
|
|
98
|
+
disabled: isDisabled,
|
|
99
|
+
"aria-current": player.isCurrentPlayer ? "true" : undefined,
|
|
100
|
+
"aria-disabled": isDisabled,
|
|
101
|
+
"data-dreamboard-player-roster-switch": "",
|
|
102
|
+
"data-player-id": player.playerId,
|
|
103
|
+
"data-active": player.isActive || undefined,
|
|
104
|
+
"data-current": player.isCurrentPlayer || undefined,
|
|
105
|
+
"data-controllable": player.isControllable || undefined,
|
|
106
|
+
"data-switchable": player.canSwitchToPlayer || undefined,
|
|
107
|
+
"data-disabled": isDisabled || undefined,
|
|
108
|
+
onClick: composeEventHandlers(onClick, () => {
|
|
109
|
+
if (!isDisabled)
|
|
110
|
+
switchPlayer(player.playerId);
|
|
111
|
+
}),
|
|
112
|
+
});
|
|
113
|
+
}
|
|
114
|
+
export function PlayerRosterName({ player, children, ...props }) {
|
|
115
|
+
return renderPrimitive("span", {
|
|
116
|
+
...props,
|
|
117
|
+
"data-dreamboard-player-roster-name": "",
|
|
118
|
+
children: children ?? player.name,
|
|
119
|
+
});
|
|
120
|
+
}
|
|
121
|
+
export function PlayerRosterScore({ player, children, ...props }) {
|
|
122
|
+
if (player.score === undefined && children === undefined)
|
|
123
|
+
return null;
|
|
124
|
+
const label = player.scoreLabel ? ` ${player.scoreLabel}` : "";
|
|
125
|
+
return renderPrimitive("span", {
|
|
126
|
+
...props,
|
|
127
|
+
"data-dreamboard-player-roster-score": "",
|
|
128
|
+
children: children ?? `${player.score}${label}`,
|
|
129
|
+
});
|
|
130
|
+
}
|
|
131
|
+
export function PlayerRosterBadges({ player, children, ...props }) {
|
|
132
|
+
if (player.badges.length === 0 && children === undefined)
|
|
133
|
+
return null;
|
|
134
|
+
return renderPrimitive("span", {
|
|
135
|
+
...props,
|
|
136
|
+
"data-dreamboard-player-roster-badges": "",
|
|
137
|
+
children: children ??
|
|
138
|
+
player.badges.map((badge) => (_jsxs("span", { "data-dreamboard-player-roster-badge": "", title: badge.tooltip, "aria-label": badge.tooltip, children: [badge.icon, badge.label] }, badge.key))),
|
|
139
|
+
});
|
|
140
|
+
}
|
|
141
|
+
export const PlayerRoster = {
|
|
142
|
+
Root: PlayerRosterRoot,
|
|
143
|
+
List: PlayerRosterList,
|
|
144
|
+
Empty: PlayerRosterEmpty,
|
|
145
|
+
SwitchButton: PlayerRosterSwitchButton,
|
|
146
|
+
Name: PlayerRosterName,
|
|
147
|
+
Score: PlayerRosterScore,
|
|
148
|
+
Badges: PlayerRosterBadges,
|
|
149
|
+
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { type AriaAttributes, type CSSProperties, type HTMLAttributes, type JSX, type ReactElement, type ReactNode } from "react";
|
|
2
|
+
export type PrimitiveDataAttributes = Record<`data-${string}`, string | boolean | number | undefined>;
|
|
3
|
+
export type PrimitiveCommonProps = {
|
|
4
|
+
asChild?: boolean;
|
|
5
|
+
children?: ReactNode;
|
|
6
|
+
className?: string;
|
|
7
|
+
style?: CSSProperties;
|
|
8
|
+
} & AriaAttributes & PrimitiveDataAttributes;
|
|
9
|
+
type EventHandler<Event> = (event: Event) => void;
|
|
10
|
+
export declare function composeEventHandlers<Event extends {
|
|
11
|
+
defaultPrevented: boolean;
|
|
12
|
+
}>(authorHandler: EventHandler<Event> | undefined, primitiveHandler: EventHandler<Event> | undefined): EventHandler<Event> | undefined;
|
|
13
|
+
export declare function renderPrimitive<ElementProps extends HTMLAttributes<HTMLElement>>(tagName: keyof JSX.IntrinsicElements, props: ElementProps & PrimitiveCommonProps): ReactElement;
|
|
14
|
+
export {};
|
|
15
|
+
//# sourceMappingURL=primitive-props.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"primitive-props.d.ts","sourceRoot":"","sources":["../../src/primitives/primitive-props.tsx"],"names":[],"mappings":"AAAA,OAAO,EAGL,KAAK,cAAc,EACnB,KAAK,aAAa,EAClB,KAAK,cAAc,EACnB,KAAK,GAAG,EAGR,KAAK,YAAY,EACjB,KAAK,SAAS,EACf,MAAM,OAAO,CAAC;AAEf,MAAM,MAAM,uBAAuB,GAAG,MAAM,CAC1C,QAAQ,MAAM,EAAE,EAChB,MAAM,GAAG,OAAO,GAAG,MAAM,GAAG,SAAS,CACtC,CAAC;AAEF,MAAM,MAAM,oBAAoB,GAAG;IACjC,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,QAAQ,CAAC,EAAE,SAAS,CAAC;IACrB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,KAAK,CAAC,EAAE,aAAa,CAAC;CACvB,GAAG,cAAc,GAChB,uBAAuB,CAAC;AAE1B,KAAK,YAAY,CAAC,KAAK,IAAI,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,CAAC;AAElD,wBAAgB,oBAAoB,CAClC,KAAK,SAAS;IAAE,gBAAgB,EAAE,OAAO,CAAA;CAAE,EAE3C,aAAa,EAAE,YAAY,CAAC,KAAK,CAAC,GAAG,SAAS,EAC9C,gBAAgB,EAAE,YAAY,CAAC,KAAK,CAAC,GAAG,SAAS,GAChD,YAAY,CAAC,KAAK,CAAC,GAAG,SAAS,CASjC;AAED,wBAAgB,eAAe,CAC7B,YAAY,SAAS,cAAc,CAAC,WAAW,CAAC,EAEhD,OAAO,EAAE,MAAM,GAAG,CAAC,iBAAiB,EACpC,KAAK,EAAE,YAAY,GAAG,oBAAoB,GACzC,YAAY,CAgCd"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { cloneElement, isValidElement, } from "react";
|
|
3
|
+
export function composeEventHandlers(authorHandler, primitiveHandler) {
|
|
4
|
+
if (!authorHandler)
|
|
5
|
+
return primitiveHandler;
|
|
6
|
+
if (!primitiveHandler)
|
|
7
|
+
return authorHandler;
|
|
8
|
+
return (event) => {
|
|
9
|
+
authorHandler(event);
|
|
10
|
+
if (!event.defaultPrevented) {
|
|
11
|
+
primitiveHandler(event);
|
|
12
|
+
}
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
export function renderPrimitive(tagName, props) {
|
|
16
|
+
const { asChild, children, ...primitiveProps } = props;
|
|
17
|
+
if (asChild) {
|
|
18
|
+
if (!isValidElement(children)) {
|
|
19
|
+
throw new Error("asChild requires exactly one valid React element child.");
|
|
20
|
+
}
|
|
21
|
+
const element = children;
|
|
22
|
+
const childProps = element.props;
|
|
23
|
+
return cloneElement(element, {
|
|
24
|
+
...primitiveProps,
|
|
25
|
+
...childProps,
|
|
26
|
+
className: [primitiveProps.className, childProps.className]
|
|
27
|
+
.filter(Boolean)
|
|
28
|
+
.join(" "),
|
|
29
|
+
style: {
|
|
30
|
+
...(primitiveProps.style ?? {}),
|
|
31
|
+
...(childProps.style ?? {}),
|
|
32
|
+
},
|
|
33
|
+
onClick: composeEventHandlers(childProps.onClick, primitiveProps.onClick),
|
|
34
|
+
onChange: composeEventHandlers(childProps.onChange, primitiveProps.onChange),
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
const Tag = tagName;
|
|
38
|
+
return _jsx(Tag, { ...primitiveProps, children: children });
|
|
39
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { type ButtonHTMLAttributes, type ReactNode } from "react";
|
|
2
|
+
import type { PromptKey, PromptOptionKey } from "../ui-contract.js";
|
|
3
|
+
import type { InteractionDescriptor } from "../types/plugin-state.js";
|
|
4
|
+
import { type InteractionPartProps, type InteractionRootProps } from "./interaction.js";
|
|
5
|
+
import { type PrimitiveCommonProps } from "./primitive-props.js";
|
|
6
|
+
export type PromptRootProps<Prompt extends string = PromptKey> = InteractionRootProps<Prompt>;
|
|
7
|
+
export declare function PromptRoot<Prompt extends string = PromptKey>(props: PromptRootProps<Prompt>): import("react/jsx-runtime").JSX.Element;
|
|
8
|
+
export declare function PromptTitle(props: InteractionPartProps): import("react/jsx-runtime").JSX.Element;
|
|
9
|
+
export declare function PromptMessage(props: InteractionPartProps): import("react/jsx-runtime").JSX.Element | null;
|
|
10
|
+
export type PromptOptionProps<Option extends string = PromptOptionKey> = PrimitiveCommonProps & ButtonHTMLAttributes<HTMLButtonElement> & {
|
|
11
|
+
value: Option;
|
|
12
|
+
disableWhenUnavailable?: boolean;
|
|
13
|
+
onSubmitError?: (error: unknown) => void;
|
|
14
|
+
onSubmitSuccess?: () => void;
|
|
15
|
+
};
|
|
16
|
+
export declare function PromptOption<Option extends string = PromptOptionKey>({ value, disabled, disableWhenUnavailable, onClick, onSubmitError, onSubmitSuccess, children, ...props }: PromptOptionProps<Option>): import("react").ReactElement<unknown, string | import("react").JSXElementConstructor<any>>;
|
|
17
|
+
export declare function PromptOptions({ children, }: {
|
|
18
|
+
children?: (option: {
|
|
19
|
+
id: string;
|
|
20
|
+
label?: string;
|
|
21
|
+
}) => ReactNode;
|
|
22
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
23
|
+
export declare function PromptInboxRoot({ children }: {
|
|
24
|
+
children: ReactNode;
|
|
25
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
26
|
+
export declare function PromptInboxEmpty({ children }: {
|
|
27
|
+
children?: ReactNode;
|
|
28
|
+
}): import("react/jsx-runtime").JSX.Element | null;
|
|
29
|
+
export declare function PromptInboxItems({ children, }: {
|
|
30
|
+
children?: (prompt: InteractionDescriptor) => ReactNode;
|
|
31
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
32
|
+
export declare const Prompt: {
|
|
33
|
+
Root: typeof PromptRoot;
|
|
34
|
+
Title: typeof PromptTitle;
|
|
35
|
+
Message: typeof PromptMessage;
|
|
36
|
+
Option: typeof PromptOption;
|
|
37
|
+
Options: typeof PromptOptions;
|
|
38
|
+
};
|
|
39
|
+
export declare const PromptInbox: {
|
|
40
|
+
Root: typeof PromptInboxRoot;
|
|
41
|
+
Empty: typeof PromptInboxEmpty;
|
|
42
|
+
Items: typeof PromptInboxItems;
|
|
43
|
+
};
|
|
44
|
+
//# sourceMappingURL=prompt.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prompt.d.ts","sourceRoot":"","sources":["../../src/primitives/prompt.tsx"],"names":[],"mappings":"AAAA,OAAO,EAGL,KAAK,oBAAoB,EACzB,KAAK,SAAS,EACf,MAAM,OAAO,CAAC;AAEf,OAAO,KAAK,EAAE,SAAS,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpE,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,0BAA0B,CAAC;AAGtE,OAAO,EAKL,KAAK,oBAAoB,EACzB,KAAK,oBAAoB,EAC1B,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAGL,KAAK,oBAAoB,EAC1B,MAAM,sBAAsB,CAAC;AAE9B,MAAM,MAAM,eAAe,CAAC,MAAM,SAAS,MAAM,GAAG,SAAS,IAC3D,oBAAoB,CAAC,MAAM,CAAC,CAAC;AAE/B,wBAAgB,UAAU,CAAC,MAAM,SAAS,MAAM,GAAG,SAAS,EAC1D,KAAK,EAAE,eAAe,CAAC,MAAM,CAAC,2CAG/B;AAED,wBAAgB,WAAW,CAAC,KAAK,EAAE,oBAAoB,2CAStD;AAED,wBAAgB,aAAa,CAAC,KAAK,EAAE,oBAAoB,kDASxD;AAED,MAAM,MAAM,iBAAiB,CAAC,MAAM,SAAS,MAAM,GAAG,eAAe,IACnE,oBAAoB,GAClB,oBAAoB,CAAC,iBAAiB,CAAC,GAAG;IACxC,KAAK,EAAE,MAAM,CAAC;IACd,sBAAsB,CAAC,EAAE,OAAO,CAAC;IACjC,aAAa,CAAC,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,IAAI,CAAC;IACzC,eAAe,CAAC,EAAE,MAAM,IAAI,CAAC;CAC9B,CAAC;AAEN,wBAAgB,YAAY,CAAC,MAAM,SAAS,MAAM,GAAG,eAAe,EAAE,EACpE,KAAK,EACL,QAAQ,EACR,sBAA8B,EAC9B,OAAO,EACP,aAAa,EACb,eAAe,EACf,QAAQ,EACR,GAAG,KAAK,EACT,EAAE,iBAAiB,CAAC,MAAM,CAAC,8FAqC3B;AAED,wBAAgB,aAAa,CAAC,EAC5B,QAAQ,GACT,EAAE;IACD,QAAQ,CAAC,EAAE,CAAC,MAAM,EAAE;QAAE,EAAE,EAAE,MAAM,CAAC;QAAC,KAAK,CAAC,EAAE,MAAM,CAAA;KAAE,KAAK,SAAS,CAAC;CAClE,2CAcA;AAkBD,wBAAgB,eAAe,CAAC,EAAE,QAAQ,EAAE,EAAE;IAAE,QAAQ,EAAE,SAAS,CAAA;CAAE,2CAOpE;AAED,wBAAgB,gBAAgB,CAAC,EAAE,QAAQ,EAAE,EAAE;IAAE,QAAQ,CAAC,EAAE,SAAS,CAAA;CAAE,kDAItE;AAED,wBAAgB,gBAAgB,CAAC,EAC/B,QAAQ,GACT,EAAE;IACD,QAAQ,CAAC,EAAE,CAAC,MAAM,EAAE,qBAAqB,KAAK,SAAS,CAAC;CACzD,2CAoBA;AAED,eAAO,MAAM,MAAM;;;;;;CAMlB,CAAC;AAEF,eAAO,MAAM,WAAW;;;;CAIvB,CAAC"}
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { createContext, useContext, } from "react";
|
|
3
|
+
import { useSeatInbox } from "../hooks/useSeatInbox.js";
|
|
4
|
+
import { interactionInputKeys } from "../utils/interaction-inputs.js";
|
|
5
|
+
import { interactionLabel } from "../utils/interaction-labels.js";
|
|
6
|
+
import { InteractionDescription, InteractionLabel, InteractionRoot, useInteractionPrimitiveContext, } from "./interaction.js";
|
|
7
|
+
import { composeEventHandlers, renderPrimitive, } from "./primitive-props.js";
|
|
8
|
+
export function PromptRoot(props) {
|
|
9
|
+
return _jsx(InteractionRoot, { ...props });
|
|
10
|
+
}
|
|
11
|
+
export function PromptTitle(props) {
|
|
12
|
+
const { descriptor } = useInteractionPrimitiveContext();
|
|
13
|
+
return (_jsx(InteractionLabel, { ...props, children: props.children ??
|
|
14
|
+
descriptor?.context?.title ??
|
|
15
|
+
(descriptor ? interactionLabel(descriptor) : undefined) }));
|
|
16
|
+
}
|
|
17
|
+
export function PromptMessage(props) {
|
|
18
|
+
const { descriptor } = useInteractionPrimitiveContext();
|
|
19
|
+
const message = props.children ??
|
|
20
|
+
(typeof descriptor?.context?.payload?.message === "string"
|
|
21
|
+
? descriptor.context.payload.message
|
|
22
|
+
: undefined);
|
|
23
|
+
if (!message)
|
|
24
|
+
return null;
|
|
25
|
+
return _jsx(InteractionDescription, { ...props, children: message });
|
|
26
|
+
}
|
|
27
|
+
export function PromptOption({ value, disabled, disableWhenUnavailable = false, onClick, onSubmitError, onSubmitSuccess, children, ...props }) {
|
|
28
|
+
const { descriptor, handle } = useInteractionPrimitiveContext();
|
|
29
|
+
const option = descriptor?.context?.options?.find((candidate) => candidate.id === value);
|
|
30
|
+
const inputKey = descriptor ? interactionInputKeys(descriptor)[0] : undefined;
|
|
31
|
+
const isDisabled = disabled ??
|
|
32
|
+
(!handle ||
|
|
33
|
+
!inputKey ||
|
|
34
|
+
handle.status !== "open" ||
|
|
35
|
+
option?.data === false ||
|
|
36
|
+
(disableWhenUnavailable && !descriptor?.available));
|
|
37
|
+
return renderPrimitive("button", {
|
|
38
|
+
type: "button",
|
|
39
|
+
...props,
|
|
40
|
+
disabled: isDisabled,
|
|
41
|
+
"aria-disabled": isDisabled,
|
|
42
|
+
"data-dreamboard-prompt-option": "",
|
|
43
|
+
"data-option-value": value,
|
|
44
|
+
"data-disabled": isDisabled || undefined,
|
|
45
|
+
"data-available": descriptor?.available ?? false,
|
|
46
|
+
onClick: composeEventHandlers(onClick, () => {
|
|
47
|
+
if (!handle || !inputKey || isDisabled)
|
|
48
|
+
return;
|
|
49
|
+
void handle
|
|
50
|
+
.submit({ [inputKey]: value })
|
|
51
|
+
.then(() => onSubmitSuccess?.())
|
|
52
|
+
.catch((error) => {
|
|
53
|
+
if (onSubmitError) {
|
|
54
|
+
onSubmitError(error);
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
57
|
+
console.error(error);
|
|
58
|
+
});
|
|
59
|
+
}),
|
|
60
|
+
children: children ?? option?.label ?? value,
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
export function PromptOptions({ children, }) {
|
|
64
|
+
const { descriptor } = useInteractionPrimitiveContext();
|
|
65
|
+
const options = descriptor?.context?.options ?? [];
|
|
66
|
+
return (_jsx(_Fragment, { children: options.map((option) => children ? (children(option)) : (_jsx(PromptOption, { value: option.id }, option.id))) }));
|
|
67
|
+
}
|
|
68
|
+
const PromptInboxContext = createContext(null);
|
|
69
|
+
function usePromptInboxContext() {
|
|
70
|
+
const value = useContext(PromptInboxContext);
|
|
71
|
+
if (!value) {
|
|
72
|
+
throw new Error("PromptInbox primitives must be rendered inside <PromptInbox.Root>.");
|
|
73
|
+
}
|
|
74
|
+
return value;
|
|
75
|
+
}
|
|
76
|
+
export function PromptInboxRoot({ children }) {
|
|
77
|
+
const inbox = useSeatInbox();
|
|
78
|
+
return (_jsx(PromptInboxContext.Provider, { value: { prompts: inbox.prompts }, children: children }));
|
|
79
|
+
}
|
|
80
|
+
export function PromptInboxEmpty({ children }) {
|
|
81
|
+
const { prompts } = usePromptInboxContext();
|
|
82
|
+
if (prompts.length > 0)
|
|
83
|
+
return null;
|
|
84
|
+
return _jsx(_Fragment, { children: children });
|
|
85
|
+
}
|
|
86
|
+
export function PromptInboxItems({ children, }) {
|
|
87
|
+
const { prompts } = usePromptInboxContext();
|
|
88
|
+
return (_jsx(_Fragment, { children: prompts.map((prompt) => children ? (children(prompt)) : (_jsxs(PromptRoot, { interaction: prompt.interactionKey, children: [_jsx(PromptTitle, {}), _jsx(PromptMessage, {}), _jsx(PromptOptions, {})] }, prompt.interactionKey))) }));
|
|
89
|
+
}
|
|
90
|
+
export const Prompt = {
|
|
91
|
+
Root: PromptRoot,
|
|
92
|
+
Title: PromptTitle,
|
|
93
|
+
Message: PromptMessage,
|
|
94
|
+
Option: PromptOption,
|
|
95
|
+
Options: PromptOptions,
|
|
96
|
+
};
|
|
97
|
+
export const PromptInbox = {
|
|
98
|
+
Root: PromptInboxRoot,
|
|
99
|
+
Empty: PromptInboxEmpty,
|
|
100
|
+
Items: PromptInboxItems,
|
|
101
|
+
};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { type HTMLAttributes } from "react";
|
|
2
|
+
import type { ZoneHandlesSnapshot } from "../types/plugin-state.js";
|
|
3
|
+
import type { ZoneKey } from "../ui-contract.js";
|
|
4
|
+
import { type PrimitiveCommonProps } from "./primitive-props.js";
|
|
5
|
+
interface ZoneContextValue {
|
|
6
|
+
zone: string;
|
|
7
|
+
snapshot: ZoneHandlesSnapshot | null;
|
|
8
|
+
}
|
|
9
|
+
interface ZoneCardContextValue {
|
|
10
|
+
zone: string;
|
|
11
|
+
cardId: string;
|
|
12
|
+
}
|
|
13
|
+
export declare function useZonePrimitiveContext(): ZoneContextValue;
|
|
14
|
+
export declare function useZoneCardContext(): ZoneCardContextValue | null;
|
|
15
|
+
export interface ZoneRootProps<Zone extends string = ZoneKey> extends PrimitiveCommonProps, HTMLAttributes<HTMLElement> {
|
|
16
|
+
zone: Zone;
|
|
17
|
+
}
|
|
18
|
+
export declare function ZoneRoot<Zone extends string = ZoneKey>({ zone, children, ...props }: ZoneRootProps<Zone>): import("react/jsx-runtime").JSX.Element;
|
|
19
|
+
export type ZoneListProps = PrimitiveCommonProps & HTMLAttributes<HTMLElement>;
|
|
20
|
+
export declare function ZoneList({ children, ...props }: ZoneListProps): import("react").ReactElement<unknown, string | import("react").JSXElementConstructor<any>>;
|
|
21
|
+
export interface ZoneItemProps extends PrimitiveCommonProps, HTMLAttributes<HTMLElement> {
|
|
22
|
+
card: string;
|
|
23
|
+
}
|
|
24
|
+
export declare function ZoneItem({ card, children, ...props }: ZoneItemProps): import("react/jsx-runtime").JSX.Element;
|
|
25
|
+
export declare const Zone: {
|
|
26
|
+
Root: typeof ZoneRoot;
|
|
27
|
+
List: typeof ZoneList;
|
|
28
|
+
Item: typeof ZoneItem;
|
|
29
|
+
};
|
|
30
|
+
export {};
|
|
31
|
+
//# sourceMappingURL=zone.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"zone.d.ts","sourceRoot":"","sources":["../../src/primitives/zone.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAsC,KAAK,cAAc,EAAE,MAAM,OAAO,CAAC;AAEhF,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AACpE,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AACjD,OAAO,EAEL,KAAK,oBAAoB,EAC1B,MAAM,sBAAsB,CAAC;AAE9B,UAAU,gBAAgB;IACxB,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,mBAAmB,GAAG,IAAI,CAAC;CACtC;AAED,UAAU,oBAAoB;IAC5B,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;CAChB;AAKD,wBAAgB,uBAAuB,IAAI,gBAAgB,CAM1D;AAED,wBAAgB,kBAAkB,IAAI,oBAAoB,GAAG,IAAI,CAEhE;AAED,MAAM,WAAW,aAAa,CAAC,IAAI,SAAS,MAAM,GAAG,OAAO,CAC1D,SAAQ,oBAAoB,EAC1B,cAAc,CAAC,WAAW,CAAC;IAC7B,IAAI,EAAE,IAAI,CAAC;CACZ;AAED,wBAAgB,QAAQ,CAAC,IAAI,SAAS,MAAM,GAAG,OAAO,EAAE,EACtD,IAAI,EACJ,QAAQ,EACR,GAAG,KAAK,EACT,EAAE,aAAa,CAAC,IAAI,CAAC,2CAkBrB;AAED,MAAM,MAAM,aAAa,GAAG,oBAAoB,GAAG,cAAc,CAAC,WAAW,CAAC,CAAC;AAE/E,wBAAgB,QAAQ,CAAC,EAAE,QAAQ,EAAE,GAAG,KAAK,EAAE,EAAE,aAAa,8FAW7D;AAED,MAAM,WAAW,aACf,SAAQ,oBAAoB,EAC1B,cAAc,CAAC,WAAW,CAAC;IAC7B,IAAI,EAAE,MAAM,CAAC;CACd;AAED,wBAAgB,QAAQ,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,GAAG,KAAK,EAAE,EAAE,aAAa,2CAqBnE;AAED,eAAO,MAAM,IAAI;;;;CAIhB,CAAC"}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { createContext, useContext, useMemo } from "react";
|
|
3
|
+
import { usePluginState } from "../context/PluginStateContext.js";
|
|
4
|
+
import { renderPrimitive, } from "./primitive-props.js";
|
|
5
|
+
const ZoneContext = createContext(null);
|
|
6
|
+
const ZoneCardContext = createContext(null);
|
|
7
|
+
export function useZonePrimitiveContext() {
|
|
8
|
+
const value = useContext(ZoneContext);
|
|
9
|
+
if (!value) {
|
|
10
|
+
throw new Error("Zone primitives must be rendered inside <Zone.Root>.");
|
|
11
|
+
}
|
|
12
|
+
return value;
|
|
13
|
+
}
|
|
14
|
+
export function useZoneCardContext() {
|
|
15
|
+
return useContext(ZoneCardContext);
|
|
16
|
+
}
|
|
17
|
+
export function ZoneRoot({ zone, children, ...props }) {
|
|
18
|
+
const snapshot = usePluginState((state) => state.gameplay.zones[zone]) ?? null;
|
|
19
|
+
const value = useMemo(() => ({ zone, snapshot }), [snapshot, zone]);
|
|
20
|
+
return (_jsx(ZoneContext.Provider, { value: value, children: renderPrimitive("div", {
|
|
21
|
+
...props,
|
|
22
|
+
"data-dreamboard-zone-root": "",
|
|
23
|
+
"data-zone": zone,
|
|
24
|
+
"data-card-count": snapshot?.cardIds.length ?? 0,
|
|
25
|
+
children,
|
|
26
|
+
}) }));
|
|
27
|
+
}
|
|
28
|
+
export function ZoneList({ children, ...props }) {
|
|
29
|
+
const { zone, snapshot } = useZonePrimitiveContext();
|
|
30
|
+
const isEmpty = (snapshot?.cardIds.length ?? 0) === 0;
|
|
31
|
+
return renderPrimitive("div", {
|
|
32
|
+
...props,
|
|
33
|
+
role: props.role ?? "list",
|
|
34
|
+
"data-dreamboard-zone-list": "",
|
|
35
|
+
"data-zone": zone,
|
|
36
|
+
"data-empty": isEmpty || undefined,
|
|
37
|
+
children,
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
export function ZoneItem({ card, children, ...props }) {
|
|
41
|
+
const { zone, snapshot } = useZonePrimitiveContext();
|
|
42
|
+
const playable = snapshot?.playableByCardId[card] ?? [];
|
|
43
|
+
const cardContext = useMemo(() => ({ zone, cardId: card }), [card, zone]);
|
|
44
|
+
return (_jsx(ZoneCardContext.Provider, { value: cardContext, children: renderPrimitive("div", {
|
|
45
|
+
...props,
|
|
46
|
+
role: props.role ?? "listitem",
|
|
47
|
+
"data-dreamboard-zone-item": "",
|
|
48
|
+
"data-zone": zone,
|
|
49
|
+
"data-card-id": card,
|
|
50
|
+
"data-playable": playable.some((descriptor) => descriptor.available) || undefined,
|
|
51
|
+
children,
|
|
52
|
+
}) }));
|
|
53
|
+
}
|
|
54
|
+
export const Zone = {
|
|
55
|
+
Root: ZoneRoot,
|
|
56
|
+
List: ZoneList,
|
|
57
|
+
Item: ZoneItem,
|
|
58
|
+
};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export { useActivePlayers } from "./hooks/useActivePlayers.js";
|
|
2
|
+
export { useSimultaneousPhase } from "./hooks/useSimultaneousPhase.js";
|
|
3
|
+
export { usePlayerTurnOrder } from "./hooks/usePlayerTurnOrder.js";
|
|
4
|
+
export { useGameSelector } from "./hooks/useGameSelector.js";
|
|
5
|
+
export { useIsMyTurn } from "./hooks/useIsMyTurn.js";
|
|
6
|
+
export { useCards } from "./hooks/useCards.js";
|
|
7
|
+
export { useGameView } from "./hooks/useGameView.js";
|
|
8
|
+
export { useLobby } from "./hooks/useLobby.js";
|
|
9
|
+
export { useMe } from "./hooks/useMe.js";
|
|
10
|
+
export { usePlayerInfo } from "./hooks/usePlayerInfo.js";
|
|
11
|
+
export { useSeatInbox, type SeatInbox } from "./hooks/useSeatInbox.js";
|
|
12
|
+
export { useInteractionHandle, type InteractionHandle, type InteractionHandleStatus, type DraftValidation, type InteractionParamsShape, } from "./hooks/useInteractionHandle.js";
|
|
13
|
+
export { useInteractionByKey } from "./hooks/useInteractionByKey.js";
|
|
14
|
+
export { usePluginSession } from "./context/PluginSessionContext.js";
|
|
15
|
+
export { type ClientParamSchema, type ClientParamSchemaMap, } from "./context/ClientParamSchemaContext.js";
|
|
16
|
+
export type { GameplayPromptOption, GameplaySnapshot, PluginStateSnapshot, } from "./types/reducer-state.js";
|
|
17
|
+
export type { InteractionDescriptor, InteractionContext, InteractionContextOption, } from "./types/plugin-state.js";
|
|
18
|
+
export type { LobbyState } from "./hooks/useLobby.js";
|
|
19
|
+
export type { Player } from "./hooks/useMe.js";
|
|
20
|
+
export type { CardCollection, ViewCard, ViewSlotOccupant, } from "@dreamboard/sdk-types";
|
|
21
|
+
//# sourceMappingURL=reducer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"reducer.d.ts","sourceRoot":"","sources":["../src/reducer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAC;AAC/D,OAAO,EAAE,oBAAoB,EAAE,MAAM,iCAAiC,CAAC;AACvE,OAAO,EAAE,kBAAkB,EAAE,MAAM,+BAA+B,CAAC;AACnE,OAAO,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAC7D,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AACrD,OAAO,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAC/C,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AACrD,OAAO,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAC/C,OAAO,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AACzC,OAAO,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AACzD,OAAO,EAAE,YAAY,EAAE,KAAK,SAAS,EAAE,MAAM,yBAAyB,CAAC;AACvE,OAAO,EACL,oBAAoB,EACpB,KAAK,iBAAiB,EACtB,KAAK,uBAAuB,EAC5B,KAAK,eAAe,EACpB,KAAK,sBAAsB,GAC5B,MAAM,iCAAiC,CAAC;AACzC,OAAO,EAAE,mBAAmB,EAAE,MAAM,gCAAgC,CAAC;AACrE,OAAO,EAAE,gBAAgB,EAAE,MAAM,mCAAmC,CAAC;AACrE,OAAO,EACL,KAAK,iBAAiB,EACtB,KAAK,oBAAoB,GAC1B,MAAM,uCAAuC,CAAC;AAE/C,YAAY,EACV,oBAAoB,EACpB,gBAAgB,EAChB,mBAAmB,GACpB,MAAM,0BAA0B,CAAC;AAClC,YAAY,EACV,qBAAqB,EACrB,kBAAkB,EAClB,wBAAwB,GACzB,MAAM,yBAAyB,CAAC;AACjC,YAAY,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AACtD,YAAY,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAC/C,YAAY,EACV,cAAc,EACd,QAAQ,EACR,gBAAgB,GACjB,MAAM,uBAAuB,CAAC"}
|
package/dist/reducer.js
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export { useActivePlayers } from "./hooks/useActivePlayers.js";
|
|
2
|
+
export { useSimultaneousPhase } from "./hooks/useSimultaneousPhase.js";
|
|
3
|
+
export { usePlayerTurnOrder } from "./hooks/usePlayerTurnOrder.js";
|
|
4
|
+
export { useGameSelector } from "./hooks/useGameSelector.js";
|
|
5
|
+
export { useIsMyTurn } from "./hooks/useIsMyTurn.js";
|
|
6
|
+
export { useCards } from "./hooks/useCards.js";
|
|
7
|
+
export { useGameView } from "./hooks/useGameView.js";
|
|
8
|
+
export { useLobby } from "./hooks/useLobby.js";
|
|
9
|
+
export { useMe } from "./hooks/useMe.js";
|
|
10
|
+
export { usePlayerInfo } from "./hooks/usePlayerInfo.js";
|
|
11
|
+
export { useSeatInbox } from "./hooks/useSeatInbox.js";
|
|
12
|
+
export { useInteractionHandle, } from "./hooks/useInteractionHandle.js";
|
|
13
|
+
export { useInteractionByKey } from "./hooks/useInteractionByKey.js";
|
|
14
|
+
export { usePluginSession } from "./context/PluginSessionContext.js";
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import type { RuntimeAPI, PluginSessionState } from "../types/runtime-api.js";
|
|
2
|
+
import type { PluginStateSnapshot } from "../types/plugin-state.js";
|
|
3
|
+
/**
|
|
4
|
+
* Extended RuntimeAPI with plugin-specific methods for state-sync architecture.
|
|
5
|
+
*/
|
|
6
|
+
export interface PluginRuntimeAPI extends RuntimeAPI {
|
|
7
|
+
/**
|
|
8
|
+
* Get the current state snapshot.
|
|
9
|
+
* Returns null if no state-sync has been received yet.
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* ```typescript
|
|
13
|
+
* const snapshot = runtime.getSnapshot();
|
|
14
|
+
* if (snapshot?.view) {
|
|
15
|
+
* console.log('Current view:', snapshot.view);
|
|
16
|
+
* }
|
|
17
|
+
* ```
|
|
18
|
+
*/
|
|
19
|
+
getSnapshot: () => PluginStateSnapshot | null;
|
|
20
|
+
/**
|
|
21
|
+
* Subscribe to state changes from state-sync messages.
|
|
22
|
+
* Called whenever the host sends a new state-sync.
|
|
23
|
+
*
|
|
24
|
+
* @param listener - Callback invoked with new state snapshot
|
|
25
|
+
* @returns Unsubscribe function
|
|
26
|
+
*
|
|
27
|
+
* @example
|
|
28
|
+
* ```typescript
|
|
29
|
+
* const unsubscribe = runtime.subscribeToState((state) => {
|
|
30
|
+
* console.log('New phase:', state.gameplay.currentPhase);
|
|
31
|
+
* });
|
|
32
|
+
* ```
|
|
33
|
+
*/
|
|
34
|
+
subscribeToState: (listener: (state: PluginStateSnapshot) => void) => () => void;
|
|
35
|
+
/** Internal API for RuntimeContext to subscribe to session state changes */
|
|
36
|
+
_subscribeToSessionState: (listener: (state: PluginSessionState) => void) => () => void;
|
|
37
|
+
/**
|
|
38
|
+
* Request to restore game state to a previous history entry.
|
|
39
|
+
* Only works if the user is the host.
|
|
40
|
+
*
|
|
41
|
+
* @param entryId - ID of the history entry to restore to
|
|
42
|
+
*
|
|
43
|
+
* @example
|
|
44
|
+
* ```typescript
|
|
45
|
+
* // Restore to a previous state
|
|
46
|
+
* runtime.restoreHistory?.('entry-abc-123');
|
|
47
|
+
* ```
|
|
48
|
+
*/
|
|
49
|
+
restoreHistory?: (entryId: string) => void;
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Creates a RuntimeAPI implementation for plugin iframes.
|
|
53
|
+
*
|
|
54
|
+
* Architecture (state-sync):
|
|
55
|
+
* - Host maintains all state in GameSessionStore
|
|
56
|
+
* - Host sends complete state snapshots via state-sync messages
|
|
57
|
+
* - Plugin stores received state and notifies subscribers
|
|
58
|
+
* - No buffering needed - plugin only renders when state exists
|
|
59
|
+
*
|
|
60
|
+
* Security:
|
|
61
|
+
* - Plugin runs in sandboxed iframe (no network access, no same-origin)
|
|
62
|
+
* - All backend communication goes through main app
|
|
63
|
+
*
|
|
64
|
+
* @returns PluginRuntimeAPI instance
|
|
65
|
+
*/
|
|
66
|
+
export declare function createPluginRuntimeAPI(): PluginRuntimeAPI;
|
|
67
|
+
//# sourceMappingURL=createPluginRuntimeAPI.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createPluginRuntimeAPI.d.ts","sourceRoot":"","sources":["../../src/runtime/createPluginRuntimeAPI.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,UAAU,EACV,kBAAkB,EAEnB,MAAM,yBAAyB,CAAC;AACjC,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AA+DpE;;GAEG;AACH,MAAM,WAAW,gBAAiB,SAAQ,UAAU;IAClD;;;;;;;;;;;OAWG;IACH,WAAW,EAAE,MAAM,mBAAmB,GAAG,IAAI,CAAC;IAE9C;;;;;;;;;;;;;OAaG;IACH,gBAAgB,EAAE,CAChB,QAAQ,EAAE,CAAC,KAAK,EAAE,mBAAmB,KAAK,IAAI,KAC3C,MAAM,IAAI,CAAC;IAEhB,4EAA4E;IAC5E,wBAAwB,EAAE,CACxB,QAAQ,EAAE,CAAC,KAAK,EAAE,kBAAkB,KAAK,IAAI,KAC1C,MAAM,IAAI,CAAC;IAEhB;;;;;;;;;;;OAWG;IACH,cAAc,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,CAAC;CAC5C;AAkCD;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,sBAAsB,IAAI,gBAAgB,CA+azD"}
|