jails-js 5.7.0 → 5.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/jails.js +1 -1
- package/dist/jails.js.map +1 -1
- package/package.json +2 -2
- package/src/component.ts +23 -27
- package/src/template-system.ts +4 -4
- package/src/transpile.ts +1 -9
- package/src/utils/idiomorph.ts +879 -0
package/dist/jails.js
CHANGED
@@ -1,2 +1,2 @@
|
|
1
|
-
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).jails={})}(this,(function(e){"use strict";const t=new DOMParser;const n=(e,t,n)=>{var r,o;null==(r=t.parentNode)||r.insertBefore(e,t),null==(o=t.parentNode)||o.insertBefore(n,t.nextSibling)},r=document.createElement("textarea"),o=e=>(r.innerHTML=e,r.value),i=e=>requestAnimationFrame?requestAnimationFrame(e):setTimeout(e,1e3/60),a=e=>JSON.parse(JSON.stringify(e)),s=e=>{var t,n,r,o=e.attributes;if(o)for(t=o.length-1;t>=0;t-=1)"function"==typeof e[r=o[t].name]&&(e[r]=null);if(o=e.childNodes)for(n=o.length,t=0;t<n;t+=1)s(e.childNodes[t])},l=(e,t)=>{try{return e()}catch(n){return t||""}},c={tags:["${","}"]};function u(e,r){const i=function(e,r,o,i){const a=new RegExp(`\\${r.tags[0]}(.+?)\\${r.tags[1]}`,"g"),s=t.parseFromString(e.replace(/<\/?template[^>]*>/g,""),"text/html"),l=s.querySelector(i.localName),c=Object.keys(o).toString();return l.querySelectorAll(c).forEach((e=>{const t=e.cloneNode();e.replaceWith(t)})),s.querySelectorAll("[html-for], [html-if], [html-inner], [html-class], [html-model]").forEach((e=>{const t=e.getAttribute("html-foreach"),r=e.getAttribute("html-for"),o=e.getAttribute("html-if"),i=e.getAttribute("html-inner"),a=e.getAttribute("html-class"),s=r||t;if(s){const t=r?"html-for":"html-foreach",o=s.match(/(.*)\sin\s(.*)/)||"",i=o[1],a=o[2];e.removeAttribute(t),e.setAttribute("scope","");const l=document.createElement("script");l.dataset.scope="",l.type="text/html",l.text="%%_= $scope _%%",e.appendChild(l);const c=document.createTextNode(`%%_(function(){ var $index = 0; for(var $key in safe(function(){ return ${a} }) ){ var ${i} = ${a}[$key]; var $scope = JSON.stringify({ '${i}':${i}, $index: $index, $key:$key }); _%%`),u=document.createTextNode("%%_ $index++; } })() _%%");n(c,e,u)}if(o){e.removeAttribute("html-if");const t=document.createTextNode(`%%_ if ( safe(function(){ return ${o} }) ){ _%%`),r=document.createTextNode("%%_ } _%%");n(t,e,r)}i&&(e.removeAttribute("html-inner"),e.innerHTML=`%%_=${i}_%%`),a&&(e.removeAttribute("html-class"),e.className=(e.className+` %%_=${a}_%%`).trim())})),s.body.innerHTML.replace(a,"%%_=$1_%%").replace(/html-(allowfullscreen|async|autofocus|autoplay|checked|controls|default|defer|disabled|formnovalidate|inert|ismap|itemscope|loop|multiple|muted|nomodule|novalidate|open|playsinline|readonly|required|reversed|selected)=\"(.*?)\"/g,"%%_if(safe(function(){ return $2 })){_%%$1%%_}_%%").replace(/html-(.*?)=\"(.*?)\"/g,((e,t,n)=>"key"===t||"model"===t||"scope"==t?e:n?`${t}="%%_=safe(function(){ return ${n=n.replace(/^{|}$/g,"")} })_%%"`:e))}(e.outerHTML,c,r,e),a=JSON.stringify(i);return new Function("$element","safe",`\n\t\tvar $data = this;\n\t\twith( $data ){\n\t\t\tvar output=${a.replace(/%%_=(.+?)_%%/g,(function(e,t){return'"+safe(function(){return '+o(t)+';})+"'})).replace(/%%_(.+?)_%%/g,(function(e,t){return'";'+o(t)+'\noutput+="'}))};return output;\n\t\t}\n\t`)}const d=(e,t,n,r)=>{[].concat(e.matches&&e.matches(t)?e:[]).concat(Array.from(e.querySelectorAll(t))).reverse().forEach((e=>{e.querySelectorAll("template").forEach((e=>d(e.content,t,n,r))),f(e,n,r)}))},f=(e,t,n)=>{if(!e.getAttribute("tplid")){const r="xxxxxxxx".replace(/[xy]/g,(e=>{const t=8*Math.random()|0;return("x"==e?t:3&t|8).toString(8)}));e.setAttribute("tplid",r);const o=e.localName;if(o in n&&n[o].module.template){const i=n[o].module.template();i.constructor===Promise?(e.__template=i,i.then((o=>{e.innerHTML=o,t[r]=u(e,n)}))):e.innerHTML=i}t[r]=u(e,n)}},m={},h={},p=(e,t)=>{h[e]=Object.assign({},h[e],t),m[e]&&m[e].forEach((e=>e(t)))},b=(e,t)=>(m[e]=m[e]||[],m[e].push(t),e in h&&t(h[e]),()=>{m[e]=m[e].filter((e=>e!=t))});var v;var _="http://www.w3.org/1999/xhtml",g="undefined"==typeof document?void 0:document,y=!!g&&"content"in g.createElement("template"),A=!!g&&g.createRange&&"createContextualFragment"in g.createRange();function N(e){return e=e.trim(),y?function(e){var t=g.createElement("template");return t.innerHTML=e,t.content.childNodes[0]}(e):A?function(e){return v||(v=g.createRange()).selectNode(g.body),v.createContextualFragment(e).childNodes[0]}(e):function(e){var t=g.createElement("body");return t.innerHTML=e,t.childNodes[0]}(e)}function E(e,t){var n,r,o=e.nodeName,i=t.nodeName;return o===i||(n=o.charCodeAt(0),r=i.charCodeAt(0),n<=90&&r>=97?o===i.toUpperCase():r<=90&&n>=97&&i===o.toUpperCase())}function T(e,t,n){e[n]!==t[n]&&(e[n]=t[n],e[n]?e.setAttribute(n,""):e.removeAttribute(n))}var x={OPTION:function(e,t){var n=e.parentNode;if(n){var r=n.nodeName.toUpperCase();"OPTGROUP"===r&&(r=(n=n.parentNode)&&n.nodeName.toUpperCase()),"SELECT"!==r||n.hasAttribute("multiple")||(e.hasAttribute("selected")&&!t.selected&&(e.setAttribute("selected","selected"),e.removeAttribute("selected")),n.selectedIndex=-1)}T(e,t,"selected")},INPUT:function(e,t){T(e,t,"checked"),T(e,t,"disabled"),e.value!==t.value&&(e.value=t.value),t.hasAttribute("value")||e.removeAttribute("value")},TEXTAREA:function(e,t){var n=t.value;e.value!==n&&(e.value=n);var r=e.firstChild;if(r){var o=r.nodeValue;if(o==n||!n&&o==e.placeholder)return;r.nodeValue=n}},SELECT:function(e,t){if(!t.hasAttribute("multiple")){for(var n,r,o=-1,i=0,a=e.firstChild;a;)if("OPTGROUP"===(r=a.nodeName&&a.nodeName.toUpperCase()))a=(n=a).firstChild;else{if("OPTION"===r){if(a.hasAttribute("selected")){o=i;break}i++}!(a=a.nextSibling)&&n&&(a=n.nextSibling,n=null)}e.selectedIndex=o}}};function C(){}function S(e){if(e)return e.getAttribute&&e.getAttribute("id")||e.id}var $,O=($=function(e,t){var n,r,o,i,a=t.attributes;if(11!==t.nodeType&&11!==e.nodeType){for(var s=a.length-1;s>=0;s--)r=(n=a[s]).name,o=n.namespaceURI,i=n.value,o?(r=n.localName||r,e.getAttributeNS(o,r)!==i&&("xmlns"===n.prefix&&(r=n.name),e.setAttributeNS(o,r,i))):e.getAttribute(r)!==i&&e.setAttribute(r,i);for(var l=e.attributes,c=l.length-1;c>=0;c--)r=(n=l[c]).name,(o=n.namespaceURI)?(r=n.localName||r,t.hasAttributeNS(o,r)||e.removeAttributeNS(o,r)):t.hasAttribute(r)||e.removeAttribute(r)}},function(e,t,n){if(n||(n={}),"string"==typeof t)if("#document"===e.nodeName||"HTML"===e.nodeName||"BODY"===e.nodeName){var r=t;(t=g.createElement("html")).innerHTML=r}else t=N(t);else 11===t.nodeType&&(t=t.firstElementChild);var o=n.getNodeKey||S,i=n.onBeforeNodeAdded||C,a=n.onNodeAdded||C,s=n.onBeforeElUpdated||C,l=n.onElUpdated||C,c=n.onBeforeNodeDiscarded||C,u=n.onNodeDiscarded||C,d=n.onBeforeElChildrenUpdated||C,f=n.skipFromChildren||C,m=n.addChild||function(e,t){return e.appendChild(t)},h=!0===n.childrenOnly,p=Object.create(null),b=[];function v(e){b.push(e)}function y(e,t){if(1===e.nodeType)for(var n=e.firstChild;n;){var r=void 0;t&&(r=o(n))?v(r):(u(n),n.firstChild&&y(n,t)),n=n.nextSibling}}function A(e,t,n){!1!==c(e)&&(t&&t.removeChild(e),u(e),y(e,n))}function T(e){a(e);for(var t=e.firstChild;t;){var n=t.nextSibling,r=o(t);if(r){var i=p[r];i&&E(t,i)?(t.parentNode.replaceChild(i,t),O(i,t)):T(t)}else T(t);t=n}}function O(e,t,n){var r=o(t);if(r&&delete p[r],!n){if(!1===s(e,t))return;if($(e,t),l(e),!1===d(e,t))return}"TEXTAREA"!==e.nodeName?function(e,t){var n,r,a,s,l,c=f(e,t),u=t.firstChild,d=e.firstChild;e:for(;u;){for(s=u.nextSibling,n=o(u);!c&&d;){if(a=d.nextSibling,u.isSameNode&&u.isSameNode(d)){u=s,d=a;continue e}r=o(d);var h=d.nodeType,b=void 0;if(h===u.nodeType&&(1===h?(n?n!==r&&((l=p[n])?a===l?b=!1:(e.insertBefore(l,d),r?v(r):A(d,e,!0),r=o(d=l)):b=!1):r&&(b=!1),(b=!1!==b&&E(d,u))&&O(d,u)):3!==h&&8!=h||(b=!0,d.nodeValue!==u.nodeValue&&(d.nodeValue=u.nodeValue))),b){u=s,d=a;continue e}r?v(r):A(d,e,!0),d=a}if(n&&(l=p[n])&&E(l,u))c||m(e,l),O(l,u);else{var _=i(u);!1!==_&&(_&&(u=_),u.actualize&&(u=u.actualize(e.ownerDocument||g)),m(e,u),T(u))}u=s,d=a}!function(e,t,n){for(;t;){var r=t.nextSibling;(n=o(t))?v(n):A(t,e,!0),t=r}}(e,d,r);var y=x[e.nodeName];y&&y(e,t)}(e,t):x.TEXTAREA(e,t)}!function e(t){if(1===t.nodeType||11===t.nodeType)for(var n=t.firstChild;n;){var r=o(n);r&&(p[r]=n),e(n),n=n.nextSibling}}(e);var w,M,L=e,k=L.nodeType,U=t.nodeType;if(!h)if(1===k)1===U?E(e,t)||(u(e),L=function(e,t){for(var n=e.firstChild;n;){var r=n.nextSibling;t.appendChild(n),n=r}return t}(e,(w=t.nodeName,(M=t.namespaceURI)&&M!==_?g.createElementNS(M,w):g.createElement(w)))):L=t;else if(3===k||8===k){if(U===k)return L.nodeValue!==t.nodeValue&&(L.nodeValue=t.nodeValue),L;L=t}if(L===t)u(e);else{if(t.isSameNode&&t.isSameNode(L))return;if(O(L,t,h),b)for(var j=0,H=b.length;j<H;j++){var P=p[b[j]];P&&A(P,P.parentNode,!1)}}return!h&&L!==e&&e.parentNode&&(L.actualize&&(L=L.actualize(e.ownerDocument||g)),e.parentNode.replaceChild(L,e)),L});const w="CustomEvent"in window&&"function"==typeof window.CustomEvent?(e,t)=>new CustomEvent(e,t):(e,t)=>{const n=document.createEvent("CustomEvent");return n.initCustomEvent(e,!0,!0,t),n},M=(e,t)=>function(n){const r=this,o=n.detail||{};e.__events[t].forEach((e=>{e.handler.apply(r,[n].concat(o.args))}))},L=(e,t)=>{e.__events[t]&&e.__events[t].listener&&(e.removeEventListener(t,e.__events[t].listener,"focus"==t||"blur"==t||"mouseenter"==t||"mouseleave"==t),delete e.__events[t])},k=(e,t,n)=>function(r){const o=this,i=r.detail||{};let a=r.target;for(;a&&(a.matches(t)&&(r.delegateTarget=a,n.apply(o,[r].concat(i.args))),a!==e);)a=a.parentNode},U=(e,t,n,r)=>{if(e.__events=e.__events||{},e.__events[t]=e.__events[t]||[],!e.__events[t].length){const n=M(e,t);e.addEventListener(t,n,"focus"==t||"blur"==t||"mouseenter"==t||"mouseleave"==t),e.__events[t].listener=n}n.call?e.__events[t].push({handler:n,callback:n}):e.__events[t].push({handler:k(e,n,r),callback:r})},j=(e,t,n)=>{if(n&&e.__events[t]&&e.__events[t].length){var r=e.__events[t];e.__events[t]=e.__events[t].filter((function(e){return e.callback!=n})),e.__events[t].listener=r.listener,e.__events[t].length||L(e,t)}else L(e,t)},H=(e,t,n)=>{e.dispatchEvent(w(t,{bubbles:!0,detail:n}))};const P=e=>({main:e=>e,unmount:e=>e,onupdate:e=>e,view:e.view?e.view:e=>e}),R=e=>({onNodeAdded:F,onElUpdated:F,onBeforeElChildrenUpdated:q,onBeforeElUpdated:q}),q=e=>{if("html-static"in e.attributes)return!1},F=e=>(1!==e.nodeType||("scope"in e.attributes&&e.querySelectorAll("[tplid]").forEach((t=>{if(!t.___scope___){const n=e.lastElementChild;t.___scope___="scope"in n.dataset?new Function(`return ${n.text}`)():{}}})),!e.getAttribute("tplid")))&&e;function B(e,t,n,r){return class extends HTMLElement{constructor(){super();const{base:o,options:s}=function(e,{module:t,dependencies:n,templates:r,components:o}){const s=P(t),c=new Function(`return ${e.getAttribute("html-model")||"{}"}`)(),u=Object.keys(o).toString();d(e,u,r,o);const f=e.getAttribute("tplid"),m=f?r[f]:null,h={data:t.model?a(t.model):{}};h.data=Object.assign(h.data,c);const v={template:m,elm:e,dependencies:n,publish:p,subscribe:b,main(e){s.main=e},unmount(e){s.unmount=e},onupdate(e){s.onupdate=e},on(t,n,r){U(e,t,n,r)},off(t,n){j(e,t,n)},trigger(t,n,r){n.constructor===String?Array.from(e.querySelectorAll(n)).forEach((e=>H(e,t,{args:r}))):H(e,t,{args:n})},emit:(...t)=>{H(e,t.shift(),{args:t})},state:{set(e){if(e.constructor===Function){const t=a(h.data);e(t),v.render(t)}else v.render(e);return new Promise((e=>i((t=>i((()=>e(h.data)))))))},get:()=>a(h.data),getRaw:()=>h.data},render(t=h.data){if(!document.body.contains(e))return;h.data=Object.assign(h.data,t);const n=a(h.data),o=r[f].call(Object.assign(s.view(n),e.___scope___),e,l);O(e,o,R()),i((n=>{Array.from(e.querySelectorAll("[tplid]")).forEach((e=>{const n=Object.assign(e.base.state.getRaw(),t);e.options.onupdate(n),e.base.render(n)}))}))},innerHTML(t,n){const r=n?t:e,o=(new DOMParser).parseFromString(r.outerHTML,"text/html"),a=n||t;o.body.firstElementChild.innerHTML=a,i((e=>O(r,o.body.innerHTML,R())))}};return{base:v,options:s}}(this,{module:e,dependencies:t,templates:n,components:r});this.base=o,this.options=s,this.returns=e.default(o)}connectedCallback(){if(this.base.render(),this.__template&&this.__template.constructor===Promise)this.__template.then((e=>{if(this.base&&this.options.main){const e=this.options.main(this.base);e&&e.length&&e.forEach((e=>e(this.base)))}}));else if(this.returns&&this.returns.constructor===Promise)this.returns.then((e=>{if(this.base&&this.options.main){const e=this.options.main(this.base);e&&e.length&&e.forEach((e=>e(this.base)))}}));else if(this.base&&this.options.main){const e=this.options.main(this.base);e&&e.length&&e.forEach((e=>e(this.base)))}}disconnectedCallback(){this.options.unmount(this.base),i((()=>{document.body.contains(this)||(this.__events&&(this.__events=null),this.base&&(this.base.elm=null),this.base&&(this.base=null),s(this))}))}attributeChangedCallback(){}}}const V={},I={},D={templateConfig:e=>{Object.assign(c,e)},publish:p,subscribe:b,register(e,t,n={}){I[e]={name:e,module:t,dependencies:n}},start(e=document.body){const t=Object.keys(I),n=t.toString();t.length&&(d(e,n,V,I),z())}},z=()=>{Object.values(I).forEach((e=>{const{name:t,module:n,dependencies:r}=e;if(!customElements.get(t)){const e=B(n,r,V,I);customElements.define(t,e)}}))};e.default=D,e.html=(e,...t)=>{let n=e.raw,r="";return t.forEach(((e,t)=>{let o=n[t];Array.isArray(e)&&(e=e.join("")),r+=o,r+=e})),r+=n[n.length-1],r},Object.defineProperties(e,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})}));
|
1
|
+
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).jails={})}(this,(function(e){"use strict";const t=new DOMParser;const n=(e,t,n)=>{var r,o;null==(r=t.parentNode)||r.insertBefore(e,t),null==(o=t.parentNode)||o.insertBefore(n,t.nextSibling)},r=document.createElement("textarea"),o=e=>(r.innerHTML=e,r.value),l=e=>requestAnimationFrame?requestAnimationFrame(e):setTimeout(e,1e3/60),a=e=>JSON.parse(JSON.stringify(e)),i=e=>{var t,n,r,o=e.attributes;if(o)for(t=o.length-1;t>=0;t-=1)"function"==typeof e[r=o[t].name]&&(e[r]=null);if(o=e.childNodes)for(n=o.length,t=0;t<n;t+=1)i(e.childNodes[t])},s=(e,t)=>{try{return e()}catch(n){return t||""}},c={tags:["${","}"]};function u(e){const r=function(e,r){const o=new RegExp(`\\${r.tags[0]}(.+?)\\${r.tags[1]}`,"g"),l=t.parseFromString(e.replace(/<\/?template[^>]*>/g,""),"text/html");return l.querySelectorAll("[html-for], [html-if], [html-inner], [html-class], [html-model]").forEach((e=>{const t=e.getAttribute("html-foreach"),r=e.getAttribute("html-for"),o=e.getAttribute("html-if"),l=e.getAttribute("html-inner"),a=e.getAttribute("html-class"),i=r||t;if(i){const t=r?"html-for":"html-foreach",o=i.match(/(.*)\sin\s(.*)/)||"",l=o[1],a=o[2];e.removeAttribute(t),e.setAttribute("scope","");const s=document.createElement("script");s.dataset.scope="",s.type="text/html",s.text="%%_= $scope _%%",e.appendChild(s);const c=document.createTextNode(`%%_(function(){ var $index = 0; for(var $key in safe(function(){ return ${a} }) ){ var ${l} = ${a}[$key]; var $scope = JSON.stringify({ '${l}':${l}, $index: $index, $key:$key }); _%%`),u=document.createTextNode("%%_ $index++; } })() _%%");n(c,e,u)}if(o){e.removeAttribute("html-if");const t=document.createTextNode(`%%_ if ( safe(function(){ return ${o} }) ){ _%%`),r=document.createTextNode("%%_ } _%%");n(t,e,r)}l&&(e.removeAttribute("html-inner"),e.innerHTML=`%%_=${l}_%%`),a&&(e.removeAttribute("html-class"),e.className=(e.className+` %%_=${a}_%%`).trim())})),l.body.innerHTML.replace(o,"%%_=$1_%%").replace(/html-(allowfullscreen|async|autofocus|autoplay|checked|controls|default|defer|disabled|formnovalidate|inert|ismap|itemscope|loop|multiple|muted|nomodule|novalidate|open|playsinline|readonly|required|reversed|selected)=\"(.*?)\"/g,"%%_if(safe(function(){ return $2 })){_%%$1%%_}_%%").replace(/html-(.*?)=\"(.*?)\"/g,((e,t,n)=>"key"===t||"model"===t||"scope"==t?e:n?`${t}="%%_=safe(function(){ return ${n=n.replace(/^{|}$/g,"")} })_%%"`:e))}(e.outerHTML,c),l=JSON.stringify(r);return new Function("$element","safe",`\n\t\tvar $data = this;\n\t\twith( $data ){\n\t\t\tvar output=${l.replace(/%%_=(.+?)_%%/g,(function(e,t){return'"+safe(function(){return '+o(t)+';})+"'})).replace(/%%_(.+?)_%%/g,(function(e,t){return'";'+o(t)+'\noutput+="'}))};return output;\n\t\t}\n\t`)}const d=(e,t,n,r)=>{[].concat(e.matches&&e.matches(t)?e:[]).concat(Array.from(e.querySelectorAll(t))).reverse().forEach((e=>{e.querySelectorAll("template").forEach((e=>d(e.content,t,n,r))),f(e,n,r)}))},f=(e,t,n)=>{if(!e.getAttribute("tplid")){const r="xxxxxxxx".replace(/[xy]/g,(e=>{const t=8*Math.random()|0;return("x"==e?t:3&t|8).toString(8)}));e.setAttribute("tplid",r);const o=e.localName;if(o in n&&n[o].module.template){const l=n[o].module.template();l.constructor===Promise?(e.__template=l,l.then((n=>{e.innerHTML=n,t[r]=u(e)}))):e.innerHTML=l}t[r]=u(e)}},m={},h={},p=(e,t)=>{h[e]=Object.assign({},h[e],t),m[e]&&m[e].forEach((e=>e(t)))},b=(e,t)=>(m[e]=m[e]||[],m[e].push(t),e in h&&t(h[e]),()=>{m[e]=m[e].filter((e=>e!=t))}),g=function(){let e=new Set,t={morphStyle:"outerHTML",callbacks:{beforeNodeAdded:c,afterNodeAdded:c,beforeNodeMorphed:c,afterNodeMorphed:c,beforeNodeRemoved:c,afterNodeRemoved:c,beforeAttributeUpdated:c},head:{style:"merge",shouldPreserve:function(e){return"true"===e.getAttribute("im-preserve")},shouldReAppend:function(e){return"true"===e.getAttribute("im-re-append")},shouldRemove:c,afterHeadMorphed:c}};function n(e,t,r){if(r.head.block){let o=e.querySelector("head"),l=t.querySelector("head");if(o&&l){let a=s(l,o,r);return void Promise.all(a).then((function(){n(e,t,Object.assign(r,{head:{block:!1,ignore:!0}}))}))}}if("innerHTML"===r.morphStyle)return l(t,e,r),e.children;if("outerHTML"===r.morphStyle||null==r.morphStyle){let n=function(e,t,n){let r;r=e.firstChild;let o=r,l=0;for(;r;){let e=p(r,t,n);e>l&&(o=r,l=e),r=r.nextSibling}return o}(t,e,r),l=null==n?void 0:n.previousSibling,a=null==n?void 0:n.nextSibling,i=o(e,n,r);return n?function(e,t,n){let r=[],o=[];for(;null!=e;)r.push(e),e=e.previousSibling;for(;r.length>0;){let e=r.pop();o.push(e),t.parentElement.insertBefore(e,t)}o.push(t);for(;null!=n;)r.push(n),o.push(n),n=n.nextSibling;for(;r.length>0;)t.parentElement.insertBefore(r.pop(),t.nextSibling);return o}(l,i,a):[]}throw"Do not understand how to morph style "+r.morphStyle}function r(e,t){return t.ignoreActiveValue&&e===document.activeElement}function o(e,t,n){if(!n.ignoreActive||e!==document.activeElement)return null==t?!1===n.callbacks.beforeNodeRemoved(e)?e:(e.remove(),n.callbacks.afterNodeRemoved(e),null):d(e,t)?(!1===n.callbacks.beforeNodeMorphed(e,t)||(e instanceof HTMLHeadElement&&n.head.ignore||(e instanceof HTMLHeadElement&&"morph"!==n.head.style?s(t,e,n):(!function(e,t,n){let o=e.nodeType;if(1===o){const r=e.attributes,o=t.attributes;for(const e of r)a(e.name,t,"update",n)||t.getAttribute(e.name)!==e.value&&t.setAttribute(e.name,e.value);for(let l=o.length-1;0<=l;l--){const r=o[l];a(r.name,t,"remove",n)||(e.hasAttribute(r.name)||t.removeAttribute(r.name))}}8!==o&&3!==o||t.nodeValue!==e.nodeValue&&(t.nodeValue=e.nodeValue);r(t,n)||function(e,t,n){if(e instanceof HTMLInputElement&&t instanceof HTMLInputElement&&"file"!==e.type){let r=e.value,o=t.value;i(e,t,"checked",n),i(e,t,"disabled",n),e.hasAttribute("value")?r!==o&&(a("value",t,"update",n)||(t.setAttribute("value",r),t.value=r)):a("value",t,"remove",n)||(t.value="",t.removeAttribute("value"))}else if(e instanceof HTMLOptionElement)i(e,t,"selected",n);else if(e instanceof HTMLTextAreaElement&&t instanceof HTMLTextAreaElement){let r=e.value,o=t.value;if(a("value",t,"update",n))return;r!==o&&(t.value=r),t.firstChild&&t.firstChild.nodeValue!==r&&(t.firstChild.nodeValue=r)}}(e,t,n)}(t,e,n),r(e,n)||l(t,e,n))),n.callbacks.afterNodeMorphed(e,t)),e):!1===n.callbacks.beforeNodeRemoved(e)||!1===n.callbacks.beforeNodeAdded(t)?e:(e.parentElement.replaceChild(t,e),n.callbacks.afterNodeAdded(t),n.callbacks.afterNodeRemoved(e),t)}function l(e,t,n){let r,l=e.firstChild,a=t.firstChild;for(;l;){if(r=l,l=r.nextSibling,null==a){if(!1===n.callbacks.beforeNodeAdded(r))return;t.appendChild(r),n.callbacks.afterNodeAdded(r),_(n,r);continue}if(u(r,a,n)){o(a,r,n),a=a.nextSibling,_(n,r);continue}let i=m(e,t,r,a,n);if(i){a=f(a,i,n),o(i,r,n),_(n,r);continue}let s=h(e,t,r,a,n);if(s)a=f(a,s,n),o(s,r,n),_(n,r);else{if(!1===n.callbacks.beforeNodeAdded(r))return;t.insertBefore(r,a),n.callbacks.afterNodeAdded(r),_(n,r)}}for(;null!==a;){let e=a;a=a.nextSibling,b(e,n)}}function a(e,t,n,r){return!("value"!==e||!r.ignoreActiveValue||t!==document.activeElement)||!1===r.callbacks.beforeAttributeUpdated(e,t,n)}function i(e,t,n,r){if(e[n]!==t[n]){let o=a(n,t,"update",r);o||(t[n]=e[n]),e[n]?o||t.setAttribute(n,e[n]):a(n,t,"remove",r)||t.removeAttribute(n)}}function s(e,t,n){let r=[],o=[],l=[],a=[],i=n.head.style,s=new Map;for(const u of e.children)s.set(u.outerHTML,u);for(const u of t.children){let e=s.has(u.outerHTML),t=n.head.shouldReAppend(u),r=n.head.shouldPreserve(u);e||r?t?o.push(u):(s.delete(u.outerHTML),l.push(u)):"append"===i?t&&(o.push(u),a.push(u)):!1!==n.head.shouldRemove(u)&&o.push(u)}a.push(...s.values());let c=[];for(const u of a){let e=document.createRange().createContextualFragment(u.outerHTML).firstChild;if(!1!==n.callbacks.beforeNodeAdded(e)){if(e.href||e.src){let t=null,n=new Promise((function(e){t=e}));e.addEventListener("load",(function(){t()})),c.push(n)}t.appendChild(e),n.callbacks.afterNodeAdded(e),r.push(e)}}for(const u of o)!1!==n.callbacks.beforeNodeRemoved(u)&&(t.removeChild(u),n.callbacks.afterNodeRemoved(u));return n.head.afterHeadMorphed(t,{added:r,kept:l,removed:o}),c}function c(){}function u(e,t,n){return null!=e&&null!=t&&(e.nodeType===t.nodeType&&e.tagName===t.tagName&&(""!==e.id&&e.id===t.id||y(n,e,t)>0))}function d(e,t){return null!=e&&null!=t&&(e.nodeType===t.nodeType&&e.tagName===t.tagName)}function f(e,t,n){for(;e!==t;){let t=e;e=e.nextSibling,b(t,n)}return _(n,t),t.nextSibling}function m(e,t,n,r,o){let l=y(o,n,t);if(l>0){let t=r,a=0;for(;null!=t;){if(u(n,t,o))return t;if(a+=y(o,t,e),a>l)return null;t=t.nextSibling}}return null}function h(e,t,n,r,o){let l=r,a=n.nextSibling,i=0;for(;null!=l;){if(y(o,l,e)>0)return null;if(d(n,l))return l;if(d(a,l)&&(i++,a=a.nextSibling,i>=2))return null;l=l.nextSibling}return l}function p(e,t,n){return d(e,t)?.5+y(n,e,t):0}function b(e,t){_(t,e),!1!==t.callbacks.beforeNodeRemoved(e)&&(e.remove(),t.callbacks.afterNodeRemoved(e))}function g(e,t){return!e.deadIds.has(t)}function v(t,n,r){return(t.idMap.get(r)||e).has(n)}function _(t,n){let r=t.idMap.get(n)||e;for(const e of r)t.deadIds.add(e)}function y(t,n,r){let o=t.idMap.get(n)||e,l=0;for(const e of o)g(t,e)&&v(t,e,r)&&++l;return l}function A(e,t){let n=e.parentElement,r=e.querySelectorAll("[id]");for(const o of r){let e=o;for(;e!==n&&null!=e;){let n=t.get(e);null==n&&(n=new Set,t.set(e,n)),n.add(o.id),e=e.parentElement}}}function S(e,t){let n=new Map;return A(e,n),A(t,n),n}return{morph:function(e,r,o={}){e instanceof Document&&(e=e.documentElement),"string"==typeof r&&(r=function(e){let t=new DOMParser,n=e.replace(/<svg(\s[^>]*>|>)([\s\S]*?)<\/svg>/gim,"");if(n.match(/<\/html>/)||n.match(/<\/head>/)||n.match(/<\/body>/)){let r=t.parseFromString(e,"text/html");if(n.match(/<\/html>/))return r.generatedByIdiomorph=!0,r;{let e=r.firstChild;return e?(e.generatedByIdiomorph=!0,e):null}}{let n=t.parseFromString("<body><template>"+e+"</template></body>","text/html").body.querySelector("template").content;return n.generatedByIdiomorph=!0,n}}(r));let l=function(e){if(null==e){return document.createElement("div")}if(e.generatedByIdiomorph)return e;if(e instanceof Node){const t=document.createElement("div");return t.append(e),t}{const t=document.createElement("div");for(const n of[...e])t.append(n);return t}}(r),a=function(e,n,r){return r=function(e){let n={};return Object.assign(n,t),Object.assign(n,e),n.callbacks={},Object.assign(n.callbacks,t.callbacks),Object.assign(n.callbacks,e.callbacks),n.head={},Object.assign(n.head,t.head),Object.assign(n.head,e.head),n}(r),{target:e,newContent:n,config:r,morphStyle:r.morphStyle,ignoreActive:r.ignoreActive,ignoreActiveValue:r.ignoreActiveValue,idMap:S(e,n),deadIds:new Set,callbacks:r.callbacks,head:r.head}}(e,l,o);return n(e,l,a)},defaults:t}}(),v="CustomEvent"in window&&"function"==typeof window.CustomEvent?(e,t)=>new CustomEvent(e,t):(e,t)=>{const n=document.createEvent("CustomEvent");return n.initCustomEvent(e,!0,!0,t),n},_=(e,t)=>function(n){const r=this,o=n.detail||{};e.__events[t].forEach((e=>{e.handler.apply(r,[n].concat(o.args))}))},y=(e,t)=>{e.__events[t]&&e.__events[t].listener&&(e.removeEventListener(t,e.__events[t].listener,"focus"==t||"blur"==t||"mouseenter"==t||"mouseleave"==t),delete e.__events[t])},A=(e,t,n)=>function(r){const o=this,l=r.detail||{};let a=r.target;for(;a&&(a.matches(t)&&(r.delegateTarget=a,n.apply(o,[r].concat(l.args))),a!==e);)a=a.parentNode},S=(e,t,n,r)=>{if(e.__events=e.__events||{},e.__events[t]=e.__events[t]||[],!e.__events[t].length){const n=_(e,t);e.addEventListener(t,n,"focus"==t||"blur"==t||"mouseenter"==t||"mouseleave"==t),e.__events[t].listener=n}n.call?e.__events[t].push({handler:n,callback:n}):e.__events[t].push({handler:A(e,n,r),callback:r})},E=(e,t,n)=>{if(n&&e.__events[t]&&e.__events[t].length){var r=e.__events[t];e.__events[t]=e.__events[t].filter((function(e){return e.callback!=n})),e.__events[t].listener=r.listener,e.__events[t].length||y(e,t)}else y(e,t)},x=(e,t,n)=>{e.dispatchEvent(v(t,{bubbles:!0,detail:n}))};const k=e=>({main:e=>e,unmount:e=>e,onupdate:e=>e,view:e.view?e.view:e=>e}),N=e=>{e.querySelectorAll("[scope]").forEach((e=>{e.querySelectorAll("[tplid]").forEach((t=>{if(!t.___scope___){const n=e.lastElementChild;t.___scope___="scope"in n.dataset?new Function(`return ${n.text}`)():{}}}))}))},M={callbacks:{beforeNodeMorphed(e){if(1===e.nodeType&&"html-static"in e.attributes)return!1}}};function T(e,t,n,r){return class extends HTMLElement{constructor(){super();const{base:o,options:i}=function(e,{module:t,dependencies:n,templates:r,components:o}){const i=k(t),c=new Function(`return ${e.getAttribute("html-model")||"{}"}`)(),u=Object.keys(o).toString();d(e,u,r,o);const f=e.getAttribute("tplid"),m=f?r[f]:null,h={data:t.model?a(t.model):{}};h.data=Object.assign(h.data,c);const v={template:m,elm:e,dependencies:n,publish:p,subscribe:b,main(e){i.main=e},unmount(e){i.unmount=e},onupdate(e){i.onupdate=e},on(t,n,r){S(e,t,n,r)},off(t,n){E(e,t,n)},trigger(t,n,r){n.constructor===String?Array.from(e.querySelectorAll(n)).forEach((e=>x(e,t,{args:r}))):x(e,t,{args:n})},emit:(...t)=>{x(e,t.shift(),{args:t})},state:{set(e){if(e.constructor===Function){const t=a(h.data);e(t),v.render(t)}else v.render(e);return new Promise((e=>l((t=>l((()=>e(h.data)))))))},get:()=>a(h.data),getRaw:()=>h.data},render(t=h.data){if(!document.body.contains(e))return;h.data=Object.assign(h.data,t);const n=a(h.data),o=r[f].call(Object.assign(i.view(n),e.___scope___),e,s);g.morph(e,o,M),N(e),l((n=>{Array.from(e.querySelectorAll("[tplid]")).forEach((e=>{const n=Object.assign(e.base.state.getRaw(),t);e.options.onupdate(n),e.base.render(n)}))}))},innerHTML(t,n){const r=n?t:e,o=(new DOMParser).parseFromString(r.outerHTML,"text/html"),a=n||t;o.body.firstElementChild.innerHTML=a,l((e=>g.morph(r,o.body.innerHTML,M)))}};return{base:v,options:i}}(this,{module:e,dependencies:t,templates:n,components:r});this.base=o,this.options=i,this.returns=e.default(o)}connectedCallback(){if(this.base.render(),this.__template&&this.__template.constructor===Promise)this.__template.then((e=>{if(this.base&&this.options.main){const e=this.options.main(this.base);e&&e.length&&e.forEach((e=>e(this.base)))}}));else if(this.returns&&this.returns.constructor===Promise)this.returns.then((e=>{if(this.base&&this.options.main){const e=this.options.main(this.base);e&&e.length&&e.forEach((e=>e(this.base)))}}));else if(this.base&&this.options.main){const e=this.options.main(this.base);e&&e.length&&e.forEach((e=>e(this.base)))}}disconnectedCallback(){this.options.unmount(this.base),l((()=>{document.body.contains(this)||(this.__events&&(this.__events=null),this.base&&(this.base.elm=null),this.base&&(this.base=null),i(this))}))}attributeChangedCallback(){}}}const $={},w={},H={templateConfig:e=>{Object.assign(c,e)},publish:p,subscribe:b,register(e,t,n={}){w[e]={name:e,module:t,dependencies:n}},start(e=document.body){const t=Object.keys(w),n=t.toString();t.length&&(d(e,n,$,w),L())}},L=()=>{Object.values(w).forEach((e=>{const{name:t,module:n,dependencies:r}=e;if(!customElements.get(t)){const e=T(n,r,$,w);customElements.define(t,e)}}))};e.default=H,e.html=(e,...t)=>{let n=e.raw,r="";return t.forEach(((e,t)=>{let o=n[t];Array.isArray(e)&&(e=e.join("")),r+=o,r+=e})),r+=n[n.length-1],r},Object.defineProperties(e,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})}));
|
2
2
|
//# sourceMappingURL=jails.js.map
|
package/dist/jails.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"jails.js","sources":["../src/transpile.ts","../src/utils/index.ts","../src/template-system.ts","../src/utils/pubsub.ts","../node_modules/morphdom/dist/morphdom-esm.js","../src/utils/events.ts","../src/component.ts","../src/element.ts","../src/index.ts"],"sourcesContent":["const parser = new DOMParser()\n\nexport default function Transpile(html, config, components, element) {\n\n\tconst regexTags = new RegExp(`\\\\${config.tags[0]}(.+?)\\\\${config.tags[1]}`, 'g')\n\tconst virtual = parser.parseFromString(html.replace(/<\\/?template[^>]*>/g, ''), 'text/html')\n\n\tconst root = virtual.querySelector(element.localName)\n\tconst childNodes = Object.keys(components).toString()\n\n\troot.querySelectorAll(childNodes).forEach( node => {\n\t\tconst clone = node.cloneNode()\n\t\tnode.replaceWith(clone)\n\t})\n\n\tvirtual.querySelectorAll('[html-for], [html-if], [html-inner], [html-class], [html-model]').forEach((element) => {\n\n\t\tconst htmlForeach = element.getAttribute('html-foreach')\n\t\tconst htmlFor \t= element.getAttribute('html-for')\n\t\tconst htmlIf \t= element.getAttribute('html-if')\n\t\tconst htmlInner = element.getAttribute('html-inner')\n\t\tconst htmlClass = element.getAttribute('html-class')\n\t\tconst forEachInstruction = htmlFor || htmlForeach\n\n\t\tif ( forEachInstruction ) {\n\t\t\tconst selector = htmlFor? 'html-for': 'html-foreach'\n\t\t\tconst split = forEachInstruction.match(/(.*)\\sin\\s(.*)/) || ''\n\t\t\tconst varname = split[1]\n\t\t\tconst object = split[2]\n\n\t\t\telement.removeAttribute(selector)\n\t\t\telement.setAttribute('scope', '')\n\t\t\tconst script = document.createElement('script')\n\n\t\t\tscript.dataset.scope = ''\n\t\t\tscript.type = 'text/html'\n\t\t\tscript.text = `%%_= $scope _%%`\n\n\t\t\telement.appendChild( script )\n\n\t\t\tconst open = document.createTextNode(`%%_(function(){ var $index = 0; for(var $key in safe(function(){ return ${object} }) ){ var ${varname} = ${object}[$key]; var $scope = JSON.stringify({ '${varname}':${varname}, $index: $index, $key:$key }); _%%`)\n\t\t\tconst close = document.createTextNode(`%%_ $index++; } })() _%%`)\n\t\t\twrap(open, element, close)\n\t\t}\n\t\tif (htmlIf) {\n\t\t\telement.removeAttribute('html-if')\n\t\t\tconst open = document.createTextNode(`%%_ if ( safe(function(){ return ${htmlIf} }) ){ _%%`)\n\t\t\tconst close = document.createTextNode(`%%_ } _%%`)\n\t\t\twrap(open, element, close)\n\t\t}\n\t\tif (htmlInner) {\n\t\t\telement.removeAttribute('html-inner')\n\t\t\telement.innerHTML = `%%_=${htmlInner}_%%`\n\t\t}\n\t\tif (htmlClass) {\n\t\t\telement.removeAttribute('html-class')\n\t\t\telement.className = (element.className + ` %%_=${htmlClass}_%%`).trim()\n\t\t}\n\t})\n\n\n\treturn (\n\t\tvirtual.body.innerHTML\n\t\t\t.replace(regexTags, '%%_=$1_%%')\n\t\t\t// Booleans\n\t\t\t// https://meiert.com/en/blog/boolean-attributes-of-html/\n\t\t\t.replace(/html-(allowfullscreen|async|autofocus|autoplay|checked|controls|default|defer|disabled|formnovalidate|inert|ismap|itemscope|loop|multiple|muted|nomodule|novalidate|open|playsinline|readonly|required|reversed|selected)=\\\"(.*?)\\\"/g, `%%_if(safe(function(){ return $2 })){_%%$1%%_}_%%`)\n\t\t\t// The rest\n\t\t\t.replace(/html-(.*?)=\\\"(.*?)\\\"/g, (all, key, value) => {\n\t\t\t\tif (key === 'key' || key === 'model' || key == 'scope') {\n\t\t\t\t\treturn all\n\t\t\t\t}\n\t\t\t\tif (value) {\n\t\t\t\t\tvalue = value.replace(/^{|}$/g, '')\n\t\t\t\t\treturn `${key}=\"%%_=safe(function(){ return ${value} })_%%\"`\n\t\t\t\t} else {\n\t\t\t\t\treturn all\n\t\t\t\t}\n\t\t\t})\n\t)\n}\n\nconst wrap = (open, node, close) => {\n\tnode.parentNode?.insertBefore(open, node)\n\tnode.parentNode?.insertBefore(close, node.nextSibling)\n}\n","const textarea = document.createElement('textarea')\n\nexport const decodeHTML = (text) => {\n\ttextarea.innerHTML = text\n\treturn textarea.value\n}\n\nexport const rAF = (fn) => {\n\tif (requestAnimationFrame)\n\t\treturn requestAnimationFrame(fn)\n\telse\n\t\treturn setTimeout(fn, 1000 / 60)\n}\n\nexport const uuid = () => {\n\treturn 'xxxxxxxx'.replace(/[xy]/g, (c) => {\n\t\tconst r = Math.random() * 8 | 0, v = c == 'x' ? r : (r & 0x3 | 0x8)\n\t\treturn v.toString(8)\n\t})\n}\n\n\nexport const dup = (o) => {\n\treturn JSON.parse(JSON.stringify(o))\n}\n\n// http://crockford.com/javascript/memory/leak.html\nexport const purge = (d) => {\n\tvar a = d.attributes, i, l, n\n\tif (a) {\n\t\tfor (i = a.length - 1; i >= 0; i -= 1) {\n\t\t\tn = a[i].name\n\t\t\tif (typeof d[n] === 'function') {\n\t\t\t\td[n] = null\n\t\t\t}\n\t\t}\n\t}\n\ta = d.childNodes\n\tif (a) {\n\t\tl = a.length\n\t\tfor (i = 0; i < l; i += 1) {\n\t\t\tpurge(d.childNodes[i])\n\t\t}\n\t}\n}\n\nexport const safe = (execute, val) => {\n\ttry{return execute()}catch(err){return val || ''}\n}\n\n// From\n// https://2ality.com/2015/01/template-strings-html.html#comment-2078932192\nexport const html = (literalSections, ...substs) => {\n\n\t// Use raw literal sections: we don’t want\n\t// backslashes (\\n etc.) to be interpreted\n\tlet raw = literalSections.raw\n\n\tlet result = ''\n\n\tsubsts.forEach((subst, i) => {\n\t\t// Retrieve the literal section preceding\n\t\t// the current substitution\n\t\tlet lit = raw[i]\n\n\t\t// In the example, map() returns an array:\n\t\t// If substitution is an array (and not a string),\n\t\t// we turn it into a string\n\t\tif (Array.isArray(subst)) {\n\t\t\tsubst = subst.join('')\n\t\t}\n\n\t\tresult += lit\n\t\tresult += subst\n\t})\n\t// Take care of last literal section\n\t// (Never fails, because an empty template string\n\t// produces one literal section, an empty string)\n\tresult += raw[raw.length-1] // (A)\n\n\treturn result\n}\n","import Transpile from './transpile'\nimport { uuid, decodeHTML } from './utils'\n\nconst config = {\n\ttags: ['${', '}']\n}\n\nexport const templateConfig = (newconfig) => {\n\tObject.assign(config, newconfig)\n}\n\nexport default function Template(element, components) {\n\n\tconst html = Transpile(element.outerHTML, config, components, element)\n\tconst decodedHTML = JSON.stringify(html)\n\n\treturn new Function('$element', 'safe',`\n\t\tvar $data = this;\n\t\twith( $data ){\n\t\t\tvar output=${decodedHTML\n\t\t\t\t.replace(/%%_=(.+?)_%%/g, function(_, variable){\n\t\t\t\t\treturn '\"+safe(function(){return '+decodeHTML(variable)+';})+\"'\n\t\t\t\t})\n\t\t\t\t.replace(/%%_(.+?)_%%/g, function(_, variable){\n\t\t\t\t\treturn '\";' + decodeHTML(variable) +'\\noutput+=\"'\n\t\t\t\t})};return output;\n\t\t}\n\t`)\n}\n\nexport const buildtemplates = ( target, selector, templates, components ) => {\n\t[]\n\t\t.concat( target.matches? (target.matches(selector)? target : []) : [] )\n\t\t.concat( Array.from(target.querySelectorAll( selector )) )\n\t\t.reverse()\n\t\t.forEach( (node:HTMLElement) => {\n\t\t\tnode.querySelectorAll('template').forEach( template => buildtemplates(template.content, selector, templates, components ))\n\t\t\tcreateTemplateId(node, templates, components)\n\t\t})\n}\n\nconst createTemplateId = (element, templates, components ) => {\n\n\tconst tplid = element.getAttribute('tplid')\n\n\tif (!tplid) {\n\t\tconst id = uuid()\n\t\telement.setAttribute('tplid', id)\n\t\tconst name = element.localName\n\n\t\tif( name in components && components[name].module.template ) {\n\t\t\tconst html = components[name].module.template()\n\t\t\tif( html.constructor === Promise ) {\n\t\t\t\telement.__template = html\n\t\t\t\thtml.then( htmlstring => {\n\t\t\t\t\telement.innerHTML = htmlstring\n\t\t\t\t\ttemplates[id] = Template(element, components)\n\t\t\t\t})\n\t\t\t}else {\n\t\t\t\telement.innerHTML = html\n\t\t\t}\n\t\t}\n\t\ttemplates[id] = Template(element, components)\n\t}\n}\n\n","const topics: any = {}\nconst _async: any = {}\n\nexport const publish = (name, params) => {\n\t_async[name] = Object.assign({}, _async[name], params)\n\tif (topics[name])\n\t\ttopics[name].forEach(topic => topic(params))\n}\n\nexport const subscribe = (name, method) => {\n\ttopics[name] = topics[name] || []\n\ttopics[name].push(method)\n\tif (name in _async) {\n\t\tmethod(_async[name])\n\t}\n\treturn () => {\n\t\ttopics[name] = topics[name].filter( fn => fn != method )\n\t}\n}\n\n","var DOCUMENT_FRAGMENT_NODE = 11;\n\nfunction morphAttrs(fromNode, toNode) {\n var toNodeAttrs = toNode.attributes;\n var attr;\n var attrName;\n var attrNamespaceURI;\n var attrValue;\n var fromValue;\n\n // document-fragments dont have attributes so lets not do anything\n if (toNode.nodeType === DOCUMENT_FRAGMENT_NODE || fromNode.nodeType === DOCUMENT_FRAGMENT_NODE) {\n return;\n }\n\n // update attributes on original DOM element\n for (var i = toNodeAttrs.length - 1; i >= 0; i--) {\n attr = toNodeAttrs[i];\n attrName = attr.name;\n attrNamespaceURI = attr.namespaceURI;\n attrValue = attr.value;\n\n if (attrNamespaceURI) {\n attrName = attr.localName || attrName;\n fromValue = fromNode.getAttributeNS(attrNamespaceURI, attrName);\n\n if (fromValue !== attrValue) {\n if (attr.prefix === 'xmlns'){\n attrName = attr.name; // It's not allowed to set an attribute with the XMLNS namespace without specifying the `xmlns` prefix\n }\n fromNode.setAttributeNS(attrNamespaceURI, attrName, attrValue);\n }\n } else {\n fromValue = fromNode.getAttribute(attrName);\n\n if (fromValue !== attrValue) {\n fromNode.setAttribute(attrName, attrValue);\n }\n }\n }\n\n // Remove any extra attributes found on the original DOM element that\n // weren't found on the target element.\n var fromNodeAttrs = fromNode.attributes;\n\n for (var d = fromNodeAttrs.length - 1; d >= 0; d--) {\n attr = fromNodeAttrs[d];\n attrName = attr.name;\n attrNamespaceURI = attr.namespaceURI;\n\n if (attrNamespaceURI) {\n attrName = attr.localName || attrName;\n\n if (!toNode.hasAttributeNS(attrNamespaceURI, attrName)) {\n fromNode.removeAttributeNS(attrNamespaceURI, attrName);\n }\n } else {\n if (!toNode.hasAttribute(attrName)) {\n fromNode.removeAttribute(attrName);\n }\n }\n }\n}\n\nvar range; // Create a range object for efficently rendering strings to elements.\nvar NS_XHTML = 'http://www.w3.org/1999/xhtml';\n\nvar doc = typeof document === 'undefined' ? undefined : document;\nvar HAS_TEMPLATE_SUPPORT = !!doc && 'content' in doc.createElement('template');\nvar HAS_RANGE_SUPPORT = !!doc && doc.createRange && 'createContextualFragment' in doc.createRange();\n\nfunction createFragmentFromTemplate(str) {\n var template = doc.createElement('template');\n template.innerHTML = str;\n return template.content.childNodes[0];\n}\n\nfunction createFragmentFromRange(str) {\n if (!range) {\n range = doc.createRange();\n range.selectNode(doc.body);\n }\n\n var fragment = range.createContextualFragment(str);\n return fragment.childNodes[0];\n}\n\nfunction createFragmentFromWrap(str) {\n var fragment = doc.createElement('body');\n fragment.innerHTML = str;\n return fragment.childNodes[0];\n}\n\n/**\n * This is about the same\n * var html = new DOMParser().parseFromString(str, 'text/html');\n * return html.body.firstChild;\n *\n * @method toElement\n * @param {String} str\n */\nfunction toElement(str) {\n str = str.trim();\n if (HAS_TEMPLATE_SUPPORT) {\n // avoid restrictions on content for things like `<tr><th>Hi</th></tr>` which\n // createContextualFragment doesn't support\n // <template> support not available in IE\n return createFragmentFromTemplate(str);\n } else if (HAS_RANGE_SUPPORT) {\n return createFragmentFromRange(str);\n }\n\n return createFragmentFromWrap(str);\n}\n\n/**\n * Returns true if two node's names are the same.\n *\n * NOTE: We don't bother checking `namespaceURI` because you will never find two HTML elements with the same\n * nodeName and different namespace URIs.\n *\n * @param {Element} a\n * @param {Element} b The target element\n * @return {boolean}\n */\nfunction compareNodeNames(fromEl, toEl) {\n var fromNodeName = fromEl.nodeName;\n var toNodeName = toEl.nodeName;\n var fromCodeStart, toCodeStart;\n\n if (fromNodeName === toNodeName) {\n return true;\n }\n\n fromCodeStart = fromNodeName.charCodeAt(0);\n toCodeStart = toNodeName.charCodeAt(0);\n\n // If the target element is a virtual DOM node or SVG node then we may\n // need to normalize the tag name before comparing. Normal HTML elements that are\n // in the \"http://www.w3.org/1999/xhtml\"\n // are converted to upper case\n if (fromCodeStart <= 90 && toCodeStart >= 97) { // from is upper and to is lower\n return fromNodeName === toNodeName.toUpperCase();\n } else if (toCodeStart <= 90 && fromCodeStart >= 97) { // to is upper and from is lower\n return toNodeName === fromNodeName.toUpperCase();\n } else {\n return false;\n }\n}\n\n/**\n * Create an element, optionally with a known namespace URI.\n *\n * @param {string} name the element name, e.g. 'div' or 'svg'\n * @param {string} [namespaceURI] the element's namespace URI, i.e. the value of\n * its `xmlns` attribute or its inferred namespace.\n *\n * @return {Element}\n */\nfunction createElementNS(name, namespaceURI) {\n return !namespaceURI || namespaceURI === NS_XHTML ?\n doc.createElement(name) :\n doc.createElementNS(namespaceURI, name);\n}\n\n/**\n * Copies the children of one DOM element to another DOM element\n */\nfunction moveChildren(fromEl, toEl) {\n var curChild = fromEl.firstChild;\n while (curChild) {\n var nextChild = curChild.nextSibling;\n toEl.appendChild(curChild);\n curChild = nextChild;\n }\n return toEl;\n}\n\nfunction syncBooleanAttrProp(fromEl, toEl, name) {\n if (fromEl[name] !== toEl[name]) {\n fromEl[name] = toEl[name];\n if (fromEl[name]) {\n fromEl.setAttribute(name, '');\n } else {\n fromEl.removeAttribute(name);\n }\n }\n}\n\nvar specialElHandlers = {\n OPTION: function(fromEl, toEl) {\n var parentNode = fromEl.parentNode;\n if (parentNode) {\n var parentName = parentNode.nodeName.toUpperCase();\n if (parentName === 'OPTGROUP') {\n parentNode = parentNode.parentNode;\n parentName = parentNode && parentNode.nodeName.toUpperCase();\n }\n if (parentName === 'SELECT' && !parentNode.hasAttribute('multiple')) {\n if (fromEl.hasAttribute('selected') && !toEl.selected) {\n // Workaround for MS Edge bug where the 'selected' attribute can only be\n // removed if set to a non-empty value:\n // https://developer.microsoft.com/en-us/microsoft-edge/platform/issues/12087679/\n fromEl.setAttribute('selected', 'selected');\n fromEl.removeAttribute('selected');\n }\n // We have to reset select element's selectedIndex to -1, otherwise setting\n // fromEl.selected using the syncBooleanAttrProp below has no effect.\n // The correct selectedIndex will be set in the SELECT special handler below.\n parentNode.selectedIndex = -1;\n }\n }\n syncBooleanAttrProp(fromEl, toEl, 'selected');\n },\n /**\n * The \"value\" attribute is special for the <input> element since it sets\n * the initial value. Changing the \"value\" attribute without changing the\n * \"value\" property will have no effect since it is only used to the set the\n * initial value. Similar for the \"checked\" attribute, and \"disabled\".\n */\n INPUT: function(fromEl, toEl) {\n syncBooleanAttrProp(fromEl, toEl, 'checked');\n syncBooleanAttrProp(fromEl, toEl, 'disabled');\n\n if (fromEl.value !== toEl.value) {\n fromEl.value = toEl.value;\n }\n\n if (!toEl.hasAttribute('value')) {\n fromEl.removeAttribute('value');\n }\n },\n\n TEXTAREA: function(fromEl, toEl) {\n var newValue = toEl.value;\n if (fromEl.value !== newValue) {\n fromEl.value = newValue;\n }\n\n var firstChild = fromEl.firstChild;\n if (firstChild) {\n // Needed for IE. Apparently IE sets the placeholder as the\n // node value and vise versa. This ignores an empty update.\n var oldValue = firstChild.nodeValue;\n\n if (oldValue == newValue || (!newValue && oldValue == fromEl.placeholder)) {\n return;\n }\n\n firstChild.nodeValue = newValue;\n }\n },\n SELECT: function(fromEl, toEl) {\n if (!toEl.hasAttribute('multiple')) {\n var selectedIndex = -1;\n var i = 0;\n // We have to loop through children of fromEl, not toEl since nodes can be moved\n // from toEl to fromEl directly when morphing.\n // At the time this special handler is invoked, all children have already been morphed\n // and appended to / removed from fromEl, so using fromEl here is safe and correct.\n var curChild = fromEl.firstChild;\n var optgroup;\n var nodeName;\n while(curChild) {\n nodeName = curChild.nodeName && curChild.nodeName.toUpperCase();\n if (nodeName === 'OPTGROUP') {\n optgroup = curChild;\n curChild = optgroup.firstChild;\n } else {\n if (nodeName === 'OPTION') {\n if (curChild.hasAttribute('selected')) {\n selectedIndex = i;\n break;\n }\n i++;\n }\n curChild = curChild.nextSibling;\n if (!curChild && optgroup) {\n curChild = optgroup.nextSibling;\n optgroup = null;\n }\n }\n }\n\n fromEl.selectedIndex = selectedIndex;\n }\n }\n};\n\nvar ELEMENT_NODE = 1;\nvar DOCUMENT_FRAGMENT_NODE$1 = 11;\nvar TEXT_NODE = 3;\nvar COMMENT_NODE = 8;\n\nfunction noop() {}\n\nfunction defaultGetNodeKey(node) {\n if (node) {\n return (node.getAttribute && node.getAttribute('id')) || node.id;\n }\n}\n\nfunction morphdomFactory(morphAttrs) {\n\n return function morphdom(fromNode, toNode, options) {\n if (!options) {\n options = {};\n }\n\n if (typeof toNode === 'string') {\n if (fromNode.nodeName === '#document' || fromNode.nodeName === 'HTML' || fromNode.nodeName === 'BODY') {\n var toNodeHtml = toNode;\n toNode = doc.createElement('html');\n toNode.innerHTML = toNodeHtml;\n } else {\n toNode = toElement(toNode);\n }\n } else if (toNode.nodeType === DOCUMENT_FRAGMENT_NODE$1) {\n toNode = toNode.firstElementChild;\n }\n\n var getNodeKey = options.getNodeKey || defaultGetNodeKey;\n var onBeforeNodeAdded = options.onBeforeNodeAdded || noop;\n var onNodeAdded = options.onNodeAdded || noop;\n var onBeforeElUpdated = options.onBeforeElUpdated || noop;\n var onElUpdated = options.onElUpdated || noop;\n var onBeforeNodeDiscarded = options.onBeforeNodeDiscarded || noop;\n var onNodeDiscarded = options.onNodeDiscarded || noop;\n var onBeforeElChildrenUpdated = options.onBeforeElChildrenUpdated || noop;\n var skipFromChildren = options.skipFromChildren || noop;\n var addChild = options.addChild || function(parent, child){ return parent.appendChild(child); };\n var childrenOnly = options.childrenOnly === true;\n\n // This object is used as a lookup to quickly find all keyed elements in the original DOM tree.\n var fromNodesLookup = Object.create(null);\n var keyedRemovalList = [];\n\n function addKeyedRemoval(key) {\n keyedRemovalList.push(key);\n }\n\n function walkDiscardedChildNodes(node, skipKeyedNodes) {\n if (node.nodeType === ELEMENT_NODE) {\n var curChild = node.firstChild;\n while (curChild) {\n\n var key = undefined;\n\n if (skipKeyedNodes && (key = getNodeKey(curChild))) {\n // If we are skipping keyed nodes then we add the key\n // to a list so that it can be handled at the very end.\n addKeyedRemoval(key);\n } else {\n // Only report the node as discarded if it is not keyed. We do this because\n // at the end we loop through all keyed elements that were unmatched\n // and then discard them in one final pass.\n onNodeDiscarded(curChild);\n if (curChild.firstChild) {\n walkDiscardedChildNodes(curChild, skipKeyedNodes);\n }\n }\n\n curChild = curChild.nextSibling;\n }\n }\n }\n\n /**\n * Removes a DOM node out of the original DOM\n *\n * @param {Node} node The node to remove\n * @param {Node} parentNode The nodes parent\n * @param {Boolean} skipKeyedNodes If true then elements with keys will be skipped and not discarded.\n * @return {undefined}\n */\n function removeNode(node, parentNode, skipKeyedNodes) {\n if (onBeforeNodeDiscarded(node) === false) {\n return;\n }\n\n if (parentNode) {\n parentNode.removeChild(node);\n }\n\n onNodeDiscarded(node);\n walkDiscardedChildNodes(node, skipKeyedNodes);\n }\n\n // // TreeWalker implementation is no faster, but keeping this around in case this changes in the future\n // function indexTree(root) {\n // var treeWalker = document.createTreeWalker(\n // root,\n // NodeFilter.SHOW_ELEMENT);\n //\n // var el;\n // while((el = treeWalker.nextNode())) {\n // var key = getNodeKey(el);\n // if (key) {\n // fromNodesLookup[key] = el;\n // }\n // }\n // }\n\n // // NodeIterator implementation is no faster, but keeping this around in case this changes in the future\n //\n // function indexTree(node) {\n // var nodeIterator = document.createNodeIterator(node, NodeFilter.SHOW_ELEMENT);\n // var el;\n // while((el = nodeIterator.nextNode())) {\n // var key = getNodeKey(el);\n // if (key) {\n // fromNodesLookup[key] = el;\n // }\n // }\n // }\n\n function indexTree(node) {\n if (node.nodeType === ELEMENT_NODE || node.nodeType === DOCUMENT_FRAGMENT_NODE$1) {\n var curChild = node.firstChild;\n while (curChild) {\n var key = getNodeKey(curChild);\n if (key) {\n fromNodesLookup[key] = curChild;\n }\n\n // Walk recursively\n indexTree(curChild);\n\n curChild = curChild.nextSibling;\n }\n }\n }\n\n indexTree(fromNode);\n\n function handleNodeAdded(el) {\n onNodeAdded(el);\n\n var curChild = el.firstChild;\n while (curChild) {\n var nextSibling = curChild.nextSibling;\n\n var key = getNodeKey(curChild);\n if (key) {\n var unmatchedFromEl = fromNodesLookup[key];\n // if we find a duplicate #id node in cache, replace `el` with cache value\n // and morph it to the child node.\n if (unmatchedFromEl && compareNodeNames(curChild, unmatchedFromEl)) {\n curChild.parentNode.replaceChild(unmatchedFromEl, curChild);\n morphEl(unmatchedFromEl, curChild);\n } else {\n handleNodeAdded(curChild);\n }\n } else {\n // recursively call for curChild and it's children to see if we find something in\n // fromNodesLookup\n handleNodeAdded(curChild);\n }\n\n curChild = nextSibling;\n }\n }\n\n function cleanupFromEl(fromEl, curFromNodeChild, curFromNodeKey) {\n // We have processed all of the \"to nodes\". If curFromNodeChild is\n // non-null then we still have some from nodes left over that need\n // to be removed\n while (curFromNodeChild) {\n var fromNextSibling = curFromNodeChild.nextSibling;\n if ((curFromNodeKey = getNodeKey(curFromNodeChild))) {\n // Since the node is keyed it might be matched up later so we defer\n // the actual removal to later\n addKeyedRemoval(curFromNodeKey);\n } else {\n // NOTE: we skip nested keyed nodes from being removed since there is\n // still a chance they will be matched up later\n removeNode(curFromNodeChild, fromEl, true /* skip keyed nodes */);\n }\n curFromNodeChild = fromNextSibling;\n }\n }\n\n function morphEl(fromEl, toEl, childrenOnly) {\n var toElKey = getNodeKey(toEl);\n\n if (toElKey) {\n // If an element with an ID is being morphed then it will be in the final\n // DOM so clear it out of the saved elements collection\n delete fromNodesLookup[toElKey];\n }\n\n if (!childrenOnly) {\n // optional\n if (onBeforeElUpdated(fromEl, toEl) === false) {\n return;\n }\n\n // update attributes on original DOM element first\n morphAttrs(fromEl, toEl);\n // optional\n onElUpdated(fromEl);\n\n if (onBeforeElChildrenUpdated(fromEl, toEl) === false) {\n return;\n }\n }\n\n if (fromEl.nodeName !== 'TEXTAREA') {\n morphChildren(fromEl, toEl);\n } else {\n specialElHandlers.TEXTAREA(fromEl, toEl);\n }\n }\n\n function morphChildren(fromEl, toEl) {\n var skipFrom = skipFromChildren(fromEl, toEl);\n var curToNodeChild = toEl.firstChild;\n var curFromNodeChild = fromEl.firstChild;\n var curToNodeKey;\n var curFromNodeKey;\n\n var fromNextSibling;\n var toNextSibling;\n var matchingFromEl;\n\n // walk the children\n outer: while (curToNodeChild) {\n toNextSibling = curToNodeChild.nextSibling;\n curToNodeKey = getNodeKey(curToNodeChild);\n\n // walk the fromNode children all the way through\n while (!skipFrom && curFromNodeChild) {\n fromNextSibling = curFromNodeChild.nextSibling;\n\n if (curToNodeChild.isSameNode && curToNodeChild.isSameNode(curFromNodeChild)) {\n curToNodeChild = toNextSibling;\n curFromNodeChild = fromNextSibling;\n continue outer;\n }\n\n curFromNodeKey = getNodeKey(curFromNodeChild);\n\n var curFromNodeType = curFromNodeChild.nodeType;\n\n // this means if the curFromNodeChild doesnt have a match with the curToNodeChild\n var isCompatible = undefined;\n\n if (curFromNodeType === curToNodeChild.nodeType) {\n if (curFromNodeType === ELEMENT_NODE) {\n // Both nodes being compared are Element nodes\n\n if (curToNodeKey) {\n // The target node has a key so we want to match it up with the correct element\n // in the original DOM tree\n if (curToNodeKey !== curFromNodeKey) {\n // The current element in the original DOM tree does not have a matching key so\n // let's check our lookup to see if there is a matching element in the original\n // DOM tree\n if ((matchingFromEl = fromNodesLookup[curToNodeKey])) {\n if (fromNextSibling === matchingFromEl) {\n // Special case for single element removals. To avoid removing the original\n // DOM node out of the tree (since that can break CSS transitions, etc.),\n // we will instead discard the current node and wait until the next\n // iteration to properly match up the keyed target element with its matching\n // element in the original tree\n isCompatible = false;\n } else {\n // We found a matching keyed element somewhere in the original DOM tree.\n // Let's move the original DOM node into the current position and morph\n // it.\n\n // NOTE: We use insertBefore instead of replaceChild because we want to go through\n // the `removeNode()` function for the node that is being discarded so that\n // all lifecycle hooks are correctly invoked\n fromEl.insertBefore(matchingFromEl, curFromNodeChild);\n\n // fromNextSibling = curFromNodeChild.nextSibling;\n\n if (curFromNodeKey) {\n // Since the node is keyed it might be matched up later so we defer\n // the actual removal to later\n addKeyedRemoval(curFromNodeKey);\n } else {\n // NOTE: we skip nested keyed nodes from being removed since there is\n // still a chance they will be matched up later\n removeNode(curFromNodeChild, fromEl, true /* skip keyed nodes */);\n }\n\n curFromNodeChild = matchingFromEl;\n curFromNodeKey = getNodeKey(curFromNodeChild);\n }\n } else {\n // The nodes are not compatible since the \"to\" node has a key and there\n // is no matching keyed node in the source tree\n isCompatible = false;\n }\n }\n } else if (curFromNodeKey) {\n // The original has a key\n isCompatible = false;\n }\n\n isCompatible = isCompatible !== false && compareNodeNames(curFromNodeChild, curToNodeChild);\n if (isCompatible) {\n // We found compatible DOM elements so transform\n // the current \"from\" node to match the current\n // target DOM node.\n // MORPH\n morphEl(curFromNodeChild, curToNodeChild);\n }\n\n } else if (curFromNodeType === TEXT_NODE || curFromNodeType == COMMENT_NODE) {\n // Both nodes being compared are Text or Comment nodes\n isCompatible = true;\n // Simply update nodeValue on the original node to\n // change the text value\n if (curFromNodeChild.nodeValue !== curToNodeChild.nodeValue) {\n curFromNodeChild.nodeValue = curToNodeChild.nodeValue;\n }\n\n }\n }\n\n if (isCompatible) {\n // Advance both the \"to\" child and the \"from\" child since we found a match\n // Nothing else to do as we already recursively called morphChildren above\n curToNodeChild = toNextSibling;\n curFromNodeChild = fromNextSibling;\n continue outer;\n }\n\n // No compatible match so remove the old node from the DOM and continue trying to find a\n // match in the original DOM. However, we only do this if the from node is not keyed\n // since it is possible that a keyed node might match up with a node somewhere else in the\n // target tree and we don't want to discard it just yet since it still might find a\n // home in the final DOM tree. After everything is done we will remove any keyed nodes\n // that didn't find a home\n if (curFromNodeKey) {\n // Since the node is keyed it might be matched up later so we defer\n // the actual removal to later\n addKeyedRemoval(curFromNodeKey);\n } else {\n // NOTE: we skip nested keyed nodes from being removed since there is\n // still a chance they will be matched up later\n removeNode(curFromNodeChild, fromEl, true /* skip keyed nodes */);\n }\n\n curFromNodeChild = fromNextSibling;\n } // END: while(curFromNodeChild) {}\n\n // If we got this far then we did not find a candidate match for\n // our \"to node\" and we exhausted all of the children \"from\"\n // nodes. Therefore, we will just append the current \"to\" node\n // to the end\n if (curToNodeKey && (matchingFromEl = fromNodesLookup[curToNodeKey]) && compareNodeNames(matchingFromEl, curToNodeChild)) {\n // MORPH\n if(!skipFrom){ addChild(fromEl, matchingFromEl); }\n morphEl(matchingFromEl, curToNodeChild);\n } else {\n var onBeforeNodeAddedResult = onBeforeNodeAdded(curToNodeChild);\n if (onBeforeNodeAddedResult !== false) {\n if (onBeforeNodeAddedResult) {\n curToNodeChild = onBeforeNodeAddedResult;\n }\n\n if (curToNodeChild.actualize) {\n curToNodeChild = curToNodeChild.actualize(fromEl.ownerDocument || doc);\n }\n addChild(fromEl, curToNodeChild);\n handleNodeAdded(curToNodeChild);\n }\n }\n\n curToNodeChild = toNextSibling;\n curFromNodeChild = fromNextSibling;\n }\n\n cleanupFromEl(fromEl, curFromNodeChild, curFromNodeKey);\n\n var specialElHandler = specialElHandlers[fromEl.nodeName];\n if (specialElHandler) {\n specialElHandler(fromEl, toEl);\n }\n } // END: morphChildren(...)\n\n var morphedNode = fromNode;\n var morphedNodeType = morphedNode.nodeType;\n var toNodeType = toNode.nodeType;\n\n if (!childrenOnly) {\n // Handle the case where we are given two DOM nodes that are not\n // compatible (e.g. <div> --> <span> or <div> --> TEXT)\n if (morphedNodeType === ELEMENT_NODE) {\n if (toNodeType === ELEMENT_NODE) {\n if (!compareNodeNames(fromNode, toNode)) {\n onNodeDiscarded(fromNode);\n morphedNode = moveChildren(fromNode, createElementNS(toNode.nodeName, toNode.namespaceURI));\n }\n } else {\n // Going from an element node to a text node\n morphedNode = toNode;\n }\n } else if (morphedNodeType === TEXT_NODE || morphedNodeType === COMMENT_NODE) { // Text or comment node\n if (toNodeType === morphedNodeType) {\n if (morphedNode.nodeValue !== toNode.nodeValue) {\n morphedNode.nodeValue = toNode.nodeValue;\n }\n\n return morphedNode;\n } else {\n // Text node to something else\n morphedNode = toNode;\n }\n }\n }\n\n if (morphedNode === toNode) {\n // The \"to node\" was not compatible with the \"from node\" so we had to\n // toss out the \"from node\" and use the \"to node\"\n onNodeDiscarded(fromNode);\n } else {\n if (toNode.isSameNode && toNode.isSameNode(morphedNode)) {\n return;\n }\n\n morphEl(morphedNode, toNode, childrenOnly);\n\n // We now need to loop over any keyed nodes that might need to be\n // removed. We only do the removal if we know that the keyed node\n // never found a match. When a keyed node is matched up we remove\n // it out of fromNodesLookup and we use fromNodesLookup to determine\n // if a keyed node has been matched up or not\n if (keyedRemovalList) {\n for (var i=0, len=keyedRemovalList.length; i<len; i++) {\n var elToRemove = fromNodesLookup[keyedRemovalList[i]];\n if (elToRemove) {\n removeNode(elToRemove, elToRemove.parentNode, false);\n }\n }\n }\n }\n\n if (!childrenOnly && morphedNode !== fromNode && fromNode.parentNode) {\n if (morphedNode.actualize) {\n morphedNode = morphedNode.actualize(fromNode.ownerDocument || doc);\n }\n // If we had to swap out the from node with a new node because the old\n // node was not compatible with the target node then we need to\n // replace the old DOM node in the original DOM tree. This is only\n // possible if the original DOM node was part of a DOM tree which\n // we know is the case if it has a parent node.\n fromNode.parentNode.replaceChild(morphedNode, fromNode);\n }\n\n return morphedNode;\n };\n}\n\nvar morphdom = morphdomFactory(morphAttrs);\n\nexport default morphdom;\n","const customEvent = (() => {\n\treturn ('CustomEvent' in window && typeof window.CustomEvent === 'function')\n\t\t? (name, data) => new CustomEvent(name, data)\n\t\t: (name, data) => {\n\t\t\tconst newEvent = document.createEvent('CustomEvent')\n\t\t\tnewEvent.initCustomEvent(name, true, true, data)\n\t\t\treturn newEvent\n\t\t}\n})()\n\nconst handler = (node, ev) => {\n\treturn function (e) {\n\t\tconst scope = this\n\t\tconst detail = e.detail || {}\n\t\tnode.__events[ev].forEach(o => {\n\t\t\to.handler.apply(scope, [e].concat(detail.args))\n\t\t})\n\t}\n}\n\nconst removeListener = (node, ev) => {\n\tif (node.__events[ev] && node.__events[ev].listener) {\n\t\tnode.removeEventListener(\n\t\t\tev,\n\t\t\tnode.__events[ev].listener,\n\t\t\t(ev == 'focus' || ev == 'blur' || ev == 'mouseenter' || ev == 'mouseleave'))\n\t\tdelete node.__events[ev]\n\t}\n}\n\nconst delegate = (node, selector, callback) => {\n\treturn function (e) {\n\n\t\tconst element = this\n\t\tconst detail = e.detail || {}\n\n\t\tlet parent = e.target\n\n\t\twhile (parent) {\n\t\t\tif (parent.matches(selector)) {\n\t\t\t\te.delegateTarget = parent\n\t\t\t\tcallback.apply(element, [e].concat(detail.args))\n\t\t\t}\n\t\t\tif (parent === node) break\n\t\t\tparent = parent.parentNode\n\t\t}\n\t}\n}\n\nexport const on = (node, ev, selectorOrCallback, callback) => {\n\n\tnode.__events = node.__events || {}\n\tnode.__events[ev] = (node.__events[ev] || [])\n\n\tif (!node.__events[ev].length) {\n\t\tconst fn = handler(node, ev)\n\t\tnode.addEventListener(\n\t\t\tev,\n\t\t\tfn,\n\t\t\t(ev == 'focus' || ev == 'blur' || ev == 'mouseenter' || ev == 'mouseleave'))\n\t\tnode.__events[ev].listener = fn\n\t}\n\n\tif (selectorOrCallback.call) {\n\t\tnode.__events[ev].push({ handler: selectorOrCallback, callback: selectorOrCallback })\n\t} else {\n\t\tnode.__events[ev].push({ handler: delegate(node, selectorOrCallback, callback), callback })\n\t}\n}\n\nexport const off = (node, ev, fn) => {\n\n\tif (fn && node.__events[ev] && node.__events[ev].length) {\n\t\tvar old = node.__events[ev]\n\t\tnode.__events[ev] = node.__events[ev].filter(function (o) { return o.callback != fn; })\n\t\tnode.__events[ev].listener = old.listener\n\t\tif (!node.__events[ev].length)\n\t\t\tremoveListener(node, ev)\n\t} else {\n\t\tremoveListener(node, ev)\n\t}\n}\n\nexport const trigger = (node, name, args) => {\n\tnode.dispatchEvent(customEvent(name, { bubbles: true, detail: args }))\n}\n","import { type Component } from '..'\nimport morphdom from 'morphdom'\n\nimport { rAF, dup, safe } from './utils'\nimport { buildtemplates } from './template-system'\nimport { on, off, trigger } from './utils/events'\nimport { publish, subscribe } from './utils/pubsub'\n\nexport default function Component( elm, { module, dependencies, templates, components }) {\n\n\tconst options = getOptions( module )\n\tconst initialState = (new Function( `return ${elm.getAttribute('html-model') || '{}'}`))()\n\tconst selector = Object.keys(components).toString()\n\n\tbuildtemplates( elm, selector, templates, components )\n\n\tconst tplid = elm.getAttribute('tplid')\n\tconst template = tplid ? templates[tplid] : null\n\tconst state = { data: module.model ? dup(module.model) : {} }\n\tstate.data = Object.assign( state.data, initialState)\n\n\tconst base: Component = {\n\t\ttemplate,\n\t\telm,\n\t\tdependencies,\n\t\tpublish,\n\t\tsubscribe,\n\n\t\tmain(fn) {\n\t\t\toptions.main = fn\n\t\t},\n\n\t\tunmount(fn) {\n\t\t\toptions.unmount = fn\n\t\t},\n\n\t\tonupdate(fn) {\n\t\t\toptions.onupdate = fn\n\t\t},\n\n\t\ton(eventName, selectorOrCallback, callback) {\n\t\t\ton(elm, eventName, selectorOrCallback, callback)\n\t\t},\n\n\t\toff(eventName, callback) {\n\t\t\toff(elm, eventName, callback)\n\t\t},\n\n\t\ttrigger(eventName, target, args) {\n\t\t\tif (target.constructor === String) {\n\t\t\t\tArray\n\t\t\t\t\t.from(elm.querySelectorAll(target))\n\t\t\t\t\t.forEach( children => trigger(children, eventName, { args: args }) )\n\t\t\t}\n\t\t\telse trigger(elm, eventName, { args: target })\n\t\t},\n\n\t\temit: ( ...args ) => {\n\t\t\ttrigger(elm, args.shift(), { args: args })\n\t\t},\n\n\t\tstate: {\n\t\t\tset( data ) {\n\t\t\t\tif (data.constructor === Function) {\n\t\t\t\t\tconst newstate = dup(state.data)\n\t\t\t\t\tdata(newstate)\n\t\t\t\t\tbase.render(newstate)\n\t\t\t\t} else {\n\t\t\t\t\tbase.render(data)\n\t\t\t\t}\n\t\t\t\treturn new Promise((resolve) => rAF(_ => rAF(() => resolve(state.data))))\n\t\t\t},\n\t\t\tget() {\n\t\t\t\treturn dup(state.data)\n\t\t\t},\n\n\t\t\tgetRaw(){\n\t\t\t\treturn state.data\n\t\t\t}\n\t\t},\n\n\t\trender(data = state.data) {\n\n\t\t\tif (!document.body.contains(elm)) {\n\t\t\t\treturn\n\t\t\t}\n\n\t\t\tstate.data = Object.assign(state.data, data)\n\n\t\t\tconst newdata = dup(state.data)\n\t\t\tconst newhtml = templates[tplid].call(Object.assign(options.view(newdata), elm.___scope___), elm, safe)\n\n\t\t\tmorphdom(elm, newhtml, morphdomOptions(elm))\n\n\t\t\trAF(_ => {\n\t\t\t\tArray\n\t\t\t\t\t.from(elm.querySelectorAll('[tplid]'))\n\t\t\t\t\t.forEach((child: any) => {\n\t\t\t\t\t\tconst props = Object.assign( child.base.state.getRaw(), data )\n\t\t\t\t\t\tchild.options.onupdate(props)\n\t\t\t\t\t\tchild.base.render(props)\n\t\t\t\t\t})\n\t\t\t})\n\t\t},\n\n\t\tinnerHTML( target, html_ ) {\n\n\t\t\tconst element = html_? target : elm\n\t\t\tconst parser = new DOMParser()\n\t\t\tconst virtual = parser.parseFromString(element.outerHTML, 'text/html')\n\t\t\tconst html = html_? html_ : target\n\n\t\t\tvirtual.body.firstElementChild.innerHTML = html as string\n\t\t\trAF( _ => morphdom(element, virtual.body.innerHTML, morphdomOptions(elm)))\n\t\t}\n\t}\n\n\treturn { base, options }\n}\n\nconst getOptions = (module) => ({\n\tmain: (a) => a,\n\tunmount: (a) => a,\n\tonupdate: (a) => a,\n\tview: module.view ? module.view : (a) => a\n})\n\nconst morphdomOptions = (_parent ) => ({\n\tonNodeAdded: onUpdates,\n\tonElUpdated: onUpdates,\n\tonBeforeElChildrenUpdated: checkStatic,\n\tonBeforeElUpdated: checkStatic\n})\n\nconst checkStatic = (node) => {\n\tif ('html-static' in node.attributes) {\n\t\treturn false\n\t}\n}\n\nconst onUpdates = (node) => {\n\tif (node.nodeType === 1) {\n\t\tif( 'scope' in node.attributes ) {\n\t\t\tnode.querySelectorAll('[tplid]').forEach( cp => {\n\t\t\t\tif( !cp.___scope___ ) {\n\t\t\t\t\tconst script = node.lastElementChild\n\t\t\t\t\tcp.___scope___ = 'scope' in script.dataset? (new Function(`return ${script.text}`))() : {}\n\t\t\t\t}\n\t\t\t})\n\t\t}\n\t\tif ( node.getAttribute('tplid') ) {\n\t\t\treturn false\n\t\t}\n\t}\n\treturn node\n}\n","import Component from './component'\nimport { purge, rAF } from './utils'\n\nexport default function Element(module, dependencies, templates, components) {\n\treturn class extends HTMLElement {\n\n\t\tbase: any\n\t\toptions: any\n\t\treturns : any\n\t\t__events: any\n\n\t\tconstructor() {\n\n\t\t\tsuper()\n\t\t\tconst { base, options } = Component(this, { module, dependencies, templates, components })\n\n\t\t\tthis.base = base\n\t\t\tthis.options = options\n\t\t\tthis.returns = module.default(base)\n\t\t}\n\n\t\tconnectedCallback() {\n\n\t\t\tthis.base.render()\n\n\t\t\tif( this.__template && this.__template.constructor === Promise ) {\n\t\t\t\tthis.__template.then( _ => {\n\t\t\t\t\tif( this.base && this.options.main) {\n\t\t\t\t\t\tconst array = this.options.main(this.base)\n\t\t\t\t\t\tif( array && array.length ){\n\t\t\t\t\t\t\tarray.forEach(f => f(this.base))\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t})\n\t\t\t\treturn\n\t\t\t}\n\n\t\t\tif( this.returns && this.returns.constructor === Promise ) {\n\t\t\t\tthis.returns.then( _ => {\n\t\t\t\t\tif( this.base && this.options.main) {\n\t\t\t\t\t\tconst array = this.options.main(this.base)\n\t\t\t\t\t\tif( array && array.length ){\n\t\t\t\t\t\t\tarray.forEach(f => f(this.base))\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t})\n\t\t\t}else {\n\t\t\t\tif( this.base && this.options.main ){\n\t\t\t\t\tconst array = this.options.main(this.base)\n\t\t\t\t\tif( array && array.length ) {\n\t\t\t\t\t\tarray.forEach(f => f(this.base))\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tdisconnectedCallback() {\n\t\t\tthis.options.unmount(this.base)\n\t\t\trAF(() => {\n\t\t\t\tif(!document.body.contains(this) ) {\n\t\t\t\t\tthis.__events? this.__events = null : null\n\t\t\t\t\tthis.base? this.base.elm = null : null\n\t\t\t\t\tthis.base? this.base = null : null\n\t\t\t\t\tpurge(this)\n\t\t\t\t}\n\t\t\t})\n\n\t\t}\n\n\t\tattributeChangedCallback() {\n\t\t\t//TODO\n\t\t}\n\t}\n}\n","import { templateConfig, buildtemplates } from './template-system'\nimport { publish, subscribe } from './utils/pubsub'\nimport { html } from './utils'\nimport Element from './element'\n\nconst templates = {}\nconst components = {}\n\nexport { html }\n\nexport default {\n\n\ttemplateConfig,\n\n\tpublish,\n\tsubscribe,\n\n\tregister( name, module, dependencies = {} ) {\n\t\tcomponents[name] = { name, module, dependencies }\n\t},\n\n\tstart( target = document.body ) {\n\t\tconst keys = Object.keys(components)\n\t\tconst selector = keys.toString()\n\t\tif( keys.length ) {\n\t\t\tbuildtemplates( target, selector, templates, components )\n\t\t\tregisterComponents()\n\t\t}\n\t}\n}\n\nconst registerComponents = () => {\n\tObject\n\t\t.values( components )\n\t\t.forEach( (component) => {\n\t\t\tconst { name, module, dependencies } = component as any\n\t\t\tif( !customElements.get(name) ){\n\t\t\t\tconst Base = Element(module, dependencies, templates, components)\n\t\t\t\tcustomElements.define(name, Base)\n\t\t\t}\n\t\t})\n}\n"],"names":["parser","DOMParser","wrap","open","node","close","_a","parentNode","insertBefore","_b","nextSibling","textarea","document","createElement","decodeHTML","text","innerHTML","value","rAF","fn","requestAnimationFrame","setTimeout","dup","o","JSON","parse","stringify","purge","d","i","l","n","a","attributes","length","name","childNodes","safe","execute","val","err","config","tags","Template","element","components","html","regexTags","RegExp","virtual","parseFromString","replace","root","querySelector","localName","Object","keys","toString","querySelectorAll","forEach","clone","cloneNode","replaceWith","htmlForeach","getAttribute","htmlFor","htmlIf","htmlInner","htmlClass","forEachInstruction","selector","split","match","varname","object","removeAttribute","element2","setAttribute","script","dataset","scope","type","appendChild","createTextNode","className","trim","body","all","key","Transpile","outerHTML","decodedHTML","Function","_","variable","buildtemplates","target","templates","concat","matches","Array","from","reverse","template","content","createTemplateId","id","c","r","Math","random","module","constructor","Promise","__template","then","htmlstring","topics","_async","publish","params","assign","topic","subscribe","method","push","filter","range","NS_XHTML","doc","HAS_TEMPLATE_SUPPORT","HAS_RANGE_SUPPORT","createRange","toElement","str","createFragmentFromTemplate","selectNode","createContextualFragment","createFragmentFromRange","fragment","createFragmentFromWrap","compareNodeNames","fromEl","toEl","fromCodeStart","toCodeStart","fromNodeName","nodeName","toNodeName","charCodeAt","toUpperCase","syncBooleanAttrProp","specialElHandlers","OPTION","parentName","hasAttribute","selected","selectedIndex","INPUT","TEXTAREA","newValue","firstChild","oldValue","nodeValue","placeholder","SELECT","optgroup","curChild","noop","defaultGetNodeKey","morphAttrs","morphdom","fromNode","toNode","attr","attrName","attrNamespaceURI","attrValue","toNodeAttrs","nodeType","namespaceURI","getAttributeNS","prefix","setAttributeNS","fromNodeAttrs","hasAttributeNS","removeAttributeNS","options","toNodeHtml","firstElementChild","getNodeKey","onBeforeNodeAdded","onNodeAdded","onBeforeElUpdated","onElUpdated","onBeforeNodeDiscarded","onNodeDiscarded","onBeforeElChildrenUpdated","skipFromChildren","addChild","parent","child","childrenOnly","fromNodesLookup","create","keyedRemovalList","addKeyedRemoval","walkDiscardedChildNodes","skipKeyedNodes","removeNode","removeChild","handleNodeAdded","el","unmatchedFromEl","replaceChild","morphEl","toElKey","curToNodeKey","curFromNodeKey","fromNextSibling","toNextSibling","matchingFromEl","skipFrom","curToNodeChild","curFromNodeChild","outer","isSameNode","curFromNodeType","isCompatible","onBeforeNodeAddedResult","actualize","ownerDocument","cleanupFromEl","specialElHandler","morphChildren","indexTree","morphedNode","morphedNodeType","toNodeType","nextChild","moveChildren","createElementNS","len","elToRemove","customEvent","window","CustomEvent","data","newEvent","createEvent","initCustomEvent","handler","ev","e","this","detail","__events","apply","args","removeListener","listener","removeEventListener","delegate","callback","delegateTarget","on","selectorOrCallback","addEventListener","call","off","old","trigger","dispatchEvent","bubbles","getOptions","main","unmount","onupdate","view","morphdomOptions","_parent","onUpdates","checkStatic","cp","___scope___","lastElementChild","Element","dependencies","HTMLElement","base","elm","initialState","tplid","state","model","eventName","String","children","emit","shift","set","newstate","render","resolve","get","getRaw","contains","newdata","newhtml","props","html_","Component","returns","default","connectedCallback","array","f","disconnectedCallback","attributeChangedCallback","index","templateConfig","newconfig","register","start","registerComponents","values","component","customElements","Base","define","literalSections","substs","raw","result","subst","lit","isArray","join"],"mappings":"6OAAM,MAAAA,EAAS,IAAIC,UAkFnB,MAAMC,EAAO,CAACC,EAAMC,EAAMC,aACpB,OAAAC,EAAAF,EAAAG,aAAYD,EAAAE,aAAaL,EAAMC,GACpC,OAAAK,EAAAL,EAAKG,aAALE,EAAiBD,aAAaH,EAAOD,EAAKM,YAAA,ECpFrCC,EAAWC,SAASC,cAAc,YAE3BC,EAAcC,IAC1BJ,EAASK,UAAYD,EACdJ,EAASM,OAGJC,EAAOC,GACfC,sBACIA,sBAAsBD,GAEtBE,WAAWF,EAAI,IAAO,IAWlBG,EAAOC,GACZC,KAAKC,MAAMD,KAAKE,UAAUH,IAIrBI,EAASC,IACrB,IAAsBC,EAAGC,EAAGC,EAAxBC,EAAIJ,EAAEK,WACV,GAAID,EACH,IAAKH,EAAIG,EAAEE,OAAS,EAAGL,GAAK,EAAGA,GAAK,EAEf,mBAATD,EADPG,EAAAC,EAAEH,GAAGM,QAERP,EAAEG,GAAK,MAKV,GADAC,EAAIJ,EAAEQ,WAGL,IADAN,EAAIE,EAAEE,OACDL,EAAI,EAAGA,EAAIC,EAAGD,GAAK,EACjBF,EAAAC,EAAEQ,WAAWP,GAErB,EAGYQ,EAAO,CAACC,EAASC,KAC1B,IAAC,OAAOD,UAAgBE,GAAK,OAAOD,GAAO,EAAE,GC5C3CE,EAAS,CACdC,KAAM,CAAC,KAAM,MAOU,SAAAC,EAASC,EAASC,GAEzC,MAAMC,EFXP,SAAkCA,EAAML,EAAQI,EAAYD,GAE3D,MAAMG,EAAY,IAAIC,OAAO,KAAKP,EAAOC,KAAK,YAAYD,EAAOC,KAAK,KAAM,KACtEO,EAAUjD,EAAOkD,gBAAgBJ,EAAKK,QAAQ,sBAAuB,IAAK,aAE1EC,EA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ACE8Q,OAAQxR,GACRc,SAAU2Q,IACV,MAAMnS,KAAEA,EAAM4E,OAAAA,EAAAA,aAAQgL,GAAiBuC,EACvC,IAAKC,eAAevB,IAAI7Q,GAAO,CAC9B,MAAMqS,EAAO1C,EAAQ/K,EAAQgL,EAAc9L,EAAWpD,GACvC0R,eAAAE,OAAOtS,EAAMqS,EAC7B,IACA,qBPYiB,CAACE,KAAoBC,KAIxC,IAAIC,EAAMF,EAAgBE,IAEtBC,EAAS,GAsBN,OApBAF,EAAAhR,SAAQ,CAACmR,EAAOjT,KAGlB,IAAAkT,EAAMH,EAAI/S,GAKVuE,MAAM4O,QAAQF,KACTA,EAAAA,EAAMG,KAAK,KAGVJ,GAAAE,EACAF,GAAAC,CAAA,IAKDD,GAAAD,EAAIA,EAAI1S,OAAO,GAElB2S,CAAA","x_google_ignoreList":[4]}
|
1
|
+
{"version":3,"file":"jails.js","sources":["../src/transpile.ts","../src/utils/index.ts","../src/template-system.ts","../src/utils/pubsub.ts","../src/utils/idiomorph.ts","../src/utils/events.ts","../src/component.ts","../src/element.ts","../src/index.ts"],"sourcesContent":["const parser = new DOMParser()\n\nexport default function Transpile(html, config) {\n\n\tconst regexTags = new RegExp(`\\\\${config.tags[0]}(.+?)\\\\${config.tags[1]}`, 'g')\n\tconst virtual = parser.parseFromString(html.replace(/<\\/?template[^>]*>/g, ''), 'text/html')\n\n\tvirtual.querySelectorAll('[html-for], [html-if], [html-inner], [html-class], [html-model]').forEach((element) => {\n\n\t\tconst htmlForeach = element.getAttribute('html-foreach')\n\t\tconst htmlFor \t= element.getAttribute('html-for')\n\t\tconst htmlIf \t= element.getAttribute('html-if')\n\t\tconst htmlInner = element.getAttribute('html-inner')\n\t\tconst htmlClass = element.getAttribute('html-class')\n\t\tconst forEachInstruction = htmlFor || htmlForeach\n\n\t\tif ( forEachInstruction ) {\n\t\t\tconst selector = htmlFor? 'html-for': 'html-foreach'\n\t\t\tconst split = forEachInstruction.match(/(.*)\\sin\\s(.*)/) || ''\n\t\t\tconst varname = split[1]\n\t\t\tconst object = split[2]\n\n\t\t\telement.removeAttribute(selector)\n\t\t\telement.setAttribute('scope', '')\n\t\t\tconst script = document.createElement('script')\n\n\t\t\tscript.dataset.scope = ''\n\t\t\tscript.type = 'text/html'\n\t\t\tscript.text = `%%_= $scope _%%`\n\n\t\t\telement.appendChild( script )\n\n\t\t\tconst open = document.createTextNode(`%%_(function(){ var $index = 0; for(var $key in safe(function(){ return ${object} }) ){ var ${varname} = ${object}[$key]; var $scope = JSON.stringify({ '${varname}':${varname}, $index: $index, $key:$key }); _%%`)\n\t\t\tconst close = document.createTextNode(`%%_ $index++; } })() _%%`)\n\t\t\twrap(open, element, close)\n\t\t}\n\t\tif (htmlIf) {\n\t\t\telement.removeAttribute('html-if')\n\t\t\tconst open = document.createTextNode(`%%_ if ( safe(function(){ return ${htmlIf} }) ){ _%%`)\n\t\t\tconst close = document.createTextNode(`%%_ } _%%`)\n\t\t\twrap(open, element, close)\n\t\t}\n\t\tif (htmlInner) {\n\t\t\telement.removeAttribute('html-inner')\n\t\t\telement.innerHTML = `%%_=${htmlInner}_%%`\n\t\t}\n\t\tif (htmlClass) {\n\t\t\telement.removeAttribute('html-class')\n\t\t\telement.className = (element.className + ` %%_=${htmlClass}_%%`).trim()\n\t\t}\n\t})\n\n\n\treturn (\n\t\tvirtual.body.innerHTML\n\t\t\t.replace(regexTags, '%%_=$1_%%')\n\t\t\t// Booleans\n\t\t\t// https://meiert.com/en/blog/boolean-attributes-of-html/\n\t\t\t.replace(/html-(allowfullscreen|async|autofocus|autoplay|checked|controls|default|defer|disabled|formnovalidate|inert|ismap|itemscope|loop|multiple|muted|nomodule|novalidate|open|playsinline|readonly|required|reversed|selected)=\\\"(.*?)\\\"/g, `%%_if(safe(function(){ return $2 })){_%%$1%%_}_%%`)\n\t\t\t// The rest\n\t\t\t.replace(/html-(.*?)=\\\"(.*?)\\\"/g, (all, key, value) => {\n\t\t\t\tif (key === 'key' || key === 'model' || key == 'scope') {\n\t\t\t\t\treturn all\n\t\t\t\t}\n\t\t\t\tif (value) {\n\t\t\t\t\tvalue = value.replace(/^{|}$/g, '')\n\t\t\t\t\treturn `${key}=\"%%_=safe(function(){ return ${value} })_%%\"`\n\t\t\t\t} else {\n\t\t\t\t\treturn all\n\t\t\t\t}\n\t\t\t})\n\t)\n}\n\nconst wrap = (open, node, close) => {\n\tnode.parentNode?.insertBefore(open, node)\n\tnode.parentNode?.insertBefore(close, node.nextSibling)\n}\n","const textarea = document.createElement('textarea')\n\nexport const decodeHTML = (text) => {\n\ttextarea.innerHTML = text\n\treturn textarea.value\n}\n\nexport const rAF = (fn) => {\n\tif (requestAnimationFrame)\n\t\treturn requestAnimationFrame(fn)\n\telse\n\t\treturn setTimeout(fn, 1000 / 60)\n}\n\nexport const uuid = () => {\n\treturn 'xxxxxxxx'.replace(/[xy]/g, (c) => {\n\t\tconst r = Math.random() * 8 | 0, v = c == 'x' ? r : (r & 0x3 | 0x8)\n\t\treturn v.toString(8)\n\t})\n}\n\n\nexport const dup = (o) => {\n\treturn JSON.parse(JSON.stringify(o))\n}\n\n// http://crockford.com/javascript/memory/leak.html\nexport const purge = (d) => {\n\tvar a = d.attributes, i, l, n\n\tif (a) {\n\t\tfor (i = a.length - 1; i >= 0; i -= 1) {\n\t\t\tn = a[i].name\n\t\t\tif (typeof d[n] === 'function') {\n\t\t\t\td[n] = null\n\t\t\t}\n\t\t}\n\t}\n\ta = d.childNodes\n\tif (a) {\n\t\tl = a.length\n\t\tfor (i = 0; i < l; i += 1) {\n\t\t\tpurge(d.childNodes[i])\n\t\t}\n\t}\n}\n\nexport const safe = (execute, val) => {\n\ttry{return execute()}catch(err){return val || ''}\n}\n\n// From\n// https://2ality.com/2015/01/template-strings-html.html#comment-2078932192\nexport const html = (literalSections, ...substs) => {\n\n\t// Use raw literal sections: we don’t want\n\t// backslashes (\\n etc.) to be interpreted\n\tlet raw = literalSections.raw\n\n\tlet result = ''\n\n\tsubsts.forEach((subst, i) => {\n\t\t// Retrieve the literal section preceding\n\t\t// the current substitution\n\t\tlet lit = raw[i]\n\n\t\t// In the example, map() returns an array:\n\t\t// If substitution is an array (and not a string),\n\t\t// we turn it into a string\n\t\tif (Array.isArray(subst)) {\n\t\t\tsubst = subst.join('')\n\t\t}\n\n\t\tresult += lit\n\t\tresult += subst\n\t})\n\t// Take care of last literal section\n\t// (Never fails, because an empty template string\n\t// produces one literal section, an empty string)\n\tresult += raw[raw.length-1] // (A)\n\n\treturn result\n}\n","import Transpile from './transpile'\nimport { uuid, decodeHTML } from './utils'\n\nconst config = {\n\ttags: ['${', '}']\n}\n\nexport const templateConfig = (newconfig) => {\n\tObject.assign(config, newconfig)\n}\n\nexport default function Template(element) {\n\n\tconst html = Transpile(element.outerHTML, config)\n\tconst decodedHTML = JSON.stringify(html)\n\n\treturn new Function('$element', 'safe',`\n\t\tvar $data = this;\n\t\twith( $data ){\n\t\t\tvar output=${decodedHTML\n\t\t\t\t.replace(/%%_=(.+?)_%%/g, function(_, variable){\n\t\t\t\t\treturn '\"+safe(function(){return '+decodeHTML(variable)+';})+\"'\n\t\t\t\t})\n\t\t\t\t.replace(/%%_(.+?)_%%/g, function(_, variable){\n\t\t\t\t\treturn '\";' + decodeHTML(variable) +'\\noutput+=\"'\n\t\t\t\t})};return output;\n\t\t}\n\t`)\n}\n\nexport const buildtemplates = ( target, selector, templates, components ) => {\n\t[]\n\t\t.concat( target.matches? (target.matches(selector)? target : []) : [] )\n\t\t.concat( Array.from(target.querySelectorAll( selector )) )\n\t\t.reverse()\n\t\t.forEach( (node:HTMLElement) => {\n\t\t\tnode.querySelectorAll('template').forEach( template => buildtemplates(template.content, selector, templates, components ))\n\t\t\tcreateTemplateId(node, templates, components)\n\t\t})\n}\n\nconst createTemplateId = (element, templates, components ) => {\n\n\tconst tplid = element.getAttribute('tplid')\n\n\tif (!tplid) {\n\t\tconst id = uuid()\n\t\telement.setAttribute('tplid', id)\n\t\tconst name = element.localName\n\n\t\tif( name in components && components[name].module.template ) {\n\t\t\tconst html = components[name].module.template()\n\t\t\tif( html.constructor === Promise ) {\n\t\t\t\telement.__template = html\n\t\t\t\thtml.then( htmlstring => {\n\t\t\t\t\telement.innerHTML = htmlstring\n\t\t\t\t\ttemplates[id] = Template(element)\n\t\t\t\t})\n\t\t\t}else {\n\t\t\t\telement.innerHTML = html\n\t\t\t}\n\t\t}\n\t\ttemplates[id] = Template(element)\n\t}\n}\n\n","const topics: any = {}\nconst _async: any = {}\n\nexport const publish = (name, params) => {\n\t_async[name] = Object.assign({}, _async[name], params)\n\tif (topics[name])\n\t\ttopics[name].forEach(topic => topic(params))\n}\n\nexport const subscribe = (name, method) => {\n\ttopics[name] = topics[name] || []\n\ttopics[name].push(method)\n\tif (name in _async) {\n\t\tmethod(_async[name])\n\t}\n\treturn () => {\n\t\ttopics[name] = topics[name].filter( fn => fn != method )\n\t}\n}\n\n","/**\n * BSD 2-Clause License\n * https://github.com/bigskysoftware/idiomorph\n\n\tCopyright (c) 2022, Big Sky Software\n\tAll rights reserved.\n\n\tRedistribution and use in source and binary forms, with or without\n\tmodification, are permitted provided that the following conditions are met:\n\n\t1. Redistributions of source code must retain the above copyright notice, this\n\tlist of conditions and the following disclaimer.\n\n\t2. Redistributions in binary form must reproduce the above copyright notice,\n\tthis list of conditions and the following disclaimer in the documentation\n\tand/or other materials provided with the distribution.\n\n\tTHIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\"\n\tAND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n\tIMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n\tDISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE\n\tFOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL\n\tDAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR\n\tSERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER\n\tCAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,\n\tOR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n\tOF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n */\n\n// base IIFE to define idiomorph\n\n\nexport const Idiomorph = (function () {\n\t'use strict';\n\n\t//=============================================================================\n\t// AND NOW IT BEGINS...\n\t//=============================================================================\n\tlet EMPTY_SET = new Set();\n\n\t// default configuration values, updatable by users now\n\tlet defaults = {\n\t\tmorphStyle: \"outerHTML\",\n\t\tcallbacks : {\n\t\t\tbeforeNodeAdded: noOp,\n\t\t\tafterNodeAdded: noOp,\n\t\t\tbeforeNodeMorphed: noOp,\n\t\t\tafterNodeMorphed: noOp,\n\t\t\tbeforeNodeRemoved: noOp,\n\t\t\tafterNodeRemoved: noOp,\n\t\t\tbeforeAttributeUpdated: noOp,\n\n\t\t},\n\t\thead: {\n\t\t\tstyle: 'merge',\n\t\t\tshouldPreserve: function (elt) {\n\t\t\t\treturn elt.getAttribute(\"im-preserve\") === \"true\";\n\t\t\t},\n\t\t\tshouldReAppend: function (elt) {\n\t\t\t\treturn elt.getAttribute(\"im-re-append\") === \"true\";\n\t\t\t},\n\t\t\tshouldRemove: noOp,\n\t\t\tafterHeadMorphed: noOp,\n\t\t}\n\t};\n\n\t//=============================================================================\n\t// Core Morphing Algorithm - morph, morphNormalizedContent, morphOldNodeTo, morphChildren\n\t//=============================================================================\n\tfunction morph(oldNode, newContent, config = {}) {\n\n\t\tif (oldNode instanceof Document) {\n\t\t\toldNode = oldNode.documentElement;\n\t\t}\n\n\t\tif (typeof newContent === 'string') {\n\t\t\tnewContent = parseContent(newContent);\n\t\t}\n\n\t\tlet normalizedContent = normalizeContent(newContent);\n\n\t\tlet ctx = createMorphContext(oldNode, normalizedContent, config);\n\n\t\treturn morphNormalizedContent(oldNode, normalizedContent, ctx);\n\t}\n\n\tfunction morphNormalizedContent(oldNode, normalizedNewContent, ctx) {\n\t\tif (ctx.head.block) {\n\t\t\tlet oldHead = oldNode.querySelector('head');\n\t\t\tlet newHead = normalizedNewContent.querySelector('head');\n\t\t\tif (oldHead && newHead) {\n\t\t\t\tlet promises = handleHeadElement(newHead, oldHead, ctx);\n\t\t\t\t// when head promises resolve, call morph again, ignoring the head tag\n\t\t\t\tPromise.all(promises).then(function () {\n\t\t\t\t\tmorphNormalizedContent(oldNode, normalizedNewContent, Object.assign(ctx, {\n\t\t\t\t\t\thead: {\n\t\t\t\t\t\t\tblock: false,\n\t\t\t\t\t\t\tignore: true\n\t\t\t\t\t\t}\n\t\t\t\t\t}));\n\t\t\t\t});\n\t\t\t\treturn;\n\t\t\t}\n\t\t}\n\n\t\tif (ctx.morphStyle === \"innerHTML\") {\n\n\t\t\t// innerHTML, so we are only updating the children\n\t\t\tmorphChildren(normalizedNewContent, oldNode, ctx);\n\t\t\treturn oldNode.children;\n\n\t\t} else if (ctx.morphStyle === \"outerHTML\" || ctx.morphStyle == null) {\n\t\t\t// otherwise find the best element match in the new content, morph that, and merge its siblings\n\t\t\t// into either side of the best match\n\t\t\tlet bestMatch = findBestNodeMatch(normalizedNewContent, oldNode, ctx);\n\n\t\t\t// stash the siblings that will need to be inserted on either side of the best match\n\t\t\tlet previousSibling = bestMatch?.previousSibling;\n\t\t\tlet nextSibling = bestMatch?.nextSibling;\n\n\t\t\t// morph it\n\t\t\tlet morphedNode = morphOldNodeTo(oldNode, bestMatch, ctx);\n\n\t\t\tif (bestMatch) {\n\t\t\t\t// if there was a best match, merge the siblings in too and return the\n\t\t\t\t// whole bunch\n\t\t\t\treturn insertSiblings(previousSibling, morphedNode, nextSibling);\n\t\t\t} else {\n\t\t\t\t// otherwise nothing was added to the DOM\n\t\t\t\treturn []\n\t\t\t}\n\t\t} else {\n\t\t\tthrow \"Do not understand how to morph style \" + ctx.morphStyle;\n\t\t}\n\t}\n\n\n\t/**\n\t * @param possibleActiveElement\n\t * @param ctx\n\t * @returns {boolean}\n\t */\n\tfunction ignoreValueOfActiveElement(possibleActiveElement, ctx) {\n\t\treturn ctx.ignoreActiveValue && possibleActiveElement === document.activeElement;\n\t}\n\n\t/**\n\t * @param oldNode root node to merge content into\n\t * @param newContent new content to merge\n\t * @param ctx the merge context\n\t * @returns {Element} the element that ended up in the DOM\n\t */\n\tfunction morphOldNodeTo(oldNode, newContent, ctx) {\n\t\tif (ctx.ignoreActive && oldNode === document.activeElement) {\n\t\t\t// don't morph focused element\n\t\t} else if (newContent == null) {\n\t\t\tif (ctx.callbacks.beforeNodeRemoved(oldNode) === false) return oldNode;\n\n\t\t\toldNode.remove();\n\t\t\tctx.callbacks.afterNodeRemoved(oldNode);\n\t\t\treturn null;\n\t\t} else if (!isSoftMatch(oldNode, newContent)) {\n\t\t\tif (ctx.callbacks.beforeNodeRemoved(oldNode) === false) return oldNode;\n\t\t\tif (ctx.callbacks.beforeNodeAdded(newContent) === false) return oldNode;\n\n\t\t\toldNode.parentElement.replaceChild(newContent, oldNode);\n\t\t\tctx.callbacks.afterNodeAdded(newContent);\n\t\t\tctx.callbacks.afterNodeRemoved(oldNode);\n\t\t\treturn newContent;\n\t\t} else {\n\t\t\tif (ctx.callbacks.beforeNodeMorphed(oldNode, newContent) === false) return oldNode;\n\n\t\t\tif (oldNode instanceof HTMLHeadElement && ctx.head.ignore) {\n\t\t\t\t// ignore the head element\n\t\t\t} else if (oldNode instanceof HTMLHeadElement && ctx.head.style !== \"morph\") {\n\t\t\t\thandleHeadElement(newContent, oldNode, ctx);\n\t\t\t} else {\n\t\t\t\tsyncNodeFrom(newContent, oldNode, ctx);\n\t\t\t\tif (!ignoreValueOfActiveElement(oldNode, ctx)) {\n\t\t\t\t\tmorphChildren(newContent, oldNode, ctx);\n\t\t\t\t}\n\t\t\t}\n\t\t\tctx.callbacks.afterNodeMorphed(oldNode, newContent);\n\t\t\treturn oldNode;\n\t\t}\n\t}\n\n\t/**\n\t * This is the core algorithm for matching up children. The idea is to use id sets to try to match up\n\t * nodes as faithfully as possible. We greedily match, which allows us to keep the algorithm fast, but\n\t * by using id sets, we are able to better match up with content deeper in the DOM.\n\t *\n\t * Basic algorithm is, for each node in the new content:\n\t *\n\t * - if we have reached the end of the old parent, append the new content\n\t * - if the new content has an id set match with the current insertion point, morph\n\t * - search for an id set match\n\t * - if id set match found, morph\n\t * - otherwise search for a \"soft\" match\n\t * - if a soft match is found, morph\n\t * - otherwise, prepend the new node before the current insertion point\n\t *\n\t * The two search algorithms terminate if competing node matches appear to outweigh what can be achieved\n\t * with the current node. See findIdSetMatch() and findSoftMatch() for details.\n\t *\n\t * @param {Element} newParent the parent element of the new content\n\t * @param {Element } oldParent the old content that we are merging the new content into\n\t * @param ctx the merge context\n\t */\n\tfunction morphChildren(newParent, oldParent, ctx) {\n\n\t\tlet nextNewChild = newParent.firstChild;\n\t\tlet insertionPoint = oldParent.firstChild;\n\t\tlet newChild;\n\n\t\t// run through all the new content\n\t\twhile (nextNewChild) {\n\n\t\t\tnewChild = nextNewChild;\n\t\t\tnextNewChild = newChild.nextSibling;\n\n\t\t\t// if we are at the end of the exiting parent's children, just append\n\t\t\tif (insertionPoint == null) {\n\t\t\t\tif (ctx.callbacks.beforeNodeAdded(newChild) === false) return;\n\n\t\t\t\toldParent.appendChild(newChild);\n\t\t\t\tctx.callbacks.afterNodeAdded(newChild);\n\t\t\t\tremoveIdsFromConsideration(ctx, newChild);\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\t// if the current node has an id set match then morph\n\t\t\tif (isIdSetMatch(newChild, insertionPoint, ctx)) {\n\t\t\t\tmorphOldNodeTo(insertionPoint, newChild, ctx);\n\t\t\t\tinsertionPoint = insertionPoint.nextSibling;\n\t\t\t\tremoveIdsFromConsideration(ctx, newChild);\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\t// otherwise search forward in the existing old children for an id set match\n\t\t\tlet idSetMatch = findIdSetMatch(newParent, oldParent, newChild, insertionPoint, ctx);\n\n\t\t\t// if we found a potential match, remove the nodes until that point and morph\n\t\t\tif (idSetMatch) {\n\t\t\t\tinsertionPoint = removeNodesBetween(insertionPoint, idSetMatch, ctx);\n\t\t\t\tmorphOldNodeTo(idSetMatch, newChild, ctx);\n\t\t\t\tremoveIdsFromConsideration(ctx, newChild);\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\t// no id set match found, so scan forward for a soft match for the current node\n\t\t\tlet softMatch = findSoftMatch(newParent, oldParent, newChild, insertionPoint, ctx);\n\n\t\t\t// if we found a soft match for the current node, morph\n\t\t\tif (softMatch) {\n\t\t\t\tinsertionPoint = removeNodesBetween(insertionPoint, softMatch, ctx);\n\t\t\t\tmorphOldNodeTo(softMatch, newChild, ctx);\n\t\t\t\tremoveIdsFromConsideration(ctx, newChild);\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\t// abandon all hope of morphing, just insert the new child before the insertion point\n\t\t\t// and move on\n\t\t\tif (ctx.callbacks.beforeNodeAdded(newChild) === false) return;\n\n\t\t\toldParent.insertBefore(newChild, insertionPoint);\n\t\t\tctx.callbacks.afterNodeAdded(newChild);\n\t\t\tremoveIdsFromConsideration(ctx, newChild);\n\t\t}\n\n\t\t// remove any remaining old nodes that didn't match up with new content\n\t\twhile (insertionPoint !== null) {\n\n\t\t\tlet tempNode = insertionPoint;\n\t\t\tinsertionPoint = insertionPoint.nextSibling;\n\t\t\tremoveNode(tempNode, ctx);\n\t\t}\n\t}\n\n\t//=============================================================================\n\t// Attribute Syncing Code\n\t//=============================================================================\n\n\t/**\n\t * @param attr {String} the attribute to be mutated\n\t * @param to {Element} the element that is going to be updated\n\t * @param updateType {(\"update\"|\"remove\")}\n\t * @param ctx the merge context\n\t * @returns {boolean} true if the attribute should be ignored, false otherwise\n\t */\n\tfunction ignoreAttribute(attr, to, updateType, ctx) {\n\t\tif(attr === 'value' && ctx.ignoreActiveValue && to === document.activeElement){\n\t\t\treturn true;\n\t\t}\n\t\treturn ctx.callbacks.beforeAttributeUpdated(attr, to, updateType) === false;\n\t}\n\n\t/**\n\t * syncs a given node with another node, copying over all attributes and\n\t * inner element state from the 'from' node to the 'to' node\n\t *\n\t * @param {Element} from the element to copy attributes & state from\n\t * @param {Element} to the element to copy attributes & state to\n\t * @param ctx the merge context\n\t */\n\tfunction syncNodeFrom(from, to, ctx) {\n\t\tlet type = from.nodeType\n\n\t\t// if is an element type, sync the attributes from the\n\t\t// new node into the new node\n\t\tif (type === 1 /* element type */) {\n\t\t\tconst fromAttributes = from.attributes;\n\t\t\tconst toAttributes = to.attributes;\n\t\t\tfor (const fromAttribute of fromAttributes) {\n\t\t\t\tif (ignoreAttribute(fromAttribute.name, to, 'update', ctx)) {\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\tif (to.getAttribute(fromAttribute.name) !== fromAttribute.value) {\n\t\t\t\t\tto.setAttribute(fromAttribute.name, fromAttribute.value);\n\t\t\t\t}\n\t\t\t}\n\t\t\t// iterate backwards to avoid skipping over items when a delete occurs\n\t\t\tfor (let i = toAttributes.length - 1; 0 <= i; i--) {\n\t\t\t\tconst toAttribute = toAttributes[i];\n\t\t\t\tif (ignoreAttribute(toAttribute.name, to, 'remove', ctx)) {\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\tif (!from.hasAttribute(toAttribute.name)) {\n\t\t\t\t\tto.removeAttribute(toAttribute.name);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\t// sync text nodes\n\t\tif (type === 8 /* comment */ || type === 3 /* text */) {\n\t\t\tif (to.nodeValue !== from.nodeValue) {\n\t\t\t\tto.nodeValue = from.nodeValue;\n\t\t\t}\n\t\t}\n\n\t\tif (!ignoreValueOfActiveElement(to, ctx)) {\n\t\t\t// sync input values\n\t\t\tsyncInputValue(from, to, ctx);\n\t\t}\n\t}\n\n\t/**\n\t * @param from {Element} element to sync the value from\n\t * @param to {Element} element to sync the value to\n\t * @param attributeName {String} the attribute name\n\t * @param ctx the merge context\n\t */\n\tfunction syncBooleanAttribute(from, to, attributeName, ctx) {\n\t\tif (from[attributeName] !== to[attributeName]) {\n\t\t\tlet ignoreUpdate = ignoreAttribute(attributeName, to, 'update', ctx);\n\t\t\tif (!ignoreUpdate) {\n\t\t\t\tto[attributeName] = from[attributeName];\n\t\t\t}\n\t\t\tif (from[attributeName]) {\n\t\t\t\tif (!ignoreUpdate) {\n\t\t\t\t\tto.setAttribute(attributeName, from[attributeName]);\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tif (!ignoreAttribute(attributeName, to, 'remove', ctx)) {\n\t\t\t\t\tto.removeAttribute(attributeName);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * NB: many bothans died to bring us information:\n\t *\n\t * https://github.com/patrick-steele-idem/morphdom/blob/master/src/specialElHandlers.js\n\t * https://github.com/choojs/nanomorph/blob/master/lib/morph.jsL113\n\t *\n\t * @param from {Element} the element to sync the input value from\n\t * @param to {Element} the element to sync the input value to\n\t * @param ctx the merge context\n\t */\n\tfunction syncInputValue(from, to, ctx) {\n\t\tif (from instanceof HTMLInputElement &&\n\t\t\tto instanceof HTMLInputElement &&\n\t\t\tfrom.type !== 'file') {\n\n\t\t\tlet fromValue = from.value;\n\t\t\tlet toValue = to.value;\n\n\t\t\t// sync boolean attributes\n\t\t\tsyncBooleanAttribute(from, to, 'checked', ctx);\n\t\t\tsyncBooleanAttribute(from, to, 'disabled', ctx);\n\n\t\t\tif (!from.hasAttribute('value')) {\n\t\t\t\tif (!ignoreAttribute('value', to, 'remove', ctx)) {\n\t\t\t\t\tto.value = '';\n\t\t\t\t\tto.removeAttribute('value');\n\t\t\t\t}\n\t\t\t} else if (fromValue !== toValue) {\n\t\t\t\tif (!ignoreAttribute('value', to, 'update', ctx)) {\n\t\t\t\t\tto.setAttribute('value', fromValue);\n\t\t\t\t\tto.value = fromValue;\n\t\t\t\t}\n\t\t\t}\n\t\t} else if (from instanceof HTMLOptionElement) {\n\t\t\tsyncBooleanAttribute(from, to, 'selected', ctx)\n\t\t} else if (from instanceof HTMLTextAreaElement && to instanceof HTMLTextAreaElement) {\n\t\t\tlet fromValue = from.value;\n\t\t\tlet toValue = to.value;\n\t\t\tif (ignoreAttribute('value', to, 'update', ctx)) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (fromValue !== toValue) {\n\t\t\t\tto.value = fromValue;\n\t\t\t}\n\t\t\tif (to.firstChild && to.firstChild.nodeValue !== fromValue) {\n\t\t\t\tto.firstChild.nodeValue = fromValue\n\t\t\t}\n\t\t}\n\t}\n\n\t//=============================================================================\n\t// the HEAD tag can be handled specially, either w/ a 'merge' or 'append' style\n\t//=============================================================================\n\tfunction handleHeadElement(newHeadTag, currentHead, ctx) {\n\n\t\tlet added = []\n\t\tlet removed = []\n\t\tlet preserved = []\n\t\tlet nodesToAppend = []\n\n\t\tlet headMergeStyle = ctx.head.style;\n\n\t\t// put all new head elements into a Map, by their outerHTML\n\t\tlet srcToNewHeadNodes = new Map();\n\t\tfor (const newHeadChild of newHeadTag.children) {\n\t\t\tsrcToNewHeadNodes.set(newHeadChild.outerHTML, newHeadChild);\n\t\t}\n\n\t\t// for each elt in the current head\n\t\tfor (const currentHeadElt of currentHead.children) {\n\n\t\t\t// If the current head element is in the map\n\t\t\tlet inNewContent = srcToNewHeadNodes.has(currentHeadElt.outerHTML);\n\t\t\tlet isReAppended = ctx.head.shouldReAppend(currentHeadElt);\n\t\t\tlet isPreserved = ctx.head.shouldPreserve(currentHeadElt);\n\t\t\tif (inNewContent || isPreserved) {\n\t\t\t\tif (isReAppended) {\n\t\t\t\t\t// remove the current version and let the new version replace it and re-execute\n\t\t\t\t\tremoved.push(currentHeadElt);\n\t\t\t\t} else {\n\t\t\t\t\t// this element already exists and should not be re-appended, so remove it from\n\t\t\t\t\t// the new content map, preserving it in the DOM\n\t\t\t\t\tsrcToNewHeadNodes.delete(currentHeadElt.outerHTML);\n\t\t\t\t\tpreserved.push(currentHeadElt);\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tif (headMergeStyle === \"append\") {\n\t\t\t\t\t// we are appending and this existing element is not new content\n\t\t\t\t\t// so if and only if it is marked for re-append do we do anything\n\t\t\t\t\tif (isReAppended) {\n\t\t\t\t\t\tremoved.push(currentHeadElt);\n\t\t\t\t\t\tnodesToAppend.push(currentHeadElt);\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\t// if this is a merge, we remove this content since it is not in the new head\n\t\t\t\t\tif (ctx.head.shouldRemove(currentHeadElt) !== false) {\n\t\t\t\t\t\tremoved.push(currentHeadElt);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\t// Push the remaining new head elements in the Map into the\n\t\t// nodes to append to the head tag\n\t\tnodesToAppend.push(...srcToNewHeadNodes.values());\n\t\tlog(\"to append: \", nodesToAppend);\n\n\t\tlet promises = [];\n\t\tfor (const newNode of nodesToAppend) {\n\t\t\tlog(\"adding: \", newNode);\n\t\t\tlet newElt = document.createRange().createContextualFragment(newNode.outerHTML).firstChild;\n\t\t\tlog(newElt);\n\t\t\tif (ctx.callbacks.beforeNodeAdded(newElt) !== false) {\n\t\t\t\tif (newElt.href || newElt.src) {\n\t\t\t\t\tlet resolve = null;\n\t\t\t\t\tlet promise = new Promise(function (_resolve) {\n\t\t\t\t\t\tresolve = _resolve;\n\t\t\t\t\t});\n\t\t\t\t\tnewElt.addEventListener('load', function () {\n\t\t\t\t\t\tresolve();\n\t\t\t\t\t});\n\t\t\t\t\tpromises.push(promise);\n\t\t\t\t}\n\t\t\t\tcurrentHead.appendChild(newElt);\n\t\t\t\tctx.callbacks.afterNodeAdded(newElt);\n\t\t\t\tadded.push(newElt);\n\t\t\t}\n\t\t}\n\n\t\t// remove all removed elements, after we have appended the new elements to avoid\n\t\t// additional network requests for things like style sheets\n\t\tfor (const removedElement of removed) {\n\t\t\tif (ctx.callbacks.beforeNodeRemoved(removedElement) !== false) {\n\t\t\t\tcurrentHead.removeChild(removedElement);\n\t\t\t\tctx.callbacks.afterNodeRemoved(removedElement);\n\t\t\t}\n\t\t}\n\n\t\tctx.head.afterHeadMorphed(currentHead, {added: added, kept: preserved, removed: removed});\n\t\treturn promises;\n\t}\n\n\t//=============================================================================\n\t// Misc\n\t//=============================================================================\n\n\tfunction log() {\n\t\t//console.log(arguments);\n\t}\n\n\tfunction noOp() {\n\t}\n\n\t/*\n\t Deep merges the config object and the Idiomoroph.defaults object to\n\t produce a final configuration object\n\t */\n\tfunction mergeDefaults(config) {\n\t\tlet finalConfig = {};\n\t\t// copy top level stuff into final config\n\t\tObject.assign(finalConfig, defaults);\n\t\tObject.assign(finalConfig, config);\n\n\t\t// copy callbacks into final config (do this to deep merge the callbacks)\n\t\tfinalConfig.callbacks = {};\n\t\tObject.assign(finalConfig.callbacks, defaults.callbacks);\n\t\tObject.assign(finalConfig.callbacks, config.callbacks);\n\n\t\t// copy head config into final config (do this to deep merge the head)\n\t\tfinalConfig.head = {};\n\t\tObject.assign(finalConfig.head, defaults.head);\n\t\tObject.assign(finalConfig.head, config.head);\n\t\treturn finalConfig;\n\t}\n\n\tfunction createMorphContext(oldNode, newContent, config) {\n\t\tconfig = mergeDefaults(config);\n\t\treturn {\n\t\t\ttarget: oldNode,\n\t\t\tnewContent: newContent,\n\t\t\tconfig: config,\n\t\t\tmorphStyle: config.morphStyle,\n\t\t\tignoreActive: config.ignoreActive,\n\t\t\tignoreActiveValue: config.ignoreActiveValue,\n\t\t\tidMap: createIdMap(oldNode, newContent),\n\t\t\tdeadIds: new Set(),\n\t\t\tcallbacks: config.callbacks,\n\t\t\thead: config.head\n\t\t}\n\t}\n\n\tfunction isIdSetMatch(node1, node2, ctx) {\n\t\tif (node1 == null || node2 == null) {\n\t\t\treturn false;\n\t\t}\n\t\tif (node1.nodeType === node2.nodeType && node1.tagName === node2.tagName) {\n\t\t\tif (node1.id !== \"\" && node1.id === node2.id) {\n\t\t\t\treturn true;\n\t\t\t} else {\n\t\t\t\treturn getIdIntersectionCount(ctx, node1, node2) > 0;\n\t\t\t}\n\t\t}\n\t\treturn false;\n\t}\n\n\tfunction isSoftMatch(node1, node2) {\n\t\tif (node1 == null || node2 == null) {\n\t\t\treturn false;\n\t\t}\n\t\treturn node1.nodeType === node2.nodeType && node1.tagName === node2.tagName\n\t}\n\n\tfunction removeNodesBetween(startInclusive, endExclusive, ctx) {\n\t\twhile (startInclusive !== endExclusive) {\n\t\t\tlet tempNode = startInclusive;\n\t\t\tstartInclusive = startInclusive.nextSibling;\n\t\t\tremoveNode(tempNode, ctx);\n\t\t}\n\t\tremoveIdsFromConsideration(ctx, endExclusive);\n\t\treturn endExclusive.nextSibling;\n\t}\n\n\t//=============================================================================\n\t// Scans forward from the insertionPoint in the old parent looking for a potential id match\n\t// for the newChild. We stop if we find a potential id match for the new child OR\n\t// if the number of potential id matches we are discarding is greater than the\n\t// potential id matches for the new child\n\t//=============================================================================\n\tfunction findIdSetMatch(newContent, oldParent, newChild, insertionPoint, ctx) {\n\n\t\t// max id matches we are willing to discard in our search\n\t\tlet newChildPotentialIdCount = getIdIntersectionCount(ctx, newChild, oldParent);\n\n\t\tlet potentialMatch = null;\n\n\t\t// only search forward if there is a possibility of an id match\n\t\tif (newChildPotentialIdCount > 0) {\n\t\t\tlet potentialMatch = insertionPoint;\n\t\t\t// if there is a possibility of an id match, scan forward\n\t\t\t// keep track of the potential id match count we are discarding (the\n\t\t\t// newChildPotentialIdCount must be greater than this to make it likely\n\t\t\t// worth it)\n\t\t\tlet otherMatchCount = 0;\n\t\t\twhile (potentialMatch != null) {\n\n\t\t\t\t// If we have an id match, return the current potential match\n\t\t\t\tif (isIdSetMatch(newChild, potentialMatch, ctx)) {\n\t\t\t\t\treturn potentialMatch;\n\t\t\t\t}\n\n\t\t\t\t// computer the other potential matches of this new content\n\t\t\t\totherMatchCount += getIdIntersectionCount(ctx, potentialMatch, newContent);\n\t\t\t\tif (otherMatchCount > newChildPotentialIdCount) {\n\t\t\t\t\t// if we have more potential id matches in _other_ content, we\n\t\t\t\t\t// do not have a good candidate for an id match, so return null\n\t\t\t\t\treturn null;\n\t\t\t\t}\n\n\t\t\t\t// advanced to the next old content child\n\t\t\t\tpotentialMatch = potentialMatch.nextSibling;\n\t\t\t}\n\t\t}\n\t\treturn potentialMatch;\n\t}\n\n\t//=============================================================================\n\t// Scans forward from the insertionPoint in the old parent looking for a potential soft match\n\t// for the newChild. We stop if we find a potential soft match for the new child OR\n\t// if we find a potential id match in the old parents children OR if we find two\n\t// potential soft matches for the next two pieces of new content\n\t//=============================================================================\n\tfunction findSoftMatch(newContent, oldParent, newChild, insertionPoint, ctx) {\n\n\t\tlet potentialSoftMatch = insertionPoint;\n\t\tlet nextSibling = newChild.nextSibling;\n\t\tlet siblingSoftMatchCount = 0;\n\n\t\twhile (potentialSoftMatch != null) {\n\n\t\t\tif (getIdIntersectionCount(ctx, potentialSoftMatch, newContent) > 0) {\n\t\t\t\t// the current potential soft match has a potential id set match with the remaining new\n\t\t\t\t// content so bail out of looking\n\t\t\t\treturn null;\n\t\t\t}\n\n\t\t\t// if we have a soft match with the current node, return it\n\t\t\tif (isSoftMatch(newChild, potentialSoftMatch)) {\n\t\t\t\treturn potentialSoftMatch;\n\t\t\t}\n\n\t\t\tif (isSoftMatch(nextSibling, potentialSoftMatch)) {\n\t\t\t\t// the next new node has a soft match with this node, so\n\t\t\t\t// increment the count of future soft matches\n\t\t\t\tsiblingSoftMatchCount++;\n\t\t\t\tnextSibling = nextSibling.nextSibling;\n\n\t\t\t\t// If there are two future soft matches, bail to allow the siblings to soft match\n\t\t\t\t// so that we don't consume future soft matches for the sake of the current node\n\t\t\t\tif (siblingSoftMatchCount >= 2) {\n\t\t\t\t\treturn null;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// advanced to the next old content child\n\t\t\tpotentialSoftMatch = potentialSoftMatch.nextSibling;\n\t\t}\n\n\t\treturn potentialSoftMatch;\n\t}\n\n\tfunction parseContent(newContent) {\n\t\tlet parser = new DOMParser();\n\n\t\t// remove svgs to avoid false-positive matches on head, etc.\n\t\tlet contentWithSvgsRemoved = newContent.replace(/<svg(\\s[^>]*>|>)([\\s\\S]*?)<\\/svg>/gim, '');\n\n\t\t// if the newContent contains a html, head or body tag, we can simply parse it w/o wrapping\n\t\tif (contentWithSvgsRemoved.match(/<\\/html>/) || contentWithSvgsRemoved.match(/<\\/head>/) || contentWithSvgsRemoved.match(/<\\/body>/)) {\n\t\t\tlet content = parser.parseFromString(newContent, \"text/html\");\n\t\t\t// if it is a full HTML document, return the document itself as the parent container\n\t\t\tif (contentWithSvgsRemoved.match(/<\\/html>/)) {\n\t\t\t\tcontent.generatedByIdiomorph = true;\n\t\t\t\treturn content;\n\t\t\t} else {\n\t\t\t\t// otherwise return the html element as the parent container\n\t\t\t\tlet htmlElement = content.firstChild;\n\t\t\t\tif (htmlElement) {\n\t\t\t\t\thtmlElement.generatedByIdiomorph = true;\n\t\t\t\t\treturn htmlElement;\n\t\t\t\t} else {\n\t\t\t\t\treturn null;\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\t// if it is partial HTML, wrap it in a template tag to provide a parent element and also to help\n\t\t\t// deal with touchy tags like tr, tbody, etc.\n\t\t\tlet responseDoc = parser.parseFromString(\"<body><template>\" + newContent + \"</template></body>\", \"text/html\");\n\t\t\tlet content = responseDoc.body.querySelector('template').content;\n\t\t\tcontent.generatedByIdiomorph = true;\n\t\t\treturn content\n\t\t}\n\t}\n\n\tfunction normalizeContent(newContent) {\n\t\tif (newContent == null) {\n\t\t\t// noinspection UnnecessaryLocalVariableJS\n\t\t\tconst dummyParent = document.createElement('div');\n\t\t\treturn dummyParent;\n\t\t} else if (newContent.generatedByIdiomorph) {\n\t\t\t// the template tag created by idiomorph parsing can serve as a dummy parent\n\t\t\treturn newContent;\n\t\t} else if (newContent instanceof Node) {\n\t\t\t// a single node is added as a child to a dummy parent\n\t\t\tconst dummyParent = document.createElement('div');\n\t\t\tdummyParent.append(newContent);\n\t\t\treturn dummyParent;\n\t\t} else {\n\t\t\t// all nodes in the array or HTMLElement collection are consolidated under\n\t\t\t// a single dummy parent element\n\t\t\tconst dummyParent = document.createElement('div');\n\t\t\tfor (const elt of [...newContent]) {\n\t\t\t\tdummyParent.append(elt);\n\t\t\t}\n\t\t\treturn dummyParent;\n\t\t}\n\t}\n\n\tfunction insertSiblings(previousSibling, morphedNode, nextSibling) {\n\t\tlet stack = []\n\t\tlet added = []\n\t\twhile (previousSibling != null) {\n\t\t\tstack.push(previousSibling);\n\t\t\tpreviousSibling = previousSibling.previousSibling;\n\t\t}\n\t\twhile (stack.length > 0) {\n\t\t\tlet node = stack.pop();\n\t\t\tadded.push(node); // push added preceding siblings on in order and insert\n\t\t\tmorphedNode.parentElement.insertBefore(node, morphedNode);\n\t\t}\n\t\tadded.push(morphedNode);\n\t\twhile (nextSibling != null) {\n\t\t\tstack.push(nextSibling);\n\t\t\tadded.push(nextSibling); // here we are going in order, so push on as we scan, rather than add\n\t\t\tnextSibling = nextSibling.nextSibling;\n\t\t}\n\t\twhile (stack.length > 0) {\n\t\t\tmorphedNode.parentElement.insertBefore(stack.pop(), morphedNode.nextSibling);\n\t\t}\n\t\treturn added;\n\t}\n\n\tfunction findBestNodeMatch(newContent, oldNode, ctx) {\n\t\tlet currentElement;\n\t\tcurrentElement = newContent.firstChild;\n\t\tlet bestElement = currentElement;\n\t\tlet score = 0;\n\t\twhile (currentElement) {\n\t\t\tlet newScore = scoreElement(currentElement, oldNode, ctx);\n\t\t\tif (newScore > score) {\n\t\t\t\tbestElement = currentElement;\n\t\t\t\tscore = newScore;\n\t\t\t}\n\t\t\tcurrentElement = currentElement.nextSibling;\n\t\t}\n\t\treturn bestElement;\n\t}\n\n\tfunction scoreElement(node1, node2, ctx) {\n\t\tif (isSoftMatch(node1, node2)) {\n\t\t\treturn .5 + getIdIntersectionCount(ctx, node1, node2);\n\t\t}\n\t\treturn 0;\n\t}\n\n\tfunction removeNode(tempNode, ctx) {\n\t\tremoveIdsFromConsideration(ctx, tempNode)\n\t\tif (ctx.callbacks.beforeNodeRemoved(tempNode) === false) return;\n\n\t\ttempNode.remove();\n\t\tctx.callbacks.afterNodeRemoved(tempNode);\n\t}\n\n\t//=============================================================================\n\t// ID Set Functions\n\t//=============================================================================\n\n\tfunction isIdInConsideration(ctx, id) {\n\t\treturn !ctx.deadIds.has(id);\n\t}\n\n\tfunction idIsWithinNode(ctx, id, targetNode) {\n\t\tlet idSet = ctx.idMap.get(targetNode) || EMPTY_SET;\n\t\treturn idSet.has(id);\n\t}\n\n\tfunction removeIdsFromConsideration(ctx, node) {\n\t\tlet idSet = ctx.idMap.get(node) || EMPTY_SET;\n\t\tfor (const id of idSet) {\n\t\t\tctx.deadIds.add(id);\n\t\t}\n\t}\n\n\tfunction getIdIntersectionCount(ctx, node1, node2) {\n\t\tlet sourceSet = ctx.idMap.get(node1) || EMPTY_SET;\n\t\tlet matchCount = 0;\n\t\tfor (const id of sourceSet) {\n\t\t\t// a potential match is an id in the source and potentialIdsSet, but\n\t\t\t// that has not already been merged into the DOM\n\t\t\tif (isIdInConsideration(ctx, id) && idIsWithinNode(ctx, id, node2)) {\n\t\t\t\t++matchCount;\n\t\t\t}\n\t\t}\n\t\treturn matchCount;\n\t}\n\n\t/**\n\t * A bottom up algorithm that finds all elements with ids inside of the node\n\t * argument and populates id sets for those nodes and all their parents, generating\n\t * a set of ids contained within all nodes for the entire hierarchy in the DOM\n\t *\n\t * @param node {Element}\n\t * @param {Map<Node, Set<String>>} idMap\n\t */\n\tfunction populateIdMapForNode(node, idMap) {\n\t\tlet nodeParent = node.parentElement;\n\t\t// find all elements with an id property\n\t\tlet idElements = node.querySelectorAll('[id]');\n\t\tfor (const elt of idElements) {\n\t\t\tlet current = elt;\n\t\t\t// walk up the parent hierarchy of that element, adding the id\n\t\t\t// of element to the parent's id set\n\t\t\twhile (current !== nodeParent && current != null) {\n\t\t\t\tlet idSet = idMap.get(current);\n\t\t\t\t// if the id set doesn't exist, create it and insert it in the map\n\t\t\t\tif (idSet == null) {\n\t\t\t\t\tidSet = new Set();\n\t\t\t\t\tidMap.set(current, idSet);\n\t\t\t\t}\n\t\t\t\tidSet.add(elt.id);\n\t\t\t\tcurrent = current.parentElement;\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * This function computes a map of nodes to all ids contained within that node (inclusive of the\n\t * node). This map can be used to ask if two nodes have intersecting sets of ids, which allows\n\t * for a looser definition of \"matching\" than tradition id matching, and allows child nodes\n\t * to contribute to a parent nodes matching.\n\t *\n\t * @param {Element} oldContent the old content that will be morphed\n\t * @param {Element} newContent the new content to morph to\n\t * @returns {Map<Node, Set<String>>} a map of nodes to id sets for the\n\t */\n\tfunction createIdMap(oldContent, newContent) {\n\t\tlet idMap = new Map();\n\t\tpopulateIdMapForNode(oldContent, idMap);\n\t\tpopulateIdMapForNode(newContent, idMap);\n\t\treturn idMap;\n\t}\n\n\t//=============================================================================\n\t// This is what ends up becoming the Idiomorph global object\n\t//=============================================================================\n\treturn {\n\t\tmorph,\n\t\tdefaults\n\t}\n})();\n","const customEvent = (() => {\n\treturn ('CustomEvent' in window && typeof window.CustomEvent === 'function')\n\t\t? (name, data) => new CustomEvent(name, data)\n\t\t: (name, data) => {\n\t\t\tconst newEvent = document.createEvent('CustomEvent')\n\t\t\tnewEvent.initCustomEvent(name, true, true, data)\n\t\t\treturn newEvent\n\t\t}\n})()\n\nconst handler = (node, ev) => {\n\treturn function (e) {\n\t\tconst scope = this\n\t\tconst detail = e.detail || {}\n\t\tnode.__events[ev].forEach(o => {\n\t\t\to.handler.apply(scope, [e].concat(detail.args))\n\t\t})\n\t}\n}\n\nconst removeListener = (node, ev) => {\n\tif (node.__events[ev] && node.__events[ev].listener) {\n\t\tnode.removeEventListener(\n\t\t\tev,\n\t\t\tnode.__events[ev].listener,\n\t\t\t(ev == 'focus' || ev == 'blur' || ev == 'mouseenter' || ev == 'mouseleave'))\n\t\tdelete node.__events[ev]\n\t}\n}\n\nconst delegate = (node, selector, callback) => {\n\treturn function (e) {\n\n\t\tconst element = this\n\t\tconst detail = e.detail || {}\n\n\t\tlet parent = e.target\n\n\t\twhile (parent) {\n\t\t\tif (parent.matches(selector)) {\n\t\t\t\te.delegateTarget = parent\n\t\t\t\tcallback.apply(element, [e].concat(detail.args))\n\t\t\t}\n\t\t\tif (parent === node) break\n\t\t\tparent = parent.parentNode\n\t\t}\n\t}\n}\n\nexport const on = (node, ev, selectorOrCallback, callback) => {\n\n\tnode.__events = node.__events || {}\n\tnode.__events[ev] = (node.__events[ev] || [])\n\n\tif (!node.__events[ev].length) {\n\t\tconst fn = handler(node, ev)\n\t\tnode.addEventListener(\n\t\t\tev,\n\t\t\tfn,\n\t\t\t(ev == 'focus' || ev == 'blur' || ev == 'mouseenter' || ev == 'mouseleave'))\n\t\tnode.__events[ev].listener = fn\n\t}\n\n\tif (selectorOrCallback.call) {\n\t\tnode.__events[ev].push({ handler: selectorOrCallback, callback: selectorOrCallback })\n\t} else {\n\t\tnode.__events[ev].push({ handler: delegate(node, selectorOrCallback, callback), callback })\n\t}\n}\n\nexport const off = (node, ev, fn) => {\n\n\tif (fn && node.__events[ev] && node.__events[ev].length) {\n\t\tvar old = node.__events[ev]\n\t\tnode.__events[ev] = node.__events[ev].filter(function (o) { return o.callback != fn; })\n\t\tnode.__events[ev].listener = old.listener\n\t\tif (!node.__events[ev].length)\n\t\t\tremoveListener(node, ev)\n\t} else {\n\t\tremoveListener(node, ev)\n\t}\n}\n\nexport const trigger = (node, name, args) => {\n\tnode.dispatchEvent(customEvent(name, { bubbles: true, detail: args }))\n}\n","import { type Component } from '..'\nimport { Idiomorph } from './utils/idiomorph'\nimport { rAF, dup, safe } from './utils'\nimport { buildtemplates } from './template-system'\nimport { on, off, trigger } from './utils/events'\nimport { publish, subscribe } from './utils/pubsub'\n\nexport default function Component( elm, { module, dependencies, templates, components }) {\n\n\tconst options = getOptions( module )\n\tconst initialState = (new Function( `return ${elm.getAttribute('html-model') || '{}'}`))()\n\tconst selector = Object.keys(components).toString()\n\n\tbuildtemplates( elm, selector, templates, components )\n\n\tconst tplid = elm.getAttribute('tplid')\n\tconst template = tplid ? templates[tplid] : null\n\tconst state = { data: module.model ? dup(module.model) : {} }\n\tstate.data = Object.assign( state.data, initialState)\n\n\tconst base: Component = {\n\t\ttemplate,\n\t\telm,\n\t\tdependencies,\n\t\tpublish,\n\t\tsubscribe,\n\n\t\tmain(fn) {\n\t\t\toptions.main = fn\n\t\t},\n\n\t\tunmount(fn) {\n\t\t\toptions.unmount = fn\n\t\t},\n\n\t\tonupdate(fn) {\n\t\t\toptions.onupdate = fn\n\t\t},\n\n\t\ton(eventName, selectorOrCallback, callback) {\n\t\t\ton(elm, eventName, selectorOrCallback, callback)\n\t\t},\n\n\t\toff(eventName, callback) {\n\t\t\toff(elm, eventName, callback)\n\t\t},\n\n\t\ttrigger(eventName, target, args) {\n\t\t\tif (target.constructor === String) {\n\t\t\t\tArray\n\t\t\t\t\t.from(elm.querySelectorAll(target))\n\t\t\t\t\t.forEach( children => trigger(children, eventName, { args: args }) )\n\t\t\t}\n\t\t\telse trigger(elm, eventName, { args: target })\n\t\t},\n\n\t\temit: ( ...args ) => {\n\t\t\ttrigger(elm, args.shift(), { args: args })\n\t\t},\n\n\t\tstate: {\n\t\t\tset( data ) {\n\t\t\t\tif (data.constructor === Function) {\n\t\t\t\t\tconst newstate = dup(state.data)\n\t\t\t\t\tdata(newstate)\n\t\t\t\t\tbase.render(newstate)\n\t\t\t\t} else {\n\t\t\t\t\tbase.render(data)\n\t\t\t\t}\n\t\t\t\treturn new Promise((resolve) => rAF(_ => rAF(() => resolve(state.data))))\n\t\t\t},\n\t\t\tget() {\n\t\t\t\treturn dup(state.data)\n\t\t\t},\n\n\t\t\tgetRaw(){\n\t\t\t\treturn state.data\n\t\t\t}\n\t\t},\n\n\t\trender(data = state.data) {\n\n\t\t\tif (!document.body.contains(elm)) {\n\t\t\t\treturn\n\t\t\t}\n\n\t\t\tstate.data = Object.assign(state.data, data)\n\n\t\t\tconst newdata = dup(state.data)\n\t\t\tconst newhtml = templates[tplid].call(Object.assign(options.view(newdata), elm.___scope___), elm, safe)\n\n\t\t\tIdiomorph.morph(elm, newhtml, IdiomorphOptions)\n\t\t\tupdateScope( elm )\n\n\t\t\trAF(_ => {\n\t\t\t\tArray\n\t\t\t\t\t.from(elm.querySelectorAll('[tplid]'))\n\t\t\t\t\t.forEach((child: any) => {\n\t\t\t\t\t\tconst props = Object.assign( child.base.state.getRaw(), data )\n\t\t\t\t\t\tchild.options.onupdate(props)\n\t\t\t\t\t\tchild.base.render(props)\n\t\t\t\t\t})\n\t\t\t})\n\t\t},\n\n\t\tinnerHTML( target, html_ ) {\n\n\t\t\tconst element = html_? target : elm\n\t\t\tconst parser = new DOMParser()\n\t\t\tconst virtual = parser.parseFromString(element.outerHTML, 'text/html')\n\t\t\tconst html = html_? html_ : target\n\n\t\t\tvirtual.body.firstElementChild.innerHTML = html as string\n\t\t\trAF( _ => Idiomorph.morph(element, virtual.body.innerHTML, IdiomorphOptions) )\n\t\t}\n\t}\n\n\treturn { base, options }\n}\n\nconst getOptions = (module) => ({\n\tmain: (a) => a,\n\tunmount: (a) => a,\n\tonupdate: (a) => a,\n\tview: module.view ? module.view : (a) => a\n})\n\nconst updateScope = (node) => {\n\tnode.querySelectorAll('[scope]').forEach( scopeElement => {\n\t\tscopeElement.querySelectorAll('[tplid]').forEach( cp => {\n\t\t\tif( !cp.___scope___ ) {\n\t\t\t\tconst script = scopeElement.lastElementChild\n\t\t\t\tcp.___scope___ = 'scope' in script.dataset? (new Function(`return ${script.text}`))() : {}\n\t\t\t}\n\t\t})\n\t})\n}\n\n\nconst IdiomorphOptions = {\n\n\tcallbacks: {\n\n\t\tbeforeNodeMorphed( node ) {\n\t\t\tif( node.nodeType === 1 ) {\n\t\t\t\tif( 'html-static' in node.attributes ) {\n\t\t\t\t\treturn false\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n}\n","import Component from './component'\nimport { purge, rAF } from './utils'\n\nexport default function Element(module, dependencies, templates, components) {\n\treturn class extends HTMLElement {\n\n\t\tbase: any\n\t\toptions: any\n\t\treturns : any\n\t\t__events: any\n\n\t\tconstructor() {\n\n\t\t\tsuper()\n\t\t\tconst { base, options } = Component(this, { module, dependencies, templates, components })\n\n\t\t\tthis.base = base\n\t\t\tthis.options = options\n\t\t\tthis.returns = module.default(base)\n\t\t}\n\n\t\tconnectedCallback() {\n\n\t\t\tthis.base.render()\n\n\t\t\tif( this.__template && this.__template.constructor === Promise ) {\n\t\t\t\tthis.__template.then( _ => {\n\t\t\t\t\tif( this.base && this.options.main) {\n\t\t\t\t\t\tconst array = this.options.main(this.base)\n\t\t\t\t\t\tif( array && array.length ){\n\t\t\t\t\t\t\tarray.forEach(f => f(this.base))\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t})\n\t\t\t\treturn\n\t\t\t}\n\n\t\t\tif( this.returns && this.returns.constructor === Promise ) {\n\t\t\t\tthis.returns.then( _ => {\n\t\t\t\t\tif( this.base && this.options.main) {\n\t\t\t\t\t\tconst array = this.options.main(this.base)\n\t\t\t\t\t\tif( array && array.length ){\n\t\t\t\t\t\t\tarray.forEach(f => f(this.base))\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t})\n\t\t\t}else {\n\t\t\t\tif( this.base && this.options.main ){\n\t\t\t\t\tconst array = this.options.main(this.base)\n\t\t\t\t\tif( array && array.length ) {\n\t\t\t\t\t\tarray.forEach(f => f(this.base))\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tdisconnectedCallback() {\n\t\t\tthis.options.unmount(this.base)\n\t\t\trAF(() => {\n\t\t\t\tif(!document.body.contains(this) ) {\n\t\t\t\t\tthis.__events? this.__events = null : null\n\t\t\t\t\tthis.base? this.base.elm = null : null\n\t\t\t\t\tthis.base? this.base = null : null\n\t\t\t\t\tpurge(this)\n\t\t\t\t}\n\t\t\t})\n\n\t\t}\n\n\t\tattributeChangedCallback() {\n\t\t\t//TODO\n\t\t}\n\t}\n}\n","import { templateConfig, buildtemplates } from './template-system'\nimport { publish, subscribe } from './utils/pubsub'\nimport { html } from './utils'\nimport Element from './element'\n\nconst templates = {}\nconst components = {}\n\nexport { html }\n\nexport default {\n\n\ttemplateConfig,\n\n\tpublish,\n\tsubscribe,\n\n\tregister( name, module, dependencies = {} ) {\n\t\tcomponents[name] = { name, module, dependencies }\n\t},\n\n\tstart( target = document.body ) {\n\t\tconst keys = Object.keys(components)\n\t\tconst selector = keys.toString()\n\t\tif( keys.length ) {\n\t\t\tbuildtemplates( target, selector, templates, components )\n\t\t\tregisterComponents()\n\t\t}\n\t}\n}\n\nconst registerComponents = () => {\n\tObject\n\t\t.values( components )\n\t\t.forEach( (component) => {\n\t\t\tconst { name, module, dependencies } = component as any\n\t\t\tif( !customElements.get(name) ){\n\t\t\t\tconst Base = Element(module, dependencies, templates, components)\n\t\t\t\tcustomElements.define(name, Base)\n\t\t\t}\n\t\t})\n}\n"],"names":["parser","DOMParser","wrap","open","node","close","_a","parentNode","insertBefore","_b","nextSibling","textarea","document","createElement","decodeHTML","text","innerHTML","value","rAF","fn","requestAnimationFrame","setTimeout","dup","o","JSON","parse","stringify","purge","d","i","l","n","a","attributes","length","name","childNodes","safe","execute","val","err","config","tags","Template","element","html","regexTags","RegExp","virtual","parseFromString","replace","querySelectorAll","forEach","htmlForeach","getAttribute","htmlFor","htmlIf","htmlInner","htmlClass","forEachInstruction","selector","split","match","varname","object","removeAttribute","setAttribute","script","dataset","scope","type","appendChild","createTextNode","className","trim","body","all","key","Transpile","outerHTML","decodedHTML","Function","_","variable","buildtemplates","target","templates","components","concat","matches","Array","from","reverse","template","content","createTemplateId","id","c","r","Math","random","toString","localName","module","constructor","Promise","__template","then","htmlstring","topics","_async","publish","params","Object","assign","topic","subscribe","method","push","filter","Idiomorph","EMPTY_SET","Set","defaults","morphStyle","callbacks","beforeNodeAdded","noOp","afterNodeAdded","beforeNodeMorphed","afterNodeMorphed","beforeNodeRemoved","afterNodeRemoved","beforeAttributeUpdated","head","style","shouldPreserve","elt","shouldReAppend","shouldRemove","afterHeadMorphed","morphNormalizedContent","oldNode","normalizedNewContent","ctx","block","oldHead","querySelector","newHead","promises","handleHeadElement","ignore","morphChildren","children","bestMatch","newContent","currentElement","firstChild","bestElement","score","newScore","scoreElement","findBestNodeMatch","previousSibling","morphedNode","morphOldNodeTo","stack","added","pop","parentElement","insertSiblings","ignoreValueOfActiveElement","possibleActiveElement","ignoreActiveValue","activeElement","ignoreActive","remove","isSoftMatch","HTMLHeadElement","to","nodeType","fromAttributes","toAttributes","fromAttribute","ignoreAttribute","toAttribute","hasAttribute","nodeValue","HTMLInputElement","fromValue","toValue","syncBooleanAttribute","HTMLOptionElement","HTMLTextAreaElement","syncInputValue","syncNodeFrom","replaceChild","newParent","oldParent","newChild","nextNewChild","insertionPoint","removeIdsFromConsideration","isIdSetMatch","idSetMatch","findIdSetMatch","removeNodesBetween","softMatch","findSoftMatch","tempNode","removeNode","attr","updateType","attributeName","ignoreUpdate","newHeadTag","currentHead","removed","preserved","nodesToAppend","headMergeStyle","srcToNewHeadNodes","Map","newHeadChild","set","currentHeadElt","inNewContent","has","isReAppended","isPreserved","delete","values","newNode","newElt","createRange","createContextualFragment","href","src","resolve","promise","_resolve","addEventListener","removedElement","removeChild","kept","node1","node2","tagName","getIdIntersectionCount","startInclusive","endExclusive","newChildPotentialIdCount","potentialMatch","otherMatchCount","potentialSoftMatch","siblingSoftMatchCount","isIdInConsideration","deadIds","idIsWithinNode","targetNode","idMap","get","idSet","add","sourceSet","matchCount","populateIdMapForNode","nodeParent","idElements","current","createIdMap","oldContent","morph","Document","documentElement","contentWithSvgsRemoved","generatedByIdiomorph","htmlElement","parseContent","normalizedContent","Node","dummyParent","append","normalizeContent","finalConfig","mergeDefaults","createMorphContext","customEvent","window","CustomEvent","data","newEvent","createEvent","initCustomEvent","handler","ev","e","this","detail","__events","apply","args","removeListener","listener","removeEventListener","delegate","callback","parent","delegateTarget","on","selectorOrCallback","call","off","old","trigger","dispatchEvent","bubbles","getOptions","main","unmount","onupdate","view","updateScope","scopeElement","cp","___scope___","lastElementChild","IdiomorphOptions","Element","dependencies","HTMLElement","base","options","elm","initialState","keys","tplid","state","model","eventName","String","emit","shift","newstate","render","getRaw","contains","newdata","newhtml","child","props","html_","firstElementChild","Component","returns","default","connectedCallback","array","f","disconnectedCallback","attributeChangedCallback","index","templateConfig","newconfig","register","start","registerComponents","component","customElements","Base","define","literalSections","substs","raw","result","subst","lit","isArray","join"],"mappings":"6OAAM,MAAAA,EAAS,IAAIC,UA0EnB,MAAMC,EAAO,CAACC,EAAMC,EAAMC,aACpB,OAAAC,EAAAF,EAAAG,aAAYD,EAAAE,aAAaL,EAAMC,GACpC,OAAAK,EAAAL,EAAKG,aAALE,EAAiBD,aAAaH,EAAOD,EAAKM,YAAA,EC5ErCC,EAAWC,SAASC,cAAc,YAE3BC,EAAcC,IAC1BJ,EAASK,UAAYD,EACdJ,EAASM,OAGJC,EAAOC,GACfC,sBACIA,sBAAsBD,GAEtBE,WAAWF,EAAI,IAAO,IAWlBG,EAAOC,GACZC,KAAKC,MAAMD,KAAKE,UAAUH,IAIrBI,EAASC,IACrB,IAAsBC,EAAGC,EAAGC,EAAxBC,EAAIJ,EAAEK,WACV,GAAID,EACH,IAAKH,EAAIG,EAAEE,OAAS,EAAGL,GAAK,EAAGA,GAAK,EAEf,mBAATD,EADPG,EAAAC,EAAEH,GAAGM,QAERP,EAAEG,GAAK,MAKV,GADAC,EAAIJ,EAAEQ,WAGL,IADAN,EAAIE,EAAEE,OACDL,EAAI,EAAGA,EAAIC,EAAGD,GAAK,EACjBF,EAAAC,EAAEQ,WAAWP,GAErB,EAGYQ,EAAO,CAACC,EAASC,KAC1B,IAAC,OAAOD,UAAgBE,GAAK,OAAOD,GAAO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
{
|
2
2
|
"name": "jails-js",
|
3
|
-
"version": "5.
|
3
|
+
"version": "5.8.0",
|
4
4
|
"description": "Jails - Elegant and Minimalistic Javascript Application Library",
|
5
5
|
"module": "./dist/jails.js",
|
6
6
|
"main": "./dist/jails.js",
|
@@ -35,6 +35,6 @@
|
|
35
35
|
"vite": "^4.4.5"
|
36
36
|
},
|
37
37
|
"dependencies": {
|
38
|
-
"
|
38
|
+
"idiomorph": "^0.3.0"
|
39
39
|
}
|
40
40
|
}
|
package/src/component.ts
CHANGED
@@ -1,6 +1,5 @@
|
|
1
1
|
import { type Component } from '..'
|
2
|
-
import
|
3
|
-
|
2
|
+
import { Idiomorph } from './utils/idiomorph'
|
4
3
|
import { rAF, dup, safe } from './utils'
|
5
4
|
import { buildtemplates } from './template-system'
|
6
5
|
import { on, off, trigger } from './utils/events'
|
@@ -90,7 +89,8 @@ export default function Component( elm, { module, dependencies, templates, compo
|
|
90
89
|
const newdata = dup(state.data)
|
91
90
|
const newhtml = templates[tplid].call(Object.assign(options.view(newdata), elm.___scope___), elm, safe)
|
92
91
|
|
93
|
-
|
92
|
+
Idiomorph.morph(elm, newhtml, IdiomorphOptions)
|
93
|
+
updateScope( elm )
|
94
94
|
|
95
95
|
rAF(_ => {
|
96
96
|
Array
|
@@ -111,7 +111,7 @@ export default function Component( elm, { module, dependencies, templates, compo
|
|
111
111
|
const html = html_? html_ : target
|
112
112
|
|
113
113
|
virtual.body.firstElementChild.innerHTML = html as string
|
114
|
-
rAF( _ =>
|
114
|
+
rAF( _ => Idiomorph.morph(element, virtual.body.innerHTML, IdiomorphOptions) )
|
115
115
|
}
|
116
116
|
}
|
117
117
|
|
@@ -125,32 +125,28 @@ const getOptions = (module) => ({
|
|
125
125
|
view: module.view ? module.view : (a) => a
|
126
126
|
})
|
127
127
|
|
128
|
-
const
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
})
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
return false
|
138
|
-
}
|
128
|
+
const updateScope = (node) => {
|
129
|
+
node.querySelectorAll('[scope]').forEach( scopeElement => {
|
130
|
+
scopeElement.querySelectorAll('[tplid]').forEach( cp => {
|
131
|
+
if( !cp.___scope___ ) {
|
132
|
+
const script = scopeElement.lastElementChild
|
133
|
+
cp.___scope___ = 'scope' in script.dataset? (new Function(`return ${script.text}`))() : {}
|
134
|
+
}
|
135
|
+
})
|
136
|
+
})
|
139
137
|
}
|
140
138
|
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
139
|
+
|
140
|
+
const IdiomorphOptions = {
|
141
|
+
|
142
|
+
callbacks: {
|
143
|
+
|
144
|
+
beforeNodeMorphed( node ) {
|
145
|
+
if( node.nodeType === 1 ) {
|
146
|
+
if( 'html-static' in node.attributes ) {
|
147
|
+
return false
|
148
148
|
}
|
149
|
-
}
|
150
|
-
}
|
151
|
-
if ( node.getAttribute('tplid') ) {
|
152
|
-
return false
|
149
|
+
}
|
153
150
|
}
|
154
151
|
}
|
155
|
-
return node
|
156
152
|
}
|
package/src/template-system.ts
CHANGED
@@ -9,9 +9,9 @@ export const templateConfig = (newconfig) => {
|
|
9
9
|
Object.assign(config, newconfig)
|
10
10
|
}
|
11
11
|
|
12
|
-
export default function Template(element
|
12
|
+
export default function Template(element) {
|
13
13
|
|
14
|
-
const html = Transpile(element.outerHTML, config
|
14
|
+
const html = Transpile(element.outerHTML, config)
|
15
15
|
const decodedHTML = JSON.stringify(html)
|
16
16
|
|
17
17
|
return new Function('$element', 'safe',`
|
@@ -54,13 +54,13 @@ const createTemplateId = (element, templates, components ) => {
|
|
54
54
|
element.__template = html
|
55
55
|
html.then( htmlstring => {
|
56
56
|
element.innerHTML = htmlstring
|
57
|
-
templates[id] = Template(element
|
57
|
+
templates[id] = Template(element)
|
58
58
|
})
|
59
59
|
}else {
|
60
60
|
element.innerHTML = html
|
61
61
|
}
|
62
62
|
}
|
63
|
-
templates[id] = Template(element
|
63
|
+
templates[id] = Template(element)
|
64
64
|
}
|
65
65
|
}
|
66
66
|
|
package/src/transpile.ts
CHANGED
@@ -1,18 +1,10 @@
|
|
1
1
|
const parser = new DOMParser()
|
2
2
|
|
3
|
-
export default function Transpile(html, config
|
3
|
+
export default function Transpile(html, config) {
|
4
4
|
|
5
5
|
const regexTags = new RegExp(`\\${config.tags[0]}(.+?)\\${config.tags[1]}`, 'g')
|
6
6
|
const virtual = parser.parseFromString(html.replace(/<\/?template[^>]*>/g, ''), 'text/html')
|
7
7
|
|
8
|
-
const root = virtual.querySelector(element.localName)
|
9
|
-
const childNodes = Object.keys(components).toString()
|
10
|
-
|
11
|
-
root.querySelectorAll(childNodes).forEach( node => {
|
12
|
-
const clone = node.cloneNode()
|
13
|
-
node.replaceWith(clone)
|
14
|
-
})
|
15
|
-
|
16
8
|
virtual.querySelectorAll('[html-for], [html-if], [html-inner], [html-class], [html-model]').forEach((element) => {
|
17
9
|
|
18
10
|
const htmlForeach = element.getAttribute('html-foreach')
|