@antv/g-webgpu 1.7.52 → 1.7.53
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 +197 -82
- package/dist/index.js +197 -82
- package/dist/index.umd.js +8306 -6773
- package/dist/index.umd.min.js +1 -1
- package/package.json +3 -3
package/dist/index.esm.js
CHANGED
|
@@ -345,10 +345,49 @@ function _asyncToGenerator(fn) {
|
|
|
345
345
|
});
|
|
346
346
|
};
|
|
347
347
|
}
|
|
348
|
-
function
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
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);
|
|
352
391
|
}
|
|
353
392
|
function _setPrototypeOf(o, p) {
|
|
354
393
|
_setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) {
|
|
@@ -357,9 +396,63 @@ function _setPrototypeOf(o, p) {
|
|
|
357
396
|
};
|
|
358
397
|
return _setPrototypeOf(o, p);
|
|
359
398
|
}
|
|
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
|
+
}
|
|
360
452
|
|
|
361
453
|
var WebGPUContextService = /*#__PURE__*/function () {
|
|
362
454
|
function WebGPUContextService(context) {
|
|
455
|
+
_classCallCheck(this, WebGPUContextService);
|
|
363
456
|
this.$container = void 0;
|
|
364
457
|
this.$canvas = void 0;
|
|
365
458
|
this.dpr = void 0;
|
|
@@ -369,13 +462,13 @@ var WebGPUContextService = /*#__PURE__*/function () {
|
|
|
369
462
|
// @ts-ignore
|
|
370
463
|
this.deviceRendererPlugin = context.deviceRendererPlugin;
|
|
371
464
|
}
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
var
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
switch (_context.prev = _context.next) {
|
|
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) {
|
|
379
472
|
case 0:
|
|
380
473
|
_this$canvasConfig = this.canvasConfig, container = _this$canvasConfig.container, canvas = _this$canvasConfig.canvas;
|
|
381
474
|
if (canvas) {
|
|
@@ -403,105 +496,127 @@ var WebGPUContextService = /*#__PURE__*/function () {
|
|
|
403
496
|
case "end":
|
|
404
497
|
return _context.stop();
|
|
405
498
|
}
|
|
406
|
-
}
|
|
407
|
-
}
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
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;
|
|
411
510
|
}
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
_proto.getContext = function getContext() {
|
|
418
|
-
// @ts-ignore
|
|
419
|
-
return this.deviceRendererPlugin.getDevice().canvasContext;
|
|
420
|
-
};
|
|
421
|
-
_proto.getBoundingClientRect = function getBoundingClientRect() {
|
|
422
|
-
if (this.$canvas.getBoundingClientRect) {
|
|
423
|
-
return this.$canvas.getBoundingClientRect();
|
|
511
|
+
}, {
|
|
512
|
+
key: "getContext",
|
|
513
|
+
value: function getContext() {
|
|
514
|
+
// @ts-ignore
|
|
515
|
+
return this.deviceRendererPlugin.getDevice().canvasContext;
|
|
424
516
|
}
|
|
425
|
-
}
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
517
|
+
}, {
|
|
518
|
+
key: "getBoundingClientRect",
|
|
519
|
+
value: function getBoundingClientRect() {
|
|
520
|
+
if (this.$canvas.getBoundingClientRect) {
|
|
521
|
+
return this.$canvas.getBoundingClientRect();
|
|
522
|
+
}
|
|
523
|
+
}
|
|
524
|
+
}, {
|
|
525
|
+
key: "destroy",
|
|
526
|
+
value: function destroy() {
|
|
429
527
|
// @ts-ignore
|
|
430
|
-
this.$container
|
|
528
|
+
if (this.$container && this.$canvas && this.$canvas.parentNode) {
|
|
529
|
+
// @ts-ignore
|
|
530
|
+
this.$container.removeChild(this.$canvas);
|
|
531
|
+
}
|
|
431
532
|
}
|
|
432
|
-
}
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
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
|
+
}
|
|
446
549
|
}
|
|
447
|
-
}
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
_proto.applyCursorStyle = function applyCursorStyle(cursor) {
|
|
452
|
-
if (this.$container && this.$container.style) {
|
|
453
|
-
this.$container.style.cursor = cursor;
|
|
550
|
+
}, {
|
|
551
|
+
key: "getDPR",
|
|
552
|
+
value: function getDPR() {
|
|
553
|
+
return this.dpr;
|
|
454
554
|
}
|
|
455
|
-
}
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
555
|
+
}, {
|
|
556
|
+
key: "applyCursorStyle",
|
|
557
|
+
value: function applyCursorStyle(cursor) {
|
|
558
|
+
if (this.$container && this.$container.style) {
|
|
559
|
+
this.$container.style.cursor = cursor;
|
|
560
|
+
}
|
|
561
|
+
}
|
|
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) {
|
|
461
568
|
case 0:
|
|
462
569
|
return _context2.abrupt("return", '');
|
|
463
570
|
case 1:
|
|
464
571
|
case "end":
|
|
465
572
|
return _context2.stop();
|
|
466
573
|
}
|
|
467
|
-
}
|
|
468
|
-
}
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
}
|
|
574
|
+
}, _callee2);
|
|
575
|
+
}));
|
|
576
|
+
function toDataURL(_x) {
|
|
577
|
+
return _toDataURL.apply(this, arguments);
|
|
578
|
+
}
|
|
579
|
+
return toDataURL;
|
|
580
|
+
}()
|
|
581
|
+
}]);
|
|
475
582
|
return WebGPUContextService;
|
|
476
583
|
}();
|
|
477
584
|
|
|
478
585
|
var ContextRegisterPlugin = /*#__PURE__*/function (_AbstractRendererPlug) {
|
|
479
|
-
|
|
586
|
+
_inherits(ContextRegisterPlugin, _AbstractRendererPlug);
|
|
587
|
+
var _super = _createSuper(ContextRegisterPlugin);
|
|
480
588
|
function ContextRegisterPlugin(rendererPlugin) {
|
|
481
589
|
var _this;
|
|
482
|
-
|
|
590
|
+
_classCallCheck(this, ContextRegisterPlugin);
|
|
591
|
+
_this = _super.call(this);
|
|
483
592
|
_this.rendererPlugin = void 0;
|
|
484
593
|
_this.name = 'webgpu-context-register';
|
|
485
594
|
_this.rendererPlugin = rendererPlugin;
|
|
486
595
|
return _this;
|
|
487
596
|
}
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
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
|
+
}]);
|
|
497
610
|
return ContextRegisterPlugin;
|
|
498
611
|
}(AbstractRendererPlugin);
|
|
499
612
|
|
|
500
613
|
var Renderer = /*#__PURE__*/function (_AbstractRenderer) {
|
|
501
|
-
|
|
614
|
+
_inherits(Renderer, _AbstractRenderer);
|
|
615
|
+
var _super = _createSuper(Renderer);
|
|
502
616
|
function Renderer(config) {
|
|
503
617
|
var _this;
|
|
504
|
-
|
|
618
|
+
_classCallCheck(this, Renderer);
|
|
619
|
+
_this = _super.call(this, config);
|
|
505
620
|
var deviceRendererPlugin = new Plugin();
|
|
506
621
|
_this.registerPlugin(new ContextRegisterPlugin(deviceRendererPlugin));
|
|
507
622
|
_this.registerPlugin(new Plugin$1());
|
|
@@ -511,7 +626,7 @@ var Renderer = /*#__PURE__*/function (_AbstractRenderer) {
|
|
|
511
626
|
_this.registerPlugin(new Plugin$4());
|
|
512
627
|
return _this;
|
|
513
628
|
}
|
|
514
|
-
return Renderer;
|
|
629
|
+
return _createClass(Renderer);
|
|
515
630
|
}(AbstractRenderer);
|
|
516
631
|
|
|
517
632
|
export { Renderer };
|