typegpu
Version:
A thin layer between JS and WebGPU/WGSL that improves development experience and allows for faster iteration.
2 lines • 15.9 kB
JavaScript
Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { newObj[key] = obj[key]; } } } newObj.default = obj; return newObj; } }var _chunkCDUKTYEScjs = require('../chunk-CDUKTYES.cjs');var _chunkBJSN5UVVcjs = require('../chunk-BJSN5UVV.cjs');var Ve=_chunkBJSN5UVVcjs.ga.call(void 0, ()=>{throw new Error("discard() can only be used on the GPU.")},()=>_chunkBJSN5UVVcjs.da.call(void 0, "discard;",_chunkBJSN5UVVcjs.A),"discard");var Ue=_chunkBJSN5UVVcjs.ga.call(void 0, (e,t)=>_chunkCDUKTYEScjs.f.call(void 0, _chunkBJSN5UVVcjs.Oa.translation(t),e),(e,t)=>({value:`(${_chunkBJSN5UVVcjs.Oa.translation(t).value} * ${e.value})`,dataType:e.dataType}),"translate4"),Ee= exports.scale4 =_chunkBJSN5UVVcjs.ga.call(void 0, (e,t)=>_chunkCDUKTYEScjs.f.call(void 0, _chunkBJSN5UVVcjs.Oa.scaling(t),e),(e,t)=>({value:`(${_chunkBJSN5UVVcjs.Oa.scaling(t).value} * ${e.value})`,dataType:e.dataType}),"scale4"),Oe= exports.rotateX4 =_chunkBJSN5UVVcjs.ga.call(void 0, (e,t)=>_chunkCDUKTYEScjs.f.call(void 0, _chunkBJSN5UVVcjs.Oa.rotationX(t),e),(e,t)=>({value:`(${_chunkBJSN5UVVcjs.Oa.rotationX(t).value} * ${e.value})`,dataType:e.dataType}),"rotateX4"),Le= exports.rotateY4 =_chunkBJSN5UVVcjs.ga.call(void 0, (e,t)=>_chunkCDUKTYEScjs.f.call(void 0, _chunkBJSN5UVVcjs.Oa.rotationY(t),e),(e,t)=>({value:`(${_chunkBJSN5UVVcjs.Oa.rotationY(t).value} * ${e.value})`,dataType:e.dataType}),"rotateY4"),_e= exports.rotateZ4 =_chunkBJSN5UVVcjs.ga.call(void 0, (e,t)=>_chunkCDUKTYEScjs.f.call(void 0, _chunkBJSN5UVVcjs.Oa.rotationZ(t),e),(e,t)=>({value:`(${_chunkBJSN5UVVcjs.Oa.rotationZ(t).value} * ${e.value})`,dataType:e.dataType}),"rotateZ4");function g(e){return e.dataType.type.includes("2")?_chunkBJSN5UVVcjs.sa:e.dataType.type.includes("3")?_chunkBJSN5UVVcjs.xa:_chunkBJSN5UVVcjs.Ca}var Pe=_chunkBJSN5UVVcjs.ga.call(void 0, (e,t)=>k(b(e,t)),(e,t)=>_chunkBJSN5UVVcjs.da.call(void 0, `all(${e.value} == ${t.value})`,_chunkBJSN5UVVcjs.ja),"allEq"),b= exports.eq =_chunkBJSN5UVVcjs.ga.call(void 0, (e,t)=>_chunkCDUKTYEScjs.a.eq[e.kind](e,t),(e,t)=>_chunkBJSN5UVVcjs.da.call(void 0, `(${e.value} == ${t.value})`,g(e)),"eq"),he= exports.ne =_chunkBJSN5UVVcjs.ga.call(void 0, (e,t)=>m(b(e,t)),(e,t)=>_chunkBJSN5UVVcjs.da.call(void 0, `(${e.value} != ${t.value})`,g(e)),"ne"),w= exports.lt =_chunkBJSN5UVVcjs.ga.call(void 0, (e,t)=>_chunkCDUKTYEScjs.a.lt[e.kind](e,t),(e,t)=>_chunkBJSN5UVVcjs.da.call(void 0, `(${e.value} < ${t.value})`,g(e)),"lt"),Ge= exports.le =_chunkBJSN5UVVcjs.ga.call(void 0, (e,t)=>B(w(e,t),b(e,t)),(e,t)=>_chunkBJSN5UVVcjs.da.call(void 0, `(${e.value} <= ${t.value})`,g(e)),"le"),Ne= exports.gt =_chunkBJSN5UVVcjs.ga.call(void 0, (e,t)=>J(m(w(e,t)),m(b(e,t))),(e,t)=>_chunkBJSN5UVVcjs.da.call(void 0, `(${e.value} > ${t.value})`,g(e)),"gt"),Fe= exports.ge =_chunkBJSN5UVVcjs.ga.call(void 0, (e,t)=>m(w(e,t)),(e,t)=>_chunkBJSN5UVVcjs.da.call(void 0, `(${e.value} >= ${t.value})`,g(e)),"ge"),m= exports.not =_chunkBJSN5UVVcjs.ga.call(void 0, e=>_chunkCDUKTYEScjs.a.neg[e.kind](e),e=>_chunkBJSN5UVVcjs.da.call(void 0, `!(${e.value})`,e.dataType),"not"),B= exports.or =_chunkBJSN5UVVcjs.ga.call(void 0, (e,t)=>_chunkCDUKTYEScjs.a.or[e.kind](e,t),(e,t)=>_chunkBJSN5UVVcjs.da.call(void 0, `(${e.value} | ${t.value})`,e.dataType),"or"),J= exports.and =_chunkBJSN5UVVcjs.ga.call(void 0, (e,t)=>m(B(m(e),m(t))),(e,t)=>_chunkBJSN5UVVcjs.da.call(void 0, `(${e.value} & ${t.value})`,e.dataType),"and"),k= exports.all =_chunkBJSN5UVVcjs.ga.call(void 0, e=>_chunkCDUKTYEScjs.a.all[e.kind](e),e=>_chunkBJSN5UVVcjs.da.call(void 0, `all(${e.value})`,_chunkBJSN5UVVcjs.ja),"all"),We= exports.any =_chunkBJSN5UVVcjs.ga.call(void 0, e=>!k(m(e)),e=>_chunkBJSN5UVVcjs.da.call(void 0, `any(${e.value})`,_chunkBJSN5UVVcjs.ja),"any"),Xe= exports.isCloseTo =_chunkBJSN5UVVcjs.ga.call(void 0, (e,t,o=.01)=>typeof e=="number"&&typeof t=="number"?Math.abs(e-t)<o:_chunkBJSN5UVVcjs.B.call(void 0, e)&&_chunkBJSN5UVVcjs.B.call(void 0, t)?_chunkCDUKTYEScjs.a.isCloseToZero[e.kind](_chunkCDUKTYEScjs.e.call(void 0, e,t),o):!1,(e,t,o=_chunkBJSN5UVVcjs.da.call(void 0, .01,_chunkBJSN5UVVcjs.ma))=>_chunkCDUKTYEScjs.b.call(void 0, e)&&_chunkCDUKTYEScjs.b.call(void 0, t)?_chunkBJSN5UVVcjs.da.call(void 0, `(abs(f32(${e.value}) - f32(${t.value})) <= ${o.value})`,_chunkBJSN5UVVcjs.ja):!_chunkCDUKTYEScjs.b.call(void 0, e)&&!_chunkCDUKTYEScjs.b.call(void 0, t)?_chunkBJSN5UVVcjs.da.call(void 0, `all(abs(${e.value} - ${t.value}) <= (${e.value} - ${e.value}) + ${o.value})`,_chunkBJSN5UVVcjs.ja):_chunkBJSN5UVVcjs.da.call(void 0, "false",_chunkBJSN5UVVcjs.ja),"isCloseTo"),Je= exports.select =_chunkBJSN5UVVcjs.ga.call(void 0, (e,t,o)=>typeof o=="boolean"?o?t:e:_chunkCDUKTYEScjs.a.select[e.kind](e,t,o),(e,t,o)=>_chunkBJSN5UVVcjs.da.call(void 0, `select(${e.value}, ${t.value}, ${o.value})`,e.dataType),"select");var Me=_chunkBJSN5UVVcjs.ga.call(void 0, ()=>console.warn("workgroupBarrier is a no-op outside of GPU mode."),()=>_chunkBJSN5UVVcjs.da.call(void 0, "workgroupBarrier()",_chunkBJSN5UVVcjs.A),"workgroupBarrier"),qe= exports.storageBarrier =_chunkBJSN5UVVcjs.ga.call(void 0, ()=>console.warn("storageBarrier is a no-op outside of GPU mode."),()=>_chunkBJSN5UVVcjs.da.call(void 0, "storageBarrier()",_chunkBJSN5UVVcjs.A),"storageBarrier"),Ce= exports.textureBarrier =_chunkBJSN5UVVcjs.ga.call(void 0, ()=>console.warn("textureBarrier is a no-op outside of GPU mode."),()=>_chunkBJSN5UVVcjs.da.call(void 0, "textureBarrier()",_chunkBJSN5UVVcjs.A),"textureBarrier"),Ze= exports.atomicLoad =_chunkBJSN5UVVcjs.ga.call(void 0, e=>{throw new Error("Atomic operations are not supported outside of GPU mode.")},e=>{if(_chunkBJSN5UVVcjs.K.call(void 0, e.dataType)&&e.dataType.type==="atomic")return _chunkBJSN5UVVcjs.da.call(void 0, `atomicLoad(&${e.value})`,e.dataType.inner);throw new Error(`Invalid atomic type: ${JSON.stringify(e.dataType,null,2)}`)},"atomicLoad"),Ye= exports.atomicStore =_chunkBJSN5UVVcjs.ga.call(void 0, (e,t)=>{throw new Error("Atomic operations are not supported outside of GPU mode.")},(e,t)=>{if(!_chunkBJSN5UVVcjs.K.call(void 0, e.dataType)||e.dataType.type!=="atomic")throw new Error(`Invalid atomic type: ${JSON.stringify(e.dataType,null,2)}`);return _chunkBJSN5UVVcjs.da.call(void 0, `atomicStore(&${e.value}, ${t.value})`,_chunkBJSN5UVVcjs.A)},"atomicStore"),f=(e,t)=>e.dataType.type==="atomic"&&e.dataType.inner.type==="i32"?[e.dataType,_chunkBJSN5UVVcjs.la]:[e.dataType,_chunkBJSN5UVVcjs.ka],je= exports.atomicAdd =_chunkBJSN5UVVcjs.ga.call(void 0, (e,t)=>{throw new Error("Atomic operations are not supported outside of GPU mode.")},(e,t)=>{if(_chunkBJSN5UVVcjs.K.call(void 0, e.dataType)&&e.dataType.type==="atomic")return _chunkBJSN5UVVcjs.da.call(void 0, `atomicAdd(&${e.value}, ${t.value})`,e.dataType.inner);throw new Error(`Invalid atomic type: ${JSON.stringify(e.dataType,null,2)}`)},"atomicAdd",f),Re= exports.atomicSub =_chunkBJSN5UVVcjs.ga.call(void 0, (e,t)=>{throw new Error("Atomic operations are not supported outside of GPU mode.")},(e,t)=>{if(_chunkBJSN5UVVcjs.K.call(void 0, e.dataType)&&e.dataType.type==="atomic")return _chunkBJSN5UVVcjs.da.call(void 0, `atomicSub(&${e.value}, ${t.value})`,e.dataType.inner);throw new Error(`Invalid atomic type: ${JSON.stringify(e.dataType,null,2)}`)},"atomicSub",f),ze= exports.atomicMax =_chunkBJSN5UVVcjs.ga.call(void 0, (e,t)=>{throw new Error("Atomic operations are not supported outside of GPU mode.")},(e,t)=>{if(_chunkBJSN5UVVcjs.K.call(void 0, e.dataType)&&e.dataType.type==="atomic")return _chunkBJSN5UVVcjs.da.call(void 0, `atomicMax(&${e.value}, ${t.value})`,e.dataType.inner);throw new Error(`Invalid atomic type: ${JSON.stringify(e.dataType,null,2)}`)},"atomicMax",f),He= exports.atomicMin =_chunkBJSN5UVVcjs.ga.call(void 0, (e,t)=>{throw new Error("Atomic operations are not supported outside of GPU mode.")},(e,t)=>{if(_chunkBJSN5UVVcjs.K.call(void 0, e.dataType)&&e.dataType.type==="atomic")return _chunkBJSN5UVVcjs.da.call(void 0, `atomicMin(&${e.value}, ${t.value})`,e.dataType.inner);throw new Error(`Invalid atomic type: ${JSON.stringify(e.dataType,null,2)}`)},"atomicMin",f),Ke= exports.atomicAnd =_chunkBJSN5UVVcjs.ga.call(void 0, (e,t)=>{throw new Error("Atomic operations are not supported outside of GPU mode.")},(e,t)=>{if(_chunkBJSN5UVVcjs.K.call(void 0, e.dataType)&&e.dataType.type==="atomic")return _chunkBJSN5UVVcjs.da.call(void 0, `atomicAnd(&${e.value}, ${t.value})`,e.dataType.inner);throw new Error(`Invalid atomic type: ${JSON.stringify(e.dataType,null,2)}`)},"atomicAnd",f),Qe= exports.atomicOr =_chunkBJSN5UVVcjs.ga.call(void 0, (e,t)=>{throw new Error("Atomic operations are not supported outside of GPU mode.")},(e,t)=>{if(_chunkBJSN5UVVcjs.K.call(void 0, e.dataType)&&e.dataType.type==="atomic")return _chunkBJSN5UVVcjs.da.call(void 0, `atomicOr(&${e.value}, ${t.value})`,e.dataType.inner);throw new Error(`Invalid atomic type: ${JSON.stringify(e.dataType,null,2)}`)},"atomicOr",f),et= exports.atomicXor =_chunkBJSN5UVVcjs.ga.call(void 0, (e,t)=>{throw new Error("Atomic operations are not supported outside of GPU mode.")},(e,t)=>{if(_chunkBJSN5UVVcjs.K.call(void 0, e.dataType)&&e.dataType.type==="atomic")return _chunkBJSN5UVVcjs.da.call(void 0, `atomicXor(&${e.value}, ${t.value})`,e.dataType.inner);throw new Error(`Invalid atomic type: ${JSON.stringify(e.dataType,null,2)}`)},"atomicXor",f);var tt=_chunkBJSN5UVVcjs.ga.call(void 0, e=>e.length,e=>_chunkBJSN5UVVcjs.N.call(void 0, e.dataType)&&_chunkBJSN5UVVcjs.L.call(void 0, e.dataType.inner)&&e.dataType.inner.elementCount>0?_chunkBJSN5UVVcjs.da.call(void 0, String(e.dataType.inner.elementCount),_chunkBJSN5UVVcjs.ha):_chunkBJSN5UVVcjs.da.call(void 0, `arrayLength(${e.value})`,_chunkBJSN5UVVcjs.ka),"arrayLength",e=>[_chunkBJSN5UVVcjs.Qa.call(void 0, e.dataType)]);var _typedbinary = require('typed-binary'); var d = _interopRequireWildcard(_typedbinary);var rt=_chunkBJSN5UVVcjs.ga.call(void 0, e=>{let t=new ArrayBuffer(4);new d.BufferWriter(t).writeUint32(e);let n=new d.BufferReader(t);return _chunkBJSN5UVVcjs.oa.call(void 0, n.readFloat16(),n.readFloat16())},e=>_chunkBJSN5UVVcjs.da.call(void 0, `unpack2x16float(${e.value})`,_chunkBJSN5UVVcjs.oa),"unpack2x16float"),at= exports.pack2x16float =_chunkBJSN5UVVcjs.ga.call(void 0, e=>{let t=new ArrayBuffer(4),o=new d.BufferWriter(t);o.writeFloat16(e.x),o.writeFloat16(e.y);let n=new d.BufferReader(t);return _chunkBJSN5UVVcjs.ka.call(void 0, n.readUint32())},e=>_chunkBJSN5UVVcjs.da.call(void 0, `pack2x16float(${e.value})`,_chunkBJSN5UVVcjs.ka),"pack2x16float"),ot= exports.unpack4x8unorm =_chunkBJSN5UVVcjs.ga.call(void 0, e=>{let t=new ArrayBuffer(4);new d.BufferWriter(t).writeUint32(e);let n=new d.BufferReader(t);return _chunkBJSN5UVVcjs.ya.call(void 0, n.readUint8()/255,n.readUint8()/255,n.readUint8()/255,n.readUint8()/255)},e=>_chunkBJSN5UVVcjs.da.call(void 0, `unpack4x8unorm(${e.value})`,_chunkBJSN5UVVcjs.ya),"unpack4x8unorm"),nt= exports.pack4x8unorm =_chunkBJSN5UVVcjs.ga.call(void 0, e=>{let t=new ArrayBuffer(4),o=new d.BufferWriter(t);o.writeUint8(e.x*255),o.writeUint8(e.y*255),o.writeUint8(e.z*255),o.writeUint8(e.w*255);let n=new d.BufferReader(t);return _chunkBJSN5UVVcjs.ka.call(void 0, n.readUint32())},e=>_chunkBJSN5UVVcjs.da.call(void 0, `pack4x8unorm(${e.value})`,_chunkBJSN5UVVcjs.ka),"pack4x8unorm");var ut=_chunkBJSN5UVVcjs.ga.call(void 0, (e,t,o,n,u)=>{throw new Error("Texture sampling is not supported outside of GPU mode.")},(e,t,o,n,u)=>{let l=[e,t,o];return n!==void 0&&l.push(n),u!==void 0&&l.push(u),_chunkBJSN5UVVcjs.da.call(void 0, `textureSample(${l.map($=>$.value).join(", ")})`,_chunkBJSN5UVVcjs.ya)},"textureSample"),pt= exports.textureSampleLevel =_chunkBJSN5UVVcjs.ga.call(void 0, (e,t,o,n,u)=>{throw new Error("Texture sampling is not supported outside of GPU mode.")},(e,t,o,n,u)=>{let l=[e,t,o,n];return u!==void 0&&l.push(u),_chunkBJSN5UVVcjs.da.call(void 0, `textureSampleLevel(${l.map($=>$.value).join(", ")})`,_chunkBJSN5UVVcjs.ya)},"textureSampleLevel"),it={u32:_chunkBJSN5UVVcjs.Ba,i32:_chunkBJSN5UVVcjs.Aa,f32:_chunkBJSN5UVVcjs.ya},Tt= exports.textureLoad =_chunkBJSN5UVVcjs.ga.call(void 0, (e,t,o)=>{throw new Error("Texture loading is not supported outside of GPU mode.")},(e,t,o)=>{let n=[e,t];o!==void 0&&n.push(o);let u=e.dataType;return _chunkBJSN5UVVcjs.da.call(void 0, `textureLoad(${n.map(l=>l.value).join(", ")})`,"texelDataType"in u?u.texelDataType:it[u.channelDataType.type])},"textureLoad"),dt= exports.textureStore =_chunkBJSN5UVVcjs.ga.call(void 0, (e,t,o,n)=>{throw new Error("Texture storing is not supported outside of GPU mode.")},(e,t,o,n)=>_chunkBJSN5UVVcjs.da.call(void 0, `textureStore(${[e,t,o,n].filter(u=>u!==void 0).map(u=>u.value).join(", ")})`,_chunkBJSN5UVVcjs.A),"textureStore"),st= exports.textureDimensions =_chunkBJSN5UVVcjs.ga.call(void 0, (e,t)=>{throw new Error("Texture dimensions are not supported outside of GPU mode.")},(e,t)=>{let o=e.dataType.dimension;return _chunkBJSN5UVVcjs.da.call(void 0, `textureDimensions(${e.value}${t!==void 0?`, ${t.value}`:""})`,o==="1d"?_chunkBJSN5UVVcjs.ka:o==="3d"?_chunkBJSN5UVVcjs.wa:_chunkBJSN5UVVcjs.ra)},"textureDimensions");exports.abs = _chunkCDUKTYEScjs.h; exports.acos = _chunkCDUKTYEScjs.j; exports.acosh = _chunkCDUKTYEScjs.k; exports.add = _chunkCDUKTYEScjs.d; exports.all = k; exports.allEq = Pe; exports.and = J; exports.any = We; exports.arrayLength = tt; exports.asin = _chunkCDUKTYEScjs.l; exports.atan2 = _chunkCDUKTYEScjs.i; exports.atomicAdd = je; exports.atomicAnd = Ke; exports.atomicLoad = Ze; exports.atomicMax = ze; exports.atomicMin = He; exports.atomicOr = Qe; exports.atomicStore = Ye; exports.atomicSub = Re; exports.atomicXor = et; exports.ceil = _chunkCDUKTYEScjs.m; exports.clamp = _chunkCDUKTYEScjs.n; exports.cos = _chunkCDUKTYEScjs.o; exports.cosh = _chunkCDUKTYEScjs.p; exports.cross = _chunkCDUKTYEScjs.q; exports.discard = Ve; exports.distance = _chunkCDUKTYEScjs.H; exports.div = _chunkCDUKTYEScjs.g; exports.dot = _chunkCDUKTYEScjs.r; exports.eq = b; exports.exp = _chunkCDUKTYEScjs.C; exports.exp2 = _chunkCDUKTYEScjs.D; exports.floor = _chunkCDUKTYEScjs.t; exports.fract = _chunkCDUKTYEScjs.u; exports.ge = Fe; exports.gt = Ne; exports.identity2 = _chunkBJSN5UVVcjs.Ea; exports.identity3 = _chunkBJSN5UVVcjs.Fa; exports.identity4 = _chunkBJSN5UVVcjs.Ga; exports.isCloseTo = Xe; exports.le = Ge; exports.length = _chunkCDUKTYEScjs.v; exports.log = _chunkCDUKTYEScjs.w; exports.log2 = _chunkCDUKTYEScjs.x; exports.lt = w; exports.max = _chunkCDUKTYEScjs.y; exports.min = _chunkCDUKTYEScjs.z; exports.mix = _chunkCDUKTYEScjs.F; exports.mul = _chunkCDUKTYEScjs.f; exports.ne = he; exports.neg = _chunkCDUKTYEScjs.I; exports.normalize = _chunkCDUKTYEScjs.s; exports.not = m; exports.or = B; exports.pack2x16float = at; exports.pack4x8unorm = nt; exports.pow = _chunkCDUKTYEScjs.E; exports.reflect = _chunkCDUKTYEScjs.G; exports.rotateX4 = Oe; exports.rotateY4 = Le; exports.rotateZ4 = _e; exports.rotationX4 = _chunkBJSN5UVVcjs.Ja; exports.rotationY4 = _chunkBJSN5UVVcjs.Ka; exports.rotationZ4 = _chunkBJSN5UVVcjs.La; exports.scale4 = Ee; exports.scaling4 = _chunkBJSN5UVVcjs.Ia; exports.select = Je; exports.sign = _chunkCDUKTYEScjs.A; exports.sin = _chunkCDUKTYEScjs.B; exports.sqrt = _chunkCDUKTYEScjs.J; exports.storageBarrier = qe; exports.sub = _chunkCDUKTYEScjs.e; exports.tanh = _chunkCDUKTYEScjs.K; exports.textureBarrier = Ce; exports.textureDimensions = st; exports.textureLoad = Tt; exports.textureSample = ut; exports.textureSampleLevel = pt; exports.textureStore = dt; exports.translate4 = Ue; exports.translation4 = _chunkBJSN5UVVcjs.Ha; exports.unpack2x16float = rt; exports.unpack4x8unorm = ot; exports.workgroupBarrier = Me;
//# sourceMappingURL=index.cjs.map
;