dreamboard 0.1.19 → 0.1.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/dist/{chunk-WSJTQ3SA.js → chunk-MOVHYB6E.js} +9 -9
- package/dist/chunk-MOVHYB6E.js.map +1 -0
- package/dist/index.js +1 -1
- package/dist/internal.js +13 -2
- package/dist/internal.js.map +1 -1
- package/dist/{src-X7NGTW44.js → src-CUL7EGGG.js} +9 -1
- package/dist/src-CUL7EGGG.js.map +1 -0
- package/package.json +3 -3
- package/dist/chunk-WSJTQ3SA.js.map +0 -1
- package/dist/src-X7NGTW44.js.map +0 -1
package/dist/src-X7NGTW44.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../packages/testing/src/definitions.ts","../../../packages/testing/src/create-expect-api.ts","../../../packages/testing/src/create-test-runtime.ts"],"sourcesContent":["export type TestRunner = \"reducer\" | \"embedded\" | \"browser\";\n\nexport type InteractionDescriptorLike = {\n interactionId?: string;\n surface?: string;\n kind?: string;\n available?: boolean;\n unavailableReason?: string;\n context?: {\n to?: string;\n };\n} & Record<string, unknown>;\n\nexport type SnapshotMatcherHandler = (\n name: string | undefined,\n actual: unknown,\n) => void;\n\nexport type RejectionExpectation = {\n errorCode?: string;\n message?: string | RegExp;\n};\n\nexport type ExpectMatchers = {\n toBe: (expected: unknown) => void;\n toEqual: (expected: unknown) => void;\n toMatchObject: (expected: Record<string, unknown>) => void;\n toBeDefined: () => void;\n toBeUndefined: () => void;\n toBeNull: () => void;\n toContain: (expected: unknown) => void;\n toContainEqual: (expected: unknown) => void;\n toHaveLength: (expected: number) => void;\n toBeGreaterThanOrEqual: (expected: number) => void;\n toThrow: (predicate?: string | RegExp | ((error: Error) => boolean)) => void;\n toMatchSnapshot: (filename?: string) => void;\n toRejectWith: (expected: RejectionExpectation) => Promise<void>;\n toHaveInteraction: (\n interactionId: string,\n opts?: Partial<InteractionDescriptorLike>,\n ) => void;\n toBeGatedBy: (reason: string, opts?: { interactionId?: string }) => void;\n toBeActiveFor: (playerId: string, opts?: { interactionId?: string }) => void;\n not: {\n toHaveInteraction: (interactionId: string) => void;\n };\n};\n\nexport type ExpectFn = (actual: unknown) => ExpectMatchers;\n\nexport interface BaseContext<PlayerId extends string = string> {\n game: {\n start(): Promise<void>;\n submit(\n playerId: PlayerId,\n interactionId: string,\n params?: unknown,\n ): Promise<void>;\n };\n players(): readonly PlayerId[];\n seat(index: number): PlayerId;\n}\n\nexport interface SharedScenarioContext<\n PlayerId extends string = string,\n StateName extends string = string,\n View = unknown,\n Descriptor extends InteractionDescriptorLike = InteractionDescriptorLike,\n> extends BaseContext<PlayerId> {\n state(): StateName;\n view(playerId: PlayerId): View;\n interactions(playerId: PlayerId): readonly Descriptor[];\n expect: ExpectFn;\n}\n\nexport interface BaseDefinition {\n id: string;\n seed?: number;\n players?: number;\n setupProfileId?: string | null;\n extends?: string;\n setup: (ctx: BaseContext) => void | Promise<void>;\n}\n\nexport interface ScenarioDefinition<\n Runners extends readonly TestRunner[] = readonly [\"reducer\"],\n PhaseName extends string = string,\n StageName extends string = string,\n> {\n id: string;\n description?: string;\n from: string;\n runners?: Runners;\n phase?: PhaseName;\n stage?: StageName;\n when: (ctx: SharedScenarioContext) => void | Promise<void>;\n then: (ctx: SharedScenarioContext) => void | Promise<void>;\n}\n\nexport function defineBase<const Definition extends BaseDefinition>(\n definition: Definition,\n): Definition {\n return definition;\n}\n\nexport function defineScenario<\n const Runners extends readonly TestRunner[] = readonly [\"reducer\"],\n const PhaseName extends string = string,\n const StageName extends string = string,\n>(\n definition: ScenarioDefinition<Runners, PhaseName, StageName>,\n): ScenarioDefinition<Runners, PhaseName, StageName> {\n return definition;\n}\n","import { isDeepStrictEqual } from \"node:util\";\nimport type {\n ExpectFn,\n ExpectMatchers,\n InteractionDescriptorLike,\n RejectionExpectation,\n SnapshotMatcherHandler,\n} from \"./definitions.js\";\n\ntype CreateExpectApiOptions = {\n matchSnapshot?: SnapshotMatcherHandler;\n};\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n return typeof value === \"object\" && value !== null && !Array.isArray(value);\n}\n\nfunction matchPartial(\n actual: unknown,\n expected: unknown,\n path: string = \"value\",\n): string | null {\n if (!isRecord(expected)) {\n return isDeepStrictEqual(actual, expected)\n ? null\n : `${path} does not match`;\n }\n if (!isRecord(actual)) {\n return `${path} is not an object`;\n }\n for (const [key, expectedValue] of Object.entries(expected)) {\n const actualValue = actual[key];\n if (!(key in actual)) {\n return `${path}.${key} is missing`;\n }\n const mismatch = matchPartial(actualValue, expectedValue, `${path}.${key}`);\n if (mismatch) {\n return mismatch;\n }\n }\n return null;\n}\n\nfunction asDescriptorList(actual: unknown): InteractionDescriptorLike[] {\n if (!Array.isArray(actual)) {\n throw new Error(\"Expected interaction descriptor array.\");\n }\n return actual as InteractionDescriptorLike[];\n}\n\nfunction findInteraction(\n descriptors: readonly InteractionDescriptorLike[],\n interactionId: string,\n): InteractionDescriptorLike | null {\n return (\n descriptors.find(\n (descriptor) => descriptor.interactionId === interactionId,\n ) ?? null\n );\n}\n\nfunction assertDescriptorMatches(\n descriptor: InteractionDescriptorLike,\n opts: Partial<InteractionDescriptorLike> | undefined,\n): void {\n if (!opts) {\n return;\n }\n const mismatch = matchPartial(descriptor, opts, \"interaction\");\n if (mismatch) {\n throw new Error(mismatch);\n }\n}\n\nfunction createSubmissionErrorMatcher(\n actual: unknown,\n expected: RejectionExpectation,\n): Promise<void> {\n const resolvePromise = (): Promise<unknown> => {\n if (typeof actual === \"function\") {\n return Promise.resolve().then(() => (actual as () => unknown)());\n }\n return Promise.resolve(actual);\n };\n\n return resolvePromise()\n .then(() => {\n throw new Error(\"Expected promise to reject.\");\n })\n .catch((error: unknown) => {\n if (!(error instanceof Error)) {\n throw new Error(\"Expected rejection to be an Error.\");\n }\n if (\n expected.errorCode !== undefined &&\n (error as Error & { errorCode?: string }).errorCode !==\n expected.errorCode\n ) {\n throw new Error(\n `Expected rejection errorCode '${expected.errorCode}', received '${\n (error as Error & { errorCode?: string }).errorCode ?? \"undefined\"\n }'.`,\n );\n }\n if (\n typeof expected.message === \"string\" &&\n error.message !== expected.message\n ) {\n throw new Error(\n `Expected rejection message '${expected.message}', received '${error.message}'.`,\n );\n }\n if (\n expected.message instanceof RegExp &&\n !expected.message.test(error.message)\n ) {\n throw new Error(\n `Expected rejection message '${error.message}' to match ${String(expected.message)}.`,\n );\n }\n });\n}\n\nfunction assertLength(actual: unknown, expected: number): void {\n if (\n actual === null ||\n actual === undefined ||\n typeof (actual as { length?: unknown }).length !== \"number\"\n ) {\n throw new Error(\"toHaveLength expects a value with a numeric length.\");\n }\n const length = (actual as { length: number }).length;\n if (length !== expected) {\n throw new Error(`Expected length ${expected}, received ${length}.`);\n }\n}\n\nfunction assertThrown(\n actual: unknown,\n predicate?: string | RegExp | ((error: Error) => boolean),\n): void {\n if (typeof actual !== \"function\") {\n throw new Error(\"toThrow expects a function.\");\n }\n try {\n (actual as () => unknown)();\n } catch (error) {\n if (!(error instanceof Error)) {\n throw new Error(\"Thrown value is not an Error.\");\n }\n if (predicate === undefined) {\n return;\n }\n if (typeof predicate === \"string\" && error.message !== predicate) {\n throw new Error(\n `Expected thrown message '${predicate}', received '${error.message}'.`,\n );\n }\n if (predicate instanceof RegExp && !predicate.test(error.message)) {\n throw new Error(\n `Expected thrown message '${error.message}' to match ${String(predicate)}.`,\n );\n }\n if (typeof predicate === \"function\" && !predicate(error)) {\n throw new Error(\"Thrown error did not satisfy predicate.\");\n }\n return;\n }\n throw new Error(\"Expected function to throw.\");\n}\n\nexport function createExpectApi(\n options: CreateExpectApiOptions = {},\n): ExpectFn {\n const buildMatchers = (actual: unknown): ExpectMatchers => ({\n toBe: (expected: unknown) => {\n if (actual !== expected) {\n throw new Error(\n `Expected '${String(actual)}' to be '${String(expected)}'.`,\n );\n }\n },\n toEqual: (expected: unknown) => {\n if (!isDeepStrictEqual(actual, expected)) {\n throw new Error(\"Expected values to be deeply equal.\");\n }\n },\n toMatchObject: (expected: Record<string, unknown>) => {\n const mismatch = matchPartial(actual, expected);\n if (mismatch) {\n throw new Error(mismatch);\n }\n },\n toBeDefined: () => {\n if (actual === undefined) {\n throw new Error(\"Expected value to be defined.\");\n }\n },\n toBeUndefined: () => {\n if (actual !== undefined) {\n throw new Error(\n `Expected value to be undefined, but received '${String(actual)}'.`,\n );\n }\n },\n toBeNull: () => {\n if (actual !== null) {\n throw new Error(\n `Expected value to be null, but received '${String(actual)}'.`,\n );\n }\n },\n toContain: (expected: unknown) => {\n if (Array.isArray(actual)) {\n if (!actual.includes(expected)) {\n throw new Error(\"Expected array to contain value.\");\n }\n return;\n }\n if (typeof actual === \"string\") {\n if (!actual.includes(String(expected))) {\n throw new Error(\"Expected string to contain value.\");\n }\n return;\n }\n throw new Error(\"toContain expects an array or string actual value.\");\n },\n toContainEqual: (expected: unknown) => {\n if (!Array.isArray(actual)) {\n throw new Error(\"toContainEqual expects an array actual value.\");\n }\n if (!actual.some((value) => isDeepStrictEqual(value, expected))) {\n throw new Error(\"Expected array to contain an equal value.\");\n }\n },\n toHaveLength: (expected: number) => {\n assertLength(actual, expected);\n },\n toBeGreaterThanOrEqual: (expected: number) => {\n if (typeof actual !== \"number\") {\n throw new Error(\n \"toBeGreaterThanOrEqual expects a number actual value.\",\n );\n }\n if (actual < expected) {\n throw new Error(`Expected ${actual} to be >= ${expected}.`);\n }\n },\n toThrow: (predicate) => {\n assertThrown(actual, predicate);\n },\n toMatchSnapshot: (filename) => {\n if (!options.matchSnapshot) {\n throw new Error(\n \"Snapshot matching is not configured for this expect API.\",\n );\n }\n options.matchSnapshot(filename, actual);\n },\n toRejectWith: (expected) => createSubmissionErrorMatcher(actual, expected),\n toHaveInteraction: (interactionId, opts) => {\n const descriptors = asDescriptorList(actual);\n const descriptor = findInteraction(descriptors, interactionId);\n if (!descriptor) {\n throw new Error(`Expected interaction '${interactionId}' to exist.`);\n }\n assertDescriptorMatches(descriptor, opts);\n },\n toBeGatedBy: (reason, opts) => {\n const descriptor = Array.isArray(actual)\n ? (() => {\n if (!opts?.interactionId) {\n throw new Error(\n \"toBeGatedBy on a descriptor array requires opts.interactionId.\",\n );\n }\n return findInteraction(\n asDescriptorList(actual),\n opts.interactionId,\n );\n })()\n : (actual as InteractionDescriptorLike | null);\n if (!descriptor) {\n throw new Error(\"Expected interaction descriptor to exist.\");\n }\n if (descriptor.available !== false) {\n throw new Error(\"Expected interaction to be unavailable.\");\n }\n if (descriptor.unavailableReason !== reason) {\n throw new Error(\n `Expected unavailableReason '${reason}', received '${\n descriptor.unavailableReason ?? \"undefined\"\n }'.`,\n );\n }\n },\n toBeActiveFor: (playerId, opts) => {\n const descriptor = Array.isArray(actual)\n ? (() => {\n if (!opts?.interactionId) {\n throw new Error(\n \"toBeActiveFor on a descriptor array requires opts.interactionId.\",\n );\n }\n return findInteraction(\n asDescriptorList(actual),\n opts.interactionId,\n );\n })()\n : (actual as InteractionDescriptorLike | null);\n if (!descriptor) {\n throw new Error(\"Expected interaction descriptor to exist.\");\n }\n if (descriptor.context?.to !== playerId) {\n throw new Error(\n `Expected interaction to target '${playerId}', received '${\n descriptor.context?.to ?? \"undefined\"\n }'.`,\n );\n }\n if (descriptor.available !== true) {\n throw new Error(\"Expected interaction to be available.\");\n }\n },\n not: {\n toHaveInteraction: (interactionId) => {\n const descriptors = asDescriptorList(actual);\n if (findInteraction(descriptors, interactionId)) {\n throw new Error(\n `Expected interaction '${interactionId}' to be absent.`,\n );\n }\n },\n },\n });\n\n return (actual: unknown) => buildMatchers(actual);\n}\n","import type {\n HostPlayerGameplayView,\n HostSessionContext,\n HostSessionSnapshot,\n SeatAssignment,\n} from \"@dreamboard/api-client\";\nimport type { ReducerBundleContract } from \"@dreamboard/reducer-contract/bundle\";\nimport type * as Wire from \"@dreamboard/reducer-contract/wire\";\nimport type { PluginStateSnapshot } from \"@dreamboard/ui-sdk/reducer\";\nimport type {\n PluginSessionState,\n RuntimeAPI,\n SubmissionError,\n ValidationResult,\n} from \"@dreamboard/ui-sdk\";\nimport {\n createUnifiedSessionStore,\n type GameplayViewport,\n type SessionContext,\n type SSEManagerLike,\n} from \"@dreamboard/ui-host-runtime/runtime\";\n\ntype ReducerStaticProjection = Wire.BoardStaticProjection;\ntype ReducerBundleLike = Pick<\n ReducerBundleContract,\n \"projectSeatsDynamic\" | \"projectStatic\" | \"validateInput\" | \"dispatch\"\n>;\n\ntype BaseStateArtifact = {\n snapshot: Wire.ReducerSessionState;\n fingerprint: {\n players: number;\n };\n};\n\nexport type CreateTestRuntimeOptions = {\n baseId: string;\n baseStates: Record<string, BaseStateArtifact>;\n bundle: ReducerBundleLike;\n phase?: string;\n playerIds?: readonly string[];\n sessionId?: string;\n userId?: string | null;\n gameId?: string;\n displayNameByPlayerId?: Record<string, string>;\n};\n\nexport type CreatedTestRuntime = {\n runtime: RuntimeAPI & {\n getSnapshot(): PluginStateSnapshot;\n subscribeToState(\n listener: (state: PluginStateSnapshot) => void,\n ): () => void;\n _subscribeToSessionState(\n listener: (state: PluginSessionState) => void,\n ): () => void;\n };\n getSnapshot(): PluginStateSnapshot;\n players(): readonly string[];\n seat(index: number): string;\n submit(\n playerId: string,\n interactionId: string,\n params?: unknown,\n ): Promise<void>;\n validate(\n playerId: string,\n interactionId: string,\n params?: unknown,\n ): Promise<ValidationResult>;\n setControllingPlayer(playerId: string): void;\n};\n\nfunction cloneState<T>(value: T): T {\n return structuredClone(value);\n}\n\nfunction createSubmissionError(\n errorCode: string | undefined,\n message: string | undefined,\n): SubmissionError {\n const error = new Error(message ?? \"Interaction rejected\") as SubmissionError;\n error.name = \"SubmissionError\";\n error.errorCode = errorCode;\n return error;\n}\n\nfunction readFlowState(state: Wire.ReducerSessionState): {\n currentPhase: string | null;\n activePlayers: string[];\n} {\n const flow = ((\n state.domain as\n | { flow?: { currentPhase?: string; activePlayers?: string[] } }\n | undefined\n )?.flow ?? {}) as {\n currentPhase?: string;\n activePlayers?: string[];\n };\n return {\n currentPhase: flow.currentPhase ?? null,\n activePlayers: Array.isArray(flow.activePlayers) ? flow.activePlayers : [],\n };\n}\n\nfunction buildSeatAssignments(\n playerIds: readonly string[],\n userId: string | null,\n displayNameByPlayerId: Record<string, string> | undefined,\n): SeatAssignment[] {\n const actor =\n userId != null ? { kind: \"AUTH_USER\" as const, id: userId } : undefined;\n return playerIds.map((playerId) => ({\n playerId,\n controllerActor: actor,\n displayName: displayNameByPlayerId?.[playerId] ?? playerId,\n }));\n}\n\nfunction resolvePlayerIds(options: {\n baseState: BaseStateArtifact;\n explicitPlayerIds?: readonly string[];\n}): string[] {\n if (options.explicitPlayerIds && options.explicitPlayerIds.length > 0) {\n return [...options.explicitPlayerIds];\n }\n return Array.from(\n { length: options.baseState.fingerprint.players },\n (_, index) => `player-${index + 1}`,\n );\n}\n\n// Stub SSE manager for the in-memory store. `createTestRuntime` never\n// connects to a live backend; updates are delivered through\n// `applyGameplaySnapshotLocal(...)` instead.\nfunction createStubSseManager(): SSEManagerLike {\n return {\n connect: () => undefined,\n disconnect: () => undefined,\n on: () => () => undefined,\n onAnyMessage: () => () => undefined,\n };\n}\n\nfunction buildGameplaySnapshot(options: {\n state: Wire.ReducerSessionState;\n bundle: ReducerBundleLike;\n staticProjection: ReducerStaticProjection | null;\n playerId: string;\n version: number;\n expectedPhase: string | undefined;\n baseId: string;\n}): HostPlayerGameplayView {\n const projection = options.bundle.projectSeatsDynamic({\n state: options.state,\n playerIds: [options.playerId],\n });\n\n const flow = readFlowState(options.state);\n if (options.expectedPhase && flow.currentPhase !== options.expectedPhase) {\n throw new Error(\n `Expected base '${options.baseId}' to be in phase '${options.expectedPhase}', received '${\n flow.currentPhase ?? \"null\"\n }'.`,\n );\n }\n\n const seats = projection.seats ?? {};\n const seat = seats[options.playerId];\n\n return {\n version: options.version,\n actionSetVersion: `${options.version}:test`,\n playerId: options.playerId,\n activePlayers: flow.activePlayers,\n currentPhase: flow.currentPhase ?? \"\",\n currentStage: projection.currentStage ?? \"\",\n stageSeats: projection.stageSeats ?? [],\n view: JSON.stringify(seat?.view ?? null),\n availableInteractions:\n (seat?.availableInteractions as HostPlayerGameplayView[\"availableInteractions\"]) ??\n [],\n zones: (seat?.zones as HostPlayerGameplayView[\"zones\"]) ?? {},\n boardStatic: options.staticProjection\n ? JSON.stringify(options.staticProjection.view)\n : undefined,\n boardStaticHash: options.staticProjection?.hash,\n };\n}\n\nfunction createHostContext(options: {\n sessionId: string;\n userId: string;\n gameId: string;\n phase: HostSessionContext[\"phase\"];\n hostActor: { kind: \"AUTH_USER\"; id: string };\n switchablePlayerIds: string[];\n}): HostSessionContext {\n return {\n sessionId: options.sessionId,\n shortCode: options.sessionId,\n phase: options.phase,\n status: \"active\",\n hostActor: options.hostActor,\n gameSource: {\n kind: \"USER_COMPILED\",\n ownerUserId: options.userId,\n gameId: options.gameId,\n compiledResultId: \"00000000-0000-0000-0000-000000000000\",\n },\n switchablePlayerIds: options.switchablePlayerIds,\n history: {\n entries: [],\n currentIndex: -1,\n canGoBack: false,\n canGoForward: false,\n },\n };\n}\n\nfunction createRuntimeSessionContext(options: {\n sessionId: string;\n userId: string;\n gameId: string;\n hostActor: { kind: \"AUTH_USER\"; id: string };\n switchablePlayerIds: string[];\n seats: SeatAssignment[];\n canStart: boolean;\n}): SessionContext {\n return {\n identity: {\n sessionId: options.sessionId,\n shortCode: options.sessionId,\n gameId: options.gameId,\n },\n userId: options.userId,\n seats: options.seats,\n canStart: options.canStart,\n hostActor: options.hostActor,\n switchablePlayerIds: options.switchablePlayerIds,\n history: {\n entries: [],\n currentIndex: -1,\n canGoBack: false,\n canGoForward: false,\n },\n };\n}\n\nfunction gameplayViewportFromSnapshot(\n snapshot: HostPlayerGameplayView,\n): GameplayViewport {\n return {\n version: snapshot.version,\n actionSetVersion: snapshot.actionSetVersion,\n activePlayers: snapshot.activePlayers,\n currentPhase: snapshot.currentPhase,\n currentStage: snapshot.currentStage,\n stageSeats: snapshot.stageSeats,\n simultaneousPhase: snapshot.simultaneousPhase ?? null,\n view: JSON.parse(snapshot.view) as GameplayViewport[\"view\"],\n availableInteractions: snapshot.availableInteractions,\n zones: snapshot.zones,\n boardStatic: snapshot.boardStatic\n ? (JSON.parse(snapshot.boardStatic) as Record<string, unknown>)\n : null,\n boardStaticHash: snapshot.boardStaticHash ?? null,\n };\n}\n\n// Reuses `packages/ui-host-runtime`'s unified session store so the\n// `getPluginSnapshot()` projection and `applyGameplaySnapshotLocal(...)`\n// reducer running inside workspace tests are the same code paths\n// running inside the host app. Prevents snapshot-shape drift between\n// host plugin UI and authored UI tests.\nexport function createTestRuntime(\n options: CreateTestRuntimeOptions,\n): CreatedTestRuntime {\n const baseState = options.baseStates[options.baseId];\n if (!baseState) {\n throw new Error(`Unknown test base '${options.baseId}'.`);\n }\n\n let currentState = cloneState(baseState.snapshot);\n const playerIds = resolvePlayerIds({\n baseState,\n explicitPlayerIds: options.playerIds,\n });\n const userId = options.userId ?? \"test-user\";\n const sessionId = options.sessionId ?? \"test-session\";\n const gameId = options.gameId ?? \"test-game\";\n const seats = buildSeatAssignments(\n playerIds,\n userId,\n options.displayNameByPlayerId,\n );\n const storeApi = createUnifiedSessionStore({\n createSseManager: createStubSseManager,\n // Test runtimes keep `userId` present so the unified store derives\n // controllable player ids from seat assignments whenever the\n // incoming snapshot omits `controllablePlayerIds`.\n fallbackToAllSeatsWhenUserIdMissing: false,\n });\n\n const hostActor = { kind: \"AUTH_USER\" as const, id: userId };\n const lobbySnapshot: HostSessionSnapshot = {\n type: \"lobby\",\n context: createHostContext({\n sessionId,\n userId,\n gameId,\n phase: \"lobby\",\n hostActor,\n switchablePlayerIds: playerIds,\n }),\n lobby: {\n seats,\n canStart: true,\n hostActor,\n },\n };\n const setSessionState = (input: {\n selectedPlayerId: string;\n gameplay?: HostPlayerGameplayView;\n }): void => {\n const context = createRuntimeSessionContext({\n sessionId,\n userId,\n gameId,\n hostActor,\n switchablePlayerIds: playerIds,\n seats,\n canStart: true,\n });\n storeApi.setState((state) => ({\n ...state,\n session: input.gameplay\n ? {\n type: \"gameplay\",\n context,\n perspective: { playerId: input.selectedPlayerId },\n gameplay: gameplayViewportFromSnapshot(input.gameplay),\n }\n : {\n type: \"lobby\",\n context,\n preferredPlayerId: input.selectedPlayerId || null,\n },\n connection: { ...state.connection, error: null },\n activity: {\n ...state.activity,\n syncId: state.activity.syncId + 1,\n lastSyncTimestamp: Date.now(),\n },\n }));\n };\n\n setSessionState({\n selectedPlayerId: playerIds[0] ?? \"\",\n });\n\n let version = 0;\n let currentPlayerId = playerIds[0] ?? \"\";\n const staticProjection = options.bundle.projectStatic?.() ?? null;\n\n const applyCurrentState = (): void => {\n version += 1;\n const snapshot = buildGameplaySnapshot({\n state: currentState,\n bundle: options.bundle,\n staticProjection,\n playerId: currentPlayerId,\n version,\n expectedPhase: version === 1 ? options.phase : undefined,\n baseId: options.baseId,\n });\n setSessionState({\n selectedPlayerId: currentPlayerId,\n gameplay: snapshot,\n });\n };\n\n applyCurrentState();\n\n const stateListeners = new Set<(state: PluginStateSnapshot) => void>();\n const sessionListeners = new Set<(state: PluginSessionState) => void>();\n\n let lastPluginSnapshot = storeApi.getState().getPluginSnapshot();\n let lastSessionState: PluginSessionState = {\n ...lastPluginSnapshot.session,\n status: \"ready\",\n };\n\n storeApi.subscribe((state, previous) => {\n const nextPluginSnapshot = state.getPluginSnapshot();\n if (nextPluginSnapshot !== lastPluginSnapshot) {\n lastPluginSnapshot = nextPluginSnapshot;\n for (const listener of stateListeners) {\n listener(nextPluginSnapshot);\n }\n }\n const previousSession = previous.getPluginSnapshot().session;\n const nextSession = nextPluginSnapshot.session;\n const controllingPlayerChanged =\n nextSession.controllingPlayerId !== previousSession.controllingPlayerId;\n const controllableIdsChanged =\n nextSession.controllablePlayerIds.join(\"\\0\") !==\n previousSession.controllablePlayerIds.join(\"\\0\");\n if (controllingPlayerChanged || controllableIdsChanged) {\n lastSessionState = {\n ...nextPluginSnapshot.session,\n status: \"ready\",\n };\n for (const listener of sessionListeners) {\n listener(lastSessionState);\n }\n }\n });\n\n const validate = async (\n playerId: string,\n interactionId: string,\n params: unknown = {},\n ): Promise<ValidationResult> => {\n const result = await options.bundle.validateInput({\n state: currentState,\n input: {\n kind: \"interaction\",\n playerId,\n interactionId,\n params: params as Wire.JsonValue,\n },\n });\n return {\n valid: result.valid,\n errorCode: result.errorCode,\n message: result.message,\n };\n };\n\n const submit = async (\n playerId: string,\n interactionId: string,\n params: unknown = {},\n ): Promise<void> => {\n const validation = await validate(playerId, interactionId, params);\n if (!validation.valid) {\n throw createSubmissionError(validation.errorCode, validation.message);\n }\n const result = await options.bundle.dispatch({\n state: currentState,\n input: {\n kind: \"interaction\",\n playerId,\n interactionId,\n params: params as Wire.JsonValue,\n },\n });\n if (result.kind === \"reject\") {\n throw createSubmissionError(result.errorCode, result.message);\n }\n currentState = cloneState(result.state);\n applyCurrentState();\n };\n\n const setControllingPlayer = (playerId: string): void => {\n if (!playerIds.includes(playerId)) {\n throw new Error(`Unknown controlling player '${playerId}'.`);\n }\n currentPlayerId = playerId;\n storeApi.getState().selectPlayer(playerId);\n applyCurrentState();\n };\n\n const runtime = {\n validateInteraction: validate,\n submitInteraction: submit,\n getSessionState: (): PluginSessionState => ({ ...lastSessionState }),\n disconnect: () => undefined,\n switchPlayer: (playerId: string) => {\n setControllingPlayer(playerId);\n },\n getSnapshot: (): PluginStateSnapshot => lastPluginSnapshot,\n subscribeToState: (listener: (state: PluginStateSnapshot) => void) => {\n stateListeners.add(listener);\n return () => {\n stateListeners.delete(listener);\n };\n },\n _subscribeToSessionState: (\n listener: (state: PluginSessionState) => void,\n ) => {\n sessionListeners.add(listener);\n return () => {\n sessionListeners.delete(listener);\n };\n },\n };\n\n return {\n runtime,\n getSnapshot: () => lastPluginSnapshot,\n players: () => [...playerIds],\n seat: (index: number) => {\n if (!Number.isInteger(index) || index < 0 || index >= playerIds.length) {\n throw new Error(\n `seat(${index}) is out of range; base '${options.baseId}' has ${playerIds.length} player(s).`,\n );\n }\n return playerI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