react-cosmos-ui 6.0.0-beta.1 → 6.0.0-beta.10
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/dist/components/BaseSvg.d.ts +1 -1
- package/dist/components/Icon.d.ts +2 -2
- package/dist/components/Illustration.d.ts +2 -2
- package/dist/components/KeyBox.d.ts +2 -2
- package/dist/components/SidePanel.d.ts +2 -2
- package/dist/components/Space.d.ts +2 -2
- package/dist/components/TreeView.d.ts +2 -2
- package/dist/components/ValueInputTree/ExpandCollapseValues.d.ts +2 -2
- package/dist/components/ValueInputTree/ValueInput/BooleanValueInput.d.ts +2 -2
- package/dist/components/ValueInputTree/ValueInput/NullValueInput.d.ts +2 -2
- package/dist/components/ValueInputTree/ValueInput/NumberValueInput.d.ts +2 -2
- package/dist/components/ValueInputTree/ValueInput/StringValueInput.d.ts +2 -2
- package/dist/components/ValueInputTree/ValueInput/UndefinedValueInput.d.ts +2 -2
- package/dist/components/ValueInputTree/ValueInput/UnserializableValueInput.d.ts +2 -2
- package/dist/components/ValueInputTree/ValueInput/ValueInput.d.ts +2 -2
- package/dist/components/ValueInputTree/ValueInputDir.d.ts +4 -3
- package/dist/components/ValueInputTree/ValueInputDir.js +2 -6
- package/dist/components/ValueInputTree/ValueInputTree.js +17 -2
- package/dist/components/ValueInputTree/shared.d.ts +1 -0
- package/dist/components/ValueInputTree/valueTree.d.ts +1 -1
- package/dist/components/ValueInputTree/valueTree.js +10 -5
- package/dist/components/buttons/Button32.d.ts +1 -1
- package/dist/components/buttons/Button8.d.ts +1 -1
- package/dist/components/buttons/IconButton32.d.ts +1 -1
- package/dist/components/buttons/IconButton8.d.ts +1 -1
- package/dist/components/buttons/shared.js +4 -1
- package/dist/components/icons/index.d.ts +30 -30
- package/dist/components/illustrations/ArtificialIntelligence.d.ts +2 -2
- package/dist/components/illustrations/Astronaut.d.ts +2 -2
- package/dist/components/illustrations/BlankCanvas.d.ts +2 -2
- package/dist/components/inputs/NumberInput.d.ts +2 -2
- package/dist/components/inputs/Select.d.ts +2 -2
- package/dist/cosmos.decorator.d.ts +1 -1
- package/dist/index.d.ts +0 -1
- package/dist/index.js +0 -1
- package/dist/playground.bundle.js +326 -317
- package/dist/playground.bundle.js.map +1 -1
- package/dist/playground.js +2 -2
- package/dist/pluginMocks.d.ts +1 -0
- package/dist/pluginMocks.js +1 -0
- package/dist/plugins/ClassStatePanel/ClassStatePanel/ComponentClassState.d.ts +6 -5
- package/dist/plugins/ClassStatePanel/ClassStatePanel/ComponentClassState.js +8 -8
- package/dist/plugins/ClassStatePanel/ClassStatePanel/index.d.ts +4 -3
- package/dist/plugins/ClassStatePanel/ClassStatePanel/index.js +5 -5
- package/dist/plugins/ClassStatePanel/ClassStatePanel/shared.d.ts +2 -2
- package/dist/plugins/ClassStatePanel/ClassStatePanel/shared.js +6 -9
- package/dist/plugins/ClassStatePanel/index.js +5 -3
- package/dist/plugins/ClassStatePanel/shared.d.ts +2 -0
- package/dist/plugins/ControlPanel/ControlPanel.d.ts +6 -5
- package/dist/plugins/ControlPanel/ControlPanel.js +3 -3
- package/dist/plugins/ControlPanel/index.js +4 -2
- package/dist/plugins/ControlPanel/shared.d.ts +2 -0
- package/dist/plugins/ControlPanel/shared.js +1 -0
- package/dist/plugins/ControlSelect/SelectValueInput.d.ts +5 -5
- package/dist/plugins/ControlSelect/index.js +3 -6
- package/dist/plugins/FixtureBookmark/BookmarkFixtureButton.d.ts +2 -2
- package/dist/plugins/FixtureBookmark/FixtureBookmarks.d.ts +2 -2
- package/dist/plugins/FixtureSearch/FixtureSearchHeader.d.ts +2 -2
- package/dist/plugins/FixtureSearch/FixtureSearchOverlay.d.ts +2 -2
- package/dist/plugins/FixtureSearch/FixtureSearchOverlay.js +10 -4
- package/dist/plugins/FixtureSearch/FixtureSearchResult.d.ts +2 -2
- package/dist/plugins/FixtureSearch/FixtureSearchShortcuts.d.ts +2 -2
- package/dist/plugins/FixtureTree/BlankState.d.ts +2 -2
- package/dist/plugins/FixtureTree/FixtureTree/FixtureButton.d.ts +2 -2
- package/dist/plugins/FixtureTree/FixtureTree/FixtureDir.d.ts +2 -2
- package/dist/plugins/FixtureTree/FixtureTree/FixtureLink.d.ts +2 -2
- package/dist/plugins/FixtureTree/FixtureTree/MultiFixtureButton.d.ts +2 -2
- package/dist/plugins/FixtureTree/FixtureTree/MultiFixtureChildButton.d.ts +2 -2
- package/dist/plugins/FixtureTree/FixtureTreeContainer.d.ts +2 -2
- package/dist/plugins/FixtureTree/FixtureTreeHeader.d.ts +2 -2
- package/dist/plugins/FullScreenButton/FullScreenButton.d.ts +2 -2
- package/dist/plugins/MessageHandler/socket.js +1 -1
- package/dist/plugins/Notifications/Notifications.d.ts +2 -2
- package/dist/plugins/PluginList/PluginList.d.ts +2 -2
- package/dist/plugins/PropsPanel/BlankState.d.ts +2 -2
- package/dist/plugins/PropsPanel/PropsPanel/ComponentProps.d.ts +6 -5
- package/dist/plugins/PropsPanel/PropsPanel/ComponentProps.js +14 -12
- package/dist/plugins/PropsPanel/PropsPanel/index.d.ts +4 -3
- package/dist/plugins/PropsPanel/PropsPanel/index.js +5 -5
- package/dist/plugins/PropsPanel/PropsPanel/shared.d.ts +2 -2
- package/dist/plugins/PropsPanel/PropsPanel/shared.js +6 -9
- package/dist/plugins/PropsPanel/index.js +14 -9
- package/dist/plugins/PropsPanel/shared.d.ts +2 -0
- package/dist/plugins/RemoteRenderer/RemoteButton/index.d.ts +2 -2
- package/dist/plugins/RendererCore/index.js +11 -3
- package/dist/plugins/RendererCore/onRouterFixtureReselect.js +2 -2
- package/dist/plugins/RendererCore/onRouterFixtureSelect.js +2 -2
- package/dist/plugins/RendererCore/receiveResponse/rendererReady.js +8 -3
- package/dist/plugins/RendererCore/setFixtureState.d.ts +2 -2
- package/dist/plugins/RendererCore/setFixtureState.js +5 -4
- package/dist/plugins/RendererCore/setGlobalFixtureState.d.ts +2 -0
- package/dist/plugins/RendererCore/setGlobalFixtureState.js +15 -0
- package/dist/plugins/RendererCore/shared/postRequest.d.ts +1 -1
- package/dist/plugins/RendererCore/spec.d.ts +8 -3
- package/dist/plugins/RendererPreview/RendererOverlay/RemoteRendererConnected.d.ts +2 -2
- package/dist/plugins/RendererPreview/RendererOverlay/RemoteRendererOverlay.d.ts +2 -2
- package/dist/plugins/RendererPreview/RendererOverlay/RendererOverlay.d.ts +2 -2
- package/dist/plugins/RendererPreview/RendererOverlay/WaitingForRenderer.d.ts +2 -2
- package/dist/plugins/RendererPreview/RendererPreview.js +1 -1
- package/dist/plugins/ResponsivePreview/ResponsivePreview/ResponsiveHeader.d.ts +4 -3
- package/dist/plugins/ResponsivePreview/ResponsivePreview/ResponsivePreview.d.ts +6 -5
- package/dist/plugins/ResponsivePreview/ResponsivePreview/style.d.ts +4 -4
- package/dist/plugins/ResponsivePreview/ToggleButton/index.d.ts +2 -2
- package/dist/plugins/ResponsivePreview/index.js +10 -15
- package/dist/plugins/ResponsivePreview/shared.d.ts +3 -6
- package/dist/plugins/ResponsivePreview/spec.d.ts +2 -5
- package/dist/plugins/Root/GlobalHeader.d.ts +2 -2
- package/dist/plugins/Root/HomeOverlay/HomeOverlay.d.ts +2 -2
- package/dist/plugins/Root/HomeOverlay/KeyShortcut.d.ts +2 -2
- package/dist/plugins/Root/HomeOverlay/NoFixtureSelected.d.ts +2 -2
- package/dist/plugins/Root/HomeOverlay/WelcomeCosmos.d.ts +2 -2
- package/dist/plugins/Root/Root.d.ts +6 -5
- package/dist/plugins/Root/Root.js +2 -2
- package/dist/plugins/Root/SidePanel.d.ts +4 -3
- package/dist/plugins/Root/SidePanel.js +2 -2
- package/dist/plugins/Root/ToggleNavButton.d.ts +2 -2
- package/dist/plugins/Root/index.js +1 -1
- package/dist/plugins/Root/navOpen.js +1 -1
- package/dist/plugins/Root/panelOpen.js +1 -1
- package/dist/plugins/Router/index.js +8 -1
- package/dist/plugins/Router/spec.d.ts +3 -0
- package/dist/plugins/StandardControl/index.js +3 -6
- package/dist/slots/ControlActionSlot.d.ts +4 -4
- package/dist/slots/ControlSlot.d.ts +5 -5
- package/dist/slots/FixtureActionSlot.d.ts +2 -2
- package/dist/slots/NavRowSlot.d.ts +2 -2
- package/dist/slots/RendererActionSlot.d.ts +2 -2
- package/dist/slots/SidePanelRowSlot.d.ts +6 -5
- package/dist/slots/ValueInputSlot.d.ts +2 -2
- package/dist/testHelpers/pluginMocks.d.ts +8 -4
- package/dist/testHelpers/pluginMocks.js +4 -2
- package/package.json +8 -8
- package/pluginMocks.d.ts +1 -0
- package/pluginMocks.js +1 -0
|
@@ -2,12 +2,12 @@ import React from 'react';
|
|
|
2
2
|
import { hasFsValues, sortFsValueGroups, stringifyElementId, } from '../../../components/ValueInputTree/index.js';
|
|
3
3
|
import { ComponentProps } from './ComponentProps.js';
|
|
4
4
|
export const PropsPanel = React.memo(function PropsPanel({ fixtureState, fixtureExpansion, onFixtureStateChange, onElementExpansionChange, }) {
|
|
5
|
-
if (!fixtureState
|
|
5
|
+
if (!fixtureState) {
|
|
6
6
|
return null;
|
|
7
7
|
}
|
|
8
|
-
const propsWithValues = fixtureState.
|
|
9
|
-
return (React.createElement(React.Fragment, null, sortFsValueGroups(propsWithValues).map(
|
|
10
|
-
const strElementId = stringifyElementId(
|
|
11
|
-
return (React.createElement(ComponentProps, { key: strElementId,
|
|
8
|
+
const propsWithValues = fixtureState.filter(hasFsValues);
|
|
9
|
+
return (React.createElement(React.Fragment, null, sortFsValueGroups(propsWithValues).map(fsItem => {
|
|
10
|
+
const strElementId = stringifyElementId(fsItem.elementId);
|
|
11
|
+
return (React.createElement(ComponentProps, { key: strElementId, propsFsItem: fsItem, fixtureExpansion: fixtureExpansion, onFixtureStateChange: onFixtureStateChange, onElementExpansionChange: onElementExpansionChange }));
|
|
12
12
|
})));
|
|
13
13
|
});
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { FixtureElementId,
|
|
2
|
-
export declare function
|
|
1
|
+
import { FixtureElementId, FixtureStateUpdater, PropsFixtureState } from 'react-cosmos-core';
|
|
2
|
+
export declare function propsFsItemUpdater(elementId: FixtureElementId, cb: FixtureStateUpdater<PropsFixtureState>): FixtureStateUpdater<PropsFixtureState>;
|
|
@@ -1,16 +1,13 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { findPropsFixtureStateItem, } from 'react-cosmos-core';
|
|
2
2
|
import { stringifyElementId } from '../../../components/ValueInputTree/index.js';
|
|
3
|
-
export function
|
|
3
|
+
export function propsFsItemUpdater(elementId, cb) {
|
|
4
4
|
return prevFs => {
|
|
5
|
-
const
|
|
6
|
-
if (!
|
|
5
|
+
const fsItem = findPropsFixtureStateItem(prevFs, elementId);
|
|
6
|
+
if (!fsItem) {
|
|
7
7
|
const elId = stringifyElementId(elementId);
|
|
8
8
|
console.warn(`Trying to update missing element with ID: ${elId}`);
|
|
9
|
-
return prevFs;
|
|
9
|
+
return prevFs ?? [];
|
|
10
10
|
}
|
|
11
|
-
return
|
|
12
|
-
...prevFs,
|
|
13
|
-
props: cb(prevFs),
|
|
14
|
-
};
|
|
11
|
+
return cb(prevFs);
|
|
15
12
|
};
|
|
16
13
|
}
|
|
@@ -1,15 +1,17 @@
|
|
|
1
|
-
import React from 'react';
|
|
1
|
+
import React, { useCallback } from 'react';
|
|
2
2
|
import { createPlugin } from 'react-plugin';
|
|
3
3
|
import { getFixtureExpansion, hasFsValues, updateElementExpansion, } from '../../components/ValueInputTree/index.js';
|
|
4
4
|
import { BlankState } from './BlankState.js';
|
|
5
5
|
import { PropsPanel } from './PropsPanel/index.js';
|
|
6
|
-
import { PROPS_TREE_EXPANSION_STORAGE_KEY } from './shared.js';
|
|
6
|
+
import { PROPS_TREE_EXPANSION_STORAGE_KEY, } from './shared.js';
|
|
7
7
|
const { namedPlug, register } = createPlugin({
|
|
8
8
|
name: 'propsPanel',
|
|
9
9
|
});
|
|
10
10
|
namedPlug('sidePanelRow', 'props', ({ pluginContext, slotProps }) => {
|
|
11
|
-
const { fixtureId,
|
|
11
|
+
const { fixtureId, getFixtureState, setFixtureState } = slotProps;
|
|
12
12
|
const { fixtureExpansion, onElementExpansionChange } = useFixtureExpansion(pluginContext, fixtureId);
|
|
13
|
+
const fixtureState = getFixtureState('props');
|
|
14
|
+
const onFixtureStateChange = useCallback(change => setFixtureState('props', change), [setFixtureState]);
|
|
13
15
|
return (React.createElement(PropsPanel, { fixtureState: fixtureState, fixtureExpansion: fixtureExpansion, onFixtureStateChange: onFixtureStateChange, onElementExpansionChange: onElementExpansionChange }));
|
|
14
16
|
});
|
|
15
17
|
// WARNING: This plug has to be aware of all control types and only show up
|
|
@@ -17,8 +19,8 @@ namedPlug('sidePanelRow', 'props', ({ pluginContext, slotProps }) => {
|
|
|
17
19
|
// TODO: Replace this with a more generic blank state (controls in general not
|
|
18
20
|
// just props)
|
|
19
21
|
namedPlug('sidePanelRow', 'blankState', ({ slotProps }) => {
|
|
20
|
-
const {
|
|
21
|
-
return shouldShowBlankState(
|
|
22
|
+
const { getFixtureState } = slotProps;
|
|
23
|
+
return shouldShowBlankState(getFixtureState) ? React.createElement(BlankState, null) : null;
|
|
22
24
|
});
|
|
23
25
|
export { register };
|
|
24
26
|
if (process.env.NODE_ENV !== 'test')
|
|
@@ -38,14 +40,17 @@ function useFixtureExpansion(context, fixtureId) {
|
|
|
38
40
|
onElementExpansionChange,
|
|
39
41
|
};
|
|
40
42
|
}
|
|
41
|
-
function shouldShowBlankState(
|
|
42
|
-
const
|
|
43
|
+
function shouldShowBlankState(getFixtureState) {
|
|
44
|
+
const props = getFixtureState('props');
|
|
45
|
+
const hasProps = props && props.some(hasFsValues);
|
|
43
46
|
if (hasProps)
|
|
44
47
|
return false;
|
|
45
|
-
const
|
|
48
|
+
const classState = getFixtureState('classState');
|
|
49
|
+
const hasClassState = classState && classState.some(hasFsValues);
|
|
46
50
|
if (hasClassState)
|
|
47
51
|
return false;
|
|
48
|
-
const
|
|
52
|
+
const controls = getFixtureState('controls');
|
|
53
|
+
const hasControls = controls && Object.keys(controls).length > 0;
|
|
49
54
|
if (hasControls)
|
|
50
55
|
return false;
|
|
51
56
|
return true;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
|
|
1
|
+
import React from 'react';
|
|
2
2
|
import { NotificationItem } from '../../Notifications/spec.js';
|
|
3
3
|
type Props = {
|
|
4
4
|
devServerOn: boolean;
|
|
5
5
|
rendererUrl: null | string;
|
|
6
6
|
pushNotification: (notification: NotificationItem) => unknown;
|
|
7
7
|
};
|
|
8
|
-
export declare function RemoteButton({ devServerOn, rendererUrl, pushNotification, }: Props): JSX.Element | null;
|
|
8
|
+
export declare function RemoteButton({ devServerOn, rendererUrl, pushNotification, }: Props): React.JSX.Element | null;
|
|
9
9
|
export {};
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { fixtureStateByName } from 'react-cosmos-core';
|
|
1
2
|
import { createPlugin } from 'react-plugin';
|
|
2
3
|
import { onRouterFixtureReselect } from './onRouterFixtureReselect.js';
|
|
3
4
|
import { onRouterFixtureSelect } from './onRouterFixtureSelect.js';
|
|
@@ -5,6 +6,7 @@ import { onRouterFixtureUnselect } from './onRouterFixtureUnselect.js';
|
|
|
5
6
|
import { receiveResponse } from './receiveResponse/index.js';
|
|
6
7
|
import { reloadRenderer } from './reloadRenderer.js';
|
|
7
8
|
import { setFixtureState } from './setFixtureState.js';
|
|
9
|
+
import { setGlobalFixtureState } from './setGlobalFixtureState.js';
|
|
8
10
|
const { on, register, onLoad } = createPlugin({
|
|
9
11
|
name: 'rendererCore',
|
|
10
12
|
defaultConfig: {
|
|
@@ -16,18 +18,21 @@ const { on, register, onLoad } = createPlugin({
|
|
|
16
18
|
primaryRendererId: null,
|
|
17
19
|
fixtures: {},
|
|
18
20
|
fixtureState: {},
|
|
21
|
+
globalFixtureState: {},
|
|
19
22
|
},
|
|
20
23
|
methods: {
|
|
21
24
|
getRendererUrl,
|
|
22
25
|
getConnectedRendererIds,
|
|
23
26
|
getPrimaryRendererId,
|
|
24
27
|
getFixtures,
|
|
25
|
-
getFixtureState,
|
|
26
28
|
isRendererConnected,
|
|
27
29
|
reloadRenderer,
|
|
28
|
-
setFixtureState,
|
|
29
30
|
selectPrimaryRenderer,
|
|
30
31
|
receiveResponse,
|
|
32
|
+
getAllFixtureState,
|
|
33
|
+
getFixtureState,
|
|
34
|
+
setFixtureState,
|
|
35
|
+
setGlobalFixtureState,
|
|
31
36
|
},
|
|
32
37
|
});
|
|
33
38
|
onLoad(({ getConfig, setState }) => {
|
|
@@ -54,9 +59,12 @@ function getPrimaryRendererId({ getState }) {
|
|
|
54
59
|
function getFixtures({ getState }) {
|
|
55
60
|
return getState().fixtures;
|
|
56
61
|
}
|
|
57
|
-
function
|
|
62
|
+
function getAllFixtureState({ getState }) {
|
|
58
63
|
return getState().fixtureState;
|
|
59
64
|
}
|
|
65
|
+
function getFixtureState({ getState }, name) {
|
|
66
|
+
return fixtureStateByName(getState().fixtureState, name);
|
|
67
|
+
}
|
|
60
68
|
function isRendererConnected({ getState }) {
|
|
61
69
|
return getState().connectedRendererIds.length > 0;
|
|
62
70
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { postSelectFixtureRequest } from './shared/postRequest.js';
|
|
2
2
|
export function onRouterFixtureReselect(context, fixtureId) {
|
|
3
|
-
const { connectedRendererIds } = context.getState();
|
|
3
|
+
const { connectedRendererIds, globalFixtureState } = context.getState();
|
|
4
4
|
connectedRendererIds.forEach(rendererId => {
|
|
5
|
-
postSelectFixtureRequest(context, rendererId, fixtureId,
|
|
5
|
+
postSelectFixtureRequest(context, rendererId, fixtureId, globalFixtureState);
|
|
6
6
|
});
|
|
7
7
|
}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { postSelectFixtureRequest } from './shared/postRequest.js';
|
|
2
2
|
export function onRouterFixtureSelect(context, fixtureId) {
|
|
3
3
|
context.setState(prevState => ({ ...prevState, fixtureState: {} }), () => {
|
|
4
|
-
const { connectedRendererIds } = context.getState();
|
|
4
|
+
const { connectedRendererIds, globalFixtureState } = context.getState();
|
|
5
5
|
connectedRendererIds.forEach(rendererId => {
|
|
6
|
-
postSelectFixtureRequest(context, rendererId, fixtureId,
|
|
6
|
+
postSelectFixtureRequest(context, rendererId, fixtureId, globalFixtureState);
|
|
7
7
|
});
|
|
8
8
|
});
|
|
9
9
|
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { isEqual } from 'lodash-es';
|
|
2
|
-
import { postSelectFixtureRequest } from '../shared/postRequest.js';
|
|
2
|
+
import { postSelectFixtureRequest, postSetFixtureStateRequest, } from '../shared/postRequest.js';
|
|
3
3
|
export function receiveRendererReadyResponse(context, { payload }) {
|
|
4
4
|
const { rendererId } = payload;
|
|
5
|
-
const { connectedRendererIds: prevRendererIds } = context.getState();
|
|
5
|
+
const { connectedRendererIds: prevRendererIds, globalFixtureState } = context.getState();
|
|
6
6
|
context.setState(stateUpdater, afterStateChanged);
|
|
7
7
|
function stateUpdater(prevState) {
|
|
8
8
|
// The first announced renderer becomes the primary one
|
|
@@ -12,7 +12,7 @@ export function receiveRendererReadyResponse(context, { payload }) {
|
|
|
12
12
|
...prevState,
|
|
13
13
|
connectedRendererIds: addToSet(connectedRendererIds, rendererId),
|
|
14
14
|
primaryRendererId,
|
|
15
|
-
fixtureState: rendererId === primaryRendererId ?
|
|
15
|
+
fixtureState: rendererId === primaryRendererId ? globalFixtureState : fixtureState,
|
|
16
16
|
};
|
|
17
17
|
}
|
|
18
18
|
function afterStateChanged() {
|
|
@@ -23,6 +23,11 @@ export function receiveRendererReadyResponse(context, { payload }) {
|
|
|
23
23
|
const { fixtureState } = context.getState();
|
|
24
24
|
postSelectFixtureRequest(context, rendererId, routerFixtureId, fixtureState);
|
|
25
25
|
}
|
|
26
|
+
else if (rendererFixtureId) {
|
|
27
|
+
if (Object.keys(globalFixtureState).length > 0) {
|
|
28
|
+
postSetFixtureStateRequest(context, rendererId, rendererFixtureId, globalFixtureState);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
26
31
|
// Notify about connected renderers that weren't connected before
|
|
27
32
|
if (!prevRendererIds.includes(rendererId)) {
|
|
28
33
|
notifyRendererConnection(context, rendererId);
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { FixtureStateChange } from 'react-cosmos-core';
|
|
2
2
|
import { RendererCoreContext } from './shared/index.js';
|
|
3
|
-
export declare function setFixtureState(context: RendererCoreContext,
|
|
3
|
+
export declare function setFixtureState(context: RendererCoreContext, name: string, change: FixtureStateChange<unknown>): void;
|
|
@@ -1,18 +1,19 @@
|
|
|
1
|
+
import { updateFixtureState, } from 'react-cosmos-core';
|
|
1
2
|
import { postSetFixtureStateRequest } from './shared/postRequest.js';
|
|
2
3
|
import { getSelectedFixtureId } from './shared/router.js';
|
|
3
|
-
export function setFixtureState(context,
|
|
4
|
+
export function setFixtureState(context, name, change) {
|
|
4
5
|
const fixtureId = getSelectedFixtureId(context);
|
|
5
6
|
if (!fixtureId) {
|
|
6
7
|
console.warn('[Renderer] Trying to set fixture state with no fixture selected');
|
|
7
8
|
return;
|
|
8
9
|
}
|
|
9
|
-
context.setState(
|
|
10
|
+
context.setState(stateUpdater, () => {
|
|
10
11
|
postRendererRequest(fixtureId);
|
|
11
12
|
});
|
|
12
|
-
function
|
|
13
|
+
function stateUpdater(prevState) {
|
|
13
14
|
return {
|
|
14
15
|
...prevState,
|
|
15
|
-
fixtureState:
|
|
16
|
+
fixtureState: updateFixtureState(prevState.fixtureState, name, change),
|
|
16
17
|
};
|
|
17
18
|
}
|
|
18
19
|
function postRendererRequest(selectedFixtureId) {
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { setFixtureState } from './setFixtureState.js';
|
|
2
|
+
import { getSelectedFixtureId } from './shared/router.js';
|
|
3
|
+
export function setGlobalFixtureState(context, name, state) {
|
|
4
|
+
context.setState(prevState => ({
|
|
5
|
+
...prevState,
|
|
6
|
+
globalFixtureState: {
|
|
7
|
+
...prevState.globalFixtureState,
|
|
8
|
+
[name]: state,
|
|
9
|
+
},
|
|
10
|
+
}));
|
|
11
|
+
const fixtureId = getSelectedFixtureId(context);
|
|
12
|
+
if (fixtureId) {
|
|
13
|
+
setFixtureState(context, name, state);
|
|
14
|
+
}
|
|
15
|
+
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { FixtureId, FixtureState, RendererId } from 'react-cosmos-core';
|
|
2
|
-
import { RendererCoreContext } from '
|
|
2
|
+
import { RendererCoreContext } from './index.js';
|
|
3
3
|
export declare function postReloadRendererRequest(context: RendererCoreContext, rendererId: RendererId): void;
|
|
4
4
|
export declare function postSelectFixtureRequest(context: RendererCoreContext, rendererId: RendererId, fixtureId: FixtureId, fixtureState: FixtureState): void;
|
|
5
5
|
export declare function postUnselectFixtureRequest(context: RendererCoreContext, rendererId: RendererId): void;
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
import { FixtureList, FixtureState, MessageType, RendererId
|
|
1
|
+
import { FixtureList, FixtureState, FixtureStateChange, MessageType, RendererId } from 'react-cosmos-core';
|
|
2
|
+
export type GetFixtureState = <T>(name: string) => T | undefined;
|
|
3
|
+
export type SetFixtureStateByName = <T>(name: string, change: FixtureStateChange<T>) => void;
|
|
2
4
|
export type RendererCoreSpec = {
|
|
3
5
|
name: 'rendererCore';
|
|
4
6
|
config: {
|
|
@@ -10,18 +12,21 @@ export type RendererCoreSpec = {
|
|
|
10
12
|
primaryRendererId: null | RendererId;
|
|
11
13
|
fixtures: FixtureList;
|
|
12
14
|
fixtureState: FixtureState;
|
|
15
|
+
globalFixtureState: FixtureState;
|
|
13
16
|
};
|
|
14
17
|
methods: {
|
|
15
18
|
getRendererUrl(): null | string;
|
|
16
19
|
getConnectedRendererIds(): RendererId[];
|
|
17
20
|
getPrimaryRendererId(): null | RendererId;
|
|
18
21
|
getFixtures(): FixtureList;
|
|
19
|
-
getFixtureState(): FixtureState;
|
|
20
22
|
isRendererConnected(): boolean;
|
|
21
23
|
reloadRenderer(): void;
|
|
22
|
-
setFixtureState(stateUpdater: StateUpdater<FixtureState>): void;
|
|
23
24
|
selectPrimaryRenderer(primaryRendererId: RendererId): void;
|
|
24
25
|
receiveResponse(msg: MessageType): void;
|
|
26
|
+
getAllFixtureState(): FixtureState;
|
|
27
|
+
getFixtureState: GetFixtureState;
|
|
28
|
+
setFixtureState: SetFixtureStateByName;
|
|
29
|
+
setGlobalFixtureState<T>(name: string, state: T): void;
|
|
25
30
|
};
|
|
26
31
|
events: {
|
|
27
32
|
request(msg: MessageType): void;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
export declare function RemoteRendererConnected(): JSX.Element;
|
|
1
|
+
import React from 'react';
|
|
2
|
+
export declare function RemoteRendererConnected(): React.JSX.Element;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
|
|
1
|
+
import React from 'react';
|
|
2
2
|
type Props = {
|
|
3
3
|
rendererConnected: boolean;
|
|
4
4
|
};
|
|
5
|
-
export declare function RemoteRendererOverlay({ rendererConnected }: Props): JSX.Element;
|
|
5
|
+
export declare function RemoteRendererOverlay({ rendererConnected }: Props): React.JSX.Element;
|
|
6
6
|
export {};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
|
|
1
|
+
import React from 'react';
|
|
2
2
|
import { RuntimeStatus } from '../spec.js';
|
|
3
3
|
type Props = {
|
|
4
4
|
runtimeStatus: RuntimeStatus;
|
|
5
5
|
};
|
|
6
|
-
export declare function RendererOverlay({ runtimeStatus }: Props): JSX.Element | null;
|
|
6
|
+
export declare function RendererOverlay({ runtimeStatus }: Props): React.JSX.Element | null;
|
|
7
7
|
export {};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
export declare function WaitingForRenderer(): JSX.Element;
|
|
1
|
+
import React from 'react';
|
|
2
|
+
export declare function WaitingForRenderer(): React.JSX.Element;
|
|
@@ -12,7 +12,7 @@ export const RendererPreview = React.memo(function RendererPreview({ rendererUrl
|
|
|
12
12
|
}
|
|
13
13
|
return (React.createElement(Slot, { name: "rendererPreviewOuter" },
|
|
14
14
|
React.createElement(Container, null,
|
|
15
|
-
React.createElement(Iframe, { "data-testid": "previewIframe", ref: onIframeRef, src: createRendererUrl(rendererUrl), frameBorder: 0, allow: "clipboard-write
|
|
15
|
+
React.createElement(Iframe, { "data-testid": "previewIframe", ref: onIframeRef, src: createRendererUrl(rendererUrl), frameBorder: 0, allow: "clipboard-write *; fullscreen *;" }),
|
|
16
16
|
React.createElement(RendererOverlay, { runtimeStatus: runtimeStatus }))));
|
|
17
17
|
});
|
|
18
18
|
const Container = styled.div `
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import {
|
|
2
|
+
import { Viewport } from 'react-cosmos-core';
|
|
3
|
+
import { ResponsiveDevice } from '../spec.js';
|
|
3
4
|
type Props = {
|
|
4
5
|
devices: ResponsiveDevice[];
|
|
5
|
-
selectedViewport:
|
|
6
|
+
selectedViewport: Viewport;
|
|
6
7
|
scaleFactor: number;
|
|
7
8
|
scaled: boolean;
|
|
8
|
-
selectViewport: (viewport:
|
|
9
|
+
selectViewport: (viewport: Viewport) => unknown;
|
|
9
10
|
toggleScale: () => unknown;
|
|
10
11
|
};
|
|
11
12
|
export declare const ResponsiveHeader: React.NamedExoticComponent<Props>;
|
|
@@ -1,13 +1,14 @@
|
|
|
1
|
-
import { Dispatch, ReactNode, SetStateAction } from 'react';
|
|
2
|
-
import {
|
|
1
|
+
import React, { Dispatch, ReactNode, SetStateAction } from 'react';
|
|
2
|
+
import { Viewport } from 'react-cosmos-core';
|
|
3
|
+
import { ResponsiveDevice } from '../spec.js';
|
|
3
4
|
type Props = {
|
|
4
5
|
children?: ReactNode;
|
|
5
6
|
devices: ResponsiveDevice[];
|
|
6
7
|
enabled: boolean;
|
|
7
|
-
viewport:
|
|
8
|
+
viewport: Viewport;
|
|
8
9
|
scaled: boolean;
|
|
9
|
-
setViewport: Dispatch<SetStateAction<
|
|
10
|
+
setViewport: Dispatch<SetStateAction<Viewport>>;
|
|
10
11
|
setScaled: (scaled: boolean) => unknown;
|
|
11
12
|
};
|
|
12
|
-
export declare function ResponsivePreview({ children, devices, enabled, viewport, scaled, setViewport, setScaled, }: Props): JSX.Element;
|
|
13
|
+
export declare function ResponsivePreview({ children, devices, enabled, viewport, scaled, setViewport, setScaled, }: Props): React.JSX.Element;
|
|
13
14
|
export {};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Viewport } from 'react-cosmos-core';
|
|
2
2
|
export declare const responsivePreviewPadding: {
|
|
3
3
|
top: number;
|
|
4
4
|
bottom: number;
|
|
@@ -11,8 +11,8 @@ export declare const stretchStyle: {
|
|
|
11
11
|
flex: number;
|
|
12
12
|
};
|
|
13
13
|
export declare function getStyles({ container, viewport, scaled, }: {
|
|
14
|
-
container:
|
|
15
|
-
viewport:
|
|
14
|
+
container: Viewport;
|
|
15
|
+
viewport: Viewport;
|
|
16
16
|
scaled: boolean;
|
|
17
17
|
}): {
|
|
18
18
|
maskContainerStyle: {
|
|
@@ -42,4 +42,4 @@ export declare function getStyles({ container, viewport, scaled, }: {
|
|
|
42
42
|
transform: string;
|
|
43
43
|
};
|
|
44
44
|
};
|
|
45
|
-
export declare function getViewportScaleFactor(viewport:
|
|
45
|
+
export declare function getViewportScaleFactor(viewport: Viewport, container: Viewport): number;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
|
|
1
|
+
import React from 'react';
|
|
2
2
|
type Props = {
|
|
3
3
|
selected: boolean;
|
|
4
4
|
onToggle: () => unknown;
|
|
5
5
|
};
|
|
6
|
-
export declare function ToggleButton({ selected, onToggle }: Props): JSX.Element;
|
|
6
|
+
export declare function ToggleButton({ selected, onToggle }: Props): React.JSX.Element;
|
|
7
7
|
export {};
|
|
@@ -27,11 +27,11 @@ namedPlug('rendererAction', 'responsivePreview', ({ pluginContext }) => {
|
|
|
27
27
|
return (React.createElement(ToggleButton, { selected: enabled, onToggle: () => {
|
|
28
28
|
if (enabled) {
|
|
29
29
|
setViewportState(pluginContext, { ...viewportState, enabled: false });
|
|
30
|
-
|
|
30
|
+
setViewportFixtureState(pluginContext, null);
|
|
31
31
|
}
|
|
32
32
|
else {
|
|
33
33
|
setViewportState(pluginContext, { ...viewportState, enabled: true });
|
|
34
|
-
|
|
34
|
+
setViewportFixtureState(pluginContext, viewport);
|
|
35
35
|
}
|
|
36
36
|
} }));
|
|
37
37
|
});
|
|
@@ -40,12 +40,10 @@ if (process.env.NODE_ENV !== 'test')
|
|
|
40
40
|
register();
|
|
41
41
|
function useViewportChange(context) {
|
|
42
42
|
const viewportState = getViewportState(context);
|
|
43
|
-
return React.useCallback((
|
|
44
|
-
const viewport = typeof
|
|
45
|
-
? viewportChange(viewportState.viewport)
|
|
46
|
-
: viewportChange;
|
|
43
|
+
return React.useCallback((change) => {
|
|
44
|
+
const viewport = typeof change === 'function' ? change(viewportState.viewport) : change;
|
|
47
45
|
setViewportState(context, { ...viewportState, enabled: true, viewport });
|
|
48
|
-
|
|
46
|
+
setViewportFixtureState(context, viewport);
|
|
49
47
|
}, [context, viewportState]);
|
|
50
48
|
}
|
|
51
49
|
function useScaledChange(context) {
|
|
@@ -58,9 +56,9 @@ function getViewportState(context) {
|
|
|
58
56
|
const viewportState = storage.getItem(VIEWPORT_STORAGE_KEY) ||
|
|
59
57
|
DEFAULT_VIEWPORT_STATE;
|
|
60
58
|
const rendererCore = getMethodsOf('rendererCore');
|
|
61
|
-
const
|
|
62
|
-
return
|
|
63
|
-
? { ...viewportState, enabled: true, viewport
|
|
59
|
+
const viewport = rendererCore.getFixtureState('viewport');
|
|
60
|
+
return viewport
|
|
61
|
+
? { ...viewportState, enabled: true, viewport }
|
|
64
62
|
: viewportState;
|
|
65
63
|
}
|
|
66
64
|
function setViewportState(context, viewportState) {
|
|
@@ -68,11 +66,8 @@ function setViewportState(context, viewportState) {
|
|
|
68
66
|
const storage = getMethodsOf('storage');
|
|
69
67
|
storage.setItem(VIEWPORT_STORAGE_KEY, viewportState);
|
|
70
68
|
}
|
|
71
|
-
function
|
|
69
|
+
function setViewportFixtureState(context, viewport) {
|
|
72
70
|
const { getMethodsOf } = context;
|
|
73
71
|
const rendererCore = getMethodsOf('rendererCore');
|
|
74
|
-
rendererCore.setFixtureState(
|
|
75
|
-
...fixtureState,
|
|
76
|
-
viewport,
|
|
77
|
-
}));
|
|
72
|
+
rendererCore.setFixtureState('viewport', viewport);
|
|
78
73
|
}
|
|
@@ -1,16 +1,13 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Viewport } from 'react-cosmos-core';
|
|
2
2
|
import { PluginContext } from 'react-plugin';
|
|
3
3
|
import { StorageSpec } from '../Storage/spec.js';
|
|
4
|
-
import { ResponsivePreviewSpec
|
|
4
|
+
import { ResponsivePreviewSpec } from './spec.js';
|
|
5
5
|
export type ResponsivePreviewContext = PluginContext<ResponsivePreviewSpec>;
|
|
6
6
|
export type StorageMethods = StorageSpec['methods'];
|
|
7
|
-
export type FixtureStateWithViewport = FixtureState & {
|
|
8
|
-
viewport?: ResponsiveViewport;
|
|
9
|
-
};
|
|
10
7
|
export type ViewportState = {
|
|
11
8
|
enabled: boolean;
|
|
12
9
|
scaled: boolean;
|
|
13
|
-
viewport:
|
|
10
|
+
viewport: Viewport;
|
|
14
11
|
};
|
|
15
12
|
export declare const DEFAULT_DEVICES: {
|
|
16
13
|
label: string;
|
|
@@ -1,8 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
height: number;
|
|
4
|
-
};
|
|
5
|
-
export type ResponsiveDevice = ResponsiveViewport & {
|
|
1
|
+
import { Viewport } from 'react-cosmos-core';
|
|
2
|
+
export type ResponsiveDevice = Viewport & {
|
|
6
3
|
label: string;
|
|
7
4
|
};
|
|
8
5
|
export type ResponsivePreviewSpec = {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
|
|
1
|
+
import React from 'react';
|
|
2
2
|
type Props = {
|
|
3
3
|
rendererConnected: boolean;
|
|
4
4
|
globalActionOrder: string[];
|
|
5
5
|
};
|
|
6
|
-
export declare function GlobalHeader({ rendererConnected, globalActionOrder }: Props): JSX.Element;
|
|
6
|
+
export declare function GlobalHeader({ rendererConnected, globalActionOrder }: Props): React.JSX.Element;
|
|
7
7
|
export {};
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
|
|
1
|
+
import React from 'react';
|
|
2
2
|
type Props = {
|
|
3
3
|
welcomeDismissed: boolean;
|
|
4
4
|
onDismissWelcome: () => unknown;
|
|
5
5
|
onShowWelcome: () => unknown;
|
|
6
6
|
};
|
|
7
|
-
export declare function HomeOverlay({ welcomeDismissed, onDismissWelcome, onShowWelcome, }: Props): JSX.Element;
|
|
7
|
+
export declare function HomeOverlay({ welcomeDismissed, onDismissWelcome, onShowWelcome, }: Props): React.JSX.Element;
|
|
8
8
|
export {};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
|
|
1
|
+
import React from 'react';
|
|
2
2
|
type Props = {
|
|
3
3
|
keys: string[];
|
|
4
4
|
label: string;
|
|
5
5
|
};
|
|
6
|
-
export declare function KeyShortcut({ keys, label }: Props): JSX.Element;
|
|
6
|
+
export declare function KeyShortcut({ keys, label }: Props): React.JSX.Element;
|
|
7
7
|
export {};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
|
|
1
|
+
import React from 'react';
|
|
2
2
|
type Props = {
|
|
3
3
|
onShowWelcome: () => unknown;
|
|
4
4
|
};
|
|
5
|
-
export declare function NoFixtureSelected({ onShowWelcome }: Props): JSX.Element;
|
|
5
|
+
export declare function NoFixtureSelected({ onShowWelcome }: Props): React.JSX.Element;
|
|
6
6
|
export {};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
|
|
1
|
+
import React from 'react';
|
|
2
2
|
type Props = {
|
|
3
3
|
onDismissWelcome: () => unknown;
|
|
4
4
|
};
|
|
5
|
-
export declare function WelcomeCosmos({ onDismissWelcome }: Props): JSX.Element;
|
|
5
|
+
export declare function WelcomeCosmos({ onDismissWelcome }: Props): React.JSX.Element;
|
|
6
6
|
export {};
|
|
@@ -1,10 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
import { FixtureId,
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { FixtureId, FlatFixtureTreeItem } from 'react-cosmos-core';
|
|
3
|
+
import { GetFixtureState, SetFixtureStateByName } from '../RendererCore/spec.js';
|
|
3
4
|
type Props = {
|
|
4
5
|
fixtureItems: FlatFixtureTreeItem[];
|
|
5
6
|
selectedFixtureId: FixtureId | null;
|
|
6
7
|
rendererConnected: boolean;
|
|
7
|
-
|
|
8
|
+
getFixtureState: GetFixtureState;
|
|
9
|
+
setFixtureState: SetFixtureStateByName;
|
|
8
10
|
navOpen: boolean;
|
|
9
11
|
panelOpen: boolean;
|
|
10
12
|
navWidth: number;
|
|
@@ -19,12 +21,11 @@ type Props = {
|
|
|
19
21
|
onTogglePanel: () => unknown;
|
|
20
22
|
onReloadRenderer: () => unknown;
|
|
21
23
|
onCloseFixture: () => unknown;
|
|
22
|
-
onFixtureStateChange: (stateUpdater: StateUpdater<FixtureState>) => void;
|
|
23
24
|
setNavWidth: (width: number) => unknown;
|
|
24
25
|
setPanelWidth: (width: number) => unknown;
|
|
25
26
|
welcomeDismissed: boolean;
|
|
26
27
|
onDismissWelcome: () => unknown;
|
|
27
28
|
onShowWelcome: () => unknown;
|
|
28
29
|
};
|
|
29
|
-
export declare function Root({ fixtureItems, selectedFixtureId, rendererConnected,
|
|
30
|
+
export declare function Root({ fixtureItems, selectedFixtureId, rendererConnected, getFixtureState, setFixtureState, navOpen, panelOpen, navWidth, panelWidth, sidePanelRowOrder, globalActionOrder, globalOrder, navRowOrder, fixtureActionOrder, rendererActionOrder, onToggleNav, onTogglePanel, onReloadRenderer, onCloseFixture, setNavWidth, setPanelWidth, welcomeDismissed, onDismissWelcome, onShowWelcome, }: Props): React.JSX.Element;
|
|
30
31
|
export {};
|