@structured-world/structured-zstd 0.0.36 → 0.0.38

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/index.d.ts CHANGED
@@ -165,4 +165,57 @@ export declare function createCompressStreamWithDictionary(dict: Uint8Array, lev
165
165
  * @param checksum Applies to the whole stream; see {@link createDecompressStream}.
166
166
  */
167
167
  export declare function createDecompressStreamWithDictionary(dict: Uint8Array, checksum?: ContentChecksum): Promise<DecompressStream>;
168
+ /**
169
+ * A dictionary prepared once and reused across many compressions,
170
+ * decompressions, and streams — the recommended way to use dictionaries when
171
+ * more than one payload is involved.
172
+ *
173
+ * Construction parses the dictionary a single time; afterwards
174
+ * {@link ZstdDict.compress} reuses a primed encoder (the per-frame dictionary
175
+ * setup cost disappears), {@link ZstdDict.decompress} reuses one decoder
176
+ * workspace, and the stream factories seed from the prepared tables instead of
177
+ * re-parsing the blob. Raw content (no dictionary magic) is accepted; such
178
+ * dictionaries have `id === 0` and produced frames carry no dictionary ID.
179
+ *
180
+ * Call {@link ZstdDict.free} when done to release the wasm-side memory
181
+ * eagerly (it is otherwise reclaimed with the object).
182
+ *
183
+ * ```ts
184
+ * const dict = await ZstdDict.create(dictBytes);
185
+ * const frame = dict.compress(payload, 19);
186
+ * const back = dict.decompress(frame);
187
+ * const stream = dict.compressStream(19);
188
+ * ```
189
+ */
190
+ export declare class ZstdDict {
191
+ private readonly inner;
192
+ private readonly module;
193
+ /** @internal */
194
+ private constructor();
195
+ /** Parse `dict` once for repeated use. Rejects if a magic-prefixed blob is corrupt. */
196
+ static create(dict: Uint8Array): Promise<ZstdDict>;
197
+ /** The dictionary ID (0 for raw content). */
198
+ get id(): number;
199
+ /**
200
+ * Compress `data` at `level` (defaults to {@link DEFAULT_LEVEL}). The first
201
+ * call at a given level primes the encoder; following calls reuse the primed
202
+ * state — the hot path for many small frames against one dictionary.
203
+ */
204
+ compress(data: Uint8Array, level?: number, checksum?: boolean): Uint8Array;
205
+ /** Decompress a frame produced with this dictionary. */
206
+ decompress(data: Uint8Array, checksum?: ContentChecksum): Uint8Array;
207
+ /**
208
+ * Open a streaming compressor seeded from this prepared dictionary (no
209
+ * per-stream re-parse). Same contract as {@link createCompressStream}.
210
+ */
211
+ compressStream(level?: number, checksum?: boolean): CompressStream;
212
+ /**
213
+ * Open a streaming decompressor against this prepared dictionary (per-stream
214
+ * setup is a reference-count bump). Also decodes frames whose headers omit
215
+ * the dictionary ID. Same contract as {@link createDecompressStream}.
216
+ */
217
+ decompressStream(checksum?: ContentChecksum): DecompressStream;
218
+ /** Release the wasm-side dictionary memory eagerly. */
219
+ free(): void;
220
+ }
168
221
  //# sourceMappingURL=index.d.ts.map
package/index.d.ts.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAIH;;;GAGG;AACH,oBAAY,eAAe;IACzB,+DAA+D;IAC/D,IAAI,IAAI;IACR,sFAAsF;IACtF,QAAQ,IAAI;IACZ,yDAAyD;IACzD,MAAM,IAAI;CACX;AAkCD;;;;;;GAMG;AACH,MAAM,WAAW,gBAAgB;IAC/B,2EAA2E;IAC3E,IAAI,CAAC,KAAK,EAAE,UAAU,GAAG,UAAU,CAAC;IACpC;;;OAGG;IACH,MAAM,IAAI,UAAU,CAAC;IACrB;;;OAGG;IACH,cAAc,IAAI,MAAM,GAAG,SAAS,CAAC;IACrC;;;;OAIG;IACH,kBAAkB,IAAI,MAAM,GAAG,SAAS,CAAC;IACzC,0CAA0C;IAC1C,IAAI,IAAI,IAAI,CAAC;CACd;AAED;;;;;;;;;GASG;AACH,MAAM,WAAW,cAAc;IAC7B,+EAA+E;IAC/E,IAAI,CAAC,KAAK,EAAE,UAAU,GAAG,UAAU,CAAC;IACpC;;;;OAIG;IACH,MAAM,IAAI,UAAU,CAAC;IACrB,0CAA0C;IAC1C,IAAI,IAAI,IAAI,CAAC;CACd;AA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UAAU,CAAC,IAAI,EAAE,UAAU,EAAE,QAAQ,CAAC,EAAE,eAAe,GAAG,UAAU;IAIpE;;;OAGG;IACH,cAAc,CAAC,KAAK,GAAE,MAAsB,EAAE,QAAQ,CAAC,EAAE,OAAO,GAAG,cAAc;IAIjF;;;;OAIG;IACH,gBAAgB,CAAC,QAAQ,CAAC,EAAE,eAAe,GAAG,gBAAgB;IAI9D,uDAAuD;IACvD,IAAI,IAAI,IAAI;CAGb"}
package/index.js CHANGED
@@ -180,4 +180,76 @@ export async function createDecompressStreamWithDictionary(dict, checksum) {
180
180
  loading ??= load();
181
181
  return (await loading).ZstdDecompressStream.withDictionary(dict, checksum);
182
182
  }
183
+ /**
184
+ * A dictionary prepared once and reused across many compressions,
185
+ * decompressions, and streams — the recommended way to use dictionaries when
186
+ * more than one payload is involved.
187
+ *
188
+ * Construction parses the dictionary a single time; afterwards
189
+ * {@link ZstdDict.compress} reuses a primed encoder (the per-frame dictionary
190
+ * setup cost disappears), {@link ZstdDict.decompress} reuses one decoder
191
+ * workspace, and the stream factories seed from the prepared tables instead of
192
+ * re-parsing the blob. Raw content (no dictionary magic) is accepted; such
193
+ * dictionaries have `id === 0` and produced frames carry no dictionary ID.
194
+ *
195
+ * Call {@link ZstdDict.free} when done to release the wasm-side memory
196
+ * eagerly (it is otherwise reclaimed with the object).
197
+ *
198
+ * ```ts
199
+ * const dict = await ZstdDict.create(dictBytes);
200
+ * const frame = dict.compress(payload, 19);
201
+ * const back = dict.decompress(frame);
202
+ * const stream = dict.compressStream(19);
203
+ * ```
204
+ */
205
+ export class ZstdDict {
206
+ inner;
207
+ module;
208
+ /** @internal */
209
+ constructor(inner, module) {
210
+ this.inner = inner;
211
+ this.module = module;
212
+ }
213
+ /** Parse `dict` once for repeated use. Rejects if a magic-prefixed blob is corrupt. */
214
+ static async create(dict) {
215
+ loading ??= load();
216
+ const module = await loading;
217
+ return new ZstdDict(new module.ZstdDictionary(dict), module);
218
+ }
219
+ /** The dictionary ID (0 for raw content). */
220
+ get id() {
221
+ return this.inner.id;
222
+ }
223
+ /**
224
+ * Compress `data` at `level` (defaults to {@link DEFAULT_LEVEL}). The first
225
+ * call at a given level primes the encoder; following calls reuse the primed
226
+ * state — the hot path for many small frames against one dictionary.
227
+ */
228
+ compress(data, level = DEFAULT_LEVEL, checksum) {
229
+ return this.inner.compress(data, level, checksum);
230
+ }
231
+ /** Decompress a frame produced with this dictionary. */
232
+ decompress(data, checksum) {
233
+ return this.inner.decompress(data, checksum);
234
+ }
235
+ /**
236
+ * Open a streaming compressor seeded from this prepared dictionary (no
237
+ * per-stream re-parse). Same contract as {@link createCompressStream}.
238
+ */
239
+ compressStream(level = DEFAULT_LEVEL, checksum) {
240
+ return this.module.ZstdCompressStream.withPreparedDictionary(level, this.inner, checksum);
241
+ }
242
+ /**
243
+ * Open a streaming decompressor against this prepared dictionary (per-stream
244
+ * setup is a reference-count bump). Also decodes frames whose headers omit
245
+ * the dictionary ID. Same contract as {@link createDecompressStream}.
246
+ */
247
+ decompressStream(checksum) {
248
+ return this.module.ZstdDecompressStream.withPreparedDictionary(this.inner, checksum);
249
+ }
250
+ /** Release the wasm-side dictionary memory eagerly. */
251
+ free() {
252
+ this.inner.free();
253
+ }
254
+ }
183
255
  //# sourceMappingURL=index.js.map
package/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,EAAE,IAAI,EAAE,MAAM,qBAAqB,CAAC;AAE3C;;;GAGG;AACH,MAAM,CAAN,IAAY,eAOX;AAPD,WAAY,eAAe;IACzB,+DAA+D;IAC/D,qDAAQ,CAAA;IACR,sFAAsF;IACtF,6DAAY,CAAA;IACZ,yDAAyD;IACzD,yDAAU,CAAA;AACZ,CAAC,EAPW,eAAe,KAAf,eAAe,QAO1B;AAuFD,mEAAmE;AACnE,MAAM,aAAa,GAAG,CAAC,CAAC;AAExB,IAAI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AAC;IAED,6CAA6C;IAC7C,IAAI,EAAE;QACJ,OAAO,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC;IACvB,CAAC;IAED;;;;OAIG;IACH,QAAQ,CAAC,IAAgB,EAAE,QAAgB,aAAa,EAAE,QAAkB;QAC1E,OAAO,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,IAAI,EAAE,KAAK,EAAE,QAAQ,CAAC,CAAC;IACpD,CAAC;IAED,wDAAwD;IACxD,UAAU,CAAC,IAAgB,EAAE,QAA0B;QACrD,OAAO,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC;IAC/C,CAAC;IAED;;;OAGG;IACH,cAAc,CAAC,QAAgB,aAAa,EAAE,QAAkB;QAC9D,OAAO,IAAI,CAAC,MAAM,CAAC,kBAAkB,CAAC,sBAAsB,CAAC,KAAK,EAAE,IAAI,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAC;IAC5F,CAAC;IAED;;;;OAIG;IACH,gBAAgB,CAAC,QAA0B;QACzC,OAAO,IAAI,CAAC,MAAM,CAAC,oBAAoB,CAAC,sBAAsB,CAAC,IAAI,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAC;IACvF,CAAC;IAED,uDAAuD;IACvD,IAAI;QACF,IAAI,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC;IACpB,CAAC;CACF"}
package/index.ts CHANGED
@@ -52,6 +52,10 @@ interface Payload {
52
52
  ) => Uint8Array;
53
53
  ZstdDecompressStream: (new (checksum?: ContentChecksum) => DecompressStream) & {
54
54
  withDictionary: (dict: Uint8Array, checksum?: ContentChecksum) => DecompressStream;
55
+ withPreparedDictionary: (
56
+ dict: WasmDictionary,
57
+ checksum?: ContentChecksum,
58
+ ) => DecompressStream;
55
59
  };
56
60
  ZstdCompressStream: (new (level: number, checksum?: boolean) => CompressStream) & {
57
61
  withDictionary: (
@@ -59,7 +63,21 @@ interface Payload {
59
63
  dict: Uint8Array,
60
64
  checksum?: boolean,
61
65
  ) => CompressStream;
66
+ withPreparedDictionary: (
67
+ level: number,
68
+ dict: WasmDictionary,
69
+ checksum?: boolean,
70
+ ) => CompressStream;
62
71
  };
72
+ ZstdDictionary: new (dict: Uint8Array) => WasmDictionary;
73
+ }
74
+
75
+ /** Raw wasm-side prepared-dictionary handle (see {@link ZstdDict}). */
76
+ interface WasmDictionary {
77
+ readonly id: number;
78
+ compress(data: Uint8Array, level: number, checksum?: boolean): Uint8Array;
79
+ decompress(data: Uint8Array, checksum?: ContentChecksum): Uint8Array;
80
+ free(): void;
63
81
  }
64
82
 
65
83
  /**
@@ -307,3 +325,81 @@ export async function createDecompressStreamWithDictionary(
307
325
  loading ??= load();
308
326
  return (await loading).ZstdDecompressStream.withDictionary(dict, checksum);
309
327
  }
328
+
329
+ /**
330
+ * A dictionary prepared once and reused across many compressions,
331
+ * decompressions, and streams — the recommended way to use dictionaries when
332
+ * more than one payload is involved.
333
+ *
334
+ * Construction parses the dictionary a single time; afterwards
335
+ * {@link ZstdDict.compress} reuses a primed encoder (the per-frame dictionary
336
+ * setup cost disappears), {@link ZstdDict.decompress} reuses one decoder
337
+ * workspace, and the stream factories seed from the prepared tables instead of
338
+ * re-parsing the blob. Raw content (no dictionary magic) is accepted; such
339
+ * dictionaries have `id === 0` and produced frames carry no dictionary ID.
340
+ *
341
+ * Call {@link ZstdDict.free} when done to release the wasm-side memory
342
+ * eagerly (it is otherwise reclaimed with the object).
343
+ *
344
+ * ```ts
345
+ * const dict = await ZstdDict.create(dictBytes);
346
+ * const frame = dict.compress(payload, 19);
347
+ * const back = dict.decompress(frame);
348
+ * const stream = dict.compressStream(19);
349
+ * ```
350
+ */
351
+ export class ZstdDict {
352
+ /** @internal */
353
+ private constructor(
354
+ private readonly inner: WasmDictionary,
355
+ private readonly module: Payload,
356
+ ) {}
357
+
358
+ /** Parse `dict` once for repeated use. Rejects if a magic-prefixed blob is corrupt. */
359
+ static async create(dict: Uint8Array): Promise<ZstdDict> {
360
+ loading ??= load();
361
+ const module = await loading;
362
+ return new ZstdDict(new module.ZstdDictionary(dict), module);
363
+ }
364
+
365
+ /** The dictionary ID (0 for raw content). */
366
+ get id(): number {
367
+ return this.inner.id;
368
+ }
369
+
370
+ /**
371
+ * Compress `data` at `level` (defaults to {@link DEFAULT_LEVEL}). The first
372
+ * call at a given level primes the encoder; following calls reuse the primed
373
+ * state — the hot path for many small frames against one dictionary.
374
+ */
375
+ compress(data: Uint8Array, level: number = DEFAULT_LEVEL, checksum?: boolean): Uint8Array {
376
+ return this.inner.compress(data, level, checksum);
377
+ }
378
+
379
+ /** Decompress a frame produced with this dictionary. */
380
+ decompress(data: Uint8Array, checksum?: ContentChecksum): Uint8Array {
381
+ return this.inner.decompress(data, checksum);
382
+ }
383
+
384
+ /**
385
+ * Open a streaming compressor seeded from this prepared dictionary (no
386
+ * per-stream re-parse). Same contract as {@link createCompressStream}.
387
+ */
388
+ compressStream(level: number = DEFAULT_LEVEL, checksum?: boolean): CompressStream {
389
+ return this.module.ZstdCompressStream.withPreparedDictionary(level, this.inner, checksum);
390
+ }
391
+
392
+ /**
393
+ * Open a streaming decompressor against this prepared dictionary (per-stream
394
+ * setup is a reference-count bump). Also decodes frames whose headers omit
395
+ * the dictionary ID. Same contract as {@link createDecompressStream}.
396
+ */
397
+ decompressStream(checksum?: ContentChecksum): DecompressStream {
398
+ return this.module.ZstdDecompressStream.withPreparedDictionary(this.inner, checksum);
399
+ }
400
+
401
+ /** Release the wasm-side dictionary memory eagerly. */
402
+ free(): void {
403
+ this.inner.free();
404
+ }
405
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@structured-world/structured-zstd",
3
- "version": "0.0.36",
3
+ "version": "0.0.38",
4
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
5
  "type": "module",
6
6
  "exports": {
@@ -62,6 +62,12 @@ export class ZstdCompressStream {
62
62
  * `decompressUsingDict`). Throws if the dictionary is invalid.
63
63
  */
64
64
  static withDictionary(level: number, dict: Uint8Array, checksum?: boolean | null): ZstdCompressStream;
65
+ /**
66
+ * Open a streaming compressor at `level` seeded from a [`ZstdDictionary`]
67
+ * prepared once: per-stream setup copies the prepared tables instead of
68
+ * re-parsing the dictionary blob (no FSE/HUF table rebuild).
69
+ */
70
+ static withPreparedDictionary(level: number, dict: ZstdDictionary, checksum?: boolean | null): ZstdCompressStream;
65
71
  }
66
72
 
67
73
  /**
@@ -112,6 +118,63 @@ export class ZstdDecompressStream {
112
118
  * dictionary is malformed.
113
119
  */
114
120
  static withDictionary(dict: Uint8Array, checksum?: ContentChecksum | null): ZstdDecompressStream;
121
+ /**
122
+ * Open a streaming decompressor against a [`ZstdDictionary`] prepared
123
+ * once: per-stream setup is a reference-count bump, no dictionary
124
+ * re-parse. Unlike [`Self::with_dictionary`] this also decodes frames
125
+ * whose headers omit the dictionary ID (raw-content dictionaries).
126
+ */
127
+ static withPreparedDictionary(dict: ZstdDictionary, checksum?: ContentChecksum | null): ZstdDecompressStream;
128
+ }
129
+
130
+ /**
131
+ * A dictionary prepared once for repeated use across compressions,
132
+ * decompressions, and streams — the wasm analogue of C's `ZSTD_CDict` +
133
+ * `ZSTD_DDict` pair behind one object.
134
+ *
135
+ * Construction parses the dictionary a single time (entropy decode tables +
136
+ * encoder conversion). The hot paths then avoid every per-call setup cost:
137
+ *
138
+ * * [`compress`](Self::compress) keeps a cached frame compressor whose
139
+ * dictionary-primed match-finder snapshot is reused across calls — the
140
+ * dominant per-frame cost for small payloads;
141
+ * * [`decompress`](Self::decompress) reuses one decoder workspace;
142
+ * * the stream constructors seed from the prepared tables (a table copy on
143
+ * the encode side, a reference-count bump on the decode side) instead of
144
+ * re-parsing the blob per stream.
145
+ *
146
+ * Raw content (bytes without the `0xEC30A437` dictionary magic) is accepted
147
+ * like upstream's auto mode: such dictionaries have ID 0 and produced frames
148
+ * carry no dictionary ID.
149
+ */
150
+ export class ZstdDictionary {
151
+ free(): void;
152
+ [Symbol.dispose](): void;
153
+ /**
154
+ * Compress `data` with this dictionary at `level` — the hot path for
155
+ * many small frames against one dictionary: the first call at a given
156
+ * level attaches the prepared tables and primes the match finder, and
157
+ * every following call reuses that primed snapshot.
158
+ *
159
+ * `checksum` is optional (default `false`).
160
+ */
161
+ compress(data: Uint8Array, level: number, checksum?: boolean | null): Uint8Array;
162
+ /**
163
+ * Decompress a frame produced with this dictionary, reusing the
164
+ * prepared tables and one decoder workspace across calls. `checksum`
165
+ * behaves as in the module-level `decompress`.
166
+ */
167
+ decompress(data: Uint8Array, checksum?: ContentChecksum | null): Uint8Array;
168
+ /**
169
+ * Parse `dict` once for repeated use. Magic-prefixed blobs (e.g. from
170
+ * `zstd --train`) parse as full dictionaries; anything else is raw
171
+ * content. Throws if a magic-prefixed blob is corrupt.
172
+ */
173
+ constructor(dict: Uint8Array);
174
+ /**
175
+ * The dictionary ID (0 for raw content).
176
+ */
177
+ readonly id: number;
115
178
  }
116
179
 
117
180
  /**
@@ -165,6 +228,7 @@ export interface InitOutput {
165
228
  readonly memory: WebAssembly.Memory;
166
229
  readonly __wbg_zstdcompressstream_free: (a: number, b: number) => void;
167
230
  readonly __wbg_zstddecompressstream_free: (a: number, b: number) => void;
231
+ readonly __wbg_zstddictionary_free: (a: number, b: number) => void;
168
232
  readonly compress: (a: number, b: number, c: number, d: number) => [number, number];
169
233
  readonly compressUsingDict: (a: number, b: number, c: number, d: number, e: number, f: number) => [number, number, number, number];
170
234
  readonly decompress: (a: number, b: number, c: number) => [number, number, number, number];
@@ -173,12 +237,18 @@ export interface InitOutput {
173
237
  readonly zstdcompressstream_new: (a: number, b: number) => number;
174
238
  readonly zstdcompressstream_push: (a: number, b: number, c: number) => [number, number, number, number];
175
239
  readonly zstdcompressstream_withDictionary: (a: number, b: number, c: number, d: number) => [number, number, number];
240
+ readonly zstdcompressstream_withPreparedDictionary: (a: number, b: number, c: number) => [number, number, number];
176
241
  readonly zstddecompressstream_calculatedChecksum: (a: number) => number;
177
242
  readonly zstddecompressstream_finish: (a: number) => [number, number, number, number];
178
243
  readonly zstddecompressstream_new: (a: number) => number;
179
244
  readonly zstddecompressstream_push: (a: number, b: number, c: number) => [number, number, number, number];
180
245
  readonly zstddecompressstream_storedChecksum: (a: number) => number;
181
246
  readonly zstddecompressstream_withDictionary: (a: number, b: number, c: number) => [number, number, number];
247
+ readonly zstddecompressstream_withPreparedDictionary: (a: number, b: number) => number;
248
+ readonly zstddictionary_compress: (a: number, b: number, c: number, d: number, e: number) => [number, number, number, number];
249
+ readonly zstddictionary_decompress: (a: number, b: number, c: number, d: number) => [number, number, number, number];
250
+ readonly zstddictionary_id: (a: number) => number;
251
+ readonly zstddictionary_new: (a: number, b: number) => [number, number, number];
182
252
  readonly __wbindgen_externrefs: WebAssembly.Table;
183
253
  readonly __wbindgen_malloc: (a: number, b: number) => number;
184
254
  readonly __wbindgen_free: (a: number, b: number, c: number) => void;
@@ -116,6 +116,23 @@ export class ZstdCompressStream {
116
116
  }
117
117
  return ZstdCompressStream.__wrap(ret[0]);
118
118
  }
119
+ /**
120
+ * Open a streaming compressor at `level` seeded from a [`ZstdDictionary`]
121
+ * prepared once: per-stream setup copies the prepared tables instead of
122
+ * re-parsing the dictionary blob (no FSE/HUF table rebuild).
123
+ * @param {number} level
124
+ * @param {ZstdDictionary} dict
125
+ * @param {boolean | null} [checksum]
126
+ * @returns {ZstdCompressStream}
127
+ */
128
+ static withPreparedDictionary(level, dict, checksum) {
129
+ _assertClass(dict, ZstdDictionary);
130
+ const ret = wasm.zstdcompressstream_withPreparedDictionary(level, dict.__wbg_ptr, isLikeNone(checksum) ? 0xFFFFFF : checksum ? 1 : 0);
131
+ if (ret[2]) {
132
+ throw takeFromExternrefTable0(ret[1]);
133
+ }
134
+ return ZstdCompressStream.__wrap(ret[0]);
135
+ }
119
136
  }
120
137
  if (Symbol.dispose) ZstdCompressStream.prototype[Symbol.dispose] = ZstdCompressStream.prototype.free;
121
138
 
@@ -227,9 +244,124 @@ export class ZstdDecompressStream {
227
244
  }
228
245
  return ZstdDecompressStream.__wrap(ret[0]);
229
246
  }
247
+ /**
248
+ * Open a streaming decompressor against a [`ZstdDictionary`] prepared
249
+ * once: per-stream setup is a reference-count bump, no dictionary
250
+ * re-parse. Unlike [`Self::with_dictionary`] this also decodes frames
251
+ * whose headers omit the dictionary ID (raw-content dictionaries).
252
+ * @param {ZstdDictionary} dict
253
+ * @param {ContentChecksum | null} [checksum]
254
+ * @returns {ZstdDecompressStream}
255
+ */
256
+ static withPreparedDictionary(dict, checksum) {
257
+ _assertClass(dict, ZstdDictionary);
258
+ const ret = wasm.zstddecompressstream_withPreparedDictionary(dict.__wbg_ptr, isLikeNone(checksum) ? 3 : checksum);
259
+ return ZstdDecompressStream.__wrap(ret);
260
+ }
230
261
  }
231
262
  if (Symbol.dispose) ZstdDecompressStream.prototype[Symbol.dispose] = ZstdDecompressStream.prototype.free;
232
263
 
264
+ /**
265
+ * A dictionary prepared once for repeated use across compressions,
266
+ * decompressions, and streams — the wasm analogue of C's `ZSTD_CDict` +
267
+ * `ZSTD_DDict` pair behind one object.
268
+ *
269
+ * Construction parses the dictionary a single time (entropy decode tables +
270
+ * encoder conversion). The hot paths then avoid every per-call setup cost:
271
+ *
272
+ * * [`compress`](Self::compress) keeps a cached frame compressor whose
273
+ * dictionary-primed match-finder snapshot is reused across calls — the
274
+ * dominant per-frame cost for small payloads;
275
+ * * [`decompress`](Self::decompress) reuses one decoder workspace;
276
+ * * the stream constructors seed from the prepared tables (a table copy on
277
+ * the encode side, a reference-count bump on the decode side) instead of
278
+ * re-parsing the blob per stream.
279
+ *
280
+ * Raw content (bytes without the `0xEC30A437` dictionary magic) is accepted
281
+ * like upstream's auto mode: such dictionaries have ID 0 and produced frames
282
+ * carry no dictionary ID.
283
+ */
284
+ export class ZstdDictionary {
285
+ __destroy_into_raw() {
286
+ const ptr = this.__wbg_ptr;
287
+ this.__wbg_ptr = 0;
288
+ ZstdDictionaryFinalization.unregister(this);
289
+ return ptr;
290
+ }
291
+ free() {
292
+ const ptr = this.__destroy_into_raw();
293
+ wasm.__wbg_zstddictionary_free(ptr, 0);
294
+ }
295
+ /**
296
+ * Compress `data` with this dictionary at `level` — the hot path for
297
+ * many small frames against one dictionary: the first call at a given
298
+ * level attaches the prepared tables and primes the match finder, and
299
+ * every following call reuses that primed snapshot.
300
+ *
301
+ * `checksum` is optional (default `false`).
302
+ * @param {Uint8Array} data
303
+ * @param {number} level
304
+ * @param {boolean | null} [checksum]
305
+ * @returns {Uint8Array}
306
+ */
307
+ compress(data, level, checksum) {
308
+ const ptr0 = passArray8ToWasm0(data, wasm.__wbindgen_malloc);
309
+ const len0 = WASM_VECTOR_LEN;
310
+ const ret = wasm.zstddictionary_compress(this.__wbg_ptr, ptr0, len0, level, isLikeNone(checksum) ? 0xFFFFFF : checksum ? 1 : 0);
311
+ if (ret[3]) {
312
+ throw takeFromExternrefTable0(ret[2]);
313
+ }
314
+ var v2 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
315
+ wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
316
+ return v2;
317
+ }
318
+ /**
319
+ * Decompress a frame produced with this dictionary, reusing the
320
+ * prepared tables and one decoder workspace across calls. `checksum`
321
+ * behaves as in the module-level `decompress`.
322
+ * @param {Uint8Array} data
323
+ * @param {ContentChecksum | null} [checksum]
324
+ * @returns {Uint8Array}
325
+ */
326
+ decompress(data, checksum) {
327
+ const ptr0 = passArray8ToWasm0(data, wasm.__wbindgen_malloc);
328
+ const len0 = WASM_VECTOR_LEN;
329
+ const ret = wasm.zstddictionary_decompress(this.__wbg_ptr, ptr0, len0, isLikeNone(checksum) ? 3 : checksum);
330
+ if (ret[3]) {
331
+ throw takeFromExternrefTable0(ret[2]);
332
+ }
333
+ var v2 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
334
+ wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
335
+ return v2;
336
+ }
337
+ /**
338
+ * The dictionary ID (0 for raw content).
339
+ * @returns {number}
340
+ */
341
+ get id() {
342
+ const ret = wasm.zstddictionary_id(this.__wbg_ptr);
343
+ return ret >>> 0;
344
+ }
345
+ /**
346
+ * Parse `dict` once for repeated use. Magic-prefixed blobs (e.g. from
347
+ * `zstd --train`) parse as full dictionaries; anything else is raw
348
+ * content. Throws if a magic-prefixed blob is corrupt.
349
+ * @param {Uint8Array} dict
350
+ */
351
+ constructor(dict) {
352
+ const ptr0 = passArray8ToWasm0(dict, wasm.__wbindgen_malloc);
353
+ const len0 = WASM_VECTOR_LEN;
354
+ const ret = wasm.zstddictionary_new(ptr0, len0);
355
+ if (ret[2]) {
356
+ throw takeFromExternrefTable0(ret[1]);
357
+ }
358
+ this.__wbg_ptr = ret[0];
359
+ ZstdDictionaryFinalization.register(this, this.__wbg_ptr, this);
360
+ return this;
361
+ }
362
+ }
363
+ if (Symbol.dispose) ZstdDictionary.prototype[Symbol.dispose] = ZstdDictionary.prototype.free;
364
+
233
365
  /**
234
366
  * Compress `data` into a standard Zstandard frame at compression `level`.
235
367
  *
@@ -334,11 +466,11 @@ export function decompressUsingDict(data, dict, checksum) {
334
466
  function __wbg_get_imports() {
335
467
  const import0 = {
336
468
  __proto__: null,
337
- __wbg_Error_9dc85fe1bc224456: function(arg0, arg1) {
469
+ __wbg_Error_fdd633d4bb5dd76a: function(arg0, arg1) {
338
470
  const ret = Error(getStringFromWasm0(arg0, arg1));
339
471
  return ret;
340
472
  },
341
- __wbg___wbindgen_throw_bbadd78c1bac3a77: function(arg0, arg1) {
473
+ __wbg___wbindgen_throw_ea4887a5f8f9a9db: function(arg0, arg1) {
342
474
  throw new Error(getStringFromWasm0(arg0, arg1));
343
475
  },
344
476
  __wbindgen_init_externref_table: function() {
@@ -363,6 +495,15 @@ const ZstdCompressStreamFinalization = (typeof FinalizationRegistry === 'undefin
363
495
  const ZstdDecompressStreamFinalization = (typeof FinalizationRegistry === 'undefined')
364
496
  ? { register: () => {}, unregister: () => {} }
365
497
  : new FinalizationRegistry(ptr => wasm.__wbg_zstddecompressstream_free(ptr, 1));
498
+ const ZstdDictionaryFinalization = (typeof FinalizationRegistry === 'undefined')
499
+ ? { register: () => {}, unregister: () => {} }
500
+ : new FinalizationRegistry(ptr => wasm.__wbg_zstddictionary_free(ptr, 1));
501
+
502
+ function _assertClass(instance, klass) {
503
+ if (!(instance instanceof klass)) {
504
+ throw new Error(`expected instance of ${klass.name}`);
505
+ }
506
+ }
366
507
 
367
508
  function getArrayU8FromWasm0(ptr, len) {
368
509
  ptr = ptr >>> 0;
Binary file
@@ -3,6 +3,7 @@
3
3
  export const memory: WebAssembly.Memory;
4
4
  export const __wbg_zstdcompressstream_free: (a: number, b: number) => void;
5
5
  export const __wbg_zstddecompressstream_free: (a: number, b: number) => void;
6
+ export const __wbg_zstddictionary_free: (a: number, b: number) => void;
6
7
  export const compress: (a: number, b: number, c: number, d: number) => [number, number];
7
8
  export const compressUsingDict: (a: number, b: number, c: number, d: number, e: number, f: number) => [number, number, number, number];
8
9
  export const decompress: (a: number, b: number, c: number) => [number, number, number, number];
@@ -11,12 +12,18 @@ export const zstdcompressstream_finish: (a: number) => [number, number, number,
11
12
  export const zstdcompressstream_new: (a: number, b: number) => number;
12
13
  export const zstdcompressstream_push: (a: number, b: number, c: number) => [number, number, number, number];
13
14
  export const zstdcompressstream_withDictionary: (a: number, b: number, c: number, d: number) => [number, number, number];
15
+ export const zstdcompressstream_withPreparedDictionary: (a: number, b: number, c: number) => [number, number, number];
14
16
  export const zstddecompressstream_calculatedChecksum: (a: number) => number;
15
17
  export const zstddecompressstream_finish: (a: number) => [number, number, number, number];
16
18
  export const zstddecompressstream_new: (a: number) => number;
17
19
  export const zstddecompressstream_push: (a: number, b: number, c: number) => [number, number, number, number];
18
20
  export const zstddecompressstream_storedChecksum: (a: number) => number;
19
21
  export const zstddecompressstream_withDictionary: (a: number, b: number, c: number) => [number, number, number];
22
+ export const zstddecompressstream_withPreparedDictionary: (a: number, b: number) => number;
23
+ export const zstddictionary_compress: (a: number, b: number, c: number, d: number, e: number) => [number, number, number, number];
24
+ export const zstddictionary_decompress: (a: number, b: number, c: number, d: number) => [number, number, number, number];
25
+ export const zstddictionary_id: (a: number) => number;
26
+ export const zstddictionary_new: (a: number, b: number) => [number, number, number];
20
27
  export const __wbindgen_externrefs: WebAssembly.Table;
21
28
  export const __wbindgen_malloc: (a: number, b: number) => number;
22
29
  export const __wbindgen_free: (a: number, b: number, c: number) => void;
@@ -62,6 +62,12 @@ export class ZstdCompressStream {
62
62
  * `decompressUsingDict`). Throws if the dictionary is invalid.
63
63
  */
64
64
  static withDictionary(level: number, dict: Uint8Array, checksum?: boolean | null): ZstdCompressStream;
65
+ /**
66
+ * Open a streaming compressor at `level` seeded from a [`ZstdDictionary`]
67
+ * prepared once: per-stream setup copies the prepared tables instead of
68
+ * re-parsing the dictionary blob (no FSE/HUF table rebuild).
69
+ */
70
+ static withPreparedDictionary(level: number, dict: ZstdDictionary, checksum?: boolean | null): ZstdCompressStream;
65
71
  }
66
72
 
67
73
  /**
@@ -112,6 +118,63 @@ export class ZstdDecompressStream {
112
118
  * dictionary is malformed.
113
119
  */
114
120
  static withDictionary(dict: Uint8Array, checksum?: ContentChecksum | null): ZstdDecompressStream;
121
+ /**
122
+ * Open a streaming decompressor against a [`ZstdDictionary`] prepared
123
+ * once: per-stream setup is a reference-count bump, no dictionary
124
+ * re-parse. Unlike [`Self::with_dictionary`] this also decodes frames
125
+ * whose headers omit the dictionary ID (raw-content dictionaries).
126
+ */
127
+ static withPreparedDictionary(dict: ZstdDictionary, checksum?: ContentChecksum | null): ZstdDecompressStream;
128
+ }
129
+
130
+ /**
131
+ * A dictionary prepared once for repeated use across compressions,
132
+ * decompressions, and streams — the wasm analogue of C's `ZSTD_CDict` +
133
+ * `ZSTD_DDict` pair behind one object.
134
+ *
135
+ * Construction parses the dictionary a single time (entropy decode tables +
136
+ * encoder conversion). The hot paths then avoid every per-call setup cost:
137
+ *
138
+ * * [`compress`](Self::compress) keeps a cached frame compressor whose
139
+ * dictionary-primed match-finder snapshot is reused across calls — the
140
+ * dominant per-frame cost for small payloads;
141
+ * * [`decompress`](Self::decompress) reuses one decoder workspace;
142
+ * * the stream constructors seed from the prepared tables (a table copy on
143
+ * the encode side, a reference-count bump on the decode side) instead of
144
+ * re-parsing the blob per stream.
145
+ *
146
+ * Raw content (bytes without the `0xEC30A437` dictionary magic) is accepted
147
+ * like upstream's auto mode: such dictionaries have ID 0 and produced frames
148
+ * carry no dictionary ID.
149
+ */
150
+ export class ZstdDictionary {
151
+ free(): void;
152
+ [Symbol.dispose](): void;
153
+ /**
154
+ * Compress `data` with this dictionary at `level` — the hot path for
155
+ * many small frames against one dictionary: the first call at a given
156
+ * level attaches the prepared tables and primes the match finder, and
157
+ * every following call reuses that primed snapshot.
158
+ *
159
+ * `checksum` is optional (default `false`).
160
+ */
161
+ compress(data: Uint8Array, level: number, checksum?: boolean | null): Uint8Array;
162
+ /**
163
+ * Decompress a frame produced with this dictionary, reusing the
164
+ * prepared tables and one decoder workspace across calls. `checksum`
165
+ * behaves as in the module-level `decompress`.
166
+ */
167
+ decompress(data: Uint8Array, checksum?: ContentChecksum | null): Uint8Array;
168
+ /**
169
+ * Parse `dict` once for repeated use. Magic-prefixed blobs (e.g. from
170
+ * `zstd --train`) parse as full dictionaries; anything else is raw
171
+ * content. Throws if a magic-prefixed blob is corrupt.
172
+ */
173
+ constructor(dict: Uint8Array);
174
+ /**
175
+ * The dictionary ID (0 for raw content).
176
+ */
177
+ readonly id: number;
115
178
  }
116
179
 
117
180
  /**
@@ -165,6 +228,7 @@ export interface InitOutput {
165
228
  readonly memory: WebAssembly.Memory;
166
229
  readonly __wbg_zstdcompressstream_free: (a: number, b: number) => void;
167
230
  readonly __wbg_zstddecompressstream_free: (a: number, b: number) => void;
231
+ readonly __wbg_zstddictionary_free: (a: number, b: number) => void;
168
232
  readonly compress: (a: number, b: number, c: number, d: number) => [number, number];
169
233
  readonly compressUsingDict: (a: number, b: number, c: number, d: number, e: number, f: number) => [number, number, number, number];
170
234
  readonly decompress: (a: number, b: number, c: number) => [number, number, number, number];
@@ -173,12 +237,18 @@ export interface InitOutput {
173
237
  readonly zstdcompressstream_new: (a: number, b: number) => number;
174
238
  readonly zstdcompressstream_push: (a: number, b: number, c: number) => [number, number, number, number];
175
239
  readonly zstdcompressstream_withDictionary: (a: number, b: number, c: number, d: number) => [number, number, number];
240
+ readonly zstdcompressstream_withPreparedDictionary: (a: number, b: number, c: number) => [number, number, number];
176
241
  readonly zstddecompressstream_calculatedChecksum: (a: number) => number;
177
242
  readonly zstddecompressstream_finish: (a: number) => [number, number, number, number];
178
243
  readonly zstddecompressstream_new: (a: number) => number;
179
244
  readonly zstddecompressstream_push: (a: number, b: number, c: number) => [number, number, number, number];
180
245
  readonly zstddecompressstream_storedChecksum: (a: number) => number;
181
246
  readonly zstddecompressstream_withDictionary: (a: number, b: number, c: number) => [number, number, number];
247
+ readonly zstddecompressstream_withPreparedDictionary: (a: number, b: number) => number;
248
+ readonly zstddictionary_compress: (a: number, b: number, c: number, d: number, e: number) => [number, number, number, number];
249
+ readonly zstddictionary_decompress: (a: number, b: number, c: number, d: number) => [number, number, number, number];
250
+ readonly zstddictionary_id: (a: number) => number;
251
+ readonly zstddictionary_new: (a: number, b: number) => [number, number, number];
182
252
  readonly __wbindgen_externrefs: WebAssembly.Table;
183
253
  readonly __wbindgen_malloc: (a: number, b: number) => number;
184
254
  readonly __wbindgen_free: (a: number, b: number, c: number) => void;
@@ -116,6 +116,23 @@ export class ZstdCompressStream {
116
116
  }
117
117
  return ZstdCompressStream.__wrap(ret[0]);
118
118
  }
119
+ /**
120
+ * Open a streaming compressor at `level` seeded from a [`ZstdDictionary`]
121
+ * prepared once: per-stream setup copies the prepared tables instead of
122
+ * re-parsing the dictionary blob (no FSE/HUF table rebuild).
123
+ * @param {number} level
124
+ * @param {ZstdDictionary} dict
125
+ * @param {boolean | null} [checksum]
126
+ * @returns {ZstdCompressStream}
127
+ */
128
+ static withPreparedDictionary(level, dict, checksum) {
129
+ _assertClass(dict, ZstdDictionary);
130
+ const ret = wasm.zstdcompressstream_withPreparedDictionary(level, dict.__wbg_ptr, isLikeNone(checksum) ? 0xFFFFFF : checksum ? 1 : 0);
131
+ if (ret[2]) {
132
+ throw takeFromExternrefTable0(ret[1]);
133
+ }
134
+ return ZstdCompressStream.__wrap(ret[0]);
135
+ }
119
136
  }
120
137
  if (Symbol.dispose) ZstdCompressStream.prototype[Symbol.dispose] = ZstdCompressStream.prototype.free;
121
138
 
@@ -227,9 +244,124 @@ export class ZstdDecompressStream {
227
244
  }
228
245
  return ZstdDecompressStream.__wrap(ret[0]);
229
246
  }
247
+ /**
248
+ * Open a streaming decompressor against a [`ZstdDictionary`] prepared
249
+ * once: per-stream setup is a reference-count bump, no dictionary
250
+ * re-parse. Unlike [`Self::with_dictionary`] this also decodes frames
251
+ * whose headers omit the dictionary ID (raw-content dictionaries).
252
+ * @param {ZstdDictionary} dict
253
+ * @param {ContentChecksum | null} [checksum]
254
+ * @returns {ZstdDecompressStream}
255
+ */
256
+ static withPreparedDictionary(dict, checksum) {
257
+ _assertClass(dict, ZstdDictionary);
258
+ const ret = wasm.zstddecompressstream_withPreparedDictionary(dict.__wbg_ptr, isLikeNone(checksum) ? 3 : checksum);
259
+ return ZstdDecompressStream.__wrap(ret);
260
+ }
230
261
  }
231
262
  if (Symbol.dispose) ZstdDecompressStream.prototype[Symbol.dispose] = ZstdDecompressStream.prototype.free;
232
263
 
264
+ /**
265
+ * A dictionary prepared once for repeated use across compressions,
266
+ * decompressions, and streams — the wasm analogue of C's `ZSTD_CDict` +
267
+ * `ZSTD_DDict` pair behind one object.
268
+ *
269
+ * Construction parses the dictionary a single time (entropy decode tables +
270
+ * encoder conversion). The hot paths then avoid every per-call setup cost:
271
+ *
272
+ * * [`compress`](Self::compress) keeps a cached frame compressor whose
273
+ * dictionary-primed match-finder snapshot is reused across calls — the
274
+ * dominant per-frame cost for small payloads;
275
+ * * [`decompress`](Self::decompress) reuses one decoder workspace;
276
+ * * the stream constructors seed from the prepared tables (a table copy on
277
+ * the encode side, a reference-count bump on the decode side) instead of
278
+ * re-parsing the blob per stream.
279
+ *
280
+ * Raw content (bytes without the `0xEC30A437` dictionary magic) is accepted
281
+ * like upstream's auto mode: such dictionaries have ID 0 and produced frames
282
+ * carry no dictionary ID.
283
+ */
284
+ export class ZstdDictionary {
285
+ __destroy_into_raw() {
286
+ const ptr = this.__wbg_ptr;
287
+ this.__wbg_ptr = 0;
288
+ ZstdDictionaryFinalization.unregister(this);
289
+ return ptr;
290
+ }
291
+ free() {
292
+ const ptr = this.__destroy_into_raw();
293
+ wasm.__wbg_zstddictionary_free(ptr, 0);
294
+ }
295
+ /**
296
+ * Compress `data` with this dictionary at `level` — the hot path for
297
+ * many small frames against one dictionary: the first call at a given
298
+ * level attaches the prepared tables and primes the match finder, and
299
+ * every following call reuses that primed snapshot.
300
+ *
301
+ * `checksum` is optional (default `false`).
302
+ * @param {Uint8Array} data
303
+ * @param {number} level
304
+ * @param {boolean | null} [checksum]
305
+ * @returns {Uint8Array}
306
+ */
307
+ compress(data, level, checksum) {
308
+ const ptr0 = passArray8ToWasm0(data, wasm.__wbindgen_malloc);
309
+ const len0 = WASM_VECTOR_LEN;
310
+ const ret = wasm.zstddictionary_compress(this.__wbg_ptr, ptr0, len0, level, isLikeNone(checksum) ? 0xFFFFFF : checksum ? 1 : 0);
311
+ if (ret[3]) {
312
+ throw takeFromExternrefTable0(ret[2]);
313
+ }
314
+ var v2 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
315
+ wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
316
+ return v2;
317
+ }
318
+ /**
319
+ * Decompress a frame produced with this dictionary, reusing the
320
+ * prepared tables and one decoder workspace across calls. `checksum`
321
+ * behaves as in the module-level `decompress`.
322
+ * @param {Uint8Array} data
323
+ * @param {ContentChecksum | null} [checksum]
324
+ * @returns {Uint8Array}
325
+ */
326
+ decompress(data, checksum) {
327
+ const ptr0 = passArray8ToWasm0(data, wasm.__wbindgen_malloc);
328
+ const len0 = WASM_VECTOR_LEN;
329
+ const ret = wasm.zstddictionary_decompress(this.__wbg_ptr, ptr0, len0, isLikeNone(checksum) ? 3 : checksum);
330
+ if (ret[3]) {
331
+ throw takeFromExternrefTable0(ret[2]);
332
+ }
333
+ var v2 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
334
+ wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
335
+ return v2;
336
+ }
337
+ /**
338
+ * The dictionary ID (0 for raw content).
339
+ * @returns {number}
340
+ */
341
+ get id() {
342
+ const ret = wasm.zstddictionary_id(this.__wbg_ptr);
343
+ return ret >>> 0;
344
+ }
345
+ /**
346
+ * Parse `dict` once for repeated use. Magic-prefixed blobs (e.g. from
347
+ * `zstd --train`) parse as full dictionaries; anything else is raw
348
+ * content. Throws if a magic-prefixed blob is corrupt.
349
+ * @param {Uint8Array} dict
350
+ */
351
+ constructor(dict) {
352
+ const ptr0 = passArray8ToWasm0(dict, wasm.__wbindgen_malloc);
353
+ const len0 = WASM_VECTOR_LEN;
354
+ const ret = wasm.zstddictionary_new(ptr0, len0);
355
+ if (ret[2]) {
356
+ throw takeFromExternrefTable0(ret[1]);
357
+ }
358
+ this.__wbg_ptr = ret[0];
359
+ ZstdDictionaryFinalization.register(this, this.__wbg_ptr, this);
360
+ return this;
361
+ }
362
+ }
363
+ if (Symbol.dispose) ZstdDictionary.prototype[Symbol.dispose] = ZstdDictionary.prototype.free;
364
+
233
365
  /**
234
366
  * Compress `data` into a standard Zstandard frame at compression `level`.
235
367
  *
@@ -334,11 +466,11 @@ export function decompressUsingDict(data, dict, checksum) {
334
466
  function __wbg_get_imports() {
335
467
  const import0 = {
336
468
  __proto__: null,
337
- __wbg_Error_9dc85fe1bc224456: function(arg0, arg1) {
469
+ __wbg_Error_fdd633d4bb5dd76a: function(arg0, arg1) {
338
470
  const ret = Error(getStringFromWasm0(arg0, arg1));
339
471
  return ret;
340
472
  },
341
- __wbg___wbindgen_throw_bbadd78c1bac3a77: function(arg0, arg1) {
473
+ __wbg___wbindgen_throw_ea4887a5f8f9a9db: function(arg0, arg1) {
342
474
  throw new Error(getStringFromWasm0(arg0, arg1));
343
475
  },
344
476
  __wbindgen_init_externref_table: function() {
@@ -363,6 +495,15 @@ const ZstdCompressStreamFinalization = (typeof FinalizationRegistry === 'undefin
363
495
  const ZstdDecompressStreamFinalization = (typeof FinalizationRegistry === 'undefined')
364
496
  ? { register: () => {}, unregister: () => {} }
365
497
  : new FinalizationRegistry(ptr => wasm.__wbg_zstddecompressstream_free(ptr, 1));
498
+ const ZstdDictionaryFinalization = (typeof FinalizationRegistry === 'undefined')
499
+ ? { register: () => {}, unregister: () => {} }
500
+ : new FinalizationRegistry(ptr => wasm.__wbg_zstddictionary_free(ptr, 1));
501
+
502
+ function _assertClass(instance, klass) {
503
+ if (!(instance instanceof klass)) {
504
+ throw new Error(`expected instance of ${klass.name}`);
505
+ }
506
+ }
366
507
 
367
508
  function getArrayU8FromWasm0(ptr, len) {
368
509
  ptr = ptr >>> 0;
Binary file
@@ -3,6 +3,7 @@
3
3
  export const memory: WebAssembly.Memory;
4
4
  export const __wbg_zstdcompressstream_free: (a: number, b: number) => void;
5
5
  export const __wbg_zstddecompressstream_free: (a: number, b: number) => void;
6
+ export const __wbg_zstddictionary_free: (a: number, b: number) => void;
6
7
  export const compress: (a: number, b: number, c: number, d: number) => [number, number];
7
8
  export const compressUsingDict: (a: number, b: number, c: number, d: number, e: number, f: number) => [number, number, number, number];
8
9
  export const decompress: (a: number, b: number, c: number) => [number, number, number, number];
@@ -11,12 +12,18 @@ export const zstdcompressstream_finish: (a: number) => [number, number, number,
11
12
  export const zstdcompressstream_new: (a: number, b: number) => number;
12
13
  export const zstdcompressstream_push: (a: number, b: number, c: number) => [number, number, number, number];
13
14
  export const zstdcompressstream_withDictionary: (a: number, b: number, c: number, d: number) => [number, number, number];
15
+ export const zstdcompressstream_withPreparedDictionary: (a: number, b: number, c: number) => [number, number, number];
14
16
  export const zstddecompressstream_calculatedChecksum: (a: number) => number;
15
17
  export const zstddecompressstream_finish: (a: number) => [number, number, number, number];
16
18
  export const zstddecompressstream_new: (a: number) => number;
17
19
  export const zstddecompressstream_push: (a: number, b: number, c: number) => [number, number, number, number];
18
20
  export const zstddecompressstream_storedChecksum: (a: number) => number;
19
21
  export const zstddecompressstream_withDictionary: (a: number, b: number, c: number) => [number, number, number];
22
+ export const zstddecompressstream_withPreparedDictionary: (a: number, b: number) => number;
23
+ export const zstddictionary_compress: (a: number, b: number, c: number, d: number, e: number) => [number, number, number, number];
24
+ export const zstddictionary_decompress: (a: number, b: number, c: number, d: number) => [number, number, number, number];
25
+ export const zstddictionary_id: (a: number) => number;
26
+ export const zstddictionary_new: (a: number, b: number) => [number, number, number];
20
27
  export const __wbindgen_externrefs: WebAssembly.Table;
21
28
  export const __wbindgen_malloc: (a: number, b: number) => number;
22
29
  export const __wbindgen_free: (a: number, b: number, c: number) => void;