konva 9.3.18 → 9.3.20

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/lib/Canvas.js CHANGED
@@ -4,8 +4,6 @@ exports.HitCanvas = exports.SceneCanvas = exports.Canvas = void 0;
4
4
  const Util_1 = require("./Util");
5
5
  const Context_1 = require("./Context");
6
6
  const Global_1 = require("./Global");
7
- const Factory_1 = require("./Factory");
8
- const Validators_1 = require("./Validators");
9
7
  let _pixelRatio;
10
8
  function getDevicePixelRatio() {
11
9
  if (_pixelRatio) {
@@ -94,7 +92,6 @@ class Canvas {
94
92
  }
95
93
  }
96
94
  exports.Canvas = Canvas;
97
- Factory_1.Factory.addGetterSetter(Canvas, 'pixelRatio', undefined, (0, Validators_1.getNumberValidator)());
98
95
  class SceneCanvas extends Canvas {
99
96
  constructor(config = { width: 0, height: 0, willReadFrequently: false }) {
100
97
  super(config);
package/lib/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: '9.3.18',
19
+ version: '9.3.20',
20
20
  isBrowser: detectBrowser(),
21
21
  isUnminified: /param/.test(function (param) { }.toString()),
22
22
  dblClickWindow: 400,
package/lib/shapes/Arc.js CHANGED
@@ -51,7 +51,12 @@ class Arc extends Shape_1.Shape {
51
51
  exports.Arc = Arc;
52
52
  Arc.prototype._centroid = true;
53
53
  Arc.prototype.className = 'Arc';
54
- Arc.prototype._attrsAffectingSize = ['innerRadius', 'outerRadius'];
54
+ Arc.prototype._attrsAffectingSize = [
55
+ 'innerRadius',
56
+ 'outerRadius',
57
+ 'angle',
58
+ 'clockwise',
59
+ ];
55
60
  (0, Global_2._registerNode)(Arc);
56
61
  Factory_1.Factory.addGetterSetter(Arc, 'innerRadius', 0, (0, Validators_1.getNumberValidator)());
57
62
  Factory_1.Factory.addGetterSetter(Arc, 'outerRadius', 0, (0, Validators_1.getNumberValidator)());
@@ -7,8 +7,11 @@ export interface ImageConfig extends ShapeConfig {
7
7
  cornerRadius?: number | number[];
8
8
  }
9
9
  export declare class Image extends Shape<ImageConfig> {
10
+ private _loadListener;
10
11
  constructor(attrs: ImageConfig);
11
12
  _setImageLoad(): void;
13
+ _removeImageLoad(image: any): void;
14
+ destroy(): this;
12
15
  _useBufferCanvas(): boolean;
13
16
  _sceneFunc(context: Context): void;
14
17
  _hitFunc(context: Context): void;
@@ -9,7 +9,11 @@ const Validators_1 = require("../Validators");
9
9
  class Image extends Shape_1.Shape {
10
10
  constructor(attrs) {
11
11
  super(attrs);
12
- this.on('imageChange.konva', () => {
12
+ this._loadListener = () => {
13
+ this._requestDraw();
14
+ };
15
+ this.on('imageChange.konva', (props) => {
16
+ this._removeImageLoad(props.oldVal);
13
17
  this._setImageLoad();
14
18
  });
15
19
  this._setImageLoad();
@@ -23,11 +27,19 @@ class Image extends Shape_1.Shape {
23
27
  return;
24
28
  }
25
29
  if (image && image['addEventListener']) {
26
- image['addEventListener']('load', () => {
27
- this._requestDraw();
28
- });
30
+ image['addEventListener']('load', this._loadListener);
29
31
  }
30
32
  }
33
+ _removeImageLoad(image) {
34
+ if (image && image['removeEventListener']) {
35
+ image['removeEventListener']('load', this._loadListener);
36
+ }
37
+ }
38
+ destroy() {
39
+ this._removeImageLoad(this.image());
40
+ super.destroy();
41
+ return this;
42
+ }
31
43
  _useBufferCanvas() {
32
44
  const hasCornerRadius = !!this.cornerRadius();
33
45
  const hasShadow = this.hasShadow();
@@ -302,8 +302,14 @@ class Text extends Shape_1.Shape {
302
302
  while (line.length > 0) {
303
303
  let low = 0, high = stringToArray(line).length, match = '', matchWidth = 0;
304
304
  while (low < high) {
305
- const mid = (low + high) >>> 1, lineArray = stringToArray(line), substr = lineArray.slice(0, mid + 1).join(''), substrWidth = this._getTextWidth(substr) + additionalWidth;
306
- if (substrWidth <= maxWidth) {
305
+ const mid = (low + high) >>> 1, lineArray = stringToArray(line), substr = lineArray.slice(0, mid + 1).join(''), substrWidth = this._getTextWidth(substr);
306
+ const shouldConsiderEllipsis = shouldAddEllipsis &&
307
+ fixedHeight &&
308
+ currentHeightPx + lineHeightPx > maxHeightPx;
309
+ const effectiveWidth = shouldConsiderEllipsis
310
+ ? substrWidth + additionalWidth
311
+ : substrWidth;
312
+ if (effectiveWidth <= maxWidth) {
307
313
  low = mid + 1;
308
314
  match = substr;
309
315
  matchWidth = substrWidth;
@@ -198,10 +198,12 @@ class Transformer extends Group_1.Group {
198
198
  this.update();
199
199
  }
200
200
  };
201
- const additionalEvents = node._attrsAffectingSize
202
- .map((prop) => prop + 'Change.' + this._getEventNamespace())
203
- .join(' ');
204
- node.on(additionalEvents, onChange);
201
+ if (node._attrsAffectingSize.length) {
202
+ const additionalEvents = node._attrsAffectingSize
203
+ .map((prop) => prop + 'Change.' + this._getEventNamespace())
204
+ .join(' ');
205
+ node.on(additionalEvents, onChange);
206
+ }
205
207
  node.on(TRANSFORM_CHANGE_STR.map((e) => e + `.${this._getEventNamespace()}`).join(' '), onChange);
206
208
  node.on(`absoluteTransformChange.${this._getEventNamespace()}`, onChange);
207
209
  this._proxyDrag(node);
package/lib/types.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  export interface GetSet<Type, This> {
2
2
  (): Type;
3
- (v: Type): This;
3
+ (v: Type | null | undefined): This;
4
4
  }
5
5
  export interface Vector2d {
6
6
  x: number;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "konva",
3
- "version": "9.3.18",
3
+ "version": "9.3.20",
4
4
  "description": "HTML5 2d canvas library.",
5
5
  "author": "Anton Lavrenov",
6
6
  "files": [
@@ -19,8 +19,8 @@
19
19
  "build": "npm run compile && cp ./src/index-types.d.ts ./lib && gulp build && node ./rename-imports.mjs",
20
20
  "test:import": "npm run build && node ./test/import-test.cjs && node ./test/import-test.mjs",
21
21
  "test": "npm run test:browser && npm run test:node",
22
- "test:build": "parcel build ./test/unit-tests.html --dist-dir ./test-build --target none --public-url ./ --no-source-maps",
23
- "test:browser": "npm run test:build && mocha-headless-chrome -f ./test-build/unit-tests.html -a disable-web-security -a no-sandbox",
22
+ "test:build": "PARCEL_WORKER_BACKEND=process parcel build ./test/unit-tests.html --dist-dir ./test-build --target none --public-url ./ --no-source-maps",
23
+ "test:browser": "npm run test:build && mocha-headless-chrome -f ./test-build/unit-tests.html -a disable-web-security -a no-sandbox -a disable-setuid-sandbox",
24
24
  "test:watch": "rm -rf ./.parcel-cache && PARCEL_WORKERS=0 parcel serve ./test/unit-tests.html ./test/manual-tests.html ./test/sandbox.html ./test/text-paths.html ./test/bunnies.html",
25
25
  "test:node": "ts-mocha -r ./test/node-global-setup.mjs -p ./test/tsconfig.json test/unit/**/*.ts --exit && npm run test:import",
26
26
  "tsc": "tsc --removeComments",
@@ -63,7 +63,7 @@
63
63
  "@parcel/transformer-image": "2.13.2",
64
64
  "@size-limit/preset-big-lib": "^11.1.6",
65
65
  "@types/mocha": "^10.0.10",
66
- "canvas": "^3.0.0-rc3",
66
+ "canvas": "^3.1.0",
67
67
  "chai": "5.1.2",
68
68
  "filehound": "^1.17.6",
69
69
  "gulp": "^5.0.0",
@@ -79,14 +79,14 @@
79
79
  "gulp-util": "^3.0.8",
80
80
  "mocha": "10.2.0",
81
81
  "mocha-headless-chrome": "^4.0.0",
82
- "parcel": "2.13.2",
82
+ "parcel": "2.13.3",
83
83
  "process": "^0.11.10",
84
- "rollup": "^4.28.1",
84
+ "rollup": "^4.31.0",
85
85
  "rollup-plugin-typescript2": "^0.36.0",
86
86
  "size-limit": "^11.1.6",
87
87
  "ts-mocha": "^10.0.0",
88
88
  "ts-node": "^10.9.2",
89
- "typescript": "^5.7.2"
89
+ "typescript": "^5.7.3"
90
90
  },
91
91
  "keywords": [
92
92
  "canvas",