mirror of
https://github.com/superseriousbusiness/gotosocial.git
synced 2025-11-02 17:52:25 -06:00
[chore] Update all but bun libraries (#526)
* update all but bun libraries Signed-off-by: kim <grufwub@gmail.com> * remove my personal build script changes Signed-off-by: kim <grufwub@gmail.com>
This commit is contained in:
parent
e06bf9cc9a
commit
b56dae8120
350 changed files with 305366 additions and 5943 deletions
10
vendor/github.com/tdewolff/minify/v2/.gitignore
generated
vendored
10
vendor/github.com/tdewolff/minify/v2/.gitignore
generated
vendored
|
|
@ -1,3 +1,4 @@
|
|||
release.sh
|
||||
dist/
|
||||
benchmarks/*
|
||||
!benchmarks/*.go
|
||||
|
|
@ -12,3 +13,12 @@ parse/tests/*/crashers
|
|||
parse/tests/*/suppressions
|
||||
parse/tests/*/corpus/*
|
||||
!parse/tests/*/corpus/*.*
|
||||
bindings/js/build
|
||||
bindings/js/minify.h
|
||||
bindings/js/minify.a
|
||||
bindings/js/test.min.html
|
||||
bindings/js/node_modules
|
||||
bindings/py/minify.h
|
||||
bindings/py/minify.so
|
||||
bindings/py/test.min.html
|
||||
bindings/py/tdewolff_minify.egg-info
|
||||
|
|
|
|||
6
vendor/github.com/tdewolff/minify/v2/Dockerfile
generated
vendored
6
vendor/github.com/tdewolff/minify/v2/Dockerfile
generated
vendored
|
|
@ -1,12 +1,12 @@
|
|||
# Use this image to build the executable
|
||||
FROM golang:1.16-alpine AS compiler
|
||||
|
||||
RUN apk add --no-cache git ca-certificates make
|
||||
|
||||
WORKDIR $GOPATH/src/minify
|
||||
COPY . .
|
||||
|
||||
RUN apk add --update --update-cache --no-cache git ca-certificates && \
|
||||
GO111MODULES=on CGO_ENABLED=0 go build -ldflags "-s -w" -trimpath -o /bin/minify ./cmd/minify
|
||||
|
||||
RUN /usr/bin/env bash -c make install
|
||||
|
||||
# Final image containing the executable from the previous step
|
||||
FROM alpine:3
|
||||
|
|
|
|||
4
vendor/github.com/tdewolff/minify/v2/Makefile
generated
vendored
4
vendor/github.com/tdewolff/minify/v2/Makefile
generated
vendored
|
|
@ -1,3 +1,4 @@
|
|||
SHELL=/usr/bin/env bash
|
||||
NAME=minify
|
||||
CMD=./cmd/minify
|
||||
TARGETS=linux_amd64 darwin_amd64 freebsd_amd64 netbsd_amd64 openbsd_amd64 windows_amd64
|
||||
|
|
@ -17,8 +18,9 @@ release:
|
|||
if [ "${.SHELLSTATUS}" -eq 0 ]; then \
|
||||
echo "Releasing ${VERSION}"; \
|
||||
else \
|
||||
echo "WARNING: commit is not tagged with a version"; \
|
||||
echo "ERROR: commit is not tagged with a version"; \
|
||||
echo ""; \
|
||||
exit 1; \
|
||||
fi
|
||||
rm -rf dist
|
||||
mkdir -p dist
|
||||
|
|
|
|||
38
vendor/github.com/tdewolff/minify/v2/README.md
generated
vendored
38
vendor/github.com/tdewolff/minify/v2/README.md
generated
vendored
|
|
@ -1,13 +1,13 @@
|
|||
# Minify <a name="minify"></a> [](https://pkg.go.dev/github.com/tdewolff/minify/v2?tab=doc) [](https://goreportcard.com/report/github.com/tdewolff/minify) [](https://codecov.io/gh/tdewolff/minify) [](https://www.patreon.com/tdewolff)
|
||||
|
||||
**[Online demo](https://go.tacodewolff.nl/minify) if you need to minify files *now*.**
|
||||
**[Online demo](https://go.tacodewolff.nl/minify)** if you need to minify files *now*.
|
||||
|
||||
**[Command line tool](https://github.com/tdewolff/minify/tree/master/cmd/minify) that minifies concurrently and watches file changes.**
|
||||
**[Binaries](https://github.com/tdewolff/minify/releases) of CLI for various platforms.** See [CLI](https://github.com/tdewolff/minify/tree/master/cmd/minify) for more installation instructions.
|
||||
|
||||
**[Releases](https://github.com/tdewolff/minify/releases) of CLI for various platforms.** See [CLI](https://github.com/tdewolff/minify/tree/master/cmd/minify) for more installation instructions.
|
||||
**[Python bindings](https://pypi.org/project/tdewolff-minify/)** install with `pip install tdewolff-minify`
|
||||
|
||||
**[JavaScript bindings](https://www.npmjs.com/package/tdewolff-minify)**
|
||||
|
||||
**[Parse](https://github.com/tdewolff/minify/tree/master/parse) subpackage on which minify depends.**
|
||||
|
||||
---
|
||||
|
||||
*Did you know that the shortest valid piece of HTML5 is `<!doctype html><title>x</title>`? See for yourself at the [W3C Validator](http://validator.w3.org/)!*
|
||||
|
|
@ -600,7 +600,33 @@ func main() {
|
|||
m.AddFuncRegexp(regexp.MustCompile("[/+]xml$"), xml.Minify)
|
||||
|
||||
fs := http.FileServer(http.Dir("www/"))
|
||||
http.Handle("/", m.Middleware(fs))
|
||||
http.Handle("/", m.MiddlewareWithError(fs))
|
||||
}
|
||||
|
||||
func handleError(w http.ResponseWriter, r *http.Request, err error) {
|
||||
http.Error(w, err.Error(), http.StatusInternalServerError)
|
||||
}
|
||||
```
|
||||
|
||||
In order to properly handle minify errors, it is necessary to close the response writer since all writes are concurrently handled. There is no need to check errors on writes since they will be returned on closing.
|
||||
|
||||
```go
|
||||
func main() {
|
||||
m := minify.New()
|
||||
m.AddFunc("text/html", html.Minify)
|
||||
m.AddFuncRegexp(regexp.MustCompile("^(application|text)/(x-)?(java|ecma)script$"), js.Minify)
|
||||
|
||||
input := `<script>const i = 1_000_</script>` // Faulty JS
|
||||
req := httptest.NewRequest(http.MethodGet, "/", nil)
|
||||
rec := httptest.NewRecorder()
|
||||
m.Middleware(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
w.Header().Set("Content-Type", "text/html")
|
||||
_, _ = w.Write([]byte(input))
|
||||
|
||||
if err = w.(io.Closer).Close(); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
})).ServeHTTP(rec, req)
|
||||
}
|
||||
```
|
||||
|
||||
|
|
|
|||
6
vendor/github.com/tdewolff/minify/v2/html/html.go
generated
vendored
6
vendor/github.com/tdewolff/minify/v2/html/html.go
generated
vendored
|
|
@ -274,10 +274,10 @@ func (o *Minifier) Minify(m *minify.M, w io.Writer, r io.Reader, _ map[string]st
|
|||
}
|
||||
}
|
||||
|
||||
if o.KeepWhitespace || t.Traits&objectTag != 0 {
|
||||
omitSpace = false
|
||||
} else if t.Traits&nonPhrasingTag != 0 {
|
||||
if t.Traits&nonPhrasingTag != 0 {
|
||||
omitSpace = true // omit spaces after block elements
|
||||
} else if o.KeepWhitespace || t.Traits&objectTag != 0 {
|
||||
omitSpace = false
|
||||
}
|
||||
|
||||
if !omitEndTag {
|
||||
|
|
|
|||
2
vendor/github.com/tdewolff/minify/v2/html/table.go
generated
vendored
2
vendor/github.com/tdewolff/minify/v2/html/table.go
generated
vendored
|
|
@ -35,7 +35,7 @@ var tagMap = map[Hash]traits{
|
|||
Body: nonPhrasingTag,
|
||||
Br: nonPhrasingTag,
|
||||
Button: objectTag,
|
||||
Canvas: objectTag,
|
||||
Canvas: objectTag | keepPTag,
|
||||
Caption: nonPhrasingTag,
|
||||
Cite: normalTag,
|
||||
Code: normalTag,
|
||||
|
|
|
|||
72
vendor/github.com/tdewolff/minify/v2/minify.go
generated
vendored
72
vendor/github.com/tdewolff/minify/v2/minify.go
generated
vendored
|
|
@ -28,6 +28,9 @@ var Warning = log.New(os.Stderr, "WARNING: ", 0)
|
|||
// ErrNotExist is returned when no minifier exists for a given mimetype.
|
||||
var ErrNotExist = errors.New("minifier does not exist for mimetype")
|
||||
|
||||
// ErrClosedWriter is returned when writing to a closed writer.
|
||||
var ErrClosedWriter = errors.New("write on closed writer")
|
||||
|
||||
////////////////////////////////////////////////////////////////
|
||||
|
||||
// MinifierFunc is a function that implements Minifer.
|
||||
|
|
@ -248,37 +251,47 @@ func (m *M) Reader(mediatype string, r io.Reader) io.Reader {
|
|||
return pr
|
||||
}
|
||||
|
||||
// minifyWriter makes sure that errors from the minifier are passed down through Close (can be blocking).
|
||||
type minifyWriter struct {
|
||||
pw *io.PipeWriter
|
||||
wg sync.WaitGroup
|
||||
err error
|
||||
// writer makes sure that errors from the minifier are passed down through Close (can be blocking).
|
||||
type writer struct {
|
||||
pw *io.PipeWriter
|
||||
wg sync.WaitGroup
|
||||
err error
|
||||
closed bool
|
||||
}
|
||||
|
||||
// Write intercepts any writes to the writer.
|
||||
func (w *minifyWriter) Write(b []byte) (int, error) {
|
||||
return w.pw.Write(b)
|
||||
func (w *writer) Write(b []byte) (int, error) {
|
||||
if w.closed {
|
||||
return 0, ErrClosedWriter
|
||||
}
|
||||
n, err := w.pw.Write(b)
|
||||
if w.err != nil {
|
||||
err = w.err
|
||||
}
|
||||
return n, err
|
||||
}
|
||||
|
||||
// Close must be called when writing has finished. It returns the error from the minifier.
|
||||
func (w *minifyWriter) Close() error {
|
||||
w.pw.Close()
|
||||
w.wg.Wait()
|
||||
func (w *writer) Close() error {
|
||||
if !w.closed {
|
||||
w.pw.Close()
|
||||
w.wg.Wait()
|
||||
w.closed = true
|
||||
}
|
||||
return w.err
|
||||
}
|
||||
|
||||
// Writer wraps a Writer interface and minifies the stream.
|
||||
// Errors from the minifier are returned by Close on the writer.
|
||||
// The writer must be closed explicitly.
|
||||
func (m *M) Writer(mediatype string, w io.Writer) *minifyWriter {
|
||||
func (m *M) Writer(mediatype string, w io.Writer) *writer {
|
||||
pr, pw := io.Pipe()
|
||||
mw := &minifyWriter{pw, sync.WaitGroup{}, nil}
|
||||
mw := &writer{pw, sync.WaitGroup{}, nil, false}
|
||||
mw.wg.Add(1)
|
||||
go func() {
|
||||
defer mw.wg.Done()
|
||||
|
||||
if err := m.Minify(mediatype, w, pr); err != nil {
|
||||
io.Copy(w, pr)
|
||||
mw.err = err
|
||||
}
|
||||
pr.Close()
|
||||
|
|
@ -286,26 +299,26 @@ func (m *M) Writer(mediatype string, w io.Writer) *minifyWriter {
|
|||
return mw
|
||||
}
|
||||
|
||||
// minifyResponseWriter wraps an http.ResponseWriter and makes sure that errors from the minifier are passed down through Close (can be blocking).
|
||||
// responseWriter wraps an http.ResponseWriter and makes sure that errors from the minifier are passed down through Close (can be blocking).
|
||||
// All writes to the response writer are intercepted and minified on the fly.
|
||||
// http.ResponseWriter loses all functionality such as Pusher, Hijacker, Flusher, ...
|
||||
type minifyResponseWriter struct {
|
||||
type responseWriter struct {
|
||||
http.ResponseWriter
|
||||
|
||||
writer *minifyWriter
|
||||
writer *writer
|
||||
m *M
|
||||
mediatype string
|
||||
}
|
||||
|
||||
// WriteHeader intercepts any header writes and removes the Content-Length header.
|
||||
func (w *minifyResponseWriter) WriteHeader(status int) {
|
||||
func (w *responseWriter) WriteHeader(status int) {
|
||||
w.ResponseWriter.Header().Del("Content-Length")
|
||||
w.ResponseWriter.WriteHeader(status)
|
||||
}
|
||||
|
||||
// Write intercepts any writes to the response writer.
|
||||
// The first write will extract the Content-Type as the mediatype. Otherwise it falls back to the RequestURI extension.
|
||||
func (w *minifyResponseWriter) Write(b []byte) (int, error) {
|
||||
func (w *responseWriter) Write(b []byte) (int, error) {
|
||||
if w.writer == nil {
|
||||
// first write
|
||||
if mediatype := w.ResponseWriter.Header().Get("Content-Type"); mediatype != "" {
|
||||
|
|
@ -317,7 +330,7 @@ func (w *minifyResponseWriter) Write(b []byte) (int, error) {
|
|||
}
|
||||
|
||||
// Close must be called when writing has finished. It returns the error from the minifier.
|
||||
func (w *minifyResponseWriter) Close() error {
|
||||
func (w *responseWriter) Close() error {
|
||||
if w.writer != nil {
|
||||
return w.writer.Close()
|
||||
}
|
||||
|
|
@ -327,9 +340,9 @@ func (w *minifyResponseWriter) Close() error {
|
|||
// ResponseWriter minifies any writes to the http.ResponseWriter.
|
||||
// http.ResponseWriter loses all functionality such as Pusher, Hijacker, Flusher, ...
|
||||
// Minification might be slower than just sending the original file! Caching is advised.
|
||||
func (m *M) ResponseWriter(w http.ResponseWriter, r *http.Request) *minifyResponseWriter {
|
||||
func (m *M) ResponseWriter(w http.ResponseWriter, r *http.Request) *responseWriter {
|
||||
mediatype := mime.TypeByExtension(path.Ext(r.RequestURI))
|
||||
return &minifyResponseWriter{w, nil, m, mediatype}
|
||||
return &responseWriter{w, nil, m, mediatype}
|
||||
}
|
||||
|
||||
// Middleware provides a middleware function that minifies content on the fly by intercepting writes to http.ResponseWriter.
|
||||
|
|
@ -338,8 +351,21 @@ func (m *M) ResponseWriter(w http.ResponseWriter, r *http.Request) *minifyRespon
|
|||
func (m *M) Middleware(next http.Handler) http.Handler {
|
||||
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
mw := m.ResponseWriter(w, r)
|
||||
defer mw.Close()
|
||||
|
||||
next.ServeHTTP(mw, r)
|
||||
mw.Close()
|
||||
})
|
||||
}
|
||||
|
||||
// MiddlewareWithError provides a middleware function that minifies content on the fly by intercepting writes to http.ResponseWriter. The error function allows handling minification errors.
|
||||
// http.ResponseWriter loses all functionality such as Pusher, Hijacker, Flusher, ...
|
||||
// Minification might be slower than just sending the original file! Caching is advised.
|
||||
func (m *M) MiddlewareWithError(next http.Handler, errorFunc func(w http.ResponseWriter, r *http.Request, err error)) http.Handler {
|
||||
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
mw := m.ResponseWriter(w, r)
|
||||
next.ServeHTTP(mw, r)
|
||||
if err := mw.Close(); err != nil {
|
||||
errorFunc(w, r, err)
|
||||
return
|
||||
}
|
||||
})
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue