@iyulab/u-metaheur 0.1.0
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 +93 -0
- package/package.json +32 -0
- package/u_metaheur.d.ts +35 -0
- package/u_metaheur.js +9 -0
- package/u_metaheur_bg.js +434 -0
- package/u_metaheur_bg.wasm +0 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 iyulab
|
|
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,93 @@
|
|
|
1
|
+
# u-metaheur
|
|
2
|
+
|
|
3
|
+
**Domain-agnostic metaheuristic optimization framework**
|
|
4
|
+
|
|
5
|
+
[](https://crates.io/crates/u-metaheur)
|
|
6
|
+
[](https://docs.rs/u-metaheur)
|
|
7
|
+
[](https://github.com/iyulab/u-metaheur/actions/workflows/ci.yml)
|
|
8
|
+
[](LICENSE)
|
|
9
|
+
|
|
10
|
+
## Overview
|
|
11
|
+
|
|
12
|
+
u-metaheur provides generic implementations of common metaheuristic algorithms. It contains no domain-specific concepts — scheduling, nesting, routing, etc. are defined by the user through trait implementations.
|
|
13
|
+
|
|
14
|
+
## Algorithms
|
|
15
|
+
|
|
16
|
+
| Module | Algorithm | Description |
|
|
17
|
+
|--------|-----------|-------------|
|
|
18
|
+
| `ga` | Genetic Algorithm | Population-based evolutionary optimization with pluggable selection, crossover, and mutation operators |
|
|
19
|
+
| `brkga` | BRKGA | Biased Random-Key GA — user implements only a decoder; all evolutionary mechanics are handled generically |
|
|
20
|
+
| `sa` | Simulated Annealing | Single-solution trajectory optimization with pluggable cooling schedules |
|
|
21
|
+
| `alns` | ALNS | Adaptive Large Neighborhood Search — destroy/repair operators with adaptive weight selection |
|
|
22
|
+
| `cp` | Constraint Programming | Domain-agnostic modeling layer for constrained optimization with interval, integer, and boolean variables |
|
|
23
|
+
| `dispatching` | Dispatching | Generic priority rule composition engine for multi-rule item ranking |
|
|
24
|
+
|
|
25
|
+
## Key Traits
|
|
26
|
+
|
|
27
|
+
```rust
|
|
28
|
+
// GA — implement these for your domain
|
|
29
|
+
trait Chromosome: Clone + Send + Sync {
|
|
30
|
+
fn fitness(&self) -> f64;
|
|
31
|
+
}
|
|
32
|
+
trait Crossover<C: Chromosome> {
|
|
33
|
+
fn crossover(&self, parent1: &C, parent2: &C, rng: &mut Rng) -> C;
|
|
34
|
+
}
|
|
35
|
+
trait Mutation<C: Chromosome> {
|
|
36
|
+
fn mutate(&self, chromosome: &mut C, rng: &mut Rng);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
// BRKGA — implement only the decoder
|
|
40
|
+
trait BrkgaDecoder: Send + Sync {
|
|
41
|
+
type Solution;
|
|
42
|
+
fn decode(&self, keys: &[f64]) -> Self::Solution;
|
|
43
|
+
fn fitness(&self, solution: &Self::Solution) -> f64;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
// ALNS — implement destroy and repair operators
|
|
47
|
+
trait DestroyOperator<S> {
|
|
48
|
+
fn destroy(&self, solution: &S, rng: &mut Rng) -> S;
|
|
49
|
+
}
|
|
50
|
+
trait RepairOperator<S> {
|
|
51
|
+
fn repair(&self, solution: &S, rng: &mut Rng) -> S;
|
|
52
|
+
}
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
## Features
|
|
56
|
+
|
|
57
|
+
- **`serde`** — Enable serde serialization for algorithm parameters
|
|
58
|
+
|
|
59
|
+
## Quick Start
|
|
60
|
+
|
|
61
|
+
```toml
|
|
62
|
+
[dependencies]
|
|
63
|
+
u-metaheur = { git = "https://github.com/iyulab/u-metaheur" }
|
|
64
|
+
|
|
65
|
+
# with serde support
|
|
66
|
+
u-metaheur = { git = "https://github.com/iyulab/u-metaheur", features = ["serde"] }
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
## Build & Test
|
|
70
|
+
|
|
71
|
+
```bash
|
|
72
|
+
cargo build
|
|
73
|
+
cargo test
|
|
74
|
+
cargo bench # criterion benchmarks
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
## Dependencies
|
|
78
|
+
|
|
79
|
+
- [u-numflow](https://github.com/iyulab/u-numflow) — Mathematical primitives (statistics, RNG)
|
|
80
|
+
- `rand` 0.9 — Random number generation
|
|
81
|
+
- `rayon` 1.10 — Parallel computation
|
|
82
|
+
- `serde` 1.0 — Serialization (optional)
|
|
83
|
+
|
|
84
|
+
## License
|
|
85
|
+
|
|
86
|
+
MIT License — see [LICENSE](LICENSE).
|
|
87
|
+
|
|
88
|
+
## Related
|
|
89
|
+
|
|
90
|
+
- [u-numflow](https://github.com/iyulab/u-numflow) — Mathematical primitives
|
|
91
|
+
- [u-geometry](https://github.com/iyulab/u-geometry) — Computational geometry
|
|
92
|
+
- [u-schedule](https://github.com/iyulab/u-schedule) — Scheduling framework
|
|
93
|
+
- [u-nesting](https://github.com/iyulab/U-Nesting) — 2D/3D nesting and bin packing
|
package/package.json
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@iyulab/u-metaheur",
|
|
3
|
+
"type": "module",
|
|
4
|
+
"collaborators": [
|
|
5
|
+
"iyulab"
|
|
6
|
+
],
|
|
7
|
+
"description": "Domain-agnostic metaheuristic optimization framework: GA, BRKGA, SA, ALNS.",
|
|
8
|
+
"version": "0.1.0",
|
|
9
|
+
"license": "MIT",
|
|
10
|
+
"repository": {
|
|
11
|
+
"type": "git",
|
|
12
|
+
"url": "https://github.com/iyulab/u-metaheur"
|
|
13
|
+
},
|
|
14
|
+
"files": [
|
|
15
|
+
"u_metaheur_bg.wasm",
|
|
16
|
+
"u_metaheur.js",
|
|
17
|
+
"u_metaheur_bg.js",
|
|
18
|
+
"u_metaheur.d.ts"
|
|
19
|
+
],
|
|
20
|
+
"main": "u_metaheur.js",
|
|
21
|
+
"types": "u_metaheur.d.ts",
|
|
22
|
+
"sideEffects": [
|
|
23
|
+
"./u_metaheur.js",
|
|
24
|
+
"./snippets/*"
|
|
25
|
+
],
|
|
26
|
+
"keywords": [
|
|
27
|
+
"optimization",
|
|
28
|
+
"genetic-algorithm",
|
|
29
|
+
"metaheuristic",
|
|
30
|
+
"evolutionary"
|
|
31
|
+
]
|
|
32
|
+
}
|
package/u_metaheur.d.ts
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/* tslint:disable */
|
|
2
|
+
/* eslint-disable */
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Runs a Genetic Algorithm for TSP.
|
|
6
|
+
*
|
|
7
|
+
* # Arguments
|
|
8
|
+
* `config_json` — JS object with fields:
|
|
9
|
+
* - `nodes`: `[[x, y], ...]` (required)
|
|
10
|
+
* - `population_size`: integer (default 100)
|
|
11
|
+
* - `generations`: integer (default 200)
|
|
12
|
+
* - `mutation_rate`: float 0–1 (default 0.05)
|
|
13
|
+
*
|
|
14
|
+
* # Returns
|
|
15
|
+
* JS object with `best_distance`, `best_tour`, `generations_run`.
|
|
16
|
+
*/
|
|
17
|
+
export function run_ga(config_json: any): any;
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Runs Simulated Annealing for TSP.
|
|
21
|
+
*
|
|
22
|
+
* Uses geometric cooling (`T *= cooling_rate` per iteration).
|
|
23
|
+
* Neighbour move: 2-opt segment reversal between two random positions.
|
|
24
|
+
*
|
|
25
|
+
* # Arguments
|
|
26
|
+
* `config_json` — JS object with fields:
|
|
27
|
+
* - `nodes`: `[[x, y], ...]` (required)
|
|
28
|
+
* - `initial_temp`: float (default 1000.0)
|
|
29
|
+
* - `cooling_rate`: float in (0, 1) (default 0.995)
|
|
30
|
+
* - `iterations`: integer (default 5000)
|
|
31
|
+
*
|
|
32
|
+
* # Returns
|
|
33
|
+
* JS object with `best_distance`, `best_tour`, `iterations_run`.
|
|
34
|
+
*/
|
|
35
|
+
export function run_sa(config_json: any): any;
|
package/u_metaheur.js
ADDED
package/u_metaheur_bg.js
ADDED
|
@@ -0,0 +1,434 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Runs a Genetic Algorithm for TSP.
|
|
3
|
+
*
|
|
4
|
+
* # Arguments
|
|
5
|
+
* `config_json` — JS object with fields:
|
|
6
|
+
* - `nodes`: `[[x, y], ...]` (required)
|
|
7
|
+
* - `population_size`: integer (default 100)
|
|
8
|
+
* - `generations`: integer (default 200)
|
|
9
|
+
* - `mutation_rate`: float 0–1 (default 0.05)
|
|
10
|
+
*
|
|
11
|
+
* # Returns
|
|
12
|
+
* JS object with `best_distance`, `best_tour`, `generations_run`.
|
|
13
|
+
* @param {any} config_json
|
|
14
|
+
* @returns {any}
|
|
15
|
+
*/
|
|
16
|
+
export function run_ga(config_json) {
|
|
17
|
+
const ret = wasm.run_ga(config_json);
|
|
18
|
+
if (ret[2]) {
|
|
19
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
20
|
+
}
|
|
21
|
+
return takeFromExternrefTable0(ret[0]);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Runs Simulated Annealing for TSP.
|
|
26
|
+
*
|
|
27
|
+
* Uses geometric cooling (`T *= cooling_rate` per iteration).
|
|
28
|
+
* Neighbour move: 2-opt segment reversal between two random positions.
|
|
29
|
+
*
|
|
30
|
+
* # Arguments
|
|
31
|
+
* `config_json` — JS object with fields:
|
|
32
|
+
* - `nodes`: `[[x, y], ...]` (required)
|
|
33
|
+
* - `initial_temp`: float (default 1000.0)
|
|
34
|
+
* - `cooling_rate`: float in (0, 1) (default 0.995)
|
|
35
|
+
* - `iterations`: integer (default 5000)
|
|
36
|
+
*
|
|
37
|
+
* # Returns
|
|
38
|
+
* JS object with `best_distance`, `best_tour`, `iterations_run`.
|
|
39
|
+
* @param {any} config_json
|
|
40
|
+
* @returns {any}
|
|
41
|
+
*/
|
|
42
|
+
export function run_sa(config_json) {
|
|
43
|
+
const ret = wasm.run_sa(config_json);
|
|
44
|
+
if (ret[2]) {
|
|
45
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
46
|
+
}
|
|
47
|
+
return takeFromExternrefTable0(ret[0]);
|
|
48
|
+
}
|
|
49
|
+
export function __wbg_Error_8c4e43fe74559d73(arg0, arg1) {
|
|
50
|
+
const ret = Error(getStringFromWasm0(arg0, arg1));
|
|
51
|
+
return ret;
|
|
52
|
+
}
|
|
53
|
+
export function __wbg_Number_04624de7d0e8332d(arg0) {
|
|
54
|
+
const ret = Number(arg0);
|
|
55
|
+
return ret;
|
|
56
|
+
}
|
|
57
|
+
export function __wbg_String_8f0eb39a4a4c2f66(arg0, arg1) {
|
|
58
|
+
const ret = String(arg1);
|
|
59
|
+
const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
60
|
+
const len1 = WASM_VECTOR_LEN;
|
|
61
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
|
|
62
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
|
|
63
|
+
}
|
|
64
|
+
export function __wbg___wbindgen_bigint_get_as_i64_8fcf4ce7f1ca72a2(arg0, arg1) {
|
|
65
|
+
const v = arg1;
|
|
66
|
+
const ret = typeof(v) === 'bigint' ? v : undefined;
|
|
67
|
+
getDataViewMemory0().setBigInt64(arg0 + 8 * 1, isLikeNone(ret) ? BigInt(0) : ret, true);
|
|
68
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 0, !isLikeNone(ret), true);
|
|
69
|
+
}
|
|
70
|
+
export function __wbg___wbindgen_boolean_get_bbbb1c18aa2f5e25(arg0) {
|
|
71
|
+
const v = arg0;
|
|
72
|
+
const ret = typeof(v) === 'boolean' ? v : undefined;
|
|
73
|
+
return isLikeNone(ret) ? 0xFFFFFF : ret ? 1 : 0;
|
|
74
|
+
}
|
|
75
|
+
export function __wbg___wbindgen_debug_string_0bc8482c6e3508ae(arg0, arg1) {
|
|
76
|
+
const ret = debugString(arg1);
|
|
77
|
+
const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
78
|
+
const len1 = WASM_VECTOR_LEN;
|
|
79
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
|
|
80
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
|
|
81
|
+
}
|
|
82
|
+
export function __wbg___wbindgen_in_47fa6863be6f2f25(arg0, arg1) {
|
|
83
|
+
const ret = arg0 in arg1;
|
|
84
|
+
return ret;
|
|
85
|
+
}
|
|
86
|
+
export function __wbg___wbindgen_is_bigint_31b12575b56f32fc(arg0) {
|
|
87
|
+
const ret = typeof(arg0) === 'bigint';
|
|
88
|
+
return ret;
|
|
89
|
+
}
|
|
90
|
+
export function __wbg___wbindgen_is_function_0095a73b8b156f76(arg0) {
|
|
91
|
+
const ret = typeof(arg0) === 'function';
|
|
92
|
+
return ret;
|
|
93
|
+
}
|
|
94
|
+
export function __wbg___wbindgen_is_object_5ae8e5880f2c1fbd(arg0) {
|
|
95
|
+
const val = arg0;
|
|
96
|
+
const ret = typeof(val) === 'object' && val !== null;
|
|
97
|
+
return ret;
|
|
98
|
+
}
|
|
99
|
+
export function __wbg___wbindgen_is_undefined_9e4d92534c42d778(arg0) {
|
|
100
|
+
const ret = arg0 === undefined;
|
|
101
|
+
return ret;
|
|
102
|
+
}
|
|
103
|
+
export function __wbg___wbindgen_jsval_eq_11888390b0186270(arg0, arg1) {
|
|
104
|
+
const ret = arg0 === arg1;
|
|
105
|
+
return ret;
|
|
106
|
+
}
|
|
107
|
+
export function __wbg___wbindgen_jsval_loose_eq_9dd77d8cd6671811(arg0, arg1) {
|
|
108
|
+
const ret = arg0 == arg1;
|
|
109
|
+
return ret;
|
|
110
|
+
}
|
|
111
|
+
export function __wbg___wbindgen_number_get_8ff4255516ccad3e(arg0, arg1) {
|
|
112
|
+
const obj = arg1;
|
|
113
|
+
const ret = typeof(obj) === 'number' ? obj : undefined;
|
|
114
|
+
getDataViewMemory0().setFloat64(arg0 + 8 * 1, isLikeNone(ret) ? 0 : ret, true);
|
|
115
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 0, !isLikeNone(ret), true);
|
|
116
|
+
}
|
|
117
|
+
export function __wbg___wbindgen_string_get_72fb696202c56729(arg0, arg1) {
|
|
118
|
+
const obj = arg1;
|
|
119
|
+
const ret = typeof(obj) === 'string' ? obj : undefined;
|
|
120
|
+
var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
121
|
+
var len1 = WASM_VECTOR_LEN;
|
|
122
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
|
|
123
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
|
|
124
|
+
}
|
|
125
|
+
export function __wbg___wbindgen_throw_be289d5034ed271b(arg0, arg1) {
|
|
126
|
+
throw new Error(getStringFromWasm0(arg0, arg1));
|
|
127
|
+
}
|
|
128
|
+
export function __wbg_call_389efe28435a9388() { return handleError(function (arg0, arg1) {
|
|
129
|
+
const ret = arg0.call(arg1);
|
|
130
|
+
return ret;
|
|
131
|
+
}, arguments); }
|
|
132
|
+
export function __wbg_done_57b39ecd9addfe81(arg0) {
|
|
133
|
+
const ret = arg0.done;
|
|
134
|
+
return ret;
|
|
135
|
+
}
|
|
136
|
+
export function __wbg_getRandomValues_1c61fac11405ffdc() { return handleError(function (arg0, arg1) {
|
|
137
|
+
globalThis.crypto.getRandomValues(getArrayU8FromWasm0(arg0, arg1));
|
|
138
|
+
}, arguments); }
|
|
139
|
+
export function __wbg_get_9b94d73e6221f75c(arg0, arg1) {
|
|
140
|
+
const ret = arg0[arg1 >>> 0];
|
|
141
|
+
return ret;
|
|
142
|
+
}
|
|
143
|
+
export function __wbg_get_b3ed3ad4be2bc8ac() { return handleError(function (arg0, arg1) {
|
|
144
|
+
const ret = Reflect.get(arg0, arg1);
|
|
145
|
+
return ret;
|
|
146
|
+
}, arguments); }
|
|
147
|
+
export function __wbg_get_with_ref_key_1dc361bd10053bfe(arg0, arg1) {
|
|
148
|
+
const ret = arg0[arg1];
|
|
149
|
+
return ret;
|
|
150
|
+
}
|
|
151
|
+
export function __wbg_instanceof_ArrayBuffer_c367199e2fa2aa04(arg0) {
|
|
152
|
+
let result;
|
|
153
|
+
try {
|
|
154
|
+
result = arg0 instanceof ArrayBuffer;
|
|
155
|
+
} catch (_) {
|
|
156
|
+
result = false;
|
|
157
|
+
}
|
|
158
|
+
const ret = result;
|
|
159
|
+
return ret;
|
|
160
|
+
}
|
|
161
|
+
export function __wbg_instanceof_Uint8Array_9b9075935c74707c(arg0) {
|
|
162
|
+
let result;
|
|
163
|
+
try {
|
|
164
|
+
result = arg0 instanceof Uint8Array;
|
|
165
|
+
} catch (_) {
|
|
166
|
+
result = false;
|
|
167
|
+
}
|
|
168
|
+
const ret = result;
|
|
169
|
+
return ret;
|
|
170
|
+
}
|
|
171
|
+
export function __wbg_isArray_d314bb98fcf08331(arg0) {
|
|
172
|
+
const ret = Array.isArray(arg0);
|
|
173
|
+
return ret;
|
|
174
|
+
}
|
|
175
|
+
export function __wbg_isSafeInteger_bfbc7332a9768d2a(arg0) {
|
|
176
|
+
const ret = Number.isSafeInteger(arg0);
|
|
177
|
+
return ret;
|
|
178
|
+
}
|
|
179
|
+
export function __wbg_iterator_6ff6560ca1568e55() {
|
|
180
|
+
const ret = Symbol.iterator;
|
|
181
|
+
return ret;
|
|
182
|
+
}
|
|
183
|
+
export function __wbg_length_32ed9a279acd054c(arg0) {
|
|
184
|
+
const ret = arg0.length;
|
|
185
|
+
return ret;
|
|
186
|
+
}
|
|
187
|
+
export function __wbg_length_35a7bace40f36eac(arg0) {
|
|
188
|
+
const ret = arg0.length;
|
|
189
|
+
return ret;
|
|
190
|
+
}
|
|
191
|
+
export function __wbg_new_361308b2356cecd0() {
|
|
192
|
+
const ret = new Object();
|
|
193
|
+
return ret;
|
|
194
|
+
}
|
|
195
|
+
export function __wbg_new_3eb36ae241fe6f44() {
|
|
196
|
+
const ret = new Array();
|
|
197
|
+
return ret;
|
|
198
|
+
}
|
|
199
|
+
export function __wbg_new_dd2b680c8bf6ae29(arg0) {
|
|
200
|
+
const ret = new Uint8Array(arg0);
|
|
201
|
+
return ret;
|
|
202
|
+
}
|
|
203
|
+
export function __wbg_next_3482f54c49e8af19() { return handleError(function (arg0) {
|
|
204
|
+
const ret = arg0.next();
|
|
205
|
+
return ret;
|
|
206
|
+
}, arguments); }
|
|
207
|
+
export function __wbg_next_418f80d8f5303233(arg0) {
|
|
208
|
+
const ret = arg0.next;
|
|
209
|
+
return ret;
|
|
210
|
+
}
|
|
211
|
+
export function __wbg_prototypesetcall_bdcdcc5842e4d77d(arg0, arg1, arg2) {
|
|
212
|
+
Uint8Array.prototype.set.call(getArrayU8FromWasm0(arg0, arg1), arg2);
|
|
213
|
+
}
|
|
214
|
+
export function __wbg_set_3f1d0b984ed272ed(arg0, arg1, arg2) {
|
|
215
|
+
arg0[arg1] = arg2;
|
|
216
|
+
}
|
|
217
|
+
export function __wbg_set_f43e577aea94465b(arg0, arg1, arg2) {
|
|
218
|
+
arg0[arg1 >>> 0] = arg2;
|
|
219
|
+
}
|
|
220
|
+
export function __wbg_value_0546255b415e96c1(arg0) {
|
|
221
|
+
const ret = arg0.value;
|
|
222
|
+
return ret;
|
|
223
|
+
}
|
|
224
|
+
export function __wbindgen_cast_0000000000000001(arg0) {
|
|
225
|
+
// Cast intrinsic for `F64 -> Externref`.
|
|
226
|
+
const ret = arg0;
|
|
227
|
+
return ret;
|
|
228
|
+
}
|
|
229
|
+
export function __wbindgen_cast_0000000000000002(arg0, arg1) {
|
|
230
|
+
// Cast intrinsic for `Ref(String) -> Externref`.
|
|
231
|
+
const ret = getStringFromWasm0(arg0, arg1);
|
|
232
|
+
return ret;
|
|
233
|
+
}
|
|
234
|
+
export function __wbindgen_cast_0000000000000003(arg0) {
|
|
235
|
+
// Cast intrinsic for `U64 -> Externref`.
|
|
236
|
+
const ret = BigInt.asUintN(64, arg0);
|
|
237
|
+
return ret;
|
|
238
|
+
}
|
|
239
|
+
export function __wbindgen_init_externref_table() {
|
|
240
|
+
const table = wasm.__wbindgen_externrefs;
|
|
241
|
+
const offset = table.grow(4);
|
|
242
|
+
table.set(0, undefined);
|
|
243
|
+
table.set(offset + 0, undefined);
|
|
244
|
+
table.set(offset + 1, null);
|
|
245
|
+
table.set(offset + 2, true);
|
|
246
|
+
table.set(offset + 3, false);
|
|
247
|
+
}
|
|
248
|
+
function addToExternrefTable0(obj) {
|
|
249
|
+
const idx = wasm.__externref_table_alloc();
|
|
250
|
+
wasm.__wbindgen_externrefs.set(idx, obj);
|
|
251
|
+
return idx;
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
function debugString(val) {
|
|
255
|
+
// primitive types
|
|
256
|
+
const type = typeof val;
|
|
257
|
+
if (type == 'number' || type == 'boolean' || val == null) {
|
|
258
|
+
return `${val}`;
|
|
259
|
+
}
|
|
260
|
+
if (type == 'string') {
|
|
261
|
+
return `"${val}"`;
|
|
262
|
+
}
|
|
263
|
+
if (type == 'symbol') {
|
|
264
|
+
const description = val.description;
|
|
265
|
+
if (description == null) {
|
|
266
|
+
return 'Symbol';
|
|
267
|
+
} else {
|
|
268
|
+
return `Symbol(${description})`;
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
if (type == 'function') {
|
|
272
|
+
const name = val.name;
|
|
273
|
+
if (typeof name == 'string' && name.length > 0) {
|
|
274
|
+
return `Function(${name})`;
|
|
275
|
+
} else {
|
|
276
|
+
return 'Function';
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
// objects
|
|
280
|
+
if (Array.isArray(val)) {
|
|
281
|
+
const length = val.length;
|
|
282
|
+
let debug = '[';
|
|
283
|
+
if (length > 0) {
|
|
284
|
+
debug += debugString(val[0]);
|
|
285
|
+
}
|
|
286
|
+
for(let i = 1; i < length; i++) {
|
|
287
|
+
debug += ', ' + debugString(val[i]);
|
|
288
|
+
}
|
|
289
|
+
debug += ']';
|
|
290
|
+
return debug;
|
|
291
|
+
}
|
|
292
|
+
// Test for built-in
|
|
293
|
+
const builtInMatches = /\[object ([^\]]+)\]/.exec(toString.call(val));
|
|
294
|
+
let className;
|
|
295
|
+
if (builtInMatches && builtInMatches.length > 1) {
|
|
296
|
+
className = builtInMatches[1];
|
|
297
|
+
} else {
|
|
298
|
+
// Failed to match the standard '[object ClassName]'
|
|
299
|
+
return toString.call(val);
|
|
300
|
+
}
|
|
301
|
+
if (className == 'Object') {
|
|
302
|
+
// we're a user defined class or Object
|
|
303
|
+
// JSON.stringify avoids problems with cycles, and is generally much
|
|
304
|
+
// easier than looping through ownProperties of `val`.
|
|
305
|
+
try {
|
|
306
|
+
return 'Object(' + JSON.stringify(val) + ')';
|
|
307
|
+
} catch (_) {
|
|
308
|
+
return 'Object';
|
|
309
|
+
}
|
|
310
|
+
}
|
|
311
|
+
// errors
|
|
312
|
+
if (val instanceof Error) {
|
|
313
|
+
return `${val.name}: ${val.message}\n${val.stack}`;
|
|
314
|
+
}
|
|
315
|
+
// TODO we could test for more things here, like `Set`s and `Map`s.
|
|
316
|
+
return className;
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
function getArrayU8FromWasm0(ptr, len) {
|
|
320
|
+
ptr = ptr >>> 0;
|
|
321
|
+
return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
|
|
322
|
+
}
|
|
323
|
+
|
|
324
|
+
let cachedDataViewMemory0 = null;
|
|
325
|
+
function getDataViewMemory0() {
|
|
326
|
+
if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || (cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm.memory.buffer)) {
|
|
327
|
+
cachedDataViewMemory0 = new DataView(wasm.memory.buffer);
|
|
328
|
+
}
|
|
329
|
+
return cachedDataViewMemory0;
|
|
330
|
+
}
|
|
331
|
+
|
|
332
|
+
function getStringFromWasm0(ptr, len) {
|
|
333
|
+
ptr = ptr >>> 0;
|
|
334
|
+
return decodeText(ptr, len);
|
|
335
|
+
}
|
|
336
|
+
|
|
337
|
+
let cachedUint8ArrayMemory0 = null;
|
|
338
|
+
function getUint8ArrayMemory0() {
|
|
339
|
+
if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
|
|
340
|
+
cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
|
|
341
|
+
}
|
|
342
|
+
return cachedUint8ArrayMemory0;
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
function handleError(f, args) {
|
|
346
|
+
try {
|
|
347
|
+
return f.apply(this, args);
|
|
348
|
+
} catch (e) {
|
|
349
|
+
const idx = addToExternrefTable0(e);
|
|
350
|
+
wasm.__wbindgen_exn_store(idx);
|
|
351
|
+
}
|
|
352
|
+
}
|
|
353
|
+
|
|
354
|
+
function isLikeNone(x) {
|
|
355
|
+
return x === undefined || x === null;
|
|
356
|
+
}
|
|
357
|
+
|
|
358
|
+
function passStringToWasm0(arg, malloc, realloc) {
|
|
359
|
+
if (realloc === undefined) {
|
|
360
|
+
const buf = cachedTextEncoder.encode(arg);
|
|
361
|
+
const ptr = malloc(buf.length, 1) >>> 0;
|
|
362
|
+
getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);
|
|
363
|
+
WASM_VECTOR_LEN = buf.length;
|
|
364
|
+
return ptr;
|
|
365
|
+
}
|
|
366
|
+
|
|
367
|
+
let len = arg.length;
|
|
368
|
+
let ptr = malloc(len, 1) >>> 0;
|
|
369
|
+
|
|
370
|
+
const mem = getUint8ArrayMemory0();
|
|
371
|
+
|
|
372
|
+
let offset = 0;
|
|
373
|
+
|
|
374
|
+
for (; offset < len; offset++) {
|
|
375
|
+
const code = arg.charCodeAt(offset);
|
|
376
|
+
if (code > 0x7F) break;
|
|
377
|
+
mem[ptr + offset] = code;
|
|
378
|
+
}
|
|
379
|
+
if (offset !== len) {
|
|
380
|
+
if (offset !== 0) {
|
|
381
|
+
arg = arg.slice(offset);
|
|
382
|
+
}
|
|
383
|
+
ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
|
|
384
|
+
const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
|
|
385
|
+
const ret = cachedTextEncoder.encodeInto(arg, view);
|
|
386
|
+
|
|
387
|
+
offset += ret.written;
|
|
388
|
+
ptr = realloc(ptr, len, offset, 1) >>> 0;
|
|
389
|
+
}
|
|
390
|
+
|
|
391
|
+
WASM_VECTOR_LEN = offset;
|
|
392
|
+
return ptr;
|
|
393
|
+
}
|
|
394
|
+
|
|
395
|
+
function takeFromExternrefTable0(idx) {
|
|
396
|
+
const value = wasm.__wbindgen_externrefs.get(idx);
|
|
397
|
+
wasm.__externref_table_dealloc(idx);
|
|
398
|
+
return value;
|
|
399
|
+
}
|
|
400
|
+
|
|
401
|
+
let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
|
|
402
|
+
cachedTextDecoder.decode();
|
|
403
|
+
const MAX_SAFARI_DECODE_BYTES = 2146435072;
|
|
404
|
+
let numBytesDecoded = 0;
|
|
405
|
+
function decodeText(ptr, len) {
|
|
406
|
+
numBytesDecoded += len;
|
|
407
|
+
if (numBytesDecoded >= MAX_SAFARI_DECODE_BYTES) {
|
|
408
|
+
cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
|
|
409
|
+
cachedTextDecoder.decode();
|
|
410
|
+
numBytesDecoded = len;
|
|
411
|
+
}
|
|
412
|
+
return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
|
|
413
|
+
}
|
|
414
|
+
|
|
415
|
+
const cachedTextEncoder = new TextEncoder();
|
|
416
|
+
|
|
417
|
+
if (!('encodeInto' in cachedTextEncoder)) {
|
|
418
|
+
cachedTextEncoder.encodeInto = function (arg, view) {
|
|
419
|
+
const buf = cachedTextEncoder.encode(arg);
|
|
420
|
+
view.set(buf);
|
|
421
|
+
return {
|
|
422
|
+
read: arg.length,
|
|
423
|
+
written: buf.length
|
|
424
|
+
};
|
|
425
|
+
};
|
|
426
|
+
}
|
|
427
|
+
|
|
428
|
+
let WASM_VECTOR_LEN = 0;
|
|
429
|
+
|
|
430
|
+
|
|
431
|
+
let wasm;
|
|
432
|
+
export function __wbg_set_wasm(val) {
|
|
433
|
+
wasm = val;
|
|
434
|
+
}
|
|
Binary file
|