@antv/g-webgpu 1.1.8-alpha.1 → 1.2.1

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.d.ts CHANGED
@@ -1,9 +1,10 @@
1
1
  import type { RendererConfig } from '@antv/g';
2
2
  import { AbstractRenderer } from '@antv/g';
3
- import * as DomInteraction from '@antv/g-plugin-dom-interaction';
4
3
  import * as DeviceRenderer from '@antv/g-plugin-device-renderer';
4
+ import * as DomInteraction from '@antv/g-plugin-dom-interaction';
5
+ import * as HTMLRenderer from '@antv/g-plugin-html-renderer';
5
6
  import * as WebGPUDevice from '@antv/g-plugin-webgpu-device';
6
- export { DomInteraction, DeviceRenderer, WebGPUDevice };
7
+ export { DomInteraction, DeviceRenderer, WebGPUDevice, HTMLRenderer };
7
8
  declare type WebGPURendererConfig = RendererConfig;
8
9
  export declare class Renderer extends AbstractRenderer {
9
10
  constructor(config?: Partial<WebGPURendererConfig>);
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAC9C,OAAO,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAC3C,OAAO,KAAK,cAAc,MAAM,gCAAgC,CAAC;AACjE,OAAO,KAAK,cAAc,MAAM,gCAAgC,CAAC;AACjE,OAAO,KAAK,YAAY,MAAM,8BAA8B,CAAC;AAI7D,OAAO,EAAE,cAAc,EAAE,cAAc,EAAE,YAAY,EAAE,CAAC;AAExD,aAAK,oBAAoB,GAAG,cAAc,CAAC;AAE3C,qBAAa,QAAS,SAAQ,gBAAgB;gBAChC,MAAM,CAAC,EAAE,OAAO,CAAC,oBAAoB,CAAC;CASnD"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAC9C,OAAO,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAC3C,OAAO,KAAK,cAAc,MAAM,gCAAgC,CAAC;AACjE,OAAO,KAAK,cAAc,MAAM,gCAAgC,CAAC;AACjE,OAAO,KAAK,YAAY,MAAM,8BAA8B,CAAC;AAE7D,OAAO,KAAK,YAAY,MAAM,8BAA8B,CAAC;AAG7D,OAAO,EAAE,cAAc,EAAE,cAAc,EAAE,YAAY,EAAE,YAAY,EAAE,CAAC;AAEtE,aAAK,oBAAoB,GAAG,cAAc,CAAC;AAE3C,qBAAa,QAAS,SAAQ,gBAAgB;gBAChC,MAAM,CAAC,EAAE,OAAO,CAAC,oBAAoB,CAAC;CAUnD"}
package/dist/index.esm.js CHANGED
@@ -1,14 +1,17 @@
1
1
  import { inject, CanvasConfig, singleton, ContextService, setDOMSize, isString, isBrowser, Module, AbstractRenderer } from '@antv/g';
2
- import { Plugin as Plugin$2 } from '@antv/g-plugin-dom-interaction';
3
- import * as DomInteraction from '@antv/g-plugin-dom-interaction';
4
- export { DomInteraction };
5
- import { Plugin as Plugin$1 } from '@antv/g-plugin-device-renderer';
2
+ import { Plugin as Plugin$2 } from '@antv/g-plugin-device-renderer';
6
3
  import * as DeviceRenderer from '@antv/g-plugin-device-renderer';
7
4
  export { DeviceRenderer };
8
- import { Plugin } from '@antv/g-plugin-webgpu-device';
5
+ import { Plugin as Plugin$3 } from '@antv/g-plugin-dom-interaction';
6
+ import * as DomInteraction from '@antv/g-plugin-dom-interaction';
7
+ export { DomInteraction };
8
+ import { Plugin as Plugin$4 } from '@antv/g-plugin-html-renderer';
9
+ import * as HTMLRenderer from '@antv/g-plugin-html-renderer';
10
+ export { HTMLRenderer };
11
+ import { Plugin } from '@antv/g-plugin-image-loader';
12
+ import { Plugin as Plugin$1 } from '@antv/g-plugin-webgpu-device';
9
13
  import * as WebGPUDevice from '@antv/g-plugin-webgpu-device';
10
14
  export { WebGPUDevice };
11
- import { Plugin as Plugin$3 } from '@antv/g-plugin-html-renderer';
12
15
 
13
16
  function _regeneratorRuntime() {
14
17
  /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */
@@ -391,22 +394,114 @@ function _asyncToGenerator(fn) {
391
394
  };
392
395
  }
393
396
 
394
- function _inheritsLoose(subClass, superClass) {
395
- subClass.prototype = Object.create(superClass.prototype);
396
- subClass.prototype.constructor = subClass;
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
+ }
412
+
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
+ }
397
439
 
398
- _setPrototypeOf(subClass, superClass);
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);
399
445
  }
400
446
 
401
447
  function _setPrototypeOf(o, p) {
402
- _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) {
448
+ _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) {
403
449
  o.__proto__ = p;
404
450
  return o;
405
451
  };
406
-
407
452
  return _setPrototypeOf(o, p);
408
453
  }
409
454
 
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
+
410
505
  /******************************************************************************
411
506
  Copyright (c) Microsoft Corporation.
412
507
 
@@ -435,6 +530,8 @@ function __metadata(metadataKey, metadataValue) {
435
530
 
436
531
  var WebGLContextService = /*#__PURE__*/function () {
437
532
  function WebGLContextService() {
533
+ _classCallCheck(this, WebGLContextService);
534
+
438
535
  this.$container = void 0;
439
536
  this.$canvas = void 0;
440
537
  this.dpr = void 0;
@@ -442,106 +539,114 @@ var WebGLContextService = /*#__PURE__*/function () {
442
539
  this.canvasConfig = void 0;
443
540
  }
444
541
 
445
- var _proto = WebGLContextService.prototype;
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;
446
547
 
447
- _proto.init = /*#__PURE__*/function () {
448
- var _init = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
449
- var _this$canvasConfig, container, canvas, devicePixelRatio, $canvas, dpr;
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;
450
553
 
451
- return _regeneratorRuntime().wrap(function _callee$(_context) {
452
- while (1) {
453
- switch (_context.prev = _context.next) {
454
- case 0:
455
- _this$canvasConfig = this.canvasConfig, container = _this$canvasConfig.container, canvas = _this$canvasConfig.canvas, devicePixelRatio = _this$canvasConfig.devicePixelRatio;
554
+ if (canvas) {
555
+ this.$canvas = canvas;
456
556
 
457
- if (canvas) {
458
- this.$canvas = canvas;
557
+ if (container && canvas.parentElement !== container) {
558
+ container.appendChild(canvas);
559
+ }
459
560
 
460
- if (container && canvas.parentElement !== container) {
461
- container.appendChild(canvas);
462
- }
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;
463
566
 
464
- this.$container = canvas.parentElement;
465
- this.canvasConfig.container = this.$container;
466
- } else if (container) {
467
- // create container
468
- this.$container = isString(container) ? document.getElementById(container) : container;
567
+ if (this.$container) {
568
+ // create canvas
569
+ $canvas = document.createElement('canvas');
570
+ this.$container.appendChild($canvas);
469
571
 
470
- if (this.$container) {
471
- // create canvas
472
- $canvas = document.createElement('canvas');
473
- this.$container.appendChild($canvas);
572
+ if (!this.$container.style.position) {
573
+ this.$container.style.position = 'relative';
574
+ }
474
575
 
475
- if (!this.$container.style.position) {
476
- this.$container.style.position = 'relative';
576
+ this.$canvas = $canvas;
477
577
  }
478
-
479
- this.$canvas = $canvas;
480
- }
481
- } // use user-defined dpr first
578
+ } // use user-defined dpr first
482
579
 
483
580
 
484
- dpr = devicePixelRatio || isBrowser && window.devicePixelRatio || 1;
485
- dpr = dpr >= 1 ? Math.ceil(dpr) : 1;
486
- this.dpr = dpr;
581
+ dpr = devicePixelRatio || isBrowser && window.devicePixelRatio || 1;
582
+ dpr = dpr >= 1 ? Math.ceil(dpr) : 1;
583
+ this.dpr = dpr;
487
584
 
488
- case 5:
489
- case "end":
490
- return _context.stop();
585
+ case 5:
586
+ case "end":
587
+ return _context.stop();
588
+ }
491
589
  }
492
- }
493
- }, _callee, this);
494
- }));
495
-
496
- function init() {
497
- return _init.apply(this, arguments);
498
- }
499
-
500
- return init;
501
- }();
590
+ }, _callee, this);
591
+ }));
502
592
 
503
- _proto.getDomElement = function getDomElement() {
504
- return this.$canvas;
505
- };
506
-
507
- _proto.getContext = function getContext() {
508
- return this.context;
509
- };
593
+ function init() {
594
+ return _init.apply(this, arguments);
595
+ }
510
596
 
511
- _proto.getBoundingClientRect = function getBoundingClientRect() {
512
- if (this.$canvas.getBoundingClientRect) {
513
- return this.$canvas.getBoundingClientRect();
597
+ return init;
598
+ }()
599
+ }, {
600
+ key: "getDomElement",
601
+ value: function getDomElement() {
602
+ return this.$canvas;
514
603
  }
515
- };
516
-
517
- _proto.destroy = function destroy() {
518
- // @ts-ignore
519
- if (this.$container && this.$canvas && this.$canvas.parentNode) {
604
+ }, {
605
+ key: "getContext",
606
+ value: function getContext() {
607
+ return this.context;
608
+ }
609
+ }, {
610
+ key: "getBoundingClientRect",
611
+ value: function getBoundingClientRect() {
612
+ if (this.$canvas.getBoundingClientRect) {
613
+ return this.$canvas.getBoundingClientRect();
614
+ }
615
+ }
616
+ }, {
617
+ key: "destroy",
618
+ value: function destroy() {
520
619
  // @ts-ignore
521
- this.$container.removeChild(this.$canvas);
620
+ if (this.$container && this.$canvas && this.$canvas.parentNode) {
621
+ // @ts-ignore
622
+ this.$container.removeChild(this.$canvas);
623
+ }
522
624
  }
523
- };
524
-
525
- _proto.resize = function resize(width, height) {
526
- if (this.$canvas) {
527
- var dpr = this.getDPR(); // set canvas width & height
625
+ }, {
626
+ key: "resize",
627
+ value: function resize(width, height) {
628
+ if (this.$canvas) {
629
+ var dpr = this.getDPR(); // set canvas width & height
528
630
 
529
- this.$canvas.width = dpr * width;
530
- this.$canvas.height = dpr * height; // set CSS style width & height
631
+ this.$canvas.width = dpr * width;
632
+ this.$canvas.height = dpr * height; // set CSS style width & height
531
633
 
532
- setDOMSize(this.$canvas, width, height);
634
+ setDOMSize(this.$canvas, width, height);
635
+ }
533
636
  }
534
- };
535
-
536
- _proto.getDPR = function getDPR() {
537
- return this.dpr;
538
- };
539
-
540
- _proto.applyCursorStyle = function applyCursorStyle(cursor) {
541
- if (this.$container && this.$container.style) {
542
- this.$container.style.cursor = cursor;
637
+ }, {
638
+ key: "getDPR",
639
+ value: function getDPR() {
640
+ return this.dpr;
543
641
  }
544
- };
642
+ }, {
643
+ key: "applyCursorStyle",
644
+ value: function applyCursorStyle(cursor) {
645
+ if (this.$container && this.$container.style) {
646
+ this.$container.style.cursor = cursor;
647
+ }
648
+ }
649
+ }]);
545
650
 
546
651
  return WebGLContextService;
547
652
  }();
@@ -560,29 +665,37 @@ var containerModule = Module(function (register) {
560
665
  });
561
666
  var ContextRegisterPlugin = /*#__PURE__*/function () {
562
667
  function ContextRegisterPlugin() {
668
+ _classCallCheck(this, ContextRegisterPlugin);
669
+
563
670
  this.name = 'webgpu-context-register';
564
671
  }
565
672
 
566
- var _proto = ContextRegisterPlugin.prototype;
567
-
568
- _proto.init = function init(container) {
569
- container.load(containerModule, true);
570
- };
571
-
572
- _proto.destroy = function destroy(container) {
573
- container.unload(containerModule);
574
- };
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
+ }]);
575
684
 
576
685
  return ContextRegisterPlugin;
577
686
  }();
578
687
 
579
688
  var Renderer = /*#__PURE__*/function (_AbstractRenderer) {
580
- _inheritsLoose(Renderer, _AbstractRenderer);
689
+ _inherits(Renderer, _AbstractRenderer);
690
+
691
+ var _super = _createSuper(Renderer);
581
692
 
582
693
  function Renderer(config) {
583
694
  var _this;
584
695
 
585
- _this = _AbstractRenderer.call(this, config) || this;
696
+ _classCallCheck(this, Renderer);
697
+
698
+ _this = _super.call(this, config);
586
699
 
587
700
  _this.registerPlugin(new ContextRegisterPlugin());
588
701
 
@@ -594,10 +707,12 @@ var Renderer = /*#__PURE__*/function (_AbstractRenderer) {
594
707
 
595
708
  _this.registerPlugin(new Plugin$3());
596
709
 
710
+ _this.registerPlugin(new Plugin$4());
711
+
597
712
  return _this;
598
713
  }
599
714
 
600
- return Renderer;
715
+ return _createClass(Renderer);
601
716
  }(AbstractRenderer);
602
717
 
603
718
  export { Renderer };