ColorAssembly

Installation

Install and configure ColorAssembly in your project

Package Manager

ColorAssembly is distributed via npm and GitHub Packages.

Install the Package

# npm
npm i@CymbolTech/colorassembly
 
# yarn
yarn add @cymbol/colorassembly
 
# pnpm
pnpm add @cymbol/colorassembly

Configure npm for GitHub Packages (if needed)

Create or update .npmrc in your project root:

@cymbol:registry=https://npm.pkg.github.com

CDN Usage

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>

WASM File Setup

The package includes a WebAssembly binary that needs to be served alongside your application.

Bundler Configuration

Vite

Vite handles WASM files automatically:

import { loadColorAssembly } from '@cymbol/colorassembly';
 
const api = await loadColorAssembly();

Webpack 5

Add WASM support to your config:

// webpack.config.js
module.exports = {
  experiments: {
    asyncWebAssembly: true,
  },
  module: {
    rules: [
      {
        test: /\.wasm$/,
        type: 'asset/resource',
      },
    ],
  },
};

Next.js

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;

Manual WASM Path

If the WASM file isn't automatically resolved:

const api = await loadColorAssembly({
  wasmPath: '/assets/color-assembly.wasm'
});

Verifying Installation

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();

Bundle Size

ComponentUncompressedGzipped
WASM Binary~3.1 MB~850 KB
JavaScript~15 KB~5 KB
Types~10 KBN/A

Note: The WASM binary is loaded asynchronously and cached by the browser. Initial load may take a moment, but subsequent loads are instant.

Next Steps

Continue to the Quick Start guide to start using ColorAssembly.

On this page