wesl-tooling 0.6.6 → 0.6.9
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.d.ts +12 -1
- package/dist/index.js +34 -1
- package/package.json +4 -6
package/dist/index.d.ts
CHANGED
|
@@ -104,4 +104,15 @@ declare function testComputeShader(projectDir: string, gpu: GPU, src: string, re
|
|
|
104
104
|
declare function runSimpleComputePipeline(device: GPUDevice, module: GPUShaderModule, resultFormat?: WgslElementType$1): Promise<number[]>;
|
|
105
105
|
|
|
106
106
|
//#endregion
|
|
107
|
-
|
|
107
|
+
//#region src/Version.d.ts
|
|
108
|
+
/** @returns the version from the package.json in the provided directory */
|
|
109
|
+
declare function versionFromPackageJson(projectDir: string): Promise<string>;
|
|
110
|
+
|
|
111
|
+
//#endregion
|
|
112
|
+
//#region src/LoadModules.d.ts
|
|
113
|
+
/** load the wesl/wgsl shader sources */
|
|
114
|
+
declare function loadModules(projectDir: string, baseDir: string, srcGlob: string): Promise<Record<string, string>>;
|
|
115
|
+
declare function zip<A, B>(as: A[], bs: B[]): [A, B][];
|
|
116
|
+
|
|
117
|
+
//#endregion
|
|
118
|
+
export { CompileShaderParams, WgslElementType, compileShader, dependencyBundles, loadModules, parseDependencies, runSimpleComputePipeline, testComputeShader, versionFromPackageJson, zip };
|
package/dist/index.js
CHANGED
|
@@ -3,6 +3,8 @@ import { pathToFileURL } from "node:url";
|
|
|
3
3
|
import { resolve } from "import-meta-resolve";
|
|
4
4
|
import { WeslParseError, filterMap, findUnboundIdents, link, parseIntoRegistry, parsedRegistry, requestWeslDevice } from "wesl";
|
|
5
5
|
import { copyBuffer, elementStride } from "thimbleberry";
|
|
6
|
+
import fs from "node:fs/promises";
|
|
7
|
+
import { glob } from "glob";
|
|
6
8
|
|
|
7
9
|
//#region src/ParseDependencies.ts
|
|
8
10
|
/**
|
|
@@ -199,4 +201,35 @@ async function runSimpleComputePipeline(device, module, resultFormat) {
|
|
|
199
201
|
}
|
|
200
202
|
|
|
201
203
|
//#endregion
|
|
202
|
-
|
|
204
|
+
//#region src/Version.ts
|
|
205
|
+
/** @returns the version from the package.json in the provided directory */
|
|
206
|
+
async function versionFromPackageJson(projectDir) {
|
|
207
|
+
const pkgJsonPath = new URL("./package.json", projectDir);
|
|
208
|
+
const pkgModule = await import(pkgJsonPath.href, { with: { type: "json" } });
|
|
209
|
+
const version = pkgModule.default.version;
|
|
210
|
+
return version;
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
//#endregion
|
|
214
|
+
//#region src/LoadModules.ts
|
|
215
|
+
/** load the wesl/wgsl shader sources */
|
|
216
|
+
async function loadModules(projectDir, baseDir, srcGlob) {
|
|
217
|
+
const foundFiles = await glob(`${srcGlob}`, {
|
|
218
|
+
cwd: projectDir,
|
|
219
|
+
ignore: "node_modules/**"
|
|
220
|
+
});
|
|
221
|
+
const shaderFiles = foundFiles.map((f) => path.resolve(projectDir, f));
|
|
222
|
+
const promisedSrcs = shaderFiles.map((f) => fs.readFile(f, { encoding: "utf8" }));
|
|
223
|
+
const src = await Promise.all(promisedSrcs);
|
|
224
|
+
if (src.length === 0) throw new Error(`no WGSL/WESL files found in ${srcGlob}`);
|
|
225
|
+
const baseDirAbs = path.resolve(projectDir, baseDir);
|
|
226
|
+
const relativePaths = shaderFiles.map((p) => path.relative(baseDirAbs, path.resolve(p)));
|
|
227
|
+
const moduleEntries = zip(relativePaths, src);
|
|
228
|
+
return Object.fromEntries(moduleEntries);
|
|
229
|
+
}
|
|
230
|
+
function zip(as, bs) {
|
|
231
|
+
return as.map((a, i) => [a, bs[i]]);
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
//#endregion
|
|
235
|
+
export { compileShader, dependencyBundles, loadModules, parseDependencies, runSimpleComputePipeline, testComputeShader, versionFromPackageJson, zip };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "wesl-tooling",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.9",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"files": [
|
|
6
6
|
"dist"
|
|
@@ -9,6 +9,7 @@
|
|
|
9
9
|
"module": "./dist/index.js",
|
|
10
10
|
"types": "./dist/index.d.ts",
|
|
11
11
|
"dependencies": {
|
|
12
|
+
"glob": "^11.0.2",
|
|
12
13
|
"import-meta-resolve": "^4.1.0",
|
|
13
14
|
"thimbleberry": "^0.2.10"
|
|
14
15
|
},
|
|
@@ -17,15 +18,12 @@
|
|
|
17
18
|
"tsdown": "^0.11.12"
|
|
18
19
|
},
|
|
19
20
|
"peerDependencies": {
|
|
20
|
-
"wesl": "^0.6.
|
|
21
|
+
"wesl": "^0.6.9"
|
|
21
22
|
},
|
|
22
23
|
"scripts": {
|
|
23
|
-
"echo": "echo",
|
|
24
24
|
"build": "tsdown",
|
|
25
25
|
"dev": "tsdown --watch",
|
|
26
|
-
"
|
|
27
|
-
"lint": "eslint src",
|
|
28
|
-
"typecheck": "tsc",
|
|
26
|
+
"typecheck": "tsgo",
|
|
29
27
|
"test": "FORCE_COLOR=1 vitest",
|
|
30
28
|
"test:once": "vitest run"
|
|
31
29
|
}
|