@small-ltsc/sdk 0.2.15 → 0.2.17

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.
@@ -0,0 +1,1111 @@
1
+ /**
2
+ * Configuration for compression.
3
+ */
4
+ export class CompressionConfig {
5
+ __destroy_into_raw() {
6
+ const ptr = this.__wbg_ptr;
7
+ this.__wbg_ptr = 0;
8
+ CompressionConfigFinalization.unregister(this);
9
+ return ptr;
10
+ }
11
+ free() {
12
+ const ptr = this.__destroy_into_raw();
13
+ wasm.__wbg_compressionconfig_free(ptr, 0);
14
+ }
15
+ /**
16
+ * @returns {string}
17
+ */
18
+ get meta_token_prefix() {
19
+ let deferred1_0;
20
+ let deferred1_1;
21
+ try {
22
+ const ret = wasm.compressionconfig_meta_token_prefix(this.__wbg_ptr);
23
+ deferred1_0 = ret[0];
24
+ deferred1_1 = ret[1];
25
+ return getStringFromWasm0(ret[0], ret[1]);
26
+ } finally {
27
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
28
+ }
29
+ }
30
+ /**
31
+ * @returns {string}
32
+ */
33
+ get meta_token_suffix() {
34
+ let deferred1_0;
35
+ let deferred1_1;
36
+ try {
37
+ const ret = wasm.compressionconfig_meta_token_suffix(this.__wbg_ptr);
38
+ deferred1_0 = ret[0];
39
+ deferred1_1 = ret[1];
40
+ return getStringFromWasm0(ret[0], ret[1]);
41
+ } finally {
42
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
43
+ }
44
+ }
45
+ constructor() {
46
+ const ret = wasm.compressionconfig_new();
47
+ this.__wbg_ptr = ret >>> 0;
48
+ CompressionConfigFinalization.register(this, this.__wbg_ptr, this);
49
+ return this;
50
+ }
51
+ /**
52
+ * @returns {string}
53
+ */
54
+ get selection_mode() {
55
+ let deferred1_0;
56
+ let deferred1_1;
57
+ try {
58
+ const ret = wasm.compressionconfig_selection_mode(this.__wbg_ptr);
59
+ deferred1_0 = ret[0];
60
+ deferred1_1 = ret[1];
61
+ return getStringFromWasm0(ret[0], ret[1]);
62
+ } finally {
63
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
64
+ }
65
+ }
66
+ /**
67
+ * @param {string} prefix
68
+ */
69
+ set meta_token_prefix(prefix) {
70
+ const ptr0 = passStringToWasm0(prefix, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
71
+ const len0 = WASM_VECTOR_LEN;
72
+ wasm.compressionconfig_set_meta_token_prefix(this.__wbg_ptr, ptr0, len0);
73
+ }
74
+ /**
75
+ * @param {string} suffix
76
+ */
77
+ set meta_token_suffix(suffix) {
78
+ const ptr0 = passStringToWasm0(suffix, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
79
+ const len0 = WASM_VECTOR_LEN;
80
+ wasm.compressionconfig_set_meta_token_suffix(this.__wbg_ptr, ptr0, len0);
81
+ }
82
+ /**
83
+ * @param {string} mode
84
+ */
85
+ set selection_mode(mode) {
86
+ const ptr0 = passStringToWasm0(mode, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
87
+ const len0 = WASM_VECTOR_LEN;
88
+ wasm.compressionconfig_set_selection_mode(this.__wbg_ptr, ptr0, len0);
89
+ }
90
+ /**
91
+ * Beam width for beam search
92
+ * @returns {number}
93
+ */
94
+ get beam_width() {
95
+ const ret = wasm.__wbg_get_compressionconfig_beam_width(this.__wbg_ptr);
96
+ return ret >>> 0;
97
+ }
98
+ /**
99
+ * Dictionary end delimiter token ID
100
+ * @returns {number}
101
+ */
102
+ get dict_end_token() {
103
+ const ret = wasm.__wbg_get_compressionconfig_dict_end_token(this.__wbg_ptr);
104
+ return ret >>> 0;
105
+ }
106
+ /**
107
+ * Whether to include length tokens in dictionary
108
+ * @returns {boolean}
109
+ */
110
+ get dict_length_enabled() {
111
+ const ret = wasm.__wbg_get_compressionconfig_dict_length_enabled(this.__wbg_ptr);
112
+ return ret !== 0;
113
+ }
114
+ /**
115
+ * Dictionary start delimiter token ID
116
+ * @returns {number}
117
+ */
118
+ get dict_start_token() {
119
+ const ret = wasm.__wbg_get_compressionconfig_dict_start_token(this.__wbg_ptr);
120
+ return ret >>> 0;
121
+ }
122
+ /**
123
+ * Enable hierarchical compression
124
+ * @returns {boolean}
125
+ */
126
+ get hierarchical_enabled() {
127
+ const ret = wasm.__wbg_get_compressionconfig_hierarchical_enabled(this.__wbg_ptr);
128
+ return ret !== 0;
129
+ }
130
+ /**
131
+ * Maximum hierarchical compression depth
132
+ * @returns {number}
133
+ */
134
+ get hierarchical_max_depth() {
135
+ const ret = wasm.__wbg_get_compressionconfig_hierarchical_max_depth(this.__wbg_ptr);
136
+ return ret >>> 0;
137
+ }
138
+ /**
139
+ * Maximum pattern length to consider
140
+ * @returns {number}
141
+ */
142
+ get max_subsequence_length() {
143
+ const ret = wasm.__wbg_get_compressionconfig_max_subsequence_length(this.__wbg_ptr);
144
+ return ret >>> 0;
145
+ }
146
+ /**
147
+ * Size of meta-token pool
148
+ * @returns {number}
149
+ */
150
+ get meta_token_pool_size() {
151
+ const ret = wasm.__wbg_get_compressionconfig_meta_token_pool_size(this.__wbg_ptr);
152
+ return ret >>> 0;
153
+ }
154
+ /**
155
+ * Minimum pattern length to consider
156
+ * @returns {number}
157
+ */
158
+ get min_subsequence_length() {
159
+ const ret = wasm.__wbg_get_compressionconfig_min_subsequence_length(this.__wbg_ptr);
160
+ return ret >>> 0;
161
+ }
162
+ /**
163
+ * Enable round-trip verification
164
+ * @returns {boolean}
165
+ */
166
+ get verify() {
167
+ const ret = wasm.__wbg_get_compressionconfig_verify(this.__wbg_ptr);
168
+ return ret !== 0;
169
+ }
170
+ /**
171
+ * Beam width for beam search
172
+ * @param {number} arg0
173
+ */
174
+ set beam_width(arg0) {
175
+ wasm.__wbg_set_compressionconfig_beam_width(this.__wbg_ptr, arg0);
176
+ }
177
+ /**
178
+ * Dictionary end delimiter token ID
179
+ * @param {number} arg0
180
+ */
181
+ set dict_end_token(arg0) {
182
+ wasm.__wbg_set_compressionconfig_dict_end_token(this.__wbg_ptr, arg0);
183
+ }
184
+ /**
185
+ * Whether to include length tokens in dictionary
186
+ * @param {boolean} arg0
187
+ */
188
+ set dict_length_enabled(arg0) {
189
+ wasm.__wbg_set_compressionconfig_dict_length_enabled(this.__wbg_ptr, arg0);
190
+ }
191
+ /**
192
+ * Dictionary start delimiter token ID
193
+ * @param {number} arg0
194
+ */
195
+ set dict_start_token(arg0) {
196
+ wasm.__wbg_set_compressionconfig_dict_start_token(this.__wbg_ptr, arg0);
197
+ }
198
+ /**
199
+ * Enable hierarchical compression
200
+ * @param {boolean} arg0
201
+ */
202
+ set hierarchical_enabled(arg0) {
203
+ wasm.__wbg_set_compressionconfig_hierarchical_enabled(this.__wbg_ptr, arg0);
204
+ }
205
+ /**
206
+ * Maximum hierarchical compression depth
207
+ * @param {number} arg0
208
+ */
209
+ set hierarchical_max_depth(arg0) {
210
+ wasm.__wbg_set_compressionconfig_hierarchical_max_depth(this.__wbg_ptr, arg0);
211
+ }
212
+ /**
213
+ * Maximum pattern length to consider
214
+ * @param {number} arg0
215
+ */
216
+ set max_subsequence_length(arg0) {
217
+ wasm.__wbg_set_compressionconfig_max_subsequence_length(this.__wbg_ptr, arg0);
218
+ }
219
+ /**
220
+ * Size of meta-token pool
221
+ * @param {number} arg0
222
+ */
223
+ set meta_token_pool_size(arg0) {
224
+ wasm.__wbg_set_compressionconfig_meta_token_pool_size(this.__wbg_ptr, arg0);
225
+ }
226
+ /**
227
+ * Minimum pattern length to consider
228
+ * @param {number} arg0
229
+ */
230
+ set min_subsequence_length(arg0) {
231
+ wasm.__wbg_set_compressionconfig_min_subsequence_length(this.__wbg_ptr, arg0);
232
+ }
233
+ /**
234
+ * Enable round-trip verification
235
+ * @param {boolean} arg0
236
+ */
237
+ set verify(arg0) {
238
+ wasm.__wbg_set_compressionconfig_verify(this.__wbg_ptr, arg0);
239
+ }
240
+ }
241
+ if (Symbol.dispose) CompressionConfig.prototype[Symbol.dispose] = CompressionConfig.prototype.free;
242
+
243
+ /**
244
+ * Metrics from a compression operation.
245
+ */
246
+ export class CompressionMetrics {
247
+ __destroy_into_raw() {
248
+ const ptr = this.__wbg_ptr;
249
+ this.__wbg_ptr = 0;
250
+ CompressionMetricsFinalization.unregister(this);
251
+ return ptr;
252
+ }
253
+ free() {
254
+ const ptr = this.__destroy_into_raw();
255
+ wasm.__wbg_compressionmetrics_free(ptr, 0);
256
+ }
257
+ /**
258
+ * Number of candidates discovered
259
+ * @returns {number}
260
+ */
261
+ get candidates_discovered() {
262
+ const ret = wasm.__wbg_get_compressionmetrics_candidates_discovered(this.__wbg_ptr);
263
+ return ret >>> 0;
264
+ }
265
+ /**
266
+ * Number of candidates selected
267
+ * @returns {number}
268
+ */
269
+ get candidates_selected() {
270
+ const ret = wasm.__wbg_get_compressionconfig_max_subsequence_length(this.__wbg_ptr);
271
+ return ret >>> 0;
272
+ }
273
+ /**
274
+ * Time spent in pattern discovery (ms)
275
+ * @returns {number}
276
+ */
277
+ get discovery_time_ms() {
278
+ const ret = wasm.__wbg_get_compressionmetrics_discovery_time_ms(this.__wbg_ptr);
279
+ return ret;
280
+ }
281
+ /**
282
+ * Peak memory usage (bytes, approximate)
283
+ * @returns {number}
284
+ */
285
+ get peak_memory_bytes() {
286
+ const ret = wasm.__wbg_get_compressionmetrics_peak_memory_bytes(this.__wbg_ptr);
287
+ return ret >>> 0;
288
+ }
289
+ /**
290
+ * Time spent in selection (ms)
291
+ * @returns {number}
292
+ */
293
+ get selection_time_ms() {
294
+ const ret = wasm.__wbg_get_compressionmetrics_selection_time_ms(this.__wbg_ptr);
295
+ return ret;
296
+ }
297
+ /**
298
+ * Time spent in serialization (ms)
299
+ * @returns {number}
300
+ */
301
+ get serialization_time_ms() {
302
+ const ret = wasm.__wbg_get_compressionmetrics_serialization_time_ms(this.__wbg_ptr);
303
+ return ret;
304
+ }
305
+ /**
306
+ * Total compression time (ms)
307
+ * @returns {number}
308
+ */
309
+ get total_time_ms() {
310
+ const ret = wasm.__wbg_get_compressionmetrics_total_time_ms(this.__wbg_ptr);
311
+ return ret;
312
+ }
313
+ /**
314
+ * Number of candidates discovered
315
+ * @param {number} arg0
316
+ */
317
+ set candidates_discovered(arg0) {
318
+ wasm.__wbg_set_compressionmetrics_candidates_discovered(this.__wbg_ptr, arg0);
319
+ }
320
+ /**
321
+ * Number of candidates selected
322
+ * @param {number} arg0
323
+ */
324
+ set candidates_selected(arg0) {
325
+ wasm.__wbg_set_compressionconfig_max_subsequence_length(this.__wbg_ptr, arg0);
326
+ }
327
+ /**
328
+ * Time spent in pattern discovery (ms)
329
+ * @param {number} arg0
330
+ */
331
+ set discovery_time_ms(arg0) {
332
+ wasm.__wbg_set_compressionmetrics_discovery_time_ms(this.__wbg_ptr, arg0);
333
+ }
334
+ /**
335
+ * Peak memory usage (bytes, approximate)
336
+ * @param {number} arg0
337
+ */
338
+ set peak_memory_bytes(arg0) {
339
+ wasm.__wbg_set_compressionmetrics_peak_memory_bytes(this.__wbg_ptr, arg0);
340
+ }
341
+ /**
342
+ * Time spent in selection (ms)
343
+ * @param {number} arg0
344
+ */
345
+ set selection_time_ms(arg0) {
346
+ wasm.__wbg_set_compressionmetrics_selection_time_ms(this.__wbg_ptr, arg0);
347
+ }
348
+ /**
349
+ * Time spent in serialization (ms)
350
+ * @param {number} arg0
351
+ */
352
+ set serialization_time_ms(arg0) {
353
+ wasm.__wbg_set_compressionmetrics_serialization_time_ms(this.__wbg_ptr, arg0);
354
+ }
355
+ /**
356
+ * Total compression time (ms)
357
+ * @param {number} arg0
358
+ */
359
+ set total_time_ms(arg0) {
360
+ wasm.__wbg_set_compressionmetrics_total_time_ms(this.__wbg_ptr, arg0);
361
+ }
362
+ }
363
+ if (Symbol.dispose) CompressionMetrics.prototype[Symbol.dispose] = CompressionMetrics.prototype.free;
364
+
365
+ /**
366
+ * Result of compression operation.
367
+ */
368
+ export class CompressionResult {
369
+ static __wrap(ptr) {
370
+ ptr = ptr >>> 0;
371
+ const obj = Object.create(CompressionResult.prototype);
372
+ obj.__wbg_ptr = ptr;
373
+ CompressionResultFinalization.register(obj, obj.__wbg_ptr, obj);
374
+ return obj;
375
+ }
376
+ __destroy_into_raw() {
377
+ const ptr = this.__wbg_ptr;
378
+ this.__wbg_ptr = 0;
379
+ CompressionResultFinalization.unregister(this);
380
+ return ptr;
381
+ }
382
+ free() {
383
+ const ptr = this.__destroy_into_raw();
384
+ wasm.__wbg_compressionresult_free(ptr, 0);
385
+ }
386
+ /**
387
+ * Get the compression ratio (compressed/original).
388
+ * @returns {number}
389
+ */
390
+ get compression_ratio() {
391
+ const ret = wasm.compressionresult_compression_ratio(this.__wbg_ptr);
392
+ return ret;
393
+ }
394
+ /**
395
+ * Get the body tokens as a JS array.
396
+ * @returns {Uint32Array}
397
+ */
398
+ getBodyTokens() {
399
+ const ret = wasm.compressionresult_getBodyTokens(this.__wbg_ptr);
400
+ var v1 = getArrayU32FromWasm0(ret[0], ret[1]).slice();
401
+ wasm.__wbindgen_free(ret[0], ret[1] * 4, 4);
402
+ return v1;
403
+ }
404
+ /**
405
+ * Get the dictionary tokens as a JS array.
406
+ * @returns {Uint32Array}
407
+ */
408
+ getDictionaryTokens() {
409
+ const ret = wasm.compressionresult_getDictionaryTokens(this.__wbg_ptr);
410
+ var v1 = getArrayU32FromWasm0(ret[0], ret[1]).slice();
411
+ wasm.__wbindgen_free(ret[0], ret[1] * 4, 4);
412
+ return v1;
413
+ }
414
+ /**
415
+ * Get the original tokens as a JS array.
416
+ * @returns {Uint32Array}
417
+ */
418
+ getOriginalTokens() {
419
+ const ret = wasm.compressionresult_getOriginalTokens(this.__wbg_ptr);
420
+ var v1 = getArrayU32FromWasm0(ret[0], ret[1]).slice();
421
+ wasm.__wbindgen_free(ret[0], ret[1] * 4, 4);
422
+ return v1;
423
+ }
424
+ /**
425
+ * Get the serialized tokens as a JS array.
426
+ * @returns {Uint32Array}
427
+ */
428
+ getSerializedTokens() {
429
+ const ret = wasm.compressionresult_getSerializedTokens(this.__wbg_ptr);
430
+ var v1 = getArrayU32FromWasm0(ret[0], ret[1]).slice();
431
+ wasm.__wbindgen_free(ret[0], ret[1] * 4, 4);
432
+ return v1;
433
+ }
434
+ /**
435
+ * Get the static dictionary ID if used.
436
+ * @returns {string | undefined}
437
+ */
438
+ getStaticDictionaryId() {
439
+ const ret = wasm.compressionresult_getStaticDictionaryId(this.__wbg_ptr);
440
+ let v1;
441
+ if (ret[0] !== 0) {
442
+ v1 = getStringFromWasm0(ret[0], ret[1]).slice();
443
+ wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
444
+ }
445
+ return v1;
446
+ }
447
+ /**
448
+ * Get tokens saved by compression.
449
+ * @returns {bigint}
450
+ */
451
+ get tokens_saved() {
452
+ const ret = wasm.compressionresult_tokens_saved(this.__wbg_ptr);
453
+ return ret;
454
+ }
455
+ /**
456
+ * Compressed sequence length
457
+ * @returns {number}
458
+ */
459
+ get compressed_length() {
460
+ const ret = wasm.__wbg_get_compressionconfig_max_subsequence_length(this.__wbg_ptr);
461
+ return ret >>> 0;
462
+ }
463
+ /**
464
+ * Original sequence length
465
+ * @returns {number}
466
+ */
467
+ get original_length() {
468
+ const ret = wasm.__wbg_get_compressionmetrics_candidates_discovered(this.__wbg_ptr);
469
+ return ret >>> 0;
470
+ }
471
+ /**
472
+ * Compressed sequence length
473
+ * @param {number} arg0
474
+ */
475
+ set compressed_length(arg0) {
476
+ wasm.__wbg_set_compressionconfig_max_subsequence_length(this.__wbg_ptr, arg0);
477
+ }
478
+ /**
479
+ * Original sequence length
480
+ * @param {number} arg0
481
+ */
482
+ set original_length(arg0) {
483
+ wasm.__wbg_set_compressionmetrics_candidates_discovered(this.__wbg_ptr, arg0);
484
+ }
485
+ }
486
+ if (Symbol.dispose) CompressionResult.prototype[Symbol.dispose] = CompressionResult.prototype.free;
487
+
488
+ /**
489
+ * Streaming compressor for large inputs.
490
+ */
491
+ export class StreamingCompressor {
492
+ __destroy_into_raw() {
493
+ const ptr = this.__wbg_ptr;
494
+ this.__wbg_ptr = 0;
495
+ StreamingCompressorFinalization.unregister(this);
496
+ return ptr;
497
+ }
498
+ free() {
499
+ const ptr = this.__destroy_into_raw();
500
+ wasm.__wbg_streamingcompressor_free(ptr, 0);
501
+ }
502
+ /**
503
+ * Add a chunk of tokens.
504
+ * @param {Uint32Array} tokens
505
+ */
506
+ add_chunk(tokens) {
507
+ const ptr0 = passArray32ToWasm0(tokens, wasm.__wbindgen_malloc);
508
+ const len0 = WASM_VECTOR_LEN;
509
+ wasm.streamingcompressor_add_chunk(this.__wbg_ptr, ptr0, len0);
510
+ }
511
+ /**
512
+ * Finish streaming and produce compressed result.
513
+ * @returns {CompressionResult}
514
+ */
515
+ finish() {
516
+ const ptr = this.__destroy_into_raw();
517
+ const ret = wasm.streamingcompressor_finish(ptr);
518
+ if (ret[2]) {
519
+ throw takeFromExternrefTable0(ret[1]);
520
+ }
521
+ return CompressionResult.__wrap(ret[0]);
522
+ }
523
+ /**
524
+ * Get approximate memory usage.
525
+ * @returns {number}
526
+ */
527
+ memory_usage() {
528
+ const ret = wasm.streamingcompressor_memory_usage(this.__wbg_ptr);
529
+ return ret >>> 0;
530
+ }
531
+ /**
532
+ * Create a new streaming compressor.
533
+ * @param {any} config
534
+ */
535
+ constructor(config) {
536
+ const ret = wasm.streamingcompressor_new(config);
537
+ if (ret[2]) {
538
+ throw takeFromExternrefTable0(ret[1]);
539
+ }
540
+ this.__wbg_ptr = ret[0] >>> 0;
541
+ StreamingCompressorFinalization.register(this, this.__wbg_ptr, this);
542
+ return this;
543
+ }
544
+ }
545
+ if (Symbol.dispose) StreamingCompressor.prototype[Symbol.dispose] = StreamingCompressor.prototype.free;
546
+
547
+ /**
548
+ * WASM-specific configuration for memory and performance tuning.
549
+ */
550
+ export class WasmConfig {
551
+ __destroy_into_raw() {
552
+ const ptr = this.__wbg_ptr;
553
+ this.__wbg_ptr = 0;
554
+ WasmConfigFinalization.unregister(this);
555
+ return ptr;
556
+ }
557
+ free() {
558
+ const ptr = this.__destroy_into_raw();
559
+ wasm.__wbg_wasmconfig_free(ptr, 0);
560
+ }
561
+ /**
562
+ * Chunk size for streaming processing (default: 32768)
563
+ * @returns {number}
564
+ */
565
+ get chunk_size() {
566
+ const ret = wasm.__wbg_get_wasmconfig_chunk_size(this.__wbg_ptr);
567
+ return ret >>> 0;
568
+ }
569
+ /**
570
+ * Maximum memory usage in MB (default: 256)
571
+ * @returns {number}
572
+ */
573
+ get max_memory_mb() {
574
+ const ret = wasm.__wbg_get_wasmconfig_max_memory_mb(this.__wbg_ptr);
575
+ return ret >>> 0;
576
+ }
577
+ /**
578
+ * Enable streaming for inputs above threshold (default: 50000)
579
+ * @returns {number}
580
+ */
581
+ get streaming_threshold() {
582
+ const ret = wasm.__wbg_get_wasmconfig_streaming_threshold(this.__wbg_ptr);
583
+ return ret >>> 0;
584
+ }
585
+ /**
586
+ * Chunk size for streaming processing (default: 32768)
587
+ * @param {number} arg0
588
+ */
589
+ set chunk_size(arg0) {
590
+ wasm.__wbg_set_wasmconfig_chunk_size(this.__wbg_ptr, arg0);
591
+ }
592
+ /**
593
+ * Maximum memory usage in MB (default: 256)
594
+ * @param {number} arg0
595
+ */
596
+ set max_memory_mb(arg0) {
597
+ wasm.__wbg_set_wasmconfig_max_memory_mb(this.__wbg_ptr, arg0);
598
+ }
599
+ /**
600
+ * Enable streaming for inputs above threshold (default: 50000)
601
+ * @param {number} arg0
602
+ */
603
+ set streaming_threshold(arg0) {
604
+ wasm.__wbg_set_wasmconfig_streaming_threshold(this.__wbg_ptr, arg0);
605
+ }
606
+ constructor() {
607
+ const ret = wasm.wasmconfig_new();
608
+ this.__wbg_ptr = ret >>> 0;
609
+ WasmConfigFinalization.register(this, this.__wbg_ptr, this);
610
+ return this;
611
+ }
612
+ }
613
+ if (Symbol.dispose) WasmConfig.prototype[Symbol.dispose] = WasmConfig.prototype.free;
614
+
615
+ /**
616
+ * Compress a token sequence.
617
+ *
618
+ * # Arguments
619
+ *
620
+ * * `tokens` - The token sequence to compress (Uint32Array from JS)
621
+ * * `config` - Optional configuration (JsValue representing JsCompressionConfig)
622
+ *
623
+ * # Returns
624
+ *
625
+ * A CompressionResult containing the compressed tokens and metadata.
626
+ * @param {Uint32Array} tokens
627
+ * @param {any} config
628
+ * @returns {CompressionResult}
629
+ */
630
+ export function compress(tokens, config) {
631
+ const ptr0 = passArray32ToWasm0(tokens, wasm.__wbindgen_malloc);
632
+ const len0 = WASM_VECTOR_LEN;
633
+ const ret = wasm.compress(ptr0, len0, config);
634
+ if (ret[2]) {
635
+ throw takeFromExternrefTable0(ret[1]);
636
+ }
637
+ return CompressionResult.__wrap(ret[0]);
638
+ }
639
+
640
+ /**
641
+ * Decompress a compressed token sequence.
642
+ *
643
+ * # Arguments
644
+ *
645
+ * * `tokens` - The compressed token sequence
646
+ * * `config` - Optional configuration
647
+ *
648
+ * # Returns
649
+ *
650
+ * The original token sequence.
651
+ * @param {Uint32Array} tokens
652
+ * @param {any} config
653
+ * @returns {Uint32Array}
654
+ */
655
+ export function decompress(tokens, config) {
656
+ const ptr0 = passArray32ToWasm0(tokens, wasm.__wbindgen_malloc);
657
+ const len0 = WASM_VECTOR_LEN;
658
+ const ret = wasm.decompress(ptr0, len0, config);
659
+ if (ret[3]) {
660
+ throw takeFromExternrefTable0(ret[2]);
661
+ }
662
+ var v2 = getArrayU32FromWasm0(ret[0], ret[1]).slice();
663
+ wasm.__wbindgen_free(ret[0], ret[1] * 4, 4);
664
+ return v2;
665
+ }
666
+
667
+ /**
668
+ * Discover patterns without compressing.
669
+ *
670
+ * Useful for analysis and building static dictionaries.
671
+ * @param {Uint32Array} tokens
672
+ * @param {number} min_length
673
+ * @param {number} max_length
674
+ * @returns {any}
675
+ */
676
+ export function discover_patterns(tokens, min_length, max_length) {
677
+ const ptr0 = passArray32ToWasm0(tokens, wasm.__wbindgen_malloc);
678
+ const len0 = WASM_VECTOR_LEN;
679
+ const ret = wasm.discover_patterns(ptr0, len0, min_length, max_length);
680
+ if (ret[2]) {
681
+ throw takeFromExternrefTable0(ret[1]);
682
+ }
683
+ return takeFromExternrefTable0(ret[0]);
684
+ }
685
+
686
+ /**
687
+ * Initialize panic hook for better error messages in WASM.
688
+ */
689
+ export function init() {
690
+ wasm.init();
691
+ }
692
+
693
+ /**
694
+ * Get version information.
695
+ * @returns {string}
696
+ */
697
+ export function version() {
698
+ let deferred1_0;
699
+ let deferred1_1;
700
+ try {
701
+ const ret = wasm.version();
702
+ deferred1_0 = ret[0];
703
+ deferred1_1 = ret[1];
704
+ return getStringFromWasm0(ret[0], ret[1]);
705
+ } finally {
706
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
707
+ }
708
+ }
709
+ export function __wbg_Error_8c4e43fe74559d73(arg0, arg1) {
710
+ const ret = Error(getStringFromWasm0(arg0, arg1));
711
+ return ret;
712
+ }
713
+ export function __wbg_Number_04624de7d0e8332d(arg0) {
714
+ const ret = Number(arg0);
715
+ return ret;
716
+ }
717
+ export function __wbg_String_8f0eb39a4a4c2f66(arg0, arg1) {
718
+ const ret = String(arg1);
719
+ const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
720
+ const len1 = WASM_VECTOR_LEN;
721
+ getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
722
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
723
+ }
724
+ export function __wbg___wbindgen_bigint_get_as_i64_8fcf4ce7f1ca72a2(arg0, arg1) {
725
+ const v = arg1;
726
+ const ret = typeof(v) === 'bigint' ? v : undefined;
727
+ getDataViewMemory0().setBigInt64(arg0 + 8 * 1, isLikeNone(ret) ? BigInt(0) : ret, true);
728
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, !isLikeNone(ret), true);
729
+ }
730
+ export function __wbg___wbindgen_boolean_get_bbbb1c18aa2f5e25(arg0) {
731
+ const v = arg0;
732
+ const ret = typeof(v) === 'boolean' ? v : undefined;
733
+ return isLikeNone(ret) ? 0xFFFFFF : ret ? 1 : 0;
734
+ }
735
+ export function __wbg___wbindgen_debug_string_0bc8482c6e3508ae(arg0, arg1) {
736
+ const ret = debugString(arg1);
737
+ const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
738
+ const len1 = WASM_VECTOR_LEN;
739
+ getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
740
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
741
+ }
742
+ export function __wbg___wbindgen_in_47fa6863be6f2f25(arg0, arg1) {
743
+ const ret = arg0 in arg1;
744
+ return ret;
745
+ }
746
+ export function __wbg___wbindgen_is_bigint_31b12575b56f32fc(arg0) {
747
+ const ret = typeof(arg0) === 'bigint';
748
+ return ret;
749
+ }
750
+ export function __wbg___wbindgen_is_null_ac34f5003991759a(arg0) {
751
+ const ret = arg0 === null;
752
+ return ret;
753
+ }
754
+ export function __wbg___wbindgen_is_object_5ae8e5880f2c1fbd(arg0) {
755
+ const val = arg0;
756
+ const ret = typeof(val) === 'object' && val !== null;
757
+ return ret;
758
+ }
759
+ export function __wbg___wbindgen_is_string_cd444516edc5b180(arg0) {
760
+ const ret = typeof(arg0) === 'string';
761
+ return ret;
762
+ }
763
+ export function __wbg___wbindgen_is_undefined_9e4d92534c42d778(arg0) {
764
+ const ret = arg0 === undefined;
765
+ return ret;
766
+ }
767
+ export function __wbg___wbindgen_jsval_eq_11888390b0186270(arg0, arg1) {
768
+ const ret = arg0 === arg1;
769
+ return ret;
770
+ }
771
+ export function __wbg___wbindgen_jsval_loose_eq_9dd77d8cd6671811(arg0, arg1) {
772
+ const ret = arg0 == arg1;
773
+ return ret;
774
+ }
775
+ export function __wbg___wbindgen_number_get_8ff4255516ccad3e(arg0, arg1) {
776
+ const obj = arg1;
777
+ const ret = typeof(obj) === 'number' ? obj : undefined;
778
+ getDataViewMemory0().setFloat64(arg0 + 8 * 1, isLikeNone(ret) ? 0 : ret, true);
779
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, !isLikeNone(ret), true);
780
+ }
781
+ export function __wbg___wbindgen_string_get_72fb696202c56729(arg0, arg1) {
782
+ const obj = arg1;
783
+ const ret = typeof(obj) === 'string' ? obj : undefined;
784
+ var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
785
+ var len1 = WASM_VECTOR_LEN;
786
+ getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
787
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
788
+ }
789
+ export function __wbg___wbindgen_throw_be289d5034ed271b(arg0, arg1) {
790
+ throw new Error(getStringFromWasm0(arg0, arg1));
791
+ }
792
+ export function __wbg_error_7534b8e9a36f1ab4(arg0, arg1) {
793
+ let deferred0_0;
794
+ let deferred0_1;
795
+ try {
796
+ deferred0_0 = arg0;
797
+ deferred0_1 = arg1;
798
+ console.error(getStringFromWasm0(arg0, arg1));
799
+ } finally {
800
+ wasm.__wbindgen_free(deferred0_0, deferred0_1, 1);
801
+ }
802
+ }
803
+ export function __wbg_get_with_ref_key_1dc361bd10053bfe(arg0, arg1) {
804
+ const ret = arg0[arg1];
805
+ return ret;
806
+ }
807
+ export function __wbg_instanceof_ArrayBuffer_c367199e2fa2aa04(arg0) {
808
+ let result;
809
+ try {
810
+ result = arg0 instanceof ArrayBuffer;
811
+ } catch (_) {
812
+ result = false;
813
+ }
814
+ const ret = result;
815
+ return ret;
816
+ }
817
+ export function __wbg_instanceof_Uint8Array_9b9075935c74707c(arg0) {
818
+ let result;
819
+ try {
820
+ result = arg0 instanceof Uint8Array;
821
+ } catch (_) {
822
+ result = false;
823
+ }
824
+ const ret = result;
825
+ return ret;
826
+ }
827
+ export function __wbg_isSafeInteger_bfbc7332a9768d2a(arg0) {
828
+ const ret = Number.isSafeInteger(arg0);
829
+ return ret;
830
+ }
831
+ export function __wbg_length_32ed9a279acd054c(arg0) {
832
+ const ret = arg0.length;
833
+ return ret;
834
+ }
835
+ export function __wbg_new_361308b2356cecd0() {
836
+ const ret = new Object();
837
+ return ret;
838
+ }
839
+ export function __wbg_new_3eb36ae241fe6f44() {
840
+ const ret = new Array();
841
+ return ret;
842
+ }
843
+ export function __wbg_new_8a6f238a6ece86ea() {
844
+ const ret = new Error();
845
+ return ret;
846
+ }
847
+ export function __wbg_new_dca287b076112a51() {
848
+ const ret = new Map();
849
+ return ret;
850
+ }
851
+ export function __wbg_new_dd2b680c8bf6ae29(arg0) {
852
+ const ret = new Uint8Array(arg0);
853
+ return ret;
854
+ }
855
+ export function __wbg_prototypesetcall_bdcdcc5842e4d77d(arg0, arg1, arg2) {
856
+ Uint8Array.prototype.set.call(getArrayU8FromWasm0(arg0, arg1), arg2);
857
+ }
858
+ export function __wbg_set_1eb0999cf5d27fc8(arg0, arg1, arg2) {
859
+ const ret = arg0.set(arg1, arg2);
860
+ return ret;
861
+ }
862
+ export function __wbg_set_3f1d0b984ed272ed(arg0, arg1, arg2) {
863
+ arg0[arg1] = arg2;
864
+ }
865
+ export function __wbg_set_f43e577aea94465b(arg0, arg1, arg2) {
866
+ arg0[arg1 >>> 0] = arg2;
867
+ }
868
+ export function __wbg_stack_0ed75d68575b0f3c(arg0, arg1) {
869
+ const ret = arg1.stack;
870
+ const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
871
+ const len1 = WASM_VECTOR_LEN;
872
+ getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
873
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
874
+ }
875
+ export function __wbindgen_cast_0000000000000001(arg0) {
876
+ // Cast intrinsic for `F64 -> Externref`.
877
+ const ret = arg0;
878
+ return ret;
879
+ }
880
+ export function __wbindgen_cast_0000000000000002(arg0) {
881
+ // Cast intrinsic for `I64 -> Externref`.
882
+ const ret = arg0;
883
+ return ret;
884
+ }
885
+ export function __wbindgen_cast_0000000000000003(arg0, arg1) {
886
+ // Cast intrinsic for `Ref(String) -> Externref`.
887
+ const ret = getStringFromWasm0(arg0, arg1);
888
+ return ret;
889
+ }
890
+ export function __wbindgen_cast_0000000000000004(arg0) {
891
+ // Cast intrinsic for `U64 -> Externref`.
892
+ const ret = BigInt.asUintN(64, arg0);
893
+ return ret;
894
+ }
895
+ export function __wbindgen_init_externref_table() {
896
+ const table = wasm.__wbindgen_externrefs;
897
+ const offset = table.grow(4);
898
+ table.set(0, undefined);
899
+ table.set(offset + 0, undefined);
900
+ table.set(offset + 1, null);
901
+ table.set(offset + 2, true);
902
+ table.set(offset + 3, false);
903
+ }
904
+ const CompressionConfigFinalization = (typeof FinalizationRegistry === 'undefined')
905
+ ? { register: () => {}, unregister: () => {} }
906
+ : new FinalizationRegistry(ptr => wasm.__wbg_compressionconfig_free(ptr >>> 0, 1));
907
+ const CompressionMetricsFinalization = (typeof FinalizationRegistry === 'undefined')
908
+ ? { register: () => {}, unregister: () => {} }
909
+ : new FinalizationRegistry(ptr => wasm.__wbg_compressionmetrics_free(ptr >>> 0, 1));
910
+ const CompressionResultFinalization = (typeof FinalizationRegistry === 'undefined')
911
+ ? { register: () => {}, unregister: () => {} }
912
+ : new FinalizationRegistry(ptr => wasm.__wbg_compressionresult_free(ptr >>> 0, 1));
913
+ const StreamingCompressorFinalization = (typeof FinalizationRegistry === 'undefined')
914
+ ? { register: () => {}, unregister: () => {} }
915
+ : new FinalizationRegistry(ptr => wasm.__wbg_streamingcompressor_free(ptr >>> 0, 1));
916
+ const WasmConfigFinalization = (typeof FinalizationRegistry === 'undefined')
917
+ ? { register: () => {}, unregister: () => {} }
918
+ : new FinalizationRegistry(ptr => wasm.__wbg_wasmconfig_free(ptr >>> 0, 1));
919
+
920
+ function debugString(val) {
921
+ // primitive types
922
+ const type = typeof val;
923
+ if (type == 'number' || type == 'boolean' || val == null) {
924
+ return `${val}`;
925
+ }
926
+ if (type == 'string') {
927
+ return `"${val}"`;
928
+ }
929
+ if (type == 'symbol') {
930
+ const description = val.description;
931
+ if (description == null) {
932
+ return 'Symbol';
933
+ } else {
934
+ return `Symbol(${description})`;
935
+ }
936
+ }
937
+ if (type == 'function') {
938
+ const name = val.name;
939
+ if (typeof name == 'string' && name.length > 0) {
940
+ return `Function(${name})`;
941
+ } else {
942
+ return 'Function';
943
+ }
944
+ }
945
+ // objects
946
+ if (Array.isArray(val)) {
947
+ const length = val.length;
948
+ let debug = '[';
949
+ if (length > 0) {
950
+ debug += debugString(val[0]);
951
+ }
952
+ for(let i = 1; i < length; i++) {
953
+ debug += ', ' + debugString(val[i]);
954
+ }
955
+ debug += ']';
956
+ return debug;
957
+ }
958
+ // Test for built-in
959
+ const builtInMatches = /\[object ([^\]]+)\]/.exec(toString.call(val));
960
+ let className;
961
+ if (builtInMatches && builtInMatches.length > 1) {
962
+ className = builtInMatches[1];
963
+ } else {
964
+ // Failed to match the standard '[object ClassName]'
965
+ return toString.call(val);
966
+ }
967
+ if (className == 'Object') {
968
+ // we're a user defined class or Object
969
+ // JSON.stringify avoids problems with cycles, and is generally much
970
+ // easier than looping through ownProperties of `val`.
971
+ try {
972
+ return 'Object(' + JSON.stringify(val) + ')';
973
+ } catch (_) {
974
+ return 'Object';
975
+ }
976
+ }
977
+ // errors
978
+ if (val instanceof Error) {
979
+ return `${val.name}: ${val.message}\n${val.stack}`;
980
+ }
981
+ // TODO we could test for more things here, like `Set`s and `Map`s.
982
+ return className;
983
+ }
984
+
985
+ function getArrayU32FromWasm0(ptr, len) {
986
+ ptr = ptr >>> 0;
987
+ return getUint32ArrayMemory0().subarray(ptr / 4, ptr / 4 + len);
988
+ }
989
+
990
+ function getArrayU8FromWasm0(ptr, len) {
991
+ ptr = ptr >>> 0;
992
+ return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
993
+ }
994
+
995
+ let cachedDataViewMemory0 = null;
996
+ function getDataViewMemory0() {
997
+ if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || (cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm.memory.buffer)) {
998
+ cachedDataViewMemory0 = new DataView(wasm.memory.buffer);
999
+ }
1000
+ return cachedDataViewMemory0;
1001
+ }
1002
+
1003
+ function getStringFromWasm0(ptr, len) {
1004
+ ptr = ptr >>> 0;
1005
+ return decodeText(ptr, len);
1006
+ }
1007
+
1008
+ let cachedUint32ArrayMemory0 = null;
1009
+ function getUint32ArrayMemory0() {
1010
+ if (cachedUint32ArrayMemory0 === null || cachedUint32ArrayMemory0.byteLength === 0) {
1011
+ cachedUint32ArrayMemory0 = new Uint32Array(wasm.memory.buffer);
1012
+ }
1013
+ return cachedUint32ArrayMemory0;
1014
+ }
1015
+
1016
+ let cachedUint8ArrayMemory0 = null;
1017
+ function getUint8ArrayMemory0() {
1018
+ if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
1019
+ cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
1020
+ }
1021
+ return cachedUint8ArrayMemory0;
1022
+ }
1023
+
1024
+ function isLikeNone(x) {
1025
+ return x === undefined || x === null;
1026
+ }
1027
+
1028
+ function passArray32ToWasm0(arg, malloc) {
1029
+ const ptr = malloc(arg.length * 4, 4) >>> 0;
1030
+ getUint32ArrayMemory0().set(arg, ptr / 4);
1031
+ WASM_VECTOR_LEN = arg.length;
1032
+ return ptr;
1033
+ }
1034
+
1035
+ function passStringToWasm0(arg, malloc, realloc) {
1036
+ if (realloc === undefined) {
1037
+ const buf = cachedTextEncoder.encode(arg);
1038
+ const ptr = malloc(buf.length, 1) >>> 0;
1039
+ getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);
1040
+ WASM_VECTOR_LEN = buf.length;
1041
+ return ptr;
1042
+ }
1043
+
1044
+ let len = arg.length;
1045
+ let ptr = malloc(len, 1) >>> 0;
1046
+
1047
+ const mem = getUint8ArrayMemory0();
1048
+
1049
+ let offset = 0;
1050
+
1051
+ for (; offset < len; offset++) {
1052
+ const code = arg.charCodeAt(offset);
1053
+ if (code > 0x7F) break;
1054
+ mem[ptr + offset] = code;
1055
+ }
1056
+ if (offset !== len) {
1057
+ if (offset !== 0) {
1058
+ arg = arg.slice(offset);
1059
+ }
1060
+ ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
1061
+ const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
1062
+ const ret = cachedTextEncoder.encodeInto(arg, view);
1063
+
1064
+ offset += ret.written;
1065
+ ptr = realloc(ptr, len, offset, 1) >>> 0;
1066
+ }
1067
+
1068
+ WASM_VECTOR_LEN = offset;
1069
+ return ptr;
1070
+ }
1071
+
1072
+ function takeFromExternrefTable0(idx) {
1073
+ const value = wasm.__wbindgen_externrefs.get(idx);
1074
+ wasm.__externref_table_dealloc(idx);
1075
+ return value;
1076
+ }
1077
+
1078
+ let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
1079
+ cachedTextDecoder.decode();
1080
+ const MAX_SAFARI_DECODE_BYTES = 2146435072;
1081
+ let numBytesDecoded = 0;
1082
+ function decodeText(ptr, len) {
1083
+ numBytesDecoded += len;
1084
+ if (numBytesDecoded >= MAX_SAFARI_DECODE_BYTES) {
1085
+ cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
1086
+ cachedTextDecoder.decode();
1087
+ numBytesDecoded = len;
1088
+ }
1089
+ return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
1090
+ }
1091
+
1092
+ const cachedTextEncoder = new TextEncoder();
1093
+
1094
+ if (!('encodeInto' in cachedTextEncoder)) {
1095
+ cachedTextEncoder.encodeInto = function (arg, view) {
1096
+ const buf = cachedTextEncoder.encode(arg);
1097
+ view.set(buf);
1098
+ return {
1099
+ read: arg.length,
1100
+ written: buf.length
1101
+ };
1102
+ };
1103
+ }
1104
+
1105
+ let WASM_VECTOR_LEN = 0;
1106
+
1107
+
1108
+ let wasm;
1109
+ export function __wbg_set_wasm(val) {
1110
+ wasm = val;
1111
+ }