konva 8.4.1 → 8.4.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.
Files changed (83) hide show
  1. package/cmj/Context.d.ts +10 -9
  2. package/cmj/Context.js +9 -9
  3. package/cmj/Global.js +1 -1
  4. package/cmj/Shape.d.ts +2 -0
  5. package/cmj/shapes/Arc.d.ts +4 -3
  6. package/cmj/shapes/Arrow.d.ts +3 -2
  7. package/cmj/shapes/Circle.d.ts +4 -3
  8. package/cmj/shapes/Ellipse.d.ts +4 -3
  9. package/cmj/shapes/Image.d.ts +2 -2
  10. package/cmj/shapes/Label.d.ts +3 -2
  11. package/cmj/shapes/RegularPolygon.d.ts +4 -3
  12. package/cmj/shapes/Ring.d.ts +4 -3
  13. package/cmj/shapes/Sprite.d.ts +4 -3
  14. package/cmj/shapes/Star.d.ts +4 -3
  15. package/cmj/shapes/Text.d.ts +6 -5
  16. package/cmj/shapes/Text.js +3 -3
  17. package/cmj/shapes/TextPath.d.ts +5 -4
  18. package/cmj/shapes/Transformer.d.ts +2 -2
  19. package/cmj/shapes/Transformer.js +8 -1
  20. package/cmj/shapes/Wedge.d.ts +4 -3
  21. package/konva.js +37 -16
  22. package/konva.min.js +3 -3
  23. package/lib/Animation.d.ts +2 -2
  24. package/lib/Canvas.d.ts +1 -1
  25. package/lib/Container.d.ts +4 -4
  26. package/lib/Context.d.ts +13 -12
  27. package/lib/Context.js +9 -9
  28. package/lib/Core.d.ts +2 -2
  29. package/lib/DragAndDrop.d.ts +3 -3
  30. package/lib/FastLayer.d.ts +1 -1
  31. package/lib/Global.js +1 -1
  32. package/lib/Group.d.ts +3 -3
  33. package/lib/Layer.d.ts +9 -9
  34. package/lib/Node.d.ts +8 -8
  35. package/lib/PointerEvents.d.ts +4 -4
  36. package/lib/Shape.d.ts +6 -4
  37. package/lib/Stage.d.ts +7 -7
  38. package/lib/Tween.d.ts +2 -2
  39. package/lib/Util.d.ts +2 -2
  40. package/lib/_CoreInternals.d.ts +29 -29
  41. package/lib/_FullInternals.d.ts +67 -67
  42. package/lib/filters/Blur.d.ts +1 -1
  43. package/lib/filters/Brighten.d.ts +1 -1
  44. package/lib/filters/Contrast.d.ts +1 -1
  45. package/lib/filters/Emboss.d.ts +1 -1
  46. package/lib/filters/Enhance.d.ts +1 -1
  47. package/lib/filters/Grayscale.d.ts +1 -1
  48. package/lib/filters/HSL.d.ts +1 -1
  49. package/lib/filters/HSV.d.ts +1 -1
  50. package/lib/filters/Invert.d.ts +1 -1
  51. package/lib/filters/Kaleidoscope.d.ts +1 -1
  52. package/lib/filters/Mask.d.ts +1 -1
  53. package/lib/filters/Noise.d.ts +1 -1
  54. package/lib/filters/Pixelate.d.ts +1 -1
  55. package/lib/filters/Posterize.d.ts +1 -1
  56. package/lib/filters/RGB.d.ts +1 -1
  57. package/lib/filters/RGBA.d.ts +1 -1
  58. package/lib/filters/Sepia.d.ts +1 -1
  59. package/lib/filters/Solarize.d.ts +1 -1
  60. package/lib/filters/Threshold.d.ts +1 -1
  61. package/lib/index-node.d.ts +1 -1
  62. package/lib/index-types.d.ts +124 -124
  63. package/lib/index.d.ts +1 -1
  64. package/lib/shapes/Arc.d.ts +6 -5
  65. package/lib/shapes/Arrow.d.ts +5 -4
  66. package/lib/shapes/Circle.d.ts +6 -5
  67. package/lib/shapes/Ellipse.d.ts +6 -5
  68. package/lib/shapes/Image.d.ts +5 -5
  69. package/lib/shapes/Label.d.ts +8 -7
  70. package/lib/shapes/Line.d.ts +3 -3
  71. package/lib/shapes/Path.d.ts +2 -2
  72. package/lib/shapes/Rect.d.ts +3 -3
  73. package/lib/shapes/RegularPolygon.d.ts +6 -5
  74. package/lib/shapes/Ring.d.ts +6 -5
  75. package/lib/shapes/Sprite.d.ts +7 -6
  76. package/lib/shapes/Star.d.ts +6 -5
  77. package/lib/shapes/Text.d.ts +8 -7
  78. package/lib/shapes/Text.js +3 -3
  79. package/lib/shapes/TextPath.d.ts +7 -6
  80. package/lib/shapes/Transformer.d.ts +10 -10
  81. package/lib/shapes/Transformer.js +8 -1
  82. package/lib/shapes/Wedge.d.ts +6 -5
  83. package/package.json +1 -1
@@ -1,13 +1,14 @@
1
- import { Shape, ShapeConfig } from '../Shape';
2
- import { GetSet } from '../types';
1
+ import { Shape, ShapeConfig } from '../Shape.js';
2
+ import { GetSet } from '../types.js';
3
+ import { Context } from '../Context.js';
3
4
  export interface CircleConfig extends ShapeConfig {
4
5
  radius?: number;
5
6
  }
6
7
  export declare class Circle extends Shape<CircleConfig> {
7
- _sceneFunc(context: any): void;
8
+ _sceneFunc(context: Context): void;
8
9
  getWidth(): number;
9
10
  getHeight(): number;
10
- setWidth(width: any): void;
11
- setHeight(height: any): void;
11
+ setWidth(width: number): void;
12
+ setHeight(height: number): void;
12
13
  radius: GetSet<number, this>;
13
14
  }
@@ -1,15 +1,16 @@
1
- import { Shape, ShapeConfig } from '../Shape';
2
- import { GetSet, Vector2d } from '../types';
1
+ import { Shape, ShapeConfig } from '../Shape.js';
2
+ import { Context } from '../Context.js';
3
+ import { GetSet, Vector2d } from '../types.js';
3
4
  export interface EllipseConfig extends ShapeConfig {
4
5
  radiusX: number;
5
6
  radiusY: number;
6
7
  }
7
8
  export declare class Ellipse extends Shape<EllipseConfig> {
8
- _sceneFunc(context: any): void;
9
+ _sceneFunc(context: Context): void;
9
10
  getWidth(): number;
10
11
  getHeight(): number;
11
- setWidth(width: any): void;
12
- setHeight(height: any): void;
12
+ setWidth(width: number): void;
13
+ setHeight(height: number): void;
13
14
  radius: GetSet<Vector2d, this>;
14
15
  radiusX: GetSet<number, this>;
15
16
  radiusY: GetSet<number, this>;
@@ -1,6 +1,6 @@
1
- import { Shape, ShapeConfig } from '../Shape';
2
- import { GetSet, IRect } from '../types';
3
- import { Context } from '../Context';
1
+ import { Shape, ShapeConfig } from '../Shape.js';
2
+ import { GetSet, IRect } from '../types.js';
3
+ import { Context } from '../Context.js';
4
4
  export interface ImageConfig extends ShapeConfig {
5
5
  image: CanvasImageSource | undefined;
6
6
  crop?: IRect;
@@ -11,10 +11,10 @@ export declare class Image extends Shape<ImageConfig> {
11
11
  _setImageLoad(): void;
12
12
  _useBufferCanvas(): boolean;
13
13
  _sceneFunc(context: Context): void;
14
- _hitFunc(context: any): void;
14
+ _hitFunc(context: Context): void;
15
15
  getWidth(): any;
16
16
  getHeight(): any;
17
- static fromURL(url: any, callback: any, onError?: any): void;
17
+ static fromURL(url: string, callback: (img: Image) => void, onError?: OnErrorEventHandler): void;
18
18
  image: GetSet<CanvasImageSource | undefined, this>;
19
19
  crop: GetSet<IRect, this>;
20
20
  cropX: GetSet<number, this>;
@@ -1,12 +1,13 @@
1
- import { Shape, ShapeConfig } from '../Shape';
2
- import { Group } from '../Group';
3
- import { ContainerConfig } from '../Container';
4
- import { GetSet } from '../types';
5
- import { Text } from './Text';
1
+ import { Shape, ShapeConfig } from '../Shape.js';
2
+ import { Group } from '../Group.js';
3
+ import { Context } from '../Context.js';
4
+ import { ContainerConfig } from '../Container.js';
5
+ import { GetSet } from '../types.js';
6
+ import { Text } from './Text.js';
6
7
  export interface LabelConfig extends ContainerConfig {
7
8
  }
8
9
  export declare class Label extends Group {
9
- constructor(config?: any);
10
+ constructor(config?: LabelConfig);
10
11
  getText(): Text;
11
12
  getTag(): Tag;
12
13
  _addListeners(text: any): void;
@@ -21,7 +22,7 @@ export interface TagConfig extends ShapeConfig {
21
22
  cornerRadius?: number | Array<number>;
22
23
  }
23
24
  export declare class Tag extends Shape<TagConfig> {
24
- _sceneFunc(context: any): void;
25
+ _sceneFunc(context: Context): void;
25
26
  getSelfRect(): {
26
27
  x: number;
27
28
  y: number;
@@ -1,6 +1,6 @@
1
- import { Shape, ShapeConfig } from '../Shape';
2
- import { GetSet } from '../types';
3
- import { Context } from '../Context';
1
+ import { Shape, ShapeConfig } from '../Shape.js';
2
+ import { GetSet } from '../types.js';
3
+ import { Context } from '../Context.js';
4
4
  export interface LineConfig extends ShapeConfig {
5
5
  points?: number[] | Int8Array | Uint8Array | Uint8ClampedArray | Int16Array | Uint16Array | Int32Array | Uint32Array | Float32Array | Float64Array;
6
6
  tension?: number;
@@ -1,5 +1,5 @@
1
- import { Shape, ShapeConfig } from '../Shape';
2
- import { GetSet } from '../types';
1
+ import { Shape, ShapeConfig } from '../Shape.js';
2
+ import { GetSet } from '../types.js';
3
3
  export interface PathConfig extends ShapeConfig {
4
4
  data?: string;
5
5
  }
@@ -1,6 +1,6 @@
1
- import { Shape, ShapeConfig } from '../Shape';
2
- import { GetSet } from '../types';
3
- import { Context } from '../Context';
1
+ import { Shape, ShapeConfig } from '../Shape.js';
2
+ import { GetSet } from '../types.js';
3
+ import { Context } from '../Context.js';
4
4
  export interface RectConfig extends ShapeConfig {
5
5
  cornerRadius?: number | number[];
6
6
  }
@@ -1,11 +1,12 @@
1
- import { Shape, ShapeConfig } from '../Shape';
2
- import { GetSet } from '../types';
1
+ import { Shape, ShapeConfig } from '../Shape.js';
2
+ import { GetSet } from '../types.js';
3
+ import { Context } from '../Context.js';
3
4
  export interface RegularPolygonConfig extends ShapeConfig {
4
5
  sides: number;
5
6
  radius: number;
6
7
  }
7
8
  export declare class RegularPolygon extends Shape<RegularPolygonConfig> {
8
- _sceneFunc(context: any): void;
9
+ _sceneFunc(context: Context): void;
9
10
  _getPoints(): any[];
10
11
  getSelfRect(): {
11
12
  x: any;
@@ -15,8 +16,8 @@ export declare class RegularPolygon extends Shape<RegularPolygonConfig> {
15
16
  };
16
17
  getWidth(): number;
17
18
  getHeight(): number;
18
- setWidth(width: any): void;
19
- setHeight(height: any): void;
19
+ setWidth(width: number): void;
20
+ setHeight(height: number): void;
20
21
  radius: GetSet<number, this>;
21
22
  sides: GetSet<number, this>;
22
23
  }
@@ -1,15 +1,16 @@
1
- import { Shape, ShapeConfig } from '../Shape';
2
- import { GetSet } from '../types';
1
+ import { Shape, ShapeConfig } from '../Shape.js';
2
+ import { GetSet } from '../types.js';
3
+ import { Context } from '../Context.js';
3
4
  export interface RingConfig extends ShapeConfig {
4
5
  innerRadius: number;
5
6
  outerRadius: number;
6
7
  }
7
8
  export declare class Ring extends Shape<RingConfig> {
8
- _sceneFunc(context: any): void;
9
+ _sceneFunc(context: Context): void;
9
10
  getWidth(): number;
10
11
  getHeight(): number;
11
- setWidth(width: any): void;
12
- setHeight(height: any): void;
12
+ setWidth(width: number): void;
13
+ setHeight(height: number): void;
13
14
  outerRadius: GetSet<number, this>;
14
15
  innerRadius: GetSet<number, this>;
15
16
  }
@@ -1,6 +1,7 @@
1
- import { Shape, ShapeConfig } from '../Shape';
2
- import { Animation } from '../Animation';
3
- import { GetSet } from '../types';
1
+ import { Context } from '../Context.js';
2
+ import { Shape, ShapeConfig } from '../Shape.js';
3
+ import { Animation } from '../Animation.js';
4
+ import { GetSet } from '../types.js';
4
5
  export interface SpriteConfig extends ShapeConfig {
5
6
  animation: string;
6
7
  animations: any;
@@ -12,9 +13,9 @@ export declare class Sprite extends Shape<SpriteConfig> {
12
13
  _updated: boolean;
13
14
  anim: Animation;
14
15
  interval: any;
15
- constructor(config: any);
16
- _sceneFunc(context: any): void;
17
- _hitFunc(context: any): void;
16
+ constructor(config: SpriteConfig);
17
+ _sceneFunc(context: Context): void;
18
+ _hitFunc(context: Context): void;
18
19
  _useBufferCanvas(): boolean;
19
20
  _setInterval(): void;
20
21
  start(): void;
@@ -1,16 +1,17 @@
1
- import { Shape, ShapeConfig } from '../Shape';
2
- import { GetSet } from '../types';
1
+ import { Context } from '../Context.js';
2
+ import { Shape, ShapeConfig } from '../Shape.js';
3
+ import { GetSet } from '../types.js';
3
4
  export interface StarConfig extends ShapeConfig {
4
5
  numPoints: number;
5
6
  innerRadius: number;
6
7
  outerRadius: number;
7
8
  }
8
9
  export declare class Star extends Shape<StarConfig> {
9
- _sceneFunc(context: any): void;
10
+ _sceneFunc(context: Context): void;
10
11
  getWidth(): number;
11
12
  getHeight(): number;
12
- setWidth(width: any): void;
13
- setHeight(height: any): void;
13
+ setWidth(width: number): void;
14
+ setHeight(height: number): void;
14
15
  outerRadius: GetSet<number, this>;
15
16
  innerRadius: GetSet<number, this>;
16
17
  numPoints: GetSet<number, this>;
@@ -1,5 +1,6 @@
1
- import { Shape, ShapeConfig } from '../Shape';
2
- import { GetSet } from '../types';
1
+ import { Context } from '../Context.js';
2
+ import { Shape, ShapeConfig } from '../Shape.js';
3
+ import { GetSet } from '../types.js';
3
4
  export declare function stringToArray(string: string): string[];
4
5
  export interface TextConfig extends ShapeConfig {
5
6
  text?: string;
@@ -28,9 +29,9 @@ export declare class Text extends Shape<TextConfig> {
28
29
  textWidth: number;
29
30
  textHeight: number;
30
31
  constructor(config?: TextConfig);
31
- _sceneFunc(context: any): void;
32
- _hitFunc(context: any): void;
33
- setText(text: any): this;
32
+ _sceneFunc(context: Context): void;
33
+ _hitFunc(context: Context): void;
34
+ setText(text: string): this;
34
35
  getWidth(): any;
35
36
  getHeight(): any;
36
37
  getTextWidth(): number;
@@ -40,8 +41,8 @@ export declare class Text extends Shape<TextConfig> {
40
41
  height: number;
41
42
  };
42
43
  _getContextFont(): string;
43
- _addTextLine(line: any): number;
44
- _getTextWidth(text: any): any;
44
+ _addTextLine(line: string): number;
45
+ _getTextWidth(text: string): number;
45
46
  _setTextData(): void;
46
47
  _shouldHandleEllipsis(currentHeightPx: number): boolean;
47
48
  _tryToAddEllipsisToLastLine(): void;
@@ -305,12 +305,12 @@ export class Text extends Shape {
305
305
  this._tryToAddEllipsisToLastLine();
306
306
  }
307
307
  }
308
- if (fixedHeight && currentHeightPx + lineHeightPx > maxHeightPx) {
309
- break;
310
- }
311
308
  if (this.textArr[this.textArr.length - 1]) {
312
309
  this.textArr[this.textArr.length - 1].lastInParagraph = true;
313
310
  }
311
+ if (fixedHeight && currentHeightPx + lineHeightPx > maxHeightPx) {
312
+ break;
313
+ }
314
314
  }
315
315
  this.textHeight = fontSize;
316
316
  this.textWidth = textWidth;
@@ -1,5 +1,6 @@
1
- import { Shape, ShapeConfig } from '../Shape';
2
- import { GetSet, Vector2d } from '../types';
1
+ import { Context } from '../Context.js';
2
+ import { Shape, ShapeConfig } from '../Shape.js';
3
+ import { GetSet, Vector2d } from '../types.js';
3
4
  export interface TextPathConfig extends ShapeConfig {
4
5
  text?: string;
5
6
  data?: string;
@@ -23,13 +24,13 @@ export declare class TextPath extends Shape<TextPathConfig> {
23
24
  textWidth: number;
24
25
  textHeight: number;
25
26
  constructor(config?: TextPathConfig);
26
- _sceneFunc(context: any): void;
27
- _hitFunc(context: any): void;
27
+ _sceneFunc(context: Context): void;
28
+ _hitFunc(context: Context): void;
28
29
  getTextWidth(): number;
29
30
  getTextHeight(): number;
30
- setText(text: any): any;
31
+ setText(text: string): any;
31
32
  _getContextFont(): any;
32
- _getTextSize(text: any): {
33
+ _getTextSize(text: string): {
33
34
  width: number;
34
35
  height: number;
35
36
  };
@@ -1,9 +1,9 @@
1
- import { Transform } from '../Util';
2
- import { Node } from '../Node';
3
- import { Rect } from './Rect';
4
- import { Group } from '../Group';
5
- import { ContainerConfig } from '../Container';
6
- import { GetSet, IRect, Vector2d } from '../types';
1
+ import { Transform } from '../Util.js';
2
+ import { Node } from '../Node.js';
3
+ import { Rect } from './Rect.js';
4
+ import { Group } from '../Group.js';
5
+ import { ContainerConfig } from '../Container.js';
6
+ import { GetSet, IRect, Vector2d } from '../types.js';
7
7
  export interface Box extends IRect {
8
8
  rotation: number;
9
9
  }
@@ -41,13 +41,13 @@ export declare class Transformer extends Group {
41
41
  cos: number;
42
42
  _cursorChange: boolean;
43
43
  constructor(config?: TransformerConfig);
44
- attachTo(node: any): this;
45
- setNode(node: any): this;
46
- getNode(): Node<import("../Node").NodeConfig>;
44
+ attachTo(node: Node): this;
45
+ setNode(node: Node): this;
46
+ getNode(): Node<import("../Node.js").NodeConfig>;
47
47
  _getEventNamespace(): string;
48
48
  setNodes(nodes?: Array<Node>): this;
49
49
  _proxyDrag(node: Node): void;
50
- getNodes(): Node<import("../Node").NodeConfig>[];
50
+ getNodes(): Node<import("../Node.js").NodeConfig>[];
51
51
  getActiveAnchor(): string;
52
52
  detach(): void;
53
53
  _resetTransformCache(): void;
@@ -164,7 +164,14 @@ export class Transformer extends Group {
164
164
  if (this._nodes && this._nodes.length) {
165
165
  this.detach();
166
166
  }
167
- this._nodes = nodes;
167
+ const filteredNodes = nodes.filter((node) => {
168
+ if (node.isAncestorOf(this)) {
169
+ Util.error('Konva.Transformer cannot be an a child of the node you are trying to attach');
170
+ return false;
171
+ }
172
+ return true;
173
+ });
174
+ this._nodes = nodes = filteredNodes;
168
175
  if (nodes.length === 1 && this.useSingleNodeRotation()) {
169
176
  this.rotation(nodes[0].getAbsoluteRotation());
170
177
  }
@@ -1,16 +1,17 @@
1
- import { Shape, ShapeConfig } from '../Shape';
2
- import { GetSet } from '../types';
1
+ import { Context } from '../Context.js';
2
+ import { Shape, ShapeConfig } from '../Shape.js';
3
+ import { GetSet } from '../types.js';
3
4
  export interface WedgeConfig extends ShapeConfig {
4
5
  angle: number;
5
6
  radius: number;
6
7
  clockwise?: boolean;
7
8
  }
8
9
  export declare class Wedge extends Shape<WedgeConfig> {
9
- _sceneFunc(context: any): void;
10
+ _sceneFunc(context: Context): void;
10
11
  getWidth(): number;
11
12
  getHeight(): number;
12
- setWidth(width: any): void;
13
- setHeight(height: any): void;
13
+ setWidth(width: number): void;
14
+ setHeight(height: number): void;
14
15
  radius: GetSet<number, this>;
15
16
  angle: GetSet<number, this>;
16
17
  clockwise: GetSet<boolean, this>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "konva",
3
- "version": "8.4.1",
3
+ "version": "8.4.3",
4
4
  "author": "Anton Lavrenov",
5
5
  "files": [
6
6
  "README.md",