@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.
- package/README.md +8 -0
- package/dist/components/ActionLogDisplay.d.ts.map +1 -1
- package/dist/components/ActionLogDisplay.js +1 -1
- package/dist/components/ActionLogDisplay.js.map +1 -1
- package/dist/components/BottomBarButton.d.ts +3 -1
- package/dist/components/BottomBarButton.d.ts.map +1 -1
- package/dist/components/BottomBarButton.js +3 -2
- package/dist/components/BottomBarButton.js.map +1 -1
- package/dist/components/ClientTrustMatchViewer.d.ts +14 -1
- package/dist/components/ClientTrustMatchViewer.d.ts.map +1 -1
- package/dist/components/ClientTrustMatchViewer.js +25 -2
- package/dist/components/ClientTrustMatchViewer.js.map +1 -1
- package/dist/components/ContextGalleryDisplay.d.ts.map +1 -1
- package/dist/components/ContextGalleryDisplay.js +1 -1
- package/dist/components/ContextGalleryDisplay.js.map +1 -1
- package/dist/components/DemoWrapper.d.ts +30 -2
- package/dist/components/DemoWrapper.d.ts.map +1 -1
- package/dist/components/DemoWrapper.js +79 -43
- package/dist/components/DemoWrapper.js.map +1 -1
- package/dist/components/FullScreenGalleryDisplay.d.ts.map +1 -1
- package/dist/components/FullScreenGalleryDisplay.js +2 -2
- package/dist/components/FullScreenGalleryDisplay.js.map +1 -1
- package/dist/components/Gallery/BuiltItem.d.ts +6 -2
- package/dist/components/Gallery/BuiltItem.d.ts.map +1 -1
- package/dist/components/Gallery/BuiltItem.js +31 -9
- package/dist/components/Gallery/BuiltItem.js.map +1 -1
- package/dist/components/Gallery/GalleryController.d.ts +18 -0
- package/dist/components/Gallery/GalleryController.d.ts.map +1 -1
- package/dist/components/Gallery/GalleryController.js +70 -1
- package/dist/components/Gallery/GalleryController.js.map +1 -1
- package/dist/components/Gallery/GalleryViewer.d.ts +6 -1
- package/dist/components/Gallery/GalleryViewer.d.ts.map +1 -1
- package/dist/components/Gallery/GalleryViewer.js +48 -10
- package/dist/components/Gallery/GalleryViewer.js.map +1 -1
- package/dist/components/Gallery/LayoutManager.d.ts +6 -0
- package/dist/components/Gallery/LayoutManager.d.ts.map +1 -1
- package/dist/components/Gallery/LayoutManager.js +23 -3
- package/dist/components/Gallery/LayoutManager.js.map +1 -1
- package/dist/components/Gallery/constants.d.ts +2 -0
- package/dist/components/Gallery/constants.d.ts.map +1 -1
- package/dist/components/Gallery/constants.js +2 -0
- package/dist/components/Gallery/constants.js.map +1 -1
- package/dist/components/Gallery/registry.d.ts +34 -0
- package/dist/components/Gallery/registry.d.ts.map +1 -0
- package/dist/components/Gallery/registry.js +17 -0
- package/dist/components/Gallery/registry.js.map +1 -0
- package/dist/components/GameDesigner.d.ts.map +1 -1
- package/dist/components/GameDesigner.js +42 -10
- package/dist/components/GameDesigner.js.map +1 -1
- package/dist/components/InlineGalleryDisplay.d.ts.map +1 -1
- package/dist/components/InlineGalleryDisplay.js +2 -2
- package/dist/components/InlineGalleryDisplay.js.map +1 -1
- package/dist/components/LiveButton.d.ts.map +1 -1
- package/dist/components/LiveButton.js +5 -2
- package/dist/components/LiveButton.js.map +1 -1
- package/dist/components/MatchViewer.d.ts +6 -1
- package/dist/components/MatchViewer.d.ts.map +1 -1
- package/dist/components/MatchViewer.js +9 -3
- package/dist/components/MatchViewer.js.map +1 -1
- package/dist/components/Panel/MultiPanel.d.ts.map +1 -1
- package/dist/components/Panel/MultiPanel.js +18 -0
- package/dist/components/Panel/MultiPanel.js.map +1 -1
- package/dist/components/Panel/PanelContents.d.ts.map +1 -1
- package/dist/components/Panel/PanelContents.js +92 -23
- package/dist/components/Panel/PanelContents.js.map +1 -1
- package/dist/components/Panel/PanelTabStack.d.ts.map +1 -1
- package/dist/components/Panel/PanelTabStack.js +1 -1
- package/dist/components/Panel/PanelTabStack.js.map +1 -1
- package/dist/components/PanelSpark.d.ts.map +1 -1
- package/dist/components/PanelSpark.js +3 -2
- package/dist/components/PanelSpark.js.map +1 -1
- package/dist/components/Playground.d.ts.map +1 -1
- package/dist/components/Playground.js +46 -14
- package/dist/components/Playground.js.map +1 -1
- package/dist/components/PromptControls.d.ts.map +1 -1
- package/dist/components/PromptControls.js +4 -2
- package/dist/components/PromptControls.js.map +1 -1
- package/dist/components/SparkLineChart.d.ts.map +1 -1
- package/dist/components/SparkLineChart.js +22 -26
- package/dist/components/SparkLineChart.js.map +1 -1
- package/dist/components/TimeControlBar.d.ts.map +1 -1
- package/dist/components/TimeControlBar.js +5 -3
- package/dist/components/TimeControlBar.js.map +1 -1
- package/dist/components/TokenizedMarkdown.d.ts +23 -0
- package/dist/components/TokenizedMarkdown.d.ts.map +1 -0
- package/dist/components/TokenizedMarkdown.js +144 -0
- package/dist/components/TokenizedMarkdown.js.map +1 -0
- package/dist/components/TokenizedMessage.d.ts +8 -6
- package/dist/components/TokenizedMessage.d.ts.map +1 -1
- package/dist/components/TokenizedMessage.js +21 -54
- package/dist/components/TokenizedMessage.js.map +1 -1
- package/dist/components/TopBarPlayers.d.ts.map +1 -1
- package/dist/components/TopBarPlayers.js +2 -2
- package/dist/components/TopBarPlayers.js.map +1 -1
- package/dist/components/Tutorial/BrowserNarration.d.ts +55 -0
- package/dist/components/Tutorial/BrowserNarration.d.ts.map +1 -0
- package/dist/components/Tutorial/BrowserNarration.js +240 -0
- package/dist/components/Tutorial/BrowserNarration.js.map +1 -0
- package/dist/components/Tutorial/TutorialBox.d.ts +26 -0
- package/dist/components/Tutorial/TutorialBox.d.ts.map +1 -0
- package/dist/components/Tutorial/TutorialBox.js +239 -0
- package/dist/components/Tutorial/TutorialBox.js.map +1 -0
- package/dist/components/Tutorial/TutorialDevPanel.d.ts +9 -0
- package/dist/components/Tutorial/TutorialDevPanel.d.ts.map +1 -0
- package/dist/components/Tutorial/TutorialDevPanel.js +92 -0
- package/dist/components/Tutorial/TutorialDevPanel.js.map +1 -0
- package/dist/components/Tutorial/TutorialOverlay.d.ts +7 -0
- package/dist/components/Tutorial/TutorialOverlay.d.ts.map +1 -0
- package/dist/components/Tutorial/TutorialOverlay.js +1132 -0
- package/dist/components/Tutorial/TutorialOverlay.js.map +1 -0
- package/dist/components/Tutorial/targetRects.d.ts +67 -0
- package/dist/components/Tutorial/targetRects.d.ts.map +1 -0
- package/dist/components/Tutorial/targetRects.js +241 -0
- package/dist/components/Tutorial/targetRects.js.map +1 -0
- package/dist/game/Chit.d.ts +7 -0
- package/dist/game/Chit.d.ts.map +1 -1
- package/dist/game/Chit.js +22 -7
- package/dist/game/Chit.js.map +1 -1
- package/dist/game/ClientTimeState.d.ts +14 -0
- package/dist/game/ClientTimeState.d.ts.map +1 -1
- package/dist/game/ClientTimeState.js +17 -0
- package/dist/game/ClientTimeState.js.map +1 -1
- package/dist/game/ConnectionTransport.d.ts +3 -0
- package/dist/game/ConnectionTransport.d.ts.map +1 -1
- package/dist/game/ConnectionTransport.js +13 -4
- package/dist/game/ConnectionTransport.js.map +1 -1
- package/dist/game/Game.d.ts +14 -1
- package/dist/game/Game.d.ts.map +1 -1
- package/dist/game/GameTheme.d.ts +3 -0
- package/dist/game/GameTheme.d.ts.map +1 -1
- package/dist/game/GameTheme.js +2 -0
- package/dist/game/GameTheme.js.map +1 -1
- package/dist/game/Match.d.ts +74 -2
- package/dist/game/Match.d.ts.map +1 -1
- package/dist/game/Match.js +155 -4
- package/dist/game/Match.js.map +1 -1
- package/dist/game/MatchStorage.d.ts +8 -1
- package/dist/game/MatchStorage.d.ts.map +1 -1
- package/dist/game/MatchStorage.js +11 -3
- package/dist/game/MatchStorage.js.map +1 -1
- package/dist/game/Pick.d.ts +16 -0
- package/dist/game/Pick.d.ts.map +1 -1
- package/dist/game/Pick.js +32 -1
- package/dist/game/Pick.js.map +1 -1
- package/dist/game/PlayerChit.d.ts +3 -0
- package/dist/game/PlayerChit.d.ts.map +1 -1
- package/dist/game/PlayerChit.js +3 -0
- package/dist/game/PlayerChit.js.map +1 -1
- package/dist/game/PlayerInfo.d.ts +8 -0
- package/dist/game/PlayerInfo.d.ts.map +1 -1
- package/dist/game/PlayerInfo.js +6 -3
- package/dist/game/PlayerInfo.js.map +1 -1
- package/dist/game/PlayerPromptStatusChit.d.ts +8 -0
- package/dist/game/PlayerPromptStatusChit.d.ts.map +1 -1
- package/dist/game/PlayerPromptStatusChit.js +8 -2
- package/dist/game/PlayerPromptStatusChit.js.map +1 -1
- package/dist/game/Prompt.d.ts +15 -0
- package/dist/game/Prompt.d.ts.map +1 -1
- package/dist/game/Prompt.js +16 -0
- package/dist/game/Prompt.js.map +1 -1
- package/dist/game/Turn.d.ts +20 -4
- package/dist/game/Turn.d.ts.map +1 -1
- package/dist/game/Turn.js +191 -67
- package/dist/game/Turn.js.map +1 -1
- package/dist/game/TurnState.d.ts +20 -1
- package/dist/game/TurnState.d.ts.map +1 -1
- package/dist/game/TurnState.js +22 -3
- package/dist/game/TurnState.js.map +1 -1
- package/dist/game/ai/AiClientPrompts.d.ts +177 -0
- package/dist/game/ai/AiClientPrompts.d.ts.map +1 -0
- package/dist/game/ai/AiClientPrompts.js +561 -0
- package/dist/game/ai/AiClientPrompts.js.map +1 -0
- package/dist/game/ai/AiLiveView.d.ts +2 -0
- package/dist/game/ai/AiLiveView.d.ts.map +1 -0
- package/dist/game/ai/AiLiveView.js +48 -0
- package/dist/game/ai/AiLiveView.js.map +1 -0
- package/dist/game/ai/AiPlayerView.d.ts +2 -0
- package/dist/game/ai/AiPlayerView.d.ts.map +1 -0
- package/dist/game/ai/AiPlayerView.js +91 -0
- package/dist/game/ai/AiPlayerView.js.map +1 -0
- package/dist/game/ai/connectAiPlayer.d.ts +43 -0
- package/dist/game/ai/connectAiPlayer.d.ts.map +1 -0
- package/dist/game/ai/connectAiPlayer.js +58 -0
- package/dist/game/ai/connectAiPlayer.js.map +1 -0
- package/dist/game/ai/defineAi.d.ts +119 -0
- package/dist/game/ai/defineAi.d.ts.map +1 -0
- package/dist/game/ai/defineAi.js +122 -0
- package/dist/game/ai/defineAi.js.map +1 -0
- package/dist/game/ai/simulateMatches.d.ts +62 -0
- package/dist/game/ai/simulateMatches.d.ts.map +1 -0
- package/dist/game/ai/simulateMatches.js +108 -0
- package/dist/game/ai/simulateMatches.js.map +1 -0
- package/dist/game/badAiTransport/BadAIClientPrompts.d.ts +3 -0
- package/dist/game/badAiTransport/BadAIClientPrompts.d.ts.map +1 -1
- package/dist/game/badAiTransport/BadAIClientPrompts.js +3 -0
- package/dist/game/badAiTransport/BadAIClientPrompts.js.map +1 -1
- package/dist/game/clientTransport/ClientPrompts.d.ts +20 -1
- package/dist/game/clientTransport/ClientPrompts.d.ts.map +1 -1
- package/dist/game/clientTransport/ClientPrompts.js +30 -1
- package/dist/game/clientTransport/ClientPrompts.js.map +1 -1
- package/dist/game/clientTransport/ClientTime.d.ts +13 -0
- package/dist/game/clientTransport/ClientTime.d.ts.map +1 -1
- package/dist/game/clientTransport/ClientTime.js +51 -11
- package/dist/game/clientTransport/ClientTime.js.map +1 -1
- package/dist/game/tutorial/TutorialController.d.ts +300 -0
- package/dist/game/tutorial/TutorialController.d.ts.map +1 -0
- package/dist/game/tutorial/TutorialController.js +1182 -0
- package/dist/game/tutorial/TutorialController.js.map +1 -0
- package/dist/game/tutorial/TutorialRuntime.d.ts +89 -0
- package/dist/game/tutorial/TutorialRuntime.d.ts.map +1 -0
- package/dist/game/tutorial/TutorialRuntime.js +261 -0
- package/dist/game/tutorial/TutorialRuntime.js.map +1 -0
- package/dist/game/tutorial/TutorialTheme.d.ts +28 -0
- package/dist/game/tutorial/TutorialTheme.d.ts.map +1 -0
- package/dist/game/tutorial/TutorialTheme.js +39 -0
- package/dist/game/tutorial/TutorialTheme.js.map +1 -0
- package/dist/game/tutorial/allowed.d.ts +2 -0
- package/dist/game/tutorial/allowed.d.ts.map +1 -0
- package/dist/game/tutorial/allowed.js +119 -0
- package/dist/game/tutorial/allowed.js.map +1 -0
- package/dist/game/tutorial/checks.d.ts +58 -0
- package/dist/game/tutorial/checks.d.ts.map +1 -0
- package/dist/game/tutorial/checks.js +144 -0
- package/dist/game/tutorial/checks.js.map +1 -0
- package/dist/game/tutorial/createDemoMatch.d.ts +47 -0
- package/dist/game/tutorial/createDemoMatch.d.ts.map +1 -0
- package/dist/game/tutorial/createDemoMatch.js +67 -0
- package/dist/game/tutorial/createDemoMatch.js.map +1 -0
- package/dist/game/tutorial/defineTutorial.d.ts +353 -0
- package/dist/game/tutorial/defineTutorial.d.ts.map +1 -0
- package/dist/game/tutorial/defineTutorial.js +86 -0
- package/dist/game/tutorial/defineTutorial.js.map +1 -0
- package/dist/game/tutorial/runTutorial.d.ts +63 -0
- package/dist/game/tutorial/runTutorial.d.ts.map +1 -0
- package/dist/game/tutorial/runTutorial.js +273 -0
- package/dist/game/tutorial/runTutorial.js.map +1 -0
- package/dist/hooks/usePanelNavigation.d.ts +28 -0
- package/dist/hooks/usePanelNavigation.d.ts.map +1 -0
- package/dist/hooks/usePanelNavigation.js +36 -0
- package/dist/hooks/usePanelNavigation.js.map +1 -0
- package/dist/hooks/useTimeController.d.ts +2 -1
- package/dist/hooks/useTimeController.d.ts.map +1 -1
- package/dist/hooks/useTimeController.js +6 -2
- package/dist/hooks/useTimeController.js.map +1 -1
- package/dist/hooks/useTokenMap.d.ts +2 -4
- package/dist/hooks/useTokenMap.d.ts.map +1 -1
- package/dist/hooks/useTokenMap.js +2 -5
- package/dist/hooks/useTokenMap.js.map +1 -1
- package/dist/hooks/useTutorial.d.ts +48 -0
- package/dist/hooks/useTutorial.d.ts.map +1 -0
- package/dist/hooks/useTutorial.js +16 -0
- package/dist/hooks/useTutorial.js.map +1 -0
- package/dist/index.d.ts +57 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.html +12 -0
- package/dist/index.js +27 -3
- package/dist/index.js.map +1 -1
- package/dist/main.0792d734cde2c688d5f7.hot-update.js +16991 -0
- package/dist/main.0792d734cde2c688d5f7.hot-update.js.map +1 -0
- package/dist/main.0792d734cde2c688d5f7.hot-update.json +1 -0
- package/dist/pretty-chitty.js +204513 -0
- package/dist/pretty-chitty.js.map +1 -0
- package/dist/rendering/CameraWrapperPerspective.d.ts +5 -0
- package/dist/rendering/CameraWrapperPerspective.d.ts.map +1 -1
- package/dist/rendering/CameraWrapperPerspective.js +16 -0
- package/dist/rendering/CameraWrapperPerspective.js.map +1 -1
- package/dist/rendering/ChitGalleryItemInstance.d.ts +1 -0
- package/dist/rendering/ChitGalleryItemInstance.d.ts.map +1 -1
- package/dist/rendering/ChitGalleryItemInstance.js +12 -0
- package/dist/rendering/ChitGalleryItemInstance.js.map +1 -1
- package/dist/rendering/ChitRenderInstance.d.ts +9 -1
- package/dist/rendering/ChitRenderInstance.d.ts.map +1 -1
- package/dist/rendering/ChitRenderInstance.js +28 -0
- package/dist/rendering/ChitRenderInstance.js.map +1 -1
- package/dist/rendering/RootChitRenderInstance.d.ts +2 -0
- package/dist/rendering/RootChitRenderInstance.d.ts.map +1 -1
- package/dist/rendering/RootChitRenderInstance.js +29 -0
- package/dist/rendering/RootChitRenderInstance.js.map +1 -1
- package/dist/utilities/Annotations.d.ts +15 -0
- package/dist/utilities/Annotations.d.ts.map +1 -1
- package/dist/utilities/Annotations.js +31 -7
- package/dist/utilities/Annotations.js.map +1 -1
- package/dist/utilities/CanvasStack/CanvasStack.d.ts +13 -0
- package/dist/utilities/CanvasStack/CanvasStack.d.ts.map +1 -1
- package/dist/utilities/CanvasStack/CanvasStack.js +66 -15
- package/dist/utilities/CanvasStack/CanvasStack.js.map +1 -1
- package/dist/utilities/TokenizedText.d.ts +55 -0
- package/dist/utilities/TokenizedText.d.ts.map +1 -0
- package/dist/utilities/TokenizedText.js +47 -0
- package/dist/utilities/TokenizedText.js.map +1 -0
- package/dist/utilities/zIndex.d.ts +1 -0
- package/dist/utilities/zIndex.d.ts.map +1 -1
- package/dist/utilities/zIndex.js +1 -0
- package/dist/utilities/zIndex.js.map +1 -1
- package/package.json +3 -2
- package/src/library/components/ActionLogDisplay.tsx +1 -0
- package/src/library/components/BottomBarButton.tsx +5 -0
- package/src/library/components/ClientTrustMatchViewer.tsx +32 -2
- package/src/library/components/ContextGalleryDisplay.tsx +2 -0
- package/src/library/components/DemoWrapper.tsx +147 -52
- package/src/library/components/FullScreenGalleryDisplay.tsx +3 -0
- package/src/library/components/Gallery/BuiltItem.ts +34 -9
- package/src/library/components/Gallery/GalleryController.ts +75 -2
- package/src/library/components/Gallery/GalleryViewer.tsx +54 -10
- package/src/library/components/Gallery/LayoutManager.ts +30 -6
- package/src/library/components/Gallery/constants.ts +2 -0
- package/src/library/components/Gallery/registry.ts +44 -0
- package/src/library/components/GameDesigner.tsx +121 -12
- package/src/library/components/InlineGalleryDisplay.tsx +5 -0
- package/src/library/components/LiveButton.tsx +8 -5
- package/src/library/components/MatchViewer.tsx +14 -3
- package/src/library/components/Panel/MultiPanel.tsx +21 -0
- package/src/library/components/Panel/PanelContents.tsx +70 -1
- package/src/library/components/Panel/PanelTabStack.tsx +1 -0
- package/src/library/components/PanelSpark.tsx +9 -4
- package/src/library/components/Playground.tsx +125 -33
- package/src/library/components/PromptControls.tsx +7 -3
- package/src/library/components/SparkLineChart.tsx +23 -27
- package/src/library/components/TimeControlBar.tsx +5 -3
- package/src/library/components/TokenizedMarkdown.tsx +224 -0
- package/src/library/components/TokenizedMessage.tsx +30 -95
- package/src/library/components/TopBarPlayers.tsx +18 -10
- package/src/library/components/Tutorial/BrowserNarration.ts +233 -0
- package/src/library/components/Tutorial/TutorialBox.tsx +506 -0
- package/src/library/components/Tutorial/TutorialDevPanel.tsx +297 -0
- package/src/library/components/Tutorial/TutorialOverlay.tsx +1301 -0
- package/src/library/components/Tutorial/targetRects.ts +273 -0
- package/src/library/game/Chit.ts +23 -7
- package/src/library/game/ClientTimeState.ts +18 -0
- package/src/library/game/ConnectionTransport.ts +12 -3
- package/src/library/game/Game.ts +16 -1
- package/src/library/game/GameTheme.ts +4 -0
- package/src/library/game/Match.ts +174 -5
- package/src/library/game/MatchStorage.ts +14 -4
- package/src/library/game/Pick.ts +36 -1
- package/src/library/game/PlayerChit.ts +4 -1
- package/src/library/game/PlayerInfo.ts +13 -3
- package/src/library/game/PlayerPromptStatusChit.ts +8 -2
- package/src/library/game/Prompt.ts +20 -0
- package/src/library/game/Turn.ts +198 -68
- package/src/library/game/TurnState.ts +34 -3
- package/src/library/game/ai/AI_GUIDE.md +444 -0
- package/src/library/game/ai/AiClientPrompts.ts +730 -0
- package/src/library/game/ai/AiLiveView.ts +63 -0
- package/src/library/game/ai/AiPlayerView.ts +114 -0
- package/src/library/game/ai/ai.test.ts +475 -0
- package/src/library/game/ai/connectAiPlayer.ts +88 -0
- package/src/library/game/ai/defineAi.ts +230 -0
- package/src/library/game/ai/simulateMatches.ts +172 -0
- package/src/library/game/badAiTransport/BadAIClientPrompts.ts +3 -0
- package/src/library/game/clientTransport/ClientPrompts.ts +31 -1
- package/src/library/game/clientTransport/ClientTime.ts +54 -13
- package/src/library/game/serialize.test.ts +275 -0
- package/src/library/game/tutorial/TUTORIAL_GUIDE.md +411 -0
- package/src/library/game/tutorial/TutorialController.test.ts +731 -0
- package/src/library/game/tutorial/TutorialController.ts +1286 -0
- package/src/library/game/tutorial/TutorialRuntime.ts +311 -0
- package/src/library/game/tutorial/TutorialTheme.ts +67 -0
- package/src/library/game/tutorial/allowed.ts +145 -0
- package/src/library/game/tutorial/checks.ts +186 -0
- package/src/library/game/tutorial/createDemoMatch.ts +115 -0
- package/src/library/game/tutorial/defineTutorial.ts +414 -0
- package/src/library/game/tutorial/runTutorial.ts +331 -0
- package/src/library/game/undo.test.ts +282 -0
- package/src/library/hooks/usePanelNavigation.tsx +65 -0
- package/src/library/hooks/useTimeController.tsx +6 -2
- package/src/library/hooks/useTokenMap.ts +2 -6
- package/src/library/hooks/useTutorial.tsx +76 -0
- package/src/library/index.ts +91 -4
- package/src/library/rendering/CameraWrapperPerspective.ts +17 -0
- package/src/library/rendering/ChitGalleryItemInstance.ts +12 -0
- package/src/library/rendering/ChitRenderInstance.ts +34 -0
- package/src/library/rendering/RootChitRenderInstance.ts +30 -1
- package/src/library/utilities/Annotations.ts +35 -7
- package/src/library/utilities/CanvasStack/CanvasStack.ts +74 -29
- package/src/library/utilities/TokenizedText.test.ts +32 -0
- package/src/library/utilities/TokenizedText.ts +103 -0
- package/src/library/utilities/zIndex.ts +1 -0
|
@@ -60,11 +60,15 @@ export function useAnimationSpeedMultiplier() {
|
|
|
60
60
|
return speed;
|
|
61
61
|
}
|
|
62
62
|
|
|
63
|
-
export function TimeControllerProvider({ children }: { children: ReactNode }) {
|
|
63
|
+
export function TimeControllerProvider({ children, skipReplay = false }: { children: ReactNode; skipReplay?: boolean }) {
|
|
64
64
|
const connection = useConnection();
|
|
65
65
|
const playerId = usePlayerId();
|
|
66
66
|
const game = useGame();
|
|
67
|
-
const [clientTimeState] = useState<ClientTimeState>(
|
|
67
|
+
const [clientTimeState] = useState<ClientTimeState>(() => {
|
|
68
|
+
const state = new ClientTimeState();
|
|
69
|
+
state.skipInitialReplay = skipReplay;
|
|
70
|
+
return state;
|
|
71
|
+
});
|
|
68
72
|
const [clientTime, setClientTime] = useState<ClientTime | null>(null);
|
|
69
73
|
const [clientPrompts, setClientPrompts] = useState<ClientPrompts<any, any> | undefined>(undefined);
|
|
70
74
|
const [clientStatus, setClientStatus] = useState<ClientStatus<any, any> | undefined>(undefined);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { useChit, useChits } from "../hooks/useChits";
|
|
2
2
|
import { PlayerChit } from "../game/PlayerChit";
|
|
3
3
|
import { RootChit } from "../game/RootChit";
|
|
4
|
-
import {
|
|
4
|
+
import { buildTokenMap, TokenMap } from "../utilities/TokenizedText";
|
|
5
5
|
import { useGameTheme } from "./useGameTheme";
|
|
6
6
|
import { useGame } from "./useGame";
|
|
7
7
|
|
|
@@ -11,10 +11,6 @@ export function useTokenMap() {
|
|
|
11
11
|
const root = useChit<RootChit<PlayerChit>>("root");
|
|
12
12
|
const playerChits = useChits<PlayerChit>(root?.players.map((p) => p.id ?? "") ?? []);
|
|
13
13
|
|
|
14
|
-
const tokenMap:
|
|
15
|
-
playerChits?.forEach((p) => {
|
|
16
|
-
tokenMap[p.playerId] = { label: p.name ?? "??", color: p.color ?? theme.actionLogTextColor, image: p.imageUrl };
|
|
17
|
-
});
|
|
18
|
-
tokenMap["warning"] = { label: "⚠️" };
|
|
14
|
+
const tokenMap: TokenMap = buildTokenMap(game.tokenMap, playerChits ?? [], theme.actionLogTextColor);
|
|
19
15
|
return tokenMap;
|
|
20
16
|
}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import React, { createContext, ReactNode, useContext, useMemo, useState } from "react";
|
|
2
|
+
import { EventChannel } from "../utilities/EventChannel";
|
|
3
|
+
import { TutorialSpec } from "../game/tutorial/defineTutorial";
|
|
4
|
+
import { TutorialController, TutorialEvent } from "../game/tutorial/TutorialController";
|
|
5
|
+
import { TutorialRuntime } from "../game/tutorial/TutorialRuntime";
|
|
6
|
+
import { TutorialTheme } from "../game/tutorial/TutorialTheme";
|
|
7
|
+
import { MatchAiControls } from "../game/Match";
|
|
8
|
+
|
|
9
|
+
export type TutorialDevSettings = {
|
|
10
|
+
showTargetRects: boolean;
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
export type TutorialContextValue = {
|
|
14
|
+
spec: TutorialSpec<any, any>;
|
|
15
|
+
runtime: TutorialRuntime<any, any>;
|
|
16
|
+
themeOverrides?: Partial<TutorialTheme>;
|
|
17
|
+
ai?: MatchAiControls;
|
|
18
|
+
onEvent?: (e: TutorialEvent) => void;
|
|
19
|
+
/** Set by the overlay once it has built the controller (it needs the match view, which lives inside MatchViewer) */
|
|
20
|
+
controller: EventChannel<TutorialController<any, any> | undefined>;
|
|
21
|
+
dev: EventChannel<TutorialDevSettings>;
|
|
22
|
+
/** Start muted (dev panel toggle) */
|
|
23
|
+
muted: EventChannel<boolean>;
|
|
24
|
+
/** Step to start on (dev panel restarts, rewinds) */
|
|
25
|
+
startAt: number;
|
|
26
|
+
/** Start the script without the Start tap (after a rewind or a dev restart) */
|
|
27
|
+
autoStart: boolean;
|
|
28
|
+
/** Start held (after Back): silent until the player presses Play */
|
|
29
|
+
startPaused: boolean;
|
|
30
|
+
/** Serializes the match for a step snapshot; undefined when the host cannot rebuild the match */
|
|
31
|
+
snapshot?: () => unknown;
|
|
32
|
+
/** Puts the match back to the snapshot taken when `stepId` went live; false when there is none */
|
|
33
|
+
rewind?: (stepId: string) => Promise<boolean>;
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
const TutorialContext = createContext<TutorialContextValue | undefined>(undefined);
|
|
37
|
+
|
|
38
|
+
/** The running tutorial, or undefined when the match has none. */
|
|
39
|
+
export function useTutorial(): TutorialContextValue | undefined {
|
|
40
|
+
return useContext(TutorialContext);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export function TutorialProvider({
|
|
44
|
+
spec,
|
|
45
|
+
runtime,
|
|
46
|
+
themeOverrides,
|
|
47
|
+
ai,
|
|
48
|
+
onEvent,
|
|
49
|
+
startAt = 0,
|
|
50
|
+
autoStart = false,
|
|
51
|
+
startPaused = false,
|
|
52
|
+
snapshot,
|
|
53
|
+
rewind,
|
|
54
|
+
children,
|
|
55
|
+
}: {
|
|
56
|
+
spec: TutorialSpec<any, any>;
|
|
57
|
+
runtime: TutorialRuntime<any, any>;
|
|
58
|
+
themeOverrides?: Partial<TutorialTheme>;
|
|
59
|
+
ai?: MatchAiControls;
|
|
60
|
+
onEvent?: (e: TutorialEvent) => void;
|
|
61
|
+
startAt?: number;
|
|
62
|
+
autoStart?: boolean;
|
|
63
|
+
startPaused?: boolean;
|
|
64
|
+
snapshot?: () => unknown;
|
|
65
|
+
rewind?: (stepId: string) => Promise<boolean>;
|
|
66
|
+
children: ReactNode;
|
|
67
|
+
}) {
|
|
68
|
+
const [controller] = useState(() => new EventChannel<TutorialController<any, any> | undefined>(undefined));
|
|
69
|
+
const [dev] = useState(() => new EventChannel<TutorialDevSettings>({ showTargetRects: false }));
|
|
70
|
+
const [muted] = useState(() => new EventChannel<boolean>(false));
|
|
71
|
+
const value = useMemo<TutorialContextValue>(
|
|
72
|
+
() => ({ spec, runtime, themeOverrides, ai, onEvent, controller, dev, muted, startAt, autoStart, startPaused, snapshot, rewind }),
|
|
73
|
+
[spec, runtime, themeOverrides, ai, onEvent, controller, dev, muted, startAt, autoStart, startPaused, snapshot, rewind],
|
|
74
|
+
);
|
|
75
|
+
return <TutorialContext.Provider value={value}>{children}</TutorialContext.Provider>;
|
|
76
|
+
}
|
package/src/library/index.ts
CHANGED
|
@@ -11,6 +11,8 @@ export { Chit } from "./game/Chit";
|
|
|
11
11
|
export { Turn } from "./game/Turn";
|
|
12
12
|
/** @group Core Game Elements */
|
|
13
13
|
export { Pick, ButtonPick, ChitPick, DragTarget, DragPick } from "./game/Pick";
|
|
14
|
+
/** @group Supporting Types */
|
|
15
|
+
export type { PickAiTag } from "./game/Pick";
|
|
14
16
|
/** @group Core Game Elements */
|
|
15
17
|
export { GameTheme } from "./game/GameTheme";
|
|
16
18
|
/** @group Chits */
|
|
@@ -35,6 +37,85 @@ export { ChildOutlet, NonEditable, Ordered, Selectable } from "./utilities/Annot
|
|
|
35
37
|
/** @group Chit Annotations */
|
|
36
38
|
export type { SelectableChoice, SelectableConfig, SelectablePropertyInfo } from "./utilities/Annotations";
|
|
37
39
|
|
|
40
|
+
/** @group AI */
|
|
41
|
+
export { defineAi } from "./game/ai/defineAi";
|
|
42
|
+
/** @group AI */
|
|
43
|
+
export type {
|
|
44
|
+
GameAi,
|
|
45
|
+
AiRule,
|
|
46
|
+
AiScore,
|
|
47
|
+
AiContext,
|
|
48
|
+
AiOption,
|
|
49
|
+
AiChitOption,
|
|
50
|
+
AiDragOption,
|
|
51
|
+
AiButtonOption,
|
|
52
|
+
AiPickInfo,
|
|
53
|
+
} from "./game/ai/defineAi";
|
|
54
|
+
/** @group AI */
|
|
55
|
+
export { connectAiPlayer } from "./game/ai/connectAiPlayer";
|
|
56
|
+
/** @group AI */
|
|
57
|
+
export type { ConnectAiPlayerOptions, AiPlayerHandle } from "./game/ai/connectAiPlayer";
|
|
58
|
+
/** @group AI */
|
|
59
|
+
export type { AiPlayerOptions, AiPlayerStats, AiDecision, AiMemoryStore } from "./game/ai/AiClientPrompts";
|
|
60
|
+
/** @group AI */
|
|
61
|
+
export { simulateMatches } from "./game/ai/simulateMatches";
|
|
62
|
+
/** @group AI */
|
|
63
|
+
export type { SimulateMatchesOptions, SimulatedMatch, SimulationReport } from "./game/ai/simulateMatches";
|
|
64
|
+
|
|
65
|
+
/** @group Tutorials */
|
|
66
|
+
export { defineTutorial, listTutorials, findTutorial, splitSentences } from "./game/tutorial/defineTutorial";
|
|
67
|
+
/** @group Tutorials */
|
|
68
|
+
export type {
|
|
69
|
+
TutorialSpec,
|
|
70
|
+
TutorialStep,
|
|
71
|
+
TutorialMatchSetup,
|
|
72
|
+
TutorialContext,
|
|
73
|
+
TutorialSummary,
|
|
74
|
+
Checker,
|
|
75
|
+
CheckResult,
|
|
76
|
+
ChitSelector,
|
|
77
|
+
Target,
|
|
78
|
+
UiTarget,
|
|
79
|
+
Focus,
|
|
80
|
+
Cue,
|
|
81
|
+
BoxPlacement,
|
|
82
|
+
BoxAnchor,
|
|
83
|
+
ForcedDecision,
|
|
84
|
+
AllowedAction,
|
|
85
|
+
GalleryCommand,
|
|
86
|
+
Pose,
|
|
87
|
+
TimelineCommand,
|
|
88
|
+
TutorialGalleryState,
|
|
89
|
+
} from "./game/tutorial/defineTutorial";
|
|
90
|
+
/** @group Tutorials */
|
|
91
|
+
export { checks } from "./game/tutorial/checks";
|
|
92
|
+
/** @group Tutorials */
|
|
93
|
+
export { runTutorial } from "./game/tutorial/runTutorial";
|
|
94
|
+
/** @group Tutorials */
|
|
95
|
+
export type { RunTutorialOptions, RunTutorialResult } from "./game/tutorial/runTutorial";
|
|
96
|
+
/** @group Tutorials */
|
|
97
|
+
export { createDemoMatch } from "./game/tutorial/createDemoMatch";
|
|
98
|
+
/** @group Tutorials */
|
|
99
|
+
export type { DemoMatch, CreateDemoMatchOptions } from "./game/tutorial/createDemoMatch";
|
|
100
|
+
/** @group Tutorials */
|
|
101
|
+
export { TutorialController } from "./game/tutorial/TutorialController";
|
|
102
|
+
/** @group Tutorials */
|
|
103
|
+
export type { TutorialEvent, TutorialStatus, TutorialView, NarrationPlayer } from "./game/tutorial/TutorialController";
|
|
104
|
+
/** @group Tutorials */
|
|
105
|
+
export { TutorialRuntime } from "./game/tutorial/TutorialRuntime";
|
|
106
|
+
/** @group Tutorials */
|
|
107
|
+
export type { TutorialTheme } from "./game/tutorial/TutorialTheme";
|
|
108
|
+
/** @group Tutorials */
|
|
109
|
+
export { resolveTutorialTheme } from "./game/tutorial/TutorialTheme";
|
|
110
|
+
/** @group Tutorials */
|
|
111
|
+
export { TokenizedMarkdown } from "./components/TokenizedMarkdown";
|
|
112
|
+
/** @group Tutorials */
|
|
113
|
+
export { TutorialDevPanel } from "./components/Tutorial/TutorialDevPanel";
|
|
114
|
+
/** @group Supporting Types */
|
|
115
|
+
export type { RngSource } from "./game/TurnState";
|
|
116
|
+
/** @group Supporting Types */
|
|
117
|
+
export type { MatchConfig } from "./game/Match";
|
|
118
|
+
|
|
38
119
|
/** @group Buttons */
|
|
39
120
|
export { GameButton, DynamicGameButton, ToggleGalleryButton } from "./game/GameButton";
|
|
40
121
|
|
|
@@ -42,6 +123,9 @@ export { GameButton, DynamicGameButton, ToggleGalleryButton } from "./game/GameB
|
|
|
42
123
|
export { ParameterizedCanvas } from "./utilities/ParameterizedCanvas";
|
|
43
124
|
/** @group 2D Rendering */
|
|
44
125
|
export { StaticImage } from "./utilities/StaticImage";
|
|
126
|
+
|
|
127
|
+
export { tokenizedMessageToText, buildTokenMap, parseMessageTokens } from "./utilities/TokenizedText";
|
|
128
|
+
export type { TokenDefinition, TokenMap } from "./utilities/TokenizedText";
|
|
45
129
|
/** @group 2D Rendering */
|
|
46
130
|
export * as ReactCanvas from "./utilities/CanvasStack/ReactCanvas";
|
|
47
131
|
/** @group 2D Rendering */
|
|
@@ -81,16 +165,19 @@ export type { Stage } from "./game/GameDeckChit";
|
|
|
81
165
|
/** @group Supporting Types */
|
|
82
166
|
export { PlayerInfo } from "./game/PlayerInfo";
|
|
83
167
|
/** @group Supporting Types */
|
|
84
|
-
export type { IPlayerInfo } from "./game/PlayerInfo";
|
|
168
|
+
export type { IPlayerInfo, AiSeatInfo } from "./game/PlayerInfo";
|
|
85
169
|
/** @internal */
|
|
86
170
|
/** @group Supporting Types */
|
|
87
171
|
export { MatchViewer } from "./components/MatchViewer";
|
|
88
|
-
/** @
|
|
89
|
-
/** @group Supporting Types */
|
|
172
|
+
/** @group Tutorials */
|
|
90
173
|
export { DemoWrapper } from "./components/DemoWrapper";
|
|
174
|
+
/** @group Tutorials */
|
|
175
|
+
export type { DemoWrapperProps } from "./components/DemoWrapper";
|
|
91
176
|
/** @internal */
|
|
92
177
|
/** @group Supporting Types */
|
|
93
|
-
export { Match } from "./game/Match";
|
|
178
|
+
export { Match, MatchAiControls } from "./game/Match";
|
|
179
|
+
/** @group AI */
|
|
180
|
+
export type { SeatAiPlayersOptions } from "./game/Match";
|
|
94
181
|
/** @internal */
|
|
95
182
|
/** @group Supporting Types */
|
|
96
183
|
export { Connection } from "./game/Connection";
|
|
@@ -151,6 +151,23 @@ export class CameraWrapperPerspective {
|
|
|
151
151
|
this.adjust(this.bbox, !animate);
|
|
152
152
|
}
|
|
153
153
|
|
|
154
|
+
/**
|
|
155
|
+
* Zooms to `zoom` (clamped to the camera's range) and brings the point at panel pixel (x, y) to the
|
|
156
|
+
* middle of the panel, as far as panning allows. Animated. Zoom 1 is the whole table.
|
|
157
|
+
*/
|
|
158
|
+
public focusOn(x: number, y: number, zoom: number): void {
|
|
159
|
+
const z = Math.max(1, Math.min(zoom, this.cameraSpec.maxZoom));
|
|
160
|
+
// A point on screen sits at (content * zoom + offset) from the middle: keep the content under
|
|
161
|
+
// (x, y) and move it to the middle
|
|
162
|
+
const sx = x - this.width / 2;
|
|
163
|
+
const sy = y - this.height / 2;
|
|
164
|
+
this.current.x = -(sx - this.current.x) * (z / this.current.z);
|
|
165
|
+
this.current.y = -(sy - this.current.y) * (z / this.current.z);
|
|
166
|
+
this.current.z = z;
|
|
167
|
+
this.lockZoom();
|
|
168
|
+
this.adjust(this.bbox, false);
|
|
169
|
+
}
|
|
170
|
+
|
|
154
171
|
private lockZoom() {
|
|
155
172
|
const maxZoom = this.cameraSpec.maxZoom;
|
|
156
173
|
if (this.current.z <= 1) {
|
|
@@ -26,6 +26,7 @@ export class ChitGalleryItemInstance implements GalleryItem {
|
|
|
26
26
|
shortSummaryRenderingOptions?: RichTextRenderOptionsParameters;
|
|
27
27
|
|
|
28
28
|
private sceneWrapper: SceneWrapper | undefined;
|
|
29
|
+
private creatingMesh = false;
|
|
29
30
|
|
|
30
31
|
constructor(public chit: Chit) {
|
|
31
32
|
this.id = chit.id ?? "no id";
|
|
@@ -82,6 +83,14 @@ export class ChitGalleryItemInstance implements GalleryItem {
|
|
|
82
83
|
const renderInstance = this.chit.renderInstance;
|
|
83
84
|
const g = new Group();
|
|
84
85
|
if (renderInstance) {
|
|
86
|
+
// a refresh re-renders the chit, which would ask us to rebuild while we're mid-build
|
|
87
|
+
this.creatingMesh = true;
|
|
88
|
+
try {
|
|
89
|
+
renderInstance.refreshDisposedTextures();
|
|
90
|
+
} finally {
|
|
91
|
+
this.creatingMesh = false;
|
|
92
|
+
}
|
|
93
|
+
|
|
85
94
|
const mesh = this.cloneWithUserData(renderInstance.group) ?? new Group();
|
|
86
95
|
mesh.visible = true;
|
|
87
96
|
mesh.rotation.set(0, 0, 0);
|
|
@@ -101,6 +110,9 @@ export class ChitGalleryItemInstance implements GalleryItem {
|
|
|
101
110
|
}
|
|
102
111
|
|
|
103
112
|
update() {
|
|
113
|
+
if (this.creatingMesh) {
|
|
114
|
+
return;
|
|
115
|
+
}
|
|
104
116
|
this.cbs.forEach((cb) => cb());
|
|
105
117
|
}
|
|
106
118
|
|
|
@@ -5,6 +5,7 @@ import {
|
|
|
5
5
|
Group,
|
|
6
6
|
Mesh,
|
|
7
7
|
MeshBasicMaterial,
|
|
8
|
+
Object3D,
|
|
8
9
|
Plane,
|
|
9
10
|
Quaternion,
|
|
10
11
|
Raycaster,
|
|
@@ -18,6 +19,7 @@ import { Easing, Tween, Group as TweenGroup } from "@tweenjs/tween.js";
|
|
|
18
19
|
import { RootChitRenderInstance } from "./RootChitRenderInstance";
|
|
19
20
|
import { fixBbox } from "../utilities/BboxUtils";
|
|
20
21
|
import { ChitGalleryItemInstance } from "./ChitGalleryItemInstance";
|
|
22
|
+
import { CanvasStack } from "../utilities/CanvasStack/CanvasStack";
|
|
21
23
|
|
|
22
24
|
const LINE_COLOR = new MeshBasicMaterial({ color: 0xff0000, wireframe: true, wireframeLinewidth: 2 });
|
|
23
25
|
const CLICK_LINE_COLOR = new MeshBasicMaterial({ color: 0xffff00, wireframe: true, wireframeLinewidth: 2 });
|
|
@@ -50,6 +52,11 @@ export class ChitRenderInstance {
|
|
|
50
52
|
// rendering info
|
|
51
53
|
protected renderSpec: ChitRenderSpec | null = null;
|
|
52
54
|
|
|
55
|
+
/** The chit's own drawn object (not its children or ornaments), for exact hit tests on a tap. */
|
|
56
|
+
public get hitObject(): Object3D | undefined {
|
|
57
|
+
return this.renderSpec?.object ?? undefined;
|
|
58
|
+
}
|
|
59
|
+
|
|
53
60
|
// threejs info
|
|
54
61
|
public group = new Group(); // group storing the visible meshes. Will tween
|
|
55
62
|
protected targetAnchorPoints = new Map<OwnerOriginPosition | string, Vector3>();
|
|
@@ -453,6 +460,33 @@ export class ChitRenderInstance {
|
|
|
453
460
|
return this._galleryItem;
|
|
454
461
|
}
|
|
455
462
|
|
|
463
|
+
/**
|
|
464
|
+
* Hidden chits (e.g. inside a deck or bag) aren't counted by the TextureReferenceCounter, so their textures get
|
|
465
|
+
* reclaimed while the render spec still points at them. Galleries clone that spec, so re-render first if stale.
|
|
466
|
+
*/
|
|
467
|
+
public refreshDisposedTextures() {
|
|
468
|
+
if (this.usesDisposedTexture()) {
|
|
469
|
+
this.refresh();
|
|
470
|
+
}
|
|
471
|
+
[...this.childrenRenderInstances].forEach((child) => child.refreshDisposedTextures());
|
|
472
|
+
}
|
|
473
|
+
|
|
474
|
+
private usesDisposedTexture() {
|
|
475
|
+
let disposed = false;
|
|
476
|
+
[this.renderSpec?.object, ...(this.renderSpec?.ornaments ?? [])].forEach((root) =>
|
|
477
|
+
root?.traverse((obj) => {
|
|
478
|
+
if (!disposed && obj instanceof Mesh) {
|
|
479
|
+
const materials = Array.isArray(obj.material) ? obj.material : [obj.material];
|
|
480
|
+
disposed = materials.some((m) => {
|
|
481
|
+
const map = (m as MeshBasicMaterial | undefined)?.map;
|
|
482
|
+
return !!map && CanvasStack.isDisposedTexture(map);
|
|
483
|
+
});
|
|
484
|
+
}
|
|
485
|
+
}),
|
|
486
|
+
);
|
|
487
|
+
return disposed;
|
|
488
|
+
}
|
|
489
|
+
|
|
456
490
|
public destroyGalleryItem() {
|
|
457
491
|
if (this._galleryItem) {
|
|
458
492
|
this._galleryItem.destroy();
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Tween, Group as TweenGroup } from "@tweenjs/tween.js";
|
|
2
2
|
import { ChitRenderInstance } from "./ChitRenderInstance";
|
|
3
3
|
import { Chit } from "../game/Chit";
|
|
4
|
-
import { Box3, Group, Object3D, Plane, Raycaster, Vector2, Vector3 } from "three";
|
|
4
|
+
import { Box3, Group, Mesh, Object3D, Plane, Raycaster, Vector2, Vector3 } from "three";
|
|
5
5
|
import { CameraWrapperPerspective } from "./CameraWrapperPerspective";
|
|
6
6
|
import { LightWrapper } from "./LightWrapper";
|
|
7
7
|
import { ModalState } from "../game/ModalState";
|
|
@@ -331,6 +331,11 @@ export class RootChitRenderInstance extends ChitRenderInstance implements Textur
|
|
|
331
331
|
precision: number,
|
|
332
332
|
): Chit[] {
|
|
333
333
|
const result = new Map<Chit, number>();
|
|
334
|
+
// Box hits that the ray also hits on the chit's real shape. A clickbox is the axis-aligned box around the whole
|
|
335
|
+
// object, so a large irregular piece (a sea area, a province) claims every tap inside its rectangle, and
|
|
336
|
+
// neighbours whose rectangles overlap would all be offered in a gallery. See the end of this function.
|
|
337
|
+
const exact = new Map<Chit, number>();
|
|
338
|
+
const hasShape = new Map<Chit, boolean>();
|
|
334
339
|
const chitRenderInstances: ChitRenderInstance[] = [];
|
|
335
340
|
const threeJsToChitLookup: { [threejsId: number]: Chit } = {};
|
|
336
341
|
|
|
@@ -371,10 +376,28 @@ export class RootChitRenderInstance extends ChitRenderInstance implements Textur
|
|
|
371
376
|
const c = threeJsToChitLookup[id];
|
|
372
377
|
if (filter(c)) {
|
|
373
378
|
result.set(c, Math.min(result.get(c) ?? r, r));
|
|
379
|
+
const shape = c.renderInstance?.hitObject;
|
|
380
|
+
if (!hasShape.has(c)) {
|
|
381
|
+
let meshes = false;
|
|
382
|
+
shape?.traverse((o) => {
|
|
383
|
+
if ((o as Mesh).isMesh) meshes = true;
|
|
384
|
+
});
|
|
385
|
+
hasShape.set(c, meshes);
|
|
386
|
+
}
|
|
387
|
+
if (shape && hasShape.get(c) && (exact.get(c) ?? Infinity) > r && raycaster.intersectObject(shape, true).length) {
|
|
388
|
+
exact.set(c, r);
|
|
389
|
+
}
|
|
374
390
|
}
|
|
375
391
|
}
|
|
376
392
|
}
|
|
377
393
|
}
|
|
394
|
+
// Keep the chits whose real shape was hit, plus those with no mesh of their own to test (an empty group that
|
|
395
|
+
// is clicked through its children). If no shape was hit at all (a tap in the gap between pieces, within the
|
|
396
|
+
// finger tolerance), fall back to the boxes so a near miss still lands. Nearest first.
|
|
397
|
+
const precise = [...result.keys()].filter((c) => exact.has(c) || !hasShape.get(c));
|
|
398
|
+
if (precise.length && precise.length < result.size) {
|
|
399
|
+
return precise.sort((a, b) => (exact.get(a) ?? result.get(a)!) - (exact.get(b) ?? result.get(b)!));
|
|
400
|
+
}
|
|
378
401
|
return [...result.keys()];
|
|
379
402
|
}
|
|
380
403
|
|
|
@@ -465,6 +488,12 @@ export class RootChitRenderInstance extends ChitRenderInstance implements Textur
|
|
|
465
488
|
this.markDirty();
|
|
466
489
|
}
|
|
467
490
|
|
|
491
|
+
/** Zooms the camera to `zoom` around panel pixel (x, y), bringing it to the middle (see `CameraWrapperPerspective.focusOn`) */
|
|
492
|
+
public focusCamera(x: number, y: number, zoom: number) {
|
|
493
|
+
this.cameraWrapper.focusOn(x, y, zoom);
|
|
494
|
+
this.markDirty();
|
|
495
|
+
}
|
|
496
|
+
|
|
468
497
|
public get cameraZoom() {
|
|
469
498
|
return this.cameraWrapper.zoom;
|
|
470
499
|
}
|
|
@@ -23,6 +23,11 @@ export interface SelectableConfig {
|
|
|
23
23
|
label: string;
|
|
24
24
|
/** List of possible choices for this property */
|
|
25
25
|
choices: SelectableChoice[];
|
|
26
|
+
/**
|
|
27
|
+
* When true the property holds any number of the choices' ids (a `string[]`, e.g. the expansion
|
|
28
|
+
* modules a match plays with) rather than exactly one. Defaults to false.
|
|
29
|
+
*/
|
|
30
|
+
multiple?: boolean;
|
|
26
31
|
}
|
|
27
32
|
|
|
28
33
|
/**
|
|
@@ -203,17 +208,30 @@ export function FixChildOutlets(instance: Chit) {
|
|
|
203
208
|
|
|
204
209
|
if (obj?.__orderedOutlets) {
|
|
205
210
|
Object.entries(obj.__orderedOutlets).forEach(([key, prop]: [key: any, prop: any]) => {
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
if (v) {
|
|
209
|
-
v.outletName = key;
|
|
210
|
-
v.parent = instance;
|
|
211
|
+
if (seenKeys.has(`ordered:${key}`)) {
|
|
212
|
+
return;
|
|
211
213
|
}
|
|
214
|
+
seenKeys.add(`ordered:${key}`);
|
|
215
|
+
const existingValue = (instance as any)[key];
|
|
216
|
+
let v = existingValue || prop?.initializer?.apply(instance, []);
|
|
217
|
+
const adopt = (outlet: any) => {
|
|
218
|
+
if (outlet instanceof OrderedOutlet) {
|
|
219
|
+
outlet.outletName = key;
|
|
220
|
+
outlet.parent = instance;
|
|
221
|
+
}
|
|
222
|
+
};
|
|
223
|
+
adopt(v);
|
|
224
|
+
// An accessor rather than a data property: with TypeScript/esbuild class fields (no babel
|
|
225
|
+
// initializer capture) the subclass constructor assigns `new OrderedOutlet()` *after* this
|
|
226
|
+
// runs, and the setter adopts that outlet instead of leaving it parentless.
|
|
212
227
|
Object.defineProperty(instance, key, {
|
|
213
228
|
enumerable: true,
|
|
214
|
-
writable: true,
|
|
215
229
|
configurable: true,
|
|
216
|
-
|
|
230
|
+
get: () => v,
|
|
231
|
+
set: (newValue: any) => {
|
|
232
|
+
v = newValue;
|
|
233
|
+
adopt(v);
|
|
234
|
+
},
|
|
217
235
|
});
|
|
218
236
|
});
|
|
219
237
|
}
|
|
@@ -237,6 +255,16 @@ export function FixChildOutlets(instance: Chit) {
|
|
|
237
255
|
* ]
|
|
238
256
|
* })
|
|
239
257
|
* public difficulty: string = "medium";
|
|
258
|
+
*
|
|
259
|
+
* @Selectable({
|
|
260
|
+
* label: "Expansions",
|
|
261
|
+
* multiple: true,
|
|
262
|
+
* choices: [
|
|
263
|
+
* { id: "rivers", label: "Rivers" },
|
|
264
|
+
* { id: "traders", label: "Traders & Builders" },
|
|
265
|
+
* ],
|
|
266
|
+
* })
|
|
267
|
+
* public expansions: string[] = [];
|
|
240
268
|
* }
|
|
241
269
|
* ```
|
|
242
270
|
*
|
|
@@ -105,6 +105,7 @@ export class CanvasStack implements IUpdatingCanvas {
|
|
|
105
105
|
this._mipCanvases = [];
|
|
106
106
|
this._mipContexts = [];
|
|
107
107
|
CanvasStack._liveStacks.delete(this);
|
|
108
|
+
CanvasStack._pendingMips.delete(this);
|
|
108
109
|
|
|
109
110
|
if (this._material) {
|
|
110
111
|
this._material.dispose();
|
|
@@ -136,7 +137,7 @@ export class CanvasStack implements IUpdatingCanvas {
|
|
|
136
137
|
CanvasStack.ensureContextRestoreSubscription();
|
|
137
138
|
|
|
138
139
|
this.render();
|
|
139
|
-
this.
|
|
140
|
+
if (this.mipMaps > 0) CanvasStack.scheduleMips(this);
|
|
140
141
|
}
|
|
141
142
|
|
|
142
143
|
get mipMaps(): number {
|
|
@@ -144,6 +145,63 @@ export class CanvasStack implements IUpdatingCanvas {
|
|
|
144
145
|
return this.operation.benefitsFromMipMap() ? 2 : 0;
|
|
145
146
|
}
|
|
146
147
|
|
|
148
|
+
// Faces with text get hand-drawn mip levels: text rasterised at the small size is sharper than GPU box-filtering.
|
|
149
|
+
// Building that chain (a canvas per level, down to 1×1) for every face while the table loads is what stalled
|
|
150
|
+
// phones — Safari queues 2D drawing in its GPU process and the first texture upload waits for all of it (8 s on an
|
|
151
|
+
// iPhone for ~950 canvases). So every texture starts with GPU-generated mipmaps, and once canvas creation has gone
|
|
152
|
+
// quiet the faces that benefit get their custom chain a few per frame, swapped in by a re-upload. Plain images
|
|
153
|
+
// (mipMaps 0) never used the chain: the GPU builds theirs.
|
|
154
|
+
private static _pendingMips = new Set<CanvasStack>();
|
|
155
|
+
private static _mipTimer: ReturnType<typeof setTimeout> | undefined;
|
|
156
|
+
private static _firstPendingAt = 0;
|
|
157
|
+
private static readonly MIP_QUIET_MS = 1000; // build once no new canvas has appeared for this long…
|
|
158
|
+
private static readonly MIP_MAX_WAIT_MS = 5000; // …or this long after the first one started waiting
|
|
159
|
+
private static readonly MIP_FRAME_BUDGET_MS = 6;
|
|
160
|
+
|
|
161
|
+
private static scheduleMips(stack: CanvasStack) {
|
|
162
|
+
if (CanvasStack._pendingMips.size === 0) CanvasStack._firstPendingAt = Date.now();
|
|
163
|
+
CanvasStack._pendingMips.add(stack);
|
|
164
|
+
if (CanvasStack._mipTimer) clearTimeout(CanvasStack._mipTimer);
|
|
165
|
+
const waited = Date.now() - CanvasStack._firstPendingAt;
|
|
166
|
+
const delay = Math.max(0, Math.min(CanvasStack.MIP_QUIET_MS, CanvasStack.MIP_MAX_WAIT_MS - waited));
|
|
167
|
+
CanvasStack._mipTimer = setTimeout(() => {
|
|
168
|
+
CanvasStack._mipTimer = undefined;
|
|
169
|
+
requestAnimationFrame(CanvasStack.buildPendingMips);
|
|
170
|
+
}, delay);
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
private static buildPendingMips = () => {
|
|
174
|
+
const start = performance.now();
|
|
175
|
+
for (const stack of CanvasStack._pendingMips) {
|
|
176
|
+
CanvasStack._pendingMips.delete(stack);
|
|
177
|
+
if (stack.canvas) stack._buildMips();
|
|
178
|
+
if (performance.now() - start > CanvasStack.MIP_FRAME_BUDGET_MS) break;
|
|
179
|
+
}
|
|
180
|
+
if (CanvasStack._pendingMips.size > 0) requestAnimationFrame(CanvasStack.buildPendingMips);
|
|
181
|
+
};
|
|
182
|
+
|
|
183
|
+
private _buildMips() {
|
|
184
|
+
this._initMipCanvases();
|
|
185
|
+
if (this._texture) {
|
|
186
|
+
this._applyMipmaps(this._texture);
|
|
187
|
+
this._texture.needsUpdate = true;
|
|
188
|
+
CanvasStack.disposer.notifyChange(this._texture.uuid);
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
/** Custom levels once the chain is built (same level count as GPU generation, so the re-upload reuses the storage). */
|
|
193
|
+
private _applyMipmaps(texture: Texture) {
|
|
194
|
+
if (this._mipCanvases.length > 0) {
|
|
195
|
+
texture.generateMipmaps = false;
|
|
196
|
+
// mipmaps[i] is uploaded as WebGL level i. Level 0 must be the base
|
|
197
|
+
// canvas; levels 1..N are the custom-rendered smaller canvases.
|
|
198
|
+
texture.mipmaps = [this.canvas!, ...this._mipCanvases];
|
|
199
|
+
} else {
|
|
200
|
+
texture.generateMipmaps = true;
|
|
201
|
+
texture.mipmaps = [];
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
|
|
147
205
|
private _initMipCanvases() {
|
|
148
206
|
this._mipCanvases = [];
|
|
149
207
|
this._mipContexts = [];
|
|
@@ -233,33 +291,15 @@ export class CanvasStack implements IUpdatingCanvas {
|
|
|
233
291
|
|
|
234
292
|
if (!this._texture) {
|
|
235
293
|
const wrapper = getWebGlRendererInstance();
|
|
236
|
-
|
|
237
|
-
this.
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
this._texture.generateMipmaps = false;
|
|
246
|
-
// mipmaps[i] is uploaded as WebGL level i. Level 0 must be the base
|
|
247
|
-
// canvas; levels 1..N are the custom-rendered smaller canvases.
|
|
248
|
-
// Rendering text natively at each mip size is sharper than GPU box-filtering.
|
|
249
|
-
this._texture.mipmaps = [this.canvas, ...this._mipCanvases];
|
|
250
|
-
} else {
|
|
251
|
-
// WebGL1 only supports mipmaps on power-of-two textures, and these
|
|
252
|
-
// canvases are arbitrarily sized. Skip mipmap generation outside WebGL2.
|
|
253
|
-
this._texture = new Texture(
|
|
254
|
-
this.canvas,
|
|
255
|
-
UVMapping,
|
|
256
|
-
ClampToEdgeWrapping,
|
|
257
|
-
ClampToEdgeWrapping,
|
|
258
|
-
LinearFilter,
|
|
259
|
-
LinearMipmapLinearFilter,
|
|
260
|
-
);
|
|
261
|
-
this._texture.generateMipmaps = true;
|
|
262
|
-
}
|
|
294
|
+
this._texture = new Texture(
|
|
295
|
+
this.canvas,
|
|
296
|
+
UVMapping,
|
|
297
|
+
ClampToEdgeWrapping,
|
|
298
|
+
ClampToEdgeWrapping,
|
|
299
|
+
LinearFilter,
|
|
300
|
+
LinearMipmapLinearFilter,
|
|
301
|
+
);
|
|
302
|
+
this._applyMipmaps(this._texture);
|
|
263
303
|
this._texture.anisotropy = wrapper?.maxAnisotropy ?? 1;
|
|
264
304
|
this._texture.needsUpdate = true;
|
|
265
305
|
this._texture.colorSpace = SRGBColorSpace;
|
|
@@ -292,7 +332,12 @@ export class CanvasStack implements IUpdatingCanvas {
|
|
|
292
332
|
CanvasStack._liveStacks.delete(canvasStack);
|
|
293
333
|
});
|
|
294
334
|
|
|
295
|
-
|
|
335
|
+
/** True once the disposer has reclaimed this texture; anything still drawing with it renders blank. */
|
|
336
|
+
public static isDisposedTexture(texture: Texture) {
|
|
337
|
+
return !!_NOTHING_CANVAS && texture.source.data === _NOTHING_CANVAS;
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
public static materialDisposer =new ThreeDisposer<Material>((material) => {
|
|
296
341
|
material.dispose();
|
|
297
342
|
});
|
|
298
343
|
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { describe, expect, it } from "vitest";
|
|
2
|
+
import { buildTokenMap, parseMessageTokens, tokenizedMessageToText } from "./TokenizedText";
|
|
3
|
+
|
|
4
|
+
describe("tokenizedMessageToText", () => {
|
|
5
|
+
const tokenMap = buildTokenMap(
|
|
6
|
+
{ gold: { image: "gold.png", text: "gold" }, vp: { label: "VP", color: "#fff" }, iconOnly: { image: "x.png" } },
|
|
7
|
+
[{ playerId: "player0", name: "Josh", color: "#f00", imageUrl: "josh.png" }],
|
|
8
|
+
);
|
|
9
|
+
|
|
10
|
+
it("replaces player tokens with the player's name", () => {
|
|
11
|
+
expect(tokenizedMessageToText("Follow :player0:'s action", tokenMap)).toBe("Follow Josh's action");
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
it("prefers text, then label, and keeps unknown or image-only tokens as-is", () => {
|
|
15
|
+
expect(tokenizedMessageToText("Pay 2 :gold: for 1 :vp:", tokenMap)).toBe("Pay 2 gold for 1 VP");
|
|
16
|
+
expect(tokenizedMessageToText(":iconOnly: and :nope:", tokenMap)).toBe(":iconOnly: and :nope:");
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
it("gives the warning token a text form", () => {
|
|
20
|
+
expect(tokenizedMessageToText(":warning: Last round", tokenMap)).toBe("Warning: Last round");
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
it("leaves plain messages untouched", () => {
|
|
24
|
+
expect(tokenizedMessageToText("Waiting for turn to complete", tokenMap)).toBe("Waiting for turn to complete");
|
|
25
|
+
expect(tokenizedMessageToText("", tokenMap)).toBe("");
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
it("parses text runs and tokens in order", () => {
|
|
29
|
+
const parts = parseMessageTokens("a :player0: b", tokenMap);
|
|
30
|
+
expect(parts.map((p) => p.type)).toEqual(["text", "token", "text"]);
|
|
31
|
+
});
|
|
32
|
+
});
|