UNPKG

7.76 kBJavaScriptView Raw
1var components=function(){"use strict";var e=n;function n(e){return function(n){return n==e}}n.fn=function(e){return"function"==typeof e},n.str=function(e){return"string"==typeof e},n.num=function(e){return"number"==typeof e},n.obj=function(e){return"object"==typeof e},n.lit=function(e){return e.constructor==Object},n.bol=function(e){return"boolean"==typeof e},n.truthy=function(e){return 1==!!e},n.falsy=function(e){return 0==!!e},n.arr=function(e){return e instanceof Array},n.null=function(e){return null===e},n.def=function(e){return void 0!==e},n.in=function(e){return function(n){return!!e&&(e.indexOf?~e.indexOf(n):n in e)}},n.promise=function(e){return e instanceof Promise},n.stream=function(e){return!(!e||!e.next)};var t=Object.freeze({default:e,__moduleExports:e}),r=t&&e||t,o={arr:function(e){return Array.prototype.slice.call(e,0)},obj:function(e){var n="id";return 1==arguments.length?(n=e,t):t.apply(this,arguments);function t(e,t,o){return 0===o&&(e={}),e[r.fn(n)?n(t,o):t[n]]=t,e}}};var u=o.arr,i=o.obj,c=Object.freeze({default:o,__moduleExports:o,arr:u,obj:i}),f="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};var s="undefined"!=typeof window,a=Object.freeze({default:s,__moduleExports:s}),l=a&&s||a,p=l?window:f,d=Object.freeze({default:p,__moduleExports:p}),h=c&&o||c,m=d&&p||d,y=function(e){return function(n){if(!m.console||!console.log.apply)return n;r.arr(arguments[2])&&(arguments[2]=arguments[2].length);var t=h.arr(arguments),o="[log]["+(new Date).toISOString()+"]"+e;return t.unshift(o.grey?o.grey:o),console.log.apply(console,t),n}},b=Object.freeze({default:y,__moduleExports:y}),v=function(e){return document.body?e():document.addEventListener("DOMContentLoaded",e.bind(this))},w=Object.freeze({default:v,__moduleExports:v}),_=function(e){return x(e.class?e.class:e.prototype?e.prototype.render?e:e.prototype.connected?e:O(e):O(e))},x=Object.assign,O=function(e){return e.class=e.class||function(){function n(){}return n.prototype.render=function(){e.apply(this,arguments)},n}()},g=Object.freeze({default:_,__moduleExports:_}),j=function(){var e,n,t=new Promise(function(t,r){e=t,n=r});return arguments.length&&e(arguments[0]),t.resolve=e,t.reject=n,t};var E,z=Object.freeze({default:j,__moduleExports:j}),A=function e(n,t){return t instanceof Array&&(t=t.reduce(e,[])),(n=n||[]).concat(t)},C=Object.freeze({default:A,__moduleExports:A}),P=function(e,n){return n in e},N=Object.freeze({default:P,__moduleExports:P}),L=N&&P||N,S=function(e,n,t,r){return e.host&&e.host.nodeName&&(e=e.host),n.name&&(t=n,n=n.name),!L(e,n)&&Object.defineProperty(e,n,{value:t,writable:r}),e[n]},$=Object.freeze({default:S,__moduleExports:S}),k=z&&j||z,q=C&&A||C,D=$&&S||$,I=function(){},M=function e(n,t){return t=t||{},D(n=n||{},"emit",function(e,t,o){for(var u=n.on[e.split(".")[0]]||[],i=[],c=0;c<u.length;c++)u[c].ns&&o&&!o(u[c].ns)||i.push(r(u[c].isOnce?u.splice(c--,1)[0]:u[c],t));for(var c=0;c<n.on["*"].length;c++)i.push(r(n.on["*"][c],[e,t]));return i.reduce(q,[])},1),D(n,"once",function(e,t){return n.on(e,t,!0)},1),D(n,"off",function(e,t){o(n.on[e]||[],t),t&&t.ns&&delete n.on[e]["$"+t.ns];return n},1),D(n,"on",function(e,r,i){var c=e.split(".")[0],f=e.split(".")[1],s=n.on[c]=n.on[c]||[],a="function"==typeof r?r:0;return!a&&f?(a=n.on[c]["$"+f])?a:l(u(n,r)):a||f?a&&f?l((o(s,n.on[c]["$"+f]||-1),a)):!(!a||f)&&l(a):l(u(n,r));function l(e){return e.isOnce=i,e.type=c,f&&(n.on[c]["$"+(e.ns=f)]=e),s.push(e),(t.on||I)(e),e.next?e:n}},1),n.on["*"]=n.on["*"]||[],n;function r(e,t){return e.next?e.next(t):t instanceof Array?e.apply(n,t):e.call(n,t)}function o(e,n){for(var r=e.length;~--r;)n!=e[r]&&n!=e[r].fn&&n||(t.off||I)(e.splice(r,1)[0])}function u(n,t){var r=e((t=t||{}).base||k());return r.i=0,r.li=[],r.fn=t.fn,r.parent=n,r.source=t.fn?r.parent.source:r,r.on("stop",function(e){return r.type?r.parent.off(r.type,r):r.parent.off(r),r.reason=e}),r.each=function(e){var n=e.next?e:u(r,{fn:e});return r.li.push(n),n},r.pipe=function(e){return e(r)},r.map=function(e){return r.each(function(n,t,r){return r.next(e(n,t,r))})},r.filter=function(e){return r.each(function(n,t,r){return e(n,t,r)&&r.next(n)})},r.reduce=function(e,n){return r.each(function(t,r,o){return o.next(n=e(n,t,r,o))})},r.unpromise=function(){var e=u(r,{base:{},fn:function(n){return e.next(n)}});return r.li.push(e),e},r.next=function(e){return r.resolve&&r.resolve(e),r.li.length?r.li.map(function(n){return n.fn(e,n.i++,n)}):e},r.until=function(e){return e.each?e.each(r.stop):e.then?e.then(r.stop):e.call?r.filter(e).map(r.stop):0},r.off=function(e){return o(r.li,e),r},r.start=function(){return r.source.emit("start"),r},r.stop=function(e){return r.source.emit("stop",e)},r[Symbol.asyncIterator]=function(){return{next:function(){return r.wait=new Promise(function(e){r.wait=!0,r.map(function(n,t,o){delete r.wait,r.off(o),e({value:n,done:!1})}),r.emit("pull",r)})}}},r}},H=Object.freeze({default:M,__moduleExports:M}),T=H&&M||H,B=function(e){if(!(e=e.host&&e.host.nodeName?e.host:e).on){e.listeners={};T(e,{on:function(t){var r=t.type.split(".").shift();e.listeners[r]||e.addEventListener(r,e.listeners[r]=function(t){return t.detail&&t.detail.emitted?0:n(r,[t,e.state,e])})},off:function(n){e.on[n.type]&&e.on[n.type].length||(e.removeEventListener(n.type,e.listeners[n.type]),delete e.listeners[n.type])}});var n=e.emit;e.emit=function(t,r){var o=new CustomEvent(t,{detail:{params:r,emitted:!0},bubbles:!1,cancelable:!0});return e.dispatchEvent(o),n(t,o)}}},F=Object.freeze({default:B,__moduleExports:B}),G=g&&_||g,J=F&&B||F,K=(function(e){var n=function(){},t=l&&window.HTMLElement||function(){return function(){}}(),r=l&&window.customElements||{};e.exports=function(e,n){if(1==arguments.length&&(n=e,e="anon-"+r.anon++),n.hasOwnProperty("wrapper"))return n.wrapper;if(e.includes("-")){if(!l)return o(G(n));var t=r.get(e);if(t){if(t.class==G(n))return t;t.class=G(n),Array.from(document.querySelectorAll(e)).map(function(e){e.disconnectedCallback(),e.methods.map(function(n){delete e[n]}),e.connectedCallback()})}else r.define(e,t=o(G(n)));return t}};var o=function(e){return e.hasOwnProperty("wrapper")||(e.wrapper=function(t){function r(){t.apply(this,arguments)}return t&&(r.__proto__=t),r.prototype=Object.create(t&&t.prototype),r.prototype.constructor=r,r.prototype.connectedCallback=function(){var t=this,r=e.wrapper.class.prototype;return J(this),this.ready=this.once("ready"),this.state=this.state||{},this.methods=Object.getOwnPropertyNames(r).filter(function(e){return!(e in u)}).map(function(e){return t[e]=r[e].bind(t),e}),Promise.resolve((this.connected||n).call(this,this,this.state)).then(function(){return t.emit("ready"),t.render()})},r.prototype.render=function(){var n=this,t=e.wrapper.class.prototype;return this.pending=this.pending||this.ready.then(function(){return delete n.pending,t.render.call(n,n,n.state)})},r.prototype.disconnectedCallback=function(){(this.disconnected||n).call(this,this,this.state),this.dispatchEvent(new CustomEvent("disconnected")),this.initialised=!1},r.prototype.get=function(e){return this.querySelector(e)},r}(t)),e.wrapper.class=e,e.wrapper},u={length:1,prototype:1,name:1,render:1};r.anon=r.anon||1}(E={exports:{}},E.exports),E.exports),Q=Object.freeze({default:K,__moduleExports:K}),R=w&&v||w,U=Q&&K||Q,V=(b&&y||b)("[ri/components]");return function(e){return l?(V("creating"),Node.prototype.render=function(){var n=this.nodeName.toLowerCase();if(n.includes("-"))return this.fn$=this.fn$||e.subscribe(n).map(function(e){return U(n,e)})},Node.prototype.draw=function(){this.render()},R(function(){return Array.from(document.querySelectorAll("*")).filter(function(e){return e.nodeName.includes("-")}).map(function(e){return e.render()})}),e):e}}();