glre 0.30.0 → 0.31.0

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/dist/solid.cjs CHANGED
@@ -1,50 +1,50 @@
1
- "use strict";var M=Object.defineProperty;var je=Object.getOwnPropertyDescriptor;var He=Object.getOwnPropertyNames;var Ke=Object.prototype.hasOwnProperty;var Ze=(e,t)=>{for(var r in t)M(e,r,{get:t[r],enumerable:!0})},Qe=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of He(t))!Ke.call(e,o)&&o!==r&&M(e,o,{get:()=>t[o],enumerable:!(n=je(t,o))||n.enumerable});return e};var Je=e=>Qe(M({},"__esModule",{value:!0}),e);var Pt={};Ze(Pt,{alignTo256:()=>We,createAttrib:()=>re,createBindGroup:()=>ae,createBufferLayout:()=>le,createDescriptor:()=>ce,createDevice:()=>se,createGL:()=>ge,createIbo:()=>ee,createPipeline:()=>ie,createProgram:()=>Q,createTexture:()=>oe,createTextureSampler:()=>fe,createUniformBuffer:()=>pe,createVbo:()=>J,createVertexBuffer:()=>ue,defaultFragmentGLSL:()=>ze,defaultVertexGLSL:()=>Ve,dig:()=>nt,each:()=>be,ext:()=>rt,fig:()=>ot,flush:()=>et,getStride:()=>te,is:()=>d,isGL:()=>de,isServer:()=>qe,isWebGPUSupported:()=>ke,onGL:()=>Nt,replace:()=>tt,sig:()=>st,webgl:()=>ne,webgpu:()=>me});module.exports=Je(Pt);var R=require("reev"),$=require("refr");var U=require("reev");var d={arr:Array.isArray,bol:e=>typeof e=="boolean",str:e=>typeof e=="string",num:e=>typeof e=="number",int:e=>Number.isInteger(e),fun:e=>typeof e=="function",und:e=>typeof e>"u",nul:e=>e===null,set:e=>e instanceof Set,map:e=>e instanceof Map,obj:e=>!!e&&e.constructor.name==="Object",nan:e=>typeof e=="number"&&Number.isNaN(e)},be=(e,t)=>e.forEach(t),et=(e,...t)=>{be(e,r=>r(...t))},tt=(e="",t="_",r="/")=>e.split(t).join(r),rt=(e=".pdf")=>e.split(".").pop()?.toLowerCase()??"",ot=(e=0)=>`${e}`.split(".")[1]?.length??0,nt=(e=0)=>`${e}`.split(".")[0]?.length-(e<0?1:0),st=(e=0,t=-2)=>(t*=-1,t=Math.pow(10,t),e*=t,e=Math.round(e),e/=t,e);var S=["bool","uint","int","float","bvec2","ivec2","uvec2","vec2","bvec3","ivec3","uvec3","vec3","bvec4","ivec4","uvec4","vec4","color","mat2","mat3","mat4"],D=["toBool","toUint","toInt","toFloat","toBvec2","toIvec2","toUvec2","toVec2","toBvec3","toIvec3","toUvec3","toVec3","toBvec4","toIvec4","toUvec4","toVec4","toColor","toMat2","toMat3","toMat4"],V={add:"+",sub:"-",mul:"*",div:"/",mod:"%",equal:"==",notEqual:"!=",lessThan:"<",lessThanEqual:"<=",greaterThan:">",greaterThanEqual:">=",and:"&&",or:"||",bitAnd:"&",bitOr:"|",bitXor:"^",shiftLeft:"<<",shiftRight:">>"},ve=Object.keys(V),z=["dot","distance","length","lengthSq","determinant","luminance"],W=["all","any"],q=["abs","sign","floor","ceil","round","fract","trunc","sin","cos","tan","asin","acos","atan","exp","exp2","log","log2","sqrt","inverseSqrt","normalize","oneMinus","saturate","negate","reciprocal","dFdx","dFdy","fwidth"],k=["cross"],Y=["reflect","refract"],j=["min","max","mix","clamp","step","smoothstep"],H=["texture","textureLod","textureSize","cubeTexture"],it=["atan2","degrees","faceforward","bitcast","cbrt","difference","equals","pow","pow2","pow3","pow4","radians","transformDirection"],ye=[...z,...W,...q,...k,...Y,...j,...H,...it],Xe={float:"f32",int:"i32",uint:"u32",bool:"bool",vec2:"vec2f",vec3:"vec3f",vec4:"vec4f",mat2:"mat2x2f",mat3:"mat3x3f",mat4:"mat4x4f",ivec2:"vec2i",ivec3:"vec3i",ivec4:"vec4i",uvec2:"vec2u",uvec3:"vec3u",uvec4:"vec4u",bvec2:"vec2<bool>",bvec3:"vec3<bool>",bvec4:"vec4<bool>"},K={1:"float",2:"vec2",3:"vec3",4:"vec4",9:"mat3",16:"mat4"},_e={position:"vec4",vertex_index:"uint",instance_index:"uint",front_facing:"bool",frag_depth:"float",sample_index:"uint",sample_mask:"uint",point_coord:"vec2",positionLocal:"vec3",positionWorld:"vec3",positionView:"vec3",normalLocal:"vec3",normalWorld:"vec3",normalView:"vec3",screenCoordinate:"vec2",screenUV:"vec2",gl_FragCoord:"vec4",gl_VertexID:"uint",gl_InstanceID:"uint",gl_FrontFacing:"bool",gl_FragDepth:"float",gl_SampleID:"uint",gl_SampleMask:"uint",gl_PointCoord:"vec2",normal:"vec3",uv:"vec2",color:"vec4"},Te=["equal","notEqual","lessThan","lessThanEqual","greaterThan","greaterThanEqual"],he=["and","or"],Ee={position:"gl_FragCoord",vertex_index:"gl_VertexID",instance_index:"gl_InstanceID",front_facing:"gl_FrontFacing",frag_depth:"gl_FragDepth",sample_index:"gl_SampleID",sample_mask:"gl_SampleMask",point_coord:"gl_PointCoord",uv:"gl_FragCoord.xy"};var Z=e=>d.str(e)&&/^[xyzwrgbastpq]{1,4}$/.test(e),Ne=e=>ve.includes(e),Pe=e=>ye.includes(e),Se=e=>D.includes(e),P=e=>!e||typeof e!="object"?!1:e.isProxy;var at=0,Le=()=>`i${at++}`,w=(e,t)=>e.filter(r=>!d.und(r)&&!d.nul(r)).map(r=>c(r,t)).join(", "),L=(e,t)=>d.str(e)?t?.isWebGL?e:Xe[e]:"",Re=e=>V[e]||e,Ce=e=>Ee[e],we=e=>{let t=D.indexOf(e);return t!==-1?S[t]:"float"},Oe=e=>Array.from(e.headers).map(([,t])=>t).join(`
2
- `),Ge=(e,t)=>{let{id:r,children:n=[],layout:o}=e,[s,a,...i]=n,m=o?.type&&o?.type!=="auto"?o?.type:a?y(a,t):"void",b=[],u=[];if(o?.inputs)for(let x of o.inputs)b.push([x.name,x.type]);else for(let x=0;x<i.length;x++)b.push([`p${x}`,y(i[x],t)]);let p="";if(t?.isWebGL){for(let[x,_]of b)u.push(`${_} ${x}`);p+=`${m} ${r}(${u}) {
3
- `}else{for(let[x,_]of b)u.push(`${x}: ${L(_,t)}`);p+=`fn ${r}(${u}) -> ${L(m,t)} {
4
- `}let T=c(s,t);return T&&(p+=T+`
5
- `),a&&(p+=`return ${c(a,t)};`),p+=`
6
- }`,p},ct=`
1
+ "use strict";var te=Object.defineProperty;var rt=Object.getOwnPropertyDescriptor;var ot=Object.getOwnPropertyNames;var nt=Object.prototype.hasOwnProperty;var st=(e,t)=>{for(var r in t)te(e,r,{get:t[r],enumerable:!0})},it=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of ot(t))!nt.call(e,o)&&o!==r&&te(e,o,{get:()=>t[o],enumerable:!(n=rt(t,o))||n.enumerable});return e};var at=e=>it(te({},"__esModule",{value:!0}),e);var Po={};st(Po,{ADDITIONAL_FUNCTIONS:()=>ze,BOOL_RETURN_FUNCTIONS:()=>V,BUILTIN_TYPES:()=>se,COMPARISON_OPERATORS:()=>ie,COMPONENT_COUNT_TO_TYPE:()=>j,CONSTANTS:()=>R,CONVERSIONS:()=>B,FIRST_ARG_TYPE_FUNCTIONS:()=>q,FUNCTIONS:()=>oe,Fn:()=>Lt,HIGHEST_TYPE_FUNCTIONS:()=>k,If:()=>Nt,LOGICAL_OPERATORS:()=>ae,Loop:()=>Pt,OPERATORS:()=>M,OPERATOR_KEYS:()=>re,PRESERVE_TYPE_FUNCTIONS:()=>z,SCALAR_RETURN_FUNCTIONS:()=>D,SWIZZLES:()=>xt,Switch:()=>St,TYPE_MAPPING:()=>ne,VEC3_RETURN_FUNCTIONS:()=>W,VEC4_RETURN_FUNCTIONS:()=>Y,WGSL_TO_GLSL_BUILTIN:()=>ce,abs:()=>yr,acos:()=>Xr,alignTo256:()=>Qe,all:()=>_r,any:()=>Tr,asin:()=>hr,assign:()=>ve,atan:()=>Er,atan2:()=>Nr,attribute:()=>Ct,bitcast:()=>Pr,bool:()=>Qt,builtin:()=>h,bvec2:()=>ur,bvec3:()=>pr,bvec4:()=>fr,cbrt:()=>Sr,ceil:()=>Lr,clamp:()=>Rr,code:()=>u,color:()=>lr,constant:()=>Ot,conversion:()=>v,conversionToConstant:()=>de,cos:()=>Cr,createAttrib:()=>Se,createBindGroup:()=>Oe,createBufferLayout:()=>Ae,createDescriptor:()=>Ge,createDevice:()=>Ce,createGL:()=>De,createIbo:()=>Ne,createPipeline:()=>we,createProgram:()=>he,createTexture:()=>Le,createTextureSampler:()=>Ue,createUniformBuffer:()=>Fe,createVbo:()=>Ee,createVertexBuffer:()=>Ie,cross:()=>wr,cubeTexture:()=>br,dFdx:()=>Or,dFdy:()=>Gr,defaultFragmentGLSL:()=>Ze,defaultVertexGLSL:()=>Ke,degrees:()=>Ir,difference:()=>Fr,dig:()=>lt,distance:()=>Ur,dot:()=>Ar,each:()=>Ve,equals:()=>$r,exp:()=>Br,exp2:()=>Mr,ext:()=>pt,faceforward:()=>Dr,fig:()=>ft,float:()=>je,floor:()=>Vr,flush:()=>ct,formatConversions:()=>C,fract:()=>zr,fragDepth:()=>Bt,fragment:()=>F,frontFacing:()=>$t,function_:()=>i,fwidth:()=>Wr,generateDefine:()=>ge,getBluiltin:()=>xe,getId:()=>K,getOperator:()=>me,getStride:()=>Pe,hex2rgb:()=>le,iMouse:()=>xr,iResolution:()=>mr,iTime:()=>dr,infer:()=>_,inferImpl:()=>ke,instanceIndex:()=>At,int:()=>ye,inverseSqrt:()=>qr,is:()=>b,isConversion:()=>fe,isFunction:()=>pe,isGL:()=>Me,isNodeProxy:()=>L,isOperator:()=>ue,isServer:()=>Je,isSwizzle:()=>H,isWebGPUSupported:()=>et,ivec2:()=>or,ivec3:()=>nr,ivec4:()=>sr,joins:()=>I,length:()=>kr,lengthSq:()=>Yr,log:()=>jr,log2:()=>Hr,mat2:()=>er,mat3:()=>tr,mat4:()=>rr,max:()=>Kr,min:()=>Zr,mix:()=>Qr,negate:()=>Jr,node:()=>m,normalLocal:()=>zt,normalView:()=>qt,normalWorld:()=>Wt,normalize:()=>eo,onGL:()=>No,oneMinus:()=>to,operator:()=>Ye,pointCoord:()=>Vt,position:()=>Ft,positionLocal:()=>kt,positionView:()=>jt,positionWorld:()=>Yt,pow:()=>ro,pow2:()=>oo,pow3:()=>no,pow4:()=>so,radians:()=>io,reciprocal:()=>ao,reflect:()=>co,refract:()=>uo,replace:()=>ut,round:()=>po,sampleIndex:()=>Mt,sampleMask:()=>Dt,saturate:()=>fo,screenCoordinate:()=>Ht,screenUV:()=>Kt,select:()=>It,sig:()=>mt,sign:()=>lo,sin:()=>mo,smoothstep:()=>xo,sqrt:()=>go,step:()=>bo,swizzle:()=>Xe,tan:()=>vo,texture:()=>gr,textureSize:()=>vr,toVar:()=>be,transformDirection:()=>yo,trunc:()=>Xo,uint:()=>Zt,uniform:()=>$,uvec2:()=>ir,uvec3:()=>ar,uvec4:()=>cr,variable:()=>Gt,varying:()=>wt,vec2:()=>Te,vec3:()=>_e,vec4:()=>Jt,vertex:()=>U,vertexIndex:()=>Ut,webgl:()=>Re,webgpu:()=>$e});module.exports=at(Po);var G=require("reev"),J=require("refr");var Z=require("reev");var b={arr:Array.isArray,bol:e=>typeof e=="boolean",str:e=>typeof e=="string",num:e=>typeof e=="number",int:e=>Number.isInteger(e),fun:e=>typeof e=="function",und:e=>typeof e>"u",nul:e=>e===null,set:e=>e instanceof Set,map:e=>e instanceof Map,obj:e=>!!e&&e.constructor.name==="Object",nan:e=>typeof e=="number"&&Number.isNaN(e)},Ve=(e,t)=>e.forEach(t),ct=(e,...t)=>{Ve(e,r=>r(...t))},ut=(e="",t="_",r="/")=>e.split(t).join(r),pt=(e=".pdf")=>e.split(".").pop()?.toLowerCase()??"",ft=(e=0)=>`${e}`.split(".")[1]?.length??0,lt=(e=0)=>`${e}`.split(".")[0]?.length-(e<0?1:0),mt=(e=0,t=-2)=>(t*=-1,t=Math.pow(10,t),e*=t,e=Math.round(e),e/=t,e);var xt=["x","y","z","w","r","g","b","a","s","t","p","q"],R=["bool","uint","int","float","bvec2","ivec2","uvec2","vec2","bvec3","ivec3","uvec3","vec3","bvec4","ivec4","uvec4","vec4","color","mat2","mat3","mat4"],B=["toBool","toUint","toInt","toFloat","toBvec2","toIvec2","toUvec2","toVec2","toBvec3","toIvec3","toUvec3","toVec3","toBvec4","toIvec4","toUvec4","toVec4","toColor","toMat2","toMat3","toMat4"],M={add:"+",sub:"-",mul:"*",div:"/",mod:"%",equal:"==",notEqual:"!=",lessThan:"<",lessThanEqual:"<=",greaterThan:">",greaterThanEqual:">=",and:"&&",or:"||",bitAnd:"&",bitOr:"|",bitXor:"^",shiftLeft:"<<",shiftRight:">>"},re=Object.keys(M),D=["dot","distance","length","lengthSq","determinant","luminance"],V=["all","any"],z=["abs","sign","floor","ceil","round","fract","trunc","sin","cos","tan","asin","acos","atan","exp","exp2","log","log2","sqrt","inverseSqrt","normalize","oneMinus","saturate","negate","reciprocal","dFdx","dFdy","fwidth"],W=["cross"],q=["reflect","refract"],k=["min","max","mix","clamp","step","smoothstep"],Y=["texture","textureLod","textureSize","cubeTexture"],ze=["atan2","degrees","faceforward","bitcast","cbrt","difference","equals","pow","pow2","pow3","pow4","radians","transformDirection"],oe=[...D,...V,...z,...W,...q,...k,...Y,...ze],ne={float:"f32",int:"i32",uint:"u32",bool:"bool",vec2:"vec2f",vec3:"vec3f",vec4:"vec4f",mat2:"mat2x2f",mat3:"mat3x3f",mat4:"mat4x4f",ivec2:"vec2i",ivec3:"vec3i",ivec4:"vec4i",uvec2:"vec2u",uvec3:"vec3u",uvec4:"vec4u",bvec2:"vec2<bool>",bvec3:"vec3<bool>",bvec4:"vec4<bool>"},j={1:"float",2:"vec2",3:"vec3",4:"vec4",9:"mat3",16:"mat4"},se={position:"vec4",vertex_index:"uint",instance_index:"uint",front_facing:"bool",frag_depth:"float",sample_index:"uint",sample_mask:"uint",point_coord:"vec2",positionLocal:"vec3",positionWorld:"vec3",positionView:"vec3",normalLocal:"vec3",normalWorld:"vec3",normalView:"vec3",screenCoordinate:"vec2",screenUV:"vec2",gl_FragCoord:"vec4",gl_VertexID:"uint",gl_InstanceID:"uint",gl_FrontFacing:"bool",gl_FragDepth:"float",gl_SampleID:"uint",gl_SampleMask:"uint",gl_PointCoord:"vec2",normal:"vec3",uv:"vec2",color:"vec4"},ie=["equal","notEqual","lessThan","lessThanEqual","greaterThan","greaterThanEqual"],ae=["and","or"],ce={position:"gl_FragCoord",vertex_index:"gl_VertexID",instance_index:"gl_InstanceID",front_facing:"gl_FrontFacing",frag_depth:"gl_FragDepth",sample_index:"gl_SampleID",sample_mask:"gl_SampleMask",point_coord:"gl_PointCoord",uv:"gl_FragCoord.xy"};var H=e=>b.str(e)&&/^[xyzwrgbastpq]{1,4}$/.test(e),ue=e=>re.includes(e),pe=e=>oe.includes(e),fe=e=>B.includes(e),L=e=>!e||typeof e!="object"?!1:e.isProxy,le=e=>{let t=(e>>16&255)/255,r=(e>>8&255)/255,n=(e&255)/255;return[t,r,n]},dt=0,K=()=>`i${dt++}`,I=(e,t)=>e.filter(r=>!b.und(r)&&!b.nul(r)).map(r=>u(r,t)).join(", "),C=(e,t)=>b.str(e)?t?.isWebGL?e:ne[e]:"",me=e=>M[e]||e,xe=e=>ce[e],de=e=>{let t=B.indexOf(e);return t!==-1?R[t]:"float"},We=e=>Array.from(e.headers).map(([,t])=>t).join(`
2
+ `),ge=(e,t)=>{let{id:r,children:n=[],layout:o}=e,[s,a,...c]=n,x=o?.type&&o?.type!=="auto"?o?.type:a?_(a,t):"void",l=[],p=[];if(o?.inputs)for(let y of o.inputs)l.push([y.name,y.type]);else for(let y=0;y<c.length;y++)l.push([`p${y}`,_(c[y],t)]);let f="";if(t?.isWebGL){for(let[y,E]of l)p.push(`${E} ${y}`);f+=`${x} ${r}(${p}) {
3
+ `}else{for(let[y,E]of l)p.push(`${y}: ${C(E,t)}`);f+=`fn ${r}(${p}) -> ${C(x,t)} {
4
+ `}let N=u(s,t);return N&&(f+=N+`
5
+ `),a&&(f+=`return ${u(a,t)};`),f+=`
6
+ }`,f},gt=`
7
7
  #version 300 es
8
8
  precision mediump float;
9
9
  out vec4 fragColor;
10
- `.trim(),ut=`
10
+ `.trim(),bt=`
11
11
  @fragment
12
12
  fn main(@builtin(position) position: vec4f) -> @location(0) vec4f {
13
- `.trim(),pt=(e,t,r=!0)=>{let n="";return r&&(n+=ct),t&&(n+=`
13
+ `.trim(),vt=(e,t,r=!0)=>{let n="";return r&&(n+=gt),t&&(n+=`
14
14
  `+t+`
15
15
  `),r?n+=`void main() {
16
- fragColor = ${e};`:(n+=ut+`
16
+ fragColor = ${e};`:(n+=bt+`
17
17
  `,n+=` return ${e};`),n+=`
18
- }`,n},ft=(e,t,r=!0)=>"",O=(e,t={})=>{let r=c(e,t),n=Oe(t),o=pt(r,n,t.isWebGL);return console.log(`// \u2193\u2193\u2193 generated \u2193\u2193\u2193
18
+ }`,n},yt=(e,t,r=!0)=>"",F=(e,t={})=>{let r=u(e,t),n=We(t),o=vt(r,n,t.isWebGL);return console.log(`// \u2193\u2193\u2193 generated \u2193\u2193\u2193
19
19
 
20
20
  ${o}
21
21
 
22
- `),o},G=(e,t)=>{let r=c(e,t),n=Oe(t);return ft(r,n,t.isWebGL)};var lt=(e,t)=>e.reduce((r,n)=>{let o=y(n,t),s=S.indexOf(r);return S.indexOf(o)>s?o:r},"float"),mt=e=>_e[e],xt=(e,t,r)=>{let n=t.length>0?y(t[0],r):"float";return Y.includes(e)?n:z.includes(e)?"float":W.includes(e)?"bool":q.includes(e)?n:k.includes(e)?"vec3":H.includes(e)?"vec4":j.includes(e)?lt(t,r):n},Ie=(e,t,r)=>{if(Te.includes(r)||he.includes(r))return"bool";if(e===t||e.includes("vec")&&!t.includes("vec"))return e;if(t.includes("vec")&&!e.includes("vec"))return t;let n=S.indexOf(e),o=S.indexOf(t);return n>=o?e:t},dt=e=>d.bol(e)?"bool":d.num(e)?"float":d.arr(e)&&K[e.length]||"float",gt=e=>K[e],bt=(e,t)=>{let{type:r,props:n}=e,{id:o,children:s=[],inferFrom:a}=n,[i,m,b]=s;return a?y(a,t):r==="conversion"?i:r==="operator"?Ie(y(m,t),y(b,t),i):r==="function"?xt(i,s.slice(1),t):r==="swizzle"?gt(i.length):r==="ternary"?Ie(y(m,t),y(b,t),"add"):r==="builtin"?mt(o):r==="define"?n.layout?.type&&n.layout?.type!=="auto"?n.layout.type:m?y(m,t):"void":y(i,t)},y=(e,t)=>{if(t||(t={}),!P(e))return dt(e);if(t.infers||(t.infers=new WeakMap),t.infers.has(e))return t.infers.get(e);let r=bt(e,t);return t.infers.set(e,r),r};var c=(e,t)=>{if(t||(t={}),t.headers||(t.headers=new Map),d.str(e))return e;if(d.num(e)){let u=`${e}`;return u.includes(".")?u:u+".0"}if(d.bol(e))return e?"true":"false";if(!e)return"";let{type:r,props:n}=e,{id:o="",children:s=[]}=n,[a,i,m]=s,b="";if(r==="attribute"){if(t.headers.has(o))return o;b=`${y(e,t)} ${o}`}if(r==="uniform"){if(t.headers.has(o))return o;t.binding||(t.binding=0);let u=y(e,t);b=t.isWebGL?`uniform ${u} ${o};`:`@group(0) @binding(${t.binding++}) var<uniform> ${o}: ${L(u,t)};`}if(r==="constant"){if(t.headers.has(o))return o;let u=y(e,t),p=c(a,t);b=t.isWebGL?`const ${u} ${o} = ${p};`:`const ${o}: ${L(u,t)} = ${p};`}if(r==="varying"){if(t.headers.has(o))return o;b=`${y(e,t)} ${o}`}if(b)return t.headers.set(o,b),t.onMount?.(o),o;if(r==="variable")return o;if(r==="swizzle")return`${c(i,t)}.${c(a,t)}`;if(r==="ternary")return`(${c(a,t)} ? ${c(i,t)} : ${c(m,t)})`;if(r==="builtin")return t?.isWebGL?Ce(o):o;if(r==="conversion")return`${L(a,t)}(${w(s.slice(1),t)})`;if(r==="operator")return a==="not"||a==="bitNot"?`!${c(i,t)}`:`(${c(i,t)} ${Re(a)} ${c(m,t)})`;if(r==="function")return a==="negate"?`(-${w(s.slice(1),t)})`:`${a}(${w(s.slice(1),t)})`;if(r==="scope")return s.map(u=>c(u,t)).join(`
23
- `);if(r==="assign")return`${c(a,t)} = ${c(i,t)};`;if(r==="loop")return t.isWebGL?`for (int i = 0; i < ${a}; i += 1) {
24
- ${c(i,t)}
22
+ `),o},U=(e,t)=>{let r=u(e,t),n=We(t);return yt(r,n,t.isWebGL)};var Xt=(e,t)=>e.reduce((r,n)=>{let o=_(n,t),s=R.indexOf(r);return R.indexOf(o)>s?o:r},"float"),_t=e=>se[e],Tt=(e,t,r)=>{let n=t.length>0?_(t[0],r):"float";return q.includes(e)?n:D.includes(e)?"float":V.includes(e)?"bool":z.includes(e)?n:W.includes(e)?"vec3":Y.includes(e)?"vec4":k.includes(e)?Xt(t,r):n},qe=(e,t,r)=>{if(ie.includes(r)||ae.includes(r))return"bool";if(e===t||e.includes("vec")&&!t.includes("vec"))return e;if(t.includes("vec")&&!e.includes("vec"))return t;let n=R.indexOf(e),o=R.indexOf(t);return n>=o?e:t},ht=e=>b.bol(e)?"bool":b.num(e)?"float":b.arr(e)&&j[e.length]||"float",Et=e=>j[e],ke=(e,t)=>{let{type:r,props:n}=e,{id:o,children:s=[],inferFrom:a}=n,[c,x,l]=s;return a?_(a,t):r==="conversion"?c:r==="operator"?qe(_(x,t),_(l,t),c):r==="function"?Tt(c,s.slice(1),t):r==="swizzle"?Et(c.length):r==="ternary"?qe(_(x,t),_(l,t),"add"):r==="builtin"?_t(o):r==="define"?n.layout?.type&&n.layout?.type!=="auto"?n.layout.type:x?_(x,t):"void":_(c,t)},_=(e,t)=>{if(t||(t={}),!L(e))return ht(e);if(t.infers||(t.infers=new WeakMap),t.infers.has(e))return t.infers.get(e);let r=ke(e,t);return t.infers.set(e,r),r};var u=(e,t)=>{if(t||(t={}),t.headers||(t.headers=new Map),b.str(e))return e;if(b.num(e)){let p=`${e}`;return p.includes(".")?p:p+".0"}if(b.bol(e))return e?"true":"false";if(!e)return"";let{type:r,props:n}=e,{id:o="",children:s=[]}=n,[a,c,x]=s,l="";if(r==="attribute"){if(t.headers.has(o))return o;l=`${_(e,t)} ${o}`}if(r==="uniform"){if(t.headers.has(o))return o;t.binding||(t.binding=0);let p=_(e,t);l=t.isWebGL?`uniform ${p} ${o};`:`@group(0) @binding(${t.binding++}) var<uniform> ${o}: ${C(p,t)};`}if(r==="constant"){if(t.headers.has(o))return o;let p=_(e,t),f=u(a,t);l=t.isWebGL?`const ${p} ${o} = ${f};`:`const ${o}: ${C(p,t)} = ${f};`}if(r==="varying"){if(t.headers.has(o))return o;l=`${_(e,t)} ${o}`}if(l)return t.headers.set(o,l),t.onMount?.(o),o;if(r==="variable")return o;if(r==="swizzle")return`${u(c,t)}.${u(a,t)}`;if(r==="ternary")return`(${u(a,t)} ? ${u(c,t)} : ${u(x,t)})`;if(r==="builtin")return t?.isWebGL?xe(o):o;if(r==="conversion")return`${C(a,t)}(${I(s.slice(1),t)})`;if(r==="operator")return a==="not"||a==="bitNot"?`!${u(c,t)}`:`(${u(c,t)} ${me(a)} ${u(x,t)})`;if(r==="function")return a==="negate"?`(-${I(s.slice(1),t)})`:`${a}(${I(s.slice(1),t)})`;if(r==="scope")return s.map(p=>u(p,t)).join(`
23
+ `);if(r==="assign")return`${u(a,t)} = ${u(c,t)};`;if(r==="loop")return t.isWebGL?`for (int i = 0; i < ${a}; i += 1) {
24
+ ${u(c,t)}
25
25
  }`:`for (var i: i32 = 0; i < ${a}; i++) {
26
- ${c(i,t)}
27
- }`;if(r==="define"){let u=s.slice(2),p=`${o}(${u.map(T=>c(T,t))})`;return t.headers.has(o)||t.headers.set(o,Ge(n,t)),p}if(r==="if"){let u=`if (${c(a,t)}) {
28
- ${c(i,t)}
29
- }`;for(let p=2;p<s.length;p+=2){let T=p>=s.length-1;u+=T?` else {
30
- ${c(s[p],t)}
31
- }`:` else if (${c(s[p],t)}) {
32
- ${c(s[p+1],t)}
33
- }`}return u}if(r==="switch"){let u=`switch (${c(a,t)}) {
34
- `;for(let p=1;p<s.length;p+=2)p>=s.length-1&&s.length%2===0?u+=`default:
35
- ${c(s[p],t)}
26
+ ${u(c,t)}
27
+ }`;if(r==="define"){let p=s.slice(2),f=`${o}(${p.map(N=>u(N,t))})`;return t.headers.has(o)||t.headers.set(o,ge(n,t)),f}if(r==="if"){let p=`if (${u(a,t)}) {
28
+ ${u(c,t)}
29
+ }`;for(let f=2;f<s.length;f+=2){let N=f>=s.length-1;p+=N?` else {
30
+ ${u(s[f],t)}
31
+ }`:` else if (${u(s[f],t)}) {
32
+ ${u(s[f+1],t)}
33
+ }`}return p}if(r==="switch"){let p=`switch (${u(a,t)}) {
34
+ `;for(let f=1;f<s.length;f+=2)f>=s.length-1&&s.length%2===0?p+=`default:
35
+ ${u(s[f],t)}
36
36
  break;
37
- `:p+1<s.length&&(u+=`case ${c(s[p],t)}:
38
- ${c(s[p+1],t)}
37
+ `:f+1<s.length&&(p+=`case ${u(s[f],t)}:
38
+ ${u(s[f+1],t)}
39
39
  break;
40
- `);return u+="}",u}if(r==="declare"){let u=y(a,t),p=i?.props?.id;if(t.isWebGL)return`${u} ${p} = ${c(a,t)};`;let T=L(u);return`var ${p}: ${T} = ${c(a,t)};`}return c(a,t)};var I=null;var Fe=e=>{I&&(I.props.children||(I.props.children=[]),I.props.children.push(e))},Ue=(e,t)=>{t||(t=Le());let r=N("variable",{id:t,inferFrom:e}),n=N("declare",null,e,r);return Fe(n),r},Ae=(e,t)=>{let r=N("assign",null,e,t);return Fe(r),e};var vt=(e,t)=>{if(t==="string")return c(e)},N=(e,t,...r)=>{t||(t={}),r.length&&(t.children=r);let n=(a,i)=>{if(i==="type")return e;if(i==="props")return t;if(i==="toVar")return Ue.bind(null,s);if(i==="assign")return Ae.bind(null,s);if(i==="isProxy")return!0;if(i==="toString")return c.bind(null,s);if(i===Symbol.toPrimitive)return vt.bind(null,s);if(Z(i))return $e(i,s);if(Ne(i))return(...m)=>yt(i,s,...m);if(Pe(i))return(...m)=>Be(i,s,...m);if(Se(i))return()=>C(we(i),s)},o=(a,i,m)=>Z(i)?($e(i,s).assign(m),!0):!1,s=new Proxy({},{get:n,set:o});return s};var F=(e,t)=>N("uniform",{id:t},e);var X=e=>N("builtin",{id:e}),$e=(e,t)=>N("swizzle",null,e,t),yt=(e,...t)=>N("operator",null,e,...t),Be=(e,...t)=>N("function",null,e,...t),C=(e,...t)=>N("conversion",null,e,...t);var rr=X("position"),or=X("vertex_index"),nr=X("instance_index"),sr=X("front_facing"),ir=X("frag_depth"),ar=X("sample_index"),cr=X("sample_mask"),ur=X("point_coord"),pr=X("normalLocal"),fr=X("normalWorld"),lr=X("normalView"),mr=X("position"),xr=X("positionWorld"),dr=X("positionView"),gr=X("screenCoordinate"),br=X("screenUV"),Xt=e=>C("float",e);var Me=(e,t)=>C("vec2",e,t);var vr=F(Me(1280,800),"iResolution"),yr=F(Me(0,0),"iMouse"),Xr=F(Xt(0),"iTime");var Ve=`
40
+ `);return p+="}",p}if(r==="declare"){let p=_(a,t),f=c?.props?.id;if(t.isWebGL)return`${p} ${f} = ${u(a,t)};`;let N=C(p);return`var ${f}: ${N} = ${u(a,t)};`}return u(a,t)};var w=null,O=(e,t=()=>{})=>{let r=w;w=e,t(),w=r},A=e=>{w&&(w.props.children||(w.props.children=[]),w.props.children.push(e))},be=(e,t)=>{t||(t=K());let r=m("variable",{id:t,inferFrom:e}),n=m("declare",null,e,r);return A(n),r},ve=(e,t)=>{let r=m("assign",null,e,t);return A(r),e},Nt=(e,t)=>{let r=m("scope");O(r,t);let n=m("if",null,e,r);A(n);let o=()=>({ElseIf:(s,a)=>{let c=m("scope");return O(c,a),n.props.children.push(s,c),o()},Else:s=>{let a=m("scope");O(a,s),n.props.children.push(a)}});return o()},Pt=(e,t)=>{let r=m("scope");O(r,()=>t({i:m("variable",{id:"i",inferFrom:ye(0)})}));let n=m("loop",null,e,r);return A(n),n},St=e=>{let t=m("switch",null,e);A(t);let r=()=>({Case:(...n)=>o=>{let s=m("scope");O(s,o);for(let a of n)t.props.children.push(a,s);return r()},Default:n=>{let o=m("scope");O(o,n),t.props.children.push(o)}});return r()},Lt=e=>{let t,r=(...n)=>{let o=t?.name||K(),s=m("scope"),a,c=[],x=[];if(t?.inputs)for(let l of t.inputs)x.push({id:l.name,inferFrom:v(l.type)});else for(let l=0;l<n.length;l++)x.push({id:`p${l}`,inferFrom:n[l]});for(let l of x)c.push(m("variable",l));return O(s,()=>a=e(c)),m("define",{id:o,layout:t},s,a,...n)};return r.setLayout=n=>(t=n,r),r};var Rt=(e,t)=>{if(t==="string")return u(e)},m=(e,t,...r)=>{t||(t={}),r.length&&(t.children=r);let n=(a,c)=>{if(c==="type")return e;if(c==="props")return t;if(c==="toVar")return be.bind(null,s);if(c==="assign")return ve.bind(null,s);if(c==="isProxy")return!0;if(c==="toString")return u.bind(null,s);if(c===Symbol.toPrimitive)return Rt.bind(null,s);if(H(c))return Xe(c,s);if(ue(c))return(...x)=>Ye(c,s,...x);if(pe(c))return(...x)=>i(c,s,...x);if(fe(c))return()=>v(de(c),s)},o=(a,c,x)=>H(c)?(Xe(c,s).assign(x),!0):!1,s=new Proxy({},{get:n,set:o});return s},Ct=(e,t)=>m("varying",{id:t},e),$=(e,t)=>m("uniform",{id:t},e),wt=(e,t)=>m("varying",{id:t},e),Ot=(e,t)=>m("constant",{id:t},e),Gt=e=>m("variable",{id:e}),h=e=>m("builtin",{id:e}),Xe=(e,t)=>m("swizzle",null,e,t),Ye=(e,...t)=>m("operator",null,e,...t),i=(e,...t)=>m("function",null,e,...t),v=(e,...t)=>m("conversion",null,e,...t),It=(e,t,r)=>m("ternary",null,e,t,r);var Ft=h("position"),Ut=h("vertex_index"),At=h("instance_index"),$t=h("front_facing"),Bt=h("frag_depth"),Mt=h("sample_index"),Dt=h("sample_mask"),Vt=h("point_coord"),zt=h("normalLocal"),Wt=h("normalWorld"),qt=h("normalView"),kt=h("position"),Yt=h("positionWorld"),jt=h("positionView"),Ht=h("screenCoordinate"),Kt=h("screenUV"),je=e=>v("float",e),ye=e=>v("int",e),Zt=e=>v("uint",e),Qt=e=>v("bool",e),Te=(e,t)=>v("vec2",e,t),_e=(e,t,r)=>v("vec3",e,t,r),Jt=(e,t,r,n)=>v("vec4",e,t,r,n),er=(...e)=>v("mat2",...e),tr=(...e)=>v("mat3",...e),rr=(...e)=>v("mat4",...e),or=(e,t)=>v("ivec2",e,t),nr=(e,t,r)=>v("ivec3",e,t,r),sr=(e,t,r,n)=>v("ivec4",e,t,r,n),ir=(e,t)=>v("uvec2",e,t),ar=(e,t,r)=>v("uvec3",e,t,r),cr=(e,t,r,n)=>v("uvec4",e,t,r,n),ur=(e,t)=>v("bvec2",e,t),pr=(e,t,r)=>v("bvec3",e,t,r),fr=(e,t,r,n)=>v("bvec4",e,t,r,n),lr=(e,t,r)=>b.num(e)&&b.und(t)&&b.und(r)?_e(...le(e)):_e(e,t,r),mr=$(Te(1280,800),"iResolution"),xr=$(Te(0,0),"iMouse"),dr=$(je(0),"iTime"),gr=(e,t,r)=>i("texture",e,t,r),br=(e,t,r)=>i("cubeTexture",e,t,r),vr=(e,t)=>i("textureSize",e,t),yr=e=>i("abs",e),Xr=e=>i("acos",e),_r=e=>i("all",e),Tr=e=>i("any",e),hr=e=>i("asin",e),Er=(e,t)=>t!==void 0?i("atan",e,t):i("atan",e),Nr=(e,t)=>i("atan",e,t),Pr=(e,t)=>i("bitcast",e,t),Sr=e=>i("cbrt",e),Lr=e=>i("ceil",e),Rr=(e,t,r)=>i("clamp",e,t,r),Cr=e=>i("cos",e),wr=(e,t)=>i("cross",e,t),Or=e=>i("dFdx",e),Gr=e=>i("dFdy",e),Ir=e=>i("degrees",e),Fr=(e,t)=>i("difference",e,t),Ur=(e,t)=>i("distance",e,t),Ar=(e,t)=>i("dot",e,t),$r=(e,t)=>i("equals",e,t),Br=e=>i("exp",e),Mr=e=>i("exp2",e),Dr=(e,t,r)=>i("faceforward",e,t,r),Vr=e=>i("floor",e),zr=e=>i("fract",e),Wr=e=>i("fwidth",e),qr=e=>i("inverseSqrt",e),kr=e=>i("length",e),Yr=e=>i("lengthSq",e),jr=e=>i("log",e),Hr=e=>i("log2",e),Kr=(e,t)=>i("max",e,t),Zr=(e,t)=>i("min",e,t),Qr=(e,t,r)=>i("mix",e,t,r),Jr=e=>i("negate",e),eo=e=>i("normalize",e),to=e=>i("oneMinus",e),ro=(e,t)=>i("pow",e,t),oo=e=>i("pow2",e),no=e=>i("pow3",e),so=e=>i("pow4",e),io=e=>i("radians",e),ao=e=>i("reciprocal",e),co=(e,t)=>i("reflect",e,t),uo=(e,t,r)=>i("refract",e,t,r),po=e=>i("round",e),fo=e=>i("saturate",e),lo=e=>i("sign",e),mo=e=>i("sin",e),xo=(e,t,r)=>i("smoothstep",e,t,r),go=e=>i("sqrt",e),bo=(e,t)=>i("step",e,t),vo=e=>i("tan",e),yo=(e,t)=>i("transformDirection",e,t),Xo=e=>i("trunc",e);var Ke=`
41
41
  #version 300 es
42
42
  void main() {
43
43
  float x = float(gl_VertexID % 2) * 4.0 - 1.0;
44
44
  float y = float(gl_VertexID / 2) * 4.0 - 1.0;
45
45
  gl_Position = vec4(x, y, 0.0, 1.0);
46
46
  }
47
- `,ze=`
47
+ `,Ze=`
48
48
  #version 300 es
49
49
  precision mediump float;
50
50
  uniform vec2 iResolution;
@@ -52,19 +52,19 @@ out vec4 fragColor;
52
52
  void main() {
53
53
  fragColor = vec4(fract(gl_FragCoord.xy / iResolution), 0, 1);
54
54
  }
55
- `,De=(e,t,r)=>{let n=e.createShader(r);if(!n)throw new Error("Failed to create shader");if(e.shaderSource(n,t.trim()),e.compileShader(n),e.getShaderParameter(n,e.COMPILE_STATUS))return n;let o=e.getShaderInfoLog(n);e.deleteShader(n),console.warn(`Could not compile shader: ${o}`)},Q=(e,t=Ve,r=ze,n=()=>{})=>{P(r)&&(r=O(r,{isWebGL:!0})),P(t)&&(t=G(r,{isWebGL:!0}));let o=e.createProgram(),s=De(e,t,e.VERTEX_SHADER),a=De(e,r,e.FRAGMENT_SHADER);if(!s||!a)return n();if(e.attachShader(o,s),e.attachShader(o,a),e.linkProgram(o),e.getProgramParameter(o,e.LINK_STATUS))return o;let i=e.getProgramInfoLog(o);e.deleteProgram(o),n(),console.warn(`Could not link pg: ${i}`)},J=(e,t)=>{let r=e.createBuffer();return e.bindBuffer(e.ARRAY_BUFFER,r),e.bufferData(e.ARRAY_BUFFER,new Float32Array(t),e.STATIC_DRAW),e.bindBuffer(e.ARRAY_BUFFER,null),r},ee=(e,t)=>{let r=e.createBuffer();return e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,r),e.bufferData(e.ELEMENT_ARRAY_BUFFER,new Int16Array(t),e.STATIC_DRAW),e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,null),r},te=(e,t,r)=>{r&&(e=Math.max(...r)+1);let n=t.length/e;return Math.floor(n)},re=(e,t,r,n,o)=>{e.bindBuffer(e.ARRAY_BUFFER,n),e.enableVertexAttribArray(r),e.vertexAttribPointer(r,t,e.FLOAT,!1,0,0),o&&e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,o)},oe=(e,t,r,n)=>{let o=e.createTexture();e.bindTexture(e.TEXTURE_2D,o),e.texImage2D(e.TEXTURE_2D,0,e.RGBA,e.RGBA,e.UNSIGNED_BYTE,t),e.generateMipmap(e.TEXTURE_2D),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MIN_FILTER,e.LINEAR),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MAG_FILTER,e.LINEAR),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_S,e.CLAMP_TO_EDGE),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_T,e.CLAMP_TO_EDGE),e.bindTexture(e.TEXTURE_2D,null),e.uniform1i(r,n),e.activeTexture(e.TEXTURE0+n),e.bindTexture(e.TEXTURE_2D,o)};var ne=async e=>{let t=e.el.getContext("webgl2"),r=Q(t,e.vs,e.fs,()=>void(e.isLoop=!1));t.useProgram(r);let n=0,o=(0,U.nested)(x=>t.getUniformLocation(r,x)),s=(0,U.nested)(x=>t.getAttribLocation(r,x)),a=(0,U.nested)(()=>n++);return{webgl:{context:t,program:r},render:()=>{t.clear(t.COLOR_BUFFER_BIT),t.viewport(0,0,...e.size),t.drawArrays(t.TRIANGLES,0,3)},clean:()=>t.deleteProgram(r),_attribute:(x="",_,h)=>{let E=s(x,!0),v=J(t,_),f=ee(t,h),l=te(e.count,_,h);re(t,l,E,v,f)},_uniform:(x,_)=>{let h=o(x);if(d.num(_))return t.uniform1f(h,_);let E=_.length;if(E<=4)return t[`uniform${E}fv`](h,_);E=Math.sqrt(E)<<0,t[`uniformMatrix${E}fv`](h,!1,_)},_texture:(x,_)=>{let h=new Image;Object.assign(h,{src:_,crossOrigin:"anonymous"}),h.decode().then(()=>{let E=o(x),v=a(x);oe(t,h,E,v)})}}};var A=require("reev");var _t=`
55
+ `,He=(e,t,r)=>{let n=e.createShader(r);if(!n)throw new Error("Failed to create shader");if(e.shaderSource(n,t.trim()),e.compileShader(n),e.getShaderParameter(n,e.COMPILE_STATUS))return n;let o=e.getShaderInfoLog(n);e.deleteShader(n),console.warn(`Could not compile shader: ${o}`)},he=(e,t=Ke,r=Ze,n=()=>{})=>{L(r)&&(r=F(r,{isWebGL:!0})),L(t)&&(t=U(r,{isWebGL:!0}));let o=e.createProgram(),s=He(e,t,e.VERTEX_SHADER),a=He(e,r,e.FRAGMENT_SHADER);if(!s||!a)return n();if(e.attachShader(o,s),e.attachShader(o,a),e.linkProgram(o),e.getProgramParameter(o,e.LINK_STATUS))return o;let c=e.getProgramInfoLog(o);e.deleteProgram(o),n(),console.warn(`Could not link pg: ${c}`)},Ee=(e,t)=>{let r=e.createBuffer();return e.bindBuffer(e.ARRAY_BUFFER,r),e.bufferData(e.ARRAY_BUFFER,new Float32Array(t),e.STATIC_DRAW),e.bindBuffer(e.ARRAY_BUFFER,null),r},Ne=(e,t)=>{let r=e.createBuffer();return e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,r),e.bufferData(e.ELEMENT_ARRAY_BUFFER,new Int16Array(t),e.STATIC_DRAW),e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,null),r},Pe=(e,t,r)=>{r&&(e=Math.max(...r)+1);let n=t.length/e;return Math.floor(n)},Se=(e,t,r,n,o)=>{e.bindBuffer(e.ARRAY_BUFFER,n),e.enableVertexAttribArray(r),e.vertexAttribPointer(r,t,e.FLOAT,!1,0,0),o&&e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,o)},Le=(e,t,r,n)=>{let o=e.createTexture();e.bindTexture(e.TEXTURE_2D,o),e.texImage2D(e.TEXTURE_2D,0,e.RGBA,e.RGBA,e.UNSIGNED_BYTE,t),e.generateMipmap(e.TEXTURE_2D),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MIN_FILTER,e.LINEAR),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MAG_FILTER,e.LINEAR),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_S,e.CLAMP_TO_EDGE),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_T,e.CLAMP_TO_EDGE),e.bindTexture(e.TEXTURE_2D,null),e.uniform1i(r,n),e.activeTexture(e.TEXTURE0+n),e.bindTexture(e.TEXTURE_2D,o)};var Re=async e=>{let t=e.el.getContext("webgl2"),r=he(t,e.vs,e.fs,()=>void(e.isLoop=!1));t.useProgram(r);let n=0,o=(0,Z.nested)(y=>t.getUniformLocation(r,y)),s=(0,Z.nested)(y=>t.getAttribLocation(r,y)),a=(0,Z.nested)(()=>n++);return{webgl:{context:t,program:r},render:()=>{t.clear(t.COLOR_BUFFER_BIT),t.viewport(0,0,...e.size),t.drawArrays(t.TRIANGLES,0,3)},clean:()=>t.deleteProgram(r),_attribute:(y="",E,P)=>{let S=s(y,!0),T=Ee(t,E),d=Ne(t,P),g=Pe(e.count,E,P);Se(t,g,S,T,d)},_uniform:(y,E)=>{let P=o(y);if(b.num(E))return t.uniform1f(P,E);let S=E.length;if(S<=4)return t[`uniform${S}fv`](P,E);S=Math.sqrt(S)<<0,t[`uniformMatrix${S}fv`](P,!1,E)},_texture:(y,E)=>{let P=new Image;Object.assign(P,{src:E,crossOrigin:"anonymous"}),P.decode().then(()=>{let S=o(y),T=a(y);Le(t,P,S,T)})}}};var Q=require("reev");var _o=`
56
56
  @vertex
57
57
  fn main(@builtin(vertex_index) vertex_index: u32) -> @builtin(position) vec4f {
58
58
  let x = f32(vertex_index % 2u) * 4.0 - 1.0;
59
59
  let y = f32(vertex_index / 2u) * 4.0 - 1.0;
60
60
  return vec4f(x, y, 0.0, 1.0);
61
61
  }
62
- `,Tt=`
62
+ `,To=`
63
63
  @group(0) @binding(0) var<uniform> iResolution: vec2f;
64
64
 
65
65
  @fragment
66
66
  fn main(@builtin(position) position: vec4f) -> @location(0) vec4f {
67
67
  return vec4f(position.xy / iResolution, 0.0, 1.0);
68
68
  }
69
- `,se=async e=>{let t=navigator.gpu,r=t.getPreferredCanvasFormat(),o=await(await t.requestAdapter()).requestDevice();return e.configure({device:o,format:r,alphaMode:"opaque"}),{device:o,format:r}},ie=(e,t,r,n,o=_t,s=Tt)=>{P(o)&&(o=G(o,{isWebGL:!1})),P(s)&&(s=O(s,{isWebGL:!1}));let a=e.createPipelineLayout({bindGroupLayouts:n});return e.createRenderPipeline({vertex:{module:e.createShaderModule({code:o.trim()}),entryPoint:"main",buffers:r},fragment:{module:e.createShaderModule({code:s.trim()}),entryPoint:"main",targets:[{format:t}]},layout:a,primitive:{topology:"triangle-list"}})},ae=(e,t)=>{let r=[],n=[];t.forEach((a,i)=>{if(!a)return;let m="buffer"in a,b=a instanceof GPUTextureView,u=a instanceof GPUSampler;if(m)r.push({binding:i,visibility:3,buffer:{type:"uniform"}});else if(b)r.push({binding:i,visibility:2,texture:{}});else if(u)r.push({binding:i,visibility:2,sampler:{}});else return;n.push({binding:i,resource:a})});let o=e.createBindGroupLayout({entries:r}),s=e.createBindGroup({layout:o,entries:n});return{layout:o,bindGroup:s}},ce=e=>({colorAttachments:[{view:e.getCurrentTexture().createView(),clearValue:{r:0,g:0,b:0,a:1},loadOp:"clear",storeOp:"store"}]}),We=e=>Math.ceil(e/256)*256,ue=(e,t)=>{let r=new Float32Array(t),n=e.createBuffer({size:r.byteLength,usage:40});return{array:r,buffer:n}},pe=(e,t)=>{let r=new Float32Array(t),n=We(r.byteLength),o=e.createBuffer({size:n,usage:72});return{array:r,buffer:o}},fe=(e,t=1280,r=800)=>{let n=e.createTexture({size:[t,r],format:"rgba8unorm",usage:22}),o=e.createSampler({magFilter:"linear",minFilter:"linear"});return{texture:n,sampler:o}},ht=(e,t)=>e/t,Et=e=>e===2?"float32x2":e===3?"float32x3":e===4?"float32x4":"float32",le=(e,t,r=6)=>{let n=ht(t,r);return{arrayStride:n*4,attributes:[{shaderLocation:e,offset:0,format:Et(n)}]}};var me=async e=>{let t=e.el.getContext("webgpu"),{device:r,format:n}=await se(t),o={device:r,context:t,resources:[[],[]],loadingImg:0,needsUpdate:!0},s=[],a=[],i=[],m=(0,A.nested)((v,f)=>{let{array:l,buffer:g}=ue(r,f);return a.push(g),i.push(le(i.length,l.length,e.count)),o.needsUpdate=!0,{array:l,buffer:g}}),b=(0,A.nested)((v,f)=>{let{array:l,buffer:g}=pe(r,f);return o.resources[0].push({buffer:g}),o.needsUpdate=!0,{array:l,buffer:g}}),u=(0,A.nested)((v,{width:f,height:l})=>{let{texture:g,sampler:B}=fe(r,f,l);return o.resources[1].push(B,g.createView()),o.needsUpdate=!0,{texture:g,width:f,height:l}}),p=()=>{let v=[];s.length=0,o.resources.forEach(f=>{if(!f.length)return;let{layout:l,bindGroup:g}=ae(r,f);v.push(l),s.push(g)}),o.pipeline=ie(r,n,i,v,e.vs,e.fs)};return{webgpu:o,render:()=>{if(o.loadingImg)return;o.needsUpdate&&p(),o.needsUpdate=!1;let v=r.createCommandEncoder(),f=v.beginRenderPass(ce(t));f.setPipeline(o.pipeline),s.forEach((l,g)=>f.setBindGroup(g,l)),a.forEach((l,g)=>f.setVertexBuffer(g,l)),f.draw(e.count,1,0,0),f.end(),r.queue.submit([v.finish()])},clean:()=>{},_attribute:(v="",f)=>{let{array:l,buffer:g}=m(v,f);r.queue.writeBuffer(g,0,l)},_uniform:(v,f)=>{d.num(f)&&(f=[f]);let{array:l,buffer:g}=b(v,f);l.set(f),r.queue.writeBuffer(g,0,l)},_texture:(v,f)=>{o.loadingImg++;let l=Object.assign(new Image,{src:f,crossOrigin:"anonymous"});l.decode().then(()=>{let{texture:g,width:B,height:Ye}=u(v,l);r.queue.copyExternalImageToTexture({source:l},{texture:g},{width:B,height:Ye}),o.loadingImg--})}}};var de=e=>d.obj(e)?"isGL"in e:!1,qe=()=>typeof window>"u",ke=()=>qe()?!1:"gpu"in navigator,xe=performance.now(),ge=e=>{let t=(0,R.event)({isNative:!1,isWebGL:!0,isLoop:!0,isGL:!0,size:[0,0],mouse:[0,0],count:6,webgl:{},webgpu:{}});return t.queue=(0,$.createQueue)(),t.frame=(0,$.createFrame)(),t.attribute=(0,R.durable)((r,n,o)=>t.queue(()=>t._attribute?.(r,n,o))),t.texture=(0,R.durable)((r,n)=>t.queue(()=>t._texture?.(r,n))),t.uniform=(0,R.durable)((r,n,o)=>t.queue(()=>t._uniform?.(r,n,o))),t.uniform({iResolution:t.size,iMouse:[0,0],iTime:xe}),t("mount",async()=>{t.vs=t.vs||t.vert||t.vertex,t.fs=t.fs||t.frag||t.fragment,ke()||(t.isWebGL=!0),t.isWebGL?t(await ne(t)):t(await me(t)),t.resize(),t.frame(()=>(t.loop(),t.queue.flush(),t.render(),t.isLoop)),!t.isNative&&(window.addEventListener("resize",t.resize),t.el.addEventListener("mousemove",t.mousemove))}),t("clean",()=>{t.frame.stop(),t.frame.clean(t.render),!t.isNative&&(window.removeEventListener("resize",t.resize),t.el.removeEventListener("mousemove",t.mousemove))}),t("resize",()=>{let r=t.width||window.innerWidth,n=t.height||window.innerHeight;t.size[0]=t.el.width=r,t.size[1]=t.el.height=n,t.uniform("iResolution",t.size)}),t("mousemove",(r,n=r.clientX,o=r.clientY)=>{let[s,a]=t.size,{top:i,left:m}=t.el.getBoundingClientRect();t.mouse[0]=(n-i-s/2)/(s/2),t.mouse[1]=-(o-m-a/2)/(a/2),t.uniform("iMouse",t.mouse)}),t("loop",()=>{xe=performance.now()/1e3,t.uniform("iTime",xe)}),t(e)};var Nt=e=>{let t=de(e)?e:ge(e);return t.ref=r=>{r?(t.el=r,t.mount()):t.clean()},t};0&&(module.exports={alignTo256,createAttrib,createBindGroup,createBufferLayout,createDescriptor,createDevice,createGL,createIbo,createPipeline,createProgram,createTexture,createTextureSampler,createUniformBuffer,createVbo,createVertexBuffer,defaultFragmentGLSL,defaultVertexGLSL,dig,each,ext,fig,flush,getStride,is,isGL,isServer,isWebGPUSupported,onGL,replace,sig,webgl,webgpu});
69
+ `,Ce=async e=>{let t=navigator.gpu,r=t.getPreferredCanvasFormat(),o=await(await t.requestAdapter()).requestDevice();return e.configure({device:o,format:r,alphaMode:"opaque"}),{device:o,format:r}},we=(e,t,r,n,o=_o,s=To)=>{L(o)&&(o=U(o,{isWebGL:!1})),L(s)&&(s=F(s,{isWebGL:!1}));let a=e.createPipelineLayout({bindGroupLayouts:n});return e.createRenderPipeline({vertex:{module:e.createShaderModule({code:o.trim()}),entryPoint:"main",buffers:r},fragment:{module:e.createShaderModule({code:s.trim()}),entryPoint:"main",targets:[{format:t}]},layout:a,primitive:{topology:"triangle-list"}})},Oe=(e,t)=>{let r=[],n=[];t.forEach((a,c)=>{if(!a)return;let x="buffer"in a,l=a instanceof GPUTextureView,p=a instanceof GPUSampler;if(x)r.push({binding:c,visibility:3,buffer:{type:"uniform"}});else if(l)r.push({binding:c,visibility:2,texture:{}});else if(p)r.push({binding:c,visibility:2,sampler:{}});else return;n.push({binding:c,resource:a})});let o=e.createBindGroupLayout({entries:r}),s=e.createBindGroup({layout:o,entries:n});return{layout:o,bindGroup:s}},Ge=e=>({colorAttachments:[{view:e.getCurrentTexture().createView(),clearValue:{r:0,g:0,b:0,a:1},loadOp:"clear",storeOp:"store"}]}),Qe=e=>Math.ceil(e/256)*256,Ie=(e,t)=>{let r=new Float32Array(t),n=e.createBuffer({size:r.byteLength,usage:40});return{array:r,buffer:n}},Fe=(e,t)=>{let r=new Float32Array(t),n=Qe(r.byteLength),o=e.createBuffer({size:n,usage:72});return{array:r,buffer:o}},Ue=(e,t=1280,r=800)=>{let n=e.createTexture({size:[t,r],format:"rgba8unorm",usage:22}),o=e.createSampler({magFilter:"linear",minFilter:"linear"});return{texture:n,sampler:o}},ho=(e,t)=>e/t,Eo=e=>e===2?"float32x2":e===3?"float32x3":e===4?"float32x4":"float32",Ae=(e,t,r=6)=>{let n=ho(t,r);return{arrayStride:n*4,attributes:[{shaderLocation:e,offset:0,format:Eo(n)}]}};var $e=async e=>{let t=e.el.getContext("webgpu"),{device:r,format:n}=await Ce(t),o={device:r,context:t,resources:[[],[]],loadingImg:0,needsUpdate:!0},s=[],a=[],c=[],x=(0,Q.nested)((T,d)=>{let{array:g,buffer:X}=Ie(r,d);return a.push(X),c.push(Ae(c.length,g.length,e.count)),o.needsUpdate=!0,{array:g,buffer:X}}),l=(0,Q.nested)((T,d)=>{let{array:g,buffer:X}=Fe(r,d);return o.resources[0].push({buffer:X}),o.needsUpdate=!0,{array:g,buffer:X}}),p=(0,Q.nested)((T,{width:d,height:g})=>{let{texture:X,sampler:ee}=Ue(r,d,g);return o.resources[1].push(ee,X.createView()),o.needsUpdate=!0,{texture:X,width:d,height:g}}),f=()=>{let T=[];s.length=0,o.resources.forEach(d=>{if(!d.length)return;let{layout:g,bindGroup:X}=Oe(r,d);T.push(g),s.push(X)}),o.pipeline=we(r,n,c,T,e.vs,e.fs)};return{webgpu:o,render:()=>{if(o.loadingImg)return;o.needsUpdate&&f(),o.needsUpdate=!1;let T=r.createCommandEncoder(),d=T.beginRenderPass(Ge(t));d.setPipeline(o.pipeline),s.forEach((g,X)=>d.setBindGroup(X,g)),a.forEach((g,X)=>d.setVertexBuffer(X,g)),d.draw(e.count,1,0,0),d.end(),r.queue.submit([T.finish()])},clean:()=>{},_attribute:(T="",d)=>{let{array:g,buffer:X}=x(T,d);r.queue.writeBuffer(X,0,g)},_uniform:(T,d)=>{b.num(d)&&(d=[d]);let{array:g,buffer:X}=l(T,d);g.set(d),r.queue.writeBuffer(X,0,g)},_texture:(T,d)=>{o.loadingImg++;let g=Object.assign(new Image,{src:d,crossOrigin:"anonymous"});g.decode().then(()=>{let{texture:X,width:ee,height:tt}=p(T,g);r.queue.copyExternalImageToTexture({source:g},{texture:X},{width:ee,height:tt}),o.loadingImg--})}}};var Me=e=>b.obj(e)?"isGL"in e:!1,Je=()=>typeof window>"u",et=()=>Je()?!1:"gpu"in navigator,Be=performance.now(),De=e=>{let t=(0,G.event)({isNative:!1,isWebGL:!0,isLoop:!0,isGL:!0,size:[0,0],mouse:[0,0],count:6,webgl:{},webgpu:{}});return t.queue=(0,J.createQueue)(),t.frame=(0,J.createFrame)(),t.attribute=(0,G.durable)((r,n,o)=>t.queue(()=>t._attribute?.(r,n,o))),t.texture=(0,G.durable)((r,n)=>t.queue(()=>t._texture?.(r,n))),t.uniform=(0,G.durable)((r,n,o)=>t.queue(()=>t._uniform?.(r,n,o))),t.uniform({iResolution:t.size,iMouse:[0,0],iTime:Be}),t("mount",async()=>{t.vs=t.vs||t.vert||t.vertex,t.fs=t.fs||t.frag||t.fragment,et()||(t.isWebGL=!0),t.isWebGL?t(await Re(t)):t(await $e(t)),t.resize(),t.frame(()=>(t.loop(),t.queue.flush(),t.render(),t.isLoop)),!t.isNative&&(window.addEventListener("resize",t.resize),t.el.addEventListener("mousemove",t.mousemove))}),t("clean",()=>{t.frame.stop(),t.frame.clean(t.render),!t.isNative&&(window.removeEventListener("resize",t.resize),t.el.removeEventListener("mousemove",t.mousemove))}),t("resize",()=>{let r=t.width||window.innerWidth,n=t.height||window.innerHeight;t.size[0]=t.el.width=r,t.size[1]=t.el.height=n,t.uniform("iResolution",t.size)}),t("mousemove",(r,n=r.clientX,o=r.clientY)=>{let[s,a]=t.size,{top:c,left:x}=t.el.getBoundingClientRect();t.mouse[0]=(n-c-s/2)/(s/2),t.mouse[1]=-(o-x-a/2)/(a/2),t.uniform("iMouse",t.mouse)}),t("loop",()=>{Be=performance.now()/1e3,t.uniform("iTime",Be)}),t(e)};var No=e=>{let t=Me(e)?e:De(e);return t.ref=r=>{r?(t.el=r,t.mount()):t.clean()},t};0&&(module.exports={ADDITIONAL_FUNCTIONS,BOOL_RETURN_FUNCTIONS,BUILTIN_TYPES,COMPARISON_OPERATORS,COMPONENT_COUNT_TO_TYPE,CONSTANTS,CONVERSIONS,FIRST_ARG_TYPE_FUNCTIONS,FUNCTIONS,Fn,HIGHEST_TYPE_FUNCTIONS,If,LOGICAL_OPERATORS,Loop,OPERATORS,OPERATOR_KEYS,PRESERVE_TYPE_FUNCTIONS,SCALAR_RETURN_FUNCTIONS,SWIZZLES,Switch,TYPE_MAPPING,VEC3_RETURN_FUNCTIONS,VEC4_RETURN_FUNCTIONS,WGSL_TO_GLSL_BUILTIN,abs,acos,alignTo256,all,any,asin,assign,atan,atan2,attribute,bitcast,bool,builtin,bvec2,bvec3,bvec4,cbrt,ceil,clamp,code,color,constant,conversion,conversionToConstant,cos,createAttrib,createBindGroup,createBufferLayout,createDescriptor,createDevice,createGL,createIbo,createPipeline,createProgram,createTexture,createTextureSampler,createUniformBuffer,createVbo,createVertexBuffer,cross,cubeTexture,dFdx,dFdy,defaultFragmentGLSL,defaultVertexGLSL,degrees,difference,dig,distance,dot,each,equals,exp,exp2,ext,faceforward,fig,float,floor,flush,formatConversions,fract,fragDepth,fragment,frontFacing,function_,fwidth,generateDefine,getBluiltin,getId,getOperator,getStride,hex2rgb,iMouse,iResolution,iTime,infer,inferImpl,instanceIndex,int,inverseSqrt,is,isConversion,isFunction,isGL,isNodeProxy,isOperator,isServer,isSwizzle,isWebGPUSupported,ivec2,ivec3,ivec4,joins,length,lengthSq,log,log2,mat2,mat3,mat4,max,min,mix,negate,node,normalLocal,normalView,normalWorld,normalize,onGL,oneMinus,operator,pointCoord,position,positionLocal,positionView,positionWorld,pow,pow2,pow3,pow4,radians,reciprocal,reflect,refract,replace,round,sampleIndex,sampleMask,saturate,screenCoordinate,screenUV,select,sig,sign,sin,smoothstep,sqrt,step,swizzle,tan,texture,textureSize,toVar,transformDirection,trunc,uint,uniform,uvec2,uvec3,uvec4,variable,varying,vec2,vec3,vec4,vertex,vertexIndex,webgl,webgpu});
70
70
  //# sourceMappingURL=solid.cjs.map