- 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 <virgil@lethean.io>
33 lines
925 B
Go
33 lines
925 B
Go
package html
|
|
|
|
// Note: this file is WASM-linked. Per RFC §7 the WASM build must stay under the
|
|
// 3.5 MB raw / 1 MB gzip size budget, so we deliberately avoid importing
|
|
// dappco.re/go/core here — it transitively pulls in fmt/os/log (~500 KB+).
|
|
// stdlib strings is safe for WASM.
|
|
|
|
import "strings"
|
|
|
|
// ParseBlockID extracts the slot sequence from a data-block ID.
|
|
// Usage example: slots := ParseBlockID("L-0-C-0")
|
|
// "L-0-C-0" → ['L', 'C']
|
|
func ParseBlockID(id string) []byte {
|
|
if id == "" {
|
|
return nil
|
|
}
|
|
|
|
// Valid IDs are exact sequences of "{slot}-0" segments, e.g.
|
|
// "H-0" or "L-0-C-0". Any malformed segment invalidates the whole ID.
|
|
parts := strings.Split(id, "-")
|
|
if len(parts)%2 != 0 {
|
|
return nil
|
|
}
|
|
|
|
slots := make([]byte, 0, len(parts)/2)
|
|
for i := 0; i < len(parts); i += 2 {
|
|
if len(parts[i]) != 1 || parts[i+1] != "0" {
|
|
return nil
|
|
}
|
|
slots = append(slots, parts[i][0])
|
|
}
|
|
return slots
|
|
}
|