@antv/g-svg 1.8.28 → 1.8.29
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 +224 -106
- package/dist/index.js +224 -106
- package/dist/index.umd.js +1644 -1054
- package/dist/index.umd.min.js +1 -1
- package/package.json +5 -5
package/dist/index.js
CHANGED
|
@@ -363,10 +363,49 @@ function _asyncToGenerator(fn) {
|
|
|
363
363
|
});
|
|
364
364
|
};
|
|
365
365
|
}
|
|
366
|
-
function
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
366
|
+
function _classCallCheck(instance, Constructor) {
|
|
367
|
+
if (!(instance instanceof Constructor)) {
|
|
368
|
+
throw new TypeError("Cannot call a class as a function");
|
|
369
|
+
}
|
|
370
|
+
}
|
|
371
|
+
function _defineProperties(target, props) {
|
|
372
|
+
for (var i = 0; i < props.length; i++) {
|
|
373
|
+
var descriptor = props[i];
|
|
374
|
+
descriptor.enumerable = descriptor.enumerable || false;
|
|
375
|
+
descriptor.configurable = true;
|
|
376
|
+
if ("value" in descriptor) descriptor.writable = true;
|
|
377
|
+
Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor);
|
|
378
|
+
}
|
|
379
|
+
}
|
|
380
|
+
function _createClass(Constructor, protoProps, staticProps) {
|
|
381
|
+
if (protoProps) _defineProperties(Constructor.prototype, protoProps);
|
|
382
|
+
if (staticProps) _defineProperties(Constructor, staticProps);
|
|
383
|
+
Object.defineProperty(Constructor, "prototype", {
|
|
384
|
+
writable: false
|
|
385
|
+
});
|
|
386
|
+
return Constructor;
|
|
387
|
+
}
|
|
388
|
+
function _inherits(subClass, superClass) {
|
|
389
|
+
if (typeof superClass !== "function" && superClass !== null) {
|
|
390
|
+
throw new TypeError("Super expression must either be null or a function");
|
|
391
|
+
}
|
|
392
|
+
subClass.prototype = Object.create(superClass && superClass.prototype, {
|
|
393
|
+
constructor: {
|
|
394
|
+
value: subClass,
|
|
395
|
+
writable: true,
|
|
396
|
+
configurable: true
|
|
397
|
+
}
|
|
398
|
+
});
|
|
399
|
+
Object.defineProperty(subClass, "prototype", {
|
|
400
|
+
writable: false
|
|
401
|
+
});
|
|
402
|
+
if (superClass) _setPrototypeOf(subClass, superClass);
|
|
403
|
+
}
|
|
404
|
+
function _getPrototypeOf(o) {
|
|
405
|
+
_getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) {
|
|
406
|
+
return o.__proto__ || Object.getPrototypeOf(o);
|
|
407
|
+
};
|
|
408
|
+
return _getPrototypeOf(o);
|
|
370
409
|
}
|
|
371
410
|
function _setPrototypeOf(o, p) {
|
|
372
411
|
_setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) {
|
|
@@ -375,140 +414,219 @@ function _setPrototypeOf(o, p) {
|
|
|
375
414
|
};
|
|
376
415
|
return _setPrototypeOf(o, p);
|
|
377
416
|
}
|
|
417
|
+
function _isNativeReflectConstruct() {
|
|
418
|
+
if (typeof Reflect === "undefined" || !Reflect.construct) return false;
|
|
419
|
+
if (Reflect.construct.sham) return false;
|
|
420
|
+
if (typeof Proxy === "function") return true;
|
|
421
|
+
try {
|
|
422
|
+
Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {}));
|
|
423
|
+
return true;
|
|
424
|
+
} catch (e) {
|
|
425
|
+
return false;
|
|
426
|
+
}
|
|
427
|
+
}
|
|
428
|
+
function _assertThisInitialized(self) {
|
|
429
|
+
if (self === void 0) {
|
|
430
|
+
throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
|
|
431
|
+
}
|
|
432
|
+
return self;
|
|
433
|
+
}
|
|
434
|
+
function _possibleConstructorReturn(self, call) {
|
|
435
|
+
if (call && (typeof call === "object" || typeof call === "function")) {
|
|
436
|
+
return call;
|
|
437
|
+
} else if (call !== void 0) {
|
|
438
|
+
throw new TypeError("Derived constructors may only return object or undefined");
|
|
439
|
+
}
|
|
440
|
+
return _assertThisInitialized(self);
|
|
441
|
+
}
|
|
442
|
+
function _createSuper(Derived) {
|
|
443
|
+
var hasNativeReflectConstruct = _isNativeReflectConstruct();
|
|
444
|
+
return function _createSuperInternal() {
|
|
445
|
+
var Super = _getPrototypeOf(Derived),
|
|
446
|
+
result;
|
|
447
|
+
if (hasNativeReflectConstruct) {
|
|
448
|
+
var NewTarget = _getPrototypeOf(this).constructor;
|
|
449
|
+
result = Reflect.construct(Super, arguments, NewTarget);
|
|
450
|
+
} else {
|
|
451
|
+
result = Super.apply(this, arguments);
|
|
452
|
+
}
|
|
453
|
+
return _possibleConstructorReturn(this, result);
|
|
454
|
+
};
|
|
455
|
+
}
|
|
456
|
+
function _toPrimitive(input, hint) {
|
|
457
|
+
if (typeof input !== "object" || input === null) return input;
|
|
458
|
+
var prim = input[Symbol.toPrimitive];
|
|
459
|
+
if (prim !== undefined) {
|
|
460
|
+
var res = prim.call(input, hint || "default");
|
|
461
|
+
if (typeof res !== "object") return res;
|
|
462
|
+
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
463
|
+
}
|
|
464
|
+
return (hint === "string" ? String : Number)(input);
|
|
465
|
+
}
|
|
466
|
+
function _toPropertyKey(arg) {
|
|
467
|
+
var key = _toPrimitive(arg, "string");
|
|
468
|
+
return typeof key === "symbol" ? key : String(key);
|
|
469
|
+
}
|
|
378
470
|
|
|
379
471
|
var SVGContextService = /*#__PURE__*/function () {
|
|
380
472
|
function SVGContextService(context) {
|
|
473
|
+
_classCallCheck(this, SVGContextService);
|
|
381
474
|
this.$container = void 0;
|
|
382
475
|
this.$namespace = void 0;
|
|
383
476
|
this.dpr = void 0;
|
|
384
477
|
this.canvasConfig = void 0;
|
|
385
478
|
this.canvasConfig = context.config;
|
|
386
479
|
}
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
var
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
if (
|
|
399
|
-
this.$container.style.position
|
|
480
|
+
_createClass(SVGContextService, [{
|
|
481
|
+
key: "init",
|
|
482
|
+
value: function () {
|
|
483
|
+
var _init = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
484
|
+
var _this$canvasConfig, container, doc, devicePixelRatio, $namespace, dpr;
|
|
485
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
486
|
+
while (1) {
|
|
487
|
+
switch (_context.prev = _context.next) {
|
|
488
|
+
case 0:
|
|
489
|
+
_this$canvasConfig = this.canvasConfig, container = _this$canvasConfig.container, doc = _this$canvasConfig.document, devicePixelRatio = _this$canvasConfig.devicePixelRatio; // create container
|
|
490
|
+
this.$container = util.isString(container) ? (doc || document).getElementById(container) : container;
|
|
491
|
+
if (this.$container) {
|
|
492
|
+
if (!this.$container.style.position) {
|
|
493
|
+
this.$container.style.position = 'relative';
|
|
494
|
+
}
|
|
495
|
+
$namespace = SVGRenderer.createSVGElement('svg', doc);
|
|
496
|
+
$namespace.setAttribute('width', "".concat(this.canvasConfig.width));
|
|
497
|
+
$namespace.setAttribute('height', "".concat(this.canvasConfig.height));
|
|
498
|
+
this.$container.appendChild($namespace);
|
|
499
|
+
this.$namespace = $namespace;
|
|
400
500
|
}
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
this
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
dpr = dpr >= 1 ? Math.ceil(dpr) : 1;
|
|
410
|
-
this.dpr = dpr;
|
|
411
|
-
case 6:
|
|
412
|
-
case "end":
|
|
413
|
-
return _context.stop();
|
|
501
|
+
// use user-defined dpr first
|
|
502
|
+
dpr = devicePixelRatio || gLite.isBrowser && window.devicePixelRatio || 1;
|
|
503
|
+
dpr = dpr >= 1 ? Math.ceil(dpr) : 1;
|
|
504
|
+
this.dpr = dpr;
|
|
505
|
+
case 6:
|
|
506
|
+
case "end":
|
|
507
|
+
return _context.stop();
|
|
508
|
+
}
|
|
414
509
|
}
|
|
415
|
-
}
|
|
416
|
-
}
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
510
|
+
}, _callee, this);
|
|
511
|
+
}));
|
|
512
|
+
function init() {
|
|
513
|
+
return _init.apply(this, arguments);
|
|
514
|
+
}
|
|
515
|
+
return init;
|
|
516
|
+
}() // @ts-ignore
|
|
517
|
+
}, {
|
|
518
|
+
key: "getDomElement",
|
|
519
|
+
value: function getDomElement() {
|
|
520
|
+
return this.$namespace;
|
|
420
521
|
}
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
return this.$namespace;
|
|
426
|
-
};
|
|
427
|
-
_proto.getContext = function getContext() {
|
|
428
|
-
return this.$namespace;
|
|
429
|
-
};
|
|
430
|
-
_proto.getDPR = function getDPR() {
|
|
431
|
-
return this.dpr;
|
|
432
|
-
};
|
|
433
|
-
_proto.getBoundingClientRect = function getBoundingClientRect() {
|
|
434
|
-
var _this$$namespace;
|
|
435
|
-
return (_this$$namespace = this.$namespace) === null || _this$$namespace === void 0 ? void 0 : _this$$namespace.getBoundingClientRect();
|
|
436
|
-
};
|
|
437
|
-
_proto.destroy = function destroy() {
|
|
438
|
-
// destroy context
|
|
439
|
-
if (this.$container && this.$namespace && this.$namespace.parentNode) {
|
|
440
|
-
this.$container.removeChild(this.$namespace);
|
|
522
|
+
}, {
|
|
523
|
+
key: "getContext",
|
|
524
|
+
value: function getContext() {
|
|
525
|
+
return this.$namespace;
|
|
441
526
|
}
|
|
442
|
-
}
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
this.$namespace.setAttribute('width', "" + width);
|
|
447
|
-
this.$namespace.setAttribute('height', "" + height);
|
|
527
|
+
}, {
|
|
528
|
+
key: "getDPR",
|
|
529
|
+
value: function getDPR() {
|
|
530
|
+
return this.dpr;
|
|
448
531
|
}
|
|
449
|
-
}
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
532
|
+
}, {
|
|
533
|
+
key: "getBoundingClientRect",
|
|
534
|
+
value: function getBoundingClientRect() {
|
|
535
|
+
var _this$$namespace;
|
|
536
|
+
return (_this$$namespace = this.$namespace) === null || _this$$namespace === void 0 ? void 0 : _this$$namespace.getBoundingClientRect();
|
|
453
537
|
}
|
|
454
|
-
}
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
}
|
|
471
|
-
}
|
|
472
|
-
}, _callee2, this);
|
|
473
|
-
}));
|
|
474
|
-
function toDataURL(_x) {
|
|
475
|
-
return _toDataURL.apply(this, arguments);
|
|
538
|
+
}, {
|
|
539
|
+
key: "destroy",
|
|
540
|
+
value: function destroy() {
|
|
541
|
+
// destroy context
|
|
542
|
+
if (this.$container && this.$namespace && this.$namespace.parentNode) {
|
|
543
|
+
this.$container.removeChild(this.$namespace);
|
|
544
|
+
}
|
|
545
|
+
}
|
|
546
|
+
}, {
|
|
547
|
+
key: "resize",
|
|
548
|
+
value: function resize(width, height) {
|
|
549
|
+
// SVG should ignore DPR
|
|
550
|
+
if (this.$namespace) {
|
|
551
|
+
this.$namespace.setAttribute('width', "".concat(width));
|
|
552
|
+
this.$namespace.setAttribute('height', "".concat(height));
|
|
553
|
+
}
|
|
476
554
|
}
|
|
477
|
-
|
|
478
|
-
|
|
555
|
+
}, {
|
|
556
|
+
key: "applyCursorStyle",
|
|
557
|
+
value: function applyCursorStyle(cursor) {
|
|
558
|
+
if (this.$container) {
|
|
559
|
+
this.$container.style.cursor = cursor;
|
|
560
|
+
}
|
|
561
|
+
}
|
|
562
|
+
}, {
|
|
563
|
+
key: "toDataURL",
|
|
564
|
+
value: function () {
|
|
565
|
+
var _toDataURL = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
|
|
566
|
+
var cloneNode,
|
|
567
|
+
svgDocType,
|
|
568
|
+
svgDoc;
|
|
569
|
+
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
570
|
+
while (1) {
|
|
571
|
+
switch (_context2.prev = _context2.next) {
|
|
572
|
+
case 0:
|
|
573
|
+
cloneNode = this.$namespace.cloneNode(true);
|
|
574
|
+
svgDocType = document.implementation.createDocumentType('svg', '-//W3C//DTD SVG 1.1//EN', 'http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd');
|
|
575
|
+
svgDoc = document.implementation.createDocument('http://www.w3.org/2000/svg', 'svg', svgDocType);
|
|
576
|
+
svgDoc.replaceChild(cloneNode, svgDoc.documentElement);
|
|
577
|
+
return _context2.abrupt("return", "data:image/svg+xml;charset=utf8,".concat(encodeURIComponent(new XMLSerializer().serializeToString(svgDoc))));
|
|
578
|
+
case 6:
|
|
579
|
+
case "end":
|
|
580
|
+
return _context2.stop();
|
|
581
|
+
}
|
|
582
|
+
}
|
|
583
|
+
}, _callee2, this);
|
|
584
|
+
}));
|
|
585
|
+
function toDataURL() {
|
|
586
|
+
return _toDataURL.apply(this, arguments);
|
|
587
|
+
}
|
|
588
|
+
return toDataURL;
|
|
589
|
+
}()
|
|
590
|
+
}]);
|
|
479
591
|
return SVGContextService;
|
|
480
592
|
}();
|
|
481
593
|
|
|
482
594
|
var ContextRegisterPlugin = /*#__PURE__*/function (_AbstractRendererPlug) {
|
|
483
|
-
|
|
595
|
+
_inherits(ContextRegisterPlugin, _AbstractRendererPlug);
|
|
596
|
+
var _super = _createSuper(ContextRegisterPlugin);
|
|
484
597
|
function ContextRegisterPlugin() {
|
|
485
598
|
var _this;
|
|
599
|
+
_classCallCheck(this, ContextRegisterPlugin);
|
|
486
600
|
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
487
601
|
args[_key] = arguments[_key];
|
|
488
602
|
}
|
|
489
|
-
_this =
|
|
603
|
+
_this = _super.call.apply(_super, [this].concat(args));
|
|
490
604
|
_this.name = 'svg-context-register';
|
|
491
605
|
return _this;
|
|
492
606
|
}
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
607
|
+
_createClass(ContextRegisterPlugin, [{
|
|
608
|
+
key: "init",
|
|
609
|
+
value: function init() {
|
|
610
|
+
// @ts-ignore
|
|
611
|
+
this.context.ContextService = SVGContextService;
|
|
612
|
+
}
|
|
613
|
+
}, {
|
|
614
|
+
key: "destroy",
|
|
615
|
+
value: function destroy() {
|
|
616
|
+
delete this.context.ContextService;
|
|
617
|
+
}
|
|
618
|
+
}]);
|
|
501
619
|
return ContextRegisterPlugin;
|
|
502
620
|
}(gLite.AbstractRendererPlugin);
|
|
503
621
|
|
|
504
622
|
var Renderer = /*#__PURE__*/function (_AbstractRenderer) {
|
|
505
|
-
|
|
506
|
-
|
|
623
|
+
_inherits(Renderer, _AbstractRenderer);
|
|
624
|
+
var _super = _createSuper(Renderer);
|
|
625
|
+
function Renderer() {
|
|
507
626
|
var _this;
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
_this = _AbstractRenderer.call(this, config) || this;
|
|
627
|
+
var config = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
628
|
+
_classCallCheck(this, Renderer);
|
|
629
|
+
_this = _super.call(this, config);
|
|
512
630
|
_this.registerPlugin(new ContextRegisterPlugin());
|
|
513
631
|
_this.registerPlugin(new SVGRenderer.Plugin({
|
|
514
632
|
outputSVGElementId: config.outputSVGElementId
|
|
@@ -517,7 +635,7 @@ var Renderer = /*#__PURE__*/function (_AbstractRenderer) {
|
|
|
517
635
|
_this.registerPlugin(new SVGPicker.Plugin());
|
|
518
636
|
return _this;
|
|
519
637
|
}
|
|
520
|
-
return Renderer;
|
|
638
|
+
return _createClass(Renderer);
|
|
521
639
|
}(gLite.AbstractRenderer);
|
|
522
640
|
|
|
523
641
|
exports.DomInteraction = DomInteraction__namespace;
|