516 index.js
@@ -47,32 +47,41 @@
'use strict';

var conway = __webpack_require__(1);
var store = __webpack_require__(4)(10);
var store = __webpack_require__(4)(60);
var board = __webpack_require__(16);
var vdux = __webpack_require__(37);

store.dispatch({ type: 'SET', r: 1, c: 1 });
store.dispatch({ type: 'SET', r: 1, c: 2 });
store.dispatch({ type: 'SET', r: 2, c: 1 });
store.dispatch({ type: 'SET', r: 2, c: 2 });

store.dispatch({ type: 'SET', r: 5, c: 3 });
store.dispatch({ type: 'SET', r: 5, c: 4 });
store.dispatch({ type: 'SET', r: 5, c: 5 });
var vdux = __webpack_require__(41);

var app = function app(state) {
return board(state);
};

function makeGlider() {
store.dispatch({ type: 'SET', r: 4, c: 2 });
store.dispatch({ type: 'SET', r: 4, c: 3 });
store.dispatch({ type: 'SET', r: 4, c: 4 });
store.dispatch({ type: 'SET', r: 3, c: 4 });
store.dispatch({ type: 'SET', r: 2, c: 3 });
}

function spawnRandom() {
for (var i = 0, l = store.getState().length; i < l; i++) {
for (var j = 0; j < l; j++) {
if (Math.random() > 0.7) store.dispatch({ type: 'SET', r: i, c: j });
}
}
}

makeGlider();
spawnRandom();

document.addEventListener('DOMContentLoaded', function () {
vdux(store, app, document.body);
});

function step() {
store.dispatch({ type: 'STEP' });
}

setInterval(step, 200);
setInterval(step, 100);

/***/ },
/* 1 */
@@ -279,7 +288,7 @@
var createBoard = __webpack_require__(15).createBoard;

function configureStore(size) {
return (0, _redux.createStore)(reducer);
return (0, _redux.createStore)(reducer, createBoard(size));
}

module.exports = configureStore;
@@ -1571,7 +1580,7 @@
var cell = __webpack_require__(36);

function render(data) {
return h('.row', data.map(function (c) {
return h('.row', { style: { display: 'flex' } }, data.map(function (c) {
return cell(c);
}));
}
@@ -1585,15 +1594,366 @@
'use strict';

var h = __webpack_require__(17);
__webpack_require__(37);

function render(data) {
return h('.cell', { style: { display: 'inline' } }, [data.toString()]);
return h('.cell ' + (data ? '.alive' : '.dead'), { style: { flex: "1" } });
}

module.exports = render;

/***/ },
/* 37 */
/***/ function(module, exports, __webpack_require__) {

// style-loader: Adds some css to the DOM by adding a <style> tag

// load the styles
var content = __webpack_require__(38);
if(typeof content === 'string') content = [[module.id, content, '']];
// add the styles to the DOM
var update = __webpack_require__(40)(content, {});
if(content.locals) module.exports = content.locals;
// Hot Module Replacement
if(false) {
// When the styles change, update the <style> tags
if(!content.locals) {
module.hot.accept("!!./../../node_modules/css-loader/index.js!./cell.css", function() {
var newContent = require("!!./../../node_modules/css-loader/index.js!./cell.css");
if(typeof newContent === 'string') newContent = [[module.id, newContent, '']];
update(newContent);
});
}
// When the module is disposed, remove the <style> tags
module.hot.dispose(function() { update(); });
}

/***/ },
/* 38 */
/***/ function(module, exports, __webpack_require__) {

exports = module.exports = __webpack_require__(39)();
// imports


// module
exports.push([module.id, ".alive{\n background-color: red;\n}\n.cell:before{\n content: \"\";\n padding-top: 100%;\n display: block;\n}\n.cell {\n margin: 0.1%\n}\n", ""]);

// exports


/***/ },
/* 39 */
/***/ function(module, exports) {

/*
MIT License http://www.opensource.org/licenses/mit-license.php
Author Tobias Koppers @sokra
*/
// css base code, injected by the css-loader
module.exports = function() {
var list = [];

// return the list of modules as css string
list.toString = function toString() {
var result = [];
for(var i = 0; i < this.length; i++) {
var item = this[i];
if(item[2]) {
result.push("@media " + item[2] + "{" + item[1] + "}");
} else {
result.push(item[1]);
}
}
return result.join("");
};

// import a list of modules into the list
list.i = function(modules, mediaQuery) {
if(typeof modules === "string")
modules = [[null, modules, ""]];
var alreadyImportedModules = {};
for(var i = 0; i < this.length; i++) {
var id = this[i][0];
if(typeof id === "number")
alreadyImportedModules[id] = true;
}
for(i = 0; i < modules.length; i++) {
var item = modules[i];
// skip already imported module
// this implementation is not 100% perfect for weird media query combinations
// when a module is imported multiple times with different media queries.
// I hope this will never occur (Hey this way we have smaller bundles)
if(typeof item[0] !== "number" || !alreadyImportedModules[item[0]]) {
if(mediaQuery && !item[2]) {
item[2] = mediaQuery;
} else if(mediaQuery) {
item[2] = "(" + item[2] + ") and (" + mediaQuery + ")";
}
list.push(item);
}
}
};
return list;
};


/***/ },
/* 40 */
/***/ function(module, exports, __webpack_require__) {

/*
MIT License http://www.opensource.org/licenses/mit-license.php
Author Tobias Koppers @sokra
*/
var stylesInDom = {},
memoize = function(fn) {
var memo;
return function () {
if (typeof memo === "undefined") memo = fn.apply(this, arguments);
return memo;
};
},
isOldIE = memoize(function() {
return /msie [6-9]\b/.test(window.navigator.userAgent.toLowerCase());
}),
getHeadElement = memoize(function () {
return document.head || document.getElementsByTagName("head")[0];
}),
singletonElement = null,
singletonCounter = 0,
styleElementsInsertedAtTop = [];

module.exports = function(list, options) {
if(false) {
if(typeof document !== "object") throw new Error("The style-loader cannot be used in a non-browser environment");
}

options = options || {};
// Force single-tag solution on IE6-9, which has a hard limit on the # of <style>
// tags it will allow on a page
if (typeof options.singleton === "undefined") options.singleton = isOldIE();

// By default, add <style> tags to the bottom of <head>.
if (typeof options.insertAt === "undefined") options.insertAt = "bottom";

var styles = listToStyles(list);
addStylesToDom(styles, options);

return function update(newList) {
var mayRemove = [];
for(var i = 0; i < styles.length; i++) {
var item = styles[i];
var domStyle = stylesInDom[item.id];
domStyle.refs--;
mayRemove.push(domStyle);
}
if(newList) {
var newStyles = listToStyles(newList);
addStylesToDom(newStyles, options);
}
for(var i = 0; i < mayRemove.length; i++) {
var domStyle = mayRemove[i];
if(domStyle.refs === 0) {
for(var j = 0; j < domStyle.parts.length; j++)
domStyle.parts[j]();
delete stylesInDom[domStyle.id];
}
}
};
}

function addStylesToDom(styles, options) {
for(var i = 0; i < styles.length; i++) {
var item = styles[i];
var domStyle = stylesInDom[item.id];
if(domStyle) {
domStyle.refs++;
for(var j = 0; j < domStyle.parts.length; j++) {
domStyle.parts[j](item.parts[j]);
}
for(; j < item.parts.length; j++) {
domStyle.parts.push(addStyle(item.parts[j], options));
}
} else {
var parts = [];
for(var j = 0; j < item.parts.length; j++) {
parts.push(addStyle(item.parts[j], options));
}
stylesInDom[item.id] = {id: item.id, refs: 1, parts: parts};
}
}
}

function listToStyles(list) {
var styles = [];
var newStyles = {};
for(var i = 0; i < list.length; i++) {
var item = list[i];
var id = item[0];
var css = item[1];
var media = item[2];
var sourceMap = item[3];
var part = {css: css, media: media, sourceMap: sourceMap};
if(!newStyles[id])
styles.push(newStyles[id] = {id: id, parts: [part]});
else
newStyles[id].parts.push(part);
}
return styles;
}

function insertStyleElement(options, styleElement) {
var head = getHeadElement();
var lastStyleElementInsertedAtTop = styleElementsInsertedAtTop[styleElementsInsertedAtTop.length - 1];
if (options.insertAt === "top") {
if(!lastStyleElementInsertedAtTop) {
head.insertBefore(styleElement, head.firstChild);
} else if(lastStyleElementInsertedAtTop.nextSibling) {
head.insertBefore(styleElement, lastStyleElementInsertedAtTop.nextSibling);
} else {
head.appendChild(styleElement);
}
styleElementsInsertedAtTop.push(styleElement);
} else if (options.insertAt === "bottom") {
head.appendChild(styleElement);
} else {
throw new Error("Invalid value for parameter 'insertAt'. Must be 'top' or 'bottom'.");
}
}

function removeStyleElement(styleElement) {
styleElement.parentNode.removeChild(styleElement);
var idx = styleElementsInsertedAtTop.indexOf(styleElement);
if(idx >= 0) {
styleElementsInsertedAtTop.splice(idx, 1);
}
}

function createStyleElement(options) {
var styleElement = document.createElement("style");
styleElement.type = "text/css";
insertStyleElement(options, styleElement);
return styleElement;
}

function createLinkElement(options) {
var linkElement = document.createElement("link");
linkElement.rel = "stylesheet";
insertStyleElement(options, linkElement);
return linkElement;
}

function addStyle(obj, options) {
var styleElement, update, remove;

if (options.singleton) {
var styleIndex = singletonCounter++;
styleElement = singletonElement || (singletonElement = createStyleElement(options));
update = applyToSingletonTag.bind(null, styleElement, styleIndex, false);
remove = applyToSingletonTag.bind(null, styleElement, styleIndex, true);
} else if(obj.sourceMap &&
typeof URL === "function" &&
typeof URL.createObjectURL === "function" &&
typeof URL.revokeObjectURL === "function" &&
typeof Blob === "function" &&
typeof btoa === "function") {
styleElement = createLinkElement(options);
update = updateLink.bind(null, styleElement);
remove = function() {
removeStyleElement(styleElement);
if(styleElement.href)
URL.revokeObjectURL(styleElement.href);
};
} else {
styleElement = createStyleElement(options);
update = applyToTag.bind(null, styleElement);
remove = function() {
removeStyleElement(styleElement);
};
}

update(obj);

return function updateStyle(newObj) {
if(newObj) {
if(newObj.css === obj.css && newObj.media === obj.media && newObj.sourceMap === obj.sourceMap)
return;
update(obj = newObj);
} else {
remove();
}
};
}

var replaceText = (function () {
var textStore = [];

return function (index, replacement) {
textStore[index] = replacement;
return textStore.filter(Boolean).join('\n');
};
})();

function applyToSingletonTag(styleElement, index, remove, obj) {
var css = remove ? "" : obj.css;

if (styleElement.styleSheet) {
styleElement.styleSheet.cssText = replaceText(index, css);
} else {
var cssNode = document.createTextNode(css);
var childNodes = styleElement.childNodes;
if (childNodes[index]) styleElement.removeChild(childNodes[index]);
if (childNodes.length) {
styleElement.insertBefore(cssNode, childNodes[index]);
} else {
styleElement.appendChild(cssNode);
}
}
}

function applyToTag(styleElement, obj) {
var css = obj.css;
var media = obj.media;
var sourceMap = obj.sourceMap;

if(media) {
styleElement.setAttribute("media", media)
}

if(styleElement.styleSheet) {
styleElement.styleSheet.cssText = css;
} else {
while(styleElement.firstChild) {
styleElement.removeChild(styleElement.firstChild);
}
styleElement.appendChild(document.createTextNode(css));
}
}

function updateLink(linkElement, obj) {
var css = obj.css;
var media = obj.media;
var sourceMap = obj.sourceMap;

if(sourceMap) {
// http://stackoverflow.com/a/26603875
css += "\n/*# sourceMappingURL=data:application/json;base64," + btoa(unescape(encodeURIComponent(JSON.stringify(sourceMap)))) + " */";
}

var blob = new Blob([css], { type: "text/css" });

var oldSrc = linkElement.href;

linkElement.href = URL.createObjectURL(blob);

if(oldSrc)
URL.revokeObjectURL(oldSrc);
}


/***/ },
/* 41 */
/***/ function(module, exports, __webpack_require__) {

/**
@@ -1608,15 +1968,15 @@

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }

var _delegant = __webpack_require__(38);
var _delegant = __webpack_require__(42);

var _delegant2 = _interopRequireDefault(_delegant);

var _composeFunction = __webpack_require__(39);
var _composeFunction = __webpack_require__(43);

var _composeFunction2 = _interopRequireDefault(_composeFunction);

var _virtualDom = __webpack_require__(49);
var _virtualDom = __webpack_require__(53);

/**
* vdux
@@ -1668,7 +2028,7 @@
module.exports = exports['default'];

/***/ },
/* 38 */
/* 42 */
/***/ function(module, exports, __webpack_require__) {

/**
@@ -1689,11 +2049,11 @@

var _evStore2 = _interopRequireDefault(_evStore);

var _composeFunction = __webpack_require__(39);
var _composeFunction = __webpack_require__(43);

var _composeFunction2 = _interopRequireDefault(_composeFunction);

var _proxyEvent = __webpack_require__(47);
var _proxyEvent = __webpack_require__(51);

var _proxyEvent2 = _interopRequireDefault(_proxyEvent);

@@ -1755,15 +2115,15 @@
module.exports = exports['default'];

/***/ },
/* 39 */
/* 43 */
/***/ function(module, exports, __webpack_require__) {

"use strict";

var _interopRequire = function (obj) { return obj && obj.__esModule ? obj["default"] : obj; };

module.exports = compose;
var arityN = _interopRequire(__webpack_require__(40));
var arityN = _interopRequire(__webpack_require__(44));



@@ -1803,16 +2163,16 @@
}

/***/ },
/* 40 */
/* 44 */
/***/ function(module, exports, __webpack_require__) {

var arityFn = [
__webpack_require__(41),
__webpack_require__(42),
__webpack_require__(43),
__webpack_require__(44),
__webpack_require__(45),
__webpack_require__(46)
__webpack_require__(46),
__webpack_require__(47),
__webpack_require__(48),
__webpack_require__(49),
__webpack_require__(50)
];

module.exports = function(fn, n) {
@@ -1825,7 +2185,7 @@


/***/ },
/* 41 */
/* 45 */
/***/ function(module, exports) {

module.exports = function(fn) {
@@ -1836,7 +2196,7 @@


/***/ },
/* 42 */
/* 46 */
/***/ function(module, exports) {

module.exports = function(fn) {
@@ -1847,7 +2207,7 @@


/***/ },
/* 43 */
/* 47 */
/***/ function(module, exports) {

module.exports = function(fn) {
@@ -1858,7 +2218,7 @@


/***/ },
/* 44 */
/* 48 */
/***/ function(module, exports) {

module.exports = function(fn) {
@@ -1869,7 +2229,7 @@


/***/ },
/* 45 */
/* 49 */
/***/ function(module, exports) {

module.exports = function(fn) {
@@ -1880,7 +2240,7 @@


/***/ },
/* 46 */
/* 50 */
/***/ function(module, exports) {

module.exports = function(fn) {
@@ -1891,7 +2251,7 @@


/***/ },
/* 47 */
/* 51 */
/***/ function(module, exports, __webpack_require__) {

/**
@@ -1900,7 +2260,7 @@

"use strict";

var inherits = __webpack_require__(48);
var inherits = __webpack_require__(52);

var ALL_PROPS = ["altKey", "bubbles", "cancelable", "ctrlKey", "eventPhase", "metaKey", "relatedTarget", "shiftKey", "target", "timeStamp", "type", "view", "which"];
var KEY_PROPS = ["char", "charCode", "key", "keyCode"];
@@ -1980,7 +2340,7 @@
inherits(KeyEvent, ProxyEvent);

/***/ },
/* 48 */
/* 52 */
/***/ function(module, exports) {

if (typeof Object.create === 'function') {
@@ -2009,13 +2369,13 @@


/***/ },
/* 49 */
/* 53 */
/***/ function(module, exports, __webpack_require__) {

var diff = __webpack_require__(50)
var patch = __webpack_require__(56)
var diff = __webpack_require__(54)
var patch = __webpack_require__(60)
var h = __webpack_require__(17)
var create = __webpack_require__(65)
var create = __webpack_require__(69)
var VNode = __webpack_require__(20)
var VText = __webpack_require__(26)

@@ -2030,28 +2390,28 @@


/***/ },
/* 50 */
/* 54 */
/***/ function(module, exports, __webpack_require__) {

var diff = __webpack_require__(51)
var diff = __webpack_require__(55)

module.exports = diff


/***/ },
/* 51 */
/* 55 */
/***/ function(module, exports, __webpack_require__) {

var isArray = __webpack_require__(19)

var VPatch = __webpack_require__(52)
var VPatch = __webpack_require__(56)
var isVNode = __webpack_require__(22)
var isVText = __webpack_require__(27)
var isWidget = __webpack_require__(23)
var isThunk = __webpack_require__(24)
var handleThunk = __webpack_require__(53)
var handleThunk = __webpack_require__(57)

var diffProps = __webpack_require__(54)
var diffProps = __webpack_require__(58)

module.exports = diff

@@ -2472,7 +2832,7 @@


/***/ },
/* 52 */
/* 56 */
/***/ function(module, exports, __webpack_require__) {

var version = __webpack_require__(21)
@@ -2500,7 +2860,7 @@


/***/ },
/* 53 */
/* 57 */
/***/ function(module, exports, __webpack_require__) {

var isVNode = __webpack_require__(22)
@@ -2546,10 +2906,10 @@


/***/ },
/* 54 */
/* 58 */
/***/ function(module, exports, __webpack_require__) {

var isObject = __webpack_require__(55)
var isObject = __webpack_require__(59)
var isHook = __webpack_require__(25)

module.exports = diffProps
@@ -2610,7 +2970,7 @@


/***/ },
/* 55 */
/* 59 */
/***/ function(module, exports) {

"use strict";
@@ -2621,24 +2981,24 @@


/***/ },
/* 56 */
/* 60 */
/***/ function(module, exports, __webpack_require__) {

var patch = __webpack_require__(57)
var patch = __webpack_require__(61)

module.exports = patch


/***/ },
/* 57 */
/* 61 */
/***/ function(module, exports, __webpack_require__) {

var document = __webpack_require__(58)
var document = __webpack_require__(62)
var isArray = __webpack_require__(19)

var render = __webpack_require__(60)
var domIndex = __webpack_require__(62)
var patchOp = __webpack_require__(63)
var render = __webpack_require__(64)
var domIndex = __webpack_require__(66)
var patchOp = __webpack_require__(67)
module.exports = patch

function patch(rootNode, patches, renderOptions) {
@@ -2716,12 +3076,12 @@


/***/ },
/* 58 */
/* 62 */
/***/ function(module, exports, __webpack_require__) {

/* WEBPACK VAR INJECTION */(function(global) {var topLevel = typeof global !== 'undefined' ? global :
typeof window !== 'undefined' ? window : {}
var minDoc = __webpack_require__(59);
var minDoc = __webpack_require__(63);

if (typeof document !== 'undefined') {
module.exports = document;
@@ -2738,23 +3098,23 @@
/* WEBPACK VAR INJECTION */}.call(exports, (function() { return this; }())))

/***/ },
/* 59 */
/* 63 */
/***/ function(module, exports) {

/* (ignored) */

/***/ },
/* 60 */
/* 64 */
/***/ function(module, exports, __webpack_require__) {

var document = __webpack_require__(58)
var document = __webpack_require__(62)

var applyProperties = __webpack_require__(61)
var applyProperties = __webpack_require__(65)

var isVNode = __webpack_require__(22)
var isVText = __webpack_require__(27)
var isWidget = __webpack_require__(23)
var handleThunk = __webpack_require__(53)
var handleThunk = __webpack_require__(57)

module.exports = createElement

@@ -2796,10 +3156,10 @@


/***/ },
/* 61 */
/* 65 */
/***/ function(module, exports, __webpack_require__) {

var isObject = __webpack_require__(55)
var isObject = __webpack_require__(59)
var isHook = __webpack_require__(25)

module.exports = applyProperties
@@ -2899,7 +3259,7 @@


/***/ },
/* 62 */
/* 66 */
/***/ function(module, exports) {

// Maps a virtual DOM tree onto a real DOM tree in an efficient manner.
@@ -2990,15 +3350,15 @@


/***/ },
/* 63 */
/* 67 */
/***/ function(module, exports, __webpack_require__) {

var applyProperties = __webpack_require__(61)
var applyProperties = __webpack_require__(65)

var isWidget = __webpack_require__(23)
var VPatch = __webpack_require__(52)
var VPatch = __webpack_require__(56)

var updateWidget = __webpack_require__(64)
var updateWidget = __webpack_require__(68)

module.exports = applyPatch

@@ -3147,7 +3507,7 @@


/***/ },
/* 64 */
/* 68 */
/***/ function(module, exports, __webpack_require__) {

var isWidget = __webpack_require__(23)
@@ -3168,10 +3528,10 @@


/***/ },
/* 65 */
/* 69 */
/***/ function(module, exports, __webpack_require__) {

var createElement = __webpack_require__(60)
var createElement = __webpack_require__(64)

module.exports = createElement

@@ -3,26 +3,36 @@ var store = require('./store.js')(60);
var board = require('./components/board.js')
var vdux = require('vdux')

store.dispatch({type: 'SET', r:1, c:1})
store.dispatch({type: 'SET', r:1, c:2})
store.dispatch({type: 'SET', r:2, c:1})
store.dispatch({type: 'SET', r:2, c:2})


store.dispatch({type: 'SET', r:5, c:3})
store.dispatch({type: 'SET', r:5, c:4})
store.dispatch({type: 'SET', r:5, c:5})

var app = (state) => {
return board(state)
}

function makeGlider(){
store.dispatch({type: 'SET', r:4, c:2})
store.dispatch({type: 'SET', r:4, c:3})
store.dispatch({type: 'SET', r:4, c:4})
store.dispatch({type: 'SET', r:3, c:4})
store.dispatch({type: 'SET', r:2, c:3})
}

function spawnRandom(){
for (var i = 0, l = store.getState().length; i < l; i++) {
for (var j = 0; j < l; j++) {
if(Math.random() > 0.7)
store.dispatch({type: 'SET', r:i, c:j})
}
}
}

makeGlider()
spawnRandom()

document.addEventListener('DOMContentLoaded', () => {
vdux(store, app, document.body)
})

function step() {
store.dispatch({type: 'STEP'})
}

setInterval(step, 200)
setInterval(step, 100)