diff --git a/.vscode/launch.json b/.vscode/launch.json index f6443d88..63e6bc5d 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -23,11 +23,11 @@ "args": ["-watch=false"] }, { - "name": "gowasm: codegen (gowasmgen)", + "name": "gowasm: codegen (wasmgen)", "type": "go", "request": "launch", "mode": "auto", - "program": "${workspaceFolder}/go/cmd/gowasmgen", + "program": "${workspaceFolder}/go/cmd/wasmgen", "cwd": "${workspaceFolder}/go/cmd/examples/go-wasm-web", "args": ["./app"] } diff --git a/.vscode/tasks.json b/.vscode/tasks.json index eb232aa4..603f36e2 100644 --- a/.vscode/tasks.json +++ b/.vscode/tasks.json @@ -39,7 +39,7 @@ "label": "gowasm: codegen", "detail": "Regenerate app/*.gen.go from //gowasm: directives", "type": "shell", - "command": "go run kjol/cmd/gowasmgen ./app", + "command": "go run kjol/cmd/wasmgen ./app", "options": { "cwd": "${workspaceFolder}/go/cmd/examples/go-wasm-web" }, "problemMatcher": ["$go"], "group": "build" diff --git a/CLAUDE.md b/CLAUDE.md index 451a5ea5..c401802c 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -36,7 +36,7 @@ Language-first, **not** feature-first. Consequence: the **bundler is Go** and li Packages, imported as `kjol/`: `appenv basic chrono config csv dbutil finance httputil l4g security snailmail validation bundler`, plus the **gowasm** web-UI engine (`vdom` `wasmruntime` `rsc` `wasmdevserver` — author components in pure Go compiled to WebAssembly; -all stdlib-only), and `cmd/{bundle,migrate,loc,passgen,typecheck,gowasmgen}`. A runnable +all stdlib-only), and `cmd/{bundle,migrate,loc,passgen,typecheck,wasmgen}`. A runnable example lives in `cmd/examples/go-wasm-web` (its own nested module so its go-chart dep stays out of kjol). diff --git a/go/cmd/examples/go-wasm-web/README.md b/go/cmd/examples/go-wasm-web/README.md index 92b72ac8..b8d6c65b 100644 --- a/go/cmd/examples/go-wasm-web/README.md +++ b/go/cmd/examples/go-wasm-web/README.md @@ -36,7 +36,7 @@ app/ the application — neutral, standalone functions (no centra pages.go Deps + Shell + App/Public layouts + nav + Counter + pages chart.go Chart page (go-chart, renders on both sides) server_counter.go //gowasm:server component (server-only; clicks-over-time chart) - *.gen.go GENERATED by kjol/cmd/gowasmgen (routes, layout dispatch, stubs) + *.gen.go GENERATED by kjol/cmd/wasmgen (routes, layout dispatch, stubs) wasm/ the js/wasm client entry point (main_native.go is a host stub) server/ the dev-server main: injects Build/Render/Document into wasmdevserver wwwroot/ bootstrap.js, bootstrap.min.css (+ generated wasm_exec.js, app.wasm) @@ -50,14 +50,14 @@ wwwroot/ bootstrap.js, bootstrap.min.css (+ generated wasm_exec.js, a | `kjol/wasmruntime` | wasm client runtime: reconcile, `Run`/`Hydrate`, router, fetch, HMR state | `wasm/main.go` calls `Hydrate`/`Run` | | `kjol/rsc` | stateless server components over HTTP (gob) | `//gowasm:server` + the generated client stub | | `kjol/wasmdevserver` | reusable dev server: SSR, `/rsc`, hot reload, error overlay | `server/main.go` fills a `wasmdevserver.Config` | -| `kjol/cmd/gowasmgen` | directive codegen → `app/*.gen.go` | run by `buildWasm` and `//go:generate` | +| `kjol/cmd/wasmgen` | directive codegen → `app/*.gen.go` | run by `buildWasm` and `//go:generate` | The **golden rule** holds: `wasmdevserver` imports no app code. The app injects `Build` (how to compile the wasm), `Render` (SSR a route → HTML), and `Document` (wrap it in a page) via `wasmdevserver.Config` — the same coupling inversion kjol uses elsewhere. -## Directives (expanded by `gowasmgen` at build time) +## Directives (expanded by `wasmgen` at build time) ```go //gowasm:page / static layout=public // a route; `static` SSRs it, `layout=` wraps it diff --git a/go/cmd/examples/go-wasm-web/app/client.gen.go b/go/cmd/examples/go-wasm-web/app/client.gen.go index 72d36515..9e2daa73 100644 --- a/go/cmd/examples/go-wasm-web/app/client.gen.go +++ b/go/cmd/examples/go-wasm-web/app/client.gen.go @@ -1,4 +1,4 @@ -// Code generated by gowasmgen. DO NOT EDIT. +// Code generated by wasmgen. DO NOT EDIT. //go:build js && wasm diff --git a/go/cmd/examples/go-wasm-web/app/pages.go b/go/cmd/examples/go-wasm-web/app/pages.go index 77dec767..5eef5a0f 100644 --- a/go/cmd/examples/go-wasm-web/app/pages.go +++ b/go/cmd/examples/go-wasm-web/app/pages.go @@ -2,7 +2,7 @@ // functions (no central App struct). It is platform-neutral, so the SAME code // renders on the server (SSR) and hydrates on the client. // -// Directives (processed by cmd/gowasmgen at build time): +// Directives (processed by cmd/wasmgen at build time): // // //gowasm:page [static] [layout=] // marks a page factory as a route. `static` @@ -19,7 +19,7 @@ // generated from these directives. package app -//go:generate go run kjol/cmd/gowasmgen . +//go:generate go run kjol/cmd/wasmgen . import ( "strconv" diff --git a/go/cmd/examples/go-wasm-web/app/routes.gen.go b/go/cmd/examples/go-wasm-web/app/routes.gen.go index 3c1a67b7..e442b150 100644 --- a/go/cmd/examples/go-wasm-web/app/routes.gen.go +++ b/go/cmd/examples/go-wasm-web/app/routes.gen.go @@ -1,4 +1,4 @@ -// Code generated by gowasmgen. DO NOT EDIT. +// Code generated by wasmgen. DO NOT EDIT. package app import "kjol/vdom" diff --git a/go/cmd/examples/go-wasm-web/app/server.gen.go b/go/cmd/examples/go-wasm-web/app/server.gen.go index 8a6fec37..f5a12724 100644 --- a/go/cmd/examples/go-wasm-web/app/server.gen.go +++ b/go/cmd/examples/go-wasm-web/app/server.gen.go @@ -1,4 +1,4 @@ -// Code generated by gowasmgen. DO NOT EDIT. +// Code generated by wasmgen. DO NOT EDIT. //go:build !(js && wasm) diff --git a/go/cmd/examples/go-wasm-web/build.sh b/go/cmd/examples/go-wasm-web/build.sh index 588e7131..3cb38f0c 100755 --- a/go/cmd/examples/go-wasm-web/build.sh +++ b/go/cmd/examples/go-wasm-web/build.sh @@ -7,7 +7,7 @@ set -euo pipefail cd "$(dirname "$0")" echo "==> Generating directive glue (//gowasm:page, //gowasm:layout, //gowasm:server)" -go run kjol/cmd/gowasmgen ./app +go run kjol/cmd/wasmgen ./app echo "==> Compiling ./wasm to wwwroot/app.wasm (GOOS=js GOARCH=wasm)" GOOS=js GOARCH=wasm go build -o wwwroot/app.wasm ./wasm diff --git a/go/cmd/examples/go-wasm-web/server/main.go b/go/cmd/examples/go-wasm-web/server/main.go index 7e7b685d..04f0e01b 100644 --- a/go/cmd/examples/go-wasm-web/server/main.go +++ b/go/cmd/examples/go-wasm-web/server/main.go @@ -69,11 +69,11 @@ func document(inner string) string { ` } -// buildWasm runs the directive codegen (kjol/cmd/gowasmgen), then compiles +// buildWasm runs the directive codegen (kjol/cmd/wasmgen), then compiles // ./wasm to wwwroot/app.wasm. Returned combined output is shown in the browser // overlay on failure. func buildWasm() ([]byte, error) { - if out, err := exec.Command("go", "run", "kjol/cmd/gowasmgen", "./app").CombinedOutput(); err != nil { + if out, err := exec.Command("go", "run", "kjol/cmd/wasmgen", "./app").CombinedOutput(); err != nil { return out, err } cmd := exec.Command("go", "build", "-o", filepath.Join("wwwroot", "app.wasm"), "./wasm") diff --git a/go/cmd/examples/go-wasm-web/wwwroot/app.wasm b/go/cmd/examples/go-wasm-web/wwwroot/app.wasm index a4fe2c7d..b2578b5c 100755 Binary files a/go/cmd/examples/go-wasm-web/wwwroot/app.wasm and b/go/cmd/examples/go-wasm-web/wwwroot/app.wasm differ diff --git a/go/cmd/gowasmgen/main.go b/go/cmd/wasmgen/main.go similarity index 91% rename from go/cmd/gowasmgen/main.go rename to go/cmd/wasmgen/main.go index 37828fd4..c7bc93eb 100644 --- a/go/cmd/gowasmgen/main.go +++ b/go/cmd/wasmgen/main.go @@ -1,4 +1,4 @@ -// Command gowasmgen preprocesses component directives into glue code so that +// Command wasmgen preprocesses component directives into glue code so that // server-component calls look identical to client-component calls, and routes // can opt into SSR with a tag. // @@ -61,7 +61,7 @@ func main() { return !strings.HasSuffix(fi.Name(), ".gen.go") }, parser.ParseComments) if err != nil { - fmt.Fprintln(os.Stderr, "gowasmgen: parse:", err) + fmt.Fprintln(os.Stderr, "wasmgen: parse:", err) os.Exit(1) } @@ -129,7 +129,7 @@ func main() { write(filepath.Join(dir, "server.gen.go"), serverTmpl, data) write(filepath.Join(dir, "client.gen.go"), clientTmpl, data) - fmt.Printf("gowasmgen: %d page(s), %d server component(s)\n", len(data.Pages), len(data.Servers)) + fmt.Printf("wasmgen: %d page(s), %d server component(s)\n", len(data.Pages), len(data.Servers)) } func write(path, tmpl string, data genData) { @@ -139,7 +139,7 @@ func write(path, tmpl string, data genData) { } src, err := format.Source([]byte(b.String())) if err != nil { - fmt.Fprintf(os.Stderr, "gowasmgen: format %s: %v\n---\n%s\n", path, err, b.String()) + fmt.Fprintf(os.Stderr, "wasmgen: format %s: %v\n---\n%s\n", path, err, b.String()) os.Exit(1) } // Only write when changed, so re-running codegen doesn't churn mtimes (which @@ -152,7 +152,7 @@ func write(path, tmpl string, data genData) { } } -const routesTmpl = `// Code generated by gowasmgen. DO NOT EDIT. +const routesTmpl = `// Code generated by wasmgen. DO NOT EDIT. package app import "kjol/vdom" @@ -185,7 +185,7 @@ func LayoutFor(d Deps, path string, content *vdom.VNode) *vdom.VNode { {{end}}} ` -const serverTmpl = `// Code generated by gowasmgen. DO NOT EDIT. +const serverTmpl = `// Code generated by wasmgen. DO NOT EDIT. //go:build !(js && wasm) @@ -198,7 +198,7 @@ func init() { {{end}}} ` -const clientTmpl = `// Code generated by gowasmgen. DO NOT EDIT. +const clientTmpl = `// Code generated by wasmgen. DO NOT EDIT. //go:build js && wasm