add WASM blazor-like thing
This commit is contained in:
38
go/rsc/proto.go
Normal file
38
go/rsc/proto.go
Normal file
@@ -0,0 +1,38 @@
|
||||
// Package rsc runs server components with a stateless, React/Next-style
|
||||
// request/response: the client POSTs the component name, its (opaque) signal
|
||||
// state, and any triggered event; the server restores the state, applies the
|
||||
// event, re-renders, and returns the new state + rendered tree, which the client
|
||||
// reconciles ("swaps") into the DOM. No persistent connection, no server-held
|
||||
// session — state round-trips through the client.
|
||||
//
|
||||
// This file holds the wire types (gob), shared by server and client.
|
||||
package rsc
|
||||
|
||||
// SNode is a serialized render node. Nodes with server handlers carry an ID and
|
||||
// their event names; the client sends {name, state, ID, event} back so the
|
||||
// server can find and invoke the handler.
|
||||
type SNode struct {
|
||||
ID int
|
||||
Tag string
|
||||
Text string
|
||||
HTML string
|
||||
Attrs map[string]string
|
||||
Events []string
|
||||
Kids []*SNode
|
||||
}
|
||||
|
||||
// Request is client -> server (every request is self-contained).
|
||||
type Request struct {
|
||||
Kind string // "mount" | "event"
|
||||
Name string // component name
|
||||
State [][]byte // opaque signal snapshot from the previous response
|
||||
NodeID int // event: node that fired
|
||||
Event string // event: event name
|
||||
Value string // event: target value (inputs)
|
||||
}
|
||||
|
||||
// Response is server -> client.
|
||||
type Response struct {
|
||||
State [][]byte
|
||||
Tree *SNode
|
||||
}
|
||||
Reference in New Issue
Block a user