Skip to content

Commit 5cb4f65

Browse files
committed
feat: Add interactive LUMOS playground
- Created /playground route with Monaco Editor integration - Added WASM bindings for in-browser code generation - Includes 3 example templates (account, enum, complex) - Real-time Rust + TypeScript generation with 500ms debounce - Split-pane layout: .lumos input | Rust output | TS output - Added to sidebar with 'Interactive' badge Features: - Live code generation using WASM - Syntax highlighting for all languages - Mobile-responsive grid layout - Error handling with formatted messages - Example quick-load buttons Closes #12 - Interactive Playground Available at: docs.lumos-lang.org/playground
1 parent 39f04b6 commit 5cb4f65

File tree

7 files changed

+891
-0
lines changed

7 files changed

+891
-0
lines changed

astro.config.mjs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ export default defineConfig({
4646
{ label: 'Introduction', slug: 'getting-started/introduction' },
4747
{ label: 'Installation', slug: 'getting-started/installation' },
4848
{ label: 'Quick Start', slug: 'getting-started/quick-start' },
49+
{ label: 'Playground', link: '/playground', badge: { text: 'Interactive', variant: 'success' } },
4950
],
5051
},
5152
{

public/wasm/lumos_core.d.ts

Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
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

Comments
 (0)