@antv/g-svg 1.8.60 → 1.9.0-beta.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/dist/index.esm.js CHANGED
@@ -1,623 +1,204 @@
1
- import { isBrowser, propertyMetadataCache, AbstractRendererPlugin, AbstractRenderer } from '@antv/g-lite';
2
- import { Plugin as Plugin$1 } from '@antv/g-plugin-dom-interaction';
1
+ import { __rest, __awaiter, __generator, __extends } from 'tslib';
2
+ import { propertyMetadataCache, isBrowser, AbstractRendererPlugin, AbstractRenderer } from '@antv/g-lite';
3
3
  import * as DomInteraction from '@antv/g-plugin-dom-interaction';
4
4
  export { DomInteraction };
5
- import { Plugin as Plugin$2 } from '@antv/g-plugin-svg-picker';
6
5
  import * as SVGPicker from '@antv/g-plugin-svg-picker';
7
6
  export { SVGPicker };
8
- import { createSVGElement, Plugin } from '@antv/g-plugin-svg-renderer';
9
7
  import * as SVGRenderer from '@antv/g-plugin-svg-renderer';
8
+ import { createSVGElement } from '@antv/g-plugin-svg-renderer';
10
9
  export { SVGRenderer };
11
10
  import { isString } from '@antv/util';
12
11
 
13
- function _regeneratorRuntime() {
14
- _regeneratorRuntime = function () {
15
- return exports;
16
- };
17
- var exports = {},
18
- Op = Object.prototype,
19
- hasOwn = Op.hasOwnProperty,
20
- defineProperty = Object.defineProperty || function (obj, key, desc) {
21
- obj[key] = desc.value;
22
- },
23
- $Symbol = "function" == typeof Symbol ? Symbol : {},
24
- iteratorSymbol = $Symbol.iterator || "@@iterator",
25
- asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator",
26
- toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag";
27
- function define(obj, key, value) {
28
- return Object.defineProperty(obj, key, {
29
- value: value,
30
- enumerable: !0,
31
- configurable: !0,
32
- writable: !0
33
- }), obj[key];
34
- }
35
- try {
36
- define({}, "");
37
- } catch (err) {
38
- define = function (obj, key, value) {
39
- return obj[key] = value;
40
- };
41
- }
42
- function wrap(innerFn, outerFn, self, tryLocsList) {
43
- var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator,
44
- generator = Object.create(protoGenerator.prototype),
45
- context = new Context(tryLocsList || []);
46
- return defineProperty(generator, "_invoke", {
47
- value: makeInvokeMethod(innerFn, self, context)
48
- }), generator;
49
- }
50
- function tryCatch(fn, obj, arg) {
51
- try {
52
- return {
53
- type: "normal",
54
- arg: fn.call(obj, arg)
55
- };
56
- } catch (err) {
57
- return {
58
- type: "throw",
59
- arg: err
60
- };
61
- }
62
- }
63
- exports.wrap = wrap;
64
- var ContinueSentinel = {};
65
- function Generator() {}
66
- function GeneratorFunction() {}
67
- function GeneratorFunctionPrototype() {}
68
- var IteratorPrototype = {};
69
- define(IteratorPrototype, iteratorSymbol, function () {
70
- return this;
71
- });
72
- var getProto = Object.getPrototypeOf,
73
- NativeIteratorPrototype = getProto && getProto(getProto(values([])));
74
- NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol) && (IteratorPrototype = NativeIteratorPrototype);
75
- var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype);
76
- function defineIteratorMethods(prototype) {
77
- ["next", "throw", "return"].forEach(function (method) {
78
- define(prototype, method, function (arg) {
79
- return this._invoke(method, arg);
80
- });
81
- });
82
- }
83
- function AsyncIterator(generator, PromiseImpl) {
84
- function invoke(method, arg, resolve, reject) {
85
- var record = tryCatch(generator[method], generator, arg);
86
- if ("throw" !== record.type) {
87
- var result = record.arg,
88
- value = result.value;
89
- return value && "object" == typeof value && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) {
90
- invoke("next", value, resolve, reject);
91
- }, function (err) {
92
- invoke("throw", err, resolve, reject);
93
- }) : PromiseImpl.resolve(value).then(function (unwrapped) {
94
- result.value = unwrapped, resolve(result);
95
- }, function (error) {
96
- return invoke("throw", error, resolve, reject);
97
- });
98
- }
99
- reject(record.arg);
12
+ var SVGContextService = /** @class */ (function () {
13
+ function SVGContextService(context) {
14
+ this.context = context;
15
+ this.canvasConfig = context.config;
100
16
  }
101
- var previousPromise;
102
- defineProperty(this, "_invoke", {
103
- value: function (method, arg) {
104
- function callInvokeWithMethodAndArg() {
105
- return new PromiseImpl(function (resolve, reject) {
106
- invoke(method, arg, resolve, reject);
107
- });
108
- }
109
- return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg();
110
- }
111
- });
112
- }
113
- function makeInvokeMethod(innerFn, self, context) {
114
- var state = "suspendedStart";
115
- return function (method, arg) {
116
- if ("executing" === state) throw new Error("Generator is already running");
117
- if ("completed" === state) {
118
- if ("throw" === method) throw arg;
119
- return doneResult();
120
- }
121
- for (context.method = method, context.arg = arg;;) {
122
- var delegate = context.delegate;
123
- if (delegate) {
124
- var delegateResult = maybeInvokeDelegate(delegate, context);
125
- if (delegateResult) {
126
- if (delegateResult === ContinueSentinel) continue;
127
- return delegateResult;
128
- }
17
+ SVGContextService.prototype.init = function () {
18
+ var _a = this.canvasConfig, container = _a.container, doc = _a.document, devicePixelRatio = _a.devicePixelRatio;
19
+ // create container
20
+ this.$container = isString(container)
21
+ ? (doc || document).getElementById(container)
22
+ : container;
23
+ if (this.$container) {
24
+ if (!this.$container.style.position) {
25
+ this.$container.style.position = 'relative';
26
+ }
27
+ var $namespace = createSVGElement('svg', doc);
28
+ $namespace.setAttribute('width', "".concat(this.canvasConfig.width));
29
+ $namespace.setAttribute('height', "".concat(this.canvasConfig.height));
30
+ this.$container.appendChild($namespace);
31
+ this.$namespace = $namespace;
129
32
  }
130
- if ("next" === context.method) context.sent = context._sent = context.arg;else if ("throw" === context.method) {
131
- if ("suspendedStart" === state) throw state = "completed", context.arg;
132
- context.dispatchException(context.arg);
133
- } else "return" === context.method && context.abrupt("return", context.arg);
134
- state = "executing";
135
- var record = tryCatch(innerFn, self, context);
136
- if ("normal" === record.type) {
137
- if (state = context.done ? "completed" : "suspendedYield", record.arg === ContinueSentinel) continue;
138
- return {
139
- value: record.arg,
140
- done: context.done
141
- };
142
- }
143
- "throw" === record.type && (state = "completed", context.method = "throw", context.arg = record.arg);
144
- }
145
- };
146
- }
147
- function maybeInvokeDelegate(delegate, context) {
148
- var methodName = context.method,
149
- method = delegate.iterator[methodName];
150
- if (undefined === method) return context.delegate = null, "throw" === methodName && delegate.iterator.return && (context.method = "return", context.arg = undefined, maybeInvokeDelegate(delegate, context), "throw" === context.method) || "return" !== methodName && (context.method = "throw", context.arg = new TypeError("The iterator does not provide a '" + methodName + "' method")), ContinueSentinel;
151
- var record = tryCatch(method, delegate.iterator, context.arg);
152
- if ("throw" === record.type) return context.method = "throw", context.arg = record.arg, context.delegate = null, ContinueSentinel;
153
- var info = record.arg;
154
- return info ? info.done ? (context[delegate.resultName] = info.value, context.next = delegate.nextLoc, "return" !== context.method && (context.method = "next", context.arg = undefined), context.delegate = null, ContinueSentinel) : info : (context.method = "throw", context.arg = new TypeError("iterator result is not an object"), context.delegate = null, ContinueSentinel);
155
- }
156
- function pushTryEntry(locs) {
157
- var entry = {
158
- tryLoc: locs[0]
33
+ // use user-defined dpr first
34
+ var dpr = devicePixelRatio || (isBrowser && window.devicePixelRatio) || 1;
35
+ dpr = dpr >= 1 ? Math.ceil(dpr) : 1;
36
+ this.dpr = dpr;
159
37
  };
160
- 1 in locs && (entry.catchLoc = locs[1]), 2 in locs && (entry.finallyLoc = locs[2], entry.afterLoc = locs[3]), this.tryEntries.push(entry);
161
- }
162
- function resetTryEntry(entry) {
163
- var record = entry.completion || {};
164
- record.type = "normal", delete record.arg, entry.completion = record;
165
- }
166
- function Context(tryLocsList) {
167
- this.tryEntries = [{
168
- tryLoc: "root"
169
- }], tryLocsList.forEach(pushTryEntry, this), this.reset(!0);
170
- }
171
- function values(iterable) {
172
- if (iterable) {
173
- var iteratorMethod = iterable[iteratorSymbol];
174
- if (iteratorMethod) return iteratorMethod.call(iterable);
175
- if ("function" == typeof iterable.next) return iterable;
176
- if (!isNaN(iterable.length)) {
177
- var i = -1,
178
- next = function next() {
179
- for (; ++i < iterable.length;) if (hasOwn.call(iterable, i)) return next.value = iterable[i], next.done = !1, next;
180
- return next.value = undefined, next.done = !0, next;
181
- };
182
- return next.next = next;
183
- }
184
- }
185
- return {
186
- next: doneResult
38
+ // @ts-ignore
39
+ SVGContextService.prototype.getDomElement = function () {
40
+ return this.$namespace;
187
41
  };
188
- }
189
- function doneResult() {
190
- return {
191
- value: undefined,
192
- done: !0
42
+ SVGContextService.prototype.getContext = function () {
43
+ return this.$namespace;
193
44
  };
194
- }
195
- return GeneratorFunction.prototype = GeneratorFunctionPrototype, defineProperty(Gp, "constructor", {
196
- value: GeneratorFunctionPrototype,
197
- configurable: !0
198
- }), defineProperty(GeneratorFunctionPrototype, "constructor", {
199
- value: GeneratorFunction,
200
- configurable: !0
201
- }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"), exports.isGeneratorFunction = function (genFun) {
202
- var ctor = "function" == typeof genFun && genFun.constructor;
203
- return !!ctor && (ctor === GeneratorFunction || "GeneratorFunction" === (ctor.displayName || ctor.name));
204
- }, exports.mark = function (genFun) {
205
- return Object.setPrototypeOf ? Object.setPrototypeOf(genFun, GeneratorFunctionPrototype) : (genFun.__proto__ = GeneratorFunctionPrototype, define(genFun, toStringTagSymbol, "GeneratorFunction")), genFun.prototype = Object.create(Gp), genFun;
206
- }, exports.awrap = function (arg) {
207
- return {
208
- __await: arg
45
+ SVGContextService.prototype.getDPR = function () {
46
+ return this.dpr;
209
47
  };
210
- }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, asyncIteratorSymbol, function () {
211
- return this;
212
- }), exports.AsyncIterator = AsyncIterator, exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) {
213
- void 0 === PromiseImpl && (PromiseImpl = Promise);
214
- var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl);
215
- return exports.isGeneratorFunction(outerFn) ? iter : iter.next().then(function (result) {
216
- return result.done ? result.value : iter.next();
217
- });
218
- }, defineIteratorMethods(Gp), define(Gp, toStringTagSymbol, "Generator"), define(Gp, iteratorSymbol, function () {
219
- return this;
220
- }), define(Gp, "toString", function () {
221
- return "[object Generator]";
222
- }), exports.keys = function (val) {
223
- var object = Object(val),
224
- keys = [];
225
- for (var key in object) keys.push(key);
226
- return keys.reverse(), function next() {
227
- for (; keys.length;) {
228
- var key = keys.pop();
229
- if (key in object) return next.value = key, next.done = !1, next;
230
- }
231
- return next.done = !0, next;
48
+ SVGContextService.prototype.getBoundingClientRect = function () {
49
+ var _a;
50
+ return (_a = this.$namespace) === null || _a === void 0 ? void 0 : _a.getBoundingClientRect();
232
51
  };
233
- }, exports.values = values, Context.prototype = {
234
- constructor: Context,
235
- reset: function (skipTempReset) {
236
- if (this.prev = 0, this.next = 0, this.sent = this._sent = undefined, this.done = !1, this.delegate = null, this.method = "next", this.arg = undefined, this.tryEntries.forEach(resetTryEntry), !skipTempReset) for (var name in this) "t" === name.charAt(0) && hasOwn.call(this, name) && !isNaN(+name.slice(1)) && (this[name] = undefined);
237
- },
238
- stop: function () {
239
- this.done = !0;
240
- var rootRecord = this.tryEntries[0].completion;
241
- if ("throw" === rootRecord.type) throw rootRecord.arg;
242
- return this.rval;
243
- },
244
- dispatchException: function (exception) {
245
- if (this.done) throw exception;
246
- var context = this;
247
- function handle(loc, caught) {
248
- return record.type = "throw", record.arg = exception, context.next = loc, caught && (context.method = "next", context.arg = undefined), !!caught;
249
- }
250
- for (var i = this.tryEntries.length - 1; i >= 0; --i) {
251
- var entry = this.tryEntries[i],
252
- record = entry.completion;
253
- if ("root" === entry.tryLoc) return handle("end");
254
- if (entry.tryLoc <= this.prev) {
255
- var hasCatch = hasOwn.call(entry, "catchLoc"),
256
- hasFinally = hasOwn.call(entry, "finallyLoc");
257
- if (hasCatch && hasFinally) {
258
- if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0);
259
- if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc);
260
- } else if (hasCatch) {
261
- if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0);
262
- } else {
263
- if (!hasFinally) throw new Error("try statement without catch or finally");
264
- if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc);
265
- }
52
+ SVGContextService.prototype.destroy = function () {
53
+ // destroy context
54
+ if (this.$container && this.$namespace && this.$namespace.parentNode) {
55
+ this.$container.removeChild(this.$namespace);
266
56
  }
267
- }
268
- },
269
- abrupt: function (type, arg) {
270
- for (var i = this.tryEntries.length - 1; i >= 0; --i) {
271
- var entry = this.tryEntries[i];
272
- if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) {
273
- var finallyEntry = entry;
274
- break;
57
+ };
58
+ SVGContextService.prototype.resize = function (width, height) {
59
+ // SVG should ignore DPR
60
+ if (this.$namespace) {
61
+ this.$namespace.setAttribute('width', "".concat(width));
62
+ this.$namespace.setAttribute('height', "".concat(height));
275
63
  }
276
- }
277
- finallyEntry && ("break" === type || "continue" === type) && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc && (finallyEntry = null);
278
- var record = finallyEntry ? finallyEntry.completion : {};
279
- return record.type = type, record.arg = arg, finallyEntry ? (this.method = "next", this.next = finallyEntry.finallyLoc, ContinueSentinel) : this.complete(record);
280
- },
281
- complete: function (record, afterLoc) {
282
- if ("throw" === record.type) throw record.arg;
283
- return "break" === record.type || "continue" === record.type ? this.next = record.arg : "return" === record.type ? (this.rval = this.arg = record.arg, this.method = "return", this.next = "end") : "normal" === record.type && afterLoc && (this.next = afterLoc), ContinueSentinel;
284
- },
285
- finish: function (finallyLoc) {
286
- for (var i = this.tryEntries.length - 1; i >= 0; --i) {
287
- var entry = this.tryEntries[i];
288
- if (entry.finallyLoc === finallyLoc) return this.complete(entry.completion, entry.afterLoc), resetTryEntry(entry), ContinueSentinel;
289
- }
290
- },
291
- catch: function (tryLoc) {
292
- for (var i = this.tryEntries.length - 1; i >= 0; --i) {
293
- var entry = this.tryEntries[i];
294
- if (entry.tryLoc === tryLoc) {
295
- var record = entry.completion;
296
- if ("throw" === record.type) {
297
- var thrown = record.arg;
298
- resetTryEntry(entry);
299
- }
300
- return thrown;
64
+ };
65
+ SVGContextService.prototype.applyCursorStyle = function (cursor) {
66
+ if (this.$container) {
67
+ this.$container.style.cursor = cursor;
301
68
  }
302
- }
303
- throw new Error("illegal catch attempt");
304
- },
305
- delegateYield: function (iterable, resultName, nextLoc) {
306
- return this.delegate = {
307
- iterator: values(iterable),
308
- resultName: resultName,
309
- nextLoc: nextLoc
310
- }, "next" === this.method && (this.arg = undefined), ContinueSentinel;
311
- }
312
- }, exports;
313
- }
314
- function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
315
- try {
316
- var info = gen[key](arg);
317
- var value = info.value;
318
- } catch (error) {
319
- reject(error);
320
- return;
321
- }
322
- if (info.done) {
323
- resolve(value);
324
- } else {
325
- Promise.resolve(value).then(_next, _throw);
326
- }
327
- }
328
- function _asyncToGenerator(fn) {
329
- return function () {
330
- var self = this,
331
- args = arguments;
332
- return new Promise(function (resolve, reject) {
333
- var gen = fn.apply(self, args);
334
- function _next(value) {
335
- asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
336
- }
337
- function _throw(err) {
338
- asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
339
- }
340
- _next(undefined);
341
- });
342
- };
343
- }
344
- function _inheritsLoose(subClass, superClass) {
345
- subClass.prototype = Object.create(superClass.prototype);
346
- subClass.prototype.constructor = subClass;
347
- _setPrototypeOf(subClass, superClass);
348
- }
349
- function _setPrototypeOf(o, p) {
350
- _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) {
351
- o.__proto__ = p;
352
- return o;
353
- };
354
- return _setPrototypeOf(o, p);
355
- }
356
- function _objectWithoutPropertiesLoose(source, excluded) {
357
- if (source == null) return {};
358
- var target = {};
359
- var sourceKeys = Object.keys(source);
360
- var key, i;
361
- for (i = 0; i < sourceKeys.length; i++) {
362
- key = sourceKeys[i];
363
- if (excluded.indexOf(key) >= 0) continue;
364
- target[key] = source[key];
365
- }
366
- return target;
367
- }
368
-
369
- var _excluded = ["offset", "composite", "computedOffset", "easing"],
370
- _excluded2 = ["offset", "composite", "computedOffset", "easing", "transformOrigin"],
371
- _excluded3 = ["offset", "composite", "computedOffset", "easing", "transformOrigin"],
372
- _excluded4 = ["offset", "composite", "computedOffset", "easing", "transformOrigin"];
373
- var SVGContextService = /*#__PURE__*/function () {
374
- function SVGContextService(context) {
375
- this.context = void 0;
376
- this.$container = void 0;
377
- this.$namespace = void 0;
378
- this.dpr = void 0;
379
- this.canvasConfig = void 0;
380
- this.context = context;
381
- this.canvasConfig = context.config;
382
- }
383
- var _proto = SVGContextService.prototype;
384
- _proto.init = function init() {
385
- var _this$canvasConfig = this.canvasConfig,
386
- container = _this$canvasConfig.container,
387
- doc = _this$canvasConfig.document,
388
- devicePixelRatio = _this$canvasConfig.devicePixelRatio;
389
- // create container
390
- this.$container = isString(container) ? (doc || document).getElementById(container) : container;
391
- if (this.$container) {
392
- if (!this.$container.style.position) {
393
- this.$container.style.position = 'relative';
394
- }
395
- var $namespace = createSVGElement('svg', doc);
396
- $namespace.setAttribute('width', "" + this.canvasConfig.width);
397
- $namespace.setAttribute('height', "" + this.canvasConfig.height);
398
- this.$container.appendChild($namespace);
399
- this.$namespace = $namespace;
400
- }
401
- // use user-defined dpr first
402
- var dpr = devicePixelRatio || isBrowser && window.devicePixelRatio || 1;
403
- dpr = dpr >= 1 ? Math.ceil(dpr) : 1;
404
- this.dpr = dpr;
405
- }
406
- // @ts-ignore
407
- ;
408
- _proto.getDomElement = function getDomElement() {
409
- return this.$namespace;
410
- };
411
- _proto.getContext = function getContext() {
412
- return this.$namespace;
413
- };
414
- _proto.getDPR = function getDPR() {
415
- return this.dpr;
416
- };
417
- _proto.getBoundingClientRect = function getBoundingClientRect() {
418
- var _this$$namespace;
419
- return (_this$$namespace = this.$namespace) === null || _this$$namespace === void 0 ? void 0 : _this$$namespace.getBoundingClientRect();
420
- };
421
- _proto.destroy = function destroy() {
422
- // destroy context
423
- if (this.$container && this.$namespace && this.$namespace.parentNode) {
424
- this.$container.removeChild(this.$namespace);
425
- }
426
- };
427
- _proto.resize = function resize(width, height) {
428
- // SVG should ignore DPR
429
- if (this.$namespace) {
430
- this.$namespace.setAttribute('width', "" + width);
431
- this.$namespace.setAttribute('height', "" + height);
432
- }
433
- };
434
- _proto.applyCursorStyle = function applyCursorStyle(cursor) {
435
- if (this.$container) {
436
- this.$container.style.cursor = cursor;
437
- }
438
- };
439
- _proto.generateCSSText = function generateCSSText(animationName, selector, keyframes, timing, prefixes) {
440
- if (prefixes === void 0) {
441
- prefixes = {};
442
- }
443
- var duration = timing.duration,
444
- easing = timing.easing,
445
- delay = timing.delay,
446
- direction = timing.direction,
447
- iterations = timing.iterations,
448
- fill = timing.fill;
449
- return "@keyframes " + animationName + "{" + keyframes.map(function (keyframe) {
450
- var offset = keyframe.offset,
451
- composite = keyframe.composite,
452
- computedOffset = keyframe.computedOffset,
453
- easing = keyframe.easing,
454
- rest = _objectWithoutPropertiesLoose(keyframe, _excluded);
455
- var rules = Object.keys(rest).map(function (attributeName) {
456
- return attributeName + ":" + (prefixes[attributeName] || '') + rest[attributeName] + ";";
457
- }).join('');
458
- return computedOffset * 100 + "%{" + rules + "}";
459
- }).join('') + "}" + (selector + " {animation: " + animationName + " " + duration + "ms " + easing + " " + delay + "ms " + (iterations === Infinity ? 'infinite' : iterations) + " " + direction + " " + fill + ";}");
460
- };
461
- _proto.toDataURL = /*#__PURE__*/function () {
462
- var _toDataURL = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(options) {
463
- var _this = this;
464
- var cloneNode, doc, animationCounter, $style, svgDocType, svgDoc;
465
- return _regeneratorRuntime().wrap(function _callee$(_context) {
466
- while (1) switch (_context.prev = _context.next) {
467
- case 0:
468
- cloneNode = this.$namespace.cloneNode(true);
469
- doc = this.canvasConfig.document;
470
- animationCounter = 0;
471
- $style = null;
472
- this.context.renderingContext.root.forEach(function (object) {
473
- var animations = object.getAnimations();
474
- if (animations.length) {
475
- if (!$style) {
476
- // export animations to <style>, using CSS Transformation
477
- $style = (doc || document).createElement('style');
478
- cloneNode.appendChild($style);
479
- }
480
- // @ts-ignore
481
- var svgElement = object.elementSVG;
482
- var selfSelector = "#" + svgElement.$el.id;
483
- var groupSelector = "#" + svgElement.$groupEl.id;
484
- var selfCssText = '';
485
- var groupCssText = '';
486
- animations.forEach(function (animation) {
487
- var keyframes = animation.effect.getKeyframes();
488
- // split attributes into self and group
489
- if (keyframes.length) {
490
- var selfAttributes = [];
491
- var groupAttributes = [];
492
- var _keyframes$ = keyframes[0],
493
- offset = _keyframes$.offset,
494
- composite = _keyframes$.composite,
495
- computedOffset = _keyframes$.computedOffset,
496
- easing = _keyframes$.easing,
497
- transformOrigin = _keyframes$.transformOrigin,
498
- rest = _objectWithoutPropertiesLoose(_keyframes$, _excluded2);
499
- Object.keys(rest).forEach(function (attributeName) {
500
- var _propertyMetadataCach;
501
- if (attributeName === 'transform') {
502
- groupAttributes.push(attributeName);
503
- }
504
- var inherited = !!((_propertyMetadataCach = propertyMetadataCache[attributeName]) === null || _propertyMetadataCach === void 0 ? void 0 : _propertyMetadataCach.inh);
505
- if (inherited) {
506
- groupAttributes.push(attributeName);
507
- } else if (attributeName !== 'transform') {
508
- selfAttributes.push(attributeName);
509
- }
510
- });
511
- if (groupAttributes.length) {
512
- var keyframesWithGroup = keyframes.map(function (keyframe) {
513
- var offset = keyframe.offset,
514
- composite = keyframe.composite,
515
- computedOffset = keyframe.computedOffset,
516
- easing = keyframe.easing,
517
- transformOrigin = keyframe.transformOrigin,
518
- rest = _objectWithoutPropertiesLoose(keyframe, _excluded3);
519
- var ret = {
520
- offset: offset,
521
- composite: composite,
522
- computedOffset: computedOffset,
523
- easing: easing
524
- };
525
- Object.keys(rest).forEach(function (attributeName) {
526
- if (groupAttributes.includes(attributeName)) {
527
- ret[attributeName] = keyframe[attributeName];
528
- }
529
- });
530
- return ret;
531
- });
532
- groupCssText += _this.generateCSSText("a" + animationCounter++, groupSelector, keyframesWithGroup, animation.effect.getComputedTiming(), {
533
- transform: svgElement.$groupEl.getAttribute('transform')
534
- });
535
- }
536
- if (selfAttributes.length) {
537
- var keyframesWithSelf = keyframes.map(function (keyframe) {
538
- var offset = keyframe.offset,
539
- composite = keyframe.composite,
540
- computedOffset = keyframe.computedOffset,
541
- easing = keyframe.easing,
542
- transformOrigin = keyframe.transformOrigin,
543
- rest = _objectWithoutPropertiesLoose(keyframe, _excluded4);
544
- var ret = {
545
- offset: offset,
546
- composite: composite,
547
- computedOffset: computedOffset,
548
- easing: easing
549
- };
550
- Object.keys(rest).forEach(function (attributeName) {
551
- if (selfAttributes.includes(attributeName)) {
552
- ret[attributeName] = keyframe[attributeName];
553
- }
69
+ };
70
+ SVGContextService.prototype.generateCSSText = function (animationName, selector, keyframes, timing, prefixes) {
71
+ if (prefixes === void 0) { prefixes = {}; }
72
+ var duration = timing.duration, easing = timing.easing, delay = timing.delay, direction = timing.direction, iterations = timing.iterations, fill = timing.fill;
73
+ return ("@keyframes ".concat(animationName, "{").concat(keyframes
74
+ .map(function (keyframe) {
75
+ keyframe.offset; keyframe.composite; var computedOffset = keyframe.computedOffset; keyframe.easing; var rest = __rest(keyframe, ["offset", "composite", "computedOffset", "easing"]);
76
+ var rules = Object.keys(rest)
77
+ .map(function (attributeName) {
78
+ return "".concat(attributeName, ":").concat(prefixes[attributeName] || '').concat(rest[attributeName], ";");
79
+ })
80
+ .join('');
81
+ return "".concat(computedOffset * 100, "%{").concat(rules, "}");
82
+ })
83
+ .join(''), "}") +
84
+ "".concat(selector, " {animation: ").concat(animationName, " ").concat(duration, "ms ").concat(easing, " ").concat(delay, "ms ").concat(iterations === Infinity ? 'infinite' : iterations, " ").concat(direction, " ").concat(fill, ";}"));
85
+ };
86
+ SVGContextService.prototype.toDataURL = function (options) {
87
+ return __awaiter(this, void 0, void 0, function () {
88
+ var cloneNode, doc, animationCounter, $style, svgDocType, svgDoc;
89
+ var _this = this;
90
+ return __generator(this, function (_a) {
91
+ cloneNode = this.$namespace.cloneNode(true);
92
+ doc = this.canvasConfig.document;
93
+ animationCounter = 0;
94
+ $style = null;
95
+ this.context.renderingContext.root.forEach(function (object) {
96
+ var animations = object.getAnimations();
97
+ if (animations.length) {
98
+ if (!$style) {
99
+ // export animations to <style>, using CSS Transformation
100
+ $style = (doc || document).createElement('style');
101
+ cloneNode.appendChild($style);
102
+ }
103
+ // @ts-ignore
104
+ var svgElement_1 = object.elementSVG;
105
+ var selfSelector_1 = "#".concat(svgElement_1.$el.id);
106
+ var groupSelector_1 = "#".concat(svgElement_1.$groupEl.id);
107
+ var selfCssText_1 = '';
108
+ var groupCssText_1 = '';
109
+ animations.forEach(function (animation) {
110
+ var keyframes = animation.effect.getKeyframes();
111
+ // split attributes into self and group
112
+ if (keyframes.length) {
113
+ var selfAttributes_1 = [];
114
+ var groupAttributes_1 = [];
115
+ var _a = keyframes[0]; _a.offset; _a.composite; _a.computedOffset; _a.easing; _a.transformOrigin; var rest = __rest(_a, ["offset", "composite", "computedOffset", "easing", "transformOrigin"]);
116
+ Object.keys(rest).forEach(function (attributeName) {
117
+ var _a;
118
+ if (attributeName === 'transform') {
119
+ groupAttributes_1.push(attributeName);
120
+ }
121
+ var inherited = !!((_a = propertyMetadataCache[attributeName]) === null || _a === void 0 ? void 0 : _a.inh);
122
+ if (inherited) {
123
+ groupAttributes_1.push(attributeName);
124
+ }
125
+ else if (attributeName !== 'transform') {
126
+ selfAttributes_1.push(attributeName);
127
+ }
128
+ });
129
+ if (groupAttributes_1.length) {
130
+ var keyframesWithGroup = keyframes.map(function (keyframe) {
131
+ var offset = keyframe.offset, composite = keyframe.composite, computedOffset = keyframe.computedOffset, easing = keyframe.easing; keyframe.transformOrigin; var rest = __rest(keyframe, ["offset", "composite", "computedOffset", "easing", "transformOrigin"]);
132
+ var ret = { offset: offset, composite: composite, computedOffset: computedOffset, easing: easing };
133
+ Object.keys(rest).forEach(function (attributeName) {
134
+ if (groupAttributes_1.includes(attributeName)) {
135
+ ret[attributeName] = keyframe[attributeName];
136
+ }
137
+ });
138
+ return ret;
139
+ });
140
+ groupCssText_1 += _this.generateCSSText("a".concat(animationCounter++), groupSelector_1, keyframesWithGroup, animation.effect.getComputedTiming(), { transform: svgElement_1.$groupEl.getAttribute('transform') });
141
+ }
142
+ if (selfAttributes_1.length) {
143
+ var keyframesWithSelf = keyframes.map(function (keyframe) {
144
+ var offset = keyframe.offset, composite = keyframe.composite, computedOffset = keyframe.computedOffset, easing = keyframe.easing; keyframe.transformOrigin; var rest = __rest(keyframe, ["offset", "composite", "computedOffset", "easing", "transformOrigin"]);
145
+ var ret = { offset: offset, composite: composite, computedOffset: computedOffset, easing: easing };
146
+ Object.keys(rest).forEach(function (attributeName) {
147
+ if (selfAttributes_1.includes(attributeName)) {
148
+ ret[attributeName] = keyframe[attributeName];
149
+ }
150
+ });
151
+ return ret;
152
+ });
153
+ selfCssText_1 += _this.generateCSSText("a".concat(animationCounter++), selfSelector_1, keyframesWithSelf, animation.effect.getComputedTiming());
154
+ }
155
+ }
554
156
  });
555
- return ret;
556
- });
557
- selfCssText += _this.generateCSSText("a" + animationCounter++, selfSelector, keyframesWithSelf, animation.effect.getComputedTiming());
157
+ $style.textContent += selfCssText_1 + groupCssText_1;
558
158
  }
559
- }
560
159
  });
561
- $style.textContent += selfCssText + groupCssText;
562
- }
160
+ svgDocType = document.implementation.createDocumentType('svg', '-//W3C//DTD SVG 1.1//EN', 'http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd');
161
+ svgDoc = document.implementation.createDocument('http://www.w3.org/2000/svg', 'svg', svgDocType);
162
+ svgDoc.replaceChild(cloneNode, svgDoc.documentElement);
163
+ return [2 /*return*/, "data:image/svg+xml;charset=utf8,".concat(encodeURIComponent(new XMLSerializer().serializeToString(svgDoc)))];
563
164
  });
564
- svgDocType = document.implementation.createDocumentType('svg', '-//W3C//DTD SVG 1.1//EN', 'http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd');
565
- svgDoc = document.implementation.createDocument('http://www.w3.org/2000/svg', 'svg', svgDocType);
566
- svgDoc.replaceChild(cloneNode, svgDoc.documentElement);
567
- return _context.abrupt("return", "data:image/svg+xml;charset=utf8," + encodeURIComponent(new XMLSerializer().serializeToString(svgDoc)));
568
- case 10:
569
- case "end":
570
- return _context.stop();
571
- }
572
- }, _callee, this);
573
- }));
574
- function toDataURL(_x) {
575
- return _toDataURL.apply(this, arguments);
576
- }
577
- return toDataURL;
578
- }();
579
- return SVGContextService;
580
- }();
165
+ });
166
+ };
167
+ return SVGContextService;
168
+ }());
581
169
 
582
- var ContextRegisterPlugin = /*#__PURE__*/function (_AbstractRendererPlug) {
583
- _inheritsLoose(ContextRegisterPlugin, _AbstractRendererPlug);
584
- function ContextRegisterPlugin() {
585
- var _this;
586
- for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
587
- args[_key] = arguments[_key];
170
+ var ContextRegisterPlugin = /** @class */ (function (_super) {
171
+ __extends(ContextRegisterPlugin, _super);
172
+ function ContextRegisterPlugin() {
173
+ var _this = _super !== null && _super.apply(this, arguments) || this;
174
+ _this.name = 'svg-context-register';
175
+ return _this;
588
176
  }
589
- _this = _AbstractRendererPlug.call.apply(_AbstractRendererPlug, [this].concat(args)) || this;
590
- _this.name = 'svg-context-register';
591
- return _this;
592
- }
593
- var _proto = ContextRegisterPlugin.prototype;
594
- _proto.init = function init() {
595
- // @ts-ignore
596
- this.context.ContextService = SVGContextService;
597
- };
598
- _proto.destroy = function destroy() {
599
- delete this.context.ContextService;
600
- };
601
- return ContextRegisterPlugin;
602
- }(AbstractRendererPlugin);
177
+ ContextRegisterPlugin.prototype.init = function () {
178
+ // @ts-ignore
179
+ this.context.ContextService = SVGContextService;
180
+ };
181
+ ContextRegisterPlugin.prototype.destroy = function () {
182
+ delete this.context.ContextService;
183
+ };
184
+ return ContextRegisterPlugin;
185
+ }(AbstractRendererPlugin));
603
186
 
604
- var Renderer = /*#__PURE__*/function (_AbstractRenderer) {
605
- _inheritsLoose(Renderer, _AbstractRenderer);
606
- function Renderer(config) {
607
- var _this;
608
- if (config === void 0) {
609
- config = {};
187
+ var Renderer = /** @class */ (function (_super) {
188
+ __extends(Renderer, _super);
189
+ function Renderer(config) {
190
+ if (config === void 0) { config = {}; }
191
+ var _this = _super.call(this, config) || this;
192
+ _this.registerPlugin(new ContextRegisterPlugin());
193
+ _this.registerPlugin(new SVGRenderer.Plugin({
194
+ outputSVGElementId: config.outputSVGElementId,
195
+ }));
196
+ _this.registerPlugin(new DomInteraction.Plugin());
197
+ _this.registerPlugin(new SVGPicker.Plugin());
198
+ return _this;
610
199
  }
611
- _this = _AbstractRenderer.call(this, config) || this;
612
- _this.registerPlugin(new ContextRegisterPlugin());
613
- _this.registerPlugin(new Plugin({
614
- outputSVGElementId: config.outputSVGElementId
615
- }));
616
- _this.registerPlugin(new Plugin$1());
617
- _this.registerPlugin(new Plugin$2());
618
- return _this;
619
- }
620
- return Renderer;
621
- }(AbstractRenderer);
200
+ return Renderer;
201
+ }(AbstractRenderer));
622
202
 
623
203
  export { Renderer };
204
+ //# sourceMappingURL=index.esm.js.map