update wasmgen

This commit is contained in:
2026-07-13 00:53:44 -04:00
parent 3c494605ba
commit 261a7f2b4d
12 changed files with 22 additions and 22 deletions

View File

@@ -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

View File

@@ -1,4 +1,4 @@
// Code generated by gowasmgen. DO NOT EDIT.
// Code generated by wasmgen. DO NOT EDIT.
//go:build js && wasm

View File

@@ -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 <path> [static] [layout=<name>]
// 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"

View File

@@ -1,4 +1,4 @@
// Code generated by gowasmgen. DO NOT EDIT.
// Code generated by wasmgen. DO NOT EDIT.
package app
import "kjol/vdom"

View File

@@ -1,4 +1,4 @@
// Code generated by gowasmgen. DO NOT EDIT.
// Code generated by wasmgen. DO NOT EDIT.
//go:build !(js && wasm)

View File

@@ -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

View File

@@ -69,11 +69,11 @@ func document(inner string) string {
</html>`
}
// 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")