UNPKG

wesl-plugin

Version:

[![NPM Version](https://img.shields.io/npm/v/wesl-plugin)](https://www.npmjs.com/package/wesl-plugin) [![Static Badge](https://img.shields.io/badge/Read%20the%20-Docs-blue)](https://wesl-lang.dev/)

34 lines (27 loc) 1.21 kB
import type { ParsedRegistry, WeslJsPlugin } from "wesl"; import type { WeslTomlInfo } from "./WeslPlugin.ts"; /** function type required for for emit extensions */ export type ExtensionEmitFn = ( /** absolute path to the shader to which the extension is attached */ shaderPath: string, /** support functions available to plugin extensions */ pluginApi: PluginExtensionApi, /** static conditions specified on the js import */ // (currently used for ?static) conditions?: Record<string, boolean>, ) => Promise<string>; /** an extension that runs inside the wesl-js build plugin */ export interface PluginExtension extends WeslJsPlugin { /** javascript imports with this suffix will trigger the plugin */ extensionName: string; /** generate javascript text for js/ts importers to use. * e.g. import myPluginJs from "./foo.wesl?myPlugin"; */ emitFn: ExtensionEmitFn; } /** api supplied to plugin extensions */ export interface PluginExtensionApi { weslToml: () => Promise<WeslTomlInfo>; weslSrc: () => Promise<Record<string, string>>; weslRegistry: () => Promise<ParsedRegistry>; weslMain: (baseId: string) => Promise<string>; weslDependencies: () => Promise<string[]>; }