@dreamboard-games/sdk 0.5.0-alpha.2 → 0.5.0-alpha.21
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 +462 -53
- package/dist/board-element-CqtxU5VZ.d.ts +13 -0
- package/dist/chunk-3RFGPBES.js +1792 -0
- package/dist/chunk-3RFGPBES.js.map +1 -0
- package/dist/chunk-CZRPUWCT.js +1602 -0
- package/dist/chunk-CZRPUWCT.js.map +1 -0
- package/dist/chunk-DMSXVMYY.js +7199 -0
- package/dist/chunk-DMSXVMYY.js.map +1 -0
- package/dist/chunk-U6R7FAH4.js +630 -0
- package/dist/chunk-U6R7FAH4.js.map +1 -0
- package/dist/chunk-YT3RPO5J.js +635 -0
- package/dist/chunk-YT3RPO5J.js.map +1 -0
- package/dist/diagnostics-ZAPEBlJP.d.ts +64 -0
- package/dist/extract-CwJWDrSD.d.ts +6850 -0
- package/dist/index.d.ts +5177 -1
- package/dist/index.js +1990 -6
- package/dist/index.js.map +1 -1
- package/dist/react.d.ts +158 -0
- package/dist/react.js +1119 -0
- package/dist/react.js.map +1 -0
- package/dist/reducer.d.ts +1028 -97
- package/dist/reducer.js +4892 -125
- package/dist/reducer.js.map +1 -1
- package/dist/shortcuts-B_RrufOM.d.ts +822 -0
- package/dist/testing.d.ts +529 -569
- package/dist/testing.js +2588 -934
- package/dist/testing.js.map +1 -1
- package/dist/types-BxXRINRF.d.ts +118 -0
- package/package.json +39 -144
- package/dist/HandView-Bi2lxzQP.d.ts +0 -79
- package/dist/ResourceCounter-BFxJknqp.d.ts +0 -98
- package/dist/ThemeProvider-CElaL2ik.d.ts +0 -99
- package/dist/attributes-DbvyMbXw.d.ts +0 -68
- package/dist/browser-interaction.d.ts +0 -910
- package/dist/browser-interaction.js +0 -119
- package/dist/browser-interaction.js.map +0 -1
- package/dist/chunk-32PFKDV7.js +0 -11705
- package/dist/chunk-32PFKDV7.js.map +0 -1
- package/dist/chunk-3BAD4VC2.js +0 -263
- package/dist/chunk-3BAD4VC2.js.map +0 -1
- package/dist/chunk-3SKDNDPG.js +0 -104
- package/dist/chunk-3SKDNDPG.js.map +0 -1
- package/dist/chunk-5YV2WHJ4.js +0 -25
- package/dist/chunk-5YV2WHJ4.js.map +0 -1
- package/dist/chunk-ANRB4XKA.js +0 -90
- package/dist/chunk-ANRB4XKA.js.map +0 -1
- package/dist/chunk-BI4G3PM2.js +0 -1864
- package/dist/chunk-BI4G3PM2.js.map +0 -1
- package/dist/chunk-EVCLTY4Q.js +0 -935
- package/dist/chunk-EVCLTY4Q.js.map +0 -1
- package/dist/chunk-GDPKTBUR.js +0 -564
- package/dist/chunk-GDPKTBUR.js.map +0 -1
- package/dist/chunk-H6VDGFL5.js +0 -2903
- package/dist/chunk-H6VDGFL5.js.map +0 -1
- package/dist/chunk-LR3ZTWQF.js +0 -5960
- package/dist/chunk-LR3ZTWQF.js.map +0 -1
- package/dist/chunk-PF7L4BMG.js +0 -117
- package/dist/chunk-PF7L4BMG.js.map +0 -1
- package/dist/chunk-PN5O6GG2.js +0 -32
- package/dist/chunk-PN5O6GG2.js.map +0 -1
- package/dist/chunk-PZ5AY32C.js +0 -10
- package/dist/chunk-PZ5AY32C.js.map +0 -1
- package/dist/chunk-S2JEDVWH.js +0 -7165
- package/dist/chunk-S2JEDVWH.js.map +0 -1
- package/dist/chunk-T3ZKNUZ7.js +0 -1
- package/dist/chunk-T3ZKNUZ7.js.map +0 -1
- package/dist/chunk-UGH54WZ2.js +0 -223
- package/dist/chunk-UGH54WZ2.js.map +0 -1
- package/dist/chunk-VCDWP5VL.js +0 -746
- package/dist/chunk-VCDWP5VL.js.map +0 -1
- package/dist/chunk-VDXOF4FW.js +0 -69
- package/dist/chunk-VDXOF4FW.js.map +0 -1
- package/dist/chunk-WHR5UW3F.js +0 -1988
- package/dist/chunk-WHR5UW3F.js.map +0 -1
- package/dist/chunk-Y75CFE77.js +0 -17
- package/dist/chunk-Y75CFE77.js.map +0 -1
- package/dist/chunk-Z7QCREWI.js +0 -3435
- package/dist/chunk-Z7QCREWI.js.map +0 -1
- package/dist/chunk-ZZGN2ATS.js +0 -1941
- package/dist/chunk-ZZGN2ATS.js.map +0 -1
- package/dist/components-gAbIz7hK.d.ts +0 -1284
- package/dist/definitions-BgmV_GhC.d.ts +0 -300
- package/dist/diagnostics-DIi3ina7.d.ts +0 -50
- package/dist/digest.d.ts +0 -8
- package/dist/game-CsZScpcn.d.ts +0 -763
- package/dist/hex-board-view-aKkblDp6.d.ts +0 -1228
- package/dist/index-CcT9Q7N7.d.ts +0 -193
- package/dist/index.d-DjzoK7zn.d.ts +0 -2101
- package/dist/package-set.d.ts +0 -13
- package/dist/package-set.js +0 -12
- package/dist/package-set.js.map +0 -1
- package/dist/player-state-Cqpyeql0.d.ts +0 -371
- package/dist/plugin-runtime-contract.d.ts +0 -17
- package/dist/plugin-runtime-contract.js +0 -92
- package/dist/plugin-runtime-contract.js.map +0 -1
- package/dist/primitive-props-BNHDkgd7.d.ts +0 -16
- package/dist/protocol-dYgafTYY.d.ts +0 -314
- package/dist/reducer/advanced.d.ts +0 -82
- package/dist/reducer/advanced.js +0 -51
- package/dist/reducer/advanced.js.map +0 -1
- package/dist/reducer-contract.d.ts +0 -11
- package/dist/reducer-contract.js +0 -16
- package/dist/reducer-contract.js.map +0 -1
- package/dist/reference-games/index.d.ts +0 -31
- package/dist/reference-games/index.js +0 -48
- package/dist/reference-games/index.js.map +0 -1
- package/dist/runtime/primitives.d.ts +0 -250
- package/dist/runtime/primitives.js +0 -189
- package/dist/runtime/primitives.js.map +0 -1
- package/dist/runtime/runtime-api.d.ts +0 -2
- package/dist/runtime/runtime-api.js +0 -1
- package/dist/runtime/runtime-api.js.map +0 -1
- package/dist/runtime/workspace-contract.d.ts +0 -392
- package/dist/runtime/workspace-contract.js +0 -28
- package/dist/runtime/workspace-contract.js.map +0 -1
- package/dist/runtime-RJ5orDJU.d.ts +0 -1699
- package/dist/runtime-api-Bz5pwNU_.d.ts +0 -296
- package/dist/runtime-json-CQ9QbLZ5.d.ts +0 -5
- package/dist/runtime.d.ts +0 -83
- package/dist/runtime.js +0 -242
- package/dist/runtime.js.map +0 -1
- package/dist/schema.d.ts +0 -379
- package/dist/stale-contract-artifact-error-XLaweZtF.d.ts +0 -18
- package/dist/testing-compiler.d.ts +0 -37
- package/dist/testing-compiler.js +0 -272
- package/dist/testing-compiler.js.map +0 -1
- package/dist/testing-runtime.d.ts +0 -119
- package/dist/testing-runtime.js +0 -212
- package/dist/testing-runtime.js.map +0 -1
- package/dist/types-DJj5MJkl.d.ts +0 -256
- package/dist/types-DR7DoB1x.d.ts +0 -28
- package/dist/types-JWCYHmu7.d.ts +0 -122
- package/dist/types.d.ts +0 -1958
- package/dist/types.js +0 -14
- package/dist/types.js.map +0 -1
- package/dist/ui/components.d.ts +0 -17
- package/dist/ui/components.js +0 -216
- package/dist/ui/components.js.map +0 -1
- package/dist/ui/defaults.d.ts +0 -19
- package/dist/ui/defaults.js +0 -104
- package/dist/ui/defaults.js.map +0 -1
- package/dist/ui/player-state.d.ts +0 -2
- package/dist/ui/player-state.js +0 -1
- package/dist/ui/player-state.js.map +0 -1
- package/dist/ui/plugin-styles.css +0 -2
- package/dist/ui-contract-GTUPkf8z.d.ts +0 -1168
- package/dist/ui.d.ts +0 -317
- package/dist/ui.js +0 -277
- package/dist/ui.js.map +0 -1
- package/dist/views-BpuWcOyN.d.ts +0 -1641
|
@@ -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/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 = 10 as const;\n\nexport type InteractionResult =\n | {\n readonly type: \"interaction.result\";\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 }\n | InteractionResult;\n\nexport type PluginToHostPayload =\n | { readonly type: \"runtime.ready\" }\n | { readonly type: \"runtime.resume\" }\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 })\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 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\nexport const InteractionResultSchema = z.discriminatedUnion(\"accepted\", [\n z\n .object({\n type: z.literal(\"interaction.result\"),\n clientActionId: z.string().min(1),\n accepted: z.literal(true),\n })\n .strict(),\n 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(),\n]) satisfies z.ZodType<InteractionResult>;\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 })\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.object({ type: z.literal(\"runtime.resume\") }).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 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","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 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 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 },\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 { 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} 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 accepted: boolean;\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(): 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 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();\n if (pending && !pending.accepted) options.send(pending.command);\n arm();\n } catch (error) {\n fail(asError(error));\n }\n }, options.timeoutMs ?? 10_000);\n };\n const finishBarrier = () => {\n if (!pending?.accepted) return;\n const frame = store.get().snapshot;\n if (!frame || frame.version <= pending.command.basis.version) return;\n clearTimer();\n pending = null;\n publish({\n snapshot: frame,\n request: null,\n connection: \"ready\",\n failure: null,\n });\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, accepted: false };\n });\n publish({\n ...state,\n request: {\n interactionId,\n operation,\n phase: \"awaiting-result\",\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 if (pending.accepted) options.recover();\n else 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 if (\n context &&\n !parsed.players.some((player) => player.playerId === context!.playerId)\n ) {\n fail(new Error(\"Gameplay seat is absent from session.\"));\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) {\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 (\n !session.players.some(\n (player) => player.playerId === parsed.basis.perspectivePlayerId,\n )\n ) {\n fail(new Error(\"Gameplay seat is absent from session.\"));\n return;\n }\n if (basis && parsed.basis.version < basis.version) return;\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 { basis: nextBasis, ...frame } = immutableCopy(\n withCardImageUrls(parsed, assetUrls),\n );\n basis = nextBasis;\n publish({\n failure: null,\n request: changedSeat ? null : store.get().request,\n snapshot: Object.freeze({\n me: context.playerId,\n players: session.players,\n frame: Object.freeze(frame),\n version: basis.version,\n }),\n connection: \"ready\",\n });\n finishBarrier();\n },\n result(value: unknown) {\n if (closed) return;\n const result = InteractionResultSchema.parse(value);\n if (\n !pending ||\n result.clientActionId !== pending.command.clientActionId ||\n pending.accepted\n )\n return;\n pending.resolve(\n immutableCopy(\n result.accepted\n ? { accepted: true }\n : {\n accepted: false,\n errorCode: result.errorCode,\n ...(result.message === undefined\n ? {}\n : { message: result.message }),\n },\n ),\n );\n if (!result.accepted) {\n clearTimer();\n pending = null;\n publish({\n snapshot: store.get().snapshot!,\n request: null,\n connection: \"ready\",\n failure: null,\n });\n return;\n }\n pending.accepted = true;\n recovered = false;\n const state = store.get();\n // A pending command was submitted from ready, so its snapshot exists.\n publish({\n connection: state.connection === \"recovering\" ? \"recovering\" : \"ready\",\n snapshot: state.snapshot!,\n failure: null,\n request: { ...state.request!, phase: \"awaiting-frame\" },\n });\n arm();\n finishBarrier();\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;AAAA,EACrC;AACF,CAAC,EACA,OAAO;AAEH,IAAM,kCACI;AAEV,IAAM,sBACV,SAAO;AAAA,EACN,WAAa,SAAO,EAAE,IAAI,CAAC;AAAA,EAC3B,SAAW,SAAO,EAAE,IAAI,EAAE,YAAY;AAAA,EACtC,kBAAoB,SAAO,EAAE,IAAI,CAAC;AAAA,EAClC,qBAAqB;AACvB,CAAC,EACA,OAAO;AAEH,IAAMC,qBACI;AAEjB,IAAM,sBACH,SAAS,SAAO,GAAG,iBAAiB,EACpC,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AuB;AACtC,SAAO,iBAAiB,QAAQ,QAAQ,IAAI,MAAM,OAAO,KAAK,CAAC;AACjE;AAGA,SAAS,kBACP,OACA,MACqB;AACrB,MAAI,SAAS,QAAQ,OAAO,KAAK,IAAI,EAAE,WAAW,EAAG,QAAO;AAC5D,SAAO;AAAA,IACL,GAAG;AAAA,IACH,OAAO,OAAO;AAAA,MACZ,OAAO,QAAQ,MAAM,KAAK,EAAE,IAAI,CAAC,CAAC,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"]}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { aB as ReducerContractVersion, Q as InitializeRequest, R as InitializeResult, D as DispatchRequest, y as DispatchResult, av as ProjectRequest, aY as SeatProjectionBundle } from './extract-CwJWDrSD.js';
|
|
2
|
+
|
|
3
|
+
/** Exact worker ABI version; hosts must reject mismatched bundles. */
|
|
4
|
+
declare const REDUCER_CONTRACT_VERSION: "0.11.0";
|
|
5
|
+
type MaybePromise<T> = T | Promise<T>;
|
|
6
|
+
interface ReducerBundleContract {
|
|
7
|
+
readonly reducerContractVersion: ReducerContractVersion;
|
|
8
|
+
initialize(input: InitializeRequest): MaybePromise<InitializeResult>;
|
|
9
|
+
dispatch(input: DispatchRequest): MaybePromise<DispatchResult>;
|
|
10
|
+
project(input: ProjectRequest): SeatProjectionBundle;
|
|
11
|
+
}
|
|
12
|
+
declare function assertReducerBundleContract(value: unknown, source: string): asserts value is ReducerBundleContract;
|
|
13
|
+
|
|
14
|
+
type DispatchTraceSummaryEntry = {
|
|
15
|
+
kind: "acceptedClientInput";
|
|
16
|
+
interactionId: string;
|
|
17
|
+
playerId: string;
|
|
18
|
+
} | {
|
|
19
|
+
kind: "phaseEntered";
|
|
20
|
+
from: string;
|
|
21
|
+
to: string;
|
|
22
|
+
} | {
|
|
23
|
+
kind: "rngConsumption";
|
|
24
|
+
version: 2;
|
|
25
|
+
operation: string;
|
|
26
|
+
drawIndex: number;
|
|
27
|
+
};
|
|
28
|
+
type ReducerDiagnosticEvent = {
|
|
29
|
+
type: "submitReceived";
|
|
30
|
+
submissionId: string;
|
|
31
|
+
playerId: string;
|
|
32
|
+
interactionId: string;
|
|
33
|
+
phase: string;
|
|
34
|
+
} | {
|
|
35
|
+
type: "submitRejected";
|
|
36
|
+
submissionId: string;
|
|
37
|
+
errorCode: string;
|
|
38
|
+
ruleId?: string;
|
|
39
|
+
message?: string;
|
|
40
|
+
} | {
|
|
41
|
+
type: "submitAccepted";
|
|
42
|
+
submissionId: string;
|
|
43
|
+
trace: readonly DispatchTraceSummaryEntry[];
|
|
44
|
+
} | {
|
|
45
|
+
type: "phaseTransition";
|
|
46
|
+
from: string;
|
|
47
|
+
to: string;
|
|
48
|
+
reason: "effect" | "lifecycle";
|
|
49
|
+
} | {
|
|
50
|
+
type: "authoringWarning";
|
|
51
|
+
code: string;
|
|
52
|
+
message: string;
|
|
53
|
+
} | {
|
|
54
|
+
type: "internalError";
|
|
55
|
+
submissionId?: string;
|
|
56
|
+
message: string;
|
|
57
|
+
stack?: string;
|
|
58
|
+
};
|
|
59
|
+
type ReducerDiagnosticsSink = {
|
|
60
|
+
event(event: ReducerDiagnosticEvent): void;
|
|
61
|
+
};
|
|
62
|
+
declare const noopDiagnosticsSink: ReducerDiagnosticsSink;
|
|
63
|
+
|
|
64
|
+
export { type DispatchTraceSummaryEntry as D, type MaybePromise as M, REDUCER_CONTRACT_VERSION as R, type ReducerBundleContract as a, type ReducerDiagnosticEvent as b, type ReducerDiagnosticsSink as c, assertReducerBundleContract as d, noopDiagnosticsSink as n };
|