The web module runs in the renderer process of Electron. It is a React/Redux web application that is loaded into the BrowserWindow
by the main process of Electron. The web application implements the bulk of Deco-IDE's functionality.
To start the local web server and hot reload changes run:
$ npm run watch
-
Redux DevTools are available, but are turned off by default in the code. If you would like to turn them on, set the environment variable
NODE_ENV=development
-
Much of the styling is done through
src/styles
.scss files. There are instances of inline styling through React, but much of the major styling happens through compiled SCSS. -
Any font, icon, image, or script required by the web application should be placed in the
assets
folder and will be copied into thepublic
folder by runningnpm run watch
ornpm run build
These are the actions in your standard Redux pattern. Redux-thunk and ipc/request.js
are used
to abstract dispatched actions that call to the main process when they need to handle something (eg. opening a file). Action Types for
requests to the main process are taken from shared/src/constants
files.
The api/ModuleClient.js
class is used to communicate with the component registry. At the moment the component registry is very simple — a github project.
For more information on the registry, visit the Deco component registry github project.
All action calls and/or use of mapStateToProps
should be handled by a container. If any child component needs to make an action call then it should
receive that function as a prop from its parent container. If any child components needs access to state in the Redux Store then it should receive it as a prop
from the parent container.
Deco change factory is used to build objects representing state changes in the editor. This allows complex state changes to be handled as a discrete operation through Redux (eg. insert component then undo to reverse the editor to its state before the component was inserted.)
This is our abstraction layer over Electron's ipc module used to coordinate the main process and the renderer process. The ipc/ipcActionEmitter.js
is given
access to the Redux Store and listens for events from Electron's ipc module sent over by the main process. Ipc events received are then dispatched as actions and handled in the reducers. A ipc/Request.js
returns a promise that sends an action through ipc to the main process and then is resolved when the main process completes the action or rejects on error.
Middleware is how we bring certain CodeMirror events into Redux. It is also a way for us to intercept and modify CodeMirror events before CodeMirror acts on them. Middleware is attached (to listen) to the DecoDoc (A CodeMirror.Doc wrapper) when a document is mounted by the components/editor/Editor.jsx
component.
These are mostly convenience objects used by Factories/Middleware to represent discrete units of the editor's state.
These are classes used to cache state and/or application metadata using LocalStorage. It also includes some 'actionEmitter' classes that are given access
to the Redux Store. It is similar in concept to redux-persist
if you are familiar with that project — it is similar in that a portion of state is pushed to a persistence layer so it may later be brought back into the state (asynchronously through the Redux Store) during a new session.
The only thing worth noting about how we configure the store is our use of store/applyActionEmitters
which allows atypical code paths access to the Redux Store. Any class that isn't on the render path should use an actionEmitter to update state through Redux.