zstd-wasm-vn 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +21 -0
- package/bundler/zstd_wasm_vn.d.ts +93 -0
- package/bundler/zstd_wasm_vn.js +5 -0
- package/bundler/zstd_wasm_vn_bg.js +330 -0
- package/bundler/zstd_wasm_vn_bg.wasm +0 -0
- package/bundler/zstd_wasm_vn_bg.wasm.d.ts +34 -0
- package/deno/zstd_wasm_vn.d.ts +93 -0
- package/deno/zstd_wasm_vn.js +327 -0
- package/deno/zstd_wasm_vn_bg.wasm +0 -0
- package/deno/zstd_wasm_vn_bg.wasm.d.ts +34 -0
- package/nodejs/zstd_wasm_vn.d.ts +93 -0
- package/nodejs/zstd_wasm_vn.js +333 -0
- package/nodejs/zstd_wasm_vn_bg.wasm +0 -0
- package/nodejs/zstd_wasm_vn_bg.wasm.d.ts +34 -0
- package/package.json +58 -0
- package/web/zstd_wasm_vn.d.ts +151 -0
- package/web/zstd_wasm_vn.js +434 -0
- package/web/zstd_wasm_vn_bg.wasm +0 -0
- package/web/zstd_wasm_vn_bg.wasm.d.ts +34 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Nguyễn Đình Tạo
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
# zstd-wasm-vn
|
|
2
|
+
[](https://www.npmjs.com/package/zstd-wasm-vn)
|
|
3
|
+
|
|
4
|
+
## Installing `wasm-bindgen-cli`
|
|
5
|
+
|
|
6
|
+
```sh
|
|
7
|
+
cargo install wasm-bindgen-cli
|
|
8
|
+
cargo install wasm-opt --locked
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Building via `wasm-bindgen-cli`
|
|
12
|
+
|
|
13
|
+
```sh
|
|
14
|
+
chmod +x build.sh && ./build.sh
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
### Publish to NPM
|
|
18
|
+
|
|
19
|
+
```sh
|
|
20
|
+
cd pkg && npm publish
|
|
21
|
+
```
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
/* tslint:disable */
|
|
2
|
+
/* eslint-disable */
|
|
3
|
+
/**
|
|
4
|
+
* ZSTD compression and decompression for WebAssembly
|
|
5
|
+
*/
|
|
6
|
+
export class Zstd {
|
|
7
|
+
private constructor();
|
|
8
|
+
free(): void;
|
|
9
|
+
[Symbol.dispose](): void;
|
|
10
|
+
/**
|
|
11
|
+
* Compresses data using Zstandard compression
|
|
12
|
+
*
|
|
13
|
+
* # Arguments
|
|
14
|
+
*
|
|
15
|
+
* * `data` - Input data to compress
|
|
16
|
+
* * `level` - Compression level (1-22, default 3). Higher = better compression but slower
|
|
17
|
+
*/
|
|
18
|
+
static compress(data: Uint8Array, level?: number | null): Uint8Array;
|
|
19
|
+
/**
|
|
20
|
+
* Decompresses Zstandard compressed data
|
|
21
|
+
*
|
|
22
|
+
* # Arguments
|
|
23
|
+
*
|
|
24
|
+
* * `compressed_data` - Zstandard compressed data
|
|
25
|
+
*/
|
|
26
|
+
static decompress(compressed_data: Uint8Array): Uint8Array;
|
|
27
|
+
/**
|
|
28
|
+
* Returns the recommended default compression level
|
|
29
|
+
*/
|
|
30
|
+
static defaultCompressionLevel(): number;
|
|
31
|
+
/**
|
|
32
|
+
* Returns the minimum compression level
|
|
33
|
+
*/
|
|
34
|
+
static minCompressionLevel(): number;
|
|
35
|
+
/**
|
|
36
|
+
* Returns the maximum compression level
|
|
37
|
+
*/
|
|
38
|
+
static maxCompressionLevel(): number;
|
|
39
|
+
/**
|
|
40
|
+
* Estimates the compressed size for planning purposes
|
|
41
|
+
*/
|
|
42
|
+
static compressBound(input_size: number): number;
|
|
43
|
+
/**
|
|
44
|
+
* Calculates compression ratio (smaller = better compression)
|
|
45
|
+
*/
|
|
46
|
+
static compressionRatio(original_size: number, compressed_size: number): number;
|
|
47
|
+
/**
|
|
48
|
+
* Calculates space savings percentage
|
|
49
|
+
*/
|
|
50
|
+
static spaceSavings(original_size: number, compressed_size: number): number;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Streaming compression for large data
|
|
54
|
+
*/
|
|
55
|
+
export class ZstdCompressor {
|
|
56
|
+
free(): void;
|
|
57
|
+
[Symbol.dispose](): void;
|
|
58
|
+
/**
|
|
59
|
+
* Creates a new streaming compressor
|
|
60
|
+
*/
|
|
61
|
+
constructor(level?: number | null);
|
|
62
|
+
/**
|
|
63
|
+
* Compresses a chunk of data
|
|
64
|
+
*/
|
|
65
|
+
compress_chunk(data: Uint8Array): void;
|
|
66
|
+
/**
|
|
67
|
+
* Finalizes compression and returns the compressed data
|
|
68
|
+
*/
|
|
69
|
+
finalize(): Uint8Array;
|
|
70
|
+
/**
|
|
71
|
+
* Gets the current compression level
|
|
72
|
+
*/
|
|
73
|
+
readonly level: number;
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Streaming decompression for large data
|
|
77
|
+
*/
|
|
78
|
+
export class ZstdDecompressor {
|
|
79
|
+
free(): void;
|
|
80
|
+
[Symbol.dispose](): void;
|
|
81
|
+
/**
|
|
82
|
+
* Creates a new streaming decompressor
|
|
83
|
+
*/
|
|
84
|
+
constructor(compressed_data: Uint8Array);
|
|
85
|
+
/**
|
|
86
|
+
* Decompresses a chunk of data
|
|
87
|
+
*/
|
|
88
|
+
decompress_chunk(max_output_size: number): Uint8Array;
|
|
89
|
+
/**
|
|
90
|
+
* Decompresses all remaining data
|
|
91
|
+
*/
|
|
92
|
+
finalize(): Uint8Array;
|
|
93
|
+
}
|
|
@@ -0,0 +1,330 @@
|
|
|
1
|
+
let wasm;
|
|
2
|
+
export function __wbg_set_wasm(val) {
|
|
3
|
+
wasm = val;
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
let cachedUint8ArrayMemory0 = null;
|
|
8
|
+
|
|
9
|
+
function getUint8ArrayMemory0() {
|
|
10
|
+
if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
|
|
11
|
+
cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
|
|
12
|
+
}
|
|
13
|
+
return cachedUint8ArrayMemory0;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
|
|
17
|
+
|
|
18
|
+
cachedTextDecoder.decode();
|
|
19
|
+
|
|
20
|
+
const MAX_SAFARI_DECODE_BYTES = 2146435072;
|
|
21
|
+
let numBytesDecoded = 0;
|
|
22
|
+
function decodeText(ptr, len) {
|
|
23
|
+
numBytesDecoded += len;
|
|
24
|
+
if (numBytesDecoded >= MAX_SAFARI_DECODE_BYTES) {
|
|
25
|
+
cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
|
|
26
|
+
cachedTextDecoder.decode();
|
|
27
|
+
numBytesDecoded = len;
|
|
28
|
+
}
|
|
29
|
+
return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
function getStringFromWasm0(ptr, len) {
|
|
33
|
+
ptr = ptr >>> 0;
|
|
34
|
+
return decodeText(ptr, len);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
let WASM_VECTOR_LEN = 0;
|
|
38
|
+
|
|
39
|
+
function passArray8ToWasm0(arg, malloc) {
|
|
40
|
+
const ptr = malloc(arg.length * 1, 1) >>> 0;
|
|
41
|
+
getUint8ArrayMemory0().set(arg, ptr / 1);
|
|
42
|
+
WASM_VECTOR_LEN = arg.length;
|
|
43
|
+
return ptr;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
function isLikeNone(x) {
|
|
47
|
+
return x === undefined || x === null;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
function takeFromExternrefTable0(idx) {
|
|
51
|
+
const value = wasm.__wbindgen_export_0.get(idx);
|
|
52
|
+
wasm.__externref_table_dealloc(idx);
|
|
53
|
+
return value;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
function getArrayU8FromWasm0(ptr, len) {
|
|
57
|
+
ptr = ptr >>> 0;
|
|
58
|
+
return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
const ZstdFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
62
|
+
? { register: () => {}, unregister: () => {} }
|
|
63
|
+
: new FinalizationRegistry(ptr => wasm.__wbg_zstd_free(ptr >>> 0, 1));
|
|
64
|
+
/**
|
|
65
|
+
* ZSTD compression and decompression for WebAssembly
|
|
66
|
+
*/
|
|
67
|
+
export class Zstd {
|
|
68
|
+
|
|
69
|
+
__destroy_into_raw() {
|
|
70
|
+
const ptr = this.__wbg_ptr;
|
|
71
|
+
this.__wbg_ptr = 0;
|
|
72
|
+
ZstdFinalization.unregister(this);
|
|
73
|
+
return ptr;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
free() {
|
|
77
|
+
const ptr = this.__destroy_into_raw();
|
|
78
|
+
wasm.__wbg_zstd_free(ptr, 0);
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Compresses data using Zstandard compression
|
|
82
|
+
*
|
|
83
|
+
* # Arguments
|
|
84
|
+
*
|
|
85
|
+
* * `data` - Input data to compress
|
|
86
|
+
* * `level` - Compression level (1-22, default 3). Higher = better compression but slower
|
|
87
|
+
* @param {Uint8Array} data
|
|
88
|
+
* @param {number | null} [level]
|
|
89
|
+
* @returns {Uint8Array}
|
|
90
|
+
*/
|
|
91
|
+
static compress(data, level) {
|
|
92
|
+
const ptr0 = passArray8ToWasm0(data, wasm.__wbindgen_malloc);
|
|
93
|
+
const len0 = WASM_VECTOR_LEN;
|
|
94
|
+
const ret = wasm.zstd_compress(ptr0, len0, isLikeNone(level) ? 0x100000001 : (level) >> 0);
|
|
95
|
+
if (ret[3]) {
|
|
96
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
97
|
+
}
|
|
98
|
+
var v2 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
99
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
100
|
+
return v2;
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* Decompresses Zstandard compressed data
|
|
104
|
+
*
|
|
105
|
+
* # Arguments
|
|
106
|
+
*
|
|
107
|
+
* * `compressed_data` - Zstandard compressed data
|
|
108
|
+
* @param {Uint8Array} compressed_data
|
|
109
|
+
* @returns {Uint8Array}
|
|
110
|
+
*/
|
|
111
|
+
static decompress(compressed_data) {
|
|
112
|
+
const ptr0 = passArray8ToWasm0(compressed_data, wasm.__wbindgen_malloc);
|
|
113
|
+
const len0 = WASM_VECTOR_LEN;
|
|
114
|
+
const ret = wasm.zstd_decompress(ptr0, len0);
|
|
115
|
+
if (ret[3]) {
|
|
116
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
117
|
+
}
|
|
118
|
+
var v2 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
119
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
120
|
+
return v2;
|
|
121
|
+
}
|
|
122
|
+
/**
|
|
123
|
+
* Returns the recommended default compression level
|
|
124
|
+
* @returns {number}
|
|
125
|
+
*/
|
|
126
|
+
static defaultCompressionLevel() {
|
|
127
|
+
const ret = wasm.zstd_defaultCompressionLevel();
|
|
128
|
+
return ret;
|
|
129
|
+
}
|
|
130
|
+
/**
|
|
131
|
+
* Returns the minimum compression level
|
|
132
|
+
* @returns {number}
|
|
133
|
+
*/
|
|
134
|
+
static minCompressionLevel() {
|
|
135
|
+
const ret = wasm.zstd_minCompressionLevel();
|
|
136
|
+
return ret;
|
|
137
|
+
}
|
|
138
|
+
/**
|
|
139
|
+
* Returns the maximum compression level
|
|
140
|
+
* @returns {number}
|
|
141
|
+
*/
|
|
142
|
+
static maxCompressionLevel() {
|
|
143
|
+
const ret = wasm.zstd_maxCompressionLevel();
|
|
144
|
+
return ret;
|
|
145
|
+
}
|
|
146
|
+
/**
|
|
147
|
+
* Estimates the compressed size for planning purposes
|
|
148
|
+
* @param {number} input_size
|
|
149
|
+
* @returns {number}
|
|
150
|
+
*/
|
|
151
|
+
static compressBound(input_size) {
|
|
152
|
+
const ret = wasm.zstd_compressBound(input_size);
|
|
153
|
+
return ret >>> 0;
|
|
154
|
+
}
|
|
155
|
+
/**
|
|
156
|
+
* Calculates compression ratio (smaller = better compression)
|
|
157
|
+
* @param {number} original_size
|
|
158
|
+
* @param {number} compressed_size
|
|
159
|
+
* @returns {number}
|
|
160
|
+
*/
|
|
161
|
+
static compressionRatio(original_size, compressed_size) {
|
|
162
|
+
const ret = wasm.zstd_compressionRatio(original_size, compressed_size);
|
|
163
|
+
return ret;
|
|
164
|
+
}
|
|
165
|
+
/**
|
|
166
|
+
* Calculates space savings percentage
|
|
167
|
+
* @param {number} original_size
|
|
168
|
+
* @param {number} compressed_size
|
|
169
|
+
* @returns {number}
|
|
170
|
+
*/
|
|
171
|
+
static spaceSavings(original_size, compressed_size) {
|
|
172
|
+
const ret = wasm.zstd_spaceSavings(original_size, compressed_size);
|
|
173
|
+
return ret;
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
if (Symbol.dispose) Zstd.prototype[Symbol.dispose] = Zstd.prototype.free;
|
|
177
|
+
|
|
178
|
+
const ZstdCompressorFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
179
|
+
? { register: () => {}, unregister: () => {} }
|
|
180
|
+
: new FinalizationRegistry(ptr => wasm.__wbg_zstdcompressor_free(ptr >>> 0, 1));
|
|
181
|
+
/**
|
|
182
|
+
* Streaming compression for large data
|
|
183
|
+
*/
|
|
184
|
+
export class ZstdCompressor {
|
|
185
|
+
|
|
186
|
+
__destroy_into_raw() {
|
|
187
|
+
const ptr = this.__wbg_ptr;
|
|
188
|
+
this.__wbg_ptr = 0;
|
|
189
|
+
ZstdCompressorFinalization.unregister(this);
|
|
190
|
+
return ptr;
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
free() {
|
|
194
|
+
const ptr = this.__destroy_into_raw();
|
|
195
|
+
wasm.__wbg_zstdcompressor_free(ptr, 0);
|
|
196
|
+
}
|
|
197
|
+
/**
|
|
198
|
+
* Creates a new streaming compressor
|
|
199
|
+
* @param {number | null} [level]
|
|
200
|
+
*/
|
|
201
|
+
constructor(level) {
|
|
202
|
+
const ret = wasm.zstdcompressor_new(isLikeNone(level) ? 0x100000001 : (level) >> 0);
|
|
203
|
+
if (ret[2]) {
|
|
204
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
205
|
+
}
|
|
206
|
+
this.__wbg_ptr = ret[0] >>> 0;
|
|
207
|
+
ZstdCompressorFinalization.register(this, this.__wbg_ptr, this);
|
|
208
|
+
return this;
|
|
209
|
+
}
|
|
210
|
+
/**
|
|
211
|
+
* Compresses a chunk of data
|
|
212
|
+
* @param {Uint8Array} data
|
|
213
|
+
*/
|
|
214
|
+
compress_chunk(data) {
|
|
215
|
+
const ptr0 = passArray8ToWasm0(data, wasm.__wbindgen_malloc);
|
|
216
|
+
const len0 = WASM_VECTOR_LEN;
|
|
217
|
+
const ret = wasm.zstdcompressor_compress_chunk(this.__wbg_ptr, ptr0, len0);
|
|
218
|
+
if (ret[1]) {
|
|
219
|
+
throw takeFromExternrefTable0(ret[0]);
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
/**
|
|
223
|
+
* Finalizes compression and returns the compressed data
|
|
224
|
+
* @returns {Uint8Array}
|
|
225
|
+
*/
|
|
226
|
+
finalize() {
|
|
227
|
+
const ret = wasm.zstdcompressor_finalize(this.__wbg_ptr);
|
|
228
|
+
if (ret[3]) {
|
|
229
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
230
|
+
}
|
|
231
|
+
var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
232
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
233
|
+
return v1;
|
|
234
|
+
}
|
|
235
|
+
/**
|
|
236
|
+
* Gets the current compression level
|
|
237
|
+
* @returns {number}
|
|
238
|
+
*/
|
|
239
|
+
get level() {
|
|
240
|
+
const ret = wasm.zstdcompressor_level(this.__wbg_ptr);
|
|
241
|
+
return ret;
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
if (Symbol.dispose) ZstdCompressor.prototype[Symbol.dispose] = ZstdCompressor.prototype.free;
|
|
245
|
+
|
|
246
|
+
const ZstdDecompressorFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
247
|
+
? { register: () => {}, unregister: () => {} }
|
|
248
|
+
: new FinalizationRegistry(ptr => wasm.__wbg_zstddecompressor_free(ptr >>> 0, 1));
|
|
249
|
+
/**
|
|
250
|
+
* Streaming decompression for large data
|
|
251
|
+
*/
|
|
252
|
+
export class ZstdDecompressor {
|
|
253
|
+
|
|
254
|
+
__destroy_into_raw() {
|
|
255
|
+
const ptr = this.__wbg_ptr;
|
|
256
|
+
this.__wbg_ptr = 0;
|
|
257
|
+
ZstdDecompressorFinalization.unregister(this);
|
|
258
|
+
return ptr;
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
free() {
|
|
262
|
+
const ptr = this.__destroy_into_raw();
|
|
263
|
+
wasm.__wbg_zstddecompressor_free(ptr, 0);
|
|
264
|
+
}
|
|
265
|
+
/**
|
|
266
|
+
* Creates a new streaming decompressor
|
|
267
|
+
* @param {Uint8Array} compressed_data
|
|
268
|
+
*/
|
|
269
|
+
constructor(compressed_data) {
|
|
270
|
+
const ptr0 = passArray8ToWasm0(compressed_data, wasm.__wbindgen_malloc);
|
|
271
|
+
const len0 = WASM_VECTOR_LEN;
|
|
272
|
+
const ret = wasm.zstddecompressor_new(ptr0, len0);
|
|
273
|
+
if (ret[2]) {
|
|
274
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
275
|
+
}
|
|
276
|
+
this.__wbg_ptr = ret[0] >>> 0;
|
|
277
|
+
ZstdDecompressorFinalization.register(this, this.__wbg_ptr, this);
|
|
278
|
+
return this;
|
|
279
|
+
}
|
|
280
|
+
/**
|
|
281
|
+
* Decompresses a chunk of data
|
|
282
|
+
* @param {number} max_output_size
|
|
283
|
+
* @returns {Uint8Array}
|
|
284
|
+
*/
|
|
285
|
+
decompress_chunk(max_output_size) {
|
|
286
|
+
const ret = wasm.zstddecompressor_decompress_chunk(this.__wbg_ptr, max_output_size);
|
|
287
|
+
if (ret[3]) {
|
|
288
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
289
|
+
}
|
|
290
|
+
var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
291
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
292
|
+
return v1;
|
|
293
|
+
}
|
|
294
|
+
/**
|
|
295
|
+
* Decompresses all remaining data
|
|
296
|
+
* @returns {Uint8Array}
|
|
297
|
+
*/
|
|
298
|
+
finalize() {
|
|
299
|
+
const ret = wasm.zstddecompressor_finalize(this.__wbg_ptr);
|
|
300
|
+
if (ret[3]) {
|
|
301
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
302
|
+
}
|
|
303
|
+
var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
304
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
305
|
+
return v1;
|
|
306
|
+
}
|
|
307
|
+
}
|
|
308
|
+
if (Symbol.dispose) ZstdDecompressor.prototype[Symbol.dispose] = ZstdDecompressor.prototype.free;
|
|
309
|
+
|
|
310
|
+
export function __wbg_wbindgenthrow_451ec1a8469d7eb6(arg0, arg1) {
|
|
311
|
+
throw new Error(getStringFromWasm0(arg0, arg1));
|
|
312
|
+
};
|
|
313
|
+
|
|
314
|
+
export function __wbindgen_cast_2241b6af4c4b2941(arg0, arg1) {
|
|
315
|
+
// Cast intrinsic for `Ref(String) -> Externref`.
|
|
316
|
+
const ret = getStringFromWasm0(arg0, arg1);
|
|
317
|
+
return ret;
|
|
318
|
+
};
|
|
319
|
+
|
|
320
|
+
export function __wbindgen_init_externref_table() {
|
|
321
|
+
const table = wasm.__wbindgen_export_0;
|
|
322
|
+
const offset = table.grow(4);
|
|
323
|
+
table.set(0, undefined);
|
|
324
|
+
table.set(offset + 0, undefined);
|
|
325
|
+
table.set(offset + 1, null);
|
|
326
|
+
table.set(offset + 2, true);
|
|
327
|
+
table.set(offset + 3, false);
|
|
328
|
+
;
|
|
329
|
+
};
|
|
330
|
+
|
|
Binary file
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/* tslint:disable */
|
|
2
|
+
/* eslint-disable */
|
|
3
|
+
export const memory: WebAssembly.Memory;
|
|
4
|
+
export const __wbg_zstd_free: (a: number, b: number) => void;
|
|
5
|
+
export const zstd_compress: (a: number, b: number, c: number) => [number, number, number, number];
|
|
6
|
+
export const zstd_decompress: (a: number, b: number) => [number, number, number, number];
|
|
7
|
+
export const zstd_defaultCompressionLevel: () => number;
|
|
8
|
+
export const zstd_minCompressionLevel: () => number;
|
|
9
|
+
export const zstd_maxCompressionLevel: () => number;
|
|
10
|
+
export const zstd_compressBound: (a: number) => number;
|
|
11
|
+
export const zstd_compressionRatio: (a: number, b: number) => number;
|
|
12
|
+
export const zstd_spaceSavings: (a: number, b: number) => number;
|
|
13
|
+
export const __wbg_zstdcompressor_free: (a: number, b: number) => void;
|
|
14
|
+
export const zstdcompressor_new: (a: number) => [number, number, number];
|
|
15
|
+
export const zstdcompressor_compress_chunk: (a: number, b: number, c: number) => [number, number];
|
|
16
|
+
export const zstdcompressor_finalize: (a: number) => [number, number, number, number];
|
|
17
|
+
export const zstdcompressor_level: (a: number) => number;
|
|
18
|
+
export const __wbg_zstddecompressor_free: (a: number, b: number) => void;
|
|
19
|
+
export const zstddecompressor_new: (a: number, b: number) => [number, number, number];
|
|
20
|
+
export const zstddecompressor_decompress_chunk: (a: number, b: number) => [number, number, number, number];
|
|
21
|
+
export const zstddecompressor_finalize: (a: number) => [number, number, number, number];
|
|
22
|
+
export const rust_zstd_wasm_shim_qsort: (a: number, b: number, c: number, d: number) => void;
|
|
23
|
+
export const rust_zstd_wasm_shim_malloc: (a: number) => number;
|
|
24
|
+
export const rust_zstd_wasm_shim_memcmp: (a: number, b: number, c: number) => number;
|
|
25
|
+
export const rust_zstd_wasm_shim_calloc: (a: number, b: number) => number;
|
|
26
|
+
export const rust_zstd_wasm_shim_free: (a: number) => void;
|
|
27
|
+
export const rust_zstd_wasm_shim_memcpy: (a: number, b: number, c: number) => number;
|
|
28
|
+
export const rust_zstd_wasm_shim_memmove: (a: number, b: number, c: number) => number;
|
|
29
|
+
export const rust_zstd_wasm_shim_memset: (a: number, b: number, c: number) => number;
|
|
30
|
+
export const __wbindgen_export_0: WebAssembly.Table;
|
|
31
|
+
export const __wbindgen_malloc: (a: number, b: number) => number;
|
|
32
|
+
export const __externref_table_dealloc: (a: number) => void;
|
|
33
|
+
export const __wbindgen_free: (a: number, b: number, c: number) => void;
|
|
34
|
+
export const __wbindgen_start: () => void;
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
/* tslint:disable */
|
|
2
|
+
/* eslint-disable */
|
|
3
|
+
/**
|
|
4
|
+
* ZSTD compression and decompression for WebAssembly
|
|
5
|
+
*/
|
|
6
|
+
export class Zstd {
|
|
7
|
+
private constructor();
|
|
8
|
+
free(): void;
|
|
9
|
+
[Symbol.dispose](): void;
|
|
10
|
+
/**
|
|
11
|
+
* Compresses data using Zstandard compression
|
|
12
|
+
*
|
|
13
|
+
* # Arguments
|
|
14
|
+
*
|
|
15
|
+
* * `data` - Input data to compress
|
|
16
|
+
* * `level` - Compression level (1-22, default 3). Higher = better compression but slower
|
|
17
|
+
*/
|
|
18
|
+
static compress(data: Uint8Array, level?: number | null): Uint8Array;
|
|
19
|
+
/**
|
|
20
|
+
* Decompresses Zstandard compressed data
|
|
21
|
+
*
|
|
22
|
+
* # Arguments
|
|
23
|
+
*
|
|
24
|
+
* * `compressed_data` - Zstandard compressed data
|
|
25
|
+
*/
|
|
26
|
+
static decompress(compressed_data: Uint8Array): Uint8Array;
|
|
27
|
+
/**
|
|
28
|
+
* Returns the recommended default compression level
|
|
29
|
+
*/
|
|
30
|
+
static defaultCompressionLevel(): number;
|
|
31
|
+
/**
|
|
32
|
+
* Returns the minimum compression level
|
|
33
|
+
*/
|
|
34
|
+
static minCompressionLevel(): number;
|
|
35
|
+
/**
|
|
36
|
+
* Returns the maximum compression level
|
|
37
|
+
*/
|
|
38
|
+
static maxCompressionLevel(): number;
|
|
39
|
+
/**
|
|
40
|
+
* Estimates the compressed size for planning purposes
|
|
41
|
+
*/
|
|
42
|
+
static compressBound(input_size: number): number;
|
|
43
|
+
/**
|
|
44
|
+
* Calculates compression ratio (smaller = better compression)
|
|
45
|
+
*/
|
|
46
|
+
static compressionRatio(original_size: number, compressed_size: number): number;
|
|
47
|
+
/**
|
|
48
|
+
* Calculates space savings percentage
|
|
49
|
+
*/
|
|
50
|
+
static spaceSavings(original_size: number, compressed_size: number): number;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Streaming compression for large data
|
|
54
|
+
*/
|
|
55
|
+
export class ZstdCompressor {
|
|
56
|
+
free(): void;
|
|
57
|
+
[Symbol.dispose](): void;
|
|
58
|
+
/**
|
|
59
|
+
* Creates a new streaming compressor
|
|
60
|
+
*/
|
|
61
|
+
constructor(level?: number | null);
|
|
62
|
+
/**
|
|
63
|
+
* Compresses a chunk of data
|
|
64
|
+
*/
|
|
65
|
+
compress_chunk(data: Uint8Array): void;
|
|
66
|
+
/**
|
|
67
|
+
* Finalizes compression and returns the compressed data
|
|
68
|
+
*/
|
|
69
|
+
finalize(): Uint8Array;
|
|
70
|
+
/**
|
|
71
|
+
* Gets the current compression level
|
|
72
|
+
*/
|
|
73
|
+
readonly level: number;
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Streaming decompression for large data
|
|
77
|
+
*/
|
|
78
|
+
export class ZstdDecompressor {
|
|
79
|
+
free(): void;
|
|
80
|
+
[Symbol.dispose](): void;
|
|
81
|
+
/**
|
|
82
|
+
* Creates a new streaming decompressor
|
|
83
|
+
*/
|
|
84
|
+
constructor(compressed_data: Uint8Array);
|
|
85
|
+
/**
|
|
86
|
+
* Decompresses a chunk of data
|
|
87
|
+
*/
|
|
88
|
+
decompress_chunk(max_output_size: number): Uint8Array;
|
|
89
|
+
/**
|
|
90
|
+
* Decompresses all remaining data
|
|
91
|
+
*/
|
|
92
|
+
finalize(): Uint8Array;
|
|
93
|
+
}
|