@dreamboard-games/sdk 0.5.0-alpha.7 → 0.5.0-alpha.9

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/index.js CHANGED
@@ -5,7 +5,7 @@ import {
5
5
  createGestureRecognizer,
6
6
  isSameDropTarget,
7
7
  runtimeFeatures
8
- } from "./chunk-HZPKKBEG.js";
8
+ } from "./chunk-ZH5BENBP.js";
9
9
  import {
10
10
  BoardStaticProjectionSchema,
11
11
  CancelInteractionCommandSchema,
@@ -40,7 +40,7 @@ import {
40
40
  parsePluginSessionDescriptor,
41
41
  parsePluginToHostEnvelope,
42
42
  staticSource
43
- } from "./chunk-N37D7NPB.js";
43
+ } from "./chunk-QHYXNDJS.js";
44
44
  import "./chunk-DMFVAZI2.js";
45
45
  import {
46
46
  InputDomainSchema,
@@ -49,17 +49,18 @@ import {
49
49
  InteractionDescriptorSchema,
50
50
  InteractionInputDescriptorSchema,
51
51
  RuntimeJsonSchema,
52
+ ViewCardSchema,
52
53
  canonicalizePluginRuntimeJson,
53
54
  createHexBoardGeometry,
54
55
  digestPluginRuntimeJson,
55
56
  encodeCanonicalPluginRuntimeJson
56
- } from "./chunk-K75F5UIJ.js";
57
+ } from "./chunk-FUYMFUXO.js";
57
58
  import {
58
59
  requireLookup
59
- } from "./chunk-3JXUL4VN.js";
60
+ } from "./chunk-DPRHGA2C.js";
60
61
 
61
62
  // src/package-set.ts
62
- var DREAMBOARD_SDK_VERSION = true ? "0.5.0-alpha.7" : "0.0.0-development";
63
+ var DREAMBOARD_SDK_VERSION = true ? "0.5.0-alpha.9" : "0.0.0-development";
63
64
  var DREAMBOARD_SDK_PACKAGES = {
64
65
  "@dreamboard-games/sdk": DREAMBOARD_SDK_VERSION
65
66
  };
@@ -139,7 +140,7 @@ function iframeSource(options = {}) {
139
140
  }
140
141
 
141
142
  // src/shared/protocol/gameplay-wire.ts
142
- import { z } from "zod";
143
+ import * as z from "zod";
143
144
  var GameplayCloseCode = {
144
145
  GoingAway: 1001,
145
146
  CredentialExpired: 4e3,
@@ -1257,6 +1258,7 @@ export {
1257
1258
  SimultaneousPhaseSnapshotSchema,
1258
1259
  SubmitInteractionCommandSchema,
1259
1260
  SystemActionEventSchema,
1261
+ ViewCardSchema,
1260
1262
  ZoneHandlesSnapshotSchema,
1261
1263
  boardFeature,
1262
1264
  canonicalizePluginRuntimeJson,
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/package-set.ts","../src/headless/sources/iframe.ts","../src/shared/protocol/gameplay-wire.ts","../src/headless/sources/host-websocket.ts","../src/headless/features/hand.ts","../src/headless/features/board.ts","../src/headless/features/drag.ts","../src/headless/features/pointer-session.ts","../src/headless/features/pan-zoom.ts","../src/headless/features/origins.ts","../src/headless/fan.ts"],"sourcesContent":["declare const __DREAMBOARD_SDK_VERSION__: string;\n\nexport const DREAMBOARD_SDK_VERSION =\n typeof __DREAMBOARD_SDK_VERSION__ === \"string\"\n ? __DREAMBOARD_SDK_VERSION__\n : \"0.0.0-development\";\n\nexport const DREAMBOARD_SDK_PACKAGES = {\n \"@dreamboard-games/sdk\": DREAMBOARD_SDK_VERSION,\n} as const;\n\nexport type DreamboardSdkPackageName = keyof typeof DREAMBOARD_SDK_PACKAGES;\n\nexport type DreamboardSdkPackageSet = {\n version: 1;\n sdkVersion: string;\n packages: Record<DreamboardSdkPackageName, string>;\n};\n\nexport const DREAMBOARD_SDK_PACKAGE_SET: DreamboardSdkPackageSet = {\n version: 1,\n sdkVersion: DREAMBOARD_SDK_VERSION,\n packages: DREAMBOARD_SDK_PACKAGES,\n};\n","import {\n DREAMBOARD_PLUGIN_PROTOCOL,\n DREAMBOARD_PLUGIN_PROTOCOL_VERSION,\n} from \"../../shared/protocol/protocol.js\";\nimport { HostToPluginEnvelopeSchema } from \"../../shared/protocol/schema.js\";\nimport type { PluginToHostPayload } from \"../../shared/protocol/protocol.js\";\nimport { createSourceLifecycle } from \"./lifecycle.js\";\nimport type { CommandSource } from \"./types.js\";\n\n/** Pins its parent window, origin and channel at the first valid initialization. */\nexport function iframeSource(\n options: {\n timeoutMs?: number;\n } = {},\n): CommandSource {\n const target = window;\n const parent = target.parent;\n let channel: { id: string; origin: string } | null = null;\n let sequence = 0;\n let receivedSequence = -1;\n const send = (payload: PluginToHostPayload) => {\n if (!channel) throw new Error(\"Iframe source is not initialized.\");\n parent.postMessage(\n {\n protocol: DREAMBOARD_PLUGIN_PROTOCOL,\n version: DREAMBOARD_PLUGIN_PROTOCOL_VERSION,\n channelId: channel.id,\n sequence: ++sequence,\n payload,\n },\n channel.origin,\n );\n };\n const lifecycle = createSourceLifecycle({\n timeoutMs: options.timeoutMs,\n send,\n recover: () => send({ type: \"runtime.resume\" }),\n close: () => target.removeEventListener(\"message\", receive),\n });\n const isOpen = () => {\n const { connection } = lifecycle.source.store.get();\n return connection !== \"closed\" && connection !== \"failed\";\n };\n function receive(event: MessageEvent) {\n if (event.source !== parent) return;\n const parsed = HostToPluginEnvelopeSchema.safeParse(event.data);\n if (!parsed.success) {\n const data: unknown = event.data;\n if (\n channel &&\n event.origin === channel.origin &&\n typeof data === \"object\" &&\n data !== null &&\n \"channelId\" in data &&\n data.channelId === channel.id\n ) {\n try {\n send({\n type: \"runtime.error\",\n code: \"host-runtime-protocol-mismatch\",\n message: \"Iframe source received an invalid host envelope.\",\n });\n } finally {\n lifecycle.fail(new Error(\"Invalid iframe host envelope.\"));\n }\n }\n return;\n }\n const envelope = parsed.data;\n if (!channel) {\n if (envelope.payload.type !== \"runtime.init\") return;\n channel = { id: envelope.channelId, origin: event.origin };\n }\n if (\n channel.id !== envelope.channelId ||\n channel.origin !== event.origin ||\n envelope.sequence <= receivedSequence\n )\n return;\n receivedSequence = envelope.sequence;\n const payload = envelope.payload;\n if (payload.type === \"runtime.init\") {\n lifecycle.session(payload.session);\n if (isOpen()) send({ type: \"runtime.ready\" });\n } else if (payload.type === \"gameplay.frame\")\n lifecycle.frame(payload.frame);\n else lifecycle.result(payload);\n if (isOpen()) send({ type: \"runtime.ack\", sequence: envelope.sequence });\n }\n target.addEventListener(\"message\", receive);\n return lifecycle.source;\n}\n","import { z } from \"zod\";\nimport {\n InteractionResultSchema,\n PluginGameplayFrameSchema,\n SubmitInteractionCommandSchema,\n CancelInteractionCommandSchema,\n} from \"./schema.js\";\nexport const GameplayCloseCode = {\n GoingAway: 1001,\n CredentialExpired: 4000,\n CredentialInvalid: 4001,\n RefreshContextMismatch: 4002,\n PermissionDenied: 4100,\n ProtocolViolation: 4200,\n FrameBeforeAuth: 4201,\n SlowConsumer: 4300,\n TooManyRequests: 4301,\n} as const;\n\nexport const GameplayCredentialSchema = z.discriminatedUnion(\"kind\", [\n z\n .object({ kind: z.literal(\"user\"), token: z.string().min(1).max(16384) })\n .strict(),\n z\n .object({ kind: z.literal(\"demo\"), secret: z.string().min(1).max(1024) })\n .strict(),\n]);\nexport const AuthConnectFrameSchema = z\n .object({\n type: z.literal(\"auth.connect\"),\n credential: GameplayCredentialSchema,\n sessionId: z.string().uuid(),\n playerId: z.string().min(1).max(128),\n })\n .strict();\nexport const AuthRefreshFrameSchema = z\n .object({\n type: z.literal(\"auth.refresh\"),\n credential: GameplayCredentialSchema,\n })\n .strict();\n\nexport const SessionResumeFrameSchema = z.object({\n type: z.literal(\"session.resume\"),\n lastSeenLogCursor: z.number().int().nonnegative().nullable(),\n unacknowledgedClientActionIds: z.array(z.string().min(1)).max(32),\n});\n\nexport const AuthAcceptedFrameSchema = z.object({\n type: z.literal(\"auth.accepted\"),\n expiresAt: z.string().datetime(),\n});\n\nexport const GameplayBackpressureReasonSchema = z.enum([\n \"queue_full\",\n \"capacity_full\",\n]);\n\nexport const GameplayBackpressureOperationSchema = z.enum([\n \"session.resume\",\n \"interaction.submit\",\n \"interaction.cancel\",\n]);\nexport const GameplayBackpressureFrameSchema = z.object({\n type: z.literal(\"gameplay.backpressure\"),\n reason: GameplayBackpressureReasonSchema,\n retryAfterMs: z.number().int().positive(),\n message: z.string().min(1),\n operation: GameplayBackpressureOperationSchema,\n clientActionId: z.string().min(1).optional(),\n});\nexport const SessionSnapshotFrameSchema = z.object({\n type: z.literal(\"session.snapshot\"),\n frame: PluginGameplayFrameSchema,\n});\nexport const ClientGameplayFrameSchema = z.discriminatedUnion(\"type\", [\n AuthConnectFrameSchema,\n AuthRefreshFrameSchema,\n SessionResumeFrameSchema,\n SubmitInteractionCommandSchema,\n CancelInteractionCommandSchema,\n]);\nexport const ServerGameplayFrameSchema = z.discriminatedUnion(\"type\", [\n AuthAcceptedFrameSchema,\n GameplayBackpressureFrameSchema,\n SessionSnapshotFrameSchema,\n InteractionResultSchema,\n]);\nexport type GameplayCredential = z.infer<typeof GameplayCredentialSchema>;\nexport type ClientGameplayFrame = z.infer<typeof ClientGameplayFrameSchema>;\nexport type ServerGameplayFrame = z.infer<typeof ServerGameplayFrameSchema>;\n","import type { PluginSessionDescriptor } from \"../../shared/protocol/frame.js\";\nimport {\n ClientGameplayFrameSchema,\n ServerGameplayFrameSchema,\n GameplayCloseCode,\n type ClientGameplayFrame,\n type GameplayCredential,\n} from \"../../shared/protocol/gameplay-wire.js\";\nimport { createSourceLifecycle } from \"./lifecycle.js\";\nimport type { CommandSource, SourceCommand } from \"./types.js\";\n\nexport function hostSource(options: {\n url: string;\n session: PluginSessionDescriptor;\n playerId: string;\n getCredential(): Promise<GameplayCredential>;\n timeoutMs?: number;\n}): CommandSource {\n const { url, playerId, getCredential } = options;\n const sessionId = options.session.sessionId;\n let socket: WebSocket | null = null;\n let generation = 0;\n let disposed = false;\n let authenticated = false;\n let queued: SourceCommand | null = null;\n let reconnects = 0;\n let refreshTimer: ReturnType<typeof setTimeout> | undefined;\n let snapshotTimer: ReturnType<typeof setTimeout> | undefined;\n let openTimer: ReturnType<typeof setTimeout> | undefined;\n let cleanup = () => {};\n const timeoutMs = options.timeoutMs ?? 10_000;\n const send = (frame: ClientGameplayFrame) => {\n if (!socket || socket.readyState !== WebSocket.OPEN)\n throw new Error(\"Gameplay socket is not open.\");\n socket.send(JSON.stringify(ClientGameplayFrameSchema.parse(frame)));\n };\n const resume = () =>\n send({\n type: \"session.resume\",\n lastSeenLogCursor: null,\n unacknowledgedClientActionIds: queued ? [queued.clientActionId] : [],\n });\n const lifecycle = createSourceLifecycle({\n context: {\n sessionId,\n playerId,\n },\n timeoutMs,\n send(command) {\n if (!authenticated) {\n queued = command;\n return;\n }\n send(command);\n },\n recover() {\n if (authenticated) resume();\n else if (!openTimer) void connect();\n },\n close() {\n disposed = true;\n generation++;\n clearTimeout(refreshTimer);\n clearTimeout(openTimer);\n clearTimeout(snapshotTimer);\n cleanup();\n socket?.close();\n socket = null;\n queued = null;\n },\n });\n lifecycle.session(options.session);\n async function connect() {\n if (disposed) return;\n const current = ++generation;\n authenticated = false;\n clearTimeout(refreshTimer);\n clearTimeout(openTimer);\n clearTimeout(snapshotTimer);\n cleanup();\n socket?.close();\n socket = null;\n openTimer = setTimeout(\n () =>\n lifecycle.fail(new Error(\"Gameplay socket authentication timed out.\")),\n timeoutMs,\n );\n try {\n const credential = await getCredential();\n if (disposed || current !== generation) return;\n const next = new WebSocket(url);\n socket = next;\n const active = () => !disposed && current === generation;\n const onOpen = () => {\n if (!active()) return;\n try {\n send({\n type: \"auth.connect\",\n credential,\n sessionId,\n playerId,\n });\n } catch (error) {\n lifecycle.fail(asError(error));\n }\n };\n const onMessage = (event: MessageEvent) => {\n if (!active()) return;\n try {\n const value: unknown = JSON.parse(String(event.data));\n if (typeof value !== \"object\" || value === null || !(\"type\" in value))\n throw new Error(\"Invalid gameplay frame.\");\n if (\n ![\n \"auth.accepted\",\n \"session.snapshot\",\n \"interaction.result\",\n \"gameplay.backpressure\",\n ].includes(String(value.type))\n )\n return;\n const frame = ServerGameplayFrameSchema.parse(value);\n if (frame.type === \"auth.accepted\") {\n clearTimeout(openTimer);\n openTimer = undefined;\n const first = !authenticated;\n authenticated = true;\n if (first) {\n snapshotTimer = setTimeout(\n () => lifecycle.fail(new Error(\"Gameplay snapshot timed out.\")),\n timeoutMs,\n );\n resume();\n if (queued) {\n send(queued);\n queued = null;\n }\n }\n clearTimeout(refreshTimer);\n if (credential.kind === \"user\") {\n const ttl = Date.parse(frame.expiresAt) - Date.now();\n if (ttl <= 0)\n throw new Error(\"Gameplay credential is already expired.\");\n refreshTimer = setTimeout(\n () => {\n openTimer = setTimeout(\n () =>\n lifecycle.fail(\n new Error(\"Gameplay credential refresh timed out.\"),\n ),\n timeoutMs,\n );\n void getCredential()\n .then((updated) => {\n if (active())\n send({ type: \"auth.refresh\", credential: updated });\n })\n .catch((error) => {\n if (active()) lifecycle.fail(asError(error));\n });\n },\n Math.max(0, ttl - Math.min(60_000, ttl * 0.2)),\n );\n }\n } else if (!authenticated)\n throw new Error(\"Gameplay frame arrived before authentication.\");\n else if (frame.type === \"session.snapshot\") {\n clearTimeout(snapshotTimer);\n snapshotTimer = undefined;\n reconnects = 0;\n lifecycle.frame(frame.frame);\n } else if (frame.type === \"interaction.result\")\n lifecycle.result(frame);\n else lifecycle.fail(new Error(frame.message));\n } catch (error) {\n lifecycle.fail(asError(error));\n }\n };\n const onClose = (event: CloseEvent) => {\n if (!active()) return;\n authenticated = false;\n lifecycle.recovering();\n if (\n new Set<number>([\n GameplayCloseCode.CredentialInvalid,\n GameplayCloseCode.RefreshContextMismatch,\n GameplayCloseCode.PermissionDenied,\n GameplayCloseCode.ProtocolViolation,\n GameplayCloseCode.FrameBeforeAuth,\n ]).has(event.code) ||\n reconnects++ > 0\n ) {\n lifecycle.fail(new Error(`Gameplay socket closed (${event.code}).`));\n return;\n }\n void connect();\n lifecycle.retry();\n };\n const onError = () => {\n if (active()) next.close();\n };\n next.addEventListener(\"open\", onOpen);\n next.addEventListener(\"message\", onMessage);\n next.addEventListener(\"close\", onClose);\n next.addEventListener(\"error\", onError);\n cleanup = () => {\n next.removeEventListener(\"open\", onOpen);\n next.removeEventListener(\"message\", onMessage);\n next.removeEventListener(\"close\", onClose);\n next.removeEventListener(\"error\", onError);\n };\n } catch (error) {\n if (!disposed && current === generation) lifecycle.fail(asError(error));\n }\n }\n void connect();\n return lifecycle.source;\n}\nfunction asError(error: unknown): Error {\n return error instanceof Error ? error : new Error(String(error));\n}\n","import type { Card, CoreInstance, SeatCardId, Zone } from \"../model.js\";\n\nexport interface HandOptions<G> {\n /** Compare projected card data only; hidden cards never expose private fields. */\n readonly sort?: (\n left: Card<G, Record<never, never>>,\n right: Card<G, Record<never, never>>,\n ) => number;\n}\n\n// Generic G defers the card visibility union, so ids widen to string here.\nconst seatCardId = <G>(card: { readonly id: string }) =>\n card.id as SeatCardId<G>;\n\n/** Optional hand helpers reuse the zone order and the core selection router. */\nexport function handFeature<G>(\n _game: CoreInstance<G>,\n options: HandOptions<G> = {},\n) {\n return {\n zone: {\n getSortedCardIds(\n this: Zone<G, Record<never, never>>,\n ): readonly SeatCardId<G>[] {\n return this.getCards({ sort: options.sort }).map(seatCardId<G>);\n },\n getSelectedCardIds(\n this: Zone<G, Record<never, never>>,\n ): readonly SeatCardId<G>[] {\n return this.getCards()\n .filter((card) => card.getIsSelected())\n .map(seatCardId<G>);\n },\n getSelectableCardIds(\n this: Zone<G, Record<never, never>>,\n ): readonly SeatCardId<G>[] {\n return this.getCards()\n .filter((card) => card.getCanSelect())\n .map(seatCardId<G>);\n },\n },\n };\n}\n","import {\n runtimeFeatures,\n type RuntimeBoard,\n type RuntimeFeatureContext,\n type RuntimeFeatureSnapshot,\n type RuntimeCollection,\n} from \"../runtime-features.js\";\nimport type { RuntimeTargetOptions } from \"../targets.js\";\nimport type {\n BoardBase,\n BoardCollection,\n BoardSpaceCollection,\n BoardSpace,\n CoreInstance,\n FeatureContext,\n ReadonlyData,\n TargetOptions,\n ActionProps,\n} from \"../model.js\";\nimport type {\n RuntimeBoardSpaceState,\n RuntimeSquareBoardState,\n} from \"../../reducer/model/table.js\";\nimport { requireLookup } from \"../../shared/lookup.js\";\nimport { AmbiguousTargetError } from \"../instance.js\";\nimport { createHexBoardGeometry } from \"../../shared/hex-board.js\";\nimport type { Point } from \"./pointer-session.js\";\nimport type { ViewportTransform } from \"./pan-zoom.js\";\n\ninterface RuntimeSpace {\n readonly id: string;\n readonly data: ReadonlyData<RuntimeBoardSpaceState>;\n readonly board: RuntimeBoard;\n getIsEligible(): boolean;\n getIsSelectable(): boolean;\n getIsSelected(): boolean;\n getSelectHandler(options?: RuntimeTargetOptions): () => void;\n getTargetProps(options?: RuntimeTargetOptions): ActionProps;\n}\ntype TargetKind = \"space\" | \"edge\" | \"vertex\";\nexport interface BoardLayoutOptions {\n /** Hex radius, or square cell width and height. */\n readonly hexSize: number;\n readonly origin?: Point;\n readonly viewport?: ViewportTransform;\n}\ninterface Geometry {\n readonly viewBox: { x: number; y: number; width: number; height: number };\n readonly spaces: readonly {\n id: string;\n center: Point;\n corners: readonly Point[];\n }[];\n readonly edges: readonly { id: string; from: Point; to: Point }[];\n readonly vertices: readonly { id: string; center: Point }[];\n pointToSpace(point: Point): string | undefined;\n}\n\nfunction squareGeometry(\n board: ReadonlyData<RuntimeSquareBoardState>,\n size: number,\n origin: Point,\n): Geometry {\n const spaces = Object.values(board.spaces).map((space) => {\n const x = origin.x + space.col * size;\n const y = origin.y + space.row * size;\n return {\n id: space.id,\n center: { x: x + size / 2, y: y + size / 2 },\n corners: [\n { x, y },\n { x: x + size, y },\n { x: x + size, y: y + size },\n { x, y: y + size },\n ],\n };\n });\n const byId = new Map(spaces.map((space) => [space.id, space]));\n function sharedCorners(ids: readonly string[]) {\n const first = byId.get(ids[0] ?? \"\")?.corners ?? [];\n return first.filter((point) =>\n ids.every((id) =>\n byId\n .get(id)\n ?.corners.some(\n (candidate) => candidate.x === point.x && candidate.y === point.y,\n ),\n ),\n );\n }\n const points = spaces.flatMap((space) => space.corners);\n const xs = points.map((point) => point.x);\n const ys = points.map((point) => point.y);\n const x = xs.length ? Math.min(...xs) : 0;\n const y = ys.length ? Math.min(...ys) : 0;\n return {\n viewBox: {\n x,\n y,\n width: xs.length ? Math.max(...xs) - x : 0,\n height: ys.length ? Math.max(...ys) - y : 0,\n },\n spaces,\n // Incidence is authored. Only a unique geometric line/point is representable.\n edges: board.edges.flatMap((edge) => {\n const corners = sharedCorners(edge.spaceIds);\n return corners.length === 2\n ? [{ id: edge.id, from: corners[0], to: corners[1] }]\n : [];\n }),\n vertices: board.vertices.flatMap((vertex) => {\n const corners = sharedCorners(vertex.spaceIds);\n return corners.length === 1\n ? [{ id: vertex.id, center: corners[0] }]\n : [];\n }),\n pointToSpace(point) {\n const col = Math.floor((point.x - origin.x) / size);\n const row = Math.floor((point.y - origin.y) / size);\n return Object.values(board.spaces).find(\n (space) => space.col === col && space.row === row,\n )?.id;\n },\n };\n}\n\n/** Semantic board spaces and captured selection, with optional spatial geometry. */\nfunction createRuntimeBoardFeature(context: RuntimeFeatureContext) {\n const game = context.game;\n const captures = new WeakMap<\n object,\n {\n model: RuntimeFeatureSnapshot;\n source: ReturnType<typeof game.getOptions>[\"source\"];\n geometry?: ReturnType<typeof createHexBoardGeometry>;\n }\n >();\n const geometries = new WeakMap<\n object,\n ReturnType<typeof createHexBoardGeometry>\n >();\n let cached:\n | {\n view: unknown;\n interactions: RuntimeFeatureSnapshot[\"interactions\"];\n source: ReturnType<typeof game.getOptions>[\"source\"];\n collection: RuntimeCollection<RuntimeBoard>;\n }\n | undefined;\n function collection(): RuntimeCollection<RuntimeBoard> {\n const model = game.getSnapshot();\n const source = game.getOptions().source;\n if (\n cached &&\n cached.view === model.view &&\n cached.interactions === model.interactions &&\n cached.source === source\n )\n return cached.collection;\n const boards = Object.values(context.getBoards()).map((data) => {\n const board = context.createBoard(data);\n let geometry = geometries.get(data);\n if (!geometry && data.layout === \"hex\") {\n geometry = createHexBoardGeometry({\n id: data.baseId ?? data.id,\n orientation: data.orientation,\n spaces: Object.values(data.spaces),\n });\n geometries.set(data, geometry);\n }\n captures.set(board, { model, source, geometry });\n return board;\n });\n const byId = new Map(boards.map((board) => [board.id, board]));\n const result: RuntimeCollection<RuntimeBoard> = Object.freeze({\n get: (id: string) => requireLookup(byId.get(id), \"Board\", id),\n find: (id: string) => byId.get(id),\n getAll: () => Object.freeze(boards),\n });\n cached = {\n view: model.view,\n interactions: model.interactions,\n source,\n collection: result,\n };\n return result;\n }\n function targetsFor(owner: RuntimeBoard) {\n const board = owner.data;\n const captured = captures.get(owner)!;\n function matchingTargets(\n model: RuntimeFeatureSnapshot,\n kind: TargetKind,\n id: string,\n ) {\n const inputKinds = kind === \"space\" ? [\"space\", \"tile\"] : [kind];\n return model.interactions.list().flatMap((interaction) =>\n interaction\n .getInputs()\n .filter((input) => {\n const domain = input.getDomain();\n return (\n domain.type === \"boardTarget\" &&\n inputKinds.includes(String(domain.targetKind)) &&\n (domain.valueKind === \"player-board-space\"\n ? board.scope === \"perPlayer\" && domain.boardId === board.baseId\n : domain.boardId === board.id)\n );\n })\n .map((input) => {\n const domain = input.getDomain();\n return {\n interaction,\n input,\n value:\n domain.type === \"boardTarget\" &&\n domain.valueKind === \"player-board-space\"\n ? Object.freeze({\n boardId: board.baseId!,\n playerId: board.playerId!,\n spaceId: id,\n })\n : id,\n };\n }),\n );\n }\n function target(kind: TargetKind, id: string) {\n const matches = matchingTargets(captured.model, kind, id);\n const eligible = matches.some(({ input, value }) =>\n input.getIsEligible(value),\n );\n const selected = matches.some(({ input, value }) =>\n input.getIsSelected(value),\n );\n const selectable = matches.some(\n ({ input, value }) => !input.getTargetProps(value).disabled,\n );\n function select(options?: RuntimeTargetOptions) {\n if (\n game.getOptions().source !== captured.source ||\n game.snapshot?.me !== captured.model.snapshot?.me\n )\n return;\n const matching = matchingTargets(game.getSnapshot(), kind, id).filter(\n ({ interaction, input, value }) =>\n (!options?.interaction ||\n options.interaction === interaction.key) &&\n (!options?.input || options.input === input.key) &&\n !input.getTargetProps(value).disabled,\n );\n if (!matching.length) return;\n if (matching.length > 1) throw new AmbiguousTargetError(id);\n const domain = matching[0].input.getDomain();\n if (domain.type !== \"boardTarget\") return;\n const value = matching[0].value;\n const target =\n domain.valueKind === \"player-board-space\" && typeof value !== \"string\"\n ? { kind: \"space\" as const, valueKind: domain.valueKind, value }\n : {\n kind,\n valueKind: \"board-id\" as const,\n value: id,\n boardId: board.id,\n };\n context.routeTarget(target, {\n interaction: matching[0].interaction.key,\n input: matching[0].input.key,\n });\n }\n return {\n id,\n getIsEligible: () => eligible,\n getIsSelectable: () => selectable,\n getIsSelected: () => selected,\n getSelectHandler: (options?: RuntimeTargetOptions) => () =>\n select(options),\n getTargetProps(options?: RuntimeTargetOptions) {\n const candidates = matches.filter(\n ({ interaction, input, value }) =>\n (!options?.interaction ||\n interaction.key === options.interaction) &&\n (!options?.input || options.input === input.key) &&\n !input.getTargetProps(value).disabled,\n );\n const only = candidates.length === 1 ? candidates[0] : undefined;\n return {\n type: \"button\" as const,\n disabled: candidates.length === 0,\n \"data-action\": \"select\",\n \"data-value\":\n only && typeof only.value !== \"string\"\n ? JSON.stringify(only.value)\n : id,\n \"data-board\": board.id,\n \"data-interaction\": options?.interaction ?? only?.interaction.key,\n \"data-input\": only?.input.key,\n \"data-eligible\": eligible,\n \"data-selected\": selected,\n \"data-disabled\": candidates.length === 0,\n onClick: () => select(options),\n };\n },\n };\n }\n return target;\n }\n const spaceCollections = new WeakMap<\n object,\n RuntimeCollection<RuntimeSpace>\n >();\n function spacesFor(owner: RuntimeBoard): RuntimeCollection<RuntimeSpace> {\n const cached = spaceCollections.get(owner);\n if (cached) return cached;\n const target = targetsFor(owner);\n const data = owner.data;\n const values = Object.freeze(\n Object.values(data.spaces).map((space) =>\n Object.freeze({\n ...target(\"space\", space.id),\n data: space,\n board: owner,\n }),\n ),\n );\n const byId = new Map(values.map((space) => [space.id, space]));\n const spaces = Object.freeze({\n get: (id: string) =>\n requireLookup(byId.get(id), `Space on board ${owner.id}`, id),\n find: (id: string) => byId.get(id),\n getAll: () => values,\n });\n spaceCollections.set(owner, spaces);\n return spaces;\n }\n return {\n root: {\n get boards() {\n return collection();\n },\n },\n board: {\n get spaces(): RuntimeCollection<RuntimeSpace> {\n return spacesFor(this);\n },\n getLayout(this: RuntimeBoard, options: BoardLayoutOptions) {\n const board = this.data;\n if (board.layout === \"generic\")\n throw new Error(\n `Board '${board.id}' has no spatial geometry; use board.spaces for semantic selection.`,\n );\n const {\n hexSize,\n origin: suppliedOrigin = { x: 0, y: 0 },\n viewport: suppliedViewport = { x: 0, y: 0, scale: 1 },\n } = options;\n const origin = { ...suppliedOrigin };\n const viewport = { ...suppliedViewport };\n if (!Number.isFinite(hexSize) || hexSize <= 0)\n throw new Error(\"hexSize must be positive and finite.\");\n if (\n ![origin.x, origin.y, viewport.x, viewport.y, viewport.scale].every(\n Number.isFinite,\n ) ||\n viewport.scale <= 0\n )\n throw new Error(\n \"Layout transform must be finite with positive scale.\",\n );\n const captured = captures.get(this)!;\n const geometry: Geometry =\n board.layout === \"hex\"\n ? captured.geometry!.getLayout({ hexSize, origin })\n : squareGeometry(board, hexSize, origin);\n const point = (value: Point): Point =>\n Object.freeze({\n x: value.x * viewport.scale + viewport.x,\n y: value.y * viewport.scale + viewport.y,\n });\n const target = targetsFor(this);\n const semanticSpaces = spacesFor(this);\n const spaces = Object.freeze(\n geometry.spaces.map((space) => {\n const corners = Object.freeze(space.corners.map(point));\n const center = point(space.center);\n return Object.freeze({\n ...semanticSpaces.get(space.id),\n center,\n points: () => corners,\n transform: `translate(${center.x} ${center.y})`,\n });\n }),\n );\n const edges = Object.freeze(\n geometry.edges.map((edge) =>\n Object.freeze({\n ...target(\"edge\", edge.id),\n data: board.edges.find((data) => data.id === edge.id),\n center: point({\n x: (edge.from.x + edge.to.x) / 2,\n y: (edge.from.y + edge.to.y) / 2,\n }),\n line: Object.freeze([point(edge.from), point(edge.to)] as const),\n }),\n ),\n );\n const vertices = Object.freeze(\n geometry.vertices.map((vertex) =>\n Object.freeze({\n ...target(\"vertex\", vertex.id),\n data: board.vertices.find((data) => data.id === vertex.id),\n center: point(vertex.center),\n }),\n ),\n );\n return Object.freeze({\n viewBox: Object.freeze({ ...geometry.viewBox }),\n getSpaces: () => spaces,\n getEdges: () => edges,\n getVertices: () => vertices,\n pointToSpace(x: number, y: number) {\n return geometry.pointToSpace({\n x: (x - viewport.x) / viewport.scale,\n y: (y - viewport.y) / viewport.scale,\n });\n },\n });\n },\n } satisfies ThisType<RuntimeBoard>,\n };\n}\n\ntype RuntimeLayout = ReturnType<\n ReturnType<typeof createRuntimeBoardFeature>[\"board\"][\"getLayout\"]\n>;\ntype LayoutTarget<G, Value> = Omit<\n Value,\n \"getSelectHandler\" | \"getTargetProps\"\n> & {\n getSelectHandler(options?: TargetOptions<G>): () => void;\n getTargetProps(options?: TargetOptions<G>): ActionProps;\n};\ntype BoardLayout<G> = Omit<\n RuntimeLayout,\n \"getSpaces\" | \"getEdges\" | \"getVertices\"\n> & {\n getSpaces(): readonly (BoardSpace<G> & {\n readonly center: Point;\n points(): readonly Point[];\n readonly transform: string;\n })[];\n getEdges(): readonly LayoutTarget<\n G,\n ReturnType<RuntimeLayout[\"getEdges\"]>[number]\n >[];\n getVertices(): readonly LayoutTarget<\n G,\n ReturnType<RuntimeLayout[\"getVertices\"]>[number]\n >[];\n};\nexport interface BoardFeature<G> {\n readonly root: { readonly boards: BoardCollection<G> };\n readonly board: {\n readonly spaces: BoardSpaceCollection<G>;\n getLayout(this: BoardBase<G>, options: BoardLayoutOptions): BoardLayout<G>;\n };\n}\n/** Bind one runtime implementation to the same game/source contract as the instance. */\nexport function boardFeature<G>(\n _game: CoreInstance<G>,\n context: FeatureContext<G>,\n): BoardFeature<G> {\n // Game-binding boundary: source identities and installed hooks belong to G.\n // Proven by headless-features/inline-boards type tests and board behavior tests.\n // eslint-disable-next-line no-restricted-syntax -- Instance composition binds these runtime source identities and feature hooks to the same game G.\n return createRuntimeBoardFeature(\n context[runtimeFeatures],\n ) as unknown as BoardFeature<G>;\n}\n","import {\n runtimeFeatures,\n type RuntimeFeatureContext,\n} from \"../runtime-features.js\";\nimport type { RuntimeDropTarget, RuntimeTargetOptions } from \"../targets.js\";\nimport type { DropTarget, TargetOptions } from \"../targets.js\";\nexport type { DropTarget } from \"../targets.js\";\nimport { isSameDropTarget } from \"../drop-targets.js\";\nimport type { CoreInstance, FeatureContext, SeatCardId } from \"../model.js\";\nexport interface DragState<G> {\n readonly cardId: SeatCardId<G>;\n readonly target: DropTarget<G> | null;\n}\n\nexport interface DragController<G> {\n readonly active: DragState<G> | null;\n getCanDrag(cardId: SeatCardId<G>, options?: TargetOptions<G>): boolean;\n begin(cardId: SeatCardId<G>, options?: TargetOptions<G>): boolean;\n getDropTargets(): readonly DropTarget<G>[];\n setDropTarget(target: DropTarget<G> | null): void;\n drop(): void;\n cancel(): void;\n}\n\ninterface RuntimeDragState {\n readonly cardId: string;\n readonly target: RuntimeDropTarget | null;\n}\ninterface RuntimeDragController {\n readonly active: RuntimeDragState | null;\n getCanDrag(cardId: string, options?: RuntimeTargetOptions): boolean;\n begin(cardId: string, options?: RuntimeTargetOptions): boolean;\n getDropTargets(): readonly RuntimeDropTarget[];\n setDropTarget(target: RuntimeDropTarget | null): void;\n drop(): void;\n cancel(): void;\n}\nfunction createRuntimeDragFeature(context: RuntimeFeatureContext) {\n const game = context.game;\n let active: RuntimeDragState | null = null;\n let selection: RuntimeTargetOptions | undefined;\n let source = game.getOptions().source;\n let seat = game.snapshot?.me;\n let disposed = false;\n let version = game.snapshot?.version;\n let lastInteractions = game.interactions;\n let lastCards = game.cards;\n let branch = snapshot();\n function update(next: RuntimeDragState | null) {\n if (disposed) return;\n active = next === null ? null : Object.freeze(next);\n branch = snapshot();\n context.invalidate();\n }\n function targets(\n cardId = active?.cardId,\n selected = selection,\n ): readonly RuntimeDropTarget[] {\n if (!cardId || game.connection !== \"ready\") return [];\n const options = selected;\n const resolved = (game.cards.find(cardId)?.getInteractions() ?? []).flatMap(\n (candidate) => {\n if (\n !candidate.getIsAvailable() ||\n (options?.interaction && candidate.key !== options.interaction)\n )\n return [];\n const inputs = candidate.getInputs();\n const cardInputs = inputs.filter(\n (input) =>\n input.getDomain().type === \"cardTarget\" &&\n (!options?.input || input.key === options.input) &&\n input.getIsEligible(cardId),\n );\n // Without a board input, the card lands on an area that runs the interaction.\n if (!inputs.some((input) => input.getDomain().type === \"boardTarget\"))\n return cardInputs.map((cardInput): RuntimeDropTarget =>\n Object.freeze({\n kind: \"interaction\",\n interactionKey: candidate.key,\n cardInputKey: cardInput.key,\n }),\n );\n return cardInputs.flatMap((cardInput) =>\n inputs.flatMap((input): RuntimeDropTarget[] => {\n const domain = input.getDomain();\n if (domain.type !== \"boardTarget\") return [];\n const route = {\n interactionKey: candidate.key,\n cardInputKey: cardInput.key,\n inputKey: input.key,\n };\n if (domain.valueKind === \"player-board-space\")\n return domain.eligibleTargets\n .filter((value) => !input.getTargetProps(value).disabled)\n .map((value) =>\n Object.freeze({\n kind: \"space\",\n valueKind: domain.valueKind,\n value,\n ...route,\n }),\n );\n return domain.eligibleTargets\n .filter((value) => !input.getTargetProps(value).disabled)\n .map((value) =>\n Object.freeze({\n kind: domain.targetKind,\n valueKind: domain.valueKind,\n value,\n boardId: domain.boardId,\n ...route,\n }),\n );\n }),\n );\n },\n );\n return resolved;\n }\n function cancel() {\n if (active) update(null);\n }\n function snapshot(): RuntimeDragController {\n const captured = active;\n const dropTargets = Object.freeze(targets());\n return Object.freeze<RuntimeDragController>({\n active: captured,\n getCanDrag: (cardId, options) =>\n !disposed && targets(cardId, options).length > 0,\n begin(cardId, options) {\n if (disposed || !targets(cardId, options).length) return false;\n selection = options;\n update({ cardId, target: null });\n return true;\n },\n getDropTargets: () => dropTargets,\n setDropTarget(target: RuntimeDropTarget | null) {\n if (!active || disposed) return;\n if (\n target &&\n !targets().some((candidate) => isSameDropTarget(candidate, target))\n ) {\n update({ ...active, target: null });\n return;\n }\n update({ ...active, target });\n },\n drop() {\n const finished = active;\n const eligible =\n finished?.target &&\n targets().some((target) =>\n isSameDropTarget(target, finished.target!),\n );\n cancel();\n if (!disposed && finished?.target && eligible)\n context.routeCardDrop(finished.cardId, finished.target);\n },\n cancel,\n });\n }\n const unsubscribe = game.subscribe(() => {\n const nextSource = game.getOptions().source;\n const nextSeat = game.snapshot?.me;\n const nextVersion = game.snapshot?.version;\n if (\n nextSource !== source ||\n nextSeat !== seat ||\n nextVersion !== version ||\n game.connection !== \"ready\"\n ) {\n source = nextSource;\n seat = nextSeat;\n version = nextVersion;\n cancel();\n }\n });\n return {\n root: {\n get drag() {\n if (\n lastInteractions !== game.interactions ||\n lastCards !== game.cards\n ) {\n lastInteractions = game.interactions;\n lastCards = game.cards;\n branch = snapshot();\n }\n return branch;\n },\n },\n dispose() {\n unsubscribe();\n cancel();\n disposed = true;\n },\n };\n}\n\n/**\n * Semantic card/drop routing. A card lands on a board destination when its\n * interaction has a board input, otherwise on an area that runs the\n * interaction. Gestures, hit-testing and feedback belong to /react.\n */\nexport function dragFeature<G>(\n _game: CoreInstance<G>,\n context: FeatureContext<G>,\n): { readonly root: { readonly drag: DragController<G> }; dispose(): void } {\n // Game-binding boundary: routes come from this instance's admitted descriptors.\n // The runtime implementation revalidates both inputs atomically on drop.\n return createRuntimeDragFeature(context[runtimeFeatures]) as {\n readonly root: { readonly drag: DragController<G> };\n dispose(): void;\n };\n}\n","/** Native pointer surface; importing a feature never requires browser globals. */\nexport interface PointerSurface {\n setPointerCapture(pointerId: number): void;\n hasPointerCapture(pointerId: number): boolean;\n releasePointerCapture(pointerId: number): void;\n}\n\nexport interface PointerInput {\n readonly pointerId: number;\n readonly button: number;\n readonly clientX: number;\n readonly clientY: number;\n readonly currentTarget: PointerSurface;\n preventDefault(): void;\n}\n\nexport interface Point {\n readonly x: number;\n readonly y: number;\n}\n\nexport interface PointerMove {\n readonly origin: Point;\n readonly point: Point;\n readonly delta: Point;\n}\n\n/** One captured gesture. Pointer cancellation and disposal never commit a drop. */\nexport function createPointerSession(callbacks: {\n move(value: PointerMove): void;\n end(value: PointerMove): void;\n cancel(): void;\n}) {\n let disposed = false;\n let active:\n | { id: number; surface: PointerSurface; origin: Point; point: Point }\n | undefined;\n\n function value(): PointerMove {\n const { origin, point } = active!;\n return {\n origin,\n point,\n delta: { x: point.x - origin.x, y: point.y - origin.y },\n };\n }\n\n function release() {\n const previous = active;\n active = undefined;\n if (previous?.surface.hasPointerCapture(previous.id)) {\n previous.surface.releasePointerCapture(previous.id);\n }\n }\n\n function cancel() {\n if (!active) return;\n release();\n callbacks.cancel();\n }\n\n return {\n start(event: PointerInput): boolean {\n if (disposed || active || event.button !== 0) return false;\n event.currentTarget.setPointerCapture(event.pointerId);\n const point = { x: event.clientX, y: event.clientY };\n active = {\n id: event.pointerId,\n surface: event.currentTarget,\n origin: point,\n point,\n };\n event.preventDefault();\n return true;\n },\n move(event: PointerInput) {\n if (event.pointerId !== active?.id) return;\n active.point = { x: event.clientX, y: event.clientY };\n event.preventDefault();\n callbacks.move(value());\n },\n end(event: PointerInput) {\n if (event.pointerId !== active?.id) return;\n active.point = { x: event.clientX, y: event.clientY };\n const result = value();\n release();\n callbacks.end(result);\n },\n cancel(event?: Pick<PointerInput, \"pointerId\">) {\n if (event && event.pointerId !== active?.id) return;\n cancel();\n },\n dispose() {\n disposed = true;\n cancel();\n },\n };\n}\n","import type { CoreInstance, FeatureContext } from \"../model.js\";\nimport {\n createPointerSession,\n type PointerInput,\n type PointerSurface,\n} from \"./pointer-session.js\";\n\nexport interface ViewportTransform {\n readonly x: number;\n readonly y: number;\n readonly scale: number;\n}\nexport interface ViewportSurface extends PointerSurface {\n getBoundingClientRect(): {\n readonly left: number;\n readonly top: number;\n readonly height: number;\n };\n}\nexport interface WheelInput {\n readonly clientX: number;\n readonly clientY: number;\n readonly deltaY: number;\n readonly deltaMode: number;\n readonly currentTarget: ViewportSurface;\n preventDefault(): void;\n}\nexport interface PanZoomOptions {\n readonly initial?: ViewportTransform;\n readonly minScale?: number;\n readonly maxScale?: number;\n}\n\n/** Native pointer panning and wheel zoom around the cursor. No document listeners. */\nexport function panZoomFeature<G>(\n game: CoreInstance<G>,\n context: FeatureContext<G>,\n options: PanZoomOptions = {},\n) {\n const minScale = options.minScale ?? 0.25;\n const maxScale = options.maxScale ?? 4;\n if (\n !Number.isFinite(minScale) ||\n !Number.isFinite(maxScale) ||\n minScale <= 0 ||\n maxScale < minScale\n ) {\n throw new Error(\n \"Viewport scale limits must be positive, finite, and ordered.\",\n );\n }\n const initial = options.initial ?? { x: 0, y: 0, scale: 1 };\n let disposed = false;\n let source = game.getOptions().source;\n let seat = game.snapshot?.me;\n let dragOrigin = initial;\n let transform = admit(initial);\n let branch = snapshot();\n\n function admit(value: ViewportTransform): ViewportTransform {\n if (\n ![value.x, value.y, value.scale].every(Number.isFinite) ||\n value.scale <= 0\n ) {\n throw new Error(\n \"Viewport transform must have finite coordinates and positive scale.\",\n );\n }\n return Object.freeze({\n x: value.x,\n y: value.y,\n scale: Math.min(maxScale, Math.max(minScale, value.scale)),\n });\n }\n function update(value: ViewportTransform) {\n if (disposed) return;\n const next = admit(value);\n if (\n next.x === transform.x &&\n next.y === transform.y &&\n next.scale === transform.scale\n )\n return;\n transform = next;\n branch = snapshot();\n context.invalidate();\n }\n const pointer = createPointerSession({\n move: ({ delta }) =>\n update({\n ...dragOrigin,\n x: dragOrigin.x + delta.x,\n y: dragOrigin.y + delta.y,\n }),\n end: ({ delta }) =>\n update({\n ...dragOrigin,\n x: dragOrigin.x + delta.x,\n y: dragOrigin.y + delta.y,\n }),\n cancel() {},\n });\n function props() {\n return {\n style: { touchAction: \"none\" as const },\n onPointerDown(event: PointerInput) {\n if (pointer.start(event)) dragOrigin = transform;\n },\n onPointerMove: pointer.move,\n onPointerUp: pointer.end,\n onPointerCancel: pointer.cancel,\n onLostPointerCapture: pointer.cancel,\n onWheel(event: WheelInput) {\n if (disposed) return;\n event.preventDefault();\n const rect = event.currentTarget.getBoundingClientRect();\n const unit =\n event.deltaMode === 1 ? 16 : event.deltaMode === 2 ? rect.height : 1;\n const scale = Math.min(\n maxScale,\n Math.max(\n minScale,\n transform.scale * Math.exp(-event.deltaY * unit * 0.002),\n ),\n );\n const x = event.clientX - rect.left;\n const y = event.clientY - rect.top;\n const ratio = scale / transform.scale;\n update({\n x: x - (x - transform.x) * ratio,\n y: y - (y - transform.y) * ratio,\n scale,\n });\n },\n };\n }\n function snapshot() {\n const captured = transform;\n return Object.freeze({\n transform: captured,\n getTransform: () => captured,\n getProps: props,\n setTransform: update,\n reset: () => {\n pointer.cancel();\n update(initial);\n },\n });\n }\n const unsubscribe = game.subscribe(() => {\n const nextSource = game.getOptions().source;\n const nextSeat = game.snapshot?.me;\n if (nextSource !== source || nextSeat !== seat) {\n source = nextSource;\n seat = nextSeat;\n pointer.cancel();\n update(initial);\n }\n });\n return {\n root: {\n get viewport() {\n return branch;\n },\n },\n dispose() {\n disposed = true;\n unsubscribe();\n pointer.dispose();\n },\n };\n}\n","import type { CoreInstance, IdOf, SeatCardId } from \"../model.js\";\nimport type { SourceSnapshot } from \"../sources/types.js\";\n\n/**\n * Where a card that arrived in its zone with the current frame was on the\n * previous one: another zone, or the private zones of the player who moved.\n * `hidden` says whether the seat saw only the card's back there.\n */\nexport type CardOrigin<G> =\n | { readonly zone: IdOf<G, \"zoneId\">; readonly hidden: boolean }\n | { readonly player: IdOf<G, \"playerId\">; readonly hidden: true };\n\ntype RuntimeOrigin =\n | { readonly zone: string; readonly hidden: boolean }\n | { readonly player: string; readonly hidden: true };\ntype Zones = SourceSnapshot[\"frame\"][\"zones\"];\n\nconst isHidden = (cardId: string) => cardId.startsWith(\"hidden:\");\nconst hiddenCount = (zones: Zones, zone: string) =>\n zones[zone]?.cardIds.filter(isHidden).length ?? 0;\n\nfunction singleOrigin(\n departures: readonly { readonly zone: string; readonly hidden: boolean }[],\n count: number,\n) {\n const origin = departures[0];\n return origin &&\n departures.length >= count &&\n departures.every(\n (card) => card.zone === origin.zone && card.hidden === origin.hidden,\n )\n ? Object.freeze(origin)\n : null;\n}\n\n/**\n * Visible ids are card identities, so a visible card is followed between\n * zones. Hidden ids are positions, so only their net counts are compared.\n * An inferred origin requires one compatible source with enough departures;\n * existing hidden cards make the arriving positions ambiguous. Unexplained\n * arrivals can come from the sole mover's private zones, which the seat's\n * frame does not list. Ambiguous origins are omitted.\n */\nexport function findCardOrigins(\n previous: Zones,\n next: Zones,\n mover: string | null,\n): ReadonlyMap<string, RuntimeOrigin> {\n const shownBefore = new Map<string, string>();\n for (const [zone, { cardIds }] of Object.entries(previous))\n for (const cardId of cardIds)\n if (!isHidden(cardId)) shownBefore.set(cardId, zone);\n const shownNow = new Set(\n Object.values(next).flatMap(({ cardIds }) =>\n cardIds.filter((cardId) => !isHidden(cardId)),\n ),\n );\n let left = Object.entries(previous).flatMap(([zone, { cardIds }]) => [\n ...cardIds\n .filter((cardId) => !isHidden(cardId) && !shownNow.has(cardId))\n .map(() => ({ zone, hidden: false })),\n ...Array.from(\n {\n length: Math.max(\n 0,\n hiddenCount(previous, zone) - hiddenCount(next, zone),\n ),\n },\n () => ({ zone, hidden: true }),\n ),\n ]);\n const origins = new Map<string, RuntimeOrigin>();\n const shownArrivals: string[] = [];\n const hiddenArrivals: (string | null)[] = [];\n for (const [zone, { cardIds }] of Object.entries(next)) {\n for (const cardId of cardIds) {\n if (isHidden(cardId)) continue;\n const from = shownBefore.get(cardId);\n if (from === undefined) shownArrivals.push(cardId);\n else if (from !== zone)\n origins.set(cardId, Object.freeze({ zone: from, hidden: false }));\n }\n const hidden = cardIds.filter(isHidden);\n const before = hiddenCount(previous, zone);\n // Count ambiguous arrivals too, so another destination cannot claim their source.\n hiddenArrivals.push(\n ...Array.from(\n { length: Math.max(0, hidden.length - before) },\n (_, index) => (before === 0 ? hidden[index] : null),\n ),\n );\n }\n // Concealing a visible card can replace a hidden departure without changing\n // the hidden count. Net counts cannot resolve those simultaneous movements.\n if (\n left.some(\n (card) =>\n !card.hidden &&\n hiddenCount(previous, card.zone) > 0 &&\n hiddenCount(next, card.zone) > 0,\n )\n )\n return origins;\n const hiddenLeft = left.filter((card) => card.hidden);\n if (shownArrivals.length) {\n const origin = singleOrigin(hiddenLeft, shownArrivals.length);\n if (origin) {\n for (const cardId of shownArrivals) origins.set(cardId, origin);\n left = [\n ...left.filter((card) => !card.hidden),\n ...hiddenLeft.slice(shownArrivals.length),\n ];\n } else if (hiddenLeft.length) {\n // Which departures the shown cards consumed is also ambiguous.\n return origins;\n } else if (mover !== null) {\n const origin = Object.freeze({ player: mover, hidden: true as const });\n for (const cardId of shownArrivals) origins.set(cardId, origin);\n }\n }\n const hiddenOrigin =\n singleOrigin(left, hiddenArrivals.length) ??\n (left.length === 0 && mover !== null\n ? Object.freeze({ player: mover, hidden: true as const })\n : null);\n if (hiddenOrigin) {\n for (const cardId of hiddenArrivals)\n if (cardId !== null) origins.set(cardId, hiddenOrigin);\n }\n return origins;\n}\n\n/** The sole active player, when it is another seat. */\nfunction moverOf(snapshot: SourceSnapshot) {\n const active = snapshot.frame.flow.activePlayers;\n return active.length === 1 && active[0] !== snapshot.me ? active[0] : null;\n}\n\n/**\n * Adds `card.getOrigin()`: where a card that arrived in its zone with the\n * current frame came from, or null. Origins last until the next frame and\n * reset when the seat or source changes. Hidden origins are inferred from\n * net counts; ambiguous sources and arriving positions return null.\n */\nexport function originsFeature<G>(game: CoreInstance<G>) {\n type Origins = ReadonlyMap<SeatCardId<G>, CardOrigin<G>>;\n let frame = game.snapshot;\n let source = game.getOptions().source;\n let origins: Origins = new Map();\n function sync() {\n const next = game.snapshot;\n const nextSource = game.getOptions().source;\n if (\n next?.version === frame?.version &&\n next?.me === frame?.me &&\n nextSource === source\n )\n return;\n // Game-binding boundary: card, zone and player ids come from this instance's frames.\n origins =\n frame && next && next.me === frame.me && nextSource === source\n ? (findCardOrigins(\n frame.frame.zones,\n next.frame.zones,\n next.version === frame.version + 1 ? moverOf(frame) : null,\n ) as Origins)\n : new Map();\n frame = next;\n source = nextSource;\n }\n // Also read lazily, so a reader notified before this listener sees the new frame's origins.\n const unsubscribe = game.subscribe(sync);\n return {\n card: {\n getOrigin(this: { readonly id: SeatCardId<G> }): CardOrigin<G> | null {\n sync();\n return origins.get(this.id) ?? null;\n },\n },\n dispose: unsubscribe,\n };\n}\n","const RADIANS = Math.PI / 180;\n\nexport interface FanOptions {\n readonly count: number;\n /** The width available to the fan, in pixels. */\n readonly width: number;\n readonly cardWidth: number;\n readonly cardHeight: number;\n /** Distance between neighbouring cards along the arc when there is room. Default: 60% of the card width. */\n readonly step?: number;\n /** The smallest visible slice of a covered card. Default: 25% of the card width. */\n readonly minStep?: number;\n /** Degrees between neighbouring cards. Default 5; 0 lays a straight row. */\n readonly angle?: number;\n /** The most degrees between the two end cards. Default 30. */\n readonly maxSpread?: number;\n}\n\n/** A card's CSS `translate` from the fan's top-left corner, and its `rotate` about its own centre. */\nexport interface FanCard {\n readonly x: number;\n readonly y: number;\n /** Degrees clockwise. */\n readonly rotate: number;\n}\n\nexport interface FanLayout {\n readonly cards: readonly FanCard[];\n /** The fan's bounding box. It is wider than the available width only when the cards are at `minStep`. */\n readonly width: number;\n readonly height: number;\n}\n\n/**\n * Lays cards on a circular arc. The spread grows with the card count up to\n * `maxSpread`; the step shrinks continuously to fit the width, down to\n * `minStep`, past which the fan overflows and the hand should scroll.\n */\nexport function fanLayout({\n count,\n width,\n cardWidth,\n cardHeight,\n step = cardWidth * 0.6,\n minStep = cardWidth * 0.25,\n angle = 5,\n maxSpread = 30,\n}: FanOptions): FanLayout {\n if (count < 1) return { cards: [], width: 0, height: 0 };\n const gaps = count - 1;\n const delta = gaps ? Math.min(angle, maxSpread / gaps) * RADIANS : 0;\n const edge = (gaps * delta) / 2;\n // The horizontal distance between the end cards' centres is `spacing * span`.\n const span = delta ? (2 * Math.sin(edge)) / delta : gaps;\n // The end cards' outer halves, tilted by the edge angle.\n const ends = cardWidth * Math.cos(edge) + cardHeight * Math.sin(edge);\n const spacing = span\n ? Math.max(minStep, Math.min(step, (width - ends) / span))\n : 0;\n const radius = delta ? spacing / delta : 0;\n const centres = Array.from({ length: count }, (_, index) => {\n if (!delta) return { theta: 0, x: (index - gaps / 2) * spacing, y: 0 };\n const theta = (index - gaps / 2) * delta;\n return {\n theta,\n x: radius * Math.sin(theta),\n y: radius * (1 - Math.cos(theta)),\n };\n });\n const halfHeight = (theta: number) =>\n (cardHeight / 2) * Math.cos(theta) +\n (cardWidth / 2) * Math.abs(Math.sin(theta));\n const top = Math.min(\n ...centres.map((card) => card.y - halfHeight(card.theta)),\n );\n const bottom = Math.max(\n ...centres.map((card) => card.y + halfHeight(card.theta)),\n );\n const fanWidth = spacing * span + ends;\n return {\n cards: centres.map((card) => ({\n x: card.x + (fanWidth - cardWidth) / 2,\n y: card.y - top - cardHeight / 2,\n rotate: card.theta / RADIANS,\n })),\n width: fanWidth,\n height: bottom - top,\n };\n}\n\n/** Moves a fanned card outward along its own tilt, as for a selected card. */\nexport function liftFanCard(card: FanCard, distance: number): FanCard {\n const theta = card.rotate * RADIANS;\n return {\n x: card.x + distance * Math.sin(theta),\n y: card.y - distance * Math.cos(theta),\n rotate: card.rotate,\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEO,IAAM,yBACX,OACI,kBACA;AAEC,IAAM,0BAA0B;AAAA,EACrC,yBAAyB;AAC3B;AAUO,IAAM,6BAAsD;AAAA,EACjE,SAAS;AAAA,EACT,YAAY;AAAA,EACZ,UAAU;AACZ;;;ACbO,SAAS,aACd,UAEI,CAAC,GACU;AACf,QAAM,SAAS;AACf,QAAM,SAAS,OAAO;AACtB,MAAI,UAAiD;AACrD,MAAI,WAAW;AACf,MAAI,mBAAmB;AACvB,QAAM,OAAO,CAAC,YAAiC;AAC7C,QAAI,CAAC,QAAS,OAAM,IAAI,MAAM,mCAAmC;AACjE,WAAO;AAAA,MACL;AAAA,QACE,UAAU;AAAA,QACV,SAAS;AAAA,QACT,WAAW,QAAQ;AAAA,QACnB,UAAU,EAAE;AAAA,QACZ;AAAA,MACF;AAAA,MACA,QAAQ;AAA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,UACjB,aAAa,IAAK,KAAK,IAAI,KAAK,IAChC,YAAY,IAAK,KAAK,IAAI,KAAK,IAAI,KAAK,CAAC;AAC5C,QAAM,MAAM,KAAK;AAAA,IACf,GAAG,QAAQ,IAAI,CAAC,SAAS,KAAK,IAAI,WAAW,KAAK,KAAK,CAAC;AAAA,EAC1D;AACA,QAAM,SAAS,KAAK;AAAA,IAClB,GAAG,QAAQ,IAAI,CAAC,SAAS,KAAK,IAAI,WAAW,KAAK,KAAK,CAAC;AAAA,EAC1D;AACA,QAAM,WAAW,UAAU,OAAO;AAClC,SAAO;AAAA,IACL,OAAO,QAAQ,IAAI,CAAC,UAAU;AAAA,MAC5B,GAAG,KAAK,KAAK,WAAW,aAAa;AAAA,MACrC,GAAG,KAAK,IAAI,MAAM,aAAa;AAAA,MAC/B,QAAQ,KAAK,QAAQ;AAAA,IACvB,EAAE;AAAA,IACF,OAAO;AAAA,IACP,QAAQ,SAAS;AAAA,EACnB;AACF;AAGO,SAAS,YAAY,MAAe,UAA2B;AACpE,QAAM,QAAQ,KAAK,SAAS;AAC5B,SAAO;AAAA,IACL,GAAG,KAAK,IAAI,WAAW,KAAK,IAAI,KAAK;AAAA,IACrC,GAAG,KAAK,IAAI,WAAW,KAAK,IAAI,KAAK;AAAA,IACrC,QAAQ,KAAK;AAAA,EACf;AACF;","names":["x","y","value","target","cached","origin"]}
1
+ {"version":3,"sources":["../src/package-set.ts","../src/headless/sources/iframe.ts","../src/shared/protocol/gameplay-wire.ts","../src/headless/sources/host-websocket.ts","../src/headless/features/hand.ts","../src/headless/features/board.ts","../src/headless/features/drag.ts","../src/headless/features/pointer-session.ts","../src/headless/features/pan-zoom.ts","../src/headless/features/origins.ts","../src/headless/fan.ts"],"sourcesContent":["declare const __DREAMBOARD_SDK_VERSION__: string;\n\nexport const DREAMBOARD_SDK_VERSION =\n typeof __DREAMBOARD_SDK_VERSION__ === \"string\"\n ? __DREAMBOARD_SDK_VERSION__\n : \"0.0.0-development\";\n\nexport const DREAMBOARD_SDK_PACKAGES = {\n \"@dreamboard-games/sdk\": DREAMBOARD_SDK_VERSION,\n} as const;\n\nexport type DreamboardSdkPackageName = keyof typeof DREAMBOARD_SDK_PACKAGES;\n\nexport type DreamboardSdkPackageSet = {\n version: 1;\n sdkVersion: string;\n packages: Record<DreamboardSdkPackageName, string>;\n};\n\nexport const DREAMBOARD_SDK_PACKAGE_SET: DreamboardSdkPackageSet = {\n version: 1,\n sdkVersion: DREAMBOARD_SDK_VERSION,\n packages: DREAMBOARD_SDK_PACKAGES,\n};\n","import {\n DREAMBOARD_PLUGIN_PROTOCOL,\n DREAMBOARD_PLUGIN_PROTOCOL_VERSION,\n} from \"../../shared/protocol/protocol.js\";\nimport { HostToPluginEnvelopeSchema } from \"../../shared/protocol/schema.js\";\nimport type { PluginToHostPayload } from \"../../shared/protocol/protocol.js\";\nimport { createSourceLifecycle } from \"./lifecycle.js\";\nimport type { CommandSource } from \"./types.js\";\n\n/** Pins its parent window, origin and channel at the first valid initialization. */\nexport function iframeSource(\n options: {\n timeoutMs?: number;\n } = {},\n): CommandSource {\n const target = window;\n const parent = target.parent;\n let channel: { id: string; origin: string } | null = null;\n let sequence = 0;\n let receivedSequence = -1;\n const send = (payload: PluginToHostPayload) => {\n if (!channel) throw new Error(\"Iframe source is not initialized.\");\n parent.postMessage(\n {\n protocol: DREAMBOARD_PLUGIN_PROTOCOL,\n version: DREAMBOARD_PLUGIN_PROTOCOL_VERSION,\n channelId: channel.id,\n sequence: ++sequence,\n payload,\n },\n channel.origin,\n );\n };\n const lifecycle = createSourceLifecycle({\n timeoutMs: options.timeoutMs,\n send,\n recover: () => send({ type: \"runtime.resume\" }),\n close: () => target.removeEventListener(\"message\", receive),\n });\n const isOpen = () => {\n const { connection } = lifecycle.source.store.get();\n return connection !== \"closed\" && connection !== \"failed\";\n };\n function receive(event: MessageEvent) {\n if (event.source !== parent) return;\n const parsed = HostToPluginEnvelopeSchema.safeParse(event.data);\n if (!parsed.success) {\n const data: unknown = event.data;\n if (\n channel &&\n event.origin === channel.origin &&\n typeof data === \"object\" &&\n data !== null &&\n \"channelId\" in data &&\n data.channelId === channel.id\n ) {\n try {\n send({\n type: \"runtime.error\",\n code: \"host-runtime-protocol-mismatch\",\n message: \"Iframe source received an invalid host envelope.\",\n });\n } finally {\n lifecycle.fail(new Error(\"Invalid iframe host envelope.\"));\n }\n }\n return;\n }\n const envelope = parsed.data;\n if (!channel) {\n if (envelope.payload.type !== \"runtime.init\") return;\n channel = { id: envelope.channelId, origin: event.origin };\n }\n if (\n channel.id !== envelope.channelId ||\n channel.origin !== event.origin ||\n envelope.sequence <= receivedSequence\n )\n return;\n receivedSequence = envelope.sequence;\n const payload = envelope.payload;\n if (payload.type === \"runtime.init\") {\n lifecycle.session(payload.session);\n if (isOpen()) send({ type: \"runtime.ready\" });\n } else if (payload.type === \"gameplay.frame\")\n lifecycle.frame(payload.frame);\n else lifecycle.result(payload);\n if (isOpen()) send({ type: \"runtime.ack\", sequence: envelope.sequence });\n }\n target.addEventListener(\"message\", receive);\n return lifecycle.source;\n}\n","import * as z from \"zod\";\nimport {\n InteractionResultSchema,\n PluginGameplayFrameSchema,\n SubmitInteractionCommandSchema,\n CancelInteractionCommandSchema,\n} from \"./schema.js\";\nexport const GameplayCloseCode = {\n GoingAway: 1001,\n CredentialExpired: 4000,\n CredentialInvalid: 4001,\n RefreshContextMismatch: 4002,\n PermissionDenied: 4100,\n ProtocolViolation: 4200,\n FrameBeforeAuth: 4201,\n SlowConsumer: 4300,\n TooManyRequests: 4301,\n} as const;\n\nexport const GameplayCredentialSchema = z.discriminatedUnion(\"kind\", [\n z\n .object({ kind: z.literal(\"user\"), token: z.string().min(1).max(16384) })\n .strict(),\n z\n .object({ kind: z.literal(\"demo\"), secret: z.string().min(1).max(1024) })\n .strict(),\n]);\nexport const AuthConnectFrameSchema = z\n .object({\n type: z.literal(\"auth.connect\"),\n credential: GameplayCredentialSchema,\n sessionId: z.string().uuid(),\n playerId: z.string().min(1).max(128),\n })\n .strict();\nexport const AuthRefreshFrameSchema = z\n .object({\n type: z.literal(\"auth.refresh\"),\n credential: GameplayCredentialSchema,\n })\n .strict();\n\nexport const SessionResumeFrameSchema = z.object({\n type: z.literal(\"session.resume\"),\n lastSeenLogCursor: z.number().int().nonnegative().nullable(),\n unacknowledgedClientActionIds: z.array(z.string().min(1)).max(32),\n});\n\nexport const AuthAcceptedFrameSchema = z.object({\n type: z.literal(\"auth.accepted\"),\n expiresAt: z.string().datetime(),\n});\n\nexport const GameplayBackpressureReasonSchema = z.enum([\n \"queue_full\",\n \"capacity_full\",\n]);\n\nexport const GameplayBackpressureOperationSchema = z.enum([\n \"session.resume\",\n \"interaction.submit\",\n \"interaction.cancel\",\n]);\nexport const GameplayBackpressureFrameSchema = z.object({\n type: z.literal(\"gameplay.backpressure\"),\n reason: GameplayBackpressureReasonSchema,\n retryAfterMs: z.number().int().positive(),\n message: z.string().min(1),\n operation: GameplayBackpressureOperationSchema,\n clientActionId: z.string().min(1).optional(),\n});\nexport const SessionSnapshotFrameSchema = z.object({\n type: z.literal(\"session.snapshot\"),\n frame: PluginGameplayFrameSchema,\n});\nexport const ClientGameplayFrameSchema = z.discriminatedUnion(\"type\", [\n AuthConnectFrameSchema,\n AuthRefreshFrameSchema,\n SessionResumeFrameSchema,\n SubmitInteractionCommandSchema,\n CancelInteractionCommandSchema,\n]);\nexport const ServerGameplayFrameSchema = z.discriminatedUnion(\"type\", [\n AuthAcceptedFrameSchema,\n GameplayBackpressureFrameSchema,\n SessionSnapshotFrameSchema,\n InteractionResultSchema,\n]);\nexport type GameplayCredential = z.infer<typeof GameplayCredentialSchema>;\nexport type ClientGameplayFrame = z.infer<typeof ClientGameplayFrameSchema>;\nexport type ServerGameplayFrame = z.infer<typeof ServerGameplayFrameSchema>;\n","import type { PluginSessionDescriptor } from \"../../shared/protocol/frame.js\";\nimport {\n ClientGameplayFrameSchema,\n ServerGameplayFrameSchema,\n GameplayCloseCode,\n type ClientGameplayFrame,\n type GameplayCredential,\n} from \"../../shared/protocol/gameplay-wire.js\";\nimport { createSourceLifecycle } from \"./lifecycle.js\";\nimport type { CommandSource, SourceCommand } from \"./types.js\";\n\nexport function hostSource(options: {\n url: string;\n session: PluginSessionDescriptor;\n playerId: string;\n getCredential(): Promise<GameplayCredential>;\n timeoutMs?: number;\n}): CommandSource {\n const { url, playerId, getCredential } = options;\n const sessionId = options.session.sessionId;\n let socket: WebSocket | null = null;\n let generation = 0;\n let disposed = false;\n let authenticated = false;\n let queued: SourceCommand | null = null;\n let reconnects = 0;\n let refreshTimer: ReturnType<typeof setTimeout> | undefined;\n let snapshotTimer: ReturnType<typeof setTimeout> | undefined;\n let openTimer: ReturnType<typeof setTimeout> | undefined;\n let cleanup = () => {};\n const timeoutMs = options.timeoutMs ?? 10_000;\n const send = (frame: ClientGameplayFrame) => {\n if (!socket || socket.readyState !== WebSocket.OPEN)\n throw new Error(\"Gameplay socket is not open.\");\n socket.send(JSON.stringify(ClientGameplayFrameSchema.parse(frame)));\n };\n const resume = () =>\n send({\n type: \"session.resume\",\n lastSeenLogCursor: null,\n unacknowledgedClientActionIds: queued ? [queued.clientActionId] : [],\n });\n const lifecycle = createSourceLifecycle({\n context: {\n sessionId,\n playerId,\n },\n timeoutMs,\n send(command) {\n if (!authenticated) {\n queued = command;\n return;\n }\n send(command);\n },\n recover() {\n if (authenticated) resume();\n else if (!openTimer) void connect();\n },\n close() {\n disposed = true;\n generation++;\n clearTimeout(refreshTimer);\n clearTimeout(openTimer);\n clearTimeout(snapshotTimer);\n cleanup();\n socket?.close();\n socket = null;\n queued = null;\n },\n });\n lifecycle.session(options.session);\n async function connect() {\n if (disposed) return;\n const current = ++generation;\n authenticated = false;\n clearTimeout(refreshTimer);\n clearTimeout(openTimer);\n clearTimeout(snapshotTimer);\n cleanup();\n socket?.close();\n socket = null;\n openTimer = setTimeout(\n () =>\n lifecycle.fail(new Error(\"Gameplay socket authentication timed out.\")),\n timeoutMs,\n );\n try {\n const credential = await getCredential();\n if (disposed || current !== generation) return;\n const next = new WebSocket(url);\n socket = next;\n const active = () => !disposed && current === generation;\n const onOpen = () => {\n if (!active()) return;\n try {\n send({\n type: \"auth.connect\",\n credential,\n sessionId,\n playerId,\n });\n } catch (error) {\n lifecycle.fail(asError(error));\n }\n };\n const onMessage = (event: MessageEvent) => {\n if (!active()) return;\n try {\n const value: unknown = JSON.parse(String(event.data));\n if (typeof value !== \"object\" || value === null || !(\"type\" in value))\n throw new Error(\"Invalid gameplay frame.\");\n if (\n ![\n \"auth.accepted\",\n \"session.snapshot\",\n \"interaction.result\",\n \"gameplay.backpressure\",\n ].includes(String(value.type))\n )\n return;\n const frame = ServerGameplayFrameSchema.parse(value);\n if (frame.type === \"auth.accepted\") {\n clearTimeout(openTimer);\n openTimer = undefined;\n const first = !authenticated;\n authenticated = true;\n if (first) {\n snapshotTimer = setTimeout(\n () => lifecycle.fail(new Error(\"Gameplay snapshot timed out.\")),\n timeoutMs,\n );\n resume();\n if (queued) {\n send(queued);\n queued = null;\n }\n }\n clearTimeout(refreshTimer);\n if (credential.kind === \"user\") {\n const ttl = Date.parse(frame.expiresAt) - Date.now();\n if (ttl <= 0)\n throw new Error(\"Gameplay credential is already expired.\");\n refreshTimer = setTimeout(\n () => {\n openTimer = setTimeout(\n () =>\n lifecycle.fail(\n new Error(\"Gameplay credential refresh timed out.\"),\n ),\n timeoutMs,\n );\n void getCredential()\n .then((updated) => {\n if (active())\n send({ type: \"auth.refresh\", credential: updated });\n })\n .catch((error) => {\n if (active()) lifecycle.fail(asError(error));\n });\n },\n Math.max(0, ttl - Math.min(60_000, ttl * 0.2)),\n );\n }\n } else if (!authenticated)\n throw new Error(\"Gameplay frame arrived before authentication.\");\n else if (frame.type === \"session.snapshot\") {\n clearTimeout(snapshotTimer);\n snapshotTimer = undefined;\n reconnects = 0;\n lifecycle.frame(frame.frame);\n } else if (frame.type === \"interaction.result\")\n lifecycle.result(frame);\n else lifecycle.fail(new Error(frame.message));\n } catch (error) {\n lifecycle.fail(asError(error));\n }\n };\n const onClose = (event: CloseEvent) => {\n if (!active()) return;\n authenticated = false;\n lifecycle.recovering();\n if (\n new Set<number>([\n GameplayCloseCode.CredentialInvalid,\n GameplayCloseCode.RefreshContextMismatch,\n GameplayCloseCode.PermissionDenied,\n GameplayCloseCode.ProtocolViolation,\n GameplayCloseCode.FrameBeforeAuth,\n ]).has(event.code) ||\n reconnects++ > 0\n ) {\n lifecycle.fail(new Error(`Gameplay socket closed (${event.code}).`));\n return;\n }\n void connect();\n lifecycle.retry();\n };\n const onError = () => {\n if (active()) next.close();\n };\n next.addEventListener(\"open\", onOpen);\n next.addEventListener(\"message\", onMessage);\n next.addEventListener(\"close\", onClose);\n next.addEventListener(\"error\", onError);\n cleanup = () => {\n next.removeEventListener(\"open\", onOpen);\n next.removeEventListener(\"message\", onMessage);\n next.removeEventListener(\"close\", onClose);\n next.removeEventListener(\"error\", onError);\n };\n } catch (error) {\n if (!disposed && current === generation) lifecycle.fail(asError(error));\n }\n }\n void connect();\n return lifecycle.source;\n}\nfunction asError(error: unknown): Error {\n return error instanceof Error ? error : new Error(String(error));\n}\n","import type { Card, CoreInstance, SeatCardId, Zone } from \"../model.js\";\n\nexport interface HandOptions<G> {\n /** Compare projected card data only; hidden cards never expose private fields. */\n readonly sort?: (\n left: Card<G, Record<never, never>>,\n right: Card<G, Record<never, never>>,\n ) => number;\n}\n\n// Generic G defers the card visibility union, so ids widen to string here.\nconst seatCardId = <G>(card: { readonly id: string }) =>\n card.id as SeatCardId<G>;\n\n/** Optional hand helpers reuse the zone order and the core selection router. */\nexport function handFeature<G>(\n _game: CoreInstance<G>,\n options: HandOptions<G> = {},\n) {\n return {\n zone: {\n getSortedCardIds(\n this: Zone<G, Record<never, never>>,\n ): readonly SeatCardId<G>[] {\n return this.getCards({ sort: options.sort }).map(seatCardId<G>);\n },\n getSelectedCardIds(\n this: Zone<G, Record<never, never>>,\n ): readonly SeatCardId<G>[] {\n return this.getCards()\n .filter((card) => card.getIsSelected())\n .map(seatCardId<G>);\n },\n getSelectableCardIds(\n this: Zone<G, Record<never, never>>,\n ): readonly SeatCardId<G>[] {\n return this.getCards()\n .filter((card) => card.getCanSelect())\n .map(seatCardId<G>);\n },\n },\n };\n}\n","import {\n runtimeFeatures,\n type RuntimeBoard,\n type RuntimeFeatureContext,\n type RuntimeFeatureSnapshot,\n type RuntimeCollection,\n} from \"../runtime-features.js\";\nimport type { RuntimeTargetOptions } from \"../targets.js\";\nimport type {\n BoardBase,\n BoardCollection,\n BoardSpaceCollection,\n BoardSpace,\n CoreInstance,\n FeatureContext,\n ReadonlyData,\n TargetOptions,\n ActionProps,\n} from \"../model.js\";\nimport type {\n RuntimeBoardSpaceState,\n RuntimeSquareBoardState,\n} from \"../../reducer/model/table.js\";\nimport { requireLookup } from \"../../shared/lookup.js\";\nimport { AmbiguousTargetError } from \"../instance.js\";\nimport { createHexBoardGeometry } from \"../../shared/hex-board.js\";\nimport type { Point } from \"./pointer-session.js\";\nimport type { ViewportTransform } from \"./pan-zoom.js\";\n\ninterface RuntimeSpace {\n readonly id: string;\n readonly data: ReadonlyData<RuntimeBoardSpaceState>;\n readonly board: RuntimeBoard;\n getIsEligible(): boolean;\n getIsSelectable(): boolean;\n getIsSelected(): boolean;\n getSelectHandler(options?: RuntimeTargetOptions): () => void;\n getTargetProps(options?: RuntimeTargetOptions): ActionProps;\n}\ntype TargetKind = \"space\" | \"edge\" | \"vertex\";\nexport interface BoardLayoutOptions {\n /** Hex radius, or square cell width and height. */\n readonly hexSize: number;\n readonly origin?: Point;\n readonly viewport?: ViewportTransform;\n}\ninterface Geometry {\n readonly viewBox: { x: number; y: number; width: number; height: number };\n readonly spaces: readonly {\n id: string;\n center: Point;\n corners: readonly Point[];\n }[];\n readonly edges: readonly { id: string; from: Point; to: Point }[];\n readonly vertices: readonly { id: string; center: Point }[];\n pointToSpace(point: Point): string | undefined;\n}\n\nfunction squareGeometry(\n board: ReadonlyData<RuntimeSquareBoardState>,\n size: number,\n origin: Point,\n): Geometry {\n const spaces = Object.values(board.spaces).map((space) => {\n const x = origin.x + space.col * size;\n const y = origin.y + space.row * size;\n return {\n id: space.id,\n center: { x: x + size / 2, y: y + size / 2 },\n corners: [\n { x, y },\n { x: x + size, y },\n { x: x + size, y: y + size },\n { x, y: y + size },\n ],\n };\n });\n const byId = new Map(spaces.map((space) => [space.id, space]));\n function sharedCorners(ids: readonly string[]) {\n const first = byId.get(ids[0] ?? \"\")?.corners ?? [];\n return first.filter((point) =>\n ids.every((id) =>\n byId\n .get(id)\n ?.corners.some(\n (candidate) => candidate.x === point.x && candidate.y === point.y,\n ),\n ),\n );\n }\n const points = spaces.flatMap((space) => space.corners);\n const xs = points.map((point) => point.x);\n const ys = points.map((point) => point.y);\n const x = xs.length ? Math.min(...xs) : 0;\n const y = ys.length ? Math.min(...ys) : 0;\n return {\n viewBox: {\n x,\n y,\n width: xs.length ? Math.max(...xs) - x : 0,\n height: ys.length ? Math.max(...ys) - y : 0,\n },\n spaces,\n // Incidence is authored. Only a unique geometric line/point is representable.\n edges: board.edges.flatMap((edge) => {\n const corners = sharedCorners(edge.spaceIds);\n return corners.length === 2\n ? [{ id: edge.id, from: corners[0], to: corners[1] }]\n : [];\n }),\n vertices: board.vertices.flatMap((vertex) => {\n const corners = sharedCorners(vertex.spaceIds);\n return corners.length === 1\n ? [{ id: vertex.id, center: corners[0] }]\n : [];\n }),\n pointToSpace(point) {\n const col = Math.floor((point.x - origin.x) / size);\n const row = Math.floor((point.y - origin.y) / size);\n return Object.values(board.spaces).find(\n (space) => space.col === col && space.row === row,\n )?.id;\n },\n };\n}\n\n/** Semantic board spaces and captured selection, with optional spatial geometry. */\nfunction createRuntimeBoardFeature(context: RuntimeFeatureContext) {\n const game = context.game;\n const captures = new WeakMap<\n object,\n {\n model: RuntimeFeatureSnapshot;\n source: ReturnType<typeof game.getOptions>[\"source\"];\n geometry?: ReturnType<typeof createHexBoardGeometry>;\n }\n >();\n const geometries = new WeakMap<\n object,\n ReturnType<typeof createHexBoardGeometry>\n >();\n let cached:\n | {\n view: unknown;\n interactions: RuntimeFeatureSnapshot[\"interactions\"];\n source: ReturnType<typeof game.getOptions>[\"source\"];\n collection: RuntimeCollection<RuntimeBoard>;\n }\n | undefined;\n function collection(): RuntimeCollection<RuntimeBoard> {\n const model = game.getSnapshot();\n const source = game.getOptions().source;\n if (\n cached &&\n cached.view === model.view &&\n cached.interactions === model.interactions &&\n cached.source === source\n )\n return cached.collection;\n const boards = Object.values(context.getBoards()).map((data) => {\n const board = context.createBoard(data);\n let geometry = geometries.get(data);\n if (!geometry && data.layout === \"hex\") {\n geometry = createHexBoardGeometry({\n id: data.baseId ?? data.id,\n orientation: data.orientation,\n spaces: Object.values(data.spaces),\n });\n geometries.set(data, geometry);\n }\n captures.set(board, { model, source, geometry });\n return board;\n });\n const byId = new Map(boards.map((board) => [board.id, board]));\n const result: RuntimeCollection<RuntimeBoard> = Object.freeze({\n get: (id: string) => requireLookup(byId.get(id), \"Board\", id),\n find: (id: string) => byId.get(id),\n getAll: () => Object.freeze(boards),\n });\n cached = {\n view: model.view,\n interactions: model.interactions,\n source,\n collection: result,\n };\n return result;\n }\n function targetsFor(owner: RuntimeBoard) {\n const board = owner.data;\n const captured = captures.get(owner)!;\n function matchingTargets(\n model: RuntimeFeatureSnapshot,\n kind: TargetKind,\n id: string,\n ) {\n const inputKinds = kind === \"space\" ? [\"space\", \"tile\"] : [kind];\n return model.interactions.list().flatMap((interaction) =>\n interaction\n .getInputs()\n .filter((input) => {\n const domain = input.getDomain();\n return (\n domain.type === \"boardTarget\" &&\n inputKinds.includes(String(domain.targetKind)) &&\n (domain.valueKind === \"player-board-space\"\n ? board.scope === \"perPlayer\" && domain.boardId === board.baseId\n : domain.boardId === board.id)\n );\n })\n .map((input) => {\n const domain = input.getDomain();\n return {\n interaction,\n input,\n value:\n domain.type === \"boardTarget\" &&\n domain.valueKind === \"player-board-space\"\n ? Object.freeze({\n boardId: board.baseId!,\n playerId: board.playerId!,\n spaceId: id,\n })\n : id,\n };\n }),\n );\n }\n function target(kind: TargetKind, id: string) {\n const matches = matchingTargets(captured.model, kind, id);\n const eligible = matches.some(({ input, value }) =>\n input.getIsEligible(value),\n );\n const selected = matches.some(({ input, value }) =>\n input.getIsSelected(value),\n );\n const selectable = matches.some(\n ({ input, value }) => !input.getTargetProps(value).disabled,\n );\n function select(options?: RuntimeTargetOptions) {\n if (\n game.getOptions().source !== captured.source ||\n game.snapshot?.me !== captured.model.snapshot?.me\n )\n return;\n const matching = matchingTargets(game.getSnapshot(), kind, id).filter(\n ({ interaction, input, value }) =>\n (!options?.interaction ||\n options.interaction === interaction.key) &&\n (!options?.input || options.input === input.key) &&\n !input.getTargetProps(value).disabled,\n );\n if (!matching.length) return;\n if (matching.length > 1) throw new AmbiguousTargetError(id);\n const domain = matching[0].input.getDomain();\n if (domain.type !== \"boardTarget\") return;\n const value = matching[0].value;\n const target =\n domain.valueKind === \"player-board-space\" && typeof value !== \"string\"\n ? { kind: \"space\" as const, valueKind: domain.valueKind, value }\n : {\n kind,\n valueKind: \"board-id\" as const,\n value: id,\n boardId: board.id,\n };\n context.routeTarget(target, {\n interaction: matching[0].interaction.key,\n input: matching[0].input.key,\n });\n }\n return {\n id,\n getIsEligible: () => eligible,\n getIsSelectable: () => selectable,\n getIsSelected: () => selected,\n getSelectHandler: (options?: RuntimeTargetOptions) => () =>\n select(options),\n getTargetProps(options?: RuntimeTargetOptions) {\n const candidates = matches.filter(\n ({ interaction, input, value }) =>\n (!options?.interaction ||\n interaction.key === options.interaction) &&\n (!options?.input || options.input === input.key) &&\n !input.getTargetProps(value).disabled,\n );\n const only = candidates.length === 1 ? candidates[0] : undefined;\n return {\n type: \"button\" as const,\n disabled: candidates.length === 0,\n \"data-action\": \"select\",\n \"data-value\":\n only && typeof only.value !== \"string\"\n ? JSON.stringify(only.value)\n : id,\n \"data-board\": board.id,\n \"data-interaction\": options?.interaction ?? only?.interaction.key,\n \"data-input\": only?.input.key,\n \"data-eligible\": eligible,\n \"data-selected\": selected,\n \"data-disabled\": candidates.length === 0,\n onClick: () => select(options),\n };\n },\n };\n }\n return target;\n }\n const spaceCollections = new WeakMap<\n object,\n RuntimeCollection<RuntimeSpace>\n >();\n function spacesFor(owner: RuntimeBoard): RuntimeCollection<RuntimeSpace> {\n const cached = spaceCollections.get(owner);\n if (cached) return cached;\n const target = targetsFor(owner);\n const data = owner.data;\n const values = Object.freeze(\n Object.values(data.spaces).map((space) =>\n Object.freeze({\n ...target(\"space\", space.id),\n data: space,\n board: owner,\n }),\n ),\n );\n const byId = new Map(values.map((space) => [space.id, space]));\n const spaces = Object.freeze({\n get: (id: string) =>\n requireLookup(byId.get(id), `Space on board ${owner.id}`, id),\n find: (id: string) => byId.get(id),\n getAll: () => values,\n });\n spaceCollections.set(owner, spaces);\n return spaces;\n }\n return {\n root: {\n get boards() {\n return collection();\n },\n },\n board: {\n get spaces(): RuntimeCollection<RuntimeSpace> {\n return spacesFor(this);\n },\n getLayout(this: RuntimeBoard, options: BoardLayoutOptions) {\n const board = this.data;\n if (board.layout === \"generic\")\n throw new Error(\n `Board '${board.id}' has no spatial geometry; use board.spaces for semantic selection.`,\n );\n const {\n hexSize,\n origin: suppliedOrigin = { x: 0, y: 0 },\n viewport: suppliedViewport = { x: 0, y: 0, scale: 1 },\n } = options;\n const origin = { ...suppliedOrigin };\n const viewport = { ...suppliedViewport };\n if (!Number.isFinite(hexSize) || hexSize <= 0)\n throw new Error(\"hexSize must be positive and finite.\");\n if (\n ![origin.x, origin.y, viewport.x, viewport.y, viewport.scale].every(\n Number.isFinite,\n ) ||\n viewport.scale <= 0\n )\n throw new Error(\n \"Layout transform must be finite with positive scale.\",\n );\n const captured = captures.get(this)!;\n const geometry: Geometry =\n board.layout === \"hex\"\n ? captured.geometry!.getLayout({ hexSize, origin })\n : squareGeometry(board, hexSize, origin);\n const point = (value: Point): Point =>\n Object.freeze({\n x: value.x * viewport.scale + viewport.x,\n y: value.y * viewport.scale + viewport.y,\n });\n const target = targetsFor(this);\n const semanticSpaces = spacesFor(this);\n const spaces = Object.freeze(\n geometry.spaces.map((space) => {\n const corners = Object.freeze(space.corners.map(point));\n const center = point(space.center);\n return Object.freeze({\n ...semanticSpaces.get(space.id),\n center,\n points: () => corners,\n transform: `translate(${center.x} ${center.y})`,\n });\n }),\n );\n const edges = Object.freeze(\n geometry.edges.map((edge) =>\n Object.freeze({\n ...target(\"edge\", edge.id),\n data: board.edges.find((data) => data.id === edge.id),\n center: point({\n x: (edge.from.x + edge.to.x) / 2,\n y: (edge.from.y + edge.to.y) / 2,\n }),\n line: Object.freeze([point(edge.from), point(edge.to)] as const),\n }),\n ),\n );\n const vertices = Object.freeze(\n geometry.vertices.map((vertex) =>\n Object.freeze({\n ...target(\"vertex\", vertex.id),\n data: board.vertices.find((data) => data.id === vertex.id),\n center: point(vertex.center),\n }),\n ),\n );\n return Object.freeze({\n viewBox: Object.freeze({ ...geometry.viewBox }),\n getSpaces: () => spaces,\n getEdges: () => edges,\n getVertices: () => vertices,\n pointToSpace(x: number, y: number) {\n return geometry.pointToSpace({\n x: (x - viewport.x) / viewport.scale,\n y: (y - viewport.y) / viewport.scale,\n });\n },\n });\n },\n } satisfies ThisType<RuntimeBoard>,\n };\n}\n\ntype RuntimeLayout = ReturnType<\n ReturnType<typeof createRuntimeBoardFeature>[\"board\"][\"getLayout\"]\n>;\ntype LayoutTarget<G, Value> = Omit<\n Value,\n \"getSelectHandler\" | \"getTargetProps\"\n> & {\n getSelectHandler(options?: TargetOptions<G>): () => void;\n getTargetProps(options?: TargetOptions<G>): ActionProps;\n};\ntype BoardLayout<G> = Omit<\n RuntimeLayout,\n \"getSpaces\" | \"getEdges\" | \"getVertices\"\n> & {\n getSpaces(): readonly (BoardSpace<G> & {\n readonly center: Point;\n points(): readonly Point[];\n readonly transform: string;\n })[];\n getEdges(): readonly LayoutTarget<\n G,\n ReturnType<RuntimeLayout[\"getEdges\"]>[number]\n >[];\n getVertices(): readonly LayoutTarget<\n G,\n ReturnType<RuntimeLayout[\"getVertices\"]>[number]\n >[];\n};\nexport interface BoardFeature<G> {\n readonly root: { readonly boards: BoardCollection<G> };\n readonly board: {\n readonly spaces: BoardSpaceCollection<G>;\n getLayout(this: BoardBase<G>, options: BoardLayoutOptions): BoardLayout<G>;\n };\n}\n/** Bind one runtime implementation to the same game/source contract as the instance. */\nexport function boardFeature<G>(\n _game: CoreInstance<G>,\n context: FeatureContext<G>,\n): BoardFeature<G> {\n // Game-binding boundary: source identities and installed hooks belong to G.\n // Proven by headless-features/inline-boards type tests and board behavior tests.\n // eslint-disable-next-line no-restricted-syntax -- Instance composition binds these runtime source identities and feature hooks to the same game G.\n return createRuntimeBoardFeature(\n context[runtimeFeatures],\n ) as unknown as BoardFeature<G>;\n}\n","import {\n runtimeFeatures,\n type RuntimeFeatureContext,\n} from \"../runtime-features.js\";\nimport type { RuntimeDropTarget, RuntimeTargetOptions } from \"../targets.js\";\nimport type { DropTarget, TargetOptions } from \"../targets.js\";\nexport type { DropTarget } from \"../targets.js\";\nimport { isSameDropTarget } from \"../drop-targets.js\";\nimport type { CoreInstance, FeatureContext, SeatCardId } from \"../model.js\";\nexport interface DragState<G> {\n readonly cardId: SeatCardId<G>;\n readonly target: DropTarget<G> | null;\n}\n\nexport interface DragController<G> {\n readonly active: DragState<G> | null;\n getCanDrag(cardId: SeatCardId<G>, options?: TargetOptions<G>): boolean;\n begin(cardId: SeatCardId<G>, options?: TargetOptions<G>): boolean;\n getDropTargets(): readonly DropTarget<G>[];\n setDropTarget(target: DropTarget<G> | null): void;\n drop(): void;\n cancel(): void;\n}\n\ninterface RuntimeDragState {\n readonly cardId: string;\n readonly target: RuntimeDropTarget | null;\n}\ninterface RuntimeDragController {\n readonly active: RuntimeDragState | null;\n getCanDrag(cardId: string, options?: RuntimeTargetOptions): boolean;\n begin(cardId: string, options?: RuntimeTargetOptions): boolean;\n getDropTargets(): readonly RuntimeDropTarget[];\n setDropTarget(target: RuntimeDropTarget | null): void;\n drop(): void;\n cancel(): void;\n}\nfunction createRuntimeDragFeature(context: RuntimeFeatureContext) {\n const game = context.game;\n let active: RuntimeDragState | null = null;\n let selection: RuntimeTargetOptions | undefined;\n let source = game.getOptions().source;\n let seat = game.snapshot?.me;\n let disposed = false;\n let version = game.snapshot?.version;\n let lastInteractions = game.interactions;\n let lastCards = game.cards;\n let branch = snapshot();\n function update(next: RuntimeDragState | null) {\n if (disposed) return;\n active = next === null ? null : Object.freeze(next);\n branch = snapshot();\n context.invalidate();\n }\n function targets(\n cardId = active?.cardId,\n selected = selection,\n ): readonly RuntimeDropTarget[] {\n if (!cardId || game.connection !== \"ready\") return [];\n const options = selected;\n const resolved = (game.cards.find(cardId)?.getInteractions() ?? []).flatMap(\n (candidate) => {\n if (\n !candidate.getIsAvailable() ||\n (options?.interaction && candidate.key !== options.interaction)\n )\n return [];\n const inputs = candidate.getInputs();\n const cardInputs = inputs.filter(\n (input) =>\n input.getDomain().type === \"cardTarget\" &&\n (!options?.input || input.key === options.input) &&\n input.getIsEligible(cardId),\n );\n // Without a board input, the card lands on an area that runs the interaction.\n if (!inputs.some((input) => input.getDomain().type === \"boardTarget\"))\n return cardInputs.map((cardInput): RuntimeDropTarget =>\n Object.freeze({\n kind: \"interaction\",\n interactionKey: candidate.key,\n cardInputKey: cardInput.key,\n }),\n );\n return cardInputs.flatMap((cardInput) =>\n inputs.flatMap((input): RuntimeDropTarget[] => {\n const domain = input.getDomain();\n if (domain.type !== \"boardTarget\") return [];\n const route = {\n interactionKey: candidate.key,\n cardInputKey: cardInput.key,\n inputKey: input.key,\n };\n if (domain.valueKind === \"player-board-space\")\n return domain.eligibleTargets\n .filter((value) => !input.getTargetProps(value).disabled)\n .map((value) =>\n Object.freeze({\n kind: \"space\",\n valueKind: domain.valueKind,\n value,\n ...route,\n }),\n );\n return domain.eligibleTargets\n .filter((value) => !input.getTargetProps(value).disabled)\n .map((value) =>\n Object.freeze({\n kind: domain.targetKind,\n valueKind: domain.valueKind,\n value,\n boardId: domain.boardId,\n ...route,\n }),\n );\n }),\n );\n },\n );\n return resolved;\n }\n function cancel() {\n if (active) update(null);\n }\n function snapshot(): RuntimeDragController {\n const captured = active;\n const dropTargets = Object.freeze(targets());\n return Object.freeze<RuntimeDragController>({\n active: captured,\n getCanDrag: (cardId, options) =>\n !disposed && targets(cardId, options).length > 0,\n begin(cardId, options) {\n if (disposed || !targets(cardId, options).length) return false;\n selection = options;\n update({ cardId, target: null });\n return true;\n },\n getDropTargets: () => dropTargets,\n setDropTarget(target: RuntimeDropTarget | null) {\n if (!active || disposed) return;\n if (\n target &&\n !targets().some((candidate) => isSameDropTarget(candidate, target))\n ) {\n update({ ...active, target: null });\n return;\n }\n update({ ...active, target });\n },\n drop() {\n const finished = active;\n const eligible =\n finished?.target &&\n targets().some((target) =>\n isSameDropTarget(target, finished.target!),\n );\n cancel();\n if (!disposed && finished?.target && eligible)\n context.routeCardDrop(finished.cardId, finished.target);\n },\n cancel,\n });\n }\n const unsubscribe = game.subscribe(() => {\n const nextSource = game.getOptions().source;\n const nextSeat = game.snapshot?.me;\n const nextVersion = game.snapshot?.version;\n if (\n nextSource !== source ||\n nextSeat !== seat ||\n nextVersion !== version ||\n game.connection !== \"ready\"\n ) {\n source = nextSource;\n seat = nextSeat;\n version = nextVersion;\n cancel();\n }\n });\n return {\n root: {\n get drag() {\n if (\n lastInteractions !== game.interactions ||\n lastCards !== game.cards\n ) {\n lastInteractions = game.interactions;\n lastCards = game.cards;\n branch = snapshot();\n }\n return branch;\n },\n },\n dispose() {\n unsubscribe();\n cancel();\n disposed = true;\n },\n };\n}\n\n/**\n * Semantic card/drop routing. A card lands on a board destination when its\n * interaction has a board input, otherwise on an area that runs the\n * interaction. Gestures, hit-testing and feedback belong to /react.\n */\nexport function dragFeature<G>(\n _game: CoreInstance<G>,\n context: FeatureContext<G>,\n): { readonly root: { readonly drag: DragController<G> }; dispose(): void } {\n // Game-binding boundary: routes come from this instance's admitted descriptors.\n // The runtime implementation revalidates both inputs atomically on drop.\n return createRuntimeDragFeature(context[runtimeFeatures]) as {\n readonly root: { readonly drag: DragController<G> };\n dispose(): void;\n };\n}\n","/** Native pointer surface; importing a feature never requires browser globals. */\nexport interface PointerSurface {\n setPointerCapture(pointerId: number): void;\n hasPointerCapture(pointerId: number): boolean;\n releasePointerCapture(pointerId: number): void;\n}\n\nexport interface PointerInput {\n readonly pointerId: number;\n readonly button: number;\n readonly clientX: number;\n readonly clientY: number;\n readonly currentTarget: PointerSurface;\n preventDefault(): void;\n}\n\nexport interface Point {\n readonly x: number;\n readonly y: number;\n}\n\nexport interface PointerMove {\n readonly origin: Point;\n readonly point: Point;\n readonly delta: Point;\n}\n\n/** One captured gesture. Pointer cancellation and disposal never commit a drop. */\nexport function createPointerSession(callbacks: {\n move(value: PointerMove): void;\n end(value: PointerMove): void;\n cancel(): void;\n}) {\n let disposed = false;\n let active:\n | { id: number; surface: PointerSurface; origin: Point; point: Point }\n | undefined;\n\n function value(): PointerMove {\n const { origin, point } = active!;\n return {\n origin,\n point,\n delta: { x: point.x - origin.x, y: point.y - origin.y },\n };\n }\n\n function release() {\n const previous = active;\n active = undefined;\n if (previous?.surface.hasPointerCapture(previous.id)) {\n previous.surface.releasePointerCapture(previous.id);\n }\n }\n\n function cancel() {\n if (!active) return;\n release();\n callbacks.cancel();\n }\n\n return {\n start(event: PointerInput): boolean {\n if (disposed || active || event.button !== 0) return false;\n event.currentTarget.setPointerCapture(event.pointerId);\n const point = { x: event.clientX, y: event.clientY };\n active = {\n id: event.pointerId,\n surface: event.currentTarget,\n origin: point,\n point,\n };\n event.preventDefault();\n return true;\n },\n move(event: PointerInput) {\n if (event.pointerId !== active?.id) return;\n active.point = { x: event.clientX, y: event.clientY };\n event.preventDefault();\n callbacks.move(value());\n },\n end(event: PointerInput) {\n if (event.pointerId !== active?.id) return;\n active.point = { x: event.clientX, y: event.clientY };\n const result = value();\n release();\n callbacks.end(result);\n },\n cancel(event?: Pick<PointerInput, \"pointerId\">) {\n if (event && event.pointerId !== active?.id) return;\n cancel();\n },\n dispose() {\n disposed = true;\n cancel();\n },\n };\n}\n","import type { CoreInstance, FeatureContext } from \"../model.js\";\nimport {\n createPointerSession,\n type PointerInput,\n type PointerSurface,\n} from \"./pointer-session.js\";\n\nexport interface ViewportTransform {\n readonly x: number;\n readonly y: number;\n readonly scale: number;\n}\nexport interface ViewportSurface extends PointerSurface {\n getBoundingClientRect(): {\n readonly left: number;\n readonly top: number;\n readonly height: number;\n };\n}\nexport interface WheelInput {\n readonly clientX: number;\n readonly clientY: number;\n readonly deltaY: number;\n readonly deltaMode: number;\n readonly currentTarget: ViewportSurface;\n preventDefault(): void;\n}\nexport interface PanZoomOptions {\n readonly initial?: ViewportTransform;\n readonly minScale?: number;\n readonly maxScale?: number;\n}\n\n/** Native pointer panning and wheel zoom around the cursor. No document listeners. */\nexport function panZoomFeature<G>(\n game: CoreInstance<G>,\n context: FeatureContext<G>,\n options: PanZoomOptions = {},\n) {\n const minScale = options.minScale ?? 0.25;\n const maxScale = options.maxScale ?? 4;\n if (\n !Number.isFinite(minScale) ||\n !Number.isFinite(maxScale) ||\n minScale <= 0 ||\n maxScale < minScale\n ) {\n throw new Error(\n \"Viewport scale limits must be positive, finite, and ordered.\",\n );\n }\n const initial = options.initial ?? { x: 0, y: 0, scale: 1 };\n let disposed = false;\n let source = game.getOptions().source;\n let seat = game.snapshot?.me;\n let dragOrigin = initial;\n let transform = admit(initial);\n let branch = snapshot();\n\n function admit(value: ViewportTransform): ViewportTransform {\n if (\n ![value.x, value.y, value.scale].every(Number.isFinite) ||\n value.scale <= 0\n ) {\n throw new Error(\n \"Viewport transform must have finite coordinates and positive scale.\",\n );\n }\n return Object.freeze({\n x: value.x,\n y: value.y,\n scale: Math.min(maxScale, Math.max(minScale, value.scale)),\n });\n }\n function update(value: ViewportTransform) {\n if (disposed) return;\n const next = admit(value);\n if (\n next.x === transform.x &&\n next.y === transform.y &&\n next.scale === transform.scale\n )\n return;\n transform = next;\n branch = snapshot();\n context.invalidate();\n }\n const pointer = createPointerSession({\n move: ({ delta }) =>\n update({\n ...dragOrigin,\n x: dragOrigin.x + delta.x,\n y: dragOrigin.y + delta.y,\n }),\n end: ({ delta }) =>\n update({\n ...dragOrigin,\n x: dragOrigin.x + delta.x,\n y: dragOrigin.y + delta.y,\n }),\n cancel() {},\n });\n function props() {\n return {\n style: { touchAction: \"none\" as const },\n onPointerDown(event: PointerInput) {\n if (pointer.start(event)) dragOrigin = transform;\n },\n onPointerMove: pointer.move,\n onPointerUp: pointer.end,\n onPointerCancel: pointer.cancel,\n onLostPointerCapture: pointer.cancel,\n onWheel(event: WheelInput) {\n if (disposed) return;\n event.preventDefault();\n const rect = event.currentTarget.getBoundingClientRect();\n const unit =\n event.deltaMode === 1 ? 16 : event.deltaMode === 2 ? rect.height : 1;\n const scale = Math.min(\n maxScale,\n Math.max(\n minScale,\n transform.scale * Math.exp(-event.deltaY * unit * 0.002),\n ),\n );\n const x = event.clientX - rect.left;\n const y = event.clientY - rect.top;\n const ratio = scale / transform.scale;\n update({\n x: x - (x - transform.x) * ratio,\n y: y - (y - transform.y) * ratio,\n scale,\n });\n },\n };\n }\n function snapshot() {\n const captured = transform;\n return Object.freeze({\n transform: captured,\n getTransform: () => captured,\n getProps: props,\n setTransform: update,\n reset: () => {\n pointer.cancel();\n update(initial);\n },\n });\n }\n const unsubscribe = game.subscribe(() => {\n const nextSource = game.getOptions().source;\n const nextSeat = game.snapshot?.me;\n if (nextSource !== source || nextSeat !== seat) {\n source = nextSource;\n seat = nextSeat;\n pointer.cancel();\n update(initial);\n }\n });\n return {\n root: {\n get viewport() {\n return branch;\n },\n },\n dispose() {\n disposed = true;\n unsubscribe();\n pointer.dispose();\n },\n };\n}\n","import type { CoreInstance, IdOf, SeatCardId } from \"../model.js\";\nimport type { SourceSnapshot } from \"../sources/types.js\";\n\n/**\n * Where a card that arrived in its zone with the current frame was on the\n * previous one: another zone, or the private zones of the player who moved.\n * `hidden` says whether the seat saw only the card's back there.\n */\nexport type CardOrigin<G> =\n | { readonly zone: IdOf<G, \"zoneId\">; readonly hidden: boolean }\n | { readonly player: IdOf<G, \"playerId\">; readonly hidden: true };\n\ntype RuntimeOrigin =\n | { readonly zone: string; readonly hidden: boolean }\n | { readonly player: string; readonly hidden: true };\ntype Zones = SourceSnapshot[\"frame\"][\"zones\"];\n\nconst isHidden = (cardId: string) => cardId.startsWith(\"hidden:\");\nconst hiddenCount = (zones: Zones, zone: string) =>\n zones[zone]?.cardIds.filter(isHidden).length ?? 0;\n\nfunction singleOrigin(\n departures: readonly { readonly zone: string; readonly hidden: boolean }[],\n count: number,\n) {\n const origin = departures[0];\n return origin &&\n departures.length >= count &&\n departures.every(\n (card) => card.zone === origin.zone && card.hidden === origin.hidden,\n )\n ? Object.freeze(origin)\n : null;\n}\n\n/**\n * Visible ids are card identities, so a visible card is followed between\n * zones. Hidden ids are positions, so only their net counts are compared.\n * An inferred origin requires one compatible source with enough departures;\n * existing hidden cards make the arriving positions ambiguous. Unexplained\n * arrivals can come from the sole mover's private zones, which the seat's\n * frame does not list. Ambiguous origins are omitted.\n */\nexport function findCardOrigins(\n previous: Zones,\n next: Zones,\n mover: string | null,\n): ReadonlyMap<string, RuntimeOrigin> {\n const shownBefore = new Map<string, string>();\n for (const [zone, { cardIds }] of Object.entries(previous))\n for (const cardId of cardIds)\n if (!isHidden(cardId)) shownBefore.set(cardId, zone);\n const shownNow = new Set(\n Object.values(next).flatMap(({ cardIds }) =>\n cardIds.filter((cardId) => !isHidden(cardId)),\n ),\n );\n let left = Object.entries(previous).flatMap(([zone, { cardIds }]) => [\n ...cardIds\n .filter((cardId) => !isHidden(cardId) && !shownNow.has(cardId))\n .map(() => ({ zone, hidden: false })),\n ...Array.from(\n {\n length: Math.max(\n 0,\n hiddenCount(previous, zone) - hiddenCount(next, zone),\n ),\n },\n () => ({ zone, hidden: true }),\n ),\n ]);\n const origins = new Map<string, RuntimeOrigin>();\n const shownArrivals: string[] = [];\n const hiddenArrivals: (string | null)[] = [];\n for (const [zone, { cardIds }] of Object.entries(next)) {\n for (const cardId of cardIds) {\n if (isHidden(cardId)) continue;\n const from = shownBefore.get(cardId);\n if (from === undefined) shownArrivals.push(cardId);\n else if (from !== zone)\n origins.set(cardId, Object.freeze({ zone: from, hidden: false }));\n }\n const hidden = cardIds.filter(isHidden);\n const before = hiddenCount(previous, zone);\n // Count ambiguous arrivals too, so another destination cannot claim their source.\n hiddenArrivals.push(\n ...Array.from(\n { length: Math.max(0, hidden.length - before) },\n (_, index) => (before === 0 ? hidden[index] : null),\n ),\n );\n }\n // Concealing a visible card can replace a hidden departure without changing\n // the hidden count. Net counts cannot resolve those simultaneous movements.\n if (\n left.some(\n (card) =>\n !card.hidden &&\n hiddenCount(previous, card.zone) > 0 &&\n hiddenCount(next, card.zone) > 0,\n )\n )\n return origins;\n const hiddenLeft = left.filter((card) => card.hidden);\n if (shownArrivals.length) {\n const origin = singleOrigin(hiddenLeft, shownArrivals.length);\n if (origin) {\n for (const cardId of shownArrivals) origins.set(cardId, origin);\n left = [\n ...left.filter((card) => !card.hidden),\n ...hiddenLeft.slice(shownArrivals.length),\n ];\n } else if (hiddenLeft.length) {\n // Which departures the shown cards consumed is also ambiguous.\n return origins;\n } else if (mover !== null) {\n const origin = Object.freeze({ player: mover, hidden: true as const });\n for (const cardId of shownArrivals) origins.set(cardId, origin);\n }\n }\n const hiddenOrigin =\n singleOrigin(left, hiddenArrivals.length) ??\n (left.length === 0 && mover !== null\n ? Object.freeze({ player: mover, hidden: true as const })\n : null);\n if (hiddenOrigin) {\n for (const cardId of hiddenArrivals)\n if (cardId !== null) origins.set(cardId, hiddenOrigin);\n }\n return origins;\n}\n\n/** The sole active player, when it is another seat. */\nfunction moverOf(snapshot: SourceSnapshot) {\n const active = snapshot.frame.flow.activePlayers;\n return active.length === 1 && active[0] !== snapshot.me ? active[0] : null;\n}\n\n/**\n * Adds `card.getOrigin()`: where a card that arrived in its zone with the\n * current frame came from, or null. Origins last until the next frame and\n * reset when the seat or source changes. Hidden origins are inferred from\n * net counts; ambiguous sources and arriving positions return null.\n */\nexport function originsFeature<G>(game: CoreInstance<G>) {\n type Origins = ReadonlyMap<SeatCardId<G>, CardOrigin<G>>;\n let frame = game.snapshot;\n let source = game.getOptions().source;\n let origins: Origins = new Map();\n function sync() {\n const next = game.snapshot;\n const nextSource = game.getOptions().source;\n if (\n next?.version === frame?.version &&\n next?.me === frame?.me &&\n nextSource === source\n )\n return;\n // Game-binding boundary: card, zone and player ids come from this instance's frames.\n origins =\n frame && next && next.me === frame.me && nextSource === source\n ? (findCardOrigins(\n frame.frame.zones,\n next.frame.zones,\n next.version === frame.version + 1 ? moverOf(frame) : null,\n ) as Origins)\n : new Map();\n frame = next;\n source = nextSource;\n }\n // Also read lazily, so a reader notified before this listener sees the new frame's origins.\n const unsubscribe = game.subscribe(sync);\n return {\n card: {\n getOrigin(this: { readonly id: SeatCardId<G> }): CardOrigin<G> | null {\n sync();\n return origins.get(this.id) ?? null;\n },\n },\n dispose: unsubscribe,\n };\n}\n","const RADIANS = Math.PI / 180;\n\nexport interface FanOptions {\n readonly count: number;\n /** The width available to the fan, in pixels. */\n readonly width: number;\n readonly cardWidth: number;\n readonly cardHeight: number;\n /** Distance between neighbouring cards along the arc when there is room. Default: 60% of the card width. */\n readonly step?: number;\n /** The smallest visible slice of a covered card. Default: 25% of the card width. */\n readonly minStep?: number;\n /** Degrees between neighbouring cards. Default 5; 0 lays a straight row. */\n readonly angle?: number;\n /** The most degrees between the two end cards. Default 30. */\n readonly maxSpread?: number;\n}\n\n/** A card's CSS `translate` from the fan's top-left corner, and its `rotate` about its own centre. */\nexport interface FanCard {\n readonly x: number;\n readonly y: number;\n /** Degrees clockwise. */\n readonly rotate: number;\n}\n\nexport interface FanLayout {\n readonly cards: readonly FanCard[];\n /** The fan's bounding box. It is wider than the available width only when the cards are at `minStep`. */\n readonly width: number;\n readonly height: number;\n}\n\n/**\n * Lays cards on a circular arc. The spread grows with the card count up to\n * `maxSpread`; the step shrinks continuously to fit the width, down to\n * `minStep`, past which the fan overflows and the hand should scroll.\n */\nexport function fanLayout({\n count,\n width,\n cardWidth,\n cardHeight,\n step = cardWidth * 0.6,\n minStep = cardWidth * 0.25,\n angle = 5,\n maxSpread = 30,\n}: FanOptions): FanLayout {\n if (count < 1) return { cards: [], width: 0, height: 0 };\n const gaps = count - 1;\n const delta = gaps ? Math.min(angle, maxSpread / gaps) * RADIANS : 0;\n const edge = (gaps * delta) / 2;\n // The horizontal distance between the end cards' centres is `spacing * span`.\n const span = delta ? (2 * Math.sin(edge)) / delta : gaps;\n // The end cards' outer halves, tilted by the edge angle.\n const ends = cardWidth * Math.cos(edge) + cardHeight * Math.sin(edge);\n const spacing = span\n ? Math.max(minStep, Math.min(step, (width - ends) / span))\n : 0;\n const radius = delta ? spacing / delta : 0;\n const centres = Array.from({ length: count }, (_, index) => {\n if (!delta) return { theta: 0, x: (index - gaps / 2) * spacing, y: 0 };\n const theta = (index - gaps / 2) * delta;\n return {\n theta,\n x: radius * Math.sin(theta),\n y: radius * (1 - Math.cos(theta)),\n };\n });\n const halfHeight = (theta: number) =>\n (cardHeight / 2) * Math.cos(theta) +\n (cardWidth / 2) * Math.abs(Math.sin(theta));\n const top = Math.min(\n ...centres.map((card) => card.y - halfHeight(card.theta)),\n );\n const bottom = Math.max(\n ...centres.map((card) => card.y + halfHeight(card.theta)),\n );\n const fanWidth = spacing * span + ends;\n return {\n cards: centres.map((card) => ({\n x: card.x + (fanWidth - cardWidth) / 2,\n y: card.y - top - cardHeight / 2,\n rotate: card.theta / RADIANS,\n })),\n width: fanWidth,\n height: bottom - top,\n };\n}\n\n/** Moves a fanned card outward along its own tilt, as for a selected card. */\nexport function liftFanCard(card: FanCard, distance: number): FanCard {\n const theta = card.rotate * RADIANS;\n return {\n x: card.x + distance * Math.sin(theta),\n y: card.y - distance * Math.cos(theta),\n rotate: card.rotate,\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;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@@ -1,8 +1,8 @@
1
- import { c as BoardIdOfTable, aU as SpaceIdOfTable, a$ as TiledBoardIdOfTable, b0 as TiledEdgeIdOfTable, b2 as TiledVertexIdOfTable, d as BoardStateOfTable, ai as PlayerIdOfTable, N as InputDomain, aJ as RuntimeJson, aB as RuntimeBoardCollections, aD as RuntimeBoardState, ag as PhaseNamesOfDefinition, Z as InteractionIdOfDefinitionPhase, k as ClientParamsOfInteractionOfDefinition, M as InputCollectorOfDefinition, _ as InteractionInputDescriptor, b8 as ViewOfDefinition, I as HiddenCardId, G as GameEvent } from './extract-Bjuw_gdF.js';
1
+ import { c as BoardIdOfTable, aU as SpaceIdOfTable, a$ as TiledBoardIdOfTable, b0 as TiledEdgeIdOfTable, b2 as TiledVertexIdOfTable, d as BoardStateOfTable, ai as PlayerIdOfTable, N as InputDomain, aJ as RuntimeJson, aB as RuntimeBoardCollections, aD as RuntimeBoardState, ag as PhaseNamesOfDefinition, Z as InteractionIdOfDefinitionPhase, k as ClientParamsOfInteractionOfDefinition, M as InputCollectorOfDefinition, _ as InteractionInputDescriptor, ba as ViewOfDefinition, I as HiddenCardId, b4 as ViewCard, b5 as ViewCardOfTable, G as GameEvent } from './extract--xGrzaA9.js';
2
2
  import { P as PlayerBoardSpaceTarget } from './board-target-B0QG6OYx.js';
3
3
  import { z } from 'zod';
4
4
  import { Store } from '@tanstack/store';
5
- import { h as SourceSnapshot, i as SourceState, G as GameSource, I as InteractionDescriptor, j as SubmitResult } from './types-B3kIhBWb.js';
5
+ import { h as SourceSnapshot, i as SourceState, G as GameSource, I as InteractionDescriptor, j as SubmitResult } from './types-Dkcj6g_z.js';
6
6
 
7
7
  type RuntimeBoardTarget = {
8
8
  readonly valueKind: "board-id";
@@ -424,17 +424,12 @@ type Interaction<G, F extends Features, K extends InteractionKey<G>> = Interacti
424
424
  type ReadonlyData<T> = T extends readonly (infer Item)[] ? readonly ReadonlyData<Item>[] : T extends object ? {
425
425
  readonly [K in keyof T]: ReadonlyData<T[K]>;
426
426
  } : T;
427
- type CardDataOf<G, K extends string> = G extends {
428
- contract: {
429
- manifest: {
430
- tableSchema: infer Schema extends z.ZodType;
431
- };
432
- };
433
- } ? z.output<Schema> extends {
434
- cards: infer Cards;
435
- } ? K extends keyof Cards ? ReadonlyData<Cards[K]> & {
436
- readonly id: K;
437
- } : never : never : Readonly<Record<string, RuntimeJson>>;
427
+ type CardDataOf<G, K extends string> = [TableOfGame<G>] extends [never] ? ReadonlyData<ViewCard<K>> : TableOfGame<G> extends {
428
+ cards: Record<string, {
429
+ cardType: string;
430
+ properties: Record<string, unknown>;
431
+ }>;
432
+ } ? K extends keyof TableOfGame<G>["cards"] ? ReadonlyData<ViewCardOfTable<TableOfGame<G>, K>> : never : never;
438
433
  interface CardEntity<G> {
439
434
  readonly zone: IdOf<G, "zoneId">;
440
435
  readonly index: number;
package/dist/react.d.ts CHANGED
@@ -1,8 +1,8 @@
1
1
  import * as react from 'react';
2
2
  import { PointerEvent, MouseEvent, DragEvent, CSSProperties, ReactNode } from 'react';
3
- import { a2 as SeatCardId, a5 as TargetOptions, q as Features, E as InstanceOptions, n as CoreInstance, p as FeatureContext, G as GameInstance, r as GameSnapshot, o as DropTarget } from './model-D2Z9j0Yi.js';
4
- import { G as GameSource } from './types-B3kIhBWb.js';
5
- import './extract-Bjuw_gdF.js';
3
+ import { a5 as TargetOptions, a2 as SeatCardId, q as Features, E as InstanceOptions, n as CoreInstance, p as FeatureContext, G as GameInstance, r as GameSnapshot, o as DropTarget } from './model-BvimcW9Q.js';
4
+ import { G as GameSource } from './types-Dkcj6g_z.js';
5
+ import './extract--xGrzaA9.js';
6
6
  import 'zod';
7
7
  import 'honeycomb-grid';
8
8
  import './board-target-B0QG6OYx.js';
@@ -22,6 +22,10 @@ interface CardGestureProps {
22
22
  interface SelectionOptions<Value> {
23
23
  readonly compare?: (previous: Value, next: Value) => boolean;
24
24
  }
25
+ /** Inspection stays enabled when this control does not support dragging. */
26
+ interface CardGestureOptions<Game> {
27
+ readonly drag: false | TargetOptions<Game>;
28
+ }
25
29
  /** An area that runs this interaction with whichever card is dropped on it. */
26
30
  type DropAreaBinding<G> = Exclude<TargetOptions<G>, {
27
31
  readonly interaction?: undefined;
@@ -67,9 +71,9 @@ declare function createGameHook<Game, Source extends GameSource = GameSource>():
67
71
  compare?: SelectionOptions<Value>["compare"];
68
72
  children: (value: Value) => ReactNode;
69
73
  }) => ReactNode;
70
- useCardGesture: (cardId: SeatCardId<Game>, options?: TargetOptions<Game>) => CardGesture;
74
+ useCardGesture: (cardId: SeatCardId<Game>, options: CardGestureOptions<Game>) => CardGesture;
71
75
  useDropArea: (binding: DropTarget<Game> | DropAreaBinding<Game> | null) => DropArea;
72
76
  useDragOverlay: () => DragOverlay<Game> | null;
73
77
  };
74
78
 
75
- export { type CardGesture, type CardGestureProps, type DragOverlay, type DropArea, type DropAreaBinding, type SelectionOptions, createGameHook };
79
+ export { type CardGesture, type CardGestureOptions, type CardGestureProps, type DragOverlay, type DropArea, type DropAreaBinding, type SelectionOptions, createGameHook };
package/dist/react.js CHANGED
@@ -3,9 +3,9 @@ import {
3
3
  createGameInstance,
4
4
  createGestureRecognizer,
5
5
  isSameDropTarget
6
- } from "./chunk-HZPKKBEG.js";
6
+ } from "./chunk-ZH5BENBP.js";
7
7
  import "./chunk-DMFVAZI2.js";
8
- import "./chunk-3JXUL4VN.js";
8
+ import "./chunk-DPRHGA2C.js";
9
9
 
10
10
  // src/react/gesture.tsx
11
11
  import { createStore } from "@tanstack/store";
@@ -21,6 +21,11 @@ var CARD_STYLE = Object.freeze({
21
21
  WebkitUserSelect: "none",
22
22
  WebkitTouchCallout: "none"
23
23
  });
24
+ var INSPECTION_STYLE = Object.freeze({
25
+ ...CARD_STYLE,
26
+ // Inspection-only cards should not block their table's native scrolling.
27
+ touchAction: "manipulation"
28
+ });
24
29
  var px = (value) => `${value}px`;
25
30
  function resolveDropArea(drag, binding) {
26
31
  if (!drag || !binding) return null;
@@ -98,7 +103,8 @@ function createGestureSession(game) {
98
103
  set({ inspect: { cardId, via: "hold" } });
99
104
  },
100
105
  dragStart(origin) {
101
- if (!game.drag?.begin(cardId, options)) return false;
106
+ if (options === false || !game.drag?.begin(cardId, options))
107
+ return false;
102
108
  const box = element.getBoundingClientRect();
103
109
  clearHover();
104
110
  press.dragging = true;
@@ -196,7 +202,7 @@ function createGestureSession(game) {
196
202
  event.preventDefault();
197
203
  },
198
204
  onDragStart: (event) => event.preventDefault(),
199
- style: CARD_STYLE,
205
+ style: options === false ? INSPECTION_STYLE : CARD_STYLE,
200
206
  "data-dragging": flags.dragging || void 0,
201
207
  "data-inspecting": flags.inspecting ?? void 0
202
208
  };
@@ -332,9 +338,9 @@ function createGameHook() {
332
338
  const dragOf = (snapshot) => snapshot.drag;
333
339
  function useCardGesture(cardId, options) {
334
340
  const session = useGestureSession();
335
- const routes = options;
341
+ const routes = options.drag;
336
342
  const canDrag = useGame(
337
- (snapshot) => dragOf(snapshot)?.getCanDrag(cardId, routes) ?? false
343
+ (snapshot) => routes !== false && (dragOf(snapshot)?.getCanDrag(cardId, routes) ?? false)
338
344
  );
339
345
  const dragging = useGestureState(
340
346
  session,