p5-manager
Version:
A p5js template builder and sketch manager. Built for p5js enthusiasts.
3 lines (2 loc) • 15.9 kB
JavaScript
var app=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 s(t){return"function"==typeof t}function c(t,n){return t!=t?n==n:t!==n||t&&"object"==typeof t||"function"==typeof t}function i(n,...e){if(null==n)return t;const o=n.subscribe(...e);return o.unsubscribe?()=>o.unsubscribe():o}function l(t){return null==t?"":t}let a,u=!1;function f(t,n,e,o){for(;t<n;){const r=t+(n-t>>1);e(r)<=o?t=r+1:n=r}return t}function d(t,n){u?(!function(t){if(t.hydrate_init)return;t.hydrate_init=!0;const n=t.childNodes,e=new Int32Array(n.length+1),o=new Int32Array(n.length);e[0]=-1;let r=0;for(let t=0;t<n.length;t++){const s=f(1,r+1,(t=>n[e[t]].claim_order),n[t].claim_order)-1;o[t]=e[s]+1;const c=s+1;e[c]=t,r=Math.max(c,r)}const s=[],c=[];let i=n.length-1;for(let t=e[r]+1;0!=t;t=o[t-1]){for(s.push(n[t-1]);i>=t;i--)c.push(n[i]);i--}for(;i>=0;i--)c.push(n[i]);s.reverse(),c.sort(((t,n)=>t.claim_order-n.claim_order));for(let n=0,e=0;n<c.length;n++){for(;e<s.length&&c[n].claim_order>=s[e].claim_order;)e++;const o=e<s.length?s[e]:null;t.insertBefore(c[n],o)}}(t),(void 0===t.actual_end_child||null!==t.actual_end_child&&t.actual_end_child.parentElement!==t)&&(t.actual_end_child=t.firstChild),n!==t.actual_end_child?t.insertBefore(n,t.actual_end_child):t.actual_end_child=n.nextSibling):n.parentNode!==t&&t.appendChild(n)}function h(t,n,e){u&&!e?d(t,n):(n.parentNode!==t||e&&n.nextSibling!==e)&&t.insertBefore(n,e||null)}function p(t){t.parentNode.removeChild(t)}function g(t){return document.createElement(t)}function m(t){return document.createTextNode(t)}function $(){return m(" ")}function v(){return m("")}function _(t,n,e,o){return t.addEventListener(n,e,o),()=>t.removeEventListener(n,e,o)}function b(t,n,e){null==e?t.removeAttribute(n):t.getAttribute(n)!==e&&t.setAttribute(n,e)}function x(t,n){n=""+n,t.wholeText!==n&&(t.data=n)}function y(t){a=t}function w(){if(!a)throw new Error("Function called outside component initialization");return a}function E(){const t=w();return(n,e)=>{const o=t.$$.callbacks[n];if(o){const r=function(t,n){const e=document.createEvent("CustomEvent");return e.initCustomEvent(t,!1,!1,n),e}(n,e);o.slice().forEach((n=>{n.call(t,r)}))}}}function k(t,n){const e=t.$$.callbacks[n.type];e&&e.slice().forEach((t=>t.call(this,n)))}const j=[],O=[],q=[],A=[],L=Promise.resolve();let N=!1;function z(){N||(N=!0,L.then(I))}function S(){return z(),L}function C(t){q.push(t)}let T=!1;const M=new Set;function I(){if(!T){T=!0;do{for(let t=0;t<j.length;t+=1){const n=j[t];y(n),R(n.$$)}for(y(null),j.length=0;O.length;)O.pop()();for(let t=0;t<q.length;t+=1){const n=q[t];M.has(n)||(M.add(n),n())}q.length=0}while(j.length);for(;A.length;)A.pop()();N=!1,T=!1,M.clear()}}function R(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(C)}}const D=new Set;let H;function P(){H={r:0,c:[],p:H}}function Y(){H.r||r(H.c),H=H.p}function B(t,n){t&&t.i&&(D.delete(t),t.i(n))}function X(t,n,e,o){if(t&&t.o){if(D.has(t))return;D.add(t),H.c.push((()=>{D.delete(t),o&&(e&&t.d(1),o())})),t.o(n)}}function F(t,n){const e={},o={},r={$$scope:1};let s=t.length;for(;s--;){const c=t[s],i=n[s];if(i){for(const t in c)t in i||(o[t]=1);for(const t in i)r[t]||(e[t]=i[t],r[t]=1);t[s]=i}else for(const t in c)r[t]=1}for(const t in o)t in e||(e[t]=void 0);return e}function G(t){return"object"==typeof t&&null!==t?t:{}}function J(t){t&&t.c()}function U(t,n,o,c){const{fragment:i,on_mount:l,on_destroy:a,after_update:u}=t.$$;i&&i.m(n,o),c||C((()=>{const n=l.map(e).filter(s);a?a.push(...n):r(n),t.$$.on_mount=[]})),u.forEach(C)}function W(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 K(n,e,s,c,i,l,f=[-1]){const d=a;y(n);const h=n.$$={fragment:null,ctx:null,props:l,update:t,not_equal:i,bound:o(),on_mount:[],on_destroy:[],on_disconnect:[],before_update:[],after_update:[],context:new Map(d?d.$$.context:e.context||[]),callbacks:o(),dirty:f,skip_bound:!1};let g=!1;if(h.ctx=s?s(n,e.props||{},((t,e,...o)=>{const r=o.length?o[0]:e;return h.ctx&&i(h.ctx[t],h.ctx[t]=r)&&(!h.skip_bound&&h.bound[t]&&h.bound[t](r),g&&function(t,n){-1===t.$$.dirty[0]&&(j.push(t),z(),t.$$.dirty.fill(0)),t.$$.dirty[n/31|0]|=1<<n%31}(n,t)),e})):[],h.update(),g=!0,r(h.before_update),h.fragment=!!c&&c(h.ctx),e.target){if(e.hydrate){u=!0;const t=function(t){return Array.from(t.childNodes)}(e.target);h.fragment&&h.fragment.l(t),t.forEach(p)}else h.fragment&&h.fragment.c();e.intro&&B(n.$$.fragment),U(n,e.target,e.anchor,e.customElement),u=!1,I()}y(d)}class Q{$destroy(){W(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)}}const V=[];function Z(t,n){return{subscribe:tt(t,n).subscribe}}function tt(n,e=t){let o;const r=[];function s(t){if(c(n,t)&&(n=t,o)){const t=!V.length;for(let t=0;t<r.length;t+=1){const e=r[t];e[1](),V.push(e,n)}if(t){for(let t=0;t<V.length;t+=2)V[t][0](V[t+1]);V.length=0}}}return{set:s,update:function(t){s(t(n))},subscribe:function(c,i=t){const l=[c,i];return r.push(l),1===r.length&&(o=e(s)||t),c(n),()=>{const t=r.indexOf(l);-1!==t&&r.splice(t,1),0===r.length&&(o(),o=null)}}}}function nt(n,e,o){const c=!Array.isArray(n),l=c?[n]:n,a=e.length<2;return Z(o,(n=>{let o=!1;const u=[];let f=0,d=t;const h=()=>{if(f)return;d();const o=e(c?u[0]:u,n);a?n(o):d=s(o)?o:t},p=l.map(((t,n)=>i(t,(t=>{u[n]=t,f&=~(1<<n),o&&h()}),(()=>{f|=1<<n}))));return o=!0,h(),function(){r(p),d()}}))}function et(t){let e,o,r;const s=[t[2]];var c=t[0];function i(t){let e={};for(let t=0;t<s.length;t+=1)e=n(e,s[t]);return{props:e}}return c&&(e=new c(i()),e.$on("routeEvent",t[7])),{c(){e&&J(e.$$.fragment),o=v()},m(t,n){e&&U(e,t,n),h(t,o,n),r=!0},p(t,n){const r=4&n?F(s,[G(t[2])]):{};if(c!==(c=t[0])){if(e){P();const t=e;X(t.$$.fragment,1,0,(()=>{W(t,1)})),Y()}c?(e=new c(i()),e.$on("routeEvent",t[7]),J(e.$$.fragment),B(e.$$.fragment,1),U(e,o.parentNode,o)):e=null}else c&&e.$set(r)},i(t){r||(e&&B(e.$$.fragment,t),r=!0)},o(t){e&&X(e.$$.fragment,t),r=!1},d(t){t&&p(o),e&&W(e,t)}}}function ot(t){let e,o,r;const s=[{params:t[1]},t[2]];var c=t[0];function i(t){let e={};for(let t=0;t<s.length;t+=1)e=n(e,s[t]);return{props:e}}return c&&(e=new c(i()),e.$on("routeEvent",t[6])),{c(){e&&J(e.$$.fragment),o=v()},m(t,n){e&&U(e,t,n),h(t,o,n),r=!0},p(t,n){const r=6&n?F(s,[2&n&&{params:t[1]},4&n&&G(t[2])]):{};if(c!==(c=t[0])){if(e){P();const t=e;X(t.$$.fragment,1,0,(()=>{W(t,1)})),Y()}c?(e=new c(i()),e.$on("routeEvent",t[6]),J(e.$$.fragment),B(e.$$.fragment,1),U(e,o.parentNode,o)):e=null}else c&&e.$set(r)},i(t){r||(e&&B(e.$$.fragment,t),r=!0)},o(t){e&&X(e.$$.fragment,t),r=!1},d(t){t&&p(o),e&&W(e,t)}}}function rt(t){let n,e,o,r;const s=[ot,et],c=[];function i(t,n){return t[1]?0:1}return n=i(t),e=c[n]=s[n](t),{c(){e.c(),o=v()},m(t,e){c[n].m(t,e),h(t,o,e),r=!0},p(t,[r]){let l=n;n=i(t),n===l?c[n].p(t,r):(P(),X(c[l],1,1,(()=>{c[l]=null})),Y(),e=c[n],e?e.p(t,r):(e=c[n]=s[n](t),e.c()),B(e,1),e.m(o.parentNode,o))},i(t){r||(B(e),r=!0)},o(t){X(e),r=!1},d(t){c[n].d(t),t&&p(o)}}}function st(){const t=window.location.href.indexOf("#/");let n=t>-1?window.location.href.substr(t+1):"/";const e=n.indexOf("?");let o="";return e>-1&&(o=n.substr(e+1),n=n.substr(0,e)),{location:n,querystring:o}}const ct=Z(null,(function(t){t(st());const n=()=>{t(st())};return window.addEventListener("hashchange",n,!1),function(){window.removeEventListener("hashchange",n,!1)}})),it=nt(ct,(t=>t.location));nt(ct,(t=>t.querystring));const lt=tt(void 0);function at(t,n,e){let{routes:o={}}=n,{prefix:r=""}=n,{restoreScrollState:s=!1}=n;class c{constructor(t,n){if(!n||"function"!=typeof n&&("object"!=typeof n||!0!==n._sveltesparouter))throw Error("Invalid component object");if(!t||"string"==typeof t&&(t.length<1||"/"!=t.charAt(0)&&"*"!=t.charAt(0))||"object"==typeof t&&!(t instanceof RegExp))throw Error('Invalid value for "path" argument - strings must start with / or *');const{pattern:e,keys:o}=function(t,n){if(t instanceof RegExp)return{keys:!1,pattern:t};var e,o,r,s,c=[],i="",l=t.split("/");for(l[0]||l.shift();r=l.shift();)"*"===(e=r[0])?(c.push("wild"),i+="/(.*)"):":"===e?(o=r.indexOf("?",1),s=r.indexOf(".",1),c.push(r.substring(1,~o?o:~s?s:r.length)),i+=~o&&!~s?"(?:/([^/]+?))?":"/([^/]+?)",~s&&(i+=(~o?"?":"")+"\\"+r.substring(s))):i+="/"+r;return{keys:c,pattern:new RegExp("^"+i+(n?"(?=$|/)":"/?$"),"i")}}(t);this.path=t,"object"==typeof n&&!0===n._sveltesparouter?(this.component=n.component,this.conditions=n.conditions||[],this.userData=n.userData,this.props=n.props||{}):(this.component=()=>Promise.resolve(n),this.conditions=[],this.props={}),this._pattern=e,this._keys=o}match(t){if(r)if("string"==typeof r){if(!t.startsWith(r))return null;t=t.substr(r.length)||"/"}else if(r instanceof RegExp){const n=t.match(r);if(!n||!n[0])return null;t=t.substr(n[0].length)||"/"}const n=this._pattern.exec(t);if(null===n)return null;if(!1===this._keys)return n;const e={};let o=0;for(;o<this._keys.length;){try{e[this._keys[o]]=decodeURIComponent(n[o+1]||"")||null}catch(t){e[this._keys[o]]=null}o++}return e}async checkConditions(t){for(let n=0;n<this.conditions.length;n++)if(!await this.conditions[n](t))return!1;return!0}}const i=[];o instanceof Map?o.forEach(((t,n)=>{i.push(new c(n,t))})):Object.keys(o).forEach((t=>{i.push(new c(t,o[t]))}));let l=null,a=null,u={};const f=E();async function d(t,n){await S(),f(t,n)}let h=null,p=null;var g;s&&(p=t=>{h=t.state&&t.state.__svelte_spa_router_scrollY?t.state:null},window.addEventListener("popstate",p),g=()=>{h?window.scrollTo(h.__svelte_spa_router_scrollX,h.__svelte_spa_router_scrollY):window.scrollTo(0,0)},w().$$.after_update.push(g));let m=null,$=null;const v=ct.subscribe((async t=>{m=t;let n=0;for(;n<i.length;){const o=i[n].match(t.location);if(!o){n++;continue}const r={route:i[n].path,location:t.location,querystring:t.querystring,userData:i[n].userData,params:o&&"object"==typeof o&&Object.keys(o).length?o:null};if(!await i[n].checkConditions(r))return e(0,l=null),$=null,void d("conditionsFailed",r);d("routeLoading",Object.assign({},r));const s=i[n].component;if($!=s){s.loading?(e(0,l=s.loading),$=s,e(1,a=s.loadingParams),e(2,u={}),d("routeLoaded",Object.assign({},r,{component:l,name:l.name,params:a}))):(e(0,l=null),$=null);const n=await s();if(t!=m)return;e(0,l=n&&n.default||n),$=s}return o&&"object"==typeof o&&Object.keys(o).length?e(1,a=o):e(1,a=null),e(2,u=i[n].props),void d("routeLoaded",Object.assign({},r,{component:l,name:l.name,params:a})).then((()=>{lt.set(a)}))}e(0,l=null),$=null,lt.set(void 0)}));return function(t){w().$$.on_destroy.push(t)}((()=>{v(),p&&window.removeEventListener("popstate",p)})),t.$$set=t=>{"routes"in t&&e(3,o=t.routes),"prefix"in t&&e(4,r=t.prefix),"restoreScrollState"in t&&e(5,s=t.restoreScrollState)},t.$$.update=()=>{32&t.$$.dirty&&(history.scrollRestoration=s?"manual":"auto")},[l,a,u,o,r,s,function(n){k.call(this,t,n)},function(n){k.call(this,t,n)}]}class ut extends Q{constructor(t){super(),K(this,t,at,rt,c,{routes:3,prefix:4,restoreScrollState:5})}}function ft(t,n,e){const o=t.slice();return o[8]=n[e],o}function dt(t){let n,e,o,r,s=t[2].collectionName+"",c=t[2].projects,i=[];for(let n=0;n<c.length;n+=1)i[n]=ht(ft(t,c,n));return{c(){n=g("h2"),e=m(s),o=$(),r=g("ul");for(let t=0;t<i.length;t+=1)i[t].c();b(r,"class","svelte-bigqx7")},m(t,s){h(t,n,s),d(n,e),h(t,o,s),h(t,r,s);for(let t=0;t<i.length;t+=1)i[t].m(r,null)},p(t,n){if(4&n&&s!==(s=t[2].collectionName+"")&&x(e,s),44&n){let e;for(c=t[2].projects,e=0;e<c.length;e+=1){const o=ft(t,c,e);i[e]?i[e].p(o,n):(i[e]=ht(o),i[e].c(),i[e].m(r,null))}for(;e<i.length;e+=1)i[e].d(1);i.length=c.length}},d(t){t&&p(n),t&&p(o),t&&p(r),function(t,n){for(let e=0;e<t.length;e+=1)t[e]&&t[e].d(n)}(i,t)}}}function ht(t){let n,e,o,r,s,c,i=t[8]+"";function a(){return t[6](t[8])}return{c(){n=g("li"),e=m(i),o=$(),b(n,"class",r=l(t[8]===t[3].slice(1)?"-active":"")+" svelte-bigqx7")},m(t,r){h(t,n,r),d(n,e),d(n,o),s||(c=_(n,"click",a),s=!0)},p(o,s){t=o,4&s&&i!==(i=t[8]+"")&&x(e,i),12&s&&r!==(r=l(t[8]===t[3].slice(1)?"-active":"")+" svelte-bigqx7")&&b(n,"class",r)},d(t){t&&p(n),s=!1,c()}}}function pt(n){let e,o,r,s,c,i,l,a,u=n[1]&&dt(n);return{c(){e=g("div"),o=g("button"),o.innerHTML='<img src="/assets/star.png" alt="star.png" class="svelte-bigqx7"/>',r=$(),u&&u.c(),s=$(),c=g("div"),c.innerHTML='<a href="https://github.com/chiunhau/p5-manager" class="version">p5-manager v1.4.0</a> \n <br/>\n by\n <a href="https://twitter.com/chiunhauyou" class="author highlight svelte-bigqx7">@chiunhauyou</a>',b(o,"class","toggle svelte-bigqx7"),b(c,"class","footer svelte-bigqx7"),b(e,"class",i="sidebar "+(n[0]?"-active":"")+" svelte-bigqx7")},m(t,i){h(t,e,i),d(e,o),d(e,r),u&&u.m(e,null),d(e,s),d(e,c),l||(a=_(o,"click",n[4]),l=!0)},p(t,[n]){t[1]?u?u.p(t,n):(u=dt(t),u.c(),u.m(e,s)):u&&(u.d(1),u=null),1&n&&i!==(i="sidebar "+(t[0]?"-active":"")+" svelte-bigqx7")&&b(e,"class",i)},i:t,o:t,d(t){t&&p(e),u&&u.d(),l=!1,a()}}}function gt(t,n,e){let o;var r,s;r=it,s=t=>e(3,o=t),t.$$.on_destroy.push(i(r,s));let c,l=!1,a=!1;function u(t){!async function(t){if(!t||t.length<1||"/"!=t.charAt(0)&&0!==t.indexOf("#/"))throw Error("Invalid parameter location");await S(),history.replaceState({...history.state,__svelte_spa_router_scrollX:window.scrollX,__svelte_spa_router_scrollY:window.scrollY},void 0,void 0),window.location.hash=("#"==t.charAt(0)?"":"#")+t}(t),e(0,l=!1)}var f;f=async()=>{try{e(2,c=await(async()=>{const t=await fetch("/api/p5rc");return await t.json()})()),e(1,a=!0)}catch(t){consle.error(t)}},w().$$.on_mount.push(f);return[l,a,c,o,function(){e(0,l=!l)},u,t=>u(`/${t}`)]}class mt extends Q{constructor(t){super(),K(this,t,gt,pt,c,{})}}function $t(n){let e;return{c(){e=g("div"),e.innerHTML='<div class="wrapper svelte-14azcxx"><h1 class="svelte-14azcxx">Hello p5.js</h1> \n <h3 class="svelte-14azcxx">Get started</h3> \n <ol class="svelte-14azcxx"><li class="svelte-14azcxx"><code class="svelte-14azcxx">$ p5 new COLLECTION_NAME</code> to create a collection</li> \n <li class="svelte-14azcxx"><code class="svelte-14azcxx">$ p5 generate PROJECT_NAME</code>to generate a p5 project</li> \n <li class="svelte-14azcxx"><code class="svelte-14azcxx">$ p5 server</code> to start the p5-manager server</li> \n <li class="svelte-14azcxx">Go to<code class="svelte-14azcxx">localhost:5555</code>and have fun with p5.js :)</li></ol></div>',b(e,"class","welcome")},m(t,n){h(t,e,n)},p:t,i:t,o:t,d(t){t&&p(e)}}}class vt extends Q{constructor(t){super(),K(this,t,null,$t,c,{})}}function _t(n){let e,o,r;return{c(){e=g("iframe"),b(e,"title",o=n[0].id),e.src!==(r=`/${n[0].id}/index.html`)&&b(e,"src",r),b(e,"width","100%"),b(e,"scrolling","no"),b(e,"id","single-sketch"),b(e,"class","svelte-o2mouj")},m(t,n){h(t,e,n)},p(t,[n]){1&n&&o!==(o=t[0].id)&&b(e,"title",o),1&n&&e.src!==(r=`/${t[0].id}/index.html`)&&b(e,"src",r)},i:t,o:t,d(t){t&&p(e)}}}function bt(t,n,e){let{params:o={}}=n;return t.$$set=t=>{"params"in t&&e(0,o=t.params)},[o]}class xt extends Q{constructor(t){super(),K(this,t,bt,_t,c,{params:0})}}function yt(n){let e,o,r,s,c;return o=new mt({}),s=new ut({props:{routes:n[0]}}),{c(){e=g("div"),J(o.$$.fragment),r=$(),J(s.$$.fragment),b(e,"class","app svelte-1d838t4")},m(t,n){h(t,e,n),U(o,e,null),d(e,r),U(s,e,null),c=!0},p:t,i(t){c||(B(o.$$.fragment,t),B(s.$$.fragment,t),c=!0)},o(t){X(o.$$.fragment,t),X(s.$$.fragment,t),c=!1},d(t){t&&p(e),W(o),W(s)}}}function wt(t){return[{"/":vt,"/:id":xt}]}return new class extends Q{constructor(t){super(),K(this,t,wt,yt,c,{})}}({target:document.body})}();
//# sourceMappingURL=bundle.js.map