@antv/g-canvas 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 +2221 -0
- package/lib/index.js +62 -0
- package/package.json +18 -13
- package/dist/Canvas2DContextService.d.ts +0 -16
- package/dist/ContextRegisterPlugin.d.ts +0 -6
- package/dist/index.d.ts +0 -4
- package/dist/index.esm.js +0 -204
- package/dist/index.js +0 -307
- package/dist/utils/browser.d.ts +0 -1
- package/dist/utils/dom.d.ts +0 -1
package/lib/index.js
ADDED
|
@@ -0,0 +1,62 @@
|
|
|
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.HTMLRenderer = exports.CanvasPicker = exports.CanvasRenderer = 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 CanvasRenderer = _interopRequireWildcard(require("@antv/g-plugin-canvas-renderer"));
|
|
19
|
+
|
|
20
|
+
exports.CanvasRenderer = CanvasRenderer;
|
|
21
|
+
|
|
22
|
+
var CanvasPicker = _interopRequireWildcard(require("@antv/g-plugin-canvas-picker"));
|
|
23
|
+
|
|
24
|
+
exports.CanvasPicker = CanvasPicker;
|
|
25
|
+
|
|
26
|
+
var HTMLRenderer = _interopRequireWildcard(require("@antv/g-plugin-html-renderer"));
|
|
27
|
+
|
|
28
|
+
exports.HTMLRenderer = HTMLRenderer;
|
|
29
|
+
|
|
30
|
+
var _ContextRegisterPlugin = require("./ContextRegisterPlugin");
|
|
31
|
+
|
|
32
|
+
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); }
|
|
33
|
+
|
|
34
|
+
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; }
|
|
35
|
+
|
|
36
|
+
var Renderer = function (_super) {
|
|
37
|
+
(0, _tslib.__extends)(Renderer, _super);
|
|
38
|
+
|
|
39
|
+
function Renderer(config) {
|
|
40
|
+
var _this = _super.call(this, config) || this; // register Canvas2DContext
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
_this.registerPlugin(new _ContextRegisterPlugin.ContextRegisterPlugin()); // enable rendering with Canvas2D API
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
_this.registerPlugin(new CanvasRenderer.Plugin());
|
|
47
|
+
|
|
48
|
+
_this.registerPlugin(new DomInteraction.Plugin()); // enable picking with Canvas2D API
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
_this.registerPlugin(new CanvasPicker.Plugin()); // render HTML component
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
_this.registerPlugin(new HTMLRenderer.Plugin());
|
|
55
|
+
|
|
56
|
+
return _this;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
return Renderer;
|
|
60
|
+
}(_g.AbstractRenderer);
|
|
61
|
+
|
|
62
|
+
exports.Renderer = Renderer;
|
package/package.json
CHANGED
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@antv/g-canvas",
|
|
3
|
-
"version": "1.0.0-alpha.
|
|
3
|
+
"version": "1.0.0-alpha.28",
|
|
4
4
|
"description": "A renderer implemented by Canvas 2D API",
|
|
5
|
-
"main": "
|
|
6
|
-
"module": "
|
|
7
|
-
"types": "
|
|
8
|
-
"sideEffects": false,
|
|
5
|
+
"main": "lib/index.js",
|
|
6
|
+
"module": "es/index.esm.js",
|
|
7
|
+
"types": "es/index.d.ts",
|
|
9
8
|
"files": [
|
|
10
9
|
"package.json",
|
|
11
10
|
"dist",
|
|
@@ -38,14 +37,20 @@
|
|
|
38
37
|
},
|
|
39
38
|
"homepage": "https://github.com/antvis/g#readme",
|
|
40
39
|
"dependencies": {
|
|
41
|
-
"@antv/g": "^1.0.0-alpha.
|
|
42
|
-
"@antv/g-plugin-canvas-picker": "^1.0.0-alpha.
|
|
43
|
-
"@antv/g-plugin-canvas-renderer": "^1.0.0-alpha.
|
|
44
|
-
"@antv/g-plugin-dom-interaction": "^1.0.0-alpha.
|
|
45
|
-
"@antv/g-plugin-html-renderer": "^1.0.0-alpha.
|
|
40
|
+
"@antv/g": "^1.0.0-alpha.28",
|
|
41
|
+
"@antv/g-plugin-canvas-picker": "^1.0.0-alpha.22",
|
|
42
|
+
"@antv/g-plugin-canvas-renderer": "^1.0.0-alpha.28",
|
|
43
|
+
"@antv/g-plugin-dom-interaction": "^1.0.0-alpha.27",
|
|
44
|
+
"@antv/g-plugin-html-renderer": "^1.0.0-alpha.11",
|
|
46
45
|
"@antv/util": "^2.0.13",
|
|
47
|
-
"@babel/runtime": "^7.16.
|
|
48
|
-
|
|
46
|
+
"@babel/runtime": "^7.16.3"
|
|
47
|
+
},
|
|
48
|
+
"peerDependencies": {
|
|
49
|
+
"@antv/g": "^1.0.0-alpha.27",
|
|
50
|
+
"mana-syringe": "^0.2.1"
|
|
51
|
+
},
|
|
52
|
+
"scripts": {
|
|
53
|
+
"umd": "webpack"
|
|
49
54
|
},
|
|
50
|
-
"gitHead": "
|
|
55
|
+
"gitHead": "b8af919853fa578b4aa6c5e84715948085ac0170"
|
|
51
56
|
}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { 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
|
-
}
|
package/dist/index.d.ts
DELETED
package/dist/index.esm.js
DELETED
|
@@ -1,204 +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 { Plugin } from '@antv/g-plugin-canvas-renderer';
|
|
7
|
-
import { Plugin as Plugin$2 } from '@antv/g-plugin-canvas-picker';
|
|
8
|
-
import { Plugin as Plugin$3 } from '@antv/g-plugin-html-renderer';
|
|
9
|
-
import _createClass from '@babel/runtime/helpers/esm/createClass';
|
|
10
|
-
import { inject, singleton, Module } from 'mana-syringe';
|
|
11
|
-
import { isString } from '@antv/util';
|
|
12
|
-
|
|
13
|
-
/*! *****************************************************************************
|
|
14
|
-
Copyright (c) Microsoft Corporation.
|
|
15
|
-
|
|
16
|
-
Permission to use, copy, modify, and/or distribute this software for any
|
|
17
|
-
purpose with or without fee is hereby granted.
|
|
18
|
-
|
|
19
|
-
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
20
|
-
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
21
|
-
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
22
|
-
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
23
|
-
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
24
|
-
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
25
|
-
PERFORMANCE OF THIS SOFTWARE.
|
|
26
|
-
***************************************************************************** */
|
|
27
|
-
|
|
28
|
-
function __decorate(decorators, target, key, desc) {
|
|
29
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
30
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
31
|
-
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;
|
|
32
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
function __metadata(metadataKey, metadataValue) {
|
|
36
|
-
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(metadataKey, metadataValue);
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
var isBrowser = typeof window !== 'undefined' && typeof window.document !== 'undefined';
|
|
40
|
-
|
|
41
|
-
var PX_SUFFIX = 'px';
|
|
42
|
-
function setDOMSize($el, width, height) {
|
|
43
|
-
if (isBrowser) {
|
|
44
|
-
$el.style.width = width + PX_SUFFIX;
|
|
45
|
-
$el.style.height = height + PX_SUFFIX;
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
var Canvas2DContextService = /*#__PURE__*/function () {
|
|
50
|
-
function Canvas2DContextService() {
|
|
51
|
-
_classCallCheck(this, Canvas2DContextService);
|
|
52
|
-
|
|
53
|
-
this.$container = void 0;
|
|
54
|
-
this.$canvas = void 0;
|
|
55
|
-
this.dpr = void 0;
|
|
56
|
-
this.context = void 0;
|
|
57
|
-
this.canvasConfig = void 0;
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
_createClass(Canvas2DContextService, [{
|
|
61
|
-
key: "init",
|
|
62
|
-
value: function init() {
|
|
63
|
-
var _this$canvasConfig = this.canvasConfig,
|
|
64
|
-
container = _this$canvasConfig.container,
|
|
65
|
-
width = _this$canvasConfig.width,
|
|
66
|
-
height = _this$canvasConfig.height; // create container
|
|
67
|
-
|
|
68
|
-
this.$container = isString(container) ? document.getElementById(container) : container;
|
|
69
|
-
|
|
70
|
-
if (this.$container) {
|
|
71
|
-
// create canvas
|
|
72
|
-
var $canvas = document.createElement('canvas');
|
|
73
|
-
this.context = $canvas.getContext('2d');
|
|
74
|
-
this.$container.appendChild($canvas);
|
|
75
|
-
|
|
76
|
-
if (!this.$container.style.position) {
|
|
77
|
-
this.$container.style.position = 'relative';
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
this.$canvas = $canvas;
|
|
81
|
-
var dpr = window.devicePixelRatio || 1;
|
|
82
|
-
dpr = dpr >= 1 ? Math.ceil(dpr) : 1;
|
|
83
|
-
this.dpr = dpr;
|
|
84
|
-
this.resize(width, height);
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
}, {
|
|
88
|
-
key: "getContext",
|
|
89
|
-
value: function getContext() {
|
|
90
|
-
return this.context;
|
|
91
|
-
}
|
|
92
|
-
}, {
|
|
93
|
-
key: "getDomElement",
|
|
94
|
-
value: function getDomElement() {
|
|
95
|
-
return this.$canvas;
|
|
96
|
-
}
|
|
97
|
-
}, {
|
|
98
|
-
key: "getDPR",
|
|
99
|
-
value: function getDPR() {
|
|
100
|
-
return this.dpr;
|
|
101
|
-
}
|
|
102
|
-
}, {
|
|
103
|
-
key: "getBoundingClientRect",
|
|
104
|
-
value: function getBoundingClientRect() {
|
|
105
|
-
var _this$$canvas;
|
|
106
|
-
|
|
107
|
-
return (_this$$canvas = this.$canvas) === null || _this$$canvas === void 0 ? void 0 : _this$$canvas.getBoundingClientRect();
|
|
108
|
-
}
|
|
109
|
-
}, {
|
|
110
|
-
key: "destroy",
|
|
111
|
-
value: function destroy() {
|
|
112
|
-
if (this.$container && this.$canvas && this.$canvas.parentNode) {
|
|
113
|
-
// destroy context
|
|
114
|
-
this.$container.removeChild(this.$canvas);
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
}, {
|
|
118
|
-
key: "resize",
|
|
119
|
-
value: function resize(width, height) {
|
|
120
|
-
if (this.$canvas) {
|
|
121
|
-
// set canvas width & height
|
|
122
|
-
this.$canvas.width = this.dpr * width;
|
|
123
|
-
this.$canvas.height = this.dpr * height; // set CSS style width & height
|
|
124
|
-
|
|
125
|
-
setDOMSize(this.$canvas, width, height);
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
}, {
|
|
129
|
-
key: "applyCursorStyle",
|
|
130
|
-
value: function applyCursorStyle(cursor) {
|
|
131
|
-
if (this.$container) {
|
|
132
|
-
this.$container.style.cursor = cursor;
|
|
133
|
-
}
|
|
134
|
-
}
|
|
135
|
-
}]);
|
|
136
|
-
|
|
137
|
-
return Canvas2DContextService;
|
|
138
|
-
}();
|
|
139
|
-
|
|
140
|
-
__decorate([inject(CanvasConfig), __metadata("design:type", Object)], Canvas2DContextService.prototype, "canvasConfig", void 0);
|
|
141
|
-
|
|
142
|
-
Canvas2DContextService = __decorate([singleton({
|
|
143
|
-
token: ContextService
|
|
144
|
-
})], Canvas2DContextService);
|
|
145
|
-
|
|
146
|
-
var containerModule = Module(function (register) {
|
|
147
|
-
/**
|
|
148
|
-
* implements ContextService
|
|
149
|
-
*/
|
|
150
|
-
register(Canvas2DContextService);
|
|
151
|
-
});
|
|
152
|
-
var ContextRegisterPlugin = /*#__PURE__*/function () {
|
|
153
|
-
function ContextRegisterPlugin() {
|
|
154
|
-
_classCallCheck(this, ContextRegisterPlugin);
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
_createClass(ContextRegisterPlugin, [{
|
|
158
|
-
key: "init",
|
|
159
|
-
value: function init(container) {
|
|
160
|
-
container.load(containerModule);
|
|
161
|
-
}
|
|
162
|
-
}, {
|
|
163
|
-
key: "destroy",
|
|
164
|
-
value: function destroy(container) {// @ts-ignore
|
|
165
|
-
// container.container.unload(containerModule);
|
|
166
|
-
// container.remove(Canvas2DContextService);
|
|
167
|
-
}
|
|
168
|
-
}]);
|
|
169
|
-
|
|
170
|
-
return ContextRegisterPlugin;
|
|
171
|
-
}();
|
|
172
|
-
|
|
173
|
-
var Renderer = /*#__PURE__*/function (_AbstractRenderer) {
|
|
174
|
-
_inherits(Renderer, _AbstractRenderer);
|
|
175
|
-
|
|
176
|
-
var _super = _createSuper(Renderer);
|
|
177
|
-
|
|
178
|
-
function Renderer(config) {
|
|
179
|
-
var _this;
|
|
180
|
-
|
|
181
|
-
_classCallCheck(this, Renderer);
|
|
182
|
-
|
|
183
|
-
_this = _super.call(this, config); // register Canvas2DContext
|
|
184
|
-
|
|
185
|
-
_this.registerPlugin(new ContextRegisterPlugin()); // enable rendering with Canvas2D API
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
_this.registerPlugin(new Plugin());
|
|
189
|
-
|
|
190
|
-
_this.registerPlugin(new Plugin$1()); // enable picking with Canvas2D API
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
_this.registerPlugin(new Plugin$2()); // render HTML component
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
_this.registerPlugin(new Plugin$3());
|
|
197
|
-
|
|
198
|
-
return _this;
|
|
199
|
-
}
|
|
200
|
-
|
|
201
|
-
return Renderer;
|
|
202
|
-
}(AbstractRenderer);
|
|
203
|
-
|
|
204
|
-
export { Renderer };
|
package/dist/index.js
DELETED
|
@@ -1,307 +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 gPluginCanvasRenderer = require('@antv/g-plugin-canvas-renderer');
|
|
8
|
-
var gPluginCanvasPicker = require('@antv/g-plugin-canvas-picker');
|
|
9
|
-
var gPluginHtmlRenderer = require('@antv/g-plugin-html-renderer');
|
|
10
|
-
var manaSyringe = require('mana-syringe');
|
|
11
|
-
var util = require('@antv/util');
|
|
12
|
-
|
|
13
|
-
function _classCallCheck(instance, Constructor) {
|
|
14
|
-
if (!(instance instanceof Constructor)) {
|
|
15
|
-
throw new TypeError("Cannot call a class as a function");
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
function _defineProperties(target, props) {
|
|
20
|
-
for (var i = 0; i < props.length; i++) {
|
|
21
|
-
var descriptor = props[i];
|
|
22
|
-
descriptor.enumerable = descriptor.enumerable || false;
|
|
23
|
-
descriptor.configurable = true;
|
|
24
|
-
if ("value" in descriptor) descriptor.writable = true;
|
|
25
|
-
Object.defineProperty(target, descriptor.key, descriptor);
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
function _createClass(Constructor, protoProps, staticProps) {
|
|
30
|
-
if (protoProps) _defineProperties(Constructor.prototype, protoProps);
|
|
31
|
-
if (staticProps) _defineProperties(Constructor, staticProps);
|
|
32
|
-
return Constructor;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
function _inherits(subClass, superClass) {
|
|
36
|
-
if (typeof superClass !== "function" && superClass !== null) {
|
|
37
|
-
throw new TypeError("Super expression must either be null or a function");
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
subClass.prototype = Object.create(superClass && superClass.prototype, {
|
|
41
|
-
constructor: {
|
|
42
|
-
value: subClass,
|
|
43
|
-
writable: true,
|
|
44
|
-
configurable: true
|
|
45
|
-
}
|
|
46
|
-
});
|
|
47
|
-
if (superClass) _setPrototypeOf(subClass, superClass);
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
function _getPrototypeOf(o) {
|
|
51
|
-
_getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) {
|
|
52
|
-
return o.__proto__ || Object.getPrototypeOf(o);
|
|
53
|
-
};
|
|
54
|
-
return _getPrototypeOf(o);
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
function _setPrototypeOf(o, p) {
|
|
58
|
-
_setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) {
|
|
59
|
-
o.__proto__ = p;
|
|
60
|
-
return o;
|
|
61
|
-
};
|
|
62
|
-
|
|
63
|
-
return _setPrototypeOf(o, p);
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
function _isNativeReflectConstruct() {
|
|
67
|
-
if (typeof Reflect === "undefined" || !Reflect.construct) return false;
|
|
68
|
-
if (Reflect.construct.sham) return false;
|
|
69
|
-
if (typeof Proxy === "function") return true;
|
|
70
|
-
|
|
71
|
-
try {
|
|
72
|
-
Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {}));
|
|
73
|
-
return true;
|
|
74
|
-
} catch (e) {
|
|
75
|
-
return false;
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
function _assertThisInitialized(self) {
|
|
80
|
-
if (self === void 0) {
|
|
81
|
-
throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
return self;
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
function _possibleConstructorReturn(self, call) {
|
|
88
|
-
if (call && (typeof call === "object" || typeof call === "function")) {
|
|
89
|
-
return call;
|
|
90
|
-
} else if (call !== void 0) {
|
|
91
|
-
throw new TypeError("Derived constructors may only return object or undefined");
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
return _assertThisInitialized(self);
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
function _createSuper(Derived) {
|
|
98
|
-
var hasNativeReflectConstruct = _isNativeReflectConstruct();
|
|
99
|
-
|
|
100
|
-
return function _createSuperInternal() {
|
|
101
|
-
var Super = _getPrototypeOf(Derived),
|
|
102
|
-
result;
|
|
103
|
-
|
|
104
|
-
if (hasNativeReflectConstruct) {
|
|
105
|
-
var NewTarget = _getPrototypeOf(this).constructor;
|
|
106
|
-
|
|
107
|
-
result = Reflect.construct(Super, arguments, NewTarget);
|
|
108
|
-
} else {
|
|
109
|
-
result = Super.apply(this, arguments);
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
return _possibleConstructorReturn(this, result);
|
|
113
|
-
};
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
/*! *****************************************************************************
|
|
117
|
-
Copyright (c) Microsoft Corporation.
|
|
118
|
-
|
|
119
|
-
Permission to use, copy, modify, and/or distribute this software for any
|
|
120
|
-
purpose with or without fee is hereby granted.
|
|
121
|
-
|
|
122
|
-
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
123
|
-
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
124
|
-
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
125
|
-
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
126
|
-
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
127
|
-
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
128
|
-
PERFORMANCE OF THIS SOFTWARE.
|
|
129
|
-
***************************************************************************** */
|
|
130
|
-
|
|
131
|
-
function __decorate(decorators, target, key, desc) {
|
|
132
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
133
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
134
|
-
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;
|
|
135
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
function __metadata(metadataKey, metadataValue) {
|
|
139
|
-
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(metadataKey, metadataValue);
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
var isBrowser = typeof window !== 'undefined' && typeof window.document !== 'undefined';
|
|
143
|
-
|
|
144
|
-
var PX_SUFFIX = 'px';
|
|
145
|
-
function setDOMSize($el, width, height) {
|
|
146
|
-
if (isBrowser) {
|
|
147
|
-
$el.style.width = width + PX_SUFFIX;
|
|
148
|
-
$el.style.height = height + PX_SUFFIX;
|
|
149
|
-
}
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
var Canvas2DContextService = /*#__PURE__*/function () {
|
|
153
|
-
function Canvas2DContextService() {
|
|
154
|
-
_classCallCheck(this, Canvas2DContextService);
|
|
155
|
-
|
|
156
|
-
this.$container = void 0;
|
|
157
|
-
this.$canvas = void 0;
|
|
158
|
-
this.dpr = void 0;
|
|
159
|
-
this.context = void 0;
|
|
160
|
-
this.canvasConfig = void 0;
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
_createClass(Canvas2DContextService, [{
|
|
164
|
-
key: "init",
|
|
165
|
-
value: function init() {
|
|
166
|
-
var _this$canvasConfig = this.canvasConfig,
|
|
167
|
-
container = _this$canvasConfig.container,
|
|
168
|
-
width = _this$canvasConfig.width,
|
|
169
|
-
height = _this$canvasConfig.height; // create container
|
|
170
|
-
|
|
171
|
-
this.$container = util.isString(container) ? document.getElementById(container) : container;
|
|
172
|
-
|
|
173
|
-
if (this.$container) {
|
|
174
|
-
// create canvas
|
|
175
|
-
var $canvas = document.createElement('canvas');
|
|
176
|
-
this.context = $canvas.getContext('2d');
|
|
177
|
-
this.$container.appendChild($canvas);
|
|
178
|
-
|
|
179
|
-
if (!this.$container.style.position) {
|
|
180
|
-
this.$container.style.position = 'relative';
|
|
181
|
-
}
|
|
182
|
-
|
|
183
|
-
this.$canvas = $canvas;
|
|
184
|
-
var dpr = window.devicePixelRatio || 1;
|
|
185
|
-
dpr = dpr >= 1 ? Math.ceil(dpr) : 1;
|
|
186
|
-
this.dpr = dpr;
|
|
187
|
-
this.resize(width, height);
|
|
188
|
-
}
|
|
189
|
-
}
|
|
190
|
-
}, {
|
|
191
|
-
key: "getContext",
|
|
192
|
-
value: function getContext() {
|
|
193
|
-
return this.context;
|
|
194
|
-
}
|
|
195
|
-
}, {
|
|
196
|
-
key: "getDomElement",
|
|
197
|
-
value: function getDomElement() {
|
|
198
|
-
return this.$canvas;
|
|
199
|
-
}
|
|
200
|
-
}, {
|
|
201
|
-
key: "getDPR",
|
|
202
|
-
value: function getDPR() {
|
|
203
|
-
return this.dpr;
|
|
204
|
-
}
|
|
205
|
-
}, {
|
|
206
|
-
key: "getBoundingClientRect",
|
|
207
|
-
value: function getBoundingClientRect() {
|
|
208
|
-
var _this$$canvas;
|
|
209
|
-
|
|
210
|
-
return (_this$$canvas = this.$canvas) === null || _this$$canvas === void 0 ? void 0 : _this$$canvas.getBoundingClientRect();
|
|
211
|
-
}
|
|
212
|
-
}, {
|
|
213
|
-
key: "destroy",
|
|
214
|
-
value: function destroy() {
|
|
215
|
-
if (this.$container && this.$canvas && this.$canvas.parentNode) {
|
|
216
|
-
// destroy context
|
|
217
|
-
this.$container.removeChild(this.$canvas);
|
|
218
|
-
}
|
|
219
|
-
}
|
|
220
|
-
}, {
|
|
221
|
-
key: "resize",
|
|
222
|
-
value: function resize(width, height) {
|
|
223
|
-
if (this.$canvas) {
|
|
224
|
-
// set canvas width & height
|
|
225
|
-
this.$canvas.width = this.dpr * width;
|
|
226
|
-
this.$canvas.height = this.dpr * height; // set CSS style width & height
|
|
227
|
-
|
|
228
|
-
setDOMSize(this.$canvas, width, height);
|
|
229
|
-
}
|
|
230
|
-
}
|
|
231
|
-
}, {
|
|
232
|
-
key: "applyCursorStyle",
|
|
233
|
-
value: function applyCursorStyle(cursor) {
|
|
234
|
-
if (this.$container) {
|
|
235
|
-
this.$container.style.cursor = cursor;
|
|
236
|
-
}
|
|
237
|
-
}
|
|
238
|
-
}]);
|
|
239
|
-
|
|
240
|
-
return Canvas2DContextService;
|
|
241
|
-
}();
|
|
242
|
-
|
|
243
|
-
__decorate([manaSyringe.inject(g.CanvasConfig), __metadata("design:type", Object)], Canvas2DContextService.prototype, "canvasConfig", void 0);
|
|
244
|
-
|
|
245
|
-
Canvas2DContextService = __decorate([manaSyringe.singleton({
|
|
246
|
-
token: g.ContextService
|
|
247
|
-
})], Canvas2DContextService);
|
|
248
|
-
|
|
249
|
-
var containerModule = manaSyringe.Module(function (register) {
|
|
250
|
-
/**
|
|
251
|
-
* implements ContextService
|
|
252
|
-
*/
|
|
253
|
-
register(Canvas2DContextService);
|
|
254
|
-
});
|
|
255
|
-
var ContextRegisterPlugin = /*#__PURE__*/function () {
|
|
256
|
-
function ContextRegisterPlugin() {
|
|
257
|
-
_classCallCheck(this, ContextRegisterPlugin);
|
|
258
|
-
}
|
|
259
|
-
|
|
260
|
-
_createClass(ContextRegisterPlugin, [{
|
|
261
|
-
key: "init",
|
|
262
|
-
value: function init(container) {
|
|
263
|
-
container.load(containerModule);
|
|
264
|
-
}
|
|
265
|
-
}, {
|
|
266
|
-
key: "destroy",
|
|
267
|
-
value: function destroy(container) {// @ts-ignore
|
|
268
|
-
// container.container.unload(containerModule);
|
|
269
|
-
// container.remove(Canvas2DContextService);
|
|
270
|
-
}
|
|
271
|
-
}]);
|
|
272
|
-
|
|
273
|
-
return ContextRegisterPlugin;
|
|
274
|
-
}();
|
|
275
|
-
|
|
276
|
-
var Renderer = /*#__PURE__*/function (_AbstractRenderer) {
|
|
277
|
-
_inherits(Renderer, _AbstractRenderer);
|
|
278
|
-
|
|
279
|
-
var _super = _createSuper(Renderer);
|
|
280
|
-
|
|
281
|
-
function Renderer(config) {
|
|
282
|
-
var _this;
|
|
283
|
-
|
|
284
|
-
_classCallCheck(this, Renderer);
|
|
285
|
-
|
|
286
|
-
_this = _super.call(this, config); // register Canvas2DContext
|
|
287
|
-
|
|
288
|
-
_this.registerPlugin(new ContextRegisterPlugin()); // enable rendering with Canvas2D API
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
_this.registerPlugin(new gPluginCanvasRenderer.Plugin());
|
|
292
|
-
|
|
293
|
-
_this.registerPlugin(new gPluginDomInteraction.Plugin()); // enable picking with Canvas2D API
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
_this.registerPlugin(new gPluginCanvasPicker.Plugin()); // render HTML component
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
_this.registerPlugin(new gPluginHtmlRenderer.Plugin());
|
|
300
|
-
|
|
301
|
-
return _this;
|
|
302
|
-
}
|
|
303
|
-
|
|
304
|
-
return Renderer;
|
|
305
|
-
}(g.AbstractRenderer);
|
|
306
|
-
|
|
307
|
-
exports.Renderer = Renderer;
|
package/dist/utils/browser.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const isBrowser: boolean;
|
package/dist/utils/dom.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function setDOMSize($el: HTMLElement, width: number, height: number): void;
|