konva 8.3.11 → 8.3.12

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/cmj/Factory.d.ts CHANGED
@@ -3,7 +3,7 @@ export declare const Factory: {
3
3
  addGetter(constructor: any, attr: any, def?: any): void;
4
4
  addSetter(constructor: any, attr: any, validator?: any, after?: any): void;
5
5
  overWriteSetter(constructor: any, attr: any, validator?: any, after?: any): void;
6
- addComponentsGetterSetter(constructor: any, attr: any, components: any, validator?: any, after?: any): void;
6
+ addComponentsGetterSetter(constructor: any, attr: string, components: Array<string>, validator?: Function, after?: Function): void;
7
7
  addOverloadedGetterSetter(constructor: any, attr: any): void;
8
8
  addDeprecatedGetterSetter(constructor: any, attr: any, def: any, validator: any): void;
9
9
  backCompat(constructor: any, methods: any): void;
package/cmj/Factory.js CHANGED
@@ -63,6 +63,11 @@ exports.Factory = {
63
63
  }
64
64
  this._setAttr(attr + capitalize(key), val[key]);
65
65
  }
66
+ if (!val) {
67
+ components.forEach((component) => {
68
+ this._setAttr(attr + capitalize(component), undefined);
69
+ });
70
+ }
66
71
  this._fireChangeEvent(attr, oldVal, val);
67
72
  if (after) {
68
73
  after.call(this);
package/cmj/Global.js CHANGED
@@ -16,7 +16,7 @@ exports.glob = typeof global !== 'undefined'
16
16
  : {};
17
17
  exports.Konva = {
18
18
  _global: exports.glob,
19
- version: '8.3.11',
19
+ version: '8.3.12',
20
20
  isBrowser: detectBrowser(),
21
21
  isUnminified: /param/.test(function (param) { }.toString()),
22
22
  dblClickWindow: 400,
package/cmj/Node.d.ts CHANGED
@@ -179,7 +179,7 @@ export declare abstract class Node<Config extends NodeConfig = NodeConfig> {
179
179
  getParent(): Container<Node<NodeConfig>>;
180
180
  findAncestors(selector: string, includeSelf?: boolean, stopNode?: Node): Node<NodeConfig>[];
181
181
  isAncestorOf(node: Node): boolean;
182
- findAncestor(selector?: string, includeSelf?: boolean, stopNode?: Container): any;
182
+ findAncestor(selector?: string, includeSelf?: boolean, stopNode?: Container): Node<NodeConfig>;
183
183
  _isMatch(selector: string | Function): any;
184
184
  getLayer(): Layer | null;
185
185
  getStage(): Stage | null;
@@ -303,7 +303,7 @@ export declare abstract class Node<Config extends NodeConfig = NodeConfig> {
303
303
  opacity: GetSet<number, this>;
304
304
  rotation: GetSet<number, this>;
305
305
  zIndex: GetSet<number, this>;
306
- scale: GetSet<Vector2d, this>;
306
+ scale: GetSet<Vector2d | undefined, this>;
307
307
  scaleX: GetSet<number, this>;
308
308
  scaleY: GetSet<number, this>;
309
309
  skew: GetSet<Vector2d, this>;
package/cmj/Node.js CHANGED
@@ -988,7 +988,7 @@ class Node {
988
988
  const callback = config === null || config === void 0 ? void 0 : config.callback;
989
989
  if (callback)
990
990
  delete config.callback;
991
- this.toCanvas(config).toBlob(blob => {
991
+ this.toCanvas(config).toBlob((blob) => {
992
992
  resolve(blob);
993
993
  callback === null || callback === void 0 ? void 0 : callback(blob);
994
994
  });
package/cmj/Validators.js CHANGED
@@ -131,6 +131,10 @@ exports.getFunctionValidator = getFunctionValidator;
131
131
  function getNumberArrayValidator() {
132
132
  if (Global_1.Konva.isUnminified) {
133
133
  return function (val, attr) {
134
+ const TypedArray = Int8Array ? Object.getPrototypeOf(Int8Array) : null;
135
+ if (TypedArray && val instanceof TypedArray) {
136
+ return val;
137
+ }
134
138
  if (!Util_1.Util._isArray(val)) {
135
139
  Util_1.Util.warn(_formatValue(val) +
136
140
  ' is a not valid value for "' +
@@ -171,6 +175,9 @@ exports.getBooleanValidator = getBooleanValidator;
171
175
  function getComponentValidator(components) {
172
176
  if (Global_1.Konva.isUnminified) {
173
177
  return function (val, attr) {
178
+ if (val === undefined || val === null) {
179
+ return val;
180
+ }
174
181
  if (!Util_1.Util.isObject(val)) {
175
182
  Util_1.Util.warn(_formatValue(val) +
176
183
  ' is a not valid value for "' +
@@ -2,7 +2,7 @@ import { Shape, ShapeConfig } from '../Shape';
2
2
  import { GetSet } from '../types';
3
3
  import { Context } from '../Context';
4
4
  export interface LineConfig extends ShapeConfig {
5
- points?: number[];
5
+ points?: number[] | Int8Array | Uint8Array | Uint8ClampedArray | Int16Array | Uint16Array | Int32Array | Uint32Array | Float32Array | Float64Array;
6
6
  tension?: number;
7
7
  closed?: boolean;
8
8
  bezier?: boolean;
@@ -304,7 +304,7 @@ class Text extends Shape_1.Shape {
304
304
  this._addTextLine(line);
305
305
  currentHeightPx += lineHeightPx;
306
306
  textWidth = Math.max(textWidth, lineWidth);
307
- if (this._shouldHandleEllipsis(currentHeightPx)) {
307
+ if (this._shouldHandleEllipsis(currentHeightPx) && i < max - 1) {
308
308
  this._tryToAddEllipsisToLastLine();
309
309
  }
310
310
  }
@@ -167,7 +167,7 @@ class TextPath extends Shape_1.Shape {
167
167
  pathCmd = undefined;
168
168
  }
169
169
  }
170
- if (pathCmd === {} || p0 === undefined) {
170
+ if (Object.keys(pathCmd).length === 0 || p0 === undefined) {
171
171
  return undefined;
172
172
  }
173
173
  var needNewSegment = false;
@@ -86,12 +86,7 @@ export declare class Transformer extends Group {
86
86
  stopTransform(): void;
87
87
  destroy(): this;
88
88
  toObject(): any;
89
- getClientRect(): {
90
- x: number;
91
- y: number;
92
- width: number;
93
- height: number;
94
- };
89
+ getClientRect(): IRect;
95
90
  nodes: GetSet<Node[], this>;
96
91
  enabledAnchors: GetSet<string[], this>;
97
92
  rotationSnaps: GetSet<number[], this>;
@@ -900,7 +900,12 @@ class Transformer extends Group_1.Group {
900
900
  return Node_1.Node.prototype.toObject.call(this);
901
901
  }
902
902
  getClientRect() {
903
- return { x: 0, y: 0, width: 0, height: 0 };
903
+ if (this.nodes().length > 0) {
904
+ return super.getClientRect();
905
+ }
906
+ else {
907
+ return { x: 0, y: 0, width: 0, height: 0 };
908
+ }
904
909
  }
905
910
  }
906
911
  exports.Transformer = Transformer;
package/konva.js CHANGED
@@ -5,10 +5,10 @@
5
5
  })(this, (function () { 'use strict';
6
6
 
7
7
  /*
8
- * Konva JavaScript Framework v8.3.11
8
+ * Konva JavaScript Framework v8.3.12
9
9
  * http://konvajs.org/
10
10
  * Licensed under the MIT
11
- * Date: Fri Aug 05 2022
11
+ * Date: Mon Aug 29 2022
12
12
  *
13
13
  * Original work Copyright (C) 2011 - 2013 by Eric Rowell (KineticJS)
14
14
  * Modified work Copyright (C) 2014 - present by Anton Lavrenov (Konva)
@@ -35,7 +35,7 @@
35
35
  : {};
36
36
  const Konva$2 = {
37
37
  _global: glob,
38
- version: '8.3.11',
38
+ version: '8.3.12',
39
39
  isBrowser: detectBrowser(),
40
40
  isUnminified: /param/.test(function (param) { }.toString()),
41
41
  dblClickWindow: 400,
@@ -1171,6 +1171,12 @@
1171
1171
  function getNumberArrayValidator() {
1172
1172
  if (Konva$2.isUnminified) {
1173
1173
  return function (val, attr) {
1174
+ // Retrieve TypedArray constructor as found in MDN (if TypedArray is available)
1175
+ // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray#description
1176
+ const TypedArray = Int8Array ? Object.getPrototypeOf(Int8Array) : null;
1177
+ if (TypedArray && val instanceof TypedArray) {
1178
+ return val;
1179
+ }
1174
1180
  if (!Util._isArray(val)) {
1175
1181
  Util.warn(_formatValue(val) +
1176
1182
  ' is a not valid value for "' +
@@ -1209,6 +1215,10 @@
1209
1215
  function getComponentValidator(components) {
1210
1216
  if (Konva$2.isUnminified) {
1211
1217
  return function (val, attr) {
1218
+ // ignore validation on undefined value, because it will reset to defalt
1219
+ if (val === undefined || val === null) {
1220
+ return val;
1221
+ }
1212
1222
  if (!Util.isObject(val)) {
1213
1223
  Util.warn(_formatValue(val) +
1214
1224
  ' is a not valid value for "' +
@@ -1283,6 +1293,11 @@
1283
1293
  }
1284
1294
  this._setAttr(attr + capitalize(key), val[key]);
1285
1295
  }
1296
+ if (!val) {
1297
+ components.forEach((component) => {
1298
+ this._setAttr(attr + capitalize(component), undefined);
1299
+ });
1300
+ }
1286
1301
  this._fireChangeEvent(attr, oldVal, val);
1287
1302
  if (after) {
1288
1303
  after.call(this);
@@ -4090,33 +4105,33 @@
4090
4105
  });
4091
4106
  }
4092
4107
  /**
4093
- * Converts node into a blob. Since the toBlob method is asynchronous,
4094
- * the resulting blob can only be retrieved from the config callback
4095
- * or the returned Promise.
4096
- * @method
4097
- * @name Konva.Node#toBlob
4098
- * @param {Object} config
4099
- * @param {Function} [config.callback] function executed when the composite has completed
4100
- * @param {Number} [config.x] x position of canvas section
4101
- * @param {Number} [config.y] y position of canvas section
4102
- * @param {Number} [config.width] width of canvas section
4103
- * @param {Number} [config.height] height of canvas section
4104
- * @param {Number} [config.pixelRatio] pixelRatio of output canvas. Default is 1.
4105
- * You can use that property to increase quality of the image, for example for super hight quality exports
4106
- * or usage on retina (or similar) displays. pixelRatio will be used to multiply the size of exported image.
4107
- * If you export to 500x500 size with pixelRatio = 2, then produced image will have size 1000x1000.
4108
- * @param {Boolean} [config.imageSmoothingEnabled] set this to false if you want to disable imageSmoothing
4109
- * @example
4110
- * var blob = await node.toBlob({});
4111
- * @returns {Promise<Blob>}
4112
- */
4108
+ * Converts node into a blob. Since the toBlob method is asynchronous,
4109
+ * the resulting blob can only be retrieved from the config callback
4110
+ * or the returned Promise.
4111
+ * @method
4112
+ * @name Konva.Node#toBlob
4113
+ * @param {Object} config
4114
+ * @param {Function} [config.callback] function executed when the composite has completed
4115
+ * @param {Number} [config.x] x position of canvas section
4116
+ * @param {Number} [config.y] y position of canvas section
4117
+ * @param {Number} [config.width] width of canvas section
4118
+ * @param {Number} [config.height] height of canvas section
4119
+ * @param {Number} [config.pixelRatio] pixelRatio of output canvas. Default is 1.
4120
+ * You can use that property to increase quality of the image, for example for super hight quality exports
4121
+ * or usage on retina (or similar) displays. pixelRatio will be used to multiply the size of exported image.
4122
+ * If you export to 500x500 size with pixelRatio = 2, then produced image will have size 1000x1000.
4123
+ * @param {Boolean} [config.imageSmoothingEnabled] set this to false if you want to disable imageSmoothing
4124
+ * @example
4125
+ * var blob = await node.toBlob({});
4126
+ * @returns {Promise<Blob>}
4127
+ */
4113
4128
  toBlob(config) {
4114
4129
  return new Promise((resolve, reject) => {
4115
4130
  try {
4116
4131
  const callback = config === null || config === void 0 ? void 0 : config.callback;
4117
4132
  if (callback)
4118
4133
  delete config.callback;
4119
- this.toCanvas(config).toBlob(blob => {
4134
+ this.toCanvas(config).toBlob((blob) => {
4120
4135
  resolve(blob);
4121
4136
  callback === null || callback === void 0 ? void 0 : callback(blob);
4122
4137
  });
@@ -13626,7 +13641,7 @@
13626
13641
  this._addTextLine(line);
13627
13642
  currentHeightPx += lineHeightPx;
13628
13643
  textWidth = Math.max(textWidth, lineWidth);
13629
- if (this._shouldHandleEllipsis(currentHeightPx)) {
13644
+ if (this._shouldHandleEllipsis(currentHeightPx) && i < max - 1) {
13630
13645
  this._tryToAddEllipsisToLastLine();
13631
13646
  }
13632
13647
  }
@@ -14213,7 +14228,7 @@
14213
14228
  pathCmd = undefined;
14214
14229
  }
14215
14230
  }
14216
- if (pathCmd === {} || p0 === undefined) {
14231
+ if (Object.keys(pathCmd).length === 0 || p0 === undefined) {
14217
14232
  return undefined;
14218
14233
  }
14219
14234
  var needNewSegment = false;
@@ -15577,9 +15592,14 @@
15577
15592
  return Node.prototype.toObject.call(this);
15578
15593
  }
15579
15594
  getClientRect() {
15580
- // return zero size
15581
- // so it will be skipped in calculations
15582
- return { x: 0, y: 0, width: 0, height: 0 };
15595
+ if (this.nodes().length > 0) {
15596
+ return super.getClientRect();
15597
+ }
15598
+ else {
15599
+ // if we are detached return zero size
15600
+ // so it will be skipped in calculations
15601
+ return { x: 0, y: 0, width: 0, height: 0 };
15602
+ }
15583
15603
  }
15584
15604
  }
15585
15605
  function validateAnchors(val) {