From d90a8531a6b1720e7191048bedceef1f4e053af7 Mon Sep 17 00:00:00 2001 From: Chris Moran Date: Wed, 15 Feb 2017 14:49:44 -0500 Subject: [PATCH 1/2] Add type definitions for all classes in the shapes namespace for JointJS. --- jointjs/index.d.ts | 293 ++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 287 insertions(+), 6 deletions(-) diff --git a/jointjs/index.d.ts b/jointjs/index.d.ts index aec9f1237d..e9f6117be3 100644 --- a/jointjs/index.d.ts +++ b/jointjs/index.d.ts @@ -1,6 +1,6 @@ // Type definitions for Joint JS 1.0.1 // Project: http://www.jointjs.com/ -// Definitions by: Aidan Reel , David Durman , Ewout Van Gossum , Federico Caselli +// Definitions by: Aidan Reel , David Durman , Ewout Van Gossum , Federico Caselli , Chris Moran // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // typings: https://github.com/CaselIT/typings-jointjs @@ -188,6 +188,7 @@ declare namespace joint { vertices?: Point[]; smooth?: boolean; attrs?: TextAttrs; + z?: number; } class Link extends Cell { @@ -249,6 +250,7 @@ declare namespace joint { cellViewNamespace?: Object; /** useful undocumented option */ clickThreshold?: number; + highlighting?: any; } interface ScaleContentOptions { @@ -466,7 +468,14 @@ declare namespace joint { cy?: string | number; height?: string | number; width?: string | number; + transform?: string; + points?: string; + 'stroke-width'?: string | number; + 'ref-x'?: string | number; + 'ref-y'?: string | number; + ref?: string } + namespace basic { class Generic extends dia.Element { constructor(attributes?: GenericAttributes, options?: Object) @@ -492,14 +501,286 @@ declare namespace joint { class Ellipse extends Generic { constructor(attributes?: GenericAttributes, options?: Object) } - class Image extends Generic { - } - class Path extends Generic { + interface PolygonAttrs extends dia.TextAttrs { + polygon?: ShapeAttrs; } class Polygon extends Generic { + constructor(attributes?: GenericAttributes, options?: Object) + } + interface PolylineAttrs extends dia.TextAttrs { + polyline?: ShapeAttrs; } class Polyline extends Generic { } + class Image extends Generic { + constructor(attributes?: GenericAttributes, options?: Object) + } + interface PathAttrs extends dia.TextAttrs { + path?: ShapeAttrs; + } + class Path extends Generic { + constructor(attributes?: GenericAttributes, options?: Object) + } + interface RhombusAttrs extends dia.TextAttrs { + path?: ShapeAttrs + } + class Rhombus extends Generic { + constructor(attributes?: GenericAttributes, options?: Object) + } + interface TextBlockAttrs extends dia.TextAttrs { + rect?: ShapeAttrs; + } + class TextBlock extends Generic { + constructor(attributes?: GenericAttributes, options?: Object) + updateSize(cell: dia.Cell, size: dia.Size): void; + updateContent(cell: dia.Cell, content: string): void; + } + } + + namespace chess { + class KingWhite extends basic.Generic { + } + class KingBlack extends basic.Generic { + } + class QueenWhite extends basic.Generic { + } + class QueenBlack extends basic.Generic { + } + class RookWhite extends basic.Generic { + } + class RookBlack extends basic.Generic { + } + class BishopWhite extends basic.Generic { + } + class BishopBlack extends basic.Generic { + } + class KnightWhite extends basic.Generic { + } + class KnightBlack extends basic.Generic { + } + class PawnWhite extends basic.Generic { + } + class PawnBlack extends basic.Generic { + } + } + + namespace devs { + interface ModelAttributes extends GenericAttributes { + inPorts?: string[]; + outPorts?: string[]; + ports?: Object; + } + class Model extends basic.Generic { + constructor(attributes?: ModelAttributes, options?: Object); + changeInGroup(properties: any, opt?: Object): boolean; + changeOutGroup(properties: any, opt?: Object): boolean; + createPortItem(group: string, port: string): Object; + createPortItems(group: string, ports: string[]): Object[]; + addOutPort(port: string, opt?: Object): this; + addInPort(port: string, opt?: Object): this; + removeOutPort(port: string, opt?: Object): this; + removeInPort(port: string, opt?: Object): this; + } + class Coupled extends Model { + } + class Atomic extends Model { + } + class Link extends dia.Link { + } + } + + namespace erd { + class Entity extends basic.Generic { + constructor(attributes?: GenericAttributes, options?: Object) + } + class WeakEntity extends Entity { + } + class Relationship extends dia.Element { + constructor(attributes?: GenericAttributes, options?: Object) + } + class IdentifyingRelationship extends Relationship { + } + interface AttributeAttrs extends dia.TextAttrs { + ellipse?: ShapeAttrs + } + class Attribute extends dia.Element { + constructor(attributes?: GenericAttributes, options?: Object) + } + class Multivalued extends Attribute { + } + class Derived extends Attribute { + } + class Key extends Attribute { + } + class Normal extends Attribute { + } + interface ISAAttrs extends dia.Element { + polygon?: ShapeAttrs + } + class ISA extends dia.Element { + constructor(attributes?: GenericAttributes, options?: Object) + } + class Line extends dia.Link { + cardinality(value: string | number): void + } + } + + namespace fsa { + class State extends basic.Circle { + } + class StartState extends dia.Element { + constructor(attributes?: GenericAttributes, options?: Object) + } + class EndState extends dia.Element { + } + class Arrow extends dia.Link { + } + } + + namespace logic { + interface LogicAttrs extends ShapeAttrs { + ref?: string; + 'ref-x'?: number | string; + 'ref-dx'?: number | string; + 'ref-y'?: number | string; + 'ref-dy'?: number | string; + magnet?: boolean; + 'class'?: string; + port?: string; + } + interface IOAttrs extends dia.TextAttrs { + circle?: LogicAttrs; + } + class Gate extends basic.Generic { + constructor(attributes?: GenericAttributes, options?: Object) + } + class IO extends Gate { + } + class Input extends IO { + } + class Output extends IO { + } + class Gate11 extends Gate { + } + class Gate21 extends Gate { + } + interface Image { + 'xlink:href'?: string; + } + interface ImageAttrs extends LogicAttrs { + image?: Image; + } + class Repeater extends Gate11 { + constructor(attributes?: GenericAttributes, options?: Object) + operation(input: any): any; + } + class Note extends Gate11 { + constructor(attributes?: GenericAttributes, options?: Object) + operation(input: any): boolean; + } + class Or extends Gate21 { + constructor(attributes?: GenericAttributes, options?: Object) + operation(input1: any, input2: any): boolean; + } + class And extends Gate21 { + constructor(attributes?: GenericAttributes, options?: Object) + operation(input1: any, input2: any): boolean; + } + class Nor extends Gate21 { + constructor(attributes?: GenericAttributes, options?: Object) + operation(input1: any, input2: any): boolean; + } + class Nand extends Gate21 { + constructor(attributes?: GenericAttributes, options?: Object) + operation(input1: any, input2: any): boolean; + } + class Xor extends Gate21 { + constructor(attributes?: GenericAttributes, options?: Object) + operation(input1: any, input2: any): boolean; + } + class Xnor extends Gate21 { + constructor(attributes?: GenericAttributes, options?: Object) + operation(input1: any, input2: any): boolean; + } + interface WireArgs extends dia.LinkAttributes { + router?: Object; + connector?: Object; + } + class Wire extends dia.Link { + constructor(attributes?: WireArgs, options?: Object) + } + } + + namespace org { + interface MemberAttrs { + rect?: ShapeAttrs + image?: ShapeAttrs + } + class Member extends dia.Element { + constructor(attributes?: GenericAttributes, options?: Object) + } + class Arrow extends dia.Link { + } + } + + namespace pn { + class Place extends basic.Generic { + } + class PlaceView extends dia.ElementView { + renderTokens(): void; + } + class Transition extends basic.Generic { + constructor(attributes?: GenericAttributes, options?: Object) + } + class Link extends dia.Link { + } + } + + namespace uml { + interface ClassAttributes extends GenericAttributes { + name: string[]; + attributes: string[]; + methods: string[]; + } + class Class extends basic.Generic { + constructor(attributes?: ClassAttributes, options?: Object) + getClassName(): string[]; + updateRectangles(): void; + } + class ClassView extends dia.ElementView { + } + class Abstract extends Class { + } + class AbstractView extends ClassView { + } + class Interface extends Class { + } + class InterfaceView extends ClassView { + } + class Generalization extends dia.Link { + } + class Implementation extends dia.Link { + } + class Aggregation extends dia.Link { + } + class Composition extends dia.Link { + } + class Association extends dia.Link { + } + interface StateAttributes extends GenericAttributes { + events?: string[] + } + class State extends basic.Generic { + updateName(): void; + updateEvents(): void; + updatePath(): void; + } + class StartState extends basic.Circle { + } + class EndState extends basic.Generic { + } + class Transition extends dia.Link { + } } } @@ -553,7 +834,7 @@ declare namespace joint { } class DirectedGraph { - static layout(graph: dia.Graph, options?: LayoutOptions): dia.BBox; + static layout(graph: dia.Graph | dia.Cell[], options?: LayoutOptions): dia.BBox; } } -} \ No newline at end of file +} From cfb7872755f562ffaef33683241447765fe03837 Mon Sep 17 00:00:00 2001 From: Chris Moran Date: Thu, 16 Feb 2017 09:35:05 -0500 Subject: [PATCH 2/2] Remove use of Object in new method definitions, in favor of any. Add missing semicolons. --- jointjs/index.d.ts | 86 +++++++++++++++++++++++----------------------- 1 file changed, 43 insertions(+), 43 deletions(-) diff --git a/jointjs/index.d.ts b/jointjs/index.d.ts index e9f6117be3..c8ef9ae302 100644 --- a/jointjs/index.d.ts +++ b/jointjs/index.d.ts @@ -478,34 +478,34 @@ declare namespace joint { namespace basic { class Generic extends dia.Element { - constructor(attributes?: GenericAttributes, options?: Object) + constructor(attributes?: GenericAttributes, options?: Object); } interface RectAttrs extends dia.TextAttrs { rect?: ShapeAttrs; } class Rect extends Generic { - constructor(attributes?: GenericAttributes, options?: Object) + constructor(attributes?: GenericAttributes, options?: Object); } class Text extends Generic { - constructor(attributes?: GenericAttributes, options?: Object) + constructor(attributes?: GenericAttributes, options?: Object); } interface CircleAttrs extends dia.TextAttrs { circle?: ShapeAttrs; } class Circle extends Generic { - constructor(attributes?: GenericAttributes, options?: Object) + constructor(attributes?: GenericAttributes, options?: Object); } interface EllipseAttrs extends dia.TextAttrs { ellipse?: ShapeAttrs; } class Ellipse extends Generic { - constructor(attributes?: GenericAttributes, options?: Object) + constructor(attributes?: GenericAttributes, options?: Object); } interface PolygonAttrs extends dia.TextAttrs { polygon?: ShapeAttrs; } class Polygon extends Generic { - constructor(attributes?: GenericAttributes, options?: Object) + constructor(attributes?: GenericAttributes, options?: Object); } interface PolylineAttrs extends dia.TextAttrs { polyline?: ShapeAttrs; @@ -513,25 +513,25 @@ declare namespace joint { class Polyline extends Generic { } class Image extends Generic { - constructor(attributes?: GenericAttributes, options?: Object) + constructor(attributes?: GenericAttributes, options?: Object); } interface PathAttrs extends dia.TextAttrs { path?: ShapeAttrs; } class Path extends Generic { - constructor(attributes?: GenericAttributes, options?: Object) + constructor(attributes?: GenericAttributes, options?: Object); } interface RhombusAttrs extends dia.TextAttrs { - path?: ShapeAttrs + path?: ShapeAttrs; } class Rhombus extends Generic { - constructor(attributes?: GenericAttributes, options?: Object) + constructor(attributes?: GenericAttributes, options?: Object); } interface TextBlockAttrs extends dia.TextAttrs { rect?: ShapeAttrs; } class TextBlock extends Generic { - constructor(attributes?: GenericAttributes, options?: Object) + constructor(attributes?: GenericAttributes, options?: Object); updateSize(cell: dia.Cell, size: dia.Size): void; updateContent(cell: dia.Cell, content: string): void; } @@ -572,14 +572,14 @@ declare namespace joint { } class Model extends basic.Generic { constructor(attributes?: ModelAttributes, options?: Object); - changeInGroup(properties: any, opt?: Object): boolean; - changeOutGroup(properties: any, opt?: Object): boolean; - createPortItem(group: string, port: string): Object; - createPortItems(group: string, ports: string[]): Object[]; - addOutPort(port: string, opt?: Object): this; - addInPort(port: string, opt?: Object): this; - removeOutPort(port: string, opt?: Object): this; - removeInPort(port: string, opt?: Object): this; + changeInGroup(properties: any, opt?: any): boolean; + changeOutGroup(properties: any, opt?: any): boolean; + createPortItem(group: string, port: string): any; + createPortItems(group: string, ports: string[]): any[]; + addOutPort(port: string, opt?: any): this; + addInPort(port: string, opt?: any): this; + removeOutPort(port: string, opt?: any): this; + removeInPort(port: string, opt?: any): this; } class Coupled extends Model { } @@ -591,20 +591,20 @@ declare namespace joint { namespace erd { class Entity extends basic.Generic { - constructor(attributes?: GenericAttributes, options?: Object) + constructor(attributes?: GenericAttributes, options?: Object); } class WeakEntity extends Entity { } class Relationship extends dia.Element { - constructor(attributes?: GenericAttributes, options?: Object) + constructor(attributes?: GenericAttributes, options?: Object); } class IdentifyingRelationship extends Relationship { } interface AttributeAttrs extends dia.TextAttrs { - ellipse?: ShapeAttrs + ellipse?: ShapeAttrs; } class Attribute extends dia.Element { - constructor(attributes?: GenericAttributes, options?: Object) + constructor(attributes?: GenericAttributes, options?: Object); } class Multivalued extends Attribute { } @@ -615,13 +615,13 @@ declare namespace joint { class Normal extends Attribute { } interface ISAAttrs extends dia.Element { - polygon?: ShapeAttrs + polygon?: ShapeAttrs; } class ISA extends dia.Element { - constructor(attributes?: GenericAttributes, options?: Object) + constructor(attributes?: GenericAttributes, options?: Object); } class Line extends dia.Link { - cardinality(value: string | number): void + cardinality(value: string | number): void; } } @@ -629,7 +629,7 @@ declare namespace joint { class State extends basic.Circle { } class StartState extends dia.Element { - constructor(attributes?: GenericAttributes, options?: Object) + constructor(attributes?: GenericAttributes, options?: Object); } class EndState extends dia.Element { } @@ -652,7 +652,7 @@ declare namespace joint { circle?: LogicAttrs; } class Gate extends basic.Generic { - constructor(attributes?: GenericAttributes, options?: Object) + constructor(attributes?: GenericAttributes, options?: Object); } class IO extends Gate { } @@ -671,35 +671,35 @@ declare namespace joint { image?: Image; } class Repeater extends Gate11 { - constructor(attributes?: GenericAttributes, options?: Object) + constructor(attributes?: GenericAttributes, options?: Object); operation(input: any): any; } class Note extends Gate11 { - constructor(attributes?: GenericAttributes, options?: Object) + constructor(attributes?: GenericAttributes, options?: Object); operation(input: any): boolean; } class Or extends Gate21 { - constructor(attributes?: GenericAttributes, options?: Object) + constructor(attributes?: GenericAttributes, options?: Object); operation(input1: any, input2: any): boolean; } class And extends Gate21 { - constructor(attributes?: GenericAttributes, options?: Object) + constructor(attributes?: GenericAttributes, options?: Object); operation(input1: any, input2: any): boolean; } class Nor extends Gate21 { - constructor(attributes?: GenericAttributes, options?: Object) + constructor(attributes?: GenericAttributes, options?: Object); operation(input1: any, input2: any): boolean; } class Nand extends Gate21 { - constructor(attributes?: GenericAttributes, options?: Object) + constructor(attributes?: GenericAttributes, options?: Object); operation(input1: any, input2: any): boolean; } class Xor extends Gate21 { - constructor(attributes?: GenericAttributes, options?: Object) + constructor(attributes?: GenericAttributes, options?: Object); operation(input1: any, input2: any): boolean; } class Xnor extends Gate21 { - constructor(attributes?: GenericAttributes, options?: Object) + constructor(attributes?: GenericAttributes, options?: Object); operation(input1: any, input2: any): boolean; } interface WireArgs extends dia.LinkAttributes { @@ -707,17 +707,17 @@ declare namespace joint { connector?: Object; } class Wire extends dia.Link { - constructor(attributes?: WireArgs, options?: Object) + constructor(attributes?: WireArgs, options?: Object); } } namespace org { interface MemberAttrs { - rect?: ShapeAttrs - image?: ShapeAttrs + rect?: ShapeAttrs; + image?: ShapeAttrs; } class Member extends dia.Element { - constructor(attributes?: GenericAttributes, options?: Object) + constructor(attributes?: GenericAttributes, options?: Object); } class Arrow extends dia.Link { } @@ -730,7 +730,7 @@ declare namespace joint { renderTokens(): void; } class Transition extends basic.Generic { - constructor(attributes?: GenericAttributes, options?: Object) + constructor(attributes?: GenericAttributes, options?: Object); } class Link extends dia.Link { } @@ -743,7 +743,7 @@ declare namespace joint { methods: string[]; } class Class extends basic.Generic { - constructor(attributes?: ClassAttributes, options?: Object) + constructor(attributes?: ClassAttributes, options?: Object); getClassName(): string[]; updateRectangles(): void; } @@ -768,7 +768,7 @@ declare namespace joint { class Association extends dia.Link { } interface StateAttributes extends GenericAttributes { - events?: string[] + events?: string[]; } class State extends basic.Generic { updateName(): void;