diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..6bca197 --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,34 @@ +name: 🏗️ Build + +on: + push: + branches: [main] + pull_request: ~ + +env: + GO_VERSION: "1.25" + +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v6 + + - name: Set up Go ${{ env.GO_VERSION }} + uses: actions/setup-go@v6 + with: + go-version: ${{ env.GO_VERSION }} + + - name: 📦 Install Mise + run: | + curl https://mise.run | sh + mise install + + - name: Install dependencies + run: sudo apt install wv unrtf tidy + + - name: Build + run: mise build + + - name: Test + run: mise test diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..ff238f6 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,31 @@ +name: 🚀 Publish Release + +on: + push: + tags: + - 'v?[0-9]+.[0-9]+.[0-9]+(-alpha[0-9]+|-beta[0-9]+)?' + +env: + GO_VERSION: "1.25" + +jobs: + release: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v6 + + - name: 📦 Install Mise + run: | + curl https://mise.run | sh + mise install + + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Run GoReleaser Snapshot + run: mise release + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/snapshot.yml b/.github/workflows/snapshot.yml new file mode 100644 index 0000000..f5ba423 --- /dev/null +++ b/.github/workflows/snapshot.yml @@ -0,0 +1,34 @@ +name: 👨‍🔧 Build Snapshot Release + +on: + workflow_dispatch: ~ + +env: + GO_VERSION: "1.25" + +jobs: + release: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v6 + + - name: Set up Go + uses: actions/setup-go@v6 + with: + go-version: ${{ env.GO_VERSION }} + + - name: 📦 Install Mise + run: | + curl https://mise.run | sh + mise install + + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Run GoReleaser Snapshot + run: mise snapshot + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.gitignore b/.gitignore index 72acfc5..d872b6e 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,5 @@ sajari-convert *tests/ +/dist +/vendor diff --git a/.goreleaser.yml b/.goreleaser.yml new file mode 100644 index 0000000..706b7f5 --- /dev/null +++ b/.goreleaser.yml @@ -0,0 +1,50 @@ +project_name: docconv + +version: 2 + +builds: + - id: docconv-build + main: ./docd + binary: docconv + ldflags: + - -extldflags '-static' + env: + - CGO_ENABLED=0 + goos: [ linux ] + goarch: [ amd64, arm64 ] + +release: + prerelease: auto + name_template: "docconv {{.Version}}" + github: + owner: skpr + name: docconv + +nfpms: + - id: docconv-package + package_name: docconv + license: MIT + maintainer: Skpr + homepage: https://github.com/skpr/docconv + description: Fork of https://github.com/sajari/docconv to add additional package formats. + formats: [ apk ] + dependencies: + - tesseract-ocr + - poppler-utils + overrides: + apk: + dependencies: + - tesseract-ocr + - tesseract-ocr-dev + - poppler-utils + +dockers_v2: + - images: + - "docker.io/skpr/docconv" + - "ghcr.io/skpr/docconv" + tags: + - "{{ .Version }}" + - "latest" + platforms: + - linux/amd64 + - linux/arm64 diff --git a/.mise.toml b/.mise.toml new file mode 100644 index 0000000..79b52ef --- /dev/null +++ b/.mise.toml @@ -0,0 +1,25 @@ +[tools] +go = "1.25" +"ubi:goreleaser/goreleaser" = "latest" + +[env] +CGO_ENABLED=0 +LGFLAGS="-extldflags '-static'" + +[tasks.build] +description = "Build the application" +run = ''' +go build -v -o ./dist/docconv ./docd +''' + +[tasks.test] +description = "Run tests" +run = "go test -v ./..." + +[tasks.snapshot] +description = "Create a snapshot release with Goreleaser" +run = "goreleaser release --snapshot --clean" + +[tasks.release] +description = "Create a release with Goreleaser" +run = "goreleaser release --clean" diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 19271c3..0000000 --- a/.travis.yml +++ /dev/null @@ -1,10 +0,0 @@ -sudo: false -language: go -go: -- "1.13" -- "1.14" -- tip -go_import_path: code.sajari.com/docconv -notifications: - email: - - infra@sajari.com diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..7008e8e --- /dev/null +++ b/Dockerfile @@ -0,0 +1,8 @@ +ARG ALPINE_VERSION=3.21 +FROM alpine:$ALPINE_VERSION + +RUN apk add --no-cache tesseract-ocr tesseract-ocr-dev poppler-utils + +ARG TARGETPLATFORM +COPY $TARGETPLATFORM/docconv /usr/bin/docconv +ENTRYPOINT ["/usr/bin/docconv"] diff --git a/README.md b/README.md index 9593432..74a0563 100644 --- a/README.md +++ b/README.md @@ -1,30 +1,53 @@ # docconv -[![GoDoc](https://godoc.org/code.sajari.com/docconv?status.svg)](https://godoc.org/code.sajari.com/docconv) -[![Build Status](https://travis-ci.org/sajari/docconv.svg?branch=master)](https://travis-ci.org/sajari/docconv) +[![Go reference](https://pkg.go.dev/badge/code.sajari.com/docconv/v2.svg)](https://pkg.go.dev/code.sajari.com/docconv/v2) +[![Build status](https://github.com/sajari/docconv/workflows/Go/badge.svg?branch=master)](https://github.com/sajari/docconv/actions) +[![Report card](https://goreportcard.com/badge/code.sajari.com/docconv/v2)](https://goreportcard.com/report/code.sajari.com/docconv/v2) +[![Sourcegraph](https://sourcegraph.com/github.com/sajari/docconv/v2/-/badge.svg)](https://sourcegraph.com/github.com/sajari/docconv/v2) A Go wrapper library to convert PDF, DOC, DOCX, XML, HTML, RTF, ODT, Pages documents and images (see optional dependencies below) to plain text. -> **Note for returning users:** the Go import path for this package been moved to `code.sajari.com/docconv`. - ## Installation If you haven't setup Go before, you first need to [install Go](https://golang.org/doc/install). To fetch and build the code: - $ go get code.sajari.com/docconv/... +```console +$ go install code.sajari.com/docconv/v2/docd@latest +``` + +See `go help install` for details on the installation location of the installed `docd` executable. Make sure that the full path to the executable is in your `PATH` environment variable. -This will also build the command line tool `docd` into `$GOPATH/bin`. Make sure that `$GOPATH/bin` is in your `PATH` environment variable. +## Build + +``` +docker run -it -v $(pwd):/go/src/github.com/skpr/docconv -w /go/src/github.com/skpr/docconv golang:1.23-alpine3.11 /bin/sh -c "./build.sh 3.11" +docker run -it -v $(pwd):/go/src/github.com/skpr/docconv -w /go/src/github.com/skpr/docconv golang:1.23-alpine3.12 /bin/sh -c "./build.sh 3.12" +docker run -it -v $(pwd):/go/src/github.com/skpr/docconv -w /go/src/github.com/skpr/docconv golang:1.23-alpine3.13 /bin/sh -c "./build.sh 3.13" +``` ## Dependencies -tidy, wv, popplerutils, unrtf, https://github.com/JalfResi/justext +- tidy +- wv +- popplerutils +- unrtf +- https://github.com/JalfResi/justext + +### Debian-based Linux -Example install of dependencies (not all systems): +```console +$ sudo apt-get install poppler-utils wv unrtf tidy +$ go get github.com/JalfResi/justext +``` - $ sudo apt-get install poppler-utils wv unrtf tidy - $ go get github.com/JalfResi/justext +### macOS + +```console +$ brew install poppler-qt5 wv unrtf tidy-html5 +$ go get github.com/JalfResi/justext +``` ### Optional dependencies @@ -32,11 +55,15 @@ To add image support to the `docconv` library you first need to [install and bui Now you can add `-tags ocr` to any `go` command when building/fetching/testing `docconv` to include support for processing images: - $ go get -tags ocr code.sajari.com/docconv/... +```console +$ go get -tags ocr code.sajari.com/docconv/v2/... +``` This may complain on macOS, which you can fix by installing [tesseract](https://tesseract-ocr.github.io) via brew: - $ brew install tesseract +```console +$ brew install tesseract +``` ## docd tool @@ -48,27 +75,27 @@ The `docd` tool runs as either: 2. a service exposed from within a Docker container - This also runs as a service, but from within a Docker container. There are three build scripts: + This also runs as a service, but from within a Docker container. + Official images are published at https://hub.docker.com/r/sajari/docd. - - [./docd/debian.sh](./docd/debian.sh) - - [./docd/alpine.sh](./docd/alpine.sh) - - [./docd/appengine.sh](./docd/appengine.sh) + Optionally you can build it yourself: - The `debian` version uses the Debian package repository which can vary with builds. The `alpine` version uses a very cut down Linux distribution to produce a container ~40MB. It also locks the dependency versions for consistency, but may miss out on future updates. The `appengine` version is a flex based custom runtime for Google Cloud. + ```console + $ cd docd + $ docker build -t docd . + ``` 3. via the command line. Documents can be sent as an argument, e.g. - $ docd -input document.pdf + ```console + $ docd -input document.pdf + ``` ### Optional flags - `addr` - the bind address for the HTTP server, default is ":8888" -- `log-level` - - 0: errors & critical info - - 1: inclues 0 and logs each request as well - - 2: include 1 and logs the response payloads - `readability-length-low` - sets the readability length low if the ?readability=1 parameter is set - `readability-length-high` - sets the readability length high if the ?readability=1 parameter is set - `readability-stopwords-low` - sets the readability stopwords low if the ?readability=1 parameter is set @@ -79,11 +106,10 @@ The `docd` tool runs as either: ### How to start the service - $ # This will only log errors and critical info - $ docd -log-level 0 - - $ # This will run on port 8000 and log each request - $ docd -addr :8000 -log-level 1 +```console +$ # This runs on port 8000 +$ docd -addr :8000 +``` ## Example usage (code) @@ -100,15 +126,14 @@ package main import ( "fmt" - "log" - "code.sajari.com/docconv" + "code.sajari.com/docconv/v2" ) func main() { res, err := docconv.ConvertPath("your-file.pdf") if err != nil { - log.Fatal(err) + // TODO: handle } fmt.Println(res) } @@ -121,9 +146,8 @@ package main import ( "fmt" - "log" - "code.sajari.com/docconv/client" + "code.sajari.com/docconv/v2/client" ) func main() { @@ -132,8 +156,14 @@ func main() { res, err := client.ConvertPath(c, "your-file.pdf") if err != nil { - log.Fatal(err) + // TODO: handle } fmt.Println(res) } ``` + +Alternatively, via a `curl`: + +```console +$ curl -s -F input=@your-file.pdf http://localhost:8888/convert +``` diff --git a/build.sh b/build.sh new file mode 100755 index 0000000..02be979 --- /dev/null +++ b/build.sh @@ -0,0 +1,6 @@ +#!/bin/sh + +VERSION=$1 + +apk add make cmake gcc g++ poppler-utils wv lynx tesseract-ocr-dev +go build -o dist/docconv-${VERSION} -tags ocr github.com/skpr/docconv/docd diff --git a/client/client.go b/client/client.go index 5fe565e..69b04fd 100644 --- a/client/client.go +++ b/client/client.go @@ -89,8 +89,8 @@ func (c *Client) Convert(r io.Reader, filename string) (*Response, error) { if err != nil { return nil, err } - if _, err := io.Copy(part, r); err != nil { - return nil, err + if n, err := io.Copy(part, r); err != nil { + return nil, fmt.Errorf("could not copy file data into request (failed after %d bytes): %w", n, err) } if err := w.Close(); err != nil { return nil, err @@ -109,6 +109,16 @@ func (c *Client) Convert(r io.Reader, filename string) (*Response, error) { defer resp.Body.Close() res := &Response{} + if resp.StatusCode != http.StatusOK { + err := json.NewDecoder(resp.Body).Decode(&res) + if err != nil { + // Invalid JSON can come from proxies etc, so try + // to give something meaningful. + return nil, fmt.Errorf("non-OK status from convert server: %d (%v)", resp.StatusCode, http.StatusText(resp.StatusCode)) + } + return nil, fmt.Errorf("non-OK status from convert server: %d (%v) with error: %v", resp.StatusCode, http.StatusText(resp.StatusCode), res.Error) + } + if err := json.NewDecoder(resp.Body).Decode(&res); err != nil { return nil, err } diff --git a/client/cmd/docconv-client/main.go b/client/cmd/docconv-client/main.go index 38829d9..8572691 100644 --- a/client/cmd/docconv-client/main.go +++ b/client/cmd/docconv-client/main.go @@ -6,7 +6,7 @@ import ( "fmt" "os" - "code.sajari.com/docconv/client" + "code.sajari.com/docconv/v2/client" ) var ( diff --git a/doc.go b/doc.go index c0883f1..18f80d6 100644 --- a/doc.go +++ b/doc.go @@ -4,12 +4,12 @@ import ( "bytes" "fmt" "io" - "io/ioutil" - "log" "os" "os/exec" - "strings" "time" + + "github.com/richardlehane/mscfb" + "github.com/richardlehane/msoleps" ) // ConvertDoc converts an MS Word .doc to text. @@ -23,28 +23,45 @@ func ConvertDoc(r io.Reader) (string, map[string]string, error) { // Meta data mc := make(chan map[string]string, 1) go func() { + defer func() { + if e := recover(); e != nil { + // TODO: Propagate error. + } + }() + meta := make(map[string]string) - metaStr, err := exec.Command("wvSummary", f.Name()).Output() + + doc, err := mscfb.New(f) if err != nil { - // TODO: Remove this. - log.Println("wvSummary:", err) + // TODO: Propagate error. + mc <- meta + return } - // Parse meta output - for _, line := range strings.Split(string(metaStr), "\n") { - if parts := strings.SplitN(line, "=", 2); len(parts) > 1 { - meta[strings.TrimSpace(parts[0])] = strings.TrimSpace(parts[1]) + props := msoleps.New() + for entry, err := doc.Next(); err == nil; entry, err = doc.Next() { + if msoleps.IsMSOLEPS(entry.Initial) { + if err := props.Reset(doc); err != nil { + // TODO: Propagate error. + break + } + + for _, prop := range props.Property { + meta[prop.Name] = prop.String() + } } } + const defaultTimeFormat = "2006-01-02 15:04:05.999999999 -0700 MST" + // Convert parsed meta - if tmp, ok := meta["Last Modified"]; ok { - if t, err := time.Parse(time.RFC3339, tmp); err == nil { + if tmp, ok := meta["LastSaveTime"]; ok { + if t, err := time.Parse(defaultTimeFormat, tmp); err == nil { meta["ModifiedDate"] = fmt.Sprintf("%d", t.Unix()) } } - if tmp, ok := meta["Created"]; ok { - if t, err := time.Parse(time.RFC3339, tmp); err == nil { + if tmp, ok := meta["CreateTime"]; ok { + if t, err := time.Parse(defaultTimeFormat, tmp); err == nil { meta["CreatedDate"] = fmt.Sprintf("%d", t.Unix()) } } @@ -55,27 +72,23 @@ func ConvertDoc(r io.Reader) (string, map[string]string, error) { // Document body bc := make(chan string, 1) go func() { - // Save output to a file - outputFile, err := ioutil.TempFile("/tmp", "sajari-convert-") + var buf bytes.Buffer + outputFile, err := os.CreateTemp("/tmp", "sajari-convert-") if err != nil { - // TODO: Remove this. - log.Println("TempFile Out:", err) + bc <- buf.String() return } defer os.Remove(outputFile.Name()) err = exec.Command("wvText", f.Name(), outputFile.Name()).Run() if err != nil { - // TODO: Remove this. - log.Println("wvText:", err) + // TODO: Propagate error. } - var buf bytes.Buffer _, err = buf.ReadFrom(outputFile) if err != nil { - // TODO: Remove this. - log.Println("wvText:", err) + // TODO: Propagate error. } bc <- buf.String() diff --git a/doc_test.go b/doc_test.go new file mode 100644 index 0000000..9604f9b --- /dev/null +++ b/doc_test.go @@ -0,0 +1,91 @@ +package docconv + +import ( + "os" + "os/exec" + "path" + "strings" + "testing" + "time" + + "github.com/google/go-cmp/cmp" +) + +func TestConvertDoc(t *testing.T) { + if _, err := exec.LookPath("wvText"); err != nil { + t.Skip("wvText not installed") + return + } + + tests := []struct { + file string + wantTrimmedText string + wantMeta map[string]string + wantErr bool + }{ + { + file: "001-test.doc", + wantTrimmedText: "test", + wantMeta: map[string]string{ + "AppName": "Microsoft Office Word", + "CharCount": "4", + "Character count": "4", + "CodePage": "1252", + "Company": "", + "CreateTime": "2023-09-13 01:54:00 +0000 UTC", + "CreatedDate": "1694570040", + "Dirty links": "false", + "DocSecurity": "0", + "Document parts": "0", + "EditTime": "1970-01-01 00:00:00 +0000 UTC", + "Heading pair": "0", + "Hyperlinks changed": "false", + "LastAuthor": "cloudconvert_7", + "LastSaveTime": "2023-09-13 01:54:00 +0000 UTC", + "Line count": "1", + "ModifiedDate": "1694570040", + "PageCount": "1", + "Paragraph count": "1", + "RevNumber": "1", + "Scale": "false", + "Shared document": "false", + "Template": "Normal", + "Version": "1048576", + "WordCount": "0", + }, + }, + } + for _, tt := range tests { + t.Run(tt.file, func(t *testing.T) { + f, err := os.Open(path.Join("testdata", tt.file)) + if err != nil { + t.Fatal(err) + } + defer f.Close() + + gotText, gotMeta, err := ConvertDoc(f) + if (err != nil) != tt.wantErr { + t.Errorf("ConvertDoc() error = %v, wantErr %v", err, tt.wantErr) + return + } + gotText = strings.TrimSpace(gotText) + if gotText != tt.wantTrimmedText { + t.Errorf("ConvertDoc() text = %v, want %v", gotText, tt.wantTrimmedText) + } + if !cmp.Equal(tt.wantMeta, gotMeta, maybeTimeComparer) { + t.Errorf("ConvertDoc() meta mismatch (-want +got):\n%v", cmp.Diff(tt.wantMeta, gotMeta, maybeTimeComparer)) + } + }) + } +} + +// Compares strings as time.Times if they look like times. Required because +// wvText returns different time formats depending on system clock. +var maybeTimeComparer = cmp.Comparer(func(x, y string) bool { + xt, xterr := time.Parse("2006-01-02 15:04:05 -0700 MST", x) + yt, yterr := time.Parse("2006-01-02 15:04:05 -0700 MST", y) + if xterr == nil && yterr == nil { + return xt.Equal(yt) + } + return x == y +}) diff --git a/docconv.go b/docconv.go index eab82b2..218e06a 100755 --- a/docconv.go +++ b/docconv.go @@ -1,10 +1,9 @@ -package docconv // import "code.sajari.com/docconv" +package docconv // import "code.sajari.com/docconv/v2" import ( "encoding/json" "fmt" "io" - "io/ioutil" "os" "path" "strings" @@ -98,7 +97,7 @@ func Convert(r io.Reader, mimeType string, readability bool) (*Response, error) case "text/plain": var b []byte - b, err = ioutil.ReadAll(r) + b, err = io.ReadAll(r) body = string(b) } diff --git a/docd/Dockerfile b/docd/Dockerfile new file mode 100644 index 0000000..e82d572 --- /dev/null +++ b/docd/Dockerfile @@ -0,0 +1,29 @@ +FROM golang:1.21 AS build + +WORKDIR /app +COPY . ./ +RUN go build -o /bin/docd ./docd + +################################################################################ + +FROM debian:12-slim AS docd + +RUN apt-get update \ + && apt-get install -y --no-install-recommends \ + ca-certificates \ + lynx \ + poppler-utils \ + tidy \ + unrtf \ + wv \ + zip \ + && apt-get clean \ + && rm -rf /var/lib/apt/lists/* + +RUN update-ca-certificates + +EXPOSE 8888 + +COPY --from=build /bin/docd /docd +ENTRYPOINT ["/docd"] +CMD ["--help"] diff --git a/docd/alpine.sh b/docd/alpine.sh deleted file mode 100755 index 1d54dbc..0000000 --- a/docd/alpine.sh +++ /dev/null @@ -1,22 +0,0 @@ -#!/usr/bin/env sh - -main() { - export NAME=docd - export VERSION=alpine - - if [ "$#" -ne 1 ]; - then echo "usage: ${0} " - exit 1 - fi - - - echo "Building ${NAME} for ${VERSION}..." - - GOOS=linux GOARCH=amd64 go build -o $NAME || exit 1 - cp docd $VERSION - cd $VERSION || exit 1 - docker build -t "$NAME:$1" -t "$NAME:latest" . || exit 1 - rm docd -} - -main "$@" \ No newline at end of file diff --git a/docd/alpine/Dockerfile b/docd/alpine/Dockerfile deleted file mode 100644 index 60f8d9b..0000000 --- a/docd/alpine/Dockerfile +++ /dev/null @@ -1,17 +0,0 @@ -FROM alpine:3.7 - -MAINTAINER Hamish Ogilvy - -ENV CC=/usr/bin/gcc -ENV CXX=/usr/bin/g++ - -COPY dependencies/* / - -RUN apk add --update --no-cache make cmake gcc g++ poppler-utils=0.56.0-r0 wv=1.2.9-r3 lynx=2.8.8_p2-r6 \ - && ./install.sh \ - && apk del make cmake gcc g++ - -EXPOSE 8888 - -COPY docd / -CMD ["/docd"] diff --git a/docd/alpine/dependencies/install.sh b/docd/alpine/dependencies/install.sh deleted file mode 100755 index 22a67d5..0000000 --- a/docd/alpine/dependencies/install.sh +++ /dev/null @@ -1,22 +0,0 @@ -#!/usr/bin/env sh - -mkdir /tidy -mkdir /unrtf - -# Install Tidy -tar -C /tidy -xvf tidy-html5-5.4.0.tar.gz -cd /tidy/tidy-html5-5.4.0/build/cmake && \ - cmake ../.. -DCMAKE_BUILD_TYPE=Release && \ - make && \ - make install - -# Install UnRTF -tar -C /unrtf -xvf /unrtf-0.21.9.tar.gz -cd /unrtf/unrtf-0.21.9 && \ - ./configure && make && make install && make clean - -cd / && { - rm -r /tidy - rm -r /unrtf - rm ./*.tar.gz -} \ No newline at end of file diff --git a/docd/alpine/dependencies/tidy-html5-5.4.0.tar.gz b/docd/alpine/dependencies/tidy-html5-5.4.0.tar.gz deleted file mode 100644 index 3898d1f..0000000 Binary files a/docd/alpine/dependencies/tidy-html5-5.4.0.tar.gz and /dev/null differ diff --git a/docd/alpine/dependencies/unrtf-0.21.9.tar.gz b/docd/alpine/dependencies/unrtf-0.21.9.tar.gz deleted file mode 100644 index 11cf91a..0000000 Binary files a/docd/alpine/dependencies/unrtf-0.21.9.tar.gz and /dev/null differ diff --git a/docd/appengine.sh b/docd/appengine.sh deleted file mode 100755 index 3d01dbf..0000000 --- a/docd/appengine.sh +++ /dev/null @@ -1,25 +0,0 @@ -#!/usr/bin/env sh - -export NAME=docd -export VERSION=appengine - -function die { - echo 1>&2 $* - exit 1 -} - -mkdir appengine/dependencies -cp alpine/dependencies/* appengine/dependencies - -echo "Building ${NAME} for ${VERSION}..." - -GOOS=linux GOARCH=amd64 go build -o $NAME || exit 1 -cp docd $VERSION -cd $VERSION - -echo "Deploying to AppEngine..." -gcloud app deploy --version="1" - -# clean up -rm docd -rm -r appengine/dependencies \ No newline at end of file diff --git a/docd/appengine/Dockerfile b/docd/appengine/Dockerfile index 7029a5d..6bb57eb 100644 --- a/docd/appengine/Dockerfile +++ b/docd/appengine/Dockerfile @@ -1,15 +1,5 @@ -FROM alpine - -MAINTAINER Hamish Ogilvy - -ENV CC=/usr/bin/gcc -ENV CXX=/usr/bin/g++ - -COPY dependencies/* / - -RUN apk add --update --no-cache make cmake gcc g++ poppler-utils~=0.71.0 wv=1.2.9-r3 lynx~=2.8.8; ./install.sh; apk del make cmake gcc g++ - -EXPOSE 8080 - -COPY docd / -CMD ["/docd", "-addr", ":8080"] +# Dockerfile which produces an AppEngine custom runtime containing docd and all +# of its runtime dependencies. +# https://cloud.google.com/appengine/docs/flexible/custom-runtimes/about-custom-runtimes +FROM sajari/docd:1.3.8 +CMD ["-addr", ":8080", "-json-cloud-logging", "-error-reporting"] diff --git a/docd/appengine/README.md b/docd/appengine/README.md new file mode 100644 index 0000000..9a4c55c --- /dev/null +++ b/docd/appengine/README.md @@ -0,0 +1,7 @@ +# Deploying docd to AppEngine + +Within this directory run: + +``` +gcloud app deploy +``` diff --git a/docd/appengine/app.yaml b/docd/appengine/app.yaml index 635ab43..c88e471 100644 --- a/docd/appengine/app.yaml +++ b/docd/appengine/app.yaml @@ -4,11 +4,11 @@ env: flex service: docd resources: - memory_gb: .6 + memory_gb: 1.2 manual_scaling: - instances: 1 + instances: 2 handlers: -- url: /.* - script: _go_app \ No newline at end of file + - url: /.* + script: _go_app diff --git a/docd/convert.go b/docd/convert.go new file mode 100644 index 0000000..cb5b1e4 --- /dev/null +++ b/docd/convert.go @@ -0,0 +1,127 @@ +package main + +import ( + "bytes" + "context" + "encoding/json" + "errors" + "fmt" + "io" + "log/slog" + "net/http" + "os" + "syscall" + + "cloud.google.com/go/errorreporting" + + "code.sajari.com/docconv/v2" + "code.sajari.com/docconv/v2/docd/internal" +) + +type convertServer struct { + l *slog.Logger + er internal.ErrorReporter +} + +func (s *convertServer) convert(w http.ResponseWriter, r *http.Request) { + ctx := r.Context() + + // Readability flag. Currently only used for HTML + var readability bool + if r.FormValue("readability") == "1" { + readability = true + s.l.DebugContext(ctx, "Readability is on") + } + + path := r.FormValue("path") + if path != "" { + mimeType := docconv.MimeTypeByExtension(path) + + f, err := os.Open(path) + if err != nil { + s.serverError(ctx, w, r, fmt.Errorf("could not open file: %w", err)) + return + } + defer f.Close() + + data, err := docconv.Convert(f, mimeType, readability) + if err != nil { + s.serverError(ctx, w, r, fmt.Errorf("could not convert file from path %v: %w", path, err)) + return + } + + s.respond(ctx, w, r, http.StatusOK, data) + return + } + + // Get uploaded file + file, info, err := r.FormFile("input") + if err != nil { + s.serverError(ctx, w, r, fmt.Errorf("could not get input file: %w", err)) + return + } + defer file.Close() + + // Abort if file doesn't have a mime type + if len(info.Header["Content-Type"]) == 0 { + s.clientError(ctx, w, r, http.StatusUnprocessableEntity, "input file %v does not have a Content-Type header", info.Filename) + return + } + + // If a generic mime type was provided then use file extension to determine mimetype + mimeType := info.Header["Content-Type"][0] + if mimeType == "application/octet-stream" { + mimeType = docconv.MimeTypeByExtension(info.Filename) + } + + s.l.InfoContext(ctx, "Received file", "filename", info.Filename, "mimeType", mimeType) + + data, err := docconv.Convert(file, mimeType, readability) + if err != nil { + s.serverError(ctx, w, r, fmt.Errorf("could not convert file: %w", err)) + return + } + + s.respond(ctx, w, r, http.StatusOK, data) +} + +func (s *convertServer) clientError(ctx context.Context, w http.ResponseWriter, r *http.Request, code int, pattern string, args ...interface{}) { + s.respond(ctx, w, r, code, &docconv.Response{ + Error: fmt.Sprintf(pattern, args...), + }) + + s.l.InfoContext(ctx, fmt.Sprintf(pattern, args...)) +} + +func (s *convertServer) serverError(ctx context.Context, w http.ResponseWriter, r *http.Request, err error) { + w.WriteHeader(http.StatusInternalServerError) + w.Write([]byte(`{"error":"internal server error"}`)) + + e := errorreporting.Entry{ + Error: err, + Req: r, + } + s.er.Report(e) + + s.l.ErrorContext(ctx, err.Error(), "error", err) +} + +func (s *convertServer) respond(ctx context.Context, w http.ResponseWriter, r *http.Request, code int, resp interface{}) { + buf := &bytes.Buffer{} + err := json.NewEncoder(buf).Encode(resp) + if err != nil { + s.serverError(ctx, w, r, fmt.Errorf("could not marshal JSON response: %w", err)) + return + } + w.WriteHeader(code) + n, err := io.Copy(w, buf) + if err != nil { + // Avoid panicking on broken pipe errors. + // See https://gosamples.dev/broken-pipe/ + if errors.Is(err, syscall.EPIPE) { + s.l.DebugContext(ctx, err.Error(), "error", err) + return + } + panic(fmt.Errorf("could not write to response (failed after %d bytes): %w", n, err)) + } +} diff --git a/docd/debian.sh b/docd/debian.sh deleted file mode 100755 index 3817c50..0000000 --- a/docd/debian.sh +++ /dev/null @@ -1,18 +0,0 @@ -#!/usr/bin/env sh - -export NAME=docd -export VERSION=debian - -function die { - echo 1>&2 $* - exit 1 -} - -echo "Building ${NAME} for ${VERSION}..." - -GOOS=linux GOARCH=amd64 go build -o $NAME || exit 1 -cp docd $VERSION -cd $VERSION -docker build -t $NAME . || exit 1 -rm docd - diff --git a/docd/debian/Dockerfile b/docd/debian/Dockerfile deleted file mode 100644 index 7db1cff..0000000 --- a/docd/debian/Dockerfile +++ /dev/null @@ -1,16 +0,0 @@ -FROM debian - -MAINTAINER Hamish Ogilvy - -RUN apt-get update && apt-get install -y \ - zip \ - poppler-utils \ - wv \ - unrtf \ - tidy \ - lynx - -EXPOSE 8888 - -COPY docd / -CMD ["/docd"] diff --git a/docd/internal/cloudtrace/context.go b/docd/internal/cloudtrace/context.go new file mode 100644 index 0000000..97b0b22 --- /dev/null +++ b/docd/internal/cloudtrace/context.go @@ -0,0 +1,25 @@ +package cloudtrace + +import ( + "context" +) + +type traceKey struct{} +type spanKey struct{} + +func contextWithTraceInfo(ctx context.Context, traceHeader string) context.Context { + traceID, spanID := parseHeader(traceHeader) + if traceID != "" { + ctx = context.WithValue(ctx, traceKey{}, traceID) + } + if spanID != "" { + ctx = context.WithValue(ctx, spanKey{}, spanID) + } + return ctx +} + +func traceInfoFromContext(ctx context.Context) (traceID, spanID string) { + traceID, _ = ctx.Value(traceKey{}).(string) + spanID, _ = ctx.Value(spanKey{}).(string) + return +} diff --git a/docd/internal/cloudtrace/header.go b/docd/internal/cloudtrace/header.go new file mode 100644 index 0000000..c441baa --- /dev/null +++ b/docd/internal/cloudtrace/header.go @@ -0,0 +1,16 @@ +package cloudtrace + +import "strings" + +// The header specification is: +// "X-Cloud-Trace-Context: TRACE_ID/SPAN_ID;o=TRACE_TRUE" +const CloudTraceContextHeader = "X-Cloud-Trace-Context" + +func parseHeader(value string) (traceID, spanID string) { + var found bool + traceID, after, found := strings.Cut(value, "/") + if found { + spanID, _, _ = strings.Cut(after, ";") + } + return +} diff --git a/docd/internal/cloudtrace/http_handler.go b/docd/internal/cloudtrace/http_handler.go new file mode 100644 index 0000000..1a7071c --- /dev/null +++ b/docd/internal/cloudtrace/http_handler.go @@ -0,0 +1,14 @@ +package cloudtrace + +import "net/http" + +type HTTPHandler struct { + // Handler to wrap. + Handler http.Handler +} + +func (h *HTTPHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) { + ctx := contextWithTraceInfo(r.Context(), r.Header.Get(CloudTraceContextHeader)) + + h.Handler.ServeHTTP(w, r.WithContext(ctx)) +} diff --git a/docd/internal/cloudtrace/logger.go b/docd/internal/cloudtrace/logger.go new file mode 100644 index 0000000..5bd8016 --- /dev/null +++ b/docd/internal/cloudtrace/logger.go @@ -0,0 +1,72 @@ +package cloudtrace + +// Inspired by https://github.com/remko/cloudrun-slog + +import ( + "context" + "fmt" + "log/slog" + "os" +) + +// Extra log level supported by Cloud Logging +const LevelCritical = slog.Level(12) + +// Handler that outputs JSON understood by the structured log agent. +// See https://cloud.google.com/logging/docs/agent/logging/configuration#special-fields +type CloudLoggingHandler struct { + handler slog.Handler + projectID string +} + +var _ slog.Handler = (*CloudLoggingHandler)(nil) + +func NewCloudLoggingHandler(projectID string, level slog.Level) *CloudLoggingHandler { + return &CloudLoggingHandler{ + projectID: projectID, + handler: slog.NewJSONHandler(os.Stderr, &slog.HandlerOptions{ + AddSource: true, + Level: level, + ReplaceAttr: func(groups []string, a slog.Attr) slog.Attr { + if a.Key == slog.MessageKey { + a.Key = "message" + } else if a.Key == slog.SourceKey { + a.Key = "logging.googleapis.com/sourceLocation" + } else if a.Key == slog.LevelKey { + a.Key = "severity" + level := a.Value.Any().(slog.Level) + if level == LevelCritical { + a.Value = slog.StringValue("CRITICAL") + } + } + return a + }, + }), + } +} + +func (h *CloudLoggingHandler) Enabled(ctx context.Context, level slog.Level) bool { + return h.handler.Enabled(ctx, level) +} + +func (h *CloudLoggingHandler) Handle(ctx context.Context, rec slog.Record) error { + traceID, spanID := traceInfoFromContext(ctx) + if traceID != "" { + rec = rec.Clone() + // https://cloud.google.com/logging/docs/agent/logging/configuration#special-fields + trace := fmt.Sprintf("projects/%s/traces/%s", h.projectID, traceID) + rec.Add("logging.googleapis.com/trace", slog.StringValue(trace)) + if spanID != "" { + rec.Add("logging.googleapis.com/spanId", slog.StringValue(spanID)) + } + } + return h.handler.Handle(ctx, rec) +} + +func (h *CloudLoggingHandler) WithAttrs(attrs []slog.Attr) slog.Handler { + return &CloudLoggingHandler{handler: h.handler.WithAttrs(attrs)} +} + +func (h *CloudLoggingHandler) WithGroup(name string) slog.Handler { + return &CloudLoggingHandler{handler: h.handler.WithGroup(name)} +} diff --git a/docd/internal/debug/context.go b/docd/internal/debug/context.go new file mode 100644 index 0000000..f2896fd --- /dev/null +++ b/docd/internal/debug/context.go @@ -0,0 +1,15 @@ +package debug + +import ( + "context" +) + +type debugEnabledKey struct{} + +func debugEnabledInContext(ctx context.Context) bool { + enabled, ok := ctx.Value(debugEnabledKey{}).(bool) + if !ok { + return false + } + return enabled +} diff --git a/docd/internal/debug/http_handler.go b/docd/internal/debug/http_handler.go new file mode 100644 index 0000000..328832d --- /dev/null +++ b/docd/internal/debug/http_handler.go @@ -0,0 +1,22 @@ +package debug + +import ( + "context" + "net/http" + "strconv" +) + +type HTTPHandler struct { + // Handler to wrap. + Handler http.Handler +} + +func (h *HTTPHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) { + ctx := r.Context() + + if ok, _ := strconv.ParseBool(r.Header.Get(DebugHeader)); ok { + ctx = context.WithValue(ctx, debugEnabledKey{}, true) + } + + h.Handler.ServeHTTP(w, r.WithContext(ctx)) +} diff --git a/docd/internal/debug/logger.go b/docd/internal/debug/logger.go new file mode 100644 index 0000000..c651e23 --- /dev/null +++ b/docd/internal/debug/logger.go @@ -0,0 +1,33 @@ +package debug + +import ( + "context" + "log/slog" +) + +const DebugHeader = "X-Debug" + +type debugHandler struct { + slog.Handler +} + +func NewDebugHandler(h slog.Handler) *debugHandler { + return &debugHandler{Handler: h} +} + +var _ slog.Handler = (*debugHandler)(nil) + +func (h *debugHandler) Enabled(ctx context.Context, level slog.Level) bool { + if debugEnabledInContext(ctx) { + return true + } + return h.Handler.Enabled(ctx, level) +} + +func (h *debugHandler) WithAttrs(attrs []slog.Attr) slog.Handler { + return &debugHandler{Handler: h.Handler.WithAttrs(attrs)} +} + +func (h *debugHandler) WithGroup(name string) slog.Handler { + return &debugHandler{Handler: h.Handler.WithGroup(name)} +} diff --git a/docd/internal/error_reporter.go b/docd/internal/error_reporter.go new file mode 100644 index 0000000..a0de1a0 --- /dev/null +++ b/docd/internal/error_reporter.go @@ -0,0 +1,24 @@ +package internal + +import ( + "io" + + "cloud.google.com/go/errorreporting" +) + +// ErrorReporter reports errors. +type ErrorReporter interface { + Report(errorreporting.Entry) + io.Closer +} + +// NopErrorReporter is a no-op reporter. +type NopErrorReporter struct{} + +var _ ErrorReporter = (*NopErrorReporter)(nil) + +// Report implements ErrorReporter. +func (r *NopErrorReporter) Report(e errorreporting.Entry) {} + +// Close implements ErrorReporter. +func (r *NopErrorReporter) Close() error { return nil } diff --git a/docd/internal/recovery.go b/docd/internal/recovery.go new file mode 100644 index 0000000..2bf86d0 --- /dev/null +++ b/docd/internal/recovery.go @@ -0,0 +1,80 @@ +package internal + +import ( + "errors" + "fmt" + "log/slog" + "net/http" + "runtime/debug" + + "cloud.google.com/go/errorreporting" +) + +type recoveryHandler struct { + l *slog.Logger + er ErrorReporter + handler http.Handler +} + +// RecoveryHandler is HTTP middleware that recovers from a panic, writes a +// 500, reports the panic, logs the panic and continues to the next handler. +func RecoveryHandler(l *slog.Logger, er ErrorReporter) func(h http.Handler) http.Handler { + return func(h http.Handler) http.Handler { + return &recoveryHandler{l: l, er: er, handler: h} + } +} + +func (h recoveryHandler) ServeHTTP(w http.ResponseWriter, req *http.Request) { + defer func() { + if rec := recover(); rec != nil { + w.WriteHeader(http.StatusInternalServerError) + w.Write([]byte(`{"error":"internal server error"}`)) + h.handle(req, &recovered{rec, debug.Stack()}) + } + }() + + h.handler.ServeHTTP(w, req) +} + +func (h recoveryHandler) handle(r *http.Request, err error) { + stack, _ := stackFromRecovered(err) + + e := errorreporting.Entry{ + Error: err, + Stack: stack, + Req: r, + } + h.er.Report(e) + + h.l.ErrorContext(r.Context(), err.Error(), "error", err, "stack", string(stack)) +} + +// recovered represents the return value from a call to recover. +type recovered struct { + // p is the error value passed to the call of panic. + p interface{} + // stack is the panic stack trace. + stack []byte +} + +var _ error = (*recovered)(nil) + +// Error implements error. +func (e *recovered) Error() string { + if err, ok := e.p.(error); ok { + return err.Error() + } + return fmt.Sprintf("panic: %v", e.p) +} + +// stackFromRecovered returns a stack trace and true if the recovdered has a +// stack trace created by this package. +// +// Otherwise it returns nil and false. +func stackFromRecovered(err error) ([]byte, bool) { + var rec *recovered + if errors.As(err, &rec) { + return rec.stack, true + } + return nil, false +} diff --git a/docd/main.go b/docd/main.go index 6dd98ce..6fce2ab 100644 --- a/docd/main.go +++ b/docd/main.go @@ -1,20 +1,38 @@ package main import ( - "encoding/json" + "context" "flag" "fmt" - "log" + "log/slog" "net/http" "os" + "runtime" - "code.sajari.com/docconv" + "cloud.google.com/go/compute/metadata" + "cloud.google.com/go/errorreporting" + + "github.com/gorilla/mux" + + "code.sajari.com/docconv/v2" + "code.sajari.com/docconv/v2/docd/internal" + "code.sajari.com/docconv/v2/docd/internal/cloudtrace" + "code.sajari.com/docconv/v2/docd/internal/debug" ) var ( - inputPath = flag.String("input", "", "The file path to convert and exit; no server") - listenAddr = flag.String("addr", ":8888", "The address to listen on (e.g. 127.0.0.1:8888)") - logLevel = flag.Uint("log-level", 0, "The verbosity of the log") + listenAddr = flag.String("addr", ":8888", "The address to listen on (e.g. 127.0.0.1:8888)") + + inputPath = flag.String("input", "", "The file path to convert and exit; no server") + + jsonCloudLogging = flag.Bool("json-cloud-logging", false, "Whether or not to enable JSON Cloud Logging") + + cloudTraceGCPProjectID = flag.String("cloud-trace-gcp-project-id", "", "The GCP project to use for Cloud Trace") + + errorReporting = flag.Bool("error-reporting", false, "Whether or not to enable GCP Error Reporting") + errorReportingGCPProjectID = flag.String("error-reporting-gcp-project-id", "", "The GCP project to use for Error Reporting") + errorReportingAppEngineService = flag.String("error-reporting-app-engine-service", "", "The App Engine service to use for Error Reporting") + readabilityLengthLow = flag.Int("readability-length-low", 70, "Sets the readability length low") readabilityLengthHigh = flag.Int("readability-length-high", 200, "Sets the readability length high") readabilityStopwordsLow = flag.Float64("readability-stopwords-low", 0.2, "Sets the readability stopwords low") @@ -27,6 +45,54 @@ var ( func main() { flag.Parse() + l := slog.New(debug.NewDebugHandler(slog.Default().Handler())) + + if *jsonCloudLogging { + gcpProjectID := *cloudTraceGCPProjectID + if gcpProjectID == "" { + gcpProjectID = os.Getenv("GOOGLE_CLOUD_PROJECT") + } + if gcpProjectID == "" { + l.Debug("GOOGLE_CLOUD_PROJECT env var not provided, looking up internal metadata service") + var err error + gcpProjectID, err = metadata.ProjectID() + if err != nil { + l.Error("Could not autodetect GCP project ID", "error", err) + os.Exit(1) + } + } + + l = slog.New(debug.NewDebugHandler(cloudtrace.NewCloudLoggingHandler(gcpProjectID, slog.LevelInfo))) + slog.SetDefault(l) + l.Info("Cloud Trace GCP project ID", "projectID", gcpProjectID) + } + + var er internal.ErrorReporter = &internal.NopErrorReporter{} + if *errorReporting { + if *errorReportingGCPProjectID == "" { + *errorReportingGCPProjectID = os.Getenv("GOOGLE_CLOUD_PROJECT") + } + if *errorReportingAppEngineService == "" { + *errorReportingAppEngineService = os.Getenv("GAE_SERVICE") + } + var err error + er, err = errorreporting.NewClient(context.Background(), *errorReportingGCPProjectID, errorreporting.Config{ + ServiceName: *errorReportingAppEngineService, + OnError: func(err error) { + l.Error("Could not report error to Error Reporting service", "error", err) + }, + }) + if err != nil { + l.Error("Could not create Error Reporting client", "error", err) + os.Exit(1) + } + } + + cs := &convertServer{ + l: l, + er: er, + } + // TODO: Improve this (remove the need for it!) docconv.HTMLReadabilityOptionsValues = docconv.HTMLReadabilityOptions{ LengthLow: *readabilityLengthLow, @@ -41,106 +107,29 @@ func main() { if *inputPath != "" { resp, err := docconv.ConvertPath(*inputPath) if err != nil { - log.Printf("error converting file '%v': %v", *inputPath, err) + l.Error("Could not convert file", "error", err, "path", *inputPath) + os.Exit(1) } fmt.Print(string(resp.Body)) return } - serve() -} - -// Convert a file given a path -func convertPath(path string, readability bool) ([]byte, error) { - mimeType := docconv.MimeTypeByExtension(path) - if *logLevel >= 1 { - log.Println("Converting file: " + path + " (" + mimeType + ")") - } - // Open file - f, err := os.Open(path) - if err != nil { - return nil, err - } - defer f.Close() - - data, err := docconv.Convert(f, mimeType, readability) - if err != nil { - return nil, err - } - b, err := json.Marshal(data) - if err != nil { - return nil, err - } - if *logLevel >= 2 { - log.Println(string(b)) - } - return b, nil + serve(l, er, cs) } // Start the conversion web service -func serve() { - http.HandleFunc("/convert", func(w http.ResponseWriter, r *http.Request) { - // Readability flag. Currently only used for HTML - var readability bool - if r.FormValue("readability") == "1" { - readability = true - if *logLevel >= 2 { - log.Println("Readability is on") - } - } +func serve(l *slog.Logger, er internal.ErrorReporter, cs *convertServer) { + r := mux.NewRouter() + r.HandleFunc("/convert", cs.convert) - path := r.FormValue("path") - if path != "" { - b, err := docconv.ConvertPathReadability(path, readability) - if err != nil { - // TODO: return a sensible status code for errors like this. - log.Printf("error converting path '%v': %v", path, err) - return - } - w.Write(b) - return - } + h := internal.RecoveryHandler(l, er)(r) + h = &debug.HTTPHandler{Handler: h} + h = &cloudtrace.HTTPHandler{Handler: h} - // Get uploaded file - file, info, err := r.FormFile("input") - if err != nil { - log.Println("File upload", err) - return - } - defer file.Close() + l.Info("Go version " + runtime.Version()) - // Abort if file doesn't have a mime type - if len(info.Header["Content-Type"]) == 0 { - log.Println("No content type", info.Filename) - return - } - - // If a generic mime type was provided then use file extension to determine mimetype - mimeType := info.Header["Content-Type"][0] - if mimeType == "application/octet-stream" { - mimeType = docconv.MimeTypeByExtension(info.Filename) - } - - if *logLevel >= 1 { - log.Println("Received file: " + info.Filename + " (" + mimeType + ")") - } - - data, err := docconv.Convert(file, mimeType, readability) - if err != nil { - log.Printf("error converting data: %v", err) - data = &docconv.Response{ - Error: err.Error(), - } - } - - if err := json.NewEncoder(w).Encode(data); err != nil { - log.Printf("error marshaling JSON data: %v", err) - return - } - }) - - // Start webserver - log.Println("Setting log level to", *logLevel) - log.Println("Starting docconv on", *listenAddr) - log.Fatal(http.ListenAndServe(*listenAddr, nil)) + l.Info(fmt.Sprintf("HTTP server listening on %q...", *listenAddr)) + if err := http.ListenAndServe(*listenAddr, h); err != nil { + l.Error("HTTP server ListenAndServe", "error", err) + } } diff --git a/docx.go b/docx.go index 0b3c2e6..185e52d 100644 --- a/docx.go +++ b/docx.go @@ -6,7 +6,6 @@ import ( "encoding/xml" "fmt" "io" - "io/ioutil" "os" "time" ) @@ -40,7 +39,7 @@ func ConvertDocx(r io.Reader) (string, map[string]string, error) { size = si.Size() ra = f } else { - b, err := ioutil.ReadAll(r) + b, err := io.ReadAll(io.LimitReader(r, maxBytes)) if err != nil { return "", nil, nil } @@ -120,7 +119,7 @@ func getContentTypeDefinition(zf *zip.File) (*contentTypeDefinition, error) { defer f.Close() x := &contentTypeDefinition{} - if err := xml.NewDecoder(f).Decode(x); err != nil { + if err := xml.NewDecoder(io.LimitReader(f, maxBytes)).Decode(x); err != nil { return nil, err } return x, nil diff --git a/docx_test/docx_test.go b/docx_test/docx_test.go index f96a4f6..3b1aa50 100644 --- a/docx_test/docx_test.go +++ b/docx_test/docx_test.go @@ -1,11 +1,12 @@ package docx_test import ( + "encoding/xml" "os" "strings" "testing" - "code.sajari.com/docconv" + "code.sajari.com/docconv/v2" ) func TestConvertDocx(t *testing.T) { @@ -50,3 +51,18 @@ func TestConvertDocxWithUncommonValidStructure(t *testing.T) { t.Errorf("expected %v to contains %v", resp, want) } } + + +func TestConvertDocxDecompressionSizeLimit(t *testing.T) { + f, err := os.Open("./testdata/decompression_size_limit.docx") + if err != nil { + t.Fatalf("got error = %v, want nil", err) + } + _, _, err = docconv.ConvertDocx(f) + if _, ok := err.(*xml.SyntaxError); !ok { + t.Errorf("got error = %T, want *xml.SyntaxError", err) + } + if want := "EOF"; !strings.Contains(err.Error(), want) { + t.Errorf("got error = %v, want %v", err, want) + } +} diff --git a/docx_test/testdata/decompression_size_limit.docx b/docx_test/testdata/decompression_size_limit.docx new file mode 100755 index 0000000..4ea761f Binary files /dev/null and b/docx_test/testdata/decompression_size_limit.docx differ diff --git a/go.mod b/go.mod index 1ff6dcd..ea4b8b1 100644 --- a/go.mod +++ b/go.mod @@ -1,21 +1,46 @@ -module code.sajari.com/docconv +module code.sajari.com/docconv/v2 -go 1.14 +go 1.21 require ( + cloud.google.com/go/compute/metadata v0.2.3 + cloud.google.com/go/errorreporting v0.3.0 github.com/JalfResi/justext v0.0.0-20170829062021-c0282dea7198 - github.com/PuerkitoBio/goquery v1.5.1 // indirect github.com/advancedlogic/GoOse v0.0.0-20191112112754-e742535969c1 + github.com/google/go-cmp v0.5.9 + github.com/gorilla/mux v1.8.0 + github.com/otiai10/gosseract/v2 v2.2.4 + github.com/richardlehane/mscfb v1.0.3 + github.com/richardlehane/msoleps v1.0.4-0.20231124170528-c8ca5a164365 + golang.org/x/net v0.17.0 + google.golang.org/protobuf v1.30.0 +) + +require ( + cloud.google.com/go/compute v1.19.1 // indirect + github.com/PuerkitoBio/goquery v1.5.1 // indirect github.com/andybalholm/cascadia v1.2.0 // indirect github.com/araddon/dateparse v0.0.0-20200409225146-d820a6159ab1 // indirect + github.com/fatih/set v0.2.1 // indirect + github.com/gigawattio/window v0.0.0-20180317192513-0f5467e35573 // indirect github.com/go-resty/resty/v2 v2.3.0 // indirect - github.com/golang/protobuf v1.4.2 + github.com/golang/groupcache v0.0.0-20200121045136-8c9f03a8e57e // indirect + github.com/golang/protobuf v1.5.3 // indirect + github.com/googleapis/enterprise-certificate-proxy v0.2.3 // indirect + github.com/googleapis/gax-go/v2 v2.7.1 // indirect github.com/jaytaylor/html2text v0.0.0-20200412013138-3577fbdbcff7 // indirect github.com/levigross/exp-html v0.0.0-20120902181939-8df60c69a8f5 // indirect github.com/mattn/go-runewidth v0.0.9 // indirect github.com/olekukonko/tablewriter v0.0.4 // indirect - github.com/otiai10/gosseract/v2 v2.2.4 github.com/pkg/errors v0.9.1 // indirect - golang.org/x/net v0.0.0-20200602114024-627f9648deb9 - golang.org/x/text v0.3.2 // indirect + github.com/ssor/bom v0.0.0-20170718123548-6386211fdfcf // indirect + go.opencensus.io v0.24.0 // indirect + golang.org/x/oauth2 v0.7.0 // indirect + golang.org/x/sync v0.1.0 // indirect + golang.org/x/sys v0.13.0 // indirect + golang.org/x/text v0.13.0 // indirect + google.golang.org/api v0.114.0 // indirect + google.golang.org/appengine v1.6.7 // indirect + google.golang.org/genproto v0.0.0-20230410155749-daa745c078e1 // indirect + google.golang.org/grpc v1.56.3 // indirect ) diff --git a/go.sum b/go.sum index 3b1d3e6..77d5385 100644 --- a/go.sum +++ b/go.sum @@ -1,99 +1,201 @@ +cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= +cloud.google.com/go v0.110.0 h1:Zc8gqp3+a9/Eyph2KDmcGaPtbKRIoqq4YTlL4NMD0Ys= +cloud.google.com/go v0.110.0/go.mod h1:SJnCLqQ0FCFGSZMUNUf84MV3Aia54kn7pi8st7tMzaY= +cloud.google.com/go/compute v1.19.1 h1:am86mquDUgjGNWxiGn+5PGLbmgiWXlE/yNWpIpNvuXY= +cloud.google.com/go/compute v1.19.1/go.mod h1:6ylj3a05WF8leseCdIf77NK0g1ey+nj5IKd5/kvShxE= +cloud.google.com/go/compute/metadata v0.2.3 h1:mg4jlk7mCAj6xXp9UJ4fjI9VUI5rubuGBW5aJ7UnBMY= +cloud.google.com/go/compute/metadata v0.2.3/go.mod h1:VAV5nSsACxMJvgaAuX6Pk2AawlZn8kiOGuCv6gTkwuA= +cloud.google.com/go/errorreporting v0.3.0 h1:kj1XEWMu8P0qlLhm3FwcaFsUvXChV/OraZwA70trRR0= +cloud.google.com/go/errorreporting v0.3.0/go.mod h1:xsP2yaAp+OAW4OIm60An2bbLpqIhKXdWR/tawvl7QzU= +cloud.google.com/go/longrunning v0.4.1 h1:v+yFJOfKC3yZdY6ZUI933pIYdhyhV8S3NpWrXWmg7jM= +cloud.google.com/go/longrunning v0.4.1/go.mod h1:4iWDqhBZ70CvZ6BfETbvam3T8FMvLK+eFj0E6AaRQTo= +github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= github.com/JalfResi/justext v0.0.0-20170829062021-c0282dea7198 h1:8P+AjBhGByCuCX2zTkAf6UY+dj0JczX+t6cSdCSyvfw= github.com/JalfResi/justext v0.0.0-20170829062021-c0282dea7198/go.mod h1:0SURuH1rsE8aVWvutuMZghRNrNrYEUzibzJfhEYR8L0= -github.com/PuerkitoBio/goquery v1.4.1 h1:smcIRGdYm/w7JSbcdeLHEMzxmsBQvl8lhf0dSw2nzMI= github.com/PuerkitoBio/goquery v1.4.1/go.mod h1:T9ezsOHcCrDCgA8aF1Cqr3sSYbO/xgdy8/R/XiIMAhA= github.com/PuerkitoBio/goquery v1.5.1 h1:PSPBGne8NIUWw+/7vFBV+kG2J/5MOjbzc7154OaKCSE= github.com/PuerkitoBio/goquery v1.5.1/go.mod h1:GsLWisAFVj4WgDibEWF4pvYnkVQBpKBKeU+7zCJoLcc= github.com/advancedlogic/GoOse v0.0.0-20191112112754-e742535969c1 h1:d0Ct1dZwgwMO0Llf81Eu+Lyj6kwqXdqHP/WsSkEria0= github.com/advancedlogic/GoOse v0.0.0-20191112112754-e742535969c1/go.mod h1:f3HCSN1fBWjcpGtXyM119MJgeQl838v6so/PQOqvE1w= -github.com/andybalholm/cascadia v1.0.0 h1:hOCXnnZ5A+3eVDX8pvgl4kofXv2ELss0bKcqRySc45o= github.com/andybalholm/cascadia v1.0.0/go.mod h1:GsXiBklL0woXo1j/WYWtSYYC4ouU9PqHO0sqidkEA4Y= github.com/andybalholm/cascadia v1.1.0/go.mod h1:GsXiBklL0woXo1j/WYWtSYYC4ouU9PqHO0sqidkEA4Y= github.com/andybalholm/cascadia v1.2.0 h1:vuRCkM5Ozh/BfmsaTm26kbjm0mIOM3yS5Ek/F5h18aE= github.com/andybalholm/cascadia v1.2.0/go.mod h1:YCyR8vOZT9aZ1CHEd8ap0gMVm2aFgxBp0T0eFw1RUQY= -github.com/araddon/dateparse v0.0.0-20180729174819-cfd92a431d0e h1:s05JG2GwtJMHaPcXDpo4V35TFgyYZzNsmBlSkHPEbeg= github.com/araddon/dateparse v0.0.0-20180729174819-cfd92a431d0e/go.mod h1:SLqhdZcd+dF3TEVL2RMoob5bBP5R1P1qkox+HtCBgGI= github.com/araddon/dateparse v0.0.0-20200409225146-d820a6159ab1 h1:TEBmxO80TM04L8IuMWk77SGL1HomBmKTdzdJLLWznxI= github.com/araddon/dateparse v0.0.0-20200409225146-d820a6159ab1/go.mod h1:SLqhdZcd+dF3TEVL2RMoob5bBP5R1P1qkox+HtCBgGI= -github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8= +github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU= +github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw= +github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGXZJjfX53e64911xZQV5JYwmTeXPW+k8Sc= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= +github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= +github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= +github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1mIlRU8Am5FuJP05cCM98= +github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c= github.com/fatih/set v0.2.1 h1:nn2CaJyknWE/6txyUDGwysr3G5QC6xWB/PtVjPBbeaA= github.com/fatih/set v0.2.1/go.mod h1:+RKtMCH+favT2+3YecHGxcc0b4KyVWA1QWWJUs4E0CI= github.com/gigawattio/window v0.0.0-20180317192513-0f5467e35573 h1:u8AQ9bPa9oC+8/A/jlWouakhIvkFfuxgIIRjiy8av7I= github.com/gigawattio/window v0.0.0-20180317192513-0f5467e35573/go.mod h1:eBvb3i++NHDH4Ugo9qCvMw8t0mTSctaEa5blJbWcNxs= -github.com/go-resty/resty/v2 v2.0.0 h1:9Nq/U+V4xsoDnDa/iTrABDWUCuk3Ne92XFHPe6dKWUc= github.com/go-resty/resty/v2 v2.0.0/go.mod h1:dZGr0i9PLlaaTD4H/hoZIDjQ+r6xq8mgbRzHZf7f2J8= github.com/go-resty/resty/v2 v2.3.0 h1:JOOeAvjSlapTT92p8xiS19Zxev1neGikoHsXJeOq8So= github.com/go-resty/resty/v2 v2.3.0/go.mod h1:UpN9CgLZNsv4e9XG50UU8xdI0F43UQ4HmxLBDwaroHU= +github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q= +github.com/golang/groupcache v0.0.0-20200121045136-8c9f03a8e57e h1:1r7pUrabqp18hOBcwBwiTsbnFeTZHV9eER/QT5JVZxY= +github.com/golang/groupcache v0.0.0-20200121045136-8c9f03a8e57e/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= +github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A= +github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= +github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= +github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= github.com/golang/protobuf v1.4.0-rc.1/go.mod h1:ceaxUfeHdC40wWswd/P6IGgMaK3YpKi5j83Wpe3EHw8= github.com/golang/protobuf v1.4.0-rc.1.0.20200221234624-67d41d38c208/go.mod h1:xKAWHe0F5eneWXFV3EuXVDTCmh+JuBKY0li0aMyXATA= github.com/golang/protobuf v1.4.0-rc.2/go.mod h1:LlEzMj4AhA7rCAGe4KMBDvJI+AwstrUpVNzEA03Pprs= github.com/golang/protobuf v1.4.0-rc.4.0.20200313231945-b860323f09d0/go.mod h1:WU3c8KckQ9AFe+yFwt9sWVRKCVIyN9cPHBJSNnbL67w= github.com/golang/protobuf v1.4.0/go.mod h1:jodUvKwWbYaEsadDk5Fwe5c77LiNKVO9IDvqG2KuDX0= -github.com/golang/protobuf v1.4.2 h1:+Z5KGCizgyZCbGh1KZqA0fcLLkwbsjIzS4aV2v7wJX0= -github.com/golang/protobuf v1.4.2/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI= +github.com/golang/protobuf v1.4.1/go.mod h1:U8fpvMrcmy5pZrNK1lt4xCsGvpyWQ/VVv6QDs8UjoX8= +github.com/golang/protobuf v1.4.3/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI= +github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk= +github.com/golang/protobuf v1.5.3 h1:KhyjKVUg7Usr/dYsdSqoFveMYd5ko72D+zANwlG1mmg= +github.com/golang/protobuf v1.5.3/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= +github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M= github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= -github.com/google/go-cmp v0.4.0 h1:xsAVV57WRhGj6kEIi8ReJzQlHHqcBYCElAvkovg3B/4= github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= -github.com/jaytaylor/html2text v0.0.0-20180606194806-57d518f124b0 h1:xqgexXAGQgY3HAjNPSaCqn5Aahbo5TKsmhp8VRfr1iQ= +github.com/google/go-cmp v0.5.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/google/go-cmp v0.5.3/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38= +github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= +github.com/google/uuid v1.1.2/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= +github.com/googleapis/enterprise-certificate-proxy v0.2.3 h1:yk9/cqRKtT9wXZSsRH9aurXEpJX+U6FLtpYTdC3R06k= +github.com/googleapis/enterprise-certificate-proxy v0.2.3/go.mod h1:AwSRAtLfXpU5Nm3pW+v7rGDHp09LsPtGY9MduiEsR9k= +github.com/googleapis/gax-go/v2 v2.7.1 h1:gF4c0zjUP2H/s/hEGyLA3I0fA2ZWjzYiONAD6cvPr8A= +github.com/googleapis/gax-go/v2 v2.7.1/go.mod h1:4orTrqY6hXxxaUL4LHIPl6lGo8vAE38/qKbhSAKP6QI= +github.com/gorilla/mux v1.8.0 h1:i40aqfkR1h2SlN9hojwV5ZA91wcXFOvkdNIeFDP5koI= +github.com/gorilla/mux v1.8.0/go.mod h1:DVbg23sWSpFRCP0SfiEN6jmj59UnW/n46BH5rLB71So= github.com/jaytaylor/html2text v0.0.0-20180606194806-57d518f124b0/go.mod h1:CVKlgaMiht+LXvHG173ujK6JUhZXKb2u/BQtjPDIvyk= github.com/jaytaylor/html2text v0.0.0-20200412013138-3577fbdbcff7 h1:g0fAGBisHaEQ0TRq1iBvemFRf+8AEWEmBESSiWB3Vsc= github.com/jaytaylor/html2text v0.0.0-20200412013138-3577fbdbcff7/go.mod h1:CVKlgaMiht+LXvHG173ujK6JUhZXKb2u/BQtjPDIvyk= github.com/levigross/exp-html v0.0.0-20120902181939-8df60c69a8f5 h1:W7p+m/AECTL3s/YR5RpQ4hz5SjNeKzZBl1q36ws12s0= github.com/levigross/exp-html v0.0.0-20120902181939-8df60c69a8f5/go.mod h1:QMe2wuKJ0o7zIVE8AqiT8rd8epmm6WDIZ2wyuBqYPzM= -github.com/mattn/go-runewidth v0.0.3 h1:a+kO+98RDGEfo6asOGMmpodZq4FNtnGP54yps8BzLR4= github.com/mattn/go-runewidth v0.0.3/go.mod h1:LwmH8dsx7+W8Uxz3IHJYH5QSwggIsqBzpuz5H//U1FU= github.com/mattn/go-runewidth v0.0.7/go.mod h1:H031xJmbD/WCDINGzjvQ9THkh0rPKHF+m2gUSrubnMI= github.com/mattn/go-runewidth v0.0.9 h1:Lm995f3rfxdpd6TSmuVCHVb/QhupuXlYr8sCI/QdE+0= github.com/mattn/go-runewidth v0.0.9/go.mod h1:H031xJmbD/WCDINGzjvQ9THkh0rPKHF+m2gUSrubnMI= -github.com/olekukonko/tablewriter v0.0.0-20180506121414-d4647c9c7a84 h1:fiKJgB4JDUd43CApkmCeTSQlWjtTtABrU2qsgbuP0BI= github.com/olekukonko/tablewriter v0.0.0-20180506121414-d4647c9c7a84/go.mod h1:vsDQFd/mU46D+Z4whnwzcISnGGzXWMclvtLoiIKAKIo= github.com/olekukonko/tablewriter v0.0.4 h1:vHD/YYe1Wolo78koG299f7V/VAS08c6IpCLn+Ejf/w8= github.com/olekukonko/tablewriter v0.0.4/go.mod h1:zq6QwlOf5SlnkVbMSr5EoBv3636FWnp+qbPhuoO21uA= -github.com/otiai10/curr v0.0.0-20150429015615-9b4961190c95 h1:+OLn68pqasWca0z5ryit9KGfp3sUsW4Lqg32iRMJyzs= github.com/otiai10/curr v0.0.0-20150429015615-9b4961190c95/go.mod h1:9qAhocn7zKJG+0mI8eUu6xqkFDYS2kb2saOteoSB3cE= github.com/otiai10/gosseract/v2 v2.2.4 h1:h/PV+oJqke8q2Ccw9bjpMBWfd7N2vtGDCUcihZj3nRo= github.com/otiai10/gosseract/v2 v2.2.4/go.mod h1:ahOp/kHojnOMGv1RaUnR0jwY5JVa6BYKhYAS8nbMLSo= github.com/otiai10/mint v1.3.0 h1:Ady6MKVezQwHBkGzLFbrsywyp09Ah7rkmfjV3Bcr5uc= github.com/otiai10/mint v1.3.0/go.mod h1:F5AjcsTsWUqX+Na9fpHb52P8pcRX2CI6A3ctIT91xUo= -github.com/pkg/errors v0.8.1 h1:iURUrRGxPUNPdy5/HRSm+Yj6okJ6UtLINN0Q9M4+h3I= github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= 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/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= +github.com/richardlehane/mscfb v1.0.3 h1:rD8TBkYWkObWO0oLDFCbwMeZ4KoalxQy+QgniCj3nKI= +github.com/richardlehane/mscfb v1.0.3/go.mod h1:YzVpcZg9czvAuhk9T+a3avCpcFPMUWm7gK3DypaEsUk= +github.com/richardlehane/msoleps v1.0.1/go.mod h1:BWev5JBpU9Ko2WAgmZEuiz4/u3ZYTKbjLycmwiWUfWg= +github.com/richardlehane/msoleps v1.0.4-0.20231124170528-c8ca5a164365 h1:x5G1rZBYckUdhRTXyd8u0C1WT/oGWT99HFPYdOJ+Qyc= +github.com/richardlehane/msoleps v1.0.4-0.20231124170528-c8ca5a164365/go.mod h1:BWev5JBpU9Ko2WAgmZEuiz4/u3ZYTKbjLycmwiWUfWg= github.com/simplereach/timeutils v1.2.0/go.mod h1:VVbQDfN/FHRZa1LSqcwo4kNZ62OOyqLLGQKYB3pB0Q8= github.com/ssor/bom v0.0.0-20170718123548-6386211fdfcf h1:pvbZ0lM0XWPBqUKqFU8cmavspvIl9nulOYwdy6IFRRo= github.com/ssor/bom v0.0.0-20170718123548-6386211fdfcf/go.mod h1:RJID2RhlZKId02nZ62WenDCkgHFerpIOmW0iT7GKmXM= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= -github.com/stretchr/testify v1.4.0 h1:2E4SXV/wtOkTonXsotYi4li6zVWxYlZuYNCXe9XRJyk= +github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw= +github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo= github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= +github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= +github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= +github.com/stretchr/testify v1.8.1 h1:w7B6lhMri9wdJUVmEZPGGhZzrYTPvgJArz7wNPgYKsk= +github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= +go.opencensus.io v0.24.0 h1:y73uSU6J157QMP2kn2r30vwW1A2W2WFwSCGnAVxeaD0= +go.opencensus.io v0.24.0/go.mod h1:vNK8G9p7aAivkbmorf4v+7Hgx+Zs0yY+0fOtgBfjQKo= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= +golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= +golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= +golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= +golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU= +golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= golang.org/x/net v0.0.0-20180218175443-cbe0f9307d01/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20190213061140-3a22650c66bd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= +golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= +golang.org/x/net v0.0.0-20190603091049-60506f45cf65/go.mod h1:HSz+uSET+XFnRR8LxR5pz3Of3rY3CfYBVs4xY44aLks= golang.org/x/net v0.0.0-20190628185345-da137c7871d7/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20200202094626-16171245cfb2/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20200513185701-a91f0712d120/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= -golang.org/x/net v0.0.0-20200602114024-627f9648deb9 h1:pNX+40auqi2JqRfOP1akLGtYcn15TUbkhwuCO3foqqM= -golang.org/x/net v0.0.0-20200602114024-627f9648deb9/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= +golang.org/x/net v0.0.0-20201110031124-69a78807bb2b/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= +golang.org/x/net v0.17.0 h1:pVaXccu2ozPjCXewfr1S7xza/zcXTity9cCdXQYSjIM= +golang.org/x/net v0.17.0/go.mod h1:NxSsAGuq816PNPmqtQdLE42eU2Fs7NoRIZrHJAlaCOE= +golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= +golang.org/x/oauth2 v0.7.0 h1:qe6s0zUXlPX80/dITx3440hWZ7GwMwgDDyrSGTPJG/g= +golang.org/x/oauth2 v0.7.0/go.mod h1:hPLQkd9LyjfXTiRohC/41GhcFqxisoUQ99sCUOHO9x4= +golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.1.0 h1:wsuoTGHzEhffawBOhz5CYhcrV4IdKZbEyZjBMuTp12o= +golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/text v0.3.0 h1:g61tztE5qeGQ89tm6NTjjM9VPIm088od1l6aSorWRWg= +golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.13.0 h1:Af8nKPmuFypiUBjVoU9V20FiaFXOcuZI21p0ycVYYGE= +golang.org/x/sys v0.13.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= -golang.org/x/text v0.3.2 h1:tW2bmiBqwgJj/UpqtC8EpXEZVYOwU0yG4iWbprSVAcs= golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= +golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= +golang.org/x/text v0.13.0 h1:ablQoSUd0tRdKxZewP80B+BaqeKJuVhuRxj/dkrun3k= +golang.org/x/text v0.13.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= -golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543 h1:E7g+9GITq07hpfrRu66IVDexMakfv52eLZ2CXBWiKr4= +golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= +golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3HoIrodX9oNMXvdceNzlUR8zjMvY= +golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= +golang.org/x/tools v0.0.0-20190524140312-2c0ae7006135/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +google.golang.org/api v0.114.0 h1:1xQPji6cO2E2vLiI+C/XiFAnsn1WV3mjaEwGLhi3grE= +google.golang.org/api v0.114.0/go.mod h1:ifYI2ZsFK6/uGddGfAD5BMxlnkBqCmqHSDUVi45N5Yg= +google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM= +google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= +google.golang.org/appengine v1.6.7 h1:FZR1q0exgwxzPzp/aF+VccGrSfxfPpkBqjIIEq3ru6c= +google.golang.org/appengine v1.6.7/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc= +google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc= +google.golang.org/genproto v0.0.0-20190819201941-24fa4b261c55/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc= +google.golang.org/genproto v0.0.0-20200526211855-cb27e3aa2013/go.mod h1:NbSheEEYHJ7i3ixzK3sjbqSGDJWnxyFXZblF3eUsNvo= +google.golang.org/genproto v0.0.0-20230410155749-daa745c078e1 h1:KpwkzHKEF7B9Zxg18WzOa7djJ+Ha5DzthMyZYQfEn2A= +google.golang.org/genproto v0.0.0-20230410155749-daa745c078e1/go.mod h1:nKE/iIaLqn2bQwXBg8f1g2Ylh6r5MN5CmZvuzZCgsCU= +google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= +google.golang.org/grpc v1.23.0/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg= +google.golang.org/grpc v1.25.1/go.mod h1:c3i+UQWmh7LiEpx4sFZnkU36qjEYZ0imhYfXVyQciAY= +google.golang.org/grpc v1.27.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk= +google.golang.org/grpc v1.33.2/go.mod h1:JMHMWHQWaTccqQQlmk3MJZS+GWXOdAesneDmEnv2fbc= +google.golang.org/grpc v1.56.3 h1:8I4C0Yq1EjstUzUJzpcRVbuYA2mODtEmpWiQoN/b2nc= +google.golang.org/grpc v1.56.3/go.mod h1:I9bI3vqKfayGqPUAwGdOSu7kt6oIJLixfffKrpXqQ9s= google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8= google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0= google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM= google.golang.org/protobuf v1.20.1-0.20200309200217-e05f789c0967/go.mod h1:A+miEFZTKqfCUM6K7xSMQL9OKL/b6hQv+e19PK+JZNE= google.golang.org/protobuf v1.21.0/go.mod h1:47Nbq4nVaFHyn7ilMalzfO3qCViNmqZ2kzikPIcrTAo= -google.golang.org/protobuf v1.23.0 h1:4MY060fB1DLGMB/7MBTLnwQUY6+F09GEiz6SsrNqyzM= +google.golang.org/protobuf v1.22.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= google.golang.org/protobuf v1.23.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= -gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= +google.golang.org/protobuf v1.23.1-0.20200526195155-81db48ad09cc/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= +google.golang.org/protobuf v1.25.0/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlbajtzgsN7c= +google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= +google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= +google.golang.org/protobuf v1.30.0 h1:kPPoIgf3TsEvrm0PFe15JQ+570QVxYzEvvHqChK+cng= +google.golang.org/protobuf v1.30.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/mgo.v2 v2.0.0-20190816093944-a6b53ec6cb22/go.mod h1:yeKp02qBN3iKW1OzL3MGk2IdtZzaj7SFntXj72NppTA= -gopkg.in/yaml.v2 v2.2.2 h1:ZCJp+EgiOT7lHqUV2J862kp8Qj64Jo6az82+3Td9dZw= gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= +gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= +gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= +honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= +honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= diff --git a/html.go b/html.go index df4f26f..8fc4652 100644 --- a/html.go +++ b/html.go @@ -1,11 +1,10 @@ -// +build !appengine +//go:build !appengine package docconv import ( "bytes" "io" - "log" "strings" "golang.org/x/net/html" @@ -25,18 +24,23 @@ func ConvertHTML(r io.Reader, readability bool) (string, map[string]string, erro cleanXML, err := Tidy(buf, false) if err != nil { - log.Println("Tidy:", err) // Tidy failed, so we now manually tokenize instead clean := cleanHTML(buf, true) cleanXML = []byte(clean) - // TODO: remove this log - log.Println("Cleaned HTML using Golang tokenizer") } if readability { - cleanXML = HTMLReadability(bytes.NewReader(cleanXML)) + var err error + cleanXML, err = HTMLReadability(bytes.NewReader(cleanXML)) + if err != nil { + return "", nil, err + } + } + text, err := HTMLToText(bytes.NewReader(cleanXML)) + if err != nil { + return "", nil, err } - return HTMLToText(bytes.NewReader(cleanXML)), meta, nil + return text, meta, nil } var acceptedHTMLTags = [...]string{ @@ -127,7 +131,7 @@ type HTMLReadabilityOptions struct { var HTMLReadabilityOptionsValues HTMLReadabilityOptions // HTMLReadability extracts the readable text in an HTML document -func HTMLReadability(r io.Reader) []byte { +func HTMLReadability(r io.Reader) ([]byte, error) { jr := justext.NewReader(r) // TODO: Improve this! @@ -141,8 +145,7 @@ func HTMLReadability(r io.Reader) []byte { paragraphSet, err := jr.ReadAll() if err != nil { - log.Println("Justext:", err) - return nil + return nil, err } useClasses := strings.SplitN(HTMLReadabilityOptionsValues.ReadabilityUseClasses, ",", 10) @@ -156,13 +159,12 @@ func HTMLReadability(r io.Reader) []byte { } } - return []byte(output) + return []byte(output), nil } // HTMLToText converts HTML to plain text. -func HTMLToText(input io.Reader) string { - text, _ := XMLToText(input, []string{"br", "p", "h1", "h2", "h3", "h4"}, []string{}, false) - return text +func HTMLToText(input io.Reader) (string, error) { + return XMLToText(input, []string{"br", "p", "h1", "h2", "h3", "h4"}, []string{}, false) } var readabilityStopList = map[string]bool{"and": true, "the": true, "a": true, "about": true, "above": true, "across": true, "after": true, "afterwards": true, "again": true, "against": true, "all": true, "almost": true, "alone": true, diff --git a/html_appengine.go b/html_appengine.go index c6fb19a..47763a1 100644 --- a/html_appengine.go +++ b/html_appengine.go @@ -1,18 +1,11 @@ -// +build appengine +//go:build appengine package docconv import ( "io" - "io/ioutil" - "log" ) -func HTMLReadability(r io.Reader) []byte { - b, err := ioutil.ReadAll(r) - if err != nil { - log.Printf("HTMLReadability: %v", err) - return nil - } - return b +func HTMLReadability(r io.Reader) ([]byte, error) { + return io.ReadAll(r) } diff --git a/html_test/html_test.go b/html_test/html_test.go new file mode 100644 index 0000000..8b9801f --- /dev/null +++ b/html_test/html_test.go @@ -0,0 +1,60 @@ +package html_test + +import ( + "bytes" + "fmt" + "os" + "testing" + + "github.com/google/go-cmp/cmp" + + "code.sajari.com/docconv/v2" +) + +func TestConvertHTML_readabilityUseClasses(t *testing.T) { + tests := []struct { + readabilityUseClasses string + want string + }{ + // The default value set by this package. + { + readabilityUseClasses: "", + want: ``, + }, + // Enable output with readability true. + { + readabilityUseClasses: "good", + want: `1 +word +This is a full sentence. +`, + }, + } + + for _, tt := range tests { + t.Run(fmt.Sprintf("%q", tt.readabilityUseClasses), func(t *testing.T) { + old := docconv.HTMLReadabilityOptionsValues.ReadabilityUseClasses + t.Cleanup(func() { + docconv.HTMLReadabilityOptionsValues.ReadabilityUseClasses = old + }) + docconv.HTMLReadabilityOptionsValues.ReadabilityUseClasses = tt.readabilityUseClasses + + data, err := os.ReadFile("testdata/test.html") + must(t, err) + got, _, err := docconv.ConvertHTML(bytes.NewReader(data), true) + must(t, err) + + diff := cmp.Diff(tt.want, got) + if diff != "" { + t.Errorf("result mismatch (-want +got):\n%v", diff) + } + }) + } +} + +func must(t *testing.T, err error) { + t.Helper() + if err != nil { + t.Fatal(err) + } +} diff --git a/html_test/testdata/test.html b/html_test/testdata/test.html new file mode 100644 index 0000000..25fdf1b --- /dev/null +++ b/html_test/testdata/test.html @@ -0,0 +1,18 @@ + + + + + + + + + +

+1

+

word

+

This is a full sentence.

+ + diff --git a/iWork/TSPArchiveMessages.pb.go b/iWork/TSPArchiveMessages.pb.go index 170d81e..550d265 100644 --- a/iWork/TSPArchiveMessages.pb.go +++ b/iWork/TSPArchiveMessages.pb.go @@ -1,36 +1,24 @@ -// Code generated by protoc-gen-go. +// Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.27.1 +// protoc v4.24.4 // source: TSPArchiveMessages.proto -// DO NOT EDIT! - -/* -Package TSP is a generated protocol buffer package. - -It is generated from these files: - TSPArchiveMessages.proto - TSPDatabaseMessages.proto - TSPMessages.proto - -It has these top-level messages: - ArchiveInfo - MessageInfo - FieldInfo - FieldPath - ComponentInfo - ComponentExternalReference - ComponentDataReference - PackageMetadata - PasteboardMetadata - DataInfo - ViewStateMetadata -*/ -package TSP - -import proto "github.com/golang/protobuf/proto" -import math "math" - -// Reference imports to suppress errors if they are not otherwise used. -var _ = proto.Marshal -var _ = math.Inf + +package tsp + +import ( + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" + reflect "reflect" + sync "sync" +) + +const ( + // Verify that this generated code is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) + // Verify that runtime/protoimpl is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) +) type FieldInfo_Type int32 @@ -41,36 +29,59 @@ const ( FieldInfo_Message FieldInfo_Type = 3 ) -var FieldInfo_Type_name = map[int32]string{ - 0: "Value", - 1: "ObjectReference", - 2: "DataReference", - 3: "Message", -} -var FieldInfo_Type_value = map[string]int32{ - "Value": 0, - "ObjectReference": 1, - "DataReference": 2, - "Message": 3, -} +// Enum value maps for FieldInfo_Type. +var ( + FieldInfo_Type_name = map[int32]string{ + 0: "Value", + 1: "ObjectReference", + 2: "DataReference", + 3: "Message", + } + FieldInfo_Type_value = map[string]int32{ + "Value": 0, + "ObjectReference": 1, + "DataReference": 2, + "Message": 3, + } +) func (x FieldInfo_Type) Enum() *FieldInfo_Type { p := new(FieldInfo_Type) *p = x return p } + func (x FieldInfo_Type) String() string { - return proto.EnumName(FieldInfo_Type_name, int32(x)) + return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x)) +} + +func (FieldInfo_Type) Descriptor() protoreflect.EnumDescriptor { + return file_TSPArchiveMessages_proto_enumTypes[0].Descriptor() +} + +func (FieldInfo_Type) Type() protoreflect.EnumType { + return &file_TSPArchiveMessages_proto_enumTypes[0] } -func (x *FieldInfo_Type) UnmarshalJSON(data []byte) error { - value, err := proto.UnmarshalJSONEnum(FieldInfo_Type_value, data, "FieldInfo_Type") + +func (x FieldInfo_Type) Number() protoreflect.EnumNumber { + return protoreflect.EnumNumber(x) +} + +// Deprecated: Do not use. +func (x *FieldInfo_Type) UnmarshalJSON(b []byte) error { + num, err := protoimpl.X.UnmarshalJSONEnum(x.Descriptor(), b) if err != nil { return err } - *x = FieldInfo_Type(value) + *x = FieldInfo_Type(num) return nil } +// Deprecated: Use FieldInfo_Type.Descriptor instead. +func (FieldInfo_Type) EnumDescriptor() ([]byte, []int) { + return file_TSPArchiveMessages_proto_rawDescGZIP(), []int{2, 0} +} + type FieldInfo_Rule int32 const ( @@ -80,508 +91,1246 @@ const ( FieldInfo_NotSupported FieldInfo_Rule = -1 ) -var FieldInfo_Rule_name = map[int32]string{ - 0: "IgnoreAndDrop", - 1: "IgnoreAndPreserve", - 2: "MustUnderstand", - -1: "NotSupported", -} -var FieldInfo_Rule_value = map[string]int32{ - "IgnoreAndDrop": 0, - "IgnoreAndPreserve": 1, - "MustUnderstand": 2, - "NotSupported": -1, -} +// Enum value maps for FieldInfo_Rule. +var ( + FieldInfo_Rule_name = map[int32]string{ + 0: "IgnoreAndDrop", + 1: "IgnoreAndPreserve", + 2: "MustUnderstand", + -1: "NotSupported", + } + FieldInfo_Rule_value = map[string]int32{ + "IgnoreAndDrop": 0, + "IgnoreAndPreserve": 1, + "MustUnderstand": 2, + "NotSupported": -1, + } +) func (x FieldInfo_Rule) Enum() *FieldInfo_Rule { p := new(FieldInfo_Rule) *p = x return p } + func (x FieldInfo_Rule) String() string { - return proto.EnumName(FieldInfo_Rule_name, int32(x)) + return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x)) +} + +func (FieldInfo_Rule) Descriptor() protoreflect.EnumDescriptor { + return file_TSPArchiveMessages_proto_enumTypes[1].Descriptor() +} + +func (FieldInfo_Rule) Type() protoreflect.EnumType { + return &file_TSPArchiveMessages_proto_enumTypes[1] } -func (x *FieldInfo_Rule) UnmarshalJSON(data []byte) error { - value, err := proto.UnmarshalJSONEnum(FieldInfo_Rule_value, data, "FieldInfo_Rule") + +func (x FieldInfo_Rule) Number() protoreflect.EnumNumber { + return protoreflect.EnumNumber(x) +} + +// Deprecated: Do not use. +func (x *FieldInfo_Rule) UnmarshalJSON(b []byte) error { + num, err := protoimpl.X.UnmarshalJSONEnum(x.Descriptor(), b) if err != nil { return err } - *x = FieldInfo_Rule(value) + *x = FieldInfo_Rule(num) return nil } +// Deprecated: Use FieldInfo_Rule.Descriptor instead. +func (FieldInfo_Rule) EnumDescriptor() ([]byte, []int) { + return file_TSPArchiveMessages_proto_rawDescGZIP(), []int{2, 1} +} + type ArchiveInfo struct { - Identifier *uint64 `protobuf:"varint,1,opt,name=identifier" json:"identifier,omitempty"` - MessageInfos []*MessageInfo `protobuf:"bytes,2,rep,name=message_infos" json:"message_infos,omitempty"` - XXX_unrecognized []byte `json:"-"` + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Identifier *uint64 `protobuf:"varint,1,opt,name=identifier" json:"identifier,omitempty"` + MessageInfos []*MessageInfo `protobuf:"bytes,2,rep,name=message_infos,json=messageInfos" json:"message_infos,omitempty"` +} + +func (x *ArchiveInfo) Reset() { + *x = ArchiveInfo{} + if protoimpl.UnsafeEnabled { + mi := &file_TSPArchiveMessages_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *ArchiveInfo) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ArchiveInfo) ProtoMessage() {} + +func (x *ArchiveInfo) ProtoReflect() protoreflect.Message { + mi := &file_TSPArchiveMessages_proto_msgTypes[0] + 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) } -func (m *ArchiveInfo) Reset() { *m = ArchiveInfo{} } -func (m *ArchiveInfo) String() string { return proto.CompactTextString(m) } -func (*ArchiveInfo) ProtoMessage() {} +// Deprecated: Use ArchiveInfo.ProtoReflect.Descriptor instead. +func (*ArchiveInfo) Descriptor() ([]byte, []int) { + return file_TSPArchiveMessages_proto_rawDescGZIP(), []int{0} +} -func (m *ArchiveInfo) GetIdentifier() uint64 { - if m != nil && m.Identifier != nil { - return *m.Identifier +func (x *ArchiveInfo) GetIdentifier() uint64 { + if x != nil && x.Identifier != nil { + return *x.Identifier } return 0 } -func (m *ArchiveInfo) GetMessageInfos() []*MessageInfo { - if m != nil { - return m.MessageInfos +func (x *ArchiveInfo) GetMessageInfos() []*MessageInfo { + if x != nil { + return x.MessageInfos } return nil } type MessageInfo struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + Type *uint32 `protobuf:"varint,1,req,name=type" json:"type,omitempty"` Version []uint32 `protobuf:"varint,2,rep,packed,name=version" json:"version,omitempty"` Length *uint32 `protobuf:"varint,3,req,name=length" json:"length,omitempty"` - FieldInfos []*FieldInfo `protobuf:"bytes,4,rep,name=field_infos" json:"field_infos,omitempty"` - ObjectReferences []uint64 `protobuf:"varint,5,rep,packed,name=object_references" json:"object_references,omitempty"` - DataReferences []uint64 `protobuf:"varint,6,rep,packed,name=data_references" json:"data_references,omitempty"` - XXX_unrecognized []byte `json:"-"` + FieldInfos []*FieldInfo `protobuf:"bytes,4,rep,name=field_infos,json=fieldInfos" json:"field_infos,omitempty"` + ObjectReferences []uint64 `protobuf:"varint,5,rep,packed,name=object_references,json=objectReferences" json:"object_references,omitempty"` + DataReferences []uint64 `protobuf:"varint,6,rep,packed,name=data_references,json=dataReferences" json:"data_references,omitempty"` } -func (m *MessageInfo) Reset() { *m = MessageInfo{} } -func (m *MessageInfo) String() string { return proto.CompactTextString(m) } -func (*MessageInfo) ProtoMessage() {} +func (x *MessageInfo) Reset() { + *x = MessageInfo{} + if protoimpl.UnsafeEnabled { + mi := &file_TSPArchiveMessages_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *MessageInfo) String() string { + return protoimpl.X.MessageStringOf(x) +} -func (m *MessageInfo) GetType() uint32 { - if m != nil && m.Type != nil { - return *m.Type +func (*MessageInfo) ProtoMessage() {} + +func (x *MessageInfo) ProtoReflect() protoreflect.Message { + mi := &file_TSPArchiveMessages_proto_msgTypes[1] + 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 MessageInfo.ProtoReflect.Descriptor instead. +func (*MessageInfo) Descriptor() ([]byte, []int) { + return file_TSPArchiveMessages_proto_rawDescGZIP(), []int{1} +} + +func (x *MessageInfo) GetType() uint32 { + if x != nil && x.Type != nil { + return *x.Type } return 0 } -func (m *MessageInfo) GetVersion() []uint32 { - if m != nil { - return m.Version +func (x *MessageInfo) GetVersion() []uint32 { + if x != nil { + return x.Version } return nil } -func (m *MessageInfo) GetLength() uint32 { - if m != nil && m.Length != nil { - return *m.Length +func (x *MessageInfo) GetLength() uint32 { + if x != nil && x.Length != nil { + return *x.Length } return 0 } -func (m *MessageInfo) GetFieldInfos() []*FieldInfo { - if m != nil { - return m.FieldInfos +func (x *MessageInfo) GetFieldInfos() []*FieldInfo { + if x != nil { + return x.FieldInfos } return nil } -func (m *MessageInfo) GetObjectReferences() []uint64 { - if m != nil { - return m.ObjectReferences +func (x *MessageInfo) GetObjectReferences() []uint64 { + if x != nil { + return x.ObjectReferences } return nil } -func (m *MessageInfo) GetDataReferences() []uint64 { - if m != nil { - return m.DataReferences +func (x *MessageInfo) GetDataReferences() []uint64 { + if x != nil { + return x.DataReferences } return nil } type FieldInfo struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + Path *FieldPath `protobuf:"bytes,1,req,name=path" json:"path,omitempty"` Type *FieldInfo_Type `protobuf:"varint,2,opt,name=type,enum=TSP.FieldInfo_Type,def=0" json:"type,omitempty"` Rule *FieldInfo_Rule `protobuf:"varint,3,opt,name=rule,enum=TSP.FieldInfo_Rule,def=0" json:"rule,omitempty"` - ObjectReferences []uint64 `protobuf:"varint,4,rep,packed,name=object_references" json:"object_references,omitempty"` - DataReferences []uint64 `protobuf:"varint,5,rep,packed,name=data_references" json:"data_references,omitempty"` - XXX_unrecognized []byte `json:"-"` + ObjectReferences []uint64 `protobuf:"varint,4,rep,packed,name=object_references,json=objectReferences" json:"object_references,omitempty"` + DataReferences []uint64 `protobuf:"varint,5,rep,packed,name=data_references,json=dataReferences" json:"data_references,omitempty"` } -func (m *FieldInfo) Reset() { *m = FieldInfo{} } -func (m *FieldInfo) String() string { return proto.CompactTextString(m) } -func (*FieldInfo) ProtoMessage() {} +// Default values for FieldInfo fields. +const ( + Default_FieldInfo_Type = FieldInfo_Value + Default_FieldInfo_Rule = FieldInfo_IgnoreAndDrop +) -const Default_FieldInfo_Type FieldInfo_Type = FieldInfo_Value -const Default_FieldInfo_Rule FieldInfo_Rule = FieldInfo_IgnoreAndDrop +func (x *FieldInfo) Reset() { + *x = FieldInfo{} + if protoimpl.UnsafeEnabled { + mi := &file_TSPArchiveMessages_proto_msgTypes[2] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *FieldInfo) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*FieldInfo) ProtoMessage() {} + +func (x *FieldInfo) ProtoReflect() protoreflect.Message { + mi := &file_TSPArchiveMessages_proto_msgTypes[2] + 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) +} -func (m *FieldInfo) GetPath() *FieldPath { - if m != nil { - return m.Path +// Deprecated: Use FieldInfo.ProtoReflect.Descriptor instead. +func (*FieldInfo) Descriptor() ([]byte, []int) { + return file_TSPArchiveMessages_proto_rawDescGZIP(), []int{2} +} + +func (x *FieldInfo) GetPath() *FieldPath { + if x != nil { + return x.Path } return nil } -func (m *FieldInfo) GetType() FieldInfo_Type { - if m != nil && m.Type != nil { - return *m.Type +func (x *FieldInfo) GetType() FieldInfo_Type { + if x != nil && x.Type != nil { + return *x.Type } return Default_FieldInfo_Type } -func (m *FieldInfo) GetRule() FieldInfo_Rule { - if m != nil && m.Rule != nil { - return *m.Rule +func (x *FieldInfo) GetRule() FieldInfo_Rule { + if x != nil && x.Rule != nil { + return *x.Rule } return Default_FieldInfo_Rule } -func (m *FieldInfo) GetObjectReferences() []uint64 { - if m != nil { - return m.ObjectReferences +func (x *FieldInfo) GetObjectReferences() []uint64 { + if x != nil { + return x.ObjectReferences } return nil } -func (m *FieldInfo) GetDataReferences() []uint64 { - if m != nil { - return m.DataReferences +func (x *FieldInfo) GetDataReferences() []uint64 { + if x != nil { + return x.DataReferences } return nil } type FieldPath struct { - Path []uint32 `protobuf:"varint,1,rep,packed,name=path" json:"path,omitempty"` - XXX_unrecognized []byte `json:"-"` + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Path []uint32 `protobuf:"varint,1,rep,packed,name=path" json:"path,omitempty"` } -func (m *FieldPath) Reset() { *m = FieldPath{} } -func (m *FieldPath) String() string { return proto.CompactTextString(m) } -func (*FieldPath) ProtoMessage() {} +func (x *FieldPath) Reset() { + *x = FieldPath{} + if protoimpl.UnsafeEnabled { + mi := &file_TSPArchiveMessages_proto_msgTypes[3] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *FieldPath) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*FieldPath) ProtoMessage() {} + +func (x *FieldPath) ProtoReflect() protoreflect.Message { + mi := &file_TSPArchiveMessages_proto_msgTypes[3] + 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 FieldPath.ProtoReflect.Descriptor instead. +func (*FieldPath) Descriptor() ([]byte, []int) { + return file_TSPArchiveMessages_proto_rawDescGZIP(), []int{3} +} -func (m *FieldPath) GetPath() []uint32 { - if m != nil { - return m.Path +func (x *FieldPath) GetPath() []uint32 { + if x != nil { + return x.Path } return nil } type ComponentInfo struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + Identifier *uint64 `protobuf:"varint,1,req,name=identifier" json:"identifier,omitempty"` - PreferredLocator *string `protobuf:"bytes,2,req,name=preferred_locator" json:"preferred_locator,omitempty"` + PreferredLocator *string `protobuf:"bytes,2,req,name=preferred_locator,json=preferredLocator" json:"preferred_locator,omitempty"` Locator *string `protobuf:"bytes,3,opt,name=locator" json:"locator,omitempty"` - ReadVersion []uint32 `protobuf:"varint,4,rep,packed,name=read_version" json:"read_version,omitempty"` - WriteVersion []uint32 `protobuf:"varint,5,rep,packed,name=write_version" json:"write_version,omitempty"` - ExternalReferences []*ComponentExternalReference `protobuf:"bytes,6,rep,name=external_references" json:"external_references,omitempty"` - DataReferences []*ComponentDataReference `protobuf:"bytes,7,rep,name=data_references" json:"data_references,omitempty"` - AllowsDuplicatesOutsideOfDocumentPackage *bool `protobuf:"varint,8,opt,name=allows_duplicates_outside_of_document_package,def=0" json:"allows_duplicates_outside_of_document_package,omitempty"` - DirtiesDocumentPackage *bool `protobuf:"varint,9,opt,name=dirties_document_package,def=1" json:"dirties_document_package,omitempty"` - IsStoredOutsideObjectArchive *bool `protobuf:"varint,10,opt,name=is_stored_outside_object_archive,def=0" json:"is_stored_outside_object_archive,omitempty"` - XXX_unrecognized []byte `json:"-"` + ReadVersion []uint32 `protobuf:"varint,4,rep,packed,name=read_version,json=readVersion" json:"read_version,omitempty"` + WriteVersion []uint32 `protobuf:"varint,5,rep,packed,name=write_version,json=writeVersion" json:"write_version,omitempty"` + ExternalReferences []*ComponentExternalReference `protobuf:"bytes,6,rep,name=external_references,json=externalReferences" json:"external_references,omitempty"` + DataReferences []*ComponentDataReference `protobuf:"bytes,7,rep,name=data_references,json=dataReferences" json:"data_references,omitempty"` + AllowsDuplicatesOutsideOfDocumentPackage *bool `protobuf:"varint,8,opt,name=allows_duplicates_outside_of_document_package,json=allowsDuplicatesOutsideOfDocumentPackage,def=0" json:"allows_duplicates_outside_of_document_package,omitempty"` + DirtiesDocumentPackage *bool `protobuf:"varint,9,opt,name=dirties_document_package,json=dirtiesDocumentPackage,def=1" json:"dirties_document_package,omitempty"` + IsStoredOutsideObjectArchive *bool `protobuf:"varint,10,opt,name=is_stored_outside_object_archive,json=isStoredOutsideObjectArchive,def=0" json:"is_stored_outside_object_archive,omitempty"` } -func (m *ComponentInfo) Reset() { *m = ComponentInfo{} } -func (m *ComponentInfo) String() string { return proto.CompactTextString(m) } -func (*ComponentInfo) ProtoMessage() {} +// Default values for ComponentInfo fields. +const ( + Default_ComponentInfo_AllowsDuplicatesOutsideOfDocumentPackage = bool(false) + Default_ComponentInfo_DirtiesDocumentPackage = bool(true) + Default_ComponentInfo_IsStoredOutsideObjectArchive = bool(false) +) -const Default_ComponentInfo_AllowsDuplicatesOutsideOfDocumentPackage bool = false -const Default_ComponentInfo_DirtiesDocumentPackage bool = true -const Default_ComponentInfo_IsStoredOutsideObjectArchive bool = false +func (x *ComponentInfo) Reset() { + *x = ComponentInfo{} + if protoimpl.UnsafeEnabled { + mi := &file_TSPArchiveMessages_proto_msgTypes[4] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} -func (m *ComponentInfo) GetIdentifier() uint64 { - if m != nil && m.Identifier != nil { - return *m.Identifier +func (x *ComponentInfo) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ComponentInfo) ProtoMessage() {} + +func (x *ComponentInfo) ProtoReflect() protoreflect.Message { + mi := &file_TSPArchiveMessages_proto_msgTypes[4] + 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 ComponentInfo.ProtoReflect.Descriptor instead. +func (*ComponentInfo) Descriptor() ([]byte, []int) { + return file_TSPArchiveMessages_proto_rawDescGZIP(), []int{4} +} + +func (x *ComponentInfo) GetIdentifier() uint64 { + if x != nil && x.Identifier != nil { + return *x.Identifier } return 0 } -func (m *ComponentInfo) GetPreferredLocator() string { - if m != nil && m.PreferredLocator != nil { - return *m.PreferredLocator +func (x *ComponentInfo) GetPreferredLocator() string { + if x != nil && x.PreferredLocator != nil { + return *x.PreferredLocator } return "" } -func (m *ComponentInfo) GetLocator() string { - if m != nil && m.Locator != nil { - return *m.Locator +func (x *ComponentInfo) GetLocator() string { + if x != nil && x.Locator != nil { + return *x.Locator } return "" } -func (m *ComponentInfo) GetReadVersion() []uint32 { - if m != nil { - return m.ReadVersion +func (x *ComponentInfo) GetReadVersion() []uint32 { + if x != nil { + return x.ReadVersion } return nil } -func (m *ComponentInfo) GetWriteVersion() []uint32 { - if m != nil { - return m.WriteVersion +func (x *ComponentInfo) GetWriteVersion() []uint32 { + if x != nil { + return x.WriteVersion } return nil } -func (m *ComponentInfo) GetExternalReferences() []*ComponentExternalReference { - if m != nil { - return m.ExternalReferences +func (x *ComponentInfo) GetExternalReferences() []*ComponentExternalReference { + if x != nil { + return x.ExternalReferences } return nil } -func (m *ComponentInfo) GetDataReferences() []*ComponentDataReference { - if m != nil { - return m.DataReferences +func (x *ComponentInfo) GetDataReferences() []*ComponentDataReference { + if x != nil { + return x.DataReferences } return nil } -func (m *ComponentInfo) GetAllowsDuplicatesOutsideOfDocumentPackage() bool { - if m != nil && m.AllowsDuplicatesOutsideOfDocumentPackage != nil { - return *m.AllowsDuplicatesOutsideOfDocumentPackage +func (x *ComponentInfo) GetAllowsDuplicatesOutsideOfDocumentPackage() bool { + if x != nil && x.AllowsDuplicatesOutsideOfDocumentPackage != nil { + return *x.AllowsDuplicatesOutsideOfDocumentPackage } return Default_ComponentInfo_AllowsDuplicatesOutsideOfDocumentPackage } -func (m *ComponentInfo) GetDirtiesDocumentPackage() bool { - if m != nil && m.DirtiesDocumentPackage != nil { - return *m.DirtiesDocumentPackage +func (x *ComponentInfo) GetDirtiesDocumentPackage() bool { + if x != nil && x.DirtiesDocumentPackage != nil { + return *x.DirtiesDocumentPackage } return Default_ComponentInfo_DirtiesDocumentPackage } -func (m *ComponentInfo) GetIsStoredOutsideObjectArchive() bool { - if m != nil && m.IsStoredOutsideObjectArchive != nil { - return *m.IsStoredOutsideObjectArchive +func (x *ComponentInfo) GetIsStoredOutsideObjectArchive() bool { + if x != nil && x.IsStoredOutsideObjectArchive != nil { + return *x.IsStoredOutsideObjectArchive } return Default_ComponentInfo_IsStoredOutsideObjectArchive } type ComponentExternalReference struct { - ComponentIdentifier *uint64 `protobuf:"varint,1,req,name=component_identifier" json:"component_identifier,omitempty"` - ObjectIdentifier *uint64 `protobuf:"varint,2,opt,name=object_identifier" json:"object_identifier,omitempty"` - IsWeak *bool `protobuf:"varint,3,opt,name=is_weak" json:"is_weak,omitempty"` - XXX_unrecognized []byte `json:"-"` + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + ComponentIdentifier *uint64 `protobuf:"varint,1,req,name=component_identifier,json=componentIdentifier" json:"component_identifier,omitempty"` + ObjectIdentifier *uint64 `protobuf:"varint,2,opt,name=object_identifier,json=objectIdentifier" json:"object_identifier,omitempty"` + IsWeak *bool `protobuf:"varint,3,opt,name=is_weak,json=isWeak" json:"is_weak,omitempty"` +} + +func (x *ComponentExternalReference) Reset() { + *x = ComponentExternalReference{} + if protoimpl.UnsafeEnabled { + mi := &file_TSPArchiveMessages_proto_msgTypes[5] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *ComponentExternalReference) String() string { + return protoimpl.X.MessageStringOf(x) } -func (m *ComponentExternalReference) Reset() { *m = ComponentExternalReference{} } -func (m *ComponentExternalReference) String() string { return proto.CompactTextString(m) } -func (*ComponentExternalReference) ProtoMessage() {} +func (*ComponentExternalReference) ProtoMessage() {} -func (m *ComponentExternalReference) GetComponentIdentifier() uint64 { - if m != nil && m.ComponentIdentifier != nil { - return *m.ComponentIdentifier +func (x *ComponentExternalReference) ProtoReflect() protoreflect.Message { + mi := &file_TSPArchiveMessages_proto_msgTypes[5] + 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 ComponentExternalReference.ProtoReflect.Descriptor instead. +func (*ComponentExternalReference) Descriptor() ([]byte, []int) { + return file_TSPArchiveMessages_proto_rawDescGZIP(), []int{5} +} + +func (x *ComponentExternalReference) GetComponentIdentifier() uint64 { + if x != nil && x.ComponentIdentifier != nil { + return *x.ComponentIdentifier } return 0 } -func (m *ComponentExternalReference) GetObjectIdentifier() uint64 { - if m != nil && m.ObjectIdentifier != nil { - return *m.ObjectIdentifier +func (x *ComponentExternalReference) GetObjectIdentifier() uint64 { + if x != nil && x.ObjectIdentifier != nil { + return *x.ObjectIdentifier } return 0 } -func (m *ComponentExternalReference) GetIsWeak() bool { - if m != nil && m.IsWeak != nil { - return *m.IsWeak +func (x *ComponentExternalReference) GetIsWeak() bool { + if x != nil && x.IsWeak != nil { + return *x.IsWeak } return false } type ComponentDataReference struct { - DataIdentifier *uint64 `protobuf:"varint,1,req,name=data_identifier" json:"data_identifier,omitempty"` - XXX_unrecognized []byte `json:"-"` + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + DataIdentifier *uint64 `protobuf:"varint,1,req,name=data_identifier,json=dataIdentifier" json:"data_identifier,omitempty"` +} + +func (x *ComponentDataReference) Reset() { + *x = ComponentDataReference{} + if protoimpl.UnsafeEnabled { + mi := &file_TSPArchiveMessages_proto_msgTypes[6] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *ComponentDataReference) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ComponentDataReference) ProtoMessage() {} + +func (x *ComponentDataReference) ProtoReflect() protoreflect.Message { + mi := &file_TSPArchiveMessages_proto_msgTypes[6] + 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) } -func (m *ComponentDataReference) Reset() { *m = ComponentDataReference{} } -func (m *ComponentDataReference) String() string { return proto.CompactTextString(m) } -func (*ComponentDataReference) ProtoMessage() {} +// Deprecated: Use ComponentDataReference.ProtoReflect.Descriptor instead. +func (*ComponentDataReference) Descriptor() ([]byte, []int) { + return file_TSPArchiveMessages_proto_rawDescGZIP(), []int{6} +} -func (m *ComponentDataReference) GetDataIdentifier() uint64 { - if m != nil && m.DataIdentifier != nil { - return *m.DataIdentifier +func (x *ComponentDataReference) GetDataIdentifier() uint64 { + if x != nil && x.DataIdentifier != nil { + return *x.DataIdentifier } return 0 } type PackageMetadata struct { - LastObjectIdentifier *uint64 `protobuf:"varint,1,req,name=last_object_identifier" json:"last_object_identifier,omitempty"` + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + LastObjectIdentifier *uint64 `protobuf:"varint,1,req,name=last_object_identifier,json=lastObjectIdentifier" json:"last_object_identifier,omitempty"` Components []*ComponentInfo `protobuf:"bytes,3,rep,name=components" json:"components,omitempty"` Datas []*DataInfo `protobuf:"bytes,4,rep,name=datas" json:"datas,omitempty"` - ReadVersion []uint32 `protobuf:"varint,5,rep,packed,name=read_version" json:"read_version,omitempty"` - WriteVersion []uint32 `protobuf:"varint,6,rep,packed,name=write_version" json:"write_version,omitempty"` - XXX_unrecognized []byte `json:"-"` + ReadVersion []uint32 `protobuf:"varint,5,rep,packed,name=read_version,json=readVersion" json:"read_version,omitempty"` + WriteVersion []uint32 `protobuf:"varint,6,rep,packed,name=write_version,json=writeVersion" json:"write_version,omitempty"` +} + +func (x *PackageMetadata) Reset() { + *x = PackageMetadata{} + if protoimpl.UnsafeEnabled { + mi := &file_TSPArchiveMessages_proto_msgTypes[7] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *PackageMetadata) String() string { + return protoimpl.X.MessageStringOf(x) } -func (m *PackageMetadata) Reset() { *m = PackageMetadata{} } -func (m *PackageMetadata) String() string { return proto.CompactTextString(m) } -func (*PackageMetadata) ProtoMessage() {} +func (*PackageMetadata) ProtoMessage() {} -func (m *PackageMetadata) GetLastObjectIdentifier() uint64 { - if m != nil && m.LastObjectIdentifier != nil { - return *m.LastObjectIdentifier +func (x *PackageMetadata) ProtoReflect() protoreflect.Message { + mi := &file_TSPArchiveMessages_proto_msgTypes[7] + 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 PackageMetadata.ProtoReflect.Descriptor instead. +func (*PackageMetadata) Descriptor() ([]byte, []int) { + return file_TSPArchiveMessages_proto_rawDescGZIP(), []int{7} +} + +func (x *PackageMetadata) GetLastObjectIdentifier() uint64 { + if x != nil && x.LastObjectIdentifier != nil { + return *x.LastObjectIdentifier } return 0 } -func (m *PackageMetadata) GetComponents() []*ComponentInfo { - if m != nil { - return m.Components +func (x *PackageMetadata) GetComponents() []*ComponentInfo { + if x != nil { + return x.Components } return nil } -func (m *PackageMetadata) GetDatas() []*DataInfo { - if m != nil { - return m.Datas +func (x *PackageMetadata) GetDatas() []*DataInfo { + if x != nil { + return x.Datas } return nil } -func (m *PackageMetadata) GetReadVersion() []uint32 { - if m != nil { - return m.ReadVersion +func (x *PackageMetadata) GetReadVersion() []uint32 { + if x != nil { + return x.ReadVersion } return nil } -func (m *PackageMetadata) GetWriteVersion() []uint32 { - if m != nil { - return m.WriteVersion +func (x *PackageMetadata) GetWriteVersion() []uint32 { + if x != nil { + return x.WriteVersion } return nil } type PasteboardMetadata struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + Version []uint32 `protobuf:"varint,1,rep,packed,name=version" json:"version,omitempty"` - AppName *string `protobuf:"bytes,2,req,name=app_name" json:"app_name,omitempty"` + AppName *string `protobuf:"bytes,2,req,name=app_name,json=appName" json:"app_name,omitempty"` Datas []*DataInfo `protobuf:"bytes,3,rep,name=datas" json:"datas,omitempty"` - SourceDocumentUuid *string `protobuf:"bytes,4,opt,name=source_document_uuid" json:"source_document_uuid,omitempty"` - XXX_unrecognized []byte `json:"-"` + SourceDocumentUuid *string `protobuf:"bytes,4,opt,name=source_document_uuid,json=sourceDocumentUuid" json:"source_document_uuid,omitempty"` +} + +func (x *PasteboardMetadata) Reset() { + *x = PasteboardMetadata{} + if protoimpl.UnsafeEnabled { + mi := &file_TSPArchiveMessages_proto_msgTypes[8] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *PasteboardMetadata) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*PasteboardMetadata) ProtoMessage() {} + +func (x *PasteboardMetadata) ProtoReflect() protoreflect.Message { + mi := &file_TSPArchiveMessages_proto_msgTypes[8] + 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) } -func (m *PasteboardMetadata) Reset() { *m = PasteboardMetadata{} } -func (m *PasteboardMetadata) String() string { return proto.CompactTextString(m) } -func (*PasteboardMetadata) ProtoMessage() {} +// Deprecated: Use PasteboardMetadata.ProtoReflect.Descriptor instead. +func (*PasteboardMetadata) Descriptor() ([]byte, []int) { + return file_TSPArchiveMessages_proto_rawDescGZIP(), []int{8} +} -func (m *PasteboardMetadata) GetVersion() []uint32 { - if m != nil { - return m.Version +func (x *PasteboardMetadata) GetVersion() []uint32 { + if x != nil { + return x.Version } return nil } -func (m *PasteboardMetadata) GetAppName() string { - if m != nil && m.AppName != nil { - return *m.AppName +func (x *PasteboardMetadata) GetAppName() string { + if x != nil && x.AppName != nil { + return *x.AppName } return "" } -func (m *PasteboardMetadata) GetDatas() []*DataInfo { - if m != nil { - return m.Datas +func (x *PasteboardMetadata) GetDatas() []*DataInfo { + if x != nil { + return x.Datas } return nil } -func (m *PasteboardMetadata) GetSourceDocumentUuid() string { - if m != nil && m.SourceDocumentUuid != nil { - return *m.SourceDocumentUuid +func (x *PasteboardMetadata) GetSourceDocumentUuid() string { + if x != nil && x.SourceDocumentUuid != nil { + return *x.SourceDocumentUuid } return "" } type DataInfo struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + Identifier *uint64 `protobuf:"varint,1,req,name=identifier" json:"identifier,omitempty"` Digest []byte `protobuf:"bytes,2,req,name=digest" json:"digest,omitempty"` - PreferredFileName *string `protobuf:"bytes,3,req,name=preferred_file_name" json:"preferred_file_name,omitempty"` - FileName *string `protobuf:"bytes,4,opt,name=file_name" json:"file_name,omitempty"` - DocumentResourceLocator *string `protobuf:"bytes,5,opt,name=document_resource_locator" json:"document_resource_locator,omitempty"` - SourceBookmarkData []byte `protobuf:"bytes,6,opt,name=source_bookmark_data" json:"source_bookmark_data,omitempty"` - PasteboardExternalFilePath *string `protobuf:"bytes,99,opt,name=pasteboard_external_file_path" json:"pasteboard_external_file_path,omitempty"` - XXX_unrecognized []byte `json:"-"` + PreferredFileName *string `protobuf:"bytes,3,req,name=preferred_file_name,json=preferredFileName" json:"preferred_file_name,omitempty"` + FileName *string `protobuf:"bytes,4,opt,name=file_name,json=fileName" json:"file_name,omitempty"` + DocumentResourceLocator *string `protobuf:"bytes,5,opt,name=document_resource_locator,json=documentResourceLocator" json:"document_resource_locator,omitempty"` + SourceBookmarkData []byte `protobuf:"bytes,6,opt,name=source_bookmark_data,json=sourceBookmarkData" json:"source_bookmark_data,omitempty"` + PasteboardExternalFilePath *string `protobuf:"bytes,99,opt,name=pasteboard_external_file_path,json=pasteboardExternalFilePath" json:"pasteboard_external_file_path,omitempty"` +} + +func (x *DataInfo) Reset() { + *x = DataInfo{} + if protoimpl.UnsafeEnabled { + mi := &file_TSPArchiveMessages_proto_msgTypes[9] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *DataInfo) String() string { + return protoimpl.X.MessageStringOf(x) } -func (m *DataInfo) Reset() { *m = DataInfo{} } -func (m *DataInfo) String() string { return proto.CompactTextString(m) } -func (*DataInfo) ProtoMessage() {} +func (*DataInfo) ProtoMessage() {} -func (m *DataInfo) GetIdentifier() uint64 { - if m != nil && m.Identifier != nil { - return *m.Identifier +func (x *DataInfo) ProtoReflect() protoreflect.Message { + mi := &file_TSPArchiveMessages_proto_msgTypes[9] + 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 DataInfo.ProtoReflect.Descriptor instead. +func (*DataInfo) Descriptor() ([]byte, []int) { + return file_TSPArchiveMessages_proto_rawDescGZIP(), []int{9} +} + +func (x *DataInfo) GetIdentifier() uint64 { + if x != nil && x.Identifier != nil { + return *x.Identifier } return 0 } -func (m *DataInfo) GetDigest() []byte { - if m != nil { - return m.Digest +func (x *DataInfo) GetDigest() []byte { + if x != nil { + return x.Digest } return nil } -func (m *DataInfo) GetPreferredFileName() string { - if m != nil && m.PreferredFileName != nil { - return *m.PreferredFileName +func (x *DataInfo) GetPreferredFileName() string { + if x != nil && x.PreferredFileName != nil { + return *x.PreferredFileName } return "" } -func (m *DataInfo) GetFileName() string { - if m != nil && m.FileName != nil { - return *m.FileName +func (x *DataInfo) GetFileName() string { + if x != nil && x.FileName != nil { + return *x.FileName } return "" } -func (m *DataInfo) GetDocumentResourceLocator() string { - if m != nil && m.DocumentResourceLocator != nil { - return *m.DocumentResourceLocator +func (x *DataInfo) GetDocumentResourceLocator() string { + if x != nil && x.DocumentResourceLocator != nil { + return *x.DocumentResourceLocator } return "" } -func (m *DataInfo) GetSourceBookmarkData() []byte { - if m != nil { - return m.SourceBookmarkData +func (x *DataInfo) GetSourceBookmarkData() []byte { + if x != nil { + return x.SourceBookmarkData } return nil } -func (m *DataInfo) GetPasteboardExternalFilePath() string { - if m != nil && m.PasteboardExternalFilePath != nil { - return *m.PasteboardExternalFilePath +func (x *DataInfo) GetPasteboardExternalFilePath() string { + if x != nil && x.PasteboardExternalFilePath != nil { + return *x.PasteboardExternalFilePath } return "" } type ViewStateMetadata struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + Version []uint32 `protobuf:"varint,1,rep,packed,name=version" json:"version,omitempty"` - DocumentVersionUuid *string `protobuf:"bytes,2,req,name=document_version_uuid" json:"document_version_uuid,omitempty"` + DocumentVersionUuid *string `protobuf:"bytes,2,req,name=document_version_uuid,json=documentVersionUuid" json:"document_version_uuid,omitempty"` Component *ComponentInfo `protobuf:"bytes,3,req,name=component" json:"component,omitempty"` - XXX_unrecognized []byte `json:"-"` } -func (m *ViewStateMetadata) Reset() { *m = ViewStateMetadata{} } -func (m *ViewStateMetadata) String() string { return proto.CompactTextString(m) } -func (*ViewStateMetadata) ProtoMessage() {} +func (x *ViewStateMetadata) Reset() { + *x = ViewStateMetadata{} + if protoimpl.UnsafeEnabled { + mi := &file_TSPArchiveMessages_proto_msgTypes[10] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *ViewStateMetadata) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ViewStateMetadata) ProtoMessage() {} + +func (x *ViewStateMetadata) ProtoReflect() protoreflect.Message { + mi := &file_TSPArchiveMessages_proto_msgTypes[10] + 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 ViewStateMetadata.ProtoReflect.Descriptor instead. +func (*ViewStateMetadata) Descriptor() ([]byte, []int) { + return file_TSPArchiveMessages_proto_rawDescGZIP(), []int{10} +} -func (m *ViewStateMetadata) GetVersion() []uint32 { - if m != nil { - return m.Version +func (x *ViewStateMetadata) GetVersion() []uint32 { + if x != nil { + return x.Version } return nil } -func (m *ViewStateMetadata) GetDocumentVersionUuid() string { - if m != nil && m.DocumentVersionUuid != nil { - return *m.DocumentVersionUuid +func (x *ViewStateMetadata) GetDocumentVersionUuid() string { + if x != nil && x.DocumentVersionUuid != nil { + return *x.DocumentVersionUuid } return "" } -func (m *ViewStateMetadata) GetComponent() *ComponentInfo { - if m != nil { - return m.Component +func (x *ViewStateMetadata) GetComponent() *ComponentInfo { + if x != nil { + return x.Component } return nil } -func init() { - proto.RegisterEnum("TSP.FieldInfo_Type", FieldInfo_Type_name, FieldInfo_Type_value) - proto.RegisterEnum("TSP.FieldInfo_Rule", FieldInfo_Rule_name, FieldInfo_Rule_value) +var File_TSPArchiveMessages_proto protoreflect.FileDescriptor + +var file_TSPArchiveMessages_proto_rawDesc = []byte{ + 0x0a, 0x18, 0x54, 0x53, 0x50, 0x41, 0x72, 0x63, 0x68, 0x69, 0x76, 0x65, 0x4d, 0x65, 0x73, 0x73, + 0x61, 0x67, 0x65, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x03, 0x54, 0x53, 0x50, 0x22, + 0x64, 0x0a, 0x0b, 0x41, 0x72, 0x63, 0x68, 0x69, 0x76, 0x65, 0x49, 0x6e, 0x66, 0x6f, 0x12, 0x1e, + 0x0a, 0x0a, 0x69, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x66, 0x69, 0x65, 0x72, 0x18, 0x01, 0x20, 0x01, + 0x28, 0x04, 0x52, 0x0a, 0x69, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x66, 0x69, 0x65, 0x72, 0x12, 0x35, + 0x0a, 0x0d, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x5f, 0x69, 0x6e, 0x66, 0x6f, 0x73, 0x18, + 0x02, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x10, 0x2e, 0x54, 0x53, 0x50, 0x2e, 0x4d, 0x65, 0x73, 0x73, + 0x61, 0x67, 0x65, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x0c, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, + 0x49, 0x6e, 0x66, 0x6f, 0x73, 0x22, 0xe6, 0x01, 0x0a, 0x0b, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, + 0x65, 0x49, 0x6e, 0x66, 0x6f, 0x12, 0x12, 0x0a, 0x04, 0x74, 0x79, 0x70, 0x65, 0x18, 0x01, 0x20, + 0x02, 0x28, 0x0d, 0x52, 0x04, 0x74, 0x79, 0x70, 0x65, 0x12, 0x1c, 0x0a, 0x07, 0x76, 0x65, 0x72, + 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x02, 0x20, 0x03, 0x28, 0x0d, 0x42, 0x02, 0x10, 0x01, 0x52, 0x07, + 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x16, 0x0a, 0x06, 0x6c, 0x65, 0x6e, 0x67, 0x74, + 0x68, 0x18, 0x03, 0x20, 0x02, 0x28, 0x0d, 0x52, 0x06, 0x6c, 0x65, 0x6e, 0x67, 0x74, 0x68, 0x12, + 0x2f, 0x0a, 0x0b, 0x66, 0x69, 0x65, 0x6c, 0x64, 0x5f, 0x69, 0x6e, 0x66, 0x6f, 0x73, 0x18, 0x04, + 0x20, 0x03, 0x28, 0x0b, 0x32, 0x0e, 0x2e, 0x54, 0x53, 0x50, 0x2e, 0x46, 0x69, 0x65, 0x6c, 0x64, + 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x0a, 0x66, 0x69, 0x65, 0x6c, 0x64, 0x49, 0x6e, 0x66, 0x6f, 0x73, + 0x12, 0x2f, 0x0a, 0x11, 0x6f, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x5f, 0x72, 0x65, 0x66, 0x65, 0x72, + 0x65, 0x6e, 0x63, 0x65, 0x73, 0x18, 0x05, 0x20, 0x03, 0x28, 0x04, 0x42, 0x02, 0x10, 0x01, 0x52, + 0x10, 0x6f, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x52, 0x65, 0x66, 0x65, 0x72, 0x65, 0x6e, 0x63, 0x65, + 0x73, 0x12, 0x2b, 0x0a, 0x0f, 0x64, 0x61, 0x74, 0x61, 0x5f, 0x72, 0x65, 0x66, 0x65, 0x72, 0x65, + 0x6e, 0x63, 0x65, 0x73, 0x18, 0x06, 0x20, 0x03, 0x28, 0x04, 0x42, 0x02, 0x10, 0x01, 0x52, 0x0e, + 0x64, 0x61, 0x74, 0x61, 0x52, 0x65, 0x66, 0x65, 0x72, 0x65, 0x6e, 0x63, 0x65, 0x73, 0x22, 0x9e, + 0x03, 0x0a, 0x09, 0x46, 0x69, 0x65, 0x6c, 0x64, 0x49, 0x6e, 0x66, 0x6f, 0x12, 0x22, 0x0a, 0x04, + 0x70, 0x61, 0x74, 0x68, 0x18, 0x01, 0x20, 0x02, 0x28, 0x0b, 0x32, 0x0e, 0x2e, 0x54, 0x53, 0x50, + 0x2e, 0x46, 0x69, 0x65, 0x6c, 0x64, 0x50, 0x61, 0x74, 0x68, 0x52, 0x04, 0x70, 0x61, 0x74, 0x68, + 0x12, 0x2e, 0x0a, 0x04, 0x74, 0x79, 0x70, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x13, + 0x2e, 0x54, 0x53, 0x50, 0x2e, 0x46, 0x69, 0x65, 0x6c, 0x64, 0x49, 0x6e, 0x66, 0x6f, 0x2e, 0x54, + 0x79, 0x70, 0x65, 0x3a, 0x05, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x52, 0x04, 0x74, 0x79, 0x70, 0x65, + 0x12, 0x36, 0x0a, 0x04, 0x72, 0x75, 0x6c, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x13, + 0x2e, 0x54, 0x53, 0x50, 0x2e, 0x46, 0x69, 0x65, 0x6c, 0x64, 0x49, 0x6e, 0x66, 0x6f, 0x2e, 0x52, + 0x75, 0x6c, 0x65, 0x3a, 0x0d, 0x49, 0x67, 0x6e, 0x6f, 0x72, 0x65, 0x41, 0x6e, 0x64, 0x44, 0x72, + 0x6f, 0x70, 0x52, 0x04, 0x72, 0x75, 0x6c, 0x65, 0x12, 0x2f, 0x0a, 0x11, 0x6f, 0x62, 0x6a, 0x65, + 0x63, 0x74, 0x5f, 0x72, 0x65, 0x66, 0x65, 0x72, 0x65, 0x6e, 0x63, 0x65, 0x73, 0x18, 0x04, 0x20, + 0x03, 0x28, 0x04, 0x42, 0x02, 0x10, 0x01, 0x52, 0x10, 0x6f, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x52, + 0x65, 0x66, 0x65, 0x72, 0x65, 0x6e, 0x63, 0x65, 0x73, 0x12, 0x2b, 0x0a, 0x0f, 0x64, 0x61, 0x74, + 0x61, 0x5f, 0x72, 0x65, 0x66, 0x65, 0x72, 0x65, 0x6e, 0x63, 0x65, 0x73, 0x18, 0x05, 0x20, 0x03, + 0x28, 0x04, 0x42, 0x02, 0x10, 0x01, 0x52, 0x0e, 0x64, 0x61, 0x74, 0x61, 0x52, 0x65, 0x66, 0x65, + 0x72, 0x65, 0x6e, 0x63, 0x65, 0x73, 0x22, 0x46, 0x0a, 0x04, 0x54, 0x79, 0x70, 0x65, 0x12, 0x09, + 0x0a, 0x05, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x10, 0x00, 0x12, 0x13, 0x0a, 0x0f, 0x4f, 0x62, 0x6a, + 0x65, 0x63, 0x74, 0x52, 0x65, 0x66, 0x65, 0x72, 0x65, 0x6e, 0x63, 0x65, 0x10, 0x01, 0x12, 0x11, + 0x0a, 0x0d, 0x44, 0x61, 0x74, 0x61, 0x52, 0x65, 0x66, 0x65, 0x72, 0x65, 0x6e, 0x63, 0x65, 0x10, + 0x02, 0x12, 0x0b, 0x0a, 0x07, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x10, 0x03, 0x22, 0x5f, + 0x0a, 0x04, 0x52, 0x75, 0x6c, 0x65, 0x12, 0x11, 0x0a, 0x0d, 0x49, 0x67, 0x6e, 0x6f, 0x72, 0x65, + 0x41, 0x6e, 0x64, 0x44, 0x72, 0x6f, 0x70, 0x10, 0x00, 0x12, 0x15, 0x0a, 0x11, 0x49, 0x67, 0x6e, + 0x6f, 0x72, 0x65, 0x41, 0x6e, 0x64, 0x50, 0x72, 0x65, 0x73, 0x65, 0x72, 0x76, 0x65, 0x10, 0x01, + 0x12, 0x12, 0x0a, 0x0e, 0x4d, 0x75, 0x73, 0x74, 0x55, 0x6e, 0x64, 0x65, 0x72, 0x73, 0x74, 0x61, + 0x6e, 0x64, 0x10, 0x02, 0x12, 0x19, 0x0a, 0x0c, 0x4e, 0x6f, 0x74, 0x53, 0x75, 0x70, 0x70, 0x6f, + 0x72, 0x74, 0x65, 0x64, 0x10, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x01, 0x22, + 0x23, 0x0a, 0x09, 0x46, 0x69, 0x65, 0x6c, 0x64, 0x50, 0x61, 0x74, 0x68, 0x12, 0x16, 0x0a, 0x04, + 0x70, 0x61, 0x74, 0x68, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0d, 0x42, 0x02, 0x10, 0x01, 0x52, 0x04, + 0x70, 0x61, 0x74, 0x68, 0x22, 0xd5, 0x04, 0x0a, 0x0d, 0x43, 0x6f, 0x6d, 0x70, 0x6f, 0x6e, 0x65, + 0x6e, 0x74, 0x49, 0x6e, 0x66, 0x6f, 0x12, 0x1e, 0x0a, 0x0a, 0x69, 0x64, 0x65, 0x6e, 0x74, 0x69, + 0x66, 0x69, 0x65, 0x72, 0x18, 0x01, 0x20, 0x02, 0x28, 0x04, 0x52, 0x0a, 0x69, 0x64, 0x65, 0x6e, + 0x74, 0x69, 0x66, 0x69, 0x65, 0x72, 0x12, 0x2b, 0x0a, 0x11, 0x70, 0x72, 0x65, 0x66, 0x65, 0x72, + 0x72, 0x65, 0x64, 0x5f, 0x6c, 0x6f, 0x63, 0x61, 0x74, 0x6f, 0x72, 0x18, 0x02, 0x20, 0x02, 0x28, + 0x09, 0x52, 0x10, 0x70, 0x72, 0x65, 0x66, 0x65, 0x72, 0x72, 0x65, 0x64, 0x4c, 0x6f, 0x63, 0x61, + 0x74, 0x6f, 0x72, 0x12, 0x18, 0x0a, 0x07, 0x6c, 0x6f, 0x63, 0x61, 0x74, 0x6f, 0x72, 0x18, 0x03, + 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x6c, 0x6f, 0x63, 0x61, 0x74, 0x6f, 0x72, 0x12, 0x25, 0x0a, + 0x0c, 0x72, 0x65, 0x61, 0x64, 0x5f, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x04, 0x20, + 0x03, 0x28, 0x0d, 0x42, 0x02, 0x10, 0x01, 0x52, 0x0b, 0x72, 0x65, 0x61, 0x64, 0x56, 0x65, 0x72, + 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x27, 0x0a, 0x0d, 0x77, 0x72, 0x69, 0x74, 0x65, 0x5f, 0x76, 0x65, + 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x05, 0x20, 0x03, 0x28, 0x0d, 0x42, 0x02, 0x10, 0x01, 0x52, + 0x0c, 0x77, 0x72, 0x69, 0x74, 0x65, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x50, 0x0a, + 0x13, 0x65, 0x78, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x5f, 0x72, 0x65, 0x66, 0x65, 0x72, 0x65, + 0x6e, 0x63, 0x65, 0x73, 0x18, 0x06, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x1f, 0x2e, 0x54, 0x53, 0x50, + 0x2e, 0x43, 0x6f, 0x6d, 0x70, 0x6f, 0x6e, 0x65, 0x6e, 0x74, 0x45, 0x78, 0x74, 0x65, 0x72, 0x6e, + 0x61, 0x6c, 0x52, 0x65, 0x66, 0x65, 0x72, 0x65, 0x6e, 0x63, 0x65, 0x52, 0x12, 0x65, 0x78, 0x74, + 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x52, 0x65, 0x66, 0x65, 0x72, 0x65, 0x6e, 0x63, 0x65, 0x73, 0x12, + 0x44, 0x0a, 0x0f, 0x64, 0x61, 0x74, 0x61, 0x5f, 0x72, 0x65, 0x66, 0x65, 0x72, 0x65, 0x6e, 0x63, + 0x65, 0x73, 0x18, 0x07, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x1b, 0x2e, 0x54, 0x53, 0x50, 0x2e, 0x43, + 0x6f, 0x6d, 0x70, 0x6f, 0x6e, 0x65, 0x6e, 0x74, 0x44, 0x61, 0x74, 0x61, 0x52, 0x65, 0x66, 0x65, + 0x72, 0x65, 0x6e, 0x63, 0x65, 0x52, 0x0e, 0x64, 0x61, 0x74, 0x61, 0x52, 0x65, 0x66, 0x65, 0x72, + 0x65, 0x6e, 0x63, 0x65, 0x73, 0x12, 0x66, 0x0a, 0x2d, 0x61, 0x6c, 0x6c, 0x6f, 0x77, 0x73, 0x5f, + 0x64, 0x75, 0x70, 0x6c, 0x69, 0x63, 0x61, 0x74, 0x65, 0x73, 0x5f, 0x6f, 0x75, 0x74, 0x73, 0x69, + 0x64, 0x65, 0x5f, 0x6f, 0x66, 0x5f, 0x64, 0x6f, 0x63, 0x75, 0x6d, 0x65, 0x6e, 0x74, 0x5f, 0x70, + 0x61, 0x63, 0x6b, 0x61, 0x67, 0x65, 0x18, 0x08, 0x20, 0x01, 0x28, 0x08, 0x3a, 0x05, 0x66, 0x61, + 0x6c, 0x73, 0x65, 0x52, 0x28, 0x61, 0x6c, 0x6c, 0x6f, 0x77, 0x73, 0x44, 0x75, 0x70, 0x6c, 0x69, + 0x63, 0x61, 0x74, 0x65, 0x73, 0x4f, 0x75, 0x74, 0x73, 0x69, 0x64, 0x65, 0x4f, 0x66, 0x44, 0x6f, + 0x63, 0x75, 0x6d, 0x65, 0x6e, 0x74, 0x50, 0x61, 0x63, 0x6b, 0x61, 0x67, 0x65, 0x12, 0x3e, 0x0a, + 0x18, 0x64, 0x69, 0x72, 0x74, 0x69, 0x65, 0x73, 0x5f, 0x64, 0x6f, 0x63, 0x75, 0x6d, 0x65, 0x6e, + 0x74, 0x5f, 0x70, 0x61, 0x63, 0x6b, 0x61, 0x67, 0x65, 0x18, 0x09, 0x20, 0x01, 0x28, 0x08, 0x3a, + 0x04, 0x74, 0x72, 0x75, 0x65, 0x52, 0x16, 0x64, 0x69, 0x72, 0x74, 0x69, 0x65, 0x73, 0x44, 0x6f, + 0x63, 0x75, 0x6d, 0x65, 0x6e, 0x74, 0x50, 0x61, 0x63, 0x6b, 0x61, 0x67, 0x65, 0x12, 0x4d, 0x0a, + 0x20, 0x69, 0x73, 0x5f, 0x73, 0x74, 0x6f, 0x72, 0x65, 0x64, 0x5f, 0x6f, 0x75, 0x74, 0x73, 0x69, + 0x64, 0x65, 0x5f, 0x6f, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x5f, 0x61, 0x72, 0x63, 0x68, 0x69, 0x76, + 0x65, 0x18, 0x0a, 0x20, 0x01, 0x28, 0x08, 0x3a, 0x05, 0x66, 0x61, 0x6c, 0x73, 0x65, 0x52, 0x1c, + 0x69, 0x73, 0x53, 0x74, 0x6f, 0x72, 0x65, 0x64, 0x4f, 0x75, 0x74, 0x73, 0x69, 0x64, 0x65, 0x4f, + 0x62, 0x6a, 0x65, 0x63, 0x74, 0x41, 0x72, 0x63, 0x68, 0x69, 0x76, 0x65, 0x22, 0x95, 0x01, 0x0a, + 0x1a, 0x43, 0x6f, 0x6d, 0x70, 0x6f, 0x6e, 0x65, 0x6e, 0x74, 0x45, 0x78, 0x74, 0x65, 0x72, 0x6e, + 0x61, 0x6c, 0x52, 0x65, 0x66, 0x65, 0x72, 0x65, 0x6e, 0x63, 0x65, 0x12, 0x31, 0x0a, 0x14, 0x63, + 0x6f, 0x6d, 0x70, 0x6f, 0x6e, 0x65, 0x6e, 0x74, 0x5f, 0x69, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x66, + 0x69, 0x65, 0x72, 0x18, 0x01, 0x20, 0x02, 0x28, 0x04, 0x52, 0x13, 0x63, 0x6f, 0x6d, 0x70, 0x6f, + 0x6e, 0x65, 0x6e, 0x74, 0x49, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x66, 0x69, 0x65, 0x72, 0x12, 0x2b, + 0x0a, 0x11, 0x6f, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x5f, 0x69, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x66, + 0x69, 0x65, 0x72, 0x18, 0x02, 0x20, 0x01, 0x28, 0x04, 0x52, 0x10, 0x6f, 0x62, 0x6a, 0x65, 0x63, + 0x74, 0x49, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x66, 0x69, 0x65, 0x72, 0x12, 0x17, 0x0a, 0x07, 0x69, + 0x73, 0x5f, 0x77, 0x65, 0x61, 0x6b, 0x18, 0x03, 0x20, 0x01, 0x28, 0x08, 0x52, 0x06, 0x69, 0x73, + 0x57, 0x65, 0x61, 0x6b, 0x22, 0x41, 0x0a, 0x16, 0x43, 0x6f, 0x6d, 0x70, 0x6f, 0x6e, 0x65, 0x6e, + 0x74, 0x44, 0x61, 0x74, 0x61, 0x52, 0x65, 0x66, 0x65, 0x72, 0x65, 0x6e, 0x63, 0x65, 0x12, 0x27, + 0x0a, 0x0f, 0x64, 0x61, 0x74, 0x61, 0x5f, 0x69, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x66, 0x69, 0x65, + 0x72, 0x18, 0x01, 0x20, 0x02, 0x28, 0x04, 0x52, 0x0e, 0x64, 0x61, 0x74, 0x61, 0x49, 0x64, 0x65, + 0x6e, 0x74, 0x69, 0x66, 0x69, 0x65, 0x72, 0x22, 0xf0, 0x01, 0x0a, 0x0f, 0x50, 0x61, 0x63, 0x6b, + 0x61, 0x67, 0x65, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x12, 0x34, 0x0a, 0x16, 0x6c, + 0x61, 0x73, 0x74, 0x5f, 0x6f, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x5f, 0x69, 0x64, 0x65, 0x6e, 0x74, + 0x69, 0x66, 0x69, 0x65, 0x72, 0x18, 0x01, 0x20, 0x02, 0x28, 0x04, 0x52, 0x14, 0x6c, 0x61, 0x73, + 0x74, 0x4f, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x49, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x66, 0x69, 0x65, + 0x72, 0x12, 0x32, 0x0a, 0x0a, 0x63, 0x6f, 0x6d, 0x70, 0x6f, 0x6e, 0x65, 0x6e, 0x74, 0x73, 0x18, + 0x03, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x12, 0x2e, 0x54, 0x53, 0x50, 0x2e, 0x43, 0x6f, 0x6d, 0x70, + 0x6f, 0x6e, 0x65, 0x6e, 0x74, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x0a, 0x63, 0x6f, 0x6d, 0x70, 0x6f, + 0x6e, 0x65, 0x6e, 0x74, 0x73, 0x12, 0x23, 0x0a, 0x05, 0x64, 0x61, 0x74, 0x61, 0x73, 0x18, 0x04, + 0x20, 0x03, 0x28, 0x0b, 0x32, 0x0d, 0x2e, 0x54, 0x53, 0x50, 0x2e, 0x44, 0x61, 0x74, 0x61, 0x49, + 0x6e, 0x66, 0x6f, 0x52, 0x05, 0x64, 0x61, 0x74, 0x61, 0x73, 0x12, 0x25, 0x0a, 0x0c, 0x72, 0x65, + 0x61, 0x64, 0x5f, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x05, 0x20, 0x03, 0x28, 0x0d, + 0x42, 0x02, 0x10, 0x01, 0x52, 0x0b, 0x72, 0x65, 0x61, 0x64, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, + 0x6e, 0x12, 0x27, 0x0a, 0x0d, 0x77, 0x72, 0x69, 0x74, 0x65, 0x5f, 0x76, 0x65, 0x72, 0x73, 0x69, + 0x6f, 0x6e, 0x18, 0x06, 0x20, 0x03, 0x28, 0x0d, 0x42, 0x02, 0x10, 0x01, 0x52, 0x0c, 0x77, 0x72, + 0x69, 0x74, 0x65, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x22, 0xa4, 0x01, 0x0a, 0x12, 0x50, + 0x61, 0x73, 0x74, 0x65, 0x62, 0x6f, 0x61, 0x72, 0x64, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, + 0x61, 0x12, 0x1c, 0x0a, 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x01, 0x20, 0x03, + 0x28, 0x0d, 0x42, 0x02, 0x10, 0x01, 0x52, 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x12, + 0x19, 0x0a, 0x08, 0x61, 0x70, 0x70, 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x02, 0x20, 0x02, 0x28, + 0x09, 0x52, 0x07, 0x61, 0x70, 0x70, 0x4e, 0x61, 0x6d, 0x65, 0x12, 0x23, 0x0a, 0x05, 0x64, 0x61, + 0x74, 0x61, 0x73, 0x18, 0x03, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x0d, 0x2e, 0x54, 0x53, 0x50, 0x2e, + 0x44, 0x61, 0x74, 0x61, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x05, 0x64, 0x61, 0x74, 0x61, 0x73, 0x12, + 0x30, 0x0a, 0x14, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x5f, 0x64, 0x6f, 0x63, 0x75, 0x6d, 0x65, + 0x6e, 0x74, 0x5f, 0x75, 0x75, 0x69, 0x64, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x12, 0x73, + 0x6f, 0x75, 0x72, 0x63, 0x65, 0x44, 0x6f, 0x63, 0x75, 0x6d, 0x65, 0x6e, 0x74, 0x55, 0x75, 0x69, + 0x64, 0x22, 0xc0, 0x02, 0x0a, 0x08, 0x44, 0x61, 0x74, 0x61, 0x49, 0x6e, 0x66, 0x6f, 0x12, 0x1e, + 0x0a, 0x0a, 0x69, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x66, 0x69, 0x65, 0x72, 0x18, 0x01, 0x20, 0x02, + 0x28, 0x04, 0x52, 0x0a, 0x69, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x66, 0x69, 0x65, 0x72, 0x12, 0x16, + 0x0a, 0x06, 0x64, 0x69, 0x67, 0x65, 0x73, 0x74, 0x18, 0x02, 0x20, 0x02, 0x28, 0x0c, 0x52, 0x06, + 0x64, 0x69, 0x67, 0x65, 0x73, 0x74, 0x12, 0x2e, 0x0a, 0x13, 0x70, 0x72, 0x65, 0x66, 0x65, 0x72, + 0x72, 0x65, 0x64, 0x5f, 0x66, 0x69, 0x6c, 0x65, 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x03, 0x20, + 0x02, 0x28, 0x09, 0x52, 0x11, 0x70, 0x72, 0x65, 0x66, 0x65, 0x72, 0x72, 0x65, 0x64, 0x46, 0x69, + 0x6c, 0x65, 0x4e, 0x61, 0x6d, 0x65, 0x12, 0x1b, 0x0a, 0x09, 0x66, 0x69, 0x6c, 0x65, 0x5f, 0x6e, + 0x61, 0x6d, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x66, 0x69, 0x6c, 0x65, 0x4e, + 0x61, 0x6d, 0x65, 0x12, 0x3a, 0x0a, 0x19, 0x64, 0x6f, 0x63, 0x75, 0x6d, 0x65, 0x6e, 0x74, 0x5f, + 0x72, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x5f, 0x6c, 0x6f, 0x63, 0x61, 0x74, 0x6f, 0x72, + 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x52, 0x17, 0x64, 0x6f, 0x63, 0x75, 0x6d, 0x65, 0x6e, 0x74, + 0x52, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x4c, 0x6f, 0x63, 0x61, 0x74, 0x6f, 0x72, 0x12, + 0x30, 0x0a, 0x14, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x5f, 0x62, 0x6f, 0x6f, 0x6b, 0x6d, 0x61, + 0x72, 0x6b, 0x5f, 0x64, 0x61, 0x74, 0x61, 0x18, 0x06, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x12, 0x73, + 0x6f, 0x75, 0x72, 0x63, 0x65, 0x42, 0x6f, 0x6f, 0x6b, 0x6d, 0x61, 0x72, 0x6b, 0x44, 0x61, 0x74, + 0x61, 0x12, 0x41, 0x0a, 0x1d, 0x70, 0x61, 0x73, 0x74, 0x65, 0x62, 0x6f, 0x61, 0x72, 0x64, 0x5f, + 0x65, 0x78, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x5f, 0x66, 0x69, 0x6c, 0x65, 0x5f, 0x70, 0x61, + 0x74, 0x68, 0x18, 0x63, 0x20, 0x01, 0x28, 0x09, 0x52, 0x1a, 0x70, 0x61, 0x73, 0x74, 0x65, 0x62, + 0x6f, 0x61, 0x72, 0x64, 0x45, 0x78, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x46, 0x69, 0x6c, 0x65, + 0x50, 0x61, 0x74, 0x68, 0x22, 0x97, 0x01, 0x0a, 0x11, 0x56, 0x69, 0x65, 0x77, 0x53, 0x74, 0x61, + 0x74, 0x65, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x12, 0x1c, 0x0a, 0x07, 0x76, 0x65, + 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0d, 0x42, 0x02, 0x10, 0x01, 0x52, + 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x32, 0x0a, 0x15, 0x64, 0x6f, 0x63, 0x75, + 0x6d, 0x65, 0x6e, 0x74, 0x5f, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x5f, 0x75, 0x75, 0x69, + 0x64, 0x18, 0x02, 0x20, 0x02, 0x28, 0x09, 0x52, 0x13, 0x64, 0x6f, 0x63, 0x75, 0x6d, 0x65, 0x6e, + 0x74, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x55, 0x75, 0x69, 0x64, 0x12, 0x30, 0x0a, 0x09, + 0x63, 0x6f, 0x6d, 0x70, 0x6f, 0x6e, 0x65, 0x6e, 0x74, 0x18, 0x03, 0x20, 0x02, 0x28, 0x0b, 0x32, + 0x12, 0x2e, 0x54, 0x53, 0x50, 0x2e, 0x43, 0x6f, 0x6d, 0x70, 0x6f, 0x6e, 0x65, 0x6e, 0x74, 0x49, + 0x6e, 0x66, 0x6f, 0x52, 0x09, 0x63, 0x6f, 0x6d, 0x70, 0x6f, 0x6e, 0x65, 0x6e, 0x74, 0x42, 0x20, + 0x5a, 0x1e, 0x63, 0x6f, 0x64, 0x65, 0x2e, 0x73, 0x61, 0x6a, 0x61, 0x72, 0x69, 0x2e, 0x63, 0x6f, + 0x6d, 0x2f, 0x64, 0x6f, 0x63, 0x63, 0x6f, 0x6e, 0x76, 0x2f, 0x76, 0x32, 0x2f, 0x74, 0x73, 0x70, +} + +var ( + file_TSPArchiveMessages_proto_rawDescOnce sync.Once + file_TSPArchiveMessages_proto_rawDescData = file_TSPArchiveMessages_proto_rawDesc +) + +func file_TSPArchiveMessages_proto_rawDescGZIP() []byte { + file_TSPArchiveMessages_proto_rawDescOnce.Do(func() { + file_TSPArchiveMessages_proto_rawDescData = protoimpl.X.CompressGZIP(file_TSPArchiveMessages_proto_rawDescData) + }) + return file_TSPArchiveMessages_proto_rawDescData +} + +var file_TSPArchiveMessages_proto_enumTypes = make([]protoimpl.EnumInfo, 2) +var file_TSPArchiveMessages_proto_msgTypes = make([]protoimpl.MessageInfo, 11) +var file_TSPArchiveMessages_proto_goTypes = []interface{}{ + (FieldInfo_Type)(0), // 0: TSP.FieldInfo.Type + (FieldInfo_Rule)(0), // 1: TSP.FieldInfo.Rule + (*ArchiveInfo)(nil), // 2: TSP.ArchiveInfo + (*MessageInfo)(nil), // 3: TSP.MessageInfo + (*FieldInfo)(nil), // 4: TSP.FieldInfo + (*FieldPath)(nil), // 5: TSP.FieldPath + (*ComponentInfo)(nil), // 6: TSP.ComponentInfo + (*ComponentExternalReference)(nil), // 7: TSP.ComponentExternalReference + (*ComponentDataReference)(nil), // 8: TSP.ComponentDataReference + (*PackageMetadata)(nil), // 9: TSP.PackageMetadata + (*PasteboardMetadata)(nil), // 10: TSP.PasteboardMetadata + (*DataInfo)(nil), // 11: TSP.DataInfo + (*ViewStateMetadata)(nil), // 12: TSP.ViewStateMetadata +} +var file_TSPArchiveMessages_proto_depIdxs = []int32{ + 3, // 0: TSP.ArchiveInfo.message_infos:type_name -> TSP.MessageInfo + 4, // 1: TSP.MessageInfo.field_infos:type_name -> TSP.FieldInfo + 5, // 2: TSP.FieldInfo.path:type_name -> TSP.FieldPath + 0, // 3: TSP.FieldInfo.type:type_name -> TSP.FieldInfo.Type + 1, // 4: TSP.FieldInfo.rule:type_name -> TSP.FieldInfo.Rule + 7, // 5: TSP.ComponentInfo.external_references:type_name -> TSP.ComponentExternalReference + 8, // 6: TSP.ComponentInfo.data_references:type_name -> TSP.ComponentDataReference + 6, // 7: TSP.PackageMetadata.components:type_name -> TSP.ComponentInfo + 11, // 8: TSP.PackageMetadata.datas:type_name -> TSP.DataInfo + 11, // 9: TSP.PasteboardMetadata.datas:type_name -> TSP.DataInfo + 6, // 10: TSP.ViewStateMetadata.component:type_name -> TSP.ComponentInfo + 11, // [11:11] is the sub-list for method output_type + 11, // [11:11] is the sub-list for method input_type + 11, // [11:11] is the sub-list for extension type_name + 11, // [11:11] is the sub-list for extension extendee + 0, // [0:11] is the sub-list for field type_name +} + +func init() { file_TSPArchiveMessages_proto_init() } +func file_TSPArchiveMessages_proto_init() { + if File_TSPArchiveMessages_proto != nil { + return + } + if !protoimpl.UnsafeEnabled { + file_TSPArchiveMessages_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*ArchiveInfo); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_TSPArchiveMessages_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*MessageInfo); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_TSPArchiveMessages_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*FieldInfo); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_TSPArchiveMessages_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*FieldPath); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_TSPArchiveMessages_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*ComponentInfo); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_TSPArchiveMessages_proto_msgTypes[5].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*ComponentExternalReference); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_TSPArchiveMessages_proto_msgTypes[6].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*ComponentDataReference); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_TSPArchiveMessages_proto_msgTypes[7].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*PackageMetadata); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_TSPArchiveMessages_proto_msgTypes[8].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*PasteboardMetadata); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_TSPArchiveMessages_proto_msgTypes[9].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*DataInfo); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_TSPArchiveMessages_proto_msgTypes[10].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*ViewStateMetadata); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + } + type x struct{} + out := protoimpl.TypeBuilder{ + File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), + RawDescriptor: file_TSPArchiveMessages_proto_rawDesc, + NumEnums: 2, + NumMessages: 11, + NumExtensions: 0, + NumServices: 0, + }, + GoTypes: file_TSPArchiveMessages_proto_goTypes, + DependencyIndexes: file_TSPArchiveMessages_proto_depIdxs, + EnumInfos: file_TSPArchiveMessages_proto_enumTypes, + MessageInfos: file_TSPArchiveMessages_proto_msgTypes, + }.Build() + File_TSPArchiveMessages_proto = out.File + file_TSPArchiveMessages_proto_rawDesc = nil + file_TSPArchiveMessages_proto_goTypes = nil + file_TSPArchiveMessages_proto_depIdxs = nil } diff --git a/iWork/TSPDatabaseMessages.pb.go b/iWork/TSPDatabaseMessages.pb.go index 17a997d..69ae471 100644 --- a/iWork/TSPDatabaseMessages.pb.go +++ b/iWork/TSPDatabaseMessages.pb.go @@ -1,15 +1,24 @@ -// Code generated by protoc-gen-go. +// Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.27.1 +// protoc v4.24.4 // source: TSPDatabaseMessages.proto -// DO NOT EDIT! -package TSP +package tsp -import proto "github.com/golang/protobuf/proto" -import math "math" +import ( + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" + reflect "reflect" + sync "sync" +) -// Reference imports to suppress errors if they are not otherwise used. -var _ = proto.Marshal -var _ = math.Inf +const ( + // Verify that this generated code is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) + // Verify that runtime/protoimpl is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) +) type DatabaseImageDataArchive_ImageType int32 @@ -19,132 +28,385 @@ const ( DatabaseImageDataArchive_pdf DatabaseImageDataArchive_ImageType = 2 ) -var DatabaseImageDataArchive_ImageType_name = map[int32]string{ - 0: "unknown", - 1: "bitmap", - 2: "pdf", -} -var DatabaseImageDataArchive_ImageType_value = map[string]int32{ - "unknown": 0, - "bitmap": 1, - "pdf": 2, -} +// Enum value maps for DatabaseImageDataArchive_ImageType. +var ( + DatabaseImageDataArchive_ImageType_name = map[int32]string{ + 0: "unknown", + 1: "bitmap", + 2: "pdf", + } + DatabaseImageDataArchive_ImageType_value = map[string]int32{ + "unknown": 0, + "bitmap": 1, + "pdf": 2, + } +) func (x DatabaseImageDataArchive_ImageType) Enum() *DatabaseImageDataArchive_ImageType { p := new(DatabaseImageDataArchive_ImageType) *p = x return p } + func (x DatabaseImageDataArchive_ImageType) String() string { - return proto.EnumName(DatabaseImageDataArchive_ImageType_name, int32(x)) + return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x)) } -func (x *DatabaseImageDataArchive_ImageType) UnmarshalJSON(data []byte) error { - value, err := proto.UnmarshalJSONEnum(DatabaseImageDataArchive_ImageType_value, data, "DatabaseImageDataArchive_ImageType") + +func (DatabaseImageDataArchive_ImageType) Descriptor() protoreflect.EnumDescriptor { + return file_TSPDatabaseMessages_proto_enumTypes[0].Descriptor() +} + +func (DatabaseImageDataArchive_ImageType) Type() protoreflect.EnumType { + return &file_TSPDatabaseMessages_proto_enumTypes[0] +} + +func (x DatabaseImageDataArchive_ImageType) Number() protoreflect.EnumNumber { + return protoreflect.EnumNumber(x) +} + +// Deprecated: Do not use. +func (x *DatabaseImageDataArchive_ImageType) UnmarshalJSON(b []byte) error { + num, err := protoimpl.X.UnmarshalJSONEnum(x.Descriptor(), b) if err != nil { return err } - *x = DatabaseImageDataArchive_ImageType(value) + *x = DatabaseImageDataArchive_ImageType(num) return nil } +// Deprecated: Use DatabaseImageDataArchive_ImageType.Descriptor instead. +func (DatabaseImageDataArchive_ImageType) EnumDescriptor() ([]byte, []int) { + return file_TSPDatabaseMessages_proto_rawDescGZIP(), []int{2, 0} +} + type DatabaseData struct { - Data *DataReference `protobuf:"bytes,1,req,name=data" json:"data,omitempty"` - XXX_unrecognized []byte `json:"-"` + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Data *DataReference `protobuf:"bytes,1,req,name=data" json:"data,omitempty"` +} + +func (x *DatabaseData) Reset() { + *x = DatabaseData{} + if protoimpl.UnsafeEnabled { + mi := &file_TSPDatabaseMessages_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *DatabaseData) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*DatabaseData) ProtoMessage() {} + +func (x *DatabaseData) ProtoReflect() protoreflect.Message { + mi := &file_TSPDatabaseMessages_proto_msgTypes[0] + 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) } -func (m *DatabaseData) Reset() { *m = DatabaseData{} } -func (m *DatabaseData) String() string { return proto.CompactTextString(m) } -func (*DatabaseData) ProtoMessage() {} +// Deprecated: Use DatabaseData.ProtoReflect.Descriptor instead. +func (*DatabaseData) Descriptor() ([]byte, []int) { + return file_TSPDatabaseMessages_proto_rawDescGZIP(), []int{0} +} -func (m *DatabaseData) GetData() *DataReference { - if m != nil { - return m.Data +func (x *DatabaseData) GetData() *DataReference { + if x != nil { + return x.Data } return nil } type DatabaseDataArchive struct { - Data *Reference `protobuf:"bytes,1,opt,name=data" json:"data,omitempty"` - AppRelativePath *string `protobuf:"bytes,2,opt,name=app_relative_path" json:"app_relative_path,omitempty"` - DisplayName *string `protobuf:"bytes,3,req,name=display_name" json:"display_name,omitempty"` - Length *uint64 `protobuf:"varint,4,opt,name=length" json:"length,omitempty"` - Hash *uint32 `protobuf:"varint,5,opt,name=hash" json:"hash,omitempty"` - Sharable *bool `protobuf:"varint,6,req,name=sharable,def=1" json:"sharable,omitempty"` - XXX_unrecognized []byte `json:"-"` + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Data *Reference `protobuf:"bytes,1,opt,name=data" json:"data,omitempty"` + AppRelativePath *string `protobuf:"bytes,2,opt,name=app_relative_path,json=appRelativePath" json:"app_relative_path,omitempty"` + DisplayName *string `protobuf:"bytes,3,req,name=display_name,json=displayName" json:"display_name,omitempty"` + Length *uint64 `protobuf:"varint,4,opt,name=length" json:"length,omitempty"` + Hash *uint32 `protobuf:"varint,5,opt,name=hash" json:"hash,omitempty"` + Sharable *bool `protobuf:"varint,6,req,name=sharable,def=1" json:"sharable,omitempty"` } -func (m *DatabaseDataArchive) Reset() { *m = DatabaseDataArchive{} } -func (m *DatabaseDataArchive) String() string { return proto.CompactTextString(m) } -func (*DatabaseDataArchive) ProtoMessage() {} +// Default values for DatabaseDataArchive fields. +const ( + Default_DatabaseDataArchive_Sharable = bool(true) +) -const Default_DatabaseDataArchive_Sharable bool = true +func (x *DatabaseDataArchive) Reset() { + *x = DatabaseDataArchive{} + if protoimpl.UnsafeEnabled { + mi := &file_TSPDatabaseMessages_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *DatabaseDataArchive) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*DatabaseDataArchive) ProtoMessage() {} + +func (x *DatabaseDataArchive) ProtoReflect() protoreflect.Message { + mi := &file_TSPDatabaseMessages_proto_msgTypes[1] + 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 DatabaseDataArchive.ProtoReflect.Descriptor instead. +func (*DatabaseDataArchive) Descriptor() ([]byte, []int) { + return file_TSPDatabaseMessages_proto_rawDescGZIP(), []int{1} +} -func (m *DatabaseDataArchive) GetData() *Reference { - if m != nil { - return m.Data +func (x *DatabaseDataArchive) GetData() *Reference { + if x != nil { + return x.Data } return nil } -func (m *DatabaseDataArchive) GetAppRelativePath() string { - if m != nil && m.AppRelativePath != nil { - return *m.AppRelativePath +func (x *DatabaseDataArchive) GetAppRelativePath() string { + if x != nil && x.AppRelativePath != nil { + return *x.AppRelativePath } return "" } -func (m *DatabaseDataArchive) GetDisplayName() string { - if m != nil && m.DisplayName != nil { - return *m.DisplayName +func (x *DatabaseDataArchive) GetDisplayName() string { + if x != nil && x.DisplayName != nil { + return *x.DisplayName } return "" } -func (m *DatabaseDataArchive) GetLength() uint64 { - if m != nil && m.Length != nil { - return *m.Length +func (x *DatabaseDataArchive) GetLength() uint64 { + if x != nil && x.Length != nil { + return *x.Length } return 0 } -func (m *DatabaseDataArchive) GetHash() uint32 { - if m != nil && m.Hash != nil { - return *m.Hash +func (x *DatabaseDataArchive) GetHash() uint32 { + if x != nil && x.Hash != nil { + return *x.Hash } return 0 } -func (m *DatabaseDataArchive) GetSharable() bool { - if m != nil && m.Sharable != nil { - return *m.Sharable +func (x *DatabaseDataArchive) GetSharable() bool { + if x != nil && x.Sharable != nil { + return *x.Sharable } return Default_DatabaseDataArchive_Sharable } type DatabaseImageDataArchive struct { - Super *DatabaseDataArchive `protobuf:"bytes,1,req,name=super" json:"super,omitempty"` - Type *DatabaseImageDataArchive_ImageType `protobuf:"varint,2,req,name=type,enum=TSP.DatabaseImageDataArchive_ImageType" json:"type,omitempty"` - XXX_unrecognized []byte `json:"-"` + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Super *DatabaseDataArchive `protobuf:"bytes,1,req,name=super" json:"super,omitempty"` + Type *DatabaseImageDataArchive_ImageType `protobuf:"varint,2,req,name=type,enum=TSP.DatabaseImageDataArchive_ImageType" json:"type,omitempty"` +} + +func (x *DatabaseImageDataArchive) Reset() { + *x = DatabaseImageDataArchive{} + if protoimpl.UnsafeEnabled { + mi := &file_TSPDatabaseMessages_proto_msgTypes[2] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *DatabaseImageDataArchive) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*DatabaseImageDataArchive) ProtoMessage() {} + +func (x *DatabaseImageDataArchive) ProtoReflect() protoreflect.Message { + mi := &file_TSPDatabaseMessages_proto_msgTypes[2] + 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) } -func (m *DatabaseImageDataArchive) Reset() { *m = DatabaseImageDataArchive{} } -func (m *DatabaseImageDataArchive) String() string { return proto.CompactTextString(m) } -func (*DatabaseImageDataArchive) ProtoMessage() {} +// Deprecated: Use DatabaseImageDataArchive.ProtoReflect.Descriptor instead. +func (*DatabaseImageDataArchive) Descriptor() ([]byte, []int) { + return file_TSPDatabaseMessages_proto_rawDescGZIP(), []int{2} +} -func (m *DatabaseImageDataArchive) GetSuper() *DatabaseDataArchive { - if m != nil { - return m.Super +func (x *DatabaseImageDataArchive) GetSuper() *DatabaseDataArchive { + if x != nil { + return x.Super } return nil } -func (m *DatabaseImageDataArchive) GetType() DatabaseImageDataArchive_ImageType { - if m != nil && m.Type != nil { - return *m.Type +func (x *DatabaseImageDataArchive) GetType() DatabaseImageDataArchive_ImageType { + if x != nil && x.Type != nil { + return *x.Type } return DatabaseImageDataArchive_unknown } -func init() { - proto.RegisterEnum("TSP.DatabaseImageDataArchive_ImageType", DatabaseImageDataArchive_ImageType_name, DatabaseImageDataArchive_ImageType_value) +var File_TSPDatabaseMessages_proto protoreflect.FileDescriptor + +var file_TSPDatabaseMessages_proto_rawDesc = []byte{ + 0x0a, 0x19, 0x54, 0x53, 0x50, 0x44, 0x61, 0x74, 0x61, 0x62, 0x61, 0x73, 0x65, 0x4d, 0x65, 0x73, + 0x73, 0x61, 0x67, 0x65, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x03, 0x54, 0x53, 0x50, + 0x1a, 0x11, 0x54, 0x53, 0x50, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x73, 0x2e, 0x70, 0x72, + 0x6f, 0x74, 0x6f, 0x22, 0x36, 0x0a, 0x0c, 0x44, 0x61, 0x74, 0x61, 0x62, 0x61, 0x73, 0x65, 0x44, + 0x61, 0x74, 0x61, 0x12, 0x26, 0x0a, 0x04, 0x64, 0x61, 0x74, 0x61, 0x18, 0x01, 0x20, 0x02, 0x28, + 0x0b, 0x32, 0x12, 0x2e, 0x54, 0x53, 0x50, 0x2e, 0x44, 0x61, 0x74, 0x61, 0x52, 0x65, 0x66, 0x65, + 0x72, 0x65, 0x6e, 0x63, 0x65, 0x52, 0x04, 0x64, 0x61, 0x74, 0x61, 0x22, 0xd6, 0x01, 0x0a, 0x13, + 0x44, 0x61, 0x74, 0x61, 0x62, 0x61, 0x73, 0x65, 0x44, 0x61, 0x74, 0x61, 0x41, 0x72, 0x63, 0x68, + 0x69, 0x76, 0x65, 0x12, 0x22, 0x0a, 0x04, 0x64, 0x61, 0x74, 0x61, 0x18, 0x01, 0x20, 0x01, 0x28, + 0x0b, 0x32, 0x0e, 0x2e, 0x54, 0x53, 0x50, 0x2e, 0x52, 0x65, 0x66, 0x65, 0x72, 0x65, 0x6e, 0x63, + 0x65, 0x52, 0x04, 0x64, 0x61, 0x74, 0x61, 0x12, 0x2a, 0x0a, 0x11, 0x61, 0x70, 0x70, 0x5f, 0x72, + 0x65, 0x6c, 0x61, 0x74, 0x69, 0x76, 0x65, 0x5f, 0x70, 0x61, 0x74, 0x68, 0x18, 0x02, 0x20, 0x01, + 0x28, 0x09, 0x52, 0x0f, 0x61, 0x70, 0x70, 0x52, 0x65, 0x6c, 0x61, 0x74, 0x69, 0x76, 0x65, 0x50, + 0x61, 0x74, 0x68, 0x12, 0x21, 0x0a, 0x0c, 0x64, 0x69, 0x73, 0x70, 0x6c, 0x61, 0x79, 0x5f, 0x6e, + 0x61, 0x6d, 0x65, 0x18, 0x03, 0x20, 0x02, 0x28, 0x09, 0x52, 0x0b, 0x64, 0x69, 0x73, 0x70, 0x6c, + 0x61, 0x79, 0x4e, 0x61, 0x6d, 0x65, 0x12, 0x16, 0x0a, 0x06, 0x6c, 0x65, 0x6e, 0x67, 0x74, 0x68, + 0x18, 0x04, 0x20, 0x01, 0x28, 0x04, 0x52, 0x06, 0x6c, 0x65, 0x6e, 0x67, 0x74, 0x68, 0x12, 0x12, + 0x0a, 0x04, 0x68, 0x61, 0x73, 0x68, 0x18, 0x05, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x04, 0x68, 0x61, + 0x73, 0x68, 0x12, 0x20, 0x0a, 0x08, 0x73, 0x68, 0x61, 0x72, 0x61, 0x62, 0x6c, 0x65, 0x18, 0x06, + 0x20, 0x02, 0x28, 0x08, 0x3a, 0x04, 0x74, 0x72, 0x75, 0x65, 0x52, 0x08, 0x73, 0x68, 0x61, 0x72, + 0x61, 0x62, 0x6c, 0x65, 0x22, 0xb6, 0x01, 0x0a, 0x18, 0x44, 0x61, 0x74, 0x61, 0x62, 0x61, 0x73, + 0x65, 0x49, 0x6d, 0x61, 0x67, 0x65, 0x44, 0x61, 0x74, 0x61, 0x41, 0x72, 0x63, 0x68, 0x69, 0x76, + 0x65, 0x12, 0x2e, 0x0a, 0x05, 0x73, 0x75, 0x70, 0x65, 0x72, 0x18, 0x01, 0x20, 0x02, 0x28, 0x0b, + 0x32, 0x18, 0x2e, 0x54, 0x53, 0x50, 0x2e, 0x44, 0x61, 0x74, 0x61, 0x62, 0x61, 0x73, 0x65, 0x44, + 0x61, 0x74, 0x61, 0x41, 0x72, 0x63, 0x68, 0x69, 0x76, 0x65, 0x52, 0x05, 0x73, 0x75, 0x70, 0x65, + 0x72, 0x12, 0x3b, 0x0a, 0x04, 0x74, 0x79, 0x70, 0x65, 0x18, 0x02, 0x20, 0x02, 0x28, 0x0e, 0x32, + 0x27, 0x2e, 0x54, 0x53, 0x50, 0x2e, 0x44, 0x61, 0x74, 0x61, 0x62, 0x61, 0x73, 0x65, 0x49, 0x6d, + 0x61, 0x67, 0x65, 0x44, 0x61, 0x74, 0x61, 0x41, 0x72, 0x63, 0x68, 0x69, 0x76, 0x65, 0x2e, 0x49, + 0x6d, 0x61, 0x67, 0x65, 0x54, 0x79, 0x70, 0x65, 0x52, 0x04, 0x74, 0x79, 0x70, 0x65, 0x22, 0x2d, + 0x0a, 0x09, 0x49, 0x6d, 0x61, 0x67, 0x65, 0x54, 0x79, 0x70, 0x65, 0x12, 0x0b, 0x0a, 0x07, 0x75, + 0x6e, 0x6b, 0x6e, 0x6f, 0x77, 0x6e, 0x10, 0x00, 0x12, 0x0a, 0x0a, 0x06, 0x62, 0x69, 0x74, 0x6d, + 0x61, 0x70, 0x10, 0x01, 0x12, 0x07, 0x0a, 0x03, 0x70, 0x64, 0x66, 0x10, 0x02, 0x42, 0x20, 0x5a, + 0x1e, 0x63, 0x6f, 0x64, 0x65, 0x2e, 0x73, 0x61, 0x6a, 0x61, 0x72, 0x69, 0x2e, 0x63, 0x6f, 0x6d, + 0x2f, 0x64, 0x6f, 0x63, 0x63, 0x6f, 0x6e, 0x76, 0x2f, 0x76, 0x32, 0x2f, 0x74, 0x73, 0x70, +} + +var ( + file_TSPDatabaseMessages_proto_rawDescOnce sync.Once + file_TSPDatabaseMessages_proto_rawDescData = file_TSPDatabaseMessages_proto_rawDesc +) + +func file_TSPDatabaseMessages_proto_rawDescGZIP() []byte { + file_TSPDatabaseMessages_proto_rawDescOnce.Do(func() { + file_TSPDatabaseMessages_proto_rawDescData = protoimpl.X.CompressGZIP(file_TSPDatabaseMessages_proto_rawDescData) + }) + return file_TSPDatabaseMessages_proto_rawDescData +} + +var file_TSPDatabaseMessages_proto_enumTypes = make([]protoimpl.EnumInfo, 1) +var file_TSPDatabaseMessages_proto_msgTypes = make([]protoimpl.MessageInfo, 3) +var file_TSPDatabaseMessages_proto_goTypes = []interface{}{ + (DatabaseImageDataArchive_ImageType)(0), // 0: TSP.DatabaseImageDataArchive.ImageType + (*DatabaseData)(nil), // 1: TSP.DatabaseData + (*DatabaseDataArchive)(nil), // 2: TSP.DatabaseDataArchive + (*DatabaseImageDataArchive)(nil), // 3: TSP.DatabaseImageDataArchive + (*DataReference)(nil), // 4: TSP.DataReference + (*Reference)(nil), // 5: TSP.Reference +} +var file_TSPDatabaseMessages_proto_depIdxs = []int32{ + 4, // 0: TSP.DatabaseData.data:type_name -> TSP.DataReference + 5, // 1: TSP.DatabaseDataArchive.data:type_name -> TSP.Reference + 2, // 2: TSP.DatabaseImageDataArchive.super:type_name -> TSP.DatabaseDataArchive + 0, // 3: TSP.DatabaseImageDataArchive.type:type_name -> TSP.DatabaseImageDataArchive.ImageType + 4, // [4:4] is the sub-list for method output_type + 4, // [4:4] is the sub-list for method input_type + 4, // [4:4] is the sub-list for extension type_name + 4, // [4:4] is the sub-list for extension extendee + 0, // [0:4] is the sub-list for field type_name +} + +func init() { file_TSPDatabaseMessages_proto_init() } +func file_TSPDatabaseMessages_proto_init() { + if File_TSPDatabaseMessages_proto != nil { + return + } + file_TSPMessages_proto_init() + if !protoimpl.UnsafeEnabled { + file_TSPDatabaseMessages_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*DatabaseData); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_TSPDatabaseMessages_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*DatabaseDataArchive); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_TSPDatabaseMessages_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*DatabaseImageDataArchive); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + } + type x struct{} + out := protoimpl.TypeBuilder{ + File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), + RawDescriptor: file_TSPDatabaseMessages_proto_rawDesc, + NumEnums: 1, + NumMessages: 3, + NumExtensions: 0, + NumServices: 0, + }, + GoTypes: file_TSPDatabaseMessages_proto_goTypes, + DependencyIndexes: file_TSPDatabaseMessages_proto_depIdxs, + EnumInfos: file_TSPDatabaseMessages_proto_enumTypes, + MessageInfos: file_TSPDatabaseMessages_proto_msgTypes, + }.Build() + File_TSPDatabaseMessages_proto = out.File + file_TSPDatabaseMessages_proto_rawDesc = nil + file_TSPDatabaseMessages_proto_goTypes = nil + file_TSPDatabaseMessages_proto_depIdxs = nil } diff --git a/iWork/TSPMessages.pb.go b/iWork/TSPMessages.pb.go index 5ffc0df..2dea10e 100644 --- a/iWork/TSPMessages.pb.go +++ b/iWork/TSPMessages.pb.go @@ -1,15 +1,24 @@ -// Code generated by protoc-gen-go. +// Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.27.1 +// protoc v4.24.4 // source: TSPMessages.proto -// DO NOT EDIT! -package TSP +package tsp -import proto "github.com/golang/protobuf/proto" -import math "math" +import ( + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" + reflect "reflect" + sync "sync" +) -// Reference imports to suppress errors if they are not otherwise used. -var _ = proto.Marshal -var _ = math.Inf +const ( + // Verify that this generated code is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) + // Verify that runtime/protoimpl is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) +) type Color_ColorModel int32 @@ -19,34 +28,57 @@ const ( Color_white Color_ColorModel = 3 ) -var Color_ColorModel_name = map[int32]string{ - 1: "rgb", - 2: "cmyk", - 3: "white", -} -var Color_ColorModel_value = map[string]int32{ - "rgb": 1, - "cmyk": 2, - "white": 3, -} +// Enum value maps for Color_ColorModel. +var ( + Color_ColorModel_name = map[int32]string{ + 1: "rgb", + 2: "cmyk", + 3: "white", + } + Color_ColorModel_value = map[string]int32{ + "rgb": 1, + "cmyk": 2, + "white": 3, + } +) func (x Color_ColorModel) Enum() *Color_ColorModel { p := new(Color_ColorModel) *p = x return p } + func (x Color_ColorModel) String() string { - return proto.EnumName(Color_ColorModel_name, int32(x)) + return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x)) +} + +func (Color_ColorModel) Descriptor() protoreflect.EnumDescriptor { + return file_TSPMessages_proto_enumTypes[0].Descriptor() +} + +func (Color_ColorModel) Type() protoreflect.EnumType { + return &file_TSPMessages_proto_enumTypes[0] } -func (x *Color_ColorModel) UnmarshalJSON(data []byte) error { - value, err := proto.UnmarshalJSONEnum(Color_ColorModel_value, data, "Color_ColorModel") + +func (x Color_ColorModel) Number() protoreflect.EnumNumber { + return protoreflect.EnumNumber(x) +} + +// Deprecated: Do not use. +func (x *Color_ColorModel) UnmarshalJSON(b []byte) error { + num, err := protoimpl.X.UnmarshalJSONEnum(x.Descriptor(), b) if err != nil { return err } - *x = Color_ColorModel(value) + *x = Color_ColorModel(num) return nil } +// Deprecated: Use Color_ColorModel.Descriptor instead. +func (Color_ColorModel) EnumDescriptor() ([]byte, []int) { + return file_TSPMessages_proto_rawDescGZIP(), []int{7, 0} +} + type Path_ElementType int32 const ( @@ -57,468 +89,1286 @@ const ( Path_closeSubpath Path_ElementType = 5 ) -var Path_ElementType_name = map[int32]string{ - 1: "moveTo", - 2: "lineTo", - 3: "quadCurveTo", - 4: "curveTo", - 5: "closeSubpath", -} -var Path_ElementType_value = map[string]int32{ - "moveTo": 1, - "lineTo": 2, - "quadCurveTo": 3, - "curveTo": 4, - "closeSubpath": 5, -} +// Enum value maps for Path_ElementType. +var ( + Path_ElementType_name = map[int32]string{ + 1: "moveTo", + 2: "lineTo", + 3: "quadCurveTo", + 4: "curveTo", + 5: "closeSubpath", + } + Path_ElementType_value = map[string]int32{ + "moveTo": 1, + "lineTo": 2, + "quadCurveTo": 3, + "curveTo": 4, + "closeSubpath": 5, + } +) func (x Path_ElementType) Enum() *Path_ElementType { p := new(Path_ElementType) *p = x return p } + func (x Path_ElementType) String() string { - return proto.EnumName(Path_ElementType_name, int32(x)) + return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x)) +} + +func (Path_ElementType) Descriptor() protoreflect.EnumDescriptor { + return file_TSPMessages_proto_enumTypes[1].Descriptor() } -func (x *Path_ElementType) UnmarshalJSON(data []byte) error { - value, err := proto.UnmarshalJSONEnum(Path_ElementType_value, data, "Path_ElementType") + +func (Path_ElementType) Type() protoreflect.EnumType { + return &file_TSPMessages_proto_enumTypes[1] +} + +func (x Path_ElementType) Number() protoreflect.EnumNumber { + return protoreflect.EnumNumber(x) +} + +// Deprecated: Do not use. +func (x *Path_ElementType) UnmarshalJSON(b []byte) error { + num, err := protoimpl.X.UnmarshalJSONEnum(x.Descriptor(), b) if err != nil { return err } - *x = Path_ElementType(value) + *x = Path_ElementType(num) return nil } +// Deprecated: Use Path_ElementType.Descriptor instead. +func (Path_ElementType) EnumDescriptor() ([]byte, []int) { + return file_TSPMessages_proto_rawDescGZIP(), []int{8, 0} +} + type Reference struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + Identifier *uint64 `protobuf:"varint,1,req,name=identifier" json:"identifier,omitempty"` - DeprecatedType *int32 `protobuf:"varint,2,opt,name=deprecated_type" json:"deprecated_type,omitempty"` - DeprecatedIsExternal *bool `protobuf:"varint,3,opt,name=deprecated_is_external" json:"deprecated_is_external,omitempty"` - XXX_unrecognized []byte `json:"-"` + DeprecatedType *int32 `protobuf:"varint,2,opt,name=deprecated_type,json=deprecatedType" json:"deprecated_type,omitempty"` + DeprecatedIsExternal *bool `protobuf:"varint,3,opt,name=deprecated_is_external,json=deprecatedIsExternal" json:"deprecated_is_external,omitempty"` +} + +func (x *Reference) Reset() { + *x = Reference{} + if protoimpl.UnsafeEnabled { + mi := &file_TSPMessages_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *Reference) String() string { + return protoimpl.X.MessageStringOf(x) } -func (m *Reference) Reset() { *m = Reference{} } -func (m *Reference) String() string { return proto.CompactTextString(m) } -func (*Reference) ProtoMessage() {} +func (*Reference) ProtoMessage() {} -func (m *Reference) GetIdentifier() uint64 { - if m != nil && m.Identifier != nil { - return *m.Identifier +func (x *Reference) ProtoReflect() protoreflect.Message { + mi := &file_TSPMessages_proto_msgTypes[0] + 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 Reference.ProtoReflect.Descriptor instead. +func (*Reference) Descriptor() ([]byte, []int) { + return file_TSPMessages_proto_rawDescGZIP(), []int{0} +} + +func (x *Reference) GetIdentifier() uint64 { + if x != nil && x.Identifier != nil { + return *x.Identifier } return 0 } -func (m *Reference) GetDeprecatedType() int32 { - if m != nil && m.DeprecatedType != nil { - return *m.DeprecatedType +func (x *Reference) GetDeprecatedType() int32 { + if x != nil && x.DeprecatedType != nil { + return *x.DeprecatedType } return 0 } -func (m *Reference) GetDeprecatedIsExternal() bool { - if m != nil && m.DeprecatedIsExternal != nil { - return *m.DeprecatedIsExternal +func (x *Reference) GetDeprecatedIsExternal() bool { + if x != nil && x.DeprecatedIsExternal != nil { + return *x.DeprecatedIsExternal } return false } type DataReference struct { - Identifier *uint64 `protobuf:"varint,1,req,name=identifier" json:"identifier,omitempty"` - XXX_unrecognized []byte `json:"-"` + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Identifier *uint64 `protobuf:"varint,1,req,name=identifier" json:"identifier,omitempty"` } -func (m *DataReference) Reset() { *m = DataReference{} } -func (m *DataReference) String() string { return proto.CompactTextString(m) } -func (*DataReference) ProtoMessage() {} +func (x *DataReference) Reset() { + *x = DataReference{} + if protoimpl.UnsafeEnabled { + mi := &file_TSPMessages_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *DataReference) String() string { + return protoimpl.X.MessageStringOf(x) +} -func (m *DataReference) GetIdentifier() uint64 { - if m != nil && m.Identifier != nil { - return *m.Identifier +func (*DataReference) ProtoMessage() {} + +func (x *DataReference) ProtoReflect() protoreflect.Message { + mi := &file_TSPMessages_proto_msgTypes[1] + 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 DataReference.ProtoReflect.Descriptor instead. +func (*DataReference) Descriptor() ([]byte, []int) { + return file_TSPMessages_proto_rawDescGZIP(), []int{1} +} + +func (x *DataReference) GetIdentifier() uint64 { + if x != nil && x.Identifier != nil { + return *x.Identifier } return 0 } type Point struct { - X *float32 `protobuf:"fixed32,1,req,name=x" json:"x,omitempty"` - Y *float32 `protobuf:"fixed32,2,req,name=y" json:"y,omitempty"` - XXX_unrecognized []byte `json:"-"` + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + X *float32 `protobuf:"fixed32,1,req,name=x" json:"x,omitempty"` + Y *float32 `protobuf:"fixed32,2,req,name=y" json:"y,omitempty"` +} + +func (x *Point) Reset() { + *x = Point{} + if protoimpl.UnsafeEnabled { + mi := &file_TSPMessages_proto_msgTypes[2] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *Point) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*Point) ProtoMessage() {} + +func (x *Point) ProtoReflect() protoreflect.Message { + mi := &file_TSPMessages_proto_msgTypes[2] + 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) } -func (m *Point) Reset() { *m = Point{} } -func (m *Point) String() string { return proto.CompactTextString(m) } -func (*Point) ProtoMessage() {} +// Deprecated: Use Point.ProtoReflect.Descriptor instead. +func (*Point) Descriptor() ([]byte, []int) { + return file_TSPMessages_proto_rawDescGZIP(), []int{2} +} -func (m *Point) GetX() float32 { - if m != nil && m.X != nil { - return *m.X +func (x *Point) GetX() float32 { + if x != nil && x.X != nil { + return *x.X } return 0 } -func (m *Point) GetY() float32 { - if m != nil && m.Y != nil { - return *m.Y +func (x *Point) GetY() float32 { + if x != nil && x.Y != nil { + return *x.Y } return 0 } type Size struct { - Width *float32 `protobuf:"fixed32,1,req,name=width" json:"width,omitempty"` - Height *float32 `protobuf:"fixed32,2,req,name=height" json:"height,omitempty"` - XXX_unrecognized []byte `json:"-"` + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Width *float32 `protobuf:"fixed32,1,req,name=width" json:"width,omitempty"` + Height *float32 `protobuf:"fixed32,2,req,name=height" json:"height,omitempty"` +} + +func (x *Size) Reset() { + *x = Size{} + if protoimpl.UnsafeEnabled { + mi := &file_TSPMessages_proto_msgTypes[3] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *Size) String() string { + return protoimpl.X.MessageStringOf(x) } -func (m *Size) Reset() { *m = Size{} } -func (m *Size) String() string { return proto.CompactTextString(m) } -func (*Size) ProtoMessage() {} +func (*Size) ProtoMessage() {} -func (m *Size) GetWidth() float32 { - if m != nil && m.Width != nil { - return *m.Width +func (x *Size) ProtoReflect() protoreflect.Message { + mi := &file_TSPMessages_proto_msgTypes[3] + 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 Size.ProtoReflect.Descriptor instead. +func (*Size) Descriptor() ([]byte, []int) { + return file_TSPMessages_proto_rawDescGZIP(), []int{3} +} + +func (x *Size) GetWidth() float32 { + if x != nil && x.Width != nil { + return *x.Width } return 0 } -func (m *Size) GetHeight() float32 { - if m != nil && m.Height != nil { - return *m.Height +func (x *Size) GetHeight() float32 { + if x != nil && x.Height != nil { + return *x.Height } return 0 } type Range struct { - Location *uint32 `protobuf:"varint,1,req,name=location" json:"location,omitempty"` - Length *uint32 `protobuf:"varint,2,req,name=length" json:"length,omitempty"` - XXX_unrecognized []byte `json:"-"` + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Location *uint32 `protobuf:"varint,1,req,name=location" json:"location,omitempty"` + Length *uint32 `protobuf:"varint,2,req,name=length" json:"length,omitempty"` } -func (m *Range) Reset() { *m = Range{} } -func (m *Range) String() string { return proto.CompactTextString(m) } -func (*Range) ProtoMessage() {} +func (x *Range) Reset() { + *x = Range{} + if protoimpl.UnsafeEnabled { + mi := &file_TSPMessages_proto_msgTypes[4] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *Range) String() string { + return protoimpl.X.MessageStringOf(x) +} -func (m *Range) GetLocation() uint32 { - if m != nil && m.Location != nil { - return *m.Location +func (*Range) ProtoMessage() {} + +func (x *Range) ProtoReflect() protoreflect.Message { + mi := &file_TSPMessages_proto_msgTypes[4] + 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 Range.ProtoReflect.Descriptor instead. +func (*Range) Descriptor() ([]byte, []int) { + return file_TSPMessages_proto_rawDescGZIP(), []int{4} +} + +func (x *Range) GetLocation() uint32 { + if x != nil && x.Location != nil { + return *x.Location } return 0 } -func (m *Range) GetLength() uint32 { - if m != nil && m.Length != nil { - return *m.Length +func (x *Range) GetLength() uint32 { + if x != nil && x.Length != nil { + return *x.Length } return 0 } type Date struct { - Seconds *float64 `protobuf:"fixed64,1,req,name=seconds" json:"seconds,omitempty"` - XXX_unrecognized []byte `json:"-"` + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Seconds *float64 `protobuf:"fixed64,1,req,name=seconds" json:"seconds,omitempty"` } -func (m *Date) Reset() { *m = Date{} } -func (m *Date) String() string { return proto.CompactTextString(m) } -func (*Date) ProtoMessage() {} +func (x *Date) Reset() { + *x = Date{} + if protoimpl.UnsafeEnabled { + mi := &file_TSPMessages_proto_msgTypes[5] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} -func (m *Date) GetSeconds() float64 { - if m != nil && m.Seconds != nil { - return *m.Seconds +func (x *Date) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*Date) ProtoMessage() {} + +func (x *Date) ProtoReflect() protoreflect.Message { + mi := &file_TSPMessages_proto_msgTypes[5] + 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 Date.ProtoReflect.Descriptor instead. +func (*Date) Descriptor() ([]byte, []int) { + return file_TSPMessages_proto_rawDescGZIP(), []int{5} +} + +func (x *Date) GetSeconds() float64 { + if x != nil && x.Seconds != nil { + return *x.Seconds } return 0 } type IndexSet struct { - Ranges []*Range `protobuf:"bytes,1,rep,name=ranges" json:"ranges,omitempty"` - XXX_unrecognized []byte `json:"-"` + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Ranges []*Range `protobuf:"bytes,1,rep,name=ranges" json:"ranges,omitempty"` } -func (m *IndexSet) Reset() { *m = IndexSet{} } -func (m *IndexSet) String() string { return proto.CompactTextString(m) } -func (*IndexSet) ProtoMessage() {} +func (x *IndexSet) Reset() { + *x = IndexSet{} + if protoimpl.UnsafeEnabled { + mi := &file_TSPMessages_proto_msgTypes[6] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} -func (m *IndexSet) GetRanges() []*Range { - if m != nil { - return m.Ranges +func (x *IndexSet) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*IndexSet) ProtoMessage() {} + +func (x *IndexSet) ProtoReflect() protoreflect.Message { + mi := &file_TSPMessages_proto_msgTypes[6] + 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 IndexSet.ProtoReflect.Descriptor instead. +func (*IndexSet) Descriptor() ([]byte, []int) { + return file_TSPMessages_proto_rawDescGZIP(), []int{6} +} + +func (x *IndexSet) GetRanges() []*Range { + if x != nil { + return x.Ranges } return nil } type Color struct { - Model *Color_ColorModel `protobuf:"varint,1,req,name=model,enum=TSP.Color_ColorModel" json:"model,omitempty"` - R *float32 `protobuf:"fixed32,3,opt,name=r" json:"r,omitempty"` - G *float32 `protobuf:"fixed32,4,opt,name=g" json:"g,omitempty"` - B *float32 `protobuf:"fixed32,5,opt,name=b" json:"b,omitempty"` - A *float32 `protobuf:"fixed32,6,opt,name=a,def=1" json:"a,omitempty"` - C *float32 `protobuf:"fixed32,7,opt,name=c" json:"c,omitempty"` - M *float32 `protobuf:"fixed32,8,opt,name=m" json:"m,omitempty"` - Y *float32 `protobuf:"fixed32,9,opt,name=y" json:"y,omitempty"` - K *float32 `protobuf:"fixed32,10,opt,name=k" json:"k,omitempty"` - W *float32 `protobuf:"fixed32,11,opt,name=w" json:"w,omitempty"` - XXX_unrecognized []byte `json:"-"` + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Model *Color_ColorModel `protobuf:"varint,1,req,name=model,enum=TSP.Color_ColorModel" json:"model,omitempty"` + R *float32 `protobuf:"fixed32,3,opt,name=r" json:"r,omitempty"` + G *float32 `protobuf:"fixed32,4,opt,name=g" json:"g,omitempty"` + B *float32 `protobuf:"fixed32,5,opt,name=b" json:"b,omitempty"` + A *float32 `protobuf:"fixed32,6,opt,name=a,def=1" json:"a,omitempty"` + C *float32 `protobuf:"fixed32,7,opt,name=c" json:"c,omitempty"` + M *float32 `protobuf:"fixed32,8,opt,name=m" json:"m,omitempty"` + Y *float32 `protobuf:"fixed32,9,opt,name=y" json:"y,omitempty"` + K *float32 `protobuf:"fixed32,10,opt,name=k" json:"k,omitempty"` + W *float32 `protobuf:"fixed32,11,opt,name=w" json:"w,omitempty"` +} + +// Default values for Color fields. +const ( + Default_Color_A = float32(1) +) + +func (x *Color) Reset() { + *x = Color{} + if protoimpl.UnsafeEnabled { + mi := &file_TSPMessages_proto_msgTypes[7] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *Color) String() string { + return protoimpl.X.MessageStringOf(x) } -func (m *Color) Reset() { *m = Color{} } -func (m *Color) String() string { return proto.CompactTextString(m) } -func (*Color) ProtoMessage() {} +func (*Color) ProtoMessage() {} -const Default_Color_A float32 = 1 +func (x *Color) ProtoReflect() protoreflect.Message { + mi := &file_TSPMessages_proto_msgTypes[7] + 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 Color.ProtoReflect.Descriptor instead. +func (*Color) Descriptor() ([]byte, []int) { + return file_TSPMessages_proto_rawDescGZIP(), []int{7} +} -func (m *Color) GetModel() Color_ColorModel { - if m != nil && m.Model != nil { - return *m.Model +func (x *Color) GetModel() Color_ColorModel { + if x != nil && x.Model != nil { + return *x.Model } return Color_rgb } -func (m *Color) GetR() float32 { - if m != nil && m.R != nil { - return *m.R +func (x *Color) GetR() float32 { + if x != nil && x.R != nil { + return *x.R } return 0 } -func (m *Color) GetG() float32 { - if m != nil && m.G != nil { - return *m.G +func (x *Color) GetG() float32 { + if x != nil && x.G != nil { + return *x.G } return 0 } -func (m *Color) GetB() float32 { - if m != nil && m.B != nil { - return *m.B +func (x *Color) GetB() float32 { + if x != nil && x.B != nil { + return *x.B } return 0 } -func (m *Color) GetA() float32 { - if m != nil && m.A != nil { - return *m.A +func (x *Color) GetA() float32 { + if x != nil && x.A != nil { + return *x.A } return Default_Color_A } -func (m *Color) GetC() float32 { - if m != nil && m.C != nil { - return *m.C +func (x *Color) GetC() float32 { + if x != nil && x.C != nil { + return *x.C } return 0 } -func (m *Color) GetM() float32 { - if m != nil && m.M != nil { - return *m.M +func (x *Color) GetM() float32 { + if x != nil && x.M != nil { + return *x.M } return 0 } -func (m *Color) GetY() float32 { - if m != nil && m.Y != nil { - return *m.Y +func (x *Color) GetY() float32 { + if x != nil && x.Y != nil { + return *x.Y } return 0 } -func (m *Color) GetK() float32 { - if m != nil && m.K != nil { - return *m.K +func (x *Color) GetK() float32 { + if x != nil && x.K != nil { + return *x.K } return 0 } -func (m *Color) GetW() float32 { - if m != nil && m.W != nil { - return *m.W +func (x *Color) GetW() float32 { + if x != nil && x.W != nil { + return *x.W } return 0 } type Path struct { - Elements []*Path_Element `protobuf:"bytes,1,rep,name=elements" json:"elements,omitempty"` - XXX_unrecognized []byte `json:"-"` -} + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields -func (m *Path) Reset() { *m = Path{} } -func (m *Path) String() string { return proto.CompactTextString(m) } -func (*Path) ProtoMessage() {} + Elements []*Path_Element `protobuf:"bytes,1,rep,name=elements" json:"elements,omitempty"` +} -func (m *Path) GetElements() []*Path_Element { - if m != nil { - return m.Elements +func (x *Path) Reset() { + *x = Path{} + if protoimpl.UnsafeEnabled { + mi := &file_TSPMessages_proto_msgTypes[8] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } - return nil } -type Path_Element struct { - Type *Path_ElementType `protobuf:"varint,1,req,name=type,enum=TSP.Path_ElementType" json:"type,omitempty"` - Points []*Point `protobuf:"bytes,2,rep,name=points" json:"points,omitempty"` - XXX_unrecognized []byte `json:"-"` +func (x *Path) String() string { + return protoimpl.X.MessageStringOf(x) } -func (m *Path_Element) Reset() { *m = Path_Element{} } -func (m *Path_Element) String() string { return proto.CompactTextString(m) } -func (*Path_Element) ProtoMessage() {} +func (*Path) ProtoMessage() {} -func (m *Path_Element) GetType() Path_ElementType { - if m != nil && m.Type != nil { - return *m.Type +func (x *Path) ProtoReflect() protoreflect.Message { + mi := &file_TSPMessages_proto_msgTypes[8] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms } - return Path_moveTo + return mi.MessageOf(x) +} + +// Deprecated: Use Path.ProtoReflect.Descriptor instead. +func (*Path) Descriptor() ([]byte, []int) { + return file_TSPMessages_proto_rawDescGZIP(), []int{8} } -func (m *Path_Element) GetPoints() []*Point { - if m != nil { - return m.Points +func (x *Path) GetElements() []*Path_Element { + if x != nil { + return x.Elements } return nil } type ReferenceDictionary struct { - Entries []*ReferenceDictionary_Entry `protobuf:"bytes,1,rep,name=entries" json:"entries,omitempty"` - XXX_unrecognized []byte `json:"-"` -} + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields -func (m *ReferenceDictionary) Reset() { *m = ReferenceDictionary{} } -func (m *ReferenceDictionary) String() string { return proto.CompactTextString(m) } -func (*ReferenceDictionary) ProtoMessage() {} + Entries []*ReferenceDictionary_Entry `protobuf:"bytes,1,rep,name=entries" json:"entries,omitempty"` +} -func (m *ReferenceDictionary) GetEntries() []*ReferenceDictionary_Entry { - if m != nil { - return m.Entries +func (x *ReferenceDictionary) Reset() { + *x = ReferenceDictionary{} + if protoimpl.UnsafeEnabled { + mi := &file_TSPMessages_proto_msgTypes[9] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } - return nil } -type ReferenceDictionary_Entry struct { - Key *Reference `protobuf:"bytes,1,req,name=key" json:"key,omitempty"` - Value *Reference `protobuf:"bytes,2,req,name=value" json:"value,omitempty"` - XXX_unrecognized []byte `json:"-"` +func (x *ReferenceDictionary) String() string { + return protoimpl.X.MessageStringOf(x) } -func (m *ReferenceDictionary_Entry) Reset() { *m = ReferenceDictionary_Entry{} } -func (m *ReferenceDictionary_Entry) String() string { return proto.CompactTextString(m) } -func (*ReferenceDictionary_Entry) ProtoMessage() {} +func (*ReferenceDictionary) ProtoMessage() {} -func (m *ReferenceDictionary_Entry) GetKey() *Reference { - if m != nil { - return m.Key +func (x *ReferenceDictionary) ProtoReflect() protoreflect.Message { + mi := &file_TSPMessages_proto_msgTypes[9] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms } - return nil + return mi.MessageOf(x) } -func (m *ReferenceDictionary_Entry) GetValue() *Reference { - if m != nil { - return m.Value +// Deprecated: Use ReferenceDictionary.ProtoReflect.Descriptor instead. +func (*ReferenceDictionary) Descriptor() ([]byte, []int) { + return file_TSPMessages_proto_rawDescGZIP(), []int{9} +} + +func (x *ReferenceDictionary) GetEntries() []*ReferenceDictionary_Entry { + if x != nil { + return x.Entries } return nil } type PasteboardObject struct { - Stylesheet *Reference `protobuf:"bytes,1,opt,name=stylesheet" json:"stylesheet,omitempty"` - Drawables []*Reference `protobuf:"bytes,2,rep,name=drawables" json:"drawables,omitempty"` - Styles []*Reference `protobuf:"bytes,3,rep,name=styles" json:"styles,omitempty"` - Theme *Reference `protobuf:"bytes,4,opt,name=theme" json:"theme,omitempty"` - WpStorage *Reference `protobuf:"bytes,5,opt,name=wp_storage" json:"wp_storage,omitempty"` - GuideStorage *Reference `protobuf:"bytes,9,opt,name=guide_storage" json:"guide_storage,omitempty"` - AppNativeObject *Reference `protobuf:"bytes,6,opt,name=app_native_object" json:"app_native_object,omitempty"` - IsTextPrimary *bool `protobuf:"varint,7,opt,name=is_text_primary,def=0" json:"is_text_primary,omitempty"` - IsSmart *bool `protobuf:"varint,8,opt,name=is_smart,def=0" json:"is_smart,omitempty"` - XXX_unrecognized []byte `json:"-"` + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Stylesheet *Reference `protobuf:"bytes,1,opt,name=stylesheet" json:"stylesheet,omitempty"` + Drawables []*Reference `protobuf:"bytes,2,rep,name=drawables" json:"drawables,omitempty"` + Styles []*Reference `protobuf:"bytes,3,rep,name=styles" json:"styles,omitempty"` + Theme *Reference `protobuf:"bytes,4,opt,name=theme" json:"theme,omitempty"` + WpStorage *Reference `protobuf:"bytes,5,opt,name=wp_storage,json=wpStorage" json:"wp_storage,omitempty"` + GuideStorage *Reference `protobuf:"bytes,9,opt,name=guide_storage,json=guideStorage" json:"guide_storage,omitempty"` + AppNativeObject *Reference `protobuf:"bytes,6,opt,name=app_native_object,json=appNativeObject" json:"app_native_object,omitempty"` + IsTextPrimary *bool `protobuf:"varint,7,opt,name=is_text_primary,json=isTextPrimary,def=0" json:"is_text_primary,omitempty"` + IsSmart *bool `protobuf:"varint,8,opt,name=is_smart,json=isSmart,def=0" json:"is_smart,omitempty"` +} + +// Default values for PasteboardObject fields. +const ( + Default_PasteboardObject_IsTextPrimary = bool(false) + Default_PasteboardObject_IsSmart = bool(false) +) + +func (x *PasteboardObject) Reset() { + *x = PasteboardObject{} + if protoimpl.UnsafeEnabled { + mi := &file_TSPMessages_proto_msgTypes[10] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } } -func (m *PasteboardObject) Reset() { *m = PasteboardObject{} } -func (m *PasteboardObject) String() string { return proto.CompactTextString(m) } -func (*PasteboardObject) ProtoMessage() {} +func (x *PasteboardObject) String() string { + return protoimpl.X.MessageStringOf(x) +} -const Default_PasteboardObject_IsTextPrimary bool = false -const Default_PasteboardObject_IsSmart bool = false +func (*PasteboardObject) ProtoMessage() {} -func (m *PasteboardObject) GetStylesheet() *Reference { - if m != nil { - return m.Stylesheet +func (x *PasteboardObject) ProtoReflect() protoreflect.Message { + mi := &file_TSPMessages_proto_msgTypes[10] + 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 PasteboardObject.ProtoReflect.Descriptor instead. +func (*PasteboardObject) Descriptor() ([]byte, []int) { + return file_TSPMessages_proto_rawDescGZIP(), []int{10} +} + +func (x *PasteboardObject) GetStylesheet() *Reference { + if x != nil { + return x.Stylesheet } return nil } -func (m *PasteboardObject) GetDrawables() []*Reference { - if m != nil { - return m.Drawables +func (x *PasteboardObject) GetDrawables() []*Reference { + if x != nil { + return x.Drawables } return nil } -func (m *PasteboardObject) GetStyles() []*Reference { - if m != nil { - return m.Styles +func (x *PasteboardObject) GetStyles() []*Reference { + if x != nil { + return x.Styles } return nil } -func (m *PasteboardObject) GetTheme() *Reference { - if m != nil { - return m.Theme +func (x *PasteboardObject) GetTheme() *Reference { + if x != nil { + return x.Theme } return nil } -func (m *PasteboardObject) GetWpStorage() *Reference { - if m != nil { - return m.WpStorage +func (x *PasteboardObject) GetWpStorage() *Reference { + if x != nil { + return x.WpStorage } return nil } -func (m *PasteboardObject) GetGuideStorage() *Reference { - if m != nil { - return m.GuideStorage +func (x *PasteboardObject) GetGuideStorage() *Reference { + if x != nil { + return x.GuideStorage } return nil } -func (m *PasteboardObject) GetAppNativeObject() *Reference { - if m != nil { - return m.AppNativeObject +func (x *PasteboardObject) GetAppNativeObject() *Reference { + if x != nil { + return x.AppNativeObject } return nil } -func (m *PasteboardObject) GetIsTextPrimary() bool { - if m != nil && m.IsTextPrimary != nil { - return *m.IsTextPrimary +func (x *PasteboardObject) GetIsTextPrimary() bool { + if x != nil && x.IsTextPrimary != nil { + return *x.IsTextPrimary } return Default_PasteboardObject_IsTextPrimary } -func (m *PasteboardObject) GetIsSmart() bool { - if m != nil && m.IsSmart != nil { - return *m.IsSmart +func (x *PasteboardObject) GetIsSmart() bool { + if x != nil && x.IsSmart != nil { + return *x.IsSmart } return Default_PasteboardObject_IsSmart } type ObjectContainer struct { - Identifier *uint32 `protobuf:"varint,1,opt,name=identifier" json:"identifier,omitempty"` - Objects []*Reference `protobuf:"bytes,2,rep,name=objects" json:"objects,omitempty"` - XXX_unrecognized []byte `json:"-"` + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Identifier *uint32 `protobuf:"varint,1,opt,name=identifier" json:"identifier,omitempty"` + Objects []*Reference `protobuf:"bytes,2,rep,name=objects" json:"objects,omitempty"` +} + +func (x *ObjectContainer) Reset() { + *x = ObjectContainer{} + if protoimpl.UnsafeEnabled { + mi := &file_TSPMessages_proto_msgTypes[11] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *ObjectContainer) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ObjectContainer) ProtoMessage() {} + +func (x *ObjectContainer) ProtoReflect() protoreflect.Message { + mi := &file_TSPMessages_proto_msgTypes[11] + 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) } -func (m *ObjectContainer) Reset() { *m = ObjectContainer{} } -func (m *ObjectContainer) String() string { return proto.CompactTextString(m) } -func (*ObjectContainer) ProtoMessage() {} +// Deprecated: Use ObjectContainer.ProtoReflect.Descriptor instead. +func (*ObjectContainer) Descriptor() ([]byte, []int) { + return file_TSPMessages_proto_rawDescGZIP(), []int{11} +} -func (m *ObjectContainer) GetIdentifier() uint32 { - if m != nil && m.Identifier != nil { - return *m.Identifier +func (x *ObjectContainer) GetIdentifier() uint32 { + if x != nil && x.Identifier != nil { + return *x.Identifier } return 0 } -func (m *ObjectContainer) GetObjects() []*Reference { - if m != nil { - return m.Objects +func (x *ObjectContainer) GetObjects() []*Reference { + if x != nil { + return x.Objects + } + return nil +} + +type Path_Element struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Type *Path_ElementType `protobuf:"varint,1,req,name=type,enum=TSP.Path_ElementType" json:"type,omitempty"` + Points []*Point `protobuf:"bytes,2,rep,name=points" json:"points,omitempty"` +} + +func (x *Path_Element) Reset() { + *x = Path_Element{} + if protoimpl.UnsafeEnabled { + mi := &file_TSPMessages_proto_msgTypes[12] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *Path_Element) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*Path_Element) ProtoMessage() {} + +func (x *Path_Element) ProtoReflect() protoreflect.Message { + mi := &file_TSPMessages_proto_msgTypes[12] + 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 Path_Element.ProtoReflect.Descriptor instead. +func (*Path_Element) Descriptor() ([]byte, []int) { + return file_TSPMessages_proto_rawDescGZIP(), []int{8, 0} +} + +func (x *Path_Element) GetType() Path_ElementType { + if x != nil && x.Type != nil { + return *x.Type + } + return Path_moveTo +} + +func (x *Path_Element) GetPoints() []*Point { + if x != nil { + return x.Points } return nil } -func init() { - proto.RegisterEnum("TSP.Color_ColorModel", Color_ColorModel_name, Color_ColorModel_value) - proto.RegisterEnum("TSP.Path_ElementType", Path_ElementType_name, Path_ElementType_value) +type ReferenceDictionary_Entry struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Key *Reference `protobuf:"bytes,1,req,name=key" json:"key,omitempty"` + Value *Reference `protobuf:"bytes,2,req,name=value" json:"value,omitempty"` +} + +func (x *ReferenceDictionary_Entry) Reset() { + *x = ReferenceDictionary_Entry{} + if protoimpl.UnsafeEnabled { + mi := &file_TSPMessages_proto_msgTypes[13] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *ReferenceDictionary_Entry) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ReferenceDictionary_Entry) ProtoMessage() {} + +func (x *ReferenceDictionary_Entry) ProtoReflect() protoreflect.Message { + mi := &file_TSPMessages_proto_msgTypes[13] + 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 ReferenceDictionary_Entry.ProtoReflect.Descriptor instead. +func (*ReferenceDictionary_Entry) Descriptor() ([]byte, []int) { + return file_TSPMessages_proto_rawDescGZIP(), []int{9, 0} +} + +func (x *ReferenceDictionary_Entry) GetKey() *Reference { + if x != nil { + return x.Key + } + return nil +} + +func (x *ReferenceDictionary_Entry) GetValue() *Reference { + if x != nil { + return x.Value + } + return nil +} + +var File_TSPMessages_proto protoreflect.FileDescriptor + +var file_TSPMessages_proto_rawDesc = []byte{ + 0x0a, 0x11, 0x54, 0x53, 0x50, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x73, 0x2e, 0x70, 0x72, + 0x6f, 0x74, 0x6f, 0x12, 0x03, 0x54, 0x53, 0x50, 0x22, 0x8a, 0x01, 0x0a, 0x09, 0x52, 0x65, 0x66, + 0x65, 0x72, 0x65, 0x6e, 0x63, 0x65, 0x12, 0x1e, 0x0a, 0x0a, 0x69, 0x64, 0x65, 0x6e, 0x74, 0x69, + 0x66, 0x69, 0x65, 0x72, 0x18, 0x01, 0x20, 0x02, 0x28, 0x04, 0x52, 0x0a, 0x69, 0x64, 0x65, 0x6e, + 0x74, 0x69, 0x66, 0x69, 0x65, 0x72, 0x12, 0x27, 0x0a, 0x0f, 0x64, 0x65, 0x70, 0x72, 0x65, 0x63, + 0x61, 0x74, 0x65, 0x64, 0x5f, 0x74, 0x79, 0x70, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, + 0x0e, 0x64, 0x65, 0x70, 0x72, 0x65, 0x63, 0x61, 0x74, 0x65, 0x64, 0x54, 0x79, 0x70, 0x65, 0x12, + 0x34, 0x0a, 0x16, 0x64, 0x65, 0x70, 0x72, 0x65, 0x63, 0x61, 0x74, 0x65, 0x64, 0x5f, 0x69, 0x73, + 0x5f, 0x65, 0x78, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x18, 0x03, 0x20, 0x01, 0x28, 0x08, 0x52, + 0x14, 0x64, 0x65, 0x70, 0x72, 0x65, 0x63, 0x61, 0x74, 0x65, 0x64, 0x49, 0x73, 0x45, 0x78, 0x74, + 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x22, 0x2f, 0x0a, 0x0d, 0x44, 0x61, 0x74, 0x61, 0x52, 0x65, 0x66, + 0x65, 0x72, 0x65, 0x6e, 0x63, 0x65, 0x12, 0x1e, 0x0a, 0x0a, 0x69, 0x64, 0x65, 0x6e, 0x74, 0x69, + 0x66, 0x69, 0x65, 0x72, 0x18, 0x01, 0x20, 0x02, 0x28, 0x04, 0x52, 0x0a, 0x69, 0x64, 0x65, 0x6e, + 0x74, 0x69, 0x66, 0x69, 0x65, 0x72, 0x22, 0x23, 0x0a, 0x05, 0x50, 0x6f, 0x69, 0x6e, 0x74, 0x12, + 0x0c, 0x0a, 0x01, 0x78, 0x18, 0x01, 0x20, 0x02, 0x28, 0x02, 0x52, 0x01, 0x78, 0x12, 0x0c, 0x0a, + 0x01, 0x79, 0x18, 0x02, 0x20, 0x02, 0x28, 0x02, 0x52, 0x01, 0x79, 0x22, 0x34, 0x0a, 0x04, 0x53, + 0x69, 0x7a, 0x65, 0x12, 0x14, 0x0a, 0x05, 0x77, 0x69, 0x64, 0x74, 0x68, 0x18, 0x01, 0x20, 0x02, + 0x28, 0x02, 0x52, 0x05, 0x77, 0x69, 0x64, 0x74, 0x68, 0x12, 0x16, 0x0a, 0x06, 0x68, 0x65, 0x69, + 0x67, 0x68, 0x74, 0x18, 0x02, 0x20, 0x02, 0x28, 0x02, 0x52, 0x06, 0x68, 0x65, 0x69, 0x67, 0x68, + 0x74, 0x22, 0x3b, 0x0a, 0x05, 0x52, 0x61, 0x6e, 0x67, 0x65, 0x12, 0x1a, 0x0a, 0x08, 0x6c, 0x6f, + 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x01, 0x20, 0x02, 0x28, 0x0d, 0x52, 0x08, 0x6c, 0x6f, + 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x16, 0x0a, 0x06, 0x6c, 0x65, 0x6e, 0x67, 0x74, 0x68, + 0x18, 0x02, 0x20, 0x02, 0x28, 0x0d, 0x52, 0x06, 0x6c, 0x65, 0x6e, 0x67, 0x74, 0x68, 0x22, 0x20, + 0x0a, 0x04, 0x44, 0x61, 0x74, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x73, 0x65, 0x63, 0x6f, 0x6e, 0x64, + 0x73, 0x18, 0x01, 0x20, 0x02, 0x28, 0x01, 0x52, 0x07, 0x73, 0x65, 0x63, 0x6f, 0x6e, 0x64, 0x73, + 0x22, 0x2e, 0x0a, 0x08, 0x49, 0x6e, 0x64, 0x65, 0x78, 0x53, 0x65, 0x74, 0x12, 0x22, 0x0a, 0x06, + 0x72, 0x61, 0x6e, 0x67, 0x65, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x0a, 0x2e, 0x54, + 0x53, 0x50, 0x2e, 0x52, 0x61, 0x6e, 0x67, 0x65, 0x52, 0x06, 0x72, 0x61, 0x6e, 0x67, 0x65, 0x73, + 0x22, 0xe1, 0x01, 0x0a, 0x05, 0x43, 0x6f, 0x6c, 0x6f, 0x72, 0x12, 0x2b, 0x0a, 0x05, 0x6d, 0x6f, + 0x64, 0x65, 0x6c, 0x18, 0x01, 0x20, 0x02, 0x28, 0x0e, 0x32, 0x15, 0x2e, 0x54, 0x53, 0x50, 0x2e, + 0x43, 0x6f, 0x6c, 0x6f, 0x72, 0x2e, 0x43, 0x6f, 0x6c, 0x6f, 0x72, 0x4d, 0x6f, 0x64, 0x65, 0x6c, + 0x52, 0x05, 0x6d, 0x6f, 0x64, 0x65, 0x6c, 0x12, 0x0c, 0x0a, 0x01, 0x72, 0x18, 0x03, 0x20, 0x01, + 0x28, 0x02, 0x52, 0x01, 0x72, 0x12, 0x0c, 0x0a, 0x01, 0x67, 0x18, 0x04, 0x20, 0x01, 0x28, 0x02, + 0x52, 0x01, 0x67, 0x12, 0x0c, 0x0a, 0x01, 0x62, 0x18, 0x05, 0x20, 0x01, 0x28, 0x02, 0x52, 0x01, + 0x62, 0x12, 0x0f, 0x0a, 0x01, 0x61, 0x18, 0x06, 0x20, 0x01, 0x28, 0x02, 0x3a, 0x01, 0x31, 0x52, + 0x01, 0x61, 0x12, 0x0c, 0x0a, 0x01, 0x63, 0x18, 0x07, 0x20, 0x01, 0x28, 0x02, 0x52, 0x01, 0x63, + 0x12, 0x0c, 0x0a, 0x01, 0x6d, 0x18, 0x08, 0x20, 0x01, 0x28, 0x02, 0x52, 0x01, 0x6d, 0x12, 0x0c, + 0x0a, 0x01, 0x79, 0x18, 0x09, 0x20, 0x01, 0x28, 0x02, 0x52, 0x01, 0x79, 0x12, 0x0c, 0x0a, 0x01, + 0x6b, 0x18, 0x0a, 0x20, 0x01, 0x28, 0x02, 0x52, 0x01, 0x6b, 0x12, 0x0c, 0x0a, 0x01, 0x77, 0x18, + 0x0b, 0x20, 0x01, 0x28, 0x02, 0x52, 0x01, 0x77, 0x22, 0x2a, 0x0a, 0x0a, 0x43, 0x6f, 0x6c, 0x6f, + 0x72, 0x4d, 0x6f, 0x64, 0x65, 0x6c, 0x12, 0x07, 0x0a, 0x03, 0x72, 0x67, 0x62, 0x10, 0x01, 0x12, + 0x08, 0x0a, 0x04, 0x63, 0x6d, 0x79, 0x6b, 0x10, 0x02, 0x12, 0x09, 0x0a, 0x05, 0x77, 0x68, 0x69, + 0x74, 0x65, 0x10, 0x03, 0x22, 0xe6, 0x01, 0x0a, 0x04, 0x50, 0x61, 0x74, 0x68, 0x12, 0x2d, 0x0a, + 0x08, 0x65, 0x6c, 0x65, 0x6d, 0x65, 0x6e, 0x74, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, + 0x11, 0x2e, 0x54, 0x53, 0x50, 0x2e, 0x50, 0x61, 0x74, 0x68, 0x2e, 0x45, 0x6c, 0x65, 0x6d, 0x65, + 0x6e, 0x74, 0x52, 0x08, 0x65, 0x6c, 0x65, 0x6d, 0x65, 0x6e, 0x74, 0x73, 0x1a, 0x58, 0x0a, 0x07, + 0x45, 0x6c, 0x65, 0x6d, 0x65, 0x6e, 0x74, 0x12, 0x29, 0x0a, 0x04, 0x74, 0x79, 0x70, 0x65, 0x18, + 0x01, 0x20, 0x02, 0x28, 0x0e, 0x32, 0x15, 0x2e, 0x54, 0x53, 0x50, 0x2e, 0x50, 0x61, 0x74, 0x68, + 0x2e, 0x45, 0x6c, 0x65, 0x6d, 0x65, 0x6e, 0x74, 0x54, 0x79, 0x70, 0x65, 0x52, 0x04, 0x74, 0x79, + 0x70, 0x65, 0x12, 0x22, 0x0a, 0x06, 0x70, 0x6f, 0x69, 0x6e, 0x74, 0x73, 0x18, 0x02, 0x20, 0x03, + 0x28, 0x0b, 0x32, 0x0a, 0x2e, 0x54, 0x53, 0x50, 0x2e, 0x50, 0x6f, 0x69, 0x6e, 0x74, 0x52, 0x06, + 0x70, 0x6f, 0x69, 0x6e, 0x74, 0x73, 0x22, 0x55, 0x0a, 0x0b, 0x45, 0x6c, 0x65, 0x6d, 0x65, 0x6e, + 0x74, 0x54, 0x79, 0x70, 0x65, 0x12, 0x0a, 0x0a, 0x06, 0x6d, 0x6f, 0x76, 0x65, 0x54, 0x6f, 0x10, + 0x01, 0x12, 0x0a, 0x0a, 0x06, 0x6c, 0x69, 0x6e, 0x65, 0x54, 0x6f, 0x10, 0x02, 0x12, 0x0f, 0x0a, + 0x0b, 0x71, 0x75, 0x61, 0x64, 0x43, 0x75, 0x72, 0x76, 0x65, 0x54, 0x6f, 0x10, 0x03, 0x12, 0x0b, + 0x0a, 0x07, 0x63, 0x75, 0x72, 0x76, 0x65, 0x54, 0x6f, 0x10, 0x04, 0x12, 0x10, 0x0a, 0x0c, 0x63, + 0x6c, 0x6f, 0x73, 0x65, 0x53, 0x75, 0x62, 0x70, 0x61, 0x74, 0x68, 0x10, 0x05, 0x22, 0xa0, 0x01, + 0x0a, 0x13, 0x52, 0x65, 0x66, 0x65, 0x72, 0x65, 0x6e, 0x63, 0x65, 0x44, 0x69, 0x63, 0x74, 0x69, + 0x6f, 0x6e, 0x61, 0x72, 0x79, 0x12, 0x38, 0x0a, 0x07, 0x65, 0x6e, 0x74, 0x72, 0x69, 0x65, 0x73, + 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x1e, 0x2e, 0x54, 0x53, 0x50, 0x2e, 0x52, 0x65, 0x66, + 0x65, 0x72, 0x65, 0x6e, 0x63, 0x65, 0x44, 0x69, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x61, 0x72, 0x79, + 0x2e, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x52, 0x07, 0x65, 0x6e, 0x74, 0x72, 0x69, 0x65, 0x73, 0x1a, + 0x4f, 0x0a, 0x05, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x20, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, + 0x01, 0x20, 0x02, 0x28, 0x0b, 0x32, 0x0e, 0x2e, 0x54, 0x53, 0x50, 0x2e, 0x52, 0x65, 0x66, 0x65, + 0x72, 0x65, 0x6e, 0x63, 0x65, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x24, 0x0a, 0x05, 0x76, 0x61, + 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x02, 0x28, 0x0b, 0x32, 0x0e, 0x2e, 0x54, 0x53, 0x50, 0x2e, + 0x52, 0x65, 0x66, 0x65, 0x72, 0x65, 0x6e, 0x63, 0x65, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, + 0x22, 0xaf, 0x03, 0x0a, 0x10, 0x50, 0x61, 0x73, 0x74, 0x65, 0x62, 0x6f, 0x61, 0x72, 0x64, 0x4f, + 0x62, 0x6a, 0x65, 0x63, 0x74, 0x12, 0x2e, 0x0a, 0x0a, 0x73, 0x74, 0x79, 0x6c, 0x65, 0x73, 0x68, + 0x65, 0x65, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0e, 0x2e, 0x54, 0x53, 0x50, 0x2e, + 0x52, 0x65, 0x66, 0x65, 0x72, 0x65, 0x6e, 0x63, 0x65, 0x52, 0x0a, 0x73, 0x74, 0x79, 0x6c, 0x65, + 0x73, 0x68, 0x65, 0x65, 0x74, 0x12, 0x2c, 0x0a, 0x09, 0x64, 0x72, 0x61, 0x77, 0x61, 0x62, 0x6c, + 0x65, 0x73, 0x18, 0x02, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x0e, 0x2e, 0x54, 0x53, 0x50, 0x2e, 0x52, + 0x65, 0x66, 0x65, 0x72, 0x65, 0x6e, 0x63, 0x65, 0x52, 0x09, 0x64, 0x72, 0x61, 0x77, 0x61, 0x62, + 0x6c, 0x65, 0x73, 0x12, 0x26, 0x0a, 0x06, 0x73, 0x74, 0x79, 0x6c, 0x65, 0x73, 0x18, 0x03, 0x20, + 0x03, 0x28, 0x0b, 0x32, 0x0e, 0x2e, 0x54, 0x53, 0x50, 0x2e, 0x52, 0x65, 0x66, 0x65, 0x72, 0x65, + 0x6e, 0x63, 0x65, 0x52, 0x06, 0x73, 0x74, 0x79, 0x6c, 0x65, 0x73, 0x12, 0x24, 0x0a, 0x05, 0x74, + 0x68, 0x65, 0x6d, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0e, 0x2e, 0x54, 0x53, 0x50, + 0x2e, 0x52, 0x65, 0x66, 0x65, 0x72, 0x65, 0x6e, 0x63, 0x65, 0x52, 0x05, 0x74, 0x68, 0x65, 0x6d, + 0x65, 0x12, 0x2d, 0x0a, 0x0a, 0x77, 0x70, 0x5f, 0x73, 0x74, 0x6f, 0x72, 0x61, 0x67, 0x65, 0x18, + 0x05, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0e, 0x2e, 0x54, 0x53, 0x50, 0x2e, 0x52, 0x65, 0x66, 0x65, + 0x72, 0x65, 0x6e, 0x63, 0x65, 0x52, 0x09, 0x77, 0x70, 0x53, 0x74, 0x6f, 0x72, 0x61, 0x67, 0x65, + 0x12, 0x33, 0x0a, 0x0d, 0x67, 0x75, 0x69, 0x64, 0x65, 0x5f, 0x73, 0x74, 0x6f, 0x72, 0x61, 0x67, + 0x65, 0x18, 0x09, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0e, 0x2e, 0x54, 0x53, 0x50, 0x2e, 0x52, 0x65, + 0x66, 0x65, 0x72, 0x65, 0x6e, 0x63, 0x65, 0x52, 0x0c, 0x67, 0x75, 0x69, 0x64, 0x65, 0x53, 0x74, + 0x6f, 0x72, 0x61, 0x67, 0x65, 0x12, 0x3a, 0x0a, 0x11, 0x61, 0x70, 0x70, 0x5f, 0x6e, 0x61, 0x74, + 0x69, 0x76, 0x65, 0x5f, 0x6f, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x18, 0x06, 0x20, 0x01, 0x28, 0x0b, + 0x32, 0x0e, 0x2e, 0x54, 0x53, 0x50, 0x2e, 0x52, 0x65, 0x66, 0x65, 0x72, 0x65, 0x6e, 0x63, 0x65, + 0x52, 0x0f, 0x61, 0x70, 0x70, 0x4e, 0x61, 0x74, 0x69, 0x76, 0x65, 0x4f, 0x62, 0x6a, 0x65, 0x63, + 0x74, 0x12, 0x2d, 0x0a, 0x0f, 0x69, 0x73, 0x5f, 0x74, 0x65, 0x78, 0x74, 0x5f, 0x70, 0x72, 0x69, + 0x6d, 0x61, 0x72, 0x79, 0x18, 0x07, 0x20, 0x01, 0x28, 0x08, 0x3a, 0x05, 0x66, 0x61, 0x6c, 0x73, + 0x65, 0x52, 0x0d, 0x69, 0x73, 0x54, 0x65, 0x78, 0x74, 0x50, 0x72, 0x69, 0x6d, 0x61, 0x72, 0x79, + 0x12, 0x20, 0x0a, 0x08, 0x69, 0x73, 0x5f, 0x73, 0x6d, 0x61, 0x72, 0x74, 0x18, 0x08, 0x20, 0x01, + 0x28, 0x08, 0x3a, 0x05, 0x66, 0x61, 0x6c, 0x73, 0x65, 0x52, 0x07, 0x69, 0x73, 0x53, 0x6d, 0x61, + 0x72, 0x74, 0x22, 0x5b, 0x0a, 0x0f, 0x4f, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x43, 0x6f, 0x6e, 0x74, + 0x61, 0x69, 0x6e, 0x65, 0x72, 0x12, 0x1e, 0x0a, 0x0a, 0x69, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x66, + 0x69, 0x65, 0x72, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x0a, 0x69, 0x64, 0x65, 0x6e, 0x74, + 0x69, 0x66, 0x69, 0x65, 0x72, 0x12, 0x28, 0x0a, 0x07, 0x6f, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x73, + 0x18, 0x02, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x0e, 0x2e, 0x54, 0x53, 0x50, 0x2e, 0x52, 0x65, 0x66, + 0x65, 0x72, 0x65, 0x6e, 0x63, 0x65, 0x52, 0x07, 0x6f, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x73, 0x42, + 0x20, 0x5a, 0x1e, 0x63, 0x6f, 0x64, 0x65, 0x2e, 0x73, 0x61, 0x6a, 0x61, 0x72, 0x69, 0x2e, 0x63, + 0x6f, 0x6d, 0x2f, 0x64, 0x6f, 0x63, 0x63, 0x6f, 0x6e, 0x76, 0x2f, 0x76, 0x32, 0x2f, 0x74, 0x73, + 0x70, +} + +var ( + file_TSPMessages_proto_rawDescOnce sync.Once + file_TSPMessages_proto_rawDescData = file_TSPMessages_proto_rawDesc +) + +func file_TSPMessages_proto_rawDescGZIP() []byte { + file_TSPMessages_proto_rawDescOnce.Do(func() { + file_TSPMessages_proto_rawDescData = protoimpl.X.CompressGZIP(file_TSPMessages_proto_rawDescData) + }) + return file_TSPMessages_proto_rawDescData +} + +var file_TSPMessages_proto_enumTypes = make([]protoimpl.EnumInfo, 2) +var file_TSPMessages_proto_msgTypes = make([]protoimpl.MessageInfo, 14) +var file_TSPMessages_proto_goTypes = []interface{}{ + (Color_ColorModel)(0), // 0: TSP.Color.ColorModel + (Path_ElementType)(0), // 1: TSP.Path.ElementType + (*Reference)(nil), // 2: TSP.Reference + (*DataReference)(nil), // 3: TSP.DataReference + (*Point)(nil), // 4: TSP.Point + (*Size)(nil), // 5: TSP.Size + (*Range)(nil), // 6: TSP.Range + (*Date)(nil), // 7: TSP.Date + (*IndexSet)(nil), // 8: TSP.IndexSet + (*Color)(nil), // 9: TSP.Color + (*Path)(nil), // 10: TSP.Path + (*ReferenceDictionary)(nil), // 11: TSP.ReferenceDictionary + (*PasteboardObject)(nil), // 12: TSP.PasteboardObject + (*ObjectContainer)(nil), // 13: TSP.ObjectContainer + (*Path_Element)(nil), // 14: TSP.Path.Element + (*ReferenceDictionary_Entry)(nil), // 15: TSP.ReferenceDictionary.Entry +} +var file_TSPMessages_proto_depIdxs = []int32{ + 6, // 0: TSP.IndexSet.ranges:type_name -> TSP.Range + 0, // 1: TSP.Color.model:type_name -> TSP.Color.ColorModel + 14, // 2: TSP.Path.elements:type_name -> TSP.Path.Element + 15, // 3: TSP.ReferenceDictionary.entries:type_name -> TSP.ReferenceDictionary.Entry + 2, // 4: TSP.PasteboardObject.stylesheet:type_name -> TSP.Reference + 2, // 5: TSP.PasteboardObject.drawables:type_name -> TSP.Reference + 2, // 6: TSP.PasteboardObject.styles:type_name -> TSP.Reference + 2, // 7: TSP.PasteboardObject.theme:type_name -> TSP.Reference + 2, // 8: TSP.PasteboardObject.wp_storage:type_name -> TSP.Reference + 2, // 9: TSP.PasteboardObject.guide_storage:type_name -> TSP.Reference + 2, // 10: TSP.PasteboardObject.app_native_object:type_name -> TSP.Reference + 2, // 11: TSP.ObjectContainer.objects:type_name -> TSP.Reference + 1, // 12: TSP.Path.Element.type:type_name -> TSP.Path.ElementType + 4, // 13: TSP.Path.Element.points:type_name -> TSP.Point + 2, // 14: TSP.ReferenceDictionary.Entry.key:type_name -> TSP.Reference + 2, // 15: TSP.ReferenceDictionary.Entry.value:type_name -> TSP.Reference + 16, // [16:16] is the sub-list for method output_type + 16, // [16:16] is the sub-list for method input_type + 16, // [16:16] is the sub-list for extension type_name + 16, // [16:16] is the sub-list for extension extendee + 0, // [0:16] is the sub-list for field type_name +} + +func init() { file_TSPMessages_proto_init() } +func file_TSPMessages_proto_init() { + if File_TSPMessages_proto != nil { + return + } + if !protoimpl.UnsafeEnabled { + file_TSPMessages_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*Reference); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_TSPMessages_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*DataReference); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_TSPMessages_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*Point); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_TSPMessages_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*Size); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_TSPMessages_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*Range); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_TSPMessages_proto_msgTypes[5].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*Date); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_TSPMessages_proto_msgTypes[6].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*IndexSet); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_TSPMessages_proto_msgTypes[7].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*Color); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_TSPMessages_proto_msgTypes[8].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*Path); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_TSPMessages_proto_msgTypes[9].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*ReferenceDictionary); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_TSPMessages_proto_msgTypes[10].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*PasteboardObject); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_TSPMessages_proto_msgTypes[11].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*ObjectContainer); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_TSPMessages_proto_msgTypes[12].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*Path_Element); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_TSPMessages_proto_msgTypes[13].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*ReferenceDictionary_Entry); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + } + type x struct{} + out := protoimpl.TypeBuilder{ + File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), + RawDescriptor: file_TSPMessages_proto_rawDesc, + NumEnums: 2, + NumMessages: 14, + NumExtensions: 0, + NumServices: 0, + }, + GoTypes: file_TSPMessages_proto_goTypes, + DependencyIndexes: file_TSPMessages_proto_depIdxs, + EnumInfos: file_TSPMessages_proto_enumTypes, + MessageInfos: file_TSPMessages_proto_msgTypes, + }.Build() + File_TSPMessages_proto = out.File + file_TSPMessages_proto_rawDesc = nil + file_TSPMessages_proto_goTypes = nil + file_TSPMessages_proto_depIdxs = nil } diff --git a/iWork/generate.sh b/iWork/generate.sh new file mode 100755 index 0000000..43da203 --- /dev/null +++ b/iWork/generate.sh @@ -0,0 +1,21 @@ +#!/usr/bin/env bash +# Generate code from protos stored in pb-schema. + +set -euo pipefail + +cd "$(dirname "$0")" + +function ensure_installed() { + command -v "$1" >/dev/null 2>&1 || { + echo >&2 "Could not find $1, please ensure it is installed." + echo "Try running: $2" + exit 1 + } +} + +ensure_installed protoc "brew install protobuf" +ensure_installed protoc-gen-go "go install google.golang.org/protobuf/cmd/protoc-gen-go@latest" + +protoc -I=./pb-schema --go_out=paths=source_relative:. TSPArchiveMessages.proto +protoc -I=./pb-schema --go_out=paths=source_relative:. TSPDatabaseMessages.proto +protoc -I=./pb-schema --go_out=paths=source_relative:. TSPMessages.proto diff --git a/iWork/pb-schema/TSPArchiveMessages.proto b/iWork/pb-schema/TSPArchiveMessages.proto index 7d7ef16..fe918a5 100755 --- a/iWork/pb-schema/TSPArchiveMessages.proto +++ b/iWork/pb-schema/TSPArchiveMessages.proto @@ -1,5 +1,7 @@ syntax = "proto2"; +option go_package = "code.sajari.com/docconv/v2/tsp"; + package TSP; message ArchiveInfo { diff --git a/iWork/pb-schema/TSPDatabaseMessages.proto b/iWork/pb-schema/TSPDatabaseMessages.proto index 361222b..9bc3be8 100755 --- a/iWork/pb-schema/TSPDatabaseMessages.proto +++ b/iWork/pb-schema/TSPDatabaseMessages.proto @@ -1,5 +1,7 @@ syntax = "proto2"; +option go_package = "code.sajari.com/docconv/v2/tsp"; + import "TSPMessages.proto"; package TSP; @@ -25,4 +27,3 @@ message DatabaseImageDataArchive { required .TSP.DatabaseDataArchive super = 1; required .TSP.DatabaseImageDataArchive.ImageType type = 2; } - diff --git a/iWork/pb-schema/TSPMessages.proto b/iWork/pb-schema/TSPMessages.proto index edc960c..0fb881c 100755 --- a/iWork/pb-schema/TSPMessages.proto +++ b/iWork/pb-schema/TSPMessages.proto @@ -1,5 +1,7 @@ syntax = "proto2"; +option go_package = "code.sajari.com/docconv/v2/tsp"; + package TSP; message Reference { @@ -92,4 +94,3 @@ message ObjectContainer { optional uint32 identifier = 1; repeated .TSP.Reference objects = 2; } - diff --git a/image.go b/image.go index 0b2c6cf..e8c60b5 100644 --- a/image.go +++ b/image.go @@ -1,4 +1,4 @@ -// +build !ocr +//go:build !ocr package docconv diff --git a/image_ocr.go b/image_ocr.go index 6447309..9c9fb29 100644 --- a/image_ocr.go +++ b/image_ocr.go @@ -1,4 +1,4 @@ -// +build ocr +//go:build ocr package docconv diff --git a/image_ocr_test.go b/image_ocr_test.go index 46db151..c48c9f1 100644 --- a/image_ocr_test.go +++ b/image_ocr_test.go @@ -1,4 +1,4 @@ -// +build ocr +//go:build ocr package docconv diff --git a/limit.go b/limit.go new file mode 100644 index 0000000..8ef2940 --- /dev/null +++ b/limit.go @@ -0,0 +1,3 @@ +package docconv + +const maxBytes = 20 << 20 // 20MB diff --git a/local.go b/local.go index 40bcc99..02e6a62 100644 --- a/local.go +++ b/local.go @@ -3,7 +3,6 @@ package docconv import ( "fmt" "io" - "io/ioutil" "os" ) @@ -25,7 +24,7 @@ func NewLocalFile(r io.Reader) (*LocalFile, error) { }, nil } - f, err := ioutil.TempFile(os.TempDir(), "/docconv") + f, err := os.CreateTemp(os.TempDir(), "docconv") if err != nil { return nil, fmt.Errorf("error creating temporary file: %v", err) } diff --git a/local_test.go b/local_test.go new file mode 100644 index 0000000..0b1ab34 --- /dev/null +++ b/local_test.go @@ -0,0 +1,13 @@ +package docconv + +import ( + "strings" + "testing" +) + +func TestNewLocalFile(t *testing.T) { + _, err := NewLocalFile(strings.NewReader("test")) + if err != nil { + t.Fatalf("got error %v, want nil", err) + } +} diff --git a/odt.go b/odt.go index 68dd968..a45fbe7 100644 --- a/odt.go +++ b/odt.go @@ -5,7 +5,6 @@ import ( "bytes" "fmt" "io" - "io/ioutil" "time" ) @@ -14,7 +13,7 @@ func ConvertODT(r io.Reader) (string, map[string]string, error) { meta := make(map[string]string) var textBody string - b, err := ioutil.ReadAll(r) + b, err := io.ReadAll(io.LimitReader(r, maxBytes)) if err != nil { return "", nil, err } diff --git a/pages.go b/pages.go index c288314..0085669 100644 --- a/pages.go +++ b/pages.go @@ -7,13 +7,12 @@ import ( "encoding/binary" "fmt" "io" - "io/ioutil" "strings" - "github.com/golang/protobuf/proto" + "google.golang.org/protobuf/proto" - "code.sajari.com/docconv/iWork" - "code.sajari.com/docconv/snappy" + TSP "code.sajari.com/docconv/v2/iWork" + "code.sajari.com/docconv/v2/snappy" ) // ConvertPages converts a Pages file to text. @@ -21,7 +20,7 @@ func ConvertPages(r io.Reader) (string, map[string]string, error) { meta := make(map[string]string) var textBody string - b, err := ioutil.ReadAll(r) + b, err := io.ReadAll(io.LimitReader(r, maxBytes)) if err != nil { return "", nil, fmt.Errorf("error reading data: %v", err) } @@ -48,8 +47,17 @@ func ConvertPages(r io.Reader) (string, map[string]string, error) { rc, _ := f.Open() defer rc.Close() bReader := bufio.NewReader(snappy.NewReader(io.MultiReader(strings.NewReader("\xff\x06\x00\x00sNaPpY"), rc))) - archiveLength, err := binary.ReadVarint(bReader) - archiveInfoData, err := ioutil.ReadAll(io.LimitReader(bReader, archiveLength)) + + // Ignore error. + // NOTE: This error was unchecked. Need to revisit this to see if it + // should be acted on. + archiveLength, _ := binary.ReadVarint(bReader) + + // Ignore error. + // NOTE: This error was unchecked. Need to revisit this to see if it + // should be acted on. + archiveInfoData, _ := io.ReadAll(io.LimitReader(bReader, archiveLength)) + archiveInfo := &TSP.ArchiveInfo{} err = proto.Unmarshal(archiveInfoData, archiveInfo) fmt.Println("archiveInfo:", archiveInfo, err) diff --git a/pdf.go b/pdf.go index e5920d2..6a6a118 100644 --- a/pdf.go +++ b/pdf.go @@ -1,4 +1,4 @@ -// +build !ocr +//go:build !ocr package docconv @@ -8,7 +8,6 @@ import ( ) func ConvertPDF(r io.Reader) (string, map[string]string, error) { - f, err := NewLocalFile(r) if err != nil { return "", nil, fmt.Errorf("error creating local file: %v", err) diff --git a/pdf_ocr.go b/pdf_ocr.go index 4d9d53a..dc96515 100644 --- a/pdf_ocr.go +++ b/pdf_ocr.go @@ -1,15 +1,14 @@ -// +build ocr +//go:build ocr package docconv import ( "fmt" "io" - "io/ioutil" - "log" "os" "os/exec" "path/filepath" + "regexp" "strings" "sync" ) @@ -27,24 +26,19 @@ func compareExt(ext string, exts []string) bool { return false } -func cleanupTemp(tmpDir string) { - err := os.RemoveAll(tmpDir) - if err != nil { - log.Println(err) - } -} - func ConvertPDFImages(path string) (BodyResult, error) { bodyResult := BodyResult{} - tmp, err := ioutil.TempDir(os.TempDir(), "tmp-imgs-") + tmp, err := os.MkdirTemp(os.TempDir(), "tmp-imgs-") if err != nil { bodyResult.err = err return bodyResult, err } tmpDir := fmt.Sprintf("%s/", tmp) - defer cleanupTemp(tmpDir) + defer func() { + _ = os.RemoveAll(tmpDir) // ignore error + }() _, err = exec.Command("pdfimages", "-j", path, tmpDir).Output() if err != nil { @@ -109,17 +103,17 @@ func ConvertPDFImages(path string) (BodyResult, error) { } // PdfHasImage verify if `path` (PDF) has images -func PDFHasImage(path string) bool { +func PDFHasImage(path string) (bool, error) { cmd := "pdffonts -l 5 %s | tail -n +3 | cut -d' ' -f1 | sort | uniq" - out, err := exec.Command("bash", "-c", fmt.Sprintf(cmd, path)).Output() + out, err := exec.Command("bash", "-c", fmt.Sprintf(cmd, shellEscape(path))).CombinedOutput() + if err != nil { - log.Println(err) - return false + return false, err } if string(out) == "" { - return true + return true, nil } - return false + return false, nil } func ConvertPDF(r io.Reader) (string, map[string]string, error) { @@ -140,18 +134,20 @@ func ConvertPDF(r io.Reader) (string, map[string]string, error) { return "", nil, metaResult.err } - if !PDFHasImage(f.Name()) { + hasImage, err := PDFHasImage(f.Name()) + if err != nil { + return "", nil, fmt.Errorf("could not check if PDF has image: %w", err) + } + if !hasImage { return bodyResult.body, metaResult.meta, nil } imageConvertResult, imageConvertErr := ConvertPDFImages(f.Name()) if imageConvertErr != nil { - log.Println(imageConvertErr) - return bodyResult.body, metaResult.meta, nil + return bodyResult.body, metaResult.meta, nil // ignore error, return what we have } if imageConvertResult.err != nil { - log.Println(imageConvertResult.err) - return bodyResult.body, metaResult.meta, nil + return bodyResult.body, metaResult.meta, nil // ignore error, return what we have } fullBody := strings.Join([]string{bodyResult.body, imageConvertResult.body}, " ") @@ -159,3 +155,22 @@ func ConvertPDF(r io.Reader) (string, map[string]string, error) { return fullBody, metaResult.meta, nil } + +var shellEscapePattern *regexp.Regexp + +func init() { + shellEscapePattern = regexp.MustCompile(`[^\w@%+=:,./-]`) +} + +// shellEscape returns a shell-escaped version of the string s. The returned value +// is a string that can safely be used as one token in a shell command line. +func shellEscape(s string) string { + if len(s) == 0 { + return "''" + } + if shellEscapePattern.MatchString(s) { + return "'" + strings.Replace(s, "'", "'\"'\"'", -1) + "'" + } + + return s +} diff --git a/pdf_ocr_test.go b/pdf_ocr_test.go new file mode 100644 index 0000000..f0d3bff --- /dev/null +++ b/pdf_ocr_test.go @@ -0,0 +1,33 @@ +//go:build ocr + +package docconv + +import ( + "os" + "testing" +) + +func TestPDFHasImage_CannotExecuteCode(t *testing.T) { + // Try to inject code by passing a bad file path. + // If the code was successful it will create a file called foo in the working directory + badFilePath := "$(id >> foo).pdf" + got, err := PDFHasImage(badFilePath) + if err != nil { + t.Fatal(err) + } + if want := false; got != want { + t.Errorf("got %v, want %v", got, want) + } + + if got, want := fileExists("foo"), false; got != want { + t.Errorf("got bad file exists, want not file to exist") + } +} + +func fileExists(filename string) bool { + info, err := os.Stat(filename) + if os.IsNotExist(err) { + return false + } + return !info.IsDir() +} diff --git a/pptx.go b/pptx.go index a0cb839..c79979c 100644 --- a/pptx.go +++ b/pptx.go @@ -5,7 +5,6 @@ import ( "bytes" "fmt" "io" - "io/ioutil" "os" "strings" ) @@ -28,7 +27,7 @@ func ConvertPptx(r io.Reader) (string, map[string]string, error) { size = si.Size() ra = f } else { - b, err := ioutil.ReadAll(r) + b, err := io.ReadAll(r) if err != nil { return "", nil, nil } diff --git a/pptx_test/pptx_test.go b/pptx_test/pptx_test.go index b936e3f..696fe5f 100644 --- a/pptx_test/pptx_test.go +++ b/pptx_test/pptx_test.go @@ -1,15 +1,19 @@ package docx_test import ( + "encoding/xml" "os" "strings" "testing" - "code.sajari.com/docconv" + "code.sajari.com/docconv/v2" ) func TestConvertPptx(t *testing.T) { f, err := os.Open("./testdata/sample.pptx") + if err != nil { + t.Fatal(err) + } defer f.Close() if err != nil { @@ -27,3 +31,17 @@ func TestConvertPptx(t *testing.T) { t.Errorf("expected %v to contain %v", resp, want) } } + +func TestConvertPptxDecompressionSizeLimit(t *testing.T) { + f, err := os.Open("./testdata/decompression_size_limit.pptx") + if err != nil { + t.Fatalf("got error = %v, want nil", err) + } + _, _, err = docconv.ConvertPptx(f) + if _, ok := err.(*xml.SyntaxError); !ok { + t.Errorf("got error = %T, want *xml.SyntaxError", err) + } + if want := "EOF"; !strings.Contains(err.Error(), want) { + t.Errorf("got error = %v, want %v", err, want) + } +} diff --git a/pptx_test/testdata/decompression_size_limit.pptx b/pptx_test/testdata/decompression_size_limit.pptx new file mode 100755 index 0000000..4ea761f Binary files /dev/null and b/pptx_test/testdata/decompression_size_limit.pptx differ diff --git a/rtf.go b/rtf.go index 98e1363..6fea0e3 100644 --- a/rtf.go +++ b/rtf.go @@ -28,7 +28,7 @@ func ConvertRTF(r io.Reader) (string, map[string]string, error) { if parts := strings.SplitN(line, ":", 2); len(parts) > 1 { meta[strings.TrimSpace(parts[0])] = strings.TrimSpace(parts[1]) } - if len(line) > 4 && line[:4] != "### " { + if !strings.HasPrefix(line, "### ") { output += line + "\n" } } diff --git a/rtf_test/rtf_test.go b/rtf_test/rtf_test.go new file mode 100644 index 0000000..af14a81 --- /dev/null +++ b/rtf_test/rtf_test.go @@ -0,0 +1,38 @@ +package rtf_test + +import ( + "bytes" + "os" + "strings" + "testing" + + "code.sajari.com/docconv/v2" +) + +func TestConvertRTF(t *testing.T) { + data, err := os.ReadFile("testdata/test.rtf") + if err != nil { + t.Fatalf("got error %v, want nil", err) + } + res, _, err := docconv.ConvertRTF(bytes.NewReader(data)) + if err != nil { + t.Fatalf("got error %v, want nil", err) + } + lines := strings.Split(res, "\n")[2:] + line, expectedLine := lines[0], "hello world" + if line != expectedLine { + t.Fatalf("got %s, want %s", line, expectedLine) + } + line, expectedLine = lines[1], "helo" + if line != expectedLine { + t.Fatalf("got %s, want %s", line, expectedLine) + } + line, expectedLine = lines[2], "" + if line != expectedLine { + t.Fatalf("got %s, want %s", line, expectedLine) + } + line, expectedLine = lines[3], "1" + if line != expectedLine { + t.Fatalf("got %s, want %s", line, expectedLine) + } +} diff --git a/rtf_test/testdata/test.rtf b/rtf_test/testdata/test.rtf new file mode 100644 index 0000000..502cca6 --- /dev/null +++ b/rtf_test/testdata/test.rtf @@ -0,0 +1,23 @@ +{\rtf1\ansi\deff3\adeflang1025 +{\fonttbl{\f0\froman\fprq2\fcharset0 Times New Roman;}{\f1\froman\fprq2\fcharset2 Symbol;}{\f2\fswiss\fprq2\fcharset0 Arial;}{\f3\froman\fprq2\fcharset0 Liberation Serif{\*\falt Times New Roman};}{\f4\froman\fprq2\fcharset0 Liberation Sans{\*\falt Arial};}{\f5\fnil\fprq2\fcharset0 Lohit Devanagari;}{\f6\fnil\fprq2\fcharset0 Liberation Serif{\*\falt Times New Roman};}} +{\colortbl;\red0\green0\blue0;\red0\green0\blue255;\red0\green255\blue255;\red0\green255\blue0;\red255\green0\blue255;\red255\green0\blue0;\red255\green255\blue0;\red255\green255\blue255;\red0\green0\blue128;\red0\green128\blue128;\red0\green128\blue0;\red128\green0\blue128;\red128\green0\blue0;\red128\green128\blue0;\red128\green128\blue128;\red192\green192\blue192;} +{\stylesheet{\s0\snext0\dbch\af5\langfe1081\dbch\af6\afs24\alang1081\ql\widctlpar\hyphpar0\ltrpar\cf0\loch\f3\fs24\lang1033\kerning1 Normal;} +{\s15\sbasedon0\snext16\dbch\af5\langfe1081\dbch\af6\afs28\ql\widctlpar\hyphpar0\sb240\sa120\keepn\ltrpar\cf0\loch\f4\fs28\lang1033\kerning1 Heading;} +{\s16\sbasedon0\snext16\dbch\af5\langfe1081\dbch\af6\afs24\ql\sl276\slmult1\widctlpar\hyphpar0\sb0\sa140\ltrpar\cf0\loch\f3\fs24\lang1033\kerning1 Text Body;} +{\s17\sbasedon16\snext17\dbch\af5\langfe1081\dbch\af6\afs24\ql\sl276\slmult1\widctlpar\hyphpar0\sb0\sa140\ltrpar\cf0\loch\f3\fs24\lang1033\kerning1 List;} +{\s18\sbasedon0\snext18\dbch\af5\langfe1081\dbch\af6\afs24\ai\ql\widctlpar\hyphpar0\sb120\sa120\ltrpar\cf0\loch\f3\fs24\lang1033\kerning1 Caption;} +{\s19\sbasedon0\snext19\dbch\af5\langfe1081\dbch\af6\afs24\ql\widctlpar\hyphpar0\ltrpar\cf0\loch\f3\fs24\lang1033\kerning1 Index;} +}{\*\generator LibreOffice/6.4.6.2$Linux_X86_64 LibreOffice_project/40$Build-2}{\info{\creatim\yr2021\mo3\dy29\hr11\min30}{\revtim\yr2021\mo4\dy9\hr16\min36}{\printim\yr0\mo0\dy0\hr0\min0}}{\*\userprops}\deftab709 +\hyphauto1\viewscale100 +{\*\pgdsctbl +{\pgdsc0\pgdscuse451\pgwsxn11906\pghsxn16838\marglsxn1134\margrsxn1134\margtsxn1134\margbsxn1134\pgdscnxt0 Default Style;}} +\formshade{\*\pgdscno0}\paperh16838\paperw11906\margl1134\margr1134\margt1134\margb1134\sectd\sbknone\sectunlocked1\pgndec\pgwsxn11906\pghsxn16838\marglsxn1134\margrsxn1134\margtsxn1134\margbsxn1134\ftnbj\ftnstart1\ftnrstcont\ftnnar\aenddoc\aftnrstcont\aftnstart1\aftnnrlc +{\*\ftnsep\chftnsep}\pgndec\pard\plain \s0\dbch\af5\langfe1081\dbch\af6\afs24\alang1081\ql\widctlpar\hyphpar0\ltrpar\cf0\loch\f3\fs24\lang1033\kerning1\ql{\rtlch\dbch\af5\langfe1081\dbch\af6\afs24 \ltrch\cf0\fs24\lang1033\kerning1\loch +hello world} +\par \pard\plain \s0\dbch\af5\langfe1081\dbch\af6\afs24\alang1081\ql\widctlpar\hyphpar0\ltrpar\cf0\loch\f3\fs24\lang1033\kerning1\ql{\rtlch\dbch\af5\langfe1081\dbch\af6\afs24 \ltrch\cf0\fs24\lang1033\kerning1\loch +helo} +\par \pard\plain \s0\dbch\af5\langfe1081\dbch\af6\afs24\alang1081\ql\widctlpar\hyphpar0\ltrpar\cf0\loch\f3\fs24\lang1033\kerning1\ql{\rtlch\dbch\af5\langfe1081\dbch\af6\afs24 \ltrch\cf0\fs24\lang1033\kerning1\loch +} +\par \pard\plain \s0\dbch\af5\langfe1081\dbch\af6\afs24\alang1081\ql\widctlpar\hyphpar0\ltrpar\cf0\loch\f3\fs24\lang1033\kerning1\ql{\rtlch\dbch\af5\langfe1081\dbch\af6\afs24 \ltrch\cf0\fs24\lang1033\kerning1\loch +1} +\par } \ No newline at end of file diff --git a/snappy/snappy_test.go b/snappy/snappy_test.go index 940f79a..923bab7 100644 --- a/snappy/snappy_test.go +++ b/snappy/snappy_test.go @@ -9,7 +9,6 @@ import ( "flag" "fmt" "io" - "io/ioutil" "math/rand" "net/http" "os" @@ -119,7 +118,7 @@ func TestFramingFormat(t *testing.T) { if _, err := NewWriter(buf).Write(src); err != nil { t.Fatalf("Write: encoding: %v", err) } - dst, err := ioutil.ReadAll(NewReader(buf)) + dst, err := io.ReadAll(NewReader(buf)) if err != nil { t.Fatalf("ReadAll: decoding: %v", err) } @@ -149,7 +148,7 @@ func TestReaderReset(t *testing.T) { continue } r.Reset(strings.NewReader(s)) - got, err := ioutil.ReadAll(r) + got, err := io.ReadAll(r) switch s { case encoded: if err != nil { @@ -186,7 +185,7 @@ func TestWriterReset(t *testing.T) { failed = true continue } - got, err := ioutil.ReadAll(NewReader(buf)) + got, err := io.ReadAll(NewReader(buf)) if err != nil { t.Errorf("#%d: ReadAll: %v", i, err) failed = true @@ -229,7 +228,7 @@ func benchEncode(b *testing.B, src []byte) { } func readFile(b testing.TB, filename string) []byte { - src, err := ioutil.ReadFile(filename) + src, err := os.ReadFile(filename) if err != nil { b.Fatalf("failed reading %s: %s", filename, err) } diff --git a/testdata/001-test.doc b/testdata/001-test.doc new file mode 100644 index 0000000..e1e9f64 Binary files /dev/null and b/testdata/001-test.doc differ diff --git a/tidy.go b/tidy.go index b120ee5..e0f23a7 100644 --- a/tidy.go +++ b/tidy.go @@ -2,7 +2,6 @@ package docconv import ( "io" - "io/ioutil" "os" "os/exec" ) @@ -11,7 +10,7 @@ import ( // Errors & warnings are deliberately suppressed as underlying tools // throw warnings very easily. func Tidy(r io.Reader, xmlIn bool) ([]byte, error) { - f, err := ioutil.TempFile(os.TempDir(), "/docconv") + f, err := os.CreateTemp(os.TempDir(), "docconv") if err != nil { return nil, err } diff --git a/xml.go b/xml.go index 8f422a3..28da02e 100644 --- a/xml.go +++ b/xml.go @@ -25,7 +25,7 @@ func ConvertXML(r io.Reader) (string, map[string]string, error) { func XMLToText(r io.Reader, breaks []string, skip []string, strict bool) (string, error) { var result string - dec := xml.NewDecoder(r) + dec := xml.NewDecoder(io.LimitReader(r, maxBytes)) dec.Strict = strict for { t, err := dec.Token() @@ -76,7 +76,7 @@ func XMLToText(r io.Reader, breaks []string, skip []string, strict bool) (string // XMLToMap converts XML to a nested string map. func XMLToMap(r io.Reader) (map[string]string, error) { m := make(map[string]string) - dec := xml.NewDecoder(r) + dec := xml.NewDecoder(io.LimitReader(r, maxBytes)) var tagName string for { t, err := dec.Token()