@nasser-sw/fabric 7.0.1-beta3 → 7.0.1-beta5

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.
Files changed (105) hide show
  1. package/0 +0 -0
  2. package/dist/index.js +345 -162
  3. package/dist/index.js.map +1 -1
  4. package/dist/index.min.js +1 -1
  5. package/dist/index.min.js.map +1 -1
  6. package/dist/index.min.mjs +1 -1
  7. package/dist/index.min.mjs.map +1 -1
  8. package/dist/index.mjs +345 -162
  9. package/dist/index.mjs.map +1 -1
  10. package/dist/index.node.cjs +345 -162
  11. package/dist/index.node.cjs.map +1 -1
  12. package/dist/index.node.mjs +345 -162
  13. package/dist/index.node.mjs.map +1 -1
  14. package/dist/package.json.min.mjs +1 -1
  15. package/dist/package.json.mjs +1 -1
  16. package/dist/src/shapes/Line.d.ts +32 -86
  17. package/dist/src/shapes/Line.d.ts.map +1 -1
  18. package/dist/src/shapes/Line.min.mjs +1 -1
  19. package/dist/src/shapes/Line.min.mjs.map +1 -1
  20. package/dist/src/shapes/Line.mjs +345 -161
  21. package/dist/src/shapes/Line.mjs.map +1 -1
  22. package/dist-extensions/src/shapes/CustomLine.d.ts +10 -0
  23. package/dist-extensions/src/shapes/CustomLine.d.ts.map +1 -0
  24. package/dist-extensions/src/shapes/Line.d.ts +32 -86
  25. package/dist-extensions/src/shapes/Line.d.ts.map +1 -1
  26. package/fabric-test-editor.html +157 -8
  27. package/fabric-test2.html +513 -0
  28. package/fabric.ts +182 -182
  29. package/package.json +1 -1
  30. package/src/shapes/Line.ts +397 -164
  31. package/debug/konva/CHANGELOG.md +0 -1474
  32. package/debug/konva/LICENSE +0 -22
  33. package/debug/konva/README.md +0 -205
  34. package/debug/konva/gulpfile.mjs +0 -110
  35. package/debug/konva/package.json +0 -139
  36. package/debug/konva/release.sh +0 -65
  37. package/debug/konva/resources/doc-includes/ContainerParams.txt +0 -6
  38. package/debug/konva/resources/doc-includes/NodeParams.txt +0 -20
  39. package/debug/konva/resources/doc-includes/ShapeParams.txt +0 -53
  40. package/debug/konva/resources/jsdoc.conf.json +0 -28
  41. package/debug/konva/rollup.config.mjs +0 -32
  42. package/debug/konva/src/Animation.ts +0 -237
  43. package/debug/konva/src/BezierFunctions.ts +0 -826
  44. package/debug/konva/src/Canvas.ts +0 -193
  45. package/debug/konva/src/Container.ts +0 -649
  46. package/debug/konva/src/Context.ts +0 -1017
  47. package/debug/konva/src/Core.ts +0 -5
  48. package/debug/konva/src/DragAndDrop.ts +0 -173
  49. package/debug/konva/src/Factory.ts +0 -246
  50. package/debug/konva/src/FastLayer.ts +0 -29
  51. package/debug/konva/src/Global.ts +0 -210
  52. package/debug/konva/src/Group.ts +0 -31
  53. package/debug/konva/src/Layer.ts +0 -546
  54. package/debug/konva/src/Node.ts +0 -3477
  55. package/debug/konva/src/PointerEvents.ts +0 -67
  56. package/debug/konva/src/Shape.ts +0 -2081
  57. package/debug/konva/src/Stage.ts +0 -1000
  58. package/debug/konva/src/Tween.ts +0 -811
  59. package/debug/konva/src/Util.ts +0 -1123
  60. package/debug/konva/src/Validators.ts +0 -210
  61. package/debug/konva/src/_CoreInternals.ts +0 -85
  62. package/debug/konva/src/_FullInternals.ts +0 -171
  63. package/debug/konva/src/canvas-backend.ts +0 -36
  64. package/debug/konva/src/filters/Blur.ts +0 -388
  65. package/debug/konva/src/filters/Brighten.ts +0 -48
  66. package/debug/konva/src/filters/Brightness.ts +0 -30
  67. package/debug/konva/src/filters/Contrast.ts +0 -75
  68. package/debug/konva/src/filters/Emboss.ts +0 -207
  69. package/debug/konva/src/filters/Enhance.ts +0 -154
  70. package/debug/konva/src/filters/Grayscale.ts +0 -25
  71. package/debug/konva/src/filters/HSL.ts +0 -108
  72. package/debug/konva/src/filters/HSV.ts +0 -106
  73. package/debug/konva/src/filters/Invert.ts +0 -23
  74. package/debug/konva/src/filters/Kaleidoscope.ts +0 -274
  75. package/debug/konva/src/filters/Mask.ts +0 -220
  76. package/debug/konva/src/filters/Noise.ts +0 -44
  77. package/debug/konva/src/filters/Pixelate.ts +0 -107
  78. package/debug/konva/src/filters/Posterize.ts +0 -46
  79. package/debug/konva/src/filters/RGB.ts +0 -82
  80. package/debug/konva/src/filters/RGBA.ts +0 -103
  81. package/debug/konva/src/filters/Sepia.ts +0 -27
  82. package/debug/konva/src/filters/Solarize.ts +0 -29
  83. package/debug/konva/src/filters/Threshold.ts +0 -44
  84. package/debug/konva/src/index.ts +0 -3
  85. package/debug/konva/src/shapes/Arc.ts +0 -176
  86. package/debug/konva/src/shapes/Arrow.ts +0 -231
  87. package/debug/konva/src/shapes/Circle.ts +0 -76
  88. package/debug/konva/src/shapes/Ellipse.ts +0 -121
  89. package/debug/konva/src/shapes/Image.ts +0 -319
  90. package/debug/konva/src/shapes/Label.ts +0 -386
  91. package/debug/konva/src/shapes/Line.ts +0 -364
  92. package/debug/konva/src/shapes/Path.ts +0 -1013
  93. package/debug/konva/src/shapes/Rect.ts +0 -79
  94. package/debug/konva/src/shapes/RegularPolygon.ts +0 -167
  95. package/debug/konva/src/shapes/Ring.ts +0 -94
  96. package/debug/konva/src/shapes/Sprite.ts +0 -370
  97. package/debug/konva/src/shapes/Star.ts +0 -125
  98. package/debug/konva/src/shapes/Text.ts +0 -1065
  99. package/debug/konva/src/shapes/TextPath.ts +0 -583
  100. package/debug/konva/src/shapes/Transformer.ts +0 -1889
  101. package/debug/konva/src/shapes/Wedge.ts +0 -129
  102. package/debug/konva/src/skia-backend.ts +0 -35
  103. package/debug/konva/src/types.ts +0 -84
  104. package/debug/konva/tsconfig.json +0 -31
  105. package/debug/konva/tsconfig.test.json +0 -7
@@ -1,210 +0,0 @@
1
- import { Konva } from './Global.ts';
2
- import { Util } from './Util.ts';
3
-
4
- function _formatValue(val: any) {
5
- if (Util._isString(val)) {
6
- return '"' + val + '"';
7
- }
8
- if (Object.prototype.toString.call(val) === '[object Number]') {
9
- return val;
10
- }
11
- if (Util._isBoolean(val)) {
12
- return val;
13
- }
14
- return Object.prototype.toString.call(val);
15
- }
16
-
17
- export function RGBComponent(val: number) {
18
- if (val > 255) {
19
- return 255;
20
- } else if (val < 0) {
21
- return 0;
22
- }
23
- return Math.round(val);
24
- }
25
- export function alphaComponent(val: number) {
26
- if (val > 1) {
27
- return 1;
28
- } else if (val < 0.0001) {
29
- // chrome does not honor alpha values of 0
30
- return 0.0001;
31
- }
32
-
33
- return val;
34
- }
35
-
36
- export function getNumberValidator<T>() {
37
- if (Konva.isUnminified) {
38
- return function (val: T, attr: string): T {
39
- if (!Util._isNumber(val)) {
40
- Util.warn(
41
- _formatValue(val) +
42
- ' is a not valid value for "' +
43
- attr +
44
- '" attribute. The value should be a number.'
45
- );
46
- }
47
- return val;
48
- };
49
- }
50
- }
51
-
52
- export function getNumberOrArrayOfNumbersValidator<T>(noOfElements: number) {
53
- if (Konva.isUnminified) {
54
- return function (val: T, attr: string): T {
55
- let isNumber = Util._isNumber(val);
56
- let isValidArray = Util._isArray(val) && val.length == noOfElements;
57
- if (!isNumber && !isValidArray) {
58
- Util.warn(
59
- _formatValue(val) +
60
- ' is a not valid value for "' +
61
- attr +
62
- '" attribute. The value should be a number or Array<number>(' +
63
- noOfElements +
64
- ')'
65
- );
66
- }
67
- return val;
68
- };
69
- }
70
- }
71
-
72
- export function getNumberOrAutoValidator<T>() {
73
- if (Konva.isUnminified) {
74
- return function (val: T, attr: string): T {
75
- const isNumber = Util._isNumber(val);
76
- const isAuto = val === 'auto';
77
-
78
- if (!(isNumber || isAuto)) {
79
- Util.warn(
80
- _formatValue(val) +
81
- ' is a not valid value for "' +
82
- attr +
83
- '" attribute. The value should be a number or "auto".'
84
- );
85
- }
86
- return val;
87
- };
88
- }
89
- }
90
-
91
- export function getStringValidator<T>() {
92
- if (Konva.isUnminified) {
93
- return function (val: T, attr: string): T {
94
- if (!Util._isString(val)) {
95
- Util.warn(
96
- _formatValue(val) +
97
- ' is a not valid value for "' +
98
- attr +
99
- '" attribute. The value should be a string.'
100
- );
101
- }
102
- return val;
103
- };
104
- }
105
- }
106
-
107
- export function getStringOrGradientValidator<T>() {
108
- if (Konva.isUnminified) {
109
- return function (val: T, attr: string): T {
110
- const isString = Util._isString(val);
111
- const isGradient =
112
- Object.prototype.toString.call(val) === '[object CanvasGradient]' ||
113
- (val && val['addColorStop']);
114
- if (!(isString || isGradient)) {
115
- Util.warn(
116
- _formatValue(val) +
117
- ' is a not valid value for "' +
118
- attr +
119
- '" attribute. The value should be a string or a native gradient.'
120
- );
121
- }
122
- return val;
123
- };
124
- }
125
- }
126
-
127
- export function getFunctionValidator<T>() {
128
- if (Konva.isUnminified) {
129
- return function (val: T, attr: string): T {
130
- if (!Util._isFunction(val)) {
131
- Util.warn(
132
- _formatValue(val) +
133
- ' is a not valid value for "' +
134
- attr +
135
- '" attribute. The value should be a function.'
136
- );
137
- }
138
- return val;
139
- };
140
- }
141
- }
142
- export function getNumberArrayValidator<T>() {
143
- if (Konva.isUnminified) {
144
- return function (val: T, attr: string): T {
145
- // Retrieve TypedArray constructor as found in MDN (if TypedArray is available)
146
- // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray#description
147
- const TypedArray = Int8Array ? Object.getPrototypeOf(Int8Array) : null;
148
- if (TypedArray && val instanceof TypedArray) {
149
- return val;
150
- }
151
- if (!Util._isArray(val)) {
152
- Util.warn(
153
- _formatValue(val) +
154
- ' is a not valid value for "' +
155
- attr +
156
- '" attribute. The value should be a array of numbers.'
157
- );
158
- } else {
159
- val.forEach(function (item: any) {
160
- if (!Util._isNumber(item)) {
161
- Util.warn(
162
- '"' +
163
- attr +
164
- '" attribute has non numeric element ' +
165
- item +
166
- '. Make sure that all elements are numbers.'
167
- );
168
- }
169
- });
170
- }
171
- return val;
172
- };
173
- }
174
- }
175
- export function getBooleanValidator<T>() {
176
- if (Konva.isUnminified) {
177
- return function (val: T, attr: string): T {
178
- const isBool = val === true || val === false;
179
- if (!isBool) {
180
- Util.warn(
181
- _formatValue(val) +
182
- ' is a not valid value for "' +
183
- attr +
184
- '" attribute. The value should be a boolean.'
185
- );
186
- }
187
- return val;
188
- };
189
- }
190
- }
191
- export function getComponentValidator<T>(components: string[]) {
192
- if (Konva.isUnminified) {
193
- return function (val: T, attr: string): T {
194
- // ignore validation on undefined value, because it will reset to defalt
195
- if (val === undefined || val === null) {
196
- return val;
197
- }
198
- if (!Util.isObject(val)) {
199
- Util.warn(
200
- _formatValue(val) +
201
- ' is a not valid value for "' +
202
- attr +
203
- '" attribute. The value should be an object with properties ' +
204
- components
205
- );
206
- }
207
- return val;
208
- };
209
- }
210
- }
@@ -1,85 +0,0 @@
1
- // what is core parts of Konva?
2
- import { Konva as Global } from './Global.ts';
3
-
4
- import { Util, Transform } from './Util.ts';
5
- import { Node } from './Node.ts';
6
- import { Container } from './Container.ts';
7
-
8
- import { Stage, stages } from './Stage.ts';
9
-
10
- import { Layer } from './Layer.ts';
11
- import { FastLayer } from './FastLayer.ts';
12
-
13
- import { Group } from './Group.ts';
14
-
15
- import { DD } from './DragAndDrop.ts';
16
-
17
- import { Shape, shapes } from './Shape.ts';
18
-
19
- import { Animation } from './Animation.ts';
20
- import { Tween, Easings } from './Tween.ts';
21
-
22
- import { Context } from './Context.ts';
23
- import { Canvas } from './Canvas.ts';
24
-
25
- export const Konva = Util._assign(Global, {
26
- Util,
27
- Transform,
28
- Node,
29
- Container,
30
- Stage,
31
- stages,
32
- Layer,
33
- FastLayer,
34
- Group,
35
- DD,
36
- Shape,
37
- shapes,
38
- Animation,
39
- Tween,
40
- Easings,
41
- Context,
42
- Canvas,
43
- });
44
-
45
- export namespace Konva {
46
- export type Vector2d = import('./types.ts').Vector2d;
47
- export type Node = import('./Node.ts').Node;
48
- export type NodeConfig = import('./Node.ts').NodeConfig;
49
- export type KonvaEventObject<EventType> =
50
- import('./Node.ts').KonvaEventObject<EventType>;
51
-
52
- export type KonvaPointerEvent =
53
- import('./PointerEvents.ts').KonvaPointerEvent;
54
-
55
- export type KonvaEventListener<This, EventType> =
56
- import('./Node.ts').KonvaEventListener<This, EventType>;
57
-
58
- export type Container = import('./Container.ts').Container<Node>;
59
- export type ContainerConfig = import('./Container.ts').ContainerConfig;
60
-
61
- export type Transform = import('./Util.ts').Transform;
62
-
63
- export type Context = import('./Context.ts').Context;
64
-
65
- export type Stage = import('./Stage.ts').Stage;
66
- export type StageConfig = import('./Stage.ts').StageConfig;
67
-
68
- export type Layer = import('./Layer.ts').Layer;
69
- export type LayerConfig = import('./Layer.ts').LayerConfig;
70
-
71
- export type FastLayer = import('./FastLayer.ts').FastLayer;
72
-
73
- export type Group = import('./Group.ts').Group;
74
- export type GroupConfig = import('./Group.ts').GroupConfig;
75
-
76
- export type Shape = import('./Shape.ts').Shape;
77
- export type ShapeConfig = import('./Shape.ts').ShapeConfig;
78
-
79
- export type Animation = import('./Animation.ts').Animation;
80
-
81
- export type Tween = import('./Tween.ts').Tween;
82
- export type TweenConfig = import('./Tween.ts').TweenConfig;
83
- }
84
-
85
- export default Konva;
@@ -1,171 +0,0 @@
1
- // we need to import core of the Konva and then extend it with all additional objects
2
-
3
- import { Konva as Core } from './_CoreInternals.ts';
4
-
5
- // shapes
6
- import { Arc } from './shapes/Arc.ts';
7
- import { Arrow } from './shapes/Arrow.ts';
8
- import { Circle } from './shapes/Circle.ts';
9
- import { Ellipse } from './shapes/Ellipse.ts';
10
- import { Image } from './shapes/Image.ts';
11
- import { Label, Tag } from './shapes/Label.ts';
12
- import { Line } from './shapes/Line.ts';
13
- import { Path } from './shapes/Path.ts';
14
- import { Rect } from './shapes/Rect.ts';
15
- import { RegularPolygon } from './shapes/RegularPolygon.ts';
16
- import { Ring } from './shapes/Ring.ts';
17
- import { Sprite } from './shapes/Sprite.ts';
18
- import { Star } from './shapes/Star.ts';
19
- import { Text } from './shapes/Text.ts';
20
- import { TextPath } from './shapes/TextPath.ts';
21
- import { Transformer } from './shapes/Transformer.ts';
22
- import { Wedge } from './shapes/Wedge.ts';
23
-
24
- // filters
25
- import { Blur } from './filters/Blur.ts';
26
- import { Brighten } from './filters/Brighten.ts';
27
- import { Brightness } from './filters/Brightness.ts';
28
- import { Contrast } from './filters/Contrast.ts';
29
- import { Emboss } from './filters/Emboss.ts';
30
- import { Enhance } from './filters/Enhance.ts';
31
- import { Grayscale } from './filters/Grayscale.ts';
32
- import { HSL } from './filters/HSL.ts';
33
- import { HSV } from './filters/HSV.ts';
34
- import { Invert } from './filters/Invert.ts';
35
- import { Kaleidoscope } from './filters/Kaleidoscope.ts';
36
- import { Mask } from './filters/Mask.ts';
37
- import { Noise } from './filters/Noise.ts';
38
- import { Pixelate } from './filters/Pixelate.ts';
39
- import { Posterize } from './filters/Posterize.ts';
40
- import { RGB } from './filters/RGB.ts';
41
- import { RGBA } from './filters/RGBA.ts';
42
- import { Sepia } from './filters/Sepia.ts';
43
- import { Solarize } from './filters/Solarize.ts';
44
- import { Threshold } from './filters/Threshold.ts';
45
-
46
- export const Konva = Core.Util._assign(Core, {
47
- Arc,
48
- Arrow,
49
- Circle,
50
- Ellipse,
51
- Image,
52
- Label,
53
- Tag,
54
- Line,
55
- Path,
56
- Rect,
57
- RegularPolygon,
58
- Ring,
59
- Sprite,
60
- Star,
61
- Text,
62
- TextPath,
63
- Transformer,
64
- Wedge,
65
- /**
66
- * @namespace Filters
67
- * @memberof Konva
68
- */
69
- Filters: {
70
- Blur,
71
- Brightness,
72
- Brighten,
73
- Contrast,
74
- Emboss,
75
- Enhance,
76
- Grayscale,
77
- HSL,
78
- HSV,
79
- Invert,
80
- Kaleidoscope,
81
- Mask,
82
- Noise,
83
- Pixelate,
84
- Posterize,
85
- RGB,
86
- RGBA,
87
- Sepia,
88
- Solarize,
89
- Threshold,
90
- },
91
- });
92
-
93
- export namespace Konva {
94
- export type Vector2d = Core.Vector2d;
95
- export type Node = Core.Node;
96
- export type NodeConfig = Core.NodeConfig;
97
- export type KonvaEventObject<EventType> = Core.KonvaEventObject<EventType>;
98
-
99
- export type KonvaPointerEvent = Core.KonvaPointerEvent;
100
-
101
- export type KonvaEventListener<This, EventType> = Core.KonvaEventListener<
102
- This,
103
- EventType
104
- >;
105
-
106
- export type Container = Core.Container;
107
- export type ContainerConfig = Core.ContainerConfig;
108
-
109
- export type Transform = Core.Transform;
110
-
111
- export type Context = Core.Context;
112
-
113
- export type Stage = Core.Stage;
114
- export type StageConfig = Core.StageConfig;
115
-
116
- export type Layer = Core.Layer;
117
- export type LayerConfig = Core.LayerConfig;
118
-
119
- export type FastLayer = Core.FastLayer;
120
-
121
- export type Group = Core.Group;
122
- export type GroupConfig = Core.GroupConfig;
123
-
124
- export type Shape = Core.Shape;
125
- export type ShapeConfig = Core.ShapeConfig;
126
-
127
- export type Animation = Core.Animation;
128
-
129
- export type Tween = Core.Tween;
130
- export type TweenConfig = Core.TweenConfig;
131
-
132
- export type Arc = import('./shapes/Arc.ts').Arc;
133
- export type ArcConfig = import('./shapes/Arc.ts').ArcConfig;
134
- export type Arrow = import('./shapes/Arrow.ts').Arrow;
135
- export type ArrowConfig = import('./shapes/Arrow.ts').ArrowConfig;
136
- export type Circle = import('./shapes/Circle.ts').Circle;
137
- export type CircleConfig = import('./shapes/Circle.ts').CircleConfig;
138
- export type Ellipse = import('./shapes/Ellipse.ts').Ellipse;
139
- export type EllipseConfig = import('./shapes/Ellipse.ts').EllipseConfig;
140
- export type Image = import('./shapes/Image.ts').Image;
141
- export type ImageConfig = import('./shapes/Image.ts').ImageConfig;
142
- export type Label = import('./shapes/Label.ts').Label;
143
- export type LabelConfig = import('./shapes/Label.ts').LabelConfig;
144
- export type Tag = import('./shapes/Label.ts').Tag;
145
- export type TagConfig = import('./shapes/Label.ts').TagConfig;
146
- export type Line = import('./shapes/Line.ts').Line;
147
- export type LineConfig = import('./shapes/Line.ts').LineConfig;
148
- export type Path = import('./shapes/Path.ts').Path;
149
- export type PathConfig = import('./shapes/Path.ts').PathConfig;
150
- export type Rect = import('./shapes/Rect.ts').Rect;
151
- export type RectConfig = import('./shapes/Rect.ts').RectConfig;
152
- export type RegularPolygon =
153
- import('./shapes/RegularPolygon.ts').RegularPolygon;
154
- export type RegularPolygonConfig =
155
- import('./shapes/RegularPolygon.ts').RegularPolygonConfig;
156
- export type Ring = import('./shapes/Ring.ts').Ring;
157
- export type RingConfig = import('./shapes/Ring.ts').RingConfig;
158
- export type Sprite = import('./shapes/Sprite.ts').Sprite;
159
- export type SpriteConfig = import('./shapes/Sprite.ts').SpriteConfig;
160
- export type Star = import('./shapes/Star.ts').Star;
161
- export type StarConfig = import('./shapes/Star.ts').StarConfig;
162
- export type Text = import('./shapes/Text.ts').Text;
163
- export type TextConfig = import('./shapes/Text.ts').TextConfig;
164
- export type TextPath = import('./shapes/TextPath.ts').TextPath;
165
- export type TextPathConfig = import('./shapes/TextPath.ts').TextPathConfig;
166
- export type Transformer = import('./shapes/Transformer.ts').Transformer;
167
- export type TransformerConfig =
168
- import('./shapes/Transformer.ts').TransformerConfig;
169
- export type Wedge = import('./shapes/Wedge.ts').Wedge;
170
- export type WedgeConfig = import('./shapes/Wedge.ts').WedgeConfig;
171
- }
@@ -1,36 +0,0 @@
1
- import { Konva } from './_CoreInternals.ts';
2
- // @ts-ignore
3
- import * as Canvas from 'canvas';
4
-
5
- const canvas = Canvas['default'] || Canvas;
6
-
7
- // @ts-ignore
8
- global.DOMMatrix = canvas.DOMMatrix;
9
-
10
- (global as any).Path2D ??= class Path2D {
11
- constructor(path: any) {
12
- (this as any).path = path;
13
- }
14
-
15
- get [Symbol.toStringTag]() {
16
- return `Path2D`;
17
- }
18
- };
19
-
20
- Konva.Util['createCanvasElement'] = () => {
21
- const node = canvas.createCanvas(300, 300) as any;
22
- if (!node['style']) {
23
- node['style'] = {};
24
- }
25
- return node;
26
- };
27
-
28
- // create image in Node env
29
- Konva.Util.createImageElement = () => {
30
- const node = new canvas.Image() as any;
31
- return node;
32
- };
33
-
34
- Konva._renderBackend = 'node-canvas';
35
-
36
- export default Konva;