Spaces:
Running
Running
File size: 6,478 Bytes
6bcb42f |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 |
import {applyMiddleware, compose, combineReducers} from 'redux';
import alertsReducer, {alertsInitialState} from './alerts';
import assetDragReducer, {assetDragInitialState} from './asset-drag';
import cardsReducer, {cardsInitialState} from './cards';
import colorPickerReducer, {colorPickerInitialState} from './color-picker';
import connectionModalReducer, {connectionModalInitialState} from './connection-modal';
import customProceduresReducer, {customProceduresInitialState} from './custom-procedures';
import blockDragReducer, {blockDragInitialState} from './block-drag';
import editorTabReducer, {editorTabInitialState} from './editor-tab';
import hoveredTargetReducer, {hoveredTargetInitialState} from './hovered-target';
import menuReducer, {menuInitialState} from './menus';
import micIndicatorReducer, {micIndicatorInitialState} from './mic-indicator';
import modalReducer, {modalsInitialState} from './modals';
import modeReducer, {modeInitialState} from './mode';
import monitorReducer, {monitorsInitialState} from './monitors';
import monitorLayoutReducer, {monitorLayoutInitialState} from './monitor-layout';
import projectChangedReducer, {projectChangedInitialState} from './project-changed';
import projectStateReducer, {projectStateInitialState} from './project-state';
import projectTitleReducer, {projectTitleInitialState} from './project-title';
import fontsLoadedReducer, {fontsLoadedInitialState} from './fonts-loaded';
import restoreDeletionReducer, {restoreDeletionInitialState} from './restore-deletion';
import stageSizeReducer, {stageSizeInitialState} from './stage-size';
import targetReducer, {targetsInitialState} from './targets';
import timeoutReducer, {timeoutInitialState} from './timeout';
import toolboxReducer, {toolboxInitialState} from './toolbox';
import twReducer, {twInitialState} from './tw';
import customStageSizeReducer, {customStageSizeInitialState} from './custom-stage-size';
import vmReducer, {vmInitialState} from './vm';
import vmStatusReducer, {vmStatusInitialState} from './vm-status';
import workspaceMetricsReducer, {workspaceMetricsInitialState} from './workspace-metrics';
import throttle from 'redux-throttle';
import decks from '../lib/libraries/decks/index.jsx';
const guiMiddleware = compose(applyMiddleware(throttle(300, {leading: true, trailing: true})));
const guiInitialState = {
alerts: alertsInitialState,
assetDrag: assetDragInitialState,
blockDrag: blockDragInitialState,
cards: cardsInitialState,
colorPicker: colorPickerInitialState,
connectionModal: connectionModalInitialState,
customStageSize: customStageSizeInitialState,
customProcedures: customProceduresInitialState,
editorTab: editorTabInitialState,
mode: modeInitialState,
hoveredTarget: hoveredTargetInitialState,
stageSize: stageSizeInitialState,
menus: menuInitialState,
micIndicator: micIndicatorInitialState,
modals: modalsInitialState,
monitors: monitorsInitialState,
monitorLayout: monitorLayoutInitialState,
projectChanged: projectChangedInitialState,
projectState: projectStateInitialState,
projectTitle: projectTitleInitialState,
fontsLoaded: fontsLoadedInitialState,
restoreDeletion: restoreDeletionInitialState,
targets: targetsInitialState,
timeout: timeoutInitialState,
toolbox: toolboxInitialState,
tw: twInitialState,
vm: vmInitialState,
vmStatus: vmStatusInitialState,
workspaceMetrics: workspaceMetricsInitialState
};
const initPlayer = function (currentState) {
return Object.assign(
{},
currentState,
{mode: {
isEmbedded: false,
isFullScreen: currentState.mode.isFullScreen,
isPlayerOnly: true,
// When initializing in player mode, make sure to reset
// hasEverEnteredEditorMode
hasEverEnteredEditor: false
}}
);
};
const initFullScreen = function (currentState) {
return Object.assign(
{},
currentState,
{mode: {
isEmbedded: false,
isFullScreen: true,
isPlayerOnly: currentState.mode.isPlayerOnly,
hasEverEnteredEditor: currentState.mode.hasEverEnteredEditor
}}
);
};
const initEmbedded = function (currentState) {
return Object.assign(
{},
currentState,
{mode: {
isEmbedded: true,
// tw: embed does not need isFullScreen anymore
isFullScreen: false,
isPlayerOnly: true,
hasEverEnteredEditor: false
}}
);
};
const initTutorialCard = function (currentState, deckId) {
return Object.assign(
{},
currentState,
{
cards: {
visible: true,
content: decks,
activeDeckId: deckId,
expanded: true,
step: 0,
x: 0,
y: 0,
dragging: false
}
}
);
};
const initTelemetryModal = function (currentState) {
return Object.assign(
{},
currentState,
{
modals: {
telemetryModal: true // this key must match `MODAL_TELEMETRY` in modals.js
}
}
);
};
const guiReducer = combineReducers({
alerts: alertsReducer,
assetDrag: assetDragReducer,
blockDrag: blockDragReducer,
cards: cardsReducer,
colorPicker: colorPickerReducer,
connectionModal: connectionModalReducer,
customStageSize: customStageSizeReducer,
customProcedures: customProceduresReducer,
editorTab: editorTabReducer,
mode: modeReducer,
hoveredTarget: hoveredTargetReducer,
stageSize: stageSizeReducer,
menus: menuReducer,
micIndicator: micIndicatorReducer,
modals: modalReducer,
monitors: monitorReducer,
monitorLayout: monitorLayoutReducer,
projectChanged: projectChangedReducer,
projectState: projectStateReducer,
projectTitle: projectTitleReducer,
fontsLoaded: fontsLoadedReducer,
restoreDeletion: restoreDeletionReducer,
targets: targetReducer,
timeout: timeoutReducer,
toolbox: toolboxReducer,
tw: twReducer,
vm: vmReducer,
vmStatus: vmStatusReducer,
workspaceMetrics: workspaceMetricsReducer
});
export {
guiReducer as default,
guiInitialState,
guiMiddleware,
initEmbedded,
initFullScreen,
initPlayer,
initTelemetryModal,
initTutorialCard
};
|