@dreamboard-games/sdk 0.4.0-alpha.8 → 0.5.0-alpha.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.
Files changed (121) hide show
  1. package/README.md +49 -11
  2. package/dist/authoring/index.d.ts +6 -14
  3. package/dist/authoring/index.js +11 -547
  4. package/dist/authoring/index.js.map +1 -1
  5. package/dist/authoring-compiler.d.ts +27 -0
  6. package/dist/authoring-compiler.js +11 -0
  7. package/dist/authoring-compiler.js.map +1 -0
  8. package/dist/authoring-materialize-cli.d.ts +1 -0
  9. package/dist/authoring-materialize-cli.js +45 -0
  10. package/dist/authoring-materialize-cli.js.map +1 -0
  11. package/dist/browser-interaction.d.ts +22 -22
  12. package/dist/{chunk-3BLN5POZ.js → chunk-2GQIALJL.js} +51 -15
  13. package/dist/chunk-2GQIALJL.js.map +1 -0
  14. package/dist/chunk-533O7C4L.js +7095 -0
  15. package/dist/chunk-533O7C4L.js.map +1 -0
  16. package/dist/{chunk-44N3T2A5.js → chunk-6LMESVGT.js} +9 -28
  17. package/dist/chunk-6LMESVGT.js.map +1 -0
  18. package/dist/{chunk-ZYONCTZ2.js → chunk-DQS2EG5E.js} +3 -3
  19. package/dist/{chunk-ZYONCTZ2.js.map → chunk-DQS2EG5E.js.map} +1 -1
  20. package/dist/chunk-EOEA3I64.js +1864 -0
  21. package/dist/chunk-EOEA3I64.js.map +1 -0
  22. package/dist/{chunk-B2YBS3SG.js → chunk-FL67RDID.js} +41 -13
  23. package/dist/chunk-FL67RDID.js.map +1 -0
  24. package/dist/{chunk-2TAKLJJD.js → chunk-HIH6Y4FA.js} +222 -1267
  25. package/dist/chunk-HIH6Y4FA.js.map +1 -0
  26. package/dist/chunk-HUK4234C.js +166 -0
  27. package/dist/chunk-HUK4234C.js.map +1 -0
  28. package/dist/chunk-KGV2EUNN.js +532 -0
  29. package/dist/chunk-KGV2EUNN.js.map +1 -0
  30. package/dist/{chunk-VTK4TIXC.js → chunk-KRJPRYEA.js} +49 -4
  31. package/dist/chunk-KRJPRYEA.js.map +1 -0
  32. package/dist/chunk-KWHOFBDM.js +9 -0
  33. package/dist/chunk-KWHOFBDM.js.map +1 -0
  34. package/dist/{chunk-UC2UXAC6.js → chunk-LMHCGCA6.js} +2 -2
  35. package/dist/{chunk-XV27IQHA.js → chunk-N33CGX2F.js} +15 -85
  36. package/dist/chunk-N33CGX2F.js.map +1 -0
  37. package/dist/chunk-TXELBVTG.js +32 -0
  38. package/dist/chunk-TXELBVTG.js.map +1 -0
  39. package/dist/{chunk-2TRZSZGD.js → chunk-VRRR6QZT.js} +9 -12
  40. package/dist/chunk-VRRR6QZT.js.map +1 -0
  41. package/dist/chunk-VWTKGIYF.js +90 -0
  42. package/dist/chunk-VWTKGIYF.js.map +1 -0
  43. package/dist/{chunk-IYX5OO2K.js → chunk-XFMSLL3P.js} +133 -61
  44. package/dist/chunk-XFMSLL3P.js.map +1 -0
  45. package/dist/{chunk-YGQTL63W.js → chunk-ZSTCUJKZ.js} +4 -4
  46. package/dist/chunk-ZSTCUJKZ.js.map +1 -0
  47. package/dist/codegen.js +1 -1
  48. package/dist/{components-BTwSIjXj.d.ts → components-CNAt5J1p.d.ts} +1 -1
  49. package/dist/definitions-bZSBaPjj.d.ts +300 -0
  50. package/dist/{diagnostics-1BWjRo6-.d.ts → diagnostics-DIi3ina7.d.ts} +2 -1
  51. package/dist/digest.d.ts +8 -0
  52. package/dist/{index-CFTjJIXd.d.ts → index-CR69MyWr.d.ts} +2 -2
  53. package/dist/{index.d-C0PKOVbh.d.ts → index.d-Bw8AOcgp.d.ts} +532 -225
  54. package/dist/index.js +2 -2
  55. package/dist/package-set.d.ts +2 -2
  56. package/dist/package-set.js +2 -2
  57. package/dist/plugin-runtime-contract.d.ts +17 -0
  58. package/dist/plugin-runtime-contract.js +94 -0
  59. package/dist/plugin-runtime-contract.js.map +1 -0
  60. package/dist/{protocol-nS2ojsGr.d.ts → protocol-CVaSqPgX.d.ts} +54 -47
  61. package/dist/reducer/advanced.d.ts +5 -4
  62. package/dist/reducer/advanced.js +14 -108
  63. package/dist/reducer/advanced.js.map +1 -1
  64. package/dist/reducer-contract.d.ts +1 -1
  65. package/dist/reducer-contract.js +6 -4
  66. package/dist/reducer.d.ts +20 -98
  67. package/dist/reducer.js +28 -6050
  68. package/dist/reducer.js.map +1 -1
  69. package/dist/reference-games/index.d.ts +6 -198
  70. package/dist/reference-games/index.js +18 -200
  71. package/dist/reference-games/index.js.map +1 -1
  72. package/dist/runtime/primitives.d.ts +3 -3
  73. package/dist/runtime/primitives.js +5 -5
  74. package/dist/runtime/runtime-api.d.ts +1 -1
  75. package/dist/runtime/workspace-contract.d.ts +343 -11
  76. package/dist/runtime/workspace-contract.js +12 -6
  77. package/dist/{runtime-Dkfm1x2r.d.ts → runtime-C7Z2acNU.d.ts} +67 -31
  78. package/dist/{runtime-api-C6aWo9c0.d.ts → runtime-api-CgPuEVeF.d.ts} +4 -13
  79. package/dist/runtime.d.ts +7 -7
  80. package/dist/runtime.js +15 -11
  81. package/dist/runtime.js.map +1 -1
  82. package/dist/schema.d.ts +405 -0
  83. package/dist/{stale-contract-artifact-error-C5AaZPJ8.d.ts → stale-contract-artifact-error-XLaweZtF.d.ts} +1 -1
  84. package/dist/testing-compiler.d.ts +37 -0
  85. package/dist/testing-compiler.js +272 -0
  86. package/dist/testing-compiler.js.map +1 -0
  87. package/dist/testing-runtime.d.ts +98 -21
  88. package/dist/testing-runtime.js +154 -95
  89. package/dist/testing-runtime.js.map +1 -1
  90. package/dist/testing.d.ts +197 -156
  91. package/dist/testing.js +660 -372
  92. package/dist/testing.js.map +1 -1
  93. package/dist/types-DN4O7kH_.d.ts +122 -0
  94. package/dist/{types-CTeN_QAk.d.ts → types-q1Guidm5.d.ts} +4 -5
  95. package/dist/types.d.ts +0 -1
  96. package/dist/ui/components.d.ts +3 -2
  97. package/dist/ui/components.js +1 -1
  98. package/dist/ui/plugin-styles.css +1 -1
  99. package/dist/{ui-contract-Ue6SywvO.d.ts → ui-contract-BC4JpysE.d.ts} +2 -6
  100. package/dist/ui.d.ts +4 -3
  101. package/dist/ui.js +2 -2
  102. package/dist/{views-Qx-EHBP8.d.ts → views-D2Cfzr3h.d.ts} +17 -5
  103. package/package.json +41 -22
  104. package/REFERENCE.md +0 -22884
  105. package/dist/chunk-2TAKLJJD.js.map +0 -1
  106. package/dist/chunk-2TRZSZGD.js.map +0 -1
  107. package/dist/chunk-3BLN5POZ.js.map +0 -1
  108. package/dist/chunk-3OZMHZK3.js +0 -40
  109. package/dist/chunk-3OZMHZK3.js.map +0 -1
  110. package/dist/chunk-44N3T2A5.js.map +0 -1
  111. package/dist/chunk-5CQIJHGF.js +0 -663
  112. package/dist/chunk-5CQIJHGF.js.map +0 -1
  113. package/dist/chunk-B2YBS3SG.js.map +0 -1
  114. package/dist/chunk-IYX5OO2K.js.map +0 -1
  115. package/dist/chunk-VTK4TIXC.js.map +0 -1
  116. package/dist/chunk-VTNEWMWJ.js +0 -12
  117. package/dist/chunk-VTNEWMWJ.js.map +0 -1
  118. package/dist/chunk-XV27IQHA.js.map +0 -1
  119. package/dist/chunk-YGQTL63W.js.map +0 -1
  120. package/dist/types-B_3pObUV.d.ts +0 -192
  121. /package/dist/{chunk-UC2UXAC6.js.map → chunk-LMHCGCA6.js.map} +0 -0
@@ -4260,6 +4260,9 @@ function renderGenericBoardStateSchema(board, runtimeBoardId) {
4260
4260
  fields: ${`${boardContainerFieldsTypeName(board.board.id)}Schema`},
4261
4261
  })`
4262
4262
  ).join(",\n ");
4263
+ const renderedContainers = containerEntries ? `
4264
+ ${containerEntries}
4265
+ ` : "";
4263
4266
  return `z.object({
4264
4267
  id: z.literal(${quote(runtimeBoardId)}),
4265
4268
  baseId: z.literal(${quote(board.board.id)}),
@@ -4298,9 +4301,7 @@ function renderGenericBoardStateSchema(board, runtimeBoardId) {
4298
4301
  fields: ${`${boardRelationFieldsTypeName(board.board.id)}Schema`},
4299
4302
  }),
4300
4303
  ),
4301
- containers: z.object({
4302
- ${containerEntries}
4303
- }),
4304
+ containers: z.object({${renderedContainers}}),
4304
4305
  })`;
4305
4306
  }
4306
4307
  function renderHexBoardStateSchema(board, runtimeBoardId) {
@@ -4376,6 +4377,9 @@ function renderSquareBoardStateSchema(board, runtimeBoardId) {
4376
4377
  fields: ${`${boardContainerFieldsTypeName(board.board.id)}Schema`},
4377
4378
  })`
4378
4379
  ).join(",\n ");
4380
+ const renderedContainers = containerEntries ? `
4381
+ ${containerEntries}
4382
+ ` : "";
4379
4383
  return `z.object({
4380
4384
  id: z.literal(${quote(runtimeBoardId)}),
4381
4385
  baseId: z.literal(${quote(board.board.id)}),
@@ -4408,9 +4412,7 @@ function renderSquareBoardStateSchema(board, runtimeBoardId) {
4408
4412
  fields: ${`${boardRelationFieldsTypeName(board.board.id)}Schema`},
4409
4413
  }),
4410
4414
  ),
4411
- containers: z.object({
4412
- ${containerEntries}
4413
- }),
4415
+ containers: z.object({${renderedContainers}}),
4414
4416
  edges: z.array(
4415
4417
  z.object({
4416
4418
  id: ids.edgeId,
@@ -5414,39 +5416,117 @@ const playerIdSchema = markManifestScopedSchema(
5414
5416
  .string()
5415
5417
  .min(1)
5416
5418
  .transform((value) => asPlayerId(value)),
5419
+ "playerId",
5420
+ );
5421
+ const phaseNameSchema = markManifestScopedSchema(z.string(), "phaseName");
5422
+ const boardLayoutSchema = createManifestStringLiteralSchema(
5423
+ literals.boardLayouts,
5424
+ "boardLayout",
5425
+ );
5426
+ const setupOptionIdSchema = createManifestStringLiteralSchema(
5427
+ literals.setupOptionIds,
5428
+ "setupOptionId",
5417
5429
  );
5418
- const phaseNameSchema = markManifestScopedSchema(z.string());
5419
- const boardLayoutSchema = createManifestStringLiteralSchema(literals.boardLayouts);
5420
- const setupOptionIdSchema = createManifestStringLiteralSchema(literals.setupOptionIds);
5421
5430
  const setupProfileIdSchema = createManifestStringLiteralSchema(
5422
5431
  literals.setupProfileIds,
5432
+ "setupProfileId",
5433
+ );
5434
+ const cardSetIdSchema = createManifestStringLiteralSchema(
5435
+ literals.cardSetIds,
5436
+ "cardSetId",
5437
+ );
5438
+ const cardTypeSchema = createManifestStringLiteralSchema(
5439
+ literals.cardTypes,
5440
+ "cardType",
5441
+ );
5442
+ const cardIdSchema = createManifestStringLiteralSchema(
5443
+ literals.cardIds,
5444
+ "cardId",
5445
+ );
5446
+ const deckIdSchema = createManifestStringLiteralSchema(
5447
+ literals.deckIds,
5448
+ "deckId",
5449
+ );
5450
+ const handIdSchema = createManifestStringLiteralSchema(
5451
+ literals.handIds,
5452
+ "handId",
5453
+ );
5454
+ const sharedZoneIdSchema = createManifestStringLiteralSchema(
5455
+ literals.sharedZoneIds,
5456
+ "sharedZoneId",
5457
+ );
5458
+ const playerZoneIdSchema = createManifestStringLiteralSchema(
5459
+ literals.playerZoneIds,
5460
+ "playerZoneId",
5461
+ );
5462
+ const zoneIdSchema = createManifestStringLiteralSchema(
5463
+ literals.zoneIds,
5464
+ "zoneId",
5465
+ );
5466
+ const resourceIdSchema = createManifestStringLiteralSchema(
5467
+ literals.resourceIds,
5468
+ "resourceId",
5469
+ );
5470
+ const pieceTypeIdSchema = createManifestStringLiteralSchema(
5471
+ literals.pieceTypeIds,
5472
+ "pieceTypeId",
5473
+ );
5474
+ const pieceIdSchema = createManifestStringLiteralSchema(
5475
+ literals.pieceIds,
5476
+ "pieceId",
5477
+ );
5478
+ const dieTypeIdSchema = createManifestStringLiteralSchema(
5479
+ literals.dieTypeIds,
5480
+ "dieTypeId",
5481
+ );
5482
+ const dieIdSchema = createManifestStringLiteralSchema(
5483
+ literals.dieIds,
5484
+ "dieId",
5485
+ );
5486
+ const boardTypeIdSchema = createManifestStringLiteralSchema(
5487
+ literals.boardTypeIds,
5488
+ "boardTypeId",
5489
+ );
5490
+ const boardBaseIdSchema = createManifestStringLiteralSchema(
5491
+ literals.boardBaseIds,
5492
+ "boardBaseId",
5493
+ );
5494
+ const boardIdSchema = createManifestStringLiteralSchema(
5495
+ literals.boardIds,
5496
+ "boardId",
5423
5497
  );
5424
- const cardSetIdSchema = createManifestStringLiteralSchema(literals.cardSetIds);
5425
- const cardTypeSchema = createManifestStringLiteralSchema(literals.cardTypes);
5426
- const cardIdSchema = createManifestStringLiteralSchema(literals.cardIds);
5427
- const deckIdSchema = createManifestStringLiteralSchema(literals.deckIds);
5428
- const handIdSchema = createManifestStringLiteralSchema(literals.handIds);
5429
- const sharedZoneIdSchema = createManifestStringLiteralSchema(literals.sharedZoneIds);
5430
- const playerZoneIdSchema = createManifestStringLiteralSchema(literals.playerZoneIds);
5431
- const zoneIdSchema = createManifestStringLiteralSchema(literals.zoneIds);
5432
- const resourceIdSchema = createManifestStringLiteralSchema(literals.resourceIds);
5433
- const pieceTypeIdSchema = createManifestStringLiteralSchema(literals.pieceTypeIds);
5434
- const pieceIdSchema = createManifestStringLiteralSchema(literals.pieceIds);
5435
- const dieTypeIdSchema = createManifestStringLiteralSchema(literals.dieTypeIds);
5436
- const dieIdSchema = createManifestStringLiteralSchema(literals.dieIds);
5437
- const boardTypeIdSchema = createManifestStringLiteralSchema(literals.boardTypeIds);
5438
- const boardBaseIdSchema = createManifestStringLiteralSchema(literals.boardBaseIds);
5439
- const boardIdSchema = createManifestStringLiteralSchema(literals.boardIds);
5440
5498
  const boardContainerIdSchema = createManifestStringLiteralSchema(
5441
5499
  literals.boardContainerIds,
5500
+ "boardContainerId",
5501
+ );
5502
+ const relationTypeIdSchema = createManifestStringLiteralSchema(
5503
+ literals.relationTypeIds,
5504
+ "relationTypeId",
5505
+ );
5506
+ const edgeIdSchema = createManifestStringLiteralSchema(
5507
+ literals.edgeIds,
5508
+ "edgeId",
5509
+ );
5510
+ const edgeTypeIdSchema = createManifestStringLiteralSchema(
5511
+ literals.edgeTypeIds,
5512
+ "edgeTypeId",
5513
+ );
5514
+ const vertexIdSchema = createManifestStringLiteralSchema(
5515
+ literals.vertexIds,
5516
+ "vertexId",
5517
+ );
5518
+ const vertexTypeIdSchema = createManifestStringLiteralSchema(
5519
+ literals.vertexTypeIds,
5520
+ "vertexTypeId",
5521
+ );
5522
+ const spaceIdSchema = createManifestStringLiteralSchema(
5523
+ literals.spaceIds,
5524
+ "spaceId",
5525
+ );
5526
+ const spaceTypeIdSchema = createManifestStringLiteralSchema(
5527
+ literals.spaceTypeIds,
5528
+ "spaceTypeId",
5442
5529
  );
5443
- const relationTypeIdSchema = createManifestStringLiteralSchema(literals.relationTypeIds);
5444
- const edgeIdSchema = createManifestStringLiteralSchema(literals.edgeIds);
5445
- const edgeTypeIdSchema = createManifestStringLiteralSchema(literals.edgeTypeIds);
5446
- const vertexIdSchema = createManifestStringLiteralSchema(literals.vertexIds);
5447
- const vertexTypeIdSchema = createManifestStringLiteralSchema(literals.vertexTypeIds);
5448
- const spaceIdSchema = createManifestStringLiteralSchema(literals.spaceIds);
5449
- const spaceTypeIdSchema = createManifestStringLiteralSchema(literals.spaceTypeIds);
5450
5530
 
5451
5531
  export const ids = {
5452
5532
  playerId: playerIdSchema,
@@ -5456,9 +5536,9 @@ export const ids = {
5456
5536
  setupProfileId: setupProfileIdSchema,
5457
5537
  cardSetId: cardSetIdSchema,
5458
5538
  cardType: cardTypeSchema,
5459
- cardId: cardIdSchema as unknown as z.ZodType<CardId>,
5460
- deckId: deckIdSchema as unknown as z.ZodType<DeckId>,
5461
- handId: handIdSchema as unknown as z.ZodType<HandId>,
5539
+ cardId: cardIdSchema as unknown as typeof cardIdSchema & z.ZodType<CardId>,
5540
+ deckId: deckIdSchema as unknown as typeof deckIdSchema & z.ZodType<DeckId>,
5541
+ handId: handIdSchema as unknown as typeof handIdSchema & z.ZodType<HandId>,
5462
5542
  sharedZoneId: sharedZoneIdSchema,
5463
5543
  playerZoneId: playerZoneIdSchema,
5464
5544
  zoneId: zoneIdSchema,
@@ -6333,6 +6413,13 @@ export function createInitialTable(options: {
6333
6413
  return tableSchema.parse(table);
6334
6414
  }
6335
6415
 
6416
+ export const normalSetup = {
6417
+ minPlayers: ${JSON.stringify(manifest.players.minPlayers)},
6418
+ maxPlayers: ${JSON.stringify(manifest.players.maxPlayers)},
6419
+ createInitialTable: (options: { readonly playerIds: readonly string[] }) =>
6420
+ createInitialTable({ playerIds: options.playerIds }),
6421
+ } as const;
6422
+
6336
6423
  export const schemas = {
6337
6424
  table: tableSchema,
6338
6425
  runtime: runtimeSchema,
@@ -6376,10 +6463,14 @@ export const manifestContract: ReducerManifestContract<
6376
6463
  DeckId,
6377
6464
  HandId,
6378
6465
  CardId
6379
- > = {
6466
+ > & {
6467
+ readonly ids: typeof ids;
6468
+ readonly normalSetup: typeof normalSetup;
6469
+ } = {
6380
6470
  literals,
6381
6471
  ids,
6382
6472
  defaults,
6473
+ normalSetup,
6383
6474
  staticBoards: staticBoards as unknown as StaticBoards<TableState>,
6384
6475
  setupOptionsById,
6385
6476
  setupChoiceIdsByOptionId,
@@ -6532,14 +6623,14 @@ const unknownRecordSchema`
6532
6623
  "literals.playerIds as unknown as readonly PlayerId[]",
6533
6624
  "literals.playerIds"
6534
6625
  ).replaceAll(
6535
- "cardId: cardIdSchema as unknown as z.ZodType<CardId>,",
6536
- "cardId: assumeManifestSchema<CardId>(cardIdSchema),"
6626
+ "cardId: cardIdSchema as unknown as typeof cardIdSchema & z.ZodType<CardId>,",
6627
+ 'cardId: assumeManifestSchema<CardId, "cardId">(cardIdSchema),'
6537
6628
  ).replaceAll(
6538
- "deckId: deckIdSchema as unknown as z.ZodType<DeckId>,",
6539
- "deckId: assumeManifestSchema<DeckId>(deckIdSchema),"
6629
+ "deckId: deckIdSchema as unknown as typeof deckIdSchema & z.ZodType<DeckId>,",
6630
+ 'deckId: assumeManifestSchema<DeckId, "deckId">(deckIdSchema),'
6540
6631
  ).replaceAll(
6541
- "handId: handIdSchema as unknown as z.ZodType<HandId>,",
6542
- "handId: assumeManifestSchema<HandId>(handIdSchema),"
6632
+ "handId: handIdSchema as unknown as typeof handIdSchema & z.ZodType<HandId>,",
6633
+ 'handId: assumeManifestSchema<HandId, "handId">(handIdSchema),'
6543
6634
  ).replace(
6544
6635
  " type StaticBoards,\n",
6545
6636
  " type StaticBoards,\n type StaticBoardsJsonEnvelope,\n"
@@ -6572,13 +6663,15 @@ const unknownRecordSchema`
6572
6663
  .string()
6573
6664
  .min(1)
6574
6665
  .transform((value) => asPlayerId(value)),
6666
+ "playerId",
6575
6667
  );`,
6576
- `const playerIdSchema = assumeManifestSchema<PublicPlayerId>(
6668
+ `const playerIdSchema = assumeManifestSchema<PublicPlayerId, "playerId">(
6577
6669
  markManifestScopedSchema(
6578
6670
  z
6579
6671
  .string()
6580
6672
  .min(1)
6581
6673
  .transform((value) => asPlayerId(value)),
6674
+ "playerId",
6582
6675
  ),
6583
6676
  );`
6584
6677
  );
@@ -6952,7 +7045,7 @@ function generateManifestContractSources(manifest) {
6952
7045
 
6953
7046
  // ../workspace-codegen/src/ownership.ts
6954
7047
  var WORKSPACE_CODEGEN_OWNERSHIP = {
6955
- version: 31,
7048
+ version: 32,
6956
7049
  allowedPaths: {
6957
7050
  rootFiles: [
6958
7051
  ".npmrc",
@@ -7072,7 +7165,7 @@ function isLibraryPath(filePath) {
7072
7165
 
7073
7166
  // ../workspace-codegen/src/seeds.ts
7074
7167
  var SETUP_PROFILES_SEED_MARKER = "Generated by dreamboard setup-profiles scaffold.";
7075
- function generateUiContractContent() {
7168
+ function generateThinUiContractContent() {
7076
7169
  return `/**
7077
7170
  * Generated file.
7078
7171
  * Do not edit directly.
@@ -7080,72 +7173,22 @@ function generateUiContractContent() {
7080
7173
 
7081
7174
  import game from "../../app/game";
7082
7175
  import {
7083
- createClientParamSchemasByPhase,
7084
- } from "@dreamboard-games/sdk/reducer/advanced";
7085
- import type {
7086
- CardInputZoneIdsOfDefinition,
7087
- ClientParamsOfInteractionOfDefinition,
7088
- DefaultedClientParamKeysOfInteractionOfDefinition,
7089
- InputKeysWithCollectorKindOfDefinition,
7090
- InteractionIdOfDefinition,
7091
- InteractionIdOfDefinitionPhase,
7092
- PhaseNamesOfDefinition,
7093
- StageNamesOfDefinitionPhase,
7094
- ViewNamesOfDefinition,
7095
- ViewOfDefinition,
7096
- } from "@dreamboard-games/sdk/reducer/advanced";
7097
- import {
7098
- type BoardSpaceIdOf,
7099
- type InteractionVisualState,
7100
- } from "@dreamboard-games/sdk/ui";
7101
- import {
7102
- type BoardGridInteractionFilter,
7103
- type InteractionDescriptor,
7104
- } from "@dreamboard-games/sdk/runtime";
7105
- import {
7106
- createWorkspaceUIContract,
7107
- type BoardHexGridProps as BoardHexGridPropsGeneric,
7108
- type BoardHexViewProps as BoardHexViewPropsGeneric,
7109
- type BoardSquareGridProps as BoardSquareGridPropsGeneric,
7110
- type BoardSpaceTargetProps as BoardSpaceTargetPropsGeneric,
7111
- type ClientParamSchemaMap,
7112
- type DefineGameUIConfig,
7113
- type DreamboardUI,
7114
- type GameMeState,
7115
- type GamePlayersState,
7116
- type GameRenderState,
7117
- type GameTurnState,
7118
- type ResourceCounterComponents,
7119
- type TypedGame,
7120
- type UIContract,
7121
- type UIRootProps,
7122
- type WorkspaceBoardSurfaceDescriptor,
7123
- type WorkspaceBoardSurface,
7124
- type WorkspaceBoardTargetInputSlot,
7125
- type WorkspaceCardCollectionSurface,
7126
- type WorkspaceCardCollectionSurfaceDescriptor,
7127
- type WorkspaceCardInputSlot,
7128
- type WorkspaceFormInputSlot,
7129
- type WorkspaceHandSurfaceDescriptor,
7130
- type WorkspaceHandSurface,
7131
- type WorkspaceInteractionFormDescriptor,
7132
- type WorkspaceInteractionFormDialogProps,
7133
- type WorkspaceInteractionSlotComponent,
7134
- type WorkspaceInteractionFormsDescriptor,
7135
- type WorkspacePileSurface,
7136
- type WorkspacePileSurfaceDescriptor,
7137
- type WorkspacePilesSurfaceDescriptor,
7138
- type WorkspaceSurfaceSpec,
7139
- type ZoneCardRenderItem,
7140
- 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,
7141
7189
  } from "@dreamboard-games/sdk/runtime/workspace-contract";
7190
+ import type { DreamboardUI } from "@dreamboard-games/sdk/runtime";
7142
7191
  import {
7143
- type ButtonHTMLAttributes,
7144
- type ReactElement,
7145
- type ReactNode,
7146
- } from "react";
7147
- import {
7148
- boardHelpers,
7149
7192
  literals,
7150
7193
  staticBoards,
7151
7194
  type BoardBaseId,
@@ -7156,909 +7199,86 @@ import {
7156
7199
  type PlayerId,
7157
7200
  type ResourceId,
7158
7201
  type SpaceId,
7159
- type TiledBoardId,
7160
- type TiledEdgeState,
7161
- type TiledVertexState,
7162
7202
  type VertexId,
7163
- type ZoneId as ManifestZoneId,
7203
+ type ZoneId,
7164
7204
  } from "../manifest-contract";
7165
7205
 
7166
- /**
7167
- * Boundary tripwire (do not remove).
7168
- *
7169
- * The authored UI boundary depends on \`@dreamboard-games/sdk/runtime\` resolving to
7170
- * real types in every typecheck path (local \`tsc\` and the remote compiler
7171
- * service). If a future change to module resolution or type loading silently
7172
- * degrades \`@dreamboard-games/sdk/runtime\` to \`any\`, the assertions below stop
7173
- * compiling, turning invisible type erosion into a hard typecheck error in
7174
- * every generated workspace. \`InteractionDescriptor\` comes from the package
7175
- * root and \`ZoneCardRenderItem\` from the \`/workspace-contract\` subpath, so
7176
- * both entry points are covered.
7177
- */
7178
- type IsAny<T> = 0 extends 1 & T ? true : false;
7179
- type AssertNotAny<T> = IsAny<T> extends true
7180
- ? "sdk runtime types resolved to any \u2014 boundary degraded"
7181
- : true;
7182
- const _uiRuntimeBoundaryResolved: [
7183
- AssertNotAny<InteractionDescriptor>,
7184
- AssertNotAny<ZoneCardRenderItem>,
7185
- ] = [true, true];
7186
- void _uiRuntimeBoundaryResolved;
7187
-
7188
7206
  type GameDefinition = typeof game;
7189
-
7190
- export type ViewName = ViewNamesOfDefinition<GameDefinition>;
7191
- export type InferView<Name extends ViewName> = ViewOfDefinition<
7192
- GameDefinition,
7193
- Name
7194
- >;
7195
- export type GameView = Extract<"player", ViewName> extends never
7196
- ? never
7197
- : InferView<Extract<"player", ViewName>>;
7198
-
7199
- export type PhaseName = PhaseNamesOfDefinition<GameDefinition>;
7200
- export type GameRootState = GameRenderState<GameView, PlayerId, PhaseName>;
7201
- export type GamePlayers = GamePlayersState<PlayerId>;
7202
- export type GameMe = GameMeState<PlayerId>;
7203
- export type GameTurn = GameTurnState<PlayerId, PhaseName>;
7204
-
7205
- // -------------------------------------------------------------------------
7206
- // Interaction / Stage / Zone types (authored via defineInteraction/Stage/zones)
7207
- // -------------------------------------------------------------------------
7208
-
7209
- /** Union of all interaction ids across phases. */
7210
- export type InteractionId = InteractionIdOfDefinition<GameDefinition>;
7211
-
7212
- /** Interactions declared in a specific phase. */
7213
- export type InteractionIdForPhase<Phase extends PhaseName> =
7214
- InteractionIdOfDefinitionPhase<GameDefinition, Phase>;
7215
-
7216
- /**
7217
- * Client-facing params type for an interaction, inferred from its input
7218
- * collectors. Engine-sampled collectors are omitted
7219
- * \u2014 the trusted reducer bundle fills those fields during submit, so the
7220
- * client never supplies them.
7221
- */
7222
- export type InteractionParams<
7223
- Phase extends PhaseName,
7224
- Id extends InteractionIdForPhase<Phase>,
7225
- > = ClientParamsOfInteractionOfDefinition<GameDefinition, Phase, Id>;
7226
-
7227
- /** Client-facing params with authored input defaults. */
7228
- export type InteractionDefaultedKeys<
7229
- Phase extends PhaseName,
7230
- Id extends InteractionIdForPhase<Phase>,
7231
- > = DefaultedClientParamKeysOfInteractionOfDefinition<GameDefinition, Phase, Id>;
7232
-
7233
- /** Phase-qualified interaction key for a specific phase. */
7234
- export type InteractionKeyForPhase<Phase extends PhaseName> =
7235
- \`\${Phase}.\${InteractionIdForPhase<Phase>}\`;
7236
-
7237
- /** Phase-qualified union of every client/UI interaction key. */
7238
- export type InteractionKey = {
7239
- [P in PhaseName]: InteractionKeyForPhase<P>;
7240
- }[PhaseName];
7241
-
7242
- type PhaseOfInteractionKey<Key extends InteractionKey> =
7243
- Key extends \`\${infer P}.\${string}\` ? Extract<P, PhaseName> : never;
7244
-
7245
- type IdOfInteractionKey<Key extends InteractionKey> =
7246
- Key extends \`\${infer P}.\${infer I}\`
7247
- ? P extends PhaseName
7248
- ? Extract<I, InteractionIdForPhase<P>>
7249
- : never
7250
- : never;
7251
-
7252
- export type BoardInteractions = InteractionKey;
7253
-
7254
- /** Stage names declared in a phase. */
7255
- export type StageName<Phase extends PhaseName> = StageNamesOfDefinitionPhase<
7256
- GameDefinition,
7257
- Phase
7258
- >;
7259
-
7260
- /** Union of zone ids authored in the workspace manifest. */
7261
- export type ZoneId = ManifestZoneId;
7262
-
7263
- type CamelCase<S extends string> = S extends \`\${infer Head}-\${infer Tail}\`
7264
- ? \`\${Head}\${Capitalize<CamelCase<Tail>>}\`
7265
- : S;
7266
-
7267
- /** JS-friendly keys for authored zones, e.g. "dev-hand" -> "devHand". */
7268
- export type WorkspaceZoneKey = CamelCase<ZoneId>;
7269
-
7207
+ type RuntimeBoundary = DreamboardUI;
7270
7208
  type PlayerCardZoneId = {
7271
- [Z in (typeof literals.playerZoneIds)[number]]: (typeof literals.cardSetIdsByPlayerZoneId)[Z] extends readonly []
7272
- ? never
7273
- : Z;
7209
+ [Zone in (typeof literals.playerZoneIds)[number]]:
7210
+ (typeof literals.cardSetIdsByPlayerZoneId)[Zone] extends readonly []
7211
+ ? never
7212
+ : Zone;
7274
7213
  }[(typeof literals.playerZoneIds)[number]];
7275
-
7276
7214
  type SharedCardZoneId = {
7277
- [Z in (typeof literals.sharedZoneIds)[number]]: (typeof literals.cardSetIdsBySharedZoneId)[Z] extends readonly []
7278
- ? never
7279
- : Z;
7215
+ [Zone in (typeof literals.sharedZoneIds)[number]]:
7216
+ (typeof literals.cardSetIdsBySharedZoneId)[Zone] extends readonly []
7217
+ ? never
7218
+ : Zone;
7280
7219
  }[(typeof literals.sharedZoneIds)[number]];
7281
-
7282
- type CardZoneId = PlayerCardZoneId | SharedCardZoneId;
7283
-
7284
- /** JS-friendly keys for per-player zones that can contain cards. */
7285
- export type WorkspacePlayerCardZoneKey = CamelCase<PlayerCardZoneId>;
7286
-
7287
- /** Interaction descriptor specialised to a concrete phase-qualified key. */
7288
- export type InteractionDescriptorFor<Key extends InteractionKey> =
7289
- InteractionDescriptor<Key>;
7290
-
7291
- export type InteractionItem<Key extends InteractionKey> = {
7292
- readonly interaction: Key;
7293
- readonly descriptor: InteractionDescriptorFor<Key>;
7294
- };
7295
-
7296
- /**
7297
- * Params shape for a phase-qualified interaction key. Drives strong typing
7298
- * for component-first interaction state, forms, and submits.
7299
- */
7300
- export type InteractionParamsOf<Key extends InteractionKey> =
7301
- InteractionParams<PhaseOfInteractionKey<Key>, IdOfInteractionKey<Key>>;
7302
-
7303
- export type InteractionDefaultedKeysOf<Key extends InteractionKey> =
7304
- InteractionDefaultedKeys<PhaseOfInteractionKey<Key>, IdOfInteractionKey<Key>>;
7305
-
7306
- type InteractionParamsShape<Key extends InteractionKey> =
7307
- InteractionParamsOf<Key> extends Record<string, unknown>
7308
- ? 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
7309
7228
  : Record<string, unknown>;
7310
-
7311
- type InteractionCollectorKind =
7312
- | "form"
7313
- | "board-vertex"
7314
- | "board-edge"
7315
- | "board-tile"
7316
- | "board-space"
7317
- | "card"
7318
- | "prompt";
7319
-
7320
- type AuthoredInteractionInputKeysOf<Key extends InteractionKey> =
7321
- InputKeysWithCollectorKindOfDefinition<
7322
- GameDefinition,
7323
- PhaseOfInteractionKey<Key>,
7324
- IdOfInteractionKey<Key>,
7325
- InteractionCollectorKind
7326
- > extends infer Input
7327
- ? string extends Input
7328
- ? never
7329
- : Input & string
7330
- : never;
7331
-
7332
- type InteractionInputKeysOf<Key extends InteractionKey> =
7333
- | (string extends keyof InteractionParamsOf<Key>
7334
- ? never
7335
- : keyof InteractionParamsOf<Key> & string)
7336
- | AuthoredInteractionInputKeysOf<Key>
7337
- | (InteractionDefaultedKeysOf<Key> & string);
7338
-
7339
- type InteractionHandleDefaultedKeys<Key extends InteractionKey> = Extract<
7340
- InteractionDefaultedKeysOf<Key>,
7341
- keyof InteractionParamsShape<Key> & string
7342
- >;
7343
-
7344
- type RequiredInteractionInputKeysOf<Key extends InteractionKey> =
7345
- InteractionInputKeysOf<Key>;
7346
-
7347
- export type RequiredInteractionInputKey<Key extends InteractionKey> =
7348
- RequiredInteractionInputKeysOf<Key>;
7349
-
7350
- type InteractionSlotComponent<Props = object> = (
7351
- props: Props extends { children?: unknown }
7352
- ? Props
7353
- : Props & { children?: ReactNode },
7354
- ) => ReactElement | null;
7355
-
7356
- type InteractionDefaultInputSlot = {
7357
- readonly Default: InteractionSlotComponent;
7358
- };
7359
-
7360
- type InteractionValueInputSlot<Value = unknown> = {
7361
- readonly Value: InteractionSlotComponent<{
7362
- children: (value: unknown | undefined) => ReactNode;
7363
- }>;
7364
- };
7365
-
7366
- type InteractionFormInputSlot<Value = unknown> = {
7367
- readonly Field: InteractionSlotComponent;
7368
- readonly Options: InteractionSlotComponent<{
7369
- children: (option: { value: Value; label: string }) => ReactNode;
7370
- }>;
7371
- };
7372
-
7373
- type DreamboardSlotBrand<Meta> = {
7374
- readonly __dreamboardSlot: Meta;
7375
- };
7376
-
7377
- type InteractionCardTargetInputSlot<Card extends string = string> = {
7378
- readonly Card: InteractionSlotComponent<
7379
- { value: string } & Omit<
7380
- ButtonHTMLAttributes<HTMLButtonElement>,
7381
- | "children"
7382
- | "disabled"
7383
- | "aria-disabled"
7384
- | "aria-pressed"
7385
- | "onClick"
7386
- | "type"
7387
- | "value"
7388
- >
7389
- >;
7390
- readonly Cards: InteractionSlotComponent<{
7391
- children: (card: { id: Card }) => ReactNode;
7392
- }>;
7393
- };
7394
-
7395
- type InteractionBoardTargetInputSlot<Target extends string = string> = {
7396
- readonly Target: InteractionSlotComponent<
7397
- { value: string } & Omit<
7398
- ButtonHTMLAttributes<HTMLButtonElement>,
7399
- | "children"
7400
- | "disabled"
7401
- | "aria-disabled"
7402
- | "aria-pressed"
7403
- | "onClick"
7404
- | "type"
7405
- | "value"
7406
- >
7407
- >;
7408
- };
7409
-
7410
- type InteractionBoardSpaceTargetInputSlot<Space extends string = string> =
7411
- InteractionBoardTargetInputSlot<Space>;
7412
-
7413
- type InteractionBoardEdgeTargetInputSlot<Edge extends string = string> =
7414
- InteractionBoardTargetInputSlot<Edge>;
7415
-
7416
- type InteractionBoardVertexTargetInputSlot<Vertex extends string = string> =
7417
- InteractionBoardTargetInputSlot<Vertex>;
7418
-
7419
- type InteractionBoardTileTargetInputSlot<Tile extends string = string> =
7420
- InteractionBoardTargetInputSlot<Tile>;
7421
-
7422
- type InteractionSubmitSlot = {
7423
- readonly Button: InteractionSlotComponent<
7424
- Omit<
7425
- ButtonHTMLAttributes<HTMLButtonElement>,
7426
- "children" | "disabled" | "type" | "value"
7427
- >
7428
- >;
7429
- };
7430
-
7431
- type InteractionInputValue<
7432
- Key extends InteractionKey,
7433
- Input extends InteractionInputKeysOf<Key>,
7434
- > = InteractionParamsShape<Key>[Input & keyof InteractionParamsShape<Key>];
7435
-
7436
- type InteractionSlotValue<Value> = Value extends readonly (infer Item)[]
7437
- ? InteractionSlotValue<Item>
7438
- : Value extends { spaceId: infer Space extends string }
7439
- ? Space
7440
- : Value extends { edgeId: infer Edge extends string }
7441
- ? Edge
7442
- : Value extends { vertexId: infer Vertex extends string }
7443
- ? Vertex
7444
- : Value extends { tileId: infer Tile extends string }
7445
- ? Tile
7446
- : Value extends { cardId: infer Card extends string }
7447
- ? Card
7448
- : Value;
7449
-
7450
- type InteractionSlotStringValue<Value> = Extract<
7451
- InteractionSlotValue<Value>,
7452
- string
7453
- >;
7454
-
7455
- type FormInteractionInputKey<Key extends InteractionKey> =
7456
- InputKeysWithCollectorKindOfDefinition<
7457
- GameDefinition,
7458
- PhaseOfInteractionKey<Key>,
7459
- IdOfInteractionKey<Key>,
7460
- "form" | "prompt"
7461
- > &
7462
- InteractionInputKeysOf<Key>;
7463
-
7464
- type CardTargetInteractionInputKey<Key extends InteractionKey> =
7465
- InputKeysWithCollectorKindOfDefinition<
7466
- GameDefinition,
7467
- PhaseOfInteractionKey<Key>,
7468
- IdOfInteractionKey<Key>,
7469
- "card"
7470
- > &
7471
- InteractionInputKeysOf<Key>;
7472
-
7473
- type CardTargetZoneIds<
7474
- Key extends InteractionKey,
7475
- Input extends InteractionInputKeysOf<Key>,
7476
- > =
7477
- CardInputZoneIdsOfDefinition<
7478
- GameDefinition,
7479
- PhaseOfInteractionKey<Key>,
7480
- IdOfInteractionKey<Key>,
7481
- Input & string
7482
- > extends infer Zone extends string
7483
- ? Extract<Zone, WorkspaceZoneId>
7484
- : never;
7485
-
7486
- type BoardSpaceTargetInteractionInputKey<Key extends InteractionKey> =
7487
- InputKeysWithCollectorKindOfDefinition<
7488
- GameDefinition,
7489
- PhaseOfInteractionKey<Key>,
7490
- IdOfInteractionKey<Key>,
7491
- "board-space"
7492
- > &
7493
- InteractionInputKeysOf<Key>;
7494
-
7495
- type BoardEdgeTargetInteractionInputKey<Key extends InteractionKey> =
7496
- InputKeysWithCollectorKindOfDefinition<
7497
- GameDefinition,
7498
- PhaseOfInteractionKey<Key>,
7499
- IdOfInteractionKey<Key>,
7500
- "board-edge"
7501
- > &
7502
- InteractionInputKeysOf<Key>;
7503
-
7504
- type BoardVertexTargetInteractionInputKey<Key extends InteractionKey> =
7505
- InputKeysWithCollectorKindOfDefinition<
7506
- GameDefinition,
7507
- PhaseOfInteractionKey<Key>,
7508
- IdOfInteractionKey<Key>,
7509
- "board-vertex"
7510
- > &
7511
- InteractionInputKeysOf<Key>;
7512
-
7513
- type BoardTileTargetInteractionInputKey<Key extends InteractionKey> =
7514
- InputKeysWithCollectorKindOfDefinition<
7515
- GameDefinition,
7516
- PhaseOfInteractionKey<Key>,
7517
- IdOfInteractionKey<Key>,
7518
- "board-tile"
7519
- > &
7520
- InteractionInputKeysOf<Key>;
7521
-
7522
- type InteractionDefaultSlotFor<
7523
- Key extends InteractionKey,
7524
- Input extends InteractionInputKeysOf<Key>,
7525
- > = Input extends InteractionHandleDefaultedKeys<Key>
7526
- ? InteractionDefaultInputSlot
7527
- : object;
7528
-
7529
- export type InteractionInputSlot<
7530
- Key extends InteractionKey,
7531
- Input extends InteractionInputKeysOf<Key>,
7532
- > = InteractionValueInputSlot<InteractionInputValue<Key, Input>> &
7533
- InteractionDefaultSlotFor<Key, Input> &
7534
- (Input extends CardTargetInteractionInputKey<Key>
7535
- ? InteractionCardTargetInputSlot<
7536
- InteractionSlotStringValue<InteractionInputValue<Key, Input>>
7537
- >
7538
- : Input extends BoardSpaceTargetInteractionInputKey<Key>
7539
- ? InteractionBoardSpaceTargetInputSlot<
7540
- InteractionSlotStringValue<InteractionInputValue<Key, Input>>
7541
- >
7542
- : Input extends BoardEdgeTargetInteractionInputKey<Key>
7543
- ? InteractionBoardEdgeTargetInputSlot<
7544
- InteractionSlotStringValue<InteractionInputValue<Key, Input>>
7545
- >
7546
- : Input extends BoardVertexTargetInteractionInputKey<Key>
7547
- ? InteractionBoardVertexTargetInputSlot<
7548
- InteractionSlotStringValue<InteractionInputValue<Key, Input>>
7549
- >
7550
- : Input extends BoardTileTargetInteractionInputKey<Key>
7551
- ? InteractionBoardTileTargetInputSlot<
7552
- InteractionSlotStringValue<InteractionInputValue<Key, Input>>
7553
- >
7554
- : Input extends FormInteractionInputKey<Key>
7555
- ? InteractionFormInputSlot<InteractionInputValue<Key, Input>>
7556
- : never);
7557
-
7558
- type FormSurfaceInputSlot<
7559
- Key extends InteractionKey,
7560
- Input extends FormInteractionInputKey<Key>,
7561
- > = InteractionValueInputSlot<InteractionInputValue<Key, Input>> &
7562
- InteractionDefaultSlotFor<Key, Input> &
7563
- InteractionFormInputSlot<InteractionInputValue<Key, Input>> &
7564
- DreamboardSlotBrand<{
7565
- readonly kind: "form";
7566
- readonly interaction: Key;
7567
- readonly input: Input;
7568
- }>;
7569
-
7570
- type CardSurfaceInputSlot<Zones extends string> =
7571
- InteractionValueInputSlot<unknown> &
7572
- InteractionCardTargetInputSlot<WorkspaceCardId & string> &
7573
- DreamboardSlotBrand<{
7574
- readonly kind: "card";
7575
- readonly zones: Zones;
7576
- readonly selection: "one" | "many";
7577
- }>;
7578
-
7579
- type BoardSurfaceInputSlot<
7580
- Kind extends "space" | "edge" | "vertex" | "tile",
7581
- Target extends string = string,
7582
- > =
7583
- InteractionValueInputSlot<unknown> &
7584
- InteractionBoardTargetInputSlot<Target> &
7585
- DreamboardSlotBrand<{
7586
- readonly kind: "board";
7587
- readonly targetKind: Kind;
7588
- }>;
7589
-
7590
- type InteractionCollectorSlot<
7591
- Key extends InteractionKey,
7592
- Input extends InteractionInputKeysOf<Key>,
7593
- > = Input extends CardTargetInteractionInputKey<Key>
7594
- ? CardSurfaceInputSlot<CardTargetZoneIds<Key, Input>>
7595
- : Input extends BoardSpaceTargetInteractionInputKey<Key>
7596
- ? BoardSurfaceInputSlot<"space", string>
7597
- : Input extends BoardEdgeTargetInteractionInputKey<Key>
7598
- ? BoardSurfaceInputSlot<"edge", string>
7599
- : Input extends BoardVertexTargetInteractionInputKey<Key>
7600
- ? BoardSurfaceInputSlot<"vertex", string>
7601
- : Input extends BoardTileTargetInteractionInputKey<Key>
7602
- ? BoardSurfaceInputSlot<"tile", string>
7603
- : Input extends FormInteractionInputKey<Key>
7604
- ? FormSurfaceInputSlot<Key, Input>
7605
- : never;
7606
-
7607
- type InteractionKeysWithInput<Input extends InteractionInputKey> = {
7608
- [Key in InteractionKey]: Input extends InteractionInputKeysOf<Key>
7609
- ? Key
7610
- : never;
7611
- }[InteractionKey];
7612
-
7613
- type InteractionInputSlotByName<Input extends InteractionInputKey> =
7614
- InteractionInputSlot<
7615
- InteractionKeysWithInput<Input>,
7616
- Input & InteractionInputKeysOf<InteractionKeysWithInput<Input>>
7617
- >;
7618
-
7619
- type InteractionFormInputSlotByName<Input extends InteractionInputKey> =
7620
- InteractionInputSlot<
7621
- {
7622
- [Key in InteractionKey]: Input extends FormInteractionInputKey<Key>
7623
- ? Key
7624
- : never;
7625
- }[InteractionKey],
7626
- Input &
7627
- InteractionInputKeysOf<
7628
- {
7629
- [Key in InteractionKey]: Input extends FormInteractionInputKey<Key>
7630
- ? Key
7631
- : never;
7632
- }[InteractionKey]
7633
- >
7634
- >;
7635
-
7636
- type InteractionInputsForCollectorKind<
7637
- Key extends InteractionKey,
7638
- CollectorKind extends InteractionCollectorKind,
7639
- > = {
7640
- [Input in InteractionInputKeysOf<Key>]: CollectorKind extends "form"
7641
- ? Input extends FormInteractionInputKey<Key>
7642
- ? Input
7643
- : never
7644
- : CollectorKind extends "card"
7645
- ? Input extends CardTargetInteractionInputKey<Key>
7646
- ? Input
7647
- : never
7648
- : CollectorKind extends "board-space"
7649
- ? Input extends BoardSpaceTargetInteractionInputKey<Key>
7650
- ? Input
7651
- : never
7652
- : CollectorKind extends "board-edge"
7653
- ? Input extends BoardEdgeTargetInteractionInputKey<Key>
7654
- ? Input
7655
- : never
7656
- : CollectorKind extends "board-vertex"
7657
- ? Input extends BoardVertexTargetInteractionInputKey<Key>
7658
- ? Input
7659
- : never
7660
- : CollectorKind extends "board-tile"
7661
- ? Input extends BoardTileTargetInteractionInputKey<Key>
7662
- ? Input
7663
- : never
7664
- : never;
7665
- }[InteractionInputKeysOf<Key>];
7666
-
7667
- type InteractionKeysForCollectorKind<
7668
- CollectorKind extends InteractionCollectorKind,
7669
- > = {
7670
- [Key in InteractionKey]: InteractionInputsForCollectorKind<
7671
- Key,
7672
- CollectorKind
7673
- > extends never
7674
- ? never
7675
- : Key;
7676
- }[InteractionKey];
7677
-
7678
- type InteractionInputSlotByCollectorKind<
7679
- CollectorKind extends InteractionCollectorKind,
7680
- > = InteractionInputSlot<
7681
- InteractionKeysForCollectorKind<CollectorKind>,
7682
- InteractionInputsForCollectorKind<
7683
- InteractionKeysForCollectorKind<CollectorKind>,
7684
- CollectorKind
7685
- >
7686
- >;
7687
-
7688
- export type InteractionFormSurface<Key extends InteractionKey> = {
7689
- readonly Root: InteractionSlotComponent;
7690
- readonly Form: DreamboardUI<typeof uiContract>["Interaction"]["Form"];
7691
- readonly Dialog: (props: WorkspaceInteractionFormDialogProps) => ReactElement | null;
7692
- readonly State: DreamboardUI<typeof uiContract>["Interaction"]["State"];
7693
- readonly Arm: DreamboardUI<typeof uiContract>["Interaction"]["Trigger"];
7694
- readonly Submit: DreamboardUI<typeof uiContract>["Interaction"]["Submit"];
7695
- readonly Field: <Input extends FormInteractionInputKey<Key>>(
7696
- props: { input: Input; children?: ReactNode },
7697
- ) => ReactElement | null;
7698
- readonly slot: {
7699
- readonly [Input in FormInteractionInputKey<Key>]: FormSurfaceInputSlot<
7700
- Key,
7701
- Input
7702
- >;
7703
- };
7704
- };
7705
-
7706
- type BoardSurfaceSpaceProps<Target extends string> = {
7707
- value: Target;
7708
- children?: ReactNode;
7709
- } & Omit<BoardSpaceTargetPropsGeneric<Target>, "value" | "children">;
7710
-
7711
- export type BoardSurfaceBoardId = BoardBaseId & string;
7712
-
7713
- type BoardSurfaceRuntimeBoardId<Board extends BoardSurfaceBoardId> =
7714
- ReturnType<typeof boardHelpers.boardIdsForBase<Board>>[number] & string;
7715
-
7716
- type BoardSurfaceSpaceId<Board extends BoardSurfaceBoardId> =
7717
- ReturnType<
7718
- typeof boardHelpers.spaceIds<BoardSurfaceRuntimeBoardId<Board>>
7719
- >[number] &
7720
- string;
7721
-
7722
- type BoardSurfaceTiledBoardId<Board extends BoardSurfaceBoardId> = Extract<
7723
- BoardSurfaceRuntimeBoardId<Board>,
7724
- TiledBoardId
7725
- >;
7726
-
7727
- type BoardSurfaceEdgeId<Board extends BoardSurfaceBoardId> =
7728
- TiledEdgeState<BoardSurfaceTiledBoardId<Board>> extends { id: infer Id }
7729
- ? Id & string
7730
- : EdgeId & string;
7731
-
7732
- type BoardSurfaceVertexId<Board extends BoardSurfaceBoardId> =
7733
- TiledVertexState<BoardSurfaceTiledBoardId<Board>> extends { id: infer Id }
7734
- ? Id & string
7735
- : VertexId & string;
7736
-
7737
- export type BoardSurface<Board extends BoardSurfaceBoardId = BoardSurfaceBoardId> = {
7738
- readonly Root: InteractionSlotComponent;
7739
- readonly Space: <Target extends BoardSurfaceSpaceId<Board>>(
7740
- props: BoardSurfaceSpaceProps<Target>,
7741
- ) => ReactElement;
7742
- readonly slot: {
7743
- readonly space: BoardSurfaceInputSlot<
7744
- "space",
7745
- BoardSurfaceSpaceId<Board>
7746
- >;
7747
- readonly playerSpace: BoardSurfaceInputSlot<
7748
- "space",
7749
- BoardSurfaceSpaceId<Board>
7750
- >;
7751
- readonly edge: BoardSurfaceInputSlot<"edge", BoardSurfaceEdgeId<Board>>;
7752
- readonly vertex: BoardSurfaceInputSlot<
7753
- "vertex",
7754
- BoardSurfaceVertexId<Board>
7755
- >;
7756
- readonly tile: BoardSurfaceInputSlot<"tile", BoardSurfaceSpaceId<Board>>;
7757
- };
7758
- };
7759
-
7760
- type ZoneCardsComponent = InteractionSlotComponent<
7761
- Omit<ZoneListProps, "children" | "empty"> & {
7762
- empty?: ReactNode;
7763
- children: (card: WorkspaceZoneCard) => ReactNode;
7764
- }
7765
- >;
7766
-
7767
- type ZoneCardComponent = InteractionSlotComponent<
7768
- Omit<ButtonHTMLAttributes<HTMLButtonElement>, "type" | "value"> & {
7769
- card: WorkspaceZoneCard;
7770
- }
7771
- >;
7772
-
7773
- /**
7774
- * Generic SDK card-intent shape for typed hand emission. Authors do not
7775
- * import the runtime; the typed \`targetId\` is constrained by the
7776
- * authored interaction domain on the generated hand surface.
7777
- */
7778
- export type HandCardIntent<Card extends string, Target extends string> =
7779
- | { type: "activate"; cardId: Card; source: "tap" | "keyboard" }
7780
- | { type: "previewStart"; cardId: Card }
7781
- | { type: "previewEnd"; cardId: Card }
7782
- | {
7783
- type: "drop";
7784
- cardId: Card;
7785
- targetId: Target;
7786
- source: "pointer" | "keyboard";
7787
- };
7788
-
7789
- export type HandLayoutKindGen = "fan" | "compressed-fan" | "tray" | "strip" | "stack";
7790
- export type HandLayoutPolicyGen = {
7791
- desktop?: HandLayoutKindGen;
7792
- mobile?: HandLayoutKindGen;
7793
- };
7794
- export type HandMobileInteractionPolicy = "direct-activate" | "drag-to-target";
7795
-
7796
- export type HandStagingTarget<Card extends string> = {
7797
- readonly kind: "card";
7798
- readonly card: Card;
7799
- };
7800
-
7801
- export type HandBoardDropTargetKind = "space" | "edge" | "vertex" | "tile";
7802
-
7803
- /**
7804
- * Discriminated union that ties each board target kind to its manifest id
7805
- * family. \`tile\` shares the space-id family because tiles are addressed
7806
- * by their underlying space.
7807
- */
7808
- export type HandBoardDropTarget<
7809
- Space extends string,
7810
- Edge extends string,
7811
- Vertex extends string,
7812
- > =
7813
- | { readonly kind: "space"; readonly target: Space }
7814
- | { readonly kind: "edge"; readonly target: Edge }
7815
- | { readonly kind: "vertex"; readonly target: Vertex }
7816
- | { readonly kind: "tile"; readonly target: Space };
7817
-
7818
- export type HandDropTargetSpec<
7819
- Card extends string,
7820
- Space extends string,
7821
- Edge extends string,
7822
- Vertex extends string,
7823
- > = HandStagingTarget<Card> | HandBoardDropTarget<Space, Edge, Vertex>;
7824
-
7825
- /** Union of all manifest target ids the typed hand can carry. */
7826
- export type HandAuthoredTarget<
7827
- Card extends string,
7828
- Space extends string,
7829
- Edge extends string,
7830
- Vertex extends string,
7831
- > = Card | Space | Edge | Vertex;
7832
-
7833
- /**
7834
- * Summary projected from the live draft for a single hand. Authors render
7835
- * counts and validity hints through the compound \`hand.Summary\` and
7836
- * \`hand.Actions\` slots, or mirror them to outside state via
7837
- * \`onSelectionSummary\`.
7838
- */
7839
- export type HandSelectionSummary<Card extends string> = {
7840
- readonly selectedCount: number;
7841
- readonly selectedIds: readonly Card[];
7842
- readonly hasInvalidSelection: boolean;
7843
- };
7844
-
7845
- export type HandSurfaceProps<
7846
- Card extends string,
7847
- Space extends string,
7848
- Edge extends string,
7849
- Vertex extends string,
7850
- > = Omit<ZoneListProps, "children" | "empty"> & {
7851
- empty?: ReactNode;
7852
- /**
7853
- * Per-card render callback. Receives the projected
7854
- * \`InteractionVisualState\` (\`eligible\`, \`selected\`, \`invalid\`,
7855
- * \`disabled\`) so authors can wire SDK \`CardFace\` directly without
7856
- * recomputing draft state.
7857
- */
7858
- children: (
7859
- card: WorkspaceZoneCard,
7860
- state: InteractionVisualState,
7861
- ) => ReactNode;
7862
- layout?: HandLayoutKindGen | HandLayoutPolicyGen;
7863
- mobileInteraction?: HandMobileInteractionPolicy;
7864
- cardSize?: "sm" | "md" | "lg";
7865
- ariaLabel?: string;
7866
- /**
7867
- * Typed drop targets that participate in \`drag-to-target\` interaction.
7868
- * Each target's \`kind\` constrains the allowed \`target\` id family, so
7869
- * a \`SpaceId\` cannot be authored as an edge or vertex target.
7870
- */
7871
- dropTargets?: ReadonlyArray<{
7872
- target: HandDropTargetSpec<Card, Space, Edge, Vertex>;
7873
- label: string;
7874
- render: (state: unknown) => ReactNode;
7875
- className?: string;
7876
- role?: string;
7877
- order?: number;
7878
- }>;
7879
- renderDropTargets?: (children: ReactNode) => ReactNode;
7880
- onCardIntent?: (
7881
- intent: HandCardIntent<Card, HandAuthoredTarget<Card, Space, Edge, Vertex>>,
7882
- ) => void;
7883
- /**
7884
- * Optional selection summary observer. Invoked from a layout effect so
7885
- * consumers may safely call \`setState\` in response.
7886
- */
7887
- onSelectionSummary?: (summary: HandSelectionSummary<Card>) => void;
7888
- };
7889
-
7890
- type HandComponent<
7891
- Card extends string,
7892
- Space extends string,
7893
- Edge extends string,
7894
- Vertex extends string,
7895
- > = InteractionSlotComponent<
7896
- Omit<HandSurfaceProps<Card, Space, Edge, Vertex>, "children"> & {
7897
- children: ReactNode;
7898
- }
7899
- >;
7900
-
7901
- type HandCardsComponent = InteractionSlotComponent<{
7902
- children: (
7903
- card: WorkspaceZoneCard,
7904
- state: InteractionVisualState,
7905
- ) => ReactNode;
7906
- }>;
7907
-
7908
- type HandSummaryComponent<Card extends string> = InteractionSlotComponent<{
7909
- children?: ReactNode | ((summary: HandSelectionSummary<Card>) => ReactNode);
7910
- }>;
7911
-
7912
- /**
7913
- * Always-visible staging surface for a many-select card collection (e.g. the
7914
- * cards you've chosen to pass): a fixed row of slots showing the staged cards,
7915
- * with empty placeholders otherwise. Tapping a staged card removes it from the
7916
- * collection (it returns to the hand). Renders nothing when the zone has no
7917
- * active many-select collection, so it can be mounted unconditionally.
7918
- */
7919
- export type HandStagingProps = {
7920
- // Staged cards are always visible (you can only stage a card you can see), so
7921
- // the slot renderer receives the hydrated card variant \u2014 no hidden-card guard.
7922
- children: (card: Extract<WorkspaceZoneCard, { hidden: false }>) => ReactNode;
7923
- label?: ReactNode;
7924
- renderEmptySlot?: (index: number) => ReactNode;
7925
- cardSize?: "sm" | "md" | "lg";
7926
- ariaLabel?: string;
7927
- className?: string;
7928
- };
7929
-
7930
- type HandStagingComponent = InteractionSlotComponent<HandStagingProps>;
7931
-
7932
- export type HandSurface<Zones extends readonly WorkspaceZoneId[] = readonly WorkspaceZoneId[]> = {
7933
- readonly Hand: HandComponent<
7934
- CardId & string,
7935
- SpaceId & string,
7936
- EdgeId & string,
7937
- VertexId & string
7938
- >;
7939
- readonly Cards: HandCardsComponent;
7940
- readonly Summary: HandSummaryComponent<CardId & string>;
7941
- readonly Actions: HandSummaryComponent<CardId & string>;
7942
- readonly Card: ZoneCardComponent;
7943
- readonly Staging: HandStagingComponent;
7944
- readonly slot: {
7945
- readonly card: CardSurfaceInputSlot<Zones[number] & string>;
7946
- };
7947
- };
7948
-
7949
- export type PileSurface<Zones extends readonly WorkspaceZoneId[] = readonly WorkspaceZoneId[]> = {
7950
- readonly Pile: ZoneCardsComponent;
7951
- readonly Card: ZoneCardComponent;
7952
- };
7953
-
7954
- export type CardCollectionSurface<Zones extends readonly WorkspaceZoneId[] = readonly WorkspaceZoneId[]> = {
7955
- readonly Collection: ZoneCardsComponent;
7956
- readonly Card: ZoneCardComponent;
7957
- readonly slot: {
7958
- readonly card: CardSurfaceInputSlot<Zones[number] & string>;
7959
- };
7960
- };
7961
-
7962
- export type InteractionFormInputs<Key extends InteractionKey> = {
7963
- [Input in InteractionInputKeysOf<Key>]: (
7964
- slot: InteractionInputSlot<Key, Input>,
7965
- ) => ReactNode;
7966
- };
7967
-
7968
- export type InteractionCollectSlots<Key extends InteractionKey> = {
7969
- [Input in RequiredInteractionInputKeysOf<Key>]: InteractionCollectorSlot<
7970
- Key,
7971
- Input
7972
- >;
7973
- };
7974
-
7975
- export type InteractionRoute<Key extends InteractionKey> = {
7976
- readonly collect: InteractionCollectSlots<Key>;
7977
- };
7978
-
7979
- export type InteractionRoutes = {
7980
- [Key in InteractionKey]: InteractionRoute<Key>;
7981
- };
7982
-
7983
- export type InteractionRoutesProps = {
7984
- routes: InteractionRoutes;
7985
- fallback?: ReactNode;
7986
- includeUnavailable?: boolean | null;
7987
- };
7988
-
7989
- export type ZeroInputInteractionKey = {
7990
- [K in InteractionKey]: InteractionInputKeysOf<K> extends never
7991
- ? K
7992
- : never;
7993
- }[InteractionKey];
7994
-
7995
- export type InputInteractionKey = Exclude<
7996
- InteractionKey,
7997
- ZeroInputInteractionKey
7998
- >;
7999
-
8000
- type InteractionInputKeyOf<Key extends InteractionKey> =
8001
- Key extends InteractionKey ? InteractionInputKeysOf<Key> : never;
8002
-
8003
- export type InteractionInputKey = InteractionInputKeyOf<InteractionKey>;
8004
-
8005
- export type PromptKey = InteractionKey;
8006
-
8007
- export type PromptOptionValue = string;
8008
-
8009
- export type BoardTargetId = SpaceId | EdgeId | VertexId;
8010
-
8011
- type UIInteractionRegistry = {
8012
- [K in InteractionKey]: {
8013
- interaction: K;
8014
- phase: PhaseOfInteractionKey<K>;
8015
- id: IdOfInteractionKey<K>;
8016
- };
8017
- };
8018
-
8019
- type UIInputRegistry = {
8020
- [K in InteractionInputKey]: { input: K };
8021
- };
8022
-
8023
- type UIPromptRegistry = {
8024
- [K in PromptKey]: { interaction: K };
8025
- };
8026
-
8027
- type UIPromptOptionRegistry = {
8028
- [K in PromptOptionValue]: { value: K };
8029
- };
8030
-
8031
- type UIPlayerRegistry = {
8032
- [K in PlayerId & string]: { player: K };
8033
- };
8034
-
8035
- type UIZoneRegistry = {
8036
- [K in ZoneId & string]: { zone: K };
8037
- };
8038
-
8039
- type UICardRegistry = {
8040
- [K in CardId & string]: { card: K };
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;
8041
7235
  };
8042
7236
 
8043
- type UIPhaseRegistry = {
8044
- [K in PhaseName & string]: { phase: K };
8045
- };
8046
-
8047
- type UIBoardTargetRegistry = {
8048
- [K in BoardTargetId & string]: { target: K };
8049
- };
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
+ });
8050
7249
 
8051
- export const uiContract = {
8052
- interactions: {} as UIInteractionRegistry,
8053
- inputs: {} as UIInputRegistry,
8054
- prompts: {} as UIPromptRegistry,
8055
- promptOptions: {} as UIPromptOptionRegistry,
8056
- players: {} as UIPlayerRegistry,
8057
- zones: {} as UIZoneRegistry,
8058
- cards: {} as UICardRegistry,
8059
- phases: {} as UIPhaseRegistry,
8060
- boardTargets: {} as UIBoardTargetRegistry,
8061
- } 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>;
8062
7282
 
8063
7283
  declare module "@dreamboard-games/sdk/runtime" {
8064
7284
  interface DreamboardUIRegister {
@@ -8066,271 +7286,6 @@ declare module "@dreamboard-games/sdk/runtime" {
8066
7286
  ui: typeof uiContract;
8067
7287
  }
8068
7288
  }
8069
-
8070
- // -------------------------------------------------------------------------
8071
- // Typed hex-board view adapter
8072
- // -------------------------------------------------------------------------
8073
-
8074
- /** Generated hex-board topology source, keyed by hex-board id. */
8075
- const hexStaticBoards = staticBoards.hex;
8076
-
8077
- /** Generated square-board topology source, keyed by square-board id. */
8078
- const squareStaticBoards = staticBoards.square;
8079
-
8080
- /** Union of authored hex-board ids in this workspace's manifest. */
8081
- export type HexBoardId = keyof typeof hexStaticBoards & string;
8082
-
8083
- /** Union of authored square-board ids in this workspace's manifest. */
8084
- export type SquareBoardId = keyof typeof squareStaticBoards & string;
8085
-
8086
- /** Topology object for the named hex board, drawn from \`staticBoards.hex\`. */
8087
- export type HexBoardTopology<Id extends HexBoardId> = (typeof hexStaticBoards)[Id];
8088
-
8089
- /** Topology object for the named square board, drawn from \`staticBoards.square\`. */
8090
- export type SquareBoardTopology<Id extends SquareBoardId> = (typeof squareStaticBoards)[Id];
8091
-
8092
- /** Space id type for the named hex board. */
8093
- export type HexBoardSpaceId<Id extends HexBoardId> = BoardSpaceIdOf<
8094
- HexBoardTopology<Id>
8095
- >;
8096
-
8097
- /** Space id type for the named square board. */
8098
- export type SquareBoardSpaceId<Id extends SquareBoardId> = BoardSpaceIdOf<
8099
- SquareBoardTopology<Id>
8100
- >;
8101
-
8102
- export type HexBoardViewProps<
8103
- Id extends HexBoardId,
8104
- TSpaceView extends { id: HexBoardSpaceId<Id> },
8105
- > = Omit<BoardHexViewPropsGeneric<HexBoardTopology<Id>, TSpaceView>, "board"> & {
8106
- board: Id;
8107
- };
8108
-
8109
- export type HexBoardGridProps<
8110
- Id extends HexBoardId,
8111
- TSpaceView extends { id: HexBoardSpaceId<Id> },
8112
- > = Omit<
8113
- BoardHexGridPropsGeneric<HexBoardTopology<Id>, TSpaceView>,
8114
- "board" | "interactions"
8115
- > & {
8116
- board: Id;
8117
- };
8118
-
8119
- export type SquareBoardGridProps<Id extends SquareBoardId> = Omit<
8120
- BoardSquareGridPropsGeneric<SquareBoardTopology<Id>>,
8121
- "board" | "interactions"
8122
- > & {
8123
- board: Id;
8124
- interactions?: BoardGridInteractionFilter<InteractionKey>;
8125
- };
8126
-
8127
- type WorkspaceBoard = {
8128
- surface<const Board extends BoardSurfaceBoardId>(
8129
- board: Board,
8130
- ): WorkspaceBoardSurfaceDescriptor<Board>;
8131
- useSurface(name: string): BoardSurface;
8132
- useSurface<const Board extends BoardSurfaceBoardId>(
8133
- name: string,
8134
- options: { board: Board },
8135
- ): BoardSurface<Board>;
8136
- HexView<
8137
- const Id extends HexBoardId,
8138
- const TSpaceView extends { id: HexBoardSpaceId<Id> },
8139
- >(props: HexBoardViewProps<Id, TSpaceView>): ReactElement;
8140
- HexGrid<
8141
- const Id extends HexBoardId,
8142
- const TSpaceView extends { id: HexBoardSpaceId<Id> },
8143
- >(props: HexBoardGridProps<Id, TSpaceView>): ReactElement;
8144
- SquareGrid<const Id extends SquareBoardId>(
8145
- props: SquareBoardGridProps<Id>,
8146
- ): ReactElement;
8147
- };
8148
-
8149
- type WorkspaceCardProperties = CardProperties extends Record<string, unknown>
8150
- ? CardProperties
8151
- : Record<string, unknown>;
8152
- type WorkspaceZoneId = [ZoneId] extends [never] ? string : ZoneId;
8153
- type WorkspaceCardId = [CardId] extends [never] ? string : CardId;
8154
- type WorkspaceCardType = [CardType] extends [never] ? string : CardType;
8155
-
8156
- // ZoneCardRenderItem is a discriminated union (hidden: true | false).
8157
- // A bare Omit<..., "zone"> would collapse the union to its common keys and
8158
- // strip cardType / properties from the hydrated branch, defeating the
8159
- // discriminated-union narrowing the SDK contract promises. Distribute Omit
8160
- // across the union so each branch keeps its own shape.
8161
- type WorkspaceZoneCard = ZoneCardRenderItem<
8162
- WorkspaceCardId & string,
8163
- WorkspaceCardType & string,
8164
- WorkspaceCardProperties
8165
- > extends infer Item
8166
- ? Item extends { zone: string }
8167
- ? Omit<Item, "zone"> & { zone: WorkspaceZoneId }
8168
- : never
8169
- : never;
8170
-
8171
- type HandRole = "primary" | "auxiliary" | "task";
8172
-
8173
- type PilesSurfaceValue<Zones extends readonly CardZoneId[]> = {
8174
- readonly [Zone in Zones[number]]: PileSurface<readonly [Zone]>;
8175
- };
8176
-
8177
- type InteractionFormsSurfaceValue<
8178
- Forms extends Readonly<Record<string, InteractionKey>>,
8179
- > = {
8180
- readonly [Key in keyof Forms]: Forms[Key] extends InteractionKey
8181
- ? InteractionFormSurface<Forms[Key]>
8182
- : never;
8183
- };
8184
-
8185
- type WorkspaceSurfaceValue<Spec> =
8186
- Spec extends WorkspaceBoardSurfaceDescriptor<infer Board extends BoardSurfaceBoardId>
8187
- ? BoardSurface<Board>
8188
- : Spec extends WorkspaceHandSurfaceDescriptor<infer Zone extends PlayerCardZoneId>
8189
- ? HandSurface<readonly [Zone]>
8190
- : Spec extends WorkspacePileSurfaceDescriptor<infer Zone extends CardZoneId>
8191
- ? PileSurface<readonly [Zone]>
8192
- : Spec extends WorkspacePilesSurfaceDescriptor<
8193
- infer Zones extends readonly CardZoneId[]
8194
- >
8195
- ? PilesSurfaceValue<Zones>
8196
- : Spec extends WorkspaceCardCollectionSurfaceDescriptor<
8197
- infer Zones extends readonly CardZoneId[]
8198
- >
8199
- ? CardCollectionSurface<Zones>
8200
- : Spec extends WorkspaceInteractionFormDescriptor<
8201
- infer Interaction extends InteractionKey
8202
- >
8203
- ? InteractionFormSurface<Interaction>
8204
- : Spec extends WorkspaceInteractionFormsDescriptor<
8205
- infer Forms extends Readonly<Record<string, InteractionKey>>
8206
- >
8207
- ? InteractionFormsSurfaceValue<Forms>
8208
- : Spec extends WorkspaceSurfaceSpec
8209
- ? { readonly [Key in keyof Spec]: WorkspaceSurfaceValue<Spec[Key]> }
8210
- : never;
8211
-
8212
- type WorkspaceZone = {
8213
- hand<const Zone extends PlayerCardZoneId>(
8214
- zone: Zone,
8215
- options: { role: HandRole; label: string; order?: number },
8216
- ): WorkspaceHandSurfaceDescriptor<Zone>;
8217
- pile<const Zone extends CardZoneId>(
8218
- zone: Zone,
8219
- ): WorkspacePileSurfaceDescriptor<Zone>;
8220
- piles<const Zones extends readonly CardZoneId[]>(
8221
- zones: Zones,
8222
- ): WorkspacePilesSurfaceDescriptor<Zones>;
8223
- collection<const Zones extends readonly CardZoneId[]>(
8224
- zones: Zones,
8225
- options?: { mode?: "all" | "top-card" },
8226
- ): WorkspaceCardCollectionSurfaceDescriptor<Zones>;
8227
- useHand<const Zone extends PlayerCardZoneId>(
8228
- name: string,
8229
- options: { zone: Zone; role: HandRole; label: string; order?: number },
8230
- ): HandSurface<readonly [Zone]>;
8231
- usePile<const Zone extends CardZoneId>(
8232
- name: string,
8233
- options: { zone: Zone },
8234
- ): PileSurface<readonly [Zone]>;
8235
- useCardCollection<const Zones extends readonly CardZoneId[]>(
8236
- name: string,
8237
- options: { zones: Zones; mode?: "all" | "top-card" },
8238
- ): CardCollectionSurface<Zones>;
8239
- };
8240
-
8241
- type WorkspaceUI = Omit<
8242
- DreamboardUI<typeof uiContract>,
8243
- "Root" | "Game" | "Interaction" | "Board" | "Zone" | "Prompt" | "PromptInbox"
8244
- > & {
8245
- Root(props: UIRootProps): ReactElement;
8246
- defineSurfaces<const Spec extends WorkspaceSurfaceSpec>(
8247
- spec: Spec,
8248
- ): () => WorkspaceSurfaceValue<Spec>;
8249
- defineGameUI<Surfaces>(
8250
- config: DefineGameUIConfig<GameRootState, Surfaces> & {
8251
- useSurfaces: () => Surfaces;
8252
- interactionRoutes?: (context: {
8253
- game: GameRootState;
8254
- surfaces: Surfaces;
8255
- }) => InteractionRoutes;
8256
- phases: {
8257
- readonly [Phase in PhaseName]: (context: {
8258
- game: GameRootState;
8259
- surfaces: Surfaces;
8260
- }) => ReactNode;
8261
- };
8262
- },
8263
- ): (props: Omit<UIRootProps, "children">) => ReactElement;
8264
- readonly Game: TypedGame<typeof uiContract, GameView, PlayerId, PhaseName>;
8265
- readonly Interaction: Pick<DreamboardUI<typeof uiContract>["Interaction"], "State" | "Dialog"> & {
8266
- useForm<Key extends InteractionKey>(interaction: Key): InteractionFormSurface<Key>;
8267
- form<const Interaction extends InteractionKey>(
8268
- interaction: Interaction,
8269
- ): WorkspaceInteractionFormDescriptor<Interaction>;
8270
- forms<const Interactions extends Readonly<Record<string, InteractionKey>>>(
8271
- interactions: Interactions,
8272
- ): WorkspaceInteractionFormsDescriptor<Interactions>;
8273
- Routes(props: InteractionRoutesProps): ReactElement;
8274
- };
8275
- readonly Board: WorkspaceBoard;
8276
- readonly Zone: WorkspaceZone;
8277
- readonly ResourceCounter: ResourceCounterComponents<ResourceId>;
8278
- };
8279
-
8280
- function formInputKeysForInteraction(interaction: string): Set<string> {
8281
- const [phase, id] = interaction.split(".", 2);
8282
- const phaseSpec = phase ? (game.phases as Record<string, unknown>)[phase] : undefined;
8283
- const phaseRecord = phaseSpec as {
8284
- interactions?: Record<string, { inputs?: Record<string, { kind?: string }> }>;
8285
- cardActions?: Record<string, { inputs?: Record<string, { kind?: string }> }>;
8286
- submit?: { inputs?: Record<string, { kind?: string }> };
8287
- } | undefined;
8288
- const spec =
8289
- (id ? phaseRecord?.interactions?.[id] : undefined) ??
8290
- (id ? phaseRecord?.cardActions?.[id] : undefined) ??
8291
- (id === "submit" ? phaseRecord?.submit : undefined);
8292
- return new Set(
8293
- Object.entries((spec?.inputs ?? {}) as Record<string, { kind?: string }>)
8294
- .filter(
8295
- ([, collector]) =>
8296
- collector.kind === "form" || collector.kind === "prompt",
8297
- )
8298
- .map(([input]) => input),
8299
- );
8300
- }
8301
-
8302
- export const UI = createWorkspaceUIContract<
8303
- WorkspaceUI,
8304
- typeof uiContract,
8305
- ResourceId,
8306
- WorkspaceZoneCard,
8307
- typeof hexStaticBoards,
8308
- typeof squareStaticBoards
8309
- >({
8310
- uiContract,
8311
- clientParamSchemasByPhase: createClientParamSchemasByPhase(game) as ClientParamSchemaMap,
8312
- formInputKeysForInteraction,
8313
- resourceIds: literals.resourceIds as readonly ResourceId[],
8314
- resourcePresentationById: literals.resourcePresentationById as Partial<
8315
- Record<string, { label?: string; icon?: string }>
8316
- >,
8317
- hexStaticBoards,
8318
- squareStaticBoards,
8319
- cardIdFromZoneCard: (card) => card.id,
8320
- zoneIdFromZoneCard: (card) => card.zone,
8321
- });
8322
- export const Board: WorkspaceUI["Board"] = UI.Board;
8323
- export const Zone: WorkspaceUI["Zone"] = UI.Zone;
8324
- export const Game: WorkspaceUI["Game"] = UI.Game;
8325
- export const Interaction = UI.Interaction;
8326
- export const PlayerRoster: WorkspaceUI["PlayerRoster"] = UI.PlayerRoster;
8327
- export const Dice: WorkspaceUI["Dice"] = UI.Dice;
8328
- export const Phase = UI.Phase;
8329
- export const ResourceCounter: WorkspaceUI["ResourceCounter"] = UI.ResourceCounter;
8330
-
8331
- export const clientParamSchemasByPhase = createClientParamSchemasByPhase(
8332
- game,
8333
- ) as ClientParamSchemaMap;
8334
7289
  `;
8335
7290
  }
8336
7291
  function generateReducerSupportSeed() {
@@ -8804,7 +7759,7 @@ function generateFrameworkFiles(manifest) {
8804
7759
  return {
8805
7760
  "app/tsconfig.framework.json": generateAppFrameworkTsConfig(),
8806
7761
  "ui/tsconfig.framework.json": generateUiFrameworkTsConfig(),
8807
- "shared/generated/ui-contract.ts": generateUiContractContent(),
7762
+ "shared/generated/ui-contract.ts": generateThinUiContractContent(),
8808
7763
  "app/index.ts": generateAuthoritativeIndexFile(manifest)
8809
7764
  };
8810
7765
  }
@@ -8844,4 +7799,4 @@ export {
8844
7799
  generateAuthoritativeFiles,
8845
7800
  generateDynamicGeneratedFiles
8846
7801
  };
8847
- //# sourceMappingURL=chunk-2TAKLJJD.js.map
7802
+ //# sourceMappingURL=chunk-HIH6Y4FA.js.map