@antv/g-svg 1.1.3 → 1.1.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.esm.js CHANGED
@@ -11,11 +11,54 @@ export { SVGPicker };
11
11
  import { inject, singleton, Module } from 'mana-syringe';
12
12
  import { __decorate, __metadata } from 'tslib';
13
13
 
14
- function _inheritsLoose(subClass, superClass) {
15
- subClass.prototype = Object.create(superClass.prototype);
16
- subClass.prototype.constructor = subClass;
14
+ function _classCallCheck(instance, Constructor) {
15
+ if (!(instance instanceof Constructor)) {
16
+ throw new TypeError("Cannot call a class as a function");
17
+ }
18
+ }
19
+
20
+ function _defineProperties(target, props) {
21
+ for (var i = 0; i < props.length; i++) {
22
+ var descriptor = props[i];
23
+ descriptor.enumerable = descriptor.enumerable || false;
24
+ descriptor.configurable = true;
25
+ if ("value" in descriptor) descriptor.writable = true;
26
+ Object.defineProperty(target, descriptor.key, descriptor);
27
+ }
28
+ }
17
29
 
18
- _setPrototypeOf(subClass, superClass);
30
+ function _createClass(Constructor, protoProps, staticProps) {
31
+ if (protoProps) _defineProperties(Constructor.prototype, protoProps);
32
+ if (staticProps) _defineProperties(Constructor, staticProps);
33
+ Object.defineProperty(Constructor, "prototype", {
34
+ writable: false
35
+ });
36
+ return Constructor;
37
+ }
38
+
39
+ function _inherits(subClass, superClass) {
40
+ if (typeof superClass !== "function" && superClass !== null) {
41
+ throw new TypeError("Super expression must either be null or a function");
42
+ }
43
+
44
+ subClass.prototype = Object.create(superClass && superClass.prototype, {
45
+ constructor: {
46
+ value: subClass,
47
+ writable: true,
48
+ configurable: true
49
+ }
50
+ });
51
+ Object.defineProperty(subClass, "prototype", {
52
+ writable: false
53
+ });
54
+ if (superClass) _setPrototypeOf(subClass, superClass);
55
+ }
56
+
57
+ function _getPrototypeOf(o) {
58
+ _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) {
59
+ return o.__proto__ || Object.getPrototypeOf(o);
60
+ };
61
+ return _getPrototypeOf(o);
19
62
  }
20
63
 
21
64
  function _setPrototypeOf(o, p) {
@@ -27,76 +70,136 @@ function _setPrototypeOf(o, p) {
27
70
  return _setPrototypeOf(o, p);
28
71
  }
29
72
 
30
- var SVGContextService = /*#__PURE__*/function () {
31
- function SVGContextService() {
32
- this.$container = void 0;
33
- this.$namespace = void 0;
34
- this.dpr = void 0;
35
- this.canvasConfig = void 0;
73
+ function _isNativeReflectConstruct() {
74
+ if (typeof Reflect === "undefined" || !Reflect.construct) return false;
75
+ if (Reflect.construct.sham) return false;
76
+ if (typeof Proxy === "function") return true;
77
+
78
+ try {
79
+ Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {}));
80
+ return true;
81
+ } catch (e) {
82
+ return false;
36
83
  }
84
+ }
37
85
 
38
- var _proto = SVGContextService.prototype;
86
+ function _assertThisInitialized(self) {
87
+ if (self === void 0) {
88
+ throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
89
+ }
39
90
 
40
- _proto.init = function init() {
41
- var container = this.canvasConfig.container; // create container
91
+ return self;
92
+ }
42
93
 
43
- this.$container = isString(container) ? document.getElementById(container) : container;
94
+ function _possibleConstructorReturn(self, call) {
95
+ if (call && (typeof call === "object" || typeof call === "function")) {
96
+ return call;
97
+ } else if (call !== void 0) {
98
+ throw new TypeError("Derived constructors may only return object or undefined");
99
+ }
44
100
 
45
- if (this.$container) {
46
- if (!this.$container.style.position) {
47
- this.$container.style.position = 'relative';
48
- }
101
+ return _assertThisInitialized(self);
102
+ }
49
103
 
50
- var $namespace = createSVGElement('svg');
51
- $namespace.setAttribute('width', "" + this.canvasConfig.width);
52
- $namespace.setAttribute('height', "" + this.canvasConfig.height);
53
- this.$container.appendChild($namespace);
54
- this.$namespace = $namespace;
55
- }
104
+ function _createSuper(Derived) {
105
+ var hasNativeReflectConstruct = _isNativeReflectConstruct();
56
106
 
57
- var dpr = window.devicePixelRatio || 1;
58
- dpr = dpr >= 1 ? Math.ceil(dpr) : 1;
59
- this.dpr = dpr;
60
- } // @ts-ignore
61
- ;
107
+ return function _createSuperInternal() {
108
+ var Super = _getPrototypeOf(Derived),
109
+ result;
62
110
 
63
- _proto.getDomElement = function getDomElement() {
64
- return this.$namespace;
65
- };
111
+ if (hasNativeReflectConstruct) {
112
+ var NewTarget = _getPrototypeOf(this).constructor;
66
113
 
67
- _proto.getContext = function getContext() {
68
- return this.$namespace;
69
- };
114
+ result = Reflect.construct(Super, arguments, NewTarget);
115
+ } else {
116
+ result = Super.apply(this, arguments);
117
+ }
70
118
 
71
- _proto.getDPR = function getDPR() {
72
- return this.dpr;
119
+ return _possibleConstructorReturn(this, result);
73
120
  };
121
+ }
74
122
 
75
- _proto.getBoundingClientRect = function getBoundingClientRect() {
76
- var _this$$namespace;
123
+ var SVGContextService = /*#__PURE__*/function () {
124
+ function SVGContextService() {
125
+ _classCallCheck(this, SVGContextService);
77
126
 
78
- return (_this$$namespace = this.$namespace) === null || _this$$namespace === void 0 ? void 0 : _this$$namespace.getBoundingClientRect();
79
- };
127
+ this.$container = void 0;
128
+ this.$namespace = void 0;
129
+ this.dpr = void 0;
130
+ this.canvasConfig = void 0;
131
+ }
80
132
 
81
- _proto.destroy = function destroy() {
82
- // destroy context
83
- if (this.$container && this.$namespace && this.$namespace.parentNode) {
84
- this.$container.removeChild(this.$namespace);
85
- }
86
- };
133
+ _createClass(SVGContextService, [{
134
+ key: "init",
135
+ value: function init() {
136
+ var container = this.canvasConfig.container; // create container
87
137
 
88
- _proto.resize = function resize(width, height) {
89
- if (this.$namespace) {
90
- this.$namespace.setAttribute('width', "" + width);
91
- this.$namespace.setAttribute('height', "" + height);
138
+ this.$container = isString(container) ? document.getElementById(container) : container;
139
+
140
+ if (this.$container) {
141
+ if (!this.$container.style.position) {
142
+ this.$container.style.position = 'relative';
143
+ }
144
+
145
+ var $namespace = createSVGElement('svg');
146
+ $namespace.setAttribute('width', "".concat(this.canvasConfig.width));
147
+ $namespace.setAttribute('height', "".concat(this.canvasConfig.height));
148
+ this.$container.appendChild($namespace);
149
+ this.$namespace = $namespace;
150
+ }
151
+
152
+ var dpr = window.devicePixelRatio || 1;
153
+ dpr = dpr >= 1 ? Math.ceil(dpr) : 1;
154
+ this.dpr = dpr;
155
+ } // @ts-ignore
156
+
157
+ }, {
158
+ key: "getDomElement",
159
+ value: function getDomElement() {
160
+ return this.$namespace;
92
161
  }
93
- };
162
+ }, {
163
+ key: "getContext",
164
+ value: function getContext() {
165
+ return this.$namespace;
166
+ }
167
+ }, {
168
+ key: "getDPR",
169
+ value: function getDPR() {
170
+ return this.dpr;
171
+ }
172
+ }, {
173
+ key: "getBoundingClientRect",
174
+ value: function getBoundingClientRect() {
175
+ var _this$$namespace;
94
176
 
95
- _proto.applyCursorStyle = function applyCursorStyle(cursor) {
96
- if (this.$container) {
97
- this.$container.style.cursor = cursor;
177
+ return (_this$$namespace = this.$namespace) === null || _this$$namespace === void 0 ? void 0 : _this$$namespace.getBoundingClientRect();
98
178
  }
99
- };
179
+ }, {
180
+ key: "destroy",
181
+ value: function destroy() {
182
+ // destroy context
183
+ if (this.$container && this.$namespace && this.$namespace.parentNode) {
184
+ this.$container.removeChild(this.$namespace);
185
+ }
186
+ }
187
+ }, {
188
+ key: "resize",
189
+ value: function resize(width, height) {
190
+ if (this.$namespace) {
191
+ this.$namespace.setAttribute('width', "".concat(width));
192
+ this.$namespace.setAttribute('height', "".concat(height));
193
+ }
194
+ }
195
+ }, {
196
+ key: "applyCursorStyle",
197
+ value: function applyCursorStyle(cursor) {
198
+ if (this.$container) {
199
+ this.$container.style.cursor = cursor;
200
+ }
201
+ }
202
+ }]);
100
203
 
101
204
  return SVGContextService;
102
205
  }();
@@ -115,29 +218,37 @@ var containerModule = Module(function (register) {
115
218
  });
116
219
  var ContextRegisterPlugin = /*#__PURE__*/function () {
117
220
  function ContextRegisterPlugin() {
221
+ _classCallCheck(this, ContextRegisterPlugin);
222
+
118
223
  this.name = 'svg-context-register';
119
224
  }
120
225
 
121
- var _proto = ContextRegisterPlugin.prototype;
122
-
123
- _proto.init = function init(container) {
124
- container.load(containerModule, true);
125
- };
126
-
127
- _proto.destroy = function destroy(container) {
128
- container.unload(containerModule);
129
- };
226
+ _createClass(ContextRegisterPlugin, [{
227
+ key: "init",
228
+ value: function init(container) {
229
+ container.load(containerModule, true);
230
+ }
231
+ }, {
232
+ key: "destroy",
233
+ value: function destroy(container) {
234
+ container.unload(containerModule);
235
+ }
236
+ }]);
130
237
 
131
238
  return ContextRegisterPlugin;
132
239
  }();
133
240
 
134
241
  var Renderer = /*#__PURE__*/function (_AbstractRenderer) {
135
- _inheritsLoose(Renderer, _AbstractRenderer);
242
+ _inherits(Renderer, _AbstractRenderer);
243
+
244
+ var _super = _createSuper(Renderer);
136
245
 
137
246
  function Renderer(config) {
138
247
  var _this;
139
248
 
140
- _this = _AbstractRenderer.call(this, config) || this;
249
+ _classCallCheck(this, Renderer);
250
+
251
+ _this = _super.call(this, config);
141
252
 
142
253
  _this.registerPlugin(new ContextRegisterPlugin());
143
254
 
@@ -150,7 +261,7 @@ var Renderer = /*#__PURE__*/function (_AbstractRenderer) {
150
261
  return _this;
151
262
  }
152
263
 
153
- return Renderer;
264
+ return _createClass(Renderer);
154
265
  }(AbstractRenderer);
155
266
 
156
267
  export { Renderer };
package/dist/index.js CHANGED
@@ -33,11 +33,54 @@ var DomInteraction__namespace = /*#__PURE__*/_interopNamespace(DomInteraction);
33
33
  var SVGRenderer__namespace = /*#__PURE__*/_interopNamespace(SVGRenderer);
34
34
  var SVGPicker__namespace = /*#__PURE__*/_interopNamespace(SVGPicker);
35
35
 
36
- function _inheritsLoose(subClass, superClass) {
37
- subClass.prototype = Object.create(superClass.prototype);
38
- subClass.prototype.constructor = subClass;
36
+ function _classCallCheck(instance, Constructor) {
37
+ if (!(instance instanceof Constructor)) {
38
+ throw new TypeError("Cannot call a class as a function");
39
+ }
40
+ }
41
+
42
+ function _defineProperties(target, props) {
43
+ for (var i = 0; i < props.length; i++) {
44
+ var descriptor = props[i];
45
+ descriptor.enumerable = descriptor.enumerable || false;
46
+ descriptor.configurable = true;
47
+ if ("value" in descriptor) descriptor.writable = true;
48
+ Object.defineProperty(target, descriptor.key, descriptor);
49
+ }
50
+ }
39
51
 
40
- _setPrototypeOf(subClass, superClass);
52
+ function _createClass(Constructor, protoProps, staticProps) {
53
+ if (protoProps) _defineProperties(Constructor.prototype, protoProps);
54
+ if (staticProps) _defineProperties(Constructor, staticProps);
55
+ Object.defineProperty(Constructor, "prototype", {
56
+ writable: false
57
+ });
58
+ return Constructor;
59
+ }
60
+
61
+ function _inherits(subClass, superClass) {
62
+ if (typeof superClass !== "function" && superClass !== null) {
63
+ throw new TypeError("Super expression must either be null or a function");
64
+ }
65
+
66
+ subClass.prototype = Object.create(superClass && superClass.prototype, {
67
+ constructor: {
68
+ value: subClass,
69
+ writable: true,
70
+ configurable: true
71
+ }
72
+ });
73
+ Object.defineProperty(subClass, "prototype", {
74
+ writable: false
75
+ });
76
+ if (superClass) _setPrototypeOf(subClass, superClass);
77
+ }
78
+
79
+ function _getPrototypeOf(o) {
80
+ _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) {
81
+ return o.__proto__ || Object.getPrototypeOf(o);
82
+ };
83
+ return _getPrototypeOf(o);
41
84
  }
42
85
 
43
86
  function _setPrototypeOf(o, p) {
@@ -49,76 +92,136 @@ function _setPrototypeOf(o, p) {
49
92
  return _setPrototypeOf(o, p);
50
93
  }
51
94
 
52
- var SVGContextService = /*#__PURE__*/function () {
53
- function SVGContextService() {
54
- this.$container = void 0;
55
- this.$namespace = void 0;
56
- this.dpr = void 0;
57
- this.canvasConfig = void 0;
95
+ function _isNativeReflectConstruct() {
96
+ if (typeof Reflect === "undefined" || !Reflect.construct) return false;
97
+ if (Reflect.construct.sham) return false;
98
+ if (typeof Proxy === "function") return true;
99
+
100
+ try {
101
+ Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {}));
102
+ return true;
103
+ } catch (e) {
104
+ return false;
58
105
  }
106
+ }
59
107
 
60
- var _proto = SVGContextService.prototype;
108
+ function _assertThisInitialized(self) {
109
+ if (self === void 0) {
110
+ throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
111
+ }
61
112
 
62
- _proto.init = function init() {
63
- var container = this.canvasConfig.container; // create container
113
+ return self;
114
+ }
64
115
 
65
- this.$container = g.isString(container) ? document.getElementById(container) : container;
116
+ function _possibleConstructorReturn(self, call) {
117
+ if (call && (typeof call === "object" || typeof call === "function")) {
118
+ return call;
119
+ } else if (call !== void 0) {
120
+ throw new TypeError("Derived constructors may only return object or undefined");
121
+ }
66
122
 
67
- if (this.$container) {
68
- if (!this.$container.style.position) {
69
- this.$container.style.position = 'relative';
70
- }
123
+ return _assertThisInitialized(self);
124
+ }
71
125
 
72
- var $namespace = SVGRenderer.createSVGElement('svg');
73
- $namespace.setAttribute('width', "" + this.canvasConfig.width);
74
- $namespace.setAttribute('height', "" + this.canvasConfig.height);
75
- this.$container.appendChild($namespace);
76
- this.$namespace = $namespace;
77
- }
126
+ function _createSuper(Derived) {
127
+ var hasNativeReflectConstruct = _isNativeReflectConstruct();
78
128
 
79
- var dpr = window.devicePixelRatio || 1;
80
- dpr = dpr >= 1 ? Math.ceil(dpr) : 1;
81
- this.dpr = dpr;
82
- } // @ts-ignore
83
- ;
129
+ return function _createSuperInternal() {
130
+ var Super = _getPrototypeOf(Derived),
131
+ result;
84
132
 
85
- _proto.getDomElement = function getDomElement() {
86
- return this.$namespace;
87
- };
133
+ if (hasNativeReflectConstruct) {
134
+ var NewTarget = _getPrototypeOf(this).constructor;
88
135
 
89
- _proto.getContext = function getContext() {
90
- return this.$namespace;
91
- };
136
+ result = Reflect.construct(Super, arguments, NewTarget);
137
+ } else {
138
+ result = Super.apply(this, arguments);
139
+ }
92
140
 
93
- _proto.getDPR = function getDPR() {
94
- return this.dpr;
141
+ return _possibleConstructorReturn(this, result);
95
142
  };
143
+ }
96
144
 
97
- _proto.getBoundingClientRect = function getBoundingClientRect() {
98
- var _this$$namespace;
145
+ var SVGContextService = /*#__PURE__*/function () {
146
+ function SVGContextService() {
147
+ _classCallCheck(this, SVGContextService);
99
148
 
100
- return (_this$$namespace = this.$namespace) === null || _this$$namespace === void 0 ? void 0 : _this$$namespace.getBoundingClientRect();
101
- };
149
+ this.$container = void 0;
150
+ this.$namespace = void 0;
151
+ this.dpr = void 0;
152
+ this.canvasConfig = void 0;
153
+ }
102
154
 
103
- _proto.destroy = function destroy() {
104
- // destroy context
105
- if (this.$container && this.$namespace && this.$namespace.parentNode) {
106
- this.$container.removeChild(this.$namespace);
107
- }
108
- };
155
+ _createClass(SVGContextService, [{
156
+ key: "init",
157
+ value: function init() {
158
+ var container = this.canvasConfig.container; // create container
109
159
 
110
- _proto.resize = function resize(width, height) {
111
- if (this.$namespace) {
112
- this.$namespace.setAttribute('width', "" + width);
113
- this.$namespace.setAttribute('height', "" + height);
160
+ this.$container = g.isString(container) ? document.getElementById(container) : container;
161
+
162
+ if (this.$container) {
163
+ if (!this.$container.style.position) {
164
+ this.$container.style.position = 'relative';
165
+ }
166
+
167
+ var $namespace = SVGRenderer.createSVGElement('svg');
168
+ $namespace.setAttribute('width', "".concat(this.canvasConfig.width));
169
+ $namespace.setAttribute('height', "".concat(this.canvasConfig.height));
170
+ this.$container.appendChild($namespace);
171
+ this.$namespace = $namespace;
172
+ }
173
+
174
+ var dpr = window.devicePixelRatio || 1;
175
+ dpr = dpr >= 1 ? Math.ceil(dpr) : 1;
176
+ this.dpr = dpr;
177
+ } // @ts-ignore
178
+
179
+ }, {
180
+ key: "getDomElement",
181
+ value: function getDomElement() {
182
+ return this.$namespace;
114
183
  }
115
- };
184
+ }, {
185
+ key: "getContext",
186
+ value: function getContext() {
187
+ return this.$namespace;
188
+ }
189
+ }, {
190
+ key: "getDPR",
191
+ value: function getDPR() {
192
+ return this.dpr;
193
+ }
194
+ }, {
195
+ key: "getBoundingClientRect",
196
+ value: function getBoundingClientRect() {
197
+ var _this$$namespace;
116
198
 
117
- _proto.applyCursorStyle = function applyCursorStyle(cursor) {
118
- if (this.$container) {
119
- this.$container.style.cursor = cursor;
199
+ return (_this$$namespace = this.$namespace) === null || _this$$namespace === void 0 ? void 0 : _this$$namespace.getBoundingClientRect();
120
200
  }
121
- };
201
+ }, {
202
+ key: "destroy",
203
+ value: function destroy() {
204
+ // destroy context
205
+ if (this.$container && this.$namespace && this.$namespace.parentNode) {
206
+ this.$container.removeChild(this.$namespace);
207
+ }
208
+ }
209
+ }, {
210
+ key: "resize",
211
+ value: function resize(width, height) {
212
+ if (this.$namespace) {
213
+ this.$namespace.setAttribute('width', "".concat(width));
214
+ this.$namespace.setAttribute('height', "".concat(height));
215
+ }
216
+ }
217
+ }, {
218
+ key: "applyCursorStyle",
219
+ value: function applyCursorStyle(cursor) {
220
+ if (this.$container) {
221
+ this.$container.style.cursor = cursor;
222
+ }
223
+ }
224
+ }]);
122
225
 
123
226
  return SVGContextService;
124
227
  }();
@@ -137,29 +240,37 @@ var containerModule = manaSyringe.Module(function (register) {
137
240
  });
138
241
  var ContextRegisterPlugin = /*#__PURE__*/function () {
139
242
  function ContextRegisterPlugin() {
243
+ _classCallCheck(this, ContextRegisterPlugin);
244
+
140
245
  this.name = 'svg-context-register';
141
246
  }
142
247
 
143
- var _proto = ContextRegisterPlugin.prototype;
144
-
145
- _proto.init = function init(container) {
146
- container.load(containerModule, true);
147
- };
148
-
149
- _proto.destroy = function destroy(container) {
150
- container.unload(containerModule);
151
- };
248
+ _createClass(ContextRegisterPlugin, [{
249
+ key: "init",
250
+ value: function init(container) {
251
+ container.load(containerModule, true);
252
+ }
253
+ }, {
254
+ key: "destroy",
255
+ value: function destroy(container) {
256
+ container.unload(containerModule);
257
+ }
258
+ }]);
152
259
 
153
260
  return ContextRegisterPlugin;
154
261
  }();
155
262
 
156
263
  var Renderer = /*#__PURE__*/function (_AbstractRenderer) {
157
- _inheritsLoose(Renderer, _AbstractRenderer);
264
+ _inherits(Renderer, _AbstractRenderer);
265
+
266
+ var _super = _createSuper(Renderer);
158
267
 
159
268
  function Renderer(config) {
160
269
  var _this;
161
270
 
162
- _this = _AbstractRenderer.call(this, config) || this;
271
+ _classCallCheck(this, Renderer);
272
+
273
+ _this = _super.call(this, config);
163
274
 
164
275
  _this.registerPlugin(new ContextRegisterPlugin());
165
276
 
@@ -172,7 +283,7 @@ var Renderer = /*#__PURE__*/function (_AbstractRenderer) {
172
283
  return _this;
173
284
  }
174
285
 
175
- return Renderer;
286
+ return _createClass(Renderer);
176
287
  }(g.AbstractRenderer);
177
288
 
178
289
  exports.DomInteraction = DomInteraction__namespace;