@dreamboard-games/sdk 0.5.0-alpha.2 → 0.5.0-alpha.4

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.
Files changed (151) hide show
  1. package/README.md +186 -45
  2. package/dist/board-target-B0QG6OYx.d.ts +8 -0
  3. package/dist/chunk-3JXUL4VN.js +139 -0
  4. package/dist/chunk-3JXUL4VN.js.map +1 -0
  5. package/dist/{chunk-S2JEDVWH.js → chunk-C77SYIVT.js} +6102 -6505
  6. package/dist/chunk-C77SYIVT.js.map +1 -0
  7. package/dist/chunk-DMFVAZI2.js +16 -0
  8. package/dist/chunk-DMFVAZI2.js.map +1 -0
  9. package/dist/chunk-OOFMBCFF.js +1338 -0
  10. package/dist/chunk-OOFMBCFF.js.map +1 -0
  11. package/dist/chunk-UG2Q4NLG.js +590 -0
  12. package/dist/chunk-UG2Q4NLG.js.map +1 -0
  13. package/dist/chunk-XU6WJW6K.js +847 -0
  14. package/dist/chunk-XU6WJW6K.js.map +1 -0
  15. package/dist/diagnostics-B8d5aLad.d.ts +65 -0
  16. package/dist/extract-gVKcB8Og.d.ts +4736 -0
  17. package/dist/index.d.ts +3782 -1
  18. package/dist/index.js +1096 -6
  19. package/dist/index.js.map +1 -1
  20. package/dist/model-vdpLHrxh.d.ts +432 -0
  21. package/dist/react.d.ts +60 -0
  22. package/dist/react.js +208 -0
  23. package/dist/react.js.map +1 -0
  24. package/dist/reducer.d.ts +1244 -78
  25. package/dist/reducer.js +4204 -121
  26. package/dist/reducer.js.map +1 -1
  27. package/dist/testing.d.ts +520 -564
  28. package/dist/testing.js +2451 -915
  29. package/dist/testing.js.map +1 -1
  30. package/dist/types-Bj5ZLTUV.d.ts +114 -0
  31. package/package.json +40 -142
  32. package/dist/HandView-Bi2lxzQP.d.ts +0 -79
  33. package/dist/ResourceCounter-BFxJknqp.d.ts +0 -98
  34. package/dist/ThemeProvider-CElaL2ik.d.ts +0 -99
  35. package/dist/attributes-DbvyMbXw.d.ts +0 -68
  36. package/dist/browser-interaction.d.ts +0 -910
  37. package/dist/browser-interaction.js +0 -119
  38. package/dist/browser-interaction.js.map +0 -1
  39. package/dist/chunk-32PFKDV7.js +0 -11705
  40. package/dist/chunk-32PFKDV7.js.map +0 -1
  41. package/dist/chunk-3BAD4VC2.js +0 -263
  42. package/dist/chunk-3BAD4VC2.js.map +0 -1
  43. package/dist/chunk-3SKDNDPG.js +0 -104
  44. package/dist/chunk-3SKDNDPG.js.map +0 -1
  45. package/dist/chunk-5YV2WHJ4.js +0 -25
  46. package/dist/chunk-5YV2WHJ4.js.map +0 -1
  47. package/dist/chunk-ANRB4XKA.js +0 -90
  48. package/dist/chunk-ANRB4XKA.js.map +0 -1
  49. package/dist/chunk-BI4G3PM2.js +0 -1864
  50. package/dist/chunk-BI4G3PM2.js.map +0 -1
  51. package/dist/chunk-EVCLTY4Q.js +0 -935
  52. package/dist/chunk-EVCLTY4Q.js.map +0 -1
  53. package/dist/chunk-GDPKTBUR.js +0 -564
  54. package/dist/chunk-GDPKTBUR.js.map +0 -1
  55. package/dist/chunk-H6VDGFL5.js +0 -2903
  56. package/dist/chunk-H6VDGFL5.js.map +0 -1
  57. package/dist/chunk-LR3ZTWQF.js +0 -5960
  58. package/dist/chunk-LR3ZTWQF.js.map +0 -1
  59. package/dist/chunk-PF7L4BMG.js +0 -117
  60. package/dist/chunk-PF7L4BMG.js.map +0 -1
  61. package/dist/chunk-PN5O6GG2.js +0 -32
  62. package/dist/chunk-PN5O6GG2.js.map +0 -1
  63. package/dist/chunk-PZ5AY32C.js +0 -10
  64. package/dist/chunk-PZ5AY32C.js.map +0 -1
  65. package/dist/chunk-S2JEDVWH.js.map +0 -1
  66. package/dist/chunk-T3ZKNUZ7.js +0 -1
  67. package/dist/chunk-T3ZKNUZ7.js.map +0 -1
  68. package/dist/chunk-UGH54WZ2.js +0 -223
  69. package/dist/chunk-UGH54WZ2.js.map +0 -1
  70. package/dist/chunk-VCDWP5VL.js +0 -746
  71. package/dist/chunk-VCDWP5VL.js.map +0 -1
  72. package/dist/chunk-VDXOF4FW.js +0 -69
  73. package/dist/chunk-VDXOF4FW.js.map +0 -1
  74. package/dist/chunk-WHR5UW3F.js +0 -1988
  75. package/dist/chunk-WHR5UW3F.js.map +0 -1
  76. package/dist/chunk-Y75CFE77.js +0 -17
  77. package/dist/chunk-Y75CFE77.js.map +0 -1
  78. package/dist/chunk-Z7QCREWI.js +0 -3435
  79. package/dist/chunk-Z7QCREWI.js.map +0 -1
  80. package/dist/chunk-ZZGN2ATS.js +0 -1941
  81. package/dist/chunk-ZZGN2ATS.js.map +0 -1
  82. package/dist/components-gAbIz7hK.d.ts +0 -1284
  83. package/dist/definitions-BgmV_GhC.d.ts +0 -300
  84. package/dist/diagnostics-DIi3ina7.d.ts +0 -50
  85. package/dist/digest.d.ts +0 -8
  86. package/dist/game-CsZScpcn.d.ts +0 -763
  87. package/dist/hex-board-view-aKkblDp6.d.ts +0 -1228
  88. package/dist/index-CcT9Q7N7.d.ts +0 -193
  89. package/dist/index.d-DjzoK7zn.d.ts +0 -2101
  90. package/dist/package-set.d.ts +0 -13
  91. package/dist/package-set.js +0 -12
  92. package/dist/package-set.js.map +0 -1
  93. package/dist/player-state-Cqpyeql0.d.ts +0 -371
  94. package/dist/plugin-runtime-contract.d.ts +0 -17
  95. package/dist/plugin-runtime-contract.js +0 -92
  96. package/dist/plugin-runtime-contract.js.map +0 -1
  97. package/dist/primitive-props-BNHDkgd7.d.ts +0 -16
  98. package/dist/protocol-dYgafTYY.d.ts +0 -314
  99. package/dist/reducer/advanced.d.ts +0 -82
  100. package/dist/reducer/advanced.js +0 -51
  101. package/dist/reducer/advanced.js.map +0 -1
  102. package/dist/reducer-contract.d.ts +0 -11
  103. package/dist/reducer-contract.js +0 -16
  104. package/dist/reducer-contract.js.map +0 -1
  105. package/dist/reference-games/index.d.ts +0 -31
  106. package/dist/reference-games/index.js +0 -48
  107. package/dist/reference-games/index.js.map +0 -1
  108. package/dist/runtime/primitives.d.ts +0 -250
  109. package/dist/runtime/primitives.js +0 -189
  110. package/dist/runtime/primitives.js.map +0 -1
  111. package/dist/runtime/runtime-api.d.ts +0 -2
  112. package/dist/runtime/runtime-api.js +0 -1
  113. package/dist/runtime/runtime-api.js.map +0 -1
  114. package/dist/runtime/workspace-contract.d.ts +0 -392
  115. package/dist/runtime/workspace-contract.js +0 -28
  116. package/dist/runtime/workspace-contract.js.map +0 -1
  117. package/dist/runtime-RJ5orDJU.d.ts +0 -1699
  118. package/dist/runtime-api-Bz5pwNU_.d.ts +0 -296
  119. package/dist/runtime-json-CQ9QbLZ5.d.ts +0 -5
  120. package/dist/runtime.d.ts +0 -83
  121. package/dist/runtime.js +0 -242
  122. package/dist/runtime.js.map +0 -1
  123. package/dist/schema.d.ts +0 -379
  124. package/dist/stale-contract-artifact-error-XLaweZtF.d.ts +0 -18
  125. package/dist/testing-compiler.d.ts +0 -37
  126. package/dist/testing-compiler.js +0 -272
  127. package/dist/testing-compiler.js.map +0 -1
  128. package/dist/testing-runtime.d.ts +0 -119
  129. package/dist/testing-runtime.js +0 -212
  130. package/dist/testing-runtime.js.map +0 -1
  131. package/dist/types-DJj5MJkl.d.ts +0 -256
  132. package/dist/types-DR7DoB1x.d.ts +0 -28
  133. package/dist/types-JWCYHmu7.d.ts +0 -122
  134. package/dist/types.d.ts +0 -1958
  135. package/dist/types.js +0 -14
  136. package/dist/types.js.map +0 -1
  137. package/dist/ui/components.d.ts +0 -17
  138. package/dist/ui/components.js +0 -216
  139. package/dist/ui/components.js.map +0 -1
  140. package/dist/ui/defaults.d.ts +0 -19
  141. package/dist/ui/defaults.js +0 -104
  142. package/dist/ui/defaults.js.map +0 -1
  143. package/dist/ui/player-state.d.ts +0 -2
  144. package/dist/ui/player-state.js +0 -1
  145. package/dist/ui/player-state.js.map +0 -1
  146. package/dist/ui/plugin-styles.css +0 -2
  147. package/dist/ui-contract-GTUPkf8z.d.ts +0 -1168
  148. package/dist/ui.d.ts +0 -317
  149. package/dist/ui.js +0 -277
  150. package/dist/ui.js.map +0 -1
  151. package/dist/views-BpuWcOyN.d.ts +0 -1641
@@ -0,0 +1,114 @@
1
+ import { Store } from '@tanstack/store';
2
+ import { Q as InteractionDescriptor$1, G as GameEvent, aO as SimultaneousPhaseProjection, aN as SeatProjectionBundle, e as BoardStaticProjection, aC as RuntimeJson } from './extract-gVKcB8Og.js';
3
+
4
+ type PlayerId = string;
5
+ interface GameplayBasis {
6
+ readonly version: number;
7
+ readonly actionSetVersion: string;
8
+ readonly perspectivePlayerId: PlayerId;
9
+ }
10
+ interface PluginPlayerSummary {
11
+ readonly playerId: PlayerId;
12
+ readonly displayName: string;
13
+ readonly color?: string;
14
+ }
15
+ interface PluginSessionDescriptor {
16
+ readonly sessionId: string;
17
+ /** Turn order is the order of this array. */
18
+ readonly players: readonly PluginPlayerSummary[];
19
+ /**
20
+ * Game image files by manifest path, such as `assets/cards/front.webp`.
21
+ * Sources replace card `frontImage` and `backImage` paths with object URLs.
22
+ */
23
+ readonly assets?: Readonly<Record<string, Blob>>;
24
+ }
25
+
26
+ type InteractionDescriptor<Interaction extends string = string> = Omit<InteractionDescriptor$1, "interactionKey"> & {
27
+ readonly interactionKey: Interaction;
28
+ };
29
+ type ActionInteractionDescriptor<Interaction extends string = string> = InteractionDescriptor<Interaction>;
30
+ interface ZoneHandlesSnapshot<Interaction extends string = string> {
31
+ readonly cardIds: readonly string[];
32
+ readonly cardViewsById: Readonly<Record<string, string>>;
33
+ readonly playableByCardId: Readonly<Record<string, readonly InteractionDescriptor<Interaction>[]>>;
34
+ }
35
+ type ReadonlyProjection<Value> = Value extends readonly (infer Item)[] ? readonly ReadonlyProjection<Item>[] : Value extends object ? {
36
+ readonly [Key in keyof Value]: ReadonlyProjection<Value[Key]>;
37
+ } : Value;
38
+ type SimultaneousPhaseSnapshot = ReadonlyProjection<SimultaneousPhaseProjection>;
39
+
40
+ interface PluginGameplayFrame<View = unknown, Phase extends string = string, Interaction extends string = string> {
41
+ /** Latest committed public display-event batch. Reading a snapshot does not replay notifications. */
42
+ readonly events: readonly GameEvent[];
43
+ readonly basis: GameplayBasis;
44
+ readonly view: View | null;
45
+ readonly flow: {
46
+ readonly currentPhase: Phase | null;
47
+ readonly activePlayers: readonly PlayerId[];
48
+ readonly simultaneousPhase: SimultaneousPhaseSnapshot | null;
49
+ };
50
+ readonly availableInteractions: ReadonlyArray<InteractionDescriptor<Interaction>>;
51
+ readonly zones: Readonly<Record<string, ZoneHandlesSnapshot<Interaction>>>;
52
+ }
53
+ type ReducerSeatProjectionBundle = ReadonlyProjection<SeatProjectionBundle>;
54
+ type ReducerBoardStaticProjection = Readonly<BoardStaticProjection>;
55
+
56
+ interface SourceSnapshot {
57
+ readonly me: string;
58
+ readonly players: readonly PluginPlayerSummary[];
59
+ readonly frame: Omit<PluginGameplayFrame, "basis">;
60
+ readonly version: number;
61
+ }
62
+ type SubmitResult = {
63
+ readonly accepted: true;
64
+ } | {
65
+ readonly accepted: false;
66
+ readonly errorCode: string;
67
+ readonly message?: string;
68
+ };
69
+ interface SourceRequest {
70
+ readonly interactionId: string;
71
+ readonly operation: "submit" | "cancel";
72
+ readonly phase: "awaiting-result" | "awaiting-frame";
73
+ }
74
+ type SourceState = {
75
+ readonly connection: "connecting";
76
+ readonly snapshot: null;
77
+ readonly request: null;
78
+ readonly failure: null;
79
+ } | {
80
+ readonly connection: "ready";
81
+ readonly snapshot: SourceSnapshot;
82
+ readonly request: SourceRequest | null;
83
+ readonly failure: null;
84
+ } | {
85
+ readonly connection: "recovering";
86
+ readonly snapshot: SourceSnapshot | null;
87
+ readonly request: SourceRequest | null;
88
+ readonly failure: null;
89
+ } | {
90
+ readonly connection: "failed";
91
+ readonly snapshot: SourceSnapshot | null;
92
+ readonly request: null;
93
+ /** Terminal diagnostic, retained locally. */
94
+ readonly failure: Readonly<Error>;
95
+ } | {
96
+ readonly connection: "closed";
97
+ readonly snapshot: SourceSnapshot | null;
98
+ readonly request: null;
99
+ readonly failure: null;
100
+ };
101
+ interface GameSource {
102
+ readonly store: Pick<Store<SourceState>, "get" | "subscribe">;
103
+ dispose(): void;
104
+ }
105
+ interface CommandSource extends GameSource {
106
+ submit(interactionId: string, params: RuntimeJson): Promise<SubmitResult>;
107
+ cancel(interactionId: string): Promise<SubmitResult>;
108
+ }
109
+ /** Testing-owned sources can add local actions without widening hosted sources. */
110
+ interface ApplySource<Action, Result = void> extends GameSource {
111
+ apply(action: Action): Result;
112
+ }
113
+
114
+ export type { ActionInteractionDescriptor as A, CommandSource as C, GameSource as G, InteractionDescriptor as I, PlayerId as P, ReducerBoardStaticProjection as R, SimultaneousPhaseSnapshot as S, ZoneHandlesSnapshot as Z, ApplySource as a, GameplayBasis as b, PluginGameplayFrame as c, PluginPlayerSummary as d, PluginSessionDescriptor as e, ReducerSeatProjectionBundle as f, SourceRequest as g, SourceSnapshot as h, SourceState as i, SubmitResult as j };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@dreamboard-games/sdk",
3
- "version": "0.5.0-alpha.2",
4
- "description": "Dreamboard SDK package set metadata and public facade",
3
+ "version": "0.5.0-alpha.4",
4
+ "description": "Typed headless game instances, reducer authoring, React integration and testing",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
7
7
  "types": "./dist/index.d.ts",
@@ -11,162 +11,54 @@
11
11
  "import": "./dist/index.js",
12
12
  "default": "./dist/index.js"
13
13
  },
14
- "./package-set": {
15
- "types": "./dist/package-set.d.ts",
16
- "import": "./dist/package-set.js",
17
- "default": "./dist/package-set.js"
18
- },
19
- "./plugin-runtime-contract": {
20
- "types": "./dist/plugin-runtime-contract.d.ts",
21
- "import": "./dist/plugin-runtime-contract.js",
22
- "default": "./dist/plugin-runtime-contract.js"
23
- },
24
- "./reference-games": {
25
- "types": "./dist/reference-games/index.d.ts",
26
- "import": "./dist/reference-games/index.js",
27
- "default": "./dist/reference-games/index.js"
28
- },
29
- "./types": {
30
- "types": "./dist/types.d.ts",
31
- "import": "./dist/types.js",
32
- "default": "./dist/types.js"
33
- },
34
14
  "./reducer": {
35
15
  "types": "./dist/reducer.d.ts",
36
16
  "import": "./dist/reducer.js",
37
17
  "default": "./dist/reducer.js"
38
18
  },
39
- "./reducer/advanced": {
40
- "types": "./dist/reducer/advanced.d.ts",
41
- "import": "./dist/reducer/advanced.js",
42
- "default": "./dist/reducer/advanced.js"
43
- },
44
- "./ui": {
45
- "types": "./dist/ui.d.ts",
46
- "import": "./dist/ui.js",
47
- "default": "./dist/ui.js"
48
- },
49
- "./ui/components": {
50
- "types": "./dist/ui/components.d.ts",
51
- "import": "./dist/ui/components.js",
52
- "default": "./dist/ui/components.js"
53
- },
54
- "./ui/defaults": {
55
- "types": "./dist/ui/defaults.d.ts",
56
- "import": "./dist/ui/defaults.js",
57
- "default": "./dist/ui/defaults.js"
58
- },
59
- "./ui/player-state": {
60
- "types": "./dist/ui/player-state.d.ts",
61
- "import": "./dist/ui/player-state.js",
62
- "default": "./dist/ui/player-state.js"
63
- },
64
- "./ui/plugin-styles.css": {
65
- "default": "./dist/ui/plugin-styles.css"
66
- },
67
- "./runtime": {
68
- "types": "./dist/runtime.d.ts",
69
- "import": "./dist/runtime.js",
70
- "default": "./dist/runtime.js"
71
- },
72
- "./runtime/primitives": {
73
- "types": "./dist/runtime/primitives.d.ts",
74
- "import": "./dist/runtime/primitives.js",
75
- "default": "./dist/runtime/primitives.js"
76
- },
77
- "./runtime/workspace-contract": {
78
- "types": "./dist/runtime/workspace-contract.d.ts",
79
- "import": "./dist/runtime/workspace-contract.js",
80
- "default": "./dist/runtime/workspace-contract.js"
81
- },
82
- "./runtime/runtime-api": {
83
- "types": "./dist/runtime/runtime-api.d.ts",
84
- "import": "./dist/runtime/runtime-api.js",
85
- "default": "./dist/runtime/runtime-api.js"
86
- },
87
- "./reducer-contract": {
88
- "types": "./dist/reducer-contract.d.ts",
89
- "import": "./dist/reducer-contract.js",
90
- "default": "./dist/reducer-contract.js"
91
- },
92
19
  "./testing": {
93
20
  "types": "./dist/testing.d.ts",
94
21
  "import": "./dist/testing.js",
95
22
  "default": "./dist/testing.js"
96
23
  },
97
- "./testing-runtime": {
98
- "types": "./dist/testing-runtime.d.ts",
99
- "import": "./dist/testing-runtime.js",
100
- "default": "./dist/testing-runtime.js"
101
- },
102
- "./testing-compiler": {
103
- "types": "./dist/testing-compiler.d.ts",
104
- "import": "./dist/testing-compiler.js",
105
- "default": "./dist/testing-compiler.js"
106
- },
107
- "./browser-interaction": {
108
- "types": "./dist/browser-interaction.d.ts",
109
- "import": "./dist/browser-interaction.js",
110
- "default": "./dist/browser-interaction.js"
111
- },
112
- "./package.json": "./package.json"
24
+ "./package.json": "./package.json",
25
+ "./react": {
26
+ "types": "./dist/react.d.ts",
27
+ "import": "./dist/react.js",
28
+ "default": "./dist/react.js"
29
+ }
113
30
  },
114
31
  "files": [
115
32
  "LICENSE.md",
116
33
  "dist",
117
34
  "README.md",
118
- "!.turbo/**",
119
35
  "!tsconfig.tsbuildinfo"
120
36
  ],
121
37
  "dependencies": {
122
- "@radix-ui/react-accordion": "^1.2.14",
123
- "@radix-ui/react-dialog": "^1.1.17",
124
- "@radix-ui/react-label": "^2.1.10",
125
- "@radix-ui/react-select": "^2.3.1",
126
- "@radix-ui/react-slot": "^1.3.0",
127
- "@radix-ui/react-tooltip": "^1.2.10",
128
- "@noble/hashes": "^2.2.0",
129
- "@use-gesture/react": "^10.3.1",
130
- "clsx": "^2.1.1",
131
- "esbuild": "^0.28.1",
132
- "lucide-react": "^1.20.0",
133
- "vaul": "^1.1.2",
134
- "zustand": "^5.0.14"
38
+ "@dnd-kit/collision": "0.5.0",
39
+ "@dnd-kit/dom": "0.5.0",
40
+ "@dnd-kit/react": "0.5.0",
41
+ "@noble/hashes": "2.4.0",
42
+ "@tanstack/store": "0.11.1",
43
+ "honeycomb-grid": "4.1.5"
135
44
  },
136
45
  "devDependencies": {
137
- "@happy-dom/global-registrator": "^20.9.0",
138
- "@playwright/test": "1.60.0",
139
- "@storybook/addon-a11y": "^10.4.6",
140
- "@storybook/addon-themes": "^10.4.6",
141
- "@storybook/react-vite": "^10.4.6",
142
- "@storybook/test-runner": "^0.24.4",
143
- "@tailwindcss/cli": "^4.3.1",
144
- "@tailwindcss/vite": "^4.3.1",
145
- "@types/node": "^24.5.2",
146
- "@types/react": "^19.0.0",
147
- "@types/react-dom": "^19.0.0",
148
- "axe-playwright": "2.2.2",
149
- "concurrently": "^9.1.0",
150
- "eslint": "^9.39.1",
151
- "framer-motion": "^12.40.0",
152
- "http-server": "^14.1.1",
153
- "playwright": "1.60.0",
154
- "react": "^19.2.0",
155
- "react-dom": "^19.2.0",
156
- "storybook": "^10.4.6",
157
- "tailwindcss": "^4.3.1",
158
- "tsup": "^8.5.0",
159
- "typescript": "^5.9.3",
160
- "vite": "8.0.16",
161
- "vitest": "4.1.10",
162
- "wait-on": "^8.0.1",
163
- "zod": "4.4.3",
164
- "@dreamboard-games/plugin-runtime-contract": "0.1.0",
165
- "@dreamboard-games/sdk-types": "0.2.0",
166
- "@dreamboard-games/reducer-contract": "0.5.0"
46
+ "@happy-dom/global-registrator": "20.14.5",
47
+ "@tanstack/react-store": "0.11.1",
48
+ "@types/node": "24.19.0",
49
+ "@types/react": "19.3.0",
50
+ "@types/react-dom": "19.3.0",
51
+ "esbuild": "0.28.2",
52
+ "eslint": "10.11.0",
53
+ "react": "19.3.0",
54
+ "react-dom": "19.3.0",
55
+ "tsup": "8.5.1",
56
+ "typescript": "6.0.3",
57
+ "vitest": "5.0.2",
58
+ "zod": "4.6.5"
167
59
  },
168
60
  "peerDependencies": {
169
- "framer-motion": "^11.0.0 || ^12.0.0",
61
+ "@tanstack/react-store": "0.11.1",
170
62
  "react": "^19.0.0",
171
63
  "react-dom": "^19.0.0",
172
64
  "zod": "^4.4.3"
@@ -189,15 +81,21 @@
189
81
  "package-set"
190
82
  ],
191
83
  "license": "SEE LICENSE IN LICENSE.md",
84
+ "peerDependenciesMeta": {
85
+ "react": {
86
+ "optional": true
87
+ },
88
+ "react-dom": {
89
+ "optional": true
90
+ },
91
+ "@tanstack/react-store": {
92
+ "optional": true
93
+ }
94
+ },
192
95
  "scripts": {
193
- "build": "tsup && node ../../scripts/package.ts copy-declarations && mkdir -p dist/ui && tailwindcss -i src/ui/plugin-styles.css -o dist/ui/plugin-styles.css --minify",
96
+ "build": "tsup",
194
97
  "typecheck": "tsc --noEmit && tsc -p tsconfig.testing-contract.json",
195
98
  "lint": "eslint 'src/**/*.{ts,tsx}'",
196
- "storybook": "storybook dev -p 6006 --host 127.0.0.1 --no-open",
197
- "storybook:build": "storybook build -o storybook-static",
198
- "storybook:test": "concurrently -k -s first -n storybook,test \"http-server storybook-static -p 6006 -s --silent\" \"wait-on tcp:6006 && test-storybook --url http://127.0.0.1:6006\"",
199
- "storybook:test:visual": "playwright test --config .storybook/visual-runner.config.ts",
200
- "storybook:test:visual:update": "playwright test --config .storybook/visual-runner.config.ts --update-snapshots",
201
99
  "test": "vitest run src"
202
100
  }
203
101
  }
@@ -1,79 +0,0 @@
1
- import * as react_jsx_runtime from 'react/jsx-runtime';
2
- import { ReactNode, CSSProperties } from 'react';
3
- import { ViewCard } from './types.js';
4
- import { P as InteractionVisualState, f as CardIntent } from './hex-board-view-aKkblDp6.js';
5
-
6
- /**
7
- * Pure layout math for the controlled `HandView`.
8
- *
9
- * The functions here are independent of React and DOM measurement so they can
10
- * be unit-tested directly. {@link computeFanLayout} matches the algorithm
11
- * documented in `docs/reference/ui-sdk-mobile-hand-and-card-interactions.md`,
12
- * and {@link chooseHandLayoutMode} translates a measured container width and a
13
- * caller policy into the actual presentation mode the hand should render.
14
- */
15
- type HandPresentationMode = "fan" | "compressed-fan" | "strip" | "tray";
16
-
17
- /**
18
- * Deterministic pointer recognizer for the controlled hand view.
19
- *
20
- * The engine is independent from React: it consumes pointer events and a
21
- * caller-supplied callbacks bag, and produces semantic gesture events. It
22
- * owns no DOM, emits no `CardIntent`, and does not track the drag-lifecycle
23
- * `phase` — that responsibility lives in `CardDragSurface`. The engine only
24
- * recognizes `tap`, `previewStart`/`previewEnd`, `liftStart`/`liftMove`/
25
- * `liftEnd`/`liftCancel`, and a `horizontalBrowse` informational signal.
26
- *
27
- * The thresholds match
28
- * `docs/reference/ui-sdk-mobile-hand-and-card-interactions.md`:
29
- *
30
- * | Threshold | Default |
31
- * | ------------------------- | ----------- |
32
- * | Press preview delay | `220ms` |
33
- * | Movement slop | `8px` |
34
- * | Axis bias | `1.25` |
35
- * | Drag lift distance | `28px` |
36
- *
37
- * Callers wire the engine's `handlePointerDown` / `handlePointerMove` /
38
- * `handlePointerUp` / `handlePointerCancel` to the matching DOM events on
39
- * each interactive card.
40
- */
41
- type HandInteractionPolicy = "direct-activate" | "drag-to-target";
42
-
43
- type HandLayoutKind = HandPresentationMode | "stack";
44
- interface HandLayoutPolicy {
45
- desktop?: HandLayoutKind;
46
- mobile?: HandLayoutKind;
47
- }
48
- interface HandViewProps<CardData extends ViewCard = ViewCard> {
49
- cards: readonly CardData[];
50
- /**
51
- * Layout policy. Pass a single layout kind to use the same layout in every
52
- * viewport, or pass `{ desktop, mobile }` for a measured-width decision.
53
- * Defaults to `{ desktop: "fan", mobile: "tray" }`.
54
- */
55
- layout?: HandLayoutKind | HandLayoutPolicy;
56
- /**
57
- * Mobile interaction policy. Defaults to `direct-activate`. Use
58
- * `drag-to-target` together with a surrounding `CardDragSurface` and one
59
- * or more `CardDropTargetView` children.
60
- */
61
- mobileInteraction?: HandInteractionPolicy;
62
- /** Returns the controlled visual state for a card. */
63
- stateForCard?: (card: CardData, index: number) => InteractionVisualState | undefined;
64
- /** Visual surface renderer. */
65
- renderCard: (card: CardData, state: InteractionVisualState, index: number) => ReactNode;
66
- /** Generic UI intent callback. */
67
- onCardIntent?: (intent: CardIntent<CardData["id"] & string>) => void;
68
- /** Card width hint for fan geometry. */
69
- cardSize?: "sm" | "md" | "lg";
70
- /** Slot for the empty state. Defaults to nothing rendered. */
71
- renderEmpty?: () => ReactNode;
72
- /** ARIA label for the hand region. */
73
- "aria-label"?: string;
74
- className?: string;
75
- style?: CSSProperties;
76
- }
77
- declare function HandView<CardData extends ViewCard = ViewCard>({ cards, layout, mobileInteraction, stateForCard, renderCard, onCardIntent, cardSize, renderEmpty, "aria-label": ariaLabel, className, style, }: HandViewProps<CardData>): react_jsx_runtime.JSX.Element;
78
-
79
- export { type HandInteractionPolicy as H, type HandLayoutKind as a, type HandLayoutPolicy as b, HandView as c, type HandViewProps as d };
@@ -1,98 +0,0 @@
1
- import * as react_jsx_runtime from 'react/jsx-runtime';
2
- import * as react from 'react';
3
- import { ReactNode, HTMLAttributes, ComponentType, ReactElement } from 'react';
4
- import { P as PrimitiveCommonProps } from './primitive-props-BNHDkgd7.js';
5
-
6
- type HandRole = "primary" | "auxiliary" | "task";
7
- interface MobileHandRegistration {
8
- id: string;
9
- zone: string;
10
- label: string;
11
- role: HandRole;
12
- order?: number;
13
- version: string;
14
- count: number;
15
- active: boolean;
16
- autoOpen: boolean;
17
- content: ReactNode;
18
- }
19
- declare function MobileHandTrayProvider({ children }: {
20
- children: ReactNode;
21
- }): react_jsx_runtime.JSX.Element;
22
- declare function useRegisterMobileHand(hand: MobileHandRegistration): void;
23
- declare function useOverlayInsets(): {
24
- bottom: number;
25
- };
26
- declare function useRegisterBottomOverlayInset(id: string, height: number): void;
27
-
28
- type ResourceId = string;
29
- interface ResourceDisplayConfig<Resource extends string = ResourceId> {
30
- type: Resource;
31
- label: string;
32
- icon: ReactNode | ComponentType<{
33
- className?: string;
34
- strokeWidth?: number;
35
- "aria-hidden"?: boolean | "true" | "false";
36
- }>;
37
- iconColor?: string;
38
- bgColor?: string;
39
- textColor?: string;
40
- }
41
- interface ResourceCounterItemState<Resource extends string = ResourceId> {
42
- type: Resource;
43
- label: string;
44
- icon: ResourceDisplayConfig<Resource>["icon"];
45
- iconColor?: string;
46
- bgColor?: string;
47
- textColor?: string;
48
- count: number;
49
- isZero: boolean;
50
- interactive: boolean;
51
- select: () => void;
52
- renderIcon: (props?: ResourceIconProps) => ReactNode;
53
- dataAttributes: {
54
- "data-resource-id": Resource;
55
- "data-resource-count": number;
56
- "data-resource-zero": boolean | undefined;
57
- "data-interactive": boolean | undefined;
58
- };
59
- }
60
- interface ResourceIconProps {
61
- className?: string;
62
- strokeWidth?: number;
63
- "aria-hidden"?: boolean | "true" | "false";
64
- }
65
- type ResourceCounterRootProps<Resource extends string = ResourceId> = Omit<PrimitiveCommonProps, "children"> & Omit<HTMLAttributes<HTMLElement>, "children"> & {
66
- resources: ReadonlyArray<ResourceDisplayConfig<Resource>>;
67
- counts: Partial<Record<Resource, number>>;
68
- zero?: "show" | "hide";
69
- onResourceClick?: (resourceType: Resource) => void;
70
- children: ReactNode;
71
- };
72
- type BoundResourceCounterRootProps<Resource extends string = ResourceId> = Omit<ResourceCounterRootProps<Resource>, "resources">;
73
- type ResourceCounterProps<Resource extends string = ResourceId> = ResourceCounterRootProps<Resource>;
74
- type ResourceCounterPartProps<Resource extends string = ResourceId> = Omit<PrimitiveCommonProps, "children"> & Omit<HTMLAttributes<HTMLElement>, "children"> & {
75
- children?: ReactNode | ((resource: ResourceCounterItemState<Resource>) => ReactNode);
76
- };
77
- declare function ResourceCounterRoot<Resource extends string = ResourceId>({ resources, counts, zero, onResourceClick, children, "aria-label": ariaLabel, ...props }: ResourceCounterRootProps<Resource>): ReactElement<unknown, string | react.JSXElementConstructor<any>>;
78
- declare function ResourceCounterItem<Resource extends string = ResourceId>({ children, onClick, "aria-label": ariaLabel, ...props }: ResourceCounterPartProps<Resource>): ReactElement<unknown, string | react.JSXElementConstructor<any>>;
79
- declare function ResourceCounterIcon<Resource extends string = ResourceId>({ className, strokeWidth, "aria-hidden": ariaHidden, }: ResourceIconProps): ReactNode;
80
- declare function ResourceCounterCount<Resource extends string = ResourceId>({ children, ...props }: ResourceCounterPartProps<Resource>): ReactElement<unknown, string | react.JSXElementConstructor<any>>;
81
- declare function ResourceCounterLabel<Resource extends string = ResourceId>({ children, ...props }: ResourceCounterPartProps<Resource>): ReactElement<unknown, string | react.JSXElementConstructor<any>>;
82
- interface ResourceCounterComponents<Resource extends string = ResourceId> {
83
- Root(props: BoundResourceCounterRootProps<Resource>): ReactElement;
84
- Item(props: ResourceCounterPartProps<Resource>): ReactElement;
85
- Icon(props: ResourceIconProps): ReactNode;
86
- Count(props: ResourceCounterPartProps<Resource>): ReactElement;
87
- Label(props: ResourceCounterPartProps<Resource>): ReactElement;
88
- }
89
- declare function createResourceCounter<Resource extends string>(resources: ReadonlyArray<ResourceDisplayConfig<Resource>>): ResourceCounterComponents<Resource>;
90
- declare const ResourceCounter: {
91
- Root: typeof ResourceCounterRoot;
92
- Item: typeof ResourceCounterItem;
93
- Icon: typeof ResourceCounterIcon;
94
- Count: typeof ResourceCounterCount;
95
- Label: typeof ResourceCounterLabel;
96
- };
97
-
98
- export { type BoundResourceCounterRootProps as B, type HandRole as H, type MobileHandRegistration as M, ResourceCounter as R, MobileHandTrayProvider as a, type ResourceCounterComponents as b, ResourceCounterCount as c, ResourceCounterIcon as d, ResourceCounterItem as e, type ResourceCounterItemState as f, ResourceCounterLabel as g, type ResourceCounterPartProps as h, type ResourceCounterProps as i, ResourceCounterRoot as j, type ResourceCounterRootProps as k, type ResourceDisplayConfig as l, type ResourceIconProps as m, createResourceCounter as n, useRegisterBottomOverlayInset as o, useRegisterMobileHand as p, useOverlayInsets as u };
@@ -1,99 +0,0 @@
1
- import * as react_jsx_runtime from 'react/jsx-runtime';
2
- import { CSSProperties, ReactNode } from 'react';
3
- import { ag as Theme, ai as ThemeOverride } from './hex-board-view-aKkblDp6.js';
4
-
5
- /**
6
- * The set of preset theme ids ships in `@dreamboard-games/sdk/ui`. Authors
7
- * may register additional ones by passing a fully-resolved {@link Theme}
8
- * instead of an id.
9
- */
10
- type ThemePresetId = "tabletop" | "arcade" | "studio";
11
- /**
12
- * Resolve a preset id (or a full theme) into a {@link Theme}.
13
- *
14
- * Used internally by {@link ThemeProvider}; exported so authors who
15
- * compose at the call site (e.g. for a side-by-side preview) can do
16
- * the same resolution without mounting a provider.
17
- */
18
- declare function resolveTheme(input: ThemePresetId | Theme | undefined): Theme;
19
- /** Look up a registered preset by id. Returns `undefined` if missing. */
20
- declare function getThemePreset(id: ThemePresetId): Theme | undefined;
21
- /**
22
- * Subset returned by {@link useTheme} — the resolved theme plus a
23
- * stable copy of its CSS-variable map so consumers can reuse it (for
24
- * example, to apply tokens to a portal that escapes the provider).
25
- */
26
- interface ThemeContextValue {
27
- /** Fully resolved theme. */
28
- readonly theme: Theme;
29
- /** CSS-var map consumable as `style` on a wrapper. */
30
- readonly cssVars: CSSProperties;
31
- }
32
- interface ThemeProviderProps {
33
- /**
34
- * Preset id, a full {@link Theme}, or omitted to use the `tabletop`
35
- * default.
36
- */
37
- theme?: ThemePresetId | Theme;
38
- /**
39
- * Deep-partial overrides merged onto the resolved base theme. Use
40
- * for one-off tweaks (e.g. swapping the player palette per game)
41
- * without writing a full theme.
42
- */
43
- override?: ThemeOverride;
44
- /**
45
- * Render mode for reduced-motion enforcement.
46
- *
47
- * - `auto` (default): respect the user's OS-level preference via
48
- * `prefers-reduced-motion: reduce`.
49
- * - `force`: force `motion.reducedMotion = "true"` regardless of the
50
- * OS preference (useful for screenshot CI).
51
- * - `ignore`: never override motion (use only when the embedding
52
- * shell already decides motion behaviour).
53
- */
54
- reducedMotion?: "auto" | "force" | "ignore";
55
- /**
56
- * Where to mount the wrapper. `block` (default) renders a `div` and
57
- * applies the CSS variables to it. `none` skips the wrapper entirely
58
- * — only useful when the parent is already a Dreamboard provider and
59
- * just needs to publish a different sub-tree (rare).
60
- */
61
- as?: "block" | "none";
62
- /** Extra style merged after the CSS-var map. */
63
- style?: CSSProperties;
64
- /** Extra className for the wrapper. */
65
- className?: string;
66
- children: ReactNode;
67
- }
68
- /**
69
- * Mounts a Dreamboard theme. The provider:
70
- *
71
- * 1. Resolves the preset (or accepts a full theme).
72
- * 2. Applies any deep-partial `override`.
73
- * 3. Optionally clamps `motion.reducedMotion` to `"true"` based on the
74
- * OS-level preference (or a forced override).
75
- * 4. Serialises the resolved theme into CSS variables on a wrapper
76
- * element so descendants can read tokens via `useTheme()` *or* via
77
- * `var(--db-...)` references in their own CSS / Tailwind.
78
- *
79
- * Defaults such as `<GameLayout>` mount this for you with the configured
80
- * theme; mount it manually only when you need a sub-tree to use a different
81
- * theme (e.g. a dark sheet over a light layout).
82
- */
83
- declare function ThemeProvider({ theme: themeInput, override, reducedMotion, as, style, className, children, }: ThemeProviderProps): react_jsx_runtime.JSX.Element;
84
- /**
85
- * Read the active {@link Theme} from a {@link ThemeProvider} ancestor.
86
- *
87
- * Falls back to the `tabletop` preset (with no overrides) when called
88
- * outside a provider — components remain renderable in isolated tests
89
- * and Storybook/Cosmos fixtures without a wrapping shell.
90
- */
91
- declare function useTheme(): Theme;
92
- /**
93
- * Read the {@link CSSProperties} that publish the active theme as CSS
94
- * variables. Useful when porting a theme into a portal or drawer that
95
- * is rendered outside the provider's DOM subtree.
96
- */
97
- declare function useThemeCssVars(): CSSProperties;
98
-
99
- export { type ThemeContextValue as T, type ThemePresetId as a, ThemeProvider as b, type ThemeProviderProps as c, useThemeCssVars as d, getThemePreset as g, resolveTheme as r, useTheme as u };