konva 10.0.1 → 10.0.3
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/README.md +1 -1
- package/konva.js +38 -11
- package/konva.min.js +4 -4
- package/lib/Container.d.ts +2 -2
- package/lib/DragAndDrop.d.ts +27 -1
- package/lib/Global.js +2 -2
- package/lib/Layer.d.ts +1 -1
- package/lib/Node.d.ts +135 -47
- package/lib/PointerEvents.d.ts +1 -1
- package/lib/Shape.d.ts +2 -2
- package/lib/Stage.d.ts +3 -3
- package/lib/Tween.d.ts +3 -0
- package/lib/Util.d.ts +1 -0
- package/lib/_CoreInternals.d.ts +28 -2
- package/lib/_FullInternals.d.ts +28 -2
- package/lib/shapes/Rect.d.ts +3 -3
- package/lib/shapes/TextPath.d.ts +7 -0
- package/lib/shapes/TextPath.js +27 -5
- package/lib/shapes/Transformer.d.ts +54 -2
- package/package.json +4 -3
package/lib/Container.d.ts
CHANGED
|
@@ -13,7 +13,7 @@ export interface ContainerConfig extends NodeConfig {
|
|
|
13
13
|
clipWidth?: number;
|
|
14
14
|
clipHeight?: number;
|
|
15
15
|
}
|
|
16
|
-
export declare abstract class Container<ChildType extends Node = Node> extends Node<
|
|
16
|
+
export declare abstract class Container<ChildType extends Node = Node, Config extends ContainerConfig = ContainerConfig> extends Node<Config> {
|
|
17
17
|
children: Array<ChildType>;
|
|
18
18
|
getChildren(filterFunc?: (item: Node) => boolean): ChildType[];
|
|
19
19
|
hasChildren(): boolean;
|
|
@@ -33,7 +33,7 @@ export declare abstract class Container<ChildType extends Node = Node> extends N
|
|
|
33
33
|
};
|
|
34
34
|
isAncestorOf(node: Node): boolean;
|
|
35
35
|
clone(obj?: any): this;
|
|
36
|
-
getAllIntersections(pos: any): Shape<import("./Shape.ts").ShapeConfig
|
|
36
|
+
getAllIntersections(pos: any): Shape<import("./Shape.ts").ShapeConfig<{}>>[];
|
|
37
37
|
_clearSelfAndDescendantCache(attr?: string): void;
|
|
38
38
|
_setChildrenIndices(): void;
|
|
39
39
|
drawScene(can?: SceneCanvas, top?: Node, bufferCanvas?: SceneCanvas): this;
|
package/lib/DragAndDrop.d.ts
CHANGED
|
@@ -3,7 +3,33 @@ import type { Vector2d } from './types.ts';
|
|
|
3
3
|
export declare const DD: {
|
|
4
4
|
readonly isDragging: boolean;
|
|
5
5
|
justDragged: boolean;
|
|
6
|
-
readonly node: Node<
|
|
6
|
+
readonly node: Node<{
|
|
7
|
+
x?: number;
|
|
8
|
+
y?: number;
|
|
9
|
+
width?: number;
|
|
10
|
+
height?: number;
|
|
11
|
+
visible?: boolean;
|
|
12
|
+
listening?: boolean;
|
|
13
|
+
id?: string;
|
|
14
|
+
name?: string;
|
|
15
|
+
opacity?: number;
|
|
16
|
+
scale?: Vector2d;
|
|
17
|
+
scaleX?: number;
|
|
18
|
+
skewX?: number;
|
|
19
|
+
skewY?: number;
|
|
20
|
+
scaleY?: number;
|
|
21
|
+
rotation?: number;
|
|
22
|
+
rotationDeg?: number;
|
|
23
|
+
offset?: Vector2d;
|
|
24
|
+
offsetX?: number;
|
|
25
|
+
offsetY?: number;
|
|
26
|
+
draggable?: boolean;
|
|
27
|
+
dragDistance?: number;
|
|
28
|
+
dragBoundFunc?: (this: Node, pos: Vector2d) => Vector2d;
|
|
29
|
+
preventDefault?: boolean;
|
|
30
|
+
globalCompositeOperation?: "" | "source-over" | "source-in" | "source-out" | "source-atop" | "destination-over" | "destination-in" | "destination-out" | "destination-atop" | "lighter" | "copy" | "xor" | "multiply" | "screen" | "overlay" | "darken" | "lighten" | "color-dodge" | "color-burn" | "hard-light" | "soft-light" | "difference" | "exclusion" | "hue" | "saturation" | "color" | "luminosity";
|
|
31
|
+
filters?: (string | import("./Node.ts").FilterFunction)[];
|
|
32
|
+
}> | undefined;
|
|
7
33
|
_dragElements: Map<number, {
|
|
8
34
|
node: Node;
|
|
9
35
|
startPointerPos: Vector2d;
|
package/lib/Global.js
CHANGED
|
@@ -13,7 +13,7 @@ export const glob = typeof global !== 'undefined'
|
|
|
13
13
|
: {};
|
|
14
14
|
export const Konva = {
|
|
15
15
|
_global: glob,
|
|
16
|
-
version: '10.0.
|
|
16
|
+
version: '10.0.3',
|
|
17
17
|
isBrowser: detectBrowser(),
|
|
18
18
|
isUnminified: /param/.test(function (param) { }.toString()),
|
|
19
19
|
dblClickWindow: 400,
|
|
@@ -55,7 +55,7 @@ export const Konva = {
|
|
|
55
55
|
document: glob.document,
|
|
56
56
|
_injectGlobal(Konva) {
|
|
57
57
|
if (typeof glob.Konva !== 'undefined') {
|
|
58
|
-
console.error('
|
|
58
|
+
console.error('Several Konva instances detected. It is not recommended to use multiple Konva instances in the same environment.');
|
|
59
59
|
}
|
|
60
60
|
glob.Konva = Konva;
|
|
61
61
|
},
|
package/lib/Layer.d.ts
CHANGED
|
@@ -43,7 +43,7 @@ export declare class Layer extends Container<Group | Shape> {
|
|
|
43
43
|
getHeight(): number | undefined;
|
|
44
44
|
setHeight(): void;
|
|
45
45
|
batchDraw(): this;
|
|
46
|
-
getIntersection(pos: Vector2d): Shape<import("./Shape.ts").ShapeConfig
|
|
46
|
+
getIntersection(pos: Vector2d): Shape<import("./Shape.ts").ShapeConfig<{}>> | null;
|
|
47
47
|
_getIntersection(pos: Vector2d): {
|
|
48
48
|
shape?: Shape;
|
|
49
49
|
antialiased?: boolean;
|
package/lib/Node.d.ts
CHANGED
|
@@ -6,13 +6,12 @@ import type { Layer } from './Layer.ts';
|
|
|
6
6
|
import type { Shape } from './Shape.ts';
|
|
7
7
|
import type { Stage } from './Stage.ts';
|
|
8
8
|
import type { GetSet, IRect, Vector2d } from './types.ts';
|
|
9
|
-
import { Transform } from './Util.ts';
|
|
9
|
+
import { Transform, type AnyString } from './Util.ts';
|
|
10
10
|
export type FilterFunction = (this: Node, imageData: ImageData) => void;
|
|
11
11
|
export type Filter = FilterFunction | string;
|
|
12
12
|
type Filters = Array<FilterFunction | string>;
|
|
13
13
|
type globalCompositeOperationType = '' | 'source-over' | 'source-in' | 'source-out' | 'source-atop' | 'destination-over' | 'destination-in' | 'destination-out' | 'destination-atop' | 'lighter' | 'copy' | 'xor' | 'multiply' | 'screen' | 'overlay' | 'darken' | 'lighten' | 'color-dodge' | 'color-burn' | 'hard-light' | 'soft-light' | 'difference' | 'exclusion' | 'hue' | 'saturation' | 'color' | 'luminosity';
|
|
14
|
-
export
|
|
15
|
-
[index: string]: any;
|
|
14
|
+
export type NodeConfig<Props extends Record<string, any> = {}> = Props & {
|
|
16
15
|
x?: number;
|
|
17
16
|
y?: number;
|
|
18
17
|
width?: number;
|
|
@@ -38,7 +37,7 @@ export interface NodeConfig {
|
|
|
38
37
|
preventDefault?: boolean;
|
|
39
38
|
globalCompositeOperation?: globalCompositeOperationType;
|
|
40
39
|
filters?: Filters;
|
|
41
|
-
}
|
|
40
|
+
};
|
|
42
41
|
type NodeEventMap = GlobalEventHandlersEventMap & {
|
|
43
42
|
[index: string]: any;
|
|
44
43
|
};
|
|
@@ -52,6 +51,18 @@ export interface KonvaEventObject<EventType, This = Node> {
|
|
|
52
51
|
child?: Node;
|
|
53
52
|
}
|
|
54
53
|
export type KonvaEventListener<This, EventType> = (this: This, ev: KonvaEventObject<EventType, This>) => void;
|
|
54
|
+
export type CanvasConfig = {
|
|
55
|
+
x?: number;
|
|
56
|
+
y?: number;
|
|
57
|
+
width?: number;
|
|
58
|
+
height?: number;
|
|
59
|
+
pixelRatio?: number;
|
|
60
|
+
imageSmoothingEnabled?: boolean;
|
|
61
|
+
};
|
|
62
|
+
export type ImageConfig = CanvasConfig & {
|
|
63
|
+
mimeType?: string;
|
|
64
|
+
quality?: number;
|
|
65
|
+
};
|
|
55
66
|
export declare abstract class Node<Config extends NodeConfig = NodeConfig> {
|
|
56
67
|
_id: number;
|
|
57
68
|
eventListeners: {
|
|
@@ -84,15 +95,9 @@ export declare abstract class Node<Config extends NodeConfig = NodeConfig> {
|
|
|
84
95
|
_getCanvasCache(): any;
|
|
85
96
|
_clearSelfAndDescendantCache(attr?: string): void;
|
|
86
97
|
clearCache(): this;
|
|
87
|
-
cache(config?: {
|
|
88
|
-
x?: number;
|
|
89
|
-
y?: number;
|
|
90
|
-
width?: number;
|
|
91
|
-
height?: number;
|
|
98
|
+
cache(config?: CanvasConfig & {
|
|
92
99
|
drawBorder?: boolean;
|
|
93
100
|
offset?: number;
|
|
94
|
-
pixelRatio?: number;
|
|
95
|
-
imageSmoothingEnabled?: boolean;
|
|
96
101
|
hitCanvasPixelRatio?: number;
|
|
97
102
|
}): this | undefined;
|
|
98
103
|
isCached(): boolean;
|
|
@@ -128,10 +133,36 @@ export declare abstract class Node<Config extends NodeConfig = NodeConfig> {
|
|
|
128
133
|
_clearCaches(): void;
|
|
129
134
|
_remove(): void;
|
|
130
135
|
destroy(): this;
|
|
131
|
-
getAttr<
|
|
132
|
-
getAncestors(): Node<
|
|
133
|
-
|
|
134
|
-
|
|
136
|
+
getAttr<AttrConfig extends Config, K extends AnyString<keyof Config>>(attr: K): K extends keyof AttrConfig ? AttrConfig[K] : any;
|
|
137
|
+
getAncestors(): Node<{
|
|
138
|
+
x?: number;
|
|
139
|
+
y?: number;
|
|
140
|
+
width?: number;
|
|
141
|
+
height?: number;
|
|
142
|
+
visible?: boolean;
|
|
143
|
+
listening?: boolean;
|
|
144
|
+
id?: string;
|
|
145
|
+
name?: string;
|
|
146
|
+
opacity?: number;
|
|
147
|
+
scale?: Vector2d;
|
|
148
|
+
scaleX?: number;
|
|
149
|
+
skewX?: number;
|
|
150
|
+
skewY?: number;
|
|
151
|
+
scaleY?: number;
|
|
152
|
+
rotation?: number;
|
|
153
|
+
rotationDeg?: number;
|
|
154
|
+
offset?: Vector2d;
|
|
155
|
+
offsetX?: number;
|
|
156
|
+
offsetY?: number;
|
|
157
|
+
draggable?: boolean;
|
|
158
|
+
dragDistance?: number;
|
|
159
|
+
dragBoundFunc?: (this: Node, pos: Vector2d) => Vector2d;
|
|
160
|
+
preventDefault?: boolean;
|
|
161
|
+
globalCompositeOperation?: globalCompositeOperationType;
|
|
162
|
+
filters?: Filters;
|
|
163
|
+
}>[];
|
|
164
|
+
getAttrs(): Config;
|
|
165
|
+
setAttrs(config?: Config): this;
|
|
135
166
|
isListening(): any;
|
|
136
167
|
_isListening(relativeTo?: Node): boolean;
|
|
137
168
|
isVisible(): any;
|
|
@@ -186,10 +217,88 @@ export declare abstract class Node<Config extends NodeConfig = NodeConfig> {
|
|
|
186
217
|
children?: Array<any>;
|
|
187
218
|
};
|
|
188
219
|
toJSON(): string;
|
|
189
|
-
getParent(): Container<Node<
|
|
190
|
-
|
|
220
|
+
getParent(): Container<Node<{
|
|
221
|
+
x?: number;
|
|
222
|
+
y?: number;
|
|
223
|
+
width?: number;
|
|
224
|
+
height?: number;
|
|
225
|
+
visible?: boolean;
|
|
226
|
+
listening?: boolean;
|
|
227
|
+
id?: string;
|
|
228
|
+
name?: string;
|
|
229
|
+
opacity?: number;
|
|
230
|
+
scale?: Vector2d;
|
|
231
|
+
scaleX?: number;
|
|
232
|
+
skewX?: number;
|
|
233
|
+
skewY?: number;
|
|
234
|
+
scaleY?: number;
|
|
235
|
+
rotation?: number;
|
|
236
|
+
rotationDeg?: number;
|
|
237
|
+
offset?: Vector2d;
|
|
238
|
+
offsetX?: number;
|
|
239
|
+
offsetY?: number;
|
|
240
|
+
draggable?: boolean;
|
|
241
|
+
dragDistance?: number;
|
|
242
|
+
dragBoundFunc?: (this: Node, pos: Vector2d) => Vector2d;
|
|
243
|
+
preventDefault?: boolean;
|
|
244
|
+
globalCompositeOperation?: globalCompositeOperationType;
|
|
245
|
+
filters?: Filters;
|
|
246
|
+
}>, import("./Container.ts").ContainerConfig> | null;
|
|
247
|
+
findAncestors(selector: string | Function, includeSelf?: boolean, stopNode?: Node): Node<{
|
|
248
|
+
x?: number;
|
|
249
|
+
y?: number;
|
|
250
|
+
width?: number;
|
|
251
|
+
height?: number;
|
|
252
|
+
visible?: boolean;
|
|
253
|
+
listening?: boolean;
|
|
254
|
+
id?: string;
|
|
255
|
+
name?: string;
|
|
256
|
+
opacity?: number;
|
|
257
|
+
scale?: Vector2d;
|
|
258
|
+
scaleX?: number;
|
|
259
|
+
skewX?: number;
|
|
260
|
+
skewY?: number;
|
|
261
|
+
scaleY?: number;
|
|
262
|
+
rotation?: number;
|
|
263
|
+
rotationDeg?: number;
|
|
264
|
+
offset?: Vector2d;
|
|
265
|
+
offsetX?: number;
|
|
266
|
+
offsetY?: number;
|
|
267
|
+
draggable?: boolean;
|
|
268
|
+
dragDistance?: number;
|
|
269
|
+
dragBoundFunc?: (this: Node, pos: Vector2d) => Vector2d;
|
|
270
|
+
preventDefault?: boolean;
|
|
271
|
+
globalCompositeOperation?: globalCompositeOperationType;
|
|
272
|
+
filters?: Filters;
|
|
273
|
+
}>[];
|
|
191
274
|
isAncestorOf(node: Node): boolean;
|
|
192
|
-
findAncestor(selector: string | Function, includeSelf?: boolean, stopNode?: Container): Node<
|
|
275
|
+
findAncestor(selector: string | Function, includeSelf?: boolean, stopNode?: Container): Node<{
|
|
276
|
+
x?: number;
|
|
277
|
+
y?: number;
|
|
278
|
+
width?: number;
|
|
279
|
+
height?: number;
|
|
280
|
+
visible?: boolean;
|
|
281
|
+
listening?: boolean;
|
|
282
|
+
id?: string;
|
|
283
|
+
name?: string;
|
|
284
|
+
opacity?: number;
|
|
285
|
+
scale?: Vector2d;
|
|
286
|
+
scaleX?: number;
|
|
287
|
+
skewX?: number;
|
|
288
|
+
skewY?: number;
|
|
289
|
+
scaleY?: number;
|
|
290
|
+
rotation?: number;
|
|
291
|
+
rotationDeg?: number;
|
|
292
|
+
offset?: Vector2d;
|
|
293
|
+
offsetX?: number;
|
|
294
|
+
offsetY?: number;
|
|
295
|
+
draggable?: boolean;
|
|
296
|
+
dragDistance?: number;
|
|
297
|
+
dragBoundFunc?: (this: Node, pos: Vector2d) => Vector2d;
|
|
298
|
+
preventDefault?: boolean;
|
|
299
|
+
globalCompositeOperation?: globalCompositeOperationType;
|
|
300
|
+
filters?: Filters;
|
|
301
|
+
}>;
|
|
193
302
|
_isMatch(selector: string | Function): any;
|
|
194
303
|
getLayer(): Layer | null;
|
|
195
304
|
getStage(): Stage | null;
|
|
@@ -206,35 +315,14 @@ export declare abstract class Node<Config extends NodeConfig = NodeConfig> {
|
|
|
206
315
|
_getTransform(): Transform;
|
|
207
316
|
clone(obj?: any): any;
|
|
208
317
|
_toKonvaCanvas(config: any): SceneCanvas;
|
|
209
|
-
toCanvas(config?:
|
|
210
|
-
toDataURL(config?: {
|
|
211
|
-
|
|
212
|
-
y?: number;
|
|
213
|
-
width?: number;
|
|
214
|
-
height?: number;
|
|
215
|
-
pixelRatio?: number;
|
|
216
|
-
mimeType?: string;
|
|
217
|
-
quality?: number;
|
|
218
|
-
callback?: (str: string) => void;
|
|
318
|
+
toCanvas(config?: CanvasConfig): HTMLCanvasElement;
|
|
319
|
+
toDataURL(config?: ImageConfig & {
|
|
320
|
+
callback?: (url: string) => void;
|
|
219
321
|
}): string;
|
|
220
|
-
toImage(config?: {
|
|
221
|
-
x?: number;
|
|
222
|
-
y?: number;
|
|
223
|
-
width?: number;
|
|
224
|
-
height?: number;
|
|
225
|
-
pixelRatio?: number;
|
|
226
|
-
mimeType?: string;
|
|
227
|
-
quality?: number;
|
|
322
|
+
toImage(config?: ImageConfig & {
|
|
228
323
|
callback?: (img: HTMLImageElement) => void;
|
|
229
324
|
}): Promise<HTMLImageElement>;
|
|
230
|
-
toBlob(config?: {
|
|
231
|
-
x?: number;
|
|
232
|
-
y?: number;
|
|
233
|
-
width?: number;
|
|
234
|
-
height?: number;
|
|
235
|
-
pixelRatio?: number;
|
|
236
|
-
mimeType?: string;
|
|
237
|
-
quality?: number;
|
|
325
|
+
toBlob(config?: ImageConfig & {
|
|
238
326
|
callback?: (blob: Blob | null) => void;
|
|
239
327
|
}): Promise<unknown>;
|
|
240
328
|
setSize(size: any): this;
|
|
@@ -250,9 +338,9 @@ export declare abstract class Node<Config extends NodeConfig = NodeConfig> {
|
|
|
250
338
|
addName(name: string): this;
|
|
251
339
|
hasName(name: any): boolean;
|
|
252
340
|
removeName(name: any): this;
|
|
253
|
-
setAttr(attr:
|
|
341
|
+
setAttr<AttrConfig extends Config, K extends AnyString<keyof Config>>(attr: K, val: K extends keyof AttrConfig ? AttrConfig[K] : any): this;
|
|
254
342
|
_requestDraw(): void;
|
|
255
|
-
_setAttr(key:
|
|
343
|
+
_setAttr<AttrConfig extends Config, K extends AnyString<keyof Config>>(key: K, val: K extends keyof AttrConfig ? AttrConfig[K] : any): void;
|
|
256
344
|
_setComponentAttr(key: any, component: any, val: any): void;
|
|
257
345
|
_fireAndBubble(eventType: any, evt: any, compareShape?: any): void;
|
|
258
346
|
_getProtoListeners(eventType: any): any;
|
|
@@ -330,7 +418,7 @@ export declare abstract class Node<Config extends NodeConfig = NodeConfig> {
|
|
|
330
418
|
static create(data: any, container?: any): any;
|
|
331
419
|
static _createNode(obj: any, container?: any): any;
|
|
332
420
|
}
|
|
333
|
-
interface AnimTo extends NodeConfig {
|
|
421
|
+
interface AnimTo extends NodeConfig<Record<string, any>> {
|
|
334
422
|
onFinish?: Function;
|
|
335
423
|
onUpdate?: Function;
|
|
336
424
|
duration?: number;
|
package/lib/PointerEvents.d.ts
CHANGED
|
@@ -4,7 +4,7 @@ import type { Stage } from './Stage.ts';
|
|
|
4
4
|
export interface KonvaPointerEvent extends KonvaEventObject<PointerEvent> {
|
|
5
5
|
pointerId: number;
|
|
6
6
|
}
|
|
7
|
-
export declare function getCapturedShape(pointerId: number): Shape<import("./Shape.ts").ShapeConfig
|
|
7
|
+
export declare function getCapturedShape(pointerId: number): Shape<import("./Shape.ts").ShapeConfig<{}>> | Stage | undefined;
|
|
8
8
|
export declare function createEvent(evt: PointerEvent): KonvaPointerEvent;
|
|
9
9
|
export declare function hasPointerCapture(pointerId: number, shape: Shape | Stage): boolean;
|
|
10
10
|
export declare function setPointerCapture(pointerId: number, shape: Shape | Stage): void;
|
package/lib/Shape.d.ts
CHANGED
|
@@ -8,7 +8,7 @@ export type ShapeConfigHandler<TTarget> = {
|
|
|
8
8
|
}['bivarianceHack'];
|
|
9
9
|
export type LineJoin = 'round' | 'bevel' | 'miter';
|
|
10
10
|
export type LineCap = 'butt' | 'round' | 'square';
|
|
11
|
-
export
|
|
11
|
+
export type ShapeConfig<Props extends Record<string, any> = {}> = NodeConfig<Props> & {
|
|
12
12
|
fill?: string | CanvasGradient;
|
|
13
13
|
fillPatternImage?: HTMLImageElement;
|
|
14
14
|
fillPatternX?: number;
|
|
@@ -64,7 +64,7 @@ export interface ShapeConfig extends NodeConfig {
|
|
|
64
64
|
dashOffset?: number;
|
|
65
65
|
dashEnabled?: boolean;
|
|
66
66
|
perfectDrawEnabled?: boolean;
|
|
67
|
-
}
|
|
67
|
+
};
|
|
68
68
|
export interface ShapeGetClientRectConfig {
|
|
69
69
|
skipTransform?: boolean;
|
|
70
70
|
skipShadow?: boolean;
|
package/lib/Stage.d.ts
CHANGED
|
@@ -8,7 +8,7 @@ export interface StageConfig extends ContainerConfig {
|
|
|
8
8
|
container?: HTMLDivElement | string;
|
|
9
9
|
}
|
|
10
10
|
export declare const stages: Stage[];
|
|
11
|
-
export declare class Stage extends Container<Layer> {
|
|
11
|
+
export declare class Stage extends Container<Layer, StageConfig> {
|
|
12
12
|
content: HTMLDivElement;
|
|
13
13
|
pointerPos: Vector2d | null;
|
|
14
14
|
_pointerPositions: (Vector2d & {
|
|
@@ -49,7 +49,7 @@ export declare class Stage extends Container<Layer> {
|
|
|
49
49
|
getStage(): this;
|
|
50
50
|
getContent(): HTMLDivElement;
|
|
51
51
|
_toKonvaCanvas(config: any): SceneCanvas;
|
|
52
|
-
getIntersection(pos: Vector2d): Shape<import("./Shape.ts").ShapeConfig
|
|
52
|
+
getIntersection(pos: Vector2d): Shape<import("./Shape.ts").ShapeConfig<{}>> | null;
|
|
53
53
|
_resizeDOM(): void;
|
|
54
54
|
add(layer: Layer, ...rest: any[]): this;
|
|
55
55
|
getParent(): null;
|
|
@@ -61,7 +61,7 @@ export declare class Stage extends Container<Layer> {
|
|
|
61
61
|
_bindContentEvents(): void;
|
|
62
62
|
_pointerenter(evt: PointerEvent): void;
|
|
63
63
|
_pointerover(evt: any): void;
|
|
64
|
-
_getTargetShape(evenType: any): Shape<import("./Shape.ts").ShapeConfig
|
|
64
|
+
_getTargetShape(evenType: any): Shape<import("./Shape.ts").ShapeConfig<{}>> | null;
|
|
65
65
|
_pointerleave(evt: any): void;
|
|
66
66
|
_pointerdown(evt: TouchEvent | MouseEvent | PointerEvent): void;
|
|
67
67
|
_pointermove(evt: TouchEvent | MouseEvent | PointerEvent): void;
|
package/lib/Tween.d.ts
CHANGED
|
@@ -39,6 +39,9 @@ declare class TweenEngine {
|
|
|
39
39
|
getTimer(): number;
|
|
40
40
|
}
|
|
41
41
|
export interface TweenConfig extends NodeConfig {
|
|
42
|
+
easing?: typeof Easings[keyof typeof Easings];
|
|
43
|
+
yoyo?: boolean;
|
|
44
|
+
onReset?: Function;
|
|
42
45
|
onFinish?: Function;
|
|
43
46
|
onUpdate?: Function;
|
|
44
47
|
duration?: number;
|
package/lib/Util.d.ts
CHANGED
|
@@ -130,3 +130,4 @@ export declare const Util: {
|
|
|
130
130
|
drawRoundedRectPath(context: Context, width: number, height: number, cornerRadius: number | number[]): void;
|
|
131
131
|
drawRoundedPolygonPath(context: Context, points: Vector2d[], sides: number, radius: number, cornerRadius: number | number[]): void;
|
|
132
132
|
};
|
|
133
|
+
export type AnyString<T> = T | (string & {});
|
package/lib/_CoreInternals.d.ts
CHANGED
|
@@ -154,7 +154,33 @@ export declare const Konva: {
|
|
|
154
154
|
DD: {
|
|
155
155
|
readonly isDragging: boolean;
|
|
156
156
|
justDragged: boolean;
|
|
157
|
-
readonly node: Node<
|
|
157
|
+
readonly node: Node<{
|
|
158
|
+
x?: number;
|
|
159
|
+
y?: number;
|
|
160
|
+
width?: number;
|
|
161
|
+
height?: number;
|
|
162
|
+
visible?: boolean;
|
|
163
|
+
listening?: boolean;
|
|
164
|
+
id?: string;
|
|
165
|
+
name?: string;
|
|
166
|
+
opacity?: number;
|
|
167
|
+
scale?: import("./types.ts").Vector2d;
|
|
168
|
+
scaleX?: number;
|
|
169
|
+
skewX?: number;
|
|
170
|
+
skewY?: number;
|
|
171
|
+
scaleY?: number;
|
|
172
|
+
rotation?: number;
|
|
173
|
+
rotationDeg?: number;
|
|
174
|
+
offset?: import("./types.ts").Vector2d;
|
|
175
|
+
offsetX?: number;
|
|
176
|
+
offsetY?: number;
|
|
177
|
+
draggable?: boolean;
|
|
178
|
+
dragDistance?: number;
|
|
179
|
+
dragBoundFunc?: (this: Node, pos: import("./types.ts").Vector2d) => import("./types.ts").Vector2d;
|
|
180
|
+
preventDefault?: boolean;
|
|
181
|
+
globalCompositeOperation?: "" | "source-over" | "source-in" | "source-out" | "source-atop" | "destination-over" | "destination-in" | "destination-out" | "destination-atop" | "lighter" | "copy" | "xor" | "multiply" | "screen" | "overlay" | "darken" | "lighten" | "color-dodge" | "color-burn" | "hard-light" | "soft-light" | "difference" | "exclusion" | "hue" | "saturation" | "color" | "luminosity";
|
|
182
|
+
filters?: (string | import("./Node.ts").FilterFunction)[];
|
|
183
|
+
}> | undefined;
|
|
158
184
|
_dragElements: Map<number, {
|
|
159
185
|
node: Node;
|
|
160
186
|
startPointerPos: import("./types.ts").Vector2d;
|
|
@@ -168,7 +194,7 @@ export declare const Konva: {
|
|
|
168
194
|
};
|
|
169
195
|
Shape: typeof Shape;
|
|
170
196
|
shapes: {
|
|
171
|
-
[key: string]: Shape<import("./Shape.ts").ShapeConfig
|
|
197
|
+
[key: string]: Shape<import("./Shape.ts").ShapeConfig<{}>>;
|
|
172
198
|
};
|
|
173
199
|
Animation: typeof Animation;
|
|
174
200
|
Tween: typeof Tween;
|
package/lib/_FullInternals.d.ts
CHANGED
|
@@ -160,7 +160,33 @@ export declare const Konva: {
|
|
|
160
160
|
DD: {
|
|
161
161
|
readonly isDragging: boolean;
|
|
162
162
|
justDragged: boolean;
|
|
163
|
-
readonly node: import("./Node.ts").Node<
|
|
163
|
+
readonly node: import("./Node.ts").Node<{
|
|
164
|
+
x?: number;
|
|
165
|
+
y?: number;
|
|
166
|
+
width?: number;
|
|
167
|
+
height?: number;
|
|
168
|
+
visible?: boolean;
|
|
169
|
+
listening?: boolean;
|
|
170
|
+
id?: string;
|
|
171
|
+
name?: string;
|
|
172
|
+
opacity?: number;
|
|
173
|
+
scale?: import("./types.ts").Vector2d;
|
|
174
|
+
scaleX?: number;
|
|
175
|
+
skewX?: number;
|
|
176
|
+
skewY?: number;
|
|
177
|
+
scaleY?: number;
|
|
178
|
+
rotation?: number;
|
|
179
|
+
rotationDeg?: number;
|
|
180
|
+
offset?: import("./types.ts").Vector2d;
|
|
181
|
+
offsetX?: number;
|
|
182
|
+
offsetY?: number;
|
|
183
|
+
draggable?: boolean;
|
|
184
|
+
dragDistance?: number;
|
|
185
|
+
dragBoundFunc?: (this: import("./Node.ts").Node, pos: import("./types.ts").Vector2d) => import("./types.ts").Vector2d;
|
|
186
|
+
preventDefault?: boolean;
|
|
187
|
+
globalCompositeOperation?: "" | "source-over" | "source-in" | "source-out" | "source-atop" | "destination-over" | "destination-in" | "destination-out" | "destination-atop" | "lighter" | "copy" | "xor" | "multiply" | "screen" | "overlay" | "darken" | "lighten" | "color-dodge" | "color-burn" | "hard-light" | "soft-light" | "difference" | "exclusion" | "hue" | "saturation" | "color" | "luminosity";
|
|
188
|
+
filters?: (string | import("./Node.ts").FilterFunction)[];
|
|
189
|
+
}> | undefined;
|
|
164
190
|
_dragElements: Map<number, {
|
|
165
191
|
node: import("./Node.ts").Node;
|
|
166
192
|
startPointerPos: import("./types.ts").Vector2d;
|
|
@@ -174,7 +200,7 @@ export declare const Konva: {
|
|
|
174
200
|
};
|
|
175
201
|
Shape: typeof import("./Shape.ts").Shape;
|
|
176
202
|
shapes: {
|
|
177
|
-
[key: string]: import("./Shape.ts").Shape<import("./Shape.ts").ShapeConfig
|
|
203
|
+
[key: string]: import("./Shape.ts").Shape<import("./Shape.ts").ShapeConfig<{}>>;
|
|
178
204
|
};
|
|
179
205
|
Animation: typeof import("./Animation.ts").Animation;
|
|
180
206
|
Tween: typeof import("./Tween.ts").Tween;
|
package/lib/shapes/Rect.d.ts
CHANGED
|
@@ -2,10 +2,10 @@ import type { ShapeConfig } from '../Shape.ts';
|
|
|
2
2
|
import { Shape } from '../Shape.ts';
|
|
3
3
|
import type { GetSet } from '../types.ts';
|
|
4
4
|
import type { Context } from '../Context.ts';
|
|
5
|
-
export
|
|
5
|
+
export type RectConfig<Props extends Record<string, any> = {}> = ShapeConfig<Props> & {
|
|
6
6
|
cornerRadius?: number | number[];
|
|
7
|
-
}
|
|
8
|
-
export declare class Rect extends Shape<RectConfig
|
|
7
|
+
};
|
|
8
|
+
export declare class Rect<Props extends Record<string, any> = {}> extends Shape<RectConfig<Props>> {
|
|
9
9
|
_sceneFunc(context: Context): void;
|
|
10
10
|
cornerRadius: GetSet<number | number[], this>;
|
|
11
11
|
}
|
package/lib/shapes/TextPath.d.ts
CHANGED
|
@@ -9,7 +9,13 @@ export interface TextPathConfig extends ShapeConfig {
|
|
|
9
9
|
fontFamily?: string;
|
|
10
10
|
fontSize?: number;
|
|
11
11
|
fontStyle?: string;
|
|
12
|
+
fontVariant?: string;
|
|
13
|
+
align?: string;
|
|
12
14
|
letterSpacing?: number;
|
|
15
|
+
textBaseline?: string;
|
|
16
|
+
textDecoration?: string;
|
|
17
|
+
kerningFunc?: (leftChar: string, rightChar: string) => number;
|
|
18
|
+
lineHeight?: number;
|
|
13
19
|
}
|
|
14
20
|
export declare class TextPath extends Shape<TextPathConfig> {
|
|
15
21
|
dummyCanvas: HTMLCanvasElement;
|
|
@@ -21,6 +27,7 @@ export declare class TextPath extends Shape<TextPathConfig> {
|
|
|
21
27
|
rotation: number;
|
|
22
28
|
p0: Vector2d;
|
|
23
29
|
p1: Vector2d;
|
|
30
|
+
width: number;
|
|
24
31
|
}>;
|
|
25
32
|
partialText: string;
|
|
26
33
|
pathLength: number;
|
package/lib/shapes/TextPath.js
CHANGED
|
@@ -33,7 +33,7 @@ export class TextPath extends Shape {
|
|
|
33
33
|
return null;
|
|
34
34
|
}
|
|
35
35
|
const totalLength = this.pathLength;
|
|
36
|
-
if (length
|
|
36
|
+
if (length > totalLength) {
|
|
37
37
|
return null;
|
|
38
38
|
}
|
|
39
39
|
return Path.getPointAtLengthOfDataArray(length, this.dataArray);
|
|
@@ -51,7 +51,9 @@ export class TextPath extends Shape {
|
|
|
51
51
|
const fill = this.fill();
|
|
52
52
|
const fontSize = this.fontSize();
|
|
53
53
|
const glyphInfo = this.glyphInfo;
|
|
54
|
-
|
|
54
|
+
const hasUnderline = textDecoration.indexOf('underline') !== -1;
|
|
55
|
+
const hasLineThrough = textDecoration.indexOf('line-through') !== -1;
|
|
56
|
+
if (hasUnderline) {
|
|
55
57
|
context.beginPath();
|
|
56
58
|
}
|
|
57
59
|
for (let i = 0; i < glyphInfo.length; i++) {
|
|
@@ -61,15 +63,34 @@ export class TextPath extends Shape {
|
|
|
61
63
|
context.rotate(glyphInfo[i].rotation);
|
|
62
64
|
this.partialText = glyphInfo[i].text;
|
|
63
65
|
context.fillStrokeShape(this);
|
|
64
|
-
if (
|
|
66
|
+
if (hasUnderline) {
|
|
65
67
|
if (i === 0) {
|
|
66
68
|
context.moveTo(0, fontSize / 2 + 1);
|
|
67
69
|
}
|
|
68
|
-
|
|
70
|
+
console.log('underline log');
|
|
71
|
+
context.lineTo(glyphInfo[i].width, fontSize / 2 + 1);
|
|
69
72
|
}
|
|
70
73
|
context.restore();
|
|
71
74
|
}
|
|
72
|
-
if (
|
|
75
|
+
if (hasUnderline) {
|
|
76
|
+
context.strokeStyle = fill;
|
|
77
|
+
context.lineWidth = fontSize / 20;
|
|
78
|
+
console.log('underline log');
|
|
79
|
+
context.stroke();
|
|
80
|
+
}
|
|
81
|
+
if (hasLineThrough) {
|
|
82
|
+
context.beginPath();
|
|
83
|
+
for (let i = 0; i < glyphInfo.length; i++) {
|
|
84
|
+
context.save();
|
|
85
|
+
const p0 = glyphInfo[i].p0;
|
|
86
|
+
context.translate(p0.x, p0.y);
|
|
87
|
+
context.rotate(glyphInfo[i].rotation);
|
|
88
|
+
if (i === 0) {
|
|
89
|
+
context.moveTo(0, 0);
|
|
90
|
+
}
|
|
91
|
+
context.lineTo(glyphInfo[i].width, 0);
|
|
92
|
+
context.restore();
|
|
93
|
+
}
|
|
73
94
|
context.strokeStyle = fill;
|
|
74
95
|
context.lineWidth = fontSize / 20;
|
|
75
96
|
context.stroke();
|
|
@@ -182,6 +203,7 @@ export class TextPath extends Shape {
|
|
|
182
203
|
rotation: rotation,
|
|
183
204
|
p0: charStartPoint,
|
|
184
205
|
p1: charEndPoint,
|
|
206
|
+
width: width,
|
|
185
207
|
});
|
|
186
208
|
offsetToGlyph += glyphWidth;
|
|
187
209
|
}
|
|
@@ -49,11 +49,63 @@ export declare class Transformer extends Group {
|
|
|
49
49
|
constructor(config?: TransformerConfig);
|
|
50
50
|
attachTo(node: Node): this;
|
|
51
51
|
setNode(node: Node): this;
|
|
52
|
-
getNode(): Node<
|
|
52
|
+
getNode(): Node<{
|
|
53
|
+
x?: number;
|
|
54
|
+
y?: number;
|
|
55
|
+
width?: number;
|
|
56
|
+
height?: number;
|
|
57
|
+
visible?: boolean;
|
|
58
|
+
listening?: boolean;
|
|
59
|
+
id?: string;
|
|
60
|
+
name?: string;
|
|
61
|
+
opacity?: number;
|
|
62
|
+
scale?: Vector2d;
|
|
63
|
+
scaleX?: number;
|
|
64
|
+
skewX?: number;
|
|
65
|
+
skewY?: number;
|
|
66
|
+
scaleY?: number;
|
|
67
|
+
rotation?: number;
|
|
68
|
+
rotationDeg?: number;
|
|
69
|
+
offset?: Vector2d;
|
|
70
|
+
offsetX?: number;
|
|
71
|
+
offsetY?: number;
|
|
72
|
+
draggable?: boolean;
|
|
73
|
+
dragDistance?: number;
|
|
74
|
+
dragBoundFunc?: (this: Node, pos: Vector2d) => Vector2d;
|
|
75
|
+
preventDefault?: boolean;
|
|
76
|
+
globalCompositeOperation?: "" | "source-over" | "source-in" | "source-out" | "source-atop" | "destination-over" | "destination-in" | "destination-out" | "destination-atop" | "lighter" | "copy" | "xor" | "multiply" | "screen" | "overlay" | "darken" | "lighten" | "color-dodge" | "color-burn" | "hard-light" | "soft-light" | "difference" | "exclusion" | "hue" | "saturation" | "color" | "luminosity";
|
|
77
|
+
filters?: (string | import("../Node.ts").FilterFunction)[];
|
|
78
|
+
}>;
|
|
53
79
|
_getEventNamespace(): string;
|
|
54
80
|
setNodes(nodes?: Array<Node>): this;
|
|
55
81
|
_proxyDrag(node: Node): void;
|
|
56
|
-
getNodes(): Node<
|
|
82
|
+
getNodes(): Node<{
|
|
83
|
+
x?: number;
|
|
84
|
+
y?: number;
|
|
85
|
+
width?: number;
|
|
86
|
+
height?: number;
|
|
87
|
+
visible?: boolean;
|
|
88
|
+
listening?: boolean;
|
|
89
|
+
id?: string;
|
|
90
|
+
name?: string;
|
|
91
|
+
opacity?: number;
|
|
92
|
+
scale?: Vector2d;
|
|
93
|
+
scaleX?: number;
|
|
94
|
+
skewX?: number;
|
|
95
|
+
skewY?: number;
|
|
96
|
+
scaleY?: number;
|
|
97
|
+
rotation?: number;
|
|
98
|
+
rotationDeg?: number;
|
|
99
|
+
offset?: Vector2d;
|
|
100
|
+
offsetX?: number;
|
|
101
|
+
offsetY?: number;
|
|
102
|
+
draggable?: boolean;
|
|
103
|
+
dragDistance?: number;
|
|
104
|
+
dragBoundFunc?: (this: Node, pos: Vector2d) => Vector2d;
|
|
105
|
+
preventDefault?: boolean;
|
|
106
|
+
globalCompositeOperation?: "" | "source-over" | "source-in" | "source-out" | "source-atop" | "destination-over" | "destination-in" | "destination-out" | "destination-atop" | "lighter" | "copy" | "xor" | "multiply" | "screen" | "overlay" | "darken" | "lighten" | "color-dodge" | "color-burn" | "hard-light" | "soft-light" | "difference" | "exclusion" | "hue" | "saturation" | "color" | "luminosity";
|
|
107
|
+
filters?: (string | import("../Node.ts").FilterFunction)[];
|
|
108
|
+
}>[];
|
|
57
109
|
getActiveAnchor(): string | null;
|
|
58
110
|
detach(): void;
|
|
59
111
|
_resetTransformCache(): void;
|