@antv/g-webgpu 1.7.33 → 1.7.35
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.esm.js +233 -119
- package/dist/index.js +233 -119
- package/dist/index.umd.js +8387 -6805
- package/dist/index.umd.min.js +1 -1
- package/package.json +7 -7
package/dist/index.esm.js
CHANGED
|
@@ -149,14 +149,9 @@ function _regeneratorRuntime() {
|
|
|
149
149
|
};
|
|
150
150
|
}
|
|
151
151
|
function maybeInvokeDelegate(delegate, context) {
|
|
152
|
-
var
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
if (delegate.iterator.return && (context.method = "return", context.arg = undefined, maybeInvokeDelegate(delegate, context), "throw" === context.method)) return ContinueSentinel;
|
|
156
|
-
context.method = "throw", context.arg = new TypeError("The iterator does not provide a 'throw' method");
|
|
157
|
-
}
|
|
158
|
-
return ContinueSentinel;
|
|
159
|
-
}
|
|
152
|
+
var methodName = context.method,
|
|
153
|
+
method = delegate.iterator[methodName];
|
|
154
|
+
if (undefined === method) return context.delegate = null, "throw" === methodName && delegate.iterator.return && (context.method = "return", context.arg = undefined, maybeInvokeDelegate(delegate, context), "throw" === context.method) || "return" !== methodName && (context.method = "throw", context.arg = new TypeError("The iterator does not provide a '" + methodName + "' method")), ContinueSentinel;
|
|
160
155
|
var record = tryCatch(method, delegate.iterator, context.arg);
|
|
161
156
|
if ("throw" === record.type) return context.method = "throw", context.arg = record.arg, context.delegate = null, ContinueSentinel;
|
|
162
157
|
var info = record.arg;
|
|
@@ -350,10 +345,49 @@ function _asyncToGenerator(fn) {
|
|
|
350
345
|
});
|
|
351
346
|
};
|
|
352
347
|
}
|
|
353
|
-
function
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
348
|
+
function _classCallCheck(instance, Constructor) {
|
|
349
|
+
if (!(instance instanceof Constructor)) {
|
|
350
|
+
throw new TypeError("Cannot call a class as a function");
|
|
351
|
+
}
|
|
352
|
+
}
|
|
353
|
+
function _defineProperties(target, props) {
|
|
354
|
+
for (var i = 0; i < props.length; i++) {
|
|
355
|
+
var descriptor = props[i];
|
|
356
|
+
descriptor.enumerable = descriptor.enumerable || false;
|
|
357
|
+
descriptor.configurable = true;
|
|
358
|
+
if ("value" in descriptor) descriptor.writable = true;
|
|
359
|
+
Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor);
|
|
360
|
+
}
|
|
361
|
+
}
|
|
362
|
+
function _createClass(Constructor, protoProps, staticProps) {
|
|
363
|
+
if (protoProps) _defineProperties(Constructor.prototype, protoProps);
|
|
364
|
+
if (staticProps) _defineProperties(Constructor, staticProps);
|
|
365
|
+
Object.defineProperty(Constructor, "prototype", {
|
|
366
|
+
writable: false
|
|
367
|
+
});
|
|
368
|
+
return Constructor;
|
|
369
|
+
}
|
|
370
|
+
function _inherits(subClass, superClass) {
|
|
371
|
+
if (typeof superClass !== "function" && superClass !== null) {
|
|
372
|
+
throw new TypeError("Super expression must either be null or a function");
|
|
373
|
+
}
|
|
374
|
+
subClass.prototype = Object.create(superClass && superClass.prototype, {
|
|
375
|
+
constructor: {
|
|
376
|
+
value: subClass,
|
|
377
|
+
writable: true,
|
|
378
|
+
configurable: true
|
|
379
|
+
}
|
|
380
|
+
});
|
|
381
|
+
Object.defineProperty(subClass, "prototype", {
|
|
382
|
+
writable: false
|
|
383
|
+
});
|
|
384
|
+
if (superClass) _setPrototypeOf(subClass, superClass);
|
|
385
|
+
}
|
|
386
|
+
function _getPrototypeOf(o) {
|
|
387
|
+
_getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) {
|
|
388
|
+
return o.__proto__ || Object.getPrototypeOf(o);
|
|
389
|
+
};
|
|
390
|
+
return _getPrototypeOf(o);
|
|
357
391
|
}
|
|
358
392
|
function _setPrototypeOf(o, p) {
|
|
359
393
|
_setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) {
|
|
@@ -362,9 +396,63 @@ function _setPrototypeOf(o, p) {
|
|
|
362
396
|
};
|
|
363
397
|
return _setPrototypeOf(o, p);
|
|
364
398
|
}
|
|
399
|
+
function _isNativeReflectConstruct() {
|
|
400
|
+
if (typeof Reflect === "undefined" || !Reflect.construct) return false;
|
|
401
|
+
if (Reflect.construct.sham) return false;
|
|
402
|
+
if (typeof Proxy === "function") return true;
|
|
403
|
+
try {
|
|
404
|
+
Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {}));
|
|
405
|
+
return true;
|
|
406
|
+
} catch (e) {
|
|
407
|
+
return false;
|
|
408
|
+
}
|
|
409
|
+
}
|
|
410
|
+
function _assertThisInitialized(self) {
|
|
411
|
+
if (self === void 0) {
|
|
412
|
+
throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
|
|
413
|
+
}
|
|
414
|
+
return self;
|
|
415
|
+
}
|
|
416
|
+
function _possibleConstructorReturn(self, call) {
|
|
417
|
+
if (call && (typeof call === "object" || typeof call === "function")) {
|
|
418
|
+
return call;
|
|
419
|
+
} else if (call !== void 0) {
|
|
420
|
+
throw new TypeError("Derived constructors may only return object or undefined");
|
|
421
|
+
}
|
|
422
|
+
return _assertThisInitialized(self);
|
|
423
|
+
}
|
|
424
|
+
function _createSuper(Derived) {
|
|
425
|
+
var hasNativeReflectConstruct = _isNativeReflectConstruct();
|
|
426
|
+
return function _createSuperInternal() {
|
|
427
|
+
var Super = _getPrototypeOf(Derived),
|
|
428
|
+
result;
|
|
429
|
+
if (hasNativeReflectConstruct) {
|
|
430
|
+
var NewTarget = _getPrototypeOf(this).constructor;
|
|
431
|
+
result = Reflect.construct(Super, arguments, NewTarget);
|
|
432
|
+
} else {
|
|
433
|
+
result = Super.apply(this, arguments);
|
|
434
|
+
}
|
|
435
|
+
return _possibleConstructorReturn(this, result);
|
|
436
|
+
};
|
|
437
|
+
}
|
|
438
|
+
function _toPrimitive(input, hint) {
|
|
439
|
+
if (typeof input !== "object" || input === null) return input;
|
|
440
|
+
var prim = input[Symbol.toPrimitive];
|
|
441
|
+
if (prim !== undefined) {
|
|
442
|
+
var res = prim.call(input, hint || "default");
|
|
443
|
+
if (typeof res !== "object") return res;
|
|
444
|
+
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
445
|
+
}
|
|
446
|
+
return (hint === "string" ? String : Number)(input);
|
|
447
|
+
}
|
|
448
|
+
function _toPropertyKey(arg) {
|
|
449
|
+
var key = _toPrimitive(arg, "string");
|
|
450
|
+
return typeof key === "symbol" ? key : String(key);
|
|
451
|
+
}
|
|
365
452
|
|
|
366
453
|
var WebGPUContextService = /*#__PURE__*/function () {
|
|
367
454
|
function WebGPUContextService(context) {
|
|
455
|
+
_classCallCheck(this, WebGPUContextService);
|
|
368
456
|
this.$container = void 0;
|
|
369
457
|
this.$canvas = void 0;
|
|
370
458
|
this.dpr = void 0;
|
|
@@ -374,139 +462,165 @@ var WebGPUContextService = /*#__PURE__*/function () {
|
|
|
374
462
|
// @ts-ignore
|
|
375
463
|
this.deviceRendererPlugin = context.deviceRendererPlugin;
|
|
376
464
|
}
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
var
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
container.
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
this.$container.style.position
|
|
465
|
+
_createClass(WebGPUContextService, [{
|
|
466
|
+
key: "init",
|
|
467
|
+
value: function () {
|
|
468
|
+
var _init = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
469
|
+
var _this$canvasConfig, container, canvas, $canvas;
|
|
470
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
471
|
+
while (1) {
|
|
472
|
+
switch (_context.prev = _context.next) {
|
|
473
|
+
case 0:
|
|
474
|
+
_this$canvasConfig = this.canvasConfig, container = _this$canvasConfig.container, canvas = _this$canvasConfig.canvas;
|
|
475
|
+
if (canvas) {
|
|
476
|
+
this.$canvas = canvas;
|
|
477
|
+
if (container && canvas.parentElement !== container) {
|
|
478
|
+
container.appendChild(canvas);
|
|
479
|
+
}
|
|
480
|
+
this.$container = canvas.parentElement;
|
|
481
|
+
this.canvasConfig.container = this.$container;
|
|
482
|
+
} else if (container) {
|
|
483
|
+
// create container
|
|
484
|
+
this.$container = isString(container) ? document.getElementById(container) : container;
|
|
485
|
+
if (this.$container) {
|
|
486
|
+
// create canvas
|
|
487
|
+
$canvas = document.createElement('canvas');
|
|
488
|
+
this.$container.appendChild($canvas);
|
|
489
|
+
if (!this.$container.style.position) {
|
|
490
|
+
this.$container.style.position = 'relative';
|
|
491
|
+
}
|
|
492
|
+
this.$canvas = $canvas;
|
|
402
493
|
}
|
|
403
|
-
this.$canvas = $canvas;
|
|
404
494
|
}
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
495
|
+
this.resize(this.canvasConfig.width, this.canvasConfig.height);
|
|
496
|
+
case 3:
|
|
497
|
+
case "end":
|
|
498
|
+
return _context.stop();
|
|
499
|
+
}
|
|
410
500
|
}
|
|
411
|
-
}
|
|
412
|
-
}
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
501
|
+
}, _callee, this);
|
|
502
|
+
}));
|
|
503
|
+
function init() {
|
|
504
|
+
return _init.apply(this, arguments);
|
|
505
|
+
}
|
|
506
|
+
return init;
|
|
507
|
+
}()
|
|
508
|
+
}, {
|
|
509
|
+
key: "getDomElement",
|
|
510
|
+
value: function getDomElement() {
|
|
511
|
+
return this.$canvas;
|
|
416
512
|
}
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
_proto.getContext = function getContext() {
|
|
423
|
-
// @ts-ignore
|
|
424
|
-
return this.deviceRendererPlugin.getDevice().canvasContext;
|
|
425
|
-
};
|
|
426
|
-
_proto.getBoundingClientRect = function getBoundingClientRect() {
|
|
427
|
-
if (this.$canvas.getBoundingClientRect) {
|
|
428
|
-
return this.$canvas.getBoundingClientRect();
|
|
513
|
+
}, {
|
|
514
|
+
key: "getContext",
|
|
515
|
+
value: function getContext() {
|
|
516
|
+
// @ts-ignore
|
|
517
|
+
return this.deviceRendererPlugin.getDevice().canvasContext;
|
|
429
518
|
}
|
|
430
|
-
}
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
519
|
+
}, {
|
|
520
|
+
key: "getBoundingClientRect",
|
|
521
|
+
value: function getBoundingClientRect() {
|
|
522
|
+
if (this.$canvas.getBoundingClientRect) {
|
|
523
|
+
return this.$canvas.getBoundingClientRect();
|
|
524
|
+
}
|
|
525
|
+
}
|
|
526
|
+
}, {
|
|
527
|
+
key: "destroy",
|
|
528
|
+
value: function destroy() {
|
|
434
529
|
// @ts-ignore
|
|
435
|
-
this.$container
|
|
530
|
+
if (this.$container && this.$canvas && this.$canvas.parentNode) {
|
|
531
|
+
// @ts-ignore
|
|
532
|
+
this.$container.removeChild(this.$canvas);
|
|
533
|
+
}
|
|
436
534
|
}
|
|
437
|
-
}
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
535
|
+
}, {
|
|
536
|
+
key: "resize",
|
|
537
|
+
value: function resize(width, height) {
|
|
538
|
+
// use user-defined dpr first
|
|
539
|
+
var devicePixelRatio = this.canvasConfig.devicePixelRatio;
|
|
540
|
+
var dpr = devicePixelRatio || isBrowser && window.devicePixelRatio || 1;
|
|
541
|
+
dpr = dpr >= 1 ? Math.ceil(dpr) : 1;
|
|
542
|
+
this.dpr = dpr;
|
|
543
|
+
if (this.$canvas) {
|
|
544
|
+
var _dpr = this.getDPR();
|
|
545
|
+
// set canvas width & height
|
|
546
|
+
this.$canvas.width = _dpr * width;
|
|
547
|
+
this.$canvas.height = _dpr * height;
|
|
548
|
+
// set CSS style width & height
|
|
549
|
+
setDOMSize(this.$canvas, width, height);
|
|
550
|
+
}
|
|
451
551
|
}
|
|
452
|
-
}
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
_proto.applyCursorStyle = function applyCursorStyle(cursor) {
|
|
457
|
-
if (this.$container && this.$container.style) {
|
|
458
|
-
this.$container.style.cursor = cursor;
|
|
552
|
+
}, {
|
|
553
|
+
key: "getDPR",
|
|
554
|
+
value: function getDPR() {
|
|
555
|
+
return this.dpr;
|
|
459
556
|
}
|
|
460
|
-
}
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
case 0:
|
|
467
|
-
return _context2.abrupt("return", '');
|
|
468
|
-
case 1:
|
|
469
|
-
case "end":
|
|
470
|
-
return _context2.stop();
|
|
471
|
-
}
|
|
472
|
-
}
|
|
473
|
-
}, _callee2);
|
|
474
|
-
}));
|
|
475
|
-
function toDataURL(_x) {
|
|
476
|
-
return _toDataURL.apply(this, arguments);
|
|
557
|
+
}, {
|
|
558
|
+
key: "applyCursorStyle",
|
|
559
|
+
value: function applyCursorStyle(cursor) {
|
|
560
|
+
if (this.$container && this.$container.style) {
|
|
561
|
+
this.$container.style.cursor = cursor;
|
|
562
|
+
}
|
|
477
563
|
}
|
|
478
|
-
|
|
479
|
-
|
|
564
|
+
}, {
|
|
565
|
+
key: "toDataURL",
|
|
566
|
+
value: function () {
|
|
567
|
+
var _toDataURL = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(options) {
|
|
568
|
+
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
569
|
+
while (1) {
|
|
570
|
+
switch (_context2.prev = _context2.next) {
|
|
571
|
+
case 0:
|
|
572
|
+
return _context2.abrupt("return", '');
|
|
573
|
+
case 1:
|
|
574
|
+
case "end":
|
|
575
|
+
return _context2.stop();
|
|
576
|
+
}
|
|
577
|
+
}
|
|
578
|
+
}, _callee2);
|
|
579
|
+
}));
|
|
580
|
+
function toDataURL(_x) {
|
|
581
|
+
return _toDataURL.apply(this, arguments);
|
|
582
|
+
}
|
|
583
|
+
return toDataURL;
|
|
584
|
+
}()
|
|
585
|
+
}]);
|
|
480
586
|
return WebGPUContextService;
|
|
481
587
|
}();
|
|
482
588
|
|
|
483
589
|
var ContextRegisterPlugin = /*#__PURE__*/function (_AbstractRendererPlug) {
|
|
484
|
-
|
|
590
|
+
_inherits(ContextRegisterPlugin, _AbstractRendererPlug);
|
|
591
|
+
var _super = _createSuper(ContextRegisterPlugin);
|
|
485
592
|
function ContextRegisterPlugin(rendererPlugin) {
|
|
486
593
|
var _this;
|
|
487
|
-
|
|
594
|
+
_classCallCheck(this, ContextRegisterPlugin);
|
|
595
|
+
_this = _super.call(this);
|
|
488
596
|
_this.rendererPlugin = void 0;
|
|
489
597
|
_this.name = 'webgpu-context-register';
|
|
490
598
|
_this.rendererPlugin = rendererPlugin;
|
|
491
599
|
return _this;
|
|
492
600
|
}
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
601
|
+
_createClass(ContextRegisterPlugin, [{
|
|
602
|
+
key: "init",
|
|
603
|
+
value: function init() {
|
|
604
|
+
this.context.ContextService = WebGPUContextService;
|
|
605
|
+
// @ts-ignore
|
|
606
|
+
this.context.deviceRendererPlugin = this.rendererPlugin;
|
|
607
|
+
}
|
|
608
|
+
}, {
|
|
609
|
+
key: "destroy",
|
|
610
|
+
value: function destroy() {
|
|
611
|
+
delete this.context.ContextService;
|
|
612
|
+
}
|
|
613
|
+
}]);
|
|
502
614
|
return ContextRegisterPlugin;
|
|
503
615
|
}(AbstractRendererPlugin);
|
|
504
616
|
|
|
505
617
|
var Renderer = /*#__PURE__*/function (_AbstractRenderer) {
|
|
506
|
-
|
|
618
|
+
_inherits(Renderer, _AbstractRenderer);
|
|
619
|
+
var _super = _createSuper(Renderer);
|
|
507
620
|
function Renderer(config) {
|
|
508
621
|
var _this;
|
|
509
|
-
|
|
622
|
+
_classCallCheck(this, Renderer);
|
|
623
|
+
_this = _super.call(this, config);
|
|
510
624
|
var deviceRendererPlugin = new Plugin();
|
|
511
625
|
_this.registerPlugin(new ContextRegisterPlugin(deviceRendererPlugin));
|
|
512
626
|
_this.registerPlugin(new Plugin$1());
|
|
@@ -516,7 +630,7 @@ var Renderer = /*#__PURE__*/function (_AbstractRenderer) {
|
|
|
516
630
|
_this.registerPlugin(new Plugin$4());
|
|
517
631
|
return _this;
|
|
518
632
|
}
|
|
519
|
-
return Renderer;
|
|
633
|
+
return _createClass(Renderer);
|
|
520
634
|
}(AbstractRenderer);
|
|
521
635
|
|
|
522
636
|
export { Renderer };
|