@antv/g-webgpu 1.7.52 → 1.7.53

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,10 +366,49 @@ function _asyncToGenerator(fn) {
366
366
  });
367
367
  };
368
368
  }
369
- function _inheritsLoose(subClass, superClass) {
370
- subClass.prototype = Object.create(superClass.prototype);
371
- subClass.prototype.constructor = subClass;
372
- _setPrototypeOf(subClass, superClass);
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);
373
412
  }
374
413
  function _setPrototypeOf(o, p) {
375
414
  _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) {
@@ -378,9 +417,63 @@ function _setPrototypeOf(o, p) {
378
417
  };
379
418
  return _setPrototypeOf(o, p);
380
419
  }
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
+ }
381
473
 
382
474
  var WebGPUContextService = /*#__PURE__*/function () {
383
475
  function WebGPUContextService(context) {
476
+ _classCallCheck(this, WebGPUContextService);
384
477
  this.$container = void 0;
385
478
  this.$canvas = void 0;
386
479
  this.dpr = void 0;
@@ -390,13 +483,13 @@ var WebGPUContextService = /*#__PURE__*/function () {
390
483
  // @ts-ignore
391
484
  this.deviceRendererPlugin = context.deviceRendererPlugin;
392
485
  }
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) {
399
- switch (_context.prev = _context.next) {
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) {
400
493
  case 0:
401
494
  _this$canvasConfig = this.canvasConfig, container = _this$canvasConfig.container, canvas = _this$canvasConfig.canvas;
402
495
  if (canvas) {
@@ -424,105 +517,127 @@ var WebGPUContextService = /*#__PURE__*/function () {
424
517
  case "end":
425
518
  return _context.stop();
426
519
  }
427
- }
428
- }, _callee, this);
429
- }));
430
- function init() {
431
- return _init.apply(this, arguments);
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;
432
531
  }
433
- return init;
434
- }();
435
- _proto.getDomElement = function getDomElement() {
436
- return this.$canvas;
437
- };
438
- _proto.getContext = function getContext() {
439
- // @ts-ignore
440
- return this.deviceRendererPlugin.getDevice().canvasContext;
441
- };
442
- _proto.getBoundingClientRect = function getBoundingClientRect() {
443
- if (this.$canvas.getBoundingClientRect) {
444
- return this.$canvas.getBoundingClientRect();
532
+ }, {
533
+ key: "getContext",
534
+ value: function getContext() {
535
+ // @ts-ignore
536
+ return this.deviceRendererPlugin.getDevice().canvasContext;
445
537
  }
446
- };
447
- _proto.destroy = function destroy() {
448
- // @ts-ignore
449
- if (this.$container && this.$canvas && this.$canvas.parentNode) {
538
+ }, {
539
+ key: "getBoundingClientRect",
540
+ value: function getBoundingClientRect() {
541
+ if (this.$canvas.getBoundingClientRect) {
542
+ return this.$canvas.getBoundingClientRect();
543
+ }
544
+ }
545
+ }, {
546
+ key: "destroy",
547
+ value: function destroy() {
450
548
  // @ts-ignore
451
- this.$container.removeChild(this.$canvas);
549
+ if (this.$container && this.$canvas && this.$canvas.parentNode) {
550
+ // @ts-ignore
551
+ this.$container.removeChild(this.$canvas);
552
+ }
452
553
  }
453
- };
454
- _proto.resize = function resize(width, height) {
455
- // use user-defined dpr first
456
- var devicePixelRatio = this.canvasConfig.devicePixelRatio;
457
- var dpr = devicePixelRatio || gLite.isBrowser && window.devicePixelRatio || 1;
458
- dpr = dpr >= 1 ? Math.ceil(dpr) : 1;
459
- this.dpr = dpr;
460
- if (this.$canvas) {
461
- var _dpr = this.getDPR();
462
- // set canvas width & height
463
- this.$canvas.width = _dpr * width;
464
- this.$canvas.height = _dpr * height;
465
- // set CSS style width & height
466
- gLite.setDOMSize(this.$canvas, width, height);
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
+ }
467
570
  }
468
- };
469
- _proto.getDPR = function getDPR() {
470
- return this.dpr;
471
- };
472
- _proto.applyCursorStyle = function applyCursorStyle(cursor) {
473
- if (this.$container && this.$container.style) {
474
- this.$container.style.cursor = cursor;
571
+ }, {
572
+ key: "getDPR",
573
+ value: function getDPR() {
574
+ return this.dpr;
475
575
  }
476
- };
477
- _proto.toDataURL = /*#__PURE__*/function () {
478
- var _toDataURL = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(options) {
479
- return _regeneratorRuntime().wrap(function _callee2$(_context2) {
480
- while (1) {
481
- switch (_context2.prev = _context2.next) {
576
+ }, {
577
+ key: "applyCursorStyle",
578
+ value: function applyCursorStyle(cursor) {
579
+ if (this.$container && this.$container.style) {
580
+ this.$container.style.cursor = cursor;
581
+ }
582
+ }
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) {
482
589
  case 0:
483
590
  return _context2.abrupt("return", '');
484
591
  case 1:
485
592
  case "end":
486
593
  return _context2.stop();
487
594
  }
488
- }
489
- }, _callee2);
490
- }));
491
- function toDataURL(_x) {
492
- return _toDataURL.apply(this, arguments);
493
- }
494
- return toDataURL;
495
- }();
595
+ }, _callee2);
596
+ }));
597
+ function toDataURL(_x) {
598
+ return _toDataURL.apply(this, arguments);
599
+ }
600
+ return toDataURL;
601
+ }()
602
+ }]);
496
603
  return WebGPUContextService;
497
604
  }();
498
605
 
499
606
  var ContextRegisterPlugin = /*#__PURE__*/function (_AbstractRendererPlug) {
500
- _inheritsLoose(ContextRegisterPlugin, _AbstractRendererPlug);
607
+ _inherits(ContextRegisterPlugin, _AbstractRendererPlug);
608
+ var _super = _createSuper(ContextRegisterPlugin);
501
609
  function ContextRegisterPlugin(rendererPlugin) {
502
610
  var _this;
503
- _this = _AbstractRendererPlug.call(this) || this;
611
+ _classCallCheck(this, ContextRegisterPlugin);
612
+ _this = _super.call(this);
504
613
  _this.rendererPlugin = void 0;
505
614
  _this.name = 'webgpu-context-register';
506
615
  _this.rendererPlugin = rendererPlugin;
507
616
  return _this;
508
617
  }
509
- var _proto = ContextRegisterPlugin.prototype;
510
- _proto.init = function init() {
511
- this.context.ContextService = WebGPUContextService;
512
- // @ts-ignore
513
- this.context.deviceRendererPlugin = this.rendererPlugin;
514
- };
515
- _proto.destroy = function destroy() {
516
- delete this.context.ContextService;
517
- };
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
+ }]);
518
631
  return ContextRegisterPlugin;
519
632
  }(gLite.AbstractRendererPlugin);
520
633
 
521
634
  var Renderer = /*#__PURE__*/function (_AbstractRenderer) {
522
- _inheritsLoose(Renderer, _AbstractRenderer);
635
+ _inherits(Renderer, _AbstractRenderer);
636
+ var _super = _createSuper(Renderer);
523
637
  function Renderer(config) {
524
638
  var _this;
525
- _this = _AbstractRenderer.call(this, config) || this;
639
+ _classCallCheck(this, Renderer);
640
+ _this = _super.call(this, config);
526
641
  var deviceRendererPlugin = new DeviceRenderer.Plugin();
527
642
  _this.registerPlugin(new ContextRegisterPlugin(deviceRendererPlugin));
528
643
  _this.registerPlugin(new ImageLoader.Plugin());
@@ -532,7 +647,7 @@ var Renderer = /*#__PURE__*/function (_AbstractRenderer) {
532
647
  _this.registerPlugin(new HTMLRenderer.Plugin());
533
648
  return _this;
534
649
  }
535
- return Renderer;
650
+ return _createClass(Renderer);
536
651
  }(gLite.AbstractRenderer);
537
652
 
538
653
  exports.DeviceRenderer = DeviceRenderer__namespace;