typegpu 0.8.2 → 0.9.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/chunk-6U5HPHCJ.js DELETED
@@ -1,2 +0,0 @@
1
- import{a as D,ib as O}from"./chunk-ECR2EGZX.js";import{C as y,D as f,E as m,F as d,L as x,La as P,R as g,S as T,T as A,W as B,Wa as l,a as o,aa as I,j as W,k as w,qc as h}from"./chunk-CRZWTZM2.js";function E(t){return u("function",t,"read-write")}function V(t){return u("private",t,"read-write")}function U(t){return u("workgroup",t,"read-write")}function $(t,e="read"){return u("storage",t,e)}function C(t){return u("uniform",t,"read")}function L(t){return u("handle",t,"read")}function u(t,e,r){return{[o]:!0,type:"ptr",addressSpace:t,inner:e,access:r}}var k=P(((t,e)=>e===void 0?r=>b(t,r):b(t,e)),(t,e)=>{if(e===void 0||e.value===void 0){let r=a=>k[o].gpuImpl(t,a);return r[o]=!0,I(r,B)}if(typeof e.value!="number")throw new Error(`Cannot create disarray schema with count unknown at compile-time: '${e.value}'`);return I(b(t.value,e.value),t.value)},"disarrayOf");function b(t,e){let r=a=>{if(a&&a.length!==e)throw new Error(`Disarray schema of ${e} elements of type ${t.type} called with ${a.length} argument(s).`);return Array.from({length:e},(s,n)=>h(t,a?.[n]))};if(Object.setPrototypeOf(r,M),r.elementType=t,!Number.isInteger(e)||e<0)throw new Error(`Cannot create disarray schema with invalid element count: ${e}.`);return r.elementCount=e,r}var M={[o]:!0,type:"disarray",toString(){return`disarrayOf(${this.elementType}, ${this.elementCount})`}};function j(t){let e=r=>Object.fromEntries(Object.entries(t).map(([a,s])=>[a,h(s,r?.[a])]));return Object.setPrototypeOf(e,F),e.propTypes=t,e}var F={[o]:!0,type:"unstruct",$name(t){return w(this,t),this},toString(){return`unstruct:${W(this)??"<unnamed>"}`}};function c(t,e){if(t===e)return!0;if(t.type!==e.type)return!1;if(f(t)&&f(e)||T(t)&&T(e)){let r=t.propTypes,a=e.propTypes,s=Object.keys(r),n=Object.keys(a);if(s.length!==n.length)return!1;for(let i=0;i<s.length;i++){let S=s[i],v=n[i];if(S!==v||!S||!v||!c(r[S],a[v]))return!1}return!0}if(y(t)&&y(e)||g(t)&&g(e))return t.elementCount===e.elementCount&&c(t.elementType,e.elementType);if(m(t)&&m(e))return t.addressSpace===e.addressSpace&&t.access===e.access&&c(t.inner,e.inner);if(d(t)&&d(e))return c(t.inner,e.inner);if(x(t)&&x(e)||A(t)&&A(e)){if(!c(t.inner,e.inner)||t.attribs.length!==e.attribs.length)return!1;let r=n=>{let i=n;return`${i.type}(${(i.params??[]).join(",")})`},a=t.attribs.map(r),s=e.attribs.map(r);for(let n=0;n<a.length;n++)if(a[n]!==s[n])return!1}return!0}function p(t,e){let r=t.prototype,a=O[e][o].jsImpl;r[e]=function(s){return a(this,s)}}p(l,"add");p(l,"sub");p(l,"mul");p(l,"div");p(D,"add");p(D,"sub");p(D,"mul");export{E as a,V as b,U as c,$ as d,C as e,L as f,k as g,j as h,c as i};
2
- //# sourceMappingURL=chunk-6U5HPHCJ.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/data/ptr.ts","../src/data/disarray.ts","../src/data/unstruct.ts","../src/data/deepEqual.ts","../src/data/index.ts"],"sourcesContent":["import { $internal } from '../shared/symbols.ts';\nimport type { Access, AddressSpace, Ptr, StorableData } from './wgslTypes.ts';\n\nexport function ptrFn<T extends StorableData>(\n inner: T,\n): Ptr<'function', T, 'read-write'> {\n return INTERNAL_createPtr('function', inner, 'read-write');\n}\n\nexport function ptrPrivate<T extends StorableData>(\n inner: T,\n): Ptr<'private', T, 'read-write'> {\n return INTERNAL_createPtr('private', inner, 'read-write');\n}\n\nexport function ptrWorkgroup<T extends StorableData>(\n inner: T,\n): Ptr<'workgroup', T, 'read-write'> {\n return INTERNAL_createPtr('workgroup', inner, 'read-write');\n}\n\nexport function ptrStorage<\n T extends StorableData,\n TAccess extends 'read' | 'read-write' = 'read',\n>(inner: T, access: TAccess = 'read' as TAccess): Ptr<'storage', T, TAccess> {\n return INTERNAL_createPtr('storage', inner, access);\n}\n\nexport function ptrUniform<T extends StorableData>(\n inner: T,\n): Ptr<'uniform', T, 'read'> {\n return INTERNAL_createPtr('uniform', inner, 'read');\n}\n\nexport function ptrHandle<T extends StorableData>(\n inner: T,\n): Ptr<'handle', T, 'read'> {\n return INTERNAL_createPtr('handle', inner, 'read');\n}\n\nfunction INTERNAL_createPtr<\n TAddressSpace extends AddressSpace,\n TInner extends StorableData,\n TAccess extends Access,\n>(\n addressSpace: TAddressSpace,\n inner: TInner,\n access: TAccess,\n): Ptr<TAddressSpace, TInner, TAccess> {\n return {\n [$internal]: true,\n type: 'ptr',\n addressSpace,\n inner,\n access,\n } as Ptr<TAddressSpace, TInner, TAccess>;\n}\n","import { createDualImpl } from '../core/function/dualImpl.ts';\nimport { $internal } from '../shared/symbols.ts';\nimport { UnknownData } from './dataTypes.ts';\nimport { snip, type Snippet } from './snippet.ts';\nimport type { AnyData, Disarray } from './dataTypes.ts';\nimport { schemaCallWrapper } from './schemaCallWrapper.ts';\nimport type { AnyWgslData } from './wgslTypes.ts';\n\n// ----------\n// Public API\n// ----------\n\ninterface DisarrayConstructor {\n <TElement extends AnyData>(\n elementType: TElement,\n ): (elementCount: number) => Disarray<TElement>;\n\n <TElement extends AnyData>(\n elementType: TElement,\n elementCount: number,\n ): Disarray<TElement>;\n}\n\n/**\n * Creates an array schema that can be used to construct vertex buffers.\n * Describes arrays with fixed-size length, storing elements of the same type.\n *\n * Elements in the schema are not aligned in respect to their `byteAlignment`,\n * unless they are explicitly decorated with the custom align attribute\n * via `d.align` function.\n *\n * @example\n * const disarray = d.disarrayOf(d.vec3f, 3); // packed array of vec3f\n *\n * @example\n * const disarray = d.disarrayOf(d.align(16, d.vec3f), 3);\n *\n * If `elementCount` is not specified, a partially applied function is returned.\n * @example\n * const disarray = d.disarrayOf(d.vec3f);\n * // ^? (n: number) => Disarray<d.Vec3f>\n *\n * @param elementType The type of elements in the array.\n * @param elementCount The number of elements in the array.\n */\nexport const disarrayOf = createDualImpl(\n // JS implementation\n ((elementType, elementCount) => {\n if (elementCount === undefined) {\n return (count: number) => cpu_disarrayOf(elementType, count);\n }\n return cpu_disarrayOf(elementType, elementCount);\n }) as DisarrayConstructor,\n // CODEGEN implementation\n (elementType, elementCount) => {\n if (elementCount === undefined || elementCount.value === undefined) {\n const partial = (count: Snippet) =>\n disarrayOf[$internal].gpuImpl(elementType, count);\n // Marking so the WGSL generator lets this function through\n partial[$internal] = true;\n\n return snip(partial, UnknownData);\n }\n\n if (typeof elementCount.value !== 'number') {\n throw new Error(\n `Cannot create disarray schema with count unknown at compile-time: '${elementCount.value}'`,\n );\n }\n\n return snip(\n cpu_disarrayOf(elementType.value as AnyWgslData, elementCount.value),\n elementType.value as AnyWgslData,\n );\n },\n 'disarrayOf',\n);\n\nexport function cpu_disarrayOf<TElement extends AnyData>(\n elementType: TElement,\n elementCount: number,\n): Disarray<TElement> {\n // In the schema call, create and return a deep copy\n // by wrapping all the values in `elementType` schema calls.\n const disarraySchema = (elements?: TElement[]) => {\n if (elements && elements.length !== elementCount) {\n throw new Error(\n `Disarray schema of ${elementCount} elements of type ${elementType.type} called with ${elements.length} argument(s).`,\n );\n }\n\n return Array.from(\n { length: elementCount },\n (_, i) => schemaCallWrapper(elementType, elements?.[i]),\n );\n };\n Object.setPrototypeOf(disarraySchema, DisarrayImpl);\n\n disarraySchema.elementType = elementType;\n\n if (!Number.isInteger(elementCount) || elementCount < 0) {\n throw new Error(\n `Cannot create disarray schema with invalid element count: ${elementCount}.`,\n );\n }\n disarraySchema.elementCount = elementCount;\n\n return disarraySchema as unknown as Disarray<TElement>;\n}\n\n// --------------\n// Implementation\n// --------------\n\nconst DisarrayImpl = {\n [$internal]: true,\n type: 'disarray',\n\n toString(this: Disarray): string {\n return `disarrayOf(${this.elementType}, ${this.elementCount})`;\n },\n};\n","import { getName, setName } from '../shared/meta.ts';\nimport { $internal } from '../shared/symbols.ts';\nimport type { AnyData, Unstruct } from './dataTypes.ts';\nimport { schemaCallWrapper } from './schemaCallWrapper.ts';\nimport type { BaseData } from './wgslTypes.ts';\n\n// ----------\n// Public API\n// ----------\n\n/**\n * Creates a loose struct schema that can be used to construct vertex buffers.\n * Describes structs with members of both loose and non-loose types.\n *\n * The order of members matches the passed in properties object.\n * Members are not aligned in respect to their `byteAlignment`,\n * unless they are explicitly decorated with the custom align attribute\n * via `d.align` function.\n *\n * @example\n * const CircleStruct = d.unstruct({ radius: d.f32, pos: d.vec3f }); // packed struct with no padding\n *\n * @example\n * const CircleStruct = d.unstruct({ radius: d.f32, pos: d.align(16, d.vec3f) });\n *\n * @param properties Record with `string` keys and `TgpuData` or `TgpuLooseData` values,\n * each entry describing one struct member.\n */\nexport function unstruct<TProps extends Record<string, BaseData>>(\n properties: TProps,\n): Unstruct<TProps> {\n // In the schema call, create and return a deep copy\n // by wrapping all the values in corresponding schema calls.\n const unstructSchema = (instanceProps?: TProps) =>\n Object.fromEntries(\n Object.entries(properties).map(([key, schema]) => [\n key,\n schemaCallWrapper(schema as AnyData, instanceProps?.[key]),\n ]),\n );\n Object.setPrototypeOf(unstructSchema, UnstructImpl);\n unstructSchema.propTypes = properties;\n\n return unstructSchema as unknown as Unstruct<TProps>;\n}\n\n// --------------\n// Implementation\n// --------------\n\nconst UnstructImpl = {\n [$internal]: true,\n type: 'unstruct',\n\n $name(label: string) {\n setName(this, label);\n return this;\n },\n\n toString(): string {\n return `unstruct:${getName(this) ?? '<unnamed>'}`;\n },\n};\n","import type { AnyAttribute } from './attributes.ts';\nimport { isDisarray, isLooseDecorated, isUnstruct } from './dataTypes.ts';\nimport type { AnyData } from './dataTypes.ts';\nimport {\n isAtomic,\n isDecorated,\n isPtr,\n isWgslArray,\n isWgslStruct,\n} from './wgslTypes.ts';\n\n/**\n * Performs a deep comparison of two TypeGPU data schemas.\n *\n * @param a The first data schema to compare.\n * @param b The second data schema to compare.\n * @returns `true` if the schemas are deeply equal, `false` otherwise.\n *\n * @example\n * ```ts\n * import { vec3f, struct, deepEqual } from 'typegpu/data';\n *\n * const schema1 = struct({ a: vec3f });\n * const schema2 = struct({ a: vec3f });\n * const schema3 = struct({ b: vec3f });\n *\n * console.log(deepEqual(schema1, schema2)); // true\n * console.log(deepEqual(schema1, schema3)); // false\n * ```\n */\nexport function deepEqual(a: AnyData, b: AnyData): boolean {\n if (a === b) {\n return true;\n }\n\n if (a.type !== b.type) {\n return false;\n }\n\n if (\n (isWgslStruct(a) && isWgslStruct(b)) ||\n (isUnstruct(a) && isUnstruct(b))\n ) {\n const aProps = a.propTypes;\n const bProps = b.propTypes;\n const aKeys = Object.keys(aProps);\n const bKeys = Object.keys(bProps);\n\n if (aKeys.length !== bKeys.length) {\n return false;\n }\n\n for (let i = 0; i < aKeys.length; i++) {\n const keyA = aKeys[i];\n const keyB = bKeys[i];\n if (\n keyA !== keyB || !keyA || !keyB ||\n !deepEqual(aProps[keyA], bProps[keyB])\n ) {\n return false;\n }\n }\n return true;\n }\n\n if ((isWgslArray(a) && isWgslArray(b)) || (isDisarray(a) && isDisarray(b))) {\n return (\n a.elementCount === b.elementCount &&\n deepEqual(a.elementType as AnyData, b.elementType as AnyData)\n );\n }\n\n if (isPtr(a) && isPtr(b)) {\n return (\n a.addressSpace === b.addressSpace &&\n a.access === b.access &&\n deepEqual(a.inner as AnyData, b.inner as AnyData)\n );\n }\n\n if (isAtomic(a) && isAtomic(b)) {\n return deepEqual(a.inner as AnyData, b.inner as AnyData);\n }\n\n if (\n (isDecorated(a) && isDecorated(b)) ||\n (isLooseDecorated(a) && isLooseDecorated(b))\n ) {\n if (!deepEqual(a.inner as AnyData, b.inner as AnyData)) {\n return false;\n }\n if (a.attribs.length !== b.attribs.length) {\n return false;\n }\n\n // Create comparable string representations for each attribute\n const getAttrKey = (attr: unknown): string => {\n const anyAttr = attr as AnyAttribute;\n return `${anyAttr.type}(${(anyAttr.params ?? []).join(',')})`;\n };\n\n const attrsA = a.attribs.map(getAttrKey);\n const attrsB = b.attribs.map(getAttrKey);\n\n for (let i = 0; i < attrsA.length; i++) {\n if (attrsA[i] !== attrsB[i]) {\n return false;\n }\n }\n }\n\n // All other types have been checked for equality at the start\n return true;\n}\n","/**\n * @module typegpu/data\n */\n\nimport { type InfixOperator, infixOperators } from '../tgsl/wgslGenerator.ts';\nimport { $internal } from '../shared/symbols.ts';\nimport { MatBase } from './matrix.ts';\nimport { VecBase } from './vectorImpl.ts';\n\nfunction assignInfixOperator<T extends typeof VecBase | typeof MatBase>(\n object: T,\n operator: InfixOperator,\n) {\n type Instance = InstanceType<T>;\n\n const proto = object.prototype as {\n [K in InfixOperator]?: (this: Instance, other: unknown) => unknown;\n };\n const opImpl = infixOperators[operator][$internal].jsImpl as (\n lhs: Instance,\n rhs: unknown,\n ) => unknown;\n\n proto[operator] = function (this: Instance, other: unknown): unknown {\n return opImpl(this, other);\n };\n}\n\nassignInfixOperator(VecBase, 'add');\nassignInfixOperator(VecBase, 'sub');\nassignInfixOperator(VecBase, 'mul');\nassignInfixOperator(VecBase, 'div');\nassignInfixOperator(MatBase, 'add');\nassignInfixOperator(MatBase, 'sub');\nassignInfixOperator(MatBase, 'mul');\n\nexport { bool, f16, f32, i32, u16, u32 } from './numeric.ts';\nexport {\n isAlignAttrib,\n isAtomic,\n isBuiltinAttrib,\n isDecorated,\n isInterpolateAttrib,\n isLocationAttrib,\n isPtr,\n isSizeAttrib,\n isWgslArray,\n isWgslData,\n isWgslStruct,\n Void,\n} from './wgslTypes.ts';\nexport type {\n Align,\n AnyVecInstance,\n AnyWgslData,\n AnyWgslStruct,\n Atomic,\n BaseData,\n BaseData as BaseWgslData,\n Bool,\n Builtin,\n Decorated,\n F16,\n F32,\n I32,\n Interpolate,\n Location,\n m2x2f,\n m3x3f,\n m4x4f,\n Mat2x2f,\n Mat3x3f,\n Mat4x4f,\n Ptr,\n Size,\n StorableData,\n U16,\n U32,\n v2b,\n v2f,\n v2i,\n v2u,\n v3b,\n v3f,\n v3i,\n v3u,\n v4b,\n v4f,\n v4i,\n v4u,\n Vec2b,\n Vec2f,\n Vec2h,\n Vec2i,\n Vec2u,\n Vec3b,\n Vec3f,\n Vec3h,\n Vec3i,\n Vec3u,\n Vec4b,\n Vec4f,\n Vec4h,\n Vec4i,\n Vec4u,\n WgslArray,\n WgslStruct,\n} from './wgslTypes.ts';\nexport { struct } from './struct.ts';\nexport { arrayOf } from './array.ts';\nexport {\n ptrFn,\n ptrHandle,\n ptrPrivate,\n ptrStorage,\n ptrUniform,\n ptrWorkgroup,\n} from './ptr.ts';\nexport type {\n AnyData,\n AnyLooseData,\n Disarray,\n LooseDecorated,\n Unstruct,\n} from './dataTypes.ts';\nexport {\n texture1d,\n texture2d,\n texture2dArray,\n texture3d,\n textureCube,\n textureCubeArray,\n textureDepth2d,\n textureDepth2dArray,\n textureDepthCube,\n textureDepthCubeArray,\n textureDepthMultisampled2d,\n textureExternal,\n textureMultisampled2d,\n textureStorage1d,\n textureStorage2d,\n textureStorage2dArray,\n textureStorage3d,\n type WgslExternalTexture,\n type WgslStorageTexture,\n type WgslStorageTexture1d,\n type WgslStorageTexture2d,\n type WgslStorageTexture2dArray,\n type WgslStorageTexture3d,\n type WgslStorageTextureProps,\n type WgslTexture,\n type WgslTexture1d,\n type WgslTexture2d,\n type WgslTexture2dArray,\n type WgslTexture3d,\n type WgslTextureCube,\n type WgslTextureCubeArray,\n type WgslTextureDepth2d,\n type WgslTextureDepth2dArray,\n type WgslTextureDepthCube,\n type WgslTextureDepthCubeArray,\n type WgslTextureDepthMultisampled2d,\n type WgslTextureMultisampled2d,\n} from './texture.ts';\nexport {\n comparisonSampler,\n sampler,\n type WgslComparisonSampler,\n type WgslSampler,\n} from './sampler.ts';\nexport {\n vec2b,\n vec2f,\n vec2h,\n vec2i,\n vec2u,\n vec3b,\n vec3f,\n vec3h,\n vec3i,\n vec3u,\n vec4b,\n vec4f,\n vec4h,\n vec4i,\n vec4u,\n} from './vector.ts';\nexport { disarrayOf } from './disarray.ts';\nexport { unstruct } from './unstruct.ts';\nexport { mat2x2f, mat3x3f, mat4x4f, matToArray } from './matrix.ts';\nexport * from './vertexFormatData.ts';\nexport { atomic } from './atomic.ts';\nexport {\n align,\n type AnyAttribute,\n type HasCustomLocation,\n interpolate,\n invariant,\n type IsBuiltin,\n isBuiltin,\n location,\n size,\n} from './attributes.ts';\nexport {\n isData,\n isDisarray,\n isLooseData,\n isLooseDecorated,\n isUnstruct,\n} from './dataTypes.ts';\nexport { PUBLIC_sizeOf as sizeOf } from './sizeOf.ts';\nexport { PUBLIC_alignmentOf as alignmentOf } from './alignmentOf.ts';\nexport { builtin } from '../builtin.ts';\nexport { deepEqual } from './deepEqual.ts';\nexport type {\n AnyBuiltin,\n BuiltinClipDistances,\n BuiltinFragDepth,\n BuiltinFrontFacing,\n BuiltinGlobalInvocationId,\n BuiltinInstanceIndex,\n BuiltinLocalInvocationId,\n BuiltinLocalInvocationIndex,\n BuiltinNumWorkgroups,\n BuiltinPosition,\n BuiltinSampleIndex,\n BuiltinSampleMask,\n BuiltinVertexIndex,\n BuiltinWorkgroupId,\n} from '../builtin.ts';\nexport type { Infer, InferGPU, InferPartial } from '../shared/repr.ts';\n"],"mappings":"qMAGO,SAASA,EACdC,EACkC,CAClC,OAAOC,EAAmB,WAAYD,EAAO,YAAY,CAC3D,CAEO,SAASE,EACdF,EACiC,CACjC,OAAOC,EAAmB,UAAWD,EAAO,YAAY,CAC1D,CAEO,SAASG,EACdH,EACmC,CACnC,OAAOC,EAAmB,YAAaD,EAAO,YAAY,CAC5D,CAEO,SAASI,EAGdJ,EAAUK,EAAkB,OAA+C,CAC3E,OAAOJ,EAAmB,UAAWD,EAAOK,CAAM,CACpD,CAEO,SAASC,EACdN,EAC2B,CAC3B,OAAOC,EAAmB,UAAWD,EAAO,MAAM,CACpD,CAEO,SAASO,EACdP,EAC0B,CAC1B,OAAOC,EAAmB,SAAUD,EAAO,MAAM,CACnD,CAEA,SAASC,EAKPO,EACAR,EACAK,EACq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disarrayOf","createDualImpl","elementType","elementCount","count","cpu_disarrayOf","partial","$internal","snip","UnknownData","disarraySchema","elements","_","i","schemaCallWrapper","DisarrayImpl","unstruct","properties","unstructSchema","instanceProps","key","schema","schemaCallWrapper","UnstructImpl","$internal","label","setName","getName","deepEqual","a","b","isWgslStruct","isUnstruct","aProps","bProps","aKeys","bKeys","keyA","keyB","isWgslArray","isDisarray","isPtr","isAtomic","isDecorated","isLooseDecorated","getAttrKey","attr","anyAttr","attrsA","attrsB","i","assignInfixOperator","object","operator","proto","opImpl","infixOperators","$internal","other","VecBase","MatBase"]}
package/chunk-CGQB3SER.js DELETED
@@ -1,3 +0,0 @@
1
- import{B as P,D as I,M as N,P as _,Q as U,U as T,V as H,a as L,aa as y,c as D,f as W,ga as K,j as g,k as h,l as k,lc as w,m as M,n as j,oc as q,pc as J,q as C,rc as z,va as G}from"./chunk-CRZWTZM2.js";import{FuncParameterType as ee}from"tinyest";function S(n,e){for(let[r,t]of Object.entries(e))n[r]=t,t&&(typeof t=="object"||typeof t=="function")&&g(t)===void 0&&h(t,r)}function Se(n,e,r){let t=[...n.matchAll(/:\s*(?<arg>.*?)\s*[,)]/g)].map(s=>s?s[1]:void 0);r(Object.fromEntries(e.flatMap((s,i)=>{let o=t?t[i]:void 0;return I(s)&&o!==void 0?[[o,s]]:[]})))}function $e(n,e,r){let t=n.match(/->\s(?<output>[\w\d_]+)\s{/),s=t?t[1]?.trim():void 0;I(e)&&s&&!/\s/g.test(s)&&r({[s]:e})}function ue(n){return new RegExp(`(?<![\\w\\$_.])${n.replaceAll(".","\\.").replaceAll("$","\\$")}(?![\\w\\$_])`,"g")}function R(n,e,r){return Object.entries(e).reduce((t,[s,i])=>{let o=ue(s);if(r&&s!=="Out"&&s!=="In"&&!o.test(r)&&console.warn(`The external '${s}' wasn't used in the resolved template.`),G(i)||U(i)||M(i))return t.replaceAll(o,n.resolve(i).value);if(i!==null&&typeof i=="object"){let a=[...r.matchAll(new RegExp(`${s.replaceAll(".","\\.").replaceAll("$","\\$")}\\.(?<prop>.*?)(?![\\w\\$_])`,"g"))].map(d=>d[1]);return[...new Set(a)].reduce((d,f)=>f&&f in i?R(n,{[`${s}.${f}`]:i[f]},d):d,t)}return console.warn(`During resolution, the external '${s}' has been omitted. Only primitives, TGPU resources and plain JS objects can be used as externals.`),t},r)}function Y(n){let{strippedCode:e,argRange:r}=pe(n),t=new $(e);t.consume("(");let s=[];for(;!t.isAt(")");){let o=[];for(;t.isAt("@");)t.parseUntil(Q,X),t.consume(")"),o.push(t.lastParsed);t.parseUntil(ce);let a=t.lastParsed,l;t.isAt(":")&&(t.consume(":"),t.parseUntil(de,fe),l=t.lastParsed),s.push({identifier:a,attributes:o,type:l}),t.isAt(",")&&t.consume(",")}t.consume(")");let i;if(t.isAt("->")){t.consume("->");let o=[];for(;t.isAt("@");)t.parseUntil(Q,X),t.consume(")"),o.push(t.lastParsed);i={type:t.str.slice(t.pos),attributes:o}}return{args:s,ret:i,range:{begin:r[0],end:r[1]}}}function pe(n){let e=new $(n),r="",t;for(;!e.isFinished();){if(e.isAt(le)){e.advanceBy(1);continue}if(e.isAt("//")){e.consume("//"),e.parseUntil(Z),e.advanceBy(1);continue}if(e.isAt("/*")){e.parseUntil(me,ge),e.consume("*/");continue}if(e.isAt("{"))return{strippedCode:r,argRange:[t,e.pos]};e.isAt("(")&&t===void 0&&(t=e.pos),t!==void 0&&(r+=e.str[e.pos]),e.advanceBy(1)}throw new Error("Invalid wgsl code!")}var $=class{constructor(e){this.str=e;this.#e=0}#t;#e;get pos(){return this.#e}get lastParsed(){if(this.#t===void 0)throw new Error("Parse was not called yet!");return this.str.slice(this.#t,this.pos)}isFinished(){return this.#e>=this.str.length}isAt(e){if(typeof e=="string"){for(let r=0;r<e.length;r++)if(this.str[this.#e+r]!==e[r])return!1;return!0}for(let r of e)if(this.isAt(r))return!0;return!1}parseUntil(e,r){this.#t=this.#e;let t=0;for(;this.#e<this.str.length;){if(r&&this.isAt(r[0])&&(t+=1),r&&this.isAt(r[1])&&(t-=1),t===0&&this.isAt(e))return this.#e;this.#e+=1}throw new Error("Reached the end of the string without finding a match!")}advanceBy(e){this.#e+=e}consume(e){if(!this.isAt(e))throw new Error(`Expected '${e}' at position ${this.#e}, but found '${this.str.slice(this.#e,this.#e+e.length)}'`);this.advanceBy(e.length)}},Z=new Set([`
2
- `,"\v","\f","\r","\x85","\u2028","\u2029"]),le=new Set([...Z," "," ","\u200E","\u200F"]),Q=new Set([")"]),ce=new Set([":",",",")"]),de=new Set([",",")"]),me=new Set(["*/"]),X=["(",")"],fe=["<",">"],ge=["/*","*/"];function ne(n,e=""){let r=[],t={applyExternals(i){r.push(i)},resolve(i,o,a){let l={};for(let u of r)S(l,u);let d=i.getUniqueName(this);if(typeof n=="string"){if(!a)throw new Error("Explicit return type is required for string implementation");let u=R(i,l,n),m="",x="";if(e!==""){let p=I(o[0])?`(in: ${i.resolve(o[0]).value})`:"()",c=P(a)?J(a):"",b=a!==C?I(a)?`-> ${i.resolve(a).value}`:`-> ${c!==""?c:"@location(0)"} ${i.resolve(a).value}`:"";m=`${p} ${b} `,x=u}else{let p=Y(u);if(p.args.length!==o.length)throw new Error(`WGSL implementation has ${p.args.length} arguments, while the shell has ${o.length} arguments.`);let c=p.args.map((E,ae)=>`${E.identifier}: ${te(i,`parameter ${E.identifier}`,E.type,o[ae])}`).join(", "),b=a===C?"":`-> ${te(i,"return type",p.ret?.type,a)}`;m=`(${c}) ${b}`,x=u.slice(p.range.end)}return i.addDeclaration(`${e}fn ${d}${m}${x}`),y(d,a)}let f=j(n);if(f?.externals){let u=Object.fromEntries(Object.entries(f.externals).filter(([m])=>!(m in l)));S(l,u)}let O=f?.ast;if(!O)throw new Error("Missing metadata for tgpu.fn function body (either missing 'use gpu' directive, or misconfigured `unplugin-typegpu`)");let B=O.externalNames.filter(u=>!(u in l));if(B.length>0)throw new K(g(this),B);let A=O.params[1];A&&A.type==="i"&&e!==""&&S(l,{[A.name]:_(a)});let V=[],v=[];for(let[u,m]of o.entries()){let x=O.params[u];switch(x?.type){case ee.identifier:{let p=x.name,c=y(i.makeNameValid(p),m);V.push(c),c.value!==p&&v.push([p,c]);break}case ee.destructuredObject:{V.push(y(`_arg_${u}`,m)),v.push(...x.props.map(({name:p,alias:c})=>[c,y(`_arg_${u}.${p}`,o[u].propTypes[p])]));break}case void 0:V.push(y(`_arg_${u}`,m))}}let{head:ie,body:se,returnType:oe}=i.fnToWgsl({args:V,argAliases:Object.fromEntries(v),returnType:a,body:O.body,externalMap:l});return i.addDeclaration(`${e}fn ${d}${i.resolve(ie).value}${i.resolve(se).value}`),y(d,oe)}},s=g(n);return s!==void 0&&h(t,s),t}function te(n,e,r,t){let s=n.resolve(t).value.replace(/\s/g,"");if(!r)return s;let i=r.replace(/\s/g,"");if(i!==s)throw new Error(`Type mismatch between TGPU shell and WGSL code string: ${e}, JS type "${s}", WGSL type "${i}".`);return r}function xe(n,e={}){let r=0,t=new Set;return Object.fromEntries(Object.entries(n??{}).map(([s,i])=>{let o=T(i);if(o!==void 0){if(t.has(o))throw new Error("Duplicate custom location attributes found");t.add(o)}return[s,i]}).map(([s,i])=>{if(q(i))return[s,i];if(T(i)!==void 0)return[s,i];if(e[s])return[s,w(e[s],i)];for(;t.has(r);)r++;return[s,w(r++,i)]}))}function F(n,e={}){return H(n)?N(n)||T(n)!==void 0?n:w(0,n):z(xe(n,e))}function re(n,...e){return ye(n)?he(n,...e):n}function ye(n){return Array.isArray(n)&&"raw"in n&&Array.isArray(n.raw)&&n.raw.every(e=>typeof e=="string")}function he(n,...e){return n.slice(1).reduce((r,t,s)=>`${r}${e[s]}${t}`,n[0])}function Qe(n){if(Object.keys(n.out).length===0)throw new Error("A vertexFn output cannot be empty since it must include the 'position' builtin.");let e={in:n.in,out:n.out,argTypes:n.in&&Object.keys(n.in).length!==0?[F(n.in)]:[],isEntry:!0},r=(t,...s)=>Ie(e,re(t,...s));return Object.assign(Object.assign(r,e),{does:r})}function Ie(n,e){let r=ne(e,"@vertex "),t=n.argTypes[0];return{shell:n,$uses(i){return r.applyExternals(i),this},[L]:!0,[D]:r,$name(i){return h(r,i),k(t)&&t.$name(`${i}_Input`),this},[W](i){let o=F(n.out,i.varyingLocations).$name(`${g(this)??""}_Output`);return typeof e=="string"&&(t&&r.applyExternals({In:t}),r.applyExternals({Out:o})),r.resolve(i,n.argTypes,o)},toString(){return`vertexFn:${g(r)??"<unnamed>"}`}}}export{S as a,Se as b,$e as c,R as d,ne as e,F as f,re as g,Qe as h};
3
- //# sourceMappingURL=chunk-CGQB3SER.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/core/function/fnCore.ts","../src/core/resolve/externals.ts","../src/core/function/extractArgs.ts","../src/core/function/ioSchema.ts","../src/core/function/templateUtils.ts","../src/core/function/tgpuVertexFn.ts"],"sourcesContent":["import { FuncParameterType } from 'tinyest';\nimport { getAttributesString } from '../../data/attributes.ts';\nimport { type AnyData, undecorate } from '../../data/dataTypes.ts';\nimport {\n type ResolvedSnippet,\n snip,\n type Snippet,\n} from '../../data/snippet.ts';\nimport {\n isWgslData,\n isWgslStruct,\n Void,\n type WgslStruct,\n} from '../../data/wgslTypes.ts';\nimport { MissingLinksError } from '../../errors.ts';\nimport { getMetaData, getName, setName } from '../../shared/meta.ts';\nimport type { ResolutionCtx } from '../../types.ts';\nimport {\n applyExternals,\n type ExternalMap,\n replaceExternalsInWgsl,\n} from '../resolve/externals.ts';\nimport { extractArgs } from './extractArgs.ts';\nimport type { Implementation } from './fnTypes.ts';\n\nexport interface FnCore {\n applyExternals(newExternals: ExternalMap): void;\n resolve(\n ctx: ResolutionCtx,\n argTypes: AnyData[],\n /**\n * The return type of the function. If undefined, the type should be inferred\n * from the implementation (relevant for shellless functions).\n */\n returnType: AnyData | undefined,\n ): ResolvedSnippet;\n}\n\nexport function createFnCore(\n implementation: Implementation,\n fnAttribute = '',\n): FnCore {\n /**\n * External application has to be deferred until resolution because\n * some externals can reference the owner function which has not been\n * initialized yet (like when accessing the Output struct of a vertex\n * entry fn).\n */\n const externalsToApply: ExternalMap[] = [];\n\n const core = {\n applyExternals(newExternals: ExternalMap): void {\n externalsToApply.push(newExternals);\n },\n\n resolve(\n ctx: ResolutionCtx,\n argTypes: AnyData[],\n returnType: AnyData | undefined,\n ): ResolvedSnippet {\n const externalMap: ExternalMap = {};\n\n for (const externals of externalsToApply) {\n applyExternals(externalMap, externals);\n }\n\n const id = ctx.getUniqueName(this);\n\n if (typeof implementation === 'string') {\n if (!returnType) {\n throw new Error(\n 'Explicit return type is required for string implementation',\n );\n }\n\n const replacedImpl = replaceExternalsInWgsl(\n ctx,\n externalMap,\n implementation,\n );\n\n let header = '';\n let body = '';\n\n if (fnAttribute !== '') {\n const input = isWgslStruct(argTypes[0])\n ? `(in: ${ctx.resolve(argTypes[0]).value})`\n : '()';\n\n const attributes = isWgslData(returnType)\n ? getAttributesString(returnType)\n : '';\n const output = returnType !== Void\n ? isWgslStruct(returnType)\n ? `-> ${ctx.resolve(returnType).value}`\n : `-> ${attributes !== '' ? attributes : '@location(0)'} ${\n ctx.resolve(returnType).value\n }`\n : '';\n\n header = `${input} ${output} `;\n body = replacedImpl;\n } else {\n const providedArgs = extractArgs(replacedImpl);\n\n if (providedArgs.args.length !== argTypes.length) {\n throw new Error(\n `WGSL implementation has ${providedArgs.args.length} arguments, while the shell has ${argTypes.length} arguments.`,\n );\n }\n\n const input = providedArgs.args.map((argInfo, i) =>\n `${argInfo.identifier}: ${\n checkAndReturnType(\n ctx,\n `parameter ${argInfo.identifier}`,\n argInfo.type,\n argTypes[i],\n )\n }`\n ).join(', ');\n\n const output = returnType === Void ? '' : `-> ${\n checkAndReturnType(\n ctx,\n 'return type',\n providedArgs.ret?.type,\n returnType,\n )\n }`;\n\n header = `(${input}) ${output}`;\n\n body = replacedImpl.slice(providedArgs.range.end);\n }\n\n ctx.addDeclaration(`${fnAttribute}fn ${id}${header}${body}`);\n return snip(id, returnType);\n }\n\n // get data generated by the plugin\n const pluginData = getMetaData(implementation);\n\n if (pluginData?.externals) {\n const missing = Object.fromEntries(\n Object.entries(pluginData.externals).filter(\n ([name]) => !(name in externalMap),\n ),\n );\n\n applyExternals(externalMap, missing);\n }\n\n const ast = pluginData?.ast;\n if (!ast) {\n throw new Error(\n \"Missing metadata for tgpu.fn function body (either missing 'use gpu' directive, or misconfigured `unplugin-typegpu`)\",\n );\n }\n\n // verify all required externals are present\n const missingExternals = ast.externalNames.filter(\n (name) => !(name in externalMap),\n );\n if (missingExternals.length > 0) {\n throw new MissingLinksError(getName(this), missingExternals);\n }\n\n // If an entrypoint implementation has a second argument, it represents the output schema.\n // We look at the identifier chosen by the user and add it to externals.\n const maybeSecondArg = ast.params[1];\n if (\n maybeSecondArg && maybeSecondArg.type === 'i' && fnAttribute !== ''\n ) {\n applyExternals(\n externalMap,\n {\n // biome-ignore lint/style/noNonNullAssertion: entry functions cannot be shellless\n [maybeSecondArg.name]: undecorate(returnType!),\n },\n );\n }\n\n // generate wgsl string\n\n const args: Snippet[] = [];\n const argAliases: [string, Snippet][] = [];\n\n for (const [i, argType] of argTypes.entries()) {\n const astParam = ast.params[i];\n\n switch (astParam?.type) {\n case FuncParameterType.identifier: {\n const rawName = astParam.name;\n const snippet = snip(ctx.makeNameValid(rawName), argType);\n args.push(snippet);\n if (snippet.value !== rawName) {\n argAliases.push([rawName, snippet]);\n }\n break;\n }\n case FuncParameterType.destructuredObject: {\n args.push(snip(`_arg_${i}`, argType));\n argAliases.push(...astParam.props.map(({ name, alias }) =>\n [\n alias,\n snip(\n `_arg_${i}.${name}`,\n (argTypes[i] as WgslStruct)\n .propTypes[name],\n ),\n ] as [string, Snippet]\n ));\n break;\n }\n case undefined:\n args.push(snip(`_arg_${i}`, argType));\n }\n }\n\n const { head, body, returnType: actualReturnType } = ctx.fnToWgsl({\n args,\n argAliases: Object.fromEntries(argAliases),\n returnType,\n body: ast.body,\n externalMap,\n });\n\n ctx.addDeclaration(\n `${fnAttribute}fn ${id}${ctx.resolve(head).value}${\n ctx.resolve(body).value\n }`,\n );\n\n return snip(id, actualReturnType);\n },\n };\n\n // The implementation could have been given a name by a bundler plugin,\n // so we try to transfer it to the core.\n const maybeName = getName(implementation);\n if (maybeName !== undefined) {\n setName(core, maybeName);\n }\n\n return core;\n}\n\nfunction checkAndReturnType(\n ctx: ResolutionCtx,\n name: string,\n wgslType: string | undefined,\n jsType: unknown,\n) {\n const resolvedJsType = ctx.resolve(jsType).value.replace(/\\s/g, '');\n\n if (!wgslType) {\n return resolvedJsType;\n }\n\n const resolvedWgslType = wgslType.replace(/\\s/g, '');\n\n if (resolvedWgslType !== resolvedJsType) {\n throw new Error(\n `Type mismatch between TGPU shell and WGSL code string: ${name}, JS type \"${resolvedJsType}\", WGSL type \"${resolvedWgslType}\".`,\n );\n }\n\n return wgslType;\n}\n","import { isLooseData } from '../../data/dataTypes.ts';\nimport { isWgslStruct } from '../../data/wgslTypes.ts';\nimport { getName, hasTinyestMetadata, setName } from '../../shared/meta.ts';\nimport { isWgsl, type ResolutionCtx } from '../../types.ts';\n\n/**\n * A key-value mapping where keys represent identifiers within shader code,\n * and values can be any type that can be resolved to a code string.\n */\nexport type ExternalMap = Record<string, unknown>;\n\n/**\n * Merges two external maps into one. If a key is present in both maps, the value from the new map is used.\n * If the external value is a namable object, it is given a name if it does not already have one.\n * @param existing - The existing external map.\n * @param newExternals - The new external map.\n */\nexport function applyExternals(\n existing: ExternalMap,\n newExternals: ExternalMap,\n) {\n for (const [key, value] of Object.entries(newExternals)) {\n existing[key] = value;\n\n // Giving name to external value, if it does not already have one.\n if (\n value && (typeof value === 'object' || typeof value === 'function') &&\n getName(value) === undefined\n ) {\n setName(value, key);\n }\n }\n}\n\nexport function addArgTypesToExternals(\n implementation: string,\n argTypes: unknown[],\n applyExternals: (externals: ExternalMap) => void,\n) {\n const argTypeNames = [\n ...implementation.matchAll(/:\\s*(?<arg>.*?)\\s*[,)]/g),\n ].map((found) => (found ? found[1] : undefined));\n\n applyExternals(\n Object.fromEntries(\n argTypes.flatMap((argType, i) => {\n const argTypeName = argTypeNames ? argTypeNames[i] : undefined;\n return isWgslStruct(argType) && argTypeName !== undefined\n ? [[argTypeName, argType]]\n : [];\n }),\n ),\n );\n}\n\nexport function addReturnTypeToExternals(\n implementation: string,\n returnType: unknown,\n applyExternals: (externals: ExternalMap) => void,\n) {\n const matched = implementation.match(/->\\s(?<output>[\\w\\d_]+)\\s{/);\n const outputName = matched ? matched[1]?.trim() : undefined;\n\n if (isWgslStruct(returnType) && outputName && !/\\s/g.test(outputName)) {\n applyExternals({ [outputName]: returnType });\n }\n}\n\nfunction identifierRegex(name: string) {\n return new RegExp(\n `(?<![\\\\w\\\\$_.])${\n name.replaceAll('.', '\\\\.').replaceAll('$', '\\\\$')\n }(?![\\\\w\\\\$_])`,\n 'g',\n );\n}\n\n/**\n * Replaces all occurrences of external names in WGSL code with their resolved values.\n * It adds all necessary definitions to the resolution context.\n * @param ctx - The resolution context.\n * @param externalMap - The external map.\n * @param wgsl - The WGSL code.\n *\n * @returns The WGSL code with all external names replaced with their resolved values.\n */\nexport function replaceExternalsInWgsl(\n ctx: ResolutionCtx,\n externalMap: ExternalMap,\n wgsl: string,\n): string {\n return Object.entries(externalMap).reduce((acc, [externalName, external]) => {\n const externalRegex = identifierRegex(externalName);\n if (\n wgsl &&\n externalName !== 'Out' &&\n externalName !== 'In' &&\n !externalRegex.test(wgsl)\n ) {\n console.warn(\n `The external '${externalName}' wasn't used in the resolved template.`,\n );\n // continue anyway, we still might need to resolve the external\n }\n\n if (\n isWgsl(external) || isLooseData(external) || hasTinyestMetadata(external)\n ) {\n return acc.replaceAll(externalRegex, ctx.resolve(external).value);\n }\n\n if (external !== null && typeof external === 'object') {\n const foundProperties = [\n ...wgsl.matchAll(\n new RegExp(\n `${\n externalName.replaceAll('.', '\\\\.').replaceAll('$', '\\\\$')\n }\\\\.(?<prop>.*?)(?![\\\\w\\\\$_])`,\n 'g',\n ),\n ),\n ].map((found) => found[1]);\n const uniqueProperties = [...new Set(foundProperties)];\n\n return uniqueProperties.reduce(\n (innerAcc: string, prop) =>\n prop && prop in external\n ? replaceExternalsInWgsl(\n ctx,\n {\n [`${externalName}.${prop}`]:\n external[prop as keyof typeof external],\n },\n innerAcc,\n )\n : innerAcc,\n acc,\n );\n }\n\n console.warn(\n `During resolution, the external '${externalName}' has been omitted. Only primitives, TGPU resources and plain JS objects can be used as externals.`,\n );\n\n return acc;\n }, wgsl);\n}\n","interface FunctionArgsInfo {\n args: ArgInfo[];\n ret: ReturnInfo | undefined;\n range: {\n begin: number;\n end: number;\n };\n}\n\ninterface ArgInfo {\n identifier: string;\n attributes: string[];\n type: string | undefined;\n}\n\ninterface ReturnInfo {\n attributes: string[];\n type: string;\n}\n\n/**\n * Extracts info about arguments of a given WGSL function string.\n * @example\n * const code = `\n * fn add(a: i32, @location(0) b: i32, c) -> i32 {\n * return a + b + c;\n * }`;\n *\n * extractArgs(code);\n * // {\n * // args: [\n * // { identifier: 'a', attributes: [], type: 'i32' },\n * // { identifier: 'b', attributes: ['@location(0)'], type: 'i32' },\n * // { identifier: 'c', attributes: [], type: undefined }\n * // ],\n * // ret: { type: 'i32', attributes: [] },\n * // range: { begin: 11, end: 51 }\n * // }\n */\nexport function extractArgs(rawCode: string): FunctionArgsInfo {\n const { strippedCode, argRange: range } = strip(rawCode);\n const code = new ParsableString(strippedCode);\n code.consume('(');\n\n const args: ArgInfo[] = [];\n while (!code.isAt(')')) {\n // In each loop iteration, process all the attributes, the identifier and the potential type of a single argument.\n\n const attributes = [];\n while (code.isAt('@')) {\n code.parseUntil(closingParenthesis, parentheses);\n code.consume(')');\n attributes.push(code.lastParsed);\n }\n\n code.parseUntil(identifierEndSymbols);\n const identifier = code.lastParsed;\n\n let maybeType: string | undefined;\n if (code.isAt(':')) {\n code.consume(':');\n code.parseUntil(typeEndSymbols, angleBrackets);\n maybeType = code.lastParsed;\n }\n\n args.push({\n identifier,\n attributes,\n type: maybeType,\n });\n\n if (code.isAt(',')) {\n code.consume(',');\n }\n }\n code.consume(')');\n\n let maybeRet: ReturnInfo | undefined;\n if (code.isAt('->')) {\n code.consume('->');\n\n const attributes = [];\n while (code.isAt('@')) {\n code.parseUntil(closingParenthesis, parentheses);\n code.consume(')');\n attributes.push(code.lastParsed);\n }\n\n maybeRet = { type: code.str.slice(code.pos), attributes };\n }\n\n return {\n args,\n ret: maybeRet,\n range: { begin: range[0], end: range[1] },\n };\n}\n\n/**\n * Strips comments, whitespaces, the name and the body of the function.\n * @example\n * const code = `\n * fn add( a, // first argument\n * @location(0) b : i32 ) -> i32 {\n * return a + b; // returns the sum\n * }`;\n *\n * strip(code); // \"(a,@location(0)b:i32)->i32\"\n */\nfunction strip(\n rawCode: string,\n): { strippedCode: string; argRange: [number, number] } {\n const code = new ParsableString(rawCode);\n let strippedCode = '';\n let argsStart: number | undefined;\n\n while (!code.isFinished()) {\n // parse character by character while ignoring comments and blankspaces until you find a `{`.\n\n // skip any blankspace\n if (code.isAt(blankSpaces)) {\n code.advanceBy(1); // the blankspace character\n continue;\n }\n\n // skip line comments\n if (code.isAt('//')) {\n code.consume('//');\n code.parseUntil(lineBreaks);\n code.advanceBy(1); // the line break\n continue;\n }\n\n // skip block comments\n if (code.isAt('/*')) {\n code.parseUntil(openingCommentBlock, commentBlocks);\n code.consume('*/');\n continue;\n }\n\n if (code.isAt('{')) {\n return {\n strippedCode,\n argRange: [argsStart as number, code.pos],\n };\n }\n\n if (code.isAt('(') && argsStart === undefined) {\n argsStart = code.pos;\n }\n\n if (argsStart !== undefined) {\n strippedCode += code.str[code.pos];\n }\n code.advanceBy(1); // parsed character\n }\n throw new Error('Invalid wgsl code!');\n}\n\nclass ParsableString {\n #parseStartPos: number | undefined;\n #pos: number;\n constructor(public readonly str: string) {\n this.#pos = 0;\n }\n\n get pos(): number {\n return this.#pos;\n }\n\n /**\n * This property is equivalent to the substring of `this.str`\n * from the position of the last `parseUntil` call, to the current position.\n */\n get lastParsed(): string {\n if (this.#parseStartPos === undefined) {\n throw new Error('Parse was not called yet!');\n }\n return this.str.slice(this.#parseStartPos, this.pos);\n }\n\n isFinished() {\n return this.#pos >= this.str.length;\n }\n\n isAt(substr: string | Set<string>): boolean {\n if (typeof substr === 'string') {\n for (let i = 0; i < substr.length; i++) {\n if (this.str[this.#pos + i] !== substr[i]) {\n return false;\n }\n }\n return true;\n }\n for (const elem of substr) {\n if (this.isAt(elem)) {\n return true;\n }\n }\n return false;\n }\n\n /**\n * @param toFind a set of strings either of which satisfy the search.\n * @param brackets a pair of brackets that has to be closed for result to be valid. This includes the found character(s).\n * @example\n * // internal state:\n * // '(@attribute(0) identifier: type)'\n * // ^\n * this.parse(new Set(')'), ['(', ')']);\n * // internal state:\n * // '(@attribute(0) identifier: type)'\n * // ^\n */\n parseUntil(\n toFind: Set<string>,\n brackets?: readonly [string, string],\n ): number {\n this.#parseStartPos = this.#pos;\n let openedBrackets = 0;\n while (this.#pos < this.str.length) {\n if (brackets && this.isAt(brackets[0])) {\n openedBrackets += 1;\n }\n if (brackets && this.isAt(brackets[1])) {\n openedBrackets -= 1;\n }\n if (openedBrackets === 0) {\n if (this.isAt(toFind)) {\n return this.#pos;\n }\n }\n this.#pos += 1;\n }\n throw new Error('Reached the end of the string without finding a match!');\n }\n\n advanceBy(steps: number) {\n this.#pos += steps;\n }\n\n consume(str: string): void {\n if (!this.isAt(str)) {\n throw new Error(\n `Expected '${str}' at position ${this.#pos}, but found '${\n this.str.slice(this.#pos, this.#pos + str.length)\n }'`,\n );\n }\n this.advanceBy(str.length);\n }\n}\n\nconst lineBreaks = new Set<string>([\n '\\u000A', // line feed\n '\\u000B', // vertical tab\n '\\u000C', // form feed\n '\\u000D', // carriage return\n '\\u0085', // next line\n '\\u2028', // line separator\n '\\u2029', // paragraph separator\n]);\nconst blankSpaces = new Set<string>([\n ...lineBreaks,\n '\\u0020', // space\n '\\u0009', // horizontal tab\n '\\u200E', // left-to-right mark\n '\\u200F', // right-to-left mark\n]);\nconst closingParenthesis = new Set<string>([')']);\nconst identifierEndSymbols = new Set([':', ',', ')']);\nconst typeEndSymbols = new Set([',', ')']);\nconst openingCommentBlock = new Set(['*/']);\n\nconst parentheses = ['(', ')'] as const;\nconst angleBrackets = ['<', '>'] as const;\nconst commentBlocks = ['/*', '*/'] as const;\n","import {\n type Decorate,\n type HasCustomLocation,\n type IsBuiltin,\n location,\n} from '../../data/attributes.ts';\nimport { isBuiltin } from '../../data/attributes.ts';\nimport { getCustomLocation, isData } from '../../data/dataTypes.ts';\nimport { struct } from '../../data/struct.ts';\nimport {\n type BaseData,\n isVoid,\n type Location,\n type WgslStruct,\n} from '../../data/wgslTypes.ts';\nimport type { IOData, IOLayout, IORecord } from './fnTypes.ts';\n\nexport type WithLocations<T extends IORecord> = {\n [Key in keyof T]: IsBuiltin<T[Key]> extends true ? T[Key]\n : HasCustomLocation<T[Key]> extends true ? T[Key]\n : Decorate<T[Key], Location>;\n};\n\nexport type IOLayoutToSchema<T extends IOLayout> = T extends BaseData\n ? Decorate<T, Location<0>>\n : T extends IORecord ? WgslStruct<WithLocations<T>>\n // biome-ignore lint/suspicious/noConfusingVoidType: <it actually is void>\n : T extends { type: 'void' } ? void\n : never;\n\nexport function withLocations<T extends IOData>(\n members: IORecord<T> | undefined,\n locations: Record<string, number> = {},\n): WithLocations<IORecord<T>> {\n let nextLocation = 0;\n const usedCustomLocations = new Set<number>();\n\n return Object.fromEntries(\n Object.entries(members ?? {}).map(([key, member]) => {\n const customLocation = getCustomLocation(member);\n\n if (customLocation !== undefined) {\n if (usedCustomLocations.has(customLocation)) {\n throw new Error('Duplicate custom location attributes found');\n }\n usedCustomLocations.add(customLocation);\n }\n\n return [key, member] as const;\n }).map(([key, member]) => {\n if (isBuiltin(member)) { // skipping builtins\n return [key, member];\n }\n\n if (getCustomLocation(member) !== undefined) { // this member is already marked\n return [key, member];\n }\n\n if (locations[key]) { // location has been determined by a previous procedure\n return [key, location(locations[key], member)];\n }\n\n while (usedCustomLocations.has(nextLocation)) {\n nextLocation++;\n }\n return [key, location(nextLocation++, member)];\n }),\n );\n}\n\nexport function createIoSchema<\n T extends IOData,\n Layout extends IORecord<T> | IOLayout<T>,\n>(layout: Layout, locations: Record<string, number> = {}) {\n return (\n isData(layout)\n ? isVoid(layout)\n ? layout\n : getCustomLocation(layout) !== undefined\n ? layout\n : location(0, layout)\n : struct(withLocations(layout, locations) as Record<string, T>)\n ) as IOLayoutToSchema<Layout>;\n}\n","import type { Implementation } from './fnTypes.ts';\n\nexport function stripTemplate(\n arg: Implementation | TemplateStringsArray,\n ...values: unknown[]\n): Implementation {\n return isTemplateStringsArray(arg)\n ? templateLiteralIdentity(arg, ...values)\n : arg;\n}\n\nfunction isTemplateStringsArray(value: unknown): value is TemplateStringsArray {\n return (\n Array.isArray(value) &&\n 'raw' in value &&\n Array.isArray(value.raw) &&\n value.raw.every((item) => typeof item === 'string')\n );\n}\n\nfunction templateLiteralIdentity(\n strings: TemplateStringsArray,\n ...values: unknown[]\n): string {\n return strings\n .slice(1)\n .reduce(\n (acc, elem, index) => `${acc}${values[index]}${elem}`,\n strings[0] as string,\n );\n}\n","import type {\n AnyVertexInputBuiltin,\n AnyVertexOutputBuiltin,\n OmitBuiltins,\n} from '../../builtin.ts';\nimport type { ResolvedSnippet } from '../../data/snippet.ts';\nimport type {\n Decorated,\n Interpolate,\n Location,\n WgslStruct,\n} from '../../data/wgslTypes.ts';\nimport {\n getName,\n isNamable,\n setName,\n type TgpuNamable,\n} from '../../shared/meta.ts';\nimport { $getNameForward, $internal, $resolve } from '../../shared/symbols.ts';\nimport type { ResolutionCtx, SelfResolvable } from '../../types.ts';\nimport { createFnCore, type FnCore } from './fnCore.ts';\nimport type {\n BaseIOData,\n Implementation,\n InferIO,\n IORecord,\n} from './fnTypes.ts';\nimport { createIoSchema, type IOLayoutToSchema } from './ioSchema.ts';\nimport { stripTemplate } from './templateUtils.ts';\n\n// ----------\n// Public API\n// ----------\n\nexport type VertexInConstrained = IORecord<\n BaseIOData | Decorated<BaseIOData, Location[]> | AnyVertexInputBuiltin\n>;\n\nexport type VertexOutConstrained = IORecord<\n | BaseIOData\n | Decorated<BaseIOData, (Location | Interpolate)[]>\n | AnyVertexOutputBuiltin\n>;\n\n/**\n * Describes a vertex entry function signature (its arguments, return type and attributes)\n */\ntype TgpuVertexFnShellHeader<\n VertexIn extends VertexInConstrained,\n VertexOut extends VertexOutConstrained,\n> = {\n readonly in: VertexIn | undefined;\n readonly out: VertexOut;\n readonly argTypes: [IOLayoutToSchema<VertexIn>] | [];\n readonly isEntry: true;\n};\n\n/**\n * Describes a vertex entry function signature (its arguments, return type and attributes).\n * Allows creating tgpu vertex functions by calling this shell\n * and passing the implementation (as WGSL string or JS function) as the argument.\n */\nexport type TgpuVertexFnShell<\n VertexIn extends VertexInConstrained,\n VertexOut extends VertexOutConstrained,\n> =\n & TgpuVertexFnShellHeader<VertexIn, VertexOut>\n & ((\n implementation: (\n input: InferIO<VertexIn>,\n out: WgslStruct<VertexOut>,\n ) => InferIO<VertexOut>,\n ) => TgpuVertexFn<OmitBuiltins<VertexIn>, OmitBuiltins<VertexOut>>)\n & ((\n implementation: string,\n ) => TgpuVertexFn<OmitBuiltins<VertexIn>, OmitBuiltins<VertexOut>>)\n & ((\n strings: TemplateStringsArray,\n ...values: unknown[]\n ) => TgpuVertexFn<OmitBuiltins<VertexIn>, OmitBuiltins<VertexOut>>)\n & {\n /**\n * @deprecated Invoke the shell as a function instead.\n */\n does:\n & ((\n implementation: (input: InferIO<VertexIn>) => InferIO<VertexOut>,\n ) => TgpuVertexFn<OmitBuiltins<VertexIn>, OmitBuiltins<VertexOut>>)\n & ((\n implementation: string,\n ) => TgpuVertexFn<OmitBuiltins<VertexIn>, OmitBuiltins<VertexOut>>);\n };\n\nexport interface TgpuVertexFn<\n VertexIn extends VertexInConstrained = VertexInConstrained,\n VertexOut extends VertexOutConstrained = VertexOutConstrained,\n> extends TgpuNamable {\n readonly [$internal]: true;\n readonly shell: TgpuVertexFnShellHeader<VertexIn, VertexOut>;\n $uses(dependencyMap: Record<string, unknown>): this;\n}\n\nexport function vertexFn<VertexOut extends VertexOutConstrained>(options: {\n out: VertexOut;\n // biome-ignore lint/complexity/noBannedTypes: it's fine\n}): TgpuVertexFnShell<{}, VertexOut>;\n\nexport function vertexFn<\n VertexIn extends VertexInConstrained,\n // Not allowing single-value output, as it is better practice\n // to properly label what the vertex shader is outputting.\n VertexOut extends VertexOutConstrained,\n>(options: {\n in: VertexIn;\n out: VertexOut;\n}): TgpuVertexFnShell<VertexIn, VertexOut>;\n\n/**\n * Creates a shell of a typed entry function for the vertex shader stage. Any function\n * that implements this shell can run for each vertex, allowing the inner code to process\n * attributes and determine the final position of the vertex.\n *\n * @param options.in\n * Vertex attributes and builtins to be made available to functions that implement this shell.\n * @param options.out\n * A record containing the final position of the vertex, and any information\n * passed onto the fragment shader stage.\n */\nexport function vertexFn<\n VertexIn extends VertexInConstrained,\n // Not allowing single-value output, as it is better practice\n // to properly label what the vertex shader is outputting.\n VertexOut extends VertexOutConstrained,\n>(options: {\n in?: VertexIn;\n out: VertexOut;\n}): TgpuVertexFnShell<VertexIn, VertexOut> {\n if (Object.keys(options.out).length === 0) {\n throw new Error(\n `A vertexFn output cannot be empty since it must include the 'position' builtin.`,\n );\n }\n const shell: TgpuVertexFnShellHeader<VertexIn, VertexOut> = {\n in: options.in,\n out: options.out,\n argTypes: options.in && Object.keys(options.in).length !== 0\n ? [createIoSchema(options.in)]\n : [],\n isEntry: true,\n };\n\n const call = (\n arg: Implementation | TemplateStringsArray,\n ...values: unknown[]\n ) => createVertexFn(shell, stripTemplate(arg, ...values));\n\n return Object.assign(Object.assign(call, shell), {\n does: call,\n }) as TgpuVertexFnShell<VertexIn, VertexOut>;\n}\n\n// --------------\n// Implementation\n// --------------\n\nfunction createVertexFn(\n shell: TgpuVertexFnShellHeader<VertexInConstrained, VertexOutConstrained>,\n implementation: Implementation,\n): TgpuVertexFn<VertexInConstrained, VertexOutConstrained> {\n type This =\n & TgpuVertexFn<VertexInConstrained, VertexOutConstrained>\n & SelfResolvable\n & {\n [$internal]: true;\n [$getNameForward]: FnCore;\n };\n\n const core = createFnCore(implementation, '@vertex ');\n const inputType = shell.argTypes[0];\n\n const result: This = {\n shell,\n\n $uses(newExternals) {\n core.applyExternals(newExternals);\n return this;\n },\n\n [$internal]: true,\n [$getNameForward]: core,\n $name(newLabel: string): This {\n setName(core, newLabel);\n if (isNamable(inputType)) {\n inputType.$name(`${newLabel}_Input`);\n }\n return this;\n },\n\n [$resolve](ctx: ResolutionCtx): ResolvedSnippet {\n const outputWithLocation = createIoSchema(\n shell.out,\n ctx.varyingLocations,\n ).$name(`${getName(this) ?? ''}_Output`);\n\n if (typeof implementation === 'string') {\n if (inputType) {\n core.applyExternals({ In: inputType });\n }\n core.applyExternals({ Out: outputWithLocation });\n }\n\n return core.resolve(\n ctx,\n shell.argTypes,\n outputWithLocation,\n );\n },\n\n toString() {\n return `vertexFn:${getName(core) ?? '<unnamed>'}`;\n },\n };\n return result;\n}\n"],"mappings":"yMAAA,OAAS,qBAAAA,OAAyB,UCiB3B,SAASC,EACdC,EACAC,EACA,CACA,OAAW,CAACC,EAAKC,CAAK,IAAK,OAAO,QAAQF,CAAY,EACpDD,EAASE,CAAG,EAAIC,EAIdA,IAAU,OAAOA,GAAU,UAAY,OAAOA,GAAU,aACxDC,EAAQD,CAAK,IAAM,QAEnBE,EAAQF,EAAOD,CAAG,CAGxB,CAEO,SAASI,GACdC,EACAC,EACAT,EACA,CACA,IAAMU,EAAe,CACnB,GAAGF,EAAe,SAAS,yBAAyB,CACtD,EAAE,IAAKG,GAAWA,EAAQA,EAAM,CAAC,EAAI,MAAU,EAE/CX,EACE,OAAO,YACLS,EAAS,QAAQ,CAACG,EAAS,IAAM,CAC/B,IAAMC,EAAcH,EAAeA,EAAa,CAAC,EAAI,OACrD,OAAOI,EAAaF,CAAO,GAAKC,IAAgB,OAC5C,CAAC,CAACA,EAAaD,CAAO,CAAC,EACvB,CAAC,CACP,CAAC,CAC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AAW,CACT,MAAO,YAAYC,EAAQZ,CAAI,GAAK,WAAW,EACjD,CACF,CAEF","names":["FuncParameterType","applyExternals","existing","newExternals","key","value","getName","setName","addArgTypesToExternals","implementation","argTypes","argTypeNames","found","argType","argTypeName","isWgslStruct","addReturnTypeToExternals","returnType","matched","outputName","identifierRegex","name","replaceExternalsInWgsl","ctx","externalMap","wgsl","acc","externalName","external","externalRegex","isWgsl","isLooseData","hasTinyestMetadata","foundProperties","innerAcc","prop","extractArgs","rawCode","strippedCode","range","strip","code","ParsableString","args","attributes","closingParenthesis","parentheses","identifierEndSymbols","identifier","maybeType","typeEndSymbols","angleBrackets","maybeRet","argsStart","blankSpaces","lineBreaks","openingCommentBlock","commentBlocks","str","#pos","#parseStartPos","substr","i","elem","toFind","brackets","openedBrackets","steps","createFnCore","implementation","fnAttribute","externalsToApply","core","newExternals","ctx","argTypes","returnType","externalMap","externals","applyExternals","id","replacedImpl","replaceExternalsInWgsl","header","body","input","isWgslStruct","attributes","isWgslData","getAttributesString","output","Void","providedArgs","extractArgs","argInfo","i","checkAndReturnType","snip","pluginData","getMetaData","missing","name","ast","missingExternals","MissingLinksError","getName","maybeSecondArg","undecorate","args","argAliases","argType","astParam","FuncParameterType","rawName","snippet","alias","head","actualReturnType","maybeName","setName","wgslType","jsType","resolvedJsType","resolvedWgslType","withLocations","members","locations","nextLocation","usedCustomLocations","key","member","customLocation","getCustomLocation","isBuiltin","location","createIoSchema","layout","isData","isVoid","struct","stripTemplate","arg","values","isTemplateStringsArray","templateLiteralIdentity","value","item","strings","acc","elem","index","vertexFn","options","shell","createIoSchema","call","arg","values","createVertexFn","stripTemplate","implementation","core","createFnCore","inputType","newExternals","$internal","$getNameForward","newLabel","setName","isNamable","$resolve","ctx","outputWithLocation","getName"]}
package/chunk-CRZWTZM2.js DELETED
@@ -1,10 +0,0 @@
1
- var m="0.8.2";var o=Symbol(`typegpu:${m}:$internal`),kn=Symbol(`typegpu:${m}:$gpuValueOf`),me=Symbol(`typegpu:${m}:$getNameForward`),He=Symbol(`typegpu:${m}:$providing`),qe=Symbol(`typegpu:${m}:$ownSnippet`),oe=Symbol(`typegpu:${m}:$resolve`),Je=Symbol(`typegpu:${m}:$repr`),Fn=Symbol(`typegpu:${m}:$gpuRepr`),Pn=Symbol(`typegpu:${m}:$reprPartial`),Bn=Symbol(`typegpu:${m}:$memIdent`),En=Symbol(`typegpu:${m}:$invalidStorageSchema`),Un=Symbol(`typegpu:${m}:$validUniformSchema`),Nn=Symbol(`typegpu:${m}:$validVertexSchema`),Rn=Symbol(`typegpu:${m}:$invalidSchemaReason`);function u(e){return!!e?.[o]}var Mn={[o]:!0,type:"void",toString(){return"void"}},Wt=["bool","f32","f16","i32","u32","u16","vec2f","vec2h","vec2i","vec2u","vec2<bool>","vec3f","vec3h","vec3i","vec3u","vec3<bool>","vec4f","vec4h","vec4i","vec4u","vec4<bool>","mat2x2f","mat3x3f","mat4x4f","struct","array","ptr","atomic","decorated","abstractInt","abstractFloat","void","texture_1d","texture_storage_1d","texture_2d","texture_storage_2d","texture_multisampled_2d","texture_depth_2d","texture_depth_multisampled_2d","texture_2d_array","texture_storage_2d_array","texture_depth_2d_array","texture_cube","texture_depth_cube","texture_cube_array","texture_depth_cube_array","texture_3d","texture_storage_3d","texture_external","sampler","sampler_comparison"];function Ee(e){let t=e;return u(t)&&typeof t.kind=="string"&&t.kind.startsWith("vec")}function Ct(e){let t=e;return u(t)&&typeof t.type=="string"&&t.type.startsWith("vec2")}function Ot(e){let t=e;return u(t)&&typeof t.type=="string"&&t.type.startsWith("vec3")}function Mt(e){let t=e;return u(t)&&typeof t.type=="string"&&t.type.startsWith("vec4")}function ae(e){return Ct(e)||Ot(e)||Mt(e)}function Xe(e){let t=e;return u(t)&&typeof t.kind?.startsWith=="function"&&t.kind.startsWith("mat")}function Lt(e){return u(e)&&e?.type==="mat2x2f"}function jt(e){return u(e)&&e?.type==="mat3x3f"}function Gt(e){return u(e)&&e?.type==="mat4x4f"}function Ue(e){return Lt(e)||jt(e)||Gt(e)}function Ln(e){return Ee(e)&&["vec2f","vec3f","vec4f"].includes(e.kind)}function C(e){return u(e)&&Wt.includes(e?.type)}function fe(e){return u(e)&&e?.type==="array"}function we(e){return u(e)&&e?.type==="struct"}function jn(e){return u(e)&&e?.type==="ptr"}function Gn(e){return u(e)&&e?.type==="atomic"}function Te(e){return u(e)&&e?.type==="@align"}function ge(e){return u(e)&&e?.type==="@size"}function Ze(e){return u(e)&&e?.type==="@location"}function Kn(e){return u(e)&&e?.type==="@interpolate"}function Ne(e){return u(e)&&e?.type==="@builtin"}function _(e){return u(e)&&e?.type==="decorated"}function Yn(e){return u(e)&&e.type==="void"}function Qe(e){let t=e?.type;return u(e)&&(t==="abstractInt"||t==="abstractFloat"||t==="f32"||t==="f16"||t==="i32"||t==="u32")}function Hn(e){let t=e?.type;return u(e)&&(t==="f16"||t==="vec2h"||t==="vec3h"||t==="vec4h")}var A=process.env.NODE_ENV==="development",ve=process.env.NODE_ENV==="test";Object.assign(globalThis,{__TYPEGPU_AUTONAME__:(e,t)=>(Yt(e)&&u(e)&&!D(e)&&e.$name(t),e)});var ue=globalThis,Zn=(A||ve)&&{get enabled(){return!!ue.__TYPEGPU_MEASURE_PERF__},record(e,t){let n=ue.__TYPEGPU_PERF_RECORDS__??=new Map,r=n.get(e);r||(r=[],n.set(e,r)),r.push(t)}}||void 0;function et(e){return!!e?.[me]}function D(e){return et(e)?D(e[me]):nt(e)?.name}function k(e,t){et(e)&&k(e[me],t),Ht(e,{name:t})}function Yt(e){return!!e?.$name}function tt(e){return!!nt(e)?.ast}function nt(e){return ue.__TYPEGPU_META__.get(e)}function Ht(e,t){ue.__TYPEGPU_META__??=new WeakMap;let n=ue.__TYPEGPU_META__;n.set(e,{...n.get(e),...t})}var rt=["uint8","uint8x2","uint8x4","sint8","sint8x2","sint8x4","unorm8","unorm8x2","unorm8x4","snorm8","snorm8x2","snorm8x4","uint16","uint16x2","uint16x4","sint16","sint16x2","sint16x4","unorm16","unorm16x2","unorm16x4","snorm16","snorm16x2","snorm16x4","float16","float16x2","float16x4","float32","float32x2","float32x3","float32x4","uint32","uint32x2","uint32x3","uint32x4","sint32","sint32x2","sint32x3","sint32x4","unorm10-10-10-2","unorm8x4-bgra"],er={f32:"float32",vec2f:"float32x2",vec3f:"float32x3",vec4f:"float32x4",f16:"float16",vec2h:"float16x2",vec4h:"float16x4",u32:"uint32",vec2u:"uint32x2",vec3u:"uint32x3",vec4u:"uint32x4",i32:"sint32",vec2i:"sint32x2",vec3i:"sint32x3",vec4i:"sint32x4"};function S(e){return e.type==="decorated"||e.type==="loose-decorated"?e.inner:e}var qt=["unstruct","disarray","loose-decorated",...rt];function Re(e){return u(e)&&qt.includes(e?.type)}function ce(e){return u(e)&&e?.type==="disarray"}function ye(e){return u(e)&&e?.type==="unstruct"}function I(e){return u(e)&&e?.type==="loose-decorated"}function O(e){return e.attribs?.find(Te)?.params[0]}function at(e){return e.attribs?.find(ge)?.params[0]}function or(e){return e.attribs?.find(Ze)?.params[0]}function ar(e){return C(e)||Re(e)}var ut={type:"unknown",toString(){return"unknown"}},it=class{constructor(t,n,r){this.name=t;this.lhs=n;this.operator=r}},st=class{constructor(t){this.matrix=t}},ot=class{constructor(t){this.op=t;k(this,"consoleLog")}[o]=!0};var We="Invariant failed";function Ve(e,t){if(e)return;if(!A)throw new Error(We);let n=typeof t=="function"?t():t,r=n?`${We}: ${n}`:We;throw new Error(r)}var ct=class e extends Error{constructor(n,r){let i=r.map(s=>`- ${tt(s)?`fn*:${D(s)}`:s}`);i.length>20&&(i=[...i.slice(0,11),"...",...i.slice(-10)]);super(`Resolution of the following tree failed:
2
- ${i.join(`
3
- `)}: ${n&&typeof n=="object"&&"message"in n?n.message:n}`);this.cause=n;this.trace=r;Object.setPrototypeOf(this,e.prototype)}appendToTrace(n){let r=[n,...this.trace];return new e(this.cause,r)}},yt=class e extends Error{constructor(n,r){let i=r.map(s=>`- ${s}`);i.length>20&&(i=[...i.slice(0,11),"...",...i.slice(-10)]);super(`Execution of the following tree failed:
4
- ${i.join(`
5
- `)}: ${n&&typeof n=="object"&&"message"in n?n.message:n}`);this.cause=n;this.trace=r;Object.setPrototypeOf(this,e.prototype)}appendToTrace(n){let r=[n,...this.trace];return new e(this.cause,r)}},lt=class e extends Error{constructor(n){super(`Missing value for '${n}'`);this.slot=n;Object.setPrototypeOf(this,e.prototype)}},pt=class e extends Error{constructor(t){super(`Buffer '${D(t)??"<unnamed>"}' is not bindable as a uniform. Use .$usage('uniform') to allow it.`),Object.setPrototypeOf(this,e.prototype)}},ht=class e extends Error{constructor(t,n){super(`The function '${t??"<unnamed>"}' is missing links to the following external values: ${n}.`),Object.setPrototypeOf(this,e.prototype)}},xt=class e extends Error{constructor(t){super(`Missing bind groups for layouts: '${[...t].map(n=>D(n)??"<unnamed>").join(", ")}'. Please provide it using pipeline.with(bindGroup).(...)`),Object.setPrototypeOf(this,e.prototype)}},dt=class e extends Error{constructor(t){super(`Missing vertex buffers for layouts: '${[...t].map(n=>D(n)??"<unnamed>").join(", ")}'. Please provide it using pipeline.with(layout, buffer).(...)`),Object.setPrototypeOf(this,e.prototype)}},mt=class e extends Error{constructor(t){super(t),Object.setPrototypeOf(this,e.prototype)}},ft=class e extends Error{constructor(t){super(t),Object.setPrototypeOf(this,e.prototype)}},be=class e extends Error{constructor(t){super(t),Object.setPrototypeOf(this,e.prototype)}};function wt(e){return e?.resourceType==="slot"}function Tt(e){return e?.resourceType==="derived"}function gt(e){return e?.[He]!==void 0}function dr(e){return e?.resourceType==="accessor"}var ze=class{constructor(t,n){this.value=t;this.dataType=n}};function Ce(e){return e instanceof ze}function gr(e){return Qe(e.dataType)}function x(e,t){if(A&&Ce(e))throw new Error("Cannot nest snippets");return new ze(e,S(t))}var Se=class{type="normal"},vt=class{type="codegen"},bt=class{constructor(t,n){this.buffers=t;this.vars=n}type="simulate"};function Jt(e){return!!e?.[oe]}function Vt(e){return e?.[qe]}function _r(e){return typeof e=="number"||typeof e=="boolean"||typeof e=="string"||Jt(e)||C(e)||wt(e)||Tt(e)||gt(e)}function Ar(e){return!!e&&typeof e=="object"&&"getMappedRange"in e&&"mapAsync"in e}var Ie=!1;function Fr(e){if(Ie)return e();try{return Ie=!0,e()}finally{Ie=!1}}function Pr(){return Ie}var F;function Br(e,t){if(Ve(F===void 0||F===e,"Cannot nest context providers"),F===e)return t();F=e;try{return t()}finally{F=void 0}}function zt(){return F}var Xt=new Se;function Er(){return F?.mode??Xt}function Oe(){return F?.mode.type==="codegen"}function d(e,...t){let n=zt();function r(s){return Ce(s)?n.resolve(s.value,s.dataType).value:s}let i="";for(let s=0;s<e.length;++s){i+=e[s];let p=t[s];Array.isArray(p)?i+=p.filter(y=>y!==void 0).map(r).join(", "):p&&(i+=r(p))}return i}function St(e,t){throw new Error(`Failed to handle ${e} at ${t}`)}var Me={rank:Number.POSITIVE_INFINITY,action:"none"};function _e(e,t){let n=S(e),r=S(t);if(n.type===r.type)return{rank:0,action:"none"};if(n.type==="abstractFloat"){if(r.type==="f32")return{rank:1,action:"none"};if(r.type==="f16")return{rank:2,action:"none"}}if(n.type==="abstractInt"){if(r.type==="i32")return{rank:3,action:"none"};if(r.type==="u32")return{rank:4,action:"none"};if(r.type==="abstractFloat")return{rank:5,action:"none"};if(r.type==="f32")return{rank:6,action:"none"};if(r.type==="f16")return{rank:7,action:"none"}}return ae(n)&&ae(r)?_e(n.primitive,r.primitive):Ue(n)&&Ue(r)?{rank:0,action:"none"}:Me}function Zt(e,t){let n=S(e),r=S(t);if(n.type==="ptr"&&_e(n.inner,r).rank<Number.POSITIVE_INFINITY)return{rank:0,action:"deref"};if(r.type==="ptr"&&_e(n,r.inner).rank<Number.POSITIVE_INFINITY)return{rank:1,action:"ref"};let i={f32:0,f16:1,i32:2,u32:3,bool:4};if(n.type in i&&r.type in i){let s=n.type,p=r.type;if(s!==p){let y=i[s];return{rank:i[p]<y?10:20,action:"cast",targetType:r}}}if(n.type==="abstractFloat"){if(r.type==="u32")return{rank:2,action:"cast",targetType:r};if(r.type==="i32")return{rank:1,action:"cast",targetType:r}}return Me}function Qt(e,t,n){let r=_e(e,t);return r.rank<Number.POSITIVE_INFINITY?r:n?Zt(e,t):Me}function It(e,t,n){let r;for(let s of t){let p=[],y=0;for(let l of e){let g=Qt(l,s,n);if(y+=g.rank,g.rank===Number.POSITIVE_INFINITY)break;p.push(g)}y<(r?.sum??Number.POSITIVE_INFINITY)&&(r={type:s,details:p,sum:y})}if(!r)return;let i=r.details.map((s,p)=>({sourceIndex:p,action:s.action,...s.action==="cast"&&{targetType:s.targetType}}));return{targetType:r.type,actions:i,hasImplicitConversions:i.some(s=>s.action==="cast")}}function _t(e,t){if(e.length===0)return;let n=[...new Set((t||e).map(S))],r=It(e,n,!1);if(r)return r;let i=It(e,n,!0);if(i)return i}function en(e,t,n){if(t.action==="none")return x(e.value,n);switch(t.action){case"ref":return x(d`&${e}`,n);case"deref":return x(d`*${e}`,n);case"cast":return n(e);default:St(t.action,"applyActionToSnippet")}}function Hr(e,t){if(e.some(r=>r.type==="unknown"))return;let n=_t(e,t);if(n)return e.map(()=>n.targetType)}function At(e,t,n=!0){let r=e.map(s=>s.dataType);if(r.some(s=>s.type==="unknown"))return;A&&Array.isArray(t)&&t.length===0&&console.warn("convertToCommonType was called with an empty restrictTo array, which prevents any conversions from being made. If you intend to allow all conversions, pass undefined instead. If this was intended call the function conditionally since the result will always be undefined.");let i=_t(r,t);if(i)return(ve||A)&&n&&i.hasImplicitConversions&&console.warn(`Implicit conversions from [
6
- ${e.map(s=>` ${s.value}: ${s.dataType.type}`).join(`,
7
- `)}
8
- ] to ${i.targetType.type} are supported, but not recommended.
9
- Consider using explicit conversions instead.`),e.map((s,p)=>{let y=i.actions[p];return Ve(y,"Action should not be undefined"),en(s,y,i.targetType)})}function Dt(e,t,n=!0){if(t===e.dataType)return x(e.value,t);if(e.dataType.type==="unknown")return x(d`${x(e.value,t)}`,t);let r=At([e],[t],n);if(!r)throw new be(`Cannot convert value of type '${e.dataType.type}' to type '${t.type}'`);return r[0]}function qr(e,t){return Object.keys(e.propTypes).map(r=>{let i=t[r];if(!i)throw new Error(`Missing property ${r}`);let s=e.propTypes[r];return At([i],[s])?.[0]??i})}function tn(e){return typeof e!="string"&&Vt(e)===void 0}function $t(e,t,n,r="keep"){let i=((...s)=>Oe()?t(...s):e(...s));return k(i,n),i.toString=()=>n,Object.defineProperty(i,o,{value:{jsImpl:e,gpuImpl:t,argConversionHint:r}}),i}var Ae=class extends Error{constructor(t){super(t),this.name=this.constructor.name}};function P(e){let t=(...r)=>{let{argTypes:i,returnType:s}=typeof e.signature=="function"?e.signature(...r.map(l=>l.dataType)):e.signature,y=r.map((l,g)=>Dt(l,i[g],!e.ignoreImplicitCastWarning));if(y.every(l=>tn(l.value))&&typeof e.normalImpl=="function")try{return x(e.normalImpl(...y.map(l=>l.value)),s)}catch(l){if(!(l instanceof Ae))throw l}return x(e.codegenImpl(...y),s)},n=((...r)=>{if(Oe())return t(...r);if(typeof e.normalImpl=="string")throw new Ae(e.normalImpl);return e.normalImpl(...r)});return k(n,e.name),n.toString=()=>e.name,Object.defineProperty(n,o,{value:{jsImpl:e.normalImpl,gpuImpl:t,argConversionHint:"keep"}}),n}var ai={[o]:!0,type:"abstractInt",toString(){return"abstractInt"}},ui={[o]:!0,type:"abstractFloat",toString(){return"abstractFloat"}},nn=P({name:"bool",signature:e=>({argTypes:e?[e]:[],returnType:b}),normalImpl(e){return e===void 0?!1:typeof e=="boolean"?e:!!e},codegenImpl:e=>e.dataType.type==="bool"?d`${e}`:d`bool(${e})`}),b=Object.assign(nn,{type:"bool"}),rn=P({name:"u32",signature:e=>({argTypes:e?[e]:[],returnType:c}),normalImpl(e){return e===void 0?0:typeof e=="boolean"?e?1:0:(e&4294967295)>>>0},codegenImpl:e=>e.dataType.type==="u32"?d`${e}`:d`u32(${e})`}),c=Object.assign(rn,{type:"u32"}),sn=P({name:"i32",signature:e=>({argTypes:e?[e]:[],returnType:T}),normalImpl(e){return e===void 0?0:typeof e=="boolean"?e?1:0:e|0},codegenImpl:e=>e.dataType.type==="i32"?d`${e}`:d`i32(${e})`}),ci={[o]:!0,type:"u16"},T=Object.assign(sn,{type:"i32"}),on=P({name:"f32",signature:e=>({argTypes:e?[e]:[],returnType:h}),normalImpl(e){return e===void 0?0:typeof e=="boolean"?e?1:0:Math.fround(e)},codegenImpl:e=>e.dataType.type==="f32"?d`${e}`:d`f32(${e})`}),h=Object.assign(on,{type:"f32"}),kt=new ArrayBuffer(4),an=new Float32Array(kt),un=new Uint32Array(kt);function cn(e){an[0]=e;let t=un[0],n=t>>>31&1,r=t>>>23&255,i=t&8388607;return r===255?n<<15|31744|(i?512:0):(r=r-127+15,r<=0?r<-10?n<<15:(i=(i|8388608)>>1-r,i=i+4096>>13,n<<15|i):r>=31||(i=i+4096,i&8388608&&(i=0,++r,r>=31))?n<<15|31744:n<<15|r<<10|i>>13)}function yn(e){let t=e&32768?-1:1,n=e>>10&31,r=e&1023;return n===0?r?t*r*2**-24:t*0:n===31?r?Number.NaN:t===1?Number.POSITIVE_INFINITY:Number.NEGATIVE_INFINITY:t*(1+r/1024)*2**(n-15)}function ln(e){return yn(cn(e))}var pn=P({name:"f16",signature:e=>({argTypes:e?[e]:[],returnType:$}),normalImpl(e){return e===void 0?0:typeof e=="boolean"?e?1:0:ln(e)},codegenImpl:e=>e.dataType.type==="f16"?d`${e}`:d`f16(${e})`}),$=Object.assign(pn,{type:"f16"});var le=class extends Array{castElement(){return this[o].elementSchema[o].jsImpl}[oe](){let t=this[o].elementSchema;return this.every(n=>!n)?x(`${this.kind}()`,t):this.every(n=>this[0]===n)?x(`${this.kind}(${this[0]})`,t):x(`${this.kind}(${this.join(", ")})`,t)}toString(){return this[oe]().value}get xx(){return new this._Vec2(this[0],this[0])}get xy(){return new this._Vec2(this[0],this[1])}get xz(){return new this._Vec2(this[0],this[2])}get xw(){return new this._Vec2(this[0],this[3])}get yx(){return new this._Vec2(this[1],this[0])}get yy(){return new this._Vec2(this[1],this[1])}get yz(){return new this._Vec2(this[1],this[2])}get yw(){return new this._Vec2(this[1],this[3])}get zx(){return new this._Vec2(this[2],this[0])}get zy(){return new this._Vec2(this[2],this[1])}get zz(){return new this._Vec2(this[2],this[2])}get zw(){return new this._Vec2(this[2],this[3])}get wx(){return new this._Vec2(this[3],this[0])}get wy(){return new this._Vec2(this[3],this[1])}get wz(){return new this._Vec2(this[3],this[2])}get ww(){return new this._Vec2(this[3],this[3])}get xxx(){return new this._Vec3(this[0],this[0],this[0])}get xxy(){return new this._Vec3(this[0],this[0],this[1])}get xxz(){return new this._Vec3(this[0],this[0],this[2])}get xxw(){return new this._Vec3(this[0],this[0],this[3])}get xyx(){return new this._Vec3(this[0],this[1],this[0])}get xyy(){return new this._Vec3(this[0],this[1],this[1])}get xyz(){return new this._Vec3(this[0],this[1],this[2])}get xyw(){return new this._Vec3(this[0],this[1],this[3])}get xzx(){return new this._Vec3(this[0],this[2],this[0])}get xzy(){return new this._Vec3(this[0],this[2],this[1])}get xzz(){return new this._Vec3(this[0],this[2],this[2])}get xzw(){return new this._Vec3(this[0],this[2],this[3])}get xwx(){return new this._Vec3(this[0],this[3],this[0])}get xwy(){return new this._Vec3(this[0],this[3],this[1])}get xwz(){return new this._Vec3(this[0],this[3],this[2])}get xww(){return new this._Vec3(this[0],this[3],this[3])}get yxx(){return new this._Vec3(this[1],this[0],this[0])}get yxy(){return new this._Vec3(this[1],this[0],this[1])}get yxz(){return new this._Vec3(this[1],this[0],this[2])}get yxw(){return new this._Vec3(this[1],this[0],this[3])}get yyx(){return new this._Vec3(this[1],this[1],this[0])}get yyy(){return new this._Vec3(this[1],this[1],this[1])}get yyz(){return new this._Vec3(this[1],this[1],this[2])}get yyw(){return new this._Vec3(this[1],this[1],this[3])}get yzx(){return new this._Vec3(this[1],this[2],this[0])}get yzy(){return new this._Vec3(this[1],this[2],this[1])}get yzz(){return new this._Vec3(this[1],this[2],this[2])}get yzw(){return new this._Vec3(this[1],this[2],this[3])}get ywx(){return new this._Vec3(this[1],this[3],this[0])}get ywy(){return new this._Vec3(this[1],this[3],this[1])}get ywz(){return new this._Vec3(this[1],this[3],this[2])}get yww(){return new this._Vec3(this[1],this[3],this[3])}get zxx(){return new this._Vec3(this[2],this[0],this[0])}get zxy(){return new this._Vec3(this[2],this[0],this[1])}get zxz(){return new this._Vec3(this[2],this[0],this[2])}get zxw(){return new this._Vec3(this[2],this[0],this[3])}get zyx(){return new this._Vec3(this[2],this[1],this[0])}get zyy(){return new this._Vec3(this[2],this[1],this[1])}get zyz(){return new this._Vec3(this[2],this[1],this[2])}get zyw(){return new this._Vec3(this[2],this[1],this[3])}get zzx(){return new this._Vec3(this[2],this[2],this[0])}get zzy(){return new this._Vec3(this[2],this[2],this[1])}get zzz(){return new this._Vec3(this[2],this[2],this[2])}get zzw(){return new this._Vec3(this[2],this[2],this[3])}get zwx(){return new this._Vec3(this[2],this[3],this[0])}get zwy(){return new this._Vec3(this[2],this[3],this[1])}get zwz(){return new this._Vec3(this[2],this[3],this[2])}get zww(){return new this._Vec3(this[2],this[3],this[3])}get wxx(){return new this._Vec3(this[3],this[0],this[0])}get wxy(){return new this._Vec3(this[3],this[0],this[1])}get wxz(){return new this._Vec3(this[3],this[0],this[2])}get wxw(){return new this._Vec3(this[3],this[0],this[3])}get wyx(){return new this._Vec3(this[3],this[1],this[0])}get wyy(){return new this._Vec3(this[3],this[1],this[1])}get wyz(){return new this._Vec3(this[3],this[1],this[2])}get wyw(){return new this._Vec3(this[3],this[1],this[3])}get wzx(){return new this._Vec3(this[3],this[2],this[0])}get wzy(){return new this._Vec3(this[3],this[2],this[1])}get wzz(){return new this._Vec3(this[3],this[2],this[2])}get wzw(){return new this._Vec3(this[3],this[2],this[3])}get wwx(){return new this._Vec3(this[3],this[3],this[0])}get wwy(){return new this._Vec3(this[3],this[3],this[1])}get wwz(){return new this._Vec3(this[3],this[3],this[2])}get www(){return new this._Vec3(this[3],this[3],this[3])}get xxxx(){return new this._Vec4(this[0],this[0],this[0],this[0])}get xxxy(){return new this._Vec4(this[0],this[0],this[0],this[1])}get xxxz(){return new this._Vec4(this[0],this[0],this[0],this[2])}get xxxw(){return new this._Vec4(this[0],this[0],this[0],this[3])}get xxyx(){return new this._Vec4(this[0],this[0],this[1],this[0])}get xxyy(){return new this._Vec4(this[0],this[0],this[1],this[1])}get xxyz(){return new this._Vec4(this[0],this[0],this[1],this[2])}get xxyw(){return new this._Vec4(this[0],this[0],this[1],this[3])}get xxzx(){return new this._Vec4(this[0],this[0],this[2],this[0])}get xxzy(){return new this._Vec4(this[0],this[0],this[2],this[1])}get xxzz(){return new this._Vec4(this[0],this[0],this[2],this[2])}get xxzw(){return new this._Vec4(this[0],this[0],this[2],this[3])}get xxwx(){return new this._Vec4(this[0],this[0],this[3],this[0])}get xxwy(){return new this._Vec4(this[0],this[0],this[3],this[1])}get xxwz(){return new this._Vec4(this[0],this[0],this[3],this[2])}get xxww(){return new this._Vec4(this[0],this[0],this[3],this[3])}get xyxx(){return new this._Vec4(this[0],this[1],this[0],this[0])}get xyxy(){return new this._Vec4(this[0],this[1],this[0],this[1])}get xyxz(){return new this._Vec4(this[0],this[1],this[0],this[2])}get xyxw(){return new this._Vec4(this[0],this[1],this[0],this[3])}get xyyx(){return new this._Vec4(this[0],this[1],this[1],this[0])}get xyyy(){return new this._Vec4(this[0],this[1],this[1],this[1])}get xyyz(){return new this._Vec4(this[0],this[1],this[1],this[2])}get xyyw(){return new this._Vec4(this[0],this[1],this[1],this[3])}get xyzx(){return new this._Vec4(this[0],this[1],this[2],this[0])}get xyzy(){return new this._Vec4(this[0],this[1],this[2],this[1])}get xyzz(){return new this._Vec4(this[0],this[1],this[2],this[2])}get xyzw(){return new this._Vec4(this[0],this[1],this[2],this[3])}get xywx(){return new this._Vec4(this[0],this[1],this[3],this[0])}get xywy(){return new this._Vec4(this[0],this[1],this[3],this[1])}get xywz(){return new this._Vec4(this[0],this[1],this[3],this[2])}get xyww(){return new this._Vec4(this[0],this[1],this[3],this[3])}get xzxx(){return new this._Vec4(this[0],this[2],this[0],this[0])}get xzxy(){return new this._Vec4(this[0],this[2],this[0],this[1])}get xzxz(){return new this._Vec4(this[0],this[2],this[0],this[2])}get xzxw(){return new this._Vec4(this[0],this[2],this[0],this[3])}get xzyx(){return new this._Vec4(this[0],this[2],this[1],this[0])}get xzyy(){return new this._Vec4(this[0],this[2],this[1],this[1])}get xzyz(){return new this._Vec4(this[0],this[2],this[1],this[2])}get xzyw(){return new this._Vec4(this[0],this[2],this[1],this[3])}get xzzx(){return new this._Vec4(this[0],this[2],this[2],this[0])}get xzzy(){return new this._Vec4(this[0],this[2],this[2],this[1])}get xzzz(){return new this._Vec4(this[0],this[2],this[2],this[2])}get xzzw(){return new this._Vec4(this[0],this[2],this[2],this[3])}get xzwx(){return new this._Vec4(this[0],this[2],this[3],this[0])}get xzwy(){return new this._Vec4(this[0],this[2],this[3],this[1])}get xzwz(){return new this._Vec4(this[0],this[2],this[3],this[2])}get xzww(){return new this._Vec4(this[0],this[2],this[3],this[3])}get xwxx(){return new this._Vec4(this[0],this[3],this[0],this[0])}get xwxy(){return new this._Vec4(this[0],this[3],this[0],this[1])}get xwxz(){return new this._Vec4(this[0],this[3],this[0],this[2])}get xwxw(){return new this._Vec4(this[0],this[3],this[0],this[3])}get xwyx(){return new this._Vec4(this[0],this[3],this[1],this[0])}get xwyy(){return new this._Vec4(this[0],this[3],this[1],this[1])}get xwyz(){return new this._Vec4(this[0],this[3],this[1],this[2])}get xwyw(){return new this._Vec4(this[0],this[3],this[1],this[3])}get xwzx(){return new this._Vec4(this[0],this[3],this[2],this[0])}get xwzy(){return new this._Vec4(this[0],this[3],this[2],this[1])}get xwzz(){return new this._Vec4(this[0],this[3],this[2],this[2])}get xwzw(){return new this._Vec4(this[0],this[3],this[2],this[3])}get xwwx(){return new this._Vec4(this[0],this[3],this[3],this[0])}get xwwy(){return new this._Vec4(this[0],this[3],this[3],this[1])}get xwwz(){return new this._Vec4(this[0],this[3],this[3],this[2])}get xwww(){return new this._Vec4(this[0],this[3],this[3],this[3])}get yxxx(){return new this._Vec4(this[1],this[0],this[0],this[0])}get yxxy(){return new this._Vec4(this[1],this[0],this[0],this[1])}get yxxz(){return new this._Vec4(this[1],this[0],this[0],this[2])}get yxxw(){return new this._Vec4(this[1],this[0],this[0],this[3])}get yxyx(){return new this._Vec4(this[1],this[0],this[1],this[0])}get yxyy(){return new this._Vec4(this[1],this[0],this[1],this[1])}get yxyz(){return new this._Vec4(this[1],this[0],this[1],this[2])}get yxyw(){return new this._Vec4(this[1],this[0],this[1],this[3])}get yxzx(){return new this._Vec4(this[1],this[0],this[2],this[0])}get yxzy(){return new this._Vec4(this[1],this[0],this[2],this[1])}get yxzz(){return new this._Vec4(this[1],this[0],this[2],this[2])}get yxzw(){return new this._Vec4(this[1],this[0],this[2],this[3])}get yxwx(){return new this._Vec4(this[1],this[0],this[3],this[0])}get yxwy(){return new this._Vec4(this[1],this[0],this[3],this[1])}get yxwz(){return new this._Vec4(this[1],this[0],this[3],this[2])}get yxww(){return new this._Vec4(this[1],this[0],this[3],this[3])}get yyxx(){return new this._Vec4(this[1],this[1],this[0],this[0])}get yyxy(){return new this._Vec4(this[1],this[1],this[0],this[1])}get yyxz(){return new this._Vec4(this[1],this[1],this[0],this[2])}get yyxw(){return new this._Vec4(this[1],this[1],this[0],this[3])}get yyyx(){return new this._Vec4(this[1],this[1],this[1],this[0])}get yyyy(){return new this._Vec4(this[1],this[1],this[1],this[1])}get yyyz(){return new this._Vec4(this[1],this[1],this[1],this[2])}get yyyw(){return new this._Vec4(this[1],this[1],this[1],this[3])}get yyzx(){return new this._Vec4(this[1],this[1],this[2],this[0])}get yyzy(){return new this._Vec4(this[1],this[1],this[2],this[1])}get yyzz(){return new this._Vec4(this[1],this[1],this[2],this[2])}get yyzw(){return new this._Vec4(this[1],this[1],this[2],this[3])}get yywx(){return new this._Vec4(this[1],this[1],this[3],this[0])}get yywy(){return new this._Vec4(this[1],this[1],this[3],this[1])}get yywz(){return new this._Vec4(this[1],this[1],this[3],this[2])}get yyww(){return new this._Vec4(this[1],this[1],this[3],this[3])}get yzxx(){return new this._Vec4(this[1],this[2],this[0],this[0])}get yzxy(){return new this._Vec4(this[1],this[2],this[0],this[1])}get yzxz(){return new this._Vec4(this[1],this[2],this[0],this[2])}get yzxw(){return new this._Vec4(this[1],this[2],this[0],this[3])}get yzyx(){return new this._Vec4(this[1],this[2],this[1],this[0])}get yzyy(){return new this._Vec4(this[1],this[2],this[1],this[1])}get yzyz(){return new this._Vec4(this[1],this[2],this[1],this[2])}get yzyw(){return new this._Vec4(this[1],this[2],this[1],this[3])}get yzzx(){return new this._Vec4(this[1],this[2],this[2],this[0])}get yzzy(){return new this._Vec4(this[1],this[2],this[2],this[1])}get yzzz(){return new this._Vec4(this[1],this[2],this[2],this[2])}get yzzw(){return new this._Vec4(this[1],this[2],this[2],this[3])}get yzwx(){return new this._Vec4(this[1],this[2],this[3],this[0])}get yzwy(){return new this._Vec4(this[1],this[2],this[3],this[1])}get yzwz(){return new this._Vec4(this[1],this[2],this[3],this[2])}get yzww(){return new this._Vec4(this[1],this[2],this[3],this[3])}get ywxx(){return new this._Vec4(this[1],this[3],this[0],this[0])}get ywxy(){return new this._Vec4(this[1],this[3],this[0],this[1])}get ywxz(){return new this._Vec4(this[1],this[3],this[0],this[2])}get ywxw(){return new this._Vec4(this[1],this[3],this[0],this[3])}get ywyx(){return new this._Vec4(this[1],this[3],this[1],this[0])}get ywyy(){return new this._Vec4(this[1],this[3],this[1],this[1])}get ywyz(){return new this._Vec4(this[1],this[3],this[1],this[2])}get ywyw(){return new this._Vec4(this[1],this[3],this[1],this[3])}get ywzx(){return new this._Vec4(this[1],this[3],this[2],this[0])}get ywzy(){return new this._Vec4(this[1],this[3],this[2],this[1])}get ywzz(){return new this._Vec4(this[1],this[3],this[2],this[2])}get ywzw(){return new this._Vec4(this[1],this[3],this[2],this[3])}get ywwx(){return new this._Vec4(this[1],this[3],this[3],this[0])}get ywwy(){return new this._Vec4(this[1],this[3],this[3],this[1])}get ywwz(){return new this._Vec4(this[1],this[3],this[3],this[2])}get ywww(){return new this._Vec4(this[1],this[3],this[3],this[3])}get zxxx(){return new this._Vec4(this[2],this[0],this[0],this[0])}get zxxy(){return new this._Vec4(this[2],this[0],this[0],this[1])}get zxxz(){return new this._Vec4(this[2],this[0],this[0],this[2])}get zxxw(){return new this._Vec4(this[2],this[0],this[0],this[3])}get zxyx(){return new this._Vec4(this[2],this[0],this[1],this[0])}get zxyy(){return new this._Vec4(this[2],this[0],this[1],this[1])}get zxyz(){return new this._Vec4(this[2],this[0],this[1],this[2])}get zxyw(){return new this._Vec4(this[2],this[0],this[1],this[3])}get zxzx(){return new this._Vec4(this[2],this[0],this[2],this[0])}get zxzy(){return new this._Vec4(this[2],this[0],this[2],this[1])}get zxzz(){return new this._Vec4(this[2],this[0],this[2],this[2])}get zxzw(){return new this._Vec4(this[2],this[0],this[2],this[3])}get zxwx(){return new this._Vec4(this[2],this[0],this[3],this[0])}get zxwy(){return new this._Vec4(this[2],this[0],this[3],this[1])}get zxwz(){return new this._Vec4(this[2],this[0],this[3],this[2])}get zxww(){return new this._Vec4(this[2],this[0],this[3],this[3])}get zyxx(){return new this._Vec4(this[2],this[1],this[0],this[0])}get zyxy(){return new this._Vec4(this[2],this[1],this[0],this[1])}get zyxz(){return new this._Vec4(this[2],this[1],this[0],this[2])}get zyxw(){return new this._Vec4(this[2],this[1],this[0],this[3])}get zyyx(){return new this._Vec4(this[2],this[1],this[1],this[0])}get zyyy(){return new this._Vec4(this[2],this[1],this[1],this[1])}get zyyz(){return new this._Vec4(this[2],this[1],this[1],this[2])}get zyyw(){return new this._Vec4(this[2],this[1],this[1],this[3])}get zyzx(){return new this._Vec4(this[2],this[1],this[2],this[0])}get zyzy(){return new this._Vec4(this[2],this[1],this[2],this[1])}get zyzz(){return new this._Vec4(this[2],this[1],this[2],this[2])}get zyzw(){return new this._Vec4(this[2],this[1],this[2],this[3])}get zywx(){return new this._Vec4(this[2],this[1],this[3],this[0])}get zywy(){return new this._Vec4(this[2],this[1],this[3],this[1])}get zywz(){return new this._Vec4(this[2],this[1],this[3],this[2])}get zyww(){return new this._Vec4(this[2],this[1],this[3],this[3])}get zzxx(){return new this._Vec4(this[2],this[2],this[0],this[0])}get zzxy(){return new this._Vec4(this[2],this[2],this[0],this[1])}get zzxz(){return new this._Vec4(this[2],this[2],this[0],this[2])}get zzxw(){return new this._Vec4(this[2],this[2],this[0],this[3])}get zzyx(){return new this._Vec4(this[2],this[2],this[1],this[0])}get zzyy(){return new this._Vec4(this[2],this[2],this[1],this[1])}get zzyz(){return new this._Vec4(this[2],this[2],this[1],this[2])}get zzyw(){return new this._Vec4(this[2],this[2],this[1],this[3])}get zzzx(){return new this._Vec4(this[2],this[2],this[2],this[0])}get zzzy(){return new this._Vec4(this[2],this[2],this[2],this[1])}get zzzz(){return new this._Vec4(this[2],this[2],this[2],this[2])}get zzzw(){return new this._Vec4(this[2],this[2],this[2],this[3])}get zzwx(){return new this._Vec4(this[2],this[2],this[3],this[0])}get zzwy(){return new this._Vec4(this[2],this[2],this[3],this[1])}get zzwz(){return new this._Vec4(this[2],this[2],this[3],this[2])}get zzww(){return new this._Vec4(this[2],this[2],this[3],this[3])}get zwxx(){return new this._Vec4(this[2],this[3],this[0],this[0])}get zwxy(){return new this._Vec4(this[2],this[3],this[0],this[1])}get zwxz(){return new this._Vec4(this[2],this[3],this[0],this[2])}get zwxw(){return new this._Vec4(this[2],this[3],this[0],this[3])}get zwyx(){return new this._Vec4(this[2],this[3],this[1],this[0])}get zwyy(){return new this._Vec4(this[2],this[3],this[1],this[1])}get zwyz(){return new this._Vec4(this[2],this[3],this[1],this[2])}get zwyw(){return new this._Vec4(this[2],this[3],this[1],this[3])}get zwzx(){return new this._Vec4(this[2],this[3],this[2],this[0])}get zwzy(){return new this._Vec4(this[2],this[3],this[2],this[1])}get zwzz(){return new this._Vec4(this[2],this[3],this[2],this[2])}get zwzw(){return new this._Vec4(this[2],this[3],this[2],this[3])}get zwwx(){return new this._Vec4(this[2],this[3],this[3],this[0])}get zwwy(){return new this._Vec4(this[2],this[3],this[3],this[1])}get zwwz(){return new this._Vec4(this[2],this[3],this[3],this[2])}get zwww(){return new this._Vec4(this[2],this[3],this[3],this[3])}get wxxx(){return new this._Vec4(this[3],this[0],this[0],this[0])}get wxxy(){return new this._Vec4(this[3],this[0],this[0],this[1])}get wxxz(){return new this._Vec4(this[3],this[0],this[0],this[2])}get wxxw(){return new this._Vec4(this[3],this[0],this[0],this[3])}get wxyx(){return new this._Vec4(this[3],this[0],this[1],this[0])}get wxyy(){return new this._Vec4(this[3],this[0],this[1],this[1])}get wxyz(){return new this._Vec4(this[3],this[0],this[1],this[2])}get wxyw(){return new this._Vec4(this[3],this[0],this[1],this[3])}get wxzx(){return new this._Vec4(this[3],this[0],this[2],this[0])}get wxzy(){return new this._Vec4(this[3],this[0],this[2],this[1])}get wxzz(){return new this._Vec4(this[3],this[0],this[2],this[2])}get wxzw(){return new this._Vec4(this[3],this[0],this[2],this[3])}get wxwx(){return new this._Vec4(this[3],this[0],this[3],this[0])}get wxwy(){return new this._Vec4(this[3],this[0],this[3],this[1])}get wxwz(){return new this._Vec4(this[3],this[0],this[3],this[2])}get wxww(){return new this._Vec4(this[3],this[0],this[3],this[3])}get wyxx(){return new this._Vec4(this[3],this[1],this[0],this[0])}get wyxy(){return new this._Vec4(this[3],this[1],this[0],this[1])}get wyxz(){return new this._Vec4(this[3],this[1],this[0],this[2])}get wyxw(){return new this._Vec4(this[3],this[1],this[0],this[3])}get wyyx(){return new this._Vec4(this[3],this[1],this[1],this[0])}get wyyy(){return new this._Vec4(this[3],this[1],this[1],this[1])}get wyyz(){return new this._Vec4(this[3],this[1],this[1],this[2])}get wyyw(){return new this._Vec4(this[3],this[1],this[1],this[3])}get wyzx(){return new this._Vec4(this[3],this[1],this[2],this[0])}get wyzy(){return new this._Vec4(this[3],this[1],this[2],this[1])}get wyzz(){return new this._Vec4(this[3],this[1],this[2],this[2])}get wyzw(){return new this._Vec4(this[3],this[1],this[2],this[3])}get wywx(){return new this._Vec4(this[3],this[1],this[3],this[0])}get wywy(){return new this._Vec4(this[3],this[1],this[3],this[1])}get wywz(){return new this._Vec4(this[3],this[1],this[3],this[2])}get wyww(){return new this._Vec4(this[3],this[1],this[3],this[3])}get wzxx(){return new this._Vec4(this[3],this[2],this[0],this[0])}get wzxy(){return new this._Vec4(this[3],this[2],this[0],this[1])}get wzxz(){return new this._Vec4(this[3],this[2],this[0],this[2])}get wzxw(){return new this._Vec4(this[3],this[2],this[0],this[3])}get wzyx(){return new this._Vec4(this[3],this[2],this[1],this[0])}get wzyy(){return new this._Vec4(this[3],this[2],this[1],this[1])}get wzyz(){return new this._Vec4(this[3],this[2],this[1],this[2])}get wzyw(){return new this._Vec4(this[3],this[2],this[1],this[3])}get wzzx(){return new this._Vec4(this[3],this[2],this[2],this[0])}get wzzy(){return new this._Vec4(this[3],this[2],this[2],this[1])}get wzzz(){return new this._Vec4(this[3],this[2],this[2],this[2])}get wzzw(){return new this._Vec4(this[3],this[2],this[2],this[3])}get wzwx(){return new this._Vec4(this[3],this[2],this[3],this[0])}get wzwy(){return new this._Vec4(this[3],this[2],this[3],this[1])}get wzwz(){return new this._Vec4(this[3],this[2],this[3],this[2])}get wzww(){return new this._Vec4(this[3],this[2],this[3],this[3])}get wwxx(){return new this._Vec4(this[3],this[3],this[0],this[0])}get wwxy(){return new this._Vec4(this[3],this[3],this[0],this[1])}get wwxz(){return new this._Vec4(this[3],this[3],this[0],this[2])}get wwxw(){return new this._Vec4(this[3],this[3],this[0],this[3])}get wwyx(){return new this._Vec4(this[3],this[3],this[1],this[0])}get wwyy(){return new this._Vec4(this[3],this[3],this[1],this[1])}get wwyz(){return new this._Vec4(this[3],this[3],this[1],this[2])}get wwyw(){return new this._Vec4(this[3],this[3],this[1],this[3])}get wwzx(){return new this._Vec4(this[3],this[3],this[2],this[0])}get wwzy(){return new this._Vec4(this[3],this[3],this[2],this[1])}get wwzz(){return new this._Vec4(this[3],this[3],this[2],this[2])}get wwzw(){return new this._Vec4(this[3],this[3],this[2],this[3])}get wwwx(){return new this._Vec4(this[3],this[3],this[3],this[0])}get wwwy(){return new this._Vec4(this[3],this[3],this[3],this[1])}get wwwz(){return new this._Vec4(this[3],this[3],this[3],this[2])}get wwww(){return new this._Vec4(this[3],this[3],this[3],this[3])}},U=class extends le{e0;e1;constructor(t,n){super(2),this.e0=this.castElement()(t),this.e1=this.castElement()(n??t)}get 0(){return this.e0}get 1(){return this.e1}set 0(t){this.e0=this.castElement()(t)}set 1(t){this.e1=this.castElement()(t)}get x(){return this[0]}get y(){return this[1]}set x(t){this[0]=this.castElement()(t)}set y(t){this[1]=this.castElement()(t)}},N=class extends le{e0;e1;e2;constructor(t,n,r){super(3),this.e0=this.castElement()(t),this.e1=this.castElement()(n??t),this.e2=this.castElement()(r??t)}get 0(){return this.e0}get 1(){return this.e1}get 2(){return this.e2}set 0(t){this.e0=this.castElement()(t)}set 1(t){this.e1=this.castElement()(t)}set 2(t){this.e2=this.castElement()(t)}get x(){return this[0]}get y(){return this[1]}get z(){return this[2]}set x(t){this[0]=this.castElement()(t)}set y(t){this[1]=this.castElement()(t)}set z(t){this[2]=this.castElement()(t)}},R=class extends le{e0;e1;e2;e3;constructor(t,n,r,i){super(4),this.e0=this.castElement()(t),this.e1=this.castElement()(n??t),this.e2=this.castElement()(r??t),this.e3=this.castElement()(i??t)}get 0(){return this.e0}get 1(){return this.e1}get 2(){return this.e2}get 3(){return this.e3}set 0(t){this.e0=this.castElement()(t)}set 1(t){this.e1=this.castElement()(t)}set 2(t){this.e2=this.castElement()(t)}set 3(t){this.e3=this.castElement()(t)}get x(){return this[0]}get y(){return this[1]}get z(){return this[2]}get w(){return this[3]}set x(t){this[0]=t}set y(t){this[1]=t}set z(t){this[2]=t}set w(t){this[3]=t}},M=class e extends U{get[o](){return{elementSchema:h}}get kind(){return"vec2f"}get _Vec2(){return e}get _Vec3(){return Y}get _Vec4(){return Z}},L=class e extends U{get[o](){return{elementSchema:$}}get kind(){return"vec2h"}get _Vec2(){return e}get _Vec3(){return H}get _Vec4(){return Q}},j=class e extends U{get[o](){return{elementSchema:T}}get kind(){return"vec2i"}get _Vec2(){return e}get _Vec3(){return q}get _Vec4(){return ee}},G=class e extends U{get[o](){return{elementSchema:c}}get kind(){return"vec2u"}get _Vec2(){return e}get _Vec3(){return J}get _Vec4(){return te}},K=class e extends U{get[o](){return{elementSchema:b}}get kind(){return"vec2<bool>"}get _Vec2(){return e}get _Vec3(){return X}get _Vec4(){return ne}},Y=class e extends N{get[o](){return{elementSchema:h}}get kind(){return"vec3f"}get _Vec2(){return M}get _Vec3(){return e}get _Vec4(){return Z}},H=class e extends N{get[o](){return{elementSchema:$}}get kind(){return"vec3h"}get _Vec2(){return L}get _Vec3(){return e}get _Vec4(){return Q}},q=class e extends N{get[o](){return{elementSchema:T}}get kind(){return"vec3i"}get _Vec2(){return j}get _Vec3(){return e}get _Vec4(){return ee}},J=class e extends N{get[o](){return{elementSchema:c}}get kind(){return"vec3u"}get _Vec2(){return G}get _Vec3(){return e}get _Vec4(){return te}},X=class e extends N{get[o](){return{elementSchema:b}}get kind(){return"vec3<bool>"}get _Vec2(){return K}get _Vec3(){return e}get _Vec4(){return ne}},Z=class e extends R{get[o](){return{elementSchema:h}}get kind(){return"vec4f"}get _Vec2(){return M}get _Vec3(){return Y}get _Vec4(){return e}},Q=class e extends R{get[o](){return{elementSchema:$}}get kind(){return"vec4h"}get _Vec2(){return L}get _Vec3(){return H}get _Vec4(){return e}},ee=class e extends R{get[o](){return{elementSchema:T}}get kind(){return"vec4i"}get _Vec2(){return j}get _Vec3(){return q}get _Vec4(){return e}},te=class e extends R{get[o](){return{elementSchema:c}}get kind(){return"vec4u"}get _Vec2(){return G}get _Vec3(){return J}get _Vec4(){return e}},ne=class e extends R{get[o](){return{elementSchema:b}}get kind(){return"vec4<bool>"}get _Vec2(){return K}get _Vec3(){return X}get _Vec4(){return e}};var B=f(M,h),hn=f(L,$),pe=f(j,T),he=f(G,c),xn=f(K,b),Le=f(Y,h),dn=f(H,$),je=f(q,T),E=f(J,c),mn=f(X,b),v=f(Z,h),fn=f(Q,$),xe=f(ee,T),de=f(te,c),wn=f(ne,b),bi={vec2f:B,vec2h:hn,vec2i:pe,vec2u:he,"vec2<bool>":xn,vec3f:Le,vec3h:dn,vec3i:je,vec3u:E,"vec3<bool>":mn,vec4f:v,vec4h:fn,vec4i:xe,vec4u:de,"vec4<bool>":wn};function f(e,t){let{kind:n,length:r}=new e,s=P({name:n,signature:(...y)=>({argTypes:y.map(l=>{let g=S(l);return ae(g)?g:t}),returnType:p}),normalImpl:(...y)=>{let l=new Array(y.length),g=0;for(let se of y)if(typeof se=="number"||typeof se=="boolean")l[g++]=se;else for(let Be=0;Be<se.length;++Be)l[g++]=se[Be];if(l.length<=1||l.length===r)return new e(...l);throw new Error(`'${n}' constructor called with invalid number of arguments.`)},ignoreImplicitCastWarning:!0,codegenImpl:(...y)=>d`${n}(${y})`}),p=Object.assign(s,{type:n,primitive:t,[Je]:void 0});return p}var a=class{constructor(t){this.type=t}[o]=!0},De={uint8:c,uint8x2:he,uint8x4:de,sint8:T,sint8x2:pe,sint8x4:xe,unorm8:h,unorm8x2:B,unorm8x4:v,snorm8:h,snorm8x2:B,snorm8x4:v,uint16:c,uint16x2:he,uint16x4:de,sint16:T,sint16x2:pe,sint16x4:xe,unorm16:h,unorm16x2:B,unorm16x4:v,snorm16:h,snorm16x2:B,snorm16x4:v,float16:h,float16x2:B,float16x4:v,float32:h,float32x2:B,float32x3:Le,float32x4:v,uint32:c,uint32x2:he,uint32x3:E,uint32x4:de,sint32:T,sint32x2:pe,sint32x3:je,sint32x4:xe,"unorm10-10-10-2":v,"unorm8x4-bgra":v},Ge=new Set(Object.keys(De)),Ai=new a("uint8"),Di=new a("uint8x2"),$i=new a("uint8x4"),ki=new a("sint8"),Fi=new a("sint8x2"),Pi=new a("sint8x4"),Bi=new a("unorm8"),Ei=new a("unorm8x2"),Ui=new a("unorm8x4"),Ni=new a("snorm8"),Ri=new a("snorm8x2"),Wi=new a("snorm8x4"),Ci=new a("uint16"),Oi=new a("uint16x2"),Mi=new a("uint16x4"),Li=new a("sint16"),ji=new a("sint16x2"),Gi=new a("sint16x4"),Ki=new a("unorm16"),Yi=new a("unorm16x2"),Hi=new a("unorm16x4"),qi=new a("snorm16"),Ji=new a("snorm16x2"),Xi=new a("snorm16x4"),Zi=new a("float16"),Qi=new a("float16x2"),es=new a("float16x4"),ts=new a("float32"),ns=new a("float32x2"),rs=new a("float32x3"),is=new a("float32x4"),ss=new a("uint32"),os=new a("uint32x2"),as=new a("uint32x3"),us=new a("uint32x4"),cs=new a("sint32"),ys=new a("sint32x2"),ls=new a("sint32x3"),ps=new a("sint32x4"),hs=new a("unorm10-10-10-2"),xs=new a("unorm8x4-bgra");function ds(e){return u(e)&&Ge.has(e?.type)}function Pt(e){let t=String(e);if(t!=="[object Object]")return t;try{return JSON.stringify(e)}catch(n){return console.error("Error parsing JSON:",n),"<invalid json>"}}function Ft(e){return Ee(e)||Xe(e)?e.toString():Array.isArray(e)?`[${e.map(Ft).join(", ")}]`:e&&typeof e=="object"?`{ ${Object.entries(e).map(([t,n])=>`${t}: ${Ft(n)}`).join(", ")} }`:String(e)}var Tn={f32:4,f16:2,i32:4,u32:4,bool:4,u16:2,vec2f:8,vec2h:4,vec2i:8,vec2u:8,vec2b:8,vec3f:16,vec3h:8,vec3i:16,vec3u:16,vec3b:16,vec4f:16,vec4h:8,vec4i:16,vec4u:16,vec4b:16,mat2x2f:8,mat3x3f:16,mat4x4f:16,atomic:4};function gn(e){let t=e?.type,n=Tn[t];if(n!==void 0)return n;if(we(e))return Object.values(e.propTypes).map(V).reduce((r,i)=>r>i?r:i);if(fe(e))return V(e.elementType);if(ye(e)){let r=Object.values(e.propTypes)[0];return r?O(r)??1:1}if(ce(e))return O(e.elementType)??1;if(_(e)||I(e))return O(e)??V(e.inner);if(Ge.has(t))return 1;throw new Error(`Cannot determine alignment of data: ${Pt(e)}`)}function vn(e){if(ye(e)){let t=Object.values(e.propTypes)[0];return t?re(t):1}return ce(e)?re(e.elementType):I(e)?O(e)??re(e.inner):O(e)??1}var Bt=new WeakMap,Et=new WeakMap;function V(e){let t=Bt.get(e);return t===void 0&&(t=gn(e),Bt.set(e,t)),t}function re(e){let t=Et.get(e);return t===void 0&&(t=vn(e),Et.set(e,t)),t}function Vs(e){return V(e)}var ie=(e,t)=>{let n=t-1,r=~n;return(e&n)===0?e:(e&r)+t};var bn={bool:4,f32:4,f16:2,i32:4,u32:4,u16:2,vec2f:8,vec2h:4,vec2i:8,vec2u:8,"vec2<bool>":8,vec3f:12,vec3h:6,vec3i:12,vec3u:12,"vec3<bool>":12,vec4f:16,vec4h:8,vec4i:16,vec4u:16,"vec4<bool>":16,mat2x2f:16,mat3x3f:48,mat4x4f:64,uint8:1,uint8x2:2,uint8x4:4,sint8:1,sint8x2:2,sint8x4:4,unorm8:1,unorm8x2:2,unorm8x4:4,snorm8:1,snorm8x2:2,snorm8x4:4,uint16:2,uint16x2:4,uint16x4:8,sint16:2,sint16x2:4,sint16x4:8,unorm16:2,unorm16x2:4,unorm16x4:8,snorm16:2,snorm16x2:4,snorm16x4:8,float16:2,float16x2:4,float16x4:8,float32:4,float32x2:8,float32x3:12,float32x4:16,uint32:4,uint32x2:8,uint32x3:12,uint32x4:16,sint32:4,sint32x2:8,sint32x3:12,sint32x4:16,"unorm10-10-10-2":4,"unorm8x4-bgra":4,atomic:4};function Vn(e){let t=0,n=e.propTypes;for(let r of Object.values(n)){if(Number.isNaN(t))throw new Error("Only the last property of a struct can be unbounded");if(t=ie(t,V(r)),t+=z(r),Number.isNaN(t)&&r.type!=="array")throw new Error("Cannot nest unbounded struct within another struct")}return ie(t,V(e))}function zn(e){let t=0,n=e.propTypes;for(let r of Object.values(n)){let i=re(r);t=ie(t,i),t+=z(r)}return t}function Sn(e){let t=bn[e?.type];if(t!==void 0)return t;if(we(e))return Vn(e);if(ye(e))return zn(e);if(fe(e)){if(e.elementCount===0)return Number.NaN;let n=V(e.elementType);return ie(z(e.elementType),n)*e.elementCount}if(ce(e)){let n=re(e.elementType);return ie(z(e.elementType),n)*e.elementCount}if(_(e)||I(e))return at(e)??z(e.inner);throw new Error(`Cannot determine size of data: ${e}`)}var Ut=new WeakMap;function z(e){let t=Ut.get(e);return t===void 0&&(t=Sn(e),Ut.set(e,t)),t}function $s(e){return z(e)}function W(e,t){return _(e)?new ke(e.inner,[t,...e.attribs]):I(e)?new Fe(e.inner,[t,...e.attribs]):Re(e)?new Fe(e,[t]):new ke(e,[t])}function Ns(e,t){return W(t,{[o]:!0,type:"@align",params:[e]})}function Rs(e,t){return W(t,{[o]:!0,type:"@size",params:[e]})}function Ws(e,t){return W(t,{[o]:!0,type:"@location",params:[e]})}function Cs(e,t){return W(t,{[o]:!0,type:"@interpolate",params:[e]})}function Os(e){if(!In(e))throw new Error("The @invariant attribute must only be applied to the position built-in value.");let t=_(e)||I(e)?e.attribs.find(Ne):void 0;if(!t||t.params[0]!=="position")throw new Error("The @invariant attribute must only be applied to the position built-in value.");return W(e,{[o]:!0,type:"@invariant",params:[]})}function In(e){return(_(e)||I(e))&&e.attribs.find(Ne)!==void 0}function Ms(e){return!_(e)&&!I(e)?"":e.attribs.map(t=>t.params.length===0?`${t.type} `:`${t.type}(${t.params.join(", ")}) `).join("")}var $e=class{constructor(t,n){this.inner=t;this.attribs=n;let r=n.find(Te)?.params[0],i=n.find(ge)?.params[0];if(r!==void 0){if(r<=0)throw new Error(`Custom data alignment must be a positive number, got: ${r}.`);if(Math.log2(r)%1!==0)throw new Error(`Alignment has to be a power of 2, got: ${r}.`);if(C(this.inner)&&r%V(this.inner)!==0)throw new Error(`Custom alignment has to be a multiple of the standard data alignment. Got: ${r}, expected multiple of: ${V(this.inner)}.`)}if(i!==void 0){if(i<z(this.inner))throw new Error(`Custom data size cannot be smaller then the standard data size. Got: ${i}, expected at least: ${z(this.inner)}.`);if(i<=0)throw new Error(`Custom data size must be a positive number. Got: ${i}.`)}}[o]=!0},ke=class extends $e{[o]=!0;type="decorated"},Fe=class extends $e{[o]=!0;type="loose-decorated"};function Pe(e,t){let n=e?.type,r=n in De?De[n]:e;return typeof r!="function"?t:t===void 0?r():r(t)}function qs(e){return Nt(e,!1)}function Js(e){return Nt(e,!0)}function Nt(e,t){let n=r=>Object.fromEntries(Object.entries(e).map(([i,s])=>[i,Pe(s,r?.[i])]));return Object.setPrototypeOf(n,_n),n.propTypes=e,Object.defineProperty(n,o,{value:{isAbstruct:t}}),n}var _n={type:"struct",$name(e){return k(this,e),this},toString(){return`struct:${D(this)??"<unnamed>"}`}};var Ye=$t(((e,t)=>t===void 0?n=>Ke(e,n):Ke(e,t)),(e,t)=>{if(t?.value===void 0){let n=r=>Ye[o].gpuImpl(e,r);return n[o]=!0,x(n,ut)}if(typeof t.value!="number")throw new Error(`Cannot create array schema with count unknown at compile-time: '${t.value}'`);return x(Ke(e.value,t.value),e.value)},"arrayOf");function Ke(e,t){let n=r=>{if(r&&r.length!==t)throw new Error(`Array schema of ${t} elements of type ${e.type} called with ${r.length} argument(s).`);return Array.from({length:t},(i,s)=>Pe(e,r?.[s]))};if(Object.setPrototypeOf(n,An),Number.isNaN(z(e)))throw new Error("Cannot nest runtime sized arrays.");if(n.elementType=e,!Number.isInteger(t)||t<0)throw new Error(`Cannot create array schema with invalid element count: ${t}.`);return n.elementCount=t,n}var An={[o]:!0,type:"array",toString(){return`arrayOf(${this.elementType}, ${this.elementCount})`}};function w(e,t){return W(e,{[o]:!0,type:"@builtin",params:[t]})}var yo={vertexIndex:w(c,"vertex_index"),instanceIndex:w(c,"instance_index"),position:w(v,"position"),clipDistances:w(Ye(c,8),"clip_distances"),frontFacing:w(b,"front_facing"),fragDepth:w(h,"frag_depth"),sampleIndex:w(c,"sample_index"),sampleMask:w(c,"sample_mask"),localInvocationId:w(E,"local_invocation_id"),localInvocationIndex:w(c,"local_invocation_index"),globalInvocationId:w(E,"global_invocation_id"),workgroupId:w(E,"workgroup_id"),numWorkgroups:w(E,"num_workgroups"),subgroupInvocationId:w(c,"subgroup_invocation_id"),subgroupSize:w(c,"subgroup_size")};export{o as a,kn as b,me as c,He as d,qe as e,oe as f,Je as g,u as h,Zn as i,D as j,k,Yt as l,tt as m,nt as n,rt as o,er as p,Mn as q,Ee as r,Ct as s,Ot as t,Mt as u,ae as v,Xe as w,Lt as x,jt as y,Ue as z,Ln as A,C as B,fe as C,we as D,jn as E,Gn as F,Te as G,ge as H,Ze as I,Kn as J,Ne as K,_ as L,Yn as M,Qe as N,Hn as O,S as P,Re as Q,ce as R,ye as S,I as T,or as U,ar as V,ut as W,it as X,st as Y,ot as Z,Ce as _,gr as $,x as aa,Ve as ba,ct as ca,yt as da,lt as ea,pt as fa,ht as ga,xt as ha,dt as ia,mt as ja,ft as ka,be as la,wt as ma,Tt as na,gt as oa,dr as pa,Se as qa,vt as ra,bt as sa,Jt as ta,Vt as ua,_r as va,Ar as wa,Fr as xa,Pr as ya,Br as za,zt as Aa,Xt as Ba,Er as Ca,Oe as Da,d as Ea,St as Fa,_t as Ga,Hr as Ha,At as Ia,Dt as Ja,qr as Ka,$t as La,Ae as Ma,P as Na,ai as Oa,ui as Pa,b as Qa,c as Ra,ci as Sa,T as Ta,h as Ua,$ as Va,le as Wa,B as Xa,hn as Ya,pe as Za,he as _a,xn as $a,Le as ab,dn as bb,je as cb,E as db,mn as eb,v as fb,fn as gb,xe as hb,de as ib,wn as jb,bi as kb,Pt as lb,Ft as mb,De as nb,Ge as ob,Ai as pb,Di as qb,$i as rb,ki as sb,Fi as tb,Pi as ub,Bi as vb,Ei as wb,Ui as xb,Ni as yb,Ri as zb,Wi as Ab,Ci as Bb,Oi as Cb,Mi as Db,Li as Eb,ji as Fb,Gi as Gb,Ki as Hb,Yi as Ib,Hi as Jb,qi as Kb,Ji as Lb,Xi as Mb,Zi as Nb,Qi as Ob,es as Pb,ts as Qb,ns as Rb,rs as Sb,is as Tb,ss as Ub,os as Vb,as as Wb,us as Xb,cs as Yb,ys as Zb,ls as _b,ps as $b,hs as ac,xs as bc,ds as cc,V as dc,re as ec,Vs as fc,ie as gc,z as hc,$s as ic,Ns as jc,Rs as kc,Ws as lc,Cs as mc,Os as nc,In as oc,Ms as pc,Pe as qc,qs as rc,Js as sc,Ye as tc,yo as uc};
10
- //# sourceMappingURL=chunk-CRZWTZM2.js.map