@antv/g-webgpu 1.7.35 → 1.7.36
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 +111 -230
- package/dist/index.js +111 -230
- package/dist/index.umd.js +6767 -8365
- package/dist/index.umd.min.js +1 -1
- package/package.json +7 -7
package/dist/index.esm.js
CHANGED
|
@@ -345,49 +345,10 @@ function _asyncToGenerator(fn) {
|
|
|
345
345
|
});
|
|
346
346
|
};
|
|
347
347
|
}
|
|
348
|
-
function
|
|
349
|
-
|
|
350
|
-
|
|
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);
|
|
348
|
+
function _inheritsLoose(subClass, superClass) {
|
|
349
|
+
subClass.prototype = Object.create(superClass.prototype);
|
|
350
|
+
subClass.prototype.constructor = subClass;
|
|
351
|
+
_setPrototypeOf(subClass, superClass);
|
|
391
352
|
}
|
|
392
353
|
function _setPrototypeOf(o, p) {
|
|
393
354
|
_setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) {
|
|
@@ -396,63 +357,9 @@ function _setPrototypeOf(o, p) {
|
|
|
396
357
|
};
|
|
397
358
|
return _setPrototypeOf(o, p);
|
|
398
359
|
}
|
|
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
|
-
}
|
|
452
360
|
|
|
453
361
|
var WebGPUContextService = /*#__PURE__*/function () {
|
|
454
362
|
function WebGPUContextService(context) {
|
|
455
|
-
_classCallCheck(this, WebGPUContextService);
|
|
456
363
|
this.$container = void 0;
|
|
457
364
|
this.$canvas = void 0;
|
|
458
365
|
this.dpr = void 0;
|
|
@@ -462,165 +369,139 @@ var WebGPUContextService = /*#__PURE__*/function () {
|
|
|
462
369
|
// @ts-ignore
|
|
463
370
|
this.deviceRendererPlugin = context.deviceRendererPlugin;
|
|
464
371
|
}
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
var
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
this.$container.style.position = 'relative';
|
|
491
|
-
}
|
|
492
|
-
this.$canvas = $canvas;
|
|
372
|
+
var _proto = WebGPUContextService.prototype;
|
|
373
|
+
_proto.init = /*#__PURE__*/function () {
|
|
374
|
+
var _init = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
375
|
+
var _this$canvasConfig, container, canvas, $canvas;
|
|
376
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
377
|
+
while (1) {
|
|
378
|
+
switch (_context.prev = _context.next) {
|
|
379
|
+
case 0:
|
|
380
|
+
_this$canvasConfig = this.canvasConfig, container = _this$canvasConfig.container, canvas = _this$canvasConfig.canvas;
|
|
381
|
+
if (canvas) {
|
|
382
|
+
this.$canvas = canvas;
|
|
383
|
+
if (container && canvas.parentElement !== container) {
|
|
384
|
+
container.appendChild(canvas);
|
|
385
|
+
}
|
|
386
|
+
this.$container = canvas.parentElement;
|
|
387
|
+
this.canvasConfig.container = this.$container;
|
|
388
|
+
} else if (container) {
|
|
389
|
+
// create container
|
|
390
|
+
this.$container = isString(container) ? document.getElementById(container) : container;
|
|
391
|
+
if (this.$container) {
|
|
392
|
+
// create canvas
|
|
393
|
+
$canvas = document.createElement('canvas');
|
|
394
|
+
this.$container.appendChild($canvas);
|
|
395
|
+
if (!this.$container.style.position) {
|
|
396
|
+
this.$container.style.position = 'relative';
|
|
493
397
|
}
|
|
398
|
+
this.$canvas = $canvas;
|
|
494
399
|
}
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
400
|
+
}
|
|
401
|
+
this.resize(this.canvasConfig.width, this.canvasConfig.height);
|
|
402
|
+
case 3:
|
|
403
|
+
case "end":
|
|
404
|
+
return _context.stop();
|
|
500
405
|
}
|
|
501
|
-
}
|
|
502
|
-
})
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
return init;
|
|
507
|
-
}()
|
|
508
|
-
}, {
|
|
509
|
-
key: "getDomElement",
|
|
510
|
-
value: function getDomElement() {
|
|
511
|
-
return this.$canvas;
|
|
512
|
-
}
|
|
513
|
-
}, {
|
|
514
|
-
key: "getContext",
|
|
515
|
-
value: function getContext() {
|
|
516
|
-
// @ts-ignore
|
|
517
|
-
return this.deviceRendererPlugin.getDevice().canvasContext;
|
|
406
|
+
}
|
|
407
|
+
}, _callee, this);
|
|
408
|
+
}));
|
|
409
|
+
function init() {
|
|
410
|
+
return _init.apply(this, arguments);
|
|
518
411
|
}
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
412
|
+
return init;
|
|
413
|
+
}();
|
|
414
|
+
_proto.getDomElement = function getDomElement() {
|
|
415
|
+
return this.$canvas;
|
|
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();
|
|
525
424
|
}
|
|
526
|
-
}
|
|
527
|
-
|
|
528
|
-
|
|
425
|
+
};
|
|
426
|
+
_proto.destroy = function destroy() {
|
|
427
|
+
// @ts-ignore
|
|
428
|
+
if (this.$container && this.$canvas && this.$canvas.parentNode) {
|
|
529
429
|
// @ts-ignore
|
|
530
|
-
|
|
531
|
-
// @ts-ignore
|
|
532
|
-
this.$container.removeChild(this.$canvas);
|
|
533
|
-
}
|
|
430
|
+
this.$container.removeChild(this.$canvas);
|
|
534
431
|
}
|
|
535
|
-
}
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
setDOMSize(this.$canvas, width, height);
|
|
550
|
-
}
|
|
551
|
-
}
|
|
552
|
-
}, {
|
|
553
|
-
key: "getDPR",
|
|
554
|
-
value: function getDPR() {
|
|
555
|
-
return this.dpr;
|
|
432
|
+
};
|
|
433
|
+
_proto.resize = function resize(width, height) {
|
|
434
|
+
// use user-defined dpr first
|
|
435
|
+
var devicePixelRatio = this.canvasConfig.devicePixelRatio;
|
|
436
|
+
var dpr = devicePixelRatio || isBrowser && window.devicePixelRatio || 1;
|
|
437
|
+
dpr = dpr >= 1 ? Math.ceil(dpr) : 1;
|
|
438
|
+
this.dpr = dpr;
|
|
439
|
+
if (this.$canvas) {
|
|
440
|
+
var _dpr = this.getDPR();
|
|
441
|
+
// set canvas width & height
|
|
442
|
+
this.$canvas.width = _dpr * width;
|
|
443
|
+
this.$canvas.height = _dpr * height;
|
|
444
|
+
// set CSS style width & height
|
|
445
|
+
setDOMSize(this.$canvas, width, height);
|
|
556
446
|
}
|
|
557
|
-
}
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
447
|
+
};
|
|
448
|
+
_proto.getDPR = function getDPR() {
|
|
449
|
+
return this.dpr;
|
|
450
|
+
};
|
|
451
|
+
_proto.applyCursorStyle = function applyCursorStyle(cursor) {
|
|
452
|
+
if (this.$container && this.$container.style) {
|
|
453
|
+
this.$container.style.cursor = cursor;
|
|
563
454
|
}
|
|
564
|
-
}
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
return _context2.stop();
|
|
576
|
-
}
|
|
455
|
+
};
|
|
456
|
+
_proto.toDataURL = /*#__PURE__*/function () {
|
|
457
|
+
var _toDataURL = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(options) {
|
|
458
|
+
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
459
|
+
while (1) {
|
|
460
|
+
switch (_context2.prev = _context2.next) {
|
|
461
|
+
case 0:
|
|
462
|
+
return _context2.abrupt("return", '');
|
|
463
|
+
case 1:
|
|
464
|
+
case "end":
|
|
465
|
+
return _context2.stop();
|
|
577
466
|
}
|
|
578
|
-
}
|
|
579
|
-
})
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
}
|
|
467
|
+
}
|
|
468
|
+
}, _callee2);
|
|
469
|
+
}));
|
|
470
|
+
function toDataURL(_x) {
|
|
471
|
+
return _toDataURL.apply(this, arguments);
|
|
472
|
+
}
|
|
473
|
+
return toDataURL;
|
|
474
|
+
}();
|
|
586
475
|
return WebGPUContextService;
|
|
587
476
|
}();
|
|
588
477
|
|
|
589
478
|
var ContextRegisterPlugin = /*#__PURE__*/function (_AbstractRendererPlug) {
|
|
590
|
-
|
|
591
|
-
var _super = _createSuper(ContextRegisterPlugin);
|
|
479
|
+
_inheritsLoose(ContextRegisterPlugin, _AbstractRendererPlug);
|
|
592
480
|
function ContextRegisterPlugin(rendererPlugin) {
|
|
593
481
|
var _this;
|
|
594
|
-
|
|
595
|
-
_this = _super.call(this);
|
|
482
|
+
_this = _AbstractRendererPlug.call(this) || this;
|
|
596
483
|
_this.rendererPlugin = void 0;
|
|
597
484
|
_this.name = 'webgpu-context-register';
|
|
598
485
|
_this.rendererPlugin = rendererPlugin;
|
|
599
486
|
return _this;
|
|
600
487
|
}
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
value: function destroy() {
|
|
611
|
-
delete this.context.ContextService;
|
|
612
|
-
}
|
|
613
|
-
}]);
|
|
488
|
+
var _proto = ContextRegisterPlugin.prototype;
|
|
489
|
+
_proto.init = function init() {
|
|
490
|
+
this.context.ContextService = WebGPUContextService;
|
|
491
|
+
// @ts-ignore
|
|
492
|
+
this.context.deviceRendererPlugin = this.rendererPlugin;
|
|
493
|
+
};
|
|
494
|
+
_proto.destroy = function destroy() {
|
|
495
|
+
delete this.context.ContextService;
|
|
496
|
+
};
|
|
614
497
|
return ContextRegisterPlugin;
|
|
615
498
|
}(AbstractRendererPlugin);
|
|
616
499
|
|
|
617
500
|
var Renderer = /*#__PURE__*/function (_AbstractRenderer) {
|
|
618
|
-
|
|
619
|
-
var _super = _createSuper(Renderer);
|
|
501
|
+
_inheritsLoose(Renderer, _AbstractRenderer);
|
|
620
502
|
function Renderer(config) {
|
|
621
503
|
var _this;
|
|
622
|
-
|
|
623
|
-
_this = _super.call(this, config);
|
|
504
|
+
_this = _AbstractRenderer.call(this, config) || this;
|
|
624
505
|
var deviceRendererPlugin = new Plugin();
|
|
625
506
|
_this.registerPlugin(new ContextRegisterPlugin(deviceRendererPlugin));
|
|
626
507
|
_this.registerPlugin(new Plugin$1());
|
|
@@ -630,7 +511,7 @@ var Renderer = /*#__PURE__*/function (_AbstractRenderer) {
|
|
|
630
511
|
_this.registerPlugin(new Plugin$4());
|
|
631
512
|
return _this;
|
|
632
513
|
}
|
|
633
|
-
return
|
|
514
|
+
return Renderer;
|
|
634
515
|
}(AbstractRenderer);
|
|
635
516
|
|
|
636
517
|
export { Renderer };
|