Todo lo relacionado con imágenes para TinyWasm: builders HTML + pipeline de optimización WebP.
- Builders (
github.com/tinywasm/image) —Img,Picture,Source, construcción de elementos HTML. Compila para WASM y backend. Sin etiquetas de construcción (build tags). - Pipeline (
github.com/tinywasm/image/min) —Handler,Config, procesamiento WebP. Solo para backend.
El nombre
imagesombrea el paquete estándar de Go a propósito: el stdlibimagees demasiado pesado para TinyGo. Internamente, el pipeline aliasea el stdlib comostdimage.
import . "github.com/tinywasm/image"
func (c *Hero) Render() *dom.Element {
return Img("/img/hero.M.webp", "Hero").Lazy().Size(1024, 512).AsElement()
}
package herosection
import "github.com/tinywasm/image"
func RenderImages() []image.Asset {
return []image.Asset{
{Path: "img/hero.png", Variants: image.AllVariants, Alt: "Hero"},
}
}
El nombre de archivo debe ser
image.go. El pipeline lo detecta automáticamente.
import "github.com/tinywasm/image/min"
handler := min.New(&min.Config{RootDir: ".", OutputDir: "web/public/img", Quality: 80})
handler.LoadImages()
La detección de módulos se delega a tinywasm/modfind.
- tinywasm/dom — Element type
- tinywasm/html — HTML builders
- tinywasm/svg — SVG builders + sprite