wesl-plugin 0.6.69 → 0.6.70
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-N4JBtncl.d.mts → PluginExtension-nH8vi0nm.d.mts} +5 -1
- package/dist/{StaticExtension-BvgvwnkI.mjs → StaticExtension-Chl5KPpw.mjs} +42 -42
- package/dist/WeslPlugin-BKQJvQve.mjs +7343 -0
- package/dist/{WeslPluginOptions-DHLy1_Dm.d.mts → WeslPluginOptions-DWIrd183.d.mts} +1 -1
- package/dist/pluginIndex.d.mts +1 -1
- package/dist/pluginIndex.mjs +1 -1
- package/dist/plugins/astro.d.mts +1 -2
- package/dist/plugins/astro.mjs +3 -3
- package/dist/plugins/esbuild.d.mts +3 -4
- package/dist/plugins/esbuild.mjs +2 -2
- package/dist/plugins/farm.d.mts +1 -2
- package/dist/plugins/farm.mjs +2 -2
- package/dist/plugins/nuxt.d.mts +1 -2
- package/dist/plugins/nuxt.mjs +2 -2
- package/dist/plugins/rollup.d.mts +3 -4
- package/dist/plugins/rollup.mjs +2 -2
- package/dist/plugins/rspack.d.mts +1 -2
- package/dist/plugins/rspack.mjs +2 -2
- package/dist/plugins/vite.d.mts +3 -4
- package/dist/plugins/vite.mjs +2 -2
- package/dist/plugins/webpack.d.mts +3 -4
- package/dist/plugins/webpack.mjs +2 -2
- package/package.json +2 -2
- package/dist/WeslPlugin-C1pAE34o.mjs +0 -10077
|
@@ -33,8 +33,12 @@ interface WeslTomlInfo {
|
|
|
33
33
|
//#region src/PluginExtension.d.ts
|
|
34
34
|
/** function type required for for emit extensions */
|
|
35
35
|
type ExtensionEmitFn = (/** absolute path to the shader to which the extension is attached */
|
|
36
|
+
|
|
36
37
|
shaderPath: string, /** support functions available to plugin extensions */
|
|
37
|
-
|
|
38
|
+
|
|
39
|
+
pluginApi: PluginExtensionApi, /** static conditions specified on the js import */
|
|
40
|
+
|
|
41
|
+
conditions?: Record<string, boolean>) => Promise<string>;
|
|
38
42
|
/** an extension that runs inside the wesl-js build plugin */
|
|
39
43
|
interface PluginExtension extends WeslJsPlugin {
|
|
40
44
|
/** javascript imports with this suffix will trigger the plugin */
|
|
@@ -165,8 +165,8 @@ codes.ERR_INVALID_PACKAGE_CONFIG = createError(
|
|
|
165
165
|
* @param {string} [base]
|
|
166
166
|
* @param {string} [message]
|
|
167
167
|
*/
|
|
168
|
-
(path
|
|
169
|
-
return `Invalid package config ${path
|
|
168
|
+
(path, base, message) => {
|
|
169
|
+
return `Invalid package config ${path}${base ? ` while importing ${base}` : ""}${message ? `. ${message}` : ""}`;
|
|
170
170
|
},
|
|
171
171
|
Error
|
|
172
172
|
);
|
|
@@ -196,8 +196,8 @@ codes.ERR_MODULE_NOT_FOUND = createError(
|
|
|
196
196
|
* @param {string} base
|
|
197
197
|
* @param {boolean} [exactUrl]
|
|
198
198
|
*/
|
|
199
|
-
(path
|
|
200
|
-
return `Cannot find ${exactUrl ? "module" : "package"} '${path
|
|
199
|
+
(path, base, exactUrl = false) => {
|
|
200
|
+
return `Cannot find ${exactUrl ? "module" : "package"} '${path}' imported from ${base}`;
|
|
201
201
|
},
|
|
202
202
|
Error
|
|
203
203
|
);
|
|
@@ -235,8 +235,8 @@ codes.ERR_UNKNOWN_FILE_EXTENSION = createError(
|
|
|
235
235
|
* @param {string} extension
|
|
236
236
|
* @param {string} path
|
|
237
237
|
*/
|
|
238
|
-
(extension, path
|
|
239
|
-
return `Unknown file extension "${extension}" for ${path
|
|
238
|
+
(extension, path) => {
|
|
239
|
+
return `Unknown file extension "${extension}" for ${path}`;
|
|
240
240
|
},
|
|
241
241
|
TypeError
|
|
242
242
|
);
|
|
@@ -471,8 +471,8 @@ function getPackageScopeConfig(resolved) {
|
|
|
471
471
|
* @param {URL} url - The URL to get the package type for.
|
|
472
472
|
* @returns {PackageType}
|
|
473
473
|
*/
|
|
474
|
-
function getPackageType(url
|
|
475
|
-
return getPackageScopeConfig(url
|
|
474
|
+
function getPackageType(url) {
|
|
475
|
+
return getPackageScopeConfig(url).type;
|
|
476
476
|
}
|
|
477
477
|
|
|
478
478
|
//#endregion
|
|
@@ -537,8 +537,8 @@ function getDataProtocolModuleFormat(parsed) {
|
|
|
537
537
|
* @param {URL} url
|
|
538
538
|
* @returns {string}
|
|
539
539
|
*/
|
|
540
|
-
function extname(url
|
|
541
|
-
const pathname = url
|
|
540
|
+
function extname(url) {
|
|
541
|
+
const pathname = url.pathname;
|
|
542
542
|
let index = pathname.length;
|
|
543
543
|
while (index--) {
|
|
544
544
|
const code = pathname.codePointAt(index);
|
|
@@ -550,22 +550,22 @@ function extname(url$1) {
|
|
|
550
550
|
/**
|
|
551
551
|
* @type {ProtocolHandler}
|
|
552
552
|
*/
|
|
553
|
-
function getFileProtocolModuleFormat(url
|
|
554
|
-
const value = extname(url
|
|
553
|
+
function getFileProtocolModuleFormat(url, _context, ignoreErrors) {
|
|
554
|
+
const value = extname(url);
|
|
555
555
|
if (value === ".js") {
|
|
556
|
-
const packageType = getPackageType(url
|
|
556
|
+
const packageType = getPackageType(url);
|
|
557
557
|
if (packageType !== "none") return packageType;
|
|
558
558
|
return "commonjs";
|
|
559
559
|
}
|
|
560
560
|
if (value === "") {
|
|
561
|
-
const packageType = getPackageType(url
|
|
561
|
+
const packageType = getPackageType(url);
|
|
562
562
|
if (packageType === "none" || packageType === "commonjs") return "commonjs";
|
|
563
563
|
return "module";
|
|
564
564
|
}
|
|
565
|
-
const format
|
|
566
|
-
if (format
|
|
565
|
+
const format = extensionFormatMap[value];
|
|
566
|
+
if (format) return format;
|
|
567
567
|
if (ignoreErrors) return;
|
|
568
|
-
throw new ERR_UNKNOWN_FILE_EXTENSION(value, fileURLToPath(url
|
|
568
|
+
throw new ERR_UNKNOWN_FILE_EXTENSION(value, fileURLToPath(url));
|
|
569
569
|
}
|
|
570
570
|
function getHttpProtocolModuleFormat() {}
|
|
571
571
|
/**
|
|
@@ -573,10 +573,10 @@ function getHttpProtocolModuleFormat() {}
|
|
|
573
573
|
* @param {{parentURL: string}} context
|
|
574
574
|
* @returns {string | null}
|
|
575
575
|
*/
|
|
576
|
-
function defaultGetFormatWithoutErrors(url
|
|
577
|
-
const protocol = url
|
|
576
|
+
function defaultGetFormatWithoutErrors(url, context) {
|
|
577
|
+
const protocol = url.protocol;
|
|
578
578
|
if (!hasOwnProperty.call(protocolHandlers, protocol)) return null;
|
|
579
|
-
return protocolHandlers[protocol](url
|
|
579
|
+
return protocolHandlers[protocol](url, context, true) || null;
|
|
580
580
|
}
|
|
581
581
|
|
|
582
582
|
//#endregion
|
|
@@ -649,10 +649,10 @@ function emitInvalidSegmentDeprecation(target, request, match, packageJsonUrl, i
|
|
|
649
649
|
* @param {string} [main]
|
|
650
650
|
* @returns {void}
|
|
651
651
|
*/
|
|
652
|
-
function emitLegacyIndexDeprecation(url
|
|
652
|
+
function emitLegacyIndexDeprecation(url, packageJsonUrl, base, main) {
|
|
653
653
|
if (process.noDeprecation) return;
|
|
654
|
-
if (defaultGetFormatWithoutErrors(url
|
|
655
|
-
const urlPath = fileURLToPath(url
|
|
654
|
+
if (defaultGetFormatWithoutErrors(url, { parentURL: base.href }) !== "module") return;
|
|
655
|
+
const urlPath = fileURLToPath(url.href);
|
|
656
656
|
const packagePath = fileURLToPath(new URL$1(".", packageJsonUrl));
|
|
657
657
|
const basePath = fileURLToPath(base);
|
|
658
658
|
if (!main) process.emitWarning(`No "main" or "exports" field defined in the package.json for ${packagePath} resolving the main entry point "${urlPath.slice(packagePath.length)}", imported from ${basePath}.\nDefault "index" lookups for the main are deprecated for ES modules.`, "DeprecationWarning", "DEP0151");
|
|
@@ -662,9 +662,9 @@ function emitLegacyIndexDeprecation(url$1, packageJsonUrl, base, main) {
|
|
|
662
662
|
* @param {string} path
|
|
663
663
|
* @returns {Stats | undefined}
|
|
664
664
|
*/
|
|
665
|
-
function tryStatSync(path
|
|
665
|
+
function tryStatSync(path) {
|
|
666
666
|
try {
|
|
667
|
-
return statSync(path
|
|
667
|
+
return statSync(path);
|
|
668
668
|
} catch {}
|
|
669
669
|
}
|
|
670
670
|
/**
|
|
@@ -678,8 +678,8 @@ function tryStatSync(path$1) {
|
|
|
678
678
|
* @param {URL} url
|
|
679
679
|
* @returns {boolean}
|
|
680
680
|
*/
|
|
681
|
-
function fileExists(url
|
|
682
|
-
const stats = statSync(url
|
|
681
|
+
function fileExists(url) {
|
|
682
|
+
const stats = statSync(url, { throwIfNoEntry: false });
|
|
683
683
|
const isFile = stats ? stats.isFile() : void 0;
|
|
684
684
|
return isFile === null || isFile === void 0 ? false : isFile;
|
|
685
685
|
}
|
|
@@ -695,7 +695,7 @@ function legacyMainResolve(packageJsonUrl, packageConfig, base) {
|
|
|
695
695
|
if (packageConfig.main !== void 0) {
|
|
696
696
|
guess = new URL$1(packageConfig.main, packageJsonUrl);
|
|
697
697
|
if (fileExists(guess)) return guess;
|
|
698
|
-
const tries
|
|
698
|
+
const tries = [
|
|
699
699
|
`./${packageConfig.main}.js`,
|
|
700
700
|
`./${packageConfig.main}.json`,
|
|
701
701
|
`./${packageConfig.main}.node`,
|
|
@@ -703,9 +703,9 @@ function legacyMainResolve(packageJsonUrl, packageConfig, base) {
|
|
|
703
703
|
`./${packageConfig.main}/index.json`,
|
|
704
704
|
`./${packageConfig.main}/index.node`
|
|
705
705
|
];
|
|
706
|
-
let i
|
|
707
|
-
while (++i
|
|
708
|
-
guess = new URL$1(tries
|
|
706
|
+
let i = -1;
|
|
707
|
+
while (++i < tries.length) {
|
|
708
|
+
guess = new URL$1(tries[i], packageJsonUrl);
|
|
709
709
|
if (fileExists(guess)) break;
|
|
710
710
|
guess = void 0;
|
|
711
711
|
}
|
|
@@ -826,12 +826,12 @@ function resolvePackageTargetString(target, subpath, match, packageJsonUrl, base
|
|
|
826
826
|
if (subpath !== "" && !pattern && target[target.length - 1] !== "/") throw invalidPackageTarget(match, target, packageJsonUrl, internal, base);
|
|
827
827
|
if (!target.startsWith("./")) {
|
|
828
828
|
if (internal && !target.startsWith("../") && !target.startsWith("/")) {
|
|
829
|
-
let isURL
|
|
829
|
+
let isURL = false;
|
|
830
830
|
try {
|
|
831
831
|
new URL$1(target);
|
|
832
|
-
isURL
|
|
832
|
+
isURL = true;
|
|
833
833
|
} catch {}
|
|
834
|
-
if (!isURL
|
|
834
|
+
if (!isURL) return packageResolve(pattern ? RegExpPrototypeSymbolReplace.call(patternRegEx, target, () => subpath) : target + subpath, packageJsonUrl, conditions);
|
|
835
835
|
}
|
|
836
836
|
throw invalidPackageTarget(match, target, packageJsonUrl, internal, base);
|
|
837
837
|
}
|
|
@@ -1096,8 +1096,8 @@ function packageResolve(specifier, base, conditions) {
|
|
|
1096
1096
|
const packageConfig = getPackageScopeConfig(base);
|
|
1097
1097
|
/* c8 ignore next 16 */
|
|
1098
1098
|
if (packageConfig.exists) {
|
|
1099
|
-
const packageJsonUrl
|
|
1100
|
-
if (packageConfig.name === packageName && packageConfig.exports !== void 0 && packageConfig.exports !== null) return packageExportsResolve(packageJsonUrl
|
|
1099
|
+
const packageJsonUrl = pathToFileURL(packageConfig.pjsonPath);
|
|
1100
|
+
if (packageConfig.name === packageName && packageConfig.exports !== void 0 && packageConfig.exports !== null) return packageExportsResolve(packageJsonUrl, packageSubpath, packageConfig, base, conditions);
|
|
1101
1101
|
}
|
|
1102
1102
|
let packageJsonUrl = new URL$1("./node_modules/" + packageName + "/package.json", base);
|
|
1103
1103
|
let packageJsonPath = fileURLToPath(packageJsonUrl);
|
|
@@ -1111,12 +1111,12 @@ function packageResolve(specifier, base, conditions) {
|
|
|
1111
1111
|
packageJsonPath = fileURLToPath(packageJsonUrl);
|
|
1112
1112
|
continue;
|
|
1113
1113
|
}
|
|
1114
|
-
const packageConfig
|
|
1114
|
+
const packageConfig = read(packageJsonPath, {
|
|
1115
1115
|
base,
|
|
1116
1116
|
specifier
|
|
1117
1117
|
});
|
|
1118
|
-
if (packageConfig
|
|
1119
|
-
if (packageSubpath === ".") return legacyMainResolve(packageJsonUrl, packageConfig
|
|
1118
|
+
if (packageConfig.exports !== void 0 && packageConfig.exports !== null) return packageExportsResolve(packageJsonUrl, packageSubpath, packageConfig, base, conditions);
|
|
1119
|
+
if (packageSubpath === ".") return legacyMainResolve(packageJsonUrl, packageConfig, base);
|
|
1120
1120
|
return new URL$1(packageSubpath, packageJsonUrl);
|
|
1121
1121
|
} while (packageJsonPath.length !== lastPath.length);
|
|
1122
1122
|
throw new ERR_MODULE_NOT_FOUND(packageName, fileURLToPath(base), false);
|
|
@@ -1261,10 +1261,10 @@ function defaultResolve(specifier, context = {}) {
|
|
|
1261
1261
|
if (protocol === "node:") return { url: specifier };
|
|
1262
1262
|
if (parsed && parsed.protocol === "node:") return { url: specifier };
|
|
1263
1263
|
const conditions = getConditionsSet(context.conditions);
|
|
1264
|
-
const url
|
|
1264
|
+
const url = moduleResolve(specifier, new URL$1(parentURL), conditions, false);
|
|
1265
1265
|
return {
|
|
1266
|
-
url: url
|
|
1267
|
-
format: defaultGetFormatWithoutErrors(url
|
|
1266
|
+
url: url.href,
|
|
1267
|
+
format: defaultGetFormatWithoutErrors(url, { parentURL })
|
|
1268
1268
|
};
|
|
1269
1269
|
}
|
|
1270
1270
|
|