TCSS WebAssembly Bindings
WebAssembly bindings for the TCSS (Thematic CSS) compiler, enabling TCSS compilation in web browsers and Node.js environments.
Features
- 🚀 Fast TCSS compilation in the browser
- 📦 Small bundle size (optimized for web)
- 🔧 Multiple compilation modes (normal and minified)
- ✅ Validation and parsing utilities
- 🐛 Better error messages with panic hooks
Installation
Using npm (when published)
Building from source
# Install wasm-pack if you haven't already
|
# Build the WASM module
Usage
In the Browser
TCSS WASM Demo
In Node.js
import init from 'tcss-wasm';
await ;
const tcss = `
.button:
padding: 16px
color: #fff
`;
// Normal compilation
const css = ;
console.log;
// Minified compilation
const minified = ;
console.log;
API Reference
compile_tcss(input: string): string
Compiles TCSS source code to CSS.
Parameters:
input- The TCSS source code as a string
Returns: The compiled CSS as a string
Throws: JavaScript error if compilation fails
compile_tcss_minified(input: string): string
Compiles TCSS source code to minified CSS.
Parameters:
input- The TCSS source code as a string
Returns: The compiled and minified CSS as a string
Throws: JavaScript error if compilation fails
compile_tcss_with_options(input: string, minify: boolean): string
Compiles TCSS source code to CSS with custom options.
Parameters:
input- The TCSS source code as a stringminify- Whether to minify the output CSS
Returns: The compiled CSS as a string
Throws: JavaScript error if compilation fails
parse_tcss(input: string): object
Parses TCSS source code and returns the AST as a JavaScript object.
Parameters:
input- The TCSS source code as a string
Returns: The AST as a JavaScript object
Throws: JavaScript error if parsing fails
validate_tcss(input: string): boolean
Validates TCSS source code without generating CSS.
Parameters:
input- The TCSS source code as a string
Returns: true if the TCSS is valid
Throws: JavaScript error with details if invalid
Building
Development Build
Production Build
Build for Different Targets
# For web browsers
# For Node.js
# For bundlers (webpack, rollup, etc.)
Testing
License
MIT