@paddor/lz4rip 0.0.0-stage → 0.2.20
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +45 -2
- package/package.json +44 -4
- package/src/mod.d.ts +74 -0
- package/src/mod.js +167 -0
- package/src/pkg/lz4rip_wasm.d.ts +86 -0
- package/src/pkg/lz4rip_wasm.js +509 -0
- package/src/pkg/lz4rip_wasm_bg.wasm +0 -0
- package/src/pkg/lz4rip_wasm_bg.wasm.d.ts +24 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2020 Pascal Seitz
|
|
4
|
+
Copyright (c) 2026 Patrik Wenger
|
|
5
|
+
|
|
6
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
|
7
|
+
this software and associated documentation files (the "Software"), to deal in
|
|
8
|
+
the Software without restriction, including without limitation the rights to
|
|
9
|
+
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
|
10
|
+
the Software, and to permit persons to whom the Software is furnished to do so,
|
|
11
|
+
subject to the following conditions:
|
|
12
|
+
|
|
13
|
+
The above copyright notice and this permission notice shall be included in all
|
|
14
|
+
copies or substantial portions of the Software.
|
|
15
|
+
|
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
17
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
|
18
|
+
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
|
19
|
+
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
|
20
|
+
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
|
21
|
+
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,46 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @paddor/lz4rip
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Pure Rust LZ4 block and frame codec compiled to WebAssembly. Optimized for small
|
|
4
|
+
messages (<8 KB) in tight loops with dictionary compression.
|
|
5
|
+
|
|
6
|
+
## Usage
|
|
7
|
+
|
|
8
|
+
```js
|
|
9
|
+
import { compress, decompress, init } from "@paddor/lz4rip";
|
|
10
|
+
|
|
11
|
+
await init();
|
|
12
|
+
|
|
13
|
+
const data = new TextEncoder().encode("hello world".repeat(1000));
|
|
14
|
+
const compressed = compress(data);
|
|
15
|
+
const original = decompress(compressed, data.length);
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
LZ4 frames carry their own metadata, so the decoder needs no size:
|
|
19
|
+
|
|
20
|
+
```js
|
|
21
|
+
import { compressFrame, decompressFrame } from "@paddor/lz4rip";
|
|
22
|
+
|
|
23
|
+
const framed = compressFrame(data, { contentChecksum: true });
|
|
24
|
+
const restored = decompressFrame(framed, { maxDecompressedSize: data.length });
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
Dictionaries help small messages that share structure:
|
|
28
|
+
|
|
29
|
+
```js
|
|
30
|
+
import { Compressor, Decompressor, DictTrainer } from "@paddor/lz4rip";
|
|
31
|
+
|
|
32
|
+
const trainer = new DictTrainer(4096);
|
|
33
|
+
for (const sample of samples) trainer.addSample(sample);
|
|
34
|
+
const dictBytes = trainer.train();
|
|
35
|
+
|
|
36
|
+
const compressor = Compressor.withDict(dictBytes);
|
|
37
|
+
const decompressor = Decompressor.withDict(dictBytes);
|
|
38
|
+
const roundTrip = decompressor.decompress(compressor.compress(data), data.length);
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
`initSyncFromBytes(bytes)` initializes from preloaded WASM bytes.
|
|
42
|
+
|
|
43
|
+
## Source
|
|
44
|
+
|
|
45
|
+
Rust source and native benchmarks:
|
|
46
|
+
[github.com/paddor/lz4rip](https://github.com/paddor/lz4rip)
|
package/package.json
CHANGED
|
@@ -1,6 +1,46 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@paddor/lz4rip",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "0.2.20",
|
|
4
|
+
"description": "Pure Rust LZ4 block and frame codec compiled to WebAssembly. Compress and decompress with optional dictionary support.",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"repository": {
|
|
8
|
+
"type": "git",
|
|
9
|
+
"url": "git+https://github.com/paddor/lz4rip.git",
|
|
10
|
+
"directory": "npm"
|
|
11
|
+
},
|
|
12
|
+
"homepage": "https://github.com/paddor/lz4rip#readme",
|
|
13
|
+
"bugs": {
|
|
14
|
+
"url": "https://github.com/paddor/lz4rip/issues"
|
|
15
|
+
},
|
|
16
|
+
"keywords": [
|
|
17
|
+
"lz4",
|
|
18
|
+
"compression",
|
|
19
|
+
"decompression",
|
|
20
|
+
"dictionary",
|
|
21
|
+
"wasm",
|
|
22
|
+
"webassembly"
|
|
23
|
+
],
|
|
24
|
+
"exports": {
|
|
25
|
+
".": {
|
|
26
|
+
"types": "./src/mod.d.ts",
|
|
27
|
+
"import": "./src/mod.js",
|
|
28
|
+
"default": "./src/mod.js"
|
|
29
|
+
}
|
|
30
|
+
},
|
|
31
|
+
"types": "./src/mod.d.ts",
|
|
32
|
+
"files": [
|
|
33
|
+
"src/",
|
|
34
|
+
"LICENSE",
|
|
35
|
+
"README.md"
|
|
36
|
+
],
|
|
37
|
+
"publishConfig": {
|
|
38
|
+
"access": "public",
|
|
39
|
+
"provenance": true
|
|
40
|
+
},
|
|
41
|
+
"scripts": {
|
|
42
|
+
"build": "bash build.sh",
|
|
43
|
+
"pack:dry": "npm run build && npm pack --dry-run",
|
|
44
|
+
"test": "npm run build && node --test"
|
|
45
|
+
}
|
|
46
|
+
}
|
package/src/mod.d.ts
ADDED
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
export interface DictionaryOptions {
|
|
2
|
+
/** 32-bit dictionary identifier stored in LZ4 frame headers. */
|
|
3
|
+
id: number;
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
export interface FrameOptions {
|
|
7
|
+
/** External dictionary for LZ4 frame compression. */
|
|
8
|
+
dictionary?: Dictionary;
|
|
9
|
+
/** Enable linked blocks so blocks can reference previous block output. */
|
|
10
|
+
linkedBlocks?: boolean;
|
|
11
|
+
/** Include per-block checksums. */
|
|
12
|
+
blockChecksums?: boolean;
|
|
13
|
+
/** Include a checksum for the full decompressed content. */
|
|
14
|
+
contentChecksum?: boolean;
|
|
15
|
+
/** Store the total uncompressed content size in the frame header. */
|
|
16
|
+
contentSize?: boolean;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export interface FrameDecompressOptions {
|
|
20
|
+
/** External dictionary expected by the frame stream. */
|
|
21
|
+
dictionary?: Dictionary;
|
|
22
|
+
/** Maximum decompressed bytes allowed across the full input stream. */
|
|
23
|
+
maxDecompressedSize?: number;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export class Compressor {
|
|
27
|
+
constructor();
|
|
28
|
+
static withDict(dict: Uint8Array): Compressor;
|
|
29
|
+
compress(input: Uint8Array): Uint8Array;
|
|
30
|
+
free(): void;
|
|
31
|
+
[Symbol.dispose](): void;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export class Decompressor {
|
|
35
|
+
constructor();
|
|
36
|
+
static withDict(dict: Uint8Array): Decompressor;
|
|
37
|
+
decompress(input: Uint8Array, uncompressedSize: number): Uint8Array;
|
|
38
|
+
free(): void;
|
|
39
|
+
[Symbol.dispose](): void;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export class DictTrainer {
|
|
43
|
+
constructor(maxDictSize: number);
|
|
44
|
+
addSample(data: Uint8Array): void;
|
|
45
|
+
sampleCount(): number;
|
|
46
|
+
train(): Uint8Array;
|
|
47
|
+
free(): void;
|
|
48
|
+
[Symbol.dispose](): void;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
export class Dictionary {
|
|
52
|
+
constructor(bytes: Uint8Array, options: DictionaryOptions);
|
|
53
|
+
readonly id: number;
|
|
54
|
+
readonly bytes: Uint8Array;
|
|
55
|
+
free(): void;
|
|
56
|
+
[Symbol.dispose](): void;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
export function init(): Promise<void>;
|
|
60
|
+
export function initSyncFromBytes(bytes: BufferSource): void;
|
|
61
|
+
export function compress(input: Uint8Array): Uint8Array;
|
|
62
|
+
export function decompress(
|
|
63
|
+
input: Uint8Array,
|
|
64
|
+
uncompressedSize: number,
|
|
65
|
+
): Uint8Array;
|
|
66
|
+
export function compressFrame(
|
|
67
|
+
input: Uint8Array,
|
|
68
|
+
options?: FrameOptions,
|
|
69
|
+
): Uint8Array;
|
|
70
|
+
export function decompressFrame(
|
|
71
|
+
input: Uint8Array,
|
|
72
|
+
options?: FrameDecompressOptions,
|
|
73
|
+
): Uint8Array;
|
|
74
|
+
export function compressBound(inputLen: number): number;
|
package/src/mod.js
ADDED
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
import {
|
|
2
|
+
compress as wasmCompress,
|
|
3
|
+
compressBound as wasmCompressBound,
|
|
4
|
+
compressFrame as wasmCompressFrame,
|
|
5
|
+
Compressor as _Compressor,
|
|
6
|
+
decompress as wasmDecompress,
|
|
7
|
+
decompressFrame as wasmDecompressFrame,
|
|
8
|
+
Decompressor as _Decompressor,
|
|
9
|
+
DictTrainer as _DictTrainer,
|
|
10
|
+
initSync,
|
|
11
|
+
} from "./pkg/lz4rip_wasm.js";
|
|
12
|
+
|
|
13
|
+
export const Compressor = _Compressor;
|
|
14
|
+
export const Decompressor = _Decompressor;
|
|
15
|
+
export const DictTrainer = _DictTrainer;
|
|
16
|
+
|
|
17
|
+
const EMPTY_BYTES = new Uint8Array(0);
|
|
18
|
+
const MAX_U32 = 0xffff_ffff;
|
|
19
|
+
const MAX_WASM_USIZE = 0xffff_ffff;
|
|
20
|
+
const FRAME_FLAG_HAS_DICTIONARY = 1 << 0;
|
|
21
|
+
const FRAME_FLAG_LINKED_BLOCKS = 1 << 1;
|
|
22
|
+
const FRAME_FLAG_BLOCK_CHECKSUMS = 1 << 2;
|
|
23
|
+
const FRAME_FLAG_CONTENT_CHECKSUM = 1 << 3;
|
|
24
|
+
const FRAME_FLAG_CONTENT_SIZE = 1 << 4;
|
|
25
|
+
|
|
26
|
+
const dictionaryInner = new WeakMap();
|
|
27
|
+
|
|
28
|
+
function validateUint32(name, value) {
|
|
29
|
+
if (!Number.isInteger(value) || value < 0 || value > MAX_U32) {
|
|
30
|
+
throw new RangeError(`${name} must be an integer from 0 to 4294967295`);
|
|
31
|
+
}
|
|
32
|
+
return value;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
function getDictionaryInner(dictionary) {
|
|
36
|
+
const inner = dictionaryInner.get(dictionary);
|
|
37
|
+
if (!inner) {
|
|
38
|
+
throw new TypeError("invalid or freed Dictionary");
|
|
39
|
+
}
|
|
40
|
+
return inner;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export class Dictionary {
|
|
44
|
+
constructor(bytes, options) {
|
|
45
|
+
if (options === undefined) {
|
|
46
|
+
throw new TypeError("Dictionary options must include id");
|
|
47
|
+
}
|
|
48
|
+
dictionaryInner.set(this, {
|
|
49
|
+
bytes: new Uint8Array(bytes),
|
|
50
|
+
id: validateUint32("id", options.id),
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
get id() {
|
|
55
|
+
return getDictionaryInner(this).id;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
get bytes() {
|
|
59
|
+
return new Uint8Array(getDictionaryInner(this).bytes);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
free() {
|
|
63
|
+
dictionaryInner.delete(this);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
[Symbol.dispose]() {
|
|
67
|
+
this.free();
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
function frameDictionary(options) {
|
|
72
|
+
const dictionary = options?.dictionary;
|
|
73
|
+
if (dictionary === undefined) {
|
|
74
|
+
return { bytes: EMPTY_BYTES, id: 0, enabled: false };
|
|
75
|
+
}
|
|
76
|
+
const inner = getDictionaryInner(dictionary);
|
|
77
|
+
return { bytes: inner.bytes, id: inner.id, enabled: true };
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
function maxDecompressedSize(options) {
|
|
81
|
+
const max = options?.maxDecompressedSize;
|
|
82
|
+
if (max === undefined) return undefined;
|
|
83
|
+
if (!Number.isSafeInteger(max) || max < 0 || max > MAX_WASM_USIZE) {
|
|
84
|
+
throw new RangeError(
|
|
85
|
+
"maxDecompressedSize must be an integer from 0 to 4294967295",
|
|
86
|
+
);
|
|
87
|
+
}
|
|
88
|
+
return max;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
let initialized = false;
|
|
92
|
+
let initialization;
|
|
93
|
+
|
|
94
|
+
async function loadWasmBytes(url) {
|
|
95
|
+
if (url.protocol === "file:" && globalThis.process?.versions?.node) {
|
|
96
|
+
const { readFile } = await import("node:fs/promises");
|
|
97
|
+
return readFile(url);
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
const response = await fetch(url);
|
|
101
|
+
if (!response.ok) {
|
|
102
|
+
throw new Error(`failed to fetch ${url}: HTTP ${response.status}`);
|
|
103
|
+
}
|
|
104
|
+
return response.arrayBuffer();
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
function finishInitialization(module) {
|
|
108
|
+
// A synchronous caller may have initialized while the load was pending.
|
|
109
|
+
if (initialized) return;
|
|
110
|
+
initSync({ module });
|
|
111
|
+
initialized = true;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
export function init() {
|
|
115
|
+
if (initialized) return Promise.resolve();
|
|
116
|
+
if (initialization) return initialization;
|
|
117
|
+
|
|
118
|
+
initialization = (async () => {
|
|
119
|
+
const wasmUrl = new URL("./pkg/lz4rip_wasm_bg.wasm", import.meta.url);
|
|
120
|
+
const bytes = await loadWasmBytes(wasmUrl);
|
|
121
|
+
finishInitialization(new WebAssembly.Module(bytes));
|
|
122
|
+
})().catch((error) => {
|
|
123
|
+
initialization = undefined;
|
|
124
|
+
throw error;
|
|
125
|
+
});
|
|
126
|
+
return initialization;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
export function initSyncFromBytes(bytes) {
|
|
130
|
+
if (initialized) return;
|
|
131
|
+
finishInitialization(new WebAssembly.Module(bytes));
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
export function compress(input) {
|
|
135
|
+
return wasmCompress(input);
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
export function decompress(input, uncompressedSize) {
|
|
139
|
+
return wasmDecompress(input, uncompressedSize);
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
export function compressFrame(input, options) {
|
|
143
|
+
const dict = frameDictionary(options);
|
|
144
|
+
const flags = (dict.enabled ? FRAME_FLAG_HAS_DICTIONARY : 0) |
|
|
145
|
+
(options?.linkedBlocks === true ? FRAME_FLAG_LINKED_BLOCKS : 0) |
|
|
146
|
+
(options?.blockChecksums === true ? FRAME_FLAG_BLOCK_CHECKSUMS : 0) |
|
|
147
|
+
(options?.contentChecksum === true ? FRAME_FLAG_CONTENT_CHECKSUM : 0) |
|
|
148
|
+
(options?.contentSize === true ? FRAME_FLAG_CONTENT_SIZE : 0);
|
|
149
|
+
return wasmCompressFrame(input, dict.bytes, dict.id, flags);
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
export function decompressFrame(input, options) {
|
|
153
|
+
const dict = frameDictionary(options);
|
|
154
|
+
const max = maxDecompressedSize(options);
|
|
155
|
+
return wasmDecompressFrame(
|
|
156
|
+
input,
|
|
157
|
+
dict.bytes,
|
|
158
|
+
dict.id,
|
|
159
|
+
dict.enabled,
|
|
160
|
+
max ?? 0,
|
|
161
|
+
max !== undefined,
|
|
162
|
+
);
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
export function compressBound(inputLen) {
|
|
166
|
+
return wasmCompressBound(inputLen);
|
|
167
|
+
}
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
/* tslint:disable */
|
|
2
|
+
/* eslint-disable */
|
|
3
|
+
|
|
4
|
+
export class Compressor {
|
|
5
|
+
free(): void;
|
|
6
|
+
[Symbol.dispose](): void;
|
|
7
|
+
compress(input: Uint8Array): Uint8Array;
|
|
8
|
+
constructor();
|
|
9
|
+
static withDict(dict: Uint8Array): Compressor;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export class Decompressor {
|
|
13
|
+
free(): void;
|
|
14
|
+
[Symbol.dispose](): void;
|
|
15
|
+
decompress(input: Uint8Array, uncompressed_size: number): Uint8Array;
|
|
16
|
+
constructor();
|
|
17
|
+
static withDict(dict: Uint8Array): Decompressor;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export class DictTrainer {
|
|
21
|
+
free(): void;
|
|
22
|
+
[Symbol.dispose](): void;
|
|
23
|
+
addSample(data: Uint8Array): void;
|
|
24
|
+
constructor(max_dict_size: number);
|
|
25
|
+
sampleCount(): number;
|
|
26
|
+
train(): Uint8Array;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export function compress(input: Uint8Array): Uint8Array;
|
|
30
|
+
|
|
31
|
+
export function compressBound(input_len: number): number;
|
|
32
|
+
|
|
33
|
+
export function compressFrame(input: Uint8Array, dictionary: Uint8Array, dict_id: number, flags: number): Uint8Array;
|
|
34
|
+
|
|
35
|
+
export function decompress(input: Uint8Array, uncompressed_size: number): Uint8Array;
|
|
36
|
+
|
|
37
|
+
export function decompressFrame(input: Uint8Array, dictionary: Uint8Array, dict_id: number, has_dictionary: boolean, max_output: number, has_max_output: boolean): Uint8Array;
|
|
38
|
+
|
|
39
|
+
export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembly.Module;
|
|
40
|
+
|
|
41
|
+
export interface InitOutput {
|
|
42
|
+
readonly memory: WebAssembly.Memory;
|
|
43
|
+
readonly __wbg_compressor_free: (a: number, b: number) => void;
|
|
44
|
+
readonly __wbg_decompressor_free: (a: number, b: number) => void;
|
|
45
|
+
readonly __wbg_dicttrainer_free: (a: number, b: number) => void;
|
|
46
|
+
readonly compress: (a: number, b: number, c: number) => void;
|
|
47
|
+
readonly compressBound: (a: number) => number;
|
|
48
|
+
readonly compressFrame: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => void;
|
|
49
|
+
readonly compressor_compress: (a: number, b: number, c: number, d: number) => void;
|
|
50
|
+
readonly compressor_new: () => number;
|
|
51
|
+
readonly compressor_withDict: (a: number, b: number) => number;
|
|
52
|
+
readonly decompress: (a: number, b: number, c: number, d: number) => void;
|
|
53
|
+
readonly decompressFrame: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number) => void;
|
|
54
|
+
readonly decompressor_decompress: (a: number, b: number, c: number, d: number, e: number) => void;
|
|
55
|
+
readonly decompressor_new: () => number;
|
|
56
|
+
readonly decompressor_withDict: (a: number, b: number) => number;
|
|
57
|
+
readonly dicttrainer_addSample: (a: number, b: number, c: number, d: number) => void;
|
|
58
|
+
readonly dicttrainer_new: (a: number) => number;
|
|
59
|
+
readonly dicttrainer_sampleCount: (a: number, b: number) => void;
|
|
60
|
+
readonly dicttrainer_train: (a: number, b: number) => void;
|
|
61
|
+
readonly __wbindgen_add_to_stack_pointer: (a: number) => number;
|
|
62
|
+
readonly __wbindgen_export: (a: number, b: number) => number;
|
|
63
|
+
readonly __wbindgen_export2: (a: number, b: number, c: number) => void;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
export type SyncInitInput = BufferSource | WebAssembly.Module;
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* Instantiates the given `module`, which can either be bytes or
|
|
70
|
+
* a precompiled `WebAssembly.Module`.
|
|
71
|
+
*
|
|
72
|
+
* @param {{ module: SyncInitInput }} module - Passing `SyncInitInput` directly is deprecated.
|
|
73
|
+
*
|
|
74
|
+
* @returns {InitOutput}
|
|
75
|
+
*/
|
|
76
|
+
export function initSync(module: { module: SyncInitInput } | SyncInitInput): InitOutput;
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* If `module_or_path` is {RequestInfo} or {URL}, makes a request and
|
|
80
|
+
* for everything else, calls `WebAssembly.instantiate` directly.
|
|
81
|
+
*
|
|
82
|
+
* @param {{ module_or_path: InitInput | Promise<InitInput> }} module_or_path - Passing `InitInput` directly is deprecated.
|
|
83
|
+
*
|
|
84
|
+
* @returns {Promise<InitOutput>}
|
|
85
|
+
*/
|
|
86
|
+
export default function __wbg_init (module_or_path?: { module_or_path: InitInput | Promise<InitInput> } | InitInput | Promise<InitInput>): Promise<InitOutput>;
|
|
@@ -0,0 +1,509 @@
|
|
|
1
|
+
/* @ts-self-types="./lz4rip_wasm.d.ts" */
|
|
2
|
+
|
|
3
|
+
export class Compressor {
|
|
4
|
+
static __wrap(ptr) {
|
|
5
|
+
const obj = Object.create(Compressor.prototype);
|
|
6
|
+
obj.__wbg_ptr = ptr;
|
|
7
|
+
CompressorFinalization.register(obj, obj.__wbg_ptr, obj);
|
|
8
|
+
return obj;
|
|
9
|
+
}
|
|
10
|
+
__destroy_into_raw() {
|
|
11
|
+
const ptr = this.__wbg_ptr;
|
|
12
|
+
this.__wbg_ptr = 0;
|
|
13
|
+
CompressorFinalization.unregister(this);
|
|
14
|
+
return ptr;
|
|
15
|
+
}
|
|
16
|
+
free() {
|
|
17
|
+
const ptr = this.__destroy_into_raw();
|
|
18
|
+
wasm.__wbg_compressor_free(ptr, 0);
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* @param {Uint8Array} input
|
|
22
|
+
* @returns {Uint8Array}
|
|
23
|
+
*/
|
|
24
|
+
compress(input) {
|
|
25
|
+
try {
|
|
26
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
27
|
+
const ptr0 = passArray8ToWasm0(input, wasm.__wbindgen_export);
|
|
28
|
+
const len0 = WASM_VECTOR_LEN;
|
|
29
|
+
wasm.compressor_compress(retptr, this.__wbg_ptr, ptr0, len0);
|
|
30
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
31
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
32
|
+
var v2 = getArrayU8FromWasm0(r0, r1).slice();
|
|
33
|
+
wasm.__wbindgen_export2(r0, r1 * 1, 1);
|
|
34
|
+
return v2;
|
|
35
|
+
} finally {
|
|
36
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
constructor() {
|
|
40
|
+
const ret = wasm.compressor_new();
|
|
41
|
+
this.__wbg_ptr = ret;
|
|
42
|
+
CompressorFinalization.register(this, this.__wbg_ptr, this);
|
|
43
|
+
return this;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* @param {Uint8Array} dict
|
|
47
|
+
* @returns {Compressor}
|
|
48
|
+
*/
|
|
49
|
+
static withDict(dict) {
|
|
50
|
+
const ptr0 = passArray8ToWasm0(dict, wasm.__wbindgen_export);
|
|
51
|
+
const len0 = WASM_VECTOR_LEN;
|
|
52
|
+
const ret = wasm.compressor_withDict(ptr0, len0);
|
|
53
|
+
return Compressor.__wrap(ret);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
if (Symbol.dispose) Compressor.prototype[Symbol.dispose] = Compressor.prototype.free;
|
|
57
|
+
|
|
58
|
+
export class Decompressor {
|
|
59
|
+
static __wrap(ptr) {
|
|
60
|
+
const obj = Object.create(Decompressor.prototype);
|
|
61
|
+
obj.__wbg_ptr = ptr;
|
|
62
|
+
DecompressorFinalization.register(obj, obj.__wbg_ptr, obj);
|
|
63
|
+
return obj;
|
|
64
|
+
}
|
|
65
|
+
__destroy_into_raw() {
|
|
66
|
+
const ptr = this.__wbg_ptr;
|
|
67
|
+
this.__wbg_ptr = 0;
|
|
68
|
+
DecompressorFinalization.unregister(this);
|
|
69
|
+
return ptr;
|
|
70
|
+
}
|
|
71
|
+
free() {
|
|
72
|
+
const ptr = this.__destroy_into_raw();
|
|
73
|
+
wasm.__wbg_decompressor_free(ptr, 0);
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* @param {Uint8Array} input
|
|
77
|
+
* @param {number} uncompressed_size
|
|
78
|
+
* @returns {Uint8Array}
|
|
79
|
+
*/
|
|
80
|
+
decompress(input, uncompressed_size) {
|
|
81
|
+
try {
|
|
82
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
83
|
+
const ptr0 = passArray8ToWasm0(input, wasm.__wbindgen_export);
|
|
84
|
+
const len0 = WASM_VECTOR_LEN;
|
|
85
|
+
wasm.decompressor_decompress(retptr, this.__wbg_ptr, ptr0, len0, uncompressed_size);
|
|
86
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
87
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
88
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
89
|
+
var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
|
|
90
|
+
if (r3) {
|
|
91
|
+
throw takeObject(r2);
|
|
92
|
+
}
|
|
93
|
+
var v2 = getArrayU8FromWasm0(r0, r1).slice();
|
|
94
|
+
wasm.__wbindgen_export2(r0, r1 * 1, 1);
|
|
95
|
+
return v2;
|
|
96
|
+
} finally {
|
|
97
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
constructor() {
|
|
101
|
+
const ret = wasm.decompressor_new();
|
|
102
|
+
this.__wbg_ptr = ret;
|
|
103
|
+
DecompressorFinalization.register(this, this.__wbg_ptr, this);
|
|
104
|
+
return this;
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* @param {Uint8Array} dict
|
|
108
|
+
* @returns {Decompressor}
|
|
109
|
+
*/
|
|
110
|
+
static withDict(dict) {
|
|
111
|
+
const ptr0 = passArray8ToWasm0(dict, wasm.__wbindgen_export);
|
|
112
|
+
const len0 = WASM_VECTOR_LEN;
|
|
113
|
+
const ret = wasm.decompressor_withDict(ptr0, len0);
|
|
114
|
+
return Decompressor.__wrap(ret);
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
if (Symbol.dispose) Decompressor.prototype[Symbol.dispose] = Decompressor.prototype.free;
|
|
118
|
+
|
|
119
|
+
export class DictTrainer {
|
|
120
|
+
__destroy_into_raw() {
|
|
121
|
+
const ptr = this.__wbg_ptr;
|
|
122
|
+
this.__wbg_ptr = 0;
|
|
123
|
+
DictTrainerFinalization.unregister(this);
|
|
124
|
+
return ptr;
|
|
125
|
+
}
|
|
126
|
+
free() {
|
|
127
|
+
const ptr = this.__destroy_into_raw();
|
|
128
|
+
wasm.__wbg_dicttrainer_free(ptr, 0);
|
|
129
|
+
}
|
|
130
|
+
/**
|
|
131
|
+
* @param {Uint8Array} data
|
|
132
|
+
*/
|
|
133
|
+
addSample(data) {
|
|
134
|
+
try {
|
|
135
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
136
|
+
const ptr0 = passArray8ToWasm0(data, wasm.__wbindgen_export);
|
|
137
|
+
const len0 = WASM_VECTOR_LEN;
|
|
138
|
+
wasm.dicttrainer_addSample(retptr, this.__wbg_ptr, ptr0, len0);
|
|
139
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
140
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
141
|
+
if (r1) {
|
|
142
|
+
throw takeObject(r0);
|
|
143
|
+
}
|
|
144
|
+
} finally {
|
|
145
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
/**
|
|
149
|
+
* @param {number} max_dict_size
|
|
150
|
+
*/
|
|
151
|
+
constructor(max_dict_size) {
|
|
152
|
+
const ret = wasm.dicttrainer_new(max_dict_size);
|
|
153
|
+
this.__wbg_ptr = ret;
|
|
154
|
+
DictTrainerFinalization.register(this, this.__wbg_ptr, this);
|
|
155
|
+
return this;
|
|
156
|
+
}
|
|
157
|
+
/**
|
|
158
|
+
* @returns {number}
|
|
159
|
+
*/
|
|
160
|
+
sampleCount() {
|
|
161
|
+
try {
|
|
162
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
163
|
+
wasm.dicttrainer_sampleCount(retptr, this.__wbg_ptr);
|
|
164
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
165
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
166
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
167
|
+
if (r2) {
|
|
168
|
+
throw takeObject(r1);
|
|
169
|
+
}
|
|
170
|
+
return r0 >>> 0;
|
|
171
|
+
} finally {
|
|
172
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
/**
|
|
176
|
+
* @returns {Uint8Array}
|
|
177
|
+
*/
|
|
178
|
+
train() {
|
|
179
|
+
try {
|
|
180
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
181
|
+
wasm.dicttrainer_train(retptr, this.__wbg_ptr);
|
|
182
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
183
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
184
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
185
|
+
var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
|
|
186
|
+
if (r3) {
|
|
187
|
+
throw takeObject(r2);
|
|
188
|
+
}
|
|
189
|
+
var v1 = getArrayU8FromWasm0(r0, r1).slice();
|
|
190
|
+
wasm.__wbindgen_export2(r0, r1 * 1, 1);
|
|
191
|
+
return v1;
|
|
192
|
+
} finally {
|
|
193
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
if (Symbol.dispose) DictTrainer.prototype[Symbol.dispose] = DictTrainer.prototype.free;
|
|
198
|
+
|
|
199
|
+
/**
|
|
200
|
+
* @param {Uint8Array} input
|
|
201
|
+
* @returns {Uint8Array}
|
|
202
|
+
*/
|
|
203
|
+
export function compress(input) {
|
|
204
|
+
try {
|
|
205
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
206
|
+
const ptr0 = passArray8ToWasm0(input, wasm.__wbindgen_export);
|
|
207
|
+
const len0 = WASM_VECTOR_LEN;
|
|
208
|
+
wasm.compress(retptr, ptr0, len0);
|
|
209
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
210
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
211
|
+
var v2 = getArrayU8FromWasm0(r0, r1).slice();
|
|
212
|
+
wasm.__wbindgen_export2(r0, r1 * 1, 1);
|
|
213
|
+
return v2;
|
|
214
|
+
} finally {
|
|
215
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
/**
|
|
220
|
+
* @param {number} input_len
|
|
221
|
+
* @returns {number}
|
|
222
|
+
*/
|
|
223
|
+
export function compressBound(input_len) {
|
|
224
|
+
const ret = wasm.compressBound(input_len);
|
|
225
|
+
return ret >>> 0;
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
/**
|
|
229
|
+
* @param {Uint8Array} input
|
|
230
|
+
* @param {Uint8Array} dictionary
|
|
231
|
+
* @param {number} dict_id
|
|
232
|
+
* @param {number} flags
|
|
233
|
+
* @returns {Uint8Array}
|
|
234
|
+
*/
|
|
235
|
+
export function compressFrame(input, dictionary, dict_id, flags) {
|
|
236
|
+
try {
|
|
237
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
238
|
+
const ptr0 = passArray8ToWasm0(input, wasm.__wbindgen_export);
|
|
239
|
+
const len0 = WASM_VECTOR_LEN;
|
|
240
|
+
const ptr1 = passArray8ToWasm0(dictionary, wasm.__wbindgen_export);
|
|
241
|
+
const len1 = WASM_VECTOR_LEN;
|
|
242
|
+
wasm.compressFrame(retptr, ptr0, len0, ptr1, len1, dict_id, flags);
|
|
243
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
244
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
245
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
246
|
+
var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
|
|
247
|
+
if (r3) {
|
|
248
|
+
throw takeObject(r2);
|
|
249
|
+
}
|
|
250
|
+
var v3 = getArrayU8FromWasm0(r0, r1).slice();
|
|
251
|
+
wasm.__wbindgen_export2(r0, r1 * 1, 1);
|
|
252
|
+
return v3;
|
|
253
|
+
} finally {
|
|
254
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
/**
|
|
259
|
+
* @param {Uint8Array} input
|
|
260
|
+
* @param {number} uncompressed_size
|
|
261
|
+
* @returns {Uint8Array}
|
|
262
|
+
*/
|
|
263
|
+
export function decompress(input, uncompressed_size) {
|
|
264
|
+
try {
|
|
265
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
266
|
+
const ptr0 = passArray8ToWasm0(input, wasm.__wbindgen_export);
|
|
267
|
+
const len0 = WASM_VECTOR_LEN;
|
|
268
|
+
wasm.decompress(retptr, ptr0, len0, uncompressed_size);
|
|
269
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
270
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
271
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
272
|
+
var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
|
|
273
|
+
if (r3) {
|
|
274
|
+
throw takeObject(r2);
|
|
275
|
+
}
|
|
276
|
+
var v2 = getArrayU8FromWasm0(r0, r1).slice();
|
|
277
|
+
wasm.__wbindgen_export2(r0, r1 * 1, 1);
|
|
278
|
+
return v2;
|
|
279
|
+
} finally {
|
|
280
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
/**
|
|
285
|
+
* @param {Uint8Array} input
|
|
286
|
+
* @param {Uint8Array} dictionary
|
|
287
|
+
* @param {number} dict_id
|
|
288
|
+
* @param {boolean} has_dictionary
|
|
289
|
+
* @param {number} max_output
|
|
290
|
+
* @param {boolean} has_max_output
|
|
291
|
+
* @returns {Uint8Array}
|
|
292
|
+
*/
|
|
293
|
+
export function decompressFrame(input, dictionary, dict_id, has_dictionary, max_output, has_max_output) {
|
|
294
|
+
try {
|
|
295
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
296
|
+
const ptr0 = passArray8ToWasm0(input, wasm.__wbindgen_export);
|
|
297
|
+
const len0 = WASM_VECTOR_LEN;
|
|
298
|
+
const ptr1 = passArray8ToWasm0(dictionary, wasm.__wbindgen_export);
|
|
299
|
+
const len1 = WASM_VECTOR_LEN;
|
|
300
|
+
wasm.decompressFrame(retptr, ptr0, len0, ptr1, len1, dict_id, has_dictionary, max_output, has_max_output);
|
|
301
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
302
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
303
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
304
|
+
var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
|
|
305
|
+
if (r3) {
|
|
306
|
+
throw takeObject(r2);
|
|
307
|
+
}
|
|
308
|
+
var v3 = getArrayU8FromWasm0(r0, r1).slice();
|
|
309
|
+
wasm.__wbindgen_export2(r0, r1 * 1, 1);
|
|
310
|
+
return v3;
|
|
311
|
+
} finally {
|
|
312
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
313
|
+
}
|
|
314
|
+
}
|
|
315
|
+
function __wbg_get_imports() {
|
|
316
|
+
const import0 = {
|
|
317
|
+
__proto__: null,
|
|
318
|
+
__wbg_Error_fdd633d4bb5dd76a: function(arg0, arg1) {
|
|
319
|
+
const ret = Error(getStringFromWasm0(arg0, arg1));
|
|
320
|
+
return addHeapObject(ret);
|
|
321
|
+
},
|
|
322
|
+
__wbg___wbindgen_throw_ea4887a5f8f9a9db: function(arg0, arg1) {
|
|
323
|
+
throw new Error(getStringFromWasm0(arg0, arg1));
|
|
324
|
+
},
|
|
325
|
+
};
|
|
326
|
+
return {
|
|
327
|
+
__proto__: null,
|
|
328
|
+
"./lz4rip_wasm_bg.js": import0,
|
|
329
|
+
};
|
|
330
|
+
}
|
|
331
|
+
|
|
332
|
+
const CompressorFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
333
|
+
? { register: () => {}, unregister: () => {} }
|
|
334
|
+
: new FinalizationRegistry(ptr => wasm.__wbg_compressor_free(ptr, 1));
|
|
335
|
+
const DecompressorFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
336
|
+
? { register: () => {}, unregister: () => {} }
|
|
337
|
+
: new FinalizationRegistry(ptr => wasm.__wbg_decompressor_free(ptr, 1));
|
|
338
|
+
const DictTrainerFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
339
|
+
? { register: () => {}, unregister: () => {} }
|
|
340
|
+
: new FinalizationRegistry(ptr => wasm.__wbg_dicttrainer_free(ptr, 1));
|
|
341
|
+
|
|
342
|
+
function addHeapObject(obj) {
|
|
343
|
+
if (heap_next === heap.length) heap.push(heap.length + 1);
|
|
344
|
+
const idx = heap_next;
|
|
345
|
+
heap_next = heap[idx];
|
|
346
|
+
|
|
347
|
+
heap[idx] = obj;
|
|
348
|
+
return idx;
|
|
349
|
+
}
|
|
350
|
+
|
|
351
|
+
function dropObject(idx) {
|
|
352
|
+
if (idx < 1028) return;
|
|
353
|
+
heap[idx] = heap_next;
|
|
354
|
+
heap_next = idx;
|
|
355
|
+
}
|
|
356
|
+
|
|
357
|
+
function getArrayU8FromWasm0(ptr, len) {
|
|
358
|
+
ptr = ptr >>> 0;
|
|
359
|
+
return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
|
|
360
|
+
}
|
|
361
|
+
|
|
362
|
+
let cachedDataViewMemory0 = null;
|
|
363
|
+
function getDataViewMemory0() {
|
|
364
|
+
if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || (cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm.memory.buffer)) {
|
|
365
|
+
cachedDataViewMemory0 = new DataView(wasm.memory.buffer);
|
|
366
|
+
}
|
|
367
|
+
return cachedDataViewMemory0;
|
|
368
|
+
}
|
|
369
|
+
|
|
370
|
+
function getStringFromWasm0(ptr, len) {
|
|
371
|
+
return decodeText(ptr >>> 0, len);
|
|
372
|
+
}
|
|
373
|
+
|
|
374
|
+
let cachedUint8ArrayMemory0 = null;
|
|
375
|
+
function getUint8ArrayMemory0() {
|
|
376
|
+
if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
|
|
377
|
+
cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
|
|
378
|
+
}
|
|
379
|
+
return cachedUint8ArrayMemory0;
|
|
380
|
+
}
|
|
381
|
+
|
|
382
|
+
function getObject(idx) { return heap[idx]; }
|
|
383
|
+
|
|
384
|
+
let heap = new Array(1024).fill(undefined);
|
|
385
|
+
heap.push(undefined, null, true, false);
|
|
386
|
+
|
|
387
|
+
let heap_next = heap.length;
|
|
388
|
+
|
|
389
|
+
function passArray8ToWasm0(arg, malloc) {
|
|
390
|
+
const ptr = malloc(arg.length * 1, 1) >>> 0;
|
|
391
|
+
getUint8ArrayMemory0().set(arg, ptr / 1);
|
|
392
|
+
WASM_VECTOR_LEN = arg.length;
|
|
393
|
+
return ptr;
|
|
394
|
+
}
|
|
395
|
+
|
|
396
|
+
function takeObject(idx) {
|
|
397
|
+
const ret = getObject(idx);
|
|
398
|
+
dropObject(idx);
|
|
399
|
+
return ret;
|
|
400
|
+
}
|
|
401
|
+
|
|
402
|
+
let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
|
|
403
|
+
cachedTextDecoder.decode();
|
|
404
|
+
const MAX_SAFARI_DECODE_BYTES = 2146435072;
|
|
405
|
+
let numBytesDecoded = 0;
|
|
406
|
+
function decodeText(ptr, len) {
|
|
407
|
+
numBytesDecoded += len;
|
|
408
|
+
if (numBytesDecoded >= MAX_SAFARI_DECODE_BYTES) {
|
|
409
|
+
cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
|
|
410
|
+
cachedTextDecoder.decode();
|
|
411
|
+
numBytesDecoded = len;
|
|
412
|
+
}
|
|
413
|
+
return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
|
|
414
|
+
}
|
|
415
|
+
|
|
416
|
+
let WASM_VECTOR_LEN = 0;
|
|
417
|
+
|
|
418
|
+
let wasmModule, wasmInstance, wasm;
|
|
419
|
+
function __wbg_finalize_init(instance, module) {
|
|
420
|
+
wasmInstance = instance;
|
|
421
|
+
wasm = instance.exports;
|
|
422
|
+
wasmModule = module;
|
|
423
|
+
cachedDataViewMemory0 = null;
|
|
424
|
+
cachedUint8ArrayMemory0 = null;
|
|
425
|
+
return wasm;
|
|
426
|
+
}
|
|
427
|
+
|
|
428
|
+
async function __wbg_load(module, imports) {
|
|
429
|
+
if (typeof Response === 'function' && module instanceof Response) {
|
|
430
|
+
if (typeof WebAssembly.instantiateStreaming === 'function') {
|
|
431
|
+
try {
|
|
432
|
+
return await WebAssembly.instantiateStreaming(module, imports);
|
|
433
|
+
} catch (e) {
|
|
434
|
+
const validResponse = module.ok && expectedResponseType(module.type);
|
|
435
|
+
|
|
436
|
+
if (validResponse && module.headers.get('Content-Type') !== 'application/wasm') {
|
|
437
|
+
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);
|
|
438
|
+
|
|
439
|
+
} else { throw e; }
|
|
440
|
+
}
|
|
441
|
+
}
|
|
442
|
+
|
|
443
|
+
const bytes = await module.arrayBuffer();
|
|
444
|
+
return await WebAssembly.instantiate(bytes, imports);
|
|
445
|
+
} else {
|
|
446
|
+
const instance = await WebAssembly.instantiate(module, imports);
|
|
447
|
+
|
|
448
|
+
if (instance instanceof WebAssembly.Instance) {
|
|
449
|
+
return { instance, module };
|
|
450
|
+
} else {
|
|
451
|
+
return instance;
|
|
452
|
+
}
|
|
453
|
+
}
|
|
454
|
+
|
|
455
|
+
function expectedResponseType(type) {
|
|
456
|
+
switch (type) {
|
|
457
|
+
case 'basic': case 'cors': case 'default': return true;
|
|
458
|
+
}
|
|
459
|
+
return false;
|
|
460
|
+
}
|
|
461
|
+
}
|
|
462
|
+
|
|
463
|
+
function initSync(module) {
|
|
464
|
+
if (wasm !== undefined) return wasm;
|
|
465
|
+
|
|
466
|
+
|
|
467
|
+
if (module !== undefined) {
|
|
468
|
+
if (Object.getPrototypeOf(module) === Object.prototype) {
|
|
469
|
+
({module} = module)
|
|
470
|
+
} else {
|
|
471
|
+
console.warn('using deprecated parameters for `initSync()`; pass a single object instead')
|
|
472
|
+
}
|
|
473
|
+
}
|
|
474
|
+
|
|
475
|
+
const imports = __wbg_get_imports();
|
|
476
|
+
if (!(module instanceof WebAssembly.Module)) {
|
|
477
|
+
module = new WebAssembly.Module(module);
|
|
478
|
+
}
|
|
479
|
+
const instance = new WebAssembly.Instance(module, imports);
|
|
480
|
+
return __wbg_finalize_init(instance, module);
|
|
481
|
+
}
|
|
482
|
+
|
|
483
|
+
async function __wbg_init(module_or_path) {
|
|
484
|
+
if (wasm !== undefined) return wasm;
|
|
485
|
+
|
|
486
|
+
|
|
487
|
+
if (module_or_path !== undefined) {
|
|
488
|
+
if (Object.getPrototypeOf(module_or_path) === Object.prototype) {
|
|
489
|
+
({module_or_path} = module_or_path)
|
|
490
|
+
} else {
|
|
491
|
+
console.warn('using deprecated parameters for the initialization function; pass a single object instead')
|
|
492
|
+
}
|
|
493
|
+
}
|
|
494
|
+
|
|
495
|
+
if (module_or_path === undefined) {
|
|
496
|
+
module_or_path = new URL('lz4rip_wasm_bg.wasm', import.meta.url);
|
|
497
|
+
}
|
|
498
|
+
const imports = __wbg_get_imports();
|
|
499
|
+
|
|
500
|
+
if (typeof module_or_path === 'string' || (typeof Request === 'function' && module_or_path instanceof Request) || (typeof URL === 'function' && module_or_path instanceof URL)) {
|
|
501
|
+
module_or_path = fetch(module_or_path);
|
|
502
|
+
}
|
|
503
|
+
|
|
504
|
+
const { instance, module } = await __wbg_load(await module_or_path, imports);
|
|
505
|
+
|
|
506
|
+
return __wbg_finalize_init(instance, module);
|
|
507
|
+
}
|
|
508
|
+
|
|
509
|
+
export { initSync, __wbg_init as default };
|
|
Binary file
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/* tslint:disable */
|
|
2
|
+
/* eslint-disable */
|
|
3
|
+
export const memory: WebAssembly.Memory;
|
|
4
|
+
export const __wbg_compressor_free: (a: number, b: number) => void;
|
|
5
|
+
export const __wbg_decompressor_free: (a: number, b: number) => void;
|
|
6
|
+
export const __wbg_dicttrainer_free: (a: number, b: number) => void;
|
|
7
|
+
export const compress: (a: number, b: number, c: number) => void;
|
|
8
|
+
export const compressBound: (a: number) => number;
|
|
9
|
+
export const compressFrame: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => void;
|
|
10
|
+
export const compressor_compress: (a: number, b: number, c: number, d: number) => void;
|
|
11
|
+
export const compressor_new: () => number;
|
|
12
|
+
export const compressor_withDict: (a: number, b: number) => number;
|
|
13
|
+
export const decompress: (a: number, b: number, c: number, d: number) => void;
|
|
14
|
+
export const decompressFrame: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number) => void;
|
|
15
|
+
export const decompressor_decompress: (a: number, b: number, c: number, d: number, e: number) => void;
|
|
16
|
+
export const decompressor_new: () => number;
|
|
17
|
+
export const decompressor_withDict: (a: number, b: number) => number;
|
|
18
|
+
export const dicttrainer_addSample: (a: number, b: number, c: number, d: number) => void;
|
|
19
|
+
export const dicttrainer_new: (a: number) => number;
|
|
20
|
+
export const dicttrainer_sampleCount: (a: number, b: number) => void;
|
|
21
|
+
export const dicttrainer_train: (a: number, b: number) => void;
|
|
22
|
+
export const __wbindgen_add_to_stack_pointer: (a: number) => number;
|
|
23
|
+
export const __wbindgen_export: (a: number, b: number) => number;
|
|
24
|
+
export const __wbindgen_export2: (a: number, b: number, c: number) => void;
|