API reference
The complete public surface of @kinesisjs/core: the Tracker class, its options, the data types it consumes and emits, the adapter contract, events, telemetry and errors.
Tracker
The orchestrator. Construct one with an adapter, feed it positions, and start the loop.
Construct with worker: true and you transparently get a WorkerTracker with the same surface — the real tracker runs in a Web Worker while the adapter stays on the main thread.
TrackerOptions
adapter is the only required field. Everything else has a production default.
| Option | Type | Default | Notes |
|---|---|---|---|
adapter | TrackAdapter | — | Required. Your map binding. |
interpolation | InterpolationMode | 'adaptive' | CustomInterpolator | 'linear' | Curve or strategy. |
renderLagMs | number | 1000 | Interpolation buffer; 0 disables (snap). |
adaptive | AdaptiveOptions | — | Zone thresholds for adaptive mode. |
playout | PlayoutOptions | 'auto' | — | Jitter-absorbing playout buffer. |
maxInterpolationGap | number | 30000 | Above this gap, snap instead of interpolate. |
warningThreshold | number | 60000 | Idle → warning. |
staleThreshold | number | 600000 | Idle → removal. |
staleCheckInterval | number | 60000 | Sweeper cadence. |
ingestThrottle | number | 100 | Minimum ms between ingests per vehicle. |
initialPositionBehavior | 'show-immediately' | 'wait-for-second' | 'fade-in' | 'show-immediately' | First-point handling. |
shortestArcHeading | boolean | true | Interpolate heading the short way around. |
fadeAnimation | FadeAnimationOptions | — | Fade duration / easing. |
worker | boolean | { url: string | URL } | — | Run the tick loop off-thread. |
Position & TrailPoint
Position is what you send to ingest(). TrailPoint is the internal representation handed to your adapter.
TrackAdapter
A map binding is six methods (three optional). Implement it once per map library.
Events
Subscribe with tracker.on(name, handler); it returns an unsubscribe function.
| Event | Payload |
|---|---|
tick | { time: number; activeCount: number } |
vehicleadded | { vehicleId: string } |
vehiclewarning | { vehicleId: string; lastSeen: number } |
vehiclestale | { vehicleId: string } |
vehiclecompleted | { vehicleId: string } |
vehicleremoved | { vehicleId: string } |
ingest | { count: number; throttled: number; latency: number } |
error | TrackerError |
start · stop · destroy | void |
const off = tracker.on('vehiclewarning', ({ vehicleId, lastSeen }) => {
console.warn(vehicleId, 'silent since', new Date(lastSeen));
});
tracker.on('error', (e) => console.warn('[' + e.code + ']', e.message));
// later
off(); // unsubscribegetStats()
A frozen snapshot of live telemetry — wire it to a dashboard.
Errors
Errors never throw out of the tick loop — they surface as error events.
| Code | Raised when |
|---|---|
INVALID_POSITION | A position fails validation. |
ADAPTER_ERROR | An adapter method throws. |
INTERPOLATION_ERROR | A (custom) interpolator throws. |
WORKER_ERROR | The worker channel fails. |
INTERNAL_ERROR | Anything else; the loop keeps running. |
Math utilities
The core also exports a few allocation-light helpers, used by route-aware and custom interpolators.