This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
npm start # dev server with hot reload (opens browser)
npm test # run all Jest tests
npm run build # build production artifacts
npm run dist # clean + build
npm run clean # delete dist/Run a single test file:
npm test -- --testPathPattern="CSV"Run tests in watch mode:
npm test -- --watchNode version: v23.3.0 (see .nvmrc)
TimelineJS3 is a browser-side JavaScript library (no backend) that renders interactive multimedia timelines. It is distributed primarily as an iframe embed from timeline.knightlab.com, but can also be imported as an ES6 module (@knight-lab/timelinejs) or instantiated directly.
Entry point: src/js/index.js exports Timeline, exportJSON, parseGoogleSpreadsheetURL, and lookupMediaType.
Build outputs:
dist/js/timeline.js— bundled library (globalTL)dist/css/timeline.css— extracted stylesdist/js/locale/*.json— i18n locale filesdist/embed/*— iframe embed templates
Build tool: vite.config.js bundles src/js/index.js into dist/js/timeline.js (library mode, global TL, IIFE format) and copies locale/embed files via vite-plugin-static-copy. The main/theme/font CSS is compiled separately by tasks/compile_less.js (plain less.render(), not through Vite) so icon font references stay unhashed and consistent across all three — see the comments in vite.config.js and tasks/compile_less.js for why. npm run build runs both steps.
| Directory | Role |
|---|---|
timeline/ |
Primary Timeline class — constructor takes (elem, data, options) |
core/ |
Data loading (ConfigFactory.js), events, utilities, CSV parsing |
timenav/ |
Timeline scrubber/navigation UI |
slider/ |
StorySlider.js — the story/content display pane |
media/ |
Media type detection and embed handling (YouTube, Vimeo, images, maps, etc.) |
date/ |
TLDate.js, DateUtil.js — date parsing and formatting |
language/ |
i18n support and locale loading |
dom/ |
DOM utilities |
ui/ |
UI components (MenuBar, Message, Draggable) |
animation/ |
Easing and animation utilities |
Timelineconstructor receives a data URL or config objectConfigFactoryfetches and normalizes data (supports Google Sheets, JSON, CSV)- Parsed data becomes a
TimelineConfigwith events and optional title/era slides TimeNavrenders the navigation track;StorySliderrenders slide content- Media embeds are resolved via the
MediaTypesystem insrc/js/media/
Tests live in src/js/**/__tests__/*.test.js. Jest uses the jsdom environment and enforces UTC timezone for consistent date tests.