ColorAssembly is distributed via npm and GitHub Packages.
# npm
npm i@CymbolTech/colorassembly
# yarn
yarn add @cymbol/colorassembly
# pnpm
pnpm add @cymbol/colorassembly
Create or update .npmrc in your project root:
@cymbol:registry=https://npm.pkg.github.com
For quick prototyping, you can load ColorAssembly from a CDN:
<script src="https://cdn.jsdelivr.net/npm/@cymbol/colorassembly/dist/wasm_exec.js"></script>
<script type="module">
import loadColorAssembly from 'https://cdn.jsdelivr.net/npm/@cymbol/colorassembly/dist/index.js';
const api = await loadColorAssembly({
wasmPath: 'https://cdn.jsdelivr.net/npm/@cymbol/colorassembly/dist/color-assembly.wasm'
});
</script>
The package includes a WebAssembly binary that needs to be served alongside your application.
Vite handles WASM files automatically:
import { loadColorAssembly } from '@cymbol/colorassembly';
const api = await loadColorAssembly();
Add WASM support to your config:
// webpack.config.js
module.exports = {
experiments: {
asyncWebAssembly: true,
},
module: {
rules: [
{
test: /\.wasm$/,
type: 'asset/resource',
},
],
},
};
Enable WASM in next.config.js:
/** @type {import('next').NextConfig} */
const nextConfig = {
webpack: (config) => {
config.experiments = {
...config.experiments,
asyncWebAssembly: true,
};
return config;
},
};
module.exports = nextConfig;
If the WASM file isn't automatically resolved:
const api = await loadColorAssembly({
wasmPath: '/assets/color-assembly.wasm'
});
Create a test file:
import { loadColorAssembly } from '@cymbol/colorassembly';
async function test() {
const api = await loadColorAssembly();
const rgb = { r: 255, g: 128, b: 0 };
const hsl = api.transforms.rgbToHsl(rgb);
console.log('RGB:', rgb);
console.log('HSL:', hsl);
console.log('✅ ColorAssembly is working!');
}
test();
| Component | Uncompressed | Gzipped |
|---|
| WASM Binary | ~3.1 MB | ~850 KB |
| JavaScript | ~15 KB | ~5 KB |
| Types | ~10 KB | N/A |
Note: The WASM binary is loaded asynchronously and cached by the browser. Initial load may take a moment, but subsequent loads are instant.
Continue to the Quick Start guide to start using ColorAssembly.