@antv/g-webgpu 1.7.65 → 1.7.66

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