Skip to content

Commit a62a2f3

Browse files
committed
fixes wasm
1 parent cb0c1b0 commit a62a2f3

22 files changed

Lines changed: 44 additions & 48 deletions

File tree

Makefile

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,7 @@ extension:
2626
wasm:
2727
GOOS=js GOARCH=wasm go build -ldflags="-s -w" -trimpath -o gnata.wasm ./wasm/
2828
cp "$$(go env GOROOT)/lib/wasm/wasm_exec.js" wasm_exec.js
29-
tinygo build -o gnata-lsp.wasm -no-debug -gc=conservative -scheduler=none -panic=trap -target wasm ./editor/
30-
wasm-opt -Oz --enable-bulk-memory gnata-lsp.wasm -o gnata-lsp.wasm
29+
tinygo build -o gnata-lsp.wasm -no-debug -gc=conservative -target wasm ./editor/
3130
cp "$$(tinygo env TINYGOROOT)/targets/wasm_exec.js" lsp-wasm_exec.js
3231

3332
# CodeMirror npm package

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ A composable React package (`@gnata-sqlite/react`) for embedding a JSONata expre
6464

6565
<img src="assets/playground-gnata-hover.png" alt="Hover documentation showing $sum function" width="720" />
6666

67-
Hover over any function to see its signature, description, and examples — powered by the 85KB TinyGo WASM LSP.
67+
Hover over any function to see its signature, description, and examples — powered by the 145 KB TinyGo WASM LSP.
6868

6969
### Context-Aware Autocomplete
7070

@@ -105,7 +105,7 @@ function ExpressionBuilder() {
105105

106106
**What end users get:** autocomplete, hover docs, live diagnostics, syntax highlighting
107107

108-
**What developers get:** 85KB WASM LSP, hooks-first API, no eval required, schema-driven
108+
**What developers get:** 145 KB WASM LSP, hooks-first API, no eval required, schema-driven
109109

110110
## How It Fits Together
111111

@@ -116,7 +116,7 @@ Backend Frontend
116116
┌──────────────────┐ ┌──────────────────────────┐
117117
│ SQLite + gnata │ │ @gnata-sqlite/react │
118118
│ extension │ schema → │ CodeMirror 6 editor │
119-
│ │ │ + 85KB WASM LSP │
119+
│ │ │ + 145 KB WASM LSP │
120120
│ Runs expressions │ ← expr │ Autocomplete, hover, │
121121
│ against JSON data│ │ diagnostics │
122122
└──────────────────┘ └──────────────────────────┘

docs/content/tutorials/react-widget.mdx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ The package ships pre-built WASM binaries for the editor LSP (autocomplete, diag
3434
npx @gnata-sqlite/react setup ./public
3535
```
3636

37-
This copies `gnata-lsp.wasm` (126KB) and `lsp-wasm_exec.js` (16KB) into `public/`.
37+
This copies `gnata-lsp.wasm` (380 KB, 145 KB gzipped) and `lsp-wasm_exec.js` (16 KB) into `public/`.
3838

3939
## Step 3: Editor with full language support
4040

@@ -145,4 +145,4 @@ No WASM function props = no WASM loading. Highlighting works instantly with the
145145

146146
- [React Widget API Reference](/docs/reference/react-widget) — full props, hooks, and types
147147
- [Editor & LSP API](/docs/reference/editor-api) — low-level CodeMirror and WASM exports
148-
- [TinyGo WASM](/docs/explanation/tinygo-wasm) — why the LSP is 85KB
148+
- [TinyGo WASM](/docs/explanation/tinygo-wasm) — why the LSP is 145 KB

editor/README.md

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ CodeMirror 6 language support and LSP server for JSONata, powered by gnata's par
44

55
Two delivery modes from the same codebase:
66

7-
- **Browser** — TinyGo WASM module (126 KB) for CodeMirror diagnostics and autocomplete
7+
- **Browser** — TinyGo WASM module (380 KB, 145 KB gzipped) for CodeMirror diagnostics and autocomplete
88
- **Server** — Native Go LSP server (stdio JSON-RPC) for VS Code, Neovim, etc.
99

1010
## Quick Start
@@ -15,7 +15,7 @@ Two delivery modes from the same codebase:
1515
import { EditorView, basicSetup } from "codemirror"
1616
import { jsonataFull, initWasm } from "@gnata-sqlite/codemirror"
1717

18-
// Load the WASM module (126 KB, 61 KB gzipped).
18+
// Load the WASM module (380 KB, 145 KB gzipped).
1919
await initWasm("/gnata-lsp.wasm", "/lsp-wasm_exec.js")
2020

2121
new EditorView({
@@ -58,7 +58,7 @@ require("lspconfig").jsonata.setup({})
5858
+---------------------------+
5959
| Lezer Grammar | WASM |
6060
| (sync, every | (async, |
61-
| keystroke) | 126 KB) |
61+
| keystroke) | 380 KB) |
6262
| | |
6363
| Highlighting | Diags |
6464
| Brackets | Compl. |
@@ -226,15 +226,14 @@ Diagnostics are pushed as `textDocument/publishDiagnostics` notifications.
226226
```bash
227227
tinygo build \
228228
-o gnata-lsp.wasm -no-debug \
229-
-gc=conservative -scheduler=none -panic=trap \
229+
-gc=conservative \
230230
-target wasm ./editor/
231-
wasm-opt -Oz --enable-bulk-memory gnata-lsp.wasm -o gnata-lsp.wasm
232231

233232
# Copy TinyGo's WASM support file.
234233
cp "$(tinygo env TINYGOROOT)/targets/wasm_exec.js" lsp-wasm_exec.js
235234
```
236235

237-
Output: `gnata-lsp.wasm` (126 KB raw, 61 KB gzipped)
236+
Output: `gnata-lsp.wasm` (380 KB raw, 145 KB gzipped)
238237

239238
### Native LSP Server
240239

editor/codemirror/README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# @gnata-sqlite/codemirror
22

3-
CodeMirror 6 language support for [JSONata](https://jsonata.org) expressions — syntax highlighting, error diagnostics, autocomplete, and hover documentation, powered by a 85KB WASM module.
3+
CodeMirror 6 language support for [JSONata](https://jsonata.org) expressions — syntax highlighting, error diagnostics, autocomplete, and hover documentation, powered by a 380 KB WASM module (145 KB gzipped).
44

55
## Features
66

@@ -16,7 +16,7 @@ npm install @gnata-sqlite/codemirror
1616
```
1717

1818
You also need the WASM files served from your app:
19-
- `gnata-lsp.wasm` (61KB gzipped)
19+
- `gnata-lsp.wasm` (380 KB, 145 KB gzipped)
2020
- `lsp-wasm_exec.js` (TinyGo runtime)
2121

2222
## Quick Start
@@ -354,7 +354,7 @@ A complete working example using ESM imports (no build step):
354354

355355
```
356356
┌─────────────────────────┐ ┌──────────────────────────┐
357-
│ Your App (browser) │ │ gnata-lsp.wasm (85KB) │
357+
│ Your App (browser) │ │ gnata-lsp.wasm (145 KB) │
358358
│ │ │ TinyGo WASM module │
359359
│ CodeMirror Editor │────▶│ │
360360
│ + @gnata-sqlite/codemirror │ │ _gnataDiagnostics(expr) │

editor/codemirror/package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

editor/codemirror/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@gnata-sqlite/codemirror",
3-
"version": "0.2.0",
3+
"version": "0.2.2",
44
"description": "CodeMirror 6 language support for JSONata — syntax highlighting, linting, and autocomplete",
55
"type": "module",
66
"main": "dist/index.cjs",

editor/main_wasm.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,7 @@
66
//
77
// Build:
88
//
9-
// tinygo build -o gnata-lsp.wasm -no-debug -gc=conservative -scheduler=none -panic=trap -target wasm ./editor/
10-
// wasm-opt -Oz --enable-bulk-memory gnata-lsp.wasm -o gnata-lsp.wasm
9+
// tinygo build -o gnata-lsp.wasm -no-debug -gc=conservative -target wasm ./editor/
1110
package main
1211

1312
import (

playground/src/router.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ const indexRoute = createRoute({
1616
getParentRoute: () => rootRoute,
1717
path: '/',
1818
beforeLoad: () => {
19-
throw redirect({ to: '/sqlite' });
19+
throw redirect({ to: '/sqlite/' });
2020
},
2121
});
2222

@@ -40,7 +40,7 @@ const routeTree = rootRoute.addChildren([indexRoute, sqliteRoute, gnataRoute]);
4040

4141
const basepath = import.meta.env.BASE_URL.replace(/\/$/, '') || '/';
4242

43-
export const router = createRouter({ routeTree, basepath });
43+
export const router = createRouter({ routeTree, basepath, trailingSlash: 'always' });
4444

4545
declare module '@tanstack/react-router' {
4646
interface Register {

react/README.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -280,9 +280,8 @@ The package does not bundle WASM files — serve them from the host application.
280280
GOOS=js GOARCH=wasm go build -ldflags="-s -w" -trimpath -o gnata.wasm ./wasm/
281281
cp "$(go env GOROOT)/lib/wasm/wasm_exec.js" wasm_exec.js
282282

283-
# LSP module (TinyGo WASM — 61KB gzipped)
284-
tinygo build -o gnata-lsp.wasm -no-debug -gc=conservative -scheduler=none -panic=trap -target wasm ./editor/
285-
wasm-opt -Oz --enable-bulk-memory gnata-lsp.wasm -o gnata-lsp.wasm
283+
# LSP module (TinyGo WASM — 380 KB, 145 KB gzipped)
284+
tinygo build -o gnata-lsp.wasm -no-debug -gc=conservative -target wasm ./editor/
286285
cp "$(tinygo env TINYGOROOT)/targets/wasm_exec.js" lsp-wasm_exec.js
287286
```
288287

0 commit comments

Comments
 (0)