@neuronet.io/vido
Advanced tools
Comparing version 1.0.2 to 1.0.3
{ | ||
"name": "@neuronet.io/vido", | ||
"version": "1.0.2", | ||
"version": "1.0.3", | ||
"description": "Compilation-less and eval free frontend framework for fast scalable apps.", | ||
@@ -5,0 +5,0 @@ "main": "vido.js", |
@@ -147,3 +147,3 @@ /** | ||
* http://polymer.github.io/PATENTS.txt | ||
*/export default function(e,n){let s=0;const o={};let i,r,a=[],l=0;const c=Promise.resolve();function d(e){return t((function(t,n){return function(s){const o=s.committer.element;for(const s of t)if("function"==typeof s){const t=a.find(t=>t.instance===e&&t.componentAction.create===s&&t.element===o);if(t)t.props=n;else{void 0!==o.__vido__&&delete o.__vido__;const t={create:s,update(){},destroy(){}};a.push({instance:e,componentAction:t,element:o,props:n})}}}}))}const u={state:e,api:n,html:R,svg:O,directive:t,asyncAppend:F,asyncReplace:j,cache:q,classMap:G,guard:K,ifDefined:Q,repeat:se,styleMap:ie,unsafeHTML:ae,until:ce,actions(e,t){},createComponent(e,t){const n=s++,i=function(e){return{instance:e,destroy:()=>u.destroyComponent(e),update:()=>u.updateTemplate(),html:(t={})=>o[e].update(t)}}(n);const r=[];const a={destroy(){for(const e of r)e()},update:e(Object.assign(Object.assign({},u),{update:function(){u.updateTemplate()},onDestroy:function(e){r.push(e)},instance:n,actions:d(n)}),t)};return o[n]=a,i},destroyComponent(e){"function"==typeof o[e].destroy&&o[e].destroy(),a=a.filter(t=>(t.instance===e&&"function"==typeof t.componentAction.destroy&&t.componentAction.destroy(t.element,t.props),t.instance!==e)),delete o[e]},updateTemplate(){const e=++l,t=this;c.then((function(){e===l&&(t.render(),l=0)}))},createApp(e,t){r=t;const n=this.createComponent(e);return i=n.instance,this.render(),n},executeActions(){for(const e of a)if(void 0===e.element.__vido__){if("function"==typeof e.componentAction.create){const t=e.componentAction.create(e.element,e.props);void 0!==t&&("function"==typeof t.update&&(e.componentAction.update=t.update),"function"==typeof t.destroy&&(e.componentAction.destroy=t.destroy))}}else"function"==typeof e.componentAction.update&&e.componentAction.update(e.element,e.props);for(const e of a)e.element.__vido__={instance:e.instance,props:e.props}},render(){H(o[i].update(),r),u.executeActions()}};return u} | ||
*/export default function(e,n){let s=0;const o={};let i,r,a=[],l=0;const c=Promise.resolve();function d(e){return t((function(t,n){return function(s){const o=s.committer.element;for(const s of t)if("function"==typeof s){const t=a.find(t=>t.instance===e&&t.componentAction.create===s&&t.element===o);if(t)t.props=n;else{void 0!==o.__vido__&&delete o.__vido__;const t={create:s,update(){},destroy(){}};a.push({instance:e,componentAction:t,element:o,props:n})}}}}))}const u={state:e,api:n,html:R,svg:O,directive:t,asyncAppend:F,asyncReplace:j,cache:q,classMap:G,guard:K,ifDefined:Q,repeat:se,styleMap:ie,unsafeHTML:ae,until:ce,actions(e,t){},onDestroy(){},onChange(e){},createComponent(e,t){const n=s++,i=function(e){return{instance:e,destroy:()=>u.destroyComponent(e),update:()=>u.updateTemplate(),change(t){o[e].change(t)},html:(t={})=>o[e].update(t)}}(n);const r=[];const a=[];const l={destroy(){for(const e of r)e()},update:e(Object.assign(Object.assign({},u),{update:function(){u.updateTemplate()},onDestroy:function(e){r.push(e)},onChange:function(e){a.push(e)},instance:n,actions:d(n)}),t),change(e){for(const t of a)t(e)}};return o[n]=l,i},destroyComponent(e){"function"==typeof o[e].destroy&&o[e].destroy(),a=a.filter(t=>(t.instance===e&&"function"==typeof t.componentAction.destroy&&t.componentAction.destroy(t.element,t.props),t.instance!==e)),delete o[e]},updateTemplate(){const e=++l,t=this;c.then((function(){e===l&&(t.render(),l=0)}))},createApp(e,t){r=t;const n=this.createComponent(e);return i=n.instance,this.render(),n},executeActions(){for(const e of a)if(void 0===e.element.__vido__){if("function"==typeof e.componentAction.create){const t=e.componentAction.create(e.element,e.props);void 0!==t&&("function"==typeof t.update&&(e.componentAction.update=t.update),"function"==typeof t.destroy&&(e.componentAction.destroy=t.destroy))}}else"function"==typeof e.componentAction.update&&e.componentAction.update(e.element,e.props);for(const e of a)e.element.__vido__={instance:e.instance,props:e.props}},render(){H(o[i].update(),r),u.executeActions()}};return u} | ||
//# sourceMappingURL=vido.esm.min.js.map |
@@ -14,3 +14,3 @@ !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e=e||self).Vido=t()}(this,(function(){"use strict"; | ||
* http://polymer.github.io/PATENTS.txt | ||
*/const e=new WeakMap,t=t=>(...n)=>{const s=t(...n);return e.set(s,!0),s},n=t=>"function"==typeof t&&e.has(t),s=void 0!==window.customElements&&void 0!==window.customElements.polyfillWrapFlushCallback,o=(e,t,n=null,s=null)=>{for(;t!==n;){const n=t.nextSibling;e.insertBefore(t,s),t=n}},i=(e,t,n=null)=>{for(;t!==n;){const n=t.nextSibling;e.removeChild(t),t=n}},r={},a={},l=`{{lit-${String(Math.random()).slice(2)}}}`,c=`\x3c!--${l}--\x3e`,d=new RegExp(`${l}|${c}`),u="$lit$";class p{constructor(e,t){this.parts=[],this.element=t;const n=[],s=[],o=document.createTreeWalker(t.content,133,null,!1);let i=0,r=-1,a=0;const{strings:c,values:{length:p}}=e;for(;a<p;){const e=o.nextNode();if(null!==e){if(r++,1===e.nodeType){if(e.hasAttributes()){const t=e.attributes,{length:n}=t;let s=0;for(let e=0;e<n;e++)h(t[e].name,u)&&s++;for(;s-- >0;){const t=c[a],n=v.exec(t)[2],s=n.toLowerCase()+u,o=e.getAttribute(s);e.removeAttribute(s);const i=o.split(d);this.parts.push({type:"attribute",index:r,name:n,strings:i}),a+=i.length-1}}"TEMPLATE"===e.tagName&&(s.push(e),o.currentNode=e.content)}else if(3===e.nodeType){const t=e.data;if(t.indexOf(l)>=0){const s=e.parentNode,o=t.split(d),i=o.length-1;for(let t=0;t<i;t++){let n,i=o[t];if(""===i)n=f();else{const e=v.exec(i);null!==e&&h(e[2],u)&&(i=i.slice(0,e.index)+e[1]+e[2].slice(0,-u.length)+e[3]),n=document.createTextNode(i)}s.insertBefore(n,e),this.parts.push({type:"node",index:++r})}""===o[i]?(s.insertBefore(f(),e),n.push(e)):e.data=o[i],a+=i}}else if(8===e.nodeType)if(e.data===l){const t=e.parentNode;null!==e.previousSibling&&r!==i||(r++,t.insertBefore(f(),e)),i=r,this.parts.push({type:"node",index:r}),null===e.nextSibling?e.data="":(n.push(e),r--),a++}else{let t=-1;for(;-1!==(t=e.data.indexOf(l,t+1));)this.parts.push({type:"node",index:-1}),a++}}else o.currentNode=s.pop()}for(const e of n)e.parentNode.removeChild(e)}}const h=(e,t)=>{const n=e.length-t.length;return n>=0&&e.slice(n)===t},m=e=>-1!==e.index,f=()=>document.createComment(""),v=/([ \x09\x0a\x0c\x0d])([^\0-\x1F\x7F-\x9F "'>=/]+)([ \x09\x0a\x0c\x0d]*=[ \x09\x0a\x0c\x0d]*(?:[^ \x09\x0a\x0c\x0d"'`<>=]*|"[^"]*|'[^']*))$/; | ||
*/const e=new WeakMap,t=t=>(...n)=>{const s=t(...n);return e.set(s,!0),s},n=t=>"function"==typeof t&&e.has(t),s=void 0!==window.customElements&&void 0!==window.customElements.polyfillWrapFlushCallback,o=(e,t,n=null,s=null)=>{for(;t!==n;){const n=t.nextSibling;e.insertBefore(t,s),t=n}},i=(e,t,n=null)=>{for(;t!==n;){const n=t.nextSibling;e.removeChild(t),t=n}},r={},a={},l=`{{lit-${String(Math.random()).slice(2)}}}`,c=`\x3c!--${l}--\x3e`,d=new RegExp(`${l}|${c}`),u="$lit$";class h{constructor(e,t){this.parts=[],this.element=t;const n=[],s=[],o=document.createTreeWalker(t.content,133,null,!1);let i=0,r=-1,a=0;const{strings:c,values:{length:h}}=e;for(;a<h;){const e=o.nextNode();if(null!==e){if(r++,1===e.nodeType){if(e.hasAttributes()){const t=e.attributes,{length:n}=t;let s=0;for(let e=0;e<n;e++)p(t[e].name,u)&&s++;for(;s-- >0;){const t=c[a],n=v.exec(t)[2],s=n.toLowerCase()+u,o=e.getAttribute(s);e.removeAttribute(s);const i=o.split(d);this.parts.push({type:"attribute",index:r,name:n,strings:i}),a+=i.length-1}}"TEMPLATE"===e.tagName&&(s.push(e),o.currentNode=e.content)}else if(3===e.nodeType){const t=e.data;if(t.indexOf(l)>=0){const s=e.parentNode,o=t.split(d),i=o.length-1;for(let t=0;t<i;t++){let n,i=o[t];if(""===i)n=f();else{const e=v.exec(i);null!==e&&p(e[2],u)&&(i=i.slice(0,e.index)+e[1]+e[2].slice(0,-u.length)+e[3]),n=document.createTextNode(i)}s.insertBefore(n,e),this.parts.push({type:"node",index:++r})}""===o[i]?(s.insertBefore(f(),e),n.push(e)):e.data=o[i],a+=i}}else if(8===e.nodeType)if(e.data===l){const t=e.parentNode;null!==e.previousSibling&&r!==i||(r++,t.insertBefore(f(),e)),i=r,this.parts.push({type:"node",index:r}),null===e.nextSibling?e.data="":(n.push(e),r--),a++}else{let t=-1;for(;-1!==(t=e.data.indexOf(l,t+1));)this.parts.push({type:"node",index:-1}),a++}}else o.currentNode=s.pop()}for(const e of n)e.parentNode.removeChild(e)}}const p=(e,t)=>{const n=e.length-t.length;return n>=0&&e.slice(n)===t},m=e=>-1!==e.index,f=()=>document.createComment(""),v=/([ \x09\x0a\x0c\x0d])([^\0-\x1F\x7F-\x9F "'>=/]+)([ \x09\x0a\x0c\x0d]*=[ \x09\x0a\x0c\x0d]*(?:[^ \x09\x0a\x0c\x0d"'`<>=]*|"[^"]*|'[^']*))$/; | ||
/** | ||
@@ -81,3 +81,3 @@ * @license | ||
* http://polymer.github.io/PATENTS.txt | ||
*/function P(e){let t=L.get(e.type);void 0===t&&(t={stringsArray:new WeakMap,keyString:new Map},L.set(e.type,t));let n=t.stringsArray.get(e.strings);if(void 0!==n)return n;const s=e.strings.join(l);return void 0===(n=t.keyString.get(s))&&(n=new p(e,e.getTemplateElement()),t.keyString.set(s,n)),t.stringsArray.set(e.strings,n),n}const L=new Map,W=new WeakMap,H=(e,t,n)=>{let s=W.get(t);void 0===s&&(i(t,t.firstChild),W.set(t,s=new A(Object.assign({templateFactory:P},n))),s.appendInto(t)),s.setValue(e),s.commit()}; | ||
*/function P(e){let t=L.get(e.type);void 0===t&&(t={stringsArray:new WeakMap,keyString:new Map},L.set(e.type,t));let n=t.stringsArray.get(e.strings);if(void 0!==n)return n;const s=e.strings.join(l);return void 0===(n=t.keyString.get(s))&&(n=new h(e,e.getTemplateElement()),t.keyString.set(s,n)),t.stringsArray.set(e.strings,n),n}const L=new Map,W=new WeakMap,H=(e,t,n)=>{let s=W.get(t);void 0===s&&(i(t,t.firstChild),W.set(t,s=new A(Object.assign({templateFactory:P},n))),s.appendInto(t)),s.setValue(e),s.commit()}; | ||
/** | ||
@@ -136,3 +136,3 @@ * @license | ||
* http://polymer.github.io/PATENTS.txt | ||
*/var $=function(e){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var t,n=e[Symbol.asyncIterator];return n?n.call(e):(e="function"==typeof __values?__values(e):e[Symbol.iterator](),t={},s("next"),s("throw"),s("return"),t[Symbol.asyncIterator]=function(){return this},t);function s(n){t[n]=e[n]&&function(t){return new Promise((function(s,o){(function(e,t,n,s){Promise.resolve(s).then((function(t){e({value:t,done:n})}),t)})(s,o,(t=e[n](t)).done,t.value)}))}}};const j=t((e,t)=>async n=>{var s,o;if(!(n instanceof A))throw new Error("asyncReplace can only be used in text bindings");if(e===n.value)return;const i=new A(n.options);n.value=e;let r=0;try{for(var a,l=$(e);!(a=await l.next()).done;){let s=a.value;if(n.value!==e)break;0===r&&(n.clear(),i.appendIntoPart(n)),void 0!==t&&(s=t(s,r)),i.setValue(s),i.commit(),r++}}catch(e){s={error:e}}finally{try{a&&!a.done&&(o=l.return)&&await o.call(l)}finally{if(s)throw s.error}}}),D=new WeakMap,q=t(e=>t=>{if(!(t instanceof A))throw new Error("cache can only be used in text bindings");let n=D.get(t);void 0===n&&(n=new WeakMap,D.set(t,n));const s=t.value;if(s instanceof g){if(e instanceof y&&s.template===t.options.templateFactory(e))return void t.setValue(e);{let e=n.get(s.template);void 0===e&&(e={instance:s,nodes:document.createDocumentFragment()},n.set(s.template,e)),o(e.nodes,t.startNode.nextSibling,t.endNode)}}if(e instanceof y){const s=t.options.templateFactory(e),o=n.get(s);void 0!==o&&(t.setValue(o.nodes),t.commit(),t.value=o.instance)}t.setValue(e)}),z=new WeakMap,G=t(e=>t=>{if(!(t instanceof V)||t instanceof M||"class"!==t.committer.name||t.committer.parts.length>1)throw new Error("The `classMap` directive must be used in the `class` attribute and must be the only part in the attribute.");const{committer:n}=t,{element:s}=n;z.has(t)||(s.className=n.strings.join(" "));const{classList:o}=s,i=z.get(t);for(const t in i)t in e||o.remove(t);for(const t in e){const n=e[t];if(!i||n!==i[t]){o[n?"add":"remove"](t)}}z.set(t,e)}),J=new WeakMap,K=t((e,t)=>n=>{const s=J.get(n);if(Array.isArray(e)){if(Array.isArray(s)&&s.length===e.length&&e.every((e,t)=>e===s[t]))return}else if(s===e&&(void 0!==e||J.has(n)))return;n.setValue(t()),J.set(n,Array.isArray(e)?Array.from(e):e)}),Q=t(e=>t=>{if(void 0===e&&t instanceof V){if(e!==t.value){const e=t.committer.name;t.committer.element.removeAttribute(e)}}else t.setValue(e)}),U=(e,t)=>{const n=e.startNode.parentNode,s=void 0===t?e.endNode:t.startNode,o=n.insertBefore(f(),s);n.insertBefore(f(),s);const i=new A(e.options);return i.insertAfterNode(o),i},X=(e,t)=>(e.setValue(t),e.commit(),e),Y=(e,t,n)=>{const s=e.startNode.parentNode,i=n?n.startNode:e.endNode,r=t.endNode.nextSibling;r!==i&&o(s,t.startNode,r,i)},Z=e=>{i(e.startNode.parentNode,e.startNode,e.endNode.nextSibling)},ee=(e,t,n)=>{const s=new Map;for(let o=t;o<=n;o++)s.set(e[o],o);return s},te=new WeakMap,ne=new WeakMap,se=t((e,t,n)=>{let s;return void 0===n?n=t:void 0!==t&&(s=t),t=>{if(!(t instanceof A))throw new Error("repeat can only be used in text bindings");const o=te.get(t)||[],i=ne.get(t)||[],r=[],a=[],l=[];let c,d,u=0;for(const t of e)l[u]=s?s(t,u):u,a[u]=n(t,u),u++;let p=0,h=o.length-1,m=0,f=a.length-1;for(;p<=h&&m<=f;)if(null===o[p])p++;else if(null===o[h])h--;else if(i[p]===l[m])r[m]=X(o[p],a[m]),p++,m++;else if(i[h]===l[f])r[f]=X(o[h],a[f]),h--,f--;else if(i[p]===l[f])r[f]=X(o[p],a[f]),Y(t,o[p],r[f+1]),p++,f--;else if(i[h]===l[m])r[m]=X(o[h],a[m]),Y(t,o[h],o[p]),h--,m++;else if(void 0===c&&(c=ee(l,m,f),d=ee(i,p,h)),c.has(i[p]))if(c.has(i[h])){const e=d.get(l[m]),n=void 0!==e?o[e]:null;if(null===n){const e=U(t,o[p]);X(e,a[m]),r[m]=e}else r[m]=X(n,a[m]),Y(t,n,o[p]),o[e]=null;m++}else Z(o[h]),h--;else Z(o[p]),p++;for(;m<=f;){const e=U(t,r[f+1]);X(e,a[m]),r[m++]=e}for(;p<=h;){const e=o[p++];null!==e&&Z(e)}te.set(t,r),ne.set(t,l)}}),oe=new WeakMap,ie=t(e=>t=>{if(!(t instanceof V)||t instanceof M||"style"!==t.committer.name||t.committer.parts.length>1)throw new Error("The `styleMap` directive must be used in the style attribute and must be the only part in the attribute.");const{committer:n}=t,{style:s}=n.element;oe.has(t)||(s.cssText=n.strings.join(" "));const o=oe.get(t);for(const t in o)t in e||(-1===t.indexOf("-")?s[t]=null:s.removeProperty(t));for(const t in e)-1===t.indexOf("-")?s[t]=e[t]:s.setProperty(t,e[t]);oe.set(t,e)}),re=new WeakMap,ae=t(e=>t=>{if(!(t instanceof A))throw new Error("unsafeHTML can only be used in text bindings");const n=re.get(t);if(void 0!==n&&w(e)&&e===n.value&&t.value===n.fragment)return;const s=document.createElement("template");s.innerHTML=e;const o=document.importNode(s.content,!0);t.setValue(o),re.set(t,{value:e,fragment:o})}),le=new WeakMap,ce=t((...e)=>t=>{let n=le.get(t);void 0===n&&(n={lastRenderedIndex:2147483647,values:[]},le.set(t,n));const s=n.values;let o=s.length;n.values=e;for(let i=0;i<e.length&&!(i>n.lastRenderedIndex);i++){const r=e[i];if(w(r)||"function"!=typeof r.then){t.setValue(r),n.lastRenderedIndex=i;break}i<o&&r===s[i]||(n.lastRenderedIndex=2147483647,o=0,Promise.resolve(r).then(e=>{const s=n.values.indexOf(r);s>-1&&s<n.lastRenderedIndex&&(n.lastRenderedIndex=s,t.setValue(e),t.commit())}))}}); | ||
*/var $=function(e){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var t,n=e[Symbol.asyncIterator];return n?n.call(e):(e="function"==typeof __values?__values(e):e[Symbol.iterator](),t={},s("next"),s("throw"),s("return"),t[Symbol.asyncIterator]=function(){return this},t);function s(n){t[n]=e[n]&&function(t){return new Promise((function(s,o){(function(e,t,n,s){Promise.resolve(s).then((function(t){e({value:t,done:n})}),t)})(s,o,(t=e[n](t)).done,t.value)}))}}};const j=t((e,t)=>async n=>{var s,o;if(!(n instanceof A))throw new Error("asyncReplace can only be used in text bindings");if(e===n.value)return;const i=new A(n.options);n.value=e;let r=0;try{for(var a,l=$(e);!(a=await l.next()).done;){let s=a.value;if(n.value!==e)break;0===r&&(n.clear(),i.appendIntoPart(n)),void 0!==t&&(s=t(s,r)),i.setValue(s),i.commit(),r++}}catch(e){s={error:e}}finally{try{a&&!a.done&&(o=l.return)&&await o.call(l)}finally{if(s)throw s.error}}}),D=new WeakMap,q=t(e=>t=>{if(!(t instanceof A))throw new Error("cache can only be used in text bindings");let n=D.get(t);void 0===n&&(n=new WeakMap,D.set(t,n));const s=t.value;if(s instanceof g){if(e instanceof y&&s.template===t.options.templateFactory(e))return void t.setValue(e);{let e=n.get(s.template);void 0===e&&(e={instance:s,nodes:document.createDocumentFragment()},n.set(s.template,e)),o(e.nodes,t.startNode.nextSibling,t.endNode)}}if(e instanceof y){const s=t.options.templateFactory(e),o=n.get(s);void 0!==o&&(t.setValue(o.nodes),t.commit(),t.value=o.instance)}t.setValue(e)}),z=new WeakMap,G=t(e=>t=>{if(!(t instanceof V)||t instanceof M||"class"!==t.committer.name||t.committer.parts.length>1)throw new Error("The `classMap` directive must be used in the `class` attribute and must be the only part in the attribute.");const{committer:n}=t,{element:s}=n;z.has(t)||(s.className=n.strings.join(" "));const{classList:o}=s,i=z.get(t);for(const t in i)t in e||o.remove(t);for(const t in e){const n=e[t];if(!i||n!==i[t]){o[n?"add":"remove"](t)}}z.set(t,e)}),J=new WeakMap,K=t((e,t)=>n=>{const s=J.get(n);if(Array.isArray(e)){if(Array.isArray(s)&&s.length===e.length&&e.every((e,t)=>e===s[t]))return}else if(s===e&&(void 0!==e||J.has(n)))return;n.setValue(t()),J.set(n,Array.isArray(e)?Array.from(e):e)}),Q=t(e=>t=>{if(void 0===e&&t instanceof V){if(e!==t.value){const e=t.committer.name;t.committer.element.removeAttribute(e)}}else t.setValue(e)}),U=(e,t)=>{const n=e.startNode.parentNode,s=void 0===t?e.endNode:t.startNode,o=n.insertBefore(f(),s);n.insertBefore(f(),s);const i=new A(e.options);return i.insertAfterNode(o),i},X=(e,t)=>(e.setValue(t),e.commit(),e),Y=(e,t,n)=>{const s=e.startNode.parentNode,i=n?n.startNode:e.endNode,r=t.endNode.nextSibling;r!==i&&o(s,t.startNode,r,i)},Z=e=>{i(e.startNode.parentNode,e.startNode,e.endNode.nextSibling)},ee=(e,t,n)=>{const s=new Map;for(let o=t;o<=n;o++)s.set(e[o],o);return s},te=new WeakMap,ne=new WeakMap,se=t((e,t,n)=>{let s;return void 0===n?n=t:void 0!==t&&(s=t),t=>{if(!(t instanceof A))throw new Error("repeat can only be used in text bindings");const o=te.get(t)||[],i=ne.get(t)||[],r=[],a=[],l=[];let c,d,u=0;for(const t of e)l[u]=s?s(t,u):u,a[u]=n(t,u),u++;let h=0,p=o.length-1,m=0,f=a.length-1;for(;h<=p&&m<=f;)if(null===o[h])h++;else if(null===o[p])p--;else if(i[h]===l[m])r[m]=X(o[h],a[m]),h++,m++;else if(i[p]===l[f])r[f]=X(o[p],a[f]),p--,f--;else if(i[h]===l[f])r[f]=X(o[h],a[f]),Y(t,o[h],r[f+1]),h++,f--;else if(i[p]===l[m])r[m]=X(o[p],a[m]),Y(t,o[p],o[h]),p--,m++;else if(void 0===c&&(c=ee(l,m,f),d=ee(i,h,p)),c.has(i[h]))if(c.has(i[p])){const e=d.get(l[m]),n=void 0!==e?o[e]:null;if(null===n){const e=U(t,o[h]);X(e,a[m]),r[m]=e}else r[m]=X(n,a[m]),Y(t,n,o[h]),o[e]=null;m++}else Z(o[p]),p--;else Z(o[h]),h++;for(;m<=f;){const e=U(t,r[f+1]);X(e,a[m]),r[m++]=e}for(;h<=p;){const e=o[h++];null!==e&&Z(e)}te.set(t,r),ne.set(t,l)}}),oe=new WeakMap,ie=t(e=>t=>{if(!(t instanceof V)||t instanceof M||"style"!==t.committer.name||t.committer.parts.length>1)throw new Error("The `styleMap` directive must be used in the style attribute and must be the only part in the attribute.");const{committer:n}=t,{style:s}=n.element;oe.has(t)||(s.cssText=n.strings.join(" "));const o=oe.get(t);for(const t in o)t in e||(-1===t.indexOf("-")?s[t]=null:s.removeProperty(t));for(const t in e)-1===t.indexOf("-")?s[t]=e[t]:s.setProperty(t,e[t]);oe.set(t,e)}),re=new WeakMap,ae=t(e=>t=>{if(!(t instanceof A))throw new Error("unsafeHTML can only be used in text bindings");const n=re.get(t);if(void 0!==n&&w(e)&&e===n.value&&t.value===n.fragment)return;const s=document.createElement("template");s.innerHTML=e;const o=document.importNode(s.content,!0);t.setValue(o),re.set(t,{value:e,fragment:o})}),le=new WeakMap,ce=t((...e)=>t=>{let n=le.get(t);void 0===n&&(n={lastRenderedIndex:2147483647,values:[]},le.set(t,n));const s=n.values;let o=s.length;n.values=e;for(let i=0;i<e.length&&!(i>n.lastRenderedIndex);i++){const r=e[i];if(w(r)||"function"!=typeof r.then){t.setValue(r),n.lastRenderedIndex=i;break}i<o&&r===s[i]||(n.lastRenderedIndex=2147483647,o=0,Promise.resolve(r).then(e=>{const s=n.values.indexOf(r);s>-1&&s<n.lastRenderedIndex&&(n.lastRenderedIndex=s,t.setValue(e),t.commit())}))}}); | ||
/** | ||
@@ -150,3 +150,3 @@ * @license | ||
* http://polymer.github.io/PATENTS.txt | ||
*/return function(e,n){let s=0;const o={};let i,r,a=[],l=0;const c=Promise.resolve();function d(e){return t((function(t,n){return function(s){const o=s.committer.element;for(const s of t)if("function"==typeof s){const t=a.find(t=>t.instance===e&&t.componentAction.create===s&&t.element===o);if(t)t.props=n;else{void 0!==o.__vido__&&delete o.__vido__;const t={create:s,update(){},destroy(){}};a.push({instance:e,componentAction:t,element:o,props:n})}}}}))}const u={state:e,api:n,html:R,svg:O,directive:t,asyncAppend:F,asyncReplace:j,cache:q,classMap:G,guard:K,ifDefined:Q,repeat:se,styleMap:ie,unsafeHTML:ae,until:ce,actions(e,t){},createComponent(e,t){const n=s++,i=function(e){return{instance:e,destroy:()=>u.destroyComponent(e),update:()=>u.updateTemplate(),html:(t={})=>o[e].update(t)}}(n);const r=[];const a={destroy(){for(const e of r)e()},update:e(Object.assign(Object.assign({},u),{update:function(){u.updateTemplate()},onDestroy:function(e){r.push(e)},instance:n,actions:d(n)}),t)};return o[n]=a,i},destroyComponent(e){"function"==typeof o[e].destroy&&o[e].destroy(),a=a.filter(t=>(t.instance===e&&"function"==typeof t.componentAction.destroy&&t.componentAction.destroy(t.element,t.props),t.instance!==e)),delete o[e]},updateTemplate(){const e=++l,t=this;c.then((function(){e===l&&(t.render(),l=0)}))},createApp(e,t){r=t;const n=this.createComponent(e);return i=n.instance,this.render(),n},executeActions(){for(const e of a)if(void 0===e.element.__vido__){if("function"==typeof e.componentAction.create){const t=e.componentAction.create(e.element,e.props);void 0!==t&&("function"==typeof t.update&&(e.componentAction.update=t.update),"function"==typeof t.destroy&&(e.componentAction.destroy=t.destroy))}}else"function"==typeof e.componentAction.update&&e.componentAction.update(e.element,e.props);for(const e of a)e.element.__vido__={instance:e.instance,props:e.props}},render(){H(o[i].update(),r),u.executeActions()}};return u}})); | ||
*/return function(e,n){let s=0;const o={};let i,r,a=[],l=0;const c=Promise.resolve();function d(e){return t((function(t,n){return function(s){const o=s.committer.element;for(const s of t)if("function"==typeof s){const t=a.find(t=>t.instance===e&&t.componentAction.create===s&&t.element===o);if(t)t.props=n;else{void 0!==o.__vido__&&delete o.__vido__;const t={create:s,update(){},destroy(){}};a.push({instance:e,componentAction:t,element:o,props:n})}}}}))}const u={state:e,api:n,html:R,svg:O,directive:t,asyncAppend:F,asyncReplace:j,cache:q,classMap:G,guard:K,ifDefined:Q,repeat:se,styleMap:ie,unsafeHTML:ae,until:ce,actions(e,t){},onDestroy(){},onChange(e){},createComponent(e,t){const n=s++,i=function(e){return{instance:e,destroy:()=>u.destroyComponent(e),update:()=>u.updateTemplate(),change(t){o[e].change(t)},html:(t={})=>o[e].update(t)}}(n);const r=[];const a=[];const l={destroy(){for(const e of r)e()},update:e(Object.assign(Object.assign({},u),{update:function(){u.updateTemplate()},onDestroy:function(e){r.push(e)},onChange:function(e){a.push(e)},instance:n,actions:d(n)}),t),change(e){for(const t of a)t(e)}};return o[n]=l,i},destroyComponent(e){"function"==typeof o[e].destroy&&o[e].destroy(),a=a.filter(t=>(t.instance===e&&"function"==typeof t.componentAction.destroy&&t.componentAction.destroy(t.element,t.props),t.instance!==e)),delete o[e]},updateTemplate(){const e=++l,t=this;c.then((function(){e===l&&(t.render(),l=0)}))},createApp(e,t){r=t;const n=this.createComponent(e);return i=n.instance,this.render(),n},executeActions(){for(const e of a)if(void 0===e.element.__vido__){if("function"==typeof e.componentAction.create){const t=e.componentAction.create(e.element,e.props);void 0!==t&&("function"==typeof t.update&&(e.componentAction.update=t.update),"function"==typeof t.destroy&&(e.componentAction.destroy=t.destroy))}}else"function"==typeof e.componentAction.update&&e.componentAction.update(e.element,e.props);for(const e of a)e.element.__vido__={instance:e.instance,props:e.props}},render(){H(o[i].update(),r),u.executeActions()}};return u}})); | ||
//# sourceMappingURL=vido.min.js.map |
19
vido.ts
@@ -63,2 +63,4 @@ import { render, html, directive, svg } from 'lit-html'; | ||
actions(componentActions, props) {}, | ||
onDestroy() {}, | ||
onChange(props) {}, | ||
@@ -75,3 +77,7 @@ createComponent(component, props) { | ||
} | ||
const vidoInstance = { ...vido, update, onDestroy, instance, actions: getActions(instance) }; | ||
const onChangeFuntions = []; | ||
function onChange(fn) { | ||
onChangeFuntions.push(fn); | ||
} | ||
const vidoInstance = { ...vido, update, onDestroy, onChange, instance, actions: getActions(instance) }; | ||
const methods = { | ||
@@ -83,3 +89,8 @@ destroy() { | ||
}, | ||
update: component(vidoInstance, props) | ||
update: component(vidoInstance, props), | ||
change(props) { | ||
for (const fn of onChangeFuntions) { | ||
fn(props); | ||
} | ||
} | ||
}; | ||
@@ -164,2 +175,6 @@ components[instance] = methods; | ||
change(props) { | ||
components[instance].change(props); | ||
}, | ||
html(props = {}) { | ||
@@ -166,0 +181,0 @@ return components[instance].update(props); |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
845313
5411