Skip to main content

Adding Primitives

This guide walks through adding a new primitive type to Voltaire. We’ll use a hypothetical Frame type as an example.

Prerequisites

Step 1: Create Directory Structure

Create these files:

Step 2: Define the Type

Step 3: Implement Constructor

Step 4: Implement Methods

Step 5: Create Index with Dual Exports

Step 6: Write Tests

Step 7: Implement Zig Version

Step 8: Register in Module

Step 9: Add Documentation

API Reference

Constructors

Methods

Validation

Step 11: Run Tests

Checklist

Before submitting:
  • Type definition in FrameType.ts
  • All methods in separate .js files with JSDoc
  • Dual exports in index.ts
  • Comprehensive tests in Frame.test.ts
  • Zig implementation with inline tests
  • Registered in root.zig
  • Documentation in docs/primitives/frame/
  • Navigation updated in docs.json
  • All tests passing: zig build test && bun run test:run