@neuronet.io/vido
Advanced tools
Comparing version 1.0.12 to 1.0.13
{ | ||
"name": "@neuronet.io/vido", | ||
"version": "1.0.12", | ||
"version": "1.0.13", | ||
"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 o=0;const s={};let i,r,a=[],l=0;const c=Promise.resolve();function d(e){return t((function(t,n){return function(o){const s=o.committer.element;for(const o of t)if("function"==typeof o){const t=a.find(t=>t.instance===e&&t.componentAction.create===o&&t.element===s);if(t)t.props=n;else{void 0!==s.__vido__&&delete s.__vido__;const t={create:o,update(){},destroy(){}};a.push({instance:e,componentAction:t,element:s,props:n})}}}}))}const u={debug:!1,state:e,api:n,html:H,svg:R,directive:t,asyncAppend:B,asyncReplace:j,cache:q,classMap:G,guard:K,ifDefined:Q,repeat:oe,styleMap:ie,unsafeHTML:ae,until:ce,actions(e,t){},onDestroy(){},onChange(e){},createComponent(e,t){const n=o++,i=function(e){return{instance:e,destroy:()=>(u.debug&&(console.groupCollapsed(`destroying component ${e}`),console.log(e,s[e],s),console.trace(),console.groupEnd()),u.destroyComponent(e)),update:()=>(u.debug&&(console.groupCollapsed(`updating component ${e}`),console.log(e,s[e],s),console.trace(),console.groupEnd()),u.updateTemplate()),change(t){u.debug&&(console.groupCollapsed(`changing component ${e}`),console.log(t,e,s[e],s),console.trace(),console.groupEnd()),s[e].change(t)},html:(t={})=>s[e].update(t)}}(n);const r=[];const a=[];const l=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)}),c={instance:n,vidoInstance:l,destroy(){for(const e of r)e()},update:e(l,t),change(e){for(const n in t)if(e[n]===t[n])return;for(const t of a)t(e)}};return s[n]=c,s[n].change(t),u.debug&&(console.groupCollapsed(`component created ${n}`),console.log(n,e,t,s),console.groupEnd()),i},destroyComponent(e){"function"==typeof s[e].destroy&&s[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 s[e],u.debug&&(console.groupCollapsed(`component destroyed ${e}`),console.trace(),console.groupEnd())},updateTemplate(){const e=++l,t=this;c.then((function(){e===l&&(t.render(),l=0,u.debug&&(console.groupCollapsed("templates updated"),console.trace(),console.groupEnd()))}))},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);u.debug&&(console.groupCollapsed(`create action executed ${e.instance}`),console.log(e),console.trace(),console.groupEnd()),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),u.debug&&(console.groupCollapsed(`update action executed ${e.instance}`),console.log(e),console.trace(),console.groupEnd()));for(const e of a)e.element.__vido__={instance:e.instance,props:e.props}},render(){W(s[i].update(),r),u.executeActions()}};return u} | ||
*/export default function(e,n){let o=0;const s={};let i,r,a=[],l=0;const c=Promise.resolve();function d(e){return t((function(t,n){return function(o){const s=o.committer.element;for(const o of t)if("function"==typeof o){const t=a.find(t=>t.instance===e&&t.componentAction.create===o&&t.element===s);if(t)t.props=n;else{void 0!==s.__vido__&&delete s.__vido__;const t={create:o,update(){},destroy(){}};a.push({instance:e,componentAction:t,element:s,props:n})}}}}))}const u={debug:!1,state:e,api:n,html:H,svg:R,directive:t,asyncAppend:B,asyncReplace:j,cache:q,classMap:G,guard:K,ifDefined:Q,repeat:oe,styleMap:ie,unsafeHTML:ae,until:ce,actions(e,t){},onDestroy(){},onChange(e){},createComponent(e,t){const n=o++;let i;const r=[];const a=[];const l=function(e,t){return{instance:e,vidoInstance:t,destroy:()=>(t.debug&&(console.groupCollapsed(`destroying component ${e}`),console.log(e,s[e],s),console.trace(),console.groupEnd()),u.destroyComponent(e,t)),update:()=>(t.debug&&(console.groupCollapsed(`updating component ${e}`),console.log(e,s[e],s),console.trace(),console.groupEnd()),u.updateTemplate(t)),change(n){t.debug&&(console.groupCollapsed(`changing component ${e}`),console.log(n,e,s[e],s),console.trace(),console.groupEnd()),s[e].change(n,t)},html:(n={})=>s[e].update(n,t)}}(n,i=Object.assign(Object.assign({},u),{update:function(){u.updateTemplate(i)},onDestroy:function(e){r.push(e)},onChange:function(e){a.push(e)},instance:n,actions:d(n)})),c={instance:n,vidoInstance:i,destroy(){for(const e of r)e()},update:e(i,t),change(e){for(const n in t)if(e[n]===t[n])return;for(const t of a)t(e)}};return s[n]=c,s[n].change(t),i.debug&&(console.groupCollapsed(`component created ${n}`),console.log(n,e,t,s),console.groupEnd()),l},destroyComponent(e,t){"function"==typeof s[e].destroy&&s[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 s[e],t.debug&&(console.groupCollapsed(`component destroyed ${e}`),console.trace(),console.groupEnd())},updateTemplate(e){const t=++l,n=this;c.then((function(){t===l&&(n.render(),l=0,e.debug&&(console.groupCollapsed("templates updated"),console.trace(),console.groupEnd()))}))},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);u.debug&&(console.groupCollapsed(`create action executed ${e.instance}`),console.log(e),console.trace(),console.groupEnd()),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),u.debug&&(console.groupCollapsed(`update action executed ${e.instance}`),console.log(e),console.trace(),console.groupEnd()));for(const e of a)e.element.__vido__={instance:e.instance,props:e.props}},render(){W(s[i].update(),r),u.executeActions()}};return u} | ||
//# sourceMappingURL=vido.esm.min.js.map |
@@ -147,3 +147,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 | ||
*/return function(e,n){let o=0;const s={};let i,r,a=[],l=0;const c=Promise.resolve();function d(e){return t((function(t,n){return function(o){const s=o.committer.element;for(const o of t)if("function"==typeof o){const t=a.find(t=>t.instance===e&&t.componentAction.create===o&&t.element===s);if(t)t.props=n;else{void 0!==s.__vido__&&delete s.__vido__;const t={create:o,update(){},destroy(){}};a.push({instance:e,componentAction:t,element:s,props:n})}}}}))}const u={debug:!1,state:e,api:n,html:H,svg:R,directive:t,asyncAppend:B,asyncReplace:j,cache:q,classMap:G,guard:K,ifDefined:Q,repeat:oe,styleMap:ie,unsafeHTML:ae,until:ce,actions(e,t){},onDestroy(){},onChange(e){},createComponent(e,t){const n=o++,i=function(e){return{instance:e,destroy:()=>(u.debug&&(console.groupCollapsed(`destroying component ${e}`),console.log(e,s[e],s),console.trace(),console.groupEnd()),u.destroyComponent(e)),update:()=>(u.debug&&(console.groupCollapsed(`updating component ${e}`),console.log(e,s[e],s),console.trace(),console.groupEnd()),u.updateTemplate()),change(t){u.debug&&(console.groupCollapsed(`changing component ${e}`),console.log(t,e,s[e],s),console.trace(),console.groupEnd()),s[e].change(t)},html:(t={})=>s[e].update(t)}}(n);const r=[];const a=[];const l=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)}),c={instance:n,vidoInstance:l,destroy(){for(const e of r)e()},update:e(l,t),change(e){for(const n in t)if(e[n]===t[n])return;for(const t of a)t(e)}};return s[n]=c,s[n].change(t),u.debug&&(console.groupCollapsed(`component created ${n}`),console.log(n,e,t,s),console.groupEnd()),i},destroyComponent(e){"function"==typeof s[e].destroy&&s[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 s[e],u.debug&&(console.groupCollapsed(`component destroyed ${e}`),console.trace(),console.groupEnd())},updateTemplate(){const e=++l,t=this;c.then((function(){e===l&&(t.render(),l=0,u.debug&&(console.groupCollapsed("templates updated"),console.trace(),console.groupEnd()))}))},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);u.debug&&(console.groupCollapsed(`create action executed ${e.instance}`),console.log(e),console.trace(),console.groupEnd()),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),u.debug&&(console.groupCollapsed(`update action executed ${e.instance}`),console.log(e),console.trace(),console.groupEnd()));for(const e of a)e.element.__vido__={instance:e.instance,props:e.props}},render(){W(s[i].update(),r),u.executeActions()}};return u}})); | ||
*/return function(e,n){let o=0;const s={};let i,r,a=[],l=0;const c=Promise.resolve();function d(e){return t((function(t,n){return function(o){const s=o.committer.element;for(const o of t)if("function"==typeof o){const t=a.find(t=>t.instance===e&&t.componentAction.create===o&&t.element===s);if(t)t.props=n;else{void 0!==s.__vido__&&delete s.__vido__;const t={create:o,update(){},destroy(){}};a.push({instance:e,componentAction:t,element:s,props:n})}}}}))}const u={debug:!1,state:e,api:n,html:H,svg:R,directive:t,asyncAppend:B,asyncReplace:j,cache:q,classMap:G,guard:K,ifDefined:Q,repeat:oe,styleMap:ie,unsafeHTML:ae,until:ce,actions(e,t){},onDestroy(){},onChange(e){},createComponent(e,t){const n=o++;let i;const r=[];const a=[];const l=function(e,t){return{instance:e,vidoInstance:t,destroy:()=>(t.debug&&(console.groupCollapsed(`destroying component ${e}`),console.log(e,s[e],s),console.trace(),console.groupEnd()),u.destroyComponent(e,t)),update:()=>(t.debug&&(console.groupCollapsed(`updating component ${e}`),console.log(e,s[e],s),console.trace(),console.groupEnd()),u.updateTemplate(t)),change(n){t.debug&&(console.groupCollapsed(`changing component ${e}`),console.log(n,e,s[e],s),console.trace(),console.groupEnd()),s[e].change(n,t)},html:(n={})=>s[e].update(n,t)}}(n,i=Object.assign(Object.assign({},u),{update:function(){u.updateTemplate(i)},onDestroy:function(e){r.push(e)},onChange:function(e){a.push(e)},instance:n,actions:d(n)})),c={instance:n,vidoInstance:i,destroy(){for(const e of r)e()},update:e(i,t),change(e){for(const n in t)if(e[n]===t[n])return;for(const t of a)t(e)}};return s[n]=c,s[n].change(t),i.debug&&(console.groupCollapsed(`component created ${n}`),console.log(n,e,t,s),console.groupEnd()),l},destroyComponent(e,t){"function"==typeof s[e].destroy&&s[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 s[e],t.debug&&(console.groupCollapsed(`component destroyed ${e}`),console.trace(),console.groupEnd())},updateTemplate(e){const t=++l,n=this;c.then((function(){t===l&&(n.render(),l=0,e.debug&&(console.groupCollapsed("templates updated"),console.trace(),console.groupEnd()))}))},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);u.debug&&(console.groupCollapsed(`create action executed ${e.instance}`),console.log(e),console.trace(),console.groupEnd()),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),u.debug&&(console.groupCollapsed(`update action executed ${e.instance}`),console.log(e),console.trace(),console.groupEnd()));for(const e of a)e.element.__vido__={instance:e.instance,props:e.props}},render(){W(s[i].update(),r),u.executeActions()}};return u}})); | ||
//# sourceMappingURL=vido.min.js.map |
34
vido.ts
@@ -69,5 +69,5 @@ import { render, html, directive, svg } from 'lit-html'; | ||
const instance = componentId++; | ||
const componentInstanceMethods = getComponentInstanceMethods(instance); | ||
let vidoInstance; | ||
function update() { | ||
vido.updateTemplate(); | ||
vido.updateTemplate(vidoInstance); | ||
} | ||
@@ -82,3 +82,4 @@ const destroyable = []; | ||
} | ||
const vidoInstance = { ...vido, update, onDestroy, onChange, instance, actions: getActions(instance) }; | ||
vidoInstance = { ...vido, update, onDestroy, onChange, instance, actions: getActions(instance) }; | ||
const componentInstanceMethods = getComponentInstanceMethods(instance, vidoInstance); | ||
const methods = { | ||
@@ -106,3 +107,3 @@ instance, | ||
components[instance].change(props); | ||
if (vido.debug) { | ||
if (vidoInstance.debug) { | ||
console.groupCollapsed(`component created ${instance}`); | ||
@@ -115,3 +116,3 @@ console.log(instance, component, props, components); | ||
destroyComponent(instance) { | ||
destroyComponent(instance, vidoInstance) { | ||
if (typeof components[instance].destroy === 'function') { | ||
@@ -127,3 +128,3 @@ components[instance].destroy(); | ||
delete components[instance]; | ||
if (vido.debug) { | ||
if (vidoInstance.debug) { | ||
console.groupCollapsed(`component destroyed ${instance}`); | ||
@@ -135,3 +136,3 @@ console.trace(); | ||
updateTemplate() { | ||
updateTemplate(vidoInstance) { | ||
shouldUpdateCount++; | ||
@@ -144,3 +145,3 @@ const currentShouldUpdateCount = shouldUpdateCount; | ||
shouldUpdateCount = 0; | ||
if (vido.debug) { | ||
if (vidoInstance.debug) { | ||
console.groupCollapsed('templates updated'); | ||
@@ -205,7 +206,8 @@ console.trace(); | ||
function getComponentInstanceMethods(instance) { | ||
function getComponentInstanceMethods(instance, vidoInstance) { | ||
return { | ||
instance, | ||
vidoInstance, | ||
destroy() { | ||
if (vido.debug) { | ||
if (vidoInstance.debug) { | ||
console.groupCollapsed(`destroying component ${instance}`); | ||
@@ -217,6 +219,6 @@ console.log(instance, components[instance], components); | ||
return vido.destroyComponent(instance); | ||
return vido.destroyComponent(instance, vidoInstance); | ||
}, | ||
update() { | ||
if (vido.debug) { | ||
if (vidoInstance.debug) { | ||
console.groupCollapsed(`updating component ${instance}`); | ||
@@ -227,7 +229,7 @@ console.log(instance, components[instance], components); | ||
} | ||
return vido.updateTemplate(); | ||
return vido.updateTemplate(vidoInstance); | ||
}, | ||
change(props) { | ||
if (vido.debug) { | ||
if (vidoInstance.debug) { | ||
console.groupCollapsed(`changing component ${instance}`); | ||
@@ -238,7 +240,7 @@ console.log(props, instance, components[instance], components); | ||
} | ||
components[instance].change(props); | ||
components[instance].change(props, vidoInstance); | ||
}, | ||
html(props = {}) { | ||
return components[instance].update(props); | ||
return components[instance].update(props, vidoInstance); | ||
} | ||
@@ -245,0 +247,0 @@ }; |
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
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
869650
5587