@antv/g-svg 1.0.0-alpha.27 → 1.0.0-alpha.30

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.
@@ -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
+ }
@@ -0,0 +1,91 @@
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 _manaSyringe = require("mana-syringe");
13
+
14
+ var _util = require("@antv/util");
15
+
16
+ var _gPluginSvgRenderer = require("@antv/g-plugin-svg-renderer");
17
+
18
+ var SVGContextService =
19
+ /** @class */
20
+ function () {
21
+ function SVGContextService() {}
22
+
23
+ SVGContextService.prototype.init = function () {
24
+ var container = this.canvasConfig.container; // create container
25
+
26
+ this.$container = (0, _util.isString)(container) ? document.getElementById(container) : container;
27
+
28
+ if (this.$container) {
29
+ if (!this.$container.style.position) {
30
+ this.$container.style.position = 'relative';
31
+ }
32
+
33
+ var $namespace = (0, _gPluginSvgRenderer.createSVGElement)('svg');
34
+ $namespace.setAttribute('width', "" + this.canvasConfig.width);
35
+ $namespace.setAttribute('height', "" + this.canvasConfig.height);
36
+ this.$container.appendChild($namespace);
37
+ this.$namespace = $namespace;
38
+ }
39
+
40
+ var dpr = window.devicePixelRatio || 1;
41
+ dpr = dpr >= 1 ? Math.ceil(dpr) : 1;
42
+ this.dpr = dpr;
43
+ }; // @ts-ignore
44
+
45
+
46
+ SVGContextService.prototype.getDomElement = function () {
47
+ return this.$namespace;
48
+ };
49
+
50
+ SVGContextService.prototype.getContext = function () {
51
+ return this.$namespace;
52
+ };
53
+
54
+ SVGContextService.prototype.getDPR = function () {
55
+ return this.dpr;
56
+ };
57
+
58
+ SVGContextService.prototype.getBoundingClientRect = function () {
59
+ var _a;
60
+
61
+ return (_a = this.$namespace) === null || _a === void 0 ? void 0 : _a.getBoundingClientRect();
62
+ };
63
+
64
+ SVGContextService.prototype.destroy = function () {
65
+ // destroy context
66
+ if (this.$container && this.$namespace && this.$namespace.parentNode) {
67
+ this.$container.removeChild(this.$namespace);
68
+ }
69
+ };
70
+
71
+ SVGContextService.prototype.resize = function (width, height) {
72
+ if (this.$namespace) {
73
+ this.$namespace.setAttribute('width', "" + width);
74
+ this.$namespace.setAttribute('height', "" + height);
75
+ }
76
+ };
77
+
78
+ SVGContextService.prototype.applyCursorStyle = function (cursor) {
79
+ if (this.$container) {
80
+ this.$container.style.cursor = cursor;
81
+ }
82
+ };
83
+
84
+ (0, _tslib.__decorate)([(0, _manaSyringe.inject)(_g.CanvasConfig), (0, _tslib.__metadata)("design:type", Object)], SVGContextService.prototype, "canvasConfig", void 0);
85
+ SVGContextService = (0, _tslib.__decorate)([(0, _manaSyringe.singleton)({
86
+ token: _g.ContextService
87
+ })], SVGContextService);
88
+ return SVGContextService;
89
+ }();
90
+
91
+ exports.SVGContextService = SVGContextService;
package/lib/index.d.ts ADDED
@@ -0,0 +1,8 @@
1
+ import { AbstractRenderer, RendererConfig } from '@antv/g';
2
+ import * as DomInteraction from '@antv/g-plugin-dom-interaction';
3
+ import * as SVGRenderer from '@antv/g-plugin-svg-renderer';
4
+ import * as SVGPicker from '@antv/g-plugin-svg-picker';
5
+ export { DomInteraction, SVGRenderer, SVGPicker };
6
+ export declare class Renderer extends AbstractRenderer {
7
+ constructor(config?: Partial<RendererConfig>);
8
+ }
package/lib/index.js ADDED
@@ -0,0 +1,54 @@
1
+ "use strict";
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
+ Object.defineProperty(exports, "__esModule", {
6
+ value: true
7
+ });
8
+ exports.SVGRenderer = exports.SVGPicker = exports.Renderer = exports.DomInteraction = void 0;
9
+
10
+ var _tslib = require("tslib");
11
+
12
+ var _g = require("@antv/g");
13
+
14
+ var DomInteraction = _interopRequireWildcard(require("@antv/g-plugin-dom-interaction"));
15
+
16
+ exports.DomInteraction = DomInteraction;
17
+
18
+ var SVGRenderer = _interopRequireWildcard(require("@antv/g-plugin-svg-renderer"));
19
+
20
+ exports.SVGRenderer = SVGRenderer;
21
+
22
+ var SVGPicker = _interopRequireWildcard(require("@antv/g-plugin-svg-picker"));
23
+
24
+ exports.SVGPicker = SVGPicker;
25
+
26
+ var _ContextRegisterPlugin = require("./ContextRegisterPlugin");
27
+
28
+ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
29
+
30
+ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
31
+
32
+ var Renderer =
33
+ /** @class */
34
+ function (_super) {
35
+ (0, _tslib.__extends)(Renderer, _super);
36
+
37
+ function Renderer(config) {
38
+ var _this = _super.call(this, config) || this;
39
+
40
+ _this.registerPlugin(new _ContextRegisterPlugin.ContextRegisterPlugin());
41
+
42
+ _this.registerPlugin(new SVGRenderer.Plugin());
43
+
44
+ _this.registerPlugin(new DomInteraction.Plugin());
45
+
46
+ _this.registerPlugin(new SVGPicker.Plugin());
47
+
48
+ return _this;
49
+ }
50
+
51
+ return Renderer;
52
+ }(_g.AbstractRenderer);
53
+
54
+ exports.Renderer = Renderer;
@@ -0,0 +1,6 @@
1
+ export declare function parseRadius(radius: number[]): {
2
+ r1: number;
3
+ r2: number;
4
+ r3: number;
5
+ r4: number;
6
+ };
@@ -0,0 +1,42 @@
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
+ }
package/package.json CHANGED
@@ -1,13 +1,16 @@
1
1
  {
2
2
  "name": "@antv/g-svg",
3
- "version": "1.0.0-alpha.27",
3
+ "version": "1.0.0-alpha.30",
4
4
  "description": "A renderer implemented by SVG",
5
- "main": "dist/index.js",
6
- "module": "dist/index.esm.js",
7
- "types": "dist/index.d.ts",
5
+ "main": "lib/index.js",
6
+ "module": "es/index.esm.js",
7
+ "types": "es/index.d.ts",
8
+ "unpkg": "dist/index.umd.js",
8
9
  "files": [
9
10
  "package.json",
10
11
  "dist",
12
+ "es",
13
+ "lib",
11
14
  "LICENSE",
12
15
  "README.md"
13
16
  ],
@@ -37,13 +40,19 @@
37
40
  },
38
41
  "homepage": "https://github.com/antvis/g#readme",
39
42
  "dependencies": {
40
- "@antv/g": "^1.0.0-alpha.27",
41
- "@antv/g-plugin-dom-interaction": "^1.0.0-alpha.26",
42
- "@antv/g-plugin-svg-picker": "^1.0.0-alpha.26",
43
- "@antv/g-plugin-svg-renderer": "^1.0.0-alpha.27",
43
+ "@antv/g": "^1.0.0-alpha.30",
44
+ "@antv/g-plugin-dom-interaction": "^1.0.0-alpha.29",
45
+ "@antv/g-plugin-svg-picker": "^1.0.0-alpha.29",
46
+ "@antv/g-plugin-svg-renderer": "^1.0.0-alpha.30",
44
47
  "@antv/util": "^2.0.13",
45
- "@babel/runtime": "^7.16.0",
46
- "mana-syringe": "^0.1.0"
48
+ "mana-syringe": "^0.2.2"
49
+ },
50
+ "peerDependencies": {
51
+ "@antv/g": "^1.0.0-alpha.27",
52
+ "mana-syringe": "^0.2.2"
53
+ },
54
+ "scripts": {
55
+ "umd": "webpack"
47
56
  },
48
- "gitHead": "c01101beb86f98aaa569f97c678c909d4f3faaa3"
57
+ "gitHead": "a5bedb7fc7482122f6d56b85d9c5654d16677203"
49
58
  }
package/dist/index.d.ts DELETED
@@ -1,4 +0,0 @@
1
- import { AbstractRenderer, RendererConfig } from '@antv/g';
2
- export declare class Renderer extends AbstractRenderer {
3
- constructor(config?: Partial<RendererConfig>);
4
- }
package/dist/index.esm.js DELETED
@@ -1,181 +0,0 @@
1
- import _classCallCheck from '@babel/runtime/helpers/esm/classCallCheck';
2
- import _inherits from '@babel/runtime/helpers/esm/inherits';
3
- import _createSuper from '@babel/runtime/helpers/esm/createSuper';
4
- import { CanvasConfig, ContextService, AbstractRenderer } from '@antv/g';
5
- import { Plugin as Plugin$1 } from '@antv/g-plugin-dom-interaction';
6
- import { createSVGElement, Plugin } from '@antv/g-plugin-svg-renderer';
7
- import { Plugin as Plugin$2 } from '@antv/g-plugin-svg-picker';
8
- import _createClass from '@babel/runtime/helpers/esm/createClass';
9
- import { inject, singleton, Module } from 'mana-syringe';
10
- import { isString } from '@antv/util';
11
-
12
- /*! *****************************************************************************
13
- Copyright (c) Microsoft Corporation.
14
-
15
- Permission to use, copy, modify, and/or distribute this software for any
16
- purpose with or without fee is hereby granted.
17
-
18
- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
19
- REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
20
- AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
21
- INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
22
- LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
23
- OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
24
- PERFORMANCE OF THIS SOFTWARE.
25
- ***************************************************************************** */
26
-
27
- function __decorate(decorators, target, key, desc) {
28
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
29
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
30
- else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
31
- return c > 3 && r && Object.defineProperty(target, key, r), r;
32
- }
33
-
34
- function __metadata(metadataKey, metadataValue) {
35
- if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(metadataKey, metadataValue);
36
- }
37
-
38
- var SVGContextService = /*#__PURE__*/function () {
39
- function SVGContextService() {
40
- _classCallCheck(this, SVGContextService);
41
-
42
- this.$container = void 0;
43
- this.$namespace = void 0;
44
- this.dpr = void 0;
45
- this.canvasConfig = void 0;
46
- }
47
-
48
- _createClass(SVGContextService, [{
49
- key: "init",
50
- value: function init() {
51
- var container = this.canvasConfig.container; // create container
52
-
53
- this.$container = isString(container) ? document.getElementById(container) : container;
54
-
55
- if (this.$container) {
56
- if (!this.$container.style.position) {
57
- this.$container.style.position = 'relative';
58
- }
59
-
60
- var $namespace = createSVGElement('svg');
61
- $namespace.setAttribute('width', "".concat(this.canvasConfig.width));
62
- $namespace.setAttribute('height', "".concat(this.canvasConfig.height));
63
- this.$container.appendChild($namespace);
64
- this.$namespace = $namespace;
65
- }
66
-
67
- var dpr = window.devicePixelRatio || 1;
68
- dpr = dpr >= 1 ? Math.ceil(dpr) : 1;
69
- this.dpr = dpr;
70
- } // @ts-ignore
71
-
72
- }, {
73
- key: "getDomElement",
74
- value: function getDomElement() {
75
- return this.$namespace;
76
- }
77
- }, {
78
- key: "getContext",
79
- value: function getContext() {
80
- return this.$namespace;
81
- }
82
- }, {
83
- key: "getDPR",
84
- value: function getDPR() {
85
- return this.dpr;
86
- }
87
- }, {
88
- key: "getBoundingClientRect",
89
- value: function getBoundingClientRect() {
90
- var _this$$namespace;
91
-
92
- return (_this$$namespace = this.$namespace) === null || _this$$namespace === void 0 ? void 0 : _this$$namespace.getBoundingClientRect();
93
- }
94
- }, {
95
- key: "destroy",
96
- value: function destroy() {
97
- // destroy context
98
- if (this.$container && this.$namespace && this.$namespace.parentNode) {
99
- this.$container.removeChild(this.$namespace);
100
- }
101
- }
102
- }, {
103
- key: "resize",
104
- value: function resize(width, height) {
105
- if (this.$namespace) {
106
- this.$namespace.setAttribute('width', "".concat(width));
107
- this.$namespace.setAttribute('height', "".concat(height));
108
- }
109
- }
110
- }, {
111
- key: "applyCursorStyle",
112
- value: function applyCursorStyle(cursor) {
113
- if (this.$container) {
114
- this.$container.style.cursor = cursor;
115
- }
116
- }
117
- }]);
118
-
119
- return SVGContextService;
120
- }();
121
-
122
- __decorate([inject(CanvasConfig), __metadata("design:type", Object)], SVGContextService.prototype, "canvasConfig", void 0);
123
-
124
- SVGContextService = __decorate([singleton({
125
- token: ContextService
126
- })], SVGContextService);
127
-
128
- var containerModule = Module(function (register) {
129
- /**
130
- * implements ContextService
131
- */
132
- register(SVGContextService);
133
- });
134
- var ContextRegisterPlugin = /*#__PURE__*/function () {
135
- function ContextRegisterPlugin() {
136
- _classCallCheck(this, ContextRegisterPlugin);
137
- }
138
-
139
- _createClass(ContextRegisterPlugin, [{
140
- key: "init",
141
- value: function init(container) {
142
- container.load(containerModule);
143
- }
144
- }, {
145
- key: "destroy",
146
- value: function destroy(container) {// @ts-ignore
147
- // container.container.unload(containerModule);
148
- // container.unload(containerModule);
149
- }
150
- }]);
151
-
152
- return ContextRegisterPlugin;
153
- }();
154
-
155
- var Renderer = /*#__PURE__*/function (_AbstractRenderer) {
156
- _inherits(Renderer, _AbstractRenderer);
157
-
158
- var _super = _createSuper(Renderer);
159
-
160
- function Renderer(config) {
161
- var _this;
162
-
163
- _classCallCheck(this, Renderer);
164
-
165
- _this = _super.call(this, config);
166
-
167
- _this.registerPlugin(new ContextRegisterPlugin());
168
-
169
- _this.registerPlugin(new Plugin());
170
-
171
- _this.registerPlugin(new Plugin$1());
172
-
173
- _this.registerPlugin(new Plugin$2());
174
-
175
- return _this;
176
- }
177
-
178
- return Renderer;
179
- }(AbstractRenderer);
180
-
181
- export { Renderer };