@antv/g-svg 1.0.0-alpha.22 → 1.0.0-alpha.26

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,6 @@
1
+ import { Syringe } from 'mana-syringe';
2
+ import { RendererPlugin } from '@antv/g';
3
+ export declare class ContextRegisterPlugin implements RendererPlugin {
4
+ init(container: Syringe.Container): void;
5
+ destroy(container: Syringe.Container): void;
6
+ }
@@ -1,15 +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
- }
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
+ }
@@ -1,4 +1,4 @@
1
- import { AbstractRenderer, RendererConfig } from '@antv/g';
2
- export declare class Renderer extends AbstractRenderer {
3
- constructor(config?: Partial<RendererConfig>);
4
- }
1
+ import { AbstractRenderer, RendererConfig } from '@antv/g';
2
+ export declare class Renderer extends AbstractRenderer {
3
+ constructor(config?: Partial<RendererConfig>);
4
+ }
@@ -0,0 +1,280 @@
1
+ import { CanvasConfig, ContextService, AbstractRenderer } from '@antv/g';
2
+ import { Plugin as Plugin$1 } from '@antv/g-plugin-dom-interaction';
3
+ import { createSVGElement, Plugin } from '@antv/g-plugin-svg-renderer';
4
+ import { Plugin as Plugin$2 } from '@antv/g-plugin-svg-picker';
5
+ import { inject, singleton, Module } from 'mana-syringe';
6
+ import { isString } from '@antv/util';
7
+
8
+ function _classCallCheck(instance, Constructor) {
9
+ if (!(instance instanceof Constructor)) {
10
+ throw new TypeError("Cannot call a class as a function");
11
+ }
12
+ }
13
+
14
+ function _defineProperties(target, props) {
15
+ for (var i = 0; i < props.length; i++) {
16
+ var descriptor = props[i];
17
+ descriptor.enumerable = descriptor.enumerable || false;
18
+ descriptor.configurable = true;
19
+ if ("value" in descriptor) descriptor.writable = true;
20
+ Object.defineProperty(target, descriptor.key, descriptor);
21
+ }
22
+ }
23
+
24
+ function _createClass(Constructor, protoProps, staticProps) {
25
+ if (protoProps) _defineProperties(Constructor.prototype, protoProps);
26
+ if (staticProps) _defineProperties(Constructor, staticProps);
27
+ return Constructor;
28
+ }
29
+
30
+ function _inherits(subClass, superClass) {
31
+ if (typeof superClass !== "function" && superClass !== null) {
32
+ throw new TypeError("Super expression must either be null or a function");
33
+ }
34
+
35
+ subClass.prototype = Object.create(superClass && superClass.prototype, {
36
+ constructor: {
37
+ value: subClass,
38
+ writable: true,
39
+ configurable: true
40
+ }
41
+ });
42
+ if (superClass) _setPrototypeOf(subClass, superClass);
43
+ }
44
+
45
+ function _getPrototypeOf(o) {
46
+ _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) {
47
+ return o.__proto__ || Object.getPrototypeOf(o);
48
+ };
49
+ return _getPrototypeOf(o);
50
+ }
51
+
52
+ function _setPrototypeOf(o, p) {
53
+ _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) {
54
+ o.__proto__ = p;
55
+ return o;
56
+ };
57
+
58
+ return _setPrototypeOf(o, p);
59
+ }
60
+
61
+ function _isNativeReflectConstruct() {
62
+ if (typeof Reflect === "undefined" || !Reflect.construct) return false;
63
+ if (Reflect.construct.sham) return false;
64
+ if (typeof Proxy === "function") return true;
65
+
66
+ try {
67
+ Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {}));
68
+ return true;
69
+ } catch (e) {
70
+ return false;
71
+ }
72
+ }
73
+
74
+ function _assertThisInitialized(self) {
75
+ if (self === void 0) {
76
+ throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
77
+ }
78
+
79
+ return self;
80
+ }
81
+
82
+ function _possibleConstructorReturn(self, call) {
83
+ if (call && (typeof call === "object" || typeof call === "function")) {
84
+ return call;
85
+ } else if (call !== void 0) {
86
+ throw new TypeError("Derived constructors may only return object or undefined");
87
+ }
88
+
89
+ return _assertThisInitialized(self);
90
+ }
91
+
92
+ function _createSuper(Derived) {
93
+ var hasNativeReflectConstruct = _isNativeReflectConstruct();
94
+
95
+ return function _createSuperInternal() {
96
+ var Super = _getPrototypeOf(Derived),
97
+ result;
98
+
99
+ if (hasNativeReflectConstruct) {
100
+ var NewTarget = _getPrototypeOf(this).constructor;
101
+
102
+ result = Reflect.construct(Super, arguments, NewTarget);
103
+ } else {
104
+ result = Super.apply(this, arguments);
105
+ }
106
+
107
+ return _possibleConstructorReturn(this, result);
108
+ };
109
+ }
110
+
111
+ /*! *****************************************************************************
112
+ Copyright (c) Microsoft Corporation.
113
+
114
+ Permission to use, copy, modify, and/or distribute this software for any
115
+ purpose with or without fee is hereby granted.
116
+
117
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
118
+ REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
119
+ AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
120
+ INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
121
+ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
122
+ OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
123
+ PERFORMANCE OF THIS SOFTWARE.
124
+ ***************************************************************************** */
125
+
126
+ function __decorate(decorators, target, key, desc) {
127
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
128
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
129
+ 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;
130
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
131
+ }
132
+
133
+ function __metadata(metadataKey, metadataValue) {
134
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(metadataKey, metadataValue);
135
+ }
136
+
137
+ var SVGContextService = /*#__PURE__*/function () {
138
+ function SVGContextService() {
139
+ _classCallCheck(this, SVGContextService);
140
+
141
+ this.$container = void 0;
142
+ this.$namespace = void 0;
143
+ this.dpr = void 0;
144
+ this.canvasConfig = void 0;
145
+ }
146
+
147
+ _createClass(SVGContextService, [{
148
+ key: "init",
149
+ value: function init() {
150
+ var container = this.canvasConfig.container; // create container
151
+
152
+ this.$container = isString(container) ? document.getElementById(container) : container;
153
+
154
+ if (this.$container) {
155
+ if (!this.$container.style.position) {
156
+ this.$container.style.position = 'relative';
157
+ }
158
+
159
+ var $namespace = createSVGElement('svg');
160
+ $namespace.setAttribute('width', "".concat(this.canvasConfig.width));
161
+ $namespace.setAttribute('height', "".concat(this.canvasConfig.height));
162
+ this.$container.appendChild($namespace);
163
+ this.$namespace = $namespace;
164
+ }
165
+
166
+ var dpr = window.devicePixelRatio || 1;
167
+ dpr = dpr >= 1 ? Math.ceil(dpr) : 1;
168
+ this.dpr = dpr;
169
+ } // @ts-ignore
170
+
171
+ }, {
172
+ key: "getDomElement",
173
+ value: function getDomElement() {
174
+ return this.$namespace;
175
+ }
176
+ }, {
177
+ key: "getContext",
178
+ value: function getContext() {
179
+ return this.$namespace;
180
+ }
181
+ }, {
182
+ key: "getDPR",
183
+ value: function getDPR() {
184
+ return this.dpr;
185
+ }
186
+ }, {
187
+ key: "getBoundingClientRect",
188
+ value: function getBoundingClientRect() {
189
+ var _this$$namespace;
190
+
191
+ return (_this$$namespace = this.$namespace) === null || _this$$namespace === void 0 ? void 0 : _this$$namespace.getBoundingClientRect();
192
+ }
193
+ }, {
194
+ key: "destroy",
195
+ value: function destroy() {
196
+ // destroy context
197
+ if (this.$container && this.$namespace && this.$namespace.parentNode) {
198
+ this.$container.removeChild(this.$namespace);
199
+ }
200
+ }
201
+ }, {
202
+ key: "resize",
203
+ value: function resize(width, height) {
204
+ if (this.$namespace) {
205
+ this.$namespace.setAttribute('width', "".concat(width));
206
+ this.$namespace.setAttribute('height', "".concat(height));
207
+ }
208
+ }
209
+ }, {
210
+ key: "applyCursorStyle",
211
+ value: function applyCursorStyle(cursor) {
212
+ if (this.$container) {
213
+ this.$container.style.cursor = cursor;
214
+ }
215
+ }
216
+ }]);
217
+
218
+ return SVGContextService;
219
+ }();
220
+
221
+ __decorate([inject(CanvasConfig), __metadata("design:type", Object)], SVGContextService.prototype, "canvasConfig", void 0);
222
+
223
+ SVGContextService = __decorate([singleton({
224
+ token: ContextService
225
+ })], SVGContextService);
226
+
227
+ var containerModule = Module(function (register) {
228
+ /**
229
+ * implements ContextService
230
+ */
231
+ register(SVGContextService);
232
+ });
233
+ var ContextRegisterPlugin = /*#__PURE__*/function () {
234
+ function ContextRegisterPlugin() {
235
+ _classCallCheck(this, ContextRegisterPlugin);
236
+ }
237
+
238
+ _createClass(ContextRegisterPlugin, [{
239
+ key: "init",
240
+ value: function init(container) {
241
+ container.load(containerModule);
242
+ }
243
+ }, {
244
+ key: "destroy",
245
+ value: function destroy(container) {// @ts-ignore
246
+ // container.container.unload(containerModule);
247
+ // container.unload(containerModule);
248
+ }
249
+ }]);
250
+
251
+ return ContextRegisterPlugin;
252
+ }();
253
+
254
+ var Renderer = /*#__PURE__*/function (_AbstractRenderer) {
255
+ _inherits(Renderer, _AbstractRenderer);
256
+
257
+ var _super = _createSuper(Renderer);
258
+
259
+ function Renderer(config) {
260
+ var _this;
261
+
262
+ _classCallCheck(this, Renderer);
263
+
264
+ _this = _super.call(this, config);
265
+
266
+ _this.registerPlugin(new ContextRegisterPlugin());
267
+
268
+ _this.registerPlugin(new Plugin());
269
+
270
+ _this.registerPlugin(new Plugin$1());
271
+
272
+ _this.registerPlugin(new Plugin$2());
273
+
274
+ return _this;
275
+ }
276
+
277
+ return Renderer;
278
+ }(AbstractRenderer);
279
+
280
+ export { Renderer };
package/dist/index.js ADDED
@@ -0,0 +1,284 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var g = require('@antv/g');
6
+ var gPluginDomInteraction = require('@antv/g-plugin-dom-interaction');
7
+ var gPluginSvgRenderer = require('@antv/g-plugin-svg-renderer');
8
+ var gPluginSvgPicker = require('@antv/g-plugin-svg-picker');
9
+ var manaSyringe = require('mana-syringe');
10
+ var util = require('@antv/util');
11
+
12
+ function _classCallCheck(instance, Constructor) {
13
+ if (!(instance instanceof Constructor)) {
14
+ throw new TypeError("Cannot call a class as a function");
15
+ }
16
+ }
17
+
18
+ function _defineProperties(target, props) {
19
+ for (var i = 0; i < props.length; i++) {
20
+ var descriptor = props[i];
21
+ descriptor.enumerable = descriptor.enumerable || false;
22
+ descriptor.configurable = true;
23
+ if ("value" in descriptor) descriptor.writable = true;
24
+ Object.defineProperty(target, descriptor.key, descriptor);
25
+ }
26
+ }
27
+
28
+ function _createClass(Constructor, protoProps, staticProps) {
29
+ if (protoProps) _defineProperties(Constructor.prototype, protoProps);
30
+ if (staticProps) _defineProperties(Constructor, staticProps);
31
+ return Constructor;
32
+ }
33
+
34
+ function _inherits(subClass, superClass) {
35
+ if (typeof superClass !== "function" && superClass !== null) {
36
+ throw new TypeError("Super expression must either be null or a function");
37
+ }
38
+
39
+ subClass.prototype = Object.create(superClass && superClass.prototype, {
40
+ constructor: {
41
+ value: subClass,
42
+ writable: true,
43
+ configurable: true
44
+ }
45
+ });
46
+ if (superClass) _setPrototypeOf(subClass, superClass);
47
+ }
48
+
49
+ function _getPrototypeOf(o) {
50
+ _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) {
51
+ return o.__proto__ || Object.getPrototypeOf(o);
52
+ };
53
+ return _getPrototypeOf(o);
54
+ }
55
+
56
+ function _setPrototypeOf(o, p) {
57
+ _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) {
58
+ o.__proto__ = p;
59
+ return o;
60
+ };
61
+
62
+ return _setPrototypeOf(o, p);
63
+ }
64
+
65
+ function _isNativeReflectConstruct() {
66
+ if (typeof Reflect === "undefined" || !Reflect.construct) return false;
67
+ if (Reflect.construct.sham) return false;
68
+ if (typeof Proxy === "function") return true;
69
+
70
+ try {
71
+ Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {}));
72
+ return true;
73
+ } catch (e) {
74
+ return false;
75
+ }
76
+ }
77
+
78
+ function _assertThisInitialized(self) {
79
+ if (self === void 0) {
80
+ throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
81
+ }
82
+
83
+ return self;
84
+ }
85
+
86
+ function _possibleConstructorReturn(self, call) {
87
+ if (call && (typeof call === "object" || typeof call === "function")) {
88
+ return call;
89
+ } else if (call !== void 0) {
90
+ throw new TypeError("Derived constructors may only return object or undefined");
91
+ }
92
+
93
+ return _assertThisInitialized(self);
94
+ }
95
+
96
+ function _createSuper(Derived) {
97
+ var hasNativeReflectConstruct = _isNativeReflectConstruct();
98
+
99
+ return function _createSuperInternal() {
100
+ var Super = _getPrototypeOf(Derived),
101
+ result;
102
+
103
+ if (hasNativeReflectConstruct) {
104
+ var NewTarget = _getPrototypeOf(this).constructor;
105
+
106
+ result = Reflect.construct(Super, arguments, NewTarget);
107
+ } else {
108
+ result = Super.apply(this, arguments);
109
+ }
110
+
111
+ return _possibleConstructorReturn(this, result);
112
+ };
113
+ }
114
+
115
+ /*! *****************************************************************************
116
+ Copyright (c) Microsoft Corporation.
117
+
118
+ Permission to use, copy, modify, and/or distribute this software for any
119
+ purpose with or without fee is hereby granted.
120
+
121
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
122
+ REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
123
+ AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
124
+ INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
125
+ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
126
+ OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
127
+ PERFORMANCE OF THIS SOFTWARE.
128
+ ***************************************************************************** */
129
+
130
+ function __decorate(decorators, target, key, desc) {
131
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
132
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
133
+ 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;
134
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
135
+ }
136
+
137
+ function __metadata(metadataKey, metadataValue) {
138
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(metadataKey, metadataValue);
139
+ }
140
+
141
+ var SVGContextService = /*#__PURE__*/function () {
142
+ function SVGContextService() {
143
+ _classCallCheck(this, SVGContextService);
144
+
145
+ this.$container = void 0;
146
+ this.$namespace = void 0;
147
+ this.dpr = void 0;
148
+ this.canvasConfig = void 0;
149
+ }
150
+
151
+ _createClass(SVGContextService, [{
152
+ key: "init",
153
+ value: function init() {
154
+ var container = this.canvasConfig.container; // create container
155
+
156
+ this.$container = util.isString(container) ? document.getElementById(container) : container;
157
+
158
+ if (this.$container) {
159
+ if (!this.$container.style.position) {
160
+ this.$container.style.position = 'relative';
161
+ }
162
+
163
+ var $namespace = gPluginSvgRenderer.createSVGElement('svg');
164
+ $namespace.setAttribute('width', "".concat(this.canvasConfig.width));
165
+ $namespace.setAttribute('height', "".concat(this.canvasConfig.height));
166
+ this.$container.appendChild($namespace);
167
+ this.$namespace = $namespace;
168
+ }
169
+
170
+ var dpr = window.devicePixelRatio || 1;
171
+ dpr = dpr >= 1 ? Math.ceil(dpr) : 1;
172
+ this.dpr = dpr;
173
+ } // @ts-ignore
174
+
175
+ }, {
176
+ key: "getDomElement",
177
+ value: function getDomElement() {
178
+ return this.$namespace;
179
+ }
180
+ }, {
181
+ key: "getContext",
182
+ value: function getContext() {
183
+ return this.$namespace;
184
+ }
185
+ }, {
186
+ key: "getDPR",
187
+ value: function getDPR() {
188
+ return this.dpr;
189
+ }
190
+ }, {
191
+ key: "getBoundingClientRect",
192
+ value: function getBoundingClientRect() {
193
+ var _this$$namespace;
194
+
195
+ return (_this$$namespace = this.$namespace) === null || _this$$namespace === void 0 ? void 0 : _this$$namespace.getBoundingClientRect();
196
+ }
197
+ }, {
198
+ key: "destroy",
199
+ value: function destroy() {
200
+ // destroy context
201
+ if (this.$container && this.$namespace && this.$namespace.parentNode) {
202
+ this.$container.removeChild(this.$namespace);
203
+ }
204
+ }
205
+ }, {
206
+ key: "resize",
207
+ value: function resize(width, height) {
208
+ if (this.$namespace) {
209
+ this.$namespace.setAttribute('width', "".concat(width));
210
+ this.$namespace.setAttribute('height', "".concat(height));
211
+ }
212
+ }
213
+ }, {
214
+ key: "applyCursorStyle",
215
+ value: function applyCursorStyle(cursor) {
216
+ if (this.$container) {
217
+ this.$container.style.cursor = cursor;
218
+ }
219
+ }
220
+ }]);
221
+
222
+ return SVGContextService;
223
+ }();
224
+
225
+ __decorate([manaSyringe.inject(g.CanvasConfig), __metadata("design:type", Object)], SVGContextService.prototype, "canvasConfig", void 0);
226
+
227
+ SVGContextService = __decorate([manaSyringe.singleton({
228
+ token: g.ContextService
229
+ })], SVGContextService);
230
+
231
+ var containerModule = manaSyringe.Module(function (register) {
232
+ /**
233
+ * implements ContextService
234
+ */
235
+ register(SVGContextService);
236
+ });
237
+ var ContextRegisterPlugin = /*#__PURE__*/function () {
238
+ function ContextRegisterPlugin() {
239
+ _classCallCheck(this, ContextRegisterPlugin);
240
+ }
241
+
242
+ _createClass(ContextRegisterPlugin, [{
243
+ key: "init",
244
+ value: function init(container) {
245
+ container.load(containerModule);
246
+ }
247
+ }, {
248
+ key: "destroy",
249
+ value: function destroy(container) {// @ts-ignore
250
+ // container.container.unload(containerModule);
251
+ // container.unload(containerModule);
252
+ }
253
+ }]);
254
+
255
+ return ContextRegisterPlugin;
256
+ }();
257
+
258
+ var Renderer = /*#__PURE__*/function (_AbstractRenderer) {
259
+ _inherits(Renderer, _AbstractRenderer);
260
+
261
+ var _super = _createSuper(Renderer);
262
+
263
+ function Renderer(config) {
264
+ var _this;
265
+
266
+ _classCallCheck(this, Renderer);
267
+
268
+ _this = _super.call(this, config);
269
+
270
+ _this.registerPlugin(new ContextRegisterPlugin());
271
+
272
+ _this.registerPlugin(new gPluginSvgRenderer.Plugin());
273
+
274
+ _this.registerPlugin(new gPluginDomInteraction.Plugin());
275
+
276
+ _this.registerPlugin(new gPluginSvgPicker.Plugin());
277
+
278
+ return _this;
279
+ }
280
+
281
+ return Renderer;
282
+ }(g.AbstractRenderer);
283
+
284
+ exports.Renderer = Renderer;
@@ -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.22",
3
+ "version": "1.0.0-alpha.26",
4
4
  "description": "A renderer implemented by SVG",
5
- "main": "lib/index.js",
6
- "module": "es/index.js",
7
- "types": "lib/index.d.ts",
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,12 @@
39
37
  },
40
38
  "homepage": "https://github.com/antvis/g#readme",
41
39
  "dependencies": {
42
- "@antv/g-plugin-dom-interaction": "^1.0.0-alpha.21",
43
- "@antv/g-plugin-svg-picker": "^1.0.0-alpha.21",
44
- "@antv/g-plugin-svg-renderer": "^1.0.0-alpha.22",
45
- "@antv/util": "^2.0.13"
40
+ "@antv/g": "^1.0.0-alpha.26",
41
+ "@antv/g-plugin-dom-interaction": "^1.0.0-alpha.25",
42
+ "@antv/g-plugin-svg-picker": "^1.0.0-alpha.25",
43
+ "@antv/g-plugin-svg-renderer": "^1.0.0-alpha.26",
44
+ "@antv/util": "^2.0.13",
45
+ "mana-syringe": "^0.1.0"
46
46
  },
47
- "peerDependencies": {
48
- "@antv/g": "^1.0.0-alpha.17"
49
- },
50
- "gitHead": "71623c892dc55a274313f2f1b392c6ccd25154c1"
47
+ "gitHead": "04974923388e3c1e3c47d591c251380058372376"
51
48
  }
@@ -1,6 +0,0 @@
1
- import { Container } from 'inversify';
2
- import { RendererPlugin } from '@antv/g';
3
- export declare class ContextRegisterPlugin implements RendererPlugin {
4
- init(container: Container): void;
5
- destroy(container: Container): void;
6
- }
@@ -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
- }
@@ -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 };
@@ -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,6 +0,0 @@
1
- import { Container } from 'inversify';
2
- import { RendererPlugin } from '@antv/g';
3
- export declare class ContextRegisterPlugin implements RendererPlugin {
4
- init(container: Container): void;
5
- destroy(container: Container): void;
6
- }
@@ -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;
@@ -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
@@ -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/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;
@@ -1,6 +0,0 @@
1
- export declare function parseRadius(radius: number[]): {
2
- r1: number;
3
- r2: number;
4
- r3: number;
5
- r4: number;
6
- };
@@ -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
- }