konva 9.3.13 → 9.3.15

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/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.13',
19
+ version: '9.3.15',
20
20
  isBrowser: detectBrowser(),
21
21
  isUnminified: /param/.test(function (param) { }.toString()),
22
22
  dblClickWindow: 400,
package/lib/Node.d.ts CHANGED
@@ -39,16 +39,16 @@ export interface NodeConfig {
39
39
  type NodeEventMap = GlobalEventHandlersEventMap & {
40
40
  [index: string]: any;
41
41
  };
42
- export interface KonvaEventObject<EventType> {
42
+ export interface KonvaEventObject<EventType, This = Node> {
43
43
  type: string;
44
44
  target: Shape | Stage;
45
45
  evt: EventType;
46
46
  pointerId: number;
47
- currentTarget: Node;
47
+ currentTarget: This;
48
48
  cancelBubble: boolean;
49
49
  child?: Node;
50
50
  }
51
- export type KonvaEventListener<This, EventType> = (this: This, ev: KonvaEventObject<EventType>) => void;
51
+ export type KonvaEventListener<This, EventType> = (this: This, ev: KonvaEventObject<EventType, This>) => void;
52
52
  export declare abstract class Node<Config extends NodeConfig = NodeConfig> {
53
53
  _id: number;
54
54
  eventListeners: {
package/lib/Shape.js CHANGED
@@ -35,7 +35,13 @@ function _strokeFunc(context) {
35
35
  context.stroke();
36
36
  }
37
37
  function _fillFuncHit(context) {
38
- context.fill();
38
+ const fillRule = this.attrs.fillRule;
39
+ if (fillRule) {
40
+ context.fill(fillRule);
41
+ }
42
+ else {
43
+ context.fill();
44
+ }
39
45
  }
40
46
  function _strokeFuncHit(context) {
41
47
  context.stroke();
package/lib/Stage.d.ts CHANGED
@@ -4,7 +4,7 @@ import { GetSet, Vector2d } from './types.js';
4
4
  import { Shape } from './Shape.js';
5
5
  import { Layer } from './Layer.js';
6
6
  export interface StageConfig extends ContainerConfig {
7
- container: HTMLDivElement | string;
7
+ container?: HTMLDivElement | string;
8
8
  }
9
9
  export declare const stages: Stage[];
10
10
  export declare class Stage extends Container<Layer> {
@@ -29,6 +29,11 @@ class Image extends Shape_1.Shape {
29
29
  }
30
30
  }
31
31
  _useBufferCanvas() {
32
+ const hasCornerRadius = !!this.cornerRadius();
33
+ const hasShadow = this.hasShadow();
34
+ if (hasCornerRadius && hasShadow) {
35
+ return true;
36
+ }
32
37
  return super._useBufferCanvas(true);
33
38
  }
34
39
  _sceneFunc(context) {
@@ -17,19 +17,19 @@ export declare class Path extends Shape<PathConfig> {
17
17
  };
18
18
  getLength(): number;
19
19
  getPointAtLength(length: any): {
20
- x: any;
21
- y: any;
20
+ x: number;
21
+ y: number;
22
22
  } | null;
23
23
  data: GetSet<string, this>;
24
24
  static getLineLength(x1: any, y1: any, x2: any, y2: any): number;
25
25
  static getPathLength(dataArray: PathSegment[]): number;
26
- static getPointAtLengthOfDataArray(length: number, dataArray: any): {
27
- x: any;
28
- y: any;
26
+ static getPointAtLengthOfDataArray(length: number, dataArray: PathSegment[]): {
27
+ x: number;
28
+ y: number;
29
29
  } | null;
30
- static getPointOnLine(dist: any, P1x: any, P1y: any, P2x: any, P2y: any, fromX?: any, fromY?: any): {
31
- x: any;
32
- y: any;
30
+ static getPointOnLine(dist: number, P1x: number, P1y: number, P2x: number, P2y: number, fromX?: number, fromY?: number): {
31
+ x: number;
32
+ y: number;
33
33
  };
34
34
  static getPointOnCubicBezier(pct: any, P1x: any, P1y: any, P2x: any, P2y: any, P3x: any, P3y: any, P4x: any, P4y: any): {
35
35
  x: number;
@@ -140,7 +140,7 @@ class Path extends Shape_1.Shape {
140
140
  return pathLength;
141
141
  }
142
142
  static getPointAtLengthOfDataArray(length, dataArray) {
143
- var point, i = 0, ii = dataArray.length;
143
+ var points, i = 0, ii = dataArray.length;
144
144
  if (!ii) {
145
145
  return null;
146
146
  }
@@ -149,17 +149,17 @@ class Path extends Shape_1.Shape {
149
149
  ++i;
150
150
  }
151
151
  if (i === ii) {
152
- point = dataArray[i - 1].points.slice(-2);
152
+ points = dataArray[i - 1].points.slice(-2);
153
153
  return {
154
- x: point[0],
155
- y: point[1],
154
+ x: points[0],
155
+ y: points[1],
156
156
  };
157
157
  }
158
158
  if (length < 0.01) {
159
- point = dataArray[i].points.slice(0, 2);
159
+ points = dataArray[i].points.slice(0, 2);
160
160
  return {
161
- x: point[0],
162
- y: point[1],
161
+ x: points[0],
162
+ y: points[1],
163
163
  };
164
164
  }
165
165
  var cp = dataArray[i];
@@ -37,19 +37,19 @@ export declare class Text extends Shape<TextConfig> {
37
37
  getHeight(): any;
38
38
  getTextWidth(): number;
39
39
  getTextHeight(): number;
40
- measureSize(text: any): {
41
- actualBoundingBoxAscent: any;
42
- actualBoundingBoxDescent: any;
43
- actualBoundingBoxLeft: any;
44
- actualBoundingBoxRight: any;
45
- alphabeticBaseline: any;
46
- emHeightAscent: any;
47
- emHeightDescent: any;
48
- fontBoundingBoxAscent: any;
49
- fontBoundingBoxDescent: any;
50
- hangingBaseline: any;
51
- ideographicBaseline: any;
52
- width: any;
40
+ measureSize(text: string): {
41
+ actualBoundingBoxAscent: number;
42
+ actualBoundingBoxDescent: number;
43
+ actualBoundingBoxLeft: number;
44
+ actualBoundingBoxRight: number;
45
+ alphabeticBaseline: number;
46
+ emHeightAscent: number;
47
+ emHeightDescent: number;
48
+ fontBoundingBoxAscent: number;
49
+ fontBoundingBoxDescent: number;
50
+ hangingBaseline: number;
51
+ ideographicBaseline: number;
52
+ width: number;
53
53
  height: number;
54
54
  };
55
55
  _getContextFont(): string;
@@ -8,7 +8,21 @@ const Global_1 = require("../Global");
8
8
  const Validators_1 = require("../Validators");
9
9
  const Global_2 = require("../Global");
10
10
  function stringToArray(string) {
11
- return Array.from(string);
11
+ return [...string].reduce((acc, char, index, array) => {
12
+ if (/\p{Emoji_Modifier_Base}\p{Emoji_Modifier}?(?:\u200D\p{Emoji_Presentation})+/u.test(char)) {
13
+ acc.push(char);
14
+ }
15
+ else if (/\p{Regional_Indicator}{2}/u.test(char + (array[index + 1] || ''))) {
16
+ acc.push(char + array[index + 1]);
17
+ }
18
+ else if (index > 0 && /\p{Mn}|\p{Me}|\p{Mc}/u.test(char)) {
19
+ acc[acc.length - 1] += char;
20
+ }
21
+ else {
22
+ acc.push(char);
23
+ }
24
+ return acc;
25
+ }, []);
12
26
  }
13
27
  exports.stringToArray = stringToArray;
14
28
  var AUTO = 'auto', CENTER = 'center', INHERIT = 'inherit', JUSTIFY = 'justify', CHANGE_KONVA = 'Change.konva', CONTEXT_2D = '2d', DASH = '-', LEFT = 'left', LTR = 'ltr', TEXT = 'text', TEXT_UPPER = 'Text', TOP = 'top', BOTTOM = 'bottom', MIDDLE = 'middle', NORMAL = 'normal', PX_SPACE = 'px ', SPACE = ' ', RIGHT = 'right', RTL = 'rtl', WORD = 'word', CHAR = 'char', NONE = 'none', ELLIPSIS = '…', ATTR_CHANGE_LIST = [
@@ -28,8 +28,8 @@ export declare class TextPath extends Shape<TextPathConfig> {
28
28
  constructor(config?: TextPathConfig);
29
29
  _getTextPathLength(): number;
30
30
  _getPointAtLength(length: number): {
31
- x: any;
32
- y: any;
31
+ x: number;
32
+ y: number;
33
33
  } | null;
34
34
  _readDataAttribute(): void;
35
35
  _sceneFunc(context: Context): void;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "konva",
3
- "version": "9.3.13",
3
+ "version": "9.3.15",
4
4
  "author": "Anton Lavrenov",
5
5
  "files": [
6
6
  "README.md",