@uruhalushia/rule-converter-wasm 0.0.0 → 0.1.2
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/README.md +114 -1
- package/package.json +20 -10
- package/rule_converter_wasm.d.ts +6 -0
- package/rule_converter_wasm.js +9 -0
- package/rule_converter_wasm_bg.js +381 -0
- package/rule_converter_wasm_bg.wasm +0 -0
- package/index.js +0 -1
package/README.md
CHANGED
|
@@ -1,3 +1,116 @@
|
|
|
1
1
|
# @uruhalushia/rule-converter-wasm
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
WebAssembly bindings for browser usage. This package exposes payload-based conversion only; file and directory APIs stay in the CLI/N-API packages.
|
|
4
|
+
|
|
5
|
+
## Build
|
|
6
|
+
|
|
7
|
+
Install the wasm target and `wasm-pack` first:
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
rustup target add wasm32-unknown-unknown
|
|
11
|
+
cargo install wasm-pack
|
|
12
|
+
pnpm --dir wasm build
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
The build scripts pass `--no-opt` because current Rust emits bulk-memory instructions that older bundled `wasm-opt` builds may reject. Browser runtimes support these instructions.
|
|
16
|
+
|
|
17
|
+
For bundlers such as Vite/Webpack:
|
|
18
|
+
|
|
19
|
+
```bash
|
|
20
|
+
pnpm --dir wasm build:bundler
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
## Local Usage After Build
|
|
24
|
+
|
|
25
|
+
After running `pnpm --dir wasm build`, the browser-ready package is generated in `wasm/pkg`. The files in `pkg` are ignored by git and can be served directly during local development.
|
|
26
|
+
|
|
27
|
+
### Browser Without A Bundler
|
|
28
|
+
|
|
29
|
+
Create an HTML file outside `pkg`, then import the generated module by relative path:
|
|
30
|
+
|
|
31
|
+
```html
|
|
32
|
+
<!doctype html>
|
|
33
|
+
<meta charset="utf-8" />
|
|
34
|
+
<button id="convert">convert</button>
|
|
35
|
+
<script type="module">
|
|
36
|
+
import init, { convertPayloadString } from './wasm/pkg/rule_converter_wasm.js'
|
|
37
|
+
|
|
38
|
+
await init()
|
|
39
|
+
|
|
40
|
+
document.querySelector('#convert').addEventListener('click', () => {
|
|
41
|
+
const result = convertPayloadString(
|
|
42
|
+
`payload:\n - DOMAIN,example.com\n - DOMAIN-SUFFIX,example.net\n`,
|
|
43
|
+
{
|
|
44
|
+
inputTarget: 'mihomo',
|
|
45
|
+
inputFormat: 'yaml',
|
|
46
|
+
inputBehavior: 'classical',
|
|
47
|
+
outputTarget: 'mihomo',
|
|
48
|
+
outputFormat: 'mrs',
|
|
49
|
+
outputBehavior: 'domain',
|
|
50
|
+
},
|
|
51
|
+
)
|
|
52
|
+
|
|
53
|
+
const output = result.outputs[0]
|
|
54
|
+
console.log(output.behavior, output.format, output.count, output.bytes)
|
|
55
|
+
})
|
|
56
|
+
</script>
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
Serve the repository directory with any static server; opening the file directly with `file://` usually fails because WebAssembly modules are fetched asynchronously.
|
|
60
|
+
|
|
61
|
+
```bash
|
|
62
|
+
python -m http.server 5173
|
|
63
|
+
# open http://localhost:5173/your-test.html
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
### Bundler / Vite / Webpack
|
|
67
|
+
|
|
68
|
+
Build the bundler package first:
|
|
69
|
+
|
|
70
|
+
```bash
|
|
71
|
+
pnpm --dir wasm build:bundler
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
Then install the generated local package in your web app:
|
|
75
|
+
|
|
76
|
+
```bash
|
|
77
|
+
pnpm add file:/home/atri/git/xishang/rule-converter/wasm/pkg
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
Use it from app code:
|
|
81
|
+
|
|
82
|
+
```js
|
|
83
|
+
import init, { convertPayloadString } from '@uruhalushia/rule-converter-wasm'
|
|
84
|
+
|
|
85
|
+
await init()
|
|
86
|
+
|
|
87
|
+
const result = convertPayloadString(
|
|
88
|
+
`payload:\n - DOMAIN,example.com\n - DOMAIN-SUFFIX,example.net\n`,
|
|
89
|
+
{
|
|
90
|
+
inputTarget: 'mihomo',
|
|
91
|
+
inputFormat: 'yaml',
|
|
92
|
+
inputBehavior: 'classical',
|
|
93
|
+
outputTarget: 'mihomo',
|
|
94
|
+
outputFormat: 'mrs',
|
|
95
|
+
outputBehavior: 'domain',
|
|
96
|
+
},
|
|
97
|
+
)
|
|
98
|
+
|
|
99
|
+
for (const output of result.outputs) {
|
|
100
|
+
console.log(output.behavior, output.format, output.count, output.bytes)
|
|
101
|
+
}
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
The returned `bytes` value is a `Uint8Array`, so it can be downloaded, uploaded, or stored in IndexedDB directly.
|
|
105
|
+
|
|
106
|
+
Options use the same names as the N-API package:
|
|
107
|
+
|
|
108
|
+
```ts
|
|
109
|
+
type RuleTarget = 'mihomo' | 'general' | 'egern' | 'sing-box'
|
|
110
|
+
type InputFormat = 'yaml' | 'mrs' | 'text' | 'json' | 'srs'
|
|
111
|
+
type OutputFormat = 'mrs' | 'text' | 'yaml' | 'json' | 'srs' | 'domainset' | 'ruleset' | 'ipset'
|
|
112
|
+
type InputBehavior = 'auto' | 'domain' | 'ip' | 'classical'
|
|
113
|
+
type OutputBehavior = 'domain' | 'ip' | 'classical'
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
Defaults are `outputTarget: 'mihomo'`, `outputFormat: 'mrs'`, and `outputBehavior: 'domain'`.
|
package/package.json
CHANGED
|
@@ -1,16 +1,26 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@uruhalushia/rule-converter-wasm",
|
|
3
|
-
"version": "0.0.0",
|
|
4
|
-
"description": "Placeholder package for repository setup.",
|
|
5
3
|
"type": "module",
|
|
6
|
-
"
|
|
4
|
+
"version": "0.1.2",
|
|
7
5
|
"files": [
|
|
8
|
-
"
|
|
9
|
-
"
|
|
6
|
+
"rule_converter_wasm_bg.wasm",
|
|
7
|
+
"rule_converter_wasm.js",
|
|
8
|
+
"rule_converter_wasm_bg.js",
|
|
9
|
+
"rule_converter_wasm.d.ts"
|
|
10
10
|
],
|
|
11
|
-
"
|
|
12
|
-
"
|
|
13
|
-
|
|
14
|
-
"
|
|
15
|
-
|
|
11
|
+
"main": "rule_converter_wasm.js",
|
|
12
|
+
"types": "rule_converter_wasm.d.ts",
|
|
13
|
+
"sideEffects": [
|
|
14
|
+
"./rule_converter_wasm.js",
|
|
15
|
+
"./snippets/*"
|
|
16
|
+
],
|
|
17
|
+
"repository": {
|
|
18
|
+
"type": "git",
|
|
19
|
+
"url": "git+https://github.com/UruhaLushia/rule-converter.git"
|
|
20
|
+
},
|
|
21
|
+
"homepage": "https://github.com/UruhaLushia/rule-converter",
|
|
22
|
+
"bugs": {
|
|
23
|
+
"url": "https://github.com/UruhaLushia/rule-converter/issues"
|
|
24
|
+
},
|
|
25
|
+
"license": "GPL-3.0-only"
|
|
16
26
|
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/* @ts-self-types="./rule_converter_wasm.d.ts" */
|
|
2
|
+
import * as wasm from "./rule_converter_wasm_bg.wasm";
|
|
3
|
+
import { __wbg_set_wasm } from "./rule_converter_wasm_bg.js";
|
|
4
|
+
|
|
5
|
+
__wbg_set_wasm(wasm);
|
|
6
|
+
|
|
7
|
+
export {
|
|
8
|
+
convertPayload, convertPayloadString
|
|
9
|
+
} from "./rule_converter_wasm_bg.js";
|
|
@@ -0,0 +1,381 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @param {Uint8Array} payload
|
|
3
|
+
* @param {any} options
|
|
4
|
+
* @returns {any}
|
|
5
|
+
*/
|
|
6
|
+
export function convertPayload(payload, options) {
|
|
7
|
+
try {
|
|
8
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
9
|
+
const ptr0 = passArray8ToWasm0(payload, wasm.__wbindgen_export);
|
|
10
|
+
const len0 = WASM_VECTOR_LEN;
|
|
11
|
+
wasm.convertPayload(retptr, ptr0, len0, addHeapObject(options));
|
|
12
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
13
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
14
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
15
|
+
if (r2) {
|
|
16
|
+
throw takeObject(r1);
|
|
17
|
+
}
|
|
18
|
+
return takeObject(r0);
|
|
19
|
+
} finally {
|
|
20
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* @param {string} payload
|
|
26
|
+
* @param {any} options
|
|
27
|
+
* @returns {any}
|
|
28
|
+
*/
|
|
29
|
+
export function convertPayloadString(payload, options) {
|
|
30
|
+
try {
|
|
31
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
32
|
+
const ptr0 = passStringToWasm0(payload, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
33
|
+
const len0 = WASM_VECTOR_LEN;
|
|
34
|
+
wasm.convertPayloadString(retptr, ptr0, len0, addHeapObject(options));
|
|
35
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
36
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
37
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
38
|
+
if (r2) {
|
|
39
|
+
throw takeObject(r1);
|
|
40
|
+
}
|
|
41
|
+
return takeObject(r0);
|
|
42
|
+
} finally {
|
|
43
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
export function __wbg_Error_bce6d499ff0a4aff(arg0, arg1) {
|
|
47
|
+
const ret = Error(getStringFromWasm0(arg0, arg1));
|
|
48
|
+
return addHeapObject(ret);
|
|
49
|
+
}
|
|
50
|
+
export function __wbg_String_8564e559799eccda(arg0, arg1) {
|
|
51
|
+
const ret = String(getObject(arg1));
|
|
52
|
+
const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
53
|
+
const len1 = WASM_VECTOR_LEN;
|
|
54
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
|
|
55
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
|
|
56
|
+
}
|
|
57
|
+
export function __wbg___wbindgen_boolean_get_2304fb8c853028c8(arg0) {
|
|
58
|
+
const v = getObject(arg0);
|
|
59
|
+
const ret = typeof(v) === 'boolean' ? v : undefined;
|
|
60
|
+
return isLikeNone(ret) ? 0xFFFFFF : ret ? 1 : 0;
|
|
61
|
+
}
|
|
62
|
+
export function __wbg___wbindgen_debug_string_edece8177ad01481(arg0, arg1) {
|
|
63
|
+
const ret = debugString(getObject(arg1));
|
|
64
|
+
const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
65
|
+
const len1 = WASM_VECTOR_LEN;
|
|
66
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
|
|
67
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
|
|
68
|
+
}
|
|
69
|
+
export function __wbg___wbindgen_in_07056af4f902c445(arg0, arg1) {
|
|
70
|
+
const ret = getObject(arg0) in getObject(arg1);
|
|
71
|
+
return ret;
|
|
72
|
+
}
|
|
73
|
+
export function __wbg___wbindgen_is_null_2042690d351e14f0(arg0) {
|
|
74
|
+
const ret = getObject(arg0) === null;
|
|
75
|
+
return ret;
|
|
76
|
+
}
|
|
77
|
+
export function __wbg___wbindgen_is_object_b4593df85baada48(arg0) {
|
|
78
|
+
const val = getObject(arg0);
|
|
79
|
+
const ret = typeof(val) === 'object' && val !== null;
|
|
80
|
+
return ret;
|
|
81
|
+
}
|
|
82
|
+
export function __wbg___wbindgen_is_undefined_35bb9f4c7fd651d5(arg0) {
|
|
83
|
+
const ret = getObject(arg0) === undefined;
|
|
84
|
+
return ret;
|
|
85
|
+
}
|
|
86
|
+
export function __wbg___wbindgen_jsval_loose_eq_0ad77b7717db155c(arg0, arg1) {
|
|
87
|
+
const ret = getObject(arg0) == getObject(arg1);
|
|
88
|
+
return ret;
|
|
89
|
+
}
|
|
90
|
+
export function __wbg___wbindgen_number_get_f73a1244370fcc2c(arg0, arg1) {
|
|
91
|
+
const obj = getObject(arg1);
|
|
92
|
+
const ret = typeof(obj) === 'number' ? obj : undefined;
|
|
93
|
+
getDataViewMemory0().setFloat64(arg0 + 8 * 1, isLikeNone(ret) ? 0 : ret, true);
|
|
94
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 0, !isLikeNone(ret), true);
|
|
95
|
+
}
|
|
96
|
+
export function __wbg___wbindgen_string_get_d109740c0d18f4d7(arg0, arg1) {
|
|
97
|
+
const obj = getObject(arg1);
|
|
98
|
+
const ret = typeof(obj) === 'string' ? obj : undefined;
|
|
99
|
+
var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
100
|
+
var len1 = WASM_VECTOR_LEN;
|
|
101
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
|
|
102
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
|
|
103
|
+
}
|
|
104
|
+
export function __wbg___wbindgen_throw_9c31b086c2b26051(arg0, arg1) {
|
|
105
|
+
throw new Error(getStringFromWasm0(arg0, arg1));
|
|
106
|
+
}
|
|
107
|
+
export function __wbg_get_with_ref_key_6412cf3094599694(arg0, arg1) {
|
|
108
|
+
const ret = getObject(arg0)[getObject(arg1)];
|
|
109
|
+
return addHeapObject(ret);
|
|
110
|
+
}
|
|
111
|
+
export function __wbg_instanceof_ArrayBuffer_53db37b06f6b9afe(arg0) {
|
|
112
|
+
let result;
|
|
113
|
+
try {
|
|
114
|
+
result = getObject(arg0) instanceof ArrayBuffer;
|
|
115
|
+
} catch (_) {
|
|
116
|
+
result = false;
|
|
117
|
+
}
|
|
118
|
+
const ret = result;
|
|
119
|
+
return ret;
|
|
120
|
+
}
|
|
121
|
+
export function __wbg_instanceof_Uint8Array_abd07d4bd221d50b(arg0) {
|
|
122
|
+
let result;
|
|
123
|
+
try {
|
|
124
|
+
result = getObject(arg0) instanceof Uint8Array;
|
|
125
|
+
} catch (_) {
|
|
126
|
+
result = false;
|
|
127
|
+
}
|
|
128
|
+
const ret = result;
|
|
129
|
+
return ret;
|
|
130
|
+
}
|
|
131
|
+
export function __wbg_length_56fcd3e2b7e0299d(arg0) {
|
|
132
|
+
const ret = getObject(arg0).length;
|
|
133
|
+
return ret;
|
|
134
|
+
}
|
|
135
|
+
export function __wbg_new_02d162bc6cf02f60() {
|
|
136
|
+
const ret = new Object();
|
|
137
|
+
return addHeapObject(ret);
|
|
138
|
+
}
|
|
139
|
+
export function __wbg_new_1f236d63ba0c4784(arg0, arg1) {
|
|
140
|
+
const ret = new Error(getStringFromWasm0(arg0, arg1));
|
|
141
|
+
return addHeapObject(ret);
|
|
142
|
+
}
|
|
143
|
+
export function __wbg_new_310879b66b6e95e1() {
|
|
144
|
+
const ret = new Array();
|
|
145
|
+
return addHeapObject(ret);
|
|
146
|
+
}
|
|
147
|
+
export function __wbg_new_7ddec6de44ff8f5d(arg0) {
|
|
148
|
+
const ret = new Uint8Array(getObject(arg0));
|
|
149
|
+
return addHeapObject(ret);
|
|
150
|
+
}
|
|
151
|
+
export function __wbg_prototypesetcall_5f9bdc8d75e07276(arg0, arg1, arg2) {
|
|
152
|
+
Uint8Array.prototype.set.call(getArrayU8FromWasm0(arg0, arg1), getObject(arg2));
|
|
153
|
+
}
|
|
154
|
+
export function __wbg_set_6be42768c690e380(arg0, arg1, arg2) {
|
|
155
|
+
getObject(arg0)[takeObject(arg1)] = takeObject(arg2);
|
|
156
|
+
}
|
|
157
|
+
export function __wbg_set_78ea6a19f4818587(arg0, arg1, arg2) {
|
|
158
|
+
getObject(arg0)[arg1 >>> 0] = takeObject(arg2);
|
|
159
|
+
}
|
|
160
|
+
export function __wbindgen_cast_0000000000000001(arg0) {
|
|
161
|
+
// Cast intrinsic for `F64 -> Externref`.
|
|
162
|
+
const ret = arg0;
|
|
163
|
+
return addHeapObject(ret);
|
|
164
|
+
}
|
|
165
|
+
export function __wbindgen_cast_0000000000000002(arg0, arg1) {
|
|
166
|
+
// Cast intrinsic for `Ref(String) -> Externref`.
|
|
167
|
+
const ret = getStringFromWasm0(arg0, arg1);
|
|
168
|
+
return addHeapObject(ret);
|
|
169
|
+
}
|
|
170
|
+
export function __wbindgen_cast_0000000000000003(arg0) {
|
|
171
|
+
// Cast intrinsic for `U64 -> Externref`.
|
|
172
|
+
const ret = BigInt.asUintN(64, arg0);
|
|
173
|
+
return addHeapObject(ret);
|
|
174
|
+
}
|
|
175
|
+
export function __wbindgen_object_clone_ref(arg0) {
|
|
176
|
+
const ret = getObject(arg0);
|
|
177
|
+
return addHeapObject(ret);
|
|
178
|
+
}
|
|
179
|
+
export function __wbindgen_object_drop_ref(arg0) {
|
|
180
|
+
takeObject(arg0);
|
|
181
|
+
}
|
|
182
|
+
function addHeapObject(obj) {
|
|
183
|
+
if (heap_next === heap.length) heap.push(heap.length + 1);
|
|
184
|
+
const idx = heap_next;
|
|
185
|
+
heap_next = heap[idx];
|
|
186
|
+
|
|
187
|
+
heap[idx] = obj;
|
|
188
|
+
return idx;
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
function debugString(val) {
|
|
192
|
+
// primitive types
|
|
193
|
+
const type = typeof val;
|
|
194
|
+
if (type == 'number' || type == 'boolean' || val == null) {
|
|
195
|
+
return `${val}`;
|
|
196
|
+
}
|
|
197
|
+
if (type == 'string') {
|
|
198
|
+
return `"${val}"`;
|
|
199
|
+
}
|
|
200
|
+
if (type == 'symbol') {
|
|
201
|
+
const description = val.description;
|
|
202
|
+
if (description == null) {
|
|
203
|
+
return 'Symbol';
|
|
204
|
+
} else {
|
|
205
|
+
return `Symbol(${description})`;
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
if (type == 'function') {
|
|
209
|
+
const name = val.name;
|
|
210
|
+
if (typeof name == 'string' && name.length > 0) {
|
|
211
|
+
return `Function(${name})`;
|
|
212
|
+
} else {
|
|
213
|
+
return 'Function';
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
// objects
|
|
217
|
+
if (Array.isArray(val)) {
|
|
218
|
+
const length = val.length;
|
|
219
|
+
let debug = '[';
|
|
220
|
+
if (length > 0) {
|
|
221
|
+
debug += debugString(val[0]);
|
|
222
|
+
}
|
|
223
|
+
for(let i = 1; i < length; i++) {
|
|
224
|
+
debug += ', ' + debugString(val[i]);
|
|
225
|
+
}
|
|
226
|
+
debug += ']';
|
|
227
|
+
return debug;
|
|
228
|
+
}
|
|
229
|
+
// Test for built-in
|
|
230
|
+
const builtInMatches = /\[object ([^\]]+)\]/.exec(toString.call(val));
|
|
231
|
+
let className;
|
|
232
|
+
if (builtInMatches && builtInMatches.length > 1) {
|
|
233
|
+
className = builtInMatches[1];
|
|
234
|
+
} else {
|
|
235
|
+
// Failed to match the standard '[object ClassName]'
|
|
236
|
+
return toString.call(val);
|
|
237
|
+
}
|
|
238
|
+
if (className == 'Object') {
|
|
239
|
+
// we're a user defined class or Object
|
|
240
|
+
// JSON.stringify avoids problems with cycles, and is generally much
|
|
241
|
+
// easier than looping through ownProperties of `val`.
|
|
242
|
+
try {
|
|
243
|
+
return 'Object(' + JSON.stringify(val) + ')';
|
|
244
|
+
} catch (_) {
|
|
245
|
+
return 'Object';
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
// errors
|
|
249
|
+
if (val instanceof Error) {
|
|
250
|
+
return `${val.name}: ${val.message}\n${val.stack}`;
|
|
251
|
+
}
|
|
252
|
+
// TODO we could test for more things here, like `Set`s and `Map`s.
|
|
253
|
+
return className;
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
function dropObject(idx) {
|
|
257
|
+
if (idx < 1028) return;
|
|
258
|
+
heap[idx] = heap_next;
|
|
259
|
+
heap_next = idx;
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
function getArrayU8FromWasm0(ptr, len) {
|
|
263
|
+
ptr = ptr >>> 0;
|
|
264
|
+
return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
let cachedDataViewMemory0 = null;
|
|
268
|
+
function getDataViewMemory0() {
|
|
269
|
+
if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || (cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm.memory.buffer)) {
|
|
270
|
+
cachedDataViewMemory0 = new DataView(wasm.memory.buffer);
|
|
271
|
+
}
|
|
272
|
+
return cachedDataViewMemory0;
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
function getStringFromWasm0(ptr, len) {
|
|
276
|
+
return decodeText(ptr >>> 0, len);
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
let cachedUint8ArrayMemory0 = null;
|
|
280
|
+
function getUint8ArrayMemory0() {
|
|
281
|
+
if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
|
|
282
|
+
cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
|
|
283
|
+
}
|
|
284
|
+
return cachedUint8ArrayMemory0;
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
function getObject(idx) { return heap[idx]; }
|
|
288
|
+
|
|
289
|
+
let heap = new Array(1024).fill(undefined);
|
|
290
|
+
heap.push(undefined, null, true, false);
|
|
291
|
+
|
|
292
|
+
let heap_next = heap.length;
|
|
293
|
+
|
|
294
|
+
function isLikeNone(x) {
|
|
295
|
+
return x === undefined || x === null;
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
function passArray8ToWasm0(arg, malloc) {
|
|
299
|
+
const ptr = malloc(arg.length * 1, 1) >>> 0;
|
|
300
|
+
getUint8ArrayMemory0().set(arg, ptr / 1);
|
|
301
|
+
WASM_VECTOR_LEN = arg.length;
|
|
302
|
+
return ptr;
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
function passStringToWasm0(arg, malloc, realloc) {
|
|
306
|
+
if (realloc === undefined) {
|
|
307
|
+
const buf = cachedTextEncoder.encode(arg);
|
|
308
|
+
const ptr = malloc(buf.length, 1) >>> 0;
|
|
309
|
+
getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);
|
|
310
|
+
WASM_VECTOR_LEN = buf.length;
|
|
311
|
+
return ptr;
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
let len = arg.length;
|
|
315
|
+
let ptr = malloc(len, 1) >>> 0;
|
|
316
|
+
|
|
317
|
+
const mem = getUint8ArrayMemory0();
|
|
318
|
+
|
|
319
|
+
let offset = 0;
|
|
320
|
+
|
|
321
|
+
for (; offset < len; offset++) {
|
|
322
|
+
const code = arg.charCodeAt(offset);
|
|
323
|
+
if (code > 0x7F) break;
|
|
324
|
+
mem[ptr + offset] = code;
|
|
325
|
+
}
|
|
326
|
+
if (offset !== len) {
|
|
327
|
+
if (offset !== 0) {
|
|
328
|
+
arg = arg.slice(offset);
|
|
329
|
+
}
|
|
330
|
+
ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
|
|
331
|
+
const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
|
|
332
|
+
const ret = cachedTextEncoder.encodeInto(arg, view);
|
|
333
|
+
|
|
334
|
+
offset += ret.written;
|
|
335
|
+
ptr = realloc(ptr, len, offset, 1) >>> 0;
|
|
336
|
+
}
|
|
337
|
+
|
|
338
|
+
WASM_VECTOR_LEN = offset;
|
|
339
|
+
return ptr;
|
|
340
|
+
}
|
|
341
|
+
|
|
342
|
+
function takeObject(idx) {
|
|
343
|
+
const ret = getObject(idx);
|
|
344
|
+
dropObject(idx);
|
|
345
|
+
return ret;
|
|
346
|
+
}
|
|
347
|
+
|
|
348
|
+
let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
|
|
349
|
+
cachedTextDecoder.decode();
|
|
350
|
+
const MAX_SAFARI_DECODE_BYTES = 2146435072;
|
|
351
|
+
let numBytesDecoded = 0;
|
|
352
|
+
function decodeText(ptr, len) {
|
|
353
|
+
numBytesDecoded += len;
|
|
354
|
+
if (numBytesDecoded >= MAX_SAFARI_DECODE_BYTES) {
|
|
355
|
+
cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
|
|
356
|
+
cachedTextDecoder.decode();
|
|
357
|
+
numBytesDecoded = len;
|
|
358
|
+
}
|
|
359
|
+
return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
|
|
360
|
+
}
|
|
361
|
+
|
|
362
|
+
const cachedTextEncoder = new TextEncoder();
|
|
363
|
+
|
|
364
|
+
if (!('encodeInto' in cachedTextEncoder)) {
|
|
365
|
+
cachedTextEncoder.encodeInto = function (arg, view) {
|
|
366
|
+
const buf = cachedTextEncoder.encode(arg);
|
|
367
|
+
view.set(buf);
|
|
368
|
+
return {
|
|
369
|
+
read: arg.length,
|
|
370
|
+
written: buf.length
|
|
371
|
+
};
|
|
372
|
+
};
|
|
373
|
+
}
|
|
374
|
+
|
|
375
|
+
let WASM_VECTOR_LEN = 0;
|
|
376
|
+
|
|
377
|
+
|
|
378
|
+
let wasm;
|
|
379
|
+
export function __wbg_set_wasm(val) {
|
|
380
|
+
wasm = val;
|
|
381
|
+
}
|
|
Binary file
|
package/index.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export default {}
|