/** * Lineage web — the geometry and the reading behind ``. * * Episodes sit on a spine in chronicle order, left to right, each in its * direction's band. A relation between two episodes is an arc. This module is * pure: it decides which episodes and arcs a view shows, where each episode * sits, and the path each arc takes, so the component only draws. * * Two copies of this picture existed before it lived here: Miadi's chronicle * (`app/chronicle/components/LineageWeb.tsx`) and the wheel's Episodes tab * (`components/episode-lineage-web.tsx`, #156). jgwill/medicine-wheel#162 * brings them into one. * * @see ./lineage-layout.ts for the same spine laid out on `MWGraphData`. */ /** Continuation carries a thread forward; relation says two episodes speak to each other. */ export type LineageEdgeKind = 'continuation' | 'relation'; export declare const LINEAGE_BANDS: readonly ["east", "south", "west", "north"]; export type LineageBand = (typeof LINEAGE_BANDS)[number]; export interface LineageWebEpisode { id: string; /** Short mark shown in the chip, e.g. `E044`. */ label: string; title?: string; /** `east` | `south` | `west` | `north`; anything else sits between south and west. */ direction?: string; /** `YYYY-MM-DD`, when known. The axis is labelled by month. */ date?: string; /** Episodes of one thread are chained by a faint line, in order. */ thread?: string; /** One more line for the chip, e.g. `East · Ceremony`. */ caption?: string; } export interface LineageWebEdge { id?: string; from: string; to: string; kind: LineageEdgeKind; /** The words that say why the relation holds. */ words?: string; } export interface LineageWebView { /** The whole chronicle, or the selected episode and its relatives. */ scope: 'all' | 'around'; /** How many relations away "around" and a search's relatives reach. */ depth: 1 | 2; /** Which kinds of relation are drawn. */ kinds: Record; /** Thread chains on or off. */ threads: boolean; } export declare const DEFAULT_LINEAGE_VIEW: LineageWebView; /** * Every episode within `depth` relations of a seed, the seeds included. A * relation is walked from either end: an episode that names a seed is as * related as one a seed names. */ export declare function lineageNeighbourhood(seeds: Iterable, edges: readonly LineageWebEdge[], depth?: number): Set; export interface VisibleLineageOptions { view: LineageWebView; /** The selected episode, which `scope: "around"` centres on. */ focus?: string | null; /** The episodes a search matched, or null when nothing is typed. */ matches?: ReadonlySet | null; /** * `kin` (default): show the matches and their relatives, nothing else. * `fade`: show everything and fade what did not match. */ matchMode?: 'kin' | 'fade'; } export interface VisibleLineage { episodes: LineageWebEpisode[]; edges: LineageWebEdge[]; /** Under a `kin` search, the episodes the search found. The others shown are relatives. */ found: Set | null; /** Under a `fade` search, the episodes it did not match. */ faded: Set; } /** What a view shows: which episodes, which arcs, and how each episode is marked. */ export declare function visibleLineage(episodes: readonly LineageWebEpisode[], edges: readonly LineageWebEdge[], { view, focus, matches, matchMode }: VisibleLineageOptions): VisibleLineage; export interface LineageWebLayoutConfig { marginL: number; marginR: number; /** Room above the east band, where continuation arcs rise. */ headroom: number; /** Distance between two bands. */ bandGap: number; /** Room below the north band, where relation arcs fall. */ footroom: number; /** Height of the month axis under everything. */ axis: number; /** Fewest pixels between neighbours before the canvas widens. */ minStep: number; minWidth: number; /** Neighbours in one band step -stagger, 0, +stagger so same-day episodes stay apart. */ stagger: number; } export declare const DEFAULT_LINEAGE_WEB_LAYOUT: LineageWebLayoutConfig; export interface LineageWebLayout { width: number; height: number; positions: Map; bandY: Record; /** Where each month starts along the spine. */ months: Array<{ x: number; label: string; }>; config: LineageWebLayoutConfig; } /** Positions for episodes already in chronicle order. */ export declare function layoutLineageWeb(episodes: readonly LineageWebEpisode[], config?: Partial): LineageWebLayout; /** * The path of one arc. It bows away from the straight line between its two * episodes: continuation to the upper side, relation to the lower side, so the * two kinds do not share one band of the canvas. Between two bands the bow * is sideways and the arc stays a gentle curve, not a loop over the top. * The bow grows with the square root of the arc's length: neighbours stay * close to the spine, and long relations fan out by length instead of * stacking at one height. The arc never leaves the canvas. */ export declare function lineageArcPath(a: { x: number; y: number; }, b: { x: number; y: number; }, kind: LineageEdgeKind, layout: Pick): string; /** Consecutive episodes of each thread, as pairs to chain. */ export declare function threadChains(episodes: readonly LineageWebEpisode[]): Array<{ from: string; to: string; thread: string; }>; /** The canvas width for `count` episodes at `zoom`, never narrower than `boxWidth`. */ export declare function lineageWebWidth(count: number, zoom: number, boxWidth: number, config?: Partial): number; /** The zoom at which `count` episodes fill `boxWidth` exactly: the whole span in view. */ export declare function fitZoom(count: number, boxWidth: number, config?: Partial): number; /** * Where to scroll after the canvas changed width, so the point at `pointerX` * (measured from the box's left edge) shows the same moment on the spine. */ export declare function zoomScrollLeft(scrollLeft: number, pointerX: number, oldWidth: number, newWidth: number, config?: Partial): number; /** The next or previous episode along the spine; from nothing, the first or the last. */ export declare function stepAlongSpine(order: readonly string[], current: string | null, step: 1 | -1): string | null; /** An episode's relations, ordered by where the episode at the other end sits on the spine. */ export declare function relationsAround(id: string, edges: readonly LineageWebEdge[], order: readonly string[]): LineageWebEdge[]; /** A key for an edge that survives a change of view: its id, or its two ends and kind. */ export declare function lineageEdgeKey(e: LineageWebEdge): string; //# sourceMappingURL=lineage-web.d.ts.map