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