{"_id":"@bun-win32/d3dcompiler_47","_rev":"4-44113ed3b34f2c0ea1c57d1e4cd0d98a","name":"@bun-win32/d3dcompiler_47","dist-tags":{"latest":"2.0.1"},"versions":{"1.0.0":{"name":"@bun-win32/d3dcompiler_47","version":"1.0.0","keywords":["bun","ffi","win32","windows","d3dcompiler","d3dcompiler_47","hlsl","dxbc","shader","direct3d","d3d11","d3d12","bindings","typescript","dll"],"author":"Stev Peifer <stev@bell.net>","license":"MIT","_id":"@bun-win32/d3dcompiler_47@1.0.0","maintainers":[{"name":"obscuritysrl","email":"stev@bell.net"}],"homepage":"https://github.com/ObscuritySRL/bun-win32#readme","bugs":{"url":"https://github.com/ObscuritySRL/bun-win32/issues"},"dist":{"shasum":"eb0fb44bb7e5193c69d63a4913fedd996e6216de","tarball":"https://registry.npmjs.org/@bun-win32/d3dcompiler_47/-/d3dcompiler_47-1.0.0.tgz","fileCount":6,"integrity":"sha512-7v5/K23RpBBNGM66lqs6Htkn37E18UTYdIU6EtAq570k8WKAGkUiVhFaeUTQcfZHfpJpFMIhGeC+iKzMApXcRw==","signatures":[{"sig":"MEUCIFLXzh6Ydw+c7xjoiB2pzwPJLlGixXMHaizLRwBMKv4pAiEAmTuZ/pR7m5NKu+nflgBX4IJVZOV1kPLnbOtV5MPsArw=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":27593},"main":"./index.ts","type":"module","module":"index.ts","shasum":"eb0fb44bb7e5193c69d63a4913fedd996e6216de","engines":{"bun":">=1.1.0"},"exports":{".":"./index.ts"},"private":false,"scripts":{"example:hlsl-disco":"bun ./example/hlsl-disco.ts","example:shader-doctor":"bun ./example/shader-doctor.ts"},"_npmUser":{"name":"obscuritysrl","email":"stev@bell.net"},"_integrity":"sha512-7v5/K23RpBBNGM66lqs6Htkn37E18UTYdIU6EtAq570k8WKAGkUiVhFaeUTQcfZHfpJpFMIhGeC+iKzMApXcRw==","repository":{"url":"git://github.com/ObscuritySRL/bun-win32.git","type":"git","directory":"packages/d3dcompiler_47"},"_npmVersion":"10.8.3","description":"Zero-dependency, zero-overhead Win32 d3dcompiler_47 (HLSL → DXBC) bindings for Bun (FFI) on Windows.","directories":{},"sideEffects":false,"_nodeVersion":"24.3.0","dependencies":{"@bun-win32/core":"1.1.2"},"_hasShrinkwrap":false,"devDependencies":{"@types/bun":"latest"},"peerDependencies":{"typescript":"^5"},"_npmOperationalInternal":{"tmp":"tmp/d3dcompiler_47_1.0.0_1778767010285_0.5610082603136519","host":"s3://npm-registry-packages-npm-production"}},"1.0.1":{"name":"@bun-win32/d3dcompiler_47","version":"1.0.1","keywords":["bun","ffi","win32","windows","d3dcompiler","d3dcompiler_47","hlsl","dxbc","shader","direct3d","d3d11","d3d12","bindings","typescript","dll"],"author":"Stev Peifer <stev.p@outlook.com>","license":"MIT","_id":"@bun-win32/d3dcompiler_47@1.0.1","maintainers":[{"name":"obscuritysrl","email":"stev@bell.net"}],"homepage":"https://github.com/ObscuritySRL/bun-win32#readme","bugs":{"url":"https://github.com/ObscuritySRL/bun-win32/issues"},"dist":{"shasum":"7fe4b0af95e317e87066f7cc3b3748a71b9f7344","tarball":"https://registry.npmjs.org/@bun-win32/d3dcompiler_47/-/d3dcompiler_47-1.0.1.tgz","fileCount":6,"integrity":"sha512-Okk88b7uCP8Fmpzzgqt1wTdgHp4MIMWrcqKoUo9XGKhLqOmQ//AmZphl5YTy9Hdt2+PAyp+AQeg5Cm950Loltw==","signatures":[{"sig":"MEYCIQC0waf5th3DngLN5qyq5gxjdKvGvVprqCaCYnHM6whf3gIhAO/9abG8S6lAiipCDbujJ3fVDbXSKQ17kZeD5yY+4u7H","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":27598},"main":"./index.ts","type":"module","module":"index.ts","shasum":"7fe4b0af95e317e87066f7cc3b3748a71b9f7344","engines":{"bun":">=1.1.0"},"exports":{".":"./index.ts"},"private":false,"scripts":{"example:hlsl-disco":"bun ./example/hlsl-disco.ts","example:shader-doctor":"bun ./example/shader-doctor.ts"},"_npmUser":{"name":"obscuritysrl","email":"stev@bell.net"},"_integrity":"sha512-Okk88b7uCP8Fmpzzgqt1wTdgHp4MIMWrcqKoUo9XGKhLqOmQ//AmZphl5YTy9Hdt2+PAyp+AQeg5Cm950Loltw==","repository":{"url":"git://github.com/ObscuritySRL/bun-win32.git","type":"git","directory":"packages/d3dcompiler_47"},"_npmVersion":"10.8.3","description":"Zero-dependency, zero-overhead Win32 d3dcompiler_47 (HLSL → DXBC) bindings for Bun (FFI) on Windows.","directories":{},"sideEffects":false,"_nodeVersion":"24.3.0","dependencies":{"@bun-win32/core":"1.1.4"},"_hasShrinkwrap":false,"devDependencies":{"@types/bun":"latest"},"peerDependencies":{"typescript":"^5"},"_npmOperationalInternal":{"tmp":"tmp/d3dcompiler_47_1.0.1_1781130812230_0.4607979133325133","host":"s3://npm-registry-packages-npm-production"}},"2.0.0":{"name":"@bun-win32/d3dcompiler_47","version":"2.0.0","keywords":["bun","ffi","win32","windows","d3dcompiler","d3dcompiler_47","hlsl","dxbc","shader","direct3d","d3d11","d3d12","bindings","typescript","dll"],"author":"Stev Peifer <stev.p@outlook.com>","license":"MIT","_id":"@bun-win32/d3dcompiler_47@2.0.0","maintainers":[{"name":"obscuritysrl","email":"stev.p@outlook.com"}],"homepage":"https://github.com/ObscuritySRL/bun-win32#readme","bugs":{"url":"https://github.com/ObscuritySRL/bun-win32/issues"},"dist":{"shasum":"3529ed3120bc8417d152b7a92ed64f15a9043bea","tarball":"https://registry.npmjs.org/@bun-win32/d3dcompiler_47/-/d3dcompiler_47-2.0.0.tgz","fileCount":6,"integrity":"sha512-mU3bKs2m234FdWJNISoHN0S5yY3iCJ8e2Gi+b5OmpW6GngJ0QUggbHoGJ8JRG+UM8qFmU9qHjq9YcPFIUW9Bqg==","signatures":[{"sig":"MEUCIC/7CoCSqKsDizknNB5WUiPEtHEBUNVUVJ447w/lto2OAiEAryHz+bzK57UU1Wxsyz4z0XHX++27/dECpYlb45Vd9hQ=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":29242},"main":"./index.ts","type":"module","module":"index.ts","shasum":"3529ed3120bc8417d152b7a92ed64f15a9043bea","engines":{"bun":">=1.1.0"},"exports":{".":"./index.ts"},"private":false,"scripts":{"example:hlsl-disco":"bun ./example/hlsl-disco.ts","example:shader-doctor":"bun ./example/shader-doctor.ts"},"_npmUser":{"name":"obscuritysrl","email":"stev.p@outlook.com"},"_integrity":"sha512-mU3bKs2m234FdWJNISoHN0S5yY3iCJ8e2Gi+b5OmpW6GngJ0QUggbHoGJ8JRG+UM8qFmU9qHjq9YcPFIUW9Bqg==","repository":{"url":"git://github.com/ObscuritySRL/bun-win32.git","type":"git","directory":"packages/d3dcompiler_47"},"_npmVersion":"10.8.3","description":"Zero-dependency, zero-overhead Win32 d3dcompiler_47 (HLSL → DXBC) bindings for Bun (FFI) on Windows.","directories":{},"sideEffects":false,"_nodeVersion":"26.3.0","dependencies":{"@bun-win32/core":"2.0.0"},"_hasShrinkwrap":false,"devDependencies":{"@types/bun":"latest"},"peerDependencies":{"typescript":"^5"},"_npmOperationalInternal":{"tmp":"tmp/d3dcompiler_47_2.0.0_1782435290567_0.4238695653557327","host":"s3://npm-registry-packages-npm-production"}},"2.0.1":{"author":"Stev Peifer <stev.p@outlook.com>","bugs":{"url":"https://github.com/ObscuritySRL/bun-win32/issues"},"dependencies":{"@bun-win32/core":"2.0.1"},"description":"Zero-dependency, zero-overhead Win32 d3dcompiler_47 (HLSL → DXBC) bindings for Bun (FFI) on Windows.","devDependencies":{"@types/bun":"latest"},"exports":{".":"./index.ts"},"license":"MIT","module":"index.ts","name":"@bun-win32/d3dcompiler_47","peerDependencies":{"typescript":"^5"},"private":false,"homepage":"https://github.com/ObscuritySRL/bun-win32#readme","repository":{"type":"git","url":"git://github.com/ObscuritySRL/bun-win32.git","directory":"packages/d3dcompiler_47"},"type":"module","version":"2.0.1","main":"./index.ts","keywords":["bun","ffi","win32","windows","d3dcompiler","d3dcompiler_47","hlsl","dxbc","shader","direct3d","d3d11","d3d12","bindings","typescript","dll"],"sideEffects":false,"engines":{"bun":">=1.1.0"},"scripts":{"example:hlsl-disco":"bun ./example/hlsl-disco.ts","example:shader-doctor":"bun ./example/shader-doctor.ts"},"_id":"@bun-win32/d3dcompiler_47@2.0.1","_integrity":"sha512-sL+CjWQBRaQgb4JuBDKXM5cMQgkY/8p+c2gofRQmuHZAIRpwt/lLaG8UVfI112YbqKzU8xdboRpigy/JdfWw0Q==","_nodeVersion":"26.3.0","_npmVersion":"10.8.3","shasum":"2304e9b089001dd475038cbbd6b43a74040d2dd8","dist":{"integrity":"sha512-sL+CjWQBRaQgb4JuBDKXM5cMQgkY/8p+c2gofRQmuHZAIRpwt/lLaG8UVfI112YbqKzU8xdboRpigy/JdfWw0Q==","shasum":"2304e9b089001dd475038cbbd6b43a74040d2dd8","tarball":"https://registry.npmjs.org/@bun-win32/d3dcompiler_47/-/d3dcompiler_47-2.0.1.tgz","fileCount":6,"unpackedSize":29242,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEYCIQCyaMj7Hghhc1xcYDoyiK3Ee/+VhK8Nc6w/P3BkIUoFVwIhANYPd+mOsHG1dTfHnAK77dqNfL22S0HgjARCloPVcuNK"}]},"_npmUser":{"name":"obscuritysrl","email":"stev.p@outlook.com"},"directories":{},"maintainers":[{"name":"obscuritysrl","email":"stev.p@outlook.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/d3dcompiler_47_2.0.1_1782437749111_0.02404964063794779"},"_hasShrinkwrap":false}},"time":{"created":"2026-05-14T13:56:50.159Z","modified":"2026-06-26T01:35:49.409Z","1.0.0":"2026-05-14T13:56:50.445Z","1.0.1":"2026-06-10T22:33:32.369Z","2.0.0":"2026-06-26T00:54:50.701Z","2.0.1":"2026-06-26T01:35:49.261Z"},"bugs":{"url":"https://github.com/ObscuritySRL/bun-win32/issues"},"author":"Stev Peifer <stev.p@outlook.com>","license":"MIT","homepage":"https://github.com/ObscuritySRL/bun-win32#readme","keywords":["bun","ffi","win32","windows","d3dcompiler","d3dcompiler_47","hlsl","dxbc","shader","direct3d","d3d11","d3d12","bindings","typescript","dll"],"repository":{"type":"git","url":"git://github.com/ObscuritySRL/bun-win32.git","directory":"packages/d3dcompiler_47"},"description":"Zero-dependency, zero-overhead Win32 d3dcompiler_47 (HLSL → DXBC) bindings for Bun (FFI) on Windows.","maintainers":[{"name":"obscuritysrl","email":"stev.p@outlook.com"}],"readme":"# @bun-win32/d3dcompiler_47\n\nZero-dependency, zero-overhead Win32 D3dcompiler_47 bindings for [Bun](https://bun.sh) on Windows.\n\n## Overview\n\n`@bun-win32/d3dcompiler_47` exposes the `d3dcompiler_47.dll` exports using [Bun](https://bun.sh)'s FFI. It provides a single class, `D3dcompiler_47`, which lazily binds native symbols on first use. You can optionally preload a subset or all symbols up-front via `Preload()`.\n\nThe bindings are strongly typed for a smooth DX in TypeScript.\n\n## Features\n\n- [Bun](https://bun.sh)-first ergonomics on Windows 10/11.\n- Direct FFI to `d3dcompiler_47.dll` — HLSL → DXBC shader compilation, preprocessing, disassembly, reflection, blob part extraction, shader stripping, function linking graph, and shader assembly compression.\n- In-source docs in `structs/D3dcompiler_47.ts` with links to Microsoft Docs.\n- Lazy binding on first call; optional eager preload (`D3dcompiler_47.Preload()`).\n- No wrapper overhead; calls map 1:1 to native APIs.\n- Strongly-typed Win32 aliases (see `types/D3dcompiler_47.ts`).\n\n## Requirements\n\n- [Bun](https://bun.sh) runtime\n- Windows 10 or later\n\n## Installation\n\n```sh\nbun add @bun-win32/d3dcompiler_47\n```\n\n## Quick Start\n\nCompile an HLSL pixel shader to DXBC bytecode and read the bytes back through the `ID3DBlob` vtable.\n\n```ts\nimport D3dcompiler_47, { D3DCOMPILE_ENABLE_STRICTNESS, D3DCOMPILE_OPTIMIZATION_LEVEL3 } from '@bun-win32/d3dcompiler_47';\nimport { CFunction, FFIType, read, toArrayBuffer, type Pointer } from 'bun:ffi';\n\nconst source = Buffer.from('float4 main() : SV_Target { return float4(1,0,0,1); }\\0', 'utf8');\nconst entry = Buffer.from('main\\0', 'utf8');\nconst target = Buffer.from('ps_5_0\\0', 'utf8');\n\nconst ppCode = Buffer.alloc(8);\nconst ppErr = Buffer.alloc(8);\n\nconst hr = D3dcompiler_47.D3DCompile(\n  source.ptr!,\n  BigInt(source.byteLength - 1),\n  null, // pSourceName\n  null, // pDefines\n  null, // pInclude\n  entry.ptr!, // pEntrypoint\n  target.ptr!, // pTarget\n  D3DCOMPILE_ENABLE_STRICTNESS | D3DCOMPILE_OPTIMIZATION_LEVEL3,\n  0,\n  ppCode.ptr!,\n  ppErr.ptr!,\n);\n\nif (hr !== 0) throw new Error(`D3DCompile failed: HR=0x${(hr >>> 0).toString(16)}`);\n\n// ID3DBlob vtable: [QueryInterface, AddRef, Release, GetBufferPointer, GetBufferSize]\nconst blob = ppCode.readBigUInt64LE(0);\nconst vtable = read.u64(Number(blob) as Pointer, 0);\nconst getBufferPointer = CFunction({ ptr: Number(read.u64(Number(vtable) as Pointer, 24)) as Pointer, args: [FFIType.u64], returns: FFIType.u64 });\nconst getBufferSize = CFunction({ ptr: Number(read.u64(Number(vtable) as Pointer, 32)) as Pointer, args: [FFIType.u64], returns: FFIType.u64 });\nconst release = CFunction({ ptr: Number(read.u64(Number(vtable) as Pointer, 16)) as Pointer, args: [FFIType.u64], returns: FFIType.u32 });\n\nconst dataAddr = getBufferPointer(blob) as bigint;\nconst dataSize = Number(getBufferSize(blob) as bigint);\nconst bytecode = new Uint8Array(toArrayBuffer(Number(dataAddr) as Pointer, 0, dataSize));\nconsole.log('DXBC magic:', String.fromCharCode(...bytecode.subarray(0, 4))); // 'DXBC'\nrelease(blob);\n```\n\n> [!NOTE]\n> AI agents: see `AI.md` for the package binding contract and source-navigation guidance. It explains how to use the package without scanning the entire implementation.\n\n## Examples\n\nRun the included examples:\n\n```sh\nbun run example:hlsl-disco\nbun run example:shader-doctor\n```\n\n- **`hlsl-disco`** — Compiles four colourful HLSL pixel shaders, renders each as a split-pane view of rainbow source / syntax-highlighted disassembly, with bytecode-byte gradient previews and per-shader stats.\n- **`shader-doctor`** — A full diagnostic for a vertex shader: preprocessed output, DXBC chunk layout, every `D3DGetBlobPart` slot, parsed input / output signature records, strip-flag size deltas, and the colourised assembly.\n\n## Notes\n\n- Either rely on lazy binding or call `D3dcompiler_47.Preload()`.\n- Windows only. Bun runtime required.\n- `D3DCompile` and friends return new `ID3DBlob` instances. Their lifetime is yours: call the vtable's `Release` slot (offset `16` from the vtable pointer) when you are done, or you will leak native memory.\n- Sentinel pointer `D3D_COMPILE_STANDARD_FILE_INCLUDE = (ID3DInclude*)1` can be passed for `pInclude` if you want the compiler's built-in include handler. From TypeScript, construct it as `Number(1) as Pointer` since the API takes `FFIType.ptr`.\n- **SAL types & naming:** nullability is in the **type** — `Optional<T>` (formally optional, SAL `_*opt_`) and `Nullable<T>` (plain `[in]`/`[out]` the docs say can be NULL), the null sentinel derived from `T` (`null` for pointers `LP*`/`P*`, `0n` for handles/by-value addresses); direction is in the **parameter name** — `_out` (`_Out_`), `_in_out` (`_Inout_`), `_In_` bare. See `AI.md` and the repo `AGENTS.md`.\n","readmeFilename":"README.md"}