zstd-wasm-vn 1.2.0 → 1.2.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/bundler/zstd_wasm_vn.d.ts +86 -75
- package/bundler/zstd_wasm_vn.js +5 -1
- package/bundler/zstd_wasm_vn_bg.js +230 -229
- package/bundler/zstd_wasm_vn_bg.wasm +0 -0
- package/bundler/zstd_wasm_vn_bg.wasm.d.ts +13 -12
- package/deno/zstd_wasm_vn.d.ts +86 -75
- package/deno/zstd_wasm_vn.js +227 -219
- package/deno/zstd_wasm_vn_bg.wasm +0 -0
- package/deno/zstd_wasm_vn_bg.wasm.d.ts +13 -12
- package/esm/zstd_wasm_vn.d.ts +86 -75
- package/esm/zstd_wasm_vn.js +444 -10
- package/esm/zstd_wasm_vn_bg.wasm +0 -0
- package/esm/zstd_wasm_vn_bg.wasm.d.ts +13 -12
- package/module/zstd_wasm_vn.d.ts +86 -75
- package/module/zstd_wasm_vn.js +227 -220
- package/module/zstd_wasm_vn_bg.wasm +0 -0
- package/module/zstd_wasm_vn_bg.wasm.d.ts +13 -12
- package/no-modules/zstd_wasm_vn.d.ts +170 -159
- package/no-modules/zstd_wasm_vn.js +269 -275
- package/no-modules/zstd_wasm_vn_bg.wasm +0 -0
- package/no-modules/zstd_wasm_vn_bg.wasm.d.ts +13 -12
- package/nodejs/zstd_wasm_vn.d.ts +86 -75
- package/nodejs/zstd_wasm_vn.js +243 -233
- package/nodejs/zstd_wasm_vn_bg.wasm +0 -0
- package/nodejs/zstd_wasm_vn_bg.wasm.d.ts +13 -12
- package/package.json +1 -1
- package/web/zstd_wasm_vn.d.ts +139 -126
- package/web/zstd_wasm_vn.js +269 -273
- package/web/zstd_wasm_vn_bg.wasm +0 -0
- package/web/zstd_wasm_vn_bg.wasm.d.ts +13 -12
- package/esm/zstd_wasm_vn_bg.js +0 -438
package/web/zstd_wasm_vn.js
CHANGED
|
@@ -1,169 +1,15 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
let cachedUint8ArrayMemory0 = null;
|
|
4
|
-
|
|
5
|
-
function getUint8ArrayMemory0() {
|
|
6
|
-
if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
|
|
7
|
-
cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
|
|
8
|
-
}
|
|
9
|
-
return cachedUint8ArrayMemory0;
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
|
|
13
|
-
|
|
14
|
-
cachedTextDecoder.decode();
|
|
15
|
-
|
|
16
|
-
const MAX_SAFARI_DECODE_BYTES = 2146435072;
|
|
17
|
-
let numBytesDecoded = 0;
|
|
18
|
-
function decodeText(ptr, len) {
|
|
19
|
-
numBytesDecoded += len;
|
|
20
|
-
if (numBytesDecoded >= MAX_SAFARI_DECODE_BYTES) {
|
|
21
|
-
cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
|
|
22
|
-
cachedTextDecoder.decode();
|
|
23
|
-
numBytesDecoded = len;
|
|
24
|
-
}
|
|
25
|
-
return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
function getStringFromWasm0(ptr, len) {
|
|
29
|
-
ptr = ptr >>> 0;
|
|
30
|
-
return decodeText(ptr, len);
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
let WASM_VECTOR_LEN = 0;
|
|
34
|
-
|
|
35
|
-
function passArray8ToWasm0(arg, malloc) {
|
|
36
|
-
const ptr = malloc(arg.length * 1, 1) >>> 0;
|
|
37
|
-
getUint8ArrayMemory0().set(arg, ptr / 1);
|
|
38
|
-
WASM_VECTOR_LEN = arg.length;
|
|
39
|
-
return ptr;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
function isLikeNone(x) {
|
|
43
|
-
return x === undefined || x === null;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
function takeFromExternrefTable0(idx) {
|
|
47
|
-
const value = wasm.__wbindgen_export_0.get(idx);
|
|
48
|
-
wasm.__externref_table_dealloc(idx);
|
|
49
|
-
return value;
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
function getArrayU8FromWasm0(ptr, len) {
|
|
53
|
-
ptr = ptr >>> 0;
|
|
54
|
-
return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
|
|
55
|
-
}
|
|
56
|
-
/**
|
|
57
|
-
* Compresses data using Zstandard compression
|
|
58
|
-
*
|
|
59
|
-
* # Arguments
|
|
60
|
-
*
|
|
61
|
-
* * `data` - Input data to compress
|
|
62
|
-
* * `level` - Compression level (1-22, default 6). Higher = better compression but slower
|
|
63
|
-
* @param {Uint8Array} data
|
|
64
|
-
* @param {number | null} [level]
|
|
65
|
-
* @returns {Uint8Array}
|
|
66
|
-
*/
|
|
67
|
-
export function compress(data, level) {
|
|
68
|
-
const ptr0 = passArray8ToWasm0(data, wasm.__wbindgen_malloc);
|
|
69
|
-
const len0 = WASM_VECTOR_LEN;
|
|
70
|
-
const ret = wasm.compress(ptr0, len0, isLikeNone(level) ? 0x100000001 : (level) >> 0);
|
|
71
|
-
if (ret[3]) {
|
|
72
|
-
throw takeFromExternrefTable0(ret[2]);
|
|
73
|
-
}
|
|
74
|
-
var v2 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
75
|
-
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
76
|
-
return v2;
|
|
77
|
-
}
|
|
1
|
+
/* @ts-self-types="./zstd_wasm_vn.d.ts" */
|
|
78
2
|
|
|
79
|
-
/**
|
|
80
|
-
* Compresses data using Zstandard compression with a dictionary
|
|
81
|
-
*
|
|
82
|
-
* # Arguments
|
|
83
|
-
*
|
|
84
|
-
* * `data` - Input data to compress
|
|
85
|
-
* * `dict` - The compression dictionary
|
|
86
|
-
* * `level` - Compression level (1-22, default 6). Higher = better compression but slower
|
|
87
|
-
* @param {Uint8Array} data
|
|
88
|
-
* @param {Uint8Array} dict
|
|
89
|
-
* @param {number | null} [level]
|
|
90
|
-
* @returns {Uint8Array}
|
|
91
|
-
*/
|
|
92
|
-
export function compress_with_dict(data, dict, level) {
|
|
93
|
-
const ptr0 = passArray8ToWasm0(data, wasm.__wbindgen_malloc);
|
|
94
|
-
const len0 = WASM_VECTOR_LEN;
|
|
95
|
-
const ptr1 = passArray8ToWasm0(dict, wasm.__wbindgen_malloc);
|
|
96
|
-
const len1 = WASM_VECTOR_LEN;
|
|
97
|
-
const ret = wasm.compress_with_dict(ptr0, len0, ptr1, len1, isLikeNone(level) ? 0x100000001 : (level) >> 0);
|
|
98
|
-
if (ret[3]) {
|
|
99
|
-
throw takeFromExternrefTable0(ret[2]);
|
|
100
|
-
}
|
|
101
|
-
var v3 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
102
|
-
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
103
|
-
return v3;
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
/**
|
|
107
|
-
* Decompresses Zstandard compressed data
|
|
108
|
-
*
|
|
109
|
-
* # Arguments
|
|
110
|
-
*
|
|
111
|
-
* * `compressed_data` - Zstandard compressed data
|
|
112
|
-
* @param {Uint8Array} compressed_data
|
|
113
|
-
* @returns {Uint8Array}
|
|
114
|
-
*/
|
|
115
|
-
export function decompress(compressed_data) {
|
|
116
|
-
const ptr0 = passArray8ToWasm0(compressed_data, wasm.__wbindgen_malloc);
|
|
117
|
-
const len0 = WASM_VECTOR_LEN;
|
|
118
|
-
const ret = wasm.decompress(ptr0, len0);
|
|
119
|
-
if (ret[3]) {
|
|
120
|
-
throw takeFromExternrefTable0(ret[2]);
|
|
121
|
-
}
|
|
122
|
-
var v2 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
123
|
-
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
124
|
-
return v2;
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
/**
|
|
128
|
-
* Decompresses Zstandard compressed data using a dictionary
|
|
129
|
-
*
|
|
130
|
-
* # Arguments
|
|
131
|
-
*
|
|
132
|
-
* * `data` - Zstandard compressed data
|
|
133
|
-
* * `dict` - The decompression dictionary (must match the compression dictionary)
|
|
134
|
-
* @param {Uint8Array} data
|
|
135
|
-
* @param {Uint8Array} dict
|
|
136
|
-
* @returns {Uint8Array}
|
|
137
|
-
*/
|
|
138
|
-
export function decompress_with_dict(data, dict) {
|
|
139
|
-
const ptr0 = passArray8ToWasm0(data, wasm.__wbindgen_malloc);
|
|
140
|
-
const len0 = WASM_VECTOR_LEN;
|
|
141
|
-
const ptr1 = passArray8ToWasm0(dict, wasm.__wbindgen_malloc);
|
|
142
|
-
const len1 = WASM_VECTOR_LEN;
|
|
143
|
-
const ret = wasm.decompress_with_dict(ptr0, len0, ptr1, len1);
|
|
144
|
-
if (ret[3]) {
|
|
145
|
-
throw takeFromExternrefTable0(ret[2]);
|
|
146
|
-
}
|
|
147
|
-
var v3 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
148
|
-
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
149
|
-
return v3;
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
const ZstdFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
153
|
-
? { register: () => {}, unregister: () => {} }
|
|
154
|
-
: new FinalizationRegistry(ptr => wasm.__wbg_zstd_free(ptr >>> 0, 1));
|
|
155
3
|
/**
|
|
156
4
|
* ZSTD compression and decompression for WebAssembly
|
|
157
5
|
*/
|
|
158
6
|
export class Zstd {
|
|
159
|
-
|
|
160
7
|
__destroy_into_raw() {
|
|
161
8
|
const ptr = this.__wbg_ptr;
|
|
162
9
|
this.__wbg_ptr = 0;
|
|
163
10
|
ZstdFinalization.unregister(this);
|
|
164
11
|
return ptr;
|
|
165
12
|
}
|
|
166
|
-
|
|
167
13
|
free() {
|
|
168
14
|
const ptr = this.__destroy_into_raw();
|
|
169
15
|
wasm.__wbg_zstd_free(ptr, 0);
|
|
@@ -184,6 +30,15 @@ export class Zstd {
|
|
|
184
30
|
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
185
31
|
return v2;
|
|
186
32
|
}
|
|
33
|
+
/**
|
|
34
|
+
* Estimates the compressed size for planning purposes
|
|
35
|
+
* @param {number} input_size
|
|
36
|
+
* @returns {number}
|
|
37
|
+
*/
|
|
38
|
+
static compressBound(input_size) {
|
|
39
|
+
const ret = wasm.zstd_compressBound(input_size);
|
|
40
|
+
return ret >>> 0;
|
|
41
|
+
}
|
|
187
42
|
/**
|
|
188
43
|
* @param {Uint8Array} data
|
|
189
44
|
* @param {Uint8Array} dict
|
|
@@ -203,6 +58,16 @@ export class Zstd {
|
|
|
203
58
|
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
204
59
|
return v3;
|
|
205
60
|
}
|
|
61
|
+
/**
|
|
62
|
+
* Calculates compression ratio (smaller = better compression)
|
|
63
|
+
* @param {number} original_size
|
|
64
|
+
* @param {number} compressed_size
|
|
65
|
+
* @returns {number}
|
|
66
|
+
*/
|
|
67
|
+
static compressionRatio(original_size, compressed_size) {
|
|
68
|
+
const ret = wasm.zstd_compressionRatio(original_size, compressed_size);
|
|
69
|
+
return ret;
|
|
70
|
+
}
|
|
206
71
|
/**
|
|
207
72
|
* @param {Uint8Array} compressed_data
|
|
208
73
|
* @returns {Uint8Array}
|
|
@@ -244,14 +109,6 @@ export class Zstd {
|
|
|
244
109
|
const ret = wasm.zstd_defaultCompressionLevel();
|
|
245
110
|
return ret;
|
|
246
111
|
}
|
|
247
|
-
/**
|
|
248
|
-
* Returns the minimum compression level
|
|
249
|
-
* @returns {number}
|
|
250
|
-
*/
|
|
251
|
-
static minCompressionLevel() {
|
|
252
|
-
const ret = wasm.zstd_minCompressionLevel();
|
|
253
|
-
return ret;
|
|
254
|
-
}
|
|
255
112
|
/**
|
|
256
113
|
* Returns the maximum compression level
|
|
257
114
|
* @returns {number}
|
|
@@ -261,22 +118,11 @@ export class Zstd {
|
|
|
261
118
|
return ret;
|
|
262
119
|
}
|
|
263
120
|
/**
|
|
264
|
-
*
|
|
265
|
-
* @param {number} input_size
|
|
266
|
-
* @returns {number}
|
|
267
|
-
*/
|
|
268
|
-
static compressBound(input_size) {
|
|
269
|
-
const ret = wasm.zstd_compressBound(input_size);
|
|
270
|
-
return ret >>> 0;
|
|
271
|
-
}
|
|
272
|
-
/**
|
|
273
|
-
* Calculates compression ratio (smaller = better compression)
|
|
274
|
-
* @param {number} original_size
|
|
275
|
-
* @param {number} compressed_size
|
|
121
|
+
* Returns the minimum compression level
|
|
276
122
|
* @returns {number}
|
|
277
123
|
*/
|
|
278
|
-
static
|
|
279
|
-
const ret = wasm.
|
|
124
|
+
static minCompressionLevel() {
|
|
125
|
+
const ret = wasm.zstd_minCompressionLevel();
|
|
280
126
|
return ret;
|
|
281
127
|
}
|
|
282
128
|
/**
|
|
@@ -292,39 +138,21 @@ export class Zstd {
|
|
|
292
138
|
}
|
|
293
139
|
if (Symbol.dispose) Zstd.prototype[Symbol.dispose] = Zstd.prototype.free;
|
|
294
140
|
|
|
295
|
-
const ZstdCompressorFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
296
|
-
? { register: () => {}, unregister: () => {} }
|
|
297
|
-
: new FinalizationRegistry(ptr => wasm.__wbg_zstdcompressor_free(ptr >>> 0, 1));
|
|
298
141
|
/**
|
|
299
142
|
* ==================================== [Streaming] ====================================
|
|
300
143
|
* Streaming compression for large data
|
|
301
144
|
*/
|
|
302
145
|
export class ZstdCompressor {
|
|
303
|
-
|
|
304
146
|
__destroy_into_raw() {
|
|
305
147
|
const ptr = this.__wbg_ptr;
|
|
306
148
|
this.__wbg_ptr = 0;
|
|
307
149
|
ZstdCompressorFinalization.unregister(this);
|
|
308
150
|
return ptr;
|
|
309
151
|
}
|
|
310
|
-
|
|
311
152
|
free() {
|
|
312
153
|
const ptr = this.__destroy_into_raw();
|
|
313
154
|
wasm.__wbg_zstdcompressor_free(ptr, 0);
|
|
314
155
|
}
|
|
315
|
-
/**
|
|
316
|
-
* Creates a new streaming compressor
|
|
317
|
-
* @param {number | null} [level]
|
|
318
|
-
*/
|
|
319
|
-
constructor(level) {
|
|
320
|
-
const ret = wasm.zstdcompressor_new(isLikeNone(level) ? 0x100000001 : (level) >> 0);
|
|
321
|
-
if (ret[2]) {
|
|
322
|
-
throw takeFromExternrefTable0(ret[1]);
|
|
323
|
-
}
|
|
324
|
-
this.__wbg_ptr = ret[0] >>> 0;
|
|
325
|
-
ZstdCompressorFinalization.register(this, this.__wbg_ptr, this);
|
|
326
|
-
return this;
|
|
327
|
-
}
|
|
328
156
|
/**
|
|
329
157
|
* Compresses a chunk of data
|
|
330
158
|
* @param {Uint8Array} data
|
|
@@ -350,43 +178,50 @@ export class ZstdCompressor {
|
|
|
350
178
|
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
351
179
|
return v1;
|
|
352
180
|
}
|
|
181
|
+
/**
|
|
182
|
+
* Creates a new streaming compressor
|
|
183
|
+
* @param {number | null} [level]
|
|
184
|
+
*/
|
|
185
|
+
constructor(level) {
|
|
186
|
+
const ret = wasm.zstdcompressor_new(isLikeNone(level) ? 0x100000001 : (level) >> 0);
|
|
187
|
+
if (ret[2]) {
|
|
188
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
189
|
+
}
|
|
190
|
+
this.__wbg_ptr = ret[0] >>> 0;
|
|
191
|
+
ZstdCompressorFinalization.register(this, this.__wbg_ptr, this);
|
|
192
|
+
return this;
|
|
193
|
+
}
|
|
194
|
+
/**
|
|
195
|
+
* Flush the internal buffer to get compressed data for this chunk
|
|
196
|
+
* @param {number} at
|
|
197
|
+
* @returns {Uint8Array}
|
|
198
|
+
*/
|
|
199
|
+
split_off_chunk(at) {
|
|
200
|
+
const ret = wasm.zstdcompressor_split_off_chunk(this.__wbg_ptr, at);
|
|
201
|
+
if (ret[3]) {
|
|
202
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
203
|
+
}
|
|
204
|
+
var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
205
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
206
|
+
return v1;
|
|
207
|
+
}
|
|
353
208
|
}
|
|
354
209
|
if (Symbol.dispose) ZstdCompressor.prototype[Symbol.dispose] = ZstdCompressor.prototype.free;
|
|
355
210
|
|
|
356
|
-
const ZstdDecompressorFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
357
|
-
? { register: () => {}, unregister: () => {} }
|
|
358
|
-
: new FinalizationRegistry(ptr => wasm.__wbg_zstddecompressor_free(ptr >>> 0, 1));
|
|
359
211
|
/**
|
|
360
212
|
* Streaming decompression for large data
|
|
361
213
|
*/
|
|
362
214
|
export class ZstdDecompressor {
|
|
363
|
-
|
|
364
215
|
__destroy_into_raw() {
|
|
365
216
|
const ptr = this.__wbg_ptr;
|
|
366
217
|
this.__wbg_ptr = 0;
|
|
367
218
|
ZstdDecompressorFinalization.unregister(this);
|
|
368
219
|
return ptr;
|
|
369
220
|
}
|
|
370
|
-
|
|
371
221
|
free() {
|
|
372
222
|
const ptr = this.__destroy_into_raw();
|
|
373
223
|
wasm.__wbg_zstddecompressor_free(ptr, 0);
|
|
374
224
|
}
|
|
375
|
-
/**
|
|
376
|
-
* Creates a new streaming decompressor
|
|
377
|
-
* @param {Uint8Array} compressed_data
|
|
378
|
-
*/
|
|
379
|
-
constructor(compressed_data) {
|
|
380
|
-
const ptr0 = passArray8ToWasm0(compressed_data, wasm.__wbindgen_malloc);
|
|
381
|
-
const len0 = WASM_VECTOR_LEN;
|
|
382
|
-
const ret = wasm.zstddecompressor_new(ptr0, len0);
|
|
383
|
-
if (ret[2]) {
|
|
384
|
-
throw takeFromExternrefTable0(ret[1]);
|
|
385
|
-
}
|
|
386
|
-
this.__wbg_ptr = ret[0] >>> 0;
|
|
387
|
-
ZstdDecompressorFinalization.register(this, this.__wbg_ptr, this);
|
|
388
|
-
return this;
|
|
389
|
-
}
|
|
390
225
|
/**
|
|
391
226
|
* Decompresses a chunk of data
|
|
392
227
|
* @param {number} max_output_size
|
|
@@ -414,88 +249,257 @@ export class ZstdDecompressor {
|
|
|
414
249
|
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
415
250
|
return v1;
|
|
416
251
|
}
|
|
252
|
+
/**
|
|
253
|
+
* Creates a new streaming decompressor
|
|
254
|
+
* @param {Uint8Array} compressed_data
|
|
255
|
+
*/
|
|
256
|
+
constructor(compressed_data) {
|
|
257
|
+
const ptr0 = passArray8ToWasm0(compressed_data, wasm.__wbindgen_malloc);
|
|
258
|
+
const len0 = WASM_VECTOR_LEN;
|
|
259
|
+
const ret = wasm.zstddecompressor_new(ptr0, len0);
|
|
260
|
+
if (ret[2]) {
|
|
261
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
262
|
+
}
|
|
263
|
+
this.__wbg_ptr = ret[0] >>> 0;
|
|
264
|
+
ZstdDecompressorFinalization.register(this, this.__wbg_ptr, this);
|
|
265
|
+
return this;
|
|
266
|
+
}
|
|
417
267
|
}
|
|
418
268
|
if (Symbol.dispose) ZstdDecompressor.prototype[Symbol.dispose] = ZstdDecompressor.prototype.free;
|
|
419
269
|
|
|
420
|
-
|
|
270
|
+
/**
|
|
271
|
+
* Compresses data using Zstandard compression
|
|
272
|
+
*
|
|
273
|
+
* # Arguments
|
|
274
|
+
*
|
|
275
|
+
* * `data` - Input data to compress
|
|
276
|
+
* * `level` - Compression level (1-22, default 6). Higher = better compression but slower
|
|
277
|
+
* @param {Uint8Array} data
|
|
278
|
+
* @param {number | null} [level]
|
|
279
|
+
* @returns {Uint8Array}
|
|
280
|
+
*/
|
|
281
|
+
export function compress(data, level) {
|
|
282
|
+
const ptr0 = passArray8ToWasm0(data, wasm.__wbindgen_malloc);
|
|
283
|
+
const len0 = WASM_VECTOR_LEN;
|
|
284
|
+
const ret = wasm.compress(ptr0, len0, isLikeNone(level) ? 0x100000001 : (level) >> 0);
|
|
285
|
+
if (ret[3]) {
|
|
286
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
287
|
+
}
|
|
288
|
+
var v2 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
289
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
290
|
+
return v2;
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
/**
|
|
294
|
+
* Compresses data using Zstandard compression with a dictionary
|
|
295
|
+
*
|
|
296
|
+
* # Arguments
|
|
297
|
+
*
|
|
298
|
+
* * `data` - Input data to compress
|
|
299
|
+
* * `dict` - The compression dictionary
|
|
300
|
+
* * `level` - Compression level (1-22, default 6). Higher = better compression but slower
|
|
301
|
+
* @param {Uint8Array} data
|
|
302
|
+
* @param {Uint8Array} dict
|
|
303
|
+
* @param {number | null} [level]
|
|
304
|
+
* @returns {Uint8Array}
|
|
305
|
+
*/
|
|
306
|
+
export function compress_with_dict(data, dict, level) {
|
|
307
|
+
const ptr0 = passArray8ToWasm0(data, wasm.__wbindgen_malloc);
|
|
308
|
+
const len0 = WASM_VECTOR_LEN;
|
|
309
|
+
const ptr1 = passArray8ToWasm0(dict, wasm.__wbindgen_malloc);
|
|
310
|
+
const len1 = WASM_VECTOR_LEN;
|
|
311
|
+
const ret = wasm.compress_with_dict(ptr0, len0, ptr1, len1, isLikeNone(level) ? 0x100000001 : (level) >> 0);
|
|
312
|
+
if (ret[3]) {
|
|
313
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
314
|
+
}
|
|
315
|
+
var v3 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
316
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
317
|
+
return v3;
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
/**
|
|
321
|
+
* Decompresses Zstandard compressed data
|
|
322
|
+
*
|
|
323
|
+
* # Arguments
|
|
324
|
+
*
|
|
325
|
+
* * `compressed_data` - Zstandard compressed data
|
|
326
|
+
* @param {Uint8Array} compressed_data
|
|
327
|
+
* @returns {Uint8Array}
|
|
328
|
+
*/
|
|
329
|
+
export function decompress(compressed_data) {
|
|
330
|
+
const ptr0 = passArray8ToWasm0(compressed_data, wasm.__wbindgen_malloc);
|
|
331
|
+
const len0 = WASM_VECTOR_LEN;
|
|
332
|
+
const ret = wasm.decompress(ptr0, len0);
|
|
333
|
+
if (ret[3]) {
|
|
334
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
335
|
+
}
|
|
336
|
+
var v2 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
337
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
338
|
+
return v2;
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
/**
|
|
342
|
+
* Decompresses Zstandard compressed data using a dictionary
|
|
343
|
+
*
|
|
344
|
+
* # Arguments
|
|
345
|
+
*
|
|
346
|
+
* * `data` - Zstandard compressed data
|
|
347
|
+
* * `dict` - The decompression dictionary (must match the compression dictionary)
|
|
348
|
+
* @param {Uint8Array} data
|
|
349
|
+
* @param {Uint8Array} dict
|
|
350
|
+
* @returns {Uint8Array}
|
|
351
|
+
*/
|
|
352
|
+
export function decompress_with_dict(data, dict) {
|
|
353
|
+
const ptr0 = passArray8ToWasm0(data, wasm.__wbindgen_malloc);
|
|
354
|
+
const len0 = WASM_VECTOR_LEN;
|
|
355
|
+
const ptr1 = passArray8ToWasm0(dict, wasm.__wbindgen_malloc);
|
|
356
|
+
const len1 = WASM_VECTOR_LEN;
|
|
357
|
+
const ret = wasm.decompress_with_dict(ptr0, len0, ptr1, len1);
|
|
358
|
+
if (ret[3]) {
|
|
359
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
360
|
+
}
|
|
361
|
+
var v3 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
362
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
363
|
+
return v3;
|
|
364
|
+
}
|
|
365
|
+
|
|
366
|
+
function __wbg_get_imports() {
|
|
367
|
+
const import0 = {
|
|
368
|
+
__proto__: null,
|
|
369
|
+
__wbg___wbindgen_throw_be289d5034ed271b: function(arg0, arg1) {
|
|
370
|
+
throw new Error(getStringFromWasm0(arg0, arg1));
|
|
371
|
+
},
|
|
372
|
+
__wbindgen_cast_0000000000000001: function(arg0, arg1) {
|
|
373
|
+
// Cast intrinsic for `Ref(String) -> Externref`.
|
|
374
|
+
const ret = getStringFromWasm0(arg0, arg1);
|
|
375
|
+
return ret;
|
|
376
|
+
},
|
|
377
|
+
__wbindgen_init_externref_table: function() {
|
|
378
|
+
const table = wasm.__wbindgen_externrefs;
|
|
379
|
+
const offset = table.grow(4);
|
|
380
|
+
table.set(0, undefined);
|
|
381
|
+
table.set(offset + 0, undefined);
|
|
382
|
+
table.set(offset + 1, null);
|
|
383
|
+
table.set(offset + 2, true);
|
|
384
|
+
table.set(offset + 3, false);
|
|
385
|
+
},
|
|
386
|
+
};
|
|
387
|
+
return {
|
|
388
|
+
__proto__: null,
|
|
389
|
+
"./zstd_wasm_vn_bg.js": import0,
|
|
390
|
+
};
|
|
391
|
+
}
|
|
392
|
+
|
|
393
|
+
const ZstdFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
394
|
+
? { register: () => {}, unregister: () => {} }
|
|
395
|
+
: new FinalizationRegistry(ptr => wasm.__wbg_zstd_free(ptr >>> 0, 1));
|
|
396
|
+
const ZstdCompressorFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
397
|
+
? { register: () => {}, unregister: () => {} }
|
|
398
|
+
: new FinalizationRegistry(ptr => wasm.__wbg_zstdcompressor_free(ptr >>> 0, 1));
|
|
399
|
+
const ZstdDecompressorFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
400
|
+
? { register: () => {}, unregister: () => {} }
|
|
401
|
+
: new FinalizationRegistry(ptr => wasm.__wbg_zstddecompressor_free(ptr >>> 0, 1));
|
|
402
|
+
|
|
403
|
+
function getArrayU8FromWasm0(ptr, len) {
|
|
404
|
+
ptr = ptr >>> 0;
|
|
405
|
+
return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
|
|
406
|
+
}
|
|
407
|
+
|
|
408
|
+
function getStringFromWasm0(ptr, len) {
|
|
409
|
+
ptr = ptr >>> 0;
|
|
410
|
+
return decodeText(ptr, len);
|
|
411
|
+
}
|
|
412
|
+
|
|
413
|
+
let cachedUint8ArrayMemory0 = null;
|
|
414
|
+
function getUint8ArrayMemory0() {
|
|
415
|
+
if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
|
|
416
|
+
cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
|
|
417
|
+
}
|
|
418
|
+
return cachedUint8ArrayMemory0;
|
|
419
|
+
}
|
|
420
|
+
|
|
421
|
+
function isLikeNone(x) {
|
|
422
|
+
return x === undefined || x === null;
|
|
423
|
+
}
|
|
424
|
+
|
|
425
|
+
function passArray8ToWasm0(arg, malloc) {
|
|
426
|
+
const ptr = malloc(arg.length * 1, 1) >>> 0;
|
|
427
|
+
getUint8ArrayMemory0().set(arg, ptr / 1);
|
|
428
|
+
WASM_VECTOR_LEN = arg.length;
|
|
429
|
+
return ptr;
|
|
430
|
+
}
|
|
431
|
+
|
|
432
|
+
function takeFromExternrefTable0(idx) {
|
|
433
|
+
const value = wasm.__wbindgen_externrefs.get(idx);
|
|
434
|
+
wasm.__externref_table_dealloc(idx);
|
|
435
|
+
return value;
|
|
436
|
+
}
|
|
437
|
+
|
|
438
|
+
let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
|
|
439
|
+
cachedTextDecoder.decode();
|
|
440
|
+
const MAX_SAFARI_DECODE_BYTES = 2146435072;
|
|
441
|
+
let numBytesDecoded = 0;
|
|
442
|
+
function decodeText(ptr, len) {
|
|
443
|
+
numBytesDecoded += len;
|
|
444
|
+
if (numBytesDecoded >= MAX_SAFARI_DECODE_BYTES) {
|
|
445
|
+
cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
|
|
446
|
+
cachedTextDecoder.decode();
|
|
447
|
+
numBytesDecoded = len;
|
|
448
|
+
}
|
|
449
|
+
return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
|
|
450
|
+
}
|
|
451
|
+
|
|
452
|
+
let WASM_VECTOR_LEN = 0;
|
|
453
|
+
|
|
454
|
+
let wasmModule, wasm;
|
|
455
|
+
function __wbg_finalize_init(instance, module) {
|
|
456
|
+
wasm = instance.exports;
|
|
457
|
+
wasmModule = module;
|
|
458
|
+
cachedUint8ArrayMemory0 = null;
|
|
459
|
+
wasm.__wbindgen_start();
|
|
460
|
+
return wasm;
|
|
461
|
+
}
|
|
421
462
|
|
|
422
463
|
async function __wbg_load(module, imports) {
|
|
423
464
|
if (typeof Response === 'function' && module instanceof Response) {
|
|
424
465
|
if (typeof WebAssembly.instantiateStreaming === 'function') {
|
|
425
466
|
try {
|
|
426
467
|
return await WebAssembly.instantiateStreaming(module, imports);
|
|
427
|
-
|
|
428
468
|
} catch (e) {
|
|
429
|
-
const validResponse = module.ok &&
|
|
469
|
+
const validResponse = module.ok && expectedResponseType(module.type);
|
|
430
470
|
|
|
431
471
|
if (validResponse && module.headers.get('Content-Type') !== 'application/wasm') {
|
|
432
472
|
console.warn("`WebAssembly.instantiateStreaming` failed because your server does not serve Wasm with `application/wasm` MIME type. Falling back to `WebAssembly.instantiate` which is slower. Original error:\n", e);
|
|
433
473
|
|
|
434
|
-
} else {
|
|
435
|
-
throw e;
|
|
436
|
-
}
|
|
474
|
+
} else { throw e; }
|
|
437
475
|
}
|
|
438
476
|
}
|
|
439
477
|
|
|
440
478
|
const bytes = await module.arrayBuffer();
|
|
441
479
|
return await WebAssembly.instantiate(bytes, imports);
|
|
442
|
-
|
|
443
480
|
} else {
|
|
444
481
|
const instance = await WebAssembly.instantiate(module, imports);
|
|
445
482
|
|
|
446
483
|
if (instance instanceof WebAssembly.Instance) {
|
|
447
484
|
return { instance, module };
|
|
448
|
-
|
|
449
485
|
} else {
|
|
450
486
|
return instance;
|
|
451
487
|
}
|
|
452
488
|
}
|
|
453
|
-
}
|
|
454
|
-
|
|
455
|
-
function __wbg_get_imports() {
|
|
456
|
-
const imports = {};
|
|
457
|
-
imports.wbg = {};
|
|
458
|
-
imports.wbg.__wbg_wbindgenthrow_451ec1a8469d7eb6 = function(arg0, arg1) {
|
|
459
|
-
throw new Error(getStringFromWasm0(arg0, arg1));
|
|
460
|
-
};
|
|
461
|
-
imports.wbg.__wbindgen_cast_2241b6af4c4b2941 = function(arg0, arg1) {
|
|
462
|
-
// Cast intrinsic for `Ref(String) -> Externref`.
|
|
463
|
-
const ret = getStringFromWasm0(arg0, arg1);
|
|
464
|
-
return ret;
|
|
465
|
-
};
|
|
466
|
-
imports.wbg.__wbindgen_init_externref_table = function() {
|
|
467
|
-
const table = wasm.__wbindgen_export_0;
|
|
468
|
-
const offset = table.grow(4);
|
|
469
|
-
table.set(0, undefined);
|
|
470
|
-
table.set(offset + 0, undefined);
|
|
471
|
-
table.set(offset + 1, null);
|
|
472
|
-
table.set(offset + 2, true);
|
|
473
|
-
table.set(offset + 3, false);
|
|
474
|
-
;
|
|
475
|
-
};
|
|
476
|
-
|
|
477
|
-
return imports;
|
|
478
|
-
}
|
|
479
|
-
|
|
480
|
-
function __wbg_init_memory(imports, memory) {
|
|
481
|
-
|
|
482
|
-
}
|
|
483
489
|
|
|
484
|
-
function
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
wasm.__wbindgen_start();
|
|
491
|
-
return wasm;
|
|
490
|
+
function expectedResponseType(type) {
|
|
491
|
+
switch (type) {
|
|
492
|
+
case 'basic': case 'cors': case 'default': return true;
|
|
493
|
+
}
|
|
494
|
+
return false;
|
|
495
|
+
}
|
|
492
496
|
}
|
|
493
497
|
|
|
494
498
|
function initSync(module) {
|
|
495
499
|
if (wasm !== undefined) return wasm;
|
|
496
500
|
|
|
497
501
|
|
|
498
|
-
if (
|
|
502
|
+
if (module !== undefined) {
|
|
499
503
|
if (Object.getPrototypeOf(module) === Object.prototype) {
|
|
500
504
|
({module} = module)
|
|
501
505
|
} else {
|
|
@@ -504,15 +508,10 @@ function initSync(module) {
|
|
|
504
508
|
}
|
|
505
509
|
|
|
506
510
|
const imports = __wbg_get_imports();
|
|
507
|
-
|
|
508
|
-
__wbg_init_memory(imports);
|
|
509
|
-
|
|
510
511
|
if (!(module instanceof WebAssembly.Module)) {
|
|
511
512
|
module = new WebAssembly.Module(module);
|
|
512
513
|
}
|
|
513
|
-
|
|
514
514
|
const instance = new WebAssembly.Instance(module, imports);
|
|
515
|
-
|
|
516
515
|
return __wbg_finalize_init(instance, module);
|
|
517
516
|
}
|
|
518
517
|
|
|
@@ -520,7 +519,7 @@ async function __wbg_init(module_or_path) {
|
|
|
520
519
|
if (wasm !== undefined) return wasm;
|
|
521
520
|
|
|
522
521
|
|
|
523
|
-
if (
|
|
522
|
+
if (module_or_path !== undefined) {
|
|
524
523
|
if (Object.getPrototypeOf(module_or_path) === Object.prototype) {
|
|
525
524
|
({module_or_path} = module_or_path)
|
|
526
525
|
} else {
|
|
@@ -528,7 +527,7 @@ async function __wbg_init(module_or_path) {
|
|
|
528
527
|
}
|
|
529
528
|
}
|
|
530
529
|
|
|
531
|
-
if (
|
|
530
|
+
if (module_or_path === undefined) {
|
|
532
531
|
module_or_path = new URL('zstd_wasm_vn_bg.wasm', import.meta.url);
|
|
533
532
|
}
|
|
534
533
|
const imports = __wbg_get_imports();
|
|
@@ -537,12 +536,9 @@ async function __wbg_init(module_or_path) {
|
|
|
537
536
|
module_or_path = fetch(module_or_path);
|
|
538
537
|
}
|
|
539
538
|
|
|
540
|
-
__wbg_init_memory(imports);
|
|
541
|
-
|
|
542
539
|
const { instance, module } = await __wbg_load(await module_or_path, imports);
|
|
543
540
|
|
|
544
541
|
return __wbg_finalize_init(instance, module);
|
|
545
542
|
}
|
|
546
543
|
|
|
547
|
-
export { initSync };
|
|
548
|
-
export default __wbg_init;
|
|
544
|
+
export { initSync, __wbg_init as default };
|
package/web/zstd_wasm_vn_bg.wasm
CHANGED
|
Binary file
|