@antv/g-svg 1.0.0-alpha.6 → 1.0.1

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,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,16 +1,16 @@
1
1
  {
2
2
  "name": "@antv/g-svg",
3
- "version": "1.0.0-alpha.6",
3
+ "version": "1.0.1",
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",
8
- "unpkg": "dist/index.umd.min.js",
5
+ "main": "lib/index.js",
6
+ "module": "es/index.js",
7
+ "types": "es/index.d.ts",
8
+ "unpkg": "dist/index.umd.js",
9
9
  "files": [
10
10
  "package.json",
11
- "esm",
12
- "lib",
13
11
  "dist",
12
+ "es",
13
+ "lib",
14
14
  "LICENSE",
15
15
  "README.md"
16
16
  ],
@@ -33,18 +33,21 @@
33
33
  },
34
34
  "devDependencies": {
35
35
  "@types/gl-matrix": "^2.4.5",
36
- "@types/jest": "^25.0.0",
37
- "npm-run-all": "^4.1.5",
38
- "webpack": "^4.39.3",
39
- "webpack-cli": "^3.3.7"
36
+ "@types/jest": "^25.0.0"
40
37
  },
41
38
  "homepage": "https://github.com/antvis/g#readme",
42
39
  "dependencies": {
43
- "@antv/g": "^1.0.0-alpha.5",
44
- "@antv/g-plugin-dom-interaction": "^1.0.0-alpha.6",
45
- "@antv/g-plugin-svg-picker": "^1.0.0-alpha.6",
46
- "@antv/g-plugin-svg-renderer": "^1.0.0-alpha.6",
40
+ "@antv/g-plugin-dom-interaction": "^1.0.1",
41
+ "@antv/g-plugin-svg-picker": "^1.0.1",
42
+ "@antv/g-plugin-svg-renderer": "^1.0.1",
47
43
  "@antv/util": "^2.0.13"
48
44
  },
49
- "gitHead": "c977f1c582f0f29d2eb20568a4cab8f795f8d283"
45
+ "peerDependencies": {
46
+ "@antv/g": "^1.0.1",
47
+ "mana-syringe": "^0.2.2"
48
+ },
49
+ "scripts": {
50
+ "umd": "webpack"
51
+ },
52
+ "gitHead": "d09726ac85b8738d53c97002a98848b4a450bfcd"
50
53
  }
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: RendererConfig);
4
- }
package/dist/index.esm.js DELETED
@@ -1,410 +0,0 @@
1
- import { CanvasConfig, ContextService, AbstractRenderer } from '@antv/g';
2
- import { containerModule as containerModule$1 } from '@antv/g-plugin-dom-interaction';
3
- import { createSVGElement, containerModule } from '@antv/g-plugin-svg-renderer';
4
- import { containerModule as containerModule$2 } from '@antv/g-plugin-svg-picker';
5
- import { isString } from '@antv/util';
6
-
7
- function _classCallCheck(instance, Constructor) {
8
- if (!(instance instanceof Constructor)) {
9
- throw new TypeError("Cannot call a class as a function");
10
- }
11
- }
12
-
13
- function _defineProperties(target, props) {
14
- for (var i = 0; i < props.length; i++) {
15
- var descriptor = props[i];
16
- descriptor.enumerable = descriptor.enumerable || false;
17
- descriptor.configurable = true;
18
- if ("value" in descriptor) descriptor.writable = true;
19
- Object.defineProperty(target, descriptor.key, descriptor);
20
- }
21
- }
22
-
23
- function _createClass(Constructor, protoProps, staticProps) {
24
- if (protoProps) _defineProperties(Constructor.prototype, protoProps);
25
- if (staticProps) _defineProperties(Constructor, staticProps);
26
- return Constructor;
27
- }
28
-
29
- function _inherits(subClass, superClass) {
30
- if (typeof superClass !== "function" && superClass !== null) {
31
- throw new TypeError("Super expression must either be null or a function");
32
- }
33
-
34
- subClass.prototype = Object.create(superClass && superClass.prototype, {
35
- constructor: {
36
- value: subClass,
37
- writable: true,
38
- configurable: true
39
- }
40
- });
41
- if (superClass) _setPrototypeOf(subClass, superClass);
42
- }
43
-
44
- function _getPrototypeOf(o) {
45
- _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) {
46
- return o.__proto__ || Object.getPrototypeOf(o);
47
- };
48
- return _getPrototypeOf(o);
49
- }
50
-
51
- function _setPrototypeOf(o, p) {
52
- _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) {
53
- o.__proto__ = p;
54
- return o;
55
- };
56
-
57
- return _setPrototypeOf(o, p);
58
- }
59
-
60
- function _isNativeReflectConstruct() {
61
- if (typeof Reflect === "undefined" || !Reflect.construct) return false;
62
- if (Reflect.construct.sham) return false;
63
- if (typeof Proxy === "function") return true;
64
-
65
- try {
66
- Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {}));
67
- return true;
68
- } catch (e) {
69
- return false;
70
- }
71
- }
72
-
73
- function _assertThisInitialized(self) {
74
- if (self === void 0) {
75
- throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
76
- }
77
-
78
- return self;
79
- }
80
-
81
- function _possibleConstructorReturn(self, call) {
82
- if (call && (typeof call === "object" || typeof call === "function")) {
83
- return call;
84
- }
85
-
86
- return _assertThisInitialized(self);
87
- }
88
-
89
- function _createSuper(Derived) {
90
- var hasNativeReflectConstruct = _isNativeReflectConstruct();
91
-
92
- return function _createSuperInternal() {
93
- var Super = _getPrototypeOf(Derived),
94
- result;
95
-
96
- if (hasNativeReflectConstruct) {
97
- var NewTarget = _getPrototypeOf(this).constructor;
98
-
99
- result = Reflect.construct(Super, arguments, NewTarget);
100
- } else {
101
- result = Super.apply(this, arguments);
102
- }
103
-
104
- return _possibleConstructorReturn(this, result);
105
- };
106
- }
107
-
108
- var NAMED_TAG = "named";
109
- var INJECT_TAG = "inject";
110
- var TAGGED = "inversify:tagged";
111
- var TAGGED_PROP = "inversify:tagged_props";
112
- var PARAM_TYPES = "inversify:paramtypes";
113
- var DESIGN_PARAM_TYPES = "design:paramtypes";
114
-
115
- var idCounter = 0;
116
- function id() {
117
- return idCounter++;
118
- }
119
-
120
- var DUPLICATED_INJECTABLE_DECORATOR = "Cannot apply @injectable decorator multiple times.";
121
- var DUPLICATED_METADATA = "Metadata key was used more than once in a parameter:";
122
- var UNDEFINED_INJECT_ANNOTATION = function (name) {
123
- return "@inject called with undefined this could mean that the class " + name + " has " +
124
- "a circular dependency problem. You can use a LazyServiceIdentifer to " +
125
- "overcome this limitation.";
126
- };
127
- var INVALID_DECORATOR_OPERATION = "The @inject @multiInject @tagged and @named decorators " +
128
- "must be applied to the parameters of a class constructor or a class property.";
129
-
130
- var Metadata = (function () {
131
- function Metadata(key, value) {
132
- this.key = key;
133
- this.value = value;
134
- }
135
- Metadata.prototype.toString = function () {
136
- if (this.key === NAMED_TAG) {
137
- return "named: " + this.value.toString() + " ";
138
- }
139
- else {
140
- return "tagged: { key:" + this.key.toString() + ", value: " + this.value + " }";
141
- }
142
- };
143
- return Metadata;
144
- }());
145
-
146
- function tagParameter(annotationTarget, propertyName, parameterIndex, metadata) {
147
- var metadataKey = TAGGED;
148
- _tagParameterOrProperty(metadataKey, annotationTarget, propertyName, metadata, parameterIndex);
149
- }
150
- function tagProperty(annotationTarget, propertyName, metadata) {
151
- var metadataKey = TAGGED_PROP;
152
- _tagParameterOrProperty(metadataKey, annotationTarget.constructor, propertyName, metadata);
153
- }
154
- function _tagParameterOrProperty(metadataKey, annotationTarget, propertyName, metadata, parameterIndex) {
155
- var paramsOrPropertiesMetadata = {};
156
- var isParameterDecorator = (typeof parameterIndex === "number");
157
- var key = (parameterIndex !== undefined && isParameterDecorator) ? parameterIndex.toString() : propertyName;
158
- if (isParameterDecorator && propertyName !== undefined) {
159
- throw new Error(INVALID_DECORATOR_OPERATION);
160
- }
161
- if (Reflect.hasOwnMetadata(metadataKey, annotationTarget)) {
162
- paramsOrPropertiesMetadata = Reflect.getMetadata(metadataKey, annotationTarget);
163
- }
164
- var paramOrPropertyMetadata = paramsOrPropertiesMetadata[key];
165
- if (!Array.isArray(paramOrPropertyMetadata)) {
166
- paramOrPropertyMetadata = [];
167
- }
168
- else {
169
- for (var _i = 0, paramOrPropertyMetadata_1 = paramOrPropertyMetadata; _i < paramOrPropertyMetadata_1.length; _i++) {
170
- var m = paramOrPropertyMetadata_1[_i];
171
- if (m.key === metadata.key) {
172
- throw new Error(DUPLICATED_METADATA + " " + m.key.toString());
173
- }
174
- }
175
- }
176
- paramOrPropertyMetadata.push(metadata);
177
- paramsOrPropertiesMetadata[key] = paramOrPropertyMetadata;
178
- Reflect.defineMetadata(metadataKey, paramsOrPropertiesMetadata, annotationTarget);
179
- }
180
-
181
- function inject(serviceIdentifier) {
182
- return function (target, targetKey, index) {
183
- if (serviceIdentifier === undefined) {
184
- throw new Error(UNDEFINED_INJECT_ANNOTATION(target.name));
185
- }
186
- var metadata = new Metadata(INJECT_TAG, serviceIdentifier);
187
- if (typeof index === "number") {
188
- tagParameter(target, targetKey, index, metadata);
189
- }
190
- else {
191
- tagProperty(target, targetKey, metadata);
192
- }
193
- };
194
- }
195
-
196
- var __spreadArrays = (undefined && undefined.__spreadArrays) || function () {
197
- for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;
198
- for (var r = Array(s), k = 0, i = 0; i < il; i++)
199
- for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
200
- r[k] = a[j];
201
- return r;
202
- };
203
-
204
- var __spreadArrays$1 = (undefined && undefined.__spreadArrays) || function () {
205
- for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;
206
- for (var r = Array(s), k = 0, i = 0; i < il; i++)
207
- for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
208
- r[k] = a[j];
209
- return r;
210
- };
211
-
212
- var __awaiter = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) {
213
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
214
- return new (P || (P = Promise))(function (resolve, reject) {
215
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
216
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
217
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
218
- step((generator = generator.apply(thisArg, _arguments || [])).next());
219
- });
220
- };
221
- var __generator = (undefined && undefined.__generator) || function (thisArg, body) {
222
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
223
- return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
224
- function verb(n) { return function (v) { return step([n, v]); }; }
225
- function step(op) {
226
- if (f) throw new TypeError("Generator is already executing.");
227
- while (_) try {
228
- if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
229
- if (y = 0, t) op = [op[0] & 2, t.value];
230
- switch (op[0]) {
231
- case 0: case 1: t = op; break;
232
- case 4: _.label++; return { value: op[1], done: false };
233
- case 5: _.label++; y = op[1]; op = [0]; continue;
234
- case 7: op = _.ops.pop(); _.trys.pop(); continue;
235
- default:
236
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
237
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
238
- if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
239
- if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
240
- if (t[2]) _.ops.pop();
241
- _.trys.pop(); continue;
242
- }
243
- op = body.call(thisArg, _);
244
- } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
245
- if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
246
- }
247
- };
248
-
249
- var ContainerModule = (function () {
250
- function ContainerModule(registry) {
251
- this.id = id();
252
- this.registry = registry;
253
- }
254
- return ContainerModule;
255
- }());
256
-
257
- function injectable() {
258
- return function (target) {
259
- if (Reflect.hasOwnMetadata(PARAM_TYPES, target)) {
260
- throw new Error(DUPLICATED_INJECTABLE_DECORATOR);
261
- }
262
- var types = Reflect.getMetadata(DESIGN_PARAM_TYPES, target) || [];
263
- Reflect.defineMetadata(PARAM_TYPES, types, target);
264
- return target;
265
- };
266
- }
267
-
268
- /*! *****************************************************************************
269
- Copyright (c) Microsoft Corporation.
270
-
271
- Permission to use, copy, modify, and/or distribute this software for any
272
- purpose with or without fee is hereby granted.
273
-
274
- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
275
- REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
276
- AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
277
- INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
278
- LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
279
- OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
280
- PERFORMANCE OF THIS SOFTWARE.
281
- ***************************************************************************** */
282
-
283
- function __decorate(decorators, target, key, desc) {
284
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
285
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
286
- 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;
287
- return c > 3 && r && Object.defineProperty(target, key, r), r;
288
- }
289
-
290
- function __metadata(metadataKey, metadataValue) {
291
- if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(metadataKey, metadataValue);
292
- }
293
-
294
- var SVGContextService = /*#__PURE__*/function () {
295
- function SVGContextService() {
296
- _classCallCheck(this, SVGContextService);
297
-
298
- this.$container = void 0;
299
- this.$namespace = void 0;
300
- this.dpr = void 0;
301
- this.canvasConfig = void 0;
302
- }
303
-
304
- _createClass(SVGContextService, [{
305
- key: "init",
306
- value: function init() {
307
- var container = this.canvasConfig.container; // create container
308
-
309
- this.$container = isString(container) ? document.getElementById(container) : container;
310
-
311
- if (this.$container) {
312
- var $namespace = createSVGElement('svg');
313
- $namespace.setAttribute('width', "".concat(this.canvasConfig.width));
314
- $namespace.setAttribute('height', "".concat(this.canvasConfig.height));
315
- this.$container.appendChild($namespace);
316
- this.$namespace = $namespace;
317
- }
318
-
319
- var dpr = window.devicePixelRatio || 1;
320
- dpr = dpr >= 1 ? Math.ceil(dpr) : 1;
321
- this.dpr = dpr;
322
- } // @ts-ignore
323
-
324
- }, {
325
- key: "getDomElement",
326
- value: function getDomElement() {
327
- return this.$namespace;
328
- }
329
- }, {
330
- key: "getContext",
331
- value: function getContext() {
332
- return this.$namespace;
333
- }
334
- }, {
335
- key: "getDPR",
336
- value: function getDPR() {
337
- return this.dpr;
338
- }
339
- }, {
340
- key: "getBoundingClientRect",
341
- value: function getBoundingClientRect() {
342
- var _this$$namespace;
343
-
344
- return (_this$$namespace = this.$namespace) === null || _this$$namespace === void 0 ? void 0 : _this$$namespace.getBoundingClientRect();
345
- }
346
- }, {
347
- key: "destroy",
348
- value: function destroy() {
349
- // destroy context
350
- if (this.$container && this.$namespace) {
351
- this.$container.removeChild(this.$namespace);
352
- }
353
- }
354
- }, {
355
- key: "resize",
356
- value: function resize(width, height) {
357
- if (this.$namespace) {
358
- this.$namespace.setAttribute('width', "".concat(width));
359
- this.$namespace.setAttribute('height', "".concat(height));
360
- }
361
- }
362
- }, {
363
- key: "applyCursorStyle",
364
- value: function applyCursorStyle(cursor) {
365
- if (this.$container) {
366
- this.$container.style.cursor = cursor;
367
- }
368
- }
369
- }]);
370
-
371
- return SVGContextService;
372
- }();
373
-
374
- __decorate([inject(CanvasConfig), __metadata("design:type", Object)], SVGContextService.prototype, "canvasConfig", void 0);
375
-
376
- SVGContextService = __decorate([injectable()], SVGContextService);
377
-
378
- var Renderer = /*#__PURE__*/function (_AbstractRenderer) {
379
- _inherits(Renderer, _AbstractRenderer);
380
-
381
- var _super = _createSuper(Renderer);
382
-
383
- function Renderer(config) {
384
- var _this;
385
-
386
- _classCallCheck(this, Renderer);
387
-
388
- _this = _super.call(this, config);
389
-
390
- _this.registerPlugin(new ContainerModule(function (bind, unbind, isBound, rebind) {
391
- /**
392
- * implements ContextService
393
- */
394
- bind(SVGContextService).toSelf().inSingletonScope();
395
- bind(ContextService).toService(SVGContextService);
396
- }));
397
-
398
- _this.registerPlugin(containerModule);
399
-
400
- _this.registerPlugin(containerModule$1);
401
-
402
- _this.registerPlugin(containerModule$2);
403
-
404
- return _this;
405
- }
406
-
407
- return Renderer;
408
- }(AbstractRenderer);
409
-
410
- export { Renderer };