@pretty-chitty/core 1.1.1
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/LICENSE.md +51 -0
- package/README.md +152 -0
- package/dist/0e0a96423fd742218c61.woff2 +0 -0
- package/dist/1e28c9f184923aacc181.woff +0 -0
- package/dist/37f3b2ddcbe588b2aaa5.jpg +0 -0
- package/dist/3f0fb9058a03e14ad2fa.jpg +0 -0
- package/dist/4482e08504d544757971.woff2 +0 -0
- package/dist/5212361bfd059a27e2da.woff2 +0 -0
- package/dist/699b459f21e39ca4b8df.woff2 +0 -0
- package/dist/7e339dfbea59fe54f2e3.png +0 -0
- package/dist/a3e6d4ebd8f859f0f1dc.woff +0 -0
- package/dist/b8b0d3bc0d26444e4a5a.woff2 +0 -0
- package/dist/bce9a6fcc5b3da9a086a.woff +0 -0
- package/dist/components/ActionLogDisplay.d.ts +4 -0
- package/dist/components/ActionLogDisplay.d.ts.map +1 -0
- package/dist/components/ActionLogDisplay.js +144 -0
- package/dist/components/ActionLogDisplay.js.map +1 -0
- package/dist/components/ActionLogHistory.d.ts +6 -0
- package/dist/components/ActionLogHistory.d.ts.map +1 -0
- package/dist/components/ActionLogHistory.js +81 -0
- package/dist/components/ActionLogHistory.js.map +1 -0
- package/dist/components/ActionLogHistoryDisplay.d.ts +2 -0
- package/dist/components/ActionLogHistoryDisplay.d.ts.map +1 -0
- package/dist/components/ActionLogHistoryDisplay.js +17 -0
- package/dist/components/ActionLogHistoryDisplay.js.map +1 -0
- package/dist/components/ActionLogSidebar.d.ts +2 -0
- package/dist/components/ActionLogSidebar.d.ts.map +1 -0
- package/dist/components/ActionLogSidebar.js +9 -0
- package/dist/components/ActionLogSidebar.js.map +1 -0
- package/dist/components/BottomBar.d.ts +2 -0
- package/dist/components/BottomBar.d.ts.map +1 -0
- package/dist/components/BottomBar.js +33 -0
- package/dist/components/BottomBar.js.map +1 -0
- package/dist/components/BottomBarBreak.d.ts +2 -0
- package/dist/components/BottomBarBreak.d.ts.map +1 -0
- package/dist/components/BottomBarBreak.js +8 -0
- package/dist/components/BottomBarBreak.js.map +1 -0
- package/dist/components/BottomBarButton.d.ts +16 -0
- package/dist/components/BottomBarButton.d.ts.map +1 -0
- package/dist/components/BottomBarButton.js +123 -0
- package/dist/components/BottomBarButton.js.map +1 -0
- package/dist/components/CanvasLibraryViewer.d.ts +8 -0
- package/dist/components/CanvasLibraryViewer.d.ts.map +1 -0
- package/dist/components/CanvasLibraryViewer.js +29 -0
- package/dist/components/CanvasLibraryViewer.js.map +1 -0
- package/dist/components/ChitLibraryViewer.d.ts +8 -0
- package/dist/components/ChitLibraryViewer.d.ts.map +1 -0
- package/dist/components/ChitLibraryViewer.js +101 -0
- package/dist/components/ChitLibraryViewer.js.map +1 -0
- package/dist/components/ClientTrustMatchViewer.d.ts +11 -0
- package/dist/components/ClientTrustMatchViewer.d.ts.map +1 -0
- package/dist/components/ClientTrustMatchViewer.js +53 -0
- package/dist/components/ClientTrustMatchViewer.js.map +1 -0
- package/dist/components/ContextGalleryDisplay.d.ts +4 -0
- package/dist/components/ContextGalleryDisplay.d.ts.map +1 -0
- package/dist/components/ContextGalleryDisplay.js +49 -0
- package/dist/components/ContextGalleryDisplay.js.map +1 -0
- package/dist/components/GalleryDisplay.d.ts +2 -0
- package/dist/components/GalleryDisplay.d.ts.map +1 -0
- package/dist/components/GalleryDisplay.js +42 -0
- package/dist/components/GalleryDisplay.js.map +1 -0
- package/dist/components/GalleryPlayground.d.ts +14 -0
- package/dist/components/GalleryPlayground.d.ts.map +1 -0
- package/dist/components/GalleryPlayground.js +36 -0
- package/dist/components/GalleryPlayground.js.map +1 -0
- package/dist/components/GalleryViewer.d.ts +48 -0
- package/dist/components/GalleryViewer.d.ts.map +1 -0
- package/dist/components/GalleryViewer.js +567 -0
- package/dist/components/GalleryViewer.js.map +1 -0
- package/dist/components/GameDesigner.d.ts +5 -0
- package/dist/components/GameDesigner.d.ts.map +1 -0
- package/dist/components/GameDesigner.js +14 -0
- package/dist/components/GameDesigner.js.map +1 -0
- package/dist/components/GameDialog.d.ts +7 -0
- package/dist/components/GameDialog.d.ts.map +1 -0
- package/dist/components/GameDialog.js +24 -0
- package/dist/components/GameDialog.js.map +1 -0
- package/dist/components/GameModalBackdrop.d.ts +10 -0
- package/dist/components/GameModalBackdrop.d.ts.map +1 -0
- package/dist/components/GameModalBackdrop.js +33 -0
- package/dist/components/GameModalBackdrop.js.map +1 -0
- package/dist/components/GameModalDialog.d.ts +11 -0
- package/dist/components/GameModalDialog.d.ts.map +1 -0
- package/dist/components/GameModalDialog.js +42 -0
- package/dist/components/GameModalDialog.js.map +1 -0
- package/dist/components/LiveButton.d.ts +4 -0
- package/dist/components/LiveButton.d.ts.map +1 -0
- package/dist/components/LiveButton.js +17 -0
- package/dist/components/LiveButton.js.map +1 -0
- package/dist/components/MatchEndDisplay.d.ts +2 -0
- package/dist/components/MatchEndDisplay.d.ts.map +1 -0
- package/dist/components/MatchEndDisplay.js +67 -0
- package/dist/components/MatchEndDisplay.js.map +1 -0
- package/dist/components/MatchViewer.d.ts +5 -0
- package/dist/components/MatchViewer.d.ts.map +1 -0
- package/dist/components/MatchViewer.js +59 -0
- package/dist/components/MatchViewer.js.map +1 -0
- package/dist/components/ObjectWithPropsEditor.d.ts +5 -0
- package/dist/components/ObjectWithPropsEditor.d.ts.map +1 -0
- package/dist/components/ObjectWithPropsEditor.js +88 -0
- package/dist/components/ObjectWithPropsEditor.js.map +1 -0
- package/dist/components/Panel/MultiPanel.d.ts +13 -0
- package/dist/components/Panel/MultiPanel.d.ts.map +1 -0
- package/dist/components/Panel/MultiPanel.js +196 -0
- package/dist/components/Panel/MultiPanel.js.map +1 -0
- package/dist/components/Panel/PanelContents.d.ts +27 -0
- package/dist/components/Panel/PanelContents.d.ts.map +1 -0
- package/dist/components/Panel/PanelContents.js +202 -0
- package/dist/components/Panel/PanelContents.js.map +1 -0
- package/dist/components/Panel/PanelTabStack.d.ts +9 -0
- package/dist/components/Panel/PanelTabStack.d.ts.map +1 -0
- package/dist/components/Panel/PanelTabStack.js +56 -0
- package/dist/components/Panel/PanelTabStack.js.map +1 -0
- package/dist/components/Panel/SinglePanel.d.ts +13 -0
- package/dist/components/Panel/SinglePanel.d.ts.map +1 -0
- package/dist/components/Panel/SinglePanel.js +44 -0
- package/dist/components/Panel/SinglePanel.js.map +1 -0
- package/dist/components/Panel/ViewerWrapper.d.ts +17 -0
- package/dist/components/Panel/ViewerWrapper.d.ts.map +1 -0
- package/dist/components/Panel/ViewerWrapper.js +70 -0
- package/dist/components/Panel/ViewerWrapper.js.map +1 -0
- package/dist/components/Panel/ViewerZoomControls.d.ts +8 -0
- package/dist/components/Panel/ViewerZoomControls.d.ts.map +1 -0
- package/dist/components/Panel/ViewerZoomControls.js +152 -0
- package/dist/components/Panel/ViewerZoomControls.js.map +1 -0
- package/dist/components/Panel/util.d.ts +3 -0
- package/dist/components/Panel/util.d.ts.map +1 -0
- package/dist/components/Panel/util.js +5 -0
- package/dist/components/Panel/util.js.map +1 -0
- package/dist/components/PanelSpark.d.ts +7 -0
- package/dist/components/PanelSpark.d.ts.map +1 -0
- package/dist/components/PanelSpark.js +84 -0
- package/dist/components/PanelSpark.js.map +1 -0
- package/dist/components/PersistentCanvas.d.ts +12 -0
- package/dist/components/PersistentCanvas.d.ts.map +1 -0
- package/dist/components/PersistentCanvas.js +44 -0
- package/dist/components/PersistentCanvas.js.map +1 -0
- package/dist/components/PlayerImage.d.ts +9 -0
- package/dist/components/PlayerImage.d.ts.map +1 -0
- package/dist/components/PlayerImage.js +21 -0
- package/dist/components/PlayerImage.js.map +1 -0
- package/dist/components/Playground.d.ts +9 -0
- package/dist/components/Playground.d.ts.map +1 -0
- package/dist/components/Playground.js +129 -0
- package/dist/components/Playground.js.map +1 -0
- package/dist/components/PromptControls.d.ts +4 -0
- package/dist/components/PromptControls.d.ts.map +1 -0
- package/dist/components/PromptControls.js +87 -0
- package/dist/components/PromptControls.js.map +1 -0
- package/dist/components/SelectableItemAndStage.d.ts +8 -0
- package/dist/components/SelectableItemAndStage.d.ts.map +1 -0
- package/dist/components/SelectableItemAndStage.js +16 -0
- package/dist/components/SelectableItemAndStage.js.map +1 -0
- package/dist/components/SettingsDisplay.d.ts +2 -0
- package/dist/components/SettingsDisplay.d.ts.map +1 -0
- package/dist/components/SettingsDisplay.js +62 -0
- package/dist/components/SettingsDisplay.js.map +1 -0
- package/dist/components/SparkLineChart.d.ts +21 -0
- package/dist/components/SparkLineChart.d.ts.map +1 -0
- package/dist/components/SparkLineChart.js +143 -0
- package/dist/components/SparkLineChart.js.map +1 -0
- package/dist/components/StageAndEditor.d.ts +5 -0
- package/dist/components/StageAndEditor.d.ts.map +1 -0
- package/dist/components/StageAndEditor.js +12 -0
- package/dist/components/StageAndEditor.js.map +1 -0
- package/dist/components/TimeControlBar.d.ts +5 -0
- package/dist/components/TimeControlBar.d.ts.map +1 -0
- package/dist/components/TimeControlBar.js +38 -0
- package/dist/components/TimeControlBar.js.map +1 -0
- package/dist/components/TokenizedMessage.d.ts +13 -0
- package/dist/components/TokenizedMessage.d.ts.map +1 -0
- package/dist/components/TokenizedMessage.js +102 -0
- package/dist/components/TokenizedMessage.js.map +1 -0
- package/dist/components/TopBar.d.ts +4 -0
- package/dist/components/TopBar.d.ts.map +1 -0
- package/dist/components/TopBar.js +47 -0
- package/dist/components/TopBar.js.map +1 -0
- package/dist/components/TopBarDropdown.d.ts +6 -0
- package/dist/components/TopBarDropdown.d.ts.map +1 -0
- package/dist/components/TopBarDropdown.js +69 -0
- package/dist/components/TopBarDropdown.js.map +1 -0
- package/dist/components/TopBarPlayers.d.ts +2 -0
- package/dist/components/TopBarPlayers.d.ts.map +1 -0
- package/dist/components/TopBarPlayers.js +70 -0
- package/dist/components/TopBarPlayers.js.map +1 -0
- package/dist/components/UpdatingCanvasImage.d.ts +7 -0
- package/dist/components/UpdatingCanvasImage.d.ts.map +1 -0
- package/dist/components/UpdatingCanvasImage.js +22 -0
- package/dist/components/UpdatingCanvasImage.js.map +1 -0
- package/dist/components/UpdatingCanvasViewer.d.ts +7 -0
- package/dist/components/UpdatingCanvasViewer.d.ts.map +1 -0
- package/dist/components/UpdatingCanvasViewer.js +50 -0
- package/dist/components/UpdatingCanvasViewer.js.map +1 -0
- package/dist/components/Viewer.d.ts +16 -0
- package/dist/components/Viewer.d.ts.map +1 -0
- package/dist/components/Viewer.js +289 -0
- package/dist/components/Viewer.js.map +1 -0
- package/dist/components/index.d.ts +1 -0
- package/dist/components/index.d.ts.map +1 -0
- package/dist/components/index.js +2 -0
- package/dist/components/index.js.map +1 -0
- package/dist/e085acb5e467d8e85d21.woff +0 -0
- package/dist/e65dff62134b8879e792.woff +0 -0
- package/dist/game/Chit.d.ts +64 -0
- package/dist/game/Chit.d.ts.map +1 -0
- package/dist/game/Chit.js +524 -0
- package/dist/game/Chit.js.map +1 -0
- package/dist/game/ClientTimeState.d.ts +16 -0
- package/dist/game/ClientTimeState.d.ts.map +1 -0
- package/dist/game/ClientTimeState.js +38 -0
- package/dist/game/ClientTimeState.js.map +1 -0
- package/dist/game/ClockDetails.d.ts +9 -0
- package/dist/game/ClockDetails.d.ts.map +1 -0
- package/dist/game/ClockDetails.js +19 -0
- package/dist/game/ClockDetails.js.map +1 -0
- package/dist/game/Connection.d.ts +26 -0
- package/dist/game/Connection.d.ts.map +1 -0
- package/dist/game/Connection.js +99 -0
- package/dist/game/Connection.js.map +1 -0
- package/dist/game/ConnectionObject.d.ts +7 -0
- package/dist/game/ConnectionObject.d.ts.map +1 -0
- package/dist/game/ConnectionObject.js +16 -0
- package/dist/game/ConnectionObject.js.map +1 -0
- package/dist/game/ConnectionTransport.d.ts +17 -0
- package/dist/game/ConnectionTransport.d.ts.map +1 -0
- package/dist/game/ConnectionTransport.js +39 -0
- package/dist/game/ConnectionTransport.js.map +1 -0
- package/dist/game/DropdownChit.d.ts +7 -0
- package/dist/game/DropdownChit.d.ts.map +1 -0
- package/dist/game/DropdownChit.js +29 -0
- package/dist/game/DropdownChit.js.map +1 -0
- package/dist/game/GalleryItemChitChildrenSource.d.ts +12 -0
- package/dist/game/GalleryItemChitChildrenSource.d.ts.map +1 -0
- package/dist/game/GalleryItemChitChildrenSource.js +25 -0
- package/dist/game/GalleryItemChitChildrenSource.js.map +1 -0
- package/dist/game/GalleryItemRawSource.d.ts +9 -0
- package/dist/game/GalleryItemRawSource.d.ts.map +1 -0
- package/dist/game/GalleryItemRawSource.js +13 -0
- package/dist/game/GalleryItemRawSource.js.map +1 -0
- package/dist/game/Game.d.ts +51 -0
- package/dist/game/Game.d.ts.map +1 -0
- package/dist/game/Game.js +2 -0
- package/dist/game/Game.js.map +1 -0
- package/dist/game/GameBagChit.d.ts +16 -0
- package/dist/game/GameBagChit.d.ts.map +1 -0
- package/dist/game/GameBagChit.js +51 -0
- package/dist/game/GameBagChit.js.map +1 -0
- package/dist/game/GameButton.d.ts +30 -0
- package/dist/game/GameButton.d.ts.map +1 -0
- package/dist/game/GameButton.js +115 -0
- package/dist/game/GameButton.js.map +1 -0
- package/dist/game/GameDeckChit.d.ts +23 -0
- package/dist/game/GameDeckChit.d.ts.map +1 -0
- package/dist/game/GameDeckChit.js +79 -0
- package/dist/game/GameDeckChit.js.map +1 -0
- package/dist/game/GameTheme.d.ts +75 -0
- package/dist/game/GameTheme.d.ts.map +1 -0
- package/dist/game/GameTheme.js +103 -0
- package/dist/game/GameTheme.js.map +1 -0
- package/dist/game/Match.d.ts +34 -0
- package/dist/game/Match.d.ts.map +1 -0
- package/dist/game/Match.js +151 -0
- package/dist/game/Match.js.map +1 -0
- package/dist/game/MatchConnection.d.ts +8 -0
- package/dist/game/MatchConnection.d.ts.map +1 -0
- package/dist/game/MatchConnection.js +6 -0
- package/dist/game/MatchConnection.js.map +1 -0
- package/dist/game/MatchStorage.d.ts +17 -0
- package/dist/game/MatchStorage.d.ts.map +1 -0
- package/dist/game/MatchStorage.js +32 -0
- package/dist/game/MatchStorage.js.map +1 -0
- package/dist/game/ModalState.d.ts +9 -0
- package/dist/game/ModalState.d.ts.map +1 -0
- package/dist/game/ModalState.js +27 -0
- package/dist/game/ModalState.js.map +1 -0
- package/dist/game/OrderedOutlet.d.ts +50 -0
- package/dist/game/OrderedOutlet.d.ts.map +1 -0
- package/dist/game/OrderedOutlet.js +164 -0
- package/dist/game/OrderedOutlet.js.map +1 -0
- package/dist/game/Pick.d.ts +26 -0
- package/dist/game/Pick.d.ts.map +1 -0
- package/dist/game/Pick.js +239 -0
- package/dist/game/Pick.js.map +1 -0
- package/dist/game/PlayerChit.d.ts +16 -0
- package/dist/game/PlayerChit.d.ts.map +1 -0
- package/dist/game/PlayerChit.js +56 -0
- package/dist/game/PlayerChit.js.map +1 -0
- package/dist/game/PlayerInfo.d.ts +12 -0
- package/dist/game/PlayerInfo.d.ts.map +1 -0
- package/dist/game/PlayerInfo.js +20 -0
- package/dist/game/PlayerInfo.js.map +1 -0
- package/dist/game/PlayerPromptStatusChit.d.ts +5 -0
- package/dist/game/PlayerPromptStatusChit.d.ts.map +1 -0
- package/dist/game/PlayerPromptStatusChit.js +35 -0
- package/dist/game/PlayerPromptStatusChit.js.map +1 -0
- package/dist/game/Prompt.d.ts +94 -0
- package/dist/game/Prompt.d.ts.map +1 -0
- package/dist/game/Prompt.js +229 -0
- package/dist/game/Prompt.js.map +1 -0
- package/dist/game/RootChit.d.ts +15 -0
- package/dist/game/RootChit.d.ts.map +1 -0
- package/dist/game/RootChit.js +62 -0
- package/dist/game/RootChit.js.map +1 -0
- package/dist/game/SparkChit.d.ts +27 -0
- package/dist/game/SparkChit.d.ts.map +1 -0
- package/dist/game/SparkChit.js +97 -0
- package/dist/game/SparkChit.js.map +1 -0
- package/dist/game/StaticChitTypeRegistry.d.ts +5 -0
- package/dist/game/StaticChitTypeRegistry.d.ts.map +1 -0
- package/dist/game/StaticChitTypeRegistry.js +3 -0
- package/dist/game/StaticChitTypeRegistry.js.map +1 -0
- package/dist/game/Turn.d.ts +169 -0
- package/dist/game/Turn.d.ts.map +1 -0
- package/dist/game/Turn.js +1031 -0
- package/dist/game/Turn.js.map +1 -0
- package/dist/game/TurnState.d.ts +30 -0
- package/dist/game/TurnState.d.ts.map +1 -0
- package/dist/game/TurnState.js +170 -0
- package/dist/game/TurnState.js.map +1 -0
- package/dist/game/clientTransport/ClientPrompts.d.ts +23 -0
- package/dist/game/clientTransport/ClientPrompts.d.ts.map +1 -0
- package/dist/game/clientTransport/ClientPrompts.js +85 -0
- package/dist/game/clientTransport/ClientPrompts.js.map +1 -0
- package/dist/game/clientTransport/ClientStatus.d.ts +19 -0
- package/dist/game/clientTransport/ClientStatus.d.ts.map +1 -0
- package/dist/game/clientTransport/ClientStatus.js +25 -0
- package/dist/game/clientTransport/ClientStatus.js.map +1 -0
- package/dist/game/clientTransport/ClientTime.d.ts +42 -0
- package/dist/game/clientTransport/ClientTime.d.ts.map +1 -0
- package/dist/game/clientTransport/ClientTime.js +197 -0
- package/dist/game/clientTransport/ClientTime.js.map +1 -0
- package/dist/game/index.d.ts +1 -0
- package/dist/game/index.d.ts.map +1 -0
- package/dist/game/index.js +2 -0
- package/dist/game/index.js.map +1 -0
- package/dist/game/serverTransport/ServerPrompts.d.ts +17 -0
- package/dist/game/serverTransport/ServerPrompts.d.ts.map +1 -0
- package/dist/game/serverTransport/ServerPrompts.js +51 -0
- package/dist/game/serverTransport/ServerPrompts.js.map +1 -0
- package/dist/game/serverTransport/ServerStatus.d.ts +12 -0
- package/dist/game/serverTransport/ServerStatus.d.ts.map +1 -0
- package/dist/game/serverTransport/ServerStatus.js +16 -0
- package/dist/game/serverTransport/ServerStatus.js.map +1 -0
- package/dist/game/serverTransport/ServerTime.d.ts +39 -0
- package/dist/game/serverTransport/ServerTime.d.ts.map +1 -0
- package/dist/game/serverTransport/ServerTime.js +57 -0
- package/dist/game/serverTransport/ServerTime.js.map +1 -0
- package/dist/hooks/useChits.d.ts +4 -0
- package/dist/hooks/useChits.d.ts.map +1 -0
- package/dist/hooks/useChits.js +24 -0
- package/dist/hooks/useChits.js.map +1 -0
- package/dist/hooks/useConnection.d.ts +8 -0
- package/dist/hooks/useConnection.d.ts.map +1 -0
- package/dist/hooks/useConnection.js +14 -0
- package/dist/hooks/useConnection.js.map +1 -0
- package/dist/hooks/useEventChannelState.d.ts +4 -0
- package/dist/hooks/useEventChannelState.d.ts.map +1 -0
- package/dist/hooks/useEventChannelState.js +25 -0
- package/dist/hooks/useEventChannelState.js.map +1 -0
- package/dist/hooks/useGame.d.ts +8 -0
- package/dist/hooks/useGame.d.ts.map +1 -0
- package/dist/hooks/useGame.js +14 -0
- package/dist/hooks/useGame.js.map +1 -0
- package/dist/hooks/useGameTheme.d.ts +8 -0
- package/dist/hooks/useGameTheme.d.ts.map +1 -0
- package/dist/hooks/useGameTheme.js +11 -0
- package/dist/hooks/useGameTheme.js.map +1 -0
- package/dist/hooks/useModalState.d.ts +7 -0
- package/dist/hooks/useModalState.d.ts.map +1 -0
- package/dist/hooks/useModalState.js +12 -0
- package/dist/hooks/useModalState.js.map +1 -0
- package/dist/hooks/usePanelPositioning.d.ts +22 -0
- package/dist/hooks/usePanelPositioning.d.ts.map +1 -0
- package/dist/hooks/usePanelPositioning.js +10 -0
- package/dist/hooks/usePanelPositioning.js.map +1 -0
- package/dist/hooks/usePanelScale.d.ts +7 -0
- package/dist/hooks/usePanelScale.d.ts.map +1 -0
- package/dist/hooks/usePanelScale.js +22 -0
- package/dist/hooks/usePanelScale.js.map +1 -0
- package/dist/hooks/usePanelStates.d.ts +9 -0
- package/dist/hooks/usePanelStates.d.ts.map +1 -0
- package/dist/hooks/usePanelStates.js +19 -0
- package/dist/hooks/usePanelStates.js.map +1 -0
- package/dist/hooks/usePlayer.d.ts +7 -0
- package/dist/hooks/usePlayer.d.ts.map +1 -0
- package/dist/hooks/usePlayer.js +14 -0
- package/dist/hooks/usePlayer.js.map +1 -0
- package/dist/hooks/useSmartDebouncedState.d.ts +27 -0
- package/dist/hooks/useSmartDebouncedState.d.ts.map +1 -0
- package/dist/hooks/useSmartDebouncedState.js +109 -0
- package/dist/hooks/useSmartDebouncedState.js.map +1 -0
- package/dist/hooks/useTimeController.d.ts +22 -0
- package/dist/hooks/useTimeController.d.ts.map +1 -0
- package/dist/hooks/useTimeController.js +89 -0
- package/dist/hooks/useTimeController.js.map +1 -0
- package/dist/hooks/useTokenMap.d.ts +5 -0
- package/dist/hooks/useTokenMap.d.ts.map +1 -0
- package/dist/hooks/useTokenMap.js +16 -0
- package/dist/hooks/useTokenMap.js.map +1 -0
- package/dist/hooks/useWebGlRenderer.d.ts +34 -0
- package/dist/hooks/useWebGlRenderer.d.ts.map +1 -0
- package/dist/hooks/useWebGlRenderer.js +167 -0
- package/dist/hooks/useWebGlRenderer.js.map +1 -0
- package/dist/index.d.ts +97 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.html +12 -0
- package/dist/index.js +62 -0
- package/dist/index.js.map +1 -0
- package/dist/pretty-chitty.js +190767 -0
- package/dist/pretty-chitty.js.map +1 -0
- package/dist/rendering/CameraSpec.d.ts +22 -0
- package/dist/rendering/CameraSpec.d.ts.map +1 -0
- package/dist/rendering/CameraSpec.js +25 -0
- package/dist/rendering/CameraSpec.js.map +1 -0
- package/dist/rendering/CameraWrapperPerspective.d.ts +44 -0
- package/dist/rendering/CameraWrapperPerspective.d.ts.map +1 -0
- package/dist/rendering/CameraWrapperPerspective.js +481 -0
- package/dist/rendering/CameraWrapperPerspective.js.map +1 -0
- package/dist/rendering/ChitGalleryItemInstance.d.ts +31 -0
- package/dist/rendering/ChitGalleryItemInstance.d.ts.map +1 -0
- package/dist/rendering/ChitGalleryItemInstance.js +75 -0
- package/dist/rendering/ChitGalleryItemInstance.js.map +1 -0
- package/dist/rendering/ChitRenderInstance.d.ts +104 -0
- package/dist/rendering/ChitRenderInstance.d.ts.map +1 -0
- package/dist/rendering/ChitRenderInstance.js +902 -0
- package/dist/rendering/ChitRenderInstance.js.map +1 -0
- package/dist/rendering/ChitRenderSpec.d.ts +80 -0
- package/dist/rendering/ChitRenderSpec.d.ts.map +1 -0
- package/dist/rendering/ChitRenderSpec.js +152 -0
- package/dist/rendering/ChitRenderSpec.js.map +1 -0
- package/dist/rendering/HighlightSpec.d.ts +6 -0
- package/dist/rendering/HighlightSpec.d.ts.map +1 -0
- package/dist/rendering/HighlightSpec.js +6 -0
- package/dist/rendering/HighlightSpec.js.map +1 -0
- package/dist/rendering/LightSpec.d.ts +17 -0
- package/dist/rendering/LightSpec.d.ts.map +1 -0
- package/dist/rendering/LightSpec.js +37 -0
- package/dist/rendering/LightSpec.js.map +1 -0
- package/dist/rendering/LightWrapper.d.ts +19 -0
- package/dist/rendering/LightWrapper.d.ts.map +1 -0
- package/dist/rendering/LightWrapper.js +114 -0
- package/dist/rendering/LightWrapper.js.map +1 -0
- package/dist/rendering/RootChitRenderInstance.d.ts +81 -0
- package/dist/rendering/RootChitRenderInstance.d.ts.map +1 -0
- package/dist/rendering/RootChitRenderInstance.js +372 -0
- package/dist/rendering/RootChitRenderInstance.js.map +1 -0
- package/dist/rendering/Splay.d.ts +23 -0
- package/dist/rendering/Splay.d.ts.map +1 -0
- package/dist/rendering/Splay.js +89 -0
- package/dist/rendering/Splay.js.map +1 -0
- package/dist/rendering/SplayCounter.d.ts +19 -0
- package/dist/rendering/SplayCounter.d.ts.map +1 -0
- package/dist/rendering/SplayCounter.js +18 -0
- package/dist/rendering/SplayCounter.js.map +1 -0
- package/dist/rendering/TextureReferenceCounter.d.ts +12 -0
- package/dist/rendering/TextureReferenceCounter.d.ts.map +1 -0
- package/dist/rendering/TextureReferenceCounter.js +76 -0
- package/dist/rendering/TextureReferenceCounter.js.map +1 -0
- package/dist/rendering/index.d.ts +1 -0
- package/dist/rendering/index.d.ts.map +1 -0
- package/dist/rendering/index.js +2 -0
- package/dist/rendering/index.js.map +1 -0
- package/dist/rendering/outline/DepthVisualizationPass.d.ts +12 -0
- package/dist/rendering/outline/DepthVisualizationPass.d.ts.map +1 -0
- package/dist/rendering/outline/DepthVisualizationPass.js +93 -0
- package/dist/rendering/outline/DepthVisualizationPass.js.map +1 -0
- package/dist/rendering/outline/EffectComposer.d.ts +24 -0
- package/dist/rendering/outline/EffectComposer.d.ts.map +1 -0
- package/dist/rendering/outline/EffectComposer.js +118 -0
- package/dist/rendering/outline/EffectComposer.js.map +1 -0
- package/dist/rendering/outline/FullScreenQuad.d.ts +12 -0
- package/dist/rendering/outline/FullScreenQuad.d.ts.map +1 -0
- package/dist/rendering/outline/FullScreenQuad.js +21 -0
- package/dist/rendering/outline/FullScreenQuad.js.map +1 -0
- package/dist/rendering/outline/IDBasedOutlinePass.d.ts +49 -0
- package/dist/rendering/outline/IDBasedOutlinePass.d.ts.map +1 -0
- package/dist/rendering/outline/IDBasedOutlinePass.js +597 -0
- package/dist/rendering/outline/IDBasedOutlinePass.js.map +1 -0
- package/dist/rendering/outline/OutputPass.d.ts +13 -0
- package/dist/rendering/outline/OutputPass.d.ts.map +1 -0
- package/dist/rendering/outline/OutputPass.js +57 -0
- package/dist/rendering/outline/OutputPass.js.map +1 -0
- package/dist/rendering/outline/RenderPass.d.ts +13 -0
- package/dist/rendering/outline/RenderPass.d.ts.map +1 -0
- package/dist/rendering/outline/RenderPass.js +54 -0
- package/dist/rendering/outline/RenderPass.js.map +1 -0
- package/dist/rendering/outline/SceneWrapper.d.ts +39 -0
- package/dist/rendering/outline/SceneWrapper.d.ts.map +1 -0
- package/dist/rendering/outline/SceneWrapper.js +522 -0
- package/dist/rendering/outline/SceneWrapper.js.map +1 -0
- package/dist/rendering/outline/ShaderPass.d.ts +12 -0
- package/dist/rendering/outline/ShaderPass.d.ts.map +1 -0
- package/dist/rendering/outline/ShaderPass.js +43 -0
- package/dist/rendering/outline/ShaderPass.js.map +1 -0
- package/dist/rendering/outline/index.d.ts +8 -0
- package/dist/rendering/outline/index.d.ts.map +1 -0
- package/dist/rendering/outline/index.js +8 -0
- package/dist/rendering/outline/index.js.map +1 -0
- package/dist/rendering/outline/passes/DebugIDMappingPass.d.ts +20 -0
- package/dist/rendering/outline/passes/DebugIDMappingPass.d.ts.map +1 -0
- package/dist/rendering/outline/passes/DebugIDMappingPass.js +131 -0
- package/dist/rendering/outline/passes/DebugIDMappingPass.js.map +1 -0
- package/dist/rendering/outline/passes/DepthOcclusionPass.d.ts +24 -0
- package/dist/rendering/outline/passes/DepthOcclusionPass.d.ts.map +1 -0
- package/dist/rendering/outline/passes/DepthOcclusionPass.js +95 -0
- package/dist/rendering/outline/passes/DepthOcclusionPass.js.map +1 -0
- package/dist/rendering/outline/passes/InterMeshEdgeDetectionPass.d.ts +32 -0
- package/dist/rendering/outline/passes/InterMeshEdgeDetectionPass.d.ts.map +1 -0
- package/dist/rendering/outline/passes/InterMeshEdgeDetectionPass.js +208 -0
- package/dist/rendering/outline/passes/InterMeshEdgeDetectionPass.js.map +1 -0
- package/dist/rendering/outline/shaders.d.ts +20 -0
- package/dist/rendering/outline/shaders.d.ts.map +1 -0
- package/dist/rendering/outline/shaders.js +103 -0
- package/dist/rendering/outline/shaders.js.map +1 -0
- package/dist/rendering/outline/types.d.ts +14 -0
- package/dist/rendering/outline/types.d.ts.map +1 -0
- package/dist/rendering/outline/types.js +16 -0
- package/dist/rendering/outline/types.js.map +1 -0
- package/dist/utilities/Annotations.d.ts +60 -0
- package/dist/utilities/Annotations.d.ts.map +1 -0
- package/dist/utilities/Annotations.js +171 -0
- package/dist/utilities/Annotations.js.map +1 -0
- package/dist/utilities/BaseTable.d.ts +8 -0
- package/dist/utilities/BaseTable.d.ts.map +1 -0
- package/dist/utilities/BaseTable.js +35 -0
- package/dist/utilities/BaseTable.js.map +1 -0
- package/dist/utilities/BboxUtils.d.ts +3 -0
- package/dist/utilities/BboxUtils.d.ts.map +1 -0
- package/dist/utilities/BboxUtils.js +19 -0
- package/dist/utilities/BboxUtils.js.map +1 -0
- package/dist/utilities/CanvasStack/CanvasOperations.d.ts +140 -0
- package/dist/utilities/CanvasStack/CanvasOperations.d.ts.map +1 -0
- package/dist/utilities/CanvasStack/CanvasOperations.js +403 -0
- package/dist/utilities/CanvasStack/CanvasOperations.js.map +1 -0
- package/dist/utilities/CanvasStack/CanvasStack.d.ts +42 -0
- package/dist/utilities/CanvasStack/CanvasStack.d.ts.map +1 -0
- package/dist/utilities/CanvasStack/CanvasStack.js +128 -0
- package/dist/utilities/CanvasStack/CanvasStack.js.map +1 -0
- package/dist/utilities/CanvasStack/IconCanvas.d.ts +10 -0
- package/dist/utilities/CanvasStack/IconCanvas.d.ts.map +1 -0
- package/dist/utilities/CanvasStack/IconCanvas.js +15 -0
- package/dist/utilities/CanvasStack/IconCanvas.js.map +1 -0
- package/dist/utilities/CanvasStack/ImageCache.d.ts +8 -0
- package/dist/utilities/CanvasStack/ImageCache.d.ts.map +1 -0
- package/dist/utilities/CanvasStack/ImageCache.js +29 -0
- package/dist/utilities/CanvasStack/ImageCache.js.map +1 -0
- package/dist/utilities/CanvasStack/ImageColorOverlayer.d.ts +2 -0
- package/dist/utilities/CanvasStack/ImageColorOverlayer.d.ts.map +1 -0
- package/dist/utilities/CanvasStack/ImageColorOverlayer.js +31 -0
- package/dist/utilities/CanvasStack/ImageColorOverlayer.js.map +1 -0
- package/dist/utilities/CanvasStack/PlayerCanvas.d.ts +10 -0
- package/dist/utilities/CanvasStack/PlayerCanvas.d.ts.map +1 -0
- package/dist/utilities/CanvasStack/PlayerCanvas.js +15 -0
- package/dist/utilities/CanvasStack/PlayerCanvas.js.map +1 -0
- package/dist/utilities/CanvasStack/ReactCanvas.d.ts +133 -0
- package/dist/utilities/CanvasStack/ReactCanvas.d.ts.map +1 -0
- package/dist/utilities/CanvasStack/ReactCanvas.js +161 -0
- package/dist/utilities/CanvasStack/ReactCanvas.js.map +1 -0
- package/dist/utilities/CanvasStack/RichTextRenderer.d.ts +63 -0
- package/dist/utilities/CanvasStack/RichTextRenderer.d.ts.map +1 -0
- package/dist/utilities/CanvasStack/RichTextRenderer.js +523 -0
- package/dist/utilities/CanvasStack/RichTextRenderer.js.map +1 -0
- package/dist/utilities/CardMesh.d.ts +17 -0
- package/dist/utilities/CardMesh.d.ts.map +1 -0
- package/dist/utilities/CardMesh.js +44 -0
- package/dist/utilities/CardMesh.js.map +1 -0
- package/dist/utilities/Dice.d.ts +24 -0
- package/dist/utilities/Dice.d.ts.map +1 -0
- package/dist/utilities/Dice.js +148 -0
- package/dist/utilities/Dice.js.map +1 -0
- package/dist/utilities/EventChannel.d.ts +13 -0
- package/dist/utilities/EventChannel.d.ts.map +1 -0
- package/dist/utilities/EventChannel.js +47 -0
- package/dist/utilities/EventChannel.js.map +1 -0
- package/dist/utilities/GalleryItemConversion.d.ts +4 -0
- package/dist/utilities/GalleryItemConversion.d.ts.map +1 -0
- package/dist/utilities/GalleryItemConversion.js +28 -0
- package/dist/utilities/GalleryItemConversion.js.map +1 -0
- package/dist/utilities/IUpdatingCanvas.d.ts +19 -0
- package/dist/utilities/IUpdatingCanvas.d.ts.map +1 -0
- package/dist/utilities/IUpdatingCanvas.js +2 -0
- package/dist/utilities/IUpdatingCanvas.js.map +1 -0
- package/dist/utilities/LayoutHelper.d.ts +34 -0
- package/dist/utilities/LayoutHelper.d.ts.map +1 -0
- package/dist/utilities/LayoutHelper.js +451 -0
- package/dist/utilities/LayoutHelper.js.map +1 -0
- package/dist/utilities/ObjectWithProps.d.ts +5 -0
- package/dist/utilities/ObjectWithProps.d.ts.map +1 -0
- package/dist/utilities/ObjectWithProps.js +65 -0
- package/dist/utilities/ObjectWithProps.js.map +1 -0
- package/dist/utilities/OutlineCanvas.d.ts +12 -0
- package/dist/utilities/OutlineCanvas.d.ts.map +1 -0
- package/dist/utilities/OutlineCanvas.js +31 -0
- package/dist/utilities/OutlineCanvas.js.map +1 -0
- package/dist/utilities/OutlineGeometry.d.ts +3 -0
- package/dist/utilities/OutlineGeometry.d.ts.map +1 -0
- package/dist/utilities/OutlineGeometry.js +57 -0
- package/dist/utilities/OutlineGeometry.js.map +1 -0
- package/dist/utilities/ParameterizedCanvas.d.ts +13 -0
- package/dist/utilities/ParameterizedCanvas.d.ts.map +1 -0
- package/dist/utilities/ParameterizedCanvas.js +85 -0
- package/dist/utilities/ParameterizedCanvas.js.map +1 -0
- package/dist/utilities/RequestSharedAnimationFrame.d.ts +2 -0
- package/dist/utilities/RequestSharedAnimationFrame.d.ts.map +1 -0
- package/dist/utilities/RequestSharedAnimationFrame.js +16 -0
- package/dist/utilities/RequestSharedAnimationFrame.js.map +1 -0
- package/dist/utilities/StaticImage.d.ts +19 -0
- package/dist/utilities/StaticImage.d.ts.map +1 -0
- package/dist/utilities/StaticImage.js +38 -0
- package/dist/utilities/StaticImage.js.map +1 -0
- package/dist/utilities/SvgExtruder.d.ts +20 -0
- package/dist/utilities/SvgExtruder.d.ts.map +1 -0
- package/dist/utilities/SvgExtruder.js +238 -0
- package/dist/utilities/SvgExtruder.js.map +1 -0
- package/dist/utilities/ThreeDisposer.d.ts +11 -0
- package/dist/utilities/ThreeDisposer.d.ts.map +1 -0
- package/dist/utilities/ThreeDisposer.js +53 -0
- package/dist/utilities/ThreeDisposer.js.map +1 -0
- package/dist/utilities/zIndex.d.ts +14 -0
- package/dist/utilities/zIndex.d.ts.map +1 -0
- package/dist/utilities/zIndex.js +14 -0
- package/dist/utilities/zIndex.js.map +1 -0
- package/package.json +138 -0
- package/src/library/assets/checker.svg +4 -0
- package/src/library/assets/cutout.svg +22 -0
- package/src/library/components/ActionLogDisplay.tsx +183 -0
- package/src/library/components/ActionLogHistory.tsx +127 -0
- package/src/library/components/ActionLogHistoryDisplay.tsx +21 -0
- package/src/library/components/ActionLogSidebar.tsx +17 -0
- package/src/library/components/BottomBar.tsx +78 -0
- package/src/library/components/BottomBarBreak.tsx +12 -0
- package/src/library/components/BottomBarButton.tsx +181 -0
- package/src/library/components/CanvasLibraryViewer.tsx +86 -0
- package/src/library/components/ChitLibraryViewer.tsx +168 -0
- package/src/library/components/ClientTrustMatchViewer.tsx +83 -0
- package/src/library/components/ContextGalleryDisplay.tsx +72 -0
- package/src/library/components/GalleryDisplay.tsx +57 -0
- package/src/library/components/GalleryPlayground.tsx +50 -0
- package/src/library/components/GalleryViewer.tsx +773 -0
- package/src/library/components/GameDesigner.tsx +39 -0
- package/src/library/components/GameDialog.tsx +43 -0
- package/src/library/components/GameModalBackdrop.tsx +47 -0
- package/src/library/components/GameModalDialog.tsx +77 -0
- package/src/library/components/LiveButton.tsx +26 -0
- package/src/library/components/MatchEndDisplay.tsx +120 -0
- package/src/library/components/MatchViewer.tsx +111 -0
- package/src/library/components/ObjectWithPropsEditor.tsx +169 -0
- package/src/library/components/Panel/MultiPanel.tsx +276 -0
- package/src/library/components/Panel/PanelContents.tsx +359 -0
- package/src/library/components/Panel/PanelTabStack.tsx +103 -0
- package/src/library/components/Panel/SinglePanel.tsx +75 -0
- package/src/library/components/Panel/ViewerWrapper.tsx +131 -0
- package/src/library/components/Panel/ViewerZoomControls.tsx +216 -0
- package/src/library/components/Panel/util.ts +7 -0
- package/src/library/components/PanelSpark.tsx +112 -0
- package/src/library/components/PersistentCanvas.tsx +81 -0
- package/src/library/components/PlayerImage.tsx +40 -0
- package/src/library/components/Playground.tsx +285 -0
- package/src/library/components/PromptControls.tsx +132 -0
- package/src/library/components/SelectableItemAndStage.tsx +49 -0
- package/src/library/components/SettingsDisplay.tsx +142 -0
- package/src/library/components/SparkLineChart.tsx +307 -0
- package/src/library/components/StageAndEditor.tsx +28 -0
- package/src/library/components/TimeControlBar.tsx +71 -0
- package/src/library/components/TokenizedMessage.tsx +206 -0
- package/src/library/components/TopBar.tsx +90 -0
- package/src/library/components/TopBarDropdown.tsx +94 -0
- package/src/library/components/TopBarPlayers.tsx +163 -0
- package/src/library/components/UpdatingCanvasImage.tsx +25 -0
- package/src/library/components/UpdatingCanvasViewer.tsx +62 -0
- package/src/library/components/Viewer.tsx +360 -0
- package/src/library/components/index.ts +0 -0
- package/src/library/game/Chit.test.ts +66 -0
- package/src/library/game/Chit.ts +575 -0
- package/src/library/game/ClientTimeState.ts +42 -0
- package/src/library/game/ClockDetails.ts +24 -0
- package/src/library/game/Connection.test.ts +50 -0
- package/src/library/game/Connection.ts +122 -0
- package/src/library/game/ConnectionObject.ts +13 -0
- package/src/library/game/ConnectionTransport.ts +52 -0
- package/src/library/game/DropdownChit.tsx +17 -0
- package/src/library/game/GalleryItemChitChildrenSource.ts +31 -0
- package/src/library/game/GalleryItemRawSource.ts +15 -0
- package/src/library/game/Game.ts +55 -0
- package/src/library/game/GameBagChit.ts +42 -0
- package/src/library/game/GameButton.ts +127 -0
- package/src/library/game/GameDeckChit.ts +77 -0
- package/src/library/game/GameTheme.ts +122 -0
- package/src/library/game/Match.ts +187 -0
- package/src/library/game/MatchConnection.ts +5 -0
- package/src/library/game/MatchStorage.ts +51 -0
- package/src/library/game/ModalState.ts +29 -0
- package/src/library/game/OrderedOutlet.ts +198 -0
- package/src/library/game/Pick.ts +314 -0
- package/src/library/game/PlayerChit.ts +43 -0
- package/src/library/game/PlayerInfo.ts +30 -0
- package/src/library/game/PlayerPromptStatusChit.ts +20 -0
- package/src/library/game/Prompt.ts +292 -0
- package/src/library/game/RootChit.ts +54 -0
- package/src/library/game/SparkChit.ts +97 -0
- package/src/library/game/StaticChitTypeRegistry.ts +3 -0
- package/src/library/game/Turn.test.ts +611 -0
- package/src/library/game/Turn.ts +1249 -0
- package/src/library/game/TurnState.ts +187 -0
- package/src/library/game/clientTransport/ClientPrompts.ts +102 -0
- package/src/library/game/clientTransport/ClientStatus.ts +36 -0
- package/src/library/game/clientTransport/ClientTime.ts +256 -0
- package/src/library/game/index.ts +0 -0
- package/src/library/game/serverTransport/ServerPrompts.ts +76 -0
- package/src/library/game/serverTransport/ServerStatus.ts +31 -0
- package/src/library/game/serverTransport/ServerTime.ts +74 -0
- package/src/library/hooks/useChits.ts +32 -0
- package/src/library/hooks/useConnection.tsx +16 -0
- package/src/library/hooks/useEventChannelState.ts +33 -0
- package/src/library/hooks/useGame.tsx +16 -0
- package/src/library/hooks/useGameTheme.tsx +12 -0
- package/src/library/hooks/useModalState.tsx +13 -0
- package/src/library/hooks/usePanelPositioning.tsx +31 -0
- package/src/library/hooks/usePanelScale.tsx +23 -0
- package/src/library/hooks/usePanelStates.ts +30 -0
- package/src/library/hooks/usePlayer.tsx +15 -0
- package/src/library/hooks/useSmartDebouncedState.ts +161 -0
- package/src/library/hooks/useTimeController.tsx +108 -0
- package/src/library/hooks/useTokenMap.ts +20 -0
- package/src/library/hooks/useWebGlRenderer.tsx +227 -0
- package/src/library/index.ts +116 -0
- package/src/library/rendering/CameraSpec.ts +25 -0
- package/src/library/rendering/CameraWrapperPerspective.ts +612 -0
- package/src/library/rendering/ChitGalleryItemInstance.ts +108 -0
- package/src/library/rendering/ChitRenderInstance.ts +1141 -0
- package/src/library/rendering/ChitRenderSpec.ts +213 -0
- package/src/library/rendering/HighlightSpec.ts +5 -0
- package/src/library/rendering/LightSpec.ts +41 -0
- package/src/library/rendering/LightWrapper.ts +152 -0
- package/src/library/rendering/RootChitRenderInstance.ts +460 -0
- package/src/library/rendering/Splay.ts +118 -0
- package/src/library/rendering/SplayCounter.tsx +37 -0
- package/src/library/rendering/TextureReferenceCounter.ts +86 -0
- package/src/library/rendering/index.ts +0 -0
- package/src/library/rendering/outline/DepthVisualizationPass.ts +117 -0
- package/src/library/rendering/outline/EffectComposer.ts +187 -0
- package/src/library/rendering/outline/FullScreenQuad.ts +32 -0
- package/src/library/rendering/outline/IDBasedOutlinePass.ts +741 -0
- package/src/library/rendering/outline/OutputPass.ts +88 -0
- package/src/library/rendering/outline/RenderPass.ts +72 -0
- package/src/library/rendering/outline/SceneWrapper.ts +617 -0
- package/src/library/rendering/outline/ShaderPass.ts +50 -0
- package/src/library/rendering/outline/index.ts +8 -0
- package/src/library/rendering/outline/passes/DebugIDMappingPass.ts +154 -0
- package/src/library/rendering/outline/passes/DepthOcclusionPass.ts +106 -0
- package/src/library/rendering/outline/passes/InterMeshEdgeDetectionPass.ts +244 -0
- package/src/library/rendering/outline/shaders.ts +110 -0
- package/src/library/rendering/outline/types.ts +25 -0
- package/src/library/utilities/Annotations.ts +188 -0
- package/src/library/utilities/BaseTable.tsx +58 -0
- package/src/library/utilities/BboxUtils.ts +23 -0
- package/src/library/utilities/CanvasStack/CanvasOperations.tsx +630 -0
- package/src/library/utilities/CanvasStack/CanvasStack.ts +191 -0
- package/src/library/utilities/CanvasStack/IconCanvas.tsx +17 -0
- package/src/library/utilities/CanvasStack/ImageCache.ts +38 -0
- package/src/library/utilities/CanvasStack/ImageColorOverlayer.ts +36 -0
- package/src/library/utilities/CanvasStack/PlayerCanvas.tsx +17 -0
- package/src/library/utilities/CanvasStack/ReactCanvas.tsx +293 -0
- package/src/library/utilities/CanvasStack/RichTextRenderer.ts +719 -0
- package/src/library/utilities/CardMesh.ts +55 -0
- package/src/library/utilities/Dice.tsx +183 -0
- package/src/library/utilities/EventChannel.ts +52 -0
- package/src/library/utilities/GalleryItemConversion.ts +30 -0
- package/src/library/utilities/IUpdatingCanvas.ts +14 -0
- package/src/library/utilities/LayoutHelper.ts +586 -0
- package/src/library/utilities/ObjectWithProps.ts +52 -0
- package/src/library/utilities/OutlineCanvas.tsx +45 -0
- package/src/library/utilities/OutlineGeometry.ts +69 -0
- package/src/library/utilities/ParameterizedCanvas.ts +78 -0
- package/src/library/utilities/RequestSharedAnimationFrame.ts +16 -0
- package/src/library/utilities/StaticImage.tsx +58 -0
- package/src/library/utilities/SvgExtruder.ts +330 -0
- package/src/library/utilities/ThreeDisposer.ts +66 -0
- package/src/library/utilities/zIndex.ts +15 -0
|
@@ -0,0 +1,719 @@
|
|
|
1
|
+
export type Align = "left" | "center" | "right";
|
|
2
|
+
export type IconBaseline = "text" | "middle" | "bottom";
|
|
3
|
+
export type VerticalAlign = "top" | "middle" | "bottom";
|
|
4
|
+
|
|
5
|
+
/** A single sprite inside a larger sprite sheet image */
|
|
6
|
+
export interface SpriteRef {
|
|
7
|
+
image: HTMLImageElement; // the full spritemap image
|
|
8
|
+
x: number; // source x within the spritemap
|
|
9
|
+
y: number; // source y within the spritemap
|
|
10
|
+
width: number; // source width of the sprite
|
|
11
|
+
height: number; // source height of the sprite
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export interface IconMap {
|
|
15
|
+
[name: string]: SpriteRef | undefined;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export type RichTextRenderOptionsParameters = {
|
|
19
|
+
fontFamily?: string;
|
|
20
|
+
fontSize?: number;
|
|
21
|
+
lineHeight?: number; // multiplier (e.g., 1.25)
|
|
22
|
+
align?: Align;
|
|
23
|
+
verticalAlign?: VerticalAlign;
|
|
24
|
+
color?: string;
|
|
25
|
+
iconMap?: IconMap;
|
|
26
|
+
iconBaseline?: IconBaseline;
|
|
27
|
+
iconScale?: number; // 1.0 = same height as text
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
export interface RenderOptions extends RichTextRenderOptionsParameters {
|
|
31
|
+
x?: number;
|
|
32
|
+
y?: number;
|
|
33
|
+
maxWidth: number; // required
|
|
34
|
+
height?: number; // optional container height for vertical alignment
|
|
35
|
+
debug?: boolean;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export interface RenderResult {
|
|
39
|
+
height: number;
|
|
40
|
+
lines: number;
|
|
41
|
+
lastBaselineY: number;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
type Token =
|
|
45
|
+
| { type: "text"; text: string; bold: boolean; italic: boolean }
|
|
46
|
+
| { type: "icon"; name: string }
|
|
47
|
+
| { type: "break" };
|
|
48
|
+
|
|
49
|
+
type Run =
|
|
50
|
+
| { kind: "text"; text: string; bold: boolean; italic: boolean }
|
|
51
|
+
| { kind: "icon"; name: string }
|
|
52
|
+
| { kind: "space"; text: string; bold: boolean; italic: boolean }
|
|
53
|
+
| { kind: "break" };
|
|
54
|
+
|
|
55
|
+
type Segment =
|
|
56
|
+
| { kind: "text"; text: string; width: number; style: { bold: boolean; italic: boolean } }
|
|
57
|
+
| { kind: "icon"; width: number; height: number; sprite: SpriteRef | null; name: string }
|
|
58
|
+
| { kind: "space"; width: number };
|
|
59
|
+
|
|
60
|
+
interface Line {
|
|
61
|
+
width: number;
|
|
62
|
+
segments: Segment[];
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
interface Metrics {
|
|
66
|
+
fontFamily: string;
|
|
67
|
+
fontSize: number;
|
|
68
|
+
lineHeightPx: number;
|
|
69
|
+
iconScale: number;
|
|
70
|
+
iconBaseline: IconBaseline;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
export class RichTextRenderer {
|
|
74
|
+
render(ctx: CanvasRenderingContext2D, text: string, opts: RenderOptions): RenderResult {
|
|
75
|
+
const {
|
|
76
|
+
x = 0,
|
|
77
|
+
y = 0,
|
|
78
|
+
maxWidth,
|
|
79
|
+
height,
|
|
80
|
+
fontFamily = "system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, sans-serif",
|
|
81
|
+
fontSize = 16,
|
|
82
|
+
lineHeight = 1.25,
|
|
83
|
+
align = "left",
|
|
84
|
+
verticalAlign = "top",
|
|
85
|
+
color = "#000",
|
|
86
|
+
iconMap = {},
|
|
87
|
+
iconBaseline = "text",
|
|
88
|
+
iconScale = 1.0,
|
|
89
|
+
debug = false,
|
|
90
|
+
} = opts;
|
|
91
|
+
|
|
92
|
+
if (!maxWidth || maxWidth <= 0) {
|
|
93
|
+
throw new Error("RichTextRenderer: opts.maxWidth is required and must be > 0.");
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
const metrics: Metrics = {
|
|
97
|
+
fontFamily,
|
|
98
|
+
fontSize,
|
|
99
|
+
lineHeightPx: fontSize * lineHeight,
|
|
100
|
+
iconScale,
|
|
101
|
+
iconBaseline,
|
|
102
|
+
};
|
|
103
|
+
|
|
104
|
+
const tokens = this.tokenize(text);
|
|
105
|
+
const runs = this.expandRuns(tokens);
|
|
106
|
+
const lines = this.layoutRunsToLines(ctx, runs, metrics, maxWidth, iconMap);
|
|
107
|
+
|
|
108
|
+
// Draw
|
|
109
|
+
ctx.save();
|
|
110
|
+
ctx.textBaseline = "alphabetic";
|
|
111
|
+
ctx.fillStyle = color;
|
|
112
|
+
|
|
113
|
+
const totalHeight = lines.length * metrics.lineHeightPx;
|
|
114
|
+
// Compute initial Y based on vertical alignment if a container height was provided.
|
|
115
|
+
let startY = y;
|
|
116
|
+
if (verticalAlign === "middle" && typeof height === "number") {
|
|
117
|
+
startY = y + Math.round(Math.max(0, (height - totalHeight) / 2));
|
|
118
|
+
} else if (verticalAlign === "bottom" && typeof height === "number") {
|
|
119
|
+
startY = y + Math.round(Math.max(0, height - totalHeight));
|
|
120
|
+
}
|
|
121
|
+
let cursorY = startY;
|
|
122
|
+
for (const line of lines) {
|
|
123
|
+
let offsetX = 0;
|
|
124
|
+
if (align === "center") offsetX = (maxWidth - line.width) / 2;
|
|
125
|
+
else if (align === "right") offsetX = maxWidth - line.width;
|
|
126
|
+
|
|
127
|
+
let cursorX = x + offsetX;
|
|
128
|
+
const baselineY = cursorY + metrics.fontSize;
|
|
129
|
+
|
|
130
|
+
if (debug) {
|
|
131
|
+
ctx.save();
|
|
132
|
+
ctx.strokeStyle = "rgba(0,0,255,0.25)";
|
|
133
|
+
ctx.strokeRect(x + offsetX, cursorY, line.width, metrics.lineHeightPx);
|
|
134
|
+
ctx.restore();
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
for (const seg of line.segments) {
|
|
138
|
+
if (seg.kind === "text") {
|
|
139
|
+
ctx.font = this.makeFont(seg.style, metrics);
|
|
140
|
+
ctx.fillText(seg.text, cursorX, baselineY);
|
|
141
|
+
cursorX += seg.width;
|
|
142
|
+
} else if (seg.kind === "icon") {
|
|
143
|
+
const sprite = seg.sprite;
|
|
144
|
+
const { drawY } = this.iconBaselinePosition(baselineY, metrics, seg.height);
|
|
145
|
+
|
|
146
|
+
if (
|
|
147
|
+
sprite &&
|
|
148
|
+
sprite.image &&
|
|
149
|
+
sprite.image.complete &&
|
|
150
|
+
sprite.image.naturalWidth > 0 &&
|
|
151
|
+
sprite.image.naturalHeight > 0 &&
|
|
152
|
+
sprite.width > 0 &&
|
|
153
|
+
sprite.height > 0
|
|
154
|
+
) {
|
|
155
|
+
ctx.drawImage(
|
|
156
|
+
sprite.image,
|
|
157
|
+
sprite.x,
|
|
158
|
+
sprite.y,
|
|
159
|
+
sprite.width,
|
|
160
|
+
sprite.height, // source rect
|
|
161
|
+
Math.round(cursorX),
|
|
162
|
+
Math.round(drawY),
|
|
163
|
+
Math.round(seg.width),
|
|
164
|
+
Math.round(seg.height), // destination rect (aspect preserved)
|
|
165
|
+
);
|
|
166
|
+
} else {
|
|
167
|
+
// Placeholder box with preserved layout size
|
|
168
|
+
ctx.save();
|
|
169
|
+
ctx.strokeStyle = "rgba(0,0,0,0.35)";
|
|
170
|
+
ctx.strokeRect(Math.round(cursorX), Math.round(drawY), Math.round(seg.width), Math.round(seg.height));
|
|
171
|
+
ctx.restore();
|
|
172
|
+
}
|
|
173
|
+
cursorX += seg.width;
|
|
174
|
+
} else if (seg.kind === "space") {
|
|
175
|
+
cursorX += seg.width;
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
cursorY += metrics.lineHeightPx;
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
ctx.restore();
|
|
183
|
+
|
|
184
|
+
return {
|
|
185
|
+
height: lines.length * metrics.lineHeightPx,
|
|
186
|
+
lines: lines.length,
|
|
187
|
+
lastBaselineY: startY + (lines.length - 1) * metrics.lineHeightPx + metrics.fontSize,
|
|
188
|
+
};
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
// ---------------------- Parsing / Tokenizing ----------------------
|
|
192
|
+
|
|
193
|
+
/** Supports **bold** / __bold__ / *italic* / _italic_ / ***bold-italic*** and :icon: */
|
|
194
|
+
private tokenize(input: string): Token[] {
|
|
195
|
+
const out: Token[] = [];
|
|
196
|
+
const push = (t: Token) => out.push(t);
|
|
197
|
+
|
|
198
|
+
let i = 0;
|
|
199
|
+
const len = input.length;
|
|
200
|
+
|
|
201
|
+
const style = { bold: false, italic: false };
|
|
202
|
+
let buf = "";
|
|
203
|
+
|
|
204
|
+
const flushText = (b: string) => {
|
|
205
|
+
if (!b) return;
|
|
206
|
+
push({ type: "text", text: b, bold: style.bold, italic: style.italic });
|
|
207
|
+
};
|
|
208
|
+
|
|
209
|
+
const peek = (n = 0) => input[i + n];
|
|
210
|
+
const consume = (n = 1) => {
|
|
211
|
+
i += n;
|
|
212
|
+
};
|
|
213
|
+
const toggle = (what: "bold" | "italic") => {
|
|
214
|
+
style[what] = !style[what];
|
|
215
|
+
};
|
|
216
|
+
|
|
217
|
+
while (i < len) {
|
|
218
|
+
const ch = peek();
|
|
219
|
+
|
|
220
|
+
if (ch === "\n") {
|
|
221
|
+
flushText(buf);
|
|
222
|
+
buf = "";
|
|
223
|
+
push({ type: "break" });
|
|
224
|
+
consume();
|
|
225
|
+
continue;
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
if (ch === "\\") {
|
|
229
|
+
const next = peek(1);
|
|
230
|
+
if (next) {
|
|
231
|
+
buf += next;
|
|
232
|
+
consume(2);
|
|
233
|
+
continue;
|
|
234
|
+
}
|
|
235
|
+
buf += ch;
|
|
236
|
+
consume();
|
|
237
|
+
continue;
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
if (ch === ":") {
|
|
241
|
+
let j = i + 1;
|
|
242
|
+
while (j < len && input[j] !== ":") j++;
|
|
243
|
+
const maybeName = input.slice(i + 1, j);
|
|
244
|
+
if (j < len && maybeName && /^[a-zA-Z0-9_-]+$/.test(maybeName)) {
|
|
245
|
+
flushText(buf);
|
|
246
|
+
buf = "";
|
|
247
|
+
push({ type: "icon", name: maybeName });
|
|
248
|
+
consume(maybeName.length + 2);
|
|
249
|
+
continue;
|
|
250
|
+
}
|
|
251
|
+
buf += ch;
|
|
252
|
+
consume();
|
|
253
|
+
continue;
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
if (ch === "*" || ch === "_") {
|
|
257
|
+
const mark = ch;
|
|
258
|
+
let count = 1;
|
|
259
|
+
while (peek(count) === mark) count++;
|
|
260
|
+
const use = Math.min(count, 3);
|
|
261
|
+
flushText(buf);
|
|
262
|
+
buf = "";
|
|
263
|
+
|
|
264
|
+
if (use === 3) {
|
|
265
|
+
toggle("bold");
|
|
266
|
+
toggle("italic");
|
|
267
|
+
} else if (use === 2) {
|
|
268
|
+
toggle("bold");
|
|
269
|
+
} else {
|
|
270
|
+
toggle("italic");
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
consume(use);
|
|
274
|
+
continue;
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
buf += ch!;
|
|
278
|
+
consume();
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
flushText(buf);
|
|
282
|
+
return out;
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
/** Split text tokens into runs by whitespace, preserving spaces as runs for measurement. */
|
|
286
|
+
private expandRuns(tokens: Token[]): Run[] {
|
|
287
|
+
const runs: Run[] = [];
|
|
288
|
+
const pushText = (text: string, bold: boolean, italic: boolean) => {
|
|
289
|
+
if (text.length === 0) return;
|
|
290
|
+
runs.push({ kind: "text", text, bold, italic });
|
|
291
|
+
};
|
|
292
|
+
|
|
293
|
+
for (const t of tokens) {
|
|
294
|
+
if (t.type === "break") {
|
|
295
|
+
runs.push({ kind: "break" });
|
|
296
|
+
} else if (t.type === "icon") {
|
|
297
|
+
runs.push({ kind: "icon", name: t.name });
|
|
298
|
+
} else if (t.type === "text") {
|
|
299
|
+
const parts = t.text.split(/(\s+)/);
|
|
300
|
+
for (const p of parts) {
|
|
301
|
+
if (!p) continue;
|
|
302
|
+
if (/^\s+$/.test(p)) runs.push({ kind: "space", text: p, bold: t.bold, italic: t.italic });
|
|
303
|
+
else pushText(p, t.bold, t.italic);
|
|
304
|
+
}
|
|
305
|
+
}
|
|
306
|
+
}
|
|
307
|
+
return runs;
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
// --------------------------- Layout ---------------------------
|
|
311
|
+
|
|
312
|
+
private layoutRunsToLines(
|
|
313
|
+
ctx: CanvasRenderingContext2D,
|
|
314
|
+
runs: Run[],
|
|
315
|
+
metrics: Metrics,
|
|
316
|
+
maxWidth: number,
|
|
317
|
+
iconMap: IconMap,
|
|
318
|
+
): Line[] {
|
|
319
|
+
const lines: Line[] = [];
|
|
320
|
+
let line: Line = this.newLine();
|
|
321
|
+
let cursorW = 0;
|
|
322
|
+
|
|
323
|
+
const HYPH_RATIO = 1 / 3; // hyphenate mid-line only if word width > this * maxWidth
|
|
324
|
+
const hyphenWidthCache = new Map<string, number>();
|
|
325
|
+
|
|
326
|
+
const hyphenWidth = (styleKey: string) => {
|
|
327
|
+
if (hyphenWidthCache.has(styleKey)) return hyphenWidthCache.get(styleKey)!;
|
|
328
|
+
const w = this.measureText(ctx, "-", styleKey, metrics);
|
|
329
|
+
hyphenWidthCache.set(styleKey, w);
|
|
330
|
+
return w;
|
|
331
|
+
};
|
|
332
|
+
|
|
333
|
+
const spaceWidthCache = new Map<string, number>();
|
|
334
|
+
const measureSpace = (sp: string, styleKey: string) => {
|
|
335
|
+
const k = sp + "|" + styleKey;
|
|
336
|
+
if (spaceWidthCache.has(k)) return spaceWidthCache.get(k)!;
|
|
337
|
+
const w = this.measureText(ctx, sp, styleKey, metrics);
|
|
338
|
+
spaceWidthCache.set(k, w);
|
|
339
|
+
return w;
|
|
340
|
+
};
|
|
341
|
+
|
|
342
|
+
const flushLine = (allowEmpty = false) => {
|
|
343
|
+
if (allowEmpty || line.segments.length > 0) {
|
|
344
|
+
lines.push(line);
|
|
345
|
+
}
|
|
346
|
+
line = this.newLine();
|
|
347
|
+
cursorW = 0;
|
|
348
|
+
};
|
|
349
|
+
|
|
350
|
+
for (const r of runs) {
|
|
351
|
+
if (r.kind === "break") {
|
|
352
|
+
flushLine(true);
|
|
353
|
+
continue;
|
|
354
|
+
}
|
|
355
|
+
|
|
356
|
+
if (r.kind === "space") {
|
|
357
|
+
const styleKey = this.styleKey(r);
|
|
358
|
+
const w = measureSpace(r.text, styleKey);
|
|
359
|
+
if (cursorW + w > maxWidth) {
|
|
360
|
+
flushLine(true);
|
|
361
|
+
continue;
|
|
362
|
+
}
|
|
363
|
+
line.segments.push({ kind: "space", width: w });
|
|
364
|
+
cursorW += w;
|
|
365
|
+
continue;
|
|
366
|
+
}
|
|
367
|
+
|
|
368
|
+
if (r.kind === "icon") {
|
|
369
|
+
const sprite = iconMap[r.name] ?? null;
|
|
370
|
+
const drawH = metrics.fontSize * metrics.iconScale;
|
|
371
|
+
let drawW = drawH; // default square if missing/invalid
|
|
372
|
+
|
|
373
|
+
if (sprite && sprite.width > 0 && sprite.height > 0) {
|
|
374
|
+
drawW = drawH * (sprite.width / sprite.height); // preserve aspect ratio from sprite rect
|
|
375
|
+
}
|
|
376
|
+
|
|
377
|
+
if (cursorW > 0 && cursorW + drawW > maxWidth) {
|
|
378
|
+
flushLine(true);
|
|
379
|
+
}
|
|
380
|
+
line.segments.push({
|
|
381
|
+
kind: "icon",
|
|
382
|
+
width: drawW,
|
|
383
|
+
height: drawH,
|
|
384
|
+
sprite,
|
|
385
|
+
name: r.name,
|
|
386
|
+
});
|
|
387
|
+
cursorW += drawW;
|
|
388
|
+
continue;
|
|
389
|
+
}
|
|
390
|
+
|
|
391
|
+
// ---- Text run (single "word" or punctuation chunk) ----
|
|
392
|
+
if (r.kind === "text") {
|
|
393
|
+
const styleKey = this.styleKey(r);
|
|
394
|
+
const wordWidth = this.measureText(ctx, r.text, styleKey, metrics);
|
|
395
|
+
const avail = maxWidth - cursorW;
|
|
396
|
+
const threshold = maxWidth * HYPH_RATIO;
|
|
397
|
+
|
|
398
|
+
// Fits in remaining space: place and continue.
|
|
399
|
+
if (wordWidth <= avail) {
|
|
400
|
+
line.segments.push({
|
|
401
|
+
kind: "text",
|
|
402
|
+
text: r.text,
|
|
403
|
+
width: wordWidth,
|
|
404
|
+
style: { bold: r.bold, italic: r.italic },
|
|
405
|
+
});
|
|
406
|
+
cursorW += wordWidth;
|
|
407
|
+
continue;
|
|
408
|
+
}
|
|
409
|
+
|
|
410
|
+
// If it doesn't fit the tail…
|
|
411
|
+
if (cursorW > 0) {
|
|
412
|
+
// …and the word is "long" (over threshold), try hyphenating into the remaining space.
|
|
413
|
+
if (wordWidth > threshold) {
|
|
414
|
+
const res = this.hyphenateIntoLines(
|
|
415
|
+
ctx,
|
|
416
|
+
r.text,
|
|
417
|
+
r,
|
|
418
|
+
styleKey,
|
|
419
|
+
metrics,
|
|
420
|
+
maxWidth,
|
|
421
|
+
lines,
|
|
422
|
+
line,
|
|
423
|
+
cursorW,
|
|
424
|
+
avail, // first chunk limited by remaining space
|
|
425
|
+
hyphenWidth(styleKey),
|
|
426
|
+
);
|
|
427
|
+
line = res.line;
|
|
428
|
+
cursorW = res.cursorW;
|
|
429
|
+
continue;
|
|
430
|
+
} else {
|
|
431
|
+
// Short word: move intact to next line (no hyphen).
|
|
432
|
+
flushLine(true);
|
|
433
|
+
line.segments.push({
|
|
434
|
+
kind: "text",
|
|
435
|
+
text: r.text,
|
|
436
|
+
width: wordWidth,
|
|
437
|
+
style: { bold: r.bold, italic: r.italic },
|
|
438
|
+
});
|
|
439
|
+
cursorW = wordWidth;
|
|
440
|
+
continue;
|
|
441
|
+
}
|
|
442
|
+
}
|
|
443
|
+
|
|
444
|
+
// We're at line start and word still doesn't fit -> must hyphenate across lines.
|
|
445
|
+
if (wordWidth > maxWidth) {
|
|
446
|
+
const res = this.hyphenateIntoLines(
|
|
447
|
+
ctx,
|
|
448
|
+
r.text,
|
|
449
|
+
r,
|
|
450
|
+
styleKey,
|
|
451
|
+
metrics,
|
|
452
|
+
maxWidth,
|
|
453
|
+
lines,
|
|
454
|
+
line,
|
|
455
|
+
cursorW,
|
|
456
|
+
maxWidth, // first chunk uses full width
|
|
457
|
+
hyphenWidth(styleKey),
|
|
458
|
+
);
|
|
459
|
+
line = res.line;
|
|
460
|
+
cursorW = res.cursorW;
|
|
461
|
+
continue;
|
|
462
|
+
}
|
|
463
|
+
|
|
464
|
+
// Otherwise: we were at line start and it fits a fresh line.
|
|
465
|
+
line.segments.push({ kind: "text", text: r.text, width: wordWidth, style: { bold: r.bold, italic: r.italic } });
|
|
466
|
+
cursorW += wordWidth;
|
|
467
|
+
}
|
|
468
|
+
}
|
|
469
|
+
|
|
470
|
+
// Push the last line (may be empty when text ends with \n; keep parity with original behavior)
|
|
471
|
+
lines.push(line);
|
|
472
|
+
|
|
473
|
+
// Compute final widths
|
|
474
|
+
for (const L of lines) {
|
|
475
|
+
L.width = L.segments.reduce((a, s) => a + s.width, 0);
|
|
476
|
+
}
|
|
477
|
+
return lines;
|
|
478
|
+
}
|
|
479
|
+
|
|
480
|
+
private newLine(): Line {
|
|
481
|
+
return { width: 0, segments: [] };
|
|
482
|
+
}
|
|
483
|
+
|
|
484
|
+
private styleKey(run: { bold: boolean; italic: boolean }): string {
|
|
485
|
+
return `${run.bold ? "b" : "n"}${run.italic ? "i" : "n"}`;
|
|
486
|
+
}
|
|
487
|
+
|
|
488
|
+
private makeFont(style: { bold?: boolean; italic?: boolean }, metrics: Metrics): string {
|
|
489
|
+
const w = style?.bold ? "700" : "400";
|
|
490
|
+
const it = style?.italic ? "italic " : "";
|
|
491
|
+
return `${it}${w} ${metrics.fontSize}px ${metrics.fontFamily}`;
|
|
492
|
+
}
|
|
493
|
+
|
|
494
|
+
private measureText(ctx: CanvasRenderingContext2D, text: string, styleKey: string, metrics: Metrics): number {
|
|
495
|
+
const bold = styleKey[0] === "b";
|
|
496
|
+
const italic = styleKey[1] === "i";
|
|
497
|
+
const font = this.makeFont({ bold, italic }, metrics);
|
|
498
|
+
ctx.font = font;
|
|
499
|
+
return ctx.measureText(text).width;
|
|
500
|
+
}
|
|
501
|
+
|
|
502
|
+
// --------------------------- Hyphenation ---------------------------
|
|
503
|
+
|
|
504
|
+
/** Decide a chunk for the current line:
|
|
505
|
+
* - If whole `word` fits in `limit`, return it (no hyphen).
|
|
506
|
+
* - Else return the largest prefix that fits with a trailing "-" (requires at least 1 char left as rest).
|
|
507
|
+
* - If even "a-" won't fit, returns { first: "", rest: word, addHyphen: false }.
|
|
508
|
+
*/
|
|
509
|
+
private hyphenateChunk(
|
|
510
|
+
ctx: CanvasRenderingContext2D,
|
|
511
|
+
word: string,
|
|
512
|
+
styleKey: string,
|
|
513
|
+
metrics: Metrics,
|
|
514
|
+
limit: number,
|
|
515
|
+
hyphW: number,
|
|
516
|
+
): { first: string; rest: string; addHyphen: boolean } {
|
|
517
|
+
// Don't attempt if no space
|
|
518
|
+
if (limit <= 0) return { first: "", rest: word, addHyphen: false };
|
|
519
|
+
|
|
520
|
+
const fullW = this.measureText(ctx, word, styleKey, metrics);
|
|
521
|
+
if (fullW <= limit) {
|
|
522
|
+
return { first: word, rest: "", addHyphen: false };
|
|
523
|
+
}
|
|
524
|
+
|
|
525
|
+
// Never split within the first or last MIN_EDGE characters.
|
|
526
|
+
const MIN_EDGE = 3;
|
|
527
|
+
const n = word.length;
|
|
528
|
+
if (n <= MIN_EDGE * 2) {
|
|
529
|
+
// Word too short to hyphenate while respecting edge constraints.
|
|
530
|
+
return { first: "", rest: word, addHyphen: false };
|
|
531
|
+
}
|
|
532
|
+
|
|
533
|
+
const minFirst = MIN_EDGE;
|
|
534
|
+
const maxFirst = n - MIN_EDGE; // inclusive
|
|
535
|
+
|
|
536
|
+
// Prefer a near-50/50 split (balanced) subject to fitting in `limit`.
|
|
537
|
+
const mid = Math.floor(n / 2);
|
|
538
|
+
|
|
539
|
+
// Build candidate indices in increasing distance from mid, constrained to [minFirst, maxFirst].
|
|
540
|
+
const candidates: number[] = [];
|
|
541
|
+
for (let i = minFirst; i <= maxFirst; i++) candidates.push(i);
|
|
542
|
+
candidates.sort((a, b) => Math.abs(a - mid) - Math.abs(b - mid));
|
|
543
|
+
|
|
544
|
+
for (const idx of candidates) {
|
|
545
|
+
const prefix = word.slice(0, idx);
|
|
546
|
+
const prefixW = this.measureText(ctx, prefix, styleKey, metrics);
|
|
547
|
+
if (prefixW + hyphW <= limit) {
|
|
548
|
+
return { first: prefix, rest: word.slice(idx), addHyphen: true };
|
|
549
|
+
}
|
|
550
|
+
}
|
|
551
|
+
|
|
552
|
+
// If no balanced candidate fits, fallback to the largest prefix that fits within [minFirst, maxFirst].
|
|
553
|
+
let lo = minFirst;
|
|
554
|
+
let hi = maxFirst;
|
|
555
|
+
let best = 0;
|
|
556
|
+
while (lo <= hi) {
|
|
557
|
+
const midIdx = (lo + hi) >> 1;
|
|
558
|
+
const prefixW = this.measureText(ctx, word.slice(0, midIdx), styleKey, metrics);
|
|
559
|
+
if (prefixW + hyphW <= limit) {
|
|
560
|
+
best = midIdx;
|
|
561
|
+
lo = midIdx + 1;
|
|
562
|
+
} else {
|
|
563
|
+
hi = midIdx - 1;
|
|
564
|
+
}
|
|
565
|
+
}
|
|
566
|
+
|
|
567
|
+
if (best > 0) {
|
|
568
|
+
return { first: word.slice(0, best), rest: word.slice(best), addHyphen: true };
|
|
569
|
+
}
|
|
570
|
+
|
|
571
|
+
// As a last resort, try splitting at an index >= 2 (avoid single-character prefixes).
|
|
572
|
+
// This prevents infinite loops when a word cannot fit intact on a line but no balanced split was possible.
|
|
573
|
+
lo = 2;
|
|
574
|
+
hi = n - 1;
|
|
575
|
+
best = 0;
|
|
576
|
+
while (lo <= hi) {
|
|
577
|
+
const midIdx = (lo + hi) >> 1;
|
|
578
|
+
const prefixW = this.measureText(ctx, word.slice(0, midIdx), styleKey, metrics);
|
|
579
|
+
if (prefixW + hyphW <= limit) {
|
|
580
|
+
best = midIdx;
|
|
581
|
+
lo = midIdx + 1;
|
|
582
|
+
} else {
|
|
583
|
+
hi = midIdx - 1;
|
|
584
|
+
}
|
|
585
|
+
}
|
|
586
|
+
|
|
587
|
+
if (best <= 0) {
|
|
588
|
+
return { first: "", rest: word, addHyphen: false };
|
|
589
|
+
}
|
|
590
|
+
|
|
591
|
+
return { first: word.slice(0, best), rest: word.slice(best), addHyphen: true };
|
|
592
|
+
}
|
|
593
|
+
|
|
594
|
+
/** Hyphenate `text` across one or more lines. Returns updated `line` and `cursorW`.
|
|
595
|
+
* - First piece is constrained by `firstLimit` (remaining width on current line).
|
|
596
|
+
* - Subsequent pieces use `maxWidth`.
|
|
597
|
+
* - Adds "-" to all but the last piece.
|
|
598
|
+
*/
|
|
599
|
+
private hyphenateIntoLines(
|
|
600
|
+
ctx: CanvasRenderingContext2D,
|
|
601
|
+
text: string,
|
|
602
|
+
run: { bold: boolean; italic: boolean },
|
|
603
|
+
styleKey: string,
|
|
604
|
+
metrics: Metrics,
|
|
605
|
+
maxWidth: number,
|
|
606
|
+
lines: Line[],
|
|
607
|
+
line: Line,
|
|
608
|
+
cursorW: number,
|
|
609
|
+
firstLimit: number,
|
|
610
|
+
hyphW: number,
|
|
611
|
+
): { line: Line; cursorW: number } {
|
|
612
|
+
let remaining = text;
|
|
613
|
+
let limit = firstLimit;
|
|
614
|
+
|
|
615
|
+
const pushLine = () => {
|
|
616
|
+
lines.push(line);
|
|
617
|
+
line = this.newLine();
|
|
618
|
+
cursorW = 0;
|
|
619
|
+
limit = maxWidth;
|
|
620
|
+
};
|
|
621
|
+
|
|
622
|
+
while (remaining.length > 0) {
|
|
623
|
+
// If we can place the remainder intact within the current limit, do it and finish.
|
|
624
|
+
const wholeW = this.measureText(ctx, remaining, styleKey, metrics);
|
|
625
|
+
if (wholeW <= limit) {
|
|
626
|
+
line.segments.push({
|
|
627
|
+
kind: "text",
|
|
628
|
+
text: remaining,
|
|
629
|
+
width: wholeW,
|
|
630
|
+
style: { bold: run.bold, italic: run.italic },
|
|
631
|
+
});
|
|
632
|
+
cursorW += wholeW;
|
|
633
|
+
remaining = "";
|
|
634
|
+
break;
|
|
635
|
+
}
|
|
636
|
+
|
|
637
|
+
// Try to fit with hyphen within the current limit.
|
|
638
|
+
const chunk = this.hyphenateChunk(ctx, remaining, styleKey, metrics, limit, hyphW);
|
|
639
|
+
|
|
640
|
+
// If nothing (not even "a-") fits in the remaining tail, try to avoid infinite loops.
|
|
641
|
+
if (!chunk.first) {
|
|
642
|
+
// If we're already on a fresh line (limit == maxWidth) and still nothing fits,
|
|
643
|
+
// force-placement of a single character so we always make progress.
|
|
644
|
+
// This is a last-resort fallback to prevent infinite loops when hyphenation
|
|
645
|
+
// can't produce any valid prefix for the current limit.
|
|
646
|
+
if (limit === maxWidth) {
|
|
647
|
+
// Try to place two characters if possible to avoid single-letter line breaks like "A-\nstronomy".
|
|
648
|
+
const tryLen = Math.min(2, remaining.length);
|
|
649
|
+
let forced = remaining.slice(0, tryLen);
|
|
650
|
+
let forcedW = this.measureText(ctx, forced, styleKey, metrics);
|
|
651
|
+
// If two characters don't fit, fall back to a single character.
|
|
652
|
+
if (tryLen === 2 && forcedW + hyphW > limit) {
|
|
653
|
+
forced = remaining.slice(0, 1);
|
|
654
|
+
forcedW = this.measureText(ctx, forced, styleKey, metrics);
|
|
655
|
+
}
|
|
656
|
+
line.segments.push({
|
|
657
|
+
kind: "text",
|
|
658
|
+
text: forced,
|
|
659
|
+
width: forcedW,
|
|
660
|
+
style: { bold: run.bold, italic: run.italic },
|
|
661
|
+
});
|
|
662
|
+
cursorW += forcedW;
|
|
663
|
+
remaining = remaining.slice(forced.length);
|
|
664
|
+
if (remaining.length > 0) {
|
|
665
|
+
pushLine();
|
|
666
|
+
}
|
|
667
|
+
continue;
|
|
668
|
+
}
|
|
669
|
+
|
|
670
|
+
// Otherwise move to a fresh line and try again.
|
|
671
|
+
pushLine();
|
|
672
|
+
continue;
|
|
673
|
+
}
|
|
674
|
+
|
|
675
|
+
// Place the piece (with hyphen if needed)
|
|
676
|
+
const pieceText = chunk.addHyphen ? chunk.first + "-" : chunk.first;
|
|
677
|
+
const pieceW = this.measureText(ctx, pieceText, styleKey, metrics);
|
|
678
|
+
|
|
679
|
+
line.segments.push({
|
|
680
|
+
kind: "text",
|
|
681
|
+
text: pieceText,
|
|
682
|
+
width: pieceW,
|
|
683
|
+
style: { bold: run.bold, italic: run.italic },
|
|
684
|
+
});
|
|
685
|
+
cursorW += pieceW;
|
|
686
|
+
|
|
687
|
+
if (chunk.rest.length === 0) {
|
|
688
|
+
// Finished the word on this line.
|
|
689
|
+
remaining = "";
|
|
690
|
+
break;
|
|
691
|
+
}
|
|
692
|
+
|
|
693
|
+
// More remains -> push current line and continue on a fresh line.
|
|
694
|
+
pushLine();
|
|
695
|
+
remaining = chunk.rest;
|
|
696
|
+
// limit already set to maxWidth by pushLine()
|
|
697
|
+
}
|
|
698
|
+
|
|
699
|
+
return { line, cursorW };
|
|
700
|
+
}
|
|
701
|
+
|
|
702
|
+
// --------------------------- Icon baseline ---------------------------
|
|
703
|
+
|
|
704
|
+
private iconBaselinePosition(baselineY: number, metrics: Metrics, height: number): { drawY: number } {
|
|
705
|
+
const ascent = metrics.fontSize * 0.8;
|
|
706
|
+
const descent = metrics.fontSize * 0.2;
|
|
707
|
+
let drawY = baselineY - height;
|
|
708
|
+
|
|
709
|
+
if (metrics.iconBaseline === "text") {
|
|
710
|
+
drawY = baselineY - ascent;
|
|
711
|
+
} else if (metrics.iconBaseline === "middle") {
|
|
712
|
+
const mid = baselineY - (ascent - descent) / 2;
|
|
713
|
+
drawY = mid - height / 2;
|
|
714
|
+
} else if (metrics.iconBaseline === "bottom") {
|
|
715
|
+
drawY = baselineY - height + descent * 0.2;
|
|
716
|
+
}
|
|
717
|
+
return { drawY };
|
|
718
|
+
}
|
|
719
|
+
}
|