@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,1072 @@
|
|
|
1
|
+
import type { z } from "zod";
|
|
2
|
+
import type { RuntimeTableRecord, SchemaLike } from "./table";
|
|
3
|
+
import type {
|
|
4
|
+
InitContext,
|
|
5
|
+
ReducerManifestContract,
|
|
6
|
+
SetupProfileDefinition,
|
|
7
|
+
StateDefinition,
|
|
8
|
+
} from "./manifest";
|
|
9
|
+
import type {
|
|
10
|
+
ExactManifestContractOf,
|
|
11
|
+
HiddenSchemaOfContract,
|
|
12
|
+
ManifestContractOf,
|
|
13
|
+
ManifestOf,
|
|
14
|
+
PhaseNameOfContract,
|
|
15
|
+
PhaseStateMapOfContract,
|
|
16
|
+
PlayerIdOfTable,
|
|
17
|
+
PrivateSchemaOfContract,
|
|
18
|
+
PublicSchemaOfContract,
|
|
19
|
+
RuntimeSetupSelection,
|
|
20
|
+
TableOfManifest,
|
|
21
|
+
} from "./extract";
|
|
22
|
+
import type {
|
|
23
|
+
ReducerGameState,
|
|
24
|
+
ReducerSessionState,
|
|
25
|
+
RuntimePhaseState,
|
|
26
|
+
} from "./runtime";
|
|
27
|
+
import type {
|
|
28
|
+
EffectMap,
|
|
29
|
+
CardActionMap,
|
|
30
|
+
CardActionSpec,
|
|
31
|
+
InputCollector,
|
|
32
|
+
InteractionMap,
|
|
33
|
+
InteractionSpec,
|
|
34
|
+
PhaseDefinition,
|
|
35
|
+
PhaseZoneList,
|
|
36
|
+
SimultaneousSubmitSpec,
|
|
37
|
+
StageMap,
|
|
38
|
+
StaticViewDefinition,
|
|
39
|
+
ViewDefinition,
|
|
40
|
+
} from "./spec";
|
|
41
|
+
|
|
42
|
+
export type ReducerGameContract<
|
|
43
|
+
Table extends RuntimeTableRecord,
|
|
44
|
+
Manifest extends ReducerManifestContract<
|
|
45
|
+
Table,
|
|
46
|
+
string,
|
|
47
|
+
string,
|
|
48
|
+
string,
|
|
49
|
+
string,
|
|
50
|
+
string
|
|
51
|
+
>,
|
|
52
|
+
PublicSchema extends SchemaLike<object>,
|
|
53
|
+
PrivateSchema extends SchemaLike<object>,
|
|
54
|
+
HiddenSchema extends SchemaLike<object>,
|
|
55
|
+
Phases extends Record<string, SchemaLike<object>>,
|
|
56
|
+
> = {
|
|
57
|
+
manifest: Manifest;
|
|
58
|
+
state: StateDefinition<PublicSchema, PrivateSchema, HiddenSchema>;
|
|
59
|
+
phases: Phases;
|
|
60
|
+
/** Derived from `phases`; retained as an internal runtime convenience. */
|
|
61
|
+
phaseNames: readonly string[];
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
export type ReducerStateForConfig<
|
|
65
|
+
Table extends RuntimeTableRecord,
|
|
66
|
+
PublicSchema extends SchemaLike<object>,
|
|
67
|
+
PrivateSchema extends SchemaLike<object>,
|
|
68
|
+
HiddenSchema extends SchemaLike<object>,
|
|
69
|
+
PhaseName extends string,
|
|
70
|
+
> = ReducerGameState<
|
|
71
|
+
Table,
|
|
72
|
+
z.infer<PublicSchema>,
|
|
73
|
+
z.infer<PrivateSchema>,
|
|
74
|
+
z.infer<HiddenSchema>,
|
|
75
|
+
RuntimePhaseState,
|
|
76
|
+
PhaseName,
|
|
77
|
+
Record<PhaseName, RuntimePhaseState>
|
|
78
|
+
>;
|
|
79
|
+
|
|
80
|
+
export type ReducerSessionForConfig<
|
|
81
|
+
Table extends RuntimeTableRecord,
|
|
82
|
+
PublicSchema extends SchemaLike<object>,
|
|
83
|
+
PrivateSchema extends SchemaLike<object>,
|
|
84
|
+
HiddenSchema extends SchemaLike<object>,
|
|
85
|
+
PhaseName extends string,
|
|
86
|
+
Setup extends RuntimeSetupSelection = RuntimeSetupSelection,
|
|
87
|
+
> = ReducerSessionState<
|
|
88
|
+
ReducerStateForConfig<
|
|
89
|
+
Table,
|
|
90
|
+
PublicSchema,
|
|
91
|
+
PrivateSchema,
|
|
92
|
+
HiddenSchema,
|
|
93
|
+
PhaseName
|
|
94
|
+
>,
|
|
95
|
+
Setup
|
|
96
|
+
>;
|
|
97
|
+
|
|
98
|
+
export type BaseGameStateOfContract<Contract> = ReducerGameState<
|
|
99
|
+
TableOfManifest<ManifestContractOf<Contract>>,
|
|
100
|
+
z.infer<PublicSchemaOfContract<Contract>>,
|
|
101
|
+
z.infer<PrivateSchemaOfContract<Contract>>,
|
|
102
|
+
z.infer<HiddenSchemaOfContract<Contract>>,
|
|
103
|
+
PhaseStateMapOfContract<Contract>[PhaseNameOfContract<Contract>],
|
|
104
|
+
PhaseNameOfContract<Contract>,
|
|
105
|
+
PhaseStateMapOfContract<Contract>
|
|
106
|
+
>;
|
|
107
|
+
|
|
108
|
+
export type BaseGameSessionOfContract<Contract> = ReducerSessionState<
|
|
109
|
+
BaseGameStateOfContract<Contract>,
|
|
110
|
+
RuntimeSetupSelection<ManifestContractOf<Contract>>
|
|
111
|
+
>;
|
|
112
|
+
|
|
113
|
+
/**
|
|
114
|
+
* Heterogeneous phase map for a contract. Each phase carries its own local
|
|
115
|
+
* `PhaseStateSchema` plus authoring-time Actions/Flows/Interactions/
|
|
116
|
+
* Stages/Zones maps. The registries are bound to the contract's base state +
|
|
117
|
+
* manifest so the runtime can iterate them through a single index type
|
|
118
|
+
* without reaching for `any`.
|
|
119
|
+
*/
|
|
120
|
+
export type PhaseMapOf<Contract> = {
|
|
121
|
+
[Name in PhaseNameOfContract<Contract>]: PhaseDefinition<
|
|
122
|
+
SchemaLike<object>,
|
|
123
|
+
BaseGameStateOfContract<Contract>,
|
|
124
|
+
ManifestContractOf<Contract>,
|
|
125
|
+
Record<string, InputCollector>,
|
|
126
|
+
EffectMap<BaseGameStateOfContract<Contract>, ManifestContractOf<Contract>>,
|
|
127
|
+
InteractionMap<
|
|
128
|
+
BaseGameStateOfContract<Contract>,
|
|
129
|
+
ManifestContractOf<Contract>
|
|
130
|
+
>,
|
|
131
|
+
StageMap<BaseGameStateOfContract<Contract>, ManifestContractOf<Contract>>,
|
|
132
|
+
PhaseZoneList<ManifestContractOf<Contract>>,
|
|
133
|
+
CardActionMap<
|
|
134
|
+
BaseGameStateOfContract<Contract>,
|
|
135
|
+
ManifestContractOf<Contract>
|
|
136
|
+
>
|
|
137
|
+
>;
|
|
138
|
+
};
|
|
139
|
+
|
|
140
|
+
export type AnyPhaseDefinitionForContract<Contract> =
|
|
141
|
+
PhaseMapOf<Contract>[PhaseNameOfContract<Contract>];
|
|
142
|
+
|
|
143
|
+
/**
|
|
144
|
+
* Helpers below accept heterogeneous phase maps (each phase binds its own
|
|
145
|
+
* `PhaseStateSchema` + per-phase registries). TypeScript requires the
|
|
146
|
+
* constraint to use a shape compatible with contract-bound state types in a
|
|
147
|
+
* contravariant `initialState` position, so we erase the registry-bound
|
|
148
|
+
* state/manifest generics with `any`. The only purpose of the constraint is
|
|
149
|
+
* to guarantee `Definitions[Name]` is a `PhaseDefinition` so the `extends`
|
|
150
|
+
* check below can infer `PhaseStateSchema`.
|
|
151
|
+
*/
|
|
152
|
+
|
|
153
|
+
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
154
|
+
export type PhaseStateMapOfDefinitions<
|
|
155
|
+
Definitions extends Record<
|
|
156
|
+
string,
|
|
157
|
+
PhaseDefinition<
|
|
158
|
+
SchemaLike<object>,
|
|
159
|
+
any,
|
|
160
|
+
any,
|
|
161
|
+
Record<string, InputCollector>,
|
|
162
|
+
EffectMap<any, any>,
|
|
163
|
+
InteractionMap<any, any>,
|
|
164
|
+
StageMap<any, any>,
|
|
165
|
+
PhaseZoneList<any>,
|
|
166
|
+
CardActionMap<any, any>
|
|
167
|
+
>
|
|
168
|
+
>,
|
|
169
|
+
> = Partial<{
|
|
170
|
+
[Name in keyof Definitions &
|
|
171
|
+
string]: Definitions[Name] extends PhaseDefinition<
|
|
172
|
+
infer PhaseStateSchema,
|
|
173
|
+
infer _State,
|
|
174
|
+
infer _Manifest
|
|
175
|
+
>
|
|
176
|
+
? z.infer<PhaseStateSchema>
|
|
177
|
+
: never;
|
|
178
|
+
}>;
|
|
179
|
+
|
|
180
|
+
export type PhaseStateOfDefinitions<
|
|
181
|
+
Definitions extends Record<
|
|
182
|
+
string,
|
|
183
|
+
PhaseDefinition<
|
|
184
|
+
SchemaLike<object>,
|
|
185
|
+
any,
|
|
186
|
+
any,
|
|
187
|
+
Record<string, InputCollector>,
|
|
188
|
+
EffectMap<any, any>,
|
|
189
|
+
InteractionMap<any, any>,
|
|
190
|
+
StageMap<any, any>,
|
|
191
|
+
PhaseZoneList<any>,
|
|
192
|
+
CardActionMap<any, any>
|
|
193
|
+
>
|
|
194
|
+
>,
|
|
195
|
+
> = {
|
|
196
|
+
[Name in keyof Definitions &
|
|
197
|
+
string]: Definitions[Name] extends PhaseDefinition<
|
|
198
|
+
infer PhaseStateSchema,
|
|
199
|
+
infer _State,
|
|
200
|
+
infer _Manifest
|
|
201
|
+
>
|
|
202
|
+
? z.infer<PhaseStateSchema>
|
|
203
|
+
: never;
|
|
204
|
+
}[keyof Definitions & string];
|
|
205
|
+
/* eslint-enable @typescript-eslint/no-explicit-any */
|
|
206
|
+
|
|
207
|
+
export type ResolvedGameStateOf<
|
|
208
|
+
Contract,
|
|
209
|
+
Definitions extends PhaseMapOf<Contract>,
|
|
210
|
+
> = {
|
|
211
|
+
[Name in keyof Definitions & string]: ReducerGameState<
|
|
212
|
+
TableOfManifest<ManifestContractOf<Contract>>,
|
|
213
|
+
z.infer<PublicSchemaOfContract<Contract>>,
|
|
214
|
+
z.infer<PrivateSchemaOfContract<Contract>>,
|
|
215
|
+
z.infer<HiddenSchemaOfContract<Contract>>,
|
|
216
|
+
Definitions[Name] extends PhaseDefinition<
|
|
217
|
+
infer PhaseStateSchema,
|
|
218
|
+
infer _State,
|
|
219
|
+
infer _Manifest
|
|
220
|
+
>
|
|
221
|
+
? z.infer<PhaseStateSchema>
|
|
222
|
+
: never,
|
|
223
|
+
PhaseNameOfContract<Contract>
|
|
224
|
+
> & {
|
|
225
|
+
flow: ReducerGameState<
|
|
226
|
+
TableOfManifest<ManifestContractOf<Contract>>,
|
|
227
|
+
z.infer<PublicSchemaOfContract<Contract>>,
|
|
228
|
+
z.infer<PrivateSchemaOfContract<Contract>>,
|
|
229
|
+
z.infer<HiddenSchemaOfContract<Contract>>,
|
|
230
|
+
PhaseStateOfDefinitions<Definitions>,
|
|
231
|
+
PhaseNameOfContract<Contract>
|
|
232
|
+
>["flow"] & {
|
|
233
|
+
currentPhase: Name;
|
|
234
|
+
};
|
|
235
|
+
};
|
|
236
|
+
}[keyof Definitions & string];
|
|
237
|
+
|
|
238
|
+
export type ResolvedGameSessionOf<
|
|
239
|
+
Contract,
|
|
240
|
+
Definitions extends PhaseMapOf<Contract>,
|
|
241
|
+
> = ReducerSessionState<
|
|
242
|
+
ResolvedGameStateOf<Contract, Definitions>,
|
|
243
|
+
RuntimeSetupSelection<ManifestContractOf<Contract>>
|
|
244
|
+
>;
|
|
245
|
+
|
|
246
|
+
export type ViewMapOf<Contract> = Record<
|
|
247
|
+
string,
|
|
248
|
+
ViewDefinition<
|
|
249
|
+
BaseGameStateOfContract<Contract>,
|
|
250
|
+
ManifestContractOf<Contract>,
|
|
251
|
+
unknown
|
|
252
|
+
>
|
|
253
|
+
>;
|
|
254
|
+
|
|
255
|
+
type PhasesOfDefinition<Definition> = Definition extends {
|
|
256
|
+
phases: infer Definitions extends Record<string, unknown>;
|
|
257
|
+
}
|
|
258
|
+
? Definitions
|
|
259
|
+
: never;
|
|
260
|
+
|
|
261
|
+
export type ViewsOfDefinition<Definition> = Definition extends {
|
|
262
|
+
views?: infer Views;
|
|
263
|
+
}
|
|
264
|
+
? NonNullable<Views>
|
|
265
|
+
: never;
|
|
266
|
+
|
|
267
|
+
type NonNeverKeys<Registry> = {
|
|
268
|
+
[Key in keyof Registry]-?: [Registry[Key]] extends [never] ? never : Key;
|
|
269
|
+
}[keyof Registry];
|
|
270
|
+
|
|
271
|
+
export type ViewNamesOfDefinition<Definition> = NonNeverKeys<
|
|
272
|
+
ViewsOfDefinition<Definition>
|
|
273
|
+
> &
|
|
274
|
+
string;
|
|
275
|
+
|
|
276
|
+
export type ViewDefinitionByName<
|
|
277
|
+
Definition,
|
|
278
|
+
ViewName extends ViewNamesOfDefinition<Definition>,
|
|
279
|
+
> = ViewsOfDefinition<Definition>[ViewName];
|
|
280
|
+
|
|
281
|
+
export type ViewOfDefinition<
|
|
282
|
+
Definition,
|
|
283
|
+
ViewName extends ViewNamesOfDefinition<Definition>,
|
|
284
|
+
> =
|
|
285
|
+
ViewDefinitionByName<Definition, ViewName> extends ViewDefinition<
|
|
286
|
+
infer _State,
|
|
287
|
+
infer _Manifest,
|
|
288
|
+
infer Projection
|
|
289
|
+
>
|
|
290
|
+
? Projection
|
|
291
|
+
: never;
|
|
292
|
+
|
|
293
|
+
export type PhaseNamesOfDefinition<Definition> =
|
|
294
|
+
keyof PhasesOfDefinition<Definition> & string;
|
|
295
|
+
|
|
296
|
+
export type PhaseDefinitionByName<
|
|
297
|
+
Definition,
|
|
298
|
+
PhaseName extends PhaseNamesOfDefinition<Definition>,
|
|
299
|
+
> = PhaseName extends keyof PhasesOfDefinition<Definition> & string
|
|
300
|
+
? PhasesOfDefinition<Definition>[PhaseName]
|
|
301
|
+
: never;
|
|
302
|
+
|
|
303
|
+
type EffectsOfDefinition<Definition> =
|
|
304
|
+
PhasesOfDefinition<Definition>[keyof PhasesOfDefinition<Definition> &
|
|
305
|
+
string] extends {
|
|
306
|
+
effects?: infer Effects;
|
|
307
|
+
}
|
|
308
|
+
? Effects extends Record<string, unknown>
|
|
309
|
+
? Effects[keyof Effects & string]
|
|
310
|
+
: never
|
|
311
|
+
: never;
|
|
312
|
+
|
|
313
|
+
export type EffectIdsOfDefinition<Definition> =
|
|
314
|
+
EffectsOfDefinition<Definition> extends infer Effect
|
|
315
|
+
? Effect extends { id: infer Id }
|
|
316
|
+
? Extract<Id, string>
|
|
317
|
+
: never
|
|
318
|
+
: never;
|
|
319
|
+
|
|
320
|
+
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
321
|
+
export type GameStateOf<Source> =
|
|
322
|
+
Source extends ReducerGameDefinition<
|
|
323
|
+
infer Contract,
|
|
324
|
+
infer Definitions,
|
|
325
|
+
infer _Views
|
|
326
|
+
>
|
|
327
|
+
? ResolvedGameStateOf<Contract, Definitions>
|
|
328
|
+
: Source extends ReducerGameContract<any, any, any, any, any, any>
|
|
329
|
+
? BaseGameStateOfContract<Source>
|
|
330
|
+
: never;
|
|
331
|
+
/* eslint-enable @typescript-eslint/no-explicit-any */
|
|
332
|
+
|
|
333
|
+
/**
|
|
334
|
+
* Public structural upper bound for a reducer game contract.
|
|
335
|
+
*
|
|
336
|
+
* The `manifest` slot is intentionally erased with `any` because concrete
|
|
337
|
+
* manifests bind per-contract branded literals (e.g. `PlayerId` unions with
|
|
338
|
+
* specific string literals). Using a ground `ManifestContract<...>` type
|
|
339
|
+
* here would prevent assignability from contract-bound manifests in a
|
|
340
|
+
* contravariant position.
|
|
341
|
+
*/
|
|
342
|
+
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
343
|
+
export type ReducerGameContractLike = {
|
|
344
|
+
manifest: any;
|
|
345
|
+
state: StateDefinition<
|
|
346
|
+
SchemaLike<object>,
|
|
347
|
+
SchemaLike<object>,
|
|
348
|
+
SchemaLike<object>
|
|
349
|
+
>;
|
|
350
|
+
};
|
|
351
|
+
/* eslint-enable @typescript-eslint/no-explicit-any */
|
|
352
|
+
|
|
353
|
+
type InitialStateContextOf<Contract extends ReducerGameContractLike> =
|
|
354
|
+
InitContext<
|
|
355
|
+
TableOfManifest<ManifestOf<Contract>>,
|
|
356
|
+
ExactManifestContractOf<Contract>
|
|
357
|
+
>;
|
|
358
|
+
|
|
359
|
+
export type InitialStateCallbacks<Contract extends ReducerGameContractLike> = {
|
|
360
|
+
public?: (
|
|
361
|
+
ctx: InitialStateContextOf<Contract>,
|
|
362
|
+
) => z.infer<PublicSchemaOfContract<Contract>>;
|
|
363
|
+
private?: (
|
|
364
|
+
ctx: InitialStateContextOf<Contract> & {
|
|
365
|
+
playerId: PlayerIdOfTable<TableOfManifest<ManifestOf<Contract>>>;
|
|
366
|
+
},
|
|
367
|
+
) => z.infer<PrivateSchemaOfContract<Contract>>;
|
|
368
|
+
hidden?: (
|
|
369
|
+
ctx: InitialStateContextOf<Contract>,
|
|
370
|
+
) => z.infer<HiddenSchemaOfContract<Contract>>;
|
|
371
|
+
};
|
|
372
|
+
|
|
373
|
+
export type ReducerGameDefinition<
|
|
374
|
+
Contract extends ReducerGameContractLike,
|
|
375
|
+
Definitions extends PhaseMapOf<Contract>,
|
|
376
|
+
Views extends ViewMapOf<Contract> = Record<string, never>,
|
|
377
|
+
> = {
|
|
378
|
+
contract: Contract;
|
|
379
|
+
initial?: InitialStateCallbacks<NoInfer<Contract>>;
|
|
380
|
+
initialPhase?: keyof Definitions & string;
|
|
381
|
+
setupProfiles?: Record<
|
|
382
|
+
string,
|
|
383
|
+
SetupProfileDefinition<
|
|
384
|
+
keyof Definitions & string,
|
|
385
|
+
ExactManifestContractOf<Contract>
|
|
386
|
+
>
|
|
387
|
+
>;
|
|
388
|
+
phases: Definitions;
|
|
389
|
+
views?: Views;
|
|
390
|
+
/**
|
|
391
|
+
* Optional session-scoped static projection. Authored via
|
|
392
|
+
* {@link StaticViewDefinition}; computed once per reducer session from the
|
|
393
|
+
* manifest + setup profile and cached by the host. The client merges the
|
|
394
|
+
* cached payload into every seat view, so the per-tick `projectSeatsDynamic`
|
|
395
|
+
* call no longer needs to re-serialize static board topology.
|
|
396
|
+
*/
|
|
397
|
+
staticView?: StaticViewDefinition<
|
|
398
|
+
ExactManifestContractOf<NoInfer<Contract>>,
|
|
399
|
+
unknown
|
|
400
|
+
>;
|
|
401
|
+
};
|
|
402
|
+
|
|
403
|
+
export type AnyReducerGameDefinition = ReducerGameDefinition<
|
|
404
|
+
ReducerGameContractLike,
|
|
405
|
+
PhaseMapOf<ReducerGameContractLike>,
|
|
406
|
+
ViewMapOf<ReducerGameContractLike>
|
|
407
|
+
>;
|
|
408
|
+
|
|
409
|
+
// --- Interaction / Stage / Zone extractors -------------------------------
|
|
410
|
+
|
|
411
|
+
type InteractionRegistriesOfDefinition<Definition> =
|
|
412
|
+
PhasesOfDefinition<Definition>[keyof PhasesOfDefinition<Definition> &
|
|
413
|
+
string] extends {
|
|
414
|
+
interactions?: infer Interactions;
|
|
415
|
+
}
|
|
416
|
+
? NonNullable<Interactions>
|
|
417
|
+
: never;
|
|
418
|
+
|
|
419
|
+
type SimultaneousSubmitRegistriesOfDefinition<Definition> =
|
|
420
|
+
PhasesOfDefinition<Definition>[keyof PhasesOfDefinition<Definition> &
|
|
421
|
+
string] extends {
|
|
422
|
+
submit?: infer Submit;
|
|
423
|
+
}
|
|
424
|
+
? { submit: NonNullable<Submit> }
|
|
425
|
+
: never;
|
|
426
|
+
|
|
427
|
+
type CardActionRegistriesOfDefinition<Definition> =
|
|
428
|
+
PhasesOfDefinition<Definition>[keyof PhasesOfDefinition<Definition> &
|
|
429
|
+
string] extends {
|
|
430
|
+
cardActions?: infer CardActions;
|
|
431
|
+
}
|
|
432
|
+
? NonNullable<CardActions>
|
|
433
|
+
: never;
|
|
434
|
+
|
|
435
|
+
export type InteractionIdOfDefinition<Definition> =
|
|
436
|
+
InteractionRegistriesOfDefinition<Definition> extends infer Interactions
|
|
437
|
+
? SimultaneousSubmitRegistriesOfDefinition<Definition> extends infer Submit
|
|
438
|
+
? CardActionRegistriesOfDefinition<Definition> extends infer CardActions
|
|
439
|
+
? Interactions extends Record<string, unknown>
|
|
440
|
+
? CardActions extends Record<string, unknown>
|
|
441
|
+
? Submit extends Record<string, unknown>
|
|
442
|
+
?
|
|
443
|
+
| (NonNeverKeys<Interactions> & string)
|
|
444
|
+
| (NonNeverKeys<CardActions> & string)
|
|
445
|
+
| (NonNeverKeys<Submit> & string)
|
|
446
|
+
:
|
|
447
|
+
| (NonNeverKeys<Interactions> & string)
|
|
448
|
+
| (NonNeverKeys<CardActions> & string)
|
|
449
|
+
: Submit extends Record<string, unknown>
|
|
450
|
+
?
|
|
451
|
+
| (NonNeverKeys<Interactions> & string)
|
|
452
|
+
| (NonNeverKeys<Submit> & string)
|
|
453
|
+
: NonNeverKeys<Interactions> & string
|
|
454
|
+
: CardActions extends Record<string, unknown>
|
|
455
|
+
? Submit extends Record<string, unknown>
|
|
456
|
+
?
|
|
457
|
+
| (NonNeverKeys<CardActions> & string)
|
|
458
|
+
| (NonNeverKeys<Submit> & string)
|
|
459
|
+
: NonNeverKeys<CardActions> & string
|
|
460
|
+
: Submit extends Record<string, unknown>
|
|
461
|
+
? NonNeverKeys<Submit> & string
|
|
462
|
+
: never
|
|
463
|
+
: never
|
|
464
|
+
: never
|
|
465
|
+
: never;
|
|
466
|
+
|
|
467
|
+
type InteractionRegistryOfDefinitionPhase<
|
|
468
|
+
Definition,
|
|
469
|
+
PhaseName extends PhaseNamesOfDefinition<Definition>,
|
|
470
|
+
> =
|
|
471
|
+
PhaseDefinitionByName<Definition, PhaseName> extends {
|
|
472
|
+
interactions?: infer Interactions;
|
|
473
|
+
}
|
|
474
|
+
? NonNullable<Interactions>
|
|
475
|
+
: Record<string, never>;
|
|
476
|
+
|
|
477
|
+
type SimultaneousSubmitRegistryOfDefinitionPhase<
|
|
478
|
+
Definition,
|
|
479
|
+
PhaseName extends PhaseNamesOfDefinition<Definition>,
|
|
480
|
+
> =
|
|
481
|
+
PhaseDefinitionByName<Definition, PhaseName> extends {
|
|
482
|
+
submit?: infer Submit;
|
|
483
|
+
}
|
|
484
|
+
? { submit: NonNullable<Submit> }
|
|
485
|
+
: Record<string, never>;
|
|
486
|
+
|
|
487
|
+
type CardActionRegistryOfDefinitionPhase<
|
|
488
|
+
Definition,
|
|
489
|
+
PhaseName extends PhaseNamesOfDefinition<Definition>,
|
|
490
|
+
> =
|
|
491
|
+
PhaseDefinitionByName<Definition, PhaseName> extends {
|
|
492
|
+
cardActions?: infer CardActions;
|
|
493
|
+
}
|
|
494
|
+
? NonNullable<CardActions>
|
|
495
|
+
: Record<string, never>;
|
|
496
|
+
|
|
497
|
+
type NonNeverRegistryValue<Registry, Key extends string> =
|
|
498
|
+
Registry extends Record<string, unknown>
|
|
499
|
+
? Key extends keyof Registry
|
|
500
|
+
? [Registry[Key]] extends [never]
|
|
501
|
+
? never
|
|
502
|
+
: Registry[Key]
|
|
503
|
+
: never
|
|
504
|
+
: never;
|
|
505
|
+
|
|
506
|
+
export type InteractionIdOfDefinitionPhase<
|
|
507
|
+
Definition,
|
|
508
|
+
PhaseName extends PhaseNamesOfDefinition<Definition>,
|
|
509
|
+
> =
|
|
510
|
+
InteractionRegistryOfDefinitionPhase<
|
|
511
|
+
Definition,
|
|
512
|
+
PhaseName
|
|
513
|
+
> extends infer Interactions
|
|
514
|
+
? SimultaneousSubmitRegistryOfDefinitionPhase<
|
|
515
|
+
Definition,
|
|
516
|
+
PhaseName
|
|
517
|
+
> extends infer Submit
|
|
518
|
+
? CardActionRegistryOfDefinitionPhase<
|
|
519
|
+
Definition,
|
|
520
|
+
PhaseName
|
|
521
|
+
> extends infer CardActions
|
|
522
|
+
? Interactions extends Record<string, unknown>
|
|
523
|
+
? CardActions extends Record<string, unknown>
|
|
524
|
+
? Submit extends Record<string, unknown>
|
|
525
|
+
?
|
|
526
|
+
| (NonNeverKeys<Interactions> & string)
|
|
527
|
+
| (NonNeverKeys<CardActions> & string)
|
|
528
|
+
| (NonNeverKeys<Submit> & string)
|
|
529
|
+
:
|
|
530
|
+
| (NonNeverKeys<Interactions> & string)
|
|
531
|
+
| (NonNeverKeys<CardActions> & string)
|
|
532
|
+
: Submit extends Record<string, unknown>
|
|
533
|
+
?
|
|
534
|
+
| (NonNeverKeys<Interactions> & string)
|
|
535
|
+
| (NonNeverKeys<Submit> & string)
|
|
536
|
+
: NonNeverKeys<Interactions> & string
|
|
537
|
+
: CardActions extends Record<string, unknown>
|
|
538
|
+
? Submit extends Record<string, unknown>
|
|
539
|
+
?
|
|
540
|
+
| (NonNeverKeys<CardActions> & string)
|
|
541
|
+
| (NonNeverKeys<Submit> & string)
|
|
542
|
+
: NonNeverKeys<CardActions> & string
|
|
543
|
+
: Submit extends Record<string, unknown>
|
|
544
|
+
? NonNeverKeys<Submit> & string
|
|
545
|
+
: never
|
|
546
|
+
: never
|
|
547
|
+
: never
|
|
548
|
+
: never;
|
|
549
|
+
|
|
550
|
+
export type InteractionSpecByNameOfDefinitionPhase<
|
|
551
|
+
Definition,
|
|
552
|
+
PhaseName extends PhaseNamesOfDefinition<Definition>,
|
|
553
|
+
InteractionId extends InteractionIdOfDefinitionPhase<Definition, PhaseName>,
|
|
554
|
+
> =
|
|
555
|
+
InteractionRegistryOfDefinitionPhase<
|
|
556
|
+
Definition,
|
|
557
|
+
PhaseName
|
|
558
|
+
> extends infer Interactions
|
|
559
|
+
? Interactions extends Record<string, unknown>
|
|
560
|
+
? NonNeverRegistryValue<
|
|
561
|
+
Interactions,
|
|
562
|
+
InteractionId
|
|
563
|
+
> extends infer InteractionSpec
|
|
564
|
+
? [InteractionSpec] extends [never]
|
|
565
|
+
? CardActionRegistryOfDefinitionPhase<
|
|
566
|
+
Definition,
|
|
567
|
+
PhaseName
|
|
568
|
+
> extends infer CardActions
|
|
569
|
+
? NonNeverRegistryValue<
|
|
570
|
+
CardActions,
|
|
571
|
+
InteractionId
|
|
572
|
+
> extends infer CardActionSpec
|
|
573
|
+
? [CardActionSpec] extends [never]
|
|
574
|
+
? SimultaneousSubmitRegistryOfDefinitionPhase<
|
|
575
|
+
Definition,
|
|
576
|
+
PhaseName
|
|
577
|
+
> extends infer Submit
|
|
578
|
+
? NonNeverRegistryValue<Submit, InteractionId>
|
|
579
|
+
: never
|
|
580
|
+
: CardActionSpec
|
|
581
|
+
: never
|
|
582
|
+
: never
|
|
583
|
+
: InteractionSpec
|
|
584
|
+
: never
|
|
585
|
+
: never
|
|
586
|
+
: never;
|
|
587
|
+
|
|
588
|
+
type CollectorKindsOf<Collectors> =
|
|
589
|
+
Collectors extends Record<string, InputCollector>
|
|
590
|
+
? Collectors[keyof Collectors] extends infer Collector
|
|
591
|
+
? Collector extends { kind: infer Kind extends string }
|
|
592
|
+
? Kind
|
|
593
|
+
: never
|
|
594
|
+
: never
|
|
595
|
+
: never;
|
|
596
|
+
|
|
597
|
+
type CollectorKeysWithKind<Collectors, Kind extends string> =
|
|
598
|
+
Collectors extends Record<string, InputCollector>
|
|
599
|
+
? {
|
|
600
|
+
[K in keyof Collectors]: Collectors[K] extends {
|
|
601
|
+
kind: infer CollectorKind;
|
|
602
|
+
}
|
|
603
|
+
? Extract<CollectorKind, Kind> extends never
|
|
604
|
+
? never
|
|
605
|
+
: K
|
|
606
|
+
: never;
|
|
607
|
+
}[keyof Collectors]
|
|
608
|
+
: never;
|
|
609
|
+
|
|
610
|
+
type CardCollectorZoneIds<Collector> = Collector extends {
|
|
611
|
+
kind: "card";
|
|
612
|
+
meta: infer Meta;
|
|
613
|
+
}
|
|
614
|
+
? Meta extends { readonly zoneIds: infer ZoneIds extends readonly string[] }
|
|
615
|
+
? ZoneIds[number]
|
|
616
|
+
: Meta extends { readonly zoneId: infer ZoneId extends string }
|
|
617
|
+
? ZoneId
|
|
618
|
+
: never
|
|
619
|
+
: never;
|
|
620
|
+
|
|
621
|
+
type CollectorCardZoneIds<Collectors, Input extends string> =
|
|
622
|
+
Collectors extends Record<string, InputCollector>
|
|
623
|
+
? Input extends keyof Collectors
|
|
624
|
+
? CardCollectorZoneIds<Collectors[Input]>
|
|
625
|
+
: never
|
|
626
|
+
: never;
|
|
627
|
+
|
|
628
|
+
type InteractionIdsWithCollectorKindOfDefinitionPhase<
|
|
629
|
+
Definition,
|
|
630
|
+
PhaseName extends PhaseNamesOfDefinition<Definition>,
|
|
631
|
+
Kind extends string,
|
|
632
|
+
> = {
|
|
633
|
+
[InteractionId in InteractionIdOfDefinitionPhase<
|
|
634
|
+
Definition,
|
|
635
|
+
PhaseName
|
|
636
|
+
>]: InteractionSpecByNameOfDefinitionPhase<
|
|
637
|
+
Definition,
|
|
638
|
+
PhaseName,
|
|
639
|
+
InteractionId
|
|
640
|
+
> extends InteractionSpec<infer Collectors, infer _State, infer _Manifest>
|
|
641
|
+
? Extract<CollectorKindsOf<Collectors>, Kind> extends never
|
|
642
|
+
? never
|
|
643
|
+
: InteractionId
|
|
644
|
+
: InteractionSpecByNameOfDefinitionPhase<
|
|
645
|
+
Definition,
|
|
646
|
+
PhaseName,
|
|
647
|
+
InteractionId
|
|
648
|
+
> extends CardActionSpec<
|
|
649
|
+
infer Collectors,
|
|
650
|
+
infer _State,
|
|
651
|
+
infer _Manifest
|
|
652
|
+
>
|
|
653
|
+
? Extract<"card" | CollectorKindsOf<Collectors>, Kind> extends never
|
|
654
|
+
? never
|
|
655
|
+
: InteractionId
|
|
656
|
+
: InteractionSpecByNameOfDefinitionPhase<
|
|
657
|
+
Definition,
|
|
658
|
+
PhaseName,
|
|
659
|
+
InteractionId
|
|
660
|
+
> extends SimultaneousSubmitSpec<
|
|
661
|
+
infer Collectors,
|
|
662
|
+
infer _State,
|
|
663
|
+
infer _Manifest
|
|
664
|
+
>
|
|
665
|
+
? Extract<CollectorKindsOf<Collectors>, Kind> extends never
|
|
666
|
+
? never
|
|
667
|
+
: InteractionId
|
|
668
|
+
: never;
|
|
669
|
+
}[InteractionIdOfDefinitionPhase<Definition, PhaseName>];
|
|
670
|
+
|
|
671
|
+
type QualifiedInteractionIdsWithCollectorKindOfDefinitionPhase<
|
|
672
|
+
Definition,
|
|
673
|
+
PhaseName extends PhaseNamesOfDefinition<Definition>,
|
|
674
|
+
Kind extends string,
|
|
675
|
+
> =
|
|
676
|
+
InteractionIdsWithCollectorKindOfDefinitionPhase<
|
|
677
|
+
Definition,
|
|
678
|
+
PhaseName,
|
|
679
|
+
Kind
|
|
680
|
+
> extends infer InteractionId extends string
|
|
681
|
+
? `${PhaseName}.${InteractionId}`
|
|
682
|
+
: never;
|
|
683
|
+
|
|
684
|
+
export type PromptInteractionKeyOfDefinition<Definition> = {
|
|
685
|
+
[PhaseName in PhaseNamesOfDefinition<Definition>]: QualifiedInteractionIdsWithCollectorKindOfDefinitionPhase<
|
|
686
|
+
Definition,
|
|
687
|
+
PhaseName,
|
|
688
|
+
"prompt"
|
|
689
|
+
>;
|
|
690
|
+
}[PhaseNamesOfDefinition<Definition>];
|
|
691
|
+
|
|
692
|
+
export type BoardInteractionKeyOfDefinition<Definition> = {
|
|
693
|
+
[PhaseName in PhaseNamesOfDefinition<Definition>]: QualifiedInteractionIdsWithCollectorKindOfDefinitionPhase<
|
|
694
|
+
Definition,
|
|
695
|
+
PhaseName,
|
|
696
|
+
"board-edge" | "board-space" | "board-tile" | "board-vertex"
|
|
697
|
+
>;
|
|
698
|
+
}[PhaseNamesOfDefinition<Definition>];
|
|
699
|
+
|
|
700
|
+
export type CardInteractionKeyOfDefinition<Definition> = {
|
|
701
|
+
[PhaseName in PhaseNamesOfDefinition<Definition>]: QualifiedInteractionIdsWithCollectorKindOfDefinitionPhase<
|
|
702
|
+
Definition,
|
|
703
|
+
PhaseName,
|
|
704
|
+
"card"
|
|
705
|
+
>;
|
|
706
|
+
}[PhaseNamesOfDefinition<Definition>];
|
|
707
|
+
|
|
708
|
+
export type InputKeysWithCollectorKindOfDefinition<
|
|
709
|
+
Definition,
|
|
710
|
+
PhaseName extends PhaseNamesOfDefinition<Definition>,
|
|
711
|
+
InteractionId extends InteractionIdOfDefinitionPhase<Definition, PhaseName>,
|
|
712
|
+
Kind extends string,
|
|
713
|
+
> =
|
|
714
|
+
InteractionSpecByNameOfDefinitionPhase<
|
|
715
|
+
Definition,
|
|
716
|
+
PhaseName,
|
|
717
|
+
InteractionId
|
|
718
|
+
> extends InteractionSpec<infer Collectors, infer _State, infer _Manifest>
|
|
719
|
+
? CollectorKeysWithKind<Collectors, Kind> & string
|
|
720
|
+
: InteractionSpecByNameOfDefinitionPhase<
|
|
721
|
+
Definition,
|
|
722
|
+
PhaseName,
|
|
723
|
+
InteractionId
|
|
724
|
+
> extends CardActionSpec<
|
|
725
|
+
infer Collectors,
|
|
726
|
+
infer _State,
|
|
727
|
+
infer _Manifest
|
|
728
|
+
>
|
|
729
|
+
?
|
|
730
|
+
| (Extract<"card", Kind> extends never ? never : "cardId")
|
|
731
|
+
| (CollectorKeysWithKind<Collectors, Kind> & string)
|
|
732
|
+
: InteractionSpecByNameOfDefinitionPhase<
|
|
733
|
+
Definition,
|
|
734
|
+
PhaseName,
|
|
735
|
+
InteractionId
|
|
736
|
+
> extends SimultaneousSubmitSpec<
|
|
737
|
+
infer Collectors,
|
|
738
|
+
infer _State,
|
|
739
|
+
infer _Manifest
|
|
740
|
+
>
|
|
741
|
+
? CollectorKeysWithKind<Collectors, Kind> & string
|
|
742
|
+
: never;
|
|
743
|
+
|
|
744
|
+
export type CardInputZoneIdsOfDefinition<
|
|
745
|
+
Definition,
|
|
746
|
+
PhaseName extends PhaseNamesOfDefinition<Definition>,
|
|
747
|
+
InteractionId extends InteractionIdOfDefinitionPhase<Definition, PhaseName>,
|
|
748
|
+
Input extends string,
|
|
749
|
+
> =
|
|
750
|
+
InteractionSpecByNameOfDefinitionPhase<
|
|
751
|
+
Definition,
|
|
752
|
+
PhaseName,
|
|
753
|
+
InteractionId
|
|
754
|
+
> extends InteractionSpec<infer Collectors, infer _State, infer _Manifest>
|
|
755
|
+
? CollectorCardZoneIds<Collectors, Input>
|
|
756
|
+
: InteractionSpecByNameOfDefinitionPhase<
|
|
757
|
+
Definition,
|
|
758
|
+
PhaseName,
|
|
759
|
+
InteractionId
|
|
760
|
+
> extends CardActionSpec<
|
|
761
|
+
infer Collectors,
|
|
762
|
+
infer _State,
|
|
763
|
+
infer _Manifest
|
|
764
|
+
>
|
|
765
|
+
? Input extends "cardId"
|
|
766
|
+
? InteractionSpecByNameOfDefinitionPhase<
|
|
767
|
+
Definition,
|
|
768
|
+
PhaseName,
|
|
769
|
+
InteractionId
|
|
770
|
+
> extends { readonly playFrom: infer PlayFrom extends string }
|
|
771
|
+
? PlayFrom
|
|
772
|
+
: never
|
|
773
|
+
: CollectorCardZoneIds<Collectors, Input>
|
|
774
|
+
: InteractionSpecByNameOfDefinitionPhase<
|
|
775
|
+
Definition,
|
|
776
|
+
PhaseName,
|
|
777
|
+
InteractionId
|
|
778
|
+
> extends SimultaneousSubmitSpec<
|
|
779
|
+
infer Collectors,
|
|
780
|
+
infer _State,
|
|
781
|
+
infer _Manifest
|
|
782
|
+
>
|
|
783
|
+
? CollectorCardZoneIds<Collectors, Input>
|
|
784
|
+
: never;
|
|
785
|
+
|
|
786
|
+
export type ParamsOfInteractionOfDefinition<
|
|
787
|
+
Definition,
|
|
788
|
+
PhaseName extends PhaseNamesOfDefinition<Definition>,
|
|
789
|
+
InteractionId extends InteractionIdOfDefinitionPhase<Definition, PhaseName>,
|
|
790
|
+
> =
|
|
791
|
+
InteractionSpecByNameOfDefinitionPhase<
|
|
792
|
+
Definition,
|
|
793
|
+
PhaseName,
|
|
794
|
+
InteractionId
|
|
795
|
+
> extends InteractionSpec<infer Collectors, infer _State, infer _Manifest>
|
|
796
|
+
? Collectors extends Record<string, InputCollector>
|
|
797
|
+
? {
|
|
798
|
+
[K in keyof Collectors]: Collectors[K] extends InputCollector<
|
|
799
|
+
infer S,
|
|
800
|
+
infer _S2
|
|
801
|
+
>
|
|
802
|
+
? S extends SchemaLike<infer V>
|
|
803
|
+
? V
|
|
804
|
+
: never
|
|
805
|
+
: never;
|
|
806
|
+
}
|
|
807
|
+
: never
|
|
808
|
+
: InteractionSpecByNameOfDefinitionPhase<
|
|
809
|
+
Definition,
|
|
810
|
+
PhaseName,
|
|
811
|
+
InteractionId
|
|
812
|
+
> extends CardActionSpec<
|
|
813
|
+
infer Collectors,
|
|
814
|
+
infer _State,
|
|
815
|
+
infer _Manifest
|
|
816
|
+
>
|
|
817
|
+
? Collectors extends Record<string, InputCollector>
|
|
818
|
+
? {
|
|
819
|
+
cardId: string;
|
|
820
|
+
} & {
|
|
821
|
+
[K in keyof Collectors]: Collectors[K] extends InputCollector<
|
|
822
|
+
infer S,
|
|
823
|
+
infer _S2
|
|
824
|
+
>
|
|
825
|
+
? S extends SchemaLike<infer V>
|
|
826
|
+
? V
|
|
827
|
+
: never
|
|
828
|
+
: never;
|
|
829
|
+
}
|
|
830
|
+
: { cardId: string }
|
|
831
|
+
: InteractionSpecByNameOfDefinitionPhase<
|
|
832
|
+
Definition,
|
|
833
|
+
PhaseName,
|
|
834
|
+
InteractionId
|
|
835
|
+
> extends SimultaneousSubmitSpec<
|
|
836
|
+
infer Collectors,
|
|
837
|
+
infer _State,
|
|
838
|
+
infer _Manifest
|
|
839
|
+
>
|
|
840
|
+
? Collectors extends Record<string, InputCollector>
|
|
841
|
+
? {
|
|
842
|
+
[K in keyof Collectors]: Collectors[K] extends InputCollector<
|
|
843
|
+
infer S,
|
|
844
|
+
infer _S2
|
|
845
|
+
>
|
|
846
|
+
? S extends SchemaLike<infer V>
|
|
847
|
+
? V
|
|
848
|
+
: never
|
|
849
|
+
: never;
|
|
850
|
+
}
|
|
851
|
+
: never
|
|
852
|
+
: never;
|
|
853
|
+
|
|
854
|
+
/**
|
|
855
|
+
* Client-facing params shape for an interaction. Omits engine-sampled
|
|
856
|
+
* collectors (`rngInput.*`) — clients never supply those fields; the
|
|
857
|
+
* trusted reducer bundle fills them during `submitInteraction`.
|
|
858
|
+
*
|
|
859
|
+
* This is the type that drives `submit(playerId, id, params)`,
|
|
860
|
+
* `handle.submit(params)`, and the generated `InteractionParams` surface
|
|
861
|
+
* in `shared/generated/ui-contract.ts`. The `reduce`-input counterpart is
|
|
862
|
+
* {@link ParamsOfInteractionOfDefinition}, which includes every field
|
|
863
|
+
* because the engine has already filled the sampled ones by then.
|
|
864
|
+
*/
|
|
865
|
+
export type ClientParamsOfInteractionOfDefinition<
|
|
866
|
+
Definition,
|
|
867
|
+
PhaseName extends PhaseNamesOfDefinition<Definition>,
|
|
868
|
+
InteractionId extends InteractionIdOfDefinitionPhase<Definition, PhaseName>,
|
|
869
|
+
> =
|
|
870
|
+
InteractionSpecByNameOfDefinitionPhase<
|
|
871
|
+
Definition,
|
|
872
|
+
PhaseName,
|
|
873
|
+
InteractionId
|
|
874
|
+
> extends InteractionSpec<infer Collectors, infer _State, infer _Manifest>
|
|
875
|
+
? Collectors extends Record<string, InputCollector>
|
|
876
|
+
? {
|
|
877
|
+
[K in keyof Collectors as Collectors[K] extends InputCollector<
|
|
878
|
+
infer _S,
|
|
879
|
+
infer _S2
|
|
880
|
+
> & {
|
|
881
|
+
kind: "rng";
|
|
882
|
+
}
|
|
883
|
+
? never
|
|
884
|
+
: K]: Collectors[K] extends InputCollector<infer S, infer _S2>
|
|
885
|
+
? S extends SchemaLike<infer V>
|
|
886
|
+
? V
|
|
887
|
+
: never
|
|
888
|
+
: never;
|
|
889
|
+
}
|
|
890
|
+
: never
|
|
891
|
+
: InteractionSpecByNameOfDefinitionPhase<
|
|
892
|
+
Definition,
|
|
893
|
+
PhaseName,
|
|
894
|
+
InteractionId
|
|
895
|
+
> extends CardActionSpec<
|
|
896
|
+
infer Collectors,
|
|
897
|
+
infer _State,
|
|
898
|
+
infer _Manifest
|
|
899
|
+
>
|
|
900
|
+
? Collectors extends Record<string, InputCollector>
|
|
901
|
+
? {
|
|
902
|
+
cardId: string;
|
|
903
|
+
} & {
|
|
904
|
+
[K in keyof Collectors as Collectors[K] extends InputCollector<
|
|
905
|
+
infer _S,
|
|
906
|
+
infer _S2
|
|
907
|
+
> & {
|
|
908
|
+
kind: "rng";
|
|
909
|
+
}
|
|
910
|
+
? never
|
|
911
|
+
: K]: Collectors[K] extends InputCollector<infer S, infer _S2>
|
|
912
|
+
? S extends SchemaLike<infer V>
|
|
913
|
+
? V
|
|
914
|
+
: never
|
|
915
|
+
: never;
|
|
916
|
+
}
|
|
917
|
+
: { cardId: string }
|
|
918
|
+
: InteractionSpecByNameOfDefinitionPhase<
|
|
919
|
+
Definition,
|
|
920
|
+
PhaseName,
|
|
921
|
+
InteractionId
|
|
922
|
+
> extends SimultaneousSubmitSpec<
|
|
923
|
+
infer Collectors,
|
|
924
|
+
infer _State,
|
|
925
|
+
infer _Manifest
|
|
926
|
+
>
|
|
927
|
+
? Collectors extends Record<string, InputCollector>
|
|
928
|
+
? {
|
|
929
|
+
[K in keyof Collectors as Collectors[K] extends InputCollector<
|
|
930
|
+
infer _S,
|
|
931
|
+
infer _S2
|
|
932
|
+
> & {
|
|
933
|
+
kind: "rng";
|
|
934
|
+
}
|
|
935
|
+
? never
|
|
936
|
+
: K]: Collectors[K] extends InputCollector<infer S, infer _S2>
|
|
937
|
+
? S extends SchemaLike<infer V>
|
|
938
|
+
? V
|
|
939
|
+
: never
|
|
940
|
+
: never;
|
|
941
|
+
}
|
|
942
|
+
: never
|
|
943
|
+
: never;
|
|
944
|
+
|
|
945
|
+
type DefaultedClientCollectorKeys<
|
|
946
|
+
Collectors extends Record<string, InputCollector>,
|
|
947
|
+
> = {
|
|
948
|
+
[K in keyof Collectors]: Collectors[K] extends InputCollector<
|
|
949
|
+
infer _S,
|
|
950
|
+
infer _S2
|
|
951
|
+
> & {
|
|
952
|
+
kind: "rng";
|
|
953
|
+
}
|
|
954
|
+
? never
|
|
955
|
+
: Collectors[K] extends { readonly defaultValue: unknown }
|
|
956
|
+
? K
|
|
957
|
+
: never;
|
|
958
|
+
}[keyof Collectors];
|
|
959
|
+
|
|
960
|
+
export type DefaultedClientParamKeysOfInteractionOfDefinition<
|
|
961
|
+
Definition,
|
|
962
|
+
PhaseName extends PhaseNamesOfDefinition<Definition>,
|
|
963
|
+
InteractionId extends InteractionIdOfDefinitionPhase<Definition, PhaseName>,
|
|
964
|
+
> =
|
|
965
|
+
InteractionSpecByNameOfDefinitionPhase<
|
|
966
|
+
Definition,
|
|
967
|
+
PhaseName,
|
|
968
|
+
InteractionId
|
|
969
|
+
> extends InteractionSpec<infer Collectors, infer _State, infer _Manifest>
|
|
970
|
+
? Collectors extends Record<string, InputCollector>
|
|
971
|
+
? DefaultedClientCollectorKeys<Collectors> & string
|
|
972
|
+
: never
|
|
973
|
+
: InteractionSpecByNameOfDefinitionPhase<
|
|
974
|
+
Definition,
|
|
975
|
+
PhaseName,
|
|
976
|
+
InteractionId
|
|
977
|
+
> extends CardActionSpec<
|
|
978
|
+
infer Collectors,
|
|
979
|
+
infer _State,
|
|
980
|
+
infer _Manifest
|
|
981
|
+
>
|
|
982
|
+
? Collectors extends Record<string, InputCollector>
|
|
983
|
+
? DefaultedClientCollectorKeys<Collectors> & string
|
|
984
|
+
: never
|
|
985
|
+
: InteractionSpecByNameOfDefinitionPhase<
|
|
986
|
+
Definition,
|
|
987
|
+
PhaseName,
|
|
988
|
+
InteractionId
|
|
989
|
+
> extends SimultaneousSubmitSpec<
|
|
990
|
+
infer Collectors,
|
|
991
|
+
infer _State,
|
|
992
|
+
infer _Manifest
|
|
993
|
+
>
|
|
994
|
+
? Collectors extends Record<string, InputCollector>
|
|
995
|
+
? DefaultedClientCollectorKeys<Collectors> & string
|
|
996
|
+
: never
|
|
997
|
+
: never;
|
|
998
|
+
|
|
999
|
+
type StageRegistryOfDefinitionPhase<
|
|
1000
|
+
Definition,
|
|
1001
|
+
PhaseName extends PhaseNamesOfDefinition<Definition>,
|
|
1002
|
+
> =
|
|
1003
|
+
PhaseDefinitionByName<Definition, PhaseName> extends {
|
|
1004
|
+
stages?: infer Stages;
|
|
1005
|
+
}
|
|
1006
|
+
? NonNullable<Stages>
|
|
1007
|
+
: Record<string, never>;
|
|
1008
|
+
|
|
1009
|
+
export type StageNamesOfDefinitionPhase<
|
|
1010
|
+
Definition,
|
|
1011
|
+
PhaseName extends PhaseNamesOfDefinition<Definition>,
|
|
1012
|
+
> =
|
|
1013
|
+
StageRegistryOfDefinitionPhase<Definition, PhaseName> extends infer Stages
|
|
1014
|
+
? Stages extends Record<string, unknown>
|
|
1015
|
+
? NonNeverKeys<Stages> & string
|
|
1016
|
+
: never
|
|
1017
|
+
: never;
|
|
1018
|
+
|
|
1019
|
+
type ZoneRegistriesOfDefinition<Definition> =
|
|
1020
|
+
PhasesOfDefinition<Definition>[keyof PhasesOfDefinition<Definition> &
|
|
1021
|
+
string] extends {
|
|
1022
|
+
zones?: infer Zones;
|
|
1023
|
+
}
|
|
1024
|
+
? NonNullable<Zones>
|
|
1025
|
+
: never;
|
|
1026
|
+
|
|
1027
|
+
export type ZoneIdsOfDefinition<Definition> =
|
|
1028
|
+
ZoneRegistriesOfDefinition<Definition> extends infer Zones
|
|
1029
|
+
? Zones extends readonly (infer ZoneId)[]
|
|
1030
|
+
? Extract<ZoneId, string>
|
|
1031
|
+
: never
|
|
1032
|
+
: never;
|
|
1033
|
+
|
|
1034
|
+
type ZoneListOfDefinitionPhase<
|
|
1035
|
+
Definition,
|
|
1036
|
+
PhaseName extends PhaseNamesOfDefinition<Definition>,
|
|
1037
|
+
> =
|
|
1038
|
+
PhaseDefinitionByName<Definition, PhaseName> extends {
|
|
1039
|
+
zones?: infer Zones;
|
|
1040
|
+
}
|
|
1041
|
+
? NonNullable<Zones>
|
|
1042
|
+
: readonly [];
|
|
1043
|
+
|
|
1044
|
+
export type PlayableInteractionsOfZoneOfDefinition<
|
|
1045
|
+
Definition,
|
|
1046
|
+
PhaseName extends PhaseNamesOfDefinition<Definition>,
|
|
1047
|
+
ZoneId extends string,
|
|
1048
|
+
> =
|
|
1049
|
+
ZoneListOfDefinitionPhase<
|
|
1050
|
+
Definition,
|
|
1051
|
+
PhaseName
|
|
1052
|
+
> extends readonly (infer From)[]
|
|
1053
|
+
? Extract<From, ZoneId> extends never
|
|
1054
|
+
? never
|
|
1055
|
+
: CardActionRegistryOfDefinitionPhase<
|
|
1056
|
+
Definition,
|
|
1057
|
+
PhaseName
|
|
1058
|
+
> extends infer CardActions
|
|
1059
|
+
? CardActions extends Record<string, unknown>
|
|
1060
|
+
? {
|
|
1061
|
+
[ActionId in keyof CardActions &
|
|
1062
|
+
string]: CardActions[ActionId] extends {
|
|
1063
|
+
playFrom: infer PlayFrom extends string;
|
|
1064
|
+
}
|
|
1065
|
+
? Extract<PlayFrom, ZoneId> extends never
|
|
1066
|
+
? never
|
|
1067
|
+
: ActionId
|
|
1068
|
+
: never;
|
|
1069
|
+
}[keyof CardActions & string]
|
|
1070
|
+
: never
|
|
1071
|
+
: never
|
|
1072
|
+
: never;
|