@antv/g-svg 1.2.1 → 1.2.2
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 +86 -197
- package/dist/index.js +86 -197
- package/dist/index.umd.js +1784 -2157
- package/dist/index.umd.min.js +5 -5
- package/package.json +5 -5
package/dist/index.esm.js
CHANGED
|
@@ -391,54 +391,11 @@ function _asyncToGenerator(fn) {
|
|
|
391
391
|
};
|
|
392
392
|
}
|
|
393
393
|
|
|
394
|
-
function
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
}
|
|
398
|
-
}
|
|
399
|
-
|
|
400
|
-
function _defineProperties(target, props) {
|
|
401
|
-
for (var i = 0; i < props.length; i++) {
|
|
402
|
-
var descriptor = props[i];
|
|
403
|
-
descriptor.enumerable = descriptor.enumerable || false;
|
|
404
|
-
descriptor.configurable = true;
|
|
405
|
-
if ("value" in descriptor) descriptor.writable = true;
|
|
406
|
-
Object.defineProperty(target, descriptor.key, descriptor);
|
|
407
|
-
}
|
|
408
|
-
}
|
|
409
|
-
|
|
410
|
-
function _createClass(Constructor, protoProps, staticProps) {
|
|
411
|
-
if (protoProps) _defineProperties(Constructor.prototype, protoProps);
|
|
412
|
-
if (staticProps) _defineProperties(Constructor, staticProps);
|
|
413
|
-
Object.defineProperty(Constructor, "prototype", {
|
|
414
|
-
writable: false
|
|
415
|
-
});
|
|
416
|
-
return Constructor;
|
|
417
|
-
}
|
|
418
|
-
|
|
419
|
-
function _inherits(subClass, superClass) {
|
|
420
|
-
if (typeof superClass !== "function" && superClass !== null) {
|
|
421
|
-
throw new TypeError("Super expression must either be null or a function");
|
|
422
|
-
}
|
|
394
|
+
function _inheritsLoose(subClass, superClass) {
|
|
395
|
+
subClass.prototype = Object.create(superClass.prototype);
|
|
396
|
+
subClass.prototype.constructor = subClass;
|
|
423
397
|
|
|
424
|
-
subClass
|
|
425
|
-
constructor: {
|
|
426
|
-
value: subClass,
|
|
427
|
-
writable: true,
|
|
428
|
-
configurable: true
|
|
429
|
-
}
|
|
430
|
-
});
|
|
431
|
-
Object.defineProperty(subClass, "prototype", {
|
|
432
|
-
writable: false
|
|
433
|
-
});
|
|
434
|
-
if (superClass) _setPrototypeOf(subClass, superClass);
|
|
435
|
-
}
|
|
436
|
-
|
|
437
|
-
function _getPrototypeOf(o) {
|
|
438
|
-
_getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) {
|
|
439
|
-
return o.__proto__ || Object.getPrototypeOf(o);
|
|
440
|
-
};
|
|
441
|
-
return _getPrototypeOf(o);
|
|
398
|
+
_setPrototypeOf(subClass, superClass);
|
|
442
399
|
}
|
|
443
400
|
|
|
444
401
|
function _setPrototypeOf(o, p) {
|
|
@@ -449,157 +406,97 @@ function _setPrototypeOf(o, p) {
|
|
|
449
406
|
return _setPrototypeOf(o, p);
|
|
450
407
|
}
|
|
451
408
|
|
|
452
|
-
function
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {}));
|
|
459
|
-
return true;
|
|
460
|
-
} catch (e) {
|
|
461
|
-
return false;
|
|
462
|
-
}
|
|
463
|
-
}
|
|
464
|
-
|
|
465
|
-
function _assertThisInitialized(self) {
|
|
466
|
-
if (self === void 0) {
|
|
467
|
-
throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
|
|
409
|
+
var SVGContextService = /*#__PURE__*/function () {
|
|
410
|
+
function SVGContextService() {
|
|
411
|
+
this.$container = void 0;
|
|
412
|
+
this.$namespace = void 0;
|
|
413
|
+
this.dpr = void 0;
|
|
414
|
+
this.canvasConfig = void 0;
|
|
468
415
|
}
|
|
469
416
|
|
|
470
|
-
|
|
471
|
-
}
|
|
417
|
+
var _proto = SVGContextService.prototype;
|
|
472
418
|
|
|
473
|
-
function
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
} else if (call !== void 0) {
|
|
477
|
-
throw new TypeError("Derived constructors may only return object or undefined");
|
|
478
|
-
}
|
|
419
|
+
_proto.init = /*#__PURE__*/function () {
|
|
420
|
+
var _init = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
421
|
+
var _this$canvasConfig, container, doc, $namespace, dpr;
|
|
479
422
|
|
|
480
|
-
|
|
481
|
-
|
|
423
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
424
|
+
while (1) {
|
|
425
|
+
switch (_context.prev = _context.next) {
|
|
426
|
+
case 0:
|
|
427
|
+
_this$canvasConfig = this.canvasConfig, container = _this$canvasConfig.container, doc = _this$canvasConfig.document; // create container
|
|
482
428
|
|
|
483
|
-
|
|
484
|
-
var hasNativeReflectConstruct = _isNativeReflectConstruct();
|
|
429
|
+
this.$container = isString(container) ? (doc || document).getElementById(container) : container;
|
|
485
430
|
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
431
|
+
if (this.$container) {
|
|
432
|
+
if (!this.$container.style.position) {
|
|
433
|
+
this.$container.style.position = 'relative';
|
|
434
|
+
}
|
|
489
435
|
|
|
490
|
-
|
|
491
|
-
|
|
436
|
+
$namespace = createSVGElement('svg', doc);
|
|
437
|
+
$namespace.setAttribute('width', "" + this.canvasConfig.width);
|
|
438
|
+
$namespace.setAttribute('height', "" + this.canvasConfig.height);
|
|
439
|
+
this.$container.appendChild($namespace);
|
|
440
|
+
this.$namespace = $namespace;
|
|
441
|
+
}
|
|
492
442
|
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
}
|
|
443
|
+
dpr = window.devicePixelRatio || 1;
|
|
444
|
+
dpr = dpr >= 1 ? Math.ceil(dpr) : 1;
|
|
445
|
+
this.dpr = dpr;
|
|
497
446
|
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
447
|
+
case 6:
|
|
448
|
+
case "end":
|
|
449
|
+
return _context.stop();
|
|
450
|
+
}
|
|
451
|
+
}
|
|
452
|
+
}, _callee, this);
|
|
453
|
+
}));
|
|
501
454
|
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
455
|
+
function init() {
|
|
456
|
+
return _init.apply(this, arguments);
|
|
457
|
+
}
|
|
505
458
|
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
this.canvasConfig = void 0;
|
|
510
|
-
}
|
|
459
|
+
return init;
|
|
460
|
+
}() // @ts-ignore
|
|
461
|
+
;
|
|
511
462
|
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
var _init = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
516
|
-
var _this$canvasConfig, container, doc, $namespace, dpr;
|
|
517
|
-
|
|
518
|
-
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
519
|
-
while (1) {
|
|
520
|
-
switch (_context.prev = _context.next) {
|
|
521
|
-
case 0:
|
|
522
|
-
_this$canvasConfig = this.canvasConfig, container = _this$canvasConfig.container, doc = _this$canvasConfig.document; // create container
|
|
523
|
-
|
|
524
|
-
this.$container = isString(container) ? (doc || document).getElementById(container) : container;
|
|
525
|
-
|
|
526
|
-
if (this.$container) {
|
|
527
|
-
if (!this.$container.style.position) {
|
|
528
|
-
this.$container.style.position = 'relative';
|
|
529
|
-
}
|
|
530
|
-
|
|
531
|
-
$namespace = createSVGElement('svg', doc);
|
|
532
|
-
$namespace.setAttribute('width', "".concat(this.canvasConfig.width));
|
|
533
|
-
$namespace.setAttribute('height', "".concat(this.canvasConfig.height));
|
|
534
|
-
this.$container.appendChild($namespace);
|
|
535
|
-
this.$namespace = $namespace;
|
|
536
|
-
}
|
|
463
|
+
_proto.getDomElement = function getDomElement() {
|
|
464
|
+
return this.$namespace;
|
|
465
|
+
};
|
|
537
466
|
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
467
|
+
_proto.getContext = function getContext() {
|
|
468
|
+
return this.$namespace;
|
|
469
|
+
};
|
|
541
470
|
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
}
|
|
546
|
-
}
|
|
547
|
-
}, _callee, this);
|
|
548
|
-
}));
|
|
471
|
+
_proto.getDPR = function getDPR() {
|
|
472
|
+
return this.dpr;
|
|
473
|
+
};
|
|
549
474
|
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
}
|
|
475
|
+
_proto.getBoundingClientRect = function getBoundingClientRect() {
|
|
476
|
+
var _this$$namespace;
|
|
553
477
|
|
|
554
|
-
|
|
555
|
-
|
|
478
|
+
return (_this$$namespace = this.$namespace) === null || _this$$namespace === void 0 ? void 0 : _this$$namespace.getBoundingClientRect();
|
|
479
|
+
};
|
|
556
480
|
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
}
|
|
562
|
-
}, {
|
|
563
|
-
key: "getContext",
|
|
564
|
-
value: function getContext() {
|
|
565
|
-
return this.$namespace;
|
|
566
|
-
}
|
|
567
|
-
}, {
|
|
568
|
-
key: "getDPR",
|
|
569
|
-
value: function getDPR() {
|
|
570
|
-
return this.dpr;
|
|
481
|
+
_proto.destroy = function destroy() {
|
|
482
|
+
// destroy context
|
|
483
|
+
if (this.$container && this.$namespace && this.$namespace.parentNode) {
|
|
484
|
+
this.$container.removeChild(this.$namespace);
|
|
571
485
|
}
|
|
572
|
-
}
|
|
573
|
-
key: "getBoundingClientRect",
|
|
574
|
-
value: function getBoundingClientRect() {
|
|
575
|
-
var _this$$namespace;
|
|
486
|
+
};
|
|
576
487
|
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
value: function destroy() {
|
|
582
|
-
// destroy context
|
|
583
|
-
if (this.$container && this.$namespace && this.$namespace.parentNode) {
|
|
584
|
-
this.$container.removeChild(this.$namespace);
|
|
585
|
-
}
|
|
586
|
-
}
|
|
587
|
-
}, {
|
|
588
|
-
key: "resize",
|
|
589
|
-
value: function resize(width, height) {
|
|
590
|
-
if (this.$namespace) {
|
|
591
|
-
this.$namespace.setAttribute('width', "".concat(width));
|
|
592
|
-
this.$namespace.setAttribute('height', "".concat(height));
|
|
593
|
-
}
|
|
488
|
+
_proto.resize = function resize(width, height) {
|
|
489
|
+
if (this.$namespace) {
|
|
490
|
+
this.$namespace.setAttribute('width', "" + width);
|
|
491
|
+
this.$namespace.setAttribute('height', "" + height);
|
|
594
492
|
}
|
|
595
|
-
}
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
}
|
|
493
|
+
};
|
|
494
|
+
|
|
495
|
+
_proto.applyCursorStyle = function applyCursorStyle(cursor) {
|
|
496
|
+
if (this.$container) {
|
|
497
|
+
this.$container.style.cursor = cursor;
|
|
601
498
|
}
|
|
602
|
-
}
|
|
499
|
+
};
|
|
603
500
|
|
|
604
501
|
return SVGContextService;
|
|
605
502
|
}();
|
|
@@ -618,37 +515,29 @@ var containerModule = Module(function (register) {
|
|
|
618
515
|
});
|
|
619
516
|
var ContextRegisterPlugin = /*#__PURE__*/function () {
|
|
620
517
|
function ContextRegisterPlugin() {
|
|
621
|
-
_classCallCheck(this, ContextRegisterPlugin);
|
|
622
|
-
|
|
623
518
|
this.name = 'svg-context-register';
|
|
624
519
|
}
|
|
625
520
|
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
}
|
|
636
|
-
}]);
|
|
521
|
+
var _proto = ContextRegisterPlugin.prototype;
|
|
522
|
+
|
|
523
|
+
_proto.init = function init(container) {
|
|
524
|
+
container.load(containerModule, true);
|
|
525
|
+
};
|
|
526
|
+
|
|
527
|
+
_proto.destroy = function destroy(container) {
|
|
528
|
+
container.unload(containerModule);
|
|
529
|
+
};
|
|
637
530
|
|
|
638
531
|
return ContextRegisterPlugin;
|
|
639
532
|
}();
|
|
640
533
|
|
|
641
534
|
var Renderer = /*#__PURE__*/function (_AbstractRenderer) {
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
var _super = _createSuper(Renderer);
|
|
535
|
+
_inheritsLoose(Renderer, _AbstractRenderer);
|
|
645
536
|
|
|
646
537
|
function Renderer(config) {
|
|
647
538
|
var _this;
|
|
648
539
|
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
_this = _super.call(this, config);
|
|
540
|
+
_this = _AbstractRenderer.call(this, config) || this;
|
|
652
541
|
|
|
653
542
|
_this.registerPlugin(new ContextRegisterPlugin());
|
|
654
543
|
|
|
@@ -661,7 +550,7 @@ var Renderer = /*#__PURE__*/function (_AbstractRenderer) {
|
|
|
661
550
|
return _this;
|
|
662
551
|
}
|
|
663
552
|
|
|
664
|
-
return
|
|
553
|
+
return Renderer;
|
|
665
554
|
}(AbstractRenderer);
|
|
666
555
|
|
|
667
556
|
export { Renderer };
|