From 286731e39812a684a57db07befd11d5fad23c253 Mon Sep 17 00:00:00 2001 From: Snider Date: Tue, 14 Apr 2026 19:22:17 +0100 Subject: [PATCH 01/55] feat(html): Metadata alias on Context + Responsive.Add with media-query hint MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Brings the portable pieces of mini's feat/main-session-work onto dev: - context.go: Context.Metadata field — alias for Data, references the same underlying map. Both fields interchangeable at read/write sites. - responsive.go: responsiveVariant gains an optional media field for CSS media-query hints (e.g. "(min-width: 1024px)"); new Responsive.Add(name, layout, media...) method. Existing Variant(name, layout) becomes a thin alias over Add. - go.mod: drop stale dappco.re/go/core/{inference,log} indirect requires (refreshed by go mod tidy — forge.lthn.ai/core/{go-inference,go-log}). Mini's local deps/go-i18n/reversal grammar-vector rewrite does not apply to dev: dev consumes reversal as an external package (dappco.re/go/core/i18n/reversal) rather than an internal fork. That portion of the branch is left on feat/main-session-work for future re-integration. Verified: GOWORK=off go build ./... + go test ./... passes. Co-Authored-By: Virgil --- context.go | 8 +++++++- go.mod | 4 ++-- responsive.go | 16 +++++++++++++++- 3 files changed, 24 insertions(+), 4 deletions(-) diff --git a/context.go b/context.go index f5d40e5..91167ef 100644 --- a/context.go +++ b/context.go @@ -11,11 +11,15 @@ type Translator interface { // Context carries rendering state through the node tree. // Usage example: ctx := NewContext() +// +// Metadata is an alias for Data — both fields reference the same underlying map. +// Treat them as interchangeable; use whichever reads best in context. type Context struct { Identity string Locale string Entitlements func(feature string) bool Data map[string]any + Metadata map[string]any service Translator } @@ -39,8 +43,10 @@ func applyLocaleToService(svc Translator, locale string) { // NewContext creates a new rendering context with sensible defaults. // Usage example: html := Render(Text("welcome"), NewContext("en-GB")) func NewContext(locale ...string) *Context { + data := make(map[string]any) ctx := &Context{ - Data: make(map[string]any), + Data: data, + Metadata: data, // alias — same underlying map } if len(locale) > 0 { ctx.SetLocale(locale[0]) diff --git a/go.mod b/go.mod index f9d51e8..ec55646 100644 --- a/go.mod +++ b/go.mod @@ -12,8 +12,8 @@ require ( ) require ( - dappco.re/go/core/inference v0.1.4 // indirect - dappco.re/go/core/log v0.0.4 // indirect + forge.lthn.ai/core/go-inference v0.1.4 // indirect + forge.lthn.ai/core/go-log v0.0.4 // indirect github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect golang.org/x/text v0.35.0 // indirect diff --git a/responsive.go b/responsive.go index 896d0ae..fc25af0 100644 --- a/responsive.go +++ b/responsive.go @@ -18,6 +18,7 @@ type Responsive struct { type responsiveVariant struct { name string layout *Layout + media string // optional CSS media-query hint (e.g. "(min-width: 768px)") } // NewResponsive creates a new multi-variant responsive compositor. @@ -29,11 +30,24 @@ func NewResponsive() *Responsive { // Variant adds a named layout variant (e.g., "desktop", "tablet", "mobile"). // Usage example: NewResponsive().Variant("desktop", NewLayout("HLCRF")) // Variants render in insertion order. +// Variant is equivalent to Add(name, layout) with no media-query hint. func (r *Responsive) Variant(name string, layout *Layout) *Responsive { + return r.Add(name, layout) +} + +// Add registers a responsive variant. The optional media argument carries a +// CSS media-query hint for downstream CSS generation (e.g. "(min-width: 768px)"). +// +// Usage example: NewResponsive().Add("desktop", NewLayout("HLCRF"), "(min-width: 1024px)") +func (r *Responsive) Add(name string, layout *Layout, media ...string) *Responsive { if r == nil { r = NewResponsive() } - r.variants = append(r.variants, responsiveVariant{name: name, layout: layout}) + variant := responsiveVariant{name: name, layout: layout} + if len(media) > 0 { + variant.media = media[0] + } + r.variants = append(r.variants, variant) return r } From 09b48e00dcd42cb4d354c0c3ab5d19206244c186 Mon Sep 17 00:00:00 2001 From: Snider Date: Tue, 14 Apr 2026 20:01:28 +0100 Subject: [PATCH 02/55] chore(html): swap errors.Is for core.Is in codegen CLI, document WASM size guard-rails MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - cmd/codegen/main.go: drop "errors" stdlib import, use core.Is per Core convention (non-WASM path). - layout.go, path.go, responsive.go: add header notes documenting why these files use stdlib (errors/strings/strconv) instead of core — RFC §7 caps WASM at 3.5 MB raw / 1 MB gzip, and dappco.re/go/core transitively pulls fmt/os/log. - README.md, docs/index.md: migrate stale forge.lthn.ai/core/go-html module path to canonical dappco.re/go/core/html; refresh dependency diagram and Go version. All spec features are already implemented; this is spec-parity maintenance. Verified: go build ./..., go vet ./..., go test ./... all green (WASM size test back to 2.12 MB raw / 630 KB gzip after short-lived core-import regression). Co-Authored-By: Virgil --- README.md | 8 ++++---- cmd/codegen/main.go | 3 +-- docs/index.md | 17 ++++++++++------- layout.go | 6 ++++++ path.go | 5 +++++ responsive.go | 5 +++++ 6 files changed, 31 insertions(+), 13 deletions(-) diff --git a/README.md b/README.md index 507bc63..a04c685 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -[![Go Reference](https://pkg.go.dev/badge/forge.lthn.ai/core/go-html.svg)](https://pkg.go.dev/forge.lthn.ai/core/go-html) +[![Go Reference](https://pkg.go.dev/badge/dappco.re/go/core/html.svg)](https://pkg.go.dev/dappco.re/go/core/html) [![License: EUPL-1.2](https://img.shields.io/badge/License-EUPL--1.2-blue.svg)](LICENSE.md) [![Go Version](https://img.shields.io/badge/Go-1.26-00ADD8?style=flat&logo=go)](go.mod) @@ -6,14 +6,14 @@ HLCRF DOM compositor with grammar pipeline integration for server-side HTML generation and optional WASM client rendering. Provides a type-safe node tree (El, Text, Raw, If, Each, Switch, Entitled, AriaLabel, AltText), a five-slot Header/Left/Content/Right/Footer layout compositor with deterministic `data-block` path IDs and ARIA roles, a responsive multi-variant wrapper, a server-side grammar pipeline (StripTags, GrammarImprint via go-i18n reversal, CompareVariants), a build-time Web Component codegen CLI, and a WASM module (2.90 MB raw, 842 KB gzip) exposing `renderToString()`. -**Module**: `forge.lthn.ai/core/go-html` +**Module**: `dappco.re/go/core/html` **Licence**: EUPL-1.2 -**Language**: Go 1.25 +**Language**: Go 1.26 ## Quick Start ```go -import "forge.lthn.ai/core/go-html" +import html "dappco.re/go/core/html" page := html.NewLayout("HCF"). H(html.El("nav", html.Text("i18n.label.navigation"))). diff --git a/cmd/codegen/main.go b/cmd/codegen/main.go index 3874c2f..6697c7d 100644 --- a/cmd/codegen/main.go +++ b/cmd/codegen/main.go @@ -12,7 +12,6 @@ package main import ( "context" - "errors" "flag" goio "io" "os" @@ -92,7 +91,7 @@ func runDaemon(ctx context.Context, inputPath, outputPath string, emitTypes bool select { case <-ctx.Done(): - if errors.Is(ctx.Err(), context.Canceled) { + if core.Is(ctx.Err(), context.Canceled) { return nil } return ctx.Err() diff --git a/docs/index.md b/docs/index.md index 2d3385f..5db9bfa 100644 --- a/docs/index.md +++ b/docs/index.md @@ -7,7 +7,7 @@ description: HLCRF DOM compositor with grammar pipeline integration for type-saf `go-html` is a pure-Go library for building HTML documents as type-safe node trees and rendering them to string output. It provides a five-slot layout compositor (Header, Left, Content, Right, Footer -- abbreviated HLCRF), a responsive multi-variant wrapper, a server-side grammar analysis pipeline, a Web Component code generator, and an optional WASM module for client-side rendering. -**Module path:** `forge.lthn.ai/core/go-html` +**Module path:** `dappco.re/go/core/html` **Go version:** 1.26 **Licence:** EUPL-1.2 @@ -16,7 +16,7 @@ description: HLCRF DOM compositor with grammar pipeline integration for type-saf ```go package main -import html "forge.lthn.ai/core/go-html" +import html "dappco.re/go/core/html" func main() { page := html.NewLayout("HCF"). @@ -65,14 +65,17 @@ This builds a Header-Content-Footer layout with semantic HTML elements (`
Date: Wed, 15 Apr 2026 00:16:01 +0100 Subject: [PATCH 03/55] fix(html): align left slot with navigation semantics --- docs/architecture.md | 2 +- docs/index.md | 2 +- layout.go | 4 ++-- layout_test.go | 4 ++-- path.go | 15 ++++++++++++++- path_test.go | 2 ++ 6 files changed, 22 insertions(+), 7 deletions(-) diff --git a/docs/architecture.md b/docs/architecture.md index 169dc36..f018689 100644 --- a/docs/architecture.md +++ b/docs/architecture.md @@ -73,7 +73,7 @@ The `Layout` type is a compositor for five named slots: | Slot Letter | Semantic Element | ARIA Role | Accessor | |-------------|-----------------|-----------|----------| | H | `
` | `banner` | `layout.H(...)` | -| L | `