From 718656fe3278758e7b309bf7ee5e1cd29a6fa73c Mon Sep 17 00:00:00 2001 From: Robert Biggs Date: Tue, 29 Oct 2019 17:38:18 -0700 Subject: [PATCH] Update to vdom for onupdate hook. 1. Previous the onupdate hook always fired whether the props changed or not. Introduced a check to only fire onupdate when an element's props have changed. --- CHANGELOG.md | 6 ++++++ dist/composi-core.js | 2 +- dist/composi-core.js.gz | Bin 2383 -> 2410 bytes dist/composi-core.js.map | 2 +- dist/composi-core.mjs | 2 +- dist/composi-core.mjs.gz | Bin 2305 -> 2338 bytes dist/composi-core.mjs.map | 2 +- package-lock.json | 2 +- package.json | 2 +- src/vdom.js | 18 +++++++++++++++--- test/render.html | 38 +++++++++++++++++++++++++++----------- 11 files changed, 54 insertions(+), 20 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d8ddb14..a8808cf 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,11 @@ # composi/core Changelog +## 2.5.8 (October, 29, 2019) + +### src/vdom.js + +* Added function `areNotEqual` which is used to check if the old props and new props of a VNode are identical. If they are not identical then `onupdate` executes, otherwise not. + ## 2.5.7 (October 27, 2019) ### tsconfig.json, package.json diff --git a/dist/composi-core.js b/dist/composi-core.js index 279487b..233ce27 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){var e=4w)for(;v<=x;)b.insertBefore(g(t[v++],r,j),(m=s[u])&&m.node);else if(v>x)for(;u<=w;)k(b,s[u++]);else{var i,z,A;for(i=u,z={},A={};i<=w;i++)null!=(n=s[i].key)&&(z[n]=s[i]);for(;v<=x;){if(n=h(m=s[u]),o=h(t[v]),A[n]||null!=o&&o===h(s[u+1])){null==n&&k(b,m),u++;continue}null==o||0===c.flag?(null==n&&(l(b,m&&m.node,m,t[v],j),v++),u++):(n===o?(l(b,m.node,m,t[v],j),A[o]=!0,u++):null==(a=z[o])?l(b,m&&m.node,null,t[v],j):(l(b,b.insertBefore(a.node,m&&m.node),a,t[v],j),A[o]=!0),v++)}for(;u<=w;)null==h(m=s[u++])&&k(b,m);for(var B in z)null==A[B]&&k(b,z[B])}}();return e.node=b}function m(a){return a.nodeType===3?c(a.nodeValue,a):b(a.nodeName.toLowerCase(),p,Array.prototype.map.call(a.childNodes,m),a,null,0)}function n(a,b){!a.vdom&&b.props.onmount&&r.push(function(){b.props.onmount(a)});for(var c=l(a.parentNode,a,a.vdom||m(a),b).vdom=b;0({type:d,data:a}),c++};c{var d=a.type,e=s.call(b,d)&&b[d];return e(a.data,c)})(a):(console.error("The message you provided was not valid. Messages have the format: {type: 'whatever', data: 'something'}"),console.error("The tag you provided was:"),void console.dir(a))}}}var p={},q=[],r=[],s=Object.prototype.hasOwnProperty;a.h=function(a,d){d=d||{};for(var e,f=[],g=[],h=arguments.length,i=Array(2=f.length&&f.push(d.children),delete d.children);0d;return a.send=b,c(d),()=>{j&&(j=!1,i&&i(d))}},a.union=function(){for(var a=arguments.length,b=Array(a),c=0;cb.map(b=>b&&b(a,c))},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){var e=4w)for(;v<=x;)b.insertBefore(h(t[v++],r,j),(m=s[u])&&m.node);else if(v>x)for(;u<=w;)k(b,s[u++]);else{var z,A,B;for(z=u,A={},B={};z<=w;z++)null!=(n=s[z].key)&&(A[n]=s[z]);for(;v<=x;){if(n=i(m=s[u]),o=i(t[v]),B[n]||null!=o&&o===i(s[u+1])){null==n&&k(b,m),u++;continue}null==o||0===c.flag?(null==n&&(l(b,m&&m.node,m,t[v],j),v++),u++):(n===o?(l(b,m.node,m,t[v],j),B[o]=!0,u++):null==(a=A[o])?l(b,m&&m.node,null,t[v],j):(l(b,b.insertBefore(a.node,m&&m.node),a,t[v],j),B[o]=!0),v++)}for(;u<=w;)null==i(m=s[u++])&&k(b,m);for(var C in A)null==B[C]&&k(b,A[C])}}();return f.node=b}function m(a){return a.nodeType===3?c(a.nodeValue,a):b(a.nodeName.toLowerCase(),p,Array.prototype.map.call(a.childNodes,m),a,null,0)}function n(a,b){!a.vdom&&b.props.onmount&&r.push(function(){b.props.onmount(a)});for(var c=l(a.parentNode,a,a.vdom||m(a),b).vdom=b;0({type:d,data:a}),c++};c{var d=a.type,e=s.call(b,d)&&b[d];return e(a.data,c)})(a):(console.error("The message you provided was not valid. Messages have the format: {type: 'whatever', data: 'something'}"),console.error("The tag you provided was:"),void console.dir(a))}}}var p={},q=[],r=[],s=Object.prototype.hasOwnProperty;a.h=function(a,d){d=d||{};for(var e,f=[],g=[],h=arguments.length,i=Array(2=f.length&&f.push(d.children),delete d.children);0d;return a.send=b,c(d),()=>{j&&(j=!1,i&&i(d))}},a.union=function(){for(var a=arguments.length,b=Array(a),c=0;cb.map(b=>b&&b(a,c))},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 06a2d336c00c59a712424b6d7efaaf60b4f32d1d..e2b37714e532abb1b9dfe39d2d548c2f6f321ed9 100644 GIT binary patch literal 2410 zcmV-w36=IAiwFP!000006RlXua^uJmz0X&G@B|taDnXQb<^rfhOFiv_qZfy}?F)l3 zT>uIsND!c~kYZE(cfYK{LQx9);)6t>maJS}zRZG~GmqJ4H3{8z74z**+#td1avbyP$#pz2kM7iN_t`U? z?T4=PqGG)%s#F|~?8w}DkydWYSRv`oBObHER+g3$zun4m-mFz# zS6-&_dA)F)eq{RFY$U|CNMma}IUV)$Cd+ste*dq#e}8lL?`C&Us=6uj1DWnizA1}M zq1T2$n?b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Y%&N;hps|3PIn}d% zJ;bMBWF~CqGIB#K-|H?*z2kVtc*QfFNUhGU&Wj&QYNIA&+|Frp!$F7 zWKL{LQAkYyt|s?%+c#GaI=@Rpp|e-qU*@jkjKYaT(QEnJd^+pDj!16*`KPMB>JM=? zKj^!IKN{2Lv*4HO>%Ul4(Ug(;irX!s^k4t{BHBc{qD1nR6{+>he*nHRfl~$)000w; Bs^|a! diff --git a/dist/composi-core.js.map b/dist/composi-core.js.map index 4f97735..ba3b54d 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/h.js","../src/render.js","../src/runtime.js","../src/effects.js","../src/fragment.js"],"sourcesContent":["import { EMPTY_OBJECT, EMPTY_ARRAY, TEXT_NODE } from './constants'\n\n/**\n * @typedef {Object | {}} Props\n * @prop {Children} Props.children\n * @prop {(Element) => void} [Props.onmount]\n * @prop {(Element, Object, Object) => void} [Props.onupdate]\n * @prop {(Element, (State) => void) => void} [Props.onunmount]\n */\n/**\n * @typedef {VNode[]} Children\n */\n/**\n * @typedef {string | number | Function} Type\n * @typedef {number | string | null} Key\n * @typedef {Object | {}} VNode\n * @prop {Type} type\n * @prop {Props} props\n * @prop {Children} children\n * @prop {Element} node\n * @prop {Key} [key]\n * @prop {number} flag\n */\n/**\n * Create a virtual node with the provided properties.\n * @param {string | Function} type\n * @param {Props} props\n * @param {Children} children\n * @param {Element} node\n * @param {string | number | null} key\n * @param {number} [flag]\n * @return {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 {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 * @typedef {import('./vnode').VNode} VNode\n */\n/**\n * Return the combination of two objects of props.\n * @param {Object} a\n * @param {Object} b\n */\nexport function mergeObjects(a, b) {\n return Object.assign({}, a, b)\n}\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 if (i[0] === '-') {\n node[prop].setProperty(i, style)\n } else {\n node[prop][i] = style\n }\n }\n } else if (prop[0] === 'o' && prop[1] === 'n') {\n if (\n !((node['handlers'] || (node['handlers'] = {}))[\n (prop = prop.slice(2).toLowerCase())\n ] = newValue)\n ) {\n node.removeEventListener(prop, listener)\n } else if (!oldValue) {\n node.addEventListener(prop, listener)\n }\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 = /** @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 */\nfunction getKey(vnode) {\n return vnode == null ? null : vnode.key\n}\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 if (cb != null) {\n cb(vnode.node)\n }\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 if (cb != null) {\n cb(vnode.node, remove)\n } else {\n remove()\n }\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 if (\n (i === 'value' || i === 'selected' || i === 'checked'\n ? node[i]\n : oldVProps[i]) !== newVProps[i]\n ) {\n patchProperty(\n /** @type{Element} */ (node),\n i,\n oldVProps[i],\n newVProps[i],\n isSVG\n )\n const cb = newVProps.onupdate\n if (cb != null) {\n LIFECYCLE.push(function() {\n cb(node, oldVProps, newVProps)\n })\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, keyed, 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 if (getKey((oldVKid = oldVKids[oldHead++])) == null) {\n removeElement(node, oldVKid)\n }\n }\n\n for (let i in keyed) {\n if (newKeyed[i] == null) {\n removeElement(node, keyed[i])\n }\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","const hasOwnProperty = Object.prototype.hasOwnProperty\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 function match(tag, handlers) {\n if (!tag.type) {\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 return\n }\n return ((tag, context) => {\n const type = tag.type\n const match = hasOwnProperty.call(handlers, type) && handlers[type]\n return match(tag.data, context)\n })(tag)\n }\n\n let idx = 0\n while (idx < types.length) {\n const type = types[idx]\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} MessagesUnion\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","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('./vnode').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 if (props.children) {\n if (tempBox.length <= 0) {\n tempBox.push(props.children)\n }\n delete props.children\n }\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 if (typeof type === 'function') {\n return type(props, childNodes)\n } else {\n return createVNode(type, props, childNodes, null, key)\n }\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('./vnode').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 * @typedef {Object<string, any>} Message\n * @prop {string} type\n * @prop {any} [data]\n * @typedef {(msg?: Message) => Message} Send\n */\n/**\n * @typedef {any} State Simple or complex types for application state.\n */\n/**\n * @typedef {State | void} InitResult Return result of program init method.\n */\n/**\n * @typedef {Object<string, any>} Program A program to run.\n * @prop {() => InitResult} init Method to set up initial state.\n * @prop {(state: State, send?: Send) => void} view Method to present the current application state.\n * @prop {(state: State, msg?: Message, send?: Send) => any} update Method to capture messages sent from view or subscriptions. According to the message, an action will transform application state and pass it the the program view method.\n * @prop {(getState: () => State, send: Send) => void} [subscriptions] Method to run effects when the program starts. These run independently from the rest of the program.\n * @prop {(getState: () => State, send: Send) => void} [subs] Shortcut for subscriptions.\n * @prop {(state: State) => void} [done] Method to do clean up when shutting down a program.\n * @prop {Send} [send] A static send function for dispatching message to a program. Used with routers and in composition.\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 {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 {Message} message\n *\n */\n function send(message) {\n if (isRunning) {\n return updateView(update(state, message, send))\n }\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 function updateView(update) {\n if (update) {\n state = update\n } else if (init) {\n state = init()\n }\n if (subscriptions && isFirstRun) {\n if (typeof subscriptions === 'function') subscriptions(getState, send)\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 if (isRunning) {\n isRunning = false\n if (done) {\n done(state)\n }\n }\n }\n}\n","/**\n * @typedef {import('./runtime').Send} Send\n * @typedef {import('./runtime').Message} Message\n * @typedef {Object} State\n * @typedef {() => State} GetState\n * @typedef {(getState: GetState, send: Send) => any} Effect\n */\n/**\n * Function to batch effects together.\n * @param {...Effect} effects\n * @return {(getState: GetState, send: Send) => any} Function\n */\nexport const batchEffects = (...effects) => (getState, send) =>\n effects.map(effect => effect && effect(getState, send))\n","/**\n * Returns a group of sibling elements for inclusion in another JSX tag.\n * @typedef {import('./vnode').VNode} VNode\n * @typedef {import('./vnode').Props} Props\n * @typedef {import('./vnode').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","mergeObjects","a","b","Object","assign","listener","event","handlers","patchProperty","prop","oldValue","newValue","isSVG","i","style","setProperty","slice","toLowerCase","addEventListener","removeEventListener","removeAttribute","setAttribute","createNode","vnode","LIFECYCLE","document","createTextNode","createElementNS","createElement","k","push","len","length","appendChild","getKey","removeChildren","cb","removeElement","parent","remove","removeChild","patchNode","oldVNode","newVNode","nodeValue","insertBefore","tmpVKid","oldVKid","oldKey","newKey","oldVProps","newVProps","oldVKids","newVKids","oldHead","newHead","oldTail","newTail","onupdate","keyed","newKeyed","recycleNode","nodeType","nodeName","Array","prototype","map","call","childNodes","patch","vdom","parentNode","pop","createUnion","types","variants","create","idx","data","match","tag","context","hasOwnProperty","console","error","dir","tempBox","isArray","target","oldTarget","querySelector","msg","program","send","message","isRunning","updateView","update","state","init","subscriptions","isFirstRun","getState","view","subs","done","effects","effect"],"mappings":"2LAiCO,QAASA,CAAAA,CAAT,CACLC,CADK,CAELC,CAFK,CAGLC,CAHK,CAILC,CAJK,CAOL,IAFAC,CAAAA,CAEA,wDAFM,IAEN,CADAC,CACA,wDADO,IACP,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,IC/Cb,QAASO,CAAAA,CAAT,CAAsBC,CAAtB,CAAyBC,CAAzB,CAA4B,OAC1BC,CAAAA,MAAM,CAACC,MAAPD,CAAc,EAAdA,CAAkBF,CAAlBE,CAAqBD,CAArBC,EAOT,QAASE,CAAAA,CAAT,CAAkBC,CAAlB,CAAyB,MAClBC,SAASD,CAAK,CAAChB,MAAMgB,GAW5B,QAASE,CAAAA,CAAT,CAAuBf,CAAvB,CAA6BgB,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,IAAKb,CAAAA,CAAY,CAACU,CAAD,CAAWC,CAAX,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CAAO,MAAA,EAAA,cAAPA,CAAO,EAAA,CAAPA,aAAAA,OACKD,CAAW,CAACC,CAAD,EAA/BC,CADsB,GACtBA,SAAUI,CADY,GACZA,YAClBJ,CAAAA,CAAQ,CAACI,KAATJ,CAAiBI,EACVJ,kBKpCmB,sCAAI+B,CAAJ,MAAA,EAAA,cAAIA,CAAJ,EAAA,CAAIA,aAAAA,OAAY,CAACJ,CAAD,CAAWT,CAAX,GAC1Ca,CAAO,CAACxC,GAARwC,CAAYC,CAAM,EAAIA,CAAM,EAAIA,CAAM,CAACL,CAAD,CAAWT,CAAX,CAAtCa,CADK,aCmBiB,CAACnH,CAAD,CAAQC,CAAR,GACtBwE,KAAK,CAACuB,OAANvB,CAAczE,CAAdyE,GAAwB,CAACxE,CAAzBwE,CAAoCzE,CAApCyE,CAA4CxE"} \ 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/h.js","../src/render.js","../src/runtime.js","../src/effects.js","../src/fragment.js"],"sourcesContent":["import { EMPTY_OBJECT, EMPTY_ARRAY, TEXT_NODE } from './constants'\n\n/**\n * @typedef {Object<string, any> | {}} Props\n * @prop {Children} Props.children\n * @prop {(Element) => void} [Props.onmount]\n * @prop {(Element, Object, Object) => void} [Props.onupdate]\n * @prop {(Element, (State) => void) => void} [Props.onunmount]\n */\n/**\n * @typedef {VNode[]} Children\n */\n/**\n * @typedef {string | number | Function} Type\n * @typedef {number | string | null} Key\n * @typedef {Object | {}} VNode\n * @prop {Type} type\n * @prop {Props} props\n * @prop {Children} children\n * @prop {Element} node\n * @prop {Key} [key]\n * @prop {number} flag\n */\n/**\n * Create a virtual node with the provided properties.\n * @param {string | Function} type\n * @param {Props} props\n * @param {Children} children\n * @param {Element} node\n * @param {string | number | null} key\n * @param {number} [flag]\n * @return {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 {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('./vnode').Props} Props\n * @param {Props} oldVProps\n * @param {Props} newVProps\n */\nfunction areNotEqual(oldVProps, newVProps) {\n return JSON.stringify(oldVProps) !== JSON.stringify(newVProps)\n}\n\n/**\n * @typedef {import('./vnode').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 function mergeObjects(a, b) {\n return Object.assign({}, a, b)\n}\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 if (i[0] === '-') {\n node[prop].setProperty(i, style)\n } else {\n node[prop][i] = style\n }\n }\n } else if (prop[0] === 'o' && prop[1] === 'n') {\n if (\n !((node['handlers'] || (node['handlers'] = {}))[\n (prop = prop.slice(2).toLowerCase())\n ] = newValue)\n ) {\n node.removeEventListener(prop, listener)\n } else if (!oldValue) {\n node.addEventListener(prop, listener)\n }\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 = /** @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 */\nfunction getKey(vnode) {\n return vnode == null ? null : vnode.key\n}\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 if (cb != null) {\n cb(vnode.node)\n }\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 if (cb != null) {\n cb(vnode.node, remove)\n } else {\n remove()\n }\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 if (\n (i === 'value' || i === 'selected' || i === 'checked'\n ? node[i]\n : oldVProps[i]) !== newVProps[i]\n ) {\n patchProperty(\n /** @type{Element} */ (node),\n i,\n oldVProps[i],\n newVProps[i],\n isSVG\n )\n const cb = newVProps.onupdate\n if (cb != null) {\n if (areNotEqual(oldVProps, newVProps)) {\n LIFECYCLE.push(function() {\n cb(node, oldVProps, newVProps)\n })\n }\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, keyed, 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 if (getKey((oldVKid = oldVKids[oldHead++])) == null) {\n removeElement(node, oldVKid)\n }\n }\n\n for (let i in keyed) {\n if (newKeyed[i] == null) {\n removeElement(node, keyed[i])\n }\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","const hasOwnProperty = Object.prototype.hasOwnProperty\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 function match(tag, handlers) {\n if (!tag.type) {\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 return\n }\n return ((tag, context) => {\n const type = tag.type\n const match = hasOwnProperty.call(handlers, type) && handlers[type]\n return match(tag.data, context)\n })(tag)\n }\n\n let idx = 0\n while (idx < types.length) {\n const type = types[idx]\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} MessagesUnion\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","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('./vnode').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 if (props.children) {\n if (tempBox.length <= 0) {\n tempBox.push(props.children)\n }\n delete props.children\n }\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 if (typeof type === 'function') {\n return type(props, childNodes)\n } else {\n return createVNode(type, props, childNodes, null, key)\n }\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('./vnode').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 * @typedef {Object<string, any>} Message\n * @prop {string} type\n * @prop {any} [data]\n * @typedef {(msg?: Message) => Message} Send\n */\n/**\n * @typedef {any} State Simple or complex types for application state.\n */\n/**\n * @typedef {State | void} InitResult Return result of program init method.\n */\n/**\n * @typedef {Object<string, any>} Program A program to run.\n * @prop {() => InitResult} init Method to set up initial state.\n * @prop {(state: State, send?: Send) => void} view Method to present the current application state.\n * @prop {(state: State, msg?: Message, send?: Send) => any} update Method to capture messages sent from view or subscriptions. According to the message, an action will transform application state and pass it the the program view method.\n * @prop {(getState: () => State, send: Send) => void} [subscriptions] Method to run effects when the program starts. These run independently from the rest of the program.\n * @prop {(getState: () => State, send: Send) => void} [subs] Shortcut for subscriptions.\n * @prop {(state: State) => void} [done] Method to do clean up when shutting down a program.\n * @prop {Send} [send] A static send function for dispatching message to a program. Used with routers and in composition.\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 {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 {Message} message\n *\n */\n function send(message) {\n if (isRunning) {\n return updateView(update(state, message, send))\n }\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 function updateView(update) {\n if (update) {\n state = update\n } else if (init) {\n state = init()\n }\n if (subscriptions && isFirstRun) {\n if (typeof subscriptions === 'function') subscriptions(getState, send)\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 if (isRunning) {\n isRunning = false\n if (done) {\n done(state)\n }\n }\n }\n}\n","/**\n * @typedef {import('./runtime').Send} Send\n * @typedef {import('./runtime').Message} Message\n * @typedef {Object} State\n * @typedef {() => State} GetState\n * @typedef {(getState: GetState, send: Send) => any} Effect\n */\n/**\n * Function to batch effects together.\n * @param {...Effect} effects\n * @return {(getState: GetState, send: Send) => any} Function\n */\nexport const batchEffects = (...effects) => (getState, send) =>\n effects.map(effect => effect && effect(getState, send))\n","/**\n * Returns a group of sibling elements for inclusion in another JSX tag.\n * @typedef {import('./vnode').VNode} VNode\n * @typedef {import('./vnode').Props} Props\n * @typedef {import('./vnode').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","areNotEqual","oldVProps","newVProps","JSON","stringify","mergeObjects","a","b","Object","assign","listener","event","handlers","patchProperty","prop","oldValue","newValue","isSVG","i","style","setProperty","slice","toLowerCase","addEventListener","removeEventListener","removeAttribute","setAttribute","createNode","vnode","LIFECYCLE","document","createTextNode","createElementNS","createElement","k","push","len","length","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","Array","prototype","map","call","childNodes","patch","vdom","parentNode","pop","createUnion","types","variants","create","idx","data","match","tag","context","hasOwnProperty","console","error","dir","tempBox","isArray","target","oldTarget","querySelector","msg","program","send","message","isRunning","updateView","update","state","init","subscriptions","isFirstRun","getState","view","subs","done","effects","effect"],"mappings":"2LAiCO,QAASA,CAAAA,CAAT,CACLC,CADK,CAELC,CAFK,CAGLC,CAHK,CAILC,CAJK,CAOL,IAFAC,CAAAA,CAEA,wDAFM,IAEN,CADAC,CACA,wDADO,IACP,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,ICjDpB,QAASO,CAAAA,CAAT,CAAqBC,CAArB,CAAgCC,CAAhC,CAA2C,OAClCC,CAAAA,IAA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CAAD,CAAWT,CAAX,CAP9B,CAQxBQ,CAAU,GARc,EAU1BE,CAAI,CAACL,CAAD,CAAQL,CAAR,EA5CqB,GAMvBK,CAAAA,CANuB,CACvBC,CAAI,CAAGP,CAAO,CAACO,IADQ,CAErBI,CAAI,CAAGX,CAAO,CAACW,IAFM,CAGrBN,CAAM,CAAGL,CAAO,CAACK,MAHI,CAIrBG,CAAa,CAAGR,CAAO,CAACQ,aAARR,EAAyBA,CAAO,CAACY,IAJ5B,CAKrBC,CAAI,CAAGb,CAAO,CAACa,IALM,CAOvBV,CAAS,GAPc,CAQvBM,CAAU,GARa,CASrBC,CAAQ,CAAG,IAAMJ,CATI,OA2B3BN,CAAAA,CAAO,KAAPA,CAAkBC,EAmBlBG,CAAU,CAACE,CAAD,EAMH,IAAM,CACPH,CADO,GAETA,CAAS,GAFA,CAGLU,CAHK,EAIPA,CAAI,CAACP,CAAD,CAJG,CAAb,WJ1DK,UAAyB,4BAAPxB,CAAO,MAAA,EAAA,cAAPA,CAAO,EAAA,CAAPA,aAAAA,OACKD,CAAW,CAACC,CAAD,EAA/BC,CADsB,GACtBA,SAAUI,CADY,GACZA,YAClBJ,CAAAA,CAAQ,CAACI,KAATJ,CAAiBI,EACVJ,kBKpCmB,sCAAI+B,CAAJ,MAAA,EAAA,cAAIA,CAAJ,EAAA,CAAIA,aAAAA,OAAY,CAACJ,CAAD,CAAWT,CAAX,GAC1Ca,CAAO,CAACxC,GAARwC,CAAYC,CAAM,EAAIA,CAAM,EAAIA,CAAM,CAACL,CAAD,CAAWT,CAAX,CAAtCa,CADK,aCmBiB,CAACtH,CAAD,CAAQC,CAAR,GACtB2E,KAAK,CAACuB,OAANvB,CAAc5E,CAAd4E,GAAwB,CAAC3E,CAAzB2E,CAAoC5E,CAApC4E,CAA4C3E"} \ No newline at end of file diff --git a/dist/composi-core.mjs b/dist/composi-core.mjs index d4dc97d..f72b542 100644 --- a/dist/composi-core.mjs +++ b/dist/composi-core.mjs @@ -1,2 +1,2 @@ -var a=0,b=3,c={},d=[],e=[];function f(a,b,c,d){var e=4<arguments.length&&arguments[4]!==void 0?arguments[4]:null,f=5<arguments.length&&arguments[5]!==void 0?arguments[5]: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){b=b||{};for(var c,d=[],e=[],h=arguments.length,i=Array(2<h?h-2:0),j=2;j<h;j++)i[j-2]=arguments[j];for(var k=i.length,l=b.key;0<k--;)d.push(i[k]);for(b.children&&(0>=d.length&&d.push(b.children),delete b.children);0<d.length;)if(Array.isArray(c=d.pop()))for(var m=c.length;0<m--;)d.push(c[m]);else if(!1===c||!0===c||null==c);else e.push("object"==typeof c?c:g(c));return"function"==typeof a?a(b,e):f(a,b,e,null,l)}function h(c,a){return Object.assign({},c,a)}function j(a){this.handlers[a.type](a)}function l(a,b,c,d,e){if("key"===b);else if("style"===b&&"object"==typeof d)for(var f in h(c,d)){var g=null==d||null==d[f]?"":d[f];"-"===f[0]?a[b].setProperty(f,g):a[b][f]=g}else"o"===b[0]&&"n"===b[1]?((a.handlers||(a.handlers={}))[b=b.slice(2).toLowerCase()]=d)?!c&&a.addEventListener(b,j):a.removeEventListener(b,j):"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){var 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(var h in g.onmount&&c.push(function(){g.onmount(f)}),g)l(f,h,null,g[h],d);for(var j=0,k=a.children.length;j<k;j++)f.appendChild(m(a.children[j],c,d));return a.node=f}function n(a){return null==a?null:a.key}function o(a){for(var b=0,c=a.children.length;b<c;b++)o(a.children[b]);var d=a.props.ondestroy;return null!=d&&d(a.node),a.node}function p(a,b){var 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,j){if(f===g);else null!=f&&f.flag===b&&g.flag===b?f.type!==g.type&&(d.nodeValue=g.type):null==f||f.type!==g.type?(d=c.insertBefore(m(g,e,j),d),null!=f&&p(c,f)):function(){var b,c,k,o,r=f.props,s=g.props,t=f.children,u=g.children,v=0,w=0,x=t.length-1,y=u.length-1;for(var z in j=j||"svg"===g.type,h(r,s))("value"==z||"selected"==z||"checked"==z?d[z]:r[z])!==s[z]&&function(){l(d,z,r[z],s[z],j);var a=s.onupdate;null!=a&&e.push(function(){a(d,r,s)})}();for(;w<=y&&v<=x&&null!=(k=n(t[v]))&&k===n(u[w]);)q(d,t[v].node,t[v++],u[w++],j);for(;w<=y&&v<=x&&null!=(k=n(t[x]))&&k===n(u[y]);)q(d,t[x].node,t[x--],u[y--],j);if(v>x)for(;w<=y;)d.insertBefore(m(u[w++],e,j),(c=t[v])&&c.node);else if(w>y)for(;v<=x;)p(d,t[v++]);else{var i,A,B;for(i=v,A={},B={};i<=x;i++)null!=(k=t[i].key)&&(A[k]=t[i]);for(;w<=y;){if(k=n(c=t[v]),o=n(u[w]),B[k]||null!=o&&o===n(t[v+1])){null==k&&p(d,c),v++;continue}null==o||f.flag===a?(null==k&&(q(d,c&&c.node,c,u[w],j),w++),v++):(k===o?(q(d,c.node,c,u[w],j),B[o]=!0,v++):null==(b=A[o])?q(d,c&&c.node,null,u[w],j):(q(d,d.insertBefore(b.node,c&&c.node),b,u[w],j),B[o]=!0),w++)}for(;v<=x;)null==n(c=t[v++])&&p(d,c);for(var C in A)null==B[C]&&p(d,A[C])}}();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)});for(var c=q(a.parentNode,a,a.vdom||r(a),b).vdom=b;0<e.length;)e.pop()();return c}function t(a,b){if(Array.isArray(a))throw"Cannot insert Fragment tag directly into DOM.";var c="";if("string"==typeof b&&(c=b,b=document.querySelector(b)),!b){var d="";c&&(d=` 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. ${d}`)}s(b,a)}function u(a){function b(a){if(j)return c(g(d,a,b))}function c(a){a?d=a:e&&(d=e()),h&&k&&("function"==typeof h&&h(l,b),k=!1),f(d,b)}var d,e=a.init,f=a.view,g=a.update,h=a.subscriptions||a.subs,i=a.done,j=!0,k=!0,l=()=>d;return a.send=b,c(d),()=>{j&&(j=!1,i&&i(d))}}var v=Object.prototype.hasOwnProperty;function w(a){for(var b=Object.create(null),c=0,d=function(){var d=a[c];b[d]=a=>({type:d,data:a}),c++};c<a.length;)d();return{variants:b,match:function(a,b){return a.type?((a,c)=>{var d=a.type,e=v.call(b,d)&&b[d];return e(a.data,c)})(a):(console.error("The message you provided was not valid. Messages have the format: {type: 'whatever', data: 'something'}"),console.error("The tag you provided was:"),void console.dir(a))}}}function x(){for(var a=arguments.length,b=Array(a),c=0;c<a;c++)b[c]=arguments[c];var d=w(b),e=d.variants,f=d.match;return e.match=f,e}var y=function(){for(var a=arguments.length,b=Array(a),c=0;c<a;c++)b[c]=arguments[c];return(a,c)=>b.map(b=>b&&b(a,c))},z=(a,b)=>Array.isArray(a)&&!b?a:b;export{i as h,t as render,u as run,x as union,y as batchEffects,z as Fragment}; +var a=0,b=3,c={},d=[],e=[];function f(a,b,c,d){var e=4<arguments.length&&arguments[4]!==void 0?arguments[4]:null,f=5<arguments.length&&arguments[5]!==void 0?arguments[5]: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){b=b||{};for(var c,d=[],e=[],h=arguments.length,i=Array(2<h?h-2:0),j=2;j<h;j++)i[j-2]=arguments[j];for(var k=i.length,l=b.key;0<k--;)d.push(i[k]);for(b.children&&(0>=d.length&&d.push(b.children),delete b.children);0<d.length;)if(Array.isArray(c=d.pop()))for(var m=c.length;0<m--;)d.push(c[m]);else if(!1===c||!0===c||null==c);else e.push("object"==typeof c?c:g(c));return"function"==typeof a?a(b,e):f(a,b,e,null,l)}function h(a,b){return JSON.stringify(a)!==JSON.stringify(b)}function j(c,a){return 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(var f in j(c,d)){var g=null==d||null==d[f]?"":d[f];"-"===f[0]?a[b].setProperty(f,g):a[b][f]=g}else"o"===b[0]&&"n"===b[1]?((a.handlers||(a.handlers={}))[b=b.slice(2).toLowerCase()]=d)?!c&&a.addEventListener(b,k):a.removeEventListener(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){var 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(var h in g.onmount&&c.push(function(){g.onmount(f)}),g)l(f,h,null,g[h],d);for(var j=0,k=a.children.length;j<k;j++)f.appendChild(m(a.children[j],c,d));return a.node=f}function n(a){return null==a?null:a.key}function o(a){for(var b=0,c=a.children.length;b<c;b++)o(a.children[b]);var d=a.props.ondestroy;return null!=d&&d(a.node),a.node}function p(a,b){var 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 null!=f&&f.flag===b&&g.flag===b?f.type!==g.type&&(d.nodeValue=g.type):null==f||f.type!==g.type?(d=c.insertBefore(m(g,e,k),d),null!=f&&p(c,f)):function(){var b,c,o,r,s=f.props,t=g.props,u=f.children,v=g.children,w=0,x=0,y=u.length-1,z=v.length-1;for(var A in k=k||"svg"===g.type,j(s,t))("value"==A||"selected"==A||"checked"==A?d[A]:s[A])!==t[A]&&function(){l(d,A,s[A],t[A],k);var a=t.onupdate;null!=a&&h(s,t)&&e.push(function(){a(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{var i,B,C;for(i=w,B={},C={};i<=y;i++)null!=(o=u[i].key)&&(B[o]=u[i]);for(;x<=z;){if(o=n(c=u[w]),r=n(v[x]),C[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),C[r]=!0,w++):null==(b=B[r])?q(d,c&&c.node,null,v[x],k):(q(d,d.insertBefore(b.node,c&&c.node),b,v[x],k),C[r]=!0),x++)}for(;w<=y;)null==n(c=u[w++])&&p(d,c);for(var D in B)null==C[D]&&p(d,B[D])}}();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)});for(var c=q(a.parentNode,a,a.vdom||r(a),b).vdom=b;0<e.length;)e.pop()();return c}function t(a,b){if(Array.isArray(a))throw"Cannot insert Fragment tag directly into DOM.";var c="";if("string"==typeof b&&(c=b,b=document.querySelector(b)),!b){var d="";c&&(d=` 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. ${d}`)}s(b,a)}function u(a){function b(a){if(j)return c(g(d,a,b))}function c(a){a?d=a:e&&(d=e()),h&&k&&("function"==typeof h&&h(l,b),k=!1),f(d,b)}var d,e=a.init,f=a.view,g=a.update,h=a.subscriptions||a.subs,i=a.done,j=!0,k=!0,l=()=>d;return a.send=b,c(d),()=>{j&&(j=!1,i&&i(d))}}var v=Object.prototype.hasOwnProperty;function w(a){for(var b=Object.create(null),c=0,d=function(){var d=a[c];b[d]=a=>({type:d,data:a}),c++};c<a.length;)d();return{variants:b,match:function(a,b){return a.type?((a,c)=>{var d=a.type,e=v.call(b,d)&&b[d];return e(a.data,c)})(a):(console.error("The message you provided was not valid. Messages have the format: {type: 'whatever', data: 'something'}"),console.error("The tag you provided was:"),void console.dir(a))}}}function x(){for(var a=arguments.length,b=Array(a),c=0;c<a;c++)b[c]=arguments[c];var d=w(b),e=d.variants,f=d.match;return e.match=f,e}var y=function(){for(var a=arguments.length,b=Array(a),c=0;c<a;c++)b[c]=arguments[c];return(a,c)=>b.map(b=>b&&b(a,c))},z=(a,b)=>Array.isArray(a)&&!b?a:b;export{i as h,t as render,u as run,x as union,y as batchEffects,z as Fragment}; //# sourceMappingURL=composi-core.mjs.map diff --git a/dist/composi-core.mjs.gz b/dist/composi-core.mjs.gz index 338c28ccd301fced39b551a932638ab976a0c11a..6d07b4f7839fb5b03fe974db4c9e684b3fdf751e 100644 GIT binary patch literal 2338 zcmV+-3ElP|iwFP!000006RlWFbK|%XzVEM~l`RcXhH2Tmdm#-gW6$g%HIGzgl8Z`J z0}|jvqDT!%NtR{(_k0cTp^+!aB?p@%&}ejj-Tk4Vt*jg=COj0s@kktwT#4D7Yy1o1 zO%XL&SvavPdB`KK*kKECEq=d~RkB&>qN%-H7fF+j$Nk9c_xXho+cHzmWO_R47n?li zvH0V^uKwevtN*a8gGx7>syH<Jwe}@nSLM3)VOpBys?voY@uF1PS3J&T;>Ucc_r5+J zdruO0qS?V}F@C`-uDP)+WP@NvF0(@@!k3rBF^J2`CD)??9-fMGH+UxAR+Zelw|D6@ zy}I=$j4#A(u((Tu#pNZ-W{a!a`LJxZnD?5OBI~r|BJ^N*Fu7Y^T?I^e>rI`y*=#vy zMm+R7f5&5YaxYYmVk<fbFs^j28||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O#tW zOGEuTIotJsren}zXIX`seGmog=y1{~c`}1~G6wgi-j7*6ri5PWx|WH4QyUHyZ=1rO ztW52sa;Hr~(j`YWQ^$JiyxSvf^-fpsxMLi5-qj`QBSosdJB?qLm)V$z;7vh7)cgq2 z$%83~QBG$+W;}UAoaEadBSO*f5XFmt4-f$sB1mUHK_Frl#XYD47%IOD1+rE7CKx@8 z_EW@Mo1{9Nr@;Ti61z_u-H^@+9Hw`4Av9xX!=Hso2yyqCYjIf&XL1?_`e{>E%`tNj zxs*5bu>8Qc=6zf6Cwkcyu$v#~H6*V-#4+-`=Fc?Jk@P9}<?8A$PF-%RNPohe2x0u^ bKR$|<6fcPs{q?dYQ-Aq4@f3&FOA`P9xZ8nm diff --git a/dist/composi-core.mjs.map b/dist/composi-core.mjs.map index 5a3aa17..d47bc42 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'\n\n/**\n * @typedef {Object<string, any> | {}} Props\n * @prop {Children} Props.children\n * @prop {(Element) => void} [Props.onmount]\n * @prop {(Element, Object, Object) => void} [Props.onupdate]\n * @prop {(Element, (State) => void) => void} [Props.onunmount]\n */\n/**\n * @typedef {VNode[]} Children\n */\n/**\n * @typedef {string | number | Function} Type\n * @typedef {number | string | null} Key\n * @typedef {Object | {}} VNode\n * @prop {Type} type\n * @prop {Props} props\n * @prop {Children} children\n * @prop {Element} node\n * @prop {Key} [key]\n * @prop {number} flag\n */\n/**\n * Create a virtual node with the provided properties.\n * @param {string | Function} type\n * @param {Props} props\n * @param {Children} children\n * @param {Element} node\n * @param {string | number | null} key\n * @param {number} [flag]\n * @return {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 {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('./vnode').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 if (props.children) {\n if (tempBox.length <= 0) {\n tempBox.push(props.children)\n }\n delete props.children\n }\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 if (typeof type === 'function') {\n return type(props, childNodes)\n } else {\n return createVNode(type, props, childNodes, null, key)\n }\n}\n","import { RECYCLED_NODE, TEXT_NODE, EMPTY_OBJECT, LIFECYCLE } from './constants'\nimport { createTextVNode, createVNode } from './vnode'\n\n/**\n * @typedef {import('./vnode').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 function mergeObjects(a, b) {\n return Object.assign({}, a, b)\n}\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 if (i[0] === '-') {\n node[prop].setProperty(i, style)\n } else {\n node[prop][i] = style\n }\n }\n } else if (prop[0] === 'o' && prop[1] === 'n') {\n if (\n !((node['handlers'] || (node['handlers'] = {}))[\n (prop = prop.slice(2).toLowerCase())\n ] = newValue)\n ) {\n node.removeEventListener(prop, listener)\n } else if (!oldValue) {\n node.addEventListener(prop, listener)\n }\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 = /** @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 */\nfunction getKey(vnode) {\n return vnode == null ? null : vnode.key\n}\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 if (cb != null) {\n cb(vnode.node)\n }\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 if (cb != null) {\n cb(vnode.node, remove)\n } else {\n remove()\n }\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 if (\n (i === 'value' || i === 'selected' || i === 'checked'\n ? node[i]\n : oldVProps[i]) !== newVProps[i]\n ) {\n patchProperty(\n /** @type{Element} */ (node),\n i,\n oldVProps[i],\n newVProps[i],\n isSVG\n )\n const cb = newVProps.onupdate\n if (cb != null) {\n LIFECYCLE.push(function() {\n cb(node, oldVProps, newVProps)\n })\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, keyed, 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 if (getKey((oldVKid = oldVKids[oldHead++])) == null) {\n removeElement(node, oldVKid)\n }\n }\n\n for (let i in keyed) {\n if (newKeyed[i] == null) {\n removeElement(node, keyed[i])\n }\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('./vnode').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 * @typedef {Object<string, any>} Message\n * @prop {string} type\n * @prop {any} [data]\n * @typedef {(msg?: Message) => Message} Send\n */\n/**\n * @typedef {any} State Simple or complex types for application state.\n */\n/**\n * @typedef {State | void} InitResult Return result of program init method.\n */\n/**\n * @typedef {Object<string, any>} Program A program to run.\n * @prop {() => InitResult} init Method to set up initial state.\n * @prop {(state: State, send?: Send) => void} view Method to present the current application state.\n * @prop {(state: State, msg?: Message, send?: Send) => any} update Method to capture messages sent from view or subscriptions. According to the message, an action will transform application state and pass it the the program view method.\n * @prop {(getState: () => State, send: Send) => void} [subscriptions] Method to run effects when the program starts. These run independently from the rest of the program.\n * @prop {(getState: () => State, send: Send) => void} [subs] Shortcut for subscriptions.\n * @prop {(state: State) => void} [done] Method to do clean up when shutting down a program.\n * @prop {Send} [send] A static send function for dispatching message to a program. Used with routers and in composition.\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 {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 {Message} message\n *\n */\n function send(message) {\n if (isRunning) {\n return updateView(update(state, message, send))\n }\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 function updateView(update) {\n if (update) {\n state = update\n } else if (init) {\n state = init()\n }\n if (subscriptions && isFirstRun) {\n if (typeof subscriptions === 'function') subscriptions(getState, send)\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 if (isRunning) {\n isRunning = false\n if (done) {\n done(state)\n }\n }\n }\n}\n","const hasOwnProperty = Object.prototype.hasOwnProperty\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 function match(tag, handlers) {\n if (!tag.type) {\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 return\n }\n return ((tag, context) => {\n const type = tag.type\n const match = hasOwnProperty.call(handlers, type) && handlers[type]\n return match(tag.data, context)\n })(tag)\n }\n\n let idx = 0\n while (idx < types.length) {\n const type = types[idx]\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} MessagesUnion\n */\nexport function union(...types) {\n const { variants, match } = createUnion(types)\n variants.match = match\n return variants\n}\n","/**\n * @typedef {import('./runtime').Send} Send\n * @typedef {import('./runtime').Message} Message\n * @typedef {Object} State\n * @typedef {() => State} GetState\n * @typedef {(getState: GetState, send: Send) => any} Effect\n */\n/**\n * Function to batch effects together.\n * @param {...Effect} effects\n * @return {(getState: GetState, send: Send) => any} Function\n */\nexport const batchEffects = (...effects) => (getState, send) =>\n effects.map(effect => effect && effect(getState, send))\n","/**\n * Returns a group of sibling elements for inclusion in another JSX tag.\n * @typedef {import('./vnode').VNode} VNode\n * @typedef {import('./vnode').Props} Props\n * @typedef {import('./vnode').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","mergeObjects","a","b","Object","assign","listener","event","handlers","patchProperty","prop","oldValue","newValue","isSVG","i","style","setProperty","slice","toLowerCase","addEventListener","removeEventListener","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","oldVProps","newVProps","oldVKids","newVKids","oldHead","newHead","oldTail","newTail","onupdate","keyed","newKeyed","recycleNode","nodeType","nodeName","prototype","map","call","patch","vdom","parentNode","render","target","oldTarget","querySelector","msg","console","error","run","program","send","message","isRunning","updateView","update","state","init","subscriptions","isFirstRun","getState","view","subs","done","hasOwnProperty","createUnion","types","variants","create","idx","data","match","tag","context","dir","union","batchEffects","effects","effect","Fragment"],"mappings":"GAIaA,CAAAA,CAAa,CAAG,EAYhBC,CAAS,CAAG,EAkBZC,CAAY,CAAG,GAMfC,CAAW,CAAG,GAMdC,CAAS,CAAG,GCbzB,QAAgBC,CAAAA,CAAhB,CACEC,CADF,CAEEC,CAFF,CAGEC,CAHF,CAIEC,CAJF,CAOE,IAFAC,CAAAA,CAEA,wDAFM,IAEN,CADAC,CACA,wDADO,IACP,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,ECjDb,QAASa,CAAAA,CAAT,CAAWR,CAAX,CAAiBC,CAAjB,CAAqC,CAC1CA,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CAAAA,CAAI,CAAGiH,CAAG,CAACjH,IADO,CAElBgH,CAAK,CAAGP,CAAc,CAAC1B,IAAf0B,CAAoBlF,CAApBkF,CAA8BzG,CAA9ByG,GAAuClF,CAAQ,CAACvB,CAAD,CAFrC,OAGjBgH,CAAAA,CAAK,CAACC,CAAG,CAACF,IAAL,CAAWG,CAAX,CAHP,CAAA,EAIJD,CAJI,CATqB,EAE1BzB,OAAO,CAACC,KAARD,CACE,yGADFA,CAF0B,CAK1BA,OAAO,CAACC,KAARD,CAAc,2BAAdA,CAL0B,KAM1BA,CAAAA,OAAO,CAAC2B,GAAR3B,CAAYyB,CAAZzB,CAN0B,EAuBvB,EAYT,QAAgB4B,CAAAA,CAAhB,EAAgC,4BAAPT,CAAO,MAAA,EAAA,cAAPA,CAAO,EAAA,CAAPA,aAAAA,OACKD,CAAW,CAACC,CAAD,EAA/BC,CADsB,GACtBA,SAAUI,CADY,GACZA,YAClBJ,CAAAA,CAAQ,CAACI,KAATJ,CAAiBI,EACVJ,KCpCIS,CAAAA,CAAY,CAAG,sCAAIC,CAAJ,MAAA,EAAA,cAAIA,CAAJ,EAAA,CAAIA,aAAAA,OAAY,CAACjB,CAAD,CAAWT,CAAX,GAC1C0B,CAAO,CAACxC,GAARwC,CAAYC,CAAM,EAAIA,CAAM,EAAIA,CAAM,CAAClB,CAAD,CAAWT,CAAX,CAAtC0B,CADK,ECmBME,CAAQ,CAAG,CAACvH,CAAD,CAAQC,CAAR,GACtBW,KAAK,CAACC,OAAND,CAAcZ,CAAdY,GAAwB,CAACX,CAAzBW,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'\n\n/**\n * @typedef {Object<string, any> | {}} Props\n * @prop {Children} Props.children\n * @prop {(Element) => void} [Props.onmount]\n * @prop {(Element, Object, Object) => void} [Props.onupdate]\n * @prop {(Element, (State) => void) => void} [Props.onunmount]\n */\n/**\n * @typedef {VNode[]} Children\n */\n/**\n * @typedef {string | number | Function} Type\n * @typedef {number | string | null} Key\n * @typedef {Object | {}} VNode\n * @prop {Type} type\n * @prop {Props} props\n * @prop {Children} children\n * @prop {Element} node\n * @prop {Key} [key]\n * @prop {number} flag\n */\n/**\n * Create a virtual node with the provided properties.\n * @param {string | Function} type\n * @param {Props} props\n * @param {Children} children\n * @param {Element} node\n * @param {string | number | null} key\n * @param {number} [flag]\n * @return {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 {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('./vnode').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 if (props.children) {\n if (tempBox.length <= 0) {\n tempBox.push(props.children)\n }\n delete props.children\n }\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 if (typeof type === 'function') {\n return type(props, childNodes)\n } else {\n return createVNode(type, props, childNodes, null, key)\n }\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('./vnode').Props} Props\n * @param {Props} oldVProps\n * @param {Props} newVProps\n */\nfunction areNotEqual(oldVProps, newVProps) {\n return JSON.stringify(oldVProps) !== JSON.stringify(newVProps)\n}\n\n/**\n * @typedef {import('./vnode').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 function mergeObjects(a, b) {\n return Object.assign({}, a, b)\n}\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 if (i[0] === '-') {\n node[prop].setProperty(i, style)\n } else {\n node[prop][i] = style\n }\n }\n } else if (prop[0] === 'o' && prop[1] === 'n') {\n if (\n !((node['handlers'] || (node['handlers'] = {}))[\n (prop = prop.slice(2).toLowerCase())\n ] = newValue)\n ) {\n node.removeEventListener(prop, listener)\n } else if (!oldValue) {\n node.addEventListener(prop, listener)\n }\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 = /** @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 */\nfunction getKey(vnode) {\n return vnode == null ? null : vnode.key\n}\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 if (cb != null) {\n cb(vnode.node)\n }\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 if (cb != null) {\n cb(vnode.node, remove)\n } else {\n remove()\n }\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 if (\n (i === 'value' || i === 'selected' || i === 'checked'\n ? node[i]\n : oldVProps[i]) !== newVProps[i]\n ) {\n patchProperty(\n /** @type{Element} */ (node),\n i,\n oldVProps[i],\n newVProps[i],\n isSVG\n )\n const cb = newVProps.onupdate\n if (cb != null) {\n if (areNotEqual(oldVProps, newVProps)) {\n LIFECYCLE.push(function() {\n cb(node, oldVProps, newVProps)\n })\n }\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, keyed, 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 if (getKey((oldVKid = oldVKids[oldHead++])) == null) {\n removeElement(node, oldVKid)\n }\n }\n\n for (let i in keyed) {\n if (newKeyed[i] == null) {\n removeElement(node, keyed[i])\n }\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('./vnode').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 * @typedef {Object<string, any>} Message\n * @prop {string} type\n * @prop {any} [data]\n * @typedef {(msg?: Message) => Message} Send\n */\n/**\n * @typedef {any} State Simple or complex types for application state.\n */\n/**\n * @typedef {State | void} InitResult Return result of program init method.\n */\n/**\n * @typedef {Object<string, any>} Program A program to run.\n * @prop {() => InitResult} init Method to set up initial state.\n * @prop {(state: State, send?: Send) => void} view Method to present the current application state.\n * @prop {(state: State, msg?: Message, send?: Send) => any} update Method to capture messages sent from view or subscriptions. According to the message, an action will transform application state and pass it the the program view method.\n * @prop {(getState: () => State, send: Send) => void} [subscriptions] Method to run effects when the program starts. These run independently from the rest of the program.\n * @prop {(getState: () => State, send: Send) => void} [subs] Shortcut for subscriptions.\n * @prop {(state: State) => void} [done] Method to do clean up when shutting down a program.\n * @prop {Send} [send] A static send function for dispatching message to a program. Used with routers and in composition.\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 {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 {Message} message\n *\n */\n function send(message) {\n if (isRunning) {\n return updateView(update(state, message, send))\n }\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 function updateView(update) {\n if (update) {\n state = update\n } else if (init) {\n state = init()\n }\n if (subscriptions && isFirstRun) {\n if (typeof subscriptions === 'function') subscriptions(getState, send)\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 if (isRunning) {\n isRunning = false\n if (done) {\n done(state)\n }\n }\n }\n}\n","const hasOwnProperty = Object.prototype.hasOwnProperty\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 function match(tag, handlers) {\n if (!tag.type) {\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 return\n }\n return ((tag, context) => {\n const type = tag.type\n const match = hasOwnProperty.call(handlers, type) && handlers[type]\n return match(tag.data, context)\n })(tag)\n }\n\n let idx = 0\n while (idx < types.length) {\n const type = types[idx]\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} MessagesUnion\n */\nexport function union(...types) {\n const { variants, match } = createUnion(types)\n variants.match = match\n return variants\n}\n","/**\n * @typedef {import('./runtime').Send} Send\n * @typedef {import('./runtime').Message} Message\n * @typedef {Object} State\n * @typedef {() => State} GetState\n * @typedef {(getState: GetState, send: Send) => any} Effect\n */\n/**\n * Function to batch effects together.\n * @param {...Effect} effects\n * @return {(getState: GetState, send: Send) => any} Function\n */\nexport const batchEffects = (...effects) => (getState, send) =>\n effects.map(effect => effect && effect(getState, send))\n","/**\n * Returns a group of sibling elements for inclusion in another JSX tag.\n * @typedef {import('./vnode').VNode} VNode\n * @typedef {import('./vnode').Props} Props\n * @typedef {import('./vnode').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","toLowerCase","addEventListener","removeEventListener","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","prototype","map","call","patch","vdom","parentNode","render","target","oldTarget","querySelector","msg","console","error","run","program","send","message","isRunning","updateView","update","state","init","subscriptions","isFirstRun","getState","view","subs","done","hasOwnProperty","createUnion","types","variants","create","idx","data","match","tag","context","dir","union","batchEffects","effects","effect","Fragment"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AM1BA,CAAAA,OAAO,CAAC2B,GAAR3B,CAAYyB,CAAZzB,CAN0B,EAuBvB,EAYT,QAAgB4B,CAAAA,CAAhB,EAAgC,4BAAPT,CAAO,MAAA,EAAA,cAAPA,CAAO,EAAA,CAAPA,aAAAA,OACKD,CAAW,CAACC,CAAD,EAA/BC,CADsB,GACtBA,SAAUI,CADY,GACZA,YAClBJ,CAAAA,CAAQ,CAACI,KAATJ,CAAiBI,EACVJ,KCpCIS,CAAAA,CAAY,CAAG,sCAAIC,CAAJ,MAAA,EAAA,cAAIA,CAAJ,EAAA,CAAIA,aAAAA,OAAY,CAACjB,CAAD,CAAWT,CAAX,GAC1C0B,CAAO,CAACxC,GAARwC,CAAYC,CAAM,EAAIA,CAAM,EAAIA,CAAM,CAAClB,CAAD,CAAWT,CAAX,CAAtC0B,CADK,ECmBME,CAAQ,CAAG,CAAC1H,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 4c74648..2ec5756 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "@composi/core", - "version": "2.5.7", + "version": "2.5.8", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index cf00b0c..3740d9d 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@composi/core", - "version": "2.5.7", + "version": "2.5.8", "description": "A JavaScript library for creating websites, PWAs and hybrid apps.", "main": "src/index.js", "module": "dist/composi-core.mjs", diff --git a/src/vdom.js b/src/vdom.js index 458edce..0e48639 100644 --- a/src/vdom.js +++ b/src/vdom.js @@ -1,6 +1,16 @@ import { RECYCLED_NODE, TEXT_NODE, EMPTY_OBJECT, LIFECYCLE } from './constants' import { createTextVNode, createVNode } from './vnode' +/** + * Determin whether the old and new props are identical. + * @typedef {import('./vnode').Props} Props + * @param {Props} oldVProps + * @param {Props} newVProps + */ +function areNotEqual(oldVProps, newVProps) { + return JSON.stringify(oldVProps) !== JSON.stringify(newVProps) +} + /** * @typedef {import('./vnode').VNode} VNode */ @@ -203,9 +213,11 @@ function patchNode(parent, node, oldVNode, newVNode, isSVG) { ) const cb = newVProps.onupdate if (cb != null) { - LIFECYCLE.push(function() { - cb(node, oldVProps, newVProps) - }) + if (areNotEqual(oldVProps, newVProps)) { + LIFECYCLE.push(function() { + cb(node, oldVProps, newVProps) + }) + } } } } diff --git a/test/render.html b/test/render.html index 0742e95..00713d7 100755 --- a/test/render.html +++ b/test/render.html @@ -222,12 +222,20 @@ <h1>Mocha Tests - Composi h & render Functions</h1> describe('Component should execute thee lifecycle hooks', function () { let componentDidMount = false let componentDidUpdate = false + let secondUpdate = false let componentDidUnmount = false - function LifecycleTest(data) { + const state = { + checkUpdate: false, + items: [1, 2] + } + function LifecycleTest(state) { function testMount() { componentDidMount = true } - function testUpdate() { + function testUpdate(el, oldProps, newProps) { + if (JSON.stringify(oldProps) === JSON.stringify(newProps)) { + secondUpdate = true + } componentDidUpdate = true } function testUnmount(el, done) { @@ -236,16 +244,16 @@ <h1>Mocha Tests - Composi h & render Functions</h1> } function listItems(items) { console.log(items) - return items.map(item => html`<li onunmount=${(el, done) => testUnmount(el, done)}>${item}</li>`) + return items.map(item => html`<li onunmount=${testUnmount}>${item}</li>`) } return html` - <ul onmount=${() => testMount()} onupdate=${() => testUpdate()}> - ${listItems(data)} + <ul checkUpdate={state.checkUpdate} onmount=${testMount} onupdate=${testUpdate}> + ${listItems(state.items)} </ul> ` } let lifecyleTest = document.querySelector('#lifecycle') - render(LifecycleTest([1, 2]), lifecyleTest) + render(LifecycleTest(state), lifecyleTest) it('Functional component should execute "onmount" when it is mounted', function (done) { setTimeout(() => { @@ -256,18 +264,26 @@ <h1>Mocha Tests - Composi h & render Functions</h1> }) it('Functional component should execute "onupdate" when it is updated', function (done) { setTimeout(() => { - render(LifecycleTest([1, 2, 3]), lifecyleTest) - expect(componentDidUpdate).to.be.true - expect(lifecyleTest.children.length).to.equal(3) + state.checkUpdate = true + render(LifecycleTest(state), lifecyleTest) + expect(secondUpdate).to.be.false }, 1500) done() }) + it('Functional component should not execute "onupdate" when its props are the same', function (done) { + setTimeout(() => { + render(LifecycleTest(state), lifecyleTest) + expect(componentDidUpdate).to.be.true + }, 1800) + done() + }) it('List component\'s list items should execute "onunmount" when they are deleted', function (done) { setTimeout(() => { - render(LifecycleTest([1]), lifecyleTest) + state.items = [1] + render(LifecycleTest(state), lifecyleTest) expect(componentDidUnmount).to.be.true expect(lifecyleTest.children.length).to.equal(1) - }, 2000) + }, 2300) done() }) })