@nasser-sw/fabric 7.0.1-beta8 → 7.0.1-beta9

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 (138) hide show
  1. package/debug/konva-master/CHANGELOG.md +1475 -0
  2. package/debug/konva-master/LICENSE +22 -0
  3. package/debug/konva-master/README.md +209 -0
  4. package/debug/konva-master/gulpfile.mjs +110 -0
  5. package/debug/konva-master/package.json +139 -0
  6. package/debug/konva-master/release.sh +62 -0
  7. package/debug/konva-master/resources/doc-includes/ContainerParams.txt +6 -0
  8. package/debug/konva-master/resources/doc-includes/NodeParams.txt +20 -0
  9. package/debug/konva-master/resources/doc-includes/ShapeParams.txt +53 -0
  10. package/debug/konva-master/resources/jsdoc.conf.json +28 -0
  11. package/debug/konva-master/rollup.config.mjs +32 -0
  12. package/debug/konva-master/src/Animation.ts +237 -0
  13. package/debug/konva-master/src/BezierFunctions.ts +826 -0
  14. package/debug/konva-master/src/Canvas.ts +230 -0
  15. package/debug/konva-master/src/Container.ts +649 -0
  16. package/debug/konva-master/src/Context.ts +1017 -0
  17. package/debug/konva-master/src/Core.ts +5 -0
  18. package/debug/konva-master/src/DragAndDrop.ts +173 -0
  19. package/debug/konva-master/src/Factory.ts +246 -0
  20. package/debug/konva-master/src/FastLayer.ts +29 -0
  21. package/debug/konva-master/src/Global.ts +210 -0
  22. package/debug/konva-master/src/Group.ts +31 -0
  23. package/debug/konva-master/src/Layer.ts +546 -0
  24. package/debug/konva-master/src/Node.ts +3477 -0
  25. package/debug/konva-master/src/PointerEvents.ts +67 -0
  26. package/debug/konva-master/src/Shape.ts +2081 -0
  27. package/debug/konva-master/src/Stage.ts +1000 -0
  28. package/debug/konva-master/src/Tween.ts +811 -0
  29. package/debug/konva-master/src/Util.ts +1123 -0
  30. package/debug/konva-master/src/Validators.ts +210 -0
  31. package/debug/konva-master/src/_CoreInternals.ts +85 -0
  32. package/debug/konva-master/src/_FullInternals.ts +171 -0
  33. package/debug/konva-master/src/canvas-backend.ts +36 -0
  34. package/debug/konva-master/src/filters/Blur.ts +388 -0
  35. package/debug/konva-master/src/filters/Brighten.ts +48 -0
  36. package/debug/konva-master/src/filters/Brightness.ts +30 -0
  37. package/debug/konva-master/src/filters/Contrast.ts +75 -0
  38. package/debug/konva-master/src/filters/Emboss.ts +207 -0
  39. package/debug/konva-master/src/filters/Enhance.ts +154 -0
  40. package/debug/konva-master/src/filters/Grayscale.ts +25 -0
  41. package/debug/konva-master/src/filters/HSL.ts +108 -0
  42. package/debug/konva-master/src/filters/HSV.ts +106 -0
  43. package/debug/konva-master/src/filters/Invert.ts +23 -0
  44. package/debug/konva-master/src/filters/Kaleidoscope.ts +274 -0
  45. package/debug/konva-master/src/filters/Mask.ts +220 -0
  46. package/debug/konva-master/src/filters/Noise.ts +44 -0
  47. package/debug/konva-master/src/filters/Pixelate.ts +107 -0
  48. package/debug/konva-master/src/filters/Posterize.ts +46 -0
  49. package/debug/konva-master/src/filters/RGB.ts +82 -0
  50. package/debug/konva-master/src/filters/RGBA.ts +103 -0
  51. package/debug/konva-master/src/filters/Sepia.ts +27 -0
  52. package/debug/konva-master/src/filters/Solarize.ts +29 -0
  53. package/debug/konva-master/src/filters/Threshold.ts +44 -0
  54. package/debug/konva-master/src/index.ts +3 -0
  55. package/debug/konva-master/src/shapes/Arc.ts +176 -0
  56. package/debug/konva-master/src/shapes/Arrow.ts +231 -0
  57. package/debug/konva-master/src/shapes/Circle.ts +76 -0
  58. package/debug/konva-master/src/shapes/Ellipse.ts +121 -0
  59. package/debug/konva-master/src/shapes/Image.ts +319 -0
  60. package/debug/konva-master/src/shapes/Label.ts +386 -0
  61. package/debug/konva-master/src/shapes/Line.ts +364 -0
  62. package/debug/konva-master/src/shapes/Path.ts +1013 -0
  63. package/debug/konva-master/src/shapes/Rect.ts +79 -0
  64. package/debug/konva-master/src/shapes/RegularPolygon.ts +167 -0
  65. package/debug/konva-master/src/shapes/Ring.ts +94 -0
  66. package/debug/konva-master/src/shapes/Sprite.ts +370 -0
  67. package/debug/konva-master/src/shapes/Star.ts +125 -0
  68. package/debug/konva-master/src/shapes/Text.ts +1065 -0
  69. package/debug/konva-master/src/shapes/TextPath.ts +583 -0
  70. package/debug/konva-master/src/shapes/Transformer.ts +1889 -0
  71. package/debug/konva-master/src/shapes/Wedge.ts +129 -0
  72. package/debug/konva-master/src/skia-backend.ts +35 -0
  73. package/debug/konva-master/src/types.ts +84 -0
  74. package/debug/konva-master/tsconfig.json +31 -0
  75. package/debug/konva-master/tsconfig.test.json +7 -0
  76. package/dist/index.js +915 -23
  77. package/dist/index.js.map +1 -1
  78. package/dist/index.min.js +1 -1
  79. package/dist/index.min.js.map +1 -1
  80. package/dist/index.min.mjs +1 -1
  81. package/dist/index.min.mjs.map +1 -1
  82. package/dist/index.mjs +915 -23
  83. package/dist/index.mjs.map +1 -1
  84. package/dist/index.node.cjs +915 -23
  85. package/dist/index.node.cjs.map +1 -1
  86. package/dist/index.node.mjs +915 -23
  87. package/dist/index.node.mjs.map +1 -1
  88. package/dist/package.json.min.mjs +1 -1
  89. package/dist/package.json.mjs +1 -1
  90. package/dist/src/shapes/Text/Text.d.ts +19 -0
  91. package/dist/src/shapes/Text/Text.d.ts.map +1 -1
  92. package/dist/src/shapes/Text/Text.min.mjs +1 -1
  93. package/dist/src/shapes/Text/Text.min.mjs.map +1 -1
  94. package/dist/src/shapes/Text/Text.mjs +238 -4
  95. package/dist/src/shapes/Text/Text.mjs.map +1 -1
  96. package/dist/src/shapes/Textbox.d.ts +38 -1
  97. package/dist/src/shapes/Textbox.d.ts.map +1 -1
  98. package/dist/src/shapes/Textbox.min.mjs +1 -1
  99. package/dist/src/shapes/Textbox.min.mjs.map +1 -1
  100. package/dist/src/shapes/Textbox.mjs +497 -15
  101. package/dist/src/shapes/Textbox.mjs.map +1 -1
  102. package/dist/src/text/examples/arabicTextExample.d.ts +60 -0
  103. package/dist/src/text/examples/arabicTextExample.d.ts.map +1 -0
  104. package/dist/src/text/measure.d.ts +9 -0
  105. package/dist/src/text/measure.d.ts.map +1 -1
  106. package/dist/src/text/measure.min.mjs +1 -1
  107. package/dist/src/text/measure.min.mjs.map +1 -1
  108. package/dist/src/text/measure.mjs +175 -4
  109. package/dist/src/text/measure.mjs.map +1 -1
  110. package/dist/src/text/overlayEditor.d.ts.map +1 -1
  111. package/dist/src/text/overlayEditor.min.mjs +1 -1
  112. package/dist/src/text/overlayEditor.min.mjs.map +1 -1
  113. package/dist/src/text/overlayEditor.mjs +7 -0
  114. package/dist/src/text/overlayEditor.mjs.map +1 -1
  115. package/dist/src/text/scriptUtils.d.ts +142 -0
  116. package/dist/src/text/scriptUtils.d.ts.map +1 -0
  117. package/dist/src/text/scriptUtils.min.mjs +2 -0
  118. package/dist/src/text/scriptUtils.min.mjs.map +1 -0
  119. package/dist/src/text/scriptUtils.mjs +212 -0
  120. package/dist/src/text/scriptUtils.mjs.map +1 -0
  121. package/dist-extensions/src/shapes/Text/Text.d.ts +19 -0
  122. package/dist-extensions/src/shapes/Text/Text.d.ts.map +1 -1
  123. package/dist-extensions/src/shapes/Textbox.d.ts +38 -1
  124. package/dist-extensions/src/shapes/Textbox.d.ts.map +1 -1
  125. package/dist-extensions/src/text/measure.d.ts +9 -0
  126. package/dist-extensions/src/text/measure.d.ts.map +1 -1
  127. package/dist-extensions/src/text/overlayEditor.d.ts.map +1 -1
  128. package/dist-extensions/src/text/scriptUtils.d.ts +142 -0
  129. package/dist-extensions/src/text/scriptUtils.d.ts.map +1 -0
  130. package/fabric-test-editor.html +2401 -46
  131. package/fonts/STV Bold.ttf +0 -0
  132. package/fonts/STV Light.ttf +0 -0
  133. package/fonts/STV Regular.ttf +0 -0
  134. package/package.json +1 -1
  135. package/src/shapes/Text/Text.ts +238 -5
  136. package/src/shapes/Textbox.ts +521 -11
  137. package/src/text/measure.ts +200 -50
  138. package/src/text/overlayEditor.ts +7 -0
@@ -0,0 +1,32 @@
1
+ // import resolve from 'rollup-plugin-node-resolve';
2
+ import typescript from 'rollup-plugin-typescript2';
3
+
4
+ export default {
5
+ input: `src/index.ts`,
6
+ output: [
7
+ {
8
+ file: 'konva.js',
9
+ name: 'Konva',
10
+ format: 'umd',
11
+ sourcemap: false,
12
+ freeze: false,
13
+ },
14
+ ],
15
+ external: [],
16
+ watch: {
17
+ include: 'src/**',
18
+ },
19
+ plugins: [
20
+ // Compile TypeScript files
21
+ typescript({
22
+ useTsconfigDeclarationDir: true,
23
+ abortOnError: false,
24
+ removeComments: false,
25
+ tsconfigOverride: {
26
+ compilerOptions: {
27
+ module: 'ES2020',
28
+ },
29
+ },
30
+ }),
31
+ ],
32
+ };
@@ -0,0 +1,237 @@
1
+ import { glob } from './Global.ts';
2
+ import type { Layer } from './Layer.ts';
3
+ import type { IFrame, AnimationFn } from './types.ts';
4
+ import { Util } from './Util.ts';
5
+
6
+ const now = (function (): () => number {
7
+ if (glob.performance && glob.performance.now) {
8
+ return function () {
9
+ return glob.performance.now();
10
+ };
11
+ }
12
+
13
+ return function () {
14
+ return new Date().getTime();
15
+ };
16
+ })();
17
+
18
+ /**
19
+ * Animation constructor.
20
+ * @constructor
21
+ * @memberof Konva
22
+ * @param {AnimationFn} func function executed on each animation frame. The function is passed a frame object, which contains
23
+ * timeDiff, lastTime, time, and frameRate properties. The timeDiff property is the number of milliseconds that have passed
24
+ * since the last animation frame. The time property is the time in milliseconds that elapsed from the moment the animation started
25
+ * to the current animation frame. The lastTime property is a `time` value from the previous frame. The frameRate property is the current frame rate in frames / second.
26
+ * Return false from function, if you don't need to redraw layer/layers on some frames.
27
+ * @param {Konva.Layer|Array} [layers] layer(s) to be redrawn on each animation frame. Can be a layer, an array of layers, or null.
28
+ * Not specifying a node will result in no redraw.
29
+ * @example
30
+ * // move a node to the right at 50 pixels / second
31
+ * var velocity = 50;
32
+ *
33
+ * var anim = new Konva.Animation(function(frame) {
34
+ * var dist = velocity * (frame.timeDiff / 1000);
35
+ * node.move({x: dist, y: 0});
36
+ * }, layer);
37
+ *
38
+ * anim.start();
39
+ */
40
+ export class Animation {
41
+ func: AnimationFn;
42
+ id = Animation.animIdCounter++;
43
+
44
+ layers: Layer[];
45
+
46
+ frame: IFrame = {
47
+ time: 0,
48
+ timeDiff: 0,
49
+ lastTime: now(),
50
+ frameRate: 0,
51
+ };
52
+
53
+ constructor(func: AnimationFn, layers?) {
54
+ this.func = func;
55
+ this.setLayers(layers);
56
+ }
57
+ /**
58
+ * set layers to be redrawn on each animation frame
59
+ * @method
60
+ * @name Konva.Animation#setLayers
61
+ * @param {Konva.Layer|Array} [layers] layer(s) to be redrawn. Can be a layer, an array of layers, or null. Not specifying a node will result in no redraw.
62
+ * @return {Konva.Animation} this
63
+ */
64
+ setLayers(layers: null | Layer | Layer[]) {
65
+ let lays: Layer[] = [];
66
+ // if passing in no layers
67
+ if (layers) {
68
+ lays = Array.isArray(layers) ? layers : [layers];
69
+ }
70
+ this.layers = lays;
71
+ return this;
72
+ }
73
+ /**
74
+ * get layers
75
+ * @method
76
+ * @name Konva.Animation#getLayers
77
+ * @return {Array} Array of Konva.Layer
78
+ */
79
+ getLayers() {
80
+ return this.layers;
81
+ }
82
+ /**
83
+ * add layer. Returns true if the layer was added, and false if it was not
84
+ * @method
85
+ * @name Konva.Animation#addLayer
86
+ * @param {Konva.Layer} layer to add
87
+ * @return {Bool} true if layer is added to animation, otherwise false
88
+ */
89
+ addLayer(layer: Layer) {
90
+ const layers = this.layers;
91
+ const len = layers.length;
92
+
93
+ // don't add the layer if it already exists
94
+ for (let n = 0; n < len; n++) {
95
+ if (layers[n]._id === layer._id) {
96
+ return false;
97
+ }
98
+ }
99
+
100
+ this.layers.push(layer);
101
+ return true;
102
+ }
103
+ /**
104
+ * determine if animation is running or not. returns true or false
105
+ * @method
106
+ * @name Konva.Animation#isRunning
107
+ * @return {Bool} is animation running?
108
+ */
109
+ isRunning() {
110
+ const a = Animation;
111
+ const animations = a.animations;
112
+ const len = animations.length;
113
+
114
+ for (let n = 0; n < len; n++) {
115
+ if (animations[n].id === this.id) {
116
+ return true;
117
+ }
118
+ }
119
+ return false;
120
+ }
121
+ /**
122
+ * start animation
123
+ * @method
124
+ * @name Konva.Animation#start
125
+ * @return {Konva.Animation} this
126
+ */
127
+ start() {
128
+ this.stop();
129
+ this.frame.timeDiff = 0;
130
+ this.frame.lastTime = now();
131
+ Animation._addAnimation(this);
132
+ return this;
133
+ }
134
+ /**
135
+ * stop animation
136
+ * @method
137
+ * @name Konva.Animation#stop
138
+ * @return {Konva.Animation} this
139
+ */
140
+ stop() {
141
+ Animation._removeAnimation(this);
142
+ return this;
143
+ }
144
+ _updateFrameObject(time: number) {
145
+ this.frame.timeDiff = time - this.frame.lastTime;
146
+ this.frame.lastTime = time;
147
+ this.frame.time += this.frame.timeDiff;
148
+ this.frame.frameRate = 1000 / this.frame.timeDiff;
149
+ }
150
+
151
+ static animations: Array<Animation> = [];
152
+ static animIdCounter = 0;
153
+ static animRunning = false;
154
+
155
+ static _addAnimation(anim) {
156
+ this.animations.push(anim);
157
+ this._handleAnimation();
158
+ }
159
+ static _removeAnimation(anim) {
160
+ const id = anim.id;
161
+ const animations = this.animations;
162
+ const len = animations.length;
163
+
164
+ for (let n = 0; n < len; n++) {
165
+ if (animations[n].id === id) {
166
+ this.animations.splice(n, 1);
167
+ break;
168
+ }
169
+ }
170
+ }
171
+
172
+ static _runFrames() {
173
+ const layerHash = {};
174
+ const animations = this.animations;
175
+ /*
176
+ * loop through all animations and execute animation
177
+ * function. if the animation object has specified node,
178
+ * we can add the node to the nodes hash to eliminate
179
+ * drawing the same node multiple times. The node property
180
+ * can be the stage itself or a layer
181
+ */
182
+ /*
183
+ * WARNING: don't cache animations.length because it could change while
184
+ * the for loop is running, causing a JS error
185
+ */
186
+
187
+ for (let n = 0; n < animations.length; n++) {
188
+ const anim = animations[n];
189
+ const layers = anim.layers;
190
+ const func = anim.func;
191
+
192
+ anim._updateFrameObject(now());
193
+ const layersLen = layers.length;
194
+
195
+ // if animation object has a function, execute it
196
+ let needRedraw;
197
+ if (func) {
198
+ // allow anim bypassing drawing
199
+ needRedraw = func.call(anim, anim.frame) !== false;
200
+ } else {
201
+ needRedraw = true;
202
+ }
203
+ if (!needRedraw) {
204
+ continue;
205
+ }
206
+ for (let i = 0; i < layersLen; i++) {
207
+ const layer = layers[i];
208
+
209
+ if (layer._id !== undefined) {
210
+ layerHash[layer._id] = layer;
211
+ }
212
+ }
213
+ }
214
+
215
+ for (const key in layerHash) {
216
+ if (!layerHash.hasOwnProperty(key)) {
217
+ continue;
218
+ }
219
+ layerHash[key].batchDraw();
220
+ }
221
+ }
222
+ static _animationLoop() {
223
+ const Anim = Animation;
224
+ if (Anim.animations.length) {
225
+ Anim._runFrames();
226
+ Util.requestAnimFrame(Anim._animationLoop);
227
+ } else {
228
+ Anim.animRunning = false;
229
+ }
230
+ }
231
+ static _handleAnimation() {
232
+ if (!this.animRunning) {
233
+ this.animRunning = true;
234
+ Util.requestAnimFrame(this._animationLoop);
235
+ }
236
+ }
237
+ }