@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 CHANGED
@@ -391,54 +391,11 @@ function _asyncToGenerator(fn) {
391
391
  };
392
392
  }
393
393
 
394
- function _classCallCheck(instance, Constructor) {
395
- if (!(instance instanceof Constructor)) {
396
- throw new TypeError("Cannot call a class as a function");
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.prototype = Object.create(superClass && superClass.prototype, {
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 _isNativeReflectConstruct() {
453
- if (typeof Reflect === "undefined" || !Reflect.construct) return false;
454
- if (Reflect.construct.sham) return false;
455
- if (typeof Proxy === "function") return true;
456
-
457
- try {
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
- return self;
471
- }
417
+ var _proto = SVGContextService.prototype;
472
418
 
473
- function _possibleConstructorReturn(self, call) {
474
- if (call && (typeof call === "object" || typeof call === "function")) {
475
- return call;
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
- return _assertThisInitialized(self);
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
- function _createSuper(Derived) {
484
- var hasNativeReflectConstruct = _isNativeReflectConstruct();
429
+ this.$container = isString(container) ? (doc || document).getElementById(container) : container;
485
430
 
486
- return function _createSuperInternal() {
487
- var Super = _getPrototypeOf(Derived),
488
- result;
431
+ if (this.$container) {
432
+ if (!this.$container.style.position) {
433
+ this.$container.style.position = 'relative';
434
+ }
489
435
 
490
- if (hasNativeReflectConstruct) {
491
- var NewTarget = _getPrototypeOf(this).constructor;
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
- result = Reflect.construct(Super, arguments, NewTarget);
494
- } else {
495
- result = Super.apply(this, arguments);
496
- }
443
+ dpr = window.devicePixelRatio || 1;
444
+ dpr = dpr >= 1 ? Math.ceil(dpr) : 1;
445
+ this.dpr = dpr;
497
446
 
498
- return _possibleConstructorReturn(this, result);
499
- };
500
- }
447
+ case 6:
448
+ case "end":
449
+ return _context.stop();
450
+ }
451
+ }
452
+ }, _callee, this);
453
+ }));
501
454
 
502
- var SVGContextService = /*#__PURE__*/function () {
503
- function SVGContextService() {
504
- _classCallCheck(this, SVGContextService);
455
+ function init() {
456
+ return _init.apply(this, arguments);
457
+ }
505
458
 
506
- this.$container = void 0;
507
- this.$namespace = void 0;
508
- this.dpr = void 0;
509
- this.canvasConfig = void 0;
510
- }
459
+ return init;
460
+ }() // @ts-ignore
461
+ ;
511
462
 
512
- _createClass(SVGContextService, [{
513
- key: "init",
514
- value: function () {
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
- dpr = window.devicePixelRatio || 1;
539
- dpr = dpr >= 1 ? Math.ceil(dpr) : 1;
540
- this.dpr = dpr;
467
+ _proto.getContext = function getContext() {
468
+ return this.$namespace;
469
+ };
541
470
 
542
- case 6:
543
- case "end":
544
- return _context.stop();
545
- }
546
- }
547
- }, _callee, this);
548
- }));
471
+ _proto.getDPR = function getDPR() {
472
+ return this.dpr;
473
+ };
549
474
 
550
- function init() {
551
- return _init.apply(this, arguments);
552
- }
475
+ _proto.getBoundingClientRect = function getBoundingClientRect() {
476
+ var _this$$namespace;
553
477
 
554
- return init;
555
- }() // @ts-ignore
478
+ return (_this$$namespace = this.$namespace) === null || _this$$namespace === void 0 ? void 0 : _this$$namespace.getBoundingClientRect();
479
+ };
556
480
 
557
- }, {
558
- key: "getDomElement",
559
- value: function getDomElement() {
560
- return this.$namespace;
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
- return (_this$$namespace = this.$namespace) === null || _this$$namespace === void 0 ? void 0 : _this$$namespace.getBoundingClientRect();
578
- }
579
- }, {
580
- key: "destroy",
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
- key: "applyCursorStyle",
597
- value: function applyCursorStyle(cursor) {
598
- if (this.$container) {
599
- this.$container.style.cursor = cursor;
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
- _createClass(ContextRegisterPlugin, [{
627
- key: "init",
628
- value: function init(container) {
629
- container.load(containerModule, true);
630
- }
631
- }, {
632
- key: "destroy",
633
- value: function destroy(container) {
634
- container.unload(containerModule);
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
- _inherits(Renderer, _AbstractRenderer);
643
-
644
- var _super = _createSuper(Renderer);
535
+ _inheritsLoose(Renderer, _AbstractRenderer);
645
536
 
646
537
  function Renderer(config) {
647
538
  var _this;
648
539
 
649
- _classCallCheck(this, Renderer);
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 _createClass(Renderer);
553
+ return Renderer;
665
554
  }(AbstractRenderer);
666
555
 
667
556
  export { Renderer };