@pretty-chitty/core 1.2.18 → 2.1.0

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 (378) hide show
  1. package/README.md +8 -0
  2. package/dist/components/ActionLogDisplay.d.ts.map +1 -1
  3. package/dist/components/ActionLogDisplay.js +1 -1
  4. package/dist/components/ActionLogDisplay.js.map +1 -1
  5. package/dist/components/BottomBarButton.d.ts +3 -1
  6. package/dist/components/BottomBarButton.d.ts.map +1 -1
  7. package/dist/components/BottomBarButton.js +3 -2
  8. package/dist/components/BottomBarButton.js.map +1 -1
  9. package/dist/components/ClientTrustMatchViewer.d.ts +14 -1
  10. package/dist/components/ClientTrustMatchViewer.d.ts.map +1 -1
  11. package/dist/components/ClientTrustMatchViewer.js +25 -2
  12. package/dist/components/ClientTrustMatchViewer.js.map +1 -1
  13. package/dist/components/ContextGalleryDisplay.d.ts.map +1 -1
  14. package/dist/components/ContextGalleryDisplay.js +1 -1
  15. package/dist/components/ContextGalleryDisplay.js.map +1 -1
  16. package/dist/components/DemoWrapper.d.ts +30 -2
  17. package/dist/components/DemoWrapper.d.ts.map +1 -1
  18. package/dist/components/DemoWrapper.js +79 -43
  19. package/dist/components/DemoWrapper.js.map +1 -1
  20. package/dist/components/FullScreenGalleryDisplay.d.ts.map +1 -1
  21. package/dist/components/FullScreenGalleryDisplay.js +2 -2
  22. package/dist/components/FullScreenGalleryDisplay.js.map +1 -1
  23. package/dist/components/Gallery/BuiltItem.d.ts +6 -2
  24. package/dist/components/Gallery/BuiltItem.d.ts.map +1 -1
  25. package/dist/components/Gallery/BuiltItem.js +31 -9
  26. package/dist/components/Gallery/BuiltItem.js.map +1 -1
  27. package/dist/components/Gallery/GalleryController.d.ts +18 -0
  28. package/dist/components/Gallery/GalleryController.d.ts.map +1 -1
  29. package/dist/components/Gallery/GalleryController.js +70 -1
  30. package/dist/components/Gallery/GalleryController.js.map +1 -1
  31. package/dist/components/Gallery/GalleryViewer.d.ts +6 -1
  32. package/dist/components/Gallery/GalleryViewer.d.ts.map +1 -1
  33. package/dist/components/Gallery/GalleryViewer.js +48 -10
  34. package/dist/components/Gallery/GalleryViewer.js.map +1 -1
  35. package/dist/components/Gallery/LayoutManager.d.ts +6 -0
  36. package/dist/components/Gallery/LayoutManager.d.ts.map +1 -1
  37. package/dist/components/Gallery/LayoutManager.js +23 -3
  38. package/dist/components/Gallery/LayoutManager.js.map +1 -1
  39. package/dist/components/Gallery/constants.d.ts +2 -0
  40. package/dist/components/Gallery/constants.d.ts.map +1 -1
  41. package/dist/components/Gallery/constants.js +2 -0
  42. package/dist/components/Gallery/constants.js.map +1 -1
  43. package/dist/components/Gallery/registry.d.ts +34 -0
  44. package/dist/components/Gallery/registry.d.ts.map +1 -0
  45. package/dist/components/Gallery/registry.js +17 -0
  46. package/dist/components/Gallery/registry.js.map +1 -0
  47. package/dist/components/GameDesigner.d.ts.map +1 -1
  48. package/dist/components/GameDesigner.js +42 -10
  49. package/dist/components/GameDesigner.js.map +1 -1
  50. package/dist/components/InlineGalleryDisplay.d.ts.map +1 -1
  51. package/dist/components/InlineGalleryDisplay.js +2 -2
  52. package/dist/components/InlineGalleryDisplay.js.map +1 -1
  53. package/dist/components/LiveButton.d.ts.map +1 -1
  54. package/dist/components/LiveButton.js +5 -2
  55. package/dist/components/LiveButton.js.map +1 -1
  56. package/dist/components/MatchViewer.d.ts +6 -1
  57. package/dist/components/MatchViewer.d.ts.map +1 -1
  58. package/dist/components/MatchViewer.js +9 -3
  59. package/dist/components/MatchViewer.js.map +1 -1
  60. package/dist/components/Panel/MultiPanel.d.ts.map +1 -1
  61. package/dist/components/Panel/MultiPanel.js +18 -0
  62. package/dist/components/Panel/MultiPanel.js.map +1 -1
  63. package/dist/components/Panel/PanelContents.d.ts.map +1 -1
  64. package/dist/components/Panel/PanelContents.js +92 -23
  65. package/dist/components/Panel/PanelContents.js.map +1 -1
  66. package/dist/components/Panel/PanelTabStack.d.ts.map +1 -1
  67. package/dist/components/Panel/PanelTabStack.js +1 -1
  68. package/dist/components/Panel/PanelTabStack.js.map +1 -1
  69. package/dist/components/PanelSpark.d.ts.map +1 -1
  70. package/dist/components/PanelSpark.js +3 -2
  71. package/dist/components/PanelSpark.js.map +1 -1
  72. package/dist/components/Playground.d.ts.map +1 -1
  73. package/dist/components/Playground.js +46 -14
  74. package/dist/components/Playground.js.map +1 -1
  75. package/dist/components/PromptControls.d.ts.map +1 -1
  76. package/dist/components/PromptControls.js +4 -2
  77. package/dist/components/PromptControls.js.map +1 -1
  78. package/dist/components/SparkLineChart.d.ts.map +1 -1
  79. package/dist/components/SparkLineChart.js +22 -26
  80. package/dist/components/SparkLineChart.js.map +1 -1
  81. package/dist/components/TimeControlBar.d.ts.map +1 -1
  82. package/dist/components/TimeControlBar.js +5 -3
  83. package/dist/components/TimeControlBar.js.map +1 -1
  84. package/dist/components/TokenizedMarkdown.d.ts +23 -0
  85. package/dist/components/TokenizedMarkdown.d.ts.map +1 -0
  86. package/dist/components/TokenizedMarkdown.js +144 -0
  87. package/dist/components/TokenizedMarkdown.js.map +1 -0
  88. package/dist/components/TokenizedMessage.d.ts +8 -6
  89. package/dist/components/TokenizedMessage.d.ts.map +1 -1
  90. package/dist/components/TokenizedMessage.js +21 -54
  91. package/dist/components/TokenizedMessage.js.map +1 -1
  92. package/dist/components/TopBarPlayers.d.ts.map +1 -1
  93. package/dist/components/TopBarPlayers.js +2 -2
  94. package/dist/components/TopBarPlayers.js.map +1 -1
  95. package/dist/components/Tutorial/BrowserNarration.d.ts +55 -0
  96. package/dist/components/Tutorial/BrowserNarration.d.ts.map +1 -0
  97. package/dist/components/Tutorial/BrowserNarration.js +240 -0
  98. package/dist/components/Tutorial/BrowserNarration.js.map +1 -0
  99. package/dist/components/Tutorial/TutorialBox.d.ts +26 -0
  100. package/dist/components/Tutorial/TutorialBox.d.ts.map +1 -0
  101. package/dist/components/Tutorial/TutorialBox.js +239 -0
  102. package/dist/components/Tutorial/TutorialBox.js.map +1 -0
  103. package/dist/components/Tutorial/TutorialDevPanel.d.ts +9 -0
  104. package/dist/components/Tutorial/TutorialDevPanel.d.ts.map +1 -0
  105. package/dist/components/Tutorial/TutorialDevPanel.js +92 -0
  106. package/dist/components/Tutorial/TutorialDevPanel.js.map +1 -0
  107. package/dist/components/Tutorial/TutorialOverlay.d.ts +7 -0
  108. package/dist/components/Tutorial/TutorialOverlay.d.ts.map +1 -0
  109. package/dist/components/Tutorial/TutorialOverlay.js +1132 -0
  110. package/dist/components/Tutorial/TutorialOverlay.js.map +1 -0
  111. package/dist/components/Tutorial/targetRects.d.ts +67 -0
  112. package/dist/components/Tutorial/targetRects.d.ts.map +1 -0
  113. package/dist/components/Tutorial/targetRects.js +241 -0
  114. package/dist/components/Tutorial/targetRects.js.map +1 -0
  115. package/dist/game/Chit.d.ts +7 -0
  116. package/dist/game/Chit.d.ts.map +1 -1
  117. package/dist/game/Chit.js +22 -7
  118. package/dist/game/Chit.js.map +1 -1
  119. package/dist/game/ClientTimeState.d.ts +14 -0
  120. package/dist/game/ClientTimeState.d.ts.map +1 -1
  121. package/dist/game/ClientTimeState.js +17 -0
  122. package/dist/game/ClientTimeState.js.map +1 -1
  123. package/dist/game/ConnectionTransport.d.ts +3 -0
  124. package/dist/game/ConnectionTransport.d.ts.map +1 -1
  125. package/dist/game/ConnectionTransport.js +13 -4
  126. package/dist/game/ConnectionTransport.js.map +1 -1
  127. package/dist/game/Game.d.ts +14 -1
  128. package/dist/game/Game.d.ts.map +1 -1
  129. package/dist/game/GameTheme.d.ts +3 -0
  130. package/dist/game/GameTheme.d.ts.map +1 -1
  131. package/dist/game/GameTheme.js +2 -0
  132. package/dist/game/GameTheme.js.map +1 -1
  133. package/dist/game/Match.d.ts +74 -2
  134. package/dist/game/Match.d.ts.map +1 -1
  135. package/dist/game/Match.js +155 -4
  136. package/dist/game/Match.js.map +1 -1
  137. package/dist/game/MatchStorage.d.ts +8 -1
  138. package/dist/game/MatchStorage.d.ts.map +1 -1
  139. package/dist/game/MatchStorage.js +11 -3
  140. package/dist/game/MatchStorage.js.map +1 -1
  141. package/dist/game/Pick.d.ts +16 -0
  142. package/dist/game/Pick.d.ts.map +1 -1
  143. package/dist/game/Pick.js +32 -1
  144. package/dist/game/Pick.js.map +1 -1
  145. package/dist/game/PlayerChit.d.ts +3 -0
  146. package/dist/game/PlayerChit.d.ts.map +1 -1
  147. package/dist/game/PlayerChit.js +3 -0
  148. package/dist/game/PlayerChit.js.map +1 -1
  149. package/dist/game/PlayerInfo.d.ts +8 -0
  150. package/dist/game/PlayerInfo.d.ts.map +1 -1
  151. package/dist/game/PlayerInfo.js +6 -3
  152. package/dist/game/PlayerInfo.js.map +1 -1
  153. package/dist/game/PlayerPromptStatusChit.d.ts +8 -0
  154. package/dist/game/PlayerPromptStatusChit.d.ts.map +1 -1
  155. package/dist/game/PlayerPromptStatusChit.js +8 -2
  156. package/dist/game/PlayerPromptStatusChit.js.map +1 -1
  157. package/dist/game/Prompt.d.ts +15 -0
  158. package/dist/game/Prompt.d.ts.map +1 -1
  159. package/dist/game/Prompt.js +16 -0
  160. package/dist/game/Prompt.js.map +1 -1
  161. package/dist/game/Turn.d.ts +20 -4
  162. package/dist/game/Turn.d.ts.map +1 -1
  163. package/dist/game/Turn.js +191 -67
  164. package/dist/game/Turn.js.map +1 -1
  165. package/dist/game/TurnState.d.ts +20 -1
  166. package/dist/game/TurnState.d.ts.map +1 -1
  167. package/dist/game/TurnState.js +22 -3
  168. package/dist/game/TurnState.js.map +1 -1
  169. package/dist/game/ai/AiClientPrompts.d.ts +177 -0
  170. package/dist/game/ai/AiClientPrompts.d.ts.map +1 -0
  171. package/dist/game/ai/AiClientPrompts.js +561 -0
  172. package/dist/game/ai/AiClientPrompts.js.map +1 -0
  173. package/dist/game/ai/AiLiveView.d.ts +2 -0
  174. package/dist/game/ai/AiLiveView.d.ts.map +1 -0
  175. package/dist/game/ai/AiLiveView.js +48 -0
  176. package/dist/game/ai/AiLiveView.js.map +1 -0
  177. package/dist/game/ai/AiPlayerView.d.ts +2 -0
  178. package/dist/game/ai/AiPlayerView.d.ts.map +1 -0
  179. package/dist/game/ai/AiPlayerView.js +91 -0
  180. package/dist/game/ai/AiPlayerView.js.map +1 -0
  181. package/dist/game/ai/connectAiPlayer.d.ts +43 -0
  182. package/dist/game/ai/connectAiPlayer.d.ts.map +1 -0
  183. package/dist/game/ai/connectAiPlayer.js +58 -0
  184. package/dist/game/ai/connectAiPlayer.js.map +1 -0
  185. package/dist/game/ai/defineAi.d.ts +119 -0
  186. package/dist/game/ai/defineAi.d.ts.map +1 -0
  187. package/dist/game/ai/defineAi.js +122 -0
  188. package/dist/game/ai/defineAi.js.map +1 -0
  189. package/dist/game/ai/simulateMatches.d.ts +62 -0
  190. package/dist/game/ai/simulateMatches.d.ts.map +1 -0
  191. package/dist/game/ai/simulateMatches.js +108 -0
  192. package/dist/game/ai/simulateMatches.js.map +1 -0
  193. package/dist/game/badAiTransport/BadAIClientPrompts.d.ts +3 -0
  194. package/dist/game/badAiTransport/BadAIClientPrompts.d.ts.map +1 -1
  195. package/dist/game/badAiTransport/BadAIClientPrompts.js +3 -0
  196. package/dist/game/badAiTransport/BadAIClientPrompts.js.map +1 -1
  197. package/dist/game/clientTransport/ClientPrompts.d.ts +20 -1
  198. package/dist/game/clientTransport/ClientPrompts.d.ts.map +1 -1
  199. package/dist/game/clientTransport/ClientPrompts.js +30 -1
  200. package/dist/game/clientTransport/ClientPrompts.js.map +1 -1
  201. package/dist/game/clientTransport/ClientTime.d.ts +13 -0
  202. package/dist/game/clientTransport/ClientTime.d.ts.map +1 -1
  203. package/dist/game/clientTransport/ClientTime.js +51 -11
  204. package/dist/game/clientTransport/ClientTime.js.map +1 -1
  205. package/dist/game/tutorial/TutorialController.d.ts +300 -0
  206. package/dist/game/tutorial/TutorialController.d.ts.map +1 -0
  207. package/dist/game/tutorial/TutorialController.js +1182 -0
  208. package/dist/game/tutorial/TutorialController.js.map +1 -0
  209. package/dist/game/tutorial/TutorialRuntime.d.ts +89 -0
  210. package/dist/game/tutorial/TutorialRuntime.d.ts.map +1 -0
  211. package/dist/game/tutorial/TutorialRuntime.js +261 -0
  212. package/dist/game/tutorial/TutorialRuntime.js.map +1 -0
  213. package/dist/game/tutorial/TutorialTheme.d.ts +28 -0
  214. package/dist/game/tutorial/TutorialTheme.d.ts.map +1 -0
  215. package/dist/game/tutorial/TutorialTheme.js +39 -0
  216. package/dist/game/tutorial/TutorialTheme.js.map +1 -0
  217. package/dist/game/tutorial/allowed.d.ts +2 -0
  218. package/dist/game/tutorial/allowed.d.ts.map +1 -0
  219. package/dist/game/tutorial/allowed.js +119 -0
  220. package/dist/game/tutorial/allowed.js.map +1 -0
  221. package/dist/game/tutorial/checks.d.ts +58 -0
  222. package/dist/game/tutorial/checks.d.ts.map +1 -0
  223. package/dist/game/tutorial/checks.js +144 -0
  224. package/dist/game/tutorial/checks.js.map +1 -0
  225. package/dist/game/tutorial/createDemoMatch.d.ts +47 -0
  226. package/dist/game/tutorial/createDemoMatch.d.ts.map +1 -0
  227. package/dist/game/tutorial/createDemoMatch.js +67 -0
  228. package/dist/game/tutorial/createDemoMatch.js.map +1 -0
  229. package/dist/game/tutorial/defineTutorial.d.ts +353 -0
  230. package/dist/game/tutorial/defineTutorial.d.ts.map +1 -0
  231. package/dist/game/tutorial/defineTutorial.js +86 -0
  232. package/dist/game/tutorial/defineTutorial.js.map +1 -0
  233. package/dist/game/tutorial/runTutorial.d.ts +63 -0
  234. package/dist/game/tutorial/runTutorial.d.ts.map +1 -0
  235. package/dist/game/tutorial/runTutorial.js +273 -0
  236. package/dist/game/tutorial/runTutorial.js.map +1 -0
  237. package/dist/hooks/usePanelNavigation.d.ts +28 -0
  238. package/dist/hooks/usePanelNavigation.d.ts.map +1 -0
  239. package/dist/hooks/usePanelNavigation.js +36 -0
  240. package/dist/hooks/usePanelNavigation.js.map +1 -0
  241. package/dist/hooks/useTimeController.d.ts +2 -1
  242. package/dist/hooks/useTimeController.d.ts.map +1 -1
  243. package/dist/hooks/useTimeController.js +6 -2
  244. package/dist/hooks/useTimeController.js.map +1 -1
  245. package/dist/hooks/useTokenMap.d.ts +2 -4
  246. package/dist/hooks/useTokenMap.d.ts.map +1 -1
  247. package/dist/hooks/useTokenMap.js +2 -5
  248. package/dist/hooks/useTokenMap.js.map +1 -1
  249. package/dist/hooks/useTutorial.d.ts +48 -0
  250. package/dist/hooks/useTutorial.d.ts.map +1 -0
  251. package/dist/hooks/useTutorial.js +16 -0
  252. package/dist/hooks/useTutorial.js.map +1 -0
  253. package/dist/index.d.ts +57 -1
  254. package/dist/index.d.ts.map +1 -1
  255. package/dist/index.html +12 -0
  256. package/dist/index.js +27 -3
  257. package/dist/index.js.map +1 -1
  258. package/dist/main.0792d734cde2c688d5f7.hot-update.js +16991 -0
  259. package/dist/main.0792d734cde2c688d5f7.hot-update.js.map +1 -0
  260. package/dist/main.0792d734cde2c688d5f7.hot-update.json +1 -0
  261. package/dist/pretty-chitty.js +204513 -0
  262. package/dist/pretty-chitty.js.map +1 -0
  263. package/dist/rendering/CameraWrapperPerspective.d.ts +5 -0
  264. package/dist/rendering/CameraWrapperPerspective.d.ts.map +1 -1
  265. package/dist/rendering/CameraWrapperPerspective.js +16 -0
  266. package/dist/rendering/CameraWrapperPerspective.js.map +1 -1
  267. package/dist/rendering/ChitGalleryItemInstance.d.ts +1 -0
  268. package/dist/rendering/ChitGalleryItemInstance.d.ts.map +1 -1
  269. package/dist/rendering/ChitGalleryItemInstance.js +12 -0
  270. package/dist/rendering/ChitGalleryItemInstance.js.map +1 -1
  271. package/dist/rendering/ChitRenderInstance.d.ts +9 -1
  272. package/dist/rendering/ChitRenderInstance.d.ts.map +1 -1
  273. package/dist/rendering/ChitRenderInstance.js +28 -0
  274. package/dist/rendering/ChitRenderInstance.js.map +1 -1
  275. package/dist/rendering/RootChitRenderInstance.d.ts +2 -0
  276. package/dist/rendering/RootChitRenderInstance.d.ts.map +1 -1
  277. package/dist/rendering/RootChitRenderInstance.js +29 -0
  278. package/dist/rendering/RootChitRenderInstance.js.map +1 -1
  279. package/dist/utilities/Annotations.d.ts +15 -0
  280. package/dist/utilities/Annotations.d.ts.map +1 -1
  281. package/dist/utilities/Annotations.js +31 -7
  282. package/dist/utilities/Annotations.js.map +1 -1
  283. package/dist/utilities/CanvasStack/CanvasStack.d.ts +13 -0
  284. package/dist/utilities/CanvasStack/CanvasStack.d.ts.map +1 -1
  285. package/dist/utilities/CanvasStack/CanvasStack.js +66 -15
  286. package/dist/utilities/CanvasStack/CanvasStack.js.map +1 -1
  287. package/dist/utilities/TokenizedText.d.ts +55 -0
  288. package/dist/utilities/TokenizedText.d.ts.map +1 -0
  289. package/dist/utilities/TokenizedText.js +47 -0
  290. package/dist/utilities/TokenizedText.js.map +1 -0
  291. package/dist/utilities/zIndex.d.ts +1 -0
  292. package/dist/utilities/zIndex.d.ts.map +1 -1
  293. package/dist/utilities/zIndex.js +1 -0
  294. package/dist/utilities/zIndex.js.map +1 -1
  295. package/package.json +3 -2
  296. package/src/library/components/ActionLogDisplay.tsx +1 -0
  297. package/src/library/components/BottomBarButton.tsx +5 -0
  298. package/src/library/components/ClientTrustMatchViewer.tsx +32 -2
  299. package/src/library/components/ContextGalleryDisplay.tsx +2 -0
  300. package/src/library/components/DemoWrapper.tsx +147 -52
  301. package/src/library/components/FullScreenGalleryDisplay.tsx +3 -0
  302. package/src/library/components/Gallery/BuiltItem.ts +34 -9
  303. package/src/library/components/Gallery/GalleryController.ts +75 -2
  304. package/src/library/components/Gallery/GalleryViewer.tsx +54 -10
  305. package/src/library/components/Gallery/LayoutManager.ts +30 -6
  306. package/src/library/components/Gallery/constants.ts +2 -0
  307. package/src/library/components/Gallery/registry.ts +44 -0
  308. package/src/library/components/GameDesigner.tsx +121 -12
  309. package/src/library/components/InlineGalleryDisplay.tsx +5 -0
  310. package/src/library/components/LiveButton.tsx +8 -5
  311. package/src/library/components/MatchViewer.tsx +14 -3
  312. package/src/library/components/Panel/MultiPanel.tsx +21 -0
  313. package/src/library/components/Panel/PanelContents.tsx +70 -1
  314. package/src/library/components/Panel/PanelTabStack.tsx +1 -0
  315. package/src/library/components/PanelSpark.tsx +9 -4
  316. package/src/library/components/Playground.tsx +125 -33
  317. package/src/library/components/PromptControls.tsx +7 -3
  318. package/src/library/components/SparkLineChart.tsx +23 -27
  319. package/src/library/components/TimeControlBar.tsx +5 -3
  320. package/src/library/components/TokenizedMarkdown.tsx +224 -0
  321. package/src/library/components/TokenizedMessage.tsx +30 -95
  322. package/src/library/components/TopBarPlayers.tsx +18 -10
  323. package/src/library/components/Tutorial/BrowserNarration.ts +233 -0
  324. package/src/library/components/Tutorial/TutorialBox.tsx +506 -0
  325. package/src/library/components/Tutorial/TutorialDevPanel.tsx +297 -0
  326. package/src/library/components/Tutorial/TutorialOverlay.tsx +1301 -0
  327. package/src/library/components/Tutorial/targetRects.ts +273 -0
  328. package/src/library/game/Chit.ts +23 -7
  329. package/src/library/game/ClientTimeState.ts +18 -0
  330. package/src/library/game/ConnectionTransport.ts +12 -3
  331. package/src/library/game/Game.ts +16 -1
  332. package/src/library/game/GameTheme.ts +4 -0
  333. package/src/library/game/Match.ts +174 -5
  334. package/src/library/game/MatchStorage.ts +14 -4
  335. package/src/library/game/Pick.ts +36 -1
  336. package/src/library/game/PlayerChit.ts +4 -1
  337. package/src/library/game/PlayerInfo.ts +13 -3
  338. package/src/library/game/PlayerPromptStatusChit.ts +8 -2
  339. package/src/library/game/Prompt.ts +20 -0
  340. package/src/library/game/Turn.ts +198 -68
  341. package/src/library/game/TurnState.ts +34 -3
  342. package/src/library/game/ai/AI_GUIDE.md +444 -0
  343. package/src/library/game/ai/AiClientPrompts.ts +730 -0
  344. package/src/library/game/ai/AiLiveView.ts +63 -0
  345. package/src/library/game/ai/AiPlayerView.ts +114 -0
  346. package/src/library/game/ai/ai.test.ts +475 -0
  347. package/src/library/game/ai/connectAiPlayer.ts +88 -0
  348. package/src/library/game/ai/defineAi.ts +230 -0
  349. package/src/library/game/ai/simulateMatches.ts +172 -0
  350. package/src/library/game/badAiTransport/BadAIClientPrompts.ts +3 -0
  351. package/src/library/game/clientTransport/ClientPrompts.ts +31 -1
  352. package/src/library/game/clientTransport/ClientTime.ts +54 -13
  353. package/src/library/game/serialize.test.ts +275 -0
  354. package/src/library/game/tutorial/TUTORIAL_GUIDE.md +411 -0
  355. package/src/library/game/tutorial/TutorialController.test.ts +731 -0
  356. package/src/library/game/tutorial/TutorialController.ts +1286 -0
  357. package/src/library/game/tutorial/TutorialRuntime.ts +311 -0
  358. package/src/library/game/tutorial/TutorialTheme.ts +67 -0
  359. package/src/library/game/tutorial/allowed.ts +145 -0
  360. package/src/library/game/tutorial/checks.ts +186 -0
  361. package/src/library/game/tutorial/createDemoMatch.ts +115 -0
  362. package/src/library/game/tutorial/defineTutorial.ts +414 -0
  363. package/src/library/game/tutorial/runTutorial.ts +331 -0
  364. package/src/library/game/undo.test.ts +282 -0
  365. package/src/library/hooks/usePanelNavigation.tsx +65 -0
  366. package/src/library/hooks/useTimeController.tsx +6 -2
  367. package/src/library/hooks/useTokenMap.ts +2 -6
  368. package/src/library/hooks/useTutorial.tsx +76 -0
  369. package/src/library/index.ts +91 -4
  370. package/src/library/rendering/CameraWrapperPerspective.ts +17 -0
  371. package/src/library/rendering/ChitGalleryItemInstance.ts +12 -0
  372. package/src/library/rendering/ChitRenderInstance.ts +34 -0
  373. package/src/library/rendering/RootChitRenderInstance.ts +30 -1
  374. package/src/library/utilities/Annotations.ts +35 -7
  375. package/src/library/utilities/CanvasStack/CanvasStack.ts +74 -29
  376. package/src/library/utilities/TokenizedText.test.ts +32 -0
  377. package/src/library/utilities/TokenizedText.ts +103 -0
  378. package/src/library/utilities/zIndex.ts +1 -0
@@ -1,5 +1,6 @@
1
1
  import { GameTheme } from "../../game/GameTheme";
2
2
  import { SummaryMode } from "./types";
3
+ import { MIN_ITEM_HEIGHT_FRACTION, SINGLE_ITEM_SUMMARY_MAX_WIDTH } from "./constants";
3
4
 
4
5
  export class LayoutManager {
5
6
  // Dimensions (all scaled)
@@ -24,6 +25,8 @@ export class LayoutManager {
24
25
  // summary info
25
26
  private summaryMode: SummaryMode = "full";
26
27
  private summaryMaxHeight = 0;
28
+ private summaryWidth = 100;
29
+ private summaryHeightLimit = 0;
27
30
 
28
31
  public dirty = false;
29
32
 
@@ -69,6 +72,10 @@ export class LayoutManager {
69
72
  return { w: this.itemWidth, h: this.itemHeight, summaryMaxHeight: this.summaryMaxHeight };
70
73
  }
71
74
 
75
+ getSummaryDimensions() {
76
+ return { w: this.summaryWidth, maxHeight: this.summaryHeightLimit };
77
+ }
78
+
72
79
  getStageDimensions() {
73
80
  return { frontStageWidth: this.frontStageWidth, itemsPerPage: this.itemsPerPage, itemSpacing: this.itemSpacing };
74
81
  }
@@ -117,16 +124,14 @@ export class LayoutManager {
117
124
  }
118
125
 
119
126
  recalculateEffectiveItemDimensions() {
120
- // recalcs itemWidth,itemHeight,itemsPerPage and frontStageWidth
127
+ // recalcs itemWidth,itemHeight,itemsPerPage,frontStageWidth and the summary bounds
121
128
 
122
129
  let itemWidth = this.itemPreferredWidth ?? this.baseItemWidth;
123
130
  let itemHeight = this.itemPreferredHeight ?? this.baseItemHeight;
124
131
  const aspectRatio = itemWidth / itemHeight;
125
132
 
126
- const maxItemHeight = Math.max(
127
- this.theme.galleryItemMinimumHeight,
128
- this.h - this.itemSpacing * 2 - this.summaryMaxHeight,
129
- );
133
+ const availableHeight = this.h - this.itemSpacing * 2;
134
+ const maxItemHeight = Math.max(this.theme.galleryItemMinimumHeight, availableHeight);
130
135
  const maxItemWidth = Math.max(this.theme.galleryItemMinimumWidth, this.w - this.itemSpacing * 2);
131
136
 
132
137
  if (itemHeight > maxItemHeight) {
@@ -140,6 +145,21 @@ export class LayoutManager {
140
145
 
141
146
  itemWidth = Math.max(this.theme.galleryItemMinimumWidth, itemWidth);
142
147
 
148
+ // The summary takes its height from the item, and the item keeps its shape, so the slot (and the summary laid out
149
+ // at its width) stays as wide as the item actually draws. A narrower summary can wrap taller and shrink the item
150
+ // again, but only down to the height floor, so the layout settles instead of collapsing.
151
+ const itemHeightFloor = Math.max(
152
+ this.theme.galleryItemMinimumHeight,
153
+ Math.min(itemHeight, availableHeight * MIN_ITEM_HEIGHT_FRACTION),
154
+ );
155
+ const summaryHeightLimit = Math.max(0, availableHeight - itemHeightFloor);
156
+ itemHeight = Math.max(itemHeightFloor, Math.min(itemHeight, availableHeight - this.summaryMaxHeight));
157
+ itemWidth = Math.max(this.theme.galleryItemMinimumWidth, itemHeight * aspectRatio);
158
+
159
+ // A lone item has the stage to itself, so its summary can spread out instead of stacking into a tall column.
160
+ const summaryWidth =
161
+ this.itemCount === 1 ? Math.max(itemWidth, Math.min(maxItemWidth, SINGLE_ITEM_SUMMARY_MAX_WIDTH)) : itemWidth;
162
+
143
163
  const itemsPerPage = Math.max(
144
164
  1,
145
165
  Math.min(this.itemCount, Math.floor((this.w - this.itemSpacing * 2) / (itemWidth + this.itemSpacing))),
@@ -150,12 +170,16 @@ export class LayoutManager {
150
170
  this.itemHeight !== itemHeight ||
151
171
  this.itemWidth !== itemWidth ||
152
172
  this.itemsPerPage !== itemsPerPage ||
153
- this.frontStageWidth !== frontStageWidth
173
+ this.frontStageWidth !== frontStageWidth ||
174
+ this.summaryWidth !== summaryWidth ||
175
+ this.summaryHeightLimit !== summaryHeightLimit
154
176
  ) {
155
177
  this.itemHeight = itemHeight;
156
178
  this.itemWidth = itemWidth;
157
179
  this.itemsPerPage = itemsPerPage;
158
180
  this.frontStageWidth = frontStageWidth;
181
+ this.summaryWidth = summaryWidth;
182
+ this.summaryHeightLimit = summaryHeightLimit;
159
183
  this.dirty = true;
160
184
  }
161
185
  }
@@ -10,3 +10,5 @@ export const DEFAULT_ANGLE = Math.PI * 0.0;
10
10
  export const DEFAULT_ITEM_WIDTH = 200;
11
11
  export const DEFAULT_ITEM_SPACING = 50;
12
12
  export const DEFAULT_Z_FACTOR = 3;
13
+ export const MIN_ITEM_HEIGHT_FRACTION = 0.4;
14
+ export const SINGLE_ITEM_SUMMARY_MAX_WIDTH = 500;
@@ -0,0 +1,44 @@
1
+ import { Chit } from "../../game/Chit";
2
+
3
+ /** Which gallery: the strip above the log, the full-screen one, or the small one in the prompt bar */
4
+ export type GalleryKind = "inline" | "fullscreen" | "context";
5
+
6
+ /** A page-space rectangle (CSS px, like getBoundingClientRect) */
7
+ export type GalleryRect = { left: number; top: number; right: number; bottom: number };
8
+
9
+ /**
10
+ * An open gallery, as the tutorial overlay sees it: where a chit's item is on screen, and how to bring
11
+ * an item into view. Registered by `GalleryViewer` when given a `kind`.
12
+ */
13
+ export interface RegisteredGallery {
14
+ kind: GalleryKind;
15
+ /** The gallery's canvas, used to tell which viewer (and so which player) the gallery belongs to */
16
+ element: HTMLElement;
17
+ /**
18
+ * Where the item showing this chit is: a rect when it is on screen, "offscreen" when the gallery has
19
+ * the item but it is scrolled out of view, undefined when the gallery does not show it.
20
+ */
21
+ locate(chit: Chit): GalleryRect | "offscreen" | undefined;
22
+ /** Scrolls the gallery so the item showing this chit is in view */
23
+ scrollTo(chit: Chit): void;
24
+ /** Ids of the chits whose items the gallery shows */
25
+ chitIds(): string[];
26
+ }
27
+
28
+ const galleries = new Set<RegisteredGallery>();
29
+
30
+ export const galleryRegistry = {
31
+ register(gallery: RegisteredGallery) {
32
+ galleries.add(gallery);
33
+ return () => {
34
+ galleries.delete(gallery);
35
+ };
36
+ },
37
+ /** Open galleries inside `scope` (a viewer's root element), full-screen first, then inline, then context */
38
+ list(scope?: ParentNode | null): RegisteredGallery[] {
39
+ const order: GalleryKind[] = ["fullscreen", "inline", "context"];
40
+ return [...galleries]
41
+ .filter((g) => !scope || (scope as Node).contains(g.element))
42
+ .sort((a, b) => order.indexOf(a.kind) - order.indexOf(b.kind));
43
+ },
44
+ };
@@ -1,11 +1,117 @@
1
- import React from "react";
1
+ import React, { useState } from "react";
2
2
  import useLocalStorageState from "use-local-storage-state";
3
- import { AppBar, Tabs, Tab, CssBaseline, Stack } from "@mui/material";
3
+ import {
4
+ AppBar,
5
+ Tabs,
6
+ Tab,
7
+ CssBaseline,
8
+ Stack,
9
+ Box,
10
+ Paper,
11
+ Select,
12
+ MenuItem,
13
+ FormControl,
14
+ IconButton,
15
+ Tooltip,
16
+ ToggleButton,
17
+ } from "@mui/material";
18
+ import { OpenInNew, Refresh, Tune } from "@mui/icons-material";
4
19
  import CanvasLibraryViewer from "./CanvasLibraryViewer";
5
20
  import { Game } from "../game/Game";
6
21
  import ChitLibraryViewer from "./ChitLibraryViewer";
7
22
  import Playground from "./Playground";
8
23
  import { DemoWrapper } from "./DemoWrapper";
24
+ import { TutorialDevPanel } from "./Tutorial/TutorialDevPanel";
25
+
26
+ const NONE = "__none__";
27
+
28
+ /** The Demo tab: a demo game or any of the game's tutorials, with the tutorial workbench beside it. */
29
+ function DemoWorkbench({ game }: { game: Game<any, any> }) {
30
+ const tutorials = game.tutorials ?? [];
31
+ const [selected, setSelected] = useLocalStorageState<string>(`demo_${game.metadata.name}_tutorial`, {
32
+ defaultValue: tutorials[0] ? `${tutorials[0].id}|${tutorials[0].locale}` : NONE,
33
+ });
34
+ const [showDev, setShowDev] = useLocalStorageState<boolean>(`demo_${game.metadata.name}_devPanel`, {
35
+ defaultValue: true,
36
+ });
37
+ const [restartKey, setRestartKey] = useState(0);
38
+ const [startAt, setStartAt] = useState(0);
39
+
40
+ const [id, locale] = selected === NONE ? [undefined, undefined] : selected.split("|");
41
+ const spec = id ? tutorials.find((t) => t.id === id && t.locale === locale) : undefined;
42
+ const restart = (at = 0) => {
43
+ setStartAt(at);
44
+ setRestartKey((k) => k + 1);
45
+ };
46
+
47
+ const fullScreenUrl = spec ? `/demo?tutorial=${encodeURIComponent(spec.id)}&locale=${encodeURIComponent(spec.locale)}` : "/demo";
48
+
49
+ return (
50
+ <Stack sx={{ height: "100%", minHeight: 0 }}>
51
+ <Paper elevation={3} sx={{ position: "relative", zIndex: 1 }}>
52
+ <Stack direction="row" alignItems="center" spacing={1} sx={{ p: 1 }}>
53
+ <FormControl sx={{ minWidth: 240 }}>
54
+ <Select
55
+ variant="standard"
56
+ value={spec ? selected : NONE}
57
+ onChange={(e) => {
58
+ setSelected(e.target.value);
59
+ restart(0);
60
+ }}
61
+ >
62
+ <MenuItem value={NONE}>Demo (no tutorial)</MenuItem>
63
+ {tutorials.map((t) => (
64
+ <MenuItem key={`${t.id}|${t.locale}`} value={`${t.id}|${t.locale}`}>
65
+ {t.title} ({t.locale}) · {t.steps.length} steps
66
+ </MenuItem>
67
+ ))}
68
+ </Select>
69
+ </FormControl>
70
+ <Tooltip title="Restart">
71
+ <IconButton size="small" onClick={() => restart(0)}>
72
+ <Refresh />
73
+ </IconButton>
74
+ </Tooltip>
75
+ <Tooltip title="Open full screen">
76
+ <IconButton size="small" component="a" href={fullScreenUrl} target="_blank">
77
+ <OpenInNew />
78
+ </IconButton>
79
+ </Tooltip>
80
+ <Box flex={1} />
81
+ {spec && (
82
+ <Tooltip title="Tutorial workbench">
83
+ <ToggleButton size="small" value="dev" selected={showDev} onChange={() => setShowDev(!showDev)}>
84
+ <Tune fontSize="small" />
85
+ </ToggleButton>
86
+ </Tooltip>
87
+ )}
88
+ </Stack>
89
+ </Paper>
90
+ <Stack direction="row" sx={{ flex: 1, minHeight: 0 }}>
91
+ {/* The workbench sits beside the game, not over it: the tutorial's own layer (the dark start
92
+ screen, the box) stays inside the game and never covers the step list */}
93
+ <Box sx={{ flex: 1, minWidth: 0, position: "relative", display: "flex" }}>
94
+ <DemoWrapper key={`${selected}-${restartKey}`} game={game} tutorial={spec} startAt={startAt}>
95
+ {spec && showDev && (
96
+ <Box
97
+ sx={{
98
+ width: 360,
99
+ flexShrink: 0,
100
+ height: "100%",
101
+ bgcolor: "background.paper",
102
+ borderLeft: "1px solid rgba(0,0,0,0.12)",
103
+ overflow: "hidden",
104
+ }}
105
+ >
106
+ <TutorialDevPanel onRestart={restart} />
107
+ </Box>
108
+ )}
109
+ </DemoWrapper>
110
+ </Box>
111
+ </Stack>
112
+ </Stack>
113
+ );
114
+ }
9
115
 
10
116
  export function GameDesigner({ game }: { game: Game<any, any> }) {
11
117
  const [tabIndex, setTabIndex] = useLocalStorageState("selectedMainTab", {
@@ -15,9 +121,19 @@ export function GameDesigner({ game }: { game: Game<any, any> }) {
15
121
  const isDemo = window.location.pathname.endsWith("/demo");
16
122
 
17
123
  if (isDemo) {
124
+ const params = new URLSearchParams(window.location.search);
125
+ const tutorial = params.get("tutorial") ?? undefined;
126
+ const locale = params.get("locale") ?? undefined;
18
127
  return (
19
128
  <Stack sx={{ height: "100vh", maxHeight: "-webkit-fill-available", width: "100vw" }}>
20
- <DemoWrapper game={game} />
129
+ <DemoWrapper
130
+ game={game}
131
+ tutorial={tutorial}
132
+ locale={locale}
133
+ onBack={() => {
134
+ window.history.back();
135
+ }}
136
+ />
21
137
  </Stack>
22
138
  );
23
139
  }
@@ -29,13 +145,7 @@ export function GameDesigner({ game }: { game: Game<any, any> }) {
29
145
  <AppBar position="static">
30
146
  <Tabs
31
147
  value={tabIndex}
32
- onChange={(e, newValue) => {
33
- if (newValue === 3) {
34
- document.location.pathname = "/demo";
35
- } else {
36
- setTabIndex(newValue);
37
- }
38
- }}
148
+ onChange={(e, newValue) => setTabIndex(newValue)}
39
149
  indicatorColor="secondary"
40
150
  textColor="inherit"
41
151
  variant="fullWidth"
@@ -44,13 +154,12 @@ export function GameDesigner({ game }: { game: Game<any, any> }) {
44
154
  <Tab label="Chits" />
45
155
  <Tab label="Playground" />
46
156
  <Tab label="Demo" />
47
- {/* <Tab label="Gallery" /> */}
48
157
  </Tabs>
49
158
  </AppBar>
50
159
  {tabIndex === 0 && <CanvasLibraryViewer library={game.canvasLibrary} />}
51
160
  {tabIndex === 1 && <ChitLibraryViewer library={game.chitLibrary} />}
52
161
  {tabIndex === 2 && <Playground game={game} />}
53
- {/* {tabIndex === 3 && <GalleryPlayground game={game} />} */}
162
+ {tabIndex === 3 && <DemoWorkbench game={game} />}
54
163
  </Stack>
55
164
  );
56
165
  }
@@ -63,7 +63,9 @@ export function InlineGalleryDisplay() {
63
63
  >
64
64
  {
65
65
  <>
66
+ {inlineSource && (
66
67
  <IconButton
68
+ data-tutorial-target="gallery:toFullscreen"
67
69
  sx={{
68
70
  backgroundColor: theme.inlineGalleryButtonBackgroundColor,
69
71
  position: "absolute",
@@ -80,8 +82,11 @@ export function InlineGalleryDisplay() {
80
82
  >
81
83
  <ScreenshotMonitor sx={{ color: theme.inlineGalleryButtonForegroundColor }} />
82
84
  </IconButton>
85
+ )}
83
86
 
84
87
  <GalleryViewer
88
+ kind="inline"
89
+ tutorialTarget="gallery:inline"
85
90
  zFactor={0}
86
91
  onClose={() => {}}
87
92
  onLongPress={() => {
@@ -10,18 +10,21 @@ export default function LiveButton({ hideIfLive = true }: { hideIfLive?: boolean
10
10
  const [targetClock] = useEventChannelState(timeState.targetClock);
11
11
  const [maxClock] = useEventChannelState(timeController.maxClock);
12
12
  const [live] = useEventChannelState(timeState.live);
13
+ // A tutorial holding the board counts as the end: there is nothing to skip to past it
14
+ const [hold] = useEventChannelState(timeState.timelineHold);
15
+ const end = hold === undefined ? maxClock.clock : Math.min(hold, maxClock.clock);
13
16
 
14
- if (hideIfLive && targetClock >= maxClock.clock) {
17
+ if (hideIfLive && targetClock >= end) {
15
18
  return null;
16
19
  }
17
20
 
18
21
  return (
19
22
  <BottomBarButton
20
- disabled={targetClock >= maxClock.clock && live}
23
+ disabled={targetClock >= end && live}
21
24
  icon={SkipNext}
22
- label={live && targetClock < maxClock.clock ? "Skip" : "Live"}
23
- invisible={live && targetClock >= maxClock.clock}
24
- onClick={() => timeState.goLive(maxClock.clock)}
25
+ label={live && targetClock < end ? "Skip" : "Live"}
26
+ invisible={live && targetClock >= end}
27
+ onClick={() => timeState.goLive(end)}
25
28
  />
26
29
  );
27
30
  }
@@ -13,6 +13,7 @@ import { FullScreenGalleryDisplay } from "./FullScreenGalleryDisplay";
13
13
  import { ActionLogDisplay } from "./ActionLogDisplay";
14
14
  import { ActionLogHistoryDisplay } from "./ActionLogHistoryDisplay";
15
15
  import { PanelContents } from "./Panel/PanelContents";
16
+ import { PanelNavigationHolder } from "../hooks/usePanelNavigation";
16
17
  import useSize from "@react-hook/size";
17
18
  import { SettingsDisplay } from "./SettingsDisplay";
18
19
  import { ActionLogSidebar } from "./ActionLogSidebar";
@@ -20,6 +21,7 @@ import { InlineGalleryDisplay } from "./InlineGalleryDisplay";
20
21
  import { useLoadingState } from "../hooks/useLoadingStates";
21
22
  import { GameTheme } from "../game/GameTheme";
22
23
  import { ModalState } from "../game/ModalState";
24
+ import { TutorialOverlay } from "./Tutorial/TutorialOverlay";
23
25
 
24
26
  function createMuiTheme(gameTheme: GameTheme) {
25
27
  return createTheme({
@@ -104,22 +106,31 @@ function InnerMatchViewer({ onBack }: { onBack?: () => void }) {
104
106
  </Stack>
105
107
 
106
108
  {largeEnoughToShowLogSidebar && showLog && <ActionLogSidebar />}
109
+
110
+ <TutorialOverlay />
107
111
  </Stack>
108
112
  );
109
113
  }
110
114
 
111
- export function MatchViewer({ onBack }: { onBack?: () => void }) {
115
+ /**
116
+ * @param skipReplay Open live instead of replaying the moves since the player's last answer (a
117
+ * tutorial uses it after rebuilding the match for Back)
118
+ */
119
+ export function MatchViewer({ onBack, skipReplay = false }: { onBack?: () => void; skipReplay?: boolean }) {
112
120
  const game = useGame();
113
121
  const [modalState] = useState<ModalState>(new ModalState());
114
122
  const muiTheme = useMemo(() => createMuiTheme(game.theme), [game.theme]);
115
123
  return (
116
- <TimeControllerProvider>
124
+ <TimeControllerProvider skipReplay={skipReplay}>
117
125
  <PanelScaleProvider>
118
126
  <ModalProvider modalState={modalState}>
119
127
  <GameThemeProvider theme={game.theme}>
120
128
  <ThemeProvider theme={muiTheme}>
121
129
  <CssBaseline />
122
- <InnerMatchViewer onBack={onBack} />
130
+ {/* the tutorial overlay sits beside the panels and switches them through this */}
131
+ <PanelNavigationHolder>
132
+ <InnerMatchViewer onBack={onBack} />
133
+ </PanelNavigationHolder>
123
134
  </ThemeProvider>
124
135
  </GameThemeProvider>
125
136
  </ModalProvider>
@@ -16,6 +16,7 @@ import { PanelTabStack, TAB_HEIGHT } from "./PanelTabStack";
16
16
  import { usePanelPositioning } from "../../hooks/usePanelPositioning";
17
17
  import { useSmartDebouncedState } from "../../hooks/useSmartDebouncedState";
18
18
  import { ViewerZoomControls } from "./ViewerZoomControls";
19
+ import { usePanelNavigation } from "../../hooks/usePanelNavigation";
19
20
 
20
21
  const ANIMATION_DURATION = 0.125;
21
22
 
@@ -240,6 +241,26 @@ export function MultiPanel({
240
241
 
241
242
  const focusedRoot = focusedPanel?.renderInstance as RootChitRenderInstance;
242
243
 
244
+ // Let the tutorial overlay bring any of our panels to the front
245
+ const navigation = usePanelNavigation();
246
+ const selectRef = useRef(manuallyChangeSelectedIndex);
247
+ selectRef.current = manuallyChangeSelectedIndex;
248
+ useEffect(() => {
249
+ if (!navigation || !enabled) {
250
+ return;
251
+ }
252
+ const unregisters = chits.map((chit, index) =>
253
+ navigation.registerSelector(chit.id ?? "", () => {
254
+ selectRef.current(index);
255
+ // A tutorial asked for this panel: hold it against the automatic "show where something
256
+ // changed" switching for a while, prompt or not
257
+ setIgnoreChangesBefore(Date.now() + PANEL_ADJUST_IGNORE_DURATION);
258
+ }),
259
+ );
260
+ return () => unregisters.forEach((u) => u());
261
+ // eslint-disable-next-line react-hooks/exhaustive-deps
262
+ }, [navigation, chitIdsString, enabled]);
263
+
243
264
  return (
244
265
  <Stack
245
266
  sx={{
@@ -1,4 +1,4 @@
1
- import React, { useRef, useState, useEffect, useCallback, createContext, useContext } from "react";
1
+ import React, { useRef, useState, useEffect, useCallback, createContext, useContext, useMemo } from "react";
2
2
  import { Box } from "@mui/material";
3
3
  import useSize from "@react-hook/size";
4
4
  import { useGameTheme } from "../../hooks/useGameTheme";
@@ -11,6 +11,7 @@ import { Chit } from "../../game/Chit";
11
11
  import Hammer from "@egjs/hammerjs";
12
12
  import { PanelPositioningContext, ViewerPosition } from "../../hooks/usePanelPositioning";
13
13
  import { ViewerWrapper } from "./ViewerWrapper";
14
+ import { PanelNavigation, PanelNavigationContext, usePublishPanelNavigation } from "../../hooks/usePanelNavigation";
14
15
 
15
16
  // Types for gesture handling
16
17
  export interface ViewerGestureHandlers {
@@ -252,9 +253,76 @@ export function PanelContents({
252
253
  fullChitList.push(rootChit);
253
254
  }
254
255
 
256
+ // Panel navigation (used by the tutorial overlay to bring a chit's panel to the front)
257
+ const selectorsRef = useRef<Map<string, () => void>>(new Map());
258
+ const panelRootsRef = useRef<Chit[]>(tabChitList);
259
+ panelRootsRef.current = tabChitList;
260
+ const focusedPanelRef = useRef(focusedPanel);
261
+ focusedPanelRef.current = focusedPanel;
262
+ /** The panel root (a chit with its own viewer) that shows `chit` */
263
+ const panelOf = (chit: Chit): Chit | undefined => {
264
+ const roots = new Set(panelRootsRef.current.map((c) => c.id));
265
+ let panel: Chit | undefined = chit;
266
+ while (panel && !roots.has(panel.id)) {
267
+ panel = panel.parent;
268
+ }
269
+ return panel;
270
+ };
271
+ const navigation = useMemo<PanelNavigation>(
272
+ () => ({
273
+ registerSelector: (chitId, select) => {
274
+ selectorsRef.current.set(chitId, select);
275
+ return () => {
276
+ if (selectorsRef.current.get(chitId) === select) selectorsRef.current.delete(chitId);
277
+ };
278
+ },
279
+ panelRoots: () => panelRootsRef.current,
280
+ isFront: (chitId) => positionsRef.current.get(chitId)?.front ?? false,
281
+ revealChit: async (chit) => {
282
+ const panel = panelOf(chit);
283
+ if (!panel?.id) {
284
+ return false;
285
+ }
286
+ // Showing a panel full screen (the player zoomed in, or a tutorial focused it): that layout
287
+ // has every panel as a tab, so switch tabs there rather than leave it
288
+ const select = selectorsRef.current.get(panel.id);
289
+ if (select && !(positionsRef.current.get(panel.id)?.front ?? false)) {
290
+ select();
291
+ await new Promise((resolve) => setTimeout(resolve, 400));
292
+ }
293
+ return true;
294
+ },
295
+ keepFront: (chit) => {
296
+ // Selecting the tab already in front changes nothing but re-arms its hold against the
297
+ // automatic "show where something changed" switching
298
+ const panel = panelOf(chit);
299
+ if (panel?.id && (positionsRef.current.get(panel.id)?.front ?? false)) selectorsRef.current.get(panel.id)?.();
300
+ },
301
+ focusedPanel: () => focusedPanelRef.current,
302
+ focusPanelOf: async (chit) => {
303
+ const panel = chit ? panelOf(chit) : undefined;
304
+ if (chit && !panel?.id) return false;
305
+ if (focusedPanelRef.current === panel) return true;
306
+ if (!panel) {
307
+ setFocusedPanel(undefined);
308
+ } else if (focusedPanelRef.current) {
309
+ selectorsRef.current.get(panel.id!)?.(); // already full screen: switch to its tab
310
+ } else {
311
+ setFocusedPanel(panel);
312
+ }
313
+ await new Promise((resolve) => setTimeout(resolve, 400));
314
+ return true;
315
+ },
316
+ }),
317
+ [],
318
+ );
319
+ // The tutorial overlay is outside these panels: it reaches the navigation through the viewer
320
+ usePublishPanelNavigation(navigation);
321
+
255
322
  return (
256
323
  <GestureContext.Provider value={gestureContextValue}>
257
324
  <PanelPositioningContext.Provider value={positioningContextValue}>
325
+ <PanelNavigationContext.Provider value={navigation}>
258
326
  <Box
259
327
  sx={{
260
328
  position: "relative",
@@ -358,6 +426,7 @@ export function PanelContents({
358
426
  })}
359
427
  </Box>
360
428
  </Box>
429
+ </PanelNavigationContext.Provider>
361
430
  </PanelPositioningContext.Provider>
362
431
  </GestureContext.Provider>
363
432
  );
@@ -35,6 +35,7 @@ function PanelTab({ chit, onClick, selected }: { selected?: boolean; chit: Chit;
35
35
  return (
36
36
  <Box
37
37
  onMouseDown={onClick}
38
+ data-tutorial-target={`panelTab:${chit.id}`}
38
39
  sx={{ pt: 1, pb: 1, mt: -1, mb: -1, position: "relative", zIndex: ZINDEX_PANEL_CUTOUTS }}
39
40
  >
40
41
  <Box
@@ -42,10 +42,14 @@ export default function PanelSpark({ chit, paused, zIndex }: { zIndex: number; c
42
42
  const key = `spark${chit.id ?? "no id"}`;
43
43
  timeState.setAnimationState(key, true);
44
44
  setFlashed(true);
45
- setTimeout(() => {
46
- setFlashed(false);
47
- timeState.setAnimationState(key, false);
48
- }, DURATION);
45
+ // As fast as the board's other animations when they are hurried (going live, skipping ahead)
46
+ setTimeout(
47
+ () => {
48
+ setFlashed(false);
49
+ timeState.setAnimationState(key, false);
50
+ },
51
+ DURATION * (timeState.animationSpeedOverrideMultiplier.value ?? 1),
52
+ );
49
53
  }
50
54
  }
51
55
  }, [chit, timeState, paused, value, targetValue, DURATION]);
@@ -80,6 +84,7 @@ export default function PanelSpark({ chit, paused, zIndex }: { zIndex: number; c
80
84
  return (
81
85
  <Box
82
86
  ref={ref}
87
+ data-tutorial-target={`spark:${chit.id}`}
83
88
  sx={{
84
89
  position: "relative",
85
90
  background: flashed ? theme.sparkFlashColor : backgroundColor,