@antv/g-webgpu 1.1.3 → 1.1.6
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/WebGLContextService.d.ts +2 -3
- package/dist/WebGLContextService.d.ts.map +1 -1
- package/dist/index.esm.js +193 -82
- package/dist/index.js +193 -82
- package/dist/index.umd.js +7646 -6520
- package/dist/index.umd.min.js +5 -5
- package/package.json +6 -6
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
/// <reference types="@webgpu/types" />
|
|
1
|
+
import type { CanvasLike } from '@antv/g';
|
|
3
2
|
import { ContextService } from '@antv/g';
|
|
4
3
|
export declare class WebGLContextService implements ContextService<WebGLRenderingContext> {
|
|
5
4
|
private $container;
|
|
@@ -8,7 +7,7 @@ export declare class WebGLContextService implements ContextService<WebGLRenderin
|
|
|
8
7
|
private context;
|
|
9
8
|
private canvasConfig;
|
|
10
9
|
init(): void;
|
|
11
|
-
getDomElement():
|
|
10
|
+
getDomElement(): CanvasLike;
|
|
12
11
|
getContext(): WebGLRenderingContext;
|
|
13
12
|
getBoundingClientRect(): DOMRect;
|
|
14
13
|
destroy(): void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"WebGLContextService.d.ts","sourceRoot":"","sources":["../src/WebGLContextService.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"WebGLContextService.d.ts","sourceRoot":"","sources":["../src/WebGLContextService.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAC1C,OAAO,EAAgB,cAAc,EAAmC,MAAM,SAAS,CAAC;AAGxF,qBACa,mBAAoB,YAAW,cAAc,CAAC,qBAAqB,CAAC;IAC/E,OAAO,CAAC,UAAU,CAAqB;IACvC,OAAO,CAAC,OAAO,CAAoB;IACnC,OAAO,CAAC,GAAG,CAAS;IACpB,OAAO,CAAC,OAAO,CAA+B;IAG9C,OAAO,CAAC,YAAY,CAAe;IAEnC,IAAI;IAgCJ,aAAa;IAIb,UAAU;IAIV,qBAAqB;IAMrB,OAAO;IAQP,MAAM,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM;IAapC,MAAM;IAIN,gBAAgB,CAAC,MAAM,EAAE,MAAM;CAKhC"}
|
package/dist/index.esm.js
CHANGED
|
@@ -11,11 +11,54 @@ export { WebGPUDevice };
|
|
|
11
11
|
import { Plugin as Plugin$3 } from '@antv/g-plugin-html-renderer';
|
|
12
12
|
import { inject, singleton, Module } from 'mana-syringe';
|
|
13
13
|
|
|
14
|
-
function
|
|
15
|
-
|
|
16
|
-
|
|
14
|
+
function _classCallCheck(instance, Constructor) {
|
|
15
|
+
if (!(instance instanceof Constructor)) {
|
|
16
|
+
throw new TypeError("Cannot call a class as a function");
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
function _defineProperties(target, props) {
|
|
21
|
+
for (var i = 0; i < props.length; i++) {
|
|
22
|
+
var descriptor = props[i];
|
|
23
|
+
descriptor.enumerable = descriptor.enumerable || false;
|
|
24
|
+
descriptor.configurable = true;
|
|
25
|
+
if ("value" in descriptor) descriptor.writable = true;
|
|
26
|
+
Object.defineProperty(target, descriptor.key, descriptor);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
function _createClass(Constructor, protoProps, staticProps) {
|
|
31
|
+
if (protoProps) _defineProperties(Constructor.prototype, protoProps);
|
|
32
|
+
if (staticProps) _defineProperties(Constructor, staticProps);
|
|
33
|
+
Object.defineProperty(Constructor, "prototype", {
|
|
34
|
+
writable: false
|
|
35
|
+
});
|
|
36
|
+
return Constructor;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
function _inherits(subClass, superClass) {
|
|
40
|
+
if (typeof superClass !== "function" && superClass !== null) {
|
|
41
|
+
throw new TypeError("Super expression must either be null or a function");
|
|
42
|
+
}
|
|
17
43
|
|
|
18
|
-
|
|
44
|
+
subClass.prototype = Object.create(superClass && superClass.prototype, {
|
|
45
|
+
constructor: {
|
|
46
|
+
value: subClass,
|
|
47
|
+
writable: true,
|
|
48
|
+
configurable: true
|
|
49
|
+
}
|
|
50
|
+
});
|
|
51
|
+
Object.defineProperty(subClass, "prototype", {
|
|
52
|
+
writable: false
|
|
53
|
+
});
|
|
54
|
+
if (superClass) _setPrototypeOf(subClass, superClass);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
function _getPrototypeOf(o) {
|
|
58
|
+
_getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) {
|
|
59
|
+
return o.__proto__ || Object.getPrototypeOf(o);
|
|
60
|
+
};
|
|
61
|
+
return _getPrototypeOf(o);
|
|
19
62
|
}
|
|
20
63
|
|
|
21
64
|
function _setPrototypeOf(o, p) {
|
|
@@ -27,6 +70,56 @@ function _setPrototypeOf(o, p) {
|
|
|
27
70
|
return _setPrototypeOf(o, p);
|
|
28
71
|
}
|
|
29
72
|
|
|
73
|
+
function _isNativeReflectConstruct() {
|
|
74
|
+
if (typeof Reflect === "undefined" || !Reflect.construct) return false;
|
|
75
|
+
if (Reflect.construct.sham) return false;
|
|
76
|
+
if (typeof Proxy === "function") return true;
|
|
77
|
+
|
|
78
|
+
try {
|
|
79
|
+
Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {}));
|
|
80
|
+
return true;
|
|
81
|
+
} catch (e) {
|
|
82
|
+
return false;
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
function _assertThisInitialized(self) {
|
|
87
|
+
if (self === void 0) {
|
|
88
|
+
throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
return self;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
function _possibleConstructorReturn(self, call) {
|
|
95
|
+
if (call && (typeof call === "object" || typeof call === "function")) {
|
|
96
|
+
return call;
|
|
97
|
+
} else if (call !== void 0) {
|
|
98
|
+
throw new TypeError("Derived constructors may only return object or undefined");
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
return _assertThisInitialized(self);
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
function _createSuper(Derived) {
|
|
105
|
+
var hasNativeReflectConstruct = _isNativeReflectConstruct();
|
|
106
|
+
|
|
107
|
+
return function _createSuperInternal() {
|
|
108
|
+
var Super = _getPrototypeOf(Derived),
|
|
109
|
+
result;
|
|
110
|
+
|
|
111
|
+
if (hasNativeReflectConstruct) {
|
|
112
|
+
var NewTarget = _getPrototypeOf(this).constructor;
|
|
113
|
+
|
|
114
|
+
result = Reflect.construct(Super, arguments, NewTarget);
|
|
115
|
+
} else {
|
|
116
|
+
result = Super.apply(this, arguments);
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
return _possibleConstructorReturn(this, result);
|
|
120
|
+
};
|
|
121
|
+
}
|
|
122
|
+
|
|
30
123
|
/******************************************************************************
|
|
31
124
|
Copyright (c) Microsoft Corporation.
|
|
32
125
|
|
|
@@ -55,6 +148,8 @@ function __metadata(metadataKey, metadataValue) {
|
|
|
55
148
|
|
|
56
149
|
var WebGLContextService = /*#__PURE__*/function () {
|
|
57
150
|
function WebGLContextService() {
|
|
151
|
+
_classCallCheck(this, WebGLContextService);
|
|
152
|
+
|
|
58
153
|
this.$container = void 0;
|
|
59
154
|
this.$canvas = void 0;
|
|
60
155
|
this.dpr = void 0;
|
|
@@ -62,88 +157,96 @@ var WebGLContextService = /*#__PURE__*/function () {
|
|
|
62
157
|
this.canvasConfig = void 0;
|
|
63
158
|
}
|
|
64
159
|
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
160
|
+
_createClass(WebGLContextService, [{
|
|
161
|
+
key: "init",
|
|
162
|
+
value: function init() {
|
|
163
|
+
var _this$canvasConfig = this.canvasConfig,
|
|
164
|
+
container = _this$canvasConfig.container,
|
|
165
|
+
canvas = _this$canvasConfig.canvas,
|
|
166
|
+
devicePixelRatio = _this$canvasConfig.devicePixelRatio;
|
|
72
167
|
|
|
73
|
-
|
|
74
|
-
|
|
168
|
+
if (canvas) {
|
|
169
|
+
this.$canvas = canvas;
|
|
75
170
|
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
this.$container = canvas.parentElement;
|
|
81
|
-
this.canvasConfig.container = this.$container;
|
|
82
|
-
} else if (container) {
|
|
83
|
-
// create container
|
|
84
|
-
this.$container = isString(container) ? document.getElementById(container) : container;
|
|
85
|
-
|
|
86
|
-
if (this.$container) {
|
|
87
|
-
// create canvas
|
|
88
|
-
var $canvas = document.createElement('canvas');
|
|
89
|
-
this.$container.appendChild($canvas);
|
|
90
|
-
|
|
91
|
-
if (!this.$container.style.position) {
|
|
92
|
-
this.$container.style.position = 'relative';
|
|
171
|
+
if (container && canvas.parentElement !== container) {
|
|
172
|
+
container.appendChild(canvas);
|
|
93
173
|
}
|
|
94
174
|
|
|
95
|
-
this.$
|
|
96
|
-
|
|
97
|
-
|
|
175
|
+
this.$container = canvas.parentElement;
|
|
176
|
+
this.canvasConfig.container = this.$container;
|
|
177
|
+
} else if (container) {
|
|
178
|
+
// create container
|
|
179
|
+
this.$container = isString(container) ? document.getElementById(container) : container;
|
|
98
180
|
|
|
181
|
+
if (this.$container) {
|
|
182
|
+
// create canvas
|
|
183
|
+
var $canvas = document.createElement('canvas');
|
|
184
|
+
this.$container.appendChild($canvas);
|
|
99
185
|
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
};
|
|
186
|
+
if (!this.$container.style.position) {
|
|
187
|
+
this.$container.style.position = 'relative';
|
|
188
|
+
}
|
|
104
189
|
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
190
|
+
this.$canvas = $canvas;
|
|
191
|
+
}
|
|
192
|
+
} // use user-defined dpr first
|
|
108
193
|
|
|
109
|
-
_proto.getContext = function getContext() {
|
|
110
|
-
return this.context;
|
|
111
|
-
};
|
|
112
194
|
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
195
|
+
var dpr = devicePixelRatio || isBrowser && window.devicePixelRatio || 1;
|
|
196
|
+
dpr = dpr >= 1 ? Math.ceil(dpr) : 1;
|
|
197
|
+
this.dpr = dpr;
|
|
116
198
|
}
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
199
|
+
}, {
|
|
200
|
+
key: "getDomElement",
|
|
201
|
+
value: function getDomElement() {
|
|
202
|
+
return this.$canvas;
|
|
203
|
+
}
|
|
204
|
+
}, {
|
|
205
|
+
key: "getContext",
|
|
206
|
+
value: function getContext() {
|
|
207
|
+
return this.context;
|
|
208
|
+
}
|
|
209
|
+
}, {
|
|
210
|
+
key: "getBoundingClientRect",
|
|
211
|
+
value: function getBoundingClientRect() {
|
|
212
|
+
if (this.$canvas.getBoundingClientRect) {
|
|
213
|
+
return this.$canvas.getBoundingClientRect();
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
}, {
|
|
217
|
+
key: "destroy",
|
|
218
|
+
value: function destroy() {
|
|
122
219
|
// @ts-ignore
|
|
123
|
-
this.$container
|
|
220
|
+
if (this.$container && this.$canvas && this.$canvas.parentNode) {
|
|
221
|
+
// @ts-ignore
|
|
222
|
+
this.$container.removeChild(this.$canvas);
|
|
223
|
+
}
|
|
124
224
|
}
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
225
|
+
}, {
|
|
226
|
+
key: "resize",
|
|
227
|
+
value: function resize(width, height) {
|
|
228
|
+
if (this.$canvas) {
|
|
229
|
+
var dpr = this.getDPR(); // set canvas width & height
|
|
130
230
|
|
|
131
|
-
|
|
132
|
-
|
|
231
|
+
this.$canvas.width = dpr * width;
|
|
232
|
+
this.$canvas.height = dpr * height; // set CSS style width & height
|
|
133
233
|
|
|
134
|
-
|
|
234
|
+
setDOMSize(this.$canvas, width, height);
|
|
235
|
+
}
|
|
135
236
|
}
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
};
|
|
141
|
-
|
|
142
|
-
_proto.applyCursorStyle = function applyCursorStyle(cursor) {
|
|
143
|
-
if (this.$container && this.$container.style) {
|
|
144
|
-
this.$container.style.cursor = cursor;
|
|
237
|
+
}, {
|
|
238
|
+
key: "getDPR",
|
|
239
|
+
value: function getDPR() {
|
|
240
|
+
return this.dpr;
|
|
145
241
|
}
|
|
146
|
-
}
|
|
242
|
+
}, {
|
|
243
|
+
key: "applyCursorStyle",
|
|
244
|
+
value: function applyCursorStyle(cursor) {
|
|
245
|
+
if (this.$container && this.$container.style) {
|
|
246
|
+
this.$container.style.cursor = cursor;
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
}]);
|
|
147
250
|
|
|
148
251
|
return WebGLContextService;
|
|
149
252
|
}();
|
|
@@ -162,29 +265,37 @@ var containerModule = Module(function (register) {
|
|
|
162
265
|
});
|
|
163
266
|
var ContextRegisterPlugin = /*#__PURE__*/function () {
|
|
164
267
|
function ContextRegisterPlugin() {
|
|
268
|
+
_classCallCheck(this, ContextRegisterPlugin);
|
|
269
|
+
|
|
165
270
|
this.name = 'webgpu-context-register';
|
|
166
271
|
}
|
|
167
272
|
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
container
|
|
176
|
-
|
|
273
|
+
_createClass(ContextRegisterPlugin, [{
|
|
274
|
+
key: "init",
|
|
275
|
+
value: function init(container) {
|
|
276
|
+
container.load(containerModule, true);
|
|
277
|
+
}
|
|
278
|
+
}, {
|
|
279
|
+
key: "destroy",
|
|
280
|
+
value: function destroy(container) {
|
|
281
|
+
container.unload(containerModule);
|
|
282
|
+
}
|
|
283
|
+
}]);
|
|
177
284
|
|
|
178
285
|
return ContextRegisterPlugin;
|
|
179
286
|
}();
|
|
180
287
|
|
|
181
288
|
var Renderer = /*#__PURE__*/function (_AbstractRenderer) {
|
|
182
|
-
|
|
289
|
+
_inherits(Renderer, _AbstractRenderer);
|
|
290
|
+
|
|
291
|
+
var _super = _createSuper(Renderer);
|
|
183
292
|
|
|
184
293
|
function Renderer(config) {
|
|
185
294
|
var _this;
|
|
186
295
|
|
|
187
|
-
|
|
296
|
+
_classCallCheck(this, Renderer);
|
|
297
|
+
|
|
298
|
+
_this = _super.call(this, config);
|
|
188
299
|
|
|
189
300
|
_this.registerPlugin(new ContextRegisterPlugin());
|
|
190
301
|
|
|
@@ -199,7 +310,7 @@ var Renderer = /*#__PURE__*/function (_AbstractRenderer) {
|
|
|
199
310
|
return _this;
|
|
200
311
|
}
|
|
201
312
|
|
|
202
|
-
return Renderer;
|
|
313
|
+
return _createClass(Renderer);
|
|
203
314
|
}(AbstractRenderer);
|
|
204
315
|
|
|
205
316
|
export { Renderer };
|