@interlacejs/core
v0.1.2
Published
Shared definitions and logic with no rendering opinions.
Maintainers
Readme
@interlacejs/core
The core of the Interlace interactive-video library: the framework-free pieces both the authoring UI and the playback runtime build on.
What's inside
InteractiveMediaController— the playback state machine: hook triggering, seek snap-back, rewind rules, aggregate scoring, andfinishedemission.ContentInstance— the content lifecycle state machine (pending → visible → opened → completed/skipped) with per-item state transitions and score recording.- Hooks —
blocking(pause at a timestamp) andnon-blocking(time-window overlay) types with overlap validation. - Serialization —
serialize/deserializewith validation for the portable JSON interactive-video document. VideoAdapter— the interface contract any player implementation must satisfy, plusProgrammaticActionGuardfor programmatic-event suppression.ContentTypeRegistry+ContentType— the plugin contract for authoring/playback surfaces (the@interlacejs/quiztype is one such plugin).
Install
pnpm add @interlacejs/coreMinimal example
import { ContentTypeRegistry, deserialize } from "@interlacejs/core";
import { InteractiveMediaController } from "@interlacejs/core";
const registry = new ContentTypeRegistry();
const result = deserialize(document, registry);
const controller = new InteractiveMediaController(result.items, result.videoDuration);
controller.on("requestPause", () => adapter.pause());
// drive it from your render loop
controller.tick(video.currentTime, isPlaying);
const renderState = controller.getRenderState(video.currentTime);
// renderState.visibleAnchorIds / activeBlockingContentId / completedTagIdsReact wrappers and a full demo
The React runtime (@interlacejs/player), the authoring UI (@interlacejs/editor), and the canonical quiz type (@interlacejs/quiz) build on this package. See the root README for the full walkthrough and the apps/demo source for a working wiring.
License
ISC
