@banou/ripple 0.0.111 → 0.0.113
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/assets/{remote-BDdR-b_5.js → remote-ZS_d8OmX.js} +1 -1
- package/fkn.json +1 -1
- package/index-BvXRjgZA.js +8231 -0
- package/index.html +1 -1
- package/jassub/worker.js +2 -2
- package/package.json +2 -2
- package/sw.js +2 -2
- package/index-DQonryzk.js +0 -8192
package/index.html
CHANGED
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
<title>Ripple Torrent</title>
|
|
9
9
|
<link rel="shortcut icon" type="image/png" href="/assets/logo-bLq5c43l.png"/>
|
|
10
10
|
<link rel="manifest" href="/app.webmanifest">
|
|
11
|
-
<script type="module" crossorigin src="/index-
|
|
11
|
+
<script type="module" crossorigin src="/index-BvXRjgZA.js"></script>
|
|
12
12
|
</head>
|
|
13
13
|
<body>
|
|
14
14
|
</body>
|
package/jassub/worker.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const e={RAW:`RAW`,PROXY:`PROXY`,THROW:`THROW`,HANDLER:`HANDLER`},t={GET:`GET`,SET:`SET`,APPLY:`APPLY`,CONSTRUCT:`CONSTRUCT`,RELEASE:`RELEASE`},n=Symbol(`Abslink.proxy`),r=Symbol(`Abslink.releaseProxy`),i=Symbol(`Abslink.finalizer`),a=Symbol(`Abslink.thrown`),o=e=>typeof e==`object`&&!!e||typeof e==`function`,s=/* @__PURE__ */ new Map([[`proxy`,{canHandle:e=>o(e)&&n in e,serialize(e,t){let r=e[n];return l(e,t,r),[r,[]]},deserialize(e,t){return u(t,e)}}],[`throw`,{canHandle:e=>o(e)&&a in e,serialize({value:e}){let t;return t=e instanceof Error?{isError:!0,value:{message:e.message,name:e.name,stack:e.stack}}:{isError:!1,value:e},[t,[]]},deserialize(e){throw e.isError?Object.assign(Error(e.value.message),e.value):e.value}}]]);function c(e,t){let n=t,r=e.slice(0,-1);for(let e of r)Object.prototype.hasOwnProperty.call(n,e)&&(n=n[e]);let i=e[e.length-1],a=i?n[i]:n;return{parent:n,RawValue:a,lastSegment:i}}function l(e,n,r){return n.on(`message`,function s(l){if(!l)return;let{id:u,type:d,path:f,markerID:p}={path:[],...l};if(p!==r)return;let m=(l.argumentList??[]).map(e=>S(e,n)),h;try{let{parent:r,RawValue:i,lastSegment:a}=c(f,e);switch(d){case t.GET:h=i;break;case t.SET:r[a]=S(l.value,n),h=!0;break;case t.APPLY:h=i.apply(r,m);break;case t.CONSTRUCT:h=new i(...m);break;case t.RELEASE:h=void 0;break;default:return}}catch(e){h={value:e,[a]:0}}Promise.resolve(h).catch(e=>({value:e,[a]:0})).then(c=>{d===t.CONSTRUCT&&!(o(c)&&a in c)&&(c=b(c));let[l,f]=x(c,n);n.postMessage({...l,id:u,markerID:r},f),d===t.RELEASE&&(n.off(`message`,s),e[i]?.())}).catch(e=>{let[t,i]=x({value:/* @__PURE__ */ TypeError(`Unserializable return value`),[a]:0},n);n.postMessage({...t,id:u,markerID:r},i)})}),e}function u(e,t){let n=/* @__PURE__ */ new Map;return e.on(`message`,e=>{if(!e?.id)return;let t=n.get(e.id);if(t)try{t(e)}finally{n.delete(e.id)}}),_({endpoint:e,pendingListeners:n,rootMarkerID:t})}function d(e){if(e)throw Error(`Proxy has been released and is not useable`)}async function f(e){await C(e,{type:t.RELEASE})}const p=/* @__PURE__ */ new WeakMap,m=`FinalizationRegistry`in globalThis&&new FinalizationRegistry(e=>{let t=(p.get(e)??0)-1;p.set(e,t),t===0&&f(e).finally(()=>{e.pendingListeners.clear()})});function h(e,t){let n=(p.get(t)??0)+1;p.set(t,n),m&&m.register(e,t,e)}function g(e){m&&m.unregister(e)}function _(e,n=[]){let i=!1,a=/* @__PURE__ */ new Map,o=new Proxy(function(){},{get(s,c){if(d(i),c===r)return async()=>{for(let e of a.values())e[r]();a.clear(),g(o),f(e).finally(()=>{e.pendingListeners.clear()}),i=!0};if(c===`then`){if(n.length===0)return{then:()=>o};let r=C(e,{type:t.GET,path:n.map(e=>e.toString())}).then(t=>S(t,e.endpoint));return r.then.bind(r)}let l=a.get(c);if(l)return l;let u=_(e,[...n,c]);return a.set(c,u),u},set(r,a,o){d(i);let[s,c]=x(o,e.endpoint);return C(e,{type:t.SET,path:[...n,a].map(e=>e.toString()),value:s},c).then(t=>S(t,e.endpoint))},apply(r,a,o){if(d(i),n[n.length-1]===`bind`)return _(e,n.slice(0,-1));let[s,c]=y(o,e);return C(e,{type:t.APPLY,path:n.map(e=>e.toString()),argumentList:s},c).then(t=>S(t,e.endpoint))},construct(r,a){d(i);let[o,s]=y(a,e);return C(e,{type:t.CONSTRUCT,path:n.map(e=>e.toString()),argumentList:o},s).then(t=>S(t,e.endpoint))}});return h(o,e),o}const v=/* @__PURE__ */ new WeakMap;function y(e,t){let n=[],r=[];for(let i of e){let[e,a]=x(i,t.endpoint);n.push(e),r.push(...a)}return[n,r]}function b(e){return Object.assign(e,{[n]:O()})}function x(t,n){for(let[r,i]of s)if(i.canHandle(t)){let[a,o]=i.serialize(t,n);return[{type:e.HANDLER,name:r,value:a},o]}return[{type:e.RAW,value:t},v.get(t)??[]]}function S(t,n){switch(t.type){case e.HANDLER:return s.get(t.name).deserialize(t.value,n);case e.RAW:return t.value}}function C(e,t,n=[]){return new Promise(r=>{let i=O();e.pendingListeners.set(i,r),e.endpoint.postMessage({id:i,...t,markerID:e.rootMarkerID},n)})}const w=[],T=`0123456789abcdef`;for(let e=0;e<256;e++)w[e]=T[e>>4&15]+T[e&15];let E=0,D=``;function O(){let e=0;if(!D||E+16>512)for(D=``,E=0;e<256;++e)D+=w[Math.random()*256|0];return D.substring(E,++E+16)}function k(e,t){let n=/* @__PURE__ */ new WeakMap;return e.start?.(),t.start?.(),{on(t,r){let i=e=>r(e.data);`addEventListener`in e?e.addEventListener(t,i):`addListener`in e?e.addListener(t,i):e.on(t,i),n.set(r,i)},off(t,r){let i=n.get(r);`removeEventListener`in e?e.removeEventListener(t,i):`removeListener`in e?e.removeListener(t,i):e.off(t,i),n.delete(r)},postMessage(e,n=[]){t.postMessage(e,n)}}}function ee(e,t=globalThis,n=t){return l(e,k(t,n))}`queryLocalFonts`in globalThis&&globalThis.queryLocalFonts;const A={100:`Thin`,200:`ExtraLight`,300:`Light`,400:`Regular`,500:`Medium`,600:`SemiBold`,700:`Bold`,800:`ExtraBold`,900:`Black`,1e3:`UltraBlack`};var j=class{family;fullName;postscriptName;style;#e;#t;constructor({family:e,weight:t,isItalic:n,weightName:r}){this.family=e,this.#e=t,this.#t=n,this.style=r===`Regular`?n?`Italic`:`Regular`:r+(n?` Italic`:``),this.fullName=this.style===`Regular`?e:`${e} ${this.style}`,this.postscriptName=this.fullName.replace(/ /g,`-`)}async blob(){let e=await(await fetch(`https://fonts.googleapis.com/css2?family=${this.family}:${this.#t?`ital,`:``}wght@${this.#t?`1,`:``}${this.#e}`)).text();for(let t of[/\/\* latin-ext \*\/[\s\S]+url\(([^)]+)\)/,/\/\* latin \*\/[\s\S]+url\(([^)]+)\)/,/url\(([^)]+)\)/]){let n=e.match(t)?.[1];if(n){let e=await fetch(n);if(e.ok)return e.blob()}}throw Error(`Failed to load font blob`)}};function M([e,t]){let n=[];for(let r of t){let t=``+r,i=t.endsWith(`i`),a=t.replace(`i`,``);if(a.includes(`a`)){let[t,r]=a.split(`a`).map(e=>parseInt(e)*100);for(let a=t;a<=r;a+=100)n.push(new j({family:e,weight:`${t}..${r}`,isItalic:i,weightName:A[a]}))}else n.push(new j({family:e,weight:`${a}00`,isItalic:i,weightName:A[parseInt(a)*100]}))}return n}let N=/* @__PURE__ */ new Map;async function te(){if(N.size===0){let e=await import(`./fonts.js`);for(let t of e.default.flatMap(e=>M(e)))N.set(t.postscriptName.toLowerCase().replace(/-/g,``),t)}return N}async function ne({postscriptNames:e}={}){let t=await te();return e?e.length===0?[]:e.reduce((e,n)=>{let r=t.get(n.toLowerCase().replace(/regular$/,``).replace(/-reg$/,``).replace(/[- ]/g,``));return r&&e.push(r),e},[]):[...t.values()]}const re=[`BT.601 TV`,void 0,void 0,`BT.601 TV`,`BT.601 PC`,`BT.709 TV`,`BT.709 PC`,`SMPTE240M TV`,`SMPTE240M PC`,`FCC TV`,`FCC PC`],ie={bt709:`BT.709`,bt470bg:`BT.601`,smpte170m:`BT.601`,"bt2020-ncl":`BT.2020`},P=new Float32Array([1,0,0,0,1,0,0,0,1,0,0,0]),ae={"BT.601 TV":{"BT.709 TV":[1.0864,.096546,-.014106,-.072349,.845052,-.027694,-.014051,.058402,1.0418,0,0,0],"BT.709 PC":[.948465,.078946,-.018254,-.075064,.73081,-.035837,-.014578,.049067,.912915,.062745,.062745,.062745],"BT.601 PC":[.872569,-.005863,-.005863,-.01151,.866922,-.01151,-.002235,-.002235,.876196,.062745,.062745,.062745],"BT.2020 TV":[1.0363,.041089,-.01846,-.030397,.880729,-.03624,-.005903,.078182,1.0547,0,0,0],"BT.2020 PC":[.904456,.030232,-.022078,-.038211,.76215,-.043344,-.007421,.066442,.924246,.062745,.062745,.062745]},"BT.601 PC":{"BT.709 TV":[1.244521,.117679,-.008287,-.067105,.977257,-.01627,-.013032,.069448,1.188941,-.073059,-.073059,-.073059],"BT.709 PC":[1.0864,.096546,-.014106,-.072349,.845052,-.027694,-.014051,.058402,1.0418,0,0,0],"BT.601 TV":[1.146164,.007771,.007771,.015257,1.153649,.015257,.002963,.002963,1.141356,-.073059,-.073059,-.073059],"BT.2020 TV":[1.187488,.054547,-.013243,-.019347,1.017872,-.025999,-.003757,.091964,1.203626,-.073059,-.073059,-.073059],"BT.2020 PC":[1.0363,.041089,-.01846,-.030397,.880729,-.03624,-.005903,.078182,1.0547,0,0,0]},"BT.709 TV":{"BT.709 PC":[.874263,-.004169,-.004169,-.014024,.864408,-.014024,-.001416,-.001416,.877016,.062745,.062745,.062745],"BT.601 TV":[.9136,-.10504,.009578,.078478,1.172167,.032222,.007922,-.067127,.9582,0,0,0],"BT.601 PC":[.798366,-.096439,.004245,.054914,1.015645,.014281,.005544,-.060382,.840297,.062745,.062745,.062745],"BT.2020 TV":[.9499,-.054223,-.002956,.045506,1.038105,-.009944,.004594,.016118,1.0129,0,0,0],"BT.2020 PC":[.830253,-.0518,-.006765,.02595,.897881,-.022759,.00262,.012743,.888347,.062745,.062745,.062745]},"BT.709 PC":{"BT.709 TV":[1.143918,.005526,.005526,.018589,1.156981,.018589,.001877,.001877,1.140269,-.073059,-.073059,-.073059],"BT.601 TV":[1.045561,-.114051,.016429,.107927,1.352975,.05527,.010895,-.07454,1.092685,-.073059,-.073059,-.073059],"BT.601 PC":[.9136,-.10504,.009578,.078478,1.172167,.032222,.007922,-.067127,.9582,0,0,0],"BT.2020 TV":[1.086885,-.056202,.002161,.070392,1.20036,.007268,.007106,.020226,1.154955,-.073059,-.073059,-.073059],"BT.2020 PC":[.9499,-.054223,-.002956,.045506,1.038105,-.009944,.004594,.016118,1.0129,0,0,0]},"BT.2020 TV":{"BT.709 TV":[1.0501,.054794,.003602,-.046071,.960743,.009298,-.004029,-.015537,.9871,0,0,0],"BT.709 PC":[.91729,.042982,-.001986,-.053764,.830653,-.005127,-.004702,-.014811,.865937,.062745,.062745,.062745],"BT.601 TV":[.9637,-.046316,.015276,.03338,1.130366,.039424,.00292,-.08405,.9453,0,0,0],"BT.601 PC":[.841393,-.045837,.008268,.016028,.979655,.021338,.001402,-.074995,.829218,.062745,.062745,.062745],"BT.2020 PC":[.87328,-.005151,-.005151,-.013294,.865137,-.013294,-.001163,-.001163,.877269,.062745,.062745,.062745]},"BT.2020 PC":{"BT.709 TV":[1.202254,.069205,.010929,-.034825,1.111325,.028206,-.003046,-.016146,1.125249,-.073059,-.073059,-.073059],"BT.709 PC":[1.0501,.054794,.003602,-.046071,.960743,.009298,-.004029,-.015537,.9871,0,0,0],"BT.601 TV":[1.103897,-.045898,.024217,.055622,1.304422,.062502,.004865,-.09414,1.077664,-.073059,-.073059,-.073059],"BT.601 PC":[.9637,-.046316,.015276,.03338,1.130366,.039424,.00292,-.08405,.9453,0,0,0],"BT.2020 TV":[1.145221,.006828,.006828,.017622,1.156015,.017622,.001541,.001541,1.139934,-.073059,-.073059,-.073059]},"FCC TV":{"BT.709 TV":[1.0874,.097509,-.012742,-.073666,.849372,-.025058,-.013734,.053119,1.0378,0,0,0],"BT.709 PC":[.949324,.079773,-.017075,-.076279,.734546,-.033581,-.014221,.044505,.909479,.062745,.062745,.062745],"BT.601 TV":[1.001,932e-6,.001348,-843e-6,1.005025,.002652,-157e-6,-.005957,.996,0,0,0],"BT.601 PC":[.873427,-.005063,-.004698,-.012309,.871277,-.009239,-.002295,-.00739,.872761,.062745,.062745,.062745],"BT.2020 TV":[1.0373,.042057,-.01709,-.031439,.885327,-.03361,-.005861,.072615,1.0507,0,0,0],"BT.2020 PC":[.905315,.031062,-.020895,-.039185,.766131,-.041093,-.007306,.061631,.920811,.062745,.062745,.062745]},"FCC PC":{"BT.709 TV":[1.245686,.118801,-.006708,-.068526,.982253,-.013192,-.012776,.063329,1.184283,-.073059,-.073059,-.073059],"BT.709 PC":[1.0874,.097509,-.012742,-.073666,.849372,-.025058,-.013734,.053119,1.0378,0,0,0],"BT.601 TV":[1.147328,.008859,.009332,.014375,1.159448,.018353,.00268,-.003923,1.136698,-.073059,-.073059,-.073059],"BT.601 PC":[1.001,932e-6,.001348,-843e-6,1.005025,.002652,-157e-6,-.005957,.996,0,0,0],"BT.2020 TV":[1.188652,.055675,-.011658,-.020455,1.023185,-.022927,-.003814,.085524,1.198968,-.073059,-.073059,-.073059],"BT.2020 PC":[1.0373,.042057,-.01709,-.031439,.885327,-.03361,-.005861,.072615,1.0507,0,0,0]},"SMPTE240M TV":{"BT.709 TV":[.9994,-314e-6,-.003437,534e-6,.981134,-.011363,66e-6,.01918,1.0148,0,0,0],"BT.709 PC":[.873747,-.004432,-.007176,-.013276,.848114,-.023727,-.001648,.015142,.889726,.062745,.062745,.062745],"BT.601 TV":[.913,-.105114,.006269,.077395,1.150759,.020731,.009605,-.045646,.973,0,0,0],"BT.601 PC":[.797851,-.096492,.00135,.054241,.997118,.004465,.006732,-.041802,.853008,.062745,.062745,.062745],"BT.2020 TV":[.9493,-.054572,-.006432,.045102,1.018308,-.021268,.005598,.036264,1.0277,0,0,0],"BT.2020 PC":[.829738,-.052094,-.009807,.025874,.880769,-.032428,.003211,.030149,.901058,.062745,.062745,.062745]},"SMPTE240M PC":{"BT.709 TV":[1.14322,.005153,.001598,.018827,1.135135,.005283,.002337,.024095,1.157502,-.073059,-.073059,-.073059],"BT.709 PC":[.9994,-314e-6,-.003437,534e-6,.981134,-.011363,66e-6,.01918,1.0148,0,0,0],"BT.601 TV":[1.044863,-.114151,.012647,.106325,1.328236,.041819,.013196,-.049701,1.109917,-.073059,-.073059,-.073059],"BT.601 PC":[.913,-.105114,.006269,.077395,1.150759,.020731,.009605,-.045646,.973,0,0,0],"BT.2020 TV":[1.086186,-.056614,-.001812,.069564,1.177454,-.005992,.008633,.043544,1.172188,-.073059,-.073059,-.073059],"BT.2020 PC":[.9493,-.054572,-.006432,.045102,1.018308,-.021268,.005598,.036264,1.0277,0,0,0]}};function F(e,t,n,r,i,a){let o=i-n+1,s=e.length;for(let n=0;n<s;n++){let i=e[n],c=i.x+t;if(c>r)break;if(i.y>=o)continue;let l=i.y;for(let t=n+1;t<s;t++){let n=e[t];if(n.x>=c||n.y>l&&(l=n.y,l>=o))break}l<o&&(o=l,a.index=n,a.y=l)}return o<=i-n}function I(e,{index:t,y:n},r,i){let a=e[t].x,o=a+r,s=n+i,c=t;for(;c<e.length&&e[c].x+e[c].w<=o;)c++;if(c<e.length&&e[c].x<o){let t=e[c];t.w-=o-t.x,t.x=o}return e.splice(t,c-t,{x:a,y:s,w:r}),t+1<e.length&&e[t+1].y===s&&(e[t].w+=e[t+1].w,e.splice(t+1,1)),t>0&&e[t-1].y===s&&(e[t-1].w+=e[t].w,e.splice(t,1)),a}var L=class{canvas;_scheduledResize;colorMatrix=P;constructor(e){this.canvas=e}static isSupported(e){try{return new this(e)}catch{}}resizeCanvas(e,t){this._scheduledResize=!e||!t||this.canvas.width===e&&this.canvas.height===t?void 0:{width:e,height:t}}applyScheduledResize(){if(!this._scheduledResize)return;let e=this._scheduledResize;return this._scheduledResize=void 0,this.canvas.width=e.width,this.canvas.height=e.height,e}packAtlas(e,t,n=0,r=!1,i=t){let a=/* @__PURE__ */ new Map,o=[],s={index:0,y:0};t+=n,i+=n;for(let c of e){let{img:e,sourceKey:l}=c,u=l&&a.get(l);if(u){c.x=u.x,c.y=u.y,c.layer=u.layer;continue}let d=(c.packW??e.w)+n,f=e.h+n,p=r?0:Math.max(0,o.length-1);for(;p<o.length&&!F(o[p],d,f,t,i,s);)p++;p===o.length&&(o.push([{x:0,y:0,w:t}]),r||a.clear(),s.index=0,s.y=0),c.x=I(o[p],s,d,f),c.y=s.y,c.layer=p,l&&a.set(l,c)}return o.length}destroy(){}};const R=e=>e<0?0:e>1?255:Math.round(e*255),z={alpha:!0,desynchronized:!0,willReadFrequently:!1},B=1024;var oe=class extends L{ctx;bufferCtx;bufferCanvas=new OffscreenCanvas(B,B);colorTable=/* @__PURE__ */ new Uint32Array(256);pagePixels=new Uint32Array(B*B);pageImageData=new ImageData(new Uint8ClampedArray(this.pagePixels.buffer),B,B);constructor(e){super(e);let t=e.getContext(`2d`,z),n=this.bufferCanvas.getContext(`2d`,z);if(!t||!n)throw Error(`Could not get 2D context`);this.ctx=t,this.bufferCtx=n,this.ctx.imageSmoothingEnabled=!1}setColorConversion(e){this.colorMatrix=e}render(e,t){this.applyScheduledResize()&&(this.ctx.imageSmoothingEnabled=!1),this.ctx.clearRect(0,0,this.canvas.width,this.canvas.height);let n=[],r=0,i=0;for(let t of e)n.push({img:t,sourceKey:0,x:0,y:0,layer:0}),r=Math.max(r,t.w),i=Math.max(i,t.h);let a=this.bufferCanvas;(r>a.width||i>a.height)&&(r>a.width&&(a.width=r),i>a.height&&(a.height=i),this.pagePixels=new Uint32Array(a.width*a.height),this.pageImageData=new ImageData(new Uint8ClampedArray(this.pagePixels.buffer),a.width,a.height));let{width:o,height:s}=a,c=this.pagePixels,l=this.colorTable,u=self.HEAPU32RAW,d=this.colorMatrix,f=this.packAtlas(n,o,0,!1,s);for(let e=0,r=0;e<f;e++){let i=r,s=0,f=0;for(;i<n.length&&n[i].layer===e;i++){let{img:e,x:r,y:a}=n[i],{w:p,h:m,stride:h}=e,g=(e.color>>>24&255)/255,_=(e.color>>>16&255)/255,v=(e.color>>>8&255)/255,y=R(d[0]*g+d[3]*_+d[6]*v+d[9]),b=R(d[1]*g+d[4]*_+d[7]*v+d[10]),x=R(d[2]*g+d[5]*_+d[8]*v+d[11])<<16|b<<8|y,S=(255-(e.color&255))/255;for(let e=1;e<256;e++)l[e]=Math.round(S*e)<<24|x;let C=a*o+r;for(let n=0,r=e.bitmap,i=C;n<m;n++,r+=h,i+=o){let e=Math.min(-r&3,p),n=e+(p-e&-4);for(let n=0;n<e;n++)c[i+n]=l[t[r+n]];for(let t=r+e>>>2,a=r+n>>>2,o=i+e;t<a;t++,o+=4){let e=u[t];c[o]=l[e&255],c[o+1]=l[e>>>8&255],c[o+2]=l[e>>>16&255],c[o+3]=l[e>>>24]}for(let e=n;e<p;e++)c[i+e]=l[t[r+e]]}s=Math.max(s,r+p),f=Math.max(f,a+m)}this.bufferCtx.putImageData(this.pageImageData,0,0,0,0,s,f);for(let e=r;e<i;e++){let{img:t,x:r,y:i}=n[e];this.ctx.drawImage(a,r,i,t.w,t.h,t.dst_x,t.dst_y,t.w,t.h)}r=i}}destroy(){this.ctx=this.bufferCtx=this.bufferCanvas=null}};function V(e,t,n){return(n*16384+t)*16384+e}var H=class extends L{gl;program;u_resolution=null;u_colorMatrix=null;u_colorOffset=null;ctrl=new AbortController;constructor(e){super(e),e.addEventListener(`webglcontextlost`,e=>{e.preventDefault(),this.gl=null},this.ctrl),e.addEventListener(`webglcontextrestored`,()=>this._initGL(),this.ctrl)}createProgram(e,t){let n=this.createShader(this.gl.VERTEX_SHADER,e),r=this.createShader(this.gl.FRAGMENT_SHADER,t),i=this.gl.createProgram();if(!i)throw Error(`Failed to create program`);if(this.gl.attachShader(i,n),this.gl.attachShader(i,r),this.gl.linkProgram(i),!this.gl.getProgramParameter(i,this.gl.LINK_STATUS)){let e=this.gl.getProgramInfoLog(i);throw this.gl.deleteProgram(i),Error(`Failed to link program: `+e)}this.gl.deleteShader(n),this.gl.deleteShader(r),this.program=i}createShader(e,t){let n=this.gl.createShader(e);if(!n)throw Error(`Failed to create shader`);if(this.gl.shaderSource(n,t),this.gl.compileShader(n),!this.gl.getShaderParameter(n,this.gl.COMPILE_STATUS)){let e=this.gl.getShaderInfoLog(n);throw this.gl.deleteShader(n),Error(`Failed to compile shader: `+e)}return n}setColorConversion(e){this.colorMatrix=e,this.gl&&(this.gl.uniformMatrix3fv(this.u_colorMatrix,!1,e.subarray(0,9)),this.gl.uniform3fv(this.u_colorOffset,e.subarray(9)))}beginFrame(e){let t=this.applyScheduledResize();return t&&(this.gl.viewport(0,0,t.width,t.height),this.gl.uniform2f(this.u_resolution,t.width,t.height)),this.gl.clear(this.gl.COLOR_BUFFER_BIT),e.length!==0||(this.gl.flush(),!1)}applyCommonState(e){this.gl.enable(this.gl.BLEND),this.gl.blendFunc(this.gl.ONE,this.gl.ONE_MINUS_SRC_ALPHA),this.gl.useProgram(this.program),this.gl.uniform1i(e,0),this.setColorConversion(this.colorMatrix),this.gl.pixelStorei(this.gl.UNPACK_ALIGNMENT,1),this.gl.clearColor(0,0,0,0),this.gl.activeTexture(this.gl.TEXTURE0),this.gl.viewport(0,0,this.canvas.width,this.canvas.height),this.gl.uniform2f(this.u_resolution,this.canvas.width,this.canvas.height)}};const U=new Float32Array([0,0,1,0,0,1,1,0,1,1,0,1]);var W=class extends H{maxAtlasSize=0;atlasPadding=0;instancedArraysExt=null;u_tex=null;u_atlasSize=null;a_quadPos=-1;a_destRect=-1;a_srcXY=-1;a_color=-1;quadPosBuffer;instanceBuffer;instanceData=/* @__PURE__ */ new Float32Array;instanceCapacity=0;instanceStride=0;atlasPages=[];atlasFullAt=0;atlasSize=0;maxTextureSize=0;uploadCache=/* @__PURE__ */ new Map;copyData=/* @__PURE__ */ new Uint8Array;constructor(e){super(e);try{this._initGL()}catch(e){throw this.destroy(),e}}_initGL(){let e=this.canvas.getContext(`webgl`,{alpha:!0,premultipliedAlpha:!0,antialias:!1,depth:!1,preserveDrawingBuffer:!1,stencil:!1,desynchronized:!0,powerPreference:`default`});if(!e)throw Error(`Could not get WebGL context`);this.gl=e;let t=!!e.getShaderPrecisionFormat(e.FRAGMENT_SHADER,e.HIGH_FLOAT)?.precision;this.atlasPages=[],this.atlasSize=0,this.uploadCache.clear(),this.maxTextureSize=e.getParameter(e.MAX_TEXTURE_SIZE),this.instancedArraysExt=this.gl.getExtension(`ANGLE_instanced_arrays`),this.createProgram(`
|
|
1
|
+
const e={RAW:`RAW`,PROXY:`PROXY`,THROW:`THROW`,HANDLER:`HANDLER`},t={GET:`GET`,SET:`SET`,APPLY:`APPLY`,CONSTRUCT:`CONSTRUCT`,RELEASE:`RELEASE`},n=Symbol(`Abslink.proxy`),r=Symbol(`Abslink.releaseProxy`),i=Symbol(`Abslink.finalizer`),a=Symbol(`Abslink.thrown`),o=e=>typeof e==`object`&&!!e||typeof e==`function`,s=/* @__PURE__ */ new Map([[`proxy`,{canHandle:e=>o(e)&&n in e,serialize(e,t){let r=e[n];return l(e,t,r),[r,[]]},deserialize(e,t){return u(t,e)}}],[`throw`,{canHandle:e=>o(e)&&a in e,serialize({value:e}){let t;return t=e instanceof Error?{isError:!0,value:{message:e.message,name:e.name,stack:e.stack}}:{isError:!1,value:e},[t,[]]},deserialize(e){throw e.isError?Object.assign(Error(e.value.message),e.value):e.value}}]]);function c(e,t){let n=t,r=e.slice(0,-1);for(let e of r)Object.prototype.hasOwnProperty.call(n,e)&&(n=n[e]);let i=e[e.length-1],a=i?n[i]:n;return{parent:n,RawValue:a,lastSegment:i}}function l(e,n,r){return n.on(`message`,function s(l){if(!l)return;let{id:u,type:d,path:f,markerID:p}={path:[],...l};if(p!==r)return;let m=(l.argumentList??[]).map(e=>S(e,n)),h;try{let{parent:r,RawValue:i,lastSegment:a}=c(f,e);switch(d){case t.GET:h=i;break;case t.SET:r[a]=S(l.value,n),h=!0;break;case t.APPLY:h=i.apply(r,m);break;case t.CONSTRUCT:h=new i(...m);break;case t.RELEASE:h=void 0;break;default:return}}catch(e){h={value:e,[a]:0}}Promise.resolve(h).catch(e=>({value:e,[a]:0})).then(c=>{d===t.CONSTRUCT&&!(o(c)&&a in c)&&(c=b(c));let[l,f]=x(c,n);n.postMessage({...l,id:u,markerID:r},f),d===t.RELEASE&&(n.off(`message`,s),e[i]?.())}).catch(e=>{let[t,i]=x({value:/* @__PURE__ */ TypeError(`Unserializable return value`),[a]:0},n);n.postMessage({...t,id:u,markerID:r},i)})}),e}function u(e,t){let n=/* @__PURE__ */ new Map;return e.on(`message`,e=>{if(!e?.id)return;let t=n.get(e.id);if(t)try{t(e)}finally{n.delete(e.id)}}),_({endpoint:e,pendingListeners:n,rootMarkerID:t})}function d(e){if(e)throw Error(`Proxy has been released and is not useable`)}async function f(e){await C(e,{type:t.RELEASE})}const p=/* @__PURE__ */ new WeakMap,m=`FinalizationRegistry`in globalThis&&new FinalizationRegistry(e=>{let t=(p.get(e)??0)-1;p.set(e,t),t===0&&f(e).finally(()=>{e.pendingListeners.clear()})});function h(e,t){let n=(p.get(t)??0)+1;p.set(t,n),m&&m.register(e,t,e)}function g(e){m&&m.unregister(e)}function _(e,n=[]){let i=!1,a=/* @__PURE__ */ new Map,o=new Proxy(function(){},{get(s,c){if(d(i),c===r)return async()=>{for(let e of a.values())e[r]();a.clear(),g(o),f(e).finally(()=>{e.pendingListeners.clear()}),i=!0};if(c===`then`){if(n.length===0)return{then:()=>o};let r=C(e,{type:t.GET,path:n.map(e=>e.toString())}).then(t=>S(t,e.endpoint));return r.then.bind(r)}let l=a.get(c);if(l)return l;let u=_(e,[...n,c]);return a.set(c,u),u},set(r,a,o){d(i);let[s,c]=x(o,e.endpoint);return C(e,{type:t.SET,path:[...n,a].map(e=>e.toString()),value:s},c).then(t=>S(t,e.endpoint))},apply(r,a,o){if(d(i),n[n.length-1]===`bind`)return _(e,n.slice(0,-1));let[s,c]=y(o,e);return C(e,{type:t.APPLY,path:n.map(e=>e.toString()),argumentList:s},c).then(t=>S(t,e.endpoint))},construct(r,a){d(i);let[o,s]=y(a,e);return C(e,{type:t.CONSTRUCT,path:n.map(e=>e.toString()),argumentList:o},s).then(t=>S(t,e.endpoint))}});return h(o,e),o}const v=/* @__PURE__ */ new WeakMap;function y(e,t){let n=[],r=[];for(let i of e){let[e,a]=x(i,t.endpoint);n.push(e),r.push(...a)}return[n,r]}function b(e){return Object.assign(e,{[n]:O()})}function x(t,n){for(let[r,i]of s)if(i.canHandle(t)){let[a,o]=i.serialize(t,n);return[{type:e.HANDLER,name:r,value:a},o]}return[{type:e.RAW,value:t},v.get(t)??[]]}function S(t,n){switch(t.type){case e.HANDLER:return s.get(t.name).deserialize(t.value,n);case e.RAW:return t.value}}function C(e,t,n=[]){return new Promise(r=>{let i=O();e.pendingListeners.set(i,r),e.endpoint.postMessage({id:i,...t,markerID:e.rootMarkerID},n)})}const w=[],T=`0123456789abcdef`;for(let e=0;e<256;e++)w[e]=T[e>>4&15]+T[e&15];let E=0,D=``;function O(){let e=0;if(!D||E+16>512)for(D=``,E=0;e<256;++e)D+=w[Math.random()*256|0];return D.substring(E,++E+16)}function k(e,t){let n=/* @__PURE__ */ new WeakMap;return e.start?.(),t.start?.(),{on(t,r){let i=e=>r(e.data);`addEventListener`in e?e.addEventListener(t,i):`addListener`in e?e.addListener(t,i):e.on(t,i),n.set(r,i)},off(t,r){let i=n.get(r);`removeEventListener`in e?e.removeEventListener(t,i):`removeListener`in e?e.removeListener(t,i):e.off(t,i),n.delete(r)},postMessage(e,n=[]){t.postMessage(e,n)}}}function ee(e,t=globalThis,n=t){return l(e,k(t,n))}`queryLocalFonts`in globalThis&&globalThis.queryLocalFonts;const A={100:`Thin`,200:`ExtraLight`,300:`Light`,400:`Regular`,500:`Medium`,600:`SemiBold`,700:`Bold`,800:`ExtraBold`,900:`Black`,1e3:`UltraBlack`};var j=class{family;fullName;postscriptName;style;#e;#t;constructor({family:e,weight:t,isItalic:n,weightName:r}){this.family=e,this.#e=t,this.#t=n,this.style=r===`Regular`?n?`Italic`:`Regular`:r+(n?` Italic`:``),this.fullName=this.style===`Regular`?e:`${e} ${this.style}`,this.postscriptName=this.fullName.replace(/ /g,`-`)}async blob(){let e=await(await fetch(`https://fonts.googleapis.com/css2?family=${this.family}:${this.#t?`ital,`:``}wght@${this.#t?`1,`:``}${this.#e}`)).text();for(let t of[/\/\* latin-ext \*\/[\s\S]+url\(([^)]+)\)/,/\/\* latin \*\/[\s\S]+url\(([^)]+)\)/,/url\(([^)]+)\)/]){let n=e.match(t)?.[1];if(n){let e=await fetch(n);if(e.ok)return e.blob()}}throw Error(`Failed to load font blob`)}};function M([e,t]){let n=[];for(let r of t){let t=``+r,i=t.endsWith(`i`),a=t.replace(`i`,``);if(a.includes(`a`)){let[t,r]=a.split(`a`).map(e=>parseInt(e)*100);for(let a=t;a<=r;a+=100)n.push(new j({family:e,weight:`${t}..${r}`,isItalic:i,weightName:A[a]}))}else n.push(new j({family:e,weight:`${a}00`,isItalic:i,weightName:A[parseInt(a)*100]}))}return n}let N=/* @__PURE__ */ new Map;async function te(){if(N.size===0){let e=await import(`./fonts.js`);for(let t of e.default.flatMap(e=>M(e)))N.set(t.postscriptName.toLowerCase().replace(/-/g,``),t)}return N}async function ne({postscriptNames:e}={}){let t=await te();return e?e.length===0?[]:e.reduce((e,n)=>{let r=t.get(n.toLowerCase().replace(/regular$/,``).replace(/-reg$/,``).replace(/[- ]/g,``));return r&&e.push(r),e},[]):[...t.values()]}const re=[`BT.601 TV`,void 0,void 0,`BT.601 TV`,`BT.601 PC`,`BT.709 TV`,`BT.709 PC`,`SMPTE240M TV`,`SMPTE240M PC`,`FCC TV`,`FCC PC`],ie={bt709:`BT.709`,bt470bg:`BT.601`,smpte170m:`BT.601`,"bt2020-ncl":`BT.2020`},P=new Float32Array([1,0,0,0,1,0,0,0,1,0,0,0]),ae={"BT.601 TV":{"BT.709 TV":[1.0864,.096546,-.014106,-.072349,.845052,-.027694,-.014051,.058402,1.0418,0,0,0],"BT.709 PC":[.948465,.078946,-.018254,-.075064,.73081,-.035837,-.014578,.049067,.912915,.062745,.062745,.062745],"BT.601 PC":[.872569,-.005863,-.005863,-.01151,.866922,-.01151,-.002235,-.002235,.876196,.062745,.062745,.062745],"BT.2020 TV":[1.0363,.041089,-.01846,-.030397,.880729,-.03624,-.005903,.078182,1.0547,0,0,0],"BT.2020 PC":[.904456,.030232,-.022078,-.038211,.76215,-.043344,-.007421,.066442,.924246,.062745,.062745,.062745]},"BT.601 PC":{"BT.709 TV":[1.244521,.117679,-.008287,-.067105,.977257,-.01627,-.013032,.069448,1.188941,-.073059,-.073059,-.073059],"BT.709 PC":[1.0864,.096546,-.014106,-.072349,.845052,-.027694,-.014051,.058402,1.0418,0,0,0],"BT.601 TV":[1.146164,.007771,.007771,.015257,1.153649,.015257,.002963,.002963,1.141356,-.073059,-.073059,-.073059],"BT.2020 TV":[1.187488,.054547,-.013243,-.019347,1.017872,-.025999,-.003757,.091964,1.203626,-.073059,-.073059,-.073059],"BT.2020 PC":[1.0363,.041089,-.01846,-.030397,.880729,-.03624,-.005903,.078182,1.0547,0,0,0]},"BT.709 TV":{"BT.709 PC":[.874263,-.004169,-.004169,-.014024,.864408,-.014024,-.001416,-.001416,.877016,.062745,.062745,.062745],"BT.601 TV":[.9136,-.10504,.009578,.078478,1.172167,.032222,.007922,-.067127,.9582,0,0,0],"BT.601 PC":[.798366,-.096439,.004245,.054914,1.015645,.014281,.005544,-.060382,.840297,.062745,.062745,.062745],"BT.2020 TV":[.9499,-.054223,-.002956,.045506,1.038105,-.009944,.004594,.016118,1.0129,0,0,0],"BT.2020 PC":[.830253,-.0518,-.006765,.02595,.897881,-.022759,.00262,.012743,.888347,.062745,.062745,.062745]},"BT.709 PC":{"BT.709 TV":[1.143918,.005526,.005526,.018589,1.156981,.018589,.001877,.001877,1.140269,-.073059,-.073059,-.073059],"BT.601 TV":[1.045561,-.114051,.016429,.107927,1.352975,.05527,.010895,-.07454,1.092685,-.073059,-.073059,-.073059],"BT.601 PC":[.9136,-.10504,.009578,.078478,1.172167,.032222,.007922,-.067127,.9582,0,0,0],"BT.2020 TV":[1.086885,-.056202,.002161,.070392,1.20036,.007268,.007106,.020226,1.154955,-.073059,-.073059,-.073059],"BT.2020 PC":[.9499,-.054223,-.002956,.045506,1.038105,-.009944,.004594,.016118,1.0129,0,0,0]},"BT.2020 TV":{"BT.709 TV":[1.0501,.054794,.003602,-.046071,.960743,.009298,-.004029,-.015537,.9871,0,0,0],"BT.709 PC":[.91729,.042982,-.001986,-.053764,.830653,-.005127,-.004702,-.014811,.865937,.062745,.062745,.062745],"BT.601 TV":[.9637,-.046316,.015276,.03338,1.130366,.039424,.00292,-.08405,.9453,0,0,0],"BT.601 PC":[.841393,-.045837,.008268,.016028,.979655,.021338,.001402,-.074995,.829218,.062745,.062745,.062745],"BT.2020 PC":[.87328,-.005151,-.005151,-.013294,.865137,-.013294,-.001163,-.001163,.877269,.062745,.062745,.062745]},"BT.2020 PC":{"BT.709 TV":[1.202254,.069205,.010929,-.034825,1.111325,.028206,-.003046,-.016146,1.125249,-.073059,-.073059,-.073059],"BT.709 PC":[1.0501,.054794,.003602,-.046071,.960743,.009298,-.004029,-.015537,.9871,0,0,0],"BT.601 TV":[1.103897,-.045898,.024217,.055622,1.304422,.062502,.004865,-.09414,1.077664,-.073059,-.073059,-.073059],"BT.601 PC":[.9637,-.046316,.015276,.03338,1.130366,.039424,.00292,-.08405,.9453,0,0,0],"BT.2020 TV":[1.145221,.006828,.006828,.017622,1.156015,.017622,.001541,.001541,1.139934,-.073059,-.073059,-.073059]},"FCC TV":{"BT.709 TV":[1.0874,.097509,-.012742,-.073666,.849372,-.025058,-.013734,.053119,1.0378,0,0,0],"BT.709 PC":[.949324,.079773,-.017075,-.076279,.734546,-.033581,-.014221,.044505,.909479,.062745,.062745,.062745],"BT.601 TV":[1.001,932e-6,.001348,-843e-6,1.005025,.002652,-157e-6,-.005957,.996,0,0,0],"BT.601 PC":[.873427,-.005063,-.004698,-.012309,.871277,-.009239,-.002295,-.00739,.872761,.062745,.062745,.062745],"BT.2020 TV":[1.0373,.042057,-.01709,-.031439,.885327,-.03361,-.005861,.072615,1.0507,0,0,0],"BT.2020 PC":[.905315,.031062,-.020895,-.039185,.766131,-.041093,-.007306,.061631,.920811,.062745,.062745,.062745]},"FCC PC":{"BT.709 TV":[1.245686,.118801,-.006708,-.068526,.982253,-.013192,-.012776,.063329,1.184283,-.073059,-.073059,-.073059],"BT.709 PC":[1.0874,.097509,-.012742,-.073666,.849372,-.025058,-.013734,.053119,1.0378,0,0,0],"BT.601 TV":[1.147328,.008859,.009332,.014375,1.159448,.018353,.00268,-.003923,1.136698,-.073059,-.073059,-.073059],"BT.601 PC":[1.001,932e-6,.001348,-843e-6,1.005025,.002652,-157e-6,-.005957,.996,0,0,0],"BT.2020 TV":[1.188652,.055675,-.011658,-.020455,1.023185,-.022927,-.003814,.085524,1.198968,-.073059,-.073059,-.073059],"BT.2020 PC":[1.0373,.042057,-.01709,-.031439,.885327,-.03361,-.005861,.072615,1.0507,0,0,0]},"SMPTE240M TV":{"BT.709 TV":[.9994,-314e-6,-.003437,534e-6,.981134,-.011363,66e-6,.01918,1.0148,0,0,0],"BT.709 PC":[.873747,-.004432,-.007176,-.013276,.848114,-.023727,-.001648,.015142,.889726,.062745,.062745,.062745],"BT.601 TV":[.913,-.105114,.006269,.077395,1.150759,.020731,.009605,-.045646,.973,0,0,0],"BT.601 PC":[.797851,-.096492,.00135,.054241,.997118,.004465,.006732,-.041802,.853008,.062745,.062745,.062745],"BT.2020 TV":[.9493,-.054572,-.006432,.045102,1.018308,-.021268,.005598,.036264,1.0277,0,0,0],"BT.2020 PC":[.829738,-.052094,-.009807,.025874,.880769,-.032428,.003211,.030149,.901058,.062745,.062745,.062745]},"SMPTE240M PC":{"BT.709 TV":[1.14322,.005153,.001598,.018827,1.135135,.005283,.002337,.024095,1.157502,-.073059,-.073059,-.073059],"BT.709 PC":[.9994,-314e-6,-.003437,534e-6,.981134,-.011363,66e-6,.01918,1.0148,0,0,0],"BT.601 TV":[1.044863,-.114151,.012647,.106325,1.328236,.041819,.013196,-.049701,1.109917,-.073059,-.073059,-.073059],"BT.601 PC":[.913,-.105114,.006269,.077395,1.150759,.020731,.009605,-.045646,.973,0,0,0],"BT.2020 TV":[1.086186,-.056614,-.001812,.069564,1.177454,-.005992,.008633,.043544,1.172188,-.073059,-.073059,-.073059],"BT.2020 PC":[.9493,-.054572,-.006432,.045102,1.018308,-.021268,.005598,.036264,1.0277,0,0,0]}};function F(e,t,n,r,i,a){let o=i-n+1,s=e.length;for(let n=0;n<s;n++){let i=e[n],c=i.x+t;if(c>r)break;if(i.y>=o)continue;let l=i.y;for(let t=n+1;t<s;t++){let n=e[t];if(n.x>=c||n.y>l&&(l=n.y,l>=o))break}l<o&&(o=l,a.index=n,a.y=l)}return o<=i-n}function I(e,{index:t,y:n},r,i){let a=e[t].x,o=a+r,s=n+i,c=t;for(;c<e.length&&e[c].x+e[c].w<=o;)c++;if(c<e.length&&e[c].x<o){let t=e[c];t.w-=o-t.x,t.x=o}return e.splice(t,c-t,{x:a,y:s,w:r}),t+1<e.length&&e[t+1].y===s&&(e[t].w+=e[t+1].w,e.splice(t+1,1)),t>0&&e[t-1].y===s&&(e[t-1].w+=e[t].w,e.splice(t,1)),a}var L=class{canvas;_scheduledResize;colorMatrix=P;constructor(e){this.canvas=e}static isSupported(e){try{return new this(e)}catch{}}resizeCanvas(e,t){this._scheduledResize=!e||!t||this.canvas.width===e&&this.canvas.height===t?void 0:{width:e,height:t}}applyScheduledResize(){if(!this._scheduledResize)return;let e=this._scheduledResize;return this._scheduledResize=void 0,this.canvas.width=e.width,this.canvas.height=e.height,e}packAtlas(e,t,n=0,r=!1,i=t){let a=/* @__PURE__ */ new Map,o=[],s={index:0,y:0};t+=n,i+=n;for(let c of e){let{img:e,sourceKey:l}=c,u=l&&a.get(l);if(u){c.x=u.x,c.y=u.y,c.layer=u.layer;continue}let d=(c.packW??e.w)+n,f=e.h+n,p=r?0:Math.max(0,o.length-1);for(;p<o.length&&!F(o[p],d,f,t,i,s);)p++;p===o.length&&(o.push([{x:0,y:0,w:t}]),r||a.clear(),s.index=0,s.y=0),c.x=I(o[p],s,d,f),c.y=s.y,c.layer=p,l&&a.set(l,c)}return o.length}destroy(){}};const R=e=>e<0?0:e>1?255:Math.round(e*255),z={alpha:!0,desynchronized:!1,willReadFrequently:!1},B=1024;var oe=class extends L{ctx;bufferCtx;bufferCanvas=new OffscreenCanvas(B,B);colorTable=/* @__PURE__ */ new Uint32Array(256);pagePixels=new Uint32Array(B*B);pageImageData=new ImageData(new Uint8ClampedArray(this.pagePixels.buffer),B,B);constructor(e){super(e);let t=e.getContext(`2d`,z),n=this.bufferCanvas.getContext(`2d`,z);if(!t||!n)throw Error(`Could not get 2D context`);this.ctx=t,this.bufferCtx=n,this.ctx.imageSmoothingEnabled=!1}setColorConversion(e){this.colorMatrix=e}render(e,t){this.applyScheduledResize()&&(this.ctx.imageSmoothingEnabled=!1),this.ctx.clearRect(0,0,this.canvas.width,this.canvas.height);let n=[],r=0,i=0;for(let t of e)n.push({img:t,sourceKey:0,x:0,y:0,layer:0}),r=Math.max(r,t.w),i=Math.max(i,t.h);let a=this.bufferCanvas;(r>a.width||i>a.height)&&(r>a.width&&(a.width=r),i>a.height&&(a.height=i),this.pagePixels=new Uint32Array(a.width*a.height),this.pageImageData=new ImageData(new Uint8ClampedArray(this.pagePixels.buffer),a.width,a.height));let{width:o,height:s}=a,c=this.pagePixels,l=this.colorTable,u=self.HEAPU32RAW,d=this.colorMatrix,f=this.packAtlas(n,o,0,!1,s);for(let e=0,r=0;e<f;e++){let i=r,s=0,f=0;for(;i<n.length&&n[i].layer===e;i++){let{img:e,x:r,y:a}=n[i],{w:p,h:m,stride:h}=e,g=(e.color>>>24&255)/255,_=(e.color>>>16&255)/255,v=(e.color>>>8&255)/255,y=R(d[0]*g+d[3]*_+d[6]*v+d[9]),b=R(d[1]*g+d[4]*_+d[7]*v+d[10]),x=R(d[2]*g+d[5]*_+d[8]*v+d[11])<<16|b<<8|y,S=(255-(e.color&255))/255;for(let e=1;e<256;e++)l[e]=Math.round(S*e)<<24|x;let C=a*o+r;for(let n=0,r=e.bitmap,i=C;n<m;n++,r+=h,i+=o){let e=Math.min(-r&3,p),n=e+(p-e&-4);for(let n=0;n<e;n++)c[i+n]=l[t[r+n]];for(let t=r+e>>>2,a=r+n>>>2,o=i+e;t<a;t++,o+=4){let e=u[t];c[o]=l[e&255],c[o+1]=l[e>>>8&255],c[o+2]=l[e>>>16&255],c[o+3]=l[e>>>24]}for(let e=n;e<p;e++)c[i+e]=l[t[r+e]]}s=Math.max(s,r+p),f=Math.max(f,a+m)}this.bufferCtx.putImageData(this.pageImageData,0,0,0,0,s,f);for(let e=r;e<i;e++){let{img:t,x:r,y:i}=n[e];this.ctx.drawImage(a,r,i,t.w,t.h,t.dst_x,t.dst_y,t.w,t.h)}r=i}}destroy(){this.ctx=this.bufferCtx=this.bufferCanvas=null}};function V(e,t,n){return(n*16384+t)*16384+e}var H=class extends L{gl;program;u_resolution=null;u_colorMatrix=null;u_colorOffset=null;ctrl=new AbortController;constructor(e){super(e),e.addEventListener(`webglcontextlost`,e=>{e.preventDefault(),this.gl=null},this.ctrl),e.addEventListener(`webglcontextrestored`,()=>this._initGL(),this.ctrl)}createProgram(e,t){let n=this.createShader(this.gl.VERTEX_SHADER,e),r=this.createShader(this.gl.FRAGMENT_SHADER,t),i=this.gl.createProgram();if(!i)throw Error(`Failed to create program`);if(this.gl.attachShader(i,n),this.gl.attachShader(i,r),this.gl.linkProgram(i),!this.gl.getProgramParameter(i,this.gl.LINK_STATUS)){let e=this.gl.getProgramInfoLog(i);throw this.gl.deleteProgram(i),Error(`Failed to link program: `+e)}this.gl.deleteShader(n),this.gl.deleteShader(r),this.program=i}createShader(e,t){let n=this.gl.createShader(e);if(!n)throw Error(`Failed to create shader`);if(this.gl.shaderSource(n,t),this.gl.compileShader(n),!this.gl.getShaderParameter(n,this.gl.COMPILE_STATUS)){let e=this.gl.getShaderInfoLog(n);throw this.gl.deleteShader(n),Error(`Failed to compile shader: `+e)}return n}setColorConversion(e){this.colorMatrix=e,this.gl&&(this.gl.uniformMatrix3fv(this.u_colorMatrix,!1,e.subarray(0,9)),this.gl.uniform3fv(this.u_colorOffset,e.subarray(9)))}beginFrame(e){let t=this.applyScheduledResize();return t&&(this.gl.viewport(0,0,t.width,t.height),this.gl.uniform2f(this.u_resolution,t.width,t.height)),this.gl.clear(this.gl.COLOR_BUFFER_BIT),e.length!==0||(this.gl.flush(),!1)}applyCommonState(e){this.gl.enable(this.gl.BLEND),this.gl.blendFunc(this.gl.ONE,this.gl.ONE_MINUS_SRC_ALPHA),this.gl.useProgram(this.program),this.gl.uniform1i(e,0),this.setColorConversion(this.colorMatrix),this.gl.pixelStorei(this.gl.UNPACK_ALIGNMENT,1),this.gl.clearColor(0,0,0,0),this.gl.activeTexture(this.gl.TEXTURE0),this.gl.viewport(0,0,this.canvas.width,this.canvas.height),this.gl.uniform2f(this.u_resolution,this.canvas.width,this.canvas.height)}};const U=new Float32Array([0,0,1,0,0,1,1,0,1,1,0,1]);var W=class extends H{maxAtlasSize=0;atlasPadding=0;instancedArraysExt=null;u_tex=null;u_atlasSize=null;a_quadPos=-1;a_destRect=-1;a_srcXY=-1;a_color=-1;quadPosBuffer;instanceBuffer;instanceData=/* @__PURE__ */ new Float32Array;instanceCapacity=0;instanceStride=0;atlasPages=[];atlasFullAt=0;atlasSize=0;maxTextureSize=0;uploadCache=/* @__PURE__ */ new Map;copyData=/* @__PURE__ */ new Uint8Array;constructor(e){super(e);try{this._initGL()}catch(e){throw this.destroy(),e}}_initGL(){let e=this.canvas.getContext(`webgl`,{alpha:!0,premultipliedAlpha:!0,antialias:!1,depth:!1,preserveDrawingBuffer:!1,stencil:!1,desynchronized:!1,powerPreference:`default`});if(!e)throw Error(`Could not get WebGL context`);this.gl=e;let t=!!e.getShaderPrecisionFormat(e.FRAGMENT_SHADER,e.HIGH_FLOAT)?.precision;this.atlasPages=[],this.atlasSize=0,this.uploadCache.clear(),this.maxTextureSize=e.getParameter(e.MAX_TEXTURE_SIZE),this.instancedArraysExt=this.gl.getExtension(`ANGLE_instanced_arrays`),this.createProgram(`
|
|
2
2
|
precision highp float;
|
|
3
3
|
|
|
4
4
|
// Quad position attribute (0,0), (1,0), (0,1), (1,0), (1,1), (0,1)
|
|
@@ -62,7 +62,7 @@ void main() {
|
|
|
62
62
|
// Premultiplied alpha output
|
|
63
63
|
gl_FragColor = vec4(correctedColor * a, a);
|
|
64
64
|
}
|
|
65
|
-
`);let n=e.getShaderPrecisionFormat(e.FRAGMENT_SHADER,e.MEDIUM_FLOAT)?.precision??10;this.maxAtlasSize=t?Math.min(this.maxTextureSize,2048):Math.min(this.maxTextureSize,2**Math.max(6,n-1)),this.atlasPadding=+!t,this.u_resolution=this.gl.getUniformLocation(this.program,`u_resolution`),this.u_tex=this.gl.getUniformLocation(this.program,`u_tex`),this.u_colorMatrix=this.gl.getUniformLocation(this.program,`u_colorMatrix`),this.u_colorOffset=this.gl.getUniformLocation(this.program,`u_colorOffset`),this.u_atlasSize=this.gl.getUniformLocation(this.program,`u_atlasSize`),this.a_quadPos=this.gl.getAttribLocation(this.program,`a_quadPos`),this.a_destRect=this.gl.getAttribLocation(this.program,`a_destRect`),this.a_srcXY=this.gl.getAttribLocation(this.program,`a_srcXY`),this.a_color=this.gl.getAttribLocation(this.program,`a_color`),this.quadPosBuffer=this.gl.createBuffer(),this.gl.bindBuffer(this.gl.ARRAY_BUFFER,this.quadPosBuffer),this.gl.bufferData(this.gl.ARRAY_BUFFER,U,this.gl.STATIC_DRAW),this.instanceBuffer=this.gl.createBuffer(),this.instanceCapacity=0;let r=this.instancedArraysExt?10:72;this.ensureInstanceCapacity(256,r),this.gl.bindBuffer(this.gl.ARRAY_BUFFER,this.instanceBuffer),this.instancedArraysExt?(this.vertexAttrib(this.a_destRect,4,40,0,1),this.vertexAttrib(this.a_srcXY,2,40,16,1),this.vertexAttrib(this.a_color,4,40,24,1),this.gl.bindBuffer(this.gl.ARRAY_BUFFER,this.quadPosBuffer),this.vertexAttrib(this.a_quadPos,2,0,0)):(this.vertexAttrib(this.a_quadPos,2,48,0),this.vertexAttrib(this.a_destRect,4,48,8),this.vertexAttrib(this.a_srcXY,2,48,24),this.vertexAttrib(this.a_color,4,48,32)),this.applyCommonState(this.u_tex),this.gl.uniform2f(this.u_atlasSize,1,1)}vertexAttrib(e,t,n,r,i=0){this.gl.enableVertexAttribArray(e),this.gl.vertexAttribPointer(e,t,this.gl.FLOAT,!1,n,r),i&&this.instancedArraysExt?.vertexAttribDivisorANGLE(e,i)}ensureInstanceCapacity(e,t){e<=this.instanceCapacity||(this.instanceCapacity=Math.max(e,this.instanceCapacity*2,256),this.instanceStride=t,this.instanceData=new Float32Array(this.instanceCapacity*t),this.gl.bindBuffer(this.gl.ARRAY_BUFFER,this.instanceBuffer),this.gl.bufferData(this.gl.ARRAY_BUFFER,this.instanceData.byteLength,this.gl.DYNAMIC_DRAW))}writeImage(e,t,n,r){let i=this.instanceData;i[e]=t.dst_x,i[e+1]=t.dst_y,i[e+2]=t.w,i[e+3]=t.h,i[e+4]=n,i[e+5]=r,i[e+6]=(t.color>>>24&255)/255,i[e+7]=(t.color>>>16&255)/255,i[e+8]=(t.color>>>8&255)/255,i[e+9]=(t.color&255)/255}createAtlasPage(e){let t=this.gl.createTexture();return this.gl.bindTexture(this.gl.TEXTURE_2D,t),this.gl.texImage2D(this.gl.TEXTURE_2D,0,this.gl.ALPHA,e,e,0,this.gl.ALPHA,this.gl.UNSIGNED_BYTE,null),this.gl.texParameteri(this.gl.TEXTURE_2D,this.gl.TEXTURE_MIN_FILTER,this.gl.NEAREST),this.gl.texParameteri(this.gl.TEXTURE_2D,this.gl.TEXTURE_MAG_FILTER,this.gl.NEAREST),this.gl.texParameteri(this.gl.TEXTURE_2D,this.gl.TEXTURE_WRAP_S,this.gl.CLAMP_TO_EDGE),this.gl.texParameteri(this.gl.TEXTURE_2D,this.gl.TEXTURE_WRAP_T,this.gl.CLAMP_TO_EDGE),t}ensureAtlas(e,t){if(this.atlasSize!==e){for(let e of this.atlasPages)this.gl.deleteTexture(e);this.atlasPages=[],this.atlasSize=e,this.uploadCache.clear()}for(;this.atlasPages.length<t;)this.atlasPages.push(this.createAtlasPage(e));let n=performance.now();if(t===this.atlasPages.length)this.atlasFullAt=n;else if(n-this.atlasFullAt>2e4)for(let e of this.atlasPages.splice(t))this.gl.deleteTexture(e)}render(e,t){if(!this.gl||!this.beginFrame(e))return;let n=[],r=0,i=0;for(let a of e){if(a.w>this.maxTextureSize||a.h>this.maxTextureSize)continue;let e=a.stride>=a.w&&a.stride<=this.maxTextureSize&&a.bitmap+a.stride*a.h<=t.length,o=e?a.stride:a.w;n.push({img:a,packW:o,uploadStrided:e,x:0,y:0,layer:0,sourceKey:a.cache_id&&`${a.cache_id}:${a.bitmap}:${a.w}:${a.h}:${a.stride}`}),r=Math.max(r,o,a.h),i+=o*a.h}if(n.length===0){this.gl.flush();return}let a=Math.max(64,Math.ceil(Math.max(r,Math.ceil(Math.sqrt(i)))/64)*64),o=Math.min(this.maxTextureSize,Math.max(this.atlasSize,a),Math.max(this.maxAtlasSize,r)),s=this.packAtlas(n,o,this.atlasPadding);s>64&&o<this.maxAtlasSize&&(o=this.maxAtlasSize,s=this.packAtlas(n,o,this.atlasPadding));let c=128*this.canvas.width*this.canvas.height;if(s>64||s>1&&o*o*s>c){console.warn(`JASSUB: frame exceeds WebGL1 atlas capacity`),this.gl.flush();return}this.gl.finish(),this.ensureAtlas(o,s),this.ensureInstanceCapacity(n.length,this.instanceStride);let l=this.uploadCache;this.uploadCache=/* @__PURE__ */ new Map;let u=Array.from({length:s},()=>[]);for(let e of n)u[e.layer].push(e);for(let e=0;e<s;e++){let n=u[e];if(n.length){this.gl.bindTexture(this.gl.TEXTURE_2D,this.atlasPages[e]);for(let{img:e,x:r,y:i,layer:a,sourceKey:o,packW:s,uploadStrided:c}of n){if(o){let e=V(r,i,a),t=l.get(o)===e||this.uploadCache.get(o)===e;if(this.uploadCache.set(o,e),t)continue}if(c)this.gl.texSubImage2D(this.gl.TEXTURE_2D,0,r,i,s,e.h,this.gl.ALPHA,this.gl.UNSIGNED_BYTE,t.subarray(e.bitmap,e.bitmap+e.stride*e.h));else{let n=e.w*e.h;n>this.copyData.length&&(this.copyData=new Uint8Array(n));let a=t.subarray(e.bitmap,e.bitmap+e.stride*e.h);for(let t=0;t<e.h;t++){let n=t*e.stride;this.copyData.set(a.subarray(n,n+e.w),t*e.w)}this.gl.texSubImage2D(this.gl.TEXTURE_2D,0,r,i,e.w,e.h,this.gl.ALPHA,this.gl.UNSIGNED_BYTE,this.copyData.subarray(0,n))}}}}for(let e=0;e<s;e++){let t=u[e];if(t.length){for(let e=0;e<t.length;e++){let{img:n,x:r,y:i}=t[e];if(this.instancedArraysExt)this.writeImage(e*10,n,r,i);else for(let t=0;t<6;t++){let a=(e*6+t)*12;this.instanceData[a]=U[t*2],this.instanceData[a+1]=U[t*2+1],this.writeImage(a+2,n,r,i)}}this.gl.bindBuffer(this.gl.ARRAY_BUFFER,this.instanceBuffer),this.gl.bufferSubData(this.gl.ARRAY_BUFFER,0,this.instanceData.subarray(0,t.length*this.instanceStride)),this.gl.bindTexture(this.gl.TEXTURE_2D,this.atlasPages[e]),this.gl.uniform2f(this.u_atlasSize,this.atlasSize,this.atlasSize),this.instancedArraysExt?this.instancedArraysExt.drawArraysInstancedANGLE(this.gl.TRIANGLES,0,6,t.length):this.gl.drawArrays(this.gl.TRIANGLES,0,t.length*6)}}this.gl.flush()}destroy(){if(this.ctrl.abort(),this.gl){for(let e of this.atlasPages)this.gl.deleteTexture(e);this.atlasPages=[],this.uploadCache.clear(),this.gl.deleteBuffer(this.quadPosBuffer),this.gl.deleteBuffer(this.instanceBuffer),this.gl.deleteProgram(this.program),this.gl.getExtension(`WEBGL_lose_context`)?.loseContext(),this.quadPosBuffer=this.instanceBuffer=this.program=this.gl=this.copyData=null}}},G=class extends H{vao;u_atlas=null;instanceBuffer;instanceData;instanceFloats;instanceBytes;instanceCapacity=0;atlas=null;atlasFullAt=0;maxTextureSize=0;maxArrayTextureLayers=0;uploadCache=/* @__PURE__ */ new Map;_createInstanceData(){this.instanceData=/* @__PURE__ */ new ArrayBuffer(this.instanceCapacity*32),this.instanceFloats=new Float32Array(this.instanceData),this.instanceBytes=new Uint8Array(this.instanceData)}ensureInstanceCapacity(e){e<=this.instanceCapacity||(this.instanceCapacity=Math.max(e,this.instanceCapacity*2,256),this._createInstanceData(),this.gl.bindBuffer(this.gl.ARRAY_BUFFER,this.instanceBuffer),this.gl.bufferData(this.gl.ARRAY_BUFFER,this.instanceCapacity*32,this.gl.DYNAMIC_DRAW))}constructor(e){super(e);try{this._initGL()}catch(e){throw this.destroy(),e}}_initGL(){let e=this.canvas.getContext(`webgl2`,{alpha:!0,premultipliedAlpha:!0,antialias:!1,depth:!1,preserveDrawingBuffer:!1,stencil:!1,desynchronized:!
|
|
65
|
+
`);let n=e.getShaderPrecisionFormat(e.FRAGMENT_SHADER,e.MEDIUM_FLOAT)?.precision??10;this.maxAtlasSize=t?Math.min(this.maxTextureSize,2048):Math.min(this.maxTextureSize,2**Math.max(6,n-1)),this.atlasPadding=+!t,this.u_resolution=this.gl.getUniformLocation(this.program,`u_resolution`),this.u_tex=this.gl.getUniformLocation(this.program,`u_tex`),this.u_colorMatrix=this.gl.getUniformLocation(this.program,`u_colorMatrix`),this.u_colorOffset=this.gl.getUniformLocation(this.program,`u_colorOffset`),this.u_atlasSize=this.gl.getUniformLocation(this.program,`u_atlasSize`),this.a_quadPos=this.gl.getAttribLocation(this.program,`a_quadPos`),this.a_destRect=this.gl.getAttribLocation(this.program,`a_destRect`),this.a_srcXY=this.gl.getAttribLocation(this.program,`a_srcXY`),this.a_color=this.gl.getAttribLocation(this.program,`a_color`),this.quadPosBuffer=this.gl.createBuffer(),this.gl.bindBuffer(this.gl.ARRAY_BUFFER,this.quadPosBuffer),this.gl.bufferData(this.gl.ARRAY_BUFFER,U,this.gl.STATIC_DRAW),this.instanceBuffer=this.gl.createBuffer(),this.instanceCapacity=0;let r=this.instancedArraysExt?10:72;this.ensureInstanceCapacity(256,r),this.gl.bindBuffer(this.gl.ARRAY_BUFFER,this.instanceBuffer),this.instancedArraysExt?(this.vertexAttrib(this.a_destRect,4,40,0,1),this.vertexAttrib(this.a_srcXY,2,40,16,1),this.vertexAttrib(this.a_color,4,40,24,1),this.gl.bindBuffer(this.gl.ARRAY_BUFFER,this.quadPosBuffer),this.vertexAttrib(this.a_quadPos,2,0,0)):(this.vertexAttrib(this.a_quadPos,2,48,0),this.vertexAttrib(this.a_destRect,4,48,8),this.vertexAttrib(this.a_srcXY,2,48,24),this.vertexAttrib(this.a_color,4,48,32)),this.applyCommonState(this.u_tex),this.gl.uniform2f(this.u_atlasSize,1,1)}vertexAttrib(e,t,n,r,i=0){this.gl.enableVertexAttribArray(e),this.gl.vertexAttribPointer(e,t,this.gl.FLOAT,!1,n,r),i&&this.instancedArraysExt?.vertexAttribDivisorANGLE(e,i)}ensureInstanceCapacity(e,t){e<=this.instanceCapacity||(this.instanceCapacity=Math.max(e,this.instanceCapacity*2,256),this.instanceStride=t,this.instanceData=new Float32Array(this.instanceCapacity*t),this.gl.bindBuffer(this.gl.ARRAY_BUFFER,this.instanceBuffer),this.gl.bufferData(this.gl.ARRAY_BUFFER,this.instanceData.byteLength,this.gl.DYNAMIC_DRAW))}writeImage(e,t,n,r){let i=this.instanceData;i[e]=t.dst_x,i[e+1]=t.dst_y,i[e+2]=t.w,i[e+3]=t.h,i[e+4]=n,i[e+5]=r,i[e+6]=(t.color>>>24&255)/255,i[e+7]=(t.color>>>16&255)/255,i[e+8]=(t.color>>>8&255)/255,i[e+9]=(t.color&255)/255}createAtlasPage(e){let t=this.gl.createTexture();return this.gl.bindTexture(this.gl.TEXTURE_2D,t),this.gl.texImage2D(this.gl.TEXTURE_2D,0,this.gl.ALPHA,e,e,0,this.gl.ALPHA,this.gl.UNSIGNED_BYTE,null),this.gl.texParameteri(this.gl.TEXTURE_2D,this.gl.TEXTURE_MIN_FILTER,this.gl.NEAREST),this.gl.texParameteri(this.gl.TEXTURE_2D,this.gl.TEXTURE_MAG_FILTER,this.gl.NEAREST),this.gl.texParameteri(this.gl.TEXTURE_2D,this.gl.TEXTURE_WRAP_S,this.gl.CLAMP_TO_EDGE),this.gl.texParameteri(this.gl.TEXTURE_2D,this.gl.TEXTURE_WRAP_T,this.gl.CLAMP_TO_EDGE),t}ensureAtlas(e,t){if(this.atlasSize!==e){for(let e of this.atlasPages)this.gl.deleteTexture(e);this.atlasPages=[],this.atlasSize=e,this.uploadCache.clear()}for(;this.atlasPages.length<t;)this.atlasPages.push(this.createAtlasPage(e));let n=performance.now();if(t===this.atlasPages.length)this.atlasFullAt=n;else if(n-this.atlasFullAt>2e4)for(let e of this.atlasPages.splice(t))this.gl.deleteTexture(e)}render(e,t){if(!this.gl||!this.beginFrame(e))return;let n=[],r=0,i=0;for(let a of e){if(a.w>this.maxTextureSize||a.h>this.maxTextureSize)continue;let e=a.stride>=a.w&&a.stride<=this.maxTextureSize&&a.bitmap+a.stride*a.h<=t.length,o=e?a.stride:a.w;n.push({img:a,packW:o,uploadStrided:e,x:0,y:0,layer:0,sourceKey:a.cache_id&&`${a.cache_id}:${a.bitmap}:${a.w}:${a.h}:${a.stride}`}),r=Math.max(r,o,a.h),i+=o*a.h}if(n.length===0){this.gl.flush();return}let a=Math.max(64,Math.ceil(Math.max(r,Math.ceil(Math.sqrt(i)))/64)*64),o=Math.min(this.maxTextureSize,Math.max(this.atlasSize,a),Math.max(this.maxAtlasSize,r)),s=this.packAtlas(n,o,this.atlasPadding);s>64&&o<this.maxAtlasSize&&(o=this.maxAtlasSize,s=this.packAtlas(n,o,this.atlasPadding));let c=128*this.canvas.width*this.canvas.height;if(s>64||s>1&&o*o*s>c){console.warn(`JASSUB: frame exceeds WebGL1 atlas capacity`),this.gl.flush();return}this.gl.finish(),this.ensureAtlas(o,s),this.ensureInstanceCapacity(n.length,this.instanceStride);let l=this.uploadCache;this.uploadCache=/* @__PURE__ */ new Map;let u=Array.from({length:s},()=>[]);for(let e of n)u[e.layer].push(e);for(let e=0;e<s;e++){let n=u[e];if(n.length){this.gl.bindTexture(this.gl.TEXTURE_2D,this.atlasPages[e]);for(let{img:e,x:r,y:i,layer:a,sourceKey:o,packW:s,uploadStrided:c}of n){if(o){let e=V(r,i,a),t=l.get(o)===e||this.uploadCache.get(o)===e;if(this.uploadCache.set(o,e),t)continue}if(c)this.gl.texSubImage2D(this.gl.TEXTURE_2D,0,r,i,s,e.h,this.gl.ALPHA,this.gl.UNSIGNED_BYTE,t.subarray(e.bitmap,e.bitmap+e.stride*e.h));else{let n=e.w*e.h;n>this.copyData.length&&(this.copyData=new Uint8Array(n));let a=t.subarray(e.bitmap,e.bitmap+e.stride*e.h);for(let t=0;t<e.h;t++){let n=t*e.stride;this.copyData.set(a.subarray(n,n+e.w),t*e.w)}this.gl.texSubImage2D(this.gl.TEXTURE_2D,0,r,i,e.w,e.h,this.gl.ALPHA,this.gl.UNSIGNED_BYTE,this.copyData.subarray(0,n))}}}}for(let e=0;e<s;e++){let t=u[e];if(t.length){for(let e=0;e<t.length;e++){let{img:n,x:r,y:i}=t[e];if(this.instancedArraysExt)this.writeImage(e*10,n,r,i);else for(let t=0;t<6;t++){let a=(e*6+t)*12;this.instanceData[a]=U[t*2],this.instanceData[a+1]=U[t*2+1],this.writeImage(a+2,n,r,i)}}this.gl.bindBuffer(this.gl.ARRAY_BUFFER,this.instanceBuffer),this.gl.bufferSubData(this.gl.ARRAY_BUFFER,0,this.instanceData.subarray(0,t.length*this.instanceStride)),this.gl.bindTexture(this.gl.TEXTURE_2D,this.atlasPages[e]),this.gl.uniform2f(this.u_atlasSize,this.atlasSize,this.atlasSize),this.instancedArraysExt?this.instancedArraysExt.drawArraysInstancedANGLE(this.gl.TRIANGLES,0,6,t.length):this.gl.drawArrays(this.gl.TRIANGLES,0,t.length*6)}}this.gl.flush()}destroy(){if(this.ctrl.abort(),this.gl){for(let e of this.atlasPages)this.gl.deleteTexture(e);this.atlasPages=[],this.uploadCache.clear(),this.gl.deleteBuffer(this.quadPosBuffer),this.gl.deleteBuffer(this.instanceBuffer),this.gl.deleteProgram(this.program),this.gl.getExtension(`WEBGL_lose_context`)?.loseContext(),this.quadPosBuffer=this.instanceBuffer=this.program=this.gl=this.copyData=null}}},G=class extends H{vao;u_atlas=null;instanceBuffer;instanceData;instanceFloats;instanceBytes;instanceCapacity=0;atlas=null;atlasFullAt=0;maxTextureSize=0;maxArrayTextureLayers=0;uploadCache=/* @__PURE__ */ new Map;_createInstanceData(){this.instanceData=/* @__PURE__ */ new ArrayBuffer(this.instanceCapacity*32),this.instanceFloats=new Float32Array(this.instanceData),this.instanceBytes=new Uint8Array(this.instanceData)}ensureInstanceCapacity(e){e<=this.instanceCapacity||(this.instanceCapacity=Math.max(e,this.instanceCapacity*2,256),this._createInstanceData(),this.gl.bindBuffer(this.gl.ARRAY_BUFFER,this.instanceBuffer),this.gl.bufferData(this.gl.ARRAY_BUFFER,this.instanceCapacity*32,this.gl.DYNAMIC_DRAW))}constructor(e){super(e);try{this._initGL()}catch(e){throw this.destroy(),e}}_initGL(){let e=this.canvas.getContext(`webgl2`,{alpha:!0,premultipliedAlpha:!0,antialias:!1,depth:!1,preserveDrawingBuffer:!1,stencil:!1,desynchronized:!1,powerPreference:`default`});if(!e)throw Error(`Could not get WebGL2 context`);this.gl=e,this.maxTextureSize=this.gl.getParameter(this.gl.MAX_TEXTURE_SIZE),this.maxArrayTextureLayers=this.gl.getParameter(this.gl.MAX_ARRAY_TEXTURE_LAYERS),this.atlas=null,this.uploadCache.clear(),this.createProgram(`#version 300 es
|
|
66
66
|
precision highp float;
|
|
67
67
|
|
|
68
68
|
const vec2 QUAD_POSITIONS[6] = vec2[6](
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@banou/ripple",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.113",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -33,6 +33,6 @@
|
|
|
33
33
|
"store/phone.webp"
|
|
34
34
|
]
|
|
35
35
|
},
|
|
36
|
-
"main": "index-
|
|
36
|
+
"main": "index-BvXRjgZA.js",
|
|
37
37
|
"types": "types/contract.d.ts"
|
|
38
38
|
}
|
package/sw.js
CHANGED
|
@@ -8,8 +8,8 @@ const live = new Map()
|
|
|
8
8
|
/* Stamped at build time. These are the dev defaults and must never reach production: a worker whose
|
|
9
9
|
BUILD never changes is never reinstalled, so the update this feature announces would never fire. */
|
|
10
10
|
const MODE = "cache" // @stamp:mode
|
|
11
|
-
const BUILD = "
|
|
12
|
-
const MANIFEST = [["/assets/ar-BDvFhaGs-B37ZUZob.js","efe59c18a4ba50e4"],["/assets/ar-C7d_tKfc.js","262a54a07c2610e7"],["/assets/cs-B2V8wjEV-Bl0gJflL.js","47871835fb9845bd"],["/assets/cs-Dn8JxbTP.js","22916e1d64cc883a"],["/assets/de-B0llAkWe-CW3f9hbV.js","7e30af2af5487c2e"],["/assets/de-kjsalq0q.js","ee2d270b95f7f456"],["/assets/el-DdMjNs3W-CpW3UIqp.js","b7393587259363f2"],["/assets/el-yst__Dvk.js","085e44cd5140ebec"],["/assets/empty-BvRk9kiK.js","4a16cab41a8f641d"],["/assets/es-419-BDIqFIjA-Bczn8xdR.js","c54ecb9919f0c48a"],["/assets/es-419-DGpu0Wy3.js","b4b63ffdead9b860"],["/assets/fr-4KvU7P3Y-DeI8KRHo.js","095b8b740cfeceea"],["/assets/fr-B0Mb-0Tj.js","8d60889f214cddc5"],["/assets/he-23jbb4QA-BgdHOlz8.js","dd83a44f13caafde"],["/assets/he-DwwK_gqL.js","50258545a5113de5"],["/assets/hi-DYU91RyO-CQMN6ss4.js","2a7c6f18c713e7fa"],["/assets/hi-Lhb3QxAg.js","a0f2245675b1ab79"],["/assets/hu-CbN03cjk-Q1g0wcip.js","94dd6d40a51a6550"],["/assets/hu-JmcO2ijA.js","67d03186606c0cd9"],["/assets/id-C5uFcUUj.js","c5e20f3fcc8e8467"],["/assets/id-IC7SHPJD-2d-EIu1Q.js","bc348db13d31f4e8"],["/assets/it-COoJK0Cm-DC5J9jzE.js","c2bea2ef11f8623d"],["/assets/it-D3TPqUSS.js","c35bd1d4a9070f3e"],["/assets/ja-e0Mz8vyo-CnNrOgDh.js","9a5c9ca41cb7f6af"],["/assets/ja-p83MwSAD.js","3b30e7e7859432fb"],["/assets/ko-D52eZ7TY-D-FeGDHf.js","28c7b5ba8b2c4a4f"],["/assets/ko-D5aZ3MM9.js","4a42965d1881e061"],["/assets/libtorrent-BFRNr0NN.js","a6ee757b3be46a18"],["/assets/libtorrent-CuAQ72W-.wasm","9d58902cf272c197"],["/assets/ms-4QL7vvXo.js","bf4d06119fc6ab30"],["/assets/ms-DRzqhZg6-C1y6eCIm.js","0deff708e84b3c04"],["/assets/nl-HDNEUrxd-C0Nn2Eei.js","67b538ab73154a2a"],["/assets/nl-OHPPJKni.js","9ff815e9d5d56dc1"],["/assets/pl-BJCCCvmg-BCr-1S2N.js","179cdc532ed4e288"],["/assets/pl-DP02KlLI.js","92f2e0ebe7c87c99"],["/assets/pt-BR-BUcrLmqd-CszlA5Lx.js","b7450cc86794cb21"],["/assets/pt-BR-Bw79ie2c.js","c306bda65950e528"],["/assets/remote-
|
|
11
|
+
const BUILD = "a086b95d70dfd397" // @stamp:build
|
|
12
|
+
const MANIFEST = [["/assets/ar-BDvFhaGs-B37ZUZob.js","efe59c18a4ba50e4"],["/assets/ar-C7d_tKfc.js","262a54a07c2610e7"],["/assets/cs-B2V8wjEV-Bl0gJflL.js","47871835fb9845bd"],["/assets/cs-Dn8JxbTP.js","22916e1d64cc883a"],["/assets/de-B0llAkWe-CW3f9hbV.js","7e30af2af5487c2e"],["/assets/de-kjsalq0q.js","ee2d270b95f7f456"],["/assets/el-DdMjNs3W-CpW3UIqp.js","b7393587259363f2"],["/assets/el-yst__Dvk.js","085e44cd5140ebec"],["/assets/empty-BvRk9kiK.js","4a16cab41a8f641d"],["/assets/es-419-BDIqFIjA-Bczn8xdR.js","c54ecb9919f0c48a"],["/assets/es-419-DGpu0Wy3.js","b4b63ffdead9b860"],["/assets/fr-4KvU7P3Y-DeI8KRHo.js","095b8b740cfeceea"],["/assets/fr-B0Mb-0Tj.js","8d60889f214cddc5"],["/assets/he-23jbb4QA-BgdHOlz8.js","dd83a44f13caafde"],["/assets/he-DwwK_gqL.js","50258545a5113de5"],["/assets/hi-DYU91RyO-CQMN6ss4.js","2a7c6f18c713e7fa"],["/assets/hi-Lhb3QxAg.js","a0f2245675b1ab79"],["/assets/hu-CbN03cjk-Q1g0wcip.js","94dd6d40a51a6550"],["/assets/hu-JmcO2ijA.js","67d03186606c0cd9"],["/assets/id-C5uFcUUj.js","c5e20f3fcc8e8467"],["/assets/id-IC7SHPJD-2d-EIu1Q.js","bc348db13d31f4e8"],["/assets/it-COoJK0Cm-DC5J9jzE.js","c2bea2ef11f8623d"],["/assets/it-D3TPqUSS.js","c35bd1d4a9070f3e"],["/assets/ja-e0Mz8vyo-CnNrOgDh.js","9a5c9ca41cb7f6af"],["/assets/ja-p83MwSAD.js","3b30e7e7859432fb"],["/assets/ko-D52eZ7TY-D-FeGDHf.js","28c7b5ba8b2c4a4f"],["/assets/ko-D5aZ3MM9.js","4a42965d1881e061"],["/assets/libtorrent-BFRNr0NN.js","a6ee757b3be46a18"],["/assets/libtorrent-CuAQ72W-.wasm","9d58902cf272c197"],["/assets/ms-4QL7vvXo.js","bf4d06119fc6ab30"],["/assets/ms-DRzqhZg6-C1y6eCIm.js","0deff708e84b3c04"],["/assets/nl-HDNEUrxd-C0Nn2Eei.js","67b538ab73154a2a"],["/assets/nl-OHPPJKni.js","9ff815e9d5d56dc1"],["/assets/pl-BJCCCvmg-BCr-1S2N.js","179cdc532ed4e288"],["/assets/pl-DP02KlLI.js","92f2e0ebe7c87c99"],["/assets/pt-BR-BUcrLmqd-CszlA5Lx.js","b7450cc86794cb21"],["/assets/pt-BR-Bw79ie2c.js","c306bda65950e528"],["/assets/remote-ZS_d8OmX.js","fa9610fecf9af157"],["/assets/ro-Dw0Og2du-Ccrln2wG.js","5d2819877ec1dab7"],["/assets/ro-xJkZYRnt.js","97b9eca9c3fb9421"],["/assets/ru-WiFDU03H-BXvdsU2j.js","6c30ed64a9b80031"],["/assets/ru-uHiUpPrf.js","7cc3aefae5bba764"],["/assets/sv-CBeUvNyE-Dkpm8k4C.js","766a84d08c866f5e"],["/assets/sv-DvdyR0P3.js","76a12c880fb1bf63"],["/assets/th-Bb-QMd0n-ZH0skzd9.js","68e442b6d9f6e518"],["/assets/th-QKfUZl5H.js","e5cf9330a8525cc1"],["/assets/tr-CgS_5ren.js","9ce44dd7cb00a59e"],["/assets/tr-c0PAeIDa-D3wIg2B4.js","df7e5db783d4f678"],["/assets/uk-D8f88hum.js","1f7295a526e44e2d"],["/assets/uk-_qyOqRe1-D8R5o1rF.js","592d25d77d6f8394"],["/assets/vi-C2euzwxg.js","af2b9041b96d3158"],["/assets/vi-DAoL_mCW-D_fBIrfw.js","53955f2d2d746eac"],["/assets/volume-normalizer-worklet-DZtKqOSy.js","005fce4e9ce1d345"],["/assets/worker-DE6CT5gj.js","0589ffddd4f95ef9"],["/assets/zh-Hans-BPYw5v0U-BND4Udq7.js","6e085c2816113fa8"],["/assets/zh-Hans-Btui9Gyn.js","82db36bcf3f5dc57"],["/assets/zh-Hant-BZH6d1_4.js","5ef1136402380d10"],["/assets/zh-Hant-DQZ_47wo-CeRzPmx-.js","b85dc58c7cfc1dda"],["/index-BvXRjgZA.js","7c8f5fc89ead2532"]] // @stamp:manifest
|
|
13
13
|
|
|
14
14
|
const CACHE = 'ripple-assets-' + BUILD
|
|
15
15
|
/** Holds the name of the generation that activated last, so the next activation can keep it. */
|