+sse test

This commit is contained in:
Miki 2023-12-19 16:56:10 +01:00
parent 19cf309392
commit 2289aa31fd
61 changed files with 2250 additions and 0 deletions

BIN
sse/be/be Executable file

Binary file not shown.

37
sse/be/go.mod Normal file
View file

@ -0,0 +1,37 @@
module be
go 1.21.4
require (
github.com/gin-contrib/cors v1.5.0
github.com/gin-gonic/gin v1.9.1
)
require (
github.com/bytedance/sonic v1.10.1 // indirect
github.com/chenzhuoyu/base64x v0.0.0-20230717121745-296ad89f973d // indirect
github.com/chenzhuoyu/iasm v0.9.0 // indirect
github.com/gabriel-vasile/mimetype v1.4.2 // indirect
github.com/gin-contrib/sse v0.1.0 // indirect
github.com/go-playground/locales v0.14.1 // indirect
github.com/go-playground/universal-translator v0.18.1 // indirect
github.com/go-playground/validator/v10 v10.15.5 // indirect
github.com/goccy/go-json v0.10.2 // indirect
github.com/json-iterator/go v1.1.12 // indirect
github.com/klauspost/cpuid/v2 v2.2.5 // indirect
github.com/kr/text v0.2.0 // indirect
github.com/leodido/go-urn v1.2.4 // indirect
github.com/mattn/go-isatty v0.0.19 // indirect
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.2 // indirect
github.com/pelletier/go-toml/v2 v2.1.0 // indirect
github.com/twitchyliquid64/golang-asm v0.15.1 // indirect
github.com/ugorji/go/codec v1.2.11 // indirect
golang.org/x/arch v0.5.0 // indirect
golang.org/x/crypto v0.14.0 // indirect
golang.org/x/net v0.16.0 // indirect
golang.org/x/sys v0.13.0 // indirect
golang.org/x/text v0.13.0 // indirect
google.golang.org/protobuf v1.31.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)

102
sse/be/go.sum Normal file
View file

@ -0,0 +1,102 @@
github.com/bytedance/sonic v1.5.0/go.mod h1:ED5hyg4y6t3/9Ku1R6dU/4KyJ48DZ4jPhfY1O2AihPM=
github.com/bytedance/sonic v1.10.0-rc/go.mod h1:ElCzW+ufi8qKqNW0FY314xriJhyJhuoJ3gFZdAHF7NM=
github.com/bytedance/sonic v1.10.1 h1:7a1wuFXL1cMy7a3f7/VFcEtriuXQnUBhtoVfOZiaysc=
github.com/bytedance/sonic v1.10.1/go.mod h1:iZcSUejdk5aukTND/Eu/ivjQuEL0Cu9/rf50Hi0u/g4=
github.com/chenzhuoyu/base64x v0.0.0-20211019084208-fb5309c8db06/go.mod h1:DH46F32mSOjUmXrMHnKwZdA8wcEefY7UVqBKYGjpdQY=
github.com/chenzhuoyu/base64x v0.0.0-20221115062448-fe3a3abad311/go.mod h1:b583jCggY9gE99b6G5LEC39OIiVsWj+R97kbl5odCEk=
github.com/chenzhuoyu/base64x v0.0.0-20230717121745-296ad89f973d h1:77cEq6EriyTZ0g/qfRdp61a3Uu/AWrgIq2s0ClJV1g0=
github.com/chenzhuoyu/base64x v0.0.0-20230717121745-296ad89f973d/go.mod h1:8EPpVsBuRksnlj1mLy4AWzRNQYxauNi62uWcE3to6eA=
github.com/chenzhuoyu/iasm v0.9.0 h1:9fhXjVzq5hUy2gkhhgHl95zG2cEAhw9OSGs8toWWAwo=
github.com/chenzhuoyu/iasm v0.9.0/go.mod h1:Xjy2NpN3h7aUqeqM+woSuuvxmIe6+DDsiNLIrkAmYog=
github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/gabriel-vasile/mimetype v1.4.2 h1:w5qFW6JKBz9Y393Y4q372O9A7cUSequkh1Q7OhCmWKU=
github.com/gabriel-vasile/mimetype v1.4.2/go.mod h1:zApsH/mKG4w07erKIaJPFiX0Tsq9BFQgN3qGY5GnNgA=
github.com/gin-contrib/cors v1.5.0 h1:DgGKV7DDoOn36DFkNtbHrjoRiT5ExCe+PC9/xp7aKvk=
github.com/gin-contrib/cors v1.5.0/go.mod h1:TvU7MAZ3EwrPLI2ztzTt3tqgvBCq+wn8WpZmfADjupI=
github.com/gin-contrib/sse v0.1.0 h1:Y/yl/+YNO8GZSjAhjMsSuLt29uWRFHdHYUb5lYOV9qE=
github.com/gin-contrib/sse v0.1.0/go.mod h1:RHrZQHXnP2xjPF+u1gW/2HnVO7nvIa9PG3Gm+fLHvGI=
github.com/gin-gonic/gin v1.9.1 h1:4idEAncQnU5cB7BeOkPtxjfCSye0AAm1R0RVIqJ+Jmg=
github.com/gin-gonic/gin v1.9.1/go.mod h1:hPrL7YrpYKXt5YId3A/Tnip5kqbEAP+KLuI3SUcPTeU=
github.com/go-playground/assert/v2 v2.2.0 h1:JvknZsQTYeFEAhQwI4qEt9cyV5ONwRHC+lYKSsYSR8s=
github.com/go-playground/assert/v2 v2.2.0/go.mod h1:VDjEfimB/XKnb+ZQfWdccd7VUvScMdVu0Titje2rxJ4=
github.com/go-playground/locales v0.14.1 h1:EWaQ/wswjilfKLTECiXz7Rh+3BjFhfDFKv/oXslEjJA=
github.com/go-playground/locales v0.14.1/go.mod h1:hxrqLVvrK65+Rwrd5Fc6F2O76J/NuW9t0sjnWqG1slY=
github.com/go-playground/universal-translator v0.18.1 h1:Bcnm0ZwsGyWbCzImXv+pAJnYK9S473LQFuzCbDbfSFY=
github.com/go-playground/universal-translator v0.18.1/go.mod h1:xekY+UJKNuX9WP91TpwSH2VMlDf28Uj24BCp08ZFTUY=
github.com/go-playground/validator/v10 v10.15.5 h1:LEBecTWb/1j5TNY1YYG2RcOUN3R7NLylN+x8TTueE24=
github.com/go-playground/validator/v10 v10.15.5/go.mod h1:9iXMNT7sEkjXb0I+enO7QXmzG6QCsPWY4zveKFVRSyU=
github.com/goccy/go-json v0.10.2 h1:CrxCmQqYDkv1z7lO7Wbh2HN93uovUHgrECaO5ZrCXAU=
github.com/goccy/go-json v0.10.2/go.mod h1:6MelG93GURQebXPDq3khkgXZkazVtN9CRI+MGFi0w8I=
github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk=
github.com/google/go-cmp v0.5.5 h1:Khx7svrCpmxxtHBq5j2mp/xVjsi8hQMfNLvJFAlrGgU=
github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM=
github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo=
github.com/klauspost/cpuid/v2 v2.0.9/go.mod h1:FInQzS24/EEf25PyTYn52gqo7WaD8xa0213Md/qVLRg=
github.com/klauspost/cpuid/v2 v2.2.5 h1:0E5MSMDEoAulmXNFquVs//DdoomxaoTY1kUhbc/qbZg=
github.com/klauspost/cpuid/v2 v2.2.5/go.mod h1:Lcz8mBdAVJIBVzewtcLocK12l3Y+JytZYpaMropDUws=
github.com/knz/go-libedit v1.10.1/go.mod h1:MZTVkCWyz0oBc7JOWP3wNAzd002ZbM/5hgShxwh4x8M=
github.com/kr/pretty v0.3.0 h1:WgNl7dwNpEZ6jJ9k1snq4pZsg7DOEN8hP9Xw0Tsjwk0=
github.com/kr/pretty v0.3.0/go.mod h1:640gp4NfQd8pI5XOwp5fnNeVWj67G7CFk/SaSQn7NBk=
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
github.com/leodido/go-urn v1.2.4 h1:XlAE/cm/ms7TE/VMVoduSpNBoyc2dOxHs5MZSwAN63Q=
github.com/leodido/go-urn v1.2.4/go.mod h1:7ZrI8mTSeBSHl/UaRyKQW1qZeMgak41ANeCNaVckg+4=
github.com/mattn/go-isatty v0.0.19 h1:JITubQf0MOLdlGRuRq+jtsDlekdYPia9ZFsB8h/APPA=
github.com/mattn/go-isatty v0.0.19/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y=
github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg=
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
github.com/modern-go/reflect2 v1.0.2 h1:xBagoLtFs94CBntxluKeaWgTMpvLxC4ur3nMaC9Gz0M=
github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk=
github.com/pelletier/go-toml/v2 v2.1.0 h1:FnwAJ4oYMvbT/34k9zzHuZNrhlz48GB3/s6at6/MHO4=
github.com/pelletier/go-toml/v2 v2.1.0/go.mod h1:tJU2Z3ZkXwnxa4DPO899bsyIoywizdUvyaeZurnPPDc=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/rogpeppe/go-internal v1.8.0 h1:FCbCCtXNOY3UtUuHUYaghJg4y7Fd14rXifAYUAtL9R8=
github.com/rogpeppe/go-internal v1.8.0/go.mod h1:WmiCO8CzOY8rg0OYDC4/i/2WRWAB6poM+XZ2dLUbcbE=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw=
github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo=
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
github.com/stretchr/testify v1.8.2/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk=
github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
github.com/twitchyliquid64/golang-asm v0.15.1 h1:SU5vSMR7hnwNxj24w34ZyCi/FmDZTkS4MhqMhdFk5YI=
github.com/twitchyliquid64/golang-asm v0.15.1/go.mod h1:a1lVb/DtPvCB8fslRZhAngC2+aY1QWCk3Cedj/Gdt08=
github.com/ugorji/go/codec v1.2.11 h1:BMaWp1Bb6fHwEtbplGBGJ498wD+LKlNSl25MjdZY4dU=
github.com/ugorji/go/codec v1.2.11/go.mod h1:UNopzCgEMSXjBc6AOMqYvWC1ktqTAfzJZUZgYf6w6lg=
golang.org/x/arch v0.0.0-20210923205945-b76863e36670/go.mod h1:5om86z9Hs0C8fWVUuoMHwpExlXzs5Tkyp9hOrfG7pp8=
golang.org/x/arch v0.5.0 h1:jpGode6huXQxcskEIpOCvrU+tzo81b6+oFLUYXWtH/Y=
golang.org/x/arch v0.5.0/go.mod h1:5om86z9Hs0C8fWVUuoMHwpExlXzs5Tkyp9hOrfG7pp8=
golang.org/x/crypto v0.14.0 h1:wBqGXzWJW6m1XrIKlAH0Hs1JJ7+9KBwnIO8v66Q9cHc=
golang.org/x/crypto v0.14.0/go.mod h1:MVFd36DqK4CsrnJYDkBA3VC4m2GkXAM0PvzMCn4JQf4=
golang.org/x/net v0.16.0 h1:7eBu7KsSvFDtSXUIDbh3aqlK4DPsZ1rByC8PFfBThos=
golang.org/x/net v0.16.0/go.mod h1:NxSsAGuq816PNPmqtQdLE42eU2Fs7NoRIZrHJAlaCOE=
golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.13.0 h1:Af8nKPmuFypiUBjVoU9V20FiaFXOcuZI21p0ycVYYGE=
golang.org/x/sys v0.13.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/text v0.13.0 h1:ablQoSUd0tRdKxZewP80B+BaqeKJuVhuRxj/dkrun3k=
golang.org/x/text v0.13.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE=
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543 h1:E7g+9GITq07hpfrRu66IVDexMakfv52eLZ2CXBWiKr4=
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw=
google.golang.org/protobuf v1.31.0 h1:g0LDEJHgrBl9N9r17Ru3sqWhkIx2NB67okBHPwC7hs8=
google.golang.org/protobuf v1.31.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk=
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
nullprogram.com/x/optparse v1.0.0/go.mod h1:KdyPE+Igbe0jQUrVfMqDMeJQIJZEuyV7pjYmp6pbG50=
rsc.io/pdf v0.1.1/go.mod h1:n8OzWcQ6Sp37PL01nO98y4iUCRdTGarVfzxY20ICaU4=

175
sse/be/main.go Normal file
View file

@ -0,0 +1,175 @@
package main
import (
"encoding/json"
"io"
"strconv"
"github.com/gin-contrib/cors"
"github.com/gin-gonic/gin"
)
type Message struct {
Event string `json:"event"`
Data string `json:"data"`
Id string `json:"id"`
}
type Event struct {
Message chan Message
NewClient chan chan string
ClosedClient chan chan string
TotalClients map[chan string]bool
}
type ClientChan chan string
func main() {
r := gin.Default()
r.Use(cors.Default())
event := NewServer()
api := r.Group("/api")
api.GET("/sse", HeadersMiddleware(), event.serveHTTP(), event.retvalSSE())
api.GET("/msg", event.SendNewMsg())
api.GET("/ping", event.SendPing())
api.GET("/pong", event.SendPong())
sse := r.Group("/sse")
sse.Static("/", "./static/sse")
app := r.Group("/_app")
app.Static("/", "./static/_app")
static := r.Group("/static")
static.Static("/", "./static/static")
r.StaticFile("/", "./static/index.html")
r.StaticFile("/favicon.png", "./static/favicon.png")
r.ForwardedByClientIP = true
r.SetTrustedProxies([]string{"127.0.0.1"})
r.Run(":8888")
}
func NewServer() *Event {
event := &Event{
Message: make(chan Message),
NewClient: make(chan chan string),
ClosedClient: make(chan chan string),
TotalClients: make(map[chan string]bool),
}
go event.Broadcast()
return event
}
func HeadersMiddleware() gin.HandlerFunc {
return func(c *gin.Context) {
headers := c.Writer.Header()
headers.Set("Content-Type", "text/event-stream")
headers.Set("Cache-Control", "no-cache")
headers.Set("Connection", "keep-alive")
headers.Set("Transfer-Encoding", "chunked")
c.Next()
}
}
func (e *Event) serveHTTP() gin.HandlerFunc {
return func(c *gin.Context) {
// Initialize client channel
clientChan := make(ClientChan)
// Send new connection to event server
e.NewClient <- clientChan
defer func() {
// Send closed connection to event server
e.ClosedClient <- clientChan
}()
c.Set("clientChan", clientChan)
c.Next()
}
}
func (e *Event) retvalSSE() gin.HandlerFunc {
return func(c *gin.Context) {
v, ok := c.Get("clientChan")
if !ok {
return
}
clientChan, ok := v.(ClientChan)
if !ok {
return
}
c.Stream(func(w io.Writer) bool {
msg, ok := <-clientChan
if ok {
c.SSEvent("message", msg)
}
return ok
})
}
}
func (e *Event) Broadcast() {
id := 0
for {
select {
case client := <-e.NewClient:
e.TotalClients[client] = true
case client := <-e.ClosedClient:
delete(e.TotalClients, client)
close(client)
case message := <-e.Message:
id++
message.Id = strconv.Itoa(id)
for client := range e.TotalClients {
msg, _ := json.Marshal(message)
client <- string(msg)
}
}
}
}
func (e *Event) SendNewMsg() gin.HandlerFunc {
return func(c *gin.Context) {
e.SendMsg(Message{
Event: "message",
Data: "hello",
Id: "1",
})
}
}
func (e *Event) SendPing() gin.HandlerFunc {
return func(c *gin.Context) {
e.SendMsg(Message{
Event: "ping",
Data: "hello",
Id: "1",
})
}
}
func (e *Event) SendPong() gin.HandlerFunc {
return func(c *gin.Context) {
e.SendMsg(Message{
Event: "pong",
Data: "hello",
Id: "1",
})
}
}
func (e *Event) SendMsg(msg Message) {
e.Message <- msg
}

View file

@ -0,0 +1 @@
export const env={}

View file

@ -0,0 +1 @@
€export const env={}

Binary file not shown.

File diff suppressed because one or more lines are too long

View file

@ -0,0 +1 @@
function k(){}function x(t,n){for(const e in n)t[e]=n[e];return t}function w(t){return t()}function z(){return Object.create(null)}function j(t){t.forEach(w)}function F(t){return typeof t=="function"}function P(t,n){return t!=t?n==n:t!==n||t&&typeof t=="object"||typeof t=="function"}function S(t){return Object.keys(t).length===0}function E(t,...n){if(t==null){for(const o of n)o(void 0);return k}const e=t.subscribe(...n);return e.unsubscribe?()=>e.unsubscribe():e}function U(t,n,e){t.$$.on_destroy.push(E(n,e))}function A(t,n,e,o){if(t){const r=g(t,n,e,o);return t[0](r)}}function g(t,n,e,o){return t[1]&&o?x(e.ctx.slice(),t[1](o(n))):e.ctx}function B(t,n,e,o){if(t[2]&&o){const r=t[2](o(e));if(n.dirty===void 0)return r;if(typeof r=="object"){const a=[],f=Math.max(n.dirty.length,r.length);for(let s=0;s<f;s+=1)a[s]=n.dirty[s]|r[s];return a}return n.dirty|r}return n.dirty}function C(t,n,e,o,r,a){if(r){const f=g(n,e,o,a);t.p(f,r)}}function D(t){if(t.ctx.length>32){const n=[],e=t.ctx.length/32;for(let o=0;o<e;o++)n[o]=-1;return n}return-1}let i;function d(t){i=t}function m(){if(!i)throw new Error("Function called outside component initialization");return i}function G(t){m().$$.on_mount.push(t)}function H(t){m().$$.after_update.push(t)}const l=[],p=[];let u=[];const b=[],y=Promise.resolve();let h=!1;function v(){h||(h=!0,y.then(q))}function I(){return v(),y}function O(t){u.push(t)}const _=new Set;let c=0;function q(){if(c!==0)return;const t=i;do{try{for(;c<l.length;){const n=l[c];c++,d(n),M(n.$$)}}catch(n){throw l.length=0,c=0,n}for(d(null),l.length=0,c=0;p.length;)p.pop()();for(let n=0;n<u.length;n+=1){const e=u[n];_.has(e)||(_.add(e),e())}u.length=0}while(l.length);for(;b.length;)b.pop()();h=!1,_.clear(),d(t)}function M(t){if(t.fragment!==null){t.update(),j(t.before_update);const n=t.dirty;t.dirty=[-1],t.fragment&&t.fragment.p(t.ctx,n),t.after_update.forEach(O)}}function J(t){const n=[],e=[];u.forEach(o=>t.indexOf(o)===-1?n.push(o):e.push(o)),e.forEach(o=>o()),u=n}export{H as a,p as b,A as c,B as d,U as e,z as f,D as g,q as h,F as i,S as j,O as k,J as l,i as m,k as n,G as o,d as p,w as q,j as r,P as s,I as t,C as u,l as v,v as w};

View file

@ -0,0 +1,4 @@
o <20>Βqο!6¥mƒΥL­ZlοΝ―Pκ„V<E2809E>
#( '<27>EΫΪY6ή]™\η“6w<36>΄ώp4uφΣιΗv 4Ζ eΦε»ΖP<CE96>ύμ'*uΤΕΦ¥Ή-n.ΐΉKA“(|\ΆUΫΝ?<3F>a<EFBFBD>V<EFBFBD>σ,§cqΰςδΠJ„+¥³D<E28093>!#>eb@k<>~c£Zπzϊ<7A>l,<2C>―ΰΡ+>Ι‡ί`οχό<CF87>=―–‘†(ά™\ Δύρ<CF8D>Κ6Iiυ<69>µRί—σsj¤<CΘΨϋµFΘ)-p|<7C>$Ν(Θς}φϋ}΄ϊφ #YΚΊs=Η2¦ΪΒΠeswZεχ΄!3£Xmπ6Ag·0m<30>hBk<05>ΟάΊοkμ)έ΄75ρcK€Y7¦ ’κ «
••^`4πVqx…ƒ5zΝ]<5D><>ην/ΐ³ςϋ+‰µ:… Υ<C2B3>α£3S"Η<Uδ§υΦΒ>AΟίεO'qγSp Β¬q<C2AC>)^1Ρ—@^―ο~1I<E28093>‡cΝκ©8­YΠλ$θNs»ϊJT<4A>cνώu5$£vAρpέΣ[]σ:#{CκROτ¨΄›<1F>Hθk²P${υ-m >΄p„@¦Τ<1E>ΎΆ5κ:K®4™[ΰDρ‰Ύ†<CE8E>ΞƒT;ηUνρjΌΫ|³ςzΘ?<0E>~ΎΪx +4|ή}1ν“5<E2809C>ΌβrΎµΠβZ©«<C2A9>?u—6†ΈΧm”ΈinYυ<59>­ς<C2AD>ϋΎ`<60>ΟΒlqς¥<CF82>W?<3F>Μq΄PM™s/x`§Ύφ=r3Ύ~$<24>dύ„·mNFηnίYQ½“Z»¥§wσ„i&- έΫb)­Qεw<CEB5>ήΟΥώϊI{ΒΦΥ‡2πΝΟΘ®λ:r ρτ_ckΟρΥxmU3²{1l<Ό'λ<10>BΞ3;/ς-Τ‡€%\[$ j³ :E|)πΩέ`}<7D>Η£ΗΗΓ΄¬<CE84>ωΫό<CEAB>DU}ιI,Ω}/Η%Ξΰχ\2έ"Ο<>π±8θυ…ν7Q|rHd¤ψΑ<CF88> “²ΰ½@©Τ`xΠBq2Ώ"CΓωω£ /jph4ωG'93[²»®HΫρ*XtiS><3E>ο,™¤Ι|iΣ"[Α#SF f<±i•ΪΧW:Y7.:Ί<>β!<21>9Ζp>ψ†„ H)!γ
rή΅ΰ b5K@®<>ΘAΠƒd<01>Πά‚α,«¦£s?BD®…

View file

@ -0,0 +1 @@
import{n as d,s as k}from"./scheduler.k-kUyWhY.js";const u=[];function p(t,e=d){let n;const o=new Set;function a(s){if(k(t,s)&&(t=s,n)){const c=!u.length;for(const i of o)i[1](),u.push(i,t);if(c){for(let i=0;i<u.length;i+=2)u[i][0](u[i+1]);u.length=0}}}function l(s){a(s(t))}function r(s,c=d){const i=[s,c];return o.add(i),o.size===1&&(n=e(a,l)||d),s(t),()=>{o.delete(i),o.size===0&&n&&(n(),n=null)}}return{set:a,update:l,subscribe:r}}const m=globalThis.__sveltekit_1omqn18?.base??"",E=globalThis.__sveltekit_1omqn18?.assets??m,A="1703001309124",I="sveltekit:snapshot",w="sveltekit:scroll",y="sveltekit:states",N="sveltekit:pageurl",U="sveltekit:history",L="sveltekit:navigation",_={tap:1,hover:2,viewport:3,eager:4,off:-1,false:-1},g=location.origin;function O(t){if(t instanceof URL)return t;let e=document.baseURI;if(!e){const n=document.getElementsByTagName("base");e=n.length?n[0].href:document.URL}return new URL(t,e)}function Y(){return{x:pageXOffset,y:pageYOffset}}function f(t,e){return t.getAttribute(`data-sveltekit-${e}`)}const b={..._,"":_.hover};function v(t){let e=t.assignedSlot??t.parentNode;return e?.nodeType===11&&(e=e.host),e}function q(t,e){for(;t&&t!==e;){if(t.nodeName.toUpperCase()==="A"&&t.hasAttribute("href"))return t;t=v(t)}}function x(t,e){let n;try{n=new URL(t instanceof SVGAElement?t.href.baseVal:t.href,document.baseURI)}catch{}const o=t instanceof SVGAElement?t.target.baseVal:t.target,a=!n||!!o||T(n,e)||(t.getAttribute("rel")||"").split(/\s+/).includes("external"),l=n?.origin===g&&t.hasAttribute("download");return{url:n,external:a,target:o,download:l}}function P(t){let e=null,n=null,o=null,a=null,l=null,r=null,s=t;for(;s&&s!==document.documentElement;)o===null&&(o=f(s,"preload-code")),a===null&&(a=f(s,"preload-data")),e===null&&(e=f(s,"keepfocus")),n===null&&(n=f(s,"noscroll")),l===null&&(l=f(s,"reload")),r===null&&(r=f(s,"replacestate")),s=v(s);function c(i){switch(i){case"":case"true":return!0;case"off":case"false":return!1;default:return}}return{preload_code:b[o??"off"],preload_data:b[a??"off"],keepfocus:c(e),noscroll:c(n),reload:c(l),replace_state:c(r)}}function h(t){const e=p(t);let n=!0;function o(){n=!0,e.update(r=>r)}function a(r){n=!1,e.set(r)}function l(r){let s;return e.subscribe(c=>{(s===void 0||n&&c!==s)&&r(s=c)})}return{notify:o,set:a,subscribe:l}}function R(){const{set:t,subscribe:e}=p(!1);let n;async function o(){clearTimeout(n);try{const a=await fetch(`${E}/_app/version.json`,{headers:{pragma:"no-cache","cache-control":"no-cache"}});if(!a.ok)return!1;const r=(await a.json()).version!==A;return r&&(t(!0),clearTimeout(n)),r}catch{return!1}}return{subscribe:e,check:o}}function T(t,e){return t.origin!==g||!t.pathname.startsWith(e)}function V(t){t.client}const G={url:h({}),page:h({}),navigating:p(null),updated:R()};export{U as H,L as N,N as P,w as S,y as a,I as b,P as c,G as d,m as e,q as f,x as g,_ as h,T as i,V as j,g as o,O as r,Y as s};

File diff suppressed because one or more lines are too long

Binary file not shown.

Binary file not shown.

File diff suppressed because one or more lines are too long

View file

@ -0,0 +1 @@
import{s as l,c as r,u as i,g as u,d as f}from"../chunks/scheduler.k-kUyWhY.js";import{S as _,i as c,d as p,t as d}from"../chunks/index.PctGSwCt.js";const m=!0,g=!1,$="always",v=Object.freeze(Object.defineProperty({__proto__:null,prerender:m,ssr:g,trailingSlash:$},Symbol.toStringTag,{value:"Module"}));function y(n){let s;const a=n[1].default,e=r(a,n,n[0],null);return{c(){e&&e.c()},l(t){e&&e.l(t)},m(t,o){e&&e.m(t,o),s=!0},p(t,[o]){e&&e.p&&(!s||o&1)&&i(e,a,t,t[0],s?f(a,t[0],o,null):u(t[0]),null)},i(t){s||(p(e,t),s=!0)},o(t){d(e,t),s=!1},d(t){e&&e.d(t)}}}function S(n,s,a){let{$$slots:e={},$$scope:t}=s;return n.$$set=o=>{"$$scope"in o&&a(0,t=o.$$scope)},[t,e]}class j extends _{constructor(s){super(),c(this,s,S,y,l,{})}}export{j as component,v as universal};

Binary file not shown.

Binary file not shown.

View file

@ -0,0 +1 @@
import{s as E,n as b,e as x}from"../chunks/scheduler.k-kUyWhY.js";import{S,i as j,g as _,m as f,s as q,h as d,j as g,n as h,f as p,c as y,a as l,x as v,o as $}from"../chunks/index.PctGSwCt.js";import{d as C}from"../chunks/singletons.4aHkxUVP.js";const H=()=>{const s=C;return{page:{subscribe:s.page.subscribe},navigating:{subscribe:s.navigating.subscribe},updated:s.updated}},P={subscribe(s){return H().page.subscribe(s)}};function k(s){let t,r=s[0].status+"",o,n,i,c=s[0].error?.message+"",u;return{c(){t=_("h1"),o=f(r),n=q(),i=_("p"),u=f(c)},l(e){t=d(e,"H1",{});var a=g(t);o=h(a,r),a.forEach(p),n=y(e),i=d(e,"P",{});var m=g(i);u=h(m,c),m.forEach(p)},m(e,a){l(e,t,a),v(t,o),l(e,n,a),l(e,i,a),v(i,u)},p(e,[a]){a&1&&r!==(r=e[0].status+"")&&$(o,r),a&1&&c!==(c=e[0].error?.message+"")&&$(u,c)},i:b,o:b,d(e){e&&(p(t),p(n),p(i))}}}function w(s,t,r){let o;return x(s,P,n=>r(0,o=n)),[o]}let D=class extends S{constructor(t){super(),j(this,t,w,k,E,{})}};export{D as component};

Binary file not shown.

Binary file not shown.

View file

@ -0,0 +1 @@
import{s as d,n as l}from"../chunks/scheduler.k-kUyWhY.js";import{S as h,i as u,g as m,s as _,h as p,y as v,c as x,a as i,f as o}from"../chunks/index.PctGSwCt.js";function C(f){let t,r="Welcome to SvelteKit",a,s,c='Visit <a href="https://kit.svelte.dev">kit.svelte.dev</a> to read the documentation';return{c(){t=m("h1"),t.textContent=r,a=_(),s=m("p"),s.innerHTML=c},l(e){t=p(e,"H1",{"data-svelte-h":!0}),v(t)!=="svelte-yyjjjs"&&(t.textContent=r),a=x(e),s=p(e,"P",{"data-svelte-h":!0}),v(s)!=="svelte-jl9sbz"&&(s.innerHTML=c)},m(e,n){i(e,t,n),i(e,a,n),i(e,s,n)},p:l,i:l,o:l,d(e){e&&(o(t),o(a),o(s))}}}class H extends h{constructor(t){super(),u(this,t,null,C,d,{})}}export{H as component};

Binary file not shown.

Binary file not shown.

View file

@ -0,0 +1 @@
import{s as N,n as y,r as O,o as D}from"../chunks/scheduler.k-kUyWhY.js";import{S as E,i as T,g as m,m as k,s as x,h as w,j as z,n as B,f as u,c as b,y as C,a as g,x as J,z as h,o as L}from"../chunks/index.PctGSwCt.js";function M(p){let c,s,n,i,o="send Msg",t,l,S="send Ping",d,r,v="send Pong",_,$;return{c(){c=m("h1"),s=k(p[0]),n=x(),i=m("button"),i.textContent=o,t=x(),l=m("button"),l.textContent=S,d=x(),r=m("button"),r.textContent=v},l(e){c=w(e,"H1",{});var a=z(c);s=B(a,p[0]),a.forEach(u),n=b(e),i=w(e,"BUTTON",{"data-svelte-h":!0}),C(i)!=="svelte-1a1zt14"&&(i.textContent=o),t=b(e),l=w(e,"BUTTON",{"data-svelte-h":!0}),C(l)!=="svelte-iklzn2"&&(l.textContent=S),d=b(e),r=w(e,"BUTTON",{"data-svelte-h":!0}),C(r)!=="svelte-1i1hqj6"&&(r.textContent=v)},m(e,a){g(e,c,a),J(c,s),g(e,n,a),g(e,i,a),g(e,t,a),g(e,l,a),g(e,d,a),g(e,r,a),_||($=[h(i,"click",P),h(l,"click",U),h(r,"click",j)],_=!0)},p(e,[a]){a&1&&L(s,e[0])},i:y,o:y,d(e){e&&(u(c),u(n),u(i),u(t),u(l),u(d),u(r)),_=!1,O($)}}}function f(){return new Date(Date.now()).toISOString()}async function P(){await fetch("/api/msg")}async function U(){await fetch("/api/ping")}async function j(){await fetch("/api/pong")}function q(p,c,s){let n;function i(){const o=new EventSource("/api/sse");return console.log("subscribe"),o.onopen=()=>{console.log(`sse open ${f()}`),s(0,n=`sse open ${f()}`)},o.onerror=()=>{console.log(`sse error ${f()}`),o.readyState===EventSource.CONNECTING&&console.log(`sse reconnecting ${f()}`),s(0,n=`sse error ${f()}`)},o.onmessage=t=>{let l=JSON.parse(t.data);console.log(`received: ${JSON.stringify(l)}`),s(0,n=`received: ${JSON.stringify(l)} ${Date.now()}`)},o.addEventListener("ping",t=>{console.log(`ping: ${t.data}`),s(0,n=`ping: ${t.data} ${Date.now()}`)}),o.addEventListener("pong",t=>{console.log(`pong: ${t.data}`),s(0,n=`pong: ${t.data} ${Date.now()}`)}),o.addEventListener("message",t=>{console.log(`message: ${t.data}`),s(0,n=`message: ${t.data} ${Date.now()}`)}),()=>{o.close(),console.log(`sse closing ${Date.now()}`)}}return D(()=>i()),s(0,n=""),[n]}class H extends E{constructor(c){super(),T(this,c,q,M,N,{})}}export{H as component};

Binary file not shown.

Binary file not shown.

View file

@ -0,0 +1 @@
{"version":"1703001309124"}

Binary file not shown.

Binary file not shown.

BIN
sse/be/static/favicon.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

35
sse/be/static/index.html Normal file
View file

@ -0,0 +1,35 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8" />
<link rel="icon" href="/favicon.png" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<link rel="modulepreload" href="/_app/immutable/entry/start.PsjcEp4p.js">
<link rel="modulepreload" href="/_app/immutable/chunks/scheduler.k-kUyWhY.js">
<link rel="modulepreload" href="/_app/immutable/chunks/singletons.4aHkxUVP.js">
<link rel="modulepreload" href="/_app/immutable/entry/app.zLHOYlGu.js">
<link rel="modulepreload" href="/_app/immutable/chunks/index.PctGSwCt.js">
</head>
<body data-sveltekit-preload-data="hover">
<div style="display: contents">
<script>
{
__sveltekit_1omqn18 = {
base: "",
env: null
};
const element = document.currentScript.parentElement;
Promise.all([
import("/_app/immutable/entry/start.PsjcEp4p.js"),
import("/_app/immutable/entry/app.zLHOYlGu.js")
]).then(([kit, app]) => {
kit.start(app, element);
});
}
</script>
</div>
</body>
</html>

BIN
sse/be/static/index.html.br Normal file

Binary file not shown.

BIN
sse/be/static/index.html.gz Normal file

Binary file not shown.

View file

@ -0,0 +1,35 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8" />
<link rel="icon" href="../favicon.png" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<link rel="modulepreload" href="../_app/immutable/entry/start.PsjcEp4p.js">
<link rel="modulepreload" href="../_app/immutable/chunks/scheduler.k-kUyWhY.js">
<link rel="modulepreload" href="../_app/immutable/chunks/singletons.4aHkxUVP.js">
<link rel="modulepreload" href="../_app/immutable/entry/app.zLHOYlGu.js">
<link rel="modulepreload" href="../_app/immutable/chunks/index.PctGSwCt.js">
</head>
<body data-sveltekit-preload-data="hover">
<div style="display: contents">
<script>
{
__sveltekit_1omqn18 = {
base: new URL("..", location).pathname.slice(0, -1),
env: null
};
const element = document.currentScript.parentElement;
Promise.all([
import("../_app/immutable/entry/start.PsjcEp4p.js"),
import("../_app/immutable/entry/app.zLHOYlGu.js")
]).then(([kit, app]) => {
kit.start(app, element);
});
}
</script>
</div>
</body>
</html>

Binary file not shown.

Binary file not shown.