locar-tiler 0.6.0 → 0.7.1
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/dist/locar-tiler.d.ts +9 -7
- package/dist/locar-tiler.mjs +352 -348
- 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 D {
|
|
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, s) {
|
|
17
|
+
this.x = e, this.y = t, this.z = s;
|
|
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 D.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 - D.HALF_EARTH, n: D.HALF_EARTH - (this.y + 1) * e };
|
|
33
33
|
}
|
|
34
34
|
/**
|
|
35
35
|
* Get the top right coordinate of the tile.
|
|
@@ -57,7 +57,7 @@ class Se {
|
|
|
57
57
|
* @return {EastNorth} the Spherical Mercator coordinates.
|
|
58
58
|
*/
|
|
59
59
|
project(e) {
|
|
60
|
-
return { e: this.#e(e.
|
|
60
|
+
return { e: this.#e(e.longitude), n: this.#t(e.latitude) };
|
|
61
61
|
}
|
|
62
62
|
/**
|
|
63
63
|
* Unproject Spherical Mercator into longitude/latitude.
|
|
@@ -65,20 +65,20 @@ class Se {
|
|
|
65
65
|
* @return {LonLat} the longitude/latitude.
|
|
66
66
|
*/
|
|
67
67
|
unproject(e) {
|
|
68
|
-
return {
|
|
68
|
+
return { longitude: this.#s(e[0]), latitude: this.#i(e[1]) };
|
|
69
69
|
}
|
|
70
70
|
#e(e) {
|
|
71
|
-
return e / 180 *
|
|
71
|
+
return e / 180 * D.HALF_EARTH;
|
|
72
72
|
}
|
|
73
73
|
#t(e) {
|
|
74
74
|
var t = Math.log(Math.tan((90 + e) * Math.PI / 360)) / (Math.PI / 180);
|
|
75
|
-
return t *
|
|
75
|
+
return t * D.HALF_EARTH / 180;
|
|
76
76
|
}
|
|
77
|
-
#
|
|
78
|
-
return e /
|
|
77
|
+
#s(e) {
|
|
78
|
+
return e / D.HALF_EARTH * 180;
|
|
79
79
|
}
|
|
80
80
|
#i(e) {
|
|
81
|
-
var t = e /
|
|
81
|
+
var t = e / D.HALF_EARTH * 180;
|
|
82
82
|
return t = 180 / Math.PI * (2 * Math.atan(Math.exp(t * Math.PI / 180)) - Math.PI / 2), t;
|
|
83
83
|
}
|
|
84
84
|
/**
|
|
@@ -87,8 +87,8 @@ class Se {
|
|
|
87
87
|
* @param {number} z - the zoom level.
|
|
88
88
|
*/
|
|
89
89
|
getTile(e, t) {
|
|
90
|
-
var
|
|
91
|
-
return
|
|
90
|
+
var s = new q(-1, -1, t), a = s.getMetresInTile();
|
|
91
|
+
return s.x = Math.floor((D.HALF_EARTH + e.e) / a), s.y = Math.floor((D.HALF_EARTH - e.n) / a), s;
|
|
92
92
|
}
|
|
93
93
|
/**
|
|
94
94
|
* Obtains a tile from a given lon/lat and zoom.
|
|
@@ -149,13 +149,13 @@ class ie {
|
|
|
149
149
|
*/
|
|
150
150
|
async update(e) {
|
|
151
151
|
const t = [];
|
|
152
|
-
let
|
|
153
|
-
if (
|
|
154
|
-
this.tile =
|
|
155
|
-
const a = [
|
|
152
|
+
let s = null;
|
|
153
|
+
if (s = this.#e(e)) {
|
|
154
|
+
this.tile = s;
|
|
155
|
+
const a = [s.x, s.x - 1, s.x + 1], n = [s.y, s.y - 1, s.y + 1];
|
|
156
156
|
for (let l = 0; l < a.length; l++)
|
|
157
|
-
for (let h = 0; h <
|
|
158
|
-
const d = new q(a[l],
|
|
157
|
+
for (let h = 0; h < n.length; h++) {
|
|
158
|
+
const d = new q(a[l], n[h], s.z), r = await this.#t(d);
|
|
159
159
|
r !== null && t.push({ data: r.data, tile: d });
|
|
160
160
|
}
|
|
161
161
|
}
|
|
@@ -174,10 +174,10 @@ class ie {
|
|
|
174
174
|
* @return {DataTile[]} array of 9 tiles, including the current tile and the 8 surrounding it.
|
|
175
175
|
*/
|
|
176
176
|
getCurrentTiles() {
|
|
177
|
-
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], s = [this.tile.y, this.tile.y - 1, this.tile.y + 1];
|
|
178
178
|
for (let a = 0; a < t.length; a++)
|
|
179
|
-
for (let
|
|
180
|
-
const l = new q(t[a], n
|
|
179
|
+
for (let n = 0; n < s.length; n++) {
|
|
180
|
+
const l = new q(t[a], s[n], this.tile.z), h = this.dataTiles.get(l.getIndex());
|
|
181
181
|
h !== null && e.push({ data: h, tile: l });
|
|
182
182
|
}
|
|
183
183
|
return e;
|
|
@@ -192,10 +192,10 @@ class ie {
|
|
|
192
192
|
async #t(e) {
|
|
193
193
|
const t = e.getIndex();
|
|
194
194
|
if (this.dataTiles.get(t) === void 0) {
|
|
195
|
-
const
|
|
195
|
+
const s = await this.readTile(
|
|
196
196
|
this.url.replace("{x}", e.x.toString()).replace("{y}", e.y.toString()).replace("{z}", e.z.toString())
|
|
197
197
|
);
|
|
198
|
-
return this.dataTiles.set(t, this.rawTileToStoredTile(e,
|
|
198
|
+
return this.dataTiles.set(t, this.rawTileToStoredTile(e, s)), this.dataTiles.get(t);
|
|
199
199
|
}
|
|
200
200
|
return null;
|
|
201
201
|
}
|
|
@@ -207,8 +207,8 @@ class ie {
|
|
|
207
207
|
*/
|
|
208
208
|
async getData(e, t = 13) {
|
|
209
209
|
await this.update(e);
|
|
210
|
-
const
|
|
211
|
-
return this.dataTiles.get(`${t}/${
|
|
210
|
+
const s = this.sphMerc.getTile(e, t);
|
|
211
|
+
return this.dataTiles.get(`${t}/${s.x}/${s.y}`);
|
|
212
212
|
}
|
|
213
213
|
/**
|
|
214
214
|
* Converts the raw data from the server to a custom type of data.
|
|
@@ -280,11 +280,11 @@ class wt {
|
|
|
280
280
|
* @returns A new IOBuffer instance.
|
|
281
281
|
*/
|
|
282
282
|
constructor(e = Re, t = {}) {
|
|
283
|
-
let
|
|
284
|
-
typeof e == "number" ? e = new ArrayBuffer(e) : (
|
|
285
|
-
const a = t.offset ? t.offset >>> 0 : 0,
|
|
283
|
+
let s = !1;
|
|
284
|
+
typeof e == "number" ? e = new ArrayBuffer(e) : (s = !0, this.lastWrittenByte = e.byteLength);
|
|
285
|
+
const a = t.offset ? t.offset >>> 0 : 0, n = e.byteLength - a;
|
|
286
286
|
let l = a;
|
|
287
|
-
(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), s ? this.lastWrittenByte = n : this.lastWrittenByte = 0, this.buffer = e, this.length = n, this.byteLength = n, this.byteOffset = l, this.offset = 0, this.littleEndian = !0, this._data = new DataView(this.buffer, l, n), this._mark = 0, this._marks = [];
|
|
288
288
|
}
|
|
289
289
|
/**
|
|
290
290
|
* Checks if the memory allocated to the buffer is sufficient to store more
|
|
@@ -401,8 +401,8 @@ class wt {
|
|
|
401
401
|
*/
|
|
402
402
|
ensureAvailable(e = 1) {
|
|
403
403
|
if (!this.available(e)) {
|
|
404
|
-
const
|
|
405
|
-
a.set(new Uint8Array(this.buffer)), this.buffer = a.buffer, this.length =
|
|
404
|
+
const s = (this.offset + e) * 2, a = new Uint8Array(s);
|
|
405
|
+
a.set(new Uint8Array(this.buffer)), this.buffer = a.buffer, this.length = s, this.byteLength = s, this._data = new DataView(this.buffer);
|
|
406
406
|
}
|
|
407
407
|
return this;
|
|
408
408
|
}
|
|
@@ -451,15 +451,15 @@ class wt {
|
|
|
451
451
|
* @returns The read array.
|
|
452
452
|
*/
|
|
453
453
|
readArray(e, t) {
|
|
454
|
-
const
|
|
454
|
+
const s = et[t].BYTES_PER_ELEMENT * e, a = this.byteOffset + this.offset, n = this.buffer.slice(a, a + s);
|
|
455
455
|
if (this.littleEndian === Ce && t !== "uint8" && t !== "int8") {
|
|
456
|
-
const h = new Uint8Array(this.buffer.slice(a, a +
|
|
456
|
+
const h = new Uint8Array(this.buffer.slice(a, a + s));
|
|
457
457
|
h.reverse();
|
|
458
458
|
const d = new et[t](h.buffer);
|
|
459
|
-
return this.offset +=
|
|
459
|
+
return this.offset += s, d.reverse(), d;
|
|
460
460
|
}
|
|
461
|
-
const l = new et[t](
|
|
462
|
-
return this.offset +=
|
|
461
|
+
const l = new et[t](n);
|
|
462
|
+
return this.offset += s, l;
|
|
463
463
|
}
|
|
464
464
|
/**
|
|
465
465
|
* Read a 16-bit signed integer and move pointer forward by 2 bytes.
|
|
@@ -539,7 +539,7 @@ class wt {
|
|
|
539
539
|
*/
|
|
540
540
|
readChars(e = 1) {
|
|
541
541
|
let t = "";
|
|
542
|
-
for (let
|
|
542
|
+
for (let s = 0; s < e; s++)
|
|
543
543
|
t += this.readChar();
|
|
544
544
|
return t;
|
|
545
545
|
}
|
|
@@ -739,43 +739,43 @@ function F(i) {
|
|
|
739
739
|
for (; --e >= 0; )
|
|
740
740
|
i[e] = 0;
|
|
741
741
|
}
|
|
742
|
-
const
|
|
742
|
+
const De = 3, Ne = 258, se = 29, Me = 256, Le = Me + 1 + se, ne = 30, Be = 512, $e = new Array((Le + 2) * 2);
|
|
743
743
|
F($e);
|
|
744
|
-
const Fe = new Array(
|
|
744
|
+
const Fe = new Array(ne * 2);
|
|
745
745
|
F(Fe);
|
|
746
746
|
const He = new Array(Be);
|
|
747
747
|
F(He);
|
|
748
|
-
const Ze = new Array(
|
|
748
|
+
const Ze = new Array(Ne - De + 1);
|
|
749
749
|
F(Ze);
|
|
750
|
-
const We = new Array(
|
|
750
|
+
const We = new Array(se);
|
|
751
751
|
F(We);
|
|
752
|
-
const ze = new Array(
|
|
752
|
+
const ze = new Array(ne);
|
|
753
753
|
F(ze);
|
|
754
|
-
const Pe = (i, e, t,
|
|
755
|
-
let a = i & 65535 | 0,
|
|
754
|
+
const Pe = (i, e, t, s) => {
|
|
755
|
+
let a = i & 65535 | 0, n = i >>> 16 & 65535 | 0, l = 0;
|
|
756
756
|
for (; t !== 0; ) {
|
|
757
757
|
l = t > 2e3 ? 2e3 : t, t -= l;
|
|
758
758
|
do
|
|
759
|
-
a = a + e[
|
|
759
|
+
a = a + e[s++] | 0, n = n + a | 0;
|
|
760
760
|
while (--l);
|
|
761
|
-
a %= 65521,
|
|
761
|
+
a %= 65521, n %= 65521;
|
|
762
762
|
}
|
|
763
|
-
return a |
|
|
763
|
+
return a | n << 16 | 0;
|
|
764
764
|
};
|
|
765
765
|
var ut = Pe;
|
|
766
766
|
const Ge = () => {
|
|
767
767
|
let i, e = [];
|
|
768
768
|
for (var t = 0; t < 256; t++) {
|
|
769
769
|
i = t;
|
|
770
|
-
for (var
|
|
770
|
+
for (var s = 0; s < 8; s++)
|
|
771
771
|
i = i & 1 ? 3988292384 ^ i >>> 1 : i >>> 1;
|
|
772
772
|
e[t] = i;
|
|
773
773
|
}
|
|
774
774
|
return e;
|
|
775
|
-
}, Ke = new Uint32Array(Ge()), Ye = (i, e, t,
|
|
776
|
-
const a = Ke,
|
|
775
|
+
}, Ke = new Uint32Array(Ge()), Ye = (i, e, t, s) => {
|
|
776
|
+
const a = Ke, n = s + t;
|
|
777
777
|
i ^= -1;
|
|
778
|
-
for (let l =
|
|
778
|
+
for (let l = s; l < n; l++)
|
|
779
779
|
i = i >>> 8 ^ a[(i ^ e[l]) & 255];
|
|
780
780
|
return i ^ -1;
|
|
781
781
|
};
|
|
@@ -826,18 +826,18 @@ var Xe = function(i) {
|
|
|
826
826
|
if (t) {
|
|
827
827
|
if (typeof t != "object")
|
|
828
828
|
throw new TypeError(t + "must be non-object");
|
|
829
|
-
for (const
|
|
830
|
-
je(t,
|
|
829
|
+
for (const s in t)
|
|
830
|
+
je(t, s) && (i[s] = t[s]);
|
|
831
831
|
}
|
|
832
832
|
}
|
|
833
833
|
return i;
|
|
834
834
|
}, Ve = (i) => {
|
|
835
835
|
let e = 0;
|
|
836
|
-
for (let
|
|
837
|
-
e += i[
|
|
836
|
+
for (let s = 0, a = i.length; s < a; s++)
|
|
837
|
+
e += i[s].length;
|
|
838
838
|
const t = new Uint8Array(e);
|
|
839
|
-
for (let
|
|
840
|
-
let l = i[
|
|
839
|
+
for (let s = 0, a = 0, n = i.length; s < n; s++) {
|
|
840
|
+
let l = i[s];
|
|
841
841
|
t.set(l, a), a += l.length;
|
|
842
842
|
}
|
|
843
843
|
return t;
|
|
@@ -858,47 +858,47 @@ Z[254] = Z[254] = 1;
|
|
|
858
858
|
var qe = (i) => {
|
|
859
859
|
if (typeof TextEncoder == "function" && TextEncoder.prototype.encode)
|
|
860
860
|
return new TextEncoder().encode(i);
|
|
861
|
-
let e, t,
|
|
861
|
+
let e, t, s, a, n, l = i.length, h = 0;
|
|
862
862
|
for (a = 0; a < l; a++)
|
|
863
|
-
t = i.charCodeAt(a), (t & 64512) === 55296 && a + 1 < l && (
|
|
864
|
-
for (e = new Uint8Array(h),
|
|
865
|
-
t = i.charCodeAt(a), (t & 64512) === 55296 && a + 1 < l && (
|
|
863
|
+
t = i.charCodeAt(a), (t & 64512) === 55296 && a + 1 < l && (s = i.charCodeAt(a + 1), (s & 64512) === 56320 && (t = 65536 + (t - 55296 << 10) + (s - 56320), a++)), h += t < 128 ? 1 : t < 2048 ? 2 : t < 65536 ? 3 : 4;
|
|
864
|
+
for (e = new Uint8Array(h), n = 0, a = 0; n < h; a++)
|
|
865
|
+
t = i.charCodeAt(a), (t & 64512) === 55296 && a + 1 < l && (s = i.charCodeAt(a + 1), (s & 64512) === 56320 && (t = 65536 + (t - 55296 << 10) + (s - 56320), a++)), t < 128 ? e[n++] = t : t < 2048 ? (e[n++] = 192 | t >>> 6, e[n++] = 128 | t & 63) : t < 65536 ? (e[n++] = 224 | t >>> 12, e[n++] = 128 | t >>> 6 & 63, e[n++] = 128 | t & 63) : (e[n++] = 240 | t >>> 18, e[n++] = 128 | t >>> 12 & 63, e[n++] = 128 | t >>> 6 & 63, e[n++] = 128 | t & 63);
|
|
866
866
|
return e;
|
|
867
867
|
};
|
|
868
868
|
const Je = (i, e) => {
|
|
869
869
|
if (e < 65534 && i.subarray && oe)
|
|
870
870
|
return String.fromCharCode.apply(null, i.length === e ? i : i.subarray(0, e));
|
|
871
871
|
let t = "";
|
|
872
|
-
for (let
|
|
873
|
-
t += String.fromCharCode(i[
|
|
872
|
+
for (let s = 0; s < e; s++)
|
|
873
|
+
t += String.fromCharCode(i[s]);
|
|
874
874
|
return t;
|
|
875
875
|
};
|
|
876
876
|
var Qe = (i, e) => {
|
|
877
877
|
const t = e || i.length;
|
|
878
878
|
if (typeof TextDecoder == "function" && TextDecoder.prototype.decode)
|
|
879
879
|
return new TextDecoder().decode(i.subarray(0, e));
|
|
880
|
-
let
|
|
881
|
-
const
|
|
882
|
-
for (a = 0,
|
|
883
|
-
let l = i[
|
|
880
|
+
let s, a;
|
|
881
|
+
const n = new Array(t * 2);
|
|
882
|
+
for (a = 0, s = 0; s < t; ) {
|
|
883
|
+
let l = i[s++];
|
|
884
884
|
if (l < 128) {
|
|
885
|
-
|
|
885
|
+
n[a++] = l;
|
|
886
886
|
continue;
|
|
887
887
|
}
|
|
888
888
|
let h = Z[l];
|
|
889
889
|
if (h > 4) {
|
|
890
|
-
|
|
890
|
+
n[a++] = 65533, s += h - 1;
|
|
891
891
|
continue;
|
|
892
892
|
}
|
|
893
|
-
for (l &= h === 2 ? 31 : h === 3 ? 15 : 7; h > 1 &&
|
|
894
|
-
l = l << 6 | i[
|
|
893
|
+
for (l &= h === 2 ? 31 : h === 3 ? 15 : 7; h > 1 && s < t; )
|
|
894
|
+
l = l << 6 | i[s++] & 63, h--;
|
|
895
895
|
if (h > 1) {
|
|
896
|
-
|
|
896
|
+
n[a++] = 65533;
|
|
897
897
|
continue;
|
|
898
898
|
}
|
|
899
|
-
l < 65536 ?
|
|
899
|
+
l < 65536 ? n[a++] = l : (l -= 65536, n[a++] = 55296 | l >> 10 & 1023, n[a++] = 56320 | l & 1023);
|
|
900
900
|
}
|
|
901
|
-
return Je(
|
|
901
|
+
return Je(n, a);
|
|
902
902
|
}, ti = (i, e) => {
|
|
903
903
|
e = e || i.length, e > i.length && (e = i.length);
|
|
904
904
|
let t = e - 1;
|
|
@@ -914,28 +914,28 @@ function ei() {
|
|
|
914
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;
|
|
915
915
|
}
|
|
916
916
|
var ii = ei;
|
|
917
|
-
const K = 16209,
|
|
918
|
-
var
|
|
919
|
-
let
|
|
917
|
+
const K = 16209, si = 16191;
|
|
918
|
+
var ni = function(e, t) {
|
|
919
|
+
let s, a, n, l, h, d, r, o, w, u, f, _, U, x, g, T, y, c, E, S, p, m, A, b;
|
|
920
920
|
const k = e.state;
|
|
921
|
-
|
|
921
|
+
s = e.next_in, A = e.input, a = s + (e.avail_in - 5), n = e.next_out, b = e.output, l = n - (t - e.avail_out), h = n + (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;
|
|
922
922
|
t:
|
|
923
923
|
do {
|
|
924
|
-
_ < 15 && (f += A[
|
|
924
|
+
_ < 15 && (f += A[s++] << _, _ += 8, f += A[s++] << _, _ += 8), y = U[f & g];
|
|
925
925
|
e:
|
|
926
926
|
for (; ; ) {
|
|
927
927
|
if (c = y >>> 24, f >>>= c, _ -= c, c = y >>> 16 & 255, c === 0)
|
|
928
|
-
b[
|
|
928
|
+
b[n++] = y & 65535;
|
|
929
929
|
else if (c & 16) {
|
|
930
|
-
E = y & 65535, c &= 15, c && (_ < c && (f += A[
|
|
930
|
+
E = y & 65535, c &= 15, c && (_ < c && (f += A[s++] << _, _ += 8), E += f & (1 << c) - 1, f >>>= c, _ -= c), _ < 15 && (f += A[s++] << _, _ += 8, f += A[s++] << _, _ += 8), y = x[f & T];
|
|
931
931
|
i:
|
|
932
932
|
for (; ; ) {
|
|
933
933
|
if (c = y >>> 24, f >>>= c, _ -= c, c = y >>> 16 & 255, c & 16) {
|
|
934
|
-
if (S = y & 65535, c &= 15, _ < c && (f += A[
|
|
934
|
+
if (S = y & 65535, c &= 15, _ < c && (f += A[s++] << _, _ += 8, _ < c && (f += A[s++] << _, _ += 8)), S += f & (1 << c) - 1, S > d) {
|
|
935
935
|
e.msg = "invalid distance too far back", k.mode = K;
|
|
936
936
|
break t;
|
|
937
937
|
}
|
|
938
|
-
if (f >>>= c, _ -= c, c =
|
|
938
|
+
if (f >>>= c, _ -= c, c = n - l, S > c) {
|
|
939
939
|
if (c = S - c, c > o && k.sane) {
|
|
940
940
|
e.msg = "invalid distance too far back", k.mode = K;
|
|
941
941
|
break t;
|
|
@@ -944,40 +944,40 @@ var si = function(e, t) {
|
|
|
944
944
|
if (p += r - c, c < E) {
|
|
945
945
|
E -= c;
|
|
946
946
|
do
|
|
947
|
-
b[
|
|
947
|
+
b[n++] = u[p++];
|
|
948
948
|
while (--c);
|
|
949
|
-
p =
|
|
949
|
+
p = n - S, m = b;
|
|
950
950
|
}
|
|
951
951
|
} else if (w < c) {
|
|
952
952
|
if (p += r + w - c, c -= w, c < E) {
|
|
953
953
|
E -= c;
|
|
954
954
|
do
|
|
955
|
-
b[
|
|
955
|
+
b[n++] = u[p++];
|
|
956
956
|
while (--c);
|
|
957
957
|
if (p = 0, w < E) {
|
|
958
958
|
c = w, E -= c;
|
|
959
959
|
do
|
|
960
|
-
b[
|
|
960
|
+
b[n++] = u[p++];
|
|
961
961
|
while (--c);
|
|
962
|
-
p =
|
|
962
|
+
p = n - S, m = b;
|
|
963
963
|
}
|
|
964
964
|
}
|
|
965
965
|
} else if (p += w - c, c < E) {
|
|
966
966
|
E -= c;
|
|
967
967
|
do
|
|
968
|
-
b[
|
|
968
|
+
b[n++] = u[p++];
|
|
969
969
|
while (--c);
|
|
970
|
-
p =
|
|
970
|
+
p = n - S, m = b;
|
|
971
971
|
}
|
|
972
972
|
for (; E > 2; )
|
|
973
|
-
b[
|
|
974
|
-
E && (b[
|
|
973
|
+
b[n++] = m[p++], b[n++] = m[p++], b[n++] = m[p++], E -= 3;
|
|
974
|
+
E && (b[n++] = m[p++], E > 1 && (b[n++] = m[p++]));
|
|
975
975
|
} else {
|
|
976
|
-
p =
|
|
976
|
+
p = n - S;
|
|
977
977
|
do
|
|
978
|
-
b[
|
|
978
|
+
b[n++] = b[p++], b[n++] = b[p++], b[n++] = b[p++], E -= 3;
|
|
979
979
|
while (E > 2);
|
|
980
|
-
E && (b[
|
|
980
|
+
E && (b[n++] = b[p++], E > 1 && (b[n++] = b[p++]));
|
|
981
981
|
}
|
|
982
982
|
} else if ((c & 64) === 0) {
|
|
983
983
|
y = x[(y & 65535) + (f & (1 << c) - 1)];
|
|
@@ -992,7 +992,7 @@ var si = function(e, t) {
|
|
|
992
992
|
y = U[(y & 65535) + (f & (1 << c) - 1)];
|
|
993
993
|
continue e;
|
|
994
994
|
} else if (c & 32) {
|
|
995
|
-
k.mode =
|
|
995
|
+
k.mode = si;
|
|
996
996
|
break t;
|
|
997
997
|
} else {
|
|
998
998
|
e.msg = "invalid literal/length code", k.mode = K;
|
|
@@ -1000,8 +1000,8 @@ var si = function(e, t) {
|
|
|
1000
1000
|
}
|
|
1001
1001
|
break;
|
|
1002
1002
|
}
|
|
1003
|
-
} while (
|
|
1004
|
-
E = _ >> 3,
|
|
1003
|
+
} while (s < a && n < h);
|
|
1004
|
+
E = _ >> 3, s -= E, _ -= E << 3, f &= (1 << _) - 1, e.next_in = s, e.next_out = n, e.avail_in = s < a ? 5 + (a - s) : 5 - (s - a), e.avail_out = n < h ? 257 + (h - n) : 257 - (n - h), k.hold = f, k.bits = _;
|
|
1005
1005
|
};
|
|
1006
1006
|
const $ = 15, xt = 852, yt = 592, kt = 0, it = 1, Et = 2, ai = new Uint16Array([
|
|
1007
1007
|
/* Length codes 257..285 base */
|
|
@@ -1137,19 +1137,19 @@ const $ = 15, xt = 852, yt = 592, kt = 0, it = 1, Et = 2, ai = new Uint16Array([
|
|
|
1137
1137
|
29,
|
|
1138
1138
|
64,
|
|
1139
1139
|
64
|
|
1140
|
-
]), li = (i, e, t,
|
|
1140
|
+
]), li = (i, e, t, s, a, n, l, h) => {
|
|
1141
1141
|
const d = h.bits;
|
|
1142
1142
|
let r = 0, o = 0, w = 0, u = 0, f = 0, _ = 0, U = 0, x = 0, g = 0, T = 0, y, c, E, S, p, m = null, A;
|
|
1143
1143
|
const b = new Uint16Array($ + 1), k = new Uint16Array($ + 1);
|
|
1144
1144
|
let M = null, gt, P, G;
|
|
1145
1145
|
for (r = 0; r <= $; r++)
|
|
1146
1146
|
b[r] = 0;
|
|
1147
|
-
for (o = 0; o <
|
|
1147
|
+
for (o = 0; o < s; o++)
|
|
1148
1148
|
b[e[t + o]]++;
|
|
1149
1149
|
for (f = d, u = $; u >= 1 && b[u] === 0; u--)
|
|
1150
1150
|
;
|
|
1151
1151
|
if (f > u && (f = u), u === 0)
|
|
1152
|
-
return a[
|
|
1152
|
+
return a[n++] = 1 << 24 | 64 << 16 | 0, a[n++] = 1 << 24 | 64 << 16 | 0, h.bits = 1, 0;
|
|
1153
1153
|
for (w = 1; w < u && b[w] === 0; w++)
|
|
1154
1154
|
;
|
|
1155
1155
|
for (f < w && (f = w), x = 1, r = 1; r <= $; r++)
|
|
@@ -1159,9 +1159,9 @@ const $ = 15, xt = 852, yt = 592, kt = 0, it = 1, Et = 2, ai = new Uint16Array([
|
|
|
1159
1159
|
return -1;
|
|
1160
1160
|
for (k[1] = 0, r = 1; r < $; r++)
|
|
1161
1161
|
k[r + 1] = k[r] + b[r];
|
|
1162
|
-
for (o = 0; o <
|
|
1162
|
+
for (o = 0; o < s; o++)
|
|
1163
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 =
|
|
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 = n, _ = f, U = 0, E = -1, g = 1 << f, S = g - 1, i === it && g > xt || i === Et && g > yt)
|
|
1165
1165
|
return 1;
|
|
1166
1166
|
for (; ; ) {
|
|
1167
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;
|
|
@@ -1180,7 +1180,7 @@ const $ = 15, xt = 852, yt = 592, kt = 0, it = 1, Et = 2, ai = new Uint16Array([
|
|
|
1180
1180
|
_++, x <<= 1;
|
|
1181
1181
|
if (g += 1 << _, i === it && g > xt || i === Et && g > yt)
|
|
1182
1182
|
return 1;
|
|
1183
|
-
E = T & S, a[E] = f << 24 | _ << 16 | p -
|
|
1183
|
+
E = T & S, a[E] = f << 24 | _ << 16 | p - n | 0;
|
|
1184
1184
|
}
|
|
1185
1185
|
}
|
|
1186
1186
|
return T !== 0 && (a[p + T] = r - U << 24 | 64 << 16 | 0), h.bits = f, 0;
|
|
@@ -1198,7 +1198,7 @@ const fi = 0, he = 1, le = 2, {
|
|
|
1198
1198
|
Z_MEM_ERROR: ce,
|
|
1199
1199
|
Z_BUF_ERROR: _i,
|
|
1200
1200
|
Z_DEFLATED: Tt
|
|
1201
|
-
} = ae, tt = 16180, mt = 16181, vt = 16182, Ut = 16183, St = 16184, It = 16185, Ot = 16186, Rt = 16187, Ct = 16188,
|
|
1201
|
+
} = ae, tt = 16180, mt = 16181, vt = 16182, Ut = 16183, St = 16184, It = 16185, Ot = 16186, Rt = 16187, Ct = 16188, Dt = 16189, Q = 16190, C = 16191, st = 16192, Nt = 16193, nt = 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);
|
|
1202
1202
|
function xi() {
|
|
1203
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;
|
|
1204
1204
|
}
|
|
@@ -1221,15 +1221,15 @@ const B = (i) => {
|
|
|
1221
1221
|
let t;
|
|
1222
1222
|
if (B(i))
|
|
1223
1223
|
return O;
|
|
1224
|
-
const
|
|
1225
|
-
return e < 0 ? (t = 0, e = -e) : (t = (e >> 4) + 5, e < 48 && (e &= 15)), e && (e < 8 || e > 15) ? O : (
|
|
1224
|
+
const s = i.state;
|
|
1225
|
+
return e < 0 ? (t = 0, e = -e) : (t = (e >> 4) + 5, e < 48 && (e &= 15)), e && (e < 8 || e > 15) ? O : (s.window !== null && s.wbits !== e && (s.window = null), s.wrap = t, s.wbits = e, pe(i));
|
|
1226
1226
|
}, ge = (i, e) => {
|
|
1227
1227
|
if (!i)
|
|
1228
1228
|
return O;
|
|
1229
1229
|
const t = new xi();
|
|
1230
1230
|
i.state = t, t.strm = i, t.window = null, t.mode = tt;
|
|
1231
|
-
const
|
|
1232
|
-
return
|
|
1231
|
+
const s = we(i, e);
|
|
1232
|
+
return s !== L && (i.state = null), s;
|
|
1233
1233
|
}, yi = (i) => ge(i, bi);
|
|
1234
1234
|
let Yt = !0, rt, ot;
|
|
1235
1235
|
const ki = (i) => {
|
|
@@ -1249,12 +1249,12 @@ const ki = (i) => {
|
|
|
1249
1249
|
H(le, i.lens, 0, 32, ot, 0, i.work, { bits: 5 }), Yt = !1;
|
|
1250
1250
|
}
|
|
1251
1251
|
i.lencode = rt, i.lenbits = 9, i.distcode = ot, i.distbits = 5;
|
|
1252
|
-
}, be = (i, e, t,
|
|
1252
|
+
}, be = (i, e, t, s) => {
|
|
1253
1253
|
let a;
|
|
1254
|
-
const
|
|
1255
|
-
return
|
|
1254
|
+
const n = i.state;
|
|
1255
|
+
return n.window === null && (n.wsize = 1 << n.wbits, n.wnext = 0, n.whave = 0, n.window = new Uint8Array(n.wsize)), s >= n.wsize ? (n.window.set(e.subarray(t - n.wsize, t), 0), n.wnext = 0, n.whave = n.wsize) : (a = n.wsize - n.wnext, a > s && (a = s), n.window.set(e.subarray(t - s, t - s + a), n.wnext), s -= a, s ? (n.window.set(e.subarray(t - s, t), 0), n.wnext = s, n.whave = n.wsize) : (n.wnext += a, n.wnext === n.wsize && (n.wnext = 0), n.whave < n.wsize && (n.whave += a))), 0;
|
|
1256
1256
|
}, Ei = (i, e) => {
|
|
1257
|
-
let t,
|
|
1257
|
+
let t, s, a, n, l, h, d, r, o, w, u, f, _, U, x = 0, g, T, y, c, E, S, p, m;
|
|
1258
1258
|
const A = new Uint8Array(4);
|
|
1259
1259
|
let b, k;
|
|
1260
1260
|
const M = (
|
|
@@ -1263,19 +1263,19 @@ const ki = (i) => {
|
|
|
1263
1263
|
);
|
|
1264
1264
|
if (B(i) || !i.output || !i.input && i.avail_in !== 0)
|
|
1265
1265
|
return O;
|
|
1266
|
-
t = i.state, t.mode === C && (t.mode =
|
|
1266
|
+
t = i.state, t.mode === C && (t.mode = st), l = i.next_out, a = i.output, d = i.avail_out, n = i.next_in, s = i.input, h = i.avail_in, r = t.hold, o = t.bits, w = h, u = d, m = L;
|
|
1267
1267
|
t:
|
|
1268
1268
|
for (; ; )
|
|
1269
1269
|
switch (t.mode) {
|
|
1270
1270
|
case tt:
|
|
1271
1271
|
if (t.wrap === 0) {
|
|
1272
|
-
t.mode =
|
|
1272
|
+
t.mode = st;
|
|
1273
1273
|
break;
|
|
1274
1274
|
}
|
|
1275
1275
|
for (; o < 16; ) {
|
|
1276
1276
|
if (h === 0)
|
|
1277
1277
|
break t;
|
|
1278
|
-
h--, r += n
|
|
1278
|
+
h--, r += s[n++] << o, o += 8;
|
|
1279
1279
|
}
|
|
1280
1280
|
if (t.wrap & 2 && r === 35615) {
|
|
1281
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;
|
|
@@ -1294,13 +1294,13 @@ const ki = (i) => {
|
|
|
1294
1294
|
i.msg = "invalid window size", t.mode = v;
|
|
1295
1295
|
break;
|
|
1296
1296
|
}
|
|
1297
|
-
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 ? Dt : C, r = 0, o = 0;
|
|
1298
1298
|
break;
|
|
1299
1299
|
case mt:
|
|
1300
1300
|
for (; o < 16; ) {
|
|
1301
1301
|
if (h === 0)
|
|
1302
1302
|
break t;
|
|
1303
|
-
h--, r += n
|
|
1303
|
+
h--, r += s[n++] << o, o += 8;
|
|
1304
1304
|
}
|
|
1305
1305
|
if (t.flags = r, (t.flags & 255) !== Tt) {
|
|
1306
1306
|
i.msg = "unknown compression method", t.mode = v;
|
|
@@ -1316,7 +1316,7 @@ const ki = (i) => {
|
|
|
1316
1316
|
for (; o < 32; ) {
|
|
1317
1317
|
if (h === 0)
|
|
1318
1318
|
break t;
|
|
1319
|
-
h--, r += n
|
|
1319
|
+
h--, r += s[n++] << o, o += 8;
|
|
1320
1320
|
}
|
|
1321
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;
|
|
1322
1322
|
/* falls through */
|
|
@@ -1324,7 +1324,7 @@ const ki = (i) => {
|
|
|
1324
1324
|
for (; o < 16; ) {
|
|
1325
1325
|
if (h === 0)
|
|
1326
1326
|
break t;
|
|
1327
|
-
h--, r += n
|
|
1327
|
+
h--, r += s[n++] << o, o += 8;
|
|
1328
1328
|
}
|
|
1329
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 = St;
|
|
1330
1330
|
/* falls through */
|
|
@@ -1333,7 +1333,7 @@ const ki = (i) => {
|
|
|
1333
1333
|
for (; o < 16; ) {
|
|
1334
1334
|
if (h === 0)
|
|
1335
1335
|
break t;
|
|
1336
|
-
h--, r += n
|
|
1336
|
+
h--, r += s[n++] << o, o += 8;
|
|
1337
1337
|
}
|
|
1338
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;
|
|
1339
1339
|
} else t.head && (t.head.extra = null);
|
|
@@ -1341,15 +1341,15 @@ const ki = (i) => {
|
|
|
1341
1341
|
/* falls through */
|
|
1342
1342
|
case It:
|
|
1343
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(
|
|
1344
|
-
|
|
1345
|
-
|
|
1344
|
+
s.subarray(
|
|
1345
|
+
n,
|
|
1346
1346
|
// extra field is limited to 65536 bytes
|
|
1347
1347
|
// - no need for additional size check
|
|
1348
|
-
|
|
1348
|
+
n + f
|
|
1349
1349
|
),
|
|
1350
1350
|
/*len + copy > state.head.extra_max - len ? state.head.extra_max : copy,*/
|
|
1351
1351
|
p
|
|
1352
|
-
)), t.flags & 512 && t.wrap & 4 && (t.check = R(t.check,
|
|
1352
|
+
)), t.flags & 512 && t.wrap & 4 && (t.check = R(t.check, s, f, n)), h -= f, n += f, t.length -= f), t.length))
|
|
1353
1353
|
break t;
|
|
1354
1354
|
t.length = 0, t.mode = Ot;
|
|
1355
1355
|
/* falls through */
|
|
@@ -1359,9 +1359,9 @@ const ki = (i) => {
|
|
|
1359
1359
|
break t;
|
|
1360
1360
|
f = 0;
|
|
1361
1361
|
do
|
|
1362
|
-
p = n
|
|
1362
|
+
p = s[n + f++], t.head && p && t.length < 65536 && (t.head.name += String.fromCharCode(p));
|
|
1363
1363
|
while (p && f < h);
|
|
1364
|
-
if (t.flags & 512 && t.wrap & 4 && (t.check = R(t.check,
|
|
1364
|
+
if (t.flags & 512 && t.wrap & 4 && (t.check = R(t.check, s, f, n)), h -= f, n += f, p)
|
|
1365
1365
|
break t;
|
|
1366
1366
|
} else t.head && (t.head.name = null);
|
|
1367
1367
|
t.length = 0, t.mode = Rt;
|
|
@@ -1372,9 +1372,9 @@ const ki = (i) => {
|
|
|
1372
1372
|
break t;
|
|
1373
1373
|
f = 0;
|
|
1374
1374
|
do
|
|
1375
|
-
p = n
|
|
1375
|
+
p = s[n + f++], t.head && p && t.length < 65536 && (t.head.comment += String.fromCharCode(p));
|
|
1376
1376
|
while (p && f < h);
|
|
1377
|
-
if (t.flags & 512 && t.wrap & 4 && (t.check = R(t.check,
|
|
1377
|
+
if (t.flags & 512 && t.wrap & 4 && (t.check = R(t.check, s, f, n)), h -= f, n += f, p)
|
|
1378
1378
|
break t;
|
|
1379
1379
|
} else t.head && (t.head.comment = null);
|
|
1380
1380
|
t.mode = Ct;
|
|
@@ -1384,7 +1384,7 @@ const ki = (i) => {
|
|
|
1384
1384
|
for (; o < 16; ) {
|
|
1385
1385
|
if (h === 0)
|
|
1386
1386
|
break t;
|
|
1387
|
-
h--, r += n
|
|
1387
|
+
h--, r += s[n++] << o, o += 8;
|
|
1388
1388
|
}
|
|
1389
1389
|
if (t.wrap & 4 && r !== (t.check & 65535)) {
|
|
1390
1390
|
i.msg = "header crc mismatch", t.mode = v;
|
|
@@ -1394,24 +1394,24 @@ const ki = (i) => {
|
|
|
1394
1394
|
}
|
|
1395
1395
|
t.head && (t.head.hcrc = t.flags >> 9 & 1, t.head.done = !0), i.adler = t.check = 0, t.mode = C;
|
|
1396
1396
|
break;
|
|
1397
|
-
case
|
|
1397
|
+
case Dt:
|
|
1398
1398
|
for (; o < 32; ) {
|
|
1399
1399
|
if (h === 0)
|
|
1400
1400
|
break t;
|
|
1401
|
-
h--, r += n
|
|
1401
|
+
h--, r += s[n++] << o, o += 8;
|
|
1402
1402
|
}
|
|
1403
1403
|
i.adler = t.check = Kt(r), r = 0, o = 0, t.mode = Q;
|
|
1404
1404
|
/* falls through */
|
|
1405
1405
|
case Q:
|
|
1406
1406
|
if (t.havedict === 0)
|
|
1407
|
-
return i.next_out = l, i.avail_out = d, i.next_in =
|
|
1407
|
+
return i.next_out = l, i.avail_out = d, i.next_in = n, i.avail_in = h, t.hold = r, t.bits = o, ui;
|
|
1408
1408
|
i.adler = t.check = 1, t.mode = C;
|
|
1409
1409
|
/* falls through */
|
|
1410
1410
|
case C:
|
|
1411
1411
|
if (e === ci || e === Y)
|
|
1412
1412
|
break t;
|
|
1413
1413
|
/* falls through */
|
|
1414
|
-
case
|
|
1414
|
+
case st:
|
|
1415
1415
|
if (t.last) {
|
|
1416
1416
|
r >>>= o & 7, o -= o & 7, t.mode = at;
|
|
1417
1417
|
break;
|
|
@@ -1419,11 +1419,11 @@ const ki = (i) => {
|
|
|
1419
1419
|
for (; o < 3; ) {
|
|
1420
1420
|
if (h === 0)
|
|
1421
1421
|
break t;
|
|
1422
|
-
h--, r += n
|
|
1422
|
+
h--, r += s[n++] << o, o += 8;
|
|
1423
1423
|
}
|
|
1424
1424
|
switch (t.last = r & 1, r >>>= 1, o -= 1, r & 3) {
|
|
1425
1425
|
case 0:
|
|
1426
|
-
t.mode =
|
|
1426
|
+
t.mode = Nt;
|
|
1427
1427
|
break;
|
|
1428
1428
|
case 1:
|
|
1429
1429
|
if (ki(t), t.mode = j, e === Y) {
|
|
@@ -1439,27 +1439,27 @@ const ki = (i) => {
|
|
|
1439
1439
|
}
|
|
1440
1440
|
r >>>= 2, o -= 2;
|
|
1441
1441
|
break;
|
|
1442
|
-
case
|
|
1442
|
+
case Nt:
|
|
1443
1443
|
for (r >>>= o & 7, o -= o & 7; o < 32; ) {
|
|
1444
1444
|
if (h === 0)
|
|
1445
1445
|
break t;
|
|
1446
|
-
h--, r += n
|
|
1446
|
+
h--, r += s[n++] << o, o += 8;
|
|
1447
1447
|
}
|
|
1448
1448
|
if ((r & 65535) !== (r >>> 16 ^ 65535)) {
|
|
1449
1449
|
i.msg = "invalid stored block lengths", t.mode = v;
|
|
1450
1450
|
break;
|
|
1451
1451
|
}
|
|
1452
|
-
if (t.length = r & 65535, r = 0, o = 0, t.mode =
|
|
1452
|
+
if (t.length = r & 65535, r = 0, o = 0, t.mode = nt, e === Y)
|
|
1453
1453
|
break t;
|
|
1454
1454
|
/* falls through */
|
|
1455
|
-
case
|
|
1455
|
+
case nt:
|
|
1456
1456
|
t.mode = Mt;
|
|
1457
1457
|
/* falls through */
|
|
1458
1458
|
case Mt:
|
|
1459
1459
|
if (f = t.length, f) {
|
|
1460
1460
|
if (f > h && (f = h), f > d && (f = d), f === 0)
|
|
1461
1461
|
break t;
|
|
1462
|
-
a.set(
|
|
1462
|
+
a.set(s.subarray(n, n + f), l), h -= f, n += f, d -= f, l += f, t.length -= f;
|
|
1463
1463
|
break;
|
|
1464
1464
|
}
|
|
1465
1465
|
t.mode = C;
|
|
@@ -1468,7 +1468,7 @@ const ki = (i) => {
|
|
|
1468
1468
|
for (; o < 14; ) {
|
|
1469
1469
|
if (h === 0)
|
|
1470
1470
|
break t;
|
|
1471
|
-
h--, r += n
|
|
1471
|
+
h--, r += s[n++] << o, o += 8;
|
|
1472
1472
|
}
|
|
1473
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) {
|
|
1474
1474
|
i.msg = "too many length or distance symbols", t.mode = v;
|
|
@@ -1481,7 +1481,7 @@ const ki = (i) => {
|
|
|
1481
1481
|
for (; o < 3; ) {
|
|
1482
1482
|
if (h === 0)
|
|
1483
1483
|
break t;
|
|
1484
|
-
h--, r += n
|
|
1484
|
+
h--, r += s[n++] << o, o += 8;
|
|
1485
1485
|
}
|
|
1486
1486
|
t.lens[M[t.have++]] = r & 7, r >>>= 3, o -= 3;
|
|
1487
1487
|
}
|
|
@@ -1498,7 +1498,7 @@ const ki = (i) => {
|
|
|
1498
1498
|
for (; x = t.lencode[r & (1 << t.lenbits) - 1], g = x >>> 24, T = x >>> 16 & 255, y = x & 65535, !(g <= o); ) {
|
|
1499
1499
|
if (h === 0)
|
|
1500
1500
|
break t;
|
|
1501
|
-
h--, r += n
|
|
1501
|
+
h--, r += s[n++] << o, o += 8;
|
|
1502
1502
|
}
|
|
1503
1503
|
if (y < 16)
|
|
1504
1504
|
r >>>= g, o -= g, t.lens[t.have++] = y;
|
|
@@ -1507,7 +1507,7 @@ const ki = (i) => {
|
|
|
1507
1507
|
for (k = g + 2; o < k; ) {
|
|
1508
1508
|
if (h === 0)
|
|
1509
1509
|
break t;
|
|
1510
|
-
h--, r += n
|
|
1510
|
+
h--, r += s[n++] << o, o += 8;
|
|
1511
1511
|
}
|
|
1512
1512
|
if (r >>>= g, o -= g, t.have === 0) {
|
|
1513
1513
|
i.msg = "invalid bit length repeat", t.mode = v;
|
|
@@ -1518,14 +1518,14 @@ const ki = (i) => {
|
|
|
1518
1518
|
for (k = g + 3; o < k; ) {
|
|
1519
1519
|
if (h === 0)
|
|
1520
1520
|
break t;
|
|
1521
|
-
h--, r += n
|
|
1521
|
+
h--, r += s[n++] << o, o += 8;
|
|
1522
1522
|
}
|
|
1523
1523
|
r >>>= g, o -= g, p = 0, f = 3 + (r & 7), r >>>= 3, o -= 3;
|
|
1524
1524
|
} else {
|
|
1525
1525
|
for (k = g + 7; o < k; ) {
|
|
1526
1526
|
if (h === 0)
|
|
1527
1527
|
break t;
|
|
1528
|
-
h--, r += n
|
|
1528
|
+
h--, r += s[n++] << o, o += 8;
|
|
1529
1529
|
}
|
|
1530
1530
|
r >>>= g, o -= g, p = 0, f = 11 + (r & 127), r >>>= 7, o -= 7;
|
|
1531
1531
|
}
|
|
@@ -1559,19 +1559,19 @@ const ki = (i) => {
|
|
|
1559
1559
|
/* falls through */
|
|
1560
1560
|
case X:
|
|
1561
1561
|
if (h >= 6 && d >= 258) {
|
|
1562
|
-
i.next_out = l, i.avail_out = d, i.next_in =
|
|
1562
|
+
i.next_out = l, i.avail_out = d, i.next_in = n, i.avail_in = h, t.hold = r, t.bits = o, ni(i, u), l = i.next_out, a = i.output, d = i.avail_out, n = i.next_in, s = i.input, h = i.avail_in, r = t.hold, o = t.bits, t.mode === C && (t.back = -1);
|
|
1563
1563
|
break;
|
|
1564
1564
|
}
|
|
1565
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); ) {
|
|
1566
1566
|
if (h === 0)
|
|
1567
1567
|
break t;
|
|
1568
|
-
h--, r += n
|
|
1568
|
+
h--, r += s[n++] << o, o += 8;
|
|
1569
1569
|
}
|
|
1570
1570
|
if (T && (T & 240) === 0) {
|
|
1571
1571
|
for (c = g, E = T, S = y; x = t.lencode[S + ((r & (1 << c + E) - 1) >> c)], g = x >>> 24, T = x >>> 16 & 255, y = x & 65535, !(c + g <= o); ) {
|
|
1572
1572
|
if (h === 0)
|
|
1573
1573
|
break t;
|
|
1574
|
-
h--, r += n
|
|
1574
|
+
h--, r += s[n++] << o, o += 8;
|
|
1575
1575
|
}
|
|
1576
1576
|
r >>>= c, o -= c, t.back += c;
|
|
1577
1577
|
}
|
|
@@ -1594,7 +1594,7 @@ const ki = (i) => {
|
|
|
1594
1594
|
for (k = t.extra; o < k; ) {
|
|
1595
1595
|
if (h === 0)
|
|
1596
1596
|
break t;
|
|
1597
|
-
h--, r += n
|
|
1597
|
+
h--, r += s[n++] << o, o += 8;
|
|
1598
1598
|
}
|
|
1599
1599
|
t.length += r & (1 << t.extra) - 1, r >>>= t.extra, o -= t.extra, t.back += t.extra;
|
|
1600
1600
|
}
|
|
@@ -1604,13 +1604,13 @@ const ki = (i) => {
|
|
|
1604
1604
|
for (; x = t.distcode[r & (1 << t.distbits) - 1], g = x >>> 24, T = x >>> 16 & 255, y = x & 65535, !(g <= o); ) {
|
|
1605
1605
|
if (h === 0)
|
|
1606
1606
|
break t;
|
|
1607
|
-
h--, r += n
|
|
1607
|
+
h--, r += s[n++] << o, o += 8;
|
|
1608
1608
|
}
|
|
1609
1609
|
if ((T & 240) === 0) {
|
|
1610
1610
|
for (c = g, E = T, S = y; x = t.distcode[S + ((r & (1 << c + E) - 1) >> c)], g = x >>> 24, T = x >>> 16 & 255, y = x & 65535, !(c + g <= o); ) {
|
|
1611
1611
|
if (h === 0)
|
|
1612
1612
|
break t;
|
|
1613
|
-
h--, r += n
|
|
1613
|
+
h--, r += s[n++] << o, o += 8;
|
|
1614
1614
|
}
|
|
1615
1615
|
r >>>= c, o -= c, t.back += c;
|
|
1616
1616
|
}
|
|
@@ -1625,7 +1625,7 @@ const ki = (i) => {
|
|
|
1625
1625
|
for (k = t.extra; o < k; ) {
|
|
1626
1626
|
if (h === 0)
|
|
1627
1627
|
break t;
|
|
1628
|
-
h--, r += n
|
|
1628
|
+
h--, r += s[n++] << o, o += 8;
|
|
1629
1629
|
}
|
|
1630
1630
|
t.offset += r & (1 << t.extra) - 1, r >>>= t.extra, o -= t.extra, t.back += t.extra;
|
|
1631
1631
|
}
|
|
@@ -1662,7 +1662,7 @@ const ki = (i) => {
|
|
|
1662
1662
|
for (; o < 32; ) {
|
|
1663
1663
|
if (h === 0)
|
|
1664
1664
|
break t;
|
|
1665
|
-
h--, r |= n
|
|
1665
|
+
h--, r |= s[n++] << o, o += 8;
|
|
1666
1666
|
}
|
|
1667
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);*/
|
|
1668
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) {
|
|
@@ -1678,7 +1678,7 @@ const ki = (i) => {
|
|
|
1678
1678
|
for (; o < 32; ) {
|
|
1679
1679
|
if (h === 0)
|
|
1680
1680
|
break t;
|
|
1681
|
-
h--, r += n
|
|
1681
|
+
h--, r += s[n++] << o, o += 8;
|
|
1682
1682
|
}
|
|
1683
1683
|
if (t.wrap & 4 && r !== (t.total & 4294967295)) {
|
|
1684
1684
|
i.msg = "incorrect length check", t.mode = v;
|
|
@@ -1701,8 +1701,8 @@ const ki = (i) => {
|
|
|
1701
1701
|
default:
|
|
1702
1702
|
return O;
|
|
1703
1703
|
}
|
|
1704
|
-
return i.next_out = l, i.avail_out = d, i.next_in =
|
|
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 ===
|
|
1704
|
+
return i.next_out = l, i.avail_out = d, i.next_in = n, 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 === nt ? 256 : 0), (w === 0 && u === 0 || e === At) && m === L && (m = _i), m;
|
|
1706
1706
|
}, Ai = (i) => {
|
|
1707
1707
|
if (B(i))
|
|
1708
1708
|
return O;
|
|
@@ -1715,10 +1715,10 @@ const ki = (i) => {
|
|
|
1715
1715
|
return (t.wrap & 2) === 0 ? O : (t.head = e, e.done = !1, L);
|
|
1716
1716
|
}, mi = (i, e) => {
|
|
1717
1717
|
const t = e.length;
|
|
1718
|
-
let
|
|
1719
|
-
return B(i) || (
|
|
1718
|
+
let s, a, n;
|
|
1719
|
+
return B(i) || (s = i.state, s.wrap !== 0 && s.mode !== Q) ? O : s.mode === Q && (a = 1, a = ut(a, e, t, 0), a !== s.check) ? fe : (n = be(i, e, t, t), n ? (s.mode = de, ce) : (s.havedict = 1, L));
|
|
1720
1720
|
};
|
|
1721
|
-
var vi = pe, Ui = we, Si = _e, Ii = yi, Oi = ge, Ri = Ei, Ci = Ai,
|
|
1721
|
+
var vi = pe, Ui = we, Si = _e, Ii = yi, Oi = ge, Ri = Ei, Ci = Ai, Di = Ti, Ni = mi, Mi = "pako inflate (from Nodeca project)", N = {
|
|
1722
1722
|
inflateReset: vi,
|
|
1723
1723
|
inflateReset2: Ui,
|
|
1724
1724
|
inflateResetKeep: Si,
|
|
@@ -1726,8 +1726,8 @@ var vi = pe, Ui = we, Si = _e, Ii = yi, Oi = ge, Ri = Ei, Ci = Ai, Ni = Ti, Di =
|
|
|
1726
1726
|
inflateInit2: Oi,
|
|
1727
1727
|
inflate: Ri,
|
|
1728
1728
|
inflateEnd: Ci,
|
|
1729
|
-
inflateGetHeader:
|
|
1730
|
-
inflateSetDictionary:
|
|
1729
|
+
inflateGetHeader: Di,
|
|
1730
|
+
inflateSetDictionary: Ni,
|
|
1731
1731
|
inflateInfo: Mi
|
|
1732
1732
|
};
|
|
1733
1733
|
function Li() {
|
|
@@ -1752,38 +1752,38 @@ function z(i) {
|
|
|
1752
1752
|
}, i || {});
|
|
1753
1753
|
const e = this.options;
|
|
1754
1754
|
e.raw && e.windowBits >= 0 && e.windowBits < 16 && (e.windowBits = -e.windowBits, e.windowBits === 0 && (e.windowBits = -15)), e.windowBits >= 0 && e.windowBits < 16 && !(i && i.windowBits) && (e.windowBits += 32), e.windowBits > 15 && e.windowBits < 48 && (e.windowBits & 15) === 0 && (e.windowBits |= 15), this.err = 0, this.msg = "", this.ended = !1, this.chunks = [], this.strm = new ii(), this.strm.avail_out = 0;
|
|
1755
|
-
let t =
|
|
1755
|
+
let t = N.inflateInit2(
|
|
1756
1756
|
this.strm,
|
|
1757
1757
|
e.windowBits
|
|
1758
1758
|
);
|
|
1759
1759
|
if (t !== W)
|
|
1760
1760
|
throw new Error(_t[t]);
|
|
1761
|
-
if (this.header = new Bi(),
|
|
1761
|
+
if (this.header = new Bi(), N.inflateGetHeader(this.strm, this.header), e.dictionary && (typeof e.dictionary == "string" ? e.dictionary = pt.string2buf(e.dictionary) : xe.call(e.dictionary) === "[object ArrayBuffer]" && (e.dictionary = new Uint8Array(e.dictionary)), e.raw && (t = N.inflateSetDictionary(this.strm, e.dictionary), t !== W)))
|
|
1762
1762
|
throw new Error(_t[t]);
|
|
1763
1763
|
}
|
|
1764
1764
|
z.prototype.push = function(i, e) {
|
|
1765
|
-
const t = this.strm,
|
|
1766
|
-
let
|
|
1765
|
+
const t = this.strm, s = this.options.chunkSize, a = this.options.dictionary;
|
|
1766
|
+
let n, l, h;
|
|
1767
1767
|
if (this.ended) return !1;
|
|
1768
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; ; ) {
|
|
1769
|
-
for (t.avail_out === 0 && (t.output = new Uint8Array(
|
|
1770
|
-
|
|
1771
|
-
switch (
|
|
1769
|
+
for (t.avail_out === 0 && (t.output = new Uint8Array(s), t.next_out = 0, t.avail_out = s), n = N.inflate(t, l), n === lt && a && (n = N.inflateSetDictionary(t, a), n === W ? n = N.inflate(t, l) : n === jt && (n = lt)); t.avail_in > 0 && n === ht && t.state.wrap > 0 && i[t.next_in] !== 0; )
|
|
1770
|
+
N.inflateReset(t), n = N.inflate(t, l);
|
|
1771
|
+
switch (n) {
|
|
1772
1772
|
case Hi:
|
|
1773
1773
|
case jt:
|
|
1774
1774
|
case lt:
|
|
1775
1775
|
case Zi:
|
|
1776
|
-
return this.onEnd(
|
|
1776
|
+
return this.onEnd(n), this.ended = !0, !1;
|
|
1777
1777
|
}
|
|
1778
|
-
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 || n === ht))
|
|
1779
1779
|
if (this.options.to === "string") {
|
|
1780
1780
|
let d = pt.utf8border(t.output, t.next_out), r = t.next_out - d, o = pt.buf2string(t.output, d);
|
|
1781
|
-
t.next_out = r, t.avail_out =
|
|
1781
|
+
t.next_out = r, t.avail_out = s - r, r && t.output.set(t.output.subarray(d, d + r), 0), this.onData(o);
|
|
1782
1782
|
} else
|
|
1783
1783
|
this.onData(t.output.length === t.next_out ? t.output : t.output.subarray(0, t.next_out));
|
|
1784
|
-
if (!(
|
|
1785
|
-
if (
|
|
1786
|
-
return
|
|
1784
|
+
if (!(n === W && h === 0)) {
|
|
1785
|
+
if (n === ht)
|
|
1786
|
+
return n = N.inflateEnd(this.strm), this.onEnd(n), this.ended = !0, !0;
|
|
1787
1787
|
if (t.avail_in === 0) break;
|
|
1788
1788
|
}
|
|
1789
1789
|
}
|
|
@@ -1815,95 +1815,95 @@ for (let i = 0; i < 256; i++) {
|
|
|
1815
1815
|
}
|
|
1816
1816
|
const Vt = 4294967295;
|
|
1817
1817
|
function Xi(i, e, t) {
|
|
1818
|
-
let
|
|
1818
|
+
let s = i;
|
|
1819
1819
|
for (let a = 0; a < t; a++)
|
|
1820
|
-
|
|
1821
|
-
return
|
|
1820
|
+
s = ye[(s ^ e[a]) & 255] ^ s >>> 8;
|
|
1821
|
+
return s;
|
|
1822
1822
|
}
|
|
1823
1823
|
function Vi(i, e) {
|
|
1824
1824
|
return (Xi(Vt, i, e) ^ Vt) >>> 0;
|
|
1825
1825
|
}
|
|
1826
1826
|
function qt(i, e, t) {
|
|
1827
|
-
const
|
|
1828
|
-
if (a !==
|
|
1829
|
-
throw new Error(`CRC mismatch for chunk ${t}. Expected ${
|
|
1827
|
+
const s = i.readUint32(), a = Vi(new Uint8Array(i.buffer, i.byteOffset + i.offset - e - 4, e), e);
|
|
1828
|
+
if (a !== s)
|
|
1829
|
+
throw new Error(`CRC mismatch for chunk ${t}. Expected ${s}, found ${a}`);
|
|
1830
1830
|
}
|
|
1831
1831
|
function ke(i, e, t) {
|
|
1832
|
-
for (let
|
|
1833
|
-
e[
|
|
1832
|
+
for (let s = 0; s < t; s++)
|
|
1833
|
+
e[s] = i[s];
|
|
1834
1834
|
}
|
|
1835
|
-
function Ee(i, e, t,
|
|
1835
|
+
function Ee(i, e, t, s) {
|
|
1836
1836
|
let a = 0;
|
|
1837
|
-
for (; a <
|
|
1837
|
+
for (; a < s; a++)
|
|
1838
1838
|
e[a] = i[a];
|
|
1839
1839
|
for (; a < t; a++)
|
|
1840
|
-
e[a] = i[a] + e[a -
|
|
1840
|
+
e[a] = i[a] + e[a - s] & 255;
|
|
1841
1841
|
}
|
|
1842
|
-
function Ae(i, e, t,
|
|
1842
|
+
function Ae(i, e, t, s) {
|
|
1843
1843
|
let a = 0;
|
|
1844
1844
|
if (t.length === 0)
|
|
1845
|
-
for (; a <
|
|
1845
|
+
for (; a < s; a++)
|
|
1846
1846
|
e[a] = i[a];
|
|
1847
1847
|
else
|
|
1848
|
-
for (; a <
|
|
1848
|
+
for (; a < s; a++)
|
|
1849
1849
|
e[a] = i[a] + t[a] & 255;
|
|
1850
1850
|
}
|
|
1851
|
-
function Te(i, e, t,
|
|
1852
|
-
let
|
|
1851
|
+
function Te(i, e, t, s, a) {
|
|
1852
|
+
let n = 0;
|
|
1853
1853
|
if (t.length === 0) {
|
|
1854
|
-
for (;
|
|
1855
|
-
e[
|
|
1856
|
-
for (;
|
|
1857
|
-
e[
|
|
1854
|
+
for (; n < a; n++)
|
|
1855
|
+
e[n] = i[n];
|
|
1856
|
+
for (; n < s; n++)
|
|
1857
|
+
e[n] = i[n] + (e[n - a] >> 1) & 255;
|
|
1858
1858
|
} else {
|
|
1859
|
-
for (;
|
|
1860
|
-
e[
|
|
1861
|
-
for (;
|
|
1862
|
-
e[
|
|
1859
|
+
for (; n < a; n++)
|
|
1860
|
+
e[n] = i[n] + (t[n] >> 1) & 255;
|
|
1861
|
+
for (; n < s; n++)
|
|
1862
|
+
e[n] = i[n] + (e[n - a] + t[n] >> 1) & 255;
|
|
1863
1863
|
}
|
|
1864
1864
|
}
|
|
1865
|
-
function me(i, e, t,
|
|
1866
|
-
let
|
|
1865
|
+
function me(i, e, t, s, a) {
|
|
1866
|
+
let n = 0;
|
|
1867
1867
|
if (t.length === 0) {
|
|
1868
|
-
for (;
|
|
1869
|
-
e[
|
|
1870
|
-
for (;
|
|
1871
|
-
e[
|
|
1868
|
+
for (; n < a; n++)
|
|
1869
|
+
e[n] = i[n];
|
|
1870
|
+
for (; n < s; n++)
|
|
1871
|
+
e[n] = i[n] + e[n - a] & 255;
|
|
1872
1872
|
} else {
|
|
1873
|
-
for (;
|
|
1874
|
-
e[
|
|
1875
|
-
for (;
|
|
1876
|
-
e[
|
|
1873
|
+
for (; n < a; n++)
|
|
1874
|
+
e[n] = i[n] + t[n] & 255;
|
|
1875
|
+
for (; n < s; n++)
|
|
1876
|
+
e[n] = i[n] + qi(e[n - a], t[n], t[n - a]) & 255;
|
|
1877
1877
|
}
|
|
1878
1878
|
}
|
|
1879
1879
|
function qi(i, e, t) {
|
|
1880
|
-
const
|
|
1881
|
-
return a <=
|
|
1880
|
+
const s = i + e - t, a = Math.abs(s - i), n = Math.abs(s - e), l = Math.abs(s - t);
|
|
1881
|
+
return a <= n && a <= l ? i : n <= l ? e : t;
|
|
1882
1882
|
}
|
|
1883
|
-
function Ji(i, e, t,
|
|
1883
|
+
function Ji(i, e, t, s, a, n) {
|
|
1884
1884
|
switch (i) {
|
|
1885
1885
|
case 0:
|
|
1886
1886
|
ke(e, t, a);
|
|
1887
1887
|
break;
|
|
1888
1888
|
case 1:
|
|
1889
|
-
Ee(e, t, a,
|
|
1889
|
+
Ee(e, t, a, n);
|
|
1890
1890
|
break;
|
|
1891
1891
|
case 2:
|
|
1892
|
-
Ae(e, t,
|
|
1892
|
+
Ae(e, t, s, a);
|
|
1893
1893
|
break;
|
|
1894
1894
|
case 3:
|
|
1895
|
-
Te(e, t,
|
|
1895
|
+
Te(e, t, s, a, n);
|
|
1896
1896
|
break;
|
|
1897
1897
|
case 4:
|
|
1898
|
-
me(e, t,
|
|
1898
|
+
me(e, t, s, a, n);
|
|
1899
1899
|
break;
|
|
1900
1900
|
default:
|
|
1901
1901
|
throw new Error(`Unsupported filter: ${i}`);
|
|
1902
1902
|
}
|
|
1903
1903
|
}
|
|
1904
|
-
const Qi = new Uint16Array([255]),
|
|
1905
|
-
function
|
|
1906
|
-
const { data: e, width: t, height:
|
|
1904
|
+
const Qi = new Uint16Array([255]), ts = new Uint8Array(Qi.buffer), es = ts[0] === 255;
|
|
1905
|
+
function is(i) {
|
|
1906
|
+
const { data: e, width: t, height: s, channels: a, depth: n } = i, l = [
|
|
1907
1907
|
{ x: 0, y: 0, xStep: 8, yStep: 8 },
|
|
1908
1908
|
// Pass 1
|
|
1909
1909
|
{ x: 4, y: 0, xStep: 8, yStep: 8 },
|
|
@@ -1918,10 +1918,10 @@ function nn(i) {
|
|
|
1918
1918
|
// Pass 6
|
|
1919
1919
|
{ x: 0, y: 1, xStep: 1, yStep: 2 }
|
|
1920
1920
|
// Pass 7
|
|
1921
|
-
], h = Math.ceil(
|
|
1921
|
+
], h = Math.ceil(n / 8) * a, d = new Uint8Array(s * t * h);
|
|
1922
1922
|
let r = 0;
|
|
1923
1923
|
for (let o = 0; o < 7; o++) {
|
|
1924
|
-
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((s - w.y) / w.yStep);
|
|
1925
1925
|
if (u <= 0 || f <= 0)
|
|
1926
1926
|
continue;
|
|
1927
1927
|
const _ = u * h, U = new Uint8Array(_);
|
|
@@ -1932,29 +1932,29 @@ function nn(i) {
|
|
|
1932
1932
|
Ji(g, T, y, U, _, h), U.set(y);
|
|
1933
1933
|
for (let c = 0; c < u; c++) {
|
|
1934
1934
|
const E = w.x + c * w.xStep, S = w.y + x * w.yStep;
|
|
1935
|
-
if (!(E >= t || S >=
|
|
1935
|
+
if (!(E >= t || S >= s))
|
|
1936
1936
|
for (let p = 0; p < h; p++)
|
|
1937
1937
|
d[(S * t + E) * h + p] = y[c * h + p];
|
|
1938
1938
|
}
|
|
1939
1939
|
}
|
|
1940
1940
|
}
|
|
1941
|
-
if (
|
|
1941
|
+
if (n === 16) {
|
|
1942
1942
|
const o = new Uint16Array(d.buffer);
|
|
1943
|
-
if (
|
|
1943
|
+
if (es)
|
|
1944
1944
|
for (let w = 0; w < o.length; w++)
|
|
1945
|
-
o[w] =
|
|
1945
|
+
o[w] = ss(o[w]);
|
|
1946
1946
|
return o;
|
|
1947
1947
|
} else
|
|
1948
1948
|
return d;
|
|
1949
1949
|
}
|
|
1950
|
-
function
|
|
1950
|
+
function ss(i) {
|
|
1951
1951
|
return (i & 255) << 8 | i >> 8 & 255;
|
|
1952
1952
|
}
|
|
1953
|
-
const
|
|
1953
|
+
const ns = new Uint16Array([255]), as = new Uint8Array(ns.buffer), rs = as[0] === 255, os = new Uint8Array(0);
|
|
1954
1954
|
function Jt(i) {
|
|
1955
|
-
const { data: e, width: t, height:
|
|
1956
|
-
let r =
|
|
1957
|
-
for (let f = 0; f <
|
|
1955
|
+
const { data: e, width: t, height: s, channels: a, depth: n } = i, l = Math.ceil(n / 8) * a, h = Math.ceil(n / 8 * a * t), d = new Uint8Array(s * h);
|
|
1956
|
+
let r = os, o = 0, w, u;
|
|
1957
|
+
for (let f = 0; f < s; f++) {
|
|
1958
1958
|
switch (w = e.subarray(o + 1, o + 1 + h), u = d.subarray(f * h, (f + 1) * h), e[o]) {
|
|
1959
1959
|
case 0:
|
|
1960
1960
|
ke(w, u, h);
|
|
@@ -1976,24 +1976,24 @@ function Jt(i) {
|
|
|
1976
1976
|
}
|
|
1977
1977
|
r = u, o += h + 1;
|
|
1978
1978
|
}
|
|
1979
|
-
if (
|
|
1979
|
+
if (n === 16) {
|
|
1980
1980
|
const f = new Uint16Array(d.buffer);
|
|
1981
|
-
if (
|
|
1981
|
+
if (rs)
|
|
1982
1982
|
for (let _ = 0; _ < f.length; _++)
|
|
1983
|
-
f[_] =
|
|
1983
|
+
f[_] = hs(f[_]);
|
|
1984
1984
|
return f;
|
|
1985
1985
|
} else
|
|
1986
1986
|
return d;
|
|
1987
1987
|
}
|
|
1988
|
-
function
|
|
1988
|
+
function hs(i) {
|
|
1989
1989
|
return (i & 255) << 8 | i >> 8 & 255;
|
|
1990
1990
|
}
|
|
1991
1991
|
const J = Uint8Array.of(137, 80, 78, 71, 13, 10, 26, 10);
|
|
1992
1992
|
function Qt(i) {
|
|
1993
|
-
if (!
|
|
1993
|
+
if (!ls(i.readBytes(J.length)))
|
|
1994
1994
|
throw new Error("wrong PNG signature");
|
|
1995
1995
|
}
|
|
1996
|
-
function
|
|
1996
|
+
function ls(i) {
|
|
1997
1997
|
if (i.length < J.length)
|
|
1998
1998
|
return !1;
|
|
1999
1999
|
for (let e = 0; e < J.length; e++)
|
|
@@ -2001,29 +2001,29 @@ function fn(i) {
|
|
|
2001
2001
|
return !1;
|
|
2002
2002
|
return !0;
|
|
2003
2003
|
}
|
|
2004
|
-
const
|
|
2005
|
-
function
|
|
2006
|
-
if (
|
|
2004
|
+
const fs = "tEXt", cs = 0, ve = new TextDecoder("latin1");
|
|
2005
|
+
function ds(i) {
|
|
2006
|
+
if (_s(i), i.length === 0 || i.length > 79)
|
|
2007
2007
|
throw new Error("keyword length must be between 1 and 79");
|
|
2008
2008
|
}
|
|
2009
|
-
const
|
|
2010
|
-
function
|
|
2011
|
-
if (!
|
|
2009
|
+
const us = /^[\u0000-\u00FF]*$/;
|
|
2010
|
+
function _s(i) {
|
|
2011
|
+
if (!us.test(i))
|
|
2012
2012
|
throw new Error("invalid latin1 text");
|
|
2013
2013
|
}
|
|
2014
|
-
function
|
|
2015
|
-
const
|
|
2016
|
-
i[
|
|
2014
|
+
function ps(i, e, t) {
|
|
2015
|
+
const s = Ue(e);
|
|
2016
|
+
i[s] = ws(e, t - s.length - 1);
|
|
2017
2017
|
}
|
|
2018
2018
|
function Ue(i) {
|
|
2019
|
-
for (i.mark(); i.readByte() !==
|
|
2019
|
+
for (i.mark(); i.readByte() !== cs; )
|
|
2020
2020
|
;
|
|
2021
2021
|
const e = i.offset;
|
|
2022
2022
|
i.reset();
|
|
2023
2023
|
const t = ve.decode(i.readBytes(e - i.offset - 1));
|
|
2024
|
-
return i.skip(1),
|
|
2024
|
+
return i.skip(1), ds(t), t;
|
|
2025
2025
|
}
|
|
2026
|
-
function
|
|
2026
|
+
function ws(i, e) {
|
|
2027
2027
|
return ve.decode(i.readBytes(e));
|
|
2028
2028
|
}
|
|
2029
2029
|
const I = {
|
|
@@ -2051,7 +2051,7 @@ const I = {
|
|
|
2051
2051
|
SOURCE: 0,
|
|
2052
2052
|
OVER: 1
|
|
2053
2053
|
};
|
|
2054
|
-
class
|
|
2054
|
+
class gs extends wt {
|
|
2055
2055
|
_checkCrc;
|
|
2056
2056
|
_inflator;
|
|
2057
2057
|
_png;
|
|
@@ -2072,8 +2072,8 @@ class bn extends wt {
|
|
|
2072
2072
|
_writingDataChunks;
|
|
2073
2073
|
constructor(e, t = {}) {
|
|
2074
2074
|
super(e);
|
|
2075
|
-
const { checkCrc:
|
|
2076
|
-
this._checkCrc =
|
|
2075
|
+
const { checkCrc: s = !1 } = t;
|
|
2076
|
+
this._checkCrc = s, this._inflator = new Xt(), this._png = {
|
|
2077
2077
|
width: -1,
|
|
2078
2078
|
height: -1,
|
|
2079
2079
|
channels: -1,
|
|
@@ -2107,7 +2107,7 @@ class bn extends wt {
|
|
|
2107
2107
|
}
|
|
2108
2108
|
// https://www.w3.org/TR/PNG/#5Chunk-layout
|
|
2109
2109
|
decodeChunk(e, t) {
|
|
2110
|
-
const
|
|
2110
|
+
const s = this.offset;
|
|
2111
2111
|
switch (t) {
|
|
2112
2112
|
// 11.2 Critical chunks
|
|
2113
2113
|
case "IHDR":
|
|
@@ -2129,8 +2129,8 @@ class bn extends wt {
|
|
|
2129
2129
|
case "iCCP":
|
|
2130
2130
|
this.decodeiCCP(e);
|
|
2131
2131
|
break;
|
|
2132
|
-
case
|
|
2133
|
-
|
|
2132
|
+
case fs:
|
|
2133
|
+
ps(this._png.text, this, e);
|
|
2134
2134
|
break;
|
|
2135
2135
|
case "pHYs":
|
|
2136
2136
|
this.decodepHYs();
|
|
@@ -2139,12 +2139,12 @@ class bn extends wt {
|
|
|
2139
2139
|
this.skip(e);
|
|
2140
2140
|
break;
|
|
2141
2141
|
}
|
|
2142
|
-
if (this.offset -
|
|
2142
|
+
if (this.offset - s !== e)
|
|
2143
2143
|
throw new Error(`Length mismatch while decoding chunk ${t}`);
|
|
2144
2144
|
this._checkCrc ? qt(this, e + 4, t) : this.skip(4);
|
|
2145
2145
|
}
|
|
2146
2146
|
decodeApngChunk(e, t) {
|
|
2147
|
-
const
|
|
2147
|
+
const s = this.offset;
|
|
2148
2148
|
switch (t !== "fdAT" && t !== "IDAT" && this._writingDataChunks && this.pushDataToFrame(), t) {
|
|
2149
2149
|
case "acTL":
|
|
2150
2150
|
this.decodeACTL();
|
|
@@ -2156,35 +2156,35 @@ class bn extends wt {
|
|
|
2156
2156
|
this.decodeFDAT(e);
|
|
2157
2157
|
break;
|
|
2158
2158
|
default:
|
|
2159
|
-
this.decodeChunk(e, t), this.offset =
|
|
2159
|
+
this.decodeChunk(e, t), this.offset = s + e;
|
|
2160
2160
|
break;
|
|
2161
2161
|
}
|
|
2162
|
-
if (this.offset -
|
|
2162
|
+
if (this.offset - s !== e)
|
|
2163
2163
|
throw new Error(`Length mismatch while decoding chunk ${t}`);
|
|
2164
2164
|
this._checkCrc ? qt(this, e + 4, t) : this.skip(4);
|
|
2165
2165
|
}
|
|
2166
2166
|
// https://www.w3.org/TR/PNG/#11IHDR
|
|
2167
2167
|
decodeIHDR() {
|
|
2168
2168
|
const e = this._png;
|
|
2169
|
-
e.width = this.readUint32(), e.height = this.readUint32(), e.depth =
|
|
2169
|
+
e.width = this.readUint32(), e.height = this.readUint32(), e.depth = bs(this.readUint8());
|
|
2170
2170
|
const t = this.readUint8();
|
|
2171
2171
|
this._colorType = t;
|
|
2172
|
-
let
|
|
2172
|
+
let s;
|
|
2173
2173
|
switch (t) {
|
|
2174
2174
|
case I.GREYSCALE:
|
|
2175
|
-
|
|
2175
|
+
s = 1;
|
|
2176
2176
|
break;
|
|
2177
2177
|
case I.TRUECOLOUR:
|
|
2178
|
-
|
|
2178
|
+
s = 3;
|
|
2179
2179
|
break;
|
|
2180
2180
|
case I.INDEXED_COLOUR:
|
|
2181
|
-
|
|
2181
|
+
s = 1;
|
|
2182
2182
|
break;
|
|
2183
2183
|
case I.GREYSCALE_ALPHA:
|
|
2184
|
-
|
|
2184
|
+
s = 2;
|
|
2185
2185
|
break;
|
|
2186
2186
|
case I.TRUECOLOUR_ALPHA:
|
|
2187
|
-
|
|
2187
|
+
s = 4;
|
|
2188
2188
|
break;
|
|
2189
2189
|
// Kept for exhaustiveness.
|
|
2190
2190
|
// eslint-disable-next-line unicorn/no-useless-switch-case
|
|
@@ -2192,7 +2192,7 @@ class bn extends wt {
|
|
|
2192
2192
|
default:
|
|
2193
2193
|
throw new Error(`Unknown color type: ${t}`);
|
|
2194
2194
|
}
|
|
2195
|
-
if (this._png.channels =
|
|
2195
|
+
if (this._png.channels = s, this._compressionMethod = this.readUint8(), this._compressionMethod !== ft.DEFLATE)
|
|
2196
2196
|
throw new Error(`Unsupported compression method: ${this._compressionMethod}`);
|
|
2197
2197
|
this._filterMethod = this.readUint8(), this._interlaceMethod = this.readUint8();
|
|
2198
2198
|
}
|
|
@@ -2220,23 +2220,23 @@ class bn extends wt {
|
|
|
2220
2220
|
throw new RangeError(`PLTE field length must be a multiple of 3. Got ${e}`);
|
|
2221
2221
|
const t = e / 3;
|
|
2222
2222
|
this._hasPalette = !0;
|
|
2223
|
-
const
|
|
2224
|
-
this._palette =
|
|
2223
|
+
const s = [];
|
|
2224
|
+
this._palette = s;
|
|
2225
2225
|
for (let a = 0; a < t; a++)
|
|
2226
|
-
|
|
2226
|
+
s.push([this.readUint8(), this.readUint8(), this.readUint8()]);
|
|
2227
2227
|
}
|
|
2228
2228
|
// https://www.w3.org/TR/PNG/#11IDAT
|
|
2229
2229
|
decodeIDAT(e) {
|
|
2230
2230
|
this._writingDataChunks = !0;
|
|
2231
|
-
const t = e,
|
|
2232
|
-
if (this._inflator.push(new Uint8Array(this.buffer,
|
|
2231
|
+
const t = e, s = this.offset + this.byteOffset;
|
|
2232
|
+
if (this._inflator.push(new Uint8Array(this.buffer, s, t)), this._inflator.err)
|
|
2233
2233
|
throw new Error(`Error while decompressing the data: ${this._inflator.err}`);
|
|
2234
2234
|
this.skip(e);
|
|
2235
2235
|
}
|
|
2236
2236
|
decodeFDAT(e) {
|
|
2237
2237
|
this._writingDataChunks = !0;
|
|
2238
|
-
let t = e,
|
|
2239
|
-
if (
|
|
2238
|
+
let t = e, s = this.offset + this.byteOffset;
|
|
2239
|
+
if (s += 4, t -= 4, this._inflator.push(new Uint8Array(this.buffer, s, t)), this._inflator.err)
|
|
2240
2240
|
throw new Error(`Error while decompressing the data: ${this._inflator.err}`);
|
|
2241
2241
|
this.skip(e);
|
|
2242
2242
|
}
|
|
@@ -2259,8 +2259,8 @@ class bn extends wt {
|
|
|
2259
2259
|
throw new Error(`tRNS chunk contains more alpha values than there are palette colors (${e} vs ${this._palette.length})`);
|
|
2260
2260
|
let t = 0;
|
|
2261
2261
|
for (; t < e; t++) {
|
|
2262
|
-
const
|
|
2263
|
-
this._palette[t].push(
|
|
2262
|
+
const s = this.readByte();
|
|
2263
|
+
this._palette[t].push(s);
|
|
2264
2264
|
}
|
|
2265
2265
|
for (; t < this._palette.length; t++)
|
|
2266
2266
|
this._palette[t].push(255);
|
|
@@ -2277,9 +2277,9 @@ class bn extends wt {
|
|
|
2277
2277
|
}
|
|
2278
2278
|
// https://www.w3.org/TR/PNG/#11iCCP
|
|
2279
2279
|
decodeiCCP(e) {
|
|
2280
|
-
const t = Ue(this),
|
|
2281
|
-
if (
|
|
2282
|
-
throw new Error(`Unsupported iCCP compression method: ${
|
|
2280
|
+
const t = Ue(this), s = this.readUint8();
|
|
2281
|
+
if (s !== ft.DEFLATE)
|
|
2282
|
+
throw new Error(`Unsupported iCCP compression method: ${s}`);
|
|
2283
2283
|
const a = this.readBytes(e - t.length - 2);
|
|
2284
2284
|
this._png.iccEmbeddedProfile = {
|
|
2285
2285
|
name: t,
|
|
@@ -2288,11 +2288,11 @@ class bn extends wt {
|
|
|
2288
2288
|
}
|
|
2289
2289
|
// https://www.w3.org/TR/PNG/#11pHYs
|
|
2290
2290
|
decodepHYs() {
|
|
2291
|
-
const e = this.readUint32(), t = this.readUint32(),
|
|
2291
|
+
const e = this.readUint32(), t = this.readUint32(), s = this.readByte();
|
|
2292
2292
|
this._png.resolution = {
|
|
2293
2293
|
x: e,
|
|
2294
2294
|
y: t,
|
|
2295
|
-
unit:
|
|
2295
|
+
unit: s
|
|
2296
2296
|
};
|
|
2297
2297
|
}
|
|
2298
2298
|
decodeApngImage() {
|
|
@@ -2303,65 +2303,65 @@ class bn extends wt {
|
|
|
2303
2303
|
delayNumber: this._frames[e].delayNumber,
|
|
2304
2304
|
delayDenominator: this._frames[e].delayDenominator,
|
|
2305
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)
|
|
2306
|
-
},
|
|
2307
|
-
if (
|
|
2308
|
-
if (
|
|
2309
|
-
data:
|
|
2310
|
-
width:
|
|
2311
|
-
height:
|
|
2306
|
+
}, s = this._frames.at(e);
|
|
2307
|
+
if (s) {
|
|
2308
|
+
if (s.data = Jt({
|
|
2309
|
+
data: s.data,
|
|
2310
|
+
width: s.width,
|
|
2311
|
+
height: s.height,
|
|
2312
2312
|
channels: this._apng.channels,
|
|
2313
2313
|
depth: this._apng.depth
|
|
2314
|
-
}), this._hasPalette && (this._apng.palette = this._palette), this._hasTransparency && (this._apng.transparency = this._transparency), e === 0 ||
|
|
2315
|
-
t.data =
|
|
2314
|
+
}), this._hasPalette && (this._apng.palette = this._palette), this._hasTransparency && (this._apng.transparency = this._transparency), e === 0 || s.xOffset === 0 && s.yOffset === 0 && s.width === this._png.width && s.height === this._png.height)
|
|
2315
|
+
t.data = s.data;
|
|
2316
2316
|
else {
|
|
2317
2317
|
const a = this._apng.frames.at(e - 1);
|
|
2318
|
-
this.disposeFrame(
|
|
2318
|
+
this.disposeFrame(s, a, t), this.addFrameDataToCanvas(t, s);
|
|
2319
2319
|
}
|
|
2320
2320
|
this._apng.frames.push(t);
|
|
2321
2321
|
}
|
|
2322
2322
|
}
|
|
2323
2323
|
return this._apng;
|
|
2324
2324
|
}
|
|
2325
|
-
disposeFrame(e, t,
|
|
2325
|
+
disposeFrame(e, t, s) {
|
|
2326
2326
|
switch (e.disposeOp) {
|
|
2327
2327
|
case V.NONE:
|
|
2328
2328
|
break;
|
|
2329
2329
|
case V.BACKGROUND:
|
|
2330
2330
|
for (let a = 0; a < this._png.height; a++)
|
|
2331
|
-
for (let
|
|
2332
|
-
const l = (a * e.width +
|
|
2331
|
+
for (let n = 0; n < this._png.width; n++) {
|
|
2332
|
+
const l = (a * e.width + n) * this._png.channels;
|
|
2333
2333
|
for (let h = 0; h < this._png.channels; h++)
|
|
2334
|
-
|
|
2334
|
+
s.data[l + h] = 0;
|
|
2335
2335
|
}
|
|
2336
2336
|
break;
|
|
2337
2337
|
case V.PREVIOUS:
|
|
2338
|
-
|
|
2338
|
+
s.data.set(t.data);
|
|
2339
2339
|
break;
|
|
2340
2340
|
default:
|
|
2341
2341
|
throw new Error("Unknown disposeOp");
|
|
2342
2342
|
}
|
|
2343
2343
|
}
|
|
2344
2344
|
addFrameDataToCanvas(e, t) {
|
|
2345
|
-
const
|
|
2346
|
-
const h = ((
|
|
2345
|
+
const s = 1 << this._png.depth, a = (n, l) => {
|
|
2346
|
+
const h = ((n + t.yOffset) * this._png.width + t.xOffset + l) * this._png.channels, d = (n * t.width + l) * this._png.channels;
|
|
2347
2347
|
return { index: h, frameIndex: d };
|
|
2348
2348
|
};
|
|
2349
2349
|
switch (t.blendOp) {
|
|
2350
2350
|
case dt.SOURCE:
|
|
2351
|
-
for (let
|
|
2351
|
+
for (let n = 0; n < t.height; n++)
|
|
2352
2352
|
for (let l = 0; l < t.width; l++) {
|
|
2353
|
-
const { index: h, frameIndex: d } = a(
|
|
2353
|
+
const { index: h, frameIndex: d } = a(n, l);
|
|
2354
2354
|
for (let r = 0; r < this._png.channels; r++)
|
|
2355
2355
|
e.data[h + r] = t.data[d + r];
|
|
2356
2356
|
}
|
|
2357
2357
|
break;
|
|
2358
2358
|
// https://www.w3.org/TR/png-3/#13Alpha-channel-processing
|
|
2359
2359
|
case dt.OVER:
|
|
2360
|
-
for (let
|
|
2360
|
+
for (let n = 0; n < t.height; n++)
|
|
2361
2361
|
for (let l = 0; l < t.width; l++) {
|
|
2362
|
-
const { index: h, frameIndex: d } = a(
|
|
2362
|
+
const { index: h, frameIndex: d } = a(n, l);
|
|
2363
2363
|
for (let r = 0; r < this._png.channels; r++) {
|
|
2364
|
-
const o = t.data[d + this._png.channels - 1] /
|
|
2364
|
+
const o = t.data[d + this._png.channels - 1] / s, w = r % (this._png.channels - 1) === 0 ? 1 : t.data[d + r], u = Math.floor(o * w + (1 - o) * e.data[h + r]);
|
|
2365
2365
|
e.data[h + r] += u;
|
|
2366
2366
|
}
|
|
2367
2367
|
}
|
|
@@ -2385,7 +2385,7 @@ class bn extends wt {
|
|
|
2385
2385
|
depth: this._png.depth
|
|
2386
2386
|
});
|
|
2387
2387
|
else if (this._interlaceMethod === ct.ADAM7)
|
|
2388
|
-
this._png.data =
|
|
2388
|
+
this._png.data = is({
|
|
2389
2389
|
data: e,
|
|
2390
2390
|
width: this._png.width,
|
|
2391
2391
|
height: this._png.height,
|
|
@@ -2412,20 +2412,20 @@ class bn extends wt {
|
|
|
2412
2412
|
}), this._inflator = new Xt(), this._writingDataChunks = !1;
|
|
2413
2413
|
}
|
|
2414
2414
|
}
|
|
2415
|
-
function
|
|
2415
|
+
function bs(i) {
|
|
2416
2416
|
if (i !== 1 && i !== 2 && i !== 4 && i !== 8 && i !== 16)
|
|
2417
2417
|
throw new Error(`invalid bit depth: ${i}`);
|
|
2418
2418
|
return i;
|
|
2419
2419
|
}
|
|
2420
|
-
function
|
|
2421
|
-
return new
|
|
2420
|
+
function xs(i, e) {
|
|
2421
|
+
return new gs(i, e).decode();
|
|
2422
2422
|
}
|
|
2423
|
-
class
|
|
2423
|
+
class ys {
|
|
2424
2424
|
#e;
|
|
2425
2425
|
#t;
|
|
2426
|
-
#n;
|
|
2427
|
-
#i;
|
|
2428
2426
|
#s;
|
|
2427
|
+
#i;
|
|
2428
|
+
#n;
|
|
2429
2429
|
elevs;
|
|
2430
2430
|
/**
|
|
2431
2431
|
* Create a new DEM.
|
|
@@ -2437,8 +2437,8 @@ class kn {
|
|
|
2437
2437
|
* @param {number} xSpacing - spacing in Spherical Mercator units in the horizontal direction.
|
|
2438
2438
|
* @param {number} ySpacing - spacing in Spherical Mercator units in the vertical direction.
|
|
2439
2439
|
*/
|
|
2440
|
-
constructor(e, t,
|
|
2441
|
-
this.#e = t, this.#t =
|
|
2440
|
+
constructor(e, t, s, a, n, l) {
|
|
2441
|
+
this.#e = t, this.#t = s, this.#s = a, this.elevs = e, this.#i = n, this.#n = l;
|
|
2442
2442
|
}
|
|
2443
2443
|
/** Obtains the elevation in metres at a given x and y Spherical Mercator coordinate using bilinear interpolation.
|
|
2444
2444
|
* @param {number} x - the Spherical Mercator x coordinate.
|
|
@@ -2446,16 +2446,20 @@ class kn {
|
|
|
2446
2446
|
* @return {number} the elevation in metres
|
|
2447
2447
|
*/
|
|
2448
2448
|
getElevation(e, t) {
|
|
2449
|
-
let
|
|
2450
|
-
if (a >= 0 &&
|
|
2451
|
-
r = this.elevs[
|
|
2452
|
-
let _ = (
|
|
2449
|
+
let s = [e, t], a = Math.floor((s[0] - this.#e.e) / this.#i), n = this.#s - Math.ceil((s[1] - this.#e.n) / this.#n), l, h, d, r, o, w, u, f = null;
|
|
2450
|
+
if (a >= 0 && n >= 0 && a < this.#t - 1 && n < this.#s - 1) {
|
|
2451
|
+
r = this.elevs[n * this.#t + a], o = this.elevs[n * this.#t + a + 1], w = this.elevs[n * this.#t + a + this.#t], u = this.elevs[n * this.#t + a + this.#t + 1], l = this.#e.e + a * this.#i, l + this.#i, h = this.#e.n + (this.#s - 1 - n) * this.#n, d = h - this.#n;
|
|
2452
|
+
let _ = (s[0] - l) / this.#i, U = r * (1 - _) + o * _, x = w * (1 - _) + u * _, g = (s[1] - d) / this.#n;
|
|
2453
2453
|
f = x * (1 - g) + U * g;
|
|
2454
2454
|
}
|
|
2455
2455
|
return f;
|
|
2456
2456
|
}
|
|
2457
|
+
/** Process the DEM data with a custom function. The function has access to all the key properties of the DEM. */
|
|
2458
|
+
processData(e) {
|
|
2459
|
+
e(this.elevs, this.#e, this.#t, this.#s, this.#i, this.#n);
|
|
2460
|
+
}
|
|
2457
2461
|
}
|
|
2458
|
-
class
|
|
2462
|
+
class ks extends ie {
|
|
2459
2463
|
/**
|
|
2460
2464
|
* Create a DemTiler.
|
|
2461
2465
|
* @class
|
|
@@ -2470,14 +2474,14 @@ class En extends ie {
|
|
|
2470
2474
|
* @return {Promise<any>} a Promise resolving with raw DEM data.
|
|
2471
2475
|
*/
|
|
2472
2476
|
async readTile(e) {
|
|
2473
|
-
const
|
|
2477
|
+
const s = await (await fetch(e, {
|
|
2474
2478
|
signal: AbortSignal.timeout(3e4)
|
|
2475
|
-
})).arrayBuffer(), a =
|
|
2476
|
-
let
|
|
2479
|
+
})).arrayBuffer(), a = xs(s);
|
|
2480
|
+
let n, l = 0;
|
|
2477
2481
|
const h = new Array(a.width * a.height);
|
|
2478
2482
|
for (let d = 0; d < a.height; d++)
|
|
2479
2483
|
for (let r = 0; r < a.width; r++)
|
|
2480
|
-
|
|
2484
|
+
n = (d * a.width + r) * a.channels, h[l++] = Math.round(a.data[n] * 256 + a.data[n + 1] + a.data[n + 2] / 256 - 32768);
|
|
2481
2485
|
return { w: a.width, h: a.height, elevs: h };
|
|
2482
2486
|
}
|
|
2483
2487
|
/**
|
|
@@ -2486,8 +2490,8 @@ class En extends ie {
|
|
|
2486
2490
|
* @return {number} the elevation in metres, or Number.NEGATIVE_INFINITY if this position is outside the extent of the DEM.
|
|
2487
2491
|
*/
|
|
2488
2492
|
getElevation(e) {
|
|
2489
|
-
const t = this.getTile(e, this.tile.z),
|
|
2490
|
-
return
|
|
2493
|
+
const t = this.getTile(e, this.tile.z), s = this.dataTiles.get(`${t.z}/${t.x}/${t.y}`);
|
|
2494
|
+
return s ? s.data.getElevation(e.e, e.n) : null;
|
|
2491
2495
|
}
|
|
2492
2496
|
/**
|
|
2493
2497
|
* Obtain the elevation in metres for a given longitude/latitude.
|
|
@@ -2504,18 +2508,18 @@ class En extends ie {
|
|
|
2504
2508
|
* @return {DataTile} the DataTile pairing the Tile and the DEM data as a DEM object.
|
|
2505
2509
|
*/
|
|
2506
2510
|
rawTileToStoredTile(e, t) {
|
|
2507
|
-
const
|
|
2511
|
+
const s = e.getTopRight(), a = e.getBottomLeft(), n = (s.e - a.e) / (t.w - 1), l = (s.n - a.n) / (t.h - 1), h = new ys(
|
|
2508
2512
|
t.elevs,
|
|
2509
2513
|
a,
|
|
2510
2514
|
t.w,
|
|
2511
2515
|
t.h,
|
|
2512
|
-
|
|
2516
|
+
n,
|
|
2513
2517
|
l
|
|
2514
2518
|
);
|
|
2515
2519
|
return { tile: e, data: h };
|
|
2516
2520
|
}
|
|
2517
2521
|
}
|
|
2518
|
-
class
|
|
2522
|
+
class Es extends ie {
|
|
2519
2523
|
/**
|
|
2520
2524
|
* Create a JsonTiler.
|
|
2521
2525
|
* @class
|
|
@@ -2535,7 +2539,7 @@ class An extends ie {
|
|
|
2535
2539
|
})).json();
|
|
2536
2540
|
}
|
|
2537
2541
|
}
|
|
2538
|
-
class
|
|
2542
|
+
class As {
|
|
2539
2543
|
e;
|
|
2540
2544
|
n;
|
|
2541
2545
|
/**
|
|
@@ -2556,26 +2560,26 @@ class Tn {
|
|
|
2556
2560
|
}
|
|
2557
2561
|
}
|
|
2558
2562
|
class ee {
|
|
2559
|
-
|
|
2560
|
-
|
|
2563
|
+
longitude;
|
|
2564
|
+
latitude;
|
|
2561
2565
|
/**
|
|
2562
2566
|
* Creates a LonLat.
|
|
2563
2567
|
* @class
|
|
2564
|
-
* @param {number}
|
|
2565
|
-
* @param {number}
|
|
2568
|
+
* @param {number} longitude - the longitude.
|
|
2569
|
+
* @param {number} latitude - the latitude.
|
|
2566
2570
|
*/
|
|
2567
2571
|
constructor(e, t) {
|
|
2568
|
-
this.
|
|
2572
|
+
this.longitude = e, this.latitude = t;
|
|
2569
2573
|
}
|
|
2570
2574
|
/**
|
|
2571
2575
|
* Returns a string representation of the LonLat.
|
|
2572
2576
|
* @return {string} the string representation.
|
|
2573
2577
|
*/
|
|
2574
2578
|
toString() {
|
|
2575
|
-
return `
|
|
2579
|
+
return `longitude: ${this.longitude}, latitude: ${this.latitude}`;
|
|
2576
2580
|
}
|
|
2577
2581
|
}
|
|
2578
|
-
class
|
|
2582
|
+
class Ts {
|
|
2579
2583
|
demTiler;
|
|
2580
2584
|
jsonTiler;
|
|
2581
2585
|
/**
|
|
@@ -2597,13 +2601,13 @@ class mn {
|
|
|
2597
2601
|
* @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.
|
|
2598
2602
|
*/
|
|
2599
2603
|
async updateByLonLat(e) {
|
|
2600
|
-
const t = this.demTiler.sphMerc.project(e),
|
|
2601
|
-
return
|
|
2602
|
-
this.#e(
|
|
2604
|
+
const t = this.demTiler.sphMerc.project(e), s = await this.demTiler.update(t), a = await this.jsonTiler.update(t);
|
|
2605
|
+
return s.forEach((n, l) => {
|
|
2606
|
+
this.#e(n, a[l]);
|
|
2603
2607
|
}), a;
|
|
2604
2608
|
}
|
|
2605
2609
|
async #e(e, t) {
|
|
2606
|
-
t.data.features.forEach((a,
|
|
2610
|
+
t.data.features.forEach((a, n) => {
|
|
2607
2611
|
switch (a.geometry.type) {
|
|
2608
2612
|
case "LineString":
|
|
2609
2613
|
const l = a.geometry;
|
|
@@ -2622,19 +2626,19 @@ class mn {
|
|
|
2622
2626
|
});
|
|
2623
2627
|
}
|
|
2624
2628
|
#t(e, t) {
|
|
2625
|
-
t.forEach((
|
|
2626
|
-
const a = this.demTiler.sphMerc.project(new ee(
|
|
2627
|
-
|
|
2629
|
+
t.forEach((s) => {
|
|
2630
|
+
const a = this.demTiler.sphMerc.project(new ee(s[0], s[1])), n = e.data?.getElevation(a.e, a.n) ?? 0;
|
|
2631
|
+
n > Number.NEGATIVE_INFINITY && (s[2] = n);
|
|
2628
2632
|
});
|
|
2629
2633
|
}
|
|
2630
2634
|
}
|
|
2631
2635
|
export {
|
|
2632
|
-
|
|
2633
|
-
|
|
2634
|
-
|
|
2635
|
-
|
|
2636
|
-
|
|
2637
|
-
|
|
2636
|
+
D as Constants,
|
|
2637
|
+
ys as DEM,
|
|
2638
|
+
Ts as DemApplier,
|
|
2639
|
+
ks as DemTiler,
|
|
2640
|
+
As as EastNorth,
|
|
2641
|
+
Es as JsonTiler,
|
|
2638
2642
|
ee as LonLat,
|
|
2639
2643
|
Se as SphMercProjection,
|
|
2640
2644
|
q as Tile,
|