@leofcoin/chain 1.10.2 → 1.10.4
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/exports/browser/{browser-BOiH47em-CNA0837Q.js → browser-D-r0O9Qn-BUd-PxvP.js} +2 -2
- package/exports/browser/{browser-BuaFyOQj-BCgu_5S8.js → browser-_hiyXwPp-CeZtoaRo.js} +2 -2
- package/exports/browser/chain.js +10 -10
- package/exports/browser/{client-B2wkkpij-CXdxWu9W.js → client-U5AYtQje-DAQ00fHP.js} +4 -4
- package/exports/browser/{constants-CUoFxEp2.js → constants-CVkCJ-VS.js} +490 -221
- package/exports/browser/{index-s61gSKAd-DUkaInec.js → index-BD0Anx7_-D-zybnw-.js} +2 -2
- package/exports/browser/{messages-CZ-3jxiD-BQAqB9Vv.js → messages-Dr5w-bq6-D-moQFGj.js} +2 -2
- package/exports/browser/{node-browser-Cveo6mdM.js → node-browser-D5TgXCwx.js} +11 -7
- package/exports/browser/node-browser.js +2 -2
- package/exports/browser/workers/block-worker.js +1 -1
- package/exports/browser/workers/machine-worker.js +9 -9
- package/exports/browser/workers/{worker-jeGMMCte-BwFbyiks.js → worker-CZqErLI7-BxofVJAn.js} +490 -221
- package/exports/workers/block-worker.js +1 -1
- package/exports/workers/machine-worker.js +9 -9
- package/exports/workers/{worker-jeGMMCte-BwFbyiks.js → worker-CZqErLI7-BxofVJAn.js} +490 -221
- package/package.json +13 -13
|
@@ -11,147 +11,344 @@ var proto$3 = {
|
|
|
11
11
|
protocolVersion: String()
|
|
12
12
|
};
|
|
13
13
|
|
|
14
|
-
// base-x encoding / decoding
|
|
15
|
-
// Copyright (c) 2018 base-x contributors
|
|
16
|
-
// Copyright (c) 2014-2018 The Bitcoin Core developers (base58.cpp)
|
|
17
|
-
//
|
|
18
|
-
//
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
const
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
const
|
|
37
|
-
const
|
|
38
|
-
const
|
|
39
|
-
const
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
if (
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
14
|
+
// base-x encoding / decoding
|
|
15
|
+
// Copyright (c) 2018 base-x contributors
|
|
16
|
+
// Copyright (c) 2014-2018 The Bitcoin Core developers (base58.cpp)
|
|
17
|
+
// Copyright (c) 2026 Vandeuren Glenn
|
|
18
|
+
// Distributed under the MIT software license, see the accompanying
|
|
19
|
+
// file LICENSE or http://www.opensource.org/licenses/mit-license.php.
|
|
20
|
+
const base = (ALPHABET, options = {}) => {
|
|
21
|
+
if (ALPHABET.length >= 255) {
|
|
22
|
+
throw new TypeError("Alphabet too long");
|
|
23
|
+
}
|
|
24
|
+
const BASE_MAP = new Uint8Array(256);
|
|
25
|
+
for (let j = 0; j < BASE_MAP.length; j++) {
|
|
26
|
+
BASE_MAP[j] = 255;
|
|
27
|
+
}
|
|
28
|
+
for (let i = 0; i < ALPHABET.length; i++) {
|
|
29
|
+
const x = ALPHABET.charAt(i);
|
|
30
|
+
const xc = x.charCodeAt(0);
|
|
31
|
+
if (BASE_MAP[xc] !== 255) {
|
|
32
|
+
throw new TypeError(x + " is ambiguous");
|
|
33
|
+
}
|
|
34
|
+
BASE_MAP[xc] = i;
|
|
35
|
+
}
|
|
36
|
+
const BASE = ALPHABET.length;
|
|
37
|
+
const LEADER = ALPHABET.charAt(0);
|
|
38
|
+
const LEADER_CODE = ALPHABET.charCodeAt(0);
|
|
39
|
+
const FACTOR = Math.log(BASE) / Math.log(256); // log(BASE) / log(256), rounded up
|
|
40
|
+
const iFACTOR = Math.log(256) / Math.log(BASE); // log(256) / log(BASE), rounded up
|
|
41
|
+
// Optimization: If BASE is a power of 2, we can use bitwise operations
|
|
42
|
+
// This is much faster than the generic algorithm (approx 10x-20x)
|
|
43
|
+
const isPowerOfTwo = (BASE & (BASE - 1)) === 0;
|
|
44
|
+
if (isPowerOfTwo) {
|
|
45
|
+
const k = Math.log2(BASE);
|
|
46
|
+
const mask = (1 << k) - 1;
|
|
47
|
+
if (options.rfc4648) {
|
|
48
|
+
// RFC 4648 Mode
|
|
49
|
+
const encode = (source) => {
|
|
50
|
+
if (source instanceof Uint8Array) ;
|
|
51
|
+
else if (ArrayBuffer.isView(source)) {
|
|
52
|
+
source = new Uint8Array(source.buffer, source.byteOffset, source.byteLength);
|
|
53
|
+
}
|
|
54
|
+
else if (Array.isArray(source)) {
|
|
55
|
+
source = Uint8Array.from(source);
|
|
56
|
+
}
|
|
57
|
+
if (!(source instanceof Uint8Array)) {
|
|
58
|
+
throw new TypeError("Expected Uint8Array");
|
|
59
|
+
}
|
|
60
|
+
if (source.length === 0) {
|
|
61
|
+
return "";
|
|
62
|
+
}
|
|
63
|
+
let str = "";
|
|
64
|
+
let currentValue = 0;
|
|
65
|
+
let currentBits = 0;
|
|
66
|
+
for (let i = 0; i < source.length; i++) {
|
|
67
|
+
currentValue = (currentValue << 8) | source[i];
|
|
68
|
+
currentBits += 8;
|
|
69
|
+
while (currentBits >= k) {
|
|
70
|
+
currentBits -= k;
|
|
71
|
+
str += ALPHABET.charAt((currentValue >>> currentBits) & mask);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
// Leftover bits (padding logic for the last character)
|
|
75
|
+
if (currentBits > 0) {
|
|
76
|
+
str += ALPHABET.charAt((currentValue << (k - currentBits)) & mask);
|
|
77
|
+
}
|
|
78
|
+
// Add padding chars '=' if required
|
|
79
|
+
while ((str.length * k) % 8 !== 0) {
|
|
80
|
+
str += "=";
|
|
81
|
+
}
|
|
82
|
+
return str;
|
|
83
|
+
};
|
|
84
|
+
const decodeUnsafe = (source) => {
|
|
85
|
+
if (typeof source !== "string") {
|
|
86
|
+
throw new TypeError("Expected String");
|
|
87
|
+
}
|
|
88
|
+
if (source.length === 0) {
|
|
89
|
+
return new Uint8Array();
|
|
90
|
+
}
|
|
91
|
+
// Strip padding
|
|
92
|
+
let end = source.length;
|
|
93
|
+
while (end > 0 && source[end - 1] === "=") {
|
|
94
|
+
end--;
|
|
95
|
+
}
|
|
96
|
+
source = source.substring(0, end);
|
|
97
|
+
let currentValue = 0;
|
|
98
|
+
let currentBits = 0;
|
|
99
|
+
// Estimate size: source.length * k / 8
|
|
100
|
+
const buffer = new Uint8Array((source.length * k) >>> 3);
|
|
101
|
+
let ptr = 0;
|
|
102
|
+
for (let i = 0; i < source.length; i++) {
|
|
103
|
+
const char = source.charCodeAt(i);
|
|
104
|
+
const val = BASE_MAP[char];
|
|
105
|
+
if (val === 255)
|
|
106
|
+
return undefined;
|
|
107
|
+
currentValue = (currentValue << k) | val;
|
|
108
|
+
currentBits += k;
|
|
109
|
+
if (currentBits >= 8) {
|
|
110
|
+
currentBits -= 8;
|
|
111
|
+
buffer[ptr++] = (currentValue >>> currentBits) & 0xff;
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
return buffer;
|
|
115
|
+
};
|
|
116
|
+
const decode = (string) => {
|
|
117
|
+
const buffer = decodeUnsafe(string);
|
|
118
|
+
if (buffer)
|
|
119
|
+
return buffer;
|
|
120
|
+
throw new Error("Non-base" + BASE + " character");
|
|
121
|
+
};
|
|
122
|
+
return { encode, decodeUnsafe, decode };
|
|
123
|
+
}
|
|
124
|
+
// Standard Mode (Bitwise)
|
|
125
|
+
const encode = (source) => {
|
|
126
|
+
if (source instanceof Uint8Array) ;
|
|
127
|
+
else if (ArrayBuffer.isView(source)) {
|
|
128
|
+
source = new Uint8Array(source.buffer, source.byteOffset, source.byteLength);
|
|
129
|
+
}
|
|
130
|
+
else if (Array.isArray(source)) {
|
|
131
|
+
source = Uint8Array.from(source);
|
|
132
|
+
}
|
|
133
|
+
if (!(source instanceof Uint8Array)) {
|
|
134
|
+
throw new TypeError("Expected Uint8Array");
|
|
135
|
+
}
|
|
136
|
+
if (source.length === 0) {
|
|
137
|
+
return "";
|
|
138
|
+
}
|
|
139
|
+
let zeroes = 0;
|
|
140
|
+
let pbegin = 0;
|
|
141
|
+
const pend = source.length;
|
|
142
|
+
while (pbegin !== pend && source[pbegin] === 0) {
|
|
143
|
+
pbegin++;
|
|
144
|
+
zeroes++;
|
|
145
|
+
}
|
|
146
|
+
let str = LEADER.repeat(zeroes);
|
|
147
|
+
if (pbegin === pend)
|
|
148
|
+
return str;
|
|
149
|
+
// Bitwise conversion
|
|
150
|
+
let currentValue = 0;
|
|
151
|
+
let currentBits = 0;
|
|
152
|
+
const totalBits = (pend - pbegin) * 8;
|
|
153
|
+
let remainder = totalBits % k;
|
|
154
|
+
// Handling the initial alignment to the most significant bits
|
|
155
|
+
// If total bits isn't divisible by k, the first digit uses 'remainder' bits
|
|
156
|
+
if (remainder === 0)
|
|
157
|
+
remainder = k; // effectively divisible, treating first k bits normally
|
|
158
|
+
let seenNonZero = false;
|
|
159
|
+
let firstChunk = true;
|
|
160
|
+
for (let i = pbegin; i < pend; i++) {
|
|
161
|
+
currentValue = (currentValue << 8) | source[i];
|
|
162
|
+
currentBits += 8;
|
|
163
|
+
while (currentBits >= k || (firstChunk && currentBits >= remainder)) {
|
|
164
|
+
let bitsToExtract = k;
|
|
165
|
+
if (firstChunk) {
|
|
166
|
+
if (totalBits % k !== 0) {
|
|
167
|
+
bitsToExtract = totalBits % k;
|
|
168
|
+
}
|
|
169
|
+
firstChunk = false;
|
|
170
|
+
}
|
|
171
|
+
const shift = currentBits - bitsToExtract;
|
|
172
|
+
const digit = (currentValue >>> shift) & ((1 << bitsToExtract) - 1);
|
|
173
|
+
currentBits -= bitsToExtract;
|
|
174
|
+
if (seenNonZero || digit !== 0) {
|
|
175
|
+
str += ALPHABET.charAt(digit);
|
|
176
|
+
seenNonZero = true;
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
return str;
|
|
181
|
+
};
|
|
182
|
+
const decodeUnsafe = (source) => {
|
|
183
|
+
if (typeof source !== "string") {
|
|
184
|
+
throw new TypeError("Expected String");
|
|
185
|
+
}
|
|
186
|
+
if (source.length === 0) {
|
|
187
|
+
return new Uint8Array();
|
|
188
|
+
}
|
|
189
|
+
let psz = 0;
|
|
190
|
+
let zeroes = 0;
|
|
191
|
+
while (source.charCodeAt(psz) === LEADER_CODE) {
|
|
192
|
+
zeroes++;
|
|
193
|
+
psz++;
|
|
194
|
+
}
|
|
195
|
+
// Accumulate bits
|
|
196
|
+
// We must handle alignment.
|
|
197
|
+
const length = source.length - psz;
|
|
198
|
+
const totalBits = length * k;
|
|
199
|
+
let currentBits = (8 - (totalBits % 8)) % 8; // align to byte boundary
|
|
200
|
+
const result = new Uint8Array((totalBits + 7) >>> 3); // (totalBits + 7) / 8
|
|
201
|
+
let rIdx = 0;
|
|
202
|
+
let currentValue = 0;
|
|
203
|
+
for (let i = psz; i < source.length; i++) {
|
|
204
|
+
const char = source.charCodeAt(i);
|
|
205
|
+
const val = BASE_MAP[char];
|
|
206
|
+
if (val === 255)
|
|
207
|
+
return;
|
|
208
|
+
currentValue = (currentValue << k) | val;
|
|
209
|
+
currentBits += k;
|
|
210
|
+
if (currentBits >= 8) {
|
|
211
|
+
const shift = currentBits - 8;
|
|
212
|
+
result[rIdx++] = (currentValue >>> shift) & 0xff;
|
|
213
|
+
currentBits -= 8;
|
|
214
|
+
// Keep only the remaining bits to avoid overflow
|
|
215
|
+
currentValue &= (1 << currentBits) - 1;
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
// Skip leading zeroes in result buffer
|
|
219
|
+
let skip = 0;
|
|
220
|
+
while (skip < rIdx && result[skip] === 0) {
|
|
221
|
+
skip++;
|
|
222
|
+
}
|
|
223
|
+
// Combine with zeroes
|
|
224
|
+
const final = new Uint8Array(zeroes + (rIdx - skip));
|
|
225
|
+
// zeroes are 0, so just copy result
|
|
226
|
+
final.set(result.subarray(skip, rIdx), zeroes);
|
|
227
|
+
return final;
|
|
228
|
+
};
|
|
229
|
+
const decode = (string) => {
|
|
230
|
+
const buffer = decodeUnsafe(string);
|
|
231
|
+
if (buffer)
|
|
232
|
+
return buffer;
|
|
233
|
+
throw new Error("Non-base" + BASE + " character");
|
|
234
|
+
};
|
|
235
|
+
return { encode, decodeUnsafe, decode };
|
|
236
|
+
}
|
|
237
|
+
const encode = (source) => {
|
|
238
|
+
if (source instanceof Uint8Array) ;
|
|
239
|
+
else if (ArrayBuffer.isView(source)) {
|
|
240
|
+
source = new Uint8Array(source.buffer, source.byteOffset, source.byteLength);
|
|
241
|
+
}
|
|
242
|
+
else if (Array.isArray(source)) {
|
|
243
|
+
source = Uint8Array.from(source);
|
|
244
|
+
}
|
|
245
|
+
if (!(source instanceof Uint8Array)) {
|
|
246
|
+
throw new TypeError("Expected Uint8Array");
|
|
247
|
+
}
|
|
248
|
+
if (source.length === 0) {
|
|
249
|
+
return "";
|
|
250
|
+
}
|
|
251
|
+
// Skip & count leading zeroes.
|
|
252
|
+
let zeroes = 0;
|
|
253
|
+
let length = 0;
|
|
254
|
+
let pbegin = 0;
|
|
255
|
+
const pend = source.length;
|
|
256
|
+
while (pbegin !== pend && source[pbegin] === 0) {
|
|
257
|
+
pbegin++;
|
|
258
|
+
zeroes++;
|
|
259
|
+
}
|
|
260
|
+
// Allocate enough space in big-endian base58 representation.
|
|
261
|
+
const size = ((pend - pbegin) * iFACTOR + 1) >>> 0;
|
|
262
|
+
const b58 = new Uint8Array(size);
|
|
263
|
+
// Process the bytes.
|
|
264
|
+
while (pbegin !== pend) {
|
|
265
|
+
let carry = source[pbegin];
|
|
266
|
+
// Apply "b58 = b58 * 256 + ch".
|
|
267
|
+
let i = 0;
|
|
268
|
+
for (let it1 = size - 1; (carry !== 0 || i < length) && it1 !== -1; it1--, i++) {
|
|
269
|
+
carry += (b58[it1] << 8) >>> 0;
|
|
270
|
+
b58[it1] = (carry % BASE) >>> 0;
|
|
271
|
+
carry = (carry / BASE) >>> 0;
|
|
272
|
+
}
|
|
273
|
+
if (carry !== 0) {
|
|
274
|
+
throw new Error("Non-zero carry");
|
|
275
|
+
}
|
|
276
|
+
length = i;
|
|
277
|
+
pbegin++;
|
|
278
|
+
}
|
|
279
|
+
// Skip leading zeroes in base58 result.
|
|
280
|
+
let it2 = size - length;
|
|
281
|
+
while (it2 !== size && b58[it2] === 0) {
|
|
282
|
+
it2++;
|
|
283
|
+
}
|
|
284
|
+
// Translate the result into a string.
|
|
285
|
+
let str = LEADER.repeat(zeroes);
|
|
286
|
+
for (; it2 < size; ++it2) {
|
|
287
|
+
str += ALPHABET.charAt(b58[it2]);
|
|
288
|
+
}
|
|
289
|
+
return str;
|
|
290
|
+
};
|
|
291
|
+
const decodeUnsafe = (source) => {
|
|
292
|
+
if (typeof source !== "string") {
|
|
293
|
+
throw new TypeError("Expected String");
|
|
294
|
+
}
|
|
295
|
+
if (source.length === 0) {
|
|
296
|
+
return new Uint8Array();
|
|
297
|
+
}
|
|
298
|
+
let psz = 0;
|
|
299
|
+
// Skip and count leading '1's.
|
|
300
|
+
let zeroes = 0;
|
|
301
|
+
let length = 0;
|
|
302
|
+
while (source.charCodeAt(psz) === LEADER_CODE) {
|
|
303
|
+
zeroes++;
|
|
304
|
+
psz++;
|
|
305
|
+
}
|
|
306
|
+
// Allocate enough space in big-endian base256 representation.
|
|
307
|
+
const size = ((source.length - psz) * FACTOR + 1) >>> 0; // log(58) / log(256), rounded up.
|
|
308
|
+
let b256 = new Uint8Array(size);
|
|
309
|
+
// Process the characters.
|
|
310
|
+
for (; psz < source.length; psz++) {
|
|
311
|
+
// Decode character
|
|
312
|
+
let carry = BASE_MAP[source.charCodeAt(psz)];
|
|
313
|
+
// Invalid character
|
|
314
|
+
if (carry === 255) {
|
|
315
|
+
return;
|
|
316
|
+
}
|
|
317
|
+
let i = 0;
|
|
318
|
+
for (let it3 = size - 1; (carry !== 0 || i < length) && it3 !== -1; it3--, i++) {
|
|
319
|
+
carry += (BASE * b256[it3]) >>> 0;
|
|
320
|
+
b256[it3] = (carry & 0xff) >>> 0;
|
|
321
|
+
carry = (carry >> 8) >>> 0;
|
|
322
|
+
}
|
|
323
|
+
if (carry !== 0) {
|
|
324
|
+
throw new Error("Non-zero carry");
|
|
325
|
+
}
|
|
326
|
+
length = i;
|
|
327
|
+
}
|
|
328
|
+
// Skip leading zeroes in b256.
|
|
329
|
+
let it4 = size - length;
|
|
330
|
+
while (it4 !== size && b256[it4] === 0) {
|
|
331
|
+
it4++;
|
|
332
|
+
}
|
|
333
|
+
let vch = new Uint8Array(zeroes + (size - it4));
|
|
334
|
+
let j = zeroes;
|
|
335
|
+
while (it4 !== size) {
|
|
336
|
+
vch[j++] = b256[it4++];
|
|
337
|
+
}
|
|
338
|
+
return vch;
|
|
339
|
+
};
|
|
340
|
+
const decode = (string) => {
|
|
341
|
+
const buffer = decodeUnsafe(string);
|
|
342
|
+
if (buffer) {
|
|
343
|
+
return buffer;
|
|
344
|
+
}
|
|
345
|
+
throw new Error("Non-base" + BASE + " character");
|
|
346
|
+
};
|
|
347
|
+
return {
|
|
348
|
+
encode,
|
|
349
|
+
decodeUnsafe,
|
|
350
|
+
decode,
|
|
351
|
+
};
|
|
155
352
|
};
|
|
156
353
|
|
|
157
354
|
const ALPHABET$3 = "ABCDEFGHIJKLMNOPQRSTUVWXYZ234567";
|
|
@@ -338,7 +535,7 @@ var index$3 = (input, prefix) => {
|
|
|
338
535
|
return typedArray;
|
|
339
536
|
};
|
|
340
537
|
|
|
341
|
-
/*! pako 2.
|
|
538
|
+
/*! pako 2.2.0 https://github.com/nodeca/pako @license (MIT AND Zlib) */
|
|
342
539
|
// (C) 1995-2013 Jean-loup Gailly and Mark Adler
|
|
343
540
|
// (C) 2014-2017 Vitaly Puzrin and Andrey Tupitsin
|
|
344
541
|
//
|
|
@@ -1760,7 +1957,7 @@ const { _tr_init, _tr_stored_block, _tr_flush_block, _tr_tally, _tr_align } = tr
|
|
|
1760
1957
|
|
|
1761
1958
|
const {
|
|
1762
1959
|
Z_NO_FLUSH: Z_NO_FLUSH$2, Z_PARTIAL_FLUSH, Z_FULL_FLUSH: Z_FULL_FLUSH$1, Z_FINISH: Z_FINISH$3, Z_BLOCK: Z_BLOCK$1,
|
|
1763
|
-
Z_OK: Z_OK$3, Z_STREAM_END: Z_STREAM_END$3, Z_STREAM_ERROR: Z_STREAM_ERROR$2, Z_DATA_ERROR: Z_DATA_ERROR$2, Z_BUF_ERROR: Z_BUF_ERROR$
|
|
1960
|
+
Z_OK: Z_OK$3, Z_STREAM_END: Z_STREAM_END$3, Z_STREAM_ERROR: Z_STREAM_ERROR$2, Z_DATA_ERROR: Z_DATA_ERROR$2, Z_BUF_ERROR: Z_BUF_ERROR$2,
|
|
1764
1961
|
Z_DEFAULT_COMPRESSION: Z_DEFAULT_COMPRESSION$1,
|
|
1765
1962
|
Z_FILTERED, Z_HUFFMAN_ONLY, Z_RLE, Z_FIXED, Z_DEFAULT_STRATEGY: Z_DEFAULT_STRATEGY$1,
|
|
1766
1963
|
Z_UNKNOWN,
|
|
@@ -1859,11 +2056,35 @@ const slide_hash = (s) => {
|
|
|
1859
2056
|
};
|
|
1860
2057
|
|
|
1861
2058
|
/* eslint-disable new-cap */
|
|
1862
|
-
let
|
|
1863
|
-
|
|
1864
|
-
|
|
1865
|
-
|
|
1866
|
-
|
|
2059
|
+
let HASH = (s, prev, data) => ((prev << s.hash_shift) ^ data) & s.hash_mask;
|
|
2060
|
+
|
|
2061
|
+
|
|
2062
|
+
/* ===========================================================================
|
|
2063
|
+
* Insert string str in the dictionary and set match_head to the previous head
|
|
2064
|
+
* of the hash chain (the most recent string with same hash key). Return
|
|
2065
|
+
* the previous length of the hash chain.
|
|
2066
|
+
* IN assertion: all calls to INSERT_STRING are made with consecutive input
|
|
2067
|
+
* characters and the first MIN_MATCH bytes of str are valid (except for
|
|
2068
|
+
* the last MIN_MATCH-1 bytes of the input file).
|
|
2069
|
+
*/
|
|
2070
|
+
const INSERT_STRING = (s, str) => {
|
|
2071
|
+
let h;
|
|
2072
|
+
if (s.legacy_hash) {
|
|
2073
|
+
/* UPDATE_HASH(s, s->ins_h, s->window[(str) + (MIN_MATCH-1)]); */
|
|
2074
|
+
h = s.ins_h = HASH(s, s.ins_h, s.window[str + MIN_MATCH - 1]);
|
|
2075
|
+
} else {
|
|
2076
|
+
// ANZAC++ hash: reads 4 bytes, matches node.js zlib output (legacyHash
|
|
2077
|
+
// restores classic zlib hash). Faster, with fewer collisions.
|
|
2078
|
+
const w = s.window;
|
|
2079
|
+
// Read 4 bytes little-endian. Math.imul reproduces C uint32 overflow in
|
|
2080
|
+
// `(value * 66521 + 66521) >> 16` exactly.
|
|
2081
|
+
const value = w[str] | (w[str + 1] << 8) | (w[str + 2] << 16) | (w[str + 3] << 24);
|
|
2082
|
+
h = s.ins_h = ((Math.imul(value, 66521) + 66521) >>> 16) & s.hash_mask;
|
|
2083
|
+
}
|
|
2084
|
+
const hash_head = s.prev[str & s.w_mask] = s.head[h];
|
|
2085
|
+
s.head[h] = str;
|
|
2086
|
+
return hash_head;
|
|
2087
|
+
};
|
|
1867
2088
|
|
|
1868
2089
|
|
|
1869
2090
|
/* =========================================================================
|
|
@@ -2137,7 +2358,20 @@ const fill_window = (s) => {
|
|
|
2137
2358
|
s.lookahead += n;
|
|
2138
2359
|
|
|
2139
2360
|
/* Initialize the hash value now that we have some input: */
|
|
2140
|
-
if (s.
|
|
2361
|
+
if (!s.legacy_hash) {
|
|
2362
|
+
/* The 4-byte hash reads one extra byte, so it needs one more available. */
|
|
2363
|
+
if (s.lookahead + s.insert > MIN_MATCH) {
|
|
2364
|
+
str = s.strstart - s.insert;
|
|
2365
|
+
while (s.insert) {
|
|
2366
|
+
INSERT_STRING(s, str);
|
|
2367
|
+
str++;
|
|
2368
|
+
s.insert--;
|
|
2369
|
+
if (s.lookahead + s.insert <= MIN_MATCH) {
|
|
2370
|
+
break;
|
|
2371
|
+
}
|
|
2372
|
+
}
|
|
2373
|
+
}
|
|
2374
|
+
} else if (s.lookahead + s.insert >= MIN_MATCH) {
|
|
2141
2375
|
str = s.strstart - s.insert;
|
|
2142
2376
|
s.ins_h = s.window[str];
|
|
2143
2377
|
|
|
@@ -2147,11 +2381,7 @@ const fill_window = (s) => {
|
|
|
2147
2381
|
// Call update_hash() MIN_MATCH-3 more times
|
|
2148
2382
|
//#endif
|
|
2149
2383
|
while (s.insert) {
|
|
2150
|
-
|
|
2151
|
-
s.ins_h = HASH(s, s.ins_h, s.window[str + MIN_MATCH - 1]);
|
|
2152
|
-
|
|
2153
|
-
s.prev[str & s.w_mask] = s.head[s.ins_h];
|
|
2154
|
-
s.head[s.ins_h] = str;
|
|
2384
|
+
INSERT_STRING(s, str);
|
|
2155
2385
|
str++;
|
|
2156
2386
|
s.insert--;
|
|
2157
2387
|
if (s.lookahead + s.insert < MIN_MATCH) {
|
|
@@ -2449,11 +2679,7 @@ const deflate_fast = (s, flush) => {
|
|
|
2449
2679
|
*/
|
|
2450
2680
|
hash_head = 0/*NIL*/;
|
|
2451
2681
|
if (s.lookahead >= MIN_MATCH) {
|
|
2452
|
-
|
|
2453
|
-
s.ins_h = HASH(s, s.ins_h, s.window[s.strstart + MIN_MATCH - 1]);
|
|
2454
|
-
hash_head = s.prev[s.strstart & s.w_mask] = s.head[s.ins_h];
|
|
2455
|
-
s.head[s.ins_h] = s.strstart;
|
|
2456
|
-
/***/
|
|
2682
|
+
hash_head = INSERT_STRING(s, s.strstart);
|
|
2457
2683
|
}
|
|
2458
2684
|
|
|
2459
2685
|
/* Find the longest match, discarding those <= prev_length.
|
|
@@ -2483,11 +2709,7 @@ const deflate_fast = (s, flush) => {
|
|
|
2483
2709
|
s.match_length--; /* string at strstart already in table */
|
|
2484
2710
|
do {
|
|
2485
2711
|
s.strstart++;
|
|
2486
|
-
|
|
2487
|
-
s.ins_h = HASH(s, s.ins_h, s.window[s.strstart + MIN_MATCH - 1]);
|
|
2488
|
-
hash_head = s.prev[s.strstart & s.w_mask] = s.head[s.ins_h];
|
|
2489
|
-
s.head[s.ins_h] = s.strstart;
|
|
2490
|
-
/***/
|
|
2712
|
+
hash_head = INSERT_STRING(s, s.strstart);
|
|
2491
2713
|
/* strstart never exceeds WSIZE-MAX_MATCH, so there are
|
|
2492
2714
|
* always MIN_MATCH bytes ahead.
|
|
2493
2715
|
*/
|
|
@@ -2497,16 +2719,18 @@ const deflate_fast = (s, flush) => {
|
|
|
2497
2719
|
{
|
|
2498
2720
|
s.strstart += s.match_length;
|
|
2499
2721
|
s.match_length = 0;
|
|
2500
|
-
s.
|
|
2501
|
-
|
|
2502
|
-
|
|
2722
|
+
if (s.legacy_hash) {
|
|
2723
|
+
s.ins_h = s.window[s.strstart];
|
|
2724
|
+
/* UPDATE_HASH(s, s.ins_h, s.window[s.strstart+1]); */
|
|
2725
|
+
s.ins_h = HASH(s, s.ins_h, s.window[s.strstart + 1]);
|
|
2503
2726
|
|
|
2504
2727
|
//#if MIN_MATCH != 3
|
|
2505
2728
|
// Call UPDATE_HASH() MIN_MATCH-3 more times
|
|
2506
2729
|
//#endif
|
|
2507
|
-
|
|
2508
|
-
|
|
2509
|
-
|
|
2730
|
+
/* If lookahead < MIN_MATCH, ins_h is garbage, but it does not
|
|
2731
|
+
* matter since it will be recomputed at next deflate call.
|
|
2732
|
+
*/
|
|
2733
|
+
}
|
|
2510
2734
|
}
|
|
2511
2735
|
} else {
|
|
2512
2736
|
/* No match, output a literal byte */
|
|
@@ -2579,11 +2803,7 @@ const deflate_slow = (s, flush) => {
|
|
|
2579
2803
|
*/
|
|
2580
2804
|
hash_head = 0/*NIL*/;
|
|
2581
2805
|
if (s.lookahead >= MIN_MATCH) {
|
|
2582
|
-
|
|
2583
|
-
s.ins_h = HASH(s, s.ins_h, s.window[s.strstart + MIN_MATCH - 1]);
|
|
2584
|
-
hash_head = s.prev[s.strstart & s.w_mask] = s.head[s.ins_h];
|
|
2585
|
-
s.head[s.ins_h] = s.strstart;
|
|
2586
|
-
/***/
|
|
2806
|
+
hash_head = INSERT_STRING(s, s.strstart);
|
|
2587
2807
|
}
|
|
2588
2808
|
|
|
2589
2809
|
/* Find the longest match, discarding those <= prev_length.
|
|
@@ -2631,11 +2851,7 @@ const deflate_slow = (s, flush) => {
|
|
|
2631
2851
|
s.prev_length -= 2;
|
|
2632
2852
|
do {
|
|
2633
2853
|
if (++s.strstart <= max_insert) {
|
|
2634
|
-
|
|
2635
|
-
s.ins_h = HASH(s, s.ins_h, s.window[s.strstart + MIN_MATCH - 1]);
|
|
2636
|
-
hash_head = s.prev[s.strstart & s.w_mask] = s.head[s.ins_h];
|
|
2637
|
-
s.head[s.ins_h] = s.strstart;
|
|
2638
|
-
/***/
|
|
2854
|
+
hash_head = INSERT_STRING(s, s.strstart);
|
|
2639
2855
|
}
|
|
2640
2856
|
} while (--s.prev_length !== 0);
|
|
2641
2857
|
s.match_available = 0;
|
|
@@ -2960,6 +3176,7 @@ function DeflateState() {
|
|
|
2960
3176
|
this.head = null; /* Heads of the hash chains or NIL. */
|
|
2961
3177
|
|
|
2962
3178
|
this.ins_h = 0; /* hash index of string to be inserted */
|
|
3179
|
+
this.legacy_hash = 0; /* use classic zlib hash instead of default ANZAC++ */
|
|
2963
3180
|
this.hash_size = 0; /* number of elements in hash table */
|
|
2964
3181
|
this.hash_bits = 0; /* log2(hash_size) */
|
|
2965
3182
|
this.hash_mask = 0; /* hash_size-1 */
|
|
@@ -3182,7 +3399,7 @@ const deflateSetHeader = (strm, head) => {
|
|
|
3182
3399
|
};
|
|
3183
3400
|
|
|
3184
3401
|
|
|
3185
|
-
const deflateInit2 = (strm, level, method, windowBits, memLevel, strategy) => {
|
|
3402
|
+
const deflateInit2 = (strm, level, method, windowBits, memLevel, strategy, legacyHash) => {
|
|
3186
3403
|
|
|
3187
3404
|
if (!strm) { // === Z_NULL
|
|
3188
3405
|
return Z_STREAM_ERROR$2;
|
|
@@ -3228,7 +3445,13 @@ const deflateInit2 = (strm, level, method, windowBits, memLevel, strategy) => {
|
|
|
3228
3445
|
s.w_size = 1 << s.w_bits;
|
|
3229
3446
|
s.w_mask = s.w_size - 1;
|
|
3230
3447
|
|
|
3448
|
+
s.legacy_hash = legacyHash ? 1 : 0;
|
|
3449
|
+
|
|
3231
3450
|
s.hash_bits = memLevel + 7;
|
|
3451
|
+
/* ANZAC++ hash needs >= 15 hash bits to span its 4 read bytes. */
|
|
3452
|
+
if (!s.legacy_hash && s.hash_bits < 15) {
|
|
3453
|
+
s.hash_bits = 15;
|
|
3454
|
+
}
|
|
3232
3455
|
s.hash_size = 1 << s.hash_bits;
|
|
3233
3456
|
s.hash_mask = s.hash_size - 1;
|
|
3234
3457
|
s.hash_shift = ~~((s.hash_bits + MIN_MATCH - 1) / MIN_MATCH);
|
|
@@ -3320,7 +3543,7 @@ const deflate$2 = (strm, flush) => {
|
|
|
3320
3543
|
if (!strm.output ||
|
|
3321
3544
|
(strm.avail_in !== 0 && !strm.input) ||
|
|
3322
3545
|
(s.status === FINISH_STATE && flush !== Z_FINISH$3)) {
|
|
3323
|
-
return err(strm, (strm.avail_out === 0) ? Z_BUF_ERROR$
|
|
3546
|
+
return err(strm, (strm.avail_out === 0) ? Z_BUF_ERROR$2 : Z_STREAM_ERROR$2);
|
|
3324
3547
|
}
|
|
3325
3548
|
|
|
3326
3549
|
const old_flush = s.last_flush;
|
|
@@ -3346,12 +3569,12 @@ const deflate$2 = (strm, flush) => {
|
|
|
3346
3569
|
*/
|
|
3347
3570
|
} else if (strm.avail_in === 0 && rank(flush) <= rank(old_flush) &&
|
|
3348
3571
|
flush !== Z_FINISH$3) {
|
|
3349
|
-
return err(strm, Z_BUF_ERROR$
|
|
3572
|
+
return err(strm, Z_BUF_ERROR$2);
|
|
3350
3573
|
}
|
|
3351
3574
|
|
|
3352
3575
|
/* User must not provide more input after the first FINISH: */
|
|
3353
3576
|
if (s.status === FINISH_STATE && strm.avail_in !== 0) {
|
|
3354
|
-
return err(strm, Z_BUF_ERROR$
|
|
3577
|
+
return err(strm, Z_BUF_ERROR$2);
|
|
3355
3578
|
}
|
|
3356
3579
|
|
|
3357
3580
|
/* Write the header */
|
|
@@ -3732,12 +3955,7 @@ const deflateSetDictionary = (strm, dictionary) => {
|
|
|
3732
3955
|
let str = s.strstart;
|
|
3733
3956
|
let n = s.lookahead - (MIN_MATCH - 1);
|
|
3734
3957
|
do {
|
|
3735
|
-
|
|
3736
|
-
s.ins_h = HASH(s, s.ins_h, s.window[str + MIN_MATCH - 1]);
|
|
3737
|
-
|
|
3738
|
-
s.prev[str & s.w_mask] = s.head[s.ins_h];
|
|
3739
|
-
|
|
3740
|
-
s.head[s.ins_h] = str;
|
|
3958
|
+
INSERT_STRING(s, str);
|
|
3741
3959
|
str++;
|
|
3742
3960
|
} while (--n);
|
|
3743
3961
|
s.strstart = str;
|
|
@@ -3861,7 +4079,7 @@ const _utf8len = new Uint8Array(256);
|
|
|
3861
4079
|
for (let q = 0; q < 256; q++) {
|
|
3862
4080
|
_utf8len[q] = (q >= 252 ? 6 : q >= 248 ? 5 : q >= 240 ? 4 : q >= 224 ? 3 : q >= 192 ? 2 : 1);
|
|
3863
4081
|
}
|
|
3864
|
-
_utf8len[254] = _utf8len[
|
|
4082
|
+
_utf8len[254] = _utf8len[255] = 1; // Invalid sequence start
|
|
3865
4083
|
|
|
3866
4084
|
|
|
3867
4085
|
// convert string to array (typed, when possible)
|
|
@@ -4082,6 +4300,15 @@ const {
|
|
|
4082
4300
|
|
|
4083
4301
|
/* ===========================================================================*/
|
|
4084
4302
|
|
|
4303
|
+
const defaultOptions$1 = {
|
|
4304
|
+
level: Z_DEFAULT_COMPRESSION,
|
|
4305
|
+
method: Z_DEFLATED$1,
|
|
4306
|
+
chunkSize: 16384,
|
|
4307
|
+
windowBits: 15,
|
|
4308
|
+
memLevel: 8,
|
|
4309
|
+
strategy: Z_DEFAULT_STRATEGY,
|
|
4310
|
+
legacyHash: true
|
|
4311
|
+
};
|
|
4085
4312
|
|
|
4086
4313
|
/**
|
|
4087
4314
|
* class Deflate
|
|
@@ -4137,6 +4364,10 @@ const {
|
|
|
4137
4364
|
* [http://zlib.net/manual.html#Advanced](http://zlib.net/manual.html#Advanced)
|
|
4138
4365
|
* for more information on these.
|
|
4139
4366
|
*
|
|
4367
|
+
* - `legacyHash` (Boolean) - use the classic zlib hash (default), which matches
|
|
4368
|
+
* canonical zlib output byte-for-byte. Set to `false` to use the faster
|
|
4369
|
+
* ANZAC++ hash, which matches recent (chromium) node.js output instead.
|
|
4370
|
+
*
|
|
4140
4371
|
* Additional options, for internal needs:
|
|
4141
4372
|
*
|
|
4142
4373
|
* - `chunkSize` - size of generated data chunks (16K by default)
|
|
@@ -4169,14 +4400,7 @@ const {
|
|
|
4169
4400
|
* ```
|
|
4170
4401
|
**/
|
|
4171
4402
|
function Deflate$1(options) {
|
|
4172
|
-
this.options = common.assign({
|
|
4173
|
-
level: Z_DEFAULT_COMPRESSION,
|
|
4174
|
-
method: Z_DEFLATED$1,
|
|
4175
|
-
chunkSize: 16384,
|
|
4176
|
-
windowBits: 15,
|
|
4177
|
-
memLevel: 8,
|
|
4178
|
-
strategy: Z_DEFAULT_STRATEGY
|
|
4179
|
-
}, options || {});
|
|
4403
|
+
this.options = common.assign({}, defaultOptions$1, options || {});
|
|
4180
4404
|
|
|
4181
4405
|
let opt = this.options;
|
|
4182
4406
|
|
|
@@ -4202,7 +4426,8 @@ function Deflate$1(options) {
|
|
|
4202
4426
|
opt.method,
|
|
4203
4427
|
opt.windowBits,
|
|
4204
4428
|
opt.memLevel,
|
|
4205
|
-
opt.strategy
|
|
4429
|
+
opt.strategy,
|
|
4430
|
+
opt.legacyHash
|
|
4206
4431
|
);
|
|
4207
4432
|
|
|
4208
4433
|
if (status !== Z_OK$2) {
|
|
@@ -4822,7 +5047,7 @@ const lbase = new Uint16Array([ /* Length codes 257..285 base */
|
|
|
4822
5047
|
|
|
4823
5048
|
const lext = new Uint8Array([ /* Length codes 257..285 extra */
|
|
4824
5049
|
16, 16, 16, 16, 16, 16, 16, 16, 17, 17, 17, 17, 18, 18, 18, 18,
|
|
4825
|
-
19, 19, 19, 19, 20, 20, 20, 20, 21, 21, 21, 21, 16,
|
|
5050
|
+
19, 19, 19, 19, 20, 20, 20, 20, 21, 21, 21, 21, 16, 199, 75
|
|
4826
5051
|
]);
|
|
4827
5052
|
|
|
4828
5053
|
const dbase = new Uint16Array([ /* Distance codes 0..29 base */
|
|
@@ -5159,7 +5384,7 @@ const DISTS = 2;
|
|
|
5159
5384
|
|
|
5160
5385
|
const {
|
|
5161
5386
|
Z_FINISH: Z_FINISH$1, Z_BLOCK, Z_TREES,
|
|
5162
|
-
Z_OK: Z_OK$1, Z_STREAM_END: Z_STREAM_END$1, Z_NEED_DICT: Z_NEED_DICT$1, Z_STREAM_ERROR: Z_STREAM_ERROR$1, Z_DATA_ERROR: Z_DATA_ERROR$1, Z_MEM_ERROR: Z_MEM_ERROR$1, Z_BUF_ERROR,
|
|
5387
|
+
Z_OK: Z_OK$1, Z_STREAM_END: Z_STREAM_END$1, Z_NEED_DICT: Z_NEED_DICT$1, Z_STREAM_ERROR: Z_STREAM_ERROR$1, Z_DATA_ERROR: Z_DATA_ERROR$1, Z_MEM_ERROR: Z_MEM_ERROR$1, Z_BUF_ERROR: Z_BUF_ERROR$1,
|
|
5163
5388
|
Z_DEFLATED
|
|
5164
5389
|
} = constants$2;
|
|
5165
5390
|
|
|
@@ -5469,11 +5694,14 @@ const updatewindow = (strm, src, end, copy) => {
|
|
|
5469
5694
|
|
|
5470
5695
|
/* if it hasn't been done already, allocate space for the window */
|
|
5471
5696
|
if (state.window === null) {
|
|
5697
|
+
state.window = new Uint8Array(1 << state.wbits);
|
|
5698
|
+
}
|
|
5699
|
+
|
|
5700
|
+
/* if window not in use yet, initialize */
|
|
5701
|
+
if (state.wsize === 0) {
|
|
5472
5702
|
state.wsize = 1 << state.wbits;
|
|
5473
5703
|
state.wnext = 0;
|
|
5474
5704
|
state.whave = 0;
|
|
5475
|
-
|
|
5476
|
-
state.window = new Uint8Array(state.wsize);
|
|
5477
5705
|
}
|
|
5478
5706
|
|
|
5479
5707
|
/* copy state->wsize or less output bytes into the circular window */
|
|
@@ -6599,7 +6827,7 @@ const inflate$2 = (strm, flush) => {
|
|
|
6599
6827
|
(state.mode === TYPE ? 128 : 0) +
|
|
6600
6828
|
(state.mode === LEN_ || state.mode === COPY_ ? 256 : 0);
|
|
6601
6829
|
if (((_in === 0 && _out === 0) || flush === Z_FINISH$1) && ret === Z_OK$1) {
|
|
6602
|
-
ret = Z_BUF_ERROR;
|
|
6830
|
+
ret = Z_BUF_ERROR$1;
|
|
6603
6831
|
}
|
|
6604
6832
|
return ret;
|
|
6605
6833
|
};
|
|
@@ -6771,11 +6999,16 @@ const toString$2 = Object.prototype.toString;
|
|
|
6771
6999
|
|
|
6772
7000
|
const {
|
|
6773
7001
|
Z_NO_FLUSH, Z_FINISH,
|
|
6774
|
-
Z_OK, Z_STREAM_END, Z_NEED_DICT, Z_STREAM_ERROR, Z_DATA_ERROR, Z_MEM_ERROR
|
|
7002
|
+
Z_OK, Z_STREAM_END, Z_NEED_DICT, Z_STREAM_ERROR, Z_DATA_ERROR, Z_MEM_ERROR, Z_BUF_ERROR
|
|
6775
7003
|
} = constants$2;
|
|
6776
7004
|
|
|
6777
7005
|
/* ===========================================================================*/
|
|
6778
7006
|
|
|
7007
|
+
const defaultOptions = {
|
|
7008
|
+
chunkSize: 1024 * 64,
|
|
7009
|
+
windowBits: 15,
|
|
7010
|
+
to: ''
|
|
7011
|
+
};
|
|
6779
7012
|
|
|
6780
7013
|
/**
|
|
6781
7014
|
* class Inflate
|
|
@@ -6855,11 +7088,7 @@ const {
|
|
|
6855
7088
|
* ```
|
|
6856
7089
|
**/
|
|
6857
7090
|
function Inflate$1(options) {
|
|
6858
|
-
this.options = common.assign({
|
|
6859
|
-
chunkSize: 1024 * 64,
|
|
6860
|
-
windowBits: 15,
|
|
6861
|
-
to: ''
|
|
6862
|
-
}, options || {});
|
|
7091
|
+
this.options = common.assign({}, defaultOptions, options || {});
|
|
6863
7092
|
|
|
6864
7093
|
const opt = this.options;
|
|
6865
7094
|
|
|
@@ -6990,11 +7219,19 @@ Inflate$1.prototype.push = function (data, flush_mode) {
|
|
|
6990
7219
|
}
|
|
6991
7220
|
}
|
|
6992
7221
|
|
|
6993
|
-
//
|
|
7222
|
+
// Only the gzip format defines concatenated members (RFC 1952: a gzip file
|
|
7223
|
+
// is "a series of members"). A zlib stream (RFC 1950) ends after its
|
|
7224
|
+
// ADLER32, and a raw DEFLATE stream (RFC 1951) ends after its final block -
|
|
7225
|
+
// neither format allows anything to follow, so bytes after the end are not
|
|
7226
|
+
// ours to interpret and must be left in the input. Restart decoding only
|
|
7227
|
+
// for a gzip member: `state.flags` is non-zero only once a gzip header has
|
|
7228
|
+
// actually been decoded (it stays 0 for a zlib member, even when the format
|
|
7229
|
+
// was auto-detected and the gzip bit of `wrap` is set). A trailing zero
|
|
7230
|
+
// byte is padding, not the start of a member (no member can begin with 0).
|
|
6994
7231
|
while (strm.avail_in > 0 &&
|
|
6995
7232
|
status === Z_STREAM_END &&
|
|
6996
|
-
strm.state.wrap
|
|
6997
|
-
|
|
7233
|
+
(strm.state.wrap & 2) && strm.state.flags !== 0 &&
|
|
7234
|
+
strm.input[strm.next_in] !== 0)
|
|
6998
7235
|
{
|
|
6999
7236
|
inflate_1$2.inflateReset(strm);
|
|
7000
7237
|
status = inflate_1$2.inflate(strm, _flush_mode);
|
|
@@ -7015,7 +7252,9 @@ Inflate$1.prototype.push = function (data, flush_mode) {
|
|
|
7015
7252
|
last_avail_out = strm.avail_out;
|
|
7016
7253
|
|
|
7017
7254
|
if (strm.next_out) {
|
|
7018
|
-
if
|
|
7255
|
+
// Flush output if buffer is full, stream ended, or an explicit flush was
|
|
7256
|
+
// requested (e.g. Z_SYNC_FLUSH) - to push out the tail, same as node's zlib.
|
|
7257
|
+
if (strm.avail_out === 0 || status === Z_STREAM_END || _flush_mode > 0) {
|
|
7019
7258
|
|
|
7020
7259
|
if (this.options.to === 'string') {
|
|
7021
7260
|
|
|
@@ -7033,12 +7272,22 @@ Inflate$1.prototype.push = function (data, flush_mode) {
|
|
|
7033
7272
|
|
|
7034
7273
|
} else {
|
|
7035
7274
|
this.onData(strm.output.length === strm.next_out ? strm.output : strm.output.subarray(0, strm.next_out));
|
|
7275
|
+
|
|
7276
|
+
// Force a fresh output buffer on next iteration / next push, so the
|
|
7277
|
+
// already emitted tail is not sent again.
|
|
7278
|
+
strm.avail_out = 0;
|
|
7279
|
+
strm.next_out = 0;
|
|
7036
7280
|
}
|
|
7037
7281
|
}
|
|
7038
7282
|
}
|
|
7039
7283
|
|
|
7040
|
-
//
|
|
7041
|
-
|
|
7284
|
+
// A full output buffer means there may be more to produce - allocate a new
|
|
7285
|
+
// one and call inflate again. The status depends on the flush mode: with
|
|
7286
|
+
// Z_NO_FLUSH a full buffer is reported as Z_OK, but with Z_FINISH the same
|
|
7287
|
+
// situation is reported as Z_BUF_ERROR ("could not make progress now",
|
|
7288
|
+
// non-fatal) even though output is still pending. Both must continue; the
|
|
7289
|
+
// distinction that matters is purely "was the output buffer exhausted".
|
|
7290
|
+
if ((status === Z_OK || status === Z_BUF_ERROR) && last_avail_out === 0) continue;
|
|
7042
7291
|
|
|
7043
7292
|
// Finalize if end of stream reached.
|
|
7044
7293
|
if (status === Z_STREAM_END) {
|
|
@@ -7048,7 +7297,23 @@ Inflate$1.prototype.push = function (data, flush_mode) {
|
|
|
7048
7297
|
return true;
|
|
7049
7298
|
}
|
|
7050
7299
|
|
|
7051
|
-
if (strm.avail_in === 0)
|
|
7300
|
+
if (strm.avail_in === 0) {
|
|
7301
|
+
// Input is exhausted. If the caller declared this the end of the stream
|
|
7302
|
+
// (Z_FINISH) but we never saw Z_STREAM_END, the compressed data ended
|
|
7303
|
+
// before its terminating marker - i.e. it is truncated/incomplete. That
|
|
7304
|
+
// is an error: returning the partial output as success would be
|
|
7305
|
+
// indistinguishable from a complete decode, hiding the data loss. Report
|
|
7306
|
+
// it via Z_BUF_ERROR. (Reached only when the output buffer still had room
|
|
7307
|
+
// - a full buffer is handled by the `continue` above - so this genuinely
|
|
7308
|
+
// means "ran out of input", not "ran out of output".)
|
|
7309
|
+
if (_flush_mode === Z_FINISH) {
|
|
7310
|
+
status = inflate_1$2.inflateEnd(this.strm);
|
|
7311
|
+
this.onEnd(status === Z_OK ? Z_BUF_ERROR : status);
|
|
7312
|
+
this.ended = true;
|
|
7313
|
+
return false;
|
|
7314
|
+
}
|
|
7315
|
+
break;
|
|
7316
|
+
}
|
|
7052
7317
|
}
|
|
7053
7318
|
|
|
7054
7319
|
return true;
|
|
@@ -7134,7 +7399,7 @@ Inflate$1.prototype.onEnd = function (status) {
|
|
|
7134
7399
|
function inflate$1(input, options) {
|
|
7135
7400
|
const inflator = new Inflate$1(options);
|
|
7136
7401
|
|
|
7137
|
-
inflator.push(input);
|
|
7402
|
+
inflator.push(input, true);
|
|
7138
7403
|
|
|
7139
7404
|
// That will never happens, if you don't cheat with options :)
|
|
7140
7405
|
if (inflator.err) throw inflator.msg || messages[inflator.err];
|
|
@@ -7284,10 +7549,14 @@ var index$2 = (typedArray, prefix) => {
|
|
|
7284
7549
|
};
|
|
7285
7550
|
|
|
7286
7551
|
const ALPHABET$1 = '0123456789ABCDEF';
|
|
7287
|
-
base(ALPHABET$1);
|
|
7552
|
+
const base16 = base(ALPHABET$1);
|
|
7553
|
+
base16.decode;
|
|
7554
|
+
base16.encode;
|
|
7288
7555
|
|
|
7289
7556
|
const ALPHABET = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_';
|
|
7290
|
-
base(ALPHABET);
|
|
7557
|
+
const base64 = base(ALPHABET);
|
|
7558
|
+
base64.decode;
|
|
7559
|
+
base64.encode;
|
|
7291
7560
|
|
|
7292
7561
|
/**
|
|
7293
7562
|
* Returns a Uint8Array as String
|