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
package/cmj/Context.d.ts CHANGED
@@ -1,6 +1,7 @@
1
1
  import { Canvas } from './Canvas';
2
2
  import { Shape } from './Shape';
3
3
  import { IRect } from './types';
4
+ import type { Node } from './Node';
4
5
  declare var CONTEXT_PROPERTIES: readonly ["fillStyle", "strokeStyle", "shadowColor", "shadowBlur", "shadowOffsetX", "shadowOffsetY", "lineCap", "lineDashOffset", "lineJoin", "lineWidth", "miterLimit", "font", "textAlign", "textBaseline", "globalAlpha", "globalCompositeOperation", "imageSmoothingEnabled"];
5
6
  export declare class Context {
6
7
  canvas: Canvas;
@@ -10,16 +11,16 @@ export declare class Context {
10
11
  fillShape(shape: Shape): void;
11
12
  _fill(shape: Shape): void;
12
13
  strokeShape(shape: Shape): void;
13
- _stroke(shape: any): void;
14
+ _stroke(shape: Shape): void;
14
15
  fillStrokeShape(shape: Shape): void;
15
- getTrace(relaxed?: any, rounded?: any): string;
16
+ getTrace(relaxed?: boolean, rounded?: boolean): string;
16
17
  clearTrace(): void;
17
18
  _trace(str: any): void;
18
19
  reset(): void;
19
20
  getCanvas(): Canvas;
20
21
  clear(bounds?: IRect): void;
21
- _applyLineCap(shape: any): void;
22
- _applyOpacity(shape: any): void;
22
+ _applyLineCap(shape: Shape): void;
23
+ _applyOpacity(shape: Node): void;
23
24
  _applyLineJoin(shape: Shape): void;
24
25
  setAttr(attr: string, val: any): void;
25
26
  arc(a0: number, a1: number, a2: number, a3: number, a4: number, a5?: boolean): void;
@@ -55,7 +56,7 @@ export declare class Context {
55
56
  getLineDash(): number[];
56
57
  setTransform(a0: number, a1: number, a2: number, a3: number, a4: number, a5: number): void;
57
58
  stroke(path2d?: Path2D): void;
58
- strokeText(a0: string, a1: number, a2: number, a3: number): void;
59
+ strokeText(a0: string, a1: number, a2: number, a3?: number): void;
59
60
  transform(a0: number, a1: number, a2: number, a3: number, a4: number, a5: number): void;
60
61
  translate(a0: number, a1: number): void;
61
62
  _enableTrace(): void;
@@ -67,9 +68,9 @@ export interface Context extends CanvasContextProps {
67
68
  export declare class SceneContext extends Context {
68
69
  constructor(canvas: Canvas);
69
70
  _fillColor(shape: Shape): void;
70
- _fillPattern(shape: any): void;
71
- _fillLinearGradient(shape: any): void;
72
- _fillRadialGradient(shape: any): void;
71
+ _fillPattern(shape: Shape): void;
72
+ _fillLinearGradient(shape: Shape): void;
73
+ _fillRadialGradient(shape: Shape): void;
73
74
  _fill(shape: any): void;
74
75
  _strokeLinearGradient(shape: any): void;
75
76
  _stroke(shape: any): void;
@@ -77,7 +78,7 @@ export declare class SceneContext extends Context {
77
78
  }
78
79
  export declare class HitContext extends Context {
79
80
  constructor(canvas: Canvas);
80
- _fill(shape: any): void;
81
+ _fill(shape: Shape): void;
81
82
  strokeShape(shape: Shape): void;
82
83
  _stroke(shape: any): void;
83
84
  }
package/cmj/Context.js CHANGED
@@ -163,7 +163,7 @@ class Context {
163
163
  }
164
164
  }
165
165
  _applyLineCap(shape) {
166
- var lineCap = shape.getLineCap();
166
+ const lineCap = shape.attrs.lineCap;
167
167
  if (lineCap) {
168
168
  this.setAttr('lineCap', lineCap);
169
169
  }
@@ -175,7 +175,7 @@ class Context {
175
175
  }
176
176
  }
177
177
  _applyLineJoin(shape) {
178
- var lineJoin = shape.attrs.lineJoin;
178
+ const lineJoin = shape.attrs.lineJoin;
179
179
  if (lineJoin) {
180
180
  this.setAttr('lineJoin', lineJoin);
181
181
  }
@@ -405,29 +405,29 @@ class SceneContext extends Context {
405
405
  }
406
406
  }
407
407
  _fillRadialGradient(shape) {
408
- var grd = shape._getRadialGradient();
408
+ const grd = shape._getRadialGradient();
409
409
  if (grd) {
410
410
  this.setAttr('fillStyle', grd);
411
411
  shape._fillFunc(this);
412
412
  }
413
413
  }
414
414
  _fill(shape) {
415
- var hasColor = shape.fill(), fillPriority = shape.getFillPriority();
415
+ const hasColor = shape.fill(), fillPriority = shape.getFillPriority();
416
416
  if (hasColor && fillPriority === 'color') {
417
417
  this._fillColor(shape);
418
418
  return;
419
419
  }
420
- var hasPattern = shape.getFillPatternImage();
420
+ const hasPattern = shape.getFillPatternImage();
421
421
  if (hasPattern && fillPriority === 'pattern') {
422
422
  this._fillPattern(shape);
423
423
  return;
424
424
  }
425
- var hasLinearGradient = shape.getFillLinearGradientColorStops();
425
+ const hasLinearGradient = shape.getFillLinearGradientColorStops();
426
426
  if (hasLinearGradient && fillPriority === 'linear-gradient') {
427
427
  this._fillLinearGradient(shape);
428
428
  return;
429
429
  }
430
- var hasRadialGradient = shape.getFillRadialGradientColorStops();
430
+ const hasRadialGradient = shape.getFillRadialGradientColorStops();
431
431
  if (hasRadialGradient && fillPriority === 'radial-gradient') {
432
432
  this._fillRadialGradient(shape);
433
433
  return;
@@ -446,7 +446,7 @@ class SceneContext extends Context {
446
446
  }
447
447
  }
448
448
  _strokeLinearGradient(shape) {
449
- var start = shape.getStrokeLinearGradientStartPoint(), end = shape.getStrokeLinearGradientEndPoint(), colorStops = shape.getStrokeLinearGradientColorStops(), grd = this.createLinearGradient(start.x, start.y, end.x, end.y);
449
+ const start = shape.getStrokeLinearGradientStartPoint(), end = shape.getStrokeLinearGradientEndPoint(), colorStops = shape.getStrokeLinearGradientColorStops(), grd = this.createLinearGradient(start.x, start.y, end.x, end.y);
450
450
  if (colorStops) {
451
451
  for (var n = 0; n < colorStops.length; n += 2) {
452
452
  grd.addColorStop(colorStops[n], colorStops[n + 1]);
@@ -517,7 +517,7 @@ class HitContext extends Context {
517
517
  }
518
518
  _stroke(shape) {
519
519
  if (shape.hasHitStroke()) {
520
- var strokeScaleEnabled = shape.getStrokeScaleEnabled();
520
+ const strokeScaleEnabled = shape.getStrokeScaleEnabled();
521
521
  if (!strokeScaleEnabled) {
522
522
  this.save();
523
523
  var pixelRatio = this.getCanvas().getPixelRatio();
package/cmj/Global.js CHANGED
@@ -16,7 +16,7 @@ exports.glob = typeof global !== 'undefined'
16
16
  : {};
17
17
  exports.Konva = {
18
18
  _global: exports.glob,
19
- version: '8.4.1',
19
+ version: '8.4.3',
20
20
  isBrowser: detectBrowser(),
21
21
  isUnminified: /param/.test(function (param) { }.toString()),
22
22
  dblClickWindow: 400,
package/cmj/Shape.d.ts CHANGED
@@ -180,5 +180,7 @@ export declare class Shape<Config extends ShapeConfig = ShapeConfig> extends Nod
180
180
  strokeHitEnabled: GetSet<boolean, this>;
181
181
  strokeWidth: GetSet<number, this>;
182
182
  hitStrokeWidth: GetSet<number | 'auto', this>;
183
+ strokeLinearGradientStartPoint: GetSet<Vector2d, this>;
184
+ strokeLinearGradientEndPoint: GetSet<Vector2d, this>;
183
185
  strokeLinearGradientColorStops: GetSet<Array<number | string>, this>;
184
186
  }
@@ -1,5 +1,6 @@
1
1
  import { Shape, ShapeConfig } from '../Shape';
2
2
  import { GetSet } from '../types';
3
+ import { Context } from '../Context';
3
4
  export interface ArcConfig extends ShapeConfig {
4
5
  angle: number;
5
6
  innerRadius: number;
@@ -7,11 +8,11 @@ export interface ArcConfig extends ShapeConfig {
7
8
  clockwise?: boolean;
8
9
  }
9
10
  export declare class Arc extends Shape<ArcConfig> {
10
- _sceneFunc(context: any): void;
11
+ _sceneFunc(context: Context): void;
11
12
  getWidth(): number;
12
13
  getHeight(): number;
13
- setWidth(width: any): void;
14
- setHeight(height: any): void;
14
+ setWidth(width: number): void;
15
+ setHeight(height: number): void;
15
16
  getSelfRect(): {
16
17
  x: number;
17
18
  y: number;
@@ -1,5 +1,6 @@
1
1
  import { Line, LineConfig } from './Line';
2
2
  import { GetSet } from '../types';
3
+ import { Context } from '../Context';
3
4
  export interface ArrowConfig extends LineConfig {
4
5
  points: number[];
5
6
  tension?: number;
@@ -10,8 +11,8 @@ export interface ArrowConfig extends LineConfig {
10
11
  pointerAtEnding?: boolean;
11
12
  }
12
13
  export declare class Arrow extends Line<ArrowConfig> {
13
- _sceneFunc(ctx: any): void;
14
- __fillStroke(ctx: any): void;
14
+ _sceneFunc(ctx: Context): void;
15
+ __fillStroke(ctx: Context): void;
15
16
  getSelfRect(): {
16
17
  x: number;
17
18
  y: number;
@@ -1,13 +1,14 @@
1
1
  import { Shape, ShapeConfig } from '../Shape';
2
2
  import { GetSet } from '../types';
3
+ import { Context } from '../Context';
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
1
  import { Shape, ShapeConfig } from '../Shape';
2
+ import { Context } from '../Context';
2
3
  import { GetSet, Vector2d } from '../types';
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>;
@@ -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
1
  import { Shape, ShapeConfig } from '../Shape';
2
2
  import { Group } from '../Group';
3
+ import { Context } from '../Context';
3
4
  import { ContainerConfig } from '../Container';
4
5
  import { GetSet } from '../types';
5
6
  import { Text } from './Text';
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,11 +1,12 @@
1
1
  import { Shape, ShapeConfig } from '../Shape';
2
2
  import { GetSet } from '../types';
3
+ import { Context } from '../Context';
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
1
  import { Shape, ShapeConfig } from '../Shape';
2
2
  import { GetSet } from '../types';
3
+ import { Context } from '../Context';
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,3 +1,4 @@
1
+ import { Context } from '../Context';
1
2
  import { Shape, ShapeConfig } from '../Shape';
2
3
  import { Animation } from '../Animation';
3
4
  import { GetSet } from '../types';
@@ -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,3 +1,4 @@
1
+ import { Context } from '../Context';
1
2
  import { Shape, ShapeConfig } from '../Shape';
2
3
  import { GetSet } from '../types';
3
4
  export interface StarConfig extends ShapeConfig {
@@ -6,11 +7,11 @@ export interface StarConfig extends ShapeConfig {
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,3 +1,4 @@
1
+ import { Context } from '../Context';
1
2
  import { Shape, ShapeConfig } from '../Shape';
2
3
  import { GetSet } from '../types';
3
4
  export declare function stringToArray(string: string): 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;
@@ -309,12 +309,12 @@ class Text extends Shape_1.Shape {
309
309
  this._tryToAddEllipsisToLastLine();
310
310
  }
311
311
  }
312
- if (fixedHeight && currentHeightPx + lineHeightPx > maxHeightPx) {
313
- break;
314
- }
315
312
  if (this.textArr[this.textArr.length - 1]) {
316
313
  this.textArr[this.textArr.length - 1].lastInParagraph = true;
317
314
  }
315
+ if (fixedHeight && currentHeightPx + lineHeightPx > maxHeightPx) {
316
+ break;
317
+ }
318
318
  }
319
319
  this.textHeight = fontSize;
320
320
  this.textWidth = textWidth;
@@ -1,3 +1,4 @@
1
+ import { Context } from '../Context';
1
2
  import { Shape, ShapeConfig } from '../Shape';
2
3
  import { GetSet, Vector2d } from '../types';
3
4
  export interface TextPathConfig extends ShapeConfig {
@@ -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
  };
@@ -41,8 +41,8 @@ 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;
44
+ attachTo(node: Node): this;
45
+ setNode(node: Node): this;
46
46
  getNode(): Node<import("../Node").NodeConfig>;
47
47
  _getEventNamespace(): string;
48
48
  setNodes(nodes?: Array<Node>): this;
@@ -167,7 +167,14 @@ class Transformer extends Group_1.Group {
167
167
  if (this._nodes && this._nodes.length) {
168
168
  this.detach();
169
169
  }
170
- this._nodes = nodes;
170
+ const filteredNodes = nodes.filter((node) => {
171
+ if (node.isAncestorOf(this)) {
172
+ Util_1.Util.error('Konva.Transformer cannot be an a child of the node you are trying to attach');
173
+ return false;
174
+ }
175
+ return true;
176
+ });
177
+ this._nodes = nodes = filteredNodes;
171
178
  if (nodes.length === 1 && this.useSingleNodeRotation()) {
172
179
  this.rotation(nodes[0].getAbsoluteRotation());
173
180
  }
@@ -1,3 +1,4 @@
1
+ import { Context } from '../Context';
1
2
  import { Shape, ShapeConfig } from '../Shape';
2
3
  import { GetSet } from '../types';
3
4
  export interface WedgeConfig extends ShapeConfig {
@@ -6,11 +7,11 @@ export interface WedgeConfig extends ShapeConfig {
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/konva.js CHANGED
@@ -5,10 +5,10 @@
5
5
  })(this, (function () { 'use strict';
6
6
 
7
7
  /*
8
- * Konva JavaScript Framework v8.4.1
8
+ * Konva JavaScript Framework v8.4.3
9
9
  * http://konvajs.org/
10
10
  * Licensed under the MIT
11
- * Date: Thu Jan 19 2023
11
+ * Date: Thu Mar 23 2023
12
12
  *
13
13
  * Original work Copyright (C) 2011 - 2013 by Eric Rowell (KineticJS)
14
14
  * Modified work Copyright (C) 2014 - present by Anton Lavrenov (Konva)
@@ -35,7 +35,7 @@
35
35
  : {};
36
36
  const Konva$2 = {
37
37
  _global: glob,
38
- version: '8.4.1',
38
+ version: '8.4.3',
39
39
  isBrowser: detectBrowser(),
40
40
  isUnminified: /param/.test(function (param) { }.toString()),
41
41
  dblClickWindow: 400,
@@ -1652,7 +1652,7 @@
1652
1652
  }
1653
1653
  }
1654
1654
  _applyLineCap(shape) {
1655
- var lineCap = shape.getLineCap();
1655
+ const lineCap = shape.attrs.lineCap;
1656
1656
  if (lineCap) {
1657
1657
  this.setAttr('lineCap', lineCap);
1658
1658
  }
@@ -1664,7 +1664,7 @@
1664
1664
  }
1665
1665
  }
1666
1666
  _applyLineJoin(shape) {
1667
- var lineJoin = shape.attrs.lineJoin;
1667
+ const lineJoin = shape.attrs.lineJoin;
1668
1668
  if (lineJoin) {
1669
1669
  this.setAttr('lineJoin', lineJoin);
1670
1670
  }
@@ -2081,30 +2081,30 @@
2081
2081
  }
2082
2082
  }
2083
2083
  _fillRadialGradient(shape) {
2084
- var grd = shape._getRadialGradient();
2084
+ const grd = shape._getRadialGradient();
2085
2085
  if (grd) {
2086
2086
  this.setAttr('fillStyle', grd);
2087
2087
  shape._fillFunc(this);
2088
2088
  }
2089
2089
  }
2090
2090
  _fill(shape) {
2091
- var hasColor = shape.fill(), fillPriority = shape.getFillPriority();
2091
+ const hasColor = shape.fill(), fillPriority = shape.getFillPriority();
2092
2092
  // priority fills
2093
2093
  if (hasColor && fillPriority === 'color') {
2094
2094
  this._fillColor(shape);
2095
2095
  return;
2096
2096
  }
2097
- var hasPattern = shape.getFillPatternImage();
2097
+ const hasPattern = shape.getFillPatternImage();
2098
2098
  if (hasPattern && fillPriority === 'pattern') {
2099
2099
  this._fillPattern(shape);
2100
2100
  return;
2101
2101
  }
2102
- var hasLinearGradient = shape.getFillLinearGradientColorStops();
2102
+ const hasLinearGradient = shape.getFillLinearGradientColorStops();
2103
2103
  if (hasLinearGradient && fillPriority === 'linear-gradient') {
2104
2104
  this._fillLinearGradient(shape);
2105
2105
  return;
2106
2106
  }
2107
- var hasRadialGradient = shape.getFillRadialGradientColorStops();
2107
+ const hasRadialGradient = shape.getFillRadialGradientColorStops();
2108
2108
  if (hasRadialGradient && fillPriority === 'radial-gradient') {
2109
2109
  this._fillRadialGradient(shape);
2110
2110
  return;
@@ -2124,7 +2124,7 @@
2124
2124
  }
2125
2125
  }
2126
2126
  _strokeLinearGradient(shape) {
2127
- var start = shape.getStrokeLinearGradientStartPoint(), end = shape.getStrokeLinearGradientEndPoint(), colorStops = shape.getStrokeLinearGradientColorStops(), grd = this.createLinearGradient(start.x, start.y, end.x, end.y);
2127
+ const start = shape.getStrokeLinearGradientStartPoint(), end = shape.getStrokeLinearGradientEndPoint(), colorStops = shape.getStrokeLinearGradientColorStops(), grd = this.createLinearGradient(start.x, start.y, end.x, end.y);
2128
2128
  if (colorStops) {
2129
2129
  // build color stops
2130
2130
  for (var n = 0; n < colorStops.length; n += 2) {
@@ -2198,7 +2198,7 @@
2198
2198
  _stroke(shape) {
2199
2199
  if (shape.hasHitStroke()) {
2200
2200
  // ignore strokeScaleEnabled for Text
2201
- var strokeScaleEnabled = shape.getStrokeScaleEnabled();
2201
+ const strokeScaleEnabled = shape.getStrokeScaleEnabled();
2202
2202
  if (!strokeScaleEnabled) {
2203
2203
  this.save();
2204
2204
  var pixelRatio = this.getCanvas().getPixelRatio();
@@ -13753,12 +13753,12 @@
13753
13753
  }
13754
13754
  }
13755
13755
  // if element height is fixed, abort if adding one more line would overflow
13756
- if (fixedHeight && currentHeightPx + lineHeightPx > maxHeightPx) {
13757
- break;
13758
- }
13759
13756
  if (this.textArr[this.textArr.length - 1]) {
13760
13757
  this.textArr[this.textArr.length - 1].lastInParagraph = true;
13761
13758
  }
13759
+ if (fixedHeight && currentHeightPx + lineHeightPx > maxHeightPx) {
13760
+ break;
13761
+ }
13762
13762
  }
13763
13763
  this.textHeight = fontSize;
13764
13764
  // var maxTextWidth = 0;
@@ -14893,7 +14893,15 @@
14893
14893
  if (this._nodes && this._nodes.length) {
14894
14894
  this.detach();
14895
14895
  }
14896
- this._nodes = nodes;
14896
+ const filteredNodes = nodes.filter((node) => {
14897
+ // check if ancestor of the transformer
14898
+ if (node.isAncestorOf(this)) {
14899
+ Util.error('Konva.Transformer cannot be an a child of the node you are trying to attach');
14900
+ return false;
14901
+ }
14902
+ return true;
14903
+ });
14904
+ this._nodes = nodes = filteredNodes;
14897
14905
  if (nodes.length === 1 && this.useSingleNodeRotation()) {
14898
14906
  this.rotation(nodes[0].getAbsoluteRotation());
14899
14907
  }
@@ -14993,6 +15001,19 @@
14993
15001
  this._nodes = [];
14994
15002
  this._resetTransformCache();
14995
15003
  }
15004
+ /**
15005
+ * bind events to the Transformer. You can use events: `transform`, `transformstart`, `transformend`, `dragstart`, `dragmove`, `dragend`
15006
+ * @method
15007
+ * @name Konva.Transformer#on
15008
+ * @param {String} evtStr e.g. 'transform'
15009
+ * @param {Function} handler The handler function. The first argument of that function is event object. Event object has `target` as main target of the event, `currentTarget` as current node listener and `evt` as native browser event.
15010
+ * @returns {Konva.Transformer}
15011
+ * @example
15012
+ * // add click listener
15013
+ * tr.on('transformstart', function() {
15014
+ * console.log('transform started');
15015
+ * });
15016
+ */
14996
15017
  _resetTransformCache() {
14997
15018
  this._clearCache(NODES_RECT);
14998
15019
  this._clearCache('transform');