konva 9.3.21 → 10.0.0-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.
Files changed (129) hide show
  1. package/README.md +1 -1
  2. package/konva.js +664 -226
  3. package/konva.min.js +46 -4
  4. package/lib/Animation.d.ts +2 -2
  5. package/lib/Animation.js +7 -11
  6. package/lib/BezierFunctions.js +9 -15
  7. package/lib/Canvas.d.ts +1 -1
  8. package/lib/Canvas.js +14 -20
  9. package/lib/Container.d.ts +7 -6
  10. package/lib/Container.js +12 -16
  11. package/lib/Context.d.ts +7 -5
  12. package/lib/Context.js +34 -14
  13. package/lib/Core.d.ts +2 -2
  14. package/lib/Core.js +3 -7
  15. package/lib/DragAndDrop.d.ts +3 -3
  16. package/lib/DragAndDrop.js +24 -27
  17. package/lib/Factory.d.ts +2 -2
  18. package/lib/Factory.js +24 -27
  19. package/lib/FastLayer.d.ts +1 -1
  20. package/lib/FastLayer.js +6 -10
  21. package/lib/Global.d.ts +4 -3
  22. package/lib/Global.js +19 -19
  23. package/lib/Group.d.ts +4 -3
  24. package/lib/Group.js +6 -10
  25. package/lib/Layer.d.ts +10 -9
  26. package/lib/Layer.js +33 -37
  27. package/lib/Node.d.ts +16 -13
  28. package/lib/Node.js +207 -123
  29. package/lib/PointerEvents.d.ts +4 -4
  30. package/lib/PointerEvents.js +7 -14
  31. package/lib/Shape.d.ts +7 -4
  32. package/lib/Shape.js +91 -91
  33. package/lib/Stage.d.ts +8 -7
  34. package/lib/Stage.js +66 -56
  35. package/lib/Tween.d.ts +3 -2
  36. package/lib/Tween.js +29 -31
  37. package/lib/Util.d.ts +3 -2
  38. package/lib/Util.js +98 -38
  39. package/lib/Validators.js +44 -57
  40. package/lib/_CoreInternals.d.ts +49 -23
  41. package/lib/_CoreInternals.js +33 -36
  42. package/lib/_FullInternals.d.ts +126 -62
  43. package/lib/_FullInternals.js +77 -78
  44. package/lib/canvas-backend.d.ts +2 -0
  45. package/lib/canvas-backend.js +27 -0
  46. package/lib/filters/Blur.d.ts +1 -1
  47. package/lib/filters/Blur.js +5 -9
  48. package/lib/filters/Brighten.d.ts +1 -1
  49. package/lib/filters/Brighten.js +5 -9
  50. package/lib/filters/Brightness.d.ts +2 -0
  51. package/lib/filters/Brightness.js +8 -0
  52. package/lib/filters/Contrast.d.ts +1 -1
  53. package/lib/filters/Contrast.js +5 -9
  54. package/lib/filters/Emboss.d.ts +1 -1
  55. package/lib/filters/Emboss.js +95 -101
  56. package/lib/filters/Enhance.d.ts +1 -1
  57. package/lib/filters/Enhance.js +5 -9
  58. package/lib/filters/Grayscale.d.ts +1 -1
  59. package/lib/filters/Grayscale.js +1 -5
  60. package/lib/filters/HSL.d.ts +1 -1
  61. package/lib/filters/HSL.js +7 -11
  62. package/lib/filters/HSV.d.ts +1 -1
  63. package/lib/filters/HSV.js +7 -11
  64. package/lib/filters/Invert.d.ts +1 -1
  65. package/lib/filters/Invert.js +1 -5
  66. package/lib/filters/Kaleidoscope.d.ts +1 -1
  67. package/lib/filters/Kaleidoscope.js +9 -13
  68. package/lib/filters/Mask.d.ts +1 -1
  69. package/lib/filters/Mask.js +16 -10
  70. package/lib/filters/Noise.d.ts +1 -1
  71. package/lib/filters/Noise.js +5 -9
  72. package/lib/filters/Pixelate.d.ts +1 -1
  73. package/lib/filters/Pixelate.js +7 -11
  74. package/lib/filters/Posterize.d.ts +1 -1
  75. package/lib/filters/Posterize.js +5 -9
  76. package/lib/filters/RGB.d.ts +1 -1
  77. package/lib/filters/RGB.js +7 -11
  78. package/lib/filters/RGBA.d.ts +1 -1
  79. package/lib/filters/RGBA.js +8 -12
  80. package/lib/filters/Sepia.d.ts +1 -1
  81. package/lib/filters/Sepia.js +1 -5
  82. package/lib/filters/Solarize.d.ts +1 -1
  83. package/lib/filters/Solarize.js +13 -29
  84. package/lib/filters/Threshold.d.ts +1 -1
  85. package/lib/filters/Threshold.js +5 -9
  86. package/lib/index.d.ts +1 -1
  87. package/lib/index.js +2 -4
  88. package/lib/shapes/Arc.d.ts +4 -3
  89. package/lib/shapes/Arc.js +13 -17
  90. package/lib/shapes/Arrow.d.ts +4 -3
  91. package/lib/shapes/Arrow.js +13 -17
  92. package/lib/shapes/Circle.d.ts +4 -3
  93. package/lib/shapes/Circle.js +7 -11
  94. package/lib/shapes/Ellipse.d.ts +4 -3
  95. package/lib/shapes/Ellipse.js +9 -13
  96. package/lib/shapes/Image.d.ts +4 -3
  97. package/lib/shapes/Image.js +17 -21
  98. package/lib/shapes/Label.d.ts +7 -6
  99. package/lib/shapes/Label.js +13 -18
  100. package/lib/shapes/Line.d.ts +4 -3
  101. package/lib/shapes/Line.js +10 -14
  102. package/lib/shapes/Path.d.ts +3 -2
  103. package/lib/shapes/Path.js +83 -23
  104. package/lib/shapes/Rect.d.ts +4 -3
  105. package/lib/shapes/Rect.js +9 -13
  106. package/lib/shapes/RegularPolygon.d.ts +6 -3
  107. package/lib/shapes/RegularPolygon.js +19 -16
  108. package/lib/shapes/Ring.d.ts +4 -3
  109. package/lib/shapes/Ring.js +8 -12
  110. package/lib/shapes/Sprite.d.ts +5 -4
  111. package/lib/shapes/Sprite.js +15 -19
  112. package/lib/shapes/Star.d.ts +4 -3
  113. package/lib/shapes/Star.js +9 -13
  114. package/lib/shapes/Text.d.ts +16 -3
  115. package/lib/shapes/Text.js +73 -53
  116. package/lib/shapes/TextPath.d.ts +5 -4
  117. package/lib/shapes/TextPath.js +48 -41
  118. package/lib/shapes/Transformer.d.ts +8 -8
  119. package/lib/shapes/Transformer.js +90 -90
  120. package/lib/shapes/Wedge.d.ts +4 -3
  121. package/lib/shapes/Wedge.js +12 -16
  122. package/lib/skia-backend.d.ts +2 -0
  123. package/lib/skia-backend.js +24 -0
  124. package/lib/types.d.ts +22 -22
  125. package/lib/types.js +21 -25
  126. package/package.json +53 -25
  127. package/lib/index-node.d.ts +0 -2
  128. package/lib/index-node.js +0 -21
  129. package/lib/index-types.d.ts +0 -181
@@ -1,10 +1,7 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.RGBA = void 0;
4
- const Factory_1 = require("../Factory");
5
- const Node_1 = require("../Node");
6
- const Validators_1 = require("../Validators");
7
- const RGBA = function (imageData) {
1
+ import { Factory } from "../Factory.js";
2
+ import { Node } from "../Node.js";
3
+ import { RGBComponent } from "../Validators.js";
4
+ export const RGBA = function (imageData) {
8
5
  const data = imageData.data, nPixels = data.length, red = this.red(), green = this.green(), blue = this.blue(), alpha = this.alpha();
9
6
  for (let i = 0; i < nPixels; i += 4) {
10
7
  const ia = 1 - alpha;
@@ -13,8 +10,7 @@ const RGBA = function (imageData) {
13
10
  data[i + 2] = blue * alpha + data[i + 2] * ia;
14
11
  }
15
12
  };
16
- exports.RGBA = RGBA;
17
- Factory_1.Factory.addGetterSetter(Node_1.Node, 'red', 0, function (val) {
13
+ Factory.addGetterSetter(Node, 'red', 0, function (val) {
18
14
  this._filterUpToDate = false;
19
15
  if (val > 255) {
20
16
  return 255;
@@ -26,7 +22,7 @@ Factory_1.Factory.addGetterSetter(Node_1.Node, 'red', 0, function (val) {
26
22
  return Math.round(val);
27
23
  }
28
24
  });
29
- Factory_1.Factory.addGetterSetter(Node_1.Node, 'green', 0, function (val) {
25
+ Factory.addGetterSetter(Node, 'green', 0, function (val) {
30
26
  this._filterUpToDate = false;
31
27
  if (val > 255) {
32
28
  return 255;
@@ -38,8 +34,8 @@ Factory_1.Factory.addGetterSetter(Node_1.Node, 'green', 0, function (val) {
38
34
  return Math.round(val);
39
35
  }
40
36
  });
41
- Factory_1.Factory.addGetterSetter(Node_1.Node, 'blue', 0, Validators_1.RGBComponent, Factory_1.Factory.afterSetFilter);
42
- Factory_1.Factory.addGetterSetter(Node_1.Node, 'alpha', 1, function (val) {
37
+ Factory.addGetterSetter(Node, 'blue', 0, RGBComponent, Factory.afterSetFilter);
38
+ Factory.addGetterSetter(Node, 'alpha', 1, function (val) {
43
39
  this._filterUpToDate = false;
44
40
  if (val > 1) {
45
41
  return 1;
@@ -1,2 +1,2 @@
1
- import { Filter } from '../Node.js';
1
+ import type { Filter } from '../Node.ts';
2
2
  export declare const Sepia: Filter;
@@ -1,7 +1,4 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Sepia = void 0;
4
- const Sepia = function (imageData) {
1
+ export const Sepia = function (imageData) {
5
2
  const data = imageData.data, nPixels = data.length;
6
3
  for (let i = 0; i < nPixels; i += 4) {
7
4
  const r = data[i + 0];
@@ -12,4 +9,3 @@ const Sepia = function (imageData) {
12
9
  data[i + 2] = Math.min(255, r * 0.272 + g * 0.534 + b * 0.131);
13
10
  }
14
11
  };
15
- exports.Sepia = Sepia;
@@ -1,2 +1,2 @@
1
- import { Filter } from '../Node.js';
1
+ import type { Filter } from '../Node.ts';
2
2
  export declare const Solarize: Filter;
@@ -1,30 +1,14 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Solarize = void 0;
4
- const Solarize = function (imageData) {
5
- const data = imageData.data, w = imageData.width, h = imageData.height, w4 = w * 4;
6
- let y = h;
7
- do {
8
- const offsetY = (y - 1) * w4;
9
- let x = w;
10
- do {
11
- const offset = offsetY + (x - 1) * 4;
12
- let r = data[offset];
13
- let g = data[offset + 1];
14
- let b = data[offset + 2];
15
- if (r > 127) {
16
- r = 255 - r;
17
- }
18
- if (g > 127) {
19
- g = 255 - g;
20
- }
21
- if (b > 127) {
22
- b = 255 - b;
23
- }
24
- data[offset] = r;
25
- data[offset + 1] = g;
26
- data[offset + 2] = b;
27
- } while (--x);
28
- } while (--y);
1
+ export const Solarize = function (imageData) {
2
+ const threshold = 128;
3
+ const d = imageData.data;
4
+ for (let i = 0; i < d.length; i += 4) {
5
+ const r = d[i], g = d[i + 1], b = d[i + 2];
6
+ const L = 0.2126 * r + 0.7152 * g + 0.0722 * b;
7
+ if (L >= threshold) {
8
+ d[i] = 255 - r;
9
+ d[i + 1] = 255 - g;
10
+ d[i + 2] = 255 - b;
11
+ }
12
+ }
13
+ return imageData;
29
14
  };
30
- exports.Solarize = Solarize;
@@ -1,2 +1,2 @@
1
- import { Filter } from '../Node.js';
1
+ import type { Filter } from '../Node.ts';
2
2
  export declare const Threshold: Filter;
@@ -1,14 +1,10 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Threshold = void 0;
4
- const Factory_1 = require("../Factory");
5
- const Node_1 = require("../Node");
6
- const Validators_1 = require("../Validators");
7
- const Threshold = function (imageData) {
1
+ import { Factory } from "../Factory.js";
2
+ import { Node } from "../Node.js";
3
+ import { getNumberValidator } from "../Validators.js";
4
+ export const Threshold = function (imageData) {
8
5
  const level = this.threshold() * 255, data = imageData.data, len = data.length;
9
6
  for (let i = 0; i < len; i += 1) {
10
7
  data[i] = data[i] < level ? 0 : 255;
11
8
  }
12
9
  };
13
- exports.Threshold = Threshold;
14
- Factory_1.Factory.addGetterSetter(Node_1.Node, 'threshold', 0.5, (0, Validators_1.getNumberValidator)(), Factory_1.Factory.afterSetFilter);
10
+ Factory.addGetterSetter(Node, 'threshold', 0.5, getNumberValidator(), Factory.afterSetFilter);
package/lib/index.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- import { Konva } from './_FullInternals.js';
1
+ import { Konva } from './_FullInternals.ts';
2
2
  export default Konva;
package/lib/index.js CHANGED
@@ -1,4 +1,2 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const _FullInternals_1 = require("./_FullInternals");
4
- module.exports = _FullInternals_1.Konva;
1
+ import { Konva } from "./_FullInternals.js";
2
+ export default Konva;
@@ -1,6 +1,7 @@
1
- import { Shape, ShapeConfig } from '../Shape.js';
2
- import { GetSet } from '../types.js';
3
- import { Context } from '../Context.js';
1
+ import type { ShapeConfig } from '../Shape.ts';
2
+ import { Shape } from '../Shape.ts';
3
+ import type { GetSet } from '../types.ts';
4
+ import type { Context } from '../Context.ts';
4
5
  export interface ArcConfig extends ShapeConfig {
5
6
  angle: number;
6
7
  innerRadius: number;
package/lib/shapes/Arc.js CHANGED
@@ -1,14 +1,11 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Arc = void 0;
4
- const Factory_1 = require("../Factory");
5
- const Shape_1 = require("../Shape");
6
- const Global_1 = require("../Global");
7
- const Validators_1 = require("../Validators");
8
- const Global_2 = require("../Global");
9
- class Arc extends Shape_1.Shape {
1
+ import { Factory } from "../Factory.js";
2
+ import { Shape } from "../Shape.js";
3
+ import { Konva } from "../Global.js";
4
+ import { getNumberValidator, getBooleanValidator } from "../Validators.js";
5
+ import { _registerNode } from "../Global.js";
6
+ export class Arc extends Shape {
10
7
  _sceneFunc(context) {
11
- const angle = Global_1.Konva.getAngle(this.angle()), clockwise = this.clockwise();
8
+ const angle = Konva.getAngle(this.angle()), clockwise = this.clockwise();
12
9
  context.beginPath();
13
10
  context.arc(0, 0, this.outerRadius(), 0, angle, clockwise);
14
11
  context.arc(0, 0, this.innerRadius(), angle, 0, !clockwise);
@@ -31,7 +28,7 @@ class Arc extends Shape_1.Shape {
31
28
  const innerRadius = this.innerRadius();
32
29
  const outerRadius = this.outerRadius();
33
30
  const clockwise = this.clockwise();
34
- const angle = Global_1.Konva.getAngle(clockwise ? 360 - this.angle() : this.angle());
31
+ const angle = Konva.getAngle(clockwise ? 360 - this.angle() : this.angle());
35
32
  const boundLeftRatio = Math.cos(Math.min(angle, Math.PI));
36
33
  const boundRightRatio = 1;
37
34
  const boundTopRatio = Math.sin(Math.min(Math.max(Math.PI, angle), (3 * Math.PI) / 2));
@@ -48,7 +45,6 @@ class Arc extends Shape_1.Shape {
48
45
  };
49
46
  }
50
47
  }
51
- exports.Arc = Arc;
52
48
  Arc.prototype._centroid = true;
53
49
  Arc.prototype.className = 'Arc';
54
50
  Arc.prototype._attrsAffectingSize = [
@@ -57,8 +53,8 @@ Arc.prototype._attrsAffectingSize = [
57
53
  'angle',
58
54
  'clockwise',
59
55
  ];
60
- (0, Global_2._registerNode)(Arc);
61
- Factory_1.Factory.addGetterSetter(Arc, 'innerRadius', 0, (0, Validators_1.getNumberValidator)());
62
- Factory_1.Factory.addGetterSetter(Arc, 'outerRadius', 0, (0, Validators_1.getNumberValidator)());
63
- Factory_1.Factory.addGetterSetter(Arc, 'angle', 0, (0, Validators_1.getNumberValidator)());
64
- Factory_1.Factory.addGetterSetter(Arc, 'clockwise', false, (0, Validators_1.getBooleanValidator)());
56
+ _registerNode(Arc);
57
+ Factory.addGetterSetter(Arc, 'innerRadius', 0, getNumberValidator());
58
+ Factory.addGetterSetter(Arc, 'outerRadius', 0, getNumberValidator());
59
+ Factory.addGetterSetter(Arc, 'angle', 0, getNumberValidator());
60
+ Factory.addGetterSetter(Arc, 'clockwise', false, getBooleanValidator());
@@ -1,6 +1,7 @@
1
- import { Line, LineConfig } from './Line.js';
2
- import { GetSet } from '../types.js';
3
- import { Context } from '../Context.js';
1
+ import type { LineConfig } from './Line.ts';
2
+ import { Line } from './Line.ts';
3
+ import type { GetSet } from '../types.ts';
4
+ import type { Context } from '../Context.ts';
4
5
  export interface ArrowConfig extends LineConfig {
5
6
  points: number[];
6
7
  tension?: number;
@@ -1,12 +1,9 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Arrow = void 0;
4
- const Factory_1 = require("../Factory");
5
- const Line_1 = require("./Line");
6
- const Validators_1 = require("../Validators");
7
- const Global_1 = require("../Global");
8
- const Path_1 = require("./Path");
9
- class Arrow extends Line_1.Line {
1
+ import { Factory } from "../Factory.js";
2
+ import { Line } from "./Line.js";
3
+ import { getNumberValidator } from "../Validators.js";
4
+ import { _registerNode } from "../Global.js";
5
+ import { Path } from "./Path.js";
6
+ export class Arrow extends Line {
10
7
  _sceneFunc(ctx) {
11
8
  super._sceneFunc(ctx);
12
9
  const PI2 = Math.PI * 2;
@@ -28,8 +25,8 @@ class Arrow extends Line_1.Line {
28
25
  points[n - 2],
29
26
  points[n - 1],
30
27
  ];
31
- const lastLength = Path_1.Path.calcLength(tp[tp.length - 4], tp[tp.length - 3], 'C', lp);
32
- const previous = Path_1.Path.getPointOnQuadraticBezier(Math.min(1, 1 - length / lastLength), lp[0], lp[1], lp[2], lp[3], lp[4], lp[5]);
28
+ const lastLength = Path.calcLength(tp[tp.length - 4], tp[tp.length - 3], 'C', lp);
29
+ const previous = Path.getPointOnQuadraticBezier(Math.min(1, 1 - length / lastLength), lp[0], lp[1], lp[2], lp[3], lp[4], lp[5]);
33
30
  dx = points[n - 2] - previous.x;
34
31
  dy = points[n - 1] - previous.y;
35
32
  }
@@ -94,10 +91,9 @@ class Arrow extends Line_1.Line {
94
91
  };
95
92
  }
96
93
  }
97
- exports.Arrow = Arrow;
98
94
  Arrow.prototype.className = 'Arrow';
99
- (0, Global_1._registerNode)(Arrow);
100
- Factory_1.Factory.addGetterSetter(Arrow, 'pointerLength', 10, (0, Validators_1.getNumberValidator)());
101
- Factory_1.Factory.addGetterSetter(Arrow, 'pointerWidth', 10, (0, Validators_1.getNumberValidator)());
102
- Factory_1.Factory.addGetterSetter(Arrow, 'pointerAtBeginning', false);
103
- Factory_1.Factory.addGetterSetter(Arrow, 'pointerAtEnding', true);
95
+ _registerNode(Arrow);
96
+ Factory.addGetterSetter(Arrow, 'pointerLength', 10, getNumberValidator());
97
+ Factory.addGetterSetter(Arrow, 'pointerWidth', 10, getNumberValidator());
98
+ Factory.addGetterSetter(Arrow, 'pointerAtBeginning', false);
99
+ Factory.addGetterSetter(Arrow, 'pointerAtEnding', true);
@@ -1,6 +1,7 @@
1
- import { Shape, ShapeConfig } from '../Shape.js';
2
- import { GetSet } from '../types.js';
3
- import { Context } from '../Context.js';
1
+ import type { ShapeConfig } from '../Shape.ts';
2
+ import { Shape } from '../Shape.ts';
3
+ import type { GetSet } from '../types.ts';
4
+ import type { Context } from '../Context.ts';
4
5
  export interface CircleConfig extends ShapeConfig {
5
6
  radius?: number;
6
7
  }
@@ -1,11 +1,8 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Circle = void 0;
4
- const Factory_1 = require("../Factory");
5
- const Shape_1 = require("../Shape");
6
- const Validators_1 = require("../Validators");
7
- const Global_1 = require("../Global");
8
- class Circle extends Shape_1.Shape {
1
+ import { Factory } from "../Factory.js";
2
+ import { Shape } from "../Shape.js";
3
+ import { getNumberValidator } from "../Validators.js";
4
+ import { _registerNode } from "../Global.js";
5
+ export class Circle extends Shape {
9
6
  _sceneFunc(context) {
10
7
  context.beginPath();
11
8
  context.arc(0, 0, this.attrs.radius || 0, 0, Math.PI * 2, false);
@@ -29,9 +26,8 @@ class Circle extends Shape_1.Shape {
29
26
  }
30
27
  }
31
28
  }
32
- exports.Circle = Circle;
33
29
  Circle.prototype._centroid = true;
34
30
  Circle.prototype.className = 'Circle';
35
31
  Circle.prototype._attrsAffectingSize = ['radius'];
36
- (0, Global_1._registerNode)(Circle);
37
- Factory_1.Factory.addGetterSetter(Circle, 'radius', 0, (0, Validators_1.getNumberValidator)());
32
+ _registerNode(Circle);
33
+ Factory.addGetterSetter(Circle, 'radius', 0, getNumberValidator());
@@ -1,6 +1,7 @@
1
- import { Shape, ShapeConfig } from '../Shape.js';
2
- import { Context } from '../Context.js';
3
- import { GetSet, Vector2d } from '../types.js';
1
+ import type { ShapeConfig } from '../Shape.ts';
2
+ import { Shape } from '../Shape.ts';
3
+ import type { Context } from '../Context.ts';
4
+ import type { GetSet, Vector2d } from '../types.ts';
4
5
  export interface EllipseConfig extends ShapeConfig {
5
6
  radiusX: number;
6
7
  radiusY: number;
@@ -1,11 +1,8 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Ellipse = void 0;
4
- const Factory_1 = require("../Factory");
5
- const Shape_1 = require("../Shape");
6
- const Validators_1 = require("../Validators");
7
- const Global_1 = require("../Global");
8
- class Ellipse extends Shape_1.Shape {
1
+ import { Factory } from "../Factory.js";
2
+ import { Shape } from "../Shape.js";
3
+ import { getNumberValidator } from "../Validators.js";
4
+ import { _registerNode } from "../Global.js";
5
+ export class Ellipse extends Shape {
9
6
  _sceneFunc(context) {
10
7
  const rx = this.radiusX(), ry = this.radiusY();
11
8
  context.beginPath();
@@ -31,11 +28,10 @@ class Ellipse extends Shape_1.Shape {
31
28
  this.radiusY(height / 2);
32
29
  }
33
30
  }
34
- exports.Ellipse = Ellipse;
35
31
  Ellipse.prototype.className = 'Ellipse';
36
32
  Ellipse.prototype._centroid = true;
37
33
  Ellipse.prototype._attrsAffectingSize = ['radiusX', 'radiusY'];
38
- (0, Global_1._registerNode)(Ellipse);
39
- Factory_1.Factory.addComponentsGetterSetter(Ellipse, 'radius', ['x', 'y']);
40
- Factory_1.Factory.addGetterSetter(Ellipse, 'radiusX', 0, (0, Validators_1.getNumberValidator)());
41
- Factory_1.Factory.addGetterSetter(Ellipse, 'radiusY', 0, (0, Validators_1.getNumberValidator)());
34
+ _registerNode(Ellipse);
35
+ Factory.addComponentsGetterSetter(Ellipse, 'radius', ['x', 'y']);
36
+ Factory.addGetterSetter(Ellipse, 'radiusX', 0, getNumberValidator());
37
+ Factory.addGetterSetter(Ellipse, 'radiusY', 0, getNumberValidator());
@@ -1,6 +1,7 @@
1
- import { Shape, ShapeConfig } from '../Shape.js';
2
- import { GetSet, IRect } from '../types.js';
3
- import { Context } from '../Context.js';
1
+ import type { ShapeConfig } from '../Shape.ts';
2
+ import { Shape } from '../Shape.ts';
3
+ import type { GetSet, IRect } from '../types.ts';
4
+ import type { Context } from '../Context.ts';
4
5
  export interface ImageConfig extends ShapeConfig {
5
6
  image: CanvasImageSource | undefined;
6
7
  crop?: IRect;
@@ -1,12 +1,9 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Image = void 0;
4
- const Util_1 = require("../Util");
5
- const Factory_1 = require("../Factory");
6
- const Shape_1 = require("../Shape");
7
- const Global_1 = require("../Global");
8
- const Validators_1 = require("../Validators");
9
- class Image extends Shape_1.Shape {
1
+ import { Util } from "../Util.js";
2
+ import { Factory } from "../Factory.js";
3
+ import { Shape } from "../Shape.js";
4
+ import { _registerNode } from "../Global.js";
5
+ import { getNumberOrArrayOfNumbersValidator, getNumberValidator, } from "../Validators.js";
6
+ export class Image extends Shape {
10
7
  constructor(attrs) {
11
8
  super(attrs);
12
9
  this._loadListener = () => {
@@ -77,7 +74,7 @@ class Image extends Shape_1.Shape {
77
74
  if (this.hasFill() || this.hasStroke() || cornerRadius) {
78
75
  context.beginPath();
79
76
  cornerRadius
80
- ? Util_1.Util.drawRoundedRectPath(context, width, height, cornerRadius)
77
+ ? Util.drawRoundedRectPath(context, width, height, cornerRadius)
81
78
  : context.rect(0, 0, width, height);
82
79
  context.closePath();
83
80
  context.fillStrokeShape(this);
@@ -96,7 +93,7 @@ class Image extends Shape_1.Shape {
96
93
  context.rect(0, 0, width, height);
97
94
  }
98
95
  else {
99
- Util_1.Util.drawRoundedRectPath(context, width, height, cornerRadius);
96
+ Util.drawRoundedRectPath(context, width, height, cornerRadius);
100
97
  }
101
98
  context.closePath();
102
99
  context.fillStrokeShape(this);
@@ -110,7 +107,7 @@ class Image extends Shape_1.Shape {
110
107
  return (_a = this.attrs.height) !== null && _a !== void 0 ? _a : (_b = this.image()) === null || _b === void 0 ? void 0 : _b.height;
111
108
  }
112
109
  static fromURL(url, callback, onError = null) {
113
- const img = Util_1.Util.createImageElement();
110
+ const img = Util.createImageElement();
114
111
  img.onload = function () {
115
112
  const image = new Image({
116
113
  image: img,
@@ -122,13 +119,12 @@ class Image extends Shape_1.Shape {
122
119
  img.src = url;
123
120
  }
124
121
  }
125
- exports.Image = Image;
126
122
  Image.prototype.className = 'Image';
127
- (0, Global_1._registerNode)(Image);
128
- Factory_1.Factory.addGetterSetter(Image, 'cornerRadius', 0, (0, Validators_1.getNumberOrArrayOfNumbersValidator)(4));
129
- Factory_1.Factory.addGetterSetter(Image, 'image');
130
- Factory_1.Factory.addComponentsGetterSetter(Image, 'crop', ['x', 'y', 'width', 'height']);
131
- Factory_1.Factory.addGetterSetter(Image, 'cropX', 0, (0, Validators_1.getNumberValidator)());
132
- Factory_1.Factory.addGetterSetter(Image, 'cropY', 0, (0, Validators_1.getNumberValidator)());
133
- Factory_1.Factory.addGetterSetter(Image, 'cropWidth', 0, (0, Validators_1.getNumberValidator)());
134
- Factory_1.Factory.addGetterSetter(Image, 'cropHeight', 0, (0, Validators_1.getNumberValidator)());
123
+ _registerNode(Image);
124
+ Factory.addGetterSetter(Image, 'cornerRadius', 0, getNumberOrArrayOfNumbersValidator(4));
125
+ Factory.addGetterSetter(Image, 'image');
126
+ Factory.addComponentsGetterSetter(Image, 'crop', ['x', 'y', 'width', 'height']);
127
+ Factory.addGetterSetter(Image, 'cropX', 0, getNumberValidator());
128
+ Factory.addGetterSetter(Image, 'cropY', 0, getNumberValidator());
129
+ Factory.addGetterSetter(Image, 'cropWidth', 0, getNumberValidator());
130
+ Factory.addGetterSetter(Image, 'cropHeight', 0, getNumberValidator());
@@ -1,9 +1,10 @@
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';
1
+ import type { ShapeConfig } from '../Shape.ts';
2
+ import { Shape } from '../Shape.ts';
3
+ import { Group } from '../Group.ts';
4
+ import type { Context } from '../Context.ts';
5
+ import type { ContainerConfig } from '../Container.ts';
6
+ import type { GetSet } from '../types.ts';
7
+ import type { Text } from './Text.ts';
7
8
  export interface LabelConfig extends ContainerConfig {
8
9
  }
9
10
  declare const NONE = "none";
@@ -1,11 +1,8 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Tag = exports.Label = void 0;
4
- const Factory_1 = require("../Factory");
5
- const Shape_1 = require("../Shape");
6
- const Group_1 = require("../Group");
7
- const Validators_1 = require("../Validators");
8
- const Global_1 = require("../Global");
1
+ import { Factory } from "../Factory.js";
2
+ import { Shape } from "../Shape.js";
3
+ import { Group } from "../Group.js";
4
+ import { getNumberOrArrayOfNumbersValidator, getNumberValidator, } from "../Validators.js";
5
+ import { _registerNode } from "../Global.js";
9
6
  const ATTR_CHANGE_LIST = [
10
7
  'fontFamily',
11
8
  'fontSize',
@@ -19,7 +16,7 @@ const ATTR_CHANGE_LIST = [
19
16
  'pointerWidth',
20
17
  'pointerHeight',
21
18
  ], CHANGE_KONVA = 'Change.konva', NONE = 'none', UP = 'up', RIGHT = 'right', DOWN = 'down', LEFT = 'left', attrChangeListLen = ATTR_CHANGE_LIST.length;
22
- class Label extends Group_1.Group {
19
+ export class Label extends Group {
23
20
  constructor(config) {
24
21
  super(config);
25
22
  this.on('add.konva', function (evt) {
@@ -89,10 +86,9 @@ class Label extends Group_1.Group {
89
86
  }
90
87
  }
91
88
  }
92
- exports.Label = Label;
93
89
  Label.prototype.className = 'Label';
94
- (0, Global_1._registerNode)(Label);
95
- class Tag extends Shape_1.Shape {
90
+ _registerNode(Label);
91
+ export class Tag extends Shape {
96
92
  _sceneFunc(context) {
97
93
  const width = this.width(), height = this.height(), pointerDirection = this.pointerDirection(), pointerWidth = this.pointerWidth(), pointerHeight = this.pointerHeight(), cornerRadius = this.cornerRadius();
98
94
  let topLeft = 0;
@@ -169,10 +165,9 @@ class Tag extends Shape_1.Shape {
169
165
  };
170
166
  }
171
167
  }
172
- exports.Tag = Tag;
173
168
  Tag.prototype.className = 'Tag';
174
- (0, Global_1._registerNode)(Tag);
175
- Factory_1.Factory.addGetterSetter(Tag, 'pointerDirection', NONE);
176
- Factory_1.Factory.addGetterSetter(Tag, 'pointerWidth', 0, (0, Validators_1.getNumberValidator)());
177
- Factory_1.Factory.addGetterSetter(Tag, 'pointerHeight', 0, (0, Validators_1.getNumberValidator)());
178
- Factory_1.Factory.addGetterSetter(Tag, 'cornerRadius', 0, (0, Validators_1.getNumberOrArrayOfNumbersValidator)(4));
169
+ _registerNode(Tag);
170
+ Factory.addGetterSetter(Tag, 'pointerDirection', NONE);
171
+ Factory.addGetterSetter(Tag, 'pointerWidth', 0, getNumberValidator());
172
+ Factory.addGetterSetter(Tag, 'pointerHeight', 0, getNumberValidator());
173
+ Factory.addGetterSetter(Tag, 'cornerRadius', 0, getNumberOrArrayOfNumbersValidator(4));
@@ -1,6 +1,7 @@
1
- import { Shape, ShapeConfig } from '../Shape.js';
2
- import { Context } from '../Context.js';
3
- import { GetSet } from '../types.js';
1
+ import type { ShapeConfig } from '../Shape.ts';
2
+ import { Shape } from '../Shape.ts';
3
+ import type { Context } from '../Context.ts';
4
+ import type { GetSet } from '../types.ts';
4
5
  export interface LineConfig extends ShapeConfig {
5
6
  points?: number[] | Int8Array | Uint8Array | Uint8ClampedArray | Int16Array | Uint16Array | Int32Array | Uint32Array | Float32Array | Float64Array;
6
7
  tension?: number;
@@ -1,10 +1,7 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Line = void 0;
4
- const Factory_1 = require("../Factory");
5
- const Global_1 = require("../Global");
6
- const Shape_1 = require("../Shape");
7
- const Validators_1 = require("../Validators");
1
+ import { Factory } from "../Factory.js";
2
+ import { _registerNode } from "../Global.js";
3
+ import { Shape } from "../Shape.js";
4
+ import { getNumberArrayValidator, getNumberValidator } from "../Validators.js";
8
5
  function getControlPoints(x0, y0, x1, y1, x2, y2, t) {
9
6
  const d01 = Math.sqrt(Math.pow(x1 - x0, 2) + Math.pow(y1 - y0, 2)), d12 = Math.sqrt(Math.pow(x2 - x1, 2) + Math.pow(y2 - y1, 2)), fa = (t * d01) / (d01 + d12), fb = (t * d12) / (d01 + d12), p1x = x1 - fa * (x2 - x0), p1y = y1 - fa * (y2 - y0), p2x = x1 + fb * (x2 - x0), p2y = y1 + fb * (y2 - y0);
10
7
  return [p1x, p1y, p2x, p2y];
@@ -25,7 +22,7 @@ function expandPoints(p, tension) {
25
22
  }
26
23
  return allPoints;
27
24
  }
28
- class Line extends Shape_1.Shape {
25
+ export class Line extends Shape {
29
26
  constructor(config) {
30
27
  super(config);
31
28
  this.on('pointsChange.konva tensionChange.konva closedChange.konva bezierChange.konva', function () {
@@ -150,11 +147,10 @@ class Line extends Shape_1.Shape {
150
147
  };
151
148
  }
152
149
  }
153
- exports.Line = Line;
154
150
  Line.prototype.className = 'Line';
155
151
  Line.prototype._attrsAffectingSize = ['points', 'bezier', 'tension'];
156
- (0, Global_1._registerNode)(Line);
157
- Factory_1.Factory.addGetterSetter(Line, 'closed', false);
158
- Factory_1.Factory.addGetterSetter(Line, 'bezier', false);
159
- Factory_1.Factory.addGetterSetter(Line, 'tension', 0, (0, Validators_1.getNumberValidator)());
160
- Factory_1.Factory.addGetterSetter(Line, 'points', [], (0, Validators_1.getNumberArrayValidator)());
152
+ _registerNode(Line);
153
+ Factory.addGetterSetter(Line, 'closed', false);
154
+ Factory.addGetterSetter(Line, 'bezier', false);
155
+ Factory.addGetterSetter(Line, 'tension', 0, getNumberValidator());
156
+ Factory.addGetterSetter(Line, 'points', [], getNumberArrayValidator());
@@ -1,5 +1,6 @@
1
- import { Shape, ShapeConfig } from '../Shape.js';
2
- import { GetSet, PathSegment } from '../types.js';
1
+ import type { ShapeConfig } from '../Shape.ts';
2
+ import { Shape } from '../Shape.ts';
3
+ import type { GetSet, PathSegment } from '../types.ts';
3
4
  export interface PathConfig extends ShapeConfig {
4
5
  data?: string;
5
6
  }