From 62044abc7a001717ca0869f7923add9c2bdd363e Mon Sep 17 00:00:00 2001 From: Mohsen Mirzakhani Date: Mon, 5 Aug 2024 20:11:37 +0300 Subject: [PATCH] Editor with highlighting pattern. (#65) --- go.mod | 14 +- go.sum | 28 +- ui/pages/requests/component/address_bar.go | 33 +- ui/pages/requests/component/form.go | 25 +- .../requests/component/pre_post_request.go | 85 ++- ui/pages/requests/grpc/address_bar.go | 33 +- ui/widgets/code_editor.go | 18 +- ui/widgets/keyvalue.go | 39 +- ui/widgets/labeled_input.go | 27 +- ui/widgets/pattern_editor.go | 133 ++++ vendor/gioui.org/app/app.go | 4 + vendor/gioui.org/app/gl_macos.m | 2 +- vendor/gioui.org/app/metal_macos.go | 4 +- vendor/gioui.org/app/os.go | 12 +- vendor/gioui.org/app/os_android.go | 3 + vendor/gioui.org/app/os_ios.go | 3 + vendor/gioui.org/app/os_js.go | 3 + vendor/gioui.org/app/os_macos.go | 17 +- vendor/gioui.org/app/os_macos.m | 8 +- vendor/gioui.org/app/os_unix.go | 30 +- vendor/gioui.org/app/os_wayland.go | 26 +- vendor/gioui.org/app/os_windows.go | 15 +- vendor/gioui.org/app/os_x11.go | 10 - vendor/gioui.org/app/window.go | 85 ++- vendor/gioui.org/io/input/router.go | 51 +- .../gioui.org/x/explorer/explorer_windows.go | 67 +- vendor/gioui.org/x/richtext/README.md | 3 - vendor/gioui.org/x/richtext/richtext.go | 270 -------- vendor/gioui.org/x/styledtext/README.md | 3 - vendor/gioui.org/x/styledtext/iterator.go | 152 ----- vendor/gioui.org/x/styledtext/styledtext.go | 306 --------- .../github.com/oligo/gioview/editor/buffer.go | 25 +- .../github.com/oligo/gioview/editor/editor.go | 152 ++++- .../oligo/gioview/editor/editor_style.go | 150 ++++- .../github.com/oligo/gioview/editor/index.go | 4 - .../github.com/oligo/gioview/editor/text.go | 221 +++++- .../oligo/gioview/editor/text_iterator.go | 8 +- vendor/github.com/oligo/gioview/misc/base.go | 79 +++ vendor/github.com/oligo/gioview/misc/color.go | 67 ++ .../github.com/oligo/gioview/misc/divider.go | 53 ++ .../github.com/oligo/gioview/theme/fonts.go | 95 +++ .../github.com/oligo/gioview/theme/theme.go | 124 ++++ .../golang.org/x/net/http/httpguts/httplex.go | 13 +- vendor/golang.org/x/net/http2/frame.go | 40 +- vendor/golang.org/x/net/http2/pipe.go | 11 +- vendor/golang.org/x/net/http2/server.go | 24 +- vendor/golang.org/x/net/http2/testsync.go | 331 +++++++++ vendor/golang.org/x/net/http2/transport.go | 313 +++++++-- .../googleapis/rpc/status/status.pb.go | 4 +- vendor/google.golang.org/grpc/README.md | 2 +- .../{ => balancer/pickfirst}/pickfirst.go | 32 +- .../grpc/balancer/roundrobin/roundrobin.go | 4 +- .../grpc/balancer_wrapper.go | 4 + .../grpc_binarylog_v1/binarylog.pb.go | 2 +- vendor/google.golang.org/grpc/clientconn.go | 66 +- .../google.golang.org/grpc/credentials/tls.go | 34 +- vendor/google.golang.org/grpc/dialoptions.go | 46 ++ .../grpc/internal/backoff/backoff.go | 4 +- .../grpc/internal/envconfig/envconfig.go | 6 + .../grpc/internal/grpcrand/grpcrand.go | 100 --- .../grpc/internal/grpcrand/grpcrand_go1.21.go | 73 -- .../grpc/internal/internal.go | 37 +- .../internal/resolver/dns/dns_resolver.go | 14 +- .../resolver/dns/internal/internal.go | 13 +- .../grpc/internal/transport/http2_server.go | 4 +- .../grpc/metadata/metadata.go | 15 - .../google.golang.org/grpc/picker_wrapper.go | 81 ++- .../grpc_reflection_v1/reflection.pb.go | 2 +- .../grpc_reflection_v1/reflection_grpc.pb.go | 2 +- .../grpc_reflection_v1alpha/reflection.pb.go | 2 +- .../reflection_grpc.pb.go | 2 +- .../grpc/resolver_wrapper.go | 2 +- .../google.golang.org/grpc/service_config.go | 24 +- vendor/google.golang.org/grpc/stream.go | 4 +- vendor/google.golang.org/grpc/version.go | 2 +- .../protobuf/encoding/protojson/encode.go | 20 +- .../protobuf/encoding/prototext/encode.go | 20 +- .../editiondefaults/editions_defaults.binpb | Bin 78 -> 93 bytes .../protobuf/internal/errors/errors.go | 15 + .../protobuf/internal/filedesc/desc.go | 19 +- .../protobuf/internal/filedesc/desc_init.go | 21 +- .../internal/filedesc/desc_list_gen.go | 11 + .../protobuf/internal/filedesc/editions.go | 4 +- .../protobuf/internal/genid/descriptor_gen.go | 46 +- .../internal/genid/go_features_gen.go | 2 +- .../protobuf/internal/impl/codec_field.go | 64 +- .../protobuf/internal/impl/codec_map.go | 15 +- .../protobuf/internal/impl/legacy_file.go | 4 +- .../protobuf/internal/version/version.go | 6 +- .../protobuf/proto/encode.go | 37 +- .../protobuf/proto/messageset.go | 7 +- .../google.golang.org/protobuf/proto/size.go | 2 + .../protobuf/reflect/protodesc/desc_init.go | 1 + .../protobuf/reflect/protodesc/editions.go | 6 +- .../reflect/protoreflect/source_gen.go | 19 + .../types/descriptorpb/descriptor.pb.go | 636 +++++++++++------- .../types/gofeaturespb/go_features.pb.go | 122 ++-- .../types/gofeaturespb/go_features.proto | 28 - vendor/modules.txt | 24 +- 99 files changed, 2993 insertions(+), 1936 deletions(-) create mode 100644 ui/widgets/pattern_editor.go delete mode 100644 vendor/gioui.org/x/richtext/README.md delete mode 100644 vendor/gioui.org/x/richtext/richtext.go delete mode 100644 vendor/gioui.org/x/styledtext/README.md delete mode 100644 vendor/gioui.org/x/styledtext/iterator.go delete mode 100644 vendor/gioui.org/x/styledtext/styledtext.go create mode 100644 vendor/github.com/oligo/gioview/misc/base.go create mode 100644 vendor/github.com/oligo/gioview/misc/color.go create mode 100644 vendor/github.com/oligo/gioview/misc/divider.go create mode 100644 vendor/github.com/oligo/gioview/theme/fonts.go create mode 100644 vendor/github.com/oligo/gioview/theme/theme.go create mode 100644 vendor/golang.org/x/net/http2/testsync.go rename vendor/google.golang.org/grpc/{ => balancer/pickfirst}/pickfirst.go (89%) delete mode 100644 vendor/google.golang.org/grpc/internal/grpcrand/grpcrand.go delete mode 100644 vendor/google.golang.org/grpc/internal/grpcrand/grpcrand_go1.21.go delete mode 100644 vendor/google.golang.org/protobuf/types/gofeaturespb/go_features.proto diff --git a/go.mod b/go.mod index 5e609733..006f7851 100644 --- a/go.mod +++ b/go.mod @@ -3,17 +3,17 @@ module github.com/chapar-rest/chapar go 1.22.1 require ( - gioui.org v0.7.0 - gioui.org/x v0.7.0 + gioui.org v0.7.1 + gioui.org/x v0.7.1 github.com/PaesslerAG/jsonpath v0.1.1 github.com/alecthomas/chroma/v2 v2.14.0 github.com/dustin/go-humanize v1.0.1 github.com/google/uuid v1.6.0 github.com/jhump/protoreflect v1.16.0 - github.com/oligo/gioview v0.4.1-0.20240715092046-997b87ed0255 + github.com/oligo/gioview v0.5.1-0.20240805165652-db7ac64b4905 golang.org/x/exp/shiny v0.0.0-20240707233637-46b078467d37 - google.golang.org/grpc v1.64.0 - google.golang.org/protobuf v1.33.1-0.20240408130810-98873a205002 + google.golang.org/grpc v1.65.0 + google.golang.org/protobuf v1.34.1 gopkg.in/yaml.v2 v2.4.0 ) @@ -30,9 +30,9 @@ require ( github.com/shopspring/decimal v1.3.1 // indirect golang.org/x/exp v0.0.0-20240707233637-46b078467d37 // indirect golang.org/x/image v0.18.0 // indirect - golang.org/x/net v0.22.0 // indirect + golang.org/x/net v0.25.0 // indirect golang.org/x/sync v0.7.0 // indirect golang.org/x/sys v0.22.0 // indirect golang.org/x/text v0.16.0 // indirect - google.golang.org/genproto/googleapis/rpc v0.0.0-20240318140521-94a12d6c2237 // indirect + google.golang.org/genproto/googleapis/rpc v0.0.0-20240528184218-531527333157 // indirect ) diff --git a/go.sum b/go.sum index b5b83cd2..61407b2e 100644 --- a/go.sum +++ b/go.sum @@ -1,14 +1,14 @@ eliasnaur.com/font v0.0.0-20230308162249-dd43949cb42d h1:ARo7NCVvN2NdhLlJE9xAbKweuI9L6UgfTbYb0YwPacY= eliasnaur.com/font v0.0.0-20230308162249-dd43949cb42d/go.mod h1:OYVuxibdk9OSLX8vAqydtRPP87PyTFcT9uH3MlEGBQA= -gioui.org v0.7.0 h1:5I+7Uu2yjTu7W5p7HWQrgsDPO3vex+8T1DsvCLGBfuI= -gioui.org v0.7.0/go.mod h1:19wZxaNP+eHN4H2YdZwEfbkAAgoYB5rcIbDHo4BqUl4= +gioui.org v0.7.1 h1:l7OVj47n1z8acaszQ6Wlu+Rxme+HqF3q8b+Fs68+x3w= +gioui.org v0.7.1/go.mod h1:5Kw/q7R1BWc5MKStuTNvhCgSrRqbfHc9Dzfjs4IGgZo= gioui.org/cpu v0.0.0-20210808092351-bfe733dd3334/go.mod h1:A8M0Cn5o+vY5LTMlnRoK3O5kG+rH0kWfJjeKd9QpBmQ= gioui.org/cpu v0.0.0-20220412190645-f1e9e8c3b1f7 h1:tNJdnP5CgM39PRc+KWmBRRYX/zJ+rd5XaYxY5d5veqA= gioui.org/cpu v0.0.0-20220412190645-f1e9e8c3b1f7/go.mod h1:A8M0Cn5o+vY5LTMlnRoK3O5kG+rH0kWfJjeKd9QpBmQ= gioui.org/shader v1.0.8 h1:6ks0o/A+b0ne7RzEqRZK5f4Gboz2CfG+mVliciy6+qA= gioui.org/shader v1.0.8/go.mod h1:mWdiME581d/kV7/iEhLmUgUK5iZ09XR5XpduXzbePVM= -gioui.org/x v0.7.0 h1:8rkLfy4MAHM+MgEv8IUwRcmB9rxJqYnRzbuOJqXzG6Y= -gioui.org/x v0.7.0/go.mod h1:zJdmUbD5PuGHL8fzX0kehLTZ6TmIvfo6mg10sW54dsU= +gioui.org/x v0.7.1 h1:7bnQHsV7qB36tIUit2WDcUx4Cnmo+6T9I38B9brLQ7o= +gioui.org/x v0.7.1/go.mod h1:5CzZ64oFpOaqb2kaMvj+QEr5T3nVuLKD0LizLH32ii0= git.wow.st/gmp/jni v0.0.0-20210610011705-34026c7e22d0 h1:bGG/g4ypjrCJoSvFrP5hafr9PPB5aw8SjcOWWila7ZI= git.wow.st/gmp/jni v0.0.0-20210610011705-34026c7e22d0/go.mod h1:+axXBRUTIDlCeE73IKeD/os7LoEnTKdkp8/gQOFjqyo= github.com/PaesslerAG/gval v1.0.0/go.mod h1:y/nm5yEyTeX6av0OfKJNp9rBNj2XrGhAf5+v24IBN1I= @@ -47,8 +47,8 @@ github.com/hexops/gotextdiff v1.0.3 h1:gitA9+qJrrTCsiCl7+kh75nPqQt1cx4ZkudSTLoUq github.com/hexops/gotextdiff v1.0.3/go.mod h1:pSWU5MAI3yDq+fZBTazCSJysOMbxWL1BSow5/V2vxeg= github.com/jhump/protoreflect v1.16.0 h1:54fZg+49widqXYQ0b+usAFHbMkBGR4PpXrsHc8+TBDg= github.com/jhump/protoreflect v1.16.0/go.mod h1:oYPd7nPvcBw/5wlDfm/AVmU9zH9BgqGCI469pGxfj/8= -github.com/oligo/gioview v0.4.1-0.20240715092046-997b87ed0255 h1:ao+r5gHJoc+A0CA0fAXFyc/RURb8lvIeWuuRHj70QKY= -github.com/oligo/gioview v0.4.1-0.20240715092046-997b87ed0255/go.mod h1:WEa28vrpnPfZnhYL14tAWdsM4kvcW7NUlYLTE/Xbefo= +github.com/oligo/gioview v0.5.1-0.20240805165652-db7ac64b4905 h1:iBiM6OWNacjpEy5qwflkvZC5pp6XJ3Fz5azIdEO7tmE= +github.com/oligo/gioview v0.5.1-0.20240805165652-db7ac64b4905/go.mod h1:5wxSoxxJ7FOVPnEYhqlUrT451rOmL8DQZCTeVlbVkoY= 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/shopspring/decimal v1.3.1 h1:2Usl1nmF/WZucqkFZhnfFYxxxu8LG21F6nPQBE5gKV8= @@ -61,20 +61,20 @@ golang.org/x/exp/shiny v0.0.0-20240707233637-46b078467d37 h1:SOSg7+sueresE4IbmmG golang.org/x/exp/shiny v0.0.0-20240707233637-46b078467d37/go.mod h1:3F+MieQB7dRYLTmnncoFbb1crS5lfQoTfDgQy6K4N0o= golang.org/x/image v0.18.0 h1:jGzIakQa/ZXI1I0Fxvaa9W7yP25TqT6cHIHn+6CqvSQ= golang.org/x/image v0.18.0/go.mod h1:4yyo5vMFQjVjUcVk4jEQcU9MGy/rulF5WvUILseCM2E= -golang.org/x/net v0.22.0 h1:9sGLhx7iRIHEiX0oAJ3MRZMUCElJgy7Br1nO+AMN3Tc= -golang.org/x/net v0.22.0/go.mod h1:JKghWKKOSdJwpW2GEx0Ja7fmaKnMsbu+MWVZTokSYmg= +golang.org/x/net v0.25.0 h1:d/OCCoBEUq33pjydKrGQhw7IlUPI2Oylr+8qLx49kac= +golang.org/x/net v0.25.0/go.mod h1:JkAGAh7GEvH74S6FOH42FLoXpXbE/aqXSrIQjXgsiwM= golang.org/x/sync v0.7.0 h1:YsImfSBoP9QPYL0xyKJPq0gcaJdG3rInoqxTWbfQu9M= golang.org/x/sync v0.7.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= golang.org/x/sys v0.22.0 h1:RI27ohtqKCnwULzJLqkv897zojh5/DwS/ENaMzUOaWI= golang.org/x/sys v0.22.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/text v0.16.0 h1:a94ExnEXNtEwYLGJSIUxnWoxoRz/ZcCsV63ROupILh4= golang.org/x/text v0.16.0/go.mod h1:GhwF1Be+LQoKShO3cGOHzqOgRrGaYc9AvblQOmPVHnI= -google.golang.org/genproto/googleapis/rpc v0.0.0-20240318140521-94a12d6c2237 h1:NnYq6UN9ReLM9/Y01KWNOWyI5xQ9kbIms5GGJVwS/Yc= -google.golang.org/genproto/googleapis/rpc v0.0.0-20240318140521-94a12d6c2237/go.mod h1:WtryC6hu0hhx87FDGxWCDptyssuo68sk10vYjF+T9fY= -google.golang.org/grpc v1.64.0 h1:KH3VH9y/MgNQg1dE7b3XfVK0GsPSIzJwdF617gUSbvY= -google.golang.org/grpc v1.64.0/go.mod h1:oxjF8E3FBnjp+/gVFYdWacaLDx9na1aqy9oovLpxQYg= -google.golang.org/protobuf v1.33.1-0.20240408130810-98873a205002 h1:V7Da7qt0MkY3noVANIMVBk28nOnijADeOR3i5Hcvpj4= -google.golang.org/protobuf v1.33.1-0.20240408130810-98873a205002/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos= +google.golang.org/genproto/googleapis/rpc v0.0.0-20240528184218-531527333157 h1:Zy9XzmMEflZ/MAaA7vNcoebnRAld7FsPW1EeBB7V0m8= +google.golang.org/genproto/googleapis/rpc v0.0.0-20240528184218-531527333157/go.mod h1:EfXuqaE1J41VCDicxHzUDm+8rk+7ZdXzHV0IhO/I6s0= +google.golang.org/grpc v1.65.0 h1:bs/cUb4lp1G5iImFFd3u5ixQzweKizoZJAwBNLR42lc= +google.golang.org/grpc v1.65.0/go.mod h1:WgYC2ypjlB0EiQi6wdKixMqukr6lBc0Vo+oOgjrM5ZQ= +google.golang.org/protobuf v1.34.1 h1:9ddQBjfCyZPOHPUiPxpYESBLc+T8P3E+Vo4IbKZgFWg= +google.golang.org/protobuf v1.34.1/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY= diff --git a/ui/pages/requests/component/address_bar.go b/ui/pages/requests/component/address_bar.go index 98c6ba63..905f1afe 100644 --- a/ui/pages/requests/component/address_bar.go +++ b/ui/pages/requests/component/address_bar.go @@ -13,7 +13,7 @@ import ( ) type AddressBar struct { - url *widget.Editor + url *widgets.PatternEditor lastSelectedMethod string methodDropDown *widgets.DropDown @@ -27,7 +27,7 @@ type AddressBar struct { func NewAddressBar(theme *chapartheme.Theme, address, method string) *AddressBar { a := &AddressBar{ - url: &widget.Editor{}, + url: widgets.NewPatternEditor(), methodDropDown: widgets.NewDropDownWithoutBorder(theme), lastSelectedMethod: method, } @@ -55,6 +55,7 @@ func (a *AddressBar) SetSelectedMethod(method string) { func (a *AddressBar) SetOnURLChanged(onURLChanged func(url string)) { a.onURLChanged = onURLChanged + a.url.SetOnChanged(onURLChanged) } func (a *AddressBar) SetOnMethodChanged(onMethodChanged func(method string)) { @@ -66,6 +67,7 @@ func (a *AddressBar) SetOnMethodChanged(onMethodChanged func(method string)) { func (a *AddressBar) SetOnSubmit(onSubmit func()) { a.onSubmit = onSubmit + a.url.SetOnSubmit(onSubmit) } func (a *AddressBar) SetURL(url string) { @@ -84,27 +86,6 @@ func (a *AddressBar) Layout(gtx layout.Context, theme *chapartheme.Theme) layout CornerRadius: unit.Dp(4), } - for { - event, ok := a.url.Update(gtx) - if !ok { - break - } - - switch event.(type) { - // on carriage return event - case widget.SubmitEvent: - if a.onSubmit != nil { - // goroutine to prevent blocking the ui update - go a.onSubmit() - } - // on change event - case widget.ChangeEvent: - if a.onURLChanged != nil { - a.onURLChanged(a.url.Text()) - } - } - } - if a.methodDropDown.GetSelected().Text != a.lastSelectedMethod { a.lastSelectedMethod = a.methodDropDown.GetSelected().Text if a.onMethodChanged != nil { @@ -131,11 +112,7 @@ func (a *AddressBar) Layout(gtx layout.Context, theme *chapartheme.Theme) layout widgets.DrawLineFlex(theme.SeparatorColor, unit.Dp(20), unit.Dp(1)), layout.Flexed(1, func(gtx layout.Context) layout.Dimensions { return layout.Inset{Left: unit.Dp(10), Right: unit.Dp(5)}.Layout(gtx, func(gtx layout.Context) layout.Dimensions { - gtx.Constraints.Min.Y = gtx.Dp(20) - editor := material.Editor(theme.Material(), a.url, "https://example.com") - editor.SelectionColor = theme.TextSelectionColor - editor.TextSize = unit.Sp(14) - return editor.Layout(gtx) + return a.url.Layout(gtx, theme, "https://example.com") }) }), ) diff --git a/ui/pages/requests/component/form.go b/ui/pages/requests/component/form.go index e627a3b7..185c8b67 100644 --- a/ui/pages/requests/component/form.go +++ b/ui/pages/requests/component/form.go @@ -3,10 +3,8 @@ package component import ( "gioui.org/layout" "gioui.org/unit" - "gioui.org/widget" "github.com/chapar-rest/chapar/ui/chapartheme" - "github.com/chapar-rest/chapar/ui/keys" "github.com/chapar-rest/chapar/ui/widgets" ) @@ -20,7 +18,7 @@ type Field struct { Label string Value string - Editor *widget.Editor + Editor *widgets.PatternEditor } func NewForm(fields []*Field) *Form { @@ -37,7 +35,8 @@ func (f *Form) GetValues() map[string]string { values := make(map[string]string) for _, field := range f.Fields { if field.Editor == nil { - field.Editor = new(widget.Editor) + field.Editor = widgets.NewPatternEditor() + field.Editor.SetOnChanged(f.onDataChange) } values[field.Label] = field.Editor.Text() @@ -45,10 +44,17 @@ func (f *Form) GetValues() map[string]string { return values } +func (f *Form) onDataChange(_ string) { + if f.onChange != nil { + f.onChange(f.GetValues()) + } +} + func (f *Form) SetValues(values map[string]string) { for _, field := range f.Fields { if field.Editor == nil { - field.Editor = new(widget.Editor) + field.Editor = widgets.NewPatternEditor() + field.Editor.SetOnChanged(f.onDataChange) } field.Editor.SetText(values[field.Label]) @@ -61,15 +67,10 @@ func (f *Form) Layout(gtx layout.Context, theme *chapartheme.Theme) layout.Dimen field := field childs = append(childs, layout.Rigid(func(gtx layout.Context) layout.Dimensions { if field.Editor == nil { - field.Editor = new(widget.Editor) + field.Editor = widgets.NewPatternEditor() + field.Editor.SetOnChanged(f.onDataChange) } - keys.OnEditorChange(gtx, field.Editor, func() { - if f.onChange != nil { - f.onChange(f.GetValues()) - } - }) - lb := &widgets.LabeledInput{ Label: field.Label, SpaceBetween: 5, diff --git a/ui/pages/requests/component/pre_post_request.go b/ui/pages/requests/component/pre_post_request.go index 42f617ed..3cf3bad4 100644 --- a/ui/pages/requests/component/pre_post_request.go +++ b/ui/pages/requests/component/pre_post_request.go @@ -5,12 +5,10 @@ import ( "gioui.org/layout" "gioui.org/unit" - "gioui.org/widget" "gioui.org/widget/material" "github.com/chapar-rest/chapar/internal/domain" "github.com/chapar-rest/chapar/ui/chapartheme" - "github.com/chapar-rest/chapar/ui/keys" "github.com/chapar-rest/chapar/ui/widgets" ) @@ -28,9 +26,9 @@ type PrePostRequest struct { } type SetEnvForm struct { - statusCodeEditor widget.Editor - targetEditor widget.Editor - fromEditor widget.Editor + statusCodeEditor *widgets.LabeledInput + targetEditor *widgets.LabeledInput + fromEditor *widgets.LabeledInput fromDropDown *widgets.DropDown preview string } @@ -62,6 +60,28 @@ func NewPrePostRequest(options []Option, theme *chapartheme.Theme) *PrePostReque widgets.NewDropDownOption("From Header").WithValue(domain.PostRequestSetFromResponseHeader), widgets.NewDropDownOption("From Cookie").WithValue(domain.PostRequestSetFromResponseCookie), ), + statusCodeEditor: &widgets.LabeledInput{ + Label: "Status Code", + SpaceBetween: 5, + MinEditorWidth: unit.Dp(150), + MinLabelWidth: unit.Dp(80), + Editor: widgets.NewPatternEditor(), + }, + targetEditor: &widgets.LabeledInput{ + Label: "Target Key", + SpaceBetween: 5, + MinEditorWidth: unit.Dp(150), + MinLabelWidth: unit.Dp(80), + Editor: widgets.NewPatternEditor(), + }, + fromEditor: &widgets.LabeledInput{ + Label: "Key", + SpaceBetween: 5, + MinEditorWidth: unit.Dp(150), + MinLabelWidth: unit.Dp(80), + Editor: widgets.NewPatternEditor(), + Hint: "e.g. name", + }, }, } p.setEnvForm.fromDropDown.MaxWidth = unit.Dp(150) @@ -111,6 +131,16 @@ func (p *PrePostRequest) SetOnPostRequestSetChanged(f func(statusCode int, item, statusCode, _ := strconv.Atoi(p.setEnvForm.statusCodeEditor.Text()) p.onSetEnvFormChanged(statusCode, p.setEnvForm.targetEditor.Text(), selected, p.setEnvForm.fromEditor.Text()) }) + p.setEnvForm.statusCodeEditor.SetOnChanged(func(text string) { + p.enforceNumericEditor(p.setEnvForm.statusCodeEditor.Editor) + p.handleDataChange() + }) + p.setEnvForm.targetEditor.SetOnChanged(func(_ string) { + p.handleDataChange() + }) + p.setEnvForm.fromEditor.SetOnChanged(func(_ string) { + p.handleDataChange() + }) } func (p *PrePostRequest) Layout(gtx layout.Context, theme *chapartheme.Theme) layout.Dimensions { @@ -153,7 +183,7 @@ func (p *PrePostRequest) handleDataChange() { } } -func (p *PrePostRequest) enforceNumericEditor(editor *widget.Editor) { +func (p *PrePostRequest) enforceNumericEditor(editor *widgets.PatternEditor) { if _, err := strconv.Atoi(editor.Text()); err != nil { editor.SetText("0") } @@ -162,42 +192,15 @@ func (p *PrePostRequest) enforceNumericEditor(editor *widget.Editor) { func (p *PrePostRequest) SetEnvForm(gtx layout.Context, theme *chapartheme.Theme) layout.Dimensions { topButtonInset := layout.Inset{Top: unit.Dp(8), Bottom: unit.Dp(4)} - keys.OnEditorChange(gtx, &p.setEnvForm.statusCodeEditor, func() { - p.enforceNumericEditor(&p.setEnvForm.statusCodeEditor) - p.handleDataChange() - }) - - keys.OnEditorChange(gtx, &p.setEnvForm.targetEditor, func() { - p.handleDataChange() - }) - - keys.OnEditorChange(gtx, &p.setEnvForm.fromEditor, func() { - p.handleDataChange() - }) - return layout.Flex{Axis: layout.Vertical}.Layout(gtx, layout.Rigid(func(gtx layout.Context) layout.Dimensions { return topButtonInset.Layout(gtx, func(gtx layout.Context) layout.Dimensions { - lb := &widgets.LabeledInput{ - Label: "Target Key", - SpaceBetween: 5, - MinEditorWidth: unit.Dp(150), - MinLabelWidth: unit.Dp(80), - Editor: &p.setEnvForm.targetEditor, - } - return lb.Layout(gtx, theme) + return p.setEnvForm.targetEditor.Layout(gtx, theme) }) }), layout.Rigid(func(gtx layout.Context) layout.Dimensions { return topButtonInset.Layout(gtx, func(gtx layout.Context) layout.Dimensions { - lb := &widgets.LabeledInput{ - Label: "Status Code", - SpaceBetween: 5, - MinEditorWidth: unit.Dp(150), - MinLabelWidth: unit.Dp(80), - Editor: &p.setEnvForm.statusCodeEditor, - } - return lb.Layout(gtx, theme) + return p.setEnvForm.statusCodeEditor.Layout(gtx, theme) }) }), @@ -227,15 +230,9 @@ func (p *PrePostRequest) SetEnvForm(gtx layout.Context, theme *chapartheme.Theme hint = "e.g. $.data[0].name" } - lb := &widgets.LabeledInput{ - Label: label, - SpaceBetween: 5, - MinEditorWidth: unit.Dp(150), - MinLabelWidth: unit.Dp(80), - Editor: &p.setEnvForm.fromEditor, - Hint: hint, - } - return lb.Layout(gtx, theme) + p.setEnvForm.fromEditor.SetHint(hint) + p.setEnvForm.fromEditor.SetLabel(label) + return p.setEnvForm.fromEditor.Layout(gtx, theme) }) }), layout.Rigid(func(gtx layout.Context) layout.Dimensions { diff --git a/ui/pages/requests/grpc/address_bar.go b/ui/pages/requests/grpc/address_bar.go index 764d0243..e3c2d14e 100644 --- a/ui/pages/requests/grpc/address_bar.go +++ b/ui/pages/requests/grpc/address_bar.go @@ -13,7 +13,7 @@ import ( type AddressBar struct { theme *chapartheme.Theme - serverAddress *widget.Editor + serverAddress *widgets.PatternEditor lastSelectedMethod string methodDropDown *widgets.DropDown @@ -28,7 +28,7 @@ type AddressBar struct { func NewAddressBar(theme *chapartheme.Theme, address, lastSelectedMethod string, services []domain.GRPCService) *AddressBar { a := &AddressBar{ theme: theme, - serverAddress: &widget.Editor{}, + serverAddress: widgets.NewPatternEditor(), methodDropDown: widgets.NewDropDownWithoutBorder(theme), lastSelectedMethod: lastSelectedMethod, } @@ -70,6 +70,7 @@ func (a *AddressBar) SetSelectedMethod(method string) { func (a *AddressBar) SetOnServerAddressChanged(onServerAddressChanged func(url string)) { a.onServerAddressChanged = onServerAddressChanged + a.serverAddress.SetOnChanged(onServerAddressChanged) } func (a *AddressBar) SetOnMethodChanged(onMethodChanged func(method string)) { @@ -78,6 +79,7 @@ func (a *AddressBar) SetOnMethodChanged(onMethodChanged func(method string)) { func (a *AddressBar) SetOnSubmit(onSubmit func()) { a.onSubmit = onSubmit + a.serverAddress.SetOnSubmit(onSubmit) } func (a *AddressBar) Layout(gtx layout.Context, theme *chapartheme.Theme) layout.Dimensions { @@ -92,27 +94,6 @@ func (a *AddressBar) Layout(gtx layout.Context, theme *chapartheme.Theme) layout CornerRadius: unit.Dp(4), } - for { - event, ok := a.serverAddress.Update(gtx) - if !ok { - break - } - - switch event.(type) { - // on carriage return event - case widget.SubmitEvent: - if a.onSubmit != nil { - // goroutine to prevent blocking the ui update - go a.onSubmit() - } - // on change event - case widget.ChangeEvent: - if a.onServerAddressChanged != nil { - a.onServerAddressChanged(a.serverAddress.Text()) - } - } - } - methodSelected := a.methodDropDown.GetSelected().GetValue() if methodSelected != a.lastSelectedMethod { a.lastSelectedMethod = methodSelected @@ -135,11 +116,7 @@ func (a *AddressBar) Layout(gtx layout.Context, theme *chapartheme.Theme) layout }.Layout(gtx, layout.Flexed(0.3, func(gtx layout.Context) layout.Dimensions { return layout.Inset{Left: unit.Dp(10), Right: unit.Dp(5)}.Layout(gtx, func(gtx layout.Context) layout.Dimensions { - gtx.Constraints.Min.Y = gtx.Dp(20) - editor := material.Editor(theme.Material(), a.serverAddress, "localhost:8080") - editor.SelectionColor = theme.TextSelectionColor - editor.TextSize = unit.Sp(14) - return editor.Layout(gtx) + return a.serverAddress.Layout(gtx, theme, "localhost:8080") }) }), widgets.DrawLineFlex(theme.SeparatorColor, unit.Dp(20), unit.Dp(1)), diff --git a/ui/widgets/code_editor.go b/ui/widgets/code_editor.go index 1dade974..ccd56f8e 100644 --- a/ui/widgets/code_editor.go +++ b/ui/widgets/code_editor.go @@ -10,7 +10,6 @@ import ( "gioui.org/text" "gioui.org/unit" "gioui.org/widget" - "gioui.org/x/richtext" "github.com/alecthomas/chroma/v2" "github.com/alecthomas/chroma/v2/lexers" @@ -44,8 +43,6 @@ type CodeEditor struct { font font.FontFace - rhState richtext.InteractiveText - border widget.Border beatufier widget.Clickable @@ -57,11 +54,10 @@ type CodeEditor struct { func NewCodeEditor(code string, lang string, theme *chapartheme.Theme) *CodeEditor { c := &CodeEditor{ - editor: new(giovieweditor.Editor), - code: code, - font: fonts.MustGetCodeEditorFont(), - rhState: richtext.InteractiveText{}, - lang: lang, + editor: new(giovieweditor.Editor), + code: code, + font: fonts.MustGetCodeEditorFont(), + lang: lang, } c.border = widget.Border{ @@ -202,6 +198,8 @@ func (c *CodeEditor) Layout(gtx layout.Context, theme *chapartheme.Theme, hint s TypeFace: c.font.Font.Typeface, TextSize: unit.Sp(14), LineHeightScale: 1.2, + ShowLineNum: true, + LineNumPadding: unit.Dp(10), } return giovieweditor.NewEditor(c.editor, editorConf, hint).Layout(gtx) @@ -237,7 +235,7 @@ func (c *CodeEditor) stylingText(text string) []*giovieweditor.TextStyle { } if entry.Colour.IsSet() { - textStyle.Color = colorToOp(entry.Colour) + textStyle.Color = chromaColorToOp(entry.Colour) } textStyles = append(textStyles, textStyle) @@ -250,7 +248,7 @@ func (c *CodeEditor) stylingText(text string) []*giovieweditor.TextStyle { return textStyles } -func colorToOp(textColor chroma.Colour) op.CallOp { +func chromaColorToOp(textColor chroma.Colour) op.CallOp { ops := new(op.Ops) m := op.Record(ops) diff --git a/ui/widgets/keyvalue.go b/ui/widgets/keyvalue.go index 0d1e9947..4d9e4b9d 100644 --- a/ui/widgets/keyvalue.go +++ b/ui/widgets/keyvalue.go @@ -38,7 +38,7 @@ type KeyValueItem struct { Active bool keyEditor *widget.Editor - valueEditor *widget.Editor + valueEditor *PatternEditor activeBool *widget.Bool deleteButton *widget.Clickable @@ -52,7 +52,6 @@ func NewKeyValue(items ...*KeyValueItem) *KeyValue { Size: unit.Dp(20), Clickable: &widget.Clickable{}, }, - Items: items, list: &widget.List{ List: layout.List{ Axis: layout.Vertical, @@ -62,6 +61,9 @@ func NewKeyValue(items ...*KeyValueItem) *KeyValue { filteredItems: make([]*KeyValueItem, 0), } + // To make sure items are sorted by index and have the onValueChange callback set. + kv.SetItems(items) + kv.addButton.OnClick = func() { kv.AddItem(NewKeyValueItem("", "", uuid.NewString(), true)) kv.triggerChanged() @@ -74,10 +76,8 @@ func NewKeyValueItem(key, value, identifier string, active bool) *KeyValueItem { k := &widget.Editor{SingleLine: true} k.SetText(key) - v := &widget.Editor{SingleLine: true} - v.SetText(value) - - return &KeyValueItem{ + v := NewPatternEditor() + kv := &KeyValueItem{ Identifier: identifier, Key: key, Value: value, @@ -87,6 +87,10 @@ func NewKeyValueItem(key, value, identifier string, active bool) *KeyValueItem { deleteButton: &widget.Clickable{}, activeBool: &widget.Bool{Value: active}, } + + v.SetText(value) + + return kv } func (kv *KeyValue) Filter(text string) { @@ -117,6 +121,11 @@ func (kv *KeyValue) AddItem(item *KeyValueItem) { kv.mx.Lock() defer kv.mx.Unlock() + item.valueEditor.SetOnChanged(func(text string) { + item.Value = text + kv.triggerChanged() + }) + item.index = len(kv.Items) kv.Items = append(kv.Items, item) } @@ -126,6 +135,10 @@ func (kv *KeyValue) SetItems(items []*KeyValueItem) { defer kv.mx.Unlock() for i := range items { items[i].index = i + items[i].valueEditor.SetOnChanged(func(text string) { + items[i].Value = text + kv.triggerChanged() + }) } kv.Items = items } @@ -178,16 +191,6 @@ func (kv *KeyValue) itemLayout(gtx layout.Context, theme *chapartheme.Theme, ind } } - for { - event, ok := item.valueEditor.Update(gtx) - if !ok { - break - } - if _, ok := event.(widget.ChangeEvent); ok { - item.Value = item.valueEditor.Text() - kv.triggerChanged() - } - } leftPadding := layout.Inset{Left: unit.Dp(8)} content := layout.Flex{Axis: layout.Horizontal, Alignment: layout.Middle}.Layout(gtx, @@ -211,9 +214,7 @@ func (kv *KeyValue) itemLayout(gtx layout.Context, theme *chapartheme.Theme, ind DrawLineFlex(theme.TableBorderColor, unit.Dp(35), unit.Dp(1)), layout.Flexed(1, func(gtx layout.Context) layout.Dimensions { return leftPadding.Layout(gtx, func(gtx layout.Context) layout.Dimensions { - ed := material.Editor(theme.Material(), item.valueEditor, "Value") - ed.SelectionColor = theme.TextSelectionColor - return ed.Layout(gtx) + return item.valueEditor.Layout(gtx, theme, "Value") }) }), ) diff --git a/ui/widgets/labeled_input.go b/ui/widgets/labeled_input.go index 8308ed16..c12bead4 100644 --- a/ui/widgets/labeled_input.go +++ b/ui/widgets/labeled_input.go @@ -14,10 +14,30 @@ type LabeledInput struct { SpaceBetween int MinEditorWidth unit.Dp MinLabelWidth unit.Dp - Editor *widget.Editor + Editor *PatternEditor Hint string } +func (l *LabeledInput) SetText(text string) { + l.Editor.SetText(text) +} + +func (l *LabeledInput) Text() string { + return l.Editor.Text() +} + +func (l *LabeledInput) SetHint(hint string) { + l.Hint = hint +} + +func (l *LabeledInput) SetLabel(label string) { + l.Label = label +} + +func (l *LabeledInput) SetOnChanged(f func(text string)) { + l.Editor.SetOnChanged(f) +} + func (l *LabeledInput) Layout(gtx layout.Context, theme *chapartheme.Theme) layout.Dimensions { return layout.Flex{ Axis: layout.Horizontal, @@ -37,10 +57,7 @@ func (l *LabeledInput) Layout(gtx layout.Context, theme *chapartheme.Theme) layo CornerRadius: unit.Dp(4), }.Layout(gtx, func(gtx layout.Context) layout.Dimensions { return layout.UniformInset(unit.Dp(8)).Layout(gtx, func(gtx layout.Context) layout.Dimensions { - editor := material.Editor(theme.Material(), l.Editor, l.Hint) - editor.SelectionColor = theme.TextSelectionColor - - return editor.Layout(gtx) + return l.Editor.Layout(gtx, theme, l.Hint) }) }) }), diff --git a/ui/widgets/pattern_editor.go b/ui/widgets/pattern_editor.go new file mode 100644 index 00000000..eee5cc79 --- /dev/null +++ b/ui/widgets/pattern_editor.go @@ -0,0 +1,133 @@ +package widgets + +import ( + "image/color" + "regexp" + + "gioui.org/layout" + "gioui.org/op" + "gioui.org/op/paint" + "gioui.org/unit" + giovieweditor "github.com/oligo/gioview/editor" + + "github.com/chapar-rest/chapar/ui/chapartheme" +) + +var ( + singleBracket = regexp.MustCompile(`(\{[a-zA-Z0-9_]+})`) + doubleBracket = regexp.MustCompile(`(\{\{[a-zA-Z0-9_]+}})`) +) + +// PatternEditor is a widget that allows the user to edit a text like and highlight patterns like {{id}} or {name} +type PatternEditor struct { + *giovieweditor.Editor + Keys map[string]string + + styledText string + + onChange func(text string) + onSubmit func() +} + +// NewPatternEditor creates a new PatternEditor +func NewPatternEditor() *PatternEditor { + pe := &PatternEditor{ + Editor: new(giovieweditor.Editor), + Keys: make(map[string]string), + } + + pe.Editor.SingleLine = true + + return pe +} + +func (p *PatternEditor) SetText(text string) { + p.Editor.SetText(text, false) + p.updateStyles(text) +} + +func (p *PatternEditor) SetOnSubmit(onSubmit func()) { + p.onSubmit = onSubmit +} + +func (p *PatternEditor) SetOnChanged(onChange func(text string)) { + p.onChange = onChange +} + +func (p *PatternEditor) Layout(gtx layout.Context, theme *chapartheme.Theme, hint string) layout.Dimensions { + if p.styledText == "" { + p.updateStyles(p.Editor.Text()) + } + + editorConf := &giovieweditor.EditorConf{ + Shaper: theme.Shaper, + TextColor: theme.Fg, + Bg: theme.Bg, + SelectionColor: theme.TextSelectionColor, + TextSize: unit.Sp(14), + LineHeightScale: 1, + } + + for { + event, ok := p.Editor.Update(gtx) + if !ok { + break + } + + switch event.(type) { + // on carriage return event + case giovieweditor.SubmitEvent: + if p.onSubmit != nil { + // goroutine to prevent blocking the ui update + go p.onSubmit() + } + // on change event + case giovieweditor.ChangeEvent: + p.UpdateStyles() + if p.onChange != nil { + p.onChange(p.Editor.Text()) + } + } + } + gtx.Constraints.Max.Y = gtx.Dp(20) + return giovieweditor.NewEditor(p.Editor, editorConf, hint).Layout(gtx) +} + +func (p *PatternEditor) UpdateStyles() { + p.updateStyles(p.Editor.Text()) +} + +func (p *PatternEditor) updateStyles(text string) { + if p.styledText == text { + return + } + + var styles []*giovieweditor.TextStyle + + keyColor := color.NRGBA{R: 255, G: 165, B: 0, A: 255} + // Apply styles based on matches + applyStyles := func(re *regexp.Regexp) { + matches := re.FindAllStringIndex(text, -1) + for _, match := range matches { + styles = append(styles, &giovieweditor.TextStyle{ + Start: match[0], + End: match[1], + Color: nRGBAColorToOp(keyColor), + }) + } + } + + applyStyles(singleBracket) + applyStyles(doubleBracket) + + p.styledText = text + p.Editor.UpdateTextStyles(styles) +} + +func nRGBAColorToOp(textColor color.NRGBA) op.CallOp { + ops := new(op.Ops) + + m := op.Record(ops) + paint.ColorOp{Color: textColor}.Add(ops) + return m.Stop() +} diff --git a/vendor/gioui.org/app/app.go b/vendor/gioui.org/app/app.go index ef4a0fe2..a9bb0614 100644 --- a/vendor/gioui.org/app/app.go +++ b/vendor/gioui.org/app/app.go @@ -61,6 +61,10 @@ type FrameEvent struct { type ViewEvent interface { implementsViewEvent() ImplementsEvent() + // Valid will return true when the ViewEvent does contains valid handles. + // If a window receives an invalid ViewEvent, it should deinitialize any + // state referring to handles from a previous ViewEvent. + Valid() bool } // Insets is the space taken up by diff --git a/vendor/gioui.org/app/gl_macos.m b/vendor/gioui.org/app/gl_macos.m index e545391d..3f95ac0f 100644 --- a/vendor/gioui.org/app/gl_macos.m +++ b/vendor/gioui.org/app/gl_macos.m @@ -7,7 +7,7 @@ #include #include "_cgo_export.h" -CALayer *gio_layerFactory(void) { +CALayer *gio_layerFactory(BOOL presentWithTrans) { @autoreleasepool { return [CALayer layer]; } diff --git a/vendor/gioui.org/app/metal_macos.go b/vendor/gioui.org/app/metal_macos.go index 4fe7586c..15d60b08 100644 --- a/vendor/gioui.org/app/metal_macos.go +++ b/vendor/gioui.org/app/metal_macos.go @@ -12,12 +12,12 @@ package app #import #include -CALayer *gio_layerFactory(void) { +CALayer *gio_layerFactory(BOOL presentWithTrans) { @autoreleasepool { CAMetalLayer *l = [CAMetalLayer layer]; l.autoresizingMask = kCALayerHeightSizable|kCALayerWidthSizable; l.needsDisplayOnBoundsChange = YES; - l.presentsWithTransaction = YES; + l.presentsWithTransaction = presentWithTrans; return l; } } diff --git a/vendor/gioui.org/app/os.go b/vendor/gioui.org/app/os.go index e1ded757..28ed35f8 100644 --- a/vendor/gioui.org/app/os.go +++ b/vendor/gioui.org/app/os.go @@ -173,19 +173,13 @@ type context interface { Unlock() } -// basicDriver is the subset of [driver] that may be called even after -// a window is destroyed. -type basicDriver interface { +// driver is the interface for the platform implementation +// of a window. +type driver interface { // Event blocks until an event is available and returns it. Event() event.Event // Invalidate requests a FrameEvent. Invalidate() -} - -// driver is the interface for the platform implementation -// of a window. -type driver interface { - basicDriver // SetAnimating sets the animation flag. When the window is animating, // FrameEvents are delivered as fast as the display can handle them. SetAnimating(anim bool) diff --git a/vendor/gioui.org/app/os_android.go b/vendor/gioui.org/app/os_android.go index a18bd083..3255d5f9 100644 --- a/vendor/gioui.org/app/os_android.go +++ b/vendor/gioui.org/app/os_android.go @@ -1495,3 +1495,6 @@ func Java_org_gioui_Gio_scheduleMainFuncs(env *C.JNIEnv, cls C.jclass) { func (AndroidViewEvent) implementsViewEvent() {} func (AndroidViewEvent) ImplementsEvent() {} +func (a AndroidViewEvent) Valid() bool { + return a != (AndroidViewEvent{}) +} diff --git a/vendor/gioui.org/app/os_ios.go b/vendor/gioui.org/app/os_ios.go index 53a22eaf..2a281cb8 100644 --- a/vendor/gioui.org/app/os_ios.go +++ b/vendor/gioui.org/app/os_ios.go @@ -441,3 +441,6 @@ func gio_runMain() { func (UIKitViewEvent) implementsViewEvent() {} func (UIKitViewEvent) ImplementsEvent() {} +func (u UIKitViewEvent) Valid() bool { + return u != (UIKitViewEvent{}) +} diff --git a/vendor/gioui.org/app/os_js.go b/vendor/gioui.org/app/os_js.go index 79e02783..66042917 100644 --- a/vendor/gioui.org/app/os_js.go +++ b/vendor/gioui.org/app/os_js.go @@ -822,3 +822,6 @@ func translateKey(k string) (key.Name, bool) { func (JSViewEvent) implementsViewEvent() {} func (JSViewEvent) ImplementsEvent() {} +func (j JSViewEvent) Valid() bool { + return !(j.Element.IsNull() || j.Element.IsUndefined()) +} diff --git a/vendor/gioui.org/app/os_macos.go b/vendor/gioui.org/app/os_macos.go index 1da5083f..f133ab10 100644 --- a/vendor/gioui.org/app/os_macos.go +++ b/vendor/gioui.org/app/os_macos.go @@ -40,7 +40,7 @@ import ( #define MOUSE_SCROLL 4 __attribute__ ((visibility ("hidden"))) void gio_main(void); -__attribute__ ((visibility ("hidden"))) CFTypeRef gio_createView(void); +__attribute__ ((visibility ("hidden"))) CFTypeRef gio_createView(int presentWithTrans); __attribute__ ((visibility ("hidden"))) CFTypeRef gio_createWindow(CFTypeRef viewRef, CGFloat width, CGFloat height, CGFloat minWidth, CGFloat minHeight, CGFloat maxWidth, CGFloat maxHeight); __attribute__ ((visibility ("hidden"))) void gio_viewSetHandle(CFTypeRef viewRef, uintptr_t handle); @@ -925,7 +925,9 @@ func newWindow(win *callbacks, options []Option) { w.loop = newEventLoop(w.w, w.wakeup) win.SetDriver(w) res <- struct{}{} - if err := w.init(); err != nil { + var cnf Config + cnf.apply(unit.Metric{}, options) + if err := w.init(cnf.CustomRenderer); err != nil { w.ProcessEvent(DestroyEvent{Err: err}) return } @@ -946,8 +948,12 @@ func newWindow(win *callbacks, options []Option) { <-res } -func (w *window) init() error { - view := C.gio_createView() +func (w *window) init(customRenderer bool) error { + presentWithTrans := 1 + if customRenderer { + presentWithTrans = 0 + } + view := C.gio_createView(C.int(presentWithTrans)) if view == 0 { return errors.New("newOSWindow: failed to create view") } @@ -1068,3 +1074,6 @@ func convertMods(mods C.NSUInteger) key.Modifiers { func (AppKitViewEvent) implementsViewEvent() {} func (AppKitViewEvent) ImplementsEvent() {} +func (a AppKitViewEvent) Valid() bool { + return a != (AppKitViewEvent{}) +} diff --git a/vendor/gioui.org/app/os_macos.m b/vendor/gioui.org/app/os_macos.m index 01b42978..b1940321 100644 --- a/vendor/gioui.org/app/os_macos.m +++ b/vendor/gioui.org/app/os_macos.m @@ -6,7 +6,7 @@ #include "_cgo_export.h" -__attribute__ ((visibility ("hidden"))) CALayer *gio_layerFactory(void); +__attribute__ ((visibility ("hidden"))) CALayer *gio_layerFactory(BOOL presentWithTrans); @interface GioAppDelegate : NSObject @end @@ -16,6 +16,7 @@ @interface GioWindowDelegate : NSObject @interface GioView : NSView @property uintptr_t handle; +@property BOOL presentWithTrans; @end @implementation GioWindowDelegate @@ -88,7 +89,7 @@ - (void)displayLayer:(CALayer *)layer { gio_onDraw(self.handle); } - (CALayer *)makeBackingLayer { - CALayer *layer = gio_layerFactory(); + CALayer *layer = gio_layerFactory(self.presentWithTrans); layer.delegate = self; return layer; } @@ -392,10 +393,11 @@ CFTypeRef gio_createWindow(CFTypeRef viewRef, CGFloat width, CGFloat height, CGF } } -CFTypeRef gio_createView(void) { +CFTypeRef gio_createView(int presentWithTrans) { @autoreleasepool { NSRect frame = NSMakeRect(0, 0, 0, 0); GioView* view = [[GioView alloc] initWithFrame:frame]; + view.presentWithTrans = presentWithTrans ? YES : NO; view.wantsLayer = YES; view.layerContentsRedrawPolicy = NSViewLayerContentsRedrawDuringViewResize; diff --git a/vendor/gioui.org/app/os_unix.go b/vendor/gioui.org/app/os_unix.go index b91cf89a..28181b8f 100644 --- a/vendor/gioui.org/app/os_unix.go +++ b/vendor/gioui.org/app/os_unix.go @@ -9,7 +9,6 @@ import ( "errors" "unsafe" - "gioui.org/io/event" "gioui.org/io/pointer" ) @@ -22,6 +21,9 @@ type X11ViewEvent struct { func (X11ViewEvent) implementsViewEvent() {} func (X11ViewEvent) ImplementsEvent() {} +func (x X11ViewEvent) Valid() bool { + return x != (X11ViewEvent{}) +} type WaylandViewEvent struct { // Display is the *wl_display returned by wl_display_connect. @@ -32,6 +34,9 @@ type WaylandViewEvent struct { func (WaylandViewEvent) implementsViewEvent() {} func (WaylandViewEvent) ImplementsEvent() {} +func (w WaylandViewEvent) Valid() bool { + return w != (WaylandViewEvent{}) +} func osMain() { select {} @@ -57,35 +62,12 @@ func newWindow(window *callbacks, options []Option) { errFirst = err } } - window.SetDriver(&dummyDriver{ - win: window, - wakeups: make(chan event.Event, 1), - }) if errFirst == nil { errFirst = errors.New("app: no window driver available") } window.ProcessEvent(DestroyEvent{Err: errFirst}) } -type dummyDriver struct { - win *callbacks - wakeups chan event.Event -} - -func (d *dummyDriver) Event() event.Event { - if e, ok := d.win.nextEvent(); ok { - return e - } - return <-d.wakeups -} - -func (d *dummyDriver) Invalidate() { - select { - case d.wakeups <- wakeupEvent{}: - default: - } -} - // xCursor contains mapping from pointer.Cursor to XCursor. var xCursor = [...]string{ pointer.CursorDefault: "left_ptr", diff --git a/vendor/gioui.org/app/os_wayland.go b/vendor/gioui.org/app/os_wayland.go index 0689655d..24d1d874 100644 --- a/vendor/gioui.org/app/os_wayland.go +++ b/vendor/gioui.org/app/os_wayland.go @@ -217,10 +217,6 @@ type window struct { wakeups chan struct{} closing bool - - // invMu avoids the race between the destruction of disp and - // Invalidate waking it up. - invMu sync.Mutex } type poller struct { @@ -1369,10 +1365,8 @@ func (w *window) close(err error) { w.ProcessEvent(WaylandViewEvent{}) w.ProcessEvent(DestroyEvent{Err: err}) w.destroy() - w.invMu.Lock() w.disp.destroy() w.disp = nil - w.invMu.Unlock() } func (w *window) dispatch() { @@ -1416,11 +1410,7 @@ func (w *window) Invalidate() { default: return } - w.invMu.Lock() - defer w.invMu.Unlock() - if w.disp != nil { - w.disp.wakeup() - } + w.disp.wakeup() } func (w *window) Run(f func()) { @@ -1643,6 +1633,14 @@ func (w *window) flushScroll() { if total == (f32.Point{}) { return } + if w.scroll.steps == (image.Point{}) { + w.fling.xExtrapolation.SampleDelta(w.scroll.time, -w.scroll.dist.X) + w.fling.yExtrapolation.SampleDelta(w.scroll.time, -w.scroll.dist.Y) + } + // Zero scroll distance prior to calling ProcessEvent, otherwise we may recursively + // re-process the scroll distance. + w.scroll.dist = f32.Point{} + w.scroll.steps = image.Point{} w.ProcessEvent(pointer.Event{ Kind: pointer.Scroll, Source: pointer.Mouse, @@ -1652,12 +1650,6 @@ func (w *window) flushScroll() { Time: w.scroll.time, Modifiers: w.disp.xkb.Modifiers(), }) - if w.scroll.steps == (image.Point{}) { - w.fling.xExtrapolation.SampleDelta(w.scroll.time, -w.scroll.dist.X) - w.fling.yExtrapolation.SampleDelta(w.scroll.time, -w.scroll.dist.Y) - } - w.scroll.dist = f32.Point{} - w.scroll.steps = image.Point{} } func (w *window) onPointerMotion(x, y C.wl_fixed_t, t C.uint32_t) { diff --git a/vendor/gioui.org/app/os_windows.go b/vendor/gioui.org/app/os_windows.go index 72489270..7c950a5a 100644 --- a/vendor/gioui.org/app/os_windows.go +++ b/vendor/gioui.org/app/os_windows.go @@ -54,9 +54,6 @@ type window struct { borderSize image.Point config Config loop *eventLoop - - // invMu avoids the race between destroying the window and Invalidate. - invMu sync.Mutex } const _WM_WAKEUP = windows.WM_USER + iota @@ -304,10 +301,8 @@ func windowProc(hwnd syscall.Handle, msg uint32, wParam, lParam uintptr) uintptr windows.ReleaseDC(w.hdc) w.hdc = 0 } - w.invMu.Lock() // The system destroys the HWND for us. w.hwnd = 0 - w.invMu.Unlock() windows.PostQuitMessage(0) case windows.WM_NCCALCSIZE: if w.config.Decorated { @@ -620,13 +615,6 @@ func (w *window) Frame(frame *op.Ops) { } func (w *window) wakeup() { - w.invMu.Lock() - defer w.invMu.Unlock() - if w.hwnd == 0 { - w.loop.Wakeup() - w.loop.FlushEvents() - return - } if err := windows.PostMessage(w.hwnd, _WM_WAKEUP, 0, 0); err != nil { panic(err) } @@ -993,3 +981,6 @@ func configForDPI(dpi int) unit.Metric { func (Win32ViewEvent) implementsViewEvent() {} func (Win32ViewEvent) ImplementsEvent() {} +func (w Win32ViewEvent) Valid() bool { + return w != (Win32ViewEvent{}) +} diff --git a/vendor/gioui.org/app/os_x11.go b/vendor/gioui.org/app/os_x11.go index 3865f25d..83e6b351 100644 --- a/vendor/gioui.org/app/os_x11.go +++ b/vendor/gioui.org/app/os_x11.go @@ -113,9 +113,6 @@ type x11Window struct { wakeups chan struct{} handler x11EventHandler buf [100]byte - - // invMy avoids the race between destroy and Invalidate. - invMu sync.Mutex } var ( @@ -416,11 +413,6 @@ func (w *x11Window) Invalidate() { case w.wakeups <- struct{}{}: default: } - w.invMu.Lock() - defer w.invMu.Unlock() - if w.x == nil { - return - } if _, err := syscall.Write(w.notify.write, x11OneByte); err != nil && err != syscall.EAGAIN { panic(fmt.Errorf("failed to write to pipe: %v", err)) } @@ -509,8 +501,6 @@ func (w *x11Window) dispatch() { } func (w *x11Window) destroy() { - w.invMu.Lock() - defer w.invMu.Unlock() if w.notify.write != 0 { syscall.Close(w.notify.write) w.notify.write = 0 diff --git a/vendor/gioui.org/app/window.go b/vendor/gioui.org/app/window.go index 70f6a359..79a8c6a8 100644 --- a/vendor/gioui.org/app/window.go +++ b/vendor/gioui.org/app/window.go @@ -7,8 +7,8 @@ import ( "fmt" "image" "image/color" - "reflect" "runtime" + "sync" "time" "unicode/utf8" @@ -41,7 +41,8 @@ type Option func(unit.Metric, *Config) // // More than one Window is not supported on iOS, Android, WebAssembly. type Window struct { - initialOpts []Option + initialOpts []Option + initialActions []system.Action ctx context gpu gpu.GPU @@ -88,8 +89,11 @@ type Window struct { } imeState editorState driver driver - // basic is the driver interface that is needed even after the window is gone. - basic basicDriver + + // invMu protects mayInvalidate. + invMu sync.Mutex + mayInvalidate bool + // coalesced tracks the most recent events waiting to be delivered // to the client. coalesced eventSummary @@ -103,11 +107,12 @@ type Window struct { } type eventSummary struct { - wakeup bool - cfg *ConfigEvent - view *ViewEvent - frame *frameEvent - destroy *DestroyEvent + wakeup bool + cfg *ConfigEvent + view *ViewEvent + frame *frameEvent + framePending bool + destroy *DestroyEvent } type callbacks struct { @@ -214,6 +219,7 @@ func (w *Window) frame(frame *op.Ops, viewport image.Point) error { } func (w *Window) processFrame(frame *op.Ops, ack chan<- struct{}) { + w.coalesced.framePending = false wrapper := &w.decorations.Ops off := op.Offset(w.lastFrame.off).Push(wrapper) ops.AddCall(&wrapper.Internal, &frame.Internal, ops.PC{}, ops.PCFor(&frame.Internal)) @@ -271,8 +277,11 @@ func (w *Window) updateState() { // // Invalidate is safe for concurrent use. func (w *Window) Invalidate() { - if w.basic != nil { - w.basic.Invalidate() + w.invMu.Lock() + defer w.invMu.Unlock() + if w.mayInvalidate { + w.mayInvalidate = false + w.driver.Invalidate() } } @@ -282,7 +291,7 @@ func (w *Window) Option(opts ...Option) { if len(opts) == 0 { return } - if w.basic == nil { + if w.driver == nil { w.initialOpts = append(w.initialOpts, opts...) return } @@ -377,11 +386,11 @@ func (w *Window) setNextFrame(at time.Time) { } } -func (c *callbacks) SetDriver(d basicDriver) { - c.w.basic = d - if d, ok := d.(driver); ok { - c.w.driver = d +func (c *callbacks) SetDriver(d driver) { + if d == nil { + panic("nil driver") } + c.w.driver = d } func (c *callbacks) ProcessFrame(frame *op.Ops, ack chan<- struct{}) { @@ -548,10 +557,20 @@ func (c *callbacks) Invalidate() { } func (c *callbacks) nextEvent() (event.Event, bool) { - s := &c.w.coalesced - // Every event counts as a wakeup. - defer func() { s.wakeup = false }() + return c.w.nextEvent() +} + +func (w *Window) nextEvent() (event.Event, bool) { + s := &w.coalesced + defer func() { + // Every event counts as a wakeup. + s.wakeup = false + }() switch { + case s.framePending: + // If the user didn't call FrameEvent.Event, process + // an empty frame. + w.processFrame(new(op.Ops), nil) case s.view != nil: e := *s.view s.view = nil @@ -568,10 +587,14 @@ func (c *callbacks) nextEvent() (event.Event, bool) { case s.frame != nil: e := *s.frame s.frame = nil + s.framePending = true return e.FrameEvent, true case s.wakeup: return wakeupEvent{}, true } + w.invMu.Lock() + defer w.invMu.Unlock() + w.mayInvalidate = w.driver != nil return nil, false } @@ -615,6 +638,9 @@ func (w *Window) processEvent(e event.Event) bool { w.coalesced.frame = &e2 case DestroyEvent: w.destroyGPU() + w.invMu.Lock() + w.mayInvalidate = false + w.invMu.Unlock() w.driver = nil if q := w.timer.quit; q != nil { q <- struct{}{} @@ -622,7 +648,7 @@ func (w *Window) processEvent(e event.Event) bool { } w.coalesced.destroy = &e2 case ViewEvent: - if reflect.ValueOf(e2).IsZero() && w.gpu != nil { + if !e2.Valid() && w.gpu != nil { w.ctx.Lock() w.gpu.Release() w.gpu = nil @@ -686,10 +712,17 @@ func (w *Window) processEvent(e event.Event) bool { // [FrameEvent], or until [Invalidate] is called. The window is created // and shown the first time Event is called. func (w *Window) Event() event.Event { - if w.basic == nil { + if w.driver == nil { w.init() } - return w.basic.Event() + if w.driver == nil { + e, ok := w.nextEvent() + if !ok { + panic("window initializion failed without a DestroyEvent") + } + return e + } + return w.driver.Event() } func (w *Window) init() { @@ -727,6 +760,10 @@ func (w *Window) init() { w.imeState.compose = key.Range{Start: -1, End: -1} w.semantic.ids = make(map[input.SemanticID]input.SemanticNode) newWindow(&callbacks{w}, options) + for _, acts := range w.initialActions { + w.Perform(acts) + } + w.initialActions = nil } func (w *Window) updateCursor() { @@ -826,6 +863,10 @@ func (w *Window) Perform(actions system.Action) { if acts == 0 { return } + if w.driver == nil { + w.initialActions = append(w.initialActions, acts) + return + } w.Run(func() { w.driver.Perform(actions) }) diff --git a/vendor/gioui.org/io/input/router.go b/vendor/gioui.org/io/input/router.go index 9e07e9a6..accb37ff 100644 --- a/vendor/gioui.org/io/input/router.go +++ b/vendor/gioui.org/io/input/router.go @@ -274,28 +274,29 @@ func (q *Router) Event(filters ...event.Filter) (event.Event, bool) { } } } - if !q.deferring { - for i := range q.changes { - change := &q.changes[i] - for j, evt := range change.events { - match := false - switch e := evt.event.(type) { - case key.Event: - match = q.key.scratchFilter.Matches(change.state.keyState.focus, e, false) - default: - for _, tf := range q.scratchFilters { - if evt.tag == tf.tag && tf.filter.Matches(evt.event) { - match = true - break - } + for i := range q.changes { + if q.deferring && i > 0 { + break + } + change := &q.changes[i] + for j, evt := range change.events { + match := false + switch e := evt.event.(type) { + case key.Event: + match = q.key.scratchFilter.Matches(change.state.keyState.focus, e, false) + default: + for _, tf := range q.scratchFilters { + if evt.tag == tf.tag && tf.filter.Matches(evt.event) { + match = true + break } } - if match { - change.events = append(change.events[:j], change.events[j+1:]...) - // Fast forward state to last matched. - q.collapseState(i) - return evt.event, true - } + } + if match { + change.events = append(change.events[:j], change.events[j+1:]...) + // Fast forward state to last matched. + q.collapseState(i) + return evt.event, true } } } @@ -313,15 +314,15 @@ func (q *Router) collapseState(idx int) { } first := &q.changes[0] first.state = q.changes[idx].state - for i := 1; i <= idx; i++ { - first.events = append(first.events, q.changes[i].events...) + for _, ch := range q.changes[1 : idx+1] { + first.events = append(first.events, ch.events...) } q.changes = append(q.changes[:1], q.changes[idx+1:]...) } -// Frame replaces the declared handlers from the supplied -// operation list. The text input state, wakeup time and whether -// there are active profile handlers is also saved. +// Frame completes the current frame and starts a new with the +// handlers from the frame argument. Remaining events are discarded, +// unless they were deferred by a command. func (q *Router) Frame(frame *op.Ops) { var remaining []event.Event if n := len(q.changes); n > 0 { diff --git a/vendor/gioui.org/x/explorer/explorer_windows.go b/vendor/gioui.org/x/explorer/explorer_windows.go index 27bdf43e..094b2868 100644 --- a/vendor/gioui.org/x/explorer/explorer_windows.go +++ b/vendor/gioui.org/x/explorer/explorer_windows.go @@ -22,10 +22,12 @@ var ( _GetOpenFileName = _Dialog32.NewProc("GetOpenFileNameW") // https://docs.microsoft.com/en-us/windows/win32/api/commdlg/ns-commdlg-openfilenamew - _FlagFileMustExist = uint32(0x00001000) - _FlagForceShowHidden = uint32(0x10000000) - _FlagOverwritePrompt = uint32(0x00000002) - _FlagDisableLinks = uint32(0x00100000) + _FlagFileMustExist = uint32(0x00001000) + _FlagForceShowHidden = uint32(0x10000000) + _FlagOverwritePrompt = uint32(0x00000002) + _FlagDisableLinks = uint32(0x00100000) + _FlagAllowMultiSelect = uint32(0x00000200) + _FlagExplorer = uint32(0x00080000) _FilePathLength = uint32(65535) _OpenFileStructLength = uint32(unsafe.Sizeof(_OpenFileName{})) @@ -118,8 +120,61 @@ func (e *Explorer) importFile(extensions ...string) (io.ReadCloser, error) { return os.Open(path) } -func (e *Explorer) importFiles(_ ...string) ([]io.ReadCloser, error) { - return nil, ErrNotAvailable +func (e *Explorer) importFiles(extensions ...string) ([]io.ReadCloser, error) { + pathUTF16 := make([]uint16, _FilePathLength) + + open := _OpenFileName{ + File: &pathUTF16[0], + MaxFile: _FilePathLength, + Filter: buildFilter(extensions), + Flags: _FlagFileMustExist | _FlagForceShowHidden | _FlagDisableLinks | _FlagAllowMultiSelect | _FlagExplorer, + StructSize: _OpenFileStructLength, + } + + if r, _, _ := _GetOpenFileName.Call(uintptr(unsafe.Pointer(&open))); r == 0 { + return nil, ErrUserDecline + } + + // Split the pathUTF16 by null characters + paths := make([]string, 0) + currentPath := make([]uint16, 0) + for _, char := range pathUTF16 { + if char == 0 { + if len(currentPath) > 0 { + paths = append(paths, windows.UTF16ToString(currentPath)) + currentPath = currentPath[:0] + } + } else { + currentPath = append(currentPath, char) + } + } + + // The first element is the directory, append it to each filename + dir := paths[0] + filePaths := make([]string, len(paths)-1) + for i, file := range paths[1:] { + filePaths[i] = filepath.Join(dir, file) + } + + if len(filePaths) == 0 { + return nil, ErrUserDecline + } + + files := make([]io.ReadCloser, len(filePaths)) + for i, filePath := range filePaths { + file, err := os.Open(filePath) + if err != nil { + for _, file := range files { + if file != nil { + file.Close() + } + } + return nil, err + } + files[i] = file + } + + return files, nil } func buildFilter(extensions []string) *uint16 { diff --git a/vendor/gioui.org/x/richtext/README.md b/vendor/gioui.org/x/richtext/README.md deleted file mode 100644 index 0f2248ba..00000000 --- a/vendor/gioui.org/x/richtext/README.md +++ /dev/null @@ -1,3 +0,0 @@ -# richtext - -Provides a widget that renders text in different styles. diff --git a/vendor/gioui.org/x/richtext/richtext.go b/vendor/gioui.org/x/richtext/richtext.go deleted file mode 100644 index 5cf678a4..00000000 --- a/vendor/gioui.org/x/richtext/richtext.go +++ /dev/null @@ -1,270 +0,0 @@ -// Package richtext provides rendering of text containing multiple fonts, styles, and levels of interactivity. -package richtext - -import ( - "image/color" - "time" - - "gioui.org/font" - "gioui.org/gesture" - "gioui.org/io/pointer" - "gioui.org/layout" - "gioui.org/op" - "gioui.org/op/clip" - "gioui.org/text" - "gioui.org/unit" - "gioui.org/x/styledtext" -) - -// LongPressDuration is the default duration of a long press gesture. -// Override this variable to change the detection threshold. -var LongPressDuration time.Duration = 250 * time.Millisecond - -// EventType describes a kind of iteraction with rich text. -type EventType uint8 - -const ( - Hover EventType = iota - Unhover - LongPress - Click -) - -// Event describes an interaction with rich text. -type Event struct { - Type EventType - // ClickData is only populated if Type == Clicked - ClickData gesture.ClickEvent -} - -// InteractiveSpan holds the persistent state of rich text that can -// be interacted with by the user. It can report clicks, hovers, and -// long-presses on the text. -type InteractiveSpan struct { - click gesture.Click - pressing bool - hovering bool - longPressed bool - pressStarted time.Time - contents string - metadata map[string]interface{} -} - -func (i *InteractiveSpan) Update(gtx layout.Context) (Event, bool) { - if i == nil { - return Event{}, false - } - for { - e, ok := i.click.Update(gtx.Source) - if !ok { - break - } - switch e.Kind { - case gesture.KindClick: - i.pressing = false - if i.longPressed { - i.longPressed = false - } else { - return Event{Type: Click, ClickData: e}, true - } - case gesture.KindPress: - i.pressStarted = gtx.Now - i.pressing = true - case gesture.KindCancel: - i.pressing = false - i.longPressed = false - } - } - if isHovered := i.click.Hovered(); isHovered != i.hovering { - i.hovering = isHovered - if isHovered { - return Event{Type: Hover}, true - } else { - return Event{Type: Unhover}, true - } - } - - if !i.longPressed && i.pressing && gtx.Now.Sub(i.pressStarted) > LongPressDuration { - i.longPressed = true - return Event{Type: LongPress}, true - } - return Event{}, false -} - -// Layout adds the pointer input op for this interactive span and updates its -// state. It uses the most recent pointer.AreaOp as its input area. -func (i *InteractiveSpan) Layout(gtx layout.Context) layout.Dimensions { - for { - _, ok := i.Update(gtx) - if !ok { - break - } - } - if i.pressing && !i.longPressed { - gtx.Execute(op.InvalidateCmd{}) - } - defer clip.Rect{Max: gtx.Constraints.Max}.Push(gtx.Ops).Pop() - - pointer.CursorPointer.Add(gtx.Ops) - i.click.Add(gtx.Ops) - return layout.Dimensions{} -} - -// Content returns the text content of the interactive span as well as the -// metadata associated with it. -func (i *InteractiveSpan) Content() (string, map[string]interface{}) { - return i.contents, i.metadata -} - -// Get looks up a metadata property on the interactive span. -func (i *InteractiveSpan) Get(key string) interface{} { - return i.metadata[key] -} - -// InteractiveText holds persistent state for a block of text containing -// spans that may be interactive. -type InteractiveText struct { - Spans []InteractiveSpan - lastUpdate time.Time - updateIndex int -} - -// resize makes sure that there are exactly n interactive spans. -func (i *InteractiveText) resize(n int) { - if n == 0 && i == nil { - return - } - - if cap(i.Spans) >= n { - i.Spans = i.Spans[:n] - } else { - i.Spans = make([]InteractiveSpan, n) - } -} - -// Update returns the first span with unprocessed events and the events that -// need processing for it. -func (i *InteractiveText) Update(gtx layout.Context) (*InteractiveSpan, Event, bool) { - if i == nil { - return nil, Event{}, false - } - if i.lastUpdate != gtx.Now { - i.lastUpdate = gtx.Now - i.updateIndex = 0 - } - for k := i.updateIndex; k < len(i.Spans); k++ { - i.updateIndex = k - span := &i.Spans[k] - for { - ev, ok := span.Update(gtx) - if !ok { - break - } - return span, ev, true - } - } - return nil, Event{}, false -} - -// SpanStyle describes the appearance of a span of styled text. -type SpanStyle struct { - Font font.Font - Size unit.Sp - Color color.NRGBA - Content string - Interactive bool - metadata map[string]interface{} - interactiveIdx int -} - -// Set configures a metadata key-value pair on the span that can be -// retrieved if the span is interacted with. If the provided value -// is empty, the key will be deleted from the metadata. -func (ss *SpanStyle) Set(key string, value interface{}) { - if value == "" { - if ss.metadata != nil { - delete(ss.metadata, key) - if len(ss.metadata) == 0 { - ss.metadata = nil - } - } - return - } - if ss.metadata == nil { - ss.metadata = make(map[string]interface{}) - } - ss.metadata[key] = value -} - -// DeepCopy returns an identical SpanStyle with its own copy of its metadata. -func (ss SpanStyle) DeepCopy() SpanStyle { - out := ss - if len(ss.metadata) > 0 { - md := make(map[string]interface{}) - for k, v := range ss.metadata { - md[k] = v - } - out.metadata = md - } - return out -} - -// TextStyle presents rich text. -type TextStyle struct { - State *InteractiveText - Styles []SpanStyle - Alignment text.Alignment - WrapPolicy styledtext.WrapPolicy - *text.Shaper -} - -// Text constructs a TextStyle. -func Text(state *InteractiveText, shaper *text.Shaper, styles ...SpanStyle) TextStyle { - return TextStyle{ - State: state, - Styles: styles, - Shaper: shaper, - } -} - -// Layout renders the TextStyle. -func (t TextStyle) Layout(gtx layout.Context) layout.Dimensions { - for { - _, _, ok := t.State.Update(gtx) - if !ok { - break - } - } - // OPT(dh): it'd be nice to avoid this allocation - styles := make([]styledtext.SpanStyle, len(t.Styles)) - numInteractive := 0 - for i := range t.Styles { - st := &t.Styles[i] - if st.Interactive { - st.interactiveIdx = numInteractive - numInteractive++ - } - styles[i] = styledtext.SpanStyle{ - Font: st.Font, - Size: st.Size, - Color: st.Color, - Content: st.Content, - } - } - t.State.resize(numInteractive) - - text := styledtext.Text(t.Shaper, styles...) - text.WrapPolicy = t.WrapPolicy - text.Alignment = t.Alignment - return text.Layout(gtx, func(gtx layout.Context, i int, _ layout.Dimensions) { - span := &t.Styles[i] - if !span.Interactive { - return - } - - state := &t.State.Spans[span.interactiveIdx] - state.contents = span.Content - state.metadata = span.metadata - state.Layout(gtx) - }) -} diff --git a/vendor/gioui.org/x/styledtext/README.md b/vendor/gioui.org/x/styledtext/README.md deleted file mode 100644 index 0a9b42c3..00000000 --- a/vendor/gioui.org/x/styledtext/README.md +++ /dev/null @@ -1,3 +0,0 @@ -# styledtext - -Provides a widget that renders text in different styles. diff --git a/vendor/gioui.org/x/styledtext/iterator.go b/vendor/gioui.org/x/styledtext/iterator.go deleted file mode 100644 index 6ff89847..00000000 --- a/vendor/gioui.org/x/styledtext/iterator.go +++ /dev/null @@ -1,152 +0,0 @@ -package styledtext - -import ( - "image" - - "gioui.org/layout" - "gioui.org/op" - "gioui.org/op/clip" - "gioui.org/op/paint" - "gioui.org/text" - "golang.org/x/exp/constraints" - "golang.org/x/image/math/fixed" -) - -// textIterator computes the bounding box of and paints text. This iterator is -// specialized to laying out single lines of text. -type textIterator struct { - // viewport is the rectangle of document coordinates that the iterator is - // trying to fill with text. - viewport image.Rectangle - // maxLines tracks the maximum allowed number of glyphs with FlagLineBreak. - maxLines int - - // linesSeen tracks the number of FlagLineBreak glyphs we have seen. - linesSeen int - // init tracks whether the iterator has processed any glyphs. - init bool - // firstX tracks the x offset of the first processed glyph. This is subtracted - // from all glyph x offsets in order to ensure that the text is rendered at - // x=0. - firstX fixed.Int26_6 - // hasNewline tracks whether the processed glyphs contained a synthetic newline - // character. - hasNewline bool - // lineOff tracks the origin for the glyphs in the current line. - lineOff image.Point - // padding is the space needed outside of the bounds of the text to ensure no - // part of a glyph is clipped. - padding image.Rectangle - // bounds is the logical bounding box of the text. - bounds image.Rectangle - // runes is the count of runes represented by the processed glyphs. - runes int - // visible tracks whether the most recently iterated glyph is visible within - // the viewport. - visible bool - // first tracks whether the iterator has processed a glyph yet. - first bool - // baseline tracks the location of the first line of text's baseline. - baseline int -} - -// processGlyph checks whether the glyph is visible within the iterator's configured -// viewport and (if so) updates the iterator's text dimensions to include the glyph. -func (it *textIterator) processGlyph(g text.Glyph, ok bool) (_ text.Glyph, visibleOrBefore bool) { - logicalBounds := image.Rectangle{ - Min: image.Pt(g.X.Floor(), int(g.Y)-g.Ascent.Ceil()), - Max: image.Pt((g.X + g.Advance).Ceil(), int(g.Y)+g.Descent.Ceil()), - } - if g.Flags&text.FlagTruncator != 0 { - // If the truncator is the first glyph, force a newline. - if it.runes == 0 { - it.hasNewline = true - } - // We always need to update the vertical bounds for the truncator glyph in case it's the only - // glyph on its line. Otherwise the line will seem to have zero size. - it.bounds.Min.Y = min(it.bounds.Min.Y, logicalBounds.Min.Y) - it.bounds.Max.Y = max(it.bounds.Max.Y, logicalBounds.Max.Y) - return g, false - } - it.runes += int(g.Runes) - it.hasNewline = it.hasNewline || (g.Flags&text.FlagLineBreak > 0 && g.Flags&text.FlagParagraphBreak > 0) - if it.maxLines > 0 { - if g.Flags&text.FlagLineBreak != 0 { - it.linesSeen++ - } - if it.linesSeen == it.maxLines && g.Flags&text.FlagParagraphBreak != 0 { - return g, false - } - } - // Compute the maximum extent to which glyphs overhang on the horizontal - // axis. - if d := g.Bounds.Min.X.Floor(); d < it.padding.Min.X { - it.padding.Min.X = d - } - if d := (g.Bounds.Max.X - g.Advance).Ceil(); d > it.padding.Max.X { - it.padding.Max.X = d - } - if !it.first { - it.first = true - it.baseline = int(g.Y) - it.bounds = logicalBounds - } - - above := logicalBounds.Max.Y < it.viewport.Min.Y - below := logicalBounds.Min.Y > it.viewport.Max.Y - left := logicalBounds.Max.X < it.viewport.Min.X - right := logicalBounds.Min.X > it.viewport.Max.X - it.visible = !above && !below && !left && !right - if it.visible { - it.bounds.Min.X = min(it.bounds.Min.X, logicalBounds.Min.X) - it.bounds.Min.Y = min(it.bounds.Min.Y, logicalBounds.Min.Y) - it.bounds.Max.X = max(it.bounds.Max.X, logicalBounds.Max.X) - it.bounds.Max.Y = max(it.bounds.Max.Y, logicalBounds.Max.Y) - } - return g, ok && !below - -} - -func min[T constraints.Ordered](a, b T) T { - if a < b { - return a - } - return b -} - -func max[T constraints.Ordered](a, b T) T { - if a > b { - return a - } - return b -} - -// paintGlyph buffers up and paints text glyphs. It should be invoked iteratively upon each glyph -// until it returns false. The line parameter should be a slice with -// a backing array of sufficient size to buffer multiple glyphs. -// A modified slice will be returned with each invocation, and is -// expected to be passed back in on the following invocation. -// This design is awkward, but prevents the line slice from escaping -// to the heap. -func (it *textIterator) paintGlyph(gtx layout.Context, shaper *text.Shaper, glyph text.Glyph, line []text.Glyph) ([]text.Glyph, bool) { - _, visibleOrBefore := it.processGlyph(glyph, true) - if it.visible { - if !it.init { - it.firstX = glyph.X - it.init = true - } - if len(line) == 0 { - it.lineOff = image.Point{X: (glyph.X - it.firstX).Floor(), Y: int(glyph.Y)}.Sub(it.viewport.Min) - } - line = append(line, glyph) - } - if glyph.Flags&text.FlagLineBreak > 0 || cap(line)-len(line) == 0 || !visibleOrBefore { - t := op.Offset(it.lineOff).Push(gtx.Ops) - op := clip.Outline{Path: shaper.Shape(line)}.Op().Push(gtx.Ops) - paint.PaintOp{}.Add(gtx.Ops) - op.Pop() - t.Pop() - line = line[:0] - } - return line, visibleOrBefore -} diff --git a/vendor/gioui.org/x/styledtext/styledtext.go b/vendor/gioui.org/x/styledtext/styledtext.go deleted file mode 100644 index eea8a8c8..00000000 --- a/vendor/gioui.org/x/styledtext/styledtext.go +++ /dev/null @@ -1,306 +0,0 @@ -// Package styledtext provides rendering of text containing multiple fonts and styles. -package styledtext - -import ( - "image" - "image/color" - "unicode/utf8" - - "gioui.org/font" - "gioui.org/layout" - "gioui.org/op" - "gioui.org/op/paint" - "gioui.org/text" - "gioui.org/unit" - "golang.org/x/image/math/fixed" -) - -// SpanStyle describes the appearance of a span of styled text. -type SpanStyle struct { - Font font.Font - Size unit.Sp - Color color.NRGBA - Content string - - idx int -} - -// spanShape describes the text shaping of a single span. -type spanShape struct { - offset image.Point - call op.CallOp - size image.Point - ascent int -} - -// Layout renders the span using the provided text shaping. -func (ss SpanStyle) Layout(gtx layout.Context, shape spanShape) layout.Dimensions { - paint.ColorOp{Color: ss.Color}.Add(gtx.Ops) - defer op.Offset(shape.offset).Push(gtx.Ops).Pop() - shape.call.Add(gtx.Ops) - return layout.Dimensions{Size: shape.size} -} - -// WrapPolicy defines line wrapping policies for styledtext. Due to complexities -// of the styledtext implementation, there are fewer options available than in -// [gioui.org/text.WrapPolicy]. -type WrapPolicy uint8 - -const ( - // WrapWords implements behavior like [gioui.org/text/.WrapWords]. This is the default, - // as it prevents words from being split across lines. - WrapWords WrapPolicy = iota - // WrapWords implements behavior like [gioui.org/text/.WrapGraphemes]. This often gives - // unpleasant results, as it will choose to split words across lines whenever it can. Some - // use-cases may still want this, however. - WrapGraphemes -) - -func (s WrapPolicy) textPolicy() text.WrapPolicy { - switch s { - case WrapWords: - return text.WrapWords - default: - return text.WrapGraphemes - } -} - -// TextStyle presents rich text. -type TextStyle struct { - Styles []SpanStyle - Alignment text.Alignment - WrapPolicy WrapPolicy - *text.Shaper -} - -// Text constructs a TextStyle. -func Text(shaper *text.Shaper, styles ...SpanStyle) TextStyle { - return TextStyle{ - Styles: styles, - Shaper: shaper, - } -} - -type spanResults struct { - call op.CallOp - width int - height int - ascent int - runes int - multiLine bool - endedWithNewline bool -} - -func (t TextStyle) iterateSpan(gtx layout.Context, maxWidth int, span SpanStyle, truncate bool) (op.CallOp, textIterator) { - var glyphs [32]text.Glyph - maxLines := 0 - if truncate { - maxLines = 1 - } - // shape the text of the current span - macro := op.Record(gtx.Ops) - paint.ColorOp{Color: span.Color}.Add(gtx.Ops) - t.Shaper.LayoutString(text.Parameters{ - Font: span.Font, - PxPerEm: fixed.I(gtx.Sp(span.Size)), - MaxLines: maxLines, - MaxWidth: maxWidth, - Truncator: "\u200b", // Unicode zero-width space. - Locale: gtx.Locale, - WrapPolicy: t.WrapPolicy.textPolicy(), - }, span.Content) - ti := textIterator{ - viewport: image.Rectangle{Max: gtx.Constraints.Max}, - maxLines: 1, - } - - line := glyphs[:0] - for g, ok := t.Shaper.NextGlyph(); ok; g, ok = t.Shaper.NextGlyph() { - line, ok = ti.paintGlyph(gtx, t.Shaper, g, line) - if !ok { - break - } - } - return macro.Stop(), ti -} - -func (t TextStyle) layoutSpan(gtx layout.Context, maxWidth int, span SpanStyle) spanResults { - call, ti := t.iterateSpan(gtx, maxWidth, span, true) - runesDisplayed := ti.runes - multiLine := runesDisplayed < utf8.RuneCountInString(span.Content) - endedWithNewline := ti.hasNewline - if multiLine { - var i int - for i = 0; i < runesDisplayed; { - _, sz := utf8.DecodeRuneInString(span.Content[i:]) - i += sz - } - firstTruncatedRune, _ := utf8.DecodeRuneInString(span.Content[i:]) - if firstTruncatedRune == '\n' { - endedWithNewline = true - runesDisplayed++ - } else if runesDisplayed == 0 && t.WrapPolicy == WrapWords { - // If we're only wrapping on word boundaries, we failed to display any runes whatsoever, - // and it wasn't due to a hard newline, we need to line-wrap without truncation to discover - // the word that doesn't fit on the line. - call, ti = t.iterateSpan(gtx, maxWidth, span, false) - runesDisplayed = ti.runes - multiLine = runesDisplayed < utf8.RuneCountInString(span.Content) - endedWithNewline = ti.hasNewline - } - } - return spanResults{ - call: call, - width: ti.bounds.Dx(), - height: ti.bounds.Dy(), - ascent: ti.baseline, - runes: runesDisplayed, - multiLine: multiLine, - endedWithNewline: endedWithNewline, - } -} - -// Layout renders the TextStyle. -// -// The spanFn function, if not nil, gets called for each span after it has been -// drawn, with the offset set to the span's top left corner. This can be used to -// set up input handling, for example. -// -// The context's maximum constraint is set to the span's dimensions, while the -// dims argument additionally provides the text's baseline. The idx argument is -// the span's index in TextStyle.Styles. The function may get called multiple -// times with the same index if a span has to be broken across multiple lines. -func (t TextStyle) Layout(gtx layout.Context, spanFn func(gtx layout.Context, idx int, dims layout.Dimensions)) layout.Dimensions { - spans := make([]SpanStyle, len(t.Styles)) - copy(spans, t.Styles) - for i := range spans { - spans[i].idx = i - } - - var ( - lineDims image.Point - lineAscent int - overallSize image.Point - lineShapes []spanShape - lineStartIndex int - ) - - for i := 0; i < len(spans); i++ { - // grab the next span - span := spans[i] - - // constrain the width of the line to the remaining space - maxWidth := gtx.Constraints.Max.X - lineDims.X - - res := t.layoutSpan(gtx, maxWidth, span) - - // forceToNextLine handles the case in which the first segment of the new span does not fit - // AND there is already content on the current line. If there is no content on the line, - // we should display the content that doesn't fit anyway, as it won't fit on the next - // line either. - forceToNextLine := lineDims.X > 0 && res.width > maxWidth - - if !forceToNextLine { - // store the text shaping results for the line - lineShapes = append(lineShapes, spanShape{ - offset: image.Point{X: lineDims.X}, - size: image.Point{X: res.width, Y: res.height}, - call: res.call, - ascent: res.ascent, - }) - // update the dimensions of the current line - lineDims.X += res.width - if lineDims.Y < res.height { - lineDims.Y = res.height - } - if lineAscent < res.ascent { - lineAscent = res.ascent - } - - // update the width of the overall text - if overallSize.X < lineDims.X { - overallSize.X = lineDims.X - } - - } - - // if we are breaking the current span across lines or we are on the - // last span, lay out all of the spans for the line. - if res.multiLine || res.endedWithNewline || i == len(spans)-1 || forceToNextLine { - lineMacro := op.Record(gtx.Ops) - for i, shape := range lineShapes { - // lay out this span - span = spans[i+lineStartIndex] - shape.offset.Y = overallSize.Y - span.Layout(gtx, shape) - - if spanFn == nil { - continue - } - offStack := op.Offset(shape.offset).Push(gtx.Ops) - fnGtx := gtx - fnGtx.Constraints.Min = image.Point{} - fnGtx.Constraints.Max = shape.size - spanFn(fnGtx, span.idx, layout.Dimensions{Size: shape.size, Baseline: shape.ascent}) - offStack.Pop() - } - lineCall := lineMacro.Stop() - - // Compute padding to align line. If the line is longer than can be displayed then padding is implicitly - // limited to zero. - finalShape := lineShapes[len(lineShapes)-1] - lineWidth := finalShape.offset.X + finalShape.size.X - var pad int - if lineWidth < gtx.Constraints.Max.X { - switch t.Alignment { - case text.Start: - pad = 0 - case text.Middle: - pad = (gtx.Constraints.Max.X - lineWidth) / 2 - case text.End: - pad = gtx.Constraints.Max.X - lineWidth - } - } - - stack := op.Offset(image.Pt(pad, 0)).Push(gtx.Ops) - lineCall.Add(gtx.Ops) - stack.Pop() - - // reset line shaping data and update overall vertical dimensions - lineShapes = lineShapes[:0] - overallSize.Y += lineDims.Y - lineDims = image.Point{} - lineAscent = 0 - } - - // if the current span breaks across lines - if res.multiLine && !forceToNextLine { - // mark where the next line to be laid out starts - lineStartIndex = i + 1 - - // ensure the spans slice has room for another span - spans = append(spans, SpanStyle{}) - // shift existing spans further - for k := len(spans) - 1; k > i+1; k-- { - spans[k] = spans[k-1] - } - // synthesize and insert a new span - byteLen := 0 - for i := 0; i < res.runes; i++ { - _, n := utf8.DecodeRuneInString(span.Content[byteLen:]) - byteLen += n - } - span.Content = span.Content[byteLen:] - spans[i+1] = span - } else if forceToNextLine { - // mark where the next line to be laid out starts - lineStartIndex = i - i-- - } else if res.endedWithNewline { - // mark where the next line to be laid out starts - lineStartIndex = i + 1 - } - } - - return layout.Dimensions{Size: gtx.Constraints.Constrain(overallSize)} -} diff --git a/vendor/github.com/oligo/gioview/editor/buffer.go b/vendor/github.com/oligo/gioview/editor/buffer.go index 0a5787cc..060fb02c 100644 --- a/vendor/github.com/oligo/gioview/editor/buffer.go +++ b/vendor/github.com/oligo/gioview/editor/buffer.go @@ -3,6 +3,7 @@ package editor import ( + "bytes" "io" "unicode/utf8" @@ -11,9 +12,6 @@ import ( // editBuffer implements a gap buffer for text editing. type editBuffer struct { - // pos is the byte position for Read and ReadRune. - pos int - // The gap start and end in bytes. gapstart, gapend int text []byte @@ -129,3 +127,24 @@ func (e *editBuffer) prepend(caret int, s string) { e.gapstart += len(s) e.changed = e.changed || len(s) > 0 } + +func (e *editBuffer) countLinesBeforeOffset(byteOffset int64) int { + cnt := 0 + + if byteOffset >= int64(len(e.text)) { + byteOffset = int64(len(e.text)) + } + + offset := 0 + for { + index := bytes.IndexByte(e.text[offset:byteOffset], '\n') + if index == -1 { + break + } + offset += index + cnt++ + offset++ // Move past the newline + } + + return cnt +} diff --git a/vendor/github.com/oligo/gioview/editor/editor.go b/vendor/github.com/oligo/gioview/editor/editor.go index af551fd3..ef2eb019 100644 --- a/vendor/github.com/oligo/gioview/editor/editor.go +++ b/vendor/github.com/oligo/gioview/editor/editor.go @@ -42,7 +42,13 @@ type Editor struct { // LineHeightScale is multiplied by LineHeight to determine the final gap // between baselines. If zero, a sensible default will be used. LineHeightScale float32 - + // SingleLine force the text to stay on a single line. + // SingleLine also sets the scrolling direction to + // horizontal. + SingleLine bool + // Submit enabled translation of carriage return keys to SubmitEvents. + // If not enabled, carriage returns are inserted as newlines in the text. + Submit bool // ReadOnly controls whether the contents of the editor can be altered by // user interaction. If set to true, the editor will allow selecting text // and copying it interactively, but not modifying it. @@ -58,6 +64,11 @@ type Editor struct { // WrapPolicy configures how displayed text will be broken into lines. WrapPolicy text.WrapPolicy + // Keep editor focused is set to true, the editor will keep the focus. + // This is useful when the editor is used with a menu. so even when menu is focused, the editor will highlight the + // selected text. + KeepFocus bool + buffer *editBuffer textStyles []*TextStyle // scratch is a byte buffer that is reused to efficiently read portions of text @@ -105,6 +116,17 @@ type imeState struct { type selectionAction int +type LineInfo struct { + // line number starting from 1. + LineNum int + // offset in the cross axis. + YOffset int + // offset of the start rune the line. + Start int + // offset of the end rune the line. + End int +} + const ( selectionExtend selectionAction = iota selectionClear @@ -117,6 +139,12 @@ type EditorEvent interface { // A ChangeEvent is generated for every user change to the text. type ChangeEvent struct{} +// A SubmitEvent is generated when Submit is set +// and a carriage return key is pressed. +type SubmitEvent struct { + Text string +} + // A SelectEvent is generated when the user selects some text, or changes the // selection (e.g. with a shift-click), including if they remove the // selection. The selected text is not part of the event, on the theory that @@ -163,22 +191,38 @@ func (e *Editor) processEvents(gtx layout.Context) (ev EditorEvent, ok bool) { func (e *Editor) processPointer(gtx layout.Context) (EditorEvent, bool) { sbounds := e.text.ScrollBounds() var smin, smax int - axis := gesture.Vertical - smin, smax = sbounds.Min.Y, sbounds.Max.Y + var axis gesture.Axis + if e.SingleLine { + axis = gesture.Horizontal + smin, smax = sbounds.Min.X, sbounds.Max.X + } else { + axis = gesture.Vertical + smin, smax = sbounds.Min.Y, sbounds.Max.Y + } var scrollX, scrollY pointer.ScrollRange textDims := e.text.FullDimensions() visibleDims := e.text.Dimensions() - scrollOffY := e.text.ScrollOff().Y - scrollY.Min = -scrollOffY - scrollY.Max = max(0, textDims.Size.Y-(scrollOffY+visibleDims.Size.Y)) + if e.SingleLine { + scrollOffX := e.text.ScrollOff().X + scrollX.Min = min(-scrollOffX, 0) + scrollX.Max = max(0, textDims.Size.X-(scrollOffX+visibleDims.Size.X)) + } else { + scrollOffY := e.text.ScrollOff().Y + scrollY.Min = -scrollOffY + scrollY.Max = max(0, textDims.Size.Y-(scrollOffY+visibleDims.Size.Y)) + } sdist := e.scroller.Update(gtx.Metric, gtx.Source, gtx.Now, axis, scrollX, scrollY) var soff int - - e.text.ScrollRel(0, sdist) - soff = e.text.ScrollOff().Y + if e.SingleLine { + e.text.ScrollRel(sdist, 0) + soff = e.text.ScrollOff().X + } else { + e.text.ScrollRel(0, sdist) + soff = e.text.ScrollOff().Y + } for { evt, ok := e.clicker.Update(gtx.Source) @@ -220,6 +264,9 @@ func (e *Editor) processPointerEvent(gtx layout.Context, ev event.Event) (Editor Y: int(math.Round(float64(evt.Position.Y))), }) gtx.Execute(key.FocusCmd{Tag: e}) + if !e.ReadOnly { + gtx.Execute(key.SoftKeyboardCmd{Show: true}) + } if e.scroller.State() != gesture.StateFlinging { e.scrollCaret = true } @@ -243,8 +290,8 @@ func (e *Editor) processPointerEvent(gtx layout.Context, ev event.Event) (Editor e.text.MoveWord(1, selectionExtend) e.dragging = false case evt.NumClicks >= 3: - e.text.MoveStart(selectionClear) - e.text.MoveEnd(selectionExtend) + e.text.MoveLineStart(selectionClear) + e.text.MoveLineEnd(selectionExtend) e.dragging = false } } @@ -305,8 +352,8 @@ func (e *Editor) processKey(gtx layout.Context) (EditorEvent, bool) { key.Filter{Focus: e, Name: key.NameDeleteBackward, Optional: key.ModShortcutAlt | key.ModShift}, key.Filter{Focus: e, Name: key.NameDeleteForward, Optional: key.ModShortcutAlt | key.ModShift}, - key.Filter{Focus: e, Name: key.NameHome, Optional: key.ModShift}, - key.Filter{Focus: e, Name: key.NameEnd, Optional: key.ModShift}, + key.Filter{Focus: e, Name: key.NameHome, Optional: key.ModShortcut | key.ModShift}, + key.Filter{Focus: e, Name: key.NameEnd, Optional: key.ModShortcut | key.ModShift}, key.Filter{Focus: e, Name: key.NamePageDown, Optional: key.ModShift}, key.Filter{Focus: e, Name: key.NamePageUp, Optional: key.ModShift}, key.Filter{Focus: e, Name: key.NameTab}, @@ -327,13 +374,21 @@ func (e *Editor) processKey(gtx layout.Context) (EditorEvent, bool) { case key.FocusEvent: // Reset IME state. e.ime.imeState = imeState{} - if ke.Focus { + if ke.Focus && !e.ReadOnly { gtx.Execute(key.SoftKeyboardCmd{Show: true}) } case key.Event: if !gtx.Focused(e) || ke.State != key.Press { break } + if !e.ReadOnly && e.Submit && (ke.Name == key.NameReturn || ke.Name == key.NameEnter) { + if !ke.Modifiers.Contain(key.ModShift) { + e.scratch = e.text.Text(e.scratch) + return SubmitEvent{ + Text: string(e.scratch), + }, true + } + } e.scrollCaret = true e.scroller.Stop() ev, ok := e.command(gtx, ke) @@ -349,10 +404,33 @@ func (e *Editor) processKey(gtx layout.Context) (EditorEvent, bool) { e.scrollCaret = true e.scroller.Stop() s := ke.Text - moves := e.replace(ke.Range.Start, ke.Range.End, s, true) + moves := 0 + submit := false + switch { + case e.Submit: + if i := strings.IndexByte(s, '\n'); i != -1 { + submit = true + moves += len(s) - i + s = s[:i] + } + case e.SingleLine: + s = strings.ReplaceAll(s, "\n", " ") + } + moves += e.replace(ke.Range.Start, ke.Range.End, s, true) adjust += utf8.RuneCountInString(ke.Text) - moves // Reset caret xoff. e.text.MoveCaret(0, 0) + if submit { + e.scratch = e.text.Text(e.scratch) + submitEvent := SubmitEvent{ + Text: string(e.scratch), + } + if e.text.Changed() { + e.pending = append(e.pending, submitEvent) + return ChangeEvent{}, true + } + return submitEvent, true + } // Complete a paste event, initiated by Shortcut-V in Editor.command(). case transfer.DataEvent: e.scrollCaret = true @@ -422,6 +500,10 @@ func (e *Editor) command(gtx layout.Context, k key.Event) (EditorEvent, bool) { } } } + case key.NameHome: + e.text.MoveTextStart(selAct) + case key.NameEnd: + e.text.MoveTextEnd(selAct) } return nil, false } @@ -483,14 +565,9 @@ func (e *Editor) command(gtx layout.Context, k key.Event) (EditorEvent, bool) { case key.NamePageDown: e.text.MovePages(+1, selAct) case key.NameHome: - e.text.MoveStart(selAct) + e.text.MoveLineStart(selAct) case key.NameEnd: - e.text.MoveEnd(selAct) - case key.NameTab: - if !e.ReadOnly { - // soft tab as 4 spaces - e.Insert(" ") - } + e.text.MoveLineEnd(selAct) } return nil, false } @@ -507,6 +584,7 @@ func (e *Editor) initBuffer() { e.text.LineHeight = e.LineHeight e.text.LineHeightScale = e.LineHeightScale e.text.WrapPolicy = e.WrapPolicy + e.text.SingleLine = e.SingleLine } // Update the state of the editor in response to input events. Update consumes editor @@ -541,7 +619,7 @@ func (e *Editor) Update(gtx layout.Context) (EditorEvent, bool) { // Layout lays out the editor using the provided textMaterial as the paint material // for the text glyphs+caret and the selectMaterial as the paint material for the // selection rectangle. -func (e *Editor) Layout(gtx layout.Context, lt *text.Shaper, font font.Font, size unit.Sp, textMaterial, selectMaterial op.CallOp) layout.Dimensions { +func (e *Editor) Layout(gtx layout.Context, lt *text.Shaper, font font.Font, size unit.Sp, textMaterial, selectMaterial op.CallOp, lineMaterial op.CallOp) layout.Dimensions { for { _, ok := e.Update(gtx) if !ok { @@ -550,7 +628,7 @@ func (e *Editor) Layout(gtx layout.Context, lt *text.Shaper, font font.Font, siz } e.text.Layout(gtx, lt, font, size) - return e.layout(gtx, textMaterial, selectMaterial) + return e.layout(gtx, textMaterial, selectMaterial, lineMaterial) } // updateSnippet queues a key.SnippetCmd if the snippet content or position @@ -596,7 +674,7 @@ func (e *Editor) updateSnippet(gtx layout.Context, start, end int) { gtx.Execute(key.SnippetCmd{Tag: e, Snippet: newSnip}) } -func (e *Editor) layout(gtx layout.Context, textMaterial, selectMaterial op.CallOp) layout.Dimensions { +func (e *Editor) layout(gtx layout.Context, textMaterial, selectMaterial op.CallOp, lineMaterial op.CallOp) layout.Dimensions { // Adjust scrolling for new viewport and layout. e.text.ScrollRel(0, 0) @@ -631,6 +709,7 @@ func (e *Editor) layout(gtx layout.Context, textMaterial, selectMaterial op.Call if e.Len() > 0 { e.paintSelection(gtx, selectMaterial) e.paintText(gtx, textMaterial) + e.paintLineHighlight(gtx, lineMaterial) } if gtx.Enabled() { e.paintCaret(gtx, textMaterial) @@ -643,9 +722,9 @@ func (e *Editor) layout(gtx layout.Context, textMaterial, selectMaterial op.Call func (e *Editor) paintSelection(gtx layout.Context, material op.CallOp) { e.initBuffer() // comment below code to ensure selected text is highlighted when editor menu poped up. - // if !gtx.Focused(e) { - // return - // } + if !gtx.Focused(e) && !e.KeepFocus { + return + } e.text.PaintSelection(gtx, material) } @@ -666,6 +745,11 @@ func (e *Editor) paintCaret(gtx layout.Context, material op.CallOp) { e.text.PaintCaret(gtx, material) } +func (e *Editor) paintLineHighlight(gtx layout.Context, material op.CallOp) { + e.initBuffer() + e.text.paintLineHighlight(gtx, material) +} + // Len is the length of the editor contents, in runes. func (e *Editor) Len() int { e.initBuffer() @@ -681,6 +765,9 @@ func (e *Editor) Text() string { func (e *Editor) SetText(s string, addHistory bool) { e.initBuffer() + if e.SingleLine { + s = strings.ReplaceAll(s, "\n", " ") + } // disable history when loading doc. In other case history might be required e.replace(0, e.text.Len(), s, addHistory) // Reset xoff and move the caret to the beginning. @@ -729,6 +816,9 @@ func (e *Editor) Delete(graphemeClusters int) (deletedRunes int) { func (e *Editor) Insert(s string) (insertedRunes int) { e.initBuffer() + if e.SingleLine { + s = strings.ReplaceAll(s, "\n", " ") + } start, end := e.text.Selection() moves := e.replace(start, end, s, true) if end < start { @@ -1005,6 +1095,11 @@ func (e *Editor) UpdateTextStyles(styles []*TextStyle) { e.textStyles = styles } +func (e *Editor) VisibleLines() ([]*LineInfo, error) { + e.initBuffer() + return e.text.VisibleLines() +} + func max(a, b int) int { if a > b { return a @@ -1039,3 +1134,4 @@ func sign(n int) int { func (s ChangeEvent) isEditorEvent() {} func (s SelectEvent) isEditorEvent() {} +func (s SubmitEvent) isEditorEvent() {} diff --git a/vendor/github.com/oligo/gioview/editor/editor_style.go b/vendor/github.com/oligo/gioview/editor/editor_style.go index a54b0479..1ffec915 100644 --- a/vendor/github.com/oligo/gioview/editor/editor_style.go +++ b/vendor/github.com/oligo/gioview/editor/editor_style.go @@ -3,15 +3,19 @@ package editor import ( + "fmt" + "image" "image/color" "gioui.org/font" "gioui.org/layout" "gioui.org/op" + "gioui.org/op/clip" "gioui.org/op/paint" "gioui.org/text" "gioui.org/unit" "gioui.org/widget" + "github.com/oligo/gioview/misc" ) type EditorStyle struct { @@ -31,16 +35,35 @@ type EditorStyle struct { HintColor color.NRGBA // SelectionColor is the color of the background for selected text. SelectionColor color.NRGBA - Editor *Editor + //LineHighlightColor is the color used to highlight the clicked logical line. + // If not set, line will not be highlighted. + LineHighlightColor color.NRGBA - shaper *text.Shaper + Editor *Editor + ShowLineNum bool + + shaper *text.Shaper + lineBar *lineNumberBar +} + +type lineNumberBar struct { + shaper *text.Shaper + lineHeight unit.Sp + lineHeightScale float32 + // Color is the text color. + color color.NRGBA + typeFace font.Typeface + textSize unit.Sp + // padding between line number and the editor content. + padding unit.Dp } type EditorConf struct { - Shaper *text.Shaper - TextColor color.NRGBA - Bg color.NRGBA - SelectionColor color.NRGBA + Shaper *text.Shaper + TextColor color.NRGBA + Bg color.NRGBA + SelectionColor color.NRGBA + LineHighlightColor color.NRGBA // typeface for editing TypeFace font.Typeface TextSize unit.Sp @@ -49,22 +72,40 @@ type EditorConf struct { LineHeightScale float32 //May be helpful for code syntax highlighting. ColorScheme string + ShowLineNum bool + // padding between line number and the editor content. + LineNumPadding unit.Dp } func NewEditor(editor *Editor, conf *EditorConf, hint string) EditorStyle { + if conf.LineNumPadding <= 0 { + conf.LineNumPadding = unit.Dp(32) + } + return EditorStyle{ Editor: editor, Font: font.Font{ Typeface: conf.TypeFace, Weight: conf.Weight, }, - LineHeightScale: conf.LineHeightScale, - TextSize: conf.TextSize, - Color: conf.TextColor, - shaper: conf.Shaper, - Hint: hint, - HintColor: MulAlpha(conf.TextColor, 0xbb), - SelectionColor: MulAlpha(conf.SelectionColor, 0x60), + LineHeightScale: conf.LineHeightScale, + TextSize: conf.TextSize, + Color: conf.TextColor, + shaper: conf.Shaper, + Hint: hint, + HintColor: MulAlpha(conf.TextColor, 0xbb), + SelectionColor: MulAlpha(conf.SelectionColor, 0x60), + LineHighlightColor: MulAlpha(conf.LineHighlightColor, 0x25), + ShowLineNum: conf.ShowLineNum, + lineBar: &lineNumberBar{ + shaper: conf.Shaper, + lineHeight: conf.LineHeight, + lineHeightScale: conf.LineHeightScale, + color: misc.WithAlpha(conf.TextColor, 0xb6), + typeFace: conf.TypeFace, + textSize: conf.TextSize, + padding: conf.LineNumPadding, + }, } } @@ -79,6 +120,9 @@ func (e EditorStyle) Layout(gtx layout.Context) layout.Dimensions { selectionColorMacro := op.Record(gtx.Ops) paint.ColorOp{Color: blendDisabledColor(!gtx.Enabled(), e.SelectionColor)}.Add(gtx.Ops) selectionColor := selectionColorMacro.Stop() + lineColorMacro := op.Record(gtx.Ops) + paint.ColorOp{Color: e.LineHighlightColor}.Add(gtx.Ops) + lineColor := lineColorMacro.Stop() macro := op.Record(gtx.Ops) tl := widget.Label{ @@ -98,10 +142,84 @@ func (e EditorStyle) Layout(gtx layout.Context) layout.Dimensions { } e.Editor.LineHeight = e.LineHeight e.Editor.LineHeightScale = e.LineHeightScale - dims = e.Editor.Layout(gtx, e.shaper, e.Font, e.TextSize, textColor, selectionColor) - if e.Editor.Len() == 0 { - call.Add(gtx.Ops) + + if !e.ShowLineNum { + d := e.Editor.Layout(gtx, e.shaper, e.Font, e.TextSize, textColor, selectionColor, lineColor) + if e.Editor.Len() == 0 { + call.Add(gtx.Ops) + } + return d } + + // clip line number bar. + defer clip.Rect(image.Rectangle{Max: gtx.Constraints.Max}).Push(gtx.Ops).Pop() + dims = layout.Flex{ + Axis: layout.Horizontal, + }.Layout(gtx, + layout.Rigid(func(gtx layout.Context) layout.Dimensions { + return e.lineBar.Layout(gtx, e.Editor) + }), + + layout.Rigid(layout.Spacer{Width: e.lineBar.padding}.Layout), + + layout.Rigid(func(gtx layout.Context) layout.Dimensions { + d := e.Editor.Layout(gtx, e.shaper, e.Font, e.TextSize, textColor, selectionColor, lineColor) + if e.Editor.Len() == 0 { + call.Add(gtx.Ops) + } + return d + }), + ) + + return dims +} + +func (bar lineNumberBar) layoutLine(gtx layout.Context, pos *LineInfo, textColor op.CallOp) layout.Dimensions { + stack := op.Offset(image.Point{Y: pos.YOffset}).Push(gtx.Ops) + + tl := widget.Label{ + Alignment: text.End, + MaxLines: 1, + LineHeight: bar.lineHeight, + LineHeightScale: bar.lineHeightScale, + } + + d := tl.Layout(gtx, bar.shaper, + font.Font{Typeface: bar.typeFace, Weight: font.Normal}, + bar.textSize, + fmt.Sprintf("%d", pos.LineNum), + textColor) + stack.Pop() + return d +} + +func (bar lineNumberBar) Layout(gtx layout.Context, e *Editor) layout.Dimensions { + dims := layout.Dimensions{Size: image.Point{X: gtx.Constraints.Min.X}} + + textColorMacro := op.Record(gtx.Ops) + paint.ColorOp{Color: bar.color}.Add(gtx.Ops) + textColor := textColorMacro.Stop() + + fake := gtx + fake.Ops = &op.Ops{} + + positions, _ := e.VisibleLines() + maxWidth := 0 + { + for _, pos := range positions { + d := bar.layoutLine(fake, pos, textColor) + maxWidth = max(maxWidth, d.Size.X) + } + + } + + gtx.Constraints.Max.X = maxWidth + gtx.Constraints.Min.X = gtx.Constraints.Max.X + for _, pos := range positions { + d := bar.layoutLine(gtx, pos, textColor) + dims.Size = image.Point{X: maxWidth, Y: dims.Size.Y + d.Size.Y} + } + return dims } diff --git a/vendor/github.com/oligo/gioview/editor/index.go b/vendor/github.com/oligo/gioview/editor/index.go index 0ee5f85f..02eaca16 100644 --- a/vendor/github.com/oligo/gioview/editor/index.go +++ b/vendor/github.com/oligo/gioview/editor/index.go @@ -347,10 +347,6 @@ type Region struct { Baseline int } -// region is identical to Region except that its coordinates are in document -// space instead of a widget coordinate space. -type region = Region - // locate returns highlight regions covering the glyphs that represent the runes in // [startRune,endRune). If the rects parameter is non-nil, locate will use it to // return results instead of allocating, provided that there is enough capacity. diff --git a/vendor/github.com/oligo/gioview/editor/text.go b/vendor/github.com/oligo/gioview/editor/text.go index 384fb4a8..419e5576 100644 --- a/vendor/github.com/oligo/gioview/editor/text.go +++ b/vendor/github.com/oligo/gioview/editor/text.go @@ -2,6 +2,7 @@ package editor import ( "bufio" + "errors" "image" "io" "math" @@ -50,7 +51,10 @@ type textView struct { // LineHeightScale applies a scaling factor to the LineHeight. If zero, a // sensible default will be used. LineHeightScale float32 - + // SingleLine forces the text to stay on a single line. + // SingleLine also sets the scrolling direction to + // horizontal. + SingleLine bool // MaxLines limits the shaped text to a specific quantity of shaped lines. MaxLines int // Truncator is the text that will be shown at the end of the final @@ -190,6 +194,129 @@ func (e *textView) closestToXYGraphemes(x fixed.Int26_6, y int) combinedPos { } } +// searchForLineRange finds the logical line range given a position in the document. +func (e *textView) searchForLineRange(screenLine int) [2]combinedPos { + // find the start pos of the screen line. + spos := e.closestToLineCol(screenLine, 0) + + var start, end combinedPos + p := spos + for { + if p.runes == 0 { + start = p + break + } + + r, _, err := e.ReadRuneBefore(int64(e.runeOffset(p.runes))) + if err != nil { + break + } + if r == rune('\n') { + start = p + break + } + p = e.index.closestToLineCol(screenPos{line: p.lineCol.line - 1, col: 0}) + } + + p = spos + for { + r, _, err := e.ReadRuneBefore(int64(e.runeOffset(p.runes))) + if err != nil { + if err == io.EOF { + end = p + } + break + } + + if (r == rune('\n') && p != start) || e.runeOffset(p.runes) == int(e.rr.Size()) { + end = p + break + } + p = e.index.closestToLineCol(screenPos{line: p.lineCol.line + 1, col: 0}) + } + + // When start line = end line, the line is a empty line, no need to + // resolve to the end rune of the logical line. + if start.lineCol.line != end.lineCol.line { + end = e.closestToRune(end.runes - 1) + } + + return [2]combinedPos{start, end} +} + +// VisibleLines finds all visible logical line positions in the viewport, marking them with line numbers. +func (e *textView) VisibleLines() ([]*LineInfo, error) { + e.makeValid() + if e.viewSize.Y <= 0 { + return nil, nil + } + + firstPos := e.closestToXYGraphemes(0, e.scrollOff.Y) + lastPos := e.closestToXYGraphemes(0, e.viewSize.Y+e.scrollOff.Y) + firstRng := e.searchForLineRange(firstPos.lineCol.line) + lastRng := e.searchForLineRange(lastPos.lineCol.line) + + linePos := append([][2]combinedPos{}, firstRng) + + // check the succeeding screen lines + pos := firstRng[1] + for pos.runes < lastRng[0].runes { + lineRng := e.searchForLineRange(pos.lineCol.line + 1) + linePos = append(linePos, lineRng) + pos = lineRng[1] + } + + if len(linePos) <= 0 { + return nil, errors.New("no lines found") + } + + lines := make([]*LineInfo, 0) + for idx, rng := range linePos { + if idx == 0 { + if rng[0].lineCol.line == 0 { + lines = append(lines, &LineInfo{ + LineNum: 1, + YOffset: rng[0].y - rng[0].ascent.Ceil(), + Start: rng[0].runes, + End: rng[1].runes, + }) + } else { + startLine := e.rr.(*editBuffer).countLinesBeforeOffset(int64(e.runeOffset(rng[0].runes))) + lines = append(lines, &LineInfo{ + LineNum: startLine + 1, + YOffset: rng[0].y - e.ScrollOff().Y - rng[0].ascent.Ceil(), + Start: rng[0].runes, + End: rng[1].runes, + }) + } + + continue + } + + lines = append(lines, &LineInfo{ + LineNum: lines[idx-1].LineNum + 1, + YOffset: rng[0].y - e.ScrollOff().Y - rng[0].ascent.Ceil(), + Start: rng[0].runes, + End: rng[1].runes, + }) + + } + + return lines, nil +} + +// caretCurrentLine returns the current logical line that the carent is in. +// Only the start position is checked. +func (e *textView) caretCurrentLine() (start combinedPos, end combinedPos) { + caretStart := e.closestToRune(e.caret.start) + + linePos := e.searchForLineRange(caretStart.lineCol.line) + + start = linePos[0] + end = linePos[1] + return +} + func absFixed(i fixed.Int26_6) fixed.Int26_6 { if i < 0 { return -i @@ -234,6 +361,9 @@ func (e *textView) Layout(gtx layout.Context, lt *text.Shaper, font font.Font, s e.params.PxPerEm = textSize } maxWidth := gtx.Constraints.Max.X + if e.SingleLine { + maxWidth = math.MaxInt + } minWidth := gtx.Constraints.Min.X if maxWidth != e.params.MaxWidth { @@ -297,6 +427,27 @@ func (e *textView) PaintSelection(gtx layout.Context, material op.CallOp) { } } +// paintLineHighlight clips and paints the visible line that the caret is in when there is no +// text selected. +func (e *textView) paintLineHighlight(gtx layout.Context, material op.CallOp) { + if e.caret.start != e.caret.end { + return + } + + start, end := e.caretCurrentLine() + if start == (combinedPos{}) || end == (combinedPos{}) { + return + } + + bounds := image.Rectangle{Min: image.Point{X: 0, Y: start.y - start.ascent.Ceil()}, + Max: image.Point{X: e.viewSize.X, Y: end.y + end.descent.Ceil()}}.Sub(e.scrollOff) + + area := clip.Rect(bounds).Push(gtx.Ops) + material.Add(gtx.Ops) + paint.PaintOp{}.Add(gtx.Ops) + area.Pop() +} + // PaintText clips and paints the visible text glyph outlines using the provided // material to fill the glyphs. func (e *textView) PaintText(gtx layout.Context, material op.CallOp, textStyles []*TextStyle) { @@ -406,8 +557,18 @@ func (e *textView) Text(buf []byte) []byte { func (e *textView) ScrollBounds() image.Rectangle { var b image.Rectangle - b.Max.Y = e.dims.Size.Y - e.viewSize.Y - + if e.SingleLine { + if len(e.index.lines) > 0 { + line := e.index.lines[0] + b.Min.X = line.xOff.Floor() + if b.Min.X > 0 { + b.Min.X = 0 + } + } + b.Max.X = e.dims.Size.X + b.Min.X - e.viewSize.X + } else { + b.Max.Y = e.dims.Size.Y - e.viewSize.Y + } return b } @@ -614,9 +775,28 @@ func (e *textView) MoveCaret(startDelta, endDelta int) { e.caret.end = e.moveByGraphemes(e.caret.end, endDelta) } -// MoveStart moves the caret to the start of the current line, ensuring that the resulting +// MoveTextStart moves the caret to the start of the text. +func (e *textView) MoveTextStart(selAct selectionAction) { + caret := e.closestToRune(e.caret.end) + e.caret.start = 0 + e.caret.end = caret.runes + e.caret.xoff = -caret.x + e.updateSelection(selAct) + e.clampCursorToGraphemes() +} + +// MoveTextEnd moves the caret to the end of the text. +func (e *textView) MoveTextEnd(selAct selectionAction) { + caret := e.closestToRune(math.MaxInt) + e.caret.start = caret.runes + e.caret.xoff = fixed.I(e.params.MaxWidth) - caret.x + e.updateSelection(selAct) + e.clampCursorToGraphemes() +} + +// MoveLineStart moves the caret to the start of the current line, ensuring that the resulting // cursor position is on a grapheme cluster boundary. -func (e *textView) MoveStart(selAct selectionAction) { +func (e *textView) MoveLineStart(selAct selectionAction) { caret := e.closestToRune(e.caret.start) caret = e.closestToLineCol(caret.lineCol.line, 0) e.caret.start = caret.runes @@ -625,9 +805,9 @@ func (e *textView) MoveStart(selAct selectionAction) { e.clampCursorToGraphemes() } -// MoveEnd moves the caret to the end of the current line, ensuring that the resulting +// MoveLineEnd moves the caret to the end of the current line, ensuring that the resulting // cursor position is on a grapheme cluster boundary. -func (e *textView) MoveEnd(selAct selectionAction) { +func (e *textView) MoveLineEnd(selAct selectionAction) { caret := e.closestToRune(e.caret.start) caret = e.closestToLineCol(caret.lineCol.line, math.MaxInt) e.caret.start = caret.runes @@ -684,16 +864,25 @@ func (e *textView) MoveWord(distance int, selAct selectionAction) { func (e *textView) ScrollToCaret() { caret := e.closestToRune(e.caret.start) - - miny := caret.y - caret.ascent.Ceil() - maxy := caret.y + caret.descent.Ceil() - var dist int - if d := miny - e.scrollOff.Y; d < 0 { - dist = d - } else if d := maxy - (e.scrollOff.Y + e.viewSize.Y); d > 0 { - dist = d + if e.SingleLine { + var dist int + if d := caret.x.Floor() - e.scrollOff.X; d < 0 { + dist = d + } else if d := caret.x.Ceil() - (e.scrollOff.X + e.viewSize.X); d > 0 { + dist = d + } + e.ScrollRel(dist, 0) + } else { + miny := caret.y - caret.ascent.Ceil() + maxy := caret.y + caret.descent.Ceil() + var dist int + if d := miny - e.scrollOff.Y; d < 0 { + dist = d + } else if d := maxy - (e.scrollOff.Y + e.viewSize.Y); d > 0 { + dist = d + } + e.ScrollRel(0, dist) } - e.ScrollRel(0, dist) } // SelectionLen returns the length of the selection, in runes; it is diff --git a/vendor/github.com/oligo/gioview/editor/text_iterator.go b/vendor/github.com/oligo/gioview/editor/text_iterator.go index accc8afb..2cf75347 100644 --- a/vendor/github.com/oligo/gioview/editor/text_iterator.go +++ b/vendor/github.com/oligo/gioview/editor/text_iterator.go @@ -193,7 +193,7 @@ func (it *textIterator) groupGlyphs(line []glyphStyle) []*glyphSpan { for _, s := range line { span := spans[idx] if len(span.glyphs) <= 0 { - span.addFirstGlyph(s, it.lineOff) + span.addFirstGlyph(s, float32(it.viewport.Min.X)+it.lineOff.X) continue } @@ -204,7 +204,7 @@ func (it *textIterator) groupGlyphs(line []glyphStyle) []*glyphSpan { idx++ spans = append(spans, &glyphSpan{}) span := spans[idx] - span.addFirstGlyph(s, it.lineOff) + span.addFirstGlyph(s, float32(it.viewport.Min.X)+it.lineOff.X) } } @@ -212,13 +212,13 @@ func (it *textIterator) groupGlyphs(line []glyphStyle) []*glyphSpan { return spans } -func (span *glyphSpan) addFirstGlyph(s glyphStyle, lineOff f32.Point) { +func (span *glyphSpan) addFirstGlyph(s glyphStyle, lineOff float32) { span.glyphs = append(span.glyphs, s.g) span.fg = s.fg span.bg = s.bg // offset is where the first glyph character starts // thanks to setting an offset, the rectangle and the glyph can be drawn from X: 0 - span.offset = float32(s.g.X.Floor() - lineOff.Round().X) + span.offset = fixedToFloat(s.g.X) - lineOff } func (span *glyphSpan) calculateBgRect() clip.Rect { diff --git a/vendor/github.com/oligo/gioview/misc/base.go b/vendor/github.com/oligo/gioview/misc/base.go new file mode 100644 index 00000000..fbc475a5 --- /dev/null +++ b/vendor/github.com/oligo/gioview/misc/base.go @@ -0,0 +1,79 @@ +package misc + +import ( + "image" + "image/color" + + "github.com/oligo/gioview/theme" + + "gioui.org/layout" + "gioui.org/text" + "gioui.org/unit" + "gioui.org/widget" + "gioui.org/widget/material" +) + +type ( + C = layout.Context + D = layout.Dimensions +) + +type Icon struct { + *widget.Icon + Color color.NRGBA + Size unit.Dp +} + +func (i Icon) Layout(gtx C, th *theme.Theme) D { + if i.Size <= 0 { + i.Size = unit.Dp(18) + } + if i.Color == (color.NRGBA{}) { + i.Color = WithAlpha(th.Palette.Fg, 0xb6) + } + + iconSize := gtx.Dp(i.Size) + gtx.Constraints = layout.Exact(image.Pt(iconSize, iconSize)) + + return i.Icon.Layout(gtx, i.Color) +} + +func IconButton(th *theme.Theme, icon *widget.Icon, button *widget.Clickable, description string) material.IconButtonStyle { + return material.IconButtonStyle{ + Background: th.Palette.Bg, + Color: WithAlpha(th.Palette.Fg, 0xb6), + Icon: icon, + Size: 18, + Inset: layout.UniformInset(4), + Button: button, + Description: description, + } +} + +func LayoutErrorLabel(gtx C, th *theme.Theme, err error) D { + if err != nil { + return layout.Inset{ + Top: unit.Dp(10), + Bottom: unit.Dp(10), + Left: unit.Dp(15), + Right: unit.Dp(15), + }.Layout(gtx, func(gtx C) D { + label := material.Label(th.Theme, th.TextSize*0.8, err.Error()) + label.Color = color.NRGBA{R: 255, A: 255} + label.Alignment = text.Middle + return label.Layout(gtx) + }) + } else { + return layout.Dimensions{} + } +} + +// WithAlpha returns the input color with the new alpha value. +func WithAlpha(c color.NRGBA, a uint8) color.NRGBA { + return color.NRGBA{ + R: c.R, + G: c.G, + B: c.B, + A: a, + } +} diff --git a/vendor/github.com/oligo/gioview/misc/color.go b/vendor/github.com/oligo/gioview/misc/color.go new file mode 100644 index 00000000..d6bbf535 --- /dev/null +++ b/vendor/github.com/oligo/gioview/misc/color.go @@ -0,0 +1,67 @@ +package misc + +import ( + "fmt" + "image/color" + "strconv" + "strings" +) + +type Color struct { + color.NRGBA +} + +func argb(c uint32) color.NRGBA { + return color.NRGBA{A: uint8(c >> 24), R: uint8(c >> 16), G: uint8(c >> 8), B: uint8(c)} +} + +// construct a Color from hex string, int, or wrapping a NRGBA. +func NewColor(value interface{}) Color { + switch value := value.(type) { + case color.NRGBA: + return Color{ + NRGBA: value, + } + case string: + if !strings.HasPrefix(value, "#") || len(value) < 7 { + return Color{} + } + + value = strings.TrimPrefix(value, "#") + bitSize := 24 + if len(value) == 6 { + bitSize = 24 + } else if len(value) == 8 { + bitSize = 32 + } + + val, err := strconv.ParseUint(value, 16, bitSize) + if err != nil { + return Color{} + } + + return Color{ + NRGBA: argb(0xff000000 | uint32(val)), + } + + case uint32: + return Color{ + NRGBA: argb(0xff000000 | value), + } + case int: + return Color{ + NRGBA: argb(0xff000000 | uint32(value)), + } + default: + panic("wrong color value type: " + fmt.Sprintf("%T", value)) + } +} + +// Calculate relative luminance of a RGBA color. +func (c Color) Luminance() float32 { + return float32(c.R)*0.2126 + float32(c.G)*0.7152 + float32(c.B)*0.0722 +} + +func HexColor(v interface{}) color.NRGBA { + return NewColor(v).NRGBA +} diff --git a/vendor/github.com/oligo/gioview/misc/divider.go b/vendor/github.com/oligo/gioview/misc/divider.go new file mode 100644 index 00000000..88a47f29 --- /dev/null +++ b/vendor/github.com/oligo/gioview/misc/divider.go @@ -0,0 +1,53 @@ +package misc + +import ( + "image" + "image/color" + + "github.com/oligo/gioview/theme" + + "gioui.org/layout" + "gioui.org/op/clip" + "gioui.org/op/paint" + "gioui.org/unit" +) + +type DividerStyle struct { + Thickness unit.Dp + Fill color.NRGBA + Inset layout.Inset + Axis layout.Axis +} + +func (d *DividerStyle) Layout(gtx layout.Context, th *theme.Theme) layout.Dimensions { + if (d.Axis == layout.Horizontal && gtx.Constraints.Min.X == 0) || + (d.Axis == layout.Vertical && gtx.Constraints.Min.Y == 0) { + return D{} + } + + if d.Fill == (color.NRGBA{}) { + d.Fill = WithAlpha(th.Fg, 0x60) + } + + return d.Inset.Layout(gtx, func(gtx C) D { + weight := gtx.Dp(d.Thickness) + + var maxDim = image.Point{} + if d.Axis == layout.Horizontal { + maxDim = image.Pt(gtx.Constraints.Min.X, weight) + } else { + maxDim = image.Pt(weight, gtx.Constraints.Min.Y) + } + + line := image.Rectangle{Max: maxDim} + paint.FillShape(gtx.Ops, d.Fill, clip.Rect(line).Op()) + return D{Size: line.Max} + }) +} + +func Divider(axis layout.Axis, thickness unit.Dp) *DividerStyle { + return &DividerStyle{ + Thickness: thickness, + Axis: axis, + } +} diff --git a/vendor/github.com/oligo/gioview/theme/fonts.go b/vendor/github.com/oligo/gioview/theme/fonts.go new file mode 100644 index 00000000..e6ee2861 --- /dev/null +++ b/vendor/github.com/oligo/gioview/theme/fonts.go @@ -0,0 +1,95 @@ +package theme + +import ( + _ "embed" + "fmt" + "log" + "os" + "path/filepath" + "slices" + + "gioui.org/font" + "gioui.org/font/gofont" + "gioui.org/font/opentype" + "gioui.org/text" +) + +var fontExts = []string{".otf", ".otc", ".ttf", ".ttc"} + +// LoadBuiltin loads fonts from the belowing sources: +// 1. The provided dir. +// 2. embedded font bytes. +// 3. The Gio builtin Go font collection. +func LoadBuiltin(fontDir string, embeddedFonts [][]byte) []font.FontFace { + var fonts []font.FontFace + fonts = append(fonts, gofont.Collection()...) + + // load embedded fonts: + for _, f := range embeddedFonts { + face, err := loadFont(f) + if err != nil { + log.Printf("loading embedded font failed: %v", err) + } + + fonts = append(fonts, *face) + } + + fonts = append(fonts, loadFromFs(fontDir)...) + + for _, f := range fonts { + log.Printf("loaded builtin font face: %s, style: %s, weight: %s", f.Font.Typeface, f.Font.Style, f.Font.Weight) + } + + return fonts +} + +// load fonts from directory +func loadFromFs(fontDir string) []font.FontFace { + if st, err := os.Stat(fontDir); err != nil || os.IsNotExist(err) || !st.IsDir() { + return nil + } + + var fonts []font.FontFace + + entries, err := os.ReadDir(fontDir) + if err != nil { + log.Printf("loading fonts from dir failed: %v", err) + return fonts + } + + for _, entry := range entries { + if entry.IsDir() { + continue + } + filename := entry.Name() + if !slices.Contains(fontExts, filepath.Ext(filename)) { + continue + } + ttfData, err := os.ReadFile(filepath.Join(fontDir, filename)) + if err != nil { + log.Printf("read font %s from dir failed: %v", filename, err) + continue + } + + face, err := loadFont(ttfData) + if err != nil { + log.Printf("loading font %s failed: %v", filename, err) + continue + } + fonts = append(fonts, *face) + } + + return fonts +} + +func loadFont(ttf []byte) (*font.FontFace, error) { + faces, err := opentype.ParseCollection(ttf) + if err != nil { + return nil, fmt.Errorf("failed to parse font: %v", err) + } + + return &text.FontFace{ + Font: faces[0].Font, + Face: faces[0].Face, + }, nil +} diff --git a/vendor/github.com/oligo/gioview/theme/theme.go b/vendor/github.com/oligo/gioview/theme/theme.go new file mode 100644 index 00000000..da41a794 --- /dev/null +++ b/vendor/github.com/oligo/gioview/theme/theme.go @@ -0,0 +1,124 @@ +package theme + +import ( + "fmt" + "image/color" + "reflect" + + "gioui.org/text" + "gioui.org/widget/material" +) + +var ( + DefaultHover = 48 + DefaultSelected = 96 +) + +type Palette struct { + // Bg is the background color atop which content is currently being + // drawn. + Bg color.NRGBA + + // Fg is a color suitable for drawing on top of Bg. + Fg color.NRGBA + + // ContrastBg is a color used to draw attention to active, + // important, interactive widgets such as buttons. + ContrastBg color.NRGBA + + // ContrastFg is a color suitable for content drawn on top of + // ContrastBg. + ContrastFg color.NRGBA + + // Bg2 specifies the background color for components like navibar + Bg2 color.NRGBA + + HoverAlpha, SelectedAlpha uint8 +} + +type SubThemeID string + +type Theme struct { + *material.Theme + + // Alpha is the set of alpha values to be applied for certain + // states like hover, selected, etc... + HoverAlpha, SelectedAlpha uint8 + + // Bg2 specifies the background color for components like navibar + Bg2 color.NRGBA + + // sub theme maps and their type info used to + // accept dynamic subtheme registration. + subThemes map[SubThemeID]interface{} + subThemeTypes map[SubThemeID]reflect.Type +} + +// NewTheme instantiates a theme, extending material theme. +func NewTheme(fontDir string, embeddedFonts [][]byte, noSystemFonts bool) *Theme { + th := material.NewTheme() + + var options = []text.ShaperOption{ + text.WithCollection(LoadBuiltin(fontDir, embeddedFonts)), + } + + if noSystemFonts { + options = append(options, text.NoSystemFonts()) + } + + th.Shaper = text.NewShaper(options...) + + theme := &Theme{ + Theme: th, + HoverAlpha: uint8(DefaultHover), + SelectedAlpha: uint8(DefaultSelected), + Bg2: th.Bg, + } + + return theme +} + +func (t *Theme) WithPalette(p Palette) *Theme { + t.Theme.Palette = material.Palette{ + Bg: p.Bg, + Fg: p.Fg, + ContrastFg: p.ContrastFg, + ContrastBg: p.ContrastBg, + } + + if p.HoverAlpha > 0 { + t.HoverAlpha = p.HoverAlpha + } + if p.SelectedAlpha > 0 { + t.SelectedAlpha = p.SelectedAlpha + } + + t.Bg2 = p.Bg2 + return t +} + +func (th *Theme) Register(ID SubThemeID, sub interface{}) error { + if th.subThemes == nil { + th.subThemes = make(map[SubThemeID]interface{}) + th.subThemeTypes = make(map[SubThemeID]reflect.Type) + } + + // confliction check + if t, ok := th.subThemeTypes[ID]; ok { + if t != reflect.TypeOf(sub) { + return fmt.Errorf("type %v already registered as %s", ID, t.Name()) + } + } + + th.subThemes[ID] = sub + th.subThemeTypes[ID] = reflect.TypeOf(sub) + return nil +} + +func (th *Theme) Get(ID SubThemeID) interface{} { + if _, exist := th.subThemeTypes[ID]; !exist { + panic(fmt.Sprintf("%v not registered", ID)) + } + + return th.subThemes[ID] +} diff --git a/vendor/golang.org/x/net/http/httpguts/httplex.go b/vendor/golang.org/x/net/http/httpguts/httplex.go index 6e071e85..9b4de940 100644 --- a/vendor/golang.org/x/net/http/httpguts/httplex.go +++ b/vendor/golang.org/x/net/http/httpguts/httplex.go @@ -12,7 +12,7 @@ import ( "golang.org/x/net/idna" ) -var isTokenTable = [127]bool{ +var isTokenTable = [256]bool{ '!': true, '#': true, '$': true, @@ -93,12 +93,7 @@ var isTokenTable = [127]bool{ } func IsTokenRune(r rune) bool { - i := int(r) - return i < len(isTokenTable) && isTokenTable[i] -} - -func isNotToken(r rune) bool { - return !IsTokenRune(r) + return r < utf8.RuneSelf && isTokenTable[byte(r)] } // HeaderValuesContainsToken reports whether any string in values @@ -202,8 +197,8 @@ func ValidHeaderFieldName(v string) bool { if len(v) == 0 { return false } - for _, r := range v { - if !IsTokenRune(r) { + for i := 0; i < len(v); i++ { + if !isTokenTable[v[i]] { return false } } diff --git a/vendor/golang.org/x/net/http2/frame.go b/vendor/golang.org/x/net/http2/frame.go index e2b298d8..105c3b27 100644 --- a/vendor/golang.org/x/net/http2/frame.go +++ b/vendor/golang.org/x/net/http2/frame.go @@ -490,6 +490,9 @@ func terminalReadFrameError(err error) bool { // returned error is ErrFrameTooLarge. Other errors may be of type // ConnectionError, StreamError, or anything else from the underlying // reader. +// +// If ReadFrame returns an error and a non-nil Frame, the Frame's StreamID +// indicates the stream responsible for the error. func (fr *Framer) ReadFrame() (Frame, error) { fr.errDetail = nil if fr.lastFrame != nil { @@ -1521,7 +1524,7 @@ func (fr *Framer) maxHeaderStringLen() int { // readMetaFrame returns 0 or more CONTINUATION frames from fr and // merge them into the provided hf and returns a MetaHeadersFrame // with the decoded hpack values. -func (fr *Framer) readMetaFrame(hf *HeadersFrame) (*MetaHeadersFrame, error) { +func (fr *Framer) readMetaFrame(hf *HeadersFrame) (Frame, error) { if fr.AllowIllegalReads { return nil, errors.New("illegal use of AllowIllegalReads with ReadMetaHeaders") } @@ -1564,6 +1567,7 @@ func (fr *Framer) readMetaFrame(hf *HeadersFrame) (*MetaHeadersFrame, error) { if size > remainSize { hdec.SetEmitEnabled(false) mh.Truncated = true + remainSize = 0 return } remainSize -= size @@ -1576,8 +1580,38 @@ func (fr *Framer) readMetaFrame(hf *HeadersFrame) (*MetaHeadersFrame, error) { var hc headersOrContinuation = hf for { frag := hc.HeaderBlockFragment() + + // Avoid parsing large amounts of headers that we will then discard. + // If the sender exceeds the max header list size by too much, + // skip parsing the fragment and close the connection. + // + // "Too much" is either any CONTINUATION frame after we've already + // exceeded the max header list size (in which case remainSize is 0), + // or a frame whose encoded size is more than twice the remaining + // header list bytes we're willing to accept. + if int64(len(frag)) > int64(2*remainSize) { + if VerboseLogs { + log.Printf("http2: header list too large") + } + // It would be nice to send a RST_STREAM before sending the GOAWAY, + // but the structure of the server's frame writer makes this difficult. + return mh, ConnectionError(ErrCodeProtocol) + } + + // Also close the connection after any CONTINUATION frame following an + // invalid header, since we stop tracking the size of the headers after + // an invalid one. + if invalid != nil { + if VerboseLogs { + log.Printf("http2: invalid header: %v", invalid) + } + // It would be nice to send a RST_STREAM before sending the GOAWAY, + // but the structure of the server's frame writer makes this difficult. + return mh, ConnectionError(ErrCodeProtocol) + } + if _, err := hdec.Write(frag); err != nil { - return nil, ConnectionError(ErrCodeCompression) + return mh, ConnectionError(ErrCodeCompression) } if hc.HeadersEnded() { @@ -1594,7 +1628,7 @@ func (fr *Framer) readMetaFrame(hf *HeadersFrame) (*MetaHeadersFrame, error) { mh.HeadersFrame.invalidate() if err := hdec.Close(); err != nil { - return nil, ConnectionError(ErrCodeCompression) + return mh, ConnectionError(ErrCodeCompression) } if invalid != nil { fr.errDetail = invalid diff --git a/vendor/golang.org/x/net/http2/pipe.go b/vendor/golang.org/x/net/http2/pipe.go index 684d984f..3b9f06b9 100644 --- a/vendor/golang.org/x/net/http2/pipe.go +++ b/vendor/golang.org/x/net/http2/pipe.go @@ -77,7 +77,10 @@ func (p *pipe) Read(d []byte) (n int, err error) { } } -var errClosedPipeWrite = errors.New("write on closed buffer") +var ( + errClosedPipeWrite = errors.New("write on closed buffer") + errUninitializedPipeWrite = errors.New("write on uninitialized buffer") +) // Write copies bytes from p into the buffer and wakes a reader. // It is an error to write more data than the buffer can hold. @@ -91,6 +94,12 @@ func (p *pipe) Write(d []byte) (n int, err error) { if p.err != nil || p.breakErr != nil { return 0, errClosedPipeWrite } + // pipe.setBuffer is never invoked, leaving the buffer uninitialized. + // We shouldn't try to write to an uninitialized pipe, + // but returning an error is better than panicking. + if p.b == nil { + return 0, errUninitializedPipeWrite + } return p.b.Write(d) } diff --git a/vendor/golang.org/x/net/http2/server.go b/vendor/golang.org/x/net/http2/server.go index ae94c640..c5d08108 100644 --- a/vendor/golang.org/x/net/http2/server.go +++ b/vendor/golang.org/x/net/http2/server.go @@ -124,6 +124,7 @@ type Server struct { // IdleTimeout specifies how long until idle clients should be // closed with a GOAWAY frame. PING frames are not considered // activity for the purposes of IdleTimeout. + // If zero or negative, there is no timeout. IdleTimeout time.Duration // MaxUploadBufferPerConnection is the size of the initial flow @@ -434,7 +435,7 @@ func (s *Server) ServeConn(c net.Conn, opts *ServeConnOpts) { // passes the connection off to us with the deadline already set. // Write deadlines are set per stream in serverConn.newStream. // Disarm the net.Conn write deadline here. - if sc.hs.WriteTimeout != 0 { + if sc.hs.WriteTimeout > 0 { sc.conn.SetWriteDeadline(time.Time{}) } @@ -731,11 +732,7 @@ func isClosedConnError(err error) bool { return false } - // TODO: remove this string search and be more like the Windows - // case below. That might involve modifying the standard library - // to return better error types. - str := err.Error() - if strings.Contains(str, "use of closed network connection") { + if errors.Is(err, net.ErrClosed) { return true } @@ -924,7 +921,7 @@ func (sc *serverConn) serve() { sc.setConnState(http.StateActive) sc.setConnState(http.StateIdle) - if sc.srv.IdleTimeout != 0 { + if sc.srv.IdleTimeout > 0 { sc.idleTimer = time.AfterFunc(sc.srv.IdleTimeout, sc.onIdleTimer) defer sc.idleTimer.Stop() } @@ -1481,6 +1478,11 @@ func (sc *serverConn) processFrameFromReader(res readFrameResult) bool { sc.goAway(ErrCodeFlowControl) return true case ConnectionError: + if res.f != nil { + if id := res.f.Header().StreamID; id > sc.maxClientStreamID { + sc.maxClientStreamID = id + } + } sc.logf("http2: server connection error from %v: %v", sc.conn.RemoteAddr(), ev) sc.goAway(ErrCode(ev)) return true // goAway will handle shutdown @@ -1637,7 +1639,7 @@ func (sc *serverConn) closeStream(st *stream, err error) { delete(sc.streams, st.id) if len(sc.streams) == 0 { sc.setConnState(http.StateIdle) - if sc.srv.IdleTimeout != 0 { + if sc.srv.IdleTimeout > 0 { sc.idleTimer.Reset(sc.srv.IdleTimeout) } if h1ServerKeepAlivesDisabled(sc.hs) { @@ -2017,7 +2019,7 @@ func (sc *serverConn) processHeaders(f *MetaHeadersFrame) error { // similar to how the http1 server works. Here it's // technically more like the http1 Server's ReadHeaderTimeout // (in Go 1.8), though. That's a more sane option anyway. - if sc.hs.ReadTimeout != 0 { + if sc.hs.ReadTimeout > 0 { sc.conn.SetReadDeadline(time.Time{}) st.readDeadline = time.AfterFunc(sc.hs.ReadTimeout, st.onReadTimeout) } @@ -2038,7 +2040,7 @@ func (sc *serverConn) upgradeRequest(req *http.Request) { // Disable any read deadline set by the net/http package // prior to the upgrade. - if sc.hs.ReadTimeout != 0 { + if sc.hs.ReadTimeout > 0 { sc.conn.SetReadDeadline(time.Time{}) } @@ -2116,7 +2118,7 @@ func (sc *serverConn) newStream(id, pusherID uint32, state streamState) *stream st.flow.conn = &sc.flow // link to conn-level counter st.flow.add(sc.initialStreamSendWindowSize) st.inflow.init(sc.srv.initialStreamRecvWindowSize()) - if sc.hs.WriteTimeout != 0 { + if sc.hs.WriteTimeout > 0 { st.writeDeadline = time.AfterFunc(sc.hs.WriteTimeout, st.onWriteTimeout) } diff --git a/vendor/golang.org/x/net/http2/testsync.go b/vendor/golang.org/x/net/http2/testsync.go new file mode 100644 index 00000000..61075bd1 --- /dev/null +++ b/vendor/golang.org/x/net/http2/testsync.go @@ -0,0 +1,331 @@ +// Copyright 2024 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. +package http2 + +import ( + "context" + "sync" + "time" +) + +// testSyncHooks coordinates goroutines in tests. +// +// For example, a call to ClientConn.RoundTrip involves several goroutines, including: +// - the goroutine running RoundTrip; +// - the clientStream.doRequest goroutine, which writes the request; and +// - the clientStream.readLoop goroutine, which reads the response. +// +// Using testSyncHooks, a test can start a RoundTrip and identify when all these goroutines +// are blocked waiting for some condition such as reading the Request.Body or waiting for +// flow control to become available. +// +// The testSyncHooks also manage timers and synthetic time in tests. +// This permits us to, for example, start a request and cause it to time out waiting for +// response headers without resorting to time.Sleep calls. +type testSyncHooks struct { + // active/inactive act as a mutex and condition variable. + // + // - neither chan contains a value: testSyncHooks is locked. + // - active contains a value: unlocked, and at least one goroutine is not blocked + // - inactive contains a value: unlocked, and all goroutines are blocked + active chan struct{} + inactive chan struct{} + + // goroutine counts + total int // total goroutines + condwait map[*sync.Cond]int // blocked in sync.Cond.Wait + blocked []*testBlockedGoroutine // otherwise blocked + + // fake time + now time.Time + timers []*fakeTimer + + // Transport testing: Report various events. + newclientconn func(*ClientConn) + newstream func(*clientStream) +} + +// testBlockedGoroutine is a blocked goroutine. +type testBlockedGoroutine struct { + f func() bool // blocked until f returns true + ch chan struct{} // closed when unblocked +} + +func newTestSyncHooks() *testSyncHooks { + h := &testSyncHooks{ + active: make(chan struct{}, 1), + inactive: make(chan struct{}, 1), + condwait: map[*sync.Cond]int{}, + } + h.inactive <- struct{}{} + h.now = time.Date(2000, 1, 1, 0, 0, 0, 0, time.UTC) + return h +} + +// lock acquires the testSyncHooks mutex. +func (h *testSyncHooks) lock() { + select { + case <-h.active: + case <-h.inactive: + } +} + +// waitInactive waits for all goroutines to become inactive. +func (h *testSyncHooks) waitInactive() { + for { + <-h.inactive + if !h.unlock() { + break + } + } +} + +// unlock releases the testSyncHooks mutex. +// It reports whether any goroutines are active. +func (h *testSyncHooks) unlock() (active bool) { + // Look for a blocked goroutine which can be unblocked. + blocked := h.blocked[:0] + unblocked := false + for _, b := range h.blocked { + if !unblocked && b.f() { + unblocked = true + close(b.ch) + } else { + blocked = append(blocked, b) + } + } + h.blocked = blocked + + // Count goroutines blocked on condition variables. + condwait := 0 + for _, count := range h.condwait { + condwait += count + } + + if h.total > condwait+len(blocked) { + h.active <- struct{}{} + return true + } else { + h.inactive <- struct{}{} + return false + } +} + +// goRun starts a new goroutine. +func (h *testSyncHooks) goRun(f func()) { + h.lock() + h.total++ + h.unlock() + go func() { + defer func() { + h.lock() + h.total-- + h.unlock() + }() + f() + }() +} + +// blockUntil indicates that a goroutine is blocked waiting for some condition to become true. +// It waits until f returns true before proceeding. +// +// Example usage: +// +// h.blockUntil(func() bool { +// // Is the context done yet? +// select { +// case <-ctx.Done(): +// default: +// return false +// } +// return true +// }) +// // Wait for the context to become done. +// <-ctx.Done() +// +// The function f passed to blockUntil must be non-blocking and idempotent. +func (h *testSyncHooks) blockUntil(f func() bool) { + if f() { + return + } + ch := make(chan struct{}) + h.lock() + h.blocked = append(h.blocked, &testBlockedGoroutine{ + f: f, + ch: ch, + }) + h.unlock() + <-ch +} + +// broadcast is sync.Cond.Broadcast. +func (h *testSyncHooks) condBroadcast(cond *sync.Cond) { + h.lock() + delete(h.condwait, cond) + h.unlock() + cond.Broadcast() +} + +// broadcast is sync.Cond.Wait. +func (h *testSyncHooks) condWait(cond *sync.Cond) { + h.lock() + h.condwait[cond]++ + h.unlock() +} + +// newTimer creates a new fake timer. +func (h *testSyncHooks) newTimer(d time.Duration) timer { + h.lock() + defer h.unlock() + t := &fakeTimer{ + hooks: h, + when: h.now.Add(d), + c: make(chan time.Time), + } + h.timers = append(h.timers, t) + return t +} + +// afterFunc creates a new fake AfterFunc timer. +func (h *testSyncHooks) afterFunc(d time.Duration, f func()) timer { + h.lock() + defer h.unlock() + t := &fakeTimer{ + hooks: h, + when: h.now.Add(d), + f: f, + } + h.timers = append(h.timers, t) + return t +} + +func (h *testSyncHooks) contextWithTimeout(ctx context.Context, d time.Duration) (context.Context, context.CancelFunc) { + ctx, cancel := context.WithCancel(ctx) + t := h.afterFunc(d, cancel) + return ctx, func() { + t.Stop() + cancel() + } +} + +func (h *testSyncHooks) timeUntilEvent() time.Duration { + h.lock() + defer h.unlock() + var next time.Time + for _, t := range h.timers { + if next.IsZero() || t.when.Before(next) { + next = t.when + } + } + if d := next.Sub(h.now); d > 0 { + return d + } + return 0 +} + +// advance advances time and causes synthetic timers to fire. +func (h *testSyncHooks) advance(d time.Duration) { + h.lock() + defer h.unlock() + h.now = h.now.Add(d) + timers := h.timers[:0] + for _, t := range h.timers { + t := t // remove after go.mod depends on go1.22 + t.mu.Lock() + switch { + case t.when.After(h.now): + timers = append(timers, t) + case t.when.IsZero(): + // stopped timer + default: + t.when = time.Time{} + if t.c != nil { + close(t.c) + } + if t.f != nil { + h.total++ + go func() { + defer func() { + h.lock() + h.total-- + h.unlock() + }() + t.f() + }() + } + } + t.mu.Unlock() + } + h.timers = timers +} + +// A timer wraps a time.Timer, or a synthetic equivalent in tests. +// Unlike time.Timer, timer is single-use: The timer channel is closed when the timer expires. +type timer interface { + C() <-chan time.Time + Stop() bool + Reset(d time.Duration) bool +} + +// timeTimer implements timer using real time. +type timeTimer struct { + t *time.Timer + c chan time.Time +} + +// newTimeTimer creates a new timer using real time. +func newTimeTimer(d time.Duration) timer { + ch := make(chan time.Time) + t := time.AfterFunc(d, func() { + close(ch) + }) + return &timeTimer{t, ch} +} + +// newTimeAfterFunc creates an AfterFunc timer using real time. +func newTimeAfterFunc(d time.Duration, f func()) timer { + return &timeTimer{ + t: time.AfterFunc(d, f), + } +} + +func (t timeTimer) C() <-chan time.Time { return t.c } +func (t timeTimer) Stop() bool { return t.t.Stop() } +func (t timeTimer) Reset(d time.Duration) bool { return t.t.Reset(d) } + +// fakeTimer implements timer using fake time. +type fakeTimer struct { + hooks *testSyncHooks + + mu sync.Mutex + when time.Time // when the timer will fire + c chan time.Time // closed when the timer fires; mutually exclusive with f + f func() // called when the timer fires; mutually exclusive with c +} + +func (t *fakeTimer) C() <-chan time.Time { return t.c } + +func (t *fakeTimer) Stop() bool { + t.mu.Lock() + defer t.mu.Unlock() + stopped := t.when.IsZero() + t.when = time.Time{} + return stopped +} + +func (t *fakeTimer) Reset(d time.Duration) bool { + if t.c != nil || t.f == nil { + panic("fakeTimer only supports Reset on AfterFunc timers") + } + t.mu.Lock() + defer t.mu.Unlock() + t.hooks.lock() + defer t.hooks.unlock() + active := !t.when.IsZero() + t.when = t.hooks.now.Add(d) + if !active { + t.hooks.timers = append(t.hooks.timers, t) + } + return active +} diff --git a/vendor/golang.org/x/net/http2/transport.go b/vendor/golang.org/x/net/http2/transport.go index c2a5b44b..2fa49490 100644 --- a/vendor/golang.org/x/net/http2/transport.go +++ b/vendor/golang.org/x/net/http2/transport.go @@ -147,6 +147,12 @@ type Transport struct { // waiting for their turn. StrictMaxConcurrentStreams bool + // IdleConnTimeout is the maximum amount of time an idle + // (keep-alive) connection will remain idle before closing + // itself. + // Zero means no limit. + IdleConnTimeout time.Duration + // ReadIdleTimeout is the timeout after which a health check using ping // frame will be carried out if no frame is received on the connection. // Note that a ping response will is considered a received frame, so if @@ -178,6 +184,8 @@ type Transport struct { connPoolOnce sync.Once connPoolOrDef ClientConnPool // non-nil version of ConnPool + + syncHooks *testSyncHooks } func (t *Transport) maxHeaderListSize() uint32 { @@ -302,7 +310,7 @@ type ClientConn struct { readerErr error // set before readerDone is closed idleTimeout time.Duration // or 0 for never - idleTimer *time.Timer + idleTimer timer mu sync.Mutex // guards following cond *sync.Cond // hold mu; broadcast on flow/closed changes @@ -344,6 +352,60 @@ type ClientConn struct { werr error // first write error that has occurred hbuf bytes.Buffer // HPACK encoder writes into this henc *hpack.Encoder + + syncHooks *testSyncHooks // can be nil +} + +// Hook points used for testing. +// Outside of tests, cc.syncHooks is nil and these all have minimal implementations. +// Inside tests, see the testSyncHooks function docs. + +// goRun starts a new goroutine. +func (cc *ClientConn) goRun(f func()) { + if cc.syncHooks != nil { + cc.syncHooks.goRun(f) + return + } + go f() +} + +// condBroadcast is cc.cond.Broadcast. +func (cc *ClientConn) condBroadcast() { + if cc.syncHooks != nil { + cc.syncHooks.condBroadcast(cc.cond) + } + cc.cond.Broadcast() +} + +// condWait is cc.cond.Wait. +func (cc *ClientConn) condWait() { + if cc.syncHooks != nil { + cc.syncHooks.condWait(cc.cond) + } + cc.cond.Wait() +} + +// newTimer creates a new time.Timer, or a synthetic timer in tests. +func (cc *ClientConn) newTimer(d time.Duration) timer { + if cc.syncHooks != nil { + return cc.syncHooks.newTimer(d) + } + return newTimeTimer(d) +} + +// afterFunc creates a new time.AfterFunc timer, or a synthetic timer in tests. +func (cc *ClientConn) afterFunc(d time.Duration, f func()) timer { + if cc.syncHooks != nil { + return cc.syncHooks.afterFunc(d, f) + } + return newTimeAfterFunc(d, f) +} + +func (cc *ClientConn) contextWithTimeout(ctx context.Context, d time.Duration) (context.Context, context.CancelFunc) { + if cc.syncHooks != nil { + return cc.syncHooks.contextWithTimeout(ctx, d) + } + return context.WithTimeout(ctx, d) } // clientStream is the state for a single HTTP/2 stream. One of these @@ -425,7 +487,7 @@ func (cs *clientStream) abortStreamLocked(err error) { // TODO(dneil): Clean up tests where cs.cc.cond is nil. if cs.cc.cond != nil { // Wake up writeRequestBody if it is waiting on flow control. - cs.cc.cond.Broadcast() + cs.cc.condBroadcast() } } @@ -435,7 +497,7 @@ func (cs *clientStream) abortRequestBodyWrite() { defer cc.mu.Unlock() if cs.reqBody != nil && cs.reqBodyClosed == nil { cs.closeReqBodyLocked() - cc.cond.Broadcast() + cc.condBroadcast() } } @@ -445,10 +507,10 @@ func (cs *clientStream) closeReqBodyLocked() { } cs.reqBodyClosed = make(chan struct{}) reqBodyClosed := cs.reqBodyClosed - go func() { + cs.cc.goRun(func() { cs.reqBody.Close() close(reqBodyClosed) - }() + }) } type stickyErrWriter struct { @@ -537,15 +599,6 @@ func authorityAddr(scheme string, authority string) (addr string) { return net.JoinHostPort(host, port) } -var retryBackoffHook func(time.Duration) *time.Timer - -func backoffNewTimer(d time.Duration) *time.Timer { - if retryBackoffHook != nil { - return retryBackoffHook(d) - } - return time.NewTimer(d) -} - // RoundTripOpt is like RoundTrip, but takes options. func (t *Transport) RoundTripOpt(req *http.Request, opt RoundTripOpt) (*http.Response, error) { if !(req.URL.Scheme == "https" || (req.URL.Scheme == "http" && t.AllowHTTP)) { @@ -573,13 +626,27 @@ func (t *Transport) RoundTripOpt(req *http.Request, opt RoundTripOpt) (*http.Res backoff := float64(uint(1) << (uint(retry) - 1)) backoff += backoff * (0.1 * mathrand.Float64()) d := time.Second * time.Duration(backoff) - timer := backoffNewTimer(d) + var tm timer + if t.syncHooks != nil { + tm = t.syncHooks.newTimer(d) + t.syncHooks.blockUntil(func() bool { + select { + case <-tm.C(): + case <-req.Context().Done(): + default: + return false + } + return true + }) + } else { + tm = newTimeTimer(d) + } select { - case <-timer.C: + case <-tm.C(): t.vlogf("RoundTrip retrying after failure: %v", roundTripErr) continue case <-req.Context().Done(): - timer.Stop() + tm.Stop() err = req.Context().Err() } } @@ -658,6 +725,9 @@ func canRetryError(err error) bool { } func (t *Transport) dialClientConn(ctx context.Context, addr string, singleUse bool) (*ClientConn, error) { + if t.syncHooks != nil { + return t.newClientConn(nil, singleUse, t.syncHooks) + } host, _, err := net.SplitHostPort(addr) if err != nil { return nil, err @@ -666,7 +736,7 @@ func (t *Transport) dialClientConn(ctx context.Context, addr string, singleUse b if err != nil { return nil, err } - return t.newClientConn(tconn, singleUse) + return t.newClientConn(tconn, singleUse, nil) } func (t *Transport) newTLSConfig(host string) *tls.Config { @@ -732,10 +802,10 @@ func (t *Transport) maxEncoderHeaderTableSize() uint32 { } func (t *Transport) NewClientConn(c net.Conn) (*ClientConn, error) { - return t.newClientConn(c, t.disableKeepAlives()) + return t.newClientConn(c, t.disableKeepAlives(), nil) } -func (t *Transport) newClientConn(c net.Conn, singleUse bool) (*ClientConn, error) { +func (t *Transport) newClientConn(c net.Conn, singleUse bool, hooks *testSyncHooks) (*ClientConn, error) { cc := &ClientConn{ t: t, tconn: c, @@ -750,10 +820,15 @@ func (t *Transport) newClientConn(c net.Conn, singleUse bool) (*ClientConn, erro wantSettingsAck: true, pings: make(map[[8]byte]chan struct{}), reqHeaderMu: make(chan struct{}, 1), + syncHooks: hooks, + } + if hooks != nil { + hooks.newclientconn(cc) + c = cc.tconn } if d := t.idleConnTimeout(); d != 0 { cc.idleTimeout = d - cc.idleTimer = time.AfterFunc(d, cc.onIdleTimeout) + cc.idleTimer = cc.afterFunc(d, cc.onIdleTimeout) } if VerboseLogs { t.vlogf("http2: Transport creating client conn %p to %v", cc, c.RemoteAddr()) @@ -818,7 +893,7 @@ func (t *Transport) newClientConn(c net.Conn, singleUse bool) (*ClientConn, erro return nil, cc.werr } - go cc.readLoop() + cc.goRun(cc.readLoop) return cc, nil } @@ -826,7 +901,7 @@ func (cc *ClientConn) healthCheck() { pingTimeout := cc.t.pingTimeout() // We don't need to periodically ping in the health check, because the readLoop of ClientConn will // trigger the healthCheck again if there is no frame received. - ctx, cancel := context.WithTimeout(context.Background(), pingTimeout) + ctx, cancel := cc.contextWithTimeout(context.Background(), pingTimeout) defer cancel() cc.vlogf("http2: Transport sending health check") err := cc.Ping(ctx) @@ -861,7 +936,20 @@ func (cc *ClientConn) setGoAway(f *GoAwayFrame) { } last := f.LastStreamID for streamID, cs := range cc.streams { - if streamID > last { + if streamID <= last { + // The server's GOAWAY indicates that it received this stream. + // It will either finish processing it, or close the connection + // without doing so. Either way, leave the stream alone for now. + continue + } + if streamID == 1 && cc.goAway.ErrCode != ErrCodeNo { + // Don't retry the first stream on a connection if we get a non-NO error. + // If the server is sending an error on a new connection, + // retrying the request on a new one probably isn't going to work. + cs.abortStreamLocked(fmt.Errorf("http2: Transport received GOAWAY from server ErrCode:%v", cc.goAway.ErrCode)) + } else { + // Aborting the stream with errClentConnGotGoAway indicates that + // the request should be retried on a new connection. cs.abortStreamLocked(errClientConnGotGoAway) } } @@ -1056,7 +1144,7 @@ func (cc *ClientConn) Shutdown(ctx context.Context) error { // Wait for all in-flight streams to complete or connection to close done := make(chan struct{}) cancelled := false // guarded by cc.mu - go func() { + cc.goRun(func() { cc.mu.Lock() defer cc.mu.Unlock() for { @@ -1068,9 +1156,9 @@ func (cc *ClientConn) Shutdown(ctx context.Context) error { if cancelled { break } - cc.cond.Wait() + cc.condWait() } - }() + }) shutdownEnterWaitStateHook() select { case <-done: @@ -1080,7 +1168,7 @@ func (cc *ClientConn) Shutdown(ctx context.Context) error { cc.mu.Lock() // Free the goroutine above cancelled = true - cc.cond.Broadcast() + cc.condBroadcast() cc.mu.Unlock() return ctx.Err() } @@ -1118,7 +1206,7 @@ func (cc *ClientConn) closeForError(err error) { for _, cs := range cc.streams { cs.abortStreamLocked(err) } - cc.cond.Broadcast() + cc.condBroadcast() cc.mu.Unlock() cc.closeConn() } @@ -1215,6 +1303,10 @@ func (cc *ClientConn) decrStreamReservationsLocked() { } func (cc *ClientConn) RoundTrip(req *http.Request) (*http.Response, error) { + return cc.roundTrip(req, nil) +} + +func (cc *ClientConn) roundTrip(req *http.Request, streamf func(*clientStream)) (*http.Response, error) { ctx := req.Context() cs := &clientStream{ cc: cc, @@ -1229,9 +1321,23 @@ func (cc *ClientConn) RoundTrip(req *http.Request) (*http.Response, error) { respHeaderRecv: make(chan struct{}), donec: make(chan struct{}), } - go cs.doRequest(req) + cc.goRun(func() { + cs.doRequest(req) + }) waitDone := func() error { + if cc.syncHooks != nil { + cc.syncHooks.blockUntil(func() bool { + select { + case <-cs.donec: + case <-ctx.Done(): + case <-cs.reqCancel: + default: + return false + } + return true + }) + } select { case <-cs.donec: return nil @@ -1292,7 +1398,24 @@ func (cc *ClientConn) RoundTrip(req *http.Request) (*http.Response, error) { return err } + if streamf != nil { + streamf(cs) + } + for { + if cc.syncHooks != nil { + cc.syncHooks.blockUntil(func() bool { + select { + case <-cs.respHeaderRecv: + case <-cs.abort: + case <-ctx.Done(): + case <-cs.reqCancel: + default: + return false + } + return true + }) + } select { case <-cs.respHeaderRecv: return handleResponseHeaders() @@ -1348,6 +1471,21 @@ func (cs *clientStream) writeRequest(req *http.Request) (err error) { if cc.reqHeaderMu == nil { panic("RoundTrip on uninitialized ClientConn") // for tests } + var newStreamHook func(*clientStream) + if cc.syncHooks != nil { + newStreamHook = cc.syncHooks.newstream + cc.syncHooks.blockUntil(func() bool { + select { + case cc.reqHeaderMu <- struct{}{}: + <-cc.reqHeaderMu + case <-cs.reqCancel: + case <-ctx.Done(): + default: + return false + } + return true + }) + } select { case cc.reqHeaderMu <- struct{}{}: case <-cs.reqCancel: @@ -1372,6 +1510,10 @@ func (cs *clientStream) writeRequest(req *http.Request) (err error) { } cc.mu.Unlock() + if newStreamHook != nil { + newStreamHook(cs) + } + // TODO(bradfitz): this is a copy of the logic in net/http. Unify somewhere? if !cc.t.disableCompression() && req.Header.Get("Accept-Encoding") == "" && @@ -1452,15 +1594,30 @@ func (cs *clientStream) writeRequest(req *http.Request) (err error) { var respHeaderTimer <-chan time.Time var respHeaderRecv chan struct{} if d := cc.responseHeaderTimeout(); d != 0 { - timer := time.NewTimer(d) + timer := cc.newTimer(d) defer timer.Stop() - respHeaderTimer = timer.C + respHeaderTimer = timer.C() respHeaderRecv = cs.respHeaderRecv } // Wait until the peer half-closes its end of the stream, // or until the request is aborted (via context, error, or otherwise), // whichever comes first. for { + if cc.syncHooks != nil { + cc.syncHooks.blockUntil(func() bool { + select { + case <-cs.peerClosed: + case <-respHeaderTimer: + case <-respHeaderRecv: + case <-cs.abort: + case <-ctx.Done(): + case <-cs.reqCancel: + default: + return false + } + return true + }) + } select { case <-cs.peerClosed: return nil @@ -1609,7 +1766,7 @@ func (cc *ClientConn) awaitOpenSlotForStreamLocked(cs *clientStream) error { return nil } cc.pendingRequests++ - cc.cond.Wait() + cc.condWait() cc.pendingRequests-- select { case <-cs.abort: @@ -1871,8 +2028,24 @@ func (cs *clientStream) awaitFlowControl(maxBytes int) (taken int32, err error) cs.flow.take(take) return take, nil } - cc.cond.Wait() + cc.condWait() + } +} + +func validateHeaders(hdrs http.Header) string { + for k, vv := range hdrs { + if !httpguts.ValidHeaderFieldName(k) { + return fmt.Sprintf("name %q", k) + } + for _, v := range vv { + if !httpguts.ValidHeaderFieldValue(v) { + // Don't include the value in the error, + // because it may be sensitive. + return fmt.Sprintf("value for header %q", k) + } + } } + return "" } var errNilRequestURL = errors.New("http2: Request.URI is nil") @@ -1912,19 +2085,14 @@ func (cc *ClientConn) encodeHeaders(req *http.Request, addGzipHeader bool, trail } } - // Check for any invalid headers and return an error before we + // Check for any invalid headers+trailers and return an error before we // potentially pollute our hpack state. (We want to be able to // continue to reuse the hpack encoder for future requests) - for k, vv := range req.Header { - if !httpguts.ValidHeaderFieldName(k) { - return nil, fmt.Errorf("invalid HTTP header name %q", k) - } - for _, v := range vv { - if !httpguts.ValidHeaderFieldValue(v) { - // Don't include the value in the error, because it may be sensitive. - return nil, fmt.Errorf("invalid HTTP header value for header %q", k) - } - } + if err := validateHeaders(req.Header); err != "" { + return nil, fmt.Errorf("invalid HTTP header %s", err) + } + if err := validateHeaders(req.Trailer); err != "" { + return nil, fmt.Errorf("invalid HTTP trailer %s", err) } enumerateHeaders := func(f func(name, value string)) { @@ -2143,7 +2311,7 @@ func (cc *ClientConn) forgetStreamID(id uint32) { } // Wake up writeRequestBody via clientStream.awaitFlowControl and // wake up RoundTrip if there is a pending request. - cc.cond.Broadcast() + cc.condBroadcast() closeOnIdle := cc.singleUse || cc.doNotReuse || cc.t.disableKeepAlives() || cc.goAway != nil if closeOnIdle && cc.streamsReserved == 0 && len(cc.streams) == 0 { @@ -2231,7 +2399,7 @@ func (rl *clientConnReadLoop) cleanup() { cs.abortStreamLocked(err) } } - cc.cond.Broadcast() + cc.condBroadcast() cc.mu.Unlock() } @@ -2266,10 +2434,9 @@ func (rl *clientConnReadLoop) run() error { cc := rl.cc gotSettings := false readIdleTimeout := cc.t.ReadIdleTimeout - var t *time.Timer + var t timer if readIdleTimeout != 0 { - t = time.AfterFunc(readIdleTimeout, cc.healthCheck) - defer t.Stop() + t = cc.afterFunc(readIdleTimeout, cc.healthCheck) } for { f, err := cc.fr.ReadFrame() @@ -2684,7 +2851,7 @@ func (rl *clientConnReadLoop) processData(f *DataFrame) error { }) return nil } - if !cs.firstByte { + if !cs.pastHeaders { cc.logf("protocol error: received DATA before a HEADERS frame") rl.endStreamError(cs, StreamError{ StreamID: f.StreamID, @@ -2867,7 +3034,7 @@ func (rl *clientConnReadLoop) processSettingsNoWrite(f *SettingsFrame) error { for _, cs := range cc.streams { cs.flow.add(delta) } - cc.cond.Broadcast() + cc.condBroadcast() cc.initialWindowSize = s.Val case SettingHeaderTableSize: @@ -2922,7 +3089,7 @@ func (rl *clientConnReadLoop) processWindowUpdate(f *WindowUpdateFrame) error { return ConnectionError(ErrCodeFlowControl) } - cc.cond.Broadcast() + cc.condBroadcast() return nil } @@ -2964,24 +3131,38 @@ func (cc *ClientConn) Ping(ctx context.Context) error { } cc.mu.Unlock() } - errc := make(chan error, 1) - go func() { + var pingError error + errc := make(chan struct{}) + cc.goRun(func() { cc.wmu.Lock() defer cc.wmu.Unlock() - if err := cc.fr.WritePing(false, p); err != nil { - errc <- err + if pingError = cc.fr.WritePing(false, p); pingError != nil { + close(errc) return } - if err := cc.bw.Flush(); err != nil { - errc <- err + if pingError = cc.bw.Flush(); pingError != nil { + close(errc) return } - }() + }) + if cc.syncHooks != nil { + cc.syncHooks.blockUntil(func() bool { + select { + case <-c: + case <-errc: + case <-ctx.Done(): + case <-cc.readerDone: + default: + return false + } + return true + }) + } select { case <-c: return nil - case err := <-errc: - return err + case <-errc: + return pingError case <-ctx.Done(): return ctx.Err() case <-cc.readerDone: @@ -3150,9 +3331,17 @@ func (rt noDialH2RoundTripper) RoundTrip(req *http.Request) (*http.Response, err } func (t *Transport) idleConnTimeout() time.Duration { + // to keep things backwards compatible, we use non-zero values of + // IdleConnTimeout, followed by using the IdleConnTimeout on the underlying + // http1 transport, followed by 0 + if t.IdleConnTimeout != 0 { + return t.IdleConnTimeout + } + if t.t1 != nil { return t.t1.IdleConnTimeout } + return 0 } diff --git a/vendor/google.golang.org/genproto/googleapis/rpc/status/status.pb.go b/vendor/google.golang.org/genproto/googleapis/rpc/status/status.pb.go index a6b50818..6ad1b1c1 100644 --- a/vendor/google.golang.org/genproto/googleapis/rpc/status/status.pb.go +++ b/vendor/google.golang.org/genproto/googleapis/rpc/status/status.pb.go @@ -1,4 +1,4 @@ -// Copyright 2022 Google LLC +// Copyright 2024 Google LLC // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -15,7 +15,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: // protoc-gen-go v1.26.0 -// protoc v3.21.9 +// protoc v4.24.4 // source: google/rpc/status.proto package status diff --git a/vendor/google.golang.org/grpc/README.md b/vendor/google.golang.org/grpc/README.md index ab0fbb79..b572707c 100644 --- a/vendor/google.golang.org/grpc/README.md +++ b/vendor/google.golang.org/grpc/README.md @@ -10,7 +10,7 @@ RPC framework that puts mobile and HTTP/2 first. For more information see the ## Prerequisites -- **[Go][]**: any one of the **three latest major** [releases][go-releases]. +- **[Go][]**: any one of the **two latest major** [releases][go-releases]. ## Installation diff --git a/vendor/google.golang.org/grpc/pickfirst.go b/vendor/google.golang.org/grpc/balancer/pickfirst/pickfirst.go similarity index 89% rename from vendor/google.golang.org/grpc/pickfirst.go rename to vendor/google.golang.org/grpc/balancer/pickfirst/pickfirst.go index 88536266..07527603 100644 --- a/vendor/google.golang.org/grpc/pickfirst.go +++ b/vendor/google.golang.org/grpc/balancer/pickfirst/pickfirst.go @@ -16,26 +16,36 @@ * */ -package grpc +// Package pickfirst contains the pick_first load balancing policy. +package pickfirst import ( "encoding/json" "errors" "fmt" + "math/rand" "google.golang.org/grpc/balancer" "google.golang.org/grpc/connectivity" + "google.golang.org/grpc/grpclog" + "google.golang.org/grpc/internal" internalgrpclog "google.golang.org/grpc/internal/grpclog" - "google.golang.org/grpc/internal/grpcrand" "google.golang.org/grpc/internal/pretty" "google.golang.org/grpc/resolver" "google.golang.org/grpc/serviceconfig" ) +func init() { + balancer.Register(pickfirstBuilder{}) + internal.ShuffleAddressListForTesting = func(n int, swap func(i, j int)) { rand.Shuffle(n, swap) } +} + +var logger = grpclog.Component("pick-first-lb") + const ( - // PickFirstBalancerName is the name of the pick_first balancer. - PickFirstBalancerName = "pick_first" - logPrefix = "[pick-first-lb %p] " + // Name is the name of the pick_first balancer. + Name = "pick_first" + logPrefix = "[pick-first-lb %p] " ) type pickfirstBuilder struct{} @@ -47,7 +57,7 @@ func (pickfirstBuilder) Build(cc balancer.ClientConn, opt balancer.BuildOptions) } func (pickfirstBuilder) Name() string { - return PickFirstBalancerName + return Name } type pfConfig struct { @@ -93,6 +103,12 @@ func (b *pickfirstBalancer) ResolverError(err error) { }) } +type Shuffler interface { + ShuffleAddressListForTesting(n int, swap func(i, j int)) +} + +func ShuffleAddressListForTesting(n int, swap func(i, j int)) { rand.Shuffle(n, swap) } + func (b *pickfirstBalancer) UpdateClientConnState(state balancer.ClientConnState) error { if len(state.ResolverState.Addresses) == 0 && len(state.ResolverState.Endpoints) == 0 { // The resolver reported an empty address list. Treat it like an error by @@ -124,7 +140,7 @@ func (b *pickfirstBalancer) UpdateClientConnState(state balancer.ClientConnState // within each endpoint. - A61 if cfg.ShuffleAddressList { endpoints = append([]resolver.Endpoint{}, endpoints...) - grpcrand.Shuffle(len(endpoints), func(i, j int) { endpoints[i], endpoints[j] = endpoints[j], endpoints[i] }) + internal.ShuffleAddressListForTesting.(func(int, func(int, int)))(len(endpoints), func(i, j int) { endpoints[i], endpoints[j] = endpoints[j], endpoints[i] }) } // "Flatten the list by concatenating the ordered list of addresses for each @@ -145,7 +161,7 @@ func (b *pickfirstBalancer) UpdateClientConnState(state balancer.ClientConnState addrs = state.ResolverState.Addresses if cfg.ShuffleAddressList { addrs = append([]resolver.Address{}, addrs...) - grpcrand.Shuffle(len(addrs), func(i, j int) { addrs[i], addrs[j] = addrs[j], addrs[i] }) + rand.Shuffle(len(addrs), func(i, j int) { addrs[i], addrs[j] = addrs[j], addrs[i] }) } } diff --git a/vendor/google.golang.org/grpc/balancer/roundrobin/roundrobin.go b/vendor/google.golang.org/grpc/balancer/roundrobin/roundrobin.go index f7031ad2..260255d3 100644 --- a/vendor/google.golang.org/grpc/balancer/roundrobin/roundrobin.go +++ b/vendor/google.golang.org/grpc/balancer/roundrobin/roundrobin.go @@ -22,12 +22,12 @@ package roundrobin import ( + "math/rand" "sync/atomic" "google.golang.org/grpc/balancer" "google.golang.org/grpc/balancer/base" "google.golang.org/grpc/grpclog" - "google.golang.org/grpc/internal/grpcrand" ) // Name is the name of round_robin balancer. @@ -60,7 +60,7 @@ func (*rrPickerBuilder) Build(info base.PickerBuildInfo) balancer.Picker { // Start at a random index, as the same RR balancer rebuilds a new // picker when SubConn states change, and we don't want to apply excess // load to the first server in the list. - next: uint32(grpcrand.Intn(len(scs))), + next: uint32(rand.Intn(len(scs))), } } diff --git a/vendor/google.golang.org/grpc/balancer_wrapper.go b/vendor/google.golang.org/grpc/balancer_wrapper.go index af39b8a4..4161fdf4 100644 --- a/vendor/google.golang.org/grpc/balancer_wrapper.go +++ b/vendor/google.golang.org/grpc/balancer_wrapper.go @@ -198,6 +198,10 @@ func (ccb *ccBalancerWrapper) UpdateAddresses(sc balancer.SubConn, addrs []resol func (ccb *ccBalancerWrapper) UpdateState(s balancer.State) { ccb.cc.mu.Lock() defer ccb.cc.mu.Unlock() + if ccb.cc.conns == nil { + // The CC has been closed; ignore this update. + return + } ccb.mu.Lock() if ccb.closed { diff --git a/vendor/google.golang.org/grpc/binarylog/grpc_binarylog_v1/binarylog.pb.go b/vendor/google.golang.org/grpc/binarylog/grpc_binarylog_v1/binarylog.pb.go index 1afb1e84..63c639e4 100644 --- a/vendor/google.golang.org/grpc/binarylog/grpc_binarylog_v1/binarylog.pb.go +++ b/vendor/google.golang.org/grpc/binarylog/grpc_binarylog_v1/binarylog.pb.go @@ -18,7 +18,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.33.0 +// protoc-gen-go v1.34.1 // protoc v4.25.2 // source: grpc/binlog/v1/binarylog.proto diff --git a/vendor/google.golang.org/grpc/clientconn.go b/vendor/google.golang.org/grpc/clientconn.go index 2359f94b..423be7b4 100644 --- a/vendor/google.golang.org/grpc/clientconn.go +++ b/vendor/google.golang.org/grpc/clientconn.go @@ -31,6 +31,7 @@ import ( "google.golang.org/grpc/balancer" "google.golang.org/grpc/balancer/base" + "google.golang.org/grpc/balancer/pickfirst" "google.golang.org/grpc/codes" "google.golang.org/grpc/connectivity" "google.golang.org/grpc/internal" @@ -72,6 +73,8 @@ var ( // invalidDefaultServiceConfigErrPrefix is used to prefix the json parsing error for the default // service config. invalidDefaultServiceConfigErrPrefix = "grpc: the provided default service config is invalid" + // PickFirstBalancerName is the name of the pick_first balancer. + PickFirstBalancerName = pickfirst.Name ) // The following errors are returned from Dial and DialContext @@ -152,6 +155,16 @@ func NewClient(target string, opts ...DialOption) (conn *ClientConn, err error) for _, opt := range opts { opt.apply(&cc.dopts) } + + // Determine the resolver to use. + if err := cc.initParsedTargetAndResolverBuilder(); err != nil { + return nil, err + } + + for _, opt := range globalPerTargetDialOptions { + opt.DialOptionForTarget(cc.parsedTarget.URL).apply(&cc.dopts) + } + chainUnaryClientInterceptors(cc) chainStreamClientInterceptors(cc) @@ -160,7 +173,7 @@ func NewClient(target string, opts ...DialOption) (conn *ClientConn, err error) } if cc.dopts.defaultServiceConfigRawJSON != nil { - scpr := parseServiceConfig(*cc.dopts.defaultServiceConfigRawJSON) + scpr := parseServiceConfig(*cc.dopts.defaultServiceConfigRawJSON, cc.dopts.maxCallAttempts) if scpr.Err != nil { return nil, fmt.Errorf("%s: %v", invalidDefaultServiceConfigErrPrefix, scpr.Err) } @@ -168,25 +181,16 @@ func NewClient(target string, opts ...DialOption) (conn *ClientConn, err error) } cc.mkp = cc.dopts.copts.KeepaliveParams - // Register ClientConn with channelz. - cc.channelzRegistration(target) - - // TODO: Ideally it should be impossible to error from this function after - // channelz registration. This will require removing some channelz logs - // from the following functions that can error. Errors can be returned to - // the user, and successful logs can be emitted here, after the checks have - // passed and channelz is subsequently registered. - - // Determine the resolver to use. - if err := cc.parseTargetAndFindResolver(); err != nil { - channelz.RemoveEntry(cc.channelz.ID) - return nil, err - } - if err = cc.determineAuthority(); err != nil { - channelz.RemoveEntry(cc.channelz.ID) + if err = cc.initAuthority(); err != nil { return nil, err } + // Register ClientConn with channelz. Note that this is only done after + // channel creation cannot fail. + cc.channelzRegistration(target) + channelz.Infof(logger, cc.channelz, "parsed dial target is: %#v", cc.parsedTarget) + channelz.Infof(logger, cc.channelz, "Channel authority set to %q", cc.authority) + cc.csMgr = newConnectivityStateManager(cc.ctx, cc.channelz) cc.pickerWrapper = newPickerWrapper(cc.dopts.copts.StatsHandlers) @@ -587,11 +591,11 @@ type ClientConn struct { // The following are initialized at dial time, and are read-only after that. target string // User's dial target. - parsedTarget resolver.Target // See parseTargetAndFindResolver(). - authority string // See determineAuthority(). + parsedTarget resolver.Target // See initParsedTargetAndResolverBuilder(). + authority string // See initAuthority(). dopts dialOptions // Default and user specified dial options. channelz *channelz.Channel // Channelz object. - resolverBuilder resolver.Builder // See parseTargetAndFindResolver(). + resolverBuilder resolver.Builder // See initParsedTargetAndResolverBuilder(). idlenessMgr *idle.Manager // The following provide their own synchronization, and therefore don't @@ -692,8 +696,7 @@ func (cc *ClientConn) waitForResolvedAddrs(ctx context.Context) error { var emptyServiceConfig *ServiceConfig func init() { - balancer.Register(pickfirstBuilder{}) - cfg := parseServiceConfig("{}") + cfg := parseServiceConfig("{}", defaultMaxCallAttempts) if cfg.Err != nil { panic(fmt.Sprintf("impossible error parsing empty service config: %v", cfg.Err)) } @@ -1673,22 +1676,19 @@ func (cc *ClientConn) connectionError() error { return cc.lastConnectionError } -// parseTargetAndFindResolver parses the user's dial target and stores the -// parsed target in `cc.parsedTarget`. +// initParsedTargetAndResolverBuilder parses the user's dial target and stores +// the parsed target in `cc.parsedTarget`. // // The resolver to use is determined based on the scheme in the parsed target // and the same is stored in `cc.resolverBuilder`. // // Doesn't grab cc.mu as this method is expected to be called only at Dial time. -func (cc *ClientConn) parseTargetAndFindResolver() error { - channelz.Infof(logger, cc.channelz, "original dial target is: %q", cc.target) +func (cc *ClientConn) initParsedTargetAndResolverBuilder() error { + logger.Infof("original dial target is: %q", cc.target) var rb resolver.Builder parsedTarget, err := parseTarget(cc.target) - if err != nil { - channelz.Infof(logger, cc.channelz, "dial target %q parse failed: %v", cc.target, err) - } else { - channelz.Infof(logger, cc.channelz, "parsed dial target is: %#v", parsedTarget) + if err == nil { rb = cc.getResolver(parsedTarget.URL.Scheme) if rb != nil { cc.parsedTarget = parsedTarget @@ -1707,15 +1707,12 @@ func (cc *ClientConn) parseTargetAndFindResolver() error { defScheme = resolver.GetDefaultScheme() } - channelz.Infof(logger, cc.channelz, "fallback to scheme %q", defScheme) canonicalTarget := defScheme + ":///" + cc.target parsedTarget, err = parseTarget(canonicalTarget) if err != nil { - channelz.Infof(logger, cc.channelz, "dial target %q parse failed: %v", canonicalTarget, err) return err } - channelz.Infof(logger, cc.channelz, "parsed dial target is: %+v", parsedTarget) rb = cc.getResolver(parsedTarget.URL.Scheme) if rb == nil { return fmt.Errorf("could not get resolver for default scheme: %q", parsedTarget.URL.Scheme) @@ -1805,7 +1802,7 @@ func encodeAuthority(authority string) string { // credentials do not match the authority configured through the dial option. // // Doesn't grab cc.mu as this method is expected to be called only at Dial time. -func (cc *ClientConn) determineAuthority() error { +func (cc *ClientConn) initAuthority() error { dopts := cc.dopts // Historically, we had two options for users to specify the serverName or // authority for a channel. One was through the transport credentials @@ -1838,6 +1835,5 @@ func (cc *ClientConn) determineAuthority() error { } else { cc.authority = encodeAuthority(endpoint) } - channelz.Infof(logger, cc.channelz, "Channel authority set to %q", cc.authority) return nil } diff --git a/vendor/google.golang.org/grpc/credentials/tls.go b/vendor/google.golang.org/grpc/credentials/tls.go index 5dafd34e..41143585 100644 --- a/vendor/google.golang.org/grpc/credentials/tls.go +++ b/vendor/google.golang.org/grpc/credentials/tls.go @@ -27,9 +27,13 @@ import ( "net/url" "os" + "google.golang.org/grpc/grpclog" credinternal "google.golang.org/grpc/internal/credentials" + "google.golang.org/grpc/internal/envconfig" ) +var logger = grpclog.Component("credentials") + // TLSInfo contains the auth information for a TLS authenticated connection. // It implements the AuthInfo interface. type TLSInfo struct { @@ -112,6 +116,22 @@ func (c *tlsCreds) ClientHandshake(ctx context.Context, authority string, rawCon conn.Close() return nil, nil, ctx.Err() } + + // The negotiated protocol can be either of the following: + // 1. h2: When the server supports ALPN. Only HTTP/2 can be negotiated since + // it is the only protocol advertised by the client during the handshake. + // The tls library ensures that the server chooses a protocol advertised + // by the client. + // 2. "" (empty string): If the server doesn't support ALPN. ALPN is a requirement + // for using HTTP/2 over TLS. We can terminate the connection immediately. + np := conn.ConnectionState().NegotiatedProtocol + if np == "" { + if envconfig.EnforceALPNEnabled { + conn.Close() + return nil, nil, fmt.Errorf("credentials: cannot check peer: missing selected ALPN property") + } + logger.Warningf("Allowing TLS connection to server %q with ALPN disabled. TLS connections to servers with ALPN disabled will be disallowed in future grpc-go releases", cfg.ServerName) + } tlsInfo := TLSInfo{ State: conn.ConnectionState(), CommonAuthInfo: CommonAuthInfo{ @@ -131,8 +151,20 @@ func (c *tlsCreds) ServerHandshake(rawConn net.Conn) (net.Conn, AuthInfo, error) conn.Close() return nil, nil, err } + cs := conn.ConnectionState() + // The negotiated application protocol can be empty only if the client doesn't + // support ALPN. In such cases, we can close the connection since ALPN is required + // for using HTTP/2 over TLS. + if cs.NegotiatedProtocol == "" { + if envconfig.EnforceALPNEnabled { + conn.Close() + return nil, nil, fmt.Errorf("credentials: cannot check peer: missing selected ALPN property") + } else if logger.V(2) { + logger.Info("Allowing TLS connection from client with ALPN disabled. TLS connections with ALPN disabled will be disallowed in future grpc-go releases") + } + } tlsInfo := TLSInfo{ - State: conn.ConnectionState(), + State: cs, CommonAuthInfo: CommonAuthInfo{ SecurityLevel: PrivacyAndIntegrity, }, diff --git a/vendor/google.golang.org/grpc/dialoptions.go b/vendor/google.golang.org/grpc/dialoptions.go index 00273702..f5453d48 100644 --- a/vendor/google.golang.org/grpc/dialoptions.go +++ b/vendor/google.golang.org/grpc/dialoptions.go @@ -21,6 +21,7 @@ package grpc import ( "context" "net" + "net/url" "time" "google.golang.org/grpc/backoff" @@ -36,6 +37,11 @@ import ( "google.golang.org/grpc/stats" ) +const ( + // https://github.com/grpc/proposal/blob/master/A6-client-retries.md#limits-on-retries-and-hedges + defaultMaxCallAttempts = 5 +) + func init() { internal.AddGlobalDialOptions = func(opt ...DialOption) { globalDialOptions = append(globalDialOptions, opt...) @@ -43,6 +49,14 @@ func init() { internal.ClearGlobalDialOptions = func() { globalDialOptions = nil } + internal.AddGlobalPerTargetDialOptions = func(opt any) { + if ptdo, ok := opt.(perTargetDialOption); ok { + globalPerTargetDialOptions = append(globalPerTargetDialOptions, ptdo) + } + } + internal.ClearGlobalPerTargetDialOptions = func() { + globalPerTargetDialOptions = nil + } internal.WithBinaryLogger = withBinaryLogger internal.JoinDialOptions = newJoinDialOption internal.DisableGlobalDialOptions = newDisableGlobalDialOptions @@ -80,6 +94,7 @@ type dialOptions struct { idleTimeout time.Duration recvBufferPool SharedBufferPool defaultScheme string + maxCallAttempts int } // DialOption configures how we set up the connection. @@ -89,6 +104,19 @@ type DialOption interface { var globalDialOptions []DialOption +// perTargetDialOption takes a parsed target and returns a dial option to apply. +// +// This gets called after NewClient() parses the target, and allows per target +// configuration set through a returned DialOption. The DialOption will not take +// effect if specifies a resolver builder, as that Dial Option is factored in +// while parsing target. +type perTargetDialOption interface { + // DialOption returns a Dial Option to apply. + DialOptionForTarget(parsedTarget url.URL) DialOption +} + +var globalPerTargetDialOptions []perTargetDialOption + // EmptyDialOption does not alter the dial configuration. It can be embedded in // another structure to build custom dial options. // @@ -655,6 +683,7 @@ func defaultDialOptions() dialOptions { idleTimeout: 30 * time.Minute, recvBufferPool: nopBufferPool{}, defaultScheme: "dns", + maxCallAttempts: defaultMaxCallAttempts, } } @@ -712,6 +741,23 @@ func WithIdleTimeout(d time.Duration) DialOption { }) } +// WithMaxCallAttempts returns a DialOption that configures the maximum number +// of attempts per call (including retries and hedging) using the channel. +// Service owners may specify a higher value for these parameters, but higher +// values will be treated as equal to the maximum value by the client +// implementation. This mitigates security concerns related to the service +// config being transferred to the client via DNS. +// +// A value of 5 will be used if this dial option is not set or n < 2. +func WithMaxCallAttempts(n int) DialOption { + return newFuncDialOption(func(o *dialOptions) { + if n < 2 { + n = defaultMaxCallAttempts + } + o.maxCallAttempts = n + }) +} + // WithRecvBufferPool returns a DialOption that configures the ClientConn // to use the provided shared buffer pool for parsing incoming messages. Depending // on the application's workload, this could result in reduced memory allocation. diff --git a/vendor/google.golang.org/grpc/internal/backoff/backoff.go b/vendor/google.golang.org/grpc/internal/backoff/backoff.go index fed1c011..b15cf482 100644 --- a/vendor/google.golang.org/grpc/internal/backoff/backoff.go +++ b/vendor/google.golang.org/grpc/internal/backoff/backoff.go @@ -25,10 +25,10 @@ package backoff import ( "context" "errors" + "math/rand" "time" grpcbackoff "google.golang.org/grpc/backoff" - "google.golang.org/grpc/internal/grpcrand" ) // Strategy defines the methodology for backing off after a grpc connection @@ -67,7 +67,7 @@ func (bc Exponential) Backoff(retries int) time.Duration { } // Randomize backoff delays so that if a cluster of requests start at // the same time, they won't operate in lockstep. - backoff *= 1 + bc.Config.Jitter*(grpcrand.Float64()*2-1) + backoff *= 1 + bc.Config.Jitter*(rand.Float64()*2-1) if backoff < 0 { return 0 } diff --git a/vendor/google.golang.org/grpc/internal/envconfig/envconfig.go b/vendor/google.golang.org/grpc/internal/envconfig/envconfig.go index 9c915d9e..d9064871 100644 --- a/vendor/google.golang.org/grpc/internal/envconfig/envconfig.go +++ b/vendor/google.golang.org/grpc/internal/envconfig/envconfig.go @@ -40,6 +40,12 @@ var ( // ALTSMaxConcurrentHandshakes is the maximum number of concurrent ALTS // handshakes that can be performed. ALTSMaxConcurrentHandshakes = uint64FromEnv("GRPC_ALTS_MAX_CONCURRENT_HANDSHAKES", 100, 1, 100) + // EnforceALPNEnabled is set if TLS connections to servers with ALPN disabled + // should be rejected. The HTTP/2 protocol requires ALPN to be enabled, this + // option is present for backward compatibility. This option may be overridden + // by setting the environment variable "GRPC_ENFORCE_ALPN_ENABLED" to "true" + // or "false". + EnforceALPNEnabled = boolFromEnv("GRPC_ENFORCE_ALPN_ENABLED", false) ) func boolFromEnv(envVar string, def bool) bool { diff --git a/vendor/google.golang.org/grpc/internal/grpcrand/grpcrand.go b/vendor/google.golang.org/grpc/internal/grpcrand/grpcrand.go deleted file mode 100644 index 0126d6b5..00000000 --- a/vendor/google.golang.org/grpc/internal/grpcrand/grpcrand.go +++ /dev/null @@ -1,100 +0,0 @@ -//go:build !go1.21 - -// TODO: when this file is deleted (after Go 1.20 support is dropped), delete -// all of grpcrand and call the rand package directly. - -/* - * - * Copyright 2018 gRPC authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -// Package grpcrand implements math/rand functions in a concurrent-safe way -// with a global random source, independent of math/rand's global source. -package grpcrand - -import ( - "math/rand" - "sync" - "time" -) - -var ( - r = rand.New(rand.NewSource(time.Now().UnixNano())) - mu sync.Mutex -) - -// Int implements rand.Int on the grpcrand global source. -func Int() int { - mu.Lock() - defer mu.Unlock() - return r.Int() -} - -// Int63n implements rand.Int63n on the grpcrand global source. -func Int63n(n int64) int64 { - mu.Lock() - defer mu.Unlock() - return r.Int63n(n) -} - -// Intn implements rand.Intn on the grpcrand global source. -func Intn(n int) int { - mu.Lock() - defer mu.Unlock() - return r.Intn(n) -} - -// Int31n implements rand.Int31n on the grpcrand global source. -func Int31n(n int32) int32 { - mu.Lock() - defer mu.Unlock() - return r.Int31n(n) -} - -// Float64 implements rand.Float64 on the grpcrand global source. -func Float64() float64 { - mu.Lock() - defer mu.Unlock() - return r.Float64() -} - -// Uint64 implements rand.Uint64 on the grpcrand global source. -func Uint64() uint64 { - mu.Lock() - defer mu.Unlock() - return r.Uint64() -} - -// Uint32 implements rand.Uint32 on the grpcrand global source. -func Uint32() uint32 { - mu.Lock() - defer mu.Unlock() - return r.Uint32() -} - -// ExpFloat64 implements rand.ExpFloat64 on the grpcrand global source. -func ExpFloat64() float64 { - mu.Lock() - defer mu.Unlock() - return r.ExpFloat64() -} - -// Shuffle implements rand.Shuffle on the grpcrand global source. -var Shuffle = func(n int, f func(int, int)) { - mu.Lock() - defer mu.Unlock() - r.Shuffle(n, f) -} diff --git a/vendor/google.golang.org/grpc/internal/grpcrand/grpcrand_go1.21.go b/vendor/google.golang.org/grpc/internal/grpcrand/grpcrand_go1.21.go deleted file mode 100644 index c37299af..00000000 --- a/vendor/google.golang.org/grpc/internal/grpcrand/grpcrand_go1.21.go +++ /dev/null @@ -1,73 +0,0 @@ -//go:build go1.21 - -/* - * - * Copyright 2024 gRPC authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -// Package grpcrand implements math/rand functions in a concurrent-safe way -// with a global random source, independent of math/rand's global source. -package grpcrand - -import "math/rand" - -// This implementation will be used for Go version 1.21 or newer. -// For older versions, the original implementation with mutex will be used. - -// Int implements rand.Int on the grpcrand global source. -func Int() int { - return rand.Int() -} - -// Int63n implements rand.Int63n on the grpcrand global source. -func Int63n(n int64) int64 { - return rand.Int63n(n) -} - -// Intn implements rand.Intn on the grpcrand global source. -func Intn(n int) int { - return rand.Intn(n) -} - -// Int31n implements rand.Int31n on the grpcrand global source. -func Int31n(n int32) int32 { - return rand.Int31n(n) -} - -// Float64 implements rand.Float64 on the grpcrand global source. -func Float64() float64 { - return rand.Float64() -} - -// Uint64 implements rand.Uint64 on the grpcrand global source. -func Uint64() uint64 { - return rand.Uint64() -} - -// Uint32 implements rand.Uint32 on the grpcrand global source. -func Uint32() uint32 { - return rand.Uint32() -} - -// ExpFloat64 implements rand.ExpFloat64 on the grpcrand global source. -func ExpFloat64() float64 { - return rand.ExpFloat64() -} - -// Shuffle implements rand.Shuffle on the grpcrand global source. -var Shuffle = func(n int, f func(int, int)) { - rand.Shuffle(n, f) -} diff --git a/vendor/google.golang.org/grpc/internal/internal.go b/vendor/google.golang.org/grpc/internal/internal.go index 48d24bdb..5d665398 100644 --- a/vendor/google.golang.org/grpc/internal/internal.go +++ b/vendor/google.golang.org/grpc/internal/internal.go @@ -106,6 +106,14 @@ var ( // This is used in the 1.0 release of gcp/observability, and thus must not be // deleted or changed. ClearGlobalDialOptions func() + + // AddGlobalPerTargetDialOptions adds a PerTargetDialOption that will be + // configured for newly created ClientConns. + AddGlobalPerTargetDialOptions any // func (opt any) + // ClearGlobalPerTargetDialOptions clears the slice of global late apply + // dial options. + ClearGlobalPerTargetDialOptions func() + // JoinDialOptions combines the dial options passed as arguments into a // single dial option. JoinDialOptions any // func(...grpc.DialOption) grpc.DialOption @@ -126,7 +134,8 @@ var ( // deleted or changed. BinaryLogger any // func(binarylog.Logger) grpc.ServerOption - // SubscribeToConnectivityStateChanges adds a grpcsync.Subscriber to a provided grpc.ClientConn + // SubscribeToConnectivityStateChanges adds a grpcsync.Subscriber to a + // provided grpc.ClientConn. SubscribeToConnectivityStateChanges any // func(*grpc.ClientConn, grpcsync.Subscriber) // NewXDSResolverWithConfigForTesting creates a new xds resolver builder using @@ -184,25 +193,25 @@ var ( ChannelzTurnOffForTesting func() - // TriggerXDSResourceNameNotFoundForTesting triggers the resource-not-found - // error for a given resource type and name. This is usually triggered when - // the associated watch timer fires. For testing purposes, having this - // function makes events more predictable than relying on timer events. - TriggerXDSResourceNameNotFoundForTesting any // func(func(xdsresource.Type, string), string, string) error + // TriggerXDSResourceNotFoundForTesting causes the provided xDS Client to + // invoke resource-not-found error for the given resource type and name. + TriggerXDSResourceNotFoundForTesting any // func(xdsclient.XDSClient, xdsresource.Type, string) error - // TriggerXDSResourceNameNotFoundClient invokes the testing xDS Client - // singleton to invoke resource not found for a resource type name and - // resource name. - TriggerXDSResourceNameNotFoundClient any // func(string, string) error - - // FromOutgoingContextRaw returns the un-merged, intermediary contents of metadata.rawMD. + // FromOutgoingContextRaw returns the un-merged, intermediary contents of + // metadata.rawMD. FromOutgoingContextRaw any // func(context.Context) (metadata.MD, [][]string, bool) - // UserSetDefaultScheme is set to true if the user has overridden the default resolver scheme. + // UserSetDefaultScheme is set to true if the user has overridden the + // default resolver scheme. UserSetDefaultScheme bool = false + + // ShuffleAddressListForTesting pseudo-randomizes the order of addresses. n + // is the number of elements. swap swaps the elements with indexes i and j. + ShuffleAddressListForTesting any // func(n int, swap func(i, j int)) ) -// HealthChecker defines the signature of the client-side LB channel health checking function. +// HealthChecker defines the signature of the client-side LB channel health +// checking function. // // The implementation is expected to create a health checking RPC stream by // calling newStream(), watch for the health status of serviceName, and report diff --git a/vendor/google.golang.org/grpc/internal/resolver/dns/dns_resolver.go b/vendor/google.golang.org/grpc/internal/resolver/dns/dns_resolver.go index f3f52a59..4552db16 100644 --- a/vendor/google.golang.org/grpc/internal/resolver/dns/dns_resolver.go +++ b/vendor/google.golang.org/grpc/internal/resolver/dns/dns_resolver.go @@ -24,6 +24,7 @@ import ( "context" "encoding/json" "fmt" + "math/rand" "net" "os" "strconv" @@ -35,7 +36,6 @@ import ( "google.golang.org/grpc/grpclog" "google.golang.org/grpc/internal/backoff" "google.golang.org/grpc/internal/envconfig" - "google.golang.org/grpc/internal/grpcrand" "google.golang.org/grpc/internal/resolver/dns/internal" "google.golang.org/grpc/resolver" "google.golang.org/grpc/serviceconfig" @@ -63,6 +63,8 @@ var ( func init() { resolver.Register(NewBuilder()) internal.TimeAfterFunc = time.After + internal.TimeNowFunc = time.Now + internal.TimeUntilFunc = time.Until internal.NewNetResolver = newNetResolver internal.AddressDialer = addressDialer } @@ -209,12 +211,12 @@ func (d *dnsResolver) watcher() { err = d.cc.UpdateState(*state) } - var waitTime time.Duration + var nextResolutionTime time.Time if err == nil { // Success resolving, wait for the next ResolveNow. However, also wait 30 // seconds at the very least to prevent constantly re-resolving. backoffIndex = 1 - waitTime = MinResolutionInterval + nextResolutionTime = internal.TimeNowFunc().Add(MinResolutionInterval) select { case <-d.ctx.Done(): return @@ -223,13 +225,13 @@ func (d *dnsResolver) watcher() { } else { // Poll on an error found in DNS Resolver or an error received from // ClientConn. - waitTime = backoff.DefaultExponential.Backoff(backoffIndex) + nextResolutionTime = internal.TimeNowFunc().Add(backoff.DefaultExponential.Backoff(backoffIndex)) backoffIndex++ } select { case <-d.ctx.Done(): return - case <-internal.TimeAfterFunc(waitTime): + case <-internal.TimeAfterFunc(internal.TimeUntilFunc(nextResolutionTime)): } } } @@ -423,7 +425,7 @@ func chosenByPercentage(a *int) bool { if a == nil { return true } - return grpcrand.Intn(100)+1 <= *a + return rand.Intn(100)+1 <= *a } func canaryingSC(js string) string { diff --git a/vendor/google.golang.org/grpc/internal/resolver/dns/internal/internal.go b/vendor/google.golang.org/grpc/internal/resolver/dns/internal/internal.go index a7ecaf8d..c0eae4f5 100644 --- a/vendor/google.golang.org/grpc/internal/resolver/dns/internal/internal.go +++ b/vendor/google.golang.org/grpc/internal/resolver/dns/internal/internal.go @@ -51,11 +51,22 @@ var ( // The following vars are overridden from tests. var ( // TimeAfterFunc is used by the DNS resolver to wait for the given duration - // to elapse. In non-test code, this is implemented by time.After. In test + // to elapse. In non-test code, this is implemented by time.After. In test // code, this can be used to control the amount of time the resolver is // blocked waiting for the duration to elapse. TimeAfterFunc func(time.Duration) <-chan time.Time + // TimeNowFunc is used by the DNS resolver to get the current time. + // In non-test code, this is implemented by time.Now. In test code, + // this can be used to control the current time for the resolver. + TimeNowFunc func() time.Time + + // TimeUntilFunc is used by the DNS resolver to calculate the remaining + // wait time for re-resolution. In non-test code, this is implemented by + // time.Until. In test code, this can be used to control the remaining + // time for resolver to wait for re-resolution. + TimeUntilFunc func(time.Time) time.Duration + // NewNetResolver returns the net.Resolver instance for the given target. NewNetResolver func(string) (NetResolver, error) diff --git a/vendor/google.golang.org/grpc/internal/transport/http2_server.go b/vendor/google.golang.org/grpc/internal/transport/http2_server.go index cab0e2d3..b7091165 100644 --- a/vendor/google.golang.org/grpc/internal/transport/http2_server.go +++ b/vendor/google.golang.org/grpc/internal/transport/http2_server.go @@ -25,6 +25,7 @@ import ( "fmt" "io" "math" + "math/rand" "net" "net/http" "strconv" @@ -43,7 +44,6 @@ import ( "google.golang.org/grpc/codes" "google.golang.org/grpc/credentials" "google.golang.org/grpc/internal/channelz" - "google.golang.org/grpc/internal/grpcrand" "google.golang.org/grpc/internal/grpcsync" "google.golang.org/grpc/keepalive" "google.golang.org/grpc/metadata" @@ -1440,7 +1440,7 @@ func getJitter(v time.Duration) time.Duration { } // Generate a jitter between +/- 10% of the value. r := int64(v / 10) - j := grpcrand.Int63n(2*r) - r + j := rand.Int63n(2*r) - r return time.Duration(j) } diff --git a/vendor/google.golang.org/grpc/metadata/metadata.go b/vendor/google.golang.org/grpc/metadata/metadata.go index 6c01a9b3..1e9485fd 100644 --- a/vendor/google.golang.org/grpc/metadata/metadata.go +++ b/vendor/google.golang.org/grpc/metadata/metadata.go @@ -90,21 +90,6 @@ func Pairs(kv ...string) MD { return md } -// String implements the Stringer interface for pretty-printing a MD. -// Ordering of the values is non-deterministic as it ranges over a map. -func (md MD) String() string { - var sb strings.Builder - fmt.Fprintf(&sb, "MD{") - for k, v := range md { - if sb.Len() > 3 { - fmt.Fprintf(&sb, ", ") - } - fmt.Fprintf(&sb, "%s=[%s]", k, strings.Join(v, ", ")) - } - fmt.Fprintf(&sb, "}") - return sb.String() -} - // Len returns the number of items in md. func (md MD) Len() int { return len(md) diff --git a/vendor/google.golang.org/grpc/picker_wrapper.go b/vendor/google.golang.org/grpc/picker_wrapper.go index 56e8aba7..bdaa2130 100644 --- a/vendor/google.golang.org/grpc/picker_wrapper.go +++ b/vendor/google.golang.org/grpc/picker_wrapper.go @@ -22,7 +22,7 @@ import ( "context" "fmt" "io" - "sync" + "sync/atomic" "google.golang.org/grpc/balancer" "google.golang.org/grpc/codes" @@ -33,35 +33,43 @@ import ( "google.golang.org/grpc/status" ) +// pickerGeneration stores a picker and a channel used to signal that a picker +// newer than this one is available. +type pickerGeneration struct { + // picker is the picker produced by the LB policy. May be nil if a picker + // has never been produced. + picker balancer.Picker + // blockingCh is closed when the picker has been invalidated because there + // is a new one available. + blockingCh chan struct{} +} + // pickerWrapper is a wrapper of balancer.Picker. It blocks on certain pick // actions and unblock when there's a picker update. type pickerWrapper struct { - mu sync.Mutex - done bool - blockingCh chan struct{} - picker balancer.Picker + // If pickerGen holds a nil pointer, the pickerWrapper is closed. + pickerGen atomic.Pointer[pickerGeneration] statsHandlers []stats.Handler // to record blocking picker calls } func newPickerWrapper(statsHandlers []stats.Handler) *pickerWrapper { - return &pickerWrapper{ - blockingCh: make(chan struct{}), + pw := &pickerWrapper{ statsHandlers: statsHandlers, } + pw.pickerGen.Store(&pickerGeneration{ + blockingCh: make(chan struct{}), + }) + return pw } -// updatePicker is called by UpdateBalancerState. It unblocks all blocked pick. +// updatePicker is called by UpdateState calls from the LB policy. It +// unblocks all blocked pick. func (pw *pickerWrapper) updatePicker(p balancer.Picker) { - pw.mu.Lock() - if pw.done { - pw.mu.Unlock() - return - } - pw.picker = p - // pw.blockingCh should never be nil. - close(pw.blockingCh) - pw.blockingCh = make(chan struct{}) - pw.mu.Unlock() + old := pw.pickerGen.Swap(&pickerGeneration{ + picker: p, + blockingCh: make(chan struct{}), + }) + close(old.blockingCh) } // doneChannelzWrapper performs the following: @@ -98,20 +106,17 @@ func (pw *pickerWrapper) pick(ctx context.Context, failfast bool, info balancer. var lastPickErr error for { - pw.mu.Lock() - if pw.done { - pw.mu.Unlock() + pg := pw.pickerGen.Load() + if pg == nil { return nil, balancer.PickResult{}, ErrClientConnClosing } - - if pw.picker == nil { - ch = pw.blockingCh + if pg.picker == nil { + ch = pg.blockingCh } - if ch == pw.blockingCh { + if ch == pg.blockingCh { // This could happen when either: // - pw.picker is nil (the previous if condition), or - // - has called pick on the current picker. - pw.mu.Unlock() + // - we have already called pick on the current picker. select { case <-ctx.Done(): var errStr string @@ -145,9 +150,8 @@ func (pw *pickerWrapper) pick(ctx context.Context, failfast bool, info balancer. } } - ch = pw.blockingCh - p := pw.picker - pw.mu.Unlock() + ch = pg.blockingCh + p := pg.picker pickResult, err := p.Pick(info) if err != nil { @@ -197,24 +201,15 @@ func (pw *pickerWrapper) pick(ctx context.Context, failfast bool, info balancer. } func (pw *pickerWrapper) close() { - pw.mu.Lock() - defer pw.mu.Unlock() - if pw.done { - return - } - pw.done = true - close(pw.blockingCh) + old := pw.pickerGen.Swap(nil) + close(old.blockingCh) } // reset clears the pickerWrapper and prepares it for being used again when idle // mode is exited. func (pw *pickerWrapper) reset() { - pw.mu.Lock() - defer pw.mu.Unlock() - if pw.done { - return - } - pw.blockingCh = make(chan struct{}) + old := pw.pickerGen.Swap(&pickerGeneration{blockingCh: make(chan struct{})}) + close(old.blockingCh) } // dropError is a wrapper error that indicates the LB policy wishes to drop the diff --git a/vendor/google.golang.org/grpc/reflection/grpc_reflection_v1/reflection.pb.go b/vendor/google.golang.org/grpc/reflection/grpc_reflection_v1/reflection.pb.go index 6c49c233..666eda8e 100644 --- a/vendor/google.golang.org/grpc/reflection/grpc_reflection_v1/reflection.pb.go +++ b/vendor/google.golang.org/grpc/reflection/grpc_reflection_v1/reflection.pb.go @@ -21,7 +21,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.33.0 +// protoc-gen-go v1.34.1 // protoc v4.25.2 // source: grpc/reflection/v1/reflection.proto diff --git a/vendor/google.golang.org/grpc/reflection/grpc_reflection_v1/reflection_grpc.pb.go b/vendor/google.golang.org/grpc/reflection/grpc_reflection_v1/reflection_grpc.pb.go index 6e544f81..17d21fde 100644 --- a/vendor/google.golang.org/grpc/reflection/grpc_reflection_v1/reflection_grpc.pb.go +++ b/vendor/google.golang.org/grpc/reflection/grpc_reflection_v1/reflection_grpc.pb.go @@ -21,7 +21,7 @@ // Code generated by protoc-gen-go-grpc. DO NOT EDIT. // versions: -// - protoc-gen-go-grpc v1.3.0 +// - protoc-gen-go-grpc v1.4.0 // - protoc v4.25.2 // source: grpc/reflection/v1/reflection.proto diff --git a/vendor/google.golang.org/grpc/reflection/grpc_reflection_v1alpha/reflection.pb.go b/vendor/google.golang.org/grpc/reflection/grpc_reflection_v1alpha/reflection.pb.go index 909b24a1..cd032ace 100644 --- a/vendor/google.golang.org/grpc/reflection/grpc_reflection_v1alpha/reflection.pb.go +++ b/vendor/google.golang.org/grpc/reflection/grpc_reflection_v1alpha/reflection.pb.go @@ -18,7 +18,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.33.0 +// protoc-gen-go v1.34.1 // protoc v4.25.2 // grpc/reflection/v1alpha/reflection.proto is a deprecated file. diff --git a/vendor/google.golang.org/grpc/reflection/grpc_reflection_v1alpha/reflection_grpc.pb.go b/vendor/google.golang.org/grpc/reflection/grpc_reflection_v1alpha/reflection_grpc.pb.go index 3de5dc35..93886e38 100644 --- a/vendor/google.golang.org/grpc/reflection/grpc_reflection_v1alpha/reflection_grpc.pb.go +++ b/vendor/google.golang.org/grpc/reflection/grpc_reflection_v1alpha/reflection_grpc.pb.go @@ -18,7 +18,7 @@ // Code generated by protoc-gen-go-grpc. DO NOT EDIT. // versions: -// - protoc-gen-go-grpc v1.3.0 +// - protoc-gen-go-grpc v1.4.0 // - protoc v4.25.2 // grpc/reflection/v1alpha/reflection.proto is a deprecated file. diff --git a/vendor/google.golang.org/grpc/resolver_wrapper.go b/vendor/google.golang.org/grpc/resolver_wrapper.go index 9dcc9780..c5fb4523 100644 --- a/vendor/google.golang.org/grpc/resolver_wrapper.go +++ b/vendor/google.golang.org/grpc/resolver_wrapper.go @@ -171,7 +171,7 @@ func (ccr *ccResolverWrapper) NewAddress(addrs []resolver.Address) { // ParseServiceConfig is called by resolver implementations to parse a JSON // representation of the service config. func (ccr *ccResolverWrapper) ParseServiceConfig(scJSON string) *serviceconfig.ParseResult { - return parseServiceConfig(scJSON) + return parseServiceConfig(scJSON, ccr.cc.dopts.maxCallAttempts) } // addChannelzTraceEvent adds a channelz trace event containing the new diff --git a/vendor/google.golang.org/grpc/service_config.go b/vendor/google.golang.org/grpc/service_config.go index 9da8fc80..2671c5ef 100644 --- a/vendor/google.golang.org/grpc/service_config.go +++ b/vendor/google.golang.org/grpc/service_config.go @@ -26,6 +26,7 @@ import ( "time" "google.golang.org/grpc/balancer" + "google.golang.org/grpc/balancer/pickfirst" "google.golang.org/grpc/codes" "google.golang.org/grpc/internal" "google.golang.org/grpc/internal/balancer/gracefulswitch" @@ -163,9 +164,11 @@ type jsonSC struct { } func init() { - internal.ParseServiceConfig = parseServiceConfig + internal.ParseServiceConfig = func(js string) *serviceconfig.ParseResult { + return parseServiceConfig(js, defaultMaxCallAttempts) + } } -func parseServiceConfig(js string) *serviceconfig.ParseResult { +func parseServiceConfig(js string, maxAttempts int) *serviceconfig.ParseResult { if len(js) == 0 { return &serviceconfig.ParseResult{Err: fmt.Errorf("no JSON service config provided")} } @@ -183,12 +186,12 @@ func parseServiceConfig(js string) *serviceconfig.ParseResult { } c := rsc.LoadBalancingConfig if c == nil { - name := PickFirstBalancerName + name := pickfirst.Name if rsc.LoadBalancingPolicy != nil { name = *rsc.LoadBalancingPolicy } if balancer.Get(name) == nil { - name = PickFirstBalancerName + name = pickfirst.Name } cfg := []map[string]any{{name: struct{}{}}} strCfg, err := json.Marshal(cfg) @@ -218,7 +221,7 @@ func parseServiceConfig(js string) *serviceconfig.ParseResult { WaitForReady: m.WaitForReady, Timeout: (*time.Duration)(m.Timeout), } - if mc.RetryPolicy, err = convertRetryPolicy(m.RetryPolicy); err != nil { + if mc.RetryPolicy, err = convertRetryPolicy(m.RetryPolicy, maxAttempts); err != nil { logger.Warningf("grpc: unmarshalling service config %s: %v", js, err) return &serviceconfig.ParseResult{Err: err} } @@ -264,7 +267,7 @@ func parseServiceConfig(js string) *serviceconfig.ParseResult { return &serviceconfig.ParseResult{Config: &sc} } -func convertRetryPolicy(jrp *jsonRetryPolicy) (p *internalserviceconfig.RetryPolicy, err error) { +func convertRetryPolicy(jrp *jsonRetryPolicy, maxAttempts int) (p *internalserviceconfig.RetryPolicy, err error) { if jrp == nil { return nil, nil } @@ -278,17 +281,16 @@ func convertRetryPolicy(jrp *jsonRetryPolicy) (p *internalserviceconfig.RetryPol return nil, nil } + if jrp.MaxAttempts < maxAttempts { + maxAttempts = jrp.MaxAttempts + } rp := &internalserviceconfig.RetryPolicy{ - MaxAttempts: jrp.MaxAttempts, + MaxAttempts: maxAttempts, InitialBackoff: time.Duration(jrp.InitialBackoff), MaxBackoff: time.Duration(jrp.MaxBackoff), BackoffMultiplier: jrp.BackoffMultiplier, RetryableStatusCodes: make(map[codes.Code]bool), } - if rp.MaxAttempts > 5 { - // TODO(retry): Make the max maxAttempts configurable. - rp.MaxAttempts = 5 - } for _, code := range jrp.RetryableStatusCodes { rp.RetryableStatusCodes[code] = true } diff --git a/vendor/google.golang.org/grpc/stream.go b/vendor/google.golang.org/grpc/stream.go index b54563e8..8051ef5b 100644 --- a/vendor/google.golang.org/grpc/stream.go +++ b/vendor/google.golang.org/grpc/stream.go @@ -23,6 +23,7 @@ import ( "errors" "io" "math" + "math/rand" "strconv" "sync" "time" @@ -34,7 +35,6 @@ import ( "google.golang.org/grpc/internal/balancerload" "google.golang.org/grpc/internal/binarylog" "google.golang.org/grpc/internal/channelz" - "google.golang.org/grpc/internal/grpcrand" "google.golang.org/grpc/internal/grpcutil" imetadata "google.golang.org/grpc/internal/metadata" iresolver "google.golang.org/grpc/internal/resolver" @@ -699,7 +699,7 @@ func (a *csAttempt) shouldRetry(err error) (bool, error) { if max := float64(rp.MaxBackoff); cur > max { cur = max } - dur = time.Duration(grpcrand.Int63n(int64(cur))) + dur = time.Duration(rand.Int63n(int64(cur))) cs.numRetriesSincePushback++ } diff --git a/vendor/google.golang.org/grpc/version.go b/vendor/google.golang.org/grpc/version.go index e1806e76..bafaef99 100644 --- a/vendor/google.golang.org/grpc/version.go +++ b/vendor/google.golang.org/grpc/version.go @@ -19,4 +19,4 @@ package grpc // Version is the current grpc version. -const Version = "1.64.0" +const Version = "1.65.0" diff --git a/vendor/google.golang.org/protobuf/encoding/protojson/encode.go b/vendor/google.golang.org/protobuf/encoding/protojson/encode.go index 3f75098b..29846df2 100644 --- a/vendor/google.golang.org/protobuf/encoding/protojson/encode.go +++ b/vendor/google.golang.org/protobuf/encoding/protojson/encode.go @@ -25,15 +25,17 @@ const defaultIndent = " " // Format formats the message as a multiline string. // This function is only intended for human consumption and ignores errors. -// Do not depend on the output being stable. It may change over time across -// different versions of the program. +// Do not depend on the output being stable. Its output will change across +// different builds of your program, even when using the same version of the +// protobuf module. func Format(m proto.Message) string { return MarshalOptions{Multiline: true}.Format(m) } // Marshal writes the given [proto.Message] in JSON format using default options. -// Do not depend on the output being stable. It may change over time across -// different versions of the program. +// Do not depend on the output being stable. Its output will change across +// different builds of your program, even when using the same version of the +// protobuf module. func Marshal(m proto.Message) ([]byte, error) { return MarshalOptions{}.Marshal(m) } @@ -110,8 +112,9 @@ type MarshalOptions struct { // Format formats the message as a string. // This method is only intended for human consumption and ignores errors. -// Do not depend on the output being stable. It may change over time across -// different versions of the program. +// Do not depend on the output being stable. Its output will change across +// different builds of your program, even when using the same version of the +// protobuf module. func (o MarshalOptions) Format(m proto.Message) string { if m == nil || !m.ProtoReflect().IsValid() { return "" // invalid syntax, but okay since this is for debugging @@ -122,8 +125,9 @@ func (o MarshalOptions) Format(m proto.Message) string { } // Marshal marshals the given [proto.Message] in the JSON format using options in -// MarshalOptions. Do not depend on the output being stable. It may change over -// time across different versions of the program. +// Do not depend on the output being stable. Its output will change across +// different builds of your program, even when using the same version of the +// protobuf module. func (o MarshalOptions) Marshal(m proto.Message) ([]byte, error) { return o.marshal(nil, m) } diff --git a/vendor/google.golang.org/protobuf/encoding/prototext/encode.go b/vendor/google.golang.org/protobuf/encoding/prototext/encode.go index 95967e81..1f57e661 100644 --- a/vendor/google.golang.org/protobuf/encoding/prototext/encode.go +++ b/vendor/google.golang.org/protobuf/encoding/prototext/encode.go @@ -27,15 +27,17 @@ const defaultIndent = " " // Format formats the message as a multiline string. // This function is only intended for human consumption and ignores errors. -// Do not depend on the output being stable. It may change over time across -// different versions of the program. +// Do not depend on the output being stable. Its output will change across +// different builds of your program, even when using the same version of the +// protobuf module. func Format(m proto.Message) string { return MarshalOptions{Multiline: true}.Format(m) } // Marshal writes the given [proto.Message] in textproto format using default -// options. Do not depend on the output being stable. It may change over time -// across different versions of the program. +// options. Do not depend on the output being stable. Its output will change +// across different builds of your program, even when using the same version of +// the protobuf module. func Marshal(m proto.Message) ([]byte, error) { return MarshalOptions{}.Marshal(m) } @@ -84,8 +86,9 @@ type MarshalOptions struct { // Format formats the message as a string. // This method is only intended for human consumption and ignores errors. -// Do not depend on the output being stable. It may change over time across -// different versions of the program. +// Do not depend on the output being stable. Its output will change across +// different builds of your program, even when using the same version of the +// protobuf module. func (o MarshalOptions) Format(m proto.Message) string { if m == nil || !m.ProtoReflect().IsValid() { return "" // invalid syntax, but okay since this is for debugging @@ -98,8 +101,9 @@ func (o MarshalOptions) Format(m proto.Message) string { } // Marshal writes the given [proto.Message] in textproto format using options in -// MarshalOptions object. Do not depend on the output being stable. It may -// change over time across different versions of the program. +// MarshalOptions object. Do not depend on the output being stable. Its output +// will change across different builds of your program, even when using the +// same version of the protobuf module. func (o MarshalOptions) Marshal(m proto.Message) ([]byte, error) { return o.marshal(nil, m) } diff --git a/vendor/google.golang.org/protobuf/internal/editiondefaults/editions_defaults.binpb b/vendor/google.golang.org/protobuf/internal/editiondefaults/editions_defaults.binpb index f691305eb4f73440cd48caba949023eab52ef304..ff6a38360add36f53d48bb0863b701696e0d7b2d 100644 GIT binary patch literal 93 zcmd;*mUzal#C*w)K}(Q>QGiK;Nr72|(SYfa9TNv5m$bxlxFnMRqXeS@6Ht;7B*_4j Ve8H{+(u69m1u{(G8N0>{b^xZ!4_5#H literal 78 zcmd-Q6B6WL6kw8IQef6#G+?@9$Hc)X@r<1dB+ewjD8Z<}1Qcfki8Dw%hln$xi@#u3 Kc*d^rf*k;APzzxI diff --git a/vendor/google.golang.org/protobuf/internal/errors/errors.go b/vendor/google.golang.org/protobuf/internal/errors/errors.go index 20c17b35..d9671982 100644 --- a/vendor/google.golang.org/protobuf/internal/errors/errors.go +++ b/vendor/google.golang.org/protobuf/internal/errors/errors.go @@ -87,3 +87,18 @@ func InvalidUTF8(name string) error { func RequiredNotSet(name string) error { return New("required field %v not set", name) } + +type SizeMismatchError struct { + Calculated, Measured int +} + +func (e *SizeMismatchError) Error() string { + return fmt.Sprintf("size mismatch (see https://github.com/golang/protobuf/issues/1609): calculated=%d, measured=%d", e.Calculated, e.Measured) +} + +func MismatchedSizeCalculation(calculated, measured int) error { + return &SizeMismatchError{ + Calculated: calculated, + Measured: measured, + } +} diff --git a/vendor/google.golang.org/protobuf/internal/filedesc/desc.go b/vendor/google.golang.org/protobuf/internal/filedesc/desc.go index 55b5de1a..ece53bea 100644 --- a/vendor/google.golang.org/protobuf/internal/filedesc/desc.go +++ b/vendor/google.golang.org/protobuf/internal/filedesc/desc.go @@ -422,14 +422,6 @@ type ( Cardinality protoreflect.Cardinality Kind protoreflect.Kind EditionFeatures EditionFeatures - // To resolve the EditionFeatures we need to resolve the Extendee which - // happens at the end of the initialization of L1. Thus, we need to buffer - // the unresolved features (which are parsed when starting to initialize - // L1). We cannot move this to L2 because it is required to initialize - // Kind properly. Because some of the options (i.e. packed) affect the - // EditionFeatures we need to unmarshal the full options after resolving - // the Extendee. - rawOptions []byte } ExtensionL2 struct { Options func() protoreflect.ProtoMessage @@ -457,7 +449,16 @@ func (xd *Extension) HasPresence() bool { return xd.L1.Cardi func (xd *Extension) HasOptionalKeyword() bool { return (xd.L0.ParentFile.L1.Syntax == protoreflect.Proto2 && xd.L1.Cardinality == protoreflect.Optional) || xd.lazyInit().IsProto3Optional } -func (xd *Extension) IsPacked() bool { return xd.L1.EditionFeatures.IsPacked } +func (xd *Extension) IsPacked() bool { + if xd.L1.Cardinality != protoreflect.Repeated { + return false + } + switch xd.L1.Kind { + case protoreflect.StringKind, protoreflect.BytesKind, protoreflect.MessageKind, protoreflect.GroupKind: + return false + } + return xd.L1.EditionFeatures.IsPacked +} func (xd *Extension) IsExtension() bool { return true } func (xd *Extension) IsWeak() bool { return false } func (xd *Extension) IsList() bool { return xd.Cardinality() == protoreflect.Repeated } diff --git a/vendor/google.golang.org/protobuf/internal/filedesc/desc_init.go b/vendor/google.golang.org/protobuf/internal/filedesc/desc_init.go index 1de5ea9c..3bc3b1cd 100644 --- a/vendor/google.golang.org/protobuf/internal/filedesc/desc_init.go +++ b/vendor/google.golang.org/protobuf/internal/filedesc/desc_init.go @@ -34,20 +34,6 @@ func newRawFile(db Builder) *File { for i := range fd.allExtensions { xd := &fd.allExtensions[i] xd.L1.Extendee = fd.resolveMessageDependency(xd.L1.Extendee, listExtTargets, int32(i)) - - // If the Extendee is not resolved, we cannot resolve the edition - // features of the parent. This should (to my knowledge) only happen - // for v1 messages for which we don't support editions. In v2 the - // Extendee should be resolved at binary start up time. - if _, ok := xd.L1.Extendee.(PlaceholderMessage); !ok { - xd.L1.EditionFeatures = featuresFromParentDesc(xd.L1.Extendee) - } - if xd.L1.rawOptions != nil { - xd.unmarshalOptions(xd.L1.rawOptions) - } - if xd.L1.Kind == protoreflect.MessageKind && xd.L1.EditionFeatures.IsDelimitedEncoded { - xd.L1.Kind = protoreflect.GroupKind - } } fd.checkDecls() @@ -459,6 +445,7 @@ func (xd *Extension) unmarshalSeed(b []byte, sb *strs.Builder, pf *File, pd prot xd.L0.ParentFile = pf xd.L0.Parent = pd xd.L0.Index = i + xd.L1.EditionFeatures = featuresFromParentDesc(pd) for len(b) > 0 { num, typ, n := protowire.ConsumeTag(b) @@ -484,13 +471,17 @@ func (xd *Extension) unmarshalSeed(b []byte, sb *strs.Builder, pf *File, pd prot case genid.FieldDescriptorProto_Extendee_field_number: xd.L1.Extendee = PlaceholderMessage(makeFullName(sb, v)) case genid.FieldDescriptorProto_Options_field_number: - xd.L1.rawOptions = v + xd.unmarshalOptions(v) } default: m := protowire.ConsumeFieldValue(num, typ, b) b = b[m:] } } + + if xd.L1.Kind == protoreflect.MessageKind && xd.L1.EditionFeatures.IsDelimitedEncoded { + xd.L1.Kind = protoreflect.GroupKind + } } func (xd *Extension) unmarshalOptions(b []byte) { diff --git a/vendor/google.golang.org/protobuf/internal/filedesc/desc_list_gen.go b/vendor/google.golang.org/protobuf/internal/filedesc/desc_list_gen.go index 30db19fd..f4107c05 100644 --- a/vendor/google.golang.org/protobuf/internal/filedesc/desc_list_gen.go +++ b/vendor/google.golang.org/protobuf/internal/filedesc/desc_list_gen.go @@ -8,6 +8,7 @@ package filedesc import ( "fmt" + "strings" "sync" "google.golang.org/protobuf/internal/descfmt" @@ -198,6 +199,16 @@ func (p *Fields) lazyInit() *Fields { if _, ok := p.byText[d.TextName()]; !ok { p.byText[d.TextName()] = d } + if isGroupLike(d) { + lowerJSONName := strings.ToLower(d.JSONName()) + if _, ok := p.byJSON[lowerJSONName]; !ok { + p.byJSON[lowerJSONName] = d + } + lowerTextName := strings.ToLower(d.TextName()) + if _, ok := p.byText[lowerTextName]; !ok { + p.byText[lowerTextName] = d + } + } if _, ok := p.byNum[d.Number()]; !ok { p.byNum[d.Number()] = d } diff --git a/vendor/google.golang.org/protobuf/internal/filedesc/editions.go b/vendor/google.golang.org/protobuf/internal/filedesc/editions.go index d1e16a26..11f5f356 100644 --- a/vendor/google.golang.org/protobuf/internal/filedesc/editions.go +++ b/vendor/google.golang.org/protobuf/internal/filedesc/editions.go @@ -108,7 +108,9 @@ func unmarshalEditionDefault(b []byte) { v, m := protowire.ConsumeBytes(b) b = b[m:] switch num { - case genid.FeatureSetDefaults_FeatureSetEditionDefault_Features_field_number: + case genid.FeatureSetDefaults_FeatureSetEditionDefault_FixedFeatures_field_number: + fs = unmarshalFeatureSet(v, fs) + case genid.FeatureSetDefaults_FeatureSetEditionDefault_OverridableFeatures_field_number: fs = unmarshalFeatureSet(v, fs) } } diff --git a/vendor/google.golang.org/protobuf/internal/genid/descriptor_gen.go b/vendor/google.golang.org/protobuf/internal/genid/descriptor_gen.go index 40272c89..1447a119 100644 --- a/vendor/google.golang.org/protobuf/internal/genid/descriptor_gen.go +++ b/vendor/google.golang.org/protobuf/internal/genid/descriptor_gen.go @@ -21,6 +21,7 @@ const ( // Enum values for google.protobuf.Edition. const ( Edition_EDITION_UNKNOWN_enum_value = 0 + Edition_EDITION_LEGACY_enum_value = 900 Edition_EDITION_PROTO2_enum_value = 998 Edition_EDITION_PROTO3_enum_value = 999 Edition_EDITION_2023_enum_value = 1000 @@ -653,6 +654,7 @@ const ( FieldOptions_Targets_field_name protoreflect.Name = "targets" FieldOptions_EditionDefaults_field_name protoreflect.Name = "edition_defaults" FieldOptions_Features_field_name protoreflect.Name = "features" + FieldOptions_FeatureSupport_field_name protoreflect.Name = "feature_support" FieldOptions_UninterpretedOption_field_name protoreflect.Name = "uninterpreted_option" FieldOptions_Ctype_field_fullname protoreflect.FullName = "google.protobuf.FieldOptions.ctype" @@ -667,6 +669,7 @@ const ( FieldOptions_Targets_field_fullname protoreflect.FullName = "google.protobuf.FieldOptions.targets" FieldOptions_EditionDefaults_field_fullname protoreflect.FullName = "google.protobuf.FieldOptions.edition_defaults" FieldOptions_Features_field_fullname protoreflect.FullName = "google.protobuf.FieldOptions.features" + FieldOptions_FeatureSupport_field_fullname protoreflect.FullName = "google.protobuf.FieldOptions.feature_support" FieldOptions_UninterpretedOption_field_fullname protoreflect.FullName = "google.protobuf.FieldOptions.uninterpreted_option" ) @@ -684,6 +687,7 @@ const ( FieldOptions_Targets_field_number protoreflect.FieldNumber = 19 FieldOptions_EditionDefaults_field_number protoreflect.FieldNumber = 20 FieldOptions_Features_field_number protoreflect.FieldNumber = 21 + FieldOptions_FeatureSupport_field_number protoreflect.FieldNumber = 22 FieldOptions_UninterpretedOption_field_number protoreflect.FieldNumber = 999 ) @@ -767,6 +771,33 @@ const ( FieldOptions_EditionDefault_Value_field_number protoreflect.FieldNumber = 2 ) +// Names for google.protobuf.FieldOptions.FeatureSupport. +const ( + FieldOptions_FeatureSupport_message_name protoreflect.Name = "FeatureSupport" + FieldOptions_FeatureSupport_message_fullname protoreflect.FullName = "google.protobuf.FieldOptions.FeatureSupport" +) + +// Field names for google.protobuf.FieldOptions.FeatureSupport. +const ( + FieldOptions_FeatureSupport_EditionIntroduced_field_name protoreflect.Name = "edition_introduced" + FieldOptions_FeatureSupport_EditionDeprecated_field_name protoreflect.Name = "edition_deprecated" + FieldOptions_FeatureSupport_DeprecationWarning_field_name protoreflect.Name = "deprecation_warning" + FieldOptions_FeatureSupport_EditionRemoved_field_name protoreflect.Name = "edition_removed" + + FieldOptions_FeatureSupport_EditionIntroduced_field_fullname protoreflect.FullName = "google.protobuf.FieldOptions.FeatureSupport.edition_introduced" + FieldOptions_FeatureSupport_EditionDeprecated_field_fullname protoreflect.FullName = "google.protobuf.FieldOptions.FeatureSupport.edition_deprecated" + FieldOptions_FeatureSupport_DeprecationWarning_field_fullname protoreflect.FullName = "google.protobuf.FieldOptions.FeatureSupport.deprecation_warning" + FieldOptions_FeatureSupport_EditionRemoved_field_fullname protoreflect.FullName = "google.protobuf.FieldOptions.FeatureSupport.edition_removed" +) + +// Field numbers for google.protobuf.FieldOptions.FeatureSupport. +const ( + FieldOptions_FeatureSupport_EditionIntroduced_field_number protoreflect.FieldNumber = 1 + FieldOptions_FeatureSupport_EditionDeprecated_field_number protoreflect.FieldNumber = 2 + FieldOptions_FeatureSupport_DeprecationWarning_field_number protoreflect.FieldNumber = 3 + FieldOptions_FeatureSupport_EditionRemoved_field_number protoreflect.FieldNumber = 4 +) + // Names for google.protobuf.OneofOptions. const ( OneofOptions_message_name protoreflect.Name = "OneofOptions" @@ -1110,17 +1141,20 @@ const ( // Field names for google.protobuf.FeatureSetDefaults.FeatureSetEditionDefault. const ( - FeatureSetDefaults_FeatureSetEditionDefault_Edition_field_name protoreflect.Name = "edition" - FeatureSetDefaults_FeatureSetEditionDefault_Features_field_name protoreflect.Name = "features" + FeatureSetDefaults_FeatureSetEditionDefault_Edition_field_name protoreflect.Name = "edition" + FeatureSetDefaults_FeatureSetEditionDefault_OverridableFeatures_field_name protoreflect.Name = "overridable_features" + FeatureSetDefaults_FeatureSetEditionDefault_FixedFeatures_field_name protoreflect.Name = "fixed_features" - FeatureSetDefaults_FeatureSetEditionDefault_Edition_field_fullname protoreflect.FullName = "google.protobuf.FeatureSetDefaults.FeatureSetEditionDefault.edition" - FeatureSetDefaults_FeatureSetEditionDefault_Features_field_fullname protoreflect.FullName = "google.protobuf.FeatureSetDefaults.FeatureSetEditionDefault.features" + FeatureSetDefaults_FeatureSetEditionDefault_Edition_field_fullname protoreflect.FullName = "google.protobuf.FeatureSetDefaults.FeatureSetEditionDefault.edition" + FeatureSetDefaults_FeatureSetEditionDefault_OverridableFeatures_field_fullname protoreflect.FullName = "google.protobuf.FeatureSetDefaults.FeatureSetEditionDefault.overridable_features" + FeatureSetDefaults_FeatureSetEditionDefault_FixedFeatures_field_fullname protoreflect.FullName = "google.protobuf.FeatureSetDefaults.FeatureSetEditionDefault.fixed_features" ) // Field numbers for google.protobuf.FeatureSetDefaults.FeatureSetEditionDefault. const ( - FeatureSetDefaults_FeatureSetEditionDefault_Edition_field_number protoreflect.FieldNumber = 3 - FeatureSetDefaults_FeatureSetEditionDefault_Features_field_number protoreflect.FieldNumber = 2 + FeatureSetDefaults_FeatureSetEditionDefault_Edition_field_number protoreflect.FieldNumber = 3 + FeatureSetDefaults_FeatureSetEditionDefault_OverridableFeatures_field_number protoreflect.FieldNumber = 4 + FeatureSetDefaults_FeatureSetEditionDefault_FixedFeatures_field_number protoreflect.FieldNumber = 5 ) // Names for google.protobuf.SourceCodeInfo. diff --git a/vendor/google.golang.org/protobuf/internal/genid/go_features_gen.go b/vendor/google.golang.org/protobuf/internal/genid/go_features_gen.go index fd9015e8..9a652a2b 100644 --- a/vendor/google.golang.org/protobuf/internal/genid/go_features_gen.go +++ b/vendor/google.golang.org/protobuf/internal/genid/go_features_gen.go @@ -10,7 +10,7 @@ import ( protoreflect "google.golang.org/protobuf/reflect/protoreflect" ) -const File_reflect_protodesc_proto_go_features_proto = "reflect/protodesc/proto/go_features.proto" +const File_google_protobuf_go_features_proto = "google/protobuf/go_features.proto" // Names for google.protobuf.GoFeatures. const ( diff --git a/vendor/google.golang.org/protobuf/internal/impl/codec_field.go b/vendor/google.golang.org/protobuf/internal/impl/codec_field.go index 3fadd241..78ee47e4 100644 --- a/vendor/google.golang.org/protobuf/internal/impl/codec_field.go +++ b/vendor/google.golang.org/protobuf/internal/impl/codec_field.go @@ -233,9 +233,15 @@ func sizeMessageInfo(p pointer, f *coderFieldInfo, opts marshalOptions) int { } func appendMessageInfo(b []byte, p pointer, f *coderFieldInfo, opts marshalOptions) ([]byte, error) { + calculatedSize := f.mi.sizePointer(p.Elem(), opts) b = protowire.AppendVarint(b, f.wiretag) - b = protowire.AppendVarint(b, uint64(f.mi.sizePointer(p.Elem(), opts))) - return f.mi.marshalAppendPointer(b, p.Elem(), opts) + b = protowire.AppendVarint(b, uint64(calculatedSize)) + before := len(b) + b, err := f.mi.marshalAppendPointer(b, p.Elem(), opts) + if measuredSize := len(b) - before; calculatedSize != measuredSize && err == nil { + return nil, errors.MismatchedSizeCalculation(calculatedSize, measuredSize) + } + return b, err } func consumeMessageInfo(b []byte, p pointer, wtyp protowire.Type, f *coderFieldInfo, opts unmarshalOptions) (out unmarshalOutput, err error) { @@ -262,14 +268,21 @@ func isInitMessageInfo(p pointer, f *coderFieldInfo) error { return f.mi.checkInitializedPointer(p.Elem()) } -func sizeMessage(m proto.Message, tagsize int, _ marshalOptions) int { - return protowire.SizeBytes(proto.Size(m)) + tagsize +func sizeMessage(m proto.Message, tagsize int, opts marshalOptions) int { + return protowire.SizeBytes(opts.Options().Size(m)) + tagsize } func appendMessage(b []byte, m proto.Message, wiretag uint64, opts marshalOptions) ([]byte, error) { + mopts := opts.Options() + calculatedSize := mopts.Size(m) b = protowire.AppendVarint(b, wiretag) - b = protowire.AppendVarint(b, uint64(proto.Size(m))) - return opts.Options().MarshalAppend(b, m) + b = protowire.AppendVarint(b, uint64(calculatedSize)) + before := len(b) + b, err := mopts.MarshalAppend(b, m) + if measuredSize := len(b) - before; calculatedSize != measuredSize && err == nil { + return nil, errors.MismatchedSizeCalculation(calculatedSize, measuredSize) + } + return b, err } func consumeMessage(b []byte, m proto.Message, wtyp protowire.Type, opts unmarshalOptions) (out unmarshalOutput, err error) { @@ -405,8 +418,8 @@ func consumeGroupType(b []byte, p pointer, wtyp protowire.Type, f *coderFieldInf return f.mi.unmarshalPointer(b, p.Elem(), f.num, opts) } -func sizeGroup(m proto.Message, tagsize int, _ marshalOptions) int { - return 2*tagsize + proto.Size(m) +func sizeGroup(m proto.Message, tagsize int, opts marshalOptions) int { + return 2*tagsize + opts.Options().Size(m) } func appendGroup(b []byte, m proto.Message, wiretag uint64, opts marshalOptions) ([]byte, error) { @@ -482,10 +495,14 @@ func appendMessageSliceInfo(b []byte, p pointer, f *coderFieldInfo, opts marshal b = protowire.AppendVarint(b, f.wiretag) siz := f.mi.sizePointer(v, opts) b = protowire.AppendVarint(b, uint64(siz)) + before := len(b) b, err = f.mi.marshalAppendPointer(b, v, opts) if err != nil { return b, err } + if measuredSize := len(b) - before; siz != measuredSize { + return nil, errors.MismatchedSizeCalculation(siz, measuredSize) + } } return b, nil } @@ -520,28 +537,34 @@ func isInitMessageSliceInfo(p pointer, f *coderFieldInfo) error { return nil } -func sizeMessageSlice(p pointer, goType reflect.Type, tagsize int, _ marshalOptions) int { +func sizeMessageSlice(p pointer, goType reflect.Type, tagsize int, opts marshalOptions) int { + mopts := opts.Options() s := p.PointerSlice() n := 0 for _, v := range s { m := asMessage(v.AsValueOf(goType.Elem())) - n += protowire.SizeBytes(proto.Size(m)) + tagsize + n += protowire.SizeBytes(mopts.Size(m)) + tagsize } return n } func appendMessageSlice(b []byte, p pointer, wiretag uint64, goType reflect.Type, opts marshalOptions) ([]byte, error) { + mopts := opts.Options() s := p.PointerSlice() var err error for _, v := range s { m := asMessage(v.AsValueOf(goType.Elem())) b = protowire.AppendVarint(b, wiretag) - siz := proto.Size(m) + siz := mopts.Size(m) b = protowire.AppendVarint(b, uint64(siz)) - b, err = opts.Options().MarshalAppend(b, m) + before := len(b) + b, err = mopts.MarshalAppend(b, m) if err != nil { return b, err } + if measuredSize := len(b) - before; siz != measuredSize { + return nil, errors.MismatchedSizeCalculation(siz, measuredSize) + } } return b, nil } @@ -582,11 +605,12 @@ func isInitMessageSlice(p pointer, goType reflect.Type) error { // Slices of messages func sizeMessageSliceValue(listv protoreflect.Value, tagsize int, opts marshalOptions) int { + mopts := opts.Options() list := listv.List() n := 0 for i, llen := 0, list.Len(); i < llen; i++ { m := list.Get(i).Message().Interface() - n += protowire.SizeBytes(proto.Size(m)) + tagsize + n += protowire.SizeBytes(mopts.Size(m)) + tagsize } return n } @@ -597,13 +621,17 @@ func appendMessageSliceValue(b []byte, listv protoreflect.Value, wiretag uint64, for i, llen := 0, list.Len(); i < llen; i++ { m := list.Get(i).Message().Interface() b = protowire.AppendVarint(b, wiretag) - siz := proto.Size(m) + siz := mopts.Size(m) b = protowire.AppendVarint(b, uint64(siz)) + before := len(b) var err error b, err = mopts.MarshalAppend(b, m) if err != nil { return b, err } + if measuredSize := len(b) - before; siz != measuredSize { + return nil, errors.MismatchedSizeCalculation(siz, measuredSize) + } } return b, nil } @@ -651,11 +679,12 @@ var coderMessageSliceValue = valueCoderFuncs{ } func sizeGroupSliceValue(listv protoreflect.Value, tagsize int, opts marshalOptions) int { + mopts := opts.Options() list := listv.List() n := 0 for i, llen := 0, list.Len(); i < llen; i++ { m := list.Get(i).Message().Interface() - n += 2*tagsize + proto.Size(m) + n += 2*tagsize + mopts.Size(m) } return n } @@ -738,12 +767,13 @@ func makeGroupSliceFieldCoder(fd protoreflect.FieldDescriptor, ft reflect.Type) } } -func sizeGroupSlice(p pointer, messageType reflect.Type, tagsize int, _ marshalOptions) int { +func sizeGroupSlice(p pointer, messageType reflect.Type, tagsize int, opts marshalOptions) int { + mopts := opts.Options() s := p.PointerSlice() n := 0 for _, v := range s { m := asMessage(v.AsValueOf(messageType.Elem())) - n += 2*tagsize + proto.Size(m) + n += 2*tagsize + mopts.Size(m) } return n } diff --git a/vendor/google.golang.org/protobuf/internal/impl/codec_map.go b/vendor/google.golang.org/protobuf/internal/impl/codec_map.go index 111b9d16..fb35f0ba 100644 --- a/vendor/google.golang.org/protobuf/internal/impl/codec_map.go +++ b/vendor/google.golang.org/protobuf/internal/impl/codec_map.go @@ -9,6 +9,7 @@ import ( "sort" "google.golang.org/protobuf/encoding/protowire" + "google.golang.org/protobuf/internal/errors" "google.golang.org/protobuf/internal/genid" "google.golang.org/protobuf/reflect/protoreflect" ) @@ -240,11 +241,16 @@ func appendMapItem(b []byte, keyrv, valrv reflect.Value, mapi *mapInfo, f *coder size += mapi.keyFuncs.size(key.Value(), mapKeyTagSize, opts) size += mapi.valFuncs.size(val, mapValTagSize, opts) b = protowire.AppendVarint(b, uint64(size)) + before := len(b) b, err := mapi.keyFuncs.marshal(b, key.Value(), mapi.keyWiretag, opts) if err != nil { return nil, err } - return mapi.valFuncs.marshal(b, val, mapi.valWiretag, opts) + b, err = mapi.valFuncs.marshal(b, val, mapi.valWiretag, opts) + if measuredSize := len(b) - before; size != measuredSize && err == nil { + return nil, errors.MismatchedSizeCalculation(size, measuredSize) + } + return b, err } else { key := mapi.conv.keyConv.PBValueOf(keyrv).MapKey() val := pointerOfValue(valrv) @@ -259,7 +265,12 @@ func appendMapItem(b []byte, keyrv, valrv reflect.Value, mapi *mapInfo, f *coder } b = protowire.AppendVarint(b, mapi.valWiretag) b = protowire.AppendVarint(b, uint64(valSize)) - return f.mi.marshalAppendPointer(b, val, opts) + before := len(b) + b, err = f.mi.marshalAppendPointer(b, val, opts) + if measuredSize := len(b) - before; valSize != measuredSize && err == nil { + return nil, errors.MismatchedSizeCalculation(valSize, measuredSize) + } + return b, err } } diff --git a/vendor/google.golang.org/protobuf/internal/impl/legacy_file.go b/vendor/google.golang.org/protobuf/internal/impl/legacy_file.go index 9ab09108..b649f112 100644 --- a/vendor/google.golang.org/protobuf/internal/impl/legacy_file.go +++ b/vendor/google.golang.org/protobuf/internal/impl/legacy_file.go @@ -7,7 +7,7 @@ package impl import ( "bytes" "compress/gzip" - "io/ioutil" + "io" "sync" "google.golang.org/protobuf/internal/filedesc" @@ -51,7 +51,7 @@ func legacyLoadFileDesc(b []byte) protoreflect.FileDescriptor { if err != nil { panic(err) } - b2, err := ioutil.ReadAll(zr) + b2, err := io.ReadAll(zr) if err != nil { panic(err) } diff --git a/vendor/google.golang.org/protobuf/internal/version/version.go b/vendor/google.golang.org/protobuf/internal/version/version.go index 787f207f..a3cba508 100644 --- a/vendor/google.golang.org/protobuf/internal/version/version.go +++ b/vendor/google.golang.org/protobuf/internal/version/version.go @@ -51,9 +51,9 @@ import ( // 10. Send out the CL for review and submit it. const ( Major = 1 - Minor = 33 - Patch = 0 - PreRelease = "devel" + Minor = 34 + Patch = 1 + PreRelease = "" ) // String formats the version string for this module in semver format. diff --git a/vendor/google.golang.org/protobuf/proto/encode.go b/vendor/google.golang.org/protobuf/proto/encode.go index 5f69539c..1f847bcc 100644 --- a/vendor/google.golang.org/protobuf/proto/encode.go +++ b/vendor/google.golang.org/protobuf/proto/encode.go @@ -5,12 +5,17 @@ package proto import ( + "errors" + "fmt" + "google.golang.org/protobuf/encoding/protowire" "google.golang.org/protobuf/internal/encoding/messageset" "google.golang.org/protobuf/internal/order" "google.golang.org/protobuf/internal/pragma" "google.golang.org/protobuf/reflect/protoreflect" "google.golang.org/protobuf/runtime/protoiface" + + protoerrors "google.golang.org/protobuf/internal/errors" ) // MarshalOptions configures the marshaler. @@ -70,6 +75,27 @@ type MarshalOptions struct { UseCachedSize bool } +// flags turns the specified MarshalOptions (user-facing) into +// protoiface.MarshalInputFlags (used internally by the marshaler). +// +// See impl.marshalOptions.Options for the inverse operation. +func (o MarshalOptions) flags() protoiface.MarshalInputFlags { + var flags protoiface.MarshalInputFlags + + // Note: o.AllowPartial is always forced to true by MarshalOptions.marshal, + // which is why it is not a part of MarshalInputFlags. + + if o.Deterministic { + flags |= protoiface.MarshalDeterministic + } + + if o.UseCachedSize { + flags |= protoiface.MarshalUseCachedSize + } + + return flags +} + // Marshal returns the wire-format encoding of m. // // This is the most common entry point for encoding a Protobuf message. @@ -152,12 +178,7 @@ func (o MarshalOptions) marshal(b []byte, m protoreflect.Message) (out protoifac in := protoiface.MarshalInput{ Message: m, Buf: b, - } - if o.Deterministic { - in.Flags |= protoiface.MarshalDeterministic - } - if o.UseCachedSize { - in.Flags |= protoiface.MarshalUseCachedSize + Flags: o.flags(), } if methods.Size != nil { sout := methods.Size(protoiface.SizeInput{ @@ -175,6 +196,10 @@ func (o MarshalOptions) marshal(b []byte, m protoreflect.Message) (out protoifac out.Buf, err = o.marshalMessageSlow(b, m) } if err != nil { + var mismatch *protoerrors.SizeMismatchError + if errors.As(err, &mismatch) { + return out, fmt.Errorf("marshaling %s: %v", string(m.Descriptor().FullName()), err) + } return out, err } if allowPartial { diff --git a/vendor/google.golang.org/protobuf/proto/messageset.go b/vendor/google.golang.org/protobuf/proto/messageset.go index 312d5d45..575d1483 100644 --- a/vendor/google.golang.org/protobuf/proto/messageset.go +++ b/vendor/google.golang.org/protobuf/proto/messageset.go @@ -47,11 +47,16 @@ func (o MarshalOptions) marshalMessageSet(b []byte, m protoreflect.Message) ([]b func (o MarshalOptions) marshalMessageSetField(b []byte, fd protoreflect.FieldDescriptor, value protoreflect.Value) ([]byte, error) { b = messageset.AppendFieldStart(b, fd.Number()) b = protowire.AppendTag(b, messageset.FieldMessage, protowire.BytesType) - b = protowire.AppendVarint(b, uint64(o.Size(value.Message().Interface()))) + calculatedSize := o.Size(value.Message().Interface()) + b = protowire.AppendVarint(b, uint64(calculatedSize)) + before := len(b) b, err := o.marshalMessage(b, value.Message()) if err != nil { return b, err } + if measuredSize := len(b) - before; calculatedSize != measuredSize { + return nil, errors.MismatchedSizeCalculation(calculatedSize, measuredSize) + } b = messageset.AppendFieldEnd(b) return b, nil } diff --git a/vendor/google.golang.org/protobuf/proto/size.go b/vendor/google.golang.org/protobuf/proto/size.go index f1692b49..052fb5ae 100644 --- a/vendor/google.golang.org/protobuf/proto/size.go +++ b/vendor/google.golang.org/protobuf/proto/size.go @@ -34,6 +34,7 @@ func (o MarshalOptions) size(m protoreflect.Message) (size int) { if methods != nil && methods.Size != nil { out := methods.Size(protoiface.SizeInput{ Message: m, + Flags: o.flags(), }) return out.Size } @@ -42,6 +43,7 @@ func (o MarshalOptions) size(m protoreflect.Message) (size int) { // This case is mainly used for legacy types with a Marshal method. out, _ := methods.Marshal(protoiface.MarshalInput{ Message: m, + Flags: o.flags(), }) return len(out.Buf) } diff --git a/vendor/google.golang.org/protobuf/reflect/protodesc/desc_init.go b/vendor/google.golang.org/protobuf/reflect/protodesc/desc_init.go index ff5be207..85617554 100644 --- a/vendor/google.golang.org/protobuf/reflect/protodesc/desc_init.go +++ b/vendor/google.golang.org/protobuf/reflect/protodesc/desc_init.go @@ -198,6 +198,7 @@ func (r descsByName) initExtensionDeclarations(xds []*descriptorpb.FieldDescript if x.L0, err = r.makeBase(x, parent, xd.GetName(), i, sb); err != nil { return nil, err } + x.L1.EditionFeatures = mergeEditionFeatures(parent, xd.GetOptions().GetFeatures()) if opts := xd.GetOptions(); opts != nil { opts = proto.Clone(opts).(*descriptorpb.FieldOptions) x.L2.Options = func() protoreflect.ProtoMessage { return opts } diff --git a/vendor/google.golang.org/protobuf/reflect/protodesc/editions.go b/vendor/google.golang.org/protobuf/reflect/protodesc/editions.go index f6a1fec6..804830ed 100644 --- a/vendor/google.golang.org/protobuf/reflect/protodesc/editions.go +++ b/vendor/google.golang.org/protobuf/reflect/protodesc/editions.go @@ -62,18 +62,20 @@ func getFeatureSetFor(ed filedesc.Edition) *descriptorpb.FeatureSet { fmt.Fprintf(os.Stderr, "internal error: unsupported edition %v (did you forget to update the embedded defaults (i.e. the bootstrap descriptor proto)?)\n", edpb) os.Exit(1) } - fs := defaults.GetDefaults()[0].GetFeatures() + fsed := defaults.GetDefaults()[0] // Using a linear search for now. // Editions are guaranteed to be sorted and thus we could use a binary search. // Given that there are only a handful of editions (with one more per year) // there is not much reason to use a binary search. for _, def := range defaults.GetDefaults() { if def.GetEdition() <= edpb { - fs = def.GetFeatures() + fsed = def } else { break } } + fs := proto.Clone(fsed.GetFixedFeatures()).(*descriptorpb.FeatureSet) + proto.Merge(fs, fsed.GetOverridableFeatures()) defaultsCache[ed] = fs return fs } diff --git a/vendor/google.golang.org/protobuf/reflect/protoreflect/source_gen.go b/vendor/google.golang.org/protobuf/reflect/protoreflect/source_gen.go index 7dcc2ff0..00102d31 100644 --- a/vendor/google.golang.org/protobuf/reflect/protoreflect/source_gen.go +++ b/vendor/google.golang.org/protobuf/reflect/protoreflect/source_gen.go @@ -373,6 +373,8 @@ func (p *SourcePath) appendFieldOptions(b []byte) []byte { b = p.appendRepeatedField(b, "edition_defaults", (*SourcePath).appendFieldOptions_EditionDefault) case 21: b = p.appendSingularField(b, "features", (*SourcePath).appendFeatureSet) + case 22: + b = p.appendSingularField(b, "feature_support", (*SourcePath).appendFieldOptions_FeatureSupport) case 999: b = p.appendRepeatedField(b, "uninterpreted_option", (*SourcePath).appendUninterpretedOption) } @@ -519,6 +521,23 @@ func (p *SourcePath) appendFieldOptions_EditionDefault(b []byte) []byte { return b } +func (p *SourcePath) appendFieldOptions_FeatureSupport(b []byte) []byte { + if len(*p) == 0 { + return b + } + switch (*p)[0] { + case 1: + b = p.appendSingularField(b, "edition_introduced", nil) + case 2: + b = p.appendSingularField(b, "edition_deprecated", nil) + case 3: + b = p.appendSingularField(b, "deprecation_warning", nil) + case 4: + b = p.appendSingularField(b, "edition_removed", nil) + } + return b +} + func (p *SourcePath) appendUninterpretedOption_NamePart(b []byte) []byte { if len(*p) == 0 { return b diff --git a/vendor/google.golang.org/protobuf/types/descriptorpb/descriptor.pb.go b/vendor/google.golang.org/protobuf/types/descriptorpb/descriptor.pb.go index 78624cf6..10c9030e 100644 --- a/vendor/google.golang.org/protobuf/types/descriptorpb/descriptor.pb.go +++ b/vendor/google.golang.org/protobuf/types/descriptorpb/descriptor.pb.go @@ -54,6 +54,9 @@ type Edition int32 const ( // A placeholder for an unknown edition value. Edition_EDITION_UNKNOWN Edition = 0 + // A placeholder edition for specifying default behaviors *before* a feature + // was first introduced. This is effectively an "infinite past". + Edition_EDITION_LEGACY Edition = 900 // Legacy syntax "editions". These pre-date editions, but behave much like // distinct editions. These can't be used to specify the edition of proto // files, but feature definitions must supply proto2/proto3 defaults for @@ -82,6 +85,7 @@ const ( var ( Edition_name = map[int32]string{ 0: "EDITION_UNKNOWN", + 900: "EDITION_LEGACY", 998: "EDITION_PROTO2", 999: "EDITION_PROTO3", 1000: "EDITION_2023", @@ -95,6 +99,7 @@ var ( } Edition_value = map[string]int32{ "EDITION_UNKNOWN": 0, + "EDITION_LEGACY": 900, "EDITION_PROTO2": 998, "EDITION_PROTO3": 999, "EDITION_2023": 1000, @@ -2177,12 +2182,16 @@ type FileOptions struct { // // Deprecated: Marked as deprecated in google/protobuf/descriptor.proto. JavaGenerateEqualsAndHash *bool `protobuf:"varint,20,opt,name=java_generate_equals_and_hash,json=javaGenerateEqualsAndHash" json:"java_generate_equals_and_hash,omitempty"` - // If set true, then the Java2 code generator will generate code that - // throws an exception whenever an attempt is made to assign a non-UTF-8 - // byte sequence to a string field. - // Message reflection will do the same. - // However, an extension field still accepts non-UTF-8 byte sequences. - // This option has no effect on when used with the lite runtime. + // A proto2 file can set this to true to opt in to UTF-8 checking for Java, + // which will throw an exception if invalid UTF-8 is parsed from the wire or + // assigned to a string field. + // + // TODO: clarify exactly what kinds of field types this option + // applies to, and update these docs accordingly. + // + // Proto3 files already perform these checks. Setting the option explicitly to + // false has no effect: it cannot be used to opt proto3 files out of UTF-8 + // checks. JavaStringCheckUtf8 *bool `protobuf:"varint,27,opt,name=java_string_check_utf8,json=javaStringCheckUtf8,def=0" json:"java_string_check_utf8,omitempty"` OptimizeFor *FileOptions_OptimizeMode `protobuf:"varint,9,opt,name=optimize_for,json=optimizeFor,enum=google.protobuf.FileOptions_OptimizeMode,def=1" json:"optimize_for,omitempty"` // Sets the Go package where structs generated from this .proto will be @@ -2679,7 +2688,8 @@ type FieldOptions struct { Targets []FieldOptions_OptionTargetType `protobuf:"varint,19,rep,name=targets,enum=google.protobuf.FieldOptions_OptionTargetType" json:"targets,omitempty"` EditionDefaults []*FieldOptions_EditionDefault `protobuf:"bytes,20,rep,name=edition_defaults,json=editionDefaults" json:"edition_defaults,omitempty"` // Any features defined in the specific edition. - Features *FeatureSet `protobuf:"bytes,21,opt,name=features" json:"features,omitempty"` + Features *FeatureSet `protobuf:"bytes,21,opt,name=features" json:"features,omitempty"` + FeatureSupport *FieldOptions_FeatureSupport `protobuf:"bytes,22,opt,name=feature_support,json=featureSupport" json:"feature_support,omitempty"` // The parser stores options it doesn't recognize here. See above. UninterpretedOption []*UninterpretedOption `protobuf:"bytes,999,rep,name=uninterpreted_option,json=uninterpretedOption" json:"uninterpreted_option,omitempty"` } @@ -2811,6 +2821,13 @@ func (x *FieldOptions) GetFeatures() *FeatureSet { return nil } +func (x *FieldOptions) GetFeatureSupport() *FieldOptions_FeatureSupport { + if x != nil { + return x.FeatureSupport + } + return nil +} + func (x *FieldOptions) GetUninterpretedOption() []*UninterpretedOption { if x != nil { return x.UninterpretedOption @@ -3968,6 +3985,88 @@ func (x *FieldOptions_EditionDefault) GetValue() string { return "" } +// Information about the support window of a feature. +type FieldOptions_FeatureSupport struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // The edition that this feature was first available in. In editions + // earlier than this one, the default assigned to EDITION_LEGACY will be + // used, and proto files will not be able to override it. + EditionIntroduced *Edition `protobuf:"varint,1,opt,name=edition_introduced,json=editionIntroduced,enum=google.protobuf.Edition" json:"edition_introduced,omitempty"` + // The edition this feature becomes deprecated in. Using this after this + // edition may trigger warnings. + EditionDeprecated *Edition `protobuf:"varint,2,opt,name=edition_deprecated,json=editionDeprecated,enum=google.protobuf.Edition" json:"edition_deprecated,omitempty"` + // The deprecation warning text if this feature is used after the edition it + // was marked deprecated in. + DeprecationWarning *string `protobuf:"bytes,3,opt,name=deprecation_warning,json=deprecationWarning" json:"deprecation_warning,omitempty"` + // The edition this feature is no longer available in. In editions after + // this one, the last default assigned will be used, and proto files will + // not be able to override it. + EditionRemoved *Edition `protobuf:"varint,4,opt,name=edition_removed,json=editionRemoved,enum=google.protobuf.Edition" json:"edition_removed,omitempty"` +} + +func (x *FieldOptions_FeatureSupport) Reset() { + *x = FieldOptions_FeatureSupport{} + if protoimpl.UnsafeEnabled { + mi := &file_google_protobuf_descriptor_proto_msgTypes[28] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *FieldOptions_FeatureSupport) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*FieldOptions_FeatureSupport) ProtoMessage() {} + +func (x *FieldOptions_FeatureSupport) ProtoReflect() protoreflect.Message { + mi := &file_google_protobuf_descriptor_proto_msgTypes[28] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use FieldOptions_FeatureSupport.ProtoReflect.Descriptor instead. +func (*FieldOptions_FeatureSupport) Descriptor() ([]byte, []int) { + return file_google_protobuf_descriptor_proto_rawDescGZIP(), []int{12, 1} +} + +func (x *FieldOptions_FeatureSupport) GetEditionIntroduced() Edition { + if x != nil && x.EditionIntroduced != nil { + return *x.EditionIntroduced + } + return Edition_EDITION_UNKNOWN +} + +func (x *FieldOptions_FeatureSupport) GetEditionDeprecated() Edition { + if x != nil && x.EditionDeprecated != nil { + return *x.EditionDeprecated + } + return Edition_EDITION_UNKNOWN +} + +func (x *FieldOptions_FeatureSupport) GetDeprecationWarning() string { + if x != nil && x.DeprecationWarning != nil { + return *x.DeprecationWarning + } + return "" +} + +func (x *FieldOptions_FeatureSupport) GetEditionRemoved() Edition { + if x != nil && x.EditionRemoved != nil { + return *x.EditionRemoved + } + return Edition_EDITION_UNKNOWN +} + // The name of the uninterpreted option. Each string represents a segment in // a dot-separated name. is_extension is true iff a segment represents an // extension (denoted with parentheses in options specs in .proto files). @@ -3985,7 +4084,7 @@ type UninterpretedOption_NamePart struct { func (x *UninterpretedOption_NamePart) Reset() { *x = UninterpretedOption_NamePart{} if protoimpl.UnsafeEnabled { - mi := &file_google_protobuf_descriptor_proto_msgTypes[28] + mi := &file_google_protobuf_descriptor_proto_msgTypes[29] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -3998,7 +4097,7 @@ func (x *UninterpretedOption_NamePart) String() string { func (*UninterpretedOption_NamePart) ProtoMessage() {} func (x *UninterpretedOption_NamePart) ProtoReflect() protoreflect.Message { - mi := &file_google_protobuf_descriptor_proto_msgTypes[28] + mi := &file_google_protobuf_descriptor_proto_msgTypes[29] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -4037,14 +4136,17 @@ type FeatureSetDefaults_FeatureSetEditionDefault struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - Edition *Edition `protobuf:"varint,3,opt,name=edition,enum=google.protobuf.Edition" json:"edition,omitempty"` - Features *FeatureSet `protobuf:"bytes,2,opt,name=features" json:"features,omitempty"` + Edition *Edition `protobuf:"varint,3,opt,name=edition,enum=google.protobuf.Edition" json:"edition,omitempty"` + // Defaults of features that can be overridden in this edition. + OverridableFeatures *FeatureSet `protobuf:"bytes,4,opt,name=overridable_features,json=overridableFeatures" json:"overridable_features,omitempty"` + // Defaults of features that can't be overridden in this edition. + FixedFeatures *FeatureSet `protobuf:"bytes,5,opt,name=fixed_features,json=fixedFeatures" json:"fixed_features,omitempty"` } func (x *FeatureSetDefaults_FeatureSetEditionDefault) Reset() { *x = FeatureSetDefaults_FeatureSetEditionDefault{} if protoimpl.UnsafeEnabled { - mi := &file_google_protobuf_descriptor_proto_msgTypes[29] + mi := &file_google_protobuf_descriptor_proto_msgTypes[30] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -4057,7 +4159,7 @@ func (x *FeatureSetDefaults_FeatureSetEditionDefault) String() string { func (*FeatureSetDefaults_FeatureSetEditionDefault) ProtoMessage() {} func (x *FeatureSetDefaults_FeatureSetEditionDefault) ProtoReflect() protoreflect.Message { - mi := &file_google_protobuf_descriptor_proto_msgTypes[29] + mi := &file_google_protobuf_descriptor_proto_msgTypes[30] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -4080,9 +4182,16 @@ func (x *FeatureSetDefaults_FeatureSetEditionDefault) GetEdition() Edition { return Edition_EDITION_UNKNOWN } -func (x *FeatureSetDefaults_FeatureSetEditionDefault) GetFeatures() *FeatureSet { +func (x *FeatureSetDefaults_FeatureSetEditionDefault) GetOverridableFeatures() *FeatureSet { if x != nil { - return x.Features + return x.OverridableFeatures + } + return nil +} + +func (x *FeatureSetDefaults_FeatureSetEditionDefault) GetFixedFeatures() *FeatureSet { + if x != nil { + return x.FixedFeatures } return nil } @@ -4188,7 +4297,7 @@ type SourceCodeInfo_Location struct { func (x *SourceCodeInfo_Location) Reset() { *x = SourceCodeInfo_Location{} if protoimpl.UnsafeEnabled { - mi := &file_google_protobuf_descriptor_proto_msgTypes[30] + mi := &file_google_protobuf_descriptor_proto_msgTypes[31] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -4201,7 +4310,7 @@ func (x *SourceCodeInfo_Location) String() string { func (*SourceCodeInfo_Location) ProtoMessage() {} func (x *SourceCodeInfo_Location) ProtoReflect() protoreflect.Message { - mi := &file_google_protobuf_descriptor_proto_msgTypes[30] + mi := &file_google_protobuf_descriptor_proto_msgTypes[31] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -4275,7 +4384,7 @@ type GeneratedCodeInfo_Annotation struct { func (x *GeneratedCodeInfo_Annotation) Reset() { *x = GeneratedCodeInfo_Annotation{} if protoimpl.UnsafeEnabled { - mi := &file_google_protobuf_descriptor_proto_msgTypes[31] + mi := &file_google_protobuf_descriptor_proto_msgTypes[32] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -4288,7 +4397,7 @@ func (x *GeneratedCodeInfo_Annotation) String() string { func (*GeneratedCodeInfo_Annotation) ProtoMessage() {} func (x *GeneratedCodeInfo_Annotation) ProtoReflect() protoreflect.Message { - mi := &file_google_protobuf_descriptor_proto_msgTypes[31] + mi := &file_google_protobuf_descriptor_proto_msgTypes[32] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -4702,7 +4811,7 @@ var file_google_protobuf_descriptor_proto_rawDesc = []byte{ 0x72, 0x65, 0x74, 0x65, 0x64, 0x4f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x2a, 0x09, 0x08, 0xe8, 0x07, 0x10, 0x80, 0x80, 0x80, 0x80, 0x02, 0x4a, 0x04, 0x08, 0x04, 0x10, 0x05, 0x4a, 0x04, 0x08, 0x05, 0x10, 0x06, 0x4a, 0x04, 0x08, 0x06, 0x10, 0x07, 0x4a, 0x04, 0x08, 0x08, 0x10, 0x09, 0x4a, 0x04, - 0x08, 0x09, 0x10, 0x0a, 0x22, 0xad, 0x0a, 0x0a, 0x0c, 0x46, 0x69, 0x65, 0x6c, 0x64, 0x4f, 0x70, + 0x08, 0x09, 0x10, 0x0a, 0x22, 0x9d, 0x0d, 0x0a, 0x0c, 0x46, 0x69, 0x65, 0x6c, 0x64, 0x4f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x12, 0x41, 0x0a, 0x05, 0x63, 0x74, 0x79, 0x70, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x23, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x46, 0x69, 0x65, 0x6c, 0x64, 0x4f, 0x70, 0x74, 0x69, @@ -4743,18 +4852,41 @@ var file_google_protobuf_descriptor_proto_rawDesc = []byte{ 0x12, 0x37, 0x0a, 0x08, 0x66, 0x65, 0x61, 0x74, 0x75, 0x72, 0x65, 0x73, 0x18, 0x15, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1b, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x46, 0x65, 0x61, 0x74, 0x75, 0x72, 0x65, 0x53, 0x65, 0x74, 0x52, - 0x08, 0x66, 0x65, 0x61, 0x74, 0x75, 0x72, 0x65, 0x73, 0x12, 0x58, 0x0a, 0x14, 0x75, 0x6e, 0x69, - 0x6e, 0x74, 0x65, 0x72, 0x70, 0x72, 0x65, 0x74, 0x65, 0x64, 0x5f, 0x6f, 0x70, 0x74, 0x69, 0x6f, - 0x6e, 0x18, 0xe7, 0x07, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x24, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, - 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x55, 0x6e, 0x69, 0x6e, 0x74, - 0x65, 0x72, 0x70, 0x72, 0x65, 0x74, 0x65, 0x64, 0x4f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x13, - 0x75, 0x6e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x70, 0x72, 0x65, 0x74, 0x65, 0x64, 0x4f, 0x70, 0x74, - 0x69, 0x6f, 0x6e, 0x1a, 0x5a, 0x0a, 0x0e, 0x45, 0x64, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x44, 0x65, - 0x66, 0x61, 0x75, 0x6c, 0x74, 0x12, 0x32, 0x0a, 0x07, 0x65, 0x64, 0x69, 0x74, 0x69, 0x6f, 0x6e, - 0x18, 0x03, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x18, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, - 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x45, 0x64, 0x69, 0x74, 0x69, 0x6f, 0x6e, - 0x52, 0x07, 0x65, 0x64, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, - 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x22, + 0x08, 0x66, 0x65, 0x61, 0x74, 0x75, 0x72, 0x65, 0x73, 0x12, 0x55, 0x0a, 0x0f, 0x66, 0x65, 0x61, + 0x74, 0x75, 0x72, 0x65, 0x5f, 0x73, 0x75, 0x70, 0x70, 0x6f, 0x72, 0x74, 0x18, 0x16, 0x20, 0x01, + 0x28, 0x0b, 0x32, 0x2c, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, + 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x46, 0x69, 0x65, 0x6c, 0x64, 0x4f, 0x70, 0x74, 0x69, 0x6f, 0x6e, + 0x73, 0x2e, 0x46, 0x65, 0x61, 0x74, 0x75, 0x72, 0x65, 0x53, 0x75, 0x70, 0x70, 0x6f, 0x72, 0x74, + 0x52, 0x0e, 0x66, 0x65, 0x61, 0x74, 0x75, 0x72, 0x65, 0x53, 0x75, 0x70, 0x70, 0x6f, 0x72, 0x74, + 0x12, 0x58, 0x0a, 0x14, 0x75, 0x6e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x70, 0x72, 0x65, 0x74, 0x65, + 0x64, 0x5f, 0x6f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0xe7, 0x07, 0x20, 0x03, 0x28, 0x0b, 0x32, + 0x24, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, + 0x66, 0x2e, 0x55, 0x6e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x70, 0x72, 0x65, 0x74, 0x65, 0x64, 0x4f, + 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x13, 0x75, 0x6e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x70, 0x72, + 0x65, 0x74, 0x65, 0x64, 0x4f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x1a, 0x5a, 0x0a, 0x0e, 0x45, 0x64, + 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x44, 0x65, 0x66, 0x61, 0x75, 0x6c, 0x74, 0x12, 0x32, 0x0a, 0x07, + 0x65, 0x64, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x18, 0x2e, + 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, + 0x45, 0x64, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x07, 0x65, 0x64, 0x69, 0x74, 0x69, 0x6f, 0x6e, + 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, + 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x1a, 0x96, 0x02, 0x0a, 0x0e, 0x46, 0x65, 0x61, 0x74, 0x75, + 0x72, 0x65, 0x53, 0x75, 0x70, 0x70, 0x6f, 0x72, 0x74, 0x12, 0x47, 0x0a, 0x12, 0x65, 0x64, 0x69, + 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x69, 0x6e, 0x74, 0x72, 0x6f, 0x64, 0x75, 0x63, 0x65, 0x64, 0x18, + 0x01, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x18, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, + 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x45, 0x64, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x52, + 0x11, 0x65, 0x64, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x49, 0x6e, 0x74, 0x72, 0x6f, 0x64, 0x75, 0x63, + 0x65, 0x64, 0x12, 0x47, 0x0a, 0x12, 0x65, 0x64, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x64, 0x65, + 0x70, 0x72, 0x65, 0x63, 0x61, 0x74, 0x65, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x18, + 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, + 0x2e, 0x45, 0x64, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x11, 0x65, 0x64, 0x69, 0x74, 0x69, 0x6f, + 0x6e, 0x44, 0x65, 0x70, 0x72, 0x65, 0x63, 0x61, 0x74, 0x65, 0x64, 0x12, 0x2f, 0x0a, 0x13, 0x64, + 0x65, 0x70, 0x72, 0x65, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x77, 0x61, 0x72, 0x6e, 0x69, + 0x6e, 0x67, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x12, 0x64, 0x65, 0x70, 0x72, 0x65, 0x63, + 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x57, 0x61, 0x72, 0x6e, 0x69, 0x6e, 0x67, 0x12, 0x41, 0x0a, 0x0f, + 0x65, 0x64, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x72, 0x65, 0x6d, 0x6f, 0x76, 0x65, 0x64, 0x18, + 0x04, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x18, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, + 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x45, 0x64, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x52, + 0x0e, 0x65, 0x64, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x6d, 0x6f, 0x76, 0x65, 0x64, 0x22, 0x2f, 0x0a, 0x05, 0x43, 0x54, 0x79, 0x70, 0x65, 0x12, 0x0a, 0x0a, 0x06, 0x53, 0x54, 0x52, 0x49, 0x4e, 0x47, 0x10, 0x00, 0x12, 0x08, 0x0a, 0x04, 0x43, 0x4f, 0x52, 0x44, 0x10, 0x01, 0x12, 0x10, 0x0a, 0x0c, 0x53, 0x54, 0x52, 0x49, 0x4e, 0x47, 0x5f, 0x50, 0x49, 0x45, 0x43, 0x45, 0x10, 0x02, @@ -4898,177 +5030,187 @@ var file_google_protobuf_descriptor_proto_rawDesc = []byte{ 0x6e, 0x61, 0x6d, 0x65, 0x5f, 0x70, 0x61, 0x72, 0x74, 0x18, 0x01, 0x20, 0x02, 0x28, 0x09, 0x52, 0x08, 0x6e, 0x61, 0x6d, 0x65, 0x50, 0x61, 0x72, 0x74, 0x12, 0x21, 0x0a, 0x0c, 0x69, 0x73, 0x5f, 0x65, 0x78, 0x74, 0x65, 0x6e, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x02, 0x20, 0x02, 0x28, 0x08, 0x52, - 0x0b, 0x69, 0x73, 0x45, 0x78, 0x74, 0x65, 0x6e, 0x73, 0x69, 0x6f, 0x6e, 0x22, 0x8c, 0x0a, 0x0a, - 0x0a, 0x46, 0x65, 0x61, 0x74, 0x75, 0x72, 0x65, 0x53, 0x65, 0x74, 0x12, 0x8b, 0x01, 0x0a, 0x0e, + 0x0b, 0x69, 0x73, 0x45, 0x78, 0x74, 0x65, 0x6e, 0x73, 0x69, 0x6f, 0x6e, 0x22, 0xb9, 0x0a, 0x0a, + 0x0a, 0x46, 0x65, 0x61, 0x74, 0x75, 0x72, 0x65, 0x53, 0x65, 0x74, 0x12, 0x91, 0x01, 0x0a, 0x0e, 0x66, 0x69, 0x65, 0x6c, 0x64, 0x5f, 0x70, 0x72, 0x65, 0x73, 0x65, 0x6e, 0x63, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x29, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x46, 0x65, 0x61, 0x74, 0x75, 0x72, 0x65, 0x53, 0x65, 0x74, 0x2e, 0x46, 0x69, 0x65, 0x6c, 0x64, 0x50, 0x72, 0x65, 0x73, 0x65, 0x6e, 0x63, 0x65, 0x42, - 0x39, 0x88, 0x01, 0x01, 0x98, 0x01, 0x04, 0x98, 0x01, 0x01, 0xa2, 0x01, 0x0d, 0x12, 0x08, 0x45, + 0x3f, 0x88, 0x01, 0x01, 0x98, 0x01, 0x04, 0x98, 0x01, 0x01, 0xa2, 0x01, 0x0d, 0x12, 0x08, 0x45, 0x58, 0x50, 0x4c, 0x49, 0x43, 0x49, 0x54, 0x18, 0xe6, 0x07, 0xa2, 0x01, 0x0d, 0x12, 0x08, 0x49, 0x4d, 0x50, 0x4c, 0x49, 0x43, 0x49, 0x54, 0x18, 0xe7, 0x07, 0xa2, 0x01, 0x0d, 0x12, 0x08, 0x45, - 0x58, 0x50, 0x4c, 0x49, 0x43, 0x49, 0x54, 0x18, 0xe8, 0x07, 0x52, 0x0d, 0x66, 0x69, 0x65, 0x6c, - 0x64, 0x50, 0x72, 0x65, 0x73, 0x65, 0x6e, 0x63, 0x65, 0x12, 0x66, 0x0a, 0x09, 0x65, 0x6e, 0x75, - 0x6d, 0x5f, 0x74, 0x79, 0x70, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x24, 0x2e, 0x67, - 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x46, - 0x65, 0x61, 0x74, 0x75, 0x72, 0x65, 0x53, 0x65, 0x74, 0x2e, 0x45, 0x6e, 0x75, 0x6d, 0x54, 0x79, - 0x70, 0x65, 0x42, 0x23, 0x88, 0x01, 0x01, 0x98, 0x01, 0x06, 0x98, 0x01, 0x01, 0xa2, 0x01, 0x0b, - 0x12, 0x06, 0x43, 0x4c, 0x4f, 0x53, 0x45, 0x44, 0x18, 0xe6, 0x07, 0xa2, 0x01, 0x09, 0x12, 0x04, - 0x4f, 0x50, 0x45, 0x4e, 0x18, 0xe7, 0x07, 0x52, 0x08, 0x65, 0x6e, 0x75, 0x6d, 0x54, 0x79, 0x70, - 0x65, 0x12, 0x92, 0x01, 0x0a, 0x17, 0x72, 0x65, 0x70, 0x65, 0x61, 0x74, 0x65, 0x64, 0x5f, 0x66, - 0x69, 0x65, 0x6c, 0x64, 0x5f, 0x65, 0x6e, 0x63, 0x6f, 0x64, 0x69, 0x6e, 0x67, 0x18, 0x03, 0x20, - 0x01, 0x28, 0x0e, 0x32, 0x31, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, - 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x46, 0x65, 0x61, 0x74, 0x75, 0x72, 0x65, 0x53, 0x65, 0x74, - 0x2e, 0x52, 0x65, 0x70, 0x65, 0x61, 0x74, 0x65, 0x64, 0x46, 0x69, 0x65, 0x6c, 0x64, 0x45, 0x6e, - 0x63, 0x6f, 0x64, 0x69, 0x6e, 0x67, 0x42, 0x27, 0x88, 0x01, 0x01, 0x98, 0x01, 0x04, 0x98, 0x01, - 0x01, 0xa2, 0x01, 0x0d, 0x12, 0x08, 0x45, 0x58, 0x50, 0x41, 0x4e, 0x44, 0x45, 0x44, 0x18, 0xe6, - 0x07, 0xa2, 0x01, 0x0b, 0x12, 0x06, 0x50, 0x41, 0x43, 0x4b, 0x45, 0x44, 0x18, 0xe7, 0x07, 0x52, - 0x15, 0x72, 0x65, 0x70, 0x65, 0x61, 0x74, 0x65, 0x64, 0x46, 0x69, 0x65, 0x6c, 0x64, 0x45, 0x6e, - 0x63, 0x6f, 0x64, 0x69, 0x6e, 0x67, 0x12, 0x78, 0x0a, 0x0f, 0x75, 0x74, 0x66, 0x38, 0x5f, 0x76, - 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0e, 0x32, - 0x2a, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, - 0x66, 0x2e, 0x46, 0x65, 0x61, 0x74, 0x75, 0x72, 0x65, 0x53, 0x65, 0x74, 0x2e, 0x55, 0x74, 0x66, - 0x38, 0x56, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x42, 0x23, 0x88, 0x01, 0x01, - 0x98, 0x01, 0x04, 0x98, 0x01, 0x01, 0xa2, 0x01, 0x09, 0x12, 0x04, 0x4e, 0x4f, 0x4e, 0x45, 0x18, - 0xe6, 0x07, 0xa2, 0x01, 0x0b, 0x12, 0x06, 0x56, 0x45, 0x52, 0x49, 0x46, 0x59, 0x18, 0xe7, 0x07, - 0x52, 0x0e, 0x75, 0x74, 0x66, 0x38, 0x56, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x69, 0x6f, 0x6e, - 0x12, 0x78, 0x0a, 0x10, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x5f, 0x65, 0x6e, 0x63, 0x6f, - 0x64, 0x69, 0x6e, 0x67, 0x18, 0x05, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x2b, 0x2e, 0x67, 0x6f, 0x6f, - 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x46, 0x65, 0x61, - 0x74, 0x75, 0x72, 0x65, 0x53, 0x65, 0x74, 0x2e, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x45, - 0x6e, 0x63, 0x6f, 0x64, 0x69, 0x6e, 0x67, 0x42, 0x20, 0x88, 0x01, 0x01, 0x98, 0x01, 0x04, 0x98, - 0x01, 0x01, 0xa2, 0x01, 0x14, 0x12, 0x0f, 0x4c, 0x45, 0x4e, 0x47, 0x54, 0x48, 0x5f, 0x50, 0x52, - 0x45, 0x46, 0x49, 0x58, 0x45, 0x44, 0x18, 0xe6, 0x07, 0x52, 0x0f, 0x6d, 0x65, 0x73, 0x73, 0x61, - 0x67, 0x65, 0x45, 0x6e, 0x63, 0x6f, 0x64, 0x69, 0x6e, 0x67, 0x12, 0x7c, 0x0a, 0x0b, 0x6a, 0x73, - 0x6f, 0x6e, 0x5f, 0x66, 0x6f, 0x72, 0x6d, 0x61, 0x74, 0x18, 0x06, 0x20, 0x01, 0x28, 0x0e, 0x32, - 0x26, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, - 0x66, 0x2e, 0x46, 0x65, 0x61, 0x74, 0x75, 0x72, 0x65, 0x53, 0x65, 0x74, 0x2e, 0x4a, 0x73, 0x6f, - 0x6e, 0x46, 0x6f, 0x72, 0x6d, 0x61, 0x74, 0x42, 0x33, 0x88, 0x01, 0x01, 0x98, 0x01, 0x03, 0x98, - 0x01, 0x06, 0x98, 0x01, 0x01, 0xa2, 0x01, 0x17, 0x12, 0x12, 0x4c, 0x45, 0x47, 0x41, 0x43, 0x59, - 0x5f, 0x42, 0x45, 0x53, 0x54, 0x5f, 0x45, 0x46, 0x46, 0x4f, 0x52, 0x54, 0x18, 0xe6, 0x07, 0xa2, - 0x01, 0x0a, 0x12, 0x05, 0x41, 0x4c, 0x4c, 0x4f, 0x57, 0x18, 0xe7, 0x07, 0x52, 0x0a, 0x6a, 0x73, - 0x6f, 0x6e, 0x46, 0x6f, 0x72, 0x6d, 0x61, 0x74, 0x22, 0x5c, 0x0a, 0x0d, 0x46, 0x69, 0x65, 0x6c, - 0x64, 0x50, 0x72, 0x65, 0x73, 0x65, 0x6e, 0x63, 0x65, 0x12, 0x1a, 0x0a, 0x16, 0x46, 0x49, 0x45, - 0x4c, 0x44, 0x5f, 0x50, 0x52, 0x45, 0x53, 0x45, 0x4e, 0x43, 0x45, 0x5f, 0x55, 0x4e, 0x4b, 0x4e, - 0x4f, 0x57, 0x4e, 0x10, 0x00, 0x12, 0x0c, 0x0a, 0x08, 0x45, 0x58, 0x50, 0x4c, 0x49, 0x43, 0x49, - 0x54, 0x10, 0x01, 0x12, 0x0c, 0x0a, 0x08, 0x49, 0x4d, 0x50, 0x4c, 0x49, 0x43, 0x49, 0x54, 0x10, - 0x02, 0x12, 0x13, 0x0a, 0x0f, 0x4c, 0x45, 0x47, 0x41, 0x43, 0x59, 0x5f, 0x52, 0x45, 0x51, 0x55, - 0x49, 0x52, 0x45, 0x44, 0x10, 0x03, 0x22, 0x37, 0x0a, 0x08, 0x45, 0x6e, 0x75, 0x6d, 0x54, 0x79, - 0x70, 0x65, 0x12, 0x15, 0x0a, 0x11, 0x45, 0x4e, 0x55, 0x4d, 0x5f, 0x54, 0x59, 0x50, 0x45, 0x5f, - 0x55, 0x4e, 0x4b, 0x4e, 0x4f, 0x57, 0x4e, 0x10, 0x00, 0x12, 0x08, 0x0a, 0x04, 0x4f, 0x50, 0x45, - 0x4e, 0x10, 0x01, 0x12, 0x0a, 0x0a, 0x06, 0x43, 0x4c, 0x4f, 0x53, 0x45, 0x44, 0x10, 0x02, 0x22, - 0x56, 0x0a, 0x15, 0x52, 0x65, 0x70, 0x65, 0x61, 0x74, 0x65, 0x64, 0x46, 0x69, 0x65, 0x6c, 0x64, - 0x45, 0x6e, 0x63, 0x6f, 0x64, 0x69, 0x6e, 0x67, 0x12, 0x23, 0x0a, 0x1f, 0x52, 0x45, 0x50, 0x45, - 0x41, 0x54, 0x45, 0x44, 0x5f, 0x46, 0x49, 0x45, 0x4c, 0x44, 0x5f, 0x45, 0x4e, 0x43, 0x4f, 0x44, - 0x49, 0x4e, 0x47, 0x5f, 0x55, 0x4e, 0x4b, 0x4e, 0x4f, 0x57, 0x4e, 0x10, 0x00, 0x12, 0x0a, 0x0a, - 0x06, 0x50, 0x41, 0x43, 0x4b, 0x45, 0x44, 0x10, 0x01, 0x12, 0x0c, 0x0a, 0x08, 0x45, 0x58, 0x50, - 0x41, 0x4e, 0x44, 0x45, 0x44, 0x10, 0x02, 0x22, 0x43, 0x0a, 0x0e, 0x55, 0x74, 0x66, 0x38, 0x56, - 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x1b, 0x0a, 0x17, 0x55, 0x54, 0x46, - 0x38, 0x5f, 0x56, 0x41, 0x4c, 0x49, 0x44, 0x41, 0x54, 0x49, 0x4f, 0x4e, 0x5f, 0x55, 0x4e, 0x4b, - 0x4e, 0x4f, 0x57, 0x4e, 0x10, 0x00, 0x12, 0x0a, 0x0a, 0x06, 0x56, 0x45, 0x52, 0x49, 0x46, 0x59, - 0x10, 0x02, 0x12, 0x08, 0x0a, 0x04, 0x4e, 0x4f, 0x4e, 0x45, 0x10, 0x03, 0x22, 0x53, 0x0a, 0x0f, - 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x45, 0x6e, 0x63, 0x6f, 0x64, 0x69, 0x6e, 0x67, 0x12, - 0x1c, 0x0a, 0x18, 0x4d, 0x45, 0x53, 0x53, 0x41, 0x47, 0x45, 0x5f, 0x45, 0x4e, 0x43, 0x4f, 0x44, - 0x49, 0x4e, 0x47, 0x5f, 0x55, 0x4e, 0x4b, 0x4e, 0x4f, 0x57, 0x4e, 0x10, 0x00, 0x12, 0x13, 0x0a, - 0x0f, 0x4c, 0x45, 0x4e, 0x47, 0x54, 0x48, 0x5f, 0x50, 0x52, 0x45, 0x46, 0x49, 0x58, 0x45, 0x44, - 0x10, 0x01, 0x12, 0x0d, 0x0a, 0x09, 0x44, 0x45, 0x4c, 0x49, 0x4d, 0x49, 0x54, 0x45, 0x44, 0x10, - 0x02, 0x22, 0x48, 0x0a, 0x0a, 0x4a, 0x73, 0x6f, 0x6e, 0x46, 0x6f, 0x72, 0x6d, 0x61, 0x74, 0x12, - 0x17, 0x0a, 0x13, 0x4a, 0x53, 0x4f, 0x4e, 0x5f, 0x46, 0x4f, 0x52, 0x4d, 0x41, 0x54, 0x5f, 0x55, - 0x4e, 0x4b, 0x4e, 0x4f, 0x57, 0x4e, 0x10, 0x00, 0x12, 0x09, 0x0a, 0x05, 0x41, 0x4c, 0x4c, 0x4f, - 0x57, 0x10, 0x01, 0x12, 0x16, 0x0a, 0x12, 0x4c, 0x45, 0x47, 0x41, 0x43, 0x59, 0x5f, 0x42, 0x45, - 0x53, 0x54, 0x5f, 0x45, 0x46, 0x46, 0x4f, 0x52, 0x54, 0x10, 0x02, 0x2a, 0x06, 0x08, 0xe8, 0x07, - 0x10, 0xe9, 0x07, 0x2a, 0x06, 0x08, 0xe9, 0x07, 0x10, 0xea, 0x07, 0x2a, 0x06, 0x08, 0xea, 0x07, - 0x10, 0xeb, 0x07, 0x2a, 0x06, 0x08, 0x8b, 0x4e, 0x10, 0x90, 0x4e, 0x2a, 0x06, 0x08, 0x90, 0x4e, - 0x10, 0x91, 0x4e, 0x4a, 0x06, 0x08, 0xe7, 0x07, 0x10, 0xe8, 0x07, 0x22, 0xfe, 0x02, 0x0a, 0x12, - 0x46, 0x65, 0x61, 0x74, 0x75, 0x72, 0x65, 0x53, 0x65, 0x74, 0x44, 0x65, 0x66, 0x61, 0x75, 0x6c, - 0x74, 0x73, 0x12, 0x58, 0x0a, 0x08, 0x64, 0x65, 0x66, 0x61, 0x75, 0x6c, 0x74, 0x73, 0x18, 0x01, - 0x20, 0x03, 0x28, 0x0b, 0x32, 0x3c, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, - 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x46, 0x65, 0x61, 0x74, 0x75, 0x72, 0x65, 0x53, 0x65, - 0x74, 0x44, 0x65, 0x66, 0x61, 0x75, 0x6c, 0x74, 0x73, 0x2e, 0x46, 0x65, 0x61, 0x74, 0x75, 0x72, - 0x65, 0x53, 0x65, 0x74, 0x45, 0x64, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x44, 0x65, 0x66, 0x61, 0x75, - 0x6c, 0x74, 0x52, 0x08, 0x64, 0x65, 0x66, 0x61, 0x75, 0x6c, 0x74, 0x73, 0x12, 0x41, 0x0a, 0x0f, - 0x6d, 0x69, 0x6e, 0x69, 0x6d, 0x75, 0x6d, 0x5f, 0x65, 0x64, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x18, - 0x04, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x18, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, + 0x58, 0x50, 0x4c, 0x49, 0x43, 0x49, 0x54, 0x18, 0xe8, 0x07, 0xb2, 0x01, 0x03, 0x08, 0xe8, 0x07, + 0x52, 0x0d, 0x66, 0x69, 0x65, 0x6c, 0x64, 0x50, 0x72, 0x65, 0x73, 0x65, 0x6e, 0x63, 0x65, 0x12, + 0x6c, 0x0a, 0x09, 0x65, 0x6e, 0x75, 0x6d, 0x5f, 0x74, 0x79, 0x70, 0x65, 0x18, 0x02, 0x20, 0x01, + 0x28, 0x0e, 0x32, 0x24, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, + 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x46, 0x65, 0x61, 0x74, 0x75, 0x72, 0x65, 0x53, 0x65, 0x74, 0x2e, + 0x45, 0x6e, 0x75, 0x6d, 0x54, 0x79, 0x70, 0x65, 0x42, 0x29, 0x88, 0x01, 0x01, 0x98, 0x01, 0x06, + 0x98, 0x01, 0x01, 0xa2, 0x01, 0x0b, 0x12, 0x06, 0x43, 0x4c, 0x4f, 0x53, 0x45, 0x44, 0x18, 0xe6, + 0x07, 0xa2, 0x01, 0x09, 0x12, 0x04, 0x4f, 0x50, 0x45, 0x4e, 0x18, 0xe7, 0x07, 0xb2, 0x01, 0x03, + 0x08, 0xe8, 0x07, 0x52, 0x08, 0x65, 0x6e, 0x75, 0x6d, 0x54, 0x79, 0x70, 0x65, 0x12, 0x98, 0x01, + 0x0a, 0x17, 0x72, 0x65, 0x70, 0x65, 0x61, 0x74, 0x65, 0x64, 0x5f, 0x66, 0x69, 0x65, 0x6c, 0x64, + 0x5f, 0x65, 0x6e, 0x63, 0x6f, 0x64, 0x69, 0x6e, 0x67, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0e, 0x32, + 0x31, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, + 0x66, 0x2e, 0x46, 0x65, 0x61, 0x74, 0x75, 0x72, 0x65, 0x53, 0x65, 0x74, 0x2e, 0x52, 0x65, 0x70, + 0x65, 0x61, 0x74, 0x65, 0x64, 0x46, 0x69, 0x65, 0x6c, 0x64, 0x45, 0x6e, 0x63, 0x6f, 0x64, 0x69, + 0x6e, 0x67, 0x42, 0x2d, 0x88, 0x01, 0x01, 0x98, 0x01, 0x04, 0x98, 0x01, 0x01, 0xa2, 0x01, 0x0d, + 0x12, 0x08, 0x45, 0x58, 0x50, 0x41, 0x4e, 0x44, 0x45, 0x44, 0x18, 0xe6, 0x07, 0xa2, 0x01, 0x0b, + 0x12, 0x06, 0x50, 0x41, 0x43, 0x4b, 0x45, 0x44, 0x18, 0xe7, 0x07, 0xb2, 0x01, 0x03, 0x08, 0xe8, + 0x07, 0x52, 0x15, 0x72, 0x65, 0x70, 0x65, 0x61, 0x74, 0x65, 0x64, 0x46, 0x69, 0x65, 0x6c, 0x64, + 0x45, 0x6e, 0x63, 0x6f, 0x64, 0x69, 0x6e, 0x67, 0x12, 0x7e, 0x0a, 0x0f, 0x75, 0x74, 0x66, 0x38, + 0x5f, 0x76, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x04, 0x20, 0x01, 0x28, + 0x0e, 0x32, 0x2a, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, + 0x62, 0x75, 0x66, 0x2e, 0x46, 0x65, 0x61, 0x74, 0x75, 0x72, 0x65, 0x53, 0x65, 0x74, 0x2e, 0x55, + 0x74, 0x66, 0x38, 0x56, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x42, 0x29, 0x88, + 0x01, 0x01, 0x98, 0x01, 0x04, 0x98, 0x01, 0x01, 0xa2, 0x01, 0x09, 0x12, 0x04, 0x4e, 0x4f, 0x4e, + 0x45, 0x18, 0xe6, 0x07, 0xa2, 0x01, 0x0b, 0x12, 0x06, 0x56, 0x45, 0x52, 0x49, 0x46, 0x59, 0x18, + 0xe7, 0x07, 0xb2, 0x01, 0x03, 0x08, 0xe8, 0x07, 0x52, 0x0e, 0x75, 0x74, 0x66, 0x38, 0x56, 0x61, + 0x6c, 0x69, 0x64, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x7e, 0x0a, 0x10, 0x6d, 0x65, 0x73, 0x73, + 0x61, 0x67, 0x65, 0x5f, 0x65, 0x6e, 0x63, 0x6f, 0x64, 0x69, 0x6e, 0x67, 0x18, 0x05, 0x20, 0x01, + 0x28, 0x0e, 0x32, 0x2b, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, + 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x46, 0x65, 0x61, 0x74, 0x75, 0x72, 0x65, 0x53, 0x65, 0x74, 0x2e, + 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x45, 0x6e, 0x63, 0x6f, 0x64, 0x69, 0x6e, 0x67, 0x42, + 0x26, 0x88, 0x01, 0x01, 0x98, 0x01, 0x04, 0x98, 0x01, 0x01, 0xa2, 0x01, 0x14, 0x12, 0x0f, 0x4c, + 0x45, 0x4e, 0x47, 0x54, 0x48, 0x5f, 0x50, 0x52, 0x45, 0x46, 0x49, 0x58, 0x45, 0x44, 0x18, 0xe6, + 0x07, 0xb2, 0x01, 0x03, 0x08, 0xe8, 0x07, 0x52, 0x0f, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, + 0x45, 0x6e, 0x63, 0x6f, 0x64, 0x69, 0x6e, 0x67, 0x12, 0x82, 0x01, 0x0a, 0x0b, 0x6a, 0x73, 0x6f, + 0x6e, 0x5f, 0x66, 0x6f, 0x72, 0x6d, 0x61, 0x74, 0x18, 0x06, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x26, + 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, + 0x2e, 0x46, 0x65, 0x61, 0x74, 0x75, 0x72, 0x65, 0x53, 0x65, 0x74, 0x2e, 0x4a, 0x73, 0x6f, 0x6e, + 0x46, 0x6f, 0x72, 0x6d, 0x61, 0x74, 0x42, 0x39, 0x88, 0x01, 0x01, 0x98, 0x01, 0x03, 0x98, 0x01, + 0x06, 0x98, 0x01, 0x01, 0xa2, 0x01, 0x17, 0x12, 0x12, 0x4c, 0x45, 0x47, 0x41, 0x43, 0x59, 0x5f, + 0x42, 0x45, 0x53, 0x54, 0x5f, 0x45, 0x46, 0x46, 0x4f, 0x52, 0x54, 0x18, 0xe6, 0x07, 0xa2, 0x01, + 0x0a, 0x12, 0x05, 0x41, 0x4c, 0x4c, 0x4f, 0x57, 0x18, 0xe7, 0x07, 0xb2, 0x01, 0x03, 0x08, 0xe8, + 0x07, 0x52, 0x0a, 0x6a, 0x73, 0x6f, 0x6e, 0x46, 0x6f, 0x72, 0x6d, 0x61, 0x74, 0x22, 0x5c, 0x0a, + 0x0d, 0x46, 0x69, 0x65, 0x6c, 0x64, 0x50, 0x72, 0x65, 0x73, 0x65, 0x6e, 0x63, 0x65, 0x12, 0x1a, + 0x0a, 0x16, 0x46, 0x49, 0x45, 0x4c, 0x44, 0x5f, 0x50, 0x52, 0x45, 0x53, 0x45, 0x4e, 0x43, 0x45, + 0x5f, 0x55, 0x4e, 0x4b, 0x4e, 0x4f, 0x57, 0x4e, 0x10, 0x00, 0x12, 0x0c, 0x0a, 0x08, 0x45, 0x58, + 0x50, 0x4c, 0x49, 0x43, 0x49, 0x54, 0x10, 0x01, 0x12, 0x0c, 0x0a, 0x08, 0x49, 0x4d, 0x50, 0x4c, + 0x49, 0x43, 0x49, 0x54, 0x10, 0x02, 0x12, 0x13, 0x0a, 0x0f, 0x4c, 0x45, 0x47, 0x41, 0x43, 0x59, + 0x5f, 0x52, 0x45, 0x51, 0x55, 0x49, 0x52, 0x45, 0x44, 0x10, 0x03, 0x22, 0x37, 0x0a, 0x08, 0x45, + 0x6e, 0x75, 0x6d, 0x54, 0x79, 0x70, 0x65, 0x12, 0x15, 0x0a, 0x11, 0x45, 0x4e, 0x55, 0x4d, 0x5f, + 0x54, 0x59, 0x50, 0x45, 0x5f, 0x55, 0x4e, 0x4b, 0x4e, 0x4f, 0x57, 0x4e, 0x10, 0x00, 0x12, 0x08, + 0x0a, 0x04, 0x4f, 0x50, 0x45, 0x4e, 0x10, 0x01, 0x12, 0x0a, 0x0a, 0x06, 0x43, 0x4c, 0x4f, 0x53, + 0x45, 0x44, 0x10, 0x02, 0x22, 0x56, 0x0a, 0x15, 0x52, 0x65, 0x70, 0x65, 0x61, 0x74, 0x65, 0x64, + 0x46, 0x69, 0x65, 0x6c, 0x64, 0x45, 0x6e, 0x63, 0x6f, 0x64, 0x69, 0x6e, 0x67, 0x12, 0x23, 0x0a, + 0x1f, 0x52, 0x45, 0x50, 0x45, 0x41, 0x54, 0x45, 0x44, 0x5f, 0x46, 0x49, 0x45, 0x4c, 0x44, 0x5f, + 0x45, 0x4e, 0x43, 0x4f, 0x44, 0x49, 0x4e, 0x47, 0x5f, 0x55, 0x4e, 0x4b, 0x4e, 0x4f, 0x57, 0x4e, + 0x10, 0x00, 0x12, 0x0a, 0x0a, 0x06, 0x50, 0x41, 0x43, 0x4b, 0x45, 0x44, 0x10, 0x01, 0x12, 0x0c, + 0x0a, 0x08, 0x45, 0x58, 0x50, 0x41, 0x4e, 0x44, 0x45, 0x44, 0x10, 0x02, 0x22, 0x43, 0x0a, 0x0e, + 0x55, 0x74, 0x66, 0x38, 0x56, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x1b, + 0x0a, 0x17, 0x55, 0x54, 0x46, 0x38, 0x5f, 0x56, 0x41, 0x4c, 0x49, 0x44, 0x41, 0x54, 0x49, 0x4f, + 0x4e, 0x5f, 0x55, 0x4e, 0x4b, 0x4e, 0x4f, 0x57, 0x4e, 0x10, 0x00, 0x12, 0x0a, 0x0a, 0x06, 0x56, + 0x45, 0x52, 0x49, 0x46, 0x59, 0x10, 0x02, 0x12, 0x08, 0x0a, 0x04, 0x4e, 0x4f, 0x4e, 0x45, 0x10, + 0x03, 0x22, 0x53, 0x0a, 0x0f, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x45, 0x6e, 0x63, 0x6f, + 0x64, 0x69, 0x6e, 0x67, 0x12, 0x1c, 0x0a, 0x18, 0x4d, 0x45, 0x53, 0x53, 0x41, 0x47, 0x45, 0x5f, + 0x45, 0x4e, 0x43, 0x4f, 0x44, 0x49, 0x4e, 0x47, 0x5f, 0x55, 0x4e, 0x4b, 0x4e, 0x4f, 0x57, 0x4e, + 0x10, 0x00, 0x12, 0x13, 0x0a, 0x0f, 0x4c, 0x45, 0x4e, 0x47, 0x54, 0x48, 0x5f, 0x50, 0x52, 0x45, + 0x46, 0x49, 0x58, 0x45, 0x44, 0x10, 0x01, 0x12, 0x0d, 0x0a, 0x09, 0x44, 0x45, 0x4c, 0x49, 0x4d, + 0x49, 0x54, 0x45, 0x44, 0x10, 0x02, 0x22, 0x48, 0x0a, 0x0a, 0x4a, 0x73, 0x6f, 0x6e, 0x46, 0x6f, + 0x72, 0x6d, 0x61, 0x74, 0x12, 0x17, 0x0a, 0x13, 0x4a, 0x53, 0x4f, 0x4e, 0x5f, 0x46, 0x4f, 0x52, + 0x4d, 0x41, 0x54, 0x5f, 0x55, 0x4e, 0x4b, 0x4e, 0x4f, 0x57, 0x4e, 0x10, 0x00, 0x12, 0x09, 0x0a, + 0x05, 0x41, 0x4c, 0x4c, 0x4f, 0x57, 0x10, 0x01, 0x12, 0x16, 0x0a, 0x12, 0x4c, 0x45, 0x47, 0x41, + 0x43, 0x59, 0x5f, 0x42, 0x45, 0x53, 0x54, 0x5f, 0x45, 0x46, 0x46, 0x4f, 0x52, 0x54, 0x10, 0x02, + 0x2a, 0x06, 0x08, 0xe8, 0x07, 0x10, 0xe9, 0x07, 0x2a, 0x06, 0x08, 0xe9, 0x07, 0x10, 0xea, 0x07, + 0x2a, 0x06, 0x08, 0xea, 0x07, 0x10, 0xeb, 0x07, 0x2a, 0x06, 0x08, 0x86, 0x4e, 0x10, 0x87, 0x4e, + 0x2a, 0x06, 0x08, 0x8b, 0x4e, 0x10, 0x90, 0x4e, 0x2a, 0x06, 0x08, 0x90, 0x4e, 0x10, 0x91, 0x4e, + 0x4a, 0x06, 0x08, 0xe7, 0x07, 0x10, 0xe8, 0x07, 0x22, 0xd9, 0x03, 0x0a, 0x12, 0x46, 0x65, 0x61, + 0x74, 0x75, 0x72, 0x65, 0x53, 0x65, 0x74, 0x44, 0x65, 0x66, 0x61, 0x75, 0x6c, 0x74, 0x73, 0x12, + 0x58, 0x0a, 0x08, 0x64, 0x65, 0x66, 0x61, 0x75, 0x6c, 0x74, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, + 0x0b, 0x32, 0x3c, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, + 0x62, 0x75, 0x66, 0x2e, 0x46, 0x65, 0x61, 0x74, 0x75, 0x72, 0x65, 0x53, 0x65, 0x74, 0x44, 0x65, + 0x66, 0x61, 0x75, 0x6c, 0x74, 0x73, 0x2e, 0x46, 0x65, 0x61, 0x74, 0x75, 0x72, 0x65, 0x53, 0x65, + 0x74, 0x45, 0x64, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x44, 0x65, 0x66, 0x61, 0x75, 0x6c, 0x74, 0x52, + 0x08, 0x64, 0x65, 0x66, 0x61, 0x75, 0x6c, 0x74, 0x73, 0x12, 0x41, 0x0a, 0x0f, 0x6d, 0x69, 0x6e, + 0x69, 0x6d, 0x75, 0x6d, 0x5f, 0x65, 0x64, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x04, 0x20, 0x01, + 0x28, 0x0e, 0x32, 0x18, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, + 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x45, 0x64, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x0e, 0x6d, 0x69, + 0x6e, 0x69, 0x6d, 0x75, 0x6d, 0x45, 0x64, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x41, 0x0a, 0x0f, + 0x6d, 0x61, 0x78, 0x69, 0x6d, 0x75, 0x6d, 0x5f, 0x65, 0x64, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x18, + 0x05, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x18, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x45, 0x64, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x52, - 0x0e, 0x6d, 0x69, 0x6e, 0x69, 0x6d, 0x75, 0x6d, 0x45, 0x64, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x12, - 0x41, 0x0a, 0x0f, 0x6d, 0x61, 0x78, 0x69, 0x6d, 0x75, 0x6d, 0x5f, 0x65, 0x64, 0x69, 0x74, 0x69, - 0x6f, 0x6e, 0x18, 0x05, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x18, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, - 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x45, 0x64, 0x69, 0x74, 0x69, - 0x6f, 0x6e, 0x52, 0x0e, 0x6d, 0x61, 0x78, 0x69, 0x6d, 0x75, 0x6d, 0x45, 0x64, 0x69, 0x74, 0x69, - 0x6f, 0x6e, 0x1a, 0x87, 0x01, 0x0a, 0x18, 0x46, 0x65, 0x61, 0x74, 0x75, 0x72, 0x65, 0x53, 0x65, - 0x74, 0x45, 0x64, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x44, 0x65, 0x66, 0x61, 0x75, 0x6c, 0x74, 0x12, - 0x32, 0x0a, 0x07, 0x65, 0x64, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0e, - 0x32, 0x18, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, - 0x75, 0x66, 0x2e, 0x45, 0x64, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x07, 0x65, 0x64, 0x69, 0x74, - 0x69, 0x6f, 0x6e, 0x12, 0x37, 0x0a, 0x08, 0x66, 0x65, 0x61, 0x74, 0x75, 0x72, 0x65, 0x73, 0x18, - 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1b, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, - 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x46, 0x65, 0x61, 0x74, 0x75, 0x72, 0x65, 0x53, - 0x65, 0x74, 0x52, 0x08, 0x66, 0x65, 0x61, 0x74, 0x75, 0x72, 0x65, 0x73, 0x22, 0xa7, 0x02, 0x0a, - 0x0e, 0x53, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x43, 0x6f, 0x64, 0x65, 0x49, 0x6e, 0x66, 0x6f, 0x12, - 0x44, 0x0a, 0x08, 0x6c, 0x6f, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x01, 0x20, 0x03, 0x28, - 0x0b, 0x32, 0x28, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, - 0x62, 0x75, 0x66, 0x2e, 0x53, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x43, 0x6f, 0x64, 0x65, 0x49, 0x6e, - 0x66, 0x6f, 0x2e, 0x4c, 0x6f, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x08, 0x6c, 0x6f, 0x63, - 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x1a, 0xce, 0x01, 0x0a, 0x08, 0x4c, 0x6f, 0x63, 0x61, 0x74, 0x69, - 0x6f, 0x6e, 0x12, 0x16, 0x0a, 0x04, 0x70, 0x61, 0x74, 0x68, 0x18, 0x01, 0x20, 0x03, 0x28, 0x05, - 0x42, 0x02, 0x10, 0x01, 0x52, 0x04, 0x70, 0x61, 0x74, 0x68, 0x12, 0x16, 0x0a, 0x04, 0x73, 0x70, - 0x61, 0x6e, 0x18, 0x02, 0x20, 0x03, 0x28, 0x05, 0x42, 0x02, 0x10, 0x01, 0x52, 0x04, 0x73, 0x70, - 0x61, 0x6e, 0x12, 0x29, 0x0a, 0x10, 0x6c, 0x65, 0x61, 0x64, 0x69, 0x6e, 0x67, 0x5f, 0x63, 0x6f, - 0x6d, 0x6d, 0x65, 0x6e, 0x74, 0x73, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0f, 0x6c, 0x65, - 0x61, 0x64, 0x69, 0x6e, 0x67, 0x43, 0x6f, 0x6d, 0x6d, 0x65, 0x6e, 0x74, 0x73, 0x12, 0x2b, 0x0a, - 0x11, 0x74, 0x72, 0x61, 0x69, 0x6c, 0x69, 0x6e, 0x67, 0x5f, 0x63, 0x6f, 0x6d, 0x6d, 0x65, 0x6e, - 0x74, 0x73, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x10, 0x74, 0x72, 0x61, 0x69, 0x6c, 0x69, - 0x6e, 0x67, 0x43, 0x6f, 0x6d, 0x6d, 0x65, 0x6e, 0x74, 0x73, 0x12, 0x3a, 0x0a, 0x19, 0x6c, 0x65, - 0x61, 0x64, 0x69, 0x6e, 0x67, 0x5f, 0x64, 0x65, 0x74, 0x61, 0x63, 0x68, 0x65, 0x64, 0x5f, 0x63, - 0x6f, 0x6d, 0x6d, 0x65, 0x6e, 0x74, 0x73, 0x18, 0x06, 0x20, 0x03, 0x28, 0x09, 0x52, 0x17, 0x6c, - 0x65, 0x61, 0x64, 0x69, 0x6e, 0x67, 0x44, 0x65, 0x74, 0x61, 0x63, 0x68, 0x65, 0x64, 0x43, 0x6f, - 0x6d, 0x6d, 0x65, 0x6e, 0x74, 0x73, 0x22, 0xd0, 0x02, 0x0a, 0x11, 0x47, 0x65, 0x6e, 0x65, 0x72, - 0x61, 0x74, 0x65, 0x64, 0x43, 0x6f, 0x64, 0x65, 0x49, 0x6e, 0x66, 0x6f, 0x12, 0x4d, 0x0a, 0x0a, - 0x61, 0x6e, 0x6e, 0x6f, 0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, - 0x32, 0x2d, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, - 0x75, 0x66, 0x2e, 0x47, 0x65, 0x6e, 0x65, 0x72, 0x61, 0x74, 0x65, 0x64, 0x43, 0x6f, 0x64, 0x65, - 0x49, 0x6e, 0x66, 0x6f, 0x2e, 0x41, 0x6e, 0x6e, 0x6f, 0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x52, - 0x0a, 0x61, 0x6e, 0x6e, 0x6f, 0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x1a, 0xeb, 0x01, 0x0a, 0x0a, - 0x41, 0x6e, 0x6e, 0x6f, 0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x16, 0x0a, 0x04, 0x70, 0x61, - 0x74, 0x68, 0x18, 0x01, 0x20, 0x03, 0x28, 0x05, 0x42, 0x02, 0x10, 0x01, 0x52, 0x04, 0x70, 0x61, - 0x74, 0x68, 0x12, 0x1f, 0x0a, 0x0b, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x5f, 0x66, 0x69, 0x6c, - 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x46, - 0x69, 0x6c, 0x65, 0x12, 0x14, 0x0a, 0x05, 0x62, 0x65, 0x67, 0x69, 0x6e, 0x18, 0x03, 0x20, 0x01, - 0x28, 0x05, 0x52, 0x05, 0x62, 0x65, 0x67, 0x69, 0x6e, 0x12, 0x10, 0x0a, 0x03, 0x65, 0x6e, 0x64, - 0x18, 0x04, 0x20, 0x01, 0x28, 0x05, 0x52, 0x03, 0x65, 0x6e, 0x64, 0x12, 0x52, 0x0a, 0x08, 0x73, - 0x65, 0x6d, 0x61, 0x6e, 0x74, 0x69, 0x63, 0x18, 0x05, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x36, 0x2e, + 0x0e, 0x6d, 0x61, 0x78, 0x69, 0x6d, 0x75, 0x6d, 0x45, 0x64, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x1a, + 0xe2, 0x01, 0x0a, 0x18, 0x46, 0x65, 0x61, 0x74, 0x75, 0x72, 0x65, 0x53, 0x65, 0x74, 0x45, 0x64, + 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x44, 0x65, 0x66, 0x61, 0x75, 0x6c, 0x74, 0x12, 0x32, 0x0a, 0x07, + 0x65, 0x64, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x18, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, - 0x47, 0x65, 0x6e, 0x65, 0x72, 0x61, 0x74, 0x65, 0x64, 0x43, 0x6f, 0x64, 0x65, 0x49, 0x6e, 0x66, - 0x6f, 0x2e, 0x41, 0x6e, 0x6e, 0x6f, 0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x2e, 0x53, 0x65, 0x6d, - 0x61, 0x6e, 0x74, 0x69, 0x63, 0x52, 0x08, 0x73, 0x65, 0x6d, 0x61, 0x6e, 0x74, 0x69, 0x63, 0x22, - 0x28, 0x0a, 0x08, 0x53, 0x65, 0x6d, 0x61, 0x6e, 0x74, 0x69, 0x63, 0x12, 0x08, 0x0a, 0x04, 0x4e, - 0x4f, 0x4e, 0x45, 0x10, 0x00, 0x12, 0x07, 0x0a, 0x03, 0x53, 0x45, 0x54, 0x10, 0x01, 0x12, 0x09, - 0x0a, 0x05, 0x41, 0x4c, 0x49, 0x41, 0x53, 0x10, 0x02, 0x2a, 0x92, 0x02, 0x0a, 0x07, 0x45, 0x64, - 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x13, 0x0a, 0x0f, 0x45, 0x44, 0x49, 0x54, 0x49, 0x4f, 0x4e, - 0x5f, 0x55, 0x4e, 0x4b, 0x4e, 0x4f, 0x57, 0x4e, 0x10, 0x00, 0x12, 0x13, 0x0a, 0x0e, 0x45, 0x44, - 0x49, 0x54, 0x49, 0x4f, 0x4e, 0x5f, 0x50, 0x52, 0x4f, 0x54, 0x4f, 0x32, 0x10, 0xe6, 0x07, 0x12, - 0x13, 0x0a, 0x0e, 0x45, 0x44, 0x49, 0x54, 0x49, 0x4f, 0x4e, 0x5f, 0x50, 0x52, 0x4f, 0x54, 0x4f, - 0x33, 0x10, 0xe7, 0x07, 0x12, 0x11, 0x0a, 0x0c, 0x45, 0x44, 0x49, 0x54, 0x49, 0x4f, 0x4e, 0x5f, - 0x32, 0x30, 0x32, 0x33, 0x10, 0xe8, 0x07, 0x12, 0x11, 0x0a, 0x0c, 0x45, 0x44, 0x49, 0x54, 0x49, - 0x4f, 0x4e, 0x5f, 0x32, 0x30, 0x32, 0x34, 0x10, 0xe9, 0x07, 0x12, 0x17, 0x0a, 0x13, 0x45, 0x44, - 0x49, 0x54, 0x49, 0x4f, 0x4e, 0x5f, 0x31, 0x5f, 0x54, 0x45, 0x53, 0x54, 0x5f, 0x4f, 0x4e, 0x4c, - 0x59, 0x10, 0x01, 0x12, 0x17, 0x0a, 0x13, 0x45, 0x44, 0x49, 0x54, 0x49, 0x4f, 0x4e, 0x5f, 0x32, - 0x5f, 0x54, 0x45, 0x53, 0x54, 0x5f, 0x4f, 0x4e, 0x4c, 0x59, 0x10, 0x02, 0x12, 0x1d, 0x0a, 0x17, - 0x45, 0x44, 0x49, 0x54, 0x49, 0x4f, 0x4e, 0x5f, 0x39, 0x39, 0x39, 0x39, 0x37, 0x5f, 0x54, 0x45, - 0x53, 0x54, 0x5f, 0x4f, 0x4e, 0x4c, 0x59, 0x10, 0x9d, 0x8d, 0x06, 0x12, 0x1d, 0x0a, 0x17, 0x45, - 0x44, 0x49, 0x54, 0x49, 0x4f, 0x4e, 0x5f, 0x39, 0x39, 0x39, 0x39, 0x38, 0x5f, 0x54, 0x45, 0x53, - 0x54, 0x5f, 0x4f, 0x4e, 0x4c, 0x59, 0x10, 0x9e, 0x8d, 0x06, 0x12, 0x1d, 0x0a, 0x17, 0x45, 0x44, - 0x49, 0x54, 0x49, 0x4f, 0x4e, 0x5f, 0x39, 0x39, 0x39, 0x39, 0x39, 0x5f, 0x54, 0x45, 0x53, 0x54, - 0x5f, 0x4f, 0x4e, 0x4c, 0x59, 0x10, 0x9f, 0x8d, 0x06, 0x12, 0x13, 0x0a, 0x0b, 0x45, 0x44, 0x49, - 0x54, 0x49, 0x4f, 0x4e, 0x5f, 0x4d, 0x41, 0x58, 0x10, 0xff, 0xff, 0xff, 0xff, 0x07, 0x42, 0x7e, - 0x0a, 0x13, 0x63, 0x6f, 0x6d, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, - 0x74, 0x6f, 0x62, 0x75, 0x66, 0x42, 0x10, 0x44, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x6f, - 0x72, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x73, 0x48, 0x01, 0x5a, 0x2d, 0x67, 0x6f, 0x6f, 0x67, 0x6c, - 0x65, 0x2e, 0x67, 0x6f, 0x6c, 0x61, 0x6e, 0x67, 0x2e, 0x6f, 0x72, 0x67, 0x2f, 0x70, 0x72, 0x6f, - 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x74, 0x79, 0x70, 0x65, 0x73, 0x2f, 0x64, 0x65, 0x73, 0x63, - 0x72, 0x69, 0x70, 0x74, 0x6f, 0x72, 0x70, 0x62, 0xf8, 0x01, 0x01, 0xa2, 0x02, 0x03, 0x47, 0x50, - 0x42, 0xaa, 0x02, 0x1a, 0x47, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x50, 0x72, 0x6f, 0x74, 0x6f, - 0x62, 0x75, 0x66, 0x2e, 0x52, 0x65, 0x66, 0x6c, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, + 0x45, 0x64, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x07, 0x65, 0x64, 0x69, 0x74, 0x69, 0x6f, 0x6e, + 0x12, 0x4e, 0x0a, 0x14, 0x6f, 0x76, 0x65, 0x72, 0x72, 0x69, 0x64, 0x61, 0x62, 0x6c, 0x65, 0x5f, + 0x66, 0x65, 0x61, 0x74, 0x75, 0x72, 0x65, 0x73, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1b, + 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, + 0x2e, 0x46, 0x65, 0x61, 0x74, 0x75, 0x72, 0x65, 0x53, 0x65, 0x74, 0x52, 0x13, 0x6f, 0x76, 0x65, + 0x72, 0x72, 0x69, 0x64, 0x61, 0x62, 0x6c, 0x65, 0x46, 0x65, 0x61, 0x74, 0x75, 0x72, 0x65, 0x73, + 0x12, 0x42, 0x0a, 0x0e, 0x66, 0x69, 0x78, 0x65, 0x64, 0x5f, 0x66, 0x65, 0x61, 0x74, 0x75, 0x72, + 0x65, 0x73, 0x18, 0x05, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1b, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, + 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x46, 0x65, 0x61, 0x74, 0x75, + 0x72, 0x65, 0x53, 0x65, 0x74, 0x52, 0x0d, 0x66, 0x69, 0x78, 0x65, 0x64, 0x46, 0x65, 0x61, 0x74, + 0x75, 0x72, 0x65, 0x73, 0x22, 0xa7, 0x02, 0x0a, 0x0e, 0x53, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x43, + 0x6f, 0x64, 0x65, 0x49, 0x6e, 0x66, 0x6f, 0x12, 0x44, 0x0a, 0x08, 0x6c, 0x6f, 0x63, 0x61, 0x74, + 0x69, 0x6f, 0x6e, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x28, 0x2e, 0x67, 0x6f, 0x6f, 0x67, + 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x53, 0x6f, 0x75, 0x72, + 0x63, 0x65, 0x43, 0x6f, 0x64, 0x65, 0x49, 0x6e, 0x66, 0x6f, 0x2e, 0x4c, 0x6f, 0x63, 0x61, 0x74, + 0x69, 0x6f, 0x6e, 0x52, 0x08, 0x6c, 0x6f, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x1a, 0xce, 0x01, + 0x0a, 0x08, 0x4c, 0x6f, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x16, 0x0a, 0x04, 0x70, 0x61, + 0x74, 0x68, 0x18, 0x01, 0x20, 0x03, 0x28, 0x05, 0x42, 0x02, 0x10, 0x01, 0x52, 0x04, 0x70, 0x61, + 0x74, 0x68, 0x12, 0x16, 0x0a, 0x04, 0x73, 0x70, 0x61, 0x6e, 0x18, 0x02, 0x20, 0x03, 0x28, 0x05, + 0x42, 0x02, 0x10, 0x01, 0x52, 0x04, 0x73, 0x70, 0x61, 0x6e, 0x12, 0x29, 0x0a, 0x10, 0x6c, 0x65, + 0x61, 0x64, 0x69, 0x6e, 0x67, 0x5f, 0x63, 0x6f, 0x6d, 0x6d, 0x65, 0x6e, 0x74, 0x73, 0x18, 0x03, + 0x20, 0x01, 0x28, 0x09, 0x52, 0x0f, 0x6c, 0x65, 0x61, 0x64, 0x69, 0x6e, 0x67, 0x43, 0x6f, 0x6d, + 0x6d, 0x65, 0x6e, 0x74, 0x73, 0x12, 0x2b, 0x0a, 0x11, 0x74, 0x72, 0x61, 0x69, 0x6c, 0x69, 0x6e, + 0x67, 0x5f, 0x63, 0x6f, 0x6d, 0x6d, 0x65, 0x6e, 0x74, 0x73, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, + 0x52, 0x10, 0x74, 0x72, 0x61, 0x69, 0x6c, 0x69, 0x6e, 0x67, 0x43, 0x6f, 0x6d, 0x6d, 0x65, 0x6e, + 0x74, 0x73, 0x12, 0x3a, 0x0a, 0x19, 0x6c, 0x65, 0x61, 0x64, 0x69, 0x6e, 0x67, 0x5f, 0x64, 0x65, + 0x74, 0x61, 0x63, 0x68, 0x65, 0x64, 0x5f, 0x63, 0x6f, 0x6d, 0x6d, 0x65, 0x6e, 0x74, 0x73, 0x18, + 0x06, 0x20, 0x03, 0x28, 0x09, 0x52, 0x17, 0x6c, 0x65, 0x61, 0x64, 0x69, 0x6e, 0x67, 0x44, 0x65, + 0x74, 0x61, 0x63, 0x68, 0x65, 0x64, 0x43, 0x6f, 0x6d, 0x6d, 0x65, 0x6e, 0x74, 0x73, 0x22, 0xd0, + 0x02, 0x0a, 0x11, 0x47, 0x65, 0x6e, 0x65, 0x72, 0x61, 0x74, 0x65, 0x64, 0x43, 0x6f, 0x64, 0x65, + 0x49, 0x6e, 0x66, 0x6f, 0x12, 0x4d, 0x0a, 0x0a, 0x61, 0x6e, 0x6e, 0x6f, 0x74, 0x61, 0x74, 0x69, + 0x6f, 0x6e, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x2d, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, + 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x47, 0x65, 0x6e, 0x65, 0x72, + 0x61, 0x74, 0x65, 0x64, 0x43, 0x6f, 0x64, 0x65, 0x49, 0x6e, 0x66, 0x6f, 0x2e, 0x41, 0x6e, 0x6e, + 0x6f, 0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x0a, 0x61, 0x6e, 0x6e, 0x6f, 0x74, 0x61, 0x74, + 0x69, 0x6f, 0x6e, 0x1a, 0xeb, 0x01, 0x0a, 0x0a, 0x41, 0x6e, 0x6e, 0x6f, 0x74, 0x61, 0x74, 0x69, + 0x6f, 0x6e, 0x12, 0x16, 0x0a, 0x04, 0x70, 0x61, 0x74, 0x68, 0x18, 0x01, 0x20, 0x03, 0x28, 0x05, + 0x42, 0x02, 0x10, 0x01, 0x52, 0x04, 0x70, 0x61, 0x74, 0x68, 0x12, 0x1f, 0x0a, 0x0b, 0x73, 0x6f, + 0x75, 0x72, 0x63, 0x65, 0x5f, 0x66, 0x69, 0x6c, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, + 0x0a, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x46, 0x69, 0x6c, 0x65, 0x12, 0x14, 0x0a, 0x05, 0x62, + 0x65, 0x67, 0x69, 0x6e, 0x18, 0x03, 0x20, 0x01, 0x28, 0x05, 0x52, 0x05, 0x62, 0x65, 0x67, 0x69, + 0x6e, 0x12, 0x10, 0x0a, 0x03, 0x65, 0x6e, 0x64, 0x18, 0x04, 0x20, 0x01, 0x28, 0x05, 0x52, 0x03, + 0x65, 0x6e, 0x64, 0x12, 0x52, 0x0a, 0x08, 0x73, 0x65, 0x6d, 0x61, 0x6e, 0x74, 0x69, 0x63, 0x18, + 0x05, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x36, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, + 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x47, 0x65, 0x6e, 0x65, 0x72, 0x61, 0x74, 0x65, + 0x64, 0x43, 0x6f, 0x64, 0x65, 0x49, 0x6e, 0x66, 0x6f, 0x2e, 0x41, 0x6e, 0x6e, 0x6f, 0x74, 0x61, + 0x74, 0x69, 0x6f, 0x6e, 0x2e, 0x53, 0x65, 0x6d, 0x61, 0x6e, 0x74, 0x69, 0x63, 0x52, 0x08, 0x73, + 0x65, 0x6d, 0x61, 0x6e, 0x74, 0x69, 0x63, 0x22, 0x28, 0x0a, 0x08, 0x53, 0x65, 0x6d, 0x61, 0x6e, + 0x74, 0x69, 0x63, 0x12, 0x08, 0x0a, 0x04, 0x4e, 0x4f, 0x4e, 0x45, 0x10, 0x00, 0x12, 0x07, 0x0a, + 0x03, 0x53, 0x45, 0x54, 0x10, 0x01, 0x12, 0x09, 0x0a, 0x05, 0x41, 0x4c, 0x49, 0x41, 0x53, 0x10, + 0x02, 0x2a, 0xa7, 0x02, 0x0a, 0x07, 0x45, 0x64, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x13, 0x0a, + 0x0f, 0x45, 0x44, 0x49, 0x54, 0x49, 0x4f, 0x4e, 0x5f, 0x55, 0x4e, 0x4b, 0x4e, 0x4f, 0x57, 0x4e, + 0x10, 0x00, 0x12, 0x13, 0x0a, 0x0e, 0x45, 0x44, 0x49, 0x54, 0x49, 0x4f, 0x4e, 0x5f, 0x4c, 0x45, + 0x47, 0x41, 0x43, 0x59, 0x10, 0x84, 0x07, 0x12, 0x13, 0x0a, 0x0e, 0x45, 0x44, 0x49, 0x54, 0x49, + 0x4f, 0x4e, 0x5f, 0x50, 0x52, 0x4f, 0x54, 0x4f, 0x32, 0x10, 0xe6, 0x07, 0x12, 0x13, 0x0a, 0x0e, + 0x45, 0x44, 0x49, 0x54, 0x49, 0x4f, 0x4e, 0x5f, 0x50, 0x52, 0x4f, 0x54, 0x4f, 0x33, 0x10, 0xe7, + 0x07, 0x12, 0x11, 0x0a, 0x0c, 0x45, 0x44, 0x49, 0x54, 0x49, 0x4f, 0x4e, 0x5f, 0x32, 0x30, 0x32, + 0x33, 0x10, 0xe8, 0x07, 0x12, 0x11, 0x0a, 0x0c, 0x45, 0x44, 0x49, 0x54, 0x49, 0x4f, 0x4e, 0x5f, + 0x32, 0x30, 0x32, 0x34, 0x10, 0xe9, 0x07, 0x12, 0x17, 0x0a, 0x13, 0x45, 0x44, 0x49, 0x54, 0x49, + 0x4f, 0x4e, 0x5f, 0x31, 0x5f, 0x54, 0x45, 0x53, 0x54, 0x5f, 0x4f, 0x4e, 0x4c, 0x59, 0x10, 0x01, + 0x12, 0x17, 0x0a, 0x13, 0x45, 0x44, 0x49, 0x54, 0x49, 0x4f, 0x4e, 0x5f, 0x32, 0x5f, 0x54, 0x45, + 0x53, 0x54, 0x5f, 0x4f, 0x4e, 0x4c, 0x59, 0x10, 0x02, 0x12, 0x1d, 0x0a, 0x17, 0x45, 0x44, 0x49, + 0x54, 0x49, 0x4f, 0x4e, 0x5f, 0x39, 0x39, 0x39, 0x39, 0x37, 0x5f, 0x54, 0x45, 0x53, 0x54, 0x5f, + 0x4f, 0x4e, 0x4c, 0x59, 0x10, 0x9d, 0x8d, 0x06, 0x12, 0x1d, 0x0a, 0x17, 0x45, 0x44, 0x49, 0x54, + 0x49, 0x4f, 0x4e, 0x5f, 0x39, 0x39, 0x39, 0x39, 0x38, 0x5f, 0x54, 0x45, 0x53, 0x54, 0x5f, 0x4f, + 0x4e, 0x4c, 0x59, 0x10, 0x9e, 0x8d, 0x06, 0x12, 0x1d, 0x0a, 0x17, 0x45, 0x44, 0x49, 0x54, 0x49, + 0x4f, 0x4e, 0x5f, 0x39, 0x39, 0x39, 0x39, 0x39, 0x5f, 0x54, 0x45, 0x53, 0x54, 0x5f, 0x4f, 0x4e, + 0x4c, 0x59, 0x10, 0x9f, 0x8d, 0x06, 0x12, 0x13, 0x0a, 0x0b, 0x45, 0x44, 0x49, 0x54, 0x49, 0x4f, + 0x4e, 0x5f, 0x4d, 0x41, 0x58, 0x10, 0xff, 0xff, 0xff, 0xff, 0x07, 0x42, 0x7e, 0x0a, 0x13, 0x63, + 0x6f, 0x6d, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, + 0x75, 0x66, 0x42, 0x10, 0x44, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x6f, 0x72, 0x50, 0x72, + 0x6f, 0x74, 0x6f, 0x73, 0x48, 0x01, 0x5a, 0x2d, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x67, + 0x6f, 0x6c, 0x61, 0x6e, 0x67, 0x2e, 0x6f, 0x72, 0x67, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, + 0x75, 0x66, 0x2f, 0x74, 0x79, 0x70, 0x65, 0x73, 0x2f, 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, + 0x74, 0x6f, 0x72, 0x70, 0x62, 0xf8, 0x01, 0x01, 0xa2, 0x02, 0x03, 0x47, 0x50, 0x42, 0xaa, 0x02, + 0x1a, 0x47, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, + 0x2e, 0x52, 0x65, 0x66, 0x6c, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, } var ( @@ -5084,7 +5226,7 @@ func file_google_protobuf_descriptor_proto_rawDescGZIP() []byte { } var file_google_protobuf_descriptor_proto_enumTypes = make([]protoimpl.EnumInfo, 17) -var file_google_protobuf_descriptor_proto_msgTypes = make([]protoimpl.MessageInfo, 32) +var file_google_protobuf_descriptor_proto_msgTypes = make([]protoimpl.MessageInfo, 33) var file_google_protobuf_descriptor_proto_goTypes = []interface{}{ (Edition)(0), // 0: google.protobuf.Edition (ExtensionRangeOptions_VerificationState)(0), // 1: google.protobuf.ExtensionRangeOptions.VerificationState @@ -5131,10 +5273,11 @@ var file_google_protobuf_descriptor_proto_goTypes = []interface{}{ (*ExtensionRangeOptions_Declaration)(nil), // 42: google.protobuf.ExtensionRangeOptions.Declaration (*EnumDescriptorProto_EnumReservedRange)(nil), // 43: google.protobuf.EnumDescriptorProto.EnumReservedRange (*FieldOptions_EditionDefault)(nil), // 44: google.protobuf.FieldOptions.EditionDefault - (*UninterpretedOption_NamePart)(nil), // 45: google.protobuf.UninterpretedOption.NamePart - (*FeatureSetDefaults_FeatureSetEditionDefault)(nil), // 46: google.protobuf.FeatureSetDefaults.FeatureSetEditionDefault - (*SourceCodeInfo_Location)(nil), // 47: google.protobuf.SourceCodeInfo.Location - (*GeneratedCodeInfo_Annotation)(nil), // 48: google.protobuf.GeneratedCodeInfo.Annotation + (*FieldOptions_FeatureSupport)(nil), // 45: google.protobuf.FieldOptions.FeatureSupport + (*UninterpretedOption_NamePart)(nil), // 46: google.protobuf.UninterpretedOption.NamePart + (*FeatureSetDefaults_FeatureSetEditionDefault)(nil), // 47: google.protobuf.FeatureSetDefaults.FeatureSetEditionDefault + (*SourceCodeInfo_Location)(nil), // 48: google.protobuf.SourceCodeInfo.Location + (*GeneratedCodeInfo_Annotation)(nil), // 49: google.protobuf.GeneratedCodeInfo.Annotation } var file_google_protobuf_descriptor_proto_depIdxs = []int32{ 18, // 0: google.protobuf.FileDescriptorSet.file:type_name -> google.protobuf.FileDescriptorProto @@ -5179,40 +5322,45 @@ var file_google_protobuf_descriptor_proto_depIdxs = []int32{ 8, // 39: google.protobuf.FieldOptions.targets:type_name -> google.protobuf.FieldOptions.OptionTargetType 44, // 40: google.protobuf.FieldOptions.edition_defaults:type_name -> google.protobuf.FieldOptions.EditionDefault 36, // 41: google.protobuf.FieldOptions.features:type_name -> google.protobuf.FeatureSet - 35, // 42: google.protobuf.FieldOptions.uninterpreted_option:type_name -> google.protobuf.UninterpretedOption - 36, // 43: google.protobuf.OneofOptions.features:type_name -> google.protobuf.FeatureSet - 35, // 44: google.protobuf.OneofOptions.uninterpreted_option:type_name -> google.protobuf.UninterpretedOption - 36, // 45: google.protobuf.EnumOptions.features:type_name -> google.protobuf.FeatureSet - 35, // 46: google.protobuf.EnumOptions.uninterpreted_option:type_name -> google.protobuf.UninterpretedOption - 36, // 47: google.protobuf.EnumValueOptions.features:type_name -> google.protobuf.FeatureSet - 35, // 48: google.protobuf.EnumValueOptions.uninterpreted_option:type_name -> google.protobuf.UninterpretedOption - 36, // 49: google.protobuf.ServiceOptions.features:type_name -> google.protobuf.FeatureSet - 35, // 50: google.protobuf.ServiceOptions.uninterpreted_option:type_name -> google.protobuf.UninterpretedOption - 9, // 51: google.protobuf.MethodOptions.idempotency_level:type_name -> google.protobuf.MethodOptions.IdempotencyLevel - 36, // 52: google.protobuf.MethodOptions.features:type_name -> google.protobuf.FeatureSet - 35, // 53: google.protobuf.MethodOptions.uninterpreted_option:type_name -> google.protobuf.UninterpretedOption - 45, // 54: google.protobuf.UninterpretedOption.name:type_name -> google.protobuf.UninterpretedOption.NamePart - 10, // 55: google.protobuf.FeatureSet.field_presence:type_name -> google.protobuf.FeatureSet.FieldPresence - 11, // 56: google.protobuf.FeatureSet.enum_type:type_name -> google.protobuf.FeatureSet.EnumType - 12, // 57: google.protobuf.FeatureSet.repeated_field_encoding:type_name -> google.protobuf.FeatureSet.RepeatedFieldEncoding - 13, // 58: google.protobuf.FeatureSet.utf8_validation:type_name -> google.protobuf.FeatureSet.Utf8Validation - 14, // 59: google.protobuf.FeatureSet.message_encoding:type_name -> google.protobuf.FeatureSet.MessageEncoding - 15, // 60: google.protobuf.FeatureSet.json_format:type_name -> google.protobuf.FeatureSet.JsonFormat - 46, // 61: google.protobuf.FeatureSetDefaults.defaults:type_name -> google.protobuf.FeatureSetDefaults.FeatureSetEditionDefault - 0, // 62: google.protobuf.FeatureSetDefaults.minimum_edition:type_name -> google.protobuf.Edition - 0, // 63: google.protobuf.FeatureSetDefaults.maximum_edition:type_name -> google.protobuf.Edition - 47, // 64: google.protobuf.SourceCodeInfo.location:type_name -> google.protobuf.SourceCodeInfo.Location - 48, // 65: google.protobuf.GeneratedCodeInfo.annotation:type_name -> google.protobuf.GeneratedCodeInfo.Annotation - 20, // 66: google.protobuf.DescriptorProto.ExtensionRange.options:type_name -> google.protobuf.ExtensionRangeOptions - 0, // 67: google.protobuf.FieldOptions.EditionDefault.edition:type_name -> google.protobuf.Edition - 0, // 68: google.protobuf.FeatureSetDefaults.FeatureSetEditionDefault.edition:type_name -> google.protobuf.Edition - 36, // 69: google.protobuf.FeatureSetDefaults.FeatureSetEditionDefault.features:type_name -> google.protobuf.FeatureSet - 16, // 70: google.protobuf.GeneratedCodeInfo.Annotation.semantic:type_name -> google.protobuf.GeneratedCodeInfo.Annotation.Semantic - 71, // [71:71] is the sub-list for method output_type - 71, // [71:71] is the sub-list for method input_type - 71, // [71:71] is the sub-list for extension type_name - 71, // [71:71] is the sub-list for extension extendee - 0, // [0:71] is the sub-list for field type_name + 45, // 42: google.protobuf.FieldOptions.feature_support:type_name -> google.protobuf.FieldOptions.FeatureSupport + 35, // 43: google.protobuf.FieldOptions.uninterpreted_option:type_name -> google.protobuf.UninterpretedOption + 36, // 44: google.protobuf.OneofOptions.features:type_name -> google.protobuf.FeatureSet + 35, // 45: google.protobuf.OneofOptions.uninterpreted_option:type_name -> google.protobuf.UninterpretedOption + 36, // 46: google.protobuf.EnumOptions.features:type_name -> google.protobuf.FeatureSet + 35, // 47: google.protobuf.EnumOptions.uninterpreted_option:type_name -> google.protobuf.UninterpretedOption + 36, // 48: google.protobuf.EnumValueOptions.features:type_name -> google.protobuf.FeatureSet + 35, // 49: google.protobuf.EnumValueOptions.uninterpreted_option:type_name -> google.protobuf.UninterpretedOption + 36, // 50: google.protobuf.ServiceOptions.features:type_name -> google.protobuf.FeatureSet + 35, // 51: google.protobuf.ServiceOptions.uninterpreted_option:type_name -> google.protobuf.UninterpretedOption + 9, // 52: google.protobuf.MethodOptions.idempotency_level:type_name -> google.protobuf.MethodOptions.IdempotencyLevel + 36, // 53: google.protobuf.MethodOptions.features:type_name -> google.protobuf.FeatureSet + 35, // 54: google.protobuf.MethodOptions.uninterpreted_option:type_name -> google.protobuf.UninterpretedOption + 46, // 55: google.protobuf.UninterpretedOption.name:type_name -> google.protobuf.UninterpretedOption.NamePart + 10, // 56: google.protobuf.FeatureSet.field_presence:type_name -> google.protobuf.FeatureSet.FieldPresence + 11, // 57: google.protobuf.FeatureSet.enum_type:type_name -> google.protobuf.FeatureSet.EnumType + 12, // 58: google.protobuf.FeatureSet.repeated_field_encoding:type_name -> google.protobuf.FeatureSet.RepeatedFieldEncoding + 13, // 59: google.protobuf.FeatureSet.utf8_validation:type_name -> google.protobuf.FeatureSet.Utf8Validation + 14, // 60: google.protobuf.FeatureSet.message_encoding:type_name -> google.protobuf.FeatureSet.MessageEncoding + 15, // 61: google.protobuf.FeatureSet.json_format:type_name -> google.protobuf.FeatureSet.JsonFormat + 47, // 62: google.protobuf.FeatureSetDefaults.defaults:type_name -> google.protobuf.FeatureSetDefaults.FeatureSetEditionDefault + 0, // 63: google.protobuf.FeatureSetDefaults.minimum_edition:type_name -> google.protobuf.Edition + 0, // 64: google.protobuf.FeatureSetDefaults.maximum_edition:type_name -> google.protobuf.Edition + 48, // 65: google.protobuf.SourceCodeInfo.location:type_name -> google.protobuf.SourceCodeInfo.Location + 49, // 66: google.protobuf.GeneratedCodeInfo.annotation:type_name -> google.protobuf.GeneratedCodeInfo.Annotation + 20, // 67: google.protobuf.DescriptorProto.ExtensionRange.options:type_name -> google.protobuf.ExtensionRangeOptions + 0, // 68: google.protobuf.FieldOptions.EditionDefault.edition:type_name -> google.protobuf.Edition + 0, // 69: google.protobuf.FieldOptions.FeatureSupport.edition_introduced:type_name -> google.protobuf.Edition + 0, // 70: google.protobuf.FieldOptions.FeatureSupport.edition_deprecated:type_name -> google.protobuf.Edition + 0, // 71: google.protobuf.FieldOptions.FeatureSupport.edition_removed:type_name -> google.protobuf.Edition + 0, // 72: google.protobuf.FeatureSetDefaults.FeatureSetEditionDefault.edition:type_name -> google.protobuf.Edition + 36, // 73: google.protobuf.FeatureSetDefaults.FeatureSetEditionDefault.overridable_features:type_name -> google.protobuf.FeatureSet + 36, // 74: google.protobuf.FeatureSetDefaults.FeatureSetEditionDefault.fixed_features:type_name -> google.protobuf.FeatureSet + 16, // 75: google.protobuf.GeneratedCodeInfo.Annotation.semantic:type_name -> google.protobuf.GeneratedCodeInfo.Annotation.Semantic + 76, // [76:76] is the sub-list for method output_type + 76, // [76:76] is the sub-list for method input_type + 76, // [76:76] is the sub-list for extension type_name + 76, // [76:76] is the sub-list for extension extendee + 0, // [0:76] is the sub-list for field type_name } func init() { file_google_protobuf_descriptor_proto_init() } @@ -5578,7 +5726,7 @@ func file_google_protobuf_descriptor_proto_init() { } } file_google_protobuf_descriptor_proto_msgTypes[28].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*UninterpretedOption_NamePart); i { + switch v := v.(*FieldOptions_FeatureSupport); i { case 0: return &v.state case 1: @@ -5590,7 +5738,7 @@ func file_google_protobuf_descriptor_proto_init() { } } file_google_protobuf_descriptor_proto_msgTypes[29].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*FeatureSetDefaults_FeatureSetEditionDefault); i { + switch v := v.(*UninterpretedOption_NamePart); i { case 0: return &v.state case 1: @@ -5602,7 +5750,7 @@ func file_google_protobuf_descriptor_proto_init() { } } file_google_protobuf_descriptor_proto_msgTypes[30].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*SourceCodeInfo_Location); i { + switch v := v.(*FeatureSetDefaults_FeatureSetEditionDefault); i { case 0: return &v.state case 1: @@ -5614,6 +5762,18 @@ func file_google_protobuf_descriptor_proto_init() { } } file_google_protobuf_descriptor_proto_msgTypes[31].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*SourceCodeInfo_Location); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_google_protobuf_descriptor_proto_msgTypes[32].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*GeneratedCodeInfo_Annotation); i { case 0: return &v.state @@ -5632,7 +5792,7 @@ func file_google_protobuf_descriptor_proto_init() { GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_google_protobuf_descriptor_proto_rawDesc, NumEnums: 17, - NumMessages: 32, + NumMessages: 33, NumExtensions: 0, NumServices: 0, }, diff --git a/vendor/google.golang.org/protobuf/types/gofeaturespb/go_features.pb.go b/vendor/google.golang.org/protobuf/types/gofeaturespb/go_features.pb.go index 25de5ae0..b0df3fb3 100644 --- a/vendor/google.golang.org/protobuf/types/gofeaturespb/go_features.pb.go +++ b/vendor/google.golang.org/protobuf/types/gofeaturespb/go_features.pb.go @@ -6,9 +6,9 @@ // https://developers.google.com/open-source/licenses/bsd // Code generated by protoc-gen-go. DO NOT EDIT. -// source: reflect/protodesc/proto/go_features.proto +// source: google/protobuf/go_features.proto -package proto +package gofeaturespb import ( protoreflect "google.golang.org/protobuf/reflect/protoreflect" @@ -30,7 +30,7 @@ type GoFeatures struct { func (x *GoFeatures) Reset() { *x = GoFeatures{} if protoimpl.UnsafeEnabled { - mi := &file_reflect_protodesc_proto_go_features_proto_msgTypes[0] + mi := &file_google_protobuf_go_features_proto_msgTypes[0] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -43,7 +43,7 @@ func (x *GoFeatures) String() string { func (*GoFeatures) ProtoMessage() {} func (x *GoFeatures) ProtoReflect() protoreflect.Message { - mi := &file_reflect_protodesc_proto_go_features_proto_msgTypes[0] + mi := &file_google_protobuf_go_features_proto_msgTypes[0] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -56,7 +56,7 @@ func (x *GoFeatures) ProtoReflect() protoreflect.Message { // Deprecated: Use GoFeatures.ProtoReflect.Descriptor instead. func (*GoFeatures) Descriptor() ([]byte, []int) { - return file_reflect_protodesc_proto_go_features_proto_rawDescGZIP(), []int{0} + return file_google_protobuf_go_features_proto_rawDescGZIP(), []int{0} } func (x *GoFeatures) GetLegacyUnmarshalJsonEnum() bool { @@ -66,69 +66,73 @@ func (x *GoFeatures) GetLegacyUnmarshalJsonEnum() bool { return false } -var file_reflect_protodesc_proto_go_features_proto_extTypes = []protoimpl.ExtensionInfo{ +var file_google_protobuf_go_features_proto_extTypes = []protoimpl.ExtensionInfo{ { ExtendedType: (*descriptorpb.FeatureSet)(nil), ExtensionType: (*GoFeatures)(nil), Field: 1002, - Name: "google.protobuf.go", + Name: "pb.go", Tag: "bytes,1002,opt,name=go", - Filename: "reflect/protodesc/proto/go_features.proto", + Filename: "google/protobuf/go_features.proto", }, } // Extension fields to descriptorpb.FeatureSet. var ( - // optional google.protobuf.GoFeatures go = 1002; - E_Go = &file_reflect_protodesc_proto_go_features_proto_extTypes[0] + // optional pb.GoFeatures go = 1002; + E_Go = &file_google_protobuf_go_features_proto_extTypes[0] ) -var File_reflect_protodesc_proto_go_features_proto protoreflect.FileDescriptor - -var file_reflect_protodesc_proto_go_features_proto_rawDesc = []byte{ - 0x0a, 0x29, 0x72, 0x65, 0x66, 0x6c, 0x65, 0x63, 0x74, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x64, - 0x65, 0x73, 0x63, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x67, 0x6f, 0x5f, 0x66, 0x65, 0x61, - 0x74, 0x75, 0x72, 0x65, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x0f, 0x67, 0x6f, 0x6f, - 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x1a, 0x20, 0x67, 0x6f, - 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x64, 0x65, - 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x6f, 0x72, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x6a, - 0x0a, 0x0a, 0x47, 0x6f, 0x46, 0x65, 0x61, 0x74, 0x75, 0x72, 0x65, 0x73, 0x12, 0x5c, 0x0a, 0x1a, - 0x6c, 0x65, 0x67, 0x61, 0x63, 0x79, 0x5f, 0x75, 0x6e, 0x6d, 0x61, 0x72, 0x73, 0x68, 0x61, 0x6c, - 0x5f, 0x6a, 0x73, 0x6f, 0x6e, 0x5f, 0x65, 0x6e, 0x75, 0x6d, 0x18, 0x01, 0x20, 0x01, 0x28, 0x08, - 0x42, 0x1f, 0x88, 0x01, 0x01, 0x98, 0x01, 0x06, 0xa2, 0x01, 0x09, 0x12, 0x04, 0x74, 0x72, 0x75, - 0x65, 0x18, 0xe6, 0x07, 0xa2, 0x01, 0x0a, 0x12, 0x05, 0x66, 0x61, 0x6c, 0x73, 0x65, 0x18, 0xe7, - 0x07, 0x52, 0x17, 0x6c, 0x65, 0x67, 0x61, 0x63, 0x79, 0x55, 0x6e, 0x6d, 0x61, 0x72, 0x73, 0x68, - 0x61, 0x6c, 0x4a, 0x73, 0x6f, 0x6e, 0x45, 0x6e, 0x75, 0x6d, 0x3a, 0x49, 0x0a, 0x02, 0x67, 0x6f, - 0x12, 0x1b, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, - 0x75, 0x66, 0x2e, 0x46, 0x65, 0x61, 0x74, 0x75, 0x72, 0x65, 0x53, 0x65, 0x74, 0x18, 0xea, 0x07, - 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1b, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, - 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x47, 0x6f, 0x46, 0x65, 0x61, 0x74, 0x75, 0x72, 0x65, - 0x73, 0x52, 0x02, 0x67, 0x6f, 0x42, 0x34, 0x5a, 0x32, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, - 0x67, 0x6f, 0x6c, 0x61, 0x6e, 0x67, 0x2e, 0x6f, 0x72, 0x67, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, - 0x62, 0x75, 0x66, 0x2f, 0x72, 0x65, 0x66, 0x6c, 0x65, 0x63, 0x74, 0x2f, 0x70, 0x72, 0x6f, 0x74, - 0x6f, 0x64, 0x65, 0x73, 0x63, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, +var File_google_protobuf_go_features_proto protoreflect.FileDescriptor + +var file_google_protobuf_go_features_proto_rawDesc = []byte{ + 0x0a, 0x21, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, + 0x66, 0x2f, 0x67, 0x6f, 0x5f, 0x66, 0x65, 0x61, 0x74, 0x75, 0x72, 0x65, 0x73, 0x2e, 0x70, 0x72, + 0x6f, 0x74, 0x6f, 0x12, 0x02, 0x70, 0x62, 0x1a, 0x20, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, + 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, + 0x74, 0x6f, 0x72, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0xc9, 0x01, 0x0a, 0x0a, 0x47, 0x6f, + 0x46, 0x65, 0x61, 0x74, 0x75, 0x72, 0x65, 0x73, 0x12, 0xba, 0x01, 0x0a, 0x1a, 0x6c, 0x65, 0x67, + 0x61, 0x63, 0x79, 0x5f, 0x75, 0x6e, 0x6d, 0x61, 0x72, 0x73, 0x68, 0x61, 0x6c, 0x5f, 0x6a, 0x73, + 0x6f, 0x6e, 0x5f, 0x65, 0x6e, 0x75, 0x6d, 0x18, 0x01, 0x20, 0x01, 0x28, 0x08, 0x42, 0x7d, 0x88, + 0x01, 0x01, 0x98, 0x01, 0x06, 0xa2, 0x01, 0x09, 0x12, 0x04, 0x74, 0x72, 0x75, 0x65, 0x18, 0x84, + 0x07, 0xa2, 0x01, 0x0a, 0x12, 0x05, 0x66, 0x61, 0x6c, 0x73, 0x65, 0x18, 0xe7, 0x07, 0xb2, 0x01, + 0x5b, 0x08, 0xe8, 0x07, 0x10, 0xe8, 0x07, 0x1a, 0x53, 0x54, 0x68, 0x65, 0x20, 0x6c, 0x65, 0x67, + 0x61, 0x63, 0x79, 0x20, 0x55, 0x6e, 0x6d, 0x61, 0x72, 0x73, 0x68, 0x61, 0x6c, 0x4a, 0x53, 0x4f, + 0x4e, 0x20, 0x41, 0x50, 0x49, 0x20, 0x69, 0x73, 0x20, 0x64, 0x65, 0x70, 0x72, 0x65, 0x63, 0x61, + 0x74, 0x65, 0x64, 0x20, 0x61, 0x6e, 0x64, 0x20, 0x77, 0x69, 0x6c, 0x6c, 0x20, 0x62, 0x65, 0x20, + 0x72, 0x65, 0x6d, 0x6f, 0x76, 0x65, 0x64, 0x20, 0x69, 0x6e, 0x20, 0x61, 0x20, 0x66, 0x75, 0x74, + 0x75, 0x72, 0x65, 0x20, 0x65, 0x64, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x2e, 0x52, 0x17, 0x6c, 0x65, + 0x67, 0x61, 0x63, 0x79, 0x55, 0x6e, 0x6d, 0x61, 0x72, 0x73, 0x68, 0x61, 0x6c, 0x4a, 0x73, 0x6f, + 0x6e, 0x45, 0x6e, 0x75, 0x6d, 0x3a, 0x3c, 0x0a, 0x02, 0x67, 0x6f, 0x12, 0x1b, 0x2e, 0x67, 0x6f, + 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x46, 0x65, + 0x61, 0x74, 0x75, 0x72, 0x65, 0x53, 0x65, 0x74, 0x18, 0xea, 0x07, 0x20, 0x01, 0x28, 0x0b, 0x32, + 0x0e, 0x2e, 0x70, 0x62, 0x2e, 0x47, 0x6f, 0x46, 0x65, 0x61, 0x74, 0x75, 0x72, 0x65, 0x73, 0x52, + 0x02, 0x67, 0x6f, 0x42, 0x2f, 0x5a, 0x2d, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x67, 0x6f, + 0x6c, 0x61, 0x6e, 0x67, 0x2e, 0x6f, 0x72, 0x67, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, + 0x66, 0x2f, 0x74, 0x79, 0x70, 0x65, 0x73, 0x2f, 0x67, 0x6f, 0x66, 0x65, 0x61, 0x74, 0x75, 0x72, + 0x65, 0x73, 0x70, 0x62, } var ( - file_reflect_protodesc_proto_go_features_proto_rawDescOnce sync.Once - file_reflect_protodesc_proto_go_features_proto_rawDescData = file_reflect_protodesc_proto_go_features_proto_rawDesc + file_google_protobuf_go_features_proto_rawDescOnce sync.Once + file_google_protobuf_go_features_proto_rawDescData = file_google_protobuf_go_features_proto_rawDesc ) -func file_reflect_protodesc_proto_go_features_proto_rawDescGZIP() []byte { - file_reflect_protodesc_proto_go_features_proto_rawDescOnce.Do(func() { - file_reflect_protodesc_proto_go_features_proto_rawDescData = protoimpl.X.CompressGZIP(file_reflect_protodesc_proto_go_features_proto_rawDescData) +func file_google_protobuf_go_features_proto_rawDescGZIP() []byte { + file_google_protobuf_go_features_proto_rawDescOnce.Do(func() { + file_google_protobuf_go_features_proto_rawDescData = protoimpl.X.CompressGZIP(file_google_protobuf_go_features_proto_rawDescData) }) - return file_reflect_protodesc_proto_go_features_proto_rawDescData + return file_google_protobuf_go_features_proto_rawDescData } -var file_reflect_protodesc_proto_go_features_proto_msgTypes = make([]protoimpl.MessageInfo, 1) -var file_reflect_protodesc_proto_go_features_proto_goTypes = []interface{}{ - (*GoFeatures)(nil), // 0: google.protobuf.GoFeatures +var file_google_protobuf_go_features_proto_msgTypes = make([]protoimpl.MessageInfo, 1) +var file_google_protobuf_go_features_proto_goTypes = []interface{}{ + (*GoFeatures)(nil), // 0: pb.GoFeatures (*descriptorpb.FeatureSet)(nil), // 1: google.protobuf.FeatureSet } -var file_reflect_protodesc_proto_go_features_proto_depIdxs = []int32{ - 1, // 0: google.protobuf.go:extendee -> google.protobuf.FeatureSet - 0, // 1: google.protobuf.go:type_name -> google.protobuf.GoFeatures +var file_google_protobuf_go_features_proto_depIdxs = []int32{ + 1, // 0: pb.go:extendee -> google.protobuf.FeatureSet + 0, // 1: pb.go:type_name -> pb.GoFeatures 2, // [2:2] is the sub-list for method output_type 2, // [2:2] is the sub-list for method input_type 1, // [1:2] is the sub-list for extension type_name @@ -136,13 +140,13 @@ var file_reflect_protodesc_proto_go_features_proto_depIdxs = []int32{ 0, // [0:0] is the sub-list for field type_name } -func init() { file_reflect_protodesc_proto_go_features_proto_init() } -func file_reflect_protodesc_proto_go_features_proto_init() { - if File_reflect_protodesc_proto_go_features_proto != nil { +func init() { file_google_protobuf_go_features_proto_init() } +func file_google_protobuf_go_features_proto_init() { + if File_google_protobuf_go_features_proto != nil { return } if !protoimpl.UnsafeEnabled { - file_reflect_protodesc_proto_go_features_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + file_google_protobuf_go_features_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*GoFeatures); i { case 0: return &v.state @@ -159,19 +163,19 @@ func file_reflect_protodesc_proto_go_features_proto_init() { out := protoimpl.TypeBuilder{ File: protoimpl.DescBuilder{ GoPackagePath: reflect.TypeOf(x{}).PkgPath(), - RawDescriptor: file_reflect_protodesc_proto_go_features_proto_rawDesc, + RawDescriptor: file_google_protobuf_go_features_proto_rawDesc, NumEnums: 0, NumMessages: 1, NumExtensions: 1, NumServices: 0, }, - GoTypes: file_reflect_protodesc_proto_go_features_proto_goTypes, - DependencyIndexes: file_reflect_protodesc_proto_go_features_proto_depIdxs, - MessageInfos: file_reflect_protodesc_proto_go_features_proto_msgTypes, - ExtensionInfos: file_reflect_protodesc_proto_go_features_proto_extTypes, + GoTypes: file_google_protobuf_go_features_proto_goTypes, + DependencyIndexes: file_google_protobuf_go_features_proto_depIdxs, + MessageInfos: file_google_protobuf_go_features_proto_msgTypes, + ExtensionInfos: file_google_protobuf_go_features_proto_extTypes, }.Build() - File_reflect_protodesc_proto_go_features_proto = out.File - file_reflect_protodesc_proto_go_features_proto_rawDesc = nil - file_reflect_protodesc_proto_go_features_proto_goTypes = nil - file_reflect_protodesc_proto_go_features_proto_depIdxs = nil + File_google_protobuf_go_features_proto = out.File + file_google_protobuf_go_features_proto_rawDesc = nil + file_google_protobuf_go_features_proto_goTypes = nil + file_google_protobuf_go_features_proto_depIdxs = nil } diff --git a/vendor/google.golang.org/protobuf/types/gofeaturespb/go_features.proto b/vendor/google.golang.org/protobuf/types/gofeaturespb/go_features.proto deleted file mode 100644 index d2465712..00000000 --- a/vendor/google.golang.org/protobuf/types/gofeaturespb/go_features.proto +++ /dev/null @@ -1,28 +0,0 @@ -// Protocol Buffers - Google's data interchange format -// Copyright 2023 Google Inc. All rights reserved. -// -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file or at -// https://developers.google.com/open-source/licenses/bsd - -syntax = "proto2"; - -package google.protobuf; - -import "google/protobuf/descriptor.proto"; - -option go_package = "google.golang.org/protobuf/types/gofeaturespb"; - -extend google.protobuf.FeatureSet { - optional GoFeatures go = 1002; -} - -message GoFeatures { - // Whether or not to generate the deprecated UnmarshalJSON method for enums. - optional bool legacy_unmarshal_json_enum = 1 [ - retention = RETENTION_RUNTIME, - targets = TARGET_TYPE_ENUM, - edition_defaults = { edition: EDITION_PROTO2, value: "true" }, - edition_defaults = { edition: EDITION_PROTO3, value: "false" } - ]; -} diff --git a/vendor/modules.txt b/vendor/modules.txt index 2408a758..446d34b1 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -1,4 +1,4 @@ -# gioui.org v0.7.0 +# gioui.org v0.7.1 ## explicit; go 1.21 gioui.org/app gioui.org/app/internal/windows @@ -51,13 +51,11 @@ gioui.org/cpu gioui.org/shader gioui.org/shader/gio gioui.org/shader/piet -# gioui.org/x v0.7.0 +# gioui.org/x v0.7.1 ## explicit; go 1.21 gioui.org/x/component gioui.org/x/explorer gioui.org/x/outlay -gioui.org/x/richtext -gioui.org/x/styledtext # git.wow.st/gmp/jni v0.0.0-20210610011705-34026c7e22d0 ## explicit; go 1.14 git.wow.st/gmp/jni @@ -126,9 +124,11 @@ github.com/jhump/protoreflect/desc/protoparse/ast github.com/jhump/protoreflect/desc/sourceinfo github.com/jhump/protoreflect/grpcreflect github.com/jhump/protoreflect/internal -# github.com/oligo/gioview v0.4.1-0.20240715092046-997b87ed0255 +# github.com/oligo/gioview v0.5.1-0.20240805165652-db7ac64b4905 ## explicit; go 1.21.4 github.com/oligo/gioview/editor +github.com/oligo/gioview/misc +github.com/oligo/gioview/theme # github.com/shopspring/decimal v1.3.1 ## explicit; go 1.13 github.com/shopspring/decimal @@ -162,7 +162,7 @@ golang.org/x/image/math/fixed golang.org/x/image/tiff golang.org/x/image/tiff/lzw golang.org/x/image/vector -# golang.org/x/net v0.22.0 +# golang.org/x/net v0.25.0 ## explicit; go 1.18 golang.org/x/net/http/httpguts golang.org/x/net/http2 @@ -184,17 +184,18 @@ golang.org/x/text/secure/bidirule golang.org/x/text/transform golang.org/x/text/unicode/bidi golang.org/x/text/unicode/norm -# google.golang.org/genproto/googleapis/rpc v0.0.0-20240318140521-94a12d6c2237 -## explicit; go 1.19 +# google.golang.org/genproto/googleapis/rpc v0.0.0-20240528184218-531527333157 +## explicit; go 1.20 google.golang.org/genproto/googleapis/rpc/status -# google.golang.org/grpc v1.64.0 -## explicit; go 1.19 +# google.golang.org/grpc v1.65.0 +## explicit; go 1.21 google.golang.org/grpc google.golang.org/grpc/attributes google.golang.org/grpc/backoff google.golang.org/grpc/balancer google.golang.org/grpc/balancer/base google.golang.org/grpc/balancer/grpclb/state +google.golang.org/grpc/balancer/pickfirst google.golang.org/grpc/balancer/roundrobin google.golang.org/grpc/binarylog/grpc_binarylog_v1 google.golang.org/grpc/channelz @@ -215,7 +216,6 @@ google.golang.org/grpc/internal/channelz google.golang.org/grpc/internal/credentials google.golang.org/grpc/internal/envconfig google.golang.org/grpc/internal/grpclog -google.golang.org/grpc/internal/grpcrand google.golang.org/grpc/internal/grpcsync google.golang.org/grpc/internal/grpcutil google.golang.org/grpc/internal/idle @@ -244,7 +244,7 @@ google.golang.org/grpc/serviceconfig google.golang.org/grpc/stats google.golang.org/grpc/status google.golang.org/grpc/tap -# google.golang.org/protobuf v1.33.1-0.20240408130810-98873a205002 +# google.golang.org/protobuf v1.34.1 ## explicit; go 1.17 google.golang.org/protobuf/encoding/protojson google.golang.org/protobuf/encoding/prototext