UNPKG

jointjs

Version:

JavaScript diagramming library

1,786 lines (1,118 loc) 173 kB
/*! JointJS v3.7.7 (2023-11-07) - JavaScript diagramming library This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/. */ // Definitions by: // Aidan Reel <http://github.com/areel>, // David Durman <http://github.com/DavidDurman>, // Ewout Van Gossum <https://github.com/DenEwout>, // Federico Caselli <https://github.com/CaselIT>, // Chris Moran <https://github.com/ChrisMoran> // Michael MacFadden https://github.com/mmacfadden // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // typings: https://github.com/CaselIT/typings-jointjs /// <reference types="backbone" /> import * as Backbone from 'backbone'; export as namespace joint; export namespace g { export enum types { Point = 1, Line = 2, Ellipse = 3, Rect = 4, Polyline = 5, Polygon = 6, Curve = 7, Path = 8, } export type Shape = Path | Point | Line | Polyline | Polygon | Rect | Ellipse; export interface PlainPoint { x: number; y: number; } export interface PlainRect { x: number; y: number; width: number; height: number; } export interface Scale { sx: number; sy: number; } export interface PrecisionOpt { precision?: number; } export interface SubdivisionsOpt extends PrecisionOpt { subdivisions?: Curve[]; } export interface SegmentSubdivisionsOpt extends PrecisionOpt { segmentSubdivisions?: Curve[][]; } export interface PathT { segmentIndex: number; value: number; } export interface Segment { type: SegmentType; isSegment: boolean; isSubpathStart: boolean; isVisible: boolean; nextSegment: Segment | null; previousSegment: Segment | null; subpathStartSegment: Segment | null; start: Point | null | never; // getter, `never` for Moveto end: Point | null; // getter or directly assigned bbox(): Rect | null; clone(): Segment; closestPoint(p: Point, opt?: SubdivisionsOpt): Point; closestPointLength(p: Point, opt?: SubdivisionsOpt): number; closestPointNormalizedLength(p: Point, opt?: SubdivisionsOpt): number; closestPointT(p: Point): number; closestPointTangent(p: Point): Line | null; divideAt(ratio: number, opt?: SubdivisionsOpt): [Segment, Segment]; divideAtLength(length: number, opt?: SubdivisionsOpt): [Segment, Segment]; divideAtT(t: number): [Segment, Segment]; equals(segment: Segment): boolean; getSubdivisions(): Curve[]; isDifferentiable(): boolean; length(): number; lengthAtT(t: number, opt?: PrecisionOpt): number; pointAt(ratio: number): Point; pointAtLength(length: number): Point; pointAtT(t: number): Point; round(precision?: number): this; scale(sx: number, sy: number, origin?: PlainPoint): this; tangentAt(ratio: number): Line | null; tangentAtLength(length: number): Line | null; tangentAtT(t: number): Line | null; translate(tx?: number, ty?: number): this; translate(tx: PlainPoint): this; serialize(): string; toString(): string; } export interface SegmentTypes { [key: string]: Segment; } type CardinalDirection = 'NE' | 'E' | 'SE' | 'S' | 'SW' | 'W' | 'NW' | 'N'; type RectangleSide = 'left' | 'right' | 'top' | 'bottom'; type PathSegmentUnit = Segment | Segment[]; type PathObjectUnit = Line | Line[] | Curve | Curve[]; type SegmentType = 'L' | 'C' | 'M' | 'Z' | 'z'; export function normalizeAngle(angle: number): number; export function snapToGrid(val: number, gridSize: number): number; export function toDeg(rad: number): number; export function toRad(deg: number, over360?: boolean): number; export function random(min?: number, max?: number): number; export interface SkeletonPoints { startControlPoint1: Point; startControlPoint2: Point; divider: Point; dividerControlPoint1: Point; dividerControlPoint2: Point; } class Curve { start: Point; controlPoint1: Point; controlPoint2: Point; end: Point; type: types.Curve; constructor(p1: PlainPoint | string, p2: PlainPoint | string, p3: PlainPoint | string, p4: PlainPoint | string); constructor(curve: Curve); bbox(): Rect; clone(): Curve; closestPoint(p: PlainPoint, opt?: SubdivisionsOpt): Point; closestPointLength(p: PlainPoint, opt?: SubdivisionsOpt): number; closestPointNormalizedLength(p: PlainPoint, opt?: SubdivisionsOpt): number; closestPointT(p: PlainPoint, opt?: SubdivisionsOpt): number; closestPointTangent(p: PlainPoint, opt?: SubdivisionsOpt): Line | null; containsPoint(p: PlainPoint, opt?: SubdivisionsOpt): boolean; divideAt(ratio: number, opt?: SubdivisionsOpt): [Curve, Curve]; divideAtLength(length: number, opt?: SubdivisionsOpt): [Curve, Curve]; divideAtT(t: number): [Curve, Curve]; divide(t: number): [Curve, Curve]; // alias to `divideAtT` endpointDistance(): number; equals(c: Curve): boolean; getSkeletonPoints(t: number): SkeletonPoints; getSubdivisions(opt?: PrecisionOpt): Curve[]; isDifferentiable(): boolean; length(opt?: SubdivisionsOpt): number; lengthAtT(t: number, opt?: PrecisionOpt): number; pointAt(ratio: number, opt?: SubdivisionsOpt): Point; pointAtLength(length: number, opt?: SubdivisionsOpt): Point; pointAtT(t: number): Point; round(precision?: number): this; scale(sx: number, sy: number, origin?: PlainPoint | string): this; tangentAt(ratio: number, opt?: SubdivisionsOpt): Line | null; tangentAtLength(length: number, opt?: SubdivisionsOpt): Line | null; tangentAtT(t: number): Line | null; tAt(ratio: number, opt?: SubdivisionsOpt): number; tAtLength(length: number, opt?: SubdivisionsOpt): number; translate(tx?: number, ty?: number): this; translate(tx: PlainPoint): this; toPoints(opt?: SubdivisionsOpt): Point[]; toPolyline(opt?: SubdivisionsOpt): Polyline; toString(): string; static throughPoints(points: PlainPoint[]): Curve[]; } class Ellipse { x: number; y: number; a: number; b: number; type: types.Ellipse; constructor(center: PlainPoint | string, a: number, b: number); constructor(ellipse: Ellipse); bbox(): Rect; center(): Point; clone(): Ellipse; containsPoint(p: PlainPoint): boolean; equals(ellipse: Ellipse): boolean; inflate(dx?: number, dy?: number): this; intersectionWithLine(l: Line): Point[] | null; intersectionWithLineFromCenterToPoint(p: PlainPoint, angle?: number): Point; normalizedDistance(point: PlainPoint): number; round(precision?: number): this; tangentTheta(p: PlainPoint): number; toString(): string; static fromRect(rect: PlainRect): Ellipse; } class Line { start: Point; end: Point; type: types.Line; constructor(p1: PlainPoint | string, p2: PlainPoint | string); constructor(line: Line); constructor(); angle(): number; bbox(): Rect; bearing(): CardinalDirection; clone(): Line; parallel(distance: number): Line; closestPoint(p: PlainPoint | string): Point; closestPointLength(p: PlainPoint | string): number; closestPointNormalizedLength(p: PlainPoint | string): number; closestPointTangent(p: PlainPoint | string): Line | null; containsPoint(p: PlainPoint): boolean; divideAt(t: number): [Line, Line]; divideAtLength(length: number): [Line, Line]; equals(line: Line): boolean; intersect(line: Line): Point | null; // Backwards compatibility, should return an array intersect(rect: Rect): Point[] | null; intersect(ellipse: Ellipse): Point[] | null; intersect(polyline: Polyline): Point[] | null; intersect(path: Path, opt?: SegmentSubdivisionsOpt): Point[] | null; intersectionWithLine(l: Line): Point[] | null; isDifferentiable(): boolean; length(): number; midpoint(): Point; pointAt(t: number): Point; pointAtLength(length: number): Point; pointOffset(p: PlainPoint | string): number; rotate(origin: PlainPoint, angle: number): this; round(precision?: number): this; scale(sx: number, sy: number, origin?: PlainPoint): this; setLength(length: number): this; squaredLength(): number; tangentAt(t: number): Line | null; tangentAtLength(length: number): Line | null; translate(tx?: number, ty?: number): this; translate(tx: PlainPoint): this; vector(): Point; toString(): string; serialize(): string; } class Path { segments: Segment[]; start: Point | null; // getter end: Point | null; // getter type: types.Path; constructor(); constructor(pathData: string); constructor(segments: PathSegmentUnit | PathSegmentUnit[]); constructor(objects: PathObjectUnit | PathObjectUnit[]); constructor(polyline: Polyline); appendSegment(segments: PathSegmentUnit | PathSegmentUnit[]): void; bbox(): Rect | null; clone(): Path; closestPoint(p: Point, opt?: SegmentSubdivisionsOpt): Point | null; closestPointLength(p: Point, opt?: SegmentSubdivisionsOpt): number; closestPointNormalizedLength(p: Point, opt?: SegmentSubdivisionsOpt): number; closestPointTangent(p: Point, opt?: SegmentSubdivisionsOpt): Line | null; containsPoint(p: PlainPoint, opt?: SegmentSubdivisionsOpt): boolean; divideAt(ratio: number, opt?: SegmentSubdivisionsOpt): [Path, Path] | null; divideAtLength(length: number, opt?: SegmentSubdivisionsOpt): [Path, Path] | null; equals(p: Path): boolean; getSegment(index: number): Segment | null; getSegmentSubdivisions(opt?: PrecisionOpt): Curve[][]; getSubpaths(): Path[]; insertSegment(index: number, segments: PathSegmentUnit | PathSegmentUnit[]): void; intersectionWithLine(l: Line, opt?: SegmentSubdivisionsOpt): Point[] | null; isDifferentiable(): boolean; isValid(): boolean; length(opt?: SegmentSubdivisionsOpt): number; pointAt(ratio: number, opt?: SegmentSubdivisionsOpt): Point | null; pointAtLength(length: number, opt?: SegmentSubdivisionsOpt): Point | null; removeSegment(index: number): void; replaceSegment(index: number, segments: PathSegmentUnit | PathSegmentUnit[]): void; round(precision?: number): this; scale(sx: number, sy: number, origin?: PlainPoint | string): this; segmentAt(ratio: number, opt?: SegmentSubdivisionsOpt): Segment | null; segmentAtLength(length: number, opt?: SegmentSubdivisionsOpt): Segment | null; segmentIndexAt(ratio: number, opt?: SegmentSubdivisionsOpt): number | null; segmentIndexAtLength(length: number, opt?: SegmentSubdivisionsOpt): number | null; tangentAt(ratio: number, opt?: SegmentSubdivisionsOpt): Line | null; tangentAtLength(length: number, opt?: SegmentSubdivisionsOpt): Line | null; toPoints(opt?: SegmentSubdivisionsOpt): Point[][] | null; toPolylines(opt?: SegmentSubdivisionsOpt): Polyline[] | null; translate(tx?: number, ty?: number): this; translate(tx: PlainPoint): this; serialize(): string; toString(): string; validate(): this; private closestPointT(p: Point, opt?: SegmentSubdivisionsOpt): PathT | null; private lengthAtT(t: PathT, opt?: SegmentSubdivisionsOpt): number; private pointAtT(t: PathT): Point | null; private tangentAtT(t: PathT): Line | null; private prepareSegment(segment: Segment, previousSegment?: Segment | null, nextSegment?: Segment | null): Segment; private updateSubpathStartSegment(segment: Segment): void; static createSegment(type: SegmentType, ...args: any[]): PathSegmentUnit; static parse(pathData: string): Path; static segmentTypes: SegmentTypes; static isDataSupported(pathData: string): boolean; } class Point implements PlainPoint { x: number; y: number; type: types.Point; constructor(x?: number, y?: number); constructor(p: PlainPoint | string); chooseClosest(points: PlainPoint[]): Point | null; adhereToRect(r: Rect): this; angleBetween(p1: PlainPoint, p2: PlainPoint): number; bearing(p: Point): CardinalDirection; changeInAngle(dx: number, dy: number, ref: PlainPoint | string): number; clone(): Point; cross(p1: PlainPoint, p2: PlainPoint): number; difference(dx?: number, dy?: number): Point; difference(p: PlainPoint): Point; distance(p: PlainPoint | string): number; dot(p: PlainPoint): number; equals(p: Point): boolean; lerp(p: Point, t: number): Point; magnitude(): number; manhattanDistance(p: PlainPoint): number; move(ref: PlainPoint | string, distance: number): this; normalize(length: number): this; offset(dx?: number, dy?: number): this; offset(p: PlainPoint): this; reflection(ref: PlainPoint | string): Point; rotate(origin: PlainPoint | string, angle: number): this; round(precision?: number): this; scale(sx: number, sy: number, origin?: PlainPoint | string): this; snapToGrid(gx: number, gy?: number): this; squaredDistance(p: PlainPoint | string): number; theta(p: PlainPoint | string): number; toJSON(): PlainPoint; toPolar(origin?: PlainPoint | string): this; toString(): string; serialize(): string; translate(tx?: number, ty?: number): this; translate(tx: PlainPoint): this; update(x?: number, y?: number): this; update(p: PlainPoint): this; vectorAngle(p: PlainPoint): number; static fromPolar(distance: number, angle: number, origin?: PlainPoint | string): Point; static random(x1: number, x2: number, y1: number, y2: number): Point; } abstract class PolygonalChain { points: Point[]; start: Point | null; // getter end: Point | null; // getter constructor(); constructor(svgString: string); constructor(points: PlainPoint[]); bbox(): Rect | null; closestPoint(p: PlainPoint | string): Point | null; closestPointLength(p: PlainPoint | string): number; closestPointNormalizedLength(p: PlainPoint | string): number; closestPointTangent(p: PlainPoint | string): Line | null; containsPoint(p: PlainPoint): boolean; equals(p: Polyline): boolean; isDifferentiable(): boolean; intersectionWithLine(l: Line): Point[] | null; close(): this; length(): number; pointAt(ratio: number): Point | null; pointAtLength(length: number): Point | null; round(precision?: number): this; scale(sx: number, sy: number, origin?: PlainPoint | string): this; simplify(opt?: { threshold?: number }): this; tangentAt(ratio: number): Line | null; tangentAtLength(length: number): Line | null; translate(tx?: number, ty?: number): this; translate(tx: PlainPoint): this; serialize(): string; toString(): string; clone(): this; convexHull(): this; } class Polyline extends PolygonalChain { type: types.Polyline; static parse(svgString: string): Polyline; static fromRect(rect: Rect): Polyline; } class Polygon extends PolygonalChain { type: types.Polygon; static parse(svgString: string): Polygon; static fromRect(rect: Rect): Polygon; } class Rect implements PlainRect { x: number; y: number; width: number; height: number; type: types.Rect; constructor(x?: number, y?: number, width?: number, height?: number); constructor(r: PlainRect); bbox(angle?: number): Rect; rotateAroundCenter(angle: number): this; bottomLeft(): Point; bottomLine(): Line; bottomMiddle(): Point; bottomRight(): Point; center(): Point; clone(): Rect; containsPoint(p: PlainPoint | string): boolean; containsRect(r: PlainRect): boolean; corner(): Point; equals(r: PlainRect): boolean; inflate(dx?: number, dy?: number): this; intersect(r: Rect): Rect | null; intersectionWithLine(l: Line): Point[] | null; intersectionWithLineFromCenterToPoint(p: PlainPoint | string, angle?: number): Point; leftLine(): Line; leftMiddle(): Point; maxRectScaleToFit(rect: PlainRect, origin?: PlainPoint): Scale; maxRectUniformScaleToFit(rect: PlainRect, origin?: PlainPoint): number; moveAndExpand(r: PlainRect): this; normalize(): this; offset(dx?: number, dy?: number): this; offset(p: PlainPoint): this; origin(): Point; pointNearestToPoint(point: PlainPoint | string): Point; rightLine(): Line; rightMiddle(): Point; round(precision?: number): this; scale(sx: number, sy: number, origin?: PlainPoint | string): this; sideNearestToPoint(point: PlainPoint | string): RectangleSide; snapToGrid(gx: number, gy?: number): this; topLeft(): Point; topLine(): Line; topMiddle(): Point; topRight(): Point; translate(tx?: number, ty?: number): this; translate(tx: PlainPoint): this; toJSON(): PlainRect; toString(): string; union(rect: PlainRect): Rect; update(x?: number, y?: number, width?: number, height?: number): this; update(rect: PlainRect): this; static fromEllipse(e: Ellipse): Rect; static fromPointUnion(...points: PlainPoint[]): Rect | null; static fromRectUnion(...rects: PlainRect[]): Rect | null; } namespace bezier { interface IBezierCurve { p0: Point; p1: Point; p2: Point; p3: Point; } export function curveThroughPoints(points: PlainPoint[] | Point[]): string[]; export function getCurveControlPoints(points: PlainPoint[] | Point[]): [Point[], Point[]]; export function getCurveDivider( p0: string | PlainPoint, p1: string | PlainPoint, p2: string | PlainPoint, p3: string | PlainPoint ): (t: number) => [IBezierCurve, IBezierCurve]; export function getFirstControlPoints(rhs: number[]): number[]; export function getInversionSolver( p0: PlainPoint, p1: PlainPoint, p2: PlainPoint, p3: PlainPoint ): (p: PlainPoint) => number; } namespace scale { export function linear(domain: [number, number], range: [number, number], value: number): number; } namespace intersection { function exists(shape1: Shape, shape2: Shape, shape1opt?: SegmentSubdivisionsOpt | null, shape2opt?: SegmentSubdivisionsOpt | null): boolean; /* Line */ export function lineWithLine(line1: Line, line2: Line): boolean; /* Ellipse */ export function ellipseWithLine(ellipse: Ellipse, line: Line): boolean; export function ellipseWithEllipse(ellipse1: Ellipse, ellipse2: Ellipse): boolean; /* Rect */ export function rectWithLine(rect: Rect, line: Line): boolean; export function rectWithEllipse(rect: Rect, ellipse: Ellipse): boolean; export function rectWithRect(rect1: Rect, rect2: Rect): boolean; /* Polyline */ export function polylineWithLine(polyline: Polyline, line: Line): boolean; export function polylineWithEllipse(polyline: Polyline, ellipse: Ellipse): boolean; export function polylineWithRect(polyline: Polyline, rect: Rect): boolean; export function polylineWithPolyline(polyline1: Polyline, polyline2: Polyline): boolean; /* Polygon */ export function polygonWithLine(polygon: Polygon, line: Line): boolean; export function polygonWithEllipse(polygon: Polygon, ellipse: Ellipse): boolean; export function polygonWithRect(polygon: Polygon, rect: Rect): boolean; export function polygonWithPolyline(polygon: Polygon, polyline: Polyline): boolean; export function polygonWithPolygon(polygon1: Polygon, polygon2: Polygon): boolean; /* Path */ export function pathWithLine(path: Path, line: Line, pathOpt?: SegmentSubdivisionsOpt): boolean; export function pathWithEllipse(path: Path, ellipse: Ellipse, pathOpt?: SegmentSubdivisionsOpt): boolean; export function pathWithRect(path: Path, rect: Rect, pathOpt?: SegmentSubdivisionsOpt): boolean; export function pathWithPolyline(path: Path, polyline: Polyline, pathOpt?: SegmentSubdivisionsOpt): boolean; export function pathWithPolygon(path: Path, polygon: Polygon, pathOpt?: SegmentSubdivisionsOpt): boolean; export function pathWithPath(path1: Path, path2: Path, pathOpt1?: SegmentSubdivisionsOpt | null, pathOpt2?: SegmentSubdivisionsOpt | null): boolean; } } export const V: VCallable; export type V = VElement; export const Vectorizer: VCallable; export type Vectorizer = VElement; export namespace Vectorizer { interface RotateOptions { absolute?: boolean; } interface AnnotateStringOptions { includeAnnotationIndices?: boolean; offset?: number; } type TextVerticalAnchor = 'top' | 'bottom' | 'middle'; interface TextOptions { eol?: string; x?: number | string; textVerticalAnchor?: TextVerticalAnchor | number | string; lineHeight?: number | string; textPath?: string | { [key: string]: any }; annotations?: TextAnnotation[]; includeAnnotationIndices?: boolean; displayEmpty?: boolean; } interface GetBBoxOptions { target?: SVGElement | VElement; recursive?: boolean; } interface TransformOptions { absolute?: boolean; } interface ParseXMLOptions { async?: boolean; } interface TextAnnotation { start: number; end: number; attrs: { [key: string]: any }; } // modifiable Matrix. SVGMatrix doesn't allow set on properties or a constructor. interface Matrix { a: number; b: number; c: number; d: number; e: number; f: number; } interface Sample { x: number; y: number; distance: number; } interface DecomposedTransformation { translateX: number; translateY: number; scaleX: number; scaleY: number; skewX: number; skewY: number; rotation: number; } interface RoundedRect extends g.PlainRect { 'rx'?: number; 'ry'?: number; 'top-rx'?: number; 'top-ry'?: number; 'bottom-rx'?: number; 'bottom-ry'?: number; } interface Rotation { angle: number; cx?: number; cy?: number; } interface Translation { tx: number; ty: number; } interface Scale { sx: number; sy: number; } interface Transform { value: string; translate: Translation; rotate: Rotation; scale: Scale; } interface QualifiedAttribute { ns: string | null; local: string; } } interface VCallable extends VStatic { ( svg: SVGElement | VElement | string, attrs?: { [key: string]: any }, children?: VElement | VElement[] | SVGElement | SVGElement[] ): VElement; } export class VElement { id: string; node: SVGElement; getTransformToElement(toElem: SVGGElement | VElement): SVGMatrix; transform(): SVGMatrix; transform(matrix: SVGMatrix | Vectorizer.Matrix, opt?: Vectorizer.TransformOptions): this; translate(): Vectorizer.Translation; translate(tx: number, ty?: number, opt?: Vectorizer.TransformOptions): this; rotate(): Vectorizer.Rotation; rotate(angle: number, cx?: number, cy?: number, opt?: Vectorizer.RotateOptions): this; scale(): Vectorizer.Scale; scale(sx: number, sy?: number): this; bbox(withoutTransformations?: boolean, target?: SVGElement | VElement): g.Rect; getBBox(opt?: Vectorizer.GetBBoxOptions): g.Rect; text(content: string, opt?: Vectorizer.TextOptions): this; removeAttr(name: string): this; attr(): { [key: string]: string }; attr(name: string): string | null; attr(name: string, value: any): this; attr(attrs: { [key: string]: any }): this; normalizePath(): this; remove(): this; empty(): this; append(els: VElement | VElement[] | SVGElement | SVGElement[]): this; prepend(els: VElement | VElement[] | SVGElement | SVGElement[]): this; before(els: VElement | VElement[] | SVGElement | SVGElement[]): this; appendTo(el: SVGElement | VElement): this; parent(): VElement | null; // returns either this or VElement, no point in specifying this. svg(): VElement; tagName(): string; defs(): VElement | undefined; clone(): VElement; findOne(selector: string): VElement | undefined; find(selector: string): VElement[]; children(): VElement[]; index(): number; findParentByClass(className: string, terminator?: SVGElement): VElement | null; contains(el: SVGElement | VElement): boolean; toLocalPoint(x: number, y: number): SVGPoint; translateCenterToPoint(p: g.PlainPoint): this; translateAndAutoOrient(position: g.PlainPoint, reference: g.PlainPoint, target?: SVGElement | VElement): this; animateAlongPath(attrs: { [key: string]: any }, path: SVGElement | VElement): void; hasClass(className: string): boolean; addClass(className: string): VElement; removeClass(className: string): this; toggleClass(className: string, switchArg?: boolean): this; sample(interval?: number): Vectorizer.Sample[]; convertToPath(): VElement; convertToPathData(): string; findIntersection(ref: g.PlainPoint, target: SVGElement | VElement): g.PlainPoint | undefined; toGeometryShape(): g.Shape; private setAttributes(attrs: { [key: string]: any }): this; private setAttribute(name: string, value: string): this; } interface VStatic { createSVGDocument(content: string): Document; createSVGStyle(stylesheet: string): SVGStyleElement; createCDATASection(data: string): CDATASection; uniqueId(): string; ensureId(node: SVGElement | VElement): string; sanitizeText(text: string): string; isUndefined(value: any): boolean; isString(value: any): boolean; isObject(value: any): boolean; isArray(value: any): boolean; parseXML(data: string, opt?: Vectorizer.ParseXMLOptions): XMLDocument; qualifyAttr(name: string): Vectorizer.QualifiedAttribute; transformStringToMatrix(transform: string): SVGMatrix; matrixToTransformString(matrix: SVGMatrix | Vectorizer.Matrix): string; parseTransformString(transform: string): Vectorizer.Transform; deltaTransformPoint(matrix: SVGMatrix | Vectorizer.Matrix, point: SVGPoint | g.PlainPoint): g.PlainPoint; decomposeMatrix(matrix: SVGMatrix | Vectorizer.Matrix): Vectorizer.DecomposedTransformation; matrixToScale(matrix: SVGMatrix | Vectorizer.Matrix): Vectorizer.Scale; matrixToRotate(matrix: SVGMatrix | Vectorizer.Matrix): Vectorizer.Rotation; matrixToTranslate(matrix: SVGMatrix | Vectorizer.Matrix): Vectorizer.Translation; isV(value: any): boolean; isVElement(value: any): boolean; isSVGGraphicsElement(value: any): boolean; createSVGMatrix(matrix?: SVGMatrix | Partial<Vectorizer.Matrix>): SVGMatrix; createSVGTransform(matrix?: SVGMatrix | Partial<Vectorizer.Matrix>): SVGTransform; createSVGPoint(x: number, y: number): SVGPoint; transformRect(r: g.PlainRect, matrix: SVGMatrix): g.Rect; transformPoint(p: g.PlainPoint, matrix: SVGMatrix): g.Point; transformLine(p: g.Line, matrix: SVGMatrix): g.Line; transformPolyline(p: g.Polyline | g.PlainPoint[], matrix: SVGMatrix): g.Polyline; styleToObject(styleString: string): { [key: string]: string }; createSlicePathData(innerRadius: number, outRadius: number, startAngle: number, endAngle: number): string; mergeAttrs(a: any, b: any): any; annotateString(t: string, annotations: Vectorizer.TextAnnotation[], opt?: Vectorizer.AnnotateStringOptions): Array< string | { [key: string]: any }> ; findAnnotationsAtIndex(annotations: Vectorizer.TextAnnotation[], index: number): Vectorizer.TextAnnotation[]; findAnnotationsBetweenIndexes(annotations: Vectorizer.TextAnnotation[], start: number, end: number): Vectorizer.TextAnnotation[]; shiftAnnotations(annotations: Vectorizer.TextAnnotation[], index: number, offset: number): Vectorizer.TextAnnotation[]; convertLineToPathData(line: string | SVGElement | VElement): string; convertPolygonToPathData(line: string | SVGElement | VElement): string; convertPolylineToPathData(line: string | SVGElement | VElement): string; svgPointsToPath(points: g.PlainPoint[] | SVGPoint[]): string; getPointsFromSvgNode(node: SVGElement | VElement): SVGPoint[]; convertCircleToPathData(circle: string | SVGElement | VElement): string; convertEllipseToPathData(ellipse: string | SVGElement | VElement): string; convertRectToPathData(rect: string | SVGElement | VElement): string; rectToPath(r: Vectorizer.RoundedRect): string; normalizePathData(path: string): string; toNode(el: SVGElement | VElement | SVGElement[]): SVGElement; prototype: VElement; } export const version: string; export namespace config { var useCSSSelectors: boolean; var classNamePrefix: string; var defaultTheme: string; var doubleTapInterval: number; } export namespace dia { type Event = JQuery.TriggeredEvent; type ObjectHash = { [key: string]: any }; type Point = g.PlainPoint; type BBox = g.PlainRect; type Size = Pick<BBox, 'width' | 'height'>; type PaddingJSON = { left?: number; top?: number; right?: number; bottom?: number; }; type Padding = number | PaddingJSON; type SidesJSON = { left?: number; top?: number; right?: number; bottom?: number; horizontal?: number; vertical?: number; }; type LegacyPositionName = 'topLeft' | 'topRight' | 'bottomLeft' | 'bottomRight' | 'topMiddle' | 'bottomMiddle' | 'leftMiddle' | 'rightMiddle' | 'corner' | 'origin'; type PositionName = 'top' | 'left' | 'bottom' | 'right' | 'center' | 'top-left' | 'top-right' | 'bottom-left' | 'bottom-right' | LegacyPositionName; type Sides = number | SidesJSON; type OrthogonalDirection = 'left' | 'top' | 'right' | 'bottom'; type Direction = OrthogonalDirection | 'top-left' | 'top-right' | 'bottom-right' | 'bottom-left'; type LinkEnd = 'source' | 'target'; type MarkupNodeJSON = { tagName: string; selector?: string; groupSelector?: string | string[]; namespaceURI?: string; className?: string; attributes?: attributes.NativeSVGAttributes; style?: { [key: string]: any }; children?: MarkupJSON; textContent?: string; }; type MarkupJSON = Array<MarkupNodeJSON | string>; type Path = string | Array<string | number>; interface ModelSetOptions extends Backbone.ModelSetOptions { dry?: boolean; isolate?: boolean; [key: string]: any; } interface CollectionAddOptions extends Backbone.AddOptions { dry?: boolean; [key: string]: any; } interface SVGPatternJSON { id?: string; type: 'pattern'; attrs?: attributes.NativeSVGAttributes; markup: string | MarkupJSON; } interface SVGGradientJSON { id?: string; type: 'linearGradient' | 'radialGradient'; attrs?: attributes.NativeSVGAttributes; stops: Array<{ offset: number | string; color: string; opacity?: number; }>; } type SVGMarkerJSON = SVGComplexMarkerJSON | SVGSimpleMarkerJSON; interface SVGComplexMarkerJSON { id?: string; markup: string | MarkupJSON; attrs?: attributes.NativeSVGAttributes; } interface SVGSimpleMarkerJSON extends attributes.NativeSVGAttributes { id?: string; type?: string; /** * @deprecated use `attrs` instead */ markerUnits?: string; } type SVGFilterJSON = util.filter.FilterJSON<'outline'> | util.filter.FilterJSON<'highlight'> | util.filter.FilterJSON<'blur'> | util.filter.FilterJSON<'dropShadow'> | util.filter.FilterJSON<'grayscale'> | util.filter.FilterJSON<'sepia'> | util.filter.FilterJSON<'saturate'> | util.filter.FilterJSON<'hueRotate'> | util.filter.FilterJSON<'invert'> | util.filter.FilterJSON<'brightness'> | util.filter.FilterJSON<'contrast'>; export namespace Graph { interface Options { [key: string]: any; } interface ConnectionOptions extends Cell.EmbeddableOptions { inbound?: boolean; outbound?: boolean; } interface ExploreOptions extends ConnectionOptions { breadthFirst?: boolean; } class Cells extends Backbone.Collection<Cell> { graph: Graph; cellNamespace: any; } interface Attributes { cells?: Cells; [key: string]: any; } } class Graph<A extends ObjectHash = Graph.Attributes, S = dia.ModelSetOptions> extends Backbone.Model<A, S> { constructor(attributes?: Graph.Attributes, opt?: { cellNamespace?: any, cellModel?: typeof Cell }); addCell(cell: Cell.JSON | Cell, opt?: CollectionAddOptions): this; addCell(cell: Array<Cell | Cell.JSON>, opt?: CollectionAddOptions): this; addCells(cells: Array<Cell | Cell.JSON>, opt?: CollectionAddOptions): this; resetCells(cells: Array<Cell | Cell.JSON>, opt?: Graph.Options): this; getCell(id: Cell.ID | Cell): Cell; getElements(): Element[]; getLinks(): Link[]; getCells(): Cell[]; getFirstCell(): Cell | undefined; getLastCell(): Cell | undefined; getConnectedLinks(cell: Cell, opt?: Graph.ConnectionOptions): Link[]; disconnectLinks(cell: Cell, opt?: S): void; removeLinks(cell: Cell, opt?: Cell.DisconnectableOptions): void; translate(tx: number, ty?: number, opt?: Element.TranslateOptions): this; cloneCells(cells: Cell[]): { [id: string]: Cell }; getSubgraph(cells: Cell[], opt?: Cell.EmbeddableOptions): Cell[]; cloneSubgraph(cells: Cell[], opt?: Cell.EmbeddableOptions): { [id: string]: Cell }; dfs(element: Element, iteratee: (element: Element, distance: number) => boolean, opt?: Graph.ConnectionOptions): void; bfs(element: Element, iteratee: (element: Element, distance: number) => boolean, opt?: Graph.ConnectionOptions): void; search(element: Element, iteratee: (element: Element, distance: number) => boolean, opt?: Graph.ExploreOptions): void; getSuccessors(element: Element, opt?: Graph.ExploreOptions): Element[]; getPredecessors(element: Element, opt?: Graph.ExploreOptions): Element[]; isSuccessor(elementA: Element, elementB: Element): boolean; isPredecessor(elementA: Element, elementB: Element): boolean; isSource(element: Element): boolean; isSink(element: Element): boolean; getSources(): Element[]; getSinks(): Element[]; getNeighbors(element: Element, opt?: Graph.ConnectionOptions): Element[]; isNeighbor(elementA: Element, elementB: Element, opt?: Graph.ConnectionOptions): boolean; getCommonAncestor(...cells: Cell[]): Element | undefined; toJSON(): any; fromJSON(json: any, opt?: S): this; clear(opt?: { [key: string]: any }): this; findModelsFromPoint(p: Point): Element[]; findModelsInArea(rect: BBox, opt?: { strict?: boolean }): Element[]; findModelsUnderElement(element: Element, opt?: { searchBy?: 'bbox' | PositionName }): Element[]; getBBox(): g.Rect | null; getCellsBBox(cells: Cell[], opt?: Cell.EmbeddableOptions): g.Rect | null; hasActiveBatch(name?: string | string[]): boolean; maxZIndex(): number; minZIndex(): number; removeCells(cells: Cell[], opt?: Cell.DisconnectableOptions): this; resize(width: number, height: number, opt?: S): this; resizeCells(width: number, height: number, cells: Cell[], opt?: S): this; startBatch(name: string, data?: { [key: string]: any }): this; stopBatch(name: string, data?: { [key: string]: any }): this; toGraphLib(opt?: { [key: string]: any }): any; fromGraphLib(glGraph: any, opt?: { [key: string]: any }): this; } // dia.Cell export namespace Cell { type ID = string | number; interface GenericAttributes<T> { attrs?: T; z?: number; [key: string]: any; } interface Selectors { [selector: string]: attributes.SVGAttributes | undefined; } interface Attributes extends GenericAttributes<Selectors> { } type JSON<K extends Selectors = Selectors, T extends GenericAttributes<K> = GenericAttributes<K>> = T & { [attribute in keyof T]: T[attribute]; } & { id: ID; type: string; }; interface Constructor<T extends Backbone.Model> { new(opt?: { id?: ID, [key: string]: any }): T; define(type: string, defaults?: any, protoProps?: any, staticProps?: any): dia.Cell.Constructor<T>; } interface Options { [key: string]: any; } interface EmbeddableOptions<T = boolean> extends Options { deep?: T; } interface DisconnectableOptions extends Options { disconnectLinks?: boolean; } interface GetEmbeddedCellsOptions extends EmbeddableOptions { breadthFirst?: boolean; sortSiblings?: boolean; } interface ToFrontAndBackOptions extends GetEmbeddedCellsOptions { foregroundEmbeds?: boolean; } interface TransitionOptions extends Options { delay?: number; duration?: number; timingFunction?: util.timing.TimingFunction; valueFunction?: util.interpolate.InterpolateFunction<any>; } } class Cell<A extends ObjectHash = Cell.Attributes, S extends Backbone.ModelSetOptions = dia.ModelSetOptions> extends Backbone.Model<A, S> { constructor(attributes?: A, opt?: Graph.Options); id: Cell.ID; graph: Graph; markup: string | MarkupJSON; protected generateId(): string | number; protected stopPendingTransitions(path?: string, delim?: string): void; protected stopScheduledTransitions(path?: string, delim?: string): void; toJSON(): Cell.JSON<any, A>; remove(opt?: Cell.DisconnectableOptions): this; toFront(opt?: Cell.ToFrontAndBackOptions): this; toBack(opt?: Cell.ToFrontAndBackOptions): this; parent(): string; parent(parentId: Cell.ID): this; getParentCell(): Cell | null; getAncestors(): Cell[]; getEmbeddedCells(opt?: Cell.GetEmbeddedCellsOptions): Cell[]; isEmbeddedIn(cell: Cell, opt?: Cell.EmbeddableOptions): boolean; isEmbedded(): boolean; prop(key: Path): any; prop(object: Partial<A>, opt?: Cell.Options): this; prop(key: Path, value: any, opt?: Cell.Options): this; removeProp(path: Path, opt?: Cell.Options): this; attr(key?: Path): any; attr(object: Cell.Selectors, opt?: Cell.Options): this; attr(key: Path, value: any, opt?: Cell.Options): this; clone(): this; clone(opt: Cell.EmbeddableOptions<false>): this; clone(opt: Cell.EmbeddableOptions<true>): Cell[]; removeAttr(path: Path, opt?: Cell.Options): this; transition(path: string, value?: any, opt?: Cell.TransitionOptions, delim?: string): number; getTransitions(): string[]; stopTransitions(path?: string, delim?: string): this; embed(cell: Cell | Cell[], opt?: Graph.Options): this; unembed(cell: Cell | Cell[], opt?: Graph.Options): this; canEmbed(cell: Cell | Cell[]): boolean; addTo(graph: Graph, opt?: Graph.Options): this; findView(paper: Paper): CellView; isLink(): this is Link; isElement(): this is Element; startBatch(name: string, opt?: Graph.Options): this; stopBatch(name: string, opt?: Graph.Options): this; position(): g.Point; z(): number; angle(): number; getBBox(): g.Rect; getPointFromConnectedLink(link: dia.Link, endType: dia.LinkEnd): g.Point; getPointRotatedAroundCenter(angle: number, x: number, y: number): g.Point; getPointRotatedAroundCenter(angle: number, point: dia.Point): g.Point; getRelativePointFromAbsolute(x: number, y: number): g.Point; getRelativePointFromAbsolute(absolutePoint: dia.Point): g.Point; getAbsolutePointFromRelative(x: number, y: number): g.Point; getAbsolutePointFromRelative(relativePoint: dia.Point): g.Point; getChangeFlag(attributes: { [key: string]: number }): number; static define(type: string, defaults?: any, protoProps?: any, staticProps?: any): Cell.Constructor<Cell>; /** * @deprecated */ protected processPorts(): void; } // dia.Element export namespace Element { interface GenericAttributes<T> extends Cell.GenericAttributes<T> { markup?: string | MarkupJSON; position?: Point; size?: Size; angle?: number; ports?: { groups?: { [key: string]: PortGroup }; items?: Port[]; }; } interface Attributes extends GenericAttributes<Cell.Selectors> { } type PortPositionCallback = (ports: Port[], bbox: g.Rect) => dia.Point[]; interface PortPositionJSON { name?: string; args?: { [key: string]: any }; } type PositionType = string | PortPositionCallback | PortPositionJSON; interface PortGroup { position?: PositionType; markup?: string | MarkupJSON; attrs?: Cell.Selectors; label?: { markup?: string | MarkupJSON; position?: PositionType; }; } interface Port { id?: string; markup?: string | MarkupJSON; group?: string; attrs?: Cell.Selectors; args?: { [key: string]: any }; label?: { markup?: string | MarkupJSON; position?: PositionType; }; z?: number | 'auto'; } interface PortPosition extends Point { angle: number; } interface TranslateOptions extends Cell.Options { restrictedArea?: BBox | Paper.PointConstraintCallback; transition?: Cell.TransitionOptions; } interface PositionOptions extends TranslateOptions { parentRelative?: boolean; deep?: boolean; } interface BBoxOptions extends Cell.EmbeddableOptions { rotate?: boolean; } } class Element<A extends ObjectHash = Element.Attributes, S extends Backbone.ModelSetOptions = dia.ModelSetOptions> extends Cell<A, S> { translate(tx: number, ty?: number, opt?: Element.TranslateOptions): this; position(opt?: Element.PositionOptions): g.Point; position(x: number, y: number, opt?: Element.PositionOptions): this; size(): Size; size(width: number, height?: number, opt?: { direction?: Direction, [key: string]: any }): this; resize(width: number, height: number, opt?: { direction?: Direction, [key: string]: any }): this; rotate(deg: number, absolute?: boolean, origin?: Point, opt?: { [key: string]: any }): this; angle(): number; scale(scaleX: number, scaleY: number, origin?: Point, opt?: { [key: string]: any }): this; fitEmbeds(opt?: { deep?: boolean, padding?: Padding, expandOnly?: boolean, shrinkOnly?: boolean }): this; fitToChildren(opt?: { deep?: boolean, padding?: Padding, expandOnly?: boolean, shrinkOnly?: boolean }): this; fitParent(opt?: { deep?: boolean, padding?: Padding, expandOnly?: boolean, shrinkOnly?: boolean, terminator?: Cell | Cell.ID }): this; getBBox(opt?: Element.BBoxOptions): g.Rect; addPort(port: Element.Port, opt?: S): this; addPorts(ports: Element.Port[], opt?: S): this; insertPort(before: number | string | Element.Port, port: Element.Port, opt?: S): this; removePort(port: string | Element.Port, opt?: S): this; removePorts(opt?: S): this; removePorts(ports: Array<Element.Port | string>, opt?: S): this; hasPorts(): boolean; hasPort(id: string): boolean; getPorts(): Element.Port[]; getGroupPorts(groupName: string): Element.Port[]; getPort(id: string): Element.Port; getPortsPositions(groupName: string): { [id: string]: Element.PortPosition }; getPortIndex(port: string | Element.Port): number; portProp(portId: string, path: dia.Path): any; portProp(portId: string, path: dia.Path, value?: any, opt?: S): Element; protected generatePortId(): string | number; static define(type: string, defaults?: any, protoProps?: any, staticProps?: any): Cell.Constructor<Element>; } // dia.Link export namespace Link { interface EndCellArgs { magnet?: string; selector?: string; port?: string; anchor?: anchors.AnchorJSON; connectionPoint?: connectionPoints.ConnectionPointJSON; priority?: boolean; } interface EndJSON extends EndCellArgs { id?: Cell.ID; x?: number; y?: number; } interface GenericAttributes<T> extends Cell.GenericAttributes<T> { source?: EndJSON; target?: EndJSON; labels?: Label[]; vertices?: Point[]; manhattan?: boolean; router?: routers.Router | routers.RouterJSON; smooth?: boolean; connector?: connectors.Connector | connectors.ConnectorJSON; } interface LinkSelectors extends Cell.Selectors { '.connection'?: attributes.SVGPathAttributes; '.connection-wrap'?: attributes.SVGPathAttributes; '.marker-source'?: attributes.SVGPathAttributes; '.marker-target'?: attributes.SVGPathAttributes; '.labels'?: attributes.SVGAttributes; '.marker-vertices'?: attributes.SVGAttributes; '.marker-arrowheads'?: attributes.SVGAttributes; '.link-tools'?: attributes.SVGAttributes; } interface Attributes extends Cell.GenericAttributes<LinkSelectors> { } interface LabelPosition { distance?: number; // optional for default labels offset?: number | { x: number, y: number }; angle?: number; args?: LinkView.LabelOptions; } interface Label { markup?: string | MarkupJSON; position?: LabelPosition | number; // optional for default labels attrs?: Cell.Selectors; size?: Size; } interface Vertex extends Point { [key: string]: any; } } class Link<A extends ObjectHash = Link.Attributes, S extends Backbone.ModelSetOptions = dia.ModelSetOptions> extends Cell<A, S> { toolMarkup: string; doubleToolMarkup?: string; vertexMarkup: string; arrowHead