@antv/g-webgpu 1.2.1 → 1.3.0
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/ContextRegisterPlugin.d.ts +3 -0
- package/dist/ContextRegisterPlugin.d.ts.map +1 -1
- package/dist/WebGPUContextService.d.ts +20 -0
- package/dist/WebGPUContextService.d.ts.map +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.esm.js +144 -220
- package/dist/index.js +139 -215
- package/dist/index.umd.js +7206 -8299
- package/dist/index.umd.min.js +6 -6
- package/dist/tokens.d.ts +3 -0
- package/dist/tokens.d.ts.map +1 -0
- package/package.json +7 -7
- package/dist/WebGLContextService.d.ts +0 -18
- package/dist/WebGLContextService.d.ts.map +0 -1
package/dist/index.js
CHANGED
|
@@ -415,54 +415,11 @@ function _asyncToGenerator(fn) {
|
|
|
415
415
|
};
|
|
416
416
|
}
|
|
417
417
|
|
|
418
|
-
function
|
|
419
|
-
|
|
420
|
-
|
|
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
|
-
}
|
|
418
|
+
function _inheritsLoose(subClass, superClass) {
|
|
419
|
+
subClass.prototype = Object.create(superClass.prototype);
|
|
420
|
+
subClass.prototype.constructor = subClass;
|
|
447
421
|
|
|
448
|
-
subClass
|
|
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
|
-
}
|
|
460
|
-
|
|
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);
|
|
422
|
+
_setPrototypeOf(subClass, superClass);
|
|
466
423
|
}
|
|
467
424
|
|
|
468
425
|
function _setPrototypeOf(o, p) {
|
|
@@ -473,55 +430,7 @@ function _setPrototypeOf(o, p) {
|
|
|
473
430
|
return _setPrototypeOf(o, p);
|
|
474
431
|
}
|
|
475
432
|
|
|
476
|
-
|
|
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
|
-
}
|
|
433
|
+
var DeviceRendererPlugin = g.Syringe.defineToken('DeviceRendererPlugin');
|
|
525
434
|
|
|
526
435
|
/******************************************************************************
|
|
527
436
|
Copyright (c) Microsoft Corporation.
|
|
@@ -549,182 +458,197 @@ function __metadata(metadataKey, metadataValue) {
|
|
|
549
458
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(metadataKey, metadataValue);
|
|
550
459
|
}
|
|
551
460
|
|
|
552
|
-
var
|
|
553
|
-
function
|
|
554
|
-
_classCallCheck(this, WebGLContextService);
|
|
555
|
-
|
|
461
|
+
var WebGPUContextService = /*#__PURE__*/function () {
|
|
462
|
+
function WebGPUContextService() {
|
|
556
463
|
this.$container = void 0;
|
|
557
464
|
this.$canvas = void 0;
|
|
558
465
|
this.dpr = void 0;
|
|
559
|
-
this.context = void 0;
|
|
560
466
|
this.canvasConfig = void 0;
|
|
467
|
+
this.deviceRendererPlugin = void 0;
|
|
561
468
|
}
|
|
562
469
|
|
|
563
|
-
|
|
564
|
-
key: "init",
|
|
565
|
-
value: function () {
|
|
566
|
-
var _init = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
567
|
-
var _this$canvasConfig, container, canvas, devicePixelRatio, $canvas, dpr;
|
|
470
|
+
var _proto = WebGPUContextService.prototype;
|
|
568
471
|
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
case 0:
|
|
573
|
-
_this$canvasConfig = this.canvasConfig, container = _this$canvasConfig.container, canvas = _this$canvasConfig.canvas, devicePixelRatio = _this$canvasConfig.devicePixelRatio;
|
|
472
|
+
_proto.init = /*#__PURE__*/function () {
|
|
473
|
+
var _init = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
474
|
+
var _this$canvasConfig, container, canvas, devicePixelRatio, $canvas, dpr;
|
|
574
475
|
|
|
575
|
-
|
|
576
|
-
|
|
476
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
477
|
+
while (1) {
|
|
478
|
+
switch (_context.prev = _context.next) {
|
|
479
|
+
case 0:
|
|
480
|
+
_this$canvasConfig = this.canvasConfig, container = _this$canvasConfig.container, canvas = _this$canvasConfig.canvas, devicePixelRatio = _this$canvasConfig.devicePixelRatio;
|
|
577
481
|
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
}
|
|
482
|
+
if (canvas) {
|
|
483
|
+
this.$canvas = canvas;
|
|
581
484
|
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
}
|
|
585
|
-
// create container
|
|
586
|
-
this.$container = g.isString(container) ? document.getElementById(container) : container;
|
|
485
|
+
if (container && canvas.parentElement !== container) {
|
|
486
|
+
container.appendChild(canvas);
|
|
487
|
+
}
|
|
587
488
|
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
489
|
+
this.$container = canvas.parentElement;
|
|
490
|
+
this.canvasConfig.container = this.$container;
|
|
491
|
+
} else if (container) {
|
|
492
|
+
// create container
|
|
493
|
+
this.$container = g.isString(container) ? document.getElementById(container) : container;
|
|
592
494
|
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
495
|
+
if (this.$container) {
|
|
496
|
+
// create canvas
|
|
497
|
+
$canvas = document.createElement('canvas');
|
|
498
|
+
this.$container.appendChild($canvas);
|
|
596
499
|
|
|
597
|
-
|
|
500
|
+
if (!this.$container.style.position) {
|
|
501
|
+
this.$container.style.position = 'relative';
|
|
598
502
|
}
|
|
599
|
-
} // use user-defined dpr first
|
|
600
503
|
|
|
504
|
+
this.$canvas = $canvas;
|
|
505
|
+
}
|
|
506
|
+
} // use user-defined dpr first
|
|
601
507
|
|
|
602
|
-
dpr = devicePixelRatio || g.isBrowser && window.devicePixelRatio || 1;
|
|
603
|
-
dpr = dpr >= 1 ? Math.ceil(dpr) : 1;
|
|
604
|
-
this.dpr = dpr;
|
|
605
508
|
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
}
|
|
610
|
-
}
|
|
611
|
-
}, _callee, this);
|
|
612
|
-
}));
|
|
509
|
+
dpr = devicePixelRatio || g.isBrowser && window.devicePixelRatio || 1;
|
|
510
|
+
dpr = dpr >= 1 ? Math.ceil(dpr) : 1;
|
|
511
|
+
this.dpr = dpr;
|
|
613
512
|
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
513
|
+
case 5:
|
|
514
|
+
case "end":
|
|
515
|
+
return _context.stop();
|
|
516
|
+
}
|
|
517
|
+
}
|
|
518
|
+
}, _callee, this);
|
|
519
|
+
}));
|
|
617
520
|
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
}, {
|
|
621
|
-
key: "getDomElement",
|
|
622
|
-
value: function getDomElement() {
|
|
623
|
-
return this.$canvas;
|
|
521
|
+
function init() {
|
|
522
|
+
return _init.apply(this, arguments);
|
|
624
523
|
}
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
524
|
+
|
|
525
|
+
return init;
|
|
526
|
+
}();
|
|
527
|
+
|
|
528
|
+
_proto.getDomElement = function getDomElement() {
|
|
529
|
+
return this.$canvas;
|
|
530
|
+
};
|
|
531
|
+
|
|
532
|
+
_proto.getContext = function getContext() {
|
|
533
|
+
// @ts-ignore
|
|
534
|
+
return this.deviceRendererPlugin.getDevice().canvasContext;
|
|
535
|
+
};
|
|
536
|
+
|
|
537
|
+
_proto.getBoundingClientRect = function getBoundingClientRect() {
|
|
538
|
+
if (this.$canvas.getBoundingClientRect) {
|
|
539
|
+
return this.$canvas.getBoundingClientRect();
|
|
636
540
|
}
|
|
637
|
-
}
|
|
638
|
-
|
|
639
|
-
|
|
541
|
+
};
|
|
542
|
+
|
|
543
|
+
_proto.destroy = function destroy() {
|
|
544
|
+
// @ts-ignore
|
|
545
|
+
if (this.$container && this.$canvas && this.$canvas.parentNode) {
|
|
640
546
|
// @ts-ignore
|
|
641
|
-
|
|
642
|
-
// @ts-ignore
|
|
643
|
-
this.$container.removeChild(this.$canvas);
|
|
644
|
-
}
|
|
547
|
+
this.$container.removeChild(this.$canvas);
|
|
645
548
|
}
|
|
646
|
-
}
|
|
647
|
-
key: "resize",
|
|
648
|
-
value: function resize(width, height) {
|
|
649
|
-
if (this.$canvas) {
|
|
650
|
-
var dpr = this.getDPR(); // set canvas width & height
|
|
549
|
+
};
|
|
651
550
|
|
|
652
|
-
|
|
653
|
-
|
|
551
|
+
_proto.resize = function resize(width, height) {
|
|
552
|
+
if (this.$canvas) {
|
|
553
|
+
var dpr = this.getDPR(); // set canvas width & height
|
|
654
554
|
|
|
655
|
-
|
|
656
|
-
|
|
555
|
+
this.$canvas.width = dpr * width;
|
|
556
|
+
this.$canvas.height = dpr * height; // set CSS style width & height
|
|
557
|
+
|
|
558
|
+
g.setDOMSize(this.$canvas, width, height);
|
|
657
559
|
}
|
|
658
|
-
}
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
560
|
+
};
|
|
561
|
+
|
|
562
|
+
_proto.getDPR = function getDPR() {
|
|
563
|
+
return this.dpr;
|
|
564
|
+
};
|
|
565
|
+
|
|
566
|
+
_proto.applyCursorStyle = function applyCursorStyle(cursor) {
|
|
567
|
+
if (this.$container && this.$container.style) {
|
|
568
|
+
this.$container.style.cursor = cursor;
|
|
662
569
|
}
|
|
663
|
-
}
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
570
|
+
};
|
|
571
|
+
|
|
572
|
+
_proto.toDataURL = /*#__PURE__*/function () {
|
|
573
|
+
var _toDataURL = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(options) {
|
|
574
|
+
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
575
|
+
while (1) {
|
|
576
|
+
switch (_context2.prev = _context2.next) {
|
|
577
|
+
case 0:
|
|
578
|
+
return _context2.abrupt("return", '');
|
|
579
|
+
|
|
580
|
+
case 1:
|
|
581
|
+
case "end":
|
|
582
|
+
return _context2.stop();
|
|
583
|
+
}
|
|
584
|
+
}
|
|
585
|
+
}, _callee2);
|
|
586
|
+
}));
|
|
587
|
+
|
|
588
|
+
function toDataURL(_x) {
|
|
589
|
+
return _toDataURL.apply(this, arguments);
|
|
669
590
|
}
|
|
670
|
-
}]);
|
|
671
591
|
|
|
672
|
-
|
|
592
|
+
return toDataURL;
|
|
593
|
+
}();
|
|
594
|
+
|
|
595
|
+
return WebGPUContextService;
|
|
673
596
|
}();
|
|
674
597
|
|
|
675
|
-
__decorate([g.inject(g.CanvasConfig), __metadata("design:type", Object)],
|
|
598
|
+
__decorate([g.inject(g.CanvasConfig), __metadata("design:type", Object)], WebGPUContextService.prototype, "canvasConfig", void 0);
|
|
676
599
|
|
|
677
|
-
|
|
600
|
+
__decorate([g.inject(DeviceRendererPlugin), __metadata("design:type", DeviceRenderer.Plugin)], WebGPUContextService.prototype, "deviceRendererPlugin", void 0);
|
|
601
|
+
|
|
602
|
+
WebGPUContextService = __decorate([g.singleton({
|
|
678
603
|
token: g.ContextService
|
|
679
|
-
})],
|
|
604
|
+
})], WebGPUContextService);
|
|
680
605
|
|
|
681
606
|
var containerModule = g.Module(function (register) {
|
|
682
607
|
/**
|
|
683
608
|
* implements ContextService
|
|
684
609
|
*/
|
|
685
|
-
register(
|
|
610
|
+
register(WebGPUContextService);
|
|
686
611
|
});
|
|
687
612
|
var ContextRegisterPlugin = /*#__PURE__*/function () {
|
|
688
|
-
function ContextRegisterPlugin() {
|
|
689
|
-
|
|
690
|
-
|
|
613
|
+
function ContextRegisterPlugin(rendererPlugin) {
|
|
614
|
+
this.rendererPlugin = void 0;
|
|
691
615
|
this.name = 'webgpu-context-register';
|
|
616
|
+
this.rendererPlugin = rendererPlugin;
|
|
692
617
|
}
|
|
693
618
|
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
619
|
+
var _proto = ContextRegisterPlugin.prototype;
|
|
620
|
+
|
|
621
|
+
_proto.init = function init(container) {
|
|
622
|
+
container.register(DeviceRendererPlugin, {
|
|
623
|
+
useValue: this.rendererPlugin
|
|
624
|
+
});
|
|
625
|
+
container.load(containerModule, true);
|
|
626
|
+
};
|
|
627
|
+
|
|
628
|
+
_proto.destroy = function destroy(container) {
|
|
629
|
+
container.unload(containerModule);
|
|
630
|
+
container.remove(DeviceRendererPlugin);
|
|
631
|
+
};
|
|
705
632
|
|
|
706
633
|
return ContextRegisterPlugin;
|
|
707
634
|
}();
|
|
708
635
|
|
|
709
636
|
var Renderer = /*#__PURE__*/function (_AbstractRenderer) {
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
var _super = _createSuper(Renderer);
|
|
637
|
+
_inheritsLoose(Renderer, _AbstractRenderer);
|
|
713
638
|
|
|
714
639
|
function Renderer(config) {
|
|
715
640
|
var _this;
|
|
716
641
|
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
_this = _super.call(this, config);
|
|
642
|
+
_this = _AbstractRenderer.call(this, config) || this;
|
|
643
|
+
var deviceRendererPlugin = new DeviceRenderer.Plugin();
|
|
720
644
|
|
|
721
|
-
_this.registerPlugin(new ContextRegisterPlugin());
|
|
645
|
+
_this.registerPlugin(new ContextRegisterPlugin(deviceRendererPlugin));
|
|
722
646
|
|
|
723
647
|
_this.registerPlugin(new ImageLoader.Plugin());
|
|
724
648
|
|
|
725
649
|
_this.registerPlugin(new WebGPUDevice.Plugin());
|
|
726
650
|
|
|
727
|
-
_this.registerPlugin(
|
|
651
|
+
_this.registerPlugin(deviceRendererPlugin);
|
|
728
652
|
|
|
729
653
|
_this.registerPlugin(new DomInteraction.Plugin());
|
|
730
654
|
|
|
@@ -733,7 +657,7 @@ var Renderer = /*#__PURE__*/function (_AbstractRenderer) {
|
|
|
733
657
|
return _this;
|
|
734
658
|
}
|
|
735
659
|
|
|
736
|
-
return
|
|
660
|
+
return Renderer;
|
|
737
661
|
}(g.AbstractRenderer);
|
|
738
662
|
|
|
739
663
|
exports.DeviceRenderer = DeviceRenderer__namespace;
|