import * as Monaco from 'monaco-editor/esm/vs/editor/editor.api'; import { ElementDefinition } from 'cytoscape'; /** * Label, ID, Classes, or Data Attribute Value * * *Note:* The word "descriptor" refers to it being a sort of inverse (CSS) Selector, in that we're describing * an element rather than selecting one that may exist */ type Descriptor = string | number | boolean; /** * These are the things stored in the document with text (as opposed to edges, which are stored via indentation, etc.) * * They are stored under "data" in the document * e.g., label #id.class1.class2[x=14][cool] */ interface Data { [key: string]: Descriptor; } /** * The more specific version of attributes with a guarateed id, classes, and label * * A "Feature" refers to a node or an edge in the graph, both of which are gauranteed to at least have this data */ interface FeatureData extends Data { id: string; classes: string; label: string; } /** * Data that is a result of parsing the document */ type Parser = { lineNumber: number; }; type Node = { data: FeatureData; parser?: Parser; }; type Edge = { source: string; target: string; data: FeatureData; parser?: Parser; }; type Graph = { nodes: Node[]; edges: Edge[]; }; type PointerType = "id" | "class" | "label"; type Pointer = [PointerType, string]; declare function parse(text: string): Graph; declare function toMermaid({ nodes, edges }: Graph): string; declare const languageId = "graphselector"; declare const defaultTheme = "graphselector-theme"; declare const defaultThemeDark = "graphselector-theme-dark"; declare const colors: Record; declare function registerHighlighter(monaco: typeof Monaco): void; declare const highlight_colors: typeof colors; declare const highlight_defaultTheme: typeof defaultTheme; declare const highlight_defaultThemeDark: typeof defaultThemeDark; declare const highlight_languageId: typeof languageId; declare const highlight_registerHighlighter: typeof registerHighlighter; declare namespace highlight { export { highlight_colors as colors, highlight_defaultTheme as defaultTheme, highlight_defaultThemeDark as defaultThemeDark, highlight_languageId as languageId, highlight_registerHighlighter as registerHighlighter }; } declare function toCytoscapeElements(parsed: Graph | null): ElementDefinition[]; declare function addClassesToEdge({ line, classNames }: { line: string; classNames: string[]; }): string; declare function addClassesToNode({ line, classNames }: { line: string; classNames: string[]; }): string; /** * Adds a data attribute to a node * or updates the value of an existing data attribute */ declare function addDataAttributeToNode({ line, name, value, }: { line: string; name: string; value: Descriptor; }): string; declare function removeClassesFromEdge({ line, classNames, }: { /** The line text */ line: string; /** Array of string *without* the dot (.) */ classNames: string[]; }): string; declare function removeClassesFromNode({ line, classNames, }: { /** The line text */ line: string; /** Array of string *without* the dot (.) */ classNames: string[]; }): string; /** * Removes a data attribute from a node by name */ declare function removeDataAttributeFromNode({ line, name }: { line: string; name: string; }): string; declare const operations: { removeClassesFromNode: typeof removeClassesFromNode; addClassesToNode: typeof addClassesToNode; addDataAttributeToNode: typeof addDataAttributeToNode; removeDataAttributeFromNode: typeof removeDataAttributeFromNode; addClassesToEdge: typeof addClassesToEdge; removeClassesFromEdge: typeof removeClassesFromEdge; }; type OperationKey = keyof typeof operations; /** Create a type which is a tuple. First the opertion key, then the paramaters of the function */ type Operation = { [K in OperationKey]: [K, Omit[0], "line">]; }[OperationKey]; type Instruction = { /** a **1-indexed** (not 0-indexed) line number */ lineNumber: number; operation: Operation; }; /** * Used to alter the text of a graph given an instruction. * * e.g. _"tell the node on line 14 to remove the class 'foo'"_ * * **Note:** The line number is 1-indexed, not 0-indexed. */ declare function operate(graphText: string, instruction: Instruction): string; type StringifyOptions = { /** * Whether to compact the output by removing newlines and spaces */ compact?: boolean; }; /** * Convets a graph to graph-selector DSL */ declare function stringify(graph: Graph, options?: StringifyOptions): string; declare class ParseError extends Error { startLineNumber: number; endLineNumber: number; startColumn: number; endColumn: number; code: string; constructor(message: string, startLineNumber: number, endLineNumber: number, startColumn: number, endColumn: number, /** A unique string referencing this error. Used for translations in consuming contexts. */ code: string); } export { type Data, type Descriptor, type Edge, type FeatureData, type Graph, type Instruction, type Node, type Operation, type OperationKey, ParseError, type Parser, type Pointer, type PointerType, highlight, operate, operations, parse, stringify, toCytoscapeElements, toMermaid };