@dreamboard-games/sdk 0.5.0-alpha.28 → 0.5.0-alpha.29

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.
@@ -20,7 +20,7 @@ import {
20
20
 
21
21
  // src/shared/protocol/protocol.ts
22
22
  var DREAMBOARD_PLUGIN_PROTOCOL = "dreamboard-plugin";
23
- var DREAMBOARD_PLUGIN_PROTOCOL_VERSION = 10;
23
+ var DREAMBOARD_PLUGIN_PROTOCOL_VERSION = 11;
24
24
 
25
25
  // src/shared/protocol/schema.ts
26
26
  import * as z from "zod";
@@ -71,6 +71,8 @@ var ProjectedViewSchema = z.record(z.string(), RuntimeJsonSchema).superRefine((v
71
71
  }
72
72
  });
73
73
  var SeatFrameSchema = z.object({
74
+ players: z.array(PlayerIdSchema),
75
+ causedBy: z.string().min(1).optional(),
74
76
  events: z.array(GameEventSchema).max(32),
75
77
  view: ProjectedViewSchema.nullable(),
76
78
  flow: z.object({
@@ -87,20 +89,13 @@ var SeatFrameSchema = z.object({
87
89
  var PluginGameplayFrameSchema = SeatFrameSchema.extend({
88
90
  basis: GameplayBasisSchema
89
91
  });
90
- var InteractionResultSchema = z.discriminatedUnion("accepted", [
91
- z.object({
92
- type: z.literal("interaction.result"),
93
- clientActionId: z.string().min(1),
94
- accepted: z.literal(true)
95
- }).strict(),
96
- z.object({
97
- type: z.literal("interaction.result"),
98
- clientActionId: z.string().min(1),
99
- accepted: z.literal(false),
100
- errorCode: z.string().min(1),
101
- message: z.string().optional()
102
- }).strict()
103
- ]);
92
+ var InteractionResultSchema = z.object({
93
+ type: z.literal("interaction.result"),
94
+ clientActionId: z.string().min(1),
95
+ accepted: z.literal(false),
96
+ errorCode: z.string().min(1),
97
+ message: z.string().optional()
98
+ }).strict();
104
99
  var SubmitInteractionCommandSchema = z.object({
105
100
  type: z.literal("interaction.submit"),
106
101
  clientActionId: z.string().min(1),
@@ -116,13 +111,17 @@ var HostToPluginPayloadSchema = z.discriminatedUnion("type", [
116
111
  }).strict(),
117
112
  z.object({
118
113
  type: z.literal("gameplay.frame"),
119
- frame: PluginGameplayFrameSchema
114
+ frame: PluginGameplayFrameSchema,
115
+ acknowledgedClientActionId: z.string().min(1).optional()
120
116
  }).strict(),
121
117
  InteractionResultSchema
122
118
  ]);
123
119
  var PluginToHostPayloadSchema = z.discriminatedUnion("type", [
124
120
  z.object({ type: z.literal("runtime.ready") }).strict(),
125
- z.object({ type: z.literal("runtime.resume") }).strict(),
121
+ z.object({
122
+ type: z.literal("runtime.resume"),
123
+ pendingClientActionId: z.string().min(1).optional()
124
+ }).strict(),
126
125
  z.object({
127
126
  type: z.literal("runtime.ack"),
128
127
  sequence: z.number().int().nonnegative(),
@@ -170,6 +169,7 @@ import { createStore } from "@tanstack/store";
170
169
  import * as z2 from "zod";
171
170
  var SourceSnapshotSchema = z2.object({
172
171
  me: z2.string().min(1),
172
+ causedBy: z2.string().min(1).optional(),
173
173
  players: z2.array(PluginPlayerSummarySchema),
174
174
  frame: SeatFrameSchema,
175
175
  version: z2.number().int().nonnegative()
@@ -204,6 +204,21 @@ function staticSource(input) {
204
204
  };
205
205
  }
206
206
 
207
+ // src/shared/protocol/players.ts
208
+ var PLAYER_SEAT_COLORS = [
209
+ "#2563EB",
210
+ "#DC2626",
211
+ "#059669",
212
+ "#7C3AED",
213
+ "#DB2777",
214
+ "#0891B2",
215
+ "#65A30D",
216
+ "#EA580C"
217
+ ];
218
+ function playerSeatColor(seatIndex) {
219
+ return PLAYER_SEAT_COLORS[seatIndex % PLAYER_SEAT_COLORS.length];
220
+ }
221
+
207
222
  // src/shared/protocol/digest.ts
208
223
  function computePluginActionSetVersion(input) {
209
224
  return digestPluginRuntimeJson({
@@ -244,6 +259,8 @@ function materializePluginGameplayFrame(input) {
244
259
  );
245
260
  const zones = seat?.zones == null ? {} : hydrateZones(registry, seat.zones, "zones");
246
261
  const frame = {
262
+ players: input.players,
263
+ ...input.causedBy === void 0 ? {} : { causedBy: input.causedBy },
247
264
  events: seat?.events ?? [],
248
265
  basis: {
249
266
  sessionId: input.sessionId,
@@ -325,6 +342,7 @@ function createSourceLifecycle(options) {
325
342
  );
326
343
  let session = null;
327
344
  let assetUrls = null;
345
+ const playerSummaries = /* @__PURE__ */ new Map();
328
346
  let basis = null;
329
347
  let pending = null;
330
348
  let timer;
@@ -371,27 +389,14 @@ function createSourceLifecycle(options) {
371
389
  recovered = true;
372
390
  recovering();
373
391
  try {
374
- options.recover();
375
- if (pending && !pending.accepted) options.send(pending.command);
376
- arm();
392
+ options.recover(pending?.command.clientActionId);
393
+ if (pending) options.send(pending.command);
394
+ if (pending) arm();
377
395
  } catch (error) {
378
396
  fail(asError(error));
379
397
  }
380
398
  }, options.timeoutMs ?? 1e4);
381
399
  };
382
- const finishBarrier = () => {
383
- if (!pending?.accepted) return;
384
- const frame = store.get().snapshot;
385
- if (!frame || frame.version <= pending.command.basis.version) return;
386
- clearTimer();
387
- pending = null;
388
- publish({
389
- snapshot: frame,
390
- request: null,
391
- connection: "ready",
392
- failure: null
393
- });
394
- };
395
400
  const start = async (operation, interactionId, params) => {
396
401
  const state = store.get();
397
402
  if (closed || state.connection !== "ready" || !basis)
@@ -411,14 +416,14 @@ function createSourceLifecycle(options) {
411
416
  );
412
417
  recovered = false;
413
418
  const promise = new Promise((resolve, reject) => {
414
- pending = { command, resolve, reject, accepted: false };
419
+ pending = { command, resolve, reject };
415
420
  });
416
421
  publish({
417
422
  ...state,
418
423
  request: {
424
+ clientActionId: command.clientActionId,
419
425
  interactionId,
420
- operation,
421
- phase: "awaiting-result"
426
+ operation
422
427
  }
423
428
  });
424
429
  arm();
@@ -443,8 +448,7 @@ function createSourceLifecycle(options) {
443
448
  retry() {
444
449
  if (closed || !pending) return;
445
450
  try {
446
- if (pending.accepted) options.recover();
447
- else options.send(pending.command);
451
+ options.send(pending.command);
448
452
  } catch (error) {
449
453
  fail(asError(error));
450
454
  }
@@ -458,11 +462,7 @@ function createSourceLifecycle(options) {
458
462
  fail(new Error("Gameplay session changed."));
459
463
  return;
460
464
  }
461
- if (context && !parsed.players.some((player) => player.playerId === context.playerId)) {
462
- fail(new Error("Gameplay seat is absent from session."));
463
- return;
464
- }
465
- session = immutableCopy(parsed);
465
+ session ??= immutableCopy(parsed);
466
466
  assetUrls ??= Object.fromEntries(
467
467
  Object.entries(assets ?? {}).map(([path, blob]) => [
468
468
  path,
@@ -470,7 +470,7 @@ function createSourceLifecycle(options) {
470
470
  ])
471
471
  );
472
472
  },
473
- frame(value) {
473
+ frame(value, acknowledgedClientActionId) {
474
474
  if (closed) return;
475
475
  const parsed = PluginGameplayFrameSchema.parse(value);
476
476
  if (!session) {
@@ -490,13 +490,10 @@ function createSourceLifecycle(options) {
490
490
  fail(new Error("Gameplay perspective changed."));
491
491
  return;
492
492
  }
493
- if (!session.players.some(
494
- (player) => player.playerId === parsed.basis.perspectivePlayerId
495
- )) {
493
+ if (!parsed.players.includes(parsed.basis.perspectivePlayerId)) {
496
494
  fail(new Error("Gameplay seat is absent from session."));
497
495
  return;
498
496
  }
499
- if (basis && parsed.basis.version < basis.version) return;
500
497
  if (changedSeat) {
501
498
  clearTimer();
502
499
  pending?.reject(new Error("Gameplay perspective changed."));
@@ -504,59 +501,80 @@ function createSourceLifecycle(options) {
504
501
  recovered = false;
505
502
  context = { ...context, playerId: parsed.basis.perspectivePlayerId };
506
503
  }
504
+ const confirmed = pending && pending.command.clientActionId === acknowledgedClientActionId ? pending : null;
505
+ if (confirmed) {
506
+ clearTimer();
507
+ pending = null;
508
+ recovered = false;
509
+ }
510
+ if (!changedSeat && basis && parsed.basis.version <= basis.version) {
511
+ if (confirmed || store.get().connection === "recovering") {
512
+ publish({
513
+ ...store.get(),
514
+ snapshot: store.get().snapshot,
515
+ request: confirmed ? null : store.get().request,
516
+ connection: "ready",
517
+ failure: null
518
+ });
519
+ }
520
+ confirmed?.resolve({ accepted: true });
521
+ return;
522
+ }
507
523
  const { basis: nextBasis, ...frame } = immutableCopy(
508
524
  withCardImageUrls(parsed, assetUrls)
509
525
  );
510
526
  basis = nextBasis;
511
527
  publish({
512
528
  failure: null,
513
- request: changedSeat ? null : store.get().request,
529
+ request: changedSeat || confirmed ? null : store.get().request,
514
530
  snapshot: Object.freeze({
515
531
  me: context.playerId,
516
- players: session.players,
532
+ players: Object.freeze(
533
+ frame.players.map((playerId, index) => {
534
+ let summary = playerSummaries.get(playerId);
535
+ if (!summary) {
536
+ const metadata = session.players.find(
537
+ (player) => player.playerId === playerId
538
+ );
539
+ summary = Object.freeze({
540
+ playerId,
541
+ displayName: metadata?.displayName ?? `Player ${index + 1}`,
542
+ color: metadata?.color ?? playerSeatColor(index)
543
+ });
544
+ playerSummaries.set(playerId, summary);
545
+ }
546
+ return summary;
547
+ })
548
+ ),
549
+ ...frame.causedBy === void 0 ? {} : { causedBy: frame.causedBy },
517
550
  frame: Object.freeze(frame),
518
551
  version: basis.version
519
552
  }),
520
553
  connection: "ready"
521
554
  });
522
- finishBarrier();
555
+ confirmed?.resolve({ accepted: true });
523
556
  },
524
557
  result(value) {
525
558
  if (closed) return;
526
559
  const result = InteractionResultSchema.parse(value);
527
- if (!pending || result.clientActionId !== pending.command.clientActionId || pending.accepted)
528
- return;
529
- pending.resolve(
530
- immutableCopy(
531
- result.accepted ? { accepted: true } : {
532
- accepted: false,
533
- errorCode: result.errorCode,
534
- ...result.message === void 0 ? {} : { message: result.message }
535
- }
536
- )
537
- );
538
- if (!result.accepted) {
539
- clearTimer();
540
- pending = null;
541
- publish({
542
- snapshot: store.get().snapshot,
543
- request: null,
544
- connection: "ready",
545
- failure: null
546
- });
560
+ if (!pending || result.clientActionId !== pending.command.clientActionId)
547
561
  return;
548
- }
549
- pending.accepted = true;
550
- recovered = false;
551
- const state = store.get();
562
+ const rejected = pending;
563
+ clearTimer();
564
+ pending = null;
552
565
  publish({
553
- connection: state.connection === "recovering" ? "recovering" : "ready",
554
- snapshot: state.snapshot,
555
- failure: null,
556
- request: { ...state.request, phase: "awaiting-frame" }
566
+ snapshot: store.get().snapshot,
567
+ request: null,
568
+ connection: "ready",
569
+ failure: null
557
570
  });
558
- arm();
559
- finishBarrier();
571
+ rejected.resolve(
572
+ immutableCopy({
573
+ accepted: false,
574
+ errorCode: result.errorCode,
575
+ ...result.message === void 0 ? {} : { message: result.message }
576
+ })
577
+ );
560
578
  }
561
579
  };
562
580
  }
@@ -628,10 +646,12 @@ export {
628
646
  parsePluginToHostEnvelope,
629
647
  SourceSnapshotSchema,
630
648
  staticSource,
649
+ PLAYER_SEAT_COLORS,
650
+ playerSeatColor,
631
651
  createSourceLifecycle,
632
652
  computePluginActionSetVersion,
633
653
  digestPluginGameplayFrame,
634
654
  digestPluginCommandRequest,
635
655
  materializePluginGameplayFrame
636
656
  };
637
- //# sourceMappingURL=chunk-SHUHBE62.js.map
657
+ //# sourceMappingURL=chunk-CWANHA4C.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/shared/protocol/protocol.ts","../src/shared/protocol/schema.ts","../src/headless/sources/static.ts","../src/shared/protocol/players.ts","../src/shared/protocol/digest.ts","../src/shared/protocol/projection.ts","../src/headless/sources/lifecycle.ts"],"sourcesContent":["import type {\n GameplayBasis,\n InteractionDescriptor,\n PluginGameplayFrame,\n PluginSessionDescriptor,\n} from \"./frame.js\";\nimport type { RuntimeJson } from \"../runtime-json.js\";\n\nexport const DREAMBOARD_PLUGIN_PROTOCOL = \"dreamboard-plugin\" as const;\nexport const DREAMBOARD_PLUGIN_PROTOCOL_VERSION = 11 as const;\n\nexport type InteractionResult =\n | {\n readonly clientActionId: string;\n readonly accepted: true;\n }\n | {\n readonly type: \"interaction.result\";\n readonly clientActionId: string;\n readonly accepted: false;\n readonly errorCode: string;\n readonly message?: string;\n };\n\nexport interface SubmitInteractionCommand {\n readonly type: \"interaction.submit\";\n readonly clientActionId: string;\n readonly basis: GameplayBasis;\n readonly interactionId: string;\n readonly params: RuntimeJson;\n}\n\nexport interface CancelInteractionCommand {\n readonly type: \"interaction.cancel\";\n readonly clientActionId: string;\n readonly basis: GameplayBasis;\n readonly interactionId: string;\n}\n\nexport type HostToPluginPayload =\n | {\n readonly type: \"runtime.init\";\n readonly session: PluginSessionDescriptor;\n }\n | {\n readonly type: \"gameplay.frame\";\n readonly frame: PluginGameplayFrame;\n /** Confirms a durable action covered by this frame. Independent of causedBy. */\n readonly acknowledgedClientActionId?: string;\n }\n | Extract<InteractionResult, { accepted: false }>;\n\nexport type PluginToHostPayload =\n | { readonly type: \"runtime.ready\" }\n | { readonly type: \"runtime.resume\"; readonly pendingClientActionId?: string }\n | {\n readonly type: \"runtime.ack\";\n /** Echoes the host envelope sequence. It is delivery order only. */\n readonly sequence: number;\n readonly clientReceivedAtMs?: number;\n readonly clientRenderedAtMs?: number;\n }\n | SubmitInteractionCommand\n | CancelInteractionCommand\n | {\n readonly type: \"runtime.error\";\n readonly message: string;\n readonly code?: string;\n };\n\nexport interface PluginProtocolEnvelope<Payload> {\n readonly protocol: typeof DREAMBOARD_PLUGIN_PROTOCOL;\n readonly version: typeof DREAMBOARD_PLUGIN_PROTOCOL_VERSION;\n readonly channelId: string;\n /** Delivery order only. It is not a game revision. */\n readonly sequence: number;\n readonly payload: Payload;\n}\n\nexport type HostToPluginEnvelope = PluginProtocolEnvelope<HostToPluginPayload>;\nexport type PluginToHostEnvelope = PluginProtocolEnvelope<PluginToHostPayload>;\n\nexport type ActionSetVersionInput = {\n readonly version: number;\n readonly availableInteractions: readonly InteractionDescriptor[];\n};\n","import { PlayerIdSchema } from \"../domain/player-identity.js\";\nimport { ViewCardSchema } from \"../domain/cards.js\";\nimport * as ReducerWireZod from \"../runtime-schema\";\nimport * as z from \"zod\";\nimport {\n DREAMBOARD_PLUGIN_PROTOCOL,\n DREAMBOARD_PLUGIN_PROTOCOL_VERSION,\n} from \"./protocol.js\";\nimport { RuntimeJsonSchema } from \"../runtime-json.js\";\nimport {\n BoardProjectionSchema,\n ProjectedTileSchema,\n} from \"../seat-topology-schema.js\";\nimport type {\n GameOutcome,\n GameplayBasis,\n PluginGameplayFrame,\n PluginSessionDescriptor,\n ZoneHandlesSnapshot,\n} from \"./frame.js\";\nimport type {\n HostToPluginPayload,\n InteractionResult,\n PluginProtocolEnvelope,\n PluginToHostPayload,\n} from \"./protocol.js\";\n\nexport const GameEventDetailSchema =\n ReducerWireZod.ProjectedGameEventDetailSchema;\nexport const SystemActionEventSchema = ReducerWireZod.SystemActionEventSchema;\nexport const GameEventSchema = ReducerWireZod.ProjectedGameEventSchema;\nexport const SeatProjectionBundleSchema =\n ReducerWireZod.SeatProjectionBundleSchema;\n\nexport { PlayerIdSchema } from \"../domain/player-identity.js\";\n\nexport const PluginPlayerSummarySchema = z\n .object({\n playerId: PlayerIdSchema,\n displayName: z.string(),\n color: z.string().optional(),\n })\n .strict();\n\nexport const PluginSessionDescriptorSchema = z\n .object({\n sessionId: z.string().min(1),\n players: z.array(PluginPlayerSummarySchema),\n assets: z.record(z.string(), z.instanceof(Blob)).optional(),\n })\n .strict() satisfies z.ZodType<PluginSessionDescriptor>;\n\nexport {\n InteractionCommitPolicySchema,\n InputSelectionSchema,\n InputDomainSchema,\n InteractionChoiceOptionSchema,\n InteractionInputDescriptorSchema,\n InteractionAvailabilitySchema,\n InteractionDescriptorSchema,\n} from \"../interaction-schema.js\";\nimport { InteractionDescriptorSchema } from \"../interaction-schema.js\";\n\nexport const ZoneHandlesSnapshotSchema = z\n .object({\n tiles: z.array(ProjectedTileSchema),\n cardIds: z.array(z.string()),\n cardViewsById: z.record(z.string(), ViewCardSchema),\n cardBacksById: z.record(z.string(), z.string()),\n playableByCardId: z.record(\n z.string(),\n z.array(InteractionDescriptorSchema),\n ),\n shuffled: z.literal(true).optional(),\n })\n .strict() satisfies z.ZodType<ZoneHandlesSnapshot>;\n\nexport const SimultaneousPhaseSnapshotSchema =\n ReducerWireZod.SimultaneousPhaseProjectionSchema;\n\nexport const GameplayBasisSchema = z\n .object({\n sessionId: z.string().min(1),\n version: z.number().int().nonnegative(),\n actionSetVersion: z.string().min(1),\n perspectivePlayerId: PlayerIdSchema,\n })\n .strict() satisfies z.ZodType<GameplayBasis>;\n\nexport const GameOutcomeSchema =\n ReducerWireZod.GameOutcomeSchema satisfies z.ZodType<GameOutcome>;\n\nconst ProjectedViewSchema = z\n .record(z.string(), RuntimeJsonSchema)\n .superRefine((view, context) => {\n if (!Object.hasOwn(view, \"boards\")) return;\n const boards = BoardProjectionSchema.safeParse(view.boards);\n if (!boards.success) {\n for (const issue of boards.error.issues) {\n context.addIssue({\n code: \"custom\",\n path: [\"boards\", ...issue.path],\n message: issue.message,\n });\n }\n }\n });\n\nexport const SeatFrameSchema = z\n .object({\n players: z.array(PlayerIdSchema),\n causedBy: z.string().min(1).optional(),\n events: z.array(GameEventSchema).max(32),\n view: ProjectedViewSchema.nullable(),\n flow: z\n .object({\n currentPhase: z.string().nullable(),\n activePlayers: z.array(PlayerIdSchema),\n simultaneousPhase: SimultaneousPhaseSnapshotSchema.nullable(),\n })\n .strict(),\n availableInteractions: z.array(InteractionDescriptorSchema),\n zones: z.record(\n z.string(),\n z.record(z.string(), ZoneHandlesSnapshotSchema),\n ),\n })\n .strict();\n\nexport const PluginGameplayFrameSchema = SeatFrameSchema.extend({\n basis: GameplayBasisSchema,\n}) satisfies z.ZodType<PluginGameplayFrame>;\n\n/** Only rejections are standalone wire results; success accompanies a frame. */\nexport const InteractionResultSchema = z\n .object({\n type: z.literal(\"interaction.result\"),\n clientActionId: z.string().min(1),\n accepted: z.literal(false),\n errorCode: z.string().min(1),\n message: z.string().optional(),\n })\n .strict() satisfies z.ZodType<\n Extract<InteractionResult, { accepted: false }>\n>;\n\nexport const SubmitInteractionCommandSchema = z\n .object({\n type: z.literal(\"interaction.submit\"),\n clientActionId: z.string().min(1),\n basis: GameplayBasisSchema,\n interactionId: z.string().min(1),\n params: RuntimeJsonSchema,\n })\n .strict();\n\nexport const CancelInteractionCommandSchema =\n SubmitInteractionCommandSchema.omit({ params: true })\n .extend({ type: z.literal(\"interaction.cancel\") })\n .strict();\n\nexport const HostToPluginPayloadSchema = z.discriminatedUnion(\"type\", [\n z\n .object({\n type: z.literal(\"runtime.init\"),\n session: PluginSessionDescriptorSchema,\n })\n .strict(),\n z\n .object({\n type: z.literal(\"gameplay.frame\"),\n frame: PluginGameplayFrameSchema,\n acknowledgedClientActionId: z.string().min(1).optional(),\n })\n .strict(),\n InteractionResultSchema,\n]) satisfies z.ZodType<HostToPluginPayload>;\n\nexport const PluginToHostPayloadSchema = z.discriminatedUnion(\"type\", [\n z.object({ type: z.literal(\"runtime.ready\") }).strict(),\n z\n .object({\n type: z.literal(\"runtime.resume\"),\n pendingClientActionId: z.string().min(1).optional(),\n })\n .strict(),\n z\n .object({\n type: z.literal(\"runtime.ack\"),\n sequence: z.number().int().nonnegative(),\n clientReceivedAtMs: z.number().finite().optional(),\n clientRenderedAtMs: z.number().finite().optional(),\n })\n .strict(),\n SubmitInteractionCommandSchema,\n CancelInteractionCommandSchema,\n z\n .object({\n type: z.literal(\"runtime.error\"),\n message: z.string(),\n code: z.string().optional(),\n })\n .strict(),\n]) satisfies z.ZodType<PluginToHostPayload>;\n\nexport function createPluginProtocolEnvelopeSchema<Payload>(\n payloadSchema: z.ZodType<Payload>,\n): z.ZodType<PluginProtocolEnvelope<Payload>> {\n return z\n .object({\n protocol: z.literal(DREAMBOARD_PLUGIN_PROTOCOL),\n version: z.literal(DREAMBOARD_PLUGIN_PROTOCOL_VERSION),\n channelId: z.string().min(1),\n sequence: z.number().int().nonnegative(),\n payload: payloadSchema,\n })\n .strict();\n}\n\nexport const HostToPluginEnvelopeSchema = createPluginProtocolEnvelopeSchema(\n HostToPluginPayloadSchema,\n);\n\nexport const PluginToHostEnvelopeSchema = createPluginProtocolEnvelopeSchema(\n PluginToHostPayloadSchema,\n);\n\nexport function parsePluginSessionDescriptor(\n value: unknown,\n): PluginSessionDescriptor {\n return PluginSessionDescriptorSchema.parse(value);\n}\n\nexport function parsePluginGameplayFrame(value: unknown): PluginGameplayFrame {\n return PluginGameplayFrameSchema.parse(value);\n}\n\nexport function parseHostToPluginEnvelope(\n value: unknown,\n): PluginProtocolEnvelope<HostToPluginPayload> {\n return HostToPluginEnvelopeSchema.parse(value);\n}\n\nexport function parsePluginToHostEnvelope(\n value: unknown,\n): PluginProtocolEnvelope<PluginToHostPayload> {\n return PluginToHostEnvelopeSchema.parse(value);\n}\n","import { createStore } from \"@tanstack/store\";\nimport * as z from \"zod\";\nimport {\n SeatFrameSchema,\n PluginPlayerSummarySchema,\n} from \"../../shared/protocol/schema.js\";\nimport { immutableCopy } from \"../../shared/immutable.js\";\nimport type { GameSource, SourceSnapshot, SourceState } from \"./types.js\";\n\nexport const SourceSnapshotSchema = z\n .object({\n me: z.string().min(1),\n causedBy: z.string().min(1).optional(),\n players: z.array(PluginPlayerSummarySchema),\n frame: SeatFrameSchema,\n version: z.number().int().nonnegative(),\n })\n .strict();\n\n/** A read-only fixture source accepts the public seat snapshot, never wire basis. */\nexport function staticSource(input: SourceSnapshot): GameSource {\n const snapshot = immutableCopy(SourceSnapshotSchema.parse(input));\n if (!snapshot.players.some((player) => player.playerId === snapshot.me))\n throw new Error(\"Gameplay seat is absent from session.\");\n const store = createStore<SourceState>(\n Object.freeze({\n snapshot,\n connection: \"ready\",\n request: null,\n failure: null,\n }),\n );\n return {\n store: {\n get: () => store.get(),\n subscribe: (listener) => store.subscribe(listener),\n },\n dispose() {\n store.setState((state) =>\n Object.freeze({\n snapshot: state.snapshot,\n connection: \"closed\",\n request: null,\n failure: null,\n }),\n );\n },\n };\n}\n","/** Stable seat colors shared by hosted and local gameplay. */\nexport const PLAYER_SEAT_COLORS = [\n \"#2563EB\",\n \"#DC2626\",\n \"#059669\",\n \"#7C3AED\",\n \"#DB2777\",\n \"#0891B2\",\n \"#65A30D\",\n \"#EA580C\",\n] as const;\n\nexport function playerSeatColor(seatIndex: number): string {\n return PLAYER_SEAT_COLORS[seatIndex % PLAYER_SEAT_COLORS.length];\n}\n","import type { PluginGameplayFrame } from \"./frame.js\";\nimport {\n type ActionSetVersionInput,\n type SubmitInteractionCommand,\n type CancelInteractionCommand,\n} from \"./protocol.js\";\nimport {\n canonicalizePluginRuntimeJson,\n digestPluginRuntimeJson,\n encodeCanonicalPluginRuntimeJson,\n} from \"./json.js\";\n\nexport {\n canonicalizePluginRuntimeJson,\n digestPluginRuntimeJson,\n encodeCanonicalPluginRuntimeJson,\n};\n\nexport function computePluginActionSetVersion(\n input: ActionSetVersionInput,\n): string {\n return digestPluginRuntimeJson({\n digestVersion: \"plugin-action-set@6\",\n version: input.version,\n availableInteractions: input.availableInteractions,\n });\n}\n\nexport function digestPluginGameplayFrame(frame: PluginGameplayFrame): string {\n return digestPluginRuntimeJson({\n digestVersion: \"plugin-gameplay-frame@6\",\n frame,\n });\n}\n\nexport function digestPluginCommandRequest(\n command: SubmitInteractionCommand | CancelInteractionCommand,\n): string {\n return digestPluginRuntimeJson({\n digestVersion: \"plugin-command-request@6\",\n command,\n });\n}\n","import { canonicalizePluginRuntimeJson } from \"./json\";\nimport {\n PluginGameplayFrameSchema,\n SeatProjectionBundleSchema,\n} from \"./schema.js\";\nimport type {\n InteractionDescriptor,\n PlayerId,\n PluginGameplayFrame,\n ReducerSeatProjectionBundle,\n ZoneHandlesSnapshot,\n} from \"./frame.js\";\nimport type { RuntimeJson } from \"../runtime-json.js\";\n\nexport interface MaterializePluginGameplayFrameInput {\n readonly players: readonly PlayerId[];\n readonly causedBy?: string;\n readonly currentPhase: string | null;\n readonly activePlayers: readonly PlayerId[];\n readonly dynamicProjection: ReducerSeatProjectionBundle;\n readonly perspectivePlayerId: PlayerId;\n\n readonly sessionId: string;\n readonly version: number;\n readonly actionSetVersion: string;\n}\n\nexport function materializePluginGameplayFrame(\n input: MaterializePluginGameplayFrameInput,\n): PluginGameplayFrame {\n const dynamicProjection = SeatProjectionBundleSchema.parse(\n canonicalizePluginRuntimeJson(input.dynamicProjection),\n );\n if (\n dynamicProjection.referenceBasis.sessionId !== input.sessionId ||\n dynamicProjection.referenceBasis.version !== input.version\n ) {\n throw new Error(\n \"Projection reference basis does not match the frame basis.\",\n );\n }\n const registry = dynamicProjection.interactionsByRef ?? {};\n const seat = dynamicProjection.seats[input.perspectivePlayerId] ?? null;\n\n const availableInteractions =\n seat == null\n ? []\n : hydrateInteractionRefs(\n registry,\n seat.availableInteractionRefs ?? [],\n \"availableInteractionRefs\",\n );\n const zones =\n seat?.zones == null ? {} : hydrateZones(registry, seat.zones, \"zones\");\n\n const frame = {\n players: input.players,\n ...(input.causedBy === undefined ? {} : { causedBy: input.causedBy }),\n events: seat?.events ?? [],\n basis: {\n sessionId: input.sessionId,\n version: input.version,\n actionSetVersion: input.actionSetVersion,\n perspectivePlayerId: input.perspectivePlayerId,\n },\n view: materializeView(seat?.view, seat?.boards),\n flow: {\n currentPhase: input.currentPhase,\n activePlayers: [...input.activePlayers],\n simultaneousPhase: dynamicProjection.simultaneousPhase ?? null,\n },\n availableInteractions,\n zones,\n } satisfies PluginGameplayFrame;\n\n return PluginGameplayFrameSchema.parse(frame);\n}\n\nfunction materializeView(\n seatView: unknown,\n seatBoards: ReducerSeatProjectionBundle[\"seats\"][string][\"boards\"],\n): RuntimeJson | null {\n const parts = [\n seatView,\n seatBoards === undefined ? undefined : { boards: seatBoards },\n ].filter((part) => part !== undefined && part !== null);\n if (parts.length === 0) return null;\n // Admitting schemas guarantee records and reject authored `boards` fields.\n return Object.assign({}, ...parts) as Record<string, RuntimeJson>;\n}\n\nfunction hydrateZones(\n registry: Readonly<Record<string, InteractionDescriptor>>,\n value: NonNullable<ReducerSeatProjectionBundle[\"seats\"][string][\"zones\"]>,\n path: string,\n): Record<string, Record<string, ZoneHandlesSnapshot>> {\n return Object.fromEntries(\n Object.entries(value).map(([zoneId, hosts]) => [\n zoneId,\n Object.fromEntries(\n Object.entries(hosts).map(([hostId, zone]) => [\n hostId,\n {\n tiles: zone.tiles,\n cardIds: zone.cardIds,\n cardViewsById: zone.cardViewsById,\n cardBacksById: zone.cardBacksById,\n playableByCardId: Object.fromEntries(\n Object.entries(zone.playableByCardId).map(([cardId, refs]) => [\n cardId,\n hydrateInteractionRefs(\n registry,\n refs,\n `${path}.${zoneId}.${hostId}.playableByCardId.${cardId}`,\n ),\n ]),\n ),\n ...(zone.shuffled ? { shuffled: true as const } : {}),\n },\n ]),\n ),\n ]),\n );\n}\n\nfunction hydrateInteractionRefs(\n registry: Readonly<Record<string, InteractionDescriptor>>,\n value: readonly string[],\n path: string,\n): InteractionDescriptor[] {\n return value.map((ref, index) => {\n const descriptor = registry[ref];\n if (!descriptor) {\n throw new Error(\n `Seat projection ${path}[${index}] references '${ref}', which is missing from interactionsByRef.`,\n );\n }\n return descriptor;\n });\n}\n","import { playerSeatColor } from \"../../shared/protocol/players.js\";\nimport { createStore } from \"@tanstack/store\";\nimport {\n PluginGameplayFrameSchema,\n PluginSessionDescriptorSchema,\n InteractionResultSchema,\n PluginToHostPayloadSchema,\n} from \"../../shared/protocol/schema.js\";\nimport type {\n GameplayBasis,\n PluginGameplayFrame,\n PluginSessionDescriptor,\n PluginPlayerSummary,\n} from \"../../shared/protocol/frame.js\";\nimport { immutableCopy } from \"../../shared/immutable.js\";\nimport type {\n CommandSource,\n SourceCommand,\n SourceContext,\n SourceState,\n SubmitResult,\n} from \"./types.js\";\n\ninterface Pending {\n readonly command: SourceCommand;\n readonly resolve: (result: SubmitResult) => void;\n readonly reject: (error: Error) => void;\n}\n\n/** Adapter-private lifecycle. Transport callbacks must belong to this lifetime. */\nexport function createSourceLifecycle(options: {\n context?: SourceContext;\n send(command: SourceCommand): void;\n recover(pendingClientActionId?: string): void;\n close(): void;\n timeoutMs?: number;\n followHostSeat?: boolean;\n}) {\n let context = options.context ? immutableCopy(options.context) : null;\n const store = createStore<SourceState>(\n Object.freeze({\n snapshot: null,\n connection: \"connecting\",\n request: null,\n failure: null,\n }),\n );\n let session: Omit<PluginSessionDescriptor, \"assets\"> | null = null;\n let assetUrls: Readonly<Record<string, string>> | null = null;\n const playerSummaries = new Map<string, PluginPlayerSummary>();\n let basis: GameplayBasis | null = null;\n let pending: Pending | null = null;\n let timer: ReturnType<typeof setTimeout> | undefined;\n let recovered = false;\n let closed = false;\n const clearTimer = () => {\n clearTimeout(timer);\n timer = undefined;\n };\n const publish = (state: SourceState) => {\n if (state.request) Object.freeze(state.request);\n store.setState(() => Object.freeze(state));\n };\n const recovering = () => {\n if (closed) return;\n publish({ ...store.get(), connection: \"recovering\", failure: null });\n };\n const close = (failure: Error | null) => {\n if (closed) return;\n closed = true;\n clearTimer();\n for (const url of Object.values(assetUrls ?? {})) URL.revokeObjectURL(url);\n pending?.reject(failure ?? new Error(\"Gameplay source disposed.\"));\n pending = null;\n options.close();\n const snapshot = store.get().snapshot;\n publish(\n failure\n ? {\n connection: \"failed\",\n snapshot,\n request: null,\n failure: Object.freeze(failure),\n }\n : { connection: \"closed\", snapshot, request: null, failure: null },\n );\n };\n const fail = (error: Error) => close(error);\n const arm = () => {\n clearTimer();\n timer = setTimeout(() => {\n if (recovered) {\n fail(new Error(\"Gameplay source recovery timed out.\"));\n return;\n }\n recovered = true;\n recovering();\n try {\n options.recover(pending?.command.clientActionId);\n if (pending) options.send(pending.command);\n if (pending) arm();\n } catch (error) {\n fail(asError(error));\n }\n }, options.timeoutMs ?? 10_000);\n };\n const start = async (\n operation: \"submit\" | \"cancel\",\n interactionId: string,\n params?: unknown,\n ) => {\n const state = store.get();\n if (closed || state.connection !== \"ready\" || !basis)\n return Promise.reject(new Error(\"Gameplay source is not open.\"));\n if (pending)\n return Promise.reject(\n new Error(\"A gameplay interaction is already pending.\"),\n );\n const command = immutableCopy(\n PluginToHostPayloadSchema.parse({\n type:\n operation === \"cancel\" ? \"interaction.cancel\" : \"interaction.submit\",\n clientActionId: crypto.randomUUID(),\n basis,\n interactionId,\n ...(operation === \"cancel\" ? {} : { params }),\n }) as SourceCommand,\n );\n recovered = false;\n const promise = new Promise<SubmitResult>((resolve, reject) => {\n pending = { command, resolve, reject };\n });\n publish({\n ...state,\n request: {\n clientActionId: command.clientActionId,\n interactionId,\n operation,\n },\n });\n arm();\n try {\n options.send(command);\n } catch (error) {\n fail(asError(error));\n }\n return promise;\n };\n const source: CommandSource = {\n store: {\n get: () => store.get(),\n subscribe: (listener) => store.subscribe(listener),\n },\n submit: (interactionId, params) => start(\"submit\", interactionId, params),\n cancel: (interactionId) => start(\"cancel\", interactionId),\n dispose: () => close(null),\n };\n return {\n source,\n retry() {\n if (closed || !pending) return;\n try {\n options.send(pending.command);\n } catch (error) {\n fail(asError(error));\n }\n },\n fail,\n recovering,\n session(value: unknown) {\n if (closed) return;\n const { assets, ...parsed } = PluginSessionDescriptorSchema.parse(value);\n if (\n (context?.sessionId ?? session?.sessionId) &&\n parsed.sessionId !== (context?.sessionId ?? session?.sessionId)\n ) {\n fail(new Error(\"Gameplay session changed.\"));\n return;\n }\n session ??= immutableCopy(parsed);\n // Hosts repeat initialization until ready; the first delivery wins.\n assetUrls ??= Object.fromEntries(\n Object.entries(assets ?? {}).map(([path, blob]) => [\n path,\n URL.createObjectURL(blob),\n ]),\n );\n },\n frame(value: unknown, acknowledgedClientActionId?: string) {\n if (closed) return;\n const parsed = PluginGameplayFrameSchema.parse(value);\n if (!session) {\n fail(new Error(\"Gameplay frame arrived before session metadata.\"));\n return;\n }\n context ??= {\n sessionId: session.sessionId,\n playerId: parsed.basis.perspectivePlayerId,\n };\n if (parsed.basis.sessionId !== context.sessionId) {\n fail(new Error(\"Gameplay authority session changed.\"));\n return;\n }\n const changedSeat = parsed.basis.perspectivePlayerId !== context.playerId;\n if (changedSeat && !options.followHostSeat) {\n fail(new Error(\"Gameplay perspective changed.\"));\n return;\n }\n if (!parsed.players.includes(parsed.basis.perspectivePlayerId)) {\n fail(new Error(\"Gameplay seat is absent from session.\"));\n return;\n }\n if (changedSeat) {\n clearTimer();\n pending?.reject(new Error(\"Gameplay perspective changed.\"));\n pending = null;\n recovered = false;\n context = { ...context, playerId: parsed.basis.perspectivePlayerId };\n }\n const confirmed =\n pending && pending.command.clientActionId === acknowledgedClientActionId\n ? pending\n : null;\n if (confirmed) {\n clearTimer();\n pending = null;\n recovered = false;\n }\n if (!changedSeat && basis && parsed.basis.version <= basis.version) {\n if (confirmed || store.get().connection === \"recovering\") {\n publish({\n ...store.get(),\n snapshot: store.get().snapshot!,\n request: confirmed ? null : store.get().request,\n connection: \"ready\",\n failure: null,\n });\n }\n confirmed?.resolve({ accepted: true });\n return;\n }\n const { basis: nextBasis, ...frame } = immutableCopy(\n withCardImageUrls(parsed, assetUrls),\n );\n basis = nextBasis;\n publish({\n failure: null,\n request: changedSeat || confirmed ? null : store.get().request,\n snapshot: Object.freeze({\n me: context.playerId,\n players: Object.freeze(\n frame.players.map((playerId, index) => {\n let summary = playerSummaries.get(playerId);\n if (!summary) {\n const metadata = session!.players.find(\n (player) => player.playerId === playerId,\n );\n summary = Object.freeze({\n playerId,\n displayName: metadata?.displayName ?? `Player ${index + 1}`,\n color: metadata?.color ?? playerSeatColor(index),\n });\n playerSummaries.set(playerId, summary);\n }\n return summary;\n }),\n ),\n ...(frame.causedBy === undefined ? {} : { causedBy: frame.causedBy }),\n frame: Object.freeze(frame),\n version: basis.version,\n }),\n connection: \"ready\",\n });\n confirmed?.resolve({ accepted: true });\n },\n result(value: unknown) {\n if (closed) return;\n const result = InteractionResultSchema.parse(value);\n if (!pending || result.clientActionId !== pending.command.clientActionId)\n return;\n const rejected = pending;\n clearTimer();\n pending = null;\n publish({\n snapshot: store.get().snapshot!,\n request: null,\n connection: \"ready\",\n failure: null,\n });\n rejected.resolve(\n immutableCopy({\n accepted: false,\n errorCode: result.errorCode,\n ...(result.message === undefined ? {} : { message: result.message }),\n }),\n );\n },\n };\n}\nfunction asError(error: unknown): Error {\n return error instanceof Error ? error : new Error(String(error));\n}\n\n/** Replaces card image paths in card views and hidden card backs with delivered URLs. */\nfunction withCardImageUrls(\n frame: PluginGameplayFrame,\n urls: Readonly<Record<string, string>> | null,\n): PluginGameplayFrame {\n if (urls === null || Object.keys(urls).length === 0) return frame;\n return {\n ...frame,\n zones: Object.fromEntries(\n Object.entries(frame.zones).map(([zoneId, hosts]) => [\n zoneId,\n Object.fromEntries(\n Object.entries(hosts).map(([hostId, zone]) => [\n hostId,\n {\n ...zone,\n cardViewsById: Object.fromEntries(\n Object.entries(zone.cardViewsById).map(([cardId, card]) => [\n cardId,\n {\n ...card,\n frontImage:\n card.frontImage === undefined\n ? undefined\n : (urls[card.frontImage] ?? card.frontImage),\n backImage:\n card.backImage === undefined\n ? undefined\n : (urls[card.backImage] ?? card.backImage),\n },\n ]),\n ),\n cardBacksById: Object.fromEntries(\n Object.entries(zone.cardBacksById).map(([cardId, path]) => [\n cardId,\n urls[path] ?? path,\n ]),\n ),\n },\n ]),\n ),\n ]),\n ),\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAQO,IAAM,6BAA6B;AACnC,IAAM,qCAAqC;;;ACNlD,YAAY,OAAO;AAwBZ,IAAM,wBACI;AACV,IAAMA,2BAAyC;AAC/C,IAAM,kBAAiC;AACvC,IAAMC,8BACI;AAIV,IAAM,4BACV,SAAO;AAAA,EACN,UAAU;AAAA,EACV,aAAe,SAAO;AAAA,EACtB,OAAS,SAAO,EAAE,SAAS;AAC7B,CAAC,EACA,OAAO;AAEH,IAAM,gCACV,SAAO;AAAA,EACN,WAAa,SAAO,EAAE,IAAI,CAAC;AAAA,EAC3B,SAAW,QAAM,yBAAyB;AAAA,EAC1C,QAAU,SAAS,SAAO,GAAK,aAAW,IAAI,CAAC,EAAE,SAAS;AAC5D,CAAC,EACA,OAAO;AAaH,IAAM,4BACV,SAAO;AAAA,EACN,OAAS,QAAM,mBAAmB;AAAA,EAClC,SAAW,QAAQ,SAAO,CAAC;AAAA,EAC3B,eAAiB,SAAS,SAAO,GAAG,cAAc;AAAA,EAClD,eAAiB,SAAS,SAAO,GAAK,SAAO,CAAC;AAAA,EAC9C,kBAAoB;AAAA,IAChB,SAAO;AAAA,IACP,QAAM,2BAA2B;AAA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C,QAAQ,KAAK,MAAM;AAAA,QACnD;AAAA,QACA,OAAO;AAAA,UACL,OAAO,QAAQ,KAAK,EAAE,IAAI,CAAC,CAAC,QAAQ,IAAI,MAAM;AAAA,YAC5C;AAAA,YACA;AAAA,cACE,GAAG;AAAA,cACH,eAAe,OAAO;AAAA,gBACpB,OAAO,QAAQ,KAAK,aAAa,EAAE,IAAI,CAAC,CAAC,QAAQ,IAAI,MAAM;AAAA,kBACzD;AAAA,kBACA;AAAA,oBACE,GAAG;AAAA,oBACH,YACE,KAAK,eAAe,SAChB,SACC,KAAK,KAAK,UAAU,KAAK,KAAK;AAAA,oBACrC,WACE,KAAK,cAAc,SACf,SACC,KAAK,KAAK,SAAS,KAAK,KAAK;AAAA,kBACtC;AAAA,gBACF,CAAC;AAAA,cACH;AAAA,cACA,eAAe,OAAO;AAAA,gBACpB,OAAO,QAAQ,KAAK,aAAa,EAAE,IAAI,CAAC,CAAC,QAAQ,IAAI,MAAM;AAAA,kBACzD;AAAA,kBACA,KAAK,IAAI,KAAK;AAAA,gBAChB,CAAC;AAAA,cACH;AAAA,YACF;AAAA,UACF,CAAC;AAAA,QACH;AAAA,MACF,CAAC;AAAA,IACH;AAAA,EACF;AACF;","names":["SystemActionEventSchema","SeatProjectionBundleSchema","GameOutcomeSchema","z","SeatProjectionBundleSchema","createStore","createStore"]}