wesl-plugin 0.6.0-pre7 → 0.6.0-pre8
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/{chunk-MAE4GAHG.js → chunk-76TWXIYH.js} +1 -1
- package/dist/{chunk-ZDLLLCLM.js → chunk-GFPPDTJP.js} +18 -34
- package/dist/{chunk-NFFZEA4R.js → chunk-IDITK737.js} +1 -1
- package/dist/plugins/astro.js +1 -1
- package/dist/plugins/esbuild.js +1 -1
- package/dist/plugins/farm.js +1 -1
- package/dist/plugins/nuxt.js +3 -3
- package/dist/plugins/rollup.js +1 -1
- package/dist/plugins/rspack.js +1 -1
- package/dist/plugins/vite.js +2 -2
- package/dist/plugins/webpack.js +2 -2
- package/package.json +2 -3
- package/src/weslPlugin.ts +19 -35
|
@@ -212,9 +212,6 @@ var require_brace_expansion = __commonJS({
|
|
|
212
212
|
}
|
|
213
213
|
});
|
|
214
214
|
|
|
215
|
-
// src/weslPlugin.ts
|
|
216
|
-
import chokidar from "chokidar";
|
|
217
|
-
|
|
218
215
|
// ../../node_modules/.pnpm/minimatch@10.0.1/node_modules/minimatch/dist/esm/index.js
|
|
219
216
|
var import_brace_expansion = __toESM(require_brace_expansion(), 1);
|
|
220
217
|
|
|
@@ -6593,28 +6590,29 @@ import fs from "node:fs/promises";
|
|
|
6593
6590
|
import path2 from "node:path";
|
|
6594
6591
|
import toml from "toml";
|
|
6595
6592
|
import { createUnplugin } from "unplugin";
|
|
6596
|
-
import {
|
|
6597
|
-
filterMap,
|
|
6598
|
-
parsedRegistry,
|
|
6599
|
-
parseIntoRegistry
|
|
6600
|
-
} from "wesl";
|
|
6593
|
+
import { parsedRegistry, parseIntoRegistry } from "wesl";
|
|
6601
6594
|
function weslPlugin(options = {}, meta) {
|
|
6602
6595
|
const cache = {};
|
|
6603
6596
|
const context = { cache, meta, options };
|
|
6604
6597
|
return {
|
|
6605
6598
|
name: "wesl-plugin",
|
|
6606
6599
|
resolveId: buildResolver(options),
|
|
6607
|
-
load: buildLoader(context)
|
|
6600
|
+
load: buildLoader(context),
|
|
6601
|
+
watchChange(id, change) {
|
|
6602
|
+
if (id.endsWith("wesl.toml")) {
|
|
6603
|
+
cache.weslToml = void 0;
|
|
6604
|
+
cache.registry = void 0;
|
|
6605
|
+
} else {
|
|
6606
|
+
cache.registry = void 0;
|
|
6607
|
+
}
|
|
6608
|
+
}
|
|
6608
6609
|
};
|
|
6609
6610
|
}
|
|
6610
6611
|
function pluginNames(options) {
|
|
6611
|
-
|
|
6612
|
-
const suffixes = filterMap(extensions, (p) => p.extensionName);
|
|
6613
|
-
return suffixes;
|
|
6612
|
+
return options.extensions?.map((p) => p.extensionName) ?? [];
|
|
6614
6613
|
}
|
|
6615
6614
|
function pluginsByName(options) {
|
|
6616
|
-
const
|
|
6617
|
-
const entries = filterMap(extensions, (p) => [p.extensionName, p]);
|
|
6615
|
+
const entries = options.extensions?.map((p) => [p.extensionName, p]) ?? [];
|
|
6618
6616
|
return Object.fromEntries(entries);
|
|
6619
6617
|
}
|
|
6620
6618
|
var pluginSuffix = /(?<baseId>.*\.w[eg]sl)\?(?<pluginName>[\w_-]+)/;
|
|
@@ -6622,9 +6620,6 @@ function buildResolver(options) {
|
|
|
6622
6620
|
const suffixes = pluginNames(options);
|
|
6623
6621
|
return resolver;
|
|
6624
6622
|
function resolver(id) {
|
|
6625
|
-
if (id === options.weslToml || id === "wesl.toml") {
|
|
6626
|
-
return id;
|
|
6627
|
-
}
|
|
6628
6623
|
const matched = pluginSuffixMatch(id, suffixes);
|
|
6629
6624
|
return matched ? id : null;
|
|
6630
6625
|
}
|
|
@@ -6659,13 +6654,13 @@ function buildLoader(context) {
|
|
|
6659
6654
|
}
|
|
6660
6655
|
}
|
|
6661
6656
|
async function getWeslToml(context, unpluginCtx) {
|
|
6662
|
-
const { cache
|
|
6657
|
+
const { cache } = context;
|
|
6663
6658
|
if (cache.weslToml) return cache.weslToml;
|
|
6664
|
-
const
|
|
6659
|
+
const tomlFile = context.options.weslToml ?? "wesl.toml";
|
|
6660
|
+
unpluginCtx.addWatchFile(tomlFile);
|
|
6665
6661
|
let parsedToml;
|
|
6666
6662
|
try {
|
|
6667
6663
|
const tomlString = await fs.readFile(tomlFile, "utf-8");
|
|
6668
|
-
unpluginCtx.addWatchFile(tomlFile);
|
|
6669
6664
|
parsedToml = toml.parse(tomlString);
|
|
6670
6665
|
} catch {
|
|
6671
6666
|
console.log(`using defaults: no wesl.toml found at ${tomlFile}`);
|
|
@@ -6681,12 +6676,6 @@ async function getWeslToml(context, unpluginCtx) {
|
|
|
6681
6676
|
),
|
|
6682
6677
|
toml: parsedToml
|
|
6683
6678
|
};
|
|
6684
|
-
if (context.meta.watchMode) {
|
|
6685
|
-
chokidar.watch(tomlFile).on("change", () => {
|
|
6686
|
-
cache.registry = void 0;
|
|
6687
|
-
cache.weslToml = void 0;
|
|
6688
|
-
});
|
|
6689
|
-
}
|
|
6690
6679
|
return cache.weslToml;
|
|
6691
6680
|
}
|
|
6692
6681
|
async function getRegistry(context, unpluginCtx) {
|
|
@@ -6700,14 +6689,9 @@ async function getRegistry(context, unpluginCtx) {
|
|
|
6700
6689
|
const fullPaths = Object.keys(loaded).map(
|
|
6701
6690
|
(p) => path2.resolve(resolvedWeslRoot, p)
|
|
6702
6691
|
);
|
|
6703
|
-
|
|
6704
|
-
|
|
6705
|
-
|
|
6706
|
-
console.log("resetting cache", f);
|
|
6707
|
-
cache.registry = void 0;
|
|
6708
|
-
});
|
|
6709
|
-
});
|
|
6710
|
-
}
|
|
6692
|
+
fullPaths.forEach((f) => {
|
|
6693
|
+
unpluginCtx.addWatchFile(f);
|
|
6694
|
+
});
|
|
6711
6695
|
cache.registry = registry;
|
|
6712
6696
|
return registry;
|
|
6713
6697
|
}
|
package/dist/plugins/astro.js
CHANGED
package/dist/plugins/esbuild.js
CHANGED
package/dist/plugins/farm.js
CHANGED
package/dist/plugins/nuxt.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import {
|
|
2
2
|
webpack_default
|
|
3
|
-
} from "../chunk-
|
|
3
|
+
} from "../chunk-IDITK737.js";
|
|
4
4
|
import {
|
|
5
5
|
vite_default
|
|
6
|
-
} from "../chunk-
|
|
7
|
-
import "../chunk-
|
|
6
|
+
} from "../chunk-76TWXIYH.js";
|
|
7
|
+
import "../chunk-GFPPDTJP.js";
|
|
8
8
|
import "../chunk-JSBRDJBE.js";
|
|
9
9
|
|
|
10
10
|
// src/plugins/nuxt.ts
|
package/dist/plugins/rollup.js
CHANGED
package/dist/plugins/rspack.js
CHANGED
package/dist/plugins/vite.js
CHANGED
package/dist/plugins/webpack.js
CHANGED
package/package.json
CHANGED
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "wesl-plugin",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.6.0-
|
|
4
|
+
"version": "0.6.0-pre8",
|
|
5
5
|
"dependencies": {
|
|
6
|
-
"chokidar": "^4.0.3",
|
|
7
6
|
"toml": "^3.0.0",
|
|
8
7
|
"unplugin": "^2.1.2",
|
|
9
|
-
"wesl": "0.6.0-
|
|
8
|
+
"wesl": "0.6.0-pre8"
|
|
10
9
|
},
|
|
11
10
|
"devDependencies": {
|
|
12
11
|
"@nuxt/kit": "^3.15.2",
|
package/src/weslPlugin.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import chokidar from "chokidar";
|
|
2
1
|
import { glob } from "glob";
|
|
3
2
|
import fs from "node:fs/promises";
|
|
4
3
|
import path from "node:path";
|
|
@@ -13,12 +12,7 @@ import type {
|
|
|
13
12
|
UnpluginOptions
|
|
14
13
|
} from "unplugin";
|
|
15
14
|
import { createUnplugin } from "unplugin";
|
|
16
|
-
import {
|
|
17
|
-
filterMap,
|
|
18
|
-
parsedRegistry,
|
|
19
|
-
ParsedRegistry,
|
|
20
|
-
parseIntoRegistry
|
|
21
|
-
} from "wesl";
|
|
15
|
+
import { parsedRegistry, ParsedRegistry, parseIntoRegistry } from "wesl";
|
|
22
16
|
import { PluginExtension, PluginExtensionApi } from "./PluginExtension.js";
|
|
23
17
|
import type { WeslPluginOptions } from "./weslPluginOptions.js";
|
|
24
18
|
|
|
@@ -102,20 +96,26 @@ export function weslPlugin(
|
|
|
102
96
|
name: "wesl-plugin",
|
|
103
97
|
resolveId: buildResolver(options),
|
|
104
98
|
load: buildLoader(context),
|
|
99
|
+
watchChange(id, change) {
|
|
100
|
+
if (id.endsWith("wesl.toml")) {
|
|
101
|
+
// The cache is shared for multiple imports
|
|
102
|
+
cache.weslToml = undefined;
|
|
103
|
+
cache.registry = undefined;
|
|
104
|
+
} else {
|
|
105
|
+
cache.registry = undefined;
|
|
106
|
+
}
|
|
107
|
+
},
|
|
105
108
|
};
|
|
106
109
|
}
|
|
107
110
|
|
|
108
111
|
function pluginNames(options: WeslPluginOptions): string[] {
|
|
109
|
-
|
|
110
|
-
const suffixes = filterMap(extensions, p => p.extensionName);
|
|
111
|
-
return suffixes;
|
|
112
|
+
return options.extensions?.map(p => p.extensionName) ?? [];
|
|
112
113
|
}
|
|
113
114
|
|
|
114
115
|
function pluginsByName(
|
|
115
116
|
options: WeslPluginOptions,
|
|
116
117
|
): Record<string, PluginExtension> {
|
|
117
|
-
const
|
|
118
|
-
const entries = filterMap(extensions, p => [p.extensionName, p]);
|
|
118
|
+
const entries = options.extensions?.map(p => [p.extensionName, p]) ?? [];
|
|
119
119
|
return Object.fromEntries(entries);
|
|
120
120
|
}
|
|
121
121
|
|
|
@@ -131,9 +131,6 @@ function buildResolver(options: WeslPluginOptions): Resolver {
|
|
|
131
131
|
this: UnpluginBuildContext & UnpluginContext,
|
|
132
132
|
id: string,
|
|
133
133
|
): string | null {
|
|
134
|
-
if (id === options.weslToml || id === "wesl.toml") {
|
|
135
|
-
return id;
|
|
136
|
-
}
|
|
137
134
|
const matched = pluginSuffixMatch(id, suffixes);
|
|
138
135
|
return matched ? id : null;
|
|
139
136
|
}
|
|
@@ -190,14 +187,15 @@ async function getWeslToml(
|
|
|
190
187
|
context: PluginContext,
|
|
191
188
|
unpluginCtx: UnpluginBuildContext & UnpluginContext,
|
|
192
189
|
): Promise<WeslTomlInfo> {
|
|
193
|
-
const { cache
|
|
190
|
+
const { cache } = context;
|
|
194
191
|
if (cache.weslToml) return cache.weslToml;
|
|
195
|
-
|
|
192
|
+
|
|
193
|
+
const tomlFile = context.options.weslToml ?? "wesl.toml";
|
|
194
|
+
unpluginCtx.addWatchFile(tomlFile); // The cache gets cleared by the watchChange hook
|
|
196
195
|
|
|
197
196
|
let parsedToml: WeslToml;
|
|
198
197
|
try {
|
|
199
198
|
const tomlString = await fs.readFile(tomlFile, "utf-8");
|
|
200
|
-
unpluginCtx.addWatchFile(tomlFile);
|
|
201
199
|
parsedToml = toml.parse(tomlString) as WeslToml;
|
|
202
200
|
} catch {
|
|
203
201
|
console.log(`using defaults: no wesl.toml found at ${tomlFile}`);
|
|
@@ -213,15 +211,6 @@ async function getWeslToml(
|
|
|
213
211
|
),
|
|
214
212
|
toml: parsedToml,
|
|
215
213
|
};
|
|
216
|
-
|
|
217
|
-
if (context.meta.watchMode) {
|
|
218
|
-
// clear cache on wesl.toml change
|
|
219
|
-
chokidar.watch(tomlFile).on("change", () => {
|
|
220
|
-
cache.registry = undefined;
|
|
221
|
-
cache.weslToml = undefined;
|
|
222
|
-
});
|
|
223
|
-
}
|
|
224
|
-
|
|
225
214
|
return cache.weslToml;
|
|
226
215
|
}
|
|
227
216
|
|
|
@@ -247,14 +236,9 @@ async function getRegistry(
|
|
|
247
236
|
);
|
|
248
237
|
|
|
249
238
|
// trigger clearing cache on shader file change
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
console.log("resetting cache", f);
|
|
254
|
-
cache.registry = undefined;
|
|
255
|
-
});
|
|
256
|
-
});
|
|
257
|
-
}
|
|
239
|
+
fullPaths.forEach(f => {
|
|
240
|
+
unpluginCtx.addWatchFile(f);
|
|
241
|
+
});
|
|
258
242
|
|
|
259
243
|
cache.registry = registry;
|
|
260
244
|
return registry;
|