typegpu
Version:
A thin layer between JS and WebGPU/WGSL that improves development experience and allows for faster iteration.
30 lines (29 loc) • 1.34 kB
TypeScript
export declare const bannedTokens: Set<string>;
export declare const builtins: Set<string>;
/**
* Sanitizes the primer so that it is compliant with WGSL guidelines.
* This primer is not necessarily a valid identifier yet, as it may still collide with other idents or reserved keywords.
*/
export declare function sanitizePrimer(primer: string | undefined): string;
type ValidationResult = {
success: true;
error?: undefined;
} | {
success: false;
error?: string | undefined;
};
/**
* A function for checking whether an identifier is valid.
* If `ident` passes the checks, it is not necessarily a valid identifier yet, as it may still collide with other idents or reserved keywords.
* @example
* validateIdentifier("ident"); // { success: true }
* validateIdentifier("_"); // { success: false, error: `Identifiers cannot be equal to '' or '_'` }
* validateIdentifier("my variable"); // { success: false, error: "Identifiers cannot contain whitespace." }
* validateIdentifier("0"); // { success: false, error: "Identifier is not compliant with the WGSL guideline." }
*/
export declare function validateIdentifier(ident: string): ValidationResult;
/**
* Same as `validateIdentifier`, except also checks for bannedToken clashes.
*/
export declare function validateProp(ident: string): ValidationResult;
export {};