@antv/g-svg 1.1.8-alpha.2 → 1.2.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.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.esm.js +201 -91
- package/dist/index.js +201 -91
- package/dist/index.umd.js +2740 -2119
- package/dist/index.umd.min.js +5 -5
- package/package.json +5 -5
package/dist/index.js
CHANGED
|
@@ -4,8 +4,8 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
4
4
|
|
|
5
5
|
var g = require('@antv/g');
|
|
6
6
|
var DomInteraction = require('@antv/g-plugin-dom-interaction');
|
|
7
|
-
var SVGRenderer = require('@antv/g-plugin-svg-renderer');
|
|
8
7
|
var SVGPicker = require('@antv/g-plugin-svg-picker');
|
|
8
|
+
var SVGRenderer = require('@antv/g-plugin-svg-renderer');
|
|
9
9
|
var tslib = require('tslib');
|
|
10
10
|
|
|
11
11
|
function _interopNamespace(e) {
|
|
@@ -29,8 +29,8 @@ function _interopNamespace(e) {
|
|
|
29
29
|
}
|
|
30
30
|
|
|
31
31
|
var DomInteraction__namespace = /*#__PURE__*/_interopNamespace(DomInteraction);
|
|
32
|
-
var SVGRenderer__namespace = /*#__PURE__*/_interopNamespace(SVGRenderer);
|
|
33
32
|
var SVGPicker__namespace = /*#__PURE__*/_interopNamespace(SVGPicker);
|
|
33
|
+
var SVGRenderer__namespace = /*#__PURE__*/_interopNamespace(SVGRenderer);
|
|
34
34
|
|
|
35
35
|
function _regeneratorRuntime() {
|
|
36
36
|
/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */
|
|
@@ -413,113 +413,215 @@ function _asyncToGenerator(fn) {
|
|
|
413
413
|
};
|
|
414
414
|
}
|
|
415
415
|
|
|
416
|
-
function
|
|
417
|
-
|
|
418
|
-
|
|
416
|
+
function _classCallCheck(instance, Constructor) {
|
|
417
|
+
if (!(instance instanceof Constructor)) {
|
|
418
|
+
throw new TypeError("Cannot call a class as a function");
|
|
419
|
+
}
|
|
420
|
+
}
|
|
421
|
+
|
|
422
|
+
function _defineProperties(target, props) {
|
|
423
|
+
for (var i = 0; i < props.length; i++) {
|
|
424
|
+
var descriptor = props[i];
|
|
425
|
+
descriptor.enumerable = descriptor.enumerable || false;
|
|
426
|
+
descriptor.configurable = true;
|
|
427
|
+
if ("value" in descriptor) descriptor.writable = true;
|
|
428
|
+
Object.defineProperty(target, descriptor.key, descriptor);
|
|
429
|
+
}
|
|
430
|
+
}
|
|
431
|
+
|
|
432
|
+
function _createClass(Constructor, protoProps, staticProps) {
|
|
433
|
+
if (protoProps) _defineProperties(Constructor.prototype, protoProps);
|
|
434
|
+
if (staticProps) _defineProperties(Constructor, staticProps);
|
|
435
|
+
Object.defineProperty(Constructor, "prototype", {
|
|
436
|
+
writable: false
|
|
437
|
+
});
|
|
438
|
+
return Constructor;
|
|
439
|
+
}
|
|
440
|
+
|
|
441
|
+
function _inherits(subClass, superClass) {
|
|
442
|
+
if (typeof superClass !== "function" && superClass !== null) {
|
|
443
|
+
throw new TypeError("Super expression must either be null or a function");
|
|
444
|
+
}
|
|
445
|
+
|
|
446
|
+
subClass.prototype = Object.create(superClass && superClass.prototype, {
|
|
447
|
+
constructor: {
|
|
448
|
+
value: subClass,
|
|
449
|
+
writable: true,
|
|
450
|
+
configurable: true
|
|
451
|
+
}
|
|
452
|
+
});
|
|
453
|
+
Object.defineProperty(subClass, "prototype", {
|
|
454
|
+
writable: false
|
|
455
|
+
});
|
|
456
|
+
if (superClass) _setPrototypeOf(subClass, superClass);
|
|
457
|
+
}
|
|
419
458
|
|
|
420
|
-
|
|
459
|
+
function _getPrototypeOf(o) {
|
|
460
|
+
_getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) {
|
|
461
|
+
return o.__proto__ || Object.getPrototypeOf(o);
|
|
462
|
+
};
|
|
463
|
+
return _getPrototypeOf(o);
|
|
421
464
|
}
|
|
422
465
|
|
|
423
466
|
function _setPrototypeOf(o, p) {
|
|
424
|
-
_setPrototypeOf = Object.setPrototypeOf
|
|
467
|
+
_setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) {
|
|
425
468
|
o.__proto__ = p;
|
|
426
469
|
return o;
|
|
427
470
|
};
|
|
428
|
-
|
|
429
471
|
return _setPrototypeOf(o, p);
|
|
430
472
|
}
|
|
431
473
|
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
this.dpr = void 0;
|
|
437
|
-
this.canvasConfig = void 0;
|
|
438
|
-
}
|
|
474
|
+
function _isNativeReflectConstruct() {
|
|
475
|
+
if (typeof Reflect === "undefined" || !Reflect.construct) return false;
|
|
476
|
+
if (Reflect.construct.sham) return false;
|
|
477
|
+
if (typeof Proxy === "function") return true;
|
|
439
478
|
|
|
440
|
-
|
|
479
|
+
try {
|
|
480
|
+
Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {}));
|
|
481
|
+
return true;
|
|
482
|
+
} catch (e) {
|
|
483
|
+
return false;
|
|
484
|
+
}
|
|
485
|
+
}
|
|
441
486
|
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
487
|
+
function _assertThisInitialized(self) {
|
|
488
|
+
if (self === void 0) {
|
|
489
|
+
throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
|
|
490
|
+
}
|
|
445
491
|
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
switch (_context.prev = _context.next) {
|
|
449
|
-
case 0:
|
|
450
|
-
_this$canvasConfig = this.canvasConfig, container = _this$canvasConfig.container, doc = _this$canvasConfig.document; // create container
|
|
492
|
+
return self;
|
|
493
|
+
}
|
|
451
494
|
|
|
452
|
-
|
|
495
|
+
function _possibleConstructorReturn(self, call) {
|
|
496
|
+
if (call && (typeof call === "object" || typeof call === "function")) {
|
|
497
|
+
return call;
|
|
498
|
+
} else if (call !== void 0) {
|
|
499
|
+
throw new TypeError("Derived constructors may only return object or undefined");
|
|
500
|
+
}
|
|
453
501
|
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
this.$container.style.position = 'relative';
|
|
457
|
-
}
|
|
502
|
+
return _assertThisInitialized(self);
|
|
503
|
+
}
|
|
458
504
|
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
$namespace.setAttribute('height', "" + this.canvasConfig.height);
|
|
462
|
-
this.$container.appendChild($namespace);
|
|
463
|
-
this.$namespace = $namespace;
|
|
464
|
-
}
|
|
505
|
+
function _createSuper(Derived) {
|
|
506
|
+
var hasNativeReflectConstruct = _isNativeReflectConstruct();
|
|
465
507
|
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
508
|
+
return function _createSuperInternal() {
|
|
509
|
+
var Super = _getPrototypeOf(Derived),
|
|
510
|
+
result;
|
|
469
511
|
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
return _context.stop();
|
|
473
|
-
}
|
|
474
|
-
}
|
|
475
|
-
}, _callee, this);
|
|
476
|
-
}));
|
|
512
|
+
if (hasNativeReflectConstruct) {
|
|
513
|
+
var NewTarget = _getPrototypeOf(this).constructor;
|
|
477
514
|
|
|
478
|
-
|
|
479
|
-
|
|
515
|
+
result = Reflect.construct(Super, arguments, NewTarget);
|
|
516
|
+
} else {
|
|
517
|
+
result = Super.apply(this, arguments);
|
|
480
518
|
}
|
|
481
519
|
|
|
482
|
-
return
|
|
483
|
-
}() // @ts-ignore
|
|
484
|
-
;
|
|
485
|
-
|
|
486
|
-
_proto.getDomElement = function getDomElement() {
|
|
487
|
-
return this.$namespace;
|
|
520
|
+
return _possibleConstructorReturn(this, result);
|
|
488
521
|
};
|
|
522
|
+
}
|
|
489
523
|
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
524
|
+
var SVGContextService = /*#__PURE__*/function () {
|
|
525
|
+
function SVGContextService() {
|
|
526
|
+
_classCallCheck(this, SVGContextService);
|
|
493
527
|
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
528
|
+
this.$container = void 0;
|
|
529
|
+
this.$namespace = void 0;
|
|
530
|
+
this.dpr = void 0;
|
|
531
|
+
this.canvasConfig = void 0;
|
|
532
|
+
}
|
|
533
|
+
|
|
534
|
+
_createClass(SVGContextService, [{
|
|
535
|
+
key: "init",
|
|
536
|
+
value: function () {
|
|
537
|
+
var _init = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
538
|
+
var _this$canvasConfig, container, doc, $namespace, dpr;
|
|
539
|
+
|
|
540
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
541
|
+
while (1) {
|
|
542
|
+
switch (_context.prev = _context.next) {
|
|
543
|
+
case 0:
|
|
544
|
+
_this$canvasConfig = this.canvasConfig, container = _this$canvasConfig.container, doc = _this$canvasConfig.document; // create container
|
|
545
|
+
|
|
546
|
+
this.$container = g.isString(container) ? (doc || document).getElementById(container) : container;
|
|
547
|
+
|
|
548
|
+
if (this.$container) {
|
|
549
|
+
if (!this.$container.style.position) {
|
|
550
|
+
this.$container.style.position = 'relative';
|
|
551
|
+
}
|
|
552
|
+
|
|
553
|
+
$namespace = SVGRenderer.createSVGElement('svg', doc);
|
|
554
|
+
$namespace.setAttribute('width', "".concat(this.canvasConfig.width));
|
|
555
|
+
$namespace.setAttribute('height', "".concat(this.canvasConfig.height));
|
|
556
|
+
this.$container.appendChild($namespace);
|
|
557
|
+
this.$namespace = $namespace;
|
|
558
|
+
}
|
|
497
559
|
|
|
498
|
-
|
|
499
|
-
|
|
560
|
+
dpr = window.devicePixelRatio || 1;
|
|
561
|
+
dpr = dpr >= 1 ? Math.ceil(dpr) : 1;
|
|
562
|
+
this.dpr = dpr;
|
|
500
563
|
|
|
501
|
-
|
|
502
|
-
|
|
564
|
+
case 6:
|
|
565
|
+
case "end":
|
|
566
|
+
return _context.stop();
|
|
567
|
+
}
|
|
568
|
+
}
|
|
569
|
+
}, _callee, this);
|
|
570
|
+
}));
|
|
503
571
|
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
572
|
+
function init() {
|
|
573
|
+
return _init.apply(this, arguments);
|
|
574
|
+
}
|
|
575
|
+
|
|
576
|
+
return init;
|
|
577
|
+
}() // @ts-ignore
|
|
510
578
|
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
this.$namespace
|
|
579
|
+
}, {
|
|
580
|
+
key: "getDomElement",
|
|
581
|
+
value: function getDomElement() {
|
|
582
|
+
return this.$namespace;
|
|
515
583
|
}
|
|
516
|
-
}
|
|
584
|
+
}, {
|
|
585
|
+
key: "getContext",
|
|
586
|
+
value: function getContext() {
|
|
587
|
+
return this.$namespace;
|
|
588
|
+
}
|
|
589
|
+
}, {
|
|
590
|
+
key: "getDPR",
|
|
591
|
+
value: function getDPR() {
|
|
592
|
+
return this.dpr;
|
|
593
|
+
}
|
|
594
|
+
}, {
|
|
595
|
+
key: "getBoundingClientRect",
|
|
596
|
+
value: function getBoundingClientRect() {
|
|
597
|
+
var _this$$namespace;
|
|
517
598
|
|
|
518
|
-
|
|
519
|
-
if (this.$container) {
|
|
520
|
-
this.$container.style.cursor = cursor;
|
|
599
|
+
return (_this$$namespace = this.$namespace) === null || _this$$namespace === void 0 ? void 0 : _this$$namespace.getBoundingClientRect();
|
|
521
600
|
}
|
|
522
|
-
}
|
|
601
|
+
}, {
|
|
602
|
+
key: "destroy",
|
|
603
|
+
value: function destroy() {
|
|
604
|
+
// destroy context
|
|
605
|
+
if (this.$container && this.$namespace && this.$namespace.parentNode) {
|
|
606
|
+
this.$container.removeChild(this.$namespace);
|
|
607
|
+
}
|
|
608
|
+
}
|
|
609
|
+
}, {
|
|
610
|
+
key: "resize",
|
|
611
|
+
value: function resize(width, height) {
|
|
612
|
+
if (this.$namespace) {
|
|
613
|
+
this.$namespace.setAttribute('width', "".concat(width));
|
|
614
|
+
this.$namespace.setAttribute('height', "".concat(height));
|
|
615
|
+
}
|
|
616
|
+
}
|
|
617
|
+
}, {
|
|
618
|
+
key: "applyCursorStyle",
|
|
619
|
+
value: function applyCursorStyle(cursor) {
|
|
620
|
+
if (this.$container) {
|
|
621
|
+
this.$container.style.cursor = cursor;
|
|
622
|
+
}
|
|
623
|
+
}
|
|
624
|
+
}]);
|
|
523
625
|
|
|
524
626
|
return SVGContextService;
|
|
525
627
|
}();
|
|
@@ -538,29 +640,37 @@ var containerModule = g.Module(function (register) {
|
|
|
538
640
|
});
|
|
539
641
|
var ContextRegisterPlugin = /*#__PURE__*/function () {
|
|
540
642
|
function ContextRegisterPlugin() {
|
|
643
|
+
_classCallCheck(this, ContextRegisterPlugin);
|
|
644
|
+
|
|
541
645
|
this.name = 'svg-context-register';
|
|
542
646
|
}
|
|
543
647
|
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
container
|
|
552
|
-
|
|
648
|
+
_createClass(ContextRegisterPlugin, [{
|
|
649
|
+
key: "init",
|
|
650
|
+
value: function init(container) {
|
|
651
|
+
container.load(containerModule, true);
|
|
652
|
+
}
|
|
653
|
+
}, {
|
|
654
|
+
key: "destroy",
|
|
655
|
+
value: function destroy(container) {
|
|
656
|
+
container.unload(containerModule);
|
|
657
|
+
}
|
|
658
|
+
}]);
|
|
553
659
|
|
|
554
660
|
return ContextRegisterPlugin;
|
|
555
661
|
}();
|
|
556
662
|
|
|
557
663
|
var Renderer = /*#__PURE__*/function (_AbstractRenderer) {
|
|
558
|
-
|
|
664
|
+
_inherits(Renderer, _AbstractRenderer);
|
|
665
|
+
|
|
666
|
+
var _super = _createSuper(Renderer);
|
|
559
667
|
|
|
560
668
|
function Renderer(config) {
|
|
561
669
|
var _this;
|
|
562
670
|
|
|
563
|
-
|
|
671
|
+
_classCallCheck(this, Renderer);
|
|
672
|
+
|
|
673
|
+
_this = _super.call(this, config);
|
|
564
674
|
|
|
565
675
|
_this.registerPlugin(new ContextRegisterPlugin());
|
|
566
676
|
|
|
@@ -573,10 +683,10 @@ var Renderer = /*#__PURE__*/function (_AbstractRenderer) {
|
|
|
573
683
|
return _this;
|
|
574
684
|
}
|
|
575
685
|
|
|
576
|
-
return Renderer;
|
|
686
|
+
return _createClass(Renderer);
|
|
577
687
|
}(g.AbstractRenderer);
|
|
578
688
|
|
|
579
689
|
exports.DomInteraction = DomInteraction__namespace;
|
|
580
|
-
exports.SVGRenderer = SVGRenderer__namespace;
|
|
581
690
|
exports.SVGPicker = SVGPicker__namespace;
|
|
691
|
+
exports.SVGRenderer = SVGRenderer__namespace;
|
|
582
692
|
exports.Renderer = Renderer;
|