|
| 1 | +/* tslint:disable */ |
| 2 | +/* eslint-disable */ |
| 3 | +/** |
| 4 | + * Generate Rust and TypeScript code from a LUMOS schema |
| 5 | + * |
| 6 | + * # Arguments |
| 7 | + * |
| 8 | + * * `source` - The .lumos schema source code |
| 9 | + * |
| 10 | + * # Returns |
| 11 | + * |
| 12 | + * A `GeneratedCode` struct containing both Rust and TypeScript outputs, |
| 13 | + * or a JavaScript Error if parsing/generation fails |
| 14 | + * |
| 15 | + * # Example (JavaScript) |
| 16 | + * |
| 17 | + * ```js |
| 18 | + * import { generateCode } from 'lumos-wasm'; |
| 19 | + * |
| 20 | + * const schema = ` |
| 21 | + * #[solana] |
| 22 | + * #[account] |
| 23 | + * struct PlayerAccount { |
| 24 | + * wallet: PublicKey, |
| 25 | + * level: u16, |
| 26 | + * } |
| 27 | + * `; |
| 28 | + * |
| 29 | + * try { |
| 30 | + * const result = generateCode(schema); |
| 31 | + * console.log('Rust:', result.rust); |
| 32 | + * console.log('TypeScript:', result.typescript); |
| 33 | + * } catch (error) { |
| 34 | + * console.error('Generation failed:', error.message); |
| 35 | + * } |
| 36 | + * ``` |
| 37 | + */ |
| 38 | +export function generateCode(source: string): GeneratedCode; |
| 39 | +/** |
| 40 | + * Validate a LUMOS schema without generating code |
| 41 | + * |
| 42 | + * Useful for providing real-time feedback in the editor without |
| 43 | + * the overhead of full code generation. |
| 44 | + * |
| 45 | + * # Arguments |
| 46 | + * |
| 47 | + * * `source` - The .lumos schema source code |
| 48 | + * |
| 49 | + * # Returns |
| 50 | + * |
| 51 | + * `Ok(())` if the schema is valid, or a JavaScript Error with the validation message |
| 52 | + */ |
| 53 | +export function validateSchema(source: string): void; |
| 54 | +/** |
| 55 | + * Result of code generation containing both Rust and TypeScript outputs |
| 56 | + */ |
| 57 | +export class GeneratedCode { |
| 58 | + private constructor(); |
| 59 | + free(): void; |
| 60 | + [Symbol.dispose](): void; |
| 61 | + /** |
| 62 | + * Generated Rust code |
| 63 | + */ |
| 64 | + rust: string; |
| 65 | + /** |
| 66 | + * Generated TypeScript code |
| 67 | + */ |
| 68 | + typescript: string; |
| 69 | +} |
| 70 | + |
| 71 | +export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembly.Module; |
| 72 | + |
| 73 | +export interface InitOutput { |
| 74 | + readonly memory: WebAssembly.Memory; |
| 75 | + readonly __wbg_generatedcode_free: (a: number, b: number) => void; |
| 76 | + readonly __wbg_get_generatedcode_rust: (a: number, b: number) => void; |
| 77 | + readonly __wbg_set_generatedcode_rust: (a: number, b: number, c: number) => void; |
| 78 | + readonly __wbg_get_generatedcode_typescript: (a: number, b: number) => void; |
| 79 | + readonly __wbg_set_generatedcode_typescript: (a: number, b: number, c: number) => void; |
| 80 | + readonly generateCode: (a: number, b: number, c: number) => void; |
| 81 | + readonly validateSchema: (a: number, b: number, c: number) => void; |
| 82 | + readonly __wbindgen_add_to_stack_pointer: (a: number) => number; |
| 83 | + readonly __wbindgen_export: (a: number, b: number, c: number) => void; |
| 84 | + readonly __wbindgen_export2: (a: number, b: number) => number; |
| 85 | + readonly __wbindgen_export3: (a: number, b: number, c: number, d: number) => number; |
| 86 | +} |
| 87 | + |
| 88 | +export type SyncInitInput = BufferSource | WebAssembly.Module; |
| 89 | +/** |
| 90 | +* Instantiates the given `module`, which can either be bytes or |
| 91 | +* a precompiled `WebAssembly.Module`. |
| 92 | +* |
| 93 | +* @param {{ module: SyncInitInput }} module - Passing `SyncInitInput` directly is deprecated. |
| 94 | +* |
| 95 | +* @returns {InitOutput} |
| 96 | +*/ |
| 97 | +export function initSync(module: { module: SyncInitInput } | SyncInitInput): InitOutput; |
| 98 | + |
| 99 | +/** |
| 100 | +* If `module_or_path` is {RequestInfo} or {URL}, makes a request and |
| 101 | +* for everything else, calls `WebAssembly.instantiate` directly. |
| 102 | +* |
| 103 | +* @param {{ module_or_path: InitInput | Promise<InitInput> }} module_or_path - Passing `InitInput` directly is deprecated. |
| 104 | +* |
| 105 | +* @returns {Promise<InitOutput>} |
| 106 | +*/ |
| 107 | +export default function __wbg_init (module_or_path?: { module_or_path: InitInput | Promise<InitInput> } | InitInput | Promise<InitInput>): Promise<InitOutput>; |
0 commit comments