Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@antv/g-webgpu

Package Overview
Dependencies
Maintainers
0
Versions
235
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@antv/g-webgpu - npm Package Compare versions

Comparing version 2.0.20 to 2.0.21

types/ContextRegisterPlugin.d.ts

262

dist/index.esm.js

@@ -1,3 +0,11 @@

import { __awaiter, __generator, __extends, __assign } from 'tslib';
import { setDOMSize, isBrowser, AbstractRendererPlugin, ClipSpaceNearZ, AbstractRenderer } from '@antv/g-lite';
/*!
* @antv/g-webgpu
* @description A renderer implemented by WebGPU
* @version 2.0.21
* @date 10/23/2024, 7:15:58 AM
* @author AntVis
* @docs https://g.antv.antgroup.com/
*/
import _objectSpread from '@babel/runtime/helpers/objectSpread2';
import { setDOMSize, isBrowser, AbstractRendererPlugin, AbstractRenderer, ClipSpaceNearZ } from '@antv/g-lite';
import * as DeviceRenderer from '@antv/g-plugin-device-renderer';

@@ -10,133 +18,137 @@ export { DeviceRenderer };

import * as ImageLoader from '@antv/g-plugin-image-loader';
import { WebGPUDeviceContribution } from '@antv/g-device-api';
import _regeneratorRuntime from '@babel/runtime/helpers/regeneratorRuntime';
import _asyncToGenerator from '@babel/runtime/helpers/asyncToGenerator';
import { isString } from '@antv/util';
import { WebGPUDeviceContribution } from '@antv/g-device-api';
var WebGPUContextService = /** @class */ (function () {
function WebGPUContextService(context) {
this.canvasConfig = context.config;
// @ts-ignore
this.deviceRendererPlugin = context.deviceRendererPlugin;
}
WebGPUContextService.prototype.init = function () {
var _a = this.canvasConfig, container = _a.container, canvas = _a.canvas;
if (canvas) {
this.$canvas = canvas;
if (container &&
canvas.parentElement !== container) {
container.appendChild(canvas);
}
this.$container = canvas.parentElement;
this.canvasConfig.container = this.$container;
class WebGPUContextService {
constructor(context) {
this.canvasConfig = context.config;
// @ts-ignore
this.deviceRendererPlugin = context.deviceRendererPlugin;
}
init() {
var _this$canvasConfig = this.canvasConfig,
container = _this$canvasConfig.container,
canvas = _this$canvasConfig.canvas;
if (canvas) {
this.$canvas = canvas;
if (container && canvas.parentElement !== container) {
container.appendChild(canvas);
}
this.$container = canvas.parentElement;
this.canvasConfig.container = this.$container;
} else if (container) {
// create container
this.$container = isString(container) ? document.getElementById(container) : container;
if (this.$container) {
// create canvas
var $canvas = document.createElement('canvas');
this.$container.appendChild($canvas);
if (!this.$container.style.position) {
this.$container.style.position = 'relative';
}
else if (container) {
// create container
this.$container = isString(container)
? document.getElementById(container)
: container;
if (this.$container) {
// create canvas
var $canvas = document.createElement('canvas');
this.$container.appendChild($canvas);
if (!this.$container.style.position) {
this.$container.style.position = 'relative';
}
this.$canvas = $canvas;
}
}
this.resize(this.canvasConfig.width, this.canvasConfig.height);
};
WebGPUContextService.prototype.getDomElement = function () {
return this.$canvas;
};
WebGPUContextService.prototype.getContext = function () {
return (
// @ts-ignore
this.deviceRendererPlugin.getDevice().canvasContext);
};
WebGPUContextService.prototype.getBoundingClientRect = function () {
if (this.$canvas.getBoundingClientRect) {
return this.$canvas.getBoundingClientRect();
}
};
WebGPUContextService.prototype.destroy = function () {
// @ts-ignore
if (this.$container && this.$canvas && this.$canvas.parentNode) {
// @ts-ignore
this.$container.removeChild(this.$canvas);
}
};
WebGPUContextService.prototype.resize = function (width, height) {
// use user-defined dpr first
var devicePixelRatio = this.canvasConfig.devicePixelRatio;
var dpr = devicePixelRatio || (isBrowser && window.devicePixelRatio) || 1;
dpr = dpr >= 1 ? Math.ceil(dpr) : 1;
this.dpr = dpr;
if (this.$canvas) {
var dpr_1 = this.getDPR();
// set canvas width & height
this.$canvas.width = dpr_1 * width;
this.$canvas.height = dpr_1 * height;
// set CSS style width & height
setDOMSize(this.$canvas, width, height);
}
};
WebGPUContextService.prototype.getDPR = function () {
return this.dpr;
};
WebGPUContextService.prototype.applyCursorStyle = function (cursor) {
if (this.$container && this.$container.style) {
this.$container.style.cursor = cursor;
}
};
WebGPUContextService.prototype.toDataURL = function (options) {
return __awaiter(this, void 0, void 0, function () {
return __generator(this, function (_a) {
return [2 /*return*/, ''];
});
});
};
return WebGPUContextService;
}());
var ContextRegisterPlugin = /** @class */ (function (_super) {
__extends(ContextRegisterPlugin, _super);
function ContextRegisterPlugin(rendererPlugin, config) {
var _this = _super.call(this) || this;
_this.rendererPlugin = rendererPlugin;
_this.config = config;
_this.name = 'webgpu-context-register';
return _this;
this.$canvas = $canvas;
}
}
ContextRegisterPlugin.prototype.init = function () {
this.context.ContextService = WebGPUContextService;
this.context.deviceRendererPlugin = this.rendererPlugin;
var config = this.config;
this.context.deviceContribution = new WebGPUDeviceContribution({
shaderCompilerPath: config === null || config === void 0 ? void 0 : config.shaderCompilerPath,
onContextLost: config === null || config === void 0 ? void 0 : config.onContextLost,
});
};
ContextRegisterPlugin.prototype.destroy = function () {
delete this.context.ContextService;
};
return ContextRegisterPlugin;
}(AbstractRendererPlugin));
this.resize(this.canvasConfig.width, this.canvasConfig.height);
}
getDomElement() {
return this.$canvas;
}
getContext() {
return (
// @ts-ignore
this.deviceRendererPlugin.getDevice().canvasContext
);
}
getBoundingClientRect() {
if (this.$canvas.getBoundingClientRect) {
return this.$canvas.getBoundingClientRect();
}
}
destroy() {
// @ts-ignore
if (this.$container && this.$canvas && this.$canvas.parentNode) {
// @ts-ignore
this.$container.removeChild(this.$canvas);
}
}
resize(width, height) {
// use user-defined dpr first
var devicePixelRatio = this.canvasConfig.devicePixelRatio;
var dpr = devicePixelRatio || isBrowser && window.devicePixelRatio || 1;
dpr = dpr >= 1 ? Math.ceil(dpr) : 1;
this.dpr = dpr;
if (this.$canvas) {
var _dpr = this.getDPR();
var Renderer = /** @class */ (function (_super) {
__extends(Renderer, _super);
function Renderer(config) {
var _this = _super.call(this, __assign({ enableSizeAttenuation: false }, config)) || this;
_this.clipSpaceNearZ = ClipSpaceNearZ.ZERO;
var deviceRendererPlugin = new DeviceRenderer.Plugin();
_this.registerPlugin(new ContextRegisterPlugin(deviceRendererPlugin, config));
_this.registerPlugin(new ImageLoader.Plugin());
_this.registerPlugin(deviceRendererPlugin);
_this.registerPlugin(new DomInteraction.Plugin());
_this.registerPlugin(new HTMLRenderer.Plugin());
return _this;
// set canvas width & height
this.$canvas.width = _dpr * width;
this.$canvas.height = _dpr * height;
// set CSS style width & height
setDOMSize(this.$canvas, width, height);
}
return Renderer;
}(AbstractRenderer));
}
getDPR() {
return this.dpr;
}
applyCursorStyle(cursor) {
if (this.$container && this.$container.style) {
this.$container.style.cursor = cursor;
}
}
toDataURL(options) {
return _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
return _regeneratorRuntime().wrap(function _callee$(_context) {
while (1) switch (_context.prev = _context.next) {
case 0:
return _context.abrupt("return", '');
case 1:
case "end":
return _context.stop();
}
}, _callee);
}))();
}
}
class ContextRegisterPlugin extends AbstractRendererPlugin {
constructor(rendererPlugin, config) {
super();
this.name = 'webgpu-context-register';
this.rendererPlugin = rendererPlugin;
this.config = config;
}
init() {
this.context.ContextService = WebGPUContextService;
this.context.deviceRendererPlugin = this.rendererPlugin;
var config = this.config;
this.context.deviceContribution = new WebGPUDeviceContribution({
shaderCompilerPath: config === null || config === void 0 ? void 0 : config.shaderCompilerPath,
onContextLost: config === null || config === void 0 ? void 0 : config.onContextLost
});
}
destroy() {
delete this.context.ContextService;
}
}
class Renderer extends AbstractRenderer {
constructor(config) {
super(_objectSpread({
enableSizeAttenuation: false
}, config));
this.clipSpaceNearZ = ClipSpaceNearZ.ZERO;
var deviceRendererPlugin = new DeviceRenderer.Plugin();
this.registerPlugin(new ContextRegisterPlugin(deviceRendererPlugin, config));
this.registerPlugin(new ImageLoader.Plugin());
this.registerPlugin(deviceRendererPlugin);
this.registerPlugin(new DomInteraction.Plugin());
this.registerPlugin(new HTMLRenderer.Plugin());
}
}
export { Renderer };
//# sourceMappingURL=index.esm.js.map

@@ -0,4 +1,12 @@

/*!
* @antv/g-webgpu
* @description A renderer implemented by WebGPU
* @version 2.0.21
* @date 10/23/2024, 7:15:58 AM
* @author AntVis
* @docs https://g.antv.antgroup.com/
*/
'use strict';
var tslib = require('tslib');
var _objectSpread = require('@babel/runtime/helpers/objectSpread2');
var gLite = require('@antv/g-lite');

@@ -9,20 +17,22 @@ var DeviceRenderer = require('@antv/g-plugin-device-renderer');

var ImageLoader = require('@antv/g-plugin-image-loader');
var gDeviceApi = require('@antv/g-device-api');
var _regeneratorRuntime = require('@babel/runtime/helpers/regeneratorRuntime');
var _asyncToGenerator = require('@babel/runtime/helpers/asyncToGenerator');
var util = require('@antv/util');
var gDeviceApi = require('@antv/g-device-api');
function _interopNamespaceDefault(e) {
var n = Object.create(null);
if (e) {
Object.keys(e).forEach(function (k) {
if (k !== 'default') {
var d = Object.getOwnPropertyDescriptor(e, k);
Object.defineProperty(n, k, d.get ? d : {
enumerable: true,
get: function () { return e[k]; }
});
}
var n = Object.create(null);
if (e) {
Object.keys(e).forEach(function (k) {
if (k !== 'default') {
var d = Object.getOwnPropertyDescriptor(e, k);
Object.defineProperty(n, k, d.get ? d : {
enumerable: true,
get: function () { return e[k]; }
});
}
n.default = e;
return Object.freeze(n);
}
});
}
n.default = e;
return Object.freeze(n);
}

@@ -35,129 +45,131 @@

var WebGPUContextService = /** @class */ (function () {
function WebGPUContextService(context) {
this.canvasConfig = context.config;
// @ts-ignore
this.deviceRendererPlugin = context.deviceRendererPlugin;
}
WebGPUContextService.prototype.init = function () {
var _a = this.canvasConfig, container = _a.container, canvas = _a.canvas;
if (canvas) {
this.$canvas = canvas;
if (container &&
canvas.parentElement !== container) {
container.appendChild(canvas);
}
this.$container = canvas.parentElement;
this.canvasConfig.container = this.$container;
class WebGPUContextService {
constructor(context) {
this.canvasConfig = context.config;
// @ts-ignore
this.deviceRendererPlugin = context.deviceRendererPlugin;
}
init() {
var _this$canvasConfig = this.canvasConfig,
container = _this$canvasConfig.container,
canvas = _this$canvasConfig.canvas;
if (canvas) {
this.$canvas = canvas;
if (container && canvas.parentElement !== container) {
container.appendChild(canvas);
}
this.$container = canvas.parentElement;
this.canvasConfig.container = this.$container;
} else if (container) {
// create container
this.$container = util.isString(container) ? document.getElementById(container) : container;
if (this.$container) {
// create canvas
var $canvas = document.createElement('canvas');
this.$container.appendChild($canvas);
if (!this.$container.style.position) {
this.$container.style.position = 'relative';
}
else if (container) {
// create container
this.$container = util.isString(container)
? document.getElementById(container)
: container;
if (this.$container) {
// create canvas
var $canvas = document.createElement('canvas');
this.$container.appendChild($canvas);
if (!this.$container.style.position) {
this.$container.style.position = 'relative';
}
this.$canvas = $canvas;
}
}
this.resize(this.canvasConfig.width, this.canvasConfig.height);
};
WebGPUContextService.prototype.getDomElement = function () {
return this.$canvas;
};
WebGPUContextService.prototype.getContext = function () {
return (
// @ts-ignore
this.deviceRendererPlugin.getDevice().canvasContext);
};
WebGPUContextService.prototype.getBoundingClientRect = function () {
if (this.$canvas.getBoundingClientRect) {
return this.$canvas.getBoundingClientRect();
}
};
WebGPUContextService.prototype.destroy = function () {
// @ts-ignore
if (this.$container && this.$canvas && this.$canvas.parentNode) {
// @ts-ignore
this.$container.removeChild(this.$canvas);
}
};
WebGPUContextService.prototype.resize = function (width, height) {
// use user-defined dpr first
var devicePixelRatio = this.canvasConfig.devicePixelRatio;
var dpr = devicePixelRatio || (gLite.isBrowser && window.devicePixelRatio) || 1;
dpr = dpr >= 1 ? Math.ceil(dpr) : 1;
this.dpr = dpr;
if (this.$canvas) {
var dpr_1 = this.getDPR();
// set canvas width & height
this.$canvas.width = dpr_1 * width;
this.$canvas.height = dpr_1 * height;
// set CSS style width & height
gLite.setDOMSize(this.$canvas, width, height);
}
};
WebGPUContextService.prototype.getDPR = function () {
return this.dpr;
};
WebGPUContextService.prototype.applyCursorStyle = function (cursor) {
if (this.$container && this.$container.style) {
this.$container.style.cursor = cursor;
}
};
WebGPUContextService.prototype.toDataURL = function (options) {
return tslib.__awaiter(this, void 0, void 0, function () {
return tslib.__generator(this, function (_a) {
return [2 /*return*/, ''];
});
});
};
return WebGPUContextService;
}());
var ContextRegisterPlugin = /** @class */ (function (_super) {
tslib.__extends(ContextRegisterPlugin, _super);
function ContextRegisterPlugin(rendererPlugin, config) {
var _this = _super.call(this) || this;
_this.rendererPlugin = rendererPlugin;
_this.config = config;
_this.name = 'webgpu-context-register';
return _this;
this.$canvas = $canvas;
}
}
ContextRegisterPlugin.prototype.init = function () {
this.context.ContextService = WebGPUContextService;
this.context.deviceRendererPlugin = this.rendererPlugin;
var config = this.config;
this.context.deviceContribution = new gDeviceApi.WebGPUDeviceContribution({
shaderCompilerPath: config === null || config === void 0 ? void 0 : config.shaderCompilerPath,
onContextLost: config === null || config === void 0 ? void 0 : config.onContextLost,
});
};
ContextRegisterPlugin.prototype.destroy = function () {
delete this.context.ContextService;
};
return ContextRegisterPlugin;
}(gLite.AbstractRendererPlugin));
this.resize(this.canvasConfig.width, this.canvasConfig.height);
}
getDomElement() {
return this.$canvas;
}
getContext() {
return (
// @ts-ignore
this.deviceRendererPlugin.getDevice().canvasContext
);
}
getBoundingClientRect() {
if (this.$canvas.getBoundingClientRect) {
return this.$canvas.getBoundingClientRect();
}
}
destroy() {
// @ts-ignore
if (this.$container && this.$canvas && this.$canvas.parentNode) {
// @ts-ignore
this.$container.removeChild(this.$canvas);
}
}
resize(width, height) {
// use user-defined dpr first
var devicePixelRatio = this.canvasConfig.devicePixelRatio;
var dpr = devicePixelRatio || gLite.isBrowser && window.devicePixelRatio || 1;
dpr = dpr >= 1 ? Math.ceil(dpr) : 1;
this.dpr = dpr;
if (this.$canvas) {
var _dpr = this.getDPR();
var Renderer = /** @class */ (function (_super) {
tslib.__extends(Renderer, _super);
function Renderer(config) {
var _this = _super.call(this, tslib.__assign({ enableSizeAttenuation: false }, config)) || this;
_this.clipSpaceNearZ = gLite.ClipSpaceNearZ.ZERO;
var deviceRendererPlugin = new DeviceRenderer__namespace.Plugin();
_this.registerPlugin(new ContextRegisterPlugin(deviceRendererPlugin, config));
_this.registerPlugin(new ImageLoader__namespace.Plugin());
_this.registerPlugin(deviceRendererPlugin);
_this.registerPlugin(new DomInteraction__namespace.Plugin());
_this.registerPlugin(new HTMLRenderer__namespace.Plugin());
return _this;
// set canvas width & height
this.$canvas.width = _dpr * width;
this.$canvas.height = _dpr * height;
// set CSS style width & height
gLite.setDOMSize(this.$canvas, width, height);
}
return Renderer;
}(gLite.AbstractRenderer));
}
getDPR() {
return this.dpr;
}
applyCursorStyle(cursor) {
if (this.$container && this.$container.style) {
this.$container.style.cursor = cursor;
}
}
toDataURL(options) {
return _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
return _regeneratorRuntime().wrap(function _callee$(_context) {
while (1) switch (_context.prev = _context.next) {
case 0:
return _context.abrupt("return", '');
case 1:
case "end":
return _context.stop();
}
}, _callee);
}))();
}
}
class ContextRegisterPlugin extends gLite.AbstractRendererPlugin {
constructor(rendererPlugin, config) {
super();
this.name = 'webgpu-context-register';
this.rendererPlugin = rendererPlugin;
this.config = config;
}
init() {
this.context.ContextService = WebGPUContextService;
this.context.deviceRendererPlugin = this.rendererPlugin;
var config = this.config;
this.context.deviceContribution = new gDeviceApi.WebGPUDeviceContribution({
shaderCompilerPath: config === null || config === void 0 ? void 0 : config.shaderCompilerPath,
onContextLost: config === null || config === void 0 ? void 0 : config.onContextLost
});
}
destroy() {
delete this.context.ContextService;
}
}
class Renderer extends gLite.AbstractRenderer {
constructor(config) {
super(_objectSpread({
enableSizeAttenuation: false
}, config));
this.clipSpaceNearZ = gLite.ClipSpaceNearZ.ZERO;
var deviceRendererPlugin = new DeviceRenderer__namespace.Plugin();
this.registerPlugin(new ContextRegisterPlugin(deviceRendererPlugin, config));
this.registerPlugin(new ImageLoader__namespace.Plugin());
this.registerPlugin(deviceRendererPlugin);
this.registerPlugin(new DomInteraction__namespace.Plugin());
this.registerPlugin(new HTMLRenderer__namespace.Plugin());
}
}
exports.DeviceRenderer = DeviceRenderer__namespace;

@@ -164,0 +176,0 @@ exports.DomInteraction = DomInteraction__namespace;

{
"name": "@antv/g-webgpu",
"version": "2.0.20",
"version": "2.0.21",
"description": "A renderer implemented by WebGPU",

@@ -20,3 +20,3 @@ "keywords": [

"exports": {
"types": "./dist/index.d.ts",
"types": "./types/index.d.ts",
"import": "./dist/index.esm.js",

@@ -28,6 +28,7 @@ "default": "./dist/index.js"

"module": "dist/index.esm.js",
"types": "dist/index.d.ts",
"types": "types/index.d.ts",
"files": [
"package.json",
"dist",
"types",
"LICENSE",

@@ -39,9 +40,10 @@ "README.md"

"@antv/util": "^3.3.5",
"@babel/runtime": "^7.25.6",
"@webgpu/types": "^0.1.6",
"tslib": "^2.5.3",
"@antv/g-lite": "2.1.0",
"@antv/g-plugin-device-renderer": "2.1.0",
"@antv/g-plugin-dom-interaction": "2.1.0",
"@antv/g-plugin-html-renderer": "2.1.0",
"@antv/g-plugin-image-loader": "2.0.11"
"@antv/g-lite": "2.1.1",
"@antv/g-plugin-device-renderer": "2.1.1",
"@antv/g-plugin-image-loader": "2.0.12",
"@antv/g-plugin-dom-interaction": "2.1.1",
"@antv/g-plugin-html-renderer": "2.1.1"
},

@@ -56,3 +58,4 @@ "devDependencies": {

"scripts": {
"build": "npm run clean && rollup -c",
"build:types": "tsc --emitDeclarationOnly --noCheck",
"build": "npm run clean && npm run build:types && rollup -c",
"clean": "rimraf dist",

@@ -59,0 +62,0 @@ "sync": "tnpm sync",

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc