@idraw/util 0.2.0-y.0 → 0.3.0-alpha.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -1,77 +1,222 @@
1
- declare function compose(middleware: Middleware[]): (context: any, next?: Middleware) => any;
1
+ import { TypeBoardSizeOptions } from '@idraw/types';
2
+ import { TypeContext } from '@idraw/types';
2
3
 
3
- declare function createUUID(): string;
4
+ declare function angle(value: any): boolean;
4
5
 
5
- declare function deepClone(target: any): any;
6
+ declare function attrs(attrs: any): boolean;
6
7
 
7
- declare const _default: {
8
- time: {
9
- delay: typeof delay;
10
- compose: typeof compose;
11
- throttle: typeof throttle;
12
- };
13
- loader: {
14
- loadImage: typeof loadImage;
15
- loadSVG: typeof loadSVG;
16
- loadHTML: typeof loadHTML;
17
- };
18
- file: {
19
- downloadImageFromCanvas: typeof downloadImageFromCanvas;
20
- };
21
- color: {
22
- toColorHexStr: typeof toColorHexStr;
23
- toColorHexNum: typeof toColorHexNum;
24
- isColorStr: typeof isColorStr;
25
- };
26
- uuid: {
27
- createUUID: typeof createUUID;
28
- };
29
- istype: {
30
- type(data: any, lowerCase?: boolean | undefined): string;
31
- array(data: any): boolean;
32
- json(data: any): boolean;
33
- function(data: any): boolean;
34
- asyncFunction(data: any): boolean;
35
- string(data: any): boolean;
36
- number(data: any): boolean;
37
- undefined(data: any): boolean;
38
- null(data: any): boolean;
39
- promise(data: any): boolean;
40
- nodeList(data: any): boolean;
41
- imageData(data: any): boolean;
8
+ declare function borderRadius(value: any): boolean;
9
+
10
+ declare function borderWidth(value: any): boolean;
11
+
12
+ export declare const check: {
13
+ attrs: typeof attrs;
14
+ textDesc: typeof textDesc;
15
+ rectDesc: typeof rectDesc;
16
+ circleDesc: typeof circleDesc;
17
+ imageDesc: typeof imageDesc;
18
+ svgDesc: typeof svgDesc;
19
+ htmlDesc: typeof htmlDesc;
20
+ };
21
+
22
+ declare function circleDesc(desc: any): boolean;
23
+
24
+ declare function color(value: any): boolean;
25
+
26
+ export declare function compose(middleware: Middleware[]): (context: any, next?: Middleware) => any;
27
+
28
+ export declare class Context implements TypeContext {
29
+ private _opts;
30
+ private _ctx;
31
+ private _transform;
32
+ constructor(ctx: CanvasRenderingContext2D, opts: Options);
33
+ getContext(): CanvasRenderingContext2D;
34
+ resetSize(opts: TypeBoardSizeOptions): void;
35
+ calcDeviceNum(num: number): number;
36
+ calcScreenNum(num: number): number;
37
+ getSize(): {
38
+ width: number;
39
+ height: number;
40
+ contextWidth: number;
41
+ contextHeight: number;
42
+ devicePixelRatio: number;
42
43
  };
43
- data: {
44
- deepClone: typeof deepClone;
44
+ setTransform(config: Transform): void;
45
+ getTransform(): {
46
+ scale: number;
47
+ scrollX: number;
48
+ scrollY: number;
45
49
  };
46
- };
47
- export default _default;
50
+ setFillStyle(color: string | CanvasPattern | CanvasGradient): void;
51
+ fill(fillRule?: CanvasFillRule | undefined): void;
52
+ arc(x: number, y: number, radius: number, startAngle: number, endAngle: number, anticlockwise?: boolean | undefined): void;
53
+ rect(x: number, y: number, w: number, h: number): void;
54
+ fillRect(x: number, y: number, w: number, h: number): void;
55
+ clearRect(x: number, y: number, w: number, h: number): void;
56
+ beginPath(): void;
57
+ closePath(): void;
58
+ lineTo(x: number, y: number): void;
59
+ moveTo(x: number, y: number): void;
60
+ arcTo(x1: number, y1: number, x2: number, y2: number, radius: number): void;
61
+ setLineWidth(w: number): number;
62
+ setLineDash(nums: number[]): void;
63
+ isPointInPath(x: number, y: number): boolean;
64
+ isPointInPathWithoutScroll(x: number, y: number): boolean;
65
+ setStrokeStyle(color: string): void;
66
+ stroke(): void;
67
+ translate(x: number, y: number): void;
68
+ rotate(angle: number): void;
69
+ drawImage(...args: any[]): void;
70
+ createPattern(image: CanvasImageSource, repetition: string | null): CanvasPattern | null;
71
+ measureText(text: string): TextMetrics;
72
+ setTextAlign(align: CanvasTextAlign): void;
73
+ fillText(text: string, x: number, y: number, maxWidth?: number | undefined): void;
74
+ strokeText(text: string, x: number, y: number, maxWidth?: number | undefined): void;
75
+ setFont(opts: {
76
+ fontSize: number;
77
+ fontFamily?: string;
78
+ fontWeight?: 'bold';
79
+ }): void;
80
+ setTextBaseline(baseline: CanvasTextBaseline): void;
81
+ setGlobalAlpha(alpha: number): void;
82
+ save(): void;
83
+ restore(): void;
84
+ scale(ratioX: number, ratioY: number): void;
85
+ setShadowColor(color: string): void;
86
+ setShadowOffsetX(offsetX: number): void;
87
+ setShadowOffsetY(offsetY: number): void;
88
+ setShadowBlur(blur: number): void;
89
+ ellipse(x: number, y: number, radiusX: number, radiusY: number, rotation: number, startAngle: number, endAngle: number, counterclockwise?: boolean | undefined): void;
90
+ private _doSize;
91
+ private _doX;
92
+ private _doY;
93
+ }
94
+
95
+ export declare function createUUID(): string;
96
+
97
+ export declare function deepClone(target: any): any;
48
98
 
49
- declare function delay(time: number): Promise<void>;
99
+ export declare function delay(time: number): Promise<void>;
50
100
 
51
- declare function downloadImageFromCanvas(canvas: HTMLCanvasElement, opts: {
101
+ export declare function downloadImageFromCanvas(canvas: HTMLCanvasElement, opts: {
52
102
  filename: string;
53
103
  type: ImageType;
54
104
  }): void;
55
105
 
106
+ declare function fontFamily(value: any): boolean;
107
+
108
+ declare function fontSize(value: any): boolean;
109
+
110
+ declare function fontWeight(value: any): boolean;
111
+
112
+ declare function h(value: any): boolean;
113
+
114
+ declare function html(value: any): boolean;
115
+
116
+ declare function htmlDesc(desc: any): boolean;
117
+
118
+ declare function imageBase64(value: any): boolean;
119
+
120
+ declare function imageDesc(desc: any): boolean;
121
+
122
+ declare function imageSrc(value: any): boolean;
123
+
56
124
  declare type ImageType = 'image/jpeg' | 'image/png';
57
125
 
58
- declare function isColorStr(color?: string): boolean;
126
+ declare function imageURL(value: any): boolean;
59
127
 
60
- declare function loadHTML(html: string, opts: {
128
+ export declare const is: {
129
+ x: typeof x;
130
+ y: typeof y;
131
+ w: typeof w;
132
+ h: typeof h;
133
+ angle: typeof angle;
134
+ number: typeof number;
135
+ borderWidth: typeof borderWidth;
136
+ borderRadius: typeof borderRadius;
137
+ color: typeof color;
138
+ imageSrc: typeof imageSrc;
139
+ imageURL: typeof imageURL;
140
+ imageBase64: typeof imageBase64;
141
+ svg: typeof svg;
142
+ html: typeof html;
143
+ text: typeof text;
144
+ fontSize: typeof fontSize;
145
+ lineHeight: typeof lineHeight;
146
+ textAlign: typeof textAlign;
147
+ fontFamily: typeof fontFamily;
148
+ fontWeight: typeof fontWeight;
149
+ strokeWidth: typeof strokeWidth;
150
+ };
151
+
152
+ export declare function isColorStr(color?: string): boolean;
153
+
154
+ export declare const istype: {
155
+ type(data: any, lowerCase?: boolean | undefined): string;
156
+ array(data: any): boolean;
157
+ json(data: any): boolean;
158
+ function(data: any): boolean;
159
+ asyncFunction(data: any): boolean;
160
+ string(data: any): boolean;
161
+ number(data: any): boolean;
162
+ undefined(data: any): boolean;
163
+ null(data: any): boolean;
164
+ promise(data: any): boolean;
165
+ };
166
+
167
+ declare function lineHeight(value: any): boolean;
168
+
169
+ export declare function loadHTML(html: string, opts: {
61
170
  width: number;
62
171
  height: number;
63
172
  }): Promise<HTMLImageElement>;
64
173
 
65
- declare function loadImage(src: string): Promise<HTMLImageElement>;
174
+ export declare function loadImage(src: string): Promise<HTMLImageElement>;
66
175
 
67
- declare function loadSVG(svg: string): Promise<HTMLImageElement>;
176
+ export declare function loadSVG(svg: string): Promise<HTMLImageElement>;
68
177
 
69
178
  declare type Middleware = (ctx: any, next: Middleware) => any;
70
179
 
71
- declare function throttle(fn: (...args: any[]) => any, timeout: number): (...args: any[]) => any;
180
+ declare function number(value: any): boolean;
181
+
182
+ declare type Options = {
183
+ width: number;
184
+ height: number;
185
+ contextWidth: number;
186
+ contextHeight: number;
187
+ devicePixelRatio: number;
188
+ };
189
+
190
+ declare function rectDesc(desc: any): boolean;
191
+
192
+ declare function strokeWidth(value: any): boolean;
193
+
194
+ declare function svg(value: any): boolean;
195
+
196
+ declare function svgDesc(desc: any): boolean;
197
+
198
+ declare function text(value: any): boolean;
199
+
200
+ declare function textAlign(value: any): boolean;
201
+
202
+ declare function textDesc(desc: any): boolean;
203
+
204
+ export declare function throttle(fn: (...args: any[]) => any, timeout: number): (...args: any[]) => any;
205
+
206
+ export declare function toColorHexNum(color: string): number;
207
+
208
+ export declare function toColorHexStr(color: number): string;
209
+
210
+ declare type Transform = {
211
+ scale?: number;
212
+ scrollX?: number;
213
+ scrollY?: number;
214
+ };
215
+
216
+ declare function w(value: any): boolean;
72
217
 
73
- declare function toColorHexNum(color: string): number;
218
+ declare function x(value: any): boolean;
74
219
 
75
- declare function toColorHexStr(color: number): string;
220
+ declare function y(value: any): boolean;
76
221
 
77
222
  export { }