@antv/g-svg 1.0.0-alpha.21 → 1.0.0-alpha.25
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 → dist}/ContextRegisterPlugin.d.ts +6 -6
- package/{lib → dist}/SVGContextService.d.ts +15 -15
- package/{es → dist}/index.d.ts +4 -4
- package/dist/index.esm.js +438 -0
- package/dist/index.js +442 -0
- package/dist/index.umd.js +22659 -0
- package/dist/index.umd.min.js +104 -0
- package/{es → dist}/utils/format.d.ts +6 -6
- package/package.json +9 -13
- package/es/ContextRegisterPlugin.js +0 -26
- package/es/SVGContextService.d.ts +0 -15
- package/es/SVGContextService.js +0 -77
- package/es/index.js +0 -28
- package/es/utils/format.js +0 -34
- package/lib/ContextRegisterPlugin.d.ts +0 -6
- package/lib/ContextRegisterPlugin.js +0 -36
- package/lib/SVGContextService.js +0 -87
- package/lib/index.d.ts +0 -4
- package/lib/index.js +0 -40
- package/lib/utils/format.d.ts +0 -6
- package/lib/utils/format.js +0 -42
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
export declare function parseRadius(radius: number[]): {
|
|
2
|
-
r1: number;
|
|
3
|
-
r2: number;
|
|
4
|
-
r3: number;
|
|
5
|
-
r4: number;
|
|
6
|
-
};
|
|
1
|
+
export declare function parseRadius(radius: number[]): {
|
|
2
|
+
r1: number;
|
|
3
|
+
r2: number;
|
|
4
|
+
r3: number;
|
|
5
|
+
r4: number;
|
|
6
|
+
};
|
package/package.json
CHANGED
|
@@ -1,14 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@antv/g-svg",
|
|
3
|
-
"version": "1.0.0-alpha.
|
|
3
|
+
"version": "1.0.0-alpha.25",
|
|
4
4
|
"description": "A renderer implemented by SVG",
|
|
5
|
-
"main": "
|
|
6
|
-
"module": "
|
|
7
|
-
"types": "
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"module": "dist/index.esm.js",
|
|
7
|
+
"types": "dist/index.d.ts",
|
|
8
8
|
"files": [
|
|
9
9
|
"package.json",
|
|
10
|
-
"es",
|
|
11
|
-
"lib",
|
|
12
10
|
"dist",
|
|
13
11
|
"LICENSE",
|
|
14
12
|
"README.md"
|
|
@@ -39,13 +37,11 @@
|
|
|
39
37
|
},
|
|
40
38
|
"homepage": "https://github.com/antvis/g#readme",
|
|
41
39
|
"dependencies": {
|
|
42
|
-
"@antv/g
|
|
43
|
-
"@antv/g-plugin-
|
|
44
|
-
"@antv/g-plugin-svg-
|
|
40
|
+
"@antv/g": "^1.0.0-alpha.25",
|
|
41
|
+
"@antv/g-plugin-dom-interaction": "^1.0.0-alpha.24",
|
|
42
|
+
"@antv/g-plugin-svg-picker": "^1.0.0-alpha.24",
|
|
43
|
+
"@antv/g-plugin-svg-renderer": "^1.0.0-alpha.25",
|
|
45
44
|
"@antv/util": "^2.0.13"
|
|
46
45
|
},
|
|
47
|
-
"
|
|
48
|
-
"@antv/g": "^1.0.0-alpha.17"
|
|
49
|
-
},
|
|
50
|
-
"gitHead": "9dd75b27ba6bf0c42256b1971cde602a765e7f23"
|
|
46
|
+
"gitHead": "e2b8bc287c7faa181013d9e5df071ff97d702c94"
|
|
51
47
|
}
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import { ContainerModule } from 'inversify';
|
|
2
|
-
import { ContextService } from '@antv/g';
|
|
3
|
-
import { SVGContextService } from './SVGContextService';
|
|
4
|
-
var containerModule = new ContainerModule(function (bind, unbind, isBound, rebind) {
|
|
5
|
-
/**
|
|
6
|
-
* implements ContextService
|
|
7
|
-
*/
|
|
8
|
-
bind(SVGContextService).toSelf().inSingletonScope();
|
|
9
|
-
bind(ContextService).toService(SVGContextService);
|
|
10
|
-
});
|
|
11
|
-
|
|
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
|
-
};
|
|
22
|
-
|
|
23
|
-
return ContextRegisterPlugin;
|
|
24
|
-
}();
|
|
25
|
-
|
|
26
|
-
export { ContextRegisterPlugin };
|
|
@@ -1,15 +0,0 @@
|
|
|
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
DELETED
|
@@ -1,77 +0,0 @@
|
|
|
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';
|
|
6
|
-
|
|
7
|
-
var SVGContextService = function () {
|
|
8
|
-
function SVGContextService() {}
|
|
9
|
-
|
|
10
|
-
SVGContextService.prototype.init = function () {
|
|
11
|
-
var container = this.canvasConfig.container; // create container
|
|
12
|
-
|
|
13
|
-
this.$container = isString(container) ? document.getElementById(container) : container;
|
|
14
|
-
|
|
15
|
-
if (this.$container) {
|
|
16
|
-
if (!this.$container.style.position) {
|
|
17
|
-
this.$container.style.position = 'relative';
|
|
18
|
-
}
|
|
19
|
-
|
|
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
|
-
}
|
|
26
|
-
|
|
27
|
-
var dpr = window.devicePixelRatio || 1;
|
|
28
|
-
dpr = dpr >= 1 ? Math.ceil(dpr) : 1;
|
|
29
|
-
this.dpr = dpr;
|
|
30
|
-
}; // @ts-ignore
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
SVGContextService.prototype.getDomElement = function () {
|
|
34
|
-
return this.$namespace;
|
|
35
|
-
};
|
|
36
|
-
|
|
37
|
-
SVGContextService.prototype.getContext = function () {
|
|
38
|
-
return this.$namespace;
|
|
39
|
-
};
|
|
40
|
-
|
|
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);
|
|
55
|
-
}
|
|
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);
|
|
62
|
-
}
|
|
63
|
-
};
|
|
64
|
-
|
|
65
|
-
SVGContextService.prototype.applyCursorStyle = function (cursor) {
|
|
66
|
-
if (this.$container) {
|
|
67
|
-
this.$container.style.cursor = cursor;
|
|
68
|
-
}
|
|
69
|
-
};
|
|
70
|
-
|
|
71
|
-
__decorate([inject(CanvasConfig), __metadata("design:type", Object)], SVGContextService.prototype, "canvasConfig", void 0);
|
|
72
|
-
|
|
73
|
-
SVGContextService = __decorate([injectable()], SVGContextService);
|
|
74
|
-
return SVGContextService;
|
|
75
|
-
}();
|
|
76
|
-
|
|
77
|
-
export { SVGContextService };
|
package/es/index.js
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import { __extends } from "tslib";
|
|
2
|
-
import { AbstractRenderer } from '@antv/g';
|
|
3
|
-
import { Plugin as DomInteractionPlugin } from '@antv/g-plugin-dom-interaction';
|
|
4
|
-
import { Plugin as SvgRendererPlugin } from '@antv/g-plugin-svg-renderer';
|
|
5
|
-
import { Plugin as SvgPickerPlugin } from '@antv/g-plugin-svg-picker';
|
|
6
|
-
import { ContextRegisterPlugin } from './ContextRegisterPlugin';
|
|
7
|
-
|
|
8
|
-
var Renderer = function (_super) {
|
|
9
|
-
__extends(Renderer, _super);
|
|
10
|
-
|
|
11
|
-
function Renderer(config) {
|
|
12
|
-
var _this = _super.call(this, config) || this;
|
|
13
|
-
|
|
14
|
-
_this.registerPlugin(new ContextRegisterPlugin());
|
|
15
|
-
|
|
16
|
-
_this.registerPlugin(new SvgRendererPlugin());
|
|
17
|
-
|
|
18
|
-
_this.registerPlugin(new DomInteractionPlugin());
|
|
19
|
-
|
|
20
|
-
_this.registerPlugin(new SvgPickerPlugin());
|
|
21
|
-
|
|
22
|
-
return _this;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
return Renderer;
|
|
26
|
-
}(AbstractRenderer);
|
|
27
|
-
|
|
28
|
-
export { Renderer };
|
package/es/utils/format.js
DELETED
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import { isArray } from '@antv/util';
|
|
2
|
-
export function parseRadius(radius) {
|
|
3
|
-
var r1 = 0;
|
|
4
|
-
var r2 = 0;
|
|
5
|
-
var r3 = 0;
|
|
6
|
-
var r4 = 0;
|
|
7
|
-
|
|
8
|
-
if (isArray(radius)) {
|
|
9
|
-
if (radius.length === 1) {
|
|
10
|
-
r1 = r2 = r3 = r4 = radius[0];
|
|
11
|
-
} else if (radius.length === 2) {
|
|
12
|
-
r1 = r3 = radius[0];
|
|
13
|
-
r2 = r4 = radius[1];
|
|
14
|
-
} else if (radius.length === 3) {
|
|
15
|
-
r1 = radius[0];
|
|
16
|
-
r2 = r4 = radius[1];
|
|
17
|
-
r3 = radius[2];
|
|
18
|
-
} else {
|
|
19
|
-
r1 = radius[0];
|
|
20
|
-
r2 = radius[1];
|
|
21
|
-
r3 = radius[2];
|
|
22
|
-
r4 = radius[3];
|
|
23
|
-
}
|
|
24
|
-
} else {
|
|
25
|
-
r1 = r2 = r3 = r4 = radius;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
return {
|
|
29
|
-
r1: r1,
|
|
30
|
-
r2: r2,
|
|
31
|
-
r3: r3,
|
|
32
|
-
r4: r4
|
|
33
|
-
};
|
|
34
|
-
}
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.ContextRegisterPlugin = void 0;
|
|
7
|
-
|
|
8
|
-
var _inversify = require("inversify");
|
|
9
|
-
|
|
10
|
-
var _g = require("@antv/g");
|
|
11
|
-
|
|
12
|
-
var _SVGContextService = require("./SVGContextService");
|
|
13
|
-
|
|
14
|
-
var containerModule = new _inversify.ContainerModule(function (bind, unbind, isBound, rebind) {
|
|
15
|
-
/**
|
|
16
|
-
* implements ContextService
|
|
17
|
-
*/
|
|
18
|
-
bind(_SVGContextService.SVGContextService).toSelf().inSingletonScope();
|
|
19
|
-
bind(_g.ContextService).toService(_SVGContextService.SVGContextService);
|
|
20
|
-
});
|
|
21
|
-
|
|
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
|
-
};
|
|
32
|
-
|
|
33
|
-
return ContextRegisterPlugin;
|
|
34
|
-
}();
|
|
35
|
-
|
|
36
|
-
exports.ContextRegisterPlugin = ContextRegisterPlugin;
|
package/lib/SVGContextService.js
DELETED
|
@@ -1,87 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.SVGContextService = void 0;
|
|
7
|
-
|
|
8
|
-
var _tslib = require("tslib");
|
|
9
|
-
|
|
10
|
-
var _g = require("@antv/g");
|
|
11
|
-
|
|
12
|
-
var _inversify = require("inversify");
|
|
13
|
-
|
|
14
|
-
var _util = require("@antv/util");
|
|
15
|
-
|
|
16
|
-
var _gPluginSvgRenderer = require("@antv/g-plugin-svg-renderer");
|
|
17
|
-
|
|
18
|
-
var SVGContextService = function () {
|
|
19
|
-
function SVGContextService() {}
|
|
20
|
-
|
|
21
|
-
SVGContextService.prototype.init = function () {
|
|
22
|
-
var container = this.canvasConfig.container; // create container
|
|
23
|
-
|
|
24
|
-
this.$container = (0, _util.isString)(container) ? document.getElementById(container) : container;
|
|
25
|
-
|
|
26
|
-
if (this.$container) {
|
|
27
|
-
if (!this.$container.style.position) {
|
|
28
|
-
this.$container.style.position = 'relative';
|
|
29
|
-
}
|
|
30
|
-
|
|
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
|
-
}
|
|
37
|
-
|
|
38
|
-
var dpr = window.devicePixelRatio || 1;
|
|
39
|
-
dpr = dpr >= 1 ? Math.ceil(dpr) : 1;
|
|
40
|
-
this.dpr = dpr;
|
|
41
|
-
}; // @ts-ignore
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
SVGContextService.prototype.getDomElement = function () {
|
|
45
|
-
return this.$namespace;
|
|
46
|
-
};
|
|
47
|
-
|
|
48
|
-
SVGContextService.prototype.getContext = function () {
|
|
49
|
-
return this.$namespace;
|
|
50
|
-
};
|
|
51
|
-
|
|
52
|
-
SVGContextService.prototype.getDPR = function () {
|
|
53
|
-
return this.dpr;
|
|
54
|
-
};
|
|
55
|
-
|
|
56
|
-
SVGContextService.prototype.getBoundingClientRect = function () {
|
|
57
|
-
var _a;
|
|
58
|
-
|
|
59
|
-
return (_a = this.$namespace) === null || _a === void 0 ? void 0 : _a.getBoundingClientRect();
|
|
60
|
-
};
|
|
61
|
-
|
|
62
|
-
SVGContextService.prototype.destroy = function () {
|
|
63
|
-
// destroy context
|
|
64
|
-
if (this.$container && this.$namespace && this.$namespace.parentNode) {
|
|
65
|
-
this.$container.removeChild(this.$namespace);
|
|
66
|
-
}
|
|
67
|
-
};
|
|
68
|
-
|
|
69
|
-
SVGContextService.prototype.resize = function (width, height) {
|
|
70
|
-
if (this.$namespace) {
|
|
71
|
-
this.$namespace.setAttribute('width', "" + width);
|
|
72
|
-
this.$namespace.setAttribute('height', "" + height);
|
|
73
|
-
}
|
|
74
|
-
};
|
|
75
|
-
|
|
76
|
-
SVGContextService.prototype.applyCursorStyle = function (cursor) {
|
|
77
|
-
if (this.$container) {
|
|
78
|
-
this.$container.style.cursor = cursor;
|
|
79
|
-
}
|
|
80
|
-
};
|
|
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);
|
|
84
|
-
return SVGContextService;
|
|
85
|
-
}();
|
|
86
|
-
|
|
87
|
-
exports.SVGContextService = SVGContextService;
|
package/lib/index.d.ts
DELETED
package/lib/index.js
DELETED
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.Renderer = void 0;
|
|
7
|
-
|
|
8
|
-
var _tslib = require("tslib");
|
|
9
|
-
|
|
10
|
-
var _g = require("@antv/g");
|
|
11
|
-
|
|
12
|
-
var _gPluginDomInteraction = require("@antv/g-plugin-dom-interaction");
|
|
13
|
-
|
|
14
|
-
var _gPluginSvgRenderer = require("@antv/g-plugin-svg-renderer");
|
|
15
|
-
|
|
16
|
-
var _gPluginSvgPicker = require("@antv/g-plugin-svg-picker");
|
|
17
|
-
|
|
18
|
-
var _ContextRegisterPlugin = require("./ContextRegisterPlugin");
|
|
19
|
-
|
|
20
|
-
var Renderer = function (_super) {
|
|
21
|
-
(0, _tslib.__extends)(Renderer, _super);
|
|
22
|
-
|
|
23
|
-
function Renderer(config) {
|
|
24
|
-
var _this = _super.call(this, config) || this;
|
|
25
|
-
|
|
26
|
-
_this.registerPlugin(new _ContextRegisterPlugin.ContextRegisterPlugin());
|
|
27
|
-
|
|
28
|
-
_this.registerPlugin(new _gPluginSvgRenderer.Plugin());
|
|
29
|
-
|
|
30
|
-
_this.registerPlugin(new _gPluginDomInteraction.Plugin());
|
|
31
|
-
|
|
32
|
-
_this.registerPlugin(new _gPluginSvgPicker.Plugin());
|
|
33
|
-
|
|
34
|
-
return _this;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
return Renderer;
|
|
38
|
-
}(_g.AbstractRenderer);
|
|
39
|
-
|
|
40
|
-
exports.Renderer = Renderer;
|
package/lib/utils/format.d.ts
DELETED
package/lib/utils/format.js
DELETED
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.parseRadius = parseRadius;
|
|
7
|
-
|
|
8
|
-
var _util = require("@antv/util");
|
|
9
|
-
|
|
10
|
-
function parseRadius(radius) {
|
|
11
|
-
var r1 = 0;
|
|
12
|
-
var r2 = 0;
|
|
13
|
-
var r3 = 0;
|
|
14
|
-
var r4 = 0;
|
|
15
|
-
|
|
16
|
-
if ((0, _util.isArray)(radius)) {
|
|
17
|
-
if (radius.length === 1) {
|
|
18
|
-
r1 = r2 = r3 = r4 = radius[0];
|
|
19
|
-
} else if (radius.length === 2) {
|
|
20
|
-
r1 = r3 = radius[0];
|
|
21
|
-
r2 = r4 = radius[1];
|
|
22
|
-
} else if (radius.length === 3) {
|
|
23
|
-
r1 = radius[0];
|
|
24
|
-
r2 = r4 = radius[1];
|
|
25
|
-
r3 = radius[2];
|
|
26
|
-
} else {
|
|
27
|
-
r1 = radius[0];
|
|
28
|
-
r2 = radius[1];
|
|
29
|
-
r3 = radius[2];
|
|
30
|
-
r4 = radius[3];
|
|
31
|
-
}
|
|
32
|
-
} else {
|
|
33
|
-
r1 = r2 = r3 = r4 = radius;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
return {
|
|
37
|
-
r1: r1,
|
|
38
|
-
r2: r2,
|
|
39
|
-
r3: r3,
|
|
40
|
-
r4: r4
|
|
41
|
-
};
|
|
42
|
-
}
|