@dreamboard-games/sdk 0.5.0-alpha.1 → 0.5.0-alpha.2

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 (87) hide show
  1. package/README.md +9 -4
  2. package/dist/browser-interaction.d.ts +22 -22
  3. package/dist/chunk-5YV2WHJ4.js +25 -0
  4. package/dist/chunk-5YV2WHJ4.js.map +1 -0
  5. package/dist/{chunk-K2JGSRMD.js → chunk-ANRB4XKA.js} +1 -1
  6. package/dist/chunk-ANRB4XKA.js.map +1 -0
  7. package/dist/{chunk-XRS4AZFK.js → chunk-BI4G3PM2.js} +6 -6
  8. package/dist/chunk-BI4G3PM2.js.map +1 -0
  9. package/dist/{chunk-MIKC4Y67.js → chunk-EVCLTY4Q.js} +19 -6
  10. package/dist/chunk-EVCLTY4Q.js.map +1 -0
  11. package/dist/{chunk-EHPEMPRZ.js → chunk-H6VDGFL5.js} +1 -1
  12. package/dist/chunk-H6VDGFL5.js.map +1 -0
  13. package/dist/{chunk-4ZKTGZZK.js → chunk-LR3ZTWQF.js} +1 -1
  14. package/dist/chunk-LR3ZTWQF.js.map +1 -0
  15. package/dist/{chunk-VZ7N6WAQ.js → chunk-PN5O6GG2.js} +2 -2
  16. package/dist/{chunk-7M3N5DFJ.js → chunk-S2JEDVWH.js} +2 -2
  17. package/dist/{chunk-M2S3QC32.js → chunk-Y75CFE77.js} +2 -6
  18. package/dist/chunk-Y75CFE77.js.map +1 -0
  19. package/dist/chunk-Z7QCREWI.js +3435 -0
  20. package/dist/chunk-Z7QCREWI.js.map +1 -0
  21. package/dist/{chunk-MYKS6MTR.js → chunk-ZZGN2ATS.js} +601 -7
  22. package/dist/chunk-ZZGN2ATS.js.map +1 -0
  23. package/dist/{components-CuBO6rev.d.ts → components-gAbIz7hK.d.ts} +1 -1
  24. package/dist/{definitions-1Hj-pQU8.d.ts → definitions-BgmV_GhC.d.ts} +3 -3
  25. package/dist/{game-g9dDFYyU.d.ts → game-CsZScpcn.d.ts} +221 -4
  26. package/dist/{index-Bxbv3c9W.d.ts → index-CcT9Q7N7.d.ts} +1 -1
  27. package/dist/index.js +1 -2
  28. package/dist/package-set.js +1 -2
  29. package/dist/reducer/advanced.d.ts +11 -11
  30. package/dist/reducer/advanced.js +8 -6
  31. package/dist/reducer-contract.d.ts +9 -1
  32. package/dist/reducer-contract.js +3 -3
  33. package/dist/reducer.d.ts +10 -7
  34. package/dist/reducer.js +14 -10
  35. package/dist/reducer.js.map +1 -1
  36. package/dist/runtime/primitives.d.ts +4 -3
  37. package/dist/runtime/primitives.js +2 -2
  38. package/dist/runtime/runtime-api.d.ts +2 -1
  39. package/dist/runtime/workspace-contract.d.ts +38 -9
  40. package/dist/runtime/workspace-contract.js +11 -7
  41. package/dist/{runtime-DksMTWtC.d.ts → runtime-RJ5orDJU.d.ts} +22 -29
  42. package/dist/{runtime-api-C9bDgp63.d.ts → runtime-api-Bz5pwNU_.d.ts} +4 -1
  43. package/dist/runtime.d.ts +5 -5
  44. package/dist/runtime.js +13 -12
  45. package/dist/runtime.js.map +1 -1
  46. package/dist/testing-compiler.d.ts +3 -3
  47. package/dist/testing-runtime.d.ts +5 -5
  48. package/dist/testing-runtime.js +5 -5
  49. package/dist/testing.d.ts +14 -14
  50. package/dist/testing.js +12 -12
  51. package/dist/{types-Dlh4GsNp.d.ts → types-JWCYHmu7.d.ts} +1 -1
  52. package/dist/types.js +6 -18
  53. package/dist/types.js.map +1 -1
  54. package/dist/ui/components.d.ts +2 -2
  55. package/dist/{ui-contract-Mgx_k9gm.d.ts → ui-contract-GTUPkf8z.d.ts} +175 -175
  56. package/dist/ui.d.ts +3 -3
  57. package/dist/{views-B4lD4fT0.d.ts → views-BpuWcOyN.d.ts} +2 -2
  58. package/package.json +2 -21
  59. package/dist/authoring/index.d.ts +0 -59
  60. package/dist/authoring/index.js +0 -24
  61. package/dist/authoring/index.js.map +0 -1
  62. package/dist/authoring-compiler.d.ts +0 -27
  63. package/dist/authoring-compiler.js +0 -11
  64. package/dist/authoring-compiler.js.map +0 -1
  65. package/dist/authoring-generate-cli.d.ts +0 -1
  66. package/dist/authoring-generate-cli.js +0 -45
  67. package/dist/authoring-generate-cli.js.map +0 -1
  68. package/dist/chunk-2WJSQQT7.js +0 -166
  69. package/dist/chunk-2WJSQQT7.js.map +0 -1
  70. package/dist/chunk-4ZKTGZZK.js.map +0 -1
  71. package/dist/chunk-EHPEMPRZ.js.map +0 -1
  72. package/dist/chunk-EY2LL5WD.js +0 -9
  73. package/dist/chunk-EY2LL5WD.js.map +0 -1
  74. package/dist/chunk-JUGQ6F3N.js +0 -7538
  75. package/dist/chunk-JUGQ6F3N.js.map +0 -1
  76. package/dist/chunk-K2JGSRMD.js.map +0 -1
  77. package/dist/chunk-M2S3QC32.js.map +0 -1
  78. package/dist/chunk-MIKC4Y67.js.map +0 -1
  79. package/dist/chunk-MYKS6MTR.js.map +0 -1
  80. package/dist/chunk-QLSK3DYO.js +0 -532
  81. package/dist/chunk-QLSK3DYO.js.map +0 -1
  82. package/dist/chunk-XRS4AZFK.js.map +0 -1
  83. package/dist/codegen.d.ts +0 -939
  84. package/dist/codegen.js +0 -40
  85. package/dist/codegen.js.map +0 -1
  86. /package/dist/{chunk-VZ7N6WAQ.js.map → chunk-PN5O6GG2.js.map} +0 -0
  87. /package/dist/{chunk-7M3N5DFJ.js.map → chunk-S2JEDVWH.js.map} +0 -0
@@ -1,13 +1,26 @@
1
1
  import {
2
+ asPlayerId,
3
+ assumeManifestSchema,
2
4
  cardInput,
3
5
  cardTarget,
6
+ createManifestGameStateSchema,
7
+ createManifestRuntimeSchema,
4
8
  createManifestStringLiteralSchema,
5
9
  createTargetRule,
6
10
  createTargetRuleBuilder,
7
11
  isManifestScopedSchema,
8
12
  isPerPlayer,
9
- markManifestScopedSchema
10
- } from "./chunk-EHPEMPRZ.js";
13
+ markManifestScopedSchema,
14
+ perPlayer,
15
+ perPlayerSchema
16
+ } from "./chunk-H6VDGFL5.js";
17
+ import {
18
+ buildTypedRecord
19
+ } from "./chunk-5YV2WHJ4.js";
20
+ import {
21
+ analyzeManifest,
22
+ materializeManifestTable
23
+ } from "./chunk-Z7QCREWI.js";
11
24
 
12
25
  // src/reducer/schema-helpers.ts
13
26
  import { z } from "zod";
@@ -786,6 +799,585 @@ function coin() {
786
799
  }
787
800
  var rngInput = { d6, coin };
788
801
 
802
+ // src/reducer/manifest/compiler.ts
803
+ import { z as z7 } from "zod";
804
+
805
+ // src/reducer/manifest/schema.ts
806
+ import { z as z6 } from "zod";
807
+ function createTableSchema(analysis, ids) {
808
+ const unknownRecordSchema = z6.record(z6.string(), z6.unknown());
809
+ const objectSchema = (schema) => schema && Object.keys(schema.properties).length ? z6.object(
810
+ Object.fromEntries(
811
+ Object.entries(schema.properties).map(([key, value]) => [
812
+ key,
813
+ propertySchema(value)
814
+ ])
815
+ )
816
+ ) : unknownRecordSchema;
817
+ function propertySchema(schema) {
818
+ if (!schema) return z6.unknown();
819
+ let result;
820
+ switch (schema.type) {
821
+ case "string":
822
+ result = z6.string();
823
+ break;
824
+ case "integer":
825
+ result = z6.number().int();
826
+ break;
827
+ case "number":
828
+ result = z6.number();
829
+ break;
830
+ case "boolean":
831
+ result = z6.boolean();
832
+ break;
833
+ case "enum":
834
+ result = schema.enums?.length ? z6.enum(schema.enums) : z6.string();
835
+ break;
836
+ case "array":
837
+ result = z6.array(propertySchema(schema.items));
838
+ break;
839
+ case "record":
840
+ result = z6.record(z6.string(), propertySchema(schema.values));
841
+ break;
842
+ case "object":
843
+ result = objectSchema({ properties: schema.properties ?? {} });
844
+ break;
845
+ default:
846
+ result = ids[schema.type];
847
+ }
848
+ if (schema.nullable) result = result.nullable();
849
+ if (schema.optional) result = result.optional();
850
+ if (Object.prototype.hasOwnProperty.call(schema, "default"))
851
+ result = result.default(schema.default);
852
+ return result;
853
+ }
854
+ const shape = (items, getKey, getSchema) => z6.object(
855
+ Object.fromEntries(items.map((item) => [getKey(item), getSchema(item)]))
856
+ );
857
+ const cardStateByIdSchema = shape(
858
+ analysis.cardIds,
859
+ (id) => id,
860
+ (id) => {
861
+ const setId = analysis.cardSetIdByCardId.get(id);
862
+ const type = analysis.cardTypeByCardId.get(id);
863
+ const schema = analysis.cardSets.find(
864
+ (set) => set.id === setId
865
+ ).cardSchema;
866
+ const properties = schema && "variants" in schema ? objectSchema({
867
+ properties: {
868
+ ...schema.shared,
869
+ ...schema.variants[type]?.properties
870
+ }
871
+ }) : objectSchema(schema);
872
+ return z6.object({
873
+ componentType: z6.string().optional(),
874
+ id: z6.literal(id),
875
+ cardSetId: z6.literal(setId),
876
+ cardType: z6.literal(type),
877
+ name: z6.string().optional(),
878
+ text: z6.string().optional(),
879
+ properties
880
+ });
881
+ }
882
+ );
883
+ const pieceStateByIdSchema = shape(
884
+ analysis.pieceIds,
885
+ (id) => id,
886
+ (id) => {
887
+ const type = analysis.pieceTypeIdByPieceId.get(id);
888
+ return z6.object({
889
+ componentType: z6.string().optional(),
890
+ id: z6.literal(id),
891
+ pieceTypeId: z6.literal(type),
892
+ pieceName: z6.string().nullish(),
893
+ ownerId: ids.playerId.nullish(),
894
+ properties: objectSchema(analysis.pieceTypeSchemasById.get(type))
895
+ });
896
+ }
897
+ );
898
+ const dieStateByIdSchema = shape(
899
+ analysis.dieIds,
900
+ (id) => id,
901
+ (id) => {
902
+ const type = analysis.dieTypeIdByDieId.get(id);
903
+ return z6.object({
904
+ componentType: z6.string().optional(),
905
+ id: z6.literal(id),
906
+ dieTypeId: z6.literal(type),
907
+ dieName: z6.string().nullish(),
908
+ ownerId: ids.playerId.nullish(),
909
+ sides: z6.literal(
910
+ analysis.manifest.dieTypes?.find((die) => die.id === type)?.sides ?? 6
911
+ ),
912
+ value: z6.number().int().nullish(),
913
+ properties: objectSchema(analysis.dieTypeSchemasById.get(type))
914
+ });
915
+ }
916
+ );
917
+ const sharedZoneSchema = shape(
918
+ analysis.sharedZones,
919
+ (zone) => zone.id,
920
+ () => z6.array(ids.cardId)
921
+ );
922
+ const playerZoneSchema = shape(
923
+ analysis.playerZones,
924
+ (zone) => zone.id,
925
+ () => perPlayerSchema(z6.array(ids.cardId))
926
+ );
927
+ const zoneIdSchema = ids.zoneId;
928
+ const playerZoneIdSchema = ids.playerZoneId;
929
+ const slotVariants = analysis.strictSlotHosts.flatMap(
930
+ (host) => host.slotIds.map(
931
+ (slotId) => z6.object({
932
+ type: z6.literal("InSlot"),
933
+ host: z6.object({ kind: z6.literal(host.kind), id: z6.literal(host.id) }),
934
+ slotId: z6.literal(slotId),
935
+ position: z6.number().int().nullish()
936
+ })
937
+ )
938
+ );
939
+ const slotLocationSchema = slotVariants.length ? z6.union(
940
+ slotVariants
941
+ ) : z6.never();
942
+ const boardSpaceTypeIdSchema = ids.spaceTypeId.nullable().optional();
943
+ const boardSpaceStateSchema = z6.object({
944
+ id: ids.spaceId,
945
+ name: z6.string().nullable().optional(),
946
+ typeId: boardSpaceTypeIdSchema,
947
+ fields: unknownRecordSchema,
948
+ zoneId: z6.string().nullable().optional()
949
+ });
950
+ const hexSpaceStateSchema = boardSpaceStateSchema.extend({
951
+ q: z6.number().int(),
952
+ r: z6.number().int()
953
+ });
954
+ const squareSpaceStateSchema = boardSpaceStateSchema.extend({
955
+ row: z6.number().int(),
956
+ col: z6.number().int()
957
+ });
958
+ const boardRelationStateSchema = z6.object({
959
+ id: z6.string().nullable().optional(),
960
+ typeId: ids.relationTypeId,
961
+ fromSpaceId: ids.spaceId,
962
+ toSpaceId: ids.spaceId,
963
+ directed: z6.boolean(),
964
+ fields: unknownRecordSchema
965
+ });
966
+ const boardContainerStateSchema = z6.object({
967
+ id: ids.boardContainerId,
968
+ name: z6.string(),
969
+ host: z6.discriminatedUnion("type", [
970
+ z6.object({ type: z6.literal("board") }),
971
+ z6.object({ type: z6.literal("space"), spaceId: ids.spaceId })
972
+ ]),
973
+ allowedCardSetIds: z6.array(ids.cardSetId).optional(),
974
+ zoneId: z6.string(),
975
+ fields: unknownRecordSchema
976
+ });
977
+ const runtimeGenericBoardStateSchema = z6.object({
978
+ id: ids.boardId,
979
+ baseId: ids.boardBaseId,
980
+ layout: z6.literal("generic"),
981
+ typeId: ids.boardTypeId.nullable().optional(),
982
+ scope: z6.enum(["shared", "perPlayer"]),
983
+ playerId: ids.playerId.nullable().optional(),
984
+ templateId: z6.string().nullable().optional(),
985
+ fields: unknownRecordSchema,
986
+ // T220: per-board state.spaces is loose-keyed by string. See the
987
+ // codegen-template comment in renderGenericBoardStateSchema for
988
+ // the rationale; the wire shape is unchanged (additionalProperties
989
+ // JSON), and the inner id field narrows at parse time.
990
+ spaces: z6.record(z6.string(), boardSpaceStateSchema),
991
+ relations: z6.array(boardRelationStateSchema),
992
+ containers: z6.record(z6.string(), boardContainerStateSchema)
993
+ });
994
+ const hexEdgeStateSchema = z6.object({
995
+ id: ids.edgeId,
996
+ spaceIds: z6.array(ids.spaceId).min(1).max(2),
997
+ typeId: ids.edgeTypeId.nullable().optional(),
998
+ label: z6.string().nullable().optional(),
999
+ ownerId: ids.playerId.nullable().optional(),
1000
+ fields: unknownRecordSchema
1001
+ });
1002
+ const hexVertexStateSchema = z6.object({
1003
+ id: ids.vertexId,
1004
+ spaceIds: z6.array(ids.spaceId).min(1).max(3),
1005
+ typeId: ids.vertexTypeId.nullable().optional(),
1006
+ label: z6.string().nullable().optional(),
1007
+ ownerId: ids.playerId.nullable().optional(),
1008
+ fields: unknownRecordSchema
1009
+ });
1010
+ const squareVertexStateSchema = z6.object({
1011
+ id: ids.vertexId,
1012
+ spaceIds: z6.array(ids.spaceId).min(1).max(4),
1013
+ typeId: ids.vertexTypeId.nullable().optional(),
1014
+ label: z6.string().nullable().optional(),
1015
+ ownerId: ids.playerId.nullable().optional(),
1016
+ fields: unknownRecordSchema
1017
+ });
1018
+ const runtimeHexBoardStateSchema = runtimeGenericBoardStateSchema.extend({
1019
+ layout: z6.literal("hex"),
1020
+ // T220: loose-keyed by string — see comment above.
1021
+ spaces: z6.record(z6.string(), hexSpaceStateSchema),
1022
+ relations: z6.array(boardRelationStateSchema),
1023
+ containers: z6.object({}),
1024
+ orientation: z6.enum(["pointy-top", "flat-top"]),
1025
+ edges: z6.array(hexEdgeStateSchema),
1026
+ vertices: z6.array(hexVertexStateSchema)
1027
+ });
1028
+ const runtimeSquareBoardStateSchema = runtimeGenericBoardStateSchema.extend({
1029
+ layout: z6.literal("square"),
1030
+ // T220: loose-keyed by string — see comment above.
1031
+ spaces: z6.record(z6.string(), squareSpaceStateSchema),
1032
+ relations: z6.array(boardRelationStateSchema),
1033
+ containers: z6.record(z6.string(), boardContainerStateSchema),
1034
+ edges: z6.array(hexEdgeStateSchema),
1035
+ vertices: z6.array(squareVertexStateSchema)
1036
+ });
1037
+ const boards = analysis.analyzedBoards.flatMap(
1038
+ (board) => board.runtimeBoardIds.map((id) => {
1039
+ const base = {
1040
+ id: board.board.scope === "perPlayer" ? z6.templateLiteral([board.board.id, ":", z6.string().min(1)]) : z6.literal(id),
1041
+ baseId: z6.literal(board.board.id),
1042
+ scope: z6.literal(board.board.scope),
1043
+ fields: objectSchema(board.boardFieldsSchema)
1044
+ };
1045
+ const spaces = boardSpaceStateSchema.extend({
1046
+ fields: objectSchema(board.spaceFieldsSchema)
1047
+ });
1048
+ const relations = z6.array(
1049
+ boardRelationStateSchema.extend({
1050
+ fields: objectSchema(
1051
+ "relationFieldsSchema" in board ? board.relationFieldsSchema : void 0
1052
+ )
1053
+ })
1054
+ );
1055
+ const containers = "containers" in board ? shape(
1056
+ board.containers,
1057
+ (item) => item.id,
1058
+ (item) => boardContainerStateSchema.extend({
1059
+ id: z6.literal(item.id),
1060
+ fields: objectSchema(board.containerFieldsSchema)
1061
+ })
1062
+ ) : z6.object({});
1063
+ if (board.layout === "generic")
1064
+ return {
1065
+ id,
1066
+ scope: board.board.scope,
1067
+ layout: board.layout,
1068
+ schema: runtimeGenericBoardStateSchema.extend({
1069
+ ...base,
1070
+ spaces: z6.record(z6.string(), spaces),
1071
+ relations,
1072
+ containers
1073
+ })
1074
+ };
1075
+ const edges = z6.array(
1076
+ hexEdgeStateSchema.extend({
1077
+ fields: objectSchema(board.edgeFieldsSchema)
1078
+ })
1079
+ );
1080
+ const vertices = z6.array(
1081
+ (board.layout === "hex" ? hexVertexStateSchema : squareVertexStateSchema).extend({ fields: objectSchema(board.vertexFieldsSchema) })
1082
+ );
1083
+ return {
1084
+ id,
1085
+ scope: board.board.scope,
1086
+ layout: board.layout,
1087
+ schema: board.layout === "hex" ? runtimeHexBoardStateSchema.extend({
1088
+ ...base,
1089
+ spaces: z6.record(
1090
+ z6.string(),
1091
+ spaces.extend({ q: z6.number().int(), r: z6.number().int() })
1092
+ ),
1093
+ edges,
1094
+ vertices
1095
+ }) : runtimeSquareBoardStateSchema.extend({
1096
+ ...base,
1097
+ spaces: z6.record(
1098
+ z6.string(),
1099
+ spaces.extend({
1100
+ row: z6.number().int(),
1101
+ col: z6.number().int()
1102
+ })
1103
+ ),
1104
+ relations,
1105
+ containers,
1106
+ edges,
1107
+ vertices
1108
+ })
1109
+ };
1110
+ })
1111
+ );
1112
+ const boardCollection = (entries) => {
1113
+ const shared = entries.filter((board) => board.scope === "shared");
1114
+ const scoped = entries.filter((board) => board.scope === "perPlayer").map((board) => board.schema);
1115
+ return shape(
1116
+ shared,
1117
+ (board) => board.id,
1118
+ (board) => board.schema
1119
+ ).catchall(scoped.length ? z6.union(scoped) : z6.never());
1120
+ };
1121
+ const boardStateByIdSchema = boardCollection(boards);
1122
+ const hexBoardStateByIdSchema = boardCollection(
1123
+ boards.filter((board) => board.layout === "hex")
1124
+ );
1125
+ const squareBoardStateByIdSchema = boardCollection(
1126
+ boards.filter((board) => board.layout === "square")
1127
+ );
1128
+ return z6.object({
1129
+ playerOrder: z6.array(ids.playerId),
1130
+ zones: z6.object({
1131
+ shared: sharedZoneSchema,
1132
+ perPlayer: playerZoneSchema,
1133
+ visibility: z6.record(
1134
+ zoneIdSchema,
1135
+ z6.enum(["all", "ownerOnly", "public", "hidden"])
1136
+ ),
1137
+ cardSetIdsByZoneId: z6.record(zoneIdSchema, z6.array(ids.cardSetId)).optional()
1138
+ }),
1139
+ decks: sharedZoneSchema,
1140
+ hands: playerZoneSchema,
1141
+ handVisibility: z6.record(
1142
+ playerZoneIdSchema,
1143
+ z6.enum(["all", "ownerOnly", "public", "hidden"])
1144
+ ),
1145
+ cards: cardStateByIdSchema,
1146
+ pieces: pieceStateByIdSchema,
1147
+ componentLocations: z6.record(
1148
+ z6.string(),
1149
+ z6.union([
1150
+ z6.object({ type: z6.literal("Detached") }),
1151
+ z6.object({
1152
+ type: z6.literal("InDeck"),
1153
+ deckId: ids.deckId,
1154
+ playedBy: ids.playerId.nullable(),
1155
+ position: z6.number().int().nullable().optional()
1156
+ }),
1157
+ z6.object({
1158
+ type: z6.literal("InHand"),
1159
+ handId: ids.handId,
1160
+ playerId: ids.playerId,
1161
+ position: z6.number().int().nullable().optional()
1162
+ }),
1163
+ z6.object({
1164
+ type: z6.literal("InZone"),
1165
+ zoneId: z6.string(),
1166
+ playedBy: ids.playerId.nullable().optional(),
1167
+ position: z6.number().int().nullable().optional()
1168
+ }),
1169
+ z6.object({
1170
+ type: z6.literal("OnSpace"),
1171
+ boardId: ids.boardId,
1172
+ spaceId: ids.spaceId,
1173
+ position: z6.number().int().nullable().optional()
1174
+ }),
1175
+ z6.object({
1176
+ type: z6.literal("InContainer"),
1177
+ boardId: ids.boardId,
1178
+ containerId: ids.boardContainerId,
1179
+ position: z6.number().int().nullable().optional()
1180
+ }),
1181
+ z6.object({
1182
+ type: z6.literal("OnEdge"),
1183
+ boardId: ids.boardId,
1184
+ edgeId: ids.edgeId,
1185
+ position: z6.number().int().nullable().optional()
1186
+ }),
1187
+ z6.object({
1188
+ type: z6.literal("OnVertex"),
1189
+ boardId: ids.boardId,
1190
+ vertexId: ids.vertexId,
1191
+ position: z6.number().int().nullable().optional()
1192
+ }),
1193
+ slotLocationSchema
1194
+ ])
1195
+ ),
1196
+ ownerOfCard: z6.record(ids.cardId, ids.playerId.nullable()),
1197
+ visibility: z6.record(
1198
+ ids.cardId,
1199
+ z6.object({
1200
+ faceUp: z6.boolean(),
1201
+ visibleTo: z6.array(ids.playerId).nullable().optional()
1202
+ })
1203
+ ),
1204
+ resources: perPlayerSchema(z6.record(ids.resourceId, z6.number().int())),
1205
+ boards: z6.object({
1206
+ byId: boardStateByIdSchema,
1207
+ hex: hexBoardStateByIdSchema,
1208
+ square: squareBoardStateByIdSchema,
1209
+ network: z6.record(z6.string(), unknownRecordSchema).default({}),
1210
+ track: z6.record(z6.string(), unknownRecordSchema).default({})
1211
+ }),
1212
+ dice: dieStateByIdSchema
1213
+ });
1214
+ }
1215
+
1216
+ // src/reducer/manifest/compiler.ts
1217
+ function compileManifest(manifest) {
1218
+ const source = manifest;
1219
+ const analysis = analyzeManifest(source);
1220
+ const initial = materializeManifestTable({
1221
+ manifest: source,
1222
+ playerIds: analysis.playerIds,
1223
+ shuffleItems: (values) => [...values]
1224
+ });
1225
+ const sharedZoneIds = analysis.sharedZones.map((zone) => zone.id).sort();
1226
+ const playerZoneIds = analysis.playerZones.map((zone) => zone.id).sort();
1227
+ const literals = {
1228
+ ...Object.fromEntries(
1229
+ Object.entries(analysis).filter(([key]) => key.endsWith("Ids") || key === "cardTypes").map(([key, value]) => [key, value])
1230
+ ),
1231
+ playerIds: analysis.playerIds.map(asPlayerId),
1232
+ phaseNames: [],
1233
+ boardLayouts: ["generic", "hex", "square"],
1234
+ deckIds: sharedZoneIds,
1235
+ handIds: playerZoneIds,
1236
+ sharedZoneIds,
1237
+ playerZoneIds,
1238
+ resourcePresentationById: analysis.resourcePresentationById,
1239
+ handVisibilityById: Object.fromEntries(
1240
+ playerZoneIds.map((id) => [
1241
+ id,
1242
+ analysis.zoneVisibilityById.get(id) ?? "ownerOnly"
1243
+ ])
1244
+ ),
1245
+ zoneVisibilityById: Object.fromEntries(analysis.zoneVisibilityById),
1246
+ cardSetIdByCardId: Object.fromEntries(analysis.cardSetIdByCardId),
1247
+ cardTypeByCardId: Object.fromEntries(analysis.cardTypeByCardId),
1248
+ setupChoiceIdsByOptionId: Object.fromEntries(
1249
+ analysis.setupChoiceIdsByOptionId
1250
+ ),
1251
+ cardSetIdsBySharedZoneId: Object.fromEntries(analysis.sharedZoneCardSetIds),
1252
+ cardSetIdsByPlayerZoneId: Object.fromEntries(analysis.playerZoneCardSetIds)
1253
+ };
1254
+ const families = [
1255
+ "phaseName",
1256
+ "boardLayout",
1257
+ "setupOptionId",
1258
+ "setupProfileId",
1259
+ "cardSetId",
1260
+ "cardType",
1261
+ "cardId",
1262
+ "deckId",
1263
+ "handId",
1264
+ "sharedZoneId",
1265
+ "playerZoneId",
1266
+ "zoneId",
1267
+ "resourceId",
1268
+ "pieceTypeId",
1269
+ "pieceId",
1270
+ "dieTypeId",
1271
+ "dieId",
1272
+ "boardTypeId",
1273
+ "boardBaseId",
1274
+ "boardId",
1275
+ "boardContainerId",
1276
+ "relationTypeId",
1277
+ "edgeId",
1278
+ "edgeTypeId",
1279
+ "vertexId",
1280
+ "vertexTypeId",
1281
+ "spaceId",
1282
+ "spaceTypeId"
1283
+ ];
1284
+ const ids = {
1285
+ ...Object.fromEntries(
1286
+ families.map((family) => {
1287
+ const values = literals[`${family}s`];
1288
+ return [
1289
+ family,
1290
+ family === "phaseName" ? markManifestScopedSchema(z7.string(), family) : values.length ? createManifestStringLiteralSchema(values, family) : markManifestScopedSchema(z7.never(), family)
1291
+ ];
1292
+ })
1293
+ ),
1294
+ playerId: markManifestScopedSchema(
1295
+ z7.string().min(1).transform(asPlayerId),
1296
+ "playerId"
1297
+ )
1298
+ };
1299
+ const boardIdSchemas = analysis.analyzedBoards.map(
1300
+ (board) => board.board.scope === "perPlayer" ? z7.templateLiteral([board.board.id, ":", z7.string().min(1)]) : z7.literal(board.board.id)
1301
+ );
1302
+ ids.boardId = markManifestScopedSchema(
1303
+ boardIdSchemas.length ? z7.union(boardIdSchemas) : z7.never(),
1304
+ "boardId"
1305
+ );
1306
+ const tableSchema = assumeManifestSchema(
1307
+ createTableSchema(analysis, ids)
1308
+ );
1309
+ const resolvePlayers = (players = analysis.playerIds) => players.map(asPlayerId);
1310
+ const emptyDecks = () => Object.fromEntries(sharedZoneIds.map((id) => [id, []]));
1311
+ const hands = (players) => Object.fromEntries(
1312
+ playerZoneIds.map((id) => [
1313
+ id,
1314
+ perPlayer(resolvePlayers(players), () => [])
1315
+ ])
1316
+ );
1317
+ const defaults = {
1318
+ zones: (players) => ({
1319
+ shared: emptyDecks(),
1320
+ perPlayer: hands(players),
1321
+ visibility: structuredClone(literals.zoneVisibilityById),
1322
+ cardSetIdsByZoneId: Object.fromEntries(analysis.zoneCardSetIdsById)
1323
+ }),
1324
+ decks: emptyDecks,
1325
+ hands,
1326
+ handVisibility: () => structuredClone(literals.handVisibilityById),
1327
+ ownerOfCard: () => Object.fromEntries(analysis.cardIds.map((id) => [id, null])),
1328
+ visibility: () => Object.fromEntries(analysis.cardIds.map((id) => [id, { faceUp: true }])),
1329
+ resources: (players) => perPlayer(
1330
+ resolvePlayers(players),
1331
+ () => Object.fromEntries(analysis.resourceIds.map((id) => [id, 0]))
1332
+ )
1333
+ };
1334
+ const runtimeSchema = createManifestRuntimeSchema({
1335
+ phaseNameSchema: z7.string(),
1336
+ playerIdSchema: ids.playerId,
1337
+ setupProfileIdSchema: ids.setupProfileId
1338
+ });
1339
+ const createInitialTable = (options = {}) => tableSchema.parse(
1340
+ materializeManifestTable({
1341
+ manifest: source,
1342
+ playerIds: options.playerIds ?? analysis.playerIds,
1343
+ shuffleItems: options.shuffleItems ?? ((values) => [...values])
1344
+ })
1345
+ );
1346
+ return {
1347
+ literals,
1348
+ ids,
1349
+ defaults,
1350
+ records: Object.fromEntries(
1351
+ [...families, "playerId"].map((family) => [
1352
+ `${family}s`,
1353
+ (initial2) => buildTypedRecord(
1354
+ literals[`${family}s`],
1355
+ initial2
1356
+ )
1357
+ ])
1358
+ ),
1359
+ tableSchema,
1360
+ runtimeSchema,
1361
+ schemas: { table: tableSchema, runtime: runtimeSchema },
1362
+ staticBoards: initial.boards,
1363
+ setupOptionsById: analysis.setupOptionsById,
1364
+ setupChoiceIdsByOptionId: literals.setupChoiceIdsByOptionId,
1365
+ setupProfilesById: analysis.setupProfilesById,
1366
+ createInitialTable,
1367
+ normalSetup: {
1368
+ minPlayers: source.players.minPlayers,
1369
+ maxPlayers: source.players.maxPlayers,
1370
+ createInitialTable
1371
+ },
1372
+ createGameStateSchema: (config) => createManifestGameStateSchema({
1373
+ ...config,
1374
+ tableSchema,
1375
+ playerIdSchema: ids.playerId,
1376
+ setupProfileIdSchema: ids.setupProfileId
1377
+ })
1378
+ };
1379
+ }
1380
+
789
1381
  // src/reducer/authoring/validation.ts
790
1382
  var MANIFEST_SCOPED_ID_NAMES = [
791
1383
  "playerId",
@@ -1061,14 +1653,14 @@ function defineCardAction() {
1061
1653
  }
1062
1654
 
1063
1655
  // src/reducer/authoring/phase.ts
1064
- import { z as z6 } from "zod";
1656
+ import { z as z8 } from "zod";
1065
1657
  function stepStateSchema(schema, steps) {
1066
- const stepSchema = z6.enum(steps);
1658
+ const stepSchema = z8.enum(steps);
1067
1659
  const maybeObject = schema;
1068
1660
  if (typeof maybeObject.extend === "function") {
1069
1661
  return maybeObject.extend({ step: stepSchema });
1070
1662
  }
1071
- return z6.intersection(schema, z6.object({ step: stepSchema }));
1663
+ return z8.intersection(schema, z8.object({ step: stepSchema }));
1072
1664
  }
1073
1665
  function unwrapStepInteractions(interactions) {
1074
1666
  if (!interactions) return void 0;
@@ -1332,7 +1924,8 @@ function defineGameDefinition(definition) {
1332
1924
  return definition;
1333
1925
  }
1334
1926
  function createGame(model) {
1335
- return createContractAuthoring(defineGameContract(model));
1927
+ const manifest = "literals" in model.manifest ? model.manifest : compileManifest(model.manifest);
1928
+ return createContractAuthoring(defineGameContract({ ...model, manifest }));
1336
1929
  }
1337
1930
 
1338
1931
  export {
@@ -1341,7 +1934,8 @@ export {
1341
1934
  normalizeCommandParams,
1342
1935
  defineInputs,
1343
1936
  many,
1937
+ compileManifest,
1344
1938
  defineGameDefinition,
1345
1939
  createGame
1346
1940
  };
1347
- //# sourceMappingURL=chunk-MYKS6MTR.js.map
1941
+ //# sourceMappingURL=chunk-ZZGN2ATS.js.map