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,10 @@
1
- import { KonvaEventObject } from './Node.js';
2
- import { Shape } from './Shape.js';
3
- import { Stage } from './Stage.js';
1
+ import type { KonvaEventObject } from './Node.ts';
2
+ import type { Shape } from './Shape.ts';
3
+ 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.js").ShapeConfig> | Stage | undefined;
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;
@@ -1,26 +1,19 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getCapturedShape = getCapturedShape;
4
- exports.createEvent = createEvent;
5
- exports.hasPointerCapture = hasPointerCapture;
6
- exports.setPointerCapture = setPointerCapture;
7
- exports.releaseCapture = releaseCapture;
8
- const Global_1 = require("./Global");
1
+ import { Konva } from "./Global.js";
9
2
  const Captures = new Map();
10
- const SUPPORT_POINTER_EVENTS = Global_1.Konva._global['PointerEvent'] !== undefined;
11
- function getCapturedShape(pointerId) {
3
+ const SUPPORT_POINTER_EVENTS = Konva._global['PointerEvent'] !== undefined;
4
+ export function getCapturedShape(pointerId) {
12
5
  return Captures.get(pointerId);
13
6
  }
14
- function createEvent(evt) {
7
+ export function createEvent(evt) {
15
8
  return {
16
9
  evt,
17
10
  pointerId: evt.pointerId,
18
11
  };
19
12
  }
20
- function hasPointerCapture(pointerId, shape) {
13
+ export function hasPointerCapture(pointerId, shape) {
21
14
  return Captures.get(pointerId) === shape;
22
15
  }
23
- function setPointerCapture(pointerId, shape) {
16
+ export function setPointerCapture(pointerId, shape) {
24
17
  releaseCapture(pointerId);
25
18
  const stage = shape.getStage();
26
19
  if (!stage)
@@ -30,7 +23,7 @@ function setPointerCapture(pointerId, shape) {
30
23
  shape._fire('gotpointercapture', createEvent(new PointerEvent('gotpointercapture')));
31
24
  }
32
25
  }
33
- function releaseCapture(pointerId, target) {
26
+ export function releaseCapture(pointerId, target) {
34
27
  const shape = Captures.get(pointerId);
35
28
  if (!shape)
36
29
  return;
package/lib/Shape.d.ts CHANGED
@@ -1,7 +1,8 @@
1
- import { Node, NodeConfig } from './Node.js';
2
- import { Context } from './Context.js';
3
- import { GetSet, Vector2d } from './types.js';
4
- import { HitCanvas, SceneCanvas } from './Canvas.js';
1
+ import type { NodeConfig } from './Node.ts';
2
+ import { Node } from './Node.ts';
3
+ import type { Context } from './Context.ts';
4
+ import type { GetSet, Vector2d } from './types.ts';
5
+ import type { HitCanvas, SceneCanvas } from './Canvas.ts';
5
6
  export type ShapeConfigHandler<TTarget> = {
6
7
  bivarianceHack(ctx: Context, shape: TTarget): void;
7
8
  }['bivarianceHack'];
@@ -48,6 +49,7 @@ export interface ShapeConfig extends NodeConfig {
48
49
  strokeEnabled?: boolean;
49
50
  lineJoin?: LineJoin;
50
51
  lineCap?: LineCap;
52
+ miterLimit?: number;
51
53
  sceneFunc?: (con: Context, shape: Shape) => void;
52
54
  hitFunc?: (con: Context, shape: Shape) => void;
53
55
  shadowColor?: string;
@@ -165,6 +167,7 @@ export declare class Shape<Config extends ShapeConfig = ShapeConfig> extends Nod
165
167
  hitFunc: GetSet<ShapeConfigHandler<this>, this>;
166
168
  lineCap: GetSet<LineCap, this>;
167
169
  lineJoin: GetSet<LineJoin, this>;
170
+ miterLimit: GetSet<number, this>;
168
171
  perfectDrawEnabled: GetSet<boolean, this>;
169
172
  sceneFunc: GetSet<ShapeConfigHandler<this>, this>;
170
173
  shadowColor: GetSet<string, this>;
package/lib/Shape.js CHANGED
@@ -1,13 +1,10 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Shape = exports.shapes = void 0;
4
- const Global_1 = require("./Global");
5
- const Util_1 = require("./Util");
6
- const Factory_1 = require("./Factory");
7
- const Node_1 = require("./Node");
8
- const Validators_1 = require("./Validators");
9
- const Global_2 = require("./Global");
10
- const PointerEvents = require("./PointerEvents");
1
+ import { Konva } from "./Global.js";
2
+ import { Transform, Util } from "./Util.js";
3
+ import { Factory } from "./Factory.js";
4
+ import { Node } from "./Node.js";
5
+ import { getNumberValidator, getNumberOrAutoValidator, getStringValidator, getBooleanValidator, getStringOrGradientValidator, } from "./Validators.js";
6
+ import { _registerNode } from "./Global.js";
7
+ import * as PointerEvents from "./PointerEvents.js";
11
8
  const HAS_SHADOW = 'hasShadow';
12
9
  const SHADOW_RGBA = 'shadowRGBA';
13
10
  const patternImage = 'patternImage';
@@ -18,10 +15,10 @@ function getDummyContext() {
18
15
  if (dummyContext) {
19
16
  return dummyContext;
20
17
  }
21
- dummyContext = Util_1.Util.createCanvasElement().getContext('2d');
18
+ dummyContext = Util.createCanvasElement().getContext('2d');
22
19
  return dummyContext;
23
20
  }
24
- exports.shapes = {};
21
+ export const shapes = {};
25
22
  function _fillFunc(context) {
26
23
  const fillRule = this.attrs.fillRule;
27
24
  if (fillRule) {
@@ -61,25 +58,25 @@ function _clearLinearGradientCache() {
61
58
  function _clearRadialGradientCache() {
62
59
  this._clearCache(radialGradient);
63
60
  }
64
- class Shape extends Node_1.Node {
61
+ export class Shape extends Node {
65
62
  constructor(config) {
66
63
  super(config);
67
64
  let key;
68
65
  while (true) {
69
- key = Util_1.Util.getRandomColor();
70
- if (key && !(key in exports.shapes)) {
66
+ key = Util.getRandomColor();
67
+ if (key && !(key in shapes)) {
71
68
  break;
72
69
  }
73
70
  }
74
71
  this.colorKey = key;
75
- exports.shapes[key] = this;
72
+ shapes[key] = this;
76
73
  }
77
74
  getContext() {
78
- Util_1.Util.warn('shape.getContext() method is deprecated. Please do not use it.');
75
+ Util.warn('shape.getContext() method is deprecated. Please do not use it.');
79
76
  return this.getLayer().getContext();
80
77
  }
81
78
  getCanvas() {
82
- Util_1.Util.warn('shape.getCanvas() method is deprecated. Please do not use it.');
79
+ Util.warn('shape.getCanvas() method is deprecated. Please do not use it.');
83
80
  return this.getLayer().getCanvas();
84
81
  }
85
82
  getSceneFunc() {
@@ -107,9 +104,9 @@ class Shape extends Node_1.Node {
107
104
  const ctx = getDummyContext();
108
105
  const pattern = ctx.createPattern(this.fillPatternImage(), this.fillPatternRepeat() || 'repeat');
109
106
  if (pattern && pattern.setTransform) {
110
- const tr = new Util_1.Transform();
107
+ const tr = new Transform();
111
108
  tr.translate(this.fillPatternX(), this.fillPatternY());
112
- tr.rotate(Global_1.Konva.getAngle(this.fillPatternRotation()));
109
+ tr.rotate(Konva.getAngle(this.fillPatternRotation()));
113
110
  tr.scale(this.fillPatternScaleX(), this.fillPatternScaleY());
114
111
  tr.translate(-1 * this.fillPatternOffsetX(), -1 * this.fillPatternOffsetY());
115
112
  const m = tr.getMatrix();
@@ -167,7 +164,7 @@ class Shape extends Node_1.Node {
167
164
  if (!this.hasShadow()) {
168
165
  return;
169
166
  }
170
- const rgba = Util_1.Util.colorToRGBA(this.shadowColor());
167
+ const rgba = Util.colorToRGBA(this.shadowColor());
171
168
  if (rgba) {
172
169
  return ('rgba(' +
173
170
  rgba.r +
@@ -226,8 +223,8 @@ class Shape extends Node_1.Node {
226
223
  return p[3] > 0;
227
224
  }
228
225
  destroy() {
229
- Node_1.Node.prototype.destroy.call(this);
230
- delete exports.shapes[this.colorKey];
226
+ Node.prototype.destroy.call(this);
227
+ delete shapes[this.colorKey];
231
228
  delete this.colorKey;
232
229
  return this;
233
230
  }
@@ -251,7 +248,7 @@ class Shape extends Node_1.Node {
251
248
  return false;
252
249
  }
253
250
  setStrokeHitEnabled(val) {
254
- Util_1.Util.warn('strokeHitEnabled property is deprecated. Please use hitStrokeWidth instead.');
251
+ Util.warn('strokeHitEnabled property is deprecated. Please use hitStrokeWidth instead.');
255
252
  if (val) {
256
253
  this.hitStrokeWidth('auto');
257
254
  }
@@ -344,6 +341,7 @@ class Shape extends Node_1.Node {
344
341
  bufferContext.clear();
345
342
  bufferContext.save();
346
343
  bufferContext._applyLineJoin(this);
344
+ bufferContext._applyMiterLimit(this);
347
345
  const o = this.getAbsoluteTransform(top).getMatrix();
348
346
  bufferContext.transform(o[0], o[1], o[2], o[3], o[4], o[5]);
349
347
  drawFunc.call(this, bufferContext, this);
@@ -358,6 +356,7 @@ class Shape extends Node_1.Node {
358
356
  }
359
357
  else {
360
358
  context._applyLineJoin(this);
359
+ context._applyMiterLimit(this);
361
360
  if (!cachingSelf) {
362
361
  const o = this.getAbsoluteTransform(top).getMatrix();
363
362
  context.transform(o[0], o[1], o[2], o[3], o[4], o[5]);
@@ -378,7 +377,7 @@ class Shape extends Node_1.Node {
378
377
  }
379
378
  const layer = this.getLayer(), canvas = can || layer.hitCanvas, context = canvas && canvas.getContext(), drawFunc = this.hitFunc() || this.sceneFunc(), cachedCanvas = this._getCanvasCache(), cachedHitCanvas = cachedCanvas && cachedCanvas.hit;
380
379
  if (!this.colorKey) {
381
- Util_1.Util.warn('Looks like your canvas has a destroyed shape in it. Do not reuse shape after you destroyed it. If you want to reuse shape you should call remove() instead of destroy()');
380
+ Util.warn('Looks like your canvas has a destroyed shape in it. Do not reuse shape after you destroyed it. If you want to reuse shape you should call remove() instead of destroy()');
382
381
  }
383
382
  if (cachedHitCanvas) {
384
383
  context.save();
@@ -393,6 +392,7 @@ class Shape extends Node_1.Node {
393
392
  }
394
393
  context.save();
395
394
  context._applyLineJoin(this);
395
+ context._applyMiterLimit(this);
396
396
  const selfCache = this === top;
397
397
  if (!selfCache) {
398
398
  const o = this.getAbsoluteTransform(top).getMatrix();
@@ -410,7 +410,7 @@ class Shape extends Node_1.Node {
410
410
  const hitImageData = hitContext.getImageData(0, 0, hitWidth, hitHeight);
411
411
  const hitData = hitImageData.data;
412
412
  const len = hitData.length;
413
- const rgbColorKey = Util_1.Util._hexToRgb(this.colorKey);
413
+ const rgbColorKey = Util._hexToRgb(this.colorKey);
414
414
  for (let i = 0; i < len; i += 4) {
415
415
  const alpha = hitData[i + 3];
416
416
  if (alpha > alphaThreshold) {
@@ -426,7 +426,7 @@ class Shape extends Node_1.Node {
426
426
  hitContext.putImageData(hitImageData, 0, 0);
427
427
  }
428
428
  catch (e) {
429
- Util_1.Util.error('Unable to draw hit graph from cached scene canvas. ' + e.message);
429
+ Util.error('Unable to draw hit graph from cached scene canvas. ' + e.message);
430
430
  }
431
431
  return this;
432
432
  }
@@ -440,100 +440,100 @@ class Shape extends Node_1.Node {
440
440
  PointerEvents.releaseCapture(pointerId, this);
441
441
  }
442
442
  }
443
- exports.Shape = Shape;
444
443
  Shape.prototype._fillFunc = _fillFunc;
445
444
  Shape.prototype._strokeFunc = _strokeFunc;
446
445
  Shape.prototype._fillFuncHit = _fillFuncHit;
447
446
  Shape.prototype._strokeFuncHit = _strokeFuncHit;
448
447
  Shape.prototype._centroid = false;
449
448
  Shape.prototype.nodeType = 'Shape';
450
- (0, Global_2._registerNode)(Shape);
449
+ _registerNode(Shape);
451
450
  Shape.prototype.eventListeners = {};
452
451
  Shape.prototype.on.call(Shape.prototype, 'shadowColorChange.konva shadowBlurChange.konva shadowOffsetChange.konva shadowOpacityChange.konva shadowEnabledChange.konva', _clearHasShadowCache);
453
452
  Shape.prototype.on.call(Shape.prototype, 'shadowColorChange.konva shadowOpacityChange.konva shadowEnabledChange.konva', _clearGetShadowRGBACache);
454
453
  Shape.prototype.on.call(Shape.prototype, 'fillPriorityChange.konva fillPatternImageChange.konva fillPatternRepeatChange.konva fillPatternScaleXChange.konva fillPatternScaleYChange.konva fillPatternOffsetXChange.konva fillPatternOffsetYChange.konva fillPatternXChange.konva fillPatternYChange.konva fillPatternRotationChange.konva', _clearFillPatternCache);
455
454
  Shape.prototype.on.call(Shape.prototype, 'fillPriorityChange.konva fillLinearGradientColorStopsChange.konva fillLinearGradientStartPointXChange.konva fillLinearGradientStartPointYChange.konva fillLinearGradientEndPointXChange.konva fillLinearGradientEndPointYChange.konva', _clearLinearGradientCache);
456
455
  Shape.prototype.on.call(Shape.prototype, 'fillPriorityChange.konva fillRadialGradientColorStopsChange.konva fillRadialGradientStartPointXChange.konva fillRadialGradientStartPointYChange.konva fillRadialGradientEndPointXChange.konva fillRadialGradientEndPointYChange.konva fillRadialGradientStartRadiusChange.konva fillRadialGradientEndRadiusChange.konva', _clearRadialGradientCache);
457
- Factory_1.Factory.addGetterSetter(Shape, 'stroke', undefined, (0, Validators_1.getStringOrGradientValidator)());
458
- Factory_1.Factory.addGetterSetter(Shape, 'strokeWidth', 2, (0, Validators_1.getNumberValidator)());
459
- Factory_1.Factory.addGetterSetter(Shape, 'fillAfterStrokeEnabled', false);
460
- Factory_1.Factory.addGetterSetter(Shape, 'hitStrokeWidth', 'auto', (0, Validators_1.getNumberOrAutoValidator)());
461
- Factory_1.Factory.addGetterSetter(Shape, 'strokeHitEnabled', true, (0, Validators_1.getBooleanValidator)());
462
- Factory_1.Factory.addGetterSetter(Shape, 'perfectDrawEnabled', true, (0, Validators_1.getBooleanValidator)());
463
- Factory_1.Factory.addGetterSetter(Shape, 'shadowForStrokeEnabled', true, (0, Validators_1.getBooleanValidator)());
464
- Factory_1.Factory.addGetterSetter(Shape, 'lineJoin');
465
- Factory_1.Factory.addGetterSetter(Shape, 'lineCap');
466
- Factory_1.Factory.addGetterSetter(Shape, 'sceneFunc');
467
- Factory_1.Factory.addGetterSetter(Shape, 'hitFunc');
468
- Factory_1.Factory.addGetterSetter(Shape, 'dash');
469
- Factory_1.Factory.addGetterSetter(Shape, 'dashOffset', 0, (0, Validators_1.getNumberValidator)());
470
- Factory_1.Factory.addGetterSetter(Shape, 'shadowColor', undefined, (0, Validators_1.getStringValidator)());
471
- Factory_1.Factory.addGetterSetter(Shape, 'shadowBlur', 0, (0, Validators_1.getNumberValidator)());
472
- Factory_1.Factory.addGetterSetter(Shape, 'shadowOpacity', 1, (0, Validators_1.getNumberValidator)());
473
- Factory_1.Factory.addComponentsGetterSetter(Shape, 'shadowOffset', ['x', 'y']);
474
- Factory_1.Factory.addGetterSetter(Shape, 'shadowOffsetX', 0, (0, Validators_1.getNumberValidator)());
475
- Factory_1.Factory.addGetterSetter(Shape, 'shadowOffsetY', 0, (0, Validators_1.getNumberValidator)());
476
- Factory_1.Factory.addGetterSetter(Shape, 'fillPatternImage');
477
- Factory_1.Factory.addGetterSetter(Shape, 'fill', undefined, (0, Validators_1.getStringOrGradientValidator)());
478
- Factory_1.Factory.addGetterSetter(Shape, 'fillPatternX', 0, (0, Validators_1.getNumberValidator)());
479
- Factory_1.Factory.addGetterSetter(Shape, 'fillPatternY', 0, (0, Validators_1.getNumberValidator)());
480
- Factory_1.Factory.addGetterSetter(Shape, 'fillLinearGradientColorStops');
481
- Factory_1.Factory.addGetterSetter(Shape, 'strokeLinearGradientColorStops');
482
- Factory_1.Factory.addGetterSetter(Shape, 'fillRadialGradientStartRadius', 0);
483
- Factory_1.Factory.addGetterSetter(Shape, 'fillRadialGradientEndRadius', 0);
484
- Factory_1.Factory.addGetterSetter(Shape, 'fillRadialGradientColorStops');
485
- Factory_1.Factory.addGetterSetter(Shape, 'fillPatternRepeat', 'repeat');
486
- Factory_1.Factory.addGetterSetter(Shape, 'fillEnabled', true);
487
- Factory_1.Factory.addGetterSetter(Shape, 'strokeEnabled', true);
488
- Factory_1.Factory.addGetterSetter(Shape, 'shadowEnabled', true);
489
- Factory_1.Factory.addGetterSetter(Shape, 'dashEnabled', true);
490
- Factory_1.Factory.addGetterSetter(Shape, 'strokeScaleEnabled', true);
491
- Factory_1.Factory.addGetterSetter(Shape, 'fillPriority', 'color');
492
- Factory_1.Factory.addComponentsGetterSetter(Shape, 'fillPatternOffset', ['x', 'y']);
493
- Factory_1.Factory.addGetterSetter(Shape, 'fillPatternOffsetX', 0, (0, Validators_1.getNumberValidator)());
494
- Factory_1.Factory.addGetterSetter(Shape, 'fillPatternOffsetY', 0, (0, Validators_1.getNumberValidator)());
495
- Factory_1.Factory.addComponentsGetterSetter(Shape, 'fillPatternScale', ['x', 'y']);
496
- Factory_1.Factory.addGetterSetter(Shape, 'fillPatternScaleX', 1, (0, Validators_1.getNumberValidator)());
497
- Factory_1.Factory.addGetterSetter(Shape, 'fillPatternScaleY', 1, (0, Validators_1.getNumberValidator)());
498
- Factory_1.Factory.addComponentsGetterSetter(Shape, 'fillLinearGradientStartPoint', [
456
+ Factory.addGetterSetter(Shape, 'stroke', undefined, getStringOrGradientValidator());
457
+ Factory.addGetterSetter(Shape, 'strokeWidth', 2, getNumberValidator());
458
+ Factory.addGetterSetter(Shape, 'fillAfterStrokeEnabled', false);
459
+ Factory.addGetterSetter(Shape, 'hitStrokeWidth', 'auto', getNumberOrAutoValidator());
460
+ Factory.addGetterSetter(Shape, 'strokeHitEnabled', true, getBooleanValidator());
461
+ Factory.addGetterSetter(Shape, 'perfectDrawEnabled', true, getBooleanValidator());
462
+ Factory.addGetterSetter(Shape, 'shadowForStrokeEnabled', true, getBooleanValidator());
463
+ Factory.addGetterSetter(Shape, 'lineJoin');
464
+ Factory.addGetterSetter(Shape, 'lineCap');
465
+ Factory.addGetterSetter(Shape, 'miterLimit');
466
+ Factory.addGetterSetter(Shape, 'sceneFunc');
467
+ Factory.addGetterSetter(Shape, 'hitFunc');
468
+ Factory.addGetterSetter(Shape, 'dash');
469
+ Factory.addGetterSetter(Shape, 'dashOffset', 0, getNumberValidator());
470
+ Factory.addGetterSetter(Shape, 'shadowColor', undefined, getStringValidator());
471
+ Factory.addGetterSetter(Shape, 'shadowBlur', 0, getNumberValidator());
472
+ Factory.addGetterSetter(Shape, 'shadowOpacity', 1, getNumberValidator());
473
+ Factory.addComponentsGetterSetter(Shape, 'shadowOffset', ['x', 'y']);
474
+ Factory.addGetterSetter(Shape, 'shadowOffsetX', 0, getNumberValidator());
475
+ Factory.addGetterSetter(Shape, 'shadowOffsetY', 0, getNumberValidator());
476
+ Factory.addGetterSetter(Shape, 'fillPatternImage');
477
+ Factory.addGetterSetter(Shape, 'fill', undefined, getStringOrGradientValidator());
478
+ Factory.addGetterSetter(Shape, 'fillPatternX', 0, getNumberValidator());
479
+ Factory.addGetterSetter(Shape, 'fillPatternY', 0, getNumberValidator());
480
+ Factory.addGetterSetter(Shape, 'fillLinearGradientColorStops');
481
+ Factory.addGetterSetter(Shape, 'strokeLinearGradientColorStops');
482
+ Factory.addGetterSetter(Shape, 'fillRadialGradientStartRadius', 0);
483
+ Factory.addGetterSetter(Shape, 'fillRadialGradientEndRadius', 0);
484
+ Factory.addGetterSetter(Shape, 'fillRadialGradientColorStops');
485
+ Factory.addGetterSetter(Shape, 'fillPatternRepeat', 'repeat');
486
+ Factory.addGetterSetter(Shape, 'fillEnabled', true);
487
+ Factory.addGetterSetter(Shape, 'strokeEnabled', true);
488
+ Factory.addGetterSetter(Shape, 'shadowEnabled', true);
489
+ Factory.addGetterSetter(Shape, 'dashEnabled', true);
490
+ Factory.addGetterSetter(Shape, 'strokeScaleEnabled', true);
491
+ Factory.addGetterSetter(Shape, 'fillPriority', 'color');
492
+ Factory.addComponentsGetterSetter(Shape, 'fillPatternOffset', ['x', 'y']);
493
+ Factory.addGetterSetter(Shape, 'fillPatternOffsetX', 0, getNumberValidator());
494
+ Factory.addGetterSetter(Shape, 'fillPatternOffsetY', 0, getNumberValidator());
495
+ Factory.addComponentsGetterSetter(Shape, 'fillPatternScale', ['x', 'y']);
496
+ Factory.addGetterSetter(Shape, 'fillPatternScaleX', 1, getNumberValidator());
497
+ Factory.addGetterSetter(Shape, 'fillPatternScaleY', 1, getNumberValidator());
498
+ Factory.addComponentsGetterSetter(Shape, 'fillLinearGradientStartPoint', [
499
499
  'x',
500
500
  'y',
501
501
  ]);
502
- Factory_1.Factory.addComponentsGetterSetter(Shape, 'strokeLinearGradientStartPoint', [
502
+ Factory.addComponentsGetterSetter(Shape, 'strokeLinearGradientStartPoint', [
503
503
  'x',
504
504
  'y',
505
505
  ]);
506
- Factory_1.Factory.addGetterSetter(Shape, 'fillLinearGradientStartPointX', 0);
507
- Factory_1.Factory.addGetterSetter(Shape, 'strokeLinearGradientStartPointX', 0);
508
- Factory_1.Factory.addGetterSetter(Shape, 'fillLinearGradientStartPointY', 0);
509
- Factory_1.Factory.addGetterSetter(Shape, 'strokeLinearGradientStartPointY', 0);
510
- Factory_1.Factory.addComponentsGetterSetter(Shape, 'fillLinearGradientEndPoint', [
506
+ Factory.addGetterSetter(Shape, 'fillLinearGradientStartPointX', 0);
507
+ Factory.addGetterSetter(Shape, 'strokeLinearGradientStartPointX', 0);
508
+ Factory.addGetterSetter(Shape, 'fillLinearGradientStartPointY', 0);
509
+ Factory.addGetterSetter(Shape, 'strokeLinearGradientStartPointY', 0);
510
+ Factory.addComponentsGetterSetter(Shape, 'fillLinearGradientEndPoint', [
511
511
  'x',
512
512
  'y',
513
513
  ]);
514
- Factory_1.Factory.addComponentsGetterSetter(Shape, 'strokeLinearGradientEndPoint', [
514
+ Factory.addComponentsGetterSetter(Shape, 'strokeLinearGradientEndPoint', [
515
515
  'x',
516
516
  'y',
517
517
  ]);
518
- Factory_1.Factory.addGetterSetter(Shape, 'fillLinearGradientEndPointX', 0);
519
- Factory_1.Factory.addGetterSetter(Shape, 'strokeLinearGradientEndPointX', 0);
520
- Factory_1.Factory.addGetterSetter(Shape, 'fillLinearGradientEndPointY', 0);
521
- Factory_1.Factory.addGetterSetter(Shape, 'strokeLinearGradientEndPointY', 0);
522
- Factory_1.Factory.addComponentsGetterSetter(Shape, 'fillRadialGradientStartPoint', [
518
+ Factory.addGetterSetter(Shape, 'fillLinearGradientEndPointX', 0);
519
+ Factory.addGetterSetter(Shape, 'strokeLinearGradientEndPointX', 0);
520
+ Factory.addGetterSetter(Shape, 'fillLinearGradientEndPointY', 0);
521
+ Factory.addGetterSetter(Shape, 'strokeLinearGradientEndPointY', 0);
522
+ Factory.addComponentsGetterSetter(Shape, 'fillRadialGradientStartPoint', [
523
523
  'x',
524
524
  'y',
525
525
  ]);
526
- Factory_1.Factory.addGetterSetter(Shape, 'fillRadialGradientStartPointX', 0);
527
- Factory_1.Factory.addGetterSetter(Shape, 'fillRadialGradientStartPointY', 0);
528
- Factory_1.Factory.addComponentsGetterSetter(Shape, 'fillRadialGradientEndPoint', [
526
+ Factory.addGetterSetter(Shape, 'fillRadialGradientStartPointX', 0);
527
+ Factory.addGetterSetter(Shape, 'fillRadialGradientStartPointY', 0);
528
+ Factory.addComponentsGetterSetter(Shape, 'fillRadialGradientEndPoint', [
529
529
  'x',
530
530
  'y',
531
531
  ]);
532
- Factory_1.Factory.addGetterSetter(Shape, 'fillRadialGradientEndPointX', 0);
533
- Factory_1.Factory.addGetterSetter(Shape, 'fillRadialGradientEndPointY', 0);
534
- Factory_1.Factory.addGetterSetter(Shape, 'fillPatternRotation', 0);
535
- Factory_1.Factory.addGetterSetter(Shape, 'fillRule', undefined, (0, Validators_1.getStringValidator)());
536
- Factory_1.Factory.backCompat(Shape, {
532
+ Factory.addGetterSetter(Shape, 'fillRadialGradientEndPointX', 0);
533
+ Factory.addGetterSetter(Shape, 'fillRadialGradientEndPointY', 0);
534
+ Factory.addGetterSetter(Shape, 'fillPatternRotation', 0);
535
+ Factory.addGetterSetter(Shape, 'fillRule', undefined, getStringValidator());
536
+ Factory.backCompat(Shape, {
537
537
  dashArray: 'dash',
538
538
  getDashArray: 'getDash',
539
539
  setDashArray: 'getDash',
package/lib/Stage.d.ts CHANGED
@@ -1,8 +1,9 @@
1
- import { Container, ContainerConfig } from './Container.js';
2
- import { SceneCanvas, HitCanvas } from './Canvas.js';
3
- import { GetSet, Vector2d } from './types.js';
4
- import { Shape } from './Shape.js';
5
- import { Layer } from './Layer.js';
1
+ import type { ContainerConfig } from './Container.ts';
2
+ import { Container } from './Container.ts';
3
+ import { SceneCanvas, HitCanvas } from './Canvas.ts';
4
+ import type { GetSet, Vector2d } from './types.ts';
5
+ import type { Shape } from './Shape.ts';
6
+ import type { Layer } from './Layer.ts';
6
7
  export interface StageConfig extends ContainerConfig {
7
8
  container?: HTMLDivElement | string;
8
9
  }
@@ -48,7 +49,7 @@ export declare class Stage extends Container<Layer> {
48
49
  getStage(): this;
49
50
  getContent(): HTMLDivElement;
50
51
  _toKonvaCanvas(config: any): SceneCanvas;
51
- getIntersection(pos: Vector2d): Shape<import("./Shape.js").ShapeConfig> | null;
52
+ getIntersection(pos: Vector2d): Shape<import("./Shape.ts").ShapeConfig> | null;
52
53
  _resizeDOM(): void;
53
54
  add(layer: Layer, ...rest: any[]): this;
54
55
  getParent(): null;
@@ -60,7 +61,7 @@ export declare class Stage extends Container<Layer> {
60
61
  _bindContentEvents(): void;
61
62
  _pointerenter(evt: PointerEvent): void;
62
63
  _pointerover(evt: any): void;
63
- _getTargetShape(evenType: any): Shape<import("./Shape.js").ShapeConfig> | null;
64
+ _getTargetShape(evenType: any): Shape<import("./Shape.ts").ShapeConfig> | null;
64
65
  _pointerleave(evt: any): void;
65
66
  _pointerdown(evt: TouchEvent | MouseEvent | PointerEvent): void;
66
67
  _pointermove(evt: TouchEvent | MouseEvent | PointerEvent): void;