@iyulab/u-routing 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 +125 -0
- package/package.json +33 -0
- package/u_routing.d.ts +16 -0
- package/u_routing.js +9 -0
- package/u_routing_bg.js +404 -0
- package/u_routing_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,125 @@
|
|
|
1
|
+
# u-routing
|
|
2
|
+
|
|
3
|
+
[](https://crates.io/crates/u-routing)
|
|
4
|
+
[](https://docs.rs/u-routing)
|
|
5
|
+
[](https://github.com/iyulab/u-routing/actions/workflows/ci.yml)
|
|
6
|
+
[](LICENSE)
|
|
7
|
+
|
|
8
|
+
Vehicle routing optimization library providing building-block algorithms for
|
|
9
|
+
TSP, CVRP, and VRPTW variants.
|
|
10
|
+
|
|
11
|
+
## Features
|
|
12
|
+
|
|
13
|
+
- **Models** — Customer, Vehicle, Route, Solution, TimeWindow, RoutingProblem trait
|
|
14
|
+
- **Distance** — Dense distance/travel-time matrix with nearest-neighbor lookup
|
|
15
|
+
- **Evaluation** — Route feasibility checking (capacity, time windows, max distance/duration)
|
|
16
|
+
- **Constructive heuristics** — Nearest Neighbor (O(n²)), Clarke-Wright Savings (O(n² log n))
|
|
17
|
+
- **Local search** — Intra-route 2-opt (Croes 1958), inter-route Relocate (Or 1976)
|
|
18
|
+
- **Genetic algorithm** — Giant tour + Prins (2004) split DP, OX crossover, 2-opt refinement
|
|
19
|
+
- **ALNS** — Random/Worst/Shaw removal + Greedy/Regret-k insertion (Ropke & Pisinger 2006)
|
|
20
|
+
|
|
21
|
+
## Quick Start
|
|
22
|
+
|
|
23
|
+
```rust
|
|
24
|
+
use u_routing::models::{Customer, Vehicle};
|
|
25
|
+
use u_routing::distance::DistanceMatrix;
|
|
26
|
+
use u_routing::constructive::nearest_neighbor;
|
|
27
|
+
use u_routing::local_search::{two_opt_improve, relocate_improve};
|
|
28
|
+
|
|
29
|
+
let customers = vec![
|
|
30
|
+
Customer::depot(0.0, 0.0),
|
|
31
|
+
Customer::new(1, 1.0, 0.0, 10, 0.0),
|
|
32
|
+
Customer::new(2, 2.0, 0.0, 10, 0.0),
|
|
33
|
+
Customer::new(3, 3.0, 0.0, 10, 0.0),
|
|
34
|
+
];
|
|
35
|
+
let dm = DistanceMatrix::from_customers(&customers);
|
|
36
|
+
let vehicles = vec![Vehicle::new(0, 30)];
|
|
37
|
+
|
|
38
|
+
// Constructive → Local search pipeline
|
|
39
|
+
let initial = nearest_neighbor(&customers, &dm, &vehicles);
|
|
40
|
+
let improved = relocate_improve(&initial, &customers, &dm, &vehicles[0]);
|
|
41
|
+
println!("Distance: {}", improved.total_distance());
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
### GA Solver
|
|
45
|
+
|
|
46
|
+
```rust
|
|
47
|
+
use u_routing::models::Customer;
|
|
48
|
+
use u_routing::distance::DistanceMatrix;
|
|
49
|
+
use u_routing::ga::RoutingGaProblem;
|
|
50
|
+
use u_metaheur::ga::{GaConfig, GaRunner};
|
|
51
|
+
|
|
52
|
+
let customers = vec![
|
|
53
|
+
Customer::depot(0.0, 0.0),
|
|
54
|
+
Customer::new(1, 1.0, 0.0, 10, 0.0),
|
|
55
|
+
Customer::new(2, 2.0, 0.0, 10, 0.0),
|
|
56
|
+
Customer::new(3, 3.0, 0.0, 10, 0.0),
|
|
57
|
+
];
|
|
58
|
+
let dm = DistanceMatrix::from_customers(&customers);
|
|
59
|
+
|
|
60
|
+
let problem = RoutingGaProblem::new(customers, dm, 30);
|
|
61
|
+
let config = GaConfig::default()
|
|
62
|
+
.with_population_size(50)
|
|
63
|
+
.with_max_generations(200);
|
|
64
|
+
|
|
65
|
+
let result = GaRunner::run(&problem, &config);
|
|
66
|
+
println!("Best distance: {}", result.best_fitness);
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
### ALNS Solver
|
|
70
|
+
|
|
71
|
+
```rust
|
|
72
|
+
use u_routing::models::Customer;
|
|
73
|
+
use u_routing::distance::DistanceMatrix;
|
|
74
|
+
use u_routing::alns::{RoutingAlnsProblem, destroy::RandomRemoval, repair::GreedyInsertion};
|
|
75
|
+
use u_metaheur::alns::{AlnsConfig, AlnsRunner};
|
|
76
|
+
|
|
77
|
+
let customers = vec![
|
|
78
|
+
Customer::depot(0.0, 0.0),
|
|
79
|
+
Customer::new(1, 1.0, 0.0, 10, 0.0),
|
|
80
|
+
Customer::new(2, 2.0, 0.0, 10, 0.0),
|
|
81
|
+
Customer::new(3, 3.0, 0.0, 10, 0.0),
|
|
82
|
+
];
|
|
83
|
+
let dm = DistanceMatrix::from_customers(&customers);
|
|
84
|
+
|
|
85
|
+
let problem = RoutingAlnsProblem::new(customers.clone(), dm.clone(), 30);
|
|
86
|
+
let destroy = vec![RandomRemoval];
|
|
87
|
+
let repair = vec![GreedyInsertion::new(dm, customers, 30)];
|
|
88
|
+
let config = AlnsConfig::default().with_max_iterations(5000).with_seed(42);
|
|
89
|
+
|
|
90
|
+
let result = AlnsRunner::run(&problem, &destroy, &repair, &config);
|
|
91
|
+
println!("Best cost: {}", result.best_cost);
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
## Architecture
|
|
95
|
+
|
|
96
|
+
```
|
|
97
|
+
u-routing
|
|
98
|
+
├── models/ Domain types (Customer, Vehicle, Route, Solution)
|
|
99
|
+
├── distance/ Distance matrix
|
|
100
|
+
├── evaluation/ Route evaluator + constraint checking
|
|
101
|
+
├── constructive/ Nearest Neighbor, Clarke-Wright Savings
|
|
102
|
+
├── local_search/ 2-opt, Relocate
|
|
103
|
+
├── ga/ Giant tour + Split DP + GaProblem bridge
|
|
104
|
+
└── alns/ Destroy/Repair operators + AlnsProblem bridge
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
## Dependencies
|
|
108
|
+
|
|
109
|
+
- [`u-metaheur`](https://crates.io/crates/u-metaheur) — GA/ALNS framework
|
|
110
|
+
- [`u-numflow`](https://crates.io/crates/u-numflow) — Math primitives, RNG
|
|
111
|
+
|
|
112
|
+
## References
|
|
113
|
+
|
|
114
|
+
- Clarke, G. & Wright, J.W. (1964). "Scheduling of Vehicles from a Central Depot to a Number of Delivery Points"
|
|
115
|
+
- Croes, G.A. (1958). "A method for solving traveling salesman problems"
|
|
116
|
+
- Or, I. (1976). "Traveling Salesman-Type Combinatorial Problems and Their Relation to the Logistics of Blood Banking"
|
|
117
|
+
- Prins, C. (2004). "A simple and effective evolutionary algorithm for the vehicle routing problem"
|
|
118
|
+
- Ropke, S. & Pisinger, D. (2006). "An Adaptive Large Neighborhood Search Heuristic for the Pickup and Delivery Problem with Time Windows"
|
|
119
|
+
- Shaw, P. (1998). "Using Constraint Programming and Local Search Methods to Solve Vehicle Routing Problems"
|
|
120
|
+
|
|
121
|
+
## Related
|
|
122
|
+
|
|
123
|
+
- [u-numflow](https://crates.io/crates/u-numflow) — Mathematical optimization primitives
|
|
124
|
+
- [u-metaheur](https://crates.io/crates/u-metaheur) — Metaheuristic algorithms
|
|
125
|
+
- [u-schedule](https://crates.io/crates/u-schedule) — Scheduling optimization
|
package/package.json
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@iyulab/u-routing",
|
|
3
|
+
"type": "module",
|
|
4
|
+
"collaborators": [
|
|
5
|
+
"iyulab"
|
|
6
|
+
],
|
|
7
|
+
"description": "Vehicle routing optimization: TSP, CVRP, VRPTW with constructive heuristics, local search, GA, and ALNS.",
|
|
8
|
+
"version": "0.1.0",
|
|
9
|
+
"license": "MIT",
|
|
10
|
+
"repository": {
|
|
11
|
+
"type": "git",
|
|
12
|
+
"url": "https://github.com/iyulab/u-routing"
|
|
13
|
+
},
|
|
14
|
+
"files": [
|
|
15
|
+
"u_routing_bg.wasm",
|
|
16
|
+
"u_routing.js",
|
|
17
|
+
"u_routing_bg.js",
|
|
18
|
+
"u_routing.d.ts"
|
|
19
|
+
],
|
|
20
|
+
"main": "u_routing.js",
|
|
21
|
+
"types": "u_routing.d.ts",
|
|
22
|
+
"sideEffects": [
|
|
23
|
+
"./u_routing.js",
|
|
24
|
+
"./snippets/*"
|
|
25
|
+
],
|
|
26
|
+
"keywords": [
|
|
27
|
+
"routing",
|
|
28
|
+
"vrp",
|
|
29
|
+
"tsp",
|
|
30
|
+
"optimization",
|
|
31
|
+
"logistics"
|
|
32
|
+
]
|
|
33
|
+
}
|
package/u_routing.d.ts
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/* tslint:disable */
|
|
2
|
+
/* eslint-disable */
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Solve a capacitated VRP problem given as JSON.
|
|
6
|
+
*
|
|
7
|
+
* # Arguments
|
|
8
|
+
* * `problem_json` — A JS object matching the VRP input schema.
|
|
9
|
+
*
|
|
10
|
+
* # Returns
|
|
11
|
+
* A JS object with `routes`, `total_distance`, and `num_vehicles`.
|
|
12
|
+
*
|
|
13
|
+
* # Errors
|
|
14
|
+
* Returns a `JsValue` string describing the error if input is invalid.
|
|
15
|
+
*/
|
|
16
|
+
export function solve_vrp(problem_json: any): any;
|
package/u_routing.js
ADDED
package/u_routing_bg.js
ADDED
|
@@ -0,0 +1,404 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Solve a capacitated VRP problem given as JSON.
|
|
3
|
+
*
|
|
4
|
+
* # Arguments
|
|
5
|
+
* * `problem_json` — A JS object matching the VRP input schema.
|
|
6
|
+
*
|
|
7
|
+
* # Returns
|
|
8
|
+
* A JS object with `routes`, `total_distance`, and `num_vehicles`.
|
|
9
|
+
*
|
|
10
|
+
* # Errors
|
|
11
|
+
* Returns a `JsValue` string describing the error if input is invalid.
|
|
12
|
+
* @param {any} problem_json
|
|
13
|
+
* @returns {any}
|
|
14
|
+
*/
|
|
15
|
+
export function solve_vrp(problem_json) {
|
|
16
|
+
const ret = wasm.solve_vrp(problem_json);
|
|
17
|
+
if (ret[2]) {
|
|
18
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
19
|
+
}
|
|
20
|
+
return takeFromExternrefTable0(ret[0]);
|
|
21
|
+
}
|
|
22
|
+
export function __wbg_Error_83742b46f01ce22d(arg0, arg1) {
|
|
23
|
+
const ret = Error(getStringFromWasm0(arg0, arg1));
|
|
24
|
+
return ret;
|
|
25
|
+
}
|
|
26
|
+
export function __wbg_Number_a5a435bd7bbec835(arg0) {
|
|
27
|
+
const ret = Number(arg0);
|
|
28
|
+
return ret;
|
|
29
|
+
}
|
|
30
|
+
export function __wbg_String_8564e559799eccda(arg0, arg1) {
|
|
31
|
+
const ret = String(arg1);
|
|
32
|
+
const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
33
|
+
const len1 = WASM_VECTOR_LEN;
|
|
34
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
|
|
35
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
|
|
36
|
+
}
|
|
37
|
+
export function __wbg___wbindgen_bigint_get_as_i64_447a76b5c6ef7bda(arg0, arg1) {
|
|
38
|
+
const v = arg1;
|
|
39
|
+
const ret = typeof(v) === 'bigint' ? v : undefined;
|
|
40
|
+
getDataViewMemory0().setBigInt64(arg0 + 8 * 1, isLikeNone(ret) ? BigInt(0) : ret, true);
|
|
41
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 0, !isLikeNone(ret), true);
|
|
42
|
+
}
|
|
43
|
+
export function __wbg___wbindgen_boolean_get_c0f3f60bac5a78d1(arg0) {
|
|
44
|
+
const v = arg0;
|
|
45
|
+
const ret = typeof(v) === 'boolean' ? v : undefined;
|
|
46
|
+
return isLikeNone(ret) ? 0xFFFFFF : ret ? 1 : 0;
|
|
47
|
+
}
|
|
48
|
+
export function __wbg___wbindgen_debug_string_5398f5bb970e0daa(arg0, arg1) {
|
|
49
|
+
const ret = debugString(arg1);
|
|
50
|
+
const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
51
|
+
const len1 = WASM_VECTOR_LEN;
|
|
52
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
|
|
53
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
|
|
54
|
+
}
|
|
55
|
+
export function __wbg___wbindgen_in_41dbb8413020e076(arg0, arg1) {
|
|
56
|
+
const ret = arg0 in arg1;
|
|
57
|
+
return ret;
|
|
58
|
+
}
|
|
59
|
+
export function __wbg___wbindgen_is_bigint_e2141d4f045b7eda(arg0) {
|
|
60
|
+
const ret = typeof(arg0) === 'bigint';
|
|
61
|
+
return ret;
|
|
62
|
+
}
|
|
63
|
+
export function __wbg___wbindgen_is_function_3c846841762788c1(arg0) {
|
|
64
|
+
const ret = typeof(arg0) === 'function';
|
|
65
|
+
return ret;
|
|
66
|
+
}
|
|
67
|
+
export function __wbg___wbindgen_is_object_781bc9f159099513(arg0) {
|
|
68
|
+
const val = arg0;
|
|
69
|
+
const ret = typeof(val) === 'object' && val !== null;
|
|
70
|
+
return ret;
|
|
71
|
+
}
|
|
72
|
+
export function __wbg___wbindgen_is_undefined_52709e72fb9f179c(arg0) {
|
|
73
|
+
const ret = arg0 === undefined;
|
|
74
|
+
return ret;
|
|
75
|
+
}
|
|
76
|
+
export function __wbg___wbindgen_jsval_eq_ee31bfad3e536463(arg0, arg1) {
|
|
77
|
+
const ret = arg0 === arg1;
|
|
78
|
+
return ret;
|
|
79
|
+
}
|
|
80
|
+
export function __wbg___wbindgen_jsval_loose_eq_5bcc3bed3c69e72b(arg0, arg1) {
|
|
81
|
+
const ret = arg0 == arg1;
|
|
82
|
+
return ret;
|
|
83
|
+
}
|
|
84
|
+
export function __wbg___wbindgen_number_get_34bb9d9dcfa21373(arg0, arg1) {
|
|
85
|
+
const obj = arg1;
|
|
86
|
+
const ret = typeof(obj) === 'number' ? obj : undefined;
|
|
87
|
+
getDataViewMemory0().setFloat64(arg0 + 8 * 1, isLikeNone(ret) ? 0 : ret, true);
|
|
88
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 0, !isLikeNone(ret), true);
|
|
89
|
+
}
|
|
90
|
+
export function __wbg___wbindgen_string_get_395e606bd0ee4427(arg0, arg1) {
|
|
91
|
+
const obj = arg1;
|
|
92
|
+
const ret = typeof(obj) === 'string' ? obj : undefined;
|
|
93
|
+
var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
94
|
+
var len1 = WASM_VECTOR_LEN;
|
|
95
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
|
|
96
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
|
|
97
|
+
}
|
|
98
|
+
export function __wbg___wbindgen_throw_6ddd609b62940d55(arg0, arg1) {
|
|
99
|
+
throw new Error(getStringFromWasm0(arg0, arg1));
|
|
100
|
+
}
|
|
101
|
+
export function __wbg_call_e133b57c9155d22c() { return handleError(function (arg0, arg1) {
|
|
102
|
+
const ret = arg0.call(arg1);
|
|
103
|
+
return ret;
|
|
104
|
+
}, arguments); }
|
|
105
|
+
export function __wbg_done_08ce71ee07e3bd17(arg0) {
|
|
106
|
+
const ret = arg0.done;
|
|
107
|
+
return ret;
|
|
108
|
+
}
|
|
109
|
+
export function __wbg_get_326e41e095fb2575() { return handleError(function (arg0, arg1) {
|
|
110
|
+
const ret = Reflect.get(arg0, arg1);
|
|
111
|
+
return ret;
|
|
112
|
+
}, arguments); }
|
|
113
|
+
export function __wbg_get_unchecked_329cfe50afab7352(arg0, arg1) {
|
|
114
|
+
const ret = arg0[arg1 >>> 0];
|
|
115
|
+
return ret;
|
|
116
|
+
}
|
|
117
|
+
export function __wbg_get_with_ref_key_6412cf3094599694(arg0, arg1) {
|
|
118
|
+
const ret = arg0[arg1];
|
|
119
|
+
return ret;
|
|
120
|
+
}
|
|
121
|
+
export function __wbg_instanceof_ArrayBuffer_101e2bf31071a9f6(arg0) {
|
|
122
|
+
let result;
|
|
123
|
+
try {
|
|
124
|
+
result = arg0 instanceof ArrayBuffer;
|
|
125
|
+
} catch (_) {
|
|
126
|
+
result = false;
|
|
127
|
+
}
|
|
128
|
+
const ret = result;
|
|
129
|
+
return ret;
|
|
130
|
+
}
|
|
131
|
+
export function __wbg_instanceof_Uint8Array_740438561a5b956d(arg0) {
|
|
132
|
+
let result;
|
|
133
|
+
try {
|
|
134
|
+
result = arg0 instanceof Uint8Array;
|
|
135
|
+
} catch (_) {
|
|
136
|
+
result = false;
|
|
137
|
+
}
|
|
138
|
+
const ret = result;
|
|
139
|
+
return ret;
|
|
140
|
+
}
|
|
141
|
+
export function __wbg_isArray_33b91feb269ff46e(arg0) {
|
|
142
|
+
const ret = Array.isArray(arg0);
|
|
143
|
+
return ret;
|
|
144
|
+
}
|
|
145
|
+
export function __wbg_isSafeInteger_ecd6a7f9c3e053cd(arg0) {
|
|
146
|
+
const ret = Number.isSafeInteger(arg0);
|
|
147
|
+
return ret;
|
|
148
|
+
}
|
|
149
|
+
export function __wbg_iterator_d8f549ec8fb061b1() {
|
|
150
|
+
const ret = Symbol.iterator;
|
|
151
|
+
return ret;
|
|
152
|
+
}
|
|
153
|
+
export function __wbg_length_b3416cf66a5452c8(arg0) {
|
|
154
|
+
const ret = arg0.length;
|
|
155
|
+
return ret;
|
|
156
|
+
}
|
|
157
|
+
export function __wbg_length_ea16607d7b61445b(arg0) {
|
|
158
|
+
const ret = arg0.length;
|
|
159
|
+
return ret;
|
|
160
|
+
}
|
|
161
|
+
export function __wbg_new_5f486cdf45a04d78(arg0) {
|
|
162
|
+
const ret = new Uint8Array(arg0);
|
|
163
|
+
return ret;
|
|
164
|
+
}
|
|
165
|
+
export function __wbg_new_a70fbab9066b301f() {
|
|
166
|
+
const ret = new Array();
|
|
167
|
+
return ret;
|
|
168
|
+
}
|
|
169
|
+
export function __wbg_new_ab79df5bd7c26067() {
|
|
170
|
+
const ret = new Object();
|
|
171
|
+
return ret;
|
|
172
|
+
}
|
|
173
|
+
export function __wbg_next_11b99ee6237339e3() { return handleError(function (arg0) {
|
|
174
|
+
const ret = arg0.next();
|
|
175
|
+
return ret;
|
|
176
|
+
}, arguments); }
|
|
177
|
+
export function __wbg_next_e01a967809d1aa68(arg0) {
|
|
178
|
+
const ret = arg0.next;
|
|
179
|
+
return ret;
|
|
180
|
+
}
|
|
181
|
+
export function __wbg_prototypesetcall_d62e5099504357e6(arg0, arg1, arg2) {
|
|
182
|
+
Uint8Array.prototype.set.call(getArrayU8FromWasm0(arg0, arg1), arg2);
|
|
183
|
+
}
|
|
184
|
+
export function __wbg_set_282384002438957f(arg0, arg1, arg2) {
|
|
185
|
+
arg0[arg1 >>> 0] = arg2;
|
|
186
|
+
}
|
|
187
|
+
export function __wbg_set_6be42768c690e380(arg0, arg1, arg2) {
|
|
188
|
+
arg0[arg1] = arg2;
|
|
189
|
+
}
|
|
190
|
+
export function __wbg_value_21fc78aab0322612(arg0) {
|
|
191
|
+
const ret = arg0.value;
|
|
192
|
+
return ret;
|
|
193
|
+
}
|
|
194
|
+
export function __wbindgen_cast_0000000000000001(arg0) {
|
|
195
|
+
// Cast intrinsic for `F64 -> Externref`.
|
|
196
|
+
const ret = arg0;
|
|
197
|
+
return ret;
|
|
198
|
+
}
|
|
199
|
+
export function __wbindgen_cast_0000000000000002(arg0, arg1) {
|
|
200
|
+
// Cast intrinsic for `Ref(String) -> Externref`.
|
|
201
|
+
const ret = getStringFromWasm0(arg0, arg1);
|
|
202
|
+
return ret;
|
|
203
|
+
}
|
|
204
|
+
export function __wbindgen_cast_0000000000000003(arg0) {
|
|
205
|
+
// Cast intrinsic for `U64 -> Externref`.
|
|
206
|
+
const ret = BigInt.asUintN(64, arg0);
|
|
207
|
+
return ret;
|
|
208
|
+
}
|
|
209
|
+
export function __wbindgen_init_externref_table() {
|
|
210
|
+
const table = wasm.__wbindgen_externrefs;
|
|
211
|
+
const offset = table.grow(4);
|
|
212
|
+
table.set(0, undefined);
|
|
213
|
+
table.set(offset + 0, undefined);
|
|
214
|
+
table.set(offset + 1, null);
|
|
215
|
+
table.set(offset + 2, true);
|
|
216
|
+
table.set(offset + 3, false);
|
|
217
|
+
}
|
|
218
|
+
function addToExternrefTable0(obj) {
|
|
219
|
+
const idx = wasm.__externref_table_alloc();
|
|
220
|
+
wasm.__wbindgen_externrefs.set(idx, obj);
|
|
221
|
+
return idx;
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
function debugString(val) {
|
|
225
|
+
// primitive types
|
|
226
|
+
const type = typeof val;
|
|
227
|
+
if (type == 'number' || type == 'boolean' || val == null) {
|
|
228
|
+
return `${val}`;
|
|
229
|
+
}
|
|
230
|
+
if (type == 'string') {
|
|
231
|
+
return `"${val}"`;
|
|
232
|
+
}
|
|
233
|
+
if (type == 'symbol') {
|
|
234
|
+
const description = val.description;
|
|
235
|
+
if (description == null) {
|
|
236
|
+
return 'Symbol';
|
|
237
|
+
} else {
|
|
238
|
+
return `Symbol(${description})`;
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
if (type == 'function') {
|
|
242
|
+
const name = val.name;
|
|
243
|
+
if (typeof name == 'string' && name.length > 0) {
|
|
244
|
+
return `Function(${name})`;
|
|
245
|
+
} else {
|
|
246
|
+
return 'Function';
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
// objects
|
|
250
|
+
if (Array.isArray(val)) {
|
|
251
|
+
const length = val.length;
|
|
252
|
+
let debug = '[';
|
|
253
|
+
if (length > 0) {
|
|
254
|
+
debug += debugString(val[0]);
|
|
255
|
+
}
|
|
256
|
+
for(let i = 1; i < length; i++) {
|
|
257
|
+
debug += ', ' + debugString(val[i]);
|
|
258
|
+
}
|
|
259
|
+
debug += ']';
|
|
260
|
+
return debug;
|
|
261
|
+
}
|
|
262
|
+
// Test for built-in
|
|
263
|
+
const builtInMatches = /\[object ([^\]]+)\]/.exec(toString.call(val));
|
|
264
|
+
let className;
|
|
265
|
+
if (builtInMatches && builtInMatches.length > 1) {
|
|
266
|
+
className = builtInMatches[1];
|
|
267
|
+
} else {
|
|
268
|
+
// Failed to match the standard '[object ClassName]'
|
|
269
|
+
return toString.call(val);
|
|
270
|
+
}
|
|
271
|
+
if (className == 'Object') {
|
|
272
|
+
// we're a user defined class or Object
|
|
273
|
+
// JSON.stringify avoids problems with cycles, and is generally much
|
|
274
|
+
// easier than looping through ownProperties of `val`.
|
|
275
|
+
try {
|
|
276
|
+
return 'Object(' + JSON.stringify(val) + ')';
|
|
277
|
+
} catch (_) {
|
|
278
|
+
return 'Object';
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
// errors
|
|
282
|
+
if (val instanceof Error) {
|
|
283
|
+
return `${val.name}: ${val.message}\n${val.stack}`;
|
|
284
|
+
}
|
|
285
|
+
// TODO we could test for more things here, like `Set`s and `Map`s.
|
|
286
|
+
return className;
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
function getArrayU8FromWasm0(ptr, len) {
|
|
290
|
+
ptr = ptr >>> 0;
|
|
291
|
+
return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
let cachedDataViewMemory0 = null;
|
|
295
|
+
function getDataViewMemory0() {
|
|
296
|
+
if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || (cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm.memory.buffer)) {
|
|
297
|
+
cachedDataViewMemory0 = new DataView(wasm.memory.buffer);
|
|
298
|
+
}
|
|
299
|
+
return cachedDataViewMemory0;
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
function getStringFromWasm0(ptr, len) {
|
|
303
|
+
ptr = ptr >>> 0;
|
|
304
|
+
return decodeText(ptr, len);
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
let cachedUint8ArrayMemory0 = null;
|
|
308
|
+
function getUint8ArrayMemory0() {
|
|
309
|
+
if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
|
|
310
|
+
cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
|
|
311
|
+
}
|
|
312
|
+
return cachedUint8ArrayMemory0;
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
function handleError(f, args) {
|
|
316
|
+
try {
|
|
317
|
+
return f.apply(this, args);
|
|
318
|
+
} catch (e) {
|
|
319
|
+
const idx = addToExternrefTable0(e);
|
|
320
|
+
wasm.__wbindgen_exn_store(idx);
|
|
321
|
+
}
|
|
322
|
+
}
|
|
323
|
+
|
|
324
|
+
function isLikeNone(x) {
|
|
325
|
+
return x === undefined || x === null;
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
function passStringToWasm0(arg, malloc, realloc) {
|
|
329
|
+
if (realloc === undefined) {
|
|
330
|
+
const buf = cachedTextEncoder.encode(arg);
|
|
331
|
+
const ptr = malloc(buf.length, 1) >>> 0;
|
|
332
|
+
getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);
|
|
333
|
+
WASM_VECTOR_LEN = buf.length;
|
|
334
|
+
return ptr;
|
|
335
|
+
}
|
|
336
|
+
|
|
337
|
+
let len = arg.length;
|
|
338
|
+
let ptr = malloc(len, 1) >>> 0;
|
|
339
|
+
|
|
340
|
+
const mem = getUint8ArrayMemory0();
|
|
341
|
+
|
|
342
|
+
let offset = 0;
|
|
343
|
+
|
|
344
|
+
for (; offset < len; offset++) {
|
|
345
|
+
const code = arg.charCodeAt(offset);
|
|
346
|
+
if (code > 0x7F) break;
|
|
347
|
+
mem[ptr + offset] = code;
|
|
348
|
+
}
|
|
349
|
+
if (offset !== len) {
|
|
350
|
+
if (offset !== 0) {
|
|
351
|
+
arg = arg.slice(offset);
|
|
352
|
+
}
|
|
353
|
+
ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
|
|
354
|
+
const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
|
|
355
|
+
const ret = cachedTextEncoder.encodeInto(arg, view);
|
|
356
|
+
|
|
357
|
+
offset += ret.written;
|
|
358
|
+
ptr = realloc(ptr, len, offset, 1) >>> 0;
|
|
359
|
+
}
|
|
360
|
+
|
|
361
|
+
WASM_VECTOR_LEN = offset;
|
|
362
|
+
return ptr;
|
|
363
|
+
}
|
|
364
|
+
|
|
365
|
+
function takeFromExternrefTable0(idx) {
|
|
366
|
+
const value = wasm.__wbindgen_externrefs.get(idx);
|
|
367
|
+
wasm.__externref_table_dealloc(idx);
|
|
368
|
+
return value;
|
|
369
|
+
}
|
|
370
|
+
|
|
371
|
+
let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
|
|
372
|
+
cachedTextDecoder.decode();
|
|
373
|
+
const MAX_SAFARI_DECODE_BYTES = 2146435072;
|
|
374
|
+
let numBytesDecoded = 0;
|
|
375
|
+
function decodeText(ptr, len) {
|
|
376
|
+
numBytesDecoded += len;
|
|
377
|
+
if (numBytesDecoded >= MAX_SAFARI_DECODE_BYTES) {
|
|
378
|
+
cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
|
|
379
|
+
cachedTextDecoder.decode();
|
|
380
|
+
numBytesDecoded = len;
|
|
381
|
+
}
|
|
382
|
+
return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
|
|
383
|
+
}
|
|
384
|
+
|
|
385
|
+
const cachedTextEncoder = new TextEncoder();
|
|
386
|
+
|
|
387
|
+
if (!('encodeInto' in cachedTextEncoder)) {
|
|
388
|
+
cachedTextEncoder.encodeInto = function (arg, view) {
|
|
389
|
+
const buf = cachedTextEncoder.encode(arg);
|
|
390
|
+
view.set(buf);
|
|
391
|
+
return {
|
|
392
|
+
read: arg.length,
|
|
393
|
+
written: buf.length
|
|
394
|
+
};
|
|
395
|
+
};
|
|
396
|
+
}
|
|
397
|
+
|
|
398
|
+
let WASM_VECTOR_LEN = 0;
|
|
399
|
+
|
|
400
|
+
|
|
401
|
+
let wasm;
|
|
402
|
+
export function __wbg_set_wasm(val) {
|
|
403
|
+
wasm = val;
|
|
404
|
+
}
|
|
Binary file
|