ruvector/npm/wasm
rUv eefcc5322b feat: Add multi-platform GitHub Actions workflow for native module builds
Phase 2: Multi-Platform Native Builds

This commit adds comprehensive GitHub Actions CI/CD for building native
NAPI modules across all major platforms:

 Features:
- GitHub Actions workflow with 5-platform matrix build:
  - Linux (x64, ARM64)
  - macOS (x64 Intel, ARM64 Apple Silicon)
  - Windows (x64)
- Parallel builds complete in 7-10 minutes
- Automated artifact uploads and publishing
- Platform-specific npm packages with smart detection

📦 Package Structure:
- @ruvector/core - Main package with platform detection
- @ruvector/core-{platform} - Platform-specific binaries
- Smart loader with automatic platform selection
- Optional dependencies ensure minimal install size

🔧 Developer Tools:
- scripts/publish-platforms.js - Automated publishing
- Comprehensive TypeScript definitions
- Smoke tests for each platform
- Local build support with napi build

📚 Documentation:
- docs/BUILD_PROCESS.md - Complete build guide
- docs/PHASE2_MULTIPLATFORM_COMPLETE.md - Phase summary
- README for @ruvector/core package
- Troubleshooting and cross-compilation guides

🚀 Publishing Workflow:
1. Tag release (git tag v0.1.1)
2. Push to GitHub
3. CI builds all platforms
4. Publishes platform packages
5. Publishes main packages

Next: Phase 3 - WASM support with architectural refactoring

🤖 Generated with Claude Code
2025-11-21 13:19:13 +00:00
..
src feat: Add multi-platform GitHub Actions workflow for native module builds 2025-11-21 13:19:13 +00:00
.npmignore feat: Add multi-platform GitHub Actions workflow for native module builds 2025-11-21 13:19:13 +00:00
LICENSE feat: Add multi-platform GitHub Actions workflow for native module builds 2025-11-21 13:19:13 +00:00
package.json feat: Add multi-platform GitHub Actions workflow for native module builds 2025-11-21 13:19:13 +00:00
README.md feat: Add multi-platform GitHub Actions workflow for native module builds 2025-11-21 13:19:13 +00:00
tsconfig.esm.json feat: Add multi-platform GitHub Actions workflow for native module builds 2025-11-21 13:19:13 +00:00
tsconfig.json feat: Add multi-platform GitHub Actions workflow for native module builds 2025-11-21 13:19:13 +00:00

@ruvector/wasm

WebAssembly bindings for Ruvector - High-performance vector database for browsers and Node.js.

Features

  • 🚀 High Performance: SIMD-accelerated vector operations
  • 🌐 Universal: Works in browsers and Node.js
  • 🎯 Multiple Distance Metrics: Cosine, Euclidean, Dot Product, Manhattan
  • 🔍 Fast Search: HNSW indexing for approximate nearest neighbor search
  • 💾 Persistent Storage: IndexedDB (browser) and file system (Node.js)
  • 🦀 Rust-powered: Built with Rust and WebAssembly

Installation

npm install @ruvector/wasm

Quick Start

Browser

import { VectorDB } from '@ruvector/wasm/browser';

// Create database
const db = new VectorDB({ dimensions: 128 });
await db.init();

// Insert vectors
const vector = new Float32Array(128).fill(0.5);
const id = db.insert(vector, 'my-vector', { label: 'example' });

// Search
const results = db.search(vector, 10);
console.log(results);

// Save to IndexedDB
await db.saveToIndexedDB();

Node.js

import { VectorDB } from '@ruvector/wasm/node';

// Create database
const db = new VectorDB({ dimensions: 128 });
await db.init();

// Insert vectors
const vector = new Float32Array(128).fill(0.5);
const id = db.insert(vector, 'my-vector', { label: 'example' });

// Search
const results = db.search(vector, 10);
console.log(results);

Universal (Auto-detect)

import { VectorDB } from '@ruvector/wasm';

// Works in both browser and Node.js
const db = new VectorDB({ dimensions: 128 });
await db.init();

const vector = new Float32Array(128).fill(0.5);
const id = db.insert(vector);
const results = db.search(vector, 10);

API Reference

VectorDB

Constructor

new VectorDB(options: DbOptions)

Options:

  • dimensions: number - Vector dimensions (required)
  • metric?: 'euclidean' | 'cosine' | 'dotproduct' | 'manhattan' - Distance metric (default: 'cosine')
  • useHnsw?: boolean - Use HNSW index (default: true)

Methods

init()

Initialize the database (must be called before use).

await db.init(): Promise<void>
insert()

Insert a single vector.

db.insert(
  vector: Float32Array | number[],
  id?: string,
  metadata?: Record<string, any>
): string
insertBatch()

Insert multiple vectors efficiently.

db.insertBatch(entries: VectorEntry[]): string[]

Search for similar vectors.

db.search(
  query: Float32Array | number[],
  k: number,
  filter?: Record<string, any>
): SearchResult[]
delete()

Delete a vector by ID.

db.delete(id: string): boolean
get()

Get a vector by ID.

db.get(id: string): VectorEntry | null
len()

Get the number of vectors.

db.len(): number
isEmpty()

Check if database is empty.

db.isEmpty(): boolean
getDimensions()

Get vector dimensions.

db.getDimensions(): number
save()

Save database to persistent storage.

await db.save(path?: string): Promise<void>

Utility Functions

detectSIMD()

Check if SIMD is supported.

const hasSIMD = await detectSIMD();

version()

Get library version.

const ver = await version();

benchmark()

Run performance benchmark.

const opsPerSec = await benchmark('insert', 1000, 128);

Types

VectorEntry

interface VectorEntry {
  id?: string;
  vector: Float32Array | number[];
  metadata?: Record<string, any>;
}

SearchResult

interface SearchResult {
  id: string;
  score: number;
  vector?: Float32Array;
  metadata?: Record<string, any>;
}

DbOptions

interface DbOptions {
  dimensions: number;
  metric?: 'euclidean' | 'cosine' | 'dotproduct' | 'manhattan';
  useHnsw?: boolean;
}

Performance

Ruvector WASM delivers exceptional performance:

  • SIMD Acceleration: Up to 4x faster with WebAssembly SIMD
  • HNSW Index: Sub-linear search complexity
  • Zero-copy: Efficient memory usage with transferable objects
  • Batch Operations: Optimized bulk inserts

Browser Compatibility

  • Chrome 91+ (SIMD support)
  • Firefox 89+ (SIMD support)
  • Safari 16.4+ (SIMD support)
  • Edge 91+ (SIMD support)

License

MIT