2017-11-15 15:13:49 +01:00
|
|
|
// import polyfill
|
|
|
|
import 'babel-polyfill';
|
|
|
|
|
|
|
|
// inject tap event plugin
|
|
|
|
import injectTapEventPlugin from 'react-tap-event-plugin';
|
|
|
|
injectTapEventPlugin();
|
|
|
|
|
|
|
|
// create store
|
|
|
|
import { createStore, combineReducers, compose, applyMiddleware } from 'redux';
|
|
|
|
import thunkMiddleware from 'redux-thunk';
|
|
|
|
import promiseMiddleware from 'redux-promise-middleware';
|
|
|
|
import { createLogger } from 'redux-logger';
|
2017-12-07 16:20:18 +01:00
|
|
|
import sketcherReducer from './src/reducer/index.js';
|
2017-11-15 15:13:49 +01:00
|
|
|
const reducer = combineReducers({ sketcher: sketcherReducer });
|
|
|
|
const enhancer = compose(applyMiddleware(thunkMiddleware, promiseMiddleware(), createLogger({ collapsed: true })));
|
|
|
|
const store = createStore(reducer, enhancer);
|
|
|
|
|
2017-12-12 11:42:06 +01:00
|
|
|
// add actions to window
|
2017-11-17 23:34:20 +01:00
|
|
|
import actionWrapper from 'redux-action-wrapper';
|
2017-11-17 22:22:36 +01:00
|
|
|
import * as actions from './src/actions/index.js';
|
2017-11-17 23:34:20 +01:00
|
|
|
window.actions = actionWrapper(actions, store.dispatch);
|
2017-11-17 22:22:36 +01:00
|
|
|
|
2017-12-12 11:42:06 +01:00
|
|
|
// add model to store
|
2017-12-07 16:21:27 +01:00
|
|
|
import modelData from './models/noodlebot.d3sketch';
|
|
|
|
import JSONToSketchData from './src/shape/JSONToSketchData.js';
|
2017-12-12 11:42:06 +01:00
|
|
|
JSONToSketchData(JSON.parse(modelData)).then(data => {
|
2017-12-07 16:21:27 +01:00
|
|
|
store.dispatch(actions.openSketch({ data }));
|
2017-12-12 11:42:06 +01:00
|
|
|
});
|
|
|
|
|
|
|
|
// default css
|
|
|
|
import jss from 'jss';
|
|
|
|
import preset from 'jss-preset-default';
|
|
|
|
import normalize from 'normalize-jss';
|
|
|
|
jss.setup(preset());
|
2017-12-14 11:18:41 +01:00
|
|
|
jss.createStyleSheet(normalize).attach();
|
2017-12-12 11:42:06 +01:00
|
|
|
jss.createStyleSheet({
|
2017-12-14 11:18:41 +01:00
|
|
|
'@global': {
|
|
|
|
'*': { margin: 0, padding: 0 },
|
|
|
|
'#app, body, html': { height: '100%', fontFamily: 'sans-serif' },
|
|
|
|
body: { overflow: 'auto' },
|
|
|
|
html: { overflow: 'hidden' }
|
|
|
|
}
|
2017-12-12 11:42:06 +01:00
|
|
|
}).attach();
|
2017-11-18 21:21:16 +01:00
|
|
|
|
2017-11-15 15:13:49 +01:00
|
|
|
// render dom
|
|
|
|
import React from 'react';
|
|
|
|
import { Provider } from 'react-redux';
|
|
|
|
import { render } from 'react-dom';
|
|
|
|
import App from './src/components/App.js';
|
|
|
|
|
2017-12-07 16:21:10 +01:00
|
|
|
async function init() {
|
|
|
|
if (process.env.TARGET === 'app') {
|
|
|
|
await new Promise(resolve => document.addEventListener('deviceready', resolve, false));
|
|
|
|
}
|
|
|
|
|
|
|
|
render((
|
|
|
|
<Provider store={store}>
|
|
|
|
<App />
|
|
|
|
</Provider>
|
|
|
|
), document.getElementById('app'));
|
|
|
|
}
|
|
|
|
init();
|