redhotmagma-graphics-editor 1.51.0 → 1.51.2
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/App.js +76 -81
- package/CanvasAdapters/Mock/Canvas.js +54 -62
- package/CanvasAdapters/Mock/Objects/CanvasObject.js +15 -17
- package/CanvasAdapters/Mock/Objects/Group.js +21 -23
- package/CanvasAdapters/Mock/Objects/Image.js +21 -23
- package/CanvasAdapters/Mock/Objects/Text.js +22 -24
- package/CanvasAdapters/PaperJs/Canvas.js +144 -164
- package/CanvasAdapters/PaperJs/Objects/CanvasObject.js +24 -25
- package/CanvasAdapters/PaperJs/Objects/Group.js +22 -24
- package/CanvasAdapters/PaperJs/Objects/Image.js +56 -62
- package/CanvasAdapters/PaperJs/Objects/Text.js +35 -36
- package/CanvasAdapters/PaperJs/Utils/HTML2Paper.js +11 -12
- package/CanvasAdapters/PaperJs/Utils/SVGfix.js +5 -5
- package/CanvasAdapters/PaperJs/Utils/StyleParams.js +3 -3
- package/CanvasAdapters/PaperJs/Utils/TextToSVGRepository.js +26 -27
- package/CanvasAdapters/PaperJs/Utils/UseColorLayer.js +1 -1
- package/CanvasAdapters/PaperJs/Utils/UseMask.js +49 -55
- package/CanvasInterface/Canvas.js +56 -61
- package/CanvasInterface/CanvasProvider.js +22 -24
- package/CanvasInterface/Objects/CanvasObject.js +16 -19
- package/CanvasInterface/Observable.js +10 -11
- package/CanvasInterface/canvasConnect.js +21 -23
- package/CanvasInterface/index.js +1 -2
- package/Components/Canvas/Canvas.js +20 -22
- package/Components/Canvas/CanvasContainer.js +1 -1
- package/Components/DelayedContainer.js +19 -21
- package/Components/Editor/Editor.js +19 -20
- package/Components/Editor/EditorContainer.js +30 -32
- package/Components/InlineToolbox/InlineToolbox.js +40 -42
- package/Components/InlineToolbox/InlineToolboxButton.js +7 -7
- package/Components/ManipulableContainer.js +20 -22
- package/Components/ResizeDetect/ResizeDetect.js +20 -22
- package/Components/Rulers/Ruler.js +22 -25
- package/Components/Rulers/Rulers.js +17 -19
- package/Components/SelectionToolbox/ColorPalette.js +20 -23
- package/Components/SelectionToolbox/SelectionToolbox.js +25 -26
- package/Components/SelectionToolbox/TextTools.js +29 -31
- package/Components/StandardToolbox/StandardToolbox.js +63 -65
- package/Components/TextEditor/TextEditor.js +39 -41
- package/Components/TextEditor/TextEditorStateProvider.js +19 -21
- package/Components/Toolbox/ToolboxContainer.js +4 -4
- package/Components/Toolbox/ToolboxRow.js +4 -4
- package/Utils/DOM.js +7 -7
- package/Utils/Device.js +1 -1
- package/Utils/Logger.js +7 -8
- package/Utils/Range.js +1 -1
- package/_demos/UsingExternalControls/App.js +18 -20
- package/_demos/UsingRenderProps/App.js +21 -23
- package/index.js +4 -2
- package/package.json +1 -1
package/App.js
CHANGED
|
@@ -17,25 +17,26 @@ var _excluded = ["children"]; // ╔════════════╗
|
|
|
17
17
|
// ╚════════════╝
|
|
18
18
|
// Do not use this App component directly!
|
|
19
19
|
// It was made only for development and demo purposes!
|
|
20
|
-
function _interopRequireDefault(
|
|
21
|
-
function
|
|
22
|
-
function
|
|
23
|
-
function
|
|
24
|
-
function
|
|
25
|
-
function
|
|
26
|
-
function
|
|
27
|
-
function
|
|
28
|
-
function
|
|
29
|
-
function
|
|
30
|
-
function
|
|
31
|
-
function
|
|
32
|
-
function
|
|
33
|
-
function
|
|
34
|
-
function
|
|
35
|
-
function
|
|
36
|
-
function
|
|
37
|
-
function
|
|
38
|
-
function
|
|
20
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
|
|
21
|
+
function _regenerator() { /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/babel/babel/blob/main/packages/babel-helpers/LICENSE */ var e, t, r = "function" == typeof Symbol ? Symbol : {}, n = r.iterator || "@@iterator", o = r.toStringTag || "@@toStringTag"; function i(r, n, o, i) { var c = n && n.prototype instanceof Generator ? n : Generator, u = Object.create(c.prototype); return _regeneratorDefine2(u, "_invoke", function (r, n, o) { var i, c, u, f = 0, p = o || [], y = !1, G = { p: 0, n: 0, v: e, a: d, f: d.bind(e, 4), d: function d(t, r) { return i = t, c = 0, u = e, G.n = r, a; } }; function d(r, n) { for (c = r, u = n, t = 0; !y && f && !o && t < p.length; t++) { var o, i = p[t], d = G.p, l = i[2]; r > 3 ? (o = l === n) && (u = i[(c = i[4]) ? 5 : (c = 3, 3)], i[4] = i[5] = e) : i[0] <= d && ((o = r < 2 && d < i[1]) ? (c = 0, G.v = n, G.n = i[1]) : d < l && (o = r < 3 || i[0] > n || n > l) && (i[4] = r, i[5] = n, G.n = l, c = 0)); } if (o || r > 1) return a; throw y = !0, n; } return function (o, p, l) { if (f > 1) throw TypeError("Generator is already running"); for (y && 1 === p && d(p, l), c = p, u = l; (t = c < 2 ? e : u) || !y;) { i || (c ? c < 3 ? (c > 1 && (G.n = -1), d(c, u)) : G.n = u : G.v = u); try { if (f = 2, i) { if (c || (o = "next"), t = i[o]) { if (!(t = t.call(i, u))) throw TypeError("iterator result is not an object"); if (!t.done) return t; u = t.value, c < 2 && (c = 0); } else 1 === c && (t = i["return"]) && t.call(i), c < 2 && (u = TypeError("The iterator does not provide a '" + o + "' method"), c = 1); i = e; } else if ((t = (y = G.n < 0) ? u : r.call(n, G)) !== a) break; } catch (t) { i = e, c = 1, u = t; } finally { f = 1; } } return { value: t, done: y }; }; }(r, o, i), !0), u; } var a = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} t = Object.getPrototypeOf; var c = [][n] ? t(t([][n]())) : (_regeneratorDefine2(t = {}, n, function () { return this; }), t), u = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(c); function f(e) { return Object.setPrototypeOf ? Object.setPrototypeOf(e, GeneratorFunctionPrototype) : (e.__proto__ = GeneratorFunctionPrototype, _regeneratorDefine2(e, o, "GeneratorFunction")), e.prototype = Object.create(u), e; } return GeneratorFunction.prototype = GeneratorFunctionPrototype, _regeneratorDefine2(u, "constructor", GeneratorFunctionPrototype), _regeneratorDefine2(GeneratorFunctionPrototype, "constructor", GeneratorFunction), GeneratorFunction.displayName = "GeneratorFunction", _regeneratorDefine2(GeneratorFunctionPrototype, o, "GeneratorFunction"), _regeneratorDefine2(u), _regeneratorDefine2(u, o, "Generator"), _regeneratorDefine2(u, n, function () { return this; }), _regeneratorDefine2(u, "toString", function () { return "[object Generator]"; }), (_regenerator = function _regenerator() { return { w: i, m: f }; })(); }
|
|
22
|
+
function _regeneratorDefine2(e, r, n, t) { var i = Object.defineProperty; try { i({}, "", {}); } catch (e) { i = 0; } _regeneratorDefine2 = function _regeneratorDefine(e, r, n, t) { function o(r, n) { _regeneratorDefine2(e, r, function (e) { return this._invoke(r, n, e); }); } r ? i ? i(e, r, { value: n, enumerable: !t, configurable: !t, writable: !t }) : e[r] = n : (o("next", 0), o("throw", 1), o("return", 2)); }, _regeneratorDefine2(e, r, n, t); }
|
|
23
|
+
function asyncGeneratorStep(n, t, e, r, o, a, c) { try { var i = n[a](c), u = i.value; } catch (n) { return void e(n); } i.done ? t(u) : Promise.resolve(u).then(r, o); }
|
|
24
|
+
function _asyncToGenerator(n) { return function () { var t = this, e = arguments; return new Promise(function (r, o) { var a = n.apply(t, e); function _next(n) { asyncGeneratorStep(a, r, o, _next, _throw, "next", n); } function _throw(n) { asyncGeneratorStep(a, r, o, _next, _throw, "throw", n); } _next(void 0); }); }; }
|
|
25
|
+
function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); }
|
|
26
|
+
function _defineProperties(e, r) { for (var t = 0; t < r.length; t++) { var o = r[t]; o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, _toPropertyKey(o.key), o); } }
|
|
27
|
+
function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; }
|
|
28
|
+
function _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); }
|
|
29
|
+
function _possibleConstructorReturn(t, e) { if (e && ("object" == _typeof(e) || "function" == typeof e)) return e; if (void 0 !== e) throw new TypeError("Derived constructors may only return object or undefined"); return _assertThisInitialized(t); }
|
|
30
|
+
function _assertThisInitialized(e) { if (void 0 === e) throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); return e; }
|
|
31
|
+
function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
|
|
32
|
+
function _getPrototypeOf(t) { return _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function (t) { return t.__proto__ || Object.getPrototypeOf(t); }, _getPrototypeOf(t); }
|
|
33
|
+
function _inherits(t, e) { if ("function" != typeof e && null !== e) throw new TypeError("Super expression must either be null or a function"); t.prototype = Object.create(e && e.prototype, { constructor: { value: t, writable: !0, configurable: !0 } }), Object.defineProperty(t, "prototype", { writable: !1 }), e && _setPrototypeOf(t, e); }
|
|
34
|
+
function _setPrototypeOf(t, e) { return _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function (t, e) { return t.__proto__ = e, t; }, _setPrototypeOf(t, e); }
|
|
35
|
+
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
|
36
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
|
|
37
|
+
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
38
|
+
function _objectWithoutProperties(e, t) { if (null == e) return {}; var o, r, i = _objectWithoutPropertiesLoose(e, t); if (Object.getOwnPropertySymbols) { var n = Object.getOwnPropertySymbols(e); for (r = 0; r < n.length; r++) o = n[r], -1 === t.indexOf(o) && {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]); } return i; }
|
|
39
|
+
function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (-1 !== e.indexOf(n)) continue; t[n] = r[n]; } return t; }
|
|
39
40
|
console.warn('Do not use this App component directly! It was made only for development and demo purposes!');
|
|
40
41
|
var canvasRepository = (0, _CanvasRepository.createCanvasRepository)();
|
|
41
42
|
canvasRepository.onCreate = function (canvas) {
|
|
@@ -172,19 +173,17 @@ var MaskSelect = function MaskSelect(_ref3) {
|
|
|
172
173
|
}));
|
|
173
174
|
};
|
|
174
175
|
var App = /*#__PURE__*/function (_React$Component) {
|
|
175
|
-
_inherits(App, _React$Component);
|
|
176
|
-
var _super = _createSuper(App);
|
|
177
176
|
function App() {
|
|
178
177
|
var _this;
|
|
179
178
|
_classCallCheck(this, App);
|
|
180
179
|
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
181
180
|
args[_key] = arguments[_key];
|
|
182
181
|
}
|
|
183
|
-
_this =
|
|
184
|
-
_defineProperty(
|
|
182
|
+
_this = _callSuper(this, App, [].concat(args));
|
|
183
|
+
_defineProperty(_this, "state", {
|
|
185
184
|
canvasInstance: canvasRepository.requestCanvas('c1', canvases.c1)
|
|
186
185
|
});
|
|
187
|
-
_defineProperty(
|
|
186
|
+
_defineProperty(_this, "mockUploadFunction", function (files) {
|
|
188
187
|
return new Promise(function (resolve, reject) {
|
|
189
188
|
var reader = new FileReader();
|
|
190
189
|
reader.onload = function () {
|
|
@@ -197,7 +196,7 @@ var App = /*#__PURE__*/function (_React$Component) {
|
|
|
197
196
|
reader.readAsDataURL(files[0]);
|
|
198
197
|
});
|
|
199
198
|
});
|
|
200
|
-
_defineProperty(
|
|
199
|
+
_defineProperty(_this, "saveCanvasData", function () {
|
|
201
200
|
var canvasData = canvasRepository.getActiveCanvas().toObject(true, {
|
|
202
201
|
includeObjects: true
|
|
203
202
|
});
|
|
@@ -206,112 +205,108 @@ var App = /*#__PURE__*/function (_React$Component) {
|
|
|
206
205
|
console.log('canvas saved!');
|
|
207
206
|
}
|
|
208
207
|
});
|
|
209
|
-
_defineProperty(
|
|
210
|
-
var canvasData;
|
|
211
|
-
return
|
|
212
|
-
while (1) switch (_context.
|
|
208
|
+
_defineProperty(_this, "loadCanvasData", /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee() {
|
|
209
|
+
var canvasData, _t;
|
|
210
|
+
return _regenerator().w(function (_context) {
|
|
211
|
+
while (1) switch (_context.p = _context.n) {
|
|
213
212
|
case 0:
|
|
214
213
|
if (!window.localStorage) {
|
|
215
|
-
_context.
|
|
214
|
+
_context.n = 5;
|
|
216
215
|
break;
|
|
217
216
|
}
|
|
218
|
-
_context.
|
|
217
|
+
_context.p = 1;
|
|
219
218
|
canvasData = JSON.parse(localStorage.getItem('savedCanvasData'));
|
|
220
219
|
if (!canvasData) {
|
|
221
|
-
_context.
|
|
220
|
+
_context.n = 3;
|
|
222
221
|
break;
|
|
223
222
|
}
|
|
224
|
-
_context.
|
|
223
|
+
_context.n = 2;
|
|
225
224
|
return canvasRepository.getActiveCanvas().fromObject(canvasData);
|
|
226
|
-
case
|
|
225
|
+
case 2:
|
|
227
226
|
console.log('canvas loaded!');
|
|
228
|
-
case
|
|
229
|
-
_context.
|
|
227
|
+
case 3:
|
|
228
|
+
_context.n = 5;
|
|
230
229
|
break;
|
|
231
|
-
case
|
|
232
|
-
_context.
|
|
233
|
-
|
|
234
|
-
console.error(
|
|
230
|
+
case 4:
|
|
231
|
+
_context.p = 4;
|
|
232
|
+
_t = _context.v;
|
|
233
|
+
console.error(_t);
|
|
235
234
|
alert('Could not load data!');
|
|
236
|
-
case
|
|
237
|
-
|
|
238
|
-
return _context.stop();
|
|
235
|
+
case 5:
|
|
236
|
+
return _context.a(2);
|
|
239
237
|
}
|
|
240
|
-
}, _callee, null, [[1,
|
|
238
|
+
}, _callee, null, [[1, 4]]);
|
|
241
239
|
})));
|
|
242
|
-
_defineProperty(
|
|
240
|
+
_defineProperty(_this, "setFontSizeMin", function () {
|
|
243
241
|
return (0, _FontSizeMin.applyFontSizeMin)(canvasRepository.getActiveCanvas(), 20);
|
|
244
242
|
});
|
|
245
|
-
_defineProperty(
|
|
243
|
+
_defineProperty(_this, "clearCanvas", function () {
|
|
246
244
|
return canvasRepository.getActiveCanvas().clear();
|
|
247
245
|
});
|
|
248
|
-
_defineProperty(
|
|
246
|
+
_defineProperty(_this, "switchCanvas", function (_ref5) {
|
|
249
247
|
var value = _ref5.target.value;
|
|
250
248
|
_this.setState({
|
|
251
249
|
canvasInstance: canvasRepository.requestCanvas(value, canvases[value])
|
|
252
250
|
});
|
|
253
251
|
});
|
|
254
|
-
_defineProperty(
|
|
252
|
+
_defineProperty(_this, "screenshotToConsole", /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2() {
|
|
255
253
|
var screenshot;
|
|
256
|
-
return
|
|
257
|
-
while (1) switch (_context2.
|
|
254
|
+
return _regenerator().w(function (_context2) {
|
|
255
|
+
while (1) switch (_context2.n) {
|
|
258
256
|
case 0:
|
|
259
257
|
console.time('screenshot');
|
|
260
|
-
_context2.
|
|
258
|
+
_context2.n = 1;
|
|
261
259
|
return canvasRepository.getActiveCanvas().getScreenshot(fontToFileMap);
|
|
262
|
-
case
|
|
263
|
-
screenshot = _context2.
|
|
260
|
+
case 1:
|
|
261
|
+
screenshot = _context2.v;
|
|
264
262
|
console.log('Screenshot:', "data:image/svg+xml;base64,".concat(btoa(screenshot)));
|
|
265
263
|
console.timeEnd('screenshot');
|
|
266
|
-
case
|
|
267
|
-
|
|
268
|
-
return _context2.stop();
|
|
264
|
+
case 2:
|
|
265
|
+
return _context2.a(2);
|
|
269
266
|
}
|
|
270
267
|
}, _callee2);
|
|
271
268
|
})));
|
|
272
|
-
_defineProperty(
|
|
269
|
+
_defineProperty(_this, "screenshotsToConsole", /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee3() {
|
|
273
270
|
var elements;
|
|
274
|
-
return
|
|
275
|
-
while (1) switch (_context3.
|
|
271
|
+
return _regenerator().w(function (_context3) {
|
|
272
|
+
while (1) switch (_context3.n) {
|
|
276
273
|
case 0:
|
|
277
|
-
_context3.
|
|
274
|
+
_context3.n = 1;
|
|
278
275
|
return canvasRepository.getActiveCanvas().getScreenshotsOfElements(fontToFileMap);
|
|
279
|
-
case
|
|
280
|
-
elements = _context3.
|
|
276
|
+
case 1:
|
|
277
|
+
elements = _context3.v;
|
|
281
278
|
console.log(elements);
|
|
282
|
-
case
|
|
283
|
-
|
|
284
|
-
return _context3.stop();
|
|
279
|
+
case 2:
|
|
280
|
+
return _context3.a(2);
|
|
285
281
|
}
|
|
286
282
|
}, _callee3);
|
|
287
283
|
})));
|
|
288
|
-
_defineProperty(
|
|
284
|
+
_defineProperty(_this, "onMaskSelected", /*#__PURE__*/function () {
|
|
289
285
|
var _ref8 = _asyncToGenerator(function (_ref9) {
|
|
290
286
|
var value = _ref9.target.value;
|
|
291
|
-
return /*#__PURE__*/
|
|
287
|
+
return /*#__PURE__*/_regenerator().m(function _callee4() {
|
|
292
288
|
var maskData, maskHandler;
|
|
293
|
-
return
|
|
294
|
-
while (1) switch (_context4.
|
|
289
|
+
return _regenerator().w(function (_context4) {
|
|
290
|
+
while (1) switch (_context4.n) {
|
|
295
291
|
case 0:
|
|
296
292
|
if (!value) {
|
|
297
|
-
_context4.
|
|
293
|
+
_context4.n = 2;
|
|
298
294
|
break;
|
|
299
295
|
}
|
|
300
|
-
maskData = maskDataSamples.filter(function (
|
|
301
|
-
var id =
|
|
296
|
+
maskData = maskDataSamples.filter(function (_ref0) {
|
|
297
|
+
var id = _ref0.id;
|
|
302
298
|
return id === value;
|
|
303
299
|
})[0];
|
|
304
|
-
_context4.
|
|
300
|
+
_context4.n = 1;
|
|
305
301
|
return canvasRepository.getActiveCanvas().useMask(maskData);
|
|
306
|
-
case
|
|
307
|
-
_context4.
|
|
302
|
+
case 1:
|
|
303
|
+
_context4.n = 3;
|
|
308
304
|
break;
|
|
309
|
-
case
|
|
305
|
+
case 2:
|
|
310
306
|
maskHandler = canvasRepository.getActiveCanvas().getMaskHandler();
|
|
311
307
|
maskHandler && maskHandler.dispose();
|
|
312
|
-
case
|
|
313
|
-
|
|
314
|
-
return _context4.stop();
|
|
308
|
+
case 3:
|
|
309
|
+
return _context4.a(2);
|
|
315
310
|
}
|
|
316
311
|
}, _callee4);
|
|
317
312
|
})();
|
|
@@ -322,7 +317,8 @@ var App = /*#__PURE__*/function (_React$Component) {
|
|
|
322
317
|
}());
|
|
323
318
|
return _this;
|
|
324
319
|
}
|
|
325
|
-
|
|
320
|
+
_inherits(App, _React$Component);
|
|
321
|
+
return _createClass(App, [{
|
|
326
322
|
key: "render",
|
|
327
323
|
value: function render() {
|
|
328
324
|
return /*#__PURE__*/_react["default"].createElement(_CanvasProvider.CanvasProvider, {
|
|
@@ -374,6 +370,5 @@ var App = /*#__PURE__*/function (_React$Component) {
|
|
|
374
370
|
}))));
|
|
375
371
|
}
|
|
376
372
|
}]);
|
|
377
|
-
return App;
|
|
378
373
|
}(_react["default"].Component);
|
|
379
374
|
var _default = exports["default"] = App;
|
|
@@ -11,33 +11,33 @@ var _Image = require("./Objects/Image");
|
|
|
11
11
|
var _Text = require("./Objects/Text");
|
|
12
12
|
var _Logger = _interopRequireDefault(require("../../Utils/Logger"));
|
|
13
13
|
var _excluded = ["type"];
|
|
14
|
-
function _interopRequireDefault(
|
|
15
|
-
function _objectWithoutProperties(
|
|
16
|
-
function _objectWithoutPropertiesLoose(
|
|
17
|
-
function
|
|
18
|
-
function
|
|
19
|
-
function
|
|
20
|
-
function
|
|
21
|
-
function
|
|
22
|
-
function
|
|
23
|
-
function
|
|
24
|
-
function
|
|
25
|
-
function
|
|
26
|
-
function
|
|
27
|
-
function
|
|
28
|
-
function
|
|
29
|
-
function
|
|
30
|
-
function
|
|
31
|
-
function
|
|
14
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
|
|
15
|
+
function _objectWithoutProperties(e, t) { if (null == e) return {}; var o, r, i = _objectWithoutPropertiesLoose(e, t); if (Object.getOwnPropertySymbols) { var n = Object.getOwnPropertySymbols(e); for (r = 0; r < n.length; r++) o = n[r], -1 === t.indexOf(o) && {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]); } return i; }
|
|
16
|
+
function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (-1 !== e.indexOf(n)) continue; t[n] = r[n]; } return t; }
|
|
17
|
+
function _regenerator() { /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/babel/babel/blob/main/packages/babel-helpers/LICENSE */ var e, t, r = "function" == typeof Symbol ? Symbol : {}, n = r.iterator || "@@iterator", o = r.toStringTag || "@@toStringTag"; function i(r, n, o, i) { var c = n && n.prototype instanceof Generator ? n : Generator, u = Object.create(c.prototype); return _regeneratorDefine2(u, "_invoke", function (r, n, o) { var i, c, u, f = 0, p = o || [], y = !1, G = { p: 0, n: 0, v: e, a: d, f: d.bind(e, 4), d: function d(t, r) { return i = t, c = 0, u = e, G.n = r, a; } }; function d(r, n) { for (c = r, u = n, t = 0; !y && f && !o && t < p.length; t++) { var o, i = p[t], d = G.p, l = i[2]; r > 3 ? (o = l === n) && (u = i[(c = i[4]) ? 5 : (c = 3, 3)], i[4] = i[5] = e) : i[0] <= d && ((o = r < 2 && d < i[1]) ? (c = 0, G.v = n, G.n = i[1]) : d < l && (o = r < 3 || i[0] > n || n > l) && (i[4] = r, i[5] = n, G.n = l, c = 0)); } if (o || r > 1) return a; throw y = !0, n; } return function (o, p, l) { if (f > 1) throw TypeError("Generator is already running"); for (y && 1 === p && d(p, l), c = p, u = l; (t = c < 2 ? e : u) || !y;) { i || (c ? c < 3 ? (c > 1 && (G.n = -1), d(c, u)) : G.n = u : G.v = u); try { if (f = 2, i) { if (c || (o = "next"), t = i[o]) { if (!(t = t.call(i, u))) throw TypeError("iterator result is not an object"); if (!t.done) return t; u = t.value, c < 2 && (c = 0); } else 1 === c && (t = i["return"]) && t.call(i), c < 2 && (u = TypeError("The iterator does not provide a '" + o + "' method"), c = 1); i = e; } else if ((t = (y = G.n < 0) ? u : r.call(n, G)) !== a) break; } catch (t) { i = e, c = 1, u = t; } finally { f = 1; } } return { value: t, done: y }; }; }(r, o, i), !0), u; } var a = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} t = Object.getPrototypeOf; var c = [][n] ? t(t([][n]())) : (_regeneratorDefine2(t = {}, n, function () { return this; }), t), u = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(c); function f(e) { return Object.setPrototypeOf ? Object.setPrototypeOf(e, GeneratorFunctionPrototype) : (e.__proto__ = GeneratorFunctionPrototype, _regeneratorDefine2(e, o, "GeneratorFunction")), e.prototype = Object.create(u), e; } return GeneratorFunction.prototype = GeneratorFunctionPrototype, _regeneratorDefine2(u, "constructor", GeneratorFunctionPrototype), _regeneratorDefine2(GeneratorFunctionPrototype, "constructor", GeneratorFunction), GeneratorFunction.displayName = "GeneratorFunction", _regeneratorDefine2(GeneratorFunctionPrototype, o, "GeneratorFunction"), _regeneratorDefine2(u), _regeneratorDefine2(u, o, "Generator"), _regeneratorDefine2(u, n, function () { return this; }), _regeneratorDefine2(u, "toString", function () { return "[object Generator]"; }), (_regenerator = function _regenerator() { return { w: i, m: f }; })(); }
|
|
18
|
+
function _regeneratorDefine2(e, r, n, t) { var i = Object.defineProperty; try { i({}, "", {}); } catch (e) { i = 0; } _regeneratorDefine2 = function _regeneratorDefine(e, r, n, t) { function o(r, n) { _regeneratorDefine2(e, r, function (e) { return this._invoke(r, n, e); }); } r ? i ? i(e, r, { value: n, enumerable: !t, configurable: !t, writable: !t }) : e[r] = n : (o("next", 0), o("throw", 1), o("return", 2)); }, _regeneratorDefine2(e, r, n, t); }
|
|
19
|
+
function asyncGeneratorStep(n, t, e, r, o, a, c) { try { var i = n[a](c), u = i.value; } catch (n) { return void e(n); } i.done ? t(u) : Promise.resolve(u).then(r, o); }
|
|
20
|
+
function _asyncToGenerator(n) { return function () { var t = this, e = arguments; return new Promise(function (r, o) { var a = n.apply(t, e); function _next(n) { asyncGeneratorStep(a, r, o, _next, _throw, "next", n); } function _throw(n) { asyncGeneratorStep(a, r, o, _next, _throw, "throw", n); } _next(void 0); }); }; }
|
|
21
|
+
function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); }
|
|
22
|
+
function _defineProperties(e, r) { for (var t = 0; t < r.length; t++) { var o = r[t]; o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, _toPropertyKey(o.key), o); } }
|
|
23
|
+
function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; }
|
|
24
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
|
|
25
|
+
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
26
|
+
function _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); }
|
|
27
|
+
function _possibleConstructorReturn(t, e) { if (e && ("object" == _typeof(e) || "function" == typeof e)) return e; if (void 0 !== e) throw new TypeError("Derived constructors may only return object or undefined"); return _assertThisInitialized(t); }
|
|
28
|
+
function _assertThisInitialized(e) { if (void 0 === e) throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); return e; }
|
|
29
|
+
function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
|
|
30
|
+
function _getPrototypeOf(t) { return _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function (t) { return t.__proto__ || Object.getPrototypeOf(t); }, _getPrototypeOf(t); }
|
|
31
|
+
function _inherits(t, e) { if ("function" != typeof e && null !== e) throw new TypeError("Super expression must either be null or a function"); t.prototype = Object.create(e && e.prototype, { constructor: { value: t, writable: !0, configurable: !0 } }), Object.defineProperty(t, "prototype", { writable: !1 }), e && _setPrototypeOf(t, e); }
|
|
32
|
+
function _setPrototypeOf(t, e) { return _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function (t, e) { return t.__proto__ = e, t; }, _setPrototypeOf(t, e); }
|
|
32
33
|
var logger = new _Logger["default"]('Canvas');
|
|
33
34
|
var Canvas = exports.Canvas = /*#__PURE__*/function (_AbstractCanvas) {
|
|
34
|
-
_inherits(Canvas, _AbstractCanvas);
|
|
35
|
-
var _super = _createSuper(Canvas);
|
|
36
35
|
function Canvas() {
|
|
37
36
|
_classCallCheck(this, Canvas);
|
|
38
|
-
return
|
|
37
|
+
return _callSuper(this, Canvas, arguments);
|
|
39
38
|
}
|
|
40
|
-
|
|
39
|
+
_inherits(Canvas, _AbstractCanvas);
|
|
40
|
+
return _createClass(Canvas, [{
|
|
41
41
|
key: "addText",
|
|
42
42
|
value: function addText(options) {
|
|
43
43
|
var text = new _Text.Text(options);
|
|
@@ -47,26 +47,23 @@ var Canvas = exports.Canvas = /*#__PURE__*/function (_AbstractCanvas) {
|
|
|
47
47
|
}, {
|
|
48
48
|
key: "addImage",
|
|
49
49
|
value: function () {
|
|
50
|
-
var _addImage = _asyncToGenerator(
|
|
50
|
+
var _addImage = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(options) {
|
|
51
51
|
var src, image;
|
|
52
|
-
return
|
|
53
|
-
while (1) switch (_context.
|
|
52
|
+
return _regenerator().w(function (_context) {
|
|
53
|
+
while (1) switch (_context.n) {
|
|
54
54
|
case 0:
|
|
55
55
|
src = options.src;
|
|
56
56
|
image = new _Image.Image(options);
|
|
57
57
|
if (!src) {
|
|
58
|
-
_context.
|
|
58
|
+
_context.n = 1;
|
|
59
59
|
break;
|
|
60
60
|
}
|
|
61
|
-
_context.
|
|
61
|
+
_context.n = 1;
|
|
62
62
|
return image.loadFromURL(src);
|
|
63
|
-
case
|
|
63
|
+
case 1:
|
|
64
64
|
this.add(image);
|
|
65
65
|
logger.log('Image has been added.', image);
|
|
66
|
-
return _context.
|
|
67
|
-
case 8:
|
|
68
|
-
case "end":
|
|
69
|
-
return _context.stop();
|
|
66
|
+
return _context.a(2, image);
|
|
70
67
|
}
|
|
71
68
|
}, _callee, this);
|
|
72
69
|
}));
|
|
@@ -78,26 +75,23 @@ var Canvas = exports.Canvas = /*#__PURE__*/function (_AbstractCanvas) {
|
|
|
78
75
|
}, {
|
|
79
76
|
key: "addGroup",
|
|
80
77
|
value: function () {
|
|
81
|
-
var _addGroup = _asyncToGenerator(
|
|
78
|
+
var _addGroup = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2(options) {
|
|
82
79
|
var src, group;
|
|
83
|
-
return
|
|
84
|
-
while (1) switch (_context2.
|
|
80
|
+
return _regenerator().w(function (_context2) {
|
|
81
|
+
while (1) switch (_context2.n) {
|
|
85
82
|
case 0:
|
|
86
83
|
src = options.src;
|
|
87
84
|
group = new _Group.Group(options);
|
|
88
85
|
if (!src) {
|
|
89
|
-
_context2.
|
|
86
|
+
_context2.n = 1;
|
|
90
87
|
break;
|
|
91
88
|
}
|
|
92
|
-
_context2.
|
|
89
|
+
_context2.n = 1;
|
|
93
90
|
return group.loadFromURL(src);
|
|
94
|
-
case
|
|
91
|
+
case 1:
|
|
95
92
|
this.add(group);
|
|
96
93
|
logger.log('Group has been added.', group);
|
|
97
|
-
return _context2.
|
|
98
|
-
case 8:
|
|
99
|
-
case "end":
|
|
100
|
-
return _context2.stop();
|
|
94
|
+
return _context2.a(2, group);
|
|
101
95
|
}
|
|
102
96
|
}, _callee2, this);
|
|
103
97
|
}));
|
|
@@ -109,30 +103,29 @@ var Canvas = exports.Canvas = /*#__PURE__*/function (_AbstractCanvas) {
|
|
|
109
103
|
}, {
|
|
110
104
|
key: "addItemFromObject",
|
|
111
105
|
value: function () {
|
|
112
|
-
var _addItemFromObject = _asyncToGenerator(
|
|
113
|
-
var type, props;
|
|
114
|
-
return
|
|
115
|
-
while (1) switch (_context3.
|
|
106
|
+
var _addItemFromObject = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee3(options) {
|
|
107
|
+
var type, props, _t;
|
|
108
|
+
return _regenerator().w(function (_context3) {
|
|
109
|
+
while (1) switch (_context3.n) {
|
|
116
110
|
case 0:
|
|
117
111
|
type = options.type, props = _objectWithoutProperties(options, _excluded);
|
|
118
|
-
|
|
119
|
-
_context3.
|
|
112
|
+
_t = type;
|
|
113
|
+
_context3.n = _t === 'Image' ? 1 : _t === 'Group' ? 3 : _t === 'Text' ? 5 : 6;
|
|
120
114
|
break;
|
|
121
|
-
case
|
|
122
|
-
_context3.
|
|
115
|
+
case 1:
|
|
116
|
+
_context3.n = 2;
|
|
123
117
|
return this.addImage(props);
|
|
124
|
-
case
|
|
125
|
-
return _context3.
|
|
126
|
-
case
|
|
127
|
-
_context3.
|
|
118
|
+
case 2:
|
|
119
|
+
return _context3.a(2, _context3.v);
|
|
120
|
+
case 3:
|
|
121
|
+
_context3.n = 4;
|
|
128
122
|
return this.addGroup(props);
|
|
129
|
-
case
|
|
130
|
-
return _context3.
|
|
131
|
-
case
|
|
132
|
-
return _context3.
|
|
133
|
-
case
|
|
134
|
-
|
|
135
|
-
return _context3.stop();
|
|
123
|
+
case 4:
|
|
124
|
+
return _context3.a(2, _context3.v);
|
|
125
|
+
case 5:
|
|
126
|
+
return _context3.a(2, this.addText(props));
|
|
127
|
+
case 6:
|
|
128
|
+
return _context3.a(2);
|
|
136
129
|
}
|
|
137
130
|
}, _callee3, this);
|
|
138
131
|
}));
|
|
@@ -142,5 +135,4 @@ var Canvas = exports.Canvas = /*#__PURE__*/function (_AbstractCanvas) {
|
|
|
142
135
|
return addItemFromObject;
|
|
143
136
|
}()
|
|
144
137
|
}]);
|
|
145
|
-
return Canvas;
|
|
146
138
|
}(_Canvas.AbstractCanvas);
|