Commit c68c674
authored
feat(wasm): WASM bindings for browser use (#638)
## Summary
Add WebAssembly bindings for using the Postgres Language Server in the
browser. This enables:
- SQL parsing and linting in web applications
- Monaco editor integration with LSP support
- Schema-aware completions and hover information
## Two APIs
The package provides two independent APIs:
| API | Use Case | Import Path |
|-----|----------|-------------|
| **Workspace** | Direct parse, lint, complete, hover |
`@postgres-language-server/wasm/workspace` |
| **LanguageServer** | Full LSP JSON-RPC protocol |
`@postgres-language-server/wasm/lsp` |
### Workspace API Example
```typescript
import { createWorkspace } from '@postgres-language-server/wasm/workspace';
const workspace = await createWorkspace();
workspace.insertFile('/query.sql', 'SELECT * FROM users;');
const diagnostics = workspace.lint('/query.sql');
const completions = workspace.complete('/query.sql', 14);
```
### LanguageServer API Example
```typescript
import { createLanguageServer } from '@postgres-language-server/wasm/lsp';
const lsp = await createLanguageServer();
const responses = lsp.handleMessage({
jsonrpc: '2.0',
id: 1,
method: 'initialize',
params: { capabilities: {} }
});
```
## Implementation
- `pgls_wasm` Rust crate with Emscripten target
- `@postgres-language-server/wasm` TypeScript package
- Web worker integration for Monaco editor
## Test plan
- [x] Unit tests for Workspace API (parse, lint, complete, hover)
- [x] Unit tests for LanguageServer API (LSP messages)
- [x] E2E tests with Monaco editor via Playwright
- [x] Web worker integration tests1 parent d9964c1 commit c68c674
File tree
70 files changed
+5293
-393
lines changed- .cargo
- .github/workflows
- crates
- pgls_analyser
- pgls_analyse
- pgls_cli
- src
- commands
- pgls_completions
- pgls_diagnostics/src
- pgls_hover
- pgls_plpgsql_check
- pgls_query
- pgls_schema_cache
- src
- pgls_splinter
- pgls_treesitter_grammar
- pgls_treesitter
- pgls_type_resolver
- pgls_typecheck
- pgls_wasm
- src
- pgls_workspace
- src
- workspace
- server
- packages/@postgres-language-server/wasm
- e2e
- src
- tests
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
70 files changed
+5293
-393
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
241 | 241 | | |
242 | 242 | | |
243 | 243 | | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
244 | 280 | | |
245 | 281 | | |
246 | 282 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
33 | 33 | | |
34 | 34 | | |
35 | 35 | | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
36 | 48 | | |
37 | 49 | | |
38 | 50 | | |
| 51 | + | |
| 52 | + | |
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
37 | 37 | | |
38 | 38 | | |
39 | 39 | | |
40 | | - | |
| 40 | + | |
41 | 41 | | |
42 | 42 | | |
43 | 43 | | |
| |||
82 | 82 | | |
83 | 83 | | |
84 | 84 | | |
85 | | - | |
| 85 | + | |
86 | 86 | | |
87 | 87 | | |
88 | 88 | | |
| |||
92 | 92 | | |
93 | 93 | | |
94 | 94 | | |
| 95 | + | |
95 | 96 | | |
96 | 97 | | |
97 | 98 | | |
| |||
0 commit comments