go-html/cmd/wasm/register.go
Virgil 9b620cf673
Some checks are pending
Security Scan / security (push) Waiting to run
Test / test (push) Waiting to run
refactor(html): add AX docs to helper wrappers
Co-Authored-By: Virgil <virgil@lethean.io>
2026-04-03 19:54:45 +00:00

27 lines
840 B
Go

//go:build !js
package main
import (
"encoding/json"
"dappco.re/go/core/html/codegen"
log "dappco.re/go/core/log"
)
// cmd/wasm/register.go: buildComponentJS takes a JSON slot map and returns the WC bundle JS string.
// Example: js, err := buildComponentJS(`{"H":"site-header","C":"app-content"}`).
// This is the pure-Go part testable without WASM.
// Excluded from WASM builds — encoding/json and text/template are too heavy.
// Use cmd/codegen/ CLI instead for build-time generation.
func buildComponentJS(slotsJSON string) (string, error) {
var slots map[string]string
if err := json.Unmarshal([]byte(slotsJSON), &slots); err != nil {
return "", log.E("buildComponentJS", "unmarshal JSON", err)
}
return codegen.GenerateBundle(slots)
}
func main() {
log.Info("go-html WASM module — build with GOOS=js GOARCH=wasm")
}