| name | helios-core |
| description | Core API for Helios video engine. Use when creating compositions, managing timeline state, controlling playback, or subscribing to frame updates. Covers Helios class instantiation, signals, animation helpers, and DOM synchronization. |
Helios Core API
The Helios class is the headless logic engine for video compositions. It manages timeline state, provides frame-accurate control, and drives animations.
Quick Start
import { Helios } from '@helios-project/core';
const helios = new Helios({
duration: 10,
fps: 30,
width: 1920,
height: 1080,
inputProps: { text: "Hello World" }
});
const unsubscribe = helios.subscribe((state) => {
console.log(`Frame: ${state.currentFrame}, Props:`, state.inputProps);
});
helios.play();
API Reference
Constructor
new Helios(options: HeliosOptions)
interface HeliosOptions {
duration: number;
fps: number;
width?: number;
height?: number;
initialFrame?: number;
loop?: boolean;
autoSyncAnimations?: boolean;
animationScope?: HTMLElement;
inputProps?: Record<string, any>;
schema?: HeliosSchema;
playbackRate?: number;
volume?: number;
muted?: boolean;
audioTracks?: Record<string, AudioTrackState>;
availableAudioTracks?: AudioTrackMetadata[];
captions?: string | CaptionCue[];
markers?: Marker[];
playbackRange?: [number, number];
driver?: TimeDriver;
}
State
helios.getState(): Readonly<HeliosState>
interface HeliosState {
width: number;
height: number;
duration: number;
fps: number;
currentFrame: number;
currentTime: number;
loop: boolean;
isPlaying: boolean;
inputProps: Record<string, any>;
playbackRate: number;
volume: number;
muted: boolean;
audioTracks: Record<string, AudioTrackState>;
availableAudioTracks: AudioTrackMetadata[];
captions: CaptionCue[];
activeCaptions: CaptionCue[];
markers: Marker[];
playbackRange: [number, number] | null;
}
type AudioTrackState = {
volume: number;
muted: boolean;
}
Methods
Playback Control
helios.play()
helios.pause()
helios.seek(frame: number)
helios.setPlaybackRate(rate: number)
helios.setPlaybackRange(startFrame: number, endFrame: number)
helios.clearPlaybackRange()
Timeline Configuration
helios.setDuration(seconds: number)
helios.setFps(fps: number)
helios.setLoop(shouldLoop: boolean)
Resolution Control
helios.setSize(width: number, height: number)
Audio Control
helios.setAudioVolume(volume: number)
helios.setAudioMuted(muted: boolean)
helios.setAudioTrackVolume(trackId: string, volume: number)
helios.setAudioTrackMuted(trackId: string, muted: boolean)
await helios.getAudioContext();
await helios.getAudioSourceNode(trackId);
Data Input & Validation
helios.setInputProps(props: Record<string, any>)
Captions
helios.setCaptions(captions: string | CaptionCue[])
Markers
Manage timeline markers for key events.
interface Marker {
id: string;
time: number;
label?: string;
color?: string;
metadata?: Record<string, any>;
}
helios.setMarkers(markers: Marker[])
helios.addMarker(marker: Marker)
helios.removeMarker(id: string)
helios.seekToMarker(id: string)
Subscription
type HeliosSubscriber = (state: HeliosState) => void;
const unsubscribe = helios.subscribe((state: HeliosState) => {
});
unsubscribe();
Timeline Binding
Bind Helios to document.timeline when the timeline is driven externally (e.g., by the Renderer or Studio).
helios.bindToDocumentTimeline()
helios.unbindFromDocumentTimeline()
Stability Registry
Register asynchronous checks that the Renderer must await before capturing frames (e.g., loading fonts, models, or data).
helios.registerStabilityCheck(
fetch('/data.json').then(r => r.json()).then(data => {
})
);
await helios.waitUntilStable();
Diagnostics
Check browser capabilities for rendering.
const report = await Helios.diagnose();
interface DiagnosticReport {
waapi: boolean;
webCodecs: boolean;
offscreenCanvas: boolean;
webgl: boolean;
webgl2: boolean;
webAudio: boolean;
colorGamut: 'srgb' | 'p3' | 'rec2020' | null;
videoCodecs: {
h264: boolean;
vp8: boolean;
vp9: boolean;
av1: boolean;
};
audioCodecs: {
aac: boolean;
opus: boolean;
};
videoDecoders: {
h264: boolean;
vp8: boolean;
vp9: boolean;
av1: boolean;
};
audioDecoders: {
aac: boolean;
opus: boolean;
};
userAgent: string;
}
AI Context
Generate a system prompt for AI agents that includes the current composition context.
import { createSystemPrompt, HELIOS_BASE_PROMPT } from '@helios-project/core';
const prompt = createSystemPrompt(helios);
Advanced Utilities
RenderSession
Controlled frame iteration, typically used for custom rendering or processing loops.
import { RenderSession } from '@helios-project/core';
const session = new RenderSession(helios, {
startFrame: 0,
endFrame: 100,
abortSignal: controller.signal
});
for await (const frame of session) {
console.log(`Processing frame ${frame}`);
}
Signals
The Helios class exposes reactive signals for granular state management. You can also create your own signals.
import { signal, computed, effect, ReadonlySignal } from '@helios-project/core';
const count = signal(0);
const double = computed(() => count.value * 2);
effect(() => {
console.log(`Count: ${count.value}, Double: ${double.value}`);
});
count.value = 1;
Public Helios Signals
All Helios state properties are available as read-only signals on the instance:
helios.currentFrame: ReadonlySignal<number>
helios.isPlaying: ReadonlySignal<boolean>
helios.inputProps: ReadonlySignal<Record<string, any>>
helios.playbackRate: ReadonlySignal<number>
helios.volume: ReadonlySignal<number>
helios.muted: ReadonlySignal<boolean>
helios.audioTracks: ReadonlySignal<Record<string, AudioTrackState>>
helios.availableAudioTracks: ReadonlySignal<AudioTrackMetadata[]>
helios.captions: ReadonlySignal<CaptionCue[]>
helios.activeCaptions: ReadonlySignal<CaptionCue[]>
helios.markers: ReadonlySignal<Marker[]>
helios.currentTime: ReadonlySignal<number>
helios.playbackRange: ReadonlySignal<[number, number] | null>
helios.width: ReadonlySignal<number>
helios.height: ReadonlySignal<number>
helios.loop: ReadonlySignal<boolean>
Animation Helpers
Spring Physics
Simulate a damped harmonic oscillator.
import { spring, calculateSpringDuration } from '@helios-project/core';
const val = spring({
frame: currentFrame,
fps: 30,
from: 0,
to: 100,
config: { stiffness: 100, damping: 10, mass: 1 }
});
const duration = calculateSpringDuration({
fps: 30,
from: 0,
to: 100,
config: { stiffness: 100, damping: 10 }
});
Series (Sequencing)
Arrange multiple items in a timeline sequence.
import { series } from '@helios-project/core';
const items = [
{ id: 'a', durationInFrames: 30 },
{ id: 'b', durationInFrames: 60, offset: -10 }
];
const sequenced = series(items, 0);
Stagger
Stagger the start time of a list of items by a fixed interval.
import { stagger } from '@helios-project/core';
const items = [{ id: 'a' }, { id: 'b' }, { id: 'c' }];
const staggered = stagger(items, 5);
Shift
Shift the start time of a list of sequenced items.
import { shift } from '@helios-project/core';
const items = [{ from: 0 }, { from: 10 }];
const shifted = shift(items, 30);
Interpolation
Map values from one range to another.
import { interpolate } from '@helios-project/core';
const opacity = interpolate(frame, [0, 30], [0, 1], {
extrapolateRight: 'clamp'
});
Schema Validation
Define input types for validation and UI generation in Studio. Supported types now include model, json, and shader.
const schema = {
type: 'object',
properties: {
title: { type: 'string' },
logo: { type: 'image' },
video: { type: 'video' },
audio: { type: 'audio' },
font: { type: 'font' },
model: { type: 'model' },
config: { type: 'json' },
effect: { type: 'shader' },
data: { type: 'float32array' },
count: { type: 'number', minimum: 0, step: 1 },
email: { type: 'string', pattern: '^\\S+@\\S+\\.\\S+$' },
avatar: { type: 'image', accept: '.png,.jpg' },
settings: {
type: 'object',
group: 'Advanced Settings',
properties: { }
}
}
};
Source Files
- Main class:
packages/core/src/index.ts
- Signals:
packages/core/src/signals.ts
- Animation:
packages/core/src/animation.ts
- Sequencing:
packages/core/src/sequencing.ts
- Validation:
packages/core/src/schema.ts