svelte-viewpoint
Version:
Super tiny, loadable component for SvelteJS with blackjack and data preloading.
3 lines (2 loc) • 8.5 kB
JavaScript
var viewpoint=function(){"use strict";function t(){}function n(t,n){for(const e in n)t[e]=n[e];return t}function e(t){return t()}function o(){return Object.create(null)}function r(t){t.forEach(e)}function c(t){return"function"==typeof t}function i(t,n){return t!=t?n==n:t!==n||t&&"object"==typeof t||"function"==typeof t}function u(t,n,e,o){if(t){const r=l(t,n,e,o);return t[0](r)}}function l(t,e,o,r){return t[1]&&r?n(o.ctx.slice(),t[1](r(e))):o.ctx}function s(t,n,e,o,r,c,i){const u=function(t,n,e,o){if(t[2]&&o){const r=t[2](o(e));if(void 0===n.dirty)return r;if("object"==typeof r){const t=[],e=Math.max(n.dirty.length,r.length);for(let o=0;o<e;o+=1)t[o]=n.dirty[o]|r[o];return t}return n.dirty|r}return n.dirty}(n,o,r,c);if(u){const r=l(n,e,o,i);t.p(r,u)}}function f(t,n){const e={};n=new Set(n);for(const o in t)n.has(o)||"$"===o[0]||(e[o]=t[o]);return e}function a(t,n,e){t.insertBefore(n,e||null)}function d(t){t.parentNode.removeChild(t)}function p(){return t="",document.createTextNode(t);var t}let m;function $(t){m=t}function h(){if(!m)throw new Error("Function called outside component initialization");return m}const g=[],b=[],y=[],k=[],v=Promise.resolve();let x=!1;function _(t){y.push(t)}let w=!1;const E=new Set;function N(){if(!w){w=!0;do{for(let t=0;t<g.length;t+=1){const n=g[t];$(n),T(n.$$)}for($(null),g.length=0;b.length;)b.pop()();for(let t=0;t<y.length;t+=1){const n=y[t];E.has(n)||(E.add(n),n())}y.length=0}while(g.length);for(;k.length;)k.pop()();x=!1,w=!1,E.clear()}}function T(t){if(null!==t.fragment){t.update(),r(t.before_update);const n=t.dirty;t.dirty=[-1],t.fragment&&t.fragment.p(t.ctx,n),t.after_update.forEach(_)}}const j=new Set;let P;function S(){P={r:0,c:[],p:P}}function C(){P.r||r(P.c),P=P.p}function O(t,n){t&&t.i&&(j.delete(t),t.i(n))}function A(t,n,e,o){if(t&&t.o){if(j.has(t))return;j.add(t),P.c.push((()=>{j.delete(t),o&&(e&&t.d(1),o())})),t.o(n)}}function M(t,n){const e=n.token={};function o(t,o,r,c){if(n.token!==e)return;n.resolved=c;let i=n.ctx;void 0!==r&&(i=i.slice(),i[r]=c);const u=t&&(n.current=t)(i);let l=!1;n.block&&(n.blocks?n.blocks.forEach(((t,e)=>{e!==o&&t&&(S(),A(t,1,1,(()=>{n.blocks[e]===t&&(n.blocks[e]=null)})),C())})):n.block.d(1),u.c(),O(u,1),u.m(n.mount(),n.anchor),l=!0),n.block=u,n.blocks&&(n.blocks[o]=u),l&&N()}if((r=t)&&"object"==typeof r&&"function"==typeof r.then){const e=h();if(t.then((t=>{$(e),o(n.then,1,n.value,t),$(null)}),(t=>{if($(e),o(n.catch,2,n.error,t),$(null),!n.hasCatch)throw t})),n.current!==n.pending)return o(n.pending,0),!0}else{if(n.current!==n.then)return o(n.then,1,n.value,t),!0;n.resolved=t}var r}function q(t){return"object"==typeof t&&null!==t?t:{}}function z(t){t&&t.c()}function B(t,n,o,i){const{fragment:u,on_mount:l,on_destroy:s,after_update:f}=t.$$;u&&u.m(n,o),i||_((()=>{const n=l.map(e).filter(c);s?s.push(...n):r(n),t.$$.on_mount=[]})),f.forEach(_)}function F(t,n){const e=t.$$;null!==e.fragment&&(r(e.on_destroy),e.fragment&&e.fragment.d(n),e.on_destroy=e.fragment=null,e.ctx=[])}function D(t,n){-1===t.$$.dirty[0]&&(g.push(t),x||(x=!0,v.then(N)),t.$$.dirty.fill(0)),t.$$.dirty[n/31|0]|=1<<n%31}function G(n,e,c,i,u,l,s=[-1]){const f=m;$(n);const a=n.$$={fragment:null,ctx:null,props:l,update:t,not_equal:u,bound:o(),on_mount:[],on_destroy:[],on_disconnect:[],before_update:[],after_update:[],context:new Map(f?f.$$.context:[]),callbacks:o(),dirty:s,skip_bound:!1};let p=!1;if(a.ctx=c?c(n,e.props||{},((t,e,...o)=>{const r=o.length?o[0]:e;return a.ctx&&u(a.ctx[t],a.ctx[t]=r)&&(!a.skip_bound&&a.bound[t]&&a.bound[t](r),p&&D(n,t)),e})):[],a.update(),p=!0,r(a.before_update),a.fragment=!!i&&i(a.ctx),e.target){if(e.hydrate){const t=(h=e.target,Array.from(h.childNodes));a.fragment&&a.fragment.l(t),t.forEach(d)}else a.fragment&&a.fragment.c();e.intro&&O(n.$$.fragment),B(n,e.target,e.anchor,e.customElement),N()}var h;$(f)}const H=t=>({error:144&t}),I=t=>({error:t[15]}),J=t=>({}),K=t=>({}),L=t=>({}),Q=t=>({});function R(t){let n;const e=t[12].error,o=u(e,t,t[13],I);return{c(){o&&o.c()},m(t,e){o&&o.m(t,e),n=!0},p(t,n){o&&o.p&&8336&n&&s(o,e,t,t[13],n,H,I)},i(t){n||(O(o,t),n=!0)},o(t){A(o,t),n=!1},d(t){o&&o.d(t)}}}function U(t){let n,e,o=t[14]&&V(t);return{c(){o&&o.c(),n=p()},m(t,r){o&&o.m(t,r),a(t,n,r),e=!0},p(t,e){t[14]?o?(o.p(t,e),144&e&&O(o,1)):(o=V(t),o.c(),O(o,1),o.m(n.parentNode,n)):o&&(S(),A(o,1,1,(()=>{o=null})),C())},i(t){e||(O(o),e=!0)},o(t){A(o),e=!1},d(t){o&&o.d(t),t&&d(n)}}}function V(t){let e,o,r;const c=[t[7],t[1]];var i=t[14];function u(t){let e={$$slots:{default:[W]},$$scope:{ctx:t}};for(let t=0;t<c.length;t+=1)e=n(e,c[t]);return{props:e}}return i&&(e=new i(u(t))),{c(){e&&z(e.$$.fragment),o=p()},m(t,n){e&&B(e,t,n),a(t,o,n),r=!0},p(t,n){const r=130&n?function(t,n){const e={},o={},r={$$scope:1};let c=t.length;for(;c--;){const i=t[c],u=n[c];if(u){for(const t in i)t in u||(o[t]=1);for(const t in u)r[t]||(e[t]=u[t],r[t]=1);t[c]=u}else for(const t in i)r[t]=1}for(const t in o)t in e||(e[t]=void 0);return e}(c,[128&n&&q(t[7]),2&n&&q(t[1])]):{};if(8192&n&&(r.$$scope={dirty:n,ctx:t}),i!==(i=t[14])){if(e){S();const t=e;A(t.$$.fragment,1,0,(()=>{F(t,1)})),C()}i?(e=new i(u(t)),z(e.$$.fragment),O(e.$$.fragment,1),B(e,o.parentNode,o)):e=null}else i&&e.$set(r)},i(t){r||(e&&O(e.$$.fragment,t),r=!0)},o(t){e&&A(e.$$.fragment,t),r=!1},d(t){t&&d(o),e&&F(e,t)}}}function W(t){let n;const e=t[12].default,o=u(e,t,t[13],null);return{c(){o&&o.c()},m(t,e){o&&o.m(t,e),n=!0},p(t,n){o&&o.p&&8192&n&&s(o,e,t,t[13],n,null,null)},i(t){n||(O(o,t),n=!0)},o(t){A(o,t),n=!1},d(t){o&&o.d(t)}}}function X(t){let n,e,o,r;const c=[Z,Y],i=[];function u(t,n){return t[0]&&!t[2]?0:t[3]?-1:1}return~(n=u(t))&&(e=i[n]=c[n](t)),{c(){e&&e.c(),o=p()},m(t,e){~n&&i[n].m(t,e),a(t,o,e),r=!0},p(t,r){let l=n;n=u(t),n===l?~n&&i[n].p(t,r):(e&&(S(),A(i[l],1,1,(()=>{i[l]=null})),C()),~n?(e=i[n],e?e.p(t,r):(e=i[n]=c[n](t),e.c()),O(e,1),e.m(o.parentNode,o)):e=null)},i(t){r||(O(e),r=!0)},o(t){A(e),r=!1},d(t){~n&&i[n].d(t),t&&d(o)}}}function Y(t){let n;const e=t[12].loading,o=u(e,t,t[13],K);return{c(){o&&o.c()},m(t,e){o&&o.m(t,e),n=!0},p(t,n){o&&o.p&&8192&n&&s(o,e,t,t[13],n,J,K)},i(t){n||(O(o,t),n=!0)},o(t){A(o,t),n=!1},d(t){o&&o.d(t)}}}function Z(t){let n;const e=t[12].waiting,o=u(e,t,t[13],Q);return{c(){o&&o.c()},m(t,e){o&&o.m(t,e),n=!0},p(t,n){o&&o.p&&8192&n&&s(o,e,t,t[13],n,L,Q)},i(t){n||(O(o,t),n=!0)},o(t){A(o,t),n=!1},d(t){o&&o.d(t)}}}function tt(t){let n,e,o,r={ctx:t,current:null,token:null,hasCatch:!0,pending:X,then:U,catch:R,value:14,error:15,blocks:[,,,]};return M((t[7],e=Promise.resolve().then(t[6]).then(t[4]).then(t[5])),r),{c(){n=p(),r.block.c()},m(t,e){a(t,n,e),r.block.m(t,r.anchor=e),r.mount=()=>n.parentNode,r.anchor=n,o=!0},p(n,[o]){if(t=n,r.ctx=t,144&o&&e!==(t[7],e=Promise.resolve().then(t[6]).then(t[4]).then(t[5]))&&M(e,r));else{const n=t.slice();n[14]=n[15]=r.resolved,r.block.p(n,o)}},i(t){o||(O(r.block),o=!0)},o(t){for(let t=0;t<3;t+=1){A(r.blocks[t])}o=!1},d(t){t&&d(n),r.block.d(t),r.token=null,r=null}}}function nt(t,e,o){let r;const c=["component","preloading","delay","timeout","abort"];let i,u,l=f(e,c),{$$slots:s={},$$scope:a}=e,{component:d=null}=e,{preloading:p=!0}=e,m=null,{delay:$=200}=e,{timeout:h=0}=e,{abort:g=0}=e;return t.$$set=t=>{e=n(n({},e),function(t){const n={};for(const e in t)"$"!==e[0]&&(n[e]=t[e]);return n}(t)),o(7,l=f(e,c)),"component"in t&&o(8,d=t.component),"preloading"in t&&o(9,p=t.preloading),"delay"in t&&o(10,$=t.delay),"timeout"in t&&o(0,h=t.timeout),"abort"in t&&o(11,g=t.abort),"$$scope"in t&&o(13,a=t.$$scope)},t.$$.update=()=>{2304&t.$$.dirty&&o(4,r=function(){return new Promise(((t,n)=>{let e;Promise.resolve("function"!=typeof d||/^\s*class\s+/.test(d.toString())?d:d()).then((n=>{clearTimeout(e),t(n)})),g&&(e=setTimeout((()=>{n(new Error("Aborted by timeout."))}),g))}))})},[h,m,i,u,r,function(t){return t&&Promise.resolve(p&&"function"==typeof t.preload?t.preload(l):void 0).then(((n={})=>(o(1,m=n),t.default||t)))},function(){$&&o(3,u=setTimeout((()=>{o(3,u=clearTimeout(u))}),$)),h&&o(2,i=setTimeout((()=>{o(2,i=clearTimeout(i))}),h))},l,d,p,$,g,s,a]}return class extends class{$destroy(){F(this,1),this.$destroy=t}$on(t,n){const e=this.$$.callbacks[t]||(this.$$.callbacks[t]=[]);return e.push(n),()=>{const t=e.indexOf(n);-1!==t&&e.splice(t,1)}}$set(t){var n;this.$$set&&(n=t,0!==Object.keys(n).length)&&(this.$$.skip_bound=!0,this.$$set(t),this.$$.skip_bound=!1)}}{constructor(t){super(),G(this,t,nt,tt,i,{component:8,preloading:9,delay:10,timeout:0,abort:11})}}}();
//# sourceMappingURL=viewpoint.min.js.map