tcss-wasm 1.0.0

WebAssembly bindings for TCSS (Thematic CSS) compiler
Documentation
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>TCSS WASM Demo</title>
    <style>
        body {
            font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
            max-width: 1200px;
            margin: 0 auto;
            padding: 20px;
            background: #f5f5f5;
        }
        .container {
            display: grid;
            grid-template-columns: 1fr 1fr;
            gap: 20px;
            margin-top: 20px;
        }
        .panel {
            background: white;
            border-radius: 8px;
            padding: 20px;
            box-shadow: 0 2px 4px rgba(0,0,0,0.1);
        }
        h1 {
            color: #333;
        }
        h2 {
            color: #666;
            font-size: 18px;
            margin-top: 0;
        }
        textarea {
            width: 100%;
            height: 300px;
            font-family: 'Monaco', 'Menlo', 'Courier New', monospace;
            font-size: 14px;
            padding: 10px;
            border: 1px solid #ddd;
            border-radius: 4px;
            resize: vertical;
        }
        pre {
            background: #f8f8f8;
            padding: 15px;
            border-radius: 4px;
            overflow-x: auto;
            font-size: 14px;
            line-height: 1.5;
        }
        .error {
            background: #fee;
            color: #c33;
            padding: 10px;
            border-radius: 4px;
            margin-top: 10px;
        }
        .success {
            background: #efe;
            color: #3c3;
            padding: 10px;
            border-radius: 4px;
            margin-top: 10px;
        }
        button {
            background: #3498db;
            color: white;
            border: none;
            padding: 10px 20px;
            border-radius: 4px;
            cursor: pointer;
            font-size: 14px;
            margin-top: 10px;
        }
        button:hover {
            background: #2980b9;
        }
    </style>
</head>
<body>
    <h1>🎨 TCSS WebAssembly Demo</h1>
    <p>Try compiling TCSS to CSS in your browser using WebAssembly!</p>

    <div class="container">
        <div class="panel">
            <h2>TCSS Input</h2>
            <textarea id="tcss-input">@var primary: #3498db
@var secondary: #2ecc71
@var spacing: 16px

@fn spacing(x):
    return x * spacing

.button:
    background: primary
    color: #fff
    padding: spacing(1)
    border-radius: 4px
    border: 0px
    cursor: pointer

.button-secondary:
    background: secondary
    color: #fff
    padding: spacing(1)
    border-radius: 4px</textarea>
            <button onclick="compile()">Compile to CSS</button>
            <button onclick="compileMinified()">Compile Minified</button>
            <button onclick="validateInput()">Validate</button>
        </div>

        <div class="panel">
            <h2>CSS Output</h2>
            <pre id="css-output">Click "Compile to CSS" to see the output...</pre>
        </div>
    </div>

    <div id="status"></div>

    <script type="module">
        import init, { 
            compile_tcss, 
            compile_tcss_minified, 
            validate_tcss,
            parse_tcss 
        } from './pkg/tcss_wasm.js';

        // Initialize WASM module
        await init();
        console.log('TCSS WASM module initialized!');

        // Make functions available globally
        window.compile = function() {
            const input = document.getElementById('tcss-input').value;
            const output = document.getElementById('css-output');
            const status = document.getElementById('status');

            try {
                const css = compile_tcss(input);
                output.textContent = css;
                status.innerHTML = '<div class="success">✓ Compilation successful!</div>';
            } catch (error) {
                output.textContent = 'Error: ' + error;
                status.innerHTML = '<div class="error">✗ ' + error + '</div>';
            }
        };

        window.compileMinified = function() {
            const input = document.getElementById('tcss-input').value;
            const output = document.getElementById('css-output');
            const status = document.getElementById('status');

            try {
                const css = compile_tcss_minified(input);
                output.textContent = css;
                status.innerHTML = '<div class="success">✓ Minified compilation successful!</div>';
            } catch (error) {
                output.textContent = 'Error: ' + error;
                status.innerHTML = '<div class="error">✗ ' + error + '</div>';
            }
        };

        window.validateInput = function() {
            const input = document.getElementById('tcss-input').value;
            const status = document.getElementById('status');

            try {
                const isValid = validate_tcss(input);
                if (isValid) {
                    status.innerHTML = '<div class="success">✓ TCSS is valid!</div>';
                }
            } catch (error) {
                status.innerHTML = '<div class="error">✗ Validation failed: ' + error + '</div>';
            }
        };

        // Auto-compile on load
        window.compile();
    </script>
</body>
</html>