Repository: exupero/islands Branch: gh-pages Commit: cce8de43a13a Files: 14 Total size: 204.9 KB Directory structure: gitextract_9ridvt9g/ ├── .gitignore ├── Makefile ├── README.md ├── index.html ├── project.clj ├── resources/ │ └── public/ │ ├── css/ │ │ └── isle.css │ ├── index.html │ └── js/ │ └── main.js ├── scripts/ │ ├── build.clj │ └── figwheel.clj └── src/ └── isle/ ├── core.cljs ├── macros.clj ├── math.cljs └── svg.cljs ================================================ FILE CONTENTS ================================================ ================================================ FILE: .gitignore ================================================ /target /lib /classes /checkouts /resources/public/js/* pom.xml pom.xml.asc *.jar *.class .lein-deps-sum .lein-failures .lein-plugins .lein-repl-history js-dev !/resources/public/js/main.js ================================================ FILE: Makefile ================================================ build: lein run -m clojure.main scripts/build.clj ================================================ FILE: README.md ================================================ # Islands A procedural island generator I made with [@jvranish](https://github.com/jvranish) and [@shawn42](https://github.com/shawn42). Run with `lein run -m clojure.main scripts/figwheel.clj`. Open a browser to `http://localhost:3454/`. ================================================ FILE: index.html ================================================ Islands
================================================ FILE: project.clj ================================================ (defproject isle "0.1.0-SNAPSHOT" :description "FIXME: write description" :url "http://example.com/FIXME" :license {:name "Eclipse Public License" :url "http://www.eclipse.org/legal/epl-v10.html"} :source-paths ["src"] :dependencies [[org.clojure/clojure "1.7.0"] [org.clojure/clojurescript "1.7.122" :exclusions [org.apache.ant/ant]] [org.clojure/core.match "0.3.0-alpha4"] [org.clojure/core.async "0.2.374"] [rand-cljc "0.1.0"] [vdom "0.1.1-SNAPSHOT"]] :profiles {:dev {:dependencies [[figwheel-sidecar "0.5.0-2" :scope "provided"]]}}) ================================================ FILE: resources/public/css/isle.css ================================================ main { max-width: 600px; margin: 1rem auto; } button { margin-bottom: 1rem; } .island { stroke: green; stroke-width: 0.5; fill: limegreen; fill-rule: evenodd; vector-effect: non-scaling-stroke; } .water { fill: dodgerblue; } @media print { .island { fill: none; stroke: black; } .water { fill: none; } .unprinted { display: none; } } ================================================ FILE: resources/public/index.html ================================================ Islands
================================================ FILE: resources/public/js/main.js ================================================ if(typeof Math.imul == "undefined" || (Math.imul(0xffffffff,5) == 0)) { Math.imul = function (a, b) { var ah = (a >>> 16) & 0xffff; var al = a & 0xffff; var bh = (b >>> 16) & 0xffff; var bl = b & 0xffff; // the shift by 0 fixes the sign on the high part // the final |0 converts the unsigned value into a signed value return ((al * bl) + (((ah * bl + al * bh) << 16) >>> 0)|0); } } (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o * Available under the MIT License * ECMAScript compliant, uniform cross-browser split method */ /** * Splits a string into an array of strings using a regex or string separator. Matches of the * separator are not included in the result array. However, if `separator` is a regex that contains * capturing groups, backreferences are spliced into the result each time `separator` is matched. * Fixes browser bugs compared to the native `String.prototype.split` and can be used reliably * cross-browser. * @param {String} str String to split. * @param {RegExp|String} separator Regex or string to use for separating the string. * @param {Number} [limit] Maximum number of items to include in the result array. * @returns {Array} Array of substrings. * @example * * // Basic use * split('a b c d', ' '); * // -> ['a', 'b', 'c', 'd'] * * // With limit * split('a b c d', ' ', 2); * // -> ['a', 'b'] * * // Backreferences in result array * split('..word1 word2..', /([a-z]+)(\d+)/i); * // -> ['..', 'word', '1', ' ', 'word', '2', '..'] */ module.exports = (function split(undef) { var nativeSplit = String.prototype.split, compliantExecNpcg = /()??/.exec("")[1] === undef, // NPCG: nonparticipating capturing group self; self = function(str, separator, limit) { // If `separator` is not a regex, use `nativeSplit` if (Object.prototype.toString.call(separator) !== "[object RegExp]") { return nativeSplit.call(str, separator, limit); } var output = [], flags = (separator.ignoreCase ? "i" : "") + (separator.multiline ? "m" : "") + (separator.extended ? "x" : "") + // Proposed for ES6 (separator.sticky ? "y" : ""), // Firefox 3+ lastLastIndex = 0, // Make `global` and avoid `lastIndex` issues by working with a copy separator = new RegExp(separator.source, flags + "g"), separator2, match, lastIndex, lastLength; str += ""; // Type-convert if (!compliantExecNpcg) { // Doesn't need flags gy, but they don't hurt separator2 = new RegExp("^" + separator.source + "$(?!\\s)", flags); } /* Values for `limit`, per the spec: * If undefined: 4294967295 // Math.pow(2, 32) - 1 * If 0, Infinity, or NaN: 0 * If positive number: limit = Math.floor(limit); if (limit > 4294967295) limit -= 4294967296; * If negative number: 4294967296 - Math.floor(Math.abs(limit)) * If other: Type-convert, then use the above rules */ limit = limit === undef ? -1 >>> 0 : // Math.pow(2, 32) - 1 limit >>> 0; // ToUint32(limit) while (match = separator.exec(str)) { // `separator.lastIndex` is not reliable cross-browser lastIndex = match.index + match[0].length; if (lastIndex > lastLastIndex) { output.push(str.slice(lastLastIndex, match.index)); // Fix browsers whose `exec` methods don't consistently return `undefined` for // nonparticipating capturing groups if (!compliantExecNpcg && match.length > 1) { match[0].replace(separator2, function() { for (var i = 1; i < arguments.length - 2; i++) { if (arguments[i] === undef) { match[i] = undef; } } }); } if (match.length > 1 && match.index < str.length) { Array.prototype.push.apply(output, match.slice(1)); } lastLength = match[0].length; lastLastIndex = lastIndex; if (output.length >= limit) { break; } } if (separator.lastIndex === match.index) { separator.lastIndex++; // Avoid an infinite loop } } if (lastLastIndex === str.length) { if (lastLength || !separator.test("")) { output.push(""); } } else { output.push(str.slice(lastLastIndex)); } return output.length > limit ? output.slice(0, limit) : output; }; return self; })(); },{}],5:[function(require,module,exports){ 'use strict'; var OneVersionConstraint = require('individual/one-version'); var MY_VERSION = '7'; OneVersionConstraint('ev-store', MY_VERSION); var hashKey = '__EV_STORE_KEY@' + MY_VERSION; module.exports = EvStore; function EvStore(elem) { var hash = elem[hashKey]; if (!hash) { hash = elem[hashKey] = {}; } return hash; } },{"individual/one-version":7}],6:[function(require,module,exports){ (function (global){ 'use strict'; /*global window, global*/ var root = typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : {}; module.exports = Individual; function Individual(key, value) { if (key in root) { return root[key]; } root[key] = value; return value; } }).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) },{}],7:[function(require,module,exports){ 'use strict'; var Individual = require('./index.js'); module.exports = OneVersion; function OneVersion(moduleName, version, defaultValue) { var key = '__INDIVIDUAL_ONE_VERSION_' + moduleName; var enforceKey = key + '_ENFORCE_SINGLETON'; var versionValue = Individual(enforceKey, version); if (versionValue !== version) { throw new Error('Can only have one copy of ' + moduleName + '.\n' + 'You already have version ' + versionValue + ' installed.\n' + 'This means you cannot install version ' + version); } return Individual(key, defaultValue); } },{"./index.js":6}],8:[function(require,module,exports){ (function (global){ var topLevel = typeof global !== 'undefined' ? global : typeof window !== 'undefined' ? window : {} var minDoc = require('min-document'); if (typeof document !== 'undefined') { module.exports = document; } else { var doccy = topLevel['__GLOBAL_DOCUMENT_CACHE@4']; if (!doccy) { doccy = topLevel['__GLOBAL_DOCUMENT_CACHE@4'] = minDoc; } module.exports = doccy; } }).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) },{"min-document":1}],9:[function(require,module,exports){ "use strict"; module.exports = function isObject(x) { return typeof x === "object" && x !== null; }; },{}],10:[function(require,module,exports){ var nativeIsArray = Array.isArray var toString = Object.prototype.toString module.exports = nativeIsArray || isArray function isArray(obj) { return toString.call(obj) === "[object Array]" } },{}],11:[function(require,module,exports){ var patch = require("./vdom/patch.js") module.exports = patch },{"./vdom/patch.js":16}],12:[function(require,module,exports){ var isObject = require("is-object") var isHook = require("../vnode/is-vhook.js") module.exports = applyProperties function applyProperties(node, props, previous) { for (var propName in props) { var propValue = props[propName] if (propValue === undefined) { removeProperty(node, propName, propValue, previous); } else if (isHook(propValue)) { removeProperty(node, propName, propValue, previous) if (propValue.hook) { propValue.hook(node, propName, previous ? previous[propName] : undefined) } } else { if (isObject(propValue)) { patchObject(node, props, previous, propName, propValue); } else { node[propName] = propValue } } } } function removeProperty(node, propName, propValue, previous) { if (previous) { var previousValue = previous[propName] if (!isHook(previousValue)) { if (propName === "attributes") { for (var attrName in previousValue) { node.removeAttribute(attrName) } } else if (propName === "style") { for (var i in previousValue) { node.style[i] = "" } } else if (typeof previousValue === "string") { node[propName] = "" } else { node[propName] = null } } else if (previousValue.unhook) { previousValue.unhook(node, propName, propValue) } } } function patchObject(node, props, previous, propName, propValue) { var previousValue = previous ? previous[propName] : undefined // Set attributes if (propName === "attributes") { for (var attrName in propValue) { var attrValue = propValue[attrName] if (attrValue === undefined) { node.removeAttribute(attrName) } else { node.setAttribute(attrName, attrValue) } } return } if(previousValue && isObject(previousValue) && getPrototype(previousValue) !== getPrototype(propValue)) { node[propName] = propValue return } if (!isObject(node[propName])) { node[propName] = {} } var replacer = propName === "style" ? "" : undefined for (var k in propValue) { var value = propValue[k] node[propName][k] = (value === undefined) ? replacer : value } } function getPrototype(value) { if (Object.getPrototypeOf) { return Object.getPrototypeOf(value) } else if (value.__proto__) { return value.__proto__ } else if (value.constructor) { return value.constructor.prototype } } },{"../vnode/is-vhook.js":27,"is-object":9}],13:[function(require,module,exports){ var document = require("global/document") var applyProperties = require("./apply-properties") var isVNode = require("../vnode/is-vnode.js") var isVText = require("../vnode/is-vtext.js") var isWidget = require("../vnode/is-widget.js") var handleThunk = require("../vnode/handle-thunk.js") module.exports = createElement function createElement(vnode, opts) { var doc = opts ? opts.document || document : document var warn = opts ? opts.warn : null vnode = handleThunk(vnode).a if (isWidget(vnode)) { return vnode.init() } else if (isVText(vnode)) { return doc.createTextNode(vnode.text) } else if (!isVNode(vnode)) { if (warn) { warn("Item is not a valid virtual dom node", vnode) } return null } var node = (vnode.namespace === null) ? doc.createElement(vnode.tagName) : doc.createElementNS(vnode.namespace, vnode.tagName) var props = vnode.properties applyProperties(node, props) var children = vnode.children for (var i = 0; i < children.length; i++) { var childNode = createElement(children[i], opts) if (childNode) { node.appendChild(childNode) } } return node } },{"../vnode/handle-thunk.js":25,"../vnode/is-vnode.js":28,"../vnode/is-vtext.js":29,"../vnode/is-widget.js":30,"./apply-properties":12,"global/document":8}],14:[function(require,module,exports){ // Maps a virtual DOM tree onto a real DOM tree in an efficient manner. // We don't want to read all of the DOM nodes in the tree so we use // the in-order tree indexing to eliminate recursion down certain branches. // We only recurse into a DOM node if we know that it contains a child of // interest. var noChild = {} module.exports = domIndex function domIndex(rootNode, tree, indices, nodes) { if (!indices || indices.length === 0) { return {} } else { indices.sort(ascending) return recurse(rootNode, tree, indices, nodes, 0) } } function recurse(rootNode, tree, indices, nodes, rootIndex) { nodes = nodes || {} if (rootNode) { if (indexInRange(indices, rootIndex, rootIndex)) { nodes[rootIndex] = rootNode } var vChildren = tree.children if (vChildren) { var childNodes = rootNode.childNodes for (var i = 0; i < tree.children.length; i++) { rootIndex += 1 var vChild = vChildren[i] || noChild var nextIndex = rootIndex + (vChild.count || 0) // skip recursion down the tree if there are no nodes down here if (indexInRange(indices, rootIndex, nextIndex)) { recurse(childNodes[i], vChild, indices, nodes, rootIndex) } rootIndex = nextIndex } } } return nodes } // Binary search for an index in the interval [left, right] function indexInRange(indices, left, right) { if (indices.length === 0) { return false } var minIndex = 0 var maxIndex = indices.length - 1 var currentIndex var currentItem while (minIndex <= maxIndex) { currentIndex = ((maxIndex + minIndex) / 2) >> 0 currentItem = indices[currentIndex] if (minIndex === maxIndex) { return currentItem >= left && currentItem <= right } else if (currentItem < left) { minIndex = currentIndex + 1 } else if (currentItem > right) { maxIndex = currentIndex - 1 } else { return true } } return false; } function ascending(a, b) { return a > b ? 1 : -1 } },{}],15:[function(require,module,exports){ var applyProperties = require("./apply-properties") var isWidget = require("../vnode/is-widget.js") var VPatch = require("../vnode/vpatch.js") var render = require("./create-element") var updateWidget = require("./update-widget") module.exports = applyPatch function applyPatch(vpatch, domNode, renderOptions) { var type = vpatch.type var vNode = vpatch.vNode var patch = vpatch.patch switch (type) { case VPatch.REMOVE: return removeNode(domNode, vNode) case VPatch.INSERT: return insertNode(domNode, patch, renderOptions) case VPatch.VTEXT: return stringPatch(domNode, vNode, patch, renderOptions) case VPatch.WIDGET: return widgetPatch(domNode, vNode, patch, renderOptions) case VPatch.VNODE: return vNodePatch(domNode, vNode, patch, renderOptions) case VPatch.ORDER: reorderChildren(domNode, patch) return domNode case VPatch.PROPS: applyProperties(domNode, patch, vNode.properties) return domNode case VPatch.THUNK: return replaceRoot(domNode, renderOptions.patch(domNode, patch, renderOptions)) default: return domNode } } function removeNode(domNode, vNode) { var parentNode = domNode.parentNode if (parentNode) { parentNode.removeChild(domNode) } destroyWidget(domNode, vNode); return null } function insertNode(parentNode, vNode, renderOptions) { var newNode = render(vNode, renderOptions) if (parentNode) { parentNode.appendChild(newNode) } return parentNode } function stringPatch(domNode, leftVNode, vText, renderOptions) { var newNode if (domNode.nodeType === 3) { domNode.replaceData(0, domNode.length, vText.text) newNode = domNode } else { var parentNode = domNode.parentNode newNode = render(vText, renderOptions) if (parentNode && newNode !== domNode) { parentNode.replaceChild(newNode, domNode) } } return newNode } function widgetPatch(domNode, leftVNode, widget, renderOptions) { var updating = updateWidget(leftVNode, widget) var newNode if (updating) { newNode = widget.update(leftVNode, domNode) || domNode } else { newNode = render(widget, renderOptions) } var parentNode = domNode.parentNode if (parentNode && newNode !== domNode) { parentNode.replaceChild(newNode, domNode) } if (!updating) { destroyWidget(domNode, leftVNode) } return newNode } function vNodePatch(domNode, leftVNode, vNode, renderOptions) { var parentNode = domNode.parentNode var newNode = render(vNode, renderOptions) if (parentNode && newNode !== domNode) { parentNode.replaceChild(newNode, domNode) } return newNode } function destroyWidget(domNode, w) { if (typeof w.destroy === "function" && isWidget(w)) { w.destroy(domNode) } } function reorderChildren(domNode, moves) { var childNodes = domNode.childNodes var keyMap = {} var node var remove var insert for (var i = 0; i < moves.removes.length; i++) { remove = moves.removes[i] node = childNodes[remove.from] if (remove.key) { keyMap[remove.key] = node } domNode.removeChild(node) } var length = childNodes.length for (var j = 0; j < moves.inserts.length; j++) { insert = moves.inserts[j] node = keyMap[insert.key] // this is the weirdest bug i've ever seen in webkit domNode.insertBefore(node, insert.to >= length++ ? null : childNodes[insert.to]) } } function replaceRoot(oldRoot, newRoot) { if (oldRoot && newRoot && oldRoot !== newRoot && oldRoot.parentNode) { oldRoot.parentNode.replaceChild(newRoot, oldRoot) } return newRoot; } },{"../vnode/is-widget.js":30,"../vnode/vpatch.js":33,"./apply-properties":12,"./create-element":13,"./update-widget":17}],16:[function(require,module,exports){ var document = require("global/document") var isArray = require("x-is-array") var domIndex = require("./dom-index") var patchOp = require("./patch-op") module.exports = patch function patch(rootNode, patches) { return patchRecursive(rootNode, patches) } function patchRecursive(rootNode, patches, renderOptions) { var indices = patchIndices(patches) if (indices.length === 0) { return rootNode } var index = domIndex(rootNode, patches.a, indices) var ownerDocument = rootNode.ownerDocument if (!renderOptions) { renderOptions = { patch: patchRecursive } if (ownerDocument !== document) { renderOptions.document = ownerDocument } } for (var i = 0; i < indices.length; i++) { var nodeIndex = indices[i] rootNode = applyPatch(rootNode, index[nodeIndex], patches[nodeIndex], renderOptions) } return rootNode } function applyPatch(rootNode, domNode, patchList, renderOptions) { if (!domNode) { return rootNode } var newNode if (isArray(patchList)) { for (var i = 0; i < patchList.length; i++) { newNode = patchOp(patchList[i], domNode, renderOptions) if (domNode === rootNode) { rootNode = newNode } } } else { newNode = patchOp(patchList, domNode, renderOptions) if (domNode === rootNode) { rootNode = newNode } } return rootNode } function patchIndices(patches) { var indices = [] for (var key in patches) { if (key !== "a") { indices.push(Number(key)) } } return indices } },{"./dom-index":14,"./patch-op":15,"global/document":8,"x-is-array":10}],17:[function(require,module,exports){ var isWidget = require("../vnode/is-widget.js") module.exports = updateWidget function updateWidget(a, b) { if (isWidget(a) && isWidget(b)) { if ("name" in a && "name" in b) { return a.id === b.id } else { return a.init === b.init } } return false } },{"../vnode/is-widget.js":30}],18:[function(require,module,exports){ 'use strict'; module.exports = AttributeHook; function AttributeHook(namespace, value) { if (!(this instanceof AttributeHook)) { return new AttributeHook(namespace, value); } this.namespace = namespace; this.value = value; } AttributeHook.prototype.hook = function (node, prop, prev) { if (prev && prev.type === 'AttributeHook' && prev.value === this.value && prev.namespace === this.namespace) { return; } node.setAttributeNS(this.namespace, prop, this.value); }; AttributeHook.prototype.unhook = function (node, prop, next) { if (next && next.type === 'AttributeHook' && next.namespace === this.namespace) { return; } var colonPosition = prop.indexOf(':'); var localName = colonPosition > -1 ? prop.substr(colonPosition + 1) : prop; node.removeAttributeNS(this.namespace, localName); }; AttributeHook.prototype.type = 'AttributeHook'; },{}],19:[function(require,module,exports){ 'use strict'; var EvStore = require('ev-store'); module.exports = EvHook; function EvHook(value) { if (!(this instanceof EvHook)) { return new EvHook(value); } this.value = value; } EvHook.prototype.hook = function (node, propertyName) { var es = EvStore(node); var propName = propertyName.substr(3); es[propName] = this.value; }; EvHook.prototype.unhook = function(node, propertyName) { var es = EvStore(node); var propName = propertyName.substr(3); es[propName] = undefined; }; },{"ev-store":5}],20:[function(require,module,exports){ 'use strict'; module.exports = SoftSetHook; function SoftSetHook(value) { if (!(this instanceof SoftSetHook)) { return new SoftSetHook(value); } this.value = value; } SoftSetHook.prototype.hook = function (node, propertyName) { if (node[propertyName] !== this.value) { node[propertyName] = this.value; } }; },{}],21:[function(require,module,exports){ 'use strict'; var isArray = require('x-is-array'); var VNode = require('../vnode/vnode.js'); var VText = require('../vnode/vtext.js'); var isVNode = require('../vnode/is-vnode'); var isVText = require('../vnode/is-vtext'); var isWidget = require('../vnode/is-widget'); var isHook = require('../vnode/is-vhook'); var isVThunk = require('../vnode/is-thunk'); var parseTag = require('./parse-tag.js'); var softSetHook = require('./hooks/soft-set-hook.js'); var evHook = require('./hooks/ev-hook.js'); module.exports = h; function h(tagName, properties, children) { var childNodes = []; var tag, props, key, namespace; if (!children && isChildren(properties)) { children = properties; props = {}; } props = props || properties || {}; tag = parseTag(tagName, props); // support keys if (props.hasOwnProperty('key')) { key = props.key; props.key = undefined; } // support namespace if (props.hasOwnProperty('namespace')) { namespace = props.namespace; props.namespace = undefined; } // fix cursor bug if (tag === 'INPUT' && !namespace && props.hasOwnProperty('value') && props.value !== undefined && !isHook(props.value) ) { props.value = softSetHook(props.value); } transformProperties(props); if (children !== undefined && children !== null) { addChild(children, childNodes, tag, props); } return new VNode(tag, props, childNodes, key, namespace); } function addChild(c, childNodes, tag, props) { if (typeof c === 'string') { childNodes.push(new VText(c)); } else if (isChild(c)) { childNodes.push(c); } else if (isArray(c)) { for (var i = 0; i < c.length; i++) { addChild(c[i], childNodes, tag, props); } } else if (c === null || c === undefined) { return; } else { throw UnexpectedVirtualElement({ foreignObject: c, parentVnode: { tagName: tag, properties: props } }); } } function transformProperties(props) { for (var propName in props) { if (props.hasOwnProperty(propName)) { var value = props[propName]; if (isHook(value)) { continue; } if (propName.substr(0, 3) === 'ev-') { // add ev-foo support props[propName] = evHook(value); } } } } function isChild(x) { return isVNode(x) || isVText(x) || isWidget(x) || isVThunk(x); } function isChildren(x) { return typeof x === 'string' || isArray(x) || isChild(x); } function UnexpectedVirtualElement(data) { var err = new Error(); err.type = 'virtual-hyperscript.unexpected.virtual-element'; err.message = 'Unexpected virtual child passed to h().\n' + 'Expected a VNode / Vthunk / VWidget / string but:\n' + 'got:\n' + errorString(data.foreignObject) + '.\n' + 'The parent vnode is:\n' + errorString(data.parentVnode) '\n' + 'Suggested fix: change your `h(..., [ ... ])` callsite.'; err.foreignObject = data.foreignObject; err.parentVnode = data.parentVnode; return err; } function errorString(obj) { try { return JSON.stringify(obj, null, ' '); } catch (e) { return String(obj); } } },{"../vnode/is-thunk":26,"../vnode/is-vhook":27,"../vnode/is-vnode":28,"../vnode/is-vtext":29,"../vnode/is-widget":30,"../vnode/vnode.js":32,"../vnode/vtext.js":34,"./hooks/ev-hook.js":19,"./hooks/soft-set-hook.js":20,"./parse-tag.js":22,"x-is-array":10}],22:[function(require,module,exports){ 'use strict'; var split = require('browser-split'); var classIdSplit = /([\.#]?[a-zA-Z0-9_:-]+)/; var notClassId = /^\.|#/; module.exports = parseTag; function parseTag(tag, props) { if (!tag) { return 'DIV'; } var noId = !(props.hasOwnProperty('id')); var tagParts = split(tag, classIdSplit); var tagName = null; if (notClassId.test(tagParts[1])) { tagName = 'DIV'; } var classes, part, type, i; for (i = 0; i < tagParts.length; i++) { part = tagParts[i]; if (!part) { continue; } type = part.charAt(0); if (!tagName) { tagName = part; } else if (type === '.') { classes = classes || []; classes.push(part.substring(1, part.length)); } else if (type === '#' && noId) { props.id = part.substring(1, part.length); } } if (classes) { if (props.className) { classes.push(props.className); } props.className = classes.join(' '); } return props.namespace ? tagName : tagName.toUpperCase(); } },{"browser-split":4}],23:[function(require,module,exports){ 'use strict'; var DEFAULT_NAMESPACE = null; var EV_NAMESPACE = 'http://www.w3.org/2001/xml-events'; var XLINK_NAMESPACE = 'http://www.w3.org/1999/xlink'; var XML_NAMESPACE = 'http://www.w3.org/XML/1998/namespace'; // http://www.w3.org/TR/SVGTiny12/attributeTable.html // http://www.w3.org/TR/SVG/attindex.html var SVG_PROPERTIES = { 'about': DEFAULT_NAMESPACE, 'accent-height': DEFAULT_NAMESPACE, 'accumulate': DEFAULT_NAMESPACE, 'additive': DEFAULT_NAMESPACE, 'alignment-baseline': DEFAULT_NAMESPACE, 'alphabetic': DEFAULT_NAMESPACE, 'amplitude': DEFAULT_NAMESPACE, 'arabic-form': DEFAULT_NAMESPACE, 'ascent': DEFAULT_NAMESPACE, 'attributeName': DEFAULT_NAMESPACE, 'attributeType': DEFAULT_NAMESPACE, 'azimuth': DEFAULT_NAMESPACE, 'bandwidth': DEFAULT_NAMESPACE, 'baseFrequency': DEFAULT_NAMESPACE, 'baseProfile': DEFAULT_NAMESPACE, 'baseline-shift': DEFAULT_NAMESPACE, 'bbox': DEFAULT_NAMESPACE, 'begin': DEFAULT_NAMESPACE, 'bias': DEFAULT_NAMESPACE, 'by': DEFAULT_NAMESPACE, 'calcMode': DEFAULT_NAMESPACE, 'cap-height': DEFAULT_NAMESPACE, 'class': DEFAULT_NAMESPACE, 'clip': DEFAULT_NAMESPACE, 'clip-path': DEFAULT_NAMESPACE, 'clip-rule': DEFAULT_NAMESPACE, 'clipPathUnits': DEFAULT_NAMESPACE, 'color': DEFAULT_NAMESPACE, 'color-interpolation': DEFAULT_NAMESPACE, 'color-interpolation-filters': DEFAULT_NAMESPACE, 'color-profile': DEFAULT_NAMESPACE, 'color-rendering': DEFAULT_NAMESPACE, 'content': DEFAULT_NAMESPACE, 'contentScriptType': DEFAULT_NAMESPACE, 'contentStyleType': DEFAULT_NAMESPACE, 'cursor': DEFAULT_NAMESPACE, 'cx': DEFAULT_NAMESPACE, 'cy': DEFAULT_NAMESPACE, 'd': DEFAULT_NAMESPACE, 'datatype': DEFAULT_NAMESPACE, 'defaultAction': DEFAULT_NAMESPACE, 'descent': DEFAULT_NAMESPACE, 'diffuseConstant': DEFAULT_NAMESPACE, 'direction': DEFAULT_NAMESPACE, 'display': DEFAULT_NAMESPACE, 'divisor': DEFAULT_NAMESPACE, 'dominant-baseline': DEFAULT_NAMESPACE, 'dur': DEFAULT_NAMESPACE, 'dx': DEFAULT_NAMESPACE, 'dy': DEFAULT_NAMESPACE, 'edgeMode': DEFAULT_NAMESPACE, 'editable': DEFAULT_NAMESPACE, 'elevation': DEFAULT_NAMESPACE, 'enable-background': DEFAULT_NAMESPACE, 'end': DEFAULT_NAMESPACE, 'ev:event': EV_NAMESPACE, 'event': DEFAULT_NAMESPACE, 'exponent': DEFAULT_NAMESPACE, 'externalResourcesRequired': DEFAULT_NAMESPACE, 'fill': DEFAULT_NAMESPACE, 'fill-opacity': DEFAULT_NAMESPACE, 'fill-rule': DEFAULT_NAMESPACE, 'filter': DEFAULT_NAMESPACE, 'filterRes': DEFAULT_NAMESPACE, 'filterUnits': DEFAULT_NAMESPACE, 'flood-color': DEFAULT_NAMESPACE, 'flood-opacity': DEFAULT_NAMESPACE, 'focusHighlight': DEFAULT_NAMESPACE, 'focusable': DEFAULT_NAMESPACE, 'font-family': DEFAULT_NAMESPACE, 'font-size': DEFAULT_NAMESPACE, 'font-size-adjust': DEFAULT_NAMESPACE, 'font-stretch': DEFAULT_NAMESPACE, 'font-style': DEFAULT_NAMESPACE, 'font-variant': DEFAULT_NAMESPACE, 'font-weight': DEFAULT_NAMESPACE, 'format': DEFAULT_NAMESPACE, 'from': DEFAULT_NAMESPACE, 'fx': DEFAULT_NAMESPACE, 'fy': DEFAULT_NAMESPACE, 'g1': DEFAULT_NAMESPACE, 'g2': DEFAULT_NAMESPACE, 'glyph-name': DEFAULT_NAMESPACE, 'glyph-orientation-horizontal': DEFAULT_NAMESPACE, 'glyph-orientation-vertical': DEFAULT_NAMESPACE, 'glyphRef': DEFAULT_NAMESPACE, 'gradientTransform': DEFAULT_NAMESPACE, 'gradientUnits': DEFAULT_NAMESPACE, 'handler': DEFAULT_NAMESPACE, 'hanging': DEFAULT_NAMESPACE, 'height': DEFAULT_NAMESPACE, 'horiz-adv-x': DEFAULT_NAMESPACE, 'horiz-origin-x': DEFAULT_NAMESPACE, 'horiz-origin-y': DEFAULT_NAMESPACE, 'id': DEFAULT_NAMESPACE, 'ideographic': DEFAULT_NAMESPACE, 'image-rendering': DEFAULT_NAMESPACE, 'in': DEFAULT_NAMESPACE, 'in2': DEFAULT_NAMESPACE, 'initialVisibility': DEFAULT_NAMESPACE, 'intercept': DEFAULT_NAMESPACE, 'k': DEFAULT_NAMESPACE, 'k1': DEFAULT_NAMESPACE, 'k2': DEFAULT_NAMESPACE, 'k3': DEFAULT_NAMESPACE, 'k4': DEFAULT_NAMESPACE, 'kernelMatrix': DEFAULT_NAMESPACE, 'kernelUnitLength': DEFAULT_NAMESPACE, 'kerning': DEFAULT_NAMESPACE, 'keyPoints': DEFAULT_NAMESPACE, 'keySplines': DEFAULT_NAMESPACE, 'keyTimes': DEFAULT_NAMESPACE, 'lang': DEFAULT_NAMESPACE, 'lengthAdjust': DEFAULT_NAMESPACE, 'letter-spacing': DEFAULT_NAMESPACE, 'lighting-color': DEFAULT_NAMESPACE, 'limitingConeAngle': DEFAULT_NAMESPACE, 'local': DEFAULT_NAMESPACE, 'marker-end': DEFAULT_NAMESPACE, 'marker-mid': DEFAULT_NAMESPACE, 'marker-start': DEFAULT_NAMESPACE, 'markerHeight': DEFAULT_NAMESPACE, 'markerUnits': DEFAULT_NAMESPACE, 'markerWidth': DEFAULT_NAMESPACE, 'mask': DEFAULT_NAMESPACE, 'maskContentUnits': DEFAULT_NAMESPACE, 'maskUnits': DEFAULT_NAMESPACE, 'mathematical': DEFAULT_NAMESPACE, 'max': DEFAULT_NAMESPACE, 'media': DEFAULT_NAMESPACE, 'mediaCharacterEncoding': DEFAULT_NAMESPACE, 'mediaContentEncodings': DEFAULT_NAMESPACE, 'mediaSize': DEFAULT_NAMESPACE, 'mediaTime': DEFAULT_NAMESPACE, 'method': DEFAULT_NAMESPACE, 'min': DEFAULT_NAMESPACE, 'mode': DEFAULT_NAMESPACE, 'name': DEFAULT_NAMESPACE, 'nav-down': DEFAULT_NAMESPACE, 'nav-down-left': DEFAULT_NAMESPACE, 'nav-down-right': DEFAULT_NAMESPACE, 'nav-left': DEFAULT_NAMESPACE, 'nav-next': DEFAULT_NAMESPACE, 'nav-prev': DEFAULT_NAMESPACE, 'nav-right': DEFAULT_NAMESPACE, 'nav-up': DEFAULT_NAMESPACE, 'nav-up-left': DEFAULT_NAMESPACE, 'nav-up-right': DEFAULT_NAMESPACE, 'numOctaves': DEFAULT_NAMESPACE, 'observer': DEFAULT_NAMESPACE, 'offset': DEFAULT_NAMESPACE, 'opacity': DEFAULT_NAMESPACE, 'operator': DEFAULT_NAMESPACE, 'order': DEFAULT_NAMESPACE, 'orient': DEFAULT_NAMESPACE, 'orientation': DEFAULT_NAMESPACE, 'origin': DEFAULT_NAMESPACE, 'overflow': DEFAULT_NAMESPACE, 'overlay': DEFAULT_NAMESPACE, 'overline-position': DEFAULT_NAMESPACE, 'overline-thickness': DEFAULT_NAMESPACE, 'panose-1': DEFAULT_NAMESPACE, 'path': DEFAULT_NAMESPACE, 'pathLength': DEFAULT_NAMESPACE, 'patternContentUnits': DEFAULT_NAMESPACE, 'patternTransform': DEFAULT_NAMESPACE, 'patternUnits': DEFAULT_NAMESPACE, 'phase': DEFAULT_NAMESPACE, 'playbackOrder': DEFAULT_NAMESPACE, 'pointer-events': DEFAULT_NAMESPACE, 'points': DEFAULT_NAMESPACE, 'pointsAtX': DEFAULT_NAMESPACE, 'pointsAtY': DEFAULT_NAMESPACE, 'pointsAtZ': DEFAULT_NAMESPACE, 'preserveAlpha': DEFAULT_NAMESPACE, 'preserveAspectRatio': DEFAULT_NAMESPACE, 'primitiveUnits': DEFAULT_NAMESPACE, 'propagate': DEFAULT_NAMESPACE, 'property': DEFAULT_NAMESPACE, 'r': DEFAULT_NAMESPACE, 'radius': DEFAULT_NAMESPACE, 'refX': DEFAULT_NAMESPACE, 'refY': DEFAULT_NAMESPACE, 'rel': DEFAULT_NAMESPACE, 'rendering-intent': DEFAULT_NAMESPACE, 'repeatCount': DEFAULT_NAMESPACE, 'repeatDur': DEFAULT_NAMESPACE, 'requiredExtensions': DEFAULT_NAMESPACE, 'requiredFeatures': DEFAULT_NAMESPACE, 'requiredFonts': DEFAULT_NAMESPACE, 'requiredFormats': DEFAULT_NAMESPACE, 'resource': DEFAULT_NAMESPACE, 'restart': DEFAULT_NAMESPACE, 'result': DEFAULT_NAMESPACE, 'rev': DEFAULT_NAMESPACE, 'role': DEFAULT_NAMESPACE, 'rotate': DEFAULT_NAMESPACE, 'rx': DEFAULT_NAMESPACE, 'ry': DEFAULT_NAMESPACE, 'scale': DEFAULT_NAMESPACE, 'seed': DEFAULT_NAMESPACE, 'shape-rendering': DEFAULT_NAMESPACE, 'slope': DEFAULT_NAMESPACE, 'snapshotTime': DEFAULT_NAMESPACE, 'spacing': DEFAULT_NAMESPACE, 'specularConstant': DEFAULT_NAMESPACE, 'specularExponent': DEFAULT_NAMESPACE, 'spreadMethod': DEFAULT_NAMESPACE, 'startOffset': DEFAULT_NAMESPACE, 'stdDeviation': DEFAULT_NAMESPACE, 'stemh': DEFAULT_NAMESPACE, 'stemv': DEFAULT_NAMESPACE, 'stitchTiles': DEFAULT_NAMESPACE, 'stop-color': DEFAULT_NAMESPACE, 'stop-opacity': DEFAULT_NAMESPACE, 'strikethrough-position': DEFAULT_NAMESPACE, 'strikethrough-thickness': DEFAULT_NAMESPACE, 'string': DEFAULT_NAMESPACE, 'stroke': DEFAULT_NAMESPACE, 'stroke-dasharray': DEFAULT_NAMESPACE, 'stroke-dashoffset': DEFAULT_NAMESPACE, 'stroke-linecap': DEFAULT_NAMESPACE, 'stroke-linejoin': DEFAULT_NAMESPACE, 'stroke-miterlimit': DEFAULT_NAMESPACE, 'stroke-opacity': DEFAULT_NAMESPACE, 'stroke-width': DEFAULT_NAMESPACE, 'surfaceScale': DEFAULT_NAMESPACE, 'syncBehavior': DEFAULT_NAMESPACE, 'syncBehaviorDefault': DEFAULT_NAMESPACE, 'syncMaster': DEFAULT_NAMESPACE, 'syncTolerance': DEFAULT_NAMESPACE, 'syncToleranceDefault': DEFAULT_NAMESPACE, 'systemLanguage': DEFAULT_NAMESPACE, 'tableValues': DEFAULT_NAMESPACE, 'target': DEFAULT_NAMESPACE, 'targetX': DEFAULT_NAMESPACE, 'targetY': DEFAULT_NAMESPACE, 'text-anchor': DEFAULT_NAMESPACE, 'text-decoration': DEFAULT_NAMESPACE, 'text-rendering': DEFAULT_NAMESPACE, 'textLength': DEFAULT_NAMESPACE, 'timelineBegin': DEFAULT_NAMESPACE, 'title': DEFAULT_NAMESPACE, 'to': DEFAULT_NAMESPACE, 'transform': DEFAULT_NAMESPACE, 'transformBehavior': DEFAULT_NAMESPACE, 'type': DEFAULT_NAMESPACE, 'typeof': DEFAULT_NAMESPACE, 'u1': DEFAULT_NAMESPACE, 'u2': DEFAULT_NAMESPACE, 'underline-position': DEFAULT_NAMESPACE, 'underline-thickness': DEFAULT_NAMESPACE, 'unicode': DEFAULT_NAMESPACE, 'unicode-bidi': DEFAULT_NAMESPACE, 'unicode-range': DEFAULT_NAMESPACE, 'units-per-em': DEFAULT_NAMESPACE, 'v-alphabetic': DEFAULT_NAMESPACE, 'v-hanging': DEFAULT_NAMESPACE, 'v-ideographic': DEFAULT_NAMESPACE, 'v-mathematical': DEFAULT_NAMESPACE, 'values': DEFAULT_NAMESPACE, 'version': DEFAULT_NAMESPACE, 'vert-adv-y': DEFAULT_NAMESPACE, 'vert-origin-x': DEFAULT_NAMESPACE, 'vert-origin-y': DEFAULT_NAMESPACE, 'viewBox': DEFAULT_NAMESPACE, 'viewTarget': DEFAULT_NAMESPACE, 'visibility': DEFAULT_NAMESPACE, 'width': DEFAULT_NAMESPACE, 'widths': DEFAULT_NAMESPACE, 'word-spacing': DEFAULT_NAMESPACE, 'writing-mode': DEFAULT_NAMESPACE, 'x': DEFAULT_NAMESPACE, 'x-height': DEFAULT_NAMESPACE, 'x1': DEFAULT_NAMESPACE, 'x2': DEFAULT_NAMESPACE, 'xChannelSelector': DEFAULT_NAMESPACE, 'xlink:actuate': XLINK_NAMESPACE, 'xlink:arcrole': XLINK_NAMESPACE, 'xlink:href': XLINK_NAMESPACE, 'xlink:role': XLINK_NAMESPACE, 'xlink:show': XLINK_NAMESPACE, 'xlink:title': XLINK_NAMESPACE, 'xlink:type': XLINK_NAMESPACE, 'xml:base': XML_NAMESPACE, 'xml:id': XML_NAMESPACE, 'xml:lang': XML_NAMESPACE, 'xml:space': XML_NAMESPACE, 'y': DEFAULT_NAMESPACE, 'y1': DEFAULT_NAMESPACE, 'y2': DEFAULT_NAMESPACE, 'yChannelSelector': DEFAULT_NAMESPACE, 'z': DEFAULT_NAMESPACE, 'zoomAndPan': DEFAULT_NAMESPACE }; module.exports = SVGAttributeNamespace; function SVGAttributeNamespace(value) { if (SVG_PROPERTIES.hasOwnProperty(value)) { return SVG_PROPERTIES[value]; } } },{}],24:[function(require,module,exports){ 'use strict'; var isArray = require('x-is-array'); var h = require('./index.js'); var SVGAttributeNamespace = require('./svg-attribute-namespace'); var attributeHook = require('./hooks/attribute-hook'); var SVG_NAMESPACE = 'http://www.w3.org/2000/svg'; module.exports = svg; function svg(tagName, properties, children) { if (!children && isChildren(properties)) { children = properties; properties = {}; } properties = properties || {}; // set namespace for svg properties.namespace = SVG_NAMESPACE; var attributes = properties.attributes || (properties.attributes = {}); for (var key in properties) { if (!properties.hasOwnProperty(key)) { continue; } var namespace = SVGAttributeNamespace(key); if (namespace === undefined) { // not a svg attribute continue; } var value = properties[key]; if (typeof value !== 'string' && typeof value !== 'number' && typeof value !== 'boolean' ) { continue; } if (namespace !== null) { // namespaced attribute properties[key] = attributeHook(namespace, value); continue; } attributes[key] = value properties[key] = undefined } return h(tagName, properties, children); } function isChildren(x) { return typeof x === 'string' || isArray(x); } },{"./hooks/attribute-hook":18,"./index.js":21,"./svg-attribute-namespace":23,"x-is-array":10}],25:[function(require,module,exports){ var isVNode = require("./is-vnode") var isVText = require("./is-vtext") var isWidget = require("./is-widget") var isThunk = require("./is-thunk") module.exports = handleThunk function handleThunk(a, b) { var renderedA = a var renderedB = b if (isThunk(b)) { renderedB = renderThunk(b, a) } if (isThunk(a)) { renderedA = renderThunk(a, null) } return { a: renderedA, b: renderedB } } function renderThunk(thunk, previous) { var renderedThunk = thunk.vnode if (!renderedThunk) { renderedThunk = thunk.vnode = thunk.render(previous) } if (!(isVNode(renderedThunk) || isVText(renderedThunk) || isWidget(renderedThunk))) { throw new Error("thunk did not return a valid node"); } return renderedThunk } },{"./is-thunk":26,"./is-vnode":28,"./is-vtext":29,"./is-widget":30}],26:[function(require,module,exports){ module.exports = isThunk function isThunk(t) { return t && t.type === "Thunk" } },{}],27:[function(require,module,exports){ module.exports = isHook function isHook(hook) { return hook && (typeof hook.hook === "function" && !hook.hasOwnProperty("hook") || typeof hook.unhook === "function" && !hook.hasOwnProperty("unhook")) } },{}],28:[function(require,module,exports){ var version = require("./version") module.exports = isVirtualNode function isVirtualNode(x) { return x && x.type === "VirtualNode" && x.version === version } },{"./version":31}],29:[function(require,module,exports){ var version = require("./version") module.exports = isVirtualText function isVirtualText(x) { return x && x.type === "VirtualText" && x.version === version } },{"./version":31}],30:[function(require,module,exports){ module.exports = isWidget function isWidget(w) { return w && w.type === "Widget" } },{}],31:[function(require,module,exports){ module.exports = "2" },{}],32:[function(require,module,exports){ var version = require("./version") var isVNode = require("./is-vnode") var isWidget = require("./is-widget") var isThunk = require("./is-thunk") var isVHook = require("./is-vhook") module.exports = VirtualNode var noProperties = {} var noChildren = [] function VirtualNode(tagName, properties, children, key, namespace) { this.tagName = tagName this.properties = properties || noProperties this.children = children || noChildren this.key = key != null ? String(key) : undefined this.namespace = (typeof namespace === "string") ? namespace : null var count = (children && children.length) || 0 var descendants = 0 var hasWidgets = false var hasThunks = false var descendantHooks = false var hooks for (var propName in properties) { if (properties.hasOwnProperty(propName)) { var property = properties[propName] if (isVHook(property) && property.unhook) { if (!hooks) { hooks = {} } hooks[propName] = property } } } for (var i = 0; i < count; i++) { var child = children[i] if (isVNode(child)) { descendants += child.count || 0 if (!hasWidgets && child.hasWidgets) { hasWidgets = true } if (!hasThunks && child.hasThunks) { hasThunks = true } if (!descendantHooks && (child.hooks || child.descendantHooks)) { descendantHooks = true } } else if (!hasWidgets && isWidget(child)) { if (typeof child.destroy === "function") { hasWidgets = true } } else if (!hasThunks && isThunk(child)) { hasThunks = true; } } this.count = count + descendants this.hasWidgets = hasWidgets this.hasThunks = hasThunks this.hooks = hooks this.descendantHooks = descendantHooks } VirtualNode.prototype.version = version VirtualNode.prototype.type = "VirtualNode" },{"./is-thunk":26,"./is-vhook":27,"./is-vnode":28,"./is-widget":30,"./version":31}],33:[function(require,module,exports){ var version = require("./version") VirtualPatch.NONE = 0 VirtualPatch.VTEXT = 1 VirtualPatch.VNODE = 2 VirtualPatch.WIDGET = 3 VirtualPatch.PROPS = 4 VirtualPatch.ORDER = 5 VirtualPatch.INSERT = 6 VirtualPatch.REMOVE = 7 VirtualPatch.THUNK = 8 module.exports = VirtualPatch function VirtualPatch(type, vNode, patch) { this.type = Number(type) this.vNode = vNode this.patch = patch } VirtualPatch.prototype.version = version VirtualPatch.prototype.type = "VirtualPatch" },{"./version":31}],34:[function(require,module,exports){ var version = require("./version") module.exports = VirtualText function VirtualText(text) { this.text = String(text) } VirtualText.prototype.version = version VirtualText.prototype.type = "VirtualText" },{"./version":31}],35:[function(require,module,exports){ var isObject = require("is-object") var isHook = require("../vnode/is-vhook") module.exports = diffProps function diffProps(a, b) { var diff for (var aKey in a) { if (!(aKey in b)) { diff = diff || {} diff[aKey] = undefined } var aValue = a[aKey] var bValue = b[aKey] if (aValue === bValue) { continue } else if (isObject(aValue) && isObject(bValue)) { if (getPrototype(bValue) !== getPrototype(aValue)) { diff = diff || {} diff[aKey] = bValue } else if (isHook(bValue)) { diff = diff || {} diff[aKey] = bValue } else { var objectDiff = diffProps(aValue, bValue) if (objectDiff) { diff = diff || {} diff[aKey] = objectDiff } } } else { diff = diff || {} diff[aKey] = bValue } } for (var bKey in b) { if (!(bKey in a)) { diff = diff || {} diff[bKey] = b[bKey] } } return diff } function getPrototype(value) { if (Object.getPrototypeOf) { return Object.getPrototypeOf(value) } else if (value.__proto__) { return value.__proto__ } else if (value.constructor) { return value.constructor.prototype } } },{"../vnode/is-vhook":27,"is-object":9}],36:[function(require,module,exports){ var isArray = require("x-is-array") var VPatch = require("../vnode/vpatch") var isVNode = require("../vnode/is-vnode") var isVText = require("../vnode/is-vtext") var isWidget = require("../vnode/is-widget") var isThunk = require("../vnode/is-thunk") var handleThunk = require("../vnode/handle-thunk") var diffProps = require("./diff-props") module.exports = diff function diff(a, b) { var patch = { a: a } walk(a, b, patch, 0) return patch } function walk(a, b, patch, index) { if (a === b) { return } var apply = patch[index] var applyClear = false if (isThunk(a) || isThunk(b)) { thunks(a, b, patch, index) } else if (b == null) { // If a is a widget we will add a remove patch for it // Otherwise any child widgets/hooks must be destroyed. // This prevents adding two remove patches for a widget. if (!isWidget(a)) { clearState(a, patch, index) apply = patch[index] } apply = appendPatch(apply, new VPatch(VPatch.REMOVE, a, b)) } else if (isVNode(b)) { if (isVNode(a)) { if (a.tagName === b.tagName && a.namespace === b.namespace && a.key === b.key) { var propsPatch = diffProps(a.properties, b.properties) if (propsPatch) { apply = appendPatch(apply, new VPatch(VPatch.PROPS, a, propsPatch)) } apply = diffChildren(a, b, patch, apply, index) } else { apply = appendPatch(apply, new VPatch(VPatch.VNODE, a, b)) applyClear = true } } else { apply = appendPatch(apply, new VPatch(VPatch.VNODE, a, b)) applyClear = true } } else if (isVText(b)) { if (!isVText(a)) { apply = appendPatch(apply, new VPatch(VPatch.VTEXT, a, b)) applyClear = true } else if (a.text !== b.text) { apply = appendPatch(apply, new VPatch(VPatch.VTEXT, a, b)) } } else if (isWidget(b)) { if (!isWidget(a)) { applyClear = true } apply = appendPatch(apply, new VPatch(VPatch.WIDGET, a, b)) } if (apply) { patch[index] = apply } if (applyClear) { clearState(a, patch, index) } } function diffChildren(a, b, patch, apply, index) { var aChildren = a.children var orderedSet = reorder(aChildren, b.children) var bChildren = orderedSet.children var aLen = aChildren.length var bLen = bChildren.length var len = aLen > bLen ? aLen : bLen for (var i = 0; i < len; i++) { var leftNode = aChildren[i] var rightNode = bChildren[i] index += 1 if (!leftNode) { if (rightNode) { // Excess nodes in b need to be added apply = appendPatch(apply, new VPatch(VPatch.INSERT, null, rightNode)) } } else { walk(leftNode, rightNode, patch, index) } if (isVNode(leftNode) && leftNode.count) { index += leftNode.count } } if (orderedSet.moves) { // Reorder nodes last apply = appendPatch(apply, new VPatch( VPatch.ORDER, a, orderedSet.moves )) } return apply } function clearState(vNode, patch, index) { // TODO: Make this a single walk, not two unhook(vNode, patch, index) destroyWidgets(vNode, patch, index) } // Patch records for all destroyed widgets must be added because we need // a DOM node reference for the destroy function function destroyWidgets(vNode, patch, index) { if (isWidget(vNode)) { if (typeof vNode.destroy === "function") { patch[index] = appendPatch( patch[index], new VPatch(VPatch.REMOVE, vNode, null) ) } } else if (isVNode(vNode) && (vNode.hasWidgets || vNode.hasThunks)) { var children = vNode.children var len = children.length for (var i = 0; i < len; i++) { var child = children[i] index += 1 destroyWidgets(child, patch, index) if (isVNode(child) && child.count) { index += child.count } } } else if (isThunk(vNode)) { thunks(vNode, null, patch, index) } } // Create a sub-patch for thunks function thunks(a, b, patch, index) { var nodes = handleThunk(a, b) var thunkPatch = diff(nodes.a, nodes.b) if (hasPatches(thunkPatch)) { patch[index] = new VPatch(VPatch.THUNK, null, thunkPatch) } } function hasPatches(patch) { for (var index in patch) { if (index !== "a") { return true } } return false } // Execute hooks when two nodes are identical function unhook(vNode, patch, index) { if (isVNode(vNode)) { if (vNode.hooks) { patch[index] = appendPatch( patch[index], new VPatch( VPatch.PROPS, vNode, undefinedKeys(vNode.hooks) ) ) } if (vNode.descendantHooks || vNode.hasThunks) { var children = vNode.children var len = children.length for (var i = 0; i < len; i++) { var child = children[i] index += 1 unhook(child, patch, index) if (isVNode(child) && child.count) { index += child.count } } } } else if (isThunk(vNode)) { thunks(vNode, null, patch, index) } } function undefinedKeys(obj) { var result = {} for (var key in obj) { result[key] = undefined } return result } // List diff, naive left to right reordering function reorder(aChildren, bChildren) { // O(M) time, O(M) memory var bChildIndex = keyIndex(bChildren) var bKeys = bChildIndex.keys var bFree = bChildIndex.free if (bFree.length === bChildren.length) { return { children: bChildren, moves: null } } // O(N) time, O(N) memory var aChildIndex = keyIndex(aChildren) var aKeys = aChildIndex.keys var aFree = aChildIndex.free if (aFree.length === aChildren.length) { return { children: bChildren, moves: null } } // O(MAX(N, M)) memory var newChildren = [] var freeIndex = 0 var freeCount = bFree.length var deletedItems = 0 // Iterate through a and match a node in b // O(N) time, for (var i = 0 ; i < aChildren.length; i++) { var aItem = aChildren[i] var itemIndex if (aItem.key) { if (bKeys.hasOwnProperty(aItem.key)) { // Match up the old keys itemIndex = bKeys[aItem.key] newChildren.push(bChildren[itemIndex]) } else { // Remove old keyed items itemIndex = i - deletedItems++ newChildren.push(null) } } else { // Match the item in a with the next free item in b if (freeIndex < freeCount) { itemIndex = bFree[freeIndex++] newChildren.push(bChildren[itemIndex]) } else { // There are no free items in b to match with // the free items in a, so the extra free nodes // are deleted. itemIndex = i - deletedItems++ newChildren.push(null) } } } var lastFreeIndex = freeIndex >= bFree.length ? bChildren.length : bFree[freeIndex] // Iterate through b and append any new keys // O(M) time for (var j = 0; j < bChildren.length; j++) { var newItem = bChildren[j] if (newItem.key) { if (!aKeys.hasOwnProperty(newItem.key)) { // Add any new keyed items // We are adding new items to the end and then sorting them // in place. In future we should insert new items in place. newChildren.push(newItem) } } else if (j >= lastFreeIndex) { // Add any leftover non-keyed items newChildren.push(newItem) } } var simulate = newChildren.slice() var simulateIndex = 0 var removes = [] var inserts = [] var simulateItem for (var k = 0; k < bChildren.length;) { var wantedItem = bChildren[k] simulateItem = simulate[simulateIndex] // remove items while (simulateItem === null && simulate.length) { removes.push(remove(simulate, simulateIndex, null)) simulateItem = simulate[simulateIndex] } if (!simulateItem || simulateItem.key !== wantedItem.key) { // if we need a key in this position... if (wantedItem.key) { if (simulateItem && simulateItem.key) { // if an insert doesn't put this key in place, it needs to move if (bKeys[simulateItem.key] !== k + 1) { removes.push(remove(simulate, simulateIndex, simulateItem.key)) simulateItem = simulate[simulateIndex] // if the remove didn't put the wanted item in place, we need to insert it if (!simulateItem || simulateItem.key !== wantedItem.key) { inserts.push({key: wantedItem.key, to: k}) } // items are matching, so skip ahead else { simulateIndex++ } } else { inserts.push({key: wantedItem.key, to: k}) } } else { inserts.push({key: wantedItem.key, to: k}) } k++ } // a key in simulate has no matching wanted key, remove it else if (simulateItem && simulateItem.key) { removes.push(remove(simulate, simulateIndex, simulateItem.key)) } } else { simulateIndex++ k++ } } // remove all the remaining nodes from simulate while(simulateIndex < simulate.length) { simulateItem = simulate[simulateIndex] removes.push(remove(simulate, simulateIndex, simulateItem && simulateItem.key)) } // If the only moves we have are deletes then we can just // let the delete patch remove these items. if (removes.length === deletedItems && !inserts.length) { return { children: newChildren, moves: null } } return { children: newChildren, moves: { removes: removes, inserts: inserts } } } function remove(arr, index, key) { arr.splice(index, 1) return { from: index, key: key } } function keyIndex(children) { var keys = {} var free = [] var length = children.length for (var i = 0; i < length; i++) { var child = children[i] if (child.key) { keys[child.key] = i } else { free.push(i) } } return { keys: keys, // A hash of key name to index free: free, // An array of unkeyed item indices } } function appendPatch(apply, patch) { if (apply) { if (isArray(apply)) { apply.push(patch) } else { apply = [apply, patch] } return apply } else { return patch } } },{"../vnode/handle-thunk":25,"../vnode/is-thunk":26,"../vnode/is-vnode":28,"../vnode/is-vtext":29,"../vnode/is-widget":30,"../vnode/vpatch":33,"./diff-props":35,"x-is-array":10}],37:[function(require,module,exports){ return VDOM = { diff: require("virtual-dom/diff"), patch: require("virtual-dom/patch"), create: require("virtual-dom/create-element"), VHtml: require("virtual-dom/vnode/vnode"), VText: require("virtual-dom/vnode/vtext"), VSvg: require("virtual-dom/virtual-hyperscript/svg") } },{"virtual-dom/create-element":2,"virtual-dom/diff":3,"virtual-dom/patch":11,"virtual-dom/virtual-hyperscript/svg":24,"virtual-dom/vnode/vnode":32,"virtual-dom/vnode/vtext":34}]},{},[37]); var g,aa=this; function u(a){var b=typeof a;if("object"==b)if(a){if(a instanceof Array)return"array";if(a instanceof Object)return b;var c=Object.prototype.toString.call(a);if("[object Window]"==c)return"object";if("[object Array]"==c||"number"==typeof a.length&&"undefined"!=typeof a.splice&&"undefined"!=typeof a.propertyIsEnumerable&&!a.propertyIsEnumerable("splice"))return"array";if("[object Function]"==c||"undefined"!=typeof a.call&&"undefined"!=typeof a.propertyIsEnumerable&&!a.propertyIsEnumerable("call"))return"function"}else return"null";else if("function"== b&&"undefined"==typeof a.call)return"object";return b}function ba(a){return a[ca]||(a[ca]=++ea)}var ca="closure_uid_"+(1E9*Math.random()>>>0),ea=0;function ga(a,b,c){return a.call.apply(a.bind,arguments)}function ja(a,b,c){if(!a)throw Error();if(2b?1:a>>16&65535)*d+c*(b>>>16&65535)<<16>>>0)|0};function Zb(a){a=Yb(a|0,-862048943);return Yb(a<<15|a>>>-15,461845907)} function $b(a,b){var c=(a|0)^(b|0);return Yb(c<<13|c>>>-13,5)+-430675100|0}function ac(a,b){var c=(a|0)^b,c=Yb(c^c>>>16,-2048144789),c=Yb(c^c>>>13,-1028477387);return c^c>>>16}function bc(a){var b;a:{b=1;for(var c=0;;)if(b>2)}function Ja(a,b){return b instanceof a}function lc(a,b){if(a.Ga===b.Ga)return 0;var c=Na(a.ra);if(y(c?b.ra:c))return-1;if(y(a.ra)){if(Na(b.ra))return 1;c=ra(a.ra,b.ra);return 0===c?ra(a.name,b.name):c}return ra(a.name,b.name)}H;function dc(a,b,c,d,e){this.ra=a;this.name=b;this.Ga=c;this.Ua=d;this.ya=e;this.i=2154168321;this.B=4096}g=dc.prototype;g.toString=function(){return this.Ga};g.equiv=function(a){return this.w(null,a)}; g.w=function(a,b){return b instanceof dc?this.Ga===b.Ga:!1};g.call=function(){function a(a,b,c){return H.c?H.c(b,this,c):H.call(null,b,this,c)}function b(a,b){return H.b?H.b(b,this):H.call(null,b,this)}var c=null,c=function(c,e,f){switch(arguments.length){case 2:return b.call(this,0,e);case 3:return a.call(this,0,e,f)}throw Error("Invalid arity: "+arguments.length);};c.b=b;c.c=a;return c}();g.apply=function(a,b){return this.call.apply(this,[this].concat(Qa(b)))}; g.a=function(a){return H.b?H.b(a,this):H.call(null,a,this)};g.b=function(a,b){return H.c?H.c(a,this,b):H.call(null,a,this,b)};g.O=function(){return this.ya};g.R=function(a,b){return new dc(this.ra,this.name,this.Ga,this.Ua,b)};g.N=function(){var a=this.Ua;return null!=a?a:this.Ua=a=kc(bc(this.name),ic(this.ra))};g.hb=function(){return this.name};g.ib=function(){return this.ra};g.K=function(a,b){return Ab(b,this.Ga)}; var nc=function nc(b){for(var c=[],d=arguments.length,e=0;;)if(ea?0:a};g.N=function(){return xc(this)};g.w=function(a,b){return Cc.b?Cc.b(this,b):Cc.call(null,this,b)};g.Y=function(a,b){return Lc(this.f,b,this.f[this.j],this.j+1)}; g.Z=function(a,b,c){return Lc(this.f,b,c,this.j)};g.$=function(){return this.f[this.j]};g.qa=function(){return this.j+1d)c=1;else if(0===c)c=0;else a:for(d=0;;){var e=fc(Zc(a,d),Zc(b,d));if(0===e&&d+1b?a:b};wd.l=function(a,b,c){return Ra.c(wd,a>b?a:b,c)};wd.D=function(a){var b=L(a),c=M(a);a=L(c);c=M(c);return wd.l(b,a,c)};wd.A=2;var xd=function xd(b){for(var c=[],d=arguments.length,e=0;;)if(e>1&1431655765;a=(a&858993459)+(a>>2&858993459);return 16843009*(a+(a>>4)&252645135)>>24}function Bd(a){var b=2;for(a=K(a);;)if(a&&0a?0:a-1>>>5<<5}function De(a,b,c){for(;;){if(0===b)return c;var d=Be(a);d.f[0]=c;c=d;b-=5}}var Ee=function Ee(b,c,d,e){var f=new Ae(d.L,Qa(d.f)),h=b.m-1>>>c&31;5===c?f.f[h]=e:(d=d.f[h],b=null!=d?Ee(b,c-5,d,e):De(null,c-5,e),f.f[h]=b);return f}; function Fe(a,b){throw Error([E("No item "),E(a),E(" in vector of length "),E(b)].join(""));}function Ge(a,b){if(b>=Ce(a))return a.I;for(var c=a.root,d=a.shift;;)if(0>>d&31],d=e;else return c.f}function He(a,b){return 0<=b&&b>>c&31;b=Ie(b,c-5,d.f[k],e,f);h.f[k]=b}return h};function Je(a,b,c,d,e,f){this.j=a;this.rb=b;this.f=c;this.Ha=d;this.start=e;this.end=f} Je.prototype.ua=function(){return this.j=this.m)return new J(this.I,0);var a;a:{a=this.root;for(var b=this.shift;;)if(0this.m-Ce(this)){for(var c=this.I.length,d=Array(c+1),e=0;;)if(e>>5>1<b)a=new U(null,b,5,V,a,null);else for(var c=32,d=(new U(null,32,5,V,a.slice(0,32),null)).Wa(null);;)if(cb||this.end<=this.start+b?Fe(b,this.end-this.start):G.b(this.Ha,this.start+b)};g.ta=function(a,b,c){return 0>b||this.end<=this.start+b?c:G.c(this.Ha,this.start+b,c)};g.Qa=function(a,b,c){var d=this.start+b;a=this.v;c=ad.c(this.Ha,d,c);b=this.start;var e=this.end,d=d+1,d=e>d?e:d;return Re.C?Re.C(a,c,b,d,null):Re.call(null,a,c,b,d,null)};g.O=function(){return this.v};g.X=function(){return this.end-this.start};g.N=function(){var a=this.s;return null!=a?a:this.s=a=xc(this)}; g.w=function(a,b){return Cc(this,b)};g.Y=function(a,b){return Hc(this,b)};g.Z=function(a,b,c){return Ic(this,b,c)};g.Pa=function(a,b,c){if("number"===typeof b)return mb(this,b,c);throw Error("Subvec's key for assoc must be a number.");};g.S=function(){var a=this;return function(b){return function d(e){return e===a.end?null:O(G.b(a.Ha,e),new Ld(null,function(){return function(){return d(e+1)}}(b),null,null))}}(this)(a.start)}; g.R=function(a,b){return Re.C?Re.C(b,this.Ha,this.start,this.end,this.s):Re.call(null,b,this.Ha,this.start,this.end,this.s)};g.T=function(a,b){var c=this.v,d=mb(this.Ha,this.end,b),e=this.start,f=this.end+1;return Re.C?Re.C(c,d,e,f,null):Re.call(null,c,d,e,f,null)}; g.call=function(){var a=null,a=function(a,c,d){switch(arguments.length){case 2:return this.U(null,c);case 3:return this.ta(null,c,d)}throw Error("Invalid arity: "+arguments.length);};a.b=function(a,c){return this.U(null,c)};a.c=function(a,c,d){return this.ta(null,c,d)};return a}();g.apply=function(a,b){return this.call.apply(this,[this].concat(Qa(b)))};g.a=function(a){return this.U(null,a)};g.b=function(a,b){return this.ta(null,a,b)};Se.prototype[Pa]=function(){return tc(this)}; function Re(a,b,c,d,e){for(;;)if(b instanceof Se)c=b.start+c,d=b.start+d,b=b.Ha;else{var f=Xc(b);if(0>c||0>d||c>f||d>f)throw Error("Index out of bounds");return new Se(a,b,c,d,e)}}var Qe=function Qe(b){for(var c=[],d=arguments.length,e=0;;)if(e>>c&31;if(5===c)b=e;else{var h=d.f[f];b=null!=h?Ue(b,c-5,h,e):De(b.root.L,c-5,e)}d.f[f]=b;return d};function Me(a,b,c,d){this.m=a;this.shift=b;this.root=c;this.I=d;this.B=88;this.i=275}g=Me.prototype; g.kb=function(a,b){if(this.root.L){if(32>this.m-Ce(this))this.I[this.m&31]=b;else{var c=new Ae(this.root.L,this.I),d=[null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null];d[0]=b;this.I=d;if(this.m>>>5>1<>>a&31,n=f(a-5,l.f[m]);l.f[m]=n}return l}}(this).call(null,d.shift,d.root),d.root=a),this;if(b===d.m)return Fb(this,c);throw Error([E("Index "),E(b),E(" out of bounds for TransientVector of length"),E(d.m)].join(""));}throw Error("assoc! after persistent!");}; g.X=function(){if(this.root.L)return this.m;throw Error("count after persistent!");};g.U=function(a,b){if(this.root.L)return He(this,b)[b&31];throw Error("nth after persistent!");};g.ta=function(a,b,c){return 0<=b&&bb?4:2*(b+1));md(this.f,0,c,0,2*b);return new tf(a,this.aa,c)};g.ob=function(){return lf.a?lf.a(this.f):lf.call(null,this.f)};g.La=function(a,b,c,d){var e=1<<(b>>>a&31);if(0===(this.aa&e))return d;var f=Ad(this.aa&e-1),e=this.f[2*f],f=this.f[2*f+1];return null==e?f.La(a+5,b,c,d):of(c,e)?f:d}; g.Ba=function(a,b,c,d,e,f){var h=1<<(c>>>b&31),k=Ad(this.aa&h-1);if(0===(this.aa&h)){var l=Ad(this.aa);if(2*l>>b&31]=uf.Ba(a,b+5,c,d,e,f);for(e=d=0;;)if(32>d)0!== (this.aa>>>d&1)&&(k[d]=null!=this.f[e]?uf.Ba(a,b+5,jc(this.f[e]),this.f[e],this.f[e+1],f):this.f[e+1],e+=2),d+=1;else break;return new rf(a,l+1,k)}b=Array(2*(l+4));md(this.f,0,b,0,2*k);b[2*k]=d;b[2*k+1]=e;md(this.f,2*k,b,2*(k+1),2*(l-k));f.M=!0;a=this.Ra(a);a.f=b;a.aa|=h;return a}l=this.f[2*k];h=this.f[2*k+1];if(null==l)return l=h.Ba(a,b+5,c,d,e,f),l===h?this:qf(this,a,2*k+1,l);if(of(d,l))return e===h?this:qf(this,a,2*k+1,e);f.M=!0;f=b+5;d=nf.W?nf.W(a,f,l,h,c,d,e):nf.call(null,a,f,l,h,c,d,e);e=2* k;k=2*k+1;a=this.Ra(a);a.f[e]=null;a.f[k]=d;return a}; g.Aa=function(a,b,c,d,e){var f=1<<(b>>>a&31),h=Ad(this.aa&f-1);if(0===(this.aa&f)){var k=Ad(this.aa);if(16<=k){h=[null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null];h[b>>>a&31]=uf.Aa(a+5,b,c,d,e);for(d=c=0;;)if(32>c)0!==(this.aa>>>c&1)&&(h[c]=null!=this.f[d]?uf.Aa(a+5,jc(this.f[d]),this.f[d],this.f[d+1],e):this.f[d+1],d+=2),c+=1;else break;return new rf(null,k+1,h)}a=Array(2*(k+1));md(this.f, 0,a,0,2*h);a[2*h]=c;a[2*h+1]=d;md(this.f,2*h,a,2*(h+1),2*(k-h));e.M=!0;return new tf(null,this.aa|f,a)}var l=this.f[2*h],f=this.f[2*h+1];if(null==l)return k=f.Aa(a+5,b,c,d,e),k===f?this:new tf(null,this.aa,pf(this.f,2*h+1,k));if(of(c,l))return d===f?this:new tf(null,this.aa,pf(this.f,2*h+1,d));e.M=!0;e=this.aa;k=this.f;a+=5;a=nf.V?nf.V(a,l,f,b,c,d):nf.call(null,a,l,f,b,c,d);c=2*h;h=2*h+1;d=Qa(k);d[c]=null;d[h]=a;return new tf(null,e,d)};g.Da=function(){return new sf(this.f,0,null,null)}; var uf=new tf(null,0,[]);function vf(a,b,c){this.f=a;this.j=b;this.Ca=c}vf.prototype.ua=function(){for(var a=this.f.length;;){if(null!=this.Ca&&this.Ca.ua())return!0;if(this.j>>a&31];return null!=e?e.La(a+5,b,c,d):d};g.Ba=function(a,b,c,d,e,f){var h=c>>>b&31,k=this.f[h];if(null==k)return a=qf(this,a,h,uf.Ba(a,b+5,c,d,e,f)),a.m+=1,a;b=k.Ba(a,b+5,c,d,e,f);return b===k?this:qf(this,a,h,b)}; g.Aa=function(a,b,c,d,e){var f=b>>>a&31,h=this.f[f];if(null==h)return new rf(null,this.m+1,pf(this.f,f,uf.Aa(a+5,b,c,d,e)));a=h.Aa(a+5,b,c,d,e);return a===h?this:new rf(null,this.m,pf(this.f,f,a))};g.Da=function(){return new vf(this.f,0,null)};function wf(a,b,c){b*=2;for(var d=0;;)if(da?d:of(c,this.f[a])?this.f[a+1]:d}; g.Ba=function(a,b,c,d,e,f){if(c===this.Ka){b=wf(this.f,this.m,d);if(-1===b){if(this.f.length>2*this.m)return b=2*this.m,c=2*this.m+1,a=this.Ra(a),a.f[b]=d,a.f[c]=e,f.M=!0,a.m+=1,a;c=this.f.length;b=Array(c+2);md(this.f,0,b,0,c);b[c]=d;b[c+1]=e;f.M=!0;d=this.m+1;a===this.L?(this.f=b,this.m=d,a=this):a=new xf(this.L,this.Ka,d,b);return a}return this.f[b+1]===e?this:qf(this,a,b+1,e)}return(new tf(a,1<<(this.Ka>>>b&31),[null,this,null,null])).Ba(a,b,c,d,e,f)}; g.Aa=function(a,b,c,d,e){return b===this.Ka?(a=wf(this.f,this.m,c),-1===a?(a=2*this.m,b=Array(a+2),md(this.f,0,b,0,a),b[a]=c,b[a+1]=d,e.M=!0,new xf(null,this.Ka,this.m+1,b)):ec.b(this.f[a],d)?this:new xf(null,this.Ka,this.m,pf(this.f,a+1,d))):(new tf(null,1<<(this.Ka>>>a&31),[null,this])).Aa(a,b,c,d,e)};g.Da=function(){return new sf(this.f,0,null,null)}; var nf=function nf(b){for(var c=[],d=arguments.length,e=0;;)if(ethis.end};Kf.prototype.next=function(){var a=this.j;this.j+=this.step;return a};function Lf(a,b,c,d,e){this.v=a;this.start=b;this.end=c;this.step=d;this.s=e;this.i=32375006;this.B=8192}g=Lf.prototype;g.toString=function(){return Wb(this)}; g.equiv=function(a){return this.w(null,a)};g.U=function(a,b){if(bthis.end&&0===this.step)return this.start;throw Error("Index out of bounds");};g.ta=function(a,b,c){return bthis.end&&0===this.step?this.start:c};g.Da=function(){return new Kf(this.start,this.end,this.step)};g.O=function(){return this.v}; g.pa=function(){return 0this.end?new Lf(this.v,this.start+this.step,this.end,this.step,null):null};g.X=function(){return Na(xb(this))?0:Math.ceil((this.end-this.start)/this.step)};g.N=function(){var a=this.s;return null!=a?a:this.s=a=xc(this)};g.w=function(a,b){return Cc(this,b)};g.Y=function(a,b){return Hc(this,b)}; g.Z=function(a,b,c){for(a=this.start;;)if(0this.end){c=b.b?b.b(c,a):b.call(null,c,a);if(Gc(c))return N.a?N.a(c):N.call(null,c);a+=this.step}else return c};g.$=function(){return null==xb(this)?null:this.start};g.qa=function(){return null!=xb(this)?new Lf(this.v,this.start+this.step,this.end,this.step,null):rc};g.S=function(){return 0this.step?this.start>this.end?this:null:this.start===this.end?null:this}; g.R=function(a,b){return new Lf(b,this.start,this.end,this.step,this.s)};g.T=function(a,b){return O(b,this)};Lf.prototype[Pa]=function(){return tc(this)}; function Mf(a,b){return function(){function c(c,d,e){return new U(null,2,5,V,[a.c?a.c(c,d,e):a.call(null,c,d,e),b.c?b.c(c,d,e):b.call(null,c,d,e)],null)}function d(c,d){return new U(null,2,5,V,[a.b?a.b(c,d):a.call(null,c,d),b.b?b.b(c,d):b.call(null,c,d)],null)}function e(c){return new U(null,2,5,V,[a.a?a.a(c):a.call(null,c),b.a?b.a(c):b.call(null,c)],null)}function f(){return new U(null,2,5,V,[a.u?a.u():a.call(null),b.u?b.u():b.call(null)],null)}var h=null,k=function(){function c(a,b,e,f){var h=null; if(3wa)return Ab(a,"#");Ab(a,c);if(0===Ha.a(f))K(h)&&Ab(a,function(){var a=Nf.a(f);return y(a)?a:"..."}());else{if(K(h)){var l=L(h);b.c?b.c(l,a,f):b.call(null,l,a,f)}for(var m=M(h),n=Ha.a(f)-1;;)if(!m||null!=n&&0===n){K(m)&&0===n&&(Ab(a,d),Ab(a,function(){var a=Nf.a(f);return y(a)?a:"..."}()));break}else{Ab(a,d);var p=L(m);c=a;h=f;b.c?b.c(p,c,h):b.call(null,p,c,h);var q=M(m);c=n-1;m=q;n=c}}return Ab(a,e)}finally{wa=k}} function Of(a,b){for(var c=K(b),d=null,e=0,f=0;;)if(fthis.head?(fh(this.f,this.I,a,0,this.f.length-this.I),fh(this.f,0,a,this.f.length-this.I,this.head),this.I=0,this.head=this.length,this.f=a):this.I===this.head?(this.head=this.I=0,this.f=a):null};if("undefined"===typeof hh)var hh={};var ih; function jh(){var a=aa.MessageChannel;"undefined"===typeof a&&"undefined"!==typeof window&&window.postMessage&&window.addEventListener&&-1==ch.indexOf("Presto")&&(a=function(){var a=document.createElement("IFRAME");a.style.display="none";a.src="";document.documentElement.appendChild(a);var b=a.contentWindow,a=b.document;a.open();a.write("");a.close();var c="callImmediate"+Math.random(),d="file:"==b.location.protocol?"*":b.location.protocol+"//"+b.location.host,a=ma(function(a){if(("*"==d||a.origin== d)&&a.data==c)this.port1.onmessage()},this);b.addEventListener("message",a,!1);this.port1={};this.port2={postMessage:function(){b.postMessage(c,d)}}});if("undefined"!==typeof a&&-1==ch.indexOf("Trident")&&-1==ch.indexOf("MSIE")){var b=new a,c={},d=c;b.port1.onmessage=function(){if(void 0!==c.next){c=c.next;var a=c.Fb;c.Fb=null;a()}};return function(a){d.next={Fb:a};d=d.next;b.port2.postMessage(0)}}return"undefined"!==typeof document&&"onreadystatechange"in document.createElement("SCRIPT")?function(a){var b= document.createElement("SCRIPT");b.onreadystatechange=function(){b.onreadystatechange=null;b.parentNode.removeChild(b);b=null;a();a=null};document.documentElement.appendChild(b)}:function(a){aa.setTimeout(a,0)}};var kh;kh=new gh(0,0,0,Array(32));var lh=!1,mh=!1;nh;function oh(){lh=!0;mh=!1;for(var a=0;;){var b=kh.pop();if(null!=b&&(b.u?b.u():b.call(null),1024>a)){a+=1;continue}break}lh=!1;return 0=this.Na&&(this.Na+=2147483646);b&&this.install()}(function(){function a(){}a.prototype=Ah.prototype;Ch.Cc=Ah.prototype;Ch.prototype=new a;Ch.prototype.constructor=Ch;Ch.rb=function(a,c,d){for(var e=Array(arguments.length-2),f=2;f> coll (partition 2 1) (mapcat (fn [[left right]] (if (pred left right) (subdivide-with f pred [left (f left right) right] (dec max-depth)) [left])))) coll)) (defn island [rng max-depth] (as-> (rng/rand-int rng 17) x (+ 3 x) (circle rng x 100) (loopback x) (subdivide-with (partial midpoint rng) #(<= 2 (m/dist (:position %1) (:position %2))) x max-depth))) (defn generate-model [] (let [seed (let [s (string/replace js/location.hash #"#" "")] (when-not (string/blank? s) (js/parseInt s))) rng (rng/rng (or seed (rand-int 100000000)))] {:rng rng :island (island rng 15)})) (def model (atom (generate-model))) (defmulti emit (fn [t & _] t)) (defmethod emit :reset-points [_] (let [seed (rand-int 100000000) rng (rng/rng seed)] (set! (.-hash js/location) seed) (swap! model (fn [m] (assoc m :rng rng :island (island rng 15)))))) (defonce render! (let [r (renderer (.getElementById js/document "app"))] #(r (ui emit @model)))) (defonce on-update (add-watch model :rerender (fn [_ _ _ model] (render! model)))) (defonce hash-change (.addEventListener js/window "hashchange" #(reset! model (generate-model)))) (render! @model) ================================================ FILE: src/isle/macros.clj ================================================ (ns isle.macros) (defmacro spy [x] `(let [x# ~x] (println '~x " => " x#) x#)) ================================================ FILE: src/isle/math.cljs ================================================ (ns isle.math (:require-macros [isle.macros :refer [spy]])) (def sin js/Math.sin) (def cos js/Math.cos) (def acos js/Math.acos) (def pi js/Math.PI) (def tau (* 2 pi)) (def sqrt js/Math.sqrt) (def sqr #(js/Math.pow % 2)) (defn dist [[x y] [x' y']] (sqrt (+ (sqr (- x x')) (sqr (- y y'))))) (defn avg [xs] (/ (reduce + xs) (count xs))) (def magnitude (partial dist [0 0])) (defn unit-vector [[x y]] (let [len (dist [0 0] [x y])] [(/ x len) (/ y len)])) (defn dot [[ax ay] [bx by]] (+ (* ax bx) (* ay by))) (defn angle [[ax ay] [bx by] [cx cy]] (let [ba [(- bx ax) (- by ay)] bc [(- bx cx) (- by cy)]] (acos (/ (dot ba bc) (* (magnitude ba) (magnitude bc)))))) (defn slope [[ax ay] [bx by]] (/ (- by ay) (- bx ax))) (defn determinant [[ax ay] [bx by]] (- (* ax by) (* ay bx))) (defn diff [[ax ay] [bx by]] [(- ax bx) (- ay by)]) (defn scale [v s] (mapv #(* 2 %) v)) (defn clockwise? [a b c] (pos? (determinant (diff b a) (diff b c)))) (defn colinear? [a b c] (zero? (determinant (diff b a) (diff b c)))) (defn counter-clockwise? [a b c] (neg? (determinant (diff b a) (diff b c)))) ================================================ FILE: src/isle/svg.cljs ================================================ (ns isle.svg (:require-macros [isle.macros :refer [spy]])) (defn translate [x y] (str "translate(" x "," y ")")) (defn rotate [d] (str "rotate(" d ")")) (defn pair [[x y]] (str x "," y)) (defn path [pts] (as-> pts x (map pair x) (interpose "L" x) (clj->js x) (.join x "") (str "M" x))) (defn closed-path [pts] (if (seq pts) (str (path pts) "Z") ""))