redhotmagma-graphics-editor 1.51.1 → 1.51.3

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 (50) hide show
  1. package/App.js +76 -81
  2. package/CanvasAdapters/Mock/Canvas.js +54 -62
  3. package/CanvasAdapters/Mock/Objects/CanvasObject.js +15 -17
  4. package/CanvasAdapters/Mock/Objects/Group.js +21 -23
  5. package/CanvasAdapters/Mock/Objects/Image.js +21 -23
  6. package/CanvasAdapters/Mock/Objects/Text.js +22 -24
  7. package/CanvasAdapters/PaperJs/Canvas.js +144 -164
  8. package/CanvasAdapters/PaperJs/Objects/CanvasObject.js +24 -25
  9. package/CanvasAdapters/PaperJs/Objects/Group.js +22 -24
  10. package/CanvasAdapters/PaperJs/Objects/Image.js +56 -62
  11. package/CanvasAdapters/PaperJs/Objects/Text.js +35 -36
  12. package/CanvasAdapters/PaperJs/Utils/HTML2Paper.js +11 -12
  13. package/CanvasAdapters/PaperJs/Utils/SVGfix.js +5 -5
  14. package/CanvasAdapters/PaperJs/Utils/StyleParams.js +3 -3
  15. package/CanvasAdapters/PaperJs/Utils/TextToSVGRepository.js +26 -27
  16. package/CanvasAdapters/PaperJs/Utils/UseColorLayer.js +1 -1
  17. package/CanvasAdapters/PaperJs/Utils/UseMask.js +49 -55
  18. package/CanvasInterface/Canvas.js +56 -61
  19. package/CanvasInterface/CanvasProvider.js +22 -24
  20. package/CanvasInterface/Objects/CanvasObject.js +16 -19
  21. package/CanvasInterface/Observable.js +10 -11
  22. package/CanvasInterface/canvasConnect.js +21 -23
  23. package/CanvasInterface/index.js +1 -2
  24. package/Components/Canvas/Canvas.js +20 -22
  25. package/Components/Canvas/CanvasContainer.js +1 -1
  26. package/Components/DelayedContainer.js +19 -21
  27. package/Components/Editor/Editor.js +19 -20
  28. package/Components/Editor/EditorContainer.js +30 -32
  29. package/Components/InlineToolbox/InlineToolbox.js +40 -42
  30. package/Components/InlineToolbox/InlineToolboxButton.js +7 -7
  31. package/Components/ManipulableContainer.js +20 -22
  32. package/Components/ResizeDetect/ResizeDetect.js +20 -22
  33. package/Components/Rulers/Ruler.js +22 -25
  34. package/Components/Rulers/Rulers.js +17 -19
  35. package/Components/SelectionToolbox/ColorPalette.js +20 -23
  36. package/Components/SelectionToolbox/SelectionToolbox.js +25 -26
  37. package/Components/SelectionToolbox/TextTools.js +29 -31
  38. package/Components/StandardToolbox/StandardToolbox.js +63 -65
  39. package/Components/TextEditor/TextEditor.js +39 -41
  40. package/Components/TextEditor/TextEditorStateProvider.js +19 -21
  41. package/Components/Toolbox/ToolboxContainer.js +4 -4
  42. package/Components/Toolbox/ToolboxRow.js +4 -4
  43. package/Utils/DOM.js +7 -7
  44. package/Utils/Device.js +1 -1
  45. package/Utils/Logger.js +7 -8
  46. package/Utils/Range.js +1 -1
  47. package/_demos/UsingExternalControls/App.js +18 -20
  48. package/_demos/UsingRenderProps/App.js +21 -23
  49. package/index.js +4 -2
  50. package/package.json +1 -1
@@ -1,6 +1,5 @@
1
1
  "use strict";
2
2
 
3
- function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
4
3
  Object.defineProperty(exports, "__esModule", {
5
4
  value: true
6
5
  });
@@ -10,17 +9,18 @@ var _isEqual = _interopRequireDefault(require("lodash/isEqual"));
10
9
  var _Logger = _interopRequireDefault(require("../../../Utils/Logger"));
11
10
  var _SVGfix = require("./SVGfix");
12
11
  var _DOM = require("../../../Utils/DOM");
13
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
14
- function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = "function" == typeof Symbol ? Symbol : {}, a = i.iterator || "@@iterator", c = i.asyncIterator || "@@asyncIterator", u = i.toStringTag || "@@toStringTag"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, ""); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, "_invoke", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: "normal", arg: t.call(e, r) }; } catch (t) { return { type: "throw", arg: t }; } } e.wrap = wrap; var h = "suspendedStart", l = "suspendedYield", f = "executing", s = "completed", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { ["next", "throw", "return"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if ("throw" !== c.type) { var u = c.arg, h = u.value; return h && "object" == _typeof(h) && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) { invoke("next", t, i, a); }, function (t) { invoke("throw", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke("throw", t, i, a); }); } a(c.arg); } var r; o(this, "_invoke", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error("Generator is already running"); if (o === s) { if ("throw" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else "return" === n.method && n.abrupt("return", n.arg); o = f; var p = tryCatch(e, r, n); if ("normal" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } "throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, "throw" === n && e.iterator["return"] && (r.method = "return", r.arg = t, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y; var i = tryCatch(o, e.iterator, r.arg); if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = "normal", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: "root" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || "" === e) { var r = e[a]; if (r) return r.call(e); if ("function" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + " is not iterable"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) { var e = "function" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () { return this; }), define(g, "toString", function () { return "[object Generator]"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if ("throw" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if ("root" === i.tryLoc) return handle("end"); if (i.tryLoc <= this.prev) { var c = n.call(i, "catchLoc"), u = n.call(i, "finallyLoc"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error("try statement without catch or finally"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) { var i = o; break; } } i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if ("throw" === t.type) throw t.arg; return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, "catch": function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if ("throw" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, "next" === this.method && (this.arg = t), y; } }, e; }
15
- function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
16
- function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
17
- function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it["return"] != null) it["return"](); } finally { if (didErr) throw err; } } }; }
18
- function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
12
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
13
+ 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 }; })(); }
14
+ 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); }
15
+ 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); }
16
+ 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); }); }; }
17
+ function _createForOfIteratorHelper(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (!t) { if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e && r && "number" == typeof r.length) { t && (r = t); var _n = 0, F = function F() {}; return { s: F, n: function n() { return _n >= r.length ? { done: !0 } : { done: !1, value: r[_n++] }; }, e: function e(r) { throw r; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var o, a = !0, u = !1; return { s: function s() { t = t.call(r); }, n: function n() { var r = t.next(); return a = r.done, r; }, e: function e(r) { u = !0, o = r; }, f: function f() { try { a || null == t["return"] || t["return"](); } finally { if (u) throw o; } } }; }
18
+ function _toConsumableArray(r) { return _arrayWithoutHoles(r) || _iterableToArray(r) || _unsupportedIterableToArray(r) || _nonIterableSpread(); }
19
19
  function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
20
- function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
21
- function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
22
- function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
23
- function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
20
+ function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
21
+ function _iterableToArray(r) { if ("undefined" != typeof Symbol && null != r[Symbol.iterator] || null != r["@@iterator"]) return Array.from(r); }
22
+ function _arrayWithoutHoles(r) { if (Array.isArray(r)) return _arrayLikeToArray(r); }
23
+ function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
24
24
  var logger = new _Logger["default"]('UseMask');
25
25
  var loadMask = function loadMask(src) {
26
26
  return new Promise(function (resolve, reject) {
@@ -36,7 +36,6 @@ var loadMask = function loadMask(src) {
36
36
  group.setClipped(false);
37
37
  group.firstChild.remove(); // the clip mask is always the first child
38
38
  }
39
-
40
39
  resolve(group);
41
40
  },
42
41
  onError: function onError(e) {
@@ -66,7 +65,7 @@ var addClipGroup = exports.addClipGroup = function addClipGroup(project, maskIte
66
65
  project.layers.designerLayer.insertChild(0, clipItem);
67
66
  project.layers.designerLayer.clipped = true;
68
67
  };
69
- var traverseItems = function traverseItems(item, cb) {
68
+ var _traverseItems = function traverseItems(item, cb) {
70
69
  if (false === cb(item)) {
71
70
  return;
72
71
  }
@@ -77,7 +76,7 @@ var traverseItems = function traverseItems(item, cb) {
77
76
  try {
78
77
  for (_iterator.s(); !(_step = _iterator.n()).done;) {
79
78
  var child = _step.value;
80
- traverseItems(child, cb);
79
+ _traverseItems(child, cb);
81
80
  }
82
81
  } catch (err) {
83
82
  _iterator.e(err);
@@ -88,7 +87,7 @@ var traverseItems = function traverseItems(item, cb) {
88
87
  };
89
88
  var prepareMaskObjects = exports.prepareMaskObjects = function prepareMaskObjects(maskItem) {
90
89
  var paths = [];
91
- traverseItems(maskItem, function (item) {
90
+ _traverseItems(maskItem, function (item) {
92
91
  if (item instanceof _paper["default"].Path || item instanceof _paper["default"].CompoundPath) {
93
92
  paths.push(item);
94
93
  return false;
@@ -140,39 +139,38 @@ var addOutlineLayer = exports.addOutlineLayer = function addOutlineLayer(project
140
139
  return layer;
141
140
  };
142
141
  var loadMaskSVG = /*#__PURE__*/function () {
143
- var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(svg) {
142
+ var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(svg) {
144
143
  var blob, url;
145
- return _regeneratorRuntime().wrap(function _callee$(_context) {
146
- while (1) switch (_context.prev = _context.next) {
144
+ return _regenerator().w(function (_context) {
145
+ while (1) switch (_context.p = _context.n) {
147
146
  case 0:
148
147
  blob = new Blob([svg], {
149
148
  type: 'image/svg+xml'
150
149
  });
151
150
  url = URL.createObjectURL(blob);
152
- _context.prev = 2;
153
- _context.next = 5;
151
+ _context.p = 1;
152
+ _context.n = 2;
154
153
  return loadMask(url);
155
- case 5:
156
- return _context.abrupt("return", _context.sent);
157
- case 6:
158
- _context.prev = 6;
154
+ case 2:
155
+ return _context.a(2, _context.v);
156
+ case 3:
157
+ _context.p = 3;
159
158
  URL.revokeObjectURL(url);
160
- return _context.finish(6);
161
- case 9:
162
- case "end":
163
- return _context.stop();
159
+ return _context.f(3);
160
+ case 4:
161
+ return _context.a(2);
164
162
  }
165
- }, _callee, null, [[2,, 6, 9]]);
163
+ }, _callee, null, [[1,, 3, 4]]);
166
164
  }));
167
165
  return function loadMaskSVG(_x) {
168
166
  return _ref.apply(this, arguments);
169
167
  };
170
168
  }();
171
169
  var useMask = exports.useMask = /*#__PURE__*/function () {
172
- var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(project, initialMaskData) {
170
+ var _ref2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee3(project, initialMaskData) {
173
171
  var scaling, _maskData, _maskDataSVG, maskHandler, currentLayer, dispose, updateOutline, init, outlineLayer, toggleOutline, fixSVGExport;
174
- return _regeneratorRuntime().wrap(function _callee3$(_context3) {
175
- while (1) switch (_context3.prev = _context3.next) {
172
+ return _regenerator().w(function (_context3) {
173
+ while (1) switch (_context3.n) {
176
174
  case 0:
177
175
  _maskData = {};
178
176
  maskHandler = {}; // the layer that holds all the user items
@@ -215,31 +213,31 @@ var useMask = exports.useMask = /*#__PURE__*/function () {
215
213
  init = /*#__PURE__*/function () {
216
214
  var _ref3 = _asyncToGenerator(function () {
217
215
  var maskData = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
218
- return /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
216
+ return /*#__PURE__*/_regenerator().m(function _callee2() {
219
217
  var _project$layers2, designerLayer, outlineLayer, src, _maskData$outlineColo, outlineColor, _maskData$x, x, _maskData$y, y, _maskData$rotation, rotation, mask, _maskData$relativeSca, relativeScaling, position;
220
- return _regeneratorRuntime().wrap(function _callee2$(_context2) {
221
- while (1) switch (_context2.prev = _context2.next) {
218
+ return _regenerator().w(function (_context2) {
219
+ while (1) switch (_context2.n) {
222
220
  case 0:
223
221
  _project$layers2 = project.layers, designerLayer = _project$layers2.designerLayer, outlineLayer = _project$layers2.outlineLayer;
224
222
  if (!(0, _isEqual["default"])(maskData, _maskData)) {
225
- _context2.next = 4;
223
+ _context2.n = 1;
226
224
  break;
227
225
  }
228
226
  if (!(designerLayer.isClipped() && outlineLayer)) {
229
- _context2.next = 4;
227
+ _context2.n = 1;
230
228
  break;
231
229
  }
232
- return _context2.abrupt("return");
233
- case 4:
230
+ return _context2.a(2);
231
+ case 1:
234
232
  src = maskData.src, _maskData$outlineColo = maskData.outlineColor, outlineColor = _maskData$outlineColo === void 0 ? 'black' : _maskData$outlineColo, _maskData$x = maskData.x, x = _maskData$x === void 0 ? 0.5 : _maskData$x, _maskData$y = maskData.y, y = _maskData$y === void 0 ? 0.5 : _maskData$y, _maskData$rotation = maskData.rotation, rotation = _maskData$rotation === void 0 ? 0 : _maskData$rotation;
235
- _context2.next = 7;
233
+ _context2.n = 2;
236
234
  return loadMaskSource(src);
237
- case 7:
238
- _maskDataSVG = _context2.sent;
239
- _context2.next = 10;
235
+ case 2:
236
+ _maskDataSVG = _context2.v;
237
+ _context2.n = 3;
240
238
  return loadMaskSVG(_maskDataSVG);
241
- case 10:
242
- mask = _context2.sent;
239
+ case 3:
240
+ mask = _context2.v;
243
241
  _maskData$relativeSca = maskData.relativeScaling, relativeScaling = _maskData$relativeSca === void 0 ? false : _maskData$relativeSca;
244
242
  scaling = relativeScaling ? relativeScaling / (mask.boundsOrig.width / currentLayer.view.size.width) : maskData.scaling || 1;
245
243
  position = currentLayer.view.size.multiply(new _paper["default"].Point(x, y));
@@ -259,9 +257,8 @@ var useMask = exports.useMask = /*#__PURE__*/function () {
259
257
 
260
258
  // after all layers added, the first layer should be activated again
261
259
  currentLayer.activate();
262
- case 25:
263
- case "end":
264
- return _context2.stop();
260
+ case 4:
261
+ return _context2.a(2);
265
262
  }
266
263
  }, _callee2);
267
264
  })();
@@ -304,12 +301,12 @@ var useMask = exports.useMask = /*#__PURE__*/function () {
304
301
  }; // initialize automatically
305
302
  dispose(); // remove the current mask in every case
306
303
  if (!initialMaskData) {
307
- _context3.next = 13;
304
+ _context3.n = 1;
308
305
  break;
309
306
  }
310
- _context3.next = 13;
307
+ _context3.n = 1;
311
308
  return init(initialMaskData);
312
- case 13:
309
+ case 1:
313
310
  Object.assign(maskHandler, {
314
311
  init: init,
315
312
  toggleOutline: toggleOutline,
@@ -317,10 +314,7 @@ var useMask = exports.useMask = /*#__PURE__*/function () {
317
314
  fixSVGExport: fixSVGExport,
318
315
  dispose: dispose
319
316
  });
320
- return _context3.abrupt("return", maskHandler);
321
- case 15:
322
- case "end":
323
- return _context3.stop();
317
+ return _context3.a(2, maskHandler);
324
318
  }
325
319
  }, _callee3);
326
320
  }));
@@ -12,22 +12,24 @@ var _Image = require("../Utils/Image");
12
12
  var _UnitConversion = require("../Utils/UnitConversion");
13
13
  var _Device = require("../Utils/Device");
14
14
  var _Logger = _interopRequireDefault(require("../Utils/Logger"));
15
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
16
- function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = "function" == typeof Symbol ? Symbol : {}, a = i.iterator || "@@iterator", c = i.asyncIterator || "@@asyncIterator", u = i.toStringTag || "@@toStringTag"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, ""); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, "_invoke", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: "normal", arg: t.call(e, r) }; } catch (t) { return { type: "throw", arg: t }; } } e.wrap = wrap; var h = "suspendedStart", l = "suspendedYield", f = "executing", s = "completed", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { ["next", "throw", "return"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if ("throw" !== c.type) { var u = c.arg, h = u.value; return h && "object" == _typeof(h) && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) { invoke("next", t, i, a); }, function (t) { invoke("throw", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke("throw", t, i, a); }); } a(c.arg); } var r; o(this, "_invoke", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error("Generator is already running"); if (o === s) { if ("throw" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else "return" === n.method && n.abrupt("return", n.arg); o = f; var p = tryCatch(e, r, n); if ("normal" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } "throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, "throw" === n && e.iterator["return"] && (r.method = "return", r.arg = t, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y; var i = tryCatch(o, e.iterator, r.arg); if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = "normal", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: "root" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || "" === e) { var r = e[a]; if (r) return r.call(e); if ("function" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + " is not iterable"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) { var e = "function" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () { return this; }), define(g, "toString", function () { return "[object Generator]"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if ("throw" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if ("root" === i.tryLoc) return handle("end"); if (i.tryLoc <= this.prev) { var c = n.call(i, "catchLoc"), u = n.call(i, "finallyLoc"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error("try statement without catch or finally"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) { var i = o; break; } } i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if ("throw" === t.type) throw t.arg; return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, "catch": function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if ("throw" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, "next" === this.method && (this.arg = t), y; } }, e; }
17
- function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
18
- function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
15
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
16
+ function _regeneratorValues(e) { if (null != e) { var t = e["function" == typeof Symbol && Symbol.iterator || "@@iterator"], r = 0; if (t) return t.call(e); if ("function" == typeof e.next) return e; if (!isNaN(e.length)) return { next: function next() { return e && r >= e.length && (e = void 0), { value: e && e[r++], done: !e }; } }; } throw new TypeError(_typeof(e) + " is not iterable"); }
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); }); }; }
19
21
  function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
20
22
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
21
- function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it["return"] != null) it["return"](); } finally { if (didErr) throw err; } } }; }
22
- function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
23
- function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
23
+ function _createForOfIteratorHelper(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (!t) { if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e && r && "number" == typeof r.length) { t && (r = t); var _n = 0, F = function F() {}; return { s: F, n: function n() { return _n >= r.length ? { done: !0 } : { done: !1, value: r[_n++] }; }, e: function e(r) { throw r; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var o, a = !0, u = !1; return { s: function s() { t = t.call(r); }, n: function n() { var r = t.next(); return a = r.done, r; }, e: function e(r) { u = !0, o = r; }, f: function f() { try { a || null == t["return"] || t["return"](); } finally { if (u) throw o; } } }; }
24
+ function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
25
+ function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
24
26
  function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
25
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
26
- function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
27
- function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
28
- function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
29
- function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
30
- function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
27
+ function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); }
28
+ 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); } }
29
+ function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; }
30
+ 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; }
31
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
32
+ 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); }
31
33
  var logger = new _Logger["default"]('AbstractCanvas');
32
34
  var CanvasEvents = exports.CanvasEvents = /*#__PURE__*/function (CanvasEvents) {
33
35
  CanvasEvents["OnChange"] = "onChange";
@@ -69,7 +71,7 @@ var AbstractCanvas = exports.AbstractCanvas = /*#__PURE__*/function () {
69
71
  });
70
72
  }
71
73
  }
72
- _createClass(AbstractCanvas, [{
74
+ return _createClass(AbstractCanvas, [{
73
75
  key: "init",
74
76
  value: function init(canvasElement, options) {
75
77
  if (canvasElement instanceof HTMLCanvasElement) {
@@ -372,23 +374,23 @@ var AbstractCanvas = exports.AbstractCanvas = /*#__PURE__*/function () {
372
374
  }, {
373
375
  key: "updateFromObject",
374
376
  value: function () {
375
- var _updateFromObject = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(canvasObject) {
377
+ var _updateFromObject = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(canvasObject) {
376
378
  var _this3 = this;
377
379
  var objects, wait, _loop, i;
378
- return _regeneratorRuntime().wrap(function _callee$(_context2) {
379
- while (1) switch (_context2.prev = _context2.next) {
380
+ return _regenerator().w(function (_context2) {
381
+ while (1) switch (_context2.n) {
380
382
  case 0:
381
383
  this._objectEventsEnabled = false;
382
384
  objects = canvasObject.objects;
383
385
  wait = [];
384
386
  if (!(objects && objects.length > 0)) {
385
- _context2.next = 11;
387
+ _context2.n = 3;
386
388
  break;
387
389
  }
388
- _loop = /*#__PURE__*/_regeneratorRuntime().mark(function _loop() {
390
+ _loop = /*#__PURE__*/_regenerator().m(function _loop() {
389
391
  var rawObject, currentObject;
390
- return _regeneratorRuntime().wrap(function _loop$(_context) {
391
- while (1) switch (_context.prev = _context.next) {
392
+ return _regenerator().w(function (_context) {
393
+ while (1) switch (_context.n) {
392
394
  case 0:
393
395
  rawObject = objects[i];
394
396
  currentObject = _this3.objects.find(function (_ref4) {
@@ -400,32 +402,30 @@ var AbstractCanvas = exports.AbstractCanvas = /*#__PURE__*/function () {
400
402
  } else {
401
403
  logger.error('Object not found!', rawObject);
402
404
  }
403
- case 3:
404
- case "end":
405
- return _context.stop();
405
+ case 1:
406
+ return _context.a(2);
406
407
  }
407
408
  }, _loop);
408
409
  });
409
410
  i = 0;
410
- case 6:
411
+ case 1:
411
412
  if (!(i < objects.length)) {
412
- _context2.next = 11;
413
+ _context2.n = 3;
413
414
  break;
414
415
  }
415
- return _context2.delegateYield(_loop(), "t0", 8);
416
- case 8:
416
+ return _context2.d(_regeneratorValues(_loop()), 2);
417
+ case 2:
417
418
  i++;
418
- _context2.next = 6;
419
+ _context2.n = 1;
419
420
  break;
420
- case 11:
421
- _context2.next = 13;
421
+ case 3:
422
+ _context2.n = 4;
422
423
  return Promise.all(wait);
423
- case 13:
424
+ case 4:
424
425
  this._objectEventsEnabled = true;
425
426
  this._observable.triggerEvent(CanvasEvents.OnChange);
426
- case 15:
427
- case "end":
428
- return _context2.stop();
427
+ case 5:
428
+ return _context2.a(2);
429
429
  }
430
430
  }, _callee, this);
431
431
  }));
@@ -437,44 +437,43 @@ var AbstractCanvas = exports.AbstractCanvas = /*#__PURE__*/function () {
437
437
  }, {
438
438
  key: "fromObject",
439
439
  value: function () {
440
- var _fromObject = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(canvasObject) {
440
+ var _fromObject = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee3(canvasObject) {
441
441
  var _this, objects, wait, i, addedObjects;
442
- return _regeneratorRuntime().wrap(function _callee3$(_context4) {
443
- while (1) switch (_context4.prev = _context4.next) {
442
+ return _regenerator().w(function (_context4) {
443
+ while (1) switch (_context4.n) {
444
444
  case 0:
445
445
  if (this.canvasElement) {
446
- _context4.next = 3;
446
+ _context4.n = 1;
447
447
  break;
448
448
  }
449
449
  _this = this;
450
- return _context4.abrupt("return", new Promise(function (resolve) {
451
- _this._fromObject = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
450
+ return _context4.a(2, new Promise(function (resolve) {
451
+ _this._fromObject = /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2() {
452
452
  var result;
453
- return _regeneratorRuntime().wrap(function _callee2$(_context3) {
454
- while (1) switch (_context3.prev = _context3.next) {
453
+ return _regenerator().w(function (_context3) {
454
+ while (1) switch (_context3.n) {
455
455
  case 0:
456
456
  delete _this._fromObject;
457
- _context3.next = 3;
457
+ _context3.n = 1;
458
458
  return _this.fromObject(canvasObject);
459
- case 3:
460
- result = _context3.sent;
459
+ case 1:
460
+ result = _context3.v;
461
461
  resolve(result);
462
- case 5:
463
- case "end":
464
- return _context3.stop();
462
+ case 2:
463
+ return _context3.a(2);
465
464
  }
466
465
  }, _callee2);
467
466
  }));
468
467
  }));
469
- case 3:
468
+ case 1:
470
469
  this._objectEventsEnabled = false;
471
470
  this.clear();
472
471
  if (canvasObject) {
473
- _context4.next = 7;
472
+ _context4.n = 2;
474
473
  break;
475
474
  }
476
- return _context4.abrupt("return", Promise.resolve());
477
- case 7:
475
+ return _context4.a(2, Promise.resolve());
476
+ case 2:
478
477
  objects = canvasObject.objects;
479
478
  wait = [];
480
479
  if (objects && objects.length > 0) {
@@ -482,15 +481,12 @@ var AbstractCanvas = exports.AbstractCanvas = /*#__PURE__*/function () {
482
481
  wait.push(this.addItemFromObject(objects[i], i, true));
483
482
  }
484
483
  }
485
- _context4.next = 12;
484
+ _context4.n = 3;
486
485
  return Promise.all(wait);
487
- case 12:
488
- addedObjects = _context4.sent;
486
+ case 3:
487
+ addedObjects = _context4.v;
489
488
  this._objectEventsEnabled = true;
490
- return _context4.abrupt("return", addedObjects);
491
- case 15:
492
- case "end":
493
- return _context4.stop();
489
+ return _context4.a(2, addedObjects);
494
490
  }
495
491
  }, _callee3, this);
496
492
  }));
@@ -539,5 +535,4 @@ var AbstractCanvas = exports.AbstractCanvas = /*#__PURE__*/function () {
539
535
  //do nothing
540
536
  }
541
537
  }]);
542
- return AbstractCanvas;
543
538
  }();