Docs
Install
A script tag or npm, Show me in five lines.
trace-avatar has no dependencies. Install it from npm, or load a build from a CDN.
npm i trace-avatarShow me
Import createTrace, give it a trace object or the URL of a .trace.json, and play.
import { createTrace } from 'trace-avatar'; // Show me
const guide = createTrace({ trace: '/tours/invoice.trace.json', controls: true });
guide.on('step', ({ index, element }) => console.log('step', index, element));
guide.on('stalled', ({ index, reason }) => console.warn('step', index, reason));
guide.play();Do it for me
The trace-avatar/perform entry acts on the page. Its default mode is perform, and it plays Show me too with mode: 'overlay'.
import { createTrace } from 'trace-avatar/perform';
const helper = createTrace({
trace: '/tours/invoice.trace.json',
navigate: (path) => router.push(path),
prepare: async (requires) => requires.includes('signed-in') ? isSignedIn() : true,
onReset: () => resetSandbox(),
});
helper.play();From a CDN
<!-- Show me: the TraceAvatar global -->
<script src="https://cdn.jsdelivr.net/npm/trace-avatar/dist/trace.min.js"></script>
<!-- Do it for me (also plays Show me) -->
<script src="https://cdn.jsdelivr.net/npm/trace-avatar/dist/trace-perform.min.js"></script>
<!-- Guides for the whole app, from one tag -->
<script src="https://cdn.jsdelivr.net/npm/trace-avatar/dist/trace-auto.min.js"
data-guides="/guides/index.json" defer></script>Entries and sizes
trace-avatar: the player, about 14 KB min+brotli.trace-avatar/perform: player plus hands, 15 KB.trace-avatar/auto: the guides loader, about 6 KB until its first play.trace-avatar/record9 KB,trace-avatar/studioabout 14 KB (authors only).trace-avatar/export2.5 KB,trace-avatar/repair3.2 KB,trace-avatar/assist3.8 KB in a page.
Each size is guarded by size-limit in CI.
The full reference is in the README on GitHub.