Comprehensive TypeScript type definitions and interfaces for the Slidev presentation framework ecosystem
npx @tessl/cli install tessl/npm-slidev--types@52.1.0@slidev/types provides comprehensive TypeScript type definitions and interfaces for the Slidev presentation framework ecosystem. It serves as the shared foundation for type safety across all Slidev packages, containing type definitions for slide configuration, frontmatter schemas, presentation options, CLI interfaces, code execution contexts, and various plugin systems.
npm install @slidev/typesimport type {
SlidevConfig,
Frontmatter,
SlideInfo,
CodeRunner,
AppSetup,
MonacoSetup,
ContextMenuItem,
MarkdownTransformer,
TocItem,
RootsInfo,
ResolvedSlidevOptions
} from "@slidev/types";For CommonJS:
const { SlidevConfig, Frontmatter, SlideInfo } = require("@slidev/types");import type { SlidevConfig, Frontmatter, SlideInfo } from "@slidev/types";
// Define slide configuration
const config: SlidevConfig = {
title: "My Presentation",
theme: "default",
highlighter: "shiki",
fonts: {
sans: "Inter",
mono: "Fira Code"
}
};
// Define slide frontmatter
const slideFrontmatter: Frontmatter = {
layout: "cover",
title: "Welcome",
class: "text-center"
};
// Work with slide information
function processSlide(slide: SlideInfo) {
console.log(`Slide ${slide.index}: ${slide.title}`);
return slide.content;
}@slidev/types is organized around several key areas:
Core configuration interfaces for presentations and individual slides, including theme settings, font options, and slide-specific metadata.
interface SlidevConfig extends Omit<Required<HeadmatterConfig>, keyof ResolvedSlidevConfigSub>, ResolvedSlidevConfigSub {}
interface HeadmatterConfig extends TransitionOptions {
title?: string;
theme?: string;
addons?: string[];
highlighter?: 'shiki';
fonts?: FontOptions;
drawings?: DrawingsOptions;
}
interface Frontmatter extends TransitionOptions {
layout?: BuiltinLayouts | string;
class?: string | string[] | Record<string, unknown>;
clicks?: number;
title?: string;
hide?: boolean;
}Interfaces for extending Slidev with custom functionality including app initialization, Monaco editor setup, code runners, and various plugin hooks.
type AppSetup = (context: AppContext) => Awaitable<void>;
type MonacoSetup = (m: typeof monaco) => Awaitable<MonacoSetupReturn | void>;
type CodeRunnersSetup = (runners: CodeRunnerProviders) => Awaitable<CodeRunnerProviders | void>;
interface AppContext {
app: App;
router: Router;
}Types for executing and displaying code within presentations, including context interfaces and output formatting options.
type CodeRunner = (code: string, ctx: CodeRunnerContext) => Awaitable<CodeRunnerOutputs>;
interface CodeRunnerContext {
options: Record<string, unknown>;
highlight: (code: string, lang: string, options?: Partial<CodeToHastOptions>) => string;
run: (code: string, lang: string) => Promise<CodeRunnerOutputs>;
}
type CodeRunnerOutput = CodeRunnerOutputHtml | CodeRunnerOutputError | CodeRunnerOutputText | CodeRunnerOutputTextArray | CodeRunnerOutputDom;Types for managing slide interactions, animations, and click-based progression through presentation content.
interface ClicksContext {
current: number;
readonly clicksStart: number;
calculateSince: (at: RawSingleAtValue, size?: number) => ClicksInfo | null;
calculateRange: (at: RawRangeAtValue) => ClicksInfo | null;
register: (el: ClicksElement, info: Pick<ClicksInfo, 'delta' | 'max'> | null) => void;
}
interface ClicksInfo {
start: number;
end: number;
max: number;
delta: number;
}Command-line interface types for Slidev's build, export, and development commands.
interface CommonArgs {
entry: string;
theme?: string;
}
interface ExportArgs extends CommonArgs {
'output'?: string;
'format'?: string;
'timeout'?: number;
'with-clicks'?: boolean;
}
interface BuildArgs extends ExportArgs {
out: string;
base?: string;
inspect: boolean;
}Core data structures for slide information, markdown processing, and presentation data management.
interface SlideInfo extends SlideInfoBase {
index: number;
source: SourceSlideInfo;
noteHTML?: string;
}
interface SlidevData {
slides: SlideInfo[];
entry: SlidevMarkdown;
config: SlidevConfig;
features: SlidevDetectedFeatures;
}Server configuration, entry options, and resolved utilities for Slidev runtime environment.
interface RootsInfo {
cliRoot: string;
clientRoot: string;
userRoot: string;
userPkgJson: Record<string, any>;
userWorkspaceRoot: string;
}
interface SlidevEntryOptions {
entry: string;
theme?: string;
remote?: string;
inspect?: boolean;
download?: boolean;
base?: string;
}
interface ResolvedSlidevOptions extends RootsInfo, SlidevEntryOptions {
data: SlidevData;
themeRaw: string;
themeRoots: string[];
addonRoots: string[];
roots: string[];
mode: 'dev' | 'build' | 'export';
utils: ResolvedSlidevUtils;
}Options and Configuration System
Types for Slidev's context menu system with right-click menus and interactive options.
type ContextMenuItem = ContextMenuOption | 'separator';
type ContextMenuOption = {
action: () => void;
disabled?: boolean;
} & (
| {
small?: false;
icon?: Component | string;
label: string | Component;
}
| {
small: true;
icon: Component | string;
label: string;
}
);Types for custom markdown transformation during slide processing and rendering.
interface MarkdownTransformContext {
s: MagicString;
slide: SlideInfo;
options: ResolvedSlidevOptions;
}
type MarkdownTransformer = (ctx: MarkdownTransformContext) => Awaitable<void>;Hierarchical navigation structure and TOC item management for presentations.
interface TocItem {
no: number;
active?: boolean;
activeParent?: boolean;
children: TocItem[];
hasActiveParent?: boolean;
level: number;
titleLevel: number;
path: string;
hideInToc?: boolean;
title?: string;
}