@antv/g-svg 1.1.0 → 1.1.3-alpha.0

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.
@@ -1,7 +1,8 @@
1
- import type { Syringe } from 'mana-syringe';
2
- import type { RendererPlugin } from '@antv/g';
3
- export declare class ContextRegisterPlugin implements RendererPlugin {
4
- name: string;
5
- init(container: Syringe.Container): void;
6
- destroy(container: Syringe.Container): void;
7
- }
1
+ import type { Syringe } from 'mana-syringe';
2
+ import type { RendererPlugin } from '@antv/g';
3
+ export declare class ContextRegisterPlugin implements RendererPlugin {
4
+ name: string;
5
+ init(container: Syringe.Container): void;
6
+ destroy(container: Syringe.Container): void;
7
+ }
8
+ //# sourceMappingURL=ContextRegisterPlugin.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ContextRegisterPlugin.d.ts","sourceRoot":"","sources":["../src/ContextRegisterPlugin.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAE5C,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAU9C,qBAAa,qBAAsB,YAAW,cAAc;IAC1D,IAAI,SAA0B;IAC9B,IAAI,CAAC,SAAS,EAAE,OAAO,CAAC,SAAS,GAAG,IAAI;IAGxC,OAAO,CAAC,SAAS,EAAE,OAAO,CAAC,SAAS,GAAG,IAAI;CAG5C"}
@@ -1,15 +1,16 @@
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
+ }
16
+ //# sourceMappingURL=SVGContextService.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SVGContextService.d.ts","sourceRoot":"","sources":["../src/SVGContextService.ts"],"names":[],"mappings":"AAAA,OAAO,EAAgB,cAAc,EAAY,MAAM,SAAS,CAAC;AAIjE,qBACa,iBAAkB,YAAW,cAAc,CAAC,UAAU,CAAC;IAClE,OAAO,CAAC,UAAU,CAAqB;IACvC,OAAO,CAAC,UAAU,CAAoB;IACtC,OAAO,CAAC,GAAG,CAAS;IAGpB,OAAO,CAAC,YAAY,CAAe;IAEnC,IAAI;IAwBJ,aAAa;IAIb,UAAU;IAIV,MAAM;IAIN,qBAAqB;IAIrB,OAAO;IAOP,MAAM,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM;IAOpC,gBAAgB,CAAC,MAAM,EAAE,MAAM;CAKhC"}
@@ -1,9 +1,10 @@
1
- import type { RendererConfig } from '@antv/g';
2
- import { AbstractRenderer } from '@antv/g';
3
- import * as DomInteraction from '@antv/g-plugin-dom-interaction';
4
- import * as SVGRenderer from '@antv/g-plugin-svg-renderer';
5
- import * as SVGPicker from '@antv/g-plugin-svg-picker';
6
- export { DomInteraction, SVGRenderer, SVGPicker };
7
- export declare class Renderer extends AbstractRenderer {
8
- constructor(config?: Partial<RendererConfig>);
9
- }
1
+ import type { RendererConfig } from '@antv/g';
2
+ import { AbstractRenderer } from '@antv/g';
3
+ import * as DomInteraction from '@antv/g-plugin-dom-interaction';
4
+ import * as SVGRenderer from '@antv/g-plugin-svg-renderer';
5
+ import * as SVGPicker from '@antv/g-plugin-svg-picker';
6
+ export { DomInteraction, SVGRenderer, SVGPicker };
7
+ export declare class Renderer extends AbstractRenderer {
8
+ constructor(config?: Partial<RendererConfig>);
9
+ }
10
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAC9C,OAAO,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAC3C,OAAO,KAAK,cAAc,MAAM,gCAAgC,CAAC;AACjE,OAAO,KAAK,WAAW,MAAM,6BAA6B,CAAC;AAC3D,OAAO,KAAK,SAAS,MAAM,2BAA2B,CAAC;AAGvD,OAAO,EAAE,cAAc,EAAE,WAAW,EAAE,SAAS,EAAE,CAAC;AAElD,qBAAa,QAAS,SAAQ,gBAAgB;gBAChC,MAAM,CAAC,EAAE,OAAO,CAAC,cAAc,CAAC;CAQ7C"}
@@ -0,0 +1,156 @@
1
+ import { CanvasConfig, ContextService, isString, AbstractRenderer } from '@antv/g';
2
+ import { Plugin as Plugin$1 } from '@antv/g-plugin-dom-interaction';
3
+ import * as DomInteraction from '@antv/g-plugin-dom-interaction';
4
+ export { DomInteraction };
5
+ import { createSVGElement, Plugin } from '@antv/g-plugin-svg-renderer';
6
+ import * as SVGRenderer from '@antv/g-plugin-svg-renderer';
7
+ export { SVGRenderer };
8
+ import { Plugin as Plugin$2 } from '@antv/g-plugin-svg-picker';
9
+ import * as SVGPicker from '@antv/g-plugin-svg-picker';
10
+ export { SVGPicker };
11
+ import { inject, singleton, Module } from 'mana-syringe';
12
+ import { __decorate, __metadata } from 'tslib';
13
+
14
+ function _inheritsLoose(subClass, superClass) {
15
+ subClass.prototype = Object.create(superClass.prototype);
16
+ subClass.prototype.constructor = subClass;
17
+
18
+ _setPrototypeOf(subClass, superClass);
19
+ }
20
+
21
+ function _setPrototypeOf(o, p) {
22
+ _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) {
23
+ o.__proto__ = p;
24
+ return o;
25
+ };
26
+
27
+ return _setPrototypeOf(o, p);
28
+ }
29
+
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;
36
+ }
37
+
38
+ var _proto = SVGContextService.prototype;
39
+
40
+ _proto.init = function init() {
41
+ var container = this.canvasConfig.container; // create container
42
+
43
+ this.$container = isString(container) ? document.getElementById(container) : container;
44
+
45
+ if (this.$container) {
46
+ if (!this.$container.style.position) {
47
+ this.$container.style.position = 'relative';
48
+ }
49
+
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
+ }
56
+
57
+ var dpr = window.devicePixelRatio || 1;
58
+ dpr = dpr >= 1 ? Math.ceil(dpr) : 1;
59
+ this.dpr = dpr;
60
+ } // @ts-ignore
61
+ ;
62
+
63
+ _proto.getDomElement = function getDomElement() {
64
+ return this.$namespace;
65
+ };
66
+
67
+ _proto.getContext = function getContext() {
68
+ return this.$namespace;
69
+ };
70
+
71
+ _proto.getDPR = function getDPR() {
72
+ return this.dpr;
73
+ };
74
+
75
+ _proto.getBoundingClientRect = function getBoundingClientRect() {
76
+ var _this$$namespace;
77
+
78
+ return (_this$$namespace = this.$namespace) === null || _this$$namespace === void 0 ? void 0 : _this$$namespace.getBoundingClientRect();
79
+ };
80
+
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
+ };
87
+
88
+ _proto.resize = function resize(width, height) {
89
+ if (this.$namespace) {
90
+ this.$namespace.setAttribute('width', "" + width);
91
+ this.$namespace.setAttribute('height', "" + height);
92
+ }
93
+ };
94
+
95
+ _proto.applyCursorStyle = function applyCursorStyle(cursor) {
96
+ if (this.$container) {
97
+ this.$container.style.cursor = cursor;
98
+ }
99
+ };
100
+
101
+ return SVGContextService;
102
+ }();
103
+
104
+ __decorate([inject(CanvasConfig), __metadata("design:type", Object)], SVGContextService.prototype, "canvasConfig", void 0);
105
+
106
+ SVGContextService = __decorate([singleton({
107
+ token: ContextService
108
+ })], SVGContextService);
109
+
110
+ var containerModule = Module(function (register) {
111
+ /**
112
+ * implements ContextService
113
+ */
114
+ register(SVGContextService);
115
+ });
116
+ var ContextRegisterPlugin = /*#__PURE__*/function () {
117
+ function ContextRegisterPlugin() {
118
+ this.name = 'svg-context-register';
119
+ }
120
+
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
+ };
130
+
131
+ return ContextRegisterPlugin;
132
+ }();
133
+
134
+ var Renderer = /*#__PURE__*/function (_AbstractRenderer) {
135
+ _inheritsLoose(Renderer, _AbstractRenderer);
136
+
137
+ function Renderer(config) {
138
+ var _this;
139
+
140
+ _this = _AbstractRenderer.call(this, config) || this;
141
+
142
+ _this.registerPlugin(new ContextRegisterPlugin());
143
+
144
+ _this.registerPlugin(new Plugin());
145
+
146
+ _this.registerPlugin(new Plugin$1());
147
+
148
+ _this.registerPlugin(new Plugin$2());
149
+
150
+ return _this;
151
+ }
152
+
153
+ return Renderer;
154
+ }(AbstractRenderer);
155
+
156
+ export { Renderer };
package/dist/index.js ADDED
@@ -0,0 +1,181 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var g = require('@antv/g');
6
+ var DomInteraction = require('@antv/g-plugin-dom-interaction');
7
+ var SVGRenderer = require('@antv/g-plugin-svg-renderer');
8
+ var SVGPicker = require('@antv/g-plugin-svg-picker');
9
+ var manaSyringe = require('mana-syringe');
10
+ var tslib = require('tslib');
11
+
12
+ function _interopNamespace(e) {
13
+ if (e && e.__esModule) return e;
14
+ var n = Object.create(null);
15
+ if (e) {
16
+ Object.keys(e).forEach(function (k) {
17
+ if (k !== 'default') {
18
+ var d = Object.getOwnPropertyDescriptor(e, k);
19
+ Object.defineProperty(n, k, d.get ? d : {
20
+ enumerable: true,
21
+ get: function () {
22
+ return e[k];
23
+ }
24
+ });
25
+ }
26
+ });
27
+ }
28
+ n['default'] = e;
29
+ return Object.freeze(n);
30
+ }
31
+
32
+ var DomInteraction__namespace = /*#__PURE__*/_interopNamespace(DomInteraction);
33
+ var SVGRenderer__namespace = /*#__PURE__*/_interopNamespace(SVGRenderer);
34
+ var SVGPicker__namespace = /*#__PURE__*/_interopNamespace(SVGPicker);
35
+
36
+ function _inheritsLoose(subClass, superClass) {
37
+ subClass.prototype = Object.create(superClass.prototype);
38
+ subClass.prototype.constructor = subClass;
39
+
40
+ _setPrototypeOf(subClass, superClass);
41
+ }
42
+
43
+ function _setPrototypeOf(o, p) {
44
+ _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) {
45
+ o.__proto__ = p;
46
+ return o;
47
+ };
48
+
49
+ return _setPrototypeOf(o, p);
50
+ }
51
+
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;
58
+ }
59
+
60
+ var _proto = SVGContextService.prototype;
61
+
62
+ _proto.init = function init() {
63
+ var container = this.canvasConfig.container; // create container
64
+
65
+ this.$container = g.isString(container) ? document.getElementById(container) : container;
66
+
67
+ if (this.$container) {
68
+ if (!this.$container.style.position) {
69
+ this.$container.style.position = 'relative';
70
+ }
71
+
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
+ }
78
+
79
+ var dpr = window.devicePixelRatio || 1;
80
+ dpr = dpr >= 1 ? Math.ceil(dpr) : 1;
81
+ this.dpr = dpr;
82
+ } // @ts-ignore
83
+ ;
84
+
85
+ _proto.getDomElement = function getDomElement() {
86
+ return this.$namespace;
87
+ };
88
+
89
+ _proto.getContext = function getContext() {
90
+ return this.$namespace;
91
+ };
92
+
93
+ _proto.getDPR = function getDPR() {
94
+ return this.dpr;
95
+ };
96
+
97
+ _proto.getBoundingClientRect = function getBoundingClientRect() {
98
+ var _this$$namespace;
99
+
100
+ return (_this$$namespace = this.$namespace) === null || _this$$namespace === void 0 ? void 0 : _this$$namespace.getBoundingClientRect();
101
+ };
102
+
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
+ };
109
+
110
+ _proto.resize = function resize(width, height) {
111
+ if (this.$namespace) {
112
+ this.$namespace.setAttribute('width', "" + width);
113
+ this.$namespace.setAttribute('height', "" + height);
114
+ }
115
+ };
116
+
117
+ _proto.applyCursorStyle = function applyCursorStyle(cursor) {
118
+ if (this.$container) {
119
+ this.$container.style.cursor = cursor;
120
+ }
121
+ };
122
+
123
+ return SVGContextService;
124
+ }();
125
+
126
+ tslib.__decorate([manaSyringe.inject(g.CanvasConfig), tslib.__metadata("design:type", Object)], SVGContextService.prototype, "canvasConfig", void 0);
127
+
128
+ SVGContextService = tslib.__decorate([manaSyringe.singleton({
129
+ token: g.ContextService
130
+ })], SVGContextService);
131
+
132
+ var containerModule = manaSyringe.Module(function (register) {
133
+ /**
134
+ * implements ContextService
135
+ */
136
+ register(SVGContextService);
137
+ });
138
+ var ContextRegisterPlugin = /*#__PURE__*/function () {
139
+ function ContextRegisterPlugin() {
140
+ this.name = 'svg-context-register';
141
+ }
142
+
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
+ };
152
+
153
+ return ContextRegisterPlugin;
154
+ }();
155
+
156
+ var Renderer = /*#__PURE__*/function (_AbstractRenderer) {
157
+ _inheritsLoose(Renderer, _AbstractRenderer);
158
+
159
+ function Renderer(config) {
160
+ var _this;
161
+
162
+ _this = _AbstractRenderer.call(this, config) || this;
163
+
164
+ _this.registerPlugin(new ContextRegisterPlugin());
165
+
166
+ _this.registerPlugin(new SVGRenderer.Plugin());
167
+
168
+ _this.registerPlugin(new DomInteraction.Plugin());
169
+
170
+ _this.registerPlugin(new SVGPicker.Plugin());
171
+
172
+ return _this;
173
+ }
174
+
175
+ return Renderer;
176
+ }(g.AbstractRenderer);
177
+
178
+ exports.DomInteraction = DomInteraction__namespace;
179
+ exports.SVGRenderer = SVGRenderer__namespace;
180
+ exports.SVGPicker = SVGPicker__namespace;
181
+ exports.Renderer = Renderer;