@antv/g-webgpu 1.1.5 → 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/index.js CHANGED
@@ -33,11 +33,54 @@ var DomInteraction__namespace = /*#__PURE__*/_interopNamespace(DomInteraction);
33
33
  var DeviceRenderer__namespace = /*#__PURE__*/_interopNamespace(DeviceRenderer);
34
34
  var WebGPUDevice__namespace = /*#__PURE__*/_interopNamespace(WebGPUDevice);
35
35
 
36
- function _inheritsLoose(subClass, superClass) {
37
- subClass.prototype = Object.create(superClass.prototype);
38
- subClass.prototype.constructor = subClass;
36
+ function _classCallCheck(instance, Constructor) {
37
+ if (!(instance instanceof Constructor)) {
38
+ throw new TypeError("Cannot call a class as a function");
39
+ }
40
+ }
41
+
42
+ function _defineProperties(target, props) {
43
+ for (var i = 0; i < props.length; i++) {
44
+ var descriptor = props[i];
45
+ descriptor.enumerable = descriptor.enumerable || false;
46
+ descriptor.configurable = true;
47
+ if ("value" in descriptor) descriptor.writable = true;
48
+ Object.defineProperty(target, descriptor.key, descriptor);
49
+ }
50
+ }
51
+
52
+ function _createClass(Constructor, protoProps, staticProps) {
53
+ if (protoProps) _defineProperties(Constructor.prototype, protoProps);
54
+ if (staticProps) _defineProperties(Constructor, staticProps);
55
+ Object.defineProperty(Constructor, "prototype", {
56
+ writable: false
57
+ });
58
+ return Constructor;
59
+ }
60
+
61
+ function _inherits(subClass, superClass) {
62
+ if (typeof superClass !== "function" && superClass !== null) {
63
+ throw new TypeError("Super expression must either be null or a function");
64
+ }
39
65
 
40
- _setPrototypeOf(subClass, superClass);
66
+ subClass.prototype = Object.create(superClass && superClass.prototype, {
67
+ constructor: {
68
+ value: subClass,
69
+ writable: true,
70
+ configurable: true
71
+ }
72
+ });
73
+ Object.defineProperty(subClass, "prototype", {
74
+ writable: false
75
+ });
76
+ if (superClass) _setPrototypeOf(subClass, superClass);
77
+ }
78
+
79
+ function _getPrototypeOf(o) {
80
+ _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) {
81
+ return o.__proto__ || Object.getPrototypeOf(o);
82
+ };
83
+ return _getPrototypeOf(o);
41
84
  }
42
85
 
43
86
  function _setPrototypeOf(o, p) {
@@ -49,6 +92,56 @@ function _setPrototypeOf(o, p) {
49
92
  return _setPrototypeOf(o, p);
50
93
  }
51
94
 
95
+ function _isNativeReflectConstruct() {
96
+ if (typeof Reflect === "undefined" || !Reflect.construct) return false;
97
+ if (Reflect.construct.sham) return false;
98
+ if (typeof Proxy === "function") return true;
99
+
100
+ try {
101
+ Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {}));
102
+ return true;
103
+ } catch (e) {
104
+ return false;
105
+ }
106
+ }
107
+
108
+ function _assertThisInitialized(self) {
109
+ if (self === void 0) {
110
+ throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
111
+ }
112
+
113
+ return self;
114
+ }
115
+
116
+ function _possibleConstructorReturn(self, call) {
117
+ if (call && (typeof call === "object" || typeof call === "function")) {
118
+ return call;
119
+ } else if (call !== void 0) {
120
+ throw new TypeError("Derived constructors may only return object or undefined");
121
+ }
122
+
123
+ return _assertThisInitialized(self);
124
+ }
125
+
126
+ function _createSuper(Derived) {
127
+ var hasNativeReflectConstruct = _isNativeReflectConstruct();
128
+
129
+ return function _createSuperInternal() {
130
+ var Super = _getPrototypeOf(Derived),
131
+ result;
132
+
133
+ if (hasNativeReflectConstruct) {
134
+ var NewTarget = _getPrototypeOf(this).constructor;
135
+
136
+ result = Reflect.construct(Super, arguments, NewTarget);
137
+ } else {
138
+ result = Super.apply(this, arguments);
139
+ }
140
+
141
+ return _possibleConstructorReturn(this, result);
142
+ };
143
+ }
144
+
52
145
  /******************************************************************************
53
146
  Copyright (c) Microsoft Corporation.
54
147
 
@@ -77,6 +170,8 @@ function __metadata(metadataKey, metadataValue) {
77
170
 
78
171
  var WebGLContextService = /*#__PURE__*/function () {
79
172
  function WebGLContextService() {
173
+ _classCallCheck(this, WebGLContextService);
174
+
80
175
  this.$container = void 0;
81
176
  this.$canvas = void 0;
82
177
  this.dpr = void 0;
@@ -84,88 +179,96 @@ var WebGLContextService = /*#__PURE__*/function () {
84
179
  this.canvasConfig = void 0;
85
180
  }
86
181
 
87
- var _proto = WebGLContextService.prototype;
182
+ _createClass(WebGLContextService, [{
183
+ key: "init",
184
+ value: function init() {
185
+ var _this$canvasConfig = this.canvasConfig,
186
+ container = _this$canvasConfig.container,
187
+ canvas = _this$canvasConfig.canvas,
188
+ devicePixelRatio = _this$canvasConfig.devicePixelRatio;
88
189
 
89
- _proto.init = function init() {
90
- var _this$canvasConfig = this.canvasConfig,
91
- container = _this$canvasConfig.container,
92
- canvas = _this$canvasConfig.canvas,
93
- devicePixelRatio = _this$canvasConfig.devicePixelRatio;
190
+ if (canvas) {
191
+ this.$canvas = canvas;
94
192
 
95
- if (canvas) {
96
- this.$canvas = canvas;
97
-
98
- if (container && canvas.parentElement !== container) {
99
- container.appendChild(canvas);
100
- }
101
-
102
- this.$container = canvas.parentElement;
103
- this.canvasConfig.container = this.$container;
104
- } else if (container) {
105
- // create container
106
- this.$container = g.isString(container) ? document.getElementById(container) : container;
107
-
108
- if (this.$container) {
109
- // create canvas
110
- var $canvas = document.createElement('canvas');
111
- this.$container.appendChild($canvas);
112
-
113
- if (!this.$container.style.position) {
114
- this.$container.style.position = 'relative';
193
+ if (container && canvas.parentElement !== container) {
194
+ container.appendChild(canvas);
115
195
  }
116
196
 
117
- this.$canvas = $canvas;
118
- }
119
- } // use user-defined dpr first
197
+ this.$container = canvas.parentElement;
198
+ this.canvasConfig.container = this.$container;
199
+ } else if (container) {
200
+ // create container
201
+ this.$container = g.isString(container) ? document.getElementById(container) : container;
120
202
 
203
+ if (this.$container) {
204
+ // create canvas
205
+ var $canvas = document.createElement('canvas');
206
+ this.$container.appendChild($canvas);
121
207
 
122
- var dpr = devicePixelRatio || g.isBrowser && window.devicePixelRatio || 1;
123
- dpr = dpr >= 1 ? Math.ceil(dpr) : 1;
124
- this.dpr = dpr;
125
- };
208
+ if (!this.$container.style.position) {
209
+ this.$container.style.position = 'relative';
210
+ }
126
211
 
127
- _proto.getDomElement = function getDomElement() {
128
- return this.$canvas;
129
- };
212
+ this.$canvas = $canvas;
213
+ }
214
+ } // use user-defined dpr first
130
215
 
131
- _proto.getContext = function getContext() {
132
- return this.context;
133
- };
134
216
 
135
- _proto.getBoundingClientRect = function getBoundingClientRect() {
136
- if (this.$canvas.getBoundingClientRect) {
137
- return this.$canvas.getBoundingClientRect();
217
+ var dpr = devicePixelRatio || g.isBrowser && window.devicePixelRatio || 1;
218
+ dpr = dpr >= 1 ? Math.ceil(dpr) : 1;
219
+ this.dpr = dpr;
138
220
  }
139
- };
140
-
141
- _proto.destroy = function destroy() {
142
- // @ts-ignore
143
- if (this.$container && this.$canvas && this.$canvas.parentNode) {
221
+ }, {
222
+ key: "getDomElement",
223
+ value: function getDomElement() {
224
+ return this.$canvas;
225
+ }
226
+ }, {
227
+ key: "getContext",
228
+ value: function getContext() {
229
+ return this.context;
230
+ }
231
+ }, {
232
+ key: "getBoundingClientRect",
233
+ value: function getBoundingClientRect() {
234
+ if (this.$canvas.getBoundingClientRect) {
235
+ return this.$canvas.getBoundingClientRect();
236
+ }
237
+ }
238
+ }, {
239
+ key: "destroy",
240
+ value: function destroy() {
144
241
  // @ts-ignore
145
- this.$container.removeChild(this.$canvas);
242
+ if (this.$container && this.$canvas && this.$canvas.parentNode) {
243
+ // @ts-ignore
244
+ this.$container.removeChild(this.$canvas);
245
+ }
146
246
  }
147
- };
148
-
149
- _proto.resize = function resize(width, height) {
150
- if (this.$canvas) {
151
- var dpr = this.getDPR(); // set canvas width & height
247
+ }, {
248
+ key: "resize",
249
+ value: function resize(width, height) {
250
+ if (this.$canvas) {
251
+ var dpr = this.getDPR(); // set canvas width & height
152
252
 
153
- this.$canvas.width = dpr * width;
154
- this.$canvas.height = dpr * height; // set CSS style width & height
253
+ this.$canvas.width = dpr * width;
254
+ this.$canvas.height = dpr * height; // set CSS style width & height
155
255
 
156
- g.setDOMSize(this.$canvas, width, height);
256
+ g.setDOMSize(this.$canvas, width, height);
257
+ }
157
258
  }
158
- };
159
-
160
- _proto.getDPR = function getDPR() {
161
- return this.dpr;
162
- };
163
-
164
- _proto.applyCursorStyle = function applyCursorStyle(cursor) {
165
- if (this.$container && this.$container.style) {
166
- this.$container.style.cursor = cursor;
259
+ }, {
260
+ key: "getDPR",
261
+ value: function getDPR() {
262
+ return this.dpr;
167
263
  }
168
- };
264
+ }, {
265
+ key: "applyCursorStyle",
266
+ value: function applyCursorStyle(cursor) {
267
+ if (this.$container && this.$container.style) {
268
+ this.$container.style.cursor = cursor;
269
+ }
270
+ }
271
+ }]);
169
272
 
170
273
  return WebGLContextService;
171
274
  }();
@@ -184,29 +287,37 @@ var containerModule = manaSyringe.Module(function (register) {
184
287
  });
185
288
  var ContextRegisterPlugin = /*#__PURE__*/function () {
186
289
  function ContextRegisterPlugin() {
290
+ _classCallCheck(this, ContextRegisterPlugin);
291
+
187
292
  this.name = 'webgpu-context-register';
188
293
  }
189
294
 
190
- var _proto = ContextRegisterPlugin.prototype;
191
-
192
- _proto.init = function init(container) {
193
- container.load(containerModule, true);
194
- };
195
-
196
- _proto.destroy = function destroy(container) {
197
- container.unload(containerModule);
198
- };
295
+ _createClass(ContextRegisterPlugin, [{
296
+ key: "init",
297
+ value: function init(container) {
298
+ container.load(containerModule, true);
299
+ }
300
+ }, {
301
+ key: "destroy",
302
+ value: function destroy(container) {
303
+ container.unload(containerModule);
304
+ }
305
+ }]);
199
306
 
200
307
  return ContextRegisterPlugin;
201
308
  }();
202
309
 
203
310
  var Renderer = /*#__PURE__*/function (_AbstractRenderer) {
204
- _inheritsLoose(Renderer, _AbstractRenderer);
311
+ _inherits(Renderer, _AbstractRenderer);
312
+
313
+ var _super = _createSuper(Renderer);
205
314
 
206
315
  function Renderer(config) {
207
316
  var _this;
208
317
 
209
- _this = _AbstractRenderer.call(this, config) || this;
318
+ _classCallCheck(this, Renderer);
319
+
320
+ _this = _super.call(this, config);
210
321
 
211
322
  _this.registerPlugin(new ContextRegisterPlugin());
212
323
 
@@ -221,7 +332,7 @@ var Renderer = /*#__PURE__*/function (_AbstractRenderer) {
221
332
  return _this;
222
333
  }
223
334
 
224
- return Renderer;
335
+ return _createClass(Renderer);
225
336
  }(g.AbstractRenderer);
226
337
 
227
338
  exports.DomInteraction = DomInteraction__namespace;