@antv/g-canvas 1.0.0-alpha.20 → 1.0.0-alpha.24

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,16 @@
1
+ import type { ContextService } from '@antv/g';
2
+ export declare class Canvas2DContextService implements ContextService<CanvasRenderingContext2D> {
3
+ private $container;
4
+ private $canvas;
5
+ private dpr;
6
+ private context;
7
+ private canvasConfig;
8
+ init(): void;
9
+ getContext(): CanvasRenderingContext2D;
10
+ getDomElement(): HTMLCanvasElement;
11
+ getDPR(): number;
12
+ getBoundingClientRect(): DOMRect;
13
+ destroy(): void;
14
+ resize(width: number, height: number): void;
15
+ applyCursorStyle(cursor: string): void;
16
+ }
@@ -1,114 +1,83 @@
1
- var _dec, _dec2, _class, _class2, _descriptor;
2
-
3
- function _initializerDefineProperty(target, property, descriptor, context) { if (!descriptor) return; Object.defineProperty(target, property, { enumerable: descriptor.enumerable, configurable: descriptor.configurable, writable: descriptor.writable, value: descriptor.initializer ? descriptor.initializer.call(context) : void 0 }); }
4
-
5
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
1
+ import { __decorate, __metadata } from "tslib";
2
+ import { CanvasConfig } from '@antv/g';
3
+ import { inject, injectable } from 'inversify';
4
+ import { isString } from '@antv/util';
5
+ import { setDOMSize } from './utils/dom';
6
6
 
7
- function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
7
+ var Canvas2DContextService = function () {
8
+ function Canvas2DContextService() {}
8
9
 
9
- function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
10
+ Canvas2DContextService.prototype.init = function () {
11
+ var _a = this.canvasConfig,
12
+ container = _a.container,
13
+ width = _a.width,
14
+ height = _a.height; // create container
10
15
 
11
- function _applyDecoratedDescriptor(target, property, decorators, descriptor, context) { var desc = {}; Object.keys(descriptor).forEach(function (key) { desc[key] = descriptor[key]; }); desc.enumerable = !!desc.enumerable; desc.configurable = !!desc.configurable; if ('value' in desc || desc.initializer) { desc.writable = true; } desc = decorators.slice().reverse().reduce(function (desc, decorator) { return decorator(target, property, desc) || desc; }, desc); if (context && desc.initializer !== void 0) { desc.value = desc.initializer ? desc.initializer.call(context) : void 0; desc.initializer = undefined; } if (desc.initializer === void 0) { Object.defineProperty(target, property, desc); desc = null; } return desc; }
16
+ this.$container = isString(container) ? document.getElementById(container) : container;
12
17
 
13
- function _initializerWarningHelper(descriptor, context) { throw new Error('Decorating class property failed. Please ensure that ' + 'proposal-class-properties is enabled and runs after the decorators transform.'); }
18
+ if (this.$container) {
19
+ // create canvas
20
+ var $canvas = document.createElement('canvas');
21
+ this.context = $canvas.getContext('2d');
22
+ this.$container.appendChild($canvas);
14
23
 
15
- import { CanvasConfig } from '@antv/g';
16
- import { inject, injectable } from 'inversify';
17
- import { isString } from '@antv/util';
18
- import { setDOMSize } from './utils/dom';
19
- export var Canvas2DContextService = (_dec = injectable(), _dec2 = inject(CanvasConfig), _dec(_class = (_class2 = /*#__PURE__*/function () {
20
- function Canvas2DContextService() {
21
- _classCallCheck(this, Canvas2DContextService);
22
-
23
- this.$container = void 0;
24
- this.$canvas = void 0;
25
- this.dpr = void 0;
26
- this.context = void 0;
27
-
28
- _initializerDefineProperty(this, "canvasConfig", _descriptor, this);
29
- }
30
-
31
- _createClass(Canvas2DContextService, [{
32
- key: "init",
33
- value: function init() {
34
- var _this$canvasConfig = this.canvasConfig,
35
- container = _this$canvasConfig.container,
36
- width = _this$canvasConfig.width,
37
- height = _this$canvasConfig.height; // create container
38
-
39
- this.$container = isString(container) ? document.getElementById(container) : container;
40
-
41
- if (this.$container) {
42
- // create canvas
43
- var $canvas = document.createElement('canvas');
44
- this.context = $canvas.getContext('2d');
45
- this.$container.appendChild($canvas);
46
-
47
- if (!this.$container.style.position) {
48
- this.$container.style.position = 'relative';
49
- }
50
-
51
- this.$canvas = $canvas;
52
- var dpr = window.devicePixelRatio || 1;
53
- dpr = dpr >= 1 ? Math.ceil(dpr) : 1;
54
- this.dpr = dpr;
55
- this.resize(width, height);
24
+ if (!this.$container.style.position) {
25
+ this.$container.style.position = 'relative';
56
26
  }
57
- }
58
- }, {
59
- key: "getContext",
60
- value: function getContext() {
61
- return this.context;
62
- }
63
- }, {
64
- key: "getDomElement",
65
- value: function getDomElement() {
66
- return this.$canvas;
67
- }
68
- }, {
69
- key: "getDPR",
70
- value: function getDPR() {
71
- return this.dpr;
72
- }
73
- }, {
74
- key: "getBoundingClientRect",
75
- value: function getBoundingClientRect() {
76
- var _this$$canvas;
77
27
 
78
- return (_this$$canvas = this.$canvas) === null || _this$$canvas === void 0 ? void 0 : _this$$canvas.getBoundingClientRect();
28
+ this.$canvas = $canvas;
29
+ var dpr = window.devicePixelRatio || 1;
30
+ dpr = dpr >= 1 ? Math.ceil(dpr) : 1;
31
+ this.dpr = dpr;
32
+ this.resize(width, height);
79
33
  }
80
- }, {
81
- key: "destroy",
82
- value: function destroy() {
83
- if (this.$container && this.$canvas && this.$canvas.parentNode) {
84
- // destroy context
85
- this.$container.removeChild(this.$canvas);
86
- }
34
+ };
35
+
36
+ Canvas2DContextService.prototype.getContext = function () {
37
+ return this.context;
38
+ };
39
+
40
+ Canvas2DContextService.prototype.getDomElement = function () {
41
+ return this.$canvas;
42
+ };
43
+
44
+ Canvas2DContextService.prototype.getDPR = function () {
45
+ return this.dpr;
46
+ };
47
+
48
+ Canvas2DContextService.prototype.getBoundingClientRect = function () {
49
+ var _a;
50
+
51
+ return (_a = this.$canvas) === null || _a === void 0 ? void 0 : _a.getBoundingClientRect();
52
+ };
53
+
54
+ Canvas2DContextService.prototype.destroy = function () {
55
+ if (this.$container && this.$canvas && this.$canvas.parentNode) {
56
+ // destroy context
57
+ this.$container.removeChild(this.$canvas);
87
58
  }
88
- }, {
89
- key: "resize",
90
- value: function resize(width, height) {
91
- if (this.$canvas) {
92
- // set canvas width & height
93
- this.$canvas.width = this.dpr * width;
94
- this.$canvas.height = this.dpr * height; // set CSS style width & height
95
-
96
- setDOMSize(this.$canvas, width, height);
97
- }
59
+ };
60
+
61
+ Canvas2DContextService.prototype.resize = function (width, height) {
62
+ if (this.$canvas) {
63
+ // set canvas width & height
64
+ this.$canvas.width = this.dpr * width;
65
+ this.$canvas.height = this.dpr * height; // set CSS style width & height
66
+
67
+ setDOMSize(this.$canvas, width, height);
98
68
  }
99
- }, {
100
- key: "applyCursorStyle",
101
- value: function applyCursorStyle(cursor) {
102
- if (this.$container) {
103
- this.$container.style.cursor = cursor;
104
- }
69
+ };
70
+
71
+ Canvas2DContextService.prototype.applyCursorStyle = function (cursor) {
72
+ if (this.$container) {
73
+ this.$container.style.cursor = cursor;
105
74
  }
106
- }]);
75
+ };
76
+
77
+ __decorate([inject(CanvasConfig), __metadata("design:type", Object)], Canvas2DContextService.prototype, "canvasConfig", void 0);
107
78
 
79
+ Canvas2DContextService = __decorate([injectable()], Canvas2DContextService);
108
80
  return Canvas2DContextService;
109
- }(), (_descriptor = _applyDecoratedDescriptor(_class2.prototype, "canvasConfig", [_dec2], {
110
- configurable: true,
111
- enumerable: true,
112
- writable: true,
113
- initializer: null
114
- })), _class2)) || _class);
81
+ }();
82
+
83
+ export { Canvas2DContextService };
@@ -0,0 +1,6 @@
1
+ import { Container } from 'inversify';
2
+ import { RendererPlugin } from '@antv/g';
3
+ export declare class ContextRegisterPlugin implements RendererPlugin {
4
+ init(container: Container): void;
5
+ destroy(container: Container): void;
6
+ }
@@ -1,9 +1,3 @@
1
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
2
-
3
- function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
4
-
5
- function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
6
-
7
1
  import { ContainerModule } from 'inversify';
8
2
  import { ContextService } from '@antv/g';
9
3
  import { Canvas2DContextService } from './Canvas2DContextService';
@@ -14,22 +8,19 @@ var containerModule = new ContainerModule(function (bind, unbind, isBound, rebin
14
8
  bind(Canvas2DContextService).toSelf().inSingletonScope();
15
9
  bind(ContextService).toService(Canvas2DContextService);
16
10
  });
17
- export var ContextRegisterPlugin = /*#__PURE__*/function () {
18
- function ContextRegisterPlugin() {
19
- _classCallCheck(this, ContextRegisterPlugin);
20
- }
21
11
 
22
- _createClass(ContextRegisterPlugin, [{
23
- key: "init",
24
- value: function init(container) {
25
- container.load(containerModule);
26
- }
27
- }, {
28
- key: "destroy",
29
- value: function destroy(container) {
30
- container.unload(containerModule);
31
- }
32
- }]);
12
+ var ContextRegisterPlugin = function () {
13
+ function ContextRegisterPlugin() {}
14
+
15
+ ContextRegisterPlugin.prototype.init = function (container) {
16
+ container.load(containerModule);
17
+ };
18
+
19
+ ContextRegisterPlugin.prototype.destroy = function (container) {
20
+ container.unload(containerModule);
21
+ };
33
22
 
34
23
  return ContextRegisterPlugin;
35
- }();
24
+ }();
25
+
26
+ export { ContextRegisterPlugin };
package/es/index.d.ts ADDED
@@ -0,0 +1,4 @@
1
+ import { AbstractRenderer, RendererConfig } from '@antv/g';
2
+ export declare class Renderer extends AbstractRenderer {
3
+ constructor(config?: Partial<RendererConfig>);
4
+ }
package/es/index.js CHANGED
@@ -1,38 +1,17 @@
1
- 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); }
2
-
3
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
4
-
5
- function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
6
-
7
- function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
8
-
9
- function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
10
-
11
- function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
12
-
13
- function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
14
-
15
- function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
16
-
17
- function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
18
-
1
+ import { __extends } from "tslib";
19
2
  import { AbstractRenderer } from '@antv/g';
20
3
  import { Plugin as DomInteractionPlugin } from '@antv/g-plugin-dom-interaction';
21
4
  import { Plugin as CanvasRendererPlugin } from '@antv/g-plugin-canvas-renderer';
22
5
  import { Plugin as CanvasPickerPlugin } from '@antv/g-plugin-canvas-picker';
23
6
  import { Plugin as HTMLRendererPlugin } from '@antv/g-plugin-html-renderer';
24
7
  import { ContextRegisterPlugin } from './ContextRegisterPlugin';
25
- export var Renderer = /*#__PURE__*/function (_AbstractRenderer) {
26
- _inherits(Renderer, _AbstractRenderer);
27
8
 
28
- var _super = _createSuper(Renderer);
9
+ var Renderer = function (_super) {
10
+ __extends(Renderer, _super);
29
11
 
30
12
  function Renderer(config) {
31
- var _this;
13
+ var _this = _super.call(this, config) || this; // register Canvas2DContext
32
14
 
33
- _classCallCheck(this, Renderer);
34
-
35
- _this = _super.call(this, config); // register Canvas2DContext
36
15
 
37
16
  _this.registerPlugin(new ContextRegisterPlugin()); // enable rendering with Canvas2D API
38
17
 
@@ -51,4 +30,6 @@ export var Renderer = /*#__PURE__*/function (_AbstractRenderer) {
51
30
  }
52
31
 
53
32
  return Renderer;
54
- }(AbstractRenderer);
33
+ }(AbstractRenderer);
34
+
35
+ export { Renderer };
@@ -0,0 +1 @@
1
+ export declare const isBrowser: boolean;
@@ -0,0 +1 @@
1
+ export declare function setDOMSize($el: HTMLElement, width: number, height: number): void;
@@ -0,0 +1,16 @@
1
+ import type { ContextService } from '@antv/g';
2
+ export declare class Canvas2DContextService implements ContextService<CanvasRenderingContext2D> {
3
+ private $container;
4
+ private $canvas;
5
+ private dpr;
6
+ private context;
7
+ private canvasConfig;
8
+ init(): void;
9
+ getContext(): CanvasRenderingContext2D;
10
+ getDomElement(): HTMLCanvasElement;
11
+ getDPR(): number;
12
+ getBoundingClientRect(): DOMRect;
13
+ destroy(): void;
14
+ resize(width: number, height: number): void;
15
+ applyCursorStyle(cursor: string): void;
16
+ }
@@ -5,6 +5,8 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.Canvas2DContextService = void 0;
7
7
 
8
+ var _tslib = require("tslib");
9
+
8
10
  var _g = require("@antv/g");
9
11
 
10
12
  var _inversify = require("inversify");
@@ -13,114 +15,79 @@ var _util = require("@antv/util");
13
15
 
14
16
  var _dom = require("./utils/dom");
15
17
 
16
- var _dec, _dec2, _class, _class2, _descriptor;
17
-
18
- function _initializerDefineProperty(target, property, descriptor, context) { if (!descriptor) return; Object.defineProperty(target, property, { enumerable: descriptor.enumerable, configurable: descriptor.configurable, writable: descriptor.writable, value: descriptor.initializer ? descriptor.initializer.call(context) : void 0 }); }
18
+ var Canvas2DContextService = function () {
19
+ function Canvas2DContextService() {}
19
20
 
20
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
21
+ Canvas2DContextService.prototype.init = function () {
22
+ var _a = this.canvasConfig,
23
+ container = _a.container,
24
+ width = _a.width,
25
+ height = _a.height; // create container
21
26
 
22
- function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
27
+ this.$container = (0, _util.isString)(container) ? document.getElementById(container) : container;
23
28
 
24
- function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
29
+ if (this.$container) {
30
+ // create canvas
31
+ var $canvas = document.createElement('canvas');
32
+ this.context = $canvas.getContext('2d');
33
+ this.$container.appendChild($canvas);
25
34
 
26
- function _applyDecoratedDescriptor(target, property, decorators, descriptor, context) { var desc = {}; Object.keys(descriptor).forEach(function (key) { desc[key] = descriptor[key]; }); desc.enumerable = !!desc.enumerable; desc.configurable = !!desc.configurable; if ('value' in desc || desc.initializer) { desc.writable = true; } desc = decorators.slice().reverse().reduce(function (desc, decorator) { return decorator(target, property, desc) || desc; }, desc); if (context && desc.initializer !== void 0) { desc.value = desc.initializer ? desc.initializer.call(context) : void 0; desc.initializer = undefined; } if (desc.initializer === void 0) { Object.defineProperty(target, property, desc); desc = null; } return desc; }
35
+ if (!this.$container.style.position) {
36
+ this.$container.style.position = 'relative';
37
+ }
27
38
 
28
- function _initializerWarningHelper(descriptor, context) { throw new Error('Decorating class property failed. Please ensure that ' + 'proposal-class-properties is enabled and runs after the decorators transform.'); }
39
+ this.$canvas = $canvas;
40
+ var dpr = window.devicePixelRatio || 1;
41
+ dpr = dpr >= 1 ? Math.ceil(dpr) : 1;
42
+ this.dpr = dpr;
43
+ this.resize(width, height);
44
+ }
45
+ };
29
46
 
30
- var Canvas2DContextService = (_dec = (0, _inversify.injectable)(), _dec2 = (0, _inversify.inject)(_g.CanvasConfig), _dec(_class = (_class2 = /*#__PURE__*/function () {
31
- function Canvas2DContextService() {
32
- _classCallCheck(this, Canvas2DContextService);
47
+ Canvas2DContextService.prototype.getContext = function () {
48
+ return this.context;
49
+ };
33
50
 
34
- this.$container = void 0;
35
- this.$canvas = void 0;
36
- this.dpr = void 0;
37
- this.context = void 0;
51
+ Canvas2DContextService.prototype.getDomElement = function () {
52
+ return this.$canvas;
53
+ };
38
54
 
39
- _initializerDefineProperty(this, "canvasConfig", _descriptor, this);
40
- }
55
+ Canvas2DContextService.prototype.getDPR = function () {
56
+ return this.dpr;
57
+ };
41
58
 
42
- _createClass(Canvas2DContextService, [{
43
- key: "init",
44
- value: function init() {
45
- var _this$canvasConfig = this.canvasConfig,
46
- container = _this$canvasConfig.container,
47
- width = _this$canvasConfig.width,
48
- height = _this$canvasConfig.height; // create container
59
+ Canvas2DContextService.prototype.getBoundingClientRect = function () {
60
+ var _a;
49
61
 
50
- this.$container = (0, _util.isString)(container) ? document.getElementById(container) : container;
62
+ return (_a = this.$canvas) === null || _a === void 0 ? void 0 : _a.getBoundingClientRect();
63
+ };
51
64
 
52
- if (this.$container) {
53
- // create canvas
54
- var $canvas = document.createElement('canvas');
55
- this.context = $canvas.getContext('2d');
56
- this.$container.appendChild($canvas);
65
+ Canvas2DContextService.prototype.destroy = function () {
66
+ if (this.$container && this.$canvas && this.$canvas.parentNode) {
67
+ // destroy context
68
+ this.$container.removeChild(this.$canvas);
69
+ }
70
+ };
57
71
 
58
- if (!this.$container.style.position) {
59
- this.$container.style.position = 'relative';
60
- }
72
+ Canvas2DContextService.prototype.resize = function (width, height) {
73
+ if (this.$canvas) {
74
+ // set canvas width & height
75
+ this.$canvas.width = this.dpr * width;
76
+ this.$canvas.height = this.dpr * height; // set CSS style width & height
61
77
 
62
- this.$canvas = $canvas;
63
- var dpr = window.devicePixelRatio || 1;
64
- dpr = dpr >= 1 ? Math.ceil(dpr) : 1;
65
- this.dpr = dpr;
66
- this.resize(width, height);
67
- }
68
- }
69
- }, {
70
- key: "getContext",
71
- value: function getContext() {
72
- return this.context;
73
- }
74
- }, {
75
- key: "getDomElement",
76
- value: function getDomElement() {
77
- return this.$canvas;
78
+ (0, _dom.setDOMSize)(this.$canvas, width, height);
78
79
  }
79
- }, {
80
- key: "getDPR",
81
- value: function getDPR() {
82
- return this.dpr;
83
- }
84
- }, {
85
- key: "getBoundingClientRect",
86
- value: function getBoundingClientRect() {
87
- var _this$$canvas;
80
+ };
88
81
 
89
- return (_this$$canvas = this.$canvas) === null || _this$$canvas === void 0 ? void 0 : _this$$canvas.getBoundingClientRect();
90
- }
91
- }, {
92
- key: "destroy",
93
- value: function destroy() {
94
- if (this.$container && this.$canvas && this.$canvas.parentNode) {
95
- // destroy context
96
- this.$container.removeChild(this.$canvas);
97
- }
98
- }
99
- }, {
100
- key: "resize",
101
- value: function resize(width, height) {
102
- if (this.$canvas) {
103
- // set canvas width & height
104
- this.$canvas.width = this.dpr * width;
105
- this.$canvas.height = this.dpr * height; // set CSS style width & height
106
-
107
- (0, _dom.setDOMSize)(this.$canvas, width, height);
108
- }
109
- }
110
- }, {
111
- key: "applyCursorStyle",
112
- value: function applyCursorStyle(cursor) {
113
- if (this.$container) {
114
- this.$container.style.cursor = cursor;
115
- }
82
+ Canvas2DContextService.prototype.applyCursorStyle = function (cursor) {
83
+ if (this.$container) {
84
+ this.$container.style.cursor = cursor;
116
85
  }
117
- }]);
86
+ };
118
87
 
88
+ (0, _tslib.__decorate)([(0, _inversify.inject)(_g.CanvasConfig), (0, _tslib.__metadata)("design:type", Object)], Canvas2DContextService.prototype, "canvasConfig", void 0);
89
+ Canvas2DContextService = (0, _tslib.__decorate)([(0, _inversify.injectable)()], Canvas2DContextService);
119
90
  return Canvas2DContextService;
120
- }(), (_descriptor = _applyDecoratedDescriptor(_class2.prototype, "canvasConfig", [_dec2], {
121
- configurable: true,
122
- enumerable: true,
123
- writable: true,
124
- initializer: null
125
- })), _class2)) || _class);
91
+ }();
92
+
126
93
  exports.Canvas2DContextService = Canvas2DContextService;
@@ -0,0 +1,6 @@
1
+ import { Container } from 'inversify';
2
+ import { RendererPlugin } from '@antv/g';
3
+ export declare class ContextRegisterPlugin implements RendererPlugin {
4
+ init(container: Container): void;
5
+ destroy(container: Container): void;
6
+ }
@@ -11,12 +11,6 @@ var _g = require("@antv/g");
11
11
 
12
12
  var _Canvas2DContextService = require("./Canvas2DContextService");
13
13
 
14
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
15
-
16
- function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
17
-
18
- function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
19
-
20
14
  var containerModule = new _inversify.ContainerModule(function (bind, unbind, isBound, rebind) {
21
15
  /**
22
16
  * implements ContextService
@@ -25,22 +19,16 @@ var containerModule = new _inversify.ContainerModule(function (bind, unbind, isB
25
19
  bind(_g.ContextService).toService(_Canvas2DContextService.Canvas2DContextService);
26
20
  });
27
21
 
28
- var ContextRegisterPlugin = /*#__PURE__*/function () {
29
- function ContextRegisterPlugin() {
30
- _classCallCheck(this, ContextRegisterPlugin);
31
- }
32
-
33
- _createClass(ContextRegisterPlugin, [{
34
- key: "init",
35
- value: function init(container) {
36
- container.load(containerModule);
37
- }
38
- }, {
39
- key: "destroy",
40
- value: function destroy(container) {
41
- container.unload(containerModule);
42
- }
43
- }]);
22
+ var ContextRegisterPlugin = function () {
23
+ function ContextRegisterPlugin() {}
24
+
25
+ ContextRegisterPlugin.prototype.init = function (container) {
26
+ container.load(containerModule);
27
+ };
28
+
29
+ ContextRegisterPlugin.prototype.destroy = function (container) {
30
+ container.unload(containerModule);
31
+ };
44
32
 
45
33
  return ContextRegisterPlugin;
46
34
  }();
package/lib/index.d.ts ADDED
@@ -0,0 +1,4 @@
1
+ import { AbstractRenderer, RendererConfig } from '@antv/g';
2
+ export declare class Renderer extends AbstractRenderer {
3
+ constructor(config?: Partial<RendererConfig>);
4
+ }
package/lib/index.js CHANGED
@@ -1,12 +1,12 @@
1
1
  "use strict";
2
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
3
  Object.defineProperty(exports, "__esModule", {
6
4
  value: true
7
5
  });
8
6
  exports.Renderer = void 0;
9
7
 
8
+ var _tslib = require("tslib");
9
+
10
10
  var _g = require("@antv/g");
11
11
 
12
12
  var _gPluginDomInteraction = require("@antv/g-plugin-dom-interaction");
@@ -19,33 +19,12 @@ var _gPluginHtmlRenderer = require("@antv/g-plugin-html-renderer");
19
19
 
20
20
  var _ContextRegisterPlugin = require("./ContextRegisterPlugin");
21
21
 
22
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
23
-
24
- function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
25
-
26
- function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
27
-
28
- function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
29
-
30
- function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
31
-
32
- function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
33
-
34
- function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
35
-
36
- function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
37
-
38
- var Renderer = /*#__PURE__*/function (_AbstractRenderer) {
39
- _inherits(Renderer, _AbstractRenderer);
40
-
41
- var _super = _createSuper(Renderer);
22
+ var Renderer = function (_super) {
23
+ (0, _tslib.__extends)(Renderer, _super);
42
24
 
43
25
  function Renderer(config) {
44
- var _this;
45
-
46
- _classCallCheck(this, Renderer);
26
+ var _this = _super.call(this, config) || this; // register Canvas2DContext
47
27
 
48
- _this = _super.call(this, config); // register Canvas2DContext
49
28
 
50
29
  _this.registerPlugin(new _ContextRegisterPlugin.ContextRegisterPlugin()); // enable rendering with Canvas2D API
51
30
 
@@ -0,0 +1 @@
1
+ export declare const isBrowser: boolean;
@@ -0,0 +1 @@
1
+ export declare function setDOMSize($el: HTMLElement, width: number, height: number): void;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@antv/g-canvas",
3
- "version": "1.0.0-alpha.20",
3
+ "version": "1.0.0-alpha.24",
4
4
  "description": "A renderer implemented by Canvas 2D API",
5
5
  "main": "lib/index.js",
6
6
  "module": "es/index.js",
@@ -40,14 +40,12 @@
40
40
  },
41
41
  "homepage": "https://github.com/antvis/g#readme",
42
42
  "dependencies": {
43
- "@antv/g-plugin-canvas-picker": "^1.0.0-alpha.14",
44
- "@antv/g-plugin-canvas-renderer": "^1.0.0-alpha.20",
45
- "@antv/g-plugin-dom-interaction": "^1.0.0-alpha.20",
46
- "@antv/g-plugin-html-renderer": "^1.0.0-alpha.3",
43
+ "@antv/g": "^1.0.0-alpha.24",
44
+ "@antv/g-plugin-canvas-picker": "^1.0.0-alpha.18",
45
+ "@antv/g-plugin-canvas-renderer": "^1.0.0-alpha.24",
46
+ "@antv/g-plugin-dom-interaction": "^1.0.0-alpha.23",
47
+ "@antv/g-plugin-html-renderer": "^1.0.0-alpha.7",
47
48
  "@antv/util": "^2.0.13"
48
49
  },
49
- "peerDependencies": {
50
- "@antv/g": "^1.0.0-alpha.17"
51
- },
52
- "gitHead": "bfcb87639cfb109825e1d4515ffef6ea48e2b65f"
50
+ "gitHead": "fb9ebf362059d1f55a855856f05d42514a72c922"
53
51
  }