@antv/g-webgpu 1.2.0 → 1.2.3
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 +54 -20
- package/dist/index.js +49 -15
- package/dist/index.umd.js +696 -567
- 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
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import type { RendererPlugin, Syringe } from '@antv/g';
|
|
2
|
+
import type * as DeviceRenderer from '@antv/g-plugin-device-renderer';
|
|
2
3
|
export declare class ContextRegisterPlugin implements RendererPlugin {
|
|
4
|
+
private rendererPlugin;
|
|
3
5
|
name: string;
|
|
6
|
+
constructor(rendererPlugin: DeviceRenderer.Plugin);
|
|
4
7
|
init(container: Syringe.Container): void;
|
|
5
8
|
destroy(container: Syringe.Container): void;
|
|
6
9
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ContextRegisterPlugin.d.ts","sourceRoot":"","sources":["../src/ContextRegisterPlugin.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"ContextRegisterPlugin.d.ts","sourceRoot":"","sources":["../src/ContextRegisterPlugin.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAEvD,OAAO,KAAK,KAAK,cAAc,MAAM,gCAAgC,CAAC;AAWtE,qBAAa,qBAAsB,YAAW,cAAc;IAE9C,OAAO,CAAC,cAAc;IADlC,IAAI,SAA6B;gBACb,cAAc,EAAE,cAAc,CAAC,MAAM;IAEzD,IAAI,CAAC,SAAS,EAAE,OAAO,CAAC,SAAS,GAAG,IAAI;IAMxC,OAAO,CAAC,SAAS,EAAE,OAAO,CAAC,SAAS,GAAG,IAAI;CAI5C"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/// <reference types="@webgpu/types" />
|
|
2
|
+
import type { CanvasLike, DataURLOptions } from '@antv/g';
|
|
3
|
+
import { ContextService } from '@antv/g';
|
|
4
|
+
export declare class WebGPUContextService implements ContextService<GPUCanvasContext> {
|
|
5
|
+
private $container;
|
|
6
|
+
private $canvas;
|
|
7
|
+
private dpr;
|
|
8
|
+
private canvasConfig;
|
|
9
|
+
private deviceRendererPlugin;
|
|
10
|
+
init(): Promise<void>;
|
|
11
|
+
getDomElement(): CanvasLike;
|
|
12
|
+
getContext(): GPUCanvasContext;
|
|
13
|
+
getBoundingClientRect(): DOMRect;
|
|
14
|
+
destroy(): void;
|
|
15
|
+
resize(width: number, height: number): void;
|
|
16
|
+
getDPR(): number;
|
|
17
|
+
applyCursorStyle(cursor: string): void;
|
|
18
|
+
toDataURL(options: Partial<DataURLOptions>): Promise<string>;
|
|
19
|
+
}
|
|
20
|
+
//# sourceMappingURL=WebGPUContextService.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"WebGPUContextService.d.ts","sourceRoot":"","sources":["../src/WebGPUContextService.ts"],"names":[],"mappings":";AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAC1D,OAAO,EAEL,cAAc,EAMf,MAAM,SAAS,CAAC;AAIjB,qBACa,oBAAqB,YAAW,cAAc,CAAC,gBAAgB,CAAC;IAC3E,OAAO,CAAC,UAAU,CAAqB;IACvC,OAAO,CAAC,OAAO,CAAoB;IACnC,OAAO,CAAC,GAAG,CAAS;IAGpB,OAAO,CAAC,YAAY,CAAe;IAGnC,OAAO,CAAC,oBAAoB,CAAwB;IAE9C,IAAI;IAgCV,aAAa;IAIb,UAAU;IAKV,qBAAqB;IAMrB,OAAO;IAQP,MAAM,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM;IAapC,MAAM;IAIN,gBAAgB,CAAC,MAAM,EAAE,MAAM;IAMzB,SAAS,CAAC,OAAO,EAAE,OAAO,CAAC,cAAc,CAAC;CAGjD"}
|
package/dist/index.d.ts.map
CHANGED
|
@@ -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;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;
|
|
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;CAWnD"}
|
package/dist/index.esm.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { inject, CanvasConfig, singleton, ContextService, setDOMSize, isString, isBrowser, Module, AbstractRenderer } from '@antv/g';
|
|
2
|
-
import { Plugin
|
|
1
|
+
import { Syringe, inject, CanvasConfig, singleton, ContextService, setDOMSize, isString, isBrowser, Module, AbstractRenderer } from '@antv/g';
|
|
2
|
+
import { Plugin } from '@antv/g-plugin-device-renderer';
|
|
3
3
|
import * as DeviceRenderer from '@antv/g-plugin-device-renderer';
|
|
4
4
|
export { DeviceRenderer };
|
|
5
5
|
import { Plugin as Plugin$3 } from '@antv/g-plugin-dom-interaction';
|
|
@@ -8,8 +8,8 @@ export { DomInteraction };
|
|
|
8
8
|
import { Plugin as Plugin$4 } from '@antv/g-plugin-html-renderer';
|
|
9
9
|
import * as HTMLRenderer from '@antv/g-plugin-html-renderer';
|
|
10
10
|
export { HTMLRenderer };
|
|
11
|
-
import { Plugin } from '@antv/g-plugin-image-loader';
|
|
12
|
-
import { Plugin as Plugin$
|
|
11
|
+
import { Plugin as Plugin$1 } from '@antv/g-plugin-image-loader';
|
|
12
|
+
import { Plugin as Plugin$2 } from '@antv/g-plugin-webgpu-device';
|
|
13
13
|
import * as WebGPUDevice from '@antv/g-plugin-webgpu-device';
|
|
14
14
|
export { WebGPUDevice };
|
|
15
15
|
|
|
@@ -402,14 +402,15 @@ function _inheritsLoose(subClass, superClass) {
|
|
|
402
402
|
}
|
|
403
403
|
|
|
404
404
|
function _setPrototypeOf(o, p) {
|
|
405
|
-
_setPrototypeOf = Object.setPrototypeOf
|
|
405
|
+
_setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) {
|
|
406
406
|
o.__proto__ = p;
|
|
407
407
|
return o;
|
|
408
408
|
};
|
|
409
|
-
|
|
410
409
|
return _setPrototypeOf(o, p);
|
|
411
410
|
}
|
|
412
411
|
|
|
412
|
+
var DeviceRendererPlugin = Syringe.defineToken('DeviceRendererPlugin');
|
|
413
|
+
|
|
413
414
|
/******************************************************************************
|
|
414
415
|
Copyright (c) Microsoft Corporation.
|
|
415
416
|
|
|
@@ -436,16 +437,16 @@ function __metadata(metadataKey, metadataValue) {
|
|
|
436
437
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(metadataKey, metadataValue);
|
|
437
438
|
}
|
|
438
439
|
|
|
439
|
-
var
|
|
440
|
-
function
|
|
440
|
+
var WebGPUContextService = /*#__PURE__*/function () {
|
|
441
|
+
function WebGPUContextService() {
|
|
441
442
|
this.$container = void 0;
|
|
442
443
|
this.$canvas = void 0;
|
|
443
444
|
this.dpr = void 0;
|
|
444
|
-
this.context = void 0;
|
|
445
445
|
this.canvasConfig = void 0;
|
|
446
|
+
this.deviceRendererPlugin = void 0;
|
|
446
447
|
}
|
|
447
448
|
|
|
448
|
-
var _proto =
|
|
449
|
+
var _proto = WebGPUContextService.prototype;
|
|
449
450
|
|
|
450
451
|
_proto.init = /*#__PURE__*/function () {
|
|
451
452
|
var _init = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
@@ -508,7 +509,8 @@ var WebGLContextService = /*#__PURE__*/function () {
|
|
|
508
509
|
};
|
|
509
510
|
|
|
510
511
|
_proto.getContext = function getContext() {
|
|
511
|
-
|
|
512
|
+
// @ts-ignore
|
|
513
|
+
return this.deviceRendererPlugin.getDevice().canvasContext;
|
|
512
514
|
};
|
|
513
515
|
|
|
514
516
|
_proto.getBoundingClientRect = function getBoundingClientRect() {
|
|
@@ -546,34 +548,65 @@ var WebGLContextService = /*#__PURE__*/function () {
|
|
|
546
548
|
}
|
|
547
549
|
};
|
|
548
550
|
|
|
549
|
-
|
|
551
|
+
_proto.toDataURL = /*#__PURE__*/function () {
|
|
552
|
+
var _toDataURL = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(options) {
|
|
553
|
+
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
554
|
+
while (1) {
|
|
555
|
+
switch (_context2.prev = _context2.next) {
|
|
556
|
+
case 0:
|
|
557
|
+
return _context2.abrupt("return", '');
|
|
558
|
+
|
|
559
|
+
case 1:
|
|
560
|
+
case "end":
|
|
561
|
+
return _context2.stop();
|
|
562
|
+
}
|
|
563
|
+
}
|
|
564
|
+
}, _callee2);
|
|
565
|
+
}));
|
|
566
|
+
|
|
567
|
+
function toDataURL(_x) {
|
|
568
|
+
return _toDataURL.apply(this, arguments);
|
|
569
|
+
}
|
|
570
|
+
|
|
571
|
+
return toDataURL;
|
|
572
|
+
}();
|
|
573
|
+
|
|
574
|
+
return WebGPUContextService;
|
|
550
575
|
}();
|
|
551
576
|
|
|
552
|
-
__decorate([inject(CanvasConfig), __metadata("design:type", Object)],
|
|
577
|
+
__decorate([inject(CanvasConfig), __metadata("design:type", Object)], WebGPUContextService.prototype, "canvasConfig", void 0);
|
|
553
578
|
|
|
554
|
-
|
|
579
|
+
__decorate([inject(DeviceRendererPlugin), __metadata("design:type", Plugin)], WebGPUContextService.prototype, "deviceRendererPlugin", void 0);
|
|
580
|
+
|
|
581
|
+
WebGPUContextService = __decorate([singleton({
|
|
555
582
|
token: ContextService
|
|
556
|
-
})],
|
|
583
|
+
})], WebGPUContextService);
|
|
557
584
|
|
|
558
585
|
var containerModule = Module(function (register) {
|
|
559
586
|
/**
|
|
560
587
|
* implements ContextService
|
|
561
588
|
*/
|
|
562
|
-
register(
|
|
589
|
+
register(WebGPUContextService);
|
|
563
590
|
});
|
|
564
591
|
var ContextRegisterPlugin = /*#__PURE__*/function () {
|
|
565
|
-
function ContextRegisterPlugin() {
|
|
592
|
+
function ContextRegisterPlugin(rendererPlugin) {
|
|
593
|
+
this.rendererPlugin = void 0;
|
|
566
594
|
this.name = 'webgpu-context-register';
|
|
595
|
+
this.rendererPlugin = rendererPlugin;
|
|
567
596
|
}
|
|
568
597
|
|
|
569
598
|
var _proto = ContextRegisterPlugin.prototype;
|
|
570
599
|
|
|
571
600
|
_proto.init = function init(container) {
|
|
601
|
+
container.register(DeviceRendererPlugin, {
|
|
602
|
+
useValue: this.rendererPlugin
|
|
603
|
+
});
|
|
572
604
|
container.load(containerModule, true);
|
|
573
605
|
};
|
|
574
606
|
|
|
575
607
|
_proto.destroy = function destroy(container) {
|
|
576
608
|
container.unload(containerModule);
|
|
609
|
+
container.remove(DeviceRendererPlugin);
|
|
577
610
|
};
|
|
578
611
|
|
|
579
612
|
return ContextRegisterPlugin;
|
|
@@ -586,15 +619,16 @@ var Renderer = /*#__PURE__*/function (_AbstractRenderer) {
|
|
|
586
619
|
var _this;
|
|
587
620
|
|
|
588
621
|
_this = _AbstractRenderer.call(this, config) || this;
|
|
622
|
+
var deviceRendererPlugin = new Plugin();
|
|
589
623
|
|
|
590
|
-
_this.registerPlugin(new ContextRegisterPlugin());
|
|
591
|
-
|
|
592
|
-
_this.registerPlugin(new Plugin());
|
|
624
|
+
_this.registerPlugin(new ContextRegisterPlugin(deviceRendererPlugin));
|
|
593
625
|
|
|
594
626
|
_this.registerPlugin(new Plugin$1());
|
|
595
627
|
|
|
596
628
|
_this.registerPlugin(new Plugin$2());
|
|
597
629
|
|
|
630
|
+
_this.registerPlugin(deviceRendererPlugin);
|
|
631
|
+
|
|
598
632
|
_this.registerPlugin(new Plugin$3());
|
|
599
633
|
|
|
600
634
|
_this.registerPlugin(new Plugin$4());
|
package/dist/index.js
CHANGED
|
@@ -423,14 +423,15 @@ function _inheritsLoose(subClass, superClass) {
|
|
|
423
423
|
}
|
|
424
424
|
|
|
425
425
|
function _setPrototypeOf(o, p) {
|
|
426
|
-
_setPrototypeOf = Object.setPrototypeOf
|
|
426
|
+
_setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) {
|
|
427
427
|
o.__proto__ = p;
|
|
428
428
|
return o;
|
|
429
429
|
};
|
|
430
|
-
|
|
431
430
|
return _setPrototypeOf(o, p);
|
|
432
431
|
}
|
|
433
432
|
|
|
433
|
+
var DeviceRendererPlugin = g.Syringe.defineToken('DeviceRendererPlugin');
|
|
434
|
+
|
|
434
435
|
/******************************************************************************
|
|
435
436
|
Copyright (c) Microsoft Corporation.
|
|
436
437
|
|
|
@@ -457,16 +458,16 @@ function __metadata(metadataKey, metadataValue) {
|
|
|
457
458
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(metadataKey, metadataValue);
|
|
458
459
|
}
|
|
459
460
|
|
|
460
|
-
var
|
|
461
|
-
function
|
|
461
|
+
var WebGPUContextService = /*#__PURE__*/function () {
|
|
462
|
+
function WebGPUContextService() {
|
|
462
463
|
this.$container = void 0;
|
|
463
464
|
this.$canvas = void 0;
|
|
464
465
|
this.dpr = void 0;
|
|
465
|
-
this.context = void 0;
|
|
466
466
|
this.canvasConfig = void 0;
|
|
467
|
+
this.deviceRendererPlugin = void 0;
|
|
467
468
|
}
|
|
468
469
|
|
|
469
|
-
var _proto =
|
|
470
|
+
var _proto = WebGPUContextService.prototype;
|
|
470
471
|
|
|
471
472
|
_proto.init = /*#__PURE__*/function () {
|
|
472
473
|
var _init = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
@@ -529,7 +530,8 @@ var WebGLContextService = /*#__PURE__*/function () {
|
|
|
529
530
|
};
|
|
530
531
|
|
|
531
532
|
_proto.getContext = function getContext() {
|
|
532
|
-
|
|
533
|
+
// @ts-ignore
|
|
534
|
+
return this.deviceRendererPlugin.getDevice().canvasContext;
|
|
533
535
|
};
|
|
534
536
|
|
|
535
537
|
_proto.getBoundingClientRect = function getBoundingClientRect() {
|
|
@@ -567,34 +569,65 @@ var WebGLContextService = /*#__PURE__*/function () {
|
|
|
567
569
|
}
|
|
568
570
|
};
|
|
569
571
|
|
|
570
|
-
|
|
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);
|
|
590
|
+
}
|
|
591
|
+
|
|
592
|
+
return toDataURL;
|
|
593
|
+
}();
|
|
594
|
+
|
|
595
|
+
return WebGPUContextService;
|
|
571
596
|
}();
|
|
572
597
|
|
|
573
|
-
__decorate([g.inject(g.CanvasConfig), __metadata("design:type", Object)],
|
|
598
|
+
__decorate([g.inject(g.CanvasConfig), __metadata("design:type", Object)], WebGPUContextService.prototype, "canvasConfig", void 0);
|
|
574
599
|
|
|
575
|
-
|
|
600
|
+
__decorate([g.inject(DeviceRendererPlugin), __metadata("design:type", DeviceRenderer.Plugin)], WebGPUContextService.prototype, "deviceRendererPlugin", void 0);
|
|
601
|
+
|
|
602
|
+
WebGPUContextService = __decorate([g.singleton({
|
|
576
603
|
token: g.ContextService
|
|
577
|
-
})],
|
|
604
|
+
})], WebGPUContextService);
|
|
578
605
|
|
|
579
606
|
var containerModule = g.Module(function (register) {
|
|
580
607
|
/**
|
|
581
608
|
* implements ContextService
|
|
582
609
|
*/
|
|
583
|
-
register(
|
|
610
|
+
register(WebGPUContextService);
|
|
584
611
|
});
|
|
585
612
|
var ContextRegisterPlugin = /*#__PURE__*/function () {
|
|
586
|
-
function ContextRegisterPlugin() {
|
|
613
|
+
function ContextRegisterPlugin(rendererPlugin) {
|
|
614
|
+
this.rendererPlugin = void 0;
|
|
587
615
|
this.name = 'webgpu-context-register';
|
|
616
|
+
this.rendererPlugin = rendererPlugin;
|
|
588
617
|
}
|
|
589
618
|
|
|
590
619
|
var _proto = ContextRegisterPlugin.prototype;
|
|
591
620
|
|
|
592
621
|
_proto.init = function init(container) {
|
|
622
|
+
container.register(DeviceRendererPlugin, {
|
|
623
|
+
useValue: this.rendererPlugin
|
|
624
|
+
});
|
|
593
625
|
container.load(containerModule, true);
|
|
594
626
|
};
|
|
595
627
|
|
|
596
628
|
_proto.destroy = function destroy(container) {
|
|
597
629
|
container.unload(containerModule);
|
|
630
|
+
container.remove(DeviceRendererPlugin);
|
|
598
631
|
};
|
|
599
632
|
|
|
600
633
|
return ContextRegisterPlugin;
|
|
@@ -607,14 +640,15 @@ var Renderer = /*#__PURE__*/function (_AbstractRenderer) {
|
|
|
607
640
|
var _this;
|
|
608
641
|
|
|
609
642
|
_this = _AbstractRenderer.call(this, config) || this;
|
|
643
|
+
var deviceRendererPlugin = new DeviceRenderer.Plugin();
|
|
610
644
|
|
|
611
|
-
_this.registerPlugin(new ContextRegisterPlugin());
|
|
645
|
+
_this.registerPlugin(new ContextRegisterPlugin(deviceRendererPlugin));
|
|
612
646
|
|
|
613
647
|
_this.registerPlugin(new ImageLoader.Plugin());
|
|
614
648
|
|
|
615
649
|
_this.registerPlugin(new WebGPUDevice.Plugin());
|
|
616
650
|
|
|
617
|
-
_this.registerPlugin(
|
|
651
|
+
_this.registerPlugin(deviceRendererPlugin);
|
|
618
652
|
|
|
619
653
|
_this.registerPlugin(new DomInteraction.Plugin());
|
|
620
654
|
|