locar-tiler 0.2.0 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -2
- package/dist/locar-tiler.d.ts +40 -3
- package/dist/locar-tiler.mjs +439 -422
- package/dist/locar-tiler.umd.js +1 -1
- package/package.json +1 -1
package/dist/locar-tiler.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
class
|
|
1
|
+
class N {
|
|
2
2
|
static EARTH = 4007501668e-2;
|
|
3
3
|
static HALF_EARTH = 2003750834e-2;
|
|
4
4
|
}
|
|
@@ -13,15 +13,15 @@ class q {
|
|
|
13
13
|
* @param {number} y - the y coordinate of the tile.
|
|
14
14
|
* @param {number} z - the zoom of the tile.
|
|
15
15
|
*/
|
|
16
|
-
constructor(e, t,
|
|
17
|
-
this.x = e, this.y = t, this.z =
|
|
16
|
+
constructor(e, t, n) {
|
|
17
|
+
this.x = e, this.y = t, this.z = n;
|
|
18
18
|
}
|
|
19
19
|
/**
|
|
20
20
|
* Get the number of Spherical Mercator "metres" in a given tile.
|
|
21
21
|
* @return {number} the number of Spherical Mercator "metres" in a given tile.
|
|
22
22
|
*/
|
|
23
23
|
getMetresInTile() {
|
|
24
|
-
return
|
|
24
|
+
return N.EARTH / Math.pow(2, this.z);
|
|
25
25
|
}
|
|
26
26
|
/**
|
|
27
27
|
* Get the bottom left coordinate of the tile.
|
|
@@ -29,7 +29,7 @@ class q {
|
|
|
29
29
|
*/
|
|
30
30
|
getBottomLeft() {
|
|
31
31
|
var e = this.getMetresInTile();
|
|
32
|
-
return { e: this.x * e -
|
|
32
|
+
return { e: this.x * e - N.HALF_EARTH, n: N.HALF_EARTH - (this.y + 1) * e };
|
|
33
33
|
}
|
|
34
34
|
/**
|
|
35
35
|
* Get the top right coordinate of the tile.
|
|
@@ -46,6 +46,9 @@ class q {
|
|
|
46
46
|
getIndex() {
|
|
47
47
|
return `${this.z}/${this.x}/${this.y}`;
|
|
48
48
|
}
|
|
49
|
+
toString() {
|
|
50
|
+
return this.getIndex();
|
|
51
|
+
}
|
|
49
52
|
}
|
|
50
53
|
class Ie {
|
|
51
54
|
/**
|
|
@@ -62,20 +65,20 @@ class Ie {
|
|
|
62
65
|
* @return {LonLat} the longitude/latitude.
|
|
63
66
|
*/
|
|
64
67
|
unproject(e) {
|
|
65
|
-
return { lon: this.#
|
|
68
|
+
return { lon: this.#n(e[0]), lat: this.#i(e[1]) };
|
|
66
69
|
}
|
|
67
70
|
#e(e) {
|
|
68
|
-
return e / 180 *
|
|
71
|
+
return e / 180 * N.HALF_EARTH;
|
|
69
72
|
}
|
|
70
73
|
#t(e) {
|
|
71
74
|
var t = Math.log(Math.tan((90 + e) * Math.PI / 360)) / (Math.PI / 180);
|
|
72
|
-
return t *
|
|
75
|
+
return t * N.HALF_EARTH / 180;
|
|
73
76
|
}
|
|
74
|
-
#
|
|
75
|
-
return e /
|
|
77
|
+
#n(e) {
|
|
78
|
+
return e / N.HALF_EARTH * 180;
|
|
76
79
|
}
|
|
77
80
|
#i(e) {
|
|
78
|
-
var t = e /
|
|
81
|
+
var t = e / N.HALF_EARTH * 180;
|
|
79
82
|
return t = 180 / Math.PI * (2 * Math.atan(Math.exp(t * Math.PI / 180)) - Math.PI / 2), t;
|
|
80
83
|
}
|
|
81
84
|
/**
|
|
@@ -84,8 +87,8 @@ class Ie {
|
|
|
84
87
|
* @param {number} z - the zoom level.
|
|
85
88
|
*/
|
|
86
89
|
getTile(e, t) {
|
|
87
|
-
var
|
|
88
|
-
return
|
|
90
|
+
var n = new q(-1, -1, t), a = n.getMetresInTile();
|
|
91
|
+
return n.x = Math.floor((N.HALF_EARTH + e.e) / a), n.y = Math.floor((N.HALF_EARTH - e.n) / a), n;
|
|
89
92
|
}
|
|
90
93
|
/**
|
|
91
94
|
* Obtains a tile from a given lon/lat and zoom.
|
|
@@ -146,13 +149,13 @@ class ie {
|
|
|
146
149
|
*/
|
|
147
150
|
async update(e) {
|
|
148
151
|
const t = [];
|
|
149
|
-
let
|
|
150
|
-
if (
|
|
151
|
-
this.tile =
|
|
152
|
-
const a = [
|
|
152
|
+
let n = null;
|
|
153
|
+
if (n = this.#e(e)) {
|
|
154
|
+
this.tile = n;
|
|
155
|
+
const a = [n.x, n.x - 1, n.x + 1], s = [n.y, n.y - 1, n.y + 1];
|
|
153
156
|
for (let l = 0; l < a.length; l++)
|
|
154
|
-
for (let h = 0; h <
|
|
155
|
-
const d = new q(a[l],
|
|
157
|
+
for (let h = 0; h < s.length; h++) {
|
|
158
|
+
const d = new q(a[l], s[h], n.z), r = await this.#t(d);
|
|
156
159
|
r !== null && t.push({ data: r.data, tile: d });
|
|
157
160
|
}
|
|
158
161
|
}
|
|
@@ -171,10 +174,10 @@ class ie {
|
|
|
171
174
|
* @return {DataTile[]} array of 9 tiles, including the current tile and the 8 surrounding it.
|
|
172
175
|
*/
|
|
173
176
|
getCurrentTiles() {
|
|
174
|
-
const e = [], t = [this.tile.x, this.tile.x - 1, this.tile.x + 1],
|
|
177
|
+
const e = [], t = [this.tile.x, this.tile.x - 1, this.tile.x + 1], n = [this.tile.y, this.tile.y - 1, this.tile.y + 1];
|
|
175
178
|
for (let a = 0; a < t.length; a++)
|
|
176
|
-
for (let
|
|
177
|
-
const l = new q(t[a], s
|
|
179
|
+
for (let s = 0; s < n.length; s++) {
|
|
180
|
+
const l = new q(t[a], n[s], this.tile.z), h = this.dataTiles.get(l.getIndex());
|
|
178
181
|
h !== null && e.push({ data: h, tile: l });
|
|
179
182
|
}
|
|
180
183
|
return e;
|
|
@@ -188,11 +191,11 @@ class ie {
|
|
|
188
191
|
}
|
|
189
192
|
async #t(e) {
|
|
190
193
|
const t = e.getIndex();
|
|
191
|
-
if (this.dataTiles
|
|
192
|
-
const
|
|
194
|
+
if (this.dataTiles.get(t) === void 0) {
|
|
195
|
+
const n = await this.readTile(
|
|
193
196
|
this.url.replace("{x}", e.x.toString()).replace("{y}", e.y.toString()).replace("{z}", e.z.toString())
|
|
194
197
|
);
|
|
195
|
-
return this.dataTiles
|
|
198
|
+
return this.dataTiles.set(t, this.rawTileToStoredTile(e, n)), this.dataTiles.get(t);
|
|
196
199
|
}
|
|
197
200
|
return null;
|
|
198
201
|
}
|
|
@@ -204,8 +207,8 @@ class ie {
|
|
|
204
207
|
*/
|
|
205
208
|
async getData(e, t = 13) {
|
|
206
209
|
await this.update(e);
|
|
207
|
-
const
|
|
208
|
-
return this.dataTiles
|
|
210
|
+
const n = this.sphMerc.getTile(e, t);
|
|
211
|
+
return this.dataTiles.get(`${t}/${n.x}/${n.y}`);
|
|
209
212
|
}
|
|
210
213
|
/**
|
|
211
214
|
* Converts the raw data from the server to a custom type of data.
|
|
@@ -222,10 +225,10 @@ function bt(i, e = "utf8") {
|
|
|
222
225
|
return new TextDecoder(e).decode(i);
|
|
223
226
|
}
|
|
224
227
|
const Oe = new TextEncoder();
|
|
225
|
-
function
|
|
228
|
+
function Se(i) {
|
|
226
229
|
return Oe.encode(i);
|
|
227
230
|
}
|
|
228
|
-
const
|
|
231
|
+
const Re = 1024 * 8, Ce = (() => {
|
|
229
232
|
const i = new Uint8Array(4), e = new Uint32Array(i.buffer);
|
|
230
233
|
return !((e[0] = 1) & i[0]);
|
|
231
234
|
})(), et = {
|
|
@@ -276,12 +279,12 @@ class wt {
|
|
|
276
279
|
* @param options - An object for the options.
|
|
277
280
|
* @returns A new IOBuffer instance.
|
|
278
281
|
*/
|
|
279
|
-
constructor(e =
|
|
280
|
-
let
|
|
281
|
-
typeof e == "number" ? e = new ArrayBuffer(e) : (
|
|
282
|
-
const a = t.offset ? t.offset >>> 0 : 0,
|
|
282
|
+
constructor(e = Re, t = {}) {
|
|
283
|
+
let n = !1;
|
|
284
|
+
typeof e == "number" ? e = new ArrayBuffer(e) : (n = !0, this.lastWrittenByte = e.byteLength);
|
|
285
|
+
const a = t.offset ? t.offset >>> 0 : 0, s = e.byteLength - a;
|
|
283
286
|
let l = a;
|
|
284
|
-
(ArrayBuffer.isView(e) || e instanceof wt) && (e.byteLength !== e.buffer.byteLength && (l = e.byteOffset + a), e = e.buffer),
|
|
287
|
+
(ArrayBuffer.isView(e) || e instanceof wt) && (e.byteLength !== e.buffer.byteLength && (l = e.byteOffset + a), e = e.buffer), n ? this.lastWrittenByte = s : this.lastWrittenByte = 0, this.buffer = e, this.length = s, this.byteLength = s, this.byteOffset = l, this.offset = 0, this.littleEndian = !0, this._data = new DataView(this.buffer, l, s), this._mark = 0, this._marks = [];
|
|
285
288
|
}
|
|
286
289
|
/**
|
|
287
290
|
* Checks if the memory allocated to the buffer is sufficient to store more
|
|
@@ -398,8 +401,8 @@ class wt {
|
|
|
398
401
|
*/
|
|
399
402
|
ensureAvailable(e = 1) {
|
|
400
403
|
if (!this.available(e)) {
|
|
401
|
-
const
|
|
402
|
-
a.set(new Uint8Array(this.buffer)), this.buffer = a.buffer, this.length =
|
|
404
|
+
const n = (this.offset + e) * 2, a = new Uint8Array(n);
|
|
405
|
+
a.set(new Uint8Array(this.buffer)), this.buffer = a.buffer, this.length = n, this.byteLength = n, this._data = new DataView(this.buffer);
|
|
403
406
|
}
|
|
404
407
|
return this;
|
|
405
408
|
}
|
|
@@ -448,15 +451,15 @@ class wt {
|
|
|
448
451
|
* @returns The read array.
|
|
449
452
|
*/
|
|
450
453
|
readArray(e, t) {
|
|
451
|
-
const
|
|
452
|
-
if (this.littleEndian ===
|
|
453
|
-
const h = new Uint8Array(this.buffer.slice(a, a +
|
|
454
|
+
const n = et[t].BYTES_PER_ELEMENT * e, a = this.byteOffset + this.offset, s = this.buffer.slice(a, a + n);
|
|
455
|
+
if (this.littleEndian === Ce && t !== "uint8" && t !== "int8") {
|
|
456
|
+
const h = new Uint8Array(this.buffer.slice(a, a + n));
|
|
454
457
|
h.reverse();
|
|
455
458
|
const d = new et[t](h.buffer);
|
|
456
|
-
return this.offset +=
|
|
459
|
+
return this.offset += n, d.reverse(), d;
|
|
457
460
|
}
|
|
458
|
-
const l = new et[t](
|
|
459
|
-
return this.offset +=
|
|
461
|
+
const l = new et[t](s);
|
|
462
|
+
return this.offset += n, l;
|
|
460
463
|
}
|
|
461
464
|
/**
|
|
462
465
|
* Read a 16-bit signed integer and move pointer forward by 2 bytes.
|
|
@@ -536,7 +539,7 @@ class wt {
|
|
|
536
539
|
*/
|
|
537
540
|
readChars(e = 1) {
|
|
538
541
|
let t = "";
|
|
539
|
-
for (let
|
|
542
|
+
for (let n = 0; n < e; n++)
|
|
540
543
|
t += this.readChar();
|
|
541
544
|
return t;
|
|
542
545
|
}
|
|
@@ -705,7 +708,7 @@ class wt {
|
|
|
705
708
|
* @returns This.
|
|
706
709
|
*/
|
|
707
710
|
writeUtf8(e) {
|
|
708
|
-
return this.writeBytes(
|
|
711
|
+
return this.writeBytes(Se(e));
|
|
709
712
|
}
|
|
710
713
|
/**
|
|
711
714
|
* Export a Uint8Array view of the internal buffer.
|
|
@@ -736,47 +739,47 @@ function F(i) {
|
|
|
736
739
|
for (; --e >= 0; )
|
|
737
740
|
i[e] = 0;
|
|
738
741
|
}
|
|
739
|
-
const
|
|
742
|
+
const Ne = 3, De = 258, ne = 29, Me = 256, Le = Me + 1 + ne, se = 30, Be = 512, $e = new Array((Le + 2) * 2);
|
|
740
743
|
F($e);
|
|
741
|
-
const Fe = new Array(
|
|
744
|
+
const Fe = new Array(se * 2);
|
|
742
745
|
F(Fe);
|
|
743
746
|
const He = new Array(Be);
|
|
744
747
|
F(He);
|
|
745
|
-
const Ze = new Array(De -
|
|
748
|
+
const Ze = new Array(De - Ne + 1);
|
|
746
749
|
F(Ze);
|
|
747
|
-
const We = new Array(
|
|
750
|
+
const We = new Array(ne);
|
|
748
751
|
F(We);
|
|
749
|
-
const ze = new Array(
|
|
752
|
+
const ze = new Array(se);
|
|
750
753
|
F(ze);
|
|
751
|
-
const Pe = (i, e, t,
|
|
752
|
-
let a = i & 65535 | 0,
|
|
754
|
+
const Pe = (i, e, t, n) => {
|
|
755
|
+
let a = i & 65535 | 0, s = i >>> 16 & 65535 | 0, l = 0;
|
|
753
756
|
for (; t !== 0; ) {
|
|
754
757
|
l = t > 2e3 ? 2e3 : t, t -= l;
|
|
755
758
|
do
|
|
756
|
-
a = a + e[
|
|
759
|
+
a = a + e[n++] | 0, s = s + a | 0;
|
|
757
760
|
while (--l);
|
|
758
|
-
a %= 65521,
|
|
761
|
+
a %= 65521, s %= 65521;
|
|
759
762
|
}
|
|
760
|
-
return a |
|
|
763
|
+
return a | s << 16 | 0;
|
|
761
764
|
};
|
|
762
765
|
var ut = Pe;
|
|
763
766
|
const Ge = () => {
|
|
764
767
|
let i, e = [];
|
|
765
768
|
for (var t = 0; t < 256; t++) {
|
|
766
769
|
i = t;
|
|
767
|
-
for (var
|
|
770
|
+
for (var n = 0; n < 8; n++)
|
|
768
771
|
i = i & 1 ? 3988292384 ^ i >>> 1 : i >>> 1;
|
|
769
772
|
e[t] = i;
|
|
770
773
|
}
|
|
771
774
|
return e;
|
|
772
|
-
},
|
|
773
|
-
const a =
|
|
775
|
+
}, Ke = new Uint32Array(Ge()), Ye = (i, e, t, n) => {
|
|
776
|
+
const a = Ke, s = n + t;
|
|
774
777
|
i ^= -1;
|
|
775
|
-
for (let l =
|
|
778
|
+
for (let l = n; l < s; l++)
|
|
776
779
|
i = i >>> 8 ^ a[(i ^ e[l]) & 255];
|
|
777
780
|
return i ^ -1;
|
|
778
781
|
};
|
|
779
|
-
var
|
|
782
|
+
var R = Ye, _t = {
|
|
780
783
|
2: "need dictionary",
|
|
781
784
|
/* Z_NEED_DICT 2 */
|
|
782
785
|
1: "stream end",
|
|
@@ -823,18 +826,18 @@ var Xe = function(i) {
|
|
|
823
826
|
if (t) {
|
|
824
827
|
if (typeof t != "object")
|
|
825
828
|
throw new TypeError(t + "must be non-object");
|
|
826
|
-
for (const
|
|
827
|
-
je(t,
|
|
829
|
+
for (const n in t)
|
|
830
|
+
je(t, n) && (i[n] = t[n]);
|
|
828
831
|
}
|
|
829
832
|
}
|
|
830
833
|
return i;
|
|
831
834
|
}, Ve = (i) => {
|
|
832
835
|
let e = 0;
|
|
833
|
-
for (let
|
|
834
|
-
e += i[
|
|
836
|
+
for (let n = 0, a = i.length; n < a; n++)
|
|
837
|
+
e += i[n].length;
|
|
835
838
|
const t = new Uint8Array(e);
|
|
836
|
-
for (let
|
|
837
|
-
let l = i[
|
|
839
|
+
for (let n = 0, a = 0, s = i.length; n < s; n++) {
|
|
840
|
+
let l = i[n];
|
|
838
841
|
t.set(l, a), a += l.length;
|
|
839
842
|
}
|
|
840
843
|
return t;
|
|
@@ -855,47 +858,47 @@ Z[254] = Z[254] = 1;
|
|
|
855
858
|
var qe = (i) => {
|
|
856
859
|
if (typeof TextEncoder == "function" && TextEncoder.prototype.encode)
|
|
857
860
|
return new TextEncoder().encode(i);
|
|
858
|
-
let e, t,
|
|
861
|
+
let e, t, n, a, s, l = i.length, h = 0;
|
|
859
862
|
for (a = 0; a < l; a++)
|
|
860
|
-
t = i.charCodeAt(a), (t & 64512) === 55296 && a + 1 < l && (
|
|
861
|
-
for (e = new Uint8Array(h),
|
|
862
|
-
t = i.charCodeAt(a), (t & 64512) === 55296 && a + 1 < l && (
|
|
863
|
+
t = i.charCodeAt(a), (t & 64512) === 55296 && a + 1 < l && (n = i.charCodeAt(a + 1), (n & 64512) === 56320 && (t = 65536 + (t - 55296 << 10) + (n - 56320), a++)), h += t < 128 ? 1 : t < 2048 ? 2 : t < 65536 ? 3 : 4;
|
|
864
|
+
for (e = new Uint8Array(h), s = 0, a = 0; s < h; a++)
|
|
865
|
+
t = i.charCodeAt(a), (t & 64512) === 55296 && a + 1 < l && (n = i.charCodeAt(a + 1), (n & 64512) === 56320 && (t = 65536 + (t - 55296 << 10) + (n - 56320), a++)), t < 128 ? e[s++] = t : t < 2048 ? (e[s++] = 192 | t >>> 6, e[s++] = 128 | t & 63) : t < 65536 ? (e[s++] = 224 | t >>> 12, e[s++] = 128 | t >>> 6 & 63, e[s++] = 128 | t & 63) : (e[s++] = 240 | t >>> 18, e[s++] = 128 | t >>> 12 & 63, e[s++] = 128 | t >>> 6 & 63, e[s++] = 128 | t & 63);
|
|
863
866
|
return e;
|
|
864
867
|
};
|
|
865
868
|
const Je = (i, e) => {
|
|
866
869
|
if (e < 65534 && i.subarray && oe)
|
|
867
870
|
return String.fromCharCode.apply(null, i.length === e ? i : i.subarray(0, e));
|
|
868
871
|
let t = "";
|
|
869
|
-
for (let
|
|
870
|
-
t += String.fromCharCode(i[
|
|
872
|
+
for (let n = 0; n < e; n++)
|
|
873
|
+
t += String.fromCharCode(i[n]);
|
|
871
874
|
return t;
|
|
872
875
|
};
|
|
873
876
|
var Qe = (i, e) => {
|
|
874
877
|
const t = e || i.length;
|
|
875
878
|
if (typeof TextDecoder == "function" && TextDecoder.prototype.decode)
|
|
876
879
|
return new TextDecoder().decode(i.subarray(0, e));
|
|
877
|
-
let
|
|
878
|
-
const
|
|
879
|
-
for (a = 0,
|
|
880
|
-
let l = i[
|
|
880
|
+
let n, a;
|
|
881
|
+
const s = new Array(t * 2);
|
|
882
|
+
for (a = 0, n = 0; n < t; ) {
|
|
883
|
+
let l = i[n++];
|
|
881
884
|
if (l < 128) {
|
|
882
|
-
|
|
885
|
+
s[a++] = l;
|
|
883
886
|
continue;
|
|
884
887
|
}
|
|
885
888
|
let h = Z[l];
|
|
886
889
|
if (h > 4) {
|
|
887
|
-
|
|
890
|
+
s[a++] = 65533, n += h - 1;
|
|
888
891
|
continue;
|
|
889
892
|
}
|
|
890
|
-
for (l &= h === 2 ? 31 : h === 3 ? 15 : 7; h > 1 &&
|
|
891
|
-
l = l << 6 | i[
|
|
893
|
+
for (l &= h === 2 ? 31 : h === 3 ? 15 : 7; h > 1 && n < t; )
|
|
894
|
+
l = l << 6 | i[n++] & 63, h--;
|
|
892
895
|
if (h > 1) {
|
|
893
|
-
|
|
896
|
+
s[a++] = 65533;
|
|
894
897
|
continue;
|
|
895
898
|
}
|
|
896
|
-
l < 65536 ?
|
|
899
|
+
l < 65536 ? s[a++] = l : (l -= 65536, s[a++] = 55296 | l >> 10 & 1023, s[a++] = 56320 | l & 1023);
|
|
897
900
|
}
|
|
898
|
-
return Je(
|
|
901
|
+
return Je(s, a);
|
|
899
902
|
}, ti = (i, e) => {
|
|
900
903
|
e = e || i.length, e > i.length && (e = i.length);
|
|
901
904
|
let t = e - 1;
|
|
@@ -911,76 +914,76 @@ function ei() {
|
|
|
911
914
|
this.input = null, this.next_in = 0, this.avail_in = 0, this.total_in = 0, this.output = null, this.next_out = 0, this.avail_out = 0, this.total_out = 0, this.msg = "", this.state = null, this.data_type = 2, this.adler = 0;
|
|
912
915
|
}
|
|
913
916
|
var ii = ei;
|
|
914
|
-
const
|
|
915
|
-
var
|
|
916
|
-
let
|
|
917
|
-
const
|
|
918
|
-
|
|
917
|
+
const K = 16209, ni = 16191;
|
|
918
|
+
var si = function(e, t) {
|
|
919
|
+
let n, a, s, l, h, d, r, o, w, u, f, _, U, x, g, T, y, c, E, I, p, m, A, b;
|
|
920
|
+
const k = e.state;
|
|
921
|
+
n = e.next_in, A = e.input, a = n + (e.avail_in - 5), s = e.next_out, b = e.output, l = s - (t - e.avail_out), h = s + (e.avail_out - 257), d = k.dmax, r = k.wsize, o = k.whave, w = k.wnext, u = k.window, f = k.hold, _ = k.bits, U = k.lencode, x = k.distcode, g = (1 << k.lenbits) - 1, T = (1 << k.distbits) - 1;
|
|
919
922
|
t:
|
|
920
923
|
do {
|
|
921
|
-
_ < 15 && (f += A[
|
|
924
|
+
_ < 15 && (f += A[n++] << _, _ += 8, f += A[n++] << _, _ += 8), y = U[f & g];
|
|
922
925
|
e:
|
|
923
926
|
for (; ; ) {
|
|
924
927
|
if (c = y >>> 24, f >>>= c, _ -= c, c = y >>> 16 & 255, c === 0)
|
|
925
|
-
b[
|
|
928
|
+
b[s++] = y & 65535;
|
|
926
929
|
else if (c & 16) {
|
|
927
|
-
|
|
930
|
+
E = y & 65535, c &= 15, c && (_ < c && (f += A[n++] << _, _ += 8), E += f & (1 << c) - 1, f >>>= c, _ -= c), _ < 15 && (f += A[n++] << _, _ += 8, f += A[n++] << _, _ += 8), y = x[f & T];
|
|
928
931
|
i:
|
|
929
932
|
for (; ; ) {
|
|
930
933
|
if (c = y >>> 24, f >>>= c, _ -= c, c = y >>> 16 & 255, c & 16) {
|
|
931
|
-
if (I = y & 65535, c &= 15, _ < c && (f += A[
|
|
932
|
-
e.msg = "invalid distance too far back",
|
|
934
|
+
if (I = y & 65535, c &= 15, _ < c && (f += A[n++] << _, _ += 8, _ < c && (f += A[n++] << _, _ += 8)), I += f & (1 << c) - 1, I > d) {
|
|
935
|
+
e.msg = "invalid distance too far back", k.mode = K;
|
|
933
936
|
break t;
|
|
934
937
|
}
|
|
935
|
-
if (f >>>= c, _ -= c, c =
|
|
936
|
-
if (c = I - c, c > o &&
|
|
937
|
-
e.msg = "invalid distance too far back",
|
|
938
|
+
if (f >>>= c, _ -= c, c = s - l, I > c) {
|
|
939
|
+
if (c = I - c, c > o && k.sane) {
|
|
940
|
+
e.msg = "invalid distance too far back", k.mode = K;
|
|
938
941
|
break t;
|
|
939
942
|
}
|
|
940
943
|
if (p = 0, m = u, w === 0) {
|
|
941
|
-
if (p += r - c, c <
|
|
942
|
-
|
|
944
|
+
if (p += r - c, c < E) {
|
|
945
|
+
E -= c;
|
|
943
946
|
do
|
|
944
|
-
b[
|
|
947
|
+
b[s++] = u[p++];
|
|
945
948
|
while (--c);
|
|
946
|
-
p =
|
|
949
|
+
p = s - I, m = b;
|
|
947
950
|
}
|
|
948
951
|
} else if (w < c) {
|
|
949
|
-
if (p += r + w - c, c -= w, c <
|
|
950
|
-
|
|
952
|
+
if (p += r + w - c, c -= w, c < E) {
|
|
953
|
+
E -= c;
|
|
951
954
|
do
|
|
952
|
-
b[
|
|
955
|
+
b[s++] = u[p++];
|
|
953
956
|
while (--c);
|
|
954
|
-
if (p = 0, w <
|
|
955
|
-
c = w,
|
|
957
|
+
if (p = 0, w < E) {
|
|
958
|
+
c = w, E -= c;
|
|
956
959
|
do
|
|
957
|
-
b[
|
|
960
|
+
b[s++] = u[p++];
|
|
958
961
|
while (--c);
|
|
959
|
-
p =
|
|
962
|
+
p = s - I, m = b;
|
|
960
963
|
}
|
|
961
964
|
}
|
|
962
|
-
} else if (p += w - c, c <
|
|
963
|
-
|
|
965
|
+
} else if (p += w - c, c < E) {
|
|
966
|
+
E -= c;
|
|
964
967
|
do
|
|
965
|
-
b[
|
|
968
|
+
b[s++] = u[p++];
|
|
966
969
|
while (--c);
|
|
967
|
-
p =
|
|
970
|
+
p = s - I, m = b;
|
|
968
971
|
}
|
|
969
|
-
for (;
|
|
970
|
-
b[
|
|
971
|
-
|
|
972
|
+
for (; E > 2; )
|
|
973
|
+
b[s++] = m[p++], b[s++] = m[p++], b[s++] = m[p++], E -= 3;
|
|
974
|
+
E && (b[s++] = m[p++], E > 1 && (b[s++] = m[p++]));
|
|
972
975
|
} else {
|
|
973
|
-
p =
|
|
976
|
+
p = s - I;
|
|
974
977
|
do
|
|
975
|
-
b[
|
|
976
|
-
while (
|
|
977
|
-
|
|
978
|
+
b[s++] = b[p++], b[s++] = b[p++], b[s++] = b[p++], E -= 3;
|
|
979
|
+
while (E > 2);
|
|
980
|
+
E && (b[s++] = b[p++], E > 1 && (b[s++] = b[p++]));
|
|
978
981
|
}
|
|
979
982
|
} else if ((c & 64) === 0) {
|
|
980
983
|
y = x[(y & 65535) + (f & (1 << c) - 1)];
|
|
981
984
|
continue i;
|
|
982
985
|
} else {
|
|
983
|
-
e.msg = "invalid distance code",
|
|
986
|
+
e.msg = "invalid distance code", k.mode = K;
|
|
984
987
|
break t;
|
|
985
988
|
}
|
|
986
989
|
break;
|
|
@@ -989,18 +992,18 @@ var ni = function(e, t) {
|
|
|
989
992
|
y = U[(y & 65535) + (f & (1 << c) - 1)];
|
|
990
993
|
continue e;
|
|
991
994
|
} else if (c & 32) {
|
|
992
|
-
|
|
995
|
+
k.mode = ni;
|
|
993
996
|
break t;
|
|
994
997
|
} else {
|
|
995
|
-
e.msg = "invalid literal/length code",
|
|
998
|
+
e.msg = "invalid literal/length code", k.mode = K;
|
|
996
999
|
break t;
|
|
997
1000
|
}
|
|
998
1001
|
break;
|
|
999
1002
|
}
|
|
1000
|
-
} while (
|
|
1001
|
-
|
|
1003
|
+
} while (n < a && s < h);
|
|
1004
|
+
E = _ >> 3, n -= E, _ -= E << 3, f &= (1 << _) - 1, e.next_in = n, e.next_out = s, e.avail_in = n < a ? 5 + (a - n) : 5 - (n - a), e.avail_out = s < h ? 257 + (h - s) : 257 - (s - h), k.hold = f, k.bits = _;
|
|
1002
1005
|
};
|
|
1003
|
-
const $ = 15, xt = 852, yt = 592,
|
|
1006
|
+
const $ = 15, xt = 852, yt = 592, kt = 0, it = 1, Et = 2, ai = new Uint16Array([
|
|
1004
1007
|
/* Length codes 257..285 base */
|
|
1005
1008
|
3,
|
|
1006
1009
|
4,
|
|
@@ -1134,31 +1137,31 @@ const $ = 15, xt = 852, yt = 592, Et = 0, it = 1, kt = 2, ai = new Uint16Array([
|
|
|
1134
1137
|
29,
|
|
1135
1138
|
64,
|
|
1136
1139
|
64
|
|
1137
|
-
]), li = (i, e, t,
|
|
1140
|
+
]), li = (i, e, t, n, a, s, l, h) => {
|
|
1138
1141
|
const d = h.bits;
|
|
1139
|
-
let r = 0, o = 0, w = 0, u = 0, f = 0, _ = 0, U = 0, x = 0, g = 0, T = 0, y, c,
|
|
1140
|
-
const b = new Uint16Array($ + 1),
|
|
1142
|
+
let r = 0, o = 0, w = 0, u = 0, f = 0, _ = 0, U = 0, x = 0, g = 0, T = 0, y, c, E, I, p, m = null, A;
|
|
1143
|
+
const b = new Uint16Array($ + 1), k = new Uint16Array($ + 1);
|
|
1141
1144
|
let M = null, gt, P, G;
|
|
1142
1145
|
for (r = 0; r <= $; r++)
|
|
1143
1146
|
b[r] = 0;
|
|
1144
|
-
for (o = 0; o <
|
|
1147
|
+
for (o = 0; o < n; o++)
|
|
1145
1148
|
b[e[t + o]]++;
|
|
1146
1149
|
for (f = d, u = $; u >= 1 && b[u] === 0; u--)
|
|
1147
1150
|
;
|
|
1148
1151
|
if (f > u && (f = u), u === 0)
|
|
1149
|
-
return a[
|
|
1152
|
+
return a[s++] = 1 << 24 | 64 << 16 | 0, a[s++] = 1 << 24 | 64 << 16 | 0, h.bits = 1, 0;
|
|
1150
1153
|
for (w = 1; w < u && b[w] === 0; w++)
|
|
1151
1154
|
;
|
|
1152
1155
|
for (f < w && (f = w), x = 1, r = 1; r <= $; r++)
|
|
1153
1156
|
if (x <<= 1, x -= b[r], x < 0)
|
|
1154
1157
|
return -1;
|
|
1155
|
-
if (x > 0 && (i ===
|
|
1158
|
+
if (x > 0 && (i === kt || u !== 1))
|
|
1156
1159
|
return -1;
|
|
1157
|
-
for (
|
|
1158
|
-
|
|
1159
|
-
for (o = 0; o <
|
|
1160
|
-
e[t + o] !== 0 && (l[
|
|
1161
|
-
if (i ===
|
|
1160
|
+
for (k[1] = 0, r = 1; r < $; r++)
|
|
1161
|
+
k[r + 1] = k[r] + b[r];
|
|
1162
|
+
for (o = 0; o < n; o++)
|
|
1163
|
+
e[t + o] !== 0 && (l[k[e[t + o]]++] = o);
|
|
1164
|
+
if (i === kt ? (m = M = l, A = 20) : i === it ? (m = ai, M = ri, A = 257) : (m = oi, M = hi, A = 0), T = 0, o = 0, r = w, p = s, _ = f, U = 0, E = -1, g = 1 << f, I = g - 1, i === it && g > xt || i === Et && g > yt)
|
|
1162
1165
|
return 1;
|
|
1163
1166
|
for (; ; ) {
|
|
1164
1167
|
gt = r - U, l[o] + 1 < A ? (P = 0, G = l[o]) : l[o] >= A ? (P = M[l[o] - A], G = m[l[o] - A]) : (P = 96, G = 0), y = 1 << r - U, c = 1 << _, w = c;
|
|
@@ -1172,12 +1175,12 @@ const $ = 15, xt = 852, yt = 592, Et = 0, it = 1, kt = 2, ai = new Uint16Array([
|
|
|
1172
1175
|
break;
|
|
1173
1176
|
r = e[t + l[o]];
|
|
1174
1177
|
}
|
|
1175
|
-
if (r > f && (T & I) !==
|
|
1178
|
+
if (r > f && (T & I) !== E) {
|
|
1176
1179
|
for (U === 0 && (U = f), p += w, _ = r - U, x = 1 << _; _ + U < u && (x -= b[_ + U], !(x <= 0)); )
|
|
1177
1180
|
_++, x <<= 1;
|
|
1178
|
-
if (g += 1 << _, i === it && g > xt || i ===
|
|
1181
|
+
if (g += 1 << _, i === it && g > xt || i === Et && g > yt)
|
|
1179
1182
|
return 1;
|
|
1180
|
-
|
|
1183
|
+
E = T & I, a[E] = f << 24 | _ << 16 | p - s | 0;
|
|
1181
1184
|
}
|
|
1182
1185
|
}
|
|
1183
1186
|
return T !== 0 && (a[p + T] = r - U << 24 | 64 << 16 | 0), h.bits = f, 0;
|
|
@@ -1186,16 +1189,16 @@ var H = li;
|
|
|
1186
1189
|
const fi = 0, he = 1, le = 2, {
|
|
1187
1190
|
Z_FINISH: At,
|
|
1188
1191
|
Z_BLOCK: ci,
|
|
1189
|
-
Z_TREES:
|
|
1192
|
+
Z_TREES: Y,
|
|
1190
1193
|
Z_OK: L,
|
|
1191
1194
|
Z_STREAM_END: di,
|
|
1192
1195
|
Z_NEED_DICT: ui,
|
|
1193
|
-
Z_STREAM_ERROR:
|
|
1196
|
+
Z_STREAM_ERROR: S,
|
|
1194
1197
|
Z_DATA_ERROR: fe,
|
|
1195
1198
|
Z_MEM_ERROR: ce,
|
|
1196
1199
|
Z_BUF_ERROR: _i,
|
|
1197
1200
|
Z_DEFLATED: Tt
|
|
1198
|
-
} = ae, tt = 16180, mt = 16181, vt = 16182, Ut = 16183, It = 16184, Ot = 16185,
|
|
1201
|
+
} = ae, tt = 16180, mt = 16181, vt = 16182, Ut = 16183, It = 16184, Ot = 16185, St = 16186, Rt = 16187, Ct = 16188, Nt = 16189, Q = 16190, C = 16191, nt = 16192, Dt = 16193, st = 16194, Mt = 16195, Lt = 16196, Bt = 16197, $t = 16198, j = 16199, X = 16200, Ft = 16201, Ht = 16202, Zt = 16203, Wt = 16204, zt = 16205, at = 16206, Pt = 16207, Gt = 16208, v = 16209, de = 16210, ue = 16211, pi = 852, wi = 592, gi = 15, bi = gi, Kt = (i) => (i >>> 24 & 255) + (i >>> 8 & 65280) + ((i & 65280) << 8) + ((i & 255) << 24);
|
|
1199
1202
|
function xi() {
|
|
1200
1203
|
this.strm = null, this.mode = 0, this.last = !1, this.wrap = 0, this.havedict = !1, this.flags = 0, this.dmax = 0, this.check = 0, this.total = 0, this.head = null, this.wbits = 0, this.wsize = 0, this.whave = 0, this.wnext = 0, this.window = null, this.hold = 0, this.bits = 0, this.length = 0, this.offset = 0, this.extra = 0, this.lencode = null, this.distcode = null, this.lenbits = 0, this.distbits = 0, this.ncode = 0, this.nlen = 0, this.ndist = 0, this.have = 0, this.next = null, this.lens = new Uint16Array(320), this.work = new Uint16Array(288), this.lendyn = null, this.distdyn = null, this.sane = 0, this.back = 0, this.was = 0;
|
|
1201
1204
|
}
|
|
@@ -1206,31 +1209,31 @@ const B = (i) => {
|
|
|
1206
1209
|
return !e || e.strm !== i || e.mode < tt || e.mode > ue ? 1 : 0;
|
|
1207
1210
|
}, _e = (i) => {
|
|
1208
1211
|
if (B(i))
|
|
1209
|
-
return
|
|
1212
|
+
return S;
|
|
1210
1213
|
const e = i.state;
|
|
1211
1214
|
return i.total_in = i.total_out = e.total = 0, i.msg = "", e.wrap && (i.adler = e.wrap & 1), e.mode = tt, e.last = 0, e.havedict = 0, e.flags = -1, e.dmax = 32768, e.head = null, e.hold = 0, e.bits = 0, e.lencode = e.lendyn = new Int32Array(pi), e.distcode = e.distdyn = new Int32Array(wi), e.sane = 1, e.back = -1, L;
|
|
1212
1215
|
}, pe = (i) => {
|
|
1213
1216
|
if (B(i))
|
|
1214
|
-
return
|
|
1217
|
+
return S;
|
|
1215
1218
|
const e = i.state;
|
|
1216
1219
|
return e.wsize = 0, e.whave = 0, e.wnext = 0, _e(i);
|
|
1217
1220
|
}, we = (i, e) => {
|
|
1218
1221
|
let t;
|
|
1219
1222
|
if (B(i))
|
|
1220
|
-
return
|
|
1221
|
-
const
|
|
1222
|
-
return e < 0 ? (t = 0, e = -e) : (t = (e >> 4) + 5, e < 48 && (e &= 15)), e && (e < 8 || e > 15) ?
|
|
1223
|
+
return S;
|
|
1224
|
+
const n = i.state;
|
|
1225
|
+
return e < 0 ? (t = 0, e = -e) : (t = (e >> 4) + 5, e < 48 && (e &= 15)), e && (e < 8 || e > 15) ? S : (n.window !== null && n.wbits !== e && (n.window = null), n.wrap = t, n.wbits = e, pe(i));
|
|
1223
1226
|
}, ge = (i, e) => {
|
|
1224
1227
|
if (!i)
|
|
1225
|
-
return
|
|
1228
|
+
return S;
|
|
1226
1229
|
const t = new xi();
|
|
1227
1230
|
i.state = t, t.strm = i, t.window = null, t.mode = tt;
|
|
1228
|
-
const
|
|
1229
|
-
return
|
|
1231
|
+
const n = we(i, e);
|
|
1232
|
+
return n !== L && (i.state = null), n;
|
|
1230
1233
|
}, yi = (i) => ge(i, bi);
|
|
1231
|
-
let
|
|
1232
|
-
const
|
|
1233
|
-
if (
|
|
1234
|
+
let Yt = !0, rt, ot;
|
|
1235
|
+
const ki = (i) => {
|
|
1236
|
+
if (Yt) {
|
|
1234
1237
|
rt = new Int32Array(512), ot = new Int32Array(32);
|
|
1235
1238
|
let e = 0;
|
|
1236
1239
|
for (; e < 144; )
|
|
@@ -1243,39 +1246,39 @@ const Ei = (i) => {
|
|
|
1243
1246
|
i.lens[e++] = 8;
|
|
1244
1247
|
for (H(he, i.lens, 0, 288, rt, 0, i.work, { bits: 9 }), e = 0; e < 32; )
|
|
1245
1248
|
i.lens[e++] = 5;
|
|
1246
|
-
H(le, i.lens, 0, 32, ot, 0, i.work, { bits: 5 }),
|
|
1249
|
+
H(le, i.lens, 0, 32, ot, 0, i.work, { bits: 5 }), Yt = !1;
|
|
1247
1250
|
}
|
|
1248
1251
|
i.lencode = rt, i.lenbits = 9, i.distcode = ot, i.distbits = 5;
|
|
1249
|
-
}, be = (i, e, t,
|
|
1252
|
+
}, be = (i, e, t, n) => {
|
|
1250
1253
|
let a;
|
|
1251
|
-
const
|
|
1252
|
-
return
|
|
1253
|
-
},
|
|
1254
|
-
let t,
|
|
1254
|
+
const s = i.state;
|
|
1255
|
+
return s.window === null && (s.wsize = 1 << s.wbits, s.wnext = 0, s.whave = 0, s.window = new Uint8Array(s.wsize)), n >= s.wsize ? (s.window.set(e.subarray(t - s.wsize, t), 0), s.wnext = 0, s.whave = s.wsize) : (a = s.wsize - s.wnext, a > n && (a = n), s.window.set(e.subarray(t - n, t - n + a), s.wnext), n -= a, n ? (s.window.set(e.subarray(t - n, t), 0), s.wnext = n, s.whave = s.wsize) : (s.wnext += a, s.wnext === s.wsize && (s.wnext = 0), s.whave < s.wsize && (s.whave += a))), 0;
|
|
1256
|
+
}, Ei = (i, e) => {
|
|
1257
|
+
let t, n, a, s, l, h, d, r, o, w, u, f, _, U, x = 0, g, T, y, c, E, I, p, m;
|
|
1255
1258
|
const A = new Uint8Array(4);
|
|
1256
|
-
let b,
|
|
1259
|
+
let b, k;
|
|
1257
1260
|
const M = (
|
|
1258
1261
|
/* permutation of code lengths */
|
|
1259
1262
|
new Uint8Array([16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15])
|
|
1260
1263
|
);
|
|
1261
1264
|
if (B(i) || !i.output || !i.input && i.avail_in !== 0)
|
|
1262
|
-
return
|
|
1263
|
-
t = i.state, t.mode ===
|
|
1265
|
+
return S;
|
|
1266
|
+
t = i.state, t.mode === C && (t.mode = nt), l = i.next_out, a = i.output, d = i.avail_out, s = i.next_in, n = i.input, h = i.avail_in, r = t.hold, o = t.bits, w = h, u = d, m = L;
|
|
1264
1267
|
t:
|
|
1265
1268
|
for (; ; )
|
|
1266
1269
|
switch (t.mode) {
|
|
1267
1270
|
case tt:
|
|
1268
1271
|
if (t.wrap === 0) {
|
|
1269
|
-
t.mode =
|
|
1272
|
+
t.mode = nt;
|
|
1270
1273
|
break;
|
|
1271
1274
|
}
|
|
1272
1275
|
for (; o < 16; ) {
|
|
1273
1276
|
if (h === 0)
|
|
1274
1277
|
break t;
|
|
1275
|
-
h--, r += s
|
|
1278
|
+
h--, r += n[s++] << o, o += 8;
|
|
1276
1279
|
}
|
|
1277
1280
|
if (t.wrap & 2 && r === 35615) {
|
|
1278
|
-
t.wbits === 0 && (t.wbits = 15), t.check = 0, A[0] = r & 255, A[1] = r >>> 8 & 255, t.check =
|
|
1281
|
+
t.wbits === 0 && (t.wbits = 15), t.check = 0, A[0] = r & 255, A[1] = r >>> 8 & 255, t.check = R(t.check, A, 2, 0), r = 0, o = 0, t.mode = mt;
|
|
1279
1282
|
break;
|
|
1280
1283
|
}
|
|
1281
1284
|
if (t.head && (t.head.done = !1), !(t.wrap & 1) || /* check if zlib header allowed */
|
|
@@ -1291,13 +1294,13 @@ const Ei = (i) => {
|
|
|
1291
1294
|
i.msg = "invalid window size", t.mode = v;
|
|
1292
1295
|
break;
|
|
1293
1296
|
}
|
|
1294
|
-
t.dmax = 1 << t.wbits, t.flags = 0, i.adler = t.check = 1, t.mode = r & 512 ?
|
|
1297
|
+
t.dmax = 1 << t.wbits, t.flags = 0, i.adler = t.check = 1, t.mode = r & 512 ? Nt : C, r = 0, o = 0;
|
|
1295
1298
|
break;
|
|
1296
1299
|
case mt:
|
|
1297
1300
|
for (; o < 16; ) {
|
|
1298
1301
|
if (h === 0)
|
|
1299
1302
|
break t;
|
|
1300
|
-
h--, r += s
|
|
1303
|
+
h--, r += n[s++] << o, o += 8;
|
|
1301
1304
|
}
|
|
1302
1305
|
if (t.flags = r, (t.flags & 255) !== Tt) {
|
|
1303
1306
|
i.msg = "unknown compression method", t.mode = v;
|
|
@@ -1307,81 +1310,81 @@ const Ei = (i) => {
|
|
|
1307
1310
|
i.msg = "unknown header flags set", t.mode = v;
|
|
1308
1311
|
break;
|
|
1309
1312
|
}
|
|
1310
|
-
t.head && (t.head.text = r >> 8 & 1), t.flags & 512 && t.wrap & 4 && (A[0] = r & 255, A[1] = r >>> 8 & 255, t.check =
|
|
1313
|
+
t.head && (t.head.text = r >> 8 & 1), t.flags & 512 && t.wrap & 4 && (A[0] = r & 255, A[1] = r >>> 8 & 255, t.check = R(t.check, A, 2, 0)), r = 0, o = 0, t.mode = vt;
|
|
1311
1314
|
/* falls through */
|
|
1312
1315
|
case vt:
|
|
1313
1316
|
for (; o < 32; ) {
|
|
1314
1317
|
if (h === 0)
|
|
1315
1318
|
break t;
|
|
1316
|
-
h--, r += s
|
|
1319
|
+
h--, r += n[s++] << o, o += 8;
|
|
1317
1320
|
}
|
|
1318
|
-
t.head && (t.head.time = r), t.flags & 512 && t.wrap & 4 && (A[0] = r & 255, A[1] = r >>> 8 & 255, A[2] = r >>> 16 & 255, A[3] = r >>> 24 & 255, t.check =
|
|
1321
|
+
t.head && (t.head.time = r), t.flags & 512 && t.wrap & 4 && (A[0] = r & 255, A[1] = r >>> 8 & 255, A[2] = r >>> 16 & 255, A[3] = r >>> 24 & 255, t.check = R(t.check, A, 4, 0)), r = 0, o = 0, t.mode = Ut;
|
|
1319
1322
|
/* falls through */
|
|
1320
1323
|
case Ut:
|
|
1321
1324
|
for (; o < 16; ) {
|
|
1322
1325
|
if (h === 0)
|
|
1323
1326
|
break t;
|
|
1324
|
-
h--, r += s
|
|
1327
|
+
h--, r += n[s++] << o, o += 8;
|
|
1325
1328
|
}
|
|
1326
|
-
t.head && (t.head.xflags = r & 255, t.head.os = r >> 8), t.flags & 512 && t.wrap & 4 && (A[0] = r & 255, A[1] = r >>> 8 & 255, t.check =
|
|
1329
|
+
t.head && (t.head.xflags = r & 255, t.head.os = r >> 8), t.flags & 512 && t.wrap & 4 && (A[0] = r & 255, A[1] = r >>> 8 & 255, t.check = R(t.check, A, 2, 0)), r = 0, o = 0, t.mode = It;
|
|
1327
1330
|
/* falls through */
|
|
1328
1331
|
case It:
|
|
1329
1332
|
if (t.flags & 1024) {
|
|
1330
1333
|
for (; o < 16; ) {
|
|
1331
1334
|
if (h === 0)
|
|
1332
1335
|
break t;
|
|
1333
|
-
h--, r += s
|
|
1336
|
+
h--, r += n[s++] << o, o += 8;
|
|
1334
1337
|
}
|
|
1335
|
-
t.length = r, t.head && (t.head.extra_len = r), t.flags & 512 && t.wrap & 4 && (A[0] = r & 255, A[1] = r >>> 8 & 255, t.check =
|
|
1338
|
+
t.length = r, t.head && (t.head.extra_len = r), t.flags & 512 && t.wrap & 4 && (A[0] = r & 255, A[1] = r >>> 8 & 255, t.check = R(t.check, A, 2, 0)), r = 0, o = 0;
|
|
1336
1339
|
} else t.head && (t.head.extra = null);
|
|
1337
1340
|
t.mode = Ot;
|
|
1338
1341
|
/* falls through */
|
|
1339
1342
|
case Ot:
|
|
1340
1343
|
if (t.flags & 1024 && (f = t.length, f > h && (f = h), f && (t.head && (p = t.head.extra_len - t.length, t.head.extra || (t.head.extra = new Uint8Array(t.head.extra_len)), t.head.extra.set(
|
|
1341
|
-
|
|
1342
|
-
|
|
1344
|
+
n.subarray(
|
|
1345
|
+
s,
|
|
1343
1346
|
// extra field is limited to 65536 bytes
|
|
1344
1347
|
// - no need for additional size check
|
|
1345
|
-
|
|
1348
|
+
s + f
|
|
1346
1349
|
),
|
|
1347
1350
|
/*len + copy > state.head.extra_max - len ? state.head.extra_max : copy,*/
|
|
1348
1351
|
p
|
|
1349
|
-
)), t.flags & 512 && t.wrap & 4 && (t.check =
|
|
1352
|
+
)), t.flags & 512 && t.wrap & 4 && (t.check = R(t.check, n, f, s)), h -= f, s += f, t.length -= f), t.length))
|
|
1350
1353
|
break t;
|
|
1351
|
-
t.length = 0, t.mode =
|
|
1354
|
+
t.length = 0, t.mode = St;
|
|
1352
1355
|
/* falls through */
|
|
1353
|
-
case
|
|
1356
|
+
case St:
|
|
1354
1357
|
if (t.flags & 2048) {
|
|
1355
1358
|
if (h === 0)
|
|
1356
1359
|
break t;
|
|
1357
1360
|
f = 0;
|
|
1358
1361
|
do
|
|
1359
|
-
p = s
|
|
1362
|
+
p = n[s + f++], t.head && p && t.length < 65536 && (t.head.name += String.fromCharCode(p));
|
|
1360
1363
|
while (p && f < h);
|
|
1361
|
-
if (t.flags & 512 && t.wrap & 4 && (t.check =
|
|
1364
|
+
if (t.flags & 512 && t.wrap & 4 && (t.check = R(t.check, n, f, s)), h -= f, s += f, p)
|
|
1362
1365
|
break t;
|
|
1363
1366
|
} else t.head && (t.head.name = null);
|
|
1364
|
-
t.length = 0, t.mode =
|
|
1367
|
+
t.length = 0, t.mode = Rt;
|
|
1365
1368
|
/* falls through */
|
|
1366
|
-
case
|
|
1369
|
+
case Rt:
|
|
1367
1370
|
if (t.flags & 4096) {
|
|
1368
1371
|
if (h === 0)
|
|
1369
1372
|
break t;
|
|
1370
1373
|
f = 0;
|
|
1371
1374
|
do
|
|
1372
|
-
p = s
|
|
1375
|
+
p = n[s + f++], t.head && p && t.length < 65536 && (t.head.comment += String.fromCharCode(p));
|
|
1373
1376
|
while (p && f < h);
|
|
1374
|
-
if (t.flags & 512 && t.wrap & 4 && (t.check =
|
|
1377
|
+
if (t.flags & 512 && t.wrap & 4 && (t.check = R(t.check, n, f, s)), h -= f, s += f, p)
|
|
1375
1378
|
break t;
|
|
1376
1379
|
} else t.head && (t.head.comment = null);
|
|
1377
|
-
t.mode =
|
|
1380
|
+
t.mode = Ct;
|
|
1378
1381
|
/* falls through */
|
|
1379
|
-
case
|
|
1382
|
+
case Ct:
|
|
1380
1383
|
if (t.flags & 512) {
|
|
1381
1384
|
for (; o < 16; ) {
|
|
1382
1385
|
if (h === 0)
|
|
1383
1386
|
break t;
|
|
1384
|
-
h--, r += s
|
|
1387
|
+
h--, r += n[s++] << o, o += 8;
|
|
1385
1388
|
}
|
|
1386
1389
|
if (t.wrap & 4 && r !== (t.check & 65535)) {
|
|
1387
1390
|
i.msg = "header crc mismatch", t.mode = v;
|
|
@@ -1389,26 +1392,26 @@ const Ei = (i) => {
|
|
|
1389
1392
|
}
|
|
1390
1393
|
r = 0, o = 0;
|
|
1391
1394
|
}
|
|
1392
|
-
t.head && (t.head.hcrc = t.flags >> 9 & 1, t.head.done = !0), i.adler = t.check = 0, t.mode =
|
|
1395
|
+
t.head && (t.head.hcrc = t.flags >> 9 & 1, t.head.done = !0), i.adler = t.check = 0, t.mode = C;
|
|
1393
1396
|
break;
|
|
1394
|
-
case
|
|
1397
|
+
case Nt:
|
|
1395
1398
|
for (; o < 32; ) {
|
|
1396
1399
|
if (h === 0)
|
|
1397
1400
|
break t;
|
|
1398
|
-
h--, r += s
|
|
1401
|
+
h--, r += n[s++] << o, o += 8;
|
|
1399
1402
|
}
|
|
1400
|
-
i.adler = t.check =
|
|
1403
|
+
i.adler = t.check = Kt(r), r = 0, o = 0, t.mode = Q;
|
|
1401
1404
|
/* falls through */
|
|
1402
1405
|
case Q:
|
|
1403
1406
|
if (t.havedict === 0)
|
|
1404
|
-
return i.next_out = l, i.avail_out = d, i.next_in =
|
|
1405
|
-
i.adler = t.check = 1, t.mode =
|
|
1407
|
+
return i.next_out = l, i.avail_out = d, i.next_in = s, i.avail_in = h, t.hold = r, t.bits = o, ui;
|
|
1408
|
+
i.adler = t.check = 1, t.mode = C;
|
|
1406
1409
|
/* falls through */
|
|
1407
|
-
case
|
|
1408
|
-
if (e === ci || e ===
|
|
1410
|
+
case C:
|
|
1411
|
+
if (e === ci || e === Y)
|
|
1409
1412
|
break t;
|
|
1410
1413
|
/* falls through */
|
|
1411
|
-
case
|
|
1414
|
+
case nt:
|
|
1412
1415
|
if (t.last) {
|
|
1413
1416
|
r >>>= o & 7, o -= o & 7, t.mode = at;
|
|
1414
1417
|
break;
|
|
@@ -1416,14 +1419,14 @@ const Ei = (i) => {
|
|
|
1416
1419
|
for (; o < 3; ) {
|
|
1417
1420
|
if (h === 0)
|
|
1418
1421
|
break t;
|
|
1419
|
-
h--, r += s
|
|
1422
|
+
h--, r += n[s++] << o, o += 8;
|
|
1420
1423
|
}
|
|
1421
1424
|
switch (t.last = r & 1, r >>>= 1, o -= 1, r & 3) {
|
|
1422
1425
|
case 0:
|
|
1423
1426
|
t.mode = Dt;
|
|
1424
1427
|
break;
|
|
1425
1428
|
case 1:
|
|
1426
|
-
if (
|
|
1429
|
+
if (ki(t), t.mode = j, e === Y) {
|
|
1427
1430
|
r >>>= 2, o -= 2;
|
|
1428
1431
|
break t;
|
|
1429
1432
|
}
|
|
@@ -1440,32 +1443,32 @@ const Ei = (i) => {
|
|
|
1440
1443
|
for (r >>>= o & 7, o -= o & 7; o < 32; ) {
|
|
1441
1444
|
if (h === 0)
|
|
1442
1445
|
break t;
|
|
1443
|
-
h--, r += s
|
|
1446
|
+
h--, r += n[s++] << o, o += 8;
|
|
1444
1447
|
}
|
|
1445
1448
|
if ((r & 65535) !== (r >>> 16 ^ 65535)) {
|
|
1446
1449
|
i.msg = "invalid stored block lengths", t.mode = v;
|
|
1447
1450
|
break;
|
|
1448
1451
|
}
|
|
1449
|
-
if (t.length = r & 65535, r = 0, o = 0, t.mode =
|
|
1452
|
+
if (t.length = r & 65535, r = 0, o = 0, t.mode = st, e === Y)
|
|
1450
1453
|
break t;
|
|
1451
1454
|
/* falls through */
|
|
1452
|
-
case
|
|
1455
|
+
case st:
|
|
1453
1456
|
t.mode = Mt;
|
|
1454
1457
|
/* falls through */
|
|
1455
1458
|
case Mt:
|
|
1456
1459
|
if (f = t.length, f) {
|
|
1457
1460
|
if (f > h && (f = h), f > d && (f = d), f === 0)
|
|
1458
1461
|
break t;
|
|
1459
|
-
a.set(
|
|
1462
|
+
a.set(n.subarray(s, s + f), l), h -= f, s += f, d -= f, l += f, t.length -= f;
|
|
1460
1463
|
break;
|
|
1461
1464
|
}
|
|
1462
|
-
t.mode =
|
|
1465
|
+
t.mode = C;
|
|
1463
1466
|
break;
|
|
1464
1467
|
case Lt:
|
|
1465
1468
|
for (; o < 14; ) {
|
|
1466
1469
|
if (h === 0)
|
|
1467
1470
|
break t;
|
|
1468
|
-
h--, r += s
|
|
1471
|
+
h--, r += n[s++] << o, o += 8;
|
|
1469
1472
|
}
|
|
1470
1473
|
if (t.nlen = (r & 31) + 257, r >>>= 5, o -= 5, t.ndist = (r & 31) + 1, r >>>= 5, o -= 5, t.ncode = (r & 15) + 4, r >>>= 4, o -= 4, t.nlen > 286 || t.ndist > 30) {
|
|
1471
1474
|
i.msg = "too many length or distance symbols", t.mode = v;
|
|
@@ -1478,7 +1481,7 @@ const Ei = (i) => {
|
|
|
1478
1481
|
for (; o < 3; ) {
|
|
1479
1482
|
if (h === 0)
|
|
1480
1483
|
break t;
|
|
1481
|
-
h--, r += s
|
|
1484
|
+
h--, r += n[s++] << o, o += 8;
|
|
1482
1485
|
}
|
|
1483
1486
|
t.lens[M[t.have++]] = r & 7, r >>>= 3, o -= 3;
|
|
1484
1487
|
}
|
|
@@ -1495,16 +1498,16 @@ const Ei = (i) => {
|
|
|
1495
1498
|
for (; x = t.lencode[r & (1 << t.lenbits) - 1], g = x >>> 24, T = x >>> 16 & 255, y = x & 65535, !(g <= o); ) {
|
|
1496
1499
|
if (h === 0)
|
|
1497
1500
|
break t;
|
|
1498
|
-
h--, r += s
|
|
1501
|
+
h--, r += n[s++] << o, o += 8;
|
|
1499
1502
|
}
|
|
1500
1503
|
if (y < 16)
|
|
1501
1504
|
r >>>= g, o -= g, t.lens[t.have++] = y;
|
|
1502
1505
|
else {
|
|
1503
1506
|
if (y === 16) {
|
|
1504
|
-
for (
|
|
1507
|
+
for (k = g + 2; o < k; ) {
|
|
1505
1508
|
if (h === 0)
|
|
1506
1509
|
break t;
|
|
1507
|
-
h--, r += s
|
|
1510
|
+
h--, r += n[s++] << o, o += 8;
|
|
1508
1511
|
}
|
|
1509
1512
|
if (r >>>= g, o -= g, t.have === 0) {
|
|
1510
1513
|
i.msg = "invalid bit length repeat", t.mode = v;
|
|
@@ -1512,17 +1515,17 @@ const Ei = (i) => {
|
|
|
1512
1515
|
}
|
|
1513
1516
|
p = t.lens[t.have - 1], f = 3 + (r & 3), r >>>= 2, o -= 2;
|
|
1514
1517
|
} else if (y === 17) {
|
|
1515
|
-
for (
|
|
1518
|
+
for (k = g + 3; o < k; ) {
|
|
1516
1519
|
if (h === 0)
|
|
1517
1520
|
break t;
|
|
1518
|
-
h--, r += s
|
|
1521
|
+
h--, r += n[s++] << o, o += 8;
|
|
1519
1522
|
}
|
|
1520
1523
|
r >>>= g, o -= g, p = 0, f = 3 + (r & 7), r >>>= 3, o -= 3;
|
|
1521
1524
|
} else {
|
|
1522
|
-
for (
|
|
1525
|
+
for (k = g + 7; o < k; ) {
|
|
1523
1526
|
if (h === 0)
|
|
1524
1527
|
break t;
|
|
1525
|
-
h--, r += s
|
|
1528
|
+
h--, r += n[s++] << o, o += 8;
|
|
1526
1529
|
}
|
|
1527
1530
|
r >>>= g, o -= g, p = 0, f = 11 + (r & 127), r >>>= 7, o -= 7;
|
|
1528
1531
|
}
|
|
@@ -1548,7 +1551,7 @@ const Ei = (i) => {
|
|
|
1548
1551
|
i.msg = "invalid distances set", t.mode = v;
|
|
1549
1552
|
break;
|
|
1550
1553
|
}
|
|
1551
|
-
if (t.mode = j, e ===
|
|
1554
|
+
if (t.mode = j, e === Y)
|
|
1552
1555
|
break t;
|
|
1553
1556
|
/* falls through */
|
|
1554
1557
|
case j:
|
|
@@ -1556,19 +1559,19 @@ const Ei = (i) => {
|
|
|
1556
1559
|
/* falls through */
|
|
1557
1560
|
case X:
|
|
1558
1561
|
if (h >= 6 && d >= 258) {
|
|
1559
|
-
i.next_out = l, i.avail_out = d, i.next_in =
|
|
1562
|
+
i.next_out = l, i.avail_out = d, i.next_in = s, i.avail_in = h, t.hold = r, t.bits = o, si(i, u), l = i.next_out, a = i.output, d = i.avail_out, s = i.next_in, n = i.input, h = i.avail_in, r = t.hold, o = t.bits, t.mode === C && (t.back = -1);
|
|
1560
1563
|
break;
|
|
1561
1564
|
}
|
|
1562
1565
|
for (t.back = 0; x = t.lencode[r & (1 << t.lenbits) - 1], g = x >>> 24, T = x >>> 16 & 255, y = x & 65535, !(g <= o); ) {
|
|
1563
1566
|
if (h === 0)
|
|
1564
1567
|
break t;
|
|
1565
|
-
h--, r += s
|
|
1568
|
+
h--, r += n[s++] << o, o += 8;
|
|
1566
1569
|
}
|
|
1567
1570
|
if (T && (T & 240) === 0) {
|
|
1568
|
-
for (c = g,
|
|
1571
|
+
for (c = g, E = T, I = y; x = t.lencode[I + ((r & (1 << c + E) - 1) >> c)], g = x >>> 24, T = x >>> 16 & 255, y = x & 65535, !(c + g <= o); ) {
|
|
1569
1572
|
if (h === 0)
|
|
1570
1573
|
break t;
|
|
1571
|
-
h--, r += s
|
|
1574
|
+
h--, r += n[s++] << o, o += 8;
|
|
1572
1575
|
}
|
|
1573
1576
|
r >>>= c, o -= c, t.back += c;
|
|
1574
1577
|
}
|
|
@@ -1577,7 +1580,7 @@ const Ei = (i) => {
|
|
|
1577
1580
|
break;
|
|
1578
1581
|
}
|
|
1579
1582
|
if (T & 32) {
|
|
1580
|
-
t.back = -1, t.mode =
|
|
1583
|
+
t.back = -1, t.mode = C;
|
|
1581
1584
|
break;
|
|
1582
1585
|
}
|
|
1583
1586
|
if (T & 64) {
|
|
@@ -1588,10 +1591,10 @@ const Ei = (i) => {
|
|
|
1588
1591
|
/* falls through */
|
|
1589
1592
|
case Ft:
|
|
1590
1593
|
if (t.extra) {
|
|
1591
|
-
for (
|
|
1594
|
+
for (k = t.extra; o < k; ) {
|
|
1592
1595
|
if (h === 0)
|
|
1593
1596
|
break t;
|
|
1594
|
-
h--, r += s
|
|
1597
|
+
h--, r += n[s++] << o, o += 8;
|
|
1595
1598
|
}
|
|
1596
1599
|
t.length += r & (1 << t.extra) - 1, r >>>= t.extra, o -= t.extra, t.back += t.extra;
|
|
1597
1600
|
}
|
|
@@ -1601,13 +1604,13 @@ const Ei = (i) => {
|
|
|
1601
1604
|
for (; x = t.distcode[r & (1 << t.distbits) - 1], g = x >>> 24, T = x >>> 16 & 255, y = x & 65535, !(g <= o); ) {
|
|
1602
1605
|
if (h === 0)
|
|
1603
1606
|
break t;
|
|
1604
|
-
h--, r += s
|
|
1607
|
+
h--, r += n[s++] << o, o += 8;
|
|
1605
1608
|
}
|
|
1606
1609
|
if ((T & 240) === 0) {
|
|
1607
|
-
for (c = g,
|
|
1610
|
+
for (c = g, E = T, I = y; x = t.distcode[I + ((r & (1 << c + E) - 1) >> c)], g = x >>> 24, T = x >>> 16 & 255, y = x & 65535, !(c + g <= o); ) {
|
|
1608
1611
|
if (h === 0)
|
|
1609
1612
|
break t;
|
|
1610
|
-
h--, r += s
|
|
1613
|
+
h--, r += n[s++] << o, o += 8;
|
|
1611
1614
|
}
|
|
1612
1615
|
r >>>= c, o -= c, t.back += c;
|
|
1613
1616
|
}
|
|
@@ -1619,10 +1622,10 @@ const Ei = (i) => {
|
|
|
1619
1622
|
/* falls through */
|
|
1620
1623
|
case Zt:
|
|
1621
1624
|
if (t.extra) {
|
|
1622
|
-
for (
|
|
1625
|
+
for (k = t.extra; o < k; ) {
|
|
1623
1626
|
if (h === 0)
|
|
1624
1627
|
break t;
|
|
1625
|
-
h--, r += s
|
|
1628
|
+
h--, r += n[s++] << o, o += 8;
|
|
1626
1629
|
}
|
|
1627
1630
|
t.offset += r & (1 << t.extra) - 1, r >>>= t.extra, o -= t.extra, t.back += t.extra;
|
|
1628
1631
|
}
|
|
@@ -1659,10 +1662,10 @@ const Ei = (i) => {
|
|
|
1659
1662
|
for (; o < 32; ) {
|
|
1660
1663
|
if (h === 0)
|
|
1661
1664
|
break t;
|
|
1662
|
-
h--, r |= s
|
|
1665
|
+
h--, r |= n[s++] << o, o += 8;
|
|
1663
1666
|
}
|
|
1664
1667
|
if (u -= d, i.total_out += u, t.total += u, t.wrap & 4 && u && (i.adler = t.check = /*UPDATE_CHECK(state.check, put - _out, _out);*/
|
|
1665
|
-
t.flags ?
|
|
1668
|
+
t.flags ? R(t.check, a, u, l - u) : ut(t.check, a, u, l - u)), u = d, t.wrap & 4 && (t.flags ? r : Kt(r)) !== t.check) {
|
|
1666
1669
|
i.msg = "incorrect data check", t.mode = v;
|
|
1667
1670
|
break;
|
|
1668
1671
|
}
|
|
@@ -1675,7 +1678,7 @@ const Ei = (i) => {
|
|
|
1675
1678
|
for (; o < 32; ) {
|
|
1676
1679
|
if (h === 0)
|
|
1677
1680
|
break t;
|
|
1678
|
-
h--, r += s
|
|
1681
|
+
h--, r += n[s++] << o, o += 8;
|
|
1679
1682
|
}
|
|
1680
1683
|
if (t.wrap & 4 && r !== (t.total & 4294967295)) {
|
|
1681
1684
|
i.msg = "incorrect length check", t.mode = v;
|
|
@@ -1696,34 +1699,34 @@ const Ei = (i) => {
|
|
|
1696
1699
|
case ue:
|
|
1697
1700
|
/* falls through */
|
|
1698
1701
|
default:
|
|
1699
|
-
return
|
|
1702
|
+
return S;
|
|
1700
1703
|
}
|
|
1701
|
-
return i.next_out = l, i.avail_out = d, i.next_in =
|
|
1702
|
-
t.flags ?
|
|
1704
|
+
return i.next_out = l, i.avail_out = d, i.next_in = s, i.avail_in = h, t.hold = r, t.bits = o, (t.wsize || u !== i.avail_out && t.mode < v && (t.mode < at || e !== At)) && be(i, i.output, i.next_out, u - i.avail_out), w -= i.avail_in, u -= i.avail_out, i.total_in += w, i.total_out += u, t.total += u, t.wrap & 4 && u && (i.adler = t.check = /*UPDATE_CHECK(state.check, strm.next_out - _out, _out);*/
|
|
1705
|
+
t.flags ? R(t.check, a, u, i.next_out - u) : ut(t.check, a, u, i.next_out - u)), i.data_type = t.bits + (t.last ? 64 : 0) + (t.mode === C ? 128 : 0) + (t.mode === j || t.mode === st ? 256 : 0), (w === 0 && u === 0 || e === At) && m === L && (m = _i), m;
|
|
1703
1706
|
}, Ai = (i) => {
|
|
1704
1707
|
if (B(i))
|
|
1705
|
-
return
|
|
1708
|
+
return S;
|
|
1706
1709
|
let e = i.state;
|
|
1707
1710
|
return e.window && (e.window = null), i.state = null, L;
|
|
1708
1711
|
}, Ti = (i, e) => {
|
|
1709
1712
|
if (B(i))
|
|
1710
|
-
return
|
|
1713
|
+
return S;
|
|
1711
1714
|
const t = i.state;
|
|
1712
|
-
return (t.wrap & 2) === 0 ?
|
|
1715
|
+
return (t.wrap & 2) === 0 ? S : (t.head = e, e.done = !1, L);
|
|
1713
1716
|
}, mi = (i, e) => {
|
|
1714
1717
|
const t = e.length;
|
|
1715
|
-
let
|
|
1716
|
-
return B(i) || (
|
|
1718
|
+
let n, a, s;
|
|
1719
|
+
return B(i) || (n = i.state, n.wrap !== 0 && n.mode !== Q) ? S : n.mode === Q && (a = 1, a = ut(a, e, t, 0), a !== n.check) ? fe : (s = be(i, e, t, t), s ? (n.mode = de, ce) : (n.havedict = 1, L));
|
|
1717
1720
|
};
|
|
1718
|
-
var vi = pe, Ui = we, Ii = _e, Oi = yi,
|
|
1721
|
+
var vi = pe, Ui = we, Ii = _e, Oi = yi, Si = ge, Ri = Ei, Ci = Ai, Ni = Ti, Di = mi, Mi = "pako inflate (from Nodeca project)", D = {
|
|
1719
1722
|
inflateReset: vi,
|
|
1720
1723
|
inflateReset2: Ui,
|
|
1721
1724
|
inflateResetKeep: Ii,
|
|
1722
1725
|
inflateInit: Oi,
|
|
1723
|
-
inflateInit2:
|
|
1724
|
-
inflate:
|
|
1725
|
-
inflateEnd:
|
|
1726
|
-
inflateGetHeader:
|
|
1726
|
+
inflateInit2: Si,
|
|
1727
|
+
inflate: Ri,
|
|
1728
|
+
inflateEnd: Ci,
|
|
1729
|
+
inflateGetHeader: Ni,
|
|
1727
1730
|
inflateSetDictionary: Di,
|
|
1728
1731
|
inflateInfo: Mi
|
|
1729
1732
|
};
|
|
@@ -1759,28 +1762,28 @@ function z(i) {
|
|
|
1759
1762
|
throw new Error(_t[t]);
|
|
1760
1763
|
}
|
|
1761
1764
|
z.prototype.push = function(i, e) {
|
|
1762
|
-
const t = this.strm,
|
|
1763
|
-
let
|
|
1765
|
+
const t = this.strm, n = this.options.chunkSize, a = this.options.dictionary;
|
|
1766
|
+
let s, l, h;
|
|
1764
1767
|
if (this.ended) return !1;
|
|
1765
1768
|
for (e === ~~e ? l = e : l = e === !0 ? Fi : $i, xe.call(i) === "[object ArrayBuffer]" ? t.input = new Uint8Array(i) : t.input = i, t.next_in = 0, t.avail_in = t.input.length; ; ) {
|
|
1766
|
-
for (t.avail_out === 0 && (t.output = new Uint8Array(
|
|
1767
|
-
D.inflateReset(t),
|
|
1768
|
-
switch (
|
|
1769
|
+
for (t.avail_out === 0 && (t.output = new Uint8Array(n), t.next_out = 0, t.avail_out = n), s = D.inflate(t, l), s === lt && a && (s = D.inflateSetDictionary(t, a), s === W ? s = D.inflate(t, l) : s === jt && (s = lt)); t.avail_in > 0 && s === ht && t.state.wrap > 0 && i[t.next_in] !== 0; )
|
|
1770
|
+
D.inflateReset(t), s = D.inflate(t, l);
|
|
1771
|
+
switch (s) {
|
|
1769
1772
|
case Hi:
|
|
1770
1773
|
case jt:
|
|
1771
1774
|
case lt:
|
|
1772
1775
|
case Zi:
|
|
1773
|
-
return this.onEnd(
|
|
1776
|
+
return this.onEnd(s), this.ended = !0, !1;
|
|
1774
1777
|
}
|
|
1775
|
-
if (h = t.avail_out, t.next_out && (t.avail_out === 0 ||
|
|
1778
|
+
if (h = t.avail_out, t.next_out && (t.avail_out === 0 || s === ht))
|
|
1776
1779
|
if (this.options.to === "string") {
|
|
1777
1780
|
let d = pt.utf8border(t.output, t.next_out), r = t.next_out - d, o = pt.buf2string(t.output, d);
|
|
1778
|
-
t.next_out = r, t.avail_out =
|
|
1781
|
+
t.next_out = r, t.avail_out = n - r, r && t.output.set(t.output.subarray(d, d + r), 0), this.onData(o);
|
|
1779
1782
|
} else
|
|
1780
1783
|
this.onData(t.output.length === t.next_out ? t.output : t.output.subarray(0, t.next_out));
|
|
1781
|
-
if (!(
|
|
1782
|
-
if (
|
|
1783
|
-
return
|
|
1784
|
+
if (!(s === W && h === 0)) {
|
|
1785
|
+
if (s === ht)
|
|
1786
|
+
return s = D.inflateEnd(this.strm), this.onEnd(s), this.ended = !0, !0;
|
|
1784
1787
|
if (t.avail_in === 0) break;
|
|
1785
1788
|
}
|
|
1786
1789
|
}
|
|
@@ -1801,8 +1804,8 @@ var zi = z, Pi = Wi, Gi = {
|
|
|
1801
1804
|
Inflate: zi,
|
|
1802
1805
|
inflate: Pi
|
|
1803
1806
|
};
|
|
1804
|
-
const { Inflate:
|
|
1805
|
-
var Xt =
|
|
1807
|
+
const { Inflate: Ki, inflate: Yi } = Gi;
|
|
1808
|
+
var Xt = Ki, ji = Yi;
|
|
1806
1809
|
const ye = [];
|
|
1807
1810
|
for (let i = 0; i < 256; i++) {
|
|
1808
1811
|
let e = i;
|
|
@@ -1812,95 +1815,95 @@ for (let i = 0; i < 256; i++) {
|
|
|
1812
1815
|
}
|
|
1813
1816
|
const Vt = 4294967295;
|
|
1814
1817
|
function Xi(i, e, t) {
|
|
1815
|
-
let
|
|
1818
|
+
let n = i;
|
|
1816
1819
|
for (let a = 0; a < t; a++)
|
|
1817
|
-
|
|
1818
|
-
return
|
|
1820
|
+
n = ye[(n ^ e[a]) & 255] ^ n >>> 8;
|
|
1821
|
+
return n;
|
|
1819
1822
|
}
|
|
1820
1823
|
function Vi(i, e) {
|
|
1821
1824
|
return (Xi(Vt, i, e) ^ Vt) >>> 0;
|
|
1822
1825
|
}
|
|
1823
1826
|
function qt(i, e, t) {
|
|
1824
|
-
const
|
|
1825
|
-
if (a !==
|
|
1826
|
-
throw new Error(`CRC mismatch for chunk ${t}. Expected ${
|
|
1827
|
+
const n = i.readUint32(), a = Vi(new Uint8Array(i.buffer, i.byteOffset + i.offset - e - 4, e), e);
|
|
1828
|
+
if (a !== n)
|
|
1829
|
+
throw new Error(`CRC mismatch for chunk ${t}. Expected ${n}, found ${a}`);
|
|
1827
1830
|
}
|
|
1828
|
-
function
|
|
1829
|
-
for (let
|
|
1830
|
-
e[
|
|
1831
|
+
function ke(i, e, t) {
|
|
1832
|
+
for (let n = 0; n < t; n++)
|
|
1833
|
+
e[n] = i[n];
|
|
1831
1834
|
}
|
|
1832
|
-
function
|
|
1835
|
+
function Ee(i, e, t, n) {
|
|
1833
1836
|
let a = 0;
|
|
1834
|
-
for (; a <
|
|
1837
|
+
for (; a < n; a++)
|
|
1835
1838
|
e[a] = i[a];
|
|
1836
1839
|
for (; a < t; a++)
|
|
1837
|
-
e[a] = i[a] + e[a -
|
|
1840
|
+
e[a] = i[a] + e[a - n] & 255;
|
|
1838
1841
|
}
|
|
1839
|
-
function Ae(i, e, t,
|
|
1842
|
+
function Ae(i, e, t, n) {
|
|
1840
1843
|
let a = 0;
|
|
1841
1844
|
if (t.length === 0)
|
|
1842
|
-
for (; a <
|
|
1845
|
+
for (; a < n; a++)
|
|
1843
1846
|
e[a] = i[a];
|
|
1844
1847
|
else
|
|
1845
|
-
for (; a <
|
|
1848
|
+
for (; a < n; a++)
|
|
1846
1849
|
e[a] = i[a] + t[a] & 255;
|
|
1847
1850
|
}
|
|
1848
|
-
function Te(i, e, t,
|
|
1849
|
-
let
|
|
1851
|
+
function Te(i, e, t, n, a) {
|
|
1852
|
+
let s = 0;
|
|
1850
1853
|
if (t.length === 0) {
|
|
1851
|
-
for (;
|
|
1852
|
-
e[
|
|
1853
|
-
for (;
|
|
1854
|
-
e[
|
|
1854
|
+
for (; s < a; s++)
|
|
1855
|
+
e[s] = i[s];
|
|
1856
|
+
for (; s < n; s++)
|
|
1857
|
+
e[s] = i[s] + (e[s - a] >> 1) & 255;
|
|
1855
1858
|
} else {
|
|
1856
|
-
for (;
|
|
1857
|
-
e[
|
|
1858
|
-
for (;
|
|
1859
|
-
e[
|
|
1859
|
+
for (; s < a; s++)
|
|
1860
|
+
e[s] = i[s] + (t[s] >> 1) & 255;
|
|
1861
|
+
for (; s < n; s++)
|
|
1862
|
+
e[s] = i[s] + (e[s - a] + t[s] >> 1) & 255;
|
|
1860
1863
|
}
|
|
1861
1864
|
}
|
|
1862
|
-
function me(i, e, t,
|
|
1863
|
-
let
|
|
1865
|
+
function me(i, e, t, n, a) {
|
|
1866
|
+
let s = 0;
|
|
1864
1867
|
if (t.length === 0) {
|
|
1865
|
-
for (;
|
|
1866
|
-
e[
|
|
1867
|
-
for (;
|
|
1868
|
-
e[
|
|
1868
|
+
for (; s < a; s++)
|
|
1869
|
+
e[s] = i[s];
|
|
1870
|
+
for (; s < n; s++)
|
|
1871
|
+
e[s] = i[s] + e[s - a] & 255;
|
|
1869
1872
|
} else {
|
|
1870
|
-
for (;
|
|
1871
|
-
e[
|
|
1872
|
-
for (;
|
|
1873
|
-
e[
|
|
1873
|
+
for (; s < a; s++)
|
|
1874
|
+
e[s] = i[s] + t[s] & 255;
|
|
1875
|
+
for (; s < n; s++)
|
|
1876
|
+
e[s] = i[s] + qi(e[s - a], t[s], t[s - a]) & 255;
|
|
1874
1877
|
}
|
|
1875
1878
|
}
|
|
1876
1879
|
function qi(i, e, t) {
|
|
1877
|
-
const
|
|
1878
|
-
return a <=
|
|
1880
|
+
const n = i + e - t, a = Math.abs(n - i), s = Math.abs(n - e), l = Math.abs(n - t);
|
|
1881
|
+
return a <= s && a <= l ? i : s <= l ? e : t;
|
|
1879
1882
|
}
|
|
1880
|
-
function Ji(i, e, t,
|
|
1883
|
+
function Ji(i, e, t, n, a, s) {
|
|
1881
1884
|
switch (i) {
|
|
1882
1885
|
case 0:
|
|
1883
|
-
|
|
1886
|
+
ke(e, t, a);
|
|
1884
1887
|
break;
|
|
1885
1888
|
case 1:
|
|
1886
|
-
|
|
1889
|
+
Ee(e, t, a, s);
|
|
1887
1890
|
break;
|
|
1888
1891
|
case 2:
|
|
1889
|
-
Ae(e, t,
|
|
1892
|
+
Ae(e, t, n, a);
|
|
1890
1893
|
break;
|
|
1891
1894
|
case 3:
|
|
1892
|
-
Te(e, t,
|
|
1895
|
+
Te(e, t, n, a, s);
|
|
1893
1896
|
break;
|
|
1894
1897
|
case 4:
|
|
1895
|
-
me(e, t,
|
|
1898
|
+
me(e, t, n, a, s);
|
|
1896
1899
|
break;
|
|
1897
1900
|
default:
|
|
1898
1901
|
throw new Error(`Unsupported filter: ${i}`);
|
|
1899
1902
|
}
|
|
1900
1903
|
}
|
|
1901
|
-
const Qi = new Uint16Array([255]),
|
|
1902
|
-
function
|
|
1903
|
-
const { data: e, width: t, height:
|
|
1904
|
+
const Qi = new Uint16Array([255]), tn = new Uint8Array(Qi.buffer), en = tn[0] === 255;
|
|
1905
|
+
function nn(i) {
|
|
1906
|
+
const { data: e, width: t, height: n, channels: a, depth: s } = i, l = [
|
|
1904
1907
|
{ x: 0, y: 0, xStep: 8, yStep: 8 },
|
|
1905
1908
|
// Pass 1
|
|
1906
1909
|
{ x: 4, y: 0, xStep: 8, yStep: 8 },
|
|
@@ -1915,10 +1918,10 @@ function is(i) {
|
|
|
1915
1918
|
// Pass 6
|
|
1916
1919
|
{ x: 0, y: 1, xStep: 1, yStep: 2 }
|
|
1917
1920
|
// Pass 7
|
|
1918
|
-
], h = Math.ceil(
|
|
1921
|
+
], h = Math.ceil(s / 8) * a, d = new Uint8Array(n * t * h);
|
|
1919
1922
|
let r = 0;
|
|
1920
1923
|
for (let o = 0; o < 7; o++) {
|
|
1921
|
-
const w = l[o], u = Math.ceil((t - w.x) / w.xStep), f = Math.ceil((
|
|
1924
|
+
const w = l[o], u = Math.ceil((t - w.x) / w.xStep), f = Math.ceil((n - w.y) / w.yStep);
|
|
1922
1925
|
if (u <= 0 || f <= 0)
|
|
1923
1926
|
continue;
|
|
1924
1927
|
const _ = u * h, U = new Uint8Array(_);
|
|
@@ -1928,36 +1931,36 @@ function is(i) {
|
|
|
1928
1931
|
const y = new Uint8Array(_);
|
|
1929
1932
|
Ji(g, T, y, U, _, h), U.set(y);
|
|
1930
1933
|
for (let c = 0; c < u; c++) {
|
|
1931
|
-
const
|
|
1932
|
-
if (!(
|
|
1934
|
+
const E = w.x + c * w.xStep, I = w.y + x * w.yStep;
|
|
1935
|
+
if (!(E >= t || I >= n))
|
|
1933
1936
|
for (let p = 0; p < h; p++)
|
|
1934
|
-
d[(I * t +
|
|
1937
|
+
d[(I * t + E) * h + p] = y[c * h + p];
|
|
1935
1938
|
}
|
|
1936
1939
|
}
|
|
1937
1940
|
}
|
|
1938
|
-
if (
|
|
1941
|
+
if (s === 16) {
|
|
1939
1942
|
const o = new Uint16Array(d.buffer);
|
|
1940
|
-
if (
|
|
1943
|
+
if (en)
|
|
1941
1944
|
for (let w = 0; w < o.length; w++)
|
|
1942
|
-
o[w] =
|
|
1945
|
+
o[w] = sn(o[w]);
|
|
1943
1946
|
return o;
|
|
1944
1947
|
} else
|
|
1945
1948
|
return d;
|
|
1946
1949
|
}
|
|
1947
|
-
function
|
|
1950
|
+
function sn(i) {
|
|
1948
1951
|
return (i & 255) << 8 | i >> 8 & 255;
|
|
1949
1952
|
}
|
|
1950
|
-
const
|
|
1953
|
+
const an = new Uint16Array([255]), rn = new Uint8Array(an.buffer), on = rn[0] === 255, hn = new Uint8Array(0);
|
|
1951
1954
|
function Jt(i) {
|
|
1952
|
-
const { data: e, width: t, height:
|
|
1953
|
-
let r =
|
|
1954
|
-
for (let f = 0; f <
|
|
1955
|
+
const { data: e, width: t, height: n, channels: a, depth: s } = i, l = Math.ceil(s / 8) * a, h = Math.ceil(s / 8 * a * t), d = new Uint8Array(n * h);
|
|
1956
|
+
let r = hn, o = 0, w, u;
|
|
1957
|
+
for (let f = 0; f < n; f++) {
|
|
1955
1958
|
switch (w = e.subarray(o + 1, o + 1 + h), u = d.subarray(f * h, (f + 1) * h), e[o]) {
|
|
1956
1959
|
case 0:
|
|
1957
|
-
|
|
1960
|
+
ke(w, u, h);
|
|
1958
1961
|
break;
|
|
1959
1962
|
case 1:
|
|
1960
|
-
|
|
1963
|
+
Ee(w, u, h, l);
|
|
1961
1964
|
break;
|
|
1962
1965
|
case 2:
|
|
1963
1966
|
Ae(w, u, r, h);
|
|
@@ -1973,24 +1976,24 @@ function Jt(i) {
|
|
|
1973
1976
|
}
|
|
1974
1977
|
r = u, o += h + 1;
|
|
1975
1978
|
}
|
|
1976
|
-
if (
|
|
1979
|
+
if (s === 16) {
|
|
1977
1980
|
const f = new Uint16Array(d.buffer);
|
|
1978
|
-
if (
|
|
1981
|
+
if (on)
|
|
1979
1982
|
for (let _ = 0; _ < f.length; _++)
|
|
1980
|
-
f[_] =
|
|
1983
|
+
f[_] = ln(f[_]);
|
|
1981
1984
|
return f;
|
|
1982
1985
|
} else
|
|
1983
1986
|
return d;
|
|
1984
1987
|
}
|
|
1985
|
-
function
|
|
1988
|
+
function ln(i) {
|
|
1986
1989
|
return (i & 255) << 8 | i >> 8 & 255;
|
|
1987
1990
|
}
|
|
1988
1991
|
const J = Uint8Array.of(137, 80, 78, 71, 13, 10, 26, 10);
|
|
1989
1992
|
function Qt(i) {
|
|
1990
|
-
if (!
|
|
1993
|
+
if (!fn(i.readBytes(J.length)))
|
|
1991
1994
|
throw new Error("wrong PNG signature");
|
|
1992
1995
|
}
|
|
1993
|
-
function
|
|
1996
|
+
function fn(i) {
|
|
1994
1997
|
if (i.length < J.length)
|
|
1995
1998
|
return !1;
|
|
1996
1999
|
for (let e = 0; e < J.length; e++)
|
|
@@ -1998,29 +2001,29 @@ function ls(i) {
|
|
|
1998
2001
|
return !1;
|
|
1999
2002
|
return !0;
|
|
2000
2003
|
}
|
|
2001
|
-
const
|
|
2002
|
-
function
|
|
2003
|
-
if (
|
|
2004
|
+
const cn = "tEXt", dn = 0, ve = new TextDecoder("latin1");
|
|
2005
|
+
function un(i) {
|
|
2006
|
+
if (pn(i), i.length === 0 || i.length > 79)
|
|
2004
2007
|
throw new Error("keyword length must be between 1 and 79");
|
|
2005
2008
|
}
|
|
2006
|
-
const
|
|
2007
|
-
function
|
|
2008
|
-
if (!
|
|
2009
|
+
const _n = /^[\u0000-\u00FF]*$/;
|
|
2010
|
+
function pn(i) {
|
|
2011
|
+
if (!_n.test(i))
|
|
2009
2012
|
throw new Error("invalid latin1 text");
|
|
2010
2013
|
}
|
|
2011
|
-
function
|
|
2012
|
-
const
|
|
2013
|
-
i[
|
|
2014
|
+
function wn(i, e, t) {
|
|
2015
|
+
const n = Ue(e);
|
|
2016
|
+
i[n] = gn(e, t - n.length - 1);
|
|
2014
2017
|
}
|
|
2015
2018
|
function Ue(i) {
|
|
2016
|
-
for (i.mark(); i.readByte() !==
|
|
2019
|
+
for (i.mark(); i.readByte() !== dn; )
|
|
2017
2020
|
;
|
|
2018
2021
|
const e = i.offset;
|
|
2019
2022
|
i.reset();
|
|
2020
2023
|
const t = ve.decode(i.readBytes(e - i.offset - 1));
|
|
2021
|
-
return i.skip(1),
|
|
2024
|
+
return i.skip(1), un(t), t;
|
|
2022
2025
|
}
|
|
2023
|
-
function
|
|
2026
|
+
function gn(i, e) {
|
|
2024
2027
|
return ve.decode(i.readBytes(e));
|
|
2025
2028
|
}
|
|
2026
2029
|
const O = {
|
|
@@ -2048,7 +2051,7 @@ const O = {
|
|
|
2048
2051
|
SOURCE: 0,
|
|
2049
2052
|
OVER: 1
|
|
2050
2053
|
};
|
|
2051
|
-
class
|
|
2054
|
+
class bn extends wt {
|
|
2052
2055
|
_checkCrc;
|
|
2053
2056
|
_inflator;
|
|
2054
2057
|
_png;
|
|
@@ -2069,8 +2072,8 @@ class gs extends wt {
|
|
|
2069
2072
|
_writingDataChunks;
|
|
2070
2073
|
constructor(e, t = {}) {
|
|
2071
2074
|
super(e);
|
|
2072
|
-
const { checkCrc:
|
|
2073
|
-
this._checkCrc =
|
|
2075
|
+
const { checkCrc: n = !1 } = t;
|
|
2076
|
+
this._checkCrc = n, this._inflator = new Xt(), this._png = {
|
|
2074
2077
|
width: -1,
|
|
2075
2078
|
height: -1,
|
|
2076
2079
|
channels: -1,
|
|
@@ -2104,7 +2107,7 @@ class gs extends wt {
|
|
|
2104
2107
|
}
|
|
2105
2108
|
// https://www.w3.org/TR/PNG/#5Chunk-layout
|
|
2106
2109
|
decodeChunk(e, t) {
|
|
2107
|
-
const
|
|
2110
|
+
const n = this.offset;
|
|
2108
2111
|
switch (t) {
|
|
2109
2112
|
// 11.2 Critical chunks
|
|
2110
2113
|
case "IHDR":
|
|
@@ -2126,8 +2129,8 @@ class gs extends wt {
|
|
|
2126
2129
|
case "iCCP":
|
|
2127
2130
|
this.decodeiCCP(e);
|
|
2128
2131
|
break;
|
|
2129
|
-
case
|
|
2130
|
-
|
|
2132
|
+
case cn:
|
|
2133
|
+
wn(this._png.text, this, e);
|
|
2131
2134
|
break;
|
|
2132
2135
|
case "pHYs":
|
|
2133
2136
|
this.decodepHYs();
|
|
@@ -2136,12 +2139,12 @@ class gs extends wt {
|
|
|
2136
2139
|
this.skip(e);
|
|
2137
2140
|
break;
|
|
2138
2141
|
}
|
|
2139
|
-
if (this.offset -
|
|
2142
|
+
if (this.offset - n !== e)
|
|
2140
2143
|
throw new Error(`Length mismatch while decoding chunk ${t}`);
|
|
2141
2144
|
this._checkCrc ? qt(this, e + 4, t) : this.skip(4);
|
|
2142
2145
|
}
|
|
2143
2146
|
decodeApngChunk(e, t) {
|
|
2144
|
-
const
|
|
2147
|
+
const n = this.offset;
|
|
2145
2148
|
switch (t !== "fdAT" && t !== "IDAT" && this._writingDataChunks && this.pushDataToFrame(), t) {
|
|
2146
2149
|
case "acTL":
|
|
2147
2150
|
this.decodeACTL();
|
|
@@ -2153,35 +2156,35 @@ class gs extends wt {
|
|
|
2153
2156
|
this.decodeFDAT(e);
|
|
2154
2157
|
break;
|
|
2155
2158
|
default:
|
|
2156
|
-
this.decodeChunk(e, t), this.offset =
|
|
2159
|
+
this.decodeChunk(e, t), this.offset = n + e;
|
|
2157
2160
|
break;
|
|
2158
2161
|
}
|
|
2159
|
-
if (this.offset -
|
|
2162
|
+
if (this.offset - n !== e)
|
|
2160
2163
|
throw new Error(`Length mismatch while decoding chunk ${t}`);
|
|
2161
2164
|
this._checkCrc ? qt(this, e + 4, t) : this.skip(4);
|
|
2162
2165
|
}
|
|
2163
2166
|
// https://www.w3.org/TR/PNG/#11IHDR
|
|
2164
2167
|
decodeIHDR() {
|
|
2165
2168
|
const e = this._png;
|
|
2166
|
-
e.width = this.readUint32(), e.height = this.readUint32(), e.depth =
|
|
2169
|
+
e.width = this.readUint32(), e.height = this.readUint32(), e.depth = xn(this.readUint8());
|
|
2167
2170
|
const t = this.readUint8();
|
|
2168
2171
|
this._colorType = t;
|
|
2169
|
-
let
|
|
2172
|
+
let n;
|
|
2170
2173
|
switch (t) {
|
|
2171
2174
|
case O.GREYSCALE:
|
|
2172
|
-
|
|
2175
|
+
n = 1;
|
|
2173
2176
|
break;
|
|
2174
2177
|
case O.TRUECOLOUR:
|
|
2175
|
-
|
|
2178
|
+
n = 3;
|
|
2176
2179
|
break;
|
|
2177
2180
|
case O.INDEXED_COLOUR:
|
|
2178
|
-
|
|
2181
|
+
n = 1;
|
|
2179
2182
|
break;
|
|
2180
2183
|
case O.GREYSCALE_ALPHA:
|
|
2181
|
-
|
|
2184
|
+
n = 2;
|
|
2182
2185
|
break;
|
|
2183
2186
|
case O.TRUECOLOUR_ALPHA:
|
|
2184
|
-
|
|
2187
|
+
n = 4;
|
|
2185
2188
|
break;
|
|
2186
2189
|
// Kept for exhaustiveness.
|
|
2187
2190
|
// eslint-disable-next-line unicorn/no-useless-switch-case
|
|
@@ -2189,7 +2192,7 @@ class gs extends wt {
|
|
|
2189
2192
|
default:
|
|
2190
2193
|
throw new Error(`Unknown color type: ${t}`);
|
|
2191
2194
|
}
|
|
2192
|
-
if (this._png.channels =
|
|
2195
|
+
if (this._png.channels = n, this._compressionMethod = this.readUint8(), this._compressionMethod !== ft.DEFLATE)
|
|
2193
2196
|
throw new Error(`Unsupported compression method: ${this._compressionMethod}`);
|
|
2194
2197
|
this._filterMethod = this.readUint8(), this._interlaceMethod = this.readUint8();
|
|
2195
2198
|
}
|
|
@@ -2217,23 +2220,23 @@ class gs extends wt {
|
|
|
2217
2220
|
throw new RangeError(`PLTE field length must be a multiple of 3. Got ${e}`);
|
|
2218
2221
|
const t = e / 3;
|
|
2219
2222
|
this._hasPalette = !0;
|
|
2220
|
-
const
|
|
2221
|
-
this._palette =
|
|
2223
|
+
const n = [];
|
|
2224
|
+
this._palette = n;
|
|
2222
2225
|
for (let a = 0; a < t; a++)
|
|
2223
|
-
|
|
2226
|
+
n.push([this.readUint8(), this.readUint8(), this.readUint8()]);
|
|
2224
2227
|
}
|
|
2225
2228
|
// https://www.w3.org/TR/PNG/#11IDAT
|
|
2226
2229
|
decodeIDAT(e) {
|
|
2227
2230
|
this._writingDataChunks = !0;
|
|
2228
|
-
const t = e,
|
|
2229
|
-
if (this._inflator.push(new Uint8Array(this.buffer,
|
|
2231
|
+
const t = e, n = this.offset + this.byteOffset;
|
|
2232
|
+
if (this._inflator.push(new Uint8Array(this.buffer, n, t)), this._inflator.err)
|
|
2230
2233
|
throw new Error(`Error while decompressing the data: ${this._inflator.err}`);
|
|
2231
2234
|
this.skip(e);
|
|
2232
2235
|
}
|
|
2233
2236
|
decodeFDAT(e) {
|
|
2234
2237
|
this._writingDataChunks = !0;
|
|
2235
|
-
let t = e,
|
|
2236
|
-
if (
|
|
2238
|
+
let t = e, n = this.offset + this.byteOffset;
|
|
2239
|
+
if (n += 4, t -= 4, this._inflator.push(new Uint8Array(this.buffer, n, t)), this._inflator.err)
|
|
2237
2240
|
throw new Error(`Error while decompressing the data: ${this._inflator.err}`);
|
|
2238
2241
|
this.skip(e);
|
|
2239
2242
|
}
|
|
@@ -2256,8 +2259,8 @@ class gs extends wt {
|
|
|
2256
2259
|
throw new Error(`tRNS chunk contains more alpha values than there are palette colors (${e} vs ${this._palette.length})`);
|
|
2257
2260
|
let t = 0;
|
|
2258
2261
|
for (; t < e; t++) {
|
|
2259
|
-
const
|
|
2260
|
-
this._palette[t].push(
|
|
2262
|
+
const n = this.readByte();
|
|
2263
|
+
this._palette[t].push(n);
|
|
2261
2264
|
}
|
|
2262
2265
|
for (; t < this._palette.length; t++)
|
|
2263
2266
|
this._palette[t].push(255);
|
|
@@ -2274,9 +2277,9 @@ class gs extends wt {
|
|
|
2274
2277
|
}
|
|
2275
2278
|
// https://www.w3.org/TR/PNG/#11iCCP
|
|
2276
2279
|
decodeiCCP(e) {
|
|
2277
|
-
const t = Ue(this),
|
|
2278
|
-
if (
|
|
2279
|
-
throw new Error(`Unsupported iCCP compression method: ${
|
|
2280
|
+
const t = Ue(this), n = this.readUint8();
|
|
2281
|
+
if (n !== ft.DEFLATE)
|
|
2282
|
+
throw new Error(`Unsupported iCCP compression method: ${n}`);
|
|
2280
2283
|
const a = this.readBytes(e - t.length - 2);
|
|
2281
2284
|
this._png.iccEmbeddedProfile = {
|
|
2282
2285
|
name: t,
|
|
@@ -2285,11 +2288,11 @@ class gs extends wt {
|
|
|
2285
2288
|
}
|
|
2286
2289
|
// https://www.w3.org/TR/PNG/#11pHYs
|
|
2287
2290
|
decodepHYs() {
|
|
2288
|
-
const e = this.readUint32(), t = this.readUint32(),
|
|
2291
|
+
const e = this.readUint32(), t = this.readUint32(), n = this.readByte();
|
|
2289
2292
|
this._png.resolution = {
|
|
2290
2293
|
x: e,
|
|
2291
2294
|
y: t,
|
|
2292
|
-
unit:
|
|
2295
|
+
unit: n
|
|
2293
2296
|
};
|
|
2294
2297
|
}
|
|
2295
2298
|
decodeApngImage() {
|
|
@@ -2300,65 +2303,65 @@ class gs extends wt {
|
|
|
2300
2303
|
delayNumber: this._frames[e].delayNumber,
|
|
2301
2304
|
delayDenominator: this._frames[e].delayDenominator,
|
|
2302
2305
|
data: this._apng.depth === 8 ? new Uint8Array(this._apng.width * this._apng.height * this._apng.channels) : new Uint16Array(this._apng.width * this._apng.height * this._apng.channels)
|
|
2303
|
-
},
|
|
2304
|
-
if (
|
|
2305
|
-
if (
|
|
2306
|
-
data:
|
|
2307
|
-
width:
|
|
2308
|
-
height:
|
|
2306
|
+
}, n = this._frames.at(e);
|
|
2307
|
+
if (n) {
|
|
2308
|
+
if (n.data = Jt({
|
|
2309
|
+
data: n.data,
|
|
2310
|
+
width: n.width,
|
|
2311
|
+
height: n.height,
|
|
2309
2312
|
channels: this._apng.channels,
|
|
2310
2313
|
depth: this._apng.depth
|
|
2311
|
-
}), this._hasPalette && (this._apng.palette = this._palette), this._hasTransparency && (this._apng.transparency = this._transparency), e === 0 ||
|
|
2312
|
-
t.data =
|
|
2314
|
+
}), this._hasPalette && (this._apng.palette = this._palette), this._hasTransparency && (this._apng.transparency = this._transparency), e === 0 || n.xOffset === 0 && n.yOffset === 0 && n.width === this._png.width && n.height === this._png.height)
|
|
2315
|
+
t.data = n.data;
|
|
2313
2316
|
else {
|
|
2314
2317
|
const a = this._apng.frames.at(e - 1);
|
|
2315
|
-
this.disposeFrame(
|
|
2318
|
+
this.disposeFrame(n, a, t), this.addFrameDataToCanvas(t, n);
|
|
2316
2319
|
}
|
|
2317
2320
|
this._apng.frames.push(t);
|
|
2318
2321
|
}
|
|
2319
2322
|
}
|
|
2320
2323
|
return this._apng;
|
|
2321
2324
|
}
|
|
2322
|
-
disposeFrame(e, t,
|
|
2325
|
+
disposeFrame(e, t, n) {
|
|
2323
2326
|
switch (e.disposeOp) {
|
|
2324
2327
|
case V.NONE:
|
|
2325
2328
|
break;
|
|
2326
2329
|
case V.BACKGROUND:
|
|
2327
2330
|
for (let a = 0; a < this._png.height; a++)
|
|
2328
|
-
for (let
|
|
2329
|
-
const l = (a * e.width +
|
|
2331
|
+
for (let s = 0; s < this._png.width; s++) {
|
|
2332
|
+
const l = (a * e.width + s) * this._png.channels;
|
|
2330
2333
|
for (let h = 0; h < this._png.channels; h++)
|
|
2331
|
-
|
|
2334
|
+
n.data[l + h] = 0;
|
|
2332
2335
|
}
|
|
2333
2336
|
break;
|
|
2334
2337
|
case V.PREVIOUS:
|
|
2335
|
-
|
|
2338
|
+
n.data.set(t.data);
|
|
2336
2339
|
break;
|
|
2337
2340
|
default:
|
|
2338
2341
|
throw new Error("Unknown disposeOp");
|
|
2339
2342
|
}
|
|
2340
2343
|
}
|
|
2341
2344
|
addFrameDataToCanvas(e, t) {
|
|
2342
|
-
const
|
|
2343
|
-
const h = ((
|
|
2345
|
+
const n = 1 << this._png.depth, a = (s, l) => {
|
|
2346
|
+
const h = ((s + t.yOffset) * this._png.width + t.xOffset + l) * this._png.channels, d = (s * t.width + l) * this._png.channels;
|
|
2344
2347
|
return { index: h, frameIndex: d };
|
|
2345
2348
|
};
|
|
2346
2349
|
switch (t.blendOp) {
|
|
2347
2350
|
case dt.SOURCE:
|
|
2348
|
-
for (let
|
|
2351
|
+
for (let s = 0; s < t.height; s++)
|
|
2349
2352
|
for (let l = 0; l < t.width; l++) {
|
|
2350
|
-
const { index: h, frameIndex: d } = a(
|
|
2353
|
+
const { index: h, frameIndex: d } = a(s, l);
|
|
2351
2354
|
for (let r = 0; r < this._png.channels; r++)
|
|
2352
2355
|
e.data[h + r] = t.data[d + r];
|
|
2353
2356
|
}
|
|
2354
2357
|
break;
|
|
2355
2358
|
// https://www.w3.org/TR/png-3/#13Alpha-channel-processing
|
|
2356
2359
|
case dt.OVER:
|
|
2357
|
-
for (let
|
|
2360
|
+
for (let s = 0; s < t.height; s++)
|
|
2358
2361
|
for (let l = 0; l < t.width; l++) {
|
|
2359
|
-
const { index: h, frameIndex: d } = a(
|
|
2362
|
+
const { index: h, frameIndex: d } = a(s, l);
|
|
2360
2363
|
for (let r = 0; r < this._png.channels; r++) {
|
|
2361
|
-
const o = t.data[d + this._png.channels - 1] /
|
|
2364
|
+
const o = t.data[d + this._png.channels - 1] / n, w = r % (this._png.channels - 1) === 0 ? 1 : t.data[d + r], u = Math.floor(o * w + (1 - o) * e.data[h + r]);
|
|
2362
2365
|
e.data[h + r] += u;
|
|
2363
2366
|
}
|
|
2364
2367
|
}
|
|
@@ -2382,7 +2385,7 @@ class gs extends wt {
|
|
|
2382
2385
|
depth: this._png.depth
|
|
2383
2386
|
});
|
|
2384
2387
|
else if (this._interlaceMethod === ct.ADAM7)
|
|
2385
|
-
this._png.data =
|
|
2388
|
+
this._png.data = nn({
|
|
2386
2389
|
data: e,
|
|
2387
2390
|
width: this._png.width,
|
|
2388
2391
|
height: this._png.height,
|
|
@@ -2409,20 +2412,20 @@ class gs extends wt {
|
|
|
2409
2412
|
}), this._inflator = new Xt(), this._writingDataChunks = !1;
|
|
2410
2413
|
}
|
|
2411
2414
|
}
|
|
2412
|
-
function
|
|
2415
|
+
function xn(i) {
|
|
2413
2416
|
if (i !== 1 && i !== 2 && i !== 4 && i !== 8 && i !== 16)
|
|
2414
2417
|
throw new Error(`invalid bit depth: ${i}`);
|
|
2415
2418
|
return i;
|
|
2416
2419
|
}
|
|
2417
|
-
function
|
|
2418
|
-
return new
|
|
2420
|
+
function yn(i, e) {
|
|
2421
|
+
return new bn(i, e).decode();
|
|
2419
2422
|
}
|
|
2420
|
-
class
|
|
2423
|
+
class kn {
|
|
2421
2424
|
#e;
|
|
2422
2425
|
#t;
|
|
2423
|
-
#s;
|
|
2424
|
-
#i;
|
|
2425
2426
|
#n;
|
|
2427
|
+
#i;
|
|
2428
|
+
#s;
|
|
2426
2429
|
elevs;
|
|
2427
2430
|
/**
|
|
2428
2431
|
* Create a new DEM.
|
|
@@ -2434,8 +2437,8 @@ class ys {
|
|
|
2434
2437
|
* @param {number} xSpacing - spacing in Spherical Mercator units in the horizontal direction.
|
|
2435
2438
|
* @param {number} ySpacing - spacing in Spherical Mercator units in the vertical direction.
|
|
2436
2439
|
*/
|
|
2437
|
-
constructor(e, t,
|
|
2438
|
-
this.#e = t, this.#t =
|
|
2440
|
+
constructor(e, t, n, a, s, l) {
|
|
2441
|
+
this.#e = t, this.#t = n, this.#n = a, this.elevs = e, this.#i = s, this.#s = l;
|
|
2439
2442
|
}
|
|
2440
2443
|
/** Obtains the elevation in metres at a given x and y Spherical Mercator coordinate using bilinear interpolation.
|
|
2441
2444
|
* @param {number} x - the Spherical Mercator x coordinate.
|
|
@@ -2443,16 +2446,16 @@ class ys {
|
|
|
2443
2446
|
* @return {number} the elevation in metres
|
|
2444
2447
|
*/
|
|
2445
2448
|
getElevation(e, t) {
|
|
2446
|
-
let
|
|
2447
|
-
if (a >= 0 &&
|
|
2448
|
-
r = this.elevs[
|
|
2449
|
-
let _ = (
|
|
2449
|
+
let n = [e, t], a = Math.floor((n[0] - this.#e.e) / this.#i), s = this.#n - Math.ceil((n[1] - this.#e.n) / this.#s), l, h, d, r, o, w, u, f = null;
|
|
2450
|
+
if (a >= 0 && s >= 0 && a < this.#t - 1 && s < this.#n - 1) {
|
|
2451
|
+
r = this.elevs[s * this.#t + a], o = this.elevs[s * this.#t + a + 1], w = this.elevs[s * this.#t + a + this.#t], u = this.elevs[s * this.#t + a + this.#t + 1], l = this.#e.e + a * this.#i, l + this.#i, h = this.#e.n + (this.#n - 1 - s) * this.#s, d = h - this.#s;
|
|
2452
|
+
let _ = (n[0] - l) / this.#i, U = r * (1 - _) + o * _, x = w * (1 - _) + u * _, g = (n[1] - d) / this.#s;
|
|
2450
2453
|
f = x * (1 - g) + U * g;
|
|
2451
2454
|
}
|
|
2452
2455
|
return f;
|
|
2453
2456
|
}
|
|
2454
2457
|
}
|
|
2455
|
-
class
|
|
2458
|
+
class En extends ie {
|
|
2456
2459
|
/**
|
|
2457
2460
|
* Create a DemTiler.
|
|
2458
2461
|
* @class
|
|
@@ -2467,14 +2470,14 @@ class Es extends ie {
|
|
|
2467
2470
|
* @return {Promise<any>} a Promise resolving with raw DEM data.
|
|
2468
2471
|
*/
|
|
2469
2472
|
async readTile(e) {
|
|
2470
|
-
const
|
|
2473
|
+
const n = await (await fetch(e, {
|
|
2471
2474
|
signal: AbortSignal.timeout(3e4)
|
|
2472
|
-
})).arrayBuffer(), a =
|
|
2473
|
-
let
|
|
2475
|
+
})).arrayBuffer(), a = yn(n);
|
|
2476
|
+
let s, l = 0;
|
|
2474
2477
|
const h = new Array(a.width * a.height);
|
|
2475
2478
|
for (let d = 0; d < a.height; d++)
|
|
2476
2479
|
for (let r = 0; r < a.width; r++)
|
|
2477
|
-
|
|
2480
|
+
s = (d * a.width + r) * a.channels, h[l++] = Math.round(a.data[s] * 256 + a.data[s + 1] + a.data[s + 2] / 256 - 32768);
|
|
2478
2481
|
return { w: a.width, h: a.height, elevs: h };
|
|
2479
2482
|
}
|
|
2480
2483
|
/**
|
|
@@ -2483,8 +2486,8 @@ class Es extends ie {
|
|
|
2483
2486
|
* @return {number} the elevation in metres, or Number.NEGATIVE_INFINITY if this position is outside the extent of the DEM.
|
|
2484
2487
|
*/
|
|
2485
2488
|
getElevation(e) {
|
|
2486
|
-
const t = this.getTile(e, this.tile.z),
|
|
2487
|
-
return
|
|
2489
|
+
const t = this.getTile(e, this.tile.z), n = this.dataTiles.get(`${t.z}/${t.x}/${t.y}`);
|
|
2490
|
+
return n ? n.data.getElevation(e.e, e.n) : null;
|
|
2488
2491
|
}
|
|
2489
2492
|
/**
|
|
2490
2493
|
* Obtain the elevation in metres for a given longitude/latitude.
|
|
@@ -2501,18 +2504,18 @@ class Es extends ie {
|
|
|
2501
2504
|
* @return {DataTile} the DataTile pairing the Tile and the DEM data as a DEM object.
|
|
2502
2505
|
*/
|
|
2503
2506
|
rawTileToStoredTile(e, t) {
|
|
2504
|
-
const
|
|
2507
|
+
const n = e.getTopRight(), a = e.getBottomLeft(), s = (n.e - a.e) / (t.w - 1), l = (n.n - a.n) / (t.h - 1), h = new kn(
|
|
2505
2508
|
t.elevs,
|
|
2506
2509
|
a,
|
|
2507
2510
|
t.w,
|
|
2508
2511
|
t.h,
|
|
2509
|
-
|
|
2512
|
+
s,
|
|
2510
2513
|
l
|
|
2511
2514
|
);
|
|
2512
2515
|
return { tile: e, data: h };
|
|
2513
2516
|
}
|
|
2514
2517
|
}
|
|
2515
|
-
class
|
|
2518
|
+
class An extends ie {
|
|
2516
2519
|
/**
|
|
2517
2520
|
* Create a JsonTiler.
|
|
2518
2521
|
* @class
|
|
@@ -2532,7 +2535,7 @@ class ks extends ie {
|
|
|
2532
2535
|
})).json();
|
|
2533
2536
|
}
|
|
2534
2537
|
}
|
|
2535
|
-
class
|
|
2538
|
+
class Tn {
|
|
2536
2539
|
e;
|
|
2537
2540
|
n;
|
|
2538
2541
|
/**
|
|
@@ -2544,12 +2547,19 @@ class As {
|
|
|
2544
2547
|
constructor(e, t) {
|
|
2545
2548
|
this.e = e, this.n = t;
|
|
2546
2549
|
}
|
|
2550
|
+
/**
|
|
2551
|
+
* Returns a string representation of the EastNorth.
|
|
2552
|
+
* @return {string} the string representation.
|
|
2553
|
+
*/
|
|
2554
|
+
toString() {
|
|
2555
|
+
return `e: ${this.e}, n: ${this.n}`;
|
|
2556
|
+
}
|
|
2547
2557
|
}
|
|
2548
2558
|
class ee {
|
|
2549
2559
|
lon;
|
|
2550
2560
|
lat;
|
|
2551
2561
|
/**
|
|
2552
|
-
* Creates
|
|
2562
|
+
* Creates a LonLat.
|
|
2553
2563
|
* @class
|
|
2554
2564
|
* @param {number} lon - the longitude.
|
|
2555
2565
|
* @param {number} lat - the latitude.
|
|
@@ -2557,8 +2567,15 @@ class ee {
|
|
|
2557
2567
|
constructor(e, t) {
|
|
2558
2568
|
this.lon = e, this.lat = t;
|
|
2559
2569
|
}
|
|
2570
|
+
/**
|
|
2571
|
+
* Returns a string representation of the LonLat.
|
|
2572
|
+
* @return {string} the string representation.
|
|
2573
|
+
*/
|
|
2574
|
+
toString() {
|
|
2575
|
+
return `lon: ${this.lon}, lat: ${this.lat}`;
|
|
2576
|
+
}
|
|
2560
2577
|
}
|
|
2561
|
-
class
|
|
2578
|
+
class mn {
|
|
2562
2579
|
demTiler;
|
|
2563
2580
|
jsonTiler;
|
|
2564
2581
|
/**
|
|
@@ -2580,13 +2597,13 @@ class Ts {
|
|
|
2580
2597
|
* @return {Promise<DataTile[]>} promise resolving with an array of updated JSON tiles with elevation added as a third member of the coordinates of each point. As for Tiler, only the newly-downloaded tiles are returned.
|
|
2581
2598
|
*/
|
|
2582
2599
|
async updateByLonLat(e) {
|
|
2583
|
-
const t = this.demTiler.sphMerc.project(e),
|
|
2584
|
-
return
|
|
2585
|
-
this.#e(
|
|
2600
|
+
const t = this.demTiler.sphMerc.project(e), n = await this.demTiler.update(t), a = await this.jsonTiler.update(t);
|
|
2601
|
+
return n.forEach((s, l) => {
|
|
2602
|
+
this.#e(s, a[l]);
|
|
2586
2603
|
}), a;
|
|
2587
2604
|
}
|
|
2588
2605
|
async #e(e, t) {
|
|
2589
|
-
t.data.features.forEach((a,
|
|
2606
|
+
t.data.features.forEach((a, s) => {
|
|
2590
2607
|
if (a.geometry.type == "LineString" && a.geometry.coordinates.length >= 2)
|
|
2591
2608
|
a.geometry.coordinates.forEach((l) => {
|
|
2592
2609
|
const h = this.demTiler.sphMerc.project(new ee(l[0], l[1])), d = e.data?.getElevation(h.e, h.n) ?? 0;
|
|
@@ -2601,12 +2618,12 @@ class Ts {
|
|
|
2601
2618
|
}
|
|
2602
2619
|
}
|
|
2603
2620
|
export {
|
|
2604
|
-
|
|
2605
|
-
|
|
2606
|
-
|
|
2607
|
-
|
|
2608
|
-
|
|
2609
|
-
|
|
2621
|
+
N as Constants,
|
|
2622
|
+
kn as DEM,
|
|
2623
|
+
mn as DemApplier,
|
|
2624
|
+
En as DemTiler,
|
|
2625
|
+
Tn as EastNorth,
|
|
2626
|
+
An as JsonTiler,
|
|
2610
2627
|
ee as LonLat,
|
|
2611
2628
|
Ie as SphMercProjection,
|
|
2612
2629
|
q as Tile,
|