@structured-world/structured-zstd 0.0.30

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/package.json ADDED
@@ -0,0 +1,74 @@
1
+ {
2
+ "name": "@structured-world/structured-zstd",
3
+ "version": "0.0.30",
4
+ "description": "Pure-Rust Zstandard (zstd) codec compiled to WebAssembly — compress and decompress in the browser, Node.js and Deno, with automatic SIMD (simd128) acceleration and a scalar fallback. No native addons, no FFI.",
5
+ "type": "module",
6
+ "exports": {
7
+ ".": {
8
+ "types": "./index.d.ts",
9
+ "import": "./index.js"
10
+ }
11
+ },
12
+ "types": "./index.d.ts",
13
+ "files": [
14
+ "index.js",
15
+ "index.js.map",
16
+ "index.d.ts",
17
+ "index.d.ts.map",
18
+ "index.ts",
19
+ "simd/structured_zstd_wasm.js",
20
+ "simd/structured_zstd_wasm.d.ts",
21
+ "simd/structured_zstd_wasm_bg.wasm",
22
+ "simd/structured_zstd_wasm_bg.wasm.d.ts",
23
+ "scalar/structured_zstd_wasm.js",
24
+ "scalar/structured_zstd_wasm.d.ts",
25
+ "scalar/structured_zstd_wasm_bg.wasm",
26
+ "scalar/structured_zstd_wasm_bg.wasm.d.ts",
27
+ "README.md",
28
+ "LICENSE"
29
+ ],
30
+ "sideEffects": false,
31
+ "engines": {
32
+ "node": ">=18"
33
+ },
34
+ "keywords": [
35
+ "zstd",
36
+ "zstandard",
37
+ "compression",
38
+ "decompression",
39
+ "wasm",
40
+ "webassembly",
41
+ "simd",
42
+ "simd128",
43
+ "browser",
44
+ "nodejs",
45
+ "deno",
46
+ "codec",
47
+ "pure-rust"
48
+ ],
49
+ "license": "Apache-2.0",
50
+ "author": "Structured World Foundation <foundation@sw.foundation>",
51
+ "homepage": "https://github.com/structured-world/structured-zstd#readme",
52
+ "repository": {
53
+ "type": "git",
54
+ "url": "git+https://github.com/structured-world/structured-zstd.git",
55
+ "directory": "zstd-wasm/npm"
56
+ },
57
+ "bugs": {
58
+ "url": "https://github.com/structured-world/structured-zstd/issues"
59
+ },
60
+ "dependencies": {
61
+ "wasm-feature-detect": "^1.8.0"
62
+ },
63
+ "devDependencies": {
64
+ "@types/node": "^22.10.0",
65
+ "typescript": "^5.7.0"
66
+ },
67
+ "scripts": {
68
+ "build:wasm:simd": "cd .. && wasm-pack build --release --target web --out-dir npm/simd --out-name structured_zstd_wasm -- --config 'target.wasm32-unknown-unknown.rustflags=[\"-C\",\"target-feature=+simd128\"]'",
69
+ "build:wasm:scalar": "cd .. && wasm-pack build --release --target web --out-dir npm/scalar --out-name structured_zstd_wasm",
70
+ "build:ts": "tsc",
71
+ "build": "npm run build:wasm:simd && npm run build:wasm:scalar && npm run build:ts",
72
+ "prepublishOnly": "npm run build && cp ../../LICENSE LICENSE"
73
+ }
74
+ }
@@ -0,0 +1,100 @@
1
+ /* tslint:disable */
2
+ /* eslint-disable */
3
+
4
+ /**
5
+ * Incremental streaming decompressor: feed compressed chunks via
6
+ * [`ZstdDecompressStream::push`] and receive decompressed bytes as they
7
+ * become available, then [`ZstdDecompressStream::finish`]. The decoder window
8
+ * is retained across chunks, so a large frame never needs to be fully
9
+ * buffered — a surface the common npm wasm zstd packages do not offer.
10
+ */
11
+ export class ZstdDecompressStream {
12
+ free(): void;
13
+ [Symbol.dispose](): void;
14
+ /**
15
+ * Signal end of input; returns the final decompressed bytes. Throws if the
16
+ * stream ended before the frame completed.
17
+ */
18
+ finish(): Uint8Array;
19
+ constructor();
20
+ /**
21
+ * Feed more compressed bytes; returns whatever decompressed output is now
22
+ * available (possibly empty while a block is still incomplete).
23
+ */
24
+ push(chunk: Uint8Array): Uint8Array;
25
+ }
26
+
27
+ /**
28
+ * Compress `data` into a standard Zstandard frame at compression `level`.
29
+ *
30
+ * `level` follows the zstd scale: `1..=22` (higher = smaller/slower) and
31
+ * negative levels (`-7..=-1`) for the ultra-fast tier. The returned frame
32
+ * decodes in any compliant zstd decoder, including the native C library.
33
+ */
34
+ export function compress(data: Uint8Array, level: number): Uint8Array;
35
+
36
+ /**
37
+ * Compress `data` against a raw Zstandard dictionary at compression `level`.
38
+ *
39
+ * Mirrors C `ZSTD_compress_usingDict`: the dictionary primes the encoder so
40
+ * small, similar payloads compress far better. The dictionary is the raw
41
+ * zstd dictionary blob (e.g. from `zstd --train`). Throws if it is invalid.
42
+ */
43
+ export function compressUsingDict(data: Uint8Array, dict: Uint8Array, level: number): Uint8Array;
44
+
45
+ /**
46
+ * Decompress a complete Zstandard frame back into its original bytes.
47
+ *
48
+ * Throws a JavaScript `Error` if the input is not a valid, complete frame.
49
+ */
50
+ export function decompress(data: Uint8Array): Uint8Array;
51
+
52
+ /**
53
+ * Decompress a dictionary-encoded Zstandard frame.
54
+ *
55
+ * Mirrors C `ZSTD_decompress_usingDict`: `dict` must be the same raw
56
+ * dictionary the frame was compressed with. Throws on a malformed frame or a
57
+ * dictionary mismatch.
58
+ */
59
+ export function decompressUsingDict(data: Uint8Array, dict: Uint8Array): Uint8Array;
60
+
61
+ export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembly.Module;
62
+
63
+ export interface InitOutput {
64
+ readonly memory: WebAssembly.Memory;
65
+ readonly __wbg_zstddecompressstream_free: (a: number, b: number) => void;
66
+ readonly compress: (a: number, b: number, c: number) => [number, number];
67
+ readonly compressUsingDict: (a: number, b: number, c: number, d: number, e: number) => [number, number, number, number];
68
+ readonly decompress: (a: number, b: number) => [number, number, number, number];
69
+ readonly decompressUsingDict: (a: number, b: number, c: number, d: number) => [number, number, number, number];
70
+ readonly zstddecompressstream_finish: (a: number) => [number, number, number, number];
71
+ readonly zstddecompressstream_new: () => number;
72
+ readonly zstddecompressstream_push: (a: number, b: number, c: number) => [number, number, number, number];
73
+ readonly __wbindgen_externrefs: WebAssembly.Table;
74
+ readonly __wbindgen_malloc: (a: number, b: number) => number;
75
+ readonly __wbindgen_free: (a: number, b: number, c: number) => void;
76
+ readonly __externref_table_dealloc: (a: number) => void;
77
+ readonly __wbindgen_start: () => void;
78
+ }
79
+
80
+ export type SyncInitInput = BufferSource | WebAssembly.Module;
81
+
82
+ /**
83
+ * Instantiates the given `module`, which can either be bytes or
84
+ * a precompiled `WebAssembly.Module`.
85
+ *
86
+ * @param {{ module: SyncInitInput }} module - Passing `SyncInitInput` directly is deprecated.
87
+ *
88
+ * @returns {InitOutput}
89
+ */
90
+ export function initSync(module: { module: SyncInitInput } | SyncInitInput): InitOutput;
91
+
92
+ /**
93
+ * If `module_or_path` is {RequestInfo} or {URL}, makes a request and
94
+ * for everything else, calls `WebAssembly.instantiate` directly.
95
+ *
96
+ * @param {{ module_or_path: InitInput | Promise<InitInput> }} module_or_path - Passing `InitInput` directly is deprecated.
97
+ *
98
+ * @returns {Promise<InitOutput>}
99
+ */
100
+ export default function __wbg_init (module_or_path?: { module_or_path: InitInput | Promise<InitInput> } | InitInput | Promise<InitInput>): Promise<InitOutput>;
@@ -0,0 +1,315 @@
1
+ /* @ts-self-types="./structured_zstd_wasm.d.ts" */
2
+
3
+ /**
4
+ * Incremental streaming decompressor: feed compressed chunks via
5
+ * [`ZstdDecompressStream::push`] and receive decompressed bytes as they
6
+ * become available, then [`ZstdDecompressStream::finish`]. The decoder window
7
+ * is retained across chunks, so a large frame never needs to be fully
8
+ * buffered — a surface the common npm wasm zstd packages do not offer.
9
+ */
10
+ export class ZstdDecompressStream {
11
+ __destroy_into_raw() {
12
+ const ptr = this.__wbg_ptr;
13
+ this.__wbg_ptr = 0;
14
+ ZstdDecompressStreamFinalization.unregister(this);
15
+ return ptr;
16
+ }
17
+ free() {
18
+ const ptr = this.__destroy_into_raw();
19
+ wasm.__wbg_zstddecompressstream_free(ptr, 0);
20
+ }
21
+ /**
22
+ * Signal end of input; returns the final decompressed bytes. Throws if the
23
+ * stream ended before the frame completed.
24
+ * @returns {Uint8Array}
25
+ */
26
+ finish() {
27
+ const ret = wasm.zstddecompressstream_finish(this.__wbg_ptr);
28
+ if (ret[3]) {
29
+ throw takeFromExternrefTable0(ret[2]);
30
+ }
31
+ var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
32
+ wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
33
+ return v1;
34
+ }
35
+ constructor() {
36
+ const ret = wasm.zstddecompressstream_new();
37
+ this.__wbg_ptr = ret >>> 0;
38
+ ZstdDecompressStreamFinalization.register(this, this.__wbg_ptr, this);
39
+ return this;
40
+ }
41
+ /**
42
+ * Feed more compressed bytes; returns whatever decompressed output is now
43
+ * available (possibly empty while a block is still incomplete).
44
+ * @param {Uint8Array} chunk
45
+ * @returns {Uint8Array}
46
+ */
47
+ push(chunk) {
48
+ const ptr0 = passArray8ToWasm0(chunk, wasm.__wbindgen_malloc);
49
+ const len0 = WASM_VECTOR_LEN;
50
+ const ret = wasm.zstddecompressstream_push(this.__wbg_ptr, ptr0, len0);
51
+ if (ret[3]) {
52
+ throw takeFromExternrefTable0(ret[2]);
53
+ }
54
+ var v2 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
55
+ wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
56
+ return v2;
57
+ }
58
+ }
59
+ if (Symbol.dispose) ZstdDecompressStream.prototype[Symbol.dispose] = ZstdDecompressStream.prototype.free;
60
+
61
+ /**
62
+ * Compress `data` into a standard Zstandard frame at compression `level`.
63
+ *
64
+ * `level` follows the zstd scale: `1..=22` (higher = smaller/slower) and
65
+ * negative levels (`-7..=-1`) for the ultra-fast tier. The returned frame
66
+ * decodes in any compliant zstd decoder, including the native C library.
67
+ * @param {Uint8Array} data
68
+ * @param {number} level
69
+ * @returns {Uint8Array}
70
+ */
71
+ export function compress(data, level) {
72
+ const ptr0 = passArray8ToWasm0(data, wasm.__wbindgen_malloc);
73
+ const len0 = WASM_VECTOR_LEN;
74
+ const ret = wasm.compress(ptr0, len0, level);
75
+ var v2 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
76
+ wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
77
+ return v2;
78
+ }
79
+
80
+ /**
81
+ * Compress `data` against a raw Zstandard dictionary at compression `level`.
82
+ *
83
+ * Mirrors C `ZSTD_compress_usingDict`: the dictionary primes the encoder so
84
+ * small, similar payloads compress far better. The dictionary is the raw
85
+ * zstd dictionary blob (e.g. from `zstd --train`). Throws if it is invalid.
86
+ * @param {Uint8Array} data
87
+ * @param {Uint8Array} dict
88
+ * @param {number} level
89
+ * @returns {Uint8Array}
90
+ */
91
+ export function compressUsingDict(data, dict, level) {
92
+ const ptr0 = passArray8ToWasm0(data, wasm.__wbindgen_malloc);
93
+ const len0 = WASM_VECTOR_LEN;
94
+ const ptr1 = passArray8ToWasm0(dict, wasm.__wbindgen_malloc);
95
+ const len1 = WASM_VECTOR_LEN;
96
+ const ret = wasm.compressUsingDict(ptr0, len0, ptr1, len1, level);
97
+ if (ret[3]) {
98
+ throw takeFromExternrefTable0(ret[2]);
99
+ }
100
+ var v3 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
101
+ wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
102
+ return v3;
103
+ }
104
+
105
+ /**
106
+ * Decompress a complete Zstandard frame back into its original bytes.
107
+ *
108
+ * Throws a JavaScript `Error` if the input is not a valid, complete frame.
109
+ * @param {Uint8Array} data
110
+ * @returns {Uint8Array}
111
+ */
112
+ export function decompress(data) {
113
+ const ptr0 = passArray8ToWasm0(data, wasm.__wbindgen_malloc);
114
+ const len0 = WASM_VECTOR_LEN;
115
+ const ret = wasm.decompress(ptr0, len0);
116
+ if (ret[3]) {
117
+ throw takeFromExternrefTable0(ret[2]);
118
+ }
119
+ var v2 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
120
+ wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
121
+ return v2;
122
+ }
123
+
124
+ /**
125
+ * Decompress a dictionary-encoded Zstandard frame.
126
+ *
127
+ * Mirrors C `ZSTD_decompress_usingDict`: `dict` must be the same raw
128
+ * dictionary the frame was compressed with. Throws on a malformed frame or a
129
+ * dictionary mismatch.
130
+ * @param {Uint8Array} data
131
+ * @param {Uint8Array} dict
132
+ * @returns {Uint8Array}
133
+ */
134
+ export function decompressUsingDict(data, dict) {
135
+ const ptr0 = passArray8ToWasm0(data, wasm.__wbindgen_malloc);
136
+ const len0 = WASM_VECTOR_LEN;
137
+ const ptr1 = passArray8ToWasm0(dict, wasm.__wbindgen_malloc);
138
+ const len1 = WASM_VECTOR_LEN;
139
+ const ret = wasm.decompressUsingDict(ptr0, len0, ptr1, len1);
140
+ if (ret[3]) {
141
+ throw takeFromExternrefTable0(ret[2]);
142
+ }
143
+ var v3 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
144
+ wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
145
+ return v3;
146
+ }
147
+
148
+ function __wbg_get_imports() {
149
+ const import0 = {
150
+ __proto__: null,
151
+ __wbg_Error_83742b46f01ce22d: function(arg0, arg1) {
152
+ const ret = Error(getStringFromWasm0(arg0, arg1));
153
+ return ret;
154
+ },
155
+ __wbg___wbindgen_throw_6ddd609b62940d55: function(arg0, arg1) {
156
+ throw new Error(getStringFromWasm0(arg0, arg1));
157
+ },
158
+ __wbindgen_init_externref_table: function() {
159
+ const table = wasm.__wbindgen_externrefs;
160
+ const offset = table.grow(4);
161
+ table.set(0, undefined);
162
+ table.set(offset + 0, undefined);
163
+ table.set(offset + 1, null);
164
+ table.set(offset + 2, true);
165
+ table.set(offset + 3, false);
166
+ },
167
+ };
168
+ return {
169
+ __proto__: null,
170
+ "./structured_zstd_wasm_bg.js": import0,
171
+ };
172
+ }
173
+
174
+ const ZstdDecompressStreamFinalization = (typeof FinalizationRegistry === 'undefined')
175
+ ? { register: () => {}, unregister: () => {} }
176
+ : new FinalizationRegistry(ptr => wasm.__wbg_zstddecompressstream_free(ptr >>> 0, 1));
177
+
178
+ function getArrayU8FromWasm0(ptr, len) {
179
+ ptr = ptr >>> 0;
180
+ return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
181
+ }
182
+
183
+ function getStringFromWasm0(ptr, len) {
184
+ ptr = ptr >>> 0;
185
+ return decodeText(ptr, len);
186
+ }
187
+
188
+ let cachedUint8ArrayMemory0 = null;
189
+ function getUint8ArrayMemory0() {
190
+ if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
191
+ cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
192
+ }
193
+ return cachedUint8ArrayMemory0;
194
+ }
195
+
196
+ function passArray8ToWasm0(arg, malloc) {
197
+ const ptr = malloc(arg.length * 1, 1) >>> 0;
198
+ getUint8ArrayMemory0().set(arg, ptr / 1);
199
+ WASM_VECTOR_LEN = arg.length;
200
+ return ptr;
201
+ }
202
+
203
+ function takeFromExternrefTable0(idx) {
204
+ const value = wasm.__wbindgen_externrefs.get(idx);
205
+ wasm.__externref_table_dealloc(idx);
206
+ return value;
207
+ }
208
+
209
+ let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
210
+ cachedTextDecoder.decode();
211
+ const MAX_SAFARI_DECODE_BYTES = 2146435072;
212
+ let numBytesDecoded = 0;
213
+ function decodeText(ptr, len) {
214
+ numBytesDecoded += len;
215
+ if (numBytesDecoded >= MAX_SAFARI_DECODE_BYTES) {
216
+ cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
217
+ cachedTextDecoder.decode();
218
+ numBytesDecoded = len;
219
+ }
220
+ return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
221
+ }
222
+
223
+ let WASM_VECTOR_LEN = 0;
224
+
225
+ let wasmModule, wasm;
226
+ function __wbg_finalize_init(instance, module) {
227
+ wasm = instance.exports;
228
+ wasmModule = module;
229
+ cachedUint8ArrayMemory0 = null;
230
+ wasm.__wbindgen_start();
231
+ return wasm;
232
+ }
233
+
234
+ async function __wbg_load(module, imports) {
235
+ if (typeof Response === 'function' && module instanceof Response) {
236
+ if (typeof WebAssembly.instantiateStreaming === 'function') {
237
+ try {
238
+ return await WebAssembly.instantiateStreaming(module, imports);
239
+ } catch (e) {
240
+ const validResponse = module.ok && expectedResponseType(module.type);
241
+
242
+ if (validResponse && module.headers.get('Content-Type') !== 'application/wasm') {
243
+ 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);
244
+
245
+ } else { throw e; }
246
+ }
247
+ }
248
+
249
+ const bytes = await module.arrayBuffer();
250
+ return await WebAssembly.instantiate(bytes, imports);
251
+ } else {
252
+ const instance = await WebAssembly.instantiate(module, imports);
253
+
254
+ if (instance instanceof WebAssembly.Instance) {
255
+ return { instance, module };
256
+ } else {
257
+ return instance;
258
+ }
259
+ }
260
+
261
+ function expectedResponseType(type) {
262
+ switch (type) {
263
+ case 'basic': case 'cors': case 'default': return true;
264
+ }
265
+ return false;
266
+ }
267
+ }
268
+
269
+ function initSync(module) {
270
+ if (wasm !== undefined) return wasm;
271
+
272
+
273
+ if (module !== undefined) {
274
+ if (Object.getPrototypeOf(module) === Object.prototype) {
275
+ ({module} = module)
276
+ } else {
277
+ console.warn('using deprecated parameters for `initSync()`; pass a single object instead')
278
+ }
279
+ }
280
+
281
+ const imports = __wbg_get_imports();
282
+ if (!(module instanceof WebAssembly.Module)) {
283
+ module = new WebAssembly.Module(module);
284
+ }
285
+ const instance = new WebAssembly.Instance(module, imports);
286
+ return __wbg_finalize_init(instance, module);
287
+ }
288
+
289
+ async function __wbg_init(module_or_path) {
290
+ if (wasm !== undefined) return wasm;
291
+
292
+
293
+ if (module_or_path !== undefined) {
294
+ if (Object.getPrototypeOf(module_or_path) === Object.prototype) {
295
+ ({module_or_path} = module_or_path)
296
+ } else {
297
+ console.warn('using deprecated parameters for the initialization function; pass a single object instead')
298
+ }
299
+ }
300
+
301
+ if (module_or_path === undefined) {
302
+ module_or_path = new URL('structured_zstd_wasm_bg.wasm', import.meta.url);
303
+ }
304
+ const imports = __wbg_get_imports();
305
+
306
+ if (typeof module_or_path === 'string' || (typeof Request === 'function' && module_or_path instanceof Request) || (typeof URL === 'function' && module_or_path instanceof URL)) {
307
+ module_or_path = fetch(module_or_path);
308
+ }
309
+
310
+ const { instance, module } = await __wbg_load(await module_or_path, imports);
311
+
312
+ return __wbg_finalize_init(instance, module);
313
+ }
314
+
315
+ export { initSync, __wbg_init as default };
@@ -0,0 +1,16 @@
1
+ /* tslint:disable */
2
+ /* eslint-disable */
3
+ export const memory: WebAssembly.Memory;
4
+ export const __wbg_zstddecompressstream_free: (a: number, b: number) => void;
5
+ export const compress: (a: number, b: number, c: number) => [number, number];
6
+ export const compressUsingDict: (a: number, b: number, c: number, d: number, e: number) => [number, number, number, number];
7
+ export const decompress: (a: number, b: number) => [number, number, number, number];
8
+ export const decompressUsingDict: (a: number, b: number, c: number, d: number) => [number, number, number, number];
9
+ export const zstddecompressstream_finish: (a: number) => [number, number, number, number];
10
+ export const zstddecompressstream_new: () => number;
11
+ export const zstddecompressstream_push: (a: number, b: number, c: number) => [number, number, number, number];
12
+ export const __wbindgen_externrefs: WebAssembly.Table;
13
+ export const __wbindgen_malloc: (a: number, b: number) => number;
14
+ export const __wbindgen_free: (a: number, b: number, c: number) => void;
15
+ export const __externref_table_dealloc: (a: number) => void;
16
+ export const __wbindgen_start: () => void;
@@ -0,0 +1,100 @@
1
+ /* tslint:disable */
2
+ /* eslint-disable */
3
+
4
+ /**
5
+ * Incremental streaming decompressor: feed compressed chunks via
6
+ * [`ZstdDecompressStream::push`] and receive decompressed bytes as they
7
+ * become available, then [`ZstdDecompressStream::finish`]. The decoder window
8
+ * is retained across chunks, so a large frame never needs to be fully
9
+ * buffered — a surface the common npm wasm zstd packages do not offer.
10
+ */
11
+ export class ZstdDecompressStream {
12
+ free(): void;
13
+ [Symbol.dispose](): void;
14
+ /**
15
+ * Signal end of input; returns the final decompressed bytes. Throws if the
16
+ * stream ended before the frame completed.
17
+ */
18
+ finish(): Uint8Array;
19
+ constructor();
20
+ /**
21
+ * Feed more compressed bytes; returns whatever decompressed output is now
22
+ * available (possibly empty while a block is still incomplete).
23
+ */
24
+ push(chunk: Uint8Array): Uint8Array;
25
+ }
26
+
27
+ /**
28
+ * Compress `data` into a standard Zstandard frame at compression `level`.
29
+ *
30
+ * `level` follows the zstd scale: `1..=22` (higher = smaller/slower) and
31
+ * negative levels (`-7..=-1`) for the ultra-fast tier. The returned frame
32
+ * decodes in any compliant zstd decoder, including the native C library.
33
+ */
34
+ export function compress(data: Uint8Array, level: number): Uint8Array;
35
+
36
+ /**
37
+ * Compress `data` against a raw Zstandard dictionary at compression `level`.
38
+ *
39
+ * Mirrors C `ZSTD_compress_usingDict`: the dictionary primes the encoder so
40
+ * small, similar payloads compress far better. The dictionary is the raw
41
+ * zstd dictionary blob (e.g. from `zstd --train`). Throws if it is invalid.
42
+ */
43
+ export function compressUsingDict(data: Uint8Array, dict: Uint8Array, level: number): Uint8Array;
44
+
45
+ /**
46
+ * Decompress a complete Zstandard frame back into its original bytes.
47
+ *
48
+ * Throws a JavaScript `Error` if the input is not a valid, complete frame.
49
+ */
50
+ export function decompress(data: Uint8Array): Uint8Array;
51
+
52
+ /**
53
+ * Decompress a dictionary-encoded Zstandard frame.
54
+ *
55
+ * Mirrors C `ZSTD_decompress_usingDict`: `dict` must be the same raw
56
+ * dictionary the frame was compressed with. Throws on a malformed frame or a
57
+ * dictionary mismatch.
58
+ */
59
+ export function decompressUsingDict(data: Uint8Array, dict: Uint8Array): Uint8Array;
60
+
61
+ export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembly.Module;
62
+
63
+ export interface InitOutput {
64
+ readonly memory: WebAssembly.Memory;
65
+ readonly __wbg_zstddecompressstream_free: (a: number, b: number) => void;
66
+ readonly compress: (a: number, b: number, c: number) => [number, number];
67
+ readonly compressUsingDict: (a: number, b: number, c: number, d: number, e: number) => [number, number, number, number];
68
+ readonly decompress: (a: number, b: number) => [number, number, number, number];
69
+ readonly decompressUsingDict: (a: number, b: number, c: number, d: number) => [number, number, number, number];
70
+ readonly zstddecompressstream_finish: (a: number) => [number, number, number, number];
71
+ readonly zstddecompressstream_new: () => number;
72
+ readonly zstddecompressstream_push: (a: number, b: number, c: number) => [number, number, number, number];
73
+ readonly __wbindgen_externrefs: WebAssembly.Table;
74
+ readonly __wbindgen_malloc: (a: number, b: number) => number;
75
+ readonly __wbindgen_free: (a: number, b: number, c: number) => void;
76
+ readonly __externref_table_dealloc: (a: number) => void;
77
+ readonly __wbindgen_start: () => void;
78
+ }
79
+
80
+ export type SyncInitInput = BufferSource | WebAssembly.Module;
81
+
82
+ /**
83
+ * Instantiates the given `module`, which can either be bytes or
84
+ * a precompiled `WebAssembly.Module`.
85
+ *
86
+ * @param {{ module: SyncInitInput }} module - Passing `SyncInitInput` directly is deprecated.
87
+ *
88
+ * @returns {InitOutput}
89
+ */
90
+ export function initSync(module: { module: SyncInitInput } | SyncInitInput): InitOutput;
91
+
92
+ /**
93
+ * If `module_or_path` is {RequestInfo} or {URL}, makes a request and
94
+ * for everything else, calls `WebAssembly.instantiate` directly.
95
+ *
96
+ * @param {{ module_or_path: InitInput | Promise<InitInput> }} module_or_path - Passing `InitInput` directly is deprecated.
97
+ *
98
+ * @returns {Promise<InitOutput>}
99
+ */
100
+ export default function __wbg_init (module_or_path?: { module_or_path: InitInput | Promise<InitInput> } | InitInput | Promise<InitInput>): Promise<InitOutput>;