@dreamboard-games/sdk 0.5.0-alpha.0 → 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 (113) hide show
  1. package/README.md +127 -0
  2. package/dist/browser-interaction.d.ts +22 -22
  3. package/dist/{chunk-VRRR6QZT.js → chunk-32PFKDV7.js} +170 -406
  4. package/dist/chunk-32PFKDV7.js.map +1 -0
  5. package/dist/{chunk-N33CGX2F.js → chunk-3BAD4VC2.js} +3 -3
  6. package/dist/{chunk-LMHCGCA6.js → chunk-3SKDNDPG.js} +2 -2
  7. package/dist/chunk-5YV2WHJ4.js +25 -0
  8. package/dist/chunk-5YV2WHJ4.js.map +1 -0
  9. package/dist/{chunk-VWTKGIYF.js → chunk-ANRB4XKA.js} +1 -1
  10. package/dist/chunk-ANRB4XKA.js.map +1 -0
  11. package/dist/{chunk-EOEA3I64.js → chunk-BI4G3PM2.js} +7 -7
  12. package/dist/chunk-BI4G3PM2.js.map +1 -0
  13. package/dist/{chunk-KRJPRYEA.js → chunk-EVCLTY4Q.js} +21 -8
  14. package/dist/chunk-EVCLTY4Q.js.map +1 -0
  15. package/dist/{chunk-DQS2EG5E.js → chunk-GDPKTBUR.js} +2 -2
  16. package/dist/{chunk-FL67RDID.js → chunk-H6VDGFL5.js} +128 -128
  17. package/dist/chunk-H6VDGFL5.js.map +1 -0
  18. package/dist/{chunk-6LMESVGT.js → chunk-LR3ZTWQF.js} +3 -3
  19. package/dist/chunk-LR3ZTWQF.js.map +1 -0
  20. package/dist/{chunk-TXELBVTG.js → chunk-PN5O6GG2.js} +2 -2
  21. package/dist/{chunk-533O7C4L.js → chunk-S2JEDVWH.js} +500 -430
  22. package/dist/chunk-S2JEDVWH.js.map +1 -0
  23. package/dist/{chunk-2GQIALJL.js → chunk-UGH54WZ2.js} +6 -2
  24. package/dist/chunk-UGH54WZ2.js.map +1 -0
  25. package/dist/chunk-VCDWP5VL.js +746 -0
  26. package/dist/chunk-VCDWP5VL.js.map +1 -0
  27. package/dist/{chunk-ZSTCUJKZ.js → chunk-Y75CFE77.js} +2 -6
  28. package/dist/chunk-Y75CFE77.js.map +1 -0
  29. package/dist/chunk-Z7QCREWI.js +3435 -0
  30. package/dist/chunk-Z7QCREWI.js.map +1 -0
  31. package/dist/chunk-ZZGN2ATS.js +1941 -0
  32. package/dist/chunk-ZZGN2ATS.js.map +1 -0
  33. package/dist/{components-CNAt5J1p.d.ts → components-gAbIz7hK.d.ts} +2 -18
  34. package/dist/{definitions-bZSBaPjj.d.ts → definitions-BgmV_GhC.d.ts} +3 -3
  35. package/dist/digest.d.ts +2 -2
  36. package/dist/game-CsZScpcn.d.ts +763 -0
  37. package/dist/{index-CR69MyWr.d.ts → index-CcT9Q7N7.d.ts} +1 -1
  38. package/dist/{index.d-Bw8AOcgp.d.ts → index.d-DjzoK7zn.d.ts} +67 -2
  39. package/dist/index.js +1 -2
  40. package/dist/package-set.js +1 -2
  41. package/dist/plugin-runtime-contract.d.ts +4 -4
  42. package/dist/plugin-runtime-contract.js +13 -15
  43. package/dist/{protocol-CVaSqPgX.d.ts → protocol-dYgafTYY.d.ts} +1 -7
  44. package/dist/reducer/advanced.d.ts +12 -11
  45. package/dist/reducer/advanced.js +10 -4
  46. package/dist/reducer-contract.d.ts +10 -2
  47. package/dist/reducer-contract.js +4 -4
  48. package/dist/reducer.d.ts +12 -689
  49. package/dist/reducer.js +19 -1293
  50. package/dist/reducer.js.map +1 -1
  51. package/dist/runtime/primitives.d.ts +4 -4
  52. package/dist/runtime/primitives.js +5 -5
  53. package/dist/runtime/runtime-api.d.ts +2 -2
  54. package/dist/runtime/workspace-contract.d.ts +50 -17
  55. package/dist/runtime/workspace-contract.js +15 -10
  56. package/dist/{runtime-C7Z2acNU.d.ts → runtime-RJ5orDJU.d.ts} +23 -30
  57. package/dist/{plugin-state-BRH3UiUp.d.ts → runtime-api-Bz5pwNU_.d.ts} +86 -4
  58. package/dist/runtime.d.ts +8 -8
  59. package/dist/runtime.js +19 -17
  60. package/dist/runtime.js.map +1 -1
  61. package/dist/schema.d.ts +2 -28
  62. package/dist/testing-compiler.d.ts +4 -4
  63. package/dist/testing-runtime.d.ts +7 -7
  64. package/dist/testing-runtime.js +6 -6
  65. package/dist/testing.d.ts +17 -17
  66. package/dist/testing.js +14 -14
  67. package/dist/{types-q1Guidm5.d.ts → types-DR7DoB1x.d.ts} +1 -1
  68. package/dist/{types-DN4O7kH_.d.ts → types-JWCYHmu7.d.ts} +2 -2
  69. package/dist/types.js +6 -18
  70. package/dist/types.js.map +1 -1
  71. package/dist/ui/components.d.ts +3 -4
  72. package/dist/ui/components.js +1 -5
  73. package/dist/{ui-contract-BC4JpysE.d.ts → ui-contract-GTUPkf8z.d.ts} +175 -176
  74. package/dist/ui.d.ts +4 -5
  75. package/dist/ui.js +2 -6
  76. package/dist/{views-D2Cfzr3h.d.ts → views-BpuWcOyN.d.ts} +101 -48
  77. package/package.json +3 -22
  78. package/dist/authoring/index.d.ts +0 -59
  79. package/dist/authoring/index.js +0 -24
  80. package/dist/authoring/index.js.map +0 -1
  81. package/dist/authoring-compiler.d.ts +0 -27
  82. package/dist/authoring-compiler.js +0 -11
  83. package/dist/authoring-compiler.js.map +0 -1
  84. package/dist/authoring-materialize-cli.d.ts +0 -1
  85. package/dist/authoring-materialize-cli.js +0 -45
  86. package/dist/authoring-materialize-cli.js.map +0 -1
  87. package/dist/chunk-2GQIALJL.js.map +0 -1
  88. package/dist/chunk-533O7C4L.js.map +0 -1
  89. package/dist/chunk-6LMESVGT.js.map +0 -1
  90. package/dist/chunk-EOEA3I64.js.map +0 -1
  91. package/dist/chunk-FL67RDID.js.map +0 -1
  92. package/dist/chunk-HIH6Y4FA.js +0 -7802
  93. package/dist/chunk-HIH6Y4FA.js.map +0 -1
  94. package/dist/chunk-HUK4234C.js +0 -166
  95. package/dist/chunk-HUK4234C.js.map +0 -1
  96. package/dist/chunk-KGV2EUNN.js +0 -532
  97. package/dist/chunk-KGV2EUNN.js.map +0 -1
  98. package/dist/chunk-KRJPRYEA.js.map +0 -1
  99. package/dist/chunk-KWHOFBDM.js +0 -9
  100. package/dist/chunk-KWHOFBDM.js.map +0 -1
  101. package/dist/chunk-VRRR6QZT.js.map +0 -1
  102. package/dist/chunk-VWTKGIYF.js.map +0 -1
  103. package/dist/chunk-XFMSLL3P.js +0 -637
  104. package/dist/chunk-XFMSLL3P.js.map +0 -1
  105. package/dist/chunk-ZSTCUJKZ.js.map +0 -1
  106. package/dist/codegen.d.ts +0 -941
  107. package/dist/codegen.js +0 -44
  108. package/dist/codegen.js.map +0 -1
  109. package/dist/runtime-api-CgPuEVeF.d.ts +0 -86
  110. /package/dist/{chunk-N33CGX2F.js.map → chunk-3BAD4VC2.js.map} +0 -0
  111. /package/dist/{chunk-LMHCGCA6.js.map → chunk-3SKDNDPG.js.map} +0 -0
  112. /package/dist/{chunk-DQS2EG5E.js.map → chunk-GDPKTBUR.js.map} +0 -0
  113. /package/dist/{chunk-TXELBVTG.js.map → chunk-PN5O6GG2.js.map} +0 -0
@@ -103,7 +103,7 @@ import {
103
103
  spendPlayerResourcesInPlace,
104
104
  transferPlayerResources,
105
105
  transferPlayerResourcesInPlace
106
- } from "./chunk-FL67RDID.js";
106
+ } from "./chunk-H6VDGFL5.js";
107
107
  import {
108
108
  RuntimeJsonSchema,
109
109
  assertJsonWithinLimits
@@ -112,7 +112,7 @@ import {
112
112
  REDUCER_CONTRACT_VERSION,
113
113
  builders_exports,
114
114
  zod_exports
115
- } from "./chunk-2GQIALJL.js";
115
+ } from "./chunk-UGH54WZ2.js";
116
116
 
117
117
  // src/reducer/diagnostics.ts
118
118
  var noopDiagnosticsSink = {
@@ -182,6 +182,121 @@ function summarizeDispatchTrace(trace) {
182
182
  });
183
183
  }
184
184
 
185
+ // src/reducer/table-queries.ts
186
+ function createTableQueries(table) {
187
+ return {
188
+ board: {
189
+ get: (boardId) => getBoard(table, boardId),
190
+ hex: (boardId) => getHexBoard(table, boardId),
191
+ square: (boardId) => getSquareBoard(table, boardId),
192
+ tiled: (boardId) => getTiledBoard(table, boardId),
193
+ space: (boardId, spaceId) => getSpace(table, boardId, spaceId),
194
+ hexSpace: (boardId, spaceId) => getHexSpace(table, boardId, spaceId),
195
+ squareSpace: (boardId, spaceId) => getSquareSpace(table, boardId, spaceId),
196
+ container: (boardId, containerId) => getContainer(table, boardId, containerId),
197
+ edge: (boardId, edgeId) => getEdge(table, boardId, edgeId),
198
+ vertex: (boardId, vertexId) => getVertex(table, boardId, vertexId),
199
+ byType: (typeId) => getBoardsByTypeId(table, typeId),
200
+ spacesByType: (boardId, typeId) => getSpacesByTypeId(table, boardId, typeId),
201
+ edgesByType: (boardId, typeId) => getEdgesByTypeId(table, boardId, typeId),
202
+ verticesByType: (boardId, typeId) => getVerticesByTypeId(table, boardId, typeId),
203
+ adjacentSpaces: (boardId, spaceId) => getAdjacentSpaces(table, boardId, spaceId),
204
+ relatedSpaces: (boardId, spaceId, relationTypeId) => getRelatedSpaces(table, boardId, spaceId, relationTypeId),
205
+ incidentEdges: (boardId, vertexId) => getIncidentEdges(table, boardId, vertexId),
206
+ incidentVertices: (boardId, edgeId) => getIncidentVertices(table, boardId, edgeId),
207
+ spaceEdges: (boardId, spaceId) => getSpaceEdges(table, boardId, spaceId),
208
+ spaceVertices: (boardId, spaceId) => getSpaceVertices(table, boardId, spaceId),
209
+ spaceDistance: (boardId, fromSpaceId, toSpaceId) => getSpaceDistance(table, boardId, fromSpaceId, toSpaceId),
210
+ hexSpaceAt: (boardId, q, r) => getHexSpaceAt(table, boardId, q, r),
211
+ squareSpaceAt: (boardId, row, col) => getSquareSpaceAt(table, boardId, row, col),
212
+ squareNeighbors: (boardId, spaceId, options) => getSquareNeighbors(table, boardId, spaceId, options),
213
+ squareDistance: (boardId, fromSpaceId, toSpaceId, options) => getSquareDistance(table, boardId, fromSpaceId, toSpaceId, options),
214
+ spaceOccupants: (boardId, spaceId) => getComponentsOnSpace(table, boardId, spaceId),
215
+ containerOccupants: (boardId, containerId) => getComponentsInContainer(table, boardId, containerId),
216
+ edgeOccupants: (boardId, edgeId) => getComponentsOnEdge(table, boardId, edgeId),
217
+ vertexOccupants: (boardId, vertexId) => getComponentsOnVertex(table, boardId, vertexId)
218
+ },
219
+ zone: {
220
+ sharedCards: (zoneId) => getSharedZoneCards(table, zoneId),
221
+ sharedCardCollection: (zoneId) => getSharedZoneCardCollection(table, zoneId),
222
+ allSharedCards: () => getAllSharedZoneCards(table),
223
+ playerCards: (playerId, zoneId) => getPlayerZoneCards(table, playerId, zoneId),
224
+ playerCardCollection: (playerId, zoneId) => getPlayerZoneCardCollection(table, playerId, zoneId),
225
+ allPlayerCards: (zoneId) => getAllPlayerZoneCards(table, zoneId)
226
+ },
227
+ card: {
228
+ get: (cardId) => getCard(table, cardId),
229
+ byIds: (cardIds) => getCardsById(table, cardIds),
230
+ owner: (cardId) => getCardOwner(table, cardId),
231
+ visibility: (cardId) => getCardVisibility(table, cardId)
232
+ },
233
+ slot: {
234
+ occupants: (host, slotId) => getSlotOccupants(table, host, slotId),
235
+ occupantsByHost: (host) => getSlotOccupantsByHost(table, host),
236
+ pieceOccupants: (hostId, slotId) => getSlotOccupants(table, { kind: "piece", id: hostId }, slotId),
237
+ pieceOccupantsByHost: (hostId) => getSlotOccupantsByHost(table, { kind: "piece", id: hostId }),
238
+ dieOccupants: (hostId, slotId) => getSlotOccupants(table, { kind: "die", id: hostId }, slotId),
239
+ dieOccupantsByHost: (hostId) => getSlotOccupantsByHost(table, { kind: "die", id: hostId })
240
+ },
241
+ player: {
242
+ order: () => getPlayerOrder(table),
243
+ nextInOrder: (playerId) => getNextPlayerInOrder(table, playerId),
244
+ resources: (playerId) => getPlayerResources(table, playerId),
245
+ resource: (playerId, resourceId) => getPlayerResourceAmount(table, playerId, resourceId),
246
+ resourceTotal: (playerId) => getPlayerResourceTotal(table, playerId),
247
+ canAfford: (playerId, amounts) => canAffordResources(table, playerId, amounts),
248
+ missingResources: (playerId, amounts) => getMissingResources(table, playerId, amounts)
249
+ },
250
+ component: {
251
+ data: (componentId) => table.cards[componentId] ?? table.pieces[componentId] ?? table.dice[componentId],
252
+ location: (componentId) => getComponentLocation(table, componentId),
253
+ deck: (componentId) => getComponentDeckLocation(table, componentId),
254
+ hand: (componentId) => getComponentHandLocation(table, componentId),
255
+ zone: (componentId) => getComponentZoneLocation(table, componentId),
256
+ space: (componentId) => getComponentSpaceLocation(table, componentId),
257
+ container: (componentId) => getComponentContainerLocation(table, componentId),
258
+ edge: (componentId) => getComponentEdgeLocation(table, componentId),
259
+ vertex: (componentId) => getComponentVertexLocation(table, componentId),
260
+ slot: (componentId) => getComponentSlotLocation(table, componentId)
261
+ }
262
+ };
263
+ }
264
+ function createStateQueries(state) {
265
+ return createTableQueries(
266
+ state.table
267
+ );
268
+ }
269
+
270
+ // src/reducer/derived.ts
271
+ function defineDerived() {
272
+ return (def) => def;
273
+ }
274
+ function createDerivedResolver(state, options = {}) {
275
+ const cache = /* @__PURE__ */ new Map();
276
+ const inflight = /* @__PURE__ */ new Set();
277
+ const q = options.q ?? createStateQueries(state);
278
+ const resolver = (def) => {
279
+ const typedDef = def;
280
+ if (cache.has(typedDef)) {
281
+ return cache.get(typedDef);
282
+ }
283
+ if (inflight.has(typedDef)) {
284
+ throw new Error(
285
+ `Cyclic derived: '${def.name ?? "<anonymous>"}' depends on itself.`
286
+ );
287
+ }
288
+ inflight.add(typedDef);
289
+ try {
290
+ const value = def.compute({ state, q, derived: resolver });
291
+ cache.set(typedDef, value);
292
+ return value;
293
+ } finally {
294
+ inflight.delete(typedDef);
295
+ }
296
+ };
297
+ return resolver;
298
+ }
299
+
185
300
  // src/reducer/ops.ts
186
301
  var reducerOpsInternal = /* @__PURE__ */ Symbol("dreamboard.reducerOpsInternal");
187
302
  function getReducerOpsInternal(ops) {
@@ -857,217 +972,6 @@ function createReducerOps() {
857
972
  return ops;
858
973
  }
859
974
 
860
- // src/reducer/table-queries.ts
861
- function createTableQueries(table) {
862
- return {
863
- board: {
864
- get: (boardId) => getBoard(table, boardId),
865
- hex: (boardId) => getHexBoard(table, boardId),
866
- square: (boardId) => getSquareBoard(table, boardId),
867
- tiled: (boardId) => getTiledBoard(table, boardId),
868
- space: (boardId, spaceId) => getSpace(table, boardId, spaceId),
869
- hexSpace: (boardId, spaceId) => getHexSpace(table, boardId, spaceId),
870
- squareSpace: (boardId, spaceId) => getSquareSpace(table, boardId, spaceId),
871
- container: (boardId, containerId) => getContainer(table, boardId, containerId),
872
- edge: (boardId, edgeId) => getEdge(table, boardId, edgeId),
873
- vertex: (boardId, vertexId) => getVertex(table, boardId, vertexId),
874
- byType: (typeId) => getBoardsByTypeId(table, typeId),
875
- spacesByType: (boardId, typeId) => getSpacesByTypeId(table, boardId, typeId),
876
- edgesByType: (boardId, typeId) => getEdgesByTypeId(table, boardId, typeId),
877
- verticesByType: (boardId, typeId) => getVerticesByTypeId(table, boardId, typeId),
878
- adjacentSpaces: (boardId, spaceId) => getAdjacentSpaces(table, boardId, spaceId),
879
- relatedSpaces: (boardId, spaceId, relationTypeId) => getRelatedSpaces(table, boardId, spaceId, relationTypeId),
880
- incidentEdges: (boardId, vertexId) => getIncidentEdges(table, boardId, vertexId),
881
- incidentVertices: (boardId, edgeId) => getIncidentVertices(table, boardId, edgeId),
882
- spaceEdges: (boardId, spaceId) => getSpaceEdges(table, boardId, spaceId),
883
- spaceVertices: (boardId, spaceId) => getSpaceVertices(table, boardId, spaceId),
884
- spaceDistance: (boardId, fromSpaceId, toSpaceId) => getSpaceDistance(table, boardId, fromSpaceId, toSpaceId),
885
- hexSpaceAt: (boardId, q, r) => getHexSpaceAt(table, boardId, q, r),
886
- squareSpaceAt: (boardId, row, col) => getSquareSpaceAt(table, boardId, row, col),
887
- squareNeighbors: (boardId, spaceId, options) => getSquareNeighbors(table, boardId, spaceId, options),
888
- squareDistance: (boardId, fromSpaceId, toSpaceId, options) => getSquareDistance(table, boardId, fromSpaceId, toSpaceId, options),
889
- spaceOccupants: (boardId, spaceId) => getComponentsOnSpace(table, boardId, spaceId),
890
- containerOccupants: (boardId, containerId) => getComponentsInContainer(table, boardId, containerId),
891
- edgeOccupants: (boardId, edgeId) => getComponentsOnEdge(table, boardId, edgeId),
892
- vertexOccupants: (boardId, vertexId) => getComponentsOnVertex(table, boardId, vertexId)
893
- },
894
- zone: {
895
- sharedCards: (zoneId) => getSharedZoneCards(table, zoneId),
896
- sharedCardCollection: (zoneId) => getSharedZoneCardCollection(table, zoneId),
897
- allSharedCards: () => getAllSharedZoneCards(table),
898
- playerCards: (playerId, zoneId) => getPlayerZoneCards(table, playerId, zoneId),
899
- playerCardCollection: (playerId, zoneId) => getPlayerZoneCardCollection(table, playerId, zoneId),
900
- allPlayerCards: (zoneId) => getAllPlayerZoneCards(table, zoneId)
901
- },
902
- card: {
903
- get: (cardId) => getCard(table, cardId),
904
- byIds: (cardIds) => getCardsById(table, cardIds),
905
- owner: (cardId) => getCardOwner(table, cardId),
906
- visibility: (cardId) => getCardVisibility(table, cardId)
907
- },
908
- slot: {
909
- occupants: (host, slotId) => getSlotOccupants(table, host, slotId),
910
- occupantsByHost: (host) => getSlotOccupantsByHost(table, host),
911
- pieceOccupants: (hostId, slotId) => getSlotOccupants(table, { kind: "piece", id: hostId }, slotId),
912
- pieceOccupantsByHost: (hostId) => getSlotOccupantsByHost(table, { kind: "piece", id: hostId }),
913
- dieOccupants: (hostId, slotId) => getSlotOccupants(table, { kind: "die", id: hostId }, slotId),
914
- dieOccupantsByHost: (hostId) => getSlotOccupantsByHost(table, { kind: "die", id: hostId })
915
- },
916
- player: {
917
- order: () => getPlayerOrder(table),
918
- nextInOrder: (playerId) => getNextPlayerInOrder(table, playerId),
919
- resources: (playerId) => getPlayerResources(table, playerId),
920
- resource: (playerId, resourceId) => getPlayerResourceAmount(table, playerId, resourceId),
921
- resourceTotal: (playerId) => getPlayerResourceTotal(table, playerId),
922
- canAfford: (playerId, amounts) => canAffordResources(table, playerId, amounts),
923
- missingResources: (playerId, amounts) => getMissingResources(table, playerId, amounts)
924
- },
925
- component: {
926
- data: (componentId) => table.cards[componentId] ?? table.pieces[componentId] ?? table.dice[componentId],
927
- location: (componentId) => getComponentLocation(table, componentId),
928
- deck: (componentId) => getComponentDeckLocation(table, componentId),
929
- hand: (componentId) => getComponentHandLocation(table, componentId),
930
- zone: (componentId) => getComponentZoneLocation(table, componentId),
931
- space: (componentId) => getComponentSpaceLocation(table, componentId),
932
- container: (componentId) => getComponentContainerLocation(table, componentId),
933
- edge: (componentId) => getComponentEdgeLocation(table, componentId),
934
- vertex: (componentId) => getComponentVertexLocation(table, componentId),
935
- slot: (componentId) => getComponentSlotLocation(table, componentId)
936
- }
937
- };
938
- }
939
- function createStateQueries(state) {
940
- return createTableQueries(
941
- state.table
942
- );
943
- }
944
-
945
- // src/reducer/transaction.ts
946
- var transactionContext = /* @__PURE__ */ Symbol("dreamboard.reducerTransactionContext");
947
- function getTransactionContext(host) {
948
- const context = host[transactionContext];
949
- if (!context) {
950
- throw new TypeError("Reducer transaction method called without a receiver");
951
- }
952
- return context;
953
- }
954
- function invalidate(context) {
955
- context.currentQueries = null;
956
- }
957
- function applyTransactionOp(context, op) {
958
- context.currentState = op(context.currentState);
959
- invalidate(context);
960
- return context.currentState;
961
- }
962
- function runInternal(context, key, args) {
963
- context.currentState = context.internalOps[key](context.currentState, ...args);
964
- invalidate(context);
965
- return context.currentState;
966
- }
967
- function createReducerTransactionSurface(ops) {
968
- const surface = {};
969
- const descriptors = {
970
- state: {
971
- enumerable: true,
972
- get() {
973
- return getTransactionContext(this).currentState;
974
- }
975
- },
976
- q: {
977
- enumerable: true,
978
- get() {
979
- const context = getTransactionContext(this);
980
- context.currentQueries ??= createStateQueries(context.currentState);
981
- return context.currentQueries;
982
- }
983
- },
984
- apply: {
985
- enumerable: true,
986
- get() {
987
- const context = getTransactionContext(this);
988
- context.applyMethod ??= (op) => applyTransactionOp(context, op);
989
- return context.applyMethod;
990
- }
991
- }
992
- };
993
- for (const key of Object.keys(ops)) {
994
- descriptors[String(key)] = {
995
- enumerable: true,
996
- get() {
997
- const context = getTransactionContext(this);
998
- const cacheKey = String(key);
999
- context.methodCache[cacheKey] ??= (...args) => runInternal(context, key, args);
1000
- return context.methodCache[cacheKey];
1001
- }
1002
- };
1003
- }
1004
- Object.defineProperties(surface, descriptors);
1005
- return surface;
1006
- }
1007
- function createReducerTransactionFromSurface(initialState, internalOps, surface) {
1008
- const transaction = Object.create(surface);
1009
- Object.defineProperty(transaction, transactionContext, {
1010
- value: {
1011
- currentState: {
1012
- ...initialState,
1013
- table: cloneRuntimeTable(initialState.table)
1014
- },
1015
- currentQueries: null,
1016
- internalOps,
1017
- methodCache: {}
1018
- }
1019
- });
1020
- return transaction;
1021
- }
1022
- function createReducerTransaction(initialState, ops = createReducerOps()) {
1023
- const internalOps = getReducerOpsInternal(ops);
1024
- const surface = createReducerTransactionSurface(ops);
1025
- return createReducerTransactionFromSurface(
1026
- initialState,
1027
- internalOps,
1028
- surface
1029
- );
1030
- }
1031
- function createReducerEdit(ops = createReducerOps()) {
1032
- const internalOps = getReducerOpsInternal(ops);
1033
- const surface = createReducerTransactionSurface(ops);
1034
- return (state) => createReducerTransactionFromSurface(
1035
- state,
1036
- internalOps,
1037
- surface
1038
- );
1039
- }
1040
-
1041
- // src/reducer/derived.ts
1042
- function defineDerived() {
1043
- return (def) => def;
1044
- }
1045
- function createDerivedResolver(state, options = {}) {
1046
- const cache = /* @__PURE__ */ new Map();
1047
- const inflight = /* @__PURE__ */ new Set();
1048
- const q = options.q ?? createStateQueries(state);
1049
- const resolver = (def) => {
1050
- const typedDef = def;
1051
- if (cache.has(typedDef)) {
1052
- return cache.get(typedDef);
1053
- }
1054
- if (inflight.has(typedDef)) {
1055
- throw new Error(
1056
- `Cyclic derived: '${def.name ?? "<anonymous>"}' depends on itself.`
1057
- );
1058
- }
1059
- inflight.add(typedDef);
1060
- try {
1061
- const value = def.compute({ state, q, derived: resolver });
1062
- cache.set(typedDef, value);
1063
- return value;
1064
- } finally {
1065
- inflight.delete(typedDef);
1066
- }
1067
- };
1068
- return resolver;
1069
- }
1070
-
1071
975
  // src/reducer/contract-fingerprint.ts
1072
976
  import { z } from "zod";
1073
977
  function contractFingerprint(source) {
@@ -1332,6 +1236,133 @@ function isStaleContractArtifactError(error) {
1332
1236
  return error instanceof StaleContractArtifactError || typeof error === "object" && error !== null && error.code === "STALE_CONTRACT_ARTIFACT";
1333
1237
  }
1334
1238
 
1239
+ // src/reducer/effects.ts
1240
+ function buildResume(effect, context) {
1241
+ if (!effect.__continuation) {
1242
+ return void 0;
1243
+ }
1244
+ return effect.__continuation(
1245
+ context ?? {}
1246
+ );
1247
+ }
1248
+ function invokeEffect(effect, options) {
1249
+ const continuation = buildResume(effect, options.context);
1250
+ if (effect.type === "rollDie") {
1251
+ return continuation === void 0 ? {
1252
+ kind: "engine.rollDie",
1253
+ dieId: options.dieId
1254
+ } : {
1255
+ kind: "engine.rollDie",
1256
+ dieId: options.dieId,
1257
+ continuation
1258
+ };
1259
+ }
1260
+ if (effect.type === "shuffleSharedZone") {
1261
+ return continuation === void 0 ? {
1262
+ kind: "engine.shuffleSharedZone",
1263
+ zoneId: options.zoneId
1264
+ } : {
1265
+ kind: "engine.shuffleSharedZone",
1266
+ zoneId: options.zoneId,
1267
+ continuation
1268
+ };
1269
+ }
1270
+ if (effect.type === "shufflePlayerZone") {
1271
+ return continuation === void 0 ? {
1272
+ kind: "engine.shufflePlayerZone",
1273
+ zoneId: options.zoneId,
1274
+ playerId: options.playerId
1275
+ } : {
1276
+ kind: "engine.shufflePlayerZone",
1277
+ zoneId: options.zoneId,
1278
+ playerId: options.playerId,
1279
+ continuation
1280
+ };
1281
+ }
1282
+ throw new Error(
1283
+ `fx.effect: unsupported effect type '${effect.type}'.`
1284
+ );
1285
+ }
1286
+ function createReducerFx() {
1287
+ const fx = {
1288
+ transition(to) {
1289
+ return { kind: "flow.transition", to };
1290
+ },
1291
+ effect(effect, options) {
1292
+ return invokeEffect(
1293
+ effect,
1294
+ options
1295
+ );
1296
+ }
1297
+ };
1298
+ return fx;
1299
+ }
1300
+
1301
+ // src/reducer/bundle/trusted/trusted-runtime-args.ts
1302
+ function fxForState() {
1303
+ return createReducerFx();
1304
+ }
1305
+ function buildContext(state, manifest) {
1306
+ return {
1307
+ currentPhase: state.flow.currentPhase,
1308
+ manifest,
1309
+ playerOrder: [...state.table.playerOrder],
1310
+ activePlayers: [...state.flow.activePlayers],
1311
+ runtime: publicRuntime(state.runtime),
1312
+ setup: state.runtime.setup ? {
1313
+ profileId: state.runtime.setup.profileId,
1314
+ optionValues: {
1315
+ ...state.runtime.setup.optionValues
1316
+ }
1317
+ } : null
1318
+ };
1319
+ }
1320
+ function publicRuntime(runtime) {
1321
+ const rest = { ...runtime };
1322
+ delete rest.rng;
1323
+ return rest;
1324
+ }
1325
+ var DISABLED_RANDOM_HELPERS = {
1326
+ integer() {
1327
+ throw new Error(
1328
+ "random helpers are only available in reducer mutation callbacks."
1329
+ );
1330
+ },
1331
+ subset() {
1332
+ throw new Error(
1333
+ "random helpers are only available in reducer mutation callbacks."
1334
+ );
1335
+ }
1336
+ };
1337
+ var implicitResultSymbol = /* @__PURE__ */ Symbol("dreamboard.implicitResult");
1338
+ function implicitResultOf(args) {
1339
+ return args[implicitResultSymbol]();
1340
+ }
1341
+ function buildRuntimeArgs(state, manifest, helpers, toDomainState2, extra, options = {}) {
1342
+ const domainState = toDomainState2(state);
1343
+ const q = options.q ?? createStateQueries(domainState);
1344
+ const args = {
1345
+ ...buildContext(state, manifest),
1346
+ ...helpers,
1347
+ fx: options.fx ?? fxForState(),
1348
+ q,
1349
+ derived: options.derived ?? createDerivedResolver(domainState, { q }),
1350
+ runtime: publicRuntime(state.runtime),
1351
+ random: options.random ?? DISABLED_RANDOM_HELPERS,
1352
+ ...extra
1353
+ };
1354
+ let transaction;
1355
+ Object.defineProperty(args, "tx", {
1356
+ enumerable: true,
1357
+ get: () => transaction ??= helpers.edit(domainState)
1358
+ });
1359
+ Object.defineProperty(args, implicitResultSymbol, {
1360
+ enumerable: false,
1361
+ value: () => transaction ? transaction.accept() : helpers.accept(domainState)
1362
+ });
1363
+ return args;
1364
+ }
1365
+
1335
1366
  // src/reducer/engine/runtime-instruction-engine.ts
1336
1367
  function createRuntimeInstructionEngine({
1337
1368
  reduce,
@@ -1874,34 +1905,186 @@ function isSimultaneousPhase(phase) {
1874
1905
  function simultaneousSubmitInteraction(phase) {
1875
1906
  return phase.submit;
1876
1907
  }
1877
- function resolvePromptToArray(value) {
1878
- if (value === void 0 || value === null) return [];
1879
- if (Array.isArray(value)) return value;
1880
- if (typeof value === "string") return [value];
1881
- return [];
1908
+ function resolvePromptToArray(value) {
1909
+ if (value === void 0 || value === null) return [];
1910
+ if (Array.isArray(value)) return value;
1911
+ if (typeof value === "string") return [value];
1912
+ return [];
1913
+ }
1914
+ function resolveSimultaneousActors(scope, state, phase, projection) {
1915
+ const selector = phase.actors ?? phase.actor;
1916
+ if (typeof selector === "function") {
1917
+ const selected = selector(
1918
+ scope.buildRuntimeArgs(
1919
+ state,
1920
+ {
1921
+ state: projection?.domainState ?? scope.toDomainState(state)
1922
+ },
1923
+ projection
1924
+ )
1925
+ );
1926
+ const resolved = resolvePromptToArray(selected);
1927
+ if (resolved.length > 0) {
1928
+ return resolved;
1929
+ }
1930
+ }
1931
+ const active = state.flow.activePlayers;
1932
+ if (active.length > 0) {
1933
+ return [...active];
1934
+ }
1935
+ return [...state.table.playerOrder];
1936
+ }
1937
+
1938
+ // src/reducer/transaction.ts
1939
+ var transactionContext = /* @__PURE__ */ Symbol("dreamboard.reducerTransactionContext");
1940
+ function createOutcomeMethods(context) {
1941
+ const fx = createReducerFx();
1942
+ const accept = () => ({
1943
+ type: "accept",
1944
+ state: context.currentState,
1945
+ instructions: [...context.instructions],
1946
+ events: [...context.events]
1947
+ });
1948
+ return {
1949
+ emit(...events) {
1950
+ context.events.push(...events);
1951
+ },
1952
+ schedule(...instructions) {
1953
+ context.instructions.push(...instructions);
1954
+ },
1955
+ effect(effect, options) {
1956
+ context.instructions.push(fx.effect(effect, options));
1957
+ },
1958
+ accept,
1959
+ transition(to) {
1960
+ const result = accept();
1961
+ return {
1962
+ ...result,
1963
+ instructions: [
1964
+ ...result.instructions ?? [],
1965
+ fx.transition(to)
1966
+ ]
1967
+ };
1968
+ },
1969
+ endGame(outcome, options) {
1970
+ const result = accept();
1971
+ return {
1972
+ ...result,
1973
+ instructions: options?.transition ? [
1974
+ ...result.instructions ?? [],
1975
+ fx.transition(options.transition)
1976
+ ] : result.instructions,
1977
+ terminal: outcome
1978
+ };
1979
+ },
1980
+ reject(errorCode, message) {
1981
+ return { type: "reject", errorCode, message };
1982
+ }
1983
+ };
1984
+ }
1985
+ function getTransactionContext(host) {
1986
+ const context = host[transactionContext];
1987
+ if (!context) {
1988
+ throw new TypeError("Reducer transaction method called without a receiver");
1989
+ }
1990
+ return context;
1991
+ }
1992
+ function invalidate(context) {
1993
+ context.currentQueries = null;
1994
+ }
1995
+ function applyTransactionOp(context, op) {
1996
+ context.currentState = op(context.currentState);
1997
+ invalidate(context);
1998
+ return context.currentState;
1999
+ }
2000
+ function runInternal(context, key, args) {
2001
+ context.currentState = context.internalOps[key](context.currentState, ...args);
2002
+ invalidate(context);
2003
+ return context.currentState;
1882
2004
  }
1883
- function resolveSimultaneousActors(scope, state, phase, projection) {
1884
- const selector = phase.actors ?? phase.actor;
1885
- if (typeof selector === "function") {
1886
- const selected = selector(
1887
- scope.buildRuntimeArgs(
1888
- state,
1889
- {
1890
- state: projection?.domainState ?? scope.toDomainState(state)
1891
- },
1892
- projection
1893
- )
1894
- );
1895
- const resolved = resolvePromptToArray(selected);
1896
- if (resolved.length > 0) {
1897
- return resolved;
2005
+ function createReducerTransactionSurface(ops) {
2006
+ const surface = {};
2007
+ const descriptors = {
2008
+ state: {
2009
+ enumerable: true,
2010
+ get() {
2011
+ return getTransactionContext(this).currentState;
2012
+ }
2013
+ },
2014
+ q: {
2015
+ enumerable: true,
2016
+ get() {
2017
+ const context = getTransactionContext(this);
2018
+ context.currentQueries ??= createStateQueries(context.currentState);
2019
+ return context.currentQueries;
2020
+ }
2021
+ },
2022
+ apply: {
2023
+ enumerable: true,
2024
+ get() {
2025
+ const context = getTransactionContext(this);
2026
+ context.applyMethod ??= (op) => applyTransactionOp(context, op);
2027
+ return context.applyMethod;
2028
+ }
1898
2029
  }
2030
+ };
2031
+ for (const key of [
2032
+ "emit",
2033
+ "schedule",
2034
+ "effect",
2035
+ "accept",
2036
+ "transition",
2037
+ "endGame",
2038
+ "reject"
2039
+ ]) {
2040
+ descriptors[key] = {
2041
+ enumerable: true,
2042
+ get() {
2043
+ const context = getTransactionContext(this);
2044
+ context.outcome ??= createOutcomeMethods(context);
2045
+ return context.outcome[key];
2046
+ }
2047
+ };
1899
2048
  }
1900
- const active = state.flow.activePlayers;
1901
- if (active.length > 0) {
1902
- return [...active];
2049
+ for (const key of Object.keys(ops)) {
2050
+ descriptors[String(key)] = {
2051
+ enumerable: true,
2052
+ get() {
2053
+ const context = getTransactionContext(this);
2054
+ const cacheKey = String(key);
2055
+ context.methodCache[cacheKey] ??= (...args) => runInternal(context, key, args);
2056
+ return context.methodCache[cacheKey];
2057
+ }
2058
+ };
1903
2059
  }
1904
- return [...state.table.playerOrder];
2060
+ Object.defineProperties(surface, descriptors);
2061
+ return surface;
2062
+ }
2063
+ function createReducerTransactionFromSurface(initialState, internalOps, surface) {
2064
+ const transaction = Object.create(surface);
2065
+ Object.defineProperty(transaction, transactionContext, {
2066
+ value: {
2067
+ currentState: {
2068
+ ...initialState,
2069
+ table: cloneRuntimeTable(initialState.table)
2070
+ },
2071
+ currentQueries: null,
2072
+ internalOps,
2073
+ methodCache: {},
2074
+ events: [],
2075
+ instructions: []
2076
+ }
2077
+ });
2078
+ return transaction;
2079
+ }
2080
+ function createReducerEdit(ops = createReducerOps()) {
2081
+ const internalOps = getReducerOpsInternal(ops);
2082
+ const surface = createReducerTransactionSurface(ops);
2083
+ return (state) => createReducerTransactionFromSurface(
2084
+ state,
2085
+ internalOps,
2086
+ surface
2087
+ );
1905
2088
  }
1906
2089
 
1907
2090
  // src/reducer/bundle/trusted/runtime-registry.ts
@@ -1939,119 +2122,6 @@ function collectTrustedRuntimeRegistry(definition) {
1939
2122
  };
1940
2123
  }
1941
2124
 
1942
- // src/reducer/effects.ts
1943
- function buildResume(effect, context) {
1944
- if (!effect.__continuation) {
1945
- return void 0;
1946
- }
1947
- return effect.__continuation(
1948
- context ?? {}
1949
- );
1950
- }
1951
- function invokeEffect(effect, options) {
1952
- const continuation = buildResume(effect, options.context);
1953
- if (effect.type === "rollDie") {
1954
- return continuation === void 0 ? {
1955
- kind: "engine.rollDie",
1956
- dieId: options.dieId
1957
- } : {
1958
- kind: "engine.rollDie",
1959
- dieId: options.dieId,
1960
- continuation
1961
- };
1962
- }
1963
- if (effect.type === "shuffleSharedZone") {
1964
- return continuation === void 0 ? {
1965
- kind: "engine.shuffleSharedZone",
1966
- zoneId: options.zoneId
1967
- } : {
1968
- kind: "engine.shuffleSharedZone",
1969
- zoneId: options.zoneId,
1970
- continuation
1971
- };
1972
- }
1973
- if (effect.type === "shufflePlayerZone") {
1974
- return continuation === void 0 ? {
1975
- kind: "engine.shufflePlayerZone",
1976
- zoneId: options.zoneId,
1977
- playerId: options.playerId
1978
- } : {
1979
- kind: "engine.shufflePlayerZone",
1980
- zoneId: options.zoneId,
1981
- playerId: options.playerId,
1982
- continuation
1983
- };
1984
- }
1985
- throw new Error(
1986
- `fx.effect: unsupported effect type '${effect.type}'.`
1987
- );
1988
- }
1989
- function createReducerFx() {
1990
- const fx = {
1991
- transition(to) {
1992
- return { kind: "flow.transition", to };
1993
- },
1994
- effect(effect, options) {
1995
- return invokeEffect(
1996
- effect,
1997
- options
1998
- );
1999
- }
2000
- };
2001
- return fx;
2002
- }
2003
-
2004
- // src/reducer/bundle/trusted/trusted-runtime-args.ts
2005
- function fxForState() {
2006
- return createReducerFx();
2007
- }
2008
- function buildContext(state, manifest) {
2009
- return {
2010
- currentPhase: state.flow.currentPhase,
2011
- manifest,
2012
- playerOrder: [...state.table.playerOrder],
2013
- activePlayers: [...state.flow.activePlayers],
2014
- runtime: publicRuntime(state.runtime),
2015
- setup: state.runtime.setup ? {
2016
- profileId: state.runtime.setup.profileId,
2017
- optionValues: {
2018
- ...state.runtime.setup.optionValues
2019
- }
2020
- } : null
2021
- };
2022
- }
2023
- function publicRuntime(runtime) {
2024
- const rest = { ...runtime };
2025
- delete rest.rng;
2026
- return rest;
2027
- }
2028
- var DISABLED_RANDOM_HELPERS = {
2029
- integer() {
2030
- throw new Error(
2031
- "random helpers are only available in reducer mutation callbacks."
2032
- );
2033
- },
2034
- subset() {
2035
- throw new Error(
2036
- "random helpers are only available in reducer mutation callbacks."
2037
- );
2038
- }
2039
- };
2040
- function buildRuntimeArgs(state, manifest, helpers, toDomainState2, extra, options = {}) {
2041
- const domainState = toDomainState2(state);
2042
- const q = options.q ?? createStateQueries(domainState);
2043
- return {
2044
- ...buildContext(state, manifest),
2045
- ...helpers,
2046
- fx: options.fx ?? fxForState(),
2047
- q,
2048
- derived: options.derived ?? createDerivedResolver(domainState, { q }),
2049
- runtime: publicRuntime(state.runtime),
2050
- random: options.random ?? DISABLED_RANDOM_HELPERS,
2051
- ...extra
2052
- };
2053
- }
2054
-
2055
2125
  // src/reducer/bundle/trusted/trusted-runtime-result.ts
2056
2126
  var OUTCOME_STRING_LIMIT = 256;
2057
2127
  var OUTCOME_LABEL_LIMIT = 128;
@@ -2303,9 +2373,17 @@ function rejectResult(errorCode, message) {
2303
2373
  message
2304
2374
  };
2305
2375
  }
2306
- function normalizeResult(result, fallbackState) {
2376
+ function normalizeResult(result, implicitResult) {
2307
2377
  if (result === void 0 || result === null) {
2308
- return acceptResult(fallbackState);
2378
+ result = implicitResult();
2379
+ }
2380
+ if (result.type === "accept") {
2381
+ return {
2382
+ ...result,
2383
+ instructions: [...result.instructions ?? []],
2384
+ events: normalizeGameEvents(result.events),
2385
+ ...result.terminal ? { terminal: normalizeGameOutcome(result.state, result.terminal) } : {}
2386
+ };
2309
2387
  }
2310
2388
  return result;
2311
2389
  }
@@ -2511,22 +2589,21 @@ function createTrustedInstructionRunner(scope, interactions, lifecycle) {
2511
2589
  return rejectResult("invalid-action-params", parsed.message);
2512
2590
  }
2513
2591
  const random = createMutableRandomHelpers(state.runtime.rng);
2592
+ const reduceArgs = scope.buildRuntimeArgs(
2593
+ state,
2594
+ {
2595
+ ...ctx,
2596
+ state: scope.toDomainState(state),
2597
+ input: {
2598
+ playerId: input.playerId,
2599
+ params: parsed.params
2600
+ }
2601
+ },
2602
+ { random: random.random }
2603
+ );
2514
2604
  const result = normalizeResult(
2515
- interaction.reduce(
2516
- scope.buildRuntimeArgs(
2517
- state,
2518
- {
2519
- ...ctx,
2520
- state: scope.toDomainState(state),
2521
- input: {
2522
- playerId: input.playerId,
2523
- params: parsed.params
2524
- }
2525
- },
2526
- { random: random.random }
2527
- )
2528
- ),
2529
- scope.toDomainState(state)
2605
+ interaction.reduce(reduceArgs),
2606
+ () => implicitResultOf(reduceArgs)
2530
2607
  );
2531
2608
  return result.type === "accept" ? {
2532
2609
  ...result,
@@ -2543,24 +2620,23 @@ function createTrustedInstructionRunner(scope, interactions, lifecycle) {
2543
2620
  );
2544
2621
  }
2545
2622
  const random = createMutableRandomHelpers(state.runtime.rng);
2623
+ const continuationArgs = scope.buildRuntimeArgs(
2624
+ state,
2625
+ {
2626
+ ...ctx,
2627
+ state: scope.toDomainState(state),
2628
+ input: {
2629
+ source: "effect",
2630
+ effectKind: input.effectKind,
2631
+ data: input.resumeData,
2632
+ response: input.response
2633
+ }
2634
+ },
2635
+ { random: random.random }
2636
+ );
2546
2637
  const result = normalizeResult(
2547
- continuation.reduce(
2548
- scope.buildRuntimeArgs(
2549
- state,
2550
- {
2551
- ...ctx,
2552
- state: scope.toDomainState(state),
2553
- input: {
2554
- source: "effect",
2555
- effectKind: input.effectKind,
2556
- data: input.resumeData,
2557
- response: input.response
2558
- }
2559
- },
2560
- { random: random.random }
2561
- )
2562
- ),
2563
- scope.toDomainState(state)
2638
+ continuation.reduce(continuationArgs),
2639
+ () => implicitResultOf(continuationArgs)
2564
2640
  );
2565
2641
  return result.type === "accept" ? {
2566
2642
  ...result,
@@ -2705,20 +2781,19 @@ function createTrustedInstructionRunner(scope, interactions, lifecycle) {
2705
2781
  ])
2706
2782
  );
2707
2783
  const random = createMutableRandomHelpers(stateWithSubmission.runtime.rng);
2784
+ const resolveArgs = scope.buildRuntimeArgs(
2785
+ stateWithSubmission,
2786
+ {
2787
+ state: scope.toDomainState(stateWithSubmission),
2788
+ submissions: resolvedSubmissions,
2789
+ submittedPlayerIds: [...actors],
2790
+ waitingPlayerIds: []
2791
+ },
2792
+ { random: random.random }
2793
+ );
2708
2794
  const resolved = normalizeResult(
2709
- resolve(
2710
- scope.buildRuntimeArgs(
2711
- stateWithSubmission,
2712
- {
2713
- state: scope.toDomainState(stateWithSubmission),
2714
- submissions: resolvedSubmissions,
2715
- submittedPlayerIds: [...actors],
2716
- waitingPlayerIds: []
2717
- },
2718
- { random: random.random }
2719
- )
2720
- ),
2721
- scope.toDomainState(stateWithSubmission)
2795
+ resolve(resolveArgs),
2796
+ () => implicitResultOf(resolveArgs)
2722
2797
  );
2723
2798
  if (resolved.type === "reject") {
2724
2799
  return resolved;
@@ -3142,15 +3217,15 @@ function createInteractionAuthorization(scope) {
3142
3217
  };
3143
3218
  }
3144
3219
  if (interaction.actor) {
3145
- const resolved = interaction.actor({
3146
- ...scope.buildRuntimeArgs(
3220
+ const resolved = interaction.actor(
3221
+ scope.buildRuntimeArgs(
3147
3222
  state,
3148
3223
  {
3149
3224
  state: projection?.domainState ?? scope.toDomainState(state)
3150
3225
  },
3151
3226
  projection
3152
3227
  )
3153
- });
3228
+ );
3154
3229
  return {
3155
3230
  mode: "actors",
3156
3231
  actors: resolvePromptToSet(resolved)
@@ -3166,15 +3241,15 @@ function createInteractionAuthorization(scope) {
3166
3241
  };
3167
3242
  }
3168
3243
  if (phase.actor) {
3169
- const resolved = phase.actor({
3170
- ...scope.buildRuntimeArgs(
3244
+ const resolved = phase.actor(
3245
+ scope.buildRuntimeArgs(
3171
3246
  state,
3172
3247
  {
3173
3248
  state: projection?.domainState ?? scope.toDomainState(state)
3174
3249
  },
3175
3250
  projection
3176
3251
  )
3177
- });
3252
+ );
3178
3253
  return {
3179
3254
  mode: "actors",
3180
3255
  actors: resolvePromptToSet(resolved)
@@ -5021,18 +5096,17 @@ function createLifecycleRunner(scope, interactions) {
5021
5096
  const events = [];
5022
5097
  if (phase.enter) {
5023
5098
  const random = createMutableRandomHelpers(workingState.runtime.rng);
5099
+ const enterArgs = scope.buildRuntimeArgs(
5100
+ workingState,
5101
+ {
5102
+ event,
5103
+ state: scope.toDomainState(workingState)
5104
+ },
5105
+ { random: random.random }
5106
+ );
5024
5107
  const entered = normalizeResult(
5025
- phase.enter(
5026
- scope.buildRuntimeArgs(
5027
- workingState,
5028
- {
5029
- event,
5030
- state: scope.toDomainState(workingState)
5031
- },
5032
- { random: random.random }
5033
- )
5034
- ),
5035
- scope.toDomainState(workingState)
5108
+ phase.enter(enterArgs),
5109
+ () => implicitResultOf(enterArgs)
5036
5110
  );
5037
5111
  if (entered.type === "reject") {
5038
5112
  throw new Error(
@@ -5051,18 +5125,17 @@ function createLifecycleRunner(scope, interactions) {
5051
5125
  const activeStage = interactions.resolveActiveStage(nextState, phaseName);
5052
5126
  if (activeStage?.stage.onEnter) {
5053
5127
  const random = createMutableRandomHelpers(nextState.runtime.rng);
5128
+ const stageArgs = scope.buildRuntimeArgs(
5129
+ nextState,
5130
+ {
5131
+ event,
5132
+ state: scope.toDomainState(nextState)
5133
+ },
5134
+ { random: random.random }
5135
+ );
5054
5136
  const stageEntered = normalizeResult(
5055
- activeStage.stage.onEnter(
5056
- scope.buildRuntimeArgs(
5057
- nextState,
5058
- {
5059
- event,
5060
- state: scope.toDomainState(nextState)
5061
- },
5062
- { random: random.random }
5063
- )
5064
- ),
5065
- scope.toDomainState(nextState)
5137
+ activeStage.stage.onEnter(stageArgs),
5138
+ () => implicitResultOf(stageArgs)
5066
5139
  );
5067
5140
  if (stageEntered.type === "reject") {
5068
5141
  throw new Error(
@@ -5713,7 +5786,6 @@ function createProjectionBuilder(scope, interactions) {
5713
5786
  schedulerFlow: resolveSchedulerFlowFor(state, projection),
5714
5787
  ...projectionMode === "full" ? { sharedView } : {},
5715
5788
  guidance: resolveGuidanceFor(combinedState),
5716
- recentEvents: [],
5717
5789
  interactionsByRef: registry.entries(),
5718
5790
  seats
5719
5791
  },
@@ -7078,13 +7150,11 @@ function createReducerBundle(definition, options = {}) {
7078
7150
 
7079
7151
  export {
7080
7152
  noopDiagnosticsSink,
7081
- createReducerOps,
7082
7153
  createTableQueries,
7083
7154
  createStateQueries,
7084
- createReducerTransaction,
7085
- createReducerEdit,
7086
7155
  defineDerived,
7087
7156
  createDerivedResolver,
7157
+ createReducerOps,
7088
7158
  interactionDomainEligibleCount,
7089
7159
  contractFingerprint,
7090
7160
  StaleContractArtifactError,
@@ -7092,4 +7162,4 @@ export {
7092
7162
  createReducerTestingBundle,
7093
7163
  createReducerBundle
7094
7164
  };
7095
- //# sourceMappingURL=chunk-533O7C4L.js.map
7165
+ //# sourceMappingURL=chunk-S2JEDVWH.js.map