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