@antv/g-svg 1.0.0-alpha.20 → 1.0.0-alpha.24
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/es/ContextRegisterPlugin.d.ts +6 -0
- package/es/ContextRegisterPlugin.js +13 -22
- package/es/SVGContextService.d.ts +15 -0
- package/es/SVGContextService.js +62 -92
- package/es/index.d.ts +4 -0
- package/es/index.js +7 -27
- package/es/utils/format.d.ts +6 -0
- package/lib/ContextRegisterPlugin.d.ts +6 -0
- package/lib/ContextRegisterPlugin.js +10 -22
- package/lib/SVGContextService.d.ts +15 -0
- package/lib/SVGContextService.js +53 -85
- package/lib/index.d.ts +4 -0
- package/lib/index.js +5 -27
- package/lib/utils/format.d.ts +6 -0
- package/package.json +6 -8
|
@@ -1,9 +1,3 @@
|
|
|
1
|
-
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
2
|
-
|
|
3
|
-
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
|
|
4
|
-
|
|
5
|
-
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
|
|
6
|
-
|
|
7
1
|
import { ContainerModule } from 'inversify';
|
|
8
2
|
import { ContextService } from '@antv/g';
|
|
9
3
|
import { SVGContextService } from './SVGContextService';
|
|
@@ -14,22 +8,19 @@ var containerModule = new ContainerModule(function (bind, unbind, isBound, rebin
|
|
|
14
8
|
bind(SVGContextService).toSelf().inSingletonScope();
|
|
15
9
|
bind(ContextService).toService(SVGContextService);
|
|
16
10
|
});
|
|
17
|
-
export var ContextRegisterPlugin = /*#__PURE__*/function () {
|
|
18
|
-
function ContextRegisterPlugin() {
|
|
19
|
-
_classCallCheck(this, ContextRegisterPlugin);
|
|
20
|
-
}
|
|
21
11
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
}]);
|
|
12
|
+
var ContextRegisterPlugin = function () {
|
|
13
|
+
function ContextRegisterPlugin() {}
|
|
14
|
+
|
|
15
|
+
ContextRegisterPlugin.prototype.init = function (container) {
|
|
16
|
+
container.load(containerModule);
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
ContextRegisterPlugin.prototype.destroy = function (container) {
|
|
20
|
+
container.unload(containerModule);
|
|
21
|
+
};
|
|
33
22
|
|
|
34
23
|
return ContextRegisterPlugin;
|
|
35
|
-
}();
|
|
24
|
+
}();
|
|
25
|
+
|
|
26
|
+
export { ContextRegisterPlugin };
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { ContextService } from '@antv/g';
|
|
2
|
+
export declare class SVGContextService implements ContextService<SVGElement> {
|
|
3
|
+
private $container;
|
|
4
|
+
private $namespace;
|
|
5
|
+
private dpr;
|
|
6
|
+
private canvasConfig;
|
|
7
|
+
init(): void;
|
|
8
|
+
getDomElement(): SVGElement;
|
|
9
|
+
getContext(): SVGElement;
|
|
10
|
+
getDPR(): number;
|
|
11
|
+
getBoundingClientRect(): DOMRect;
|
|
12
|
+
destroy(): void;
|
|
13
|
+
resize(width: number, height: number): void;
|
|
14
|
+
applyCursorStyle(cursor: string): void;
|
|
15
|
+
}
|
package/es/SVGContextService.js
CHANGED
|
@@ -1,107 +1,77 @@
|
|
|
1
|
-
|
|
1
|
+
import { __decorate, __metadata } from "tslib";
|
|
2
|
+
import { CanvasConfig } from '@antv/g';
|
|
3
|
+
import { inject, injectable } from 'inversify';
|
|
4
|
+
import { isString } from '@antv/util';
|
|
5
|
+
import { createSVGElement } from '@antv/g-plugin-svg-renderer';
|
|
2
6
|
|
|
3
|
-
|
|
7
|
+
var SVGContextService = function () {
|
|
8
|
+
function SVGContextService() {}
|
|
4
9
|
|
|
5
|
-
|
|
10
|
+
SVGContextService.prototype.init = function () {
|
|
11
|
+
var container = this.canvasConfig.container; // create container
|
|
6
12
|
|
|
7
|
-
|
|
13
|
+
this.$container = isString(container) ? document.getElementById(container) : container;
|
|
8
14
|
|
|
9
|
-
|
|
15
|
+
if (this.$container) {
|
|
16
|
+
if (!this.$container.style.position) {
|
|
17
|
+
this.$container.style.position = 'relative';
|
|
18
|
+
}
|
|
10
19
|
|
|
11
|
-
|
|
20
|
+
var $namespace = createSVGElement('svg');
|
|
21
|
+
$namespace.setAttribute('width', "" + this.canvasConfig.width);
|
|
22
|
+
$namespace.setAttribute('height', "" + this.canvasConfig.height);
|
|
23
|
+
this.$container.appendChild($namespace);
|
|
24
|
+
this.$namespace = $namespace;
|
|
25
|
+
}
|
|
12
26
|
|
|
13
|
-
|
|
27
|
+
var dpr = window.devicePixelRatio || 1;
|
|
28
|
+
dpr = dpr >= 1 ? Math.ceil(dpr) : 1;
|
|
29
|
+
this.dpr = dpr;
|
|
30
|
+
}; // @ts-ignore
|
|
14
31
|
|
|
15
|
-
import { CanvasConfig } from '@antv/g';
|
|
16
|
-
import { inject, injectable } from 'inversify';
|
|
17
|
-
import { isString } from '@antv/util';
|
|
18
|
-
import { createSVGElement } from '@antv/g-plugin-svg-renderer';
|
|
19
|
-
export var SVGContextService = (_dec = injectable(), _dec2 = inject(CanvasConfig), _dec(_class = (_class2 = /*#__PURE__*/function () {
|
|
20
|
-
function SVGContextService() {
|
|
21
|
-
_classCallCheck(this, SVGContextService);
|
|
22
|
-
|
|
23
|
-
this.$container = void 0;
|
|
24
|
-
this.$namespace = void 0;
|
|
25
|
-
this.dpr = void 0;
|
|
26
|
-
|
|
27
|
-
_initializerDefineProperty(this, "canvasConfig", _descriptor, this);
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
_createClass(SVGContextService, [{
|
|
31
|
-
key: "init",
|
|
32
|
-
value: function init() {
|
|
33
|
-
var container = this.canvasConfig.container; // create container
|
|
34
|
-
|
|
35
|
-
this.$container = isString(container) ? document.getElementById(container) : container;
|
|
36
|
-
|
|
37
|
-
if (this.$container) {
|
|
38
|
-
if (!this.$container.style.position) {
|
|
39
|
-
this.$container.style.position = 'relative';
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
var $namespace = createSVGElement('svg');
|
|
43
|
-
$namespace.setAttribute('width', "".concat(this.canvasConfig.width));
|
|
44
|
-
$namespace.setAttribute('height', "".concat(this.canvasConfig.height));
|
|
45
|
-
this.$container.appendChild($namespace);
|
|
46
|
-
this.$namespace = $namespace;
|
|
47
|
-
}
|
|
48
32
|
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
} // @ts-ignore
|
|
33
|
+
SVGContextService.prototype.getDomElement = function () {
|
|
34
|
+
return this.$namespace;
|
|
35
|
+
};
|
|
53
36
|
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
return this.$namespace;
|
|
58
|
-
}
|
|
59
|
-
}, {
|
|
60
|
-
key: "getContext",
|
|
61
|
-
value: function getContext() {
|
|
62
|
-
return this.$namespace;
|
|
63
|
-
}
|
|
64
|
-
}, {
|
|
65
|
-
key: "getDPR",
|
|
66
|
-
value: function getDPR() {
|
|
67
|
-
return this.dpr;
|
|
68
|
-
}
|
|
69
|
-
}, {
|
|
70
|
-
key: "getBoundingClientRect",
|
|
71
|
-
value: function getBoundingClientRect() {
|
|
72
|
-
var _this$$namespace;
|
|
37
|
+
SVGContextService.prototype.getContext = function () {
|
|
38
|
+
return this.$namespace;
|
|
39
|
+
};
|
|
73
40
|
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
41
|
+
SVGContextService.prototype.getDPR = function () {
|
|
42
|
+
return this.dpr;
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
SVGContextService.prototype.getBoundingClientRect = function () {
|
|
46
|
+
var _a;
|
|
47
|
+
|
|
48
|
+
return (_a = this.$namespace) === null || _a === void 0 ? void 0 : _a.getBoundingClientRect();
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
SVGContextService.prototype.destroy = function () {
|
|
52
|
+
// destroy context
|
|
53
|
+
if (this.$container && this.$namespace && this.$namespace.parentNode) {
|
|
54
|
+
this.$container.removeChild(this.$namespace);
|
|
83
55
|
}
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
}
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
SVGContextService.prototype.resize = function (width, height) {
|
|
59
|
+
if (this.$namespace) {
|
|
60
|
+
this.$namespace.setAttribute('width', "" + width);
|
|
61
|
+
this.$namespace.setAttribute('height', "" + height);
|
|
91
62
|
}
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
}
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
SVGContextService.prototype.applyCursorStyle = function (cursor) {
|
|
66
|
+
if (this.$container) {
|
|
67
|
+
this.$container.style.cursor = cursor;
|
|
98
68
|
}
|
|
99
|
-
}
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
__decorate([inject(CanvasConfig), __metadata("design:type", Object)], SVGContextService.prototype, "canvasConfig", void 0);
|
|
100
72
|
|
|
73
|
+
SVGContextService = __decorate([injectable()], SVGContextService);
|
|
101
74
|
return SVGContextService;
|
|
102
|
-
}()
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
writable: true,
|
|
106
|
-
initializer: null
|
|
107
|
-
})), _class2)) || _class);
|
|
75
|
+
}();
|
|
76
|
+
|
|
77
|
+
export { SVGContextService };
|
package/es/index.d.ts
ADDED
package/es/index.js
CHANGED
|
@@ -1,37 +1,15 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
4
|
-
|
|
5
|
-
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
|
|
6
|
-
|
|
7
|
-
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
|
8
|
-
|
|
9
|
-
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
10
|
-
|
|
11
|
-
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
|
|
12
|
-
|
|
13
|
-
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
14
|
-
|
|
15
|
-
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
16
|
-
|
|
17
|
-
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
18
|
-
|
|
1
|
+
import { __extends } from "tslib";
|
|
19
2
|
import { AbstractRenderer } from '@antv/g';
|
|
20
3
|
import { Plugin as DomInteractionPlugin } from '@antv/g-plugin-dom-interaction';
|
|
21
4
|
import { Plugin as SvgRendererPlugin } from '@antv/g-plugin-svg-renderer';
|
|
22
5
|
import { Plugin as SvgPickerPlugin } from '@antv/g-plugin-svg-picker';
|
|
23
6
|
import { ContextRegisterPlugin } from './ContextRegisterPlugin';
|
|
24
|
-
export var Renderer = /*#__PURE__*/function (_AbstractRenderer) {
|
|
25
|
-
_inherits(Renderer, _AbstractRenderer);
|
|
26
7
|
|
|
27
|
-
|
|
8
|
+
var Renderer = function (_super) {
|
|
9
|
+
__extends(Renderer, _super);
|
|
28
10
|
|
|
29
11
|
function Renderer(config) {
|
|
30
|
-
var _this;
|
|
31
|
-
|
|
32
|
-
_classCallCheck(this, Renderer);
|
|
33
|
-
|
|
34
|
-
_this = _super.call(this, config);
|
|
12
|
+
var _this = _super.call(this, config) || this;
|
|
35
13
|
|
|
36
14
|
_this.registerPlugin(new ContextRegisterPlugin());
|
|
37
15
|
|
|
@@ -45,4 +23,6 @@ export var Renderer = /*#__PURE__*/function (_AbstractRenderer) {
|
|
|
45
23
|
}
|
|
46
24
|
|
|
47
25
|
return Renderer;
|
|
48
|
-
}(AbstractRenderer);
|
|
26
|
+
}(AbstractRenderer);
|
|
27
|
+
|
|
28
|
+
export { Renderer };
|
|
@@ -11,12 +11,6 @@ var _g = require("@antv/g");
|
|
|
11
11
|
|
|
12
12
|
var _SVGContextService = require("./SVGContextService");
|
|
13
13
|
|
|
14
|
-
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
15
|
-
|
|
16
|
-
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
|
|
17
|
-
|
|
18
|
-
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
|
|
19
|
-
|
|
20
14
|
var containerModule = new _inversify.ContainerModule(function (bind, unbind, isBound, rebind) {
|
|
21
15
|
/**
|
|
22
16
|
* implements ContextService
|
|
@@ -25,22 +19,16 @@ var containerModule = new _inversify.ContainerModule(function (bind, unbind, isB
|
|
|
25
19
|
bind(_g.ContextService).toService(_SVGContextService.SVGContextService);
|
|
26
20
|
});
|
|
27
21
|
|
|
28
|
-
var ContextRegisterPlugin =
|
|
29
|
-
function ContextRegisterPlugin() {
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
}, {
|
|
39
|
-
key: "destroy",
|
|
40
|
-
value: function destroy(container) {
|
|
41
|
-
container.unload(containerModule);
|
|
42
|
-
}
|
|
43
|
-
}]);
|
|
22
|
+
var ContextRegisterPlugin = function () {
|
|
23
|
+
function ContextRegisterPlugin() {}
|
|
24
|
+
|
|
25
|
+
ContextRegisterPlugin.prototype.init = function (container) {
|
|
26
|
+
container.load(containerModule);
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
ContextRegisterPlugin.prototype.destroy = function (container) {
|
|
30
|
+
container.unload(containerModule);
|
|
31
|
+
};
|
|
44
32
|
|
|
45
33
|
return ContextRegisterPlugin;
|
|
46
34
|
}();
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { ContextService } from '@antv/g';
|
|
2
|
+
export declare class SVGContextService implements ContextService<SVGElement> {
|
|
3
|
+
private $container;
|
|
4
|
+
private $namespace;
|
|
5
|
+
private dpr;
|
|
6
|
+
private canvasConfig;
|
|
7
|
+
init(): void;
|
|
8
|
+
getDomElement(): SVGElement;
|
|
9
|
+
getContext(): SVGElement;
|
|
10
|
+
getDPR(): number;
|
|
11
|
+
getBoundingClientRect(): DOMRect;
|
|
12
|
+
destroy(): void;
|
|
13
|
+
resize(width: number, height: number): void;
|
|
14
|
+
applyCursorStyle(cursor: string): void;
|
|
15
|
+
}
|
package/lib/SVGContextService.js
CHANGED
|
@@ -5,6 +5,8 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.SVGContextService = void 0;
|
|
7
7
|
|
|
8
|
+
var _tslib = require("tslib");
|
|
9
|
+
|
|
8
10
|
var _g = require("@antv/g");
|
|
9
11
|
|
|
10
12
|
var _inversify = require("inversify");
|
|
@@ -13,107 +15,73 @@ var _util = require("@antv/util");
|
|
|
13
15
|
|
|
14
16
|
var _gPluginSvgRenderer = require("@antv/g-plugin-svg-renderer");
|
|
15
17
|
|
|
16
|
-
var
|
|
17
|
-
|
|
18
|
-
function _initializerDefineProperty(target, property, descriptor, context) { if (!descriptor) return; Object.defineProperty(target, property, { enumerable: descriptor.enumerable, configurable: descriptor.configurable, writable: descriptor.writable, value: descriptor.initializer ? descriptor.initializer.call(context) : void 0 }); }
|
|
19
|
-
|
|
20
|
-
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
21
|
-
|
|
22
|
-
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
|
|
18
|
+
var SVGContextService = function () {
|
|
19
|
+
function SVGContextService() {}
|
|
23
20
|
|
|
24
|
-
|
|
21
|
+
SVGContextService.prototype.init = function () {
|
|
22
|
+
var container = this.canvasConfig.container; // create container
|
|
25
23
|
|
|
26
|
-
|
|
24
|
+
this.$container = (0, _util.isString)(container) ? document.getElementById(container) : container;
|
|
27
25
|
|
|
28
|
-
|
|
26
|
+
if (this.$container) {
|
|
27
|
+
if (!this.$container.style.position) {
|
|
28
|
+
this.$container.style.position = 'relative';
|
|
29
|
+
}
|
|
29
30
|
|
|
30
|
-
var
|
|
31
|
-
|
|
32
|
-
|
|
31
|
+
var $namespace = (0, _gPluginSvgRenderer.createSVGElement)('svg');
|
|
32
|
+
$namespace.setAttribute('width', "" + this.canvasConfig.width);
|
|
33
|
+
$namespace.setAttribute('height', "" + this.canvasConfig.height);
|
|
34
|
+
this.$container.appendChild($namespace);
|
|
35
|
+
this.$namespace = $namespace;
|
|
36
|
+
}
|
|
33
37
|
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
this.dpr =
|
|
38
|
+
var dpr = window.devicePixelRatio || 1;
|
|
39
|
+
dpr = dpr >= 1 ? Math.ceil(dpr) : 1;
|
|
40
|
+
this.dpr = dpr;
|
|
41
|
+
}; // @ts-ignore
|
|
37
42
|
|
|
38
|
-
_initializerDefineProperty(this, "canvasConfig", _descriptor, this);
|
|
39
|
-
}
|
|
40
43
|
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
var container = this.canvasConfig.container; // create container
|
|
44
|
+
SVGContextService.prototype.getDomElement = function () {
|
|
45
|
+
return this.$namespace;
|
|
46
|
+
};
|
|
45
47
|
|
|
46
|
-
|
|
48
|
+
SVGContextService.prototype.getContext = function () {
|
|
49
|
+
return this.$namespace;
|
|
50
|
+
};
|
|
47
51
|
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
}
|
|
52
|
+
SVGContextService.prototype.getDPR = function () {
|
|
53
|
+
return this.dpr;
|
|
54
|
+
};
|
|
52
55
|
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
$namespace.setAttribute('height', "".concat(this.canvasConfig.height));
|
|
56
|
-
this.$container.appendChild($namespace);
|
|
57
|
-
this.$namespace = $namespace;
|
|
58
|
-
}
|
|
56
|
+
SVGContextService.prototype.getBoundingClientRect = function () {
|
|
57
|
+
var _a;
|
|
59
58
|
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
this.dpr = dpr;
|
|
63
|
-
} // @ts-ignore
|
|
59
|
+
return (_a = this.$namespace) === null || _a === void 0 ? void 0 : _a.getBoundingClientRect();
|
|
60
|
+
};
|
|
64
61
|
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
}
|
|
70
|
-
}, {
|
|
71
|
-
key: "getContext",
|
|
72
|
-
value: function getContext() {
|
|
73
|
-
return this.$namespace;
|
|
62
|
+
SVGContextService.prototype.destroy = function () {
|
|
63
|
+
// destroy context
|
|
64
|
+
if (this.$container && this.$namespace && this.$namespace.parentNode) {
|
|
65
|
+
this.$container.removeChild(this.$namespace);
|
|
74
66
|
}
|
|
75
|
-
}
|
|
76
|
-
key: "getDPR",
|
|
77
|
-
value: function getDPR() {
|
|
78
|
-
return this.dpr;
|
|
79
|
-
}
|
|
80
|
-
}, {
|
|
81
|
-
key: "getBoundingClientRect",
|
|
82
|
-
value: function getBoundingClientRect() {
|
|
83
|
-
var _this$$namespace;
|
|
67
|
+
};
|
|
84
68
|
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
value: function destroy() {
|
|
90
|
-
// destroy context
|
|
91
|
-
if (this.$container && this.$namespace && this.$namespace.parentNode) {
|
|
92
|
-
this.$container.removeChild(this.$namespace);
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
}, {
|
|
96
|
-
key: "resize",
|
|
97
|
-
value: function resize(width, height) {
|
|
98
|
-
if (this.$namespace) {
|
|
99
|
-
this.$namespace.setAttribute('width', "".concat(width));
|
|
100
|
-
this.$namespace.setAttribute('height', "".concat(height));
|
|
101
|
-
}
|
|
69
|
+
SVGContextService.prototype.resize = function (width, height) {
|
|
70
|
+
if (this.$namespace) {
|
|
71
|
+
this.$namespace.setAttribute('width', "" + width);
|
|
72
|
+
this.$namespace.setAttribute('height', "" + height);
|
|
102
73
|
}
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
}
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
SVGContextService.prototype.applyCursorStyle = function (cursor) {
|
|
77
|
+
if (this.$container) {
|
|
78
|
+
this.$container.style.cursor = cursor;
|
|
109
79
|
}
|
|
110
|
-
}
|
|
80
|
+
};
|
|
111
81
|
|
|
82
|
+
(0, _tslib.__decorate)([(0, _inversify.inject)(_g.CanvasConfig), (0, _tslib.__metadata)("design:type", Object)], SVGContextService.prototype, "canvasConfig", void 0);
|
|
83
|
+
SVGContextService = (0, _tslib.__decorate)([(0, _inversify.injectable)()], SVGContextService);
|
|
112
84
|
return SVGContextService;
|
|
113
|
-
}()
|
|
114
|
-
|
|
115
|
-
enumerable: true,
|
|
116
|
-
writable: true,
|
|
117
|
-
initializer: null
|
|
118
|
-
})), _class2)) || _class);
|
|
85
|
+
}();
|
|
86
|
+
|
|
119
87
|
exports.SVGContextService = SVGContextService;
|
package/lib/index.d.ts
ADDED
package/lib/index.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
|
|
4
|
-
|
|
5
3
|
Object.defineProperty(exports, "__esModule", {
|
|
6
4
|
value: true
|
|
7
5
|
});
|
|
8
6
|
exports.Renderer = void 0;
|
|
9
7
|
|
|
8
|
+
var _tslib = require("tslib");
|
|
9
|
+
|
|
10
10
|
var _g = require("@antv/g");
|
|
11
11
|
|
|
12
12
|
var _gPluginDomInteraction = require("@antv/g-plugin-dom-interaction");
|
|
@@ -17,33 +17,11 @@ var _gPluginSvgPicker = require("@antv/g-plugin-svg-picker");
|
|
|
17
17
|
|
|
18
18
|
var _ContextRegisterPlugin = require("./ContextRegisterPlugin");
|
|
19
19
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
|
|
23
|
-
|
|
24
|
-
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
|
25
|
-
|
|
26
|
-
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
27
|
-
|
|
28
|
-
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
|
|
29
|
-
|
|
30
|
-
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
31
|
-
|
|
32
|
-
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
33
|
-
|
|
34
|
-
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
35
|
-
|
|
36
|
-
var Renderer = /*#__PURE__*/function (_AbstractRenderer) {
|
|
37
|
-
_inherits(Renderer, _AbstractRenderer);
|
|
38
|
-
|
|
39
|
-
var _super = _createSuper(Renderer);
|
|
20
|
+
var Renderer = function (_super) {
|
|
21
|
+
(0, _tslib.__extends)(Renderer, _super);
|
|
40
22
|
|
|
41
23
|
function Renderer(config) {
|
|
42
|
-
var _this;
|
|
43
|
-
|
|
44
|
-
_classCallCheck(this, Renderer);
|
|
45
|
-
|
|
46
|
-
_this = _super.call(this, config);
|
|
24
|
+
var _this = _super.call(this, config) || this;
|
|
47
25
|
|
|
48
26
|
_this.registerPlugin(new _ContextRegisterPlugin.ContextRegisterPlugin());
|
|
49
27
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@antv/g-svg",
|
|
3
|
-
"version": "1.0.0-alpha.
|
|
3
|
+
"version": "1.0.0-alpha.24",
|
|
4
4
|
"description": "A renderer implemented by SVG",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"module": "es/index.js",
|
|
@@ -39,13 +39,11 @@
|
|
|
39
39
|
},
|
|
40
40
|
"homepage": "https://github.com/antvis/g#readme",
|
|
41
41
|
"dependencies": {
|
|
42
|
-
"@antv/g
|
|
43
|
-
"@antv/g-plugin-
|
|
44
|
-
"@antv/g-plugin-svg-
|
|
42
|
+
"@antv/g": "^1.0.0-alpha.24",
|
|
43
|
+
"@antv/g-plugin-dom-interaction": "^1.0.0-alpha.23",
|
|
44
|
+
"@antv/g-plugin-svg-picker": "^1.0.0-alpha.23",
|
|
45
|
+
"@antv/g-plugin-svg-renderer": "^1.0.0-alpha.24",
|
|
45
46
|
"@antv/util": "^2.0.13"
|
|
46
47
|
},
|
|
47
|
-
"
|
|
48
|
-
"@antv/g": "^1.0.0-alpha.17"
|
|
49
|
-
},
|
|
50
|
-
"gitHead": "bfcb87639cfb109825e1d4515ffef6ea48e2b65f"
|
|
48
|
+
"gitHead": "fb9ebf362059d1f55a855856f05d42514a72c922"
|
|
51
49
|
}
|