Comparing version 0.1.1 to 0.2.0
@@ -111,10 +111,8 @@ 'use strict'; | ||
const info = store[id] || (store[id] = createCache()); | ||
return ( | ||
(template, ...values) => { | ||
unrollValues(info, values); | ||
return uhtml.for(entry, id)(template, ...values); | ||
} | ||
); | ||
return (template, ...values) => { | ||
unrollValues(info, values); | ||
return uhtml.for(entry, id)(template, ...values); | ||
}; | ||
} | ||
); | ||
} |
self.uland=function(e){"use strict";var t=CustomEvent,n=WeakSet;var r="function"==typeof cancelAnimationFrame,o=r?cancelAnimationFrame:clearTimeout,s=r?requestAnimationFrame:setTimeout;function l(e){var t,n,l,a,c;return i(),function(e,r,o){return l=e,a=r,c=o,n||(n=s(u)),--t<0&&f(!0),f};function u(){i(),l.apply(a,c||[])}function i(){t=e||1/0,n=r?0:null}function f(e){var t=!!n;return t&&(o(n),e&&u()),t}}var a=e=>({get:t=>e.get(t),set:(t,n)=>(e.set(t,n),n)}) | ||
/*! (c) Andrea Giammarchi - ISC */;let c=null;const u=e=>{const t=[];return function n(){const r=c,o=[];c={hook:n,args:arguments,stack:t,i:0,length:t.length,after:o};try{return e.apply(null,arguments)}finally{c=r;for(let e=0,{length:t}=o;e<t;e++)o[e]()}}},i=a(new WeakMap),f=(e,t,n)=>{e.apply(t,n)},d={async:!1,always:!1},p=(e,t)=>"function"==typeof t?t(e):t,h=(e,t,n,r)=>{const o=c.i++,{hook:s,args:a,stack:u,length:h}=c;o===h&&(c.length=u.push({}));const g=u[o];if(g.args=a,o===h){const o="function"==typeof n,{async:a,always:c}=(o?r:n)||r||d;g.$=o?n(t):p(void 0,t),g._=a?i.get(s)||i.set(s,l()):f,g.f=t=>{const n=e(g.$,t);(c||g.$!==n)&&(g.$=n,g._(s,null,g.args))}}return[g.$,g.f]},g=new WeakMap,v=({hook:e,args:t})=>{e.apply(null,t)};function m(e){this.value!==e&&(this.value=e,g.get(this).forEach(v))}function y({hook:e}){return e===this.hook}const w=new WeakMap,k=a(w),b=()=>{},N=e=>(t,n)=>{const r=c.i++,{hook:o,after:s,stack:a,length:u}=c;if(r<u){const o=a[r],{update:l,values:c,stop:u}=o;if(!n||n.some(T,c)){o.values=n,e&&u(e);const{clean:r}=o;r&&(o.clean=null,r());const a=()=>{o.clean=t()};e?l(a):s.push(a)}}else{const r=e?l():b,u={clean:null,update:r,values:n,stop:b};c.length=a.push(u),(k.get(o)||k.set(o,[])).push(u);const i=()=>{u.clean=t()};e?u.stop=r(i):s.push(i)}},C=e=>{(w.get(e)||[]).forEach(e=>{const{clean:t,stop:n}=e;n(),t&&(e.clean=null,t())})},$=w.has.bind(w),x=N(!0),E=N(!1),M=(e,t)=>{const n=c.i++,{stack:r,length:o}=c;return n===o?c.length=r.push({$:e(),_:t}):t&&!t.some(T,r[n]._)||(r[n]={$:e(),_:t}),r[n].$};function T(e,t){return e!==this[t]} | ||
/*! (c) Andrea Giammarchi - ISC */;let c=null;const u=e=>{const t=[];return function n(){const r=c,o=[];c={hook:n,args:arguments,stack:t,i:0,length:t.length,after:o};try{return e.apply(null,arguments)}finally{c=r;for(let e=0,{length:t}=o;e<t;e++)o[e]()}}},i=a(new WeakMap),f=(e,t,n)=>{e.apply(t,n)},d={async:!1,always:!1},h=(e,t)=>"function"==typeof t?t(e):t,p=(e,t,n,r)=>{const o=c.i++,{hook:s,args:a,stack:u,length:p}=c;o===p&&(c.length=u.push({}));const g=u[o];if(g.args=a,o===p){const o="function"==typeof n,{async:a,always:c}=(o?r:n)||r||d;g.$=o?n(t):h(void 0,t),g._=a?i.get(s)||i.set(s,l()):f,g.f=t=>{const n=e(g.$,t);(c||g.$!==n)&&(g.$=n,g._(s,null,g.args))}}return[g.$,g.f]},g=new WeakMap,v=({hook:e,args:t})=>{e.apply(null,t)};function m(e){this.value!==e&&(this.value=e,g.get(this).forEach(v))}function y({hook:e}){return e===this.hook}const w=new WeakMap,k=a(w),b=()=>{},N=e=>(t,n)=>{const r=c.i++,{hook:o,after:s,stack:a,length:u}=c;if(r<u){const o=a[r],{update:l,values:c,stop:u}=o;if(!n||n.some(T,c)){o.values=n,e&&u(e);const{clean:r}=o;r&&(o.clean=null,r());const a=()=>{o.clean=t()};e?l(a):s.push(a)}}else{const r=e?l():b,u={clean:null,update:r,values:n,stop:b};c.length=a.push(u),(k.get(o)||k.set(o,[])).push(u);const i=()=>{u.clean=t()};e?u.stop=r(i):s.push(i)}},C=e=>{(w.get(e)||[]).forEach(e=>{const{clean:t,stop:n}=e;n(),t&&(e.clean=null,t())})},$=w.has.bind(w),x=N(!0),E=N(!1),M=(e,t)=>{const n=c.i++,{stack:r,length:o}=c;return n===o?c.length=r.push({$:e(),_:t}):t&&!t.some(T,r[n]._)||(r[n]={$:e(),_:t}),r[n].$};function T(e,t){return e!==this[t]} | ||
/*! (c) Andrea Giammarchi - ISC */const A= | ||
@@ -7,2 +7,2 @@ /*! (c) Andrea Giammarchi */ | ||
/*! (c) Andrea Giammarchi - ISC */ | ||
self.P=function(e){var t="content"in r("template")?function(e){var t=r("template");return t.innerHTML=e,t.content}:function(e){var t=r("fragment"),o=r("template"),s=null;if(/^[^\S]*?<(col(?:group)?|t(?:head|body|foot|r|d|h))/i.test(e)){var l=RegExp.$1;o.innerHTML="<table>"+e+"</table>",s=o.querySelectorAll(l)}else o.innerHTML=e,s=o.childNodes;return n(t,s),t};return function(e,n){return("svg"===n?o:t)(e)};function n(e,t){for(var n=t.length;n--;)e.appendChild(t[0])}function r(t){return"fragment"===t?e.createDocumentFragment():e.createElementNS("http://www.w3.org/1999/xhtml",t)}function o(e){var t=r("fragment"),o=r("div");return o.innerHTML='<svg xmlns="http://www.w3.org/2000/svg">'+e+"</svg>",n(t,o.firstChild.childNodes),t}}(document);const G=({childNodes:e},t)=>e[t],J=e=>{const t=[];let{parentNode:n}=e;for(;n;)t.push(z.call(n.childNodes,e)),n=(e=n).parentNode;return t},{createTreeWalker:K,importNode:Q}=document,U=1!=Q.length,V=U?(e,t)=>Q.call(document,P(e,t),!0):P,X=U?e=>K.call(document,e,129,null,!1):e=>K.call(document,e,129),Y=(e,t,n)=>((e,t,n,r,o)=>{const s=n.length;let l=t.length,a=s,c=0,u=0,i=null;for(;c<l||u<a;)if(l===c){const t=a<s?u?r(n[u-1],-0).nextSibling:r(n[a-u],0):o;for(;u<a;)e.insertBefore(r(n[u++],1),t)}else if(a===u)for(;c<l;)i&&i.has(t[c])||e.removeChild(r(t[c],-1)),c++;else if(t[c]===n[u])c++,u++;else if(t[l-1]===n[a-1])l--,a--;else if(t[c]===n[a-1]&&n[u]===t[l-1]){const o=r(t[--l],-1).nextSibling;e.insertBefore(r(n[u++],1),r(t[c++],-1).nextSibling),e.insertBefore(r(n[--a],1),o),t[l]=n[a]}else{if(!i){i=new Map;let e=u;for(;e<a;)i.set(n[e],e++)}if(i.has(t[c])){const o=i.get(t[c]);if(u<o&&o<a){let s=c,f=1;for(;++s<l&&s<a&&i.get(t[s])===o+f;)f++;if(f>o-u){const s=r(t[c],0);for(;u<o;)e.insertBefore(r(n[u++],1),s)}else e.replaceChild(r(n[u++],1),r(t[c++],-1))}else c++}else e.removeChild(r(t[c++],-1))}return n})(e.parentNode,t,n,I,e),Z=(e,t)=>"ref"===t?(e=>t=>{"function"==typeof t?t(e):t.current=e})(e):"aria"===t?(e=>t=>{for(const n in t)e.setAttribute("role"===n?n:"aria-"+n,t[n])})(e):".dataset"===t?(({dataset:e})=>t=>{for(const n in t)e[n]=t[n]})(e):"."===t.slice(0,1)?((e,t)=>n=>{e[t]=n})(e,t.slice(1)):"on"===t.slice(0,2)?((e,t)=>{let n,r=t.slice(2);return!(t in e)&&t.toLowerCase()in e&&(r=r.toLowerCase()),t=>{const o=H(t)?t:[t,!1];n!==o[0]&&(n&&e.removeEventListener(r,n,o[1]),(n=o[0])&&e.addEventListener(r,n,o[1]))}})(e,t):((e,t)=>{let n,r=!0;const o=document.createAttributeNS(null,t);return t=>{n!==t&&(n=t,null==n?r||(e.removeAttributeNode(o),r=!0):(o.value=t,r&&(e.setAttributeNodeNS(o),r=!1)))}})(e,t);function ee(e){const{type:t,path:n}=e,r=n.reduceRight(G,this);return"node"===t?(e=>{let t,n,r=[];const o=s=>{switch(typeof s){case"string":case"number":case"boolean":t!==s&&(t=s,n?n.textContent=s:n=document.createTextNode(s),r=Y(e,r,[n]));break;case"object":case"undefined":if(null==s){t!=s&&(t=s,r=Y(e,r,[]));break}if(H(s)){t=s,0===s.length?r=Y(e,r,[]):"object"==typeof s[0]?r=Y(e,r,s):o(String(s));break}"ELEMENT_NODE"in s&&t!==s&&(t=s,r=Y(e,r,11===s.nodeType?q.call(s.childNodes):[s]))}};return o})(r):"attr"===t?Z(r,e.name):(e=>{let t;return n=>{t!=n&&(t=n,e.textContent=null==n?"":n)}})(r)}const te=a(new WeakMap),ne=(e,t)=>{const n=((e,t,n)=>{const r=[],{length:o}=e;for(let n=1;n<o;n++){const o=e[n-1];r.push(O.test(o)&&B(e,n)?o.replace(O,(e,r,o)=>`${t}${n-1}=${o||'"'}${r}${o?"":'"'}`):`${o}\x3c!--${t}${n-1}--\x3e`)}r.push(e[o-1]);const s=r.join("").trim();return n?s:s.replace(R,F)})(t,"isµ","svg"===e),r=V(n,e),o=X(r),s=[],l=t.length-1;let a=0,c="isµ"+a;for(;a<l;){const e=o.nextNode();if(!e)throw"bad template: "+n;if(8===e.nodeType)e.textContent===c&&(s.push({type:"node",path:J(e)}),c="isµ"+ ++a);else{for(;e.hasAttribute(c);)s.push({type:"attr",path:J(e),name:e.getAttribute(c)}),e.removeAttribute(c),c="isµ"+ ++a;/^(?:style|textarea)$/i.test(e.tagName)&&e.textContent.trim()===`\x3c!--${c}--\x3e`&&(s.push({type:"text",path:J(e)}),c="isµ"+ ++a)}}return{content:r,nodes:s}},re=(e,t)=>{const{content:n,nodes:r}=te.get(t)||te.set(t,ne(e,t)),o=Q.call(document,n,!0);return{content:o,updates:r.map(ee,o)}},oe=(e,{type:t,template:n,values:r})=>{const{length:o}=r;se(e,r,o);let{entry:s}=e;s&&s.template===n&&s.type===t||(e.entry=s=((e,t)=>{const{content:n,updates:r}=re(e,t);return{type:e,template:t,content:n,updates:r,wire:null}})(t,n));const{content:l,updates:a,wire:c}=s;for(let e=0;e<o;e++)a[e](r[e]);return c||(s.wire=(e=>{const{childNodes:t}=e,{length:n}=t;if(n<2)return t[0];const r=q.call(t,0);return{ELEMENT_NODE:1,nodeType:111,firstChild:r[0],lastChild:r[n-1],valueOf(){if(t.length!==n){let t=0;for(;t<n;)e.appendChild(r[t++])}return e}}})(l))},se=({stack:e},t,n)=>{for(let r=0;r<n;r++){const n=t[r];n instanceof le?t[r]=oe(e[r]||(e[r]={stack:[],entry:null,wire:null}),n):H(n)?se(e[r]||(e[r]={stack:[],entry:null,wire:null}),n,n.length):e[r]=null}n<e.length&&e.splice(n)};function le(e,t,n){this.type=e,this.template=t,this.values=n}const{create:ae,defineProperties:ce}=Object,ue=e=>{const t=a(new WeakMap);return ce((t,...n)=>new le(e,t,n),{for:{value(n,r){const o=t.get(n)||t.set(n,ae(null));return o[r]||(o[r]=(t=>(n,...r)=>oe(t,{type:e,template:n,values:r}))({stack:[],entry:null,wire:null}))}},node:{value:(t,...n)=>oe({stack:[],entry:null,wire:null},{type:e,template:t,values:n}).valueOf()}})},ie=a(new WeakMap),fe=ue("html"),de=ue("svg"),{isArray:pe}=Array,{create:he}=Object,ge=(e,...t)=>new le("html",e,t);ge.for=$e(fe);const ve=(e,...t)=>new le("svg",e,t);ve.for=$e(de);const me=a(new WeakMap),ye=()=>({stack:[],entry:null}),we=(e,{fn:t,template:n,values:r})=>{let{entry:o}=e;return o&&o.fn===t||(e.entry=o={fn:t,hook:null},o.hook=((e,t)=>S((function(){const n=t.fn.apply(null,arguments);return n instanceof le?(ke(e,n),Ne(t,n)):n})))(ye(),o)),o.hook(n,...r)},ke=(e,{values:t})=>{be(e,t,t.length)},be=({stack:e},t,n)=>{for(let r=0;r<n;r++){const n=t[r];n instanceof Ce?t[r]=we(e[r]||(e[r]=ye()),n):n instanceof le?ke(e[r]||(e[r]=ye()),n):pe(n)?be(e[r]||(e[r]=ye()),n,n.length):e[r]=null}n<e.length&&e.splice(n)},Ne=(e,{type:t,template:n,values:r})=>("svg"===t?de:fe).for(e,t)(n,...r);function Ce(e,t,n){this.fn=e,this.template=t,this.values=n}function $e(e){const t=a(new WeakMap);return(n,r)=>{const o=t.get(n)||t.set(n,he(null)),s=o[r]||(o[r]=ye());return(t,...o)=>(be(s,o),e.for(n,r)(t,...o))}}return e.Component=function(e){return(t,...n)=>new Ce(e,t,n)},e.contextual=e=>{let t=!0,n=null;const r=u((function(){return e.apply(n,arguments)}));return function e(){const o=r.apply(n=this,arguments);return t&&(t=!t,$(r)&&w.set(e,w.get(r))),o}},e.createContext=e=>{const t={value:e,provide:m};return g.set(t,[]),t},e.html=ge,e.render=(e,t)=>{const n="function"==typeof t?t():t,r=me.get(e)||me.set(e,ye());return((e,t)=>{const n="function"==typeof t?t():t,r=ie.get(e)||ie.set(e,{stack:[],entry:null,wire:null}),o=n instanceof le?oe(r,n):n;return o!==r.wire&&(r.wire=o,e.textContent="",e.appendChild(o.valueOf())),e})(e,n instanceof Ce?we(r,n):(ke(r,n),n))},e.svg=ve,e.useCallback=(e,t)=>M(()=>e,t),e.useContext=e=>{const{hook:t,args:n}=c,r=g.get(e),o={hook:t,args:n};return r.some(y,o)||r.push(o),e.value},e.useEffect=x,e.useLayoutEffect=E,e.useMemo=M,e.useReducer=h,e.useRef=e=>{const t=c.i++,{stack:n,length:r}=c;return t===r&&(c.length=n.push({current:e})),n[t]},e.useState=(e,t)=>h(p,e,void 0,t),e}({}); | ||
self.P=function(e){var t="fragment",n="template",r="content"in s(n)?function(e){var t=s(n);return t.innerHTML=e,t.content}:function(e){var r=s(t),l=s(n),a=null;if(/^[^\S]*?<(col(?:group)?|t(?:head|body|foot|r|d|h))/i.test(e)){var c=RegExp.$1;l.innerHTML="<table>"+e+"</table>",a=l.querySelectorAll(c)}else l.innerHTML=e,a=l.childNodes;return o(r,a),r};return function(e,t){return("svg"===t?l:r)(e)};function o(e,t){for(var n=t.length;n--;)e.appendChild(t[0])}function s(n){return n===t?e.createDocumentFragment():e.createElementNS("http://www.w3.org/1999/xhtml",n)}function l(e){var n=s(t),r=s("div");return r.innerHTML='<svg xmlns="http://www.w3.org/2000/svg">'+e+"</svg>",o(n,r.firstChild.childNodes),n}}(document);const G=({childNodes:e},t)=>e[t],J=e=>{const t=[];let{parentNode:n}=e;for(;n;)t.push(z.call(n.childNodes,e)),n=(e=n).parentNode;return t},{createTreeWalker:K,importNode:Q}=document,U=1!=Q.length,V=U?(e,t)=>Q.call(document,P(e,t),!0):P,X=U?e=>K.call(document,e,129,null,!1):e=>K.call(document,e,129),Y=(e,t,n)=>((e,t,n,r,o)=>{const s=n.length;let l=t.length,a=s,c=0,u=0,i=null;for(;c<l||u<a;)if(l===c){const t=a<s?u?r(n[u-1],-0).nextSibling:r(n[a-u],0):o;for(;u<a;)e.insertBefore(r(n[u++],1),t)}else if(a===u)for(;c<l;)i&&i.has(t[c])||e.removeChild(r(t[c],-1)),c++;else if(t[c]===n[u])c++,u++;else if(t[l-1]===n[a-1])l--,a--;else if(t[c]===n[a-1]&&n[u]===t[l-1]){const o=r(t[--l],-1).nextSibling;e.insertBefore(r(n[u++],1),r(t[c++],-1).nextSibling),e.insertBefore(r(n[--a],1),o),t[l]=n[a]}else{if(!i){i=new Map;let e=u;for(;e<a;)i.set(n[e],e++)}if(i.has(t[c])){const o=i.get(t[c]);if(u<o&&o<a){let s=c,f=1;for(;++s<l&&s<a&&i.get(t[s])===o+f;)f++;if(f>o-u){const s=r(t[c],0);for(;u<o;)e.insertBefore(r(n[u++],1),s)}else e.replaceChild(r(n[u++],1),r(t[c++],-1))}else c++}else e.removeChild(r(t[c++],-1))}return n})(e.parentNode,t,n,I,e),Z=(e,t)=>"ref"===t?(e=>t=>{"function"==typeof t?t(e):t.current=e})(e):"aria"===t?(e=>t=>{for(const n in t)e.setAttribute("role"===n?n:"aria-"+n,t[n])})(e):".dataset"===t?(({dataset:e})=>t=>{for(const n in t)e[n]=t[n]})(e):"."===t.slice(0,1)?((e,t)=>n=>{e[t]=n})(e,t.slice(1)):"on"===t.slice(0,2)?((e,t)=>{let n,r=t.slice(2);return!(t in e)&&t.toLowerCase()in e&&(r=r.toLowerCase()),t=>{const o=H(t)?t:[t,!1];n!==o[0]&&(n&&e.removeEventListener(r,n,o[1]),(n=o[0])&&e.addEventListener(r,n,o[1]))}})(e,t):((e,t)=>{let n,r=!0;const o=document.createAttributeNS(null,t);return t=>{n!==t&&(n=t,null==n?r||(e.removeAttributeNode(o),r=!0):(o.value=t,r&&(e.setAttributeNodeNS(o),r=!1)))}})(e,t);function ee(e){const{type:t,path:n}=e,r=n.reduceRight(G,this);return"node"===t?(e=>{let t,n,r=[];const o=s=>{switch(typeof s){case"string":case"number":case"boolean":t!==s&&(t=s,n?n.textContent=s:n=document.createTextNode(s),r=Y(e,r,[n]));break;case"object":case"undefined":if(null==s){t!=s&&(t=s,r=Y(e,r,[]));break}if(H(s)){t=s,0===s.length?r=Y(e,r,[]):"object"==typeof s[0]?r=Y(e,r,s):o(String(s));break}"ELEMENT_NODE"in s&&t!==s&&(t=s,r=Y(e,r,11===s.nodeType?q.call(s.childNodes):[s]))}};return o})(r):"attr"===t?Z(r,e.name):(e=>{let t;return n=>{t!=n&&(t=n,e.textContent=null==n?"":n)}})(r)}const te="isµ",ne=a(new WeakMap),re=(e,t)=>{const n=((e,t,n)=>{const r=[],{length:o}=e;for(let n=1;n<o;n++){const o=e[n-1];r.push(O.test(o)&&B(e,n)?o.replace(O,(e,r,o)=>`${t}${n-1}=${o||'"'}${r}${o?"":'"'}`):`${o}\x3c!--${t}${n-1}--\x3e`)}r.push(e[o-1]);const s=r.join("").trim();return n?s:s.replace(R,F)})(t,te,"svg"===e),r=V(n,e),o=X(r),s=[],l=t.length-1;let a=0,c="isµ"+a;for(;a<l;){const e=o.nextNode();if(!e)throw"bad template: "+n;if(8===e.nodeType)e.textContent===c&&(s.push({type:"node",path:J(e)}),c="isµ"+ ++a);else{for(;e.hasAttribute(c);)s.push({type:"attr",path:J(e),name:e.getAttribute(c)}),e.removeAttribute(c),c="isµ"+ ++a;/^(?:style|textarea)$/i.test(e.tagName)&&e.textContent.trim()===`\x3c!--${c}--\x3e`&&(s.push({type:"text",path:J(e)}),c="isµ"+ ++a)}}return{content:r,nodes:s}},oe=(e,t)=>{const{content:n,nodes:r}=ne.get(t)||ne.set(t,re(e,t)),o=Q.call(document,n,!0);return{content:o,updates:r.map(ee,o)}},se=(e,{type:t,template:n,values:r})=>{const{length:o}=r;le(e,r,o);let{entry:s}=e;s&&s.template===n&&s.type===t||(e.entry=s=((e,t)=>{const{content:n,updates:r}=oe(e,t);return{type:e,template:t,content:n,updates:r,wire:null}})(t,n));const{content:l,updates:a,wire:c}=s;for(let e=0;e<o;e++)a[e](r[e]);return c||(s.wire=(e=>{const{childNodes:t}=e,{length:n}=t;if(n<2)return n?t[0]:e;const r=q.call(t,0);return{ELEMENT_NODE:1,nodeType:111,firstChild:r[0],lastChild:r[n-1],valueOf(){if(t.length!==n){let t=0;for(;t<n;)e.appendChild(r[t++])}return e}}})(l))},le=({stack:e},t,n)=>{for(let r=0;r<n;r++){const n=t[r];n instanceof ae?t[r]=se(e[r]||(e[r]={stack:[],entry:null,wire:null}),n):H(n)?le(e[r]||(e[r]={stack:[],entry:null,wire:null}),n,n.length):e[r]=null}n<e.length&&e.splice(n)};function ae(e,t,n){this.type=e,this.template=t,this.values=n}const{create:ce,defineProperties:ue}=Object,ie=e=>{const t=a(new WeakMap);return ue((t,...n)=>new ae(e,t,n),{for:{value(n,r){const o=t.get(n)||t.set(n,ce(null));return o[r]||(o[r]=(t=>(n,...r)=>se(t,{type:e,template:n,values:r}))({stack:[],entry:null,wire:null}))}},node:{value:(t,...n)=>se({stack:[],entry:null,wire:null},{type:e,template:t,values:n}).valueOf()}})},fe=a(new WeakMap),de=ie("html"),he=ie("svg"),{isArray:pe}=Array,{create:ge}=Object,ve=(e,...t)=>new ae("html",e,t);ve.for=xe(de);const me=(e,...t)=>new ae("svg",e,t);me.for=xe(he);const ye=a(new WeakMap),we=()=>({stack:[],entry:null}),ke=(e,{fn:t,template:n,values:r})=>{let{entry:o}=e;return o&&o.fn===t||(e.entry=o={fn:t,hook:null},o.hook=((e,t)=>S((function(){const n=t.fn.apply(null,arguments);return n instanceof ae?(be(e,n),Ce(t,n)):n})))(we(),o)),o.hook(n,...r)},be=(e,{values:t})=>{Ne(e,t,t.length)},Ne=({stack:e},t,n)=>{for(let r=0;r<n;r++){const n=t[r];n instanceof $e?t[r]=ke(e[r]||(e[r]=we()),n):n instanceof ae?be(e[r]||(e[r]=we()),n):pe(n)?Ne(e[r]||(e[r]=we()),n,n.length):e[r]=null}n<e.length&&e.splice(n)},Ce=(e,{type:t,template:n,values:r})=>("svg"===t?he:de).for(e,t)(n,...r);function $e(e,t,n){this.fn=e,this.template=t,this.values=n}function xe(e){const t=a(new WeakMap);return(n,r)=>{const o=t.get(n)||t.set(n,ge(null)),s=o[r]||(o[r]=we());return(t,...o)=>(Ne(s,o),e.for(n,r)(t,...o))}}return e.Component=function(e){return(t,...n)=>new $e(e,t,n)},e.contextual=e=>{let t=!0,n=null;const r=u((function(){return e.apply(n,arguments)}));return function e(){const o=r.apply(n=this,arguments);return t&&(t=!t,$(r)&&w.set(e,w.get(r))),o}},e.createContext=e=>{const t={value:e,provide:m};return g.set(t,[]),t},e.html=ve,e.render=(e,t)=>{const n="function"==typeof t?t():t,r=ye.get(e)||ye.set(e,we());return((e,t)=>{const n="function"==typeof t?t():t,r=fe.get(e)||fe.set(e,{stack:[],entry:null,wire:null}),o=n instanceof ae?se(r,n):n;return o!==r.wire&&(r.wire=o,e.textContent="",e.appendChild(o.valueOf())),e})(e,n instanceof $e?ke(r,n):(be(r,n),n))},e.svg=me,e.useCallback=(e,t)=>M(()=>e,t),e.useContext=e=>{const{hook:t,args:n}=c,r=g.get(e),o={hook:t,args:n};return r.some(y,o)||r.push(o),e.value},e.useEffect=x,e.useLayoutEffect=E,e.useMemo=M,e.useReducer=p,e.useRef=e=>{const t=c.i++,{stack:n,length:r}=c;return t===r&&(c.length=n.push({current:e})),n[t]},e.useState=(e,t)=>p(h,e,void 0,t),e}({}); |
@@ -106,10 +106,8 @@ import {augmentor} from 'dom-augmentor'; | ||
const info = store[id] || (store[id] = createCache()); | ||
return ( | ||
(template, ...values) => { | ||
unrollValues(info, values); | ||
return uhtml.for(entry, id)(template, ...values); | ||
} | ||
); | ||
return (template, ...values) => { | ||
unrollValues(info, values); | ||
return uhtml.for(entry, id)(template, ...values); | ||
}; | ||
} | ||
); | ||
} |
@@ -591,6 +591,4 @@ self.uland = (function (exports) { | ||
var childNodes = fragment.childNodes; | ||
var length = childNodes.length; // If the fragment has no content | ||
// it should return undefined and break | ||
if (length < 2) return childNodes[0]; | ||
var length = childNodes.length; | ||
if (length < 2) return length ? childNodes[0] : fragment; | ||
var nodes = slice.call(childNodes, 0); | ||
@@ -1014,3 +1012,3 @@ var firstChild = nodes[0]; | ||
// * aria=${...} for aria attributes | ||
// * data=${...} for dataset related attributes | ||
// * .dataset=${...} for dataset related attributes | ||
// * .setter=${...} for Custom Elements setters or nodes with setters | ||
@@ -1017,0 +1015,0 @@ // such as buttons, details, options, select, etc |
self.uland=function(t){"use strict";function e(t){return function(t){if(Array.isArray(t))return n(t)}(t)||function(t){if("undefined"!=typeof Symbol&&Symbol.iterator in Object(t))return Array.from(t)}(t)||function(t,e){if(!t)return;if("string"==typeof t)return n(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);"Object"===r&&t.constructor&&(r=t.constructor.name);if("Map"===r||"Set"===r)return Array.from(t);if("Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return n(t,e)}(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")} | ||
/*! (c) Andrea Giammarchi - ISC */()}function n(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=new Array(e);n<e;n++)r[n]=t[n];return r}var r={};r.CustomEvent="function"==typeof CustomEvent?CustomEvent:function(t){return e.prototype=new e("").constructor.prototype,e;function e(t,e){e||(e={});var n=document.createEvent("CustomEvent");return n.initCustomEvent(t,!!e.bubbles,!!e.cancelable,e.detail),n}}();var a=r.CustomEvent,o={}; | ||
/*! (c) Andrea Giammarchi - ISC */()}function n(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=new Array(e);n<e;n++)r[n]=t[n];return r}var r={};r.CustomEvent="function"==typeof CustomEvent?CustomEvent:function(t){return e[t]=new e("").constructor[t],e;function e(t,e){e||(e={});var n=document.createEvent("CustomEvent");return n.initCustomEvent(t,!!e.bubbles,!!e.cancelable,e.detail),n}}("prototype");var a=r.CustomEvent,o={}; | ||
/*! (c) Andrea Giammarchi - ISC */try{o.WeakSet=WeakSet}catch(t){!function(t){var e=new t,n=r.prototype;function r(n){e.set(this,new t),n&&n.forEach(this.add,this)}n.add=function(t){return e.get(this).set(t,1),this},n.delete=function(t){return e.get(this).delete(t)},n.has=function(t){return e.get(this).has(t)},o.WeakSet=r}(WeakMap)}var u=o.WeakSet; | ||
/*! (c) Andrea Giammarchi */var i="function"==typeof cancelAnimationFrame,c=i?cancelAnimationFrame:clearTimeout,l=i?requestAnimationFrame:setTimeout;function f(t){var e,n,r,a,o;return f(),function(t,i,c){return r=t,a=i,o=c,n||(n=l(u)),--e<0&&s(!0),s};function u(){f(),r.apply(a,o||[])}function f(){e=t||1/0,n=i?0:null}function s(t){var e=!!n;return e&&(c(n),t&&u()),e}}var s=function(t){return{get:function(e){return t.get(e)},set:function(e,n){return t.set(e,n),n}}},v=null,d=function(t){var e=[];return function n(){var r=v,a=[];v={hook:n,args:arguments,stack:e,i:0,length:e.length,after:a};try{return t.apply(null,arguments)}finally{v=r;for(var o=0,u=a.length;o<u;o++)a[o]()}}},p=s(new WeakMap),h=function(t,e,n){t.apply(e,n)},g={async:!1,always:!1},m=function(t,e){return"function"==typeof e?e(t):e},y=function(t,e,n,r){var a=v.i++,o=v,u=o.hook,i=o.args,c=o.stack,l=o.length;a===l&&(v.length=c.push({}));var s=c[a];if(s.args=i,a===l){var d="function"==typeof n,y=(d?r:n)||r||g,w=y.async,b=y.always;s.$=d?n(e):m(void 0,e),s._=w?p.get(u)||p.set(u,f()):h,s.f=function(e){var n=t(s.$,e);(b||s.$!==n)&&(s.$=n,s._(u,null,s.args))}}return[s.$,s.f]},w=new WeakMap,b=function(t){var e=t.hook,n=t.args;e.apply(null,n)}; | ||
/*! (c) Andrea Giammarchi - ISC */function k(t){this.value!==t&&(this.value=t,w.get(this).forEach(b))}function C(t){return t.hook===this.hook}var E=new WeakMap,A=s(E),N=function(){},x=function(t){return function(e,n){var r=v.i++,a=v,o=a.hook,u=a.after,i=a.stack;if(r<a.length){var c=i[r],l=c.update,s=c.values,d=c.stop;if(!n||n.some($,s)){c.values=n,t&&d(t);var p=c.clean;p&&(c.clean=null,p());var h=function(){c.clean=e()};t?l(h):u.push(h)}}else{var g=t?f():N,m={clean:null,update:g,values:n,stop:N};v.length=i.push(m),(A.get(o)||A.set(o,[])).push(m);var y=function(){m.clean=e()};t?m.stop=g(y):u.push(y)}}},S=function(t){(E.get(t)||[]).forEach((function(t){var e=t.clean;(0,t.stop)(),e&&(t.clean=null,e())}))},M=E.has.bind(E),T=x(!0),O=x(!1),W=function(t,e){var n=v.i++,r=v,a=r.stack;return n===r.length?v.length=a.push({$:t(),_:e}):e&&!e.some($,a[n]._)||(a[n]={$:t(),_:e}),a[n].$};function $(t,e){return t!==this[e]} | ||
/*! (c) Andrea Giammarchi - ISC */var L=function(t){var e=t.Event,n=t.WeakSet,r=!0,a=null;return function(t){return r&&(r=!r,a=new n,function(t){var r=new n,o=new n;try{new MutationObserver(l).observe(t,{subtree:!0,childList:!0})}catch(e){var u=0,i=[],c=function(t){i.push(t),clearTimeout(u),u=setTimeout((function(){l(i.splice(u=0,i.length))}),0)};t.addEventListener("DOMNodeRemoved",(function(t){c({addedNodes:[],removedNodes:[t.target]})}),!0),t.addEventListener("DOMNodeInserted",(function(t){c({addedNodes:[t.target],removedNodes:[]})}),!0)}function l(t){for(var e,n=t.length,a=0;a<n;a++)f((e=t[a]).removedNodes,"disconnected",o,r),f(e.addedNodes,"connected",r,o)}function f(t,n,r,a){for(var o,u=new e(n),i=t.length,c=0;c<i;1===(o=t[c++]).nodeType&&s(o,u,n,r,a));}function s(t,e,n,r,o){a.has(t)&&!r.has(t)&&(o.delete(t),r.add(t),t.dispatchEvent(e));for(var u=t.children||[],i=u.length,c=0;c<i;s(u[c++],e,n,r,o));}}(t.ownerDocument)),a.add(t),t}}({Event:a,WeakSet:u}),j=function t(e,n){var r=e.nodeType;if(r){var a=1===r?e:function(t){for(var e=t.firstChild;e&&1!==e.nodeType;)e=e.nextSibling;if(e)return e;throw"unobservable"}(e);L(a),a.addEventListener("disconnected",n,!1)}else{var o=e.valueOf();o!==e&&t(o,n)}},_=/([^\s\\>"'=]+)\s*=\s*(['"]?)$/,D=/^(?:area|base|br|col|embed|hr|img|input|keygen|link|menuitem|meta|param|source|track|wbr)$/i,R=/<[a-z][^>]+$/i,B=/>[^<>]*$/,F=/<([a-z]+[a-z0-9:._-]*)([^>]*?)(\/>)/gi,H=/\s+$/,I=function(t,e,n){return D.test(e)?t:"<".concat(e).concat(n.replace(H,""),"></").concat(e,">")},z=function(t,e,n){for(var r=[],a=t.length,o=function(n){var a=t[n-1];r.push(_.test(a)&&function t(e,n){return 0<n--&&(R.test(e[n])||!B.test(e[n])&&t(e,n))}(t,n)?a.replace(_,(function(t,r,a){return"".concat(e).concat(n-1,"=").concat(a||'"').concat(r).concat(a?"":'"')})):"".concat(a,"\x3c!--").concat(e).concat(n-1,"--\x3e"))},u=1;u<a;u++)o(u);r.push(t[a-1]);var i=r.join("").trim();return n?i:i.replace(F,I)},q=Array.isArray,P=[],U=P.indexOf,G=P.slice,J=function(t,e){return 111===t.nodeType?1/e<0?e?function(t){var e=t.firstChild,n=t.lastChild,r=document.createRange();return r.setStartAfter(e),r.setEndAfter(n),r.deleteContents(),e}(t):t.lastChild:e?t.valueOf():t.firstChild:t},K=function(t){var e="content"in r("template")?function(t){var e=r("template");return e.innerHTML=t,e.content}:function(t){var e=r("fragment"),a=r("template"),o=null;if(/^[^\S]*?<(col(?:group)?|t(?:head|body|foot|r|d|h))/i.test(t)){var u=RegExp.$1;a.innerHTML="<table>"+t+"</table>",o=a.querySelectorAll(u)}else a.innerHTML=t,o=a.childNodes;return n(e,o),e};return function(t,n){return("svg"===n?a:e)(t)};function n(t,e){for(var n=e.length;n--;)t.appendChild(e[0])}function r(e){return"fragment"===e?t.createDocumentFragment():t.createElementNS("http://www.w3.org/1999/xhtml",e)}function a(t){var e=r("fragment"),a=r("div");return a.innerHTML='<svg xmlns="http://www.w3.org/2000/svg">'+t+"</svg>",n(e,a.firstChild.childNodes),e}}(document),Q=function(t,e){return t.childNodes[e]},V=function(t){for(var e=[],n=t.parentNode;n;)e.push(U.call(n.childNodes,t)),n=(t=n).parentNode;return e},X=document,Y=X.createTreeWalker,Z=X.importNode,tt=1!=Z.length,et=tt?function(t,e){return Z.call(document,K(t,e),!0)}:K,nt=tt?function(t){return Y.call(document,t,129,null,!1)}:function(t){return Y.call(document,t,129)},rt=function(t,e,n){return function(t,e,n,r,a){for(var o=n.length,u=e.length,i=o,c=0,l=0,f=null;c<u||l<i;)if(u===c)for(var s=i<o?l?r(n[l-1],-0).nextSibling:r(n[i-l],0):a;l<i;)t.insertBefore(r(n[l++],1),s);else if(i===l)for(;c<u;)f&&f.has(e[c])||t.removeChild(r(e[c],-1)),c++;else if(e[c]===n[l])c++,l++;else if(e[u-1]===n[i-1])u--,i--;else if(e[c]===n[i-1]&&n[l]===e[u-1]){var v=r(e[--u],-1).nextSibling;t.insertBefore(r(n[l++],1),r(e[c++],-1).nextSibling),t.insertBefore(r(n[--i],1),v),e[u]=n[i]}else{if(!f){f=new Map;for(var d=l;d<i;)f.set(n[d],d++)}if(f.has(e[c])){var p=f.get(e[c]);if(l<p&&p<i){for(var h=c,g=1;++h<u&&h<i&&f.get(e[h])===p+g;)g++;if(g>p-l)for(var m=r(e[c],0);l<p;)t.insertBefore(r(n[l++],1),m);else t.replaceChild(r(n[l++],1),r(e[c++],-1))}else c++}else t.removeChild(r(e[c++],-1))}return n}(t.parentNode,e,n,J,t)},at=function(t,e){return"ref"===e?function(t){return function(e){"function"==typeof e?e(t):e.current=t}}(t):"aria"===e?function(t){return function(e){for(var n in e)t.setAttribute("role"===n?n:"aria-".concat(n),e[n])}}(t):".dataset"===e?function(t){var e=t.dataset;return function(t){for(var n in t)e[n]=t[n]}}(t):"."===e.slice(0,1)?function(t,e){return function(n){t[e]=n}}(t,e.slice(1)):"on"===e.slice(0,2)?function(t,e){var n,r=e.slice(2);return!(e in t)&&e.toLowerCase()in t&&(r=r.toLowerCase()),function(e){var a=q(e)?e:[e,!1];n!==a[0]&&(n&&t.removeEventListener(r,n,a[1]),(n=a[0])&&t.addEventListener(r,n,a[1]))}}(t,e):function(t,e){var n,r=!0,a=document.createAttributeNS(null,e);return function(e){n!==e&&(null==(n=e)?r||(t.removeAttributeNode(a),r=!0):(a.value=e,r&&(t.setAttributeNodeNS(a),r=!1)))}}(t,e)};function ot(t){var e=t.type,n=t.path.reduceRight(Q,this);return"node"===e?function(t){var e,n,r=[];return function a(o){switch(typeof o){case"string":case"number":case"boolean":e!==o&&(e=o,n?n.textContent=o:n=document.createTextNode(o),r=rt(t,r,[n]));break;case"object":case"undefined":if(null==o){e!=o&&(e=o,r=rt(t,r,[]));break}if(q(o)){e=o,0===o.length?r=rt(t,r,[]):"object"==typeof o[0]?r=rt(t,r,o):a(String(o));break}"ELEMENT_NODE"in o&&e!==o&&(e=o,r=rt(t,r,11===o.nodeType?G.call(o.childNodes):[o]))}}}(n):"attr"===e?at(n,t.name):function(t){var e;return function(n){e!=n&&(e=n,t.textContent=null==n?"":n)}}(n)}var ut=s(new WeakMap),it=function(t,e){var n=ut.get(e)||ut.set(e,function(t,e){for(var n=z(e,"isµ","svg"===t),r=et(n,t),a=nt(r),o=[],u=e.length-1,i=0,c="".concat("isµ").concat(i);i<u;){var l=a.nextNode();if(!l)throw"bad template: ".concat(n);if(8===l.nodeType)l.textContent===c&&(o.push({type:"node",path:V(l)}),c="".concat("isµ").concat(++i));else{for(;l.hasAttribute(c);)o.push({type:"attr",path:V(l),name:l.getAttribute(c)}),l.removeAttribute(c),c="".concat("isµ").concat(++i);/^(?:style|textarea)$/i.test(l.tagName)&&l.textContent.trim()==="\x3c!--".concat(c,"--\x3e")&&(o.push({type:"text",path:V(l)}),c="".concat("isµ").concat(++i))}}return{content:r,nodes:o}}(t,e)),r=n.content,a=n.nodes,o=Z.call(document,r,!0);return{content:o,updates:a.map(ot,o)}},ct=function(t,e){var n=e.type,r=e.template,a=e.values,o=a.length;lt(t,a,o);var u=t.entry;u&&u.template===r&&u.type===n||(t.entry=u=function(t,e){var n=it(t,e);return{type:t,template:e,content:n.content,updates:n.updates,wire:null}}(n,r));for(var i=u,c=i.content,l=i.updates,f=i.wire,s=0;s<o;s++)l[s](a[s]);return f||(u.wire=function(t){var e=t.childNodes,n=e.length;if(n<2)return e[0];var r=G.call(e,0);return{ELEMENT_NODE:1,nodeType:111,firstChild:r[0],lastChild:r[n-1],valueOf:function(){if(e.length!==n)for(var a=0;a<n;)t.appendChild(r[a++]);return t}}}(c))},lt=function t(e,n,r){for(var a=e.stack,o=0;o<r;o++){var u=n[o];u instanceof ft?n[o]=ct(a[o]||(a[o]={stack:[],entry:null,wire:null}),u):q(u)?t(a[o]||(a[o]={stack:[],entry:null,wire:null}),u,u.length):a[o]=null}r<a.length&&a.splice(r)};function ft(t,e,n){this.type=t,this.template=e,this.values=n}var st=Object.create,vt=Object.defineProperties,dt=function(t){var e=s(new WeakMap);return vt((function(e){for(var n=arguments.length,r=new Array(n>1?n-1:0),a=1;a<n;a++)r[a-1]=arguments[a];return new ft(t,e,r)}),{for:{value:function(n,r){var a=e.get(n)||e.set(n,st(null));return a[r]||(a[r]=function(e){return function(n){for(var r=arguments.length,a=new Array(r>1?r-1:0),o=1;o<r;o++)a[o-1]=arguments[o];return ct(e,{type:t,template:n,values:a})}}({stack:[],entry:null,wire:null}))}},node:{value:function(e){for(var n=arguments.length,r=new Array(n>1?n-1:0),a=1;a<n;a++)r[a-1]=arguments[a];return ct({stack:[],entry:null,wire:null},{type:t,template:e,values:r}).valueOf()}}})},pt=s(new WeakMap),ht=dt("html"),gt=dt("svg"),mt=Array.isArray,yt=Object.create,wt=function(t){for(var e=arguments.length,n=new Array(e>1?e-1:0),r=1;r<e;r++)n[r-1]=arguments[r];return new ft("html",t,n)};wt.for=Tt(ht);var bt=function(t){for(var e=arguments.length,n=new Array(e>1?e-1:0),r=1;r<e;r++)n[r-1]=arguments[r];return new ft("svg",t,n)};bt.for=Tt(gt);var kt=s(new WeakMap),Ct=function(t,e){return n=null,r=d((function(){var n=e.fn.apply(null,arguments);return n instanceof ft?(Nt(t,n),St(e,n)):n})),function(){var t=r.apply(this,arguments);return M(r)&&j(t,n||(n=S.bind(null,r))),t};var n,r},Et=function(){return{stack:[],entry:null}},At=function(t,n){var r,a=n.fn,o=n.template,u=n.values,i=t.entry;return i&&i.fn===a||(t.entry=i={fn:a,hook:null},i.hook=Ct(Et(),i)),(r=i).hook.apply(r,[o].concat(e(u)))},Nt=function(t,e){var n=e.values;xt(t,n,n.length)},xt=function t(e,n,r){for(var a=e.stack,o=0;o<r;o++){var u=n[o];u instanceof Mt?n[o]=At(a[o]||(a[o]=Et()),u):u instanceof ft?Nt(a[o]||(a[o]=Et()),u):mt(u)?t(a[o]||(a[o]=Et()),u,u.length):a[o]=null}r<a.length&&a.splice(r)},St=function(t,n){var r=n.type,a=n.template,o=n.values;return("svg"===r?gt:ht).for(t,r).apply(void 0,[a].concat(e(o)))};function Mt(t,e,n){this.fn=t,this.template=e,this.values=n}function Tt(t){var e=s(new WeakMap);return function(n,r){var a=e.get(n)||e.set(n,yt(null)),o=a[r]||(a[r]=Et());return function(e){for(var a=arguments.length,u=new Array(a>1?a-1:0),i=1;i<a;i++)u[i-1]=arguments[i];return xt(o,u),t.for(n,r).apply(void 0,[e].concat(u))}}}return t.Component=function(t){return function(e){for(var n=arguments.length,r=new Array(n>1?n-1:0),a=1;a<n;a++)r[a-1]=arguments[a];return new Mt(t,e,r)}},t.contextual=function(t){var e=!0,n=null,r=d((function(){return t.apply(n,arguments)}));return function t(){var a=r.apply(n=this,arguments);return e&&(e=!e,M(r)&&E.set(t,E.get(r))),a}},t.createContext=function(t){var e={value:t,provide:k};return w.set(e,[]),e},t.html=wt,t.render=function(t,e){var n="function"==typeof e?e():e,r=kt.get(t)||kt.set(t,Et());return function(t,e){var n="function"==typeof e?e():e,r=pt.get(t)||pt.set(t,{stack:[],entry:null,wire:null}),a=n instanceof ft?ct(r,n):n;return a!==r.wire&&(r.wire=a,t.textContent="",t.appendChild(a.valueOf())),t}(t,n instanceof Mt?At(r,n):(Nt(r,n),n))},t.svg=bt,t.useCallback=function(t,e){return W((function(){return t}),e)},t.useContext=function(t){var e=v,n=e.hook,r=e.args,a=w.get(t),o={hook:n,args:r};return a.some(C,o)||a.push(o),t.value},t.useEffect=T,t.useLayoutEffect=O,t.useMemo=W,t.useReducer=y,t.useRef=function(t){var e=v.i++,n=v,r=n.stack;return e===n.length&&(v.length=r.push({current:t})),r[e]},t.useState=function(t,e){return y(m,t,void 0,e)},t}({}); | ||
/*! (c) Andrea Giammarchi */var i="function"==typeof cancelAnimationFrame,c=i?cancelAnimationFrame:clearTimeout,l=i?requestAnimationFrame:setTimeout;function f(t){var e,n,r,a,o;return f(),function(t,i,c){return r=t,a=i,o=c,n||(n=l(u)),--e<0&&s(!0),s};function u(){f(),r.apply(a,o||[])}function f(){e=t||1/0,n=i?0:null}function s(t){var e=!!n;return e&&(c(n),t&&u()),e}}var s=function(t){return{get:function(e){return t.get(e)},set:function(e,n){return t.set(e,n),n}}},v=null,d=function(t){var e=[];return function n(){var r=v,a=[];v={hook:n,args:arguments,stack:e,i:0,length:e.length,after:a};try{return t.apply(null,arguments)}finally{v=r;for(var o=0,u=a.length;o<u;o++)a[o]()}}},h=s(new WeakMap),p=function(t,e,n){t.apply(e,n)},g={async:!1,always:!1},y=function(t,e){return"function"==typeof e?e(t):e},m=function(t,e,n,r){var a=v.i++,o=v,u=o.hook,i=o.args,c=o.stack,l=o.length;a===l&&(v.length=c.push({}));var s=c[a];if(s.args=i,a===l){var d="function"==typeof n,m=(d?r:n)||r||g,w=m.async,b=m.always;s.$=d?n(e):y(void 0,e),s._=w?h.get(u)||h.set(u,f()):p,s.f=function(e){var n=t(s.$,e);(b||s.$!==n)&&(s.$=n,s._(u,null,s.args))}}return[s.$,s.f]},w=new WeakMap,b=function(t){var e=t.hook,n=t.args;e.apply(null,n)}; | ||
/*! (c) Andrea Giammarchi - ISC */function k(t){this.value!==t&&(this.value=t,w.get(this).forEach(b))}function C(t){return t.hook===this.hook}var E=new WeakMap,A=s(E),N=function(){},x=function(t){return function(e,n){var r=v.i++,a=v,o=a.hook,u=a.after,i=a.stack;if(r<a.length){var c=i[r],l=c.update,s=c.values,d=c.stop;if(!n||n.some($,s)){c.values=n,t&&d(t);var h=c.clean;h&&(c.clean=null,h());var p=function(){c.clean=e()};t?l(p):u.push(p)}}else{var g=t?f():N,y={clean:null,update:g,values:n,stop:N};v.length=i.push(y),(A.get(o)||A.set(o,[])).push(y);var m=function(){y.clean=e()};t?y.stop=g(m):u.push(m)}}},S=function(t){(E.get(t)||[]).forEach((function(t){var e=t.clean;(0,t.stop)(),e&&(t.clean=null,e())}))},M=E.has.bind(E),T=x(!0),O=x(!1),W=function(t,e){var n=v.i++,r=v,a=r.stack;return n===r.length?v.length=a.push({$:t(),_:e}):e&&!e.some($,a[n]._)||(a[n]={$:t(),_:e}),a[n].$};function $(t,e){return t!==this[e]} | ||
/*! (c) Andrea Giammarchi - ISC */var L=function(t){var e=t.Event,n=t.WeakSet,r=!0,a=null;return function(t){return r&&(r=!r,a=new n,function(t){var r=new n,o=new n;try{new MutationObserver(l).observe(t,{subtree:!0,childList:!0})}catch(e){var u=0,i=[],c=function(t){i.push(t),clearTimeout(u),u=setTimeout((function(){l(i.splice(u=0,i.length))}),0)};t.addEventListener("DOMNodeRemoved",(function(t){c({addedNodes:[],removedNodes:[t.target]})}),!0),t.addEventListener("DOMNodeInserted",(function(t){c({addedNodes:[t.target],removedNodes:[]})}),!0)}function l(t){for(var e,n=t.length,a=0;a<n;a++)f((e=t[a]).removedNodes,"disconnected",o,r),f(e.addedNodes,"connected",r,o)}function f(t,n,r,a){for(var o,u=new e(n),i=t.length,c=0;c<i;1===(o=t[c++]).nodeType&&s(o,u,n,r,a));}function s(t,e,n,r,o){a.has(t)&&!r.has(t)&&(o.delete(t),r.add(t),t.dispatchEvent(e));for(var u=t.children||[],i=u.length,c=0;c<i;s(u[c++],e,n,r,o));}}(t.ownerDocument)),a.add(t),t}}({Event:a,WeakSet:u}),j=function t(e,n){var r=e.nodeType;if(r){var a=1===r?e:function(t){for(var e=t.firstChild;e&&1!==e.nodeType;)e=e.nextSibling;if(e)return e;throw"unobservable"}(e);L(a),a.addEventListener("disconnected",n,!1)}else{var o=e.valueOf();o!==e&&t(o,n)}},_=/([^\s\\>"'=]+)\s*=\s*(['"]?)$/,D=/^(?:area|base|br|col|embed|hr|img|input|keygen|link|menuitem|meta|param|source|track|wbr)$/i,R=/<[a-z][^>]+$/i,B=/>[^<>]*$/,F=/<([a-z]+[a-z0-9:._-]*)([^>]*?)(\/>)/gi,H=/\s+$/,I=function(t,e,n){return D.test(e)?t:"<".concat(e).concat(n.replace(H,""),"></").concat(e,">")},z=function(t,e,n){for(var r=[],a=t.length,o=function(n){var a=t[n-1];r.push(_.test(a)&&function t(e,n){return 0<n--&&(R.test(e[n])||!B.test(e[n])&&t(e,n))}(t,n)?a.replace(_,(function(t,r,a){return"".concat(e).concat(n-1,"=").concat(a||'"').concat(r).concat(a?"":'"')})):"".concat(a,"\x3c!--").concat(e).concat(n-1,"--\x3e"))},u=1;u<a;u++)o(u);r.push(t[a-1]);var i=r.join("").trim();return n?i:i.replace(F,I)},q=Array.isArray,P=[],U=P.indexOf,G=P.slice,J=function(t,e){return 111===t.nodeType?1/e<0?e?function(t){var e=t.firstChild,n=t.lastChild,r=document.createRange();return r.setStartAfter(e),r.setEndAfter(n),r.deleteContents(),e}(t):t.lastChild:e?t.valueOf():t.firstChild:t},K=function(t){var e="fragment",n="template",r="content"in o(n)?function(t){var e=o(n);return e.innerHTML=t,e.content}:function(t){var r=o(e),u=o(n),i=null;if(/^[^\S]*?<(col(?:group)?|t(?:head|body|foot|r|d|h))/i.test(t)){var c=RegExp.$1;u.innerHTML="<table>"+t+"</table>",i=u.querySelectorAll(c)}else u.innerHTML=t,i=u.childNodes;return a(r,i),r};return function(t,e){return("svg"===e?u:r)(t)};function a(t,e){for(var n=e.length;n--;)t.appendChild(e[0])}function o(n){return n===e?t.createDocumentFragment():t.createElementNS("http://www.w3.org/1999/xhtml",n)}function u(t){var n=o(e),r=o("div");return r.innerHTML='<svg xmlns="http://www.w3.org/2000/svg">'+t+"</svg>",a(n,r.firstChild.childNodes),n}}(document),Q=function(t,e){return t.childNodes[e]},V=function(t){for(var e=[],n=t.parentNode;n;)e.push(U.call(n.childNodes,t)),n=(t=n).parentNode;return e},X=document,Y=X.createTreeWalker,Z=X.importNode,tt=1!=Z.length,et=tt?function(t,e){return Z.call(document,K(t,e),!0)}:K,nt=tt?function(t){return Y.call(document,t,129,null,!1)}:function(t){return Y.call(document,t,129)},rt=function(t,e,n){return function(t,e,n,r,a){for(var o=n.length,u=e.length,i=o,c=0,l=0,f=null;c<u||l<i;)if(u===c)for(var s=i<o?l?r(n[l-1],-0).nextSibling:r(n[i-l],0):a;l<i;)t.insertBefore(r(n[l++],1),s);else if(i===l)for(;c<u;)f&&f.has(e[c])||t.removeChild(r(e[c],-1)),c++;else if(e[c]===n[l])c++,l++;else if(e[u-1]===n[i-1])u--,i--;else if(e[c]===n[i-1]&&n[l]===e[u-1]){var v=r(e[--u],-1).nextSibling;t.insertBefore(r(n[l++],1),r(e[c++],-1).nextSibling),t.insertBefore(r(n[--i],1),v),e[u]=n[i]}else{if(!f){f=new Map;for(var d=l;d<i;)f.set(n[d],d++)}if(f.has(e[c])){var h=f.get(e[c]);if(l<h&&h<i){for(var p=c,g=1;++p<u&&p<i&&f.get(e[p])===h+g;)g++;if(g>h-l)for(var y=r(e[c],0);l<h;)t.insertBefore(r(n[l++],1),y);else t.replaceChild(r(n[l++],1),r(e[c++],-1))}else c++}else t.removeChild(r(e[c++],-1))}return n}(t.parentNode,e,n,J,t)},at=function(t,e){return"ref"===e?function(t){return function(e){"function"==typeof e?e(t):e.current=t}}(t):"aria"===e?function(t){return function(e){for(var n in e)t.setAttribute("role"===n?n:"aria-".concat(n),e[n])}}(t):".dataset"===e?function(t){var e=t.dataset;return function(t){for(var n in t)e[n]=t[n]}}(t):"."===e.slice(0,1)?function(t,e){return function(n){t[e]=n}}(t,e.slice(1)):"on"===e.slice(0,2)?function(t,e){var n,r=e.slice(2);return!(e in t)&&e.toLowerCase()in t&&(r=r.toLowerCase()),function(e){var a=q(e)?e:[e,!1];n!==a[0]&&(n&&t.removeEventListener(r,n,a[1]),(n=a[0])&&t.addEventListener(r,n,a[1]))}}(t,e):function(t,e){var n,r=!0,a=document.createAttributeNS(null,e);return function(e){n!==e&&(null==(n=e)?r||(t.removeAttributeNode(a),r=!0):(a.value=e,r&&(t.setAttributeNodeNS(a),r=!1)))}}(t,e)};function ot(t){var e=t.type,n=t.path.reduceRight(Q,this);return"node"===e?function(t){var e,n,r=[];return function a(o){switch(typeof o){case"string":case"number":case"boolean":e!==o&&(e=o,n?n.textContent=o:n=document.createTextNode(o),r=rt(t,r,[n]));break;case"object":case"undefined":if(null==o){e!=o&&(e=o,r=rt(t,r,[]));break}if(q(o)){e=o,0===o.length?r=rt(t,r,[]):"object"==typeof o[0]?r=rt(t,r,o):a(String(o));break}"ELEMENT_NODE"in o&&e!==o&&(e=o,r=rt(t,r,11===o.nodeType?G.call(o.childNodes):[o]))}}}(n):"attr"===e?at(n,t.name):function(t){var e;return function(n){e!=n&&(e=n,t.textContent=null==n?"":n)}}(n)}var ut="isµ",it=s(new WeakMap),ct=function(t,e){var n=it.get(e)||it.set(e,function(t,e){for(var n=z(e,ut,"svg"===t),r=et(n,t),a=nt(r),o=[],u=e.length-1,i=0,c="".concat(ut).concat(i);i<u;){var l=a.nextNode();if(!l)throw"bad template: ".concat(n);if(8===l.nodeType)l.textContent===c&&(o.push({type:"node",path:V(l)}),c="".concat(ut).concat(++i));else{for(;l.hasAttribute(c);)o.push({type:"attr",path:V(l),name:l.getAttribute(c)}),l.removeAttribute(c),c="".concat(ut).concat(++i);/^(?:style|textarea)$/i.test(l.tagName)&&l.textContent.trim()==="\x3c!--".concat(c,"--\x3e")&&(o.push({type:"text",path:V(l)}),c="".concat(ut).concat(++i))}}return{content:r,nodes:o}}(t,e)),r=n.content,a=n.nodes,o=Z.call(document,r,!0);return{content:o,updates:a.map(ot,o)}},lt=function(t,e){var n=e.type,r=e.template,a=e.values,o=a.length;ft(t,a,o);var u=t.entry;u&&u.template===r&&u.type===n||(t.entry=u=function(t,e){var n=ct(t,e);return{type:t,template:e,content:n.content,updates:n.updates,wire:null}}(n,r));for(var i=u,c=i.content,l=i.updates,f=i.wire,s=0;s<o;s++)l[s](a[s]);return f||(u.wire=function(t){var e=t.childNodes,n=e.length;if(n<2)return n?e[0]:t;var r=G.call(e,0);return{ELEMENT_NODE:1,nodeType:111,firstChild:r[0],lastChild:r[n-1],valueOf:function(){if(e.length!==n)for(var a=0;a<n;)t.appendChild(r[a++]);return t}}}(c))},ft=function t(e,n,r){for(var a=e.stack,o=0;o<r;o++){var u=n[o];u instanceof st?n[o]=lt(a[o]||(a[o]={stack:[],entry:null,wire:null}),u):q(u)?t(a[o]||(a[o]={stack:[],entry:null,wire:null}),u,u.length):a[o]=null}r<a.length&&a.splice(r)};function st(t,e,n){this.type=t,this.template=e,this.values=n}var vt=Object.create,dt=Object.defineProperties,ht=function(t){var e=s(new WeakMap);return dt((function(e){for(var n=arguments.length,r=new Array(n>1?n-1:0),a=1;a<n;a++)r[a-1]=arguments[a];return new st(t,e,r)}),{for:{value:function(n,r){var a=e.get(n)||e.set(n,vt(null));return a[r]||(a[r]=function(e){return function(n){for(var r=arguments.length,a=new Array(r>1?r-1:0),o=1;o<r;o++)a[o-1]=arguments[o];return lt(e,{type:t,template:n,values:a})}}({stack:[],entry:null,wire:null}))}},node:{value:function(e){for(var n=arguments.length,r=new Array(n>1?n-1:0),a=1;a<n;a++)r[a-1]=arguments[a];return lt({stack:[],entry:null,wire:null},{type:t,template:e,values:r}).valueOf()}}})},pt=s(new WeakMap),gt=ht("html"),yt=ht("svg"),mt=Array.isArray,wt=Object.create,bt=function(t){for(var e=arguments.length,n=new Array(e>1?e-1:0),r=1;r<e;r++)n[r-1]=arguments[r];return new st("html",t,n)};bt.for=Ot(gt);var kt=function(t){for(var e=arguments.length,n=new Array(e>1?e-1:0),r=1;r<e;r++)n[r-1]=arguments[r];return new st("svg",t,n)};kt.for=Ot(yt);var Ct=s(new WeakMap),Et=function(t,e){return n=null,r=d((function(){var n=e.fn.apply(null,arguments);return n instanceof st?(xt(t,n),Mt(e,n)):n})),function(){var t=r.apply(this,arguments);return M(r)&&j(t,n||(n=S.bind(null,r))),t};var n,r},At=function(){return{stack:[],entry:null}},Nt=function(t,n){var r,a=n.fn,o=n.template,u=n.values,i=t.entry;return i&&i.fn===a||(t.entry=i={fn:a,hook:null},i.hook=Et(At(),i)),(r=i).hook.apply(r,[o].concat(e(u)))},xt=function(t,e){var n=e.values;St(t,n,n.length)},St=function t(e,n,r){for(var a=e.stack,o=0;o<r;o++){var u=n[o];u instanceof Tt?n[o]=Nt(a[o]||(a[o]=At()),u):u instanceof st?xt(a[o]||(a[o]=At()),u):mt(u)?t(a[o]||(a[o]=At()),u,u.length):a[o]=null}r<a.length&&a.splice(r)},Mt=function(t,n){var r=n.type,a=n.template,o=n.values;return("svg"===r?yt:gt).for(t,r).apply(void 0,[a].concat(e(o)))};function Tt(t,e,n){this.fn=t,this.template=e,this.values=n}function Ot(t){var e=s(new WeakMap);return function(n,r){var a=e.get(n)||e.set(n,wt(null)),o=a[r]||(a[r]=At());return function(e){for(var a=arguments.length,u=new Array(a>1?a-1:0),i=1;i<a;i++)u[i-1]=arguments[i];return St(o,u),t.for(n,r).apply(void 0,[e].concat(u))}}}return t.Component=function(t){return function(e){for(var n=arguments.length,r=new Array(n>1?n-1:0),a=1;a<n;a++)r[a-1]=arguments[a];return new Tt(t,e,r)}},t.contextual=function(t){var e=!0,n=null,r=d((function(){return t.apply(n,arguments)}));return function t(){var a=r.apply(n=this,arguments);return e&&(e=!e,M(r)&&E.set(t,E.get(r))),a}},t.createContext=function(t){var e={value:t,provide:k};return w.set(e,[]),e},t.html=bt,t.render=function(t,e){var n="function"==typeof e?e():e,r=Ct.get(t)||Ct.set(t,At());return function(t,e){var n="function"==typeof e?e():e,r=pt.get(t)||pt.set(t,{stack:[],entry:null,wire:null}),a=n instanceof st?lt(r,n):n;return a!==r.wire&&(r.wire=a,t.textContent="",t.appendChild(a.valueOf())),t}(t,n instanceof Tt?Nt(r,n):(xt(r,n),n))},t.svg=kt,t.useCallback=function(t,e){return W((function(){return t}),e)},t.useContext=function(t){var e=v,n=e.hook,r=e.args,a=w.get(t),o={hook:n,args:r};return a.some(C,o)||a.push(o),t.value},t.useEffect=T,t.useLayoutEffect=O,t.useMemo=W,t.useReducer=m,t.useRef=function(t){var e=v.i++,n=v,r=n.stack;return e===n.length&&(v.length=r.push({current:t})),r[e]},t.useState=function(t,e){return m(y,t,void 0,e)},t}({}); |
{ | ||
"name": "uland", | ||
"version": "0.1.1", | ||
"version": "0.2.0", | ||
"main": "./cjs/index.js", | ||
@@ -17,13 +17,13 @@ "scripts": { | ||
"devDependencies": { | ||
"@babel/core": "^7.10.3", | ||
"@babel/preset-env": "^7.10.3", | ||
"@babel/core": "^7.11.4", | ||
"@babel/preset-env": "^7.11.0", | ||
"@ungap/degap": "^0.2.0", | ||
"ascjs": "^4.0.1", | ||
"drop-babel-typeof": "^1.0.3", | ||
"rollup": "^2.17.1", | ||
"rollup": "^2.26.5", | ||
"rollup-plugin-babel": "^4.4.0", | ||
"rollup-plugin-includepaths": "^0.2.3", | ||
"rollup-plugin-includepaths": "^0.2.4", | ||
"rollup-plugin-node-resolve": "^5.2.0", | ||
"rollup-plugin-terser": "^6.1.0", | ||
"terser": "^4.8.0" | ||
"rollup-plugin-terser": "^7.0.0", | ||
"terser": "^5.2.1" | ||
}, | ||
@@ -39,3 +39,3 @@ "module": "./esm/index.js", | ||
"dom-augmentor": "^2.0.8", | ||
"uhtml": "^2.0.1", | ||
"uhtml": "^2.1.0", | ||
"umap": "^1.0.2" | ||
@@ -42,0 +42,0 @@ }, |
@@ -1,5 +0,9 @@ | ||
# <em>µ</em>land | ||
# 🦄 <em>µ</em>land | ||
micro-land, is a [µhtml](https://github.com/WebReflection/uhtml#readme) take at [neverland](https://github.com/WebReflection/neverland/#readme). | ||
![tiny island](./uland-head.jpg) | ||
<sup>**Social Media Photo by [Ben Klea](https://unsplash.com/@benkleaphoto) on [Unsplash](https://unsplash.com/)**</sup> | ||
*micro* land, or *unicorn* land, is a [µhtml](https://github.com/WebReflection/uhtml#readme) take at [neverland](https://github.com/WebReflection/neverland/#readme). | ||
Same API, except the exports are `{Component, render, html, svg}`, where `Component` is a function you can use either as `new Component(...)` or just `Component(...)` which is the equivalent of _neverland_ default export. | ||
@@ -10,5 +14,29 @@ | ||
The concept is exactly the same as the _neverland_ one, so please go there to know more about this module usage. | ||
The concept is exactly the same as the _neverland_ one. | ||
[Live demo](https://codepen.io/WebReflection/pen/dyGvNdg?editors=0010). | ||
```js | ||
import {Component, render, html, useState} from 'uland'; | ||
const Counter = Component((initialState) => { | ||
const [count, setCount] = useState(initialState); | ||
return html` | ||
<button onclick=${() => setCount(count + 1)}> | ||
Count: ${count} | ||
</button>`; | ||
}); | ||
// basic example, show two independent counters | ||
render(document.body, html` | ||
<div> | ||
A bounce of counters.<hr> | ||
${Counter(0)} ${Counter(1)} | ||
</div> | ||
`); | ||
``` | ||
Please [check neverland](https://github.com/WebReflection/neverland/#concept) to know more about this module usage. | ||
## Differences | ||
@@ -15,0 +43,0 @@ |
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
143893
11
57
1506
Updateduhtml@^2.1.0