New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@wgslx/wgslx-loader

Package Overview
Dependencies
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@wgslx/wgslx-loader - npm Package Compare versions

Comparing version 0.0.5 to 0.0.6

21

dist/index.js

@@ -17,2 +17,3 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
const path_1 = require("path");
const wgslx_1 = require("@wgslx/wgslx");

@@ -22,9 +23,17 @@ __exportStar(require("./shader"), exports);

this.getOptions();
const text = (0, wgslx_1.preprocess)(source);
const token = wgslx_1.Syntax.translationUnitExtended.matchAll(text, this.resourcePath);
if (token === null) {
throw new Error('Failed to parse the shader source.');
}
return [`const shader = {code:\`${(0, wgslx_1.postprocess)(token)}\`};`, 'module.exports = shader;'].join('\n');
const importResolver = {
resolveFilePath: (baseFilePath, importPath) => {
return (0, path_1.resolve)((0, path_1.dirname)(baseFilePath), importPath);
},
readSource: (filePath) => {
if (!this.fs.readFileSync) {
throw new Error('File system is not available.');
}
this.addDependency(filePath);
return this.fs.readFileSync(filePath, 'utf8');
},
};
const code = (0, wgslx_1.compileWgslx)(source, this.resourcePath, { mode: 'wgslx', importResolver });
return [`const shader = {code:\`${code}\`};`, 'module.exports = shader;'].join('\n');
}
exports.default = wgslxLoader;
{
"name": "@wgslx/wgslx-loader",
"version": "0.0.5",
"version": "0.0.6",
"description": "Webpack loader for wgsl, wgslx, and wgsli files.",

@@ -28,3 +28,3 @@ "main": "dist/index.js",

"dependencies": {
"@wgslx/wgslx": "^0.0.5"
"@wgslx/wgslx": "^0.0.7"
},

@@ -31,0 +31,0 @@ "devDependencies": {

@@ -0,3 +1,4 @@

import { resolve, dirname } from 'path';
import * as webpack from 'webpack';
import { Context, Cursor, Syntax, postprocess, preprocess } from '@wgslx/wgslx';
import { ImportResolver, compileWgslx } from '@wgslx/wgslx';

@@ -14,12 +15,18 @@ export * from './shader';

const text = preprocess(source);
const token = Syntax.translationUnitExtended.matchAll(text, this.resourcePath);
const importResolver: ImportResolver = {
resolveFilePath: (baseFilePath: string, importPath: string) => {
return resolve(dirname(baseFilePath), importPath);
},
readSource: (filePath: string) => {
if (!this.fs.readFileSync) {
throw new Error('File system is not available.');
}
if (token === null) {
throw new Error('Failed to parse the shader source.');
}
this.addDependency(filePath);
return this.fs.readFileSync(filePath, 'utf8');
},
};
return [`const shader = {code:\`${postprocess(token)}\`};`, 'module.exports = shader;'].join(
'\n'
);
const code = compileWgslx(source, this.resourcePath, { mode: 'wgslx', importResolver });
return [`const shader = {code:\`${code}\`};`, 'module.exports = shader;'].join('\n');
}
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