{"_id":"naga-wasm","_rev":"8-5ab8fb1727d1e9d265b5665dd5afc6e0","name":"naga-wasm","dist-tags":{"latest":"30.2.0"},"versions":{"0.0.0":{"name":"naga-wasm","version":"0.0.0","license":"MIT OR Apache-2.0","_id":"naga-wasm@0.0.0","maintainers":[{"name":"ryansuhartanto","email":"suhartanto@kekkon.nexus"}],"homepage":"https://github.com/kekkon-nexus/naga-wasm#readme","bugs":{"url":"https://github.com/kekkon-nexus/naga-wasm/issues"},"dist":{"shasum":"18ad98ffada8e547736e4eaa2325dbc1219ffea9","tarball":"https://registry.npmjs.org/naga-wasm/-/naga-wasm-0.0.0.tgz","fileCount":1,"integrity":"sha512-EC+Yk4c+oUSm5ZBJEOkxORA2JEf6B5Wj2giGE5+Qkqz3fMQGOgOSQmlYX0hBCt7/4UlCHFQCG4bPk2HRdaPzaQ==","signatures":[{"sig":"MEQCIGoS9U/qe4s5OeCzt4GYG5pcB8vOQe3+vSJ/sykg/G1lAiB0KfTzdrKQuxCCDQ0TJ4O7ltq3GOUqT5VFsjBmBZFLSA==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":238},"_npmUser":{"name":"ryansuhartanto","email":"suhartanto@kekkon.nexus"},"repository":{"url":"git+https://github.com/kekkon-nexus/naga-wasm.git","type":"git"},"_npmVersion":"11.19.1","description":"naga shader translator (wgpu) compiled to WebAssembly","directories":{},"_nodeVersion":"26.8.2","publishConfig":{"access":"public"},"_hasShrinkwrap":false,"_npmOperationalInternal":{"tmp":"tmp/naga-wasm_0.0.0_1789627505080_0.18060451384223608","host":"s3://npm-registry-packages-npm-production"}},"30.0.0":{"name":"naga-wasm","version":"30.0.0","keywords":["glsl","hlsl","msl","naga","shader","spirv","wasm","webassembly","wgpu","wgsl"],"license":"MIT OR Apache-2.0","_id":"naga-wasm@30.0.0","maintainers":[{"name":"ryansuhartanto","email":"suhartanto@kekkon.nexus"}],"contributors":[{"name":"Ryan Suhartanto","email":"suhartanto@kekkon.nexus"}],"homepage":"https://github.com/kekkon-nexus/naga-wasm#readme","bugs":{"url":"https://github.com/kekkon-nexus/naga-wasm/issues"},"dist":{"shasum":"27d25e355932163b09fda45561fa948744d21983","tarball":"https://registry.npmjs.org/naga-wasm/-/naga-wasm-30.0.0.tgz","fileCount":17,"integrity":"sha512-K1+lrsm6Vujkb/oQVJYLYnCL/Dw9H68nmJywgpUOiV+kqRxqrjZlARsdhn17S5nQCQH6UBG7gZw/whez4ugekA==","signatures":[{"sig":"MEUCIB9J+/N6SC1XsgkMsbnpmBT4cSRRjVkRwM+hC6sT/jE+AiEA5lWVVHAt2NS/EKZkwmb9gWb/6jWtGfcA1ZZXhjO/Yb8=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"},{"sig":"MEYCIQCRFF6hRAnhRrLCWEI0C7Nq+p6hI6SqSCTxUcAxhxgwUQIhAJusFJHWWuQ8rsoj9fO0ozhlurm6zaCkQoyxF0WJnhuC","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"attestations":{"url":"https://registry.npmjs.org/-/npm/v1/attestations/naga-wasm@30.0.0","provenance":{"predicateType":"https://slsa.dev/provenance/v1"}},"unpackedSize":2077330},"type":"module","_from":"file:naga-wasm-30.0.0.tgz","engines":{"node":">=24.12"},"exports":{".":{"dev":"./src/index.ts","node":"./dist/node.js","types":"./dist/index.d.ts","default":"./dist/index.js"},"./naga_bg.wasm":"./dist/wasm/naga_bg.wasm"},"scripts":{"prepack":"bun scripts/build.ts"},"_npmUser":{"name":"GitHub Actions","email":"npm-oidc-no-reply@github.com","trustedPublisher":{"id":"github","oidcConfigId":"oidc:b34c3a56-7442-4474-b58b-a82156d10499"}},"_resolved":"/home/runner/work/naga-wasm/naga-wasm/naga-wasm-30.0.0.tgz","_integrity":"sha512-K1+lrsm6Vujkb/oQVJYLYnCL/Dw9H68nmJywgpUOiV+kqRxqrjZlARsdhn17S5nQCQH6UBG7gZw/whez4ugekA==","deprecated":"optional options fail when passed undefined, use >=30.1.0","repository":{"url":"git+https://github.com/kekkon-nexus/naga-wasm.git","type":"git"},"_npmVersion":"12.0.2","description":"naga shader translator (wgpu) compiled to WebAssembly","directories":{},"sideEffects":false,"_nodeVersion":"22.23.2","publishConfig":{"access":"public"},"_hasShrinkwrap":false,"_npmOperationalInternal":{"tmp":"tmp/naga-wasm_30.0.0_1789628091799_0.2742523764373226","host":"s3://npm-registry-packages-npm-production"}},"30.1.0":{"name":"naga-wasm","version":"30.1.0","keywords":["glsl","hlsl","msl","naga","shader","spirv","wasm","webassembly","wgpu","wgsl"],"license":"MIT OR Apache-2.0","_id":"naga-wasm@30.1.0","maintainers":[{"name":"ryansuhartanto","email":"suhartanto@kekkon.nexus"}],"contributors":[{"name":"Ryan Suhartanto","email":"suhartanto@kekkon.nexus"}],"homepage":"https://github.com/kekkon-nexus/naga-wasm#readme","bugs":{"url":"https://github.com/kekkon-nexus/naga-wasm/issues"},"dist":{"shasum":"2a75ca2a484617895d96700dd6a6f47501b18d4c","tarball":"https://registry.npmjs.org/naga-wasm/-/naga-wasm-30.1.0.tgz","fileCount":17,"integrity":"sha512-uROKRlHP61ZIBab0ztBIFN8dWloDm+fdgO+cg5A7m7KK50HeHECiV0C2HvV1a+XNYiHVQZ6VV7EYGWbW7LS3Ug==","signatures":[{"sig":"MEUCIB+s8qLyMLEqL34gyovYXXJCMn5gWhOoNPY/HZhH+PrnAiEA/5OzX3BjLtXF3BWSlUAbatU0VgzbPBrJMZAfKAaSo0M=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"},{"sig":"MEQCIFg/lirgexIy/JWbx3JPwUIlpr6kBdzhmsk26ELdxZnPAiBLWxUyOyQtA94KXcNHT7T9YwKo+3uj0ar1PRXIQFDBmw==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"attestations":{"url":"https://registry.npmjs.org/-/npm/v1/attestations/naga-wasm@30.1.0","provenance":{"predicateType":"https://slsa.dev/provenance/v1"}},"unpackedSize":2084837},"type":"module","_from":"file:naga-wasm-30.1.0.tgz","engines":{"node":">=24.12"},"exports":{".":{"dev":"./src/index.ts","node":"./dist/node.js","types":"./dist/index.d.ts","default":"./dist/index.js"},"./naga_bg.wasm":"./dist/wasm/naga_bg.wasm"},"scripts":{"prepack":"bun scripts/build.ts"},"_npmUser":{"name":"GitHub Actions","email":"npm-oidc-no-reply@github.com","trustedPublisher":{"id":"github","oidcConfigId":"oidc:b34c3a56-7442-4474-b58b-a82156d10499"}},"_resolved":"/home/runner/work/naga-wasm/naga-wasm/naga-wasm-30.1.0.tgz","_integrity":"sha512-uROKRlHP61ZIBab0ztBIFN8dWloDm+fdgO+cg5A7m7KK50HeHECiV0C2HvV1a+XNYiHVQZ6VV7EYGWbW7LS3Ug==","repository":{"url":"git+https://github.com/kekkon-nexus/naga-wasm.git","type":"git"},"_npmVersion":"12.0.2","description":"naga shader translator (wgpu) compiled to WebAssembly","directories":{},"sideEffects":false,"_nodeVersion":"22.23.2","publishConfig":{"access":"public"},"_hasShrinkwrap":false,"_npmOperationalInternal":{"tmp":"tmp/naga-wasm_30.1.0_1789634376621_0.8197082345903863","host":"s3://npm-registry-packages-npm-production"}},"30.2.0":{"_id":"naga-wasm@30.2.0","bugs":{"url":"https://github.com/kekkon-nexus/naga-wasm/issues"},"dist":{"shasum":"9e6b9746d49a4e9748c42be3320b0f1efed111cf","tarball":"https://registry.npmjs.org/naga-wasm/-/naga-wasm-30.2.0.tgz","fileCount":17,"integrity":"sha512-TNKjybMep7dUtmslyueiXMhZLa8Tr432/v0XUcbRfip0gb9liiiynoX8iLNcOkqK/8LaIoG+8HEy4LE6/y8R1w==","signatures":[{"sig":"MEUCIG30Rba0jqoUj3+DSvt/Ulxaw+dic9JJnkQlKKBwFp41AiEA+LOiPMvsYj9ANAYj2fe5O3jllNdaCOPxb0mVDRsYD1g=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"},{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEQCIGAb5E1Tt/3wHXyXmURCMl4+F+fqVs3JS9XpEJxxmK4bAiBr0ZvYWj9L0PAApUissCDizpwSGNRLIKYnV/WkL31liA=="}],"attestations":{"url":"https://registry.npmjs.org/-/npm/v1/attestations/naga-wasm@30.2.0","provenance":{"predicateType":"https://slsa.dev/provenance/v1"}},"unpackedSize":2113104},"name":"naga-wasm","type":"module","_from":"file:naga-wasm-30.2.0.tgz","engines":{"node":">=24.12"},"exports":{".":{"dev":"./src/index.ts","node":"./dist/node.js","types":"./dist/index.d.ts","default":"./dist/index.js"},"./naga_bg.wasm":"./dist/wasm/naga_bg.wasm"},"license":"MIT OR Apache-2.0","scripts":{"prepack":"bun scripts/build.ts"},"version":"30.2.0","_npmUser":{"name":"GitHub Actions","email":"npm-oidc-no-reply@github.com","trustedPublisher":{"id":"github","oidcConfigId":"b34c3a56-7442-4474-b58b-a82156d10499"}},"homepage":"https://github.com/kekkon-nexus/naga-wasm#readme","keywords":["glsl","hlsl","msl","naga","shader","spirv","wasm","webassembly","wgpu","wgsl"],"_resolved":"/home/runner/work/naga-wasm/naga-wasm/naga-wasm-30.2.0.tgz","_integrity":"sha512-TNKjybMep7dUtmslyueiXMhZLa8Tr432/v0XUcbRfip0gb9liiiynoX8iLNcOkqK/8LaIoG+8HEy4LE6/y8R1w==","repository":{"url":"git+https://github.com/kekkon-nexus/naga-wasm.git","type":"git"},"_npmVersion":"12.1.0","description":"naga shader translator (wgpu) compiled to WebAssembly","directories":{},"maintainers":[{"name":"ryansuhartanto","email":"suhartanto@kekkon.nexus"}],"sideEffects":false,"_nodeVersion":"22.23.2","contributors":[{"name":"Ryan Suhartanto","email":"suhartanto@kekkon.nexus"}],"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/naga-wasm_30.2.0_1790763747521_0.6340937501533701"}}},"time":{"created":"2026-09-17T06:45:04.883Z","modified":"2026-09-30T10:22:27.983Z","1.0.0":"2025-10-17T20:00:08.840Z","0.0.0":"2026-09-17T06:45:05.212Z","30.0.0":"2026-09-17T06:54:51.937Z","30.1.0":"2026-09-17T08:39:36.745Z","30.2.0":"2026-09-30T10:22:27.644Z"},"bugs":{"url":"https://github.com/kekkon-nexus/naga-wasm/issues"},"license":"MIT OR Apache-2.0","homepage":"https://github.com/kekkon-nexus/naga-wasm#readme","keywords":["glsl","hlsl","msl","naga","shader","spirv","wasm","webassembly","wgpu","wgsl"],"repository":{"url":"git+https://github.com/kekkon-nexus/naga-wasm.git","type":"git"},"description":"naga shader translator (wgpu) compiled to WebAssembly","contributors":[{"name":"Ryan Suhartanto","email":"suhartanto@kekkon.nexus"}],"maintainers":[{"name":"ryansuhartanto","email":"suhartanto@kekkon.nexus"}],"readme":"# naga-wasm\n\n[![npm](https://img.shields.io/npm/v/naga-wasm?logo=npm)](https://www.npmjs.com/package/naga-wasm)\n[![CI](https://github.com/kekkon-nexus/naga-wasm/actions/workflows/ci.yaml/badge.svg)](https://github.com/kekkon-nexus/naga-wasm/actions/workflows/ci.yaml)\n[![node](https://img.shields.io/node/v/naga-wasm?logo=nodedotjs)](https://nodejs.org)\n\nThe [naga](https://github.com/gfx-rs/wgpu/tree/trunk/naga) shader translator\nfrom wgpu, compiled to WebAssembly.\n\nTranslate between WGSL, GLSL, SPIR-V, HLSL and MSL from JavaScript, in Node or\nthe browser, without shelling out to the naga CLI.\n\n- Frontends: WGSL, GLSL, SPIR-V\n- Backends: WGSL, GLSL, SPIR-V, HLSL, MSL\n\n## Install\n\n```sh\nnpm install naga-wasm\n```\n\n## Usage\n\n```ts\nimport { translate } from \"naga-wasm\";\n\nconst glsl = translate({\n\tfrom: \"wgsl\",\n\tto: \"glsl\",\n\tsource: wgsl,\n\toptions: { version: \"300 es\", stage: \"fragment\", entryPoint: \"main\" },\n});\n```\n\nIn Node the WebAssembly module loads on import. In the browser, call `init()`\nonce before anything else:\n\n```ts\nimport { init, translate } from \"naga-wasm\";\n\nawait init();\n```\n\n`init()` resolves the binary next to the module, which Vite and webpack 5\nhandle. To host it yourself, pass a URL, `Response` or bytes:\n\n```ts\nawait init({ module_or_path: new URL(\"/naga_bg.wasm\", location.href) });\n```\n\nThe binary is exported as `naga-wasm/naga_bg.wasm`.\n\n### Handles\n\n`translate` is a shortcut for the handle API. Parse once to write several\noutputs:\n\n```ts\nimport { parseWgsl, validate, writeGlsl, writeHlsl } from \"naga-wasm\";\n\nusing module = parseWgsl(source);\nusing info = validate(module);\n\nconst glsl = writeGlsl(module, info, {\n\tversion: \"300 es\",\n\tstage: \"fragment\",\n\tentryPoint: \"fs_main\",\n});\nconst hlsl = writeHlsl(module, info, { shaderModel: \"6_0\" });\n```\n\nHandles hold WebAssembly memory. Release them with `using` or `free()`.\n\n| Function                                                                                 | Returns       |\n| ---------------------------------------------------------------------------------------- | ------------- |\n| `parseWgsl(source)`                                                                      | `Module`      |\n| `parseGlsl(source, { stage, defines? })`                                                 | `Module`      |\n| `parseSpirv(words)`                                                                      | `Module`      |\n| `validate(module)`                                                                       | `ModuleInfo`  |\n| `writeWgsl(module, info, { flags? })`                                                    | `string`      |\n| `writeGlsl(module, info, { version, stage, entryPoint, bindingMap?, flags?, reflect? })` | `string`      |\n| `writeHlsl(module, info, { shaderModel?, reflect? })`                                    | `string`      |\n| `writeMsl(module, info, { langVersion?, reflect? })`                                     | `string`      |\n| `writeSpirv(module, info, { flags? })`                                                   | `Uint32Array` |\n\n`parseSpirv` accepts a `Uint8Array` or `Uint32Array`.\n\n### GLSL reflection\n\nnaga merges each texture and sampler pair into one `sampler2D` and wraps\nuniform buffers in blocks, both with generated names. `writeGlsl` returns\nthose names mapped back to their WGSL bindings with `reflect: true`, so a\nWebGL host can look up uniform locations:\n\n```ts\nconst { code, reflection } = writeGlsl(module, info, {\n\tversion: \"300 es\",\n\tstage: \"fragment\",\n\tentryPoint: \"fs_main\",\n\treflect: true,\n});\n\nreflection.textures;\n// { _group_1_binding_0_fs: { texture: { group: 1, binding: 0 }, sampler: { group: 1, binding: 1 } } }\nreflection.uniforms;\n// { Globals_block_0Fragment: { group: 0, binding: 0 } }\n```\n\n`bindingMap` assigns explicit `layout(binding = N)` slots on GLSL versions\nthat support them:\n\n```ts\nwriteGlsl(module, info, {\n\tversion: \"310 es\",\n\tstage: \"fragment\",\n\tentryPoint: \"fs_main\",\n\tbindingMap: [{ group: 1, binding: 0, slot: 3 }],\n});\n```\n\n### HLSL and MSL reflection\n\nWith `reflect: true`, `writeHlsl` and `writeMsl` return `{ code, reflection }`\nwhere `reflection.entryPoints` maps each WGSL entry point to its written name,\nor to an error when naga could not write it:\n\n```ts\nconst { reflection } = writeMsl(module, info, { reflect: true });\nreflection.entryPoints;\n// { vs_main: { name: \"vs_main\" }, fs_main: { name: \"fs_main\" } }\n```\n\n`reflect` is deprecated on all three writers because `{ code, reflection }`\nbecomes the default return in the next major. `translate` always returns only\nthe code.\n\n### Writer flags\n\n`flags` override naga's writer flags one at a time and keep the rest at their\ndefaults:\n\n```ts\nwriteGlsl(module, info, {\n\tversion: \"300 es\",\n\tstage: \"vertex\",\n\tentryPoint: \"vs_main\",\n\tflags: { forcePointSize: true },\n});\n```\n\n### Errors\n\nFailures throw a `NagaError` with:\n\n- `kind`: `\"parse\"`, `\"validation\"` or `\"write\"`\n- `message`: a one-line summary\n- `formatted`: naga's full report, including source spans\n\n```ts\nimport { NagaError, parseWgsl } from \"naga-wasm\";\n\ntry {\n\tparseWgsl(\"fn main( {\");\n} catch (error) {\n\tif (error instanceof NagaError) console.error(error.formatted);\n}\n```\n\n```\nerror: expected identifier, found \"{\"\n  ┌─ wgsl:1:10\n  │\n1 │ fn main( {\n  │          ^ expected identifier\n```\n\n## Versioning\n\nThe major version follows naga's major version. Minor and patch releases\nbelong to this package. The bundled naga version is exported as `nagaVersion`\nand noted in each release.\n\n## License\n\nThis project is licensed under either of:\n\n- Apache License, Version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or\n  <http://www.apache.org/licenses/LICENSE-2.0>)\n- MIT license ([LICENSE-MIT](LICENSE-MIT) or\n  <http://opensource.org/licenses/MIT>)\n\nat your option.\n","readmeFilename":"README.md"}