@dreamboard-games/cli 0.1.30-alpha.1 → 0.1.30-alpha.11

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 (156) hide show
  1. package/README.md +179 -22
  2. package/dist/agent-verifier/agent-workspace-verifier.mjs +31 -30
  3. package/dist/agent-verifier/agent-workspace-verifier.mjs.map +1 -0
  4. package/dist/agent-verifier/{chunk-4WD3YU2E.mjs → chunk-3IJBOLGT.mjs} +4 -12
  5. package/dist/agent-verifier/chunk-3IJBOLGT.mjs.map +1 -0
  6. package/dist/agent-verifier/{chunk-6A5HRJMQ.mjs → chunk-4GU3PCHV.mjs} +62 -99
  7. package/dist/agent-verifier/chunk-4GU3PCHV.mjs.map +1 -0
  8. package/dist/agent-verifier/{chunk-SYPLYRGB.mjs → chunk-6XRC5PWB.mjs} +119 -310
  9. package/dist/agent-verifier/chunk-6XRC5PWB.mjs.map +1 -0
  10. package/dist/agent-verifier/{chunk-BVVNBJM4.mjs → chunk-COB56ESI.mjs} +2 -1
  11. package/dist/agent-verifier/chunk-COB56ESI.mjs.map +1 -0
  12. package/dist/agent-verifier/{chunk-2GBBP27W.mjs → chunk-F2DIOJJZ.mjs} +1 -0
  13. package/dist/agent-verifier/chunk-F2DIOJJZ.mjs.map +1 -0
  14. package/dist/agent-verifier/{chunk-CFU5EWIC.mjs → chunk-G42BGGG2.mjs} +7 -6
  15. package/dist/agent-verifier/chunk-G42BGGG2.mjs.map +1 -0
  16. package/dist/agent-verifier/{chunk-XYDL7GY6.mjs → chunk-H6XDQJ3N.mjs} +1 -0
  17. package/dist/agent-verifier/{chunk-LM3OZLZG.mjs → chunk-IAYRNVUC.mjs} +1 -0
  18. package/dist/agent-verifier/chunk-IAYRNVUC.mjs.map +1 -0
  19. package/dist/agent-verifier/{chunk-2QMNAVV4.mjs → chunk-JZTH3EMV.mjs} +2 -1
  20. package/dist/agent-verifier/chunk-JZTH3EMV.mjs.map +1 -0
  21. package/dist/agent-verifier/chunk-KK47X7RV.mjs +14 -0
  22. package/dist/agent-verifier/chunk-KK47X7RV.mjs.map +1 -0
  23. package/dist/agent-verifier/{chunk-SHUMAVAP.mjs → chunk-M7UVBANQ.mjs} +8 -9
  24. package/dist/agent-verifier/chunk-M7UVBANQ.mjs.map +1 -0
  25. package/dist/agent-verifier/{chunk-2E5P5NWG.mjs → chunk-NAK77WXW.mjs} +58 -126
  26. package/dist/agent-verifier/chunk-NAK77WXW.mjs.map +1 -0
  27. package/dist/agent-verifier/{chunk-CEQ2VJWN.mjs → chunk-POBFNXD4.mjs} +2 -1
  28. package/dist/agent-verifier/chunk-POBFNXD4.mjs.map +1 -0
  29. package/dist/agent-verifier/{chunk-6UUJEYDV.mjs → chunk-QBAF7EYR.mjs} +1 -0
  30. package/dist/agent-verifier/chunk-QBAF7EYR.mjs.map +1 -0
  31. package/dist/agent-verifier/{chunk-7653FPGJ.mjs → chunk-RHI6S4SU.mjs} +3 -2
  32. package/dist/agent-verifier/chunk-RHI6S4SU.mjs.map +1 -0
  33. package/dist/agent-verifier/{chunk-MINCYHXN.mjs → chunk-TAEQKBJB.mjs} +1 -0
  34. package/dist/agent-verifier/chunk-TAEQKBJB.mjs.map +1 -0
  35. package/dist/agent-verifier/{chunk-7E65UQLY.mjs → chunk-TLYGTHXU.mjs} +3 -2
  36. package/dist/agent-verifier/chunk-TLYGTHXU.mjs.map +1 -0
  37. package/dist/agent-verifier/{chunk-JH22JNYD.mjs → chunk-UIJ2NDG6.mjs} +93 -24
  38. package/dist/agent-verifier/chunk-UIJ2NDG6.mjs.map +1 -0
  39. package/dist/agent-verifier/{chunk-EIQWDQWJ.mjs → chunk-UWJIZML3.mjs} +13 -14
  40. package/dist/agent-verifier/chunk-UWJIZML3.mjs.map +1 -0
  41. package/dist/agent-verifier/{chunk-CJEEA6NJ.mjs → chunk-VLOIZDR6.mjs} +15 -31
  42. package/dist/agent-verifier/chunk-VLOIZDR6.mjs.map +1 -0
  43. package/dist/agent-verifier/{chunk-HJFQDSTU.mjs → chunk-W2MDP5ZN.mjs} +6 -5
  44. package/dist/agent-verifier/chunk-W2MDP5ZN.mjs.map +1 -0
  45. package/dist/agent-verifier/{chunk-CEDUHGNH.mjs → chunk-XKCJBIRY.mjs} +2 -1
  46. package/dist/agent-verifier/chunk-XKCJBIRY.mjs.map +1 -0
  47. package/dist/agent-verifier/{chunk-VYJTHSYR.mjs → chunk-YDIOW2BO.mjs} +2 -1
  48. package/dist/agent-verifier/chunk-YDIOW2BO.mjs.map +1 -0
  49. package/dist/agent-verifier/{chunk-MRCUP5SW.mjs → chunk-YE7UAO3T.mjs} +1 -0
  50. package/dist/agent-verifier/chunk-YE7UAO3T.mjs.map +1 -0
  51. package/dist/agent-verifier/{chunk-EOQIV6PS.mjs → chunk-YR664DJX.mjs} +111 -116
  52. package/dist/agent-verifier/chunk-YR664DJX.mjs.map +1 -0
  53. package/dist/agent-verifier/{chunk-2SZHMP6F.mjs → chunk-Z6OZWUIZ.mjs} +6 -9
  54. package/dist/agent-verifier/chunk-Z6OZWUIZ.mjs.map +1 -0
  55. package/dist/agent-verifier/{chunk-RBDDIIPM.mjs → chunk-ZEELHSY3.mjs} +1 -0
  56. package/dist/agent-verifier/chunk-ZEELHSY3.mjs.map +1 -0
  57. package/dist/agent-verifier/{compile-5QSPIOUT.mjs → compile-WZ7X6I2A.mjs} +27 -27
  58. package/dist/agent-verifier/compile-WZ7X6I2A.mjs.map +1 -0
  59. package/dist/agent-verifier/{global-config-WX3ZZIVU.mjs → global-config-XHL7BCKN.mjs} +6 -5
  60. package/dist/agent-verifier/global-config-XHL7BCKN.mjs.map +1 -0
  61. package/dist/agent-verifier/{keychain-backend-TNOPQV3Z.mjs → keychain-backend-A3MRWLPF.mjs} +2 -1
  62. package/dist/agent-verifier/keychain-backend-A3MRWLPF.mjs.map +1 -0
  63. package/dist/agent-verifier/{local-files-MTPLP62S.mjs → local-files-ZW52HSVT.mjs} +10 -11
  64. package/dist/agent-verifier/local-files-ZW52HSVT.mjs.map +1 -0
  65. package/dist/agent-verifier/local-typecheck-3JXL2NMG.mjs +10 -0
  66. package/dist/agent-verifier/local-typecheck-3JXL2NMG.mjs.map +1 -0
  67. package/dist/agent-verifier/{materialize-workspace-FKALAE2T.mjs → materialize-workspace-BKZLLFI4.mjs} +20 -20
  68. package/dist/agent-verifier/materialize-workspace-BKZLLFI4.mjs.map +1 -0
  69. package/dist/agent-verifier/{project-state-7GR6BQTQ.mjs → project-state-XKUSCFSV.mjs} +3 -2
  70. package/dist/agent-verifier/project-state-XKUSCFSV.mjs.map +1 -0
  71. package/dist/agent-verifier/{prompt-3BAINGAQ.mjs → prompt-VKHMCQT6.mjs} +2 -1
  72. package/dist/agent-verifier/prompt-VKHMCQT6.mjs.map +1 -0
  73. package/dist/agent-verifier/{reducer-bundle-preflight-C73LEXI2.mjs → reducer-bundle-preflight-7NYZF5ZT.mjs} +6 -9
  74. package/dist/agent-verifier/reducer-bundle-preflight-7NYZF5ZT.mjs.map +1 -0
  75. package/dist/agent-verifier/reducer-contract-preflight-COD2CO22.mjs +11 -0
  76. package/dist/agent-verifier/reducer-contract-preflight-COD2CO22.mjs.map +1 -0
  77. package/dist/agent-verifier/{reducer-native-test-harness-GMWBUISX.mjs → reducer-native-test-harness-D4VWPIAC.mjs} +14 -17
  78. package/dist/agent-verifier/reducer-native-test-harness-D4VWPIAC.mjs.map +1 -0
  79. package/dist/agent-verifier/static-scaffold-JCRBDKEH.mjs +26 -0
  80. package/dist/agent-verifier/static-scaffold-JCRBDKEH.mjs.map +1 -0
  81. package/dist/agent-verifier/{sync-3DUQH32H.mjs → sync-ELLJEWMB.mjs} +41 -39
  82. package/dist/agent-verifier/sync-ELLJEWMB.mjs.map +1 -0
  83. package/dist/agent-verifier/{test-P4U5INTD.mjs → test-OSXBPLSP.mjs} +29 -31
  84. package/dist/agent-verifier/test-OSXBPLSP.mjs.map +1 -0
  85. package/dist/agent-verifier/workspace-codegen-WPZHMATU.mjs +10 -0
  86. package/dist/agent-verifier/workspace-codegen-WPZHMATU.mjs.map +1 -0
  87. package/dist/agent-verifier/{workspace-dependencies-HZ6VVS4G.mjs → workspace-dependencies-ULZZZPNX.mjs} +5 -4
  88. package/dist/agent-verifier/workspace-dependencies-ULZZZPNX.mjs.map +1 -0
  89. package/dist/{chunk-C6UAT6EH.js → chunk-GXM7RRZJ.js} +9 -11
  90. package/dist/chunk-GXM7RRZJ.js.map +1 -0
  91. package/dist/{chunk-RS7UXJZV.js → chunk-P5TITCD3.js} +790 -17875
  92. package/dist/chunk-P5TITCD3.js.map +1 -0
  93. package/dist/{global-config-AGFBDFYD.js → global-config-WPJRXVDO.js} +2 -2
  94. package/dist/global-config-WPJRXVDO.js.map +1 -0
  95. package/dist/index.js +455 -54
  96. package/dist/index.js.map +1 -1
  97. package/dist/internal.js +2 -3
  98. package/package.json +8 -7
  99. package/skills/dreamboard/references/building-your-first-game.md +510 -0
  100. package/skills/dreamboard/references/cli.md +104 -0
  101. package/skills/dreamboard/references/game-interface.md +548 -0
  102. package/skills/dreamboard/references/manifest-authoring.md +597 -0
  103. package/skills/dreamboard/references/quickstart.md +66 -0
  104. package/skills/dreamboard/references/reducer.md +864 -0
  105. package/skills/dreamboard/references/rule-authoring.md +147 -0
  106. package/skills/dreamboard/references/testing.md +249 -0
  107. package/skills/dreamboard/scripts/events-extract.mjs +218 -0
  108. package/dist/agent-verifier/chunk-54TAYXUD.mjs +0 -12
  109. package/dist/agent-verifier/chunk-HBNDKQT5.mjs +0 -8381
  110. package/dist/agent-verifier/chunk-LI3ZR3BI.mjs +0 -41
  111. package/dist/agent-verifier/chunk-U6OJN7XS.mjs +0 -8092
  112. package/dist/agent-verifier/local-typecheck-QFYYAZOK.mjs +0 -9
  113. package/dist/agent-verifier/reducer-contract-preflight-22X7DSZW.mjs +0 -10
  114. package/dist/agent-verifier/static-scaffold-AJMZZQWS.mjs +0 -28
  115. package/dist/agent-verifier/testing-5K2BJYF2.mjs +0 -674
  116. package/dist/agent-verifier/workspace-codegen-JDZJRSDV.mjs +0 -11
  117. package/dist/chunk-7FOO4AJI.js +0 -50
  118. package/dist/chunk-7FOO4AJI.js.map +0 -1
  119. package/dist/chunk-C6UAT6EH.js.map +0 -1
  120. package/dist/chunk-RS7UXJZV.js.map +0 -1
  121. package/dist/internal.d.ts +0 -311
  122. package/dist/runtime-packages/ui-host-runtime/src/actor-principal.ts +0 -71
  123. package/dist/runtime-packages/ui-host-runtime/src/browser-interaction.ts +0 -139
  124. package/dist/runtime-packages/ui-host-runtime/src/components/host-controls.tsx +0 -374
  125. package/dist/runtime-packages/ui-host-runtime/src/components/host-feedback-toaster.tsx +0 -266
  126. package/dist/runtime-packages/ui-host-runtime/src/components/host-feedback.tsx +0 -212
  127. package/dist/runtime-packages/ui-host-runtime/src/components/host-primitives.tsx +0 -271
  128. package/dist/runtime-packages/ui-host-runtime/src/components/host-session-metadata.tsx +0 -135
  129. package/dist/runtime-packages/ui-host-runtime/src/components/index.ts +0 -5
  130. package/dist/runtime-packages/ui-host-runtime/src/components/perf-overlay.tsx +0 -194
  131. package/dist/runtime-packages/ui-host-runtime/src/gameplay-authority-transport.ts +0 -626
  132. package/dist/runtime-packages/ui-host-runtime/src/host-controls.tsx +0 -1
  133. package/dist/runtime-packages/ui-host-runtime/src/host-feedback.tsx +0 -1
  134. package/dist/runtime-packages/ui-host-runtime/src/host-session-transport.ts +0 -294
  135. package/dist/runtime-packages/ui-host-runtime/src/index.ts +0 -3
  136. package/dist/runtime-packages/ui-host-runtime/src/logger.ts +0 -11
  137. package/dist/runtime-packages/ui-host-runtime/src/perf.ts +0 -324
  138. package/dist/runtime-packages/ui-host-runtime/src/plugin-bridge.ts +0 -195
  139. package/dist/runtime-packages/ui-host-runtime/src/plugin-health-check.ts +0 -138
  140. package/dist/runtime-packages/ui-host-runtime/src/plugin-messages.ts +0 -159
  141. package/dist/runtime-packages/ui-host-runtime/src/plugin-session-gateway.ts +0 -551
  142. package/dist/runtime-packages/ui-host-runtime/src/runtime/index.ts +0 -13
  143. package/dist/runtime-packages/ui-host-runtime/src/screenshot/projection-to-snapshot.ts +0 -122
  144. package/dist/runtime-packages/ui-host-runtime/src/screenshot/static-store-api.ts +0 -26
  145. package/dist/runtime-packages/ui-host-runtime/src/session-ingress-controller.ts +0 -583
  146. package/dist/runtime-packages/ui-host-runtime/src/session-ingress.ts +0 -219
  147. package/dist/runtime-packages/ui-host-runtime/src/session-live-runtime.ts +0 -117
  148. package/dist/runtime-packages/ui-host-runtime/src/session-model.ts +0 -431
  149. package/dist/runtime-packages/ui-host-runtime/src/session-projection.ts +0 -211
  150. package/dist/runtime-packages/ui-host-runtime/src/session-recovery.ts +0 -80
  151. package/dist/runtime-packages/ui-host-runtime/src/session-state-reducer.ts +0 -1034
  152. package/dist/runtime-packages/ui-host-runtime/src/sse-manager.ts +0 -416
  153. package/dist/runtime-packages/ui-host-runtime/src/unified-session-store.ts +0 -184
  154. package/dist/testing-KLSV6CPJ.js +0 -674
  155. package/dist/testing-KLSV6CPJ.js.map +0 -1
  156. /package/dist/{global-config-AGFBDFYD.js.map → agent-verifier/chunk-H6XDQJ3N.mjs.map} +0 -0
@@ -1,374 +0,0 @@
1
- import { useMemo, useRef, useState } from "react";
2
- import {
3
- Badge,
4
- Button,
5
- cn,
6
- DropdownMenu,
7
- DropdownMenuContent,
8
- DropdownMenuLabel,
9
- DropdownMenuRadioGroup,
10
- DropdownMenuRadioItem,
11
- DropdownMenuSeparator,
12
- DropdownMenuTrigger,
13
- Popover,
14
- PopoverContent,
15
- PopoverTrigger,
16
- ScrollArea,
17
- } from "./host-primitives.js";
18
- import {
19
- Check,
20
- ChevronDown,
21
- Clock3,
22
- History,
23
- RotateCcw,
24
- Sparkles,
25
- Users,
26
- } from "lucide-react";
27
- import type { HistoryState } from "../unified-session-store.js";
28
- import {
29
- createHostSwitchControlledPlayerActuatorAttributes,
30
- createHostSwitchControlledPlayerMenuTriggerAttributes,
31
- createHostSwitchControlledPlayerRootAttributes,
32
- } from "../browser-interaction.js";
33
-
34
- export interface HostControllablePlayer {
35
- playerId: string;
36
- displayName: string;
37
- }
38
-
39
- export interface HostPlayerSwitcherProps {
40
- controllablePlayers: HostControllablePlayer[];
41
- controllingPlayerId: string | null;
42
- onSwitchPlayer: (playerId: string) => void;
43
- className?: string;
44
- }
45
-
46
- export interface HostHistoryNavigatorProps {
47
- isHost: boolean;
48
- history: HistoryState | null;
49
- onRestoreHistory: (entryId: string) => Promise<void> | void;
50
- className?: string;
51
- }
52
-
53
- export interface HostSessionToolbarProps {
54
- children: React.ReactNode;
55
- className?: string;
56
- }
57
-
58
- function formatHistoryTimestamp(timestamp: string): string {
59
- try {
60
- return new Date(timestamp).toLocaleTimeString(undefined, {
61
- hour: "2-digit",
62
- minute: "2-digit",
63
- second: "2-digit",
64
- });
65
- } catch {
66
- return timestamp;
67
- }
68
- }
69
-
70
- export function HostSessionToolbar({
71
- children,
72
- className,
73
- }: HostSessionToolbarProps) {
74
- return (
75
- <div
76
- className={cn("flex flex-wrap items-center justify-end gap-2", className)}
77
- >
78
- {children}
79
- </div>
80
- );
81
- }
82
-
83
- export function HostPlayerSwitcher({
84
- controllablePlayers,
85
- controllingPlayerId,
86
- onSwitchPlayer,
87
- className,
88
- }: HostPlayerSwitcherProps) {
89
- const currentPlayer = useMemo(
90
- () =>
91
- controllablePlayers.find(
92
- (player) => player.playerId === controllingPlayerId,
93
- ) ?? controllablePlayers[0],
94
- [controllablePlayers, controllingPlayerId],
95
- );
96
- const switchRootAttributes = createHostSwitchControlledPlayerRootAttributes();
97
- const switchMenuTriggerAttributes =
98
- createHostSwitchControlledPlayerMenuTriggerAttributes();
99
-
100
- if (controllablePlayers.length <= 1) {
101
- return null;
102
- }
103
-
104
- // Designer's Notebook: the trigger button is the ONE punctuation moment
105
- // for this control (wobbly + hard shadow). The dropdown contents below are
106
- // intentionally calm — plain rows, no rotation, no per-row wobbly borders.
107
- return (
108
- <div {...switchRootAttributes}>
109
- <DropdownMenu>
110
- <DropdownMenuTrigger asChild>
111
- <Button
112
- variant="outline"
113
- className={cn(
114
- "group h-auto min-h-14 min-w-[220px] justify-between gap-3 border-[3px] border-border bg-white px-4 py-3 text-left text-foreground hard-shadow transition-all hover:bg-[#fff9c4] hover:translate-x-[2px] hover:translate-y-[2px] hover:shadow-[2px_2px_0px_0px_#2d2d2d] wobbly-border-md",
115
- className,
116
- )}
117
- {...switchMenuTriggerAttributes}
118
- >
119
- <span className="flex min-w-0 items-center gap-3">
120
- <span className="flex h-10 w-10 shrink-0 items-center justify-center border-2 border-border bg-[#e7eefc] text-[#2d5da1]">
121
- <Users className="h-4 w-4 text-[#2d5da1]" />
122
- </span>
123
- <span className="min-w-0">
124
- <span className="block text-[10px] font-bold uppercase tracking-[0.18em] text-muted-foreground">
125
- Seat Control
126
- </span>
127
- <span className="block truncate font-display text-lg leading-none text-foreground">
128
- {currentPlayer?.displayName ?? "Choose player"}
129
- </span>
130
- <span className="mt-1 block truncate text-xs text-muted-foreground">
131
- {currentPlayer?.playerId ?? "Switch the active seat"}
132
- </span>
133
- </span>
134
- </span>
135
- <span className="flex shrink-0 items-center gap-2">
136
- <Badge
137
- variant="secondary"
138
- className="border border-border/40 bg-[#efe7da] px-2.5 py-0.5 text-[10px] uppercase tracking-[0.14em] text-foreground shadow-none"
139
- >
140
- {controllablePlayers.length} seats
141
- </Badge>
142
- <ChevronDown className="h-4 w-4 text-muted-foreground transition-transform group-data-[state=open]:rotate-180" />
143
- </span>
144
- </Button>
145
- </DropdownMenuTrigger>
146
- <DropdownMenuContent
147
- align="end"
148
- className="z-[80] w-[22rem] border-2 border-border bg-[#fdfbf7] p-2 font-sans"
149
- >
150
- <DropdownMenuLabel className="px-2 pb-3 pt-1">
151
- <div className="flex items-start justify-between gap-3">
152
- <div>
153
- <p className="text-[10px] font-bold uppercase tracking-[0.18em] text-muted-foreground">
154
- Play As
155
- </p>
156
- <p className="mt-1 font-display text-xl leading-none text-foreground">
157
- Switch the active seat
158
- </p>
159
- </div>
160
- <Sparkles className="h-5 w-5 text-primary shrink-0" />
161
- </div>
162
- </DropdownMenuLabel>
163
- <DropdownMenuSeparator className="mx-1 border-b border-border/40 bg-transparent" />
164
- <DropdownMenuRadioGroup
165
- {...switchRootAttributes}
166
- value={controllingPlayerId ?? ""}
167
- onValueChange={(playerId) => {
168
- if (playerId !== controllingPlayerId) {
169
- onSwitchPlayer(playerId);
170
- }
171
- }}
172
- >
173
- {controllablePlayers.map((player, index) => (
174
- <DropdownMenuRadioItem
175
- key={player.playerId}
176
- value={player.playerId}
177
- {...createHostSwitchControlledPlayerActuatorAttributes({
178
- playerId: player.playerId,
179
- selected: player.playerId === controllingPlayerId,
180
- enabled: true,
181
- })}
182
- className="mb-1 rounded-none border-2 border-transparent bg-white px-3 py-3 transition-colors focus:border-border/40 focus:bg-[#fff9c4] focus:text-foreground focus:outline-none data-[state=checked]:border-border data-[state=checked]:bg-[#fff9c4] data-[state=checked]:text-foreground [&>span]:hidden"
183
- >
184
- <div className="flex min-w-0 items-center gap-3">
185
- <div className="flex h-9 w-9 shrink-0 items-center justify-center border-2 border-border bg-[#efe7da] text-sm font-bold text-foreground">
186
- {index + 1}
187
- </div>
188
- <div className="min-w-0 flex-1">
189
- <span className="block truncate font-display text-lg leading-none">
190
- {player.displayName}
191
- </span>
192
- <span className="mt-1 block truncate text-xs text-muted-foreground">
193
- {player.playerId}
194
- </span>
195
- </div>
196
- {player.playerId === controllingPlayerId ? (
197
- <Check className="ml-auto h-5 w-5 shrink-0 text-primary" />
198
- ) : null}
199
- </div>
200
- </DropdownMenuRadioItem>
201
- ))}
202
- </DropdownMenuRadioGroup>
203
- </DropdownMenuContent>
204
- </DropdownMenu>
205
- </div>
206
- );
207
- }
208
-
209
- export function HostHistoryNavigator({
210
- isHost,
211
- history,
212
- onRestoreHistory,
213
- className,
214
- }: HostHistoryNavigatorProps) {
215
- const triggerContainerRef = useRef<HTMLDivElement | null>(null);
216
- const [open, setOpen] = useState(false);
217
- const [confirmEntryId, setConfirmEntryId] = useState<string | null>(null);
218
- const [restoringEntryId, setRestoringEntryId] = useState<string | null>(null);
219
-
220
- const entries = useMemo(
221
- () => (history ? [...history.entries].reverse() : []),
222
- [history],
223
- );
224
-
225
- if (!isHost || !history || history.entries.length === 0) {
226
- return null;
227
- }
228
-
229
- const handleRestoreClick = async (entryId: string) => {
230
- if (confirmEntryId !== entryId) {
231
- setConfirmEntryId(entryId);
232
- return;
233
- }
234
-
235
- setRestoringEntryId(entryId);
236
- try {
237
- await onRestoreHistory(entryId);
238
- setOpen(false);
239
- setConfirmEntryId(null);
240
- } finally {
241
- setRestoringEntryId(null);
242
- }
243
- };
244
-
245
- const popoverContainer = (() => {
246
- const container = triggerContainerRef.current?.closest(
247
- "[data-slot='drawer-content']",
248
- );
249
- return container instanceof HTMLElement ? container : null;
250
- })();
251
-
252
- return (
253
- <div ref={triggerContainerRef}>
254
- <Popover
255
- open={open}
256
- onOpenChange={(nextOpen) => {
257
- setOpen(nextOpen);
258
- if (!nextOpen) {
259
- setConfirmEntryId(null);
260
- }
261
- }}
262
- >
263
- <PopoverTrigger asChild>
264
- {/* Calm secondary control — the player switcher is the loud one
265
- in this toolbar; history is its quiet sibling. */}
266
- <Button
267
- variant="outline"
268
- size="sm"
269
- className={cn(
270
- "h-10 gap-2 border-2 border-border bg-white text-foreground transition-colors hover:bg-[#e5e0d8]",
271
- className,
272
- )}
273
- >
274
- <History className="h-4 w-4 text-muted-foreground" />
275
- <span className="hidden sm:inline">History</span>
276
- <Badge
277
- variant="secondary"
278
- className="border border-border/40 bg-[#fff9c4] text-foreground"
279
- >
280
- {history.entries.length}
281
- </Badge>
282
- </Button>
283
- </PopoverTrigger>
284
- {/* Designer's Notebook: trigger above is the punctuation moment.
285
- Popover contents are calm — plain bordered rows, no per-row
286
- wobbly. Restore CTA only "presses" via translate, no inflation. */}
287
- <PopoverContent
288
- container={popoverContainer}
289
- side="right"
290
- align="start"
291
- sideOffset={12}
292
- collisionPadding={16}
293
- style={{ zIndex: 200 }}
294
- className="z-[200] w-[26rem] border-2 border-border bg-[#fdfbf7] p-0"
295
- >
296
- <div className="border-b-2 border-border bg-white px-4 py-3">
297
- <div className="flex items-center gap-2 font-display text-base">
298
- <History className="h-4 w-4" />
299
- Session History
300
- </div>
301
- <p className="mt-1 font-sans text-xs text-muted-foreground">
302
- Restore a previous game state. This affects the shared host
303
- session.
304
- </p>
305
- </div>
306
- <ScrollArea className="max-h-80">
307
- <div className="space-y-2 p-3">
308
- {entries.map((entry: HistoryState["entries"][number]) => {
309
- const isConfirming = confirmEntryId === entry.id;
310
- const isRestoring = restoringEntryId === entry.id;
311
-
312
- return (
313
- <div
314
- key={entry.id}
315
- className={cn(
316
- "border-2 border-border px-3 py-3 transition-colors",
317
- entry.isCurrent ? "bg-[#fff9c4]" : "bg-white",
318
- )}
319
- >
320
- <div className="flex items-start justify-between gap-3">
321
- <div className="min-w-0 space-y-1">
322
- <div className="flex items-center gap-2">
323
- <span className="truncate text-sm font-medium">
324
- {entry.description}
325
- </span>
326
- {entry.isCurrent && (
327
- <Badge
328
- variant="secondary"
329
- className="shrink-0 border border-border/40 bg-[#e5e0d8] text-foreground"
330
- >
331
- Current
332
- </Badge>
333
- )}
334
- </div>
335
- <div className="flex items-center gap-2 text-xs text-muted-foreground">
336
- <Clock3 className="h-3.5 w-3.5" />
337
- <span>{formatHistoryTimestamp(entry.timestamp)}</span>
338
- <span>v{entry.version}</span>
339
- </div>
340
- </div>
341
- {!entry.isCurrent && (
342
- <Button
343
- size="sm"
344
- variant={isConfirming ? "default" : "outline"}
345
- className="shrink-0"
346
- disabled={isRestoring}
347
- onClick={() => void handleRestoreClick(entry.id)}
348
- >
349
- {isRestoring ? (
350
- "Restoring..."
351
- ) : isConfirming ? (
352
- <>
353
- <Check className="mr-1 h-4 w-4" />
354
- Confirm
355
- </>
356
- ) : (
357
- <>
358
- <RotateCcw className="mr-1 h-4 w-4" />
359
- Restore
360
- </>
361
- )}
362
- </Button>
363
- )}
364
- </div>
365
- </div>
366
- );
367
- })}
368
- </div>
369
- </ScrollArea>
370
- </PopoverContent>
371
- </Popover>
372
- </div>
373
- );
374
- }
@@ -1,266 +0,0 @@
1
- import { useEffect } from "react";
2
- import { Toaster, toast } from "sonner";
3
- import { AlertTriangle, Bell, Clock3, X } from "lucide-react";
4
- import {
5
- intentForVariant,
6
- surfaceStyle,
7
- useTheme,
8
- type ButtonVariant,
9
- type Theme,
10
- } from "@dreamboard-games/sdk/ui";
11
- import type { HostFeedback } from "../unified-session-store.js";
12
-
13
- export interface HostFeedbackToasterProps {
14
- feedback?: HostFeedback[];
15
- onDismiss?: (feedbackId: string) => void;
16
- }
17
-
18
- interface FeedbackPresentation {
19
- title: string;
20
- description: string;
21
- duration: number;
22
- variant: Extract<ButtonVariant, "danger" | "warning" | "success" | "info">;
23
- icon: typeof AlertTriangle;
24
- }
25
-
26
- function describeFeedback(item: HostFeedback): FeedbackPresentation {
27
- switch (item.type) {
28
- case "YOUR_TURN": {
29
- const activePlayerCount = item.payload.activePlayers.length;
30
- return {
31
- title: "Your turn",
32
- description:
33
- activePlayerCount > 1
34
- ? "You can act with one of your controlled players."
35
- : "You can act now.",
36
- duration: 3500,
37
- variant: "success",
38
- icon: Bell,
39
- };
40
- }
41
- case "PROMPT_OPENED": {
42
- const { targetPlayer, title } = item.payload;
43
- return {
44
- title: "Response needed",
45
- description: targetPlayer
46
- ? `${title ?? "A prompt is waiting."} (${targetPlayer})`
47
- : (title ?? "A prompt is waiting."),
48
- duration: 5000,
49
- variant: "warning",
50
- icon: Clock3,
51
- };
52
- }
53
- case "ACTION_REJECTED": {
54
- const reason = item.payload.targetPlayer
55
- ? `${item.payload.reason} (${item.payload.targetPlayer})`
56
- : item.payload.reason;
57
- return {
58
- title: "Action rejected",
59
- description: reason,
60
- duration: 5000,
61
- variant: "danger",
62
- icon: AlertTriangle,
63
- };
64
- }
65
- }
66
-
67
- const exhaustive: never = item;
68
- throw new Error(
69
- `Unsupported host feedback item type: ${String((exhaustive as { type?: unknown }).type)}`,
70
- );
71
- }
72
-
73
- interface HostFeedbackToastBodyProps {
74
- presentation: FeedbackPresentation;
75
- theme: Theme;
76
- onDismiss: () => void;
77
- }
78
-
79
- /**
80
- * Inner toast body. Rendered through sonner's `toast.custom` so the
81
- * surface is fully owned by the active {@link Theme} — no implicit
82
- * `richColors` styling, no hardcoded `bg-*` Tailwind classes.
83
- */
84
- function HostFeedbackToastBody({
85
- presentation,
86
- theme,
87
- onDismiss,
88
- }: HostFeedbackToastBodyProps) {
89
- const intent = intentForVariant(theme, presentation.variant);
90
- const Icon = presentation.icon;
91
- return (
92
- <div
93
- role="status"
94
- aria-live="polite"
95
- style={{
96
- ...surfaceStyle(theme, { tone: "card", radius: "lg" }),
97
- background: intent.soft,
98
- color: intent.onSoft,
99
- border: `1px solid ${intent.border}`,
100
- boxShadow: theme.elevation.lifted,
101
- display: "flex",
102
- alignItems: "flex-start",
103
- gap: theme.space[3],
104
- padding: theme.space[3],
105
- // Match sonner's default 356px so the toast lines up with
106
- // sibling toasts that may live inside the same stack.
107
- minWidth: 320,
108
- maxWidth: 420,
109
- fontFamily: theme.typography.fontFamily.body,
110
- }}
111
- >
112
- <Icon
113
- size={20}
114
- strokeWidth={2.5}
115
- aria-hidden="true"
116
- style={{
117
- flexShrink: 0,
118
- marginTop: 2,
119
- color: intent.solid,
120
- }}
121
- />
122
- <div style={{ flex: 1, minWidth: 0 }}>
123
- <div
124
- style={{
125
- fontFamily: theme.typography.fontFamily.display,
126
- fontSize: theme.typography.fontSize.md,
127
- fontWeight: theme.typography.fontWeight.bold,
128
- lineHeight: theme.typography.lineHeight.tight,
129
- color: intent.onSoft,
130
- }}
131
- >
132
- {presentation.title}
133
- </div>
134
- <div
135
- style={{
136
- marginTop: theme.space[1],
137
- fontSize: theme.typography.fontSize.sm,
138
- fontWeight: theme.typography.fontWeight.medium,
139
- lineHeight: theme.typography.lineHeight.normal,
140
- color: intent.onSoft,
141
- opacity: 0.92,
142
- wordBreak: "break-word",
143
- }}
144
- >
145
- {presentation.description}
146
- </div>
147
- </div>
148
- <button
149
- type="button"
150
- aria-label="Dismiss notification"
151
- onClick={onDismiss}
152
- style={{
153
- flexShrink: 0,
154
- width: 28,
155
- height: 28,
156
- display: "inline-flex",
157
- alignItems: "center",
158
- justifyContent: "center",
159
- background: "transparent",
160
- border: "none",
161
- borderRadius: theme.radius.pill,
162
- color: intent.onSoft,
163
- cursor: "pointer",
164
- opacity: 0.7,
165
- transition: `opacity ${theme.motion.duration.fast} ${theme.motion.easing.out}`,
166
- }}
167
- onMouseEnter={(event) => {
168
- event.currentTarget.style.opacity = "1";
169
- }}
170
- onMouseLeave={(event) => {
171
- event.currentTarget.style.opacity = "0.7";
172
- }}
173
- >
174
- <X size={16} aria-hidden="true" />
175
- </button>
176
- </div>
177
- );
178
- }
179
-
180
- /**
181
- * Mounts a {@link Toaster} and dispatches host-feedback events as
182
- * themed sonner toasts.
183
- *
184
- * Implementation notes:
185
- *
186
- * - We use `toast.custom(jsx, { id })` with a stable `id` so sonner
187
- * deduplicates the same feedback id by itself. The previous
188
- * implementation tracked processed ids in a `useRef`, which reset
189
- * across remounts (StrictMode in dev, parent re-renders that swap
190
- * the toaster's key) and caused the "shows / disappears / shows
191
- * again" flicker. With sonner-owned dedup, remounts no longer
192
- * replay the queue.
193
- * - We render a fully themed body so the toast picks up the active
194
- * `useTheme()` palette, font stack, and elevation tokens. Sonner's
195
- * default `richColors` theme is intentionally not used because it
196
- * produces a parallel non-themeable colour scheme.
197
- * - Host feedback is the canonical home for `YOUR_TURN`,
198
- * `PROMPT_OPENED` and `ACTION_REJECTED`. The plugin-side
199
- * `<ToastProvider>` no longer mirrors these; consumers must pass
200
- * the explicit `feedback` array sourced from the unified session
201
- * store.
202
- */
203
- export function HostFeedbackToaster({
204
- feedback = [],
205
- onDismiss,
206
- }: HostFeedbackToasterProps) {
207
- const theme = useTheme();
208
-
209
- useEffect(() => {
210
- for (const item of feedback) {
211
- const presentation = describeFeedback(item);
212
- const dismiss = () => onDismiss?.(item.id);
213
-
214
- // `toast.custom(jsx, { id })` is idempotent — calling it again
215
- // with the same id updates the existing toast in place rather
216
- // than mounting a duplicate, which is exactly what we want for
217
- // host-feedback ids that may flow through several store
218
- // snapshots before being dismissed.
219
- toast.custom(
220
- (toastId) => (
221
- <HostFeedbackToastBody
222
- presentation={presentation}
223
- theme={theme}
224
- onDismiss={() => {
225
- toast.dismiss(toastId);
226
- dismiss();
227
- }}
228
- />
229
- ),
230
- {
231
- id: item.id,
232
- duration: presentation.duration,
233
- unstyled: true,
234
- onAutoClose: () => dismiss(),
235
- onDismiss: () => dismiss(),
236
- },
237
- );
238
- }
239
- }, [feedback, onDismiss, theme]);
240
-
241
- return (
242
- <Toaster
243
- position="top-center"
244
- // Disable `richColors` because we render fully themed bodies
245
- // via `toast.custom` and don't want sonner's default success /
246
- // error palette competing with the active theme.
247
- richColors={false}
248
- // Forward the OS-level theme hint so sonner's container
249
- // (backdrop, default text colour for any non-custom toasts)
250
- // matches the resolved Dreamboard theme mode.
251
- theme={theme.meta.mode === "dark" ? "dark" : "light"}
252
- toastOptions={{
253
- // We use unstyled toasts so the inner `HostFeedbackToastBody`
254
- // has full control. `unstyled: true` removes sonner's
255
- // built-in surface, padding and shadow.
256
- unstyled: true,
257
- // Make the offset match sonner's default but anchor to the
258
- // viewport with safe-area insets so the toast clears phone
259
- // notches.
260
- style: {
261
- marginTop: "env(safe-area-inset-top, 0px)",
262
- },
263
- }}
264
- />
265
- );
266
- }