goscript 0.1.4 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +5 -2
- package/cmd/go_js_wasm_exec/main.go +201 -0
- package/cmd/go_js_wasm_exec/main_test.go +83 -0
- package/cmd/goscript/{cmd_compile.go → cmd-compile.go} +7 -0
- package/cmd/goscript/cmd-test.go +14 -0
- package/cmd/goscript/cmd-test_test.go +1 -1
- package/compiler/compile-request.go +12 -9
- package/compiler/compliance_test.go +0 -1
- package/compiler/config.go +2 -0
- package/compiler/gotest/request.go +28 -0
- package/compiler/gotest/runner.go +353 -27
- package/compiler/gotest/runner_test.go +273 -1
- package/compiler/gotest/testdata/browserapi/browserapi_test.go +20 -0
- package/compiler/gotest/testdata/browserapi/go.mod +3 -0
- package/compiler/lowered-program.go +24 -17
- package/compiler/lowering.go +392 -127
- package/compiler/lowering_bench_test.go +41 -27
- package/compiler/override-facts.go +15 -0
- package/compiler/override-parity-verifier.go +450 -0
- package/compiler/override-parity.go +122 -0
- package/compiler/override-registry_test.go +559 -0
- package/compiler/protobuf-ts-binding.go +514 -0
- package/compiler/protobuf-ts-binding_test.go +172 -0
- package/compiler/semantic-model-types.go +9 -4
- package/compiler/semantic-model.go +282 -70
- package/compiler/semantic-model_test.go +82 -1
- package/compiler/service.go +20 -1
- package/compiler/skeleton_test.go +62 -8
- package/compiler/typescript-emitter.go +128 -13
- package/dist/gs/builtin/slice.d.ts +2 -1
- package/dist/gs/builtin/slice.js +29 -4
- package/dist/gs/builtin/slice.js.map +1 -1
- package/dist/gs/builtin/type.d.ts +13 -5
- package/dist/gs/builtin/type.js +153 -60
- package/dist/gs/builtin/type.js.map +1 -1
- package/dist/gs/builtin/varRef.d.ts +11 -0
- package/dist/gs/builtin/varRef.js +57 -2
- package/dist/gs/builtin/varRef.js.map +1 -1
- package/dist/gs/bytes/buffer.gs.js +1 -1
- package/dist/gs/bytes/buffer.gs.js.map +1 -1
- package/dist/gs/bytes/reader.gs.js +1 -1
- package/dist/gs/bytes/reader.gs.js.map +1 -1
- package/dist/gs/compress/zlib/index.d.ts +10 -3
- package/dist/gs/compress/zlib/index.js +50 -16
- package/dist/gs/compress/zlib/index.js.map +1 -1
- package/dist/gs/encoding/json/index.d.ts +114 -0
- package/dist/gs/encoding/json/index.js +544 -36
- package/dist/gs/encoding/json/index.js.map +1 -1
- package/dist/gs/github.com/aperturerobotics/protobuf-go-lite/index.d.ts +100 -0
- package/dist/gs/github.com/aperturerobotics/protobuf-go-lite/index.js +564 -0
- package/dist/gs/github.com/aperturerobotics/protobuf-go-lite/index.js.map +1 -1
- package/dist/gs/github.com/pkg/errors/errors.js +54 -30
- package/dist/gs/github.com/pkg/errors/errors.js.map +1 -1
- package/dist/gs/go/scanner/index.d.ts +2 -0
- package/dist/gs/go/scanner/index.js +29 -5
- package/dist/gs/go/scanner/index.js.map +1 -1
- package/dist/gs/go/token/index.js +22 -6
- package/dist/gs/go/token/index.js.map +1 -1
- package/dist/gs/hash/index.d.ts +6 -0
- package/dist/gs/hash/index.js +20 -0
- package/dist/gs/hash/index.js.map +1 -1
- package/dist/gs/internal/goarch/index.d.ts +43 -3
- package/dist/gs/internal/goarch/index.js +42 -10
- package/dist/gs/internal/goarch/index.js.map +1 -1
- package/dist/gs/io/fs/fs.js +26 -14
- package/dist/gs/io/fs/fs.js.map +1 -1
- package/dist/gs/io/fs/readdir.js +4 -2
- package/dist/gs/io/fs/readdir.js.map +1 -1
- package/dist/gs/io/fs/sub.js +8 -1
- package/dist/gs/io/fs/sub.js.map +1 -1
- package/dist/gs/io/io.d.ts +2 -0
- package/dist/gs/io/io.js.map +1 -1
- package/dist/gs/math/bits/index.d.ts +5 -0
- package/dist/gs/math/bits/index.js +16 -4
- package/dist/gs/math/bits/index.js.map +1 -1
- package/dist/gs/mime/index.d.ts +16 -0
- package/dist/gs/mime/index.js +315 -6
- package/dist/gs/mime/index.js.map +1 -1
- package/dist/gs/net/http/httptest/index.d.ts +12 -0
- package/dist/gs/net/http/httptest/index.js +85 -6
- package/dist/gs/net/http/httptest/index.js.map +1 -1
- package/dist/gs/net/http/index.d.ts +300 -5
- package/dist/gs/net/http/index.js +1598 -58
- package/dist/gs/net/http/index.js.map +1 -1
- package/dist/gs/os/dir_unix.gs.js +1 -1
- package/dist/gs/os/dir_unix.gs.js.map +1 -1
- package/dist/gs/os/error.gs.js +1 -1
- package/dist/gs/os/error.gs.js.map +1 -1
- package/dist/gs/os/exec.gs.d.ts +1 -0
- package/dist/gs/os/exec.gs.js +4 -8
- package/dist/gs/os/exec.gs.js.map +1 -1
- package/dist/gs/os/exec_posix.gs.js +1 -1
- package/dist/gs/os/exec_posix.gs.js.map +1 -1
- package/dist/gs/os/index.d.ts +1 -1
- package/dist/gs/os/index.js +1 -1
- package/dist/gs/os/index.js.map +1 -1
- package/dist/gs/os/proc.gs.d.ts +4 -0
- package/dist/gs/os/proc.gs.js +12 -6
- package/dist/gs/os/proc.gs.js.map +1 -1
- package/dist/gs/os/root_js.gs.js +1 -1
- package/dist/gs/os/root_js.gs.js.map +1 -1
- package/dist/gs/os/types.gs.js +1 -1
- package/dist/gs/os/types.gs.js.map +1 -1
- package/dist/gs/os/types_js.gs.js +1 -1
- package/dist/gs/os/types_js.gs.js.map +1 -1
- package/dist/gs/os/types_unix.gs.js +1 -1
- package/dist/gs/os/types_unix.gs.js.map +1 -1
- package/dist/gs/path/path.js +11 -7
- package/dist/gs/path/path.js.map +1 -1
- package/dist/gs/reflect/index.d.ts +5 -4
- package/dist/gs/reflect/index.js +4 -3
- package/dist/gs/reflect/index.js.map +1 -1
- package/dist/gs/reflect/map.js +15 -0
- package/dist/gs/reflect/map.js.map +1 -1
- package/dist/gs/reflect/type.d.ts +25 -6
- package/dist/gs/reflect/type.js +1418 -228
- package/dist/gs/reflect/type.js.map +1 -1
- package/dist/gs/reflect/types.d.ts +14 -6
- package/dist/gs/reflect/types.js +35 -1
- package/dist/gs/reflect/types.js.map +1 -1
- package/dist/gs/reflect/value.d.ts +1 -0
- package/dist/gs/reflect/value.js +83 -41
- package/dist/gs/reflect/value.js.map +1 -1
- package/dist/gs/reflect/visiblefields.js +4 -140
- package/dist/gs/reflect/visiblefields.js.map +1 -1
- package/dist/gs/runtime/pprof/index.d.ts +8 -2
- package/dist/gs/runtime/pprof/index.js +50 -30
- package/dist/gs/runtime/pprof/index.js.map +1 -1
- package/dist/gs/runtime/runtime.js +5 -4
- package/dist/gs/runtime/runtime.js.map +1 -1
- package/dist/gs/runtime/trace/index.js +5 -19
- package/dist/gs/runtime/trace/index.js.map +1 -1
- package/dist/gs/strconv/atoi.gs.js +1 -1
- package/dist/gs/strconv/atoi.gs.js.map +1 -1
- package/dist/gs/strconv/complex.gs.d.ts +3 -0
- package/dist/gs/strconv/complex.gs.js +148 -0
- package/dist/gs/strconv/complex.gs.js.map +1 -0
- package/dist/gs/strconv/index.d.ts +1 -0
- package/dist/gs/strconv/index.js +1 -0
- package/dist/gs/strconv/index.js.map +1 -1
- package/dist/gs/strings/builder.js +1 -1
- package/dist/gs/strings/reader.js +9 -5
- package/dist/gs/strings/reader.js.map +1 -1
- package/dist/gs/strings/replace.js +15 -7
- package/dist/gs/strings/replace.js.map +1 -1
- package/dist/gs/strings/strings.d.ts +5 -0
- package/dist/gs/strings/strings.js +57 -5
- package/dist/gs/strings/strings.js.map +1 -1
- package/dist/gs/sync/atomic/type.gs.js +9 -9
- package/dist/gs/sync/atomic/type.gs.js.map +1 -1
- package/dist/gs/sync/atomic/value.gs.js +2 -2
- package/dist/gs/sync/atomic/value.gs.js.map +1 -1
- package/dist/gs/syscall/env.js +22 -14
- package/dist/gs/syscall/env.js.map +1 -1
- package/dist/gs/testing/testing.js +55 -13
- package/dist/gs/testing/testing.js.map +1 -1
- package/dist/gs/time/time.d.ts +24 -1
- package/dist/gs/time/time.js +43 -3
- package/dist/gs/time/time.js.map +1 -1
- package/dist/gs/unique/index.js +7 -1
- package/dist/gs/unique/index.js.map +1 -1
- package/go.mod +3 -3
- package/go.sum +16 -0
- package/gs/builtin/runtime-contract.test.ts +218 -21
- package/gs/builtin/slice.ts +44 -4
- package/gs/builtin/type.ts +226 -59
- package/gs/builtin/varRef.ts +85 -2
- package/gs/bytes/buffer.gs.ts +1 -1
- package/gs/bytes/reader.gs.ts +1 -1
- package/gs/compress/zlib/index.test.ts +62 -1
- package/gs/compress/zlib/index.ts +53 -16
- package/gs/compress/zlib/parity.json +51 -0
- package/gs/encoding/json/index.test.ts +360 -6
- package/gs/encoding/json/index.ts +679 -38
- package/gs/encoding/json/parity.json +81 -0
- package/gs/github.com/aperturerobotics/protobuf-go-lite/index.test.ts +211 -3
- package/gs/github.com/aperturerobotics/protobuf-go-lite/index.ts +857 -1
- package/gs/github.com/pkg/errors/errors.ts +54 -30
- package/gs/go/scanner/index.test.ts +39 -56
- package/gs/go/scanner/index.ts +33 -5
- package/gs/go/scanner/parity.json +27 -0
- package/gs/go/token/index.ts +22 -6
- package/gs/hash/index.test.ts +20 -33
- package/gs/hash/index.ts +28 -0
- package/gs/hash/parity.json +21 -0
- package/gs/internal/goarch/index.test.ts +32 -0
- package/gs/internal/goarch/index.ts +45 -13
- package/gs/internal/goarch/parity.json +144 -0
- package/gs/io/fs/fs.ts +26 -14
- package/gs/io/fs/readdir.ts +4 -4
- package/gs/io/fs/sub.ts +8 -1
- package/gs/io/io.ts +1 -0
- package/gs/io/parity.json +162 -0
- package/gs/math/bits/index.test.ts +14 -1
- package/gs/math/bits/index.ts +23 -4
- package/gs/math/bits/parity.json +156 -0
- package/gs/mime/index.test.ts +90 -0
- package/gs/mime/index.ts +369 -6
- package/gs/mime/parity.json +36 -0
- package/gs/net/http/httptest/index.test.ts +98 -2
- package/gs/net/http/httptest/index.ts +101 -6
- package/gs/net/http/httptest/parity.json +15 -0
- package/gs/net/http/index.test.ts +781 -12
- package/gs/net/http/index.ts +1860 -139
- package/gs/net/http/meta.json +16 -1
- package/gs/net/http/parity.json +193 -0
- package/gs/os/dir_unix.gs.ts +1 -1
- package/gs/os/error.gs.ts +1 -1
- package/gs/os/exec.gs.ts +4 -8
- package/gs/os/exec_posix.gs.ts +1 -1
- package/gs/os/index.test.ts +9 -0
- package/gs/os/index.ts +1 -0
- package/gs/os/parity.json +9 -0
- package/gs/os/proc.gs.ts +18 -5
- package/gs/os/proc.test.ts +26 -0
- package/gs/os/root_js.gs.ts +1 -1
- package/gs/os/types.gs.ts +1 -1
- package/gs/os/types_js.gs.ts +1 -1
- package/gs/os/types_unix.gs.ts +1 -1
- package/gs/path/path.ts +11 -7
- package/gs/reflect/field.test.ts +37 -15
- package/gs/reflect/function-types.test.ts +518 -22
- package/gs/reflect/index.ts +8 -6
- package/gs/reflect/map.ts +20 -0
- package/gs/reflect/meta.json +6 -4
- package/gs/reflect/parity.json +234 -0
- package/gs/reflect/sliceat.test.ts +156 -0
- package/gs/reflect/structof.test.ts +401 -0
- package/gs/reflect/type.ts +1897 -317
- package/gs/reflect/typefor.test.ts +510 -10
- package/gs/reflect/types.ts +43 -18
- package/gs/reflect/value.ts +105 -45
- package/gs/reflect/visiblefields.ts +5 -168
- package/gs/runtime/parity.json +24 -0
- package/gs/runtime/pprof/index.test.ts +29 -7
- package/gs/runtime/pprof/index.ts +56 -30
- package/gs/runtime/pprof/parity.json +27 -0
- package/gs/runtime/runtime.test.ts +3 -1
- package/gs/runtime/runtime.ts +4 -3
- package/gs/runtime/trace/index.test.ts +5 -3
- package/gs/runtime/trace/index.ts +8 -20
- package/gs/runtime/trace/parity.json +36 -0
- package/gs/strconv/atoi.gs.ts +1 -1
- package/gs/strconv/complex.gs.ts +174 -0
- package/gs/strconv/complex.test.ts +65 -0
- package/gs/strconv/index.ts +1 -0
- package/gs/strconv/parity.json +120 -0
- package/gs/strings/builder.ts +1 -1
- package/gs/strings/parity.json +186 -0
- package/gs/strings/reader.ts +9 -5
- package/gs/strings/replace.ts +15 -7
- package/gs/strings/strings.test.ts +22 -2
- package/gs/strings/strings.ts +64 -6
- package/gs/sync/atomic/type.gs.ts +9 -9
- package/gs/sync/atomic/value.gs.ts +2 -2
- package/gs/syscall/env.ts +29 -14
- package/gs/testing/testing.test.ts +67 -0
- package/gs/testing/testing.ts +87 -19
- package/gs/time/parity.json +225 -0
- package/gs/time/time.test.ts +20 -2
- package/gs/time/time.ts +49 -7
- package/gs/unique/index.ts +7 -1
- package/package.json +4 -2
- package/dist/gs/github.com/aperturerobotics/starpc/srpc/index.d.ts +0 -217
- package/dist/gs/github.com/aperturerobotics/starpc/srpc/index.js +0 -926
- package/dist/gs/github.com/aperturerobotics/starpc/srpc/index.js.map +0 -1
- package/gs/github.com/aperturerobotics/starpc/srpc/index.test.ts +0 -38
- package/gs/github.com/aperturerobotics/starpc/srpc/index.ts +0 -1361
- package/gs/github.com/aperturerobotics/starpc/srpc/meta.json +0 -46
- /package/compiler/{wasm_api.go → wasm-api.go} +0 -0
|
@@ -3,37 +3,168 @@ import * as context from '@goscript/context/index.js';
|
|
|
3
3
|
import * as fs from '@goscript/io/fs/fs.js';
|
|
4
4
|
import * as io from '@goscript/io/index.js';
|
|
5
5
|
import * as time from '@goscript/time/index.js';
|
|
6
|
+
export declare const StatusContinue = 100;
|
|
7
|
+
export declare const StatusSwitchingProtocols = 101;
|
|
8
|
+
export declare const StatusProcessing = 102;
|
|
9
|
+
export declare const StatusEarlyHints = 103;
|
|
6
10
|
export declare const StatusOK = 200;
|
|
7
11
|
export declare const StatusCreated = 201;
|
|
12
|
+
export declare const StatusAccepted = 202;
|
|
13
|
+
export declare const StatusNonAuthoritativeInfo = 203;
|
|
14
|
+
export declare const StatusNoContent = 204;
|
|
15
|
+
export declare const StatusResetContent = 205;
|
|
8
16
|
export declare const StatusPartialContent = 206;
|
|
17
|
+
export declare const StatusMultiStatus = 207;
|
|
18
|
+
export declare const StatusAlreadyReported = 208;
|
|
19
|
+
export declare const StatusIMUsed = 226;
|
|
20
|
+
export declare const StatusMultipleChoices = 300;
|
|
9
21
|
export declare const StatusMovedPermanently = 301;
|
|
22
|
+
export declare const StatusFound = 302;
|
|
23
|
+
export declare const StatusSeeOther = 303;
|
|
24
|
+
export declare const StatusNotModified = 304;
|
|
25
|
+
export declare const StatusUseProxy = 305;
|
|
26
|
+
export declare const StatusTemporaryRedirect = 307;
|
|
27
|
+
export declare const StatusPermanentRedirect = 308;
|
|
10
28
|
export declare const StatusBadRequest = 400;
|
|
11
29
|
export declare const StatusUnauthorized = 401;
|
|
30
|
+
export declare const StatusPaymentRequired = 402;
|
|
12
31
|
export declare const StatusForbidden = 403;
|
|
32
|
+
export declare const StatusNotFound = 404;
|
|
13
33
|
export declare const StatusMethodNotAllowed = 405;
|
|
34
|
+
export declare const StatusNotAcceptable = 406;
|
|
35
|
+
export declare const StatusProxyAuthRequired = 407;
|
|
14
36
|
export declare const StatusRequestTimeout = 408;
|
|
15
37
|
export declare const StatusConflict = 409;
|
|
16
|
-
export declare const
|
|
38
|
+
export declare const StatusGone = 410;
|
|
39
|
+
export declare const StatusLengthRequired = 411;
|
|
40
|
+
export declare const StatusPreconditionFailed = 412;
|
|
41
|
+
export declare const StatusRequestEntityTooLarge = 413;
|
|
42
|
+
export declare const StatusRequestURITooLong = 414;
|
|
17
43
|
export declare const StatusUnsupportedMediaType = 415;
|
|
44
|
+
export declare const StatusRequestedRangeNotSatisfiable = 416;
|
|
45
|
+
export declare const StatusExpectationFailed = 417;
|
|
18
46
|
export declare const StatusTeapot = 418;
|
|
47
|
+
export declare const StatusMisdirectedRequest = 421;
|
|
48
|
+
export declare const StatusUnprocessableEntity = 422;
|
|
49
|
+
export declare const StatusLocked = 423;
|
|
50
|
+
export declare const StatusFailedDependency = 424;
|
|
51
|
+
export declare const StatusTooEarly = 425;
|
|
52
|
+
export declare const StatusUpgradeRequired = 426;
|
|
53
|
+
export declare const StatusPreconditionRequired = 428;
|
|
19
54
|
export declare const StatusTooManyRequests = 429;
|
|
20
|
-
export declare const
|
|
55
|
+
export declare const StatusRequestHeaderFieldsTooLarge = 431;
|
|
56
|
+
export declare const StatusUnavailableForLegalReasons = 451;
|
|
21
57
|
export declare const StatusInternalServerError = 500;
|
|
58
|
+
export declare const StatusNotImplemented = 501;
|
|
59
|
+
export declare const StatusBadGateway = 502;
|
|
22
60
|
export declare const StatusServiceUnavailable = 503;
|
|
61
|
+
export declare const StatusGatewayTimeout = 504;
|
|
62
|
+
export declare const StatusHTTPVersionNotSupported = 505;
|
|
63
|
+
export declare const StatusVariantAlsoNegotiates = 506;
|
|
64
|
+
export declare const StatusInsufficientStorage = 507;
|
|
65
|
+
export declare const StatusLoopDetected = 508;
|
|
66
|
+
export declare const StatusNotExtended = 510;
|
|
67
|
+
export declare const StatusNetworkAuthenticationRequired = 511;
|
|
23
68
|
export declare const MethodGet = "GET";
|
|
69
|
+
export declare const MethodHead = "HEAD";
|
|
24
70
|
export declare const MethodPost = "POST";
|
|
71
|
+
export declare const MethodPut = "PUT";
|
|
72
|
+
export declare const MethodPatch = "PATCH";
|
|
25
73
|
export declare const MethodDelete = "DELETE";
|
|
26
|
-
export declare const
|
|
74
|
+
export declare const MethodConnect = "CONNECT";
|
|
75
|
+
export declare const MethodOptions = "OPTIONS";
|
|
76
|
+
export declare const MethodTrace = "TRACE";
|
|
77
|
+
export declare const DefaultMaxHeaderBytes: number;
|
|
78
|
+
export declare const DefaultMaxIdleConnsPerHost = 2;
|
|
79
|
+
export declare const TimeFormat = "Mon, 02 Jan 2006 15:04:05 GMT";
|
|
80
|
+
export declare const TrailerPrefix = "Trailer:";
|
|
81
|
+
export declare class ProtocolError {
|
|
82
|
+
ErrorString: string;
|
|
83
|
+
constructor(errorString: string);
|
|
84
|
+
Error(): string;
|
|
85
|
+
}
|
|
86
|
+
export declare class MaxBytesError {
|
|
87
|
+
Limit: number;
|
|
88
|
+
constructor(init?: Partial<MaxBytesError>);
|
|
89
|
+
Error(): string;
|
|
90
|
+
}
|
|
91
|
+
export declare const ErrNotSupported: ProtocolError;
|
|
92
|
+
export declare const ErrUnexpectedTrailer: ProtocolError;
|
|
93
|
+
export declare const ErrMissingBoundary: ProtocolError;
|
|
94
|
+
export declare const ErrNotMultipart: ProtocolError;
|
|
95
|
+
export declare const ErrHeaderTooLong: ProtocolError;
|
|
96
|
+
export declare const ErrShortBody: ProtocolError;
|
|
97
|
+
export declare const ErrMissingContentLength: ProtocolError;
|
|
98
|
+
export declare const ErrBodyNotAllowed: $.GoError;
|
|
99
|
+
export declare const ErrBodyReadAfterClose: $.GoError;
|
|
100
|
+
export declare const ErrContentLength: $.GoError;
|
|
101
|
+
export declare const ErrHandlerTimeout: $.GoError;
|
|
102
|
+
export declare const ErrHijacked: $.GoError;
|
|
103
|
+
export declare const ErrLineTooLong: $.GoError;
|
|
104
|
+
export declare const ErrMissingFile: $.GoError;
|
|
105
|
+
export declare const ErrNoCookie: $.GoError;
|
|
106
|
+
export declare const ErrNoLocation: $.GoError;
|
|
107
|
+
export declare const ErrSchemeMismatch: $.GoError;
|
|
108
|
+
export declare const ErrServerClosed: $.GoError;
|
|
109
|
+
export declare const ErrAbortHandler: $.GoError;
|
|
110
|
+
export declare const ErrSkipAltProtocol: $.GoError;
|
|
111
|
+
export declare const ErrUseLastResponse: $.GoError;
|
|
112
|
+
export declare const ErrWriteAfterFlush: $.GoError;
|
|
27
113
|
export declare const ServerContextKey: unique symbol;
|
|
114
|
+
export declare const LocalAddrContextKey: unique symbol;
|
|
115
|
+
export type SameSite = number;
|
|
116
|
+
export declare const SameSiteDefaultMode = 1;
|
|
117
|
+
export declare const SameSiteLaxMode = 2;
|
|
118
|
+
export declare const SameSiteStrictMode = 3;
|
|
119
|
+
export declare const SameSiteNoneMode = 4;
|
|
120
|
+
export type ConnState = number;
|
|
121
|
+
export declare const StateNew = 0;
|
|
122
|
+
export declare const StateActive = 1;
|
|
123
|
+
export declare const StateIdle = 2;
|
|
124
|
+
export declare const StateHijacked = 3;
|
|
125
|
+
export declare const StateClosed = 4;
|
|
28
126
|
export declare function StatusText(code: number): string;
|
|
29
127
|
export type Header = Map<string, $.Slice<string>>;
|
|
30
128
|
export declare const Header: {
|
|
31
129
|
new (entries?: Iterable<readonly [string, $.Slice<string>]> | null): Header;
|
|
32
130
|
};
|
|
131
|
+
export declare function CanonicalHeaderKey(s: string): string;
|
|
33
132
|
export declare function Header_Add(h: Header, key: string, value: string): void;
|
|
34
133
|
export declare function Header_Del(h: Header, key: string): void;
|
|
35
134
|
export declare function Header_Get(h: Header, key: string): string;
|
|
36
135
|
export declare function Header_Set(h: Header, key: string, value: string): void;
|
|
136
|
+
export declare function Header_Values(h: Header, key: string): $.Slice<string>;
|
|
137
|
+
export declare function Header_Clone(h: Header): Header;
|
|
138
|
+
export declare function Header_Write(h: Header, w: io.Writer): $.GoError;
|
|
139
|
+
export declare function Header_WriteSubset(h: Header, w: io.Writer, exclude: Map<string, boolean> | null): $.GoError;
|
|
140
|
+
export type Dir = string;
|
|
141
|
+
export interface CookieJar {
|
|
142
|
+
SetCookies(u: any, cookies: $.Slice<Cookie | $.VarRef<Cookie> | null>): void;
|
|
143
|
+
Cookies(u: any): $.Slice<Cookie | $.VarRef<Cookie> | null>;
|
|
144
|
+
}
|
|
145
|
+
export interface CloseNotifier {
|
|
146
|
+
CloseNotify(): any;
|
|
147
|
+
}
|
|
148
|
+
export declare const NoBody: io.ReadCloser;
|
|
149
|
+
export declare class Cookie {
|
|
150
|
+
Name: string;
|
|
151
|
+
Value: string;
|
|
152
|
+
Quoted: boolean;
|
|
153
|
+
Path: string;
|
|
154
|
+
Domain: string;
|
|
155
|
+
Expires: time.Time;
|
|
156
|
+
RawExpires: string;
|
|
157
|
+
MaxAge: number;
|
|
158
|
+
Secure: boolean;
|
|
159
|
+
HttpOnly: boolean;
|
|
160
|
+
SameSite: number;
|
|
161
|
+
Partitioned: boolean;
|
|
162
|
+
Raw: string;
|
|
163
|
+
Unparsed: $.Slice<string>;
|
|
164
|
+
constructor(init?: Partial<Cookie>);
|
|
165
|
+
String(): string;
|
|
166
|
+
}
|
|
167
|
+
export declare function SetCookie(w: ResponseWriter | null, cookie: Cookie | $.VarRef<Cookie> | null): void;
|
|
37
168
|
export declare function RegisterInProcessServer(handler: Handler | null): string;
|
|
38
169
|
export declare function UnregisterInProcessServer(rawURL: string): void;
|
|
39
170
|
export interface ResponseWriter {
|
|
@@ -44,11 +175,25 @@ export interface ResponseWriter {
|
|
|
44
175
|
export declare class Request {
|
|
45
176
|
Method: string;
|
|
46
177
|
URL: any;
|
|
178
|
+
Proto: string;
|
|
179
|
+
ProtoMajor: number;
|
|
180
|
+
ProtoMinor: number;
|
|
47
181
|
Body: io.ReadCloser | null;
|
|
48
182
|
Header: Header;
|
|
49
183
|
ContentLength: number;
|
|
184
|
+
TransferEncoding: $.Slice<string>;
|
|
185
|
+
Close: boolean;
|
|
186
|
+
Host: string;
|
|
187
|
+
Form: any;
|
|
188
|
+
PostForm: any;
|
|
189
|
+
MultipartForm: any;
|
|
190
|
+
Trailer: Header;
|
|
50
191
|
RequestURI: string;
|
|
51
192
|
RemoteAddr: string;
|
|
193
|
+
TLS: any;
|
|
194
|
+
Cancel: any;
|
|
195
|
+
Response: Response | $.VarRef<Response> | null;
|
|
196
|
+
Pattern: string;
|
|
52
197
|
private ctx;
|
|
53
198
|
constructor(init?: Partial<Request> & {
|
|
54
199
|
ctx?: context.Context;
|
|
@@ -57,28 +202,116 @@ export declare class Request {
|
|
|
57
202
|
WithContext(ctx: context.Context): Request;
|
|
58
203
|
Clone(ctx: context.Context): Request;
|
|
59
204
|
UserAgent(): string;
|
|
205
|
+
Referer(): string;
|
|
206
|
+
ProtoAtLeast(major: number, minor: number): boolean;
|
|
207
|
+
Cookie(name: string): [Cookie | null, $.GoError];
|
|
208
|
+
Cookies(): $.Slice<Cookie | null>;
|
|
209
|
+
AddCookie(cookie: Cookie | $.VarRef<Cookie> | null): void;
|
|
210
|
+
SetBasicAuth(username: string, password: string): void;
|
|
211
|
+
BasicAuth(): [string, string, boolean];
|
|
60
212
|
FormValue(key: string): string;
|
|
61
213
|
}
|
|
62
214
|
export declare class Response {
|
|
63
215
|
Status: string;
|
|
64
216
|
StatusCode: number;
|
|
217
|
+
Proto: string;
|
|
218
|
+
ProtoMajor: number;
|
|
219
|
+
ProtoMinor: number;
|
|
65
220
|
Body: io.ReadCloser | null;
|
|
66
221
|
Header: Header;
|
|
67
222
|
ContentLength: number;
|
|
223
|
+
TransferEncoding: $.Slice<string>;
|
|
224
|
+
Close: boolean;
|
|
225
|
+
Uncompressed: boolean;
|
|
226
|
+
Trailer: Header;
|
|
68
227
|
Request: Request | $.VarRef<Request> | null;
|
|
228
|
+
TLS: any;
|
|
69
229
|
constructor(init?: Partial<Response>);
|
|
70
230
|
clone(): Response;
|
|
231
|
+
Cookies(): $.Slice<Cookie | null>;
|
|
232
|
+
Location(): [any, $.GoError];
|
|
233
|
+
ProtoAtLeast(major: number, minor: number): boolean;
|
|
234
|
+
Write(w: io.Writer): $.GoError;
|
|
71
235
|
}
|
|
72
236
|
export declare class Client {
|
|
73
237
|
Transport: RoundTripper | null;
|
|
74
238
|
constructor(init?: Partial<Client>);
|
|
75
239
|
Do(_req: Request | $.VarRef<Request> | null): Promise<[Response | null, $.GoError]>;
|
|
240
|
+
Get(url: string): Promise<[Response | null, $.GoError]>;
|
|
241
|
+
Head(url: string): Promise<[Response | null, $.GoError]>;
|
|
242
|
+
Post(url: string, contentType: string, body: io.Reader | null): Promise<[Response | null, $.GoError]>;
|
|
243
|
+
PostForm(url: string, data: any): Promise<[Response | null, $.GoError]>;
|
|
244
|
+
CloseIdleConnections(): void;
|
|
76
245
|
}
|
|
77
246
|
export declare const DefaultClient: Client;
|
|
247
|
+
export declare class ClientConn {
|
|
248
|
+
}
|
|
78
249
|
export interface RoundTripper {
|
|
79
250
|
RoundTrip(req: Request | $.VarRef<Request> | null): [Response | null, $.GoError] | Promise<[Response | null, $.GoError]>;
|
|
80
251
|
}
|
|
252
|
+
export declare class Protocols {
|
|
253
|
+
private bits;
|
|
254
|
+
HTTP1(): boolean;
|
|
255
|
+
SetHTTP1(ok: boolean): void;
|
|
256
|
+
HTTP2(): boolean;
|
|
257
|
+
SetHTTP2(ok: boolean): void;
|
|
258
|
+
UnencryptedHTTP2(): boolean;
|
|
259
|
+
SetUnencryptedHTTP2(ok: boolean): void;
|
|
260
|
+
String(): string;
|
|
261
|
+
private setBit;
|
|
262
|
+
}
|
|
263
|
+
export declare class HTTP2Config {
|
|
264
|
+
MaxConcurrentStreams: number;
|
|
265
|
+
StrictMaxConcurrentRequests: boolean;
|
|
266
|
+
MaxDecoderHeaderTableSize: number;
|
|
267
|
+
MaxEncoderHeaderTableSize: number;
|
|
268
|
+
MaxReadFrameSize: number;
|
|
269
|
+
MaxReceiveBufferPerConnection: number;
|
|
270
|
+
MaxReceiveBufferPerStream: number;
|
|
271
|
+
SendPingTimeout: number;
|
|
272
|
+
PingTimeout: number;
|
|
273
|
+
WriteByteTimeout: number;
|
|
274
|
+
PermitProhibitedCipherSuites: boolean;
|
|
275
|
+
CountError: ((errType: string) => void) | null;
|
|
276
|
+
constructor(init?: Partial<HTTP2Config>);
|
|
277
|
+
}
|
|
278
|
+
export declare class Transport implements RoundTripper {
|
|
279
|
+
Proxy: ((req: Request | $.VarRef<Request> | null) => [any, $.GoError]) | null;
|
|
280
|
+
OnProxyConnectResponse: ((ctx: context.Context, proxyURL: any, connectReq: Request, connectRes: Response) => $.GoError) | null;
|
|
281
|
+
DialContext: any;
|
|
282
|
+
Dial: any;
|
|
283
|
+
DialTLSContext: any;
|
|
284
|
+
DialTLS: any;
|
|
285
|
+
TLSClientConfig: any;
|
|
286
|
+
TLSHandshakeTimeout: number;
|
|
287
|
+
DisableKeepAlives: boolean;
|
|
288
|
+
DisableCompression: boolean;
|
|
289
|
+
MaxIdleConns: number;
|
|
290
|
+
MaxIdleConnsPerHost: number;
|
|
291
|
+
MaxConnsPerHost: number;
|
|
292
|
+
IdleConnTimeout: number;
|
|
293
|
+
ResponseHeaderTimeout: number;
|
|
294
|
+
ExpectContinueTimeout: number;
|
|
295
|
+
TLSNextProto: Map<string, any> | null;
|
|
296
|
+
ProxyConnectHeader: Header;
|
|
297
|
+
GetProxyConnectHeader: ((ctx: context.Context, proxyURL: any, target: string) => [Header | null, $.GoError]) | null;
|
|
298
|
+
MaxResponseHeaderBytes: number;
|
|
299
|
+
WriteBufferSize: number;
|
|
300
|
+
ReadBufferSize: number;
|
|
301
|
+
ForceAttemptHTTP2: boolean;
|
|
302
|
+
HTTP2: HTTP2Config | null;
|
|
303
|
+
Protocols: Protocols | null;
|
|
304
|
+
constructor(init?: Partial<Transport>);
|
|
305
|
+
RoundTrip(req: Request | $.VarRef<Request> | null): Promise<[Response | null, $.GoError]>;
|
|
306
|
+
CloseIdleConnections(): void;
|
|
307
|
+
CancelRequest(_req: Request | $.VarRef<Request> | null): void;
|
|
308
|
+
RegisterProtocol(_scheme: string, _rt: RoundTripper): void;
|
|
309
|
+
NewClientConn(_ctx: context.Context, _scheme: string, _address: string): [ClientConn | null, $.GoError];
|
|
310
|
+
Clone(): Transport;
|
|
311
|
+
}
|
|
81
312
|
export declare const DefaultTransport: RoundTripper;
|
|
313
|
+
export declare function NewFileTransport(root: FileSystem | null): RoundTripper;
|
|
314
|
+
export declare function NewFileTransportFS(fsys: fs.FS): RoundTripper;
|
|
82
315
|
export interface FileSystem {
|
|
83
316
|
Open(name: string): [File | null, $.GoError];
|
|
84
317
|
}
|
|
@@ -86,23 +319,61 @@ export interface File extends io.Closer, io.Reader, io.Seeker {
|
|
|
86
319
|
Readdir(count: number): [$.Slice<fs.FileInfo>, $.GoError];
|
|
87
320
|
Stat(): [fs.FileInfo, $.GoError];
|
|
88
321
|
}
|
|
322
|
+
export declare function FS(fsys: fs.FS): FileSystem;
|
|
323
|
+
export declare function FileServer(root: FileSystem | null): Handler;
|
|
324
|
+
export declare function FileServerFS(fsys: fs.FS): Handler;
|
|
325
|
+
export declare function ServeFile(w: ResponseWriter | null, r: Request | $.VarRef<Request> | null, _name: string): void;
|
|
326
|
+
export declare function ServeFileFS(w: ResponseWriter | null, r: Request | $.VarRef<Request> | null, _fsys: fs.FS, name: string): void;
|
|
89
327
|
export interface Handler {
|
|
90
328
|
ServeHTTP(w: ResponseWriter | null, r: Request | $.VarRef<Request> | null): void | Promise<void>;
|
|
91
329
|
}
|
|
92
330
|
export type HandlerFunc = (w: ResponseWriter | null, r: Request | $.VarRef<Request> | null) => void | Promise<void>;
|
|
93
331
|
export declare function HandlerFunc_ServeHTTP(h: HandlerFunc, w: ResponseWriter | null, r: Request | $.VarRef<Request> | null): void | Promise<void>;
|
|
332
|
+
export declare class CrossOriginProtection {
|
|
333
|
+
private denyHandler;
|
|
334
|
+
private trustedOrigins;
|
|
335
|
+
private bypassPatterns;
|
|
336
|
+
AddInsecureBypassPattern(pattern: string): void;
|
|
337
|
+
AddTrustedOrigin(origin: string): $.GoError;
|
|
338
|
+
Check(r: Request | $.VarRef<Request> | null): $.GoError;
|
|
339
|
+
Handler(handler: Handler | null): Handler;
|
|
340
|
+
SetDenyHandler(handler: Handler | null): void;
|
|
341
|
+
private isRequestExempt;
|
|
342
|
+
}
|
|
343
|
+
export declare function NewCrossOriginProtection(): CrossOriginProtection;
|
|
94
344
|
export declare class Server {
|
|
95
345
|
Addr: string;
|
|
96
346
|
BaseContext: ((listener: any) => context.Context) | null;
|
|
347
|
+
ConnContext: ((ctx: context.Context, conn: any) => context.Context) | null;
|
|
97
348
|
Handler: Handler | null;
|
|
349
|
+
DisableGeneralOptionsHandler: boolean;
|
|
350
|
+
TLSConfig: any;
|
|
351
|
+
ReadTimeout: number;
|
|
352
|
+
ReadTimeoutHandler: any;
|
|
98
353
|
ReadHeaderTimeout: number;
|
|
99
354
|
WriteTimeout: number;
|
|
355
|
+
IdleTimeout: number;
|
|
356
|
+
MaxHeaderBytes: number;
|
|
357
|
+
TLSNextProto: Map<string, any> | null;
|
|
358
|
+
ConnState: ((conn: any, state: ConnState) => void) | null;
|
|
359
|
+
ErrorLog: any;
|
|
360
|
+
HTTP2: HTTP2Config | null;
|
|
361
|
+
Protocols: Protocols | null;
|
|
100
362
|
constructor(init?: Partial<Server>);
|
|
101
363
|
ListenAndServe(): $.GoError;
|
|
102
364
|
ListenAndServeTLS(_certFile: string, _keyFile: string): $.GoError;
|
|
103
365
|
Close(): $.GoError;
|
|
104
366
|
Shutdown(_ctx: context.Context): $.GoError;
|
|
367
|
+
Serve(_listener: any): $.GoError;
|
|
368
|
+
ServeTLS(_listener: any, _certFile: string, _keyFile: string): $.GoError;
|
|
369
|
+
ServeHTTP(w: ResponseWriter | null, r: Request | $.VarRef<Request> | null): void | Promise<void>;
|
|
370
|
+
RegisterOnShutdown(_f: () => void): void;
|
|
371
|
+
SetKeepAlivesEnabled(_v: boolean): void;
|
|
105
372
|
}
|
|
373
|
+
export declare function ListenAndServe(_addr: string, _handler: Handler | null): $.GoError;
|
|
374
|
+
export declare function ListenAndServeTLS(_addr: string, _certFile: string, _keyFile: string, _handler: Handler | null): $.GoError;
|
|
375
|
+
export declare function Serve(_listener: any, _handler: Handler | null): $.GoError;
|
|
376
|
+
export declare function ServeTLS(_listener: any, _handler: Handler | null, _certFile: string, _keyFile: string): $.GoError;
|
|
106
377
|
export declare class PushOptions {
|
|
107
378
|
Header: Header;
|
|
108
379
|
constructor(init?: Partial<PushOptions>);
|
|
@@ -120,8 +391,13 @@ export declare class ResponseController {
|
|
|
120
391
|
rw: ResponseWriter | null;
|
|
121
392
|
constructor(rw: ResponseWriter | null);
|
|
122
393
|
Flush(): $.GoError;
|
|
394
|
+
Hijack(): [any, any, $.GoError];
|
|
395
|
+
SetReadDeadline(_deadline: time.Time): $.GoError;
|
|
396
|
+
SetWriteDeadline(_deadline: time.Time): $.GoError;
|
|
397
|
+
EnableFullDuplex(): $.GoError;
|
|
123
398
|
}
|
|
124
399
|
export declare function NewResponseController(rw: ResponseWriter | null): ResponseController;
|
|
400
|
+
export declare function MaxBytesReader(_w: ResponseWriter | null, r: io.ReadCloser | null, n: number): io.ReadCloser;
|
|
125
401
|
export declare class ServeMux implements Handler {
|
|
126
402
|
private handlers;
|
|
127
403
|
Handle(pattern: string, handler: Handler | null): void;
|
|
@@ -129,13 +405,32 @@ export declare class ServeMux implements Handler {
|
|
|
129
405
|
Handler(r: Request | $.VarRef<Request> | null): [Handler | null, string];
|
|
130
406
|
ServeHTTP(w: ResponseWriter | null, r: Request | $.VarRef<Request> | null): void | Promise<void>;
|
|
131
407
|
}
|
|
408
|
+
export declare const DefaultServeMux: ServeMux;
|
|
132
409
|
export declare function NewServeMux(): ServeMux;
|
|
410
|
+
export declare function Handle(pattern: string, handler: Handler | null): void;
|
|
133
411
|
export declare function HandleFunc(pattern: string, handler: HandlerFunc): void;
|
|
134
412
|
export declare function StripPrefix(prefix: string, handler: Handler | null): Handler;
|
|
413
|
+
export declare function AllowQuerySemicolons(handler: Handler | null): Handler;
|
|
414
|
+
export declare function MaxBytesHandler(handler: Handler | null, n: number): Handler;
|
|
415
|
+
export declare function NotFoundHandler(): Handler;
|
|
416
|
+
export declare function RedirectHandler(url: string, code: number): Handler;
|
|
417
|
+
export declare function TimeoutHandler(handler: Handler | null, _dt: number, msg: string): Handler;
|
|
135
418
|
export declare function Error(w: ResponseWriter | null, error: string, code: number): void;
|
|
136
419
|
export declare function NotFound(w: ResponseWriter | null, _r: Request | $.VarRef<Request> | null): void;
|
|
137
420
|
export declare function Redirect(w: ResponseWriter | null, _r: Request | $.VarRef<Request> | null, url: string, code: number): void;
|
|
138
421
|
export declare function ParseTime(text: string): [time.Time, $.GoError];
|
|
422
|
+
export declare function DetectContentType(data: $.Slice<number>): string;
|
|
423
|
+
export declare function ParseHTTPVersion(vers: string): [number, number, boolean];
|
|
424
|
+
export declare function ParseCookie(line: string): [$.Slice<Cookie | null>, $.GoError];
|
|
425
|
+
export declare function ParseSetCookie(line: string): [Cookie | null, $.GoError];
|
|
139
426
|
export declare function NewRequest(method: string, url: string, body: io.Reader | null): [Request | null, $.GoError];
|
|
140
|
-
export declare function NewRequestWithContext(
|
|
141
|
-
export declare function Get(_url: string): [Response | null, $.GoError]
|
|
427
|
+
export declare function NewRequestWithContext(ctx: context.Context, method: string, url: string, body: io.Reader | null): [Request | null, $.GoError];
|
|
428
|
+
export declare function Get(_url: string): Promise<[Response | null, $.GoError]>;
|
|
429
|
+
export declare function Head(_url: string): Promise<[Response | null, $.GoError]>;
|
|
430
|
+
export declare function Post(_url: string, contentType: string, body: io.Reader | null): Promise<[Response | null, $.GoError]>;
|
|
431
|
+
export declare function PostForm(_url: string, data: any): Promise<[Response | null, $.GoError]>;
|
|
432
|
+
export declare function ProxyFromEnvironment(_req: Request | $.VarRef<Request> | null): [any, $.GoError];
|
|
433
|
+
export declare function ProxyURL(fixedURL: any): (req: Request | $.VarRef<Request> | null) => [any, $.GoError];
|
|
434
|
+
export declare function ReadRequest(_reader: any): [Request | null, $.GoError];
|
|
435
|
+
export declare function ReadResponse(_reader: any, _req: Request | $.VarRef<Request> | null): [Response | null, $.GoError];
|
|
436
|
+
export declare function ServeContent(w: ResponseWriter | null, req: Request | $.VarRef<Request> | null, _name: string, _modtime: time.Time, content: io.Reader | null): Promise<void>;
|