@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.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import type { RendererConfig } from '@antv/g';
|
|
2
2
|
import { AbstractRenderer } from '@antv/g';
|
|
3
3
|
import * as DomInteraction from '@antv/g-plugin-dom-interaction';
|
|
4
|
-
import * as SVGRenderer from '@antv/g-plugin-svg-renderer';
|
|
5
4
|
import * as SVGPicker from '@antv/g-plugin-svg-picker';
|
|
6
|
-
|
|
5
|
+
import * as SVGRenderer from '@antv/g-plugin-svg-renderer';
|
|
6
|
+
export { DomInteraction, SVGPicker, SVGRenderer };
|
|
7
7
|
export declare class Renderer extends AbstractRenderer {
|
|
8
8
|
constructor(config?: Partial<RendererConfig>);
|
|
9
9
|
}
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAC9C,OAAO,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAC3C,OAAO,KAAK,cAAc,MAAM,gCAAgC,CAAC;AACjE,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAC9C,OAAO,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAC3C,OAAO,KAAK,cAAc,MAAM,gCAAgC,CAAC;AACjE,OAAO,KAAK,SAAS,MAAM,2BAA2B,CAAC;AACvD,OAAO,KAAK,WAAW,MAAM,6BAA6B,CAAC;AAE3D,OAAO,EAAE,cAAc,EAAE,SAAS,EAAE,WAAW,EAAE,CAAC;AAElD,qBAAa,QAAS,SAAQ,gBAAgB;gBAChC,MAAM,CAAC,EAAE,OAAO,CAAC,cAAc,CAAC;CAQ7C"}
|
package/dist/index.esm.js
CHANGED
|
@@ -2,12 +2,12 @@ import { inject, CanvasConfig, singleton, ContextService, isString, Module, Abst
|
|
|
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 };
|
|
5
|
-
import { createSVGElement, Plugin } from '@antv/g-plugin-svg-renderer';
|
|
6
|
-
import * as SVGRenderer from '@antv/g-plugin-svg-renderer';
|
|
7
|
-
export { SVGRenderer };
|
|
8
5
|
import { Plugin as Plugin$2 } from '@antv/g-plugin-svg-picker';
|
|
9
6
|
import * as SVGPicker from '@antv/g-plugin-svg-picker';
|
|
10
7
|
export { SVGPicker };
|
|
8
|
+
import { createSVGElement, Plugin } from '@antv/g-plugin-svg-renderer';
|
|
9
|
+
import * as SVGRenderer from '@antv/g-plugin-svg-renderer';
|
|
10
|
+
export { SVGRenderer };
|
|
11
11
|
import { __decorate, __metadata } from 'tslib';
|
|
12
12
|
|
|
13
13
|
function _regeneratorRuntime() {
|
|
@@ -391,113 +391,215 @@ function _asyncToGenerator(fn) {
|
|
|
391
391
|
};
|
|
392
392
|
}
|
|
393
393
|
|
|
394
|
-
function
|
|
395
|
-
|
|
396
|
-
|
|
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
|
+
}
|
|
423
|
+
|
|
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
|
+
}
|
|
397
436
|
|
|
398
|
-
|
|
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);
|
|
399
442
|
}
|
|
400
443
|
|
|
401
444
|
function _setPrototypeOf(o, p) {
|
|
402
|
-
_setPrototypeOf = Object.setPrototypeOf
|
|
445
|
+
_setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) {
|
|
403
446
|
o.__proto__ = p;
|
|
404
447
|
return o;
|
|
405
448
|
};
|
|
406
|
-
|
|
407
449
|
return _setPrototypeOf(o, p);
|
|
408
450
|
}
|
|
409
451
|
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
this.dpr = void 0;
|
|
415
|
-
this.canvasConfig = void 0;
|
|
416
|
-
}
|
|
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;
|
|
417
456
|
|
|
418
|
-
|
|
457
|
+
try {
|
|
458
|
+
Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {}));
|
|
459
|
+
return true;
|
|
460
|
+
} catch (e) {
|
|
461
|
+
return false;
|
|
462
|
+
}
|
|
463
|
+
}
|
|
419
464
|
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
465
|
+
function _assertThisInitialized(self) {
|
|
466
|
+
if (self === void 0) {
|
|
467
|
+
throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
|
|
468
|
+
}
|
|
423
469
|
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
switch (_context.prev = _context.next) {
|
|
427
|
-
case 0:
|
|
428
|
-
_this$canvasConfig = this.canvasConfig, container = _this$canvasConfig.container, doc = _this$canvasConfig.document; // create container
|
|
470
|
+
return self;
|
|
471
|
+
}
|
|
429
472
|
|
|
430
|
-
|
|
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
|
+
}
|
|
431
479
|
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
this.$container.style.position = 'relative';
|
|
435
|
-
}
|
|
480
|
+
return _assertThisInitialized(self);
|
|
481
|
+
}
|
|
436
482
|
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
$namespace.setAttribute('height', "" + this.canvasConfig.height);
|
|
440
|
-
this.$container.appendChild($namespace);
|
|
441
|
-
this.$namespace = $namespace;
|
|
442
|
-
}
|
|
483
|
+
function _createSuper(Derived) {
|
|
484
|
+
var hasNativeReflectConstruct = _isNativeReflectConstruct();
|
|
443
485
|
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
486
|
+
return function _createSuperInternal() {
|
|
487
|
+
var Super = _getPrototypeOf(Derived),
|
|
488
|
+
result;
|
|
447
489
|
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
return _context.stop();
|
|
451
|
-
}
|
|
452
|
-
}
|
|
453
|
-
}, _callee, this);
|
|
454
|
-
}));
|
|
490
|
+
if (hasNativeReflectConstruct) {
|
|
491
|
+
var NewTarget = _getPrototypeOf(this).constructor;
|
|
455
492
|
|
|
456
|
-
|
|
457
|
-
|
|
493
|
+
result = Reflect.construct(Super, arguments, NewTarget);
|
|
494
|
+
} else {
|
|
495
|
+
result = Super.apply(this, arguments);
|
|
458
496
|
}
|
|
459
497
|
|
|
460
|
-
return
|
|
461
|
-
}() // @ts-ignore
|
|
462
|
-
;
|
|
463
|
-
|
|
464
|
-
_proto.getDomElement = function getDomElement() {
|
|
465
|
-
return this.$namespace;
|
|
498
|
+
return _possibleConstructorReturn(this, result);
|
|
466
499
|
};
|
|
500
|
+
}
|
|
467
501
|
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
502
|
+
var SVGContextService = /*#__PURE__*/function () {
|
|
503
|
+
function SVGContextService() {
|
|
504
|
+
_classCallCheck(this, SVGContextService);
|
|
471
505
|
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
506
|
+
this.$container = void 0;
|
|
507
|
+
this.$namespace = void 0;
|
|
508
|
+
this.dpr = void 0;
|
|
509
|
+
this.canvasConfig = void 0;
|
|
510
|
+
}
|
|
475
511
|
|
|
476
|
-
|
|
477
|
-
|
|
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
|
+
}
|
|
478
537
|
|
|
479
|
-
|
|
480
|
-
|
|
538
|
+
dpr = window.devicePixelRatio || 1;
|
|
539
|
+
dpr = dpr >= 1 ? Math.ceil(dpr) : 1;
|
|
540
|
+
this.dpr = dpr;
|
|
481
541
|
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
542
|
+
case 6:
|
|
543
|
+
case "end":
|
|
544
|
+
return _context.stop();
|
|
545
|
+
}
|
|
546
|
+
}
|
|
547
|
+
}, _callee, this);
|
|
548
|
+
}));
|
|
549
|
+
|
|
550
|
+
function init() {
|
|
551
|
+
return _init.apply(this, arguments);
|
|
552
|
+
}
|
|
553
|
+
|
|
554
|
+
return init;
|
|
555
|
+
}() // @ts-ignore
|
|
488
556
|
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
this.$namespace
|
|
557
|
+
}, {
|
|
558
|
+
key: "getDomElement",
|
|
559
|
+
value: function getDomElement() {
|
|
560
|
+
return this.$namespace;
|
|
493
561
|
}
|
|
494
|
-
}
|
|
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;
|
|
571
|
+
}
|
|
572
|
+
}, {
|
|
573
|
+
key: "getBoundingClientRect",
|
|
574
|
+
value: function getBoundingClientRect() {
|
|
575
|
+
var _this$$namespace;
|
|
495
576
|
|
|
496
|
-
|
|
497
|
-
if (this.$container) {
|
|
498
|
-
this.$container.style.cursor = cursor;
|
|
577
|
+
return (_this$$namespace = this.$namespace) === null || _this$$namespace === void 0 ? void 0 : _this$$namespace.getBoundingClientRect();
|
|
499
578
|
}
|
|
500
|
-
}
|
|
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
|
+
}
|
|
594
|
+
}
|
|
595
|
+
}, {
|
|
596
|
+
key: "applyCursorStyle",
|
|
597
|
+
value: function applyCursorStyle(cursor) {
|
|
598
|
+
if (this.$container) {
|
|
599
|
+
this.$container.style.cursor = cursor;
|
|
600
|
+
}
|
|
601
|
+
}
|
|
602
|
+
}]);
|
|
501
603
|
|
|
502
604
|
return SVGContextService;
|
|
503
605
|
}();
|
|
@@ -516,29 +618,37 @@ var containerModule = Module(function (register) {
|
|
|
516
618
|
});
|
|
517
619
|
var ContextRegisterPlugin = /*#__PURE__*/function () {
|
|
518
620
|
function ContextRegisterPlugin() {
|
|
621
|
+
_classCallCheck(this, ContextRegisterPlugin);
|
|
622
|
+
|
|
519
623
|
this.name = 'svg-context-register';
|
|
520
624
|
}
|
|
521
625
|
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
container
|
|
530
|
-
|
|
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
|
+
}]);
|
|
531
637
|
|
|
532
638
|
return ContextRegisterPlugin;
|
|
533
639
|
}();
|
|
534
640
|
|
|
535
641
|
var Renderer = /*#__PURE__*/function (_AbstractRenderer) {
|
|
536
|
-
|
|
642
|
+
_inherits(Renderer, _AbstractRenderer);
|
|
643
|
+
|
|
644
|
+
var _super = _createSuper(Renderer);
|
|
537
645
|
|
|
538
646
|
function Renderer(config) {
|
|
539
647
|
var _this;
|
|
540
648
|
|
|
541
|
-
|
|
649
|
+
_classCallCheck(this, Renderer);
|
|
650
|
+
|
|
651
|
+
_this = _super.call(this, config);
|
|
542
652
|
|
|
543
653
|
_this.registerPlugin(new ContextRegisterPlugin());
|
|
544
654
|
|
|
@@ -551,7 +661,7 @@ var Renderer = /*#__PURE__*/function (_AbstractRenderer) {
|
|
|
551
661
|
return _this;
|
|
552
662
|
}
|
|
553
663
|
|
|
554
|
-
return Renderer;
|
|
664
|
+
return _createClass(Renderer);
|
|
555
665
|
}(AbstractRenderer);
|
|
556
666
|
|
|
557
667
|
export { Renderer };
|