From f1179a2d63ceeda4e69ab8897fdbcfb5f45ba4ed Mon Sep 17 00:00:00 2001 From: Robert Biggs Date: Thu, 17 Oct 2019 11:58:04 -0700 Subject: [PATCH] Update for changes to state in runtime. 1. Runtime init function now return state without square brackes. 2. Update actions now return state without square brackets. 3. Test updated for changes to runtime. --- CHANGELOG.md | 10 +++ dist/composi-core.js | 2 +- dist/composi-core.js.gz | Bin 2558 -> 2319 bytes dist/composi-core.js.map | 2 +- dist/composi-core.mjs | 2 +- dist/composi-core.mjs.gz | Bin 2478 -> 2246 bytes dist/composi-core.mjs.map | 2 +- package-lock.json | 32 ++------ package.json | 2 +- src/runtime.js | 29 +++---- test/h.html | 2 +- test/runtime.html | 163 ++++++++++++++++++-------------------- 12 files changed, 112 insertions(+), 134 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e028968..0ee77e5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,15 @@ # composi/core Changelog +## 2.5.0 (October, 21, 2019) + +### src/runtime.js + +* Updated how the runtime works. Now `init` does not require brackets for state. Just return the state you want to use. Same for `actions`--just return the new state. This means that you can no longer execute an optional effect in the `init` method to run at startup. If you want to execute an effect at startup, use the `subscriptions` method. That's what it's for. Similarly, you can no longer return an effect with state in an action. Instead send a message for another action before returning state. + +### test/runtime.html + +* Updated runtime test to handle changes to how state get returned now. + ## 2.0.1 (October, 15, 2019) ### src/render.js diff --git a/dist/composi-core.js b/dist/composi-core.js index 1e51984..63c390a 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(;u<=x;)b.insertBefore(g(s[u++],v,j),(m=r[t])&&m.node);else if(u>x)for(;t<=w;)k(b,r[t++]);else{var i,z,A;for(i=t,z={},A={};i<=w;i++)null!=(n=r[i].key)&&(z[n]=r[i]);for(;u<=x;){if(n=h(m=r[t]),o=h(s[u]),A[n]||null!=o&&o===h(r[t+1])){null==n&&k(b,m),t++;continue}null==o||0===c.flag?(null==n&&(l(b,m&&m.node,m,s[u],j),u++),t++):(n===o?(l(b,m.node,m,s[u],j),A[o]=!0,t++):null==(a=z[o])?l(b,m&&m.node,null,s[u],j):(l(b,b.insertBefore(a.node,m&&m.node),a,s[u],j),A[o]=!0),u++)}for(;t<=w;)null==h(m=r[t++])&&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(),t,Array.prototype.map.call(a.childNodes,m),a,null,0)}function n(a,b){!a.vdom&&b.props.onmount&&v.push(function(){b.props.onmount(a)});for(var c=l(a.parentNode,a,a.vdom||m(a),b).vdom=b;0a&&a.type,d=(a,b)=>(d,e)=>{var f=c(d),g=w.call(a,f)&&a[f];return g?g(d.data,e):b(e)},e=0,f=function(){var c=a[e];b[c]=a=>({type:c,data:a}),e++};e=f.length&&f.push(d.children),delete d.children);0d;return a.send=b,c(d),()=>{k&&(k=!1,j&&j(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(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;0a&&a.type,d=(a,b)=>(d,e)=>{var f=c(d),g=s.call(a,f)&&a[f];return g?g(d.data,e):b(e)},e=0,f=function(){var c=a[e];b[c]=a=>({type:c,data:a}),e++};e=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 e7411fe028d3f52180880e9068176ef5be5f1a8d..cd9c1a73ef01e4d9f9fd25fc55ab7303669c535c 100644 GIT binary patch literal 2319 zcmV+q3GntGiwFP!000006RlWFbK|%XzVEM~m@O4hhH2Teb0G~Yp2_TK9;xgk7nN!U zBteN1Maq0gmSz3-d=2m+dz|EwgG~~Tetg~ip&^zuc~qxG&XfrG(JjK2j%ruR`mohS z;^@b1QP$OX>^6C%J1(ve;HW zOk1W|TOG0zNyLv>VE##w-%5U--=g z%~MsCE^>A}37Q-hYl4oj^p+}*GhJ3Q<&lYVcD^iWVNAq=AJc@nunu9AArEv0+-az) z51BTD$cWdulJKM`8HHf!q}IlS+nA)1T#zz(er{i8%lXuGeR>A&C5c?lCiAJ9g>$dc z_1^)VF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ma?av%fV~)=(2C%V;{SZ6OIt$cj^gQw z{_O`tOqrR<=J$O$3?4q_2XVn0!(}4iaKQUuOa;}zYDNDLgRh20o(mJ?w|ChxySiNf z!PepyZDyw1%sg0M-GF-yw92|z0^f8r^LP2Fz)mN>JC1f+G$}p({BC<8k_xurR6g~nqA;?|&9BLm zp}wxnk?+4YED;9?oWa{~d`^%{iLhL0)a7_Es97M^sC7jrT#J{VG~NOoooMz4S(a66 znL=d!6+;?1!fNHpO7a?l71W_2-~RIZub%Cj(6w#f48nC@t|qY}!WDtKCdTRJu~YTo zv+mkpJAewGMZ*LJF6cV}P+zStnX;Om$~sh?g@}C06O~wd*(@yk$76i9zamMivZ)H? zDGdu>|J;8nxsFjkEsYh6o);(+3n-6r1Yoe>Im=ka8bJZ9p_&F3&-y^Eq}BdMIWR_B zTe-nD0ZyAq*sQhGGbUf+qEEs^R-|jW1!RP22&c@gp7rA~Ie&G}B~nrvM|GvR{H}BP zDMx#3Gt`BcA%ZzM(tYunL{rHDPpAyt5@^T4JOt>(!A*D`LNTROFd=K`Gtj4oJ~Q+g z=y~oq1$^>G%wZ>ITN)V(lp)t}PLTFKCK3htu(Q%X8ft)=R4UNn+6Ma3!T-&Qc7a54>@4eW|o(|}A{#|`A(P=#DO z&Kj!#Jy^Lb!TAz=ha8sQgHzFcH0cOjE>H^Z%B~+^B~*aUW5Og~9KhKC76)j_x1Qd#G)%F~M | {}} Props\n * @property {Children} Props.children\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 * @property {Type} VNode.type\n * @property {Props} VNode.props\n * @property {Children} VNode.children\n * @property {Element} VNode.node\n * @property {Key} [VNode.key]\n * @property {number} VNode.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\nexport function mergeObjects(a, b) {\n return Object.assign({}, a, b)\n}\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\nfunction createNode(vnode, LIFECYCLE, isSVG) {\n const node =\n vnode.flag === TEXT_NODE\n ? document.createTextNode(vnode.type)\n : (isSVG = isSVG || vnode.type === 'svg') // eslint-disable-line no-cond-assign\n ? document.createElementNS('http://www.w3.org/2000/svg', vnode.type)\n : document.createElement(vnode.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(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 = node)\n}\n\nfunction getKey(vnode) {\n return vnode == null ? null : vnode.key\n}\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\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\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(node, i, oldVProps[i], newVProps[i], isSVG)\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\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 */\nfunction createUnion(types) {\n const variants = Object.create(null)\n let checkTag = x => x && x.type\n\n const matcher = (handlers, catchAll) => {\n return (tag, context) => {\n const tagType = checkTag(tag)\n const match = hasOwnProperty.call(handlers, tagType) && handlers[tagType]\n return match ? match(tag.data, context) : catchAll(context)\n }\n }\n\n function match(tag, handlers, catchAll) {\n return matcher(handlers, catchAll)(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 * 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 */\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 * @property {string} Message.type\n * @property {any} [Message.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} Effect A function to run at startup.\n * @typedef {[State, Effect] | any[] | void} InitResult Return result of program init method.\n */\n/**\n * @typedef {Object<string, any>} Program A program to run.\n * @prop {() => InitResult} Program.init Method to set up initial state for app and optionally run an effect.\n * @prop {(state: State, send?: Send) => void} Program.view Method to present the current application state.\n * @prop {(state: State, msg?: Message, send?: Send) => any} Program.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} [Program.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} [Program.subs] Shortcut for subscriptions.\n * @prop {(state: State) => void} [Program.done] Method to do clean up when shutting down a program.\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, effect\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, effect] = update\n } else if (init && init.length) {\n ;[state, effect] = init\n if (subscriptions && isFirstRun) {\n if (typeof subscriptions === 'function') subscriptions(getState, send)\n isFirstRun = false\n }\n } else {\n state = []\n }\n if (effect) {\n effect(state, send)\n }\n view(state, send)\n }\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 * Function to batch effects together.\n * @param {...Function} effects\n * @return {Function} Function\n */\nexport const batchEffects = (...effects) => (state, send) =>\n effects.map(effect => effect && effect(state, 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","onmount","push","len","length","appendChild","getKey","removeChildren","cb","ondestroy","removeElement","parent","remove","removeChild","onunmount","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","checkTag","x","matcher","catchAll","tag","context","tagType","match","hasOwnProperty","data","idx","tempBox","isArray","target","oldTarget","querySelector","msg","console","error","program","send","message","isRunning","updateView","update","state","effect","init","subscriptions","isFirstRun","getState","view","subs","done","effects"],"mappings":"2LA8BO,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,CAD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BT,CAAAA,CAAQ,CAACS,KAATT,CAAiBS,EACVT,kBKlCmB,sCAAIoC,CAAJ,MAAA,EAAA,cAAIA,CAAJ,EAAA,CAAIA,aAAAA,OAAY,CAACT,CAAD,CAAQL,CAAR,GAC1Cc,CAAO,CAAC7C,GAAR6C,CAAYR,CAAM,EAAIA,CAAM,EAAIA,CAAM,CAACD,CAAD,CAAQL,CAAR,CAAtCc,CADK,aC0BiB,CAAC3H,CAAD,CAAQC,CAAR,GACtB2E,KAAK,CAACyB,OAANzB,CAAc5E,CAAd4E,GAAwB,CAAC3E,CAAzB2E,CAAoC5E,CAApC4E,CAA4C3E"} \ 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 * @property {Children} Props.children\n */\n/**\n * @typedef {VNode[]} Children\n */\n/**\n * @typedef {string | number | Function} Type\n * @typedef {number | string | null} Key\n * @typedef {Object.<string, any>} VNode\n * @property {Type} VNode.type\n * @property {Props} VNode.props\n * @property {Children} VNode.children\n * @property {Element} VNode.node\n * @property {Key} [VNode.key]\n * @property {number} VNode.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\nexport function mergeObjects(a, b) {\n return Object.assign({}, a, b)\n}\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\nfunction createNode(vnode, LIFECYCLE, isSVG) {\n const node =\n vnode.flag === TEXT_NODE\n ? document.createTextNode(vnode.type)\n : (isSVG = isSVG || vnode.type === 'svg') // eslint-disable-line no-cond-assign\n ? document.createElementNS('http://www.w3.org/2000/svg', vnode.type)\n : document.createElement(vnode.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(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 = node)\n}\n\nfunction getKey(vnode) {\n return vnode == null ? null : vnode.key\n}\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\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\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(node, i, oldVProps[i], newVProps[i], isSVG)\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\nexport function patch(node, vdom) {\n // if (JSON.stringify(vdom) === JSON.stringify(node.vdom)) return\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 */\nfunction createUnion(types) {\n const variants = Object.create(null)\n let checkTag = x => x && x.type\n\n const matcher = (handlers, catchAll) => {\n return (tag, context) => {\n const tagType = checkTag(tag)\n const match = hasOwnProperty.call(handlers, tagType) && handlers[tagType]\n return match ? match(tag.data, context) : catchAll(context)\n }\n }\n\n function match(tag, handlers, catchAll) {\n return matcher(handlers, catchAll)(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 * 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 */\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 * @property {string} Message.type\n * @property {any} [Message.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} Program.init Method to set up initial state.\n * @prop {(state: State, send?: Send) => void} Program.view Method to present the current application state.\n * @prop {(state: State, msg?: Message, send?: Send) => any} Program.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} [Program.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} [Program.subs] Shortcut for subscriptions.\n * @prop {(state: State) => void} [Program.done] Method to do clean up when shutting down a program.\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 * Function to batch effects together.\n * @param {...Function} effects\n * @return {Function} Function\n */\nexport const batchEffects = (...effects) => (state, send) =>\n effects.map(effect => effect && effect(state, 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","onmount","push","len","length","appendChild","getKey","removeChildren","cb","ondestroy","removeElement","parent","remove","removeChild","onunmount","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","checkTag","x","matcher","catchAll","tag","context","tagType","match","hasOwnProperty","data","idx","tempBox","isArray","target","oldTarget","querySelector","msg","console","error","program","send","message","isRunning","updateView","update","state","init","subscriptions","isFirstRun","getState","view","subs","done","effects","effect"],"mappings":"2LA8BO,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,ICpDb,QAASO,CAAAA,CAAT,CAAsBC,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AD,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,WJlEK,UAAyB,4BAAP5B,CAAO,MAAA,EAAA,cAAPA,CAAO,EAAA,CAAPA,aAAAA,OACKD,CAAW,CAACC,CAAD,EAA/BC,CADsB,GACtBA,SAAUS,CADY,GACZA,YAClBT,CAAAA,CAAQ,CAACS,KAATT,CAAiBS,EACVT,kBKlCmB,sCAAImC,CAAJ,MAAA,EAAA,cAAIA,CAAJ,EAAA,CAAIA,aAAAA,OAAY,CAACR,CAAD,CAAQL,CAAR,GAC1Ca,CAAO,CAAC5C,GAAR4C,CAAYC,CAAM,EAAIA,CAAM,EAAIA,CAAM,CAACT,CAAD,CAAQL,CAAR,CAAtCa,CADK,aC0BiB,CAAC1H,CAAD,CAAQC,CAAR,GACtB2E,KAAK,CAACyB,OAANzB,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 769c96b..9c66624 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.flag===b?document.createTextNode(a.type):(d=d||"svg"===a.type)?document.createElementNS("http://www.w3.org/2000/svg",a.type):document.createElement(a.type),f=a.props;for(var g in f.onmount&&c.push(function(){f.onmount(e)}),f)l(e,g,null,f[g],d);for(var h=0,j=a.children.length;h<j;h++)e.appendChild(m(a.children[h],c,d));return a.node=e}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,b){return v(a)||w(a,b)||x()}function v(a){if(Array.isArray(a))return a}function w(a,b){var c=[],d=!0,e=!1,f=void 0;try{for(var g,h=a[Symbol.iterator]();!(d=(g=h.next()).done)&&(c.push(g.value),!(b&&c.length===b));d=!0);}catch(a){e=!0,f=a}finally{try{d||null==h["return"]||h["return"]()}finally{if(e)throw f}}return c}function x(){throw new TypeError("Invalid attempt to destructure non-iterable instance")}function y(a){function b(a){if(k)return c(h(d,a,b))}function c(a){if(a){var c=u(a,2);d=c[0],e=c[1]}else if(f&&f.length){var h=u(f,2);d=h[0],e=h[1],i&&l&&("function"==typeof i&&i(m,b),l=!1)}else d=[];e&&e(d,b),g(d,b)}var d,e,f=a.init(),g=a.view,h=a.update,i=a.subscriptions||a.subs,j=a.done,k=!0,l=!0,m=()=>d;return a.send=b,c(d),()=>{k&&(k=!1,j&&j(d))}}var z=Object.prototype.hasOwnProperty;function A(a){for(var b=Object.create(null),c=a=>a&&a.type,d=(a,b)=>(d,e)=>{var f=c(d),g=z.call(a,f)&&a[f];return g?g(d.data,e):b(e)},e=0,f=function(){var c=a[e];b[c]=a=>({type:c,data:a}),e++};e<a.length;)f();return{variants:b,match:function(a,b,c){return d(b,c)(a)}}}function B(){for(var a=arguments.length,b=Array(a),c=0;c<a;c++)b[c]=arguments[c];var d=A(b),e=d.variants,f=d.match;return e.match=f,e}var C=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))},D=(a,b)=>Array.isArray(a)&&!b?a:b;export{i as h,t as render,y as run,B as union,C as batchEffects,D 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(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.flag===b?document.createTextNode(a.type):(d=d||"svg"===a.type)?document.createElementNS("http://www.w3.org/2000/svg",a.type):document.createElement(a.type),f=a.props;for(var g in f.onmount&&c.push(function(){f.onmount(e)}),f)l(e,g,null,f[g],d);for(var h=0,j=a.children.length;h<j;h++)e.appendChild(m(a.children[h],c,d));return a.node=e}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=a=>a&&a.type,d=(a,b)=>(d,e)=>{var f=c(d),g=v.call(a,f)&&a[f];return g?g(d.data,e):b(e)},e=0,f=function(){var c=a[e];b[c]=a=>({type:c,data:a}),e++};e<a.length;)f();return{variants:b,match:function(a,b,c){return d(b,c)(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 84e78f7cb1613118d0d4cd092e2ba351a966f6e9..97ea20231dd83ce2af30d03cd50a120628925dd2 100644 GIT binary patch literal 2246 zcmV;%2s!s3iwFP!000006RlWHbK|%Xz3;D}lr0uehH2Tmb0G~Y_GI=nJCn+8a#5*j zKob0rC{jaGl4V){J+A?NXgrhTl7mGOXf(QCcRw_|SGA+$OoZ|m5y{h8#B#9|8b3j@ zE2B2AN+)4Tgd!3#KkXr|<*)auPInt!wvAWlGHo;09Yz+vE+<m%t2}mQ^UG1c+!cjL z<h%d6`rQv#zq6}@TDQBpJhjKI_LbPy)wc0rT9y}atxG==Wff~b7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`qH`Z(P|5OL9Dz%wjA%C>3VE+|$aai}jYnFks2=S{mx|33U z7%0y7go?(s2*J>}5ncMT%=T9fJtv<*K5_Dylg}V8a^Eii|2J-=n911&HsG#4dC#3@ z`eh(QPi9~rW>WjO*y6+KN^N{z<_N4v@w(5=ff6Bb9f!#A+U%l6*ZG$A!j;Vp*xsBn zL98jH1^wGd#^qx?w%rY~9!#LY(t@T=beydz1y{bm!YJt7wpg;e8;=B>sphvs+21e6 z-+Z3F?8v)y?uug1Oin$zd{lH#v~3!)m%<_+8C{uSguVJoYg8&fJDOMMEU|*Fx&2{d zPY{4Wzs$@cy0IVtl)P{HPi(g^%P?B#C2h>yk3eXqv2><z%`xxZT|)Dq2C7a5k|qVY zDqH%oXhStJHn;YcKOSz3zUZ8|`qk)}jZmnsfAxuE&klg(F4PYy)Hs`+p~G)IdfDAm zo<Pj-Fb;Z~;A$LLt9nd~`;>_=Hf}H1So}XMar@9U7=eoD6h^D^NH=dgh7kPJNAoQM z;#MBb)hr6l>$a-fQ|^J-Gttt+v9CDV_gyKT>19{KZt+5|5qb3?Nsvm7_=!gPBk&Ub s>Gt-|UQ_LAZGORx6MX*9fBY=FBj<*WoM5wR$kadm8#Sjz3A7Xd0KR4Og8%>k diff --git a/dist/composi-core.mjs.map b/dist/composi-core.mjs.map index 26782af..3fd9f3b 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 * @property {Children} Props.children\n */\n/**\n * @typedef {VNode[]} Children\n */\n/**\n * @typedef {string | number | Function} Type\n * @typedef {number | string | null} Key\n * @typedef {Object.<string, any>} VNode\n * @property {Type} VNode.type\n * @property {Props} VNode.props\n * @property {Children} VNode.children\n * @property {Element} VNode.node\n * @property {Key} [VNode.key]\n * @property {number} VNode.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\nexport function mergeObjects(a, b) {\n return Object.assign({}, a, b)\n}\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\nfunction createNode(vnode, LIFECYCLE, isSVG) {\n const node =\n vnode.flag === TEXT_NODE\n ? document.createTextNode(vnode.type)\n : (isSVG = isSVG || vnode.type === 'svg') // eslint-disable-line no-cond-assign\n ? document.createElementNS('http://www.w3.org/2000/svg', vnode.type)\n : document.createElement(vnode.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(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 = node)\n}\n\nfunction getKey(vnode) {\n return vnode == null ? null : vnode.key\n}\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\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\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(node, i, oldVProps[i], newVProps[i], isSVG)\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\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 * @property {string} Message.type\n * @property {any} [Message.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} Effect A function to run at startup.\n * @typedef {[State, Effect] | any[] | void} InitResult Return result of program init method.\n */\n/**\n * @typedef {Object<string, any>} Program A program to run.\n * @prop {() => InitResult} Program.init Method to set up initial state for app and optionally run an effect.\n * @prop {(state: State, send?: Send) => void} Program.view Method to present the current application state.\n * @prop {(state: State, msg?: Message, send?: Send) => any} Program.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} [Program.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} [Program.subs] Shortcut for subscriptions.\n * @prop {(state: State) => void} [Program.done] Method to do clean up when shutting down a program.\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, effect\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, effect] = update\n } else if (init && init.length) {\n ;[state, effect] = init\n if (subscriptions && isFirstRun) {\n if (typeof subscriptions === 'function') subscriptions(getState, send)\n isFirstRun = false\n }\n } else {\n state = []\n }\n if (effect) {\n effect(state, send)\n }\n view(state, send)\n }\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 */\nfunction createUnion(types) {\n const variants = Object.create(null)\n let checkTag = x => x && x.type\n\n const matcher = (handlers, catchAll) => {\n return (tag, context) => {\n const tagType = checkTag(tag)\n const match = hasOwnProperty.call(handlers, tagType) && handlers[tagType]\n return match ? match(tag.data, context) : catchAll(context)\n }\n }\n\n function match(tag, handlers, catchAll) {\n return matcher(handlers, catchAll)(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 * 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 */\nexport function union(...types) {\n const { variants, match } = createUnion(types)\n variants.match = match\n return variants\n}\n","/**\n * Function to batch effects together.\n * @param {...Function} effects\n * @return {Function} Function\n */\nexport const batchEffects = (...effects) => (state, send) =>\n effects.map(effect => effect && effect(state, 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","onmount","len","appendChild","getKey","removeChildren","cb","ondestroy","removeElement","parent","remove","removeChild","onunmount","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","effect","init","subscriptions","isFirstRun","getState","view","subs","done","hasOwnProperty","createUnion","types","variants","create","checkTag","x","matcher","catchAll","tag","context","tagType","match","data","idx","union","batchEffects","effects","Fragment"],"mappings":"GAIaA,CAAAA,CAAa,CAAG,EAYhBC,CAAS,CAAG,EAkBZC,CAAY,CAAG,GAMfC,CAAW,CAAG,GAMdC,CAAS,CAAG,GChBzB,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,EC9Cb,QAASa,CAAAA,CAAT,CAAWR,CAAX,CAAiBC,CAAjB,CAAqC,CAC1CA,CAAK,CAAGA,CAAK,EAAI,EADyB,QAEtCE,CAAAA,EACEM,CAAO,CAAG,GACVC,CAAU,CAAG,sBAJaR,CAAU,MAAA,UAAA,cAAVA,CAAU,IAAA,CAAVA,aAAAA,CAAU,OAKtCS,CAAAA,CAAM,CAAGT,CAAQ,CAACS,MALoB,CAMpCP,CAAG,CAAGH,CAAK,CAACG,GANwB,CAQxB,CAAXO,CAAAA,CAAM,EAR6B,EAQrBF,CAAO,CAACG,IAARH,CAAaP,CAAQ,CAACS,CAAD,CAArBF,EARqB,IAUtCR,CAAK,CAACC,QAVgC,GAWlB,CAAlBO,EAAAA,CAAO,CAACE,MAX4B,EAYtCF,CAAO,CAACG,IAARH,CAAaR,CAAK,CAACC,QAAnB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,CAAD,CAARgH,CAAiBU,CAAI,GAAK,CAAE1H,IAAF,CAAEA,CAAF,CAAQ0H,KAAAA,CAAR,CAAL,EACrBC,CAAG,GApBqB,CAiBnBA,CAAG,CAAGZ,CAAK,CAACpG,MAjBO,YAuBnB,CAAEqG,QAAF,CAAEA,CAAF,CAAYS,eAXJH,EAAK/F,EAAU8F,EAAU,OAC/BD,CAAAA,CAAO,CAAC7F,CAAD,CAAW8F,CAAX,CAAPD,CAA4BE,CAA5BF,EAUF,EAOT,QAAgBQ,CAAAA,CAAhB,EAAgC,4BAAPb,CAAO,MAAA,EAAA,cAAPA,CAAO,EAAA,CAAPA,aAAAA,OACKD,CAAW,CAACC,CAAD,EAA/BC,CADsB,GACtBA,SAAUS,CADY,GACZA,YAClBT,CAAAA,CAAQ,CAACS,KAATT,CAAiBS,EACVT,KClCIa,CAAAA,CAAY,CAAG,sCAAIC,CAAJ,MAAA,EAAA,cAAIA,CAAJ,EAAA,CAAIA,aAAAA,OAAY,CAAC1B,CAAD,CAAQL,CAAR,GAC1C+B,CAAO,CAAC7C,GAAR6C,CAAYzB,CAAM,EAAIA,CAAM,EAAIA,CAAM,CAACD,CAAD,CAAQL,CAAR,CAAtC+B,CADK,EC0BMC,CAAQ,CAAG,CAAC9H,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 * @property {Children} Props.children\n */\n/**\n * @typedef {VNode[]} Children\n */\n/**\n * @typedef {string | number | Function} Type\n * @typedef {number | string | null} Key\n * @typedef {Object.<string, any>} VNode\n * @property {Type} VNode.type\n * @property {Props} VNode.props\n * @property {Children} VNode.children\n * @property {Element} VNode.node\n * @property {Key} [VNode.key]\n * @property {number} VNode.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\nexport function mergeObjects(a, b) {\n return Object.assign({}, a, b)\n}\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\nfunction createNode(vnode, LIFECYCLE, isSVG) {\n const node =\n vnode.flag === TEXT_NODE\n ? document.createTextNode(vnode.type)\n : (isSVG = isSVG || vnode.type === 'svg') // eslint-disable-line no-cond-assign\n ? document.createElementNS('http://www.w3.org/2000/svg', vnode.type)\n : document.createElement(vnode.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(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 = node)\n}\n\nfunction getKey(vnode) {\n return vnode == null ? null : vnode.key\n}\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\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\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(node, i, oldVProps[i], newVProps[i], isSVG)\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\nexport function patch(node, vdom) {\n // if (JSON.stringify(vdom) === JSON.stringify(node.vdom)) return\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 * @property {string} Message.type\n * @property {any} [Message.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} Program.init Method to set up initial state.\n * @prop {(state: State, send?: Send) => void} Program.view Method to present the current application state.\n * @prop {(state: State, msg?: Message, send?: Send) => any} Program.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} [Program.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} [Program.subs] Shortcut for subscriptions.\n * @prop {(state: State) => void} [Program.done] Method to do clean up when shutting down a program.\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 */\nfunction createUnion(types) {\n const variants = Object.create(null)\n let checkTag = x => x && x.type\n\n const matcher = (handlers, catchAll) => {\n return (tag, context) => {\n const tagType = checkTag(tag)\n const match = hasOwnProperty.call(handlers, tagType) && handlers[tagType]\n return match ? match(tag.data, context) : catchAll(context)\n }\n }\n\n function match(tag, handlers, catchAll) {\n return matcher(handlers, catchAll)(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 * 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 */\nexport function union(...types) {\n const { variants, match } = createUnion(types)\n variants.match = match\n return variants\n}\n","/**\n * Function to batch effects together.\n * @param {...Function} effects\n * @return {Function} Function\n */\nexport const batchEffects = (...effects) => (state, send) =>\n effects.map(effect => effect && effect(state, 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","onmount","len","appendChild","getKey","removeChildren","cb","ondestroy","removeElement","parent","remove","removeChild","onunmount","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","checkTag","x","matcher","catchAll","tag","context","tagType","match","data","idx","union","batchEffects","effects","effect","Fragment"],"mappings":"GAIaA,CAAAA,CAAa,CAAG,EAYhBC,CAAS,CAAG,EAkBZC,CAAY,CAAG,GAMfC,CAAW,CAAG,GAMdC,CAAS,CAAG,GChBzB,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,EC9Cb,QAASa,CAAAA,CAAT,CAAWR,CAAX,CAAiBC,CAAjB,CAAqC,CAC1CA,CAAK,CAAGA,CAAK,EAAI,EADyB,QAEtCE,CAAAA,EACEM,CAAO,CAAG,GACVC,CAAU,CAAG,sBAJaR,CAAU,MAAA,UAAA,cAAVA,CAAU,IAAA,CAAVA,aAAAA,CAAU,OAKtCS,CAAAA,CAAM,CAAGT,CAAQ,CAACS,MALoB,CAMpCP,CAAG,CAAGH,CAAK,CAACG,GANwB,CAQxB,CAAXO,CAAAA,CAAM,EAR6B,EAQrBF,CAAO,CAACG,IAARH,CAAaP,CAAQ,CAACS,CAAD,CAArBF,EARqB,IAUtCR,CAAK,CAACC,QAVgC,GAWlB,CAAlBO,EAAAA,CAAO,CAACE,MAX4B,EAYtCF,CAAO,CAACG,IAARH,CAAaR,CAAK,CAACC,QAAnBO,CAZsC,OAcjCR,CAAAA,CAAK,CAACC,QAd2B,EAiBlB,CAAjBO,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D,CAAW6F,CAAX,CAAPD,CAA4BE,CAA5BF,EAUF,EAOT,QAAgBQ,CAAAA,CAAhB,EAAgC,4BAAPb,CAAO,MAAA,EAAA,cAAPA,CAAO,EAAA,CAAPA,aAAAA,OACKD,CAAW,CAACC,CAAD,EAA/BC,CADsB,GACtBA,SAAUS,CADY,GACZA,YAClBT,CAAAA,CAAQ,CAACS,KAATT,CAAiBS,EACVT,KClCIa,CAAAA,CAAY,CAAG,sCAAIC,CAAJ,MAAA,EAAA,cAAIA,CAAJ,EAAA,CAAIA,aAAAA,OAAY,CAACzB,CAAD,CAAQL,CAAR,GAC1C8B,CAAO,CAAC5C,GAAR4C,CAAYC,CAAM,EAAIA,CAAM,EAAIA,CAAM,CAAC1B,CAAD,CAAQL,CAAR,CAAtC8B,CADK,EC0BME,CAAQ,CAAG,CAAC9H,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 7d2f2be..1b6e714 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "@composi/core", - "version": "2.0.1", + "version": "2.5.0", "lockfileVersion": 1, "requires": true, "dependencies": { @@ -904,6 +904,11 @@ "integrity": "sha512-JhkNsBm8n4Z3rU1Sl2ivPX+Gd3dBcxLUdhLrn3Yok33uBGmoT0wNspXjOgToPxFqDAHHAWj83uj7MSLEJCLpxQ==", "dev": true }, + "@composi/merge-objects": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/@composi/merge-objects/-/merge-objects-1.3.0.tgz", + "integrity": "sha512-IetmC+GBaIBA27o1AqBhmL4VOfad/cwvptCMcUL6HZg69vzXSyi5IwjWSDj9pzJVOfyVeO05rNGEsa3c9k9aAg==" + }, "@types/estree": { "version": "0.0.39", "resolved": "https://registry.npmjs.org/@types/estree/-/estree-0.0.39.tgz", @@ -1115,31 +1120,6 @@ } } }, - "babel-eslint": { - "version": "10.0.3", - "resolved": "https://registry.npmjs.org/babel-eslint/-/babel-eslint-10.0.3.tgz", - "integrity": "sha512-z3U7eMY6r/3f3/JB9mTsLjyxrv0Yb1zb8PCWCLpguxfCzBIZUwy23R1t/XKewP+8mEN2Ck8Dtr4q20z6ce6SoA==", - "dev": true, - "requires": { - "@babel/code-frame": "^7.0.0", - "@babel/parser": "^7.0.0", - "@babel/traverse": "^7.0.0", - "@babel/types": "^7.0.0", - "eslint-visitor-keys": "^1.0.0", - "resolve": "^1.12.0" - }, - "dependencies": { - "resolve": { - "version": "1.12.0", - "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.12.0.tgz", - "integrity": "sha512-B/dOmuoAik5bKcD6s6nXDCjzUKnaDvdkRyAk6rsmsKLipWj4797iothd7jmmUhWTfinVMU+wc56rYKsit2Qy4w==", - "dev": true, - "requires": { - "path-parse": "^1.0.6" - } - } - } - }, "babel-helper-evaluate-path": { "version": "0.5.0", "resolved": "https://registry.npmjs.org/babel-helper-evaluate-path/-/babel-helper-evaluate-path-0.5.0.tgz", diff --git a/package.json b/package.json index 19548d6..6f9c4db 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@composi/core", - "version": "2.0.1", + "version": "2.5.0", "description": "A JavaScript library for creating websites, PWAs and hybrid apps.", "main": "src/index.js", "module": "dist/composi-core.mjs", diff --git a/src/runtime.js b/src/runtime.js index 8ae4751..fe7875b 100644 --- a/src/runtime.js +++ b/src/runtime.js @@ -8,12 +8,11 @@ * @typedef {any} State Simple or complex types for application state. */ /** - * @typedef {(State) => void} Effect A function to run at startup. - * @typedef {[State, Effect] | any[] | void} InitResult Return result of program init method. + * @typedef {State | void} InitResult Return result of program init method. */ /** * @typedef {Object<string, any>} Program A program to run. - * @prop {() => InitResult} Program.init Method to set up initial state for app and optionally run an effect. + * @prop {() => InitResult} Program.init Method to set up initial state. * @prop {(state: State, send?: Send) => void} Program.view Method to present the current application state. * @prop {(state: State, msg?: Message, send?: Send) => any} Program.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. * @prop {(getState: () => State, send: Send) => void} [Program.subscriptions] Method to run effects when the program starts. These run independently from the rest of the program. @@ -50,12 +49,12 @@ * @return {() => void} Function to terminate runtime. */ export function run(program) { - let init = program.init() + let init = program.init const view = program.view const update = program.update const subscriptions = program.subscriptions || program.subs const done = program.done - let state, effect + let state let isRunning = true let isFirstRun = true const getState = () => state @@ -80,27 +79,21 @@ export function run(program) { /** * Handle changes to state and executing effects. - * @param {any[]} update + * @param {any} update * @return {void} undefined */ function updateView(update) { if (update) { - ;[state, effect] = update - } else if (init && init.length) { - ;[state, effect] = init - if (subscriptions && isFirstRun) { - if (typeof subscriptions === 'function') subscriptions(getState, send) - isFirstRun = false - } - } else { - state = [] + state = update + } else if (init) { + state = init() } - if (effect) { - effect(state, send) + if (subscriptions && isFirstRun) { + if (typeof subscriptions === 'function') subscriptions(getState, send) + isFirstRun = false } view(state, send) } - updateView(state) /** diff --git a/test/h.html b/test/h.html index 4b1a218..4624b25 100644 --- a/test/h.html +++ b/test/h.html @@ -27,7 +27,7 @@ <h1>Mocha Tests - Composi h Function</h1> <script src="https://unpkg.com/chai@4.1.2/chai.js"></script> <script>mocha.setup('bdd')</script> <script type='module'> - import {h, render, run, union} from 'https://unpkg.com/@composi/core/dist/composi-core.mjs?module' + import {h, render, run, union} from '/dist/composi-core.mjs?module' let expect = chai.expect const h1 = h('h1') diff --git a/test/runtime.html b/test/runtime.html index 44e3b9e..7aaac27 100755 --- a/test/runtime.html +++ b/test/runtime.html @@ -39,7 +39,7 @@ <h1 id="subscription-test3"></h1> <script src="https://unpkg.com/chai@4.1.2/chai.js"></script> <script>mocha.setup('bdd')</script> <script type='module'> - import {h, render, run, union, batchEffects} from 'https://unpkg.com/@composi/core/dist/composi-core.mjs?module' + import {h, render, run, union, batchEffects} from '/dist/composi-core.mjs?module' import htm from 'https://unpkg.com/htm/dist/htm.mjs?module' const html = htm.bind(h) let expect = chai.expect @@ -70,9 +70,9 @@ <h1 id="subscription-test3"></h1> } const program = { init() { - return ['World'] + return 'World' }, - update(state, msg) { + update(state, msg, send) { }, view(state, send) { @@ -99,13 +99,13 @@ <h1 id="subscription-test3"></h1> const program = { init() { - return ['no message'] + return 'no message' }, update(state, msg) { switch (msg.type) { case 'click': state = 'Button was clicked' - return [state] + return state break } }, @@ -139,13 +139,13 @@ <h1 id="subscription-test3"></h1> const program = { init() { - return ['no message'] + return 'no message' }, update(state, msg) { switch (msg.type) { case 'click': state = msg.data - return [state] + return state break } }, @@ -167,38 +167,12 @@ <h1 id="subscription-test3"></h1> }) }) - describe('Should be able to run effect at startup.', () => { - it('effect should run at startup.', done => { - let effectResult = false - function effect() { - effectResult = true - } - const program = { - init() { - return [0, effect] - }, - update() { - return [state] - }, - view() { - return - } - } - run(program) - setTimeout(() => { - expect(effectResult).to.equal(true) - }) - done() - }) - }) - - describe('Should be able to stop program.', () => { it('Capture program refrence and end program.', done => { let setIntervalID let isRunning = false let count = 0 - function effect() { + function effect(getState, send) { setIntervalID = setInterval(() => { count += 1 isRunning = true @@ -206,10 +180,17 @@ <h1 id="subscription-test3"></h1> } const program = { init() { - return [null, effect] + return null + }, + update() { + + }, + view() { + + }, + subscriptions(getState, send) { + return effect(getState, send) }, - update() { }, - view() { }, done() { expect(isRunning).to.equal(true) clearInterval(setIntervalID) @@ -238,13 +219,13 @@ <h1 id="subscription-test3"></h1> let taggedEffectFired = false const program = { init() { - return ['no message'] + return 'no message' }, update(state, msg) { return Msg3.match(msg, { 'click': () => { taggedEffectFired = true - return [state] + return state } }) }, @@ -277,13 +258,13 @@ <h1 id="subscription-test3"></h1> let taggedEffectFired = '' const program = { init() { - return ['no message'] + return 'no message' }, update(state, msg) { return Msg4.match(msg, { 'click': message => { taggedEffectFired = message - return [state] + return state } }) }, @@ -323,16 +304,21 @@ <h1 id="subscription-test3"></h1> }, 100) } const effects = batchEffects(hello, secondEffect, countDown) - function effect() { - effects(effect => effect) - } + const program = { init() { - return ['World', effect] + return 'World' + }, + view() { + + }, + update() { + }, - update() { }, - view() { } + subscriptions(getState, send) { + return effects(getState, send) + } } const endProgram = run(program) it('At startup all three batched effects should run', function (done) { @@ -353,13 +339,13 @@ <h1 id="subscription-test3"></h1> } const program = { init() { - return ['first'] + return 'first' }, view(state) { render(View(state), '#send-test') }, update(state, msg) { - if (msg) return [msg] + if (msg) return msg } } run(program) @@ -383,14 +369,14 @@ <h1 id="subscription-test3"></h1> let canSendMsg = false const program = { init() { - return [state] + return state }, view(state) { render(View(state), '#test-effect') }, update(state, msg, send) { if (msg.type === 'changing-state') { - return [effect(state, send)] + return effect(state, send) } else if (msg.type === 'can-send-msg') { canSendMsg = true } @@ -421,10 +407,10 @@ <h1 id="subscription-test3"></h1> } const program = { init() { - return [0] + return 0 }, update(state, msg, send) { - return [msg.data] + return msg.data }, view() { return @@ -457,14 +443,14 @@ <h1 id='subscription-test3'>${state}</h1> } const program = { init() { - return [state] + return state }, view(state, send) { return render(Component({ state, send }), test) }, update(state, msg, send) { if (msg.type === 'update-state') { - return [msg.value] + return msg.value } }, subscriptions(getState, send) { @@ -488,10 +474,10 @@ <h1 id='subscription-test3'>${state}</h1> } const program = { init() { - return [1] + return 1 }, update() { - return [state] + return state }, view() { return @@ -520,14 +506,14 @@ <h1 id='subscription-test3'>${state}</h1> } function hello(getState, send) { - send({type: 'result1', value: 'Hello World!'}) + setTimeout(() => send({type: 'result1', value: 'Hello World!'})) } const secondEffect = (getState, send) => { - send({type: 'result2', value: 'Second effect ran!'}) + setTimeout(() => send({type: 'result2', value: 'Second effect ran!'})) } const countDown = (getState, send) => { const id = setInterval(() => { - const {count} = getState() + const count = getState().count if (count === 0) { clearInterval(id) } else { @@ -550,7 +536,7 @@ <h1 id='subscription-test3'>${state}</h1> } const program = { init() { - return [state] + return state }, view(state, send) { return render(Component({state}), test) @@ -558,13 +544,13 @@ <h1 id='subscription-test3'>${state}</h1> update(state, msg, send) { if (msg.type === 'result1') { state.result1 = msg.value - return [state] + return state } else if (msg.type === 'result2') { state.result2 = msg.value - return [state] + return state } else if (msg.type === 'reduce') { state.count -= 1 - return [state] + return state } }, subscriptions(getState, send) { @@ -579,7 +565,7 @@ <h1 id='subscription-test3'>${state}</h1> expect(children[0].textContent).to.equal('Hello World!') expect(children[1].textContent).to.equal('Second effect ran!') expect(children[2].textContent).to.equal('0') - }, 1000) + }, 3000) done() }) }) @@ -593,14 +579,14 @@ <h1 id='subscription-test3'>${state}</h1> function effect1(getState, send) { const count = getState().count - send({type: 'update-state-1', value: parseInt(count) + 1}) + setTimeout(() => send({ type: 'update-state-1', value: parseInt(count) + 1 }), 500) } function effect2(getState, send) { const count = getState().count - setTimeout(() => send({type: 'update-state-2', value: parseInt(count) + 2}), 2000) + setTimeout(() => send({ type: 'update-state-2', value: parseInt(count) + 2 }), 3000) } const batchedEffects = batchEffects(effect1, effect2) - function subTest({state, send}) { + function subTest({ state, send }) { return html` <div> <p>${state.count}</p> @@ -608,42 +594,51 @@ <h1 id='subscription-test3'>${state}</h1> </div> ` } + + function actions(state, msg, send) { + if (msg.type === 'update-state-1') { + state.messageWasSent = 'true' + state.count = msg.value + return state + } else if (msg.type === 'update-state-2') { + state.messageWasSent = 'true' + state.count = msg.value + return state + } + } + const program = { init() { - return [state] + return state }, view(state, send) { - return render(subTest({state, send}), test) + return render(subTest({ state, send }), test) }, - update(state, msg) { - if (msg.type === 'update-state-1') { - state.count = msg.value - return [state] - } else if (msg.type === 'update-state-2') { - state.messageWasSent = 'true' - state.count = msg.value - return [state] - } + update(state, msg, send) { + return actions(state, msg, send) }, subscriptions(getState, send) { return batchedEffects(getState, send) } } run(program) - it('First effect should update state to 2.', function() { - expect(test.children[0].textContent).to.equal('2') + + it('First effect should update state to 2.', function(done) { + setTimeout(() => expect(test.children[0].textContent).to.equal('2'), 600) + done() }) - it('Second effect should update state to 4.', + it('Second effect should update state to 3.', function(done) { - setTimeout(() => expect(test.children[0].textContent).to.equal('4'), 2000) + setTimeout(() => expect(test.children[0].textContent).to.equal('3'), 3000) done() }) it('Second effect should send message to update action, setting messageWasSent to true.', function(done) { - setTimeout(() => expect(test.children[1].textContent).to.equal('true'), 2500) + setTimeout(() => expect(test.children[1].textContent).to.equal('true'), 3000) done() }) }) + mocha.run() </script> </body>