@antv/g-webgpu 1.7.63 → 1.7.64

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
@@ -345,49 +345,10 @@ function _asyncToGenerator(fn) {
345
345
  });
346
346
  };
347
347
  }
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);
348
+ function _inheritsLoose(subClass, superClass) {
349
+ subClass.prototype = Object.create(superClass.prototype);
350
+ subClass.prototype.constructor = subClass;
351
+ _setPrototypeOf(subClass, superClass);
391
352
  }
392
353
  function _setPrototypeOf(o, p) {
393
354
  _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) {
@@ -396,63 +357,9 @@ function _setPrototypeOf(o, p) {
396
357
  };
397
358
  return _setPrototypeOf(o, p);
398
359
  }
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
- }
452
360
 
453
361
  var WebGPUContextService = /*#__PURE__*/function () {
454
362
  function WebGPUContextService(context) {
455
- _classCallCheck(this, WebGPUContextService);
456
363
  this.$container = void 0;
457
364
  this.$canvas = void 0;
458
365
  this.dpr = void 0;
@@ -462,161 +369,135 @@ var WebGPUContextService = /*#__PURE__*/function () {
462
369
  // @ts-ignore
463
370
  this.deviceRendererPlugin = context.deviceRendererPlugin;
464
371
  }
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) switch (_context.prev = _context.next) {
472
- case 0:
473
- _this$canvasConfig = this.canvasConfig, container = _this$canvasConfig.container, canvas = _this$canvasConfig.canvas;
474
- if (canvas) {
475
- this.$canvas = canvas;
476
- if (container && canvas.parentElement !== container) {
477
- container.appendChild(canvas);
478
- }
479
- this.$container = canvas.parentElement;
480
- this.canvasConfig.container = this.$container;
481
- } else if (container) {
482
- // create container
483
- this.$container = isString(container) ? document.getElementById(container) : container;
484
- if (this.$container) {
485
- // create canvas
486
- $canvas = document.createElement('canvas');
487
- this.$container.appendChild($canvas);
488
- if (!this.$container.style.position) {
489
- this.$container.style.position = 'relative';
490
- }
491
- this.$canvas = $canvas;
372
+ var _proto = WebGPUContextService.prototype;
373
+ _proto.init = /*#__PURE__*/function () {
374
+ var _init = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
375
+ var _this$canvasConfig, container, canvas, $canvas;
376
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
377
+ while (1) switch (_context.prev = _context.next) {
378
+ case 0:
379
+ _this$canvasConfig = this.canvasConfig, container = _this$canvasConfig.container, canvas = _this$canvasConfig.canvas;
380
+ if (canvas) {
381
+ this.$canvas = canvas;
382
+ if (container && canvas.parentElement !== container) {
383
+ container.appendChild(canvas);
384
+ }
385
+ this.$container = canvas.parentElement;
386
+ this.canvasConfig.container = this.$container;
387
+ } else if (container) {
388
+ // create container
389
+ this.$container = isString(container) ? document.getElementById(container) : container;
390
+ if (this.$container) {
391
+ // create canvas
392
+ $canvas = document.createElement('canvas');
393
+ this.$container.appendChild($canvas);
394
+ if (!this.$container.style.position) {
395
+ this.$container.style.position = 'relative';
492
396
  }
397
+ this.$canvas = $canvas;
493
398
  }
494
- this.resize(this.canvasConfig.width, this.canvasConfig.height);
495
- case 3:
496
- case "end":
497
- return _context.stop();
498
- }
499
- }, _callee, this);
500
- }));
501
- function init() {
502
- return _init.apply(this, arguments);
503
- }
504
- return init;
505
- }()
506
- }, {
507
- key: "getDomElement",
508
- value: function getDomElement() {
509
- return this.$canvas;
510
- }
511
- }, {
512
- key: "getContext",
513
- value: function getContext() {
514
- // @ts-ignore
515
- return this.deviceRendererPlugin.getDevice().canvasContext;
399
+ }
400
+ this.resize(this.canvasConfig.width, this.canvasConfig.height);
401
+ case 3:
402
+ case "end":
403
+ return _context.stop();
404
+ }
405
+ }, _callee, this);
406
+ }));
407
+ function init() {
408
+ return _init.apply(this, arguments);
516
409
  }
517
- }, {
518
- key: "getBoundingClientRect",
519
- value: function getBoundingClientRect() {
520
- if (this.$canvas.getBoundingClientRect) {
521
- return this.$canvas.getBoundingClientRect();
522
- }
410
+ return init;
411
+ }();
412
+ _proto.getDomElement = function getDomElement() {
413
+ return this.$canvas;
414
+ };
415
+ _proto.getContext = function getContext() {
416
+ // @ts-ignore
417
+ return this.deviceRendererPlugin.getDevice().canvasContext;
418
+ };
419
+ _proto.getBoundingClientRect = function getBoundingClientRect() {
420
+ if (this.$canvas.getBoundingClientRect) {
421
+ return this.$canvas.getBoundingClientRect();
523
422
  }
524
- }, {
525
- key: "destroy",
526
- value: function destroy() {
423
+ };
424
+ _proto.destroy = function destroy() {
425
+ // @ts-ignore
426
+ if (this.$container && this.$canvas && this.$canvas.parentNode) {
527
427
  // @ts-ignore
528
- if (this.$container && this.$canvas && this.$canvas.parentNode) {
529
- // @ts-ignore
530
- this.$container.removeChild(this.$canvas);
531
- }
428
+ this.$container.removeChild(this.$canvas);
532
429
  }
533
- }, {
534
- key: "resize",
535
- value: function resize(width, height) {
536
- // use user-defined dpr first
537
- var devicePixelRatio = this.canvasConfig.devicePixelRatio;
538
- var dpr = devicePixelRatio || isBrowser && window.devicePixelRatio || 1;
539
- dpr = dpr >= 1 ? Math.ceil(dpr) : 1;
540
- this.dpr = dpr;
541
- if (this.$canvas) {
542
- var _dpr = this.getDPR();
543
- // set canvas width & height
544
- this.$canvas.width = _dpr * width;
545
- this.$canvas.height = _dpr * height;
546
- // set CSS style width & height
547
- setDOMSize(this.$canvas, width, height);
548
- }
430
+ };
431
+ _proto.resize = function resize(width, height) {
432
+ // use user-defined dpr first
433
+ var devicePixelRatio = this.canvasConfig.devicePixelRatio;
434
+ var dpr = devicePixelRatio || isBrowser && window.devicePixelRatio || 1;
435
+ dpr = dpr >= 1 ? Math.ceil(dpr) : 1;
436
+ this.dpr = dpr;
437
+ if (this.$canvas) {
438
+ var _dpr = this.getDPR();
439
+ // set canvas width & height
440
+ this.$canvas.width = _dpr * width;
441
+ this.$canvas.height = _dpr * height;
442
+ // set CSS style width & height
443
+ setDOMSize(this.$canvas, width, height);
549
444
  }
550
- }, {
551
- key: "getDPR",
552
- value: function getDPR() {
553
- return this.dpr;
445
+ };
446
+ _proto.getDPR = function getDPR() {
447
+ return this.dpr;
448
+ };
449
+ _proto.applyCursorStyle = function applyCursorStyle(cursor) {
450
+ if (this.$container && this.$container.style) {
451
+ this.$container.style.cursor = cursor;
554
452
  }
555
- }, {
556
- key: "applyCursorStyle",
557
- value: function applyCursorStyle(cursor) {
558
- if (this.$container && this.$container.style) {
559
- this.$container.style.cursor = cursor;
560
- }
453
+ };
454
+ _proto.toDataURL = /*#__PURE__*/function () {
455
+ var _toDataURL = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(options) {
456
+ return _regeneratorRuntime().wrap(function _callee2$(_context2) {
457
+ while (1) switch (_context2.prev = _context2.next) {
458
+ case 0:
459
+ return _context2.abrupt("return", '');
460
+ case 1:
461
+ case "end":
462
+ return _context2.stop();
463
+ }
464
+ }, _callee2);
465
+ }));
466
+ function toDataURL(_x) {
467
+ return _toDataURL.apply(this, arguments);
561
468
  }
562
- }, {
563
- key: "toDataURL",
564
- value: function () {
565
- var _toDataURL = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(options) {
566
- return _regeneratorRuntime().wrap(function _callee2$(_context2) {
567
- while (1) switch (_context2.prev = _context2.next) {
568
- case 0:
569
- return _context2.abrupt("return", '');
570
- case 1:
571
- case "end":
572
- return _context2.stop();
573
- }
574
- }, _callee2);
575
- }));
576
- function toDataURL(_x) {
577
- return _toDataURL.apply(this, arguments);
578
- }
579
- return toDataURL;
580
- }()
581
- }]);
469
+ return toDataURL;
470
+ }();
582
471
  return WebGPUContextService;
583
472
  }();
584
473
 
585
474
  var ContextRegisterPlugin = /*#__PURE__*/function (_AbstractRendererPlug) {
586
- _inherits(ContextRegisterPlugin, _AbstractRendererPlug);
587
- var _super = _createSuper(ContextRegisterPlugin);
475
+ _inheritsLoose(ContextRegisterPlugin, _AbstractRendererPlug);
588
476
  function ContextRegisterPlugin(rendererPlugin) {
589
477
  var _this;
590
- _classCallCheck(this, ContextRegisterPlugin);
591
- _this = _super.call(this);
478
+ _this = _AbstractRendererPlug.call(this) || this;
592
479
  _this.rendererPlugin = void 0;
593
480
  _this.name = 'webgpu-context-register';
594
481
  _this.rendererPlugin = rendererPlugin;
595
482
  return _this;
596
483
  }
597
- _createClass(ContextRegisterPlugin, [{
598
- key: "init",
599
- value: function init() {
600
- this.context.ContextService = WebGPUContextService;
601
- // @ts-ignore
602
- this.context.deviceRendererPlugin = this.rendererPlugin;
603
- }
604
- }, {
605
- key: "destroy",
606
- value: function destroy() {
607
- delete this.context.ContextService;
608
- }
609
- }]);
484
+ var _proto = ContextRegisterPlugin.prototype;
485
+ _proto.init = function init() {
486
+ this.context.ContextService = WebGPUContextService;
487
+ // @ts-ignore
488
+ this.context.deviceRendererPlugin = this.rendererPlugin;
489
+ };
490
+ _proto.destroy = function destroy() {
491
+ delete this.context.ContextService;
492
+ };
610
493
  return ContextRegisterPlugin;
611
494
  }(AbstractRendererPlugin);
612
495
 
613
496
  var Renderer = /*#__PURE__*/function (_AbstractRenderer) {
614
- _inherits(Renderer, _AbstractRenderer);
615
- var _super = _createSuper(Renderer);
497
+ _inheritsLoose(Renderer, _AbstractRenderer);
616
498
  function Renderer(config) {
617
499
  var _this;
618
- _classCallCheck(this, Renderer);
619
- _this = _super.call(this, config);
500
+ _this = _AbstractRenderer.call(this, config) || this;
620
501
  var deviceRendererPlugin = new Plugin();
621
502
  _this.registerPlugin(new ContextRegisterPlugin(deviceRendererPlugin));
622
503
  _this.registerPlugin(new Plugin$1());
@@ -626,7 +507,7 @@ var Renderer = /*#__PURE__*/function (_AbstractRenderer) {
626
507
  _this.registerPlugin(new Plugin$4());
627
508
  return _this;
628
509
  }
629
- return _createClass(Renderer);
510
+ return Renderer;
630
511
  }(AbstractRenderer);
631
512
 
632
513
  export { Renderer };