@dreamboard-games/sdk 0.2.0
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.md +96 -0
- package/README.md +12 -0
- package/dist/HandView-ncJIVLhN.d.ts +193 -0
- package/dist/ResourceCounter-CTREyF73.d.ts +102 -0
- package/dist/ThemeProvider-fy0_QzgO.d.ts +99 -0
- package/dist/bundle-TIZcw8LB.d.ts +281 -0
- package/dist/cards-Sl3b40Mv.d.ts +13 -0
- package/dist/chunk-7YAHLYBR.js +481 -0
- package/dist/chunk-7YAHLYBR.js.map +1 -0
- package/dist/chunk-FDNZTDD6.js +8085 -0
- package/dist/chunk-FDNZTDD6.js.map +1 -0
- package/dist/chunk-GKKBPPSW.js +598 -0
- package/dist/chunk-GKKBPPSW.js.map +1 -0
- package/dist/chunk-I46YJSOD.js +1 -0
- package/dist/chunk-I46YJSOD.js.map +1 -0
- package/dist/chunk-KAELH4KC.js +104 -0
- package/dist/chunk-KAELH4KC.js.map +1 -0
- package/dist/chunk-PZ5AY32C.js +10 -0
- package/dist/chunk-PZ5AY32C.js.map +1 -0
- package/dist/chunk-T3ZKNUZ7.js +1 -0
- package/dist/chunk-T3ZKNUZ7.js.map +1 -0
- package/dist/chunk-T52J5RMF.js +1 -0
- package/dist/chunk-T52J5RMF.js.map +1 -0
- package/dist/chunk-TDSWKVZ4.js +5401 -0
- package/dist/chunk-TDSWKVZ4.js.map +1 -0
- package/dist/chunk-U5C6BONG.js +34 -0
- package/dist/chunk-U5C6BONG.js.map +1 -0
- package/dist/chunk-VDXOF4FW.js +69 -0
- package/dist/chunk-VDXOF4FW.js.map +1 -0
- package/dist/chunk-VFTAA4WO.js +115 -0
- package/dist/chunk-VFTAA4WO.js.map +1 -0
- package/dist/chunk-WN74KVNY.js +17 -0
- package/dist/chunk-WN74KVNY.js.map +1 -0
- package/dist/chunk-WYPQ3GG5.js +10990 -0
- package/dist/chunk-WYPQ3GG5.js.map +1 -0
- package/dist/components-D5ZRE2Hl.d.ts +1451 -0
- package/dist/generated/runtime/primitives.d.ts +12 -0
- package/dist/generated/runtime/primitives.js +180 -0
- package/dist/generated/runtime/primitives.js.map +1 -0
- package/dist/generated/runtime-api.d.ts +3 -0
- package/dist/generated/runtime-api.js +2 -0
- package/dist/generated/runtime-api.js.map +1 -0
- package/dist/generated/runtime.d.ts +14 -0
- package/dist/generated/runtime.js +18 -0
- package/dist/generated/runtime.js.map +1 -0
- package/dist/generated/workspace-contract.d.ts +14 -0
- package/dist/generated/workspace-contract.js +14 -0
- package/dist/generated/workspace-contract.js.map +1 -0
- package/dist/hex-board-view-D_07hO6O.d.ts +933 -0
- package/dist/hex-color-MhOyuY-o.d.ts +8 -0
- package/dist/index-BwqPQtBu.d.ts +1433 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +12 -0
- package/dist/index.js.map +1 -0
- package/dist/infrastructure/reducer-bundle-abi.d.ts +1083 -0
- package/dist/infrastructure/reducer-bundle-abi.js +14 -0
- package/dist/infrastructure/reducer-bundle-abi.js.map +1 -0
- package/dist/infrastructure/workspace-codegen.d.ts +53 -0
- package/dist/infrastructure/workspace-codegen.js +44 -0
- package/dist/infrastructure/workspace-codegen.js.map +1 -0
- package/dist/manifest-contract-BNHVGFtU.d.ts +9 -0
- package/dist/package-set.d.ts +13 -0
- package/dist/package-set.js +12 -0
- package/dist/package-set.js.map +1 -0
- package/dist/primitive-props-DpKs-GCr.d.ts +11 -0
- package/dist/reducer.d.ts +3786 -0
- package/dist/reducer.js +8131 -0
- package/dist/reducer.js.map +1 -0
- package/dist/runtime/primitives.d.ts +226 -0
- package/dist/runtime/primitives.js +180 -0
- package/dist/runtime/primitives.js.map +1 -0
- package/dist/runtime/types/runtime-api.d.ts +1 -0
- package/dist/runtime/types/runtime-api.js +2 -0
- package/dist/runtime/types/runtime-api.js.map +1 -0
- package/dist/runtime/workspace-contract.d.ts +172 -0
- package/dist/runtime/workspace-contract.js +14 -0
- package/dist/runtime/workspace-contract.js.map +1 -0
- package/dist/runtime-api-3dshj6kK.d.ts +101 -0
- package/dist/runtime-api-DWxvTr-O.d.ts +379 -0
- package/dist/runtime.d.ts +58 -0
- package/dist/runtime.js +13 -0
- package/dist/runtime.js.map +1 -0
- package/dist/slots-1GPGihk8.d.ts +8 -0
- package/dist/testing.d.ts +149 -0
- package/dist/testing.js +513 -0
- package/dist/testing.js.map +1 -0
- package/dist/types.d.ts +496 -0
- package/dist/types.js +28 -0
- package/dist/types.js.map +1 -0
- package/dist/ui/components.d.ts +16 -0
- package/dist/ui/components.js +192 -0
- package/dist/ui/components.js.map +1 -0
- package/dist/ui/defaults.d.ts +19 -0
- package/dist/ui/defaults.js +104 -0
- package/dist/ui/defaults.js.map +1 -0
- package/dist/ui/plugin-styles.css +250 -0
- package/dist/ui/types/player-state.d.ts +365 -0
- package/dist/ui/types/player-state.js +1 -0
- package/dist/ui/types/player-state.js.map +1 -0
- package/dist/ui-contract-iQfTtUSL.d.ts +1161 -0
- package/dist/ui.d.ts +320 -0
- package/dist/ui.js +253 -0
- package/dist/ui.js.map +1 -0
- package/package.json +199 -0
- package/src/generated/reducer-contract/builders.ts +90 -0
- package/src/generated/reducer-contract/version.ts +9 -0
- package/src/generated/reducer-contract/wire.ts +100 -0
- package/src/generated/reducer-contract/zod.ts +101 -0
- package/src/generated/runtime/primitives.ts +2 -0
- package/src/generated/runtime-api.ts +5 -0
- package/src/generated/runtime.ts +35 -0
- package/src/generated/workspace-contract.ts +2 -0
- package/src/index.ts +7 -0
- package/src/infrastructure/reducer-bundle-abi.ts +8 -0
- package/src/infrastructure/reducer-contract/bundle.ts +37 -0
- package/src/infrastructure/workspace-codegen/hex-geometry.ts +69 -0
- package/src/infrastructure/workspace-codegen/index.ts +64 -0
- package/src/infrastructure/workspace-codegen/manifest-contract.ts +6632 -0
- package/src/infrastructure/workspace-codegen/manifest-validation.ts +795 -0
- package/src/infrastructure/workspace-codegen/ownership.ts +131 -0
- package/src/infrastructure/workspace-codegen/preset-card-sets.ts +169 -0
- package/src/infrastructure/workspace-codegen/seeds.ts +1705 -0
- package/src/infrastructure/workspace-codegen.ts +1 -0
- package/src/package-set.ts +19 -0
- package/src/reducer/authoring/contract.ts +157 -0
- package/src/reducer/authoring/effect.ts +224 -0
- package/src/reducer/authoring/game.ts +23 -0
- package/src/reducer/authoring/interaction.ts +98 -0
- package/src/reducer/authoring/phase.ts +300 -0
- package/src/reducer/authoring/types.ts +70 -0
- package/src/reducer/authoring/validation.ts +382 -0
- package/src/reducer/authoring/view-stage.ts +68 -0
- package/src/reducer/authoring.ts +29 -0
- package/src/reducer/bundle/ingress-bundle.ts +491 -0
- package/src/reducer/bundle/trusted/engine-instruction-resolver.ts +254 -0
- package/src/reducer/bundle/trusted/flow-instruction-resolver.ts +73 -0
- package/src/reducer/bundle/trusted/instruction-runner.ts +414 -0
- package/src/reducer/bundle/trusted/interaction-authorization.ts +137 -0
- package/src/reducer/bundle/trusted/interaction-collectors.ts +859 -0
- package/src/reducer/bundle/trusted/interaction-decision.ts +747 -0
- package/src/reducer/bundle/trusted/interaction-resolver.ts +95 -0
- package/src/reducer/bundle/trusted/interaction-types.ts +171 -0
- package/src/reducer/bundle/trusted/lifecycle-runner.ts +427 -0
- package/src/reducer/bundle/trusted/projection-builder.ts +356 -0
- package/src/reducer/bundle/trusted/projection-context.ts +39 -0
- package/src/reducer/bundle/trusted/rng-sampler.ts +150 -0
- package/src/reducer/bundle/trusted/runtime-registry.ts +120 -0
- package/src/reducer/bundle/trusted/runtime-scope.ts +336 -0
- package/src/reducer/bundle/trusted/simultaneous-player.ts +97 -0
- package/src/reducer/bundle/trusted/stage-resolver.ts +87 -0
- package/src/reducer/bundle/trusted/static-projection.ts +116 -0
- package/src/reducer/bundle/trusted/trusted-runtime-args.ts +97 -0
- package/src/reducer/bundle/trusted/trusted-runtime-result.ts +39 -0
- package/src/reducer/bundle/trusted/trusted-setup-profiles.ts +43 -0
- package/src/reducer/bundle/trusted/trusted-state-codec.ts +48 -0
- package/src/reducer/bundle/trusted-bundle.ts +97 -0
- package/src/reducer/bundle/types.ts +171 -0
- package/src/reducer/bundle.ts +2 -0
- package/src/reducer/client-param-schemas.ts +57 -0
- package/src/reducer/compose.ts +34 -0
- package/src/reducer/core/runtime-input.ts +30 -0
- package/src/reducer/core/runtime-instruction.ts +59 -0
- package/src/reducer/core/types.ts +62 -0
- package/src/reducer/definition-index.ts +277 -0
- package/src/reducer/derived.ts +106 -0
- package/src/reducer/effects.ts +92 -0
- package/src/reducer/engine/runtime-instruction-engine.ts +155 -0
- package/src/reducer/ingress/decode-runtime-input.ts +7 -0
- package/src/reducer/ingress/decode-session-state.ts +9 -0
- package/src/reducer/ingress/encode-session-state.ts +6 -0
- package/src/reducer/ingress/input-codec.ts +18 -0
- package/src/reducer/ingress/phase-schemas.ts +62 -0
- package/src/reducer/ingress/raw-types.ts +107 -0
- package/src/reducer/ingress/runtime-codec.ts +14 -0
- package/src/reducer/ingress/runtime-payload.ts +13 -0
- package/src/reducer/ingress/session-codec.ts +392 -0
- package/src/reducer/ingress/types.ts +6 -0
- package/src/reducer/inputs/boardInput.ts +217 -0
- package/src/reducer/inputs/boardTarget.ts +190 -0
- package/src/reducer/inputs/cardInput.ts +86 -0
- package/src/reducer/inputs/cardTarget.ts +101 -0
- package/src/reducer/inputs/choiceTarget.ts +104 -0
- package/src/reducer/inputs/defineInputs.ts +71 -0
- package/src/reducer/inputs/formInput.ts +809 -0
- package/src/reducer/inputs/many.ts +120 -0
- package/src/reducer/inputs/promptInput.ts +87 -0
- package/src/reducer/inputs/rngInput.ts +58 -0
- package/src/reducer/inputs/targetRule.ts +123 -0
- package/src/reducer/inputs.ts +41 -0
- package/src/reducer/model/definition.ts +1072 -0
- package/src/reducer/model/extract.ts +745 -0
- package/src/reducer/model/manifest.ts +570 -0
- package/src/reducer/model/queries.ts +641 -0
- package/src/reducer/model/runtime.ts +264 -0
- package/src/reducer/model/spec.ts +1386 -0
- package/src/reducer/model/table.ts +260 -0
- package/src/reducer/model.ts +7 -0
- package/src/reducer/ops.ts +1034 -0
- package/src/reducer/parse-utils.ts +28 -0
- package/src/reducer/per-player.ts +422 -0
- package/src/reducer/rng.ts +69 -0
- package/src/reducer/schema-helpers.ts +185 -0
- package/src/reducer/setup-bootstrap-helpers.ts +171 -0
- package/src/reducer/setup-bootstrap.ts +481 -0
- package/src/reducer/table-ops.ts +2671 -0
- package/src/reducer/table-queries.ts +372 -0
- package/src/reducer/transaction.ts +120 -0
- package/src/reducer.ts +314 -0
- package/src/runtime/primitives.ts +1 -0
- package/src/runtime/types/runtime-api.ts +1 -0
- package/src/runtime/workspace-contract.ts +32 -0
- package/src/runtime-internal/components/InteractionForm.tsx +1309 -0
- package/src/runtime-internal/components/PluginRuntime.tsx +103 -0
- package/src/runtime-internal/components/board/target-layer.ts +70 -0
- package/src/runtime-internal/context/ClientParamSchemaContext.tsx +44 -0
- package/src/runtime-internal/context/InteractionDraftContext.tsx +279 -0
- package/src/runtime-internal/context/PluginSessionContext.tsx +47 -0
- package/src/runtime-internal/context/PluginStateContext.tsx +262 -0
- package/src/runtime-internal/context/RuntimeContext.tsx +96 -0
- package/src/runtime-internal/defaults/components.tsx +409 -0
- package/src/runtime-internal/defaults/index.ts +11 -0
- package/src/runtime-internal/errors/ValidationError.ts +29 -0
- package/src/runtime-internal/hooks/useActivePlayers.ts +33 -0
- package/src/runtime-internal/hooks/useBoardInteractions.ts +665 -0
- package/src/runtime-internal/hooks/useGameSelector.ts +105 -0
- package/src/runtime-internal/hooks/useGameView.ts +9 -0
- package/src/runtime-internal/hooks/useInteractionByKey.ts +354 -0
- package/src/runtime-internal/hooks/useInteractionHandle.ts +438 -0
- package/src/runtime-internal/hooks/useIsMyTurn.ts +20 -0
- package/src/runtime-internal/hooks/useLobby.ts +76 -0
- package/src/runtime-internal/hooks/useMe.ts +48 -0
- package/src/runtime-internal/hooks/usePlayerInfo.ts +28 -0
- package/src/runtime-internal/hooks/usePlayerTurnOrder.ts +23 -0
- package/src/runtime-internal/hooks/usePluginRuntime.ts +147 -0
- package/src/runtime-internal/hooks/useSeatInbox.ts +61 -0
- package/src/runtime-internal/hooks/useSimultaneousPhase.ts +10 -0
- package/src/runtime-internal/index.ts +42 -0
- package/src/runtime-internal/internal.ts +43 -0
- package/src/runtime-internal/plugin-styles.css +250 -0
- package/src/runtime-internal/primitives/board.tsx +459 -0
- package/src/runtime-internal/primitives/dialog-lifecycle.ts +58 -0
- package/src/runtime-internal/primitives/dice.tsx +79 -0
- package/src/runtime-internal/primitives/game-ui-provider.tsx +35 -0
- package/src/runtime-internal/primitives/game.tsx +387 -0
- package/src/runtime-internal/primitives/hand-intent-adapter.ts +147 -0
- package/src/runtime-internal/primitives/hand-surface.tsx +594 -0
- package/src/runtime-internal/primitives/index.ts +196 -0
- package/src/runtime-internal/primitives/interaction-form-binding.tsx +56 -0
- package/src/runtime-internal/primitives/interaction-submit.ts +90 -0
- package/src/runtime-internal/primitives/interaction.tsx +987 -0
- package/src/runtime-internal/primitives/phase.tsx +43 -0
- package/src/runtime-internal/primitives/player-roster.tsx +302 -0
- package/src/runtime-internal/primitives/primitive-props.tsx +101 -0
- package/src/runtime-internal/primitives/prompt.tsx +255 -0
- package/src/runtime-internal/primitives/ui.tsx +60 -0
- package/src/runtime-internal/primitives/zone.tsx +791 -0
- package/src/runtime-internal/reducer.ts +30 -0
- package/src/runtime-internal/runtime/createPluginRuntimeAPI.ts +605 -0
- package/src/runtime-internal/types/plugin-state.ts +508 -0
- package/src/runtime-internal/types/reducer-state.ts +24 -0
- package/src/runtime-internal/types/runtime-api.ts +114 -0
- package/src/runtime-internal/ui-contract.ts +519 -0
- package/src/runtime-internal/utils/card-intent-adapter.ts +546 -0
- package/src/runtime-internal/utils/interaction-inputs.ts +492 -0
- package/src/runtime-internal/utils/interaction-labels.ts +23 -0
- package/src/runtime-internal/utils/interaction-router.ts +273 -0
- package/src/runtime-internal/utils/interaction-status.ts +74 -0
- package/src/runtime-internal/workspace-contract.ts +1170 -0
- package/src/runtime.ts +34 -0
- package/src/testing/create-expect-api.ts +352 -0
- package/src/testing/create-test-runtime.ts +381 -0
- package/src/testing/definitions.ts +127 -0
- package/src/testing/index.ts +3 -0
- package/src/testing.ts +1 -0
- package/src/type-stubs/manifest-contract.d.ts +42 -0
- package/src/type-stubs/manifest-contract.js +72 -0
- package/src/type-stubs/ui-contract.d.ts +5 -0
- package/src/type-stubs/ui-contract.js +1 -0
- package/src/types/authoring-card-properties.type-test.ts +266 -0
- package/src/types/authoring.ts +1282 -0
- package/src/types/cards.ts +19 -0
- package/src/types/contracts.ts +1550 -0
- package/src/types/generated-helpers.ts +35 -0
- package/src/types/index.ts +147 -0
- package/src/types/slots.ts +11 -0
- package/src/types.ts +1 -0
- package/src/ui/components/ActionButton.tsx +97 -0
- package/src/ui/components/ActionPanel.tsx +315 -0
- package/src/ui/components/Card.tsx +378 -0
- package/src/ui/components/CardDragSurface.tsx +1076 -0
- package/src/ui/components/ChromeSuppressionContext.tsx +70 -0
- package/src/ui/components/CostDisplay.tsx +145 -0
- package/src/ui/components/DiceRoller.tsx +581 -0
- package/src/ui/components/Drawer.tsx +180 -0
- package/src/ui/components/ErrorBoundary.tsx +275 -0
- package/src/ui/components/GameEndDisplay.tsx +398 -0
- package/src/ui/components/GameSkeleton.tsx +260 -0
- package/src/ui/components/Hand.tsx +468 -0
- package/src/ui/components/HandDock.tsx +299 -0
- package/src/ui/components/HandView.tsx +441 -0
- package/src/ui/components/MobileHandTray.tsx +381 -0
- package/src/ui/components/MoreActions.tsx +143 -0
- package/src/ui/components/PhaseIndicator.tsx +341 -0
- package/src/ui/components/PlayArea.tsx +146 -0
- package/src/ui/components/PrimaryActionButton.tsx +336 -0
- package/src/ui/components/PrimaryButton.tsx +45 -0
- package/src/ui/components/ResourceCounter.tsx +270 -0
- package/src/ui/components/StagingZone.tsx +134 -0
- package/src/ui/components/ThemedButton.tsx +113 -0
- package/src/ui/components/Toast.tsx +264 -0
- package/src/ui/components/board/HexGrid.tsx +1294 -0
- package/src/ui/components/board/NetworkGraph.tsx +476 -0
- package/src/ui/components/board/SlotSystem.tsx +388 -0
- package/src/ui/components/board/SquareGrid.tsx +1165 -0
- package/src/ui/components/board/TrackBoard.tsx +496 -0
- package/src/ui/components/board/ZoneMap.tsx +448 -0
- package/src/ui/components/board/hex-board-view.ts +123 -0
- package/src/ui/components/board/index.ts +142 -0
- package/src/ui/components/board/interaction-accessibility.ts +21 -0
- package/src/ui/components/board/target-layer.ts +66 -0
- package/src/ui/components/card-render-content.type-test.ts +27 -0
- package/src/ui/components/hand-layout-math.ts +163 -0
- package/src/ui/components/hand-pointer-engine.ts +413 -0
- package/src/ui/components/index.ts +245 -0
- package/src/ui/components.ts +1 -0
- package/src/ui/defaults/components.tsx +106 -0
- package/src/ui/defaults/index.ts +8 -0
- package/src/ui/defaults.ts +1 -0
- package/src/ui/errors/ValidationError.ts +29 -0
- package/src/ui/helpers/cards.ts +19 -0
- package/src/ui/helpers/track-board.ts +211 -0
- package/src/ui/hooks/useBoardTopology.ts +316 -0
- package/src/ui/hooks/useCards.ts +10 -0
- package/src/ui/hooks/useHandCardPointer.ts +381 -0
- package/src/ui/hooks/useHandLayout.ts +378 -0
- package/src/ui/hooks/useHandPresentation.ts +121 -0
- package/src/ui/hooks/useHexBoard.ts +74 -0
- package/src/ui/hooks/useHexGrid.ts +185 -0
- package/src/ui/hooks/useIsMobile.ts +35 -0
- package/src/ui/hooks/usePanZoom.ts +278 -0
- package/src/ui/hooks/useSquareBoard.ts +124 -0
- package/src/ui/hooks/useSquareGrid.ts +328 -0
- package/src/ui/index.ts +98 -0
- package/src/ui/internal/ui/alert.tsx +51 -0
- package/src/ui/internal/ui/button.tsx +58 -0
- package/src/ui/internal/ui/dialog.tsx +134 -0
- package/src/ui/internal/ui/input.tsx +21 -0
- package/src/ui/internal/ui/label.tsx +21 -0
- package/src/ui/internal/ui/select.tsx +129 -0
- package/src/ui/internal/ui/tooltip.tsx +54 -0
- package/src/ui/internal/ui/utils.ts +5 -0
- package/src/ui/plugin-styles.css +250 -0
- package/src/ui/primitives/dialog-lifecycle.ts +58 -0
- package/src/ui/primitives/dice.tsx +79 -0
- package/src/ui/primitives/primitive-props.tsx +101 -0
- package/src/ui/theme/ThemeProvider.tsx +252 -0
- package/src/ui/theme/board.ts +61 -0
- package/src/ui/theme/css-vars.ts +105 -0
- package/src/ui/theme/derive.ts +240 -0
- package/src/ui/theme/index.ts +61 -0
- package/src/ui/theme/presets/arcade.ts +261 -0
- package/src/ui/theme/presets/studio.ts +261 -0
- package/src/ui/theme/presets/tabletop.ts +266 -0
- package/src/ui/theme/tokens.ts +392 -0
- package/src/ui/types/hex-color.ts +20 -0
- package/src/ui/types/player-state.ts +463 -0
- package/src/ui/types/tiled-board.ts +785 -0
- package/src/ui/types/visual-state.ts +137 -0
- package/src/ui.ts +1 -0
|
@@ -0,0 +1,933 @@
|
|
|
1
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
+
import { ReactNode } from 'react';
|
|
3
|
+
import { BoardId, HexTileState, HexEdgeState, EdgeTypeId, PlayerId, HexVertexState, VertexTypeId, SpaceTypeId, SquareCellState, SquareEdgeState, SquareVertexState, SquarePieceState, HexBoardState, SquareBoardState } from './ui/types/player-state.js';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Token contract for `@dreamboard-games/sdk/ui`.
|
|
7
|
+
*
|
|
8
|
+
* The {@link Theme} object is the only thing components consume for
|
|
9
|
+
* visual styling. Every preset (tabletop, arcade, studio) is just a
|
|
10
|
+
* different fully-resolved {@link Theme}; every author override is a
|
|
11
|
+
* deep partial of it. Components never inline hex codes, font stacks,
|
|
12
|
+
* or shadow strings — they read from `useTheme()` (or, when written in
|
|
13
|
+
* Tailwind, from CSS variables that the {@link ThemeProvider} writes
|
|
14
|
+
* onto its wrapper element).
|
|
15
|
+
*
|
|
16
|
+
* Architectural rules:
|
|
17
|
+
*
|
|
18
|
+
* 1. **Foundation → Semantic → Component.** Foundation palette ramps
|
|
19
|
+
* (`color.neutral`, `color.brand`, …) are never read directly by
|
|
20
|
+
* components. Components read `semantic.*` (e.g. `surface.card`,
|
|
21
|
+
* `intent.primary`) which the preset maps from foundation tokens.
|
|
22
|
+
* 2. **No optional deep keys.** Presets must supply every leaf so
|
|
23
|
+
* components don't need fallbacks. Author-supplied overrides are
|
|
24
|
+
* `DeepPartial<Theme>` and merged before the provider mounts.
|
|
25
|
+
* 3. **Scalar leaves only.** Every leaf is a string (CSS-ready) so the
|
|
26
|
+
* serializer can emit a CSS variable for it without per-token
|
|
27
|
+
* formatting logic.
|
|
28
|
+
*/
|
|
29
|
+
/** Identity-only metadata. */
|
|
30
|
+
interface ThemeMeta {
|
|
31
|
+
/** Stable id used by `data-dreamboard-theme` and CSS-var scoping. */
|
|
32
|
+
readonly id: string;
|
|
33
|
+
/** Human-readable name for dev tools. */
|
|
34
|
+
readonly name: string;
|
|
35
|
+
/**
|
|
36
|
+
* Render mode hint for components that need to choose between light
|
|
37
|
+
* and dark sub-tokens. Presets pick one; authors don't toggle this.
|
|
38
|
+
*/
|
|
39
|
+
readonly mode: "light" | "dark";
|
|
40
|
+
}
|
|
41
|
+
/** Foundation color ramp. Six stops keeps presets compact. */
|
|
42
|
+
interface ColorRamp {
|
|
43
|
+
readonly 50: string;
|
|
44
|
+
readonly 100: string;
|
|
45
|
+
readonly 200: string;
|
|
46
|
+
readonly 400: string;
|
|
47
|
+
readonly 600: string;
|
|
48
|
+
readonly 800: string;
|
|
49
|
+
readonly 950: string;
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Per-player color tokens. The {@link Theme.player} array is indexed by
|
|
53
|
+
* 0-based seat slot (`player[0]` = first seat). Each entry carries a
|
|
54
|
+
* `solid` brand color, a `soft` tint usable as a background, and `on`
|
|
55
|
+
* — the recommended foreground when text sits on `solid`.
|
|
56
|
+
*/
|
|
57
|
+
interface PlayerColor {
|
|
58
|
+
readonly solid: string;
|
|
59
|
+
readonly soft: string;
|
|
60
|
+
readonly on: string;
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Foundation palette. Components never read this directly; presets map
|
|
64
|
+
* these into {@link SemanticTokens}. Exposed so authors who write a
|
|
65
|
+
* full theme can compose without inventing their own palette type.
|
|
66
|
+
*/
|
|
67
|
+
interface FoundationColor {
|
|
68
|
+
readonly neutral: ColorRamp;
|
|
69
|
+
readonly brand: ColorRamp;
|
|
70
|
+
readonly accent: ColorRamp;
|
|
71
|
+
readonly success: ColorRamp;
|
|
72
|
+
readonly warning: ColorRamp;
|
|
73
|
+
readonly danger: ColorRamp;
|
|
74
|
+
readonly info: ColorRamp;
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Semantic colors consumed by every component. These are the *only*
|
|
78
|
+
* color tokens components should reference. Names describe role
|
|
79
|
+
* ("the surface a player card sits on"), not appearance ("light grey").
|
|
80
|
+
*/
|
|
81
|
+
interface SemanticColor {
|
|
82
|
+
readonly surface: {
|
|
83
|
+
/** Outermost shell background. */
|
|
84
|
+
readonly app: string;
|
|
85
|
+
/** Board canvas background (behind tiles). */
|
|
86
|
+
readonly board: string;
|
|
87
|
+
/** HUD chrome panels (top bar, action bar, side rails). */
|
|
88
|
+
readonly hud: string;
|
|
89
|
+
/** Standalone cards (player cards, action cards, hand cards). */
|
|
90
|
+
readonly card: string;
|
|
91
|
+
/** Modal/sheet body. */
|
|
92
|
+
readonly sheet: string;
|
|
93
|
+
/** Scrim behind a blocker overlay. */
|
|
94
|
+
readonly overlay: string;
|
|
95
|
+
/** Subtle inset (resource pills, count badges, …). */
|
|
96
|
+
readonly inset: string;
|
|
97
|
+
};
|
|
98
|
+
readonly text: {
|
|
99
|
+
/** Default body and headline text on light surfaces. */
|
|
100
|
+
readonly primary: string;
|
|
101
|
+
/** De-emphasised metadata, hint copy, captions. */
|
|
102
|
+
readonly muted: string;
|
|
103
|
+
/** Text used on `intent.primary` solid backgrounds. */
|
|
104
|
+
readonly onIntent: string;
|
|
105
|
+
/** Brand-tinted text for emphasis (links, key numbers). */
|
|
106
|
+
readonly accent: string;
|
|
107
|
+
/** Disabled text (button labels in disabled state). */
|
|
108
|
+
readonly disabled: string;
|
|
109
|
+
};
|
|
110
|
+
readonly border: {
|
|
111
|
+
/** Hairline divider between sibling rows. */
|
|
112
|
+
readonly subtle: string;
|
|
113
|
+
/** Standard card / panel border. */
|
|
114
|
+
readonly default: string;
|
|
115
|
+
/** Outlined emphasis (hovered tiles, selected card). */
|
|
116
|
+
readonly strong: string;
|
|
117
|
+
/** Focus ring (keyboard nav). */
|
|
118
|
+
readonly focus: string;
|
|
119
|
+
};
|
|
120
|
+
/**
|
|
121
|
+
* Intent colours map to action emphasis. Components pick a slot
|
|
122
|
+
* (`primary` for "do the main thing now", `danger` for destructive
|
|
123
|
+
* confirms, etc.) and read both the surface and on-color from it.
|
|
124
|
+
*/
|
|
125
|
+
readonly intent: {
|
|
126
|
+
readonly primary: IntentColor;
|
|
127
|
+
readonly secondary: IntentColor;
|
|
128
|
+
readonly success: IntentColor;
|
|
129
|
+
readonly danger: IntentColor;
|
|
130
|
+
readonly warning: IntentColor;
|
|
131
|
+
readonly info: IntentColor;
|
|
132
|
+
};
|
|
133
|
+
}
|
|
134
|
+
/** A semantic intent (button background + matching foreground + soft tint). */
|
|
135
|
+
interface IntentColor {
|
|
136
|
+
/** Solid fill (button bg, badge bg). */
|
|
137
|
+
readonly solid: string;
|
|
138
|
+
/** Recommended text/icon color sitting on `solid`. */
|
|
139
|
+
readonly on: string;
|
|
140
|
+
/** Subtle tint (e.g. badge bg with `text` for foreground). */
|
|
141
|
+
readonly soft: string;
|
|
142
|
+
/** Suitable foreground when sitting on `soft`. */
|
|
143
|
+
readonly onSoft: string;
|
|
144
|
+
/** Border tint matched to this intent (e.g. focus ring on intent). */
|
|
145
|
+
readonly border: string;
|
|
146
|
+
}
|
|
147
|
+
/** Border-radius ramp. */
|
|
148
|
+
interface Radius {
|
|
149
|
+
readonly none: string;
|
|
150
|
+
readonly sm: string;
|
|
151
|
+
readonly md: string;
|
|
152
|
+
readonly lg: string;
|
|
153
|
+
/** HUD chrome (top bar pieces, action-bar bar). */
|
|
154
|
+
readonly hud: string;
|
|
155
|
+
/** Fully-round badges/pills. */
|
|
156
|
+
readonly pill: string;
|
|
157
|
+
}
|
|
158
|
+
/** Spacing ramp (rem-based by default). */
|
|
159
|
+
interface Space {
|
|
160
|
+
readonly 0: string;
|
|
161
|
+
readonly 0.5: string;
|
|
162
|
+
readonly 1: string;
|
|
163
|
+
readonly 1.5: string;
|
|
164
|
+
readonly 2: string;
|
|
165
|
+
readonly 3: string;
|
|
166
|
+
readonly 4: string;
|
|
167
|
+
readonly 6: string;
|
|
168
|
+
readonly 8: string;
|
|
169
|
+
readonly 12: string;
|
|
170
|
+
}
|
|
171
|
+
/** Typography tokens. */
|
|
172
|
+
interface Typography {
|
|
173
|
+
readonly fontFamily: {
|
|
174
|
+
/** Hero text — phase name, scoreboard headline, winner banner. */
|
|
175
|
+
readonly display: string;
|
|
176
|
+
/** Default UI body text. */
|
|
177
|
+
readonly body: string;
|
|
178
|
+
/** Numeric runs (scores, counters, tabular data). Tabular figures preferred. */
|
|
179
|
+
readonly tabular: string;
|
|
180
|
+
/** Source/code/raw-id rendering. */
|
|
181
|
+
readonly mono: string;
|
|
182
|
+
};
|
|
183
|
+
readonly fontSize: {
|
|
184
|
+
readonly xs: string;
|
|
185
|
+
readonly sm: string;
|
|
186
|
+
readonly md: string;
|
|
187
|
+
readonly lg: string;
|
|
188
|
+
readonly xl: string;
|
|
189
|
+
readonly "2xl": string;
|
|
190
|
+
readonly "3xl": string;
|
|
191
|
+
};
|
|
192
|
+
readonly fontWeight: {
|
|
193
|
+
readonly regular: string;
|
|
194
|
+
readonly medium: string;
|
|
195
|
+
readonly bold: string;
|
|
196
|
+
};
|
|
197
|
+
readonly lineHeight: {
|
|
198
|
+
readonly tight: string;
|
|
199
|
+
readonly normal: string;
|
|
200
|
+
readonly relaxed: string;
|
|
201
|
+
};
|
|
202
|
+
readonly letterSpacing: {
|
|
203
|
+
readonly tight: string;
|
|
204
|
+
readonly normal: string;
|
|
205
|
+
readonly wide: string;
|
|
206
|
+
/** All-caps labels ("YOUR TURN"). */
|
|
207
|
+
readonly caps: string;
|
|
208
|
+
};
|
|
209
|
+
}
|
|
210
|
+
/** Drop-shadow elevation ramp. */
|
|
211
|
+
interface Elevation {
|
|
212
|
+
/** Resting state (cards, panels). */
|
|
213
|
+
readonly rest: string;
|
|
214
|
+
/** Hover-lift (interactive cards). */
|
|
215
|
+
readonly hover: string;
|
|
216
|
+
/** Selected / dragged element. */
|
|
217
|
+
readonly lifted: string;
|
|
218
|
+
/** Modal / overlay stack. */
|
|
219
|
+
readonly overlay: string;
|
|
220
|
+
/** Inner shadow (board canvas inset, resource pill well). */
|
|
221
|
+
readonly inset: string;
|
|
222
|
+
}
|
|
223
|
+
/**
|
|
224
|
+
* Motion tokens. Components import durations and easings from here so a
|
|
225
|
+
* single `prefers-reduced-motion` switch zeroes everything out at the
|
|
226
|
+
* provider, not per-component.
|
|
227
|
+
*/
|
|
228
|
+
interface Motion {
|
|
229
|
+
readonly duration: {
|
|
230
|
+
/** Hover, focus, micro-press (~80ms). */
|
|
231
|
+
readonly fast: string;
|
|
232
|
+
/** Default — most state changes (~160ms). */
|
|
233
|
+
readonly normal: string;
|
|
234
|
+
/** Layout shifts, drawer open/close (~280ms). */
|
|
235
|
+
readonly slow: string;
|
|
236
|
+
/**
|
|
237
|
+
* Looping ambient pulses — active-player breath, dice glow.
|
|
238
|
+
* Components should respect `motion.reducedMotion` before kicking
|
|
239
|
+
* off looping animations.
|
|
240
|
+
*/
|
|
241
|
+
readonly ambient: string;
|
|
242
|
+
};
|
|
243
|
+
readonly easing: {
|
|
244
|
+
/** Default for entering / settling. */
|
|
245
|
+
readonly out: string;
|
|
246
|
+
/** Default for exiting. */
|
|
247
|
+
readonly in: string;
|
|
248
|
+
/** Symmetric. */
|
|
249
|
+
readonly inOut: string;
|
|
250
|
+
/** Springy — selected card lift, active-player wobble. */
|
|
251
|
+
readonly spring: string;
|
|
252
|
+
};
|
|
253
|
+
/**
|
|
254
|
+
* `"true"` when the active client requests reduced motion. Components
|
|
255
|
+
* should branch on this rather than forcing animations off via CSS,
|
|
256
|
+
* because some animations (e.g. dice roll, shuffle) are critical for
|
|
257
|
+
* conveying state and need a static fallback.
|
|
258
|
+
*/
|
|
259
|
+
readonly reducedMotion: "true" | "false";
|
|
260
|
+
}
|
|
261
|
+
/**
|
|
262
|
+
* Component-level token slots derived from semantic + foundation tokens.
|
|
263
|
+
* Kept intentionally tiny — a slot is added here only when a component
|
|
264
|
+
* needs to deviate from the semantic mapping in a way that authors
|
|
265
|
+
* should be able to customise without re-skinning the whole intent
|
|
266
|
+
* scale.
|
|
267
|
+
*/
|
|
268
|
+
interface ComponentTokens {
|
|
269
|
+
readonly board: {
|
|
270
|
+
/** Outer ring around the board canvas. */
|
|
271
|
+
readonly frameBorder: string;
|
|
272
|
+
/** Inner board surface tint (overlays the canvas tile renderer). */
|
|
273
|
+
readonly frameBackground: string;
|
|
274
|
+
/** Highlight ring drawn on hovered interactive targets. */
|
|
275
|
+
readonly hoverRing: string;
|
|
276
|
+
/** Idle hint colour for eligible-but-unhovered targets. */
|
|
277
|
+
readonly eligibleHint: string;
|
|
278
|
+
};
|
|
279
|
+
readonly card: {
|
|
280
|
+
/** Border drawn around face-up cards. */
|
|
281
|
+
readonly border: string;
|
|
282
|
+
/** Border drawn around face-down cards. */
|
|
283
|
+
readonly backBorder: string;
|
|
284
|
+
/** Card-back fill colour. */
|
|
285
|
+
readonly backBackground: string;
|
|
286
|
+
/** Selected outline. */
|
|
287
|
+
readonly selectedRing: string;
|
|
288
|
+
};
|
|
289
|
+
readonly playerCard: {
|
|
290
|
+
/** Background of the active-player card. */
|
|
291
|
+
readonly activeBackground: string;
|
|
292
|
+
/** Border of the active-player card. */
|
|
293
|
+
readonly activeBorder: string;
|
|
294
|
+
/** Glow colour radiated by the active-player card. */
|
|
295
|
+
readonly activeGlow: string;
|
|
296
|
+
/** Background of the "you" badge. */
|
|
297
|
+
readonly youBadgeBackground: string;
|
|
298
|
+
/** Foreground of the "you" badge. */
|
|
299
|
+
readonly youBadgeForeground: string;
|
|
300
|
+
};
|
|
301
|
+
readonly toast: {
|
|
302
|
+
readonly successBackground: string;
|
|
303
|
+
readonly errorBackground: string;
|
|
304
|
+
readonly infoBackground: string;
|
|
305
|
+
readonly foreground: string;
|
|
306
|
+
};
|
|
307
|
+
}
|
|
308
|
+
/**
|
|
309
|
+
* The complete theme contract. Every leaf is a CSS-ready string so the
|
|
310
|
+
* provider can emit a CSS variable for each path without per-leaf
|
|
311
|
+
* formatting. {@link DeepPartial} is exported for author overrides.
|
|
312
|
+
*/
|
|
313
|
+
interface Theme {
|
|
314
|
+
readonly meta: ThemeMeta;
|
|
315
|
+
readonly color: FoundationColor;
|
|
316
|
+
readonly semantic: SemanticColor;
|
|
317
|
+
readonly radius: Radius;
|
|
318
|
+
readonly space: Space;
|
|
319
|
+
readonly typography: Typography;
|
|
320
|
+
readonly elevation: Elevation;
|
|
321
|
+
readonly motion: Motion;
|
|
322
|
+
readonly player: readonly [
|
|
323
|
+
PlayerColor,
|
|
324
|
+
PlayerColor,
|
|
325
|
+
PlayerColor,
|
|
326
|
+
PlayerColor,
|
|
327
|
+
PlayerColor,
|
|
328
|
+
PlayerColor
|
|
329
|
+
];
|
|
330
|
+
readonly component: ComponentTokens;
|
|
331
|
+
}
|
|
332
|
+
/**
|
|
333
|
+
* Recursive partial for theme overrides. Authors pass this to
|
|
334
|
+
* `<ThemeProvider override={...}/>` (or to a preset's `extend`
|
|
335
|
+
* helper) to tweak individual tokens without re-declaring the whole
|
|
336
|
+
* tree.
|
|
337
|
+
*/
|
|
338
|
+
type ThemeOverride = DeepPartial<Theme>;
|
|
339
|
+
type DeepPartial<T> = T extends ReadonlyArray<infer U> ? ReadonlyArray<DeepPartial<U>> : T extends object ? {
|
|
340
|
+
readonly [K in keyof T]?: DeepPartial<T[K]>;
|
|
341
|
+
} : T;
|
|
342
|
+
/**
|
|
343
|
+
* Deep merge for {@link Theme} overrides. Arrays (notably
|
|
344
|
+
* {@link Theme.player}) are *replaced* rather than merged so callers
|
|
345
|
+
* can't accidentally end up with mixed-preset palettes.
|
|
346
|
+
*/
|
|
347
|
+
declare function mergeTheme(base: Theme, override?: ThemeOverride): Theme;
|
|
348
|
+
|
|
349
|
+
type RuntimeFields = Record<string, unknown>;
|
|
350
|
+
interface GeneratedTiledEdgeStateLike<SpaceIdValue extends string = string, EdgeIdValue extends string = string, Fields = RuntimeFields> {
|
|
351
|
+
id: EdgeIdValue;
|
|
352
|
+
spaceIds: readonly SpaceIdValue[];
|
|
353
|
+
typeId?: EdgeTypeId | null;
|
|
354
|
+
label?: string | null;
|
|
355
|
+
ownerId?: PlayerId | null;
|
|
356
|
+
fields?: Fields;
|
|
357
|
+
}
|
|
358
|
+
interface GeneratedTiledVertexStateLike<SpaceIdValue extends string = string, VertexIdValue extends string = string, Fields = RuntimeFields> {
|
|
359
|
+
id: VertexIdValue;
|
|
360
|
+
spaceIds: readonly SpaceIdValue[];
|
|
361
|
+
typeId?: VertexTypeId | null;
|
|
362
|
+
label?: string | null;
|
|
363
|
+
ownerId?: PlayerId | null;
|
|
364
|
+
fields?: Fields;
|
|
365
|
+
}
|
|
366
|
+
interface GeneratedHexSpaceStateLike<SpaceIdValue extends string = string, Fields = RuntimeFields> {
|
|
367
|
+
id: SpaceIdValue;
|
|
368
|
+
q: number;
|
|
369
|
+
r: number;
|
|
370
|
+
typeId?: SpaceTypeId | null;
|
|
371
|
+
label?: string | null;
|
|
372
|
+
ownerId?: PlayerId | null;
|
|
373
|
+
fields?: Fields;
|
|
374
|
+
}
|
|
375
|
+
interface GeneratedSquareSpaceStateLike<SpaceIdValue extends string = string, Fields = RuntimeFields> {
|
|
376
|
+
id: SpaceIdValue;
|
|
377
|
+
row: number;
|
|
378
|
+
col: number;
|
|
379
|
+
typeId?: SpaceTypeId | null;
|
|
380
|
+
label?: string | null;
|
|
381
|
+
ownerId?: PlayerId | null;
|
|
382
|
+
fields?: Fields;
|
|
383
|
+
}
|
|
384
|
+
interface GeneratedHexBoardInput<BoardIdValue extends string = BoardId, SpaceIdValue extends string = string, EdgeIdValue extends string = string, VertexIdValue extends string = string, SpaceFields = RuntimeFields, EdgeFields = RuntimeFields, VertexFields = RuntimeFields> {
|
|
385
|
+
id: BoardIdValue;
|
|
386
|
+
layout?: "hex";
|
|
387
|
+
orientation?: "pointy-top" | "flat-top";
|
|
388
|
+
spaces: Readonly<Record<SpaceIdValue, GeneratedHexSpaceStateLike<SpaceIdValue, SpaceFields>>>;
|
|
389
|
+
edges: ReadonlyArray<HexEdgeState<BoardIdValue, SpaceIdValue, EdgeIdValue, EdgeFields> | GeneratedTiledEdgeStateLike<SpaceIdValue, EdgeIdValue, EdgeFields>>;
|
|
390
|
+
vertices: ReadonlyArray<HexVertexState<BoardIdValue, SpaceIdValue, VertexIdValue, VertexFields> | GeneratedTiledVertexStateLike<SpaceIdValue, VertexIdValue, VertexFields>>;
|
|
391
|
+
}
|
|
392
|
+
interface AuthoredHexBoardInput<BoardIdValue extends string = BoardId, SpaceIdValue extends string = string, EdgeIdValue extends string = string, VertexIdValue extends string = string, SpaceFields = RuntimeFields, EdgeFields = RuntimeFields, VertexFields = RuntimeFields, SpaceView = unknown> {
|
|
393
|
+
id: BoardIdValue;
|
|
394
|
+
layout?: "hex";
|
|
395
|
+
orientation?: "pointy-top" | "flat-top";
|
|
396
|
+
tiles: ReadonlyArray<HexTileState<BoardIdValue, SpaceIdValue, SpaceFields, SpaceView>>;
|
|
397
|
+
edges: ReadonlyArray<HexEdgeState<BoardIdValue, SpaceIdValue, EdgeIdValue, EdgeFields> | GeneratedTiledEdgeStateLike<SpaceIdValue, EdgeIdValue, EdgeFields>>;
|
|
398
|
+
vertices: ReadonlyArray<HexVertexState<BoardIdValue, SpaceIdValue, VertexIdValue, VertexFields> | GeneratedTiledVertexStateLike<SpaceIdValue, VertexIdValue, VertexFields>>;
|
|
399
|
+
}
|
|
400
|
+
type HexBoardInput<BoardIdValue extends string = BoardId, SpaceIdValue extends string = string, EdgeIdValue extends string = string, VertexIdValue extends string = string, SpaceFields = RuntimeFields, EdgeFields = RuntimeFields, VertexFields = RuntimeFields> = AuthoredHexBoardInput<BoardIdValue, SpaceIdValue, EdgeIdValue, VertexIdValue, SpaceFields, EdgeFields, VertexFields> | GeneratedHexBoardInput<BoardIdValue, SpaceIdValue, EdgeIdValue, VertexIdValue, SpaceFields, EdgeFields, VertexFields>;
|
|
401
|
+
interface GeneratedSquareBoardInput<BoardIdValue extends string = BoardId, SpaceIdValue extends string = string, EdgeIdValue extends string = string, VertexIdValue extends string = string, PieceIdValue extends string = string, SpaceFields = RuntimeFields, EdgeFields = RuntimeFields, VertexFields = RuntimeFields, PieceFields = RuntimeFields> {
|
|
402
|
+
id: BoardIdValue;
|
|
403
|
+
layout?: "square";
|
|
404
|
+
spaces: Readonly<Record<SpaceIdValue, GeneratedSquareSpaceStateLike<SpaceIdValue, SpaceFields>>>;
|
|
405
|
+
edges: ReadonlyArray<SquareEdgeState<SpaceIdValue, EdgeIdValue, EdgeFields> | GeneratedTiledEdgeStateLike<SpaceIdValue, EdgeIdValue, EdgeFields>>;
|
|
406
|
+
vertices: ReadonlyArray<SquareVertexState<SpaceIdValue, VertexIdValue, VertexFields> | GeneratedTiledVertexStateLike<SpaceIdValue, VertexIdValue, VertexFields>>;
|
|
407
|
+
pieces?: ReadonlyArray<SquarePieceState<PieceIdValue, PieceFields>>;
|
|
408
|
+
}
|
|
409
|
+
interface AuthoredSquareBoardInput<BoardIdValue extends string = BoardId, SpaceIdValue extends string = string, EdgeIdValue extends string = string, VertexIdValue extends string = string, PieceIdValue extends string = string, SpaceFields = RuntimeFields, EdgeFields = RuntimeFields, VertexFields = RuntimeFields, PieceFields = RuntimeFields> {
|
|
410
|
+
id: BoardIdValue;
|
|
411
|
+
layout?: "square";
|
|
412
|
+
rows: number;
|
|
413
|
+
cols: number;
|
|
414
|
+
cells: ReadonlyArray<SquareCellState<SpaceIdValue, SpaceFields>>;
|
|
415
|
+
edges: ReadonlyArray<SquareEdgeState<SpaceIdValue, EdgeIdValue, EdgeFields> | GeneratedTiledEdgeStateLike<SpaceIdValue, EdgeIdValue, EdgeFields>>;
|
|
416
|
+
vertices: ReadonlyArray<SquareVertexState<SpaceIdValue, VertexIdValue, VertexFields> | GeneratedTiledVertexStateLike<SpaceIdValue, VertexIdValue, VertexFields>>;
|
|
417
|
+
pieces: ReadonlyArray<SquarePieceState<PieceIdValue, PieceFields>>;
|
|
418
|
+
}
|
|
419
|
+
type SquareBoardInput<BoardIdValue extends string = BoardId, SpaceIdValue extends string = string, EdgeIdValue extends string = string, VertexIdValue extends string = string, PieceIdValue extends string = string, SpaceFields = RuntimeFields, EdgeFields = RuntimeFields, VertexFields = RuntimeFields, PieceFields = RuntimeFields> = AuthoredSquareBoardInput<BoardIdValue, SpaceIdValue, EdgeIdValue, VertexIdValue, PieceIdValue, SpaceFields, EdgeFields, VertexFields, PieceFields> | GeneratedSquareBoardInput<BoardIdValue, SpaceIdValue, EdgeIdValue, VertexIdValue, PieceIdValue, SpaceFields, EdgeFields, VertexFields, PieceFields>;
|
|
420
|
+
type AnyHexBoardInput = HexBoardInput<string, string, string, string, RuntimeFields, RuntimeFields, RuntimeFields>;
|
|
421
|
+
type AnySquareBoardInput = SquareBoardInput<string, string, string, string, string, RuntimeFields, RuntimeFields, RuntimeFields, RuntimeFields>;
|
|
422
|
+
type BoardIdOf<TBoard> = TBoard extends {
|
|
423
|
+
id: infer Id extends string;
|
|
424
|
+
} ? Id : string;
|
|
425
|
+
type SpaceRecordValueOf<TBoard> = TBoard extends {
|
|
426
|
+
spaces: Readonly<Record<string, infer Space>>;
|
|
427
|
+
} ? Space : never;
|
|
428
|
+
type TileValueOf<TBoard> = TBoard extends {
|
|
429
|
+
tiles: ReadonlyArray<infer Tile>;
|
|
430
|
+
} ? Tile : never;
|
|
431
|
+
type CellValueOf<TBoard> = TBoard extends {
|
|
432
|
+
cells: ReadonlyArray<infer Cell>;
|
|
433
|
+
} ? Cell : never;
|
|
434
|
+
type EdgeValueOf<TBoard> = TBoard extends {
|
|
435
|
+
edges: ReadonlyArray<infer Edge>;
|
|
436
|
+
} ? Edge : never;
|
|
437
|
+
type VertexValueOf<TBoard> = TBoard extends {
|
|
438
|
+
vertices: ReadonlyArray<infer Vertex>;
|
|
439
|
+
} ? Vertex : never;
|
|
440
|
+
type PieceValueOf<TBoard> = TBoard extends {
|
|
441
|
+
pieces?: ReadonlyArray<infer Piece>;
|
|
442
|
+
} ? Piece : never;
|
|
443
|
+
type BoardSpaceIdOf<TBoard> = SpaceRecordValueOf<TBoard> extends {
|
|
444
|
+
id: infer Id extends string;
|
|
445
|
+
} ? Id : TileValueOf<TBoard> extends {
|
|
446
|
+
id: infer Id extends string;
|
|
447
|
+
} ? Id : CellValueOf<TBoard> extends {
|
|
448
|
+
id: infer Id extends string;
|
|
449
|
+
} ? Id : never;
|
|
450
|
+
type BoardEdgeIdOf<TBoard> = EdgeValueOf<TBoard> extends {
|
|
451
|
+
id: infer Id extends string;
|
|
452
|
+
} ? Id : never;
|
|
453
|
+
type BoardVertexIdOf<TBoard> = VertexValueOf<TBoard> extends {
|
|
454
|
+
id: infer Id extends string;
|
|
455
|
+
} ? Id : never;
|
|
456
|
+
type HexTilePropertiesOf<TBoard> = SpaceRecordValueOf<TBoard> extends {
|
|
457
|
+
fields?: infer Fields;
|
|
458
|
+
} ? Fields : TileValueOf<TBoard> extends {
|
|
459
|
+
properties?: infer Properties;
|
|
460
|
+
} ? Properties : RuntimeFields;
|
|
461
|
+
type HexTileViewOf<TBoard> = TileValueOf<TBoard> extends {
|
|
462
|
+
view: infer View;
|
|
463
|
+
} ? View : TileValueOf<TBoard> extends {
|
|
464
|
+
view?: infer View;
|
|
465
|
+
} ? View | undefined : unknown;
|
|
466
|
+
type HexEdgePropertiesOf<TBoard> = EdgeValueOf<TBoard> extends {
|
|
467
|
+
fields?: infer Fields;
|
|
468
|
+
} ? Fields : EdgeValueOf<TBoard> extends {
|
|
469
|
+
properties?: infer Properties;
|
|
470
|
+
} ? Properties : RuntimeFields;
|
|
471
|
+
type HexVertexPropertiesOf<TBoard> = VertexValueOf<TBoard> extends {
|
|
472
|
+
fields?: infer Fields;
|
|
473
|
+
} ? Fields : VertexValueOf<TBoard> extends {
|
|
474
|
+
properties?: infer Properties;
|
|
475
|
+
} ? Properties : RuntimeFields;
|
|
476
|
+
type SquareCellPropertiesOf<TBoard> = SpaceRecordValueOf<TBoard> extends {
|
|
477
|
+
fields?: infer Fields;
|
|
478
|
+
} ? Fields : CellValueOf<TBoard> extends {
|
|
479
|
+
properties?: infer Properties;
|
|
480
|
+
} ? Properties : RuntimeFields;
|
|
481
|
+
type SquareEdgePropertiesOf<TBoard> = EdgeValueOf<TBoard> extends {
|
|
482
|
+
fields?: infer Fields;
|
|
483
|
+
} ? Fields : EdgeValueOf<TBoard> extends {
|
|
484
|
+
properties?: infer Properties;
|
|
485
|
+
} ? Properties : RuntimeFields;
|
|
486
|
+
type SquareVertexPropertiesOf<TBoard> = VertexValueOf<TBoard> extends {
|
|
487
|
+
fields?: infer Fields;
|
|
488
|
+
} ? Fields : VertexValueOf<TBoard> extends {
|
|
489
|
+
properties?: infer Properties;
|
|
490
|
+
} ? Properties : RuntimeFields;
|
|
491
|
+
type SquarePiecePropertiesOf<TBoard> = PieceValueOf<TBoard> extends {
|
|
492
|
+
properties?: infer Properties;
|
|
493
|
+
} ? Properties : RuntimeFields;
|
|
494
|
+
/**
|
|
495
|
+
* Normalized hex tile shape for a given board input.
|
|
496
|
+
*
|
|
497
|
+
* `view` is always present (required) on the result so consumers can
|
|
498
|
+
* read overlay fields without a null-check. For boards that do not
|
|
499
|
+
* statically declare a `view` shape (the generic case), `view` falls
|
|
500
|
+
* back to `unknown`, which still admits any value.
|
|
501
|
+
*
|
|
502
|
+
* The runtime normalizer injects `view: undefined` for inputs that
|
|
503
|
+
* do not author a `view` field, keeping the runtime contract aligned
|
|
504
|
+
* with this static shape.
|
|
505
|
+
*/
|
|
506
|
+
type NormalizedHexTileOf<TBoard extends AnyHexBoardInput> = Omit<HexTileState<BoardIdOf<TBoard>, BoardSpaceIdOf<TBoard>, HexTilePropertiesOf<TBoard>, HexTileViewOf<TBoard>>, "view"> & {
|
|
507
|
+
view: HexTileViewOf<TBoard>;
|
|
508
|
+
};
|
|
509
|
+
type NormalizedHexEdgeOf<TBoard extends AnyHexBoardInput> = HexEdgeState<BoardIdOf<TBoard>, BoardSpaceIdOf<TBoard>, BoardEdgeIdOf<TBoard>, HexEdgePropertiesOf<TBoard>>;
|
|
510
|
+
type NormalizedHexVertexOf<TBoard extends AnyHexBoardInput> = HexVertexState<BoardIdOf<TBoard>, BoardSpaceIdOf<TBoard>, BoardVertexIdOf<TBoard>, HexVertexPropertiesOf<TBoard>>;
|
|
511
|
+
type NormalizedSquareCellOf<TBoard extends AnySquareBoardInput> = SquareCellState<BoardSpaceIdOf<TBoard>, SquareCellPropertiesOf<TBoard>>;
|
|
512
|
+
type NormalizedSquareEdgeOf<TBoard extends AnySquareBoardInput> = SquareEdgeState<BoardSpaceIdOf<TBoard>, BoardEdgeIdOf<TBoard>, SquareEdgePropertiesOf<TBoard>>;
|
|
513
|
+
type NormalizedSquareVertexOf<TBoard extends AnySquareBoardInput> = SquareVertexState<BoardSpaceIdOf<TBoard>, BoardVertexIdOf<TBoard>, SquareVertexPropertiesOf<TBoard>>;
|
|
514
|
+
type NormalizedSquarePieceOf<TBoard extends AnySquareBoardInput> = SquarePieceState<PieceValueOf<TBoard> extends {
|
|
515
|
+
id: infer PieceIdValue extends string;
|
|
516
|
+
} ? PieceIdValue : string, SquarePiecePropertiesOf<TBoard>>;
|
|
517
|
+
type NormalizedHexBoard<TBoard extends AnyHexBoardInput> = Omit<Pick<HexBoardState<BoardIdOf<TBoard>, BoardSpaceIdOf<TBoard>, BoardEdgeIdOf<TBoard>, BoardVertexIdOf<TBoard>, HexTilePropertiesOf<TBoard>, HexEdgePropertiesOf<TBoard>, HexVertexPropertiesOf<TBoard>>, "id" | "tiles" | "edges" | "vertices">, "tiles"> & {
|
|
518
|
+
tiles: ReadonlyArray<NormalizedHexTileOf<TBoard>>;
|
|
519
|
+
orientation?: "pointy-top" | "flat-top";
|
|
520
|
+
};
|
|
521
|
+
type NormalizedSquareBoard<TBoard extends AnySquareBoardInput> = Pick<SquareBoardState<BoardIdOf<TBoard>, BoardSpaceIdOf<TBoard>, BoardEdgeIdOf<TBoard>, BoardVertexIdOf<TBoard>, PieceValueOf<TBoard> extends {
|
|
522
|
+
id: infer PieceIdValue extends string;
|
|
523
|
+
} ? PieceIdValue : string, SquareCellPropertiesOf<TBoard>, SquareEdgePropertiesOf<TBoard>, SquareVertexPropertiesOf<TBoard>, SquarePiecePropertiesOf<TBoard>>, "id" | "rows" | "cols" | "cells" | "edges" | "vertices" | "pieces">;
|
|
524
|
+
declare function normalizeHexBoardInput<TBoard extends AnyHexBoardInput>(board: TBoard): NormalizedHexBoard<TBoard>;
|
|
525
|
+
declare function normalizeSquareBoardInput<TBoard extends AnySquareBoardInput>(board: TBoard): NormalizedSquareBoard<TBoard>;
|
|
526
|
+
|
|
527
|
+
type BoardTargetKind = "edge" | "vertex" | "space" | "tile";
|
|
528
|
+
interface InteractiveTargetState {
|
|
529
|
+
kind?: BoardTargetKind;
|
|
530
|
+
id: string;
|
|
531
|
+
eligible: boolean;
|
|
532
|
+
selectable: boolean;
|
|
533
|
+
hovered: boolean;
|
|
534
|
+
pending: boolean;
|
|
535
|
+
conflict: boolean;
|
|
536
|
+
unavailableReason?: string;
|
|
537
|
+
select?: () => unknown | Promise<unknown>;
|
|
538
|
+
}
|
|
539
|
+
interface InteractiveTargetLayer {
|
|
540
|
+
enabled?: boolean;
|
|
541
|
+
eligible?: ReadonlySet<string>;
|
|
542
|
+
selectTargetId?: (targetId: string) => unknown | Promise<unknown>;
|
|
543
|
+
targetState?: (targetId: string) => Partial<InteractiveTargetState>;
|
|
544
|
+
}
|
|
545
|
+
interface InteractiveTargetRenderState extends InteractiveTargetState {
|
|
546
|
+
isEnabled: boolean;
|
|
547
|
+
isEligible: boolean;
|
|
548
|
+
isHovered: boolean;
|
|
549
|
+
}
|
|
550
|
+
|
|
551
|
+
type HexOrientation = "pointy-top" | "flat-top";
|
|
552
|
+
/**
|
|
553
|
+
* Geometry context passed to `renderTile`.
|
|
554
|
+
*
|
|
555
|
+
* `corners`, `points`, and `bounds` are expressed in tile-local
|
|
556
|
+
* coordinates because each tile is rendered inside a `<g>` translated
|
|
557
|
+
* to its center. Use `position` if you need the resolved center in the
|
|
558
|
+
* board's absolute SVG coordinates.
|
|
559
|
+
*
|
|
560
|
+
* The `inset` option shrinks the polygon toward the center by that many
|
|
561
|
+
* pixels, which is useful for layered effects such as borders, frames,
|
|
562
|
+
* or inner highlights without re-deriving the hex math yourself.
|
|
563
|
+
*/
|
|
564
|
+
interface HexTileGeometry {
|
|
565
|
+
size: number;
|
|
566
|
+
orientation: HexOrientation;
|
|
567
|
+
center: {
|
|
568
|
+
x: 0;
|
|
569
|
+
y: 0;
|
|
570
|
+
};
|
|
571
|
+
position: {
|
|
572
|
+
x: number;
|
|
573
|
+
y: number;
|
|
574
|
+
};
|
|
575
|
+
corners: (options?: {
|
|
576
|
+
inset?: number;
|
|
577
|
+
}) => Array<{
|
|
578
|
+
x: number;
|
|
579
|
+
y: number;
|
|
580
|
+
}>;
|
|
581
|
+
points: (options?: {
|
|
582
|
+
inset?: number;
|
|
583
|
+
}) => string;
|
|
584
|
+
bounds: {
|
|
585
|
+
minX: number;
|
|
586
|
+
minY: number;
|
|
587
|
+
maxX: number;
|
|
588
|
+
maxY: number;
|
|
589
|
+
width: number;
|
|
590
|
+
height: number;
|
|
591
|
+
};
|
|
592
|
+
}
|
|
593
|
+
interface EdgePosition {
|
|
594
|
+
/** Absolute SVG start point of the visible edge line. */
|
|
595
|
+
x1: number;
|
|
596
|
+
y1: number;
|
|
597
|
+
/** Absolute SVG end point of the visible edge line. */
|
|
598
|
+
x2: number;
|
|
599
|
+
y2: number;
|
|
600
|
+
/** Absolute SVG midpoint of the edge. */
|
|
601
|
+
midX: number;
|
|
602
|
+
midY: number;
|
|
603
|
+
/**
|
|
604
|
+
* Angle in degrees from hex1 center to hex2 center.
|
|
605
|
+
* This is perpendicular to the visible edge line.
|
|
606
|
+
*/
|
|
607
|
+
centerAngle: number;
|
|
608
|
+
/** Angle in degrees of the visible edge line itself. */
|
|
609
|
+
edgeAngle: number;
|
|
610
|
+
}
|
|
611
|
+
interface InteractiveHexVertex<TBoard extends AnyHexBoardInput = AnyHexBoardInput> extends NormalizedHexVertexOf<TBoard> {
|
|
612
|
+
position: {
|
|
613
|
+
x: number;
|
|
614
|
+
y: number;
|
|
615
|
+
};
|
|
616
|
+
spaceIds: ReadonlyArray<BoardSpaceIdOf<TBoard>>;
|
|
617
|
+
}
|
|
618
|
+
interface InteractiveHexEdge<TBoard extends AnyHexBoardInput = AnyHexBoardInput> extends NormalizedHexEdgeOf<TBoard> {
|
|
619
|
+
position: EdgePosition;
|
|
620
|
+
spaceIds: ReadonlyArray<BoardSpaceIdOf<TBoard>>;
|
|
621
|
+
}
|
|
622
|
+
type InteractiveHexSpace<TBoard extends AnyHexBoardInput = AnyHexBoardInput> = NormalizedHexTileOf<TBoard>;
|
|
623
|
+
interface HexGeneratedGridInputProps {
|
|
624
|
+
id?: string;
|
|
625
|
+
layout?: "hex";
|
|
626
|
+
orientation?: HexOrientation;
|
|
627
|
+
spaces: Extract<AnyHexBoardInput, {
|
|
628
|
+
spaces: unknown;
|
|
629
|
+
}>["spaces"];
|
|
630
|
+
edges?: AnyHexBoardInput["edges"];
|
|
631
|
+
vertices?: AnyHexBoardInput["vertices"];
|
|
632
|
+
}
|
|
633
|
+
interface HexAuthoredGridInputProps {
|
|
634
|
+
id?: string;
|
|
635
|
+
layout?: "hex";
|
|
636
|
+
orientation?: HexOrientation;
|
|
637
|
+
tiles: Extract<AnyHexBoardInput, {
|
|
638
|
+
tiles: unknown;
|
|
639
|
+
}>["tiles"];
|
|
640
|
+
edges?: AnyHexBoardInput["edges"];
|
|
641
|
+
vertices?: AnyHexBoardInput["vertices"];
|
|
642
|
+
}
|
|
643
|
+
type HexGridInputProps = HexGeneratedGridInputProps | HexAuthoredGridInputProps;
|
|
644
|
+
type ResolvedArrayProp<Value> = Exclude<Value, undefined> extends readonly unknown[] ? Exclude<Value, undefined> : readonly [];
|
|
645
|
+
type HexBoardLikeOfProps<TProps extends HexGridInputProps> = TProps extends {
|
|
646
|
+
id?: infer Id;
|
|
647
|
+
layout?: infer Layout;
|
|
648
|
+
orientation?: infer Orientation;
|
|
649
|
+
spaces: infer Spaces;
|
|
650
|
+
edges?: infer Edges;
|
|
651
|
+
vertices?: infer Vertices;
|
|
652
|
+
} ? {
|
|
653
|
+
id: Extract<Id, string> extends never ? string : Extract<Id, string>;
|
|
654
|
+
layout?: Extract<Layout, "hex">;
|
|
655
|
+
orientation?: Extract<Orientation, HexOrientation>;
|
|
656
|
+
spaces: Spaces;
|
|
657
|
+
edges: ResolvedArrayProp<Edges>;
|
|
658
|
+
vertices: ResolvedArrayProp<Vertices>;
|
|
659
|
+
} & GeneratedHexBoardInput : TProps extends {
|
|
660
|
+
id?: infer Id;
|
|
661
|
+
layout?: infer Layout;
|
|
662
|
+
orientation?: infer Orientation;
|
|
663
|
+
tiles: infer Tiles;
|
|
664
|
+
edges?: infer Edges;
|
|
665
|
+
vertices?: infer Vertices;
|
|
666
|
+
} ? {
|
|
667
|
+
id: Extract<Id, string> extends never ? string : Extract<Id, string>;
|
|
668
|
+
layout?: Extract<Layout, "hex">;
|
|
669
|
+
orientation?: Extract<Orientation, HexOrientation>;
|
|
670
|
+
tiles: Tiles;
|
|
671
|
+
edges: ResolvedArrayProp<Edges>;
|
|
672
|
+
vertices: ResolvedArrayProp<Vertices>;
|
|
673
|
+
} & AuthoredHexBoardInput : never;
|
|
674
|
+
type HexGridProps<TProps extends HexGridInputProps = HexGridInputProps> = TProps & {
|
|
675
|
+
orientation?: HexOrientation;
|
|
676
|
+
/** Hex radius in pixels */
|
|
677
|
+
hexSize?: number;
|
|
678
|
+
/**
|
|
679
|
+
* Receives tile data centered at (0,0) plus a `HexTileGeometry`
|
|
680
|
+
* helper. Use `geometry.points({ inset })` to draw custom polygons
|
|
681
|
+
* without duplicating `hexSize` / orientation in the consumer.
|
|
682
|
+
*/
|
|
683
|
+
renderTile: (tile: NormalizedHexTileOf<NoInfer<HexBoardLikeOfProps<TProps>>>, geometry: HexTileGeometry) => ReactNode;
|
|
684
|
+
/**
|
|
685
|
+
* Receives edge geometry in absolute SVG coordinates.
|
|
686
|
+
* Use `position.edgeAngle` to align artwork with the visible edge.
|
|
687
|
+
*/
|
|
688
|
+
renderEdge: (edge: NormalizedHexEdgeOf<NoInfer<HexBoardLikeOfProps<TProps>>>, position: EdgePosition) => ReactNode;
|
|
689
|
+
renderVertex: (vertex: NormalizedHexVertexOf<NoInfer<HexBoardLikeOfProps<TProps>>>, position: {
|
|
690
|
+
x: number;
|
|
691
|
+
y: number;
|
|
692
|
+
}) => ReactNode;
|
|
693
|
+
width?: number | string;
|
|
694
|
+
height?: number | string;
|
|
695
|
+
enablePanZoom?: boolean;
|
|
696
|
+
initialZoom?: number;
|
|
697
|
+
minZoom?: number;
|
|
698
|
+
maxZoom?: number;
|
|
699
|
+
className?: string;
|
|
700
|
+
/** Reducer-aware space target layer from `board.targetLayers.space(...)`. */
|
|
701
|
+
interactiveSpaces?: InteractiveTargetLayer;
|
|
702
|
+
/** Reducer-aware vertex target layer from `board.targetLayers.vertex(...)`. */
|
|
703
|
+
interactiveVertices?: InteractiveTargetLayer;
|
|
704
|
+
/** Reducer-aware edge target layer from `board.targetLayers.edge(...)`. */
|
|
705
|
+
interactiveEdges?: InteractiveTargetLayer;
|
|
706
|
+
/** Receives space geometry centered at (0,0). */
|
|
707
|
+
renderInteractiveSpace?: (space: InteractiveHexSpace<NoInfer<HexBoardLikeOfProps<TProps>>>, state: InteractiveTargetRenderState) => ReactNode;
|
|
708
|
+
/**
|
|
709
|
+
* Receives vertex geometry in absolute SVG coordinates.
|
|
710
|
+
*/
|
|
711
|
+
renderInteractiveVertex?: (vertex: InteractiveHexVertex<NoInfer<HexBoardLikeOfProps<TProps>>>, position: {
|
|
712
|
+
x: number;
|
|
713
|
+
y: number;
|
|
714
|
+
}, state: InteractiveTargetRenderState) => ReactNode;
|
|
715
|
+
/**
|
|
716
|
+
* Receives edge geometry in the same absolute SVG coordinates as `renderEdge`.
|
|
717
|
+
*/
|
|
718
|
+
renderInteractiveEdge?: (edge: InteractiveHexEdge<NoInfer<HexBoardLikeOfProps<TProps>>>, position: EdgePosition, state: InteractiveTargetRenderState) => ReactNode;
|
|
719
|
+
interactiveVertexSize?: number;
|
|
720
|
+
interactiveEdgeSize?: number;
|
|
721
|
+
};
|
|
722
|
+
interface HexGridBoardProps<TBoard extends AnyHexBoardInput = AnyHexBoardInput> {
|
|
723
|
+
board: TBoard;
|
|
724
|
+
orientation?: HexOrientation;
|
|
725
|
+
hexSize?: number;
|
|
726
|
+
/**
|
|
727
|
+
* Receives tile data centered at (0,0) plus a `HexTileGeometry`
|
|
728
|
+
* helper. Use `geometry.points({ inset })` to draw custom polygons
|
|
729
|
+
* without duplicating `hexSize` / orientation in the consumer.
|
|
730
|
+
*/
|
|
731
|
+
renderTile: (tile: NormalizedHexTileOf<NoInfer<TBoard>>, geometry: HexTileGeometry) => ReactNode;
|
|
732
|
+
/**
|
|
733
|
+
* Receives edge geometry in absolute SVG coordinates.
|
|
734
|
+
* Use `position.edgeAngle` to align artwork with the visible edge.
|
|
735
|
+
*/
|
|
736
|
+
renderEdge: (edge: NormalizedHexEdgeOf<NoInfer<TBoard>>, position: EdgePosition) => ReactNode;
|
|
737
|
+
renderVertex: (vertex: NormalizedHexVertexOf<NoInfer<TBoard>>, position: {
|
|
738
|
+
x: number;
|
|
739
|
+
y: number;
|
|
740
|
+
}) => ReactNode;
|
|
741
|
+
width?: number | string;
|
|
742
|
+
height?: number | string;
|
|
743
|
+
enablePanZoom?: boolean;
|
|
744
|
+
initialZoom?: number;
|
|
745
|
+
minZoom?: number;
|
|
746
|
+
maxZoom?: number;
|
|
747
|
+
className?: string;
|
|
748
|
+
interactiveSpaces?: InteractiveTargetLayer;
|
|
749
|
+
interactiveVertices?: InteractiveTargetLayer;
|
|
750
|
+
interactiveEdges?: InteractiveTargetLayer;
|
|
751
|
+
/** Receives space geometry centered at (0,0). */
|
|
752
|
+
renderInteractiveSpace?: (space: InteractiveHexSpace<NoInfer<TBoard>>, state: InteractiveTargetRenderState) => ReactNode;
|
|
753
|
+
/**
|
|
754
|
+
* Receives vertex geometry in absolute SVG coordinates.
|
|
755
|
+
*/
|
|
756
|
+
renderInteractiveVertex?: (vertex: InteractiveHexVertex<NoInfer<TBoard>>, position: {
|
|
757
|
+
x: number;
|
|
758
|
+
y: number;
|
|
759
|
+
}, state: InteractiveTargetRenderState) => ReactNode;
|
|
760
|
+
/**
|
|
761
|
+
* Receives edge geometry in the same absolute SVG coordinates as `renderEdge`.
|
|
762
|
+
*/
|
|
763
|
+
renderInteractiveEdge?: (edge: InteractiveHexEdge<NoInfer<TBoard>>, position: EdgePosition, state: InteractiveTargetRenderState) => ReactNode;
|
|
764
|
+
interactiveVertexSize?: number;
|
|
765
|
+
interactiveEdgeSize?: number;
|
|
766
|
+
}
|
|
767
|
+
interface DefaultHexTileProps {
|
|
768
|
+
/** Should match hexSize from HexGrid */
|
|
769
|
+
size: number;
|
|
770
|
+
fill: string;
|
|
771
|
+
stroke?: string;
|
|
772
|
+
strokeWidth?: number;
|
|
773
|
+
isSelected?: boolean;
|
|
774
|
+
isHighlighted?: boolean;
|
|
775
|
+
label?: string;
|
|
776
|
+
showCoordinates?: boolean;
|
|
777
|
+
coordinates?: {
|
|
778
|
+
q: number;
|
|
779
|
+
r: number;
|
|
780
|
+
};
|
|
781
|
+
orientation?: HexOrientation;
|
|
782
|
+
onClick?: () => void;
|
|
783
|
+
onPointerEnter?: () => void;
|
|
784
|
+
onPointerLeave?: () => void;
|
|
785
|
+
className?: string;
|
|
786
|
+
}
|
|
787
|
+
/** Pre-built hexagon tile for use in `renderTile`. */
|
|
788
|
+
declare function DefaultHexTile({ size, fill, stroke, strokeWidth, isSelected, isHighlighted, label, showCoordinates, coordinates, orientation, onClick, onPointerEnter, onPointerLeave, className, }: DefaultHexTileProps): react_jsx_runtime.JSX.Element;
|
|
789
|
+
interface DefaultHexEdgeProps {
|
|
790
|
+
position: EdgePosition;
|
|
791
|
+
color: string;
|
|
792
|
+
hasOwner?: boolean;
|
|
793
|
+
strokeWidth?: number;
|
|
794
|
+
touchTargetSize?: number;
|
|
795
|
+
onClick?: () => void;
|
|
796
|
+
className?: string;
|
|
797
|
+
}
|
|
798
|
+
/** Pre-built edge/road component for use in `renderEdge`. */
|
|
799
|
+
declare function DefaultHexEdge({ position, color, hasOwner, strokeWidth, touchTargetSize, onClick, className, }: DefaultHexEdgeProps): react_jsx_runtime.JSX.Element;
|
|
800
|
+
interface DefaultHexVertexProps {
|
|
801
|
+
position: {
|
|
802
|
+
x: number;
|
|
803
|
+
y: number;
|
|
804
|
+
};
|
|
805
|
+
color: string;
|
|
806
|
+
stroke?: string;
|
|
807
|
+
strokeWidth?: number;
|
|
808
|
+
hasOwner?: boolean;
|
|
809
|
+
isSelected?: boolean;
|
|
810
|
+
isHighlighted?: boolean;
|
|
811
|
+
size?: number;
|
|
812
|
+
touchTargetSize?: number;
|
|
813
|
+
shape?: "circle" | "square";
|
|
814
|
+
onClick?: () => void;
|
|
815
|
+
onPointerEnter?: () => void;
|
|
816
|
+
onPointerLeave?: () => void;
|
|
817
|
+
className?: string;
|
|
818
|
+
}
|
|
819
|
+
/** Pre-built vertex/settlement component for use in `renderVertex`. */
|
|
820
|
+
declare function DefaultHexVertex({ position, color, stroke, strokeWidth, hasOwner, isSelected, isHighlighted, size, touchTargetSize, shape, onClick, onPointerEnter, onPointerLeave, className, }: DefaultHexVertexProps): react_jsx_runtime.JSX.Element;
|
|
821
|
+
declare const hexUtils: {
|
|
822
|
+
/** Convert axial coordinates to pixel position. */
|
|
823
|
+
axialToPixel(q: number, r: number, size: number, orientation: HexOrientation): {
|
|
824
|
+
x: number;
|
|
825
|
+
y: number;
|
|
826
|
+
};
|
|
827
|
+
getNeighbors(q: number, r: number): Array<{
|
|
828
|
+
q: number;
|
|
829
|
+
r: number;
|
|
830
|
+
}>;
|
|
831
|
+
getDistance(q1: number, r1: number, q2: number, r2: number): number;
|
|
832
|
+
getHexCorners(centerX: number, centerY: number, size: number, orientation: HexOrientation): Array<{
|
|
833
|
+
x: number;
|
|
834
|
+
y: number;
|
|
835
|
+
}>;
|
|
836
|
+
getHexPoints(centerX: number, centerY: number, size: number, orientation: HexOrientation): string;
|
|
837
|
+
getEdgePosition(hex1Pos: {
|
|
838
|
+
x: number;
|
|
839
|
+
y: number;
|
|
840
|
+
}, hex2Pos: {
|
|
841
|
+
x: number;
|
|
842
|
+
y: number;
|
|
843
|
+
}, size: number): EdgePosition;
|
|
844
|
+
getVertexPosition(hex1Pos: {
|
|
845
|
+
x: number;
|
|
846
|
+
y: number;
|
|
847
|
+
}, hex2Pos: {
|
|
848
|
+
x: number;
|
|
849
|
+
y: number;
|
|
850
|
+
}, hex3Pos: {
|
|
851
|
+
x: number;
|
|
852
|
+
y: number;
|
|
853
|
+
}): {
|
|
854
|
+
x: number;
|
|
855
|
+
y: number;
|
|
856
|
+
};
|
|
857
|
+
};
|
|
858
|
+
interface HexGridComponent {
|
|
859
|
+
<const TBoard extends AnyHexBoardInput>(props: HexGridBoardProps<TBoard>): ReactNode;
|
|
860
|
+
<const TProps extends HexGeneratedGridInputProps>(props: HexGridProps<TProps>): ReactNode;
|
|
861
|
+
<const TProps extends HexAuthoredGridInputProps>(props: HexGridProps<TProps>): ReactNode;
|
|
862
|
+
}
|
|
863
|
+
declare const HexGrid: HexGridComponent;
|
|
864
|
+
|
|
865
|
+
/**
|
|
866
|
+
* Typed adapter for joining static hex-board topology with a dynamic
|
|
867
|
+
* per-space view overlay. Use this to feed `HexGrid` a single board
|
|
868
|
+
* value whose tiles carry both static geometry (`q`, `r`, `id`) and
|
|
869
|
+
* the projected view fields the UI cares about (e.g. `terrain`,
|
|
870
|
+
* `numberToken`).
|
|
871
|
+
*
|
|
872
|
+
* The runtime is intentionally strict: every static space must have
|
|
873
|
+
* exactly one overlay, duplicates throw, and overlays for ids that
|
|
874
|
+
* are not on the board throw. There is no relaxed fallback in v1 —
|
|
875
|
+
* silent merge bugs are far more expensive than a loud throw at
|
|
876
|
+
* dev/CI time.
|
|
877
|
+
*/
|
|
878
|
+
|
|
879
|
+
/**
|
|
880
|
+
* Per-tile result produced by {@link createHexBoardView}. Each tile
|
|
881
|
+
* carries the static topology (`id`, `q`, `r`) plus the matched
|
|
882
|
+
* overlay row in `view`.
|
|
883
|
+
*
|
|
884
|
+
* Static board fields/properties are preserved from `TBoard`.
|
|
885
|
+
* Consumers should use `tile.properties` for authored static space
|
|
886
|
+
* fields and `tile.view` for dynamic per-space projection data.
|
|
887
|
+
*/
|
|
888
|
+
type HexBoardViewTile<TBoard extends AnyHexBoardInput, TSpaceView extends {
|
|
889
|
+
id: BoardSpaceIdOf<TBoard>;
|
|
890
|
+
}> = Omit<NormalizedHexTileOf<TBoard>, "view"> & {
|
|
891
|
+
view: TSpaceView;
|
|
892
|
+
};
|
|
893
|
+
/**
|
|
894
|
+
* Result of {@link createHexBoardView}. Shaped like an authored hex
|
|
895
|
+
* board so it can be passed straight to `<HexGrid board={...} />`
|
|
896
|
+
* without any further adapter work.
|
|
897
|
+
*
|
|
898
|
+
* The type-level board id and space id are preserved from `TBoard`,
|
|
899
|
+
* so `tile.id` stays narrow inside `renderTile`. `tile.view` is the
|
|
900
|
+
* authored overlay row, fully typed.
|
|
901
|
+
*/
|
|
902
|
+
interface HexBoardView<TBoard extends AnyHexBoardInput, TSpaceView extends {
|
|
903
|
+
id: BoardSpaceIdOf<TBoard>;
|
|
904
|
+
}> {
|
|
905
|
+
id: BoardIdOf<TBoard>;
|
|
906
|
+
layout?: "hex";
|
|
907
|
+
orientation?: "pointy-top" | "flat-top";
|
|
908
|
+
tiles: ReadonlyArray<HexBoardViewTile<TBoard, TSpaceView>>;
|
|
909
|
+
edges: TBoard["edges"];
|
|
910
|
+
vertices: TBoard["vertices"];
|
|
911
|
+
}
|
|
912
|
+
interface CreateHexBoardViewOptions<TSpaceView> {
|
|
913
|
+
spaces: readonly TSpaceView[];
|
|
914
|
+
}
|
|
915
|
+
/**
|
|
916
|
+
* Join a static hex board topology with a dynamic per-space overlay.
|
|
917
|
+
*
|
|
918
|
+
* The result is suitable for direct use as the `board` prop on
|
|
919
|
+
* `<HexGrid>`. Every overlay is enforced 1-to-1 against the board's
|
|
920
|
+
* spaces:
|
|
921
|
+
*
|
|
922
|
+
* - missing overlay for a board space → throws
|
|
923
|
+
* - duplicate overlay (same `id` twice) → throws
|
|
924
|
+
* - overlay `id` not present on the board → throws
|
|
925
|
+
*
|
|
926
|
+
* Each tile in the result carries a `view` field with the matched
|
|
927
|
+
* overlay row.
|
|
928
|
+
*/
|
|
929
|
+
declare function createHexBoardView<const TBoard extends AnyHexBoardInput, const TSpaceView extends {
|
|
930
|
+
id: BoardSpaceIdOf<TBoard>;
|
|
931
|
+
}>(board: TBoard, options: CreateHexBoardViewOptions<TSpaceView>): HexBoardView<TBoard, TSpaceView>;
|
|
932
|
+
|
|
933
|
+
export { type ThemeMeta as $, type AnyHexBoardInput as A, type BoardEdgeIdOf as B, type ColorRamp as C, DefaultHexEdge as D, type EdgePosition as E, type FoundationColor as F, type GeneratedHexBoardInput as G, type HexBoardInput as H, type IntentColor as I, type InteractiveTargetLayer as J, type InteractiveTargetRenderState as K, type NormalizedHexEdgeOf as L, type Motion as M, type NormalizedHexBoard as N, type NormalizedHexTileOf as O, type NormalizedHexVertexOf as P, type NormalizedSquareBoard as Q, type NormalizedSquareCellOf as R, type NormalizedSquareEdgeOf as S, type NormalizedSquarePieceOf as T, type NormalizedSquareVertexOf as U, type PlayerColor as V, type Radius as W, type SemanticColor as X, type Space as Y, type SquareBoardInput as Z, type Theme as _, type AnySquareBoardInput as a, type ThemeOverride as a0, type Typography as a1, createHexBoardView as a2, hexUtils as a3, mergeTheme as a4, normalizeHexBoardInput as a5, normalizeSquareBoardInput as a6, type AuthoredHexBoardInput as b, type AuthoredSquareBoardInput as c, type BoardSpaceIdOf as d, type BoardVertexIdOf as e, type ComponentTokens as f, type DefaultHexEdgeProps as g, DefaultHexTile as h, type DefaultHexTileProps as i, DefaultHexVertex as j, type DefaultHexVertexProps as k, type Elevation as l, type GeneratedHexSpaceStateLike as m, type GeneratedSquareBoardInput as n, type GeneratedSquareSpaceStateLike as o, type GeneratedTiledEdgeStateLike as p, type GeneratedTiledVertexStateLike as q, type HexBoardView as r, type HexBoardViewTile as s, HexGrid as t, type HexGridBoardProps as u, type HexGridProps as v, type HexOrientation as w, type HexTileGeometry as x, type InteractiveHexEdge as y, type InteractiveHexVertex as z };
|