@antv/g-webgpu 1.2.1 → 1.2.2

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 CHANGED
@@ -394,54 +394,11 @@ function _asyncToGenerator(fn) {
394
394
  };
395
395
  }
396
396
 
397
- function _classCallCheck(instance, Constructor) {
398
- if (!(instance instanceof Constructor)) {
399
- throw new TypeError("Cannot call a class as a function");
400
- }
401
- }
402
-
403
- function _defineProperties(target, props) {
404
- for (var i = 0; i < props.length; i++) {
405
- var descriptor = props[i];
406
- descriptor.enumerable = descriptor.enumerable || false;
407
- descriptor.configurable = true;
408
- if ("value" in descriptor) descriptor.writable = true;
409
- Object.defineProperty(target, descriptor.key, descriptor);
410
- }
411
- }
397
+ function _inheritsLoose(subClass, superClass) {
398
+ subClass.prototype = Object.create(superClass.prototype);
399
+ subClass.prototype.constructor = subClass;
412
400
 
413
- function _createClass(Constructor, protoProps, staticProps) {
414
- if (protoProps) _defineProperties(Constructor.prototype, protoProps);
415
- if (staticProps) _defineProperties(Constructor, staticProps);
416
- Object.defineProperty(Constructor, "prototype", {
417
- writable: false
418
- });
419
- return Constructor;
420
- }
421
-
422
- function _inherits(subClass, superClass) {
423
- if (typeof superClass !== "function" && superClass !== null) {
424
- throw new TypeError("Super expression must either be null or a function");
425
- }
426
-
427
- subClass.prototype = Object.create(superClass && superClass.prototype, {
428
- constructor: {
429
- value: subClass,
430
- writable: true,
431
- configurable: true
432
- }
433
- });
434
- Object.defineProperty(subClass, "prototype", {
435
- writable: false
436
- });
437
- if (superClass) _setPrototypeOf(subClass, superClass);
438
- }
439
-
440
- function _getPrototypeOf(o) {
441
- _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) {
442
- return o.__proto__ || Object.getPrototypeOf(o);
443
- };
444
- return _getPrototypeOf(o);
401
+ _setPrototypeOf(subClass, superClass);
445
402
  }
446
403
 
447
404
  function _setPrototypeOf(o, p) {
@@ -452,56 +409,6 @@ function _setPrototypeOf(o, p) {
452
409
  return _setPrototypeOf(o, p);
453
410
  }
454
411
 
455
- function _isNativeReflectConstruct() {
456
- if (typeof Reflect === "undefined" || !Reflect.construct) return false;
457
- if (Reflect.construct.sham) return false;
458
- if (typeof Proxy === "function") return true;
459
-
460
- try {
461
- Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {}));
462
- return true;
463
- } catch (e) {
464
- return false;
465
- }
466
- }
467
-
468
- function _assertThisInitialized(self) {
469
- if (self === void 0) {
470
- throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
471
- }
472
-
473
- return self;
474
- }
475
-
476
- function _possibleConstructorReturn(self, call) {
477
- if (call && (typeof call === "object" || typeof call === "function")) {
478
- return call;
479
- } else if (call !== void 0) {
480
- throw new TypeError("Derived constructors may only return object or undefined");
481
- }
482
-
483
- return _assertThisInitialized(self);
484
- }
485
-
486
- function _createSuper(Derived) {
487
- var hasNativeReflectConstruct = _isNativeReflectConstruct();
488
-
489
- return function _createSuperInternal() {
490
- var Super = _getPrototypeOf(Derived),
491
- result;
492
-
493
- if (hasNativeReflectConstruct) {
494
- var NewTarget = _getPrototypeOf(this).constructor;
495
-
496
- result = Reflect.construct(Super, arguments, NewTarget);
497
- } else {
498
- result = Super.apply(this, arguments);
499
- }
500
-
501
- return _possibleConstructorReturn(this, result);
502
- };
503
- }
504
-
505
412
  /******************************************************************************
506
413
  Copyright (c) Microsoft Corporation.
507
414
 
@@ -530,8 +437,6 @@ function __metadata(metadataKey, metadataValue) {
530
437
 
531
438
  var WebGLContextService = /*#__PURE__*/function () {
532
439
  function WebGLContextService() {
533
- _classCallCheck(this, WebGLContextService);
534
-
535
440
  this.$container = void 0;
536
441
  this.$canvas = void 0;
537
442
  this.dpr = void 0;
@@ -539,114 +444,106 @@ var WebGLContextService = /*#__PURE__*/function () {
539
444
  this.canvasConfig = void 0;
540
445
  }
541
446
 
542
- _createClass(WebGLContextService, [{
543
- key: "init",
544
- value: function () {
545
- var _init = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
546
- var _this$canvasConfig, container, canvas, devicePixelRatio, $canvas, dpr;
447
+ var _proto = WebGLContextService.prototype;
547
448
 
548
- return _regeneratorRuntime().wrap(function _callee$(_context) {
549
- while (1) {
550
- switch (_context.prev = _context.next) {
551
- case 0:
552
- _this$canvasConfig = this.canvasConfig, container = _this$canvasConfig.container, canvas = _this$canvasConfig.canvas, devicePixelRatio = _this$canvasConfig.devicePixelRatio;
449
+ _proto.init = /*#__PURE__*/function () {
450
+ var _init = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
451
+ var _this$canvasConfig, container, canvas, devicePixelRatio, $canvas, dpr;
553
452
 
554
- if (canvas) {
555
- this.$canvas = canvas;
453
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
454
+ while (1) {
455
+ switch (_context.prev = _context.next) {
456
+ case 0:
457
+ _this$canvasConfig = this.canvasConfig, container = _this$canvasConfig.container, canvas = _this$canvasConfig.canvas, devicePixelRatio = _this$canvasConfig.devicePixelRatio;
556
458
 
557
- if (container && canvas.parentElement !== container) {
558
- container.appendChild(canvas);
559
- }
459
+ if (canvas) {
460
+ this.$canvas = canvas;
560
461
 
561
- this.$container = canvas.parentElement;
562
- this.canvasConfig.container = this.$container;
563
- } else if (container) {
564
- // create container
565
- this.$container = isString(container) ? document.getElementById(container) : container;
462
+ if (container && canvas.parentElement !== container) {
463
+ container.appendChild(canvas);
464
+ }
566
465
 
567
- if (this.$container) {
568
- // create canvas
569
- $canvas = document.createElement('canvas');
570
- this.$container.appendChild($canvas);
466
+ this.$container = canvas.parentElement;
467
+ this.canvasConfig.container = this.$container;
468
+ } else if (container) {
469
+ // create container
470
+ this.$container = isString(container) ? document.getElementById(container) : container;
571
471
 
572
- if (!this.$container.style.position) {
573
- this.$container.style.position = 'relative';
574
- }
472
+ if (this.$container) {
473
+ // create canvas
474
+ $canvas = document.createElement('canvas');
475
+ this.$container.appendChild($canvas);
575
476
 
576
- this.$canvas = $canvas;
477
+ if (!this.$container.style.position) {
478
+ this.$container.style.position = 'relative';
577
479
  }
578
- } // use user-defined dpr first
579
480
 
481
+ this.$canvas = $canvas;
482
+ }
483
+ } // use user-defined dpr first
580
484
 
581
- dpr = devicePixelRatio || isBrowser && window.devicePixelRatio || 1;
582
- dpr = dpr >= 1 ? Math.ceil(dpr) : 1;
583
- this.dpr = dpr;
584
485
 
585
- case 5:
586
- case "end":
587
- return _context.stop();
588
- }
589
- }
590
- }, _callee, this);
591
- }));
486
+ dpr = devicePixelRatio || isBrowser && window.devicePixelRatio || 1;
487
+ dpr = dpr >= 1 ? Math.ceil(dpr) : 1;
488
+ this.dpr = dpr;
592
489
 
593
- function init() {
594
- return _init.apply(this, arguments);
595
- }
490
+ case 5:
491
+ case "end":
492
+ return _context.stop();
493
+ }
494
+ }
495
+ }, _callee, this);
496
+ }));
596
497
 
597
- return init;
598
- }()
599
- }, {
600
- key: "getDomElement",
601
- value: function getDomElement() {
602
- return this.$canvas;
603
- }
604
- }, {
605
- key: "getContext",
606
- value: function getContext() {
607
- return this.context;
498
+ function init() {
499
+ return _init.apply(this, arguments);
608
500
  }
609
- }, {
610
- key: "getBoundingClientRect",
611
- value: function getBoundingClientRect() {
612
- if (this.$canvas.getBoundingClientRect) {
613
- return this.$canvas.getBoundingClientRect();
614
- }
501
+
502
+ return init;
503
+ }();
504
+
505
+ _proto.getDomElement = function getDomElement() {
506
+ return this.$canvas;
507
+ };
508
+
509
+ _proto.getContext = function getContext() {
510
+ return this.context;
511
+ };
512
+
513
+ _proto.getBoundingClientRect = function getBoundingClientRect() {
514
+ if (this.$canvas.getBoundingClientRect) {
515
+ return this.$canvas.getBoundingClientRect();
615
516
  }
616
- }, {
617
- key: "destroy",
618
- value: function destroy() {
517
+ };
518
+
519
+ _proto.destroy = function destroy() {
520
+ // @ts-ignore
521
+ if (this.$container && this.$canvas && this.$canvas.parentNode) {
619
522
  // @ts-ignore
620
- if (this.$container && this.$canvas && this.$canvas.parentNode) {
621
- // @ts-ignore
622
- this.$container.removeChild(this.$canvas);
623
- }
523
+ this.$container.removeChild(this.$canvas);
624
524
  }
625
- }, {
626
- key: "resize",
627
- value: function resize(width, height) {
628
- if (this.$canvas) {
629
- var dpr = this.getDPR(); // set canvas width & height
525
+ };
630
526
 
631
- this.$canvas.width = dpr * width;
632
- this.$canvas.height = dpr * height; // set CSS style width & height
527
+ _proto.resize = function resize(width, height) {
528
+ if (this.$canvas) {
529
+ var dpr = this.getDPR(); // set canvas width & height
633
530
 
634
- setDOMSize(this.$canvas, width, height);
635
- }
636
- }
637
- }, {
638
- key: "getDPR",
639
- value: function getDPR() {
640
- return this.dpr;
531
+ this.$canvas.width = dpr * width;
532
+ this.$canvas.height = dpr * height; // set CSS style width & height
533
+
534
+ setDOMSize(this.$canvas, width, height);
641
535
  }
642
- }, {
643
- key: "applyCursorStyle",
644
- value: function applyCursorStyle(cursor) {
645
- if (this.$container && this.$container.style) {
646
- this.$container.style.cursor = cursor;
647
- }
536
+ };
537
+
538
+ _proto.getDPR = function getDPR() {
539
+ return this.dpr;
540
+ };
541
+
542
+ _proto.applyCursorStyle = function applyCursorStyle(cursor) {
543
+ if (this.$container && this.$container.style) {
544
+ this.$container.style.cursor = cursor;
648
545
  }
649
- }]);
546
+ };
650
547
 
651
548
  return WebGLContextService;
652
549
  }();
@@ -665,37 +562,29 @@ var containerModule = Module(function (register) {
665
562
  });
666
563
  var ContextRegisterPlugin = /*#__PURE__*/function () {
667
564
  function ContextRegisterPlugin() {
668
- _classCallCheck(this, ContextRegisterPlugin);
669
-
670
565
  this.name = 'webgpu-context-register';
671
566
  }
672
567
 
673
- _createClass(ContextRegisterPlugin, [{
674
- key: "init",
675
- value: function init(container) {
676
- container.load(containerModule, true);
677
- }
678
- }, {
679
- key: "destroy",
680
- value: function destroy(container) {
681
- container.unload(containerModule);
682
- }
683
- }]);
568
+ var _proto = ContextRegisterPlugin.prototype;
569
+
570
+ _proto.init = function init(container) {
571
+ container.load(containerModule, true);
572
+ };
573
+
574
+ _proto.destroy = function destroy(container) {
575
+ container.unload(containerModule);
576
+ };
684
577
 
685
578
  return ContextRegisterPlugin;
686
579
  }();
687
580
 
688
581
  var Renderer = /*#__PURE__*/function (_AbstractRenderer) {
689
- _inherits(Renderer, _AbstractRenderer);
690
-
691
- var _super = _createSuper(Renderer);
582
+ _inheritsLoose(Renderer, _AbstractRenderer);
692
583
 
693
584
  function Renderer(config) {
694
585
  var _this;
695
586
 
696
- _classCallCheck(this, Renderer);
697
-
698
- _this = _super.call(this, config);
587
+ _this = _AbstractRenderer.call(this, config) || this;
699
588
 
700
589
  _this.registerPlugin(new ContextRegisterPlugin());
701
590
 
@@ -712,7 +601,7 @@ var Renderer = /*#__PURE__*/function (_AbstractRenderer) {
712
601
  return _this;
713
602
  }
714
603
 
715
- return _createClass(Renderer);
604
+ return Renderer;
716
605
  }(AbstractRenderer);
717
606
 
718
607
  export { Renderer };