@dreamboard-games/sdk 0.4.0-alpha.11 → 0.4.0-alpha.13

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (43) hide show
  1. package/REFERENCE.md +444 -9
  2. package/dist/authoring/index.js +3 -3
  3. package/dist/authoring-compiler.js +4 -4
  4. package/dist/authoring-materialize-cli.js +4 -4
  5. package/dist/{chunk-THTFQZZ3.js → chunk-42HQLHVA.js} +3 -3
  6. package/dist/{chunk-RP6QDQGI.js → chunk-7JBPOJOF.js} +46 -1
  7. package/dist/chunk-7JBPOJOF.js.map +1 -0
  8. package/dist/{chunk-SACZWUA6.js → chunk-HIH6Y4FA.js} +86 -1224
  9. package/dist/{chunk-SACZWUA6.js.map → chunk-HIH6Y4FA.js.map} +1 -1
  10. package/dist/{chunk-RU3Z5J6V.js → chunk-KZFHTUI5.js} +4 -4
  11. package/dist/{chunk-HRWI2DIJ.js → chunk-MLFHVYF7.js} +2 -2
  12. package/dist/{chunk-3OY46H7D.js → chunk-OFIDC7DJ.js} +3 -3
  13. package/dist/{chunk-CP3BF3B2.js → chunk-THWT4V3Z.js} +2 -2
  14. package/dist/{chunk-CP3BF3B2.js.map → chunk-THWT4V3Z.js.map} +1 -1
  15. package/dist/{chunk-4IIY742N.js → chunk-UTSBXZAM.js} +2 -2
  16. package/dist/chunk-VWTKGIYF.js +90 -0
  17. package/dist/chunk-VWTKGIYF.js.map +1 -0
  18. package/dist/codegen.js +1 -1
  19. package/dist/{index-CRfZ21dM.d.ts → index-CR69MyWr.d.ts} +1 -1
  20. package/dist/index.js +2 -2
  21. package/dist/package-set.d.ts +2 -2
  22. package/dist/package-set.js +2 -2
  23. package/dist/reducer/advanced.js +7 -82
  24. package/dist/reducer/advanced.js.map +1 -1
  25. package/dist/reducer-contract.js +1 -1
  26. package/dist/reference-game-compiler.js +2 -2
  27. package/dist/reference-game-source-manifest-cli.js +2 -2
  28. package/dist/runtime/workspace-contract.d.ts +342 -10
  29. package/dist/runtime/workspace-contract.js +7 -1
  30. package/dist/runtime.d.ts +1 -1
  31. package/dist/runtime.js +7 -3
  32. package/dist/runtime.js.map +1 -1
  33. package/dist/testing-runtime.js +2 -2
  34. package/dist/testing.d.ts +84 -20
  35. package/dist/testing.js +167 -23
  36. package/dist/testing.js.map +1 -1
  37. package/package.json +1 -1
  38. package/dist/chunk-RP6QDQGI.js.map +0 -1
  39. /package/dist/{chunk-THTFQZZ3.js.map → chunk-42HQLHVA.js.map} +0 -0
  40. /package/dist/{chunk-RU3Z5J6V.js.map → chunk-KZFHTUI5.js.map} +0 -0
  41. /package/dist/{chunk-HRWI2DIJ.js.map → chunk-MLFHVYF7.js.map} +0 -0
  42. /package/dist/{chunk-3OY46H7D.js.map → chunk-OFIDC7DJ.js.map} +0 -0
  43. /package/dist/{chunk-4IIY742N.js.map → chunk-UTSBXZAM.js.map} +0 -0
@@ -7045,7 +7045,7 @@ function generateManifestContractSources(manifest) {
7045
7045
 
7046
7046
  // ../workspace-codegen/src/ownership.ts
7047
7047
  var WORKSPACE_CODEGEN_OWNERSHIP = {
7048
- version: 31,
7048
+ version: 32,
7049
7049
  allowedPaths: {
7050
7050
  rootFiles: [
7051
7051
  ".npmrc",
@@ -7165,7 +7165,7 @@ function isLibraryPath(filePath) {
7165
7165
 
7166
7166
  // ../workspace-codegen/src/seeds.ts
7167
7167
  var SETUP_PROFILES_SEED_MARKER = "Generated by dreamboard setup-profiles scaffold.";
7168
- function generateUiContractContent() {
7168
+ function generateThinUiContractContent() {
7169
7169
  return `/**
7170
7170
  * Generated file.
7171
7171
  * Do not edit directly.
@@ -7173,72 +7173,22 @@ function generateUiContractContent() {
7173
7173
 
7174
7174
  import game from "../../app/game";
7175
7175
  import {
7176
- createClientParamSchemasByPhase,
7177
- } from "@dreamboard-games/sdk/reducer/advanced";
7178
- import type {
7179
- CardInputZoneIdsOfDefinition,
7180
- ClientParamsOfInteractionOfDefinition,
7181
- DefaultedClientParamKeysOfInteractionOfDefinition,
7182
- InputKeysWithCollectorKindOfDefinition,
7183
- InteractionIdOfDefinition,
7184
- InteractionIdOfDefinitionPhase,
7185
- PhaseNamesOfDefinition,
7186
- StageNamesOfDefinitionPhase,
7187
- ViewNamesOfDefinition,
7188
- ViewOfDefinition,
7189
- } from "@dreamboard-games/sdk/reducer/advanced";
7190
- import {
7191
- type BoardSpaceIdOf,
7192
- type InteractionVisualState,
7193
- } from "@dreamboard-games/sdk/ui";
7194
- import {
7195
- type BoardGridInteractionFilter,
7196
- type InteractionDescriptor,
7197
- } from "@dreamboard-games/sdk/runtime";
7198
- import {
7199
- createWorkspaceUIContract,
7200
- type BoardHexGridProps as BoardHexGridPropsGeneric,
7201
- type BoardHexViewProps as BoardHexViewPropsGeneric,
7202
- type BoardSquareGridProps as BoardSquareGridPropsGeneric,
7203
- type BoardSpaceTargetProps as BoardSpaceTargetPropsGeneric,
7204
- type ClientParamSchemaMap,
7205
- type DefineGameUIConfig,
7206
- type DreamboardUI,
7207
- type GameMeState,
7208
- type GamePlayersState,
7209
- type GameRenderState,
7210
- type GameTurnState,
7211
- type ResourceCounterComponents,
7212
- type TypedGame,
7213
- type UIContract,
7214
- type UIRootProps,
7215
- type WorkspaceBoardSurfaceDescriptor,
7216
- type WorkspaceBoardSurface,
7217
- type WorkspaceBoardTargetInputSlot,
7218
- type WorkspaceCardCollectionSurface,
7219
- type WorkspaceCardCollectionSurfaceDescriptor,
7220
- type WorkspaceCardInputSlot,
7221
- type WorkspaceFormInputSlot,
7222
- type WorkspaceHandSurfaceDescriptor,
7223
- type WorkspaceHandSurface,
7224
- type WorkspaceInteractionFormDescriptor,
7225
- type WorkspaceInteractionFormDialogProps,
7226
- type WorkspaceInteractionSlotComponent,
7227
- type WorkspaceInteractionFormsDescriptor,
7228
- type WorkspacePileSurface,
7229
- type WorkspacePileSurfaceDescriptor,
7230
- type WorkspacePilesSurfaceDescriptor,
7231
- type WorkspaceSurfaceSpec,
7232
- type ZoneCardRenderItem,
7233
- type ZoneListProps,
7176
+ createGameUiContract,
7177
+ type GameUiBoardSurface,
7178
+ type GameUiCardCollectionSurface,
7179
+ type GameUiGameRootState,
7180
+ type GameUiHandSurface,
7181
+ type GameUiInteractionFormSurface,
7182
+ type GameUiInteractionKey,
7183
+ type GameUiInteractionRoutes,
7184
+ type GameUiMe,
7185
+ type GameUiPhaseName,
7186
+ type GameUiPlayers,
7187
+ type GameUiTurn,
7188
+ type GameUiView,
7234
7189
  } from "@dreamboard-games/sdk/runtime/workspace-contract";
7190
+ import type { DreamboardUI } from "@dreamboard-games/sdk/runtime";
7235
7191
  import {
7236
- type ButtonHTMLAttributes,
7237
- type ReactElement,
7238
- type ReactNode,
7239
- } from "react";
7240
- import {
7241
- boardHelpers,
7242
7192
  literals,
7243
7193
  staticBoards,
7244
7194
  type BoardBaseId,
@@ -7249,909 +7199,86 @@ import {
7249
7199
  type PlayerId,
7250
7200
  type ResourceId,
7251
7201
  type SpaceId,
7252
- type TiledBoardId,
7253
- type TiledEdgeState,
7254
- type TiledVertexState,
7255
7202
  type VertexId,
7256
- type ZoneId as ManifestZoneId,
7203
+ type ZoneId,
7257
7204
  } from "../manifest-contract";
7258
7205
 
7259
- /**
7260
- * Boundary tripwire (do not remove).
7261
- *
7262
- * The authored UI boundary depends on \`@dreamboard-games/sdk/runtime\` resolving to
7263
- * real types in every typecheck path (local \`tsc\` and the remote compiler
7264
- * service). If a future change to module resolution or type loading silently
7265
- * degrades \`@dreamboard-games/sdk/runtime\` to \`any\`, the assertions below stop
7266
- * compiling, turning invisible type erosion into a hard typecheck error in
7267
- * every generated workspace. \`InteractionDescriptor\` comes from the package
7268
- * root and \`ZoneCardRenderItem\` from the \`/workspace-contract\` subpath, so
7269
- * both entry points are covered.
7270
- */
7271
- type IsAny<T> = 0 extends 1 & T ? true : false;
7272
- type AssertNotAny<T> = IsAny<T> extends true
7273
- ? "sdk runtime types resolved to any \u2014 boundary degraded"
7274
- : true;
7275
- const _uiRuntimeBoundaryResolved: [
7276
- AssertNotAny<InteractionDescriptor>,
7277
- AssertNotAny<ZoneCardRenderItem>,
7278
- ] = [true, true];
7279
- void _uiRuntimeBoundaryResolved;
7280
-
7281
7206
  type GameDefinition = typeof game;
7282
-
7283
- export type ViewName = ViewNamesOfDefinition<GameDefinition>;
7284
- export type InferView<Name extends ViewName> = ViewOfDefinition<
7285
- GameDefinition,
7286
- Name
7287
- >;
7288
- export type GameView = Extract<"player", ViewName> extends never
7289
- ? never
7290
- : InferView<Extract<"player", ViewName>>;
7291
-
7292
- export type PhaseName = PhaseNamesOfDefinition<GameDefinition>;
7293
- export type GameRootState = GameRenderState<GameView, PlayerId, PhaseName>;
7294
- export type GamePlayers = GamePlayersState<PlayerId>;
7295
- export type GameMe = GameMeState<PlayerId>;
7296
- export type GameTurn = GameTurnState<PlayerId, PhaseName>;
7297
-
7298
- // -------------------------------------------------------------------------
7299
- // Interaction / Stage / Zone types (authored via defineInteraction/Stage/zones)
7300
- // -------------------------------------------------------------------------
7301
-
7302
- /** Union of all interaction ids across phases. */
7303
- export type InteractionId = InteractionIdOfDefinition<GameDefinition>;
7304
-
7305
- /** Interactions declared in a specific phase. */
7306
- export type InteractionIdForPhase<Phase extends PhaseName> =
7307
- InteractionIdOfDefinitionPhase<GameDefinition, Phase>;
7308
-
7309
- /**
7310
- * Client-facing params type for an interaction, inferred from its input
7311
- * collectors. Engine-sampled collectors are omitted
7312
- * \u2014 the trusted reducer bundle fills those fields during submit, so the
7313
- * client never supplies them.
7314
- */
7315
- export type InteractionParams<
7316
- Phase extends PhaseName,
7317
- Id extends InteractionIdForPhase<Phase>,
7318
- > = ClientParamsOfInteractionOfDefinition<GameDefinition, Phase, Id>;
7319
-
7320
- /** Client-facing params with authored input defaults. */
7321
- export type InteractionDefaultedKeys<
7322
- Phase extends PhaseName,
7323
- Id extends InteractionIdForPhase<Phase>,
7324
- > = DefaultedClientParamKeysOfInteractionOfDefinition<GameDefinition, Phase, Id>;
7325
-
7326
- /** Phase-qualified interaction key for a specific phase. */
7327
- export type InteractionKeyForPhase<Phase extends PhaseName> =
7328
- \`\${Phase}.\${InteractionIdForPhase<Phase>}\`;
7329
-
7330
- /** Phase-qualified union of every client/UI interaction key. */
7331
- export type InteractionKey = {
7332
- [P in PhaseName]: InteractionKeyForPhase<P>;
7333
- }[PhaseName];
7334
-
7335
- type PhaseOfInteractionKey<Key extends InteractionKey> =
7336
- Key extends \`\${infer P}.\${string}\` ? Extract<P, PhaseName> : never;
7337
-
7338
- type IdOfInteractionKey<Key extends InteractionKey> =
7339
- Key extends \`\${infer P}.\${infer I}\`
7340
- ? P extends PhaseName
7341
- ? Extract<I, InteractionIdForPhase<P>>
7342
- : never
7343
- : never;
7344
-
7345
- export type BoardInteractions = InteractionKey;
7346
-
7347
- /** Stage names declared in a phase. */
7348
- export type StageName<Phase extends PhaseName> = StageNamesOfDefinitionPhase<
7349
- GameDefinition,
7350
- Phase
7351
- >;
7352
-
7353
- /** Union of zone ids authored in the workspace manifest. */
7354
- export type ZoneId = ManifestZoneId;
7355
-
7356
- type CamelCase<S extends string> = S extends \`\${infer Head}-\${infer Tail}\`
7357
- ? \`\${Head}\${Capitalize<CamelCase<Tail>>}\`
7358
- : S;
7359
-
7360
- /** JS-friendly keys for authored zones, e.g. "dev-hand" -> "devHand". */
7361
- export type WorkspaceZoneKey = CamelCase<ZoneId>;
7362
-
7207
+ type RuntimeBoundary = DreamboardUI;
7363
7208
  type PlayerCardZoneId = {
7364
- [Z in (typeof literals.playerZoneIds)[number]]: (typeof literals.cardSetIdsByPlayerZoneId)[Z] extends readonly []
7365
- ? never
7366
- : Z;
7209
+ [Zone in (typeof literals.playerZoneIds)[number]]:
7210
+ (typeof literals.cardSetIdsByPlayerZoneId)[Zone] extends readonly []
7211
+ ? never
7212
+ : Zone;
7367
7213
  }[(typeof literals.playerZoneIds)[number]];
7368
-
7369
7214
  type SharedCardZoneId = {
7370
- [Z in (typeof literals.sharedZoneIds)[number]]: (typeof literals.cardSetIdsBySharedZoneId)[Z] extends readonly []
7371
- ? never
7372
- : Z;
7215
+ [Zone in (typeof literals.sharedZoneIds)[number]]:
7216
+ (typeof literals.cardSetIdsBySharedZoneId)[Zone] extends readonly []
7217
+ ? never
7218
+ : Zone;
7373
7219
  }[(typeof literals.sharedZoneIds)[number]];
7374
-
7375
- type CardZoneId = PlayerCardZoneId | SharedCardZoneId;
7376
-
7377
- /** JS-friendly keys for per-player zones that can contain cards. */
7378
- export type WorkspacePlayerCardZoneKey = CamelCase<PlayerCardZoneId>;
7379
-
7380
- /** Interaction descriptor specialised to a concrete phase-qualified key. */
7381
- export type InteractionDescriptorFor<Key extends InteractionKey> =
7382
- InteractionDescriptor<Key>;
7383
-
7384
- export type InteractionItem<Key extends InteractionKey> = {
7385
- readonly interaction: Key;
7386
- readonly descriptor: InteractionDescriptorFor<Key>;
7387
- };
7388
-
7389
- /**
7390
- * Params shape for a phase-qualified interaction key. Drives strong typing
7391
- * for component-first interaction state, forms, and submits.
7392
- */
7393
- export type InteractionParamsOf<Key extends InteractionKey> =
7394
- InteractionParams<PhaseOfInteractionKey<Key>, IdOfInteractionKey<Key>>;
7395
-
7396
- export type InteractionDefaultedKeysOf<Key extends InteractionKey> =
7397
- InteractionDefaultedKeys<PhaseOfInteractionKey<Key>, IdOfInteractionKey<Key>>;
7398
-
7399
- type InteractionParamsShape<Key extends InteractionKey> =
7400
- InteractionParamsOf<Key> extends Record<string, unknown>
7401
- ? InteractionParamsOf<Key>
7220
+ type ManifestTypes = {
7221
+ PlayerId: PlayerId & string;
7222
+ ResourceId: ResourceId & string;
7223
+ ZoneId: ZoneId & string;
7224
+ CardId: [CardId] extends [never] ? string : CardId & string;
7225
+ CardType: [CardType] extends [never] ? string : CardType & string;
7226
+ CardProperties: CardProperties extends Record<string, unknown>
7227
+ ? CardProperties
7402
7228
  : Record<string, unknown>;
7403
-
7404
- type InteractionCollectorKind =
7405
- | "form"
7406
- | "board-vertex"
7407
- | "board-edge"
7408
- | "board-tile"
7409
- | "board-space"
7410
- | "card"
7411
- | "prompt";
7412
-
7413
- type AuthoredInteractionInputKeysOf<Key extends InteractionKey> =
7414
- InputKeysWithCollectorKindOfDefinition<
7415
- GameDefinition,
7416
- PhaseOfInteractionKey<Key>,
7417
- IdOfInteractionKey<Key>,
7418
- InteractionCollectorKind
7419
- > extends infer Input
7420
- ? string extends Input
7421
- ? never
7422
- : Input & string
7423
- : never;
7424
-
7425
- type InteractionInputKeysOf<Key extends InteractionKey> =
7426
- | (string extends keyof InteractionParamsOf<Key>
7427
- ? never
7428
- : keyof InteractionParamsOf<Key> & string)
7429
- | AuthoredInteractionInputKeysOf<Key>
7430
- | (InteractionDefaultedKeysOf<Key> & string);
7431
-
7432
- type InteractionHandleDefaultedKeys<Key extends InteractionKey> = Extract<
7433
- InteractionDefaultedKeysOf<Key>,
7434
- keyof InteractionParamsShape<Key> & string
7435
- >;
7436
-
7437
- type RequiredInteractionInputKeysOf<Key extends InteractionKey> =
7438
- InteractionInputKeysOf<Key>;
7439
-
7440
- export type RequiredInteractionInputKey<Key extends InteractionKey> =
7441
- RequiredInteractionInputKeysOf<Key>;
7442
-
7443
- type InteractionSlotComponent<Props = object> = (
7444
- props: Props extends { children?: unknown }
7445
- ? Props
7446
- : Props & { children?: ReactNode },
7447
- ) => ReactElement | null;
7448
-
7449
- type InteractionDefaultInputSlot = {
7450
- readonly Default: InteractionSlotComponent;
7451
- };
7452
-
7453
- type InteractionValueInputSlot<Value = unknown> = {
7454
- readonly Value: InteractionSlotComponent<{
7455
- children: (value: unknown | undefined) => ReactNode;
7456
- }>;
7457
- };
7458
-
7459
- type InteractionFormInputSlot<Value = unknown> = {
7460
- readonly Field: InteractionSlotComponent;
7461
- readonly Options: InteractionSlotComponent<{
7462
- children: (option: { value: Value; label: string }) => ReactNode;
7463
- }>;
7464
- };
7465
-
7466
- type DreamboardSlotBrand<Meta> = {
7467
- readonly __dreamboardSlot: Meta;
7468
- };
7469
-
7470
- type InteractionCardTargetInputSlot<Card extends string = string> = {
7471
- readonly Card: InteractionSlotComponent<
7472
- { value: string } & Omit<
7473
- ButtonHTMLAttributes<HTMLButtonElement>,
7474
- | "children"
7475
- | "disabled"
7476
- | "aria-disabled"
7477
- | "aria-pressed"
7478
- | "onClick"
7479
- | "type"
7480
- | "value"
7481
- >
7482
- >;
7483
- readonly Cards: InteractionSlotComponent<{
7484
- children: (card: { id: Card }) => ReactNode;
7485
- }>;
7486
- };
7487
-
7488
- type InteractionBoardTargetInputSlot<Target extends string = string> = {
7489
- readonly Target: InteractionSlotComponent<
7490
- { value: string } & Omit<
7491
- ButtonHTMLAttributes<HTMLButtonElement>,
7492
- | "children"
7493
- | "disabled"
7494
- | "aria-disabled"
7495
- | "aria-pressed"
7496
- | "onClick"
7497
- | "type"
7498
- | "value"
7499
- >
7500
- >;
7501
- };
7502
-
7503
- type InteractionBoardSpaceTargetInputSlot<Space extends string = string> =
7504
- InteractionBoardTargetInputSlot<Space>;
7505
-
7506
- type InteractionBoardEdgeTargetInputSlot<Edge extends string = string> =
7507
- InteractionBoardTargetInputSlot<Edge>;
7508
-
7509
- type InteractionBoardVertexTargetInputSlot<Vertex extends string = string> =
7510
- InteractionBoardTargetInputSlot<Vertex>;
7511
-
7512
- type InteractionBoardTileTargetInputSlot<Tile extends string = string> =
7513
- InteractionBoardTargetInputSlot<Tile>;
7514
-
7515
- type InteractionSubmitSlot = {
7516
- readonly Button: InteractionSlotComponent<
7517
- Omit<
7518
- ButtonHTMLAttributes<HTMLButtonElement>,
7519
- "children" | "disabled" | "type" | "value"
7520
- >
7521
- >;
7522
- };
7523
-
7524
- type InteractionInputValue<
7525
- Key extends InteractionKey,
7526
- Input extends InteractionInputKeysOf<Key>,
7527
- > = InteractionParamsShape<Key>[Input & keyof InteractionParamsShape<Key>];
7528
-
7529
- type InteractionSlotValue<Value> = Value extends readonly (infer Item)[]
7530
- ? InteractionSlotValue<Item>
7531
- : Value extends { spaceId: infer Space extends string }
7532
- ? Space
7533
- : Value extends { edgeId: infer Edge extends string }
7534
- ? Edge
7535
- : Value extends { vertexId: infer Vertex extends string }
7536
- ? Vertex
7537
- : Value extends { tileId: infer Tile extends string }
7538
- ? Tile
7539
- : Value extends { cardId: infer Card extends string }
7540
- ? Card
7541
- : Value;
7542
-
7543
- type InteractionSlotStringValue<Value> = Extract<
7544
- InteractionSlotValue<Value>,
7545
- string
7546
- >;
7547
-
7548
- type FormInteractionInputKey<Key extends InteractionKey> =
7549
- InputKeysWithCollectorKindOfDefinition<
7550
- GameDefinition,
7551
- PhaseOfInteractionKey<Key>,
7552
- IdOfInteractionKey<Key>,
7553
- "form" | "prompt"
7554
- > &
7555
- InteractionInputKeysOf<Key>;
7556
-
7557
- type CardTargetInteractionInputKey<Key extends InteractionKey> =
7558
- InputKeysWithCollectorKindOfDefinition<
7559
- GameDefinition,
7560
- PhaseOfInteractionKey<Key>,
7561
- IdOfInteractionKey<Key>,
7562
- "card"
7563
- > &
7564
- InteractionInputKeysOf<Key>;
7565
-
7566
- type CardTargetZoneIds<
7567
- Key extends InteractionKey,
7568
- Input extends InteractionInputKeysOf<Key>,
7569
- > =
7570
- CardInputZoneIdsOfDefinition<
7571
- GameDefinition,
7572
- PhaseOfInteractionKey<Key>,
7573
- IdOfInteractionKey<Key>,
7574
- Input & string
7575
- > extends infer Zone extends string
7576
- ? Extract<Zone, WorkspaceZoneId>
7577
- : never;
7578
-
7579
- type BoardSpaceTargetInteractionInputKey<Key extends InteractionKey> =
7580
- InputKeysWithCollectorKindOfDefinition<
7581
- GameDefinition,
7582
- PhaseOfInteractionKey<Key>,
7583
- IdOfInteractionKey<Key>,
7584
- "board-space"
7585
- > &
7586
- InteractionInputKeysOf<Key>;
7587
-
7588
- type BoardEdgeTargetInteractionInputKey<Key extends InteractionKey> =
7589
- InputKeysWithCollectorKindOfDefinition<
7590
- GameDefinition,
7591
- PhaseOfInteractionKey<Key>,
7592
- IdOfInteractionKey<Key>,
7593
- "board-edge"
7594
- > &
7595
- InteractionInputKeysOf<Key>;
7596
-
7597
- type BoardVertexTargetInteractionInputKey<Key extends InteractionKey> =
7598
- InputKeysWithCollectorKindOfDefinition<
7599
- GameDefinition,
7600
- PhaseOfInteractionKey<Key>,
7601
- IdOfInteractionKey<Key>,
7602
- "board-vertex"
7603
- > &
7604
- InteractionInputKeysOf<Key>;
7605
-
7606
- type BoardTileTargetInteractionInputKey<Key extends InteractionKey> =
7607
- InputKeysWithCollectorKindOfDefinition<
7608
- GameDefinition,
7609
- PhaseOfInteractionKey<Key>,
7610
- IdOfInteractionKey<Key>,
7611
- "board-tile"
7612
- > &
7613
- InteractionInputKeysOf<Key>;
7614
-
7615
- type InteractionDefaultSlotFor<
7616
- Key extends InteractionKey,
7617
- Input extends InteractionInputKeysOf<Key>,
7618
- > = Input extends InteractionHandleDefaultedKeys<Key>
7619
- ? InteractionDefaultInputSlot
7620
- : object;
7621
-
7622
- export type InteractionInputSlot<
7623
- Key extends InteractionKey,
7624
- Input extends InteractionInputKeysOf<Key>,
7625
- > = InteractionValueInputSlot<InteractionInputValue<Key, Input>> &
7626
- InteractionDefaultSlotFor<Key, Input> &
7627
- (Input extends CardTargetInteractionInputKey<Key>
7628
- ? InteractionCardTargetInputSlot<
7629
- InteractionSlotStringValue<InteractionInputValue<Key, Input>>
7630
- >
7631
- : Input extends BoardSpaceTargetInteractionInputKey<Key>
7632
- ? InteractionBoardSpaceTargetInputSlot<
7633
- InteractionSlotStringValue<InteractionInputValue<Key, Input>>
7634
- >
7635
- : Input extends BoardEdgeTargetInteractionInputKey<Key>
7636
- ? InteractionBoardEdgeTargetInputSlot<
7637
- InteractionSlotStringValue<InteractionInputValue<Key, Input>>
7638
- >
7639
- : Input extends BoardVertexTargetInteractionInputKey<Key>
7640
- ? InteractionBoardVertexTargetInputSlot<
7641
- InteractionSlotStringValue<InteractionInputValue<Key, Input>>
7642
- >
7643
- : Input extends BoardTileTargetInteractionInputKey<Key>
7644
- ? InteractionBoardTileTargetInputSlot<
7645
- InteractionSlotStringValue<InteractionInputValue<Key, Input>>
7646
- >
7647
- : Input extends FormInteractionInputKey<Key>
7648
- ? InteractionFormInputSlot<InteractionInputValue<Key, Input>>
7649
- : never);
7650
-
7651
- type FormSurfaceInputSlot<
7652
- Key extends InteractionKey,
7653
- Input extends FormInteractionInputKey<Key>,
7654
- > = InteractionValueInputSlot<InteractionInputValue<Key, Input>> &
7655
- InteractionDefaultSlotFor<Key, Input> &
7656
- InteractionFormInputSlot<InteractionInputValue<Key, Input>> &
7657
- DreamboardSlotBrand<{
7658
- readonly kind: "form";
7659
- readonly interaction: Key;
7660
- readonly input: Input;
7661
- }>;
7662
-
7663
- type CardSurfaceInputSlot<Zones extends string> =
7664
- InteractionValueInputSlot<unknown> &
7665
- InteractionCardTargetInputSlot<WorkspaceCardId & string> &
7666
- DreamboardSlotBrand<{
7667
- readonly kind: "card";
7668
- readonly zones: Zones;
7669
- readonly selection: "one" | "many";
7670
- }>;
7671
-
7672
- type BoardSurfaceInputSlot<
7673
- Kind extends "space" | "edge" | "vertex" | "tile",
7674
- Target extends string = string,
7675
- > =
7676
- InteractionValueInputSlot<unknown> &
7677
- InteractionBoardTargetInputSlot<Target> &
7678
- DreamboardSlotBrand<{
7679
- readonly kind: "board";
7680
- readonly targetKind: Kind;
7681
- }>;
7682
-
7683
- type InteractionCollectorSlot<
7684
- Key extends InteractionKey,
7685
- Input extends InteractionInputKeysOf<Key>,
7686
- > = Input extends CardTargetInteractionInputKey<Key>
7687
- ? CardSurfaceInputSlot<CardTargetZoneIds<Key, Input>>
7688
- : Input extends BoardSpaceTargetInteractionInputKey<Key>
7689
- ? BoardSurfaceInputSlot<"space", string>
7690
- : Input extends BoardEdgeTargetInteractionInputKey<Key>
7691
- ? BoardSurfaceInputSlot<"edge", string>
7692
- : Input extends BoardVertexTargetInteractionInputKey<Key>
7693
- ? BoardSurfaceInputSlot<"vertex", string>
7694
- : Input extends BoardTileTargetInteractionInputKey<Key>
7695
- ? BoardSurfaceInputSlot<"tile", string>
7696
- : Input extends FormInteractionInputKey<Key>
7697
- ? FormSurfaceInputSlot<Key, Input>
7698
- : never;
7699
-
7700
- type InteractionKeysWithInput<Input extends InteractionInputKey> = {
7701
- [Key in InteractionKey]: Input extends InteractionInputKeysOf<Key>
7702
- ? Key
7703
- : never;
7704
- }[InteractionKey];
7705
-
7706
- type InteractionInputSlotByName<Input extends InteractionInputKey> =
7707
- InteractionInputSlot<
7708
- InteractionKeysWithInput<Input>,
7709
- Input & InteractionInputKeysOf<InteractionKeysWithInput<Input>>
7710
- >;
7711
-
7712
- type InteractionFormInputSlotByName<Input extends InteractionInputKey> =
7713
- InteractionInputSlot<
7714
- {
7715
- [Key in InteractionKey]: Input extends FormInteractionInputKey<Key>
7716
- ? Key
7717
- : never;
7718
- }[InteractionKey],
7719
- Input &
7720
- InteractionInputKeysOf<
7721
- {
7722
- [Key in InteractionKey]: Input extends FormInteractionInputKey<Key>
7723
- ? Key
7724
- : never;
7725
- }[InteractionKey]
7726
- >
7727
- >;
7728
-
7729
- type InteractionInputsForCollectorKind<
7730
- Key extends InteractionKey,
7731
- CollectorKind extends InteractionCollectorKind,
7732
- > = {
7733
- [Input in InteractionInputKeysOf<Key>]: CollectorKind extends "form"
7734
- ? Input extends FormInteractionInputKey<Key>
7735
- ? Input
7736
- : never
7737
- : CollectorKind extends "card"
7738
- ? Input extends CardTargetInteractionInputKey<Key>
7739
- ? Input
7740
- : never
7741
- : CollectorKind extends "board-space"
7742
- ? Input extends BoardSpaceTargetInteractionInputKey<Key>
7743
- ? Input
7744
- : never
7745
- : CollectorKind extends "board-edge"
7746
- ? Input extends BoardEdgeTargetInteractionInputKey<Key>
7747
- ? Input
7748
- : never
7749
- : CollectorKind extends "board-vertex"
7750
- ? Input extends BoardVertexTargetInteractionInputKey<Key>
7751
- ? Input
7752
- : never
7753
- : CollectorKind extends "board-tile"
7754
- ? Input extends BoardTileTargetInteractionInputKey<Key>
7755
- ? Input
7756
- : never
7757
- : never;
7758
- }[InteractionInputKeysOf<Key>];
7759
-
7760
- type InteractionKeysForCollectorKind<
7761
- CollectorKind extends InteractionCollectorKind,
7762
- > = {
7763
- [Key in InteractionKey]: InteractionInputsForCollectorKind<
7764
- Key,
7765
- CollectorKind
7766
- > extends never
7767
- ? never
7768
- : Key;
7769
- }[InteractionKey];
7770
-
7771
- type InteractionInputSlotByCollectorKind<
7772
- CollectorKind extends InteractionCollectorKind,
7773
- > = InteractionInputSlot<
7774
- InteractionKeysForCollectorKind<CollectorKind>,
7775
- InteractionInputsForCollectorKind<
7776
- InteractionKeysForCollectorKind<CollectorKind>,
7777
- CollectorKind
7778
- >
7779
- >;
7780
-
7781
- export type InteractionFormSurface<Key extends InteractionKey> = {
7782
- readonly Root: InteractionSlotComponent;
7783
- readonly Form: DreamboardUI<typeof uiContract>["Interaction"]["Form"];
7784
- readonly Dialog: (props: WorkspaceInteractionFormDialogProps) => ReactElement | null;
7785
- readonly State: DreamboardUI<typeof uiContract>["Interaction"]["State"];
7786
- readonly Arm: DreamboardUI<typeof uiContract>["Interaction"]["Trigger"];
7787
- readonly Submit: DreamboardUI<typeof uiContract>["Interaction"]["Submit"];
7788
- readonly Field: <Input extends FormInteractionInputKey<Key>>(
7789
- props: { input: Input; children?: ReactNode },
7790
- ) => ReactElement | null;
7791
- readonly slot: {
7792
- readonly [Input in FormInteractionInputKey<Key>]: FormSurfaceInputSlot<
7793
- Key,
7794
- Input
7795
- >;
7796
- };
7797
- };
7798
-
7799
- type BoardSurfaceSpaceProps<Target extends string> = {
7800
- value: Target;
7801
- children?: ReactNode;
7802
- } & Omit<BoardSpaceTargetPropsGeneric<Target>, "value" | "children">;
7803
-
7804
- export type BoardSurfaceBoardId = BoardBaseId & string;
7805
-
7806
- type BoardSurfaceRuntimeBoardId<Board extends BoardSurfaceBoardId> =
7807
- ReturnType<typeof boardHelpers.boardIdsForBase<Board>>[number] & string;
7808
-
7809
- type BoardSurfaceSpaceId<Board extends BoardSurfaceBoardId> =
7810
- ReturnType<
7811
- typeof boardHelpers.spaceIds<BoardSurfaceRuntimeBoardId<Board>>
7812
- >[number] &
7813
- string;
7814
-
7815
- type BoardSurfaceTiledBoardId<Board extends BoardSurfaceBoardId> = Extract<
7816
- BoardSurfaceRuntimeBoardId<Board>,
7817
- TiledBoardId
7818
- >;
7819
-
7820
- type BoardSurfaceEdgeId<Board extends BoardSurfaceBoardId> =
7821
- TiledEdgeState<BoardSurfaceTiledBoardId<Board>> extends { id: infer Id }
7822
- ? Id & string
7823
- : EdgeId & string;
7824
-
7825
- type BoardSurfaceVertexId<Board extends BoardSurfaceBoardId> =
7826
- TiledVertexState<BoardSurfaceTiledBoardId<Board>> extends { id: infer Id }
7827
- ? Id & string
7828
- : VertexId & string;
7829
-
7830
- export type BoardSurface<Board extends BoardSurfaceBoardId = BoardSurfaceBoardId> = {
7831
- readonly Root: InteractionSlotComponent;
7832
- readonly Space: <Target extends BoardSurfaceSpaceId<Board>>(
7833
- props: BoardSurfaceSpaceProps<Target>,
7834
- ) => ReactElement;
7835
- readonly slot: {
7836
- readonly space: BoardSurfaceInputSlot<
7837
- "space",
7838
- BoardSurfaceSpaceId<Board>
7839
- >;
7840
- readonly playerSpace: BoardSurfaceInputSlot<
7841
- "space",
7842
- BoardSurfaceSpaceId<Board>
7843
- >;
7844
- readonly edge: BoardSurfaceInputSlot<"edge", BoardSurfaceEdgeId<Board>>;
7845
- readonly vertex: BoardSurfaceInputSlot<
7846
- "vertex",
7847
- BoardSurfaceVertexId<Board>
7848
- >;
7849
- readonly tile: BoardSurfaceInputSlot<"tile", BoardSurfaceSpaceId<Board>>;
7850
- };
7851
- };
7852
-
7853
- type ZoneCardsComponent = InteractionSlotComponent<
7854
- Omit<ZoneListProps, "children" | "empty"> & {
7855
- empty?: ReactNode;
7856
- children: (card: WorkspaceZoneCard) => ReactNode;
7857
- }
7858
- >;
7859
-
7860
- type ZoneCardComponent = InteractionSlotComponent<
7861
- Omit<ButtonHTMLAttributes<HTMLButtonElement>, "type" | "value"> & {
7862
- card: WorkspaceZoneCard;
7863
- }
7864
- >;
7865
-
7866
- /**
7867
- * Generic SDK card-intent shape for typed hand emission. Authors do not
7868
- * import the runtime; the typed \`targetId\` is constrained by the
7869
- * authored interaction domain on the generated hand surface.
7870
- */
7871
- export type HandCardIntent<Card extends string, Target extends string> =
7872
- | { type: "activate"; cardId: Card; source: "tap" | "keyboard" }
7873
- | { type: "previewStart"; cardId: Card }
7874
- | { type: "previewEnd"; cardId: Card }
7875
- | {
7876
- type: "drop";
7877
- cardId: Card;
7878
- targetId: Target;
7879
- source: "pointer" | "keyboard";
7880
- };
7881
-
7882
- export type HandLayoutKindGen = "fan" | "compressed-fan" | "tray" | "strip" | "stack";
7883
- export type HandLayoutPolicyGen = {
7884
- desktop?: HandLayoutKindGen;
7885
- mobile?: HandLayoutKindGen;
7229
+ BoardBaseId: BoardBaseId & string;
7230
+ SpaceId: SpaceId & string;
7231
+ EdgeId: EdgeId & string;
7232
+ VertexId: VertexId & string;
7233
+ PlayerCardZoneId: PlayerCardZoneId & string;
7234
+ CardZoneId: (PlayerCardZoneId | SharedCardZoneId) & string;
7886
7235
  };
7887
- export type HandMobileInteractionPolicy = "direct-activate" | "drag-to-target";
7888
7236
 
7889
- export type HandStagingTarget<Card extends string> = {
7890
- readonly kind: "card";
7891
- readonly card: Card;
7892
- };
7893
-
7894
- export type HandBoardDropTargetKind = "space" | "edge" | "vertex" | "tile";
7895
-
7896
- /**
7897
- * Discriminated union that ties each board target kind to its manifest id
7898
- * family. \`tile\` shares the space-id family because tiles are addressed
7899
- * by their underlying space.
7900
- */
7901
- export type HandBoardDropTarget<
7902
- Space extends string,
7903
- Edge extends string,
7904
- Vertex extends string,
7905
- > =
7906
- | { readonly kind: "space"; readonly target: Space }
7907
- | { readonly kind: "edge"; readonly target: Edge }
7908
- | { readonly kind: "vertex"; readonly target: Vertex }
7909
- | { readonly kind: "tile"; readonly target: Space };
7910
-
7911
- export type HandDropTargetSpec<
7912
- Card extends string,
7913
- Space extends string,
7914
- Edge extends string,
7915
- Vertex extends string,
7916
- > = HandStagingTarget<Card> | HandBoardDropTarget<Space, Edge, Vertex>;
7917
-
7918
- /** Union of all manifest target ids the typed hand can carry. */
7919
- export type HandAuthoredTarget<
7920
- Card extends string,
7921
- Space extends string,
7922
- Edge extends string,
7923
- Vertex extends string,
7924
- > = Card | Space | Edge | Vertex;
7925
-
7926
- /**
7927
- * Summary projected from the live draft for a single hand. Authors render
7928
- * counts and validity hints through the compound \`hand.Summary\` and
7929
- * \`hand.Actions\` slots, or mirror them to outside state via
7930
- * \`onSelectionSummary\`.
7931
- */
7932
- export type HandSelectionSummary<Card extends string> = {
7933
- readonly selectedCount: number;
7934
- readonly selectedIds: readonly Card[];
7935
- readonly hasInvalidSelection: boolean;
7936
- };
7937
-
7938
- export type HandSurfaceProps<
7939
- Card extends string,
7940
- Space extends string,
7941
- Edge extends string,
7942
- Vertex extends string,
7943
- > = Omit<ZoneListProps, "children" | "empty"> & {
7944
- empty?: ReactNode;
7945
- /**
7946
- * Per-card render callback. Receives the projected
7947
- * \`InteractionVisualState\` (\`eligible\`, \`selected\`, \`invalid\`,
7948
- * \`disabled\`) so authors can wire SDK \`CardFace\` directly without
7949
- * recomputing draft state.
7950
- */
7951
- children: (
7952
- card: WorkspaceZoneCard,
7953
- state: InteractionVisualState,
7954
- ) => ReactNode;
7955
- layout?: HandLayoutKindGen | HandLayoutPolicyGen;
7956
- mobileInteraction?: HandMobileInteractionPolicy;
7957
- cardSize?: "sm" | "md" | "lg";
7958
- ariaLabel?: string;
7959
- /**
7960
- * Typed drop targets that participate in \`drag-to-target\` interaction.
7961
- * Each target's \`kind\` constrains the allowed \`target\` id family, so
7962
- * a \`SpaceId\` cannot be authored as an edge or vertex target.
7963
- */
7964
- dropTargets?: ReadonlyArray<{
7965
- target: HandDropTargetSpec<Card, Space, Edge, Vertex>;
7966
- label: string;
7967
- render: (state: unknown) => ReactNode;
7968
- className?: string;
7969
- role?: string;
7970
- order?: number;
7971
- }>;
7972
- renderDropTargets?: (children: ReactNode) => ReactNode;
7973
- onCardIntent?: (
7974
- intent: HandCardIntent<Card, HandAuthoredTarget<Card, Space, Edge, Vertex>>,
7975
- ) => void;
7976
- /**
7977
- * Optional selection summary observer. Invoked from a layout effect so
7978
- * consumers may safely call \`setState\` in response.
7979
- */
7980
- onSelectionSummary?: (summary: HandSelectionSummary<Card>) => void;
7981
- };
7982
-
7983
- type HandComponent<
7984
- Card extends string,
7985
- Space extends string,
7986
- Edge extends string,
7987
- Vertex extends string,
7988
- > = InteractionSlotComponent<
7989
- Omit<HandSurfaceProps<Card, Space, Edge, Vertex>, "children"> & {
7990
- children: ReactNode;
7991
- }
7992
- >;
7993
-
7994
- type HandCardsComponent = InteractionSlotComponent<{
7995
- children: (
7996
- card: WorkspaceZoneCard,
7997
- state: InteractionVisualState,
7998
- ) => ReactNode;
7999
- }>;
8000
-
8001
- type HandSummaryComponent<Card extends string> = InteractionSlotComponent<{
8002
- children?: ReactNode | ((summary: HandSelectionSummary<Card>) => ReactNode);
8003
- }>;
8004
-
8005
- /**
8006
- * Always-visible staging surface for a many-select card collection (e.g. the
8007
- * cards you've chosen to pass): a fixed row of slots showing the staged cards,
8008
- * with empty placeholders otherwise. Tapping a staged card removes it from the
8009
- * collection (it returns to the hand). Renders nothing when the zone has no
8010
- * active many-select collection, so it can be mounted unconditionally.
8011
- */
8012
- export type HandStagingProps = {
8013
- // Staged cards are always visible (you can only stage a card you can see), so
8014
- // the slot renderer receives the hydrated card variant \u2014 no hidden-card guard.
8015
- children: (card: Extract<WorkspaceZoneCard, { hidden: false }>) => ReactNode;
8016
- label?: ReactNode;
8017
- renderEmptySlot?: (index: number) => ReactNode;
8018
- cardSize?: "sm" | "md" | "lg";
8019
- ariaLabel?: string;
8020
- className?: string;
8021
- };
8022
-
8023
- type HandStagingComponent = InteractionSlotComponent<HandStagingProps>;
8024
-
8025
- export type HandSurface<Zones extends readonly WorkspaceZoneId[] = readonly WorkspaceZoneId[]> = {
8026
- readonly Hand: HandComponent<
8027
- CardId & string,
8028
- SpaceId & string,
8029
- EdgeId & string,
8030
- VertexId & string
8031
- >;
8032
- readonly Cards: HandCardsComponent;
8033
- readonly Summary: HandSummaryComponent<CardId & string>;
8034
- readonly Actions: HandSummaryComponent<CardId & string>;
8035
- readonly Card: ZoneCardComponent;
8036
- readonly Staging: HandStagingComponent;
8037
- readonly slot: {
8038
- readonly card: CardSurfaceInputSlot<Zones[number] & string>;
8039
- };
8040
- };
8041
-
8042
- export type PileSurface<Zones extends readonly WorkspaceZoneId[] = readonly WorkspaceZoneId[]> = {
8043
- readonly Pile: ZoneCardsComponent;
8044
- readonly Card: ZoneCardComponent;
8045
- };
8046
-
8047
- export type CardCollectionSurface<Zones extends readonly WorkspaceZoneId[] = readonly WorkspaceZoneId[]> = {
8048
- readonly Collection: ZoneCardsComponent;
8049
- readonly Card: ZoneCardComponent;
8050
- readonly slot: {
8051
- readonly card: CardSurfaceInputSlot<Zones[number] & string>;
8052
- };
8053
- };
8054
-
8055
- export type InteractionFormInputs<Key extends InteractionKey> = {
8056
- [Input in InteractionInputKeysOf<Key>]: (
8057
- slot: InteractionInputSlot<Key, Input>,
8058
- ) => ReactNode;
8059
- };
8060
-
8061
- export type InteractionCollectSlots<Key extends InteractionKey> = {
8062
- [Input in RequiredInteractionInputKeysOf<Key>]: InteractionCollectorSlot<
8063
- Key,
8064
- Input
8065
- >;
8066
- };
8067
-
8068
- export type InteractionRoute<Key extends InteractionKey> = {
8069
- readonly collect: InteractionCollectSlots<Key>;
8070
- };
8071
-
8072
- export type InteractionRoutes = Partial<{
8073
- [Key in InteractionKey]: InteractionRoute<Key>;
8074
- }>;
8075
-
8076
- export type InteractionRoutesProps = {
8077
- routes: InteractionRoutes;
8078
- fallback?: ReactNode;
8079
- includeUnavailable?: boolean | null;
8080
- };
8081
-
8082
- export type ZeroInputInteractionKey = {
8083
- [K in InteractionKey]: InteractionInputKeysOf<K> extends never
8084
- ? K
8085
- : never;
8086
- }[InteractionKey];
8087
-
8088
- export type InputInteractionKey = Exclude<
8089
- InteractionKey,
8090
- ZeroInputInteractionKey
8091
- >;
8092
-
8093
- type InteractionInputKeyOf<Key extends InteractionKey> =
8094
- Key extends InteractionKey ? InteractionInputKeysOf<Key> : never;
8095
-
8096
- export type InteractionInputKey = InteractionInputKeyOf<InteractionKey>;
8097
-
8098
- export type PromptKey = InteractionKey;
8099
-
8100
- export type PromptOptionValue = string;
8101
-
8102
- export type BoardTargetId = SpaceId | EdgeId | VertexId;
8103
-
8104
- type UIInteractionRegistry = {
8105
- [K in InteractionKey]: {
8106
- interaction: K;
8107
- phase: PhaseOfInteractionKey<K>;
8108
- id: IdOfInteractionKey<K>;
8109
- };
8110
- };
8111
-
8112
- type UIInputRegistry = {
8113
- [K in InteractionInputKey]: { input: K };
8114
- };
8115
-
8116
- type UIPromptRegistry = {
8117
- [K in PromptKey]: { interaction: K };
8118
- };
8119
-
8120
- type UIPromptOptionRegistry = {
8121
- [K in PromptOptionValue]: { value: K };
8122
- };
8123
-
8124
- type UIPlayerRegistry = {
8125
- [K in PlayerId & string]: { player: K };
8126
- };
8127
-
8128
- type UIZoneRegistry = {
8129
- [K in ZoneId & string]: { zone: K };
8130
- };
8131
-
8132
- type UICardRegistry = {
8133
- [K in CardId & string]: { card: K };
8134
- };
8135
-
8136
- type UIPhaseRegistry = {
8137
- [K in PhaseName & string]: { phase: K };
8138
- };
8139
-
8140
- type UIBoardTargetRegistry = {
8141
- [K in BoardTargetId & string]: { target: K };
8142
- };
7237
+ const contract = createGameUiContract<
7238
+ GameDefinition,
7239
+ ManifestTypes,
7240
+ typeof staticBoards.hex,
7241
+ typeof staticBoards.square
7242
+ >({
7243
+ game,
7244
+ resourceIds: literals.resourceIds as readonly ResourceId[],
7245
+ resourcePresentationById: literals.resourcePresentationById,
7246
+ hexStaticBoards: staticBoards.hex,
7247
+ squareStaticBoards: staticBoards.square,
7248
+ });
8143
7249
 
8144
- export const uiContract = {
8145
- interactions: {} as UIInteractionRegistry,
8146
- inputs: {} as UIInputRegistry,
8147
- prompts: {} as UIPromptRegistry,
8148
- promptOptions: {} as UIPromptOptionRegistry,
8149
- players: {} as UIPlayerRegistry,
8150
- zones: {} as UIZoneRegistry,
8151
- cards: {} as UICardRegistry,
8152
- phases: {} as UIPhaseRegistry,
8153
- boardTargets: {} as UIBoardTargetRegistry,
8154
- } satisfies UIContract;
7250
+ export const uiContract = contract.uiContract;
7251
+ export const UI = contract.UI;
7252
+ export const clientParamSchemasByPhase = contract.clientParamSchemasByPhase;
7253
+ export const Board = UI.Board;
7254
+ export const Zone = UI.Zone;
7255
+ export const Game = UI.Game;
7256
+ export const Interaction = UI.Interaction;
7257
+ export const PlayerRoster = UI.PlayerRoster;
7258
+ export const Dice = UI.Dice;
7259
+ export const Phase = UI.Phase;
7260
+ export const ResourceCounter = UI.ResourceCounter;
7261
+
7262
+ export type ViewName = import("@dreamboard-games/sdk/runtime/workspace-contract").GameUiViewName<GameDefinition>;
7263
+ export type GameView = GameUiView<GameDefinition>;
7264
+ export type PhaseName = GameUiPhaseName<GameDefinition>;
7265
+ export type GameRootState = GameUiGameRootState<GameDefinition, ManifestTypes>;
7266
+ export type GamePlayers = GameUiPlayers<ManifestTypes>;
7267
+ export type GameMe = GameUiMe<ManifestTypes>;
7268
+ export type GameTurn = GameUiTurn<GameDefinition, ManifestTypes>;
7269
+ export type InteractionKey = GameUiInteractionKey<GameDefinition>;
7270
+ export type InteractionRoutes = GameUiInteractionRoutes<GameDefinition>;
7271
+ export type InteractionFormSurface<Key extends InteractionKey> =
7272
+ GameUiInteractionFormSurface<GameDefinition, typeof uiContract, Key>;
7273
+ export type BoardSurface<
7274
+ Board extends ManifestTypes["BoardBaseId"] = ManifestTypes["BoardBaseId"],
7275
+ > = GameUiBoardSurface<ManifestTypes, Board>;
7276
+ export type HandSurface<
7277
+ Zones extends readonly ManifestTypes["ZoneId"][] = readonly ManifestTypes["ZoneId"][],
7278
+ > = GameUiHandSurface<ManifestTypes, Zones>;
7279
+ export type CardCollectionSurface<
7280
+ Zones extends readonly ManifestTypes["ZoneId"][] = readonly ManifestTypes["ZoneId"][],
7281
+ > = GameUiCardCollectionSurface<ManifestTypes, Zones>;
8155
7282
 
8156
7283
  declare module "@dreamboard-games/sdk/runtime" {
8157
7284
  interface DreamboardUIRegister {
@@ -8159,271 +7286,6 @@ declare module "@dreamboard-games/sdk/runtime" {
8159
7286
  ui: typeof uiContract;
8160
7287
  }
8161
7288
  }
8162
-
8163
- // -------------------------------------------------------------------------
8164
- // Typed hex-board view adapter
8165
- // -------------------------------------------------------------------------
8166
-
8167
- /** Generated hex-board topology source, keyed by hex-board id. */
8168
- const hexStaticBoards = staticBoards.hex;
8169
-
8170
- /** Generated square-board topology source, keyed by square-board id. */
8171
- const squareStaticBoards = staticBoards.square;
8172
-
8173
- /** Union of authored hex-board ids in this workspace's manifest. */
8174
- export type HexBoardId = keyof typeof hexStaticBoards & string;
8175
-
8176
- /** Union of authored square-board ids in this workspace's manifest. */
8177
- export type SquareBoardId = keyof typeof squareStaticBoards & string;
8178
-
8179
- /** Topology object for the named hex board, drawn from \`staticBoards.hex\`. */
8180
- export type HexBoardTopology<Id extends HexBoardId> = (typeof hexStaticBoards)[Id];
8181
-
8182
- /** Topology object for the named square board, drawn from \`staticBoards.square\`. */
8183
- export type SquareBoardTopology<Id extends SquareBoardId> = (typeof squareStaticBoards)[Id];
8184
-
8185
- /** Space id type for the named hex board. */
8186
- export type HexBoardSpaceId<Id extends HexBoardId> = BoardSpaceIdOf<
8187
- HexBoardTopology<Id>
8188
- >;
8189
-
8190
- /** Space id type for the named square board. */
8191
- export type SquareBoardSpaceId<Id extends SquareBoardId> = BoardSpaceIdOf<
8192
- SquareBoardTopology<Id>
8193
- >;
8194
-
8195
- export type HexBoardViewProps<
8196
- Id extends HexBoardId,
8197
- TSpaceView extends { id: HexBoardSpaceId<Id> },
8198
- > = Omit<BoardHexViewPropsGeneric<HexBoardTopology<Id>, TSpaceView>, "board"> & {
8199
- board: Id;
8200
- };
8201
-
8202
- export type HexBoardGridProps<
8203
- Id extends HexBoardId,
8204
- TSpaceView extends { id: HexBoardSpaceId<Id> },
8205
- > = Omit<
8206
- BoardHexGridPropsGeneric<HexBoardTopology<Id>, TSpaceView>,
8207
- "board" | "interactions"
8208
- > & {
8209
- board: Id;
8210
- };
8211
-
8212
- export type SquareBoardGridProps<Id extends SquareBoardId> = Omit<
8213
- BoardSquareGridPropsGeneric<SquareBoardTopology<Id>>,
8214
- "board" | "interactions"
8215
- > & {
8216
- board: Id;
8217
- interactions?: BoardGridInteractionFilter<InteractionKey>;
8218
- };
8219
-
8220
- type WorkspaceBoard = {
8221
- surface<const Board extends BoardSurfaceBoardId>(
8222
- board: Board,
8223
- ): WorkspaceBoardSurfaceDescriptor<Board>;
8224
- useSurface(name: string): BoardSurface;
8225
- useSurface<const Board extends BoardSurfaceBoardId>(
8226
- name: string,
8227
- options: { board: Board },
8228
- ): BoardSurface<Board>;
8229
- HexView<
8230
- const Id extends HexBoardId,
8231
- const TSpaceView extends { id: HexBoardSpaceId<Id> },
8232
- >(props: HexBoardViewProps<Id, TSpaceView>): ReactElement;
8233
- HexGrid<
8234
- const Id extends HexBoardId,
8235
- const TSpaceView extends { id: HexBoardSpaceId<Id> },
8236
- >(props: HexBoardGridProps<Id, TSpaceView>): ReactElement;
8237
- SquareGrid<const Id extends SquareBoardId>(
8238
- props: SquareBoardGridProps<Id>,
8239
- ): ReactElement;
8240
- };
8241
-
8242
- type WorkspaceCardProperties = CardProperties extends Record<string, unknown>
8243
- ? CardProperties
8244
- : Record<string, unknown>;
8245
- type WorkspaceZoneId = [ZoneId] extends [never] ? string : ZoneId;
8246
- type WorkspaceCardId = [CardId] extends [never] ? string : CardId;
8247
- type WorkspaceCardType = [CardType] extends [never] ? string : CardType;
8248
-
8249
- // ZoneCardRenderItem is a discriminated union (hidden: true | false).
8250
- // A bare Omit<..., "zone"> would collapse the union to its common keys and
8251
- // strip cardType / properties from the hydrated branch, defeating the
8252
- // discriminated-union narrowing the SDK contract promises. Distribute Omit
8253
- // across the union so each branch keeps its own shape.
8254
- type WorkspaceZoneCard = ZoneCardRenderItem<
8255
- WorkspaceCardId & string,
8256
- WorkspaceCardType & string,
8257
- WorkspaceCardProperties
8258
- > extends infer Item
8259
- ? Item extends { zone: string }
8260
- ? Omit<Item, "zone"> & { zone: WorkspaceZoneId }
8261
- : never
8262
- : never;
8263
-
8264
- type HandRole = "primary" | "auxiliary" | "task";
8265
-
8266
- type PilesSurfaceValue<Zones extends readonly CardZoneId[]> = {
8267
- readonly [Zone in Zones[number]]: PileSurface<readonly [Zone]>;
8268
- };
8269
-
8270
- type InteractionFormsSurfaceValue<
8271
- Forms extends Readonly<Record<string, InteractionKey>>,
8272
- > = {
8273
- readonly [Key in keyof Forms]: Forms[Key] extends InteractionKey
8274
- ? InteractionFormSurface<Forms[Key]>
8275
- : never;
8276
- };
8277
-
8278
- type WorkspaceSurfaceValue<Spec> =
8279
- Spec extends WorkspaceBoardSurfaceDescriptor<infer Board extends BoardSurfaceBoardId>
8280
- ? BoardSurface<Board>
8281
- : Spec extends WorkspaceHandSurfaceDescriptor<infer Zone extends PlayerCardZoneId>
8282
- ? HandSurface<readonly [Zone]>
8283
- : Spec extends WorkspacePileSurfaceDescriptor<infer Zone extends CardZoneId>
8284
- ? PileSurface<readonly [Zone]>
8285
- : Spec extends WorkspacePilesSurfaceDescriptor<
8286
- infer Zones extends readonly CardZoneId[]
8287
- >
8288
- ? PilesSurfaceValue<Zones>
8289
- : Spec extends WorkspaceCardCollectionSurfaceDescriptor<
8290
- infer Zones extends readonly CardZoneId[]
8291
- >
8292
- ? CardCollectionSurface<Zones>
8293
- : Spec extends WorkspaceInteractionFormDescriptor<
8294
- infer Interaction extends InteractionKey
8295
- >
8296
- ? InteractionFormSurface<Interaction>
8297
- : Spec extends WorkspaceInteractionFormsDescriptor<
8298
- infer Forms extends Readonly<Record<string, InteractionKey>>
8299
- >
8300
- ? InteractionFormsSurfaceValue<Forms>
8301
- : Spec extends WorkspaceSurfaceSpec
8302
- ? { readonly [Key in keyof Spec]: WorkspaceSurfaceValue<Spec[Key]> }
8303
- : never;
8304
-
8305
- type WorkspaceZone = {
8306
- hand<const Zone extends PlayerCardZoneId>(
8307
- zone: Zone,
8308
- options: { role: HandRole; label: string; order?: number },
8309
- ): WorkspaceHandSurfaceDescriptor<Zone>;
8310
- pile<const Zone extends CardZoneId>(
8311
- zone: Zone,
8312
- ): WorkspacePileSurfaceDescriptor<Zone>;
8313
- piles<const Zones extends readonly CardZoneId[]>(
8314
- zones: Zones,
8315
- ): WorkspacePilesSurfaceDescriptor<Zones>;
8316
- collection<const Zones extends readonly CardZoneId[]>(
8317
- zones: Zones,
8318
- options?: { mode?: "all" | "top-card" },
8319
- ): WorkspaceCardCollectionSurfaceDescriptor<Zones>;
8320
- useHand<const Zone extends PlayerCardZoneId>(
8321
- name: string,
8322
- options: { zone: Zone; role: HandRole; label: string; order?: number },
8323
- ): HandSurface<readonly [Zone]>;
8324
- usePile<const Zone extends CardZoneId>(
8325
- name: string,
8326
- options: { zone: Zone },
8327
- ): PileSurface<readonly [Zone]>;
8328
- useCardCollection<const Zones extends readonly CardZoneId[]>(
8329
- name: string,
8330
- options: { zones: Zones; mode?: "all" | "top-card" },
8331
- ): CardCollectionSurface<Zones>;
8332
- };
8333
-
8334
- type WorkspaceUI = Omit<
8335
- DreamboardUI<typeof uiContract>,
8336
- "Root" | "Game" | "Interaction" | "Board" | "Zone" | "Prompt" | "PromptInbox"
8337
- > & {
8338
- Root(props: UIRootProps): ReactElement;
8339
- defineSurfaces<const Spec extends WorkspaceSurfaceSpec>(
8340
- spec: Spec,
8341
- ): () => WorkspaceSurfaceValue<Spec>;
8342
- defineGameUI<Surfaces>(
8343
- config: DefineGameUIConfig<GameRootState, Surfaces> & {
8344
- useSurfaces: () => Surfaces;
8345
- interactionRoutes?: (context: {
8346
- game: GameRootState;
8347
- surfaces: Surfaces;
8348
- }) => InteractionRoutes;
8349
- phases: {
8350
- readonly [Phase in PhaseName]: (context: {
8351
- game: GameRootState;
8352
- surfaces: Surfaces;
8353
- }) => ReactNode;
8354
- };
8355
- },
8356
- ): (props: Omit<UIRootProps, "children">) => ReactElement;
8357
- readonly Game: TypedGame<typeof uiContract, GameView, PlayerId, PhaseName>;
8358
- readonly Interaction: Pick<DreamboardUI<typeof uiContract>["Interaction"], "State" | "Dialog"> & {
8359
- useForm<Key extends InteractionKey>(interaction: Key): InteractionFormSurface<Key>;
8360
- form<const Interaction extends InteractionKey>(
8361
- interaction: Interaction,
8362
- ): WorkspaceInteractionFormDescriptor<Interaction>;
8363
- forms<const Interactions extends Readonly<Record<string, InteractionKey>>>(
8364
- interactions: Interactions,
8365
- ): WorkspaceInteractionFormsDescriptor<Interactions>;
8366
- Routes(props: InteractionRoutesProps): ReactElement;
8367
- };
8368
- readonly Board: WorkspaceBoard;
8369
- readonly Zone: WorkspaceZone;
8370
- readonly ResourceCounter: ResourceCounterComponents<ResourceId>;
8371
- };
8372
-
8373
- function formInputKeysForInteraction(interaction: string): Set<string> {
8374
- const [phase, id] = interaction.split(".", 2);
8375
- const phaseSpec = phase ? (game.phases as Record<string, unknown>)[phase] : undefined;
8376
- const phaseRecord = phaseSpec as {
8377
- interactions?: Record<string, { inputs?: Record<string, { kind?: string }> }>;
8378
- cardActions?: Record<string, { inputs?: Record<string, { kind?: string }> }>;
8379
- submit?: { inputs?: Record<string, { kind?: string }> };
8380
- } | undefined;
8381
- const spec =
8382
- (id ? phaseRecord?.interactions?.[id] : undefined) ??
8383
- (id ? phaseRecord?.cardActions?.[id] : undefined) ??
8384
- (id === "submit" ? phaseRecord?.submit : undefined);
8385
- return new Set(
8386
- Object.entries((spec?.inputs ?? {}) as Record<string, { kind?: string }>)
8387
- .filter(
8388
- ([, collector]) =>
8389
- collector.kind === "form" || collector.kind === "prompt",
8390
- )
8391
- .map(([input]) => input),
8392
- );
8393
- }
8394
-
8395
- export const UI = createWorkspaceUIContract<
8396
- WorkspaceUI,
8397
- typeof uiContract,
8398
- ResourceId,
8399
- WorkspaceZoneCard,
8400
- typeof hexStaticBoards,
8401
- typeof squareStaticBoards
8402
- >({
8403
- uiContract,
8404
- clientParamSchemasByPhase: createClientParamSchemasByPhase(game) as ClientParamSchemaMap,
8405
- formInputKeysForInteraction,
8406
- resourceIds: literals.resourceIds as readonly ResourceId[],
8407
- resourcePresentationById: literals.resourcePresentationById as Partial<
8408
- Record<string, { label?: string; icon?: string }>
8409
- >,
8410
- hexStaticBoards,
8411
- squareStaticBoards,
8412
- cardIdFromZoneCard: (card) => card.id,
8413
- zoneIdFromZoneCard: (card) => card.zone,
8414
- });
8415
- export const Board: WorkspaceUI["Board"] = UI.Board;
8416
- export const Zone: WorkspaceUI["Zone"] = UI.Zone;
8417
- export const Game: WorkspaceUI["Game"] = UI.Game;
8418
- export const Interaction = UI.Interaction;
8419
- export const PlayerRoster: WorkspaceUI["PlayerRoster"] = UI.PlayerRoster;
8420
- export const Dice: WorkspaceUI["Dice"] = UI.Dice;
8421
- export const Phase = UI.Phase;
8422
- export const ResourceCounter: WorkspaceUI["ResourceCounter"] = UI.ResourceCounter;
8423
-
8424
- export const clientParamSchemasByPhase = createClientParamSchemasByPhase(
8425
- game,
8426
- ) as ClientParamSchemaMap;
8427
7289
  `;
8428
7290
  }
8429
7291
  function generateReducerSupportSeed() {
@@ -8897,7 +7759,7 @@ function generateFrameworkFiles(manifest) {
8897
7759
  return {
8898
7760
  "app/tsconfig.framework.json": generateAppFrameworkTsConfig(),
8899
7761
  "ui/tsconfig.framework.json": generateUiFrameworkTsConfig(),
8900
- "shared/generated/ui-contract.ts": generateUiContractContent(),
7762
+ "shared/generated/ui-contract.ts": generateThinUiContractContent(),
8901
7763
  "app/index.ts": generateAuthoritativeIndexFile(manifest)
8902
7764
  };
8903
7765
  }
@@ -8937,4 +7799,4 @@ export {
8937
7799
  generateAuthoritativeFiles,
8938
7800
  generateDynamicGeneratedFiles
8939
7801
  };
8940
- //# sourceMappingURL=chunk-SACZWUA6.js.map
7802
+ //# sourceMappingURL=chunk-HIH6Y4FA.js.map