@antv/g-svg 1.8.29 → 1.8.31
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/SVGContextService.d.ts +2 -0
- package/dist/SVGContextService.d.ts.map +1 -1
- package/dist/index.esm.js +240 -222
- package/dist/index.js +239 -221
- package/dist/index.umd.js +1196 -1640
- package/dist/index.umd.min.js +1 -1
- package/package.json +5 -5
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { CanvasContext, DataURLOptions, GlobalRuntime, ContextService } from '@antv/g-lite';
|
|
2
2
|
export declare class SVGContextService implements ContextService<SVGElement> {
|
|
3
|
+
context: GlobalRuntime & CanvasContext;
|
|
3
4
|
private $container;
|
|
4
5
|
private $namespace;
|
|
5
6
|
private dpr;
|
|
@@ -13,6 +14,7 @@ export declare class SVGContextService implements ContextService<SVGElement> {
|
|
|
13
14
|
destroy(): void;
|
|
14
15
|
resize(width: number, height: number): void;
|
|
15
16
|
applyCursorStyle(cursor: string): void;
|
|
17
|
+
private generateCSSText;
|
|
16
18
|
toDataURL(options?: Partial<DataURLOptions>): Promise<string>;
|
|
17
19
|
}
|
|
18
20
|
//# sourceMappingURL=SVGContextService.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SVGContextService.d.ts","sourceRoot":"","sources":["../src/SVGContextService.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,aAAa,EACb,cAAc,EACd,aAAa,EAEb,cAAc,
|
|
1
|
+
{"version":3,"file":"SVGContextService.d.ts","sourceRoot":"","sources":["../src/SVGContextService.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,aAAa,EACb,cAAc,EACd,aAAa,EAEb,cAAc,EAEf,MAAM,cAAc,CAAC;AAKtB,qBAAa,iBAAkB,YAAW,cAAc,CAAC,UAAU,CAAC;IAO/C,OAAO,EAAE,aAAa,GAAG,aAAa;IANzD,OAAO,CAAC,UAAU,CAAqB;IACvC,OAAO,CAAC,UAAU,CAAoB;IACtC,OAAO,CAAC,GAAG,CAAS;IAEpB,OAAO,CAAC,YAAY,CAAwB;gBAEzB,OAAO,EAAE,aAAa,GAAG,aAAa;IAInD,IAAI;IA2BV,aAAa;IAIb,UAAU;IAIV,MAAM;IAIN,qBAAqB;IAIrB,OAAO;IAOP,MAAM,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM;IAQpC,gBAAgB,CAAC,MAAM,EAAE,MAAM;IAM/B,OAAO,CAAC,eAAe;IA8BjB,SAAS,CAAC,OAAO,GAAE,OAAO,CAAC,cAAc,CAAM;CAgItD"}
|
package/dist/index.esm.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { isBrowser, AbstractRendererPlugin, AbstractRenderer } from '@antv/g-lite';
|
|
1
|
+
import { propertyMetadataCache, isBrowser, AbstractRendererPlugin, AbstractRenderer } from '@antv/g-lite';
|
|
2
2
|
import { Plugin as Plugin$1 } from '@antv/g-plugin-dom-interaction';
|
|
3
3
|
import * as DomInteraction from '@antv/g-plugin-dom-interaction';
|
|
4
4
|
export { DomInteraction };
|
|
@@ -341,49 +341,10 @@ function _asyncToGenerator(fn) {
|
|
|
341
341
|
});
|
|
342
342
|
};
|
|
343
343
|
}
|
|
344
|
-
function
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
}
|
|
349
|
-
function _defineProperties(target, props) {
|
|
350
|
-
for (var i = 0; i < props.length; i++) {
|
|
351
|
-
var descriptor = props[i];
|
|
352
|
-
descriptor.enumerable = descriptor.enumerable || false;
|
|
353
|
-
descriptor.configurable = true;
|
|
354
|
-
if ("value" in descriptor) descriptor.writable = true;
|
|
355
|
-
Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor);
|
|
356
|
-
}
|
|
357
|
-
}
|
|
358
|
-
function _createClass(Constructor, protoProps, staticProps) {
|
|
359
|
-
if (protoProps) _defineProperties(Constructor.prototype, protoProps);
|
|
360
|
-
if (staticProps) _defineProperties(Constructor, staticProps);
|
|
361
|
-
Object.defineProperty(Constructor, "prototype", {
|
|
362
|
-
writable: false
|
|
363
|
-
});
|
|
364
|
-
return Constructor;
|
|
365
|
-
}
|
|
366
|
-
function _inherits(subClass, superClass) {
|
|
367
|
-
if (typeof superClass !== "function" && superClass !== null) {
|
|
368
|
-
throw new TypeError("Super expression must either be null or a function");
|
|
369
|
-
}
|
|
370
|
-
subClass.prototype = Object.create(superClass && superClass.prototype, {
|
|
371
|
-
constructor: {
|
|
372
|
-
value: subClass,
|
|
373
|
-
writable: true,
|
|
374
|
-
configurable: true
|
|
375
|
-
}
|
|
376
|
-
});
|
|
377
|
-
Object.defineProperty(subClass, "prototype", {
|
|
378
|
-
writable: false
|
|
379
|
-
});
|
|
380
|
-
if (superClass) _setPrototypeOf(subClass, superClass);
|
|
381
|
-
}
|
|
382
|
-
function _getPrototypeOf(o) {
|
|
383
|
-
_getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) {
|
|
384
|
-
return o.__proto__ || Object.getPrototypeOf(o);
|
|
385
|
-
};
|
|
386
|
-
return _getPrototypeOf(o);
|
|
344
|
+
function _inheritsLoose(subClass, superClass) {
|
|
345
|
+
subClass.prototype = Object.create(superClass.prototype);
|
|
346
|
+
subClass.prototype.constructor = subClass;
|
|
347
|
+
_setPrototypeOf(subClass, superClass);
|
|
387
348
|
}
|
|
388
349
|
function _setPrototypeOf(o, p) {
|
|
389
350
|
_setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) {
|
|
@@ -392,219 +353,276 @@ function _setPrototypeOf(o, p) {
|
|
|
392
353
|
};
|
|
393
354
|
return _setPrototypeOf(o, p);
|
|
394
355
|
}
|
|
395
|
-
function
|
|
396
|
-
if (
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
}
|
|
405
|
-
}
|
|
406
|
-
function _assertThisInitialized(self) {
|
|
407
|
-
if (self === void 0) {
|
|
408
|
-
throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
|
|
409
|
-
}
|
|
410
|
-
return self;
|
|
411
|
-
}
|
|
412
|
-
function _possibleConstructorReturn(self, call) {
|
|
413
|
-
if (call && (typeof call === "object" || typeof call === "function")) {
|
|
414
|
-
return call;
|
|
415
|
-
} else if (call !== void 0) {
|
|
416
|
-
throw new TypeError("Derived constructors may only return object or undefined");
|
|
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];
|
|
417
365
|
}
|
|
418
|
-
return
|
|
419
|
-
}
|
|
420
|
-
function _createSuper(Derived) {
|
|
421
|
-
var hasNativeReflectConstruct = _isNativeReflectConstruct();
|
|
422
|
-
return function _createSuperInternal() {
|
|
423
|
-
var Super = _getPrototypeOf(Derived),
|
|
424
|
-
result;
|
|
425
|
-
if (hasNativeReflectConstruct) {
|
|
426
|
-
var NewTarget = _getPrototypeOf(this).constructor;
|
|
427
|
-
result = Reflect.construct(Super, arguments, NewTarget);
|
|
428
|
-
} else {
|
|
429
|
-
result = Super.apply(this, arguments);
|
|
430
|
-
}
|
|
431
|
-
return _possibleConstructorReturn(this, result);
|
|
432
|
-
};
|
|
433
|
-
}
|
|
434
|
-
function _toPrimitive(input, hint) {
|
|
435
|
-
if (typeof input !== "object" || input === null) return input;
|
|
436
|
-
var prim = input[Symbol.toPrimitive];
|
|
437
|
-
if (prim !== undefined) {
|
|
438
|
-
var res = prim.call(input, hint || "default");
|
|
439
|
-
if (typeof res !== "object") return res;
|
|
440
|
-
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
441
|
-
}
|
|
442
|
-
return (hint === "string" ? String : Number)(input);
|
|
443
|
-
}
|
|
444
|
-
function _toPropertyKey(arg) {
|
|
445
|
-
var key = _toPrimitive(arg, "string");
|
|
446
|
-
return typeof key === "symbol" ? key : String(key);
|
|
366
|
+
return target;
|
|
447
367
|
}
|
|
448
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"];
|
|
449
373
|
var SVGContextService = /*#__PURE__*/function () {
|
|
450
374
|
function SVGContextService(context) {
|
|
451
|
-
|
|
375
|
+
this.context = void 0;
|
|
452
376
|
this.$container = void 0;
|
|
453
377
|
this.$namespace = void 0;
|
|
454
378
|
this.dpr = void 0;
|
|
455
379
|
this.canvasConfig = void 0;
|
|
380
|
+
this.context = context;
|
|
456
381
|
this.canvasConfig = context.config;
|
|
457
382
|
}
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
var
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
if (this.$container) {
|
|
470
|
-
|
|
471
|
-
this.$container.style.position = 'relative';
|
|
472
|
-
}
|
|
473
|
-
$namespace = createSVGElement('svg', doc);
|
|
474
|
-
$namespace.setAttribute('width', "".concat(this.canvasConfig.width));
|
|
475
|
-
$namespace.setAttribute('height', "".concat(this.canvasConfig.height));
|
|
476
|
-
this.$container.appendChild($namespace);
|
|
477
|
-
this.$namespace = $namespace;
|
|
383
|
+
var _proto = SVGContextService.prototype;
|
|
384
|
+
_proto.init = /*#__PURE__*/function () {
|
|
385
|
+
var _init = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
386
|
+
var _this$canvasConfig, container, doc, devicePixelRatio, $namespace, dpr;
|
|
387
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
388
|
+
while (1) {
|
|
389
|
+
switch (_context.prev = _context.next) {
|
|
390
|
+
case 0:
|
|
391
|
+
_this$canvasConfig = this.canvasConfig, container = _this$canvasConfig.container, doc = _this$canvasConfig.document, devicePixelRatio = _this$canvasConfig.devicePixelRatio; // create container
|
|
392
|
+
this.$container = isString(container) ? (doc || document).getElementById(container) : container;
|
|
393
|
+
if (this.$container) {
|
|
394
|
+
if (!this.$container.style.position) {
|
|
395
|
+
this.$container.style.position = 'relative';
|
|
478
396
|
}
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
this.
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
397
|
+
$namespace = createSVGElement('svg', doc);
|
|
398
|
+
$namespace.setAttribute('width', "" + this.canvasConfig.width);
|
|
399
|
+
$namespace.setAttribute('height', "" + this.canvasConfig.height);
|
|
400
|
+
this.$container.appendChild($namespace);
|
|
401
|
+
this.$namespace = $namespace;
|
|
402
|
+
}
|
|
403
|
+
// use user-defined dpr first
|
|
404
|
+
dpr = devicePixelRatio || isBrowser && window.devicePixelRatio || 1;
|
|
405
|
+
dpr = dpr >= 1 ? Math.ceil(dpr) : 1;
|
|
406
|
+
this.dpr = dpr;
|
|
407
|
+
case 6:
|
|
408
|
+
case "end":
|
|
409
|
+
return _context.stop();
|
|
487
410
|
}
|
|
488
|
-
}
|
|
489
|
-
})
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
return init;
|
|
494
|
-
}() // @ts-ignore
|
|
495
|
-
}, {
|
|
496
|
-
key: "getDomElement",
|
|
497
|
-
value: function getDomElement() {
|
|
498
|
-
return this.$namespace;
|
|
499
|
-
}
|
|
500
|
-
}, {
|
|
501
|
-
key: "getContext",
|
|
502
|
-
value: function getContext() {
|
|
503
|
-
return this.$namespace;
|
|
504
|
-
}
|
|
505
|
-
}, {
|
|
506
|
-
key: "getDPR",
|
|
507
|
-
value: function getDPR() {
|
|
508
|
-
return this.dpr;
|
|
411
|
+
}
|
|
412
|
+
}, _callee, this);
|
|
413
|
+
}));
|
|
414
|
+
function init() {
|
|
415
|
+
return _init.apply(this, arguments);
|
|
509
416
|
}
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
417
|
+
return init;
|
|
418
|
+
}() // @ts-ignore
|
|
419
|
+
;
|
|
420
|
+
_proto.getDomElement = function getDomElement() {
|
|
421
|
+
return this.$namespace;
|
|
422
|
+
};
|
|
423
|
+
_proto.getContext = function getContext() {
|
|
424
|
+
return this.$namespace;
|
|
425
|
+
};
|
|
426
|
+
_proto.getDPR = function getDPR() {
|
|
427
|
+
return this.dpr;
|
|
428
|
+
};
|
|
429
|
+
_proto.getBoundingClientRect = function getBoundingClientRect() {
|
|
430
|
+
var _this$$namespace;
|
|
431
|
+
return (_this$$namespace = this.$namespace) === null || _this$$namespace === void 0 ? void 0 : _this$$namespace.getBoundingClientRect();
|
|
432
|
+
};
|
|
433
|
+
_proto.destroy = function destroy() {
|
|
434
|
+
// destroy context
|
|
435
|
+
if (this.$container && this.$namespace && this.$namespace.parentNode) {
|
|
436
|
+
this.$container.removeChild(this.$namespace);
|
|
515
437
|
}
|
|
516
|
-
}
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
}
|
|
438
|
+
};
|
|
439
|
+
_proto.resize = function resize(width, height) {
|
|
440
|
+
// SVG should ignore DPR
|
|
441
|
+
if (this.$namespace) {
|
|
442
|
+
this.$namespace.setAttribute('width', "" + width);
|
|
443
|
+
this.$namespace.setAttribute('height', "" + height);
|
|
523
444
|
}
|
|
524
|
-
}
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
if (this.$namespace) {
|
|
529
|
-
this.$namespace.setAttribute('width', "".concat(width));
|
|
530
|
-
this.$namespace.setAttribute('height', "".concat(height));
|
|
531
|
-
}
|
|
445
|
+
};
|
|
446
|
+
_proto.applyCursorStyle = function applyCursorStyle(cursor) {
|
|
447
|
+
if (this.$container) {
|
|
448
|
+
this.$container.style.cursor = cursor;
|
|
532
449
|
}
|
|
533
|
-
}
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
this.$container.style.cursor = cursor;
|
|
538
|
-
}
|
|
450
|
+
};
|
|
451
|
+
_proto.generateCSSText = function generateCSSText(animationName, selector, keyframes, timing, prefixes) {
|
|
452
|
+
if (prefixes === void 0) {
|
|
453
|
+
prefixes = {};
|
|
539
454
|
}
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
455
|
+
var duration = timing.duration,
|
|
456
|
+
easing = timing.easing,
|
|
457
|
+
delay = timing.delay,
|
|
458
|
+
direction = timing.direction,
|
|
459
|
+
iterations = timing.iterations,
|
|
460
|
+
fill = timing.fill;
|
|
461
|
+
return "@keyframes " + animationName + "{" + keyframes.map(function (keyframe) {
|
|
462
|
+
var offset = keyframe.offset,
|
|
463
|
+
composite = keyframe.composite,
|
|
464
|
+
computedOffset = keyframe.computedOffset,
|
|
465
|
+
easing = keyframe.easing,
|
|
466
|
+
rest = _objectWithoutPropertiesLoose(keyframe, _excluded);
|
|
467
|
+
var rules = Object.keys(rest).map(function (attributeName) {
|
|
468
|
+
return attributeName + ":" + (prefixes[attributeName] || '') + rest[attributeName] + ";";
|
|
469
|
+
}).join('');
|
|
470
|
+
return computedOffset * 100 + "%{" + rules + "}";
|
|
471
|
+
}).join('') + "}" + (selector + " {animation: " + animationName + " " + duration + "ms " + easing + " " + delay + "ms " + (iterations === Infinity ? 'infinite' : iterations) + " " + direction + " " + fill + ";}");
|
|
472
|
+
};
|
|
473
|
+
_proto.toDataURL = /*#__PURE__*/function () {
|
|
474
|
+
var _toDataURL = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(options) {
|
|
475
|
+
var _this = this;
|
|
476
|
+
var cloneNode, doc, animationCounter, $style, svgDocType, svgDoc;
|
|
477
|
+
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
478
|
+
while (1) {
|
|
479
|
+
switch (_context2.prev = _context2.next) {
|
|
480
|
+
case 0:
|
|
481
|
+
cloneNode = this.$namespace.cloneNode(true);
|
|
482
|
+
doc = this.canvasConfig.document;
|
|
483
|
+
animationCounter = 0;
|
|
484
|
+
$style = null;
|
|
485
|
+
this.context.renderingContext.root.forEach(function (object) {
|
|
486
|
+
var animations = object.getAnimations();
|
|
487
|
+
if (animations.length) {
|
|
488
|
+
if (!$style) {
|
|
489
|
+
// export animations to <style>, using CSS Transformation
|
|
490
|
+
$style = (doc || document).createElement('style');
|
|
491
|
+
cloneNode.appendChild($style);
|
|
492
|
+
}
|
|
493
|
+
// @ts-ignore
|
|
494
|
+
var svgElement = object.elementSVG;
|
|
495
|
+
var selfSelector = "#" + svgElement.$el.id;
|
|
496
|
+
var groupSelector = "#" + svgElement.$groupEl.id;
|
|
497
|
+
var selfCssText = '';
|
|
498
|
+
var groupCssText = '';
|
|
499
|
+
animations.forEach(function (animation) {
|
|
500
|
+
var keyframes = animation.effect.getKeyframes();
|
|
501
|
+
// split attributes into self and group
|
|
502
|
+
if (keyframes.length) {
|
|
503
|
+
var selfAttributes = [];
|
|
504
|
+
var groupAttributes = [];
|
|
505
|
+
var _keyframes$ = keyframes[0],
|
|
506
|
+
offset = _keyframes$.offset,
|
|
507
|
+
composite = _keyframes$.composite,
|
|
508
|
+
computedOffset = _keyframes$.computedOffset,
|
|
509
|
+
easing = _keyframes$.easing,
|
|
510
|
+
transformOrigin = _keyframes$.transformOrigin,
|
|
511
|
+
rest = _objectWithoutPropertiesLoose(_keyframes$, _excluded2);
|
|
512
|
+
Object.keys(rest).forEach(function (attributeName) {
|
|
513
|
+
var _propertyMetadataCach;
|
|
514
|
+
if (attributeName === 'transform') {
|
|
515
|
+
groupAttributes.push(attributeName);
|
|
516
|
+
}
|
|
517
|
+
var inherited = !!((_propertyMetadataCach = propertyMetadataCache[attributeName]) === null || _propertyMetadataCach === void 0 ? void 0 : _propertyMetadataCach.inh);
|
|
518
|
+
if (inherited) {
|
|
519
|
+
groupAttributes.push(attributeName);
|
|
520
|
+
} else if (attributeName !== 'transform') {
|
|
521
|
+
selfAttributes.push(attributeName);
|
|
522
|
+
}
|
|
523
|
+
});
|
|
524
|
+
if (groupAttributes.length) {
|
|
525
|
+
var keyframesWithGroup = keyframes.map(function (keyframe) {
|
|
526
|
+
var offset = keyframe.offset,
|
|
527
|
+
composite = keyframe.composite,
|
|
528
|
+
computedOffset = keyframe.computedOffset,
|
|
529
|
+
easing = keyframe.easing,
|
|
530
|
+
transformOrigin = keyframe.transformOrigin,
|
|
531
|
+
rest = _objectWithoutPropertiesLoose(keyframe, _excluded3);
|
|
532
|
+
var ret = {
|
|
533
|
+
offset: offset,
|
|
534
|
+
composite: composite,
|
|
535
|
+
computedOffset: computedOffset,
|
|
536
|
+
easing: easing
|
|
537
|
+
};
|
|
538
|
+
Object.keys(rest).forEach(function (attributeName) {
|
|
539
|
+
if (groupAttributes.includes(attributeName)) {
|
|
540
|
+
ret[attributeName] = keyframe[attributeName];
|
|
541
|
+
}
|
|
542
|
+
});
|
|
543
|
+
return ret;
|
|
544
|
+
});
|
|
545
|
+
groupCssText += _this.generateCSSText("a" + animationCounter++, groupSelector, keyframesWithGroup, animation.effect.getComputedTiming(), {
|
|
546
|
+
transform: svgElement.$groupEl.getAttribute('transform')
|
|
547
|
+
});
|
|
548
|
+
}
|
|
549
|
+
if (selfAttributes.length) {
|
|
550
|
+
var keyframesWithSelf = keyframes.map(function (keyframe) {
|
|
551
|
+
var offset = keyframe.offset,
|
|
552
|
+
composite = keyframe.composite,
|
|
553
|
+
computedOffset = keyframe.computedOffset,
|
|
554
|
+
easing = keyframe.easing,
|
|
555
|
+
transformOrigin = keyframe.transformOrigin,
|
|
556
|
+
rest = _objectWithoutPropertiesLoose(keyframe, _excluded4);
|
|
557
|
+
var ret = {
|
|
558
|
+
offset: offset,
|
|
559
|
+
composite: composite,
|
|
560
|
+
computedOffset: computedOffset,
|
|
561
|
+
easing: easing
|
|
562
|
+
};
|
|
563
|
+
Object.keys(rest).forEach(function (attributeName) {
|
|
564
|
+
if (selfAttributes.includes(attributeName)) {
|
|
565
|
+
ret[attributeName] = keyframe[attributeName];
|
|
566
|
+
}
|
|
567
|
+
});
|
|
568
|
+
return ret;
|
|
569
|
+
});
|
|
570
|
+
selfCssText += _this.generateCSSText("a" + animationCounter++, selfSelector, keyframesWithSelf, animation.effect.getComputedTiming());
|
|
571
|
+
}
|
|
572
|
+
}
|
|
573
|
+
});
|
|
574
|
+
$style.textContent += selfCssText + groupCssText;
|
|
575
|
+
}
|
|
576
|
+
});
|
|
577
|
+
svgDocType = document.implementation.createDocumentType('svg', '-//W3C//DTD SVG 1.1//EN', 'http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd');
|
|
578
|
+
svgDoc = document.implementation.createDocument('http://www.w3.org/2000/svg', 'svg', svgDocType);
|
|
579
|
+
svgDoc.replaceChild(cloneNode, svgDoc.documentElement);
|
|
580
|
+
return _context2.abrupt("return", "data:image/svg+xml;charset=utf8," + encodeURIComponent(new XMLSerializer().serializeToString(svgDoc)));
|
|
581
|
+
case 10:
|
|
582
|
+
case "end":
|
|
583
|
+
return _context2.stop();
|
|
560
584
|
}
|
|
561
|
-
}
|
|
562
|
-
})
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
}
|
|
585
|
+
}
|
|
586
|
+
}, _callee2, this);
|
|
587
|
+
}));
|
|
588
|
+
function toDataURL(_x) {
|
|
589
|
+
return _toDataURL.apply(this, arguments);
|
|
590
|
+
}
|
|
591
|
+
return toDataURL;
|
|
592
|
+
}();
|
|
569
593
|
return SVGContextService;
|
|
570
594
|
}();
|
|
571
595
|
|
|
572
596
|
var ContextRegisterPlugin = /*#__PURE__*/function (_AbstractRendererPlug) {
|
|
573
|
-
|
|
574
|
-
var _super = _createSuper(ContextRegisterPlugin);
|
|
597
|
+
_inheritsLoose(ContextRegisterPlugin, _AbstractRendererPlug);
|
|
575
598
|
function ContextRegisterPlugin() {
|
|
576
599
|
var _this;
|
|
577
|
-
_classCallCheck(this, ContextRegisterPlugin);
|
|
578
600
|
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
579
601
|
args[_key] = arguments[_key];
|
|
580
602
|
}
|
|
581
|
-
_this =
|
|
603
|
+
_this = _AbstractRendererPlug.call.apply(_AbstractRendererPlug, [this].concat(args)) || this;
|
|
582
604
|
_this.name = 'svg-context-register';
|
|
583
605
|
return _this;
|
|
584
606
|
}
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
value: function destroy() {
|
|
594
|
-
delete this.context.ContextService;
|
|
595
|
-
}
|
|
596
|
-
}]);
|
|
607
|
+
var _proto = ContextRegisterPlugin.prototype;
|
|
608
|
+
_proto.init = function init() {
|
|
609
|
+
// @ts-ignore
|
|
610
|
+
this.context.ContextService = SVGContextService;
|
|
611
|
+
};
|
|
612
|
+
_proto.destroy = function destroy() {
|
|
613
|
+
delete this.context.ContextService;
|
|
614
|
+
};
|
|
597
615
|
return ContextRegisterPlugin;
|
|
598
616
|
}(AbstractRendererPlugin);
|
|
599
617
|
|
|
600
618
|
var Renderer = /*#__PURE__*/function (_AbstractRenderer) {
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
function Renderer() {
|
|
619
|
+
_inheritsLoose(Renderer, _AbstractRenderer);
|
|
620
|
+
function Renderer(config) {
|
|
604
621
|
var _this;
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
622
|
+
if (config === void 0) {
|
|
623
|
+
config = {};
|
|
624
|
+
}
|
|
625
|
+
_this = _AbstractRenderer.call(this, config) || this;
|
|
608
626
|
_this.registerPlugin(new ContextRegisterPlugin());
|
|
609
627
|
_this.registerPlugin(new Plugin({
|
|
610
628
|
outputSVGElementId: config.outputSVGElementId
|
|
@@ -613,7 +631,7 @@ var Renderer = /*#__PURE__*/function (_AbstractRenderer) {
|
|
|
613
631
|
_this.registerPlugin(new Plugin$2());
|
|
614
632
|
return _this;
|
|
615
633
|
}
|
|
616
|
-
return
|
|
634
|
+
return Renderer;
|
|
617
635
|
}(AbstractRenderer);
|
|
618
636
|
|
|
619
637
|
export { Renderer };
|