@chalk-format/core
v0.1.4
Published
The .chalk interactive book format: the data model, reading and writing .chalk files, asset keys and stores, media libraries, and labs.
Maintainers
Readme
@chalk-format/core
The .chalk interactive book format for JavaScript and TypeScript: the data model, reading and writing .chalk
files, asset keys and stores, media libraries, and running labs.
A .chalk book is pages (a rendered PDF page, an image or a colour) with objects placed on them: ink, text, images,
video, sound, 3D models and labs, with a text layer for search. Media is named by keys made from its bytes.
npm i @chalk-format/coreimport { unpackLesson, packLesson, assetKey, registryLibrary } from '@chalk-format/core';
const { lesson, assets } = await unpackLesson(bytes); // open a .chalk
console.log(lesson.title, lesson.pages.length);
const again = await packLesson(lesson, assets); // write it back
const key = await assetKey(videoBytes); // 'c1:…', the same for the same bytes everywhere
const library = registryLibrary({ url: 'https://library.example.org' });
const found = await library.search({ q: 'pendulum', types: ['video/*'] });Labs talk to the reader through @chalk-format/core/lab/client:
import { connectLab } from '@chalk-format/core/lab/client';
const lab = await connectLab({ id: 'org.example.pendulum', version: '1.0.0' });Related packages: @chalk-format/reader (the React reader and editor),
@chalk-format/pdf (PDF → .chalk),
@chalk-format/library-server (run a media library).
The specification, guides and source: https://github.com/runagent-dev/chalk-format. Apache-2.0.
