redhotmagma-visualization 1.56.2 → 1.57.1
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/CommonUtils/Deferred.js +4 -2
- package/CommonUtils/Observable.js +20 -11
- package/CommonUtils/SyncCurrentFunction.js +26 -18
- package/CommonUtils/SyncObservableEvent.js +3 -3
- package/DevApp.js +84 -73
- package/PrintingEffects/EmbroideryEffect.js +98 -82
- package/PrintingEffects/PrintingEffects.js +24 -14
- package/React/ReactBase.js +14 -13
- package/Three/Exporters/glTFExporter.js +1 -0
- package/Three/Three2D.js +311 -281
- package/Three/Three2DLayers.js +106 -93
- package/Three/Three3D.js +214 -196
- package/Three/Three3DScene.js +231 -209
- package/Three/ThreeBase.js +56 -42
- package/Utils/TextureBuilder/createTextureBuilder.js +67 -58
- package/Utils/createImageRepository.js +50 -33
- package/Utils/imagePreloader.js +34 -22
- package/VisualizationContainer.js +13 -11
- package/VisualizationInterface.js +33 -24
- package/index.js +1 -1
- package/package.json +2 -2
- package/src/Utils/imagePreloader.js +5 -6
- package/visualizationAdapterCreator.js +2 -0
|
@@ -3,8 +3,15 @@ function _toConsumableArray(r) { return _arrayWithoutHoles(r) || _iterableToArra
|
|
|
3
3
|
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."); }
|
|
4
4
|
function _iterableToArray(r) { if ("undefined" != typeof Symbol && null != r[Symbol.iterator] || null != r["@@iterator"]) return Array.from(r); }
|
|
5
5
|
function _arrayWithoutHoles(r) { if (Array.isArray(r)) return _arrayLikeToArray(r); }
|
|
6
|
+
function _regeneratorRuntime() { "use strict"; var r = _regenerator(), e = r.m(_regeneratorRuntime), t = (Object.getPrototypeOf ? Object.getPrototypeOf(e) : e.__proto__).constructor; function n(r) { var e = "function" == typeof r && r.constructor; return !!e && (e === t || "GeneratorFunction" === (e.displayName || e.name)); } var o = { "throw": 1, "return": 2, "break": 3, "continue": 3 }; function a(r) { var e, t; return function (n) { e || (e = { stop: function stop() { return t(n.a, 2); }, "catch": function _catch() { return n.v; }, abrupt: function abrupt(r, e) { return t(n.a, o[r], e); }, delegateYield: function delegateYield(r, o, a) { return e.resultName = o, t(n.d, _regeneratorValues(r), a); }, finish: function finish(r) { return t(n.f, r); } }, t = function t(r, _t, o) { n.p = e.prev, n.n = e.next; try { return r(_t, o); } finally { e.next = n.n; } }), e.resultName && (e[e.resultName] = n.v, e.resultName = void 0), e.sent = n.v, e.next = n.n; try { return r.call(this, e); } finally { n.p = e.prev, n.n = e.next; } }; } return (_regeneratorRuntime = function _regeneratorRuntime() { return { wrap: function wrap(e, t, n, o) { return r.w(a(e), t, n, o && o.reverse()); }, isGeneratorFunction: n, mark: r.m, awrap: function awrap(r, e) { return new _OverloadYield(r, e); }, AsyncIterator: _regeneratorAsyncIterator, async: function async(r, e, t, o, u) { return (n(e) ? _regeneratorAsyncGen : _regeneratorAsync)(a(r), e, t, o, u); }, keys: _regeneratorKeys, values: _regeneratorValues }; })(); }
|
|
7
|
+
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"); }
|
|
8
|
+
function _regeneratorKeys(e) { var n = Object(e), r = []; for (var t in n) r.unshift(t); return function e() { for (; r.length;) if ((t = r.pop()) in n) return e.value = t, e.done = !1, e; return e.done = !0, e; }; }
|
|
9
|
+
function _regeneratorAsync(n, e, r, t, o) { var a = _regeneratorAsyncGen(n, e, r, t, o); return a.next().then(function (n) { return n.done ? n.value : a.next(); }); }
|
|
10
|
+
function _regeneratorAsyncGen(r, e, t, o, n) { return new _regeneratorAsyncIterator(_regenerator().w(r, e, t, o), n || Promise); }
|
|
11
|
+
function _regeneratorAsyncIterator(t, e) { function n(r, o, i, f) { try { var c = t[r](o), u = c.value; return u instanceof _OverloadYield ? e.resolve(u.v).then(function (t) { n("next", t, i, f); }, function (t) { n("throw", t, i, f); }) : e.resolve(u).then(function (t) { c.value = t, i(c); }, function (t) { return n("throw", t, i, f); }); } catch (t) { f(t); } } var r; this.next || (_regeneratorDefine2(_regeneratorAsyncIterator.prototype), _regeneratorDefine2(_regeneratorAsyncIterator.prototype, "function" == typeof Symbol && Symbol.asyncIterator || "@asyncIterator", function () { return this; })), _regeneratorDefine2(this, "_invoke", function (t, o, i) { function f() { return new e(function (e, r) { n(t, i, e, r); }); } return r = r ? r.then(f, f) : f(); }, !0); }
|
|
6
12
|
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 }; })(); }
|
|
7
13
|
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); }
|
|
14
|
+
function _OverloadYield(e, d) { this.v = e, this.k = d; }
|
|
8
15
|
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); }
|
|
9
16
|
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); }
|
|
10
17
|
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); }); }; }
|
|
@@ -58,7 +65,7 @@ var getPositionValues = function getPositionValues(node) {
|
|
|
58
65
|
var y = parseFloat(node.getAttribute("y")) || 0;
|
|
59
66
|
return [x, y];
|
|
60
67
|
};
|
|
61
|
-
var
|
|
68
|
+
var getWorldTransformValues = function getWorldTransformValues(node) {
|
|
62
69
|
var _node$parentNode;
|
|
63
70
|
var values = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {
|
|
64
71
|
translate: [0, 0],
|
|
@@ -80,23 +87,23 @@ var _getWorldTransformValues = function getWorldTransformValues(node) {
|
|
|
80
87
|
values.scale[1] *= sy;
|
|
81
88
|
values.rotate += r;
|
|
82
89
|
if ((_node$parentNode = node.parentNode) !== null && _node$parentNode !== void 0 && _node$parentNode.getAttribute) {
|
|
83
|
-
|
|
90
|
+
getWorldTransformValues(node.parentNode, values);
|
|
84
91
|
}
|
|
85
92
|
return values;
|
|
86
93
|
};
|
|
87
94
|
var getSizeValues = function getSizeValues(svgNode) {
|
|
88
95
|
return [parseFloat(svgNode.getAttribute("width")) || 0, parseFloat(svgNode.getAttribute("height")) || 0];
|
|
89
96
|
};
|
|
90
|
-
var
|
|
91
|
-
return node.parentNode ? node.parentNode === container ? node :
|
|
97
|
+
var findOutermostNode = function findOutermostNode(node, container) {
|
|
98
|
+
return node.parentNode ? node.parentNode === container ? node : findOutermostNode(node.parentNode, container) : node;
|
|
92
99
|
};
|
|
93
100
|
var svgToImg = /*#__PURE__*/function () {
|
|
94
|
-
var _ref = _asyncToGenerator(/*#__PURE__*/
|
|
101
|
+
var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(svgElement) {
|
|
95
102
|
var svgImg;
|
|
96
|
-
return
|
|
97
|
-
while (1) switch (_context.
|
|
103
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
104
|
+
while (1) switch (_context.prev = _context.next) {
|
|
98
105
|
case 0:
|
|
99
|
-
_context.
|
|
106
|
+
_context.next = 2;
|
|
100
107
|
return new Promise(function (resolve, reject) {
|
|
101
108
|
var img = document.createElement("img");
|
|
102
109
|
img.onload = function () {
|
|
@@ -107,9 +114,9 @@ var svgToImg = /*#__PURE__*/function () {
|
|
|
107
114
|
var svg64 = btoa(xml);
|
|
108
115
|
img.src = "data:image/svg+xml;base64," + svg64;
|
|
109
116
|
});
|
|
110
|
-
case
|
|
111
|
-
svgImg = _context.
|
|
112
|
-
_context.
|
|
117
|
+
case 2:
|
|
118
|
+
svgImg = _context.sent;
|
|
119
|
+
_context.next = 5;
|
|
113
120
|
return new Promise(function (resolve) {
|
|
114
121
|
setTimeout(function () {
|
|
115
122
|
// some browsers may have issues with applying effects on images with svg source
|
|
@@ -121,8 +128,11 @@ var svgToImg = /*#__PURE__*/function () {
|
|
|
121
128
|
resolve(svgCanvas);
|
|
122
129
|
});
|
|
123
130
|
});
|
|
124
|
-
case
|
|
125
|
-
return _context.
|
|
131
|
+
case 5:
|
|
132
|
+
return _context.abrupt("return", _context.sent);
|
|
133
|
+
case 6:
|
|
134
|
+
case "end":
|
|
135
|
+
return _context.stop();
|
|
126
136
|
}
|
|
127
137
|
}, _callee);
|
|
128
138
|
}));
|
|
@@ -131,15 +141,15 @@ var svgToImg = /*#__PURE__*/function () {
|
|
|
131
141
|
};
|
|
132
142
|
}();
|
|
133
143
|
var applyOnEmbeddedSvg = /*#__PURE__*/function () {
|
|
134
|
-
var _ref2 = _asyncToGenerator(/*#__PURE__*/
|
|
135
|
-
var _getSizeValues, _getSizeValues2, rootWidth, canvasWidth, svgToCanvasRatio, worldTransformValues, scaleX, scaleY, size, _createWorkingCanvas3, _createWorkingCanvas4, tmpCanvas, tmpCtx, svgAsString, svgDoc, svgElement, _worldTransformValues, wx, wy, _getPositionValues, _getPositionValues2, px, py, angle
|
|
136
|
-
return
|
|
137
|
-
while (1) switch (_context2.
|
|
144
|
+
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(imageNode, imageCanvas, ctx, rootSvgElement) {
|
|
145
|
+
var _getSizeValues, _getSizeValues2, rootWidth, canvasWidth, svgToCanvasRatio, worldTransformValues, scaleX, scaleY, size, _createWorkingCanvas3, _createWorkingCanvas4, tmpCanvas, tmpCtx, svgAsString, svgDoc, svgElement, _worldTransformValues, wx, wy, _getPositionValues, _getPositionValues2, px, py, angle;
|
|
146
|
+
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
147
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
138
148
|
case 0:
|
|
139
149
|
_getSizeValues = getSizeValues(rootSvgElement), _getSizeValues2 = _slicedToArray(_getSizeValues, 1), rootWidth = _getSizeValues2[0];
|
|
140
150
|
canvasWidth = imageCanvas.width;
|
|
141
151
|
svgToCanvasRatio = canvasWidth / rootWidth;
|
|
142
|
-
worldTransformValues =
|
|
152
|
+
worldTransformValues = getWorldTransformValues(imageNode);
|
|
143
153
|
scaleX = worldTransformValues.scale[0] * svgToCanvasRatio;
|
|
144
154
|
scaleY = worldTransformValues.scale[1] * svgToCanvasRatio;
|
|
145
155
|
size = {
|
|
@@ -147,13 +157,13 @@ var applyOnEmbeddedSvg = /*#__PURE__*/function () {
|
|
|
147
157
|
height: parseFloat(imageNode.getAttribute("height")) * scaleY
|
|
148
158
|
};
|
|
149
159
|
_createWorkingCanvas3 = createWorkingCanvas(size), _createWorkingCanvas4 = _slicedToArray(_createWorkingCanvas3, 2), tmpCanvas = _createWorkingCanvas4[0], tmpCtx = _createWorkingCanvas4[1];
|
|
150
|
-
_context2.
|
|
160
|
+
_context2.prev = 8;
|
|
151
161
|
svgAsString = window.atob(getImageSrc(imageNode).substring(SVG_DATA_URL_HDR.length));
|
|
152
162
|
svgDoc = new DOMParser().parseFromString(svgAsString, "image/svg+xml");
|
|
153
163
|
svgElement = svgDoc.getElementsByTagName("svg")[0];
|
|
154
|
-
_context2.
|
|
164
|
+
_context2.next = 14;
|
|
155
165
|
return Promise.all(Array.from(svgElement.childNodes).map(applyOnChildNode(tmpCanvas, tmpCtx, svgElement)));
|
|
156
|
-
case
|
|
166
|
+
case 14:
|
|
157
167
|
ctx.save();
|
|
158
168
|
|
|
159
169
|
// apply element transformations
|
|
@@ -165,17 +175,18 @@ var applyOnEmbeddedSvg = /*#__PURE__*/function () {
|
|
|
165
175
|
ctx.translate(px * scaleX, py * scaleY);
|
|
166
176
|
ctx.drawImage(tmpCanvas, 0, 0);
|
|
167
177
|
ctx.restore();
|
|
168
|
-
_context2.
|
|
178
|
+
_context2.next = 28;
|
|
169
179
|
break;
|
|
170
|
-
case
|
|
171
|
-
_context2.
|
|
172
|
-
|
|
180
|
+
case 25:
|
|
181
|
+
_context2.prev = 25;
|
|
182
|
+
_context2.t0 = _context2["catch"](8);
|
|
173
183
|
// eslint-disable-next-line no-console
|
|
174
|
-
console.error("Error during embedded svg image processing!",
|
|
175
|
-
case
|
|
176
|
-
|
|
184
|
+
console.error("Error during embedded svg image processing!", _context2.t0);
|
|
185
|
+
case 28:
|
|
186
|
+
case "end":
|
|
187
|
+
return _context2.stop();
|
|
177
188
|
}
|
|
178
|
-
}, _callee2, null, [[
|
|
189
|
+
}, _callee2, null, [[8, 25]]);
|
|
179
190
|
}));
|
|
180
191
|
return function applyOnEmbeddedSvg(_x2, _x3, _x4, _x5) {
|
|
181
192
|
return _ref2.apply(this, arguments);
|
|
@@ -186,41 +197,41 @@ var getImageSrc = function getImageSrc(imageNode) {
|
|
|
186
197
|
};
|
|
187
198
|
var applyOnChildNode = function applyOnChildNode(imageCanvas, ctx, svgElement) {
|
|
188
199
|
return /*#__PURE__*/function () {
|
|
189
|
-
var _ref3 = _asyncToGenerator(/*#__PURE__*/
|
|
200
|
+
var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(node) {
|
|
190
201
|
var partialSvg, img, rotation, _createWorkingCanvas5, _createWorkingCanvas6, multiplyPatternCanvas, multiplyPatternContext, patternSize, _createWorkingCanvas7, _createWorkingCanvas8, screenPatternCanvas, screenPatternContext, _createWorkingCanvas9, _createWorkingCanvas0, ocvs, octx;
|
|
191
|
-
return
|
|
192
|
-
while (1) switch (_context3.
|
|
202
|
+
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
|
203
|
+
while (1) switch (_context3.prev = _context3.next) {
|
|
193
204
|
case 0:
|
|
194
205
|
if (!(node.nodeType === 3 /** ignore text nodes **/ || node.getAttribute("visibility") === "hidden")) {
|
|
195
|
-
_context3.
|
|
206
|
+
_context3.next = 2;
|
|
196
207
|
break;
|
|
197
208
|
}
|
|
198
|
-
return _context3.
|
|
199
|
-
case
|
|
209
|
+
return _context3.abrupt("return");
|
|
210
|
+
case 2:
|
|
200
211
|
if (!(node.tagName === "image")) {
|
|
201
|
-
_context3.
|
|
212
|
+
_context3.next = 7;
|
|
202
213
|
break;
|
|
203
214
|
}
|
|
204
215
|
if (!getImageSrc(node).startsWith(SVG_DATA_URL_HDR)) {
|
|
205
|
-
_context3.
|
|
216
|
+
_context3.next = 7;
|
|
206
217
|
break;
|
|
207
218
|
}
|
|
208
|
-
_context3.
|
|
219
|
+
_context3.next = 6;
|
|
209
220
|
return applyOnEmbeddedSvg(node, imageCanvas, ctx, svgElement);
|
|
210
|
-
case
|
|
211
|
-
return _context3.
|
|
212
|
-
case
|
|
221
|
+
case 6:
|
|
222
|
+
return _context3.abrupt("return");
|
|
223
|
+
case 7:
|
|
213
224
|
partialSvg = createSvgChunk(imageCanvas, svgElement, node);
|
|
214
225
|
if (partialSvg) {
|
|
215
|
-
_context3.
|
|
226
|
+
_context3.next = 10;
|
|
216
227
|
break;
|
|
217
228
|
}
|
|
218
|
-
return _context3.
|
|
219
|
-
case
|
|
220
|
-
_context3.
|
|
229
|
+
return _context3.abrupt("return");
|
|
230
|
+
case 10:
|
|
231
|
+
_context3.next = 12;
|
|
221
232
|
return svgToImg(partialSvg);
|
|
222
|
-
case
|
|
223
|
-
img = _context3.
|
|
233
|
+
case 12:
|
|
234
|
+
img = _context3.sent;
|
|
224
235
|
rotation = Math.random() * Math.PI;
|
|
225
236
|
_createWorkingCanvas5 = createWorkingCanvas(imageCanvas), _createWorkingCanvas6 = _slicedToArray(_createWorkingCanvas5, 2), multiplyPatternCanvas = _createWorkingCanvas6[0], multiplyPatternContext = _createWorkingCanvas6[1];
|
|
226
237
|
multiplyPatternContext.fillStyle = ctx.createPattern(imagePreloader.get(multiplyImageSrc), "repeat");
|
|
@@ -248,8 +259,9 @@ var applyOnChildNode = function applyOnChildNode(imageCanvas, ctx, svgElement) {
|
|
|
248
259
|
// Draw SVG again behind
|
|
249
260
|
ctx.globalCompositeOperation = "multiply";
|
|
250
261
|
ctx.drawImage(img, 0, 0);
|
|
251
|
-
case
|
|
252
|
-
|
|
262
|
+
case 36:
|
|
263
|
+
case "end":
|
|
264
|
+
return _context3.stop();
|
|
253
265
|
}
|
|
254
266
|
}, _callee3);
|
|
255
267
|
}));
|
|
@@ -324,19 +336,19 @@ var cloneWithParent = function cloneWithParent(node, outermostParent) {
|
|
|
324
336
|
}
|
|
325
337
|
return clone;
|
|
326
338
|
};
|
|
327
|
-
var
|
|
339
|
+
var traverseDOM = function traverseDOM(node, cb) {
|
|
328
340
|
cb(node);
|
|
329
341
|
var childNodes = node.childNodes;
|
|
330
342
|
var length = childNodes.length;
|
|
331
343
|
if (length > 0) {
|
|
332
344
|
for (var i = 0; i < length; i++) {
|
|
333
|
-
|
|
345
|
+
traverseDOM(childNodes[i], cb);
|
|
334
346
|
}
|
|
335
347
|
}
|
|
336
348
|
};
|
|
337
349
|
var collectEndNodes = function collectEndNodes(node) {
|
|
338
350
|
var nodes = [];
|
|
339
|
-
|
|
351
|
+
traverseDOM(node, function (node) {
|
|
340
352
|
if (node.tagName === "path" || node.tagName === "image") {
|
|
341
353
|
nodes.push(node);
|
|
342
354
|
}
|
|
@@ -351,22 +363,22 @@ var getEffectKey = function getEffectKey(svgAsString, srcCanvas) {
|
|
|
351
363
|
var createEffectImg = function () {
|
|
352
364
|
var cache = createCache(10);
|
|
353
365
|
return /*#__PURE__*/function () {
|
|
354
|
-
var _createEffectImg = _asyncToGenerator(/*#__PURE__*/
|
|
366
|
+
var _createEffectImg = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(svgAsString, srcCanvas) {
|
|
355
367
|
var key, cachedResult, svgDoc, svgElement, _getSizeValues3, _getSizeValues4, cWidth, cHeight, aspectRatio, width, height, _createWorkingCanvas1, _createWorkingCanvas10, imageCanvas, ctx, designerLayer, childNodes, image, _getScaleValues5, _getScaleValues6, sx, sy, resultImgPromise;
|
|
356
|
-
return
|
|
357
|
-
while (1) switch (_context4.
|
|
368
|
+
return _regeneratorRuntime().wrap(function _callee4$(_context4) {
|
|
369
|
+
while (1) switch (_context4.prev = _context4.next) {
|
|
358
370
|
case 0:
|
|
359
371
|
key = getEffectKey(svgAsString, srcCanvas);
|
|
360
|
-
_context4.
|
|
372
|
+
_context4.next = 3;
|
|
361
373
|
return cache.get(key);
|
|
362
|
-
case
|
|
363
|
-
cachedResult = _context4.
|
|
374
|
+
case 3:
|
|
375
|
+
cachedResult = _context4.sent;
|
|
364
376
|
if (!cachedResult) {
|
|
365
|
-
_context4.
|
|
377
|
+
_context4.next = 6;
|
|
366
378
|
break;
|
|
367
379
|
}
|
|
368
|
-
return _context4.
|
|
369
|
-
case
|
|
380
|
+
return _context4.abrupt("return", cachedResult);
|
|
381
|
+
case 6:
|
|
370
382
|
svgDoc = new DOMParser().parseFromString(svgAsString, "image/svg+xml");
|
|
371
383
|
svgElement = svgDoc.getElementsByTagName("svg")[0];
|
|
372
384
|
_getSizeValues3 = getSizeValues(svgElement), _getSizeValues4 = _slicedToArray(_getSizeValues3, 2), cWidth = _getSizeValues4[0], cHeight = _getSizeValues4[1];
|
|
@@ -383,25 +395,28 @@ var createEffectImg = function () {
|
|
|
383
395
|
}), _createWorkingCanvas10 = _slicedToArray(_createWorkingCanvas1, 2), imageCanvas = _createWorkingCanvas10[0], ctx = _createWorkingCanvas10[1];
|
|
384
396
|
designerLayer = svgElement.getElementById("designerLayer") || svgElement.firstElementChild;
|
|
385
397
|
childNodes = collectEndNodes(designerLayer);
|
|
386
|
-
_context4.
|
|
398
|
+
_context4.next = 18;
|
|
387
399
|
return Promise.all(childNodes.map(applyOnChildNode(imageCanvas, ctx, svgElement)));
|
|
388
|
-
case
|
|
400
|
+
case 18:
|
|
389
401
|
// in case of SVGImageElements with non external source the onLoad event is not fired in every browser (eg. Safari)
|
|
390
402
|
// but it still does the operation sequentially so we can use it directly after setting the href attribute
|
|
391
403
|
image = document.createElementNS(svgElement.namespaceURI, "image");
|
|
392
404
|
image.width.baseVal.value = width;
|
|
393
405
|
image.height.baseVal.value = height;
|
|
394
406
|
image.href.baseVal = imageCanvas.toDataURL();
|
|
395
|
-
_getScaleValues5 = getScaleValues(
|
|
407
|
+
_getScaleValues5 = getScaleValues(findOutermostNode(designerLayer, svgElement)), _getScaleValues6 = _slicedToArray(_getScaleValues5, 2), sx = _getScaleValues6[0], sy = _getScaleValues6[1];
|
|
396
408
|
image.setAttribute("transform", "scale(".concat(1 / sx, ",").concat(1 / sy, ")"));
|
|
397
409
|
designerLayer.innerHTML = "";
|
|
398
410
|
designerLayer.appendChild(image);
|
|
399
411
|
resultImgPromise = svgToImg(svgDoc);
|
|
400
412
|
cache.set(key, resultImgPromise);
|
|
401
|
-
_context4.
|
|
413
|
+
_context4.next = 30;
|
|
402
414
|
return resultImgPromise;
|
|
403
|
-
case
|
|
404
|
-
return _context4.
|
|
415
|
+
case 30:
|
|
416
|
+
return _context4.abrupt("return", _context4.sent);
|
|
417
|
+
case 31:
|
|
418
|
+
case "end":
|
|
419
|
+
return _context4.stop();
|
|
405
420
|
}
|
|
406
421
|
}, _callee4);
|
|
407
422
|
}));
|
|
@@ -415,7 +430,7 @@ export function embroideryEffect(_x9) {
|
|
|
415
430
|
return _embroideryEffect.apply(this, arguments);
|
|
416
431
|
}
|
|
417
432
|
function _embroideryEffect() {
|
|
418
|
-
_embroideryEffect = _asyncToGenerator(/*#__PURE__*/
|
|
433
|
+
_embroideryEffect = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5(srcCanvas) {
|
|
419
434
|
var options,
|
|
420
435
|
getSvg,
|
|
421
436
|
svgAsString,
|
|
@@ -424,34 +439,35 @@ function _embroideryEffect() {
|
|
|
424
439
|
height,
|
|
425
440
|
srcCtx,
|
|
426
441
|
_args5 = arguments;
|
|
427
|
-
return
|
|
428
|
-
while (1) switch (_context5.
|
|
442
|
+
return _regeneratorRuntime().wrap(function _callee5$(_context5) {
|
|
443
|
+
while (1) switch (_context5.prev = _context5.next) {
|
|
429
444
|
case 0:
|
|
430
445
|
options = _args5.length > 1 && _args5[1] !== undefined ? _args5[1] : {};
|
|
431
|
-
_context5.
|
|
446
|
+
_context5.next = 3;
|
|
432
447
|
return imagePreloader.loadAll();
|
|
433
|
-
case
|
|
448
|
+
case 3:
|
|
434
449
|
getSvg = options.getSvg;
|
|
435
450
|
if (getSvg) {
|
|
436
|
-
_context5.
|
|
451
|
+
_context5.next = 6;
|
|
437
452
|
break;
|
|
438
453
|
}
|
|
439
454
|
throw new Error("The getSvg function must be provided for the embroidery effect!");
|
|
440
|
-
case
|
|
441
|
-
_context5.
|
|
455
|
+
case 6:
|
|
456
|
+
_context5.next = 8;
|
|
442
457
|
return getSvg();
|
|
443
|
-
case
|
|
444
|
-
svgAsString = _context5.
|
|
445
|
-
_context5.
|
|
458
|
+
case 8:
|
|
459
|
+
svgAsString = _context5.sent;
|
|
460
|
+
_context5.next = 11;
|
|
446
461
|
return createEffectImg(svgAsString, srcCanvas);
|
|
447
|
-
case
|
|
448
|
-
img = _context5.
|
|
462
|
+
case 11:
|
|
463
|
+
img = _context5.sent;
|
|
449
464
|
width = img.width, height = img.height; // copy the created image over the src canvas
|
|
450
465
|
srcCtx = srcCanvas.getContext("2d");
|
|
451
466
|
srcCtx.clearRect(0, 0, width, height);
|
|
452
467
|
srcCtx.drawImage(img, 0, 0);
|
|
453
|
-
case
|
|
454
|
-
|
|
468
|
+
case 16:
|
|
469
|
+
case "end":
|
|
470
|
+
return _context5.stop();
|
|
455
471
|
}
|
|
456
472
|
}, _callee5);
|
|
457
473
|
}));
|
|
@@ -1,6 +1,13 @@
|
|
|
1
1
|
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); }
|
|
2
|
+
function _regeneratorRuntime() { "use strict"; var r = _regenerator(), e = r.m(_regeneratorRuntime), t = (Object.getPrototypeOf ? Object.getPrototypeOf(e) : e.__proto__).constructor; function n(r) { var e = "function" == typeof r && r.constructor; return !!e && (e === t || "GeneratorFunction" === (e.displayName || e.name)); } var o = { "throw": 1, "return": 2, "break": 3, "continue": 3 }; function a(r) { var e, t; return function (n) { e || (e = { stop: function stop() { return t(n.a, 2); }, "catch": function _catch() { return n.v; }, abrupt: function abrupt(r, e) { return t(n.a, o[r], e); }, delegateYield: function delegateYield(r, o, a) { return e.resultName = o, t(n.d, _regeneratorValues(r), a); }, finish: function finish(r) { return t(n.f, r); } }, t = function t(r, _t, o) { n.p = e.prev, n.n = e.next; try { return r(_t, o); } finally { e.next = n.n; } }), e.resultName && (e[e.resultName] = n.v, e.resultName = void 0), e.sent = n.v, e.next = n.n; try { return r.call(this, e); } finally { n.p = e.prev, n.n = e.next; } }; } return (_regeneratorRuntime = function _regeneratorRuntime() { return { wrap: function wrap(e, t, n, o) { return r.w(a(e), t, n, o && o.reverse()); }, isGeneratorFunction: n, mark: r.m, awrap: function awrap(r, e) { return new _OverloadYield(r, e); }, AsyncIterator: _regeneratorAsyncIterator, async: function async(r, e, t, o, u) { return (n(e) ? _regeneratorAsyncGen : _regeneratorAsync)(a(r), e, t, o, u); }, keys: _regeneratorKeys, values: _regeneratorValues }; })(); }
|
|
3
|
+
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"); }
|
|
4
|
+
function _regeneratorKeys(e) { var n = Object(e), r = []; for (var t in n) r.unshift(t); return function e() { for (; r.length;) if ((t = r.pop()) in n) return e.value = t, e.done = !1, e; return e.done = !0, e; }; }
|
|
5
|
+
function _regeneratorAsync(n, e, r, t, o) { var a = _regeneratorAsyncGen(n, e, r, t, o); return a.next().then(function (n) { return n.done ? n.value : a.next(); }); }
|
|
6
|
+
function _regeneratorAsyncGen(r, e, t, o, n) { return new _regeneratorAsyncIterator(_regenerator().w(r, e, t, o), n || Promise); }
|
|
7
|
+
function _regeneratorAsyncIterator(t, e) { function n(r, o, i, f) { try { var c = t[r](o), u = c.value; return u instanceof _OverloadYield ? e.resolve(u.v).then(function (t) { n("next", t, i, f); }, function (t) { n("throw", t, i, f); }) : e.resolve(u).then(function (t) { c.value = t, i(c); }, function (t) { return n("throw", t, i, f); }); } catch (t) { f(t); } } var r; this.next || (_regeneratorDefine2(_regeneratorAsyncIterator.prototype), _regeneratorDefine2(_regeneratorAsyncIterator.prototype, "function" == typeof Symbol && Symbol.asyncIterator || "@asyncIterator", function () { return this; })), _regeneratorDefine2(this, "_invoke", function (t, o, i) { function f() { return new e(function (e, r) { n(t, i, e, r); }); } return r = r ? r.then(f, f) : f(); }, !0); }
|
|
2
8
|
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 }; })(); }
|
|
3
9
|
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); }
|
|
10
|
+
function _OverloadYield(e, d) { this.v = e, this.k = d; }
|
|
4
11
|
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); }
|
|
5
12
|
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); }); }; }
|
|
6
13
|
function _slicedToArray(r, e) { return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest(); }
|
|
@@ -33,16 +40,15 @@ export var EffectCanvas = /*#__PURE__*/function () {
|
|
|
33
40
|
this.canvas = canvas;
|
|
34
41
|
this.ctx = ctx;
|
|
35
42
|
}
|
|
36
|
-
|
|
43
|
+
_createClass(EffectCanvas, [{
|
|
37
44
|
key: "applyEffect",
|
|
38
45
|
value: function () {
|
|
39
|
-
var _applyEffect = _asyncToGenerator(/*#__PURE__*/
|
|
46
|
+
var _applyEffect = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(effect) {
|
|
40
47
|
var options,
|
|
41
48
|
effectFn,
|
|
42
|
-
_args = arguments
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
while (1) switch (_context.n) {
|
|
49
|
+
_args = arguments;
|
|
50
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
51
|
+
while (1) switch (_context.prev = _context.next) {
|
|
46
52
|
case 0:
|
|
47
53
|
options = _args.length > 1 && _args[1] !== undefined ? _args[1] : {};
|
|
48
54
|
effectFn = {
|
|
@@ -52,17 +58,20 @@ export var EffectCanvas = /*#__PURE__*/function () {
|
|
|
52
58
|
embroidery: embroideryEffect,
|
|
53
59
|
color_embossing: colorEmbossingEffect
|
|
54
60
|
}[effect];
|
|
55
|
-
|
|
56
|
-
if (!
|
|
57
|
-
_context.
|
|
61
|
+
_context.t0 = effectFn;
|
|
62
|
+
if (!_context.t0) {
|
|
63
|
+
_context.next = 7;
|
|
58
64
|
break;
|
|
59
65
|
}
|
|
60
|
-
_context.
|
|
66
|
+
_context.next = 6;
|
|
61
67
|
return effectFn(this.canvas, options);
|
|
62
|
-
case
|
|
63
|
-
|
|
64
|
-
case
|
|
65
|
-
return _context.
|
|
68
|
+
case 6:
|
|
69
|
+
_context.t0 = _context.sent;
|
|
70
|
+
case 7:
|
|
71
|
+
return _context.abrupt("return", _context.t0);
|
|
72
|
+
case 8:
|
|
73
|
+
case "end":
|
|
74
|
+
return _context.stop();
|
|
66
75
|
}
|
|
67
76
|
}, _callee, this);
|
|
68
77
|
}));
|
|
@@ -77,4 +86,5 @@ export var EffectCanvas = /*#__PURE__*/function () {
|
|
|
77
86
|
ctx.drawImage(this.canvas, 0, 0);
|
|
78
87
|
}
|
|
79
88
|
}]);
|
|
89
|
+
return EffectCanvas;
|
|
80
90
|
}();
|
package/React/ReactBase.js
CHANGED
|
@@ -2,16 +2,15 @@ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" ==
|
|
|
2
2
|
function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); }
|
|
3
3
|
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); } }
|
|
4
4
|
function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; }
|
|
5
|
-
function _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); }
|
|
6
|
-
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); }
|
|
7
|
-
function _assertThisInitialized(e) { if (void 0 === e) throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); return e; }
|
|
8
|
-
function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
|
|
9
|
-
function _superPropGet(t, o, e, r) { var p = _get(_getPrototypeOf(1 & r ? t.prototype : t), o, e); return 2 & r && "function" == typeof p ? function (t) { return p.apply(e, t); } : p; }
|
|
10
5
|
function _get() { return _get = "undefined" != typeof Reflect && Reflect.get ? Reflect.get.bind() : function (e, t, r) { var p = _superPropBase(e, t); if (p) { var n = Object.getOwnPropertyDescriptor(p, t); return n.get ? n.get.call(arguments.length < 3 ? e : r) : n.value; } }, _get.apply(null, arguments); }
|
|
11
6
|
function _superPropBase(t, o) { for (; !{}.hasOwnProperty.call(t, o) && null !== (t = _getPrototypeOf(t));); return t; }
|
|
12
|
-
function _getPrototypeOf(t) { return _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function (t) { return t.__proto__ || Object.getPrototypeOf(t); }, _getPrototypeOf(t); }
|
|
13
7
|
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); }
|
|
14
8
|
function _setPrototypeOf(t, e) { return _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function (t, e) { return t.__proto__ = e, t; }, _setPrototypeOf(t, e); }
|
|
9
|
+
function _createSuper(t) { var r = _isNativeReflectConstruct(); return function () { var e, o = _getPrototypeOf(t); if (r) { var s = _getPrototypeOf(this).constructor; e = Reflect.construct(o, arguments, s); } else e = o.apply(this, arguments); return _possibleConstructorReturn(this, e); }; }
|
|
10
|
+
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); }
|
|
11
|
+
function _assertThisInitialized(e) { if (void 0 === e) throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); return e; }
|
|
12
|
+
function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
|
|
13
|
+
function _getPrototypeOf(t) { return _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function (t) { return t.__proto__ || Object.getPrototypeOf(t); }, _getPrototypeOf(t); }
|
|
15
14
|
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; }
|
|
16
15
|
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
|
|
17
16
|
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,19 +25,20 @@ var NoComponent = function NoComponent() {
|
|
|
26
25
|
* A base class for React based visualizations which renders the given Component in the container element
|
|
27
26
|
*/
|
|
28
27
|
export var ReactBase = /*#__PURE__*/function (_VisualizationInterfa) {
|
|
28
|
+
_inherits(ReactBase, _VisualizationInterfa);
|
|
29
|
+
var _super = _createSuper(ReactBase);
|
|
29
30
|
function ReactBase(cfg) {
|
|
30
31
|
var _this;
|
|
31
32
|
_classCallCheck(this, ReactBase);
|
|
32
|
-
_this =
|
|
33
|
-
_defineProperty(_this, "_container", null);
|
|
34
|
-
_defineProperty(_this, "Component", NoComponent);
|
|
33
|
+
_this = _super.call(this, cfg);
|
|
34
|
+
_defineProperty(_assertThisInitialized(_this), "_container", null);
|
|
35
|
+
_defineProperty(_assertThisInitialized(_this), "Component", NoComponent);
|
|
35
36
|
if (cfg.Component) {
|
|
36
37
|
_this.Component = cfg.Component;
|
|
37
38
|
}
|
|
38
39
|
return _this;
|
|
39
40
|
}
|
|
40
|
-
|
|
41
|
-
return _createClass(ReactBase, [{
|
|
41
|
+
_createClass(ReactBase, [{
|
|
42
42
|
key: "init",
|
|
43
43
|
value: function init() {
|
|
44
44
|
var container = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : document.createElement("div");
|
|
@@ -57,15 +57,16 @@ export var ReactBase = /*#__PURE__*/function (_VisualizationInterfa) {
|
|
|
57
57
|
value: function render() {
|
|
58
58
|
var Component = this.Component,
|
|
59
59
|
_container = this._container;
|
|
60
|
-
ReactDOM.render(/*#__PURE__*/React.createElement(Component, null), _container);
|
|
60
|
+
ReactDOM.render( /*#__PURE__*/React.createElement(Component, null), _container);
|
|
61
61
|
}
|
|
62
62
|
}, {
|
|
63
63
|
key: "dispose",
|
|
64
64
|
value: function dispose() {
|
|
65
|
-
|
|
65
|
+
_get(_getPrototypeOf(ReactBase.prototype), "dispose", this).call(this);
|
|
66
66
|
if (this._container) {
|
|
67
67
|
ReactDOM.unmountComponentAtNode(this._container);
|
|
68
68
|
}
|
|
69
69
|
}
|
|
70
70
|
}]);
|
|
71
|
+
return ReactBase;
|
|
71
72
|
}(VisualizationInterface);
|