diff --git a/.eslintrc.json b/.eslintrc.json index 4128cd8..cdec7e4 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -9,7 +9,14 @@ "rules": { "constructor-super": 2, "curly": 0, - "eol-last": 2, + "eol-last": [ + "error", + "always" + ], + "linebreak-style": [ + "error", + "unix" + ], "no-case-declarations": 2, "no-class-assign": 2, "no-compare-neg-zero": 2, @@ -57,6 +64,7 @@ "no-unused-labels": 2, "no-unused-vars": 2, "no-useless-escape": 2, + "no-var": 2, "require-yield": 2, "use-isnan": 2, "valid-typeof": 2, @@ -68,6 +76,13 @@ 2, "as-needed" ], + "object-shorthand": [ + "error", + "always" + ], + "prefer-arrow-callback": 2, + "prefer-const": 2, + "prefer-destructuring": 2, "yoda": 2 }, "env": { diff --git a/CHANGELOG.md b/CHANGELOG.md index d2c5f74..14aa4a0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,15 @@ # composi/core Changelog +## 2.7.5 (December 18, 2019) + +## .eslinrc.json + +* Updated Eslint rules to include modern JavaScript features like const and destructuring. + +## src/h.js, src/runtime.js, src/union.js, src/vdom.js + +* Updated to use more const and destructuring. + ## 2.7.4 (December 14, 2019) ### src/index.d.ts diff --git a/dist/composi-core.js b/dist/composi-core.js index 62639a9..d5e6e2a 100644 --- a/dist/composi-core.js +++ b/dist/composi-core.js @@ -1,2 +1,2 @@ -(function(a,b){"object"==typeof exports&&"undefined"!=typeof module?b(exports):"function"==typeof define&&define.amd?define(["exports"],b):b(a.composi={})})(this,function(a){"use strict";function b(a,b,c,d,e=null,f=null){return{type:a,props:b,children:c,node:d,flag:f,key:e}}function c(a,c){return b(a,p,q,c,null,o)}function d(a){this.handlers[a.type](a)}function e(a,b,c,e,f){if("key"===b);else if("style"===b&&"object"==typeof e)for(let d in t(c,e)){const c=null==e||null==e[d]?"":e[d];"-"===d[0]?a[b].setProperty(d,c):a[b][d]=c}else"o"===b[0]&&"n"===b[1]?(((a.handlers||(a.handlers={}))[b=b.slice(2)]=e)?null:a.removeEventListener(b,d),c?null:a.addEventListener(b,d)):"list"!==b&&"form"!==b&&"type"!==b&&"draggable"!==b&&"spellcheck"!==b&&b in a&&!f?a[b]=null==e?"":e:null==e||!1===e?a.removeAttribute(b):a.setAttribute(b,e)}function f(a,b,c){const d=a.type+"",g=a.flag===o?document.createTextNode(d):(c=c||"svg"===d)?document.createElementNS("http://www.w3.org/2000/svg",d):document.createElement(d),h=a.props;for(let d in h.onmount&&b.push(function(){h.onmount(g)}),h)e(g,d,null,h[d],c);for(let d=0,e=a.children.length;d{e(b,a,m[a],o[a],g);const c=o.onupdate;null!=c&&s(m,o)&&r.push(function(){c(b,m,o)})})();for(;w<=y&&v<=x&&null!=(k=u(p[v]))&&k===u(q[w]);)i(b,p[v].node,p[v++],q[w++],g);for(;w<=y&&v<=x&&null!=(k=u(p[x]))&&k===u(q[y]);)i(b,p[x].node,p[x--],q[y--],g);if(v>x)for(;w<=y;)b.insertBefore(f(q[w++],r,g),(j=p[v])&&j.node);else if(w>y)for(;v<=x;)h(b,p[v++]);else{let d,e,f;for(d=v,e={},f={};d<=x;d++)null!=(k=p[d].key)&&(e[k]=p[d]);for(;w<=y;){if(k=u(j=p[v]),l=u(q[w]),f[k]||null!=l&&l===u(p[v+1])){null==k&&h(b,j),v++;continue}null==l||c.flag===n?(null==k&&(i(b,j&&j.node,j,q[w],g),w++),v++):(k===l?(i(b,j.node,j,q[w],g),f[l]=!0,v++):null==(a=e[l])?i(b,j&&j.node,null,q[w],g):(i(b,b.insertBefore(a.node,j&&j.node),a,q[w],g),f[l]=!0),w++)}for(;v<=x;)null==u(j=p[v++])&&h(b,j);for(let a in e)null==f[a]&&h(b,e[a])}}return d.node=b}function j(a){return a.nodeType===o?c(a.nodeValue,a):b(a.nodeName.toLowerCase(),p,Array.prototype.map.call(a.childNodes,j),a,null,n)}function k(a,b){!a.vdom&&b.props.onmount&&r.push(function(){b.props.onmount(a)});const c=i(a.parentNode,a,a.vdom||j(a),b).vdom=b;for(;0{const d=v.call(b,a)&&b[a];return d?d(e):c?c():console.error(`The message you sent has no matching action method. Check the spelling for the message or the action method. The message type was "${a}".`)})(d):(()=>{console.error("The message you provided was not valid. Messages have the format: {type: 'whatever', data?: 'something'}"),console.error("The tag you provided was:"),console.dir(a)})()}function m(a){const b=Object.create(null);for(let c=0;c({type:d,data:a}),c++}return{variants:b,match:l}}const n=0,o=3,p={},q=[],r=[],s=(a,b)=>JSON.stringify(a)!==JSON.stringify(b),t=(c,a)=>Object.assign({},c,a),u=a=>null==a?null:a.key,v=Object.prototype.hasOwnProperty,w=(...a)=>(b,c)=>a.map(a=>a&&a(b,c));a.h=function(a,d,...e){d=d||{};let f;const g=[],h=[];let i=e.length;const j=d.key;for(;0=g.length:g.push(d.children),d.children&&delete d.children;0h;a.send=b;const l=a=>{h=a?a:c?c():void 0,j&&f&&"function"==typeof f&&f(b,k),j=!1,d(h,b)};return l(h),()=>{i&&g&&g(h),i=!1}},a.union=function(...a){const{variants:b,match:c}=m(a);return b.match=c,b},a.batchEffects=w,a.batch=w,a.Fragment=(a,b)=>Array.isArray(a)&&!b?a:b,Object.defineProperty(a,"__esModule",{value:!0})}); +(function(a,b){"object"==typeof exports&&"undefined"!=typeof module?b(exports):"function"==typeof define&&define.amd?define(["exports"],b):b(a.composi={})})(this,function(a){"use strict";function b(a,b,c,d,e=null,f=null){return{type:a,props:b,children:c,node:d,flag:f,key:e}}function c(a,c){return b(a,p,q,c,null,o)}function d(a){this.handlers[a.type](a)}function e(a,b,c,e,f){if("key"===b);else if("style"===b&&"object"==typeof e)for(const d in t(c,e)){const c=null==e||null==e[d]?"":e[d];"-"===d[0]?a[b].setProperty(d,c):a[b][d]=c}else"o"===b[0]&&"n"===b[1]?(((a.handlers||(a.handlers={}))[b=b.slice(2)]=e)?null:a.removeEventListener(b,d),c?null:a.addEventListener(b,d)):"list"!==b&&"form"!==b&&"type"!==b&&"draggable"!==b&&"spellcheck"!==b&&b in a&&!f?a[b]=null==e?"":e:null==e||!1===e?a.removeAttribute(b):a.setAttribute(b,e)}function f(a,b,c){const d=a.type+"",g=a.flag===o?document.createTextNode(d):(c=c||"svg"===d)?document.createElementNS("http://www.w3.org/2000/svg",d):document.createElement(d),{props:h}=a;for(const d in h.onmount&&b.push(()=>h.onmount(g)),h)e(g,d,null,h[d],c);for(let d=0,e=a.children.length;d{e(b,a,m[a],o[a],g);const c=o.onupdate;null!=c&&s(m,o)&&r.push(()=>c(b,m,o))})();for(;w<=y&&v<=x&&null!=(k=u(p[v]))&&k===u(q[w]);)i(b,p[v].node,p[v++],q[w++],g);for(;w<=y&&v<=x&&null!=(k=u(p[x]))&&k===u(q[y]);)i(b,p[x].node,p[x--],q[y--],g);if(v>x)for(;w<=y;)b.insertBefore(f(q[w++],r,g),(j=p[v])&&j.node);else if(w>y)for(;v<=x;)h(b,p[v++]);else{let d,e,f;for(d=v,e={},f={};d<=x;d++)null!=(k=p[d].key)&&(e[k]=p[d]);for(;w<=y;){if(k=u(j=p[v]),l=u(q[w]),f[k]||null!=l&&l===u(p[v+1])){null==k&&h(b,j),v++;continue}null==l||c.flag===n?(null==k&&(i(b,j&&j.node,j,q[w],g),w++),v++):(k===l?(i(b,j.node,j,q[w],g),f[l]=!0,v++):null==(a=e[l])?i(b,j&&j.node,null,q[w],g):(i(b,b.insertBefore(a.node,j&&j.node),a,q[w],g),f[l]=!0),w++)}for(;v<=x;)null==u(j=p[v++])&&h(b,j);for(const a in e)null==f[a]&&h(b,e[a])}}return d.node=b}function j(a){return a.nodeType===o?c(a.nodeValue,a):b(a.nodeName.toLowerCase(),p,Array.prototype.map.call(a.childNodes,j),a,null,n)}function k(a,b){!a.vdom&&b.props.onmount&&r.push(()=>b.props.onmount(a));const c=i(a.parentNode,a,a.vdom||j(a),b).vdom=b;for(;0{const d=v.call(b,a)&&b[a];return d?d(e):c?c():console.error(`The message you sent has no matching action method. Check the spelling for the message or the action method. The message type was "${a}".`)})(d):(()=>{console.error("The message you provided was not valid. Messages have the format: {type: 'whatever', data?: 'something'}"),console.error("The tag you provided was:"),console.dir(a)})()}function m(a){const b=Object.create(null);for(let c=0;c({type:d,data:a}),c++}return{variants:b,match:l}}const n=0,o=3,p={},q=[],r=[],s=(a,b)=>JSON.stringify(a)!==JSON.stringify(b),t=(c,a)=>Object.assign({},c,a),u=a=>null==a?null:a.key,{hasOwnProperty:v}=Object,w=(...a)=>(b,c)=>a.map(a=>a&&a(b,c));a.h=function(a,d,...e){d=d||{};let f;const g=[],h=[];let{length:i}=e;const{key:j}=d;for(;0=g.length:g.push(d.children),d.children&&delete d.children;0i;a.send=b;const m=a=>{i=a?a:c?c():void 0,k&&h&&"function"==typeof h&&h(b,l),k=!1,d(i,b)};return m(i),()=>{j&&g&&g(i),j=!1}},a.union=function(...a){const{variants:b,match:c}=m(a);return b.match=c,b},a.batchEffects=w,a.batch=w,a.Fragment=(a,b)=>Array.isArray(a)&&!b?a:b,Object.defineProperty(a,"__esModule",{value:!0})}); //# sourceMappingURL=composi-core.js.map diff --git a/dist/composi-core.js.gz b/dist/composi-core.js.gz index f2b0011..ca2a58c 100644 Binary files a/dist/composi-core.js.gz and b/dist/composi-core.js.gz differ diff --git a/dist/composi-core.js.map b/dist/composi-core.js.map index 978447e..4e80a05 100644 --- a/dist/composi-core.js.map +++ b/dist/composi-core.js.map @@ -1 +1 @@ -{"version":3,"file":"composi-core.js.map","sources":["../src/vnode.js","../src/vdom.js","../src/union.js","../src/constants.js","../src/effects.js","../src/h.js","../src/render.js","../src/runtime.js","../src/fragment.js"],"sourcesContent":["import {EMPTY_OBJECT, EMPTY_ARRAY, TEXT_NODE} from './constants'\nimport * as Composi from './types' // eslint-disable-line no-unused-vars\n\n/**\n * Create a virtual node with the provided properties.\n * @param {string | Function} type\n * @param {Composi.Props} props\n * @param {Composi.Children} children\n * @param {Element} node\n * @param {string | number | null} key\n * @param {number | null} [flag]\n * @return {Composi.VNode} VNode\n */\nexport function createVNode(\n type,\n props,\n children,\n node,\n key = null,\n flag = null\n) {\n return {\n type,\n props,\n children,\n node,\n flag,\n key\n }\n}\n\n/**\n * Create a virtual text node.\n * @param {string} value\n * @param {Element} [node]\n * @return {Composi.VNode} VNode\n */\nexport function createTextVNode(value, node) {\n return createVNode(value, EMPTY_OBJECT, EMPTY_ARRAY, node, null, TEXT_NODE)\n}\n","import { RECYCLED_NODE, TEXT_NODE, EMPTY_OBJECT, LIFECYCLE } from './constants'\nimport { createTextVNode, createVNode } from './vnode'\n\n/**\n * Determin whether the old and new props are identical.\n * @typedef {import('./types').Props} Props\n * @param {Props} oldVProps\n * @param {Props} newVProps\n */\nconst areNotEqual = (oldVProps, newVProps) => (JSON.stringify(oldVProps) !== JSON.stringify(newVProps))\n\n/**\n * @typedef {import('./types').VNode} VNode\n */\n/**\n * Return the combination of two objects of props.\n * @param {Object} a\n * @param {Object} b\n */\nexport const mergeObjects = (a, b) => Object.assign({}, a, b)\n\n/**\n * Handle inline events.\n * @param {Event} event\n */\nfunction listener(event) {\n this.handlers[event.type](event)\n}\n/**\n * Update the properties and attributes of a VNode based on new data.\n * @param {Element} node\n * @param {string} prop\n * @param {any} oldValue\n * @param {any} newValue\n * @param {boolean} isSVG\n * @return {void} undefined\n */\nfunction patchProperty(node, prop, oldValue, newValue, isSVG) {\n if (prop === 'key') {\n } else if (prop === 'style' && typeof newValue === 'object') {\n for (let i in mergeObjects(oldValue, newValue)) {\n const style = newValue == null || newValue[i] == null ? '' : newValue[i]\n i[0] === '-'\n ? node[prop].setProperty(i, style)\n : node[prop][i] = style\n }\n } else if (prop[0] === 'o' && prop[1] === 'n') {\n !((node['handlers'] || (node['handlers'] = {}))[(prop = prop.slice(2))] = newValue)\n ? node.removeEventListener(prop, listener)\n : null;\n (!oldValue)\n ? node.addEventListener(prop, listener)\n : null\n } else if (\n prop !== 'list' &&\n prop !== 'form' &&\n prop !== 'type' &&\n prop !== 'draggable' &&\n prop !== 'spellcheck' &&\n prop in node &&\n !isSVG\n ) {\n node[prop] = newValue == null ? '' : newValue\n } else if (newValue == null || newValue === false) {\n node.removeAttribute(prop)\n } else {\n node.setAttribute(prop, newValue)\n }\n}\n\n/**\n * Create node from vnode.\n * @param {VNode} vnode\n * @param {Function[]} LIFECYCLE\n * @param {boolean} isSVG\n */\nfunction createNode(vnode, LIFECYCLE, isSVG) {\n const type = String(vnode.type)\n const node =\n vnode.flag === TEXT_NODE\n ? document.createTextNode(type)\n : (isSVG = isSVG || type === 'svg') // eslint-disable-line no-cond-assign\n ? document.createElementNS('http://www.w3.org/2000/svg', type)\n : document.createElement(type)\n const props = vnode.props\n if (props['onmount']) {\n LIFECYCLE.push(function() {\n props['onmount'](node)\n })\n }\n\n for (let k in props) {\n patchProperty(/** @type {Element} */ (node), k, null, props[k], isSVG)\n }\n\n for (let i = 0, len = vnode.children.length; i < len; i++) {\n node.appendChild(createNode(vnode.children[i], LIFECYCLE, isSVG))\n }\n\n return (vnode.node = /** @type{Element} */ (node))\n}\n\n/**\n * Get key of vnode element.\n * @param {VNode} vnode\n * @returns {null | string | number} null | string | number\n */\nconst getKey = vnode => vnode == null ? null : vnode.key\n\n/**\n * Remove child node.\n * @param {VNode} vnode\n * @returns {Node} node\n */\nfunction removeChildren(vnode) {\n for (let i = 0, length = vnode.children.length; i < length; i++) {\n removeChildren(vnode.children[i])\n }\n\n const cb = vnode.props['ondestroy']\n cb != null && cb(vnode.node)\n\n return vnode.node\n}\n\n/**\n * Remove element from DOM.\n * @param {Node} parent\n * @param {VNode} vnode\n * @returns {void} undefined\n */\nfunction removeElement(parent, vnode) {\n const remove = function() {\n parent.removeChild(removeChildren(vnode))\n }\n\n const cb = vnode.props && vnode.props['onunmount']\n cb != null\n ? cb(vnode.node, remove)\n : remove()\n}\n\n/**\n * Patch element in DOM according to new props.\n * @param {Node} parent\n * @param {Node} node\n * @param {any} oldVNode\n * @param {any} newVNode\n * @param {boolean} [isSVG]\n */\nfunction patchNode(parent, node, oldVNode, newVNode, isSVG) {\n if (oldVNode === newVNode) {\n } else if (\n oldVNode != null\n && oldVNode.flag === TEXT_NODE\n && newVNode.flag === TEXT_NODE\n ) {\n if (oldVNode.type !== newVNode.type) {\n node.nodeValue = newVNode.type\n }\n } else if (oldVNode == null || oldVNode.type !== newVNode.type) {\n node = parent.insertBefore(createNode(newVNode, LIFECYCLE, isSVG), node)\n if (oldVNode != null) {\n removeElement(parent, oldVNode)\n }\n } else {\n let tmpVKid\n let oldVKid\n\n let oldKey\n let newKey\n\n const oldVProps = oldVNode.props\n const newVProps = newVNode.props\n\n const oldVKids = oldVNode.children\n const newVKids = newVNode.children\n\n let oldHead = 0\n let newHead = 0\n let oldTail = oldVKids.length - 1\n let newTail = newVKids.length - 1\n\n isSVG = isSVG || newVNode.type === 'svg'\n\n for (let i in mergeObjects(oldVProps, newVProps)) {\n (\n (i === 'value' || i === 'selected' || i === 'checked'\n ? node[i]\n : oldVProps[i]) !== newVProps[i]\n )\n && (() => {\n patchProperty(\n /** @type{Element} */(node),\n i,\n oldVProps[i],\n newVProps[i],\n isSVG\n )\n const cb = newVProps.onupdate\n cb != null\n && (areNotEqual(oldVProps, newVProps))\n && LIFECYCLE.push(function () {\n cb(node, oldVProps, newVProps)\n })\n })()\n }\n\n while (newHead <= newTail && oldHead <= oldTail) {\n if (\n (oldKey = getKey(oldVKids[oldHead])) == null ||\n oldKey !== getKey(newVKids[newHead])\n ) {\n break\n }\n\n patchNode(\n node,\n oldVKids[oldHead].node,\n oldVKids[oldHead++],\n newVKids[newHead++],\n isSVG\n )\n }\n\n while (newHead <= newTail && oldHead <= oldTail) {\n if (\n (oldKey = getKey(oldVKids[oldTail])) == null ||\n oldKey !== getKey(newVKids[newTail])\n ) {\n break\n }\n\n patchNode(\n node,\n oldVKids[oldTail].node,\n oldVKids[oldTail--],\n newVKids[newTail--],\n isSVG\n )\n }\n\n if (oldHead > oldTail) {\n while (newHead <= newTail) {\n node.insertBefore(\n createNode(newVKids[newHead++], LIFECYCLE, isSVG),\n (oldVKid = oldVKids[oldHead]) && oldVKid.node\n )\n }\n } else if (newHead > newTail) {\n while (oldHead <= oldTail) {\n removeElement(node, oldVKids[oldHead++])\n }\n } else {\n let i\n let keyed\n let newKeyed\n for (i = oldHead, keyed = {}, newKeyed = {}; i <= oldTail; i++) {\n if ((oldKey = oldVKids[i].key) != null) {\n keyed[oldKey] = oldVKids[i]\n }\n }\n\n while (newHead <= newTail) {\n oldKey = getKey((oldVKid = oldVKids[oldHead]))\n newKey = getKey(newVKids[newHead])\n\n if (\n newKeyed[oldKey] ||\n (newKey != null && newKey === getKey(oldVKids[oldHead + 1]))\n ) {\n if (oldKey == null) {\n removeElement(node, oldVKid)\n }\n oldHead++\n continue\n }\n\n if (newKey == null || oldVNode.flag === RECYCLED_NODE) {\n if (oldKey == null) {\n patchNode(\n node,\n oldVKid && oldVKid.node,\n oldVKid,\n newVKids[newHead],\n isSVG\n )\n newHead++\n }\n oldHead++\n } else {\n if (oldKey === newKey) {\n patchNode(node, oldVKid.node, oldVKid, newVKids[newHead], isSVG)\n newKeyed[newKey] = true\n oldHead++\n } else {\n if ((tmpVKid = keyed[newKey]) != null) {\n patchNode(\n node,\n node.insertBefore(tmpVKid.node, oldVKid && oldVKid.node),\n tmpVKid,\n newVKids[newHead],\n isSVG\n )\n newKeyed[newKey] = true\n } else {\n patchNode(\n node,\n oldVKid && oldVKid.node,\n null,\n newVKids[newHead],\n isSVG\n )\n }\n }\n newHead++\n }\n }\n\n while (oldHead <= oldTail) {\n (getKey((oldVKid = oldVKids[oldHead++])) == null)\n && removeElement(node, oldVKid)\n }\n\n for (let i in keyed) {\n (newKeyed[i] == null)\n && removeElement(node, keyed[i])\n }\n }\n }\n\n return (newVNode.node = node)\n}\n\nfunction recycleNode(node) {\n return node.nodeType === TEXT_NODE\n ? createTextVNode(node.nodeValue, node)\n : createVNode(\n node.nodeName.toLowerCase(),\n EMPTY_OBJECT,\n Array.prototype.map.call(node.childNodes, recycleNode),\n node,\n null,\n RECYCLED_NODE\n )\n}\n\n/**\n * Patch DOM with virtual node from functional component.\n * @param {Node} node\n * @param {VNode} vdom\n */\nexport function patch(node, vdom) {\n if (!node['vdom']) {\n if (vdom.props['onmount']) {\n LIFECYCLE.push(function() {\n vdom.props['onmount'](node)\n })\n }\n }\n const vnode = (patchNode(\n node.parentNode,\n node,\n node['vdom'] || recycleNode(node),\n vdom\n )['vdom'] = vdom)\n while (LIFECYCLE.length > 0) LIFECYCLE.pop()()\n return vnode\n}\n","/**\n * Helper function for testing whether message type exists on actions object.\n */\nconst hasOwnProperty = Object.prototype.hasOwnProperty\n\n\n/**\n * @param {import('./types').Tag} tag\n * @param {Object} handlers\n * @param {() => void} [catchAll]\n */\nfunction match(tag, handlers, catchAll) {\n const {type, data} = tag\n return type\n ? (type => {\n const match = hasOwnProperty.call(handlers, type) && handlers[type]\n return match\n ? match(data)\n : catchAll\n ? catchAll()\n : console.error(\n `The message you sent has no matching action method. Check the spelling for the message or the action method. The message type was \"${type}\".`\n )\n })(type)\n : (() => {\n console.error(\n \"The message you provided was not valid. Messages have the format: {type: 'whatever', data?: 'something'}\"\n )\n console.error('The tag you provided was:')\n console.dir(tag)\n })()\n}\n\n/**\n * Create a union of string tags.\n * @param {string[]} types\n * @returns {Object} Object\n */\nfunction createUnion(types) {\n const variants = Object.create(null)\n\n let idx = 0\n while (idx < types.length) {\n const type = types[idx]\n type === 'match'\n && console.error(\n `The message type you provided was \"match\". This cannot be used since it would override the message union's own match method. Please change it to something else, such as \"matchName\", etc.`\n )\n\n variants[type] = data => ({ type, data })\n idx++\n }\n\n return { variants, match }\n}\n\n/**\n * @typedef {Object} MessageUnion\n */\n\n/**\n * Create a union of types for matching up with functions. This is used to define actions for the `update` method of a runtime program.\n * @param {...string} types\n * @returns {MessageUnion} MessageUnion\n */\nexport function union(...types) {\n const { variants, match } = createUnion(types)\n variants.match = match\n return variants\n}\n","/**\n * Used to determine if a vnode should be recycled.\n * @type {number}\n */\nexport const RECYCLED_NODE = 0\n\n/**\n * Used in a vnode to indicate that it is a DOM node.\n * @type {number}\n */\nexport const ELEMENT_NODE = 1\n\n/**\n * Used in a vnode to indicate that it is a text node.\n * @type {number}\n */\nexport const TEXT_NODE = 3\n\n/**\n * Namespace for SVG elements with `xlink:href` attributes.\n * @type {string}\n */\nexport const XLINK_NS = 'http://www.w3.org/1999/xlink'\n\n/**\n * Namespace for SVG elements.\n * @type {string}\n */\nexport const SVG_NS = 'http://www.w3.org/2000/svg'\n\n/**\n * An empty object. Used as placeholder for `props` in VNode.\n * @type {{}} EMPTY_OBJECT\n */\nexport const EMPTY_OBJECT = {}\n\n/**\n * An empty array. Used for access to array methods.\n * @type {any[]} EMPTY_ARRAY\n */\nexport const EMPTY_ARRAY = []\n\n/**\n * An array to store lifecycle hooks.\n * @type {any[]} LIFECYCLE\n */\nexport const LIFECYCLE = []\n","/**\n * @typedef {import('./types').Send} Send\n * @typedef {import('./types').Message} Message\n * @typedef {Object} State\n * @typedef {() => State} GetState\n * @typedef {(send?: Send, getState?: GetState) => any} Effect\n */\n/**\n * Function to batch effects together.\n * @param {...Effect} effects\n * @return {(send?: Send, getState?: GetState) => void} Function\n */\nexport const batchEffects = (...effects) => (getState, send) =>\n effects.map(effect => effect && effect(getState, send))\n\nexport const batch = batchEffects\n","import { createVNode, createTextVNode } from './vnode'\n\n/**\n * Creates a virtual node representing an element node or text node to be created. This function must be imported into any file that contains JSX. Babel uses this function to convert JSX into JavaScript.\n * @typedef {import('./types').VNode} VNode\n * @param {string | Function} type\n * @param {Object.} [props]\n * @return {VNode}\n */\nexport function h(type, props, ...children) {\n props = props || {}\n let node\n const tempBox = []\n const childNodes = []\n let length = children.length\n const key = props.key\n\n while (length-- > 0) tempBox.push(children[length])\n\n props.children\n ? (tempBox.length <= 0)\n : tempBox.push(props.children)\n props.children && delete props.children\n\n while (tempBox.length > 0) {\n if (Array.isArray((node = tempBox.pop()))) {\n let length = node.length\n while (length-- > 0) {\n tempBox.push(node[length])\n }\n } else if (node === false || node === true || node == null) {\n } else {\n childNodes.push(typeof node === 'object' ? node : createTextVNode(node))\n }\n }\n\n return (typeof type === 'function')\n ? type(props, childNodes)\n : createVNode(type, props, childNodes, null, key)\n}\n","import { patch } from './vdom'\n\n/**\n * Render a functional component. The first argument is the component to render. This can be either a JSX tag or an `h` function. The second argument is the element to hydrate or update. During the first render, the target element is hydrated with the component provided. Further updates patch the existing element based on the virtual DOM.\n * @example\n *\n * ```\n * // Render Title tag into section:\n * render(, 'section')\n * // Update the title component 5 seconds later:\n * setTimeout(() => {\n * render(<Title message='Hello Everyone!'/>, 'section')\n * }, 5000)\n * ```\n * @typedef {import('./types').VNode} VNode\n * @param {VNode} vnode\n * @param {Element | string} target\n * @return {void} undefined\n */\nexport function render(vnode, target) {\n if (Array.isArray(vnode)) {\n throw 'Cannot insert Fragment tag directly into DOM.'\n }\n let oldTarget = ''\n if (typeof target === 'string') {\n oldTarget = target\n target = document.querySelector(target)\n }\n if (!target) {\n let msg = ''\n if (oldTarget) msg = ` The selector you provided was: \"${oldTarget}\"`\n console.error(\n `@composi/core Error: The second parameter for render function was invalid. Check the selector you provided and make sure that it exists in the DOM before trying to render. ${msg}`\n )\n }\n patch(target, vnode)\n}\n","\n/**\n * The @composi/runtime.\n * @example\n *\n * ```\n * // Create a runtime program\n * const program = {\n * // Define state:\n * init() {\n * return [{count: 0}]\n * },\n * // Define view to render.\n * // Notice event to send message 'incr'.\n * view(state, send) {\n * return render(<div onclick={send('incr')}>The count is: {state.count}</div>, document.body)\n * },\n * // Define action to update state:\n * update(state, msg) {\n * if (msg === 'incr') {\n * return [state.count++]\n * }\n * }\n * }\n * // Run the program:\n * run(program)\n * ```\n * @param {import('./types').Program} program A program to run with five methods: `init`, `view`, `update`, `subscriptions` and `done`.\n * @return {() => void} Function to terminate runtime.\n */\nexport function run(program) {\n let init = program.init\n const view = program.view\n const update = program.update\n const subscriptions = program.subscriptions || program.subs\n const done = program.done\n let state\n let isRunning = true\n let isFirstRun = true\n const getState = () => state\n\n /**\n * Send a message.\n * @param {import('./types').Message} message\n *\n */\n function send(message, data) {\n let msg = message\n /**\n * message is a function from a tagged union that\n * can be called to return a message object.\n */\n isRunning\n && (typeof message === 'function') \n && (msg = /** @type {Function} */ (message)(data))\n \n return isRunning &&\n updateView(update(state, msg, send))\n }\n\n /**\n * Expose send as static function on program object.\n * This is to let you send messages to the program\n * from other contexts, such as in a @composi/router action.\n */\n program['send'] = send\n\n /**\n * Handle changes to state and executing effects.\n * @param {any} update\n * @return {void} undefined\n */\n const updateView = update => {\n update \n ? state = update \n : init \n ? state = init() \n : state = undefined\n\n isFirstRun\n && subscriptions\n && typeof subscriptions === 'function'\n && subscriptions(send, getState)\n\n isFirstRun = false\n \n view(state, send)\n }\n updateView(state)\n\n /**\n * Function to end runtime.\n * @return {void} undefined\n */\n return () => {\n isRunning\n && done\n && done(state)\n \n isRunning = false\n }\n}\n","/**\n * Returns a group of sibling elements for inclusion in another JSX tag.\n * @typedef {import('./types').VNode} VNode\n * @typedef {import('./types').Props} Props\n * @typedef {import('./types').Children} Children\n * @param {Props} props\n * @return {Children} children\n */\n/**\n * A tag to enable returning sibling elements. This is useful for returning list items to render in a list or table cells to render in a table row.\n * @example\n *\n * ```\n * <Fragment>\n * <li>A</li>\n * <li>B</li>\n * <li>C</li>\n * </Fragment>\n ```\n * Or functionally:\n * ```\n * Fragment(null, [\n * h('li', {}, 'A'),\n * h('li', {}, 'B'),\n * h('li', {}, 'C')\n * ])\n ```\n * @param {Object} [props] When using Fragment as a function, props is the first argument. Provide either null or {} as the value for props.\n * @param {Children} [children] The siblings to return with the Fragment. This will be an array of sibling elements.\n * @return {VNode[]} An array of virtual nodes.\n */\nexport const Fragment = (props, children) =>\n Array.isArray(props) && !children ? props : children\n"],"names":["createVNode","type","props","children","node","key","flag","createTextVNode","value","EMPTY_OBJECT","EMPTY_ARRAY","TEXT_NODE","listener","event","handlers","patchProperty","prop","oldValue","newValue","isSVG","i","mergeObjects","style","setProperty","slice","removeEventListener","addEventListener","removeAttribute","setAttribute","createNode","vnode","LIFECYCLE","document","createTextNode","createElementNS","createElement","k","push","len","length","appendChild","removeChildren","cb","removeElement","parent","remove","removeChild","patchNode","oldVNode","newVNode","nodeValue","insertBefore","tmpVKid","oldVKid","oldKey","newKey","oldVProps","newVProps","oldVKids","newVKids","oldHead","newHead","oldTail","newTail","onupdate","areNotEqual","getKey","keyed","newKeyed","RECYCLED_NODE","recycleNode","nodeType","nodeName","toLowerCase","Array","prototype","map","call","childNodes","patch","vdom","parentNode","pop","match","tag","catchAll","data","hasOwnProperty","console","error","dir","createUnion","types","variants","Object","create","idx","JSON","stringify","a","b","assign","batchEffects","effects","getState","send","effect","tempBox","isArray","target","oldTarget","querySelector","msg","program","message","isRunning","updateView","update","state","init","view","subscriptions","subs","done","isFirstRun"],"mappings":"2LAaO,QAASA,CAAAA,CAAT,CACLC,CADK,CAELC,CAFK,CAGLC,CAHK,CAILC,CAJK,CAKLC,CAAG,CAAG,IALD,CAMLC,CAAI,CAAG,IANF,CAOL,OACO,CACLL,IADK,CACLA,CADK,CAELC,KAFK,CAELA,CAFK,CAGLC,QAHK,CAGLA,CAHK,CAILC,IAJK,CAILA,CAJK,CAKLE,IALK,CAKLA,CALK,CAMLD,IAAAA,CANK,EAgBF,QAASE,CAAAA,CAAT,CAAyBC,CAAzB,CAAgCJ,CAAhC,CAAsC,OACpCJ,CAAAA,CAAW,CAACQ,CAAD,CAAQC,CAAR,CAAsBC,CAAtB,CAAmCN,CAAnC,CAAyC,IAAzC,CAA+CO,CAA/C,ECbpB,QAASC,CAAAA,CAAT,CAAkBC,CAAlB,CAAyB,MAClBC,SAASD,CAAK,CAACZ,MAAMY,GAW5B,QAASE,CAAAA,CAAT,CAAuBX,CAAvB,CAA6BY,CAA7B,CAAmCC,CAAnC,CAA6CC,CAA7C,CAAuDC,CAAvD,CAA8D,IAC/C,KAATH,GAAAA,EAAgB,KACb,IAAa,OAATA,GAAAA,CAAI,EAAoC,QAApB,QAAOE,CAAAA,CAA/B,KACA,GAAIE,CAAAA,IAAKC,CAA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,CAAW,CAACC,CAAD,QACvCC,CAAAA,CAAQ,CAACV,KAATU,CAAiBV,EACVU,4BErDYS,aIgBG,CAACpG,CAAD,CAAQC,CAAR,GACtBuE,KAAK,CAACkC,OAANlC,CAAcxE,CAAdwE,GAAwB,CAACvE,CAAzBuE,CAAoCxE,CAApCwE,CAA4CvE"} \ No newline at end of file +{"version":3,"file":"composi-core.js.map","sources":["../src/vnode.js","../src/vdom.js","../src/union.js","../src/constants.js","../src/effects.js","../src/h.js","../src/render.js","../src/runtime.js","../src/fragment.js"],"sourcesContent":["import {EMPTY_OBJECT, EMPTY_ARRAY, TEXT_NODE} from './constants'\nimport * as Composi from './types' // eslint-disable-line no-unused-vars\n\n/**\n * Create a virtual node with the provided properties.\n * @param {string | Function} type\n * @param {Composi.Props} props\n * @param {Composi.Children} children\n * @param {Element} node\n * @param {string | number | null} key\n * @param {number | null} [flag]\n * @return {Composi.VNode} VNode\n */\nexport function createVNode(\n type,\n props,\n children,\n node,\n key = null,\n flag = null\n) {\n return {\n type,\n props,\n children,\n node,\n flag,\n key\n }\n}\n\n/**\n * Create a virtual text node.\n * @param {string} value\n * @param {Element} [node]\n * @return {Composi.VNode} VNode\n */\nexport function createTextVNode(value, node) {\n return createVNode(value, EMPTY_OBJECT, EMPTY_ARRAY, node, null, TEXT_NODE)\n}\n","import { RECYCLED_NODE, TEXT_NODE, EMPTY_OBJECT, LIFECYCLE } from './constants'\nimport { createTextVNode, createVNode } from './vnode'\n\n/**\n * Determin whether the old and new props are identical.\n * @typedef {import('./types').Props} Props\n * @param {Props} oldVProps\n * @param {Props} newVProps\n */\nconst areNotEqual = (oldVProps, newVProps) => (JSON.stringify(oldVProps) !== JSON.stringify(newVProps))\n\n/**\n * @typedef {import('./types').VNode} VNode\n */\n/**\n * Return the combination of two objects of props.\n * @param {Object<string, any>} a\n * @param {Object<string, any>} b\n */\nexport const mergeObjects = (a, b) => Object.assign({}, a, b)\n\n/**\n * Handle inline events.\n * @param {Event} event\n */\nfunction listener(event) {\n this.handlers[event.type](event)\n}\n/**\n * Update the properties and attributes of a VNode based on new data.\n * @param {Element} node\n * @param {string} prop\n * @param {any} oldValue\n * @param {any} newValue\n * @param {boolean} isSVG\n * @return {void} undefined\n */\nfunction patchProperty(node, prop, oldValue, newValue, isSVG) {\n if (prop === 'key') {\n } else if (prop === 'style' && typeof newValue === 'object') {\n for (const i in mergeObjects(oldValue, newValue)) {\n const style = newValue == null || newValue[i] == null ? '' : newValue[i]\n i[0] === '-'\n ? node[prop].setProperty(i, style)\n : node[prop][i] = style\n }\n } else if (prop[0] === 'o' && prop[1] === 'n') {\n !((node['handlers'] || (node['handlers'] = {}))[(prop = prop.slice(2))] = newValue)\n ? node.removeEventListener(prop, listener)\n : null;\n (!oldValue)\n ? node.addEventListener(prop, listener)\n : null\n } else if (\n prop !== 'list' &&\n prop !== 'form' &&\n prop !== 'type' &&\n prop !== 'draggable' &&\n prop !== 'spellcheck' &&\n prop in node &&\n !isSVG\n ) {\n node[prop] = newValue == null ? '' : newValue\n } else if (newValue == null || newValue === false) {\n node.removeAttribute(prop)\n } else {\n node.setAttribute(prop, newValue)\n }\n}\n\n/**\n * Create node from vnode.\n * @param {VNode} vnode\n * @param {Function[]} LIFECYCLE\n * @param {boolean} isSVG\n */\nfunction createNode(vnode, LIFECYCLE, isSVG) {\n const type = String(vnode.type)\n const node =\n vnode.flag === TEXT_NODE\n ? document.createTextNode(type)\n : (isSVG = isSVG || type === 'svg') // eslint-disable-line no-cond-assign\n ? document.createElementNS('http://www.w3.org/2000/svg', type)\n : document.createElement(type)\n const {props} = vnode\n if (props['onmount']) {\n LIFECYCLE.push(() => props['onmount'](node))\n }\n\n for (const k in props) {\n patchProperty(/** @type {Element} */ (node), k, null, props[k], isSVG)\n }\n\n for (let i = 0, len = vnode.children.length; i < len; i++) {\n node.appendChild(createNode(vnode.children[i], LIFECYCLE, isSVG))\n }\n\n return (vnode.node = /** @type{Element} */ (node))\n}\n\n/**\n * Get key of vnode element.\n * @param {VNode} vnode\n * @returns {null | string | number} null | string | number\n */\nconst getKey = vnode => vnode == null ? null : vnode.key\n\n/**\n * Remove child node.\n * @param {VNode} vnode\n * @returns {Node} node\n */\nfunction removeChildren(vnode) {\n for (let i = 0, {length} = vnode.children; i < length; i++) {\n removeChildren(vnode.children[i])\n }\n\n const cb = vnode.props['ondestroy']\n cb != null && cb(vnode.node)\n\n return vnode.node\n}\n\n/**\n * Remove element from DOM.\n * @param {Node} parent\n * @param {VNode} vnode\n * @returns {void} undefined\n */\nfunction removeElement(parent, vnode) {\n const remove = function() {\n parent.removeChild(removeChildren(vnode))\n }\n\n const cb = vnode.props && vnode.props['onunmount']\n cb != null\n ? cb(vnode.node, remove)\n : remove()\n}\n\n/**\n * Patch element in DOM according to new props.\n * @param {Node} parent\n * @param {Node} node\n * @param {any} oldVNode\n * @param {any} newVNode\n * @param {boolean} [isSVG]\n */\nfunction patchNode(parent, node, oldVNode, newVNode, isSVG) {\n if (oldVNode === newVNode) {\n } else if (\n oldVNode != null\n && oldVNode.flag === TEXT_NODE\n && newVNode.flag === TEXT_NODE\n ) {\n if (oldVNode.type !== newVNode.type) {\n node.nodeValue = newVNode.type\n }\n } else if (oldVNode == null || oldVNode.type !== newVNode.type) {\n node = parent.insertBefore(createNode(newVNode, LIFECYCLE, isSVG), node)\n if (oldVNode != null) {\n removeElement(parent, oldVNode)\n }\n } else {\n let tmpVKid\n let oldVKid\n\n let oldKey\n let newKey\n\n const oldVProps = oldVNode.props\n const newVProps = newVNode.props\n\n const oldVKids = oldVNode.children\n const newVKids = newVNode.children\n\n let oldHead = 0\n let newHead = 0\n let oldTail = oldVKids.length - 1\n let newTail = newVKids.length - 1\n\n isSVG = isSVG || newVNode.type === 'svg'\n\n for (const i in mergeObjects(oldVProps, newVProps)) {\n (\n (i === 'value' || i === 'selected' || i === 'checked'\n ? node[i]\n : oldVProps[i]) !== newVProps[i]\n )\n && (() => {\n patchProperty(\n /** @type{Element} */(node),\n i,\n oldVProps[i],\n newVProps[i],\n isSVG\n )\n const cb = newVProps.onupdate\n cb != null\n && (areNotEqual(oldVProps, newVProps))\n && LIFECYCLE.push( () => cb(node, oldVProps, newVProps))\n })()\n }\n\n while (newHead <= newTail && oldHead <= oldTail) {\n if (\n (oldKey = getKey(oldVKids[oldHead])) == null ||\n oldKey !== getKey(newVKids[newHead])\n ) {\n break\n }\n\n patchNode(\n node,\n oldVKids[oldHead].node,\n oldVKids[oldHead++],\n newVKids[newHead++],\n isSVG\n )\n }\n\n while (newHead <= newTail && oldHead <= oldTail) {\n if (\n (oldKey = getKey(oldVKids[oldTail])) == null ||\n oldKey !== getKey(newVKids[newTail])\n ) {\n break\n }\n\n patchNode(\n node,\n oldVKids[oldTail].node,\n oldVKids[oldTail--],\n newVKids[newTail--],\n isSVG\n )\n }\n\n if (oldHead > oldTail) {\n while (newHead <= newTail) {\n node.insertBefore(\n createNode(newVKids[newHead++], LIFECYCLE, isSVG),\n (oldVKid = oldVKids[oldHead]) && oldVKid.node\n )\n }\n } else if (newHead > newTail) {\n while (oldHead <= oldTail) {\n removeElement(node, oldVKids[oldHead++])\n }\n } else {\n let i\n let keyed\n let newKeyed\n for (i = oldHead, keyed = {}, newKeyed = {}; i <= oldTail; i++) {\n if ((oldKey = oldVKids[i].key) != null) {\n keyed[oldKey] = oldVKids[i]\n }\n }\n\n while (newHead <= newTail) {\n oldKey = getKey((oldVKid = oldVKids[oldHead]))\n newKey = getKey(newVKids[newHead])\n\n if (\n newKeyed[oldKey] ||\n (newKey != null && newKey === getKey(oldVKids[oldHead + 1]))\n ) {\n if (oldKey == null) {\n removeElement(node, oldVKid)\n }\n oldHead++\n continue\n }\n\n if (newKey == null || oldVNode.flag === RECYCLED_NODE) {\n if (oldKey == null) {\n patchNode(\n node,\n oldVKid && oldVKid.node,\n oldVKid,\n newVKids[newHead],\n isSVG\n )\n newHead++\n }\n oldHead++\n } else {\n if (oldKey === newKey) {\n patchNode(node, oldVKid.node, oldVKid, newVKids[newHead], isSVG)\n newKeyed[newKey] = true\n oldHead++\n } else {\n if ((tmpVKid = keyed[newKey]) != null) {\n patchNode(\n node,\n node.insertBefore(tmpVKid.node, oldVKid && oldVKid.node),\n tmpVKid,\n newVKids[newHead],\n isSVG\n )\n newKeyed[newKey] = true\n } else {\n patchNode(\n node,\n oldVKid && oldVKid.node,\n null,\n newVKids[newHead],\n isSVG\n )\n }\n }\n newHead++\n }\n }\n\n while (oldHead <= oldTail) {\n (getKey((oldVKid = oldVKids[oldHead++])) == null)\n && removeElement(node, oldVKid)\n }\n\n for (const i in keyed) {\n (newKeyed[i] == null)\n && removeElement(node, keyed[i])\n }\n }\n }\n\n return (newVNode.node = node)\n}\n\nfunction recycleNode(node) {\n return node.nodeType === TEXT_NODE\n ? createTextVNode(node.nodeValue, node)\n : createVNode(\n node.nodeName.toLowerCase(),\n EMPTY_OBJECT,\n Array.prototype.map.call(node.childNodes, recycleNode),\n node,\n null,\n RECYCLED_NODE\n )\n}\n\n/**\n * Patch DOM with virtual node from functional component.\n * @param {Node} node\n * @param {VNode} vdom\n */\nexport function patch(node, vdom) {\n if (!node['vdom']) {\n if (vdom.props['onmount']) {\n LIFECYCLE.push(() => vdom.props['onmount'](node))\n }\n }\n const vnode = (patchNode(\n node.parentNode,\n node,\n node['vdom'] || recycleNode(node),\n vdom\n )['vdom'] = vdom)\n while (LIFECYCLE.length > 0) LIFECYCLE.pop()()\n return vnode\n}\n","/**\n * Helper function for testing whether message type exists on actions object.\n */\nconst {hasOwnProperty} = Object\n\n\n/**\n * @param {import('./types').Tag} tag\n * @param {Object<string, Function>} handlers\n * @param {() => void} [catchAll]\n */\nfunction match(tag, handlers, catchAll) {\n const {type, data} = tag\n return type\n ? (type => {\n const match = hasOwnProperty.call(handlers, type) && handlers[type]\n return match\n ? match(data)\n : catchAll\n ? catchAll()\n : console.error(\n `The message you sent has no matching action method. Check the spelling for the message or the action method. The message type was \"${type}\".`\n )\n })(type)\n : (() => {\n console.error(\n \"The message you provided was not valid. Messages have the format: {type: 'whatever', data?: 'something'}\"\n )\n console.error('The tag you provided was:')\n console.dir(tag)\n })()\n}\n\n/**\n * Create a union of string tags.\n * @param {string[]} types\n * @returns {Object<string, any>} Object\n */\nfunction createUnion(types) {\n const variants = Object.create(null)\n\n let idx = 0\n while (idx < types.length) {\n const type = types[idx]\n type === 'match'\n && console.error(\n `The message type you provided was \"match\". This cannot be used since it would override the message union's own match method. Please change it to something else, such as \"matchName\", etc.`\n )\n\n variants[type] = data => ({ type, data })\n idx++\n }\n\n return { variants, match }\n}\n\n/**\n * @typedef {Object} MessageUnion\n */\n\n/**\n * Create a union of types for matching up with functions. This is used to define actions for the `update` method of a runtime program.\n * @param {...string} types\n * @returns {MessageUnion} MessageUnion\n */\nexport function union(...types) {\n const { variants, match } = createUnion(types)\n variants.match = match\n return variants\n}\n","/**\n * Used to determine if a vnode should be recycled.\n * @type {number}\n */\nexport const RECYCLED_NODE = 0\n\n/**\n * Used in a vnode to indicate that it is a DOM node.\n * @type {number}\n */\nexport const ELEMENT_NODE = 1\n\n/**\n * Used in a vnode to indicate that it is a text node.\n * @type {number}\n */\nexport const TEXT_NODE = 3\n\n/**\n * Namespace for SVG elements with `xlink:href` attributes.\n * @type {string}\n */\nexport const XLINK_NS = 'http://www.w3.org/1999/xlink'\n\n/**\n * Namespace for SVG elements.\n * @type {string}\n */\nexport const SVG_NS = 'http://www.w3.org/2000/svg'\n\n/**\n * An empty object. Used as placeholder for `props` in VNode.\n * @type {{}} EMPTY_OBJECT\n */\nexport const EMPTY_OBJECT = {}\n\n/**\n * An empty array. Used for access to array methods.\n * @type {any[]} EMPTY_ARRAY\n */\nexport const EMPTY_ARRAY = []\n\n/**\n * An array to store lifecycle hooks.\n * @type {any[]} LIFECYCLE\n */\nexport const LIFECYCLE = []\n","/**\n * @typedef {import('./types').Send} Send\n * @typedef {import('./types').Message} Message\n * @typedef {import('./types').State} State\n * @typedef {() => State} GetState\n * @typedef {(send?: Send, getState?: GetState) => any} Effect\n */\n/**\n * Function to batch effects together.\n * @param {...Effect} effects\n * @return {(send?: Send, getState?: GetState) => void} Function\n */\nexport const batchEffects = (...effects) => (getState, send) =>\n effects.map(effect => effect && effect(getState, send))\n\nexport const batch = batchEffects\n","import { createVNode, createTextVNode } from './vnode'\n\n/**\n * Creates a virtual node representing an element node or text node to be created. This function must be imported into any file that contains JSX. Babel uses this function to convert JSX into JavaScript.\n * @typedef {import('./types').VNode} VNode\n * @param {string | Function} type\n * @param {Object.<string, any>} [props]\n * @return {VNode}\n */\nexport function h(type, props, ...children) {\n props = props || {}\n let node\n const tempBox = []\n const childNodes = []\n let {length} = children\n const {key} = props\n\n while (length-- > 0) tempBox.push(children[length])\n\n props.children\n ? (tempBox.length <= 0)\n : tempBox.push(props.children)\n props.children && delete props.children\n\n while (tempBox.length > 0) {\n if (Array.isArray((node = tempBox.pop()))) {\n let {length} = node\n while (length-- > 0) {\n tempBox.push(node[length])\n }\n } else if (node === false || node === true || node == null) {\n } else {\n childNodes.push(typeof node === 'object' ? node : createTextVNode(node))\n }\n }\n\n return (typeof type === 'function')\n ? type(props, childNodes)\n : createVNode(type, props, childNodes, null, key)\n}\n","import { patch } from './vdom'\n\n/**\n * Render a functional component. The first argument is the component to render. This can be either a JSX tag or an `h` function. The second argument is the element to hydrate or update. During the first render, the target element is hydrated with the component provided. Further updates patch the existing element based on the virtual DOM.\n * @example\n *\n * ```\n * // Render Title tag into section:\n * render(<Title message='Hello World!'/>, 'section')\n * // Update the title component 5 seconds later:\n * setTimeout(() => {\n * render(<Title message='Hello Everyone!'/>, 'section')\n * }, 5000)\n * ```\n * @typedef {import('./types').VNode} VNode\n * @param {VNode} vnode\n * @param {Element | string} target\n * @return {void} undefined\n */\nexport function render(vnode, target) {\n if (Array.isArray(vnode)) {\n throw 'Cannot insert Fragment tag directly into DOM.'\n }\n let oldTarget = ''\n if (typeof target === 'string') {\n oldTarget = target\n target = document.querySelector(target)\n }\n if (!target) {\n let msg = ''\n if (oldTarget) msg = ` The selector you provided was: \"${oldTarget}\"`\n console.error(\n `@composi/core Error: The second parameter for render function was invalid. Check the selector you provided and make sure that it exists in the DOM before trying to render. ${msg}`\n )\n }\n patch(target, vnode)\n}\n","\n/**\n * The @composi/runtime.\n * @example\n *\n * ```\n * // Create a runtime program\n * const program = {\n * // Define state:\n * init() {\n * return [{count: 0}]\n * },\n * // Define view to render.\n * // Notice event to send message 'incr'.\n * view(state, send) {\n * return render(<div onclick={send('incr')}>The count is: {state.count}</div>, document.body)\n * },\n * // Define action to update state:\n * update(state, msg) {\n * if (msg === 'incr') {\n * return [state.count++]\n * }\n * }\n * }\n * // Run the program:\n * run(program)\n * ```\n * @param {import('./types').Program} program A program to run with five methods: `init`, `view`, `update`, `subscriptions` and `done`.\n * @return {() => void} Function to terminate runtime.\n */\nexport function run(program) {\n const {init, view, update, subs, done} = program\n const subscriptions = subs || program.subscriptions\n let state\n let isRunning = true\n let isFirstRun = true\n const getState = () => state\n\n /**\n * Send a message.\n * @param {import('./types').Message} message\n *\n */\n function send(message, data) {\n let msg = message\n /**\n * message is a function from a tagged union that\n * can be called to return a message object.\n */\n isRunning\n && (typeof message === 'function') \n && (msg = /** @type {Function} */ (message)(data))\n \n return isRunning &&\n updateView(update(state, msg, send))\n }\n\n /**\n * Expose send as static function on program object.\n * This is to let you send messages to the program\n * from other contexts, such as in a @composi/router action.\n */\n program['send'] = send\n\n /**\n * Handle changes to state and executing effects.\n * @param {any} update\n * @return {void} undefined\n */\n const updateView = update => {\n update \n ? state = update \n : init \n ? state = init() \n : state = undefined\n\n isFirstRun\n && subscriptions\n && typeof subscriptions === 'function'\n && subscriptions(send, getState)\n\n isFirstRun = false\n \n view(state, send)\n }\n updateView(state)\n\n /**\n * Function to end runtime.\n * @return {void} undefined\n */\n return () => {\n isRunning\n && done\n && done(state)\n \n isRunning = false\n }\n}\n","/**\n * Returns a group of sibling elements for inclusion in another JSX tag.\n * @typedef {import('./types').VNode} VNode\n * @typedef {import('./types').Props} Props\n * @typedef {import('./types').Children} Children\n * @param {Props} props\n * @return {Children} children\n */\n/**\n * A tag to enable returning sibling elements. This is useful for returning list items to render in a list or table cells to render in a table row.\n * @example\n *\n * ```\n * <Fragment>\n * <li>A</li>\n * <li>B</li>\n * <li>C</li>\n * </Fragment>\n ```\n * Or functionally:\n * ```\n * Fragment(null, [\n * h('li', {}, 'A'),\n * h('li', {}, 'B'),\n * h('li', {}, 'C')\n * ])\n ```\n * @param {Object} [props] When using Fragment as a function, props is the first argument. Provide either null or {} as the value for props.\n * @param {Children} [children] The siblings to return with the Fragment. This will be an array of sibling elements.\n * @return {VNode[]} An array of virtual nodes.\n */\nexport const Fragment = (props, children) =>\n Array.isArray(props) && !children ? props : children\n"],"names":["createVNode","type","props","children","node","key","flag","createTextVNode","value","EMPTY_OBJECT","EMPTY_ARRAY","TEXT_NODE","listener","event","handlers","patchProperty","prop","oldValue","newValue","isSVG","i","mergeObjects","style","setProperty","slice","removeEventListener","addEventListener","removeAttribute","setAttribute","createNode","vnode","LIFECYCLE","document","createTextNode","createElementNS","createElement","k","push","len","length","appendChild","removeChildren","cb","removeElement","parent","remove","removeChild","patchNode","oldVNode","newVNode","nodeValue","insertBefore","tmpVKid","oldVKid","oldKey","newKey","oldVProps","newVProps","oldVKids","newVKids","oldHead","newHead","oldTail","newTail","onupdate","areNotEqual","getKey","keyed","newKeyed","RECYCLED_NODE","recycleNode","nodeType","nodeName","toLowerCase","Array","prototype","map","call","childNodes","patch","vdom","parentNode","pop","match","tag","catchAll","data","hasOwnProperty","console","error","dir","createUnion","types","variants","Object","create","idx","JSON","stringify","a","b","assign","batchEffects","effects","getState","send","effect","tempBox","isArray","target","oldTarget","querySelector","msg","program","message","isRunning","updateView","update","state","init","view","subs","done","subscriptions","isFirstRun"],"mappings":"2LAaO,QAASA,CAAAA,CAAT,CACLC,CADK,CAELC,CAFK,CAGLC,CAHK,CAILC,CAJK,CAKLC,CAAG,CAAG,IALD,CAMLC,CAAI,CAAG,IANF,CAOL,OACO,CACLL,IADK,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AAO,KAAPA,CAAkBR,CAhCS,MAuCrBW,CAAAA,CAAU,CAAGC,CAAM,EAAI,CAEvBC,CAFuB,CAC3BD,CAAM,CACMA,CADN,CAEFE,CAAI,CACIA,CAAI,EADR,OAHmB,CAO3BK,CAAU,EACLD,CADLC,EAE8B,UAAzB,QAAOD,CAAAA,CAFZC,EAGKD,CAAa,CAAClB,CAAD,CAAOD,CAAP,CAVS,CAY3BoB,CAAU,GAZiB,CAc3BJ,CAAI,CAACF,CAAD,CAAQb,CAAR,CAdN,QAgBAW,CAAAA,CAAU,CAACE,CAAD,EAMH,IAAM,CACXH,CAAS,EACJO,CADLP,EAEKO,CAAI,CAACJ,CAAD,CAHE,CAKXH,CAAS,GALX,WL1BK,SAAe,GAAGvB,CAAlB,CAAyB,MACxB,CAAEC,QAAF,CAAEA,CAAF,CAAYV,MAAAA,CAAZ,EAAsBQ,CAAW,CAACC,CAAD,QACvCC,CAAAA,CAAQ,CAACV,KAATU,CAAiBV,EACVU,4BErDYS,aIgBG,CAACpG,CAAD,CAAQC,CAAR,GACtBuE,KAAK,CAACkC,OAANlC,CAAcxE,CAAdwE,GAAwB,CAACvE,CAAzBuE,CAAoCxE,CAApCwE,CAA4CvE"} \ No newline at end of file diff --git a/dist/composi-core.mjs b/dist/composi-core.mjs index b100256..d7f4892 100644 --- a/dist/composi-core.mjs +++ b/dist/composi-core.mjs @@ -1,2 +1,2 @@ -const a=0,b=3,c={},d=[],e=[];function f(a,b,c,d,e=null,f=null){return{type:a,props:b,children:c,node:d,flag:f,key:e}}function g(a,e){return f(a,c,d,e,null,b)}function i(a,b,...c){b=b||{};let d;const e=[],h=[];let i=c.length;const j=b.key;for(;0<i--;)e.push(c[i]);for(b.children?0>=e.length:e.push(b.children),b.children&&delete b.children;0<e.length;)if(Array.isArray(d=e.pop()))for(let a=d.length;0<a--;)e.push(d[a]);else if(!1===d||!0===d||null==d);else h.push("object"==typeof d?d:g(d));return"function"==typeof a?a(b,h):f(a,b,h,null,j)}const h=(a,b)=>JSON.stringify(a)!==JSON.stringify(b),j=(c,a)=>Object.assign({},c,a);function k(a){this.handlers[a.type](a)}function l(a,b,c,d,e){if("key"===b);else if("style"===b&&"object"==typeof d)for(let e in j(c,d)){const c=null==d||null==d[e]?"":d[e];"-"===e[0]?a[b].setProperty(e,c):a[b][e]=c}else"o"===b[0]&&"n"===b[1]?(((a.handlers||(a.handlers={}))[b=b.slice(2)]=d)?null:a.removeEventListener(b,k),c?null:a.addEventListener(b,k)):"list"!==b&&"form"!==b&&"type"!==b&&"draggable"!==b&&"spellcheck"!==b&&b in a&&!e?a[b]=null==d?"":d:null==d||!1===d?a.removeAttribute(b):a.setAttribute(b,d)}function m(a,c,d){const e=a.type+"",f=a.flag===b?document.createTextNode(e):(d=d||"svg"===e)?document.createElementNS("http://www.w3.org/2000/svg",e):document.createElement(e),g=a.props;for(let b in g.onmount&&c.push(function(){g.onmount(f)}),g)l(f,b,null,g[b],d);for(let b=0,e=a.children.length;b<e;b++)f.appendChild(m(a.children[b],c,d));return a.node=f}const n=a=>null==a?null:a.key;function o(a){for(let b=0,c=a.children.length;b<c;b++)o(a.children[b]);const b=a.props.ondestroy;return null!=b&&b(a.node),a.node}function p(a,b){const c=function(){a.removeChild(o(b))},d=b.props&&b.props.onunmount;null==d?c():d(b.node,c)}function q(c,d,f,g,k){if(f===g);else if(null!=f&&f.flag===b&&g.flag===b)f.type!==g.type&&(d.nodeValue=g.type);else if(null==f||f.type!==g.type)d=c.insertBefore(m(g,e,k),d),null!=f&&p(c,f);else{let b,c,o,r;const s=f.props,t=g.props,u=f.children,v=g.children;let w=0,x=0,y=u.length-1,z=v.length-1;for(let a in k=k||"svg"===g.type,j(s,t))("value"==a||"selected"==a||"checked"==a?d[a]:s[a])!==t[a]&&(()=>{l(d,a,s[a],t[a],k);const b=t.onupdate;null!=b&&h(s,t)&&e.push(function(){b(d,s,t)})})();for(;x<=z&&w<=y&&null!=(o=n(u[w]))&&o===n(v[x]);)q(d,u[w].node,u[w++],v[x++],k);for(;x<=z&&w<=y&&null!=(o=n(u[y]))&&o===n(v[z]);)q(d,u[y].node,u[y--],v[z--],k);if(w>y)for(;x<=z;)d.insertBefore(m(v[x++],e,k),(c=u[w])&&c.node);else if(x>z)for(;w<=y;)p(d,u[w++]);else{let e,g,h;for(e=w,g={},h={};e<=y;e++)null!=(o=u[e].key)&&(g[o]=u[e]);for(;x<=z;){if(o=n(c=u[w]),r=n(v[x]),h[o]||null!=r&&r===n(u[w+1])){null==o&&p(d,c),w++;continue}null==r||f.flag===a?(null==o&&(q(d,c&&c.node,c,v[x],k),x++),w++):(o===r?(q(d,c.node,c,v[x],k),h[r]=!0,w++):null==(b=g[r])?q(d,c&&c.node,null,v[x],k):(q(d,d.insertBefore(b.node,c&&c.node),b,v[x],k),h[r]=!0),x++)}for(;w<=y;)null==n(c=u[w++])&&p(d,c);for(let a in g)null==h[a]&&p(d,g[a])}}return g.node=d}function r(d){return d.nodeType===b?g(d.nodeValue,d):f(d.nodeName.toLowerCase(),c,Array.prototype.map.call(d.childNodes,r),d,null,a)}function s(a,b){!a.vdom&&b.props.onmount&&e.push(function(){b.props.onmount(a)});const c=q(a.parentNode,a,a.vdom||r(a),b).vdom=b;for(;0<e.length;)e.pop()();return c}function t(a,b){if(Array.isArray(a))throw"Cannot insert Fragment tag directly into DOM.";let c="";if("string"==typeof b&&(c=b,b=document.querySelector(b)),!b){let a="";c&&(a=` The selector you provided was: "${c}"`),console.error(`@composi/core Error: The second parameter for render function was invalid. Check the selector you provided and make sure that it exists in the DOM before trying to render. ${a}`)}s(b,a)}function u(a){function b(a,c){let d=a;return i&&"function"==typeof a&&(d=a(c)),i&&l(e(h,d,b))}let c=a.init;const d=a.view,e=a.update,f=a.subscriptions||a.subs,g=a.done;let h,i=!0,j=!0;const k=()=>h;a.send=b;const l=a=>{h=a?a:c?c():void 0,j&&f&&"function"==typeof f&&f(b,k),j=!1,d(h,b)};return l(h),()=>{i&&g&&g(h),i=!1}}const v=Object.prototype.hasOwnProperty;function w(a,b,c){const{type:d,data:e}=a;return d?(a=>{const d=v.call(b,a)&&b[a];return d?d(e):c?c():console.error(`The message you sent has no matching action method. Check the spelling for the message or the action method. The message type was "${a}".`)})(d):(()=>{console.error("The message you provided was not valid. Messages have the format: {type: 'whatever', data?: 'something'}"),console.error("The tag you provided was:"),console.dir(a)})()}function x(a){const b=Object.create(null);for(let c=0;c<a.length;){const d=a[c];"match"===d&&console.error(`The message type you provided was "match". This cannot be used since it would override the message union's own match method. Please change it to something else, such as "matchName", etc.`),b[d]=a=>({type:d,data:a}),c++}return{variants:b,match:w}}function y(...a){const{variants:b,match:c}=x(a);return b.match=c,b}const z=(...a)=>(b,c)=>a.map(a=>a&&a(b,c)),A=z,B=(a,b)=>Array.isArray(a)&&!b?a:b;export{i as h,t as render,u as run,y as union,z as batchEffects,A as batch,B as Fragment}; +const a=0,b=3,c={},d=[],e=[];function f(a,b,c,d,e=null,f=null){return{type:a,props:b,children:c,node:d,flag:f,key:e}}function g(a,e){return f(a,c,d,e,null,b)}function i(a,b,...c){b=b||{};let d;const e=[],h=[];let{length:i}=c;const{key:j}=b;for(;0<i--;)e.push(c[i]);for(b.children?0>=e.length:e.push(b.children),b.children&&delete b.children;0<e.length;)if(Array.isArray(d=e.pop())){let{length:a}=d;for(;0<a--;)e.push(d[a])}else if(!1===d||!0===d||null==d);else h.push("object"==typeof d?d:g(d));return"function"==typeof a?a(b,h):f(a,b,h,null,j)}const h=(a,b)=>JSON.stringify(a)!==JSON.stringify(b),j=(c,a)=>Object.assign({},c,a);function k(a){this.handlers[a.type](a)}function l(a,b,c,d,e){if("key"===b);else if("style"===b&&"object"==typeof d)for(const e in j(c,d)){const c=null==d||null==d[e]?"":d[e];"-"===e[0]?a[b].setProperty(e,c):a[b][e]=c}else"o"===b[0]&&"n"===b[1]?(((a.handlers||(a.handlers={}))[b=b.slice(2)]=d)?null:a.removeEventListener(b,k),c?null:a.addEventListener(b,k)):"list"!==b&&"form"!==b&&"type"!==b&&"draggable"!==b&&"spellcheck"!==b&&b in a&&!e?a[b]=null==d?"":d:null==d||!1===d?a.removeAttribute(b):a.setAttribute(b,d)}function m(a,c,d){const e=a.type+"",f=a.flag===b?document.createTextNode(e):(d=d||"svg"===e)?document.createElementNS("http://www.w3.org/2000/svg",e):document.createElement(e),{props:g}=a;for(const b in g.onmount&&c.push(()=>g.onmount(f)),g)l(f,b,null,g[b],d);for(let b=0,e=a.children.length;b<e;b++)f.appendChild(m(a.children[b],c,d));return a.node=f}const n=a=>null==a?null:a.key;function o(a){for(let b=0,{length:c}=a.children;b<c;b++)o(a.children[b]);const b=a.props.ondestroy;return null!=b&&b(a.node),a.node}function p(a,b){const c=function(){a.removeChild(o(b))},d=b.props&&b.props.onunmount;null==d?c():d(b.node,c)}function q(c,d,f,g,k){if(f===g);else if(null!=f&&f.flag===b&&g.flag===b)f.type!==g.type&&(d.nodeValue=g.type);else if(null==f||f.type!==g.type)d=c.insertBefore(m(g,e,k),d),null!=f&&p(c,f);else{let b,c,o,r;const s=f.props,t=g.props,u=f.children,v=g.children;let w=0,x=0,y=u.length-1,z=v.length-1;for(const a in k=k||"svg"===g.type,j(s,t))("value"==a||"selected"==a||"checked"==a?d[a]:s[a])!==t[a]&&(()=>{l(d,a,s[a],t[a],k);const b=t.onupdate;null!=b&&h(s,t)&&e.push(()=>b(d,s,t))})();for(;x<=z&&w<=y&&null!=(o=n(u[w]))&&o===n(v[x]);)q(d,u[w].node,u[w++],v[x++],k);for(;x<=z&&w<=y&&null!=(o=n(u[y]))&&o===n(v[z]);)q(d,u[y].node,u[y--],v[z--],k);if(w>y)for(;x<=z;)d.insertBefore(m(v[x++],e,k),(c=u[w])&&c.node);else if(x>z)for(;w<=y;)p(d,u[w++]);else{let e,g,h;for(e=w,g={},h={};e<=y;e++)null!=(o=u[e].key)&&(g[o]=u[e]);for(;x<=z;){if(o=n(c=u[w]),r=n(v[x]),h[o]||null!=r&&r===n(u[w+1])){null==o&&p(d,c),w++;continue}null==r||f.flag===a?(null==o&&(q(d,c&&c.node,c,v[x],k),x++),w++):(o===r?(q(d,c.node,c,v[x],k),h[r]=!0,w++):null==(b=g[r])?q(d,c&&c.node,null,v[x],k):(q(d,d.insertBefore(b.node,c&&c.node),b,v[x],k),h[r]=!0),x++)}for(;w<=y;)null==n(c=u[w++])&&p(d,c);for(const a in g)null==h[a]&&p(d,g[a])}}return g.node=d}function r(d){return d.nodeType===b?g(d.nodeValue,d):f(d.nodeName.toLowerCase(),c,Array.prototype.map.call(d.childNodes,r),d,null,a)}function s(a,b){!a.vdom&&b.props.onmount&&e.push(()=>b.props.onmount(a));const c=q(a.parentNode,a,a.vdom||r(a),b).vdom=b;for(;0<e.length;)e.pop()();return c}function t(a,b){if(Array.isArray(a))throw"Cannot insert Fragment tag directly into DOM.";let c="";if("string"==typeof b&&(c=b,b=document.querySelector(b)),!b){let a="";c&&(a=` The selector you provided was: "${c}"`),console.error(`@composi/core Error: The second parameter for render function was invalid. Check the selector you provided and make sure that it exists in the DOM before trying to render. ${a}`)}s(b,a)}function u(a){function b(a,c){let d=a;return j&&"function"==typeof a&&(d=a(c)),j&&m(e(i,d,b))}const{init:c,view:d,update:e,subs:f,done:g}=a,h=f||a.subscriptions;let i,j=!0,k=!0;const l=()=>i;a.send=b;const m=a=>{i=a?a:c?c():void 0,k&&h&&"function"==typeof h&&h(b,l),k=!1,d(i,b)};return m(i),()=>{j&&g&&g(i),j=!1}}const{hasOwnProperty:v}=Object;function w(a,b,c){const{type:d,data:e}=a;return d?(a=>{const d=v.call(b,a)&&b[a];return d?d(e):c?c():console.error(`The message you sent has no matching action method. Check the spelling for the message or the action method. The message type was "${a}".`)})(d):(()=>{console.error("The message you provided was not valid. Messages have the format: {type: 'whatever', data?: 'something'}"),console.error("The tag you provided was:"),console.dir(a)})()}function x(a){const b=Object.create(null);for(let c=0;c<a.length;){const d=a[c];"match"===d&&console.error(`The message type you provided was "match". This cannot be used since it would override the message union's own match method. Please change it to something else, such as "matchName", etc.`),b[d]=a=>({type:d,data:a}),c++}return{variants:b,match:w}}function y(...a){const{variants:b,match:c}=x(a);return b.match=c,b}const z=(...a)=>(b,c)=>a.map(a=>a&&a(b,c)),A=z,B=(a,b)=>Array.isArray(a)&&!b?a:b;export{i as h,t as render,u as run,y as union,z as batchEffects,A as batch,B as Fragment}; //# sourceMappingURL=composi-core.mjs.map diff --git a/dist/composi-core.mjs.gz b/dist/composi-core.mjs.gz index 5de9ab5..606bafe 100644 Binary files a/dist/composi-core.mjs.gz and b/dist/composi-core.mjs.gz differ diff --git a/dist/composi-core.mjs.map b/dist/composi-core.mjs.map index 45c38a7..212b3cb 100644 --- a/dist/composi-core.mjs.map +++ b/dist/composi-core.mjs.map @@ -1 +1 @@ -{"version":3,"file":"composi-core.mjs.map","sources":["../src/constants.js","../src/vnode.js","../src/h.js","../src/vdom.js","../src/render.js","../src/runtime.js","../src/union.js","../src/effects.js","../src/fragment.js"],"sourcesContent":["/**\n * Used to determine if a vnode should be recycled.\n * @type {number}\n */\nexport const RECYCLED_NODE = 0\n\n/**\n * Used in a vnode to indicate that it is a DOM node.\n * @type {number}\n */\nexport const ELEMENT_NODE = 1\n\n/**\n * Used in a vnode to indicate that it is a text node.\n * @type {number}\n */\nexport const TEXT_NODE = 3\n\n/**\n * Namespace for SVG elements with `xlink:href` attributes.\n * @type {string}\n */\nexport const XLINK_NS = 'http://www.w3.org/1999/xlink'\n\n/**\n * Namespace for SVG elements.\n * @type {string}\n */\nexport const SVG_NS = 'http://www.w3.org/2000/svg'\n\n/**\n * An empty object. Used as placeholder for `props` in VNode.\n * @type {{}} EMPTY_OBJECT\n */\nexport const EMPTY_OBJECT = {}\n\n/**\n * An empty array. Used for access to array methods.\n * @type {any[]} EMPTY_ARRAY\n */\nexport const EMPTY_ARRAY = []\n\n/**\n * An array to store lifecycle hooks.\n * @type {any[]} LIFECYCLE\n */\nexport const LIFECYCLE = []\n","import {EMPTY_OBJECT, EMPTY_ARRAY, TEXT_NODE} from './constants'\nimport * as Composi from './types' // eslint-disable-line no-unused-vars\n\n/**\n * Create a virtual node with the provided properties.\n * @param {string | Function} type\n * @param {Composi.Props} props\n * @param {Composi.Children} children\n * @param {Element} node\n * @param {string | number | null} key\n * @param {number | null} [flag]\n * @return {Composi.VNode} VNode\n */\nexport function createVNode(\n type,\n props,\n children,\n node,\n key = null,\n flag = null\n) {\n return {\n type,\n props,\n children,\n node,\n flag,\n key\n }\n}\n\n/**\n * Create a virtual text node.\n * @param {string} value\n * @param {Element} [node]\n * @return {Composi.VNode} VNode\n */\nexport function createTextVNode(value, node) {\n return createVNode(value, EMPTY_OBJECT, EMPTY_ARRAY, node, null, TEXT_NODE)\n}\n","import { createVNode, createTextVNode } from './vnode'\n\n/**\n * Creates a virtual node representing an element node or text node to be created. This function must be imported into any file that contains JSX. Babel uses this function to convert JSX into JavaScript.\n * @typedef {import('./types').VNode} VNode\n * @param {string | Function} type\n * @param {Object.<string, any>} [props]\n * @return {VNode}\n */\nexport function h(type, props, ...children) {\n props = props || {}\n let node\n const tempBox = []\n const childNodes = []\n let length = children.length\n const key = props.key\n\n while (length-- > 0) tempBox.push(children[length])\n\n props.children\n ? (tempBox.length <= 0)\n : tempBox.push(props.children)\n props.children && delete props.children\n\n while (tempBox.length > 0) {\n if (Array.isArray((node = tempBox.pop()))) {\n let length = node.length\n while (length-- > 0) {\n tempBox.push(node[length])\n }\n } else if (node === false || node === true || node == null) {\n } else {\n childNodes.push(typeof node === 'object' ? node : createTextVNode(node))\n }\n }\n\n return (typeof type === 'function')\n ? type(props, childNodes)\n : createVNode(type, props, childNodes, null, key)\n}\n","import { RECYCLED_NODE, TEXT_NODE, EMPTY_OBJECT, LIFECYCLE } from './constants'\nimport { createTextVNode, createVNode } from './vnode'\n\n/**\n * Determin whether the old and new props are identical.\n * @typedef {import('./types').Props} Props\n * @param {Props} oldVProps\n * @param {Props} newVProps\n */\nconst areNotEqual = (oldVProps, newVProps) => (JSON.stringify(oldVProps) !== JSON.stringify(newVProps))\n\n/**\n * @typedef {import('./types').VNode} VNode\n */\n/**\n * Return the combination of two objects of props.\n * @param {Object<string, any>} a\n * @param {Object<string, any>} b\n */\nexport const mergeObjects = (a, b) => Object.assign({}, a, b)\n\n/**\n * Handle inline events.\n * @param {Event} event\n */\nfunction listener(event) {\n this.handlers[event.type](event)\n}\n/**\n * Update the properties and attributes of a VNode based on new data.\n * @param {Element} node\n * @param {string} prop\n * @param {any} oldValue\n * @param {any} newValue\n * @param {boolean} isSVG\n * @return {void} undefined\n */\nfunction patchProperty(node, prop, oldValue, newValue, isSVG) {\n if (prop === 'key') {\n } else if (prop === 'style' && typeof newValue === 'object') {\n for (let i in mergeObjects(oldValue, newValue)) {\n const style = newValue == null || newValue[i] == null ? '' : newValue[i]\n i[0] === '-'\n ? node[prop].setProperty(i, style)\n : node[prop][i] = style\n }\n } else if (prop[0] === 'o' && prop[1] === 'n') {\n !((node['handlers'] || (node['handlers'] = {}))[(prop = prop.slice(2))] = newValue)\n ? node.removeEventListener(prop, listener)\n : null;\n (!oldValue)\n ? node.addEventListener(prop, listener)\n : null\n } else if (\n prop !== 'list' &&\n prop !== 'form' &&\n prop !== 'type' &&\n prop !== 'draggable' &&\n prop !== 'spellcheck' &&\n prop in node &&\n !isSVG\n ) {\n node[prop] = newValue == null ? '' : newValue\n } else if (newValue == null || newValue === false) {\n node.removeAttribute(prop)\n } else {\n node.setAttribute(prop, newValue)\n }\n}\n\n/**\n * Create node from vnode.\n * @param {VNode} vnode\n * @param {Function[]} LIFECYCLE\n * @param {boolean} isSVG\n */\nfunction createNode(vnode, LIFECYCLE, isSVG) {\n const type = String(vnode.type)\n const node =\n vnode.flag === TEXT_NODE\n ? document.createTextNode(type)\n : (isSVG = isSVG || type === 'svg') // eslint-disable-line no-cond-assign\n ? document.createElementNS('http://www.w3.org/2000/svg', type)\n : document.createElement(type)\n const props = vnode.props\n if (props['onmount']) {\n LIFECYCLE.push(function() {\n props['onmount'](node)\n })\n }\n\n for (let k in props) {\n patchProperty(/** @type {Element} */ (node), k, null, props[k], isSVG)\n }\n\n for (let i = 0, len = vnode.children.length; i < len; i++) {\n node.appendChild(createNode(vnode.children[i], LIFECYCLE, isSVG))\n }\n\n return (vnode.node = /** @type{Element} */ (node))\n}\n\n/**\n * Get key of vnode element.\n * @param {VNode} vnode\n * @returns {null | string | number} null | string | number\n */\nconst getKey = vnode => vnode == null ? null : vnode.key\n\n/**\n * Remove child node.\n * @param {VNode} vnode\n * @returns {Node} node\n */\nfunction removeChildren(vnode) {\n for (let i = 0, length = vnode.children.length; i < length; i++) {\n removeChildren(vnode.children[i])\n }\n\n const cb = vnode.props['ondestroy']\n cb != null && cb(vnode.node)\n\n return vnode.node\n}\n\n/**\n * Remove element from DOM.\n * @param {Node} parent\n * @param {VNode} vnode\n * @returns {void} undefined\n */\nfunction removeElement(parent, vnode) {\n const remove = function() {\n parent.removeChild(removeChildren(vnode))\n }\n\n const cb = vnode.props && vnode.props['onunmount']\n cb != null\n ? cb(vnode.node, remove)\n : remove()\n}\n\n/**\n * Patch element in DOM according to new props.\n * @param {Node} parent\n * @param {Node} node\n * @param {any} oldVNode\n * @param {any} newVNode\n * @param {boolean} [isSVG]\n */\nfunction patchNode(parent, node, oldVNode, newVNode, isSVG) {\n if (oldVNode === newVNode) {\n } else if (\n oldVNode != null\n && oldVNode.flag === TEXT_NODE\n && newVNode.flag === TEXT_NODE\n ) {\n if (oldVNode.type !== newVNode.type) {\n node.nodeValue = newVNode.type\n }\n } else if (oldVNode == null || oldVNode.type !== newVNode.type) {\n node = parent.insertBefore(createNode(newVNode, LIFECYCLE, isSVG), node)\n if (oldVNode != null) {\n removeElement(parent, oldVNode)\n }\n } else {\n let tmpVKid\n let oldVKid\n\n let oldKey\n let newKey\n\n const oldVProps = oldVNode.props\n const newVProps = newVNode.props\n\n const oldVKids = oldVNode.children\n const newVKids = newVNode.children\n\n let oldHead = 0\n let newHead = 0\n let oldTail = oldVKids.length - 1\n let newTail = newVKids.length - 1\n\n isSVG = isSVG || newVNode.type === 'svg'\n\n for (let i in mergeObjects(oldVProps, newVProps)) {\n (\n (i === 'value' || i === 'selected' || i === 'checked'\n ? node[i]\n : oldVProps[i]) !== newVProps[i]\n )\n && (() => {\n patchProperty(\n /** @type{Element} */(node),\n i,\n oldVProps[i],\n newVProps[i],\n isSVG\n )\n const cb = newVProps.onupdate\n cb != null\n && (areNotEqual(oldVProps, newVProps))\n && LIFECYCLE.push(function () {\n cb(node, oldVProps, newVProps)\n })\n })()\n }\n\n while (newHead <= newTail && oldHead <= oldTail) {\n if (\n (oldKey = getKey(oldVKids[oldHead])) == null ||\n oldKey !== getKey(newVKids[newHead])\n ) {\n break\n }\n\n patchNode(\n node,\n oldVKids[oldHead].node,\n oldVKids[oldHead++],\n newVKids[newHead++],\n isSVG\n )\n }\n\n while (newHead <= newTail && oldHead <= oldTail) {\n if (\n (oldKey = getKey(oldVKids[oldTail])) == null ||\n oldKey !== getKey(newVKids[newTail])\n ) {\n break\n }\n\n patchNode(\n node,\n oldVKids[oldTail].node,\n oldVKids[oldTail--],\n newVKids[newTail--],\n isSVG\n )\n }\n\n if (oldHead > oldTail) {\n while (newHead <= newTail) {\n node.insertBefore(\n createNode(newVKids[newHead++], LIFECYCLE, isSVG),\n (oldVKid = oldVKids[oldHead]) && oldVKid.node\n )\n }\n } else if (newHead > newTail) {\n while (oldHead <= oldTail) {\n removeElement(node, oldVKids[oldHead++])\n }\n } else {\n let i\n let keyed\n let newKeyed\n for (i = oldHead, keyed = {}, newKeyed = {}; i <= oldTail; i++) {\n if ((oldKey = oldVKids[i].key) != null) {\n keyed[oldKey] = oldVKids[i]\n }\n }\n\n while (newHead <= newTail) {\n oldKey = getKey((oldVKid = oldVKids[oldHead]))\n newKey = getKey(newVKids[newHead])\n\n if (\n newKeyed[oldKey] ||\n (newKey != null && newKey === getKey(oldVKids[oldHead + 1]))\n ) {\n if (oldKey == null) {\n removeElement(node, oldVKid)\n }\n oldHead++\n continue\n }\n\n if (newKey == null || oldVNode.flag === RECYCLED_NODE) {\n if (oldKey == null) {\n patchNode(\n node,\n oldVKid && oldVKid.node,\n oldVKid,\n newVKids[newHead],\n isSVG\n )\n newHead++\n }\n oldHead++\n } else {\n if (oldKey === newKey) {\n patchNode(node, oldVKid.node, oldVKid, newVKids[newHead], isSVG)\n newKeyed[newKey] = true\n oldHead++\n } else {\n if ((tmpVKid = keyed[newKey]) != null) {\n patchNode(\n node,\n node.insertBefore(tmpVKid.node, oldVKid && oldVKid.node),\n tmpVKid,\n newVKids[newHead],\n isSVG\n )\n newKeyed[newKey] = true\n } else {\n patchNode(\n node,\n oldVKid && oldVKid.node,\n null,\n newVKids[newHead],\n isSVG\n )\n }\n }\n newHead++\n }\n }\n\n while (oldHead <= oldTail) {\n (getKey((oldVKid = oldVKids[oldHead++])) == null)\n && removeElement(node, oldVKid)\n }\n\n for (let i in keyed) {\n (newKeyed[i] == null)\n && removeElement(node, keyed[i])\n }\n }\n }\n\n return (newVNode.node = node)\n}\n\nfunction recycleNode(node) {\n return node.nodeType === TEXT_NODE\n ? createTextVNode(node.nodeValue, node)\n : createVNode(\n node.nodeName.toLowerCase(),\n EMPTY_OBJECT,\n Array.prototype.map.call(node.childNodes, recycleNode),\n node,\n null,\n RECYCLED_NODE\n )\n}\n\n/**\n * Patch DOM with virtual node from functional component.\n * @param {Node} node\n * @param {VNode} vdom\n */\nexport function patch(node, vdom) {\n if (!node['vdom']) {\n if (vdom.props['onmount']) {\n LIFECYCLE.push(function() {\n vdom.props['onmount'](node)\n })\n }\n }\n const vnode = (patchNode(\n node.parentNode,\n node,\n node['vdom'] || recycleNode(node),\n vdom\n )['vdom'] = vdom)\n while (LIFECYCLE.length > 0) LIFECYCLE.pop()()\n return vnode\n}\n","import { patch } from './vdom'\n\n/**\n * Render a functional component. The first argument is the component to render. This can be either a JSX tag or an `h` function. The second argument is the element to hydrate or update. During the first render, the target element is hydrated with the component provided. Further updates patch the existing element based on the virtual DOM.\n * @example\n *\n * ```\n * // Render Title tag into section:\n * render(<Title message='Hello World!'/>, 'section')\n * // Update the title component 5 seconds later:\n * setTimeout(() => {\n * render(<Title message='Hello Everyone!'/>, 'section')\n * }, 5000)\n * ```\n * @typedef {import('./types').VNode} VNode\n * @param {VNode} vnode\n * @param {Element | string} target\n * @return {void} undefined\n */\nexport function render(vnode, target) {\n if (Array.isArray(vnode)) {\n throw 'Cannot insert Fragment tag directly into DOM.'\n }\n let oldTarget = ''\n if (typeof target === 'string') {\n oldTarget = target\n target = document.querySelector(target)\n }\n if (!target) {\n let msg = ''\n if (oldTarget) msg = ` The selector you provided was: \"${oldTarget}\"`\n console.error(\n `@composi/core Error: The second parameter for render function was invalid. Check the selector you provided and make sure that it exists in the DOM before trying to render. ${msg}`\n )\n }\n patch(target, vnode)\n}\n","\n/**\n * The @composi/runtime.\n * @example\n *\n * ```\n * // Create a runtime program\n * const program = {\n * // Define state:\n * init() {\n * return [{count: 0}]\n * },\n * // Define view to render.\n * // Notice event to send message 'incr'.\n * view(state, send) {\n * return render(<div onclick={send('incr')}>The count is: {state.count}</div>, document.body)\n * },\n * // Define action to update state:\n * update(state, msg) {\n * if (msg === 'incr') {\n * return [state.count++]\n * }\n * }\n * }\n * // Run the program:\n * run(program)\n * ```\n * @param {import('./types').Program} program A program to run with five methods: `init`, `view`, `update`, `subscriptions` and `done`.\n * @return {() => void} Function to terminate runtime.\n */\nexport function run(program) {\n let init = program.init\n const view = program.view\n const update = program.update\n const subscriptions = program.subscriptions || program.subs\n const done = program.done\n let state\n let isRunning = true\n let isFirstRun = true\n const getState = () => state\n\n /**\n * Send a message.\n * @param {import('./types').Message} message\n *\n */\n function send(message, data) {\n let msg = message\n /**\n * message is a function from a tagged union that\n * can be called to return a message object.\n */\n isRunning\n && (typeof message === 'function') \n && (msg = /** @type {Function} */ (message)(data))\n \n return isRunning &&\n updateView(update(state, msg, send))\n }\n\n /**\n * Expose send as static function on program object.\n * This is to let you send messages to the program\n * from other contexts, such as in a @composi/router action.\n */\n program['send'] = send\n\n /**\n * Handle changes to state and executing effects.\n * @param {any} update\n * @return {void} undefined\n */\n const updateView = update => {\n update \n ? state = update \n : init \n ? state = init() \n : state = undefined\n\n isFirstRun\n && subscriptions\n && typeof subscriptions === 'function'\n && subscriptions(send, getState)\n\n isFirstRun = false\n \n view(state, send)\n }\n updateView(state)\n\n /**\n * Function to end runtime.\n * @return {void} undefined\n */\n return () => {\n isRunning\n && done\n && done(state)\n \n isRunning = false\n }\n}\n","/**\n * Helper function for testing whether message type exists on actions object.\n */\nconst hasOwnProperty = Object.prototype.hasOwnProperty\n\n\n/**\n * @param {import('./types').Tag} tag\n * @param {Object<string, Function>} handlers\n * @param {() => void} [catchAll]\n */\nfunction match(tag, handlers, catchAll) {\n const {type, data} = tag\n return type\n ? (type => {\n const match = hasOwnProperty.call(handlers, type) && handlers[type]\n return match\n ? match(data)\n : catchAll\n ? catchAll()\n : console.error(\n `The message you sent has no matching action method. Check the spelling for the message or the action method. The message type was \"${type}\".`\n )\n })(type)\n : (() => {\n console.error(\n \"The message you provided was not valid. Messages have the format: {type: 'whatever', data?: 'something'}\"\n )\n console.error('The tag you provided was:')\n console.dir(tag)\n })()\n}\n\n/**\n * Create a union of string tags.\n * @param {string[]} types\n * @returns {Object<string, any>} Object\n */\nfunction createUnion(types) {\n const variants = Object.create(null)\n\n let idx = 0\n while (idx < types.length) {\n const type = types[idx]\n type === 'match'\n && console.error(\n `The message type you provided was \"match\". This cannot be used since it would override the message union's own match method. Please change it to something else, such as \"matchName\", etc.`\n )\n\n variants[type] = data => ({ type, data })\n idx++\n }\n\n return { variants, match }\n}\n\n/**\n * @typedef {Object} MessageUnion\n */\n\n/**\n * Create a union of types for matching up with functions. This is used to define actions for the `update` method of a runtime program.\n * @param {...string} types\n * @returns {MessageUnion} MessageUnion\n */\nexport function union(...types) {\n const { variants, match } = createUnion(types)\n variants.match = match\n return variants\n}\n","/**\n * @typedef {import('./types').Send} Send\n * @typedef {import('./types').Message} Message\n * @typedef {Object} State\n * @typedef {() => State} GetState\n * @typedef {(send?: Send, getState?: GetState) => any} Effect\n */\n/**\n * Function to batch effects together.\n * @param {...Effect} effects\n * @return {(send?: Send, getState?: GetState) => void} Function\n */\nexport const batchEffects = (...effects) => (getState, send) =>\n effects.map(effect => effect && effect(getState, send))\n\nexport const batch = batchEffects\n","/**\n * Returns a group of sibling elements for inclusion in another JSX tag.\n * @typedef {import('./types').VNode} VNode\n * @typedef {import('./types').Props} Props\n * @typedef {import('./types').Children} Children\n * @param {Props} props\n * @return {Children} children\n */\n/**\n * A tag to enable returning sibling elements. This is useful for returning list items to render in a list or table cells to render in a table row.\n * @example\n *\n * ```\n * <Fragment>\n * <li>A</li>\n * <li>B</li>\n * <li>C</li>\n * </Fragment>\n ```\n * Or functionally:\n * ```\n * Fragment(null, [\n * h('li', {}, 'A'),\n * h('li', {}, 'B'),\n * h('li', {}, 'C')\n * ])\n ```\n * @param {Object} [props] When using Fragment as a function, props is the first argument. Provide either null or {} as the value for props.\n * @param {Children} [children] The siblings to return with the Fragment. This will be an array of sibling elements.\n * @return {VNode[]} An array of virtual nodes.\n */\nexport const Fragment = (props, children) =>\n Array.isArray(props) && !children ? props : children\n"],"names":["RECYCLED_NODE","TEXT_NODE","EMPTY_OBJECT","EMPTY_ARRAY","LIFECYCLE","createVNode","type","props","children","node","key","flag","createTextVNode","value","h","tempBox","childNodes","length","push","Array","isArray","pop","areNotEqual","oldVProps","newVProps","JSON","stringify","mergeObjects","a","b","Object","assign","listener","event","handlers","patchProperty","prop","oldValue","newValue","isSVG","i","style","setProperty","slice","removeEventListener","addEventListener","removeAttribute","setAttribute","createNode","vnode","document","createTextNode","createElementNS","createElement","k","len","appendChild","getKey","removeChildren","cb","removeElement","parent","remove","removeChild","patchNode","oldVNode","newVNode","nodeValue","insertBefore","tmpVKid","oldVKid","oldKey","newKey","oldVKids","newVKids","oldHead","newHead","oldTail","newTail","onupdate","keyed","newKeyed","recycleNode","nodeType","nodeName","toLowerCase","prototype","map","call","patch","vdom","parentNode","render","target","oldTarget","querySelector","msg","console","error","run","program","send","message","data","isRunning","updateView","update","state","init","view","subscriptions","subs","done","isFirstRun","getState","hasOwnProperty","match","tag","catchAll","dir","createUnion","types","variants","create","idx","union","batchEffects","effects","effect","batch","Fragment"],"mappings":"KAIaA,CAAAA,CAAa,CAAG,EAYhBC,CAAS,CAAG,EAkBZC,CAAY,CAAG,GAMfC,CAAW,CAAG,GAMdC,CAAS,CAAG,GCjClB,QAASC,CAAAA,CAAT,CACLC,CADK,CAELC,CAFK,CAGLC,CAHK,CAILC,CAJK,CAKLC,CAAG,CAAG,IALD,CAMLC,CAAI,CAAG,IANF,CAOL,OACO,CACLL,IADK,CACLA,CADK,CAELC,KAFK,CAELA,CAFK,CAGLC,QAHK,CAGLA,CAHK,CAILC,IAJK,CAILA,CAJK,CAKLE,IALK,CAKLA,CALK,CAMLD,IAAAA,CANK,EAgBF,QAASE,CAAAA,CAAT,CAAyBC,CAAzB,CAAgCJ,CAAhC,CAAsC,OACpCJ,CAAAA,CAAW,CAACQ,CAAD,CAAQX,CAAR,CAAsBC,CAAtB,CAAmCM,CAAnC,CAAyC,IAAzC,CAA+CR,CAA/C,EC7BpB,QAAgBa,CAAAA,CAAhB,CAAkBR,CAAlB,CAAwBC,CAAxB,CAA+B,GAAGC,CAAlC,CAA4C,CAC1CD,CAAK,CAAGA,CAAK,EAAI,EADyB,IAEtCE,CAAAA,EAFsC,KAGpCM,CAAAA,CAAO,CAAG,EAH0B,CAIpCC,CAAU,CAAG,EAJuB,IAKtCC,CAAAA,CAAM,CAAGT,CAAQ,CAACS,YAChBP,CAAAA,CAAG,CAAGH,CAAK,CAACG,IANwB,KAQxB,CAAXO,CAAAA,CAAM,EAR6B,EAQrBF,CAAO,CAACG,IAARH,CAAaP,CAAQ,CAACS,CAAD,CAArBF,EARqB,IAU1CR,CAAK,CAACC,QAAND,CACuB,CAAlBQ,EAAAA,CAAO,CAACE,MADbV,CAEIQ,CAAO,CAACG,IAARH,CAAaR,CAAK,C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zBW,CAAoCZ,CAApCY,CAA4CX"} \ No newline at end of file +{"version":3,"file":"composi-core.mjs.map","sources":["../src/constants.js","../src/vnode.js","../src/h.js","../src/vdom.js","../src/render.js","../src/runtime.js","../src/union.js","../src/effects.js","../src/fragment.js"],"sourcesContent":["/**\n * Used to determine if a vnode should be recycled.\n * @type {number}\n */\nexport const RECYCLED_NODE = 0\n\n/**\n * Used in a vnode to indicate that it is a DOM node.\n * @type {number}\n */\nexport const ELEMENT_NODE = 1\n\n/**\n * Used in a vnode to indicate that it is a text node.\n * @type {number}\n */\nexport const TEXT_NODE = 3\n\n/**\n * Namespace for SVG elements with `xlink:href` attributes.\n * @type {string}\n */\nexport const XLINK_NS = 'http://www.w3.org/1999/xlink'\n\n/**\n * Namespace for SVG elements.\n * @type {string}\n */\nexport const SVG_NS = 'http://www.w3.org/2000/svg'\n\n/**\n * An empty object. Used as placeholder for `props` in VNode.\n * @type {{}} EMPTY_OBJECT\n */\nexport const EMPTY_OBJECT = {}\n\n/**\n * An empty array. Used for access to array methods.\n * @type {any[]} EMPTY_ARRAY\n */\nexport const EMPTY_ARRAY = []\n\n/**\n * An array to store lifecycle hooks.\n * @type {any[]} LIFECYCLE\n */\nexport const LIFECYCLE = []\n","import {EMPTY_OBJECT, EMPTY_ARRAY, TEXT_NODE} from './constants'\nimport * as Composi from './types' // eslint-disable-line no-unused-vars\n\n/**\n * Create a virtual node with the provided properties.\n * @param {string | Function} type\n * @param {Composi.Props} props\n * @param {Composi.Children} children\n * @param {Element} node\n * @param {string | number | null} key\n * @param {number | null} [flag]\n * @return {Composi.VNode} VNode\n */\nexport function createVNode(\n type,\n props,\n children,\n node,\n key = null,\n flag = null\n) {\n return {\n type,\n props,\n children,\n node,\n flag,\n key\n }\n}\n\n/**\n * Create a virtual text node.\n * @param {string} value\n * @param {Element} [node]\n * @return {Composi.VNode} VNode\n */\nexport function createTextVNode(value, node) {\n return createVNode(value, EMPTY_OBJECT, EMPTY_ARRAY, node, null, TEXT_NODE)\n}\n","import { createVNode, createTextVNode } from './vnode'\n\n/**\n * Creates a virtual node representing an element node or text node to be created. This function must be imported into any file that contains JSX. Babel uses this function to convert JSX into JavaScript.\n * @typedef {import('./types').VNode} VNode\n * @param {string | Function} type\n * @param {Object.<string, any>} [props]\n * @return {VNode}\n */\nexport function h(type, props, ...children) {\n props = props || {}\n let node\n const tempBox = []\n const childNodes = []\n let {length} = children\n const {key} = props\n\n while (length-- > 0) tempBox.push(children[length])\n\n props.children\n ? (tempBox.length <= 0)\n : tempBox.push(props.children)\n props.children && delete props.children\n\n while (tempBox.length > 0) {\n if (Array.isArray((node = tempBox.pop()))) {\n let {length} = node\n while (length-- > 0) {\n tempBox.push(node[length])\n }\n } else if (node === false || node === true || node == null) {\n } else {\n childNodes.push(typeof node === 'object' ? node : createTextVNode(node))\n }\n }\n\n return (typeof type === 'function')\n ? type(props, childNodes)\n : createVNode(type, props, childNodes, null, key)\n}\n","import { RECYCLED_NODE, TEXT_NODE, EMPTY_OBJECT, LIFECYCLE } from './constants'\nimport { createTextVNode, createVNode } from './vnode'\n\n/**\n * Determin whether the old and new props are identical.\n * @typedef {import('./types').Props} Props\n * @param {Props} oldVProps\n * @param {Props} newVProps\n */\nconst areNotEqual = (oldVProps, newVProps) => (JSON.stringify(oldVProps) !== JSON.stringify(newVProps))\n\n/**\n * @typedef {import('./types').VNode} VNode\n */\n/**\n * Return the combination of two objects of props.\n * @param {Object<string, any>} a\n * @param {Object<string, any>} b\n */\nexport const mergeObjects = (a, b) => Object.assign({}, a, b)\n\n/**\n * Handle inline events.\n * @param {Event} event\n */\nfunction listener(event) {\n this.handlers[event.type](event)\n}\n/**\n * Update the properties and attributes of a VNode based on new data.\n * @param {Element} node\n * @param {string} prop\n * @param {any} oldValue\n * @param {any} newValue\n * @param {boolean} isSVG\n * @return {void} undefined\n */\nfunction patchProperty(node, prop, oldValue, newValue, isSVG) {\n if (prop === 'key') {\n } else if (prop === 'style' && typeof newValue === 'object') {\n for (const i in mergeObjects(oldValue, newValue)) {\n const style = newValue == null || newValue[i] == null ? '' : newValue[i]\n i[0] === '-'\n ? node[prop].setProperty(i, style)\n : node[prop][i] = style\n }\n } else if (prop[0] === 'o' && prop[1] === 'n') {\n !((node['handlers'] || (node['handlers'] = {}))[(prop = prop.slice(2))] = newValue)\n ? node.removeEventListener(prop, listener)\n : null;\n (!oldValue)\n ? node.addEventListener(prop, listener)\n : null\n } else if (\n prop !== 'list' &&\n prop !== 'form' &&\n prop !== 'type' &&\n prop !== 'draggable' &&\n prop !== 'spellcheck' &&\n prop in node &&\n !isSVG\n ) {\n node[prop] = newValue == null ? '' : newValue\n } else if (newValue == null || newValue === false) {\n node.removeAttribute(prop)\n } else {\n node.setAttribute(prop, newValue)\n }\n}\n\n/**\n * Create node from vnode.\n * @param {VNode} vnode\n * @param {Function[]} LIFECYCLE\n * @param {boolean} isSVG\n */\nfunction createNode(vnode, LIFECYCLE, isSVG) {\n const type = String(vnode.type)\n const node =\n vnode.flag === TEXT_NODE\n ? document.createTextNode(type)\n : (isSVG = isSVG || type === 'svg') // eslint-disable-line no-cond-assign\n ? document.createElementNS('http://www.w3.org/2000/svg', type)\n : document.createElement(type)\n const {props} = vnode\n if (props['onmount']) {\n LIFECYCLE.push(() => props['onmount'](node))\n }\n\n for (const k in props) {\n patchProperty(/** @type {Element} */ (node), k, null, props[k], isSVG)\n }\n\n for (let i = 0, len = vnode.children.length; i < len; i++) {\n node.appendChild(createNode(vnode.children[i], LIFECYCLE, isSVG))\n }\n\n return (vnode.node = /** @type{Element} */ (node))\n}\n\n/**\n * Get key of vnode element.\n * @param {VNode} vnode\n * @returns {null | string | number} null | string | number\n */\nconst getKey = vnode => vnode == null ? null : vnode.key\n\n/**\n * Remove child node.\n * @param {VNode} vnode\n * @returns {Node} node\n */\nfunction removeChildren(vnode) {\n for (let i = 0, {length} = vnode.children; i < length; i++) {\n removeChildren(vnode.children[i])\n }\n\n const cb = vnode.props['ondestroy']\n cb != null && cb(vnode.node)\n\n return vnode.node\n}\n\n/**\n * Remove element from DOM.\n * @param {Node} parent\n * @param {VNode} vnode\n * @returns {void} undefined\n */\nfunction removeElement(parent, vnode) {\n const remove = function() {\n parent.removeChild(removeChildren(vnode))\n }\n\n const cb = vnode.props && vnode.props['onunmount']\n cb != null\n ? cb(vnode.node, remove)\n : remove()\n}\n\n/**\n * Patch element in DOM according to new props.\n * @param {Node} parent\n * @param {Node} node\n * @param {any} oldVNode\n * @param {any} newVNode\n * @param {boolean} [isSVG]\n */\nfunction patchNode(parent, node, oldVNode, newVNode, isSVG) {\n if (oldVNode === newVNode) {\n } else if (\n oldVNode != null\n && oldVNode.flag === TEXT_NODE\n && newVNode.flag === TEXT_NODE\n ) {\n if (oldVNode.type !== newVNode.type) {\n node.nodeValue = newVNode.type\n }\n } else if (oldVNode == null || oldVNode.type !== newVNode.type) {\n node = parent.insertBefore(createNode(newVNode, LIFECYCLE, isSVG), node)\n if (oldVNode != null) {\n removeElement(parent, oldVNode)\n }\n } else {\n let tmpVKid\n let oldVKid\n\n let oldKey\n let newKey\n\n const oldVProps = oldVNode.props\n const newVProps = newVNode.props\n\n const oldVKids = oldVNode.children\n const newVKids = newVNode.children\n\n let oldHead = 0\n let newHead = 0\n let oldTail = oldVKids.length - 1\n let newTail = newVKids.length - 1\n\n isSVG = isSVG || newVNode.type === 'svg'\n\n for (const i in mergeObjects(oldVProps, newVProps)) {\n (\n (i === 'value' || i === 'selected' || i === 'checked'\n ? node[i]\n : oldVProps[i]) !== newVProps[i]\n )\n && (() => {\n patchProperty(\n /** @type{Element} */(node),\n i,\n oldVProps[i],\n newVProps[i],\n isSVG\n )\n const cb = newVProps.onupdate\n cb != null\n && (areNotEqual(oldVProps, newVProps))\n && LIFECYCLE.push( () => cb(node, oldVProps, newVProps))\n })()\n }\n\n while (newHead <= newTail && oldHead <= oldTail) {\n if (\n (oldKey = getKey(oldVKids[oldHead])) == null ||\n oldKey !== getKey(newVKids[newHead])\n ) {\n break\n }\n\n patchNode(\n node,\n oldVKids[oldHead].node,\n oldVKids[oldHead++],\n newVKids[newHead++],\n isSVG\n )\n }\n\n while (newHead <= newTail && oldHead <= oldTail) {\n if (\n (oldKey = getKey(oldVKids[oldTail])) == null ||\n oldKey !== getKey(newVKids[newTail])\n ) {\n break\n }\n\n patchNode(\n node,\n oldVKids[oldTail].node,\n oldVKids[oldTail--],\n newVKids[newTail--],\n isSVG\n )\n }\n\n if (oldHead > oldTail) {\n while (newHead <= newTail) {\n node.insertBefore(\n createNode(newVKids[newHead++], LIFECYCLE, isSVG),\n (oldVKid = oldVKids[oldHead]) && oldVKid.node\n )\n }\n } else if (newHead > newTail) {\n while (oldHead <= oldTail) {\n removeElement(node, oldVKids[oldHead++])\n }\n } else {\n let i\n let keyed\n let newKeyed\n for (i = oldHead, keyed = {}, newKeyed = {}; i <= oldTail; i++) {\n if ((oldKey = oldVKids[i].key) != null) {\n keyed[oldKey] = oldVKids[i]\n }\n }\n\n while (newHead <= newTail) {\n oldKey = getKey((oldVKid = oldVKids[oldHead]))\n newKey = getKey(newVKids[newHead])\n\n if (\n newKeyed[oldKey] ||\n (newKey != null && newKey === getKey(oldVKids[oldHead + 1]))\n ) {\n if (oldKey == null) {\n removeElement(node, oldVKid)\n }\n oldHead++\n continue\n }\n\n if (newKey == null || oldVNode.flag === RECYCLED_NODE) {\n if (oldKey == null) {\n patchNode(\n node,\n oldVKid && oldVKid.node,\n oldVKid,\n newVKids[newHead],\n isSVG\n )\n newHead++\n }\n oldHead++\n } else {\n if (oldKey === newKey) {\n patchNode(node, oldVKid.node, oldVKid, newVKids[newHead], isSVG)\n newKeyed[newKey] = true\n oldHead++\n } else {\n if ((tmpVKid = keyed[newKey]) != null) {\n patchNode(\n node,\n node.insertBefore(tmpVKid.node, oldVKid && oldVKid.node),\n tmpVKid,\n newVKids[newHead],\n isSVG\n )\n newKeyed[newKey] = true\n } else {\n patchNode(\n node,\n oldVKid && oldVKid.node,\n null,\n newVKids[newHead],\n isSVG\n )\n }\n }\n newHead++\n }\n }\n\n while (oldHead <= oldTail) {\n (getKey((oldVKid = oldVKids[oldHead++])) == null)\n && removeElement(node, oldVKid)\n }\n\n for (const i in keyed) {\n (newKeyed[i] == null)\n && removeElement(node, keyed[i])\n }\n }\n }\n\n return (newVNode.node = node)\n}\n\nfunction recycleNode(node) {\n return node.nodeType === TEXT_NODE\n ? createTextVNode(node.nodeValue, node)\n : createVNode(\n node.nodeName.toLowerCase(),\n EMPTY_OBJECT,\n Array.prototype.map.call(node.childNodes, recycleNode),\n node,\n null,\n RECYCLED_NODE\n )\n}\n\n/**\n * Patch DOM with virtual node from functional component.\n * @param {Node} node\n * @param {VNode} vdom\n */\nexport function patch(node, vdom) {\n if (!node['vdom']) {\n if (vdom.props['onmount']) {\n LIFECYCLE.push(() => vdom.props['onmount'](node))\n }\n }\n const vnode = (patchNode(\n node.parentNode,\n node,\n node['vdom'] || recycleNode(node),\n vdom\n )['vdom'] = vdom)\n while (LIFECYCLE.length > 0) LIFECYCLE.pop()()\n return vnode\n}\n","import { patch } from './vdom'\n\n/**\n * Render a functional component. The first argument is the component to render. This can be either a JSX tag or an `h` function. The second argument is the element to hydrate or update. During the first render, the target element is hydrated with the component provided. Further updates patch the existing element based on the virtual DOM.\n * @example\n *\n * ```\n * // Render Title tag into section:\n * render(<Title message='Hello World!'/>, 'section')\n * // Update the title component 5 seconds later:\n * setTimeout(() => {\n * render(<Title message='Hello Everyone!'/>, 'section')\n * }, 5000)\n * ```\n * @typedef {import('./types').VNode} VNode\n * @param {VNode} vnode\n * @param {Element | string} target\n * @return {void} undefined\n */\nexport function render(vnode, target) {\n if (Array.isArray(vnode)) {\n throw 'Cannot insert Fragment tag directly into DOM.'\n }\n let oldTarget = ''\n if (typeof target === 'string') {\n oldTarget = target\n target = document.querySelector(target)\n }\n if (!target) {\n let msg = ''\n if (oldTarget) msg = ` The selector you provided was: \"${oldTarget}\"`\n console.error(\n `@composi/core Error: The second parameter for render function was invalid. Check the selector you provided and make sure that it exists in the DOM before trying to render. ${msg}`\n )\n }\n patch(target, vnode)\n}\n","\n/**\n * The @composi/runtime.\n * @example\n *\n * ```\n * // Create a runtime program\n * const program = {\n * // Define state:\n * init() {\n * return [{count: 0}]\n * },\n * // Define view to render.\n * // Notice event to send message 'incr'.\n * view(state, send) {\n * return render(<div onclick={send('incr')}>The count is: {state.count}</div>, document.body)\n * },\n * // Define action to update state:\n * update(state, msg) {\n * if (msg === 'incr') {\n * return [state.count++]\n * }\n * }\n * }\n * // Run the program:\n * run(program)\n * ```\n * @param {import('./types').Program} program A program to run with five methods: `init`, `view`, `update`, `subscriptions` and `done`.\n * @return {() => void} Function to terminate runtime.\n */\nexport function run(program) {\n const {init, view, update, subs, done} = program\n const subscriptions = subs || program.subscriptions\n let state\n let isRunning = true\n let isFirstRun = true\n const getState = () => state\n\n /**\n * Send a message.\n * @param {import('./types').Message} message\n *\n */\n function send(message, data) {\n let msg = message\n /**\n * message is a function from a tagged union that\n * can be called to return a message object.\n */\n isRunning\n && (typeof message === 'function') \n && (msg = /** @type {Function} */ (message)(data))\n \n return isRunning &&\n updateView(update(state, msg, send))\n }\n\n /**\n * Expose send as static function on program object.\n * This is to let you send messages to the program\n * from other contexts, such as in a @composi/router action.\n */\n program['send'] = send\n\n /**\n * Handle changes to state and executing effects.\n * @param {any} update\n * @return {void} undefined\n */\n const updateView = update => {\n update \n ? state = update \n : init \n ? state = init() \n : state = undefined\n\n isFirstRun\n && subscriptions\n && typeof subscriptions === 'function'\n && subscriptions(send, getState)\n\n isFirstRun = false\n \n view(state, send)\n }\n updateView(state)\n\n /**\n * Function to end runtime.\n * @return {void} undefined\n */\n return () => {\n isRunning\n && done\n && done(state)\n \n isRunning = false\n }\n}\n","/**\n * Helper function for testing whether message type exists on actions object.\n */\nconst {hasOwnProperty} = Object\n\n\n/**\n * @param {import('./types').Tag} tag\n * @param {Object<string, Function>} handlers\n * @param {() => void} [catchAll]\n */\nfunction match(tag, handlers, catchAll) {\n const {type, data} = tag\n return type\n ? (type => {\n const match = hasOwnProperty.call(handlers, type) && handlers[type]\n return match\n ? match(data)\n : catchAll\n ? catchAll()\n : console.error(\n `The message you sent has no matching action method. Check the spelling for the message or the action method. The message type was \"${type}\".`\n )\n })(type)\n : (() => {\n console.error(\n \"The message you provided was not valid. Messages have the format: {type: 'whatever', data?: 'something'}\"\n )\n console.error('The tag you provided was:')\n console.dir(tag)\n })()\n}\n\n/**\n * Create a union of string tags.\n * @param {string[]} types\n * @returns {Object<string, any>} Object\n */\nfunction createUnion(types) {\n const variants = Object.create(null)\n\n let idx = 0\n while (idx < types.length) {\n const type = types[idx]\n type === 'match'\n && console.error(\n `The message type you provided was \"match\". This cannot be used since it would override the message union's own match method. Please change it to something else, such as \"matchName\", etc.`\n )\n\n variants[type] = data => ({ type, data })\n idx++\n }\n\n return { variants, match }\n}\n\n/**\n * @typedef {Object} MessageUnion\n */\n\n/**\n * Create a union of types for matching up with functions. This is used to define actions for the `update` method of a runtime program.\n * @param {...string} types\n * @returns {MessageUnion} MessageUnion\n */\nexport function union(...types) {\n const { variants, match } = createUnion(types)\n variants.match = match\n return variants\n}\n","/**\n * @typedef {import('./types').Send} Send\n * @typedef {import('./types').Message} Message\n * @typedef {import('./types').State} State\n * @typedef {() => State} GetState\n * @typedef {(send?: Send, getState?: GetState) => any} Effect\n */\n/**\n * Function to batch effects together.\n * @param {...Effect} effects\n * @return {(send?: Send, getState?: GetState) => void} Function\n */\nexport const batchEffects = (...effects) => (getState, send) =>\n effects.map(effect => effect && effect(getState, send))\n\nexport const batch = batchEffects\n","/**\n * Returns a group of sibling elements for inclusion in another JSX tag.\n * @typedef {import('./types').VNode} VNode\n * @typedef {import('./types').Props} Props\n * @typedef {import('./types').Children} Children\n * @param {Props} props\n * @return {Children} children\n */\n/**\n * A tag to enable returning sibling elements. This is useful for returning list items to render in a list or table cells to render in a table row.\n * @example\n *\n * ```\n * <Fragment>\n * <li>A</li>\n * <li>B</li>\n * <li>C</li>\n * </Fragment>\n ```\n * Or functionally:\n * ```\n * Fragment(null, [\n * h('li', {}, 'A'),\n * h('li', {}, 'B'),\n * h('li', {}, 'C')\n * ])\n ```\n * @param {Object} [props] When using Fragment as a function, props is the first argument. Provide either null or {} as the value for props.\n * @param {Children} [children] The siblings to return with the Fragment. This will be an array of sibling elements.\n * @return {VNode[]} An array of virtual nodes.\n */\nexport const Fragment = (props, children) =>\n Array.isArray(props) && !children ? props : children\n"],"names":["RECYCLED_NODE","TEXT_NODE","EMPTY_OBJECT","EMPTY_ARRAY","LIFECYCLE","createVNode","type","props","children","node","key","flag","createTextVNode","value","h","tempBox","childNodes","length","push","Array","isArray","pop","areNotEqual","oldVProps","newVProps","JSON","stringify","mergeObjects","a","b","Object","assign","listener","event","handlers","patchProperty","prop","oldValue","newValue","isSVG","i","style","setProperty","slice","removeEventListener","addEventListener","removeAttribute","setAttribute","createNode","vnode","document","createTextNode","createElementNS","createElement","k","len","appendChild","getKey","removeChildren","cb","removeElement","parent","remove","removeChild","patchNode","oldVNode","newVNode","nodeValue","insertBefore","tmpVKid","oldVKid","oldKey","newKey","oldVKids","newVKids","oldHead","newHead","oldTail","newTail","onupdate","keyed","newKeyed","recycleNode","nodeType","nodeName","toLowerCase","prototype","map","call","patch","vdom","parentNode","render","target","oldTarget","querySelector","msg","console","error","run","program","send","message","data","isRunning","updateView","update","state","init","view","subs","done","subscriptions","isFirstRun","getState","hasOwnProperty","match","tag","catchAll","dir","createUnion","types","variants","create","idx","union","batchEffects","effects","effect","batch","Fragment"],"mappings":"KAIaA,CAAAA,CAAa,CAAG,EAYhBC,CAAS,CAAG,EAkBZC,CAAY,CAAG,GAMfC,CAAW,CAAG,GAMdC,CAAS,CAAG,GCjClB,QAASC,CAAAA,CAAT,CACLC,CADK,CAELC,CAFK,CAGLC,CAHK,CAILC,CAJK,CAKLC,CAAG,CAAG,IALD,CAMLC,CAAI,CAAG,IANF,CAOL,OACO,CACLL,IADK,CACLA,CADK,CAELC,KAFK,CAELA,CAFK,CAGLC,QAHK,C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AHoB,CAOzByB,CAAQ,CAACpH,CAAD,CAARoH,CAAiBnB,CAAI,GAAK,CAAEjG,IAAF,CAAEA,CAAF,CAAQiG,KAAAA,CAAR,CAAL,CAPI,CAQzBqB,CAAG,SAGE,CAAEF,QAAF,CAAEA,CAAF,CAAYN,MAAAA,CAAZ,EAYF,QAASS,CAAAA,CAAT,CAAe,GAAGJ,CAAlB,CAAyB,MACxB,CAAEC,QAAF,CAAEA,CAAF,CAAYN,MAAAA,CAAZ,EAAsBI,CAAW,CAACC,CAAD,QACvCC,CAAAA,CAAQ,CAACN,KAATM,CAAiBN,EACVM,OCxDII,CAAAA,CAAY,CAAG,CAAC,GAAGC,CAAJ,GAAgB,CAACb,CAAD,CAAWb,CAAX,GAC1C0B,CAAO,CAACxC,GAARwC,CAAYC,CAAM,EAAIA,CAAM,EAAIA,CAAM,CAACd,CAAD,CAAWb,CAAX,CAAtC0B,EAEWE,CAAK,CAAGH,ECgBRI,CAAQ,CAAG,CAAC3H,CAAD,CAAQC,CAAR,GACtBW,KAAK,CAACC,OAAND,CAAcZ,CAAdY,GAAwB,CAACX,CAAzBW,CAAoCZ,CAApCY,CAA4CX"} \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index 4685152..784f94b 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "@composi/core", - "version": "2.7.4", + "version": "2.7.5", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index e073720..49d4843 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@composi/core", - "version": "2.7.4", + "version": "2.7.5", "description": "A JavaScript library for creating websites, PWAs and hybrid apps.", "main": "src/index.js", "module": "dist/composi-core.mjs", diff --git a/src/h.js b/src/h.js index 8e5955c..8f484d6 100755 --- a/src/h.js +++ b/src/h.js @@ -12,8 +12,8 @@ export function h(type, props, ...children) { let node const tempBox = [] const childNodes = [] - let length = children.length - const key = props.key + let {length} = children + const {key} = props while (length-- > 0) tempBox.push(children[length]) @@ -24,7 +24,7 @@ export function h(type, props, ...children) { while (tempBox.length > 0) { if (Array.isArray((node = tempBox.pop()))) { - let length = node.length + let {length} = node while (length-- > 0) { tempBox.push(node[length]) } diff --git a/src/runtime.js b/src/runtime.js index 9b66aed..4809e77 100644 --- a/src/runtime.js +++ b/src/runtime.js @@ -29,11 +29,8 @@ * @return {() => void} Function to terminate runtime. */ export function run(program) { - let init = program.init - const view = program.view - const update = program.update - const subscriptions = program.subscriptions || program.subs - const done = program.done + const {init, view, update, subs, done} = program + const subscriptions = subs || program.subscriptions let state let isRunning = true let isFirstRun = true diff --git a/src/types.js b/src/types.js index ba3bc80..04337af 100644 --- a/src/types.js +++ b/src/types.js @@ -54,3 +54,5 @@ export {} * @prop {(state: State) => void} [done] Method to do clean up when shutting down a program. * @prop {Send} [send] A static send function for dispatching message to a program. Used with routers and in composition. */ + + //export { VNode, Message, Send, Program, State, Props, GetState } from "./types" diff --git a/src/union.js b/src/union.js index bb26b6c..ad790dc 100644 --- a/src/union.js +++ b/src/union.js @@ -1,7 +1,7 @@ /** * Helper function for testing whether message type exists on actions object. */ -const hasOwnProperty = Object.prototype.hasOwnProperty +const {hasOwnProperty} = Object /** diff --git a/src/vdom.js b/src/vdom.js index de4e9c8..5dbab32 100644 --- a/src/vdom.js +++ b/src/vdom.js @@ -38,7 +38,7 @@ function listener(event) { function patchProperty(node, prop, oldValue, newValue, isSVG) { if (prop === 'key') { } else if (prop === 'style' && typeof newValue === 'object') { - for (let i in mergeObjects(oldValue, newValue)) { + for (const i in mergeObjects(oldValue, newValue)) { const style = newValue == null || newValue[i] == null ? '' : newValue[i] i[0] === '-' ? node[prop].setProperty(i, style) @@ -82,14 +82,12 @@ function createNode(vnode, LIFECYCLE, isSVG) { : (isSVG = isSVG || type === 'svg') // eslint-disable-line no-cond-assign ? document.createElementNS('http://www.w3.org/2000/svg', type) : document.createElement(type) - const props = vnode.props + const {props} = vnode if (props['onmount']) { - LIFECYCLE.push(function() { - props['onmount'](node) - }) + LIFECYCLE.push(() => props['onmount'](node)) } - for (let k in props) { + for (const k in props) { patchProperty(/** @type {Element} */ (node), k, null, props[k], isSVG) } @@ -113,7 +111,7 @@ const getKey = vnode => vnode == null ? null : vnode.key * @returns {Node} node */ function removeChildren(vnode) { - for (let i = 0, length = vnode.children.length; i < length; i++) { + for (let i = 0, {length} = vnode.children; i < length; i++) { removeChildren(vnode.children[i]) } @@ -183,7 +181,7 @@ function patchNode(parent, node, oldVNode, newVNode, isSVG) { isSVG = isSVG || newVNode.type === 'svg' - for (let i in mergeObjects(oldVProps, newVProps)) { + for (const i in mergeObjects(oldVProps, newVProps)) { ( (i === 'value' || i === 'selected' || i === 'checked' ? node[i] @@ -200,9 +198,7 @@ function patchNode(parent, node, oldVNode, newVNode, isSVG) { const cb = newVProps.onupdate cb != null && (areNotEqual(oldVProps, newVProps)) - && LIFECYCLE.push(function () { - cb(node, oldVProps, newVProps) - }) + && LIFECYCLE.push( () => cb(node, oldVProps, newVProps)) })() } @@ -322,7 +318,7 @@ function patchNode(parent, node, oldVNode, newVNode, isSVG) { && removeElement(node, oldVKid) } - for (let i in keyed) { + for (const i in keyed) { (newKeyed[i] == null) && removeElement(node, keyed[i]) } @@ -353,9 +349,7 @@ function recycleNode(node) { export function patch(node, vdom) { if (!node['vdom']) { if (vdom.props['onmount']) { - LIFECYCLE.push(function() { - vdom.props['onmount'](node) - }) + LIFECYCLE.push(() => vdom.props['onmount'](node)) } } const vnode = (patchNode( diff --git a/types/index.d.ts b/types/index.d.ts index ba8856e..dbc1649 100644 --- a/types/index.d.ts +++ b/types/index.d.ts @@ -4,3 +4,4 @@ export { run } from "./runtime"; export { union } from "./union"; export { Fragment } from "./fragment"; export { batchEffects, batch } from "./effects"; +export { VNode, Message, Send, Program, State, Props, GetState } from "./types"