This project provides a WebAssembly-based Basis Universal texture transcoder with TypeScript bindings, designed for high-performance texture transcoding in web applications.
.
├── CMakeLists.txt # WASM compilation configuration
├── basis_capi_transcoder.cpp # C++ API wrapper for Emscripten
├── extern/ # External dependencies (Basis Universal)
├── build/ # WASM compilation output (generated)
├── packages/ # NPM packages
│ └── basis-universal-transcoder/ # Main TypeScript package (@h00w/basis-universal-transcoder)
│ ├── src/ # TypeScript source code
│ ├── demo/ # Interactive demo
│ └── dist/ # Built package output (generated)
└── scripts/ # Build automation scripts
- Emscripten SDK for WASM compilation
- Node.js 16+ for package development
- Git with submodules for external dependencies
# Clone with submodules
git clone --recursive <your-repo-url>
cd basis-universal-transcoder
# Build everything (WASM + NPM package)
./scripts/build-all.sh
- WASM Development: Modify
basis_capi_transcoder.cpp
and rebuild with./scripts/build-wasm.sh
- Package Development: Work in
packages/basis-universal-transcoder/src/
and usenpm run dev
- Demo Testing: Use the interactive demo at
packages/basis-universal-transcoder/demo/
Install the package from npm:
npm install @h00w/basis-universal-transcoder
Or with other package managers:
# Yarn
yarn add @h00w/basis-universal-transcoder
# pnpm
pnpm add @h00w/basis-universal-transcoder
📖 See the package README for detailed usage instructions →
./scripts/build-wasm.sh # Build WASM module only
cd packages/basis-universal-transcoder
npm run dev # Start development server
npm run build # Build package for distribution
npm run preview # Preview built package
./scripts/build-all.sh # Build everything from scratch
- C++ wrapper around Basis Universal transcoder
- Exports C functions for Emscripten binding
- Handles KTX2 and Basis file formats
- Optimized for size and performance
- Type-safe wrapper around WASM functions
- High-level API for easy integration
- Platform detection and format optimization
- Browser and Node.js compatibility
- Interactive web interface
- File drag-and-drop support
- Real-time transcoding with performance metrics
- Platform capability detection
- ES modules build targeting
.mjs
output format - Custom Rollup configuration for file naming (
entryFileNames: '[name].mjs'
) - TypeScript declaration generation with
vite-plugin-dts
- Public directory configured for WASM file distribution
- Relative asset paths with
base: './'
- Development server with hot reload on port 3150 and demo auto-open
- File system allowlist for monorepo structure (
fs: { allow: ['..', '../..'] }
)
- Emscripten toolchain
- KTX2 and Zstandard support
- Optimized release builds
- Minimal runtime for smaller output
cd packages/basis-universal-transcoder
npm run build
npm publish
- Fork the repository
- Create a feature branch
- Make your changes
- Test with the demo application
- Submit a pull request
MIT
- Basis Universal by Binomial LLC
- Emscripten for WebAssembly compilation
- Vite for modern build tooling