Skip to content

Commit

Permalink
feat: TypeScript type definition (#23)
Browse files Browse the repository at this point in the history
  • Loading branch information
Means88 authored and dbanksdesign committed Jun 11, 2019
1 parent b105a25 commit 43312fc
Show file tree
Hide file tree
Showing 37 changed files with 830 additions and 36 deletions.
48 changes: 14 additions & 34 deletions __examples__/building-from-scratch/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export * from './models';
export * from './utils';
20 changes: 20 additions & 0 deletions models/Artboard/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import Color from '../Color';
import Group from '../Group';
import RulerData from '../RulerData';

declare class Artboard extends Group {
_class: 'artboard';
shouldBreakMaskChain: boolean;
backgroundColor: Color;
hasBackgroundColor: boolean;
horizontalRulerData: RulerData;
verticalRulerData: RulerData;
includeBackgroundColorInExport: boolean;
includeInCloudUpload: boolean;
isFlowHome: boolean;
resizesContent: boolean;

constructor(args?: any, json?: any);
}

export = Artboard;
11 changes: 11 additions & 0 deletions models/AttributedString/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import StringAttribute from '../StringAttribute';

declare class AttributedString {
_class: 'attributedString';
string: string;
attributes: StringAttribute[];

constructor(args?: any, json?: any);
}

export = AttributedString;
20 changes: 20 additions & 0 deletions models/Border/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import Color from '../Color';

declare class Border {
static Position: {
Inside: 1;
Center: 0;
Outside: 2;
};

constructor(args?: any, json?: any);

_class: 'border';
isEnabled: boolean;
color: Color;
fillType: number;
position: 0 | 1 | 2;
thickness: number;
}

export = Border;
23 changes: 23 additions & 0 deletions models/BorderOptions/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
declare class BorderOptions {
static LineCapStyle: {
butt: 0;
round: 1;
projecting: 2;
};

static LineJoinStyle: {
miter: 0;
round: 1;
bevel: 2;
};

constructor(args?: any, json?: any);

_class: 'borderOptions';
isEnabled: boolean;
dashPattern: number[];
lineCapStyle: 0 | 1 | 2;
lineJoinStyle: 0 | 1 | 2;
}

export = BorderOptions;
17 changes: 17 additions & 0 deletions models/Color/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import TinyColor from 'tinycolor2';

declare class Color {
_class: 'color';
alpha: number;
blue: number;
green: number;
red: number;

constructor(args?: any, json?: any);

set(tinyColor: TinyColor.Instance): Color;

_getTinyColor(): TinyColor.Instance;
}

export = Color;
14 changes: 14 additions & 0 deletions models/CurvePoint/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
declare class CurvePoint {
_class: 'curvePoint';
cornerRadius: number;
curveFrom: string;
curveTo: string;
hasCurveFrom: boolean;
hasCurveTo: boolean;
point: string;

constructor(args?: any, json?: any);

}

export = CurvePoint;
52 changes: 52 additions & 0 deletions models/Document/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
import Color from '../Color';
import Page from '../Page';
import SharedStyle from '../SharedStyle';

declare class Document {
_class: 'document';
do_objectID: string;
assets: {
_class: 'assetCollection';
colors: Color[];
gradients: any[]; // TODO
imageCollections: {
_class: 'imageCollection';
images: any; // TODO
},
images: any[]; // TODO
};
colorSpace: number;
currentPageIndex: number;
foreignLayerStyles: SharedStyle[];
foreignSymbols: any[]; // TODO
foreignTextStyles: SharedStyle[];
layerStyles: {
_class: 'sharedStyleContainer';
objects: SharedStyle[];
};
layerSymbols: {
_class: 'symbolContainer';
objects: any[]; // TODO
};
layerTextStyles: {
_class: 'sharedTextStyleContainer';
objects: SharedStyle[];
};
pages: Page[];

constructor(args?: any, json?: any);

getLayerStyles(): SharedStyle[];

getLayerStyle(name: string): SharedStyle | undefined;

addLayerStyle(style: SharedStyle): Document;

getTextStyles(): SharedStyle[];

addTextStyle(style: SharedStyle): Document;

addPage(pageID: string): Document;
}

export = Document;
13 changes: 13 additions & 0 deletions models/ExportFormat/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
declare class ExportFormat {
_class: 'exportFormat';
absoluteSize: number;
fileFormat: string;
name: string;
nameScheme: number;
scale: number;
visibleScaleType: number;

constructor(args?: any, json?: any);
}

export = ExportFormat;
12 changes: 12 additions & 0 deletions models/ExportOptions/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import ExportFormat from '../ExportFormat';

declare class ExportOptions {
_class: 'exportOptions';
exportFormats: ExportFormat[];
includedLayerIds: string[];
layerOptions: number;
shouldTrim: boolean;
constructor(args?: any, json?: any);
}

export = ExportOptions;
25 changes: 25 additions & 0 deletions models/Fill/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import Color from '../Color';
import Gradient from '../Gradient';

declare class Fill {
static FillType: {
Color: 0,
Gradient: 1,
Pattrern: 4,
Noise: 5,
};

_class: 'fill';
isEnabled: boolean;
color: Color;
fillType: 0 | 1 | 4 | 5;
noiseIndex: number;
noiseIntensity: number;
patternFillType: number;
patternTileScale: number;
gradient: Gradient;

constructor(args?: any, json?: any);
}

export = Fill;
26 changes: 26 additions & 0 deletions models/Gradient/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import Color from '../Color';

declare class Gradient {
static GradientStop: {
_class: 'gradientStop';
color: Color;
position: number;
}

static GradientType: {
Linear: 0;
Radial: 1;
Angular: 2;
}

_class: 'gradient';
elipseLength: number;
from: string;
to: string;
gradientType: number;
stops: Array<typeof Gradient.GradientStop>;

constructor(args?: any, json?: any);
}

export = Gradient;
Loading

0 comments on commit 43312fc

Please sign in to comment.