@antv/g-svg 1.1.6 → 1.1.7

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,54 +11,11 @@ export { SVGPicker };
11
11
  import { inject, singleton, Module } from 'mana-syringe';
12
12
  import { __decorate, __metadata } from 'tslib';
13
13
 
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
- }
14
+ function _inheritsLoose(subClass, superClass) {
15
+ subClass.prototype = Object.create(superClass.prototype);
16
+ subClass.prototype.constructor = subClass;
29
17
 
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);
18
+ _setPrototypeOf(subClass, superClass);
62
19
  }
63
20
 
64
21
  function _setPrototypeOf(o, p) {
@@ -70,136 +27,78 @@ function _setPrototypeOf(o, p) {
70
27
  return _setPrototypeOf(o, p);
71
28
  }
72
29
 
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;
83
- }
84
- }
85
-
86
- function _assertThisInitialized(self) {
87
- if (self === void 0) {
88
- throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
89
- }
90
-
91
- return self;
92
- }
93
-
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
- }
100
-
101
- return _assertThisInitialized(self);
102
- }
103
-
104
- function _createSuper(Derived) {
105
- var hasNativeReflectConstruct = _isNativeReflectConstruct();
106
-
107
- return function _createSuperInternal() {
108
- var Super = _getPrototypeOf(Derived),
109
- result;
110
-
111
- if (hasNativeReflectConstruct) {
112
- var NewTarget = _getPrototypeOf(this).constructor;
113
-
114
- result = Reflect.construct(Super, arguments, NewTarget);
115
- } else {
116
- result = Super.apply(this, arguments);
117
- }
118
-
119
- return _possibleConstructorReturn(this, result);
120
- };
121
- }
122
-
123
30
  var SVGContextService = /*#__PURE__*/function () {
124
31
  function SVGContextService() {
125
- _classCallCheck(this, SVGContextService);
126
-
127
32
  this.$container = void 0;
128
33
  this.$namespace = void 0;
129
34
  this.dpr = void 0;
130
35
  this.canvasConfig = void 0;
131
36
  }
132
37
 
133
- _createClass(SVGContextService, [{
134
- key: "init",
135
- value: function init() {
136
- var container = this.canvasConfig.container; // create container
38
+ var _proto = SVGContextService.prototype;
137
39
 
138
- this.$container = isString(container) ? document.getElementById(container) : container;
40
+ _proto.init = function init() {
41
+ var _this$canvasConfig = this.canvasConfig,
42
+ container = _this$canvasConfig.container,
43
+ doc = _this$canvasConfig.document; // create container
139
44
 
140
- if (this.$container) {
141
- if (!this.$container.style.position) {
142
- this.$container.style.position = 'relative';
143
- }
45
+ this.$container = isString(container) ? (doc || document).getElementById(container) : container;
144
46
 
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;
47
+ if (this.$container) {
48
+ if (!this.$container.style.position) {
49
+ this.$container.style.position = 'relative';
150
50
  }
151
51
 
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;
161
- }
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;
52
+ var $namespace = createSVGElement('svg', doc);
53
+ $namespace.setAttribute('width', "" + this.canvasConfig.width);
54
+ $namespace.setAttribute('height', "" + this.canvasConfig.height);
55
+ this.$container.appendChild($namespace);
56
+ this.$namespace = $namespace;
171
57
  }
172
- }, {
173
- key: "getBoundingClientRect",
174
- value: function getBoundingClientRect() {
175
- var _this$$namespace;
176
58
 
177
- return (_this$$namespace = this.$namespace) === null || _this$$namespace === void 0 ? void 0 : _this$$namespace.getBoundingClientRect();
178
- }
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
- }
59
+ var dpr = window.devicePixelRatio || 1;
60
+ dpr = dpr >= 1 ? Math.ceil(dpr) : 1;
61
+ this.dpr = dpr;
62
+ } // @ts-ignore
63
+ ;
64
+
65
+ _proto.getDomElement = function getDomElement() {
66
+ return this.$namespace;
67
+ };
68
+
69
+ _proto.getContext = function getContext() {
70
+ return this.$namespace;
71
+ };
72
+
73
+ _proto.getDPR = function getDPR() {
74
+ return this.dpr;
75
+ };
76
+
77
+ _proto.getBoundingClientRect = function getBoundingClientRect() {
78
+ var _this$$namespace;
79
+
80
+ return (_this$$namespace = this.$namespace) === null || _this$$namespace === void 0 ? void 0 : _this$$namespace.getBoundingClientRect();
81
+ };
82
+
83
+ _proto.destroy = function destroy() {
84
+ // destroy context
85
+ if (this.$container && this.$namespace && this.$namespace.parentNode) {
86
+ this.$container.removeChild(this.$namespace);
186
87
  }
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
- }
88
+ };
89
+
90
+ _proto.resize = function resize(width, height) {
91
+ if (this.$namespace) {
92
+ this.$namespace.setAttribute('width', "" + width);
93
+ this.$namespace.setAttribute('height', "" + height);
194
94
  }
195
- }, {
196
- key: "applyCursorStyle",
197
- value: function applyCursorStyle(cursor) {
198
- if (this.$container) {
199
- this.$container.style.cursor = cursor;
200
- }
95
+ };
96
+
97
+ _proto.applyCursorStyle = function applyCursorStyle(cursor) {
98
+ if (this.$container) {
99
+ this.$container.style.cursor = cursor;
201
100
  }
202
- }]);
101
+ };
203
102
 
204
103
  return SVGContextService;
205
104
  }();
@@ -218,37 +117,29 @@ var containerModule = Module(function (register) {
218
117
  });
219
118
  var ContextRegisterPlugin = /*#__PURE__*/function () {
220
119
  function ContextRegisterPlugin() {
221
- _classCallCheck(this, ContextRegisterPlugin);
222
-
223
120
  this.name = 'svg-context-register';
224
121
  }
225
122
 
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
- }]);
123
+ var _proto = ContextRegisterPlugin.prototype;
124
+
125
+ _proto.init = function init(container) {
126
+ container.load(containerModule, true);
127
+ };
128
+
129
+ _proto.destroy = function destroy(container) {
130
+ container.unload(containerModule);
131
+ };
237
132
 
238
133
  return ContextRegisterPlugin;
239
134
  }();
240
135
 
241
136
  var Renderer = /*#__PURE__*/function (_AbstractRenderer) {
242
- _inherits(Renderer, _AbstractRenderer);
243
-
244
- var _super = _createSuper(Renderer);
137
+ _inheritsLoose(Renderer, _AbstractRenderer);
245
138
 
246
139
  function Renderer(config) {
247
140
  var _this;
248
141
 
249
- _classCallCheck(this, Renderer);
250
-
251
- _this = _super.call(this, config);
142
+ _this = _AbstractRenderer.call(this, config) || this;
252
143
 
253
144
  _this.registerPlugin(new ContextRegisterPlugin());
254
145
 
@@ -261,7 +152,7 @@ var Renderer = /*#__PURE__*/function (_AbstractRenderer) {
261
152
  return _this;
262
153
  }
263
154
 
264
- return _createClass(Renderer);
155
+ return Renderer;
265
156
  }(AbstractRenderer);
266
157
 
267
158
  export { Renderer };
package/dist/index.js CHANGED
@@ -33,54 +33,11 @@ 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 _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
- }
36
+ function _inheritsLoose(subClass, superClass) {
37
+ subClass.prototype = Object.create(superClass.prototype);
38
+ subClass.prototype.constructor = subClass;
51
39
 
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);
40
+ _setPrototypeOf(subClass, superClass);
84
41
  }
85
42
 
86
43
  function _setPrototypeOf(o, p) {
@@ -92,136 +49,78 @@ function _setPrototypeOf(o, p) {
92
49
  return _setPrototypeOf(o, p);
93
50
  }
94
51
 
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;
105
- }
106
- }
107
-
108
- function _assertThisInitialized(self) {
109
- if (self === void 0) {
110
- throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
111
- }
112
-
113
- return self;
114
- }
115
-
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
- }
122
-
123
- return _assertThisInitialized(self);
124
- }
125
-
126
- function _createSuper(Derived) {
127
- var hasNativeReflectConstruct = _isNativeReflectConstruct();
128
-
129
- return function _createSuperInternal() {
130
- var Super = _getPrototypeOf(Derived),
131
- result;
132
-
133
- if (hasNativeReflectConstruct) {
134
- var NewTarget = _getPrototypeOf(this).constructor;
135
-
136
- result = Reflect.construct(Super, arguments, NewTarget);
137
- } else {
138
- result = Super.apply(this, arguments);
139
- }
140
-
141
- return _possibleConstructorReturn(this, result);
142
- };
143
- }
144
-
145
52
  var SVGContextService = /*#__PURE__*/function () {
146
53
  function SVGContextService() {
147
- _classCallCheck(this, SVGContextService);
148
-
149
54
  this.$container = void 0;
150
55
  this.$namespace = void 0;
151
56
  this.dpr = void 0;
152
57
  this.canvasConfig = void 0;
153
58
  }
154
59
 
155
- _createClass(SVGContextService, [{
156
- key: "init",
157
- value: function init() {
158
- var container = this.canvasConfig.container; // create container
60
+ var _proto = SVGContextService.prototype;
159
61
 
160
- this.$container = g.isString(container) ? document.getElementById(container) : container;
62
+ _proto.init = function init() {
63
+ var _this$canvasConfig = this.canvasConfig,
64
+ container = _this$canvasConfig.container,
65
+ doc = _this$canvasConfig.document; // create container
161
66
 
162
- if (this.$container) {
163
- if (!this.$container.style.position) {
164
- this.$container.style.position = 'relative';
165
- }
67
+ this.$container = g.isString(container) ? (doc || document).getElementById(container) : container;
166
68
 
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;
69
+ if (this.$container) {
70
+ if (!this.$container.style.position) {
71
+ this.$container.style.position = 'relative';
172
72
  }
173
73
 
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;
183
- }
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;
74
+ var $namespace = SVGRenderer.createSVGElement('svg', doc);
75
+ $namespace.setAttribute('width', "" + this.canvasConfig.width);
76
+ $namespace.setAttribute('height', "" + this.canvasConfig.height);
77
+ this.$container.appendChild($namespace);
78
+ this.$namespace = $namespace;
193
79
  }
194
- }, {
195
- key: "getBoundingClientRect",
196
- value: function getBoundingClientRect() {
197
- var _this$$namespace;
198
80
 
199
- return (_this$$namespace = this.$namespace) === null || _this$$namespace === void 0 ? void 0 : _this$$namespace.getBoundingClientRect();
200
- }
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
- }
81
+ var dpr = window.devicePixelRatio || 1;
82
+ dpr = dpr >= 1 ? Math.ceil(dpr) : 1;
83
+ this.dpr = dpr;
84
+ } // @ts-ignore
85
+ ;
86
+
87
+ _proto.getDomElement = function getDomElement() {
88
+ return this.$namespace;
89
+ };
90
+
91
+ _proto.getContext = function getContext() {
92
+ return this.$namespace;
93
+ };
94
+
95
+ _proto.getDPR = function getDPR() {
96
+ return this.dpr;
97
+ };
98
+
99
+ _proto.getBoundingClientRect = function getBoundingClientRect() {
100
+ var _this$$namespace;
101
+
102
+ return (_this$$namespace = this.$namespace) === null || _this$$namespace === void 0 ? void 0 : _this$$namespace.getBoundingClientRect();
103
+ };
104
+
105
+ _proto.destroy = function destroy() {
106
+ // destroy context
107
+ if (this.$container && this.$namespace && this.$namespace.parentNode) {
108
+ this.$container.removeChild(this.$namespace);
208
109
  }
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
- }
110
+ };
111
+
112
+ _proto.resize = function resize(width, height) {
113
+ if (this.$namespace) {
114
+ this.$namespace.setAttribute('width', "" + width);
115
+ this.$namespace.setAttribute('height', "" + height);
216
116
  }
217
- }, {
218
- key: "applyCursorStyle",
219
- value: function applyCursorStyle(cursor) {
220
- if (this.$container) {
221
- this.$container.style.cursor = cursor;
222
- }
117
+ };
118
+
119
+ _proto.applyCursorStyle = function applyCursorStyle(cursor) {
120
+ if (this.$container) {
121
+ this.$container.style.cursor = cursor;
223
122
  }
224
- }]);
123
+ };
225
124
 
226
125
  return SVGContextService;
227
126
  }();
@@ -240,37 +139,29 @@ var containerModule = manaSyringe.Module(function (register) {
240
139
  });
241
140
  var ContextRegisterPlugin = /*#__PURE__*/function () {
242
141
  function ContextRegisterPlugin() {
243
- _classCallCheck(this, ContextRegisterPlugin);
244
-
245
142
  this.name = 'svg-context-register';
246
143
  }
247
144
 
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
- }]);
145
+ var _proto = ContextRegisterPlugin.prototype;
146
+
147
+ _proto.init = function init(container) {
148
+ container.load(containerModule, true);
149
+ };
150
+
151
+ _proto.destroy = function destroy(container) {
152
+ container.unload(containerModule);
153
+ };
259
154
 
260
155
  return ContextRegisterPlugin;
261
156
  }();
262
157
 
263
158
  var Renderer = /*#__PURE__*/function (_AbstractRenderer) {
264
- _inherits(Renderer, _AbstractRenderer);
265
-
266
- var _super = _createSuper(Renderer);
159
+ _inheritsLoose(Renderer, _AbstractRenderer);
267
160
 
268
161
  function Renderer(config) {
269
162
  var _this;
270
163
 
271
- _classCallCheck(this, Renderer);
272
-
273
- _this = _super.call(this, config);
164
+ _this = _AbstractRenderer.call(this, config) || this;
274
165
 
275
166
  _this.registerPlugin(new ContextRegisterPlugin());
276
167
 
@@ -283,7 +174,7 @@ var Renderer = /*#__PURE__*/function (_AbstractRenderer) {
283
174
  return _this;
284
175
  }
285
176
 
286
- return _createClass(Renderer);
177
+ return Renderer;
287
178
  }(g.AbstractRenderer);
288
179
 
289
180
  exports.DomInteraction = DomInteraction__namespace;