@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 +3 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.esm.js +218 -103
- package/dist/index.js +216 -101
- package/dist/index.umd.js +11051 -9097
- package/dist/index.umd.min.js +7 -5
- package/package.json +8 -6
package/dist/index.js
CHANGED
|
@@ -3,10 +3,11 @@
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
5
|
var g = require('@antv/g');
|
|
6
|
-
var DomInteraction = require('@antv/g-plugin-dom-interaction');
|
|
7
6
|
var DeviceRenderer = require('@antv/g-plugin-device-renderer');
|
|
8
|
-
var
|
|
7
|
+
var DomInteraction = require('@antv/g-plugin-dom-interaction');
|
|
9
8
|
var HTMLRenderer = require('@antv/g-plugin-html-renderer');
|
|
9
|
+
var ImageLoader = require('@antv/g-plugin-image-loader');
|
|
10
|
+
var WebGPUDevice = require('@antv/g-plugin-webgpu-device');
|
|
10
11
|
|
|
11
12
|
function _interopNamespace(e) {
|
|
12
13
|
if (e && e.__esModule) return e;
|
|
@@ -28,8 +29,9 @@ function _interopNamespace(e) {
|
|
|
28
29
|
return Object.freeze(n);
|
|
29
30
|
}
|
|
30
31
|
|
|
31
|
-
var DomInteraction__namespace = /*#__PURE__*/_interopNamespace(DomInteraction);
|
|
32
32
|
var DeviceRenderer__namespace = /*#__PURE__*/_interopNamespace(DeviceRenderer);
|
|
33
|
+
var DomInteraction__namespace = /*#__PURE__*/_interopNamespace(DomInteraction);
|
|
34
|
+
var HTMLRenderer__namespace = /*#__PURE__*/_interopNamespace(HTMLRenderer);
|
|
33
35
|
var WebGPUDevice__namespace = /*#__PURE__*/_interopNamespace(WebGPUDevice);
|
|
34
36
|
|
|
35
37
|
function _regeneratorRuntime() {
|
|
@@ -413,22 +415,114 @@ function _asyncToGenerator(fn) {
|
|
|
413
415
|
};
|
|
414
416
|
}
|
|
415
417
|
|
|
416
|
-
function
|
|
417
|
-
|
|
418
|
-
|
|
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
|
+
}
|
|
433
|
+
|
|
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
|
+
}
|
|
419
460
|
|
|
420
|
-
|
|
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);
|
|
421
466
|
}
|
|
422
467
|
|
|
423
468
|
function _setPrototypeOf(o, p) {
|
|
424
|
-
_setPrototypeOf = Object.setPrototypeOf
|
|
469
|
+
_setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) {
|
|
425
470
|
o.__proto__ = p;
|
|
426
471
|
return o;
|
|
427
472
|
};
|
|
428
|
-
|
|
429
473
|
return _setPrototypeOf(o, p);
|
|
430
474
|
}
|
|
431
475
|
|
|
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
|
+
|
|
432
526
|
/******************************************************************************
|
|
433
527
|
Copyright (c) Microsoft Corporation.
|
|
434
528
|
|
|
@@ -457,6 +551,8 @@ function __metadata(metadataKey, metadataValue) {
|
|
|
457
551
|
|
|
458
552
|
var WebGLContextService = /*#__PURE__*/function () {
|
|
459
553
|
function WebGLContextService() {
|
|
554
|
+
_classCallCheck(this, WebGLContextService);
|
|
555
|
+
|
|
460
556
|
this.$container = void 0;
|
|
461
557
|
this.$canvas = void 0;
|
|
462
558
|
this.dpr = void 0;
|
|
@@ -464,106 +560,114 @@ var WebGLContextService = /*#__PURE__*/function () {
|
|
|
464
560
|
this.canvasConfig = void 0;
|
|
465
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
568
|
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
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;
|
|
472
574
|
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
switch (_context.prev = _context.next) {
|
|
476
|
-
case 0:
|
|
477
|
-
_this$canvasConfig = this.canvasConfig, container = _this$canvasConfig.container, canvas = _this$canvasConfig.canvas, devicePixelRatio = _this$canvasConfig.devicePixelRatio;
|
|
575
|
+
if (canvas) {
|
|
576
|
+
this.$canvas = canvas;
|
|
478
577
|
|
|
479
|
-
|
|
480
|
-
|
|
578
|
+
if (container && canvas.parentElement !== container) {
|
|
579
|
+
container.appendChild(canvas);
|
|
580
|
+
}
|
|
481
581
|
|
|
482
|
-
|
|
483
|
-
container
|
|
484
|
-
}
|
|
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;
|
|
485
587
|
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
this.$container = g.isString(container) ? document.getElementById(container) : container;
|
|
588
|
+
if (this.$container) {
|
|
589
|
+
// create canvas
|
|
590
|
+
$canvas = document.createElement('canvas');
|
|
591
|
+
this.$container.appendChild($canvas);
|
|
491
592
|
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
this.$container.appendChild($canvas);
|
|
593
|
+
if (!this.$container.style.position) {
|
|
594
|
+
this.$container.style.position = 'relative';
|
|
595
|
+
}
|
|
496
596
|
|
|
497
|
-
|
|
498
|
-
this.$container.style.position = 'relative';
|
|
597
|
+
this.$canvas = $canvas;
|
|
499
598
|
}
|
|
500
|
-
|
|
501
|
-
this.$canvas = $canvas;
|
|
502
|
-
}
|
|
503
|
-
} // use user-defined dpr first
|
|
599
|
+
} // use user-defined dpr first
|
|
504
600
|
|
|
505
601
|
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
602
|
+
dpr = devicePixelRatio || g.isBrowser && window.devicePixelRatio || 1;
|
|
603
|
+
dpr = dpr >= 1 ? Math.ceil(dpr) : 1;
|
|
604
|
+
this.dpr = dpr;
|
|
509
605
|
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
606
|
+
case 5:
|
|
607
|
+
case "end":
|
|
608
|
+
return _context.stop();
|
|
609
|
+
}
|
|
513
610
|
}
|
|
514
|
-
}
|
|
515
|
-
}
|
|
516
|
-
}));
|
|
517
|
-
|
|
518
|
-
function init() {
|
|
519
|
-
return _init.apply(this, arguments);
|
|
520
|
-
}
|
|
611
|
+
}, _callee, this);
|
|
612
|
+
}));
|
|
521
613
|
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
_proto.getDomElement = function getDomElement() {
|
|
526
|
-
return this.$canvas;
|
|
527
|
-
};
|
|
528
|
-
|
|
529
|
-
_proto.getContext = function getContext() {
|
|
530
|
-
return this.context;
|
|
531
|
-
};
|
|
614
|
+
function init() {
|
|
615
|
+
return _init.apply(this, arguments);
|
|
616
|
+
}
|
|
532
617
|
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
618
|
+
return init;
|
|
619
|
+
}()
|
|
620
|
+
}, {
|
|
621
|
+
key: "getDomElement",
|
|
622
|
+
value: function getDomElement() {
|
|
623
|
+
return this.$canvas;
|
|
536
624
|
}
|
|
537
|
-
}
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
625
|
+
}, {
|
|
626
|
+
key: "getContext",
|
|
627
|
+
value: function getContext() {
|
|
628
|
+
return this.context;
|
|
629
|
+
}
|
|
630
|
+
}, {
|
|
631
|
+
key: "getBoundingClientRect",
|
|
632
|
+
value: function getBoundingClientRect() {
|
|
633
|
+
if (this.$canvas.getBoundingClientRect) {
|
|
634
|
+
return this.$canvas.getBoundingClientRect();
|
|
635
|
+
}
|
|
636
|
+
}
|
|
637
|
+
}, {
|
|
638
|
+
key: "destroy",
|
|
639
|
+
value: function destroy() {
|
|
542
640
|
// @ts-ignore
|
|
543
|
-
this.$container
|
|
641
|
+
if (this.$container && this.$canvas && this.$canvas.parentNode) {
|
|
642
|
+
// @ts-ignore
|
|
643
|
+
this.$container.removeChild(this.$canvas);
|
|
644
|
+
}
|
|
544
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
|
-
|
|
548
|
-
|
|
549
|
-
var dpr = this.getDPR(); // set canvas width & height
|
|
652
|
+
this.$canvas.width = dpr * width;
|
|
653
|
+
this.$canvas.height = dpr * height; // set CSS style width & height
|
|
550
654
|
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
g.setDOMSize(this.$canvas, width, height);
|
|
655
|
+
g.setDOMSize(this.$canvas, width, height);
|
|
656
|
+
}
|
|
555
657
|
}
|
|
556
|
-
}
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
};
|
|
561
|
-
|
|
562
|
-
_proto.applyCursorStyle = function applyCursorStyle(cursor) {
|
|
563
|
-
if (this.$container && this.$container.style) {
|
|
564
|
-
this.$container.style.cursor = cursor;
|
|
658
|
+
}, {
|
|
659
|
+
key: "getDPR",
|
|
660
|
+
value: function getDPR() {
|
|
661
|
+
return this.dpr;
|
|
565
662
|
}
|
|
566
|
-
}
|
|
663
|
+
}, {
|
|
664
|
+
key: "applyCursorStyle",
|
|
665
|
+
value: function applyCursorStyle(cursor) {
|
|
666
|
+
if (this.$container && this.$container.style) {
|
|
667
|
+
this.$container.style.cursor = cursor;
|
|
668
|
+
}
|
|
669
|
+
}
|
|
670
|
+
}]);
|
|
567
671
|
|
|
568
672
|
return WebGLContextService;
|
|
569
673
|
}();
|
|
@@ -582,32 +686,42 @@ var containerModule = g.Module(function (register) {
|
|
|
582
686
|
});
|
|
583
687
|
var ContextRegisterPlugin = /*#__PURE__*/function () {
|
|
584
688
|
function ContextRegisterPlugin() {
|
|
689
|
+
_classCallCheck(this, ContextRegisterPlugin);
|
|
690
|
+
|
|
585
691
|
this.name = 'webgpu-context-register';
|
|
586
692
|
}
|
|
587
693
|
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
container
|
|
596
|
-
|
|
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
|
+
}]);
|
|
597
705
|
|
|
598
706
|
return ContextRegisterPlugin;
|
|
599
707
|
}();
|
|
600
708
|
|
|
601
709
|
var Renderer = /*#__PURE__*/function (_AbstractRenderer) {
|
|
602
|
-
|
|
710
|
+
_inherits(Renderer, _AbstractRenderer);
|
|
711
|
+
|
|
712
|
+
var _super = _createSuper(Renderer);
|
|
603
713
|
|
|
604
714
|
function Renderer(config) {
|
|
605
715
|
var _this;
|
|
606
716
|
|
|
607
|
-
|
|
717
|
+
_classCallCheck(this, Renderer);
|
|
718
|
+
|
|
719
|
+
_this = _super.call(this, config);
|
|
608
720
|
|
|
609
721
|
_this.registerPlugin(new ContextRegisterPlugin());
|
|
610
722
|
|
|
723
|
+
_this.registerPlugin(new ImageLoader.Plugin());
|
|
724
|
+
|
|
611
725
|
_this.registerPlugin(new WebGPUDevice.Plugin());
|
|
612
726
|
|
|
613
727
|
_this.registerPlugin(new DeviceRenderer.Plugin());
|
|
@@ -619,10 +733,11 @@ var Renderer = /*#__PURE__*/function (_AbstractRenderer) {
|
|
|
619
733
|
return _this;
|
|
620
734
|
}
|
|
621
735
|
|
|
622
|
-
return Renderer;
|
|
736
|
+
return _createClass(Renderer);
|
|
623
737
|
}(g.AbstractRenderer);
|
|
624
738
|
|
|
625
|
-
exports.DomInteraction = DomInteraction__namespace;
|
|
626
739
|
exports.DeviceRenderer = DeviceRenderer__namespace;
|
|
740
|
+
exports.DomInteraction = DomInteraction__namespace;
|
|
741
|
+
exports.HTMLRenderer = HTMLRenderer__namespace;
|
|
627
742
|
exports.WebGPUDevice = WebGPUDevice__namespace;
|
|
628
743
|
exports.Renderer = Renderer;
|