ry-vue-map 0.6.0 → 0.6.2
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 +1 -1
- package/lib/ryui.common.0.js +625 -794
- package/lib/ryui.common.0.js.gz +0 -0
- package/lib/ryui.common.2.js +125 -125
- package/lib/ryui.common.2.js.gz +0 -0
- package/lib/ryui.common.3.js +125 -125
- package/lib/ryui.common.4.js +5 -5
- package/lib/ryui.common.5.js +21 -21
- package/lib/ryui.common.6.js +5 -5
- package/lib/ryui.common.7.js +47 -47
- package/lib/ryui.common.7.js.gz +0 -0
- package/lib/ryui.common.8.js +3 -3
- package/lib/ryui.common.8.js.gz +0 -0
- package/lib/ryui.common.9.js +3 -3
- package/lib/ryui.common.js +78394 -105881
- package/lib/ryui.common.js.gz +0 -0
- package/lib/ryui.css +1 -1
- package/lib/ryui.css.gz +0 -0
- package/lib/ryui.umd.0.js +625 -794
- package/lib/ryui.umd.0.js.gz +0 -0
- package/lib/ryui.umd.2.js +125 -125
- package/lib/ryui.umd.2.js.gz +0 -0
- package/lib/ryui.umd.3.js +125 -125
- package/lib/ryui.umd.4.js +5 -5
- package/lib/ryui.umd.5.js +21 -21
- package/lib/ryui.umd.6.js +5 -5
- package/lib/ryui.umd.7.js +47 -47
- package/lib/ryui.umd.7.js.gz +0 -0
- package/lib/ryui.umd.8.js +3 -3
- package/lib/ryui.umd.8.js.gz +0 -0
- package/lib/ryui.umd.9.js +3 -3
- package/lib/ryui.umd.js +78394 -105881
- package/lib/ryui.umd.js.gz +0 -0
- package/lib/ryui.umd.min.0.js +3 -3
- package/lib/ryui.umd.min.0.js.gz +0 -0
- package/lib/ryui.umd.min.2.js +1 -1
- package/lib/ryui.umd.min.2.js.gz +0 -0
- package/lib/ryui.umd.min.3.js +1 -1
- package/lib/ryui.umd.min.4.js +1 -1
- package/lib/ryui.umd.min.5.js +1 -1
- package/lib/ryui.umd.min.6.js +1 -1
- package/lib/ryui.umd.min.7.js +2 -2
- package/lib/ryui.umd.min.7.js.gz +0 -0
- package/lib/ryui.umd.min.8.js +1 -1
- package/lib/ryui.umd.min.8.js.gz +0 -0
- package/lib/ryui.umd.min.9.js +1 -1
- package/lib/ryui.umd.min.js +6 -8
- package/lib/ryui.umd.min.js.gz +0 -0
- package/package.json +2 -2
- package/src/components/maps/models/ryLines/ryLines.js +6 -0
- package/src/components/maps/models/ryMapTool/mapTool.js +7 -2
- package/src/components/maps/ryLines/src/index.vue +43 -1
- package/src/components/maps/ryMap/src/index.vue +4 -6
- package/src/components/maps/ryMapTool/src/index.vue +85 -67
- package/src/utils/lMapServices.js +13 -4
- package/src/views/map/index.vue +1006 -216
package/lib/ryui.common.0.js
CHANGED
|
@@ -1,129 +1,6 @@
|
|
|
1
1
|
((typeof self !== 'undefined' ? self : this)["webpackJsonpryui"] = (typeof self !== 'undefined' ? self : this)["webpackJsonpryui"] || []).push([[0],{
|
|
2
2
|
|
|
3
|
-
/***/ "
|
|
4
|
-
/***/ (function(module, __webpack_exports__, __webpack_require__) {
|
|
5
|
-
|
|
6
|
-
"use strict";
|
|
7
|
-
|
|
8
|
-
// EXPORTS
|
|
9
|
-
__webpack_require__.d(__webpack_exports__, "a", function() { return /* binding */ basedecoder_BaseDecoder; });
|
|
10
|
-
|
|
11
|
-
// CONCATENATED MODULE: ./node_modules/.store/geotiff@2.0.4/node_modules/geotiff/dist-module/predictor.js
|
|
12
|
-
function decodeRowAcc(row, stride) {
|
|
13
|
-
let length = row.length - stride;
|
|
14
|
-
let offset = 0;
|
|
15
|
-
do {
|
|
16
|
-
for (let i = stride; i > 0; i--) {
|
|
17
|
-
row[offset + stride] += row[offset];
|
|
18
|
-
offset++;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
length -= stride;
|
|
22
|
-
} while (length > 0);
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
function decodeRowFloatingPoint(row, stride, bytesPerSample) {
|
|
26
|
-
let index = 0;
|
|
27
|
-
let count = row.length;
|
|
28
|
-
const wc = count / bytesPerSample;
|
|
29
|
-
|
|
30
|
-
while (count > stride) {
|
|
31
|
-
for (let i = stride; i > 0; --i) {
|
|
32
|
-
row[index + stride] += row[index];
|
|
33
|
-
++index;
|
|
34
|
-
}
|
|
35
|
-
count -= stride;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
const copy = row.slice();
|
|
39
|
-
for (let i = 0; i < wc; ++i) {
|
|
40
|
-
for (let b = 0; b < bytesPerSample; ++b) {
|
|
41
|
-
row[(bytesPerSample * i) + b] = copy[((bytesPerSample - b - 1) * wc) + i];
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
function applyPredictor(block, predictor, width, height, bitsPerSample,
|
|
47
|
-
planarConfiguration) {
|
|
48
|
-
if (!predictor || predictor === 1) {
|
|
49
|
-
return block;
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
for (let i = 0; i < bitsPerSample.length; ++i) {
|
|
53
|
-
if (bitsPerSample[i] % 8 !== 0) {
|
|
54
|
-
throw new Error('When decoding with predictor, only multiple of 8 bits are supported.');
|
|
55
|
-
}
|
|
56
|
-
if (bitsPerSample[i] !== bitsPerSample[0]) {
|
|
57
|
-
throw new Error('When decoding with predictor, all samples must have the same size.');
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
const bytesPerSample = bitsPerSample[0] / 8;
|
|
62
|
-
const stride = planarConfiguration === 2 ? 1 : bitsPerSample.length;
|
|
63
|
-
|
|
64
|
-
for (let i = 0; i < height; ++i) {
|
|
65
|
-
// Last strip will be truncated if height % stripHeight != 0
|
|
66
|
-
if (i * stride * width * bytesPerSample >= block.byteLength) {
|
|
67
|
-
break;
|
|
68
|
-
}
|
|
69
|
-
let row;
|
|
70
|
-
if (predictor === 2) { // horizontal prediction
|
|
71
|
-
switch (bitsPerSample[0]) {
|
|
72
|
-
case 8:
|
|
73
|
-
row = new Uint8Array(
|
|
74
|
-
block, i * stride * width * bytesPerSample, stride * width * bytesPerSample,
|
|
75
|
-
);
|
|
76
|
-
break;
|
|
77
|
-
case 16:
|
|
78
|
-
row = new Uint16Array(
|
|
79
|
-
block, i * stride * width * bytesPerSample, stride * width * bytesPerSample / 2,
|
|
80
|
-
);
|
|
81
|
-
break;
|
|
82
|
-
case 32:
|
|
83
|
-
row = new Uint32Array(
|
|
84
|
-
block, i * stride * width * bytesPerSample, stride * width * bytesPerSample / 4,
|
|
85
|
-
);
|
|
86
|
-
break;
|
|
87
|
-
default:
|
|
88
|
-
throw new Error(`Predictor 2 not allowed with ${bitsPerSample[0]} bits per sample.`);
|
|
89
|
-
}
|
|
90
|
-
decodeRowAcc(row, stride, bytesPerSample);
|
|
91
|
-
} else if (predictor === 3) { // horizontal floating point
|
|
92
|
-
row = new Uint8Array(
|
|
93
|
-
block, i * stride * width * bytesPerSample, stride * width * bytesPerSample,
|
|
94
|
-
);
|
|
95
|
-
decodeRowFloatingPoint(row, stride, bytesPerSample);
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
return block;
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
// CONCATENATED MODULE: ./node_modules/.store/geotiff@2.0.4/node_modules/geotiff/dist-module/compression/basedecoder.js
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
class basedecoder_BaseDecoder {
|
|
105
|
-
async decode(fileDirectory, buffer) {
|
|
106
|
-
const decoded = await this.decodeBlock(buffer);
|
|
107
|
-
const predictor = fileDirectory.Predictor || 1;
|
|
108
|
-
if (predictor !== 1) {
|
|
109
|
-
const isTiled = !fileDirectory.StripOffsets;
|
|
110
|
-
const tileWidth = isTiled ? fileDirectory.TileWidth : fileDirectory.ImageWidth;
|
|
111
|
-
const tileHeight = isTiled ? fileDirectory.TileLength : (
|
|
112
|
-
fileDirectory.RowsPerStrip || fileDirectory.ImageLength
|
|
113
|
-
);
|
|
114
|
-
return applyPredictor(
|
|
115
|
-
decoded, predictor, tileWidth, tileHeight, fileDirectory.BitsPerSample,
|
|
116
|
-
fileDirectory.PlanarConfiguration,
|
|
117
|
-
);
|
|
118
|
-
}
|
|
119
|
-
return decoded;
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
/***/ }),
|
|
125
|
-
|
|
126
|
-
/***/ "6caf":
|
|
3
|
+
/***/ "acff":
|
|
127
4
|
/***/ (function(__webpack_module__, __webpack_exports__, __webpack_require__) {
|
|
128
5
|
|
|
129
6
|
"use strict";
|
|
@@ -138,7 +15,7 @@ class basedecoder_BaseDecoder {
|
|
|
138
15
|
/* unused harmony export inflateRaw */
|
|
139
16
|
/* unused harmony export ungzip */
|
|
140
17
|
|
|
141
|
-
/*! pako 2.
|
|
18
|
+
/*! pako 2.0.4 https://github.com/nodeca/pako @license (MIT AND Zlib) */
|
|
142
19
|
// (C) 1995-2013 Jean-loup Gailly and Mark Adler
|
|
143
20
|
// (C) 2014-2017 Vitaly Puzrin and Andrey Tupitsin
|
|
144
21
|
//
|
|
@@ -415,10 +292,10 @@ const bi_flush = (s) => {
|
|
|
415
292
|
* The length opt_len is updated; static_len is also updated if stree is
|
|
416
293
|
* not null.
|
|
417
294
|
*/
|
|
418
|
-
const gen_bitlen = (s, desc) =>
|
|
295
|
+
const gen_bitlen = (s, desc) =>
|
|
419
296
|
// deflate_state *s;
|
|
420
297
|
// tree_desc *desc; /* the tree descriptor */
|
|
421
|
-
|
|
298
|
+
{
|
|
422
299
|
const tree = desc.dyn_tree;
|
|
423
300
|
const max_code = desc.max_code;
|
|
424
301
|
const stree = desc.stat_desc.static_tree;
|
|
@@ -467,7 +344,7 @@ const gen_bitlen = (s, desc) => {
|
|
|
467
344
|
}
|
|
468
345
|
if (overflow === 0) { return; }
|
|
469
346
|
|
|
470
|
-
//
|
|
347
|
+
// Trace((stderr,"\nbit length overflow\n"));
|
|
471
348
|
/* This happens for example on obj2 and pic of the Calgary corpus */
|
|
472
349
|
|
|
473
350
|
/* Find the first bit length which could increase: */
|
|
@@ -494,7 +371,7 @@ const gen_bitlen = (s, desc) => {
|
|
|
494
371
|
m = s.heap[--h];
|
|
495
372
|
if (m > max_code) { continue; }
|
|
496
373
|
if (tree[m * 2 + 1]/*.Len*/ !== bits) {
|
|
497
|
-
//
|
|
374
|
+
// Trace((stderr,"code %d bits %d->%d\n", m, tree[m].Len, bits));
|
|
498
375
|
s.opt_len += (bits - tree[m * 2 + 1]/*.Len*/) * tree[m * 2]/*.Freq*/;
|
|
499
376
|
tree[m * 2 + 1]/*.Len*/ = bits;
|
|
500
377
|
}
|
|
@@ -512,11 +389,11 @@ const gen_bitlen = (s, desc) => {
|
|
|
512
389
|
* OUT assertion: the field code is set for all tree elements of non
|
|
513
390
|
* zero code length.
|
|
514
391
|
*/
|
|
515
|
-
const gen_codes = (tree, max_code, bl_count) =>
|
|
392
|
+
const gen_codes = (tree, max_code, bl_count) =>
|
|
516
393
|
// ct_data *tree; /* the tree to decorate */
|
|
517
394
|
// int max_code; /* largest code with non zero frequency */
|
|
518
395
|
// ushf *bl_count; /* number of codes at each bit length */
|
|
519
|
-
|
|
396
|
+
{
|
|
520
397
|
const next_code = new Array(MAX_BITS$1 + 1); /* next code value for each bit length */
|
|
521
398
|
let code = 0; /* running code value */
|
|
522
399
|
let bits; /* bit index */
|
|
@@ -526,8 +403,7 @@ const gen_codes = (tree, max_code, bl_count) => {
|
|
|
526
403
|
* without bit reversal.
|
|
527
404
|
*/
|
|
528
405
|
for (bits = 1; bits <= MAX_BITS$1; bits++) {
|
|
529
|
-
code = (code + bl_count[bits - 1]) << 1;
|
|
530
|
-
next_code[bits] = code;
|
|
406
|
+
next_code[bits] = code = (code + bl_count[bits - 1]) << 1;
|
|
531
407
|
}
|
|
532
408
|
/* Check that the bit counts in bl_count are consistent. The last code
|
|
533
409
|
* must be all ones.
|
|
@@ -667,7 +543,7 @@ const init_block = (s) => {
|
|
|
667
543
|
|
|
668
544
|
s.dyn_ltree[END_BLOCK * 2]/*.Freq*/ = 1;
|
|
669
545
|
s.opt_len = s.static_len = 0;
|
|
670
|
-
s.
|
|
546
|
+
s.last_lit = s.matches = 0;
|
|
671
547
|
};
|
|
672
548
|
|
|
673
549
|
|
|
@@ -686,6 +562,29 @@ const bi_windup = (s) =>
|
|
|
686
562
|
s.bi_valid = 0;
|
|
687
563
|
};
|
|
688
564
|
|
|
565
|
+
/* ===========================================================================
|
|
566
|
+
* Copy a stored block, storing first the length and its
|
|
567
|
+
* one's complement if requested.
|
|
568
|
+
*/
|
|
569
|
+
const copy_block = (s, buf, len, header) =>
|
|
570
|
+
//DeflateState *s;
|
|
571
|
+
//charf *buf; /* the input data */
|
|
572
|
+
//unsigned len; /* its length */
|
|
573
|
+
//int header; /* true if block header must be written */
|
|
574
|
+
{
|
|
575
|
+
bi_windup(s); /* align on byte boundary */
|
|
576
|
+
|
|
577
|
+
if (header) {
|
|
578
|
+
put_short(s, len);
|
|
579
|
+
put_short(s, ~len);
|
|
580
|
+
}
|
|
581
|
+
// while (len--) {
|
|
582
|
+
// put_byte(s, *buf++);
|
|
583
|
+
// }
|
|
584
|
+
s.pending_buf.set(s.window.subarray(buf, buf + len), s.pending);
|
|
585
|
+
s.pending += len;
|
|
586
|
+
};
|
|
587
|
+
|
|
689
588
|
/* ===========================================================================
|
|
690
589
|
* Compares to subtrees, using the tree depth as tie breaker when
|
|
691
590
|
* the subtrees have equal frequency. This minimizes the worst case length.
|
|
@@ -704,11 +603,11 @@ const smaller = (tree, n, m, depth) => {
|
|
|
704
603
|
* when the heap property is re-established (each father smaller than its
|
|
705
604
|
* two sons).
|
|
706
605
|
*/
|
|
707
|
-
const pqdownheap = (s, tree, k) =>
|
|
606
|
+
const pqdownheap = (s, tree, k) =>
|
|
708
607
|
// deflate_state *s;
|
|
709
608
|
// ct_data *tree; /* the tree to restore */
|
|
710
609
|
// int k; /* node to move down */
|
|
711
|
-
|
|
610
|
+
{
|
|
712
611
|
const v = s.heap[k];
|
|
713
612
|
let j = k << 1; /* left son of k */
|
|
714
613
|
while (j <= s.heap_len) {
|
|
@@ -737,22 +636,23 @@ const pqdownheap = (s, tree, k) => {
|
|
|
737
636
|
/* ===========================================================================
|
|
738
637
|
* Send the block data compressed using the given Huffman trees
|
|
739
638
|
*/
|
|
740
|
-
const compress_block = (s, ltree, dtree) =>
|
|
639
|
+
const compress_block = (s, ltree, dtree) =>
|
|
741
640
|
// deflate_state *s;
|
|
742
641
|
// const ct_data *ltree; /* literal tree */
|
|
743
642
|
// const ct_data *dtree; /* distance tree */
|
|
744
|
-
|
|
643
|
+
{
|
|
745
644
|
let dist; /* distance of matched string */
|
|
746
645
|
let lc; /* match length or unmatched char (if dist == 0) */
|
|
747
|
-
let
|
|
646
|
+
let lx = 0; /* running index in l_buf */
|
|
748
647
|
let code; /* the code to send */
|
|
749
648
|
let extra; /* number of extra bits to send */
|
|
750
649
|
|
|
751
|
-
if (s.
|
|
650
|
+
if (s.last_lit !== 0) {
|
|
752
651
|
do {
|
|
753
|
-
dist = s.pending_buf[s.
|
|
754
|
-
|
|
755
|
-
|
|
652
|
+
dist = (s.pending_buf[s.d_buf + lx * 2] << 8) | (s.pending_buf[s.d_buf + lx * 2 + 1]);
|
|
653
|
+
lc = s.pending_buf[s.l_buf + lx];
|
|
654
|
+
lx++;
|
|
655
|
+
|
|
756
656
|
if (dist === 0) {
|
|
757
657
|
send_code(s, lc, ltree); /* send a literal byte */
|
|
758
658
|
//Tracecv(isgraph(lc), (stderr," '%c' ", lc));
|
|
@@ -777,10 +677,11 @@ const compress_block = (s, ltree, dtree) => {
|
|
|
777
677
|
}
|
|
778
678
|
} /* literal or match pair ? */
|
|
779
679
|
|
|
780
|
-
/* Check that the overlay between pending_buf and
|
|
781
|
-
//Assert(s->pending < s->lit_bufsize +
|
|
680
|
+
/* Check that the overlay between pending_buf and d_buf+l_buf is ok: */
|
|
681
|
+
//Assert((uInt)(s->pending) < s->lit_bufsize + 2*lx,
|
|
682
|
+
// "pendingBuf overflow");
|
|
782
683
|
|
|
783
|
-
} while (
|
|
684
|
+
} while (lx < s.last_lit);
|
|
784
685
|
}
|
|
785
686
|
|
|
786
687
|
send_code(s, END_BLOCK, ltree);
|
|
@@ -795,10 +696,10 @@ const compress_block = (s, ltree, dtree) => {
|
|
|
795
696
|
* and corresponding code. The length opt_len is updated; static_len is
|
|
796
697
|
* also updated if stree is not null. The field max_code is set.
|
|
797
698
|
*/
|
|
798
|
-
const build_tree = (s, desc) =>
|
|
699
|
+
const build_tree = (s, desc) =>
|
|
799
700
|
// deflate_state *s;
|
|
800
701
|
// tree_desc *desc; /* the tree descriptor */
|
|
801
|
-
|
|
702
|
+
{
|
|
802
703
|
const tree = desc.dyn_tree;
|
|
803
704
|
const stree = desc.stat_desc.static_tree;
|
|
804
705
|
const has_stree = desc.stat_desc.has_stree;
|
|
@@ -891,11 +792,11 @@ const build_tree = (s, desc) => {
|
|
|
891
792
|
* Scan a literal or distance tree to determine the frequencies of the codes
|
|
892
793
|
* in the bit length tree.
|
|
893
794
|
*/
|
|
894
|
-
const scan_tree = (s, tree, max_code) =>
|
|
795
|
+
const scan_tree = (s, tree, max_code) =>
|
|
895
796
|
// deflate_state *s;
|
|
896
797
|
// ct_data *tree; /* the tree to be scanned */
|
|
897
798
|
// int max_code; /* and its largest code of non zero frequency */
|
|
898
|
-
|
|
799
|
+
{
|
|
899
800
|
let n; /* iterates over all tree elements */
|
|
900
801
|
let prevlen = -1; /* last emitted length */
|
|
901
802
|
let curlen; /* length of current code */
|
|
@@ -957,11 +858,11 @@ const scan_tree = (s, tree, max_code) => {
|
|
|
957
858
|
* Send a literal or distance tree in compressed form, using the codes in
|
|
958
859
|
* bl_tree.
|
|
959
860
|
*/
|
|
960
|
-
const send_tree = (s, tree, max_code) =>
|
|
861
|
+
const send_tree = (s, tree, max_code) =>
|
|
961
862
|
// deflate_state *s;
|
|
962
863
|
// ct_data *tree; /* the tree to be scanned */
|
|
963
864
|
// int max_code; /* and its largest code of non zero frequency */
|
|
964
|
-
|
|
865
|
+
{
|
|
965
866
|
let n; /* iterates over all tree elements */
|
|
966
867
|
let prevlen = -1; /* last emitted length */
|
|
967
868
|
let curlen; /* length of current code */
|
|
@@ -1065,10 +966,10 @@ const build_bl_tree = (s) => {
|
|
|
1065
966
|
* lengths of the bit length codes, the literal tree and the distance tree.
|
|
1066
967
|
* IN assertion: lcodes >= 257, dcodes >= 1, blcodes >= 4.
|
|
1067
968
|
*/
|
|
1068
|
-
const send_all_trees = (s, lcodes, dcodes, blcodes) =>
|
|
969
|
+
const send_all_trees = (s, lcodes, dcodes, blcodes) =>
|
|
1069
970
|
// deflate_state *s;
|
|
1070
971
|
// int lcodes, dcodes, blcodes; /* number of codes for each tree */
|
|
1071
|
-
|
|
972
|
+
{
|
|
1072
973
|
let rank; /* index in bl_order */
|
|
1073
974
|
|
|
1074
975
|
//Assert (lcodes >= 257 && dcodes >= 1 && blcodes >= 4, "not enough codes");
|
|
@@ -1096,9 +997,9 @@ const send_all_trees = (s, lcodes, dcodes, blcodes) => {
|
|
|
1096
997
|
* Check if the data type is TEXT or BINARY, using the following algorithm:
|
|
1097
998
|
* - TEXT if the two conditions below are satisfied:
|
|
1098
999
|
* a) There are no non-portable control characters belonging to the
|
|
1099
|
-
* "
|
|
1000
|
+
* "black list" (0..6, 14..25, 28..31).
|
|
1100
1001
|
* b) There is at least one printable character belonging to the
|
|
1101
|
-
* "
|
|
1002
|
+
* "white list" (9 {TAB}, 10 {LF}, 13 {CR}, 32..255).
|
|
1102
1003
|
* - BINARY otherwise.
|
|
1103
1004
|
* - The following partially-portable control characters form a
|
|
1104
1005
|
* "gray list" that is ignored in this detection algorithm:
|
|
@@ -1106,21 +1007,21 @@ const send_all_trees = (s, lcodes, dcodes, blcodes) => {
|
|
|
1106
1007
|
* IN assertion: the fields Freq of dyn_ltree are set.
|
|
1107
1008
|
*/
|
|
1108
1009
|
const detect_data_type = (s) => {
|
|
1109
|
-
/*
|
|
1010
|
+
/* black_mask is the bit mask of black-listed bytes
|
|
1110
1011
|
* set bits 0..6, 14..25, and 28..31
|
|
1111
1012
|
* 0xf3ffc07f = binary 11110011111111111100000001111111
|
|
1112
1013
|
*/
|
|
1113
|
-
let
|
|
1014
|
+
let black_mask = 0xf3ffc07f;
|
|
1114
1015
|
let n;
|
|
1115
1016
|
|
|
1116
|
-
/* Check for non-textual ("
|
|
1117
|
-
for (n = 0; n <= 31; n++,
|
|
1118
|
-
if ((
|
|
1017
|
+
/* Check for non-textual ("black-listed") bytes. */
|
|
1018
|
+
for (n = 0; n <= 31; n++, black_mask >>>= 1) {
|
|
1019
|
+
if ((black_mask & 1) && (s.dyn_ltree[n * 2]/*.Freq*/ !== 0)) {
|
|
1119
1020
|
return Z_BINARY;
|
|
1120
1021
|
}
|
|
1121
1022
|
}
|
|
1122
1023
|
|
|
1123
|
-
/* Check for textual ("
|
|
1024
|
+
/* Check for textual ("white-listed") bytes. */
|
|
1124
1025
|
if (s.dyn_ltree[9 * 2]/*.Freq*/ !== 0 || s.dyn_ltree[10 * 2]/*.Freq*/ !== 0 ||
|
|
1125
1026
|
s.dyn_ltree[13 * 2]/*.Freq*/ !== 0) {
|
|
1126
1027
|
return Z_TEXT;
|
|
@@ -1131,7 +1032,7 @@ const detect_data_type = (s) => {
|
|
|
1131
1032
|
}
|
|
1132
1033
|
}
|
|
1133
1034
|
|
|
1134
|
-
/* There are no "
|
|
1035
|
+
/* There are no "black-listed" or "white-listed" bytes:
|
|
1135
1036
|
* this stream either is empty or has tolerated ("gray-listed") bytes only.
|
|
1136
1037
|
*/
|
|
1137
1038
|
return Z_BINARY;
|
|
@@ -1166,20 +1067,14 @@ const _tr_init$1 = (s) =>
|
|
|
1166
1067
|
/* ===========================================================================
|
|
1167
1068
|
* Send a stored block
|
|
1168
1069
|
*/
|
|
1169
|
-
const _tr_stored_block$1 = (s, buf, stored_len, last) =>
|
|
1070
|
+
const _tr_stored_block$1 = (s, buf, stored_len, last) =>
|
|
1170
1071
|
//DeflateState *s;
|
|
1171
1072
|
//charf *buf; /* input block */
|
|
1172
1073
|
//ulg stored_len; /* length of input block */
|
|
1173
1074
|
//int last; /* one if this is the last block for a file */
|
|
1174
|
-
|
|
1075
|
+
{
|
|
1175
1076
|
send_bits(s, (STORED_BLOCK << 1) + (last ? 1 : 0), 3); /* send block type */
|
|
1176
|
-
|
|
1177
|
-
put_short(s, stored_len);
|
|
1178
|
-
put_short(s, ~stored_len);
|
|
1179
|
-
if (stored_len) {
|
|
1180
|
-
s.pending_buf.set(s.window.subarray(buf, buf + stored_len), s.pending);
|
|
1181
|
-
}
|
|
1182
|
-
s.pending += stored_len;
|
|
1077
|
+
copy_block(s, buf, stored_len, true); /* with header */
|
|
1183
1078
|
};
|
|
1184
1079
|
|
|
1185
1080
|
|
|
@@ -1196,14 +1091,14 @@ const _tr_align$1 = (s) => {
|
|
|
1196
1091
|
|
|
1197
1092
|
/* ===========================================================================
|
|
1198
1093
|
* Determine the best encoding for the current block: dynamic trees, static
|
|
1199
|
-
* trees or store, and
|
|
1094
|
+
* trees or store, and output the encoded block to the zip file.
|
|
1200
1095
|
*/
|
|
1201
|
-
const _tr_flush_block$1 = (s, buf, stored_len, last) =>
|
|
1096
|
+
const _tr_flush_block$1 = (s, buf, stored_len, last) =>
|
|
1202
1097
|
//DeflateState *s;
|
|
1203
1098
|
//charf *buf; /* input block, or NULL if too old */
|
|
1204
1099
|
//ulg stored_len; /* length of input block */
|
|
1205
1100
|
//int last; /* one if this is the last block for a file */
|
|
1206
|
-
|
|
1101
|
+
{
|
|
1207
1102
|
let opt_lenb, static_lenb; /* opt_len and static_len in bytes */
|
|
1208
1103
|
let max_blindex = 0; /* index of last bit length code of non zero freq */
|
|
1209
1104
|
|
|
@@ -1238,7 +1133,7 @@ const _tr_flush_block$1 = (s, buf, stored_len, last) => {
|
|
|
1238
1133
|
|
|
1239
1134
|
// Tracev((stderr, "\nopt %lu(%lu) stat %lu(%lu) stored %lu lit %u ",
|
|
1240
1135
|
// opt_lenb, s->opt_len, static_lenb, s->static_len, stored_len,
|
|
1241
|
-
// s->
|
|
1136
|
+
// s->last_lit));
|
|
1242
1137
|
|
|
1243
1138
|
if (static_lenb <= opt_lenb) { opt_lenb = static_lenb; }
|
|
1244
1139
|
|
|
@@ -1285,14 +1180,19 @@ const _tr_flush_block$1 = (s, buf, stored_len, last) => {
|
|
|
1285
1180
|
* Save the match info and tally the frequency counts. Return true if
|
|
1286
1181
|
* the current block must be flushed.
|
|
1287
1182
|
*/
|
|
1288
|
-
const _tr_tally$1 = (s, dist, lc) =>
|
|
1183
|
+
const _tr_tally$1 = (s, dist, lc) =>
|
|
1289
1184
|
// deflate_state *s;
|
|
1290
1185
|
// unsigned dist; /* distance of matched string */
|
|
1291
1186
|
// unsigned lc; /* match length-MIN_MATCH or unmatched char (if dist==0) */
|
|
1187
|
+
{
|
|
1188
|
+
//let out_length, in_length, dcode;
|
|
1189
|
+
|
|
1190
|
+
s.pending_buf[s.d_buf + s.last_lit * 2] = (dist >>> 8) & 0xff;
|
|
1191
|
+
s.pending_buf[s.d_buf + s.last_lit * 2 + 1] = dist & 0xff;
|
|
1192
|
+
|
|
1193
|
+
s.pending_buf[s.l_buf + s.last_lit] = lc & 0xff;
|
|
1194
|
+
s.last_lit++;
|
|
1292
1195
|
|
|
1293
|
-
s.pending_buf[s.sym_buf + s.sym_next++] = dist;
|
|
1294
|
-
s.pending_buf[s.sym_buf + s.sym_next++] = dist >> 8;
|
|
1295
|
-
s.pending_buf[s.sym_buf + s.sym_next++] = lc;
|
|
1296
1196
|
if (dist === 0) {
|
|
1297
1197
|
/* lc is the unmatched char */
|
|
1298
1198
|
s.dyn_ltree[lc * 2]/*.Freq*/++;
|
|
@@ -1308,7 +1208,34 @@ const _tr_tally$1 = (s, dist, lc) => {
|
|
|
1308
1208
|
s.dyn_dtree[d_code(dist) * 2]/*.Freq*/++;
|
|
1309
1209
|
}
|
|
1310
1210
|
|
|
1311
|
-
|
|
1211
|
+
// (!) This block is disabled in zlib defaults,
|
|
1212
|
+
// don't enable it for binary compatibility
|
|
1213
|
+
|
|
1214
|
+
//#ifdef TRUNCATE_BLOCK
|
|
1215
|
+
// /* Try to guess if it is profitable to stop the current block here */
|
|
1216
|
+
// if ((s.last_lit & 0x1fff) === 0 && s.level > 2) {
|
|
1217
|
+
// /* Compute an upper bound for the compressed length */
|
|
1218
|
+
// out_length = s.last_lit*8;
|
|
1219
|
+
// in_length = s.strstart - s.block_start;
|
|
1220
|
+
//
|
|
1221
|
+
// for (dcode = 0; dcode < D_CODES; dcode++) {
|
|
1222
|
+
// out_length += s.dyn_dtree[dcode*2]/*.Freq*/ * (5 + extra_dbits[dcode]);
|
|
1223
|
+
// }
|
|
1224
|
+
// out_length >>>= 3;
|
|
1225
|
+
// //Tracev((stderr,"\nlast_lit %u, in %ld, out ~%ld(%ld%%) ",
|
|
1226
|
+
// // s->last_lit, in_length, out_length,
|
|
1227
|
+
// // 100L - out_length*100L/in_length));
|
|
1228
|
+
// if (s.matches < (s.last_lit>>1)/*int /2*/ && out_length < (in_length>>1)/*int /2*/) {
|
|
1229
|
+
// return true;
|
|
1230
|
+
// }
|
|
1231
|
+
// }
|
|
1232
|
+
//#endif
|
|
1233
|
+
|
|
1234
|
+
return (s.last_lit === s.lit_bufsize - 1);
|
|
1235
|
+
/* We avoid equality with lit_bufsize because of wraparound at 64K
|
|
1236
|
+
* on 16 bit machines and because stored blocks are restricted to
|
|
1237
|
+
* 64K-1 bytes.
|
|
1238
|
+
*/
|
|
1312
1239
|
};
|
|
1313
1240
|
|
|
1314
1241
|
var _tr_init_1 = _tr_init$1;
|
|
@@ -1598,16 +1525,13 @@ const MIN_LOOKAHEAD = (MAX_MATCH + MIN_MATCH + 1);
|
|
|
1598
1525
|
|
|
1599
1526
|
const PRESET_DICT = 0x20;
|
|
1600
1527
|
|
|
1601
|
-
const INIT_STATE
|
|
1602
|
-
|
|
1603
|
-
const
|
|
1604
|
-
|
|
1605
|
-
const
|
|
1606
|
-
const
|
|
1607
|
-
const
|
|
1608
|
-
const HCRC_STATE = 103; /* gzip header CRC -> BUSY_STATE */
|
|
1609
|
-
const BUSY_STATE = 113; /* deflate -> FINISH_STATE */
|
|
1610
|
-
const FINISH_STATE = 666; /* stream complete */
|
|
1528
|
+
const INIT_STATE = 42;
|
|
1529
|
+
const EXTRA_STATE = 69;
|
|
1530
|
+
const NAME_STATE = 73;
|
|
1531
|
+
const COMMENT_STATE = 91;
|
|
1532
|
+
const HCRC_STATE = 103;
|
|
1533
|
+
const BUSY_STATE = 113;
|
|
1534
|
+
const FINISH_STATE = 666;
|
|
1611
1535
|
|
|
1612
1536
|
const BS_NEED_MORE = 1; /* block not completed, need more input or more output */
|
|
1613
1537
|
const BS_BLOCK_DONE = 2; /* block flush performed */
|
|
@@ -1622,41 +1546,13 @@ const err = (strm, errorCode) => {
|
|
|
1622
1546
|
};
|
|
1623
1547
|
|
|
1624
1548
|
const rank = (f) => {
|
|
1625
|
-
return ((f)
|
|
1549
|
+
return ((f) << 1) - ((f) > 4 ? 9 : 0);
|
|
1626
1550
|
};
|
|
1627
1551
|
|
|
1628
1552
|
const zero = (buf) => {
|
|
1629
1553
|
let len = buf.length; while (--len >= 0) { buf[len] = 0; }
|
|
1630
1554
|
};
|
|
1631
1555
|
|
|
1632
|
-
/* ===========================================================================
|
|
1633
|
-
* Slide the hash table when sliding the window down (could be avoided with 32
|
|
1634
|
-
* bit values at the expense of memory usage). We slide even when level == 0 to
|
|
1635
|
-
* keep the hash table consistent if we switch back to level > 0 later.
|
|
1636
|
-
*/
|
|
1637
|
-
const slide_hash = (s) => {
|
|
1638
|
-
let n, m;
|
|
1639
|
-
let p;
|
|
1640
|
-
let wsize = s.w_size;
|
|
1641
|
-
|
|
1642
|
-
n = s.hash_size;
|
|
1643
|
-
p = n;
|
|
1644
|
-
do {
|
|
1645
|
-
m = s.head[--p];
|
|
1646
|
-
s.head[p] = (m >= wsize ? m - wsize : 0);
|
|
1647
|
-
} while (--n);
|
|
1648
|
-
n = wsize;
|
|
1649
|
-
//#ifndef FASTEST
|
|
1650
|
-
p = n;
|
|
1651
|
-
do {
|
|
1652
|
-
m = s.prev[--p];
|
|
1653
|
-
s.prev[p] = (m >= wsize ? m - wsize : 0);
|
|
1654
|
-
/* If n is not on any hash chain, prev[n] is garbage but
|
|
1655
|
-
* its value will never be used.
|
|
1656
|
-
*/
|
|
1657
|
-
} while (--n);
|
|
1658
|
-
//#endif
|
|
1659
|
-
};
|
|
1660
1556
|
|
|
1661
1557
|
/* eslint-disable new-cap */
|
|
1662
1558
|
let HASH_ZLIB = (s, prev, data) => ((prev << s.hash_shift) ^ data) & s.hash_mask;
|
|
@@ -1665,12 +1561,11 @@ let HASH_ZLIB = (s, prev, data) => ((prev << s.hash_shift) ^ data) & s.hash_mask
|
|
|
1665
1561
|
//let HASH_FAST = (s, prev, data) => ((prev << 8) + (prev >> 8) + (data << 4)) & s.hash_mask;
|
|
1666
1562
|
let HASH = HASH_ZLIB;
|
|
1667
1563
|
|
|
1668
|
-
|
|
1669
1564
|
/* =========================================================================
|
|
1670
|
-
* Flush as much pending output as possible. All deflate() output
|
|
1671
|
-
*
|
|
1672
|
-
*
|
|
1673
|
-
*
|
|
1565
|
+
* Flush as much pending output as possible. All deflate() output goes
|
|
1566
|
+
* through this function so some applications may wish to modify it
|
|
1567
|
+
* to avoid allocating a large strm->output buffer and copying into it.
|
|
1568
|
+
* (See also read_buf()).
|
|
1674
1569
|
*/
|
|
1675
1570
|
const flush_pending = (strm) => {
|
|
1676
1571
|
const s = strm.state;
|
|
@@ -1683,11 +1578,11 @@ const flush_pending = (strm) => {
|
|
|
1683
1578
|
if (len === 0) { return; }
|
|
1684
1579
|
|
|
1685
1580
|
strm.output.set(s.pending_buf.subarray(s.pending_out, s.pending_out + len), strm.next_out);
|
|
1686
|
-
strm.next_out
|
|
1687
|
-
s.pending_out
|
|
1581
|
+
strm.next_out += len;
|
|
1582
|
+
s.pending_out += len;
|
|
1688
1583
|
strm.total_out += len;
|
|
1689
1584
|
strm.avail_out -= len;
|
|
1690
|
-
s.pending
|
|
1585
|
+
s.pending -= len;
|
|
1691
1586
|
if (s.pending === 0) {
|
|
1692
1587
|
s.pending_out = 0;
|
|
1693
1588
|
}
|
|
@@ -1879,7 +1774,7 @@ const longest_match = (s, cur_match) => {
|
|
|
1879
1774
|
const fill_window = (s) => {
|
|
1880
1775
|
|
|
1881
1776
|
const _w_size = s.w_size;
|
|
1882
|
-
let n, more, str;
|
|
1777
|
+
let p, n, m, more, str;
|
|
1883
1778
|
|
|
1884
1779
|
//Assert(s->lookahead < MIN_LOOKAHEAD, "already enough lookahead");
|
|
1885
1780
|
|
|
@@ -1906,15 +1801,38 @@ const fill_window = (s) => {
|
|
|
1906
1801
|
*/
|
|
1907
1802
|
if (s.strstart >= _w_size + (_w_size - MIN_LOOKAHEAD)) {
|
|
1908
1803
|
|
|
1909
|
-
s.window.set(s.window.subarray(_w_size, _w_size + _w_size
|
|
1804
|
+
s.window.set(s.window.subarray(_w_size, _w_size + _w_size), 0);
|
|
1910
1805
|
s.match_start -= _w_size;
|
|
1911
1806
|
s.strstart -= _w_size;
|
|
1912
1807
|
/* we now have strstart >= MAX_DIST */
|
|
1913
1808
|
s.block_start -= _w_size;
|
|
1914
|
-
|
|
1915
|
-
|
|
1916
|
-
|
|
1917
|
-
|
|
1809
|
+
|
|
1810
|
+
/* Slide the hash table (could be avoided with 32 bit values
|
|
1811
|
+
at the expense of memory usage). We slide even when level == 0
|
|
1812
|
+
to keep the hash table consistent if we switch back to level > 0
|
|
1813
|
+
later. (Using level 0 permanently is not an optimal usage of
|
|
1814
|
+
zlib, so we don't care about this pathological case.)
|
|
1815
|
+
*/
|
|
1816
|
+
|
|
1817
|
+
n = s.hash_size;
|
|
1818
|
+
p = n;
|
|
1819
|
+
|
|
1820
|
+
do {
|
|
1821
|
+
m = s.head[--p];
|
|
1822
|
+
s.head[p] = (m >= _w_size ? m - _w_size : 0);
|
|
1823
|
+
} while (--n);
|
|
1824
|
+
|
|
1825
|
+
n = _w_size;
|
|
1826
|
+
p = n;
|
|
1827
|
+
|
|
1828
|
+
do {
|
|
1829
|
+
m = s.prev[--p];
|
|
1830
|
+
s.prev[p] = (m >= _w_size ? m - _w_size : 0);
|
|
1831
|
+
/* If n is not on any hash chain, prev[n] is garbage but
|
|
1832
|
+
* its value will never be used.
|
|
1833
|
+
*/
|
|
1834
|
+
} while (--n);
|
|
1835
|
+
|
|
1918
1836
|
more += _w_size;
|
|
1919
1837
|
}
|
|
1920
1838
|
if (s.strm.avail_in === 0) {
|
|
@@ -2006,216 +1924,104 @@ const fill_window = (s) => {
|
|
|
2006
1924
|
/* ===========================================================================
|
|
2007
1925
|
* Copy without compression as much as possible from the input stream, return
|
|
2008
1926
|
* the current block state.
|
|
2009
|
-
*
|
|
2010
|
-
*
|
|
2011
|
-
*
|
|
2012
|
-
*
|
|
2013
|
-
*
|
|
2014
|
-
* allowed here, then the hash table will be cleared, since two or more slides
|
|
2015
|
-
* is the same as a clear.
|
|
2016
|
-
*
|
|
2017
|
-
* deflate_stored() is written to minimize the number of times an input byte is
|
|
2018
|
-
* copied. It is most efficient with large input and output buffers, which
|
|
2019
|
-
* maximizes the opportunites to have a single copy from next_in to next_out.
|
|
1927
|
+
* This function does not insert new strings in the dictionary since
|
|
1928
|
+
* uncompressible data is probably not useful. This function is used
|
|
1929
|
+
* only for the level=0 compression option.
|
|
1930
|
+
* NOTE: this function should be optimized to avoid extra copying from
|
|
1931
|
+
* window to pending_buf.
|
|
2020
1932
|
*/
|
|
2021
1933
|
const deflate_stored = (s, flush) => {
|
|
2022
1934
|
|
|
2023
|
-
/*
|
|
2024
|
-
*
|
|
2025
|
-
* large input and output buffers, the stored block size will be larger.
|
|
1935
|
+
/* Stored blocks are limited to 0xffff bytes, pending_buf is limited
|
|
1936
|
+
* to pending_buf_size, and each stored block has a 5 byte header:
|
|
2026
1937
|
*/
|
|
2027
|
-
let
|
|
1938
|
+
let max_block_size = 0xffff;
|
|
2028
1939
|
|
|
2029
|
-
|
|
2030
|
-
|
|
2031
|
-
|
|
2032
|
-
*/
|
|
2033
|
-
let len, left, have, last = 0;
|
|
2034
|
-
let used = s.strm.avail_in;
|
|
2035
|
-
do {
|
|
2036
|
-
/* Set len to the maximum size block that we can copy directly with the
|
|
2037
|
-
* available input data and output space. Set left to how much of that
|
|
2038
|
-
* would be copied from what's left in the window.
|
|
2039
|
-
*/
|
|
2040
|
-
len = 65535/* MAX_STORED */; /* maximum deflate stored block length */
|
|
2041
|
-
have = (s.bi_valid + 42) >> 3; /* number of header bytes */
|
|
2042
|
-
if (s.strm.avail_out < have) { /* need room for header */
|
|
2043
|
-
break;
|
|
2044
|
-
}
|
|
2045
|
-
/* maximum stored block length that will fit in avail_out: */
|
|
2046
|
-
have = s.strm.avail_out - have;
|
|
2047
|
-
left = s.strstart - s.block_start; /* bytes left in window */
|
|
2048
|
-
if (len > left + s.strm.avail_in) {
|
|
2049
|
-
len = left + s.strm.avail_in; /* limit len to the input */
|
|
2050
|
-
}
|
|
2051
|
-
if (len > have) {
|
|
2052
|
-
len = have; /* limit len to the output */
|
|
2053
|
-
}
|
|
1940
|
+
if (max_block_size > s.pending_buf_size - 5) {
|
|
1941
|
+
max_block_size = s.pending_buf_size - 5;
|
|
1942
|
+
}
|
|
2054
1943
|
|
|
2055
|
-
|
|
2056
|
-
|
|
2057
|
-
|
|
2058
|
-
|
|
2059
|
-
*/
|
|
2060
|
-
if (len < min_block && ((len === 0 && flush !== Z_FINISH$3) ||
|
|
2061
|
-
flush === Z_NO_FLUSH$2 ||
|
|
2062
|
-
len !== left + s.strm.avail_in)) {
|
|
2063
|
-
break;
|
|
2064
|
-
}
|
|
1944
|
+
/* Copy as much as possible from input to output: */
|
|
1945
|
+
for (;;) {
|
|
1946
|
+
/* Fill the window as much as possible: */
|
|
1947
|
+
if (s.lookahead <= 1) {
|
|
2065
1948
|
|
|
2066
|
-
|
|
2067
|
-
|
|
2068
|
-
|
|
2069
|
-
|
|
2070
|
-
|
|
2071
|
-
|
|
2072
|
-
/* Replace the lengths in the dummy stored block with len. */
|
|
2073
|
-
s.pending_buf[s.pending - 4] = len;
|
|
2074
|
-
s.pending_buf[s.pending - 3] = len >> 8;
|
|
2075
|
-
s.pending_buf[s.pending - 2] = ~len;
|
|
2076
|
-
s.pending_buf[s.pending - 1] = ~len >> 8;
|
|
2077
|
-
|
|
2078
|
-
/* Write the stored block header bytes. */
|
|
2079
|
-
flush_pending(s.strm);
|
|
2080
|
-
|
|
2081
|
-
//#ifdef ZLIB_DEBUG
|
|
2082
|
-
// /* Update debugging counts for the data about to be copied. */
|
|
2083
|
-
// s->compressed_len += len << 3;
|
|
2084
|
-
// s->bits_sent += len << 3;
|
|
2085
|
-
//#endif
|
|
1949
|
+
//Assert(s->strstart < s->w_size+MAX_DIST(s) ||
|
|
1950
|
+
// s->block_start >= (long)s->w_size, "slide too late");
|
|
1951
|
+
// if (!(s.strstart < s.w_size + (s.w_size - MIN_LOOKAHEAD) ||
|
|
1952
|
+
// s.block_start >= s.w_size)) {
|
|
1953
|
+
// throw new Error("slide too late");
|
|
1954
|
+
// }
|
|
2086
1955
|
|
|
2087
|
-
|
|
2088
|
-
|
|
2089
|
-
|
|
2090
|
-
left = len;
|
|
1956
|
+
fill_window(s);
|
|
1957
|
+
if (s.lookahead === 0 && flush === Z_NO_FLUSH$2) {
|
|
1958
|
+
return BS_NEED_MORE;
|
|
2091
1959
|
}
|
|
2092
|
-
//zmemcpy(s->strm->next_out, s->window + s->block_start, left);
|
|
2093
|
-
s.strm.output.set(s.window.subarray(s.block_start, s.block_start + left), s.strm.next_out);
|
|
2094
|
-
s.strm.next_out += left;
|
|
2095
|
-
s.strm.avail_out -= left;
|
|
2096
|
-
s.strm.total_out += left;
|
|
2097
|
-
s.block_start += left;
|
|
2098
|
-
len -= left;
|
|
2099
|
-
}
|
|
2100
1960
|
|
|
2101
|
-
|
|
2102
|
-
|
|
2103
|
-
|
|
2104
|
-
|
|
2105
|
-
read_buf(s.strm, s.strm.output, s.strm.next_out, len);
|
|
2106
|
-
s.strm.next_out += len;
|
|
2107
|
-
s.strm.avail_out -= len;
|
|
2108
|
-
s.strm.total_out += len;
|
|
1961
|
+
if (s.lookahead === 0) {
|
|
1962
|
+
break;
|
|
1963
|
+
}
|
|
1964
|
+
/* flush the current block */
|
|
2109
1965
|
}
|
|
2110
|
-
|
|
1966
|
+
//Assert(s->block_start >= 0L, "block gone");
|
|
1967
|
+
// if (s.block_start < 0) throw new Error("block gone");
|
|
1968
|
+
|
|
1969
|
+
s.strstart += s.lookahead;
|
|
1970
|
+
s.lookahead = 0;
|
|
1971
|
+
|
|
1972
|
+
/* Emit a stored block if pending_buf will be full: */
|
|
1973
|
+
const max_start = s.block_start + max_block_size;
|
|
1974
|
+
|
|
1975
|
+
if (s.strstart === 0 || s.strstart >= max_start) {
|
|
1976
|
+
/* strstart == 0 is possible when wraparound on 16-bit machine */
|
|
1977
|
+
s.lookahead = s.strstart - max_start;
|
|
1978
|
+
s.strstart = max_start;
|
|
1979
|
+
/*** FLUSH_BLOCK(s, 0); ***/
|
|
1980
|
+
flush_block_only(s, false);
|
|
1981
|
+
if (s.strm.avail_out === 0) {
|
|
1982
|
+
return BS_NEED_MORE;
|
|
1983
|
+
}
|
|
1984
|
+
/***/
|
|
1985
|
+
|
|
2111
1986
|
|
|
2112
|
-
/* Update the sliding window with the last s->w_size bytes of the copied
|
|
2113
|
-
* data, or append all of the copied data to the existing window if less
|
|
2114
|
-
* than s->w_size bytes were copied. Also update the number of bytes to
|
|
2115
|
-
* insert in the hash tables, in the event that deflateParams() switches to
|
|
2116
|
-
* a non-zero compression level.
|
|
2117
|
-
*/
|
|
2118
|
-
used -= s.strm.avail_in; /* number of input bytes directly copied */
|
|
2119
|
-
if (used) {
|
|
2120
|
-
/* If any input was used, then no unused input remains in the window,
|
|
2121
|
-
* therefore s->block_start == s->strstart.
|
|
2122
|
-
*/
|
|
2123
|
-
if (used >= s.w_size) { /* supplant the previous history */
|
|
2124
|
-
s.matches = 2; /* clear hash */
|
|
2125
|
-
//zmemcpy(s->window, s->strm->next_in - s->w_size, s->w_size);
|
|
2126
|
-
s.window.set(s.strm.input.subarray(s.strm.next_in - s.w_size, s.strm.next_in), 0);
|
|
2127
|
-
s.strstart = s.w_size;
|
|
2128
|
-
s.insert = s.strstart;
|
|
2129
1987
|
}
|
|
2130
|
-
|
|
2131
|
-
|
|
2132
|
-
|
|
2133
|
-
|
|
2134
|
-
|
|
2135
|
-
|
|
2136
|
-
|
|
2137
|
-
|
|
2138
|
-
}
|
|
2139
|
-
if (s.insert > s.strstart) {
|
|
2140
|
-
s.insert = s.strstart;
|
|
2141
|
-
}
|
|
1988
|
+
/* Flush if we may have to slide, otherwise block_start may become
|
|
1989
|
+
* negative and the data will be gone:
|
|
1990
|
+
*/
|
|
1991
|
+
if (s.strstart - s.block_start >= (s.w_size - MIN_LOOKAHEAD)) {
|
|
1992
|
+
/*** FLUSH_BLOCK(s, 0); ***/
|
|
1993
|
+
flush_block_only(s, false);
|
|
1994
|
+
if (s.strm.avail_out === 0) {
|
|
1995
|
+
return BS_NEED_MORE;
|
|
2142
1996
|
}
|
|
2143
|
-
|
|
2144
|
-
s.window.set(s.strm.input.subarray(s.strm.next_in - used, s.strm.next_in), s.strstart);
|
|
2145
|
-
s.strstart += used;
|
|
2146
|
-
s.insert += used > s.w_size - s.insert ? s.w_size - s.insert : used;
|
|
1997
|
+
/***/
|
|
2147
1998
|
}
|
|
2148
|
-
s.block_start = s.strstart;
|
|
2149
|
-
}
|
|
2150
|
-
if (s.high_water < s.strstart) {
|
|
2151
|
-
s.high_water = s.strstart;
|
|
2152
1999
|
}
|
|
2153
2000
|
|
|
2154
|
-
|
|
2155
|
-
if (last) {
|
|
2156
|
-
return BS_FINISH_DONE;
|
|
2157
|
-
}
|
|
2001
|
+
s.insert = 0;
|
|
2158
2002
|
|
|
2159
|
-
|
|
2160
|
-
|
|
2161
|
-
s
|
|
2162
|
-
|
|
2003
|
+
if (flush === Z_FINISH$3) {
|
|
2004
|
+
/*** FLUSH_BLOCK(s, 1); ***/
|
|
2005
|
+
flush_block_only(s, true);
|
|
2006
|
+
if (s.strm.avail_out === 0) {
|
|
2007
|
+
return BS_FINISH_STARTED;
|
|
2008
|
+
}
|
|
2009
|
+
/***/
|
|
2010
|
+
return BS_FINISH_DONE;
|
|
2163
2011
|
}
|
|
2164
2012
|
|
|
2165
|
-
|
|
2166
|
-
|
|
2167
|
-
|
|
2168
|
-
|
|
2169
|
-
|
|
2170
|
-
s.strstart -= s.w_size;
|
|
2171
|
-
//zmemcpy(s->window, s->window + s->w_size, s->strstart);
|
|
2172
|
-
s.window.set(s.window.subarray(s.w_size, s.w_size + s.strstart), 0);
|
|
2173
|
-
if (s.matches < 2) {
|
|
2174
|
-
s.matches++; /* add a pending slide_hash() */
|
|
2175
|
-
}
|
|
2176
|
-
have += s.w_size; /* more space now */
|
|
2177
|
-
if (s.insert > s.strstart) {
|
|
2178
|
-
s.insert = s.strstart;
|
|
2013
|
+
if (s.strstart > s.block_start) {
|
|
2014
|
+
/*** FLUSH_BLOCK(s, 0); ***/
|
|
2015
|
+
flush_block_only(s, false);
|
|
2016
|
+
if (s.strm.avail_out === 0) {
|
|
2017
|
+
return BS_NEED_MORE;
|
|
2179
2018
|
}
|
|
2180
|
-
|
|
2181
|
-
if (have > s.strm.avail_in) {
|
|
2182
|
-
have = s.strm.avail_in;
|
|
2183
|
-
}
|
|
2184
|
-
if (have) {
|
|
2185
|
-
read_buf(s.strm, s.window, s.strstart, have);
|
|
2186
|
-
s.strstart += have;
|
|
2187
|
-
s.insert += have > s.w_size - s.insert ? s.w_size - s.insert : have;
|
|
2188
|
-
}
|
|
2189
|
-
if (s.high_water < s.strstart) {
|
|
2190
|
-
s.high_water = s.strstart;
|
|
2019
|
+
/***/
|
|
2191
2020
|
}
|
|
2192
2021
|
|
|
2193
|
-
|
|
2194
|
-
* stored block to next_out. Write a stored block to pending instead, if we
|
|
2195
|
-
* have enough input for a worthy block, or if flushing and there is enough
|
|
2196
|
-
* room for the remaining input as a stored block in the pending buffer.
|
|
2197
|
-
*/
|
|
2198
|
-
have = (s.bi_valid + 42) >> 3; /* number of header bytes */
|
|
2199
|
-
/* maximum stored block length that will fit in pending: */
|
|
2200
|
-
have = s.pending_buf_size - have > 65535/* MAX_STORED */ ? 65535/* MAX_STORED */ : s.pending_buf_size - have;
|
|
2201
|
-
min_block = have > s.w_size ? s.w_size : have;
|
|
2202
|
-
left = s.strstart - s.block_start;
|
|
2203
|
-
if (left >= min_block ||
|
|
2204
|
-
((left || flush === Z_FINISH$3) && flush !== Z_NO_FLUSH$2 &&
|
|
2205
|
-
s.strm.avail_in === 0 && left <= have)) {
|
|
2206
|
-
len = left > have ? have : left;
|
|
2207
|
-
last = flush === Z_FINISH$3 && s.strm.avail_in === 0 &&
|
|
2208
|
-
len === left ? 1 : 0;
|
|
2209
|
-
_tr_stored_block(s, s.block_start, len, last);
|
|
2210
|
-
s.block_start += len;
|
|
2211
|
-
flush_pending(s.strm);
|
|
2212
|
-
}
|
|
2213
|
-
|
|
2214
|
-
/* We've done all we can with the available input and output. */
|
|
2215
|
-
return last ? BS_FINISH_STARTED : BS_NEED_MORE;
|
|
2022
|
+
return BS_NEED_MORE;
|
|
2216
2023
|
};
|
|
2217
2024
|
|
|
2218
|
-
|
|
2219
2025
|
/* ===========================================================================
|
|
2220
2026
|
* Compress as much as possible from the input stream, return the current
|
|
2221
2027
|
* block state.
|
|
@@ -2336,7 +2142,7 @@ const deflate_fast = (s, flush) => {
|
|
|
2336
2142
|
/***/
|
|
2337
2143
|
return BS_FINISH_DONE;
|
|
2338
2144
|
}
|
|
2339
|
-
if (s.
|
|
2145
|
+
if (s.last_lit) {
|
|
2340
2146
|
/*** FLUSH_BLOCK(s, 0); ***/
|
|
2341
2147
|
flush_block_only(s, false);
|
|
2342
2148
|
if (s.strm.avail_out === 0) {
|
|
@@ -2497,7 +2303,7 @@ const deflate_slow = (s, flush) => {
|
|
|
2497
2303
|
/***/
|
|
2498
2304
|
return BS_FINISH_DONE;
|
|
2499
2305
|
}
|
|
2500
|
-
if (s.
|
|
2306
|
+
if (s.last_lit) {
|
|
2501
2307
|
/*** FLUSH_BLOCK(s, 0); ***/
|
|
2502
2308
|
flush_block_only(s, false);
|
|
2503
2309
|
if (s.strm.avail_out === 0) {
|
|
@@ -2596,7 +2402,7 @@ const deflate_rle = (s, flush) => {
|
|
|
2596
2402
|
/***/
|
|
2597
2403
|
return BS_FINISH_DONE;
|
|
2598
2404
|
}
|
|
2599
|
-
if (s.
|
|
2405
|
+
if (s.last_lit) {
|
|
2600
2406
|
/*** FLUSH_BLOCK(s, 0); ***/
|
|
2601
2407
|
flush_block_only(s, false);
|
|
2602
2408
|
if (s.strm.avail_out === 0) {
|
|
@@ -2653,7 +2459,7 @@ const deflate_huff = (s, flush) => {
|
|
|
2653
2459
|
/***/
|
|
2654
2460
|
return BS_FINISH_DONE;
|
|
2655
2461
|
}
|
|
2656
|
-
if (s.
|
|
2462
|
+
if (s.last_lit) {
|
|
2657
2463
|
/*** FLUSH_BLOCK(s, 0); ***/
|
|
2658
2464
|
flush_block_only(s, false);
|
|
2659
2465
|
if (s.strm.avail_out === 0) {
|
|
@@ -2854,7 +2660,7 @@ function DeflateState() {
|
|
|
2854
2660
|
/* Depth of each subtree used as tie breaker for trees of equal frequency
|
|
2855
2661
|
*/
|
|
2856
2662
|
|
|
2857
|
-
this.
|
|
2663
|
+
this.l_buf = 0; /* buffer index for literals or lengths */
|
|
2858
2664
|
|
|
2859
2665
|
this.lit_bufsize = 0;
|
|
2860
2666
|
/* Size of match buffer for literals/lengths. There are 4 reasons for
|
|
@@ -2876,8 +2682,13 @@ function DeflateState() {
|
|
|
2876
2682
|
* - I can't count above 4
|
|
2877
2683
|
*/
|
|
2878
2684
|
|
|
2879
|
-
this.
|
|
2880
|
-
|
|
2685
|
+
this.last_lit = 0; /* running index in l_buf */
|
|
2686
|
+
|
|
2687
|
+
this.d_buf = 0;
|
|
2688
|
+
/* Buffer index for distances. To simplify the code, d_buf and l_buf have
|
|
2689
|
+
* the same number of elements. To use different lengths, an extra flag
|
|
2690
|
+
* array would be necessary.
|
|
2691
|
+
*/
|
|
2881
2692
|
|
|
2882
2693
|
this.opt_len = 0; /* bit length of current block with optimal trees */
|
|
2883
2694
|
this.static_len = 0; /* bit length of current block with static trees */
|
|
@@ -2905,34 +2716,9 @@ function DeflateState() {
|
|
|
2905
2716
|
}
|
|
2906
2717
|
|
|
2907
2718
|
|
|
2908
|
-
/* =========================================================================
|
|
2909
|
-
* Check for a valid deflate stream state. Return 0 if ok, 1 if not.
|
|
2910
|
-
*/
|
|
2911
|
-
const deflateStateCheck = (strm) => {
|
|
2912
|
-
|
|
2913
|
-
if (!strm) {
|
|
2914
|
-
return 1;
|
|
2915
|
-
}
|
|
2916
|
-
const s = strm.state;
|
|
2917
|
-
if (!s || s.strm !== strm || (s.status !== INIT_STATE &&
|
|
2918
|
-
//#ifdef GZIP
|
|
2919
|
-
s.status !== GZIP_STATE &&
|
|
2920
|
-
//#endif
|
|
2921
|
-
s.status !== EXTRA_STATE &&
|
|
2922
|
-
s.status !== NAME_STATE &&
|
|
2923
|
-
s.status !== COMMENT_STATE &&
|
|
2924
|
-
s.status !== HCRC_STATE &&
|
|
2925
|
-
s.status !== BUSY_STATE &&
|
|
2926
|
-
s.status !== FINISH_STATE)) {
|
|
2927
|
-
return 1;
|
|
2928
|
-
}
|
|
2929
|
-
return 0;
|
|
2930
|
-
};
|
|
2931
|
-
|
|
2932
|
-
|
|
2933
2719
|
const deflateResetKeep = (strm) => {
|
|
2934
2720
|
|
|
2935
|
-
if (
|
|
2721
|
+
if (!strm || !strm.state) {
|
|
2936
2722
|
return err(strm, Z_STREAM_ERROR$2);
|
|
2937
2723
|
}
|
|
2938
2724
|
|
|
@@ -2947,16 +2733,12 @@ const deflateResetKeep = (strm) => {
|
|
|
2947
2733
|
s.wrap = -s.wrap;
|
|
2948
2734
|
/* was made negative by deflate(..., Z_FINISH); */
|
|
2949
2735
|
}
|
|
2950
|
-
s.status =
|
|
2951
|
-
//#ifdef GZIP
|
|
2952
|
-
s.wrap === 2 ? GZIP_STATE :
|
|
2953
|
-
//#endif
|
|
2954
|
-
s.wrap ? INIT_STATE : BUSY_STATE;
|
|
2736
|
+
s.status = (s.wrap ? INIT_STATE : BUSY_STATE);
|
|
2955
2737
|
strm.adler = (s.wrap === 2) ?
|
|
2956
2738
|
0 // crc32(0, Z_NULL, 0)
|
|
2957
2739
|
:
|
|
2958
2740
|
1; // adler32(0, Z_NULL, 0)
|
|
2959
|
-
s.last_flush =
|
|
2741
|
+
s.last_flush = Z_NO_FLUSH$2;
|
|
2960
2742
|
_tr_init(s);
|
|
2961
2743
|
return Z_OK$3;
|
|
2962
2744
|
};
|
|
@@ -2974,9 +2756,8 @@ const deflateReset = (strm) => {
|
|
|
2974
2756
|
|
|
2975
2757
|
const deflateSetHeader = (strm, head) => {
|
|
2976
2758
|
|
|
2977
|
-
if (
|
|
2978
|
-
|
|
2979
|
-
}
|
|
2759
|
+
if (!strm || !strm.state) { return Z_STREAM_ERROR$2; }
|
|
2760
|
+
if (strm.state.wrap !== 2) { return Z_STREAM_ERROR$2; }
|
|
2980
2761
|
strm.state.gzhead = head;
|
|
2981
2762
|
return Z_OK$3;
|
|
2982
2763
|
};
|
|
@@ -3006,7 +2787,7 @@ const deflateInit2 = (strm, level, method, windowBits, memLevel, strategy) => {
|
|
|
3006
2787
|
|
|
3007
2788
|
if (memLevel < 1 || memLevel > MAX_MEM_LEVEL || method !== Z_DEFLATED$2 ||
|
|
3008
2789
|
windowBits < 8 || windowBits > 15 || level < 0 || level > 9 ||
|
|
3009
|
-
strategy < 0 || strategy > Z_FIXED
|
|
2790
|
+
strategy < 0 || strategy > Z_FIXED) {
|
|
3010
2791
|
return err(strm, Z_STREAM_ERROR$2);
|
|
3011
2792
|
}
|
|
3012
2793
|
|
|
@@ -3020,7 +2801,6 @@ const deflateInit2 = (strm, level, method, windowBits, memLevel, strategy) => {
|
|
|
3020
2801
|
|
|
3021
2802
|
strm.state = s;
|
|
3022
2803
|
s.strm = strm;
|
|
3023
|
-
s.status = INIT_STATE; /* to pass state test in deflateReset() */
|
|
3024
2804
|
|
|
3025
2805
|
s.wrap = wrap;
|
|
3026
2806
|
s.gzhead = null;
|
|
@@ -3042,58 +2822,18 @@ const deflateInit2 = (strm, level, method, windowBits, memLevel, strategy) => {
|
|
|
3042
2822
|
|
|
3043
2823
|
s.lit_bufsize = 1 << (memLevel + 6); /* 16K elements by default */
|
|
3044
2824
|
|
|
3045
|
-
/* We overlay pending_buf and sym_buf. This works since the average size
|
|
3046
|
-
* for length/distance pairs over any compressed block is assured to be 31
|
|
3047
|
-
* bits or less.
|
|
3048
|
-
*
|
|
3049
|
-
* Analysis: The longest fixed codes are a length code of 8 bits plus 5
|
|
3050
|
-
* extra bits, for lengths 131 to 257. The longest fixed distance codes are
|
|
3051
|
-
* 5 bits plus 13 extra bits, for distances 16385 to 32768. The longest
|
|
3052
|
-
* possible fixed-codes length/distance pair is then 31 bits total.
|
|
3053
|
-
*
|
|
3054
|
-
* sym_buf starts one-fourth of the way into pending_buf. So there are
|
|
3055
|
-
* three bytes in sym_buf for every four bytes in pending_buf. Each symbol
|
|
3056
|
-
* in sym_buf is three bytes -- two for the distance and one for the
|
|
3057
|
-
* literal/length. As each symbol is consumed, the pointer to the next
|
|
3058
|
-
* sym_buf value to read moves forward three bytes. From that symbol, up to
|
|
3059
|
-
* 31 bits are written to pending_buf. The closest the written pending_buf
|
|
3060
|
-
* bits gets to the next sym_buf symbol to read is just before the last
|
|
3061
|
-
* code is written. At that time, 31*(n-2) bits have been written, just
|
|
3062
|
-
* after 24*(n-2) bits have been consumed from sym_buf. sym_buf starts at
|
|
3063
|
-
* 8*n bits into pending_buf. (Note that the symbol buffer fills when n-1
|
|
3064
|
-
* symbols are written.) The closest the writing gets to what is unread is
|
|
3065
|
-
* then n+14 bits. Here n is lit_bufsize, which is 16384 by default, and
|
|
3066
|
-
* can range from 128 to 32768.
|
|
3067
|
-
*
|
|
3068
|
-
* Therefore, at a minimum, there are 142 bits of space between what is
|
|
3069
|
-
* written and what is read in the overlain buffers, so the symbols cannot
|
|
3070
|
-
* be overwritten by the compressed data. That space is actually 139 bits,
|
|
3071
|
-
* due to the three-bit fixed-code block header.
|
|
3072
|
-
*
|
|
3073
|
-
* That covers the case where either Z_FIXED is specified, forcing fixed
|
|
3074
|
-
* codes, or when the use of fixed codes is chosen, because that choice
|
|
3075
|
-
* results in a smaller compressed block than dynamic codes. That latter
|
|
3076
|
-
* condition then assures that the above analysis also covers all dynamic
|
|
3077
|
-
* blocks. A dynamic-code block will only be chosen to be emitted if it has
|
|
3078
|
-
* fewer bits than a fixed-code block would for the same set of symbols.
|
|
3079
|
-
* Therefore its average symbol length is assured to be less than 31. So
|
|
3080
|
-
* the compressed data for a dynamic block also cannot overwrite the
|
|
3081
|
-
* symbols from which it is being constructed.
|
|
3082
|
-
*/
|
|
3083
|
-
|
|
3084
2825
|
s.pending_buf_size = s.lit_bufsize * 4;
|
|
2826
|
+
|
|
2827
|
+
//overlay = (ushf *) ZALLOC(strm, s->lit_bufsize, sizeof(ush)+2);
|
|
2828
|
+
//s->pending_buf = (uchf *) overlay;
|
|
3085
2829
|
s.pending_buf = new Uint8Array(s.pending_buf_size);
|
|
3086
2830
|
|
|
3087
2831
|
// It is offset from `s.pending_buf` (size is `s.lit_bufsize * 2`)
|
|
3088
|
-
//s->
|
|
3089
|
-
s.
|
|
2832
|
+
//s->d_buf = overlay + s->lit_bufsize/sizeof(ush);
|
|
2833
|
+
s.d_buf = 1 * s.lit_bufsize;
|
|
3090
2834
|
|
|
3091
|
-
//s->
|
|
3092
|
-
s.
|
|
3093
|
-
/* We avoid equality with lit_bufsize*3 because of wraparound at 64K
|
|
3094
|
-
* on 16 bit machines and because stored blocks are restricted to
|
|
3095
|
-
* 64K-1 bytes.
|
|
3096
|
-
*/
|
|
2835
|
+
//s->l_buf = s->pending_buf + (1+sizeof(ush))*s->lit_bufsize;
|
|
2836
|
+
s.l_buf = (1 + 2) * s.lit_bufsize;
|
|
3097
2837
|
|
|
3098
2838
|
s.level = level;
|
|
3099
2839
|
s.strategy = strategy;
|
|
@@ -3108,200 +2848,150 @@ const deflateInit = (strm, level) => {
|
|
|
3108
2848
|
};
|
|
3109
2849
|
|
|
3110
2850
|
|
|
3111
|
-
/* ========================================================================= */
|
|
3112
2851
|
const deflate$2 = (strm, flush) => {
|
|
3113
2852
|
|
|
3114
|
-
|
|
2853
|
+
let beg, val; // for gzip header write only
|
|
2854
|
+
|
|
2855
|
+
if (!strm || !strm.state ||
|
|
2856
|
+
flush > Z_BLOCK$1 || flush < 0) {
|
|
3115
2857
|
return strm ? err(strm, Z_STREAM_ERROR$2) : Z_STREAM_ERROR$2;
|
|
3116
2858
|
}
|
|
3117
2859
|
|
|
3118
2860
|
const s = strm.state;
|
|
3119
2861
|
|
|
3120
2862
|
if (!strm.output ||
|
|
3121
|
-
(strm.avail_in !== 0
|
|
2863
|
+
(!strm.input && strm.avail_in !== 0) ||
|
|
3122
2864
|
(s.status === FINISH_STATE && flush !== Z_FINISH$3)) {
|
|
3123
2865
|
return err(strm, (strm.avail_out === 0) ? Z_BUF_ERROR$1 : Z_STREAM_ERROR$2);
|
|
3124
2866
|
}
|
|
3125
2867
|
|
|
2868
|
+
s.strm = strm; /* just in case */
|
|
3126
2869
|
const old_flush = s.last_flush;
|
|
3127
2870
|
s.last_flush = flush;
|
|
3128
2871
|
|
|
3129
|
-
/* Flush as much pending output as possible */
|
|
3130
|
-
if (s.pending !== 0) {
|
|
3131
|
-
flush_pending(strm);
|
|
3132
|
-
if (strm.avail_out === 0) {
|
|
3133
|
-
/* Since avail_out is 0, deflate will be called again with
|
|
3134
|
-
* more output space, but possibly with both pending and
|
|
3135
|
-
* avail_in equal to zero. There won't be anything to do,
|
|
3136
|
-
* but this is not an error situation so make sure we
|
|
3137
|
-
* return OK instead of BUF_ERROR at next call of deflate:
|
|
3138
|
-
*/
|
|
3139
|
-
s.last_flush = -1;
|
|
3140
|
-
return Z_OK$3;
|
|
3141
|
-
}
|
|
3142
|
-
|
|
3143
|
-
/* Make sure there is something to do and avoid duplicate consecutive
|
|
3144
|
-
* flushes. For repeated and useless calls with Z_FINISH, we keep
|
|
3145
|
-
* returning Z_STREAM_END instead of Z_BUF_ERROR.
|
|
3146
|
-
*/
|
|
3147
|
-
} else if (strm.avail_in === 0 && rank(flush) <= rank(old_flush) &&
|
|
3148
|
-
flush !== Z_FINISH$3) {
|
|
3149
|
-
return err(strm, Z_BUF_ERROR$1);
|
|
3150
|
-
}
|
|
3151
|
-
|
|
3152
|
-
/* User must not provide more input after the first FINISH: */
|
|
3153
|
-
if (s.status === FINISH_STATE && strm.avail_in !== 0) {
|
|
3154
|
-
return err(strm, Z_BUF_ERROR$1);
|
|
3155
|
-
}
|
|
3156
|
-
|
|
3157
2872
|
/* Write the header */
|
|
3158
|
-
if (s.status === INIT_STATE && s.wrap === 0) {
|
|
3159
|
-
s.status = BUSY_STATE;
|
|
3160
|
-
}
|
|
3161
2873
|
if (s.status === INIT_STATE) {
|
|
3162
|
-
/* zlib header */
|
|
3163
|
-
let header = (Z_DEFLATED$2 + ((s.w_bits - 8) << 4)) << 8;
|
|
3164
|
-
let level_flags = -1;
|
|
3165
|
-
|
|
3166
|
-
if (s.strategy >= Z_HUFFMAN_ONLY || s.level < 2) {
|
|
3167
|
-
level_flags = 0;
|
|
3168
|
-
} else if (s.level < 6) {
|
|
3169
|
-
level_flags = 1;
|
|
3170
|
-
} else if (s.level === 6) {
|
|
3171
|
-
level_flags = 2;
|
|
3172
|
-
} else {
|
|
3173
|
-
level_flags = 3;
|
|
3174
|
-
}
|
|
3175
|
-
header |= (level_flags << 6);
|
|
3176
|
-
if (s.strstart !== 0) { header |= PRESET_DICT; }
|
|
3177
|
-
header += 31 - (header % 31);
|
|
3178
|
-
|
|
3179
|
-
putShortMSB(s, header);
|
|
3180
2874
|
|
|
3181
|
-
|
|
3182
|
-
|
|
3183
|
-
|
|
3184
|
-
|
|
2875
|
+
if (s.wrap === 2) { // GZIP header
|
|
2876
|
+
strm.adler = 0; //crc32(0L, Z_NULL, 0);
|
|
2877
|
+
put_byte(s, 31);
|
|
2878
|
+
put_byte(s, 139);
|
|
2879
|
+
put_byte(s, 8);
|
|
2880
|
+
if (!s.gzhead) { // s->gzhead == Z_NULL
|
|
2881
|
+
put_byte(s, 0);
|
|
2882
|
+
put_byte(s, 0);
|
|
2883
|
+
put_byte(s, 0);
|
|
2884
|
+
put_byte(s, 0);
|
|
2885
|
+
put_byte(s, 0);
|
|
2886
|
+
put_byte(s, s.level === 9 ? 2 :
|
|
2887
|
+
(s.strategy >= Z_HUFFMAN_ONLY || s.level < 2 ?
|
|
2888
|
+
4 : 0));
|
|
2889
|
+
put_byte(s, OS_CODE);
|
|
2890
|
+
s.status = BUSY_STATE;
|
|
2891
|
+
}
|
|
2892
|
+
else {
|
|
2893
|
+
put_byte(s, (s.gzhead.text ? 1 : 0) +
|
|
2894
|
+
(s.gzhead.hcrc ? 2 : 0) +
|
|
2895
|
+
(!s.gzhead.extra ? 0 : 4) +
|
|
2896
|
+
(!s.gzhead.name ? 0 : 8) +
|
|
2897
|
+
(!s.gzhead.comment ? 0 : 16)
|
|
2898
|
+
);
|
|
2899
|
+
put_byte(s, s.gzhead.time & 0xff);
|
|
2900
|
+
put_byte(s, (s.gzhead.time >> 8) & 0xff);
|
|
2901
|
+
put_byte(s, (s.gzhead.time >> 16) & 0xff);
|
|
2902
|
+
put_byte(s, (s.gzhead.time >> 24) & 0xff);
|
|
2903
|
+
put_byte(s, s.level === 9 ? 2 :
|
|
2904
|
+
(s.strategy >= Z_HUFFMAN_ONLY || s.level < 2 ?
|
|
2905
|
+
4 : 0));
|
|
2906
|
+
put_byte(s, s.gzhead.os & 0xff);
|
|
2907
|
+
if (s.gzhead.extra && s.gzhead.extra.length) {
|
|
2908
|
+
put_byte(s, s.gzhead.extra.length & 0xff);
|
|
2909
|
+
put_byte(s, (s.gzhead.extra.length >> 8) & 0xff);
|
|
2910
|
+
}
|
|
2911
|
+
if (s.gzhead.hcrc) {
|
|
2912
|
+
strm.adler = crc32_1(strm.adler, s.pending_buf, s.pending, 0);
|
|
2913
|
+
}
|
|
2914
|
+
s.gzindex = 0;
|
|
2915
|
+
s.status = EXTRA_STATE;
|
|
2916
|
+
}
|
|
3185
2917
|
}
|
|
3186
|
-
|
|
3187
|
-
|
|
2918
|
+
else // DEFLATE header
|
|
2919
|
+
{
|
|
2920
|
+
let header = (Z_DEFLATED$2 + ((s.w_bits - 8) << 4)) << 8;
|
|
2921
|
+
let level_flags = -1;
|
|
2922
|
+
|
|
2923
|
+
if (s.strategy >= Z_HUFFMAN_ONLY || s.level < 2) {
|
|
2924
|
+
level_flags = 0;
|
|
2925
|
+
} else if (s.level < 6) {
|
|
2926
|
+
level_flags = 1;
|
|
2927
|
+
} else if (s.level === 6) {
|
|
2928
|
+
level_flags = 2;
|
|
2929
|
+
} else {
|
|
2930
|
+
level_flags = 3;
|
|
2931
|
+
}
|
|
2932
|
+
header |= (level_flags << 6);
|
|
2933
|
+
if (s.strstart !== 0) { header |= PRESET_DICT; }
|
|
2934
|
+
header += 31 - (header % 31);
|
|
3188
2935
|
|
|
3189
|
-
/* Compression must start with an empty pending buffer */
|
|
3190
|
-
flush_pending(strm);
|
|
3191
|
-
if (s.pending !== 0) {
|
|
3192
|
-
s.last_flush = -1;
|
|
3193
|
-
return Z_OK$3;
|
|
3194
|
-
}
|
|
3195
|
-
}
|
|
3196
|
-
//#ifdef GZIP
|
|
3197
|
-
if (s.status === GZIP_STATE) {
|
|
3198
|
-
/* gzip header */
|
|
3199
|
-
strm.adler = 0; //crc32(0L, Z_NULL, 0);
|
|
3200
|
-
put_byte(s, 31);
|
|
3201
|
-
put_byte(s, 139);
|
|
3202
|
-
put_byte(s, 8);
|
|
3203
|
-
if (!s.gzhead) { // s->gzhead == Z_NULL
|
|
3204
|
-
put_byte(s, 0);
|
|
3205
|
-
put_byte(s, 0);
|
|
3206
|
-
put_byte(s, 0);
|
|
3207
|
-
put_byte(s, 0);
|
|
3208
|
-
put_byte(s, 0);
|
|
3209
|
-
put_byte(s, s.level === 9 ? 2 :
|
|
3210
|
-
(s.strategy >= Z_HUFFMAN_ONLY || s.level < 2 ?
|
|
3211
|
-
4 : 0));
|
|
3212
|
-
put_byte(s, OS_CODE);
|
|
3213
2936
|
s.status = BUSY_STATE;
|
|
2937
|
+
putShortMSB(s, header);
|
|
3214
2938
|
|
|
3215
|
-
/*
|
|
3216
|
-
|
|
3217
|
-
|
|
3218
|
-
s.
|
|
3219
|
-
return Z_OK$3;
|
|
3220
|
-
}
|
|
3221
|
-
}
|
|
3222
|
-
else {
|
|
3223
|
-
put_byte(s, (s.gzhead.text ? 1 : 0) +
|
|
3224
|
-
(s.gzhead.hcrc ? 2 : 0) +
|
|
3225
|
-
(!s.gzhead.extra ? 0 : 4) +
|
|
3226
|
-
(!s.gzhead.name ? 0 : 8) +
|
|
3227
|
-
(!s.gzhead.comment ? 0 : 16)
|
|
3228
|
-
);
|
|
3229
|
-
put_byte(s, s.gzhead.time & 0xff);
|
|
3230
|
-
put_byte(s, (s.gzhead.time >> 8) & 0xff);
|
|
3231
|
-
put_byte(s, (s.gzhead.time >> 16) & 0xff);
|
|
3232
|
-
put_byte(s, (s.gzhead.time >> 24) & 0xff);
|
|
3233
|
-
put_byte(s, s.level === 9 ? 2 :
|
|
3234
|
-
(s.strategy >= Z_HUFFMAN_ONLY || s.level < 2 ?
|
|
3235
|
-
4 : 0));
|
|
3236
|
-
put_byte(s, s.gzhead.os & 0xff);
|
|
3237
|
-
if (s.gzhead.extra && s.gzhead.extra.length) {
|
|
3238
|
-
put_byte(s, s.gzhead.extra.length & 0xff);
|
|
3239
|
-
put_byte(s, (s.gzhead.extra.length >> 8) & 0xff);
|
|
3240
|
-
}
|
|
3241
|
-
if (s.gzhead.hcrc) {
|
|
3242
|
-
strm.adler = crc32_1(strm.adler, s.pending_buf, s.pending, 0);
|
|
2939
|
+
/* Save the adler32 of the preset dictionary: */
|
|
2940
|
+
if (s.strstart !== 0) {
|
|
2941
|
+
putShortMSB(s, strm.adler >>> 16);
|
|
2942
|
+
putShortMSB(s, strm.adler & 0xffff);
|
|
3243
2943
|
}
|
|
3244
|
-
|
|
3245
|
-
s.status = EXTRA_STATE;
|
|
2944
|
+
strm.adler = 1; // adler32(0L, Z_NULL, 0);
|
|
3246
2945
|
}
|
|
3247
2946
|
}
|
|
2947
|
+
|
|
2948
|
+
//#ifdef GZIP
|
|
3248
2949
|
if (s.status === EXTRA_STATE) {
|
|
3249
2950
|
if (s.gzhead.extra/* != Z_NULL*/) {
|
|
3250
|
-
|
|
3251
|
-
|
|
3252
|
-
while (s.
|
|
3253
|
-
|
|
3254
|
-
|
|
3255
|
-
|
|
3256
|
-
|
|
3257
|
-
|
|
3258
|
-
|
|
3259
|
-
|
|
3260
|
-
|
|
3261
|
-
|
|
3262
|
-
//---//
|
|
3263
|
-
s.gzindex += copy;
|
|
3264
|
-
flush_pending(strm);
|
|
3265
|
-
if (s.pending !== 0) {
|
|
3266
|
-
s.last_flush = -1;
|
|
3267
|
-
return Z_OK$3;
|
|
2951
|
+
beg = s.pending; /* start of bytes to update crc */
|
|
2952
|
+
|
|
2953
|
+
while (s.gzindex < (s.gzhead.extra.length & 0xffff)) {
|
|
2954
|
+
if (s.pending === s.pending_buf_size) {
|
|
2955
|
+
if (s.gzhead.hcrc && s.pending > beg) {
|
|
2956
|
+
strm.adler = crc32_1(strm.adler, s.pending_buf, s.pending - beg, beg);
|
|
2957
|
+
}
|
|
2958
|
+
flush_pending(strm);
|
|
2959
|
+
beg = s.pending;
|
|
2960
|
+
if (s.pending === s.pending_buf_size) {
|
|
2961
|
+
break;
|
|
2962
|
+
}
|
|
3268
2963
|
}
|
|
3269
|
-
|
|
3270
|
-
|
|
2964
|
+
put_byte(s, s.gzhead.extra[s.gzindex] & 0xff);
|
|
2965
|
+
s.gzindex++;
|
|
3271
2966
|
}
|
|
3272
|
-
// JS specific: s.gzhead.extra may be TypedArray or Array for backward compatibility
|
|
3273
|
-
// TypedArray.slice and TypedArray.from don't exist in IE10-IE11
|
|
3274
|
-
let gzhead_extra = new Uint8Array(s.gzhead.extra);
|
|
3275
|
-
// zmemcpy(s->pending_buf + s->pending,
|
|
3276
|
-
// s->gzhead->extra + s->gzindex, left);
|
|
3277
|
-
s.pending_buf.set(gzhead_extra.subarray(s.gzindex, s.gzindex + left), s.pending);
|
|
3278
|
-
s.pending += left;
|
|
3279
|
-
//--- HCRC_UPDATE(beg) ---//
|
|
3280
2967
|
if (s.gzhead.hcrc && s.pending > beg) {
|
|
3281
2968
|
strm.adler = crc32_1(strm.adler, s.pending_buf, s.pending - beg, beg);
|
|
3282
2969
|
}
|
|
3283
|
-
|
|
3284
|
-
|
|
2970
|
+
if (s.gzindex === s.gzhead.extra.length) {
|
|
2971
|
+
s.gzindex = 0;
|
|
2972
|
+
s.status = NAME_STATE;
|
|
2973
|
+
}
|
|
2974
|
+
}
|
|
2975
|
+
else {
|
|
2976
|
+
s.status = NAME_STATE;
|
|
3285
2977
|
}
|
|
3286
|
-
s.status = NAME_STATE;
|
|
3287
2978
|
}
|
|
3288
2979
|
if (s.status === NAME_STATE) {
|
|
3289
2980
|
if (s.gzhead.name/* != Z_NULL*/) {
|
|
3290
|
-
|
|
3291
|
-
|
|
2981
|
+
beg = s.pending; /* start of bytes to update crc */
|
|
2982
|
+
//int val;
|
|
2983
|
+
|
|
3292
2984
|
do {
|
|
3293
2985
|
if (s.pending === s.pending_buf_size) {
|
|
3294
|
-
//--- HCRC_UPDATE(beg) ---//
|
|
3295
2986
|
if (s.gzhead.hcrc && s.pending > beg) {
|
|
3296
2987
|
strm.adler = crc32_1(strm.adler, s.pending_buf, s.pending - beg, beg);
|
|
3297
2988
|
}
|
|
3298
|
-
//---//
|
|
3299
2989
|
flush_pending(strm);
|
|
3300
|
-
|
|
3301
|
-
|
|
3302
|
-
|
|
2990
|
+
beg = s.pending;
|
|
2991
|
+
if (s.pending === s.pending_buf_size) {
|
|
2992
|
+
val = 1;
|
|
2993
|
+
break;
|
|
3303
2994
|
}
|
|
3304
|
-
beg = 0;
|
|
3305
2995
|
}
|
|
3306
2996
|
// JS specific: little magic to add zero terminator to end of string
|
|
3307
2997
|
if (s.gzindex < s.gzhead.name.length) {
|
|
@@ -3311,32 +3001,35 @@ const deflate$2 = (strm, flush) => {
|
|
|
3311
3001
|
}
|
|
3312
3002
|
put_byte(s, val);
|
|
3313
3003
|
} while (val !== 0);
|
|
3314
|
-
|
|
3004
|
+
|
|
3315
3005
|
if (s.gzhead.hcrc && s.pending > beg) {
|
|
3316
3006
|
strm.adler = crc32_1(strm.adler, s.pending_buf, s.pending - beg, beg);
|
|
3317
3007
|
}
|
|
3318
|
-
|
|
3319
|
-
|
|
3008
|
+
if (val === 0) {
|
|
3009
|
+
s.gzindex = 0;
|
|
3010
|
+
s.status = COMMENT_STATE;
|
|
3011
|
+
}
|
|
3012
|
+
}
|
|
3013
|
+
else {
|
|
3014
|
+
s.status = COMMENT_STATE;
|
|
3320
3015
|
}
|
|
3321
|
-
s.status = COMMENT_STATE;
|
|
3322
3016
|
}
|
|
3323
3017
|
if (s.status === COMMENT_STATE) {
|
|
3324
3018
|
if (s.gzhead.comment/* != Z_NULL*/) {
|
|
3325
|
-
|
|
3326
|
-
|
|
3019
|
+
beg = s.pending; /* start of bytes to update crc */
|
|
3020
|
+
//int val;
|
|
3021
|
+
|
|
3327
3022
|
do {
|
|
3328
3023
|
if (s.pending === s.pending_buf_size) {
|
|
3329
|
-
//--- HCRC_UPDATE(beg) ---//
|
|
3330
3024
|
if (s.gzhead.hcrc && s.pending > beg) {
|
|
3331
3025
|
strm.adler = crc32_1(strm.adler, s.pending_buf, s.pending - beg, beg);
|
|
3332
3026
|
}
|
|
3333
|
-
//---//
|
|
3334
3027
|
flush_pending(strm);
|
|
3335
|
-
|
|
3336
|
-
|
|
3337
|
-
|
|
3028
|
+
beg = s.pending;
|
|
3029
|
+
if (s.pending === s.pending_buf_size) {
|
|
3030
|
+
val = 1;
|
|
3031
|
+
break;
|
|
3338
3032
|
}
|
|
3339
|
-
beg = 0;
|
|
3340
3033
|
}
|
|
3341
3034
|
// JS specific: little magic to add zero terminator to end of string
|
|
3342
3035
|
if (s.gzindex < s.gzhead.comment.length) {
|
|
@@ -3346,46 +3039,71 @@ const deflate$2 = (strm, flush) => {
|
|
|
3346
3039
|
}
|
|
3347
3040
|
put_byte(s, val);
|
|
3348
3041
|
} while (val !== 0);
|
|
3349
|
-
|
|
3042
|
+
|
|
3350
3043
|
if (s.gzhead.hcrc && s.pending > beg) {
|
|
3351
3044
|
strm.adler = crc32_1(strm.adler, s.pending_buf, s.pending - beg, beg);
|
|
3352
3045
|
}
|
|
3353
|
-
|
|
3046
|
+
if (val === 0) {
|
|
3047
|
+
s.status = HCRC_STATE;
|
|
3048
|
+
}
|
|
3049
|
+
}
|
|
3050
|
+
else {
|
|
3051
|
+
s.status = HCRC_STATE;
|
|
3354
3052
|
}
|
|
3355
|
-
s.status = HCRC_STATE;
|
|
3356
3053
|
}
|
|
3357
3054
|
if (s.status === HCRC_STATE) {
|
|
3358
3055
|
if (s.gzhead.hcrc) {
|
|
3359
3056
|
if (s.pending + 2 > s.pending_buf_size) {
|
|
3360
3057
|
flush_pending(strm);
|
|
3361
|
-
if (s.pending !== 0) {
|
|
3362
|
-
s.last_flush = -1;
|
|
3363
|
-
return Z_OK$3;
|
|
3364
|
-
}
|
|
3365
3058
|
}
|
|
3366
|
-
|
|
3367
|
-
|
|
3368
|
-
|
|
3059
|
+
if (s.pending + 2 <= s.pending_buf_size) {
|
|
3060
|
+
put_byte(s, strm.adler & 0xff);
|
|
3061
|
+
put_byte(s, (strm.adler >> 8) & 0xff);
|
|
3062
|
+
strm.adler = 0; //crc32(0L, Z_NULL, 0);
|
|
3063
|
+
s.status = BUSY_STATE;
|
|
3064
|
+
}
|
|
3065
|
+
}
|
|
3066
|
+
else {
|
|
3067
|
+
s.status = BUSY_STATE;
|
|
3369
3068
|
}
|
|
3370
|
-
|
|
3069
|
+
}
|
|
3070
|
+
//#endif
|
|
3371
3071
|
|
|
3372
|
-
|
|
3072
|
+
/* Flush as much pending output as possible */
|
|
3073
|
+
if (s.pending !== 0) {
|
|
3373
3074
|
flush_pending(strm);
|
|
3374
|
-
if (
|
|
3075
|
+
if (strm.avail_out === 0) {
|
|
3076
|
+
/* Since avail_out is 0, deflate will be called again with
|
|
3077
|
+
* more output space, but possibly with both pending and
|
|
3078
|
+
* avail_in equal to zero. There won't be anything to do,
|
|
3079
|
+
* but this is not an error situation so make sure we
|
|
3080
|
+
* return OK instead of BUF_ERROR at next call of deflate:
|
|
3081
|
+
*/
|
|
3375
3082
|
s.last_flush = -1;
|
|
3376
3083
|
return Z_OK$3;
|
|
3377
3084
|
}
|
|
3085
|
+
|
|
3086
|
+
/* Make sure there is something to do and avoid duplicate consecutive
|
|
3087
|
+
* flushes. For repeated and useless calls with Z_FINISH, we keep
|
|
3088
|
+
* returning Z_STREAM_END instead of Z_BUF_ERROR.
|
|
3089
|
+
*/
|
|
3090
|
+
} else if (strm.avail_in === 0 && rank(flush) <= rank(old_flush) &&
|
|
3091
|
+
flush !== Z_FINISH$3) {
|
|
3092
|
+
return err(strm, Z_BUF_ERROR$1);
|
|
3093
|
+
}
|
|
3094
|
+
|
|
3095
|
+
/* User must not provide more input after the first FINISH: */
|
|
3096
|
+
if (s.status === FINISH_STATE && strm.avail_in !== 0) {
|
|
3097
|
+
return err(strm, Z_BUF_ERROR$1);
|
|
3378
3098
|
}
|
|
3379
|
-
//#endif
|
|
3380
3099
|
|
|
3381
3100
|
/* Start a new block or continue the current one.
|
|
3382
3101
|
*/
|
|
3383
3102
|
if (strm.avail_in !== 0 || s.lookahead !== 0 ||
|
|
3384
3103
|
(flush !== Z_NO_FLUSH$2 && s.status !== FINISH_STATE)) {
|
|
3385
|
-
let bstate = s.
|
|
3386
|
-
|
|
3387
|
-
|
|
3388
|
-
configuration_table[s.level].func(s, flush);
|
|
3104
|
+
let bstate = (s.strategy === Z_HUFFMAN_ONLY) ? deflate_huff(s, flush) :
|
|
3105
|
+
(s.strategy === Z_RLE ? deflate_rle(s, flush) :
|
|
3106
|
+
configuration_table[s.level].func(s, flush));
|
|
3389
3107
|
|
|
3390
3108
|
if (bstate === BS_FINISH_STARTED || bstate === BS_FINISH_DONE) {
|
|
3391
3109
|
s.status = FINISH_STATE;
|
|
@@ -3432,6 +3150,8 @@ const deflate$2 = (strm, flush) => {
|
|
|
3432
3150
|
}
|
|
3433
3151
|
}
|
|
3434
3152
|
}
|
|
3153
|
+
//Assert(strm->avail_out > 0, "bug2");
|
|
3154
|
+
//if (strm.avail_out <= 0) { throw new Error("bug2");}
|
|
3435
3155
|
|
|
3436
3156
|
if (flush !== Z_FINISH$3) { return Z_OK$3; }
|
|
3437
3157
|
if (s.wrap <= 0) { return Z_STREAM_END$3; }
|
|
@@ -3465,11 +3185,21 @@ const deflate$2 = (strm, flush) => {
|
|
|
3465
3185
|
|
|
3466
3186
|
const deflateEnd = (strm) => {
|
|
3467
3187
|
|
|
3468
|
-
if (
|
|
3188
|
+
if (!strm/*== Z_NULL*/ || !strm.state/*== Z_NULL*/) {
|
|
3469
3189
|
return Z_STREAM_ERROR$2;
|
|
3470
3190
|
}
|
|
3471
3191
|
|
|
3472
3192
|
const status = strm.state.status;
|
|
3193
|
+
if (status !== INIT_STATE &&
|
|
3194
|
+
status !== EXTRA_STATE &&
|
|
3195
|
+
status !== NAME_STATE &&
|
|
3196
|
+
status !== COMMENT_STATE &&
|
|
3197
|
+
status !== HCRC_STATE &&
|
|
3198
|
+
status !== BUSY_STATE &&
|
|
3199
|
+
status !== FINISH_STATE
|
|
3200
|
+
) {
|
|
3201
|
+
return err(strm, Z_STREAM_ERROR$2);
|
|
3202
|
+
}
|
|
3473
3203
|
|
|
3474
3204
|
strm.state = null;
|
|
3475
3205
|
|
|
@@ -3485,7 +3215,7 @@ const deflateSetDictionary = (strm, dictionary) => {
|
|
|
3485
3215
|
|
|
3486
3216
|
let dictLength = dictionary.length;
|
|
3487
3217
|
|
|
3488
|
-
if (
|
|
3218
|
+
if (!strm/*== Z_NULL*/ || !strm.state/*== Z_NULL*/) {
|
|
3489
3219
|
return Z_STREAM_ERROR$2;
|
|
3490
3220
|
}
|
|
3491
3221
|
|
|
@@ -3571,7 +3301,6 @@ var deflateInfo = 'pako deflate (from Nodeca project)';
|
|
|
3571
3301
|
/* Not implemented
|
|
3572
3302
|
module.exports.deflateBound = deflateBound;
|
|
3573
3303
|
module.exports.deflateCopy = deflateCopy;
|
|
3574
|
-
module.exports.deflateGetDictionary = deflateGetDictionary;
|
|
3575
3304
|
module.exports.deflateParams = deflateParams;
|
|
3576
3305
|
module.exports.deflatePending = deflatePending;
|
|
3577
3306
|
module.exports.deflatePrime = deflatePrime;
|
|
@@ -4161,7 +3890,7 @@ Deflate$1.prototype.onEnd = function (status) {
|
|
|
4161
3890
|
|
|
4162
3891
|
/**
|
|
4163
3892
|
* deflate(data[, options]) -> Uint8Array
|
|
4164
|
-
* - data (Uint8Array|
|
|
3893
|
+
* - data (Uint8Array|String): input data to compress.
|
|
4165
3894
|
* - options (Object): zlib deflate options.
|
|
4166
3895
|
*
|
|
4167
3896
|
* Compress `data` with deflate algorithm and `options`.
|
|
@@ -4205,7 +3934,7 @@ function deflate$1(input, options) {
|
|
|
4205
3934
|
|
|
4206
3935
|
/**
|
|
4207
3936
|
* deflateRaw(data[, options]) -> Uint8Array
|
|
4208
|
-
* - data (Uint8Array|
|
|
3937
|
+
* - data (Uint8Array|String): input data to compress.
|
|
4209
3938
|
* - options (Object): zlib deflate options.
|
|
4210
3939
|
*
|
|
4211
3940
|
* The same as [[deflate]], but creates raw data, without wrapper
|
|
@@ -4220,7 +3949,7 @@ function deflateRaw$1(input, options) {
|
|
|
4220
3949
|
|
|
4221
3950
|
/**
|
|
4222
3951
|
* gzip(data[, options]) -> Uint8Array
|
|
4223
|
-
* - data (Uint8Array|
|
|
3952
|
+
* - data (Uint8Array|String): input data to compress.
|
|
4224
3953
|
* - options (Object): zlib deflate options.
|
|
4225
3954
|
*
|
|
4226
3955
|
* The same as [[deflate]], but create gzip wrapper instead of
|
|
@@ -4267,8 +3996,8 @@ var deflate_1$1 = {
|
|
|
4267
3996
|
// 3. This notice may not be removed or altered from any source distribution.
|
|
4268
3997
|
|
|
4269
3998
|
// See state defs from inflate.js
|
|
4270
|
-
const BAD$1 =
|
|
4271
|
-
const TYPE$1 =
|
|
3999
|
+
const BAD$1 = 30; /* got a data error -- remain here until reset */
|
|
4000
|
+
const TYPE$1 = 12; /* i: waiting for type bits, including last-flag bit */
|
|
4272
4001
|
|
|
4273
4002
|
/*
|
|
4274
4003
|
Decode literal, length, and distance codes and write out the resulting
|
|
@@ -4660,11 +4389,13 @@ const inflate_table = (type, lens, lens_index, codes, table, table_index, work,
|
|
|
4660
4389
|
let mask; /* mask for low root bits */
|
|
4661
4390
|
let next; /* next available space in table */
|
|
4662
4391
|
let base = null; /* base value table to use */
|
|
4392
|
+
let base_index = 0;
|
|
4663
4393
|
// let shoextra; /* extra bits table to use */
|
|
4664
|
-
let
|
|
4394
|
+
let end; /* use base and extra for symbol > end */
|
|
4665
4395
|
const count = new Uint16Array(MAXBITS + 1); //[MAXBITS+1]; /* number of codes of each length */
|
|
4666
4396
|
const offs = new Uint16Array(MAXBITS + 1); //[MAXBITS+1]; /* offsets in table for each length */
|
|
4667
4397
|
let extra = null;
|
|
4398
|
+
let extra_index = 0;
|
|
4668
4399
|
|
|
4669
4400
|
let here_bits, here_op, here_val;
|
|
4670
4401
|
|
|
@@ -4799,17 +4530,19 @@ const inflate_table = (type, lens, lens_index, codes, table, table_index, work,
|
|
|
4799
4530
|
// to avoid deopts in old v8
|
|
4800
4531
|
if (type === CODES$1) {
|
|
4801
4532
|
base = extra = work; /* dummy value--not used */
|
|
4802
|
-
|
|
4533
|
+
end = 19;
|
|
4803
4534
|
|
|
4804
4535
|
} else if (type === LENS$1) {
|
|
4805
4536
|
base = lbase;
|
|
4537
|
+
base_index -= 257;
|
|
4806
4538
|
extra = lext;
|
|
4807
|
-
|
|
4539
|
+
extra_index -= 257;
|
|
4540
|
+
end = 256;
|
|
4808
4541
|
|
|
4809
4542
|
} else { /* DISTS */
|
|
4810
4543
|
base = dbase;
|
|
4811
4544
|
extra = dext;
|
|
4812
|
-
|
|
4545
|
+
end = -1;
|
|
4813
4546
|
}
|
|
4814
4547
|
|
|
4815
4548
|
/* initialize opts for loop */
|
|
@@ -4833,13 +4566,13 @@ const inflate_table = (type, lens, lens_index, codes, table, table_index, work,
|
|
|
4833
4566
|
for (;;) {
|
|
4834
4567
|
/* create table entry */
|
|
4835
4568
|
here_bits = len - drop;
|
|
4836
|
-
if (work[sym]
|
|
4569
|
+
if (work[sym] < end) {
|
|
4837
4570
|
here_op = 0;
|
|
4838
4571
|
here_val = work[sym];
|
|
4839
4572
|
}
|
|
4840
|
-
else if (work[sym]
|
|
4841
|
-
here_op = extra[work[sym]
|
|
4842
|
-
here_val = base[work[sym]
|
|
4573
|
+
else if (work[sym] > end) {
|
|
4574
|
+
here_op = extra[extra_index + work[sym]];
|
|
4575
|
+
here_val = base[base_index + work[sym]];
|
|
4843
4576
|
}
|
|
4844
4577
|
else {
|
|
4845
4578
|
here_op = 32 + 64; /* end of block */
|
|
@@ -4971,38 +4704,38 @@ const {
|
|
|
4971
4704
|
/* ===========================================================================*/
|
|
4972
4705
|
|
|
4973
4706
|
|
|
4974
|
-
const HEAD =
|
|
4975
|
-
const FLAGS =
|
|
4976
|
-
const TIME =
|
|
4977
|
-
const OS =
|
|
4978
|
-
const EXLEN =
|
|
4979
|
-
const EXTRA =
|
|
4980
|
-
const NAME =
|
|
4981
|
-
const COMMENT =
|
|
4982
|
-
const HCRC =
|
|
4983
|
-
const DICTID =
|
|
4984
|
-
const DICT =
|
|
4985
|
-
const TYPE =
|
|
4986
|
-
const TYPEDO =
|
|
4987
|
-
const STORED =
|
|
4988
|
-
const COPY_ =
|
|
4989
|
-
const COPY =
|
|
4990
|
-
const TABLE =
|
|
4991
|
-
const LENLENS =
|
|
4992
|
-
const CODELENS =
|
|
4993
|
-
const LEN_ =
|
|
4994
|
-
const LEN =
|
|
4995
|
-
const LENEXT =
|
|
4996
|
-
const DIST =
|
|
4997
|
-
const DISTEXT =
|
|
4998
|
-
const MATCH =
|
|
4999
|
-
const LIT =
|
|
5000
|
-
const CHECK =
|
|
5001
|
-
const LENGTH =
|
|
5002
|
-
const DONE =
|
|
5003
|
-
const BAD =
|
|
5004
|
-
const MEM =
|
|
5005
|
-
const SYNC =
|
|
4707
|
+
const HEAD = 1; /* i: waiting for magic header */
|
|
4708
|
+
const FLAGS = 2; /* i: waiting for method and flags (gzip) */
|
|
4709
|
+
const TIME = 3; /* i: waiting for modification time (gzip) */
|
|
4710
|
+
const OS = 4; /* i: waiting for extra flags and operating system (gzip) */
|
|
4711
|
+
const EXLEN = 5; /* i: waiting for extra length (gzip) */
|
|
4712
|
+
const EXTRA = 6; /* i: waiting for extra bytes (gzip) */
|
|
4713
|
+
const NAME = 7; /* i: waiting for end of file name (gzip) */
|
|
4714
|
+
const COMMENT = 8; /* i: waiting for end of comment (gzip) */
|
|
4715
|
+
const HCRC = 9; /* i: waiting for header crc (gzip) */
|
|
4716
|
+
const DICTID = 10; /* i: waiting for dictionary check value */
|
|
4717
|
+
const DICT = 11; /* waiting for inflateSetDictionary() call */
|
|
4718
|
+
const TYPE = 12; /* i: waiting for type bits, including last-flag bit */
|
|
4719
|
+
const TYPEDO = 13; /* i: same, but skip check to exit inflate on new block */
|
|
4720
|
+
const STORED = 14; /* i: waiting for stored size (length and complement) */
|
|
4721
|
+
const COPY_ = 15; /* i/o: same as COPY below, but only first time in */
|
|
4722
|
+
const COPY = 16; /* i/o: waiting for input or output to copy stored block */
|
|
4723
|
+
const TABLE = 17; /* i: waiting for dynamic block table lengths */
|
|
4724
|
+
const LENLENS = 18; /* i: waiting for code length code lengths */
|
|
4725
|
+
const CODELENS = 19; /* i: waiting for length/lit and distance code lengths */
|
|
4726
|
+
const LEN_ = 20; /* i: same as LEN below, but only first time in */
|
|
4727
|
+
const LEN = 21; /* i: waiting for length/lit/eob code */
|
|
4728
|
+
const LENEXT = 22; /* i: waiting for length extra bits */
|
|
4729
|
+
const DIST = 23; /* i: waiting for distance code */
|
|
4730
|
+
const DISTEXT = 24; /* i: waiting for distance extra bits */
|
|
4731
|
+
const MATCH = 25; /* o: waiting for output space to copy string */
|
|
4732
|
+
const LIT = 26; /* o: waiting for output space to write literal */
|
|
4733
|
+
const CHECK = 27; /* i: waiting for 32-bit check value */
|
|
4734
|
+
const LENGTH = 28; /* i: waiting for 32-bit length (gzip) */
|
|
4735
|
+
const DONE = 29; /* finished check, done -- remain here until reset */
|
|
4736
|
+
const BAD = 30; /* got a data error -- remain here until reset */
|
|
4737
|
+
const MEM = 31; /* got an inflate() memory error -- remain here until reset */
|
|
4738
|
+
const SYNC = 32; /* looking for synchronization bytes to restart inflate() */
|
|
5006
4739
|
|
|
5007
4740
|
/* ===========================================================================*/
|
|
5008
4741
|
|
|
@@ -5027,14 +4760,11 @@ const zswap32 = (q) => {
|
|
|
5027
4760
|
|
|
5028
4761
|
|
|
5029
4762
|
function InflateState() {
|
|
5030
|
-
this.
|
|
5031
|
-
this.mode = 0; /* current inflate mode */
|
|
4763
|
+
this.mode = 0; /* current inflate mode */
|
|
5032
4764
|
this.last = false; /* true if processing last block */
|
|
5033
|
-
this.wrap = 0; /* bit 0 true for zlib, bit 1 true for gzip
|
|
5034
|
-
bit 2 true to validate check value */
|
|
4765
|
+
this.wrap = 0; /* bit 0 true for zlib, bit 1 true for gzip */
|
|
5035
4766
|
this.havedict = false; /* true if dictionary provided */
|
|
5036
|
-
this.flags = 0; /* gzip header method and flags (0 if zlib)
|
|
5037
|
-
-1 if raw or no header yet */
|
|
4767
|
+
this.flags = 0; /* gzip header method and flags (0 if zlib) */
|
|
5038
4768
|
this.dmax = 0; /* zlib header max distance (INFLATE_STRICT) */
|
|
5039
4769
|
this.check = 0; /* protected copy of check value */
|
|
5040
4770
|
this.total = 0; /* protected copy of output count */
|
|
@@ -5088,23 +4818,9 @@ function InflateState() {
|
|
|
5088
4818
|
}
|
|
5089
4819
|
|
|
5090
4820
|
|
|
5091
|
-
const inflateStateCheck = (strm) => {
|
|
5092
|
-
|
|
5093
|
-
if (!strm) {
|
|
5094
|
-
return 1;
|
|
5095
|
-
}
|
|
5096
|
-
const state = strm.state;
|
|
5097
|
-
if (!state || state.strm !== strm ||
|
|
5098
|
-
state.mode < HEAD || state.mode > SYNC) {
|
|
5099
|
-
return 1;
|
|
5100
|
-
}
|
|
5101
|
-
return 0;
|
|
5102
|
-
};
|
|
5103
|
-
|
|
5104
|
-
|
|
5105
4821
|
const inflateResetKeep = (strm) => {
|
|
5106
4822
|
|
|
5107
|
-
if (
|
|
4823
|
+
if (!strm || !strm.state) { return Z_STREAM_ERROR$1; }
|
|
5108
4824
|
const state = strm.state;
|
|
5109
4825
|
strm.total_in = strm.total_out = state.total = 0;
|
|
5110
4826
|
strm.msg = ''; /*Z_NULL*/
|
|
@@ -5114,7 +4830,6 @@ const inflateResetKeep = (strm) => {
|
|
|
5114
4830
|
state.mode = HEAD;
|
|
5115
4831
|
state.last = 0;
|
|
5116
4832
|
state.havedict = 0;
|
|
5117
|
-
state.flags = -1;
|
|
5118
4833
|
state.dmax = 32768;
|
|
5119
4834
|
state.head = null/*Z_NULL*/;
|
|
5120
4835
|
state.hold = 0;
|
|
@@ -5132,7 +4847,7 @@ const inflateResetKeep = (strm) => {
|
|
|
5132
4847
|
|
|
5133
4848
|
const inflateReset = (strm) => {
|
|
5134
4849
|
|
|
5135
|
-
if (
|
|
4850
|
+
if (!strm || !strm.state) { return Z_STREAM_ERROR$1; }
|
|
5136
4851
|
const state = strm.state;
|
|
5137
4852
|
state.wsize = 0;
|
|
5138
4853
|
state.whave = 0;
|
|
@@ -5146,7 +4861,7 @@ const inflateReset2 = (strm, windowBits) => {
|
|
|
5146
4861
|
let wrap;
|
|
5147
4862
|
|
|
5148
4863
|
/* get the state */
|
|
5149
|
-
if (
|
|
4864
|
+
if (!strm || !strm.state) { return Z_STREAM_ERROR$1; }
|
|
5150
4865
|
const state = strm.state;
|
|
5151
4866
|
|
|
5152
4867
|
/* extract wrap request from windowBits parameter */
|
|
@@ -5155,7 +4870,7 @@ const inflateReset2 = (strm, windowBits) => {
|
|
|
5155
4870
|
windowBits = -windowBits;
|
|
5156
4871
|
}
|
|
5157
4872
|
else {
|
|
5158
|
-
wrap = (windowBits >> 4) +
|
|
4873
|
+
wrap = (windowBits >> 4) + 1;
|
|
5159
4874
|
if (windowBits < 48) {
|
|
5160
4875
|
windowBits &= 15;
|
|
5161
4876
|
}
|
|
@@ -5186,9 +4901,7 @@ const inflateInit2 = (strm, windowBits) => {
|
|
|
5186
4901
|
//if (state === Z_NULL) return Z_MEM_ERROR;
|
|
5187
4902
|
//Tracev((stderr, "inflate: allocated\n"));
|
|
5188
4903
|
strm.state = state;
|
|
5189
|
-
state.strm = strm;
|
|
5190
4904
|
state.window = null/*Z_NULL*/;
|
|
5191
|
-
state.mode = HEAD; /* to pass state test in inflateReset2() */
|
|
5192
4905
|
const ret = inflateReset2(strm, windowBits);
|
|
5193
4906
|
if (ret !== Z_OK$1) {
|
|
5194
4907
|
strm.state = null/*Z_NULL*/;
|
|
@@ -5337,7 +5050,7 @@ const inflate$2 = (strm, flush) => {
|
|
|
5337
5050
|
new Uint8Array([ 16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15 ]);
|
|
5338
5051
|
|
|
5339
5052
|
|
|
5340
|
-
if (
|
|
5053
|
+
if (!strm || !strm.state || !strm.output ||
|
|
5341
5054
|
(!strm.input && strm.avail_in !== 0)) {
|
|
5342
5055
|
return Z_STREAM_ERROR$1;
|
|
5343
5056
|
}
|
|
@@ -5378,9 +5091,6 @@ const inflate$2 = (strm, flush) => {
|
|
|
5378
5091
|
}
|
|
5379
5092
|
//===//
|
|
5380
5093
|
if ((state.wrap & 2) && hold === 0x8b1f) { /* gzip header */
|
|
5381
|
-
if (state.wbits === 0) {
|
|
5382
|
-
state.wbits = 15;
|
|
5383
|
-
}
|
|
5384
5094
|
state.check = 0/*crc32(0L, Z_NULL, 0)*/;
|
|
5385
5095
|
//=== CRC2(state.check, hold);
|
|
5386
5096
|
hbuf[0] = hold & 0xff;
|
|
@@ -5395,6 +5105,7 @@ const inflate$2 = (strm, flush) => {
|
|
|
5395
5105
|
state.mode = FLAGS;
|
|
5396
5106
|
break;
|
|
5397
5107
|
}
|
|
5108
|
+
state.flags = 0; /* expect zlib header */
|
|
5398
5109
|
if (state.head) {
|
|
5399
5110
|
state.head.done = false;
|
|
5400
5111
|
}
|
|
@@ -5417,7 +5128,7 @@ const inflate$2 = (strm, flush) => {
|
|
|
5417
5128
|
if (state.wbits === 0) {
|
|
5418
5129
|
state.wbits = len;
|
|
5419
5130
|
}
|
|
5420
|
-
if (len >
|
|
5131
|
+
else if (len > state.wbits) {
|
|
5421
5132
|
strm.msg = 'invalid window size';
|
|
5422
5133
|
state.mode = BAD;
|
|
5423
5134
|
break;
|
|
@@ -5428,7 +5139,6 @@ const inflate$2 = (strm, flush) => {
|
|
|
5428
5139
|
state.dmax = 1 << state.wbits;
|
|
5429
5140
|
//state.dmax = 1 << len;
|
|
5430
5141
|
|
|
5431
|
-
state.flags = 0; /* indicate zlib header */
|
|
5432
5142
|
//Tracev((stderr, "inflate: zlib header ok\n"));
|
|
5433
5143
|
strm.adler = state.check = 1/*adler32(0L, Z_NULL, 0)*/;
|
|
5434
5144
|
state.mode = hold & 0x200 ? DICTID : TYPE;
|
|
@@ -5460,7 +5170,7 @@ const inflate$2 = (strm, flush) => {
|
|
|
5460
5170
|
if (state.head) {
|
|
5461
5171
|
state.head.text = ((hold >> 8) & 1);
|
|
5462
5172
|
}
|
|
5463
|
-
if (
|
|
5173
|
+
if (state.flags & 0x0200) {
|
|
5464
5174
|
//=== CRC2(state.check, hold);
|
|
5465
5175
|
hbuf[0] = hold & 0xff;
|
|
5466
5176
|
hbuf[1] = (hold >>> 8) & 0xff;
|
|
@@ -5485,7 +5195,7 @@ const inflate$2 = (strm, flush) => {
|
|
|
5485
5195
|
if (state.head) {
|
|
5486
5196
|
state.head.time = hold;
|
|
5487
5197
|
}
|
|
5488
|
-
if (
|
|
5198
|
+
if (state.flags & 0x0200) {
|
|
5489
5199
|
//=== CRC4(state.check, hold)
|
|
5490
5200
|
hbuf[0] = hold & 0xff;
|
|
5491
5201
|
hbuf[1] = (hold >>> 8) & 0xff;
|
|
@@ -5513,7 +5223,7 @@ const inflate$2 = (strm, flush) => {
|
|
|
5513
5223
|
state.head.xflags = (hold & 0xff);
|
|
5514
5224
|
state.head.os = (hold >> 8);
|
|
5515
5225
|
}
|
|
5516
|
-
if (
|
|
5226
|
+
if (state.flags & 0x0200) {
|
|
5517
5227
|
//=== CRC2(state.check, hold);
|
|
5518
5228
|
hbuf[0] = hold & 0xff;
|
|
5519
5229
|
hbuf[1] = (hold >>> 8) & 0xff;
|
|
@@ -5540,7 +5250,7 @@ const inflate$2 = (strm, flush) => {
|
|
|
5540
5250
|
if (state.head) {
|
|
5541
5251
|
state.head.extra_len = hold;
|
|
5542
5252
|
}
|
|
5543
|
-
if (
|
|
5253
|
+
if (state.flags & 0x0200) {
|
|
5544
5254
|
//=== CRC2(state.check, hold);
|
|
5545
5255
|
hbuf[0] = hold & 0xff;
|
|
5546
5256
|
hbuf[1] = (hold >>> 8) & 0xff;
|
|
@@ -5582,7 +5292,7 @@ const inflate$2 = (strm, flush) => {
|
|
|
5582
5292
|
// len + copy > state.head.extra_max ?
|
|
5583
5293
|
// state.head.extra_max - len : copy);
|
|
5584
5294
|
}
|
|
5585
|
-
if (
|
|
5295
|
+
if (state.flags & 0x0200) {
|
|
5586
5296
|
state.check = crc32_1(state.check, input, copy, next);
|
|
5587
5297
|
}
|
|
5588
5298
|
have -= copy;
|
|
@@ -5608,7 +5318,7 @@ const inflate$2 = (strm, flush) => {
|
|
|
5608
5318
|
}
|
|
5609
5319
|
} while (len && copy < have);
|
|
5610
5320
|
|
|
5611
|
-
if (
|
|
5321
|
+
if (state.flags & 0x0200) {
|
|
5612
5322
|
state.check = crc32_1(state.check, input, copy, next);
|
|
5613
5323
|
}
|
|
5614
5324
|
have -= copy;
|
|
@@ -5633,7 +5343,7 @@ const inflate$2 = (strm, flush) => {
|
|
|
5633
5343
|
state.head.comment += String.fromCharCode(len);
|
|
5634
5344
|
}
|
|
5635
5345
|
} while (len && copy < have);
|
|
5636
|
-
if (
|
|
5346
|
+
if (state.flags & 0x0200) {
|
|
5637
5347
|
state.check = crc32_1(state.check, input, copy, next);
|
|
5638
5348
|
}
|
|
5639
5349
|
have -= copy;
|
|
@@ -5655,7 +5365,7 @@ const inflate$2 = (strm, flush) => {
|
|
|
5655
5365
|
bits += 8;
|
|
5656
5366
|
}
|
|
5657
5367
|
//===//
|
|
5658
|
-
if (
|
|
5368
|
+
if (hold !== (state.check & 0xffff)) {
|
|
5659
5369
|
strm.msg = 'header crc mismatch';
|
|
5660
5370
|
state.mode = BAD;
|
|
5661
5371
|
break;
|
|
@@ -6308,15 +6018,15 @@ const inflate$2 = (strm, flush) => {
|
|
|
6308
6018
|
_out -= left;
|
|
6309
6019
|
strm.total_out += _out;
|
|
6310
6020
|
state.total += _out;
|
|
6311
|
-
if (
|
|
6021
|
+
if (_out) {
|
|
6312
6022
|
strm.adler = state.check =
|
|
6313
|
-
/*
|
|
6023
|
+
/*UPDATE(state.check, put - _out, _out);*/
|
|
6314
6024
|
(state.flags ? crc32_1(state.check, output, _out, put - _out) : adler32_1(state.check, output, _out, put - _out));
|
|
6315
6025
|
|
|
6316
6026
|
}
|
|
6317
6027
|
_out = left;
|
|
6318
6028
|
// NB: crc32 stored as signed 32-bit int, zswap32 returns signed too
|
|
6319
|
-
if ((state.
|
|
6029
|
+
if ((state.flags ? hold : zswap32(hold)) !== state.check) {
|
|
6320
6030
|
strm.msg = 'incorrect data check';
|
|
6321
6031
|
state.mode = BAD;
|
|
6322
6032
|
break;
|
|
@@ -6339,7 +6049,7 @@ const inflate$2 = (strm, flush) => {
|
|
|
6339
6049
|
bits += 8;
|
|
6340
6050
|
}
|
|
6341
6051
|
//===//
|
|
6342
|
-
if (
|
|
6052
|
+
if (hold !== (state.total & 0xffffffff)) {
|
|
6343
6053
|
strm.msg = 'incorrect length check';
|
|
6344
6054
|
state.mode = BAD;
|
|
6345
6055
|
break;
|
|
@@ -6394,8 +6104,8 @@ const inflate$2 = (strm, flush) => {
|
|
|
6394
6104
|
strm.total_in += _in;
|
|
6395
6105
|
strm.total_out += _out;
|
|
6396
6106
|
state.total += _out;
|
|
6397
|
-
if (
|
|
6398
|
-
strm.adler = state.check = /*
|
|
6107
|
+
if (state.wrap && _out) {
|
|
6108
|
+
strm.adler = state.check = /*UPDATE(state.check, strm.next_out - _out, _out);*/
|
|
6399
6109
|
(state.flags ? crc32_1(state.check, output, _out, strm.next_out - _out) : adler32_1(state.check, output, _out, strm.next_out - _out));
|
|
6400
6110
|
}
|
|
6401
6111
|
strm.data_type = state.bits + (state.last ? 64 : 0) +
|
|
@@ -6410,7 +6120,7 @@ const inflate$2 = (strm, flush) => {
|
|
|
6410
6120
|
|
|
6411
6121
|
const inflateEnd = (strm) => {
|
|
6412
6122
|
|
|
6413
|
-
if (
|
|
6123
|
+
if (!strm || !strm.state /*|| strm->zfree == (free_func)0*/) {
|
|
6414
6124
|
return Z_STREAM_ERROR$1;
|
|
6415
6125
|
}
|
|
6416
6126
|
|
|
@@ -6426,7 +6136,7 @@ const inflateEnd = (strm) => {
|
|
|
6426
6136
|
const inflateGetHeader = (strm, head) => {
|
|
6427
6137
|
|
|
6428
6138
|
/* check state */
|
|
6429
|
-
if (
|
|
6139
|
+
if (!strm || !strm.state) { return Z_STREAM_ERROR$1; }
|
|
6430
6140
|
const state = strm.state;
|
|
6431
6141
|
if ((state.wrap & 2) === 0) { return Z_STREAM_ERROR$1; }
|
|
6432
6142
|
|
|
@@ -6445,7 +6155,7 @@ const inflateSetDictionary = (strm, dictionary) => {
|
|
|
6445
6155
|
let ret;
|
|
6446
6156
|
|
|
6447
6157
|
/* check state */
|
|
6448
|
-
if (
|
|
6158
|
+
if (!strm /* == Z_NULL */ || !strm.state /* == Z_NULL */) { return Z_STREAM_ERROR$1; }
|
|
6449
6159
|
state = strm.state;
|
|
6450
6160
|
|
|
6451
6161
|
if (state.wrap !== 0 && state.mode !== DICT) {
|
|
@@ -6486,7 +6196,6 @@ var inflateSetDictionary_1 = inflateSetDictionary;
|
|
|
6486
6196
|
var inflateInfo = 'pako inflate (from Nodeca project)';
|
|
6487
6197
|
|
|
6488
6198
|
/* Not implemented
|
|
6489
|
-
module.exports.inflateCodesUsed = inflateCodesUsed;
|
|
6490
6199
|
module.exports.inflateCopy = inflateCopy;
|
|
6491
6200
|
module.exports.inflateGetDictionary = inflateGetDictionary;
|
|
6492
6201
|
module.exports.inflateMark = inflateMark;
|
|
@@ -6494,7 +6203,6 @@ module.exports.inflatePrime = inflatePrime;
|
|
|
6494
6203
|
module.exports.inflateSync = inflateSync;
|
|
6495
6204
|
module.exports.inflateSyncPoint = inflateSyncPoint;
|
|
6496
6205
|
module.exports.inflateUndermine = inflateUndermine;
|
|
6497
|
-
module.exports.inflateValidate = inflateValidate;
|
|
6498
6206
|
*/
|
|
6499
6207
|
|
|
6500
6208
|
var inflate_1$2 = {
|
|
@@ -6897,7 +6605,7 @@ Inflate$1.prototype.onEnd = function (status) {
|
|
|
6897
6605
|
|
|
6898
6606
|
/**
|
|
6899
6607
|
* inflate(data[, options]) -> Uint8Array|String
|
|
6900
|
-
* - data (Uint8Array
|
|
6608
|
+
* - data (Uint8Array): input data to decompress.
|
|
6901
6609
|
* - options (Object): zlib inflate options.
|
|
6902
6610
|
*
|
|
6903
6611
|
* Decompress `data` with inflate/ungzip and `options`. Autodetect
|
|
@@ -6948,7 +6656,7 @@ function inflate$1(input, options) {
|
|
|
6948
6656
|
|
|
6949
6657
|
/**
|
|
6950
6658
|
* inflateRaw(data[, options]) -> Uint8Array|String
|
|
6951
|
-
* - data (Uint8Array
|
|
6659
|
+
* - data (Uint8Array): input data to decompress.
|
|
6952
6660
|
* - options (Object): zlib inflate options.
|
|
6953
6661
|
*
|
|
6954
6662
|
* The same as [[inflate]], but creates raw data, without wrapper
|
|
@@ -6963,7 +6671,7 @@ function inflateRaw$1(input, options) {
|
|
|
6963
6671
|
|
|
6964
6672
|
/**
|
|
6965
6673
|
* ungzip(data[, options]) -> Uint8Array|String
|
|
6966
|
-
* - data (Uint8Array
|
|
6674
|
+
* - data (Uint8Array): input data to decompress.
|
|
6967
6675
|
* - options (Object): zlib inflate options.
|
|
6968
6676
|
*
|
|
6969
6677
|
* Just shortcut to [[inflate]], because it autodetects format
|
|
@@ -7016,6 +6724,129 @@ var pako = {
|
|
|
7016
6724
|
|
|
7017
6725
|
|
|
7018
6726
|
|
|
6727
|
+
/***/ }),
|
|
6728
|
+
|
|
6729
|
+
/***/ "b3f7":
|
|
6730
|
+
/***/ (function(module, __webpack_exports__, __webpack_require__) {
|
|
6731
|
+
|
|
6732
|
+
"use strict";
|
|
6733
|
+
|
|
6734
|
+
// EXPORTS
|
|
6735
|
+
__webpack_require__.d(__webpack_exports__, "a", function() { return /* binding */ basedecoder_BaseDecoder; });
|
|
6736
|
+
|
|
6737
|
+
// CONCATENATED MODULE: ./node_modules/geotiff/dist-module/predictor.js
|
|
6738
|
+
function decodeRowAcc(row, stride) {
|
|
6739
|
+
let length = row.length - stride;
|
|
6740
|
+
let offset = 0;
|
|
6741
|
+
do {
|
|
6742
|
+
for (let i = stride; i > 0; i--) {
|
|
6743
|
+
row[offset + stride] += row[offset];
|
|
6744
|
+
offset++;
|
|
6745
|
+
}
|
|
6746
|
+
|
|
6747
|
+
length -= stride;
|
|
6748
|
+
} while (length > 0);
|
|
6749
|
+
}
|
|
6750
|
+
|
|
6751
|
+
function decodeRowFloatingPoint(row, stride, bytesPerSample) {
|
|
6752
|
+
let index = 0;
|
|
6753
|
+
let count = row.length;
|
|
6754
|
+
const wc = count / bytesPerSample;
|
|
6755
|
+
|
|
6756
|
+
while (count > stride) {
|
|
6757
|
+
for (let i = stride; i > 0; --i) {
|
|
6758
|
+
row[index + stride] += row[index];
|
|
6759
|
+
++index;
|
|
6760
|
+
}
|
|
6761
|
+
count -= stride;
|
|
6762
|
+
}
|
|
6763
|
+
|
|
6764
|
+
const copy = row.slice();
|
|
6765
|
+
for (let i = 0; i < wc; ++i) {
|
|
6766
|
+
for (let b = 0; b < bytesPerSample; ++b) {
|
|
6767
|
+
row[(bytesPerSample * i) + b] = copy[((bytesPerSample - b - 1) * wc) + i];
|
|
6768
|
+
}
|
|
6769
|
+
}
|
|
6770
|
+
}
|
|
6771
|
+
|
|
6772
|
+
function applyPredictor(block, predictor, width, height, bitsPerSample,
|
|
6773
|
+
planarConfiguration) {
|
|
6774
|
+
if (!predictor || predictor === 1) {
|
|
6775
|
+
return block;
|
|
6776
|
+
}
|
|
6777
|
+
|
|
6778
|
+
for (let i = 0; i < bitsPerSample.length; ++i) {
|
|
6779
|
+
if (bitsPerSample[i] % 8 !== 0) {
|
|
6780
|
+
throw new Error('When decoding with predictor, only multiple of 8 bits are supported.');
|
|
6781
|
+
}
|
|
6782
|
+
if (bitsPerSample[i] !== bitsPerSample[0]) {
|
|
6783
|
+
throw new Error('When decoding with predictor, all samples must have the same size.');
|
|
6784
|
+
}
|
|
6785
|
+
}
|
|
6786
|
+
|
|
6787
|
+
const bytesPerSample = bitsPerSample[0] / 8;
|
|
6788
|
+
const stride = planarConfiguration === 2 ? 1 : bitsPerSample.length;
|
|
6789
|
+
|
|
6790
|
+
for (let i = 0; i < height; ++i) {
|
|
6791
|
+
// Last strip will be truncated if height % stripHeight != 0
|
|
6792
|
+
if (i * stride * width * bytesPerSample >= block.byteLength) {
|
|
6793
|
+
break;
|
|
6794
|
+
}
|
|
6795
|
+
let row;
|
|
6796
|
+
if (predictor === 2) { // horizontal prediction
|
|
6797
|
+
switch (bitsPerSample[0]) {
|
|
6798
|
+
case 8:
|
|
6799
|
+
row = new Uint8Array(
|
|
6800
|
+
block, i * stride * width * bytesPerSample, stride * width * bytesPerSample,
|
|
6801
|
+
);
|
|
6802
|
+
break;
|
|
6803
|
+
case 16:
|
|
6804
|
+
row = new Uint16Array(
|
|
6805
|
+
block, i * stride * width * bytesPerSample, stride * width * bytesPerSample / 2,
|
|
6806
|
+
);
|
|
6807
|
+
break;
|
|
6808
|
+
case 32:
|
|
6809
|
+
row = new Uint32Array(
|
|
6810
|
+
block, i * stride * width * bytesPerSample, stride * width * bytesPerSample / 4,
|
|
6811
|
+
);
|
|
6812
|
+
break;
|
|
6813
|
+
default:
|
|
6814
|
+
throw new Error(`Predictor 2 not allowed with ${bitsPerSample[0]} bits per sample.`);
|
|
6815
|
+
}
|
|
6816
|
+
decodeRowAcc(row, stride, bytesPerSample);
|
|
6817
|
+
} else if (predictor === 3) { // horizontal floating point
|
|
6818
|
+
row = new Uint8Array(
|
|
6819
|
+
block, i * stride * width * bytesPerSample, stride * width * bytesPerSample,
|
|
6820
|
+
);
|
|
6821
|
+
decodeRowFloatingPoint(row, stride, bytesPerSample);
|
|
6822
|
+
}
|
|
6823
|
+
}
|
|
6824
|
+
return block;
|
|
6825
|
+
}
|
|
6826
|
+
|
|
6827
|
+
// CONCATENATED MODULE: ./node_modules/geotiff/dist-module/compression/basedecoder.js
|
|
6828
|
+
|
|
6829
|
+
|
|
6830
|
+
class basedecoder_BaseDecoder {
|
|
6831
|
+
async decode(fileDirectory, buffer) {
|
|
6832
|
+
const decoded = await this.decodeBlock(buffer);
|
|
6833
|
+
const predictor = fileDirectory.Predictor || 1;
|
|
6834
|
+
if (predictor !== 1) {
|
|
6835
|
+
const isTiled = !fileDirectory.StripOffsets;
|
|
6836
|
+
const tileWidth = isTiled ? fileDirectory.TileWidth : fileDirectory.ImageWidth;
|
|
6837
|
+
const tileHeight = isTiled ? fileDirectory.TileLength : (
|
|
6838
|
+
fileDirectory.RowsPerStrip || fileDirectory.ImageLength
|
|
6839
|
+
);
|
|
6840
|
+
return applyPredictor(
|
|
6841
|
+
decoded, predictor, tileWidth, tileHeight, fileDirectory.BitsPerSample,
|
|
6842
|
+
fileDirectory.PlanarConfiguration,
|
|
6843
|
+
);
|
|
6844
|
+
}
|
|
6845
|
+
return decoded;
|
|
6846
|
+
}
|
|
6847
|
+
}
|
|
6848
|
+
|
|
6849
|
+
|
|
7019
6850
|
/***/ })
|
|
7020
6851
|
|
|
7021
6852
|
}]);
|