From ec98ed8469378a2abb19af6605956b986b9288a7 Mon Sep 17 00:00:00 2001 From: Luiz Bills Date: Sat, 5 Oct 2024 19:33:40 -0300 Subject: [PATCH] update utils --- package-lock.json | 6 +++--- public/litecanvas.js | 4 ++-- public/sw.js | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/package-lock.json b/package-lock.json index 4079ea4..d5dc2d4 100644 --- a/package-lock.json +++ b/package-lock.json @@ -532,9 +532,9 @@ } }, "node_modules/@litecanvas/utils": { - "version": "0.15.0", - "resolved": "https://registry.npmjs.org/@litecanvas/utils/-/utils-0.15.0.tgz", - "integrity": "sha512-MWO5M1Z3dKv7/iplII9yglMpyUI8dCvbze7pol4Vu3cori4bYdH4AKHf2sFSpsyMVpFfQmOlXqgmgYH2oa7NnA==", + "version": "0.16.0", + "resolved": "https://registry.npmjs.org/@litecanvas/utils/-/utils-0.16.0.tgz", + "integrity": "sha512-8OjoNwpf1LJCo9q94XsjsDRk6bPQSoXdTJdA3Id3eSjMOH5w2ABQ5/jSR087NCTxEVt8IL6YDDX+IpeaaMF5SA==", "peerDependencies": { "litecanvas": "*" } diff --git a/public/litecanvas.js b/public/litecanvas.js index 40e5c08..3d00a24 100644 --- a/public/litecanvas.js +++ b/public/litecanvas.js @@ -1,7 +1,7 @@ (()=>{var e=/* @__PURE__ */new AudioContext;globalThis.zzfxV=1;var t=(t=1,a=.05,l=220,n=0,r=0,i=.1,o=0,s=1,c=0,f=0,p=0,u=0,d=0,g=0,h=0,m=0,v=0,T=1,x=0,b=0,E=0)=>{let y=Math,w=2*y.PI,H=c*=500*w/44100/44100,D=l*=(1-a+2*a*y.random(a=[]))*w/44100,I=0,A=0,S=0,P=1,k=0,C=0,z=0,O=E<0?-1:1,X=w*O*E*2/44100,L=y.cos(X),W=y.sin,Y=W(X)/4,M=1+Y,_=-2*L/M,B=(1-Y)/M,F=(1+O*L)/2/M,G=-(O+L)/M,R=0,N=0,j=0,U=0;for(n=44100*n+9,x*=44100,r*=44100,i*=44100,v*=44100,f*=500*w/85766121e6,h*=w/44100,p*=w/44100,u*=44100,d=44100*d|0,t*=.3*globalThis.zzfxV,O=n+x+r+i+v|0;SS?0:(Su&&(l+=p,D+=p,P=0),!d||++k%d||(l=D,c=H,P=P||1);(t=e.createBuffer(1,O,44100)).getChannelData(0).set(a),(l=e.createBufferSource()).buffer=t,l.connect(e.destination),l.start()},a=["#18161c","#6a7799","#aec2c2","#f3eade","#f04f78","#fcf660","#2f328f","#4b80ca","#327345","#63c64d","#703075","#a56243"];globalThis.litecanvas=function(e={}){let l=globalThis,n=Math.PI,r=2*n,i=(e,t,a)=>e.addEventListener(t,a);e=Object.assign({fps:60,fullscreen:!0,width:null,height:null,autoscale:!0,pixelart:!1,antialias:!1,canvas:null,global:!0,loop:null,pauseOnBlur:!0,tapEvents:!0,keyboardEvents:!0},e);let o=!1,s=[],c=e.canvas||document.createElement("canvas"),f=e.fullscreen,p=e.autoscale,u=1,d,g=1,h,m=1/e.fps,v=1e3*m,T=0,x,b=0,E=0,y="sans-serif",w="",H=32,D=Date.now(),I={init:!1,update:!1,draw:!1,resized:!1,tap:!1,untap:!1,tapping:!1,tapped:!1},A={settings:Object.assign({},e),colors:a},S={WIDTH:e.width,HEIGHT:e.height||e.width,CANVAS:null,ELAPSED:0,FPS:e.fps,CENTERX:0,CENTERY:0,MOUSEX:-1,MOUSEY:-1,DEFAULT_SFX:[.5,,1675,,.06,.2,1,1.8,,,637,.06],PI:n,TWO_PI:r,HALF_PI:.5*n,lerp:(e,t,a)=>e+a*(t-e),deg2rad:e=>n/180*e,rad2deg:e=>180/n*e,clamp:(e,t,a)=>ea?a:e,wrap:(e,t,a)=>e-(a-t)*Math.floor((e-t)/(a-t)),map(e,t,a,l,n,r=!1){let i=(e-t)/(a-t)*(n-l)+l;return r?S.clamp(i,l,n):i},norm:(e,t,a)=>S.map(e,t,a,0,1),rand:(e=0,t=1)=>(D=(1664525*D+0x3c6ef35f)%0x100000000)/0x100000000*(t-e)+e,randi:(e=0,t=1)=>S.floor(S.rand(e,t+1)),seed:e=>null==e?D:D=~~e,cls(e){null==e?d.clearRect(0,0,S.WIDTH,S.HEIGHT):S.rectfill(0,0,S.WIDTH,S.HEIGHT,e)},rect(e,t,a,l,n=0,r=null){d.beginPath(),d[r?"roundRect":"rect"](~~e,~~t,a,l,r),S.stroke(n)},rectfill(e,t,a,l,n=0,r=null){d.beginPath(),d[r?"roundRect":"rect"](~~e,~~t,a,l,r),S.fill(n)},circ(e,t,a,l){d.beginPath(),d.arc(~~e,~~t,a,0,r),d.closePath(),S.stroke(l)},circfill(e,t,a,l){d.beginPath(),d.arc(~~e,~~t,a,0,r),d.closePath(),S.fill(l)},line(e,t,a,l,n){d.beginPath(),d.moveTo(~~e,~~t),d.lineTo(~~a,~~l),S.stroke(n)},linewidth(e){d.lineWidth=e},linedash(e,t=0){d.setLineDash(Array.isArray(e)?e:[e]),d.lineDashOffset=t},text(e,t,a,l=3){d.font=`${w} ${H}px ${y}`,d.fillStyle=S.getcolor(l),d.fillText(a,~~e,~~t)},textfont(e){y=e},textsize(e){H=e},textstyle(e){w=e||""},textalign(e,t){e&&(d.textAlign=e),t&&(d.textBaseline=t)},textmetrics(e,t=H){d.font=`${w} ${t}px ${y}`;let a=d.measureText(e);return a.height=a.actualBoundingBoxAscent+a.actualBoundingBoxDescent,a},image(e,t,a){d.drawImage(a,~~e,~~t)},paint(e,t,a,l={}){let n=l.canvas||new OffscreenCanvas(1,1),r=l.scale||1,i=d;if(n.width=e*r,n.height=t*r,(d=n.getContext("2d")).scale(r,r),Array.isArray(a)){let e=0,t=0;for(let l of(d.imageSmoothingEnabled=!1,a)){for(let a of l)" "!==a&&"."!==a&&S.rectfill(e,t,1,1,parseInt(a,16)),e++;t++,e=0}}else a(n,d);return d=i,n},ctx:e=>(e&&(d=e),d),push:()=>d.save(),pop:()=>d.restore(),translate:(e,t)=>d.translate(~~e,~~t),scale:(e,t)=>d.scale(e,t||e),rotate:e=>d.rotate(e),transform:(e,t,a,l,n,r,i=!0)=>d[i?"setTransform":"transform"](e,t,a,l,n,r),alpha(e){d.globalAlpha=S.clamp(e,0,1)},path:e=>new Path2D(e),fill(e,t){d.fillStyle=S.getcolor(e),t?d.fill(t):d.fill()},stroke(e,t){d.strokeStyle=S.getcolor(e),t?d.stroke(t):d.stroke()},cliprect(e,t,a,l){d.beginPath(),d.rect(e,t,a,l),d.clip()},clipcirc(e,t,a){d.beginPath(),d.arc(e,t,a,0,r),d.clip()},sfx:(e,a=0,n=1)=>!(l.zzfxV<=0)&&(!navigator.userActivation||!!navigator.userActivation.hasBeenActive)&&(e=e||S.DEFAULT_SFX,(a>0||1!==n)&&((e=e.slice())[0]=n*(e[0]||1),e[10]=~~e[10]+a),t.apply(0,e),e),volume(e){l.zzfxV=+e},colrect:(e,t,a,l,n,r,i,o)=>en&&tr,colcirc:(e,t,a,l,n,r)=>(l-e)**2+(n-t)**2<=(a+r)**2,timescale(e){g=e},use(e,t={}){e.__conf=t,o?O(e):s.push(e)},listen:(e,t)=>(I[e]=I[e]||[],I[e].push(t),()=>{I[e]=I[e].filter(e=>t!==e)}),emit(e,t,a,l,n){z("before:"+e,t,a,l,n),z(e,t,a,l,n),z("after:"+e,t,a,l,n)},getcolor:e=>a[~~e%a.length],setvar(t,a){S[t]=a,e.global&&(l[t]=a)},resize(e,t){S.setvar("WIDTH",c.width=e),S.setvar("HEIGHT",c.height=t||e),C()}};for(let e of["sin","cos","atan2","hypot","tan","abs","ceil","round","floor","trunc","min","max","pow","sqrt","sign","exp"])S[e]=Math[e];function P(){o=!0,c="string"==typeof c?document.querySelector(c):c,S.setvar("CANVAS",c),d=c.getContext("2d"),S.WIDTH>0&&(f=!1),c.width=S.WIDTH,c.height=S.HEIGHT||S.WIDTH,c.parentNode||document.body.appendChild(c),c.style.display="block",f?(c.style.position="absolute",c.style.inset=0):p&&(c.style.margin="auto");let t=e.loop?e.loop:l;for(let e of Object.keys(I))t[e]&&S.listen(e,t[e]);for(let e of s)O(e);if(i(l,"resize",C),C(),e.tapEvents){let e=(e,t)=>[(e-c.offsetLeft)/u,(t-c.offsetTop)/u],t=/* @__PURE__ */new Map,a=(e,a,l)=>{let n={x:a,y:l,startX:a,startY:l,ts:performance.now()};return t.set(e,n),n},n=(e,l,n)=>{let r=t.get(e)||a(e);r.x=l,r.y=n},r=e=>e&&performance.now()-e.ts<=200,o=!1;i(c,"mousedown",t=>{t.preventDefault();let[l,n]=e(t.pageX,t.pageY);S.emit("tap",l,n,0),a(0,l,n),o=!0}),i(c,"mousemove",t=>{t.preventDefault();let[a,l]=e(t.pageX,t.pageY);S.setvar("MOUSEX",a),S.setvar("MOUSEY",l),o&&(S.emit("tapping",a,l,0),n(0,a,l))}),i(c,"mouseup",a=>{a.preventDefault();let l=t.get(0),[n,i]=e(a.pageX,a.pageY);r(l)&&S.emit("tapped",l.startX,l.startY,0),S.emit("untap",n,i,0),t.delete(0),o=!1}),i(c,"touchstart",t=>{for(let l of(t.preventDefault(),t.changedTouches)){let[t,n]=e(l.pageX,l.pageY);S.emit("tap",t,n,l.identifier+1),a(l.identifier+1,t,n)}}),i(c,"touchmove",t=>{for(let a of(t.preventDefault(),t.changedTouches)){let[t,l]=e(a.pageX,a.pageY);S.emit("tapping",t,l,a.identifier+1),n(a.identifier+1,t,l)}});let s=e=>{e.preventDefault();let a=[];if(e.targetTouches.length>0)for(let t of e.targetTouches)a.push(t.identifier+1);for(let[e,l]of t)a.includes(e)||(r(l)&&S.emit("tapped",l.startX,l.startY,e),S.emit("untap",l.x,l.y,e),t.delete(e))};i(c,"touchend",s),i(c,"touchcancel",s),i(l,"blur",()=>{for(let[e,a]of(o=!1,t))S.emit("untap",a.x,a.y,e),t.delete(e)})}if(e.keyboardEvents){let e=/* @__PURE__ */new Set;S.setvar("iskeydown",t=>"any"===t?e.size>0:e.has(t.toLowerCase())),i(l,"keydown",t=>{e.add(t.key.toLowerCase())}),i(l,"keyup",t=>{e.delete(t.key.toLowerCase())}),i(l,"blur",()=>e.clear())}e.pauseOnBlur&&(i(l,"blur",()=>{x=null}),i(l,"focus",()=>{x||(h=performance.now(),x=requestAnimationFrame(k))})),S.emit("init",S),h=performance.now(),x=requestAnimationFrame(k)}function k(e){let t=0,a=e-h;for(h=e,T+=a;T>=v;)S.emit("update",m*g),S.setvar("ELAPSED",S.ELAPSED+m*g),T-=v,t++;t&&(S.textalign("start","top"),S.emit("draw"),b++,(E+=v*t)+T>=1e3&&(S.setvar("FPS",b),b=0,E-=1e3)),x&&(x=requestAnimationFrame(k))}function C(){let t=l.innerWidth,a=l.innerHeight;f?(S.setvar("WIDTH",c.width=t),S.setvar("HEIGHT",c.height=a)):p&&(u=Math.min(t/S.WIDTH,a/S.HEIGHT),u=(e.pixelart?~~u:u)||1,c.style.width=S.WIDTH*u+"px",c.style.height=S.HEIGHT*u+"px"),S.setvar("CENTERX",S.WIDTH/2),S.setvar("CENTERY",S.HEIGHT/2),(!e.antialias||e.pixelart)&&(d.imageSmoothingEnabled=!1,c.style.imageRendering="pixelated"),S.emit("resized",u)}function z(e,t,a,l,n){if(I[e])for(let r of I[e])r(t,a,l,n)}function O(e){let t=e(S,A,e.__conf);if("object"==typeof t)for(let[e,a]of Object.entries(t))S.setvar(e,a)}if(e.global){if(l.__litecanvas)throw"global litecanvas already instantiated";Object.assign(l,S),l.__litecanvas=S}return"loading"===document.readyState?i(l,"DOMContentLoaded",P):P(),S}})(); -(()=>{var J=Object.defineProperty;var Q=(t,e)=>{for(var s in e)J(t,s,{get:e[s],enumerable:!0})};globalThis.utils=globalThis.utils||{};globalThis.utils.global=()=>{for(let t in globalThis.utils)t!=="global"&&(globalThis[t]=globalThis.utils[t])};var k={};Q(k,{ANCHOR_BOT_LEFT:()=>bt,ANCHOR_BOT_RIGHT:()=>At,ANCHOR_CENTER:()=>Mt,ANCHOR_TOP_LEFT:()=>G,ANCHOR_TOP_RIGHT:()=>It,Actor:()=>C,BACK_IN:()=>St,BACK_IN_OUT:()=>Pt,BACK_OUT:()=>kt,BOUNCE_IN:()=>Z,BOUNCE_IN_OUT:()=>Bt,BOUNCE_OUT:()=>S,Camera:()=>u,DOWN:()=>wt,EASE_IN:()=>Ot,EASE_IN_OUT:()=>Dt,EASE_OUT:()=>Ct,ELASTIC_IN:()=>Lt,ELASTIC_IN_OUT:()=>Xt,ELASTIC_OUT:()=>Rt,Grid:()=>g,LEFT:()=>Et,LINEAR:()=>K,ONE:()=>yt,RIGHT:()=>Tt,TypedGrid:()=>M,UP:()=>mt,Vector:()=>p,ZERO:()=>F,advance:()=>q,diff:()=>V,fract:()=>z,intersection:()=>d,range:()=>$,resolve:()=>L,tween:()=>Ht,vec:()=>n,vecAbs:()=>ft,vecAdd:()=>A,vecAngle:()=>nt,vecAngleBetween:()=>ht,vecCeil:()=>ut,vecClamp:()=>xt,vecCross:()=>at,vecDist:()=>rt,vecDist2:()=>ot,vecDiv:()=>y,vecDot:()=>N,vecEq:()=>b,vecFloor:()=>pt,vecIsZero:()=>gt,vecLerp:()=>ct,vecLimit:()=>it,vecMag:()=>U,vecMag2:()=>W,vecMove:()=>dt,vecMult:()=>_,vecNorm:()=>O,vecRand:()=>lt,vecReflect:()=>et,vecRotate:()=>tt,vecRound:()=>_t,vecSet:()=>Y,vecSetMag:()=>st,vecSub:()=>H,wave:()=>j});var d=(t,e,s,i,r,o,h,a)=>{let c=Math.max(t,r),P=Math.min(t+s,r+h)-c,x=Math.max(e,o),T=Math.min(e+i,o+a)-x;return[c,x,P,T]};var L=(t,e,s,i,r,o,h,a)=>{let[c,P,x,T]=d(t,e,s,i,r,o,h,a),f="",w=t,E=e;return x{this._shake.x=this._engine.randi(-e,e),this._shake.y=this._engine.randi(-e,e),s-=i,s<=0&&this.unshake()}))}unshake(){this.shaking&&(this._shake.removeListener(),this._shake.removeListener=null,this._shake.x=this._shake.y=0)}get shaking(){return this._shake.removeListener!==null}};var g=class t{_w;_h;_c;constructor(e,s,i=[]){this._w=Math.max(1,~~e),this._h=Math.max(1,~~s),this._c=i}clear(){this.forEach((e,s)=>this.set(e,s,void 0))}get width(){return this._w}get height(){return this._h}set(e,s,i){this._c[this.pointToIndex(e,s)]=i}get(e,s){return this._c[this.pointToIndex(e,s)]}has(e,s){return this.get(e,s)!=null}get length(){return this._w*this._h}pointToIndex(e,s){return this.clampX(~~e)+this.clampY(~~s)*this._w}indexToPointX(e){return e%this._w}indexToPointY(e){return Math.floor(e/this._w)}forEach(e,s=!1){let i=s?this.length-1:0,r=s?-1:this.length,o=s?-1:1;for(;i!==r;){let h=this.indexToPointX(i),a=this.indexToPointY(i),c=this._c[i];if(e(h,a,c,this)===!1)break;i+=o}}fill(e){this.forEach((s,i)=>{this.set(s,i,e)})}clone(){return t.fromArray(this._w,this._h,this._c)}clampX(e){return R(e,0,this._w-1)}clampY(e){return R(e,0,this._h-1)}toArray(){return this._c.slice()}toString(e=" ",s=!0){if(!s)return this._c.join(e);let i=[];return this.forEach((r,o,h)=>{i[o]=i[o]||"",i[o]+=h+e}),i.join(` -`)}},M=class t extends g{constructor(e,s,i=Uint8Array){super(e,s,null),this._c=new i(this._w*this._h)}has(e,s){return this.get(e,s)!==0}clone(){let e=new t(this._w,this._h,this._c.constructor);return this.forEach((s,i,r)=>{e.set(s,i,r)}),e}};function R(t,e,s){return ts?s:t}var I=Math.sqrt,X=Math.cos,B=Math.sin,v=2*Math.PI,p=class{x;y;constructor(e=0,s=e){this.x=e,this.y=s}toString(){return`Vector (${this.x}, ${this.y})`}},l=t=>t instanceof p,n=(t=0,e=t)=>(l(t)&&(e=t.y,t=t.x),new p(t,e)),b=(t,e,s=e)=>l(e)?b(t,e.x,e.y):t.x===e&&t.y===s,Y=(t,e,s=e)=>(l(e)?Y(t,e.x,e.y):(t.x=e,t.y=s),t),A=(t,e,s=e)=>l(e)?A(t,e.x,e.y):(t.x+=e,t.y+=s,t),H=(t,e,s=e)=>l(e)?H(t,e.x,e.y):(t.x-=e,t.y-=s,t),_=(t,e,s=e)=>l(e)?_(t,e.x,e.y):(t.x*=e,t.y*=s,t),y=(t,e,s=e)=>l(e)?y(t,e.x,e.y):(t.x/=e||1,t.y/=s||1,t),tt=(t,e)=>{let s=X(e),i=B(e);return t.x=s*t.x-i*t.y,t.y=i*t.x+s*t.y,t},et=(t,e)=>{let s=O(n(e));return H(t,_(s,2*N(t,s)))},st=(t,e)=>(O(t),_(t,e),t),U=t=>I(t.x*t.x+t.y*t.y),W=t=>t.x*t.x+t.y*t.y,O=t=>{let e=U(t);return e>0&&y(t,e),t},it=(t,e=1)=>{let s=W(t);return s>e*e&&(y(t,I(s)),_(t,e)),t},rt=(t,e)=>{let s=t.x-e.x,i=t.y-e.y;return I(s*s+i*i)},ot=(t,e)=>{let s=t.x-e.x,i=t.y-e.y;return s*s+i*i},nt=t=>Math.atan2(t.y,t.x),ht=(t,e)=>Math.atan2(e.y-t.y,e.x-t.x),N=(t,e)=>t.x*e.x+t.y*e.y,at=(t,e)=>t.x*e.y-t.y*e.x,ct=(t,e,s)=>(t.x+=(e.x-t.x)*s||0,t.y+=(e.y-t.y)*s||0,t),lt=(t=1,e=t,s=globalThis.rand||Math.random)=>{let i=s()*v,r=s()*(e-t)+t;return n(X(i)*r,B(i)*r)},ft=t=>(t.x=Math.abs(t.x),t.y=Math.abs(t.y),t),ut=t=>(t.x=Math.ceil(t.x),t.y=Math.ceil(t.y),t),pt=t=>(t.x=Math.floor(t.x),t.y=Math.floor(t.y),t),_t=t=>(t.x=Math.round(t.x),t.y=Math.round(t.y),t),xt=(t,e,s)=>(t.xs.x&&(t.x=s.x),t.ys.y&&(t.y=s.y),t),dt=(t,e,s=1)=>A(t,e.x*s,e.y*s),gt=t=>b(t,F),F=n(0,0),yt=n(1,1),mt=n(0,-1),Tt=n(1,0),wt=n(0,1),Et=n(-1,0);globalThis.zzfxV=1;var Mt=n(.5,.5),G=n(0,0),It=n(1,0),bt=n(0,1),At=n(1,1),C=class{sprite;pos;_o;_s;angle=0;opacity=1;hidden=!1;constructor(e,s,i=G){this.sprite=e,this.pos=s||n(0),this._o=n(i),this._s=n(1,1)}set x(e){this.pos.x=e}get x(){return this.pos.x}set y(e){this.pos.y=e}get y(){return this.pos.y}set anchor(e){this._o.x=e.x,this._o.y=e.y}get anchor(){return this._o}get width(){return this.sprite.width*this._s.x}get height(){return this.sprite.height*this._s.y}get scale(){return this._s}scaleTo(e,s=e){this._s.x=e,this._s.y=s}scaleBy(e,s=e){this._s.x*=e,this._s.y*=s}getBounds(e=!0){let s=this.sprite.width*(e?this._s.x:1),i=this.sprite.height*(e?this._s.y:1),r=this.pos.x-s*this.anchor.x,o=this.pos.y-i*this.anchor.y;return[r,o,s,i]}draw(e=globalThis,s=!0){this.hidden||this.opacity<=0||(s&&e.push(),this.transform(e),this.drawImage(e),s&&e.pop())}transform(e){e.translate(this.pos.x,this.pos.y),e.rotate(this.angle),e.scale(this._s.x,this._s.y)}drawImage(e,s=!0){let i=this.sprite.width*this.anchor.x,r=this.sprite.height*this.anchor.y;s&&e.alpha(this.opacity),e.image(-i,-r,this.sprite)}};var V=(t,e)=>Math.abs(e-t)||0;var j=(t,e,s,i=Math.sin)=>t+(i(s)+1)/2*(e-t);var z=t=>t%1||0;var $=t=>Array.from(Array(t).keys());var q=advance=(t,e,s,i=1)=>{s&&(e.x+=s.x*i,e.y+=s.y*i),t.x+=e.x*i,t.y+=e.y*i};var m=Math.PI/2,Ht=(t,e,s,i=1,r=K)=>new D(t,e,s,i,r),K=t=>t,Ot=t=>t*t,Ct=t=>-t*(t-2),Dt=t=>t<.5?2*t*t:-2*t*t+4*t-1,St=t=>t*t*t-t*Math.sin(t*Math.PI),kt=t=>{let e=1-t;return 1-(e*e*e-e*Math.sin(e*Math.PI))},Pt=t=>{if(t<.5){let s=2*t;return .5*(s*s*s-s*Math.sin(s*Math.PI))}let e=1-(2*t-1);return .5*(1-(e*e*e-e*Math.sin(t*Math.PI)))+.5},Lt=t=>Math.sin(13*m*t)*Math.pow(2,10*(t-1)),Rt=t=>Math.sin(-13*m*(t+1))*Math.pow(2,-10*t)+1,Xt=t=>{if(t<.5){let i=Math.sin(13*m*(2*t)),r=Math.pow(2,10*(2*t-1));return .5*i*r}let e=Math.sin(-13*m*(2*t-1+1)),s=Math.pow(2,-10*(2*t-1));return .5*(e*s+2)},Z=t=>1-S(1-t),S=t=>t<4/11?121*t*t/16:t<8/11?363/40*t*t-99/10*t+17/5:t<9/10?4356/361*t*t-35442/1805*t+16061/1805:54/5*t*t-513/25*t+268/25,Bt=t=>t<.5?.5*Z(t*2):.5*S(t*2-1)+.5,D=class{running=!1;_o;_p;_x;_d;_e;_cb=[];_t=0;_u=0;_lc;constructor(e,s,i,r,o){this._o=e,this._p=s,this._x=i,this._d=r,this._e=o}start(e=globalThis){this.running||this.stop();let s=this._o[this._p]||0;return this._lc=e,this._u=e.listen("update",i=>{this._o[this._p]=e.lerp(s,this._x,this._e(this._t/this._d)),this._t+=i,this._t>=this._d&&(this._o[this._p]=this._x,this.stop())}),this.running=!0,this}onEnd(e){this._cb.push(e)}stop(e=!0){if(!(!this.running||!this._u)&&(this.running=!1,this._u(),e))for(let s of this._cb)s(this._o)}reset(){this._cb.length=0,this.stop()}get progress(){return this.running?this._t/this._d:0}};globalThis.utils=Object.assign(globalThis.utils||{},k);})(); +(()=>{var J=Object.defineProperty;var Q=(t,e)=>{for(var s in e)J(t,s,{get:e[s],enumerable:!0})};globalThis.utils=globalThis.utils||{};globalThis.utils.global=()=>{for(let t in globalThis.utils)t!=="global"&&(globalThis[t]=globalThis.utils[t])};var k={};Q(k,{ANCHOR_BOT_LEFT:()=>bt,ANCHOR_BOT_RIGHT:()=>At,ANCHOR_CENTER:()=>Mt,ANCHOR_TOP_LEFT:()=>G,ANCHOR_TOP_RIGHT:()=>It,Actor:()=>C,BACK_IN:()=>St,BACK_IN_OUT:()=>Pt,BACK_OUT:()=>kt,BOUNCE_IN:()=>Z,BOUNCE_IN_OUT:()=>Yt,BOUNCE_OUT:()=>S,Camera:()=>u,DOWN:()=>wt,EASE_IN:()=>Ot,EASE_IN_OUT:()=>Dt,EASE_OUT:()=>Ct,ELASTIC_IN:()=>Lt,ELASTIC_IN_OUT:()=>Rt,ELASTIC_OUT:()=>Xt,Grid:()=>g,LEFT:()=>Et,LINEAR:()=>K,ONE:()=>yt,RIGHT:()=>Tt,TypedGrid:()=>M,UP:()=>mt,Vector:()=>p,ZERO:()=>F,advance:()=>q,diff:()=>V,fract:()=>z,intersection:()=>d,range:()=>$,resolve:()=>L,tween:()=>Ht,vec:()=>n,vecAbs:()=>ft,vecAdd:()=>A,vecAngle:()=>nt,vecAngleBetween:()=>ht,vecCeil:()=>ut,vecClamp:()=>xt,vecCross:()=>at,vecDist:()=>rt,vecDist2:()=>ot,vecDiv:()=>y,vecDot:()=>N,vecEq:()=>b,vecFloor:()=>pt,vecIsZero:()=>gt,vecLerp:()=>ct,vecLimit:()=>it,vecMag:()=>U,vecMag2:()=>W,vecMove:()=>dt,vecMult:()=>_,vecNorm:()=>O,vecRand:()=>lt,vecReflect:()=>et,vecRotate:()=>tt,vecRound:()=>_t,vecSet:()=>B,vecSetMag:()=>st,vecSub:()=>H,wave:()=>j});var d=(t,e,s,i,r,o,h,a)=>{let c=Math.max(t,r),P=Math.min(t+s,r+h)-c,x=Math.max(e,o),T=Math.min(e+i,o+a)-x;return[c,x,P,T]};var L=(t,e,s,i,r,o,h,a)=>{let[c,P,x,T]=d(t,e,s,i,r,o,h,a),f="",w=t,E=e;return x{this._shake.x=this._engine.randi(-e,e),this._shake.y=this._engine.randi(-e,e),s-=i,s<=0&&this.unshake()}))}unshake(){this.shaking&&(this._shake.removeListener(),this._shake.removeListener=null,this._shake.x=this._shake.y=0)}get shaking(){return this._shake.removeListener!==null}};var g=class t{_w;_h;_c;constructor(e,s,i=[]){this._w=Math.max(1,~~e),this._h=Math.max(1,~~s),this._c=i}clear(){this.forEach((e,s)=>this.set(e,s,void 0))}get width(){return this._w}get height(){return this._h}set(e,s,i){this._c[this.pointToIndex(e,s)]=i}get(e,s){return this._c[this.pointToIndex(e,s)]}has(e,s){return this.get(e,s)!=null}get length(){return this._w*this._h}pointToIndex(e,s){return this.clampX(~~e)+this.clampY(~~s)*this._w}indexToPointX(e){return e%this._w}indexToPointY(e){return Math.floor(e/this._w)}forEach(e,s=!1){let i=s?this.length-1:0,r=s?-1:this.length,o=s?-1:1;for(;i!==r;){let h=this.indexToPointX(i),a=this.indexToPointY(i),c=this._c[i];if(e(h,a,c,this)===!1)break;i+=o}}fill(e){this.forEach((s,i)=>{this.set(s,i,e)})}clone(){return t.fromArray(this._w,this._h,this._c)}clampX(e){return X(e,0,this._w-1)}clampY(e){return X(e,0,this._h-1)}toArray(){return this._c.slice()}toString(e=" ",s=!0){if(!s)return this._c.join(e);let i=[];return this.forEach((r,o,h)=>{i[o]=i[o]||"",i[o]+=h+e}),i.join(` +`)}},M=class t extends g{constructor(e,s,i=Uint8Array){super(e,s,null),this._c=new i(this._w*this._h)}has(e,s){return this.get(e,s)!==0}clone(){let e=new t(this._w,this._h,this._c.constructor);return this.forEach((s,i,r)=>{e.set(s,i,r)}),e}};function X(t,e,s){return ts?s:t}var I=Math.sqrt,R=Math.cos,Y=Math.sin,v=2*Math.PI,p=class{x;y;constructor(e=0,s=e){this.x=e,this.y=s}toString(){return`Vector (${this.x}, ${this.y})`}},l=t=>t instanceof p,n=(t=0,e=t)=>(l(t)&&(e=t.y,t=t.x),new p(t,e)),b=(t,e,s=e)=>l(e)?b(t,e.x,e.y):t.x===e&&t.y===s,B=(t,e,s=e)=>(l(e)?B(t,e.x,e.y):(t.x=e,t.y=s),t),A=(t,e,s=e)=>l(e)?A(t,e.x,e.y):(t.x+=e,t.y+=s,t),H=(t,e,s=e)=>l(e)?H(t,e.x,e.y):(t.x-=e,t.y-=s,t),_=(t,e,s=e)=>l(e)?_(t,e.x,e.y):(t.x*=e,t.y*=s,t),y=(t,e,s=e)=>l(e)?y(t,e.x,e.y):(t.x/=e||1,t.y/=s||1,t),tt=(t,e)=>{let s=R(e),i=Y(e);return t.x=s*t.x-i*t.y,t.y=i*t.x+s*t.y,t},et=(t,e)=>{let s=O(n(e));return H(t,_(s,2*N(t,s)))},st=(t,e)=>(O(t),_(t,e),t),U=t=>I(t.x*t.x+t.y*t.y),W=t=>t.x*t.x+t.y*t.y,O=t=>{let e=U(t);return e>0&&y(t,e),t},it=(t,e=1)=>{let s=W(t);return s>e*e&&(y(t,I(s)),_(t,e)),t},rt=(t,e)=>{let s=t.x-e.x,i=t.y-e.y;return I(s*s+i*i)},ot=(t,e)=>{let s=t.x-e.x,i=t.y-e.y;return s*s+i*i},nt=t=>Math.atan2(t.y,t.x),ht=(t,e)=>Math.atan2(e.y-t.y,e.x-t.x),N=(t,e)=>t.x*e.x+t.y*e.y,at=(t,e)=>t.x*e.y-t.y*e.x,ct=(t,e,s)=>(t.x+=(e.x-t.x)*s||0,t.y+=(e.y-t.y)*s||0,t),lt=(t=1,e=t,s=globalThis.rand||Math.random)=>{let i=s()*v,r=s()*(e-t)+t;return n(R(i)*r,Y(i)*r)},ft=t=>(t.x=Math.abs(t.x),t.y=Math.abs(t.y),t),ut=t=>(t.x=Math.ceil(t.x),t.y=Math.ceil(t.y),t),pt=t=>(t.x=Math.floor(t.x),t.y=Math.floor(t.y),t),_t=t=>(t.x=Math.round(t.x),t.y=Math.round(t.y),t),xt=(t,e,s)=>(t.xs.x&&(t.x=s.x),t.ys.y&&(t.y=s.y),t),dt=(t,e,s=1)=>A(t,e.x*s,e.y*s),gt=t=>b(t,F),F=n(0,0),yt=n(1,1),mt=n(0,-1),Tt=n(1,0),wt=n(0,1),Et=n(-1,0);globalThis.zzfxV=1;var Mt=n(.5,.5),G=n(0,0),It=n(1,0),bt=n(0,1),At=n(1,1),C=class{sprite;pos;_o;_s;flipX=!1;flipY=!1;angle=0;opacity=1;hidden=!1;constructor(e,s,i=G){this.sprite=e,this.pos=s||n(0),this._o=n(i),this._s=n(1,1)}set x(e){this.pos.x=e}get x(){return this.pos.x}set y(e){this.pos.y=e}get y(){return this.pos.y}set anchor(e){this._o.x=e.x,this._o.y=e.y}get anchor(){return this._o}get width(){return this.sprite.width*this._s.x}get height(){return this.sprite.height*this._s.y}get scale(){return this._s}scaleTo(e,s=e){this._s.x=e,this._s.y=s}scaleBy(e,s=e){this._s.x*=e,this._s.y*=s}getBounds(e=!0){let s=this.sprite.width*(e?this._s.x:1),i=this.sprite.height*(e?this._s.y:1),r=this.pos.x-s*this.anchor.x,o=this.pos.y-i*this.anchor.y;return[r,o,s,i]}draw(e=globalThis,s=!0){this.hidden||this.opacity<=0||(s&&e.push(),this.transform(e),this.drawImage(e),s&&e.pop())}transform(e){e.translate(this.pos.x,this.pos.y),e.rotate(this.angle),e.scale((this.flipX?-1:1)*this._s.x,(this.flipY?-1:1)*this._s.y)}drawImage(e,s=!0){let i=this.anchor,r=-this.sprite.width*(this.flipX?1-i.x:i.x),o=-this.sprite.height*(this.flipY?1-i.y:i.y);s&&e.alpha(this.opacity),e.image(r,o,this.sprite)}};var V=(t,e)=>Math.abs(e-t)||0;var j=(t,e,s,i=Math.sin)=>t+(i(s)+1)/2*(e-t);var z=t=>t%1||0;var $=t=>Array.from(Array(t).keys());var q=advance=(t,e,s,i=1)=>{s&&(e.x+=s.x*i,e.y+=s.y*i),t.x+=e.x*i,t.y+=e.y*i};var m=Math.PI/2,Ht=(t,e,s,i=1,r=K)=>new D(t,e,s,i,r),K=t=>t,Ot=t=>t*t,Ct=t=>-t*(t-2),Dt=t=>t<.5?2*t*t:-2*t*t+4*t-1,St=t=>t*t*t-t*Math.sin(t*Math.PI),kt=t=>{let e=1-t;return 1-(e*e*e-e*Math.sin(e*Math.PI))},Pt=t=>{if(t<.5){let s=2*t;return .5*(s*s*s-s*Math.sin(s*Math.PI))}let e=1-(2*t-1);return .5*(1-(e*e*e-e*Math.sin(t*Math.PI)))+.5},Lt=t=>Math.sin(13*m*t)*Math.pow(2,10*(t-1)),Xt=t=>Math.sin(-13*m*(t+1))*Math.pow(2,-10*t)+1,Rt=t=>{if(t<.5){let i=Math.sin(13*m*(2*t)),r=Math.pow(2,10*(2*t-1));return .5*i*r}let e=Math.sin(-13*m*(2*t-1+1)),s=Math.pow(2,-10*(2*t-1));return .5*(e*s+2)},Z=t=>1-S(1-t),S=t=>t<4/11?121*t*t/16:t<8/11?363/40*t*t-99/10*t+17/5:t<9/10?4356/361*t*t-35442/1805*t+16061/1805:54/5*t*t-513/25*t+268/25,Yt=t=>t<.5?.5*Z(t*2):.5*S(t*2-1)+.5,D=class{running=!1;_o;_p;_x;_d;_e;_cb=[];_t=0;_u=0;_lc;constructor(e,s,i,r,o){this._o=e,this._p=s,this._x=i,this._d=r,this._e=o}start(e=globalThis){this.running||this.stop();let s=this._o[this._p]||0;return this._lc=e,this._u=e.listen("update",i=>{this._o[this._p]=e.lerp(s,this._x,this._e(this._t/this._d)),this._t+=i,this._t>=this._d&&(this._o[this._p]=this._x,this.stop())}),this.running=!0,this}onEnd(e){this._cb.push(e)}stop(e=!0){if(!(!this.running||!this._u)&&(this.running=!1,this._u(),e))for(let s of this._cb)s(this._o)}reset(){this._cb.length=0,this.stop()}get progress(){return this.running?this._t/this._d:0}};globalThis.utils=Object.assign(globalThis.utils||{},k);})(); /*! @litecanvas/utils by Luiz Bills | MIT Licensed */ (()=>{var E=getScriptLoader=(t,{basename:p,prepareURL:l},{crossOrigin:m,ignoreErrors:h})=>async(e,i)=>{e=l(e);let a=document.createElement("script"),u={type:"script",src:e,id:p(e)};a.crossOrigin=m,t.setvar("LOADING",t.LOADING+1),a.onload=()=>{i&&i(a),u.asset=a,t.emit("asset-load",u),t.setvar("LOADING",t.LOADING-1)},a.onerror=()=>{if(!h)throw new Error("Failed to load "+e);i&&i(null),t.emit("asset-error",u)},t.emit("filter-asset",a,u),a.src=e,document.head.appendChild(a)};var F=getImageLoader=(t,{colors:p,basename:l,prepareURL:m},{crossOrigin:h,ignoreErrors:e})=>{let i={convertColors:u,splitFrames:a};return async(s,n)=>{s=m(s);let o=new Image,r={type:"image",src:s,id:l(s)};o.crossOrigin=h,o.id=r.id,t.setvar("LOADING",t.LOADING+1),o.onload=()=>{n&&n(o,i),r.asset=o,t.emit("asset-load",r),t.setvar("LOADING",t.LOADING-1)},o.onerror=()=>{if(!e)throw new Error("Failed to load "+s);n&&n(null,i),t.emit("asset-error",r)},t.emit("filter-asset",o,r),o.src=s};function a(s,n,o,r=0,f=0){let L=[],D=Math.floor((s.width+f)/(n+f)),d=Math.floor((s.height+f)/(o+f));for(let I=0;I-1?",":" ";s=s.substr(4).split(")")[0].split(n);let o=(+s[0]).toString(16),r=(+s[1]).toString(16),f=(+s[2]).toString(16);return o.length===1&&(o="0"+o),r.length===1&&(r="0"+r),f.length===1&&(f="0"+f),[o|0,r|0,f|0]}function R(s,n){let o=1/0,r=null,[f,L,D]=s;return n.forEach(d=>{let[I,w,O]=d.startsWith("#")?A(d):G(d),c=Math.sqrt((f-I)**2+(L-w)**2+(D-O)**2);casync(h,e,i)=>{e=l(e);let a=new FontFace(h,`url(${e})`),u={type:"font",fontName:h,src:e,id:p(e)};t.emit("filter-asset",a,u),document.fonts.add(a),t.setvar("LOADING",t.LOADING+1),a.load().then(A=>{i&&i(A),u.asset=A,t.emit("asset-load",u),t.setvar("LOADING",t.LOADING-1)}).catch(()=>{if(!m)throw new Error("Failed to load "+e);i&&i(null),t.emit("asset-error",u)})};var M=getSoundLoader=(t,{basename:p,prepareURL:l},{allowSoundInterruptions:m,ignoreErrors:h})=>async(e,i)=>{e=l(e);let a={type:"sound",src:e,id:p(e)},u=new Audio;u.id=a.id,t.setvar("LOADING",t.LOADING+1),u[m?"oncanplay":"oncanplaythrough"]=()=>{i&&i(u),a.asset=u,t.emit("asset-load",a),t.setvar("LOADING",t.LOADING-1)},u.onerror=()=>{if(!h)throw new Error("Failed to load "+e);i&&i(null),t.emit("asset-error",a)},t.emit("filter-asset",u,a),u.src=e};HTMLAudioElement.prototype.stop=HTMLAudioElement.prototype.stop||function(){this.pause(),this.currentTime=0,this.src=this.src};HTMLAudioElement.prototype.restart=HTMLAudioElement.prototype.restart||function(){this.pause(),this.currentTime=0,this.play()};window.pluginAssetLoader=T;function T(t,p,l={}){l=Object.assign({crossOrigin:"anonymous",baseURL:null,allowSoundInterruptions:!0,ignoreErrors:!1},l);function h(e){return l.baseURL&&!j(e)&&(e=l.baseURL+e),e}return p=Object.assign(p,{basename:U,prepareURL:h}),t.setvar("LOADING",0),{loadScript:E(t,p,l),loadImage:F(t,p,l),loadFont:S(t,p,l),loadSound:M(t,p,l)}}function U(t){return t.split("\\").pop().split("/").pop().split(".")[0]}function j(t){try{return!!new URL(t).protocol}catch{}return!1}})(); diff --git a/public/sw.js b/public/sw.js index 30d36a7..93df72d 100644 --- a/public/sw.js +++ b/public/sw.js @@ -1,5 +1,5 @@ const cacheName = "luizbills.litecanvas-editor-v1"; -const version = "2.11.2"; +const version = "2.12.0"; const precacheResources = [ "/",