@qispace/vue3-player 0.0.6 → 0.0.7
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/components/apartmentChooser/QiApartmentChooser.vue.d.ts +471 -3
- package/dist/components/apartmentChooser/QiApartmentChooserNavigation.vue.d.ts +50 -3
- package/dist/components/apartmentChooser/QiApartmentChooserRaster.vue.d.ts +151 -3
- package/dist/components/apartmentChooser/QiApartmentChooserRotator.vue.d.ts +66 -3
- package/dist/components/apartmentChooser/QiApartmentChooserSvg.vue.d.ts +124 -3
- package/dist/components/buildingPicker/QiBuildingChooser.vue.d.ts +425 -2
- package/dist/components/buildingPicker/QiBuildingChooserRaster.vue.d.ts +154 -3
- package/dist/components/buildingPicker/QiBuildingChooserRasterOverlay.vue.d.ts +53 -3
- package/dist/components/buildingPicker/QiBuildingChooserSceneImageStack.vue.d.ts +32 -3
- package/dist/components/buildingPicker/QiBuildingChooserSunSimControl.vue.d.ts +41 -4
- package/dist/components/buildingPicker/QiBuildingChooserSvg.vue.d.ts +156 -3
- package/dist/components/shared/QiFloatingCard.vue.d.ts +17 -3
- package/dist/components/shared/QiHoverProbe.vue.d.ts +3 -3
- package/dist/components/shared/QiNorthDirection.vue.d.ts +20 -2
- package/dist/components/shared/QiZoomBox.vue.d.ts +82 -3
- package/dist/components/virtualTourV2/Disclaimer.vue.d.ts +3 -3
- package/dist/components/virtualTourV2/FullScreenButton.vue.d.ts +13 -2
- package/dist/components/virtualTourV2/ManualSlideShow.vue.d.ts +72 -3
- package/dist/components/virtualTourV2/ManualSlideShowPlayer.vue.d.ts +14 -3
- package/dist/components/virtualTourV2/SingleImage.vue.d.ts +25 -3
- package/dist/components/virtualTourV2/SocialShare.vue.d.ts +9 -3
- package/dist/components/virtualTourV2/WaypointCarousel.vue.d.ts +30 -3
- package/dist/entry.css +1 -0
- package/dist/{vue3-player.esm.js → vue3-player.mjs} +647 -581
- package/dist/vue3-player.umd.js +2 -3
- package/package.json +12 -10
- package/dist/components/apartmentChooser/QiApartmentChooser.vue.d.ts.map +0 -1
- package/dist/components/apartmentChooser/QiApartmentChooserNavigation.vue.d.ts.map +0 -1
- package/dist/components/apartmentChooser/QiApartmentChooserRaster.vue.d.ts.map +0 -1
- package/dist/components/apartmentChooser/QiApartmentChooserRotator.vue.d.ts.map +0 -1
- package/dist/components/apartmentChooser/QiApartmentChooserSvg.vue.d.ts.map +0 -1
- package/dist/components/buildingPicker/QiBuildingChooser.vue.d.ts.map +0 -1
- package/dist/components/buildingPicker/QiBuildingChooserRaster.vue.d.ts.map +0 -1
- package/dist/components/buildingPicker/QiBuildingChooserRasterOverlay.vue.d.ts.map +0 -1
- package/dist/components/buildingPicker/QiBuildingChooserSceneImageStack.vue.d.ts.map +0 -1
- package/dist/components/buildingPicker/QiBuildingChooserSunSimControl.vue.d.ts.map +0 -1
- package/dist/components/buildingPicker/QiBuildingChooserSvg.vue.d.ts.map +0 -1
- package/dist/components/shared/QiFloatingCard.vue.d.ts.map +0 -1
- package/dist/components/shared/QiHoverProbe.vue.d.ts.map +0 -1
- package/dist/components/shared/QiNorthDirection.vue.d.ts.map +0 -1
- package/dist/components/shared/QiZoomBox.vue.d.ts.map +0 -1
- package/dist/components/virtualTourV2/Disclaimer.vue.d.ts.map +0 -1
- package/dist/components/virtualTourV2/FullScreenButton.vue.d.ts.map +0 -1
- package/dist/components/virtualTourV2/ManualSlideShow.vue.d.ts.map +0 -1
- package/dist/components/virtualTourV2/ManualSlideShowPlayer.vue.d.ts.map +0 -1
- package/dist/components/virtualTourV2/SingleImage.vue.d.ts.map +0 -1
- package/dist/components/virtualTourV2/SocialShare.vue.d.ts.map +0 -1
- package/dist/components/virtualTourV2/WaypointCarousel.vue.d.ts.map +0 -1
- package/dist/lib/virtualTour__/ApartmentConfig.d.ts +0 -27
- package/dist/lib/virtualTour__/ApartmentFiles.d.ts +0 -7
- package/dist/lib/virtualTour__/MinimapConfig.d.ts +0 -23
- package/dist/lib/virtualTour__/impl/HttpApartmentFiles.d.ts +0 -19
- package/dist/vue3-player.cjs.js +0 -2
- package/dist/vue3-player.iife.js +0 -3
- package/src/entry.esm.js +0 -17
- package/src/entry.js +0 -13
- package/src/entry.ts_ +0 -17
- package/src/lib/virtualTour__/ApartmentConfig.ts +0 -80
- package/src/lib/virtualTour__/ApartmentFiles.ts +0 -8
- package/src/lib/virtualTour__/CameraNavigator.js_ +0 -74
- package/src/lib/virtualTour__/CameraSnapshot.js +0 -42
- package/src/lib/virtualTour__/CoordConversions.js +0 -43
- package/src/lib/virtualTour__/FullscreenModel.js +0 -69
- package/src/lib/virtualTour__/MinimapConfig.ts +0 -46
- package/src/lib/virtualTour__/PlayerViewModel.js +0 -423
- package/src/lib/virtualTour__/config/ApartmentConfig.js +0 -92
- package/src/lib/virtualTour__/config/CameraConfig.js +0 -97
- package/src/lib/virtualTour__/config/Interaction.js +0 -393
- package/src/lib/virtualTour__/config/Panorama.js +0 -78
- package/src/lib/virtualTour__/config/PlayerConfig.js +0 -812
- package/src/lib/virtualTour__/config/rawinflate.export.js +0 -833
- package/src/lib/virtualTour__/config/shaders.js +0 -24
- package/src/lib/virtualTour__/impl/HttpApartmentFiles.ts +0 -57
- package/src/lib/virtualTour__/index.js +0 -1
- package/src/lib/virtualTour__/textures/arrow.png +0 -0
- package/src/lib/virtualTour__/textures/compass-bg.png +0 -0
- package/src/lib/virtualTour__/textures/compass-needle.png +0 -0
- package/src/lib/virtualTour__/textures/compass-north.png +0 -0
- package/src/lib/virtualTour__/textures/floor-1.svg +0 -4
- package/src/lib/virtualTour__/textures/floor-2.svg +0 -4
- package/src/lib/virtualTour__/textures/marker.png +0 -0
- package/src/lib/virtualTour__/textures/tod-sun.png +0 -0
- package/src/main.ts_ +0 -24
- package/src/shims-png.d.ts +0 -4
- package/src/shims-tsx.d.ts +0 -11
- package/src/shims-vue.d.ts +0 -4
- package/src/style.css +0 -0
- package/src/vite-env.d.ts +0 -5
|
@@ -1,833 +0,0 @@
|
|
|
1
|
-
/* eslint-disable */
|
|
2
|
-
|
|
3
|
-
/* constant parameters */
|
|
4
|
-
const WSIZE = 32768 // Sliding Window size
|
|
5
|
-
const STORED_BLOCK = 0
|
|
6
|
-
const STATIC_TREES = 1
|
|
7
|
-
const DYN_TREES = 2
|
|
8
|
-
/* for inflate */
|
|
9
|
-
const lbits = 9 // bits in base literal/length lookup table
|
|
10
|
-
const dbits = 6 // bits in base distance lookup table
|
|
11
|
-
/* variables (inflate) */
|
|
12
|
-
let slide
|
|
13
|
-
let wp // current position in slide
|
|
14
|
-
let fixed_tl = null // inflate static
|
|
15
|
-
let fixed_td // inflate static
|
|
16
|
-
let fixed_bl // inflate static
|
|
17
|
-
let fixed_bd // inflate static
|
|
18
|
-
let bit_buf // bit buffer
|
|
19
|
-
let bit_len // bits in bit buffer
|
|
20
|
-
let method
|
|
21
|
-
let eof
|
|
22
|
-
let copy_leng
|
|
23
|
-
let copy_dist
|
|
24
|
-
let tl // literal length decoder table
|
|
25
|
-
let td // literal distance decoder table
|
|
26
|
-
let bl // number of bits decoded by tl
|
|
27
|
-
let bd // number of bits decoded by td
|
|
28
|
-
let inflate_data
|
|
29
|
-
let inflate_pos
|
|
30
|
-
/* constant tables (inflate) */
|
|
31
|
-
const MASK_BITS = [
|
|
32
|
-
0x0000, 0x0001, 0x0003, 0x0007, 0x000f, 0x001f, 0x003f, 0x007f, 0x00ff,
|
|
33
|
-
0x01ff, 0x03ff, 0x07ff, 0x0fff, 0x1fff, 0x3fff, 0x7fff, 0xffff,
|
|
34
|
-
]
|
|
35
|
-
// Tables for deflate from PKZIP's appnote.txt.
|
|
36
|
-
// Copy lengths for literal codes 257..285
|
|
37
|
-
const cplens = [
|
|
38
|
-
3, 4, 5, 6, 7, 8, 9, 10, 11, 13, 15, 17, 19, 23, 27, 31, 35, 43, 51, 59, 67,
|
|
39
|
-
83, 99, 115, 131, 163, 195, 227, 258, 0, 0,
|
|
40
|
-
]
|
|
41
|
-
/* note: see note #13 above about the 258 in this list. */
|
|
42
|
-
// Extra bits for literal codes 257..285
|
|
43
|
-
const cplext = [
|
|
44
|
-
0,
|
|
45
|
-
0,
|
|
46
|
-
0,
|
|
47
|
-
0,
|
|
48
|
-
0,
|
|
49
|
-
0,
|
|
50
|
-
0,
|
|
51
|
-
0,
|
|
52
|
-
1,
|
|
53
|
-
1,
|
|
54
|
-
1,
|
|
55
|
-
1,
|
|
56
|
-
2,
|
|
57
|
-
2,
|
|
58
|
-
2,
|
|
59
|
-
2,
|
|
60
|
-
3,
|
|
61
|
-
3,
|
|
62
|
-
3,
|
|
63
|
-
3,
|
|
64
|
-
4,
|
|
65
|
-
4,
|
|
66
|
-
4,
|
|
67
|
-
4,
|
|
68
|
-
5,
|
|
69
|
-
5,
|
|
70
|
-
5,
|
|
71
|
-
5,
|
|
72
|
-
0,
|
|
73
|
-
99,
|
|
74
|
-
99, // 99==invalid
|
|
75
|
-
]
|
|
76
|
-
// Copy offsets for distance codes 0..29
|
|
77
|
-
const cpdist = [
|
|
78
|
-
1, 2, 3, 4, 5, 7, 9, 13, 17, 25, 33, 49, 65, 97, 129, 193, 257, 385, 513, 769,
|
|
79
|
-
1025, 1537, 2049, 3073, 4097, 6145, 8193, 12289, 16385, 24577,
|
|
80
|
-
]
|
|
81
|
-
// Extra bits for distance codes
|
|
82
|
-
const cpdext = [
|
|
83
|
-
0, 0, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11,
|
|
84
|
-
11, 12, 12, 13, 13,
|
|
85
|
-
]
|
|
86
|
-
// Order of the bit length code lengths
|
|
87
|
-
const border = [
|
|
88
|
-
16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15,
|
|
89
|
-
]
|
|
90
|
-
/* objects (inflate) */
|
|
91
|
-
|
|
92
|
-
export function HuftList() {
|
|
93
|
-
this.next = null
|
|
94
|
-
this.list = null
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
export function HuftNode() {
|
|
98
|
-
this.e = 0 // number of extra bits or operation
|
|
99
|
-
this.b = 0 // number of bits in this code or subcode
|
|
100
|
-
|
|
101
|
-
// union
|
|
102
|
-
this.n = 0 // literal, length base, or distance base
|
|
103
|
-
this.t = null // (HuftNode) pointer to next level of table
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
/*
|
|
107
|
-
* @param b- code lengths in bits (all assumed <= BMAX)
|
|
108
|
-
* @param n- number of codes (assumed <= N_MAX)
|
|
109
|
-
* @param s- number of simple-valued codes (0..s-1)
|
|
110
|
-
* @param d- list of base values for non-simple codes
|
|
111
|
-
* @param e- list of extra bits for non-simple codes
|
|
112
|
-
* @param mm- maximum lookup bits
|
|
113
|
-
*/
|
|
114
|
-
export function HuftBuild(b, n, s, d, e, mm) {
|
|
115
|
-
this.BMAX = 16 // maximum bit length of any code
|
|
116
|
-
this.N_MAX = 288 // maximum number of codes in any set
|
|
117
|
-
this.status = 0 // 0: success, 1: incomplete table, 2: bad input
|
|
118
|
-
this.root = null // (HuftList) starting table
|
|
119
|
-
this.m = 0 // maximum lookup bits, returns actual
|
|
120
|
-
|
|
121
|
-
/* Given a list of code lengths and a maximum table size, make a set of
|
|
122
|
-
tables to decode that set of codes. Return zero on success, one if
|
|
123
|
-
the given code set is incomplete (the tables are still built in this
|
|
124
|
-
case), two if the input is invalid (all zero length codes or an
|
|
125
|
-
oversubscribed set of lengths), and three if not enough memory.
|
|
126
|
-
The code with value 256 is special, and the tables are constructed
|
|
127
|
-
so that no bits beyond that code are fetched when that code is
|
|
128
|
-
decoded. */
|
|
129
|
-
let a // counter for codes of length k
|
|
130
|
-
const c = []
|
|
131
|
-
let el // length of EOB code (value 256)
|
|
132
|
-
let f // i repeats in table every f entries
|
|
133
|
-
let g // maximum code length
|
|
134
|
-
let h // table level
|
|
135
|
-
let i // counter, current code
|
|
136
|
-
let j // counter
|
|
137
|
-
let k // number of bits in current code
|
|
138
|
-
const lx = []
|
|
139
|
-
let p // pointer into c[], b[], or v[]
|
|
140
|
-
let pidx // index of p
|
|
141
|
-
let q // (HuftNode) points to current table
|
|
142
|
-
const r = new HuftNode() // table entry for structure assignment
|
|
143
|
-
const u = []
|
|
144
|
-
const v = []
|
|
145
|
-
let w
|
|
146
|
-
const x = []
|
|
147
|
-
let xp // pointer into x or c
|
|
148
|
-
let y // number of dummy codes added
|
|
149
|
-
let z // number of entries in current table
|
|
150
|
-
let o
|
|
151
|
-
let tail // (HuftList)
|
|
152
|
-
|
|
153
|
-
tail = this.root = null
|
|
154
|
-
|
|
155
|
-
// bit length count table
|
|
156
|
-
for (i = 0; i < this.BMAX + 1; i++) {
|
|
157
|
-
c[i] = 0
|
|
158
|
-
}
|
|
159
|
-
// stack of bits per table
|
|
160
|
-
for (i = 0; i < this.BMAX + 1; i++) {
|
|
161
|
-
lx[i] = 0
|
|
162
|
-
}
|
|
163
|
-
// HuftNode[BMAX][] table stack
|
|
164
|
-
for (i = 0; i < this.BMAX; i++) {
|
|
165
|
-
u[i] = null
|
|
166
|
-
}
|
|
167
|
-
// values in order of bit length
|
|
168
|
-
for (i = 0; i < this.N_MAX; i++) {
|
|
169
|
-
v[i] = 0
|
|
170
|
-
}
|
|
171
|
-
// bit offsets, then code stack
|
|
172
|
-
for (i = 0; i < this.BMAX + 1; i++) {
|
|
173
|
-
x[i] = 0
|
|
174
|
-
}
|
|
175
|
-
|
|
176
|
-
// Generate counts for each bit length
|
|
177
|
-
el = n > 256 ? b[256] : this.BMAX // set length of EOB code, if any
|
|
178
|
-
p = b
|
|
179
|
-
pidx = 0
|
|
180
|
-
i = n
|
|
181
|
-
do {
|
|
182
|
-
c[p[pidx]]++ // assume all entries <= BMAX
|
|
183
|
-
pidx++
|
|
184
|
-
} while (--i > 0)
|
|
185
|
-
if (c[0] === n) {
|
|
186
|
-
// null input--all zero length codes
|
|
187
|
-
this.root = null
|
|
188
|
-
this.m = 0
|
|
189
|
-
this.status = 0
|
|
190
|
-
return
|
|
191
|
-
}
|
|
192
|
-
|
|
193
|
-
// Find minimum and maximum length, bound *m by those
|
|
194
|
-
for (j = 1; j <= this.BMAX; j++) {
|
|
195
|
-
if (c[j] !== 0) {
|
|
196
|
-
break
|
|
197
|
-
}
|
|
198
|
-
}
|
|
199
|
-
k = j // minimum code length
|
|
200
|
-
if (mm < j) {
|
|
201
|
-
mm = j
|
|
202
|
-
}
|
|
203
|
-
for (i = this.BMAX; i !== 0; i--) {
|
|
204
|
-
if (c[i] !== 0) {
|
|
205
|
-
break
|
|
206
|
-
}
|
|
207
|
-
}
|
|
208
|
-
g = i // maximum code length
|
|
209
|
-
if (mm > i) {
|
|
210
|
-
mm = i
|
|
211
|
-
}
|
|
212
|
-
|
|
213
|
-
// Adjust last length count to fill out codes, if needed
|
|
214
|
-
for (y = 1 << j; j < i; j++, y <<= 1) {
|
|
215
|
-
if ((y -= c[j]) < 0) {
|
|
216
|
-
this.status = 2 // bad input: more codes than bits
|
|
217
|
-
this.m = mm
|
|
218
|
-
return
|
|
219
|
-
}
|
|
220
|
-
}
|
|
221
|
-
if ((y -= c[i]) < 0) {
|
|
222
|
-
this.status = 2
|
|
223
|
-
this.m = mm
|
|
224
|
-
return
|
|
225
|
-
}
|
|
226
|
-
c[i] += y
|
|
227
|
-
|
|
228
|
-
// Generate starting offsets into the value table for each length
|
|
229
|
-
x[1] = j = 0
|
|
230
|
-
p = c
|
|
231
|
-
pidx = 1
|
|
232
|
-
xp = 2
|
|
233
|
-
while (--i > 0) {
|
|
234
|
-
// note that i == g from above
|
|
235
|
-
x[xp++] = j += p[pidx++]
|
|
236
|
-
}
|
|
237
|
-
|
|
238
|
-
// Make a table of values in order of bit lengths
|
|
239
|
-
p = b
|
|
240
|
-
pidx = 0
|
|
241
|
-
i = 0
|
|
242
|
-
do {
|
|
243
|
-
if ((j = p[pidx++]) !== 0) {
|
|
244
|
-
v[x[j]++] = i
|
|
245
|
-
}
|
|
246
|
-
} while (++i < n)
|
|
247
|
-
n = x[g] // set n to length of v
|
|
248
|
-
|
|
249
|
-
// Generate the Huffman codes and for each, make the table entries
|
|
250
|
-
x[0] = i = 0 // first Huffman code is zero
|
|
251
|
-
p = v
|
|
252
|
-
pidx = 0 // grab values in bit order
|
|
253
|
-
h = -1 // no tables yet--level -1
|
|
254
|
-
w = lx[0] = 0 // no bits decoded yet
|
|
255
|
-
q = null // ditto
|
|
256
|
-
z = 0 // ditto
|
|
257
|
-
|
|
258
|
-
// go through the bit lengths (k already is bits in shortest code)
|
|
259
|
-
for (null; k <= g; k++) {
|
|
260
|
-
a = c[k]
|
|
261
|
-
while (a-- > 0) {
|
|
262
|
-
// here i is the Huffman code of length k bits for value p[pidx]
|
|
263
|
-
// make tables up to required level
|
|
264
|
-
while (k > w + lx[1 + h]) {
|
|
265
|
-
w += lx[1 + h] // add bits already decoded
|
|
266
|
-
h++
|
|
267
|
-
|
|
268
|
-
// compute minimum size table less than or equal to *m bits
|
|
269
|
-
z = (z = g - w) > mm ? mm : z // upper limit
|
|
270
|
-
if ((f = 1 << (j = k - w)) > a + 1) {
|
|
271
|
-
// try a k-w bit table
|
|
272
|
-
// too few codes for k-w bit table
|
|
273
|
-
f -= a + 1 // deduct codes from patterns left
|
|
274
|
-
xp = k
|
|
275
|
-
while (++j < z) {
|
|
276
|
-
// try smaller tables up to z bits
|
|
277
|
-
if ((f <<= 1) <= c[++xp]) {
|
|
278
|
-
break // enough codes to use up j bits
|
|
279
|
-
}
|
|
280
|
-
f -= c[xp] // else deduct codes from patterns
|
|
281
|
-
}
|
|
282
|
-
}
|
|
283
|
-
if (w + j > el && w < el) {
|
|
284
|
-
j = el - w // make EOB code end at table
|
|
285
|
-
}
|
|
286
|
-
z = 1 << j // table entries for j-bit table
|
|
287
|
-
lx[1 + h] = j // set table size in stack
|
|
288
|
-
|
|
289
|
-
// allocate and link in new table
|
|
290
|
-
q = []
|
|
291
|
-
for (o = 0; o < z; o++) {
|
|
292
|
-
q[o] = new HuftNode()
|
|
293
|
-
}
|
|
294
|
-
|
|
295
|
-
if (!tail) {
|
|
296
|
-
tail = this.root = new HuftList()
|
|
297
|
-
} else {
|
|
298
|
-
tail = tail.next = new HuftList()
|
|
299
|
-
}
|
|
300
|
-
tail.next = null
|
|
301
|
-
tail.list = q
|
|
302
|
-
u[h] = q // table starts after link
|
|
303
|
-
|
|
304
|
-
/* connect to last table, if there is one */
|
|
305
|
-
if (h > 0) {
|
|
306
|
-
x[h] = i // save pattern for backing up
|
|
307
|
-
r.b = lx[h] // bits to dump before this table
|
|
308
|
-
r.e = 16 + j // bits in this table
|
|
309
|
-
r.t = q // pointer to this table
|
|
310
|
-
j = (i & ((1 << w) - 1)) >> (w - lx[h])
|
|
311
|
-
u[h - 1][j].e = r.e
|
|
312
|
-
u[h - 1][j].b = r.b
|
|
313
|
-
u[h - 1][j].n = r.n
|
|
314
|
-
u[h - 1][j].t = r.t
|
|
315
|
-
}
|
|
316
|
-
}
|
|
317
|
-
|
|
318
|
-
// set up table entry in r
|
|
319
|
-
r.b = k - w
|
|
320
|
-
if (pidx >= n) {
|
|
321
|
-
r.e = 99 // out of values--invalid code
|
|
322
|
-
} else if (p[pidx] < s) {
|
|
323
|
-
r.e = p[pidx] < 256 ? 16 : 15 // 256 is end-of-block code
|
|
324
|
-
r.n = p[pidx++] // simple code is just the value
|
|
325
|
-
} else {
|
|
326
|
-
r.e = e[p[pidx] - s] // non-simple--look up in lists
|
|
327
|
-
r.n = d[p[pidx++] - s]
|
|
328
|
-
}
|
|
329
|
-
|
|
330
|
-
// fill code-like entries with r //
|
|
331
|
-
f = 1 << (k - w)
|
|
332
|
-
for (j = i >> w; j < z; j += f) {
|
|
333
|
-
q[j].e = r.e
|
|
334
|
-
q[j].b = r.b
|
|
335
|
-
q[j].n = r.n
|
|
336
|
-
q[j].t = r.t
|
|
337
|
-
}
|
|
338
|
-
|
|
339
|
-
// backwards increment the k-bit code i
|
|
340
|
-
for (j = 1 << (k - 1); (i & j) !== 0; j >>= 1) {
|
|
341
|
-
i ^= j
|
|
342
|
-
}
|
|
343
|
-
i ^= j
|
|
344
|
-
|
|
345
|
-
// backup over finished tables
|
|
346
|
-
while ((i & ((1 << w) - 1)) !== x[h]) {
|
|
347
|
-
w -= lx[h] // don't need to update q
|
|
348
|
-
h--
|
|
349
|
-
}
|
|
350
|
-
}
|
|
351
|
-
}
|
|
352
|
-
|
|
353
|
-
/* return actual size of base table */
|
|
354
|
-
this.m = lx[1]
|
|
355
|
-
|
|
356
|
-
/* Return true (1) if we were given an incomplete table */
|
|
357
|
-
this.status = y !== 0 && g !== 1 ? 1 : 0
|
|
358
|
-
}
|
|
359
|
-
|
|
360
|
-
/* routines (inflate) */
|
|
361
|
-
|
|
362
|
-
export function GET_BYTE() {
|
|
363
|
-
if (inflate_data.length === inflate_pos) {
|
|
364
|
-
return -1
|
|
365
|
-
}
|
|
366
|
-
return inflate_data[inflate_pos++] & 0xff
|
|
367
|
-
}
|
|
368
|
-
|
|
369
|
-
export function NEEDBITS(n) {
|
|
370
|
-
while (bit_len < n) {
|
|
371
|
-
bit_buf |= GET_BYTE() << bit_len
|
|
372
|
-
bit_len += 8
|
|
373
|
-
}
|
|
374
|
-
}
|
|
375
|
-
|
|
376
|
-
export function GETBITS(n) {
|
|
377
|
-
return bit_buf & MASK_BITS[n]
|
|
378
|
-
}
|
|
379
|
-
|
|
380
|
-
export function DUMPBITS(n) {
|
|
381
|
-
bit_buf >>= n
|
|
382
|
-
bit_len -= n
|
|
383
|
-
}
|
|
384
|
-
|
|
385
|
-
export function inflate_codes(buff, off, size) {
|
|
386
|
-
// inflate (decompress) the codes in a deflated (compressed) block.
|
|
387
|
-
// Return an error code or zero if it all goes ok.
|
|
388
|
-
let e // table entry flag/number of extra bits
|
|
389
|
-
let t // (HuftNode) pointer to table entry
|
|
390
|
-
let n
|
|
391
|
-
|
|
392
|
-
if (size === 0) {
|
|
393
|
-
return 0
|
|
394
|
-
}
|
|
395
|
-
|
|
396
|
-
// inflate the coded data
|
|
397
|
-
n = 0
|
|
398
|
-
for (;;) {
|
|
399
|
-
// do until end of block
|
|
400
|
-
NEEDBITS(bl)
|
|
401
|
-
t = tl.list[GETBITS(bl)]
|
|
402
|
-
e = t.e
|
|
403
|
-
while (e > 16) {
|
|
404
|
-
if (e === 99) {
|
|
405
|
-
return -1
|
|
406
|
-
}
|
|
407
|
-
DUMPBITS(t.b)
|
|
408
|
-
e -= 16
|
|
409
|
-
NEEDBITS(e)
|
|
410
|
-
t = t.t[GETBITS(e)]
|
|
411
|
-
e = t.e
|
|
412
|
-
}
|
|
413
|
-
DUMPBITS(t.b)
|
|
414
|
-
|
|
415
|
-
if (e === 16) {
|
|
416
|
-
// then it's a literal
|
|
417
|
-
wp &= WSIZE - 1
|
|
418
|
-
buff[off + n++] = slide[wp++] = t.n
|
|
419
|
-
if (n === size) {
|
|
420
|
-
return size
|
|
421
|
-
}
|
|
422
|
-
continue
|
|
423
|
-
}
|
|
424
|
-
|
|
425
|
-
// exit if end of block
|
|
426
|
-
if (e === 15) {
|
|
427
|
-
break
|
|
428
|
-
}
|
|
429
|
-
|
|
430
|
-
// it's an EOB or a length
|
|
431
|
-
|
|
432
|
-
// get length of block to copy
|
|
433
|
-
NEEDBITS(e)
|
|
434
|
-
copy_leng = t.n + GETBITS(e)
|
|
435
|
-
DUMPBITS(e)
|
|
436
|
-
|
|
437
|
-
// decode distance of block to copy
|
|
438
|
-
NEEDBITS(bd)
|
|
439
|
-
t = td.list[GETBITS(bd)]
|
|
440
|
-
e = t.e
|
|
441
|
-
|
|
442
|
-
while (e > 16) {
|
|
443
|
-
if (e === 99) {
|
|
444
|
-
return -1
|
|
445
|
-
}
|
|
446
|
-
DUMPBITS(t.b)
|
|
447
|
-
e -= 16
|
|
448
|
-
NEEDBITS(e)
|
|
449
|
-
t = t.t[GETBITS(e)]
|
|
450
|
-
e = t.e
|
|
451
|
-
}
|
|
452
|
-
DUMPBITS(t.b)
|
|
453
|
-
NEEDBITS(e)
|
|
454
|
-
copy_dist = wp - t.n - GETBITS(e)
|
|
455
|
-
DUMPBITS(e)
|
|
456
|
-
|
|
457
|
-
// do the copy
|
|
458
|
-
while (copy_leng > 0 && n < size) {
|
|
459
|
-
copy_leng--
|
|
460
|
-
copy_dist &= WSIZE - 1
|
|
461
|
-
wp &= WSIZE - 1
|
|
462
|
-
buff[off + n++] = slide[wp++] = slide[copy_dist++]
|
|
463
|
-
}
|
|
464
|
-
|
|
465
|
-
if (n === size) {
|
|
466
|
-
return size
|
|
467
|
-
}
|
|
468
|
-
}
|
|
469
|
-
|
|
470
|
-
method = -1 // done
|
|
471
|
-
return n
|
|
472
|
-
}
|
|
473
|
-
|
|
474
|
-
export function inflate_stored(buff, off, size) {
|
|
475
|
-
/* "decompress" an inflated type 0 (stored) block. */
|
|
476
|
-
let n
|
|
477
|
-
|
|
478
|
-
// go to byte boundary
|
|
479
|
-
n = bit_len & 7
|
|
480
|
-
DUMPBITS(n)
|
|
481
|
-
|
|
482
|
-
// get the length and its complement
|
|
483
|
-
NEEDBITS(16)
|
|
484
|
-
n = GETBITS(16)
|
|
485
|
-
DUMPBITS(16)
|
|
486
|
-
NEEDBITS(16)
|
|
487
|
-
if (n !== (~bit_buf & 0xffff)) {
|
|
488
|
-
return -1 // error in compressed data
|
|
489
|
-
}
|
|
490
|
-
DUMPBITS(16)
|
|
491
|
-
|
|
492
|
-
// read and output the compressed data
|
|
493
|
-
copy_leng = n
|
|
494
|
-
|
|
495
|
-
n = 0
|
|
496
|
-
while (copy_leng > 0 && n < size) {
|
|
497
|
-
copy_leng--
|
|
498
|
-
wp &= WSIZE - 1
|
|
499
|
-
NEEDBITS(8)
|
|
500
|
-
buff[off + n++] = slide[wp++] = GETBITS(8)
|
|
501
|
-
DUMPBITS(8)
|
|
502
|
-
}
|
|
503
|
-
|
|
504
|
-
if (copy_leng === 0) {
|
|
505
|
-
method = -1 // done
|
|
506
|
-
}
|
|
507
|
-
return n
|
|
508
|
-
}
|
|
509
|
-
|
|
510
|
-
export function inflate_fixed(buff, off, size) {
|
|
511
|
-
// decompress an inflated type 1 (fixed Huffman codes) block. We should
|
|
512
|
-
// either replace this with a custom decoder, or at least precompute the
|
|
513
|
-
// Huffman tables.
|
|
514
|
-
|
|
515
|
-
// if first time, set up tables for fixed blocks
|
|
516
|
-
if (!fixed_tl) {
|
|
517
|
-
let i // temporary variable
|
|
518
|
-
const l = [] // 288 length list for huft_build (initialized below)
|
|
519
|
-
let h // HuftBuild
|
|
520
|
-
|
|
521
|
-
// literal table
|
|
522
|
-
for (i = 0; i < 144; i++) {
|
|
523
|
-
l[i] = 8
|
|
524
|
-
}
|
|
525
|
-
for (null; i < 256; i++) {
|
|
526
|
-
l[i] = 9
|
|
527
|
-
}
|
|
528
|
-
for (null; i < 280; i++) {
|
|
529
|
-
l[i] = 7
|
|
530
|
-
}
|
|
531
|
-
for (null; i < 288; i++) {
|
|
532
|
-
// make a complete, but wrong code set
|
|
533
|
-
l[i] = 8
|
|
534
|
-
}
|
|
535
|
-
fixed_bl = 7
|
|
536
|
-
|
|
537
|
-
h = new HuftBuild(l, 288, 257, cplens, cplext, fixed_bl)
|
|
538
|
-
if (h.status !== 0) {
|
|
539
|
-
console.error('HufBuild error: ' + h.status)
|
|
540
|
-
return -1
|
|
541
|
-
}
|
|
542
|
-
fixed_tl = h.root
|
|
543
|
-
fixed_bl = h.m
|
|
544
|
-
|
|
545
|
-
// distance table
|
|
546
|
-
for (i = 0; i < 30; i++) {
|
|
547
|
-
// make an incomplete code set
|
|
548
|
-
l[i] = 5
|
|
549
|
-
}
|
|
550
|
-
fixed_bd = 5
|
|
551
|
-
|
|
552
|
-
h = new HuftBuild(l, 30, 0, cpdist, cpdext, fixed_bd)
|
|
553
|
-
if (h.status > 1) {
|
|
554
|
-
fixed_tl = null
|
|
555
|
-
console.error('HufBuild error: ' + h.status)
|
|
556
|
-
return -1
|
|
557
|
-
}
|
|
558
|
-
fixed_td = h.root
|
|
559
|
-
fixed_bd = h.m
|
|
560
|
-
}
|
|
561
|
-
|
|
562
|
-
tl = fixed_tl
|
|
563
|
-
td = fixed_td
|
|
564
|
-
bl = fixed_bl
|
|
565
|
-
bd = fixed_bd
|
|
566
|
-
return inflate_codes(buff, off, size)
|
|
567
|
-
}
|
|
568
|
-
|
|
569
|
-
export function inflate_dynamic(buff, off, size) {
|
|
570
|
-
// decompress an inflated type 2 (dynamic Huffman codes) block.
|
|
571
|
-
let i // temporary variables
|
|
572
|
-
let j
|
|
573
|
-
let l // last length
|
|
574
|
-
let n // number of lengths to get
|
|
575
|
-
let t // (HuftNode) literal/length code table
|
|
576
|
-
let nb // number of bit length codes
|
|
577
|
-
let nl // number of literal/length codes
|
|
578
|
-
let nd // number of distance codes
|
|
579
|
-
const ll = []
|
|
580
|
-
let h // (HuftBuild)
|
|
581
|
-
|
|
582
|
-
// literal/length and distance code lengths
|
|
583
|
-
for (i = 0; i < 286 + 30; i++) {
|
|
584
|
-
ll[i] = 0
|
|
585
|
-
}
|
|
586
|
-
|
|
587
|
-
// read in table lengths
|
|
588
|
-
NEEDBITS(5)
|
|
589
|
-
nl = 257 + GETBITS(5) // number of literal/length codes
|
|
590
|
-
DUMPBITS(5)
|
|
591
|
-
NEEDBITS(5)
|
|
592
|
-
nd = 1 + GETBITS(5) // number of distance codes
|
|
593
|
-
DUMPBITS(5)
|
|
594
|
-
NEEDBITS(4)
|
|
595
|
-
nb = 4 + GETBITS(4) // number of bit length codes
|
|
596
|
-
DUMPBITS(4)
|
|
597
|
-
if (nl > 286 || nd > 30) {
|
|
598
|
-
return -1 // bad lengths
|
|
599
|
-
}
|
|
600
|
-
|
|
601
|
-
// read in bit-length-code lengths
|
|
602
|
-
for (j = 0; j < nb; j++) {
|
|
603
|
-
NEEDBITS(3)
|
|
604
|
-
ll[border[j]] = GETBITS(3)
|
|
605
|
-
DUMPBITS(3)
|
|
606
|
-
}
|
|
607
|
-
for (null; j < 19; j++) {
|
|
608
|
-
ll[border[j]] = 0
|
|
609
|
-
}
|
|
610
|
-
|
|
611
|
-
// build decoding table for trees--single level, 7 bit lookup
|
|
612
|
-
bl = 7
|
|
613
|
-
h = new HuftBuild(ll, 19, 19, null, null, bl)
|
|
614
|
-
if (h.status !== 0) {
|
|
615
|
-
return -1 // incomplete code set
|
|
616
|
-
}
|
|
617
|
-
|
|
618
|
-
tl = h.root
|
|
619
|
-
bl = h.m
|
|
620
|
-
|
|
621
|
-
// read in literal and distance code lengths
|
|
622
|
-
n = nl + nd
|
|
623
|
-
i = l = 0
|
|
624
|
-
while (i < n) {
|
|
625
|
-
NEEDBITS(bl)
|
|
626
|
-
t = tl.list[GETBITS(bl)]
|
|
627
|
-
j = t.b
|
|
628
|
-
DUMPBITS(j)
|
|
629
|
-
j = t.n
|
|
630
|
-
if (j < 16) {
|
|
631
|
-
// length of code in bits (0..15)
|
|
632
|
-
ll[i++] = l = j // save last length in l
|
|
633
|
-
} else if (j === 16) {
|
|
634
|
-
// repeat last length 3 to 6 times
|
|
635
|
-
NEEDBITS(2)
|
|
636
|
-
j = 3 + GETBITS(2)
|
|
637
|
-
DUMPBITS(2)
|
|
638
|
-
if (i + j > n) {
|
|
639
|
-
return -1
|
|
640
|
-
}
|
|
641
|
-
while (j-- > 0) {
|
|
642
|
-
ll[i++] = l
|
|
643
|
-
}
|
|
644
|
-
} else if (j === 17) {
|
|
645
|
-
// 3 to 10 zero length codes
|
|
646
|
-
NEEDBITS(3)
|
|
647
|
-
j = 3 + GETBITS(3)
|
|
648
|
-
DUMPBITS(3)
|
|
649
|
-
if (i + j > n) {
|
|
650
|
-
return -1
|
|
651
|
-
}
|
|
652
|
-
while (j-- > 0) {
|
|
653
|
-
ll[i++] = 0
|
|
654
|
-
}
|
|
655
|
-
l = 0
|
|
656
|
-
} else {
|
|
657
|
-
// j === 18: 11 to 138 zero length codes
|
|
658
|
-
NEEDBITS(7)
|
|
659
|
-
j = 11 + GETBITS(7)
|
|
660
|
-
DUMPBITS(7)
|
|
661
|
-
if (i + j > n) {
|
|
662
|
-
return -1
|
|
663
|
-
}
|
|
664
|
-
while (j-- > 0) {
|
|
665
|
-
ll[i++] = 0
|
|
666
|
-
}
|
|
667
|
-
l = 0
|
|
668
|
-
}
|
|
669
|
-
}
|
|
670
|
-
|
|
671
|
-
// build the decoding tables for literal/length and distance codes
|
|
672
|
-
bl = lbits
|
|
673
|
-
h = new HuftBuild(ll, nl, 257, cplens, cplext, bl)
|
|
674
|
-
if (bl === 0) {
|
|
675
|
-
// no literals or lengths
|
|
676
|
-
h.status = 1
|
|
677
|
-
}
|
|
678
|
-
if (h.status !== 0) {
|
|
679
|
-
if (h.status !== 1) {
|
|
680
|
-
return -1 // incomplete code set
|
|
681
|
-
}
|
|
682
|
-
// **incomplete literal tree**
|
|
683
|
-
}
|
|
684
|
-
tl = h.root
|
|
685
|
-
bl = h.m
|
|
686
|
-
|
|
687
|
-
for (i = 0; i < nd; i++) {
|
|
688
|
-
ll[i] = ll[i + nl]
|
|
689
|
-
}
|
|
690
|
-
bd = dbits
|
|
691
|
-
h = new HuftBuild(ll, nd, 0, cpdist, cpdext, bd)
|
|
692
|
-
td = h.root
|
|
693
|
-
bd = h.m
|
|
694
|
-
|
|
695
|
-
if (bd === 0 && nl > 257) {
|
|
696
|
-
// lengths but no distances
|
|
697
|
-
// **incomplete distance tree**
|
|
698
|
-
return -1
|
|
699
|
-
}
|
|
700
|
-
/*
|
|
701
|
-
if (h.status === 1) {
|
|
702
|
-
// **incomplete distance tree**
|
|
703
|
-
}
|
|
704
|
-
*/
|
|
705
|
-
if (h.status !== 0) {
|
|
706
|
-
return -1
|
|
707
|
-
}
|
|
708
|
-
|
|
709
|
-
// decompress until an end-of-block code
|
|
710
|
-
return inflate_codes(buff, off, size)
|
|
711
|
-
}
|
|
712
|
-
|
|
713
|
-
export function inflate_start() {
|
|
714
|
-
if (!slide) {
|
|
715
|
-
slide = [] // new Array(2 * WSIZE); // slide.length is never called
|
|
716
|
-
}
|
|
717
|
-
wp = 0
|
|
718
|
-
bit_buf = 0
|
|
719
|
-
bit_len = 0
|
|
720
|
-
method = -1
|
|
721
|
-
eof = false
|
|
722
|
-
copy_leng = copy_dist = 0
|
|
723
|
-
tl = null
|
|
724
|
-
}
|
|
725
|
-
|
|
726
|
-
export function inflate_internal(buff, off, size) {
|
|
727
|
-
// decompress an inflated entry
|
|
728
|
-
let n, i
|
|
729
|
-
|
|
730
|
-
n = 0
|
|
731
|
-
while (n < size) {
|
|
732
|
-
if (eof && method === -1) {
|
|
733
|
-
return n
|
|
734
|
-
}
|
|
735
|
-
|
|
736
|
-
if (copy_leng > 0) {
|
|
737
|
-
if (method !== STORED_BLOCK) {
|
|
738
|
-
// STATIC_TREES or DYN_TREES
|
|
739
|
-
while (copy_leng > 0 && n < size) {
|
|
740
|
-
copy_leng--
|
|
741
|
-
copy_dist &= WSIZE - 1
|
|
742
|
-
wp &= WSIZE - 1
|
|
743
|
-
buff[off + n++] = slide[wp++] = slide[copy_dist++]
|
|
744
|
-
}
|
|
745
|
-
} else {
|
|
746
|
-
while (copy_leng > 0 && n < size) {
|
|
747
|
-
copy_leng--
|
|
748
|
-
wp &= WSIZE - 1
|
|
749
|
-
NEEDBITS(8)
|
|
750
|
-
buff[off + n++] = slide[wp++] = GETBITS(8)
|
|
751
|
-
DUMPBITS(8)
|
|
752
|
-
}
|
|
753
|
-
if (copy_leng === 0) {
|
|
754
|
-
method = -1 // done
|
|
755
|
-
}
|
|
756
|
-
}
|
|
757
|
-
if (n === size) {
|
|
758
|
-
return n
|
|
759
|
-
}
|
|
760
|
-
}
|
|
761
|
-
|
|
762
|
-
if (method === -1) {
|
|
763
|
-
if (eof) {
|
|
764
|
-
break
|
|
765
|
-
}
|
|
766
|
-
|
|
767
|
-
// read in last block bit
|
|
768
|
-
NEEDBITS(1)
|
|
769
|
-
if (GETBITS(1) !== 0) {
|
|
770
|
-
eof = true
|
|
771
|
-
}
|
|
772
|
-
DUMPBITS(1)
|
|
773
|
-
|
|
774
|
-
// read in block type
|
|
775
|
-
NEEDBITS(2)
|
|
776
|
-
method = GETBITS(2)
|
|
777
|
-
DUMPBITS(2)
|
|
778
|
-
tl = null
|
|
779
|
-
copy_leng = 0
|
|
780
|
-
}
|
|
781
|
-
|
|
782
|
-
switch (method) {
|
|
783
|
-
case STORED_BLOCK:
|
|
784
|
-
i = inflate_stored(buff, off + n, size - n)
|
|
785
|
-
break
|
|
786
|
-
|
|
787
|
-
case STATIC_TREES:
|
|
788
|
-
if (tl) {
|
|
789
|
-
i = inflate_codes(buff, off + n, size - n)
|
|
790
|
-
} else {
|
|
791
|
-
i = inflate_fixed(buff, off + n, size - n)
|
|
792
|
-
}
|
|
793
|
-
break
|
|
794
|
-
|
|
795
|
-
case DYN_TREES:
|
|
796
|
-
if (tl) {
|
|
797
|
-
i = inflate_codes(buff, off + n, size - n)
|
|
798
|
-
} else {
|
|
799
|
-
i = inflate_dynamic(buff, off + n, size - n)
|
|
800
|
-
}
|
|
801
|
-
break
|
|
802
|
-
|
|
803
|
-
default:
|
|
804
|
-
// error
|
|
805
|
-
i = -1
|
|
806
|
-
break
|
|
807
|
-
}
|
|
808
|
-
|
|
809
|
-
if (i === -1) {
|
|
810
|
-
if (eof) {
|
|
811
|
-
return 0
|
|
812
|
-
}
|
|
813
|
-
return -1
|
|
814
|
-
}
|
|
815
|
-
n += i
|
|
816
|
-
}
|
|
817
|
-
return n
|
|
818
|
-
}
|
|
819
|
-
|
|
820
|
-
export function inflate(arr) {
|
|
821
|
-
const buff = []
|
|
822
|
-
let i
|
|
823
|
-
|
|
824
|
-
inflate_start()
|
|
825
|
-
inflate_data = arr
|
|
826
|
-
inflate_pos = 0
|
|
827
|
-
|
|
828
|
-
do {
|
|
829
|
-
i = inflate_internal(buff, buff.length, 1024)
|
|
830
|
-
} while (i > 0)
|
|
831
|
-
inflate_data = null // G.C.
|
|
832
|
-
return buff
|
|
833
|
-
}
|