diff --git a/app/app.go b/app/app.go index 6cd6125..22d7a8e 100644 --- a/app/app.go +++ b/app/app.go @@ -22,13 +22,28 @@ THE SOFTWARE. package app import ( + "fmt" + "time" + "git.bullercodeworks.com/brian/expds/data" + w "git.bullercodeworks.com/brian/tcell-widgets" + h "git.bullercodeworks.com/brian/tcell-widgets/helpers" "github.com/gdamore/tcell" "github.com/spf13/cobra" ) type App struct { - repo *data.Repo + Name string + h, w int + + running bool + tScreen tcell.Screen + + screen AppScreen + repo *data.Repo + + AppLogs []data.AppLog + style tcell.Style } @@ -44,10 +59,67 @@ func NewApp() *App { func (a *App) init() error { var err error a.repo, err = data.NewRepo() + if err != nil { + return fmt.Errorf("error initializing repo: %w", err) + } + if a.tScreen, err = tcell.NewScreen(); err != nil { + return fmt.Errorf("error creating screen: %w", err) + } + if err = a.tScreen.Init(); err != nil { + return fmt.Errorf("error initializing screen: %w", err) + } + a.tScreen.SetStyle(a.style) + a.tScreen.Clear() + + a.SetScreen(&ScreenHome{}) + + go func() { + var err error + for err == nil { + time.Sleep(time.Millisecond * 100) + err = a.PostNowEvent() + } + }() return err } func (a *App) Run(args []string) error { + a.running = true + for { + if !a.running { + return nil + } + if a.screen != nil { + a.ClearScreen() + a.screen.Draw() + } else { + a.DrawText(1, 1, "No screen loaded", tcell.StyleDefault) + } + + a.tScreen.Show() + // Poll Events + ev := a.tScreen.PollEvent() + switch ev := ev.(type) { + case *tcell.EventResize: + a.tScreen.Sync() + a.w, a.h = ev.Size() + a.screen.HandleResize(ev) + case *tcell.EventKey: + if ev.Key() == tcell.KeyCtrlC { + a.Stop() + } else if ev.Key() == tcell.KeyCtrlJ { + // Ctrl+J is the keypad 'Enter' + ev = tcell.NewEventKey(tcell.KeyEnter, 0, 0) + } + if a.screen != nil && !a.screen.HandleKey(ev) { + // Screen didn't handle the key + } + case *tcell.EventTime: + if a.screen != nil { + a.screen.HandleTime(ev) + } + } + } return nil } @@ -84,14 +156,14 @@ func (a *App) Cleanup() { a.tScreen.Fini() } func (a *App) GetRepo() *data.Repo { return a.repo } // Draw a rune to the screen -func (a *DhApp) DrawRune(x, y int, style tcell.Style, r rune) { +func (a *App) DrawRune(x, y int, style tcell.Style, r rune) { a.tScreen.SetContent(x, y, r, nil, style) } // Draw text to the screen -func (a *DhApp) DrawText(x, y int, text string, style tcell.Style) { +func (a *App) DrawText(x, y int, text string, style tcell.Style) { h.DrawText(x, y, text, style, a.tScreen) } // Draw a widget to the screen -func (a *DhApp) DrawWidget(w w.Widget) { w.Draw(a.tScreen) } +func (a *App) DrawWidget(w w.Widget) { w.Draw(a.tScreen) } diff --git a/app/screen_home.go b/app/screen_home.go index d79d52a..c2234b5 100644 --- a/app/screen_home.go +++ b/app/screen_home.go @@ -22,10 +22,16 @@ THE SOFTWARE. package app import ( + "fmt" + "git.bullercodeworks.com/brian/expds/data" + "git.bullercodeworks.com/brian/expds/data/models" wd "git.bullercodeworks.com/brian/expds/widgets" w "git.bullercodeworks.com/brian/tcell-widgets" + h "git.bullercodeworks.com/brian/tcell-widgets/helpers" + "github.com/bluesky-social/indigo/atproto/syntax" "github.com/gdamore/tcell" + "github.com/spf13/viper" ) type ScreenHome struct { @@ -37,14 +43,20 @@ type ScreenHome struct { menuLayout *w.TopMenuLayout menu *w.Menu - layout *w.LinearLayout + layout *w.LinearLayout + columns *w.LinearLayout - pdsListing *wd.SimpleListWithHelp - jsonContent *wd.JsonContent + activePds *models.Pds + pdsListingTypes []models.EntryType + pdsListing *wd.SimpleListWithHelp + pdsNSIDs []syntax.NSID + jsonContent *wd.JsonContent alert *w.Alert alertLayout *w.LinearLayout + cli *w.Cli + cursor int } @@ -55,38 +67,35 @@ func (s *ScreenHome) Init(a *App) { s.menuLayout = w.NewTopMenuLayout("home.toplayout", s.style) s.initMenu() + s.cli = w.NewCli("home.cli", s.style) + s.initCli() + s.alert = w.NewAlert("home.alert", s.style) s.alert.SetVisible(false) s.alertLayout = w.NewLinearLayout("home.alertlayout", s.style) s.alertLayout.Add(s.alert) s.layout = w.NewLinearLayout("home.layout", s.style) - s.layout.SetOrientation(w.LinLayH) + + s.columns = w.NewLinearLayout("home.layout.columns", s.style) + s.columns.SetOrientation(w.LinLayH) s.pdsListing = wd.NewSimpleListWithHelp("pdslisting", s.style) + s.pdsListing.SetBorder(h.BRD_SIMPLE) s.pdsListing.SetTitle("No PDS Loaded") - s.pdsListing.SetOnSelect(s.loadSelectedPdsListing) - s.layout.Add(s.pdsListing) + s.pdsListing.SetOnSelect(s.selectPdsListingEntry) + s.pdsListing.SetOnChange(s.updateJsonView) + s.pdsListing.SetVimMode(viper.GetBool(data.KeyVimMode)) s.jsonContent = wd.NewJsonContent("jsoncontent", s.style) - s.layout.Add(s.jsonContent) + s.columns.AddAll(s.pdsListing, s.jsonContent) + + s.layout.AddAll(s.columns, s.cli) + s.layout.SetWeight(s.columns, 4) s.menuLayout.SetWidget(s.layout) } -func (s *ScreenHome) initMenu() { - s.menuLayout.SetActive(true) - menu := s.menuLayout.Menu() - s.menuLayout.AddMenuItems( - menu.CreateMenuItem("File", nil, 'f', - menu.CreateMenuItem("Exit", func() bool { - s.a.Exit() - return true - }, 'x'), - ), - ) -} - func (s *ScreenHome) GetName() string { return "home" } func (s *ScreenHome) HandleResize(ev *tcell.EventResize) { s.w, s.h = ev.Size() @@ -97,17 +106,147 @@ func (s *ScreenHome) HandleKey(ev *tcell.EventKey) bool { if s.alert.Visible() { return s.alert.HandleKey(ev) } + if ev.Key() == tcell.KeyF12 { + s.toggleCli() + return true + } + return s.menuLayout.HandleKey(ev) } - func (s *ScreenHome) HandleTime(ev *tcell.EventTime) { s.menuLayout.HandleTime(ev) } +func (s *ScreenHome) Draw() { s.a.DrawWidget(s.menuLayout) } +func (s *ScreenHome) Exit() error { return nil } +func (s *ScreenHome) Log(t string, a ...any) { + s.cli.Log(t, a...) + s.showCli() +} -func (s *ScreenHome) Draw() { s.a.DrawWidget(s.menuLayout) } +func (s *ScreenHome) initMenu() { + s.menuLayout.SetActive(true) + menu := s.menuLayout.Menu() + s.menuLayout.AddMenuItems( + menu.CreateMenuItem("File", nil, 'f', + menu.CreateMenuItem("Exit", func() bool { + s.a.Exit() + return true + }, 'x'), + ), + menu.CreateMenuItem("Settings", nil, 's', + menu.CreateMenuItem("Toggle Vim Mode", func() bool { + viper.Set(data.KeyVimMode, !viper.GetBool(data.KeyVimMode)) + viper.WriteConfig() + s.update() + return true + }, 'v'), + ), + ) +} -func (s *ScreenHome) Exit() error { return nil } +func (s *ScreenHome) update() { + s.pdsListing.SetVimMode(viper.GetBool(data.KeyVimMode)) +} -func (s *ScreenHome) Log(t string, a ...any) {} +func (s *ScreenHome) initCli() { + s.cli.SetVisible(true) + s.cli.AddCommand(w.NewCliCommand("getpds", s.cliGetPds)) +} -func (s *ScreenHome) loadSelectedPdsListing(idx int, nm string) bool { +func (s *ScreenHome) toggleCli() { + if s.layout.Contains(s.cli) { + s.layout.Delete(s.cli) + } else { + s.layout.Add(s.cli) + } +} +func (s *ScreenHome) hideCli() { + if s.layout.Contains(s.cli) { + s.layout.Delete(s.cli) + } +} +func (s *ScreenHome) showCli() { + if !s.layout.Contains(s.cli) { + s.layout.Add(s.cli) + } +} + +func (s *ScreenHome) cliGetPds(args ...string) bool { + if len(args) == 0 { + s.Log("No id given.") + s.Log("Usage: 'getpds '") + return true + } + pds, err := s.r.GetPDS(args[1]) + if err != nil { + s.cli.Log(err.Error()) + return true + } + s.cli.Log("Retrieved: %s (%s)", pds.AtId, pds.Did) + /* + vals, err := pds.List() + if err != nil { + s.cli.Log(err.Error()) + return true + } + */ + s.pdsListing.SetTitle(fmt.Sprintf("%s (%s)", pds.AtId.String(), pds.Did.String())) + + // When we first get the pds, all entries are models.TypeNSID + s.pdsListingTypes = []models.EntryType{} + nsidList := pds.NSIDStringList() + for i := 0; i < len(nsidList); i++ { + s.pdsListingTypes = append(s.pdsListingTypes, models.TypeNSID) + } + s.pdsListing.SetList(nsidList) + s.hideCli() + s.activePds = pds return true } + +func (s *ScreenHome) selectPdsListingEntry(idx int, nm string) bool { + if len(s.pdsListingTypes) < idx { + s.Log("error finding pds listing type (idx: %d >= list length: %d", idx, len(s.pdsListingTypes)) + return false + } + // Update the jsonContent with the list of records + switch s.pdsListingTypes[idx] { + case models.TypeNSID: + nsid, err := syntax.ParseNSID(nm) + if err != nil { + s.Log("error parsing NSID from %s: %w", nm, err) + return false + } + recordIds := s.activePds.GetRecordIdsFor(nsid) + s.jsonContent.SetValue(recordIds) + return true + + case models.TypeRecord: + + } + + return false +} + +func (s *ScreenHome) updateJsonView(idx int, nm string) bool { + if len(s.pdsListingTypes) < idx { + s.Log("error finding pds listing type (idx: %d >= list length: %d", idx, len(s.pdsListingTypes)) + return false + } + // Update the jsonContent with the list of records + switch s.pdsListingTypes[idx] { + case models.TypeNSID: + nsid, err := syntax.ParseNSID(nm) + if err != nil { + s.Log("error parsing NSID from %s: %w", nm, err) + return false + } + recordIds := s.activePds.GetRecordIdsFor(nsid) + s.jsonContent.SetValue(recordIds) + return true + + case models.TypeRecord: + //s.jsonContent.SetValue(s.activePds.Records[ + + } + + return false +} diff --git a/build/expds b/build/expds new file mode 100755 index 0000000..275d467 Binary files /dev/null and b/build/expds differ diff --git a/cmd/root.go b/cmd/root.go index 170447b..0e36480 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -24,9 +24,9 @@ package cmd import ( "fmt" "os" - "strings" - "git.bullercodeworks.com/brian/expds/app" + "git.bullercodeworks.com/brian/expds/data" + "git.bullercodeworks.com/brian/expds/helpers" gap "github.com/muesli/go-app-paths" "github.com/spf13/cobra" "github.com/spf13/viper" @@ -39,11 +39,10 @@ var ( Name = "expds" cfgFile string ConfigDir = "" - program cli.Program rootCmd = &cobra.Command{ Use: "expds", Short: "Utility to edit and view PDS", - RunE: opRun, + RunE: runUI, } ) @@ -63,7 +62,6 @@ func init() { func initConfig() { viper.SetEnvPrefix(data.EnvPrefix) - viper.AutomaticEnv() var firstDir string if cfgFile == "" { scope := gap.NewScope(gap.User, Name) @@ -82,14 +80,15 @@ func initConfig() { viper.SetDefault(data.KeyConfigDir, firstDir) viper.SetDefault(data.KeyDebug, false) + viper.SetDefault(data.KeyDataDir, helpers.Path(firstDir, "data")) + viper.SetDefault(data.KeyVimMode, false) viper.SetConfigFile(cfgFile) - viper.BindEnv(data.KeyDebug) + viper.AutomaticEnv() configName := fmt.Sprintf("%s.yaml", Name) var createConfig bool - sep := string(os.PathSeparator) - ConfigDir = fmt.Sprintf("%s%s", firstDir, sep) - configPath := fmt.Sprintf("%s%s", ConfigDir, configName) + ConfigDir = fmt.Sprintf("%s%s", firstDir, helpers.Sep) + configPath := helpers.Path(ConfigDir, configName) if err := viper.ReadInConfig(); err != nil { createConfig = true if _, ok := err.(viper.ConfigFileNotFoundError); ok { @@ -116,17 +115,14 @@ func initConfig() { } } - if viper.GetString(data.KeyUrl) == "" { - url := helpers.CliPromptUser("Server URL", true) - if !strings.HasSuffix(url, "/") { - url = fmt.Sprintf("%s/", url) + dDir := viper.GetString(data.KeyDataDir) + _, err := os.Stat(dDir) + if os.IsNotExist(err) { + fmt.Println("Creating Data Directory:", dDir) + err := os.Mkdir(dDir, 0o755) + if err != nil { + fmt.Println(err) + os.Exit(1) } - viper.Set(data.KeyUrl, url) - viper.WriteConfig() } } - -func opRun(cmd *cobra.Command, args []string) error { - p := app.NewProgram() - return p.Run(args) -} diff --git a/cmd/ui.go b/cmd/ui.go new file mode 100644 index 0000000..af4ce15 --- /dev/null +++ b/cmd/ui.go @@ -0,0 +1,50 @@ +/* +Copyright © Brian Buller + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. +*/ +package cmd + +import ( + "git.bullercodeworks.com/brian/expds/app" + "github.com/spf13/cobra" +) + +// uiCmd represents the ui command +var uiCmd = &cobra.Command{ + Use: "ui", + Short: "Run the expds UI", + RunE: runUI, +} + +func init() { + rootCmd.AddCommand(uiCmd) +} + +func runUI(cmd *cobra.Command, args []string) error { + app := app.NewApp() + defer func() { + maybePanic := recover() + app.Cleanup() + if maybePanic != nil { + panic(maybePanic) + } + }() + return app.Run(args) +} diff --git a/data/api.go b/data/api.go new file mode 100644 index 0000000..31f4af0 --- /dev/null +++ b/data/api.go @@ -0,0 +1,36 @@ +/* +Copyright © Brian Buller + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. +*/ +package data + +import "net/http" + +type Api struct { + client http.Client + + LastResponse string +} + +func NewApi() *Api { + return &Api{ + client: http.Client{}, + } +} diff --git a/data/app_log.go b/data/app_log.go new file mode 100644 index 0000000..f813993 --- /dev/null +++ b/data/app_log.go @@ -0,0 +1,52 @@ +/* +Copyright © Brian Buller + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. +*/ +package data + +import ( + "fmt" + "time" +) + +type AppLog struct { + tm time.Time + log string + err error +} + +func NewAppError(err error) AppLog { + return AppLog{ + tm: time.Now(), + log: err.Error(), + err: err, + } +} + +func NewAppLog(txt string) AppLog { + return AppLog{ + tm: time.Now(), + log: txt, + } +} + +func (a AppLog) String() string { + return fmt.Sprintf("%s: %s", a.tm, a.log) +} diff --git a/data/config.go b/data/config.go index 55e6757..cf72379 100644 --- a/data/config.go +++ b/data/config.go @@ -25,4 +25,6 @@ const ( EnvPrefix = "EXPDS" KeyConfigDir = "config" KeyDebug = "debug" + KeyDataDir = "data" + KeyVimMode = "vimMode" ) diff --git a/data/models/pds.go b/data/models/pds.go new file mode 100644 index 0000000..b681d1a --- /dev/null +++ b/data/models/pds.go @@ -0,0 +1,182 @@ +/* +Copyright © Brian Buller + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. +*/ +package models + +import ( + "context" + "encoding/json" + "fmt" + "os" + "slices" + "time" + + "git.bullercodeworks.com/brian/expds/helpers" + comatproto "github.com/bluesky-social/indigo/api/atproto" + "github.com/bluesky-social/indigo/atproto/atdata" + "github.com/bluesky-social/indigo/atproto/identity" + "github.com/bluesky-social/indigo/atproto/repo" + "github.com/bluesky-social/indigo/atproto/syntax" + "github.com/bluesky-social/indigo/xrpc" + "github.com/ipfs/go-cid" + "github.com/spf13/viper" +) + +type EntryType int + +const ( + TypeNSID = EntryType(iota) + TypeRecord +) + +type Pds struct { + AtId syntax.AtIdentifier + Did syntax.DID + localPath string + + Commit string + NSIDs []syntax.NSID + RecordIds []string + nsidToRecordIds map[syntax.NSID][]string + Records map[string]map[string]any + + RefreshTime time.Time +} + +func NewPdsFromDid(id string) (*Pds, error) { + ctx := context.Background() + atid, err := syntax.ParseAtIdentifier(id) + if err != nil { + return nil, err + } + + // first look up the DID and PDS for this repo + dir := identity.DefaultDirectory() + ident, err := dir.Lookup(ctx, atid) + if err != nil { + return nil, err + } + + // create a new API client to connect to the account's PDS + xrpcc := xrpc.Client{ + Host: ident.PDSEndpoint(), + } + if xrpcc.Host == "" { + return nil, fmt.Errorf("no PDS endpoint for identity") + } + + carPath := helpers.Path(viper.GetString("data"), ident.DID.String()+".car") + repoBytes, err := comatproto.SyncGetRepo(ctx, &xrpcc, ident.DID.String(), "") + if err != nil { + return nil, err + } + if err := os.WriteFile(carPath, repoBytes, 0666); err != nil { + return nil, err + } + ret := &Pds{ + AtId: atid, + Did: ident.DID, + localPath: carPath, + nsidToRecordIds: make(map[syntax.NSID][]string), + Records: make(map[string]map[string]any), + RefreshTime: time.Now(), + } + return ret, ret.unpack() +} + +func (p *Pds) unpack() error { + ctx := context.Background() + fi, err := os.Open(p.localPath) + if err != nil { + return fmt.Errorf("error opening local car: %w", err) + } + + c, r, err := repo.LoadRepoFromCAR(ctx, fi) + if err != nil { + return fmt.Errorf("error loading repo from car: %w", err) + } + + comBytes, err := json.Marshal(c) + if err != nil { + return fmt.Errorf("error building commit meta json: %w") + } + p.Commit = string(comBytes) + + err = r.MST.Walk(func(k []byte, v cid.Cid) error { + col, rkey, err := syntax.ParseRepoPath(string(k)) + if err != nil { + return fmt.Errorf("error parsing repo path (%s): %w", string(k), err) + } + + sCol, sRKey := string(col), string(rkey) + recBytes, _, err := r.GetRecordBytes(ctx, col, rkey) + if err != nil { + return fmt.Errorf("error getting record bytes (%s/%s): %w", sCol, sRKey, err) + } + + rec, err := atdata.UnmarshalCBOR(recBytes) + if err != nil { + return fmt.Errorf("error unmarshalling cbor (%s/%s): %w", sCol, sRKey, err) + } + p.Records[string(k)] = rec + + if !slices.Contains(p.NSIDs, col) { + p.NSIDs = append(p.NSIDs, col) + } + p.nsidToRecordIds[col] = append(p.nsidToRecordIds[col], sRKey) + return nil + }) + //slices.Sort(p.NSIDs) + return err +} + +func (p *Pds) NSIDStringList() []string { + var ret []string + for _, wrk := range p.NSIDs { + ret = append(ret, wrk.String()) + } + return ret +} + +func (p *Pds) List() (map[string]string, error) { + ret := make(map[string]string) + ctx := context.Background() + fi, err := os.Open(p.localPath) + if err != nil { + return ret, fmt.Errorf("error opening local car: %w", err) + } + // read repository tree in to memory + _, r, err := repo.LoadRepoFromCAR(ctx, fi) + if err != nil { + return ret, fmt.Errorf("error loading repo from car: %w", err) + } + + err = r.MST.Walk(func(k []byte, v cid.Cid) error { + ret[string(k)] = v.String() + return nil + }) + if err != nil { + return ret, fmt.Errorf("error walking repo: %w", err) + } + return ret, nil +} + +func (p *Pds) GetRecordIdsFor(n syntax.NSID) []string { return p.nsidToRecordIds[n] } diff --git a/data/repo.go b/data/repo.go index f645317..e259fe1 100644 --- a/data/repo.go +++ b/data/repo.go @@ -21,9 +21,33 @@ THE SOFTWARE. */ package data +import ( + "time" + + "git.bullercodeworks.com/brian/expds/data/models" +) + type Repo struct { + LoadedPDSs map[string]*models.Pds + + BestBy time.Duration } func NewRepo() (*Repo, error) { - return &Repo{}, nil + return &Repo{ + LoadedPDSs: make(map[string]*models.Pds), + BestBy: time.Minute * 15, + }, nil +} + +func (r *Repo) GetPDS(atId string) (*models.Pds, error) { + if p, ok := r.LoadedPDSs[atId]; ok && time.Since(p.RefreshTime) < r.BestBy { + return p, nil + } + p, err := models.NewPdsFromDid(atId) + if err != nil { + return nil, err + } + r.LoadedPDSs[atId] = p + return p, nil } diff --git a/go.mod b/go.mod index 76c78c0..c2876c3 100644 --- a/go.mod +++ b/go.mod @@ -11,23 +11,89 @@ require ( require ( git.bullercodeworks.com/brian/tcell-widgets v0.0.0-20251115204352-197df3e02988 // indirect + github.com/beorn7/perks v1.0.1 // indirect + github.com/bluesky-social/indigo v0.0.0-20260120225912-12d69fa4d209 // indirect + github.com/cespare/xxhash/v2 v2.2.0 // indirect github.com/clipperhouse/stringish v0.1.1 // indirect github.com/clipperhouse/uax29/v2 v2.3.1 // indirect + github.com/earthboundkid/versioninfo/v2 v2.24.1 // indirect + github.com/felixge/httpsnoop v1.0.4 // indirect github.com/fsnotify/fsnotify v1.9.0 // indirect github.com/gdamore/encoding v1.0.1 // indirect + github.com/go-logr/logr v1.4.1 // indirect + github.com/go-logr/stdr v1.2.2 // indirect github.com/go-viper/mapstructure/v2 v2.5.0 // indirect + github.com/gogo/protobuf v1.3.2 // indirect + github.com/google/uuid v1.4.0 // indirect + github.com/hashicorp/go-cleanhttp v0.5.2 // indirect + github.com/hashicorp/go-retryablehttp v0.7.5 // indirect + github.com/hashicorp/golang-lru v1.0.2 // indirect + github.com/hashicorp/golang-lru/v2 v2.0.7 // indirect github.com/inconshreveable/mousetrap v1.1.0 // indirect + github.com/ipfs/bbloom v0.0.4 // indirect + github.com/ipfs/go-block-format v0.2.0 // indirect + github.com/ipfs/go-blockservice v0.5.2 // indirect + github.com/ipfs/go-cid v0.4.1 // indirect + github.com/ipfs/go-datastore v0.6.0 // indirect + github.com/ipfs/go-ipfs-blockstore v1.3.1 // indirect + github.com/ipfs/go-ipfs-ds-help v1.1.1 // indirect + github.com/ipfs/go-ipfs-exchange-interface v0.2.1 // indirect + github.com/ipfs/go-ipfs-util v0.0.3 // indirect + github.com/ipfs/go-ipld-cbor v0.1.0 // indirect + github.com/ipfs/go-ipld-format v0.6.0 // indirect + github.com/ipfs/go-ipld-legacy v0.2.1 // indirect + github.com/ipfs/go-log v1.0.5 // indirect + github.com/ipfs/go-log/v2 v2.5.1 // indirect + github.com/ipfs/go-merkledag v0.11.0 // indirect + github.com/ipfs/go-metrics-interface v0.0.1 // indirect + github.com/ipfs/go-verifcid v0.0.3 // indirect + github.com/ipld/go-car v0.6.1-0.20230509095817-92d28eb23ba4 // indirect + github.com/ipld/go-codec-dagpb v1.6.0 // indirect + github.com/ipld/go-ipld-prime v0.21.0 // indirect + github.com/jbenet/goprocess v0.1.4 // indirect + github.com/klauspost/cpuid/v2 v2.2.7 // indirect github.com/lucasb-eyer/go-colorful v1.3.0 // indirect + github.com/mattn/go-isatty v0.0.20 // indirect github.com/mattn/go-runewidth v0.0.19 // indirect + github.com/matttproud/golang_protobuf_extensions/v2 v2.0.0 // indirect + github.com/minio/sha256-simd v1.0.1 // indirect github.com/mitchellh/go-homedir v1.1.0 // indirect + github.com/mr-tron/base58 v1.2.0 // indirect + github.com/multiformats/go-base32 v0.1.0 // indirect + github.com/multiformats/go-base36 v0.2.0 // indirect + github.com/multiformats/go-multibase v0.2.0 // indirect + github.com/multiformats/go-multihash v0.2.3 // indirect + github.com/multiformats/go-varint v0.0.7 // indirect + github.com/opentracing/opentracing-go v1.2.0 // indirect github.com/pelletier/go-toml/v2 v2.2.4 // indirect + github.com/polydawn/refmt v0.89.1-0.20221221234430-40501e09de1f // indirect + github.com/prometheus/client_golang v1.17.0 // indirect + github.com/prometheus/client_model v0.5.0 // indirect + github.com/prometheus/common v0.45.0 // indirect + github.com/prometheus/procfs v0.12.0 // indirect github.com/sagikazarmark/locafero v0.12.0 // indirect github.com/sourcegraph/conc v0.3.1-0.20240121214520-5f936abd7ae8 // indirect + github.com/spaolacci/murmur3 v1.1.0 // indirect github.com/spf13/afero v1.15.0 // indirect github.com/spf13/cast v1.10.0 // indirect github.com/spf13/pflag v1.0.10 // indirect github.com/subosito/gotenv v1.6.0 // indirect + github.com/whyrusleeping/cbor-gen v0.2.1-0.20241030202151-b7a6831be65e // indirect + gitlab.com/yawning/secp256k1-voi v0.0.0-20230925100816-f2616030848b // indirect + gitlab.com/yawning/tuplehash v0.0.0-20230713102510-df83abbf9a02 // indirect + go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.46.1 // indirect + go.opentelemetry.io/otel v1.21.0 // indirect + go.opentelemetry.io/otel/metric v1.21.0 // indirect + go.opentelemetry.io/otel/trace v1.21.0 // indirect + go.uber.org/atomic v1.11.0 // indirect + go.uber.org/multierr v1.11.0 // indirect + go.uber.org/zap v1.26.0 // indirect go.yaml.in/yaml/v3 v3.0.4 // indirect + golang.org/x/crypto v0.21.0 // indirect golang.org/x/sys v0.40.0 // indirect golang.org/x/text v0.33.0 // indirect + golang.org/x/time v0.3.0 // indirect + golang.org/x/xerrors v0.0.0-20231012003039-104605ab7028 // indirect + google.golang.org/protobuf v1.33.0 // indirect + lukechampine.com/blake3 v1.2.1 // indirect ) diff --git a/go.sum b/go.sum index b535989..6449b60 100644 --- a/go.sum +++ b/go.sum @@ -1,10 +1,25 @@ git.bullercodeworks.com/brian/tcell-widgets v0.0.0-20251115204352-197df3e02988 h1:O4cDOi2FcMIEKWFQ8KhlIpRfyxAZ2m1o8P6Y5B6uhNg= git.bullercodeworks.com/brian/tcell-widgets v0.0.0-20251115204352-197df3e02988/go.mod h1:3TlKbuGjY8nrKL5Qcp28h+KnEsXBl3iCwACTy79bdPg= +github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= +github.com/benbjohnson/clock v1.1.0/go.mod h1:J11/hYXuz8f4ySSvYwY0FKfm+ezbsZBKZxNJlLklBHA= +github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM= +github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw= +github.com/bluesky-social/indigo v0.0.0-20260120225912-12d69fa4d209 h1:W01PGqjCexVBzIZ4FoNe4iO8OhI9XbSE7ieWL0QnMu8= +github.com/bluesky-social/indigo v0.0.0-20260120225912-12d69fa4d209/go.mod h1:KIy0FgNQacp4uv2Z7xhNkV3qZiUSGuRky97s7Pa4v+o= +github.com/cespare/xxhash/v2 v2.2.0 h1:DC2CZ1Ep5Y4k3ZQ899DldepgrayRUGE6BBZ/cd9Cj44= +github.com/cespare/xxhash/v2 v2.2.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= github.com/clipperhouse/stringish v0.1.1 h1:+NSqMOr3GR6k1FdRhhnXrLfztGzuG+VuFDfatpWHKCs= github.com/clipperhouse/stringish v0.1.1/go.mod h1:v/WhFtE1q0ovMta2+m+UbpZ+2/HEXNWYXQgCt4hdOzA= github.com/clipperhouse/uax29/v2 v2.3.1 h1:RjM8gnVbFbgI67SBekIC7ihFpyXwRPYWXn9BZActHbw= github.com/clipperhouse/uax29/v2 v2.3.1/go.mod h1:Wn1g7MK6OoeDT0vL+Q0SQLDz/KpfsVRgg6W7ihQeh4g= +github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU= github.com/cpuguy83/go-md2man/v2 v2.0.6/go.mod h1:oOW0eioCTA6cOiMLiUPZOpcVxMig6NIQQ7OS05n1F4g= +github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/earthboundkid/versioninfo/v2 v2.24.1 h1:SJTMHaoUx3GzjjnUO1QzP3ZXK6Ee/nbWyCm58eY3oUg= +github.com/earthboundkid/versioninfo/v2 v2.24.1/go.mod h1:VcWEooDEuyUJnMfbdTh0uFN4cfEIg+kHMuWB2CDCLjw= +github.com/felixge/httpsnoop v1.0.4 h1:NFTV2Zj1bL4mc9sqWACXbQFVBBg2W3GPvqp8/ESS2Wg= +github.com/felixge/httpsnoop v1.0.4/go.mod h1:m8KPJKqk1gH5J9DgRY2ASl2lWCfGKXixSwevea8zH2U= github.com/fsnotify/fsnotify v1.9.0 h1:2Ml+OJNzbYCTzsxtv8vKSFD9PbJjmhYF14k/jKC7S9k= github.com/fsnotify/fsnotify v1.9.0/go.mod h1:8jBTzvmWwFyi3Pb8djgCCO5IBqzKJ/Jwo8TRcHyHii0= github.com/gdamore/encoding v1.0.0/go.mod h1:alR0ol34c49FCSBLjhosxzcPHQbf2trDkoo5dl+VrEg= @@ -12,27 +27,140 @@ github.com/gdamore/encoding v1.0.1 h1:YzKZckdBL6jVt2Gc+5p82qhrGiqMdG/eNs6Wy0u3Uh github.com/gdamore/encoding v1.0.1/go.mod h1:0Z0cMFinngz9kS1QfMjCP8TY7em3bZYeeklsSDPivEo= github.com/gdamore/tcell v1.4.1 h1:6T2+7Zl5U44SU3ensYi/w4SX5hpzbK6NDUDYmgCP3eQ= github.com/gdamore/tcell v1.4.1/go.mod h1:vxEiSDZdW3L+Uhjii9c3375IlDmR05bzxY404ZVSMo0= +github.com/go-logr/logr v1.2.2/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A= +github.com/go-logr/logr v1.4.1 h1:pKouT5E8xu9zeFC39JXRDukb6JFQPXM5p5I91188VAQ= +github.com/go-logr/logr v1.4.1/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY= +github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag= +github.com/go-logr/stdr v1.2.2/go.mod h1:mMo/vtBO5dYbehREoey6XUKy/eSumjCCveDpRre4VKE= github.com/go-viper/mapstructure/v2 v2.5.0 h1:vM5IJoUAy3d7zRSVtIwQgBj7BiWtMPfmPEgAXnvj1Ro= github.com/go-viper/mapstructure/v2 v2.5.0/go.mod h1:oJDH3BJKyqBA2TXFhDsKDGDTlndYOZ6rGS0BRZIxGhM= +github.com/go-yaml/yaml v2.1.0+incompatible/go.mod h1:w2MrLa16VYP0jy6N7M5kHaCkaLENm+P+Tv+MfurjSw0= +github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q= +github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q= +github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI= +github.com/google/uuid v1.4.0 h1:MtMxsa51/r9yyhkyLsVeVt0B+BGQZzpQiTQ4eHZ8bc4= +github.com/google/uuid v1.4.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= +github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY= +github.com/hashicorp/go-cleanhttp v0.5.2 h1:035FKYIWjmULyFRBKPs8TBQoi0x6d9G4xc9neXJWAZQ= +github.com/hashicorp/go-cleanhttp v0.5.2/go.mod h1:kO/YDlP8L1346E6Sodw+PrpBSV4/SoxCXGY6BqNFT48= +github.com/hashicorp/go-hclog v0.9.2/go.mod h1:5CU+agLiy3J7N7QjHK5d05KxGsuXiQLrjA0H7acj2lQ= +github.com/hashicorp/go-retryablehttp v0.7.5 h1:bJj+Pj19UZMIweq/iie+1u5YCdGrnxCT9yvm0e+Nd5M= +github.com/hashicorp/go-retryablehttp v0.7.5/go.mod h1:Jy/gPYAdjqffZ/yFGCFV2doI5wjtH1ewM9u8iYVjtX8= +github.com/hashicorp/golang-lru v1.0.2 h1:dV3g9Z/unq5DpblPpw+Oqcv4dU/1omnb4Ok8iPY6p1c= +github.com/hashicorp/golang-lru v1.0.2/go.mod h1:iADmTwqILo4mZ8BN3D2Q6+9jd8WM5uGBxy+E8yxSoD4= +github.com/hashicorp/golang-lru/v2 v2.0.7 h1:a+bsQ5rvGLjzHuww6tVxozPZFVghXaHOwFs4luLUK2k= +github.com/hashicorp/golang-lru/v2 v2.0.7/go.mod h1:QeFd9opnmA6QUJc5vARoKUSoFhyfM2/ZepoAG6RGpeM= github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2s0bqwp9tc8= github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw= +github.com/ipfs/bbloom v0.0.4 h1:Gi+8EGJ2y5qiD5FbsbpX/TMNcJw8gSqr7eyjHa4Fhvs= +github.com/ipfs/bbloom v0.0.4/go.mod h1:cS9YprKXpoZ9lT0n/Mw/a6/aFV6DTjTLYHeA+gyqMG0= +github.com/ipfs/go-block-format v0.2.0 h1:ZqrkxBA2ICbDRbK8KJs/u0O3dlp6gmAuuXUJNiW1Ycs= +github.com/ipfs/go-block-format v0.2.0/go.mod h1:+jpL11nFx5A/SPpsoBn6Bzkra/zaArfSmsknbPMYgzM= +github.com/ipfs/go-blockservice v0.5.2 h1:in9Bc+QcXwd1apOVM7Un9t8tixPKdaHQFdLSUM1Xgk8= +github.com/ipfs/go-blockservice v0.5.2/go.mod h1:VpMblFEqG67A/H2sHKAemeH9vlURVavlysbdUI632yk= +github.com/ipfs/go-cid v0.4.1 h1:A/T3qGvxi4kpKWWcPC/PgbvDA2bjVLO7n4UeVwnbs/s= +github.com/ipfs/go-cid v0.4.1/go.mod h1:uQHwDeX4c6CtyrFwdqyhpNcxVewur1M7l7fNU7LKwZk= +github.com/ipfs/go-datastore v0.6.0 h1:JKyz+Gvz1QEZw0LsX1IBn+JFCJQH4SJVFtM4uWU0Myk= +github.com/ipfs/go-datastore v0.6.0/go.mod h1:rt5M3nNbSO/8q1t4LNkLyUwRs8HupMeN/8O4Vn9YAT8= +github.com/ipfs/go-ipfs-blockstore v1.3.1 h1:cEI9ci7V0sRNivqaOr0elDsamxXFxJMMMy7PTTDQNsQ= +github.com/ipfs/go-ipfs-blockstore v1.3.1/go.mod h1:KgtZyc9fq+P2xJUiCAzbRdhhqJHvsw8u2Dlqy2MyRTE= +github.com/ipfs/go-ipfs-ds-help v1.1.1 h1:B5UJOH52IbcfS56+Ul+sv8jnIV10lbjLF5eOO0C66Nw= +github.com/ipfs/go-ipfs-ds-help v1.1.1/go.mod h1:75vrVCkSdSFidJscs8n4W+77AtTpCIAdDGAwjitJMIo= +github.com/ipfs/go-ipfs-exchange-interface v0.2.1 h1:jMzo2VhLKSHbVe+mHNzYgs95n0+t0Q69GQ5WhRDZV/s= +github.com/ipfs/go-ipfs-exchange-interface v0.2.1/go.mod h1:MUsYn6rKbG6CTtsDp+lKJPmVt3ZrCViNyH3rfPGsZ2E= +github.com/ipfs/go-ipfs-util v0.0.3 h1:2RFdGez6bu2ZlZdI+rWfIdbQb1KudQp3VGwPtdNCmE0= +github.com/ipfs/go-ipfs-util v0.0.3/go.mod h1:LHzG1a0Ig4G+iZ26UUOMjHd+lfM84LZCrn17xAKWBvs= +github.com/ipfs/go-ipld-cbor v0.1.0 h1:dx0nS0kILVivGhfWuB6dUpMa/LAwElHPw1yOGYopoYs= +github.com/ipfs/go-ipld-cbor v0.1.0/go.mod h1:U2aYlmVrJr2wsUBU67K4KgepApSZddGRDWBYR0H4sCk= +github.com/ipfs/go-ipld-format v0.6.0 h1:VEJlA2kQ3LqFSIm5Vu6eIlSxD/Ze90xtc4Meten1F5U= +github.com/ipfs/go-ipld-format v0.6.0/go.mod h1:g4QVMTn3marU3qXchwjpKPKgJv+zF+OlaKMyhJ4LHPg= +github.com/ipfs/go-ipld-legacy v0.2.1 h1:mDFtrBpmU7b//LzLSypVrXsD8QxkEWxu5qVxN99/+tk= +github.com/ipfs/go-ipld-legacy v0.2.1/go.mod h1:782MOUghNzMO2DER0FlBR94mllfdCJCkTtDtPM51otM= +github.com/ipfs/go-log v1.0.5 h1:2dOuUCB1Z7uoczMWgAyDck5JLb72zHzrMnGnCNNbvY8= +github.com/ipfs/go-log v1.0.5/go.mod h1:j0b8ZoR+7+R99LD9jZ6+AJsrzkPbSXbZfGakb5JPtIo= +github.com/ipfs/go-log/v2 v2.1.3/go.mod h1:/8d0SH3Su5Ooc31QlL1WysJhvyOTDCjcCZ9Axpmri6g= +github.com/ipfs/go-log/v2 v2.5.1 h1:1XdUzF7048prq4aBjDQQ4SL5RxftpRGdXhNRwKSAlcY= +github.com/ipfs/go-log/v2 v2.5.1/go.mod h1:prSpmC1Gpllc9UYWxDiZDreBYw7zp4Iqp1kOLU9U5UI= +github.com/ipfs/go-merkledag v0.11.0 h1:DgzwK5hprESOzS4O1t/wi6JDpyVQdvm9Bs59N/jqfBY= +github.com/ipfs/go-merkledag v0.11.0/go.mod h1:Q4f/1ezvBiJV0YCIXvt51W/9/kqJGH4I1LsA7+djsM4= +github.com/ipfs/go-metrics-interface v0.0.1 h1:j+cpbjYvu4R8zbleSs36gvB7jR+wsL2fGD6n0jO4kdg= +github.com/ipfs/go-metrics-interface v0.0.1/go.mod h1:6s6euYU4zowdslK0GKHmqaIZ3j/b/tL7HTWtJ4VPgWY= +github.com/ipfs/go-verifcid v0.0.3 h1:gmRKccqhWDocCRkC+a59g5QW7uJw5bpX9HWBevXa0zs= +github.com/ipfs/go-verifcid v0.0.3/go.mod h1:gcCtGniVzelKrbk9ooUSX/pM3xlH73fZZJDzQJRvOUw= +github.com/ipld/go-car v0.6.1-0.20230509095817-92d28eb23ba4 h1:oFo19cBmcP0Cmg3XXbrr0V/c+xU9U1huEZp8+OgBzdI= +github.com/ipld/go-car v0.6.1-0.20230509095817-92d28eb23ba4/go.mod h1:6nkFF8OmR5wLKBzRKi7/YFJpyYR7+oEn1DX+mMWnlLA= +github.com/ipld/go-codec-dagpb v1.6.0 h1:9nYazfyu9B1p3NAgfVdpRco3Fs2nFC72DqVsMj6rOcc= +github.com/ipld/go-codec-dagpb v1.6.0/go.mod h1:ANzFhfP2uMJxRBr8CE+WQWs5UsNa0pYtmKZ+agnUw9s= +github.com/ipld/go-ipld-prime v0.21.0 h1:n4JmcpOlPDIxBcY037SVfpd1G+Sj1nKZah0m6QH9C2E= +github.com/ipld/go-ipld-prime v0.21.0/go.mod h1:3RLqy//ERg/y5oShXXdx5YIp50cFGOanyMctpPjsvxQ= +github.com/jbenet/go-cienv v0.1.0/go.mod h1:TqNnHUmJgXau0nCzC7kXWeotg3J9W34CUv5Djy1+FlA= +github.com/jbenet/goprocess v0.1.4 h1:DRGOFReOMqqDNXwW70QkacFW0YN9QnwLV0Vqk+3oU0o= +github.com/jbenet/goprocess v0.1.4/go.mod h1:5yspPrukOVuOLORacaBi858NqyClJPQxYZlqdZVfqY4= +github.com/jtolds/gls v4.20.0+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfVYBRgL+9YlvaHOwJU= +github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8= +github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= +github.com/klauspost/cpuid/v2 v2.2.7 h1:ZWSB3igEs+d0qvnxR/ZBzXVmxkgt8DdzP6m9pfuVLDM= +github.com/klauspost/cpuid/v2 v2.2.7/go.mod h1:Lcz8mBdAVJIBVzewtcLocK12l3Y+JytZYpaMropDUws= +github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= +github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= +github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= github.com/lucasb-eyer/go-colorful v1.0.3/go.mod h1:R4dSotOR9KMtayYi1e77YzuveK+i7ruzyGqttikkLy0= github.com/lucasb-eyer/go-colorful v1.3.0 h1:2/yBRLdWBZKrf7gB40FoiKfAWYQ0lqNcbuQwVHXptag= github.com/lucasb-eyer/go-colorful v1.3.0/go.mod h1:R4dSotOR9KMtayYi1e77YzuveK+i7ruzyGqttikkLy0= +github.com/mattn/go-isatty v0.0.14/go.mod h1:7GGIvUiUoEMVVmxf/4nioHXj79iQHKdU27kJ6hsGG94= +github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY= +github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y= github.com/mattn/go-runewidth v0.0.7/go.mod h1:H031xJmbD/WCDINGzjvQ9THkh0rPKHF+m2gUSrubnMI= github.com/mattn/go-runewidth v0.0.19 h1:v++JhqYnZuu5jSKrk9RbgF5v4CGUjqRfBm05byFGLdw= github.com/mattn/go-runewidth v0.0.19/go.mod h1:XBkDxAl56ILZc9knddidhrOlY5R/pDhgLpndooCuJAs= +github.com/matttproud/golang_protobuf_extensions/v2 v2.0.0 h1:jWpvCLoY8Z/e3VKvlsiIGKtc+UG6U5vzxaoagmhXfyg= +github.com/matttproud/golang_protobuf_extensions/v2 v2.0.0/go.mod h1:QUyp042oQthUoa9bqDv0ER0wrtXnBruoNd7aNjkbP+k= +github.com/minio/sha256-simd v1.0.1 h1:6kaan5IFmwTNynnKKpDHe6FWHohJOHhCPchzK49dzMM= +github.com/minio/sha256-simd v1.0.1/go.mod h1:Pz6AKMiUdngCLpeTL/RJY1M9rUuPMYujV5xJjtbRSN8= github.com/mitchellh/go-homedir v1.1.0 h1:lukF9ziXFxDFPkA1vsr5zpc1XuPDn/wFntq5mG+4E0Y= github.com/mitchellh/go-homedir v1.1.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0= +github.com/mr-tron/base58 v1.2.0 h1:T/HDJBh4ZCPbU39/+c3rRvE0uKBQlU27+QI8LJ4t64o= +github.com/mr-tron/base58 v1.2.0/go.mod h1:BinMc/sQntlIE1frQmRFPUoPA1Zkr8VRgBdjWI2mNwc= github.com/muesli/go-app-paths v0.2.2 h1:NqG4EEZwNIhBq/pREgfBmgDmt3h1Smr1MjZiXbpZUnI= github.com/muesli/go-app-paths v0.2.2/go.mod h1:SxS3Umca63pcFcLtbjVb+J0oD7cl4ixQWoBKhGEtEho= +github.com/multiformats/go-base32 v0.1.0 h1:pVx9xoSPqEIQG8o+UbAe7DNi51oej1NtK+aGkbLYxPE= +github.com/multiformats/go-base32 v0.1.0/go.mod h1:Kj3tFY6zNr+ABYMqeUNeGvkIC/UYgtWibDcT0rExnbI= +github.com/multiformats/go-base36 v0.2.0 h1:lFsAbNOGeKtuKozrtBsAkSVhv1p9D0/qedU9rQyccr0= +github.com/multiformats/go-base36 v0.2.0/go.mod h1:qvnKE++v+2MWCfePClUEjE78Z7P2a1UV0xHgWc0hkp4= +github.com/multiformats/go-multibase v0.2.0 h1:isdYCVLvksgWlMW9OZRYJEa9pZETFivncJHmHnnd87g= +github.com/multiformats/go-multibase v0.2.0/go.mod h1:bFBZX4lKCA/2lyOFSAoKH5SS6oPyjtnzK/XTFDPkNuk= +github.com/multiformats/go-multihash v0.2.3 h1:7Lyc8XfX/IY2jWb/gI7JP+o7JEq9hOa7BFvVU9RSh+U= +github.com/multiformats/go-multihash v0.2.3/go.mod h1:dXgKXCXjBzdscBLk9JkjINiEsCKRVch90MdaGiKsvSM= +github.com/multiformats/go-varint v0.0.7 h1:sWSGR+f/eu5ABZA2ZpYKBILXTTs9JWpdEM/nEGOHFS8= +github.com/multiformats/go-varint v0.0.7/go.mod h1:r8PUYw/fD/SjBCiKOoDlGF6QawOELpZAu9eioSos/OU= +github.com/opentracing/opentracing-go v1.2.0 h1:uEJPy/1a5RIPAJ0Ov+OIO8OxWu77jEv+1B0VhjKrZUs= +github.com/opentracing/opentracing-go v1.2.0/go.mod h1:GxEUsuufX4nBwe+T+Wl9TAgYrxe9dPLANfrWvHYVTgc= github.com/pelletier/go-toml/v2 v2.2.4 h1:mye9XuhQ6gvn5h28+VilKrrPoQVanw5PMw/TB0t5Ec4= github.com/pelletier/go-toml/v2 v2.2.4/go.mod h1:2gIqNv+qfxSVS7cM2xJQKtLSTLUE9V8t9Stt+h56mCY= +github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= +github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/polydawn/refmt v0.89.1-0.20221221234430-40501e09de1f h1:VXTQfuJj9vKR4TCkEuWIckKvdHFeJH/huIFJ9/cXOB0= +github.com/polydawn/refmt v0.89.1-0.20221221234430-40501e09de1f/go.mod h1:/zvteZs/GwLtCgZ4BL6CBsk9IKIlexP43ObX9AxTqTw= +github.com/prometheus/client_golang v1.17.0 h1:rl2sfwZMtSthVU752MqfjQozy7blglC+1SOtjMAMh+Q= +github.com/prometheus/client_golang v1.17.0/go.mod h1:VeL+gMmOAxkS2IqfCq0ZmHSL+LjWfWDUmp1mBz9JgUY= +github.com/prometheus/client_model v0.5.0 h1:VQw1hfvPvk3Uv6Qf29VrPF32JB6rtbgI6cYPYQjL0Qw= +github.com/prometheus/client_model v0.5.0/go.mod h1:dTiFglRmd66nLR9Pv9f0mZi7B7fk5Pm3gvsjB5tr+kI= +github.com/prometheus/common v0.45.0 h1:2BGz0eBc2hdMDLnO/8n0jeB3oPrt2D08CekT0lneoxM= +github.com/prometheus/common v0.45.0/go.mod h1:YJmSTw9BoKxJplESWWxlbyttQR4uaEcGyv9MZjVOJsY= +github.com/prometheus/procfs v0.12.0 h1:jluTpSng7V9hY0O2R9DzzJHYb2xULk9VTR1V1R/k6Bo= +github.com/prometheus/procfs v0.12.0/go.mod h1:pcuDEFsWDnvcgNzo4EEweacyhjeA9Zk3cnaOZAZEfOo= +github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4= +github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= github.com/sagikazarmark/locafero v0.12.0 h1:/NQhBAkUb4+fH1jivKHWusDYFjMOOKU88eegjfxfHb4= github.com/sagikazarmark/locafero v0.12.0/go.mod h1:sZh36u/YSZ918v0Io+U9ogLYQJ9tLLBmM4eneO6WwsI= +github.com/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc= +github.com/smartystreets/assertions v1.2.0/go.mod h1:tcbTF8ujkAEcZ8TElKY+i30BzYlVhC/LOxJk7iOWnoo= +github.com/smartystreets/goconvey v1.7.2/go.mod h1:Vw0tHAZW6lzCRk3xgdin6fKYcG+G3Pg9vgXWeJpQFMM= github.com/sourcegraph/conc v0.3.1-0.20240121214520-5f936abd7ae8 h1:+jumHNA0Wrelhe64i8F6HNlS8pkoyMv5sreGx2Ry5Rw= github.com/sourcegraph/conc v0.3.1-0.20240121214520-5f936abd7ae8/go.mod h1:3n1Cwaq1E1/1lhQhtRK2ts/ZwZEhjcQeJQ1RuC6Q/8U= +github.com/spaolacci/murmur3 v1.1.0 h1:7c1g84S4BPRrfL5Xrdp6fOJ206sU9y293DDHaoy0bLI= +github.com/spaolacci/murmur3 v1.1.0/go.mod h1:JwIasOWyU6f++ZhiEuf87xNszmSA2myDM2Kzu9HwQUA= github.com/spf13/afero v1.15.0 h1:b/YBCLWAJdFWJTN9cLhiXXcD7mzKn9Dm86dNnfyQw1I= github.com/spf13/afero v1.15.0/go.mod h1:NC2ByUVxtQs4b3sIUphxK0NioZnmxgyCrfzeuq8lxMg= github.com/spf13/cast v1.10.0 h1:h2x0u2shc1QuLHfxi+cTJvs30+ZAHOGRic8uyGTDWxY= @@ -45,29 +173,91 @@ github.com/spf13/pflag v1.0.10 h1:4EBh2KAYBwaONj6b2Ye1GiHfwjqyROoF4RwYO+vPwFk= github.com/spf13/pflag v1.0.10/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg= github.com/spf13/viper v1.21.0 h1:x5S+0EU27Lbphp4UKm1C+1oQO+rKx36vfCoaVebLFSU= github.com/spf13/viper v1.21.0/go.mod h1:P0lhsswPGWD/1lZJ9ny3fYnVqxiegrlNrEmgLjbTCAY= +github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= +github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= +github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= +github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/subosito/gotenv v1.6.0 h1:9NlTDc1FTs4qu0DDq7AEtTPNw6SVm7uBMsUCUjABIf8= github.com/subosito/gotenv v1.6.0/go.mod h1:Dk4QP5c2W3ibzajGcXpNraDfq2IrhjMIvMSWPKKo0FU= +github.com/urfave/cli v1.22.10/go.mod h1:Gos4lmkARVdJ6EkW0WaNv/tZAAMe9V7XWyB60NtXRu0= +github.com/warpfork/go-wish v0.0.0-20220906213052-39a1cc7a02d0/go.mod h1:x6AKhvSSexNrVSrViXSHUEbICjmGXhtgABaHIySUSGw= +github.com/whyrusleeping/cbor-gen v0.2.1-0.20241030202151-b7a6831be65e h1:28X54ciEwwUxyHn9yrZfl5ojgF4CBNLWX7LR0rvBkf4= +github.com/whyrusleeping/cbor-gen v0.2.1-0.20241030202151-b7a6831be65e/go.mod h1:pM99HXyEbSQHcosHc0iW7YFmwnscr+t9Te4ibko05so= +github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= +github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= +github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k= github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY= +gitlab.com/yawning/secp256k1-voi v0.0.0-20230925100816-f2616030848b h1:CzigHMRySiX3drau9C6Q5CAbNIApmLdat5jPMqChvDA= +gitlab.com/yawning/secp256k1-voi v0.0.0-20230925100816-f2616030848b/go.mod h1:/y/V339mxv2sZmYYR64O07VuCpdNZqCTwO8ZcouTMI8= +gitlab.com/yawning/tuplehash v0.0.0-20230713102510-df83abbf9a02 h1:qwDnMxjkyLmAFgcfgTnfJrmYKWhHnci3GjDqcZp1M3Q= +gitlab.com/yawning/tuplehash v0.0.0-20230713102510-df83abbf9a02/go.mod h1:JTnUj0mpYiAsuZLmKjTx/ex3AtMowcCgnE7YNyCEP0I= +go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.46.1 h1:aFJWCqJMNjENlcleuuOkGAPH82y0yULBScfXcIEdS24= +go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.46.1/go.mod h1:sEGXWArGqc3tVa+ekntsN65DmVbVeW+7lTKTjZF3/Fo= +go.opentelemetry.io/otel v1.21.0 h1:hzLeKBZEL7Okw2mGzZ0cc4k/A7Fta0uoPgaJCr8fsFc= +go.opentelemetry.io/otel v1.21.0/go.mod h1:QZzNPQPm1zLX4gZK4cMi+71eaorMSGT3A4znnUvNNEo= +go.opentelemetry.io/otel/metric v1.21.0 h1:tlYWfeo+Bocx5kLEloTjbcDwBuELRrIFxwdQ36PlJu4= +go.opentelemetry.io/otel/metric v1.21.0/go.mod h1:o1p3CA8nNHW8j5yuQLdc1eeqEaPfzug24uvsyIEJRWM= +go.opentelemetry.io/otel/trace v1.21.0 h1:WD9i5gzvoUPuXIXH24ZNBudiarZDKuekPqi/E8fpfLc= +go.opentelemetry.io/otel/trace v1.21.0/go.mod h1:LGbsEB0f9LGjN+OZaQQ26sohbOmiMR+BaslueVtS/qQ= +go.uber.org/atomic v1.6.0/go.mod h1:sABNBOSYdrvTF6hTgEIbc7YasKWGhgEQZyfxyTvoXHQ= +go.uber.org/atomic v1.7.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc= +go.uber.org/atomic v1.11.0 h1:ZvwS0R+56ePWxUNi+Atn9dWONBPp/AUETXlHW0DxSjE= +go.uber.org/atomic v1.11.0/go.mod h1:LUxbIzbOniOlMKjJjyPfpl4v+PKK2cNJn91OQbhoJI0= +go.uber.org/goleak v1.1.11-0.20210813005559-691160354723/go.mod h1:cwTWslyiVhfpKIDGSZEM2HlOvcqm+tG4zioyIeLoqMQ= +go.uber.org/multierr v1.5.0/go.mod h1:FeouvMocqHpRaaGuG9EjoKcStLC43Zu/fmqdUMPcKYU= +go.uber.org/multierr v1.6.0/go.mod h1:cdWPpRnG4AhwMwsgIHip0KRBQjJy5kYEpYjJxpXp9iU= +go.uber.org/multierr v1.11.0 h1:blXXJkSxSSfBVBlC76pxqeO+LN3aDfLQo+309xJstO0= +go.uber.org/multierr v1.11.0/go.mod h1:20+QtiLqy0Nd6FdQB9TLXag12DsQkrbs3htMFfDN80Y= +go.uber.org/tools v0.0.0-20190618225709-2cfd321de3ee/go.mod h1:vJERXedbb3MVM5f9Ejo0C68/HhF8uaILCdgjnY+goOA= +go.uber.org/zap v1.16.0/go.mod h1:MA8QOfq0BHJwdXa996Y4dYkAqRKB8/1K1QMMZVaNZjQ= +go.uber.org/zap v1.19.1/go.mod h1:j3DNczoxDZroyBnOT1L/Q79cfUMGZxlv/9dzN7SM1rI= +go.uber.org/zap v1.26.0 h1:sI7k6L95XOKS281NhVKOFCUNIvv9e0w4BF8N3u+tCRo= +go.uber.org/zap v1.26.0/go.mod h1:dtElttAiwGvoJ/vj4IwHBS/gXsEu/pZ50mUIRWuG0so= go.yaml.in/yaml/v3 v3.0.4 h1:tfq32ie2Jv2UxXFdLJdh3jXuOzWiL1fo0bu/FbuKpbc= go.yaml.in/yaml/v3 v3.0.4/go.mod h1:DhzuOOF2ATzADvBadXxruRBLzYTpT36CKvDb3+aBEFg= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= +golang.org/x/crypto v0.0.0-20190510104115-cbcb75029529/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= +golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= +golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= +golang.org/x/crypto v0.21.0 h1:X31++rzVUdKhX5sWmSOFZxx8UW/ldWx55cbf08iNAMA= +golang.org/x/crypto v0.21.0/go.mod h1:0BP7YvVV9gBbVKyeTG0Gyn+gZm94bibOW5BjDEYAOMs= +golang.org/x/lint v0.0.0-20190930215403-16217165b5de/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= +golang.org/x/mod v0.0.0-20190513183733-4bf6d317e70e/go.mod h1:mXi4GBBbnImb6dmsKGUJ2LatrhH/nqhxcFungHvyanc= +golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= +golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= +golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4= golang.org/x/mod v0.8.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= +golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= +golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= +golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM= golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= golang.org/x/net v0.6.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs= golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190626150813-e07cf5db2756/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210330210617-4fbd30eecc44/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210510120138-977fb7262007/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= 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.40.0 h1:DBZZqJ2Rkml6QMQsZywtnjnnGvHza6BTfYFWY9kjEWQ= golang.org/x/sys v0.40.0/go.mod h1:OgkHotnGiDImocRcuBABYBEXf8A9a87e/uXjp9XT3ks= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= @@ -80,9 +270,35 @@ golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU= golang.org/x/text v0.33.0 h1:B3njUFyqtHDUI5jMn1YIr5B0IE2U0qck04r6d4KPAxE= golang.org/x/text v0.33.0/go.mod h1:LuMebE6+rBincTi9+xWTY8TztLzKHc/9C1uBCG27+q8= +golang.org/x/time v0.3.0 h1:rg5rLMjNzMS1RkNLzCG38eapWhnYLFYXDXj2gOlr8j4= +golang.org/x/time v0.3.0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= +golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= +golang.org/x/tools v0.0.0-20190328211700-ab21143f2384/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= +golang.org/x/tools v0.0.0-20190621195816-6e04913cbbac/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= +golang.org/x/tools v0.0.0-20191029041327-9cc4af7d6b2c/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.0.0-20191029190741-b9c20aec41a5/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.0.0-20200619180055-7c47624df98f/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= +golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= +golang.org/x/tools v0.1.5/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc= golang.org/x/tools v0.6.0/go.mod h1:Xwgl3UAJ/d3gWutnCtw505GrjyAbvKui8lOU390QaIU= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +golang.org/x/xerrors v0.0.0-20231012003039-104605ab7028 h1:+cNy6SZtPcJQH3LJVLOSmiC7MMxXNOb3PU/VUEz+EhU= +golang.org/x/xerrors v0.0.0-20231012003039-104605ab7028/go.mod h1:NDW/Ps6MPRej6fsCIbMTohpP40sJ/P/vI1MoTEGwX90= +google.golang.org/protobuf v1.33.0 h1:uNO2rsAINq/JlFpSdYEKIZ0uKD/R9cpdv0T+yoGwGmI= +google.golang.org/protobuf v1.33.0/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI= +gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= +gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= +honnef.co/go/tools v0.0.1-2019.2.3/go.mod h1:a3bituU0lyd329TUQxRnasdCoJDkEUEAqEt0JzvZhAg= +lukechampine.com/blake3 v1.2.1 h1:YuqqRuaqsGV71BV/nm9xlI0MKUv4QC54jQnBChWbGnI= +lukechampine.com/blake3 v1.2.1/go.mod h1:0OFRp7fBtAylGVCO40o87sbupkyIGgbpv1+M1k1LM6k= diff --git a/helpers/helpers.go b/helpers/helpers.go new file mode 100644 index 0000000..f454c60 --- /dev/null +++ b/helpers/helpers.go @@ -0,0 +1,33 @@ +/* +Copyright © Brian Buller + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. +*/ +package helpers + +import ( + "os" + "strings" +) + +var Sep = string(os.PathSeparator) + +func Path(parts ...string) string { + return strings.Join(parts, Sep) +} diff --git a/widgets/json_content.go b/widgets/json_content.go index 4cbc5da..3421169 100644 --- a/widgets/json_content.go +++ b/widgets/json_content.go @@ -22,6 +22,8 @@ THE SOFTWARE. package widgets import ( + "encoding/json" + "fmt" "strings" wd "git.bullercodeworks.com/brian/tcell-widgets" @@ -31,18 +33,19 @@ import ( // TODO: Format contents as json. For now this is a duplice of the Text widget type JsonContent struct { - id string - text string - contents []string - style tcell.Style - x, y int - w, h int - visible bool - active bool - focusable bool - keyMap *wd.KeyMap + id string - flags wd.LayoutFlag + valueString string + contents []string + style tcell.Style + x, y int + w, h int + visible bool + active bool + focusable bool + keyMap *wd.KeyMap + + value any } var _ wd.Widget = (*JsonContent)(nil) @@ -102,17 +105,28 @@ func (w *JsonContent) SetFocusable(b bool) { w.focusable = b } func (w *JsonContent) MinW() int { return wh.Longest(w.contents) } func (w *JsonContent) MinH() int { return len(w.contents) } -func (w *JsonContent) SetJsonContent(txt string) { - w.text = txt - if strings.Contains(w.text, "\n") { - w.contents = strings.Split(w.text, "\n") - } else { - w.contents = []string{w.text} +func (w *JsonContent) SetValue(v any) error { + w.value = v + // Go ahead and try to build the json for v + bts, err := json.MarshalIndent(v, "", " ") + if err != nil { + return fmt.Errorf("error unmarshalling value: %w", err) } + w.valueString = string(bts) + w.contents = strings.Split(w.valueString, "\n") + return nil } -func (w *JsonContent) GetJsonContent() string { return w.text } -func (w *JsonContent) GetContents() []string { return w.contents } +/* + func (w *JsonContent) SetJsonContent(txt string) { + w.text = txt + if strings.Contains(w.text, "\n") { + w.contents = strings.Split(w.text, "\n") + } else { + w.contents = []string{w.text} + } + } -func (w *JsonContent) AddFlag(f wd.LayoutFlag) { w.flags.Add(f) } -func (w *JsonContent) RemoveFlag(f wd.LayoutFlag) { w.flags.Remove(f) } +func (w *JsonContent) GetJsonContent() string { return w.text } +func (w *JsonContent) GetContents() []string { return w.contents } +*/ diff --git a/widgets/status_bar.go b/widgets/status_bar.go new file mode 100644 index 0000000..1d93ee6 --- /dev/null +++ b/widgets/status_bar.go @@ -0,0 +1,95 @@ +/* +Copyright © Brian Buller + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. +*/ +package widgets + +import ( + t "git.bullercodeworks.com/brian/tcell-widgets" + "github.com/gdamore/tcell" +) + +type StatusBar struct { + id string + style tcell.Style + x, y int + w, h int + visible bool + keyMap *t.KeyMap + + logger func(string, ...any) +} + +func NewStatusBar(id string, s tcell.Style) *StatusBar { + ret := &StatusBar{} + ret.Init(id, s) + return ret +} + +func (w *StatusBar) Init(id string, s tcell.Style) { + w.id = id + w.style = s + w.visible = true +} + +func (w *StatusBar) Id() string { return w.id } +func (w *StatusBar) HandleResize(ev *tcell.EventResize) { + w.w, w.h = ev.Size() +} + +func (w *StatusBar) GetKeyMap() *t.KeyMap { return w.keyMap } +func (w *StatusBar) SetKeyMap(km *t.KeyMap) { w.keyMap = km } + +func (w *StatusBar) HandleKey(ev *tcell.EventKey) bool { + return false +} + +func (w *StatusBar) HandleTime(ev *tcell.EventTime) {} + +func (w *StatusBar) Draw(screen tcell.Screen) { + if !w.visible { + return + } +} + +func (w *StatusBar) Active() bool { return false } +func (w *StatusBar) SetActive(a bool) {} +func (w *StatusBar) Visible() bool { return w.visible } +func (w *StatusBar) SetVisible(a bool) { w.visible = a } +func (w *StatusBar) Focusable() bool { return false } +func (w *StatusBar) SetFocusable(b bool) {} +func (w *StatusBar) SetX(x int) { w.x = x } +func (w *StatusBar) SetY(y int) { w.y = y } +func (w *StatusBar) GetX() int { return w.x } +func (w *StatusBar) GetY() int { return w.y } +func (w *StatusBar) GetPos() t.Coord { return t.Coord{X: w.x, Y: w.y} } +func (w *StatusBar) SetPos(c t.Coord) { w.x, w.y = c.X, c.Y } +func (w *StatusBar) GetW() int { return w.w } +func (w *StatusBar) GetH() int { return w.h } +func (w *StatusBar) SetW(wd int) { w.w = wd } +func (w *StatusBar) SetH(h int) { w.h = h } +func (w *StatusBar) SetSize(c t.Coord) { w.w, w.h = c.X, c.Y } +func (w *StatusBar) WantW() int { return w.w } +func (w *StatusBar) WantH() int { return w.h } +func (w *StatusBar) MinW() int { return w.w } +func (w *StatusBar) MinH() int { return 1 } + +func (w *StatusBar) SetLogger(l func(string, ...any)) { w.logger = l } +func (w *StatusBar) Log(txt string, args ...any) { w.logger(txt, args...) }