@mtkruto/node 0.0.6
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/LICENSE +165 -0
- package/README.md +1 -0
- package/esm/_dnt.shims.js +68 -0
- package/esm/client/client.js +169 -0
- package/esm/client/client_abstract.js +51 -0
- package/esm/client/client_plain.js +112 -0
- package/esm/connection/connection.js +2 -0
- package/esm/connection/connection_web_socket.js +90 -0
- package/esm/constants.js +60 -0
- package/esm/deps/deno.land/std@0.186.0/fmt/colors.js +474 -0
- package/esm/deps/deno.land/std@0.186.0/testing/_diff.js +311 -0
- package/esm/deps/deno.land/std@0.186.0/testing/_format.js +23 -0
- package/esm/deps/deno.land/std@0.186.0/testing/asserts.js +633 -0
- package/esm/deps/deno.land/x/crc32@v0.2.0/mod.js +105 -0
- package/esm/deps/deno.land/x/tgcrypto@0.1.1/mod.js +68 -0
- package/esm/deps/deno.land/x/tgcrypto@0.1.1/tgcrypto.js +1127 -0
- package/esm/deps/raw.githubusercontent.com/MTKruto/compress/master/gzip/gzip.js +239 -0
- package/esm/deps/raw.githubusercontent.com/MTKruto/compress/master/utils/uint8.js +10 -0
- package/esm/deps/raw.githubusercontent.com/MTKruto/compress/master/zlib/deflate.js +139 -0
- package/esm/deps/raw.githubusercontent.com/MTKruto/compress/master/zlib/inflate.js +176 -0
- package/esm/deps/raw.githubusercontent.com/MTKruto/compress/master/zlib/mod.js +2 -0
- package/esm/deps/raw.githubusercontent.com/MTKruto/compress/master/zlib/zlib/adler32.js +19 -0
- package/esm/deps/raw.githubusercontent.com/MTKruto/compress/master/zlib/zlib/crc32.js +25 -0
- package/esm/deps/raw.githubusercontent.com/MTKruto/compress/master/zlib/zlib/deflate.js +1941 -0
- package/esm/deps/raw.githubusercontent.com/MTKruto/compress/master/zlib/zlib/gzheader.js +85 -0
- package/esm/deps/raw.githubusercontent.com/MTKruto/compress/master/zlib/zlib/inffast.js +321 -0
- package/esm/deps/raw.githubusercontent.com/MTKruto/compress/master/zlib/zlib/inflate.js +1658 -0
- package/esm/deps/raw.githubusercontent.com/MTKruto/compress/master/zlib/zlib/inftrees.js +355 -0
- package/esm/deps/raw.githubusercontent.com/MTKruto/compress/master/zlib/zlib/messages.js +11 -0
- package/esm/deps/raw.githubusercontent.com/MTKruto/compress/master/zlib/zlib/status.js +42 -0
- package/esm/deps/raw.githubusercontent.com/MTKruto/compress/master/zlib/zlib/trees.js +1107 -0
- package/esm/deps/raw.githubusercontent.com/MTKruto/compress/master/zlib/zlib/zstream.js +86 -0
- package/esm/deps.js +4 -0
- package/esm/mod.js +4 -0
- package/esm/package.json +3 -0
- package/esm/tl/0_tl_raw_reader.js +62 -0
- package/esm/tl/0_tl_raw_writer.js +60 -0
- package/esm/tl/1_tl_object.js +149 -0
- package/esm/tl/2_types.js +48220 -0
- package/esm/tl/3_functions.js +19856 -0
- package/esm/tl/3_tl_object_deserializer.js +72 -0
- package/esm/tl/3_tl_reader.js +16 -0
- package/esm/tl/3_tl_writer.js +7 -0
- package/esm/tl/4_rpc_result.js +27 -0
- package/esm/tl/5_message.js +54 -0
- package/esm/tl/6_message_container.js +35 -0
- package/esm/transport/transport.js +32 -0
- package/esm/transport/transport_intermediate.js +56 -0
- package/esm/transport/transport_provider.js +23 -0
- package/esm/types.js +1 -0
- package/esm/utilities/0_bigint.js +37 -0
- package/esm/utilities/0_buffer.js +33 -0
- package/esm/utilities/0_crypto.js +35 -0
- package/esm/utilities/0_hash.js +7 -0
- package/esm/utilities/1_auth.js +29 -0
- package/esm/utilities/1_message.js +94 -0
- package/esm/utilities/1_obfuscation.js +33 -0
- package/package.json +40 -0
- package/script/_dnt.shims.js +77 -0
- package/script/client/client.js +173 -0
- package/script/client/client_abstract.js +55 -0
- package/script/client/client_plain.js +116 -0
- package/script/connection/connection.js +6 -0
- package/script/connection/connection_web_socket.js +117 -0
- package/script/constants.js +63 -0
- package/script/deps/deno.land/std@0.186.0/fmt/colors.js +548 -0
- package/script/deps/deno.land/std@0.186.0/testing/_diff.js +317 -0
- package/script/deps/deno.land/std@0.186.0/testing/_format.js +50 -0
- package/script/deps/deno.land/std@0.186.0/testing/asserts.js +659 -0
- package/script/deps/deno.land/x/crc32@v0.2.0/mod.js +113 -0
- package/script/deps/deno.land/x/tgcrypto@0.1.1/mod.js +82 -0
- package/script/deps/deno.land/x/tgcrypto@0.1.1/tgcrypto.js +1152 -0
- package/script/deps/raw.githubusercontent.com/MTKruto/compress/master/gzip/gzip.js +271 -0
- package/script/deps/raw.githubusercontent.com/MTKruto/compress/master/utils/uint8.js +14 -0
- package/script/deps/raw.githubusercontent.com/MTKruto/compress/master/zlib/deflate.js +172 -0
- package/script/deps/raw.githubusercontent.com/MTKruto/compress/master/zlib/inflate.js +208 -0
- package/script/deps/raw.githubusercontent.com/MTKruto/compress/master/zlib/mod.js +18 -0
- package/script/deps/raw.githubusercontent.com/MTKruto/compress/master/zlib/zlib/adler32.js +22 -0
- package/script/deps/raw.githubusercontent.com/MTKruto/compress/master/zlib/zlib/crc32.js +30 -0
- package/script/deps/raw.githubusercontent.com/MTKruto/compress/master/zlib/zlib/deflate.js +1976 -0
- package/script/deps/raw.githubusercontent.com/MTKruto/compress/master/zlib/zlib/gzheader.js +88 -0
- package/script/deps/raw.githubusercontent.com/MTKruto/compress/master/zlib/zlib/inffast.js +324 -0
- package/script/deps/raw.githubusercontent.com/MTKruto/compress/master/zlib/zlib/inflate.js +1674 -0
- package/script/deps/raw.githubusercontent.com/MTKruto/compress/master/zlib/zlib/inftrees.js +358 -0
- package/script/deps/raw.githubusercontent.com/MTKruto/compress/master/zlib/zlib/messages.js +14 -0
- package/script/deps/raw.githubusercontent.com/MTKruto/compress/master/zlib/zlib/status.js +44 -0
- package/script/deps/raw.githubusercontent.com/MTKruto/compress/master/zlib/zlib/trees.js +1115 -0
- package/script/deps/raw.githubusercontent.com/MTKruto/compress/master/zlib/zlib/zstream.js +89 -0
- package/script/deps.js +30 -0
- package/script/mod.js +32 -0
- package/script/package.json +3 -0
- package/script/tl/0_tl_raw_reader.js +66 -0
- package/script/tl/0_tl_raw_writer.js +64 -0
- package/script/tl/1_tl_object.js +156 -0
- package/script/tl/2_types.js +49824 -0
- package/script/tl/3_functions.js +20413 -0
- package/script/tl/3_tl_object_deserializer.js +76 -0
- package/script/tl/3_tl_reader.js +20 -0
- package/script/tl/3_tl_writer.js +11 -0
- package/script/tl/4_rpc_result.js +31 -0
- package/script/tl/5_message.js +58 -0
- package/script/tl/6_message_container.js +39 -0
- package/script/transport/transport.js +36 -0
- package/script/transport/transport_intermediate.js +60 -0
- package/script/transport/transport_provider.js +27 -0
- package/script/types.js +2 -0
- package/script/utilities/0_bigint.js +67 -0
- package/script/utilities/0_buffer.js +38 -0
- package/script/utilities/0_crypto.js +39 -0
- package/script/utilities/0_hash.js +35 -0
- package/script/utilities/1_auth.js +56 -0
- package/script/utilities/1_message.js +102 -0
- package/script/utilities/1_obfuscation.js +60 -0
- package/types/_dnt.shims.d.ts +10 -0
- package/types/client/client.d.ts +19 -0
- package/types/client/client_abstract.d.ts +20 -0
- package/types/client/client_plain.d.ts +10 -0
- package/types/connection/connection.d.ts +7 -0
- package/types/connection/connection_web_socket.d.ts +13 -0
- package/types/constants.d.ts +2 -0
- package/types/deps/deno.land/std@0.186.0/fmt/colors.d.ts +270 -0
- package/types/deps/deno.land/std@0.186.0/testing/_diff.d.ts +26 -0
- package/types/deps/deno.land/std@0.186.0/testing/_format.d.ts +1 -0
- package/types/deps/deno.land/std@0.186.0/testing/asserts.d.ts +284 -0
- package/types/deps/deno.land/x/crc32@v0.2.0/mod.d.ts +15 -0
- package/types/deps/deno.land/x/tgcrypto@0.1.1/mod.d.ts +47 -0
- package/types/deps/deno.land/x/tgcrypto@0.1.1/tgcrypto.d.ts +2 -0
- package/types/deps/raw.githubusercontent.com/MTKruto/compress/master/gzip/gzip.d.ts +16 -0
- package/types/deps/raw.githubusercontent.com/MTKruto/compress/master/utils/uint8.d.ts +1 -0
- package/types/deps/raw.githubusercontent.com/MTKruto/compress/master/zlib/deflate.d.ts +29 -0
- package/types/deps/raw.githubusercontent.com/MTKruto/compress/master/zlib/inflate.d.ts +23 -0
- package/types/deps/raw.githubusercontent.com/MTKruto/compress/master/zlib/mod.d.ts +2 -0
- package/types/deps/raw.githubusercontent.com/MTKruto/compress/master/zlib/zlib/adler32.d.ts +1 -0
- package/types/deps/raw.githubusercontent.com/MTKruto/compress/master/zlib/zlib/crc32.d.ts +2 -0
- package/types/deps/raw.githubusercontent.com/MTKruto/compress/master/zlib/zlib/deflate.d.ts +78 -0
- package/types/deps/raw.githubusercontent.com/MTKruto/compress/master/zlib/zlib/gzheader.d.ts +12 -0
- package/types/deps/raw.githubusercontent.com/MTKruto/compress/master/zlib/zlib/inffast.d.ts +1 -0
- package/types/deps/raw.githubusercontent.com/MTKruto/compress/master/zlib/zlib/inflate.d.ts +47 -0
- package/types/deps/raw.githubusercontent.com/MTKruto/compress/master/zlib/zlib/inftrees.d.ts +1 -0
- package/types/deps/raw.githubusercontent.com/MTKruto/compress/master/zlib/zlib/messages.d.ts +12 -0
- package/types/deps/raw.githubusercontent.com/MTKruto/compress/master/zlib/zlib/status.d.ts +30 -0
- package/types/deps/raw.githubusercontent.com/MTKruto/compress/master/zlib/zlib/trees.d.ts +5 -0
- package/types/deps/raw.githubusercontent.com/MTKruto/compress/master/zlib/zlib/zstream.d.ts +14 -0
- package/types/deps.d.ts +4 -0
- package/types/mod.d.ts +4 -0
- package/types/tl/0_tl_raw_reader.d.ts +13 -0
- package/types/tl/0_tl_raw_writer.d.ts +13 -0
- package/types/tl/1_tl_object.d.ts +36 -0
- package/types/tl/2_types.d.ts +14815 -0
- package/types/tl/3_functions.d.ts +6122 -0
- package/types/tl/3_tl_object_deserializer.d.ts +3 -0
- package/types/tl/3_tl_reader.d.ts +4 -0
- package/types/tl/3_tl_writer.d.ts +5 -0
- package/types/tl/4_rpc_result.d.ts +8 -0
- package/types/tl/5_message.d.ts +11 -0
- package/types/tl/6_message_container.d.ts +9 -0
- package/types/transport/transport.d.ts +15 -0
- package/types/transport/transport_intermediate.d.ts +11 -0
- package/types/transport/transport_provider.d.ts +12 -0
- package/types/types.d.ts +1 -0
- package/types/utilities/0_bigint.d.ts +4 -0
- package/types/utilities/0_buffer.d.ts +2 -0
- package/types/utilities/0_crypto.d.ts +8 -0
- package/types/utilities/0_hash.d.ts +2 -0
- package/types/utilities/1_auth.d.ts +1 -0
- package/types/utilities/1_message.d.ts +10 -0
- package/types/utilities/1_obfuscation.d.ts +6 -0
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
class GZheader {
|
|
4
|
+
constructor() {
|
|
5
|
+
/* true if compressed data believed to be text */
|
|
6
|
+
Object.defineProperty(this, "text", {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
configurable: true,
|
|
9
|
+
writable: true,
|
|
10
|
+
value: 0
|
|
11
|
+
});
|
|
12
|
+
/* modification time */
|
|
13
|
+
Object.defineProperty(this, "time", {
|
|
14
|
+
enumerable: true,
|
|
15
|
+
configurable: true,
|
|
16
|
+
writable: true,
|
|
17
|
+
value: 0
|
|
18
|
+
});
|
|
19
|
+
/* extra flags (not used when writing a gzip file) */
|
|
20
|
+
Object.defineProperty(this, "xflags", {
|
|
21
|
+
enumerable: true,
|
|
22
|
+
configurable: true,
|
|
23
|
+
writable: true,
|
|
24
|
+
value: 0
|
|
25
|
+
});
|
|
26
|
+
/* operating system */
|
|
27
|
+
Object.defineProperty(this, "os", {
|
|
28
|
+
enumerable: true,
|
|
29
|
+
configurable: true,
|
|
30
|
+
writable: true,
|
|
31
|
+
value: 0
|
|
32
|
+
});
|
|
33
|
+
/* pointer to extra field or Z_NULL if none */
|
|
34
|
+
Object.defineProperty(this, "extra", {
|
|
35
|
+
enumerable: true,
|
|
36
|
+
configurable: true,
|
|
37
|
+
writable: true,
|
|
38
|
+
value: null
|
|
39
|
+
});
|
|
40
|
+
/* extra field length (valid if extra != Z_NULL) */
|
|
41
|
+
Object.defineProperty(this, "extra_len", {
|
|
42
|
+
enumerable: true,
|
|
43
|
+
configurable: true,
|
|
44
|
+
writable: true,
|
|
45
|
+
value: 0
|
|
46
|
+
}); // Actually, we don't need it in JS,
|
|
47
|
+
// but leave for few code modifications
|
|
48
|
+
//
|
|
49
|
+
// Setup limits is not necessary because in js we should not preallocate memory
|
|
50
|
+
// for inflate use constant limit in 65536 bytes
|
|
51
|
+
//
|
|
52
|
+
/* space at extra (only when reading header) */
|
|
53
|
+
// extra_max = 0;
|
|
54
|
+
/* pointer to zero-terminated file name or Z_NULL */
|
|
55
|
+
Object.defineProperty(this, "name", {
|
|
56
|
+
enumerable: true,
|
|
57
|
+
configurable: true,
|
|
58
|
+
writable: true,
|
|
59
|
+
value: ""
|
|
60
|
+
});
|
|
61
|
+
/* space at name (only when reading header) */
|
|
62
|
+
// name_max = 0;
|
|
63
|
+
/* pointer to zero-terminated comment or Z_NULL */
|
|
64
|
+
Object.defineProperty(this, "comment", {
|
|
65
|
+
enumerable: true,
|
|
66
|
+
configurable: true,
|
|
67
|
+
writable: true,
|
|
68
|
+
value: ""
|
|
69
|
+
});
|
|
70
|
+
/* space at comment (only when reading header) */
|
|
71
|
+
// comm_max = 0;
|
|
72
|
+
/* true if there was or will be a header crc */
|
|
73
|
+
Object.defineProperty(this, "hcrc", {
|
|
74
|
+
enumerable: true,
|
|
75
|
+
configurable: true,
|
|
76
|
+
writable: true,
|
|
77
|
+
value: 0
|
|
78
|
+
});
|
|
79
|
+
/* true when done reading gzip header (not used when writing a gzip file) */
|
|
80
|
+
Object.defineProperty(this, "done", {
|
|
81
|
+
enumerable: true,
|
|
82
|
+
configurable: true,
|
|
83
|
+
writable: true,
|
|
84
|
+
value: false
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
exports.default = GZheader;
|
|
@@ -0,0 +1,324 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
// See state defs from inflate.js
|
|
4
|
+
const BAD = 30; /* got a data error -- remain here until reset */
|
|
5
|
+
const TYPE = 12; /* i: waiting for type bits, including last-flag bit */
|
|
6
|
+
/*
|
|
7
|
+
Decode literal, length, and distance codes and write out the resulting
|
|
8
|
+
literal and match bytes until either not enough input or output is
|
|
9
|
+
available, an end-of-block is encountered, or a data error is encountered.
|
|
10
|
+
When large enough input and output buffers are supplied to inflate(), for
|
|
11
|
+
example, a 16K input buffer and a 64K output buffer, more than 95% of the
|
|
12
|
+
inflate execution time is spent in this routine.
|
|
13
|
+
|
|
14
|
+
Entry assumptions:
|
|
15
|
+
|
|
16
|
+
state.mode === LEN
|
|
17
|
+
strm.avail_in >= 6
|
|
18
|
+
strm.avail_out >= 258
|
|
19
|
+
start >= strm.avail_out
|
|
20
|
+
state.bits < 8
|
|
21
|
+
|
|
22
|
+
On return, state.mode is one of:
|
|
23
|
+
|
|
24
|
+
LEN -- ran out of enough output space or enough available input
|
|
25
|
+
TYPE -- reached end of block code, inflate() to interpret next block
|
|
26
|
+
BAD -- error in block data
|
|
27
|
+
|
|
28
|
+
Notes:
|
|
29
|
+
|
|
30
|
+
- The maximum input bits used by a length/distance pair is 15 bits for the
|
|
31
|
+
length code, 5 bits for the length extra, 15 bits for the distance code,
|
|
32
|
+
and 13 bits for the distance extra. This totals 48 bits, or six bytes.
|
|
33
|
+
Therefore if strm.avail_in >= 6, then there is enough input to avoid
|
|
34
|
+
checking for available input while decoding.
|
|
35
|
+
|
|
36
|
+
- The maximum bytes that a single length/distance pair can output is 258
|
|
37
|
+
bytes, which is the maximum length that can be coded. inflate_fast()
|
|
38
|
+
requires strm.avail_out >= 258 for each loop to avoid checking for
|
|
39
|
+
output space.
|
|
40
|
+
*/
|
|
41
|
+
function inflate_fast(strm, start) {
|
|
42
|
+
let state;
|
|
43
|
+
let _in; /* local strm.input */
|
|
44
|
+
let last; /* have enough input while in < last */
|
|
45
|
+
let _out; /* local strm.output */
|
|
46
|
+
let beg; /* inflate()'s initial strm.output */
|
|
47
|
+
let end; /* while out < end, enough space available */
|
|
48
|
+
//#ifdef INFLATE_STRICT
|
|
49
|
+
let dmax; /* maximum distance from zlib header */
|
|
50
|
+
//#endif
|
|
51
|
+
let wsize; /* window size or zero if not using window */
|
|
52
|
+
let whave; /* valid bytes in the window */
|
|
53
|
+
let wnext; /* window write index */
|
|
54
|
+
// Use `s_window` instead `window`, avoid conflict with instrumentation tools
|
|
55
|
+
let s_window; /* allocated sliding window, if wsize != 0 */
|
|
56
|
+
let hold; /* local strm.hold */
|
|
57
|
+
let bits; /* local strm.bits */
|
|
58
|
+
let lcode; /* local strm.lencode */
|
|
59
|
+
let dcode; /* local strm.distcode */
|
|
60
|
+
let lmask; /* mask for first level of length codes */
|
|
61
|
+
let dmask; /* mask for first level of distance codes */
|
|
62
|
+
let here; /* retrieved table entry */
|
|
63
|
+
let op; /* code bits, operation, extra bits, or */
|
|
64
|
+
/* window position, window bytes to copy */
|
|
65
|
+
let len; /* match length, unused bytes */
|
|
66
|
+
let dist; /* match distance */
|
|
67
|
+
let from; /* where to copy match from */
|
|
68
|
+
let from_source;
|
|
69
|
+
let input, output; // JS specific, because we have no pointers
|
|
70
|
+
/* copy state to local variables */
|
|
71
|
+
state = strm.state;
|
|
72
|
+
//here = state.here;
|
|
73
|
+
_in = strm.next_in;
|
|
74
|
+
input = strm.input;
|
|
75
|
+
last = _in + (strm.avail_in - 5);
|
|
76
|
+
_out = strm.next_out;
|
|
77
|
+
output = strm.output;
|
|
78
|
+
beg = _out - (start - strm.avail_out);
|
|
79
|
+
end = _out + (strm.avail_out - 257);
|
|
80
|
+
//#ifdef INFLATE_STRICT
|
|
81
|
+
dmax = state.dmax;
|
|
82
|
+
//#endif
|
|
83
|
+
wsize = state.wsize;
|
|
84
|
+
whave = state.whave;
|
|
85
|
+
wnext = state.wnext;
|
|
86
|
+
s_window = state.window;
|
|
87
|
+
hold = state.hold;
|
|
88
|
+
bits = state.bits;
|
|
89
|
+
lcode = state.lencode;
|
|
90
|
+
dcode = state.distcode;
|
|
91
|
+
lmask = (1 << state.lenbits) - 1;
|
|
92
|
+
dmask = (1 << state.distbits) - 1;
|
|
93
|
+
/* decode literals and length/distances until end-of-block or not enough
|
|
94
|
+
input data or output space */
|
|
95
|
+
top: do {
|
|
96
|
+
if (bits < 15) {
|
|
97
|
+
hold += input[_in++] << bits;
|
|
98
|
+
bits += 8;
|
|
99
|
+
hold += input[_in++] << bits;
|
|
100
|
+
bits += 8;
|
|
101
|
+
}
|
|
102
|
+
here = lcode[hold & lmask];
|
|
103
|
+
dolen: for (;;) { // Goto emulation
|
|
104
|
+
op = here >>> 24 /*here.bits*/;
|
|
105
|
+
hold >>>= op;
|
|
106
|
+
bits -= op;
|
|
107
|
+
op = (here >>> 16) & 0xff /*here.op*/;
|
|
108
|
+
if (op === 0) {
|
|
109
|
+
/* literal */
|
|
110
|
+
//Tracevv((stderr, here.val >= 0x20 && here.val < 0x7f ?
|
|
111
|
+
// "inflate: literal '%c'\n" :
|
|
112
|
+
// "inflate: literal 0x%02x\n", here.val));
|
|
113
|
+
output[_out++] = here & 0xffff /*here.val*/;
|
|
114
|
+
}
|
|
115
|
+
else if (op & 16) {
|
|
116
|
+
/* length base */
|
|
117
|
+
len = here & 0xffff /*here.val*/;
|
|
118
|
+
op &= 15; /* number of extra bits */
|
|
119
|
+
if (op) {
|
|
120
|
+
if (bits < op) {
|
|
121
|
+
hold += input[_in++] << bits;
|
|
122
|
+
bits += 8;
|
|
123
|
+
}
|
|
124
|
+
len += hold & ((1 << op) - 1);
|
|
125
|
+
hold >>>= op;
|
|
126
|
+
bits -= op;
|
|
127
|
+
}
|
|
128
|
+
//Tracevv((stderr, "inflate: length %u\n", len));
|
|
129
|
+
if (bits < 15) {
|
|
130
|
+
hold += input[_in++] << bits;
|
|
131
|
+
bits += 8;
|
|
132
|
+
hold += input[_in++] << bits;
|
|
133
|
+
bits += 8;
|
|
134
|
+
}
|
|
135
|
+
here = dcode[hold & dmask];
|
|
136
|
+
dodist: for (;;) { // goto emulation
|
|
137
|
+
op = here >>> 24 /*here.bits*/;
|
|
138
|
+
hold >>>= op;
|
|
139
|
+
bits -= op;
|
|
140
|
+
op = (here >>> 16) & 0xff /*here.op*/;
|
|
141
|
+
if (op & 16) {
|
|
142
|
+
/* distance base */
|
|
143
|
+
dist = here & 0xffff /*here.val*/;
|
|
144
|
+
op &= 15; /* number of extra bits */
|
|
145
|
+
if (bits < op) {
|
|
146
|
+
hold += input[_in++] << bits;
|
|
147
|
+
bits += 8;
|
|
148
|
+
if (bits < op) {
|
|
149
|
+
hold += input[_in++] << bits;
|
|
150
|
+
bits += 8;
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
dist += hold & ((1 << op) - 1);
|
|
154
|
+
//#ifdef INFLATE_STRICT
|
|
155
|
+
if (dist > dmax) {
|
|
156
|
+
strm.msg = "invalid distance too far back";
|
|
157
|
+
state.mode = BAD;
|
|
158
|
+
break top;
|
|
159
|
+
}
|
|
160
|
+
//#endif
|
|
161
|
+
hold >>>= op;
|
|
162
|
+
bits -= op;
|
|
163
|
+
//Tracevv((stderr, "inflate: distance %u\n", dist));
|
|
164
|
+
op = _out - beg; /* max distance in output */
|
|
165
|
+
if (dist > op) {
|
|
166
|
+
/* see if copy from window */
|
|
167
|
+
op = dist - op; /* distance back in window */
|
|
168
|
+
if (op > whave) {
|
|
169
|
+
if (state.sane) {
|
|
170
|
+
strm.msg = "invalid distance too far back";
|
|
171
|
+
state.mode = BAD;
|
|
172
|
+
break top;
|
|
173
|
+
}
|
|
174
|
+
// (!) This block is disabled in zlib defaults,
|
|
175
|
+
// don't enable it for binary compatibility
|
|
176
|
+
//#ifdef INFLATE_ALLOW_INVALID_DISTANCE_TOOFAR_ARRR
|
|
177
|
+
// if (len <= op - whave) {
|
|
178
|
+
// do {
|
|
179
|
+
// output[_out++] = 0;
|
|
180
|
+
// } while (--len);
|
|
181
|
+
// continue top;
|
|
182
|
+
// }
|
|
183
|
+
// len -= op - whave;
|
|
184
|
+
// do {
|
|
185
|
+
// output[_out++] = 0;
|
|
186
|
+
// } while (--op > whave);
|
|
187
|
+
// if (op === 0) {
|
|
188
|
+
// from = _out - dist;
|
|
189
|
+
// do {
|
|
190
|
+
// output[_out++] = output[from++];
|
|
191
|
+
// } while (--len);
|
|
192
|
+
// continue top;
|
|
193
|
+
// }
|
|
194
|
+
//#endif
|
|
195
|
+
}
|
|
196
|
+
from = 0; // window index
|
|
197
|
+
from_source = s_window;
|
|
198
|
+
if (wnext === 0) {
|
|
199
|
+
/* very common case */
|
|
200
|
+
from += wsize - op;
|
|
201
|
+
if (op < len) {
|
|
202
|
+
/* some from window */
|
|
203
|
+
len -= op;
|
|
204
|
+
do {
|
|
205
|
+
output[_out++] = s_window[from++];
|
|
206
|
+
} while (--op);
|
|
207
|
+
from = _out - dist; /* rest from output */
|
|
208
|
+
from_source = output;
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
else if (wnext < op) {
|
|
212
|
+
/* wrap around window */
|
|
213
|
+
from += wsize + wnext - op;
|
|
214
|
+
op -= wnext;
|
|
215
|
+
if (op < len) {
|
|
216
|
+
/* some from end of window */
|
|
217
|
+
len -= op;
|
|
218
|
+
do {
|
|
219
|
+
output[_out++] = s_window[from++];
|
|
220
|
+
} while (--op);
|
|
221
|
+
from = 0;
|
|
222
|
+
if (wnext < len) {
|
|
223
|
+
/* some from start of window */
|
|
224
|
+
op = wnext;
|
|
225
|
+
len -= op;
|
|
226
|
+
do {
|
|
227
|
+
output[_out++] = s_window[from++];
|
|
228
|
+
} while (--op);
|
|
229
|
+
from = _out - dist; /* rest from output */
|
|
230
|
+
from_source = output;
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
else {
|
|
235
|
+
/* contiguous in window */
|
|
236
|
+
from += wnext - op;
|
|
237
|
+
if (op < len) {
|
|
238
|
+
/* some from window */
|
|
239
|
+
len -= op;
|
|
240
|
+
do {
|
|
241
|
+
output[_out++] = s_window[from++];
|
|
242
|
+
} while (--op);
|
|
243
|
+
from = _out - dist; /* rest from output */
|
|
244
|
+
from_source = output;
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
while (len > 2) {
|
|
248
|
+
output[_out++] = from_source[from++];
|
|
249
|
+
output[_out++] = from_source[from++];
|
|
250
|
+
output[_out++] = from_source[from++];
|
|
251
|
+
len -= 3;
|
|
252
|
+
}
|
|
253
|
+
if (len) {
|
|
254
|
+
output[_out++] = from_source[from++];
|
|
255
|
+
if (len > 1) {
|
|
256
|
+
output[_out++] = from_source[from++];
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
else {
|
|
261
|
+
from = _out - dist; /* copy direct from output */
|
|
262
|
+
do {
|
|
263
|
+
/* minimum length is three */
|
|
264
|
+
output[_out++] = output[from++];
|
|
265
|
+
output[_out++] = output[from++];
|
|
266
|
+
output[_out++] = output[from++];
|
|
267
|
+
len -= 3;
|
|
268
|
+
} while (len > 2);
|
|
269
|
+
if (len) {
|
|
270
|
+
output[_out++] = output[from++];
|
|
271
|
+
if (len > 1) {
|
|
272
|
+
output[_out++] = output[from++];
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
else if ((op & 64) === 0) {
|
|
278
|
+
/* 2nd level distance code */
|
|
279
|
+
here =
|
|
280
|
+
dcode[(here & 0xffff) /*here.val*/ + (hold & ((1 << op) - 1))];
|
|
281
|
+
continue dodist;
|
|
282
|
+
}
|
|
283
|
+
else {
|
|
284
|
+
strm.msg = "invalid distance code";
|
|
285
|
+
state.mode = BAD;
|
|
286
|
+
break top;
|
|
287
|
+
}
|
|
288
|
+
break; // need to emulate goto via "continue"
|
|
289
|
+
}
|
|
290
|
+
}
|
|
291
|
+
else if ((op & 64) === 0) {
|
|
292
|
+
/* 2nd level length code */
|
|
293
|
+
here = lcode[(here & 0xffff) /*here.val*/ + (hold & ((1 << op) - 1))];
|
|
294
|
+
continue dolen;
|
|
295
|
+
}
|
|
296
|
+
else if (op & 32) {
|
|
297
|
+
/* end-of-block */
|
|
298
|
+
//Tracevv((stderr, "inflate: end of block\n"));
|
|
299
|
+
state.mode = TYPE;
|
|
300
|
+
break top;
|
|
301
|
+
}
|
|
302
|
+
else {
|
|
303
|
+
strm.msg = "invalid literal/length code";
|
|
304
|
+
state.mode = BAD;
|
|
305
|
+
break top;
|
|
306
|
+
}
|
|
307
|
+
break; // need to emulate goto via "continue"
|
|
308
|
+
}
|
|
309
|
+
} while (_in < last && _out < end);
|
|
310
|
+
/* return unused bytes (on entry, bits < 8, so in won't go too far back) */
|
|
311
|
+
len = bits >> 3;
|
|
312
|
+
_in -= len;
|
|
313
|
+
bits -= len << 3;
|
|
314
|
+
hold &= (1 << bits) - 1;
|
|
315
|
+
/* update state and return */
|
|
316
|
+
strm.next_in = _in;
|
|
317
|
+
strm.next_out = _out;
|
|
318
|
+
strm.avail_in = (_in < last ? 5 + (last - _in) : 5 - (_in - last));
|
|
319
|
+
strm.avail_out = (_out < end ? 257 + (end - _out) : 257 - (_out - end));
|
|
320
|
+
state.hold = hold;
|
|
321
|
+
state.bits = bits;
|
|
322
|
+
return;
|
|
323
|
+
}
|
|
324
|
+
exports.default = inflate_fast;
|