diff --git a/chat/go.mod b/chat/go.mod index 4f70106..013eea9 100644 --- a/chat/go.mod +++ b/chat/go.mod @@ -5,6 +5,7 @@ go 1.25 require ( github.com/chromedp/chromedp v0.14.2 github.com/livetemplate/livetemplate v0.7.0 + github.com/livetemplate/lvt v0.0.0-20251213063335-769e058d10cd ) require ( diff --git a/chat/go.sum b/chat/go.sum index d0b32bb..351af87 100644 --- a/chat/go.sum +++ b/chat/go.sum @@ -118,6 +118,8 @@ github.com/leodido/go-urn v1.4.0 h1:WT9HwE9SGECu3lg4d/dIA+jxlljEa1/ffXKmRjqdmIQ= github.com/leodido/go-urn v1.4.0/go.mod h1:bvxc+MVxLKB4z00jd1z+Dvzr47oO32F/QSNjSBOlFxI= github.com/livetemplate/livetemplate v0.7.0 h1:ugpgI+MG/y3QV/moOLaL9A7wc7HVwFw3aeyN3OZ6e00= github.com/livetemplate/livetemplate v0.7.0/go.mod h1:mTI76skBGEx4jD9pO52L9xBY4/ZDW4muAKWwXnupvtc= +github.com/livetemplate/lvt v0.0.0-20251213063335-769e058d10cd h1:3Ram0HdjMF1gVLvXNJMFw78c3pr9Qfp29W+yFhLVI9A= +github.com/livetemplate/lvt v0.0.0-20251213063335-769e058d10cd/go.mod h1:iqFfvhrJJ51XkGdEFsy5Ze0+nghSL1n6RFq+5EdUEFY= github.com/lufia/plan9stats v0.0.0-20211012122336-39d0f177ccd0 h1:6E+4a0GO5zZEnZ81pIr0yLvtUWk2if982qA3F3QD6H4= github.com/lufia/plan9stats v0.0.0-20211012122336-39d0f177ccd0/go.mod h1:zJYVVT2jmtg6P3p1VtQj7WsuWi/y4VnjVBn7F8KPB3I= github.com/magiconair/properties v1.8.10 h1:s31yESBquKXCV9a/ScB3ESkOjUYYv+X0rg8SYxI99mE= diff --git a/chat/main.go b/chat/main.go index 1993f59..3e6d24a 100644 --- a/chat/main.go +++ b/chat/main.go @@ -8,6 +8,7 @@ import ( "time" "github.com/livetemplate/livetemplate" + e2etest "github.com/livetemplate/lvt/testing" ) // ChatController holds shared state (message store) with mutex protection. @@ -205,8 +206,8 @@ func main() { // Mount handler with Controller+State pattern http.Handle("/", tmpl.Handle(controller, livetemplate.AsState(initialState))) - // Serve client library - http.HandleFunc("/livetemplate-client.js", serveClientLibrary) + // Serve client library (uses embedded client from lvt/testing) + http.HandleFunc("/livetemplate-client.js", e2etest.ServeClientLibrary) port := os.Getenv("PORT") if port == "" { @@ -224,21 +225,3 @@ func main() { } } -func serveClientLibrary(w http.ResponseWriter, r *http.Request) { - paths := []string{ - "livetemplate-client.js", - "../client/dist/livetemplate-client.browser.js", - "../../client/dist/livetemplate-client.browser.js", - } - - for _, path := range paths { - content, err := os.ReadFile(path) - if err == nil { - w.Header().Set("Content-Type", "application/javascript") - w.Write(content) - return - } - } - - http.Error(w, "Client library not found. For production, use CDN: https://cdn.jsdelivr.net/npm/@livefir/livetemplate-client/dist/livetemplate-client.browser.js", http.StatusNotFound) -}