UNPKG

@fs-eire/wgsl-template

Version:

A powerful template system for generating WGSL (WebGPU Shading Language) code with support for parameters, conditionals, and multiple output formats including C++ code generation.

74 lines 2.59 kB
import type { TemplateRepository, TemplatePass0, TemplatePass1, TemplatePass2 } from "./types.js"; export * from "./errors.js"; export type { TemplateRepository, TemplatePass0, TemplatePass1, TemplatePass2, LoadFromDirectoryOptions, } from "./types.js"; export { loader } from "./loader-impl.js"; /** * Options for the build process. */ export interface BuildOptions { /** * Multiple source directories containing the source templates. * Can be strings (directory paths) or objects with path and optional alias. * When using aliases, template names will be prefixed with the alias. */ sourceDirs: ({ path: string; alias?: string; } | string)[]; /** * The output directory where the generated files will be written. */ outDir: string; /** * The file extension of the template files. */ templateExt: string; /** * * The code generator to use for generating the output files. */ generator: string; /** * The prefix to use for include paths in the generated files. * * This is used to ensure that the generated code can find included files correctly. * * If the prefix is `"myproject/a/"`, then an include path like * `#include "b/shader.wgsl"` * will be transformed to * `#include "myproject/a/b/shader.wgsl"` */ includePathPrefix?: string; /** * Whether to preserve code references in the generated output. * * If true, comments will be added to the generated code indicating the original template file and line number. * This can be useful for debugging and tracing back to the source templates. * * Default is false. */ preserveCodeReference?: boolean; } /** * Represents the result of a build operation. */ export interface BuildResult { /** * The status of the build operation. * - "success" if the build completed successfully. * - "build-error" if there was an error during the build process. * - "file-write-error" if there was an error writing files to the output directory. */ status: "success" | "build-error" | "file-write-error"; /** * The error object if the build failed. */ error?: Error; result: { pass0?: TemplateRepository<TemplatePass0>; pass1?: TemplateRepository<TemplatePass1>; pass2?: TemplateRepository<TemplatePass2>; files?: TemplateRepository<string>; }; } export declare const build: (options: BuildOptions) => Promise<BuildResult>; //# sourceMappingURL=index.d.ts.map