Skip to content

feat: TS type export (#682) #735

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Mar 21, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
68 changes: 38 additions & 30 deletions src/export.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,39 +10,47 @@ import * as pathTool from './tool/path';
import {parseSVG} from './tool/parseSVG';
import {morphPath} from './tool/morphPath';

export {default as Point} from './core/Point';
export {default as Point, PointLike} from './core/Point';

export {default as Element} from './Element';
export {
default as Element,
ElementAnimateConfig,
ElementTextConfig,
ElementTextGuideLineConfig,
ElementEvent,
ElementEventCallback,
ElementProps
} from './Element';

export {default as Group} from './graphic/Group';
export {default as Path} from './graphic/Path';
export {default as Image} from './graphic/Image';
export {default as CompoundPath} from './graphic/CompoundPath';
export {default as TSpan} from './graphic/TSpan';
export {default as Group, GroupProps} from './graphic/Group';
export {default as Path, PathStyleProps, PathProps, PathStatePropNames, PathState} from './graphic/Path';
export {default as Image, ImageStyleProps, ImageProps, ImageState} from './graphic/Image';
export {default as CompoundPath, CompoundPathShape} from './graphic/CompoundPath';
export {default as TSpan, TSpanStyleProps, TSpanProps, TSpanState} from './graphic/TSpan';
export {default as IncrementalDisplayable} from './graphic/IncrementalDisplayable';
export {default as Text} from './graphic/Text';

export {default as Arc} from './graphic/shape/Arc';
export {default as BezierCurve} from './graphic/shape/BezierCurve';
export {default as Circle} from './graphic/shape/Circle';
export {default as Droplet} from './graphic/shape/Droplet';
export {default as Ellipse} from './graphic/shape/Ellipse';
export {default as Heart} from './graphic/shape/Heart';
export {default as Isogon} from './graphic/shape/Isogon';
export {default as Line} from './graphic/shape/Line';
export {default as Polygon} from './graphic/shape/Polygon';
export {default as Polyline} from './graphic/shape/Polyline';
export {default as Rect} from './graphic/shape/Rect';
export {default as Ring} from './graphic/shape/Ring';
export {default as Rose} from './graphic/shape/Rose';
export {default as Sector} from './graphic/shape/Sector';
export {default as Star} from './graphic/shape/Star';
export {default as Trochoid} from './graphic/shape/Trochoid';

export {default as LinearGradient} from './graphic/LinearGradient';
export {default as RadialGradient} from './graphic/RadialGradient';
export {default as Pattern} from './graphic/Pattern';
export {default as BoundingRect} from './core/BoundingRect';
export {default as Text, TextStylePropsPart, TextStyleProps, TextProps, TextState} from './graphic/Text';

export {default as Arc, ArcProps, ArcShape} from './graphic/shape/Arc';
export {default as BezierCurve, BezierCurveProps, BezierCurveShape} from './graphic/shape/BezierCurve';
export {default as Circle, CircleProps, CircleShape} from './graphic/shape/Circle';
export {default as Droplet, DropletProps, DropletShape} from './graphic/shape/Droplet';
export {default as Ellipse, EllipseProps, EllipseShape} from './graphic/shape/Ellipse';
export {default as Heart, HeartProps, HeartShape} from './graphic/shape/Heart';
export {default as Isogon, IsogonProps, IsogonShape} from './graphic/shape/Isogon';
export {default as Line, LineProps, LineShape} from './graphic/shape/Line';
export {default as Polygon, PolygonProps, PolygonShape} from './graphic/shape/Polygon';
export {default as Polyline, PolylineProps, PolylineShape} from './graphic/shape/Polyline';
export {default as Rect, RectProps, RectShape} from './graphic/shape/Rect';
export {default as Ring, RingProps, RingShape} from './graphic/shape/Ring';
export {default as Rose, RoseProps, RoseShape} from './graphic/shape/Rose';
export {default as Sector, SectorProps, SectorShape} from './graphic/shape/Sector';
export {default as Star, StarProps, StarShape} from './graphic/shape/Star';
export {default as Trochoid, TrochoidProps, TrochoidShape} from './graphic/shape/Trochoid';

export {default as LinearGradient, LinearGradientObject} from './graphic/LinearGradient';
export {default as RadialGradient, RadialGradientObject} from './graphic/RadialGradient';
export {default as Pattern, PatternObject} from './graphic/Pattern';
export {default as BoundingRect, RectLike} from './core/BoundingRect';
export {default as OrientedBoundingRect} from './core/OrientedBoundingRect';

export {matrix};
Expand Down
2 changes: 1 addition & 1 deletion src/graphic/CompoundPath.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import Path from './Path';
import PathProxy from '../core/PathProxy';

interface CompoundPathShape {
export interface CompoundPathShape {
paths: Path[]
}

Expand Down
2 changes: 1 addition & 1 deletion src/graphic/Image.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ export const DEFAULT_IMAGE_ANIMATION_PROPS: MapToType<ImageProps, boolean> = {
}, DEFAULT_COMMON_ANIMATION_PROPS.style)
};

interface ImageProps extends DisplayableProps {
export interface ImageProps extends DisplayableProps {
style?: ImageStyleProps

onload?: (image: ImageLike) => void
Expand Down
2 changes: 1 addition & 1 deletion src/graphic/TSpan.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export const DEFAULT_TSPAN_STYLE: TSpanStyleProps = defaults({
} as TSpanStyleProps, DEFAULT_PATH_STYLE);


interface TSpanProps extends DisplayableProps {
export interface TSpanProps extends DisplayableProps {
style?: TSpanStyleProps
}

Expand Down
4 changes: 2 additions & 2 deletions src/graphic/shape/Arc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

import Path, { PathProps } from '../Path';

class ArcShape {
export class ArcShape {
cx = 0;
cy = 0;
r = 0;
Expand All @@ -13,7 +13,7 @@ class ArcShape {
clockwise? = true
}

interface ArcProps extends PathProps {
export interface ArcProps extends PathProps {
shape?: Partial<ArcShape>
}

Expand Down
4 changes: 2 additions & 2 deletions src/graphic/shape/BezierCurve.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import {

const out: number[] = [];

class BezierCurveShape {
export class BezierCurveShape {
x1 = 0
y1 = 0
x2 = 0
Expand Down Expand Up @@ -45,7 +45,7 @@ function someVectorAt(shape: BezierCurveShape, t: number, isTangent: boolean) {
}
}

interface BezierCurveProps extends PathProps {
export interface BezierCurveProps extends PathProps {
shape?: Partial<BezierCurveShape>
}
class BezierCurve extends Path<BezierCurveProps> {
Expand Down
4 changes: 2 additions & 2 deletions src/graphic/shape/Circle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@

import Path, { PathProps } from '../Path';

class CircleShape {
export class CircleShape {
cx = 0
cy = 0
r = 0
}

interface CircleProps extends PathProps {
export interface CircleProps extends PathProps {
shape?: Partial<CircleShape>
}
class Circle extends Path<CircleProps> {
Expand Down
4 changes: 2 additions & 2 deletions src/graphic/shape/Droplet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@

import Path, { PathProps } from '../Path';

class DropletShape {
export class DropletShape {
cx = 0
cy = 0
width = 0
height = 0
}

interface DropletProps extends PathProps {
export interface DropletProps extends PathProps {
shape?: Partial<DropletShape>
}
class Droplet extends Path<DropletProps> {
Expand Down
4 changes: 2 additions & 2 deletions src/graphic/shape/Ellipse.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@

import Path, { PathProps } from '../Path';

class EllipseShape {
export class EllipseShape {
cx = 0
cy = 0
rx = 0
ry = 0
}

interface EllipseProps extends PathProps {
export interface EllipseProps extends PathProps {
shape?: Partial<EllipseShape>
}
class Ellipse extends Path<EllipseProps> {
Expand Down
4 changes: 2 additions & 2 deletions src/graphic/shape/Heart.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@

import Path, { PathProps } from '../Path';

class HeartShape {
export class HeartShape {
cx = 0
cy = 0
width = 0
height = 0
}

interface HeartProps extends PathProps {
export interface HeartProps extends PathProps {
shape?: Partial<HeartShape>
}
class Heart extends Path<HeartProps> {
Expand Down
4 changes: 2 additions & 2 deletions src/graphic/shape/Isogon.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@ const PI = Math.PI;
const sin = Math.sin;
const cos = Math.cos;

class IsogonShape {
export class IsogonShape {
x = 0
y = 0
r = 0
n = 0
}

interface IsogonProps extends PathProps {
export interface IsogonProps extends PathProps {
shape?: Partial<IsogonShape>
}
class Isogon extends Path<IsogonProps> {
Expand Down
5 changes: 2 additions & 3 deletions src/graphic/shape/Line.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,12 @@

import Path, { PathProps } from '../Path';
import {subPixelOptimizeLine} from '../helper/subPixelOptimize';
import PathProxy from '../../core/PathProxy';
import { VectorArray } from '../../core/vector';

// Avoid create repeatly.
const subPixelOptimizeOutputShape = {};

class LineShape {
export class LineShape {
// Start point
x1 = 0
y1 = 0
Expand All @@ -22,7 +21,7 @@ class LineShape {
percent = 1
}

interface LineProps extends PathProps {
export interface LineProps extends PathProps {
shape?: Partial<LineShape>
}
class Line extends Path<LineProps> {
Expand Down
4 changes: 2 additions & 2 deletions src/graphic/shape/Polygon.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@ import Path, { PathProps } from '../Path';
import * as polyHelper from '../helper/poly';
import { VectorArray } from '../../core/vector';

class PolygonShape {
export class PolygonShape {
points: VectorArray[] = null
smooth?: number | 'spline' = 0
smoothConstraint?: VectorArray[] = null
}

interface PolygonProps extends PathProps {
export interface PolygonProps extends PathProps {
shape?: Partial<PolygonShape>
}
class Polygon extends Path<PolygonProps> {
Expand Down
4 changes: 2 additions & 2 deletions src/graphic/shape/Polyline.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@ import Path, { PathProps } from '../Path';
import * as polyHelper from '../helper/poly';
import { VectorArray } from '../../core/vector';

class PolylineShape {
export class PolylineShape {
points: VectorArray[] = null
// Percent of displayed polyline. For animating purpose
percent?: number = 1
smooth?: number | 'spline' = 0
smoothConstraint?: VectorArray[] = null
}

interface PolylineProps extends PathProps {
export interface PolylineProps extends PathProps {
shape?: Partial<PolylineShape>
}
class Polyline extends Path<PolylineProps> {
Expand Down
4 changes: 2 additions & 2 deletions src/graphic/shape/Rect.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import Path, { PathProps } from '../Path';
import * as roundRectHelper from '../helper/roundRect';
import {subPixelOptimizeRect} from '../helper/subPixelOptimize';

class RectShape {
export class RectShape {
// 左上、右上、右下、左下角的半径依次为r1、r2、r3、r4
// r缩写为1 相当于 [1, 1, 1, 1]
// r缩写为[1] 相当于 [1, 1, 1, 1]
Expand All @@ -21,7 +21,7 @@ class RectShape {
height = 0
}

interface RectProps extends PathProps {
export interface RectProps extends PathProps {
shape?: Partial<RectShape>
}
// Avoid create repeatly.
Expand Down
4 changes: 2 additions & 2 deletions src/graphic/shape/Ring.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@

import Path, { PathProps } from '../Path';

class RingShape {
export class RingShape {
cx = 0
cy = 0
r = 0
r0 = 0
}

interface RingProps extends PathProps {
export interface RingProps extends PathProps {
shape?: Partial<RingShape>
}
class Ring extends Path<RingProps> {
Expand Down
4 changes: 2 additions & 2 deletions src/graphic/shape/Rose.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@ const sin = Math.sin;
const cos = Math.cos;
const radian = Math.PI / 180;

class RoseShape {
export class RoseShape {
cx = 0
cy = 0
r: number[] = []
k = 0
n = 1
}

interface RoseProps extends PathProps {
export interface RoseProps extends PathProps {
shape?: Partial<RoseShape>
}
class Rose extends Path<RoseProps> {
Expand Down
4 changes: 2 additions & 2 deletions src/graphic/shape/Sector.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import Path, { PathProps } from '../Path';
import * as roundSectorHelper from '../helper/roundSector';

class SectorShape {
export class SectorShape {
cx = 0
cy = 0
r0 = 0
Expand All @@ -13,7 +13,7 @@ class SectorShape {
innerCornerRadius = 0
}

interface SectorProps extends PathProps {
export interface SectorProps extends PathProps {
shape?: Partial<SectorShape>
}

Expand Down
4 changes: 2 additions & 2 deletions src/graphic/shape/Star.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@ const PI = Math.PI;
const cos = Math.cos;
const sin = Math.sin;

class StarShape {
export class StarShape {
cx = 0
cy = 0
n = 3
r0: number
r = 0
}

interface StarProps extends PathProps {
export interface StarProps extends PathProps {
shape?: Partial<StarShape>
}
class Star extends Path<StarProps> {
Expand Down
4 changes: 2 additions & 2 deletions src/graphic/shape/Trochoid.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import Path, { PathProps } from '../Path';
const cos = Math.cos;
const sin = Math.sin;

class TrochoidShape {
export class TrochoidShape {
cx = 0
cy = 0
r = 0
Expand All @@ -17,7 +17,7 @@ class TrochoidShape {
location = 'out'
}

interface TrochoidProps extends PathProps {
export interface TrochoidProps extends PathProps {
shape?: Partial<TrochoidShape>
}
class Trochoid extends Path<TrochoidProps> {
Expand Down