import type { BatchModuleResolver, WeslJsPlugin } from "wesl"; import type { WeslTomlInfo } from "wesl-tooling"; /** function type required 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 */ conditions?: Record, /** plugin-level options from query params (e.g., { include: "all" }) */ options?: Record, ) => Promise; /** 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; } export interface ProjectSources { weslSrc: Record; dependencies: string[]; } /** api supplied to plugin extensions */ export interface PluginExtensionApi { weslToml: () => Promise; weslSrc: () => Promise>; weslRegistry: () => Promise; weslMain: (baseId: string) => Promise; weslDependencies: () => Promise; /** weslRoot relative to tomlDir, with forward slashes. */ debugWeslRoot: () => Promise; /** Get weslSrc scoped to modules reachable from a root, plus their deps. */ scopedProject: (rootModuleName: string) => Promise; /** Fetch project sources, either all or scoped to reachable modules. */ fetchProject: ( rootModuleName: string, options?: Record, ) => Promise; }