import { CommitStyle, TagStyle } from "./template"; import { Branch } from "./branch"; import { Refs } from "./refs"; import { Tag } from "./tag"; import { GitgraphTagOptions } from "./user-api/gitgraph-user-api"; export { CommitRenderOptions, CommitOptions, Commit }; interface CommitRenderOptions { renderDot?: (commit: Commit) => TNode; renderMessage?: (commit: Commit) => TNode; renderTooltip?: (commit: Commit) => TNode; } interface CommitOptions extends CommitRenderOptions { author: string; subject: string; style: CommitStyle; body?: string; hash?: string; parents?: string[]; dotText?: string; onClick?: (commit: Commit) => void; onMessageClick?: (commit: Commit) => void; onMouseOver?: (commit: Commit) => void; onMouseOut?: (commit: Commit) => void; } declare class Commit { /** * Ref names */ refs: Array; /** * Commit x position */ x: number; /** * Commit y position */ y: number; /** * Commit hash */ hash: string; /** * Abbreviated commit hash */ hashAbbrev: string; /** * Parent hashes */ parents: Array["hash"]>; /** * Abbreviated parent hashed */ parentsAbbrev: Array["hashAbbrev"]>; /** * Author */ author: { /** * Author name */ name: string; /** * Author email */ email: string; /** * Author date */ timestamp: number; }; /** * Committer */ committer: { /** * Commiter name */ name: string; /** * Commiter email */ email: string; /** * Commiter date */ timestamp: number; }; /** * Subject */ subject: string; /** * Body */ body: string; /** * Message */ readonly message: string; /** * Style */ style: CommitStyle; /** * Text inside commit dot */ dotText?: string; /** * List of branches attached */ branches?: Array; /** * Branch that should be rendered */ readonly branchToDisplay: Branch["name"]; /** * List of tags attached */ tags?: Array>; /** * Callback to execute on click. */ onClick: () => void; /** * Callback to execute on click on the commit message. */ onMessageClick: () => void; /** * Callback to execute on mouse over. */ onMouseOver: () => void; /** * Callback to execute on mouse out. */ onMouseOut: () => void; /** * Custom dot render */ renderDot?: (commit: Commit) => TNode; /** * Custom message render */ renderMessage?: (commit: Commit) => TNode; /** * Custom tooltip render */ renderTooltip?: (commit: Commit) => TNode; constructor(options: CommitOptions); setRefs(refs: Refs): this; setTags(tags: Refs, getTagStyle: (name: Tag["name"]) => Partial, getTagRender: (name: Tag["name"]) => GitgraphTagOptions["render"]): this; setBranches(branches: Array): this; setPosition({ x, y }: { x: number; y: number; }): this; withDefaultColor(color: string): Commit; /** * Ideally, we want Commit to be a [Value Object](https://martinfowler.com/bliki/ValueObject.html). * We started with a mutable class. So we'll refactor that little by little. * This private function is a helper to create a new Commit from existing one. */ private cloneCommit; }