svelte-viewpoint
Version:
Super tiny, loadable component for SvelteJS with blackjack and data preloading.
3 lines (2 loc) • 5.23 kB
JavaScript
!function(t,n){"object"==typeof exports&&"undefined"!=typeof module?module.exports=n(require("svelte/internal")):"function"==typeof define&&define.amd?define(["svelte/internal"],n):(t="undefined"!=typeof globalThis?globalThis:t||self).viewpoint=n(t.internal)}(this,(function(t){"use strict";const n=t=>({error:144&t}),e=t=>({error:t[15]}),o=t=>({}),r=t=>({}),i=t=>({}),s=t=>({});function c(o){let r;const i=o[12].error,s=t.create_slot(i,o,o[13],e);return{c(){s&&s.c()},m(t,n){s&&s.m(t,n),r=!0},p(o,r){s&&s.p&&8336&r&&t.update_slot(s,i,o,o[13],r,n,e)},i(n){r||(t.transition_in(s,n),r=!0)},o(n){t.transition_out(s,n),r=!1},d(t){s&&s.d(t)}}}function l(n){let e,o,r=n[14]&&u(n);return{c(){r&&r.c(),e=t.empty()},m(n,i){r&&r.m(n,i),t.insert(n,e,i),o=!0},p(n,o){n[14]?r?(r.p(n,o),144&o&&t.transition_in(r,1)):(r=u(n),r.c(),t.transition_in(r,1),r.m(e.parentNode,e)):r&&(t.group_outros(),t.transition_out(r,1,1,(()=>{r=null})),t.check_outros())},i(n){o||(t.transition_in(r),o=!0)},o(n){t.transition_out(r),o=!1},d(n){r&&r.d(n),n&&t.detach(e)}}}function u(n){let e,o,r;const i=[n[7],n[1]];var s=n[14];function c(n){let e={$$slots:{default:[a]},$$scope:{ctx:n}};for(let n=0;n<i.length;n+=1)e=t.assign(e,i[n]);return{props:e}}return s&&(e=new s(c(n))),{c(){e&&t.create_component(e.$$.fragment),o=t.empty()},m(n,i){e&&t.mount_component(e,n,i),t.insert(n,o,i),r=!0},p(n,r){const l=130&r?t.get_spread_update(i,[128&r&&t.get_spread_object(n[7]),2&r&&t.get_spread_object(n[1])]):{};if(8192&r&&(l.$$scope={dirty:r,ctx:n}),s!==(s=n[14])){if(e){t.group_outros();const n=e;t.transition_out(n.$$.fragment,1,0,(()=>{t.destroy_component(n,1)})),t.check_outros()}s?(e=new s(c(n)),t.create_component(e.$$.fragment),t.transition_in(e.$$.fragment,1),t.mount_component(e,o.parentNode,o)):e=null}else s&&e.$set(l)},i(n){r||(e&&t.transition_in(e.$$.fragment,n),r=!0)},o(n){e&&t.transition_out(e.$$.fragment,n),r=!1},d(n){n&&t.detach(o),e&&t.destroy_component(e,n)}}}function a(n){let e;const o=n[12].default,r=t.create_slot(o,n,n[13],null);return{c(){r&&r.c()},m(t,n){r&&r.m(t,n),e=!0},p(n,e){r&&r.p&&8192&e&&t.update_slot(r,o,n,n[13],e,null,null)},i(n){e||(t.transition_in(r,n),e=!0)},o(n){t.transition_out(r,n),e=!1},d(t){r&&r.d(t)}}}function p(n){let e,o,r,i;const s=[m,d],c=[];function l(t,n){return t[0]&&!t[2]?0:t[3]?-1:1}return~(e=l(n))&&(o=c[e]=s[e](n)),{c(){o&&o.c(),r=t.empty()},m(n,o){~e&&c[e].m(n,o),t.insert(n,r,o),i=!0},p(n,i){let u=e;e=l(n),e===u?~e&&c[e].p(n,i):(o&&(t.group_outros(),t.transition_out(c[u],1,1,(()=>{c[u]=null})),t.check_outros()),~e?(o=c[e],o?o.p(n,i):(o=c[e]=s[e](n),o.c()),t.transition_in(o,1),o.m(r.parentNode,r)):o=null)},i(n){i||(t.transition_in(o),i=!0)},o(n){t.transition_out(o),i=!1},d(n){~e&&c[e].d(n),n&&t.detach(r)}}}function d(n){let e;const i=n[12].loading,s=t.create_slot(i,n,n[13],r);return{c(){s&&s.c()},m(t,n){s&&s.m(t,n),e=!0},p(n,e){s&&s.p&&8192&e&&t.update_slot(s,i,n,n[13],e,o,r)},i(n){e||(t.transition_in(s,n),e=!0)},o(n){t.transition_out(s,n),e=!1},d(t){s&&s.d(t)}}}function m(n){let e;const o=n[12].waiting,r=t.create_slot(o,n,n[13],s);return{c(){r&&r.c()},m(t,n){r&&r.m(t,n),e=!0},p(n,e){r&&r.p&&8192&e&&t.update_slot(r,o,n,n[13],e,i,s)},i(n){e||(t.transition_in(r,n),e=!0)},o(n){t.transition_out(r,n),e=!1},d(t){r&&r.d(t)}}}function _(n){let e,o,r,i={ctx:n,current:null,token:null,hasCatch:!0,pending:p,then:l,catch:c,value:14,error:15,blocks:[,,,]};return t.handle_promise((n[7],o=Promise.resolve().then(n[6]).then(n[4]).then(n[5])),i),{c(){e=t.empty(),i.block.c()},m(n,o){t.insert(n,e,o),i.block.m(n,i.anchor=o),i.mount=()=>e.parentNode,i.anchor=e,r=!0},p(e,[r]){if(n=e,i.ctx=n,144&r&&o!==(n[7],o=Promise.resolve().then(n[6]).then(n[4]).then(n[5]))&&t.handle_promise(o,i));else{const t=n.slice();t[14]=t[15]=i.resolved,i.block.p(t,r)}},i(n){r||(t.transition_in(i.block),r=!0)},o(n){for(let n=0;n<3;n+=1){const e=i.blocks[n];t.transition_out(e)}r=!1},d(n){n&&t.detach(e),i.block.d(n),i.token=null,i=null}}}function f(n,e,o){let r;const i=["component","preloading","delay","timeout","abort"];let s,c,l=t.compute_rest_props(e,i),{$$slots:u={},$$scope:a}=e,{component:p=null}=e,{preloading:d=!0}=e,m=null,{delay:_=200}=e,{timeout:f=0}=e,{abort:$=0}=e;return n.$$set=n=>{e=t.assign(t.assign({},e),t.exclude_internal_props(n)),o(7,l=t.compute_rest_props(e,i)),"component"in n&&o(8,p=n.component),"preloading"in n&&o(9,d=n.preloading),"delay"in n&&o(10,_=n.delay),"timeout"in n&&o(0,f=n.timeout),"abort"in n&&o(11,$=n.abort),"$$scope"in n&&o(13,a=n.$$scope)},n.$$.update=()=>{2304&n.$$.dirty&&o(4,r=function(){return new Promise(((t,n)=>{let e;Promise.resolve("function"!=typeof p||/^\s*class\s+/.test(p.toString())?p:p()).then((n=>{clearTimeout(e),t(n)})),$&&(e=setTimeout((()=>{n(new Error("Aborted by timeout."))}),$))}))})},[f,m,s,c,r,function(t){return t&&Promise.resolve(d&&"function"==typeof t.preload?t.preload(l):void 0).then(((n={})=>(o(1,m=n),t.default||t)))},function(){_&&o(3,c=setTimeout((()=>{o(3,c=clearTimeout(c))}),_)),f&&o(2,s=setTimeout((()=>{o(2,s=clearTimeout(s))}),f))},l,p,d,_,$,u,a]}class $ extends t.SvelteComponent{constructor(n){super(),t.init(this,n,f,_,t.safe_not_equal,{component:8,preloading:9,delay:10,timeout:0,abort:11})}}return $}));
//# sourceMappingURL=index.min.js.map