Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

riot

Package Overview
Dependencies
Maintainers
1
Versions
280
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

riot - npm Package Compare versions

Comparing version 5.1.1 to 5.1.2

18

package.json
{
"name": "riot",
"version": "5.1.1",
"version": "5.1.2",
"description": "Simple and elegant component-based UI library",

@@ -39,3 +39,3 @@ "homepage": "http://riot.js.org/",

"@riotjs/compiler": "^5.1.3",
"@riotjs/dom-bindings": "5.0.0",
"@riotjs/dom-bindings": "5.0.1",
"@riotjs/util": "^2.0.0",

@@ -48,8 +48,8 @@ "bianco.attr": "^1.0.0",

"devDependencies": {
"@babel/core": "^7.12.9",
"@babel/preset-env": "^7.12.7",
"@babel/core": "^7.12.10",
"@babel/preset-env": "^7.12.11",
"@riotjs/babel-preset": "1.0.0",
"@rollup/plugin-commonjs": "^17.0.0",
"@rollup/plugin-json": "^4.1.0",
"@rollup/plugin-node-resolve": "^11.0.0",
"@rollup/plugin-node-resolve": "^11.0.1",
"babel-plugin-istanbul": "^6.0.0",

@@ -59,3 +59,3 @@ "chai": "^4.2.0",

"coveralls": "^3.1.0",
"eslint": "^7.15.0",
"eslint": "^7.16.0",
"eslint-config-riot": "^3.0.0",

@@ -71,9 +71,9 @@ "jsdom": "16.4.0",

"mocha": "^8.2.1",
"rollup": "^2.34.2",
"rollup": "^2.35.1",
"rollup-plugin-babel": "^4.4.0",
"rollup-plugin-riot": "^5.0.0",
"sinon": "^9.2.1",
"sinon": "^9.2.2",
"sinon-chai": "^3.5.0",
"terser": "^5.5.1",
"typescript": "^4.1.2"
"typescript": "^4.1.3"
},

@@ -80,0 +80,0 @@ "files": [

@@ -1,2 +0,2 @@

/* Riot v5.1.1, @license MIT */
var t,e;t=this,e=function(t){"use strict";function e(t){return t.replace(/-(\w)/g,((t,e)=>e.toUpperCase()))}function n(t,e){t.firstChild&&(e.appendChild(t.firstChild),n(t,e))}function r(t){Array.from(t).forEach(s)}const s=t=>t&&t.parentNode&&t.parentNode.removeChild(t),o=(t,e)=>e&&e.parentNode&&e.parentNode.insertBefore(t,e);var i={EACH:0,IF:1,SIMPLE:2,TAG:3,SLOT:4},u={ATTRIBUTE:0,EVENT:1,TEXT:2,VALUE:3};function a(t,e){return typeof t===e}function c(t){const e=t.ownerSVGElement;return!!e||null===e}function l(t){return!d(t.content)}function h(t){return a(t,"function")}function p(t){return!d(t)&&a(t,"object")}function d(t){return null==t}const m=Symbol("unmount"),f={nodes:[],mount(t,e){return this.update(t,e)},update(t,e){const{placeholder:n,nodes:r,childrenMap:i}=this,u=t===m?null:this.evaluate(t),a=u?Array.from(u):[],{newChildrenMap:c,batches:l,futureNodes:h}=(n.parentNode,function(t,e,n,r){const{condition:s,template:o,childrenMap:i,itemName:u,getKey:a,indexName:c,root:l,isTemplateTag:h}=r,p=new Map,d=[],m=[];return t.forEach(((t,r)=>{const f=function(t,e){let{itemName:n,indexName:r,index:s,item:o}=e;return t[n]=o,r&&(t[r]=s),t}(Object.create(e),{itemName:u,indexName:c,index:r,item:t}),b=a?a(f):r,g=i.get(b);if(function(t,e){return!!t&&!1===Boolean(t(e))}(s,f))return;const O=g?g.template:o.clone(),E=g?O.el:l.cloneNode(),v=!g,N=h&&v?function(t){const e=t.dom.cloneNode(!0);return{avoidDOMInjection:!0,fragment:e,children:Array.from(e.childNodes)}}(O):{};if(v?d.push((()=>O.mount(E,f,n,N))):d.push((()=>O.update(f,n))),h){const t=N.children||O.children;m.push(...t)}else m.push(E);i.delete(b),p.set(b,{template:O,context:f,index:r})})),{newChildrenMap:p,batches:d,futureNodes:m}}(a,t,e,this));return((t,e,n,r,i)=>{const u=n.length;let a=e.length,c=u,l=0,h=0,p=null;for(;l<a||h<c;)if(a===l){const t=c<u?h?r(n[h-1],-0).nextSibling:r(n[c-h],0):i;for(;h<c;)o(r(n[h++],1),t)}else if(c===h)for(;l<a;)p&&p.has(e[l])||s(r(e[l],-1)),l++;else if(e[l]===n[h])l++,h++;else if(e[a-1]===n[c-1])a--,c--;else if(e[l]===n[c-1]&&n[h]===e[a-1]){const t=r(e[--a],-1).nextSibling;o(r(n[h++],1),r(e[l++],-1).nextSibling),o(r(n[--c],1),t),e[a]=n[c]}else{if(!p){p=new Map;let t=h;for(;t<c;)p.set(n[t],t++)}if(p.has(e[l])){const t=p.get(e[l]);if(h<t&&t<c){let s=l,i=1;for(;++s<a&&s<c&&p.get(e[s])===t+i;)i++;if(i>t-h){const s=r(e[l],0);for(;h<t;)o(r(n[h++],1),s)}else d=r(n[h++],1),(m=r(e[l++],-1))&&m.parentNode&&m.parentNode.replaceChild(d,m)}else l++}else s(r(e[l++],-1))}var d,m})(0,r,h,function(t,e){return(n,r)=>{if(r<0){const n=t.pop();if(n){const{template:t,context:r}=n;t.unmount(r,e,null)}}return n}}(Array.from(i.values()),e),n),l.forEach((t=>t())),this.childrenMap=c,this.nodes=h,this},unmount(t,e){return this.update(m,e),this}},b={mount(t,e){return this.update(t,e)},update(t,e){const n=!!this.evaluate(t),r=!this.value&&n,s=this.value&&!n,i=()=>{const n=this.node.cloneNode();o(n,this.placeholder),this.template=this.template.clone(),this.template.mount(n,t,e)};switch(!0){case r:i();break;case s:this.unmount(t);break;default:n&&this.template.update(t,e)}return this.value=n,this},unmount(t,e){return this.template.unmount(t,e,!0),this}};function g(t){throw new Error(t)}function O(t){return t.reduce(((t,n)=>{const{value:r,type:s}=n;switch(!0){case!n.name&&0===s:return Object.assign({},t,r);case 3===s:t.value=n.value;break;default:t[e(n.name)]=n.value}return t}),{})}const E="removeAttribute",v="setAttribute",N="undefined"==typeof Element?{}:Element.prototype,T=function(t){const e=new Map,n=n=>(e.has(n)||e.set(n,t.call(this,n)))&&e.get(n);return n.cache=e,n}((t=>N.hasOwnProperty(t)));function y(t,e,n,r){let{name:s}=e;if(!s)return r&&function(t,e,n){const r=e?Object.keys(e):[];Object.keys(n).filter((t=>!r.includes(t))).forEach((e=>t.removeAttribute(e)))}(t,n,r),void(n&&function(t,e){Object.entries(e).forEach((e=>{let[n,r]=e;return y(t,{name:n},r)}))}(t,n));!T(s)&&(function(t){return a(t,"boolean")}(n)||p(n)||h(n))&&(t[s]=n),t[function(t){return d(t)||!1===t||""===t||p(t)||h(t)?E:v}(n)](s,function(t,e){return!0===e?t:e}(s,n))}const M=/^on/,_={handleEvent(t){this[t.type](t)}},j=new WeakMap;function A(t){return d(t)?"":t}const S=(t,e)=>{const n=t.childNodes[e];if(n.nodeType===Node.COMMENT_NODE){const e=document.createTextNode("");return t.replaceChild(e,n),e}return n};var w={0:y,1:function(t,e,n){let{name:r}=e;const s=r.replace(M,""),o=j.get(t)||(t=>{const e=Object.create(_);return j.set(t,e),e})(t),[i,u]=(t=>Array.isArray(t)?t:[t,!1])(n),a=o[s],c=i&&!a;a&&!i&&t.removeEventListener(s,o),c&&t.addEventListener(s,o,u),o[s]=i},2:function(t,e,n){t.data=A(n)},3:function(t,e,n){t.value=A(n)}};const x={mount(t){return this.value=this.evaluate(t),P(this,this.value),this},update(t){const e=this.evaluate(t);return this.value!==e&&(P(this,e),this.value=e),this},unmount(){return 1===this.type&&P(this,null),this}};function P(t,e){return w[t.type](t.node,t,e,t.value)}function U(t,e){return Object.assign({},x,e,{node:2===e.type?S(t,e.childNodeIndex):t})}const C=new Map,D=Symbol("riot-component"),I=new Set,Y="is",L="mount",B="update",K="unmount",R="shouldUpdate",k="onBeforeMount",$="onMounted",z="onBeforeUpdate",H="onUpdated",F="onBeforeUnmount",V="onUnmounted",G="props",q="state",W="slots",X="root",Z=Symbol.for("pure"),J=Symbol("parent"),Q=Symbol("attributes"),tt=Symbol("template");var et=Object.freeze({__proto__:null,COMPONENTS_IMPLEMENTATION_MAP:C,DOM_COMPONENT_INSTANCE_PROPERTY:D,PLUGINS_SET:I,IS_DIRECTIVE:Y,VALUE_ATTRIBUTE:"value",MOUNT_METHOD_KEY:L,UPDATE_METHOD_KEY:B,UNMOUNT_METHOD_KEY:K,SHOULD_UPDATE_KEY:R,ON_BEFORE_MOUNT_KEY:k,ON_MOUNTED_KEY:$,ON_BEFORE_UPDATE_KEY:z,ON_UPDATED_KEY:H,ON_BEFORE_UNMOUNT_KEY:F,ON_UNMOUNTED_KEY:V,PROPS_KEY:G,STATE_KEY:q,SLOTS_KEY:W,ROOT_KEY:X,IS_PURE_SYMBOL:Z,PARENT_KEY_SYMBOL:J,ATTRIBUTES_KEY_SYMBOL:Q,TEMPLATE_KEY_SYMBOL:tt});const nt=(t,e)=>t[J]||e,rt={attributes:[],getTemplateScope(t,e){return function(t,e,n){if(!t||!t.length)return n;const r=t.map((t=>Object.assign({},t,{value:t.evaluate(e)})));return Object.assign(Object.create(n||null),O(r))}(this.attributes,t,e)},mount(t,e){const n=!!t.slots&&t.slots.find((t=>{let{id:e}=t;return e===this.name})),{parentNode:r}=this.node,o=nt(t,e);return this.template=n&&dt(n.html,n.bindings).createDOM(r),this.template&&(this.template.mount(this.node,this.getTemplateScope(t,o),o),this.template.children=Array.from(this.node.childNodes),st(this.node)),s(this.node),this},update(t,e){if(this.template){const n=nt(t,e);this.template.update(this.getTemplateScope(t,n),n)}return this},unmount(t,e,n){return this.template&&this.template.unmount(this.getTemplateScope(t,e),null,n),this}};function st(t){const e=t&&t.firstChild;e&&(o(e,t),st(t))}function ot(t){return t.reduce(((t,e)=>{let{bindings:n}=e;return t.concat(n)}),[])}const it={mount(t){return this.update(t)},update(t,e){const n=this.evaluate(t);return n===this.name?this.tag.update(t):(this.unmount(t,e,!0),this.name=n,this.tag=function(t,e,n){return void 0===e&&(e=[]),void 0===n&&(n=[]),t?t({slots:e,attributes:n}):dt(function(t){return t.reduce(((t,e)=>t+e.html),"")}(e),[...ot(e),{expressions:n.map((t=>Object.assign({type:0},t)))}])}(this.getComponent(n),this.slots,this.attributes),this.tag.mount(this.node,t)),this},unmount(t,e,n){return this.tag&&this.tag.unmount(n),this}};var ut={1:function(t,e){let{evaluate:n,template:r}=e;const i=document.createTextNode("");return o(i,t),s(t),Object.assign({},b,{node:t,evaluate:n,placeholder:i,template:r.createDOM(t)})},2:function(t,e){let{expressions:n}=e;return Object.assign({},(r=n.map((e=>U(t,e))),["mount","update","unmount"].reduce(((t,e)=>Object.assign({},t,{[e]:t=>r.map((n=>n[e](t)))&&s})),{})));var r,s},0:function(t,e){let{evaluate:n,condition:r,itemName:i,indexName:u,getKey:a,template:c}=e;const h=document.createTextNode(""),p=t.cloneNode();return o(h,t),s(t),Object.assign({},f,{childrenMap:new Map,node:t,root:p,condition:r,evaluate:n,isTemplateTag:l(p),template:c.createDOM(t),getKey:a,indexName:u,itemName:i,placeholder:h})},3:function(t,e){let{evaluate:n,getComponent:r,slots:s,attributes:o}=e;return Object.assign({},it,{node:t,evaluate:n,slots:s,attributes:o,getComponent:r})},4:function(t,e){let{name:n,attributes:r}=e;return Object.assign({},rt,{attributes:r,node:t,name:n})}};function at(t,e){return t.map((t=>2===t.type?Object.assign({},t,{childNodeIndex:t.childNodeIndex+e}):t))}function ct(t,e,n){const{selector:r,type:s,redundantAttribute:o,expressions:i}=e,u=r?t.querySelector(r):t;o&&u.removeAttribute(o);const a=i||[];return(ut[s]||ut[2])(u,Object.assign({},e,{expressions:n&&!r?at(a,n):a}))}function lt(t,e){return c(t)?function(t,e){return e.ownerDocument.importNode((new window.DOMParser).parseFromString(`<svg xmlns="http://www.w3.org/2000/svg">${t}</svg>`,"application/xml").documentElement,!0)}(e,t):function(t,e){const n=l(e)?e:document.createElement("template");return n.innerHTML=t,n.content}(e,t)}function ht(t,e){switch(!0){case c(t):n(e,t);break;case l(t):t.parentNode.replaceChild(e,t);break;default:t.appendChild(e)}}const pt=Object.freeze({createDOM(t){return this.dom=this.dom||function(t,e){return e&&("string"==typeof e?lt(t,e):e)}(t,this.html),this},mount(t,e,n,r){if(void 0===r&&(r={}),!t)throw new Error("Please provide DOM node to mount properly your template");this.el&&this.unmount(e);const{fragment:s,children:o,avoidDOMInjection:i}=r,{parentNode:u}=o?o[0]:t,a=l(t),c=a?Math.max(Array.from(u.childNodes).indexOf(t),0):null;return this.isTemplateTag=a,this.createDOM(t),this.dom&&(this.fragment=s||this.dom.cloneNode(!0)),this.el=this.isTemplateTag?u:t,this.children=this.isTemplateTag?o||Array.from(this.fragment.childNodes):null,!i&&this.fragment&&ht(t,this.fragment),this.bindings=this.bindingsData.map((t=>ct(this.el,t,c))),this.bindings.forEach((t=>t.mount(e,n))),this},update(t,e){return this.bindings.forEach((n=>n.update(t,e))),this},unmount(t,e,n){if(this.el){switch(this.bindings.forEach((r=>r.unmount(t,e,n))),!0){case this.children&&null!==n:r(this.children);break;case!0===n:s(this.el);break;case null!==n:r(this.el.childNodes)}this.el=null}return this},clone(){return Object.assign({},this,{el:null})}});function dt(t,e){return void 0===e&&(e=[]),Object.assign({},pt,{html:t,bindingsData:e})}var mt=Object.freeze({__proto__:null,template:dt,createBinding:ct,createExpression:U,bindingTypes:i,expressionTypes:u});function ft(){return this}function bt(t){return h(t)?t.prototype&&t.prototype.constructor?new t:t():t}function gt(t,e,n,r){return void 0===r&&(r={}),Object.defineProperty(t,e,Object.assign({value:n,enumerable:!1,writable:!1,configurable:!0},r)),t}function Ot(t,e,n){return Object.entries(e).forEach((e=>{let[r,s]=e;gt(t,r,s,n)})),t}function Et(t,e){return Object.entries(e).forEach((e=>{let[n,r]=e;t[n]||(t[n]=r)})),t}function vt(t){return Array.isArray(t)?t:/^\[object (HTMLCollection|NodeList|Object)\]$/.test(Object.prototype.toString.call(t))&&"number"==typeof t.length?Array.from(t):[t]}function Nt(t,e){return vt("string"==typeof t?(e||document).querySelectorAll(t):t)}const Tt=t=>1===t.length?t[0]:t;function yt(t,e,n){const r="object"==typeof e?e:{[e]:n},s=Object.keys(r);return vt(t).forEach((t=>{s.forEach((e=>t.setAttribute(e,r[e])))})),t}function Mt(t,e){return function(t,e,n){const r="string"==typeof e?[e]:e;return Tt(vt(t).map((t=>Tt(r.map((e=>t[n](e)))))))}(t,e,"getAttribute")}const _t=new Map,jt=()=>At||(yt(At=Nt("style[riot]")[0]||document.createElement("style"),"type","text/css"),At.parentNode||document.head.appendChild(At),At);var At,St={CSS_BY_NAME:_t,add(t,e){return _t.has(t)||(_t.set(t,e),this.inject()),this},inject(){return jt().innerHTML=[..._t.values()].join("\n"),this},remove(t){return _t.has(t)&&(_t.delete(t),this.inject()),this}};function wt(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 function(){for(var e=arguments.length,r=new Array(e),s=0;s<e;s++)r[s]=arguments[s];return(r=[...n,...r]).length<t.length?wt(t,...r):t(...r)}}function xt(t){return Mt(t,Y)||t.tagName.toLowerCase()}const Pt=Object.freeze({$(t){return Nt(t,this.root)[0]},$$(t){return Nt(t,this.root)}}),Ut=Object.freeze({[L]:ft,[B]:ft,[K]:ft}),Ct=Object.freeze({[R]:ft,[k]:ft,[$]:ft,[z]:ft,[H]:ft,[F]:ft,[V]:ft}),Dt=Object.assign({},Ut,{clone:ft,createDOM:ft});function It(t,n){return void 0===n&&(n={}),Object.assign({},function(t){return Array.from(t.attributes).reduce(((t,n)=>(t[e(n.name)]=n.value,t)),{})}(t),bt(n))}const Yt=(t,e)=>t[D]=e;function Lt(t){return[L,B,K].reduce(((e,n)=>(e[n]=t(n),e)),{})}function Bt(t){let{css:e,template:n,exports:r,name:s}=t;const o=n?function(t,e){return t(dt,u,i,(t=>e[t]||C.get(t)))}(n,r?(void 0===(a=r.components)&&(a={}),Object.entries(bt(a)).reduce(((t,e)=>{let[n,r]=e;var s;return t[(s=n,s.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase())]=Bt(r),t}),{})):{}):Dt;var a;return t=>{let{slots:i,attributes:u,props:a}=t;if(r&&r[Z])return function(t,e){let{slots:n,attributes:r,props:s,css:o,template:i}=e;i&&g("Pure components can not have html"),o&&g("Pure components do not have css");const u=Et(t({slots:n,attributes:r,props:s}),Ut);return Lt((t=>function(){for(var e=arguments.length,n=new Array(e),r=0;r<e;r++)n[r]=arguments[r];if(t===L){const[t]=n;Yt(t,u)}return u[t](...n),u}))}(r,{slots:i,attributes:u,props:a,css:e,template:n});const c=bt(r)||{},l=Kt({css:e,template:o,componentAPI:c,name:s})({slots:i,attributes:u,props:a});return{mount:(t,e,n)=>l.mount(t,n,e),update:(t,e)=>l.update(e,t),unmount:t=>l.unmount(t)}}}function Kt(t){let{css:e,template:n,componentAPI:r,name:s}=t;return e&&s&&St.add(s,e),wt(kt)(Ot(Et(r,Object.assign({},Ct,{[q]:{}})),Object.assign({[W]:null,[X]:null},Pt,{name:s,css:e,template:n})))}function Rt(t,e){return Object.assign({},t,bt(e))}function kt(t,e){let{slots:n,attributes:r,props:s}=e;return o=function(t){return[...I].reduce(((t,e)=>e(t)||t),t)}(Ot(Object.create(t),{mount(e,o,i){return void 0===o&&(o={}),this[Q]=function(t,e){void 0===e&&(e=[]);const n=e.map((e=>U(t,e))),r={};return Object.assign(r,Object.assign({expressions:n},Lt((t=>e=>(n.forEach((n=>n[t](e))),r)))))}(e,r).mount(i),gt(this,G,Object.freeze(Object.assign({},It(e,s),O(this[Q].expressions)))),this.state=Rt(this.state,o),this[tt]=this.template.createDOM(e).clone(),Yt(e,this),t.name&&function(t,e){xt(t)!==e&&yt(t,Y,e)}(e,t.name),gt(this,X,e),gt(this,W,n),this.onBeforeMount(this.props,this.state),this[J]=i,this[tt].mount(e,this,i),this.onMounted(this.props,this.state),this},update(t,e){void 0===t&&(t={}),e&&(this[J]=e,this[Q].update(e));const n=O(this[Q].expressions);if(!1!==this.shouldUpdate(n,this.props))return gt(this,G,Object.freeze(Object.assign({},this.props,n))),this.state=Rt(this.state,t),this.onBeforeUpdate(this.props,this.state),this[tt].update(this,this[J]),this.onUpdated(this.props,this.state),this},unmount(t){return this.onBeforeUnmount(this.props,this.state),this[Q].unmount(),this[tt].unmount(this,this[J],null===t?null:!t),this.onUnmounted(this.props,this.state),this}})),Object.keys(t).filter((e=>h(t[e]))).forEach((t=>{o[t]=o[t].bind(o)})),o;var o}const{DOM_COMPONENT_INSTANCE_PROPERTY:$t,COMPONENTS_IMPLEMENTATION_MAP:zt,PLUGINS_SET:Ht}=et,Ft={cssManager:St,DOMBindings:mt,createComponent:Bt,defineComponent:Kt,globals:et};t.__=Ft,t.component=function(t){return function(e,n,r){let{slots:s,attributes:o,parentScope:i}=void 0===r?{}:r;return function(){for(var t=arguments.length,e=new Array(t),n=0;n<t;n++)e[n]=arguments[n];return e.reduce(((t,e)=>function(){return t(e(...arguments))}))}((t=>t.mount(e,i)),(t=>t({props:n,slots:s,attributes:o})),Bt)(t)}},t.install=function(t){return h(t)||g("Plugins must be of type function"),Ht.has(t)&&g("This plugin was already installed"),Ht.add(t),Ht},t.mount=function(t,e,n){return Nt(t).map((t=>function(t,e,n){const r=n||xt(t);return C.has(r)||g(`The component named "${r}" was never registered`),C.get(r)({props:e}).mount(t)}(t,e,n)))},t.pure=function(t){return h(t)||g('riot.pure accepts only arguments of type "function"'),t[Z]=!0,t},t.register=function(t,e){let{css:n,template:r,exports:s}=e;return zt.has(t)&&g(`The component "${t}" was already registered`),zt.set(t,Bt({name:t,css:n,template:r,exports:s})),zt},t.uninstall=function(t){return Ht.has(t)||g("This plugin was never installed"),Ht.delete(t),Ht},t.unmount=function(t,e){return Nt(t).map((t=>(t[$t]&&t[$t].unmount(e),t)))},t.unregister=function(t){return zt.has(t)||g(`The component "${t}" was never registered`),zt.delete(t),St.remove(t),zt},t.version="v5.1.1",Object.defineProperty(t,"__esModule",{value:!0})},"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).riot={});
/* Riot v5.1.2, @license MIT */
var t,e;t=this,e=function(t){"use strict";function e(t){return t.replace(/-(\w)/g,((t,e)=>e.toUpperCase()))}function n(t,e){t.firstChild&&(e.appendChild(t.firstChild),n(t,e))}function r(t){Array.from(t).forEach(s)}const s=t=>t&&t.parentNode&&t.parentNode.removeChild(t),o=(t,e)=>e&&e.parentNode&&e.parentNode.insertBefore(t,e),i=new Map,u=Symbol("riot-component"),a=new Set,c="is",l="mount",h="update",p="unmount",d="shouldUpdate",m="onBeforeMount",f="onMounted",b="onBeforeUpdate",g="onUpdated",O="onBeforeUnmount",E="onUnmounted",N="props",v="state",T="slots",y="root",M=Symbol.for("pure"),_=Symbol("parent"),j=Symbol("attributes"),A=Symbol("template");var S=Object.freeze({__proto__:null,COMPONENTS_IMPLEMENTATION_MAP:i,DOM_COMPONENT_INSTANCE_PROPERTY:u,PLUGINS_SET:a,IS_DIRECTIVE:c,VALUE_ATTRIBUTE:"value",MOUNT_METHOD_KEY:l,UPDATE_METHOD_KEY:h,UNMOUNT_METHOD_KEY:p,SHOULD_UPDATE_KEY:d,ON_BEFORE_MOUNT_KEY:m,ON_MOUNTED_KEY:f,ON_BEFORE_UPDATE_KEY:b,ON_UPDATED_KEY:g,ON_BEFORE_UNMOUNT_KEY:O,ON_UNMOUNTED_KEY:E,PROPS_KEY:N,STATE_KEY:v,SLOTS_KEY:T,ROOT_KEY:y,IS_PURE_SYMBOL:M,PARENT_KEY_SYMBOL:_,ATTRIBUTES_KEY_SYMBOL:j,TEMPLATE_KEY_SYMBOL:A}),w={EACH:0,IF:1,SIMPLE:2,TAG:3,SLOT:4},x={ATTRIBUTE:0,EVENT:1,TEXT:2,VALUE:3};function P(t,e){return typeof t===e}function U(t){const e=t.ownerSVGElement;return!!e||null===e}function C(t){return!Y(t.content)}function D(t){return P(t,"function")}function I(t){return!Y(t)&&P(t,"object")}function Y(t){return null==t}const L=Symbol("unmount"),B={nodes:[],mount(t,e){return this.update(t,e)},update(t,e){const{placeholder:n,nodes:r,childrenMap:i}=this,u=t===L?null:this.evaluate(t),a=u?Array.from(u):[],{newChildrenMap:c,batches:l,futureNodes:h}=(n.parentNode,function(t,e,n,r){const{condition:s,template:o,childrenMap:i,itemName:u,getKey:a,indexName:c,root:l,isTemplateTag:h}=r,p=new Map,d=[],m=[];return t.forEach(((t,r)=>{const f=function(t,e){let{itemName:n,indexName:r,index:s,item:o}=e;return t[n]=o,r&&(t[r]=s),t}(Object.create(e),{itemName:u,indexName:c,index:r,item:t}),b=a?a(f):r,g=i.get(b);if(function(t,e){return!!t&&!1===Boolean(t(e))}(s,f))return;const O=g?g.template:o.clone(),E=g?O.el:l.cloneNode(),N=!g,v=h&&N?function(t){const e=t.dom.cloneNode(!0);return{avoidDOMInjection:!0,fragment:e,children:Array.from(e.childNodes)}}(O):{};if(N?d.push((()=>O.mount(E,f,n,v))):d.push((()=>O.update(f,n))),h){const t=v.children||O.children;m.push(...t)}else m.push(E);i.delete(b),p.set(b,{template:O,context:f,index:r})})),{newChildrenMap:p,batches:d,futureNodes:m}}(a,t,e,this));return((t,e,n,r,i)=>{const u=n.length;let a=e.length,c=u,l=0,h=0,p=null;for(;l<a||h<c;)if(a===l){const t=c<u?h?r(n[h-1],-0).nextSibling:r(n[c-h],0):i;for(;h<c;)o(r(n[h++],1),t)}else if(c===h)for(;l<a;)p&&p.has(e[l])||s(r(e[l],-1)),l++;else if(e[l]===n[h])l++,h++;else if(e[a-1]===n[c-1])a--,c--;else if(e[l]===n[c-1]&&n[h]===e[a-1]){const t=r(e[--a],-1).nextSibling;o(r(n[h++],1),r(e[l++],-1).nextSibling),o(r(n[--c],1),t),e[a]=n[c]}else{if(!p){p=new Map;let t=h;for(;t<c;)p.set(n[t],t++)}if(p.has(e[l])){const t=p.get(e[l]);if(h<t&&t<c){let s=l,i=1;for(;++s<a&&s<c&&p.get(e[s])===t+i;)i++;if(i>t-h){const s=r(e[l],0);for(;h<t;)o(r(n[h++],1),s)}else d=r(n[h++],1),(m=r(e[l++],-1))&&m.parentNode&&m.parentNode.replaceChild(d,m)}else l++}else s(r(e[l++],-1))}var d,m})(0,r,h,function(t,e){return(n,r)=>{if(r<0){const n=t.pop();if(n){const{template:t,context:r}=n;t.unmount(r,e,null)}}return n}}(Array.from(i.values()),e),n),l.forEach((t=>t())),this.childrenMap=c,this.nodes=h,this},unmount(t,e){return this.update(L,e),this}},K={mount(t,e){return this.update(t,e)},update(t,e){const n=!!this.evaluate(t),r=!this.value&&n,s=this.value&&!n,i=()=>{const n=this.node.cloneNode();o(n,this.placeholder),this.template=this.template.clone(),this.template.mount(n,t,e)};switch(!0){case r:i();break;case s:this.unmount(t);break;default:n&&this.template.update(t,e)}return this.value=n,this},unmount(t,e){return this.template.unmount(t,e,!0),this}};function R(t){throw new Error(t)}function k(t){return t.reduce(((t,n)=>{const{value:r,type:s}=n;switch(!0){case!n.name&&0===s:return Object.assign({},t,r);case 3===s:t.value=n.value;break;default:t[e(n.name)]=n.value}return t}),{})}const $="removeAttribute",z="setAttribute",H="undefined"==typeof Element?{}:Element.prototype,F=function(t){const e=new Map,n=n=>(e.has(n)||e.set(n,t.call(this,n)))&&e.get(n);return n.cache=e,n}((t=>H.hasOwnProperty(t)));function V(t,e,n,r){let{name:s}=e;if(!s)return r&&function(t,e,n){const r=e?Object.keys(e):[];Object.keys(n).filter((t=>!r.includes(t))).forEach((e=>t.removeAttribute(e)))}(t,n,r),void(n&&function(t,e){Object.entries(e).forEach((e=>{let[n,r]=e;return V(t,{name:n},r)}))}(t,n));!F(s)&&(function(t){return P(t,"boolean")}(n)||I(n)||D(n))&&(t[s]=n),t[function(t){return Y(t)||!1===t||""===t||I(t)||D(t)?$:z}(n)](s,function(t,e){return!0===e?t:e}(s,n))}const G=/^on/,q={handleEvent(t){this[t.type](t)}},W=new WeakMap;function X(t){return Y(t)?"":t}const Z=(t,e)=>{const n=t.childNodes[e];if(n.nodeType===Node.COMMENT_NODE){const e=document.createTextNode("");return t.replaceChild(e,n),e}return n};var J={0:V,1:function(t,e,n){let{name:r}=e;const s=r.replace(G,""),o=W.get(t)||(t=>{const e=Object.create(q);return W.set(t,e),e})(t),[i,u]=(t=>Array.isArray(t)?t:[t,!1])(n),a=o[s],c=i&&!a;a&&!i&&t.removeEventListener(s,o),c&&t.addEventListener(s,o,u),o[s]=i},2:function(t,e,n){t.data=X(n)},3:function(t,e,n){t.value=X(n)}};const Q={mount(t){return this.value=this.evaluate(t),tt(this,this.value),this},update(t){const e=this.evaluate(t);return this.value!==e&&(tt(this,e),this.value=e),this},unmount(){return 1===this.type&&tt(this,null),this}};function tt(t,e){return J[t.type](t.node,t,e,t.value)}function et(t,e){return Object.assign({},Q,e,{node:2===e.type?Z(t,e.childNodeIndex):t})}const nt=(t,e)=>t[_]||e,rt={attributes:[],getTemplateScope(t,e){return function(t,e,n){if(!t||!t.length)return n;const r=t.map((t=>Object.assign({},t,{value:t.evaluate(e)})));return Object.assign(Object.create(n||null),k(r))}(this.attributes,t,e)},mount(t,e){const n=!!t.slots&&t.slots.find((t=>{let{id:e}=t;return e===this.name})),{parentNode:r}=this.node,o=nt(t,e);return this.template=n&&dt(n.html,n.bindings).createDOM(r),this.template&&(this.template.mount(this.node,this.getTemplateScope(t,o),o),this.template.children=Array.from(this.node.childNodes),st(this.node)),s(this.node),this},update(t,e){if(this.template){const n=nt(t,e);this.template.update(this.getTemplateScope(t,n),n)}return this},unmount(t,e,n){return this.template&&this.template.unmount(this.getTemplateScope(t,e),null,n),this}};function st(t){const e=t&&t.firstChild;e&&(o(e,t),st(t))}function ot(t){return t.reduce(((t,e)=>{let{bindings:n}=e;return t.concat(n)}),[])}const it={mount(t){return this.update(t)},update(t,e){const n=this.evaluate(t);return n===this.name?this.tag.update(t):(this.unmount(t,e,!0),this.name=n,this.tag=function(t,e,n){return void 0===e&&(e=[]),void 0===n&&(n=[]),t?t({slots:e,attributes:n}):dt(function(t){return t.reduce(((t,e)=>t+e.html),"")}(e),[...ot(e),{expressions:n.map((t=>Object.assign({type:0},t)))}])}(this.getComponent(n),this.slots,this.attributes),this.tag.mount(this.node,t)),this},unmount(t,e,n){return this.tag&&this.tag.unmount(n),this}};var ut={1:function(t,e){let{evaluate:n,template:r}=e;const i=document.createTextNode("");return o(i,t),s(t),Object.assign({},K,{node:t,evaluate:n,placeholder:i,template:r.createDOM(t)})},2:function(t,e){let{expressions:n}=e;return Object.assign({},(r=n.map((e=>et(t,e))),["mount","update","unmount"].reduce(((t,e)=>Object.assign({},t,{[e]:t=>r.map((n=>n[e](t)))&&s})),{})));var r,s},0:function(t,e){let{evaluate:n,condition:r,itemName:i,indexName:u,getKey:a,template:c}=e;const l=document.createTextNode(""),h=t.cloneNode();return o(l,t),s(t),Object.assign({},B,{childrenMap:new Map,node:t,root:h,condition:r,evaluate:n,isTemplateTag:C(h),template:c.createDOM(t),getKey:a,indexName:u,itemName:i,placeholder:l})},3:function(t,e){let{evaluate:n,getComponent:r,slots:s,attributes:o}=e;return Object.assign({},it,{node:t,evaluate:n,slots:s,attributes:o,getComponent:r})},4:function(t,e){let{name:n,attributes:r}=e;return Object.assign({},rt,{attributes:r,node:t,name:n})}};function at(t,e){return t.map((t=>2===t.type?Object.assign({},t,{childNodeIndex:t.childNodeIndex+e}):t))}function ct(t,e,n){const{selector:r,type:s,redundantAttribute:o,expressions:i}=e,u=r?t.querySelector(r):t;o&&u.removeAttribute(o);const a=i||[];return(ut[s]||ut[2])(u,Object.assign({},e,{expressions:n&&!r?at(a,n):a}))}function lt(t,e){return U(t)?function(t,e){return e.ownerDocument.importNode((new window.DOMParser).parseFromString(`<svg xmlns="http://www.w3.org/2000/svg">${t}</svg>`,"application/xml").documentElement,!0)}(e,t):function(t,e){const n=C(e)?e:document.createElement("template");return n.innerHTML=t,n.content}(e,t)}function ht(t,e){switch(!0){case U(t):n(e,t);break;case C(t):t.parentNode.replaceChild(e,t);break;default:t.appendChild(e)}}const pt=Object.freeze({createDOM(t){return this.dom=this.dom||function(t,e){return e&&("string"==typeof e?lt(t,e):e)}(t,this.html),this},mount(t,e,n,r){if(void 0===r&&(r={}),!t)throw new Error("Please provide DOM node to mount properly your template");this.el&&this.unmount(e);const{fragment:s,children:o,avoidDOMInjection:i}=r,{parentNode:u}=o?o[0]:t,a=C(t),c=a?Math.max(Array.from(u.childNodes).indexOf(t),0):null;return this.isTemplateTag=a,this.createDOM(t),this.dom&&(this.fragment=s||this.dom.cloneNode(!0)),this.el=this.isTemplateTag?u:t,this.children=this.isTemplateTag?o||Array.from(this.fragment.childNodes):null,!i&&this.fragment&&ht(t,this.fragment),this.bindings=this.bindingsData.map((t=>ct(this.el,t,c))),this.bindings.forEach((t=>t.mount(e,n))),this},update(t,e){return this.bindings.forEach((n=>n.update(t,e))),this},unmount(t,e,n){if(this.el){switch(this.bindings.forEach((r=>r.unmount(t,e,n))),!0){case this.el[M]:break;case this.children&&null!==n:r(this.children);break;case!0===n:s(this.el);break;case null!==n:r(this.el.childNodes)}this.el=null}return this},clone(){return Object.assign({},this,{el:null})}});function dt(t,e){return void 0===e&&(e=[]),Object.assign({},pt,{html:t,bindingsData:e})}var mt=Object.freeze({__proto__:null,template:dt,createBinding:ct,createExpression:et,bindingTypes:w,expressionTypes:x});function ft(){return this}function bt(t){return D(t)?t.prototype&&t.prototype.constructor?new t:t():t}function gt(t,e,n,r){return void 0===r&&(r={}),Object.defineProperty(t,e,Object.assign({value:n,enumerable:!1,writable:!1,configurable:!0},r)),t}function Ot(t,e,n){return Object.entries(e).forEach((e=>{let[r,s]=e;gt(t,r,s,n)})),t}function Et(t,e){return Object.entries(e).forEach((e=>{let[n,r]=e;t[n]||(t[n]=r)})),t}function Nt(t){return Array.isArray(t)?t:/^\[object (HTMLCollection|NodeList|Object)\]$/.test(Object.prototype.toString.call(t))&&"number"==typeof t.length?Array.from(t):[t]}function vt(t,e){return Nt("string"==typeof t?(e||document).querySelectorAll(t):t)}const Tt=t=>1===t.length?t[0]:t;function yt(t,e,n){const r="object"==typeof e?e:{[e]:n},s=Object.keys(r);return Nt(t).forEach((t=>{s.forEach((e=>t.setAttribute(e,r[e])))})),t}function Mt(t,e){return function(t,e,n){const r="string"==typeof e?[e]:e;return Tt(Nt(t).map((t=>Tt(r.map((e=>t[n](e)))))))}(t,e,"getAttribute")}const _t=new Map,jt=()=>At||(yt(At=vt("style[riot]")[0]||document.createElement("style"),"type","text/css"),At.parentNode||document.head.appendChild(At),At);var At,St={CSS_BY_NAME:_t,add(t,e){return _t.has(t)||(_t.set(t,e),this.inject()),this},inject(){return jt().innerHTML=[..._t.values()].join("\n"),this},remove(t){return _t.has(t)&&(_t.delete(t),this.inject()),this}};function wt(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 function(){for(var e=arguments.length,r=new Array(e),s=0;s<e;s++)r[s]=arguments[s];return(r=[...n,...r]).length<t.length?wt(t,...r):t(...r)}}function xt(t){return Mt(t,c)||t.tagName.toLowerCase()}const Pt=Object.freeze({$(t){return vt(t,this.root)[0]},$$(t){return vt(t,this.root)}}),Ut=Object.freeze({[l]:ft,[h]:ft,[p]:ft}),Ct=Object.freeze({[d]:ft,[m]:ft,[f]:ft,[b]:ft,[g]:ft,[O]:ft,[E]:ft}),Dt=Object.assign({},Ut,{clone:ft,createDOM:ft});function It(t,n){return void 0===n&&(n={}),Object.assign({},function(t){return Array.from(t.attributes).reduce(((t,n)=>(t[e(n.name)]=n.value,t)),{})}(t),bt(n))}const Yt=(t,e)=>t[u]=e;function Lt(t){return[l,h,p].reduce(((e,n)=>(e[n]=t(n),e)),{})}function Bt(t){let{css:e,template:n,exports:r,name:s}=t;const o=n?function(t,e){return t(dt,x,w,(t=>e[t]||i.get(t)))}(n,r?(void 0===(u=r.components)&&(u={}),Object.entries(bt(u)).reduce(((t,e)=>{let[n,r]=e;var s;return t[(s=n,s.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase())]=Bt(r),t}),{})):{}):Dt;var u;return t=>{let{slots:i,attributes:u,props:a}=t;if(r&&r[M])return function(t,e){let{slots:n,attributes:r,props:s,css:o,template:i}=e;i&&R("Pure components can not have html"),o&&R("Pure components do not have css");const u=Et(t({slots:n,attributes:r,props:s}),Ut);return Lt((t=>function(){for(var e=arguments.length,n=new Array(e),r=0;r<e;r++)n[r]=arguments[r];if(t===l){const[t]=n;t[M]=!0,Yt(t,u)}return u[t](...n),u}))}(r,{slots:i,attributes:u,props:a,css:e,template:n});const c=bt(r)||{},h=Kt({css:e,template:o,componentAPI:c,name:s})({slots:i,attributes:u,props:a});return{mount:(t,e,n)=>h.mount(t,n,e),update:(t,e)=>h.update(e,t),unmount:t=>h.unmount(t)}}}function Kt(t){let{css:e,template:n,componentAPI:r,name:s}=t;return e&&s&&St.add(s,e),wt(kt)(Ot(Et(r,Object.assign({},Ct,{[v]:{}})),Object.assign({[T]:null,[y]:null},Pt,{name:s,css:e,template:n})))}function Rt(t,e){return Object.assign({},t,bt(e))}function kt(t,e){let{slots:n,attributes:r,props:s}=e;return o=function(t){return[...a].reduce(((t,e)=>e(t)||t),t)}(Ot(Object.create(t),{mount(e,o,i){return void 0===o&&(o={}),this[j]=function(t,e){void 0===e&&(e=[]);const n=e.map((e=>et(t,e))),r={};return Object.assign(r,Object.assign({expressions:n},Lt((t=>e=>(n.forEach((n=>n[t](e))),r)))))}(e,r).mount(i),gt(this,N,Object.freeze(Object.assign({},It(e,s),k(this[j].expressions)))),this.state=Rt(this.state,o),this[A]=this.template.createDOM(e).clone(),Yt(e,this),t.name&&function(t,e){xt(t)!==e&&yt(t,c,e)}(e,t.name),gt(this,y,e),gt(this,T,n),this.onBeforeMount(this.props,this.state),this[_]=i,this[A].mount(e,this,i),this.onMounted(this.props,this.state),this},update(t,e){void 0===t&&(t={}),e&&(this[_]=e,this[j].update(e));const n=k(this[j].expressions);if(!1!==this.shouldUpdate(n,this.props))return gt(this,N,Object.freeze(Object.assign({},this.props,n))),this.state=Rt(this.state,t),this.onBeforeUpdate(this.props,this.state),this[A].update(this,this[_]),this.onUpdated(this.props,this.state),this},unmount(t){return this.onBeforeUnmount(this.props,this.state),this[j].unmount(),this[A].unmount(this,this[_],null===t?null:!t),this.onUnmounted(this.props,this.state),this}})),Object.keys(t).filter((e=>D(t[e]))).forEach((t=>{o[t]=o[t].bind(o)})),o;var o}const{DOM_COMPONENT_INSTANCE_PROPERTY:$t,COMPONENTS_IMPLEMENTATION_MAP:zt,PLUGINS_SET:Ht}=S,Ft={cssManager:St,DOMBindings:mt,createComponent:Bt,defineComponent:Kt,globals:S};t.__=Ft,t.component=function(t){return function(e,n,r){let{slots:s,attributes:o,parentScope:i}=void 0===r?{}:r;return function(){for(var t=arguments.length,e=new Array(t),n=0;n<t;n++)e[n]=arguments[n];return e.reduce(((t,e)=>function(){return t(e(...arguments))}))}((t=>t.mount(e,i)),(t=>t({props:n,slots:s,attributes:o})),Bt)(t)}},t.install=function(t){return D(t)||R("Plugins must be of type function"),Ht.has(t)&&R("This plugin was already installed"),Ht.add(t),Ht},t.mount=function(t,e,n){return vt(t).map((t=>function(t,e,n){const r=n||xt(t);return i.has(r)||R(`The component named "${r}" was never registered`),i.get(r)({props:e}).mount(t)}(t,e,n)))},t.pure=function(t){return D(t)||R('riot.pure accepts only arguments of type "function"'),t[M]=!0,t},t.register=function(t,e){let{css:n,template:r,exports:s}=e;return zt.has(t)&&R(`The component "${t}" was already registered`),zt.set(t,Bt({name:t,css:n,template:r,exports:s})),zt},t.uninstall=function(t){return Ht.has(t)||R("This plugin was never installed"),Ht.delete(t),Ht},t.unmount=function(t,e){return vt(t).map((t=>(t[$t]&&t[$t].unmount(e),t)))},t.unregister=function(t){return zt.has(t)||R(`The component "${t}" was never registered`),zt.delete(t),St.remove(t),zt},t.version="v5.1.2",Object.defineProperty(t,"__esModule",{value:!0})},"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).riot={});

@@ -166,2 +166,4 @@ import {

const [el] = args
// mark this node as pure element
el[IS_PURE_SYMBOL] = true
bindDOMNodeToComponentObject(el, component)

@@ -168,0 +170,0 @@ }

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc