@paddor/zrip 0.5.7
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 +25 -0
- package/package.json +45 -0
- package/src/mod.d.ts +46 -0
- package/src/mod.js +154 -0
- package/src/pkg/zrip_simd.wasm +0 -0
- package/src/pkg/zrip_wasm.d.ts +84 -0
- package/src/pkg/zrip_wasm.js +541 -0
- package/src/pkg/zrip_wasm_bg.wasm +0 -0
- package/src/pkg/zrip_wasm_bg.wasm.d.ts +23 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Patrik Wenger
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
# @paddor/zrip
|
|
2
|
+
|
|
3
|
+
Pure Rust zstd codec compiled to WebAssembly. Decodes standard zstd blocks and
|
|
4
|
+
frames produced at any compression level. Encodes levels -8 through 4 for fast
|
|
5
|
+
transfer pipelines. First-class dictionary support.
|
|
6
|
+
|
|
7
|
+
Automatically detects WASM SIMD support and loads the appropriate binary.
|
|
8
|
+
|
|
9
|
+
## Usage
|
|
10
|
+
|
|
11
|
+
```js
|
|
12
|
+
import { compress, decompress, init } from "@paddor/zrip";
|
|
13
|
+
|
|
14
|
+
await init();
|
|
15
|
+
|
|
16
|
+
const data = new TextEncoder().encode("hello world".repeat(1000));
|
|
17
|
+
const compressed = compress(data, 1);
|
|
18
|
+
const original = decompress(compressed);
|
|
19
|
+
const bounded = decompress(compressed, { maxDecompressedSize: data.length });
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
## Source
|
|
23
|
+
|
|
24
|
+
Rust source and native benchmarks:
|
|
25
|
+
[github.com/paddor/zrip](https://github.com/paddor/zrip)
|
package/package.json
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@paddor/zrip",
|
|
3
|
+
"version": "0.5.7",
|
|
4
|
+
"description": "Pure Rust zstd codec compiled to WebAssembly. Decodes all zstd levels, encodes -8..4, with SIMD auto-detection.",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"repository": {
|
|
8
|
+
"type": "git",
|
|
9
|
+
"url": "git+https://github.com/paddor/zrip.git",
|
|
10
|
+
"directory": "npm"
|
|
11
|
+
},
|
|
12
|
+
"homepage": "https://github.com/paddor/zrip#readme",
|
|
13
|
+
"bugs": {
|
|
14
|
+
"url": "https://github.com/paddor/zrip/issues"
|
|
15
|
+
},
|
|
16
|
+
"keywords": [
|
|
17
|
+
"zstd",
|
|
18
|
+
"zstandard",
|
|
19
|
+
"compression",
|
|
20
|
+
"decompression",
|
|
21
|
+
"wasm",
|
|
22
|
+
"webassembly"
|
|
23
|
+
],
|
|
24
|
+
"exports": {
|
|
25
|
+
".": {
|
|
26
|
+
"types": "./src/mod.d.ts",
|
|
27
|
+
"import": "./src/mod.js"
|
|
28
|
+
}
|
|
29
|
+
},
|
|
30
|
+
"types": "./src/mod.d.ts",
|
|
31
|
+
"files": [
|
|
32
|
+
"src/",
|
|
33
|
+
"LICENSE",
|
|
34
|
+
"README.md"
|
|
35
|
+
],
|
|
36
|
+
"publishConfig": {
|
|
37
|
+
"access": "public",
|
|
38
|
+
"provenance": true
|
|
39
|
+
},
|
|
40
|
+
"scripts": {
|
|
41
|
+
"build": "bash build.sh",
|
|
42
|
+
"pack:dry": "npm run build && npm pack --dry-run",
|
|
43
|
+
"test": "npm run build && node --test"
|
|
44
|
+
}
|
|
45
|
+
}
|
package/src/mod.d.ts
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
export interface DecompressOptions {
|
|
2
|
+
maxDecompressedSize?: number;
|
|
3
|
+
}
|
|
4
|
+
|
|
5
|
+
export class Compressor {
|
|
6
|
+
constructor(level: number);
|
|
7
|
+
static withDict(level: number, dict: Dictionary): Compressor;
|
|
8
|
+
compress(input: Uint8Array): Uint8Array;
|
|
9
|
+
compressWithDict(input: Uint8Array, dict: Dictionary): Uint8Array;
|
|
10
|
+
free(): void;
|
|
11
|
+
[Symbol.dispose](): void;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export class Decompressor {
|
|
15
|
+
constructor();
|
|
16
|
+
static withDict(dict: Dictionary): Decompressor;
|
|
17
|
+
decompress(input: Uint8Array, options?: DecompressOptions): Uint8Array;
|
|
18
|
+
free(): void;
|
|
19
|
+
[Symbol.dispose](): void;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export class Dictionary {
|
|
23
|
+
constructor(data: Uint8Array);
|
|
24
|
+
readonly id: number;
|
|
25
|
+
free(): void;
|
|
26
|
+
[Symbol.dispose](): void;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export function init(): Promise<void>;
|
|
30
|
+
export function initSyncFromBytes(bytes: BufferSource): void;
|
|
31
|
+
export function compress(input: Uint8Array, level?: number): Uint8Array;
|
|
32
|
+
export function decompress(
|
|
33
|
+
input: Uint8Array,
|
|
34
|
+
options?: DecompressOptions,
|
|
35
|
+
): Uint8Array;
|
|
36
|
+
export function compressBound(inputLen: number): number;
|
|
37
|
+
export function compressWithDict(
|
|
38
|
+
input: Uint8Array,
|
|
39
|
+
level: number,
|
|
40
|
+
dict: Dictionary,
|
|
41
|
+
): Uint8Array;
|
|
42
|
+
export function decompressWithDict(
|
|
43
|
+
input: Uint8Array,
|
|
44
|
+
dict: Dictionary,
|
|
45
|
+
options?: DecompressOptions,
|
|
46
|
+
): Uint8Array;
|
package/src/mod.js
ADDED
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
import {
|
|
2
|
+
compress as wasmCompress,
|
|
3
|
+
compressBound as wasmCompressBound,
|
|
4
|
+
Compressor as _Compressor,
|
|
5
|
+
compressWithDict as wasmCompressWithDict,
|
|
6
|
+
decompress as wasmDecompress,
|
|
7
|
+
Decompressor as WasmDecompressor,
|
|
8
|
+
decompressWithDict as wasmDecompressWithDict,
|
|
9
|
+
Dictionary as _Dictionary,
|
|
10
|
+
initSync,
|
|
11
|
+
} from "./pkg/zrip_wasm.js";
|
|
12
|
+
|
|
13
|
+
export const Compressor = _Compressor;
|
|
14
|
+
export const Dictionary = _Dictionary;
|
|
15
|
+
|
|
16
|
+
const MAX_WASM_USIZE = 0xffff_ffff;
|
|
17
|
+
|
|
18
|
+
function maxDecompressedSize(options) {
|
|
19
|
+
const max = options?.maxDecompressedSize;
|
|
20
|
+
if (max === undefined) return undefined;
|
|
21
|
+
if (!Number.isSafeInteger(max) || max < 0 || max > MAX_WASM_USIZE) {
|
|
22
|
+
throw new RangeError(
|
|
23
|
+
"maxDecompressedSize must be an integer from 0 to 4294967295",
|
|
24
|
+
);
|
|
25
|
+
}
|
|
26
|
+
return max;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
const decompressorInner = new WeakMap();
|
|
30
|
+
|
|
31
|
+
function getDecompressorInner(decompressor) {
|
|
32
|
+
const inner = decompressorInner.get(decompressor);
|
|
33
|
+
if (!inner) {
|
|
34
|
+
throw new TypeError("invalid or freed Decompressor");
|
|
35
|
+
}
|
|
36
|
+
return inner;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export class Decompressor {
|
|
40
|
+
constructor() {
|
|
41
|
+
decompressorInner.set(this, new WasmDecompressor());
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
static withDict(dict) {
|
|
45
|
+
const decompressor = new Decompressor();
|
|
46
|
+
getDecompressorInner(decompressor).free();
|
|
47
|
+
decompressorInner.set(decompressor, WasmDecompressor.withDict(dict));
|
|
48
|
+
return decompressor;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
decompress(input, options) {
|
|
52
|
+
return getDecompressorInner(this).decompress(
|
|
53
|
+
input,
|
|
54
|
+
maxDecompressedSize(options),
|
|
55
|
+
);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
free() {
|
|
59
|
+
const inner = decompressorInner.get(this);
|
|
60
|
+
if (!inner) return;
|
|
61
|
+
decompressorInner.delete(this);
|
|
62
|
+
inner.free();
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
[Symbol.dispose]() {
|
|
66
|
+
this.free();
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
const SIMD_TEST = new Uint8Array([
|
|
71
|
+
0x00,
|
|
72
|
+
0x61,
|
|
73
|
+
0x73,
|
|
74
|
+
0x6d,
|
|
75
|
+
0x01,
|
|
76
|
+
0x00,
|
|
77
|
+
0x00,
|
|
78
|
+
0x00,
|
|
79
|
+
0x01,
|
|
80
|
+
0x05,
|
|
81
|
+
0x01,
|
|
82
|
+
0x60,
|
|
83
|
+
0x00,
|
|
84
|
+
0x01,
|
|
85
|
+
0x7b,
|
|
86
|
+
0x03,
|
|
87
|
+
0x02,
|
|
88
|
+
0x01,
|
|
89
|
+
0x00,
|
|
90
|
+
0x0a,
|
|
91
|
+
0x0a,
|
|
92
|
+
0x01,
|
|
93
|
+
0x08,
|
|
94
|
+
0x00,
|
|
95
|
+
0x41,
|
|
96
|
+
0x00,
|
|
97
|
+
0xfd,
|
|
98
|
+
0x0f,
|
|
99
|
+
0xfd,
|
|
100
|
+
0x62,
|
|
101
|
+
0x0b,
|
|
102
|
+
]);
|
|
103
|
+
|
|
104
|
+
let initialized = false;
|
|
105
|
+
|
|
106
|
+
async function loadWasmBytes(url) {
|
|
107
|
+
if (url.protocol === "file:" && globalThis.process?.versions?.node) {
|
|
108
|
+
const { readFile } = await import("node:fs/promises");
|
|
109
|
+
return readFile(url);
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
const response = await fetch(url);
|
|
113
|
+
if (!response.ok) {
|
|
114
|
+
throw new Error(`failed to fetch ${url}: HTTP ${response.status}`);
|
|
115
|
+
}
|
|
116
|
+
return response.arrayBuffer();
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
export async function init() {
|
|
120
|
+
if (initialized) return;
|
|
121
|
+
|
|
122
|
+
const simd = WebAssembly.validate(SIMD_TEST);
|
|
123
|
+
const wasmFile = simd ? "zrip_simd.wasm" : "zrip_wasm_bg.wasm";
|
|
124
|
+
const wasmUrl = new URL(`./pkg/${wasmFile}`, import.meta.url);
|
|
125
|
+
const bytes = await loadWasmBytes(wasmUrl);
|
|
126
|
+
initSync({ module: new WebAssembly.Module(bytes) });
|
|
127
|
+
initialized = true;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
export function initSyncFromBytes(bytes) {
|
|
131
|
+
if (initialized) return;
|
|
132
|
+
initSync({ module: new WebAssembly.Module(bytes) });
|
|
133
|
+
initialized = true;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
export function compress(input, level = 1) {
|
|
137
|
+
return wasmCompress(input, level);
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
export function decompress(input, options) {
|
|
141
|
+
return wasmDecompress(input, maxDecompressedSize(options));
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
export function compressBound(inputLen) {
|
|
145
|
+
return wasmCompressBound(inputLen);
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
export function compressWithDict(input, level, dict) {
|
|
149
|
+
return wasmCompressWithDict(input, level, dict);
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
export function decompressWithDict(input, dict, options) {
|
|
153
|
+
return wasmDecompressWithDict(input, dict, maxDecompressedSize(options));
|
|
154
|
+
}
|
|
Binary file
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
/* tslint:disable */
|
|
2
|
+
/* eslint-disable */
|
|
3
|
+
|
|
4
|
+
export class Compressor {
|
|
5
|
+
free(): void;
|
|
6
|
+
[Symbol.dispose](): void;
|
|
7
|
+
compress(input: Uint8Array): Uint8Array;
|
|
8
|
+
compressWithDict(input: Uint8Array, dict: Dictionary): Uint8Array;
|
|
9
|
+
constructor(level: number);
|
|
10
|
+
static withDict(level: number, dict: Dictionary): Compressor;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export class Decompressor {
|
|
14
|
+
free(): void;
|
|
15
|
+
[Symbol.dispose](): void;
|
|
16
|
+
decompress(input: Uint8Array, max_output_size?: number | null): Uint8Array;
|
|
17
|
+
constructor();
|
|
18
|
+
static withDict(dict: Dictionary): Decompressor;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export class Dictionary {
|
|
22
|
+
free(): void;
|
|
23
|
+
[Symbol.dispose](): void;
|
|
24
|
+
constructor(data: Uint8Array);
|
|
25
|
+
readonly id: number;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export function compress(input: Uint8Array, level: number): Uint8Array;
|
|
29
|
+
|
|
30
|
+
export function compressBound(input_len: number): number;
|
|
31
|
+
|
|
32
|
+
export function compressWithDict(input: Uint8Array, level: number, dict: Dictionary): Uint8Array;
|
|
33
|
+
|
|
34
|
+
export function decompress(input: Uint8Array, max_output_size?: number | null): Uint8Array;
|
|
35
|
+
|
|
36
|
+
export function decompressWithDict(input: Uint8Array, dict: Dictionary, max_output_size?: number | null): Uint8Array;
|
|
37
|
+
|
|
38
|
+
export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembly.Module;
|
|
39
|
+
|
|
40
|
+
export interface InitOutput {
|
|
41
|
+
readonly memory: WebAssembly.Memory;
|
|
42
|
+
readonly __wbg_compressor_free: (a: number, b: number) => void;
|
|
43
|
+
readonly __wbg_decompressor_free: (a: number, b: number) => void;
|
|
44
|
+
readonly __wbg_dictionary_free: (a: number, b: number) => void;
|
|
45
|
+
readonly compress: (a: number, b: number, c: number, d: number) => void;
|
|
46
|
+
readonly compressBound: (a: number) => number;
|
|
47
|
+
readonly compressWithDict: (a: number, b: number, c: number, d: number, e: number) => void;
|
|
48
|
+
readonly compressor_compress: (a: number, b: number, c: number, d: number) => void;
|
|
49
|
+
readonly compressor_compressWithDict: (a: number, b: number, c: number, d: number, e: number) => void;
|
|
50
|
+
readonly compressor_new: (a: number, b: number) => void;
|
|
51
|
+
readonly compressor_withDict: (a: number, b: number, c: number) => void;
|
|
52
|
+
readonly decompress: (a: number, b: number, c: number, d: number) => void;
|
|
53
|
+
readonly decompressWithDict: (a: number, b: number, c: number, d: number, e: 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) => number;
|
|
57
|
+
readonly dictionary_id: (a: number) => number;
|
|
58
|
+
readonly dictionary_new: (a: number, b: number, c: number) => void;
|
|
59
|
+
readonly __wbindgen_add_to_stack_pointer: (a: number) => number;
|
|
60
|
+
readonly __wbindgen_export: (a: number, b: number) => number;
|
|
61
|
+
readonly __wbindgen_export2: (a: number, b: number, c: number) => void;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
export type SyncInitInput = BufferSource | WebAssembly.Module;
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* Instantiates the given `module`, which can either be bytes or
|
|
68
|
+
* a precompiled `WebAssembly.Module`.
|
|
69
|
+
*
|
|
70
|
+
* @param {{ module: SyncInitInput }} module - Passing `SyncInitInput` directly is deprecated.
|
|
71
|
+
*
|
|
72
|
+
* @returns {InitOutput}
|
|
73
|
+
*/
|
|
74
|
+
export function initSync(module: { module: SyncInitInput } | SyncInitInput): InitOutput;
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* If `module_or_path` is {RequestInfo} or {URL}, makes a request and
|
|
78
|
+
* for everything else, calls `WebAssembly.instantiate` directly.
|
|
79
|
+
*
|
|
80
|
+
* @param {{ module_or_path: InitInput | Promise<InitInput> }} module_or_path - Passing `InitInput` directly is deprecated.
|
|
81
|
+
*
|
|
82
|
+
* @returns {Promise<InitOutput>}
|
|
83
|
+
*/
|
|
84
|
+
export default function __wbg_init (module_or_path?: { module_or_path: InitInput | Promise<InitInput> } | InitInput | Promise<InitInput>): Promise<InitOutput>;
|
|
@@ -0,0 +1,541 @@
|
|
|
1
|
+
/* @ts-self-types="./zrip_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 r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
33
|
+
var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
|
|
34
|
+
if (r3) {
|
|
35
|
+
throw takeObject(r2);
|
|
36
|
+
}
|
|
37
|
+
var v2 = getArrayU8FromWasm0(r0, r1).slice();
|
|
38
|
+
wasm.__wbindgen_export2(r0, r1 * 1, 1);
|
|
39
|
+
return v2;
|
|
40
|
+
} finally {
|
|
41
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* @param {Uint8Array} input
|
|
46
|
+
* @param {Dictionary} dict
|
|
47
|
+
* @returns {Uint8Array}
|
|
48
|
+
*/
|
|
49
|
+
compressWithDict(input, dict) {
|
|
50
|
+
try {
|
|
51
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
52
|
+
const ptr0 = passArray8ToWasm0(input, wasm.__wbindgen_export);
|
|
53
|
+
const len0 = WASM_VECTOR_LEN;
|
|
54
|
+
_assertClass(dict, Dictionary);
|
|
55
|
+
wasm.compressor_compressWithDict(retptr, this.__wbg_ptr, ptr0, len0, dict.__wbg_ptr);
|
|
56
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
57
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
58
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
59
|
+
var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
|
|
60
|
+
if (r3) {
|
|
61
|
+
throw takeObject(r2);
|
|
62
|
+
}
|
|
63
|
+
var v2 = getArrayU8FromWasm0(r0, r1).slice();
|
|
64
|
+
wasm.__wbindgen_export2(r0, r1 * 1, 1);
|
|
65
|
+
return v2;
|
|
66
|
+
} finally {
|
|
67
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* @param {number} level
|
|
72
|
+
*/
|
|
73
|
+
constructor(level) {
|
|
74
|
+
try {
|
|
75
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
76
|
+
wasm.compressor_new(retptr, level);
|
|
77
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
78
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
79
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
80
|
+
if (r2) {
|
|
81
|
+
throw takeObject(r1);
|
|
82
|
+
}
|
|
83
|
+
this.__wbg_ptr = r0;
|
|
84
|
+
CompressorFinalization.register(this, this.__wbg_ptr, this);
|
|
85
|
+
return this;
|
|
86
|
+
} finally {
|
|
87
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* @param {number} level
|
|
92
|
+
* @param {Dictionary} dict
|
|
93
|
+
* @returns {Compressor}
|
|
94
|
+
*/
|
|
95
|
+
static withDict(level, dict) {
|
|
96
|
+
try {
|
|
97
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
98
|
+
_assertClass(dict, Dictionary);
|
|
99
|
+
wasm.compressor_withDict(retptr, level, dict.__wbg_ptr);
|
|
100
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
101
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
102
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
103
|
+
if (r2) {
|
|
104
|
+
throw takeObject(r1);
|
|
105
|
+
}
|
|
106
|
+
return Compressor.__wrap(r0);
|
|
107
|
+
} finally {
|
|
108
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
if (Symbol.dispose) Compressor.prototype[Symbol.dispose] = Compressor.prototype.free;
|
|
113
|
+
|
|
114
|
+
export class Decompressor {
|
|
115
|
+
static __wrap(ptr) {
|
|
116
|
+
const obj = Object.create(Decompressor.prototype);
|
|
117
|
+
obj.__wbg_ptr = ptr;
|
|
118
|
+
DecompressorFinalization.register(obj, obj.__wbg_ptr, obj);
|
|
119
|
+
return obj;
|
|
120
|
+
}
|
|
121
|
+
__destroy_into_raw() {
|
|
122
|
+
const ptr = this.__wbg_ptr;
|
|
123
|
+
this.__wbg_ptr = 0;
|
|
124
|
+
DecompressorFinalization.unregister(this);
|
|
125
|
+
return ptr;
|
|
126
|
+
}
|
|
127
|
+
free() {
|
|
128
|
+
const ptr = this.__destroy_into_raw();
|
|
129
|
+
wasm.__wbg_decompressor_free(ptr, 0);
|
|
130
|
+
}
|
|
131
|
+
/**
|
|
132
|
+
* @param {Uint8Array} input
|
|
133
|
+
* @param {number | null} [max_output_size]
|
|
134
|
+
* @returns {Uint8Array}
|
|
135
|
+
*/
|
|
136
|
+
decompress(input, max_output_size) {
|
|
137
|
+
try {
|
|
138
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
139
|
+
const ptr0 = passArray8ToWasm0(input, wasm.__wbindgen_export);
|
|
140
|
+
const len0 = WASM_VECTOR_LEN;
|
|
141
|
+
wasm.decompressor_decompress(retptr, this.__wbg_ptr, ptr0, len0, isLikeNone(max_output_size) ? Number.MAX_SAFE_INTEGER : (max_output_size) >>> 0);
|
|
142
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
143
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
144
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
145
|
+
var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
|
|
146
|
+
if (r3) {
|
|
147
|
+
throw takeObject(r2);
|
|
148
|
+
}
|
|
149
|
+
var v2 = getArrayU8FromWasm0(r0, r1).slice();
|
|
150
|
+
wasm.__wbindgen_export2(r0, r1 * 1, 1);
|
|
151
|
+
return v2;
|
|
152
|
+
} finally {
|
|
153
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
constructor() {
|
|
157
|
+
const ret = wasm.decompressor_new();
|
|
158
|
+
this.__wbg_ptr = ret;
|
|
159
|
+
DecompressorFinalization.register(this, this.__wbg_ptr, this);
|
|
160
|
+
return this;
|
|
161
|
+
}
|
|
162
|
+
/**
|
|
163
|
+
* @param {Dictionary} dict
|
|
164
|
+
* @returns {Decompressor}
|
|
165
|
+
*/
|
|
166
|
+
static withDict(dict) {
|
|
167
|
+
_assertClass(dict, Dictionary);
|
|
168
|
+
const ret = wasm.decompressor_withDict(dict.__wbg_ptr);
|
|
169
|
+
return Decompressor.__wrap(ret);
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
if (Symbol.dispose) Decompressor.prototype[Symbol.dispose] = Decompressor.prototype.free;
|
|
173
|
+
|
|
174
|
+
export class Dictionary {
|
|
175
|
+
__destroy_into_raw() {
|
|
176
|
+
const ptr = this.__wbg_ptr;
|
|
177
|
+
this.__wbg_ptr = 0;
|
|
178
|
+
DictionaryFinalization.unregister(this);
|
|
179
|
+
return ptr;
|
|
180
|
+
}
|
|
181
|
+
free() {
|
|
182
|
+
const ptr = this.__destroy_into_raw();
|
|
183
|
+
wasm.__wbg_dictionary_free(ptr, 0);
|
|
184
|
+
}
|
|
185
|
+
/**
|
|
186
|
+
* @returns {number}
|
|
187
|
+
*/
|
|
188
|
+
get id() {
|
|
189
|
+
const ret = wasm.dictionary_id(this.__wbg_ptr);
|
|
190
|
+
return ret >>> 0;
|
|
191
|
+
}
|
|
192
|
+
/**
|
|
193
|
+
* @param {Uint8Array} data
|
|
194
|
+
*/
|
|
195
|
+
constructor(data) {
|
|
196
|
+
try {
|
|
197
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
198
|
+
const ptr0 = passArray8ToWasm0(data, wasm.__wbindgen_export);
|
|
199
|
+
const len0 = WASM_VECTOR_LEN;
|
|
200
|
+
wasm.dictionary_new(retptr, ptr0, len0);
|
|
201
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
202
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
203
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
204
|
+
if (r2) {
|
|
205
|
+
throw takeObject(r1);
|
|
206
|
+
}
|
|
207
|
+
this.__wbg_ptr = r0;
|
|
208
|
+
DictionaryFinalization.register(this, this.__wbg_ptr, this);
|
|
209
|
+
return this;
|
|
210
|
+
} finally {
|
|
211
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
if (Symbol.dispose) Dictionary.prototype[Symbol.dispose] = Dictionary.prototype.free;
|
|
216
|
+
|
|
217
|
+
/**
|
|
218
|
+
* @param {Uint8Array} input
|
|
219
|
+
* @param {number} level
|
|
220
|
+
* @returns {Uint8Array}
|
|
221
|
+
*/
|
|
222
|
+
export function compress(input, level) {
|
|
223
|
+
try {
|
|
224
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
225
|
+
const ptr0 = passArray8ToWasm0(input, wasm.__wbindgen_export);
|
|
226
|
+
const len0 = WASM_VECTOR_LEN;
|
|
227
|
+
wasm.compress(retptr, ptr0, len0, level);
|
|
228
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
229
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
230
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
231
|
+
var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
|
|
232
|
+
if (r3) {
|
|
233
|
+
throw takeObject(r2);
|
|
234
|
+
}
|
|
235
|
+
var v2 = getArrayU8FromWasm0(r0, r1).slice();
|
|
236
|
+
wasm.__wbindgen_export2(r0, r1 * 1, 1);
|
|
237
|
+
return v2;
|
|
238
|
+
} finally {
|
|
239
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
/**
|
|
244
|
+
* @param {number} input_len
|
|
245
|
+
* @returns {number}
|
|
246
|
+
*/
|
|
247
|
+
export function compressBound(input_len) {
|
|
248
|
+
const ret = wasm.compressBound(input_len);
|
|
249
|
+
return ret >>> 0;
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
/**
|
|
253
|
+
* @param {Uint8Array} input
|
|
254
|
+
* @param {number} level
|
|
255
|
+
* @param {Dictionary} dict
|
|
256
|
+
* @returns {Uint8Array}
|
|
257
|
+
*/
|
|
258
|
+
export function compressWithDict(input, level, dict) {
|
|
259
|
+
try {
|
|
260
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
261
|
+
const ptr0 = passArray8ToWasm0(input, wasm.__wbindgen_export);
|
|
262
|
+
const len0 = WASM_VECTOR_LEN;
|
|
263
|
+
_assertClass(dict, Dictionary);
|
|
264
|
+
wasm.compressWithDict(retptr, ptr0, len0, level, dict.__wbg_ptr);
|
|
265
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
266
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
267
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
268
|
+
var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
|
|
269
|
+
if (r3) {
|
|
270
|
+
throw takeObject(r2);
|
|
271
|
+
}
|
|
272
|
+
var v2 = getArrayU8FromWasm0(r0, r1).slice();
|
|
273
|
+
wasm.__wbindgen_export2(r0, r1 * 1, 1);
|
|
274
|
+
return v2;
|
|
275
|
+
} finally {
|
|
276
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
/**
|
|
281
|
+
* @param {Uint8Array} input
|
|
282
|
+
* @param {number | null} [max_output_size]
|
|
283
|
+
* @returns {Uint8Array}
|
|
284
|
+
*/
|
|
285
|
+
export function decompress(input, max_output_size) {
|
|
286
|
+
try {
|
|
287
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
288
|
+
const ptr0 = passArray8ToWasm0(input, wasm.__wbindgen_export);
|
|
289
|
+
const len0 = WASM_VECTOR_LEN;
|
|
290
|
+
wasm.decompress(retptr, ptr0, len0, isLikeNone(max_output_size) ? Number.MAX_SAFE_INTEGER : (max_output_size) >>> 0);
|
|
291
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
292
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
293
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
294
|
+
var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
|
|
295
|
+
if (r3) {
|
|
296
|
+
throw takeObject(r2);
|
|
297
|
+
}
|
|
298
|
+
var v2 = getArrayU8FromWasm0(r0, r1).slice();
|
|
299
|
+
wasm.__wbindgen_export2(r0, r1 * 1, 1);
|
|
300
|
+
return v2;
|
|
301
|
+
} finally {
|
|
302
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
303
|
+
}
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
/**
|
|
307
|
+
* @param {Uint8Array} input
|
|
308
|
+
* @param {Dictionary} dict
|
|
309
|
+
* @param {number | null} [max_output_size]
|
|
310
|
+
* @returns {Uint8Array}
|
|
311
|
+
*/
|
|
312
|
+
export function decompressWithDict(input, dict, max_output_size) {
|
|
313
|
+
try {
|
|
314
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
315
|
+
const ptr0 = passArray8ToWasm0(input, wasm.__wbindgen_export);
|
|
316
|
+
const len0 = WASM_VECTOR_LEN;
|
|
317
|
+
_assertClass(dict, Dictionary);
|
|
318
|
+
wasm.decompressWithDict(retptr, ptr0, len0, dict.__wbg_ptr, isLikeNone(max_output_size) ? Number.MAX_SAFE_INTEGER : (max_output_size) >>> 0);
|
|
319
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
320
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
321
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
322
|
+
var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
|
|
323
|
+
if (r3) {
|
|
324
|
+
throw takeObject(r2);
|
|
325
|
+
}
|
|
326
|
+
var v2 = getArrayU8FromWasm0(r0, r1).slice();
|
|
327
|
+
wasm.__wbindgen_export2(r0, r1 * 1, 1);
|
|
328
|
+
return v2;
|
|
329
|
+
} finally {
|
|
330
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
331
|
+
}
|
|
332
|
+
}
|
|
333
|
+
function __wbg_get_imports() {
|
|
334
|
+
const import0 = {
|
|
335
|
+
__proto__: null,
|
|
336
|
+
__wbg_Error_408e67f47ca7b58b: function(arg0, arg1) {
|
|
337
|
+
const ret = Error(getStringFromWasm0(arg0, arg1));
|
|
338
|
+
return addHeapObject(ret);
|
|
339
|
+
},
|
|
340
|
+
__wbg___wbindgen_throw_bb96b2010945f0bc: function(arg0, arg1) {
|
|
341
|
+
throw new Error(getStringFromWasm0(arg0, arg1));
|
|
342
|
+
},
|
|
343
|
+
};
|
|
344
|
+
return {
|
|
345
|
+
__proto__: null,
|
|
346
|
+
"./zrip_wasm_bg.js": import0,
|
|
347
|
+
};
|
|
348
|
+
}
|
|
349
|
+
|
|
350
|
+
const CompressorFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
351
|
+
? { register: () => {}, unregister: () => {} }
|
|
352
|
+
: new FinalizationRegistry(ptr => wasm.__wbg_compressor_free(ptr, 1));
|
|
353
|
+
const DecompressorFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
354
|
+
? { register: () => {}, unregister: () => {} }
|
|
355
|
+
: new FinalizationRegistry(ptr => wasm.__wbg_decompressor_free(ptr, 1));
|
|
356
|
+
const DictionaryFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
357
|
+
? { register: () => {}, unregister: () => {} }
|
|
358
|
+
: new FinalizationRegistry(ptr => wasm.__wbg_dictionary_free(ptr, 1));
|
|
359
|
+
|
|
360
|
+
function addHeapObject(obj) {
|
|
361
|
+
if (heap_next === heap.length) heap.push(heap.length + 1);
|
|
362
|
+
const idx = heap_next;
|
|
363
|
+
heap_next = heap[idx];
|
|
364
|
+
|
|
365
|
+
heap[idx] = obj;
|
|
366
|
+
return idx;
|
|
367
|
+
}
|
|
368
|
+
|
|
369
|
+
function _assertClass(instance, klass) {
|
|
370
|
+
if (!(instance instanceof klass)) {
|
|
371
|
+
throw new Error(`expected instance of ${klass.name}`);
|
|
372
|
+
}
|
|
373
|
+
}
|
|
374
|
+
|
|
375
|
+
function dropObject(idx) {
|
|
376
|
+
if (idx < 1028) return;
|
|
377
|
+
heap[idx] = heap_next;
|
|
378
|
+
heap_next = idx;
|
|
379
|
+
}
|
|
380
|
+
|
|
381
|
+
function getArrayU8FromWasm0(ptr, len) {
|
|
382
|
+
ptr = ptr >>> 0;
|
|
383
|
+
return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
|
|
384
|
+
}
|
|
385
|
+
|
|
386
|
+
let cachedDataViewMemory0 = null;
|
|
387
|
+
function getDataViewMemory0() {
|
|
388
|
+
if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || (cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm.memory.buffer)) {
|
|
389
|
+
cachedDataViewMemory0 = new DataView(wasm.memory.buffer);
|
|
390
|
+
}
|
|
391
|
+
return cachedDataViewMemory0;
|
|
392
|
+
}
|
|
393
|
+
|
|
394
|
+
function getStringFromWasm0(ptr, len) {
|
|
395
|
+
return decodeText(ptr >>> 0, len);
|
|
396
|
+
}
|
|
397
|
+
|
|
398
|
+
let cachedUint8ArrayMemory0 = null;
|
|
399
|
+
function getUint8ArrayMemory0() {
|
|
400
|
+
if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
|
|
401
|
+
cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
|
|
402
|
+
}
|
|
403
|
+
return cachedUint8ArrayMemory0;
|
|
404
|
+
}
|
|
405
|
+
|
|
406
|
+
function getObject(idx) { return heap[idx]; }
|
|
407
|
+
|
|
408
|
+
let heap = new Array(1024).fill(undefined);
|
|
409
|
+
heap.push(undefined, null, true, false);
|
|
410
|
+
|
|
411
|
+
let heap_next = heap.length;
|
|
412
|
+
|
|
413
|
+
function isLikeNone(x) {
|
|
414
|
+
return x === undefined || x === null;
|
|
415
|
+
}
|
|
416
|
+
|
|
417
|
+
function passArray8ToWasm0(arg, malloc) {
|
|
418
|
+
const ptr = malloc(arg.length * 1, 1) >>> 0;
|
|
419
|
+
getUint8ArrayMemory0().set(arg, ptr / 1);
|
|
420
|
+
WASM_VECTOR_LEN = arg.length;
|
|
421
|
+
return ptr;
|
|
422
|
+
}
|
|
423
|
+
|
|
424
|
+
function takeObject(idx) {
|
|
425
|
+
const ret = getObject(idx);
|
|
426
|
+
dropObject(idx);
|
|
427
|
+
return ret;
|
|
428
|
+
}
|
|
429
|
+
|
|
430
|
+
let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
|
|
431
|
+
cachedTextDecoder.decode();
|
|
432
|
+
const MAX_SAFARI_DECODE_BYTES = 2146435072;
|
|
433
|
+
let numBytesDecoded = 0;
|
|
434
|
+
function decodeText(ptr, len) {
|
|
435
|
+
numBytesDecoded += len;
|
|
436
|
+
if (numBytesDecoded >= MAX_SAFARI_DECODE_BYTES) {
|
|
437
|
+
cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
|
|
438
|
+
cachedTextDecoder.decode();
|
|
439
|
+
numBytesDecoded = len;
|
|
440
|
+
}
|
|
441
|
+
return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
|
|
442
|
+
}
|
|
443
|
+
|
|
444
|
+
let WASM_VECTOR_LEN = 0;
|
|
445
|
+
|
|
446
|
+
let wasmModule, wasmInstance, wasm;
|
|
447
|
+
function __wbg_finalize_init(instance, module) {
|
|
448
|
+
wasmInstance = instance;
|
|
449
|
+
wasm = instance.exports;
|
|
450
|
+
wasmModule = module;
|
|
451
|
+
cachedDataViewMemory0 = null;
|
|
452
|
+
cachedUint8ArrayMemory0 = null;
|
|
453
|
+
return wasm;
|
|
454
|
+
}
|
|
455
|
+
|
|
456
|
+
async function __wbg_load(module, imports) {
|
|
457
|
+
if (typeof Response === 'function' && module instanceof Response) {
|
|
458
|
+
if (!module.ok) {
|
|
459
|
+
throw new Error(`failed to fetch Wasm: ${module.status} ${module.statusText} fetching '${module.url}'`);
|
|
460
|
+
}
|
|
461
|
+
|
|
462
|
+
if (typeof WebAssembly.instantiateStreaming === 'function') {
|
|
463
|
+
try {
|
|
464
|
+
return await WebAssembly.instantiateStreaming(module, imports);
|
|
465
|
+
} catch (e) {
|
|
466
|
+
const validResponse = expectedResponseType(module.type);
|
|
467
|
+
|
|
468
|
+
if (validResponse && module.headers.get('Content-Type') !== 'application/wasm') {
|
|
469
|
+
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);
|
|
470
|
+
|
|
471
|
+
} else { throw e; }
|
|
472
|
+
}
|
|
473
|
+
}
|
|
474
|
+
|
|
475
|
+
const bytes = await module.arrayBuffer();
|
|
476
|
+
return await WebAssembly.instantiate(bytes, imports);
|
|
477
|
+
} else {
|
|
478
|
+
const instance = await WebAssembly.instantiate(module, imports);
|
|
479
|
+
|
|
480
|
+
if (instance instanceof WebAssembly.Instance) {
|
|
481
|
+
return { instance, module };
|
|
482
|
+
} else {
|
|
483
|
+
return instance;
|
|
484
|
+
}
|
|
485
|
+
}
|
|
486
|
+
|
|
487
|
+
function expectedResponseType(type) {
|
|
488
|
+
switch (type) {
|
|
489
|
+
case 'basic': case 'cors': case 'default': return true;
|
|
490
|
+
}
|
|
491
|
+
return false;
|
|
492
|
+
}
|
|
493
|
+
}
|
|
494
|
+
|
|
495
|
+
function initSync(module) {
|
|
496
|
+
if (wasm !== undefined) return wasm;
|
|
497
|
+
|
|
498
|
+
|
|
499
|
+
if (module !== undefined) {
|
|
500
|
+
if (Object.getPrototypeOf(module) === Object.prototype) {
|
|
501
|
+
({module} = module)
|
|
502
|
+
} else {
|
|
503
|
+
console.warn('using deprecated parameters for `initSync()`; pass a single object instead')
|
|
504
|
+
}
|
|
505
|
+
}
|
|
506
|
+
|
|
507
|
+
const imports = __wbg_get_imports();
|
|
508
|
+
if (!(module instanceof WebAssembly.Module)) {
|
|
509
|
+
module = new WebAssembly.Module(module);
|
|
510
|
+
}
|
|
511
|
+
const instance = new WebAssembly.Instance(module, imports);
|
|
512
|
+
return __wbg_finalize_init(instance, module);
|
|
513
|
+
}
|
|
514
|
+
|
|
515
|
+
async function __wbg_init(module_or_path) {
|
|
516
|
+
if (wasm !== undefined) return wasm;
|
|
517
|
+
|
|
518
|
+
|
|
519
|
+
if (module_or_path !== undefined) {
|
|
520
|
+
if (Object.getPrototypeOf(module_or_path) === Object.prototype) {
|
|
521
|
+
({module_or_path} = module_or_path)
|
|
522
|
+
} else {
|
|
523
|
+
console.warn('using deprecated parameters for the initialization function; pass a single object instead')
|
|
524
|
+
}
|
|
525
|
+
}
|
|
526
|
+
|
|
527
|
+
if (module_or_path === undefined) {
|
|
528
|
+
module_or_path = new URL('zrip_wasm_bg.wasm', import.meta.url);
|
|
529
|
+
}
|
|
530
|
+
const imports = __wbg_get_imports();
|
|
531
|
+
|
|
532
|
+
if (typeof module_or_path === 'string' || (typeof Request === 'function' && module_or_path instanceof Request) || (typeof URL === 'function' && module_or_path instanceof URL)) {
|
|
533
|
+
module_or_path = fetch(module_or_path);
|
|
534
|
+
}
|
|
535
|
+
|
|
536
|
+
const { instance, module } = await __wbg_load(await module_or_path, imports);
|
|
537
|
+
|
|
538
|
+
return __wbg_finalize_init(instance, module);
|
|
539
|
+
}
|
|
540
|
+
|
|
541
|
+
export { initSync, __wbg_init as default };
|
|
Binary file
|
|
@@ -0,0 +1,23 @@
|
|
|
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_dictionary_free: (a: number, b: number) => void;
|
|
7
|
+
export const compress: (a: number, b: number, c: number, d: number) => void;
|
|
8
|
+
export const compressBound: (a: number) => number;
|
|
9
|
+
export const compressWithDict: (a: number, b: number, c: number, d: number, e: number) => void;
|
|
10
|
+
export const compressor_compress: (a: number, b: number, c: number, d: number) => void;
|
|
11
|
+
export const compressor_compressWithDict: (a: number, b: number, c: number, d: number, e: number) => void;
|
|
12
|
+
export const compressor_new: (a: number, b: number) => void;
|
|
13
|
+
export const compressor_withDict: (a: number, b: number, c: number) => void;
|
|
14
|
+
export const decompress: (a: number, b: number, c: number, d: number) => void;
|
|
15
|
+
export const decompressWithDict: (a: number, b: number, c: number, d: number, e: number) => void;
|
|
16
|
+
export const decompressor_decompress: (a: number, b: number, c: number, d: number, e: number) => void;
|
|
17
|
+
export const decompressor_new: () => number;
|
|
18
|
+
export const decompressor_withDict: (a: number) => number;
|
|
19
|
+
export const dictionary_id: (a: number) => number;
|
|
20
|
+
export const dictionary_new: (a: number, b: number, c: number) => void;
|
|
21
|
+
export const __wbindgen_add_to_stack_pointer: (a: number) => number;
|
|
22
|
+
export const __wbindgen_export: (a: number, b: number) => number;
|
|
23
|
+
export const __wbindgen_export2: (a: number, b: number, c: number) => void;
|