konva 8.4.2 → 9.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.
- package/README.md +1 -9
- package/konva.js +17669 -16968
- package/konva.min.js +3 -3
- package/lib/Animation.d.ts +2 -2
- package/lib/Animation.js +11 -7
- package/lib/BezierFunctions.d.ts +6 -0
- package/lib/BezierFunctions.js +791 -0
- package/lib/Canvas.d.ts +2 -1
- package/lib/Canvas.js +26 -18
- package/lib/Container.d.ts +4 -4
- package/lib/Container.js +16 -12
- package/lib/Context.d.ts +16 -13
- package/lib/Context.js +27 -19
- package/lib/Core.d.ts +2 -2
- package/lib/Core.js +7 -3
- package/lib/DragAndDrop.d.ts +3 -3
- package/lib/DragAndDrop.js +25 -22
- package/lib/Factory.js +27 -24
- package/lib/FastLayer.d.ts +1 -1
- package/lib/FastLayer.js +10 -6
- package/lib/Global.js +16 -12
- package/lib/Group.d.ts +3 -3
- package/lib/Group.js +10 -6
- package/lib/Layer.d.ts +9 -9
- package/lib/Layer.js +37 -33
- package/lib/Node.d.ts +8 -8
- package/lib/Node.js +95 -90
- package/lib/PointerEvents.d.ts +4 -4
- package/lib/PointerEvents.js +15 -7
- package/lib/Shape.d.ts +6 -4
- package/lib/Shape.js +90 -86
- package/lib/Stage.d.ts +7 -7
- package/lib/Stage.js +51 -47
- package/lib/Tween.d.ts +2 -2
- package/lib/Tween.js +26 -22
- package/lib/Util.d.ts +2 -2
- package/lib/Util.js +29 -25
- package/lib/Validators.js +58 -44
- package/lib/_CoreInternals.d.ts +29 -29
- package/lib/_CoreInternals.js +36 -33
- package/lib/_FullInternals.d.ts +67 -67
- package/lib/_FullInternals.js +78 -75
- package/lib/filters/Blur.d.ts +1 -1
- package/lib/filters/Blur.js +9 -5
- package/lib/filters/Brighten.d.ts +1 -1
- package/lib/filters/Brighten.js +9 -5
- package/lib/filters/Contrast.d.ts +1 -1
- package/lib/filters/Contrast.js +9 -5
- package/lib/filters/Emboss.d.ts +1 -1
- package/lib/filters/Emboss.js +14 -10
- package/lib/filters/Enhance.d.ts +1 -1
- package/lib/filters/Enhance.js +9 -5
- package/lib/filters/Grayscale.d.ts +1 -1
- package/lib/filters/Grayscale.js +5 -1
- package/lib/filters/HSL.d.ts +1 -1
- package/lib/filters/HSL.js +11 -7
- package/lib/filters/HSV.d.ts +1 -1
- package/lib/filters/HSV.js +11 -7
- package/lib/filters/Invert.d.ts +1 -1
- package/lib/filters/Invert.js +5 -1
- package/lib/filters/Kaleidoscope.d.ts +1 -1
- package/lib/filters/Kaleidoscope.js +13 -9
- package/lib/filters/Mask.d.ts +1 -1
- package/lib/filters/Mask.js +9 -5
- package/lib/filters/Noise.d.ts +1 -1
- package/lib/filters/Noise.js +9 -5
- package/lib/filters/Pixelate.d.ts +1 -1
- package/lib/filters/Pixelate.js +11 -7
- package/lib/filters/Posterize.d.ts +1 -1
- package/lib/filters/Posterize.js +9 -5
- package/lib/filters/RGB.d.ts +1 -1
- package/lib/filters/RGB.js +11 -7
- package/lib/filters/RGBA.d.ts +1 -1
- package/lib/filters/RGBA.js +12 -8
- package/lib/filters/Sepia.d.ts +1 -1
- package/lib/filters/Sepia.js +5 -1
- package/lib/filters/Solarize.d.ts +1 -1
- package/lib/filters/Solarize.js +5 -1
- package/lib/filters/Threshold.d.ts +1 -1
- package/lib/filters/Threshold.js +9 -5
- package/lib/index-node.d.ts +1 -1
- package/lib/index-node.js +7 -5
- package/lib/index-types.d.ts +124 -124
- package/lib/index.d.ts +1 -1
- package/lib/index.js +4 -2
- package/lib/shapes/Arc.d.ts +6 -5
- package/lib/shapes/Arc.js +17 -13
- package/lib/shapes/Arrow.d.ts +5 -4
- package/lib/shapes/Arrow.js +17 -13
- package/lib/shapes/Circle.d.ts +6 -5
- package/lib/shapes/Circle.js +11 -7
- package/lib/shapes/Ellipse.d.ts +6 -5
- package/lib/shapes/Ellipse.js +13 -9
- package/lib/shapes/Image.d.ts +5 -5
- package/lib/shapes/Image.js +21 -17
- package/lib/shapes/Label.d.ts +8 -7
- package/lib/shapes/Label.js +18 -13
- package/lib/shapes/Line.d.ts +3 -3
- package/lib/shapes/Line.js +14 -10
- package/lib/shapes/Path.d.ts +6 -3
- package/lib/shapes/Path.js +44 -43
- package/lib/shapes/Rect.d.ts +3 -3
- package/lib/shapes/Rect.js +13 -9
- package/lib/shapes/RegularPolygon.d.ts +6 -5
- package/lib/shapes/RegularPolygon.js +12 -8
- package/lib/shapes/Ring.d.ts +6 -5
- package/lib/shapes/Ring.js +12 -8
- package/lib/shapes/Sprite.d.ts +7 -6
- package/lib/shapes/Sprite.js +19 -15
- package/lib/shapes/Star.d.ts +6 -5
- package/lib/shapes/Star.js +13 -9
- package/lib/shapes/Text.d.ts +8 -7
- package/lib/shapes/Text.js +31 -26
- package/lib/shapes/TextPath.d.ts +12 -7
- package/lib/shapes/TextPath.js +82 -188
- package/lib/shapes/Transformer.d.ts +10 -10
- package/lib/shapes/Transformer.js +92 -81
- package/lib/shapes/Wedge.d.ts +6 -5
- package/lib/shapes/Wedge.js +16 -12
- package/lib/types.d.ts +6 -0
- package/lib/types.js +5 -2
- package/package.json +13 -42
- package/cmj/Animation.d.ts +0 -24
- package/cmj/Animation.js +0 -145
- package/cmj/Canvas.d.ts +0 -32
- package/cmj/Canvas.js +0 -114
- package/cmj/Container.d.ts +0 -47
- package/cmj/Container.js +0 -325
- package/cmj/Context.d.ts +0 -84
- package/cmj/Context.js +0 -538
- package/cmj/Core.d.ts +0 -3
- package/cmj/Core.js +0 -7
- package/cmj/DragAndDrop.d.ts +0 -17
- package/cmj/DragAndDrop.js +0 -111
- package/cmj/Factory.d.ts +0 -11
- package/cmj/Factory.js +0 -125
- package/cmj/FastLayer.d.ts +0 -4
- package/cmj/FastLayer.js +0 -16
- package/cmj/Global.d.ts +0 -34
- package/cmj/Global.js +0 -61
- package/cmj/Group.d.ts +0 -8
- package/cmj/Group.js +0 -17
- package/cmj/Layer.d.ts +0 -61
- package/cmj/Layer.js +0 -309
- package/cmj/Node.d.ts +0 -328
- package/cmj/Node.js +0 -1420
- package/cmj/PointerEvents.d.ts +0 -11
- package/cmj/PointerEvents.js +0 -45
- package/cmj/Shape.d.ts +0 -184
- package/cmj/Shape.js +0 -521
- package/cmj/Stage.d.ts +0 -85
- package/cmj/Stage.js +0 -692
- package/cmj/Tween.d.ts +0 -86
- package/cmj/Tween.js +0 -520
- package/cmj/Util.d.ts +0 -91
- package/cmj/Util.js +0 -801
- package/cmj/Validators.d.ts +0 -11
- package/cmj/Validators.js +0 -192
- package/cmj/_CoreInternals.d.ts +0 -152
- package/cmj/_CoreInternals.js +0 -37
- package/cmj/_FullInternals.d.ts +0 -196
- package/cmj/_FullInternals.js +0 -81
- package/cmj/filters/Blur.d.ts +0 -2
- package/cmj/filters/Blur.js +0 -701
- package/cmj/filters/Brighten.d.ts +0 -2
- package/cmj/filters/Brighten.js +0 -16
- package/cmj/filters/Contrast.d.ts +0 -2
- package/cmj/filters/Contrast.js +0 -38
- package/cmj/filters/Emboss.d.ts +0 -2
- package/cmj/filters/Emboss.js +0 -106
- package/cmj/filters/Enhance.d.ts +0 -2
- package/cmj/filters/Enhance.js +0 -87
- package/cmj/filters/Grayscale.d.ts +0 -2
- package/cmj/filters/Grayscale.js +0 -13
- package/cmj/filters/HSL.d.ts +0 -2
- package/cmj/filters/HSL.js +0 -28
- package/cmj/filters/HSV.d.ts +0 -2
- package/cmj/filters/HSV.js +0 -28
- package/cmj/filters/Invert.d.ts +0 -2
- package/cmj/filters/Invert.js +0 -12
- package/cmj/filters/Kaleidoscope.d.ts +0 -2
- package/cmj/filters/Kaleidoscope.js +0 -137
- package/cmj/filters/Mask.d.ts +0 -2
- package/cmj/filters/Mask.js +0 -144
- package/cmj/filters/Noise.d.ts +0 -2
- package/cmj/filters/Noise.js +0 -16
- package/cmj/filters/Pixelate.d.ts +0 -2
- package/cmj/filters/Pixelate.js +0 -64
- package/cmj/filters/Posterize.d.ts +0 -2
- package/cmj/filters/Posterize.js +0 -14
- package/cmj/filters/RGB.d.ts +0 -2
- package/cmj/filters/RGB.js +0 -43
- package/cmj/filters/RGBA.d.ts +0 -2
- package/cmj/filters/RGBA.js +0 -53
- package/cmj/filters/Sepia.d.ts +0 -2
- package/cmj/filters/Sepia.js +0 -15
- package/cmj/filters/Solarize.d.ts +0 -2
- package/cmj/filters/Solarize.js +0 -29
- package/cmj/filters/Threshold.d.ts +0 -2
- package/cmj/filters/Threshold.js +0 -14
- package/cmj/index-node.d.ts +0 -2
- package/cmj/index-node.js +0 -21
- package/cmj/index-types.d.ts +0 -181
- package/cmj/index.d.ts +0 -2
- package/cmj/index.js +0 -4
- package/cmj/package.json +0 -6
- package/cmj/shapes/Arc.d.ts +0 -25
- package/cmj/shapes/Arc.js +0 -59
- package/cmj/shapes/Arrow.d.ts +0 -25
- package/cmj/shapes/Arrow.js +0 -103
- package/cmj/shapes/Circle.d.ts +0 -13
- package/cmj/shapes/Circle.js +0 -37
- package/cmj/shapes/Ellipse.d.ts +0 -16
- package/cmj/shapes/Ellipse.js +0 -41
- package/cmj/shapes/Image.d.ts +0 -25
- package/cmj/shapes/Image.js +0 -117
- package/cmj/shapes/Label.d.ts +0 -35
- package/cmj/shapes/Label.js +0 -178
- package/cmj/shapes/Line.d.ts +0 -28
- package/cmj/shapes/Line.js +0 -159
- package/cmj/shapes/Path.d.ts +0 -37
- package/cmj/shapes/Path.js +0 -631
- package/cmj/shapes/Rect.d.ts +0 -10
- package/cmj/shapes/Rect.js +0 -26
- package/cmj/shapes/RegularPolygon.d.ts +0 -22
- package/cmj/shapes/RegularPolygon.js +0 -69
- package/cmj/shapes/Ring.d.ts +0 -15
- package/cmj/shapes/Ring.js +0 -37
- package/cmj/shapes/Sprite.d.ts +0 -30
- package/cmj/shapes/Sprite.js +0 -112
- package/cmj/shapes/Star.d.ts +0 -17
- package/cmj/shapes/Star.js +0 -42
- package/cmj/shapes/Text.d.ts +0 -62
- package/cmj/shapes/Text.js +0 -373
- package/cmj/shapes/TextPath.d.ts +0 -55
- package/cmj/shapes/TextPath.js +0 -351
- package/cmj/shapes/Transformer.d.ts +0 -116
- package/cmj/shapes/Transformer.js +0 -964
- package/cmj/shapes/Wedge.d.ts +0 -17
- package/cmj/shapes/Wedge.js +0 -42
- package/cmj/types.d.ts +0 -50
- package/cmj/types.js +0 -25
package/lib/Tween.js
CHANGED
|
@@ -1,7 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Easings = exports.Tween = void 0;
|
|
4
|
+
const Util_1 = require("./Util");
|
|
5
|
+
const Animation_1 = require("./Animation");
|
|
6
|
+
const Node_1 = require("./Node");
|
|
7
|
+
const Global_1 = require("./Global");
|
|
5
8
|
var blacklist = {
|
|
6
9
|
node: 1,
|
|
7
10
|
duration: 1,
|
|
@@ -123,9 +126,9 @@ class TweenEngine {
|
|
|
123
126
|
return new Date().getTime();
|
|
124
127
|
}
|
|
125
128
|
}
|
|
126
|
-
|
|
129
|
+
class Tween {
|
|
127
130
|
constructor(config) {
|
|
128
|
-
var that = this, node = config.node, nodeId = node._id, duration, easing = config.easing || Easings.Linear, yoyo = !!config.yoyo, key;
|
|
131
|
+
var that = this, node = config.node, nodeId = node._id, duration, easing = config.easing || exports.Easings.Linear, yoyo = !!config.yoyo, key;
|
|
129
132
|
if (typeof config.duration === 'undefined') {
|
|
130
133
|
duration = 0.3;
|
|
131
134
|
}
|
|
@@ -138,11 +141,11 @@ export class Tween {
|
|
|
138
141
|
this.node = node;
|
|
139
142
|
this._id = idCounter++;
|
|
140
143
|
var layers = node.getLayer() ||
|
|
141
|
-
(node instanceof Konva['Stage'] ? node.getLayers() : null);
|
|
144
|
+
(node instanceof Global_1.Konva['Stage'] ? node.getLayers() : null);
|
|
142
145
|
if (!layers) {
|
|
143
|
-
Util.error('Tween constructor have `node` that is not in a layer. Please add node into layer first.');
|
|
146
|
+
Util_1.Util.error('Tween constructor have `node` that is not in a layer. Please add node into layer first.');
|
|
144
147
|
}
|
|
145
|
-
this.anim = new Animation(function () {
|
|
148
|
+
this.anim = new Animation_1.Animation(function () {
|
|
146
149
|
that.tween.onEnterFrame();
|
|
147
150
|
}, layers);
|
|
148
151
|
this.tween = new TweenEngine(key, function (i) {
|
|
@@ -175,17 +178,17 @@ export class Tween {
|
|
|
175
178
|
delete Tween.attrs[nodeId][tweenId][key];
|
|
176
179
|
}
|
|
177
180
|
start = node.getAttr(key);
|
|
178
|
-
if (Util._isArray(end)) {
|
|
181
|
+
if (Util_1.Util._isArray(end)) {
|
|
179
182
|
diff = [];
|
|
180
183
|
len = Math.max(end.length, start.length);
|
|
181
184
|
if (key === 'points' && end.length !== start.length) {
|
|
182
185
|
if (end.length > start.length) {
|
|
183
186
|
trueStart = start;
|
|
184
|
-
start = Util._prepareArrayForTween(start, end, node.closed());
|
|
187
|
+
start = Util_1.Util._prepareArrayForTween(start, end, node.closed());
|
|
185
188
|
}
|
|
186
189
|
else {
|
|
187
190
|
trueEnd = end;
|
|
188
|
-
end = Util._prepareArrayForTween(end, start, node.closed());
|
|
191
|
+
end = Util_1.Util._prepareArrayForTween(end, start, node.closed());
|
|
189
192
|
}
|
|
190
193
|
}
|
|
191
194
|
if (key.indexOf('fill') === 0) {
|
|
@@ -194,8 +197,8 @@ export class Tween {
|
|
|
194
197
|
diff.push(end[n] - start[n]);
|
|
195
198
|
}
|
|
196
199
|
else {
|
|
197
|
-
var startRGBA = Util.colorToRGBA(start[n]);
|
|
198
|
-
endRGBA = Util.colorToRGBA(end[n]);
|
|
200
|
+
var startRGBA = Util_1.Util.colorToRGBA(start[n]);
|
|
201
|
+
endRGBA = Util_1.Util.colorToRGBA(end[n]);
|
|
199
202
|
start[n] = startRGBA;
|
|
200
203
|
diff.push({
|
|
201
204
|
r: endRGBA.r - startRGBA.r,
|
|
@@ -213,8 +216,8 @@ export class Tween {
|
|
|
213
216
|
}
|
|
214
217
|
}
|
|
215
218
|
else if (colorAttrs.indexOf(key) !== -1) {
|
|
216
|
-
start = Util.colorToRGBA(start);
|
|
217
|
-
endRGBA = Util.colorToRGBA(end);
|
|
219
|
+
start = Util_1.Util.colorToRGBA(start);
|
|
220
|
+
endRGBA = Util_1.Util.colorToRGBA(end);
|
|
218
221
|
diff = {
|
|
219
222
|
r: endRGBA.r - start.r,
|
|
220
223
|
g: endRGBA.g - start.g,
|
|
@@ -241,7 +244,7 @@ export class Tween {
|
|
|
241
244
|
start = attr.start;
|
|
242
245
|
diff = attr.diff;
|
|
243
246
|
end = attr.end;
|
|
244
|
-
if (Util._isArray(start)) {
|
|
247
|
+
if (Util_1.Util._isArray(start)) {
|
|
245
248
|
newVal = [];
|
|
246
249
|
len = Math.max(start.length, end.length);
|
|
247
250
|
if (key.indexOf('fill') === 0) {
|
|
@@ -357,7 +360,8 @@ export class Tween {
|
|
|
357
360
|
}
|
|
358
361
|
Tween.attrs = {};
|
|
359
362
|
Tween.tweens = {};
|
|
360
|
-
|
|
363
|
+
exports.Tween = Tween;
|
|
364
|
+
Node_1.Node.prototype.to = function (params) {
|
|
361
365
|
var onFinish = params.onFinish;
|
|
362
366
|
params.node = this;
|
|
363
367
|
params.onFinish = function () {
|
|
@@ -369,7 +373,7 @@ Node.prototype.to = function (params) {
|
|
|
369
373
|
var tween = new Tween(params);
|
|
370
374
|
tween.play();
|
|
371
375
|
};
|
|
372
|
-
|
|
376
|
+
exports.Easings = {
|
|
373
377
|
BackEaseIn(t, b, c, d) {
|
|
374
378
|
var s = 1.70158;
|
|
375
379
|
return c * (t /= d) * t * ((s + 1) * t - s) + b;
|
|
@@ -476,14 +480,14 @@ export const Easings = {
|
|
|
476
480
|
}
|
|
477
481
|
},
|
|
478
482
|
BounceEaseIn(t, b, c, d) {
|
|
479
|
-
return c - Easings.BounceEaseOut(d - t, 0, c, d) + b;
|
|
483
|
+
return c - exports.Easings.BounceEaseOut(d - t, 0, c, d) + b;
|
|
480
484
|
},
|
|
481
485
|
BounceEaseInOut(t, b, c, d) {
|
|
482
486
|
if (t < d / 2) {
|
|
483
|
-
return Easings.BounceEaseIn(t * 2, 0, c, d) * 0.5 + b;
|
|
487
|
+
return exports.Easings.BounceEaseIn(t * 2, 0, c, d) * 0.5 + b;
|
|
484
488
|
}
|
|
485
489
|
else {
|
|
486
|
-
return Easings.BounceEaseOut(t * 2 - d, 0, c, d) * 0.5 + c * 0.5 + b;
|
|
490
|
+
return exports.Easings.BounceEaseOut(t * 2 - d, 0, c, d) * 0.5 + c * 0.5 + b;
|
|
487
491
|
}
|
|
488
492
|
},
|
|
489
493
|
EaseIn(t, b, c, d) {
|
package/lib/Util.d.ts
CHANGED
package/lib/Util.js
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Util = exports.Transform = void 0;
|
|
4
|
+
const Global_1 = require("./Global");
|
|
5
|
+
class Transform {
|
|
3
6
|
constructor(m = [1, 0, 0, 1, 0, 0]) {
|
|
4
7
|
this.dirty = false;
|
|
5
8
|
this.m = (m && m.slice()) || [1, 0, 0, 1, 0, 0];
|
|
@@ -142,10 +145,11 @@ export class Transform {
|
|
|
142
145
|
}
|
|
143
146
|
else {
|
|
144
147
|
}
|
|
145
|
-
result.rotation = Util._getRotation(result.rotation);
|
|
148
|
+
result.rotation = exports.Util._getRotation(result.rotation);
|
|
146
149
|
return result;
|
|
147
150
|
}
|
|
148
151
|
}
|
|
152
|
+
exports.Transform = Transform;
|
|
149
153
|
var OBJECT_ARRAY = '[object Array]', OBJECT_NUMBER = '[object Number]', OBJECT_STRING = '[object String]', OBJECT_BOOLEAN = '[object Boolean]', PI_OVER_DEG180 = Math.PI / 180, DEG180_OVER_PI = 180 / Math.PI, HASH = '#', EMPTY_STRING = '', ZERO = '0', KONVA_WARNING = 'Konva warning: ', KONVA_ERROR = 'Konva error: ', RGB_PAREN = 'rgb(', COLORS = {
|
|
150
154
|
aliceblue: [240, 248, 255],
|
|
151
155
|
antiquewhite: [250, 235, 215],
|
|
@@ -301,7 +305,7 @@ const req = (typeof requestAnimationFrame !== 'undefined' && requestAnimationFra
|
|
|
301
305
|
function (f) {
|
|
302
306
|
setTimeout(f, 60);
|
|
303
307
|
};
|
|
304
|
-
|
|
308
|
+
exports.Util = {
|
|
305
309
|
_isElement(obj) {
|
|
306
310
|
return !!(obj && obj.nodeType == 1);
|
|
307
311
|
},
|
|
@@ -380,7 +384,7 @@ export const Util = {
|
|
|
380
384
|
return false;
|
|
381
385
|
},
|
|
382
386
|
_urlToImage(url, callback) {
|
|
383
|
-
var imageObj = Util.createImageElement();
|
|
387
|
+
var imageObj = exports.Util.createImageElement();
|
|
384
388
|
imageObj.onload = function () {
|
|
385
389
|
callback(imageObj);
|
|
386
390
|
};
|
|
@@ -436,14 +440,14 @@ export const Util = {
|
|
|
436
440
|
},
|
|
437
441
|
colorToRGBA(str) {
|
|
438
442
|
str = str || 'black';
|
|
439
|
-
return (Util._namedColorToRBA(str) ||
|
|
440
|
-
Util._hex3ColorToRGBA(str) ||
|
|
441
|
-
Util._hex4ColorToRGBA(str) ||
|
|
442
|
-
Util._hex6ColorToRGBA(str) ||
|
|
443
|
-
Util._hex8ColorToRGBA(str) ||
|
|
444
|
-
Util._rgbColorToRGBA(str) ||
|
|
445
|
-
Util._rgbaColorToRGBA(str) ||
|
|
446
|
-
Util._hslColorToRGBA(str));
|
|
443
|
+
return (exports.Util._namedColorToRBA(str) ||
|
|
444
|
+
exports.Util._hex3ColorToRGBA(str) ||
|
|
445
|
+
exports.Util._hex4ColorToRGBA(str) ||
|
|
446
|
+
exports.Util._hex6ColorToRGBA(str) ||
|
|
447
|
+
exports.Util._hex8ColorToRGBA(str) ||
|
|
448
|
+
exports.Util._rgbColorToRGBA(str) ||
|
|
449
|
+
exports.Util._rgbaColorToRGBA(str) ||
|
|
450
|
+
exports.Util._hslColorToRGBA(str));
|
|
447
451
|
},
|
|
448
452
|
_namedColorToRBA(str) {
|
|
449
453
|
var c = COLORS[str.toLowerCase()];
|
|
@@ -613,15 +617,15 @@ export const Util = {
|
|
|
613
617
|
return rad * DEG180_OVER_PI;
|
|
614
618
|
},
|
|
615
619
|
_degToRad(deg) {
|
|
616
|
-
Util.warn('Util._degToRad is removed. Please use public Util.degToRad instead.');
|
|
617
|
-
return Util.degToRad(deg);
|
|
620
|
+
exports.Util.warn('Util._degToRad is removed. Please use public Util.degToRad instead.');
|
|
621
|
+
return exports.Util.degToRad(deg);
|
|
618
622
|
},
|
|
619
623
|
_radToDeg(rad) {
|
|
620
|
-
Util.warn('Util._radToDeg is removed. Please use public Util.radToDeg instead.');
|
|
621
|
-
return Util.radToDeg(rad);
|
|
624
|
+
exports.Util.warn('Util._radToDeg is removed. Please use public Util.radToDeg instead.');
|
|
625
|
+
return exports.Util.radToDeg(rad);
|
|
622
626
|
},
|
|
623
627
|
_getRotation(radians) {
|
|
624
|
-
return Konva.angleDeg ? Util.radToDeg(radians) : radians;
|
|
628
|
+
return Global_1.Konva.angleDeg ? exports.Util.radToDeg(radians) : radians;
|
|
625
629
|
},
|
|
626
630
|
_capitalize(str) {
|
|
627
631
|
return str.charAt(0).toUpperCase() + str.slice(1);
|
|
@@ -633,7 +637,7 @@ export const Util = {
|
|
|
633
637
|
console.error(KONVA_ERROR + str);
|
|
634
638
|
},
|
|
635
639
|
warn(str) {
|
|
636
|
-
if (!Konva.showWarnings) {
|
|
640
|
+
if (!Global_1.Konva.showWarnings) {
|
|
637
641
|
return;
|
|
638
642
|
}
|
|
639
643
|
console.warn(KONVA_WARNING + str);
|
|
@@ -675,14 +679,14 @@ export const Util = {
|
|
|
675
679
|
return [x, y, dist];
|
|
676
680
|
},
|
|
677
681
|
_getProjectionToLine(pt, line, isClosed) {
|
|
678
|
-
var pc = Util.cloneObject(pt);
|
|
682
|
+
var pc = exports.Util.cloneObject(pt);
|
|
679
683
|
var dist = Number.MAX_VALUE;
|
|
680
684
|
line.forEach(function (p1, i) {
|
|
681
685
|
if (!isClosed && i === line.length - 1) {
|
|
682
686
|
return;
|
|
683
687
|
}
|
|
684
688
|
var p2 = line[(i + 1) % line.length];
|
|
685
|
-
var proj = Util._getProjectionToSegment(p1.x, p1.y, p2.x, p2.y, pt.x, pt.y);
|
|
689
|
+
var proj = exports.Util._getProjectionToSegment(p1.x, p1.y, p2.x, p2.y, pt.x, pt.y);
|
|
686
690
|
var px = proj[0], py = proj[1], pdist = proj[2];
|
|
687
691
|
if (pdist < dist) {
|
|
688
692
|
pc.x = px;
|
|
@@ -713,7 +717,7 @@ export const Util = {
|
|
|
713
717
|
}
|
|
714
718
|
var newStart = [];
|
|
715
719
|
end.forEach(function (point) {
|
|
716
|
-
var pr = Util._getProjectionToLine(point, start, isClosed);
|
|
720
|
+
var pr = exports.Util._getProjectionToLine(point, start, isClosed);
|
|
717
721
|
newStart.push(pr.x);
|
|
718
722
|
newStart.push(pr.y);
|
|
719
723
|
});
|
|
@@ -728,7 +732,7 @@ export const Util = {
|
|
|
728
732
|
}
|
|
729
733
|
desc = Object.getOwnPropertyDescriptor(obj, key);
|
|
730
734
|
if (obj[key].visitedByCircularReferenceRemoval ||
|
|
731
|
-
Util._isElement(obj[key])) {
|
|
735
|
+
exports.Util._isElement(obj[key])) {
|
|
732
736
|
if (desc.configurable) {
|
|
733
737
|
delete obj[key];
|
|
734
738
|
}
|
|
@@ -736,7 +740,7 @@ export const Util = {
|
|
|
736
740
|
return null;
|
|
737
741
|
}
|
|
738
742
|
}
|
|
739
|
-
else if (Util._prepareToStringify(obj[key]) === null) {
|
|
743
|
+
else if (exports.Util._prepareToStringify(obj[key]) === null) {
|
|
740
744
|
if (desc.configurable) {
|
|
741
745
|
delete obj[key];
|
|
742
746
|
}
|
|
@@ -763,7 +767,7 @@ export const Util = {
|
|
|
763
767
|
}
|
|
764
768
|
},
|
|
765
769
|
releaseCanvas(...canvases) {
|
|
766
|
-
if (!Konva.releaseCanvasOnDestroy)
|
|
770
|
+
if (!Global_1.Konva.releaseCanvasOnDestroy)
|
|
767
771
|
return;
|
|
768
772
|
canvases.forEach(c => {
|
|
769
773
|
c.width = 0;
|
package/lib/Validators.js
CHANGED
|
@@ -1,18 +1,21 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getComponentValidator = exports.getBooleanValidator = exports.getNumberArrayValidator = exports.getFunctionValidator = exports.getStringOrGradientValidator = exports.getStringValidator = exports.getNumberOrAutoValidator = exports.getNumberOrArrayOfNumbersValidator = exports.getNumberValidator = exports.alphaComponent = exports.RGBComponent = void 0;
|
|
4
|
+
const Global_1 = require("./Global");
|
|
5
|
+
const Util_1 = require("./Util");
|
|
3
6
|
function _formatValue(val) {
|
|
4
|
-
if (Util._isString(val)) {
|
|
7
|
+
if (Util_1.Util._isString(val)) {
|
|
5
8
|
return '"' + val + '"';
|
|
6
9
|
}
|
|
7
10
|
if (Object.prototype.toString.call(val) === '[object Number]') {
|
|
8
11
|
return val;
|
|
9
12
|
}
|
|
10
|
-
if (Util._isBoolean(val)) {
|
|
13
|
+
if (Util_1.Util._isBoolean(val)) {
|
|
11
14
|
return val;
|
|
12
15
|
}
|
|
13
16
|
return Object.prototype.toString.call(val);
|
|
14
17
|
}
|
|
15
|
-
|
|
18
|
+
function RGBComponent(val) {
|
|
16
19
|
if (val > 255) {
|
|
17
20
|
return 255;
|
|
18
21
|
}
|
|
@@ -21,7 +24,8 @@ export function RGBComponent(val) {
|
|
|
21
24
|
}
|
|
22
25
|
return Math.round(val);
|
|
23
26
|
}
|
|
24
|
-
|
|
27
|
+
exports.RGBComponent = RGBComponent;
|
|
28
|
+
function alphaComponent(val) {
|
|
25
29
|
if (val > 1) {
|
|
26
30
|
return 1;
|
|
27
31
|
}
|
|
@@ -30,11 +34,12 @@ export function alphaComponent(val) {
|
|
|
30
34
|
}
|
|
31
35
|
return val;
|
|
32
36
|
}
|
|
33
|
-
|
|
34
|
-
|
|
37
|
+
exports.alphaComponent = alphaComponent;
|
|
38
|
+
function getNumberValidator() {
|
|
39
|
+
if (Global_1.Konva.isUnminified) {
|
|
35
40
|
return function (val, attr) {
|
|
36
|
-
if (!Util._isNumber(val)) {
|
|
37
|
-
Util.warn(_formatValue(val) +
|
|
41
|
+
if (!Util_1.Util._isNumber(val)) {
|
|
42
|
+
Util_1.Util.warn(_formatValue(val) +
|
|
38
43
|
' is a not valid value for "' +
|
|
39
44
|
attr +
|
|
40
45
|
'" attribute. The value should be a number.');
|
|
@@ -43,13 +48,14 @@ export function getNumberValidator() {
|
|
|
43
48
|
};
|
|
44
49
|
}
|
|
45
50
|
}
|
|
46
|
-
|
|
47
|
-
|
|
51
|
+
exports.getNumberValidator = getNumberValidator;
|
|
52
|
+
function getNumberOrArrayOfNumbersValidator(noOfElements) {
|
|
53
|
+
if (Global_1.Konva.isUnminified) {
|
|
48
54
|
return function (val, attr) {
|
|
49
|
-
let isNumber = Util._isNumber(val);
|
|
50
|
-
let isValidArray = Util._isArray(val) && val.length == noOfElements;
|
|
55
|
+
let isNumber = Util_1.Util._isNumber(val);
|
|
56
|
+
let isValidArray = Util_1.Util._isArray(val) && val.length == noOfElements;
|
|
51
57
|
if (!isNumber && !isValidArray) {
|
|
52
|
-
Util.warn(_formatValue(val) +
|
|
58
|
+
Util_1.Util.warn(_formatValue(val) +
|
|
53
59
|
' is a not valid value for "' +
|
|
54
60
|
attr +
|
|
55
61
|
'" attribute. The value should be a number or Array<number>(' +
|
|
@@ -60,13 +66,14 @@ export function getNumberOrArrayOfNumbersValidator(noOfElements) {
|
|
|
60
66
|
};
|
|
61
67
|
}
|
|
62
68
|
}
|
|
63
|
-
|
|
64
|
-
|
|
69
|
+
exports.getNumberOrArrayOfNumbersValidator = getNumberOrArrayOfNumbersValidator;
|
|
70
|
+
function getNumberOrAutoValidator() {
|
|
71
|
+
if (Global_1.Konva.isUnminified) {
|
|
65
72
|
return function (val, attr) {
|
|
66
|
-
var isNumber = Util._isNumber(val);
|
|
73
|
+
var isNumber = Util_1.Util._isNumber(val);
|
|
67
74
|
var isAuto = val === 'auto';
|
|
68
75
|
if (!(isNumber || isAuto)) {
|
|
69
|
-
Util.warn(_formatValue(val) +
|
|
76
|
+
Util_1.Util.warn(_formatValue(val) +
|
|
70
77
|
' is a not valid value for "' +
|
|
71
78
|
attr +
|
|
72
79
|
'" attribute. The value should be a number or "auto".');
|
|
@@ -75,11 +82,12 @@ export function getNumberOrAutoValidator() {
|
|
|
75
82
|
};
|
|
76
83
|
}
|
|
77
84
|
}
|
|
78
|
-
|
|
79
|
-
|
|
85
|
+
exports.getNumberOrAutoValidator = getNumberOrAutoValidator;
|
|
86
|
+
function getStringValidator() {
|
|
87
|
+
if (Global_1.Konva.isUnminified) {
|
|
80
88
|
return function (val, attr) {
|
|
81
|
-
if (!Util._isString(val)) {
|
|
82
|
-
Util.warn(_formatValue(val) +
|
|
89
|
+
if (!Util_1.Util._isString(val)) {
|
|
90
|
+
Util_1.Util.warn(_formatValue(val) +
|
|
83
91
|
' is a not valid value for "' +
|
|
84
92
|
attr +
|
|
85
93
|
'" attribute. The value should be a string.');
|
|
@@ -88,14 +96,15 @@ export function getStringValidator() {
|
|
|
88
96
|
};
|
|
89
97
|
}
|
|
90
98
|
}
|
|
91
|
-
|
|
92
|
-
|
|
99
|
+
exports.getStringValidator = getStringValidator;
|
|
100
|
+
function getStringOrGradientValidator() {
|
|
101
|
+
if (Global_1.Konva.isUnminified) {
|
|
93
102
|
return function (val, attr) {
|
|
94
|
-
const isString = Util._isString(val);
|
|
103
|
+
const isString = Util_1.Util._isString(val);
|
|
95
104
|
const isGradient = Object.prototype.toString.call(val) === '[object CanvasGradient]' ||
|
|
96
105
|
(val && val.addColorStop);
|
|
97
106
|
if (!(isString || isGradient)) {
|
|
98
|
-
Util.warn(_formatValue(val) +
|
|
107
|
+
Util_1.Util.warn(_formatValue(val) +
|
|
99
108
|
' is a not valid value for "' +
|
|
100
109
|
attr +
|
|
101
110
|
'" attribute. The value should be a string or a native gradient.');
|
|
@@ -104,11 +113,12 @@ export function getStringOrGradientValidator() {
|
|
|
104
113
|
};
|
|
105
114
|
}
|
|
106
115
|
}
|
|
107
|
-
|
|
108
|
-
|
|
116
|
+
exports.getStringOrGradientValidator = getStringOrGradientValidator;
|
|
117
|
+
function getFunctionValidator() {
|
|
118
|
+
if (Global_1.Konva.isUnminified) {
|
|
109
119
|
return function (val, attr) {
|
|
110
|
-
if (!Util._isFunction(val)) {
|
|
111
|
-
Util.warn(_formatValue(val) +
|
|
120
|
+
if (!Util_1.Util._isFunction(val)) {
|
|
121
|
+
Util_1.Util.warn(_formatValue(val) +
|
|
112
122
|
' is a not valid value for "' +
|
|
113
123
|
attr +
|
|
114
124
|
'" attribute. The value should be a function.');
|
|
@@ -117,23 +127,24 @@ export function getFunctionValidator() {
|
|
|
117
127
|
};
|
|
118
128
|
}
|
|
119
129
|
}
|
|
120
|
-
|
|
121
|
-
|
|
130
|
+
exports.getFunctionValidator = getFunctionValidator;
|
|
131
|
+
function getNumberArrayValidator() {
|
|
132
|
+
if (Global_1.Konva.isUnminified) {
|
|
122
133
|
return function (val, attr) {
|
|
123
134
|
const TypedArray = Int8Array ? Object.getPrototypeOf(Int8Array) : null;
|
|
124
135
|
if (TypedArray && val instanceof TypedArray) {
|
|
125
136
|
return val;
|
|
126
137
|
}
|
|
127
|
-
if (!Util._isArray(val)) {
|
|
128
|
-
Util.warn(_formatValue(val) +
|
|
138
|
+
if (!Util_1.Util._isArray(val)) {
|
|
139
|
+
Util_1.Util.warn(_formatValue(val) +
|
|
129
140
|
' is a not valid value for "' +
|
|
130
141
|
attr +
|
|
131
142
|
'" attribute. The value should be a array of numbers.');
|
|
132
143
|
}
|
|
133
144
|
else {
|
|
134
145
|
val.forEach(function (item) {
|
|
135
|
-
if (!Util._isNumber(item)) {
|
|
136
|
-
Util.warn('"' +
|
|
146
|
+
if (!Util_1.Util._isNumber(item)) {
|
|
147
|
+
Util_1.Util.warn('"' +
|
|
137
148
|
attr +
|
|
138
149
|
'" attribute has non numeric element ' +
|
|
139
150
|
item +
|
|
@@ -145,12 +156,13 @@ export function getNumberArrayValidator() {
|
|
|
145
156
|
};
|
|
146
157
|
}
|
|
147
158
|
}
|
|
148
|
-
|
|
149
|
-
|
|
159
|
+
exports.getNumberArrayValidator = getNumberArrayValidator;
|
|
160
|
+
function getBooleanValidator() {
|
|
161
|
+
if (Global_1.Konva.isUnminified) {
|
|
150
162
|
return function (val, attr) {
|
|
151
163
|
var isBool = val === true || val === false;
|
|
152
164
|
if (!isBool) {
|
|
153
|
-
Util.warn(_formatValue(val) +
|
|
165
|
+
Util_1.Util.warn(_formatValue(val) +
|
|
154
166
|
' is a not valid value for "' +
|
|
155
167
|
attr +
|
|
156
168
|
'" attribute. The value should be a boolean.');
|
|
@@ -159,14 +171,15 @@ export function getBooleanValidator() {
|
|
|
159
171
|
};
|
|
160
172
|
}
|
|
161
173
|
}
|
|
162
|
-
|
|
163
|
-
|
|
174
|
+
exports.getBooleanValidator = getBooleanValidator;
|
|
175
|
+
function getComponentValidator(components) {
|
|
176
|
+
if (Global_1.Konva.isUnminified) {
|
|
164
177
|
return function (val, attr) {
|
|
165
178
|
if (val === undefined || val === null) {
|
|
166
179
|
return val;
|
|
167
180
|
}
|
|
168
|
-
if (!Util.isObject(val)) {
|
|
169
|
-
Util.warn(_formatValue(val) +
|
|
181
|
+
if (!Util_1.Util.isObject(val)) {
|
|
182
|
+
Util_1.Util.warn(_formatValue(val) +
|
|
170
183
|
' is a not valid value for "' +
|
|
171
184
|
attr +
|
|
172
185
|
'" attribute. The value should be an object with properties ' +
|
|
@@ -176,3 +189,4 @@ export function getComponentValidator(components) {
|
|
|
176
189
|
};
|
|
177
190
|
}
|
|
178
191
|
}
|
|
192
|
+
exports.getComponentValidator = getComponentValidator;
|
package/lib/_CoreInternals.d.ts
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import { Transform } from './Util';
|
|
2
|
-
import { Node } from './Node';
|
|
3
|
-
import { Container } from './Container';
|
|
4
|
-
import { Stage } from './Stage';
|
|
5
|
-
import { Layer } from './Layer';
|
|
6
|
-
import { FastLayer } from './FastLayer';
|
|
7
|
-
import { Group } from './Group';
|
|
8
|
-
import { Shape } from './Shape';
|
|
9
|
-
import { Animation } from './Animation';
|
|
10
|
-
import { Tween } from './Tween';
|
|
11
|
-
import { Context } from './Context';
|
|
12
|
-
import { Canvas } from './Canvas';
|
|
1
|
+
import { Transform } from './Util.js';
|
|
2
|
+
import { Node } from './Node.js';
|
|
3
|
+
import { Container } from './Container.js';
|
|
4
|
+
import { Stage } from './Stage.js';
|
|
5
|
+
import { Layer } from './Layer.js';
|
|
6
|
+
import { FastLayer } from './FastLayer.js';
|
|
7
|
+
import { Group } from './Group.js';
|
|
8
|
+
import { Shape } from './Shape.js';
|
|
9
|
+
import { Animation } from './Animation.js';
|
|
10
|
+
import { Tween } from './Tween.js';
|
|
11
|
+
import { Context } from './Context.js';
|
|
12
|
+
import { Canvas } from './Canvas.js';
|
|
13
13
|
export declare const Konva: {
|
|
14
14
|
_global: any;
|
|
15
15
|
version: string;
|
|
@@ -59,24 +59,24 @@ export declare const Konva: {
|
|
|
59
59
|
_isInDocument(el: any): boolean;
|
|
60
60
|
_urlToImage(url: string, callback: Function): void;
|
|
61
61
|
_rgbToHex(r: number, g: number, b: number): string;
|
|
62
|
-
_hexToRgb(hex: string): import("./types").RGB;
|
|
62
|
+
_hexToRgb(hex: string): import("./types.js").RGB;
|
|
63
63
|
getRandomColor(): string;
|
|
64
|
-
getRGB(color: string): import("./types").RGB;
|
|
65
|
-
colorToRGBA(str: string): import("./types").RGBA;
|
|
64
|
+
getRGB(color: string): import("./types.js").RGB;
|
|
65
|
+
colorToRGBA(str: string): import("./types.js").RGBA;
|
|
66
66
|
_namedColorToRBA(str: string): {
|
|
67
67
|
r: any;
|
|
68
68
|
g: any;
|
|
69
69
|
b: any;
|
|
70
70
|
a: number;
|
|
71
71
|
};
|
|
72
|
-
_rgbColorToRGBA(str: string): import("./types").RGBA;
|
|
73
|
-
_rgbaColorToRGBA(str: string): import("./types").RGBA;
|
|
74
|
-
_hex8ColorToRGBA(str: string): import("./types").RGBA;
|
|
75
|
-
_hex6ColorToRGBA(str: string): import("./types").RGBA;
|
|
76
|
-
_hex4ColorToRGBA(str: string): import("./types").RGBA;
|
|
77
|
-
_hex3ColorToRGBA(str: string): import("./types").RGBA;
|
|
78
|
-
_hslColorToRGBA(str: string): import("./types").RGBA;
|
|
79
|
-
haveIntersection(r1: import("./types").IRect, r2: import("./types").IRect): boolean;
|
|
72
|
+
_rgbColorToRGBA(str: string): import("./types.js").RGBA;
|
|
73
|
+
_rgbaColorToRGBA(str: string): import("./types.js").RGBA;
|
|
74
|
+
_hex8ColorToRGBA(str: string): import("./types.js").RGBA;
|
|
75
|
+
_hex6ColorToRGBA(str: string): import("./types.js").RGBA;
|
|
76
|
+
_hex4ColorToRGBA(str: string): import("./types.js").RGBA;
|
|
77
|
+
_hex3ColorToRGBA(str: string): import("./types.js").RGBA;
|
|
78
|
+
_hslColorToRGBA(str: string): import("./types.js").RGBA;
|
|
79
|
+
haveIntersection(r1: import("./types").IRect, r2: import("./types.js").IRect): boolean;
|
|
80
80
|
cloneObject<Any>(obj: Any): Any;
|
|
81
81
|
cloneArray(arr: any[]): any[];
|
|
82
82
|
degToRad(deg: number): number;
|
|
@@ -91,7 +91,7 @@ export declare const Konva: {
|
|
|
91
91
|
each(obj: any, func: any): void;
|
|
92
92
|
_inRange(val: any, left: any, right: any): boolean;
|
|
93
93
|
_getProjectionToSegment(x1: any, y1: any, x2: any, y2: any, x3: any, y3: any): any[];
|
|
94
|
-
_getProjectionToLine(pt: import("./types").Vector2d, line: any, isClosed: any): import("./types").Vector2d;
|
|
94
|
+
_getProjectionToLine(pt: import("./types").Vector2d, line: any, isClosed: any): import("./types.js").Vector2d;
|
|
95
95
|
_prepareArrayForTween(startArray: any, endArray: any, isClosed: any): any[];
|
|
96
96
|
_prepareToStringify(obj: any): any;
|
|
97
97
|
_assign<T, U>(target: T, source: U): T & U;
|
|
@@ -110,11 +110,11 @@ export declare const Konva: {
|
|
|
110
110
|
DD: {
|
|
111
111
|
readonly isDragging: boolean;
|
|
112
112
|
justDragged: boolean;
|
|
113
|
-
readonly node: Node<import("./Node").NodeConfig>;
|
|
113
|
+
readonly node: Node<import("./Node.js").NodeConfig>;
|
|
114
114
|
_dragElements: Map<number, {
|
|
115
|
-
node: Node<import("./Node").NodeConfig>;
|
|
116
|
-
startPointerPos: import("./types").Vector2d;
|
|
117
|
-
offset: import("./types").Vector2d;
|
|
115
|
+
node: Node<import("./Node.js").NodeConfig>;
|
|
116
|
+
startPointerPos: import("./types.js").Vector2d;
|
|
117
|
+
offset: import("./types.js").Vector2d;
|
|
118
118
|
pointerId?: number;
|
|
119
119
|
dragStatus: "stopped" | "ready" | "dragging";
|
|
120
120
|
}>;
|
|
@@ -124,7 +124,7 @@ export declare const Konva: {
|
|
|
124
124
|
};
|
|
125
125
|
Shape: typeof Shape;
|
|
126
126
|
shapes: {
|
|
127
|
-
[key: string]: Shape<import("./Shape").ShapeConfig>;
|
|
127
|
+
[key: string]: Shape<import("./Shape.js").ShapeConfig>;
|
|
128
128
|
};
|
|
129
129
|
Animation: typeof Animation;
|
|
130
130
|
Tween: typeof Tween;
|