wesl-plugin 0.6.0-pre5 → 0.6.0-pre7
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-BPBKs2pN.d.ts → PluginExtension-egUuLQCG.d.ts} +8 -6
- package/dist/{chunk-ZJBZ62NB.js → chunk-MAE4GAHG.js} +1 -1
- package/dist/{chunk-USWZ2CIV.js → chunk-NFFZEA4R.js} +1 -1
- package/dist/{chunk-WRYP67OK.js → chunk-ZDLLLCLM.js} +1 -1
- package/dist/pluginIndex.d.ts +2 -2
- package/dist/pluginIndex.js +17 -17
- 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/{weslPluginOptions-BBX99ilB.d.ts → weslPluginOptions-Om3wryHY.d.ts} +1 -1
- package/package.json +2 -2
- package/src/LinkExtension.ts +20 -17
- package/src/defaultSuffixTypes.d.ts +2 -2
- package/src/weslPlugin.ts +14 -10
|
@@ -2,19 +2,21 @@ import { WeslJsPlugin, ParsedRegistry } from 'wesl';
|
|
|
2
2
|
|
|
3
3
|
/** loaded (or synthesized) info from .toml */
|
|
4
4
|
interface WeslToml {
|
|
5
|
-
/** glob search strings to find .wesl/.wgsl files. Relative to the toml directory
|
|
5
|
+
/** glob search strings to find .wesl/.wgsl files. Relative to the toml directory. */
|
|
6
6
|
weslFiles: string[];
|
|
7
|
-
/** base directory for wesl files. Relative to the toml directory
|
|
7
|
+
/** base directory for wesl files. Relative to the toml directory. */
|
|
8
8
|
weslRoot: string;
|
|
9
|
+
/** names of directly referenced wesl shader packages (e.g. npm package names) */
|
|
10
|
+
dependencies?: string[];
|
|
9
11
|
}
|
|
10
12
|
interface WeslTomlInfo {
|
|
11
13
|
/** The path to the toml file, relative to the cwd */
|
|
12
14
|
tomlFile: string;
|
|
13
|
-
/** The path to the directory that contains the toml.
|
|
15
|
+
/** The path to the directory that contains the toml.
|
|
16
|
+
* Relative to the cwd. Paths inside the toml are relative to this. */
|
|
14
17
|
tomlDir: string;
|
|
15
|
-
/**
|
|
16
|
-
*
|
|
17
|
-
*/
|
|
18
|
+
/** The wesl root, relative to the cwd.
|
|
19
|
+
* This lets us correctly do `path.resolve(resolvedWeslRoot, someShaderFile)` */
|
|
18
20
|
resolvedWeslRoot: string;
|
|
19
21
|
/** The underlying toml file */
|
|
20
22
|
toml: WeslToml;
|
|
@@ -6700,7 +6700,6 @@ async function getRegistry(context, unpluginCtx) {
|
|
|
6700
6700
|
const fullPaths = Object.keys(loaded).map(
|
|
6701
6701
|
(p) => path2.resolve(resolvedWeslRoot, p)
|
|
6702
6702
|
);
|
|
6703
|
-
fullPaths.forEach((f) => unpluginCtx.addWatchFile(f));
|
|
6704
6703
|
if (context.meta.watchMode) {
|
|
6705
6704
|
fullPaths.forEach((f) => {
|
|
6706
6705
|
chokidar.watch(f).on("change", () => {
|
|
@@ -6730,6 +6729,7 @@ async function loadWesl(context, unpluginCtx) {
|
|
|
6730
6729
|
(g) => glob(g, { cwd: tomlDir, absolute: true })
|
|
6731
6730
|
);
|
|
6732
6731
|
const files = (await Promise.all(futureFiles)).flat();
|
|
6732
|
+
files.forEach((f) => unpluginCtx.addWatchFile(f));
|
|
6733
6733
|
return await loadFiles(files, resolvedWeslRoot);
|
|
6734
6734
|
}
|
|
6735
6735
|
async function loadFiles(files, weslRoot) {
|
package/dist/pluginIndex.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { P as PluginExtension } from './PluginExtension-
|
|
2
|
-
export { E as ExtensionEmitFn, a as PluginExtensionApi } from './PluginExtension-
|
|
1
|
+
import { P as PluginExtension } from './PluginExtension-egUuLQCG.js';
|
|
2
|
+
export { E as ExtensionEmitFn, a as PluginExtensionApi } from './PluginExtension-egUuLQCG.js';
|
|
3
3
|
import 'wesl';
|
|
4
4
|
|
|
5
5
|
declare const linkBuildPlugin: PluginExtension;
|
package/dist/pluginIndex.js
CHANGED
|
@@ -2,40 +2,40 @@ import "./chunk-JSBRDJBE.js";
|
|
|
2
2
|
|
|
3
3
|
// src/LinkExtension.ts
|
|
4
4
|
import path from "node:path";
|
|
5
|
-
import { noSuffix
|
|
5
|
+
import { noSuffix } from "wesl";
|
|
6
6
|
var linkBuildPlugin = {
|
|
7
7
|
extensionName: "link",
|
|
8
8
|
emitFn: emitLinkJs
|
|
9
9
|
};
|
|
10
10
|
async function emitLinkJs(baseId, api) {
|
|
11
|
-
const { resolvedWeslRoot } = await api.weslToml();
|
|
11
|
+
const { resolvedWeslRoot, toml } = await api.weslToml();
|
|
12
|
+
const { dependencies = [] } = toml;
|
|
12
13
|
const debugWeslRoot = resolvedWeslRoot.replaceAll(path.sep, "/");
|
|
13
14
|
const weslSrc = await api.weslSrc();
|
|
14
15
|
const rootModule = await api.weslMain(baseId);
|
|
15
16
|
const rootModuleName = noSuffix(rootModule);
|
|
16
17
|
const rootName = path.basename(rootModuleName);
|
|
17
|
-
const
|
|
18
|
-
const bundleImports = packages.map((p) => `import ${p} from "${p}";`).join("\n");
|
|
18
|
+
const bundleImports = dependencies.map((p) => `import ${p} from "${p}";`).join("\n");
|
|
19
19
|
const paramsName = `link${rootName}Config`;
|
|
20
|
-
const
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
20
|
+
const linkParams = {
|
|
21
|
+
rootModuleName,
|
|
22
|
+
weslSrc,
|
|
23
|
+
debugWeslRoot
|
|
24
|
+
};
|
|
25
|
+
const libsStr = `libs: [${dependencies.join(", ")}]`;
|
|
26
|
+
const linkParamsStr = `{
|
|
27
|
+
${serializeFields(linkParams)},
|
|
28
|
+
${libsStr},
|
|
29
|
+
}`;
|
|
30
30
|
const src = `
|
|
31
31
|
${bundleImports}
|
|
32
|
-
export const ${paramsName} = ${
|
|
32
|
+
export const ${paramsName} = ${linkParamsStr};
|
|
33
33
|
export default ${paramsName};
|
|
34
34
|
`;
|
|
35
35
|
return src;
|
|
36
36
|
}
|
|
37
|
-
function
|
|
38
|
-
return Object.
|
|
37
|
+
function serializeFields(record) {
|
|
38
|
+
return Object.entries(record).map(([k, v]) => ` ${k}: ${JSON.stringify(v, null, 2)}`).join(",\n");
|
|
39
39
|
}
|
|
40
40
|
export {
|
|
41
41
|
linkBuildPlugin
|
package/dist/plugins/astro.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { W as WeslPluginOptions } from '../weslPluginOptions-
|
|
2
|
-
import '../PluginExtension-
|
|
1
|
+
import { W as WeslPluginOptions } from '../weslPluginOptions-Om3wryHY.js';
|
|
2
|
+
import '../PluginExtension-egUuLQCG.js';
|
|
3
3
|
import 'wesl';
|
|
4
4
|
|
|
5
5
|
declare const _default: (options: WeslPluginOptions) => any;
|
package/dist/plugins/astro.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as esbuild from 'esbuild';
|
|
2
|
-
import { W as WeslPluginOptions } from '../weslPluginOptions-
|
|
3
|
-
import '../PluginExtension-
|
|
2
|
+
import { W as WeslPluginOptions } from '../weslPluginOptions-Om3wryHY.js';
|
|
3
|
+
import '../PluginExtension-egUuLQCG.js';
|
|
4
4
|
import 'wesl';
|
|
5
5
|
|
|
6
6
|
declare const _default: (options?: WeslPluginOptions | undefined) => esbuild.Plugin;
|
package/dist/plugins/esbuild.js
CHANGED
package/dist/plugins/farm.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as _farmfe_core from '@farmfe/core';
|
|
2
|
-
import { W as WeslPluginOptions } from '../weslPluginOptions-
|
|
3
|
-
import '../PluginExtension-
|
|
2
|
+
import { W as WeslPluginOptions } from '../weslPluginOptions-Om3wryHY.js';
|
|
3
|
+
import '../PluginExtension-egUuLQCG.js';
|
|
4
4
|
import 'wesl';
|
|
5
5
|
|
|
6
6
|
declare const _default: (options?: WeslPluginOptions | undefined) => _farmfe_core.JsPlugin;
|
package/dist/plugins/farm.js
CHANGED
package/dist/plugins/nuxt.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as _nuxt_schema from '@nuxt/schema';
|
|
2
|
-
import { W as WeslPluginOptions } from '../weslPluginOptions-
|
|
3
|
-
import '../PluginExtension-
|
|
2
|
+
import { W as WeslPluginOptions } from '../weslPluginOptions-Om3wryHY.js';
|
|
3
|
+
import '../PluginExtension-egUuLQCG.js';
|
|
4
4
|
import 'wesl';
|
|
5
5
|
|
|
6
6
|
interface ModuleOptions extends WeslPluginOptions {
|
package/dist/plugins/nuxt.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import {
|
|
2
2
|
webpack_default
|
|
3
|
-
} from "../chunk-
|
|
3
|
+
} from "../chunk-NFFZEA4R.js";
|
|
4
4
|
import {
|
|
5
5
|
vite_default
|
|
6
|
-
} from "../chunk-
|
|
7
|
-
import "../chunk-
|
|
6
|
+
} from "../chunk-MAE4GAHG.js";
|
|
7
|
+
import "../chunk-ZDLLLCLM.js";
|
|
8
8
|
import "../chunk-JSBRDJBE.js";
|
|
9
9
|
|
|
10
10
|
// src/plugins/nuxt.ts
|
package/dist/plugins/rollup.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as rollup from 'rollup';
|
|
2
|
-
import { W as WeslPluginOptions } from '../weslPluginOptions-
|
|
3
|
-
import '../PluginExtension-
|
|
2
|
+
import { W as WeslPluginOptions } from '../weslPluginOptions-Om3wryHY.js';
|
|
3
|
+
import '../PluginExtension-egUuLQCG.js';
|
|
4
4
|
import 'wesl';
|
|
5
5
|
|
|
6
6
|
declare const _default: (options?: WeslPluginOptions | undefined) => rollup.Plugin<any> | rollup.Plugin<any>[];
|
package/dist/plugins/rollup.js
CHANGED
package/dist/plugins/rspack.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { W as WeslPluginOptions } from '../weslPluginOptions-
|
|
2
|
-
import '../PluginExtension-
|
|
1
|
+
import { W as WeslPluginOptions } from '../weslPluginOptions-Om3wryHY.js';
|
|
2
|
+
import '../PluginExtension-egUuLQCG.js';
|
|
3
3
|
import 'wesl';
|
|
4
4
|
|
|
5
5
|
declare const _default: (options?: WeslPluginOptions | undefined) => RspackPluginInstance;
|
package/dist/plugins/rspack.js
CHANGED
package/dist/plugins/vite.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as vite from 'vite';
|
|
2
|
-
import { W as WeslPluginOptions } from '../weslPluginOptions-
|
|
3
|
-
import '../PluginExtension-
|
|
2
|
+
import { W as WeslPluginOptions } from '../weslPluginOptions-Om3wryHY.js';
|
|
3
|
+
import '../PluginExtension-egUuLQCG.js';
|
|
4
4
|
import 'wesl';
|
|
5
5
|
|
|
6
6
|
declare const _default: (options?: WeslPluginOptions | undefined) => vite.Plugin<any> | vite.Plugin<any>[];
|
package/dist/plugins/vite.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as webpack from 'webpack';
|
|
2
|
-
import { W as WeslPluginOptions } from '../weslPluginOptions-
|
|
3
|
-
import '../PluginExtension-
|
|
2
|
+
import { W as WeslPluginOptions } from '../weslPluginOptions-Om3wryHY.js';
|
|
3
|
+
import '../PluginExtension-egUuLQCG.js';
|
|
4
4
|
import 'wesl';
|
|
5
5
|
|
|
6
6
|
declare const _default: (options?: WeslPluginOptions | undefined) => webpack.WebpackPluginInstance;
|
package/dist/plugins/webpack.js
CHANGED
package/package.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "wesl-plugin",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.6.0-
|
|
4
|
+
"version": "0.6.0-pre7",
|
|
5
5
|
"dependencies": {
|
|
6
6
|
"chokidar": "^4.0.3",
|
|
7
7
|
"toml": "^3.0.0",
|
|
8
8
|
"unplugin": "^2.1.2",
|
|
9
|
-
"wesl": "0.6.0-
|
|
9
|
+
"wesl": "0.6.0-pre7"
|
|
10
10
|
},
|
|
11
11
|
"devDependencies": {
|
|
12
12
|
"@nuxt/kit": "^3.15.2",
|
package/src/LinkExtension.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import path from "node:path";
|
|
2
|
-
import {
|
|
2
|
+
import { LinkParams, noSuffix } from "wesl";
|
|
3
3
|
import { PluginExtension, PluginExtensionApi } from "./PluginExtension.ts";
|
|
4
4
|
|
|
5
5
|
export const linkBuildPlugin: PluginExtension = {
|
|
@@ -12,40 +12,43 @@ async function emitLinkJs(
|
|
|
12
12
|
baseId: string,
|
|
13
13
|
api: PluginExtensionApi,
|
|
14
14
|
): Promise<string> {
|
|
15
|
-
const { resolvedWeslRoot } = await api.weslToml();
|
|
15
|
+
const { resolvedWeslRoot, toml } = await api.weslToml();
|
|
16
|
+
const { dependencies = [] } = toml;
|
|
16
17
|
const debugWeslRoot = resolvedWeslRoot.replaceAll(path.sep, "/");
|
|
17
18
|
const weslSrc = await api.weslSrc();
|
|
18
19
|
const rootModule = await api.weslMain(baseId);
|
|
19
20
|
const rootModuleName = noSuffix(rootModule);
|
|
20
21
|
const rootName = path.basename(rootModuleName);
|
|
21
|
-
const packages = scanForPackages(weslSrc);
|
|
22
22
|
|
|
23
|
-
const bundleImports =
|
|
23
|
+
const bundleImports = dependencies
|
|
24
24
|
.map(p => `import ${p} from "${p}";`)
|
|
25
25
|
.join("\n");
|
|
26
26
|
|
|
27
27
|
const paramsName = `link${rootName}Config`;
|
|
28
28
|
|
|
29
|
-
const
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
29
|
+
const linkParams: LinkParams = {
|
|
30
|
+
rootModuleName,
|
|
31
|
+
weslSrc,
|
|
32
|
+
debugWeslRoot,
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
const libsStr = `libs: [${dependencies.join(", ")}]`;
|
|
36
|
+
const linkParamsStr = `{
|
|
37
|
+
${serializeFields(linkParams)},
|
|
38
|
+
${libsStr},
|
|
39
|
+
}`;
|
|
39
40
|
|
|
40
41
|
const src = `
|
|
41
42
|
${bundleImports}
|
|
42
|
-
export const ${paramsName} = ${
|
|
43
|
+
export const ${paramsName} = ${linkParamsStr};
|
|
43
44
|
export default ${paramsName};
|
|
44
45
|
`;
|
|
45
46
|
|
|
46
47
|
return src;
|
|
47
48
|
}
|
|
48
49
|
|
|
49
|
-
function
|
|
50
|
-
return Object.
|
|
50
|
+
function serializeFields(record: Record<string, any>) {
|
|
51
|
+
return Object.entries(record)
|
|
52
|
+
.map(([k, v]) => ` ${k}: ${JSON.stringify(v, null, 2)}`)
|
|
53
|
+
.join(",\n");
|
|
51
54
|
}
|
package/src/weslPlugin.ts
CHANGED
|
@@ -24,22 +24,26 @@ import type { WeslPluginOptions } from "./weslPluginOptions.js";
|
|
|
24
24
|
|
|
25
25
|
/** loaded (or synthesized) info from .toml */
|
|
26
26
|
export interface WeslToml {
|
|
27
|
-
/** glob search strings to find .wesl/.wgsl files. Relative to the toml directory
|
|
27
|
+
/** glob search strings to find .wesl/.wgsl files. Relative to the toml directory. */
|
|
28
28
|
weslFiles: string[];
|
|
29
29
|
|
|
30
|
-
/** base directory for wesl files. Relative to the toml directory
|
|
30
|
+
/** base directory for wesl files. Relative to the toml directory. */
|
|
31
31
|
weslRoot: string;
|
|
32
|
+
|
|
33
|
+
/** names of directly referenced wesl shader packages (e.g. npm package names) */
|
|
34
|
+
dependencies?: string[];
|
|
32
35
|
}
|
|
33
36
|
|
|
34
37
|
export interface WeslTomlInfo {
|
|
35
38
|
/** The path to the toml file, relative to the cwd */
|
|
36
39
|
tomlFile: string;
|
|
37
|
-
|
|
40
|
+
|
|
41
|
+
/** The path to the directory that contains the toml.
|
|
42
|
+
* Relative to the cwd. Paths inside the toml are relative to this. */
|
|
38
43
|
tomlDir: string;
|
|
39
44
|
|
|
40
|
-
/**
|
|
41
|
-
*
|
|
42
|
-
*/
|
|
45
|
+
/** The wesl root, relative to the cwd.
|
|
46
|
+
* This lets us correctly do `path.resolve(resolvedWeslRoot, someShaderFile)` */
|
|
43
47
|
resolvedWeslRoot: string;
|
|
44
48
|
|
|
45
49
|
/** The underlying toml file */
|
|
@@ -242,9 +246,6 @@ async function getRegistry(
|
|
|
242
246
|
path.resolve(resolvedWeslRoot, p),
|
|
243
247
|
);
|
|
244
248
|
|
|
245
|
-
// trigger rebuild on shader file change
|
|
246
|
-
fullPaths.forEach(f => unpluginCtx.addWatchFile(f));
|
|
247
|
-
|
|
248
249
|
// trigger clearing cache on shader file change
|
|
249
250
|
if (context.meta.watchMode) {
|
|
250
251
|
fullPaths.forEach(f => {
|
|
@@ -292,7 +293,10 @@ async function loadWesl(
|
|
|
292
293
|
glob(g, { cwd: tomlDir, absolute: true }),
|
|
293
294
|
);
|
|
294
295
|
const files = (await Promise.all(futureFiles)).flat();
|
|
295
|
-
|
|
296
|
+
|
|
297
|
+
// trigger rebuild on shader file change
|
|
298
|
+
files.forEach(f => unpluginCtx.addWatchFile(f));
|
|
299
|
+
|
|
296
300
|
return await loadFiles(files, resolvedWeslRoot);
|
|
297
301
|
}
|
|
298
302
|
|