@dreamboard-games/sdk 0.5.0-alpha.23 → 0.5.0-alpha.25

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -291,7 +291,9 @@ phase entry and returned transitions.
291
291
 
292
292
  Mutation callbacks use `tx.roll(dieId)`, `tx.shuffle({ zone: { zoneId, hostId } })`,
293
293
  `tx.deal({ from, to, count })` and
294
- `tx.flipCard({ cardId, faceUp })` directly. Return
294
+ `tx.flipCard({ cardId, faceUp })` directly. Like events, the zones the latest
295
+ accepted operation shuffled are recorded in the runtime state; every seat that
296
+ sees such a zone learns that it was shuffled, never its new order. Return
295
297
  `tx.transition(phaseName)` to enter a phase, including reentering the current
296
298
  phase. An unreturned outcome schedules no work. Entry chains are bounded to
297
299
  1,000 entries per dispatch. `tx.endGame(outcome, { transition })` enters the
@@ -364,7 +366,8 @@ same explicit params as `submit(params)`, retaining pending and connection gates
364
366
  `handFan` adds a focused, readable card with configurable presets and timing,
365
367
  and
366
368
  `originsFeature` adds `card.getOrigin()` so a newly shown card can animate from
367
- the zone or player it came from.
369
+ the zone or player it came from, and `zone.getShuffle()` so a shuffled pile can
370
+ riffle.
368
371
 
369
372
  ## Local hand sorting
370
373
 
@@ -471,9 +474,11 @@ also be pure. `game.shortcuts.getHints(target, activity)` returns only
471
474
  currently usable, unambiguous keys with their labels and `kind`. Interaction
472
475
  hints also carry their typed interaction name; local hints do not. Both variants
473
476
  share key collision handling. Headless callers supply local focus explicitly as
474
- `activity: { focusedTarget, pointerActive }`; omitting activity admits only
475
- interaction bindings. `useShortcutHints(target)` reads those hints reactively
476
- and returns no hints when the feature is absent. The mounted
477
+ `activity: { focusedTarget, pointerActive, touch }`; omitting activity admits
478
+ only interaction bindings. Hints are empty while `touch` is true. The mounted
479
+ hooks set it when the latest press was a finger and clear it on the next key or
480
+ mouse press; the keys themselves keep working. `useShortcutHints(target)` reads
481
+ those hints reactively and returns no hints when the feature is absent. The mounted
477
482
  `useGameShortcuts` hook returns `{ target, hints }` for a reserved help/status
478
483
  area. Rejected actions and transport failures use the binding's existing
479
484
  `onError` handler; callbacks from an old source, seat, or unmounted child are
@@ -1,4 +1,4 @@
1
- import { f as BoardEdgeId, n as BoardVertexId } from './extract-CwJWDrSD.js';
1
+ import { f as BoardEdgeId, n as BoardVertexId } from './extract-Bi6_tzUr.js';
2
2
 
3
3
  declare function boardEdgeId<BoardId extends string>(layout: "hex" | "square", boardId: BoardId, latticeId: string): BoardEdgeId<BoardId>;
4
4
  declare function boardVertexId<BoardId extends string>(layout: "hex" | "square", boardId: BoardId, latticeId: string): BoardVertexId<BoardId>;
@@ -5,10 +5,11 @@ import {
5
5
  ReducerSessionStateSchema,
6
6
  ReferenceBasisSchema,
7
7
  RngDrawSchema,
8
+ ShuffledZoneSchema,
8
9
  boardSpaceHostId,
9
10
  isCardReferenceNamespace,
10
11
  parseBoardSpaceHostId
11
- } from "./chunk-U6R7FAH4.js";
12
+ } from "./chunk-IEMZ26FI.js";
12
13
  import {
13
14
  AuthoredTileDisclosureSchema,
14
15
  BoardProjectionSchema,
@@ -2191,7 +2192,8 @@ function createIngressRuntimeCodec(definition) {
2191
2192
  lastTransition: z7.object({
2192
2193
  from: phaseNameSchema,
2193
2194
  to: phaseNameSchema
2194
- }).nullable()
2195
+ }).nullable(),
2196
+ shuffledZones: z7.array(ShuffledZoneSchema).min(1).optional()
2195
2197
  });
2196
2198
  const parseRuntimeInput = createRuntimeInputParser(playerIdSchema);
2197
2199
  return {
@@ -2657,7 +2659,8 @@ function finishReducerTransaction(tx) {
2657
2659
  return context.disposition.type === "reject" ? context.disposition : {
2658
2660
  ...context.disposition,
2659
2661
  state: context.currentState,
2660
- events: [...context.events]
2662
+ events: [...context.events],
2663
+ shuffledZones: [...context.shuffledZones]
2661
2664
  };
2662
2665
  }
2663
2666
  function getTransactionContext(host) {
@@ -2744,7 +2747,7 @@ function createReducerTransactionSurface() {
2744
2747
  const context = getTransactionContext(this);
2745
2748
  return context.shuffleMethod ??= (args) => {
2746
2749
  const table = context.currentState.table;
2747
- const { ids, definition } = resolveZone(
2750
+ const { ref, ids, definition } = resolveZone(
2748
2751
  table,
2749
2752
  context.definitions,
2750
2753
  args.zone
@@ -2756,6 +2759,7 @@ function createReducerTransactionSurface() {
2756
2759
  if (shuffled.length !== ids.length || new Set(shuffled).size !== ids.length || shuffled.some((id2) => !ids.includes(id2)))
2757
2760
  throw new Error("Shuffle must preserve zone membership.");
2758
2761
  ids.splice(0, ids.length, ...shuffled);
2762
+ context.shuffledZones.push(ref);
2759
2763
  invalidate(context);
2760
2764
  };
2761
2765
  }
@@ -2774,6 +2778,7 @@ function createReducerTransactionFromSurface(initialState, surface, random, defi
2774
2778
  currentQueries: null,
2775
2779
  methodCache: {},
2776
2780
  events: [],
2781
+ shuffledZones: [],
2777
2782
  disposition: { type: "accept" },
2778
2783
  random,
2779
2784
  definitions
@@ -5262,6 +5267,7 @@ function createLifecycleRunner(scope) {
5262
5267
  const consumptions = [];
5263
5268
  let terminal;
5264
5269
  const events = [];
5270
+ let shuffledZones = [];
5265
5271
  if (phase.enter) {
5266
5272
  const random = createMutableRandomHelpers(workingState.runtime.rng);
5267
5273
  const enterArgs = scope.buildRuntimeArgs(
@@ -5285,6 +5291,7 @@ function createLifecycleRunner(scope) {
5285
5291
  };
5286
5292
  terminal ??= entered.terminal;
5287
5293
  events.push(...entered.events ?? []);
5294
+ shuffledZones = entered.shuffledZones ?? [];
5288
5295
  consumptions.push(...random.consumptions());
5289
5296
  transition = entered.transition;
5290
5297
  }
@@ -5293,7 +5300,8 @@ function createLifecycleRunner(scope) {
5293
5300
  transition,
5294
5301
  consumptions,
5295
5302
  ...terminal ? { terminal } : {},
5296
- events
5303
+ events,
5304
+ shuffledZones
5297
5305
  };
5298
5306
  }
5299
5307
  function initializePhaseResult(state, phaseName) {
@@ -6262,6 +6270,7 @@ function createReducerExecutor(scope, interactions, lifecycle) {
6262
6270
  ...resolved.transition ? { transition: resolved.transition } : {},
6263
6271
  ...resolved.terminal ? { terminal: resolved.terminal } : {},
6264
6272
  events: resolved.events ?? [],
6273
+ shuffledZones: resolved.shuffledZones ?? [],
6265
6274
  trace: rngTrace(random.consumptions())
6266
6275
  };
6267
6276
  }
@@ -6298,6 +6307,7 @@ function createReducerExecutor(scope, interactions, lifecycle) {
6298
6307
  ...result.transition ? { transition: result.transition } : {},
6299
6308
  ...result.terminal ? { terminal: result.terminal } : {},
6300
6309
  events: result.events ?? [],
6310
+ shuffledZones: result.shuffledZones ?? [],
6301
6311
  trace: rngTrace([
6302
6312
  ...sampled.consumptions,
6303
6313
  ...result.rngConsumptions ?? []
@@ -6314,6 +6324,7 @@ function createReducerExecutor(scope, interactions, lifecycle) {
6314
6324
  let transition = initial.transition;
6315
6325
  let terminal = initial.terminal;
6316
6326
  const events = [...initial.events ?? []];
6327
+ const shuffledZones = [...initial.shuffledZones ?? []];
6317
6328
  const trace = [...initial.trace ?? []];
6318
6329
  while (transition !== void 0) {
6319
6330
  if (entries >= MAX_PHASE_ENTRIES) {
@@ -6333,6 +6344,7 @@ function createReducerExecutor(scope, interactions, lifecycle) {
6333
6344
  trace.push(...rngTrace(entered.consumptions));
6334
6345
  state = entered.state;
6335
6346
  events.push(...entered.events);
6347
+ shuffledZones.push(...entered.shuffledZones);
6336
6348
  terminal ??= entered.terminal;
6337
6349
  if (finalEntry && entered.transition !== void 0) {
6338
6350
  throw new Error(
@@ -6343,15 +6355,20 @@ function createReducerExecutor(scope, interactions, lifecycle) {
6343
6355
  }
6344
6356
  const committedEvents = normalizeGameEvents(events);
6345
6357
  assertGameEventReferences(committedEvents, state.table);
6358
+ const runtime = { ...state.runtime, events: committedEvents };
6359
+ delete runtime.shuffledZones;
6360
+ const committedShuffles = [
6361
+ ...new Map(
6362
+ shuffledZones.map((zone) => [
6363
+ JSON.stringify([zone.zoneId, zone.hostId]),
6364
+ zone
6365
+ ])
6366
+ ).values()
6367
+ ];
6368
+ if (committedShuffles.length) runtime.shuffledZones = committedShuffles;
6346
6369
  return {
6347
6370
  type: "accept",
6348
- state: reconcilePending(
6349
- {
6350
- ...state,
6351
- runtime: { ...state.runtime, events: committedEvents }
6352
- },
6353
- referenceBasis
6354
- ),
6371
+ state: reconcilePending({ ...state, runtime }, referenceBasis),
6355
6372
  events: committedEvents,
6356
6373
  trace,
6357
6374
  ...terminal ? { terminal } : {}
@@ -6549,8 +6566,10 @@ function createProjectionBuilder(scope, interactions) {
6549
6566
  scope.manifest
6550
6567
  );
6551
6568
  const result = {};
6569
+ const shuffledZones = combinedState.runtime.shuffledZones ?? [];
6552
6570
  for (const {
6553
6571
  zoneId,
6572
+ hostId,
6554
6573
  seatHostId,
6555
6574
  componentIds,
6556
6575
  tiles
@@ -6619,7 +6638,10 @@ function createProjectionBuilder(scope, interactions) {
6619
6638
  cardIds,
6620
6639
  cardViewsById,
6621
6640
  cardBacksById,
6622
- playableByCardId
6641
+ playableByCardId,
6642
+ ...shuffledZones.some(
6643
+ (zone) => zone.zoneId === zoneId && zone.hostId === hostId
6644
+ ) ? { shuffled: true } : {}
6623
6645
  };
6624
6646
  }
6625
6647
  return result;
@@ -7200,4 +7222,4 @@ export {
7200
7222
  createProjectionBuilder,
7201
7223
  createReducerBundle
7202
7224
  };
7203
- //# sourceMappingURL=chunk-UUJSLFIJ.js.map
7225
+ //# sourceMappingURL=chunk-63GWNBZX.js.map