wesl-plugin 0.6.15 → 0.6.16
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/{PluginExtension-CRGiifnw.d.ts → PluginExtension-DlhUTOLC.d.ts} +15 -9
- package/dist/{WeslPlugin-CqSrnjCh.js → WeslPlugin-C5v2QWgI.js} +86 -46
- package/dist/{WeslPluginOptions-BhpzoXUz.d.ts → WeslPluginOptions-BXvD7dWh.d.ts} +1 -1
- package/dist/pluginIndex.d.ts +1 -1
- package/dist/pluginIndex.js +4 -4
- package/dist/plugins/astro.d.ts +2 -2
- package/dist/plugins/astro.js +1 -1
- package/dist/plugins/esbuild.d.ts +2 -2
- package/dist/plugins/esbuild.js +1 -1
- package/dist/plugins/farm.d.ts +2 -2
- package/dist/plugins/farm.js +1 -1
- package/dist/plugins/nuxt.d.ts +2 -2
- package/dist/plugins/nuxt.js +3 -3
- package/dist/plugins/rollup.d.ts +2 -2
- package/dist/plugins/rollup.js +1 -1
- package/dist/plugins/rspack.d.ts +2 -2
- package/dist/plugins/rspack.js +1 -1
- package/dist/plugins/vite.d.ts +2 -2
- package/dist/plugins/vite.js +2 -2
- package/dist/plugins/webpack.d.ts +2 -2
- package/dist/plugins/webpack.js +2 -2
- package/dist/{vite-Dc5eE4Lm.js → vite-DIETRAJZ.js} +1 -1
- package/dist/{webpack-lAPeYZlg.js → webpack-CKpSvDUR.js} +1 -1
- package/package.json +2 -2
- package/src/BindingLayoutExtension.ts +2 -1
- package/src/PluginApi.ts +14 -17
- package/src/PluginExtension.ts +2 -2
- package/src/WeslPlugin.ts +2 -2
- package/src/extensions/LinkExtension.ts +2 -2
- package/src/extensions/StaticExtension.ts +2 -2
|
@@ -1,14 +1,20 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { BatchModuleResolver, WeslJsPlugin } from "wesl";
|
|
2
2
|
|
|
3
3
|
//#region ../wesl-tooling/src/LoadWeslToml.d.ts
|
|
4
4
|
/** Configuration from wesl.toml */
|
|
5
5
|
interface WeslToml {
|
|
6
|
-
/**
|
|
7
|
-
|
|
6
|
+
/** WESL edition (e.g. "unstable_2025") */
|
|
7
|
+
edition: string;
|
|
8
|
+
/** glob patterns to find .wesl/.wgsl files. Relative to the toml directory. */
|
|
9
|
+
include: string[];
|
|
8
10
|
/** base directory for wesl files. Relative to the toml directory. */
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
|
|
11
|
+
root: string;
|
|
12
|
+
/** glob patterns to exclude directories. */
|
|
13
|
+
exclude?: string[];
|
|
14
|
+
/** package manager ("npm" or "cargo") */
|
|
15
|
+
"package-manager"?: string;
|
|
16
|
+
/** names of directly referenced wesl shader packages (e.g. npm package names), or "auto" for auto-detection */
|
|
17
|
+
dependencies?: string[] | string;
|
|
12
18
|
}
|
|
13
19
|
/** Information about the loaded wesl.toml file and its location */
|
|
14
20
|
interface WeslTomlInfo {
|
|
@@ -18,8 +24,8 @@ interface WeslTomlInfo {
|
|
|
18
24
|
* Paths inside the toml are relative to this. */
|
|
19
25
|
tomlDir: string;
|
|
20
26
|
/** The wesl root, relative to the projectDir.
|
|
21
|
-
* This lets loadModules do `path.resolve(projectDir,
|
|
22
|
-
|
|
27
|
+
* This lets loadModules do `path.resolve(projectDir, resolvedRoot)` */
|
|
28
|
+
resolvedRoot: string;
|
|
23
29
|
/** The underlying toml file */
|
|
24
30
|
toml: WeslToml;
|
|
25
31
|
}
|
|
@@ -41,7 +47,7 @@ interface PluginExtension extends WeslJsPlugin {
|
|
|
41
47
|
interface PluginExtensionApi {
|
|
42
48
|
weslToml: () => Promise<WeslTomlInfo>;
|
|
43
49
|
weslSrc: () => Promise<Record<string, string>>;
|
|
44
|
-
weslRegistry: () => Promise<
|
|
50
|
+
weslRegistry: () => Promise<BatchModuleResolver>;
|
|
45
51
|
weslMain: (baseId: string) => Promise<string>;
|
|
46
52
|
weslDependencies: () => Promise<string[]>;
|
|
47
53
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { t as resolve } from "./import-meta-resolve-CUFqnZwT.js";
|
|
2
2
|
import path, { posix, win32 } from "node:path";
|
|
3
|
-
import { WeslParseError,
|
|
3
|
+
import { RecordResolver, WeslParseError, bindIdentsRecursive, filterMap, findValidRootDecls, minimalMangle } from "wesl";
|
|
4
4
|
import { fileURLToPath, pathToFileURL } from "node:url";
|
|
5
5
|
import * as actualFS from "node:fs";
|
|
6
6
|
import { createUnplugin } from "unplugin";
|
|
@@ -5841,6 +5841,41 @@ const glob = Object.assign(glob_, {
|
|
|
5841
5841
|
});
|
|
5842
5842
|
glob.glob = glob;
|
|
5843
5843
|
|
|
5844
|
+
//#endregion
|
|
5845
|
+
//#region ../wesl-tooling/src/FindUnboundIdents.ts
|
|
5846
|
+
/**
|
|
5847
|
+
* Find unbound package references in library sources.
|
|
5848
|
+
*
|
|
5849
|
+
* Binds local references without following cross-package imports, revealing
|
|
5850
|
+
* which external packages are referenced but not resolved.
|
|
5851
|
+
*
|
|
5852
|
+
* @param resolver - Module resolver that supports batch operations
|
|
5853
|
+
* @returns Array of unbound module paths, each as an array of path segments
|
|
5854
|
+
* (e.g., [['foo', 'bar', 'baz'], ['other', 'pkg']])
|
|
5855
|
+
*/
|
|
5856
|
+
function findUnboundIdents(resolver) {
|
|
5857
|
+
const bindContext = {
|
|
5858
|
+
resolver,
|
|
5859
|
+
conditions: {},
|
|
5860
|
+
knownDecls: /* @__PURE__ */ new Set(),
|
|
5861
|
+
foundScopes: /* @__PURE__ */ new Set(),
|
|
5862
|
+
globalNames: /* @__PURE__ */ new Set(),
|
|
5863
|
+
globalStatements: /* @__PURE__ */ new Map(),
|
|
5864
|
+
mangler: minimalMangle,
|
|
5865
|
+
unbound: [],
|
|
5866
|
+
dontFollowDecls: true
|
|
5867
|
+
};
|
|
5868
|
+
for (const [_modulePath, ast] of resolver.allModules()) {
|
|
5869
|
+
const declEntries = findValidRootDecls(ast.rootScope, {}).map((d) => [d.originalName, d]);
|
|
5870
|
+
const liveDecls = {
|
|
5871
|
+
decls: new Map(declEntries),
|
|
5872
|
+
parent: null
|
|
5873
|
+
};
|
|
5874
|
+
bindIdentsRecursive(ast.rootScope, bindContext, liveDecls, true);
|
|
5875
|
+
}
|
|
5876
|
+
return bindContext.unbound;
|
|
5877
|
+
}
|
|
5878
|
+
|
|
5844
5879
|
//#endregion
|
|
5845
5880
|
//#region ../../node_modules/.pnpm/toml@3.0.0/node_modules/toml/lib/parser.js
|
|
5846
5881
|
var require_parser = /* @__PURE__ */ __commonJS({ "../../node_modules/.pnpm/toml@3.0.0/node_modules/toml/lib/parser.js": ((exports, module) => {
|
|
@@ -9624,9 +9659,10 @@ var require_toml = /* @__PURE__ */ __commonJS({ "../../node_modules/.pnpm/toml@3
|
|
|
9624
9659
|
var import_toml = /* @__PURE__ */ __toESM(require_toml(), 1);
|
|
9625
9660
|
/** Default configuration when no wesl.toml is found */
|
|
9626
9661
|
const defaultWeslToml = {
|
|
9627
|
-
|
|
9628
|
-
|
|
9629
|
-
|
|
9662
|
+
edition: "unstable_2025",
|
|
9663
|
+
include: ["shaders/**/*.w[eg]sl"],
|
|
9664
|
+
root: "shaders",
|
|
9665
|
+
dependencies: "auto"
|
|
9630
9666
|
};
|
|
9631
9667
|
/**
|
|
9632
9668
|
* Load and parse a wesl.toml file from the fs.
|
|
@@ -9665,13 +9701,13 @@ async function findWeslToml(projectDir, specifiedToml) {
|
|
|
9665
9701
|
parsedToml = defaultWeslToml;
|
|
9666
9702
|
tomlDir = projectDir;
|
|
9667
9703
|
}
|
|
9668
|
-
const tomlToWeslRoot = path.resolve(tomlDir, parsedToml.
|
|
9704
|
+
const tomlToWeslRoot = path.resolve(tomlDir, parsedToml.root);
|
|
9669
9705
|
const projectDirAbs = path.resolve(projectDir);
|
|
9670
|
-
const
|
|
9706
|
+
const resolvedRoot = path.relative(projectDirAbs, tomlToWeslRoot);
|
|
9671
9707
|
return {
|
|
9672
9708
|
tomlFile,
|
|
9673
9709
|
tomlDir,
|
|
9674
|
-
|
|
9710
|
+
resolvedRoot,
|
|
9675
9711
|
toml: parsedToml
|
|
9676
9712
|
};
|
|
9677
9713
|
}
|
|
@@ -9679,48 +9715,48 @@ async function findWeslToml(projectDir, specifiedToml) {
|
|
|
9679
9715
|
//#endregion
|
|
9680
9716
|
//#region ../wesl-tooling/src/ParseDependencies.ts
|
|
9681
9717
|
/**
|
|
9682
|
-
* Find
|
|
9683
|
-
* (for packaging WESL files into a library)
|
|
9718
|
+
* Find package dependencies in WESL source files.
|
|
9684
9719
|
*
|
|
9685
|
-
*
|
|
9686
|
-
*
|
|
9687
|
-
* Those identifiers are the package dependencies.
|
|
9720
|
+
* Parses sources and partially binds identifiers to reveal unresolved package
|
|
9721
|
+
* references. Returns the longest resolvable npm subpath for each dependency.
|
|
9688
9722
|
*
|
|
9689
|
-
*
|
|
9690
|
-
*
|
|
9691
|
-
*
|
|
9692
|
-
*
|
|
9693
|
-
*
|
|
9694
|
-
*
|
|
9723
|
+
* For example, 'foo::bar::baz' could resolve to:
|
|
9724
|
+
* - 'foo/bar' (package foo, export './bar' bundle)
|
|
9725
|
+
* - 'foo' (package foo, default export)
|
|
9726
|
+
*
|
|
9727
|
+
* @param weslSrc - Record of WESL source files by path
|
|
9728
|
+
* @param projectDir - Project directory for resolving package imports
|
|
9729
|
+
* @returns Dependency paths in npm format (e.g., 'foo/bar', 'foo')
|
|
9695
9730
|
*/
|
|
9696
9731
|
function parseDependencies(weslSrc, projectDir) {
|
|
9697
|
-
|
|
9732
|
+
let resolver;
|
|
9698
9733
|
try {
|
|
9699
|
-
|
|
9734
|
+
resolver = new RecordResolver(weslSrc);
|
|
9700
9735
|
} catch (e) {
|
|
9701
|
-
if (e.cause instanceof WeslParseError)
|
|
9702
|
-
|
|
9736
|
+
if (e.cause instanceof WeslParseError) {
|
|
9737
|
+
console.error(e.message, "\n");
|
|
9738
|
+
return [];
|
|
9739
|
+
}
|
|
9740
|
+
throw e;
|
|
9703
9741
|
}
|
|
9704
|
-
const unbound = findUnboundIdents(
|
|
9742
|
+
const unbound = findUnboundIdents(resolver);
|
|
9705
9743
|
if (!unbound) return [];
|
|
9706
9744
|
const pkgRefs = unbound.filter((modulePath) => modulePath.length > 1 && modulePath[0] !== "constants");
|
|
9707
9745
|
if (pkgRefs.length === 0) return [];
|
|
9708
|
-
const projectURL =
|
|
9746
|
+
const projectURL = projectDirURL(projectDir);
|
|
9709
9747
|
const deps = filterMap(pkgRefs, (mPath) => unboundToDependency(mPath, projectURL));
|
|
9710
9748
|
return [...new Set(deps)];
|
|
9711
9749
|
}
|
|
9712
|
-
/**
|
|
9713
|
-
* Find the longest resolvable npm subpath from a module path.
|
|
9750
|
+
/** Find longest resolvable npm subpath from module path segments.
|
|
9714
9751
|
*
|
|
9715
|
-
* @param mPath
|
|
9716
|
-
* @param importerURL URL
|
|
9717
|
-
* @returns
|
|
9752
|
+
* @param mPath - Module path segments (e.g., ['foo', 'bar', 'baz', 'elem'])
|
|
9753
|
+
* @param importerURL - Base URL for resolution (e.g., 'file:///path/to/project/')
|
|
9754
|
+
* @returns Longest resolvable subpath (e.g., 'foo/bar/baz' or 'foo')
|
|
9718
9755
|
*/
|
|
9719
9756
|
function unboundToDependency(mPath, importerURL) {
|
|
9720
9757
|
return [...exportSubpaths(mPath)].find((subPath) => tryResolve(subPath, importerURL));
|
|
9721
9758
|
}
|
|
9722
|
-
/** Try
|
|
9723
|
-
* @return the resolved path */
|
|
9759
|
+
/** Try Node.js module resolution; returns undefined if unresolvable. */
|
|
9724
9760
|
function tryResolve(path$2, importerURL) {
|
|
9725
9761
|
try {
|
|
9726
9762
|
return resolve(path$2, importerURL);
|
|
@@ -9728,14 +9764,18 @@ function tryResolve(path$2, importerURL) {
|
|
|
9728
9764
|
return;
|
|
9729
9765
|
}
|
|
9730
9766
|
}
|
|
9731
|
-
/**
|
|
9732
|
-
*
|
|
9733
|
-
* longest subpath first.
|
|
9734
|
-
*/
|
|
9767
|
+
/** Yield possible export subpaths from module path, longest first.
|
|
9768
|
+
* Drops the last segment (element name) and iterates down. */
|
|
9735
9769
|
function* exportSubpaths(mPath) {
|
|
9736
9770
|
const longest = mPath.length - 1;
|
|
9737
9771
|
for (let i = longest; i >= 0; i--) yield mPath.slice(0, i).join("/");
|
|
9738
9772
|
}
|
|
9773
|
+
/** Normalize project directory to file:// URL with trailing slash. */
|
|
9774
|
+
function projectDirURL(projectDir) {
|
|
9775
|
+
if (projectDir.startsWith("file://")) return projectDir.endsWith("/") ? projectDir : `${projectDir}/`;
|
|
9776
|
+
const fileUrl = pathToFileURL(projectDir).href;
|
|
9777
|
+
return fileUrl.endsWith("/") ? fileUrl : `${fileUrl}/`;
|
|
9778
|
+
}
|
|
9739
9779
|
|
|
9740
9780
|
//#endregion
|
|
9741
9781
|
//#region src/PluginApi.ts
|
|
@@ -9767,10 +9807,9 @@ async function getRegistry(context, unpluginCtx) {
|
|
|
9767
9807
|
let { registry } = cache;
|
|
9768
9808
|
if (registry) return registry;
|
|
9769
9809
|
const loaded = await loadWesl(context, unpluginCtx);
|
|
9770
|
-
const {
|
|
9771
|
-
registry =
|
|
9772
|
-
|
|
9773
|
-
Object.keys(loaded).map((p) => path.resolve(resolvedWeslRoot, p)).forEach((f) => {
|
|
9810
|
+
const { resolvedRoot } = await getWeslToml(context, unpluginCtx);
|
|
9811
|
+
registry = new RecordResolver(loaded);
|
|
9812
|
+
Object.keys(loaded).map((p) => path.resolve(resolvedRoot, p)).forEach((f) => {
|
|
9774
9813
|
unpluginCtx.addWatchFile(f);
|
|
9775
9814
|
});
|
|
9776
9815
|
cache.registry = registry;
|
|
@@ -9784,8 +9823,9 @@ async function findDependencies(context, unpluginCtx) {
|
|
|
9784
9823
|
const { toml: toml$1, tomlDir: projectDir } = await getWeslToml(context, unpluginCtx);
|
|
9785
9824
|
const weslSrc = await loadWesl(context, unpluginCtx);
|
|
9786
9825
|
const { dependencies = [] } = toml$1;
|
|
9787
|
-
|
|
9788
|
-
|
|
9826
|
+
const depsArray = Array.isArray(dependencies) ? dependencies : [dependencies];
|
|
9827
|
+
if (!depsArray.includes("auto")) return depsArray;
|
|
9828
|
+
const base = depsArray.filter((dep) => dep !== "auto");
|
|
9789
9829
|
const deps = parseDependencies(weslSrc, projectDir);
|
|
9790
9830
|
return [...new Set([...base, ...deps])];
|
|
9791
9831
|
}
|
|
@@ -9796,9 +9836,9 @@ function makeGetWeslMain(context, unpluginContext) {
|
|
|
9796
9836
|
* @return the / separated path to the shader file, relative to the weslRoot
|
|
9797
9837
|
*/
|
|
9798
9838
|
async function getWeslMain(shaderPath) {
|
|
9799
|
-
const {
|
|
9839
|
+
const { resolvedRoot } = await getWeslToml(context, unpluginContext);
|
|
9800
9840
|
await fs$1.access(shaderPath);
|
|
9801
|
-
const absRoot = path.join(process.cwd(),
|
|
9841
|
+
const absRoot = path.join(process.cwd(), resolvedRoot);
|
|
9802
9842
|
return toUnixPath(path.relative(absRoot, shaderPath));
|
|
9803
9843
|
}
|
|
9804
9844
|
}
|
|
@@ -9810,8 +9850,8 @@ function makeGetWeslMain(context, unpluginContext) {
|
|
|
9810
9850
|
* values as wesl file contents.
|
|
9811
9851
|
*/
|
|
9812
9852
|
async function loadWesl(context, unpluginCtx) {
|
|
9813
|
-
const { toml: {
|
|
9814
|
-
const futureFiles =
|
|
9853
|
+
const { toml: { include }, resolvedRoot, tomlDir } = await getWeslToml(context, unpluginCtx);
|
|
9854
|
+
const futureFiles = include.map((g) => glob(g, {
|
|
9815
9855
|
cwd: tomlDir,
|
|
9816
9856
|
absolute: true
|
|
9817
9857
|
}));
|
|
@@ -9819,7 +9859,7 @@ async function loadWesl(context, unpluginCtx) {
|
|
|
9819
9859
|
files.forEach((f) => {
|
|
9820
9860
|
unpluginCtx.addWatchFile(f);
|
|
9821
9861
|
});
|
|
9822
|
-
return await loadFiles(files,
|
|
9862
|
+
return await loadFiles(files, resolvedRoot);
|
|
9823
9863
|
}
|
|
9824
9864
|
/** load a set of shader files, converting to paths relative to the weslRoot directory */
|
|
9825
9865
|
async function loadFiles(files, weslRoot) {
|
package/dist/pluginIndex.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { n as PluginExtension, r as PluginExtensionApi, t as ExtensionEmitFn } from "./PluginExtension-
|
|
1
|
+
import { n as PluginExtension, r as PluginExtensionApi, t as ExtensionEmitFn } from "./PluginExtension-DlhUTOLC.js";
|
|
2
2
|
|
|
3
3
|
//#region src/extensions/LinkExtension.d.ts
|
|
4
4
|
declare const linkBuildExtension: PluginExtension;
|
package/dist/pluginIndex.js
CHANGED
|
@@ -10,10 +10,10 @@ const linkBuildExtension = {
|
|
|
10
10
|
};
|
|
11
11
|
/** Emit a JavaScript LinkParams structure, ready for linking at runtime. */
|
|
12
12
|
async function emitLinkJs(baseId, api) {
|
|
13
|
-
const {
|
|
13
|
+
const { resolvedRoot, tomlDir } = await api.weslToml();
|
|
14
14
|
const weslSrc = await api.weslSrc();
|
|
15
15
|
const rootModuleName = noSuffix(await api.weslMain(baseId));
|
|
16
|
-
const debugWeslRoot = path.relative(tomlDir,
|
|
16
|
+
const debugWeslRoot = path.relative(tomlDir, resolvedRoot).replaceAll(path.sep, "/");
|
|
17
17
|
const autoDeps = await api.weslDependencies();
|
|
18
18
|
const sanitizedDeps = autoDeps.map((dep) => dep.replaceAll("/", "_"));
|
|
19
19
|
const bundleImports = autoDeps.map((p, i) => `import ${sanitizedDeps[i]} from "${p}";`).join("\n");
|
|
@@ -55,7 +55,7 @@ const staticBuildExtension = {
|
|
|
55
55
|
};
|
|
56
56
|
/** Emit a JavaScript file containing the wgsl string */
|
|
57
57
|
async function emitStaticJs(baseId, api, conditions) {
|
|
58
|
-
const {
|
|
58
|
+
const { resolvedRoot, tomlDir } = await api.weslToml();
|
|
59
59
|
const parentModule = url.pathToFileURL(path.join(tomlDir, "wesl.toml")).toString();
|
|
60
60
|
const futureLibs = (await api.weslDependencies()).map((d) => resolve(d, parentModule)).map((f) => import(f));
|
|
61
61
|
const libs = (await Promise.all(futureLibs)).map((m) => m.default);
|
|
@@ -63,7 +63,7 @@ async function emitStaticJs(baseId, api, conditions) {
|
|
|
63
63
|
export const wgsl = \`${(await link({
|
|
64
64
|
weslSrc: await api.weslSrc(),
|
|
65
65
|
rootModuleName: noSuffix(await api.weslMain(baseId)),
|
|
66
|
-
debugWeslRoot: path.relative(tomlDir,
|
|
66
|
+
debugWeslRoot: path.relative(tomlDir, resolvedRoot).replaceAll(path.sep, "/"),
|
|
67
67
|
libs,
|
|
68
68
|
conditions
|
|
69
69
|
})).dest}\`;
|
package/dist/plugins/astro.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import "../PluginExtension-
|
|
2
|
-
import { t as WeslPluginOptions } from "../WeslPluginOptions-
|
|
1
|
+
import "../PluginExtension-DlhUTOLC.js";
|
|
2
|
+
import { t as WeslPluginOptions } from "../WeslPluginOptions-BXvD7dWh.js";
|
|
3
3
|
|
|
4
4
|
//#region src/plugins/astro.d.ts
|
|
5
5
|
declare const _default: (options: WeslPluginOptions) => any;
|
package/dist/plugins/astro.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import "../PluginExtension-
|
|
2
|
-
import { t as WeslPluginOptions } from "../WeslPluginOptions-
|
|
1
|
+
import "../PluginExtension-DlhUTOLC.js";
|
|
2
|
+
import { t as WeslPluginOptions } from "../WeslPluginOptions-BXvD7dWh.js";
|
|
3
3
|
import * as esbuild0 from "esbuild";
|
|
4
4
|
|
|
5
5
|
//#region src/plugins/esbuild.d.ts
|
package/dist/plugins/esbuild.js
CHANGED
package/dist/plugins/farm.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import "../PluginExtension-
|
|
2
|
-
import { t as WeslPluginOptions } from "../WeslPluginOptions-
|
|
1
|
+
import "../PluginExtension-DlhUTOLC.js";
|
|
2
|
+
import { t as WeslPluginOptions } from "../WeslPluginOptions-BXvD7dWh.js";
|
|
3
3
|
import * as _farmfe_core0 from "@farmfe/core";
|
|
4
4
|
|
|
5
5
|
//#region src/plugins/farm.d.ts
|
package/dist/plugins/farm.js
CHANGED
package/dist/plugins/nuxt.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import "../PluginExtension-
|
|
2
|
-
import { t as WeslPluginOptions } from "../WeslPluginOptions-
|
|
1
|
+
import "../PluginExtension-DlhUTOLC.js";
|
|
2
|
+
import { t as WeslPluginOptions } from "../WeslPluginOptions-BXvD7dWh.js";
|
|
3
3
|
import * as _nuxt_schema0 from "@nuxt/schema";
|
|
4
4
|
|
|
5
5
|
//#region src/plugins/nuxt.d.ts
|
package/dist/plugins/nuxt.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import "../WeslPlugin-
|
|
1
|
+
import "../WeslPlugin-C5v2QWgI.js";
|
|
2
2
|
import "../import-meta-resolve-CUFqnZwT.js";
|
|
3
|
-
import { t as vite_default } from "../vite-
|
|
4
|
-
import { t as webpack_default } from "../webpack-
|
|
3
|
+
import { t as vite_default } from "../vite-DIETRAJZ.js";
|
|
4
|
+
import { t as webpack_default } from "../webpack-CKpSvDUR.js";
|
|
5
5
|
import { addVitePlugin, addWebpackPlugin, defineNuxtModule } from "@nuxt/kit";
|
|
6
6
|
import "@nuxt/schema";
|
|
7
7
|
|
package/dist/plugins/rollup.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import "../PluginExtension-
|
|
2
|
-
import { t as WeslPluginOptions } from "../WeslPluginOptions-
|
|
1
|
+
import "../PluginExtension-DlhUTOLC.js";
|
|
2
|
+
import { t as WeslPluginOptions } from "../WeslPluginOptions-BXvD7dWh.js";
|
|
3
3
|
import * as rollup0 from "rollup";
|
|
4
4
|
|
|
5
5
|
//#region src/plugins/rollup.d.ts
|
package/dist/plugins/rollup.js
CHANGED
package/dist/plugins/rspack.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import "../PluginExtension-
|
|
2
|
-
import { t as WeslPluginOptions } from "../WeslPluginOptions-
|
|
1
|
+
import "../PluginExtension-DlhUTOLC.js";
|
|
2
|
+
import { t as WeslPluginOptions } from "../WeslPluginOptions-BXvD7dWh.js";
|
|
3
3
|
|
|
4
4
|
//#region src/plugins/rspack.d.ts
|
|
5
5
|
declare const _default: (options: WeslPluginOptions) => RspackPluginInstance;
|
package/dist/plugins/rspack.js
CHANGED
package/dist/plugins/vite.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import "../PluginExtension-
|
|
2
|
-
import { t as WeslPluginOptions } from "../WeslPluginOptions-
|
|
1
|
+
import "../PluginExtension-DlhUTOLC.js";
|
|
2
|
+
import { t as WeslPluginOptions } from "../WeslPluginOptions-BXvD7dWh.js";
|
|
3
3
|
import * as vite0 from "vite";
|
|
4
4
|
|
|
5
5
|
//#region src/plugins/vite.d.ts
|
package/dist/plugins/vite.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import "../WeslPlugin-
|
|
1
|
+
import "../WeslPlugin-C5v2QWgI.js";
|
|
2
2
|
import "../import-meta-resolve-CUFqnZwT.js";
|
|
3
|
-
import { t as vite_default } from "../vite-
|
|
3
|
+
import { t as vite_default } from "../vite-DIETRAJZ.js";
|
|
4
4
|
|
|
5
5
|
export { vite_default as default };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import "../PluginExtension-
|
|
2
|
-
import { t as WeslPluginOptions } from "../WeslPluginOptions-
|
|
1
|
+
import "../PluginExtension-DlhUTOLC.js";
|
|
2
|
+
import { t as WeslPluginOptions } from "../WeslPluginOptions-BXvD7dWh.js";
|
|
3
3
|
import * as webpack0 from "webpack";
|
|
4
4
|
|
|
5
5
|
//#region src/plugins/webpack.d.ts
|
package/dist/plugins/webpack.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import "../WeslPlugin-
|
|
1
|
+
import "../WeslPlugin-C5v2QWgI.js";
|
|
2
2
|
import "../import-meta-resolve-CUFqnZwT.js";
|
|
3
|
-
import { t as webpack_default } from "../webpack-
|
|
3
|
+
import { t as webpack_default } from "../webpack-CKpSvDUR.js";
|
|
4
4
|
|
|
5
5
|
export { webpack_default as default };
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "wesl-plugin",
|
|
3
3
|
"description": "",
|
|
4
|
-
"version": "0.6.
|
|
4
|
+
"version": "0.6.16",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"files": [
|
|
7
7
|
"src",
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
},
|
|
26
26
|
"dependencies": {
|
|
27
27
|
"unplugin": "^2.3.5",
|
|
28
|
-
"wesl": "0.6.
|
|
28
|
+
"wesl": "0.6.16"
|
|
29
29
|
},
|
|
30
30
|
"devDependencies": {
|
|
31
31
|
"@nuxt/kit": "^3.17.6",
|
package/src/PluginApi.ts
CHANGED
|
@@ -2,7 +2,7 @@ import fs from "node:fs/promises";
|
|
|
2
2
|
import path from "node:path";
|
|
3
3
|
import { glob } from "glob";
|
|
4
4
|
import type { UnpluginBuildContext, UnpluginContext } from "unplugin";
|
|
5
|
-
import {
|
|
5
|
+
import { RecordResolver } from "wesl";
|
|
6
6
|
import {
|
|
7
7
|
findWeslToml,
|
|
8
8
|
parseDependencies,
|
|
@@ -48,22 +48,19 @@ export async function getWeslToml(
|
|
|
48
48
|
async function getRegistry(
|
|
49
49
|
context: PluginContext,
|
|
50
50
|
unpluginCtx: UnpluginBuildContext & UnpluginContext,
|
|
51
|
-
): Promise<
|
|
51
|
+
): Promise<RecordResolver> {
|
|
52
52
|
const { cache } = context;
|
|
53
53
|
let { registry } = cache;
|
|
54
54
|
if (registry) return registry;
|
|
55
55
|
|
|
56
56
|
// load wesl files into registry
|
|
57
57
|
const loaded = await loadWesl(context, unpluginCtx);
|
|
58
|
-
const {
|
|
58
|
+
const { resolvedRoot } = await getWeslToml(context, unpluginCtx);
|
|
59
59
|
|
|
60
|
-
registry =
|
|
61
|
-
parseIntoRegistry(loaded, registry);
|
|
60
|
+
registry = new RecordResolver(loaded);
|
|
62
61
|
|
|
63
62
|
// The paths are relative to the weslRoot, but vite needs actual filesystem paths
|
|
64
|
-
const fullPaths = Object.keys(loaded).map(p =>
|
|
65
|
-
path.resolve(resolvedWeslRoot, p),
|
|
66
|
-
);
|
|
63
|
+
const fullPaths = Object.keys(loaded).map(p => path.resolve(resolvedRoot, p));
|
|
67
64
|
|
|
68
65
|
// trigger clearing cache on shader file change
|
|
69
66
|
fullPaths.forEach(f => {
|
|
@@ -85,10 +82,10 @@ async function findDependencies(
|
|
|
85
82
|
const { toml, tomlDir: projectDir } = await getWeslToml(context, unpluginCtx);
|
|
86
83
|
const weslSrc = await loadWesl(context, unpluginCtx);
|
|
87
84
|
const { dependencies = [] } = toml;
|
|
88
|
-
const
|
|
89
|
-
if (!
|
|
85
|
+
const depsArray = Array.isArray(dependencies) ? dependencies : [dependencies];
|
|
86
|
+
if (!depsArray.includes("auto")) return depsArray;
|
|
90
87
|
|
|
91
|
-
const base =
|
|
88
|
+
const base = depsArray.filter(dep => dep !== "auto");
|
|
92
89
|
const deps = parseDependencies(weslSrc, projectDir);
|
|
93
90
|
const combined = new Set([...base, ...deps]);
|
|
94
91
|
return [...combined];
|
|
@@ -105,10 +102,10 @@ function makeGetWeslMain(
|
|
|
105
102
|
* @return the / separated path to the shader file, relative to the weslRoot
|
|
106
103
|
*/
|
|
107
104
|
async function getWeslMain(shaderPath: string): Promise<string> {
|
|
108
|
-
const {
|
|
105
|
+
const { resolvedRoot } = await getWeslToml(context, unpluginContext);
|
|
109
106
|
await fs.access(shaderPath); // if file doesn't exist, report now when the user problem is clear.
|
|
110
107
|
|
|
111
|
-
const absRoot = path.join(process.cwd(),
|
|
108
|
+
const absRoot = path.join(process.cwd(), resolvedRoot);
|
|
112
109
|
const weslRootToMain = path.relative(absRoot, shaderPath);
|
|
113
110
|
return toUnixPath(weslRootToMain);
|
|
114
111
|
}
|
|
@@ -126,11 +123,11 @@ async function loadWesl(
|
|
|
126
123
|
unpluginCtx: UnpluginBuildContext & UnpluginContext,
|
|
127
124
|
): Promise<Record<string, string>> {
|
|
128
125
|
const {
|
|
129
|
-
toml: {
|
|
130
|
-
|
|
126
|
+
toml: { include },
|
|
127
|
+
resolvedRoot,
|
|
131
128
|
tomlDir,
|
|
132
129
|
} = await getWeslToml(context, unpluginCtx);
|
|
133
|
-
const futureFiles =
|
|
130
|
+
const futureFiles = include.map(g =>
|
|
134
131
|
glob(g, { cwd: tomlDir, absolute: true }),
|
|
135
132
|
);
|
|
136
133
|
const files = (await Promise.all(futureFiles)).flat();
|
|
@@ -140,7 +137,7 @@ async function loadWesl(
|
|
|
140
137
|
unpluginCtx.addWatchFile(f);
|
|
141
138
|
});
|
|
142
139
|
|
|
143
|
-
return await loadFiles(files,
|
|
140
|
+
return await loadFiles(files, resolvedRoot);
|
|
144
141
|
}
|
|
145
142
|
|
|
146
143
|
/** load a set of shader files, converting to paths relative to the weslRoot directory */
|
package/src/PluginExtension.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { BatchModuleResolver, WeslJsPlugin } from "wesl";
|
|
2
2
|
import type { WeslTomlInfo } from "wesl-tooling";
|
|
3
3
|
|
|
4
4
|
/** function type required for for emit extensions */
|
|
@@ -27,7 +27,7 @@ export interface PluginExtension extends WeslJsPlugin {
|
|
|
27
27
|
export interface PluginExtensionApi {
|
|
28
28
|
weslToml: () => Promise<WeslTomlInfo>;
|
|
29
29
|
weslSrc: () => Promise<Record<string, string>>;
|
|
30
|
-
weslRegistry: () => Promise<
|
|
30
|
+
weslRegistry: () => Promise<BatchModuleResolver>;
|
|
31
31
|
weslMain: (baseId: string) => Promise<string>;
|
|
32
32
|
weslDependencies: () => Promise<string[]>;
|
|
33
33
|
}
|
package/src/WeslPlugin.ts
CHANGED
|
@@ -9,7 +9,7 @@ import {
|
|
|
9
9
|
type UnpluginContextMeta,
|
|
10
10
|
type UnpluginOptions,
|
|
11
11
|
} from "unplugin";
|
|
12
|
-
import type { Conditions,
|
|
12
|
+
import type { Conditions, RecordResolver } from "wesl";
|
|
13
13
|
import type { WeslToml, WeslTomlInfo } from "wesl-tooling";
|
|
14
14
|
import { buildApi } from "./PluginApi.ts";
|
|
15
15
|
import type { PluginExtension } from "./PluginExtension.ts";
|
|
@@ -22,7 +22,7 @@ export type { WeslToml, WeslTomlInfo };
|
|
|
22
22
|
* (a plugin instance supports only one shader project)
|
|
23
23
|
*/
|
|
24
24
|
interface PluginCache {
|
|
25
|
-
registry?:
|
|
25
|
+
registry?: RecordResolver;
|
|
26
26
|
weslToml?: WeslTomlInfo;
|
|
27
27
|
}
|
|
28
28
|
|
|
@@ -15,14 +15,14 @@ async function emitLinkJs(
|
|
|
15
15
|
baseId: string,
|
|
16
16
|
api: PluginExtensionApi,
|
|
17
17
|
): Promise<string> {
|
|
18
|
-
const {
|
|
18
|
+
const { resolvedRoot, tomlDir } = await api.weslToml();
|
|
19
19
|
|
|
20
20
|
const weslSrc = await api.weslSrc();
|
|
21
21
|
|
|
22
22
|
const rootModule = await api.weslMain(baseId);
|
|
23
23
|
const rootModuleName = noSuffix(rootModule);
|
|
24
24
|
|
|
25
|
-
const tomlRelative = path.relative(tomlDir,
|
|
25
|
+
const tomlRelative = path.relative(tomlDir, resolvedRoot);
|
|
26
26
|
const debugWeslRoot = tomlRelative.replaceAll(path.sep, "/");
|
|
27
27
|
|
|
28
28
|
const autoDeps = await api.weslDependencies();
|
|
@@ -28,7 +28,7 @@ async function emitStaticJs(
|
|
|
28
28
|
api: PluginExtensionApi,
|
|
29
29
|
conditions?: Conditions,
|
|
30
30
|
): Promise<string> {
|
|
31
|
-
const {
|
|
31
|
+
const { resolvedRoot, tomlDir } = await api.weslToml();
|
|
32
32
|
|
|
33
33
|
// resolve import module relative to the root of the shader project
|
|
34
34
|
const parentModule = url
|
|
@@ -49,7 +49,7 @@ async function emitStaticJs(
|
|
|
49
49
|
const rootModuleName = noSuffix(rootModule);
|
|
50
50
|
|
|
51
51
|
// find weslRoot
|
|
52
|
-
const tomlRelative = path.relative(tomlDir,
|
|
52
|
+
const tomlRelative = path.relative(tomlDir, resolvedRoot);
|
|
53
53
|
const debugWeslRoot = tomlRelative.replaceAll(path.sep, "/");
|
|
54
54
|
|
|
55
55
|
const result = await link({
|