@antv/g-webgpu 1.1.5 → 1.1.8-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.
package/dist/index.js CHANGED
@@ -33,6 +33,387 @@ 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 _regeneratorRuntime() {
37
+ /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */
38
+
39
+ _regeneratorRuntime = function () {
40
+ return exports;
41
+ };
42
+
43
+ var exports = {},
44
+ Op = Object.prototype,
45
+ hasOwn = Op.hasOwnProperty,
46
+ $Symbol = "function" == typeof Symbol ? Symbol : {},
47
+ iteratorSymbol = $Symbol.iterator || "@@iterator",
48
+ asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator",
49
+ toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag";
50
+
51
+ function define(obj, key, value) {
52
+ return Object.defineProperty(obj, key, {
53
+ value: value,
54
+ enumerable: !0,
55
+ configurable: !0,
56
+ writable: !0
57
+ }), obj[key];
58
+ }
59
+
60
+ try {
61
+ define({}, "");
62
+ } catch (err) {
63
+ define = function (obj, key, value) {
64
+ return obj[key] = value;
65
+ };
66
+ }
67
+
68
+ function wrap(innerFn, outerFn, self, tryLocsList) {
69
+ var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator,
70
+ generator = Object.create(protoGenerator.prototype),
71
+ context = new Context(tryLocsList || []);
72
+ return generator._invoke = function (innerFn, self, context) {
73
+ var state = "suspendedStart";
74
+ return function (method, arg) {
75
+ if ("executing" === state) throw new Error("Generator is already running");
76
+
77
+ if ("completed" === state) {
78
+ if ("throw" === method) throw arg;
79
+ return doneResult();
80
+ }
81
+
82
+ for (context.method = method, context.arg = arg;;) {
83
+ var delegate = context.delegate;
84
+
85
+ if (delegate) {
86
+ var delegateResult = maybeInvokeDelegate(delegate, context);
87
+
88
+ if (delegateResult) {
89
+ if (delegateResult === ContinueSentinel) continue;
90
+ return delegateResult;
91
+ }
92
+ }
93
+
94
+ if ("next" === context.method) context.sent = context._sent = context.arg;else if ("throw" === context.method) {
95
+ if ("suspendedStart" === state) throw state = "completed", context.arg;
96
+ context.dispatchException(context.arg);
97
+ } else "return" === context.method && context.abrupt("return", context.arg);
98
+ state = "executing";
99
+ var record = tryCatch(innerFn, self, context);
100
+
101
+ if ("normal" === record.type) {
102
+ if (state = context.done ? "completed" : "suspendedYield", record.arg === ContinueSentinel) continue;
103
+ return {
104
+ value: record.arg,
105
+ done: context.done
106
+ };
107
+ }
108
+
109
+ "throw" === record.type && (state = "completed", context.method = "throw", context.arg = record.arg);
110
+ }
111
+ };
112
+ }(innerFn, self, context), generator;
113
+ }
114
+
115
+ function tryCatch(fn, obj, arg) {
116
+ try {
117
+ return {
118
+ type: "normal",
119
+ arg: fn.call(obj, arg)
120
+ };
121
+ } catch (err) {
122
+ return {
123
+ type: "throw",
124
+ arg: err
125
+ };
126
+ }
127
+ }
128
+
129
+ exports.wrap = wrap;
130
+ var ContinueSentinel = {};
131
+
132
+ function Generator() {}
133
+
134
+ function GeneratorFunction() {}
135
+
136
+ function GeneratorFunctionPrototype() {}
137
+
138
+ var IteratorPrototype = {};
139
+ define(IteratorPrototype, iteratorSymbol, function () {
140
+ return this;
141
+ });
142
+ var getProto = Object.getPrototypeOf,
143
+ NativeIteratorPrototype = getProto && getProto(getProto(values([])));
144
+ NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol) && (IteratorPrototype = NativeIteratorPrototype);
145
+ var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype);
146
+
147
+ function defineIteratorMethods(prototype) {
148
+ ["next", "throw", "return"].forEach(function (method) {
149
+ define(prototype, method, function (arg) {
150
+ return this._invoke(method, arg);
151
+ });
152
+ });
153
+ }
154
+
155
+ function AsyncIterator(generator, PromiseImpl) {
156
+ function invoke(method, arg, resolve, reject) {
157
+ var record = tryCatch(generator[method], generator, arg);
158
+
159
+ if ("throw" !== record.type) {
160
+ var result = record.arg,
161
+ value = result.value;
162
+ return value && "object" == typeof value && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) {
163
+ invoke("next", value, resolve, reject);
164
+ }, function (err) {
165
+ invoke("throw", err, resolve, reject);
166
+ }) : PromiseImpl.resolve(value).then(function (unwrapped) {
167
+ result.value = unwrapped, resolve(result);
168
+ }, function (error) {
169
+ return invoke("throw", error, resolve, reject);
170
+ });
171
+ }
172
+
173
+ reject(record.arg);
174
+ }
175
+
176
+ var previousPromise;
177
+
178
+ this._invoke = function (method, arg) {
179
+ function callInvokeWithMethodAndArg() {
180
+ return new PromiseImpl(function (resolve, reject) {
181
+ invoke(method, arg, resolve, reject);
182
+ });
183
+ }
184
+
185
+ return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg();
186
+ };
187
+ }
188
+
189
+ function maybeInvokeDelegate(delegate, context) {
190
+ var method = delegate.iterator[context.method];
191
+
192
+ if (undefined === method) {
193
+ if (context.delegate = null, "throw" === context.method) {
194
+ if (delegate.iterator.return && (context.method = "return", context.arg = undefined, maybeInvokeDelegate(delegate, context), "throw" === context.method)) return ContinueSentinel;
195
+ context.method = "throw", context.arg = new TypeError("The iterator does not provide a 'throw' method");
196
+ }
197
+
198
+ return ContinueSentinel;
199
+ }
200
+
201
+ var record = tryCatch(method, delegate.iterator, context.arg);
202
+ if ("throw" === record.type) return context.method = "throw", context.arg = record.arg, context.delegate = null, ContinueSentinel;
203
+ var info = record.arg;
204
+ return info ? info.done ? (context[delegate.resultName] = info.value, context.next = delegate.nextLoc, "return" !== context.method && (context.method = "next", context.arg = undefined), context.delegate = null, ContinueSentinel) : info : (context.method = "throw", context.arg = new TypeError("iterator result is not an object"), context.delegate = null, ContinueSentinel);
205
+ }
206
+
207
+ function pushTryEntry(locs) {
208
+ var entry = {
209
+ tryLoc: locs[0]
210
+ };
211
+ 1 in locs && (entry.catchLoc = locs[1]), 2 in locs && (entry.finallyLoc = locs[2], entry.afterLoc = locs[3]), this.tryEntries.push(entry);
212
+ }
213
+
214
+ function resetTryEntry(entry) {
215
+ var record = entry.completion || {};
216
+ record.type = "normal", delete record.arg, entry.completion = record;
217
+ }
218
+
219
+ function Context(tryLocsList) {
220
+ this.tryEntries = [{
221
+ tryLoc: "root"
222
+ }], tryLocsList.forEach(pushTryEntry, this), this.reset(!0);
223
+ }
224
+
225
+ function values(iterable) {
226
+ if (iterable) {
227
+ var iteratorMethod = iterable[iteratorSymbol];
228
+ if (iteratorMethod) return iteratorMethod.call(iterable);
229
+ if ("function" == typeof iterable.next) return iterable;
230
+
231
+ if (!isNaN(iterable.length)) {
232
+ var i = -1,
233
+ next = function next() {
234
+ for (; ++i < iterable.length;) if (hasOwn.call(iterable, i)) return next.value = iterable[i], next.done = !1, next;
235
+
236
+ return next.value = undefined, next.done = !0, next;
237
+ };
238
+
239
+ return next.next = next;
240
+ }
241
+ }
242
+
243
+ return {
244
+ next: doneResult
245
+ };
246
+ }
247
+
248
+ function doneResult() {
249
+ return {
250
+ value: undefined,
251
+ done: !0
252
+ };
253
+ }
254
+
255
+ return GeneratorFunction.prototype = GeneratorFunctionPrototype, define(Gp, "constructor", GeneratorFunctionPrototype), define(GeneratorFunctionPrototype, "constructor", GeneratorFunction), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"), exports.isGeneratorFunction = function (genFun) {
256
+ var ctor = "function" == typeof genFun && genFun.constructor;
257
+ return !!ctor && (ctor === GeneratorFunction || "GeneratorFunction" === (ctor.displayName || ctor.name));
258
+ }, exports.mark = function (genFun) {
259
+ return Object.setPrototypeOf ? Object.setPrototypeOf(genFun, GeneratorFunctionPrototype) : (genFun.__proto__ = GeneratorFunctionPrototype, define(genFun, toStringTagSymbol, "GeneratorFunction")), genFun.prototype = Object.create(Gp), genFun;
260
+ }, exports.awrap = function (arg) {
261
+ return {
262
+ __await: arg
263
+ };
264
+ }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, asyncIteratorSymbol, function () {
265
+ return this;
266
+ }), exports.AsyncIterator = AsyncIterator, exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) {
267
+ void 0 === PromiseImpl && (PromiseImpl = Promise);
268
+ var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl);
269
+ return exports.isGeneratorFunction(outerFn) ? iter : iter.next().then(function (result) {
270
+ return result.done ? result.value : iter.next();
271
+ });
272
+ }, defineIteratorMethods(Gp), define(Gp, toStringTagSymbol, "Generator"), define(Gp, iteratorSymbol, function () {
273
+ return this;
274
+ }), define(Gp, "toString", function () {
275
+ return "[object Generator]";
276
+ }), exports.keys = function (object) {
277
+ var keys = [];
278
+
279
+ for (var key in object) keys.push(key);
280
+
281
+ return keys.reverse(), function next() {
282
+ for (; keys.length;) {
283
+ var key = keys.pop();
284
+ if (key in object) return next.value = key, next.done = !1, next;
285
+ }
286
+
287
+ return next.done = !0, next;
288
+ };
289
+ }, exports.values = values, Context.prototype = {
290
+ constructor: Context,
291
+ reset: function (skipTempReset) {
292
+ if (this.prev = 0, this.next = 0, this.sent = this._sent = undefined, this.done = !1, this.delegate = null, this.method = "next", this.arg = undefined, this.tryEntries.forEach(resetTryEntry), !skipTempReset) for (var name in this) "t" === name.charAt(0) && hasOwn.call(this, name) && !isNaN(+name.slice(1)) && (this[name] = undefined);
293
+ },
294
+ stop: function () {
295
+ this.done = !0;
296
+ var rootRecord = this.tryEntries[0].completion;
297
+ if ("throw" === rootRecord.type) throw rootRecord.arg;
298
+ return this.rval;
299
+ },
300
+ dispatchException: function (exception) {
301
+ if (this.done) throw exception;
302
+ var context = this;
303
+
304
+ function handle(loc, caught) {
305
+ return record.type = "throw", record.arg = exception, context.next = loc, caught && (context.method = "next", context.arg = undefined), !!caught;
306
+ }
307
+
308
+ for (var i = this.tryEntries.length - 1; i >= 0; --i) {
309
+ var entry = this.tryEntries[i],
310
+ record = entry.completion;
311
+ if ("root" === entry.tryLoc) return handle("end");
312
+
313
+ if (entry.tryLoc <= this.prev) {
314
+ var hasCatch = hasOwn.call(entry, "catchLoc"),
315
+ hasFinally = hasOwn.call(entry, "finallyLoc");
316
+
317
+ if (hasCatch && hasFinally) {
318
+ if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0);
319
+ if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc);
320
+ } else if (hasCatch) {
321
+ if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0);
322
+ } else {
323
+ if (!hasFinally) throw new Error("try statement without catch or finally");
324
+ if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc);
325
+ }
326
+ }
327
+ }
328
+ },
329
+ abrupt: function (type, arg) {
330
+ for (var i = this.tryEntries.length - 1; i >= 0; --i) {
331
+ var entry = this.tryEntries[i];
332
+
333
+ if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) {
334
+ var finallyEntry = entry;
335
+ break;
336
+ }
337
+ }
338
+
339
+ finallyEntry && ("break" === type || "continue" === type) && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc && (finallyEntry = null);
340
+ var record = finallyEntry ? finallyEntry.completion : {};
341
+ return record.type = type, record.arg = arg, finallyEntry ? (this.method = "next", this.next = finallyEntry.finallyLoc, ContinueSentinel) : this.complete(record);
342
+ },
343
+ complete: function (record, afterLoc) {
344
+ if ("throw" === record.type) throw record.arg;
345
+ return "break" === record.type || "continue" === record.type ? this.next = record.arg : "return" === record.type ? (this.rval = this.arg = record.arg, this.method = "return", this.next = "end") : "normal" === record.type && afterLoc && (this.next = afterLoc), ContinueSentinel;
346
+ },
347
+ finish: function (finallyLoc) {
348
+ for (var i = this.tryEntries.length - 1; i >= 0; --i) {
349
+ var entry = this.tryEntries[i];
350
+ if (entry.finallyLoc === finallyLoc) return this.complete(entry.completion, entry.afterLoc), resetTryEntry(entry), ContinueSentinel;
351
+ }
352
+ },
353
+ catch: function (tryLoc) {
354
+ for (var i = this.tryEntries.length - 1; i >= 0; --i) {
355
+ var entry = this.tryEntries[i];
356
+
357
+ if (entry.tryLoc === tryLoc) {
358
+ var record = entry.completion;
359
+
360
+ if ("throw" === record.type) {
361
+ var thrown = record.arg;
362
+ resetTryEntry(entry);
363
+ }
364
+
365
+ return thrown;
366
+ }
367
+ }
368
+
369
+ throw new Error("illegal catch attempt");
370
+ },
371
+ delegateYield: function (iterable, resultName, nextLoc) {
372
+ return this.delegate = {
373
+ iterator: values(iterable),
374
+ resultName: resultName,
375
+ nextLoc: nextLoc
376
+ }, "next" === this.method && (this.arg = undefined), ContinueSentinel;
377
+ }
378
+ }, exports;
379
+ }
380
+
381
+ function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
382
+ try {
383
+ var info = gen[key](arg);
384
+ var value = info.value;
385
+ } catch (error) {
386
+ reject(error);
387
+ return;
388
+ }
389
+
390
+ if (info.done) {
391
+ resolve(value);
392
+ } else {
393
+ Promise.resolve(value).then(_next, _throw);
394
+ }
395
+ }
396
+
397
+ function _asyncToGenerator(fn) {
398
+ return function () {
399
+ var self = this,
400
+ args = arguments;
401
+ return new Promise(function (resolve, reject) {
402
+ var gen = fn.apply(self, args);
403
+
404
+ function _next(value) {
405
+ asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
406
+ }
407
+
408
+ function _throw(err) {
409
+ asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
410
+ }
411
+
412
+ _next(undefined);
413
+ });
414
+ };
415
+ }
416
+
36
417
  function _inheritsLoose(subClass, superClass) {
37
418
  subClass.prototype = Object.create(superClass.prototype);
38
419
  subClass.prototype.constructor = subClass;
@@ -86,43 +467,61 @@ var WebGLContextService = /*#__PURE__*/function () {
86
467
 
87
468
  var _proto = WebGLContextService.prototype;
88
469
 
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;
470
+ _proto.init = /*#__PURE__*/function () {
471
+ var _init = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
472
+ var _this$canvasConfig, container, canvas, devicePixelRatio, $canvas, dpr;
94
473
 
95
- if (canvas) {
96
- this.$canvas = canvas;
474
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
475
+ while (1) {
476
+ switch (_context.prev = _context.next) {
477
+ case 0:
478
+ _this$canvasConfig = this.canvasConfig, container = _this$canvasConfig.container, canvas = _this$canvasConfig.canvas, devicePixelRatio = _this$canvasConfig.devicePixelRatio;
97
479
 
98
- if (container && canvas.parentElement !== container) {
99
- container.appendChild(canvas);
100
- }
480
+ if (canvas) {
481
+ this.$canvas = canvas;
101
482
 
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;
483
+ if (container && canvas.parentElement !== container) {
484
+ container.appendChild(canvas);
485
+ }
107
486
 
108
- if (this.$container) {
109
- // create canvas
110
- var $canvas = document.createElement('canvas');
111
- this.$container.appendChild($canvas);
487
+ this.$container = canvas.parentElement;
488
+ this.canvasConfig.container = this.$container;
489
+ } else if (container) {
490
+ // create container
491
+ this.$container = g.isString(container) ? document.getElementById(container) : container;
112
492
 
113
- if (!this.$container.style.position) {
114
- this.$container.style.position = 'relative';
115
- }
493
+ if (this.$container) {
494
+ // create canvas
495
+ $canvas = document.createElement('canvas');
496
+ this.$container.appendChild($canvas);
116
497
 
117
- this.$canvas = $canvas;
118
- }
119
- } // use user-defined dpr first
498
+ if (!this.$container.style.position) {
499
+ this.$container.style.position = 'relative';
500
+ }
120
501
 
502
+ this.$canvas = $canvas;
503
+ }
504
+ } // use user-defined dpr first
121
505
 
122
- var dpr = devicePixelRatio || g.isBrowser && window.devicePixelRatio || 1;
123
- dpr = dpr >= 1 ? Math.ceil(dpr) : 1;
124
- this.dpr = dpr;
125
- };
506
+
507
+ dpr = devicePixelRatio || g.isBrowser && window.devicePixelRatio || 1;
508
+ dpr = dpr >= 1 ? Math.ceil(dpr) : 1;
509
+ this.dpr = dpr;
510
+
511
+ case 5:
512
+ case "end":
513
+ return _context.stop();
514
+ }
515
+ }
516
+ }, _callee, this);
517
+ }));
518
+
519
+ function init() {
520
+ return _init.apply(this, arguments);
521
+ }
522
+
523
+ return init;
524
+ }();
126
525
 
127
526
  _proto.getDomElement = function getDomElement() {
128
527
  return this.$canvas;