go-html/cmd/wasm/register.go
Claude dcd55a434c
feat(wasm): add registerComponents export for WC codegen
Exposes gohtml.registerComponents(slotsJSON) to browser context.
Pure-Go buildComponentJS is testable without WASM; WASM glue uses
Function constructor for browser-side execution.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-17 20:50:50 +00:00

18 lines
471 B
Go

package main
import (
"encoding/json"
"fmt"
"forge.lthn.ai/core/go-html/codegen"
)
// buildComponentJS takes a JSON slot map and returns the WC bundle JS string.
// This is the pure-Go part testable without WASM.
func buildComponentJS(slotsJSON string) (string, error) {
var slots map[string]string
if err := json.Unmarshal([]byte(slotsJSON), &slots); err != nil {
return "", fmt.Errorf("registerComponents: %w", err)
}
return codegen.GenerateBundle(slots)
}