konva 10.2.4 → 10.3.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 CHANGED
@@ -4,10 +4,14 @@
4
4
 
5
5
  <h1 align="center">Konva</h1>
6
6
 
7
- [![Financial Contributors on Open Collective](https://opencollective.com/konva/all/badge.svg?label=financial+contributors)](https://opencollective.com/konva)
7
+ <p align="center"><strong>Build interactive graphics, editors, and diagrams for the web.</strong></p>
8
+
9
+ [![npm downloads](https://img.shields.io/npm/dw/konva.svg)](https://www.npmjs.com/package/konva)
8
10
  [![npm version](https://badge.fury.io/js/konva.svg)](http://badge.fury.io/js/konva)
9
- [![Build Status](https://github.com/konvajs/konva/actions/workflows/test-browser.yml/badge.svg)](https://github.com/konvajs/konva/actions/workflows/test-browser.ym)
10
- [![Build Status](https://github.com/konvajs/konva/actions/workflows/test-node.yml/badge.svg)](https://github.com/konvajs/konva/actions/workflows/test-node.ym)[![CDNJS version](https://img.shields.io/cdnjs/v/konva.svg)](https://cdnjs.com/libraries/konva)
11
+ [![Financial Contributors on Open Collective](https://opencollective.com/konva/all/badge.svg?label=financial+contributors)](https://opencollective.com/konva)
12
+ [![Build Status](https://github.com/konvajs/konva/actions/workflows/test-browser.yml/badge.svg)](https://github.com/konvajs/konva/actions/workflows/test-browser.yml)
13
+ [![Build Status](https://github.com/konvajs/konva/actions/workflows/test-node.yml/badge.svg)](https://github.com/konvajs/konva/actions/workflows/test-node.yml)
14
+ [![CDNJS version](https://img.shields.io/cdnjs/v/konva.svg)](https://cdnjs.com/libraries/konva)
11
15
 
12
16
  Konva is an HTML5 Canvas JavaScript framework that enables high performance animations, transitions, node nesting, layering, filtering, caching, event handling for desktop and mobile applications, and much more.
13
17
 
@@ -15,9 +19,11 @@ You can draw things onto the stage, add event listeners to them, move them, scal
15
19
 
16
20
  This repository began as a GitHub fork of [ericdrowell/KineticJS](https://github.com/ericdrowell/KineticJS).
17
21
 
18
- - **Visit:** The [Home Page](http://konvajs.org/) and follow on [Twitter](https://twitter.com/lavrton)
19
- - **Discover:** [Tutorials](http://konvajs.org/docs/index.html), [API Documentation](http://konvajs.org/api/Konva.html)
20
- - **Help:** [StackOverflow](http://stackoverflow.com/questions/tagged/konvajs), [Discord Chat](https://discord.gg/8FqZwVT)
22
+ - **Visit:** The [Home Page](https://konvajs.org/) and follow on [Twitter](https://twitter.com/lavrton)
23
+ - **Discover:** [Tutorials](https://konvajs.org/docs/index.html), [API Documentation](https://konvajs.org/api/Konva.html)
24
+ - **Try it:** [Canvas Editor](https://konvajs.org/docs/sandbox/Canvas_Editor.html), [Free Drawing](https://konvajs.org/docs/sandbox/Free_Drawing.html), [Image Crop](https://konvajs.org/docs/sandbox/Canvas_Crop_Image.html), [Window Frame Designer](https://konvajs.org/docs/sandbox/Window_Frame_Designer.html), and [more demos](https://konvajs.org/docs/sandbox.html)
25
+ - **Used by:** [Polotno](https://polotno.com/?utm_source=konvajs) (design editor SDK) and many others — see the full showcase on the [home page](https://konvajs.org/)
26
+ - **Help:** [StackOverflow](https://stackoverflow.com/questions/tagged/konvajs), [Discord Chat](https://discord.gg/8FqZwVT)
21
27
 
22
28
  # Quick Look
23
29
 
package/konva.js CHANGED
@@ -5,10 +5,10 @@
5
5
  })(this, (function () { 'use strict';
6
6
 
7
7
  /*
8
- * Konva JavaScript Framework v10.2.4
8
+ * Konva JavaScript Framework v10.3.0
9
9
  * http://konvajs.org/
10
10
  * Licensed under the MIT
11
- * Date: Fri Apr 10 2026
11
+ * Date: Thu Apr 30 2026
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: '10.2.4',
38
+ version: '10.3.0',
39
39
  isBrowser: detectBrowser(),
40
40
  isUnminified: /param/.test(function (param) { }.toString()),
41
41
  dblClickWindow: 400,
@@ -14717,6 +14717,44 @@ js: import "konva/skia-backend";
14717
14717
  ],
14718
14718
  // cached variables
14719
14719
  attrChangeListLen = ATTR_CHANGE_LIST$1.length;
14720
+ // Safari on macOS renders text shadow even when globalAlpha is 0.
14721
+ // This feature check detects that bug so we can work around it with a buffer canvas.
14722
+ // Not covered by automated tests (our CI doesn't run Safari).
14723
+ // Once Safari fixes the issue this check can be removed.
14724
+ let _shadowOpacityBuggy = null;
14725
+ function hasShadowOpacityBug() {
14726
+ if (_shadowOpacityBuggy !== null) {
14727
+ return _shadowOpacityBuggy;
14728
+ }
14729
+ _shadowOpacityBuggy = false;
14730
+ try {
14731
+ const c = document.createElement('canvas');
14732
+ c.width = 10;
14733
+ c.height = 10;
14734
+ const ctx = c.getContext(CONTEXT_2D);
14735
+ if (ctx) {
14736
+ ctx.globalAlpha = 0;
14737
+ ctx.shadowColor = 'black';
14738
+ ctx.shadowBlur = 5;
14739
+ ctx.shadowOffsetX = 5;
14740
+ ctx.shadowOffsetY = 5;
14741
+ ctx.fillStyle = 'black';
14742
+ ctx.font = '10px Arial';
14743
+ ctx.fillText('X', 0, 10);
14744
+ const data = ctx.getImageData(0, 0, 10, 10).data;
14745
+ for (let i = 3; i < data.length; i += 4) {
14746
+ if (data[i] > 0) {
14747
+ _shadowOpacityBuggy = true;
14748
+ break;
14749
+ }
14750
+ }
14751
+ }
14752
+ }
14753
+ catch (e) {
14754
+ // no-op (SSR or restricted canvas)
14755
+ }
14756
+ return _shadowOpacityBuggy;
14757
+ }
14720
14758
  function normalizeFontFamily(fontFamily) {
14721
14759
  return fontFamily
14722
14760
  .split(',')
@@ -15286,6 +15324,9 @@ js: import "konva/skia-backend";
15286
15324
  if (hasLine && hasShadow) {
15287
15325
  return true;
15288
15326
  }
15327
+ if (hasShadow && this.getAbsoluteOpacity() !== 1 && hasShadowOpacityBug()) {
15328
+ return true;
15329
+ }
15289
15330
  return super._useBufferCanvas();
15290
15331
  }
15291
15332
  }
@@ -15708,7 +15749,7 @@ js: import "konva/skia-backend";
15708
15749
  this._setTextData();
15709
15750
  });
15710
15751
  // update text data for certain attr changes
15711
- this.on('textChange.konva alignChange.konva letterSpacingChange.konva kerningFuncChange.konva fontSizeChange.konva fontFamilyChange.konva', this._setTextData);
15752
+ this.on('textChange.konva alignChange.konva letterSpacingChange.konva kerningFuncChange.konva fontSizeChange.konva fontFamilyChange.konva directionChange.konva', this._setTextData);
15712
15753
  this._setTextData();
15713
15754
  }
15714
15755
  _getTextPathLength() {
@@ -15837,6 +15878,15 @@ js: import "konva/skia-backend";
15837
15878
  }
15838
15879
  _setTextData() {
15839
15880
  const charArr = stringToArray(this.text());
15881
+ // For RTL scripts (Hebrew, Arabic, …) the path is still walked left to
15882
+ // right by glyph index, so we lay glyphs out in reversed logical order.
15883
+ // A reader scanning the path right-to-left then sees the text in its
15884
+ // intended reading order. This does not perform full Unicode bidi or
15885
+ // Arabic cursive shaping — those need a real shaping engine — but it
15886
+ // makes pure RTL strings render in the right direction.
15887
+ if (this.direction() === 'rtl') {
15888
+ charArr.reverse();
15889
+ }
15840
15890
  const chars = [];
15841
15891
  let width = 0;
15842
15892
  for (let i = 0; i < charArr.length; i++) {
@@ -16144,6 +16194,28 @@ js: import "konva/skia-backend";
16144
16194
  * });
16145
16195
  */
16146
16196
  Factory.addGetterSetter(TextPath, 'kerningFunc', undefined);
16197
+ /**
16198
+ * get/set text direction. Can be 'inherit', 'ltr' or 'rtl'. Default is 'inherit'.
16199
+ *
16200
+ * Setting `'rtl'` reverses the per-glyph layout order along the path, so
16201
+ * Hebrew/Arabic strings read correctly when scanned right-to-left. This is a
16202
+ * pragmatic fix limited by canvas TextPath rendering: each glyph is still
16203
+ * drawn independently, so Arabic cursive joining and full Unicode bidi
16204
+ * reordering of mixed-direction text are not supported. For best results,
16205
+ * pair `direction: 'rtl'` with `align: 'right'` so the text starts at the
16206
+ * end of the path.
16207
+ * @name Konva.TextPath#direction
16208
+ * @method
16209
+ * @param {String} direction
16210
+ * @returns {String}
16211
+ * @example
16212
+ * // get direction
16213
+ * var direction = textpath.direction();
16214
+ *
16215
+ * // set direction
16216
+ * textpath.direction('rtl');
16217
+ */
16218
+ Factory.addGetterSetter(TextPath, 'direction', 'inherit');
16147
16219
 
16148
16220
  const EVENTS_NAME = 'tr-konva';
16149
16221
  const ATTR_CHANGE_LIST = [