{"version":3,"sources":["../package.json","../src/shared/symbols.ts","../src/name.ts","../src/errors.ts"],"names":["version","$internal","$wgslDataType","$gpuValueOf","$getNameForward","isForwarded","value","getName","definition","setName","name","map","isNamable","prefix","invariant","condition","message","ResolutionError","_ResolutionError","cause","trace","entries","ancestor"],"mappings":"AAGE,+2BAAAA,CAAAA,CAAW,OAAA,CCEN,IAAMC,CAAAA,CAAY,MAAA,CAAO,CAAA,QAAA,EAAWD,CAAO,CAAA,UAAA,CAAY,CAAA,CAIjDE,EAAAA,aAAgB,MAAA,CAAO,CAAA,QAAA,EAAWF,CAAO,CAAA,cAAA,CAAgB,CAAA,CAIzDG,EAAAA,aAAc,MAAA,CAAO,CAAA,QAAA,EAAWH,CAAO,CAAA,YAAA,CAAc,CAAA,CACrDI,CAAAA,aAAkB,MAAA,CAAO,CAAA,QAAA,EAAWJ,CAAO,CAAA,gBAAA,CAAkB,CAAA,CCJ1E,SAASK,EAAAA,CAAYC,CAAAA,CAAyD,CAC5E,MAAO,CAAC,iBAAEA,CAAAA,4BAAAA,CAA4CF,CAAe,GACvE,CAEO,SAASG,CAAAA,CAAQC,CAAAA,CAAyC,CAC/D,OAAIH,EAAAA,CAAYG,CAAU,CAAA,CACjBD,CAAAA,CAAQC,CAAAA,CAAWJ,CAAe,CAAC,CAAA,iBAEpC,UAAA,qBAAyC,gBAAA,6BAAkB,GAAA,mBAEjEI,CACF,CAAA,6BAAG,MACL,CAEO,SAASC,CAAAA,CAAQD,CAAAA,CAAoBE,CAAAA,CAAoB,CAC7D,UAAA,CAAyC,gBAAA,GAAqB,IAAI,OAAA,CACnE,IAAMC,CAAAA,CAAO,UAAA,CAAyC,gBAAA,CACtDA,CAAAA,CAAI,GAAA,CAAIH,CAAAA,CAAY,CAAE,GAAGG,CAAAA,CAAI,GAAA,CAAIH,CAAU,CAAA,CAAG,IAAA,CAAAE,CAAK,CAAC,CACtD,CAYO,SAASE,EAAAA,CAAUN,CAAAA,CAAsC,CAC9D,MAAO,CAAC,iBAAEA,CAAAA,6BAAuB,OACnC,CClCA,IAAMO,CAAAA,CAAS,kBAAA,CAKR,SAASC,CAAAA,CACdC,CAAAA,CACAC,CAAAA,CACmB,CACnB,EAAA,CAAID,CAAAA,CAEF,MAAA,CAKA,MAAM,IAAI,KAAA,CAAMF,CAAM,CAa1B,CASO,IAAMI,EAAAA,CAAN,MAAMC,EAAAA,QAAwB,KAAM,CACzC,WAAA,CACkBC,CAAAA,CACAC,CAAAA,CAChB,CACA,IAAIC,CAAAA,CAAUD,CAAAA,CAAM,GAAA,CAAKE,CAAAA,EAAa,CAAA,EAAA,EAAKA,CAAQ,CAAA,CAAA;AAQU;AAiD3D","file":"/Users/iwo/Projects/wigsill/packages/typegpu/dist/chunk-V4CSEIB2.cjs","sourcesContent":["{\n  \"name\": \"typegpu\",\n  \"private\": true,\n  \"version\": \"0.5.8\",\n  \"description\": \"A thin layer between JS and WebGPU/WGSL that improves development experience and allows for faster iteration.\",\n  \"license\": \"MIT\",\n  \"type\": \"module\",\n  \"exports\": {\n    \"./package.json\": \"./package.json\",\n    \".\": \"./src/index.ts\",\n    \"./data\": \"./src/data/index.ts\",\n    \"./std\": \"./src/std/index.ts\"\n  },\n  \"publishConfig\": {\n    \"directory\": \"dist\",\n    \"linkDirectory\": false,\n    \"main\": \"./dist/index.js\",\n    \"types\": \"./dist/index.d.ts\",\n    \"exports\": {\n      \"./package.json\": \"./dist/package.json\",\n      \".\": {\n        \"types\": \"./dist/index.d.ts\",\n        \"module\": \"./dist/index.js\",\n        \"import\": \"./dist/index.js\",\n        \"default\": \"./dist/index.cjs\"\n      },\n      \"./data\": {\n        \"types\": \"./dist/data/index.d.ts\",\n        \"module\": \"./dist/data/index.js\",\n        \"import\": \"./dist/data/index.js\",\n        \"default\": \"./dist/data/index.cjs\"\n      },\n      \"./std\": {\n        \"types\": \"./dist/std/index.d.ts\",\n        \"module\": \"./dist/std/index.js\",\n        \"import\": \"./dist/std/index.js\",\n        \"default\": \"./dist/std/index.cjs\"\n      }\n    }\n  },\n  \"sideEffects\": false,\n  \"scripts\": {\n    \"build\": \"tsup\",\n    \"test:types\": \"pnpm tsc --p ./tsconfig.test.json --noEmit\",\n    \"prepublishOnly\": \"tgpu-dev-cli prepack\"\n  },\n  \"engines\": {\n    \"node\": \">=12.20.0\"\n  },\n  \"repository\": {\n    \"type\": \"git\",\n    \"url\": \"git+https://github.com/software-mansion/TypeGPU.git\"\n  },\n  \"keywords\": [\n    \"webgpu\",\n    \"wgpu\",\n    \"wgsl\",\n    \"typescript\",\n    \"compute\",\n    \"shader\",\n    \"shaders\",\n    \"gpgpu\"\n  ],\n  \"bugs\": {\n    \"url\": \"https://github.com/software-mansion/TypeGPU/issues\"\n  },\n  \"homepage\": \"https://typegpu.com\",\n  \"devDependencies\": {\n    \"@ark/attest\": \"^0.46.0\",\n    \"@typegpu/tgpu-dev-cli\": \"workspace:*\",\n    \"@types/node\": \"^22.13.14\",\n    \"@webgpu/types\": \"catalog:\",\n    \"arktype\": \"catalog:\",\n    \"jiti\": \"^2.4.2\",\n    \"tgpu-jit\": \"workspace:*\",\n    \"tsup\": \"catalog:\",\n    \"typescript\": \"catalog:\",\n    \"unplugin-typegpu\": \"workspace:*\",\n    \"wesl\": \"0.6.7\",\n    \"wgpu-matrix\": \"^3.4.0\"\n  },\n  \"packageManager\": \"pnpm@10.4.1+sha512.c753b6c3ad7afa13af388fa6d808035a008e30ea9993f58c6663e2bc5ff21679aa834db094987129aa4d488b86df57f7b634981b2f827cdcacc698cc0cfb88af\",\n  \"dependencies\": {\n    \"tinyest\": \"workspace:~0.1.1\",\n    \"typed-binary\": \"^4.3.1\"\n  }\n}\n","// The version is inlined during build-time 🎉\n// It helps us identify problems when two versions of\n// TypeGPU are used at the same time.\nimport { version } from '../../package.json';\n\nexport const $internal = Symbol(`typegpu:${version}:$internal`);\n/**\n * A value's data type as seen by the WGSL generator\n */\nexport const $wgslDataType = Symbol(`typegpu:${version}:$wgslDataType`);\n/**\n * The getter to the value of this resource, accessible on the GPU\n */\nexport const $gpuValueOf = Symbol(`typegpu:${version}:$gpuValueOf`);\nexport const $getNameForward = Symbol(`typegpu:${version}:$getNameForward`);\n","import { $getNameForward } from './shared/symbols.ts';\n\ninterface MetaData {\n  name: string | undefined;\n}\n\ninterface GlobalWithMeta {\n  __TYPEGPU_META__: WeakMap<object, MetaData>;\n}\n\nfunction isForwarded(value: unknown): value is { [$getNameForward]: unknown } {\n  return !!(value as { [$getNameForward]?: unknown })?.[$getNameForward];\n}\n\nexport function getName(definition: unknown): string | undefined {\n  if (isForwarded(definition)) {\n    return getName(definition[$getNameForward]);\n  }\n  return (globalThis as unknown as GlobalWithMeta).__TYPEGPU_META__?.get(\n    // biome-ignore lint/suspicious/noExplicitAny: it's fine, if it's not an object, the get will return undefined\n    definition as any,\n  )?.name;\n}\n\nexport function setName(definition: object, name: string): void {\n  (globalThis as unknown as GlobalWithMeta).__TYPEGPU_META__ ??= new WeakMap();\n  const map = (globalThis as unknown as GlobalWithMeta).__TYPEGPU_META__;\n  map.set(definition, { ...map.get(definition), name });\n}\n\n/**\n * Can be assigned a name. Not to be confused with\n * being able to HAVE a name.\n * The `$name` function should use `setName` to rename the object itself,\n * or rename the object `$getNameForward` symbol points to instead if applicable.\n */\nexport interface TgpuNamable {\n  $name(label: string): this;\n}\n\nexport function isNamable(value: unknown): value is TgpuNamable {\n  return !!(value as TgpuNamable)?.$name;\n}\n","import type { TgpuBuffer } from './core/buffer/buffer.ts';\nimport type { TgpuSlot } from './core/slot/slotTypes.ts';\nimport type { TgpuVertexLayout } from './core/vertexLayout/vertexLayout.ts';\nimport type { AnyData, Disarray } from './data/dataTypes.ts';\nimport type { WgslArray } from './data/wgslTypes.ts';\nimport { getName } from './name.ts';\nimport type { TgpuBindGroupLayout } from './tgpuBindGroupLayout.ts';\n\nconst prefix = 'Invariant failed';\n\n/**\n * Inspired by: https://github.com/alexreardon/tiny-invariant/blob/master/src/tiny-invariant.ts\n */\nexport function invariant(\n  condition: unknown,\n  message?: string | (() => string),\n): asserts condition {\n  if (condition) {\n    // Condition passed\n    return;\n  }\n\n  // In production we strip the message but still throw\n  if (process.env.NODE_ENV === 'production') {\n    throw new Error(prefix);\n  }\n\n  // When not in production we allow the message to pass through\n  // *This block will be removed in production builds*\n\n  const provided = typeof message === 'function' ? message() : message;\n\n  // Options:\n  // 1. message provided: `${prefix}: ${provided}`\n  // 2. message not provided: prefix\n  const value = provided ? `${prefix}: ${provided}` : prefix;\n  throw new Error(value);\n}\n\n/**\n * An error that happens during resolution of WGSL code.\n * Contains a trace of all ancestor resolvables in\n * which this error originated.\n *\n * @category Errors\n */\nexport class ResolutionError extends Error {\n  constructor(\n    public readonly cause: unknown,\n    public readonly trace: unknown[],\n  ) {\n    let entries = trace.map((ancestor) => `- ${ancestor}`);\n\n    // Showing only the root and leaf nodes.\n    if (entries.length > 20) {\n      entries = [...entries.slice(0, 11), '...', ...entries.slice(-10)];\n    }\n\n    super(\n      `Resolution of the following tree failed: \\n${entries.join('\\n')}: ${\n        cause && typeof cause === 'object' && 'message' in cause\n          ? cause.message\n          : cause\n      }`,\n    );\n\n    // Set the prototype explicitly.\n    Object.setPrototypeOf(this, ResolutionError.prototype);\n  }\n\n  appendToTrace(ancestor: unknown): ResolutionError {\n    const newTrace = [ancestor, ...this.trace];\n\n    return new ResolutionError(this.cause, newTrace);\n  }\n}\n\n/**\n * @category Errors\n */\nexport class MissingSlotValueError extends Error {\n  constructor(public readonly slot: TgpuSlot<unknown>) {\n    super(`Missing value for '${slot}'`);\n\n    // Set the prototype explicitly.\n    Object.setPrototypeOf(this, MissingSlotValueError.prototype);\n  }\n}\n\n/**\n * @category Errors\n */\nexport class NotUniformError extends Error {\n  constructor(value: TgpuBuffer<AnyData>) {\n    super(\n      `Buffer '${\n        getName(value) ?? '<unnamed>'\n      }' is not bindable as a uniform. Use .$usage('uniform') to allow it.`,\n    );\n\n    // Set the prototype explicitly.\n    Object.setPrototypeOf(this, NotUniformError.prototype);\n  }\n}\n\nexport class MissingLinksError extends Error {\n  constructor(fnLabel: string | undefined, externalNames: string[]) {\n    super(\n      `The function '${\n        fnLabel ?? '<unnamed>'\n      }' is missing links to the following external values: ${externalNames}.`,\n    );\n\n    // Set the prototype explicitly.\n    Object.setPrototypeOf(this, MissingLinksError.prototype);\n  }\n}\n\nexport class MissingBindGroupsError extends Error {\n  constructor(layouts: Iterable<TgpuBindGroupLayout>) {\n    super(\n      `Missing bind groups for layouts: '${\n        [...layouts].map((layout) => getName(layout) ?? '<unnamed>').join(', ')\n      }'. Please provide it using pipeline.with(layout, bindGroup).(...)`,\n    );\n\n    // Set the prototype explicitly.\n    Object.setPrototypeOf(this, MissingBindGroupsError.prototype);\n  }\n}\n\nexport class MissingVertexBuffersError extends Error {\n  constructor(layouts: Iterable<TgpuVertexLayout<WgslArray | Disarray>>) {\n    super(\n      `Missing vertex buffers for layouts: '${\n        [...layouts].map((layout) => getName(layout) ?? '<unnamed>').join(', ')\n      }'. Please provide it using pipeline.with(layout, buffer).(...)`,\n    );\n\n    // Set the prototype explicitly.\n    Object.setPrototypeOf(this, MissingVertexBuffersError.prototype);\n  }\n}\n"]}