react-cosmos-ui 6.0.0-alpha.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/LICENSE +21 -0
- package/dist/components/BaseSvg.d.ts +9 -0
- package/dist/components/BaseSvg.js +8 -0
- package/dist/components/Icon.d.ts +7 -0
- package/dist/components/Icon.js +5 -0
- package/dist/components/Illustration.d.ts +8 -0
- package/dist/components/Illustration.js +5 -0
- package/dist/components/KeyBox.d.ts +9 -0
- package/dist/components/KeyBox.js +28 -0
- package/dist/components/SidePanel.d.ts +10 -0
- package/dist/components/SidePanel.js +52 -0
- package/dist/components/Space.d.ts +7 -0
- package/dist/components/Space.js +8 -0
- package/dist/components/TreeView.d.ts +19 -0
- package/dist/components/TreeView.js +26 -0
- package/dist/components/ValueInputTree/ExpandCollapseValues.d.ts +9 -0
- package/dist/components/ValueInputTree/ExpandCollapseValues.js +11 -0
- package/dist/components/ValueInputTree/ValueInput/BooleanValueInput.d.ts +8 -0
- package/dist/components/ValueInputTree/ValueInput/BooleanValueInput.js +32 -0
- package/dist/components/ValueInputTree/ValueInput/NullValueInput.d.ts +5 -0
- package/dist/components/ValueInputTree/ValueInput/NullValueInput.js +9 -0
- package/dist/components/ValueInputTree/ValueInput/NumberValueInput.d.ts +8 -0
- package/dist/components/ValueInputTree/ValueInput/NumberValueInput.js +14 -0
- package/dist/components/ValueInputTree/ValueInput/StringValueInput.d.ts +8 -0
- package/dist/components/ValueInputTree/ValueInput/StringValueInput.js +18 -0
- package/dist/components/ValueInputTree/ValueInput/UndefinedValueInput.d.ts +5 -0
- package/dist/components/ValueInputTree/ValueInput/UndefinedValueInput.js +9 -0
- package/dist/components/ValueInputTree/ValueInput/UnserializableValueInput.d.ts +6 -0
- package/dist/components/ValueInputTree/ValueInput/UnserializableValueInput.js +11 -0
- package/dist/components/ValueInputTree/ValueInput/ValueInput.d.ts +11 -0
- package/dist/components/ValueInputTree/ValueInput/ValueInput.js +30 -0
- package/dist/components/ValueInputTree/ValueInput/shared.d.ts +6 -0
- package/dist/components/ValueInputTree/ValueInput/shared.js +41 -0
- package/dist/components/ValueInputTree/ValueInputDir.d.ts +9 -0
- package/dist/components/ValueInputTree/ValueInputDir.js +68 -0
- package/dist/components/ValueInputTree/ValueInputTree.d.ts +12 -0
- package/dist/components/ValueInputTree/ValueInputTree.js +32 -0
- package/dist/components/ValueInputTree/index.d.ts +4 -0
- package/dist/components/ValueInputTree/index.js +4 -0
- package/dist/components/ValueInputTree/shared.d.ts +16 -0
- package/dist/components/ValueInputTree/shared.js +15 -0
- package/dist/components/ValueInputTree/valueGroups.d.ts +8 -0
- package/dist/components/ValueInputTree/valueGroups.js +10 -0
- package/dist/components/ValueInputTree/valueTree.d.ts +3 -0
- package/dist/components/ValueInputTree/valueTree.js +20 -0
- package/dist/components/ValueInputTree/valueTreeExpansion.d.ts +7 -0
- package/dist/components/ValueInputTree/valueTreeExpansion.js +16 -0
- package/dist/components/buttons/Button32.d.ts +11 -0
- package/dist/components/buttons/Button32.js +8 -0
- package/dist/components/buttons/Button8.d.ts +11 -0
- package/dist/components/buttons/Button8.js +8 -0
- package/dist/components/buttons/IconButton32.d.ts +10 -0
- package/dist/components/buttons/IconButton32.js +7 -0
- package/dist/components/buttons/IconButton8.d.ts +10 -0
- package/dist/components/buttons/IconButton8.js +7 -0
- package/dist/components/buttons/index.d.ts +4 -0
- package/dist/components/buttons/index.js +4 -0
- package/dist/components/buttons/shared.d.ts +15 -0
- package/dist/components/buttons/shared.js +52 -0
- package/dist/components/icons/index.d.ts +33 -0
- package/dist/components/icons/index.js +107 -0
- package/dist/components/illustrations/ArtificialIntelligence.d.ts +3 -0
- package/dist/components/illustrations/ArtificialIntelligence.js +123 -0
- package/dist/components/illustrations/Astronaut.d.ts +3 -0
- package/dist/components/illustrations/Astronaut.js +72 -0
- package/dist/components/illustrations/BlankCanvas.d.ts +3 -0
- package/dist/components/illustrations/BlankCanvas.js +75 -0
- package/dist/components/inputs/NumberInput.d.ts +15 -0
- package/dist/components/inputs/NumberInput.js +79 -0
- package/dist/components/inputs/Select.d.ts +16 -0
- package/dist/components/inputs/Select.js +69 -0
- package/dist/components/inputs/shared.d.ts +14 -0
- package/dist/components/inputs/shared.js +43 -0
- package/dist/cosmos.decorator.d.ts +5 -0
- package/dist/cosmos.decorator.js +6 -0
- package/dist/cosmos.loadPlugins.d.ts +1 -0
- package/dist/cosmos.loadPlugins.js +17 -0
- package/dist/hooks/useDrag.d.ts +14 -0
- package/dist/hooks/useDrag.js +58 -0
- package/dist/hooks/useFocus.d.ts +5 -0
- package/dist/hooks/useFocus.js +7 -0
- package/dist/index.d.ts +36 -0
- package/dist/index.js +36 -0
- package/dist/playground.bundle.js +1358 -0
- package/dist/playground.bundle.js.LICENSE.txt +64 -0
- package/dist/playground.bundle.js.map +1 -0
- package/dist/playground.d.ts +11 -0
- package/dist/playground.js +36 -0
- package/dist/playgroundConfig.d.ts +10 -0
- package/dist/playgroundConfig.js +1 -0
- package/dist/plugins/BuildNotifications/index.d.ts +2 -0
- package/dist/plugins/BuildNotifications/index.js +35 -0
- package/dist/plugins/BuildNotifications/spec.d.ts +3 -0
- package/dist/plugins/BuildNotifications/spec.js +1 -0
- package/dist/plugins/ClassStatePanel/ClassStatePanel/ComponentClassState.d.ts +10 -0
- package/dist/plugins/ClassStatePanel/ClassStatePanel/ComponentClassState.js +36 -0
- package/dist/plugins/ClassStatePanel/ClassStatePanel/index.d.ts +11 -0
- package/dist/plugins/ClassStatePanel/ClassStatePanel/index.js +13 -0
- package/dist/plugins/ClassStatePanel/ClassStatePanel/shared.d.ts +2 -0
- package/dist/plugins/ClassStatePanel/ClassStatePanel/shared.js +16 -0
- package/dist/plugins/ClassStatePanel/index.d.ts +2 -0
- package/dist/plugins/ClassStatePanel/index.js +30 -0
- package/dist/plugins/ClassStatePanel/shared.d.ts +1 -0
- package/dist/plugins/ClassStatePanel/shared.js +1 -0
- package/dist/plugins/ClassStatePanel/spec.d.ts +3 -0
- package/dist/plugins/ClassStatePanel/spec.js +1 -0
- package/dist/plugins/ContentOverlay/ContentOverlay.d.ts +13 -0
- package/dist/plugins/ContentOverlay/ContentOverlay.js +34 -0
- package/dist/plugins/ContentOverlay/KeyShortcut.d.ts +6 -0
- package/dist/plugins/ContentOverlay/KeyShortcut.js +30 -0
- package/dist/plugins/ContentOverlay/NoFixtureSelected.d.ts +5 -0
- package/dist/plugins/ContentOverlay/NoFixtureSelected.js +34 -0
- package/dist/plugins/ContentOverlay/RendererNotResponding.d.ts +1 -0
- package/dist/plugins/ContentOverlay/RendererNotResponding.js +109 -0
- package/dist/plugins/ContentOverlay/WelcomeCosmos.d.ts +5 -0
- package/dist/plugins/ContentOverlay/WelcomeCosmos.js +158 -0
- package/dist/plugins/ContentOverlay/cosmos.decorator.d.ts +5 -0
- package/dist/plugins/ContentOverlay/cosmos.decorator.js +13 -0
- package/dist/plugins/ContentOverlay/index.d.ts +2 -0
- package/dist/plugins/ContentOverlay/index.js +19 -0
- package/dist/plugins/ContentOverlay/shared.d.ts +9 -0
- package/dist/plugins/ContentOverlay/shared.js +75 -0
- package/dist/plugins/ContentOverlay/spec.d.ts +3 -0
- package/dist/plugins/ContentOverlay/spec.js +1 -0
- package/dist/plugins/ContentOverlay/welcomeDismiss.d.ts +7 -0
- package/dist/plugins/ContentOverlay/welcomeDismiss.js +17 -0
- package/dist/plugins/ControlPanel/ControlPanel.d.ts +8 -0
- package/dist/plugins/ControlPanel/ControlPanel.js +37 -0
- package/dist/plugins/ControlPanel/index.d.ts +2 -0
- package/dist/plugins/ControlPanel/index.js +17 -0
- package/dist/plugins/ControlPanel/spec.d.ts +6 -0
- package/dist/plugins/ControlPanel/spec.js +1 -0
- package/dist/plugins/ControlSelect/SelectValueInput.d.ts +8 -0
- package/dist/plugins/ControlSelect/SelectValueInput.js +15 -0
- package/dist/plugins/ControlSelect/index.d.ts +2 -0
- package/dist/plugins/ControlSelect/index.js +22 -0
- package/dist/plugins/ControlSelect/spec.d.ts +3 -0
- package/dist/plugins/ControlSelect/spec.js +1 -0
- package/dist/plugins/Core/index.d.ts +2 -0
- package/dist/plugins/Core/index.js +68 -0
- package/dist/plugins/Core/spec.d.ts +25 -0
- package/dist/plugins/Core/spec.js +1 -0
- package/dist/plugins/FixtureBookmark/BookmarkFixtureButton.d.ts +6 -0
- package/dist/plugins/FixtureBookmark/BookmarkFixtureButton.js +6 -0
- package/dist/plugins/FixtureBookmark/FixtureBookmarks.d.ts +10 -0
- package/dist/plugins/FixtureBookmark/FixtureBookmarks.js +123 -0
- package/dist/plugins/FixtureBookmark/index.d.ts +2 -0
- package/dist/plugins/FixtureBookmark/index.js +46 -0
- package/dist/plugins/FixtureBookmark/spec.d.ts +3 -0
- package/dist/plugins/FixtureBookmark/spec.js +1 -0
- package/dist/plugins/FixtureSearch/FixtureSearchHeader.d.ts +7 -0
- package/dist/plugins/FixtureSearch/FixtureSearchHeader.js +66 -0
- package/dist/plugins/FixtureSearch/FixtureSearchOverlay.d.ts +13 -0
- package/dist/plugins/FixtureSearch/FixtureSearchOverlay.js +312 -0
- package/dist/plugins/FixtureSearch/FixtureSearchResult.d.ts +9 -0
- package/dist/plugins/FixtureSearch/FixtureSearchResult.js +48 -0
- package/dist/plugins/FixtureSearch/FixtureSearchShortcuts.d.ts +1 -0
- package/dist/plugins/FixtureSearch/FixtureSearchShortcuts.js +60 -0
- package/dist/plugins/FixtureSearch/index.d.ts +2 -0
- package/dist/plugins/FixtureSearch/index.js +72 -0
- package/dist/plugins/FixtureSearch/spec.d.ts +7 -0
- package/dist/plugins/FixtureSearch/spec.js +1 -0
- package/dist/plugins/FixtureTree/BlankState.d.ts +8 -0
- package/dist/plugins/FixtureTree/BlankState.js +75 -0
- package/dist/plugins/FixtureTree/FixtureTree/FixtureButton.d.ts +12 -0
- package/dist/plugins/FixtureTree/FixtureTree/FixtureButton.js +16 -0
- package/dist/plugins/FixtureTree/FixtureTree/FixtureDir.d.ts +9 -0
- package/dist/plugins/FixtureTree/FixtureTree/FixtureDir.js +46 -0
- package/dist/plugins/FixtureTree/FixtureTree/FixtureLink.d.ts +9 -0
- package/dist/plugins/FixtureTree/FixtureTree/FixtureLink.js +34 -0
- package/dist/plugins/FixtureTree/FixtureTree/FixtureTree.d.ts +13 -0
- package/dist/plugins/FixtureTree/FixtureTree/FixtureTree.js +37 -0
- package/dist/plugins/FixtureTree/FixtureTree/FixtureTreeItem.d.ts +6 -0
- package/dist/plugins/FixtureTree/FixtureTree/FixtureTreeItem.js +24 -0
- package/dist/plugins/FixtureTree/FixtureTree/MultiFixtureButton.d.ts +13 -0
- package/dist/plugins/FixtureTree/FixtureTree/MultiFixtureButton.js +46 -0
- package/dist/plugins/FixtureTree/FixtureTree/MultiFixtureChildButton.d.ts +12 -0
- package/dist/plugins/FixtureTree/FixtureTree/MultiFixtureChildButton.js +26 -0
- package/dist/plugins/FixtureTree/FixtureTreeContainer.d.ts +14 -0
- package/dist/plugins/FixtureTree/FixtureTreeContainer.js +28 -0
- package/dist/plugins/FixtureTree/FixtureTreeHeader.d.ts +11 -0
- package/dist/plugins/FixtureTree/FixtureTreeHeader.js +33 -0
- package/dist/plugins/FixtureTree/index.d.ts +2 -0
- package/dist/plugins/FixtureTree/index.js +25 -0
- package/dist/plugins/FixtureTree/revealFixture.d.ts +3 -0
- package/dist/plugins/FixtureTree/revealFixture.js +48 -0
- package/dist/plugins/FixtureTree/shared.d.ts +7 -0
- package/dist/plugins/FixtureTree/shared.js +8 -0
- package/dist/plugins/FixtureTree/spec.d.ts +7 -0
- package/dist/plugins/FixtureTree/spec.js +1 -0
- package/dist/plugins/FixtureTree/useScrollToSelected.d.ts +6 -0
- package/dist/plugins/FixtureTree/useScrollToSelected.js +18 -0
- package/dist/plugins/FullScreenButton/FullScreenButton.d.ts +5 -0
- package/dist/plugins/FullScreenButton/FullScreenButton.js +6 -0
- package/dist/plugins/FullScreenButton/index.d.ts +2 -0
- package/dist/plugins/FullScreenButton/index.js +25 -0
- package/dist/plugins/FullScreenButton/spec.d.ts +3 -0
- package/dist/plugins/FullScreenButton/spec.js +1 -0
- package/dist/plugins/MessageHandler/index.d.ts +2 -0
- package/dist/plugins/MessageHandler/index.js +12 -0
- package/dist/plugins/MessageHandler/shared.d.ts +3 -0
- package/dist/plugins/MessageHandler/shared.js +1 -0
- package/dist/plugins/MessageHandler/socket.d.ts +4 -0
- package/dist/plugins/MessageHandler/socket.js +45 -0
- package/dist/plugins/MessageHandler/spec.d.ts +11 -0
- package/dist/plugins/MessageHandler/spec.js +1 -0
- package/dist/plugins/Notifications/Notifications.d.ts +6 -0
- package/dist/plugins/Notifications/Notifications.js +75 -0
- package/dist/plugins/Notifications/index.d.ts +2 -0
- package/dist/plugins/Notifications/index.js +36 -0
- package/dist/plugins/Notifications/pushNotification.d.ts +6 -0
- package/dist/plugins/Notifications/pushNotification.js +40 -0
- package/dist/plugins/Notifications/shared.d.ts +3 -0
- package/dist/plugins/Notifications/shared.js +1 -0
- package/dist/plugins/Notifications/spec.d.ts +22 -0
- package/dist/plugins/Notifications/spec.js +1 -0
- package/dist/plugins/PluginList/PluginList.d.ts +10 -0
- package/dist/plugins/PluginList/PluginList.js +38 -0
- package/dist/plugins/PluginList/index.d.ts +2 -0
- package/dist/plugins/PluginList/index.js +12 -0
- package/dist/plugins/PluginList/spec.d.ts +3 -0
- package/dist/plugins/PluginList/spec.js +1 -0
- package/dist/plugins/PropsPanel/BlankState.d.ts +3 -0
- package/dist/plugins/PropsPanel/BlankState.js +47 -0
- package/dist/plugins/PropsPanel/PropsPanel/ComponentProps.d.ts +10 -0
- package/dist/plugins/PropsPanel/PropsPanel/ComponentProps.js +40 -0
- package/dist/plugins/PropsPanel/PropsPanel/index.d.ts +11 -0
- package/dist/plugins/PropsPanel/PropsPanel/index.js +13 -0
- package/dist/plugins/PropsPanel/PropsPanel/shared.d.ts +2 -0
- package/dist/plugins/PropsPanel/PropsPanel/shared.js +16 -0
- package/dist/plugins/PropsPanel/index.d.ts +2 -0
- package/dist/plugins/PropsPanel/index.js +55 -0
- package/dist/plugins/PropsPanel/shared.d.ts +1 -0
- package/dist/plugins/PropsPanel/shared.js +1 -0
- package/dist/plugins/PropsPanel/spec.d.ts +3 -0
- package/dist/plugins/PropsPanel/spec.js +1 -0
- package/dist/plugins/RemoteRenderer/RemoteButton/copyToClipboard.d.ts +1 -0
- package/dist/plugins/RemoteRenderer/RemoteButton/copyToClipboard.js +24 -0
- package/dist/plugins/RemoteRenderer/RemoteButton/index.d.ts +8 -0
- package/dist/plugins/RemoteRenderer/RemoteButton/index.js +37 -0
- package/dist/plugins/RemoteRenderer/index.d.ts +2 -0
- package/dist/plugins/RemoteRenderer/index.js +36 -0
- package/dist/plugins/RemoteRenderer/shared.d.ts +3 -0
- package/dist/plugins/RemoteRenderer/shared.js +1 -0
- package/dist/plugins/RemoteRenderer/spec.d.ts +3 -0
- package/dist/plugins/RemoteRenderer/spec.js +1 -0
- package/dist/plugins/RendererCore/index.d.ts +2 -0
- package/dist/plugins/RendererCore/index.js +47 -0
- package/dist/plugins/RendererCore/isValidFixtureSelected.d.ts +2 -0
- package/dist/plugins/RendererCore/isValidFixtureSelected.js +16 -0
- package/dist/plugins/RendererCore/onRouterFixtureChange.d.ts +3 -0
- package/dist/plugins/RendererCore/onRouterFixtureChange.js +18 -0
- package/dist/plugins/RendererCore/receiveResponse/fixtureListUpdate.d.ts +3 -0
- package/dist/plugins/RendererCore/receiveResponse/fixtureListUpdate.js +11 -0
- package/dist/plugins/RendererCore/receiveResponse/fixtureStateChange.d.ts +3 -0
- package/dist/plugins/RendererCore/receiveResponse/fixtureStateChange.js +30 -0
- package/dist/plugins/RendererCore/receiveResponse/index.d.ts +3 -0
- package/dist/plugins/RendererCore/receiveResponse/index.js +20 -0
- package/dist/plugins/RendererCore/receiveResponse/playgroundCommand.d.ts +3 -0
- package/dist/plugins/RendererCore/receiveResponse/playgroundCommand.js +5 -0
- package/dist/plugins/RendererCore/receiveResponse/rendererReady.d.ts +3 -0
- package/dist/plugins/RendererCore/receiveResponse/rendererReady.js +49 -0
- package/dist/plugins/RendererCore/setFixtureState.d.ts +3 -0
- package/dist/plugins/RendererCore/setFixtureState.js +22 -0
- package/dist/plugins/RendererCore/shared/index.d.ts +4 -0
- package/dist/plugins/RendererCore/shared/index.js +1 -0
- package/dist/plugins/RendererCore/shared/postRequest.d.ts +5 -0
- package/dist/plugins/RendererCore/shared/postRequest.js +31 -0
- package/dist/plugins/RendererCore/shared/router.d.ts +2 -0
- package/dist/plugins/RendererCore/shared/router.js +3 -0
- package/dist/plugins/RendererCore/spec.d.ts +25 -0
- package/dist/plugins/RendererCore/spec.js +1 -0
- package/dist/plugins/RendererPreview/RendererPreview.d.ts +8 -0
- package/dist/plugins/RendererPreview/RendererPreview.js +25 -0
- package/dist/plugins/RendererPreview/checkRendererStatus.d.ts +2 -0
- package/dist/plugins/RendererPreview/checkRendererStatus.js +31 -0
- package/dist/plugins/RendererPreview/handleRendererRequests.d.ts +6 -0
- package/dist/plugins/RendererPreview/handleRendererRequests.js +76 -0
- package/dist/plugins/RendererPreview/handleWindowMessages.d.ts +2 -0
- package/dist/plugins/RendererPreview/handleWindowMessages.js +56 -0
- package/dist/plugins/RendererPreview/index.d.ts +2 -0
- package/dist/plugins/RendererPreview/index.js +49 -0
- package/dist/plugins/RendererPreview/shared.d.ts +9 -0
- package/dist/plugins/RendererPreview/shared.js +1 -0
- package/dist/plugins/RendererPreview/spec.d.ts +13 -0
- package/dist/plugins/RendererPreview/spec.js +1 -0
- package/dist/plugins/RendererSelect/index.d.ts +2 -0
- package/dist/plugins/RendererSelect/index.js +27 -0
- package/dist/plugins/RendererSelect/spec.d.ts +3 -0
- package/dist/plugins/RendererSelect/spec.js +1 -0
- package/dist/plugins/ResponsivePreview/ResponsivePreview/Header.d.ts +13 -0
- package/dist/plugins/ResponsivePreview/ResponsivePreview/Header.js +97 -0
- package/dist/plugins/ResponsivePreview/ResponsivePreview/ResponsivePreview.d.ts +14 -0
- package/dist/plugins/ResponsivePreview/ResponsivePreview/ResponsivePreview.js +152 -0
- package/dist/plugins/ResponsivePreview/ResponsivePreview/style.d.ts +45 -0
- package/dist/plugins/ResponsivePreview/ResponsivePreview/style.js +79 -0
- package/dist/plugins/ResponsivePreview/ToggleButton/index.d.ts +6 -0
- package/dist/plugins/ResponsivePreview/ToggleButton/index.js +6 -0
- package/dist/plugins/ResponsivePreview/index.d.ts +2 -0
- package/dist/plugins/ResponsivePreview/index.js +79 -0
- package/dist/plugins/ResponsivePreview/shared.d.ts +21 -0
- package/dist/plugins/ResponsivePreview/shared.js +19 -0
- package/dist/plugins/ResponsivePreview/spec.d.ts +13 -0
- package/dist/plugins/ResponsivePreview/spec.js +1 -0
- package/dist/plugins/Root/GlobalHeader.d.ts +9 -0
- package/dist/plugins/Root/GlobalHeader.js +59 -0
- package/dist/plugins/Root/RendererHeader.d.ts +16 -0
- package/dist/plugins/Root/RendererHeader.js +79 -0
- package/dist/plugins/Root/Root.d.ts +28 -0
- package/dist/plugins/Root/Root.js +120 -0
- package/dist/plugins/Root/SidePanel.d.ts +10 -0
- package/dist/plugins/Root/SidePanel.js +26 -0
- package/dist/plugins/Root/ToggleNavButton.d.ts +7 -0
- package/dist/plugins/Root/ToggleNavButton.js +6 -0
- package/dist/plugins/Root/index.d.ts +2 -0
- package/dist/plugins/Root/index.js +73 -0
- package/dist/plugins/Root/navOpen.d.ts +4 -0
- package/dist/plugins/Root/navOpen.js +11 -0
- package/dist/plugins/Root/navWidth.d.ts +5 -0
- package/dist/plugins/Root/navWidth.js +14 -0
- package/dist/plugins/Root/panelOpen.d.ts +4 -0
- package/dist/plugins/Root/panelOpen.js +16 -0
- package/dist/plugins/Root/panelWidth.d.ts +5 -0
- package/dist/plugins/Root/panelWidth.js +14 -0
- package/dist/plugins/Root/shared.d.ts +3 -0
- package/dist/plugins/Root/shared.js +1 -0
- package/dist/plugins/Root/spec.d.ts +14 -0
- package/dist/plugins/Root/spec.js +1 -0
- package/dist/plugins/Router/index.d.ts +2 -0
- package/dist/plugins/Router/index.js +56 -0
- package/dist/plugins/Router/spec.d.ts +15 -0
- package/dist/plugins/Router/spec.js +1 -0
- package/dist/plugins/StandardControl/index.d.ts +2 -0
- package/dist/plugins/StandardControl/index.js +43 -0
- package/dist/plugins/StandardControl/spec.d.ts +3 -0
- package/dist/plugins/StandardControl/spec.js +1 -0
- package/dist/plugins/StandardControl/storage.d.ts +7 -0
- package/dist/plugins/StandardControl/storage.js +10 -0
- package/dist/plugins/Storage/index.d.ts +2 -0
- package/dist/plugins/Storage/index.js +40 -0
- package/dist/plugins/Storage/spec.d.ts +18 -0
- package/dist/plugins/Storage/spec.js +1 -0
- package/dist/plugins/pluginEntry.d.ts +23 -0
- package/dist/plugins/pluginEntry.js +29 -0
- package/dist/shared/defaultPluginConfig.d.ts +13 -0
- package/dist/shared/defaultPluginConfig.js +13 -0
- package/dist/shared/fixtureTree.d.ts +3 -0
- package/dist/shared/fixtureTree.js +12 -0
- package/dist/shared/treeExpansion.d.ts +7 -0
- package/dist/shared/treeExpansion.js +24 -0
- package/dist/shared/url.d.ts +5 -0
- package/dist/shared/url.js +33 -0
- package/dist/slots/ControlActionSlot.d.ts +10 -0
- package/dist/slots/ControlActionSlot.js +5 -0
- package/dist/slots/ControlSlot.d.ts +11 -0
- package/dist/slots/ControlSlot.js +5 -0
- package/dist/slots/FixtureActionSlot.d.ts +10 -0
- package/dist/slots/FixtureActionSlot.js +5 -0
- package/dist/slots/NavRowSlot.d.ts +9 -0
- package/dist/slots/NavRowSlot.js +5 -0
- package/dist/slots/RendererActionSlot.d.ts +10 -0
- package/dist/slots/RendererActionSlot.js +5 -0
- package/dist/slots/SidePanelRowSlot.d.ts +12 -0
- package/dist/slots/SidePanelRowSlot.js +5 -0
- package/dist/slots/ValueInputSlot.d.ts +16 -0
- package/dist/slots/ValueInputSlot.js +5 -0
- package/dist/style/colors.d.ts +37 -0
- package/dist/style/colors.js +43 -0
- package/dist/style/globalStyle.d.ts +2 -0
- package/dist/style/globalStyle.js +49 -0
- package/dist/style/vars.d.ts +2 -0
- package/dist/style/vars.js +2 -0
- package/dist/testHelpers/pluginHelpers.d.ts +5 -0
- package/dist/testHelpers/pluginHelpers.js +25 -0
- package/dist/testHelpers/pluginMocks.d.ts +116 -0
- package/dist/testHelpers/pluginMocks.js +139 -0
- package/package.json +24 -0
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { isEqual } from 'lodash-es';
|
|
2
|
+
import React, { useCallback } from 'react';
|
|
3
|
+
import { resetFixtureStateProps, updateFixtureStateProps, } from 'react-cosmos-core';
|
|
4
|
+
import { IconButton32 } from '../../../components/buttons/index.js';
|
|
5
|
+
import { CopyIcon, RotateCcwIcon } from '../../../components/icons/index.js';
|
|
6
|
+
import { SidePanelActions, SidePanelBody, SidePanelContainer, SidePanelHeader, SidePanelTitle, } from '../../../components/SidePanel.js';
|
|
7
|
+
import { ExpandCollapseValues } from '../../../components/ValueInputTree/ExpandCollapseValues.js';
|
|
8
|
+
import { stringifyElementId, ValueInputTree, } from '../../../components/ValueInputTree/index.js';
|
|
9
|
+
import { createPropsFsUpdater } from './shared.js';
|
|
10
|
+
export function ComponentProps({ fsProps, fixtureExpansion, onFixtureStateChange, onElementExpansionChange, }) {
|
|
11
|
+
const { componentName, elementId, values } = fsProps;
|
|
12
|
+
const [reset, setReset] = React.useState(true);
|
|
13
|
+
const handleResetToggle = React.useCallback(() => setReset(!reset), [reset]);
|
|
14
|
+
const [initialValues] = React.useState(() => values);
|
|
15
|
+
const handleValuesReset = React.useCallback(() => onFixtureStateChange(createPropsFsUpdater(elementId, prevFs => resetFixtureStateProps({
|
|
16
|
+
fixtureState: prevFs,
|
|
17
|
+
elementId,
|
|
18
|
+
values: initialValues,
|
|
19
|
+
}))), [elementId, initialValues, onFixtureStateChange]);
|
|
20
|
+
const handleValueChange = React.useCallback((newValues) => {
|
|
21
|
+
const changeFn = reset ? resetFixtureStateProps : updateFixtureStateProps;
|
|
22
|
+
onFixtureStateChange(createPropsFsUpdater(elementId, prevFs => changeFn({
|
|
23
|
+
fixtureState: prevFs,
|
|
24
|
+
elementId,
|
|
25
|
+
values: newValues,
|
|
26
|
+
})));
|
|
27
|
+
}, [elementId, reset, onFixtureStateChange]);
|
|
28
|
+
const strElementId = stringifyElementId(elementId);
|
|
29
|
+
const expansion = fixtureExpansion[strElementId] || {};
|
|
30
|
+
const setExpansion = useCallback((newExpansion) => onElementExpansionChange(elementId, newExpansion), [elementId, onElementExpansionChange]);
|
|
31
|
+
return (React.createElement(SidePanelContainer, null,
|
|
32
|
+
React.createElement(SidePanelHeader, null,
|
|
33
|
+
React.createElement(SidePanelTitle, { label: "Props", componentName: componentName }),
|
|
34
|
+
React.createElement(SidePanelActions, null,
|
|
35
|
+
React.createElement(IconButton32, { title: "Reset to initial values", icon: React.createElement(RotateCcwIcon, null), disabled: isEqual(values, initialValues), onClick: handleValuesReset }),
|
|
36
|
+
React.createElement(IconButton32, { title: "Reuse instances on prop changes", icon: React.createElement(CopyIcon, null), selected: !reset, disabled: false, onClick: handleResetToggle }),
|
|
37
|
+
React.createElement(ExpandCollapseValues, { values: values, expansion: expansion, setExpansion: setExpansion }))),
|
|
38
|
+
React.createElement(SidePanelBody, null,
|
|
39
|
+
React.createElement(ValueInputTree, { id: strElementId, values: values, expansion: expansion, setExpansion: setExpansion, onValueChange: handleValueChange }))));
|
|
40
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { FixtureState, StateUpdater } from 'react-cosmos-core';
|
|
3
|
+
import { FixtureExpansion, OnElementExpansionChange } from '../../../components/ValueInputTree/index.js';
|
|
4
|
+
type Props = {
|
|
5
|
+
fixtureState: FixtureState;
|
|
6
|
+
fixtureExpansion: FixtureExpansion;
|
|
7
|
+
onFixtureStateChange: (stateUpdater: StateUpdater<FixtureState>) => void;
|
|
8
|
+
onElementExpansionChange: OnElementExpansionChange;
|
|
9
|
+
};
|
|
10
|
+
export declare const PropsPanel: React.NamedExoticComponent<Props>;
|
|
11
|
+
export {};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { hasFsValues, sortFsValueGroups, stringifyElementId, } from '../../../components/ValueInputTree/index.js';
|
|
3
|
+
import { ComponentProps } from './ComponentProps.js';
|
|
4
|
+
export const PropsPanel = React.memo(function PropsPanel({ fixtureState, fixtureExpansion, onFixtureStateChange, onElementExpansionChange, }) {
|
|
5
|
+
if (!fixtureState.props) {
|
|
6
|
+
return null;
|
|
7
|
+
}
|
|
8
|
+
const propsWithValues = fixtureState.props.filter(hasFsValues);
|
|
9
|
+
return (React.createElement(React.Fragment, null, sortFsValueGroups(propsWithValues).map(fsProps => {
|
|
10
|
+
const strElementId = stringifyElementId(fsProps.elementId);
|
|
11
|
+
return (React.createElement(ComponentProps, { key: strElementId, fsProps: fsProps, fixtureExpansion: fixtureExpansion, onFixtureStateChange: onFixtureStateChange, onElementExpansionChange: onElementExpansionChange }));
|
|
12
|
+
})));
|
|
13
|
+
});
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { findFixtureStateProps, } from 'react-cosmos-core';
|
|
2
|
+
import { stringifyElementId } from '../../../components/ValueInputTree/index.js';
|
|
3
|
+
export function createPropsFsUpdater(elementId, cb) {
|
|
4
|
+
return prevFs => {
|
|
5
|
+
const fsProps = findFixtureStateProps(prevFs, elementId);
|
|
6
|
+
if (!fsProps) {
|
|
7
|
+
const elId = stringifyElementId(elementId);
|
|
8
|
+
console.warn(`Trying to update missing element with ID: ${elId}`);
|
|
9
|
+
return prevFs;
|
|
10
|
+
}
|
|
11
|
+
return {
|
|
12
|
+
...prevFs,
|
|
13
|
+
props: cb(prevFs),
|
|
14
|
+
};
|
|
15
|
+
};
|
|
16
|
+
}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { createPlugin } from 'react-plugin';
|
|
3
|
+
import { getFixtureExpansion, hasFsValues, updateElementExpansion, } from '../../components/ValueInputTree/index.js';
|
|
4
|
+
import { BlankState } from './BlankState.js';
|
|
5
|
+
import { PropsPanel } from './PropsPanel/index.js';
|
|
6
|
+
import { PROPS_TREE_EXPANSION_STORAGE_KEY } from './shared.js';
|
|
7
|
+
const { namedPlug, register } = createPlugin({
|
|
8
|
+
name: 'propsPanel',
|
|
9
|
+
});
|
|
10
|
+
namedPlug('sidePanelRow', 'props', ({ pluginContext, slotProps }) => {
|
|
11
|
+
const { fixtureId, fixtureState, onFixtureStateChange } = slotProps;
|
|
12
|
+
const { fixtureExpansion, onElementExpansionChange } = useFixtureExpansion(pluginContext, fixtureId);
|
|
13
|
+
return (React.createElement(PropsPanel, { fixtureState: fixtureState, fixtureExpansion: fixtureExpansion, onFixtureStateChange: onFixtureStateChange, onElementExpansionChange: onElementExpansionChange }));
|
|
14
|
+
});
|
|
15
|
+
// WARNING: This plug has to be aware of all control types and only show up
|
|
16
|
+
// when none is available
|
|
17
|
+
// TODO: Replace this with a more generic blank state (controls in general not
|
|
18
|
+
// just props)
|
|
19
|
+
namedPlug('sidePanelRow', 'blankState', ({ slotProps }) => {
|
|
20
|
+
const { fixtureState } = slotProps;
|
|
21
|
+
return shouldShowBlankState(fixtureState) ? React.createElement(BlankState, null) : null;
|
|
22
|
+
});
|
|
23
|
+
export { register };
|
|
24
|
+
if (process.env.NODE_ENV !== 'test')
|
|
25
|
+
register();
|
|
26
|
+
const DEFAULT_TREE_EXPANSION = {};
|
|
27
|
+
function useFixtureExpansion(context, fixtureId) {
|
|
28
|
+
const { getMethodsOf } = context;
|
|
29
|
+
const storage = getMethodsOf('storage');
|
|
30
|
+
const propsExpansion = storage.getItem(PROPS_TREE_EXPANSION_STORAGE_KEY) ||
|
|
31
|
+
DEFAULT_TREE_EXPANSION;
|
|
32
|
+
const fixtureExpansion = getFixtureExpansion(propsExpansion, fixtureId);
|
|
33
|
+
const onElementExpansionChange = React.useCallback((elementId, treeExpansion) => {
|
|
34
|
+
storage.setItem(PROPS_TREE_EXPANSION_STORAGE_KEY, updateElementExpansion(propsExpansion, fixtureId, elementId, treeExpansion));
|
|
35
|
+
}, [storage, propsExpansion, fixtureId]);
|
|
36
|
+
return {
|
|
37
|
+
fixtureExpansion,
|
|
38
|
+
onElementExpansionChange,
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
function shouldShowBlankState(fixtureState) {
|
|
42
|
+
// Don't show blank state until props (empty or not) have been read
|
|
43
|
+
if (!fixtureState.props)
|
|
44
|
+
return false;
|
|
45
|
+
const hasProps = fixtureState.props.some(hasFsValues);
|
|
46
|
+
if (hasProps)
|
|
47
|
+
return false;
|
|
48
|
+
const hasClassState = fixtureState.classState && fixtureState.classState.some(hasFsValues);
|
|
49
|
+
if (hasClassState)
|
|
50
|
+
return false;
|
|
51
|
+
const hasControls = fixtureState.controls && Object.keys(fixtureState.controls).length > 0;
|
|
52
|
+
if (hasControls)
|
|
53
|
+
return false;
|
|
54
|
+
return true;
|
|
55
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const PROPS_TREE_EXPANSION_STORAGE_KEY = "propsTreeExpansion";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const PROPS_TREE_EXPANSION_STORAGE_KEY = 'propsTreeExpansion';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function copyToClipboard(text: string): Promise<void>;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
export async function copyToClipboard(text) {
|
|
2
|
+
const { permissions, clipboard } = navigator;
|
|
3
|
+
let permissionDenied = false;
|
|
4
|
+
try {
|
|
5
|
+
// @ts-ignore Sorry, TS, MDN begs to differ https://developer.mozilla.org/en-US/docs/Web/API/Permissions/query#Parameters
|
|
6
|
+
const { state } = await permissions.query({ name: 'clipboard-write' });
|
|
7
|
+
permissionDenied = state !== 'granted' && state !== 'prompt';
|
|
8
|
+
}
|
|
9
|
+
catch (err) {
|
|
10
|
+
// Some browsers (eg. Firefox 66) don't support the 'clipboard'
|
|
11
|
+
// PermissionDescriptor but support clipboard.writeText. So unless
|
|
12
|
+
// permission is explicitly denied, we try to copy to clipboard even if the
|
|
13
|
+
// permission check failed.
|
|
14
|
+
}
|
|
15
|
+
if (permissionDenied) {
|
|
16
|
+
throw new Error('Permission denied to write to clipboard');
|
|
17
|
+
}
|
|
18
|
+
try {
|
|
19
|
+
await clipboard.writeText(text);
|
|
20
|
+
}
|
|
21
|
+
catch (err) {
|
|
22
|
+
throw new Error('Failed to write to clipboard');
|
|
23
|
+
}
|
|
24
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { NotificationItem } from '../../Notifications/spec.js';
|
|
2
|
+
type Props = {
|
|
3
|
+
devServerOn: boolean;
|
|
4
|
+
webRendererUrl: null | string;
|
|
5
|
+
pushNotification: (notification: NotificationItem) => unknown;
|
|
6
|
+
};
|
|
7
|
+
export declare function RemoteButton({ devServerOn, webRendererUrl, pushNotification, }: Props): JSX.Element | null;
|
|
8
|
+
export {};
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { IconButton32 } from '../../../components/buttons/index.js';
|
|
3
|
+
import { CastIcon } from '../../../components/icons/index.js';
|
|
4
|
+
import { copyToClipboard } from './copyToClipboard.js';
|
|
5
|
+
export function RemoteButton({ devServerOn, webRendererUrl, pushNotification, }) {
|
|
6
|
+
if (!devServerOn || !webRendererUrl) {
|
|
7
|
+
return null;
|
|
8
|
+
}
|
|
9
|
+
return (React.createElement(IconButton32, { icon: React.createElement(CastIcon, null), title: "Copy remote renderer URL", onClick: () => copyRendererUrlToClipboard(webRendererUrl) }));
|
|
10
|
+
async function copyRendererUrlToClipboard(url) {
|
|
11
|
+
const fullUrl = getFullUrl(url);
|
|
12
|
+
try {
|
|
13
|
+
await copyToClipboard(fullUrl);
|
|
14
|
+
pushNotification({
|
|
15
|
+
id: 'renderer-url-copy',
|
|
16
|
+
type: 'success',
|
|
17
|
+
title: `Renderer URL copied to clipboard`,
|
|
18
|
+
info: 'Paste the renderer URL in the address bar of another browser.',
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
catch (err) {
|
|
22
|
+
pushNotification({
|
|
23
|
+
id: 'renderer-url-copy',
|
|
24
|
+
type: 'error',
|
|
25
|
+
title: `Failed to copy renderer URL to clipboard`,
|
|
26
|
+
info: 'Make sure your browser supports clipboard operations.',
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
function getFullUrl(rendererUrl) {
|
|
32
|
+
// Renderer URL can be absolute or relative, depending on whether the renderer
|
|
33
|
+
// is running on the same host/port as the playground
|
|
34
|
+
if (rendererUrl.startsWith('http'))
|
|
35
|
+
return rendererUrl;
|
|
36
|
+
return `${location.origin}${rendererUrl}`;
|
|
37
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { createPlugin } from 'react-plugin';
|
|
3
|
+
import { RemoteButton } from './RemoteButton/index.js';
|
|
4
|
+
const { onLoad, on, namedPlug, register } = createPlugin({
|
|
5
|
+
name: 'remoteRenderer',
|
|
6
|
+
});
|
|
7
|
+
on('messageHandler', {
|
|
8
|
+
rendererResponse: (context, msg) => {
|
|
9
|
+
const rendererCore = context.getMethodsOf('rendererCore');
|
|
10
|
+
rendererCore.receiveResponse(msg);
|
|
11
|
+
},
|
|
12
|
+
});
|
|
13
|
+
on('rendererCore', {
|
|
14
|
+
request: (context, msg) => {
|
|
15
|
+
postRendererRequest(context, msg);
|
|
16
|
+
},
|
|
17
|
+
});
|
|
18
|
+
onLoad(context => {
|
|
19
|
+
// Discover remote renderers by asking all to announce themselves
|
|
20
|
+
postRendererRequest(context, {
|
|
21
|
+
type: 'pingRenderers',
|
|
22
|
+
});
|
|
23
|
+
});
|
|
24
|
+
namedPlug('globalAction', 'remoteRenderer', ({ pluginContext }) => {
|
|
25
|
+
const { getMethodsOf } = pluginContext;
|
|
26
|
+
const core = getMethodsOf('core');
|
|
27
|
+
const notifications = getMethodsOf('notifications');
|
|
28
|
+
return (React.createElement(RemoteButton, { devServerOn: core.isDevServerOn(), webRendererUrl: core.getWebRendererUrl(), pushNotification: notifications.pushTimedNotification }));
|
|
29
|
+
});
|
|
30
|
+
export { register };
|
|
31
|
+
if (process.env.NODE_ENV !== 'test')
|
|
32
|
+
register();
|
|
33
|
+
function postRendererRequest(context, msg) {
|
|
34
|
+
const msgHandler = context.getMethodsOf('messageHandler');
|
|
35
|
+
msgHandler.postRendererRequest(msg);
|
|
36
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { createPlugin } from 'react-plugin';
|
|
2
|
+
import { isValidFixtureSelected } from './isValidFixtureSelected.js';
|
|
3
|
+
import { onRouterFixtureChange } from './onRouterFixtureChange.js';
|
|
4
|
+
import { receiveResponse } from './receiveResponse/index.js';
|
|
5
|
+
import { setFixtureState } from './setFixtureState.js';
|
|
6
|
+
const { on, register } = createPlugin({
|
|
7
|
+
name: 'rendererCore',
|
|
8
|
+
initialState: {
|
|
9
|
+
connectedRendererIds: [],
|
|
10
|
+
primaryRendererId: null,
|
|
11
|
+
fixtures: {},
|
|
12
|
+
fixtureState: {},
|
|
13
|
+
},
|
|
14
|
+
methods: {
|
|
15
|
+
getConnectedRendererIds,
|
|
16
|
+
getPrimaryRendererId,
|
|
17
|
+
getFixtures,
|
|
18
|
+
getFixtureState,
|
|
19
|
+
isRendererConnected,
|
|
20
|
+
isValidFixtureSelected,
|
|
21
|
+
setFixtureState,
|
|
22
|
+
selectPrimaryRenderer,
|
|
23
|
+
receiveResponse,
|
|
24
|
+
},
|
|
25
|
+
});
|
|
26
|
+
on('router', { fixtureChange: onRouterFixtureChange });
|
|
27
|
+
export { register };
|
|
28
|
+
if (process.env.NODE_ENV !== 'test')
|
|
29
|
+
register();
|
|
30
|
+
function getConnectedRendererIds({ getState }) {
|
|
31
|
+
return getState().connectedRendererIds;
|
|
32
|
+
}
|
|
33
|
+
function getPrimaryRendererId({ getState }) {
|
|
34
|
+
return getState().primaryRendererId;
|
|
35
|
+
}
|
|
36
|
+
function getFixtures({ getState }) {
|
|
37
|
+
return getState().fixtures;
|
|
38
|
+
}
|
|
39
|
+
function getFixtureState({ getState }) {
|
|
40
|
+
return getState().fixtureState;
|
|
41
|
+
}
|
|
42
|
+
function isRendererConnected({ getState }) {
|
|
43
|
+
return getState().connectedRendererIds.length > 0;
|
|
44
|
+
}
|
|
45
|
+
function selectPrimaryRenderer({ setState }, primaryRendererId) {
|
|
46
|
+
setState(prevState => ({ ...prevState, primaryRendererId }));
|
|
47
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { getSelectedFixtureId } from './shared/router.js';
|
|
2
|
+
export function isValidFixtureSelected(context) {
|
|
3
|
+
const fixtureId = getSelectedFixtureId(context);
|
|
4
|
+
if (fixtureId === null) {
|
|
5
|
+
return false;
|
|
6
|
+
}
|
|
7
|
+
const { fixtures } = context.getState();
|
|
8
|
+
if (!fixtures.hasOwnProperty(fixtureId.path)) {
|
|
9
|
+
return false;
|
|
10
|
+
}
|
|
11
|
+
const fixtureItem = fixtures[fixtureId.path];
|
|
12
|
+
return fixtureItem.type === 'multi'
|
|
13
|
+
? fixtureId.name !== undefined &&
|
|
14
|
+
fixtureItem.fixtureNames.indexOf(fixtureId.name) !== -1
|
|
15
|
+
: fixtureId.name === undefined;
|
|
16
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { postSelectFixtureRequest, postUnselectFixtureRequest, } from './shared/postRequest.js';
|
|
2
|
+
export function onRouterFixtureChange(context, fixtureId) {
|
|
3
|
+
if (fixtureId === null) {
|
|
4
|
+
return context.setState(emptyFixtureState, () => {
|
|
5
|
+
getConnectedRendererIds(context).forEach(rendererId => postUnselectFixtureRequest(context, rendererId));
|
|
6
|
+
});
|
|
7
|
+
}
|
|
8
|
+
// Clear fixture state between fixtures
|
|
9
|
+
context.setState(emptyFixtureState, () => {
|
|
10
|
+
getConnectedRendererIds(context).forEach(rendererId => postSelectFixtureRequest(context, rendererId, fixtureId, {}));
|
|
11
|
+
});
|
|
12
|
+
}
|
|
13
|
+
function getConnectedRendererIds(context) {
|
|
14
|
+
return context.getState().connectedRendererIds;
|
|
15
|
+
}
|
|
16
|
+
function emptyFixtureState(prevState) {
|
|
17
|
+
return { ...prevState, fixtureState: {} };
|
|
18
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export function receiveFixtureListUpdateResponse(context, { payload }) {
|
|
2
|
+
const { rendererId, fixtures } = payload;
|
|
3
|
+
const { primaryRendererId } = context.getState();
|
|
4
|
+
// Discard updates from secondary renderers
|
|
5
|
+
if (rendererId === primaryRendererId) {
|
|
6
|
+
context.setState(prevState => ({
|
|
7
|
+
...prevState,
|
|
8
|
+
fixtures,
|
|
9
|
+
}));
|
|
10
|
+
}
|
|
11
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { isEqual } from 'lodash-es';
|
|
2
|
+
import { postSetFixtureStateRequest } from '../shared/postRequest.js';
|
|
3
|
+
import { getSelectedFixtureId } from '../shared/router.js';
|
|
4
|
+
export function receiveFixtureStateChangeResponse(context, { payload }) {
|
|
5
|
+
const { rendererId, fixtureId, fixtureState } = payload;
|
|
6
|
+
const selectedFixtureId = getSelectedFixtureId(context);
|
|
7
|
+
const { primaryRendererId, fixtureState: prevFixtureState } = context.getState();
|
|
8
|
+
if (!isEqual(fixtureId, selectedFixtureId)) {
|
|
9
|
+
console.warn('[Renderer] fixtureStateChange response ignored ' +
|
|
10
|
+
`because it doesn't match the selected fixture`);
|
|
11
|
+
return;
|
|
12
|
+
}
|
|
13
|
+
// Discard updates from secondary renderers
|
|
14
|
+
if (rendererId !== primaryRendererId) {
|
|
15
|
+
return;
|
|
16
|
+
}
|
|
17
|
+
if (isEqual(fixtureState, prevFixtureState)) {
|
|
18
|
+
return;
|
|
19
|
+
}
|
|
20
|
+
context.setState(prevState => ({ ...prevState, fixtureState }), afterStateChanged);
|
|
21
|
+
function afterStateChanged() {
|
|
22
|
+
// Sync secondary renderers with changed primary renderer fixture state
|
|
23
|
+
const { connectedRendererIds } = context.getState();
|
|
24
|
+
connectedRendererIds.forEach(curRendererId => {
|
|
25
|
+
if (curRendererId !== rendererId) {
|
|
26
|
+
postSetFixtureStateRequest(context, curRendererId, fixtureId, fixtureState);
|
|
27
|
+
}
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { receiveFixtureListUpdateResponse } from './fixtureListUpdate.js';
|
|
2
|
+
import { receiveFixtureStateChangeResponse } from './fixtureStateChange.js';
|
|
3
|
+
import { receivePlaygroundCommandResponse } from './playgroundCommand.js';
|
|
4
|
+
import { receiveRendererReadyResponse } from './rendererReady.js';
|
|
5
|
+
export function receiveResponse(context, msg) {
|
|
6
|
+
context.emit('response', msg);
|
|
7
|
+
const rendererResponse = msg;
|
|
8
|
+
switch (rendererResponse.type) {
|
|
9
|
+
case 'rendererReady':
|
|
10
|
+
return receiveRendererReadyResponse(context, rendererResponse);
|
|
11
|
+
case 'fixtureListUpdate':
|
|
12
|
+
return receiveFixtureListUpdateResponse(context, rendererResponse);
|
|
13
|
+
case 'fixtureStateChange':
|
|
14
|
+
return receiveFixtureStateChangeResponse(context, rendererResponse);
|
|
15
|
+
case 'playgroundCommand':
|
|
16
|
+
return receivePlaygroundCommandResponse(context, rendererResponse);
|
|
17
|
+
default:
|
|
18
|
+
// No need to handle every message. Maybe some plugin cares about it.
|
|
19
|
+
}
|
|
20
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { postSelectFixtureRequest } from '../shared/postRequest.js';
|
|
2
|
+
import { getSelectedFixtureId } from '../shared/router.js';
|
|
3
|
+
export function receiveRendererReadyResponse(context, { payload }) {
|
|
4
|
+
const { rendererId, fixtures, initialFixtureId } = payload;
|
|
5
|
+
context.setState(stateUpdater, afterStateChanged);
|
|
6
|
+
function stateUpdater(prevState) {
|
|
7
|
+
// The first announced renderer becomes the primary one
|
|
8
|
+
const primaryRendererId = prevState.primaryRendererId || rendererId;
|
|
9
|
+
const isPrimaryRenderer = rendererId === primaryRendererId;
|
|
10
|
+
const { connectedRendererIds, fixtureState } = prevState;
|
|
11
|
+
return {
|
|
12
|
+
...prevState,
|
|
13
|
+
connectedRendererIds: addToSet(connectedRendererIds, rendererId),
|
|
14
|
+
primaryRendererId,
|
|
15
|
+
fixtures,
|
|
16
|
+
fixtureState: isPrimaryRenderer ? {} : fixtureState,
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
function afterStateChanged() {
|
|
20
|
+
if (initialFixtureId)
|
|
21
|
+
selectInitialFixture(context, initialFixtureId);
|
|
22
|
+
else
|
|
23
|
+
selectFixtureFromUrlParams(context, rendererId);
|
|
24
|
+
notifyRendererConnection(context, rendererId);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
function selectInitialFixture({ getMethodsOf }, fixtureId) {
|
|
28
|
+
const router = getMethodsOf('router');
|
|
29
|
+
router.selectFixture(fixtureId);
|
|
30
|
+
}
|
|
31
|
+
function selectFixtureFromUrlParams(context, rendererId) {
|
|
32
|
+
const fixtureId = getSelectedFixtureId(context);
|
|
33
|
+
if (fixtureId) {
|
|
34
|
+
const { fixtureState } = context.getState();
|
|
35
|
+
postSelectFixtureRequest(context, rendererId, fixtureId, fixtureState);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
function notifyRendererConnection({ getMethodsOf }, rendererId) {
|
|
39
|
+
const notifications = getMethodsOf('notifications');
|
|
40
|
+
notifications.pushTimedNotification({
|
|
41
|
+
id: `renderer-connect-${rendererId}`,
|
|
42
|
+
type: 'info',
|
|
43
|
+
title: 'Renderer connected',
|
|
44
|
+
info: 'Your fixtures are ready to use.',
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
function addToSet(set, item) {
|
|
48
|
+
return set.indexOf(item) === -1 ? [...set, item] : set;
|
|
49
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { postSetFixtureStateRequest } from './shared/postRequest.js';
|
|
2
|
+
import { getSelectedFixtureId } from './shared/router.js';
|
|
3
|
+
export function setFixtureState(context, stateUpdater) {
|
|
4
|
+
const fixtureId = getSelectedFixtureId(context);
|
|
5
|
+
if (!fixtureId) {
|
|
6
|
+
console.warn('[Renderer] Trying to set fixture state with no fixture selected');
|
|
7
|
+
return;
|
|
8
|
+
}
|
|
9
|
+
context.setState(change, () => {
|
|
10
|
+
postRendererRequest(fixtureId);
|
|
11
|
+
});
|
|
12
|
+
function change(prevState) {
|
|
13
|
+
return {
|
|
14
|
+
...prevState,
|
|
15
|
+
fixtureState: stateUpdater(prevState.fixtureState),
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
function postRendererRequest(selectedFixtureId) {
|
|
19
|
+
const { connectedRendererIds, fixtureState } = context.getState();
|
|
20
|
+
connectedRendererIds.forEach(rendererId => postSetFixtureStateRequest(context, rendererId, selectedFixtureId, fixtureState));
|
|
21
|
+
}
|
|
22
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { FixtureId, FixtureState, RendererId } from 'react-cosmos-core';
|
|
2
|
+
import { RendererCoreContext } from '../shared/index.js';
|
|
3
|
+
export declare function postSelectFixtureRequest(context: RendererCoreContext, rendererId: RendererId, fixtureId: FixtureId, fixtureState: FixtureState): void;
|
|
4
|
+
export declare function postUnselectFixtureRequest(context: RendererCoreContext, rendererId: RendererId): void;
|
|
5
|
+
export declare function postSetFixtureStateRequest(context: RendererCoreContext, rendererId: RendererId, fixtureId: FixtureId, fixtureState: FixtureState): void;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
export function postSelectFixtureRequest(context, rendererId, fixtureId, fixtureState) {
|
|
2
|
+
postRendererRequest(context, {
|
|
3
|
+
type: 'selectFixture',
|
|
4
|
+
payload: {
|
|
5
|
+
rendererId,
|
|
6
|
+
fixtureId,
|
|
7
|
+
fixtureState,
|
|
8
|
+
},
|
|
9
|
+
});
|
|
10
|
+
}
|
|
11
|
+
export function postUnselectFixtureRequest(context, rendererId) {
|
|
12
|
+
postRendererRequest(context, {
|
|
13
|
+
type: 'unselectFixture',
|
|
14
|
+
payload: {
|
|
15
|
+
rendererId,
|
|
16
|
+
},
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
export function postSetFixtureStateRequest(context, rendererId, fixtureId, fixtureState) {
|
|
20
|
+
postRendererRequest(context, {
|
|
21
|
+
type: 'setFixtureState',
|
|
22
|
+
payload: {
|
|
23
|
+
rendererId,
|
|
24
|
+
fixtureId,
|
|
25
|
+
fixtureState,
|
|
26
|
+
},
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
function postRendererRequest({ emit }, msg) {
|
|
30
|
+
emit('request', msg);
|
|
31
|
+
}
|