Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
87 changes: 0 additions & 87 deletions .compat/core/core.go

This file was deleted.

5 changes: 0 additions & 5 deletions .compat/core/go.mod

This file was deleted.

2 changes: 1 addition & 1 deletion docs/architecture.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ Two constructors are provided:

`Data` and `Metadata` point at the same backing map when the context is created through `NewContext()`. Use whichever name is clearer in the calling code. `SetLocale()` and `SetService()` keep the active translator in sync when either value changes.

The `service` field is intentionally unexported. When nil, server builds fall back to the global `i18n.T()` default while JS builds render the key unchanged. This prevents callers from setting the service inconsistently after construction while keeping the WASM import graph lean.
The `service` field is intentionally unexported. When nil, server builds fall back to Core's i18n translator while JS builds render the key unchanged. This prevents callers from setting the service inconsistently after construction while keeping the WASM import graph lean.

## HLCRF Layout

Expand Down
17 changes: 15 additions & 2 deletions go.work
Original file line number Diff line number Diff line change
@@ -1,3 +1,16 @@
go 1.26.0
go 1.26.2

use .
// Workspace mode for development: pulls fresh code from external/ submodules.
//
// Devs: git clone --recursive -> go.work picks up local sources.
// CI: GOWORK=off -> go.mod tags drive resolution.

use (
./go
./external/go
./external/go-i18n/go
./external/go-inference
./external/go-io
./external/go-log
./external/go-process
)
240 changes: 0 additions & 240 deletions go.work.sum

This file was deleted.

File renamed without changes.
19 changes: 9 additions & 10 deletions cmd/codegen/main.go → go/cmd/codegen/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
core "dappco.re/go"
"dappco.re/go/html/codegen"
coreio "dappco.re/go/io"
log "dappco.re/go/log"
)

const defaultPollInterval = 250 * time.Millisecond
Expand All @@ -28,7 +27,7 @@
var slots map[string]string
if result := core.JSONUnmarshal(data, &slots); !result.OK {
err, _ := result.Value.(error)
return core.Fail(log.E("codegen", "invalid JSON", err))
return core.Fail(core.E("codegen", "invalid JSON", err))
}

if emitTypes {
Expand Down Expand Up @@ -89,10 +88,10 @@

func runDaemon(ctx context.Context, inputPath, outputPath string, emitTypes bool, pollInterval time.Duration) core.Result {
if inputPath == "" {
return core.Fail(log.E("codegen", "watch mode requires -input", nil))
return core.Fail(core.E("codegen", "watch mode requires -input", nil))
}
if outputPath == "" {
return core.Fail(log.E("codegen", "watch mode requires -output", nil))
return core.Fail(core.E("codegen", "watch mode requires -output", nil))
}
if pollInterval <= 0 {
pollInterval = defaultPollInterval
Expand Down Expand Up @@ -308,19 +307,19 @@

pollInterval, err := time.ParseDuration(raw)
if err != nil {
return core.Fail(log.E("codegen", "invalid poll interval", err))
return core.Fail(core.E("codegen", "invalid poll interval", err))
}
return core.Ok(pollInterval)
}

func runCodegenApp(c *core.Core) core.Result {
if c == nil {
return core.Fail(log.E("codegen.main", "core app is required", nil))
return core.Fail(core.E("codegen.main", "core app is required", nil))

Check failure on line 317 in go/cmd/codegen/main.go

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Define a constant instead of duplicating this literal "codegen.main" 4 times.

See more on https://sonarcloud.io/project/issues?id=dAppCore_go-html&issues=AZ3g8tyTxmT07nRtWi1Y&open=AZ3g8tyTxmT07nRtWi1Y&pullRequest=6
}

defer func() {
if result := c.ServiceShutdown(context.Background()); !result.OK {
log.Warn("codegen shutdown failed", "scope", "codegen.main", "err", result.Error())
core.Warn("codegen shutdown failed", "scope", "codegen.main", "err", result.Error())
}
}()

Expand Down Expand Up @@ -356,14 +355,14 @@
return core.Ok(nil)
}
if err, ok := result.Value.(error); ok && err != nil {
return core.Fail(log.E(op, msg, err))
return core.Fail(core.E(op, msg, err))
}
return core.Fail(log.E(op, msg, nil))
return core.Fail(core.E(op, msg, nil))
}

func main() {
c := newCodegenApp()
if result := runCodegenApp(c); !result.OK {
log.Error("codegen failed", "scope", "codegen.main", "err", result.Error())
core.Error("codegen failed", "scope", "codegen.main", "err", result.Error())
}
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
5 changes: 2 additions & 3 deletions cmd/wasm/register.go → go/cmd/wasm/register.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import (
core "dappco.re/go"

"dappco.re/go/html/codegen"
log "dappco.re/go/log"
)

// buildComponentJS takes a JSON slot map and returns the WC bundle JS result.
Expand All @@ -17,11 +16,11 @@ func buildComponentJS(slotsJSON string) core.Result {
var slots map[string]string
if result := core.JSONUnmarshalString(slotsJSON, &slots); !result.OK {
err, _ := result.Value.(error)
return core.Fail(log.E("buildComponentJS", "unmarshal JSON", err))
return core.Fail(core.E("buildComponentJS", "unmarshal JSON", err))
}
return codegen.GenerateBundle(slots)
}

func main() {
log.Info("go-html WASM module — build with GOOS=js GOARCH=wasm")
core.Info("go-html WASM module — build with GOOS=js GOARCH=wasm")
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
13 changes: 1 addition & 12 deletions cmd/wasm/size_test.go → go/cmd/wasm/size_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,18 +26,7 @@ func TestCmdWasm_WASMBinarySizeGood(t *testing.T) {
dir := t.TempDir()
out := core.Path(dir, "gohtml.wasm")

factory := process.NewService(process.Options{})
serviceValue, err := factory(core.New())
if err != nil {
t.Fatalf("unexpected error: %v", err)
}

svc, ok := serviceValue.(*process.Service)
if !ok {
t.Fatalf("process service factory returned %T", serviceValue)
}

output, err := svc.RunWithOptions(context.Background(), process.RunOptions{
output, err := process.RunWithOptions(context.Background(), process.RunOptions{
Command: "go",
Args: []string{"build", "-ldflags=-s -w", "-o", out, "."},
Dir: ".",
Expand Down
File renamed without changes.
File renamed without changes.
7 changes: 3 additions & 4 deletions codegen/codegen.go → go/codegen/codegen.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import (
"unicode/utf8"

core "dappco.re/go"
log "dappco.re/go/log"
)

var reservedCustomElementNames = map[string]struct{}{
Expand Down Expand Up @@ -141,7 +140,7 @@ var wcTemplate = template.Must(template.New("wc").Parse(`class {{.ClassName}} ex
// Usage example: result := GenerateClass("nav-bar", "H")
func GenerateClass(tag, slot string) core.Result {
if !isValidCustomElementTag(tag) {
return core.Fail(log.E("codegen.GenerateClass", "custom element tag must be a lowercase hyphenated name: "+tag, nil))
return core.Fail(core.E("codegen.GenerateClass", "custom element tag must be a lowercase hyphenated name: "+tag, nil))
}
b := core.NewBuilder()
tagLiteral := escapeJSStringLiteral(tag)
Expand All @@ -154,7 +153,7 @@ func GenerateClass(tag, slot string) core.Result {
SlotLiteral: slotLiteral,
})
if err != nil {
return core.Fail(log.E("codegen.GenerateClass", "template exec", err))
return core.Fail(core.E("codegen.GenerateClass", "template exec", err))
}
return core.Ok(b.String())
}
Expand Down Expand Up @@ -214,7 +213,7 @@ func GenerateBundle(slots map[string]string) core.Result {
if value, ok := clsResult.Value.(error); ok {
err = value
}
return core.Fail(log.E("codegen.GenerateBundle", "generate class for tag "+tag, err))
return core.Fail(core.E("codegen.GenerateBundle", "generate class for tag "+tag, err))
}
cls, _ := clsResult.Value.(string)
b.WriteString(cls)
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion go.mod → go/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ go 1.26.2
require (
dappco.re/go/i18n v0.8.0-alpha.1
dappco.re/go/io v0.8.0-alpha.1
dappco.re/go/log v0.8.0-alpha.1
dappco.re/go/process v0.8.0-alpha.1
github.com/gin-gonic/gin v1.12.0
)

require (
dappco.re/go/core v0.8.0-alpha.1 // indirect
dappco.re/go/log v0.8.0-alpha.1 // indirect
github.com/bytedance/gopkg v0.1.4 // indirect
github.com/bytedance/sonic v1.15.0 // indirect
github.com/bytedance/sonic/loader v0.5.0 // indirect
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
7 changes: 6 additions & 1 deletion text_translate_default.go → go/text_translate_default.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,10 @@ import (
)

func translateDefault(key string, args ...any) string {
return i18n.T(key, args...)
result := i18n.Translate(key, args...)
if result.OK {
value, _ := result.Value.(string)
return value
}
return key
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Loading