@antv/g-webgpu 1.7.33 → 1.7.35
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 +233 -119
- package/dist/index.js +233 -119
- package/dist/index.umd.js +8387 -6805
- package/dist/index.umd.min.js +1 -1
- package/package.json +7 -7
package/dist/index.js
CHANGED
|
@@ -170,14 +170,9 @@ function _regeneratorRuntime() {
|
|
|
170
170
|
};
|
|
171
171
|
}
|
|
172
172
|
function maybeInvokeDelegate(delegate, context) {
|
|
173
|
-
var
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
if (delegate.iterator.return && (context.method = "return", context.arg = undefined, maybeInvokeDelegate(delegate, context), "throw" === context.method)) return ContinueSentinel;
|
|
177
|
-
context.method = "throw", context.arg = new TypeError("The iterator does not provide a 'throw' method");
|
|
178
|
-
}
|
|
179
|
-
return ContinueSentinel;
|
|
180
|
-
}
|
|
173
|
+
var methodName = context.method,
|
|
174
|
+
method = delegate.iterator[methodName];
|
|
175
|
+
if (undefined === method) return context.delegate = null, "throw" === methodName && delegate.iterator.return && (context.method = "return", context.arg = undefined, maybeInvokeDelegate(delegate, context), "throw" === context.method) || "return" !== methodName && (context.method = "throw", context.arg = new TypeError("The iterator does not provide a '" + methodName + "' method")), ContinueSentinel;
|
|
181
176
|
var record = tryCatch(method, delegate.iterator, context.arg);
|
|
182
177
|
if ("throw" === record.type) return context.method = "throw", context.arg = record.arg, context.delegate = null, ContinueSentinel;
|
|
183
178
|
var info = record.arg;
|
|
@@ -371,10 +366,49 @@ function _asyncToGenerator(fn) {
|
|
|
371
366
|
});
|
|
372
367
|
};
|
|
373
368
|
}
|
|
374
|
-
function
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
369
|
+
function _classCallCheck(instance, Constructor) {
|
|
370
|
+
if (!(instance instanceof Constructor)) {
|
|
371
|
+
throw new TypeError("Cannot call a class as a function");
|
|
372
|
+
}
|
|
373
|
+
}
|
|
374
|
+
function _defineProperties(target, props) {
|
|
375
|
+
for (var i = 0; i < props.length; i++) {
|
|
376
|
+
var descriptor = props[i];
|
|
377
|
+
descriptor.enumerable = descriptor.enumerable || false;
|
|
378
|
+
descriptor.configurable = true;
|
|
379
|
+
if ("value" in descriptor) descriptor.writable = true;
|
|
380
|
+
Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor);
|
|
381
|
+
}
|
|
382
|
+
}
|
|
383
|
+
function _createClass(Constructor, protoProps, staticProps) {
|
|
384
|
+
if (protoProps) _defineProperties(Constructor.prototype, protoProps);
|
|
385
|
+
if (staticProps) _defineProperties(Constructor, staticProps);
|
|
386
|
+
Object.defineProperty(Constructor, "prototype", {
|
|
387
|
+
writable: false
|
|
388
|
+
});
|
|
389
|
+
return Constructor;
|
|
390
|
+
}
|
|
391
|
+
function _inherits(subClass, superClass) {
|
|
392
|
+
if (typeof superClass !== "function" && superClass !== null) {
|
|
393
|
+
throw new TypeError("Super expression must either be null or a function");
|
|
394
|
+
}
|
|
395
|
+
subClass.prototype = Object.create(superClass && superClass.prototype, {
|
|
396
|
+
constructor: {
|
|
397
|
+
value: subClass,
|
|
398
|
+
writable: true,
|
|
399
|
+
configurable: true
|
|
400
|
+
}
|
|
401
|
+
});
|
|
402
|
+
Object.defineProperty(subClass, "prototype", {
|
|
403
|
+
writable: false
|
|
404
|
+
});
|
|
405
|
+
if (superClass) _setPrototypeOf(subClass, superClass);
|
|
406
|
+
}
|
|
407
|
+
function _getPrototypeOf(o) {
|
|
408
|
+
_getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) {
|
|
409
|
+
return o.__proto__ || Object.getPrototypeOf(o);
|
|
410
|
+
};
|
|
411
|
+
return _getPrototypeOf(o);
|
|
378
412
|
}
|
|
379
413
|
function _setPrototypeOf(o, p) {
|
|
380
414
|
_setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) {
|
|
@@ -383,9 +417,63 @@ function _setPrototypeOf(o, p) {
|
|
|
383
417
|
};
|
|
384
418
|
return _setPrototypeOf(o, p);
|
|
385
419
|
}
|
|
420
|
+
function _isNativeReflectConstruct() {
|
|
421
|
+
if (typeof Reflect === "undefined" || !Reflect.construct) return false;
|
|
422
|
+
if (Reflect.construct.sham) return false;
|
|
423
|
+
if (typeof Proxy === "function") return true;
|
|
424
|
+
try {
|
|
425
|
+
Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {}));
|
|
426
|
+
return true;
|
|
427
|
+
} catch (e) {
|
|
428
|
+
return false;
|
|
429
|
+
}
|
|
430
|
+
}
|
|
431
|
+
function _assertThisInitialized(self) {
|
|
432
|
+
if (self === void 0) {
|
|
433
|
+
throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
|
|
434
|
+
}
|
|
435
|
+
return self;
|
|
436
|
+
}
|
|
437
|
+
function _possibleConstructorReturn(self, call) {
|
|
438
|
+
if (call && (typeof call === "object" || typeof call === "function")) {
|
|
439
|
+
return call;
|
|
440
|
+
} else if (call !== void 0) {
|
|
441
|
+
throw new TypeError("Derived constructors may only return object or undefined");
|
|
442
|
+
}
|
|
443
|
+
return _assertThisInitialized(self);
|
|
444
|
+
}
|
|
445
|
+
function _createSuper(Derived) {
|
|
446
|
+
var hasNativeReflectConstruct = _isNativeReflectConstruct();
|
|
447
|
+
return function _createSuperInternal() {
|
|
448
|
+
var Super = _getPrototypeOf(Derived),
|
|
449
|
+
result;
|
|
450
|
+
if (hasNativeReflectConstruct) {
|
|
451
|
+
var NewTarget = _getPrototypeOf(this).constructor;
|
|
452
|
+
result = Reflect.construct(Super, arguments, NewTarget);
|
|
453
|
+
} else {
|
|
454
|
+
result = Super.apply(this, arguments);
|
|
455
|
+
}
|
|
456
|
+
return _possibleConstructorReturn(this, result);
|
|
457
|
+
};
|
|
458
|
+
}
|
|
459
|
+
function _toPrimitive(input, hint) {
|
|
460
|
+
if (typeof input !== "object" || input === null) return input;
|
|
461
|
+
var prim = input[Symbol.toPrimitive];
|
|
462
|
+
if (prim !== undefined) {
|
|
463
|
+
var res = prim.call(input, hint || "default");
|
|
464
|
+
if (typeof res !== "object") return res;
|
|
465
|
+
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
466
|
+
}
|
|
467
|
+
return (hint === "string" ? String : Number)(input);
|
|
468
|
+
}
|
|
469
|
+
function _toPropertyKey(arg) {
|
|
470
|
+
var key = _toPrimitive(arg, "string");
|
|
471
|
+
return typeof key === "symbol" ? key : String(key);
|
|
472
|
+
}
|
|
386
473
|
|
|
387
474
|
var WebGPUContextService = /*#__PURE__*/function () {
|
|
388
475
|
function WebGPUContextService(context) {
|
|
476
|
+
_classCallCheck(this, WebGPUContextService);
|
|
389
477
|
this.$container = void 0;
|
|
390
478
|
this.$canvas = void 0;
|
|
391
479
|
this.dpr = void 0;
|
|
@@ -395,139 +483,165 @@ var WebGPUContextService = /*#__PURE__*/function () {
|
|
|
395
483
|
// @ts-ignore
|
|
396
484
|
this.deviceRendererPlugin = context.deviceRendererPlugin;
|
|
397
485
|
}
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
var
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
container.
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
this.$container.style.position
|
|
486
|
+
_createClass(WebGPUContextService, [{
|
|
487
|
+
key: "init",
|
|
488
|
+
value: function () {
|
|
489
|
+
var _init = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
490
|
+
var _this$canvasConfig, container, canvas, $canvas;
|
|
491
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
492
|
+
while (1) {
|
|
493
|
+
switch (_context.prev = _context.next) {
|
|
494
|
+
case 0:
|
|
495
|
+
_this$canvasConfig = this.canvasConfig, container = _this$canvasConfig.container, canvas = _this$canvasConfig.canvas;
|
|
496
|
+
if (canvas) {
|
|
497
|
+
this.$canvas = canvas;
|
|
498
|
+
if (container && canvas.parentElement !== container) {
|
|
499
|
+
container.appendChild(canvas);
|
|
500
|
+
}
|
|
501
|
+
this.$container = canvas.parentElement;
|
|
502
|
+
this.canvasConfig.container = this.$container;
|
|
503
|
+
} else if (container) {
|
|
504
|
+
// create container
|
|
505
|
+
this.$container = util.isString(container) ? document.getElementById(container) : container;
|
|
506
|
+
if (this.$container) {
|
|
507
|
+
// create canvas
|
|
508
|
+
$canvas = document.createElement('canvas');
|
|
509
|
+
this.$container.appendChild($canvas);
|
|
510
|
+
if (!this.$container.style.position) {
|
|
511
|
+
this.$container.style.position = 'relative';
|
|
512
|
+
}
|
|
513
|
+
this.$canvas = $canvas;
|
|
423
514
|
}
|
|
424
|
-
this.$canvas = $canvas;
|
|
425
515
|
}
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
516
|
+
this.resize(this.canvasConfig.width, this.canvasConfig.height);
|
|
517
|
+
case 3:
|
|
518
|
+
case "end":
|
|
519
|
+
return _context.stop();
|
|
520
|
+
}
|
|
431
521
|
}
|
|
432
|
-
}
|
|
433
|
-
}
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
522
|
+
}, _callee, this);
|
|
523
|
+
}));
|
|
524
|
+
function init() {
|
|
525
|
+
return _init.apply(this, arguments);
|
|
526
|
+
}
|
|
527
|
+
return init;
|
|
528
|
+
}()
|
|
529
|
+
}, {
|
|
530
|
+
key: "getDomElement",
|
|
531
|
+
value: function getDomElement() {
|
|
532
|
+
return this.$canvas;
|
|
437
533
|
}
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
_proto.getContext = function getContext() {
|
|
444
|
-
// @ts-ignore
|
|
445
|
-
return this.deviceRendererPlugin.getDevice().canvasContext;
|
|
446
|
-
};
|
|
447
|
-
_proto.getBoundingClientRect = function getBoundingClientRect() {
|
|
448
|
-
if (this.$canvas.getBoundingClientRect) {
|
|
449
|
-
return this.$canvas.getBoundingClientRect();
|
|
534
|
+
}, {
|
|
535
|
+
key: "getContext",
|
|
536
|
+
value: function getContext() {
|
|
537
|
+
// @ts-ignore
|
|
538
|
+
return this.deviceRendererPlugin.getDevice().canvasContext;
|
|
450
539
|
}
|
|
451
|
-
}
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
540
|
+
}, {
|
|
541
|
+
key: "getBoundingClientRect",
|
|
542
|
+
value: function getBoundingClientRect() {
|
|
543
|
+
if (this.$canvas.getBoundingClientRect) {
|
|
544
|
+
return this.$canvas.getBoundingClientRect();
|
|
545
|
+
}
|
|
546
|
+
}
|
|
547
|
+
}, {
|
|
548
|
+
key: "destroy",
|
|
549
|
+
value: function destroy() {
|
|
455
550
|
// @ts-ignore
|
|
456
|
-
this.$container
|
|
551
|
+
if (this.$container && this.$canvas && this.$canvas.parentNode) {
|
|
552
|
+
// @ts-ignore
|
|
553
|
+
this.$container.removeChild(this.$canvas);
|
|
554
|
+
}
|
|
457
555
|
}
|
|
458
|
-
}
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
556
|
+
}, {
|
|
557
|
+
key: "resize",
|
|
558
|
+
value: function resize(width, height) {
|
|
559
|
+
// use user-defined dpr first
|
|
560
|
+
var devicePixelRatio = this.canvasConfig.devicePixelRatio;
|
|
561
|
+
var dpr = devicePixelRatio || gLite.isBrowser && window.devicePixelRatio || 1;
|
|
562
|
+
dpr = dpr >= 1 ? Math.ceil(dpr) : 1;
|
|
563
|
+
this.dpr = dpr;
|
|
564
|
+
if (this.$canvas) {
|
|
565
|
+
var _dpr = this.getDPR();
|
|
566
|
+
// set canvas width & height
|
|
567
|
+
this.$canvas.width = _dpr * width;
|
|
568
|
+
this.$canvas.height = _dpr * height;
|
|
569
|
+
// set CSS style width & height
|
|
570
|
+
gLite.setDOMSize(this.$canvas, width, height);
|
|
571
|
+
}
|
|
472
572
|
}
|
|
473
|
-
}
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
_proto.applyCursorStyle = function applyCursorStyle(cursor) {
|
|
478
|
-
if (this.$container && this.$container.style) {
|
|
479
|
-
this.$container.style.cursor = cursor;
|
|
573
|
+
}, {
|
|
574
|
+
key: "getDPR",
|
|
575
|
+
value: function getDPR() {
|
|
576
|
+
return this.dpr;
|
|
480
577
|
}
|
|
481
|
-
}
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
case 0:
|
|
488
|
-
return _context2.abrupt("return", '');
|
|
489
|
-
case 1:
|
|
490
|
-
case "end":
|
|
491
|
-
return _context2.stop();
|
|
492
|
-
}
|
|
493
|
-
}
|
|
494
|
-
}, _callee2);
|
|
495
|
-
}));
|
|
496
|
-
function toDataURL(_x) {
|
|
497
|
-
return _toDataURL.apply(this, arguments);
|
|
578
|
+
}, {
|
|
579
|
+
key: "applyCursorStyle",
|
|
580
|
+
value: function applyCursorStyle(cursor) {
|
|
581
|
+
if (this.$container && this.$container.style) {
|
|
582
|
+
this.$container.style.cursor = cursor;
|
|
583
|
+
}
|
|
498
584
|
}
|
|
499
|
-
|
|
500
|
-
|
|
585
|
+
}, {
|
|
586
|
+
key: "toDataURL",
|
|
587
|
+
value: function () {
|
|
588
|
+
var _toDataURL = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(options) {
|
|
589
|
+
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
590
|
+
while (1) {
|
|
591
|
+
switch (_context2.prev = _context2.next) {
|
|
592
|
+
case 0:
|
|
593
|
+
return _context2.abrupt("return", '');
|
|
594
|
+
case 1:
|
|
595
|
+
case "end":
|
|
596
|
+
return _context2.stop();
|
|
597
|
+
}
|
|
598
|
+
}
|
|
599
|
+
}, _callee2);
|
|
600
|
+
}));
|
|
601
|
+
function toDataURL(_x) {
|
|
602
|
+
return _toDataURL.apply(this, arguments);
|
|
603
|
+
}
|
|
604
|
+
return toDataURL;
|
|
605
|
+
}()
|
|
606
|
+
}]);
|
|
501
607
|
return WebGPUContextService;
|
|
502
608
|
}();
|
|
503
609
|
|
|
504
610
|
var ContextRegisterPlugin = /*#__PURE__*/function (_AbstractRendererPlug) {
|
|
505
|
-
|
|
611
|
+
_inherits(ContextRegisterPlugin, _AbstractRendererPlug);
|
|
612
|
+
var _super = _createSuper(ContextRegisterPlugin);
|
|
506
613
|
function ContextRegisterPlugin(rendererPlugin) {
|
|
507
614
|
var _this;
|
|
508
|
-
|
|
615
|
+
_classCallCheck(this, ContextRegisterPlugin);
|
|
616
|
+
_this = _super.call(this);
|
|
509
617
|
_this.rendererPlugin = void 0;
|
|
510
618
|
_this.name = 'webgpu-context-register';
|
|
511
619
|
_this.rendererPlugin = rendererPlugin;
|
|
512
620
|
return _this;
|
|
513
621
|
}
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
622
|
+
_createClass(ContextRegisterPlugin, [{
|
|
623
|
+
key: "init",
|
|
624
|
+
value: function init() {
|
|
625
|
+
this.context.ContextService = WebGPUContextService;
|
|
626
|
+
// @ts-ignore
|
|
627
|
+
this.context.deviceRendererPlugin = this.rendererPlugin;
|
|
628
|
+
}
|
|
629
|
+
}, {
|
|
630
|
+
key: "destroy",
|
|
631
|
+
value: function destroy() {
|
|
632
|
+
delete this.context.ContextService;
|
|
633
|
+
}
|
|
634
|
+
}]);
|
|
523
635
|
return ContextRegisterPlugin;
|
|
524
636
|
}(gLite.AbstractRendererPlugin);
|
|
525
637
|
|
|
526
638
|
var Renderer = /*#__PURE__*/function (_AbstractRenderer) {
|
|
527
|
-
|
|
639
|
+
_inherits(Renderer, _AbstractRenderer);
|
|
640
|
+
var _super = _createSuper(Renderer);
|
|
528
641
|
function Renderer(config) {
|
|
529
642
|
var _this;
|
|
530
|
-
|
|
643
|
+
_classCallCheck(this, Renderer);
|
|
644
|
+
_this = _super.call(this, config);
|
|
531
645
|
var deviceRendererPlugin = new DeviceRenderer.Plugin();
|
|
532
646
|
_this.registerPlugin(new ContextRegisterPlugin(deviceRendererPlugin));
|
|
533
647
|
_this.registerPlugin(new ImageLoader.Plugin());
|
|
@@ -537,7 +651,7 @@ var Renderer = /*#__PURE__*/function (_AbstractRenderer) {
|
|
|
537
651
|
_this.registerPlugin(new HTMLRenderer.Plugin());
|
|
538
652
|
return _this;
|
|
539
653
|
}
|
|
540
|
-
return Renderer;
|
|
654
|
+
return _createClass(Renderer);
|
|
541
655
|
}(gLite.AbstractRenderer);
|
|
542
656
|
|
|
543
657
|
exports.DeviceRenderer = DeviceRenderer__namespace;
|