vulture-wasm 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/README.md +214 -0
- package/package.json +30 -0
- package/vulture_wasm.d.ts +155 -0
- package/vulture_wasm.js +566 -0
- package/vulture_wasm_bg.wasm +0 -0
package/README.md
ADDED
|
@@ -0,0 +1,214 @@
|
|
|
1
|
+
# vulture-wasm
|
|
2
|
+
|
|
3
|
+
WebAssembly bindings for [vulture](https://github.com/urschrei/vulture) – a Rust implementation of RAPTOR public-transit routing – exposed as a single browser-friendly ES module via [wasm-bindgen](https://rustwasm.github.io/wasm-bindgen/) and [wasm-pack](https://rustwasm.github.io/wasm-pack/).
|
|
4
|
+
|
|
5
|
+
The JS side fetches a GTFS zip with `fetch()`, hands the bytes to `new VultureTimetable(zipBytes, "YYYY-MM-DD")`, and runs queries against it. There is no HTTP code inside the wasm blob.
|
|
6
|
+
|
|
7
|
+
The wasm bundle is currently ~700 KB raw, ~275 KB gzipped.
|
|
8
|
+
|
|
9
|
+
## Install
|
|
10
|
+
|
|
11
|
+
```sh
|
|
12
|
+
npm install vulture-wasm
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
```js
|
|
16
|
+
import init, { VultureTimetable, runArrival, runRange } from "vulture-wasm";
|
|
17
|
+
|
|
18
|
+
await init(); // loads the wasm module
|
|
19
|
+
|
|
20
|
+
const zipBytes = new Uint8Array(
|
|
21
|
+
await (await fetch("/path/to/feed.zip")).arrayBuffer(),
|
|
22
|
+
);
|
|
23
|
+
const tt = new VultureTimetable(zipBytes, "2024-01-15");
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
## Drop-in via CDN (no build step)
|
|
27
|
+
|
|
28
|
+
```html
|
|
29
|
+
<script type="module">
|
|
30
|
+
import init, { VultureTimetable, runArrival, runRange }
|
|
31
|
+
from "https://cdn.jsdelivr.net/npm/vulture-wasm@latest/vulture_wasm.js";
|
|
32
|
+
|
|
33
|
+
await init();
|
|
34
|
+
|
|
35
|
+
const tt = new VultureTimetable(
|
|
36
|
+
new Uint8Array(await (await fetch("/feed.zip")).arrayBuffer()),
|
|
37
|
+
"2024-01-15",
|
|
38
|
+
);
|
|
39
|
+
</script>
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
## API
|
|
43
|
+
|
|
44
|
+
`VultureTimetable` (opaque handle):
|
|
45
|
+
|
|
46
|
+
- `new VultureTimetable(zipBytes, serviceDate)` — parse a GTFS zip (`Uint8Array`) and pin the timetable to an ISO date (`YYYY-MM-DD`).
|
|
47
|
+
- `tt.nStops()`, `tt.nRoutes()` — counts.
|
|
48
|
+
- `tt.stopIdx(gtfsId)` — GTFS stop id → opaque `StopIdx`, or `undefined`.
|
|
49
|
+
- `tt.stopName(stopIdx)`, `tt.stopCoords(stopIdx)`, `tt.routeName(routeIdx)`, `tt.routeAgency(routeIdx)` — display-data accessors.
|
|
50
|
+
- `tt.allStops()`, `tt.allRoutes()` — bulk catalogue dumps for populating UI pickers.
|
|
51
|
+
- `tt.withWalkingFootpaths(maxDistMeters, walkSpeedMetersPerSec)` — replace the footpath set with one derived from stop coordinates.
|
|
52
|
+
- `tt.resetFootpaths()` — restore the original `transfers.txt` set.
|
|
53
|
+
|
|
54
|
+
Free functions:
|
|
55
|
+
|
|
56
|
+
- `runArrival(tt, originStops, targetStops, maxTransfers, departSeconds, requireWheelchair)` — single-departure query. Returns an array of journeys with timed legs.
|
|
57
|
+
- `runRange(tt, origin, target, maxTransfers, departures, requireWheelchair)` — depart-in-window Pareto profile. Returns `[{depart, journey}]` where each `journey` has the same shape as a `runArrival` entry (`origin`, `target`, `arrival`, `legs`).
|
|
58
|
+
|
|
59
|
+
`originStops` / `targetStops` / `departures` are `Uint32Array`s; times are seconds since midnight on the service date. Full type signatures are in the bundled `vulture_wasm.d.ts`.
|
|
60
|
+
|
|
61
|
+
## Examples
|
|
62
|
+
|
|
63
|
+
### 1. Stop-to-stop, single departure
|
|
64
|
+
|
|
65
|
+
```js
|
|
66
|
+
import init, { VultureTimetable, runArrival } from "vulture-wasm";
|
|
67
|
+
|
|
68
|
+
await init();
|
|
69
|
+
|
|
70
|
+
const zip = new Uint8Array(
|
|
71
|
+
await (await fetch("https://urschrei.github.io/vulture/dmrc_gtfs.zip"))
|
|
72
|
+
.arrayBuffer(),
|
|
73
|
+
);
|
|
74
|
+
const tt = new VultureTimetable(zip, "2024-01-15");
|
|
75
|
+
|
|
76
|
+
const start = tt.stopIdx("1"); // Dilshad Garden
|
|
77
|
+
const target = tt.stopIdx("44"); // Vishwavidyalaya
|
|
78
|
+
|
|
79
|
+
const journeys = runArrival(
|
|
80
|
+
tt,
|
|
81
|
+
new Uint32Array([start]),
|
|
82
|
+
new Uint32Array([target]),
|
|
83
|
+
/* maxTransfers */ 10,
|
|
84
|
+
/* depart */ 9 * 3600, // 09:00:00
|
|
85
|
+
/* wheelchair */ false,
|
|
86
|
+
);
|
|
87
|
+
|
|
88
|
+
const fmt = (s) =>
|
|
89
|
+
`${String(Math.floor(s / 3600)).padStart(2, "0")}:` +
|
|
90
|
+
`${String(Math.floor((s % 3600) / 60)).padStart(2, "0")}`;
|
|
91
|
+
|
|
92
|
+
for (const j of journeys) {
|
|
93
|
+
console.log(
|
|
94
|
+
`${tt.stopName(j.origin)} -> ${tt.stopName(j.target)},` +
|
|
95
|
+
` arrives ${fmt(j.arrival)}`,
|
|
96
|
+
);
|
|
97
|
+
for (const leg of j.legs) {
|
|
98
|
+
console.log(
|
|
99
|
+
` ${fmt(leg.depart)} ${tt.stopName(leg.board_stop)}` +
|
|
100
|
+
` -> ${fmt(leg.arrive)} ${tt.stopName(leg.alight_stop)}` +
|
|
101
|
+
` on ${tt.routeName(leg.route)}`,
|
|
102
|
+
);
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
### 2. Departure window (range query)
|
|
108
|
+
|
|
109
|
+
"Show me the Pareto-optimal options if I leave any time between 09:00 and 10:00."
|
|
110
|
+
|
|
111
|
+
```js
|
|
112
|
+
import init, { VultureTimetable, runRange } from "vulture-wasm";
|
|
113
|
+
|
|
114
|
+
await init();
|
|
115
|
+
|
|
116
|
+
const tt = new VultureTimetable(
|
|
117
|
+
new Uint8Array(
|
|
118
|
+
await (await fetch("https://urschrei.github.io/vulture/dmrc_gtfs.zip"))
|
|
119
|
+
.arrayBuffer(),
|
|
120
|
+
),
|
|
121
|
+
"2024-01-15",
|
|
122
|
+
);
|
|
123
|
+
|
|
124
|
+
const origin = tt.stopIdx("1");
|
|
125
|
+
const target = tt.stopIdx("44");
|
|
126
|
+
|
|
127
|
+
// Every 5 minutes from 09:00 up to (and including) 10:00.
|
|
128
|
+
const departures = new Uint32Array(
|
|
129
|
+
Array.from({ length: 13 }, (_, i) => 9 * 3600 + i * 300),
|
|
130
|
+
);
|
|
131
|
+
|
|
132
|
+
const profile = runRange(tt, origin, target, 10, departures, false);
|
|
133
|
+
|
|
134
|
+
for (const entry of profile) {
|
|
135
|
+
console.log(
|
|
136
|
+
`leave ${entry.depart}s -> arrive ${entry.journey.arrival}s` +
|
|
137
|
+
` in ${entry.journey.legs.length} leg(s)`,
|
|
138
|
+
);
|
|
139
|
+
}
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
### 3. Walking footpaths from coordinates
|
|
143
|
+
|
|
144
|
+
GTFS feeds with sparse `transfers.txt` (e.g. Helsinki HSL) leave most station-to-station walks unmodelled. Augment from coordinates and compare:
|
|
145
|
+
|
|
146
|
+
```js
|
|
147
|
+
import init, { VultureTimetable, runArrival } from "vulture-wasm";
|
|
148
|
+
|
|
149
|
+
await init();
|
|
150
|
+
|
|
151
|
+
const tt = new VultureTimetable(
|
|
152
|
+
new Uint8Array(await (await fetch("/path/to/feed.zip")).arrayBuffer()),
|
|
153
|
+
"2024-01-15",
|
|
154
|
+
);
|
|
155
|
+
|
|
156
|
+
const args = [
|
|
157
|
+
tt,
|
|
158
|
+
new Uint32Array([tt.stopIdx("1040601")]), // Kamppi metro
|
|
159
|
+
new Uint32Array([tt.stopIdx("1453601")]), // Itäkeskus metro
|
|
160
|
+
/* maxTransfers */ 10,
|
|
161
|
+
/* depart */ 9 * 3600,
|
|
162
|
+
/* wheelchair */ false,
|
|
163
|
+
];
|
|
164
|
+
|
|
165
|
+
const before = runArrival(...args);
|
|
166
|
+
console.log(`without footpaths: ${before.length} journey(s)`);
|
|
167
|
+
|
|
168
|
+
tt.withWalkingFootpaths(500, 1.4); // 500 m at ~5 km/h
|
|
169
|
+
const after = runArrival(...args);
|
|
170
|
+
console.log(`with footpaths: ${after.length} journey(s)`);
|
|
171
|
+
```
|
|
172
|
+
|
|
173
|
+
`tt.resetFootpaths()` restores the original `transfers.txt` set.
|
|
174
|
+
|
|
175
|
+
## Build from source
|
|
176
|
+
|
|
177
|
+
```sh
|
|
178
|
+
# From the repo root:
|
|
179
|
+
./scripts/build-demo.sh # builds vulture-wasm/pkg/ and docs/demo/pkg/
|
|
180
|
+
./scripts/build-demo.sh --serve # ... and then serves docs/demo/ at http://localhost:8765
|
|
181
|
+
|
|
182
|
+
# Or wasm-pack directly:
|
|
183
|
+
wasm-pack build vulture-wasm --target web --release
|
|
184
|
+
```
|
|
185
|
+
|
|
186
|
+
The web (ESM) target is the canonical and only output. It works in browsers, in modern Node, and inside any bundler that understands ES modules.
|
|
187
|
+
|
|
188
|
+
## Node
|
|
189
|
+
|
|
190
|
+
Same package, same import — Node just needs the wasm bytes passed in explicitly because there's no relative `fetch()` for the bundled `.wasm` file:
|
|
191
|
+
|
|
192
|
+
```js
|
|
193
|
+
import init, { VultureTimetable, runArrival } from "vulture-wasm";
|
|
194
|
+
import { readFileSync } from "node:fs";
|
|
195
|
+
import { createRequire } from "node:module";
|
|
196
|
+
|
|
197
|
+
const require = createRequire(import.meta.url);
|
|
198
|
+
const wasmPath = require.resolve("vulture-wasm/vulture_wasm_bg.wasm");
|
|
199
|
+
|
|
200
|
+
await init({ module_or_path: readFileSync(wasmPath) });
|
|
201
|
+
|
|
202
|
+
const tt = new VultureTimetable(readFileSync("feed.zip"), "2024-01-15");
|
|
203
|
+
```
|
|
204
|
+
|
|
205
|
+
The smoke test at `vulture-wasm/tests/smoke.mjs` is a runnable example: it loads the bundled Delhi Metro feed and exercises every public function. Run it with:
|
|
206
|
+
|
|
207
|
+
```sh
|
|
208
|
+
wasm-pack build vulture-wasm --target web --release
|
|
209
|
+
node vulture-wasm/tests/smoke.mjs
|
|
210
|
+
```
|
|
211
|
+
|
|
212
|
+
## Demo page
|
|
213
|
+
|
|
214
|
+
`docs/demo/` is a vanilla-JS / vanilla-CSS demo with three panels – stop-to-stop, departure window, walking-footpath comparison – running entirely client-side against the bundled Delhi Metro feed. Live at <https://urschrei.github.io/vulture/>.
|
package/package.json
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "vulture-wasm",
|
|
3
|
+
"collaborators": [
|
|
4
|
+
"Stephan Hügel <urschrei@gmail.com>"
|
|
5
|
+
],
|
|
6
|
+
"description": "WebAssembly bindings for vulture (RAPTOR transit routing)",
|
|
7
|
+
"version": "0.1.0",
|
|
8
|
+
"license": "Apache-2.0",
|
|
9
|
+
"repository": {
|
|
10
|
+
"type": "git",
|
|
11
|
+
"url": "https://github.com/urschrei/vulture"
|
|
12
|
+
},
|
|
13
|
+
"files": [
|
|
14
|
+
"vulture_wasm_bg.wasm",
|
|
15
|
+
"vulture_wasm.js",
|
|
16
|
+
"vulture_wasm.d.ts"
|
|
17
|
+
],
|
|
18
|
+
"module": "vulture_wasm.js",
|
|
19
|
+
"types": "vulture_wasm.d.ts",
|
|
20
|
+
"type": "module",
|
|
21
|
+
"main": "vulture_wasm.js",
|
|
22
|
+
"exports": {
|
|
23
|
+
".": "./vulture_wasm.js",
|
|
24
|
+
"./vulture_wasm_bg.wasm": "./vulture_wasm_bg.wasm"
|
|
25
|
+
},
|
|
26
|
+
"homepage": "https://urschrei.github.io/vulture/",
|
|
27
|
+
"bugs": {
|
|
28
|
+
"url": "https://github.com/urschrei/vulture/issues"
|
|
29
|
+
}
|
|
30
|
+
}
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
/* tslint:disable */
|
|
2
|
+
/* eslint-disable */
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Opaque handle to a parsed GTFS feed + timetable. The JS side
|
|
6
|
+
* constructs one from a `Uint8Array` of the GTFS zip and passes it
|
|
7
|
+
* into query functions by reference. The struct holds both the
|
|
8
|
+
* parsed [`Gtfs`] (used for display-data lookups: stop names,
|
|
9
|
+
* route names, coordinates) and the algorithm-side [`VTimetable`].
|
|
10
|
+
*/
|
|
11
|
+
export class VultureTimetable {
|
|
12
|
+
free(): void;
|
|
13
|
+
[Symbol.dispose](): void;
|
|
14
|
+
/**
|
|
15
|
+
* Returns the entire synthetic-route catalogue as a JS array of
|
|
16
|
+
* `{idx, id, name, agency}` objects.
|
|
17
|
+
*/
|
|
18
|
+
allRoutes(): any;
|
|
19
|
+
/**
|
|
20
|
+
* Returns the entire stop catalogue as a JS array of
|
|
21
|
+
* `{idx, id, name, lat, lon}` objects, suitable for populating
|
|
22
|
+
* a dropdown. Stops without coordinates have `lat`/`lon` set to
|
|
23
|
+
* `null`.
|
|
24
|
+
*/
|
|
25
|
+
allStops(): any;
|
|
26
|
+
/**
|
|
27
|
+
* Number of synthetic RAPTOR routes (one or more per GTFS
|
|
28
|
+
* `route_id`).
|
|
29
|
+
*/
|
|
30
|
+
nRoutes(): number;
|
|
31
|
+
/**
|
|
32
|
+
* Number of stops in the loaded timetable.
|
|
33
|
+
*/
|
|
34
|
+
nStops(): number;
|
|
35
|
+
/**
|
|
36
|
+
* Parse a GTFS zip (as a `Uint8Array`) and pin the timetable to
|
|
37
|
+
* `service_date` (ISO `YYYY-MM-DD`). Returns a handle the query
|
|
38
|
+
* functions take by reference.
|
|
39
|
+
*/
|
|
40
|
+
constructor(zip_bytes: Uint8Array, service_date: string);
|
|
41
|
+
/**
|
|
42
|
+
* Reset the timetable to its base-date single-day state,
|
|
43
|
+
* discarding any walking-footpath augmentation. Useful for
|
|
44
|
+
* "before/after" demos.
|
|
45
|
+
*/
|
|
46
|
+
resetFootpaths(): void;
|
|
47
|
+
/**
|
|
48
|
+
* Returns the agency name for the given route, or `undefined`
|
|
49
|
+
* if the route has no agency set or the agency record is
|
|
50
|
+
* missing.
|
|
51
|
+
*/
|
|
52
|
+
routeAgency(idx: number): string | undefined;
|
|
53
|
+
/**
|
|
54
|
+
* Returns the GTFS `route_long_name` (falling back to
|
|
55
|
+
* `route_short_name` when the long name is empty) for the given
|
|
56
|
+
* synthetic route index. Several `RouteIdx`s can share a name —
|
|
57
|
+
* vulture splits one GTFS `route_id` into one or more synthetic
|
|
58
|
+
* routes by stop-pattern.
|
|
59
|
+
*/
|
|
60
|
+
routeName(idx: number): string | undefined;
|
|
61
|
+
/**
|
|
62
|
+
* Returns the GTFS `[lat, lon]` for the given stop index, or
|
|
63
|
+
* `undefined` if the stop has no coordinates set.
|
|
64
|
+
*/
|
|
65
|
+
stopCoords(idx: number): Float64Array | undefined;
|
|
66
|
+
/**
|
|
67
|
+
* Resolve a GTFS `stop_id` to an integer index, or `undefined`
|
|
68
|
+
* if not in the timetable. JS callers feed the integer back into
|
|
69
|
+
* `runArrival` / `runRange`.
|
|
70
|
+
*/
|
|
71
|
+
stopIdx(id: string): number | undefined;
|
|
72
|
+
/**
|
|
73
|
+
* Returns the GTFS `stop_name` for the given index, or
|
|
74
|
+
* `undefined` if the stop has no name field set.
|
|
75
|
+
*/
|
|
76
|
+
stopName(idx: number): string | undefined;
|
|
77
|
+
/**
|
|
78
|
+
* Augment the timetable's footpath graph with bidirectional
|
|
79
|
+
* walking edges between every pair of stops within
|
|
80
|
+
* `max_distance_m` straight-line distance, using
|
|
81
|
+
* `walking_speed_m_per_s` (1.4 m/s ≈ standard pedestrian rate).
|
|
82
|
+
* Mutates the timetable in place; subsequent queries see the
|
|
83
|
+
* added footpaths.
|
|
84
|
+
*/
|
|
85
|
+
withWalkingFootpaths(max_distance_m: number, walking_speed_m_per_s: number): void;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* Single-criterion arrival-time query. `origins` and `targets` are
|
|
90
|
+
* `Uint32Array`s of stop indices (each entry gets walk-time zero).
|
|
91
|
+
* `depart` is seconds since midnight.
|
|
92
|
+
*/
|
|
93
|
+
export function runArrival(tt: VultureTimetable, origins: Uint32Array, targets: Uint32Array, max_transfers: number, depart: number, require_wheelchair: boolean): any;
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
* Range query: run RAPTOR across a window of departure times. JS
|
|
97
|
+
* passes `departures` as a `Uint32Array` of seconds-since-midnight
|
|
98
|
+
* values. Returns `[{depart, journey}]` Pareto-filtered on
|
|
99
|
+
* `(later depart, fewer transfers, earlier arrival)`.
|
|
100
|
+
*
|
|
101
|
+
* Currently single-source / single-target only — the demo's range
|
|
102
|
+
* panel doesn't need multi-endpoint, and rRAPTOR's serial path
|
|
103
|
+
* (the one we use here) requires `ArrivalTime`.
|
|
104
|
+
*/
|
|
105
|
+
export function runRange(tt: VultureTimetable, origin: number, target: number, max_transfers: number, departures: Uint32Array, require_wheelchair: boolean): any;
|
|
106
|
+
|
|
107
|
+
export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembly.Module;
|
|
108
|
+
|
|
109
|
+
export interface InitOutput {
|
|
110
|
+
readonly memory: WebAssembly.Memory;
|
|
111
|
+
readonly __wbg_vulturetimetable_free: (a: number, b: number) => void;
|
|
112
|
+
readonly runArrival: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number) => [number, number, number];
|
|
113
|
+
readonly runRange: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => [number, number, number];
|
|
114
|
+
readonly vulturetimetable_allRoutes: (a: number) => [number, number, number];
|
|
115
|
+
readonly vulturetimetable_allStops: (a: number) => [number, number, number];
|
|
116
|
+
readonly vulturetimetable_nRoutes: (a: number) => number;
|
|
117
|
+
readonly vulturetimetable_nStops: (a: number) => number;
|
|
118
|
+
readonly vulturetimetable_new: (a: number, b: number, c: number, d: number) => [number, number, number];
|
|
119
|
+
readonly vulturetimetable_resetFootpaths: (a: number) => [number, number];
|
|
120
|
+
readonly vulturetimetable_routeAgency: (a: number, b: number) => [number, number];
|
|
121
|
+
readonly vulturetimetable_routeName: (a: number, b: number) => [number, number];
|
|
122
|
+
readonly vulturetimetable_stopCoords: (a: number, b: number) => [number, number];
|
|
123
|
+
readonly vulturetimetable_stopIdx: (a: number, b: number, c: number) => number;
|
|
124
|
+
readonly vulturetimetable_stopName: (a: number, b: number) => [number, number];
|
|
125
|
+
readonly vulturetimetable_withWalkingFootpaths: (a: number, b: number, c: number) => void;
|
|
126
|
+
readonly __wbindgen_malloc: (a: number, b: number) => number;
|
|
127
|
+
readonly __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
|
|
128
|
+
readonly __externref_table_alloc: () => number;
|
|
129
|
+
readonly __wbindgen_externrefs: WebAssembly.Table;
|
|
130
|
+
readonly __externref_table_dealloc: (a: number) => void;
|
|
131
|
+
readonly __wbindgen_free: (a: number, b: number, c: number) => void;
|
|
132
|
+
readonly __wbindgen_start: () => void;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
export type SyncInitInput = BufferSource | WebAssembly.Module;
|
|
136
|
+
|
|
137
|
+
/**
|
|
138
|
+
* Instantiates the given `module`, which can either be bytes or
|
|
139
|
+
* a precompiled `WebAssembly.Module`.
|
|
140
|
+
*
|
|
141
|
+
* @param {{ module: SyncInitInput }} module - Passing `SyncInitInput` directly is deprecated.
|
|
142
|
+
*
|
|
143
|
+
* @returns {InitOutput}
|
|
144
|
+
*/
|
|
145
|
+
export function initSync(module: { module: SyncInitInput } | SyncInitInput): InitOutput;
|
|
146
|
+
|
|
147
|
+
/**
|
|
148
|
+
* If `module_or_path` is {RequestInfo} or {URL}, makes a request and
|
|
149
|
+
* for everything else, calls `WebAssembly.instantiate` directly.
|
|
150
|
+
*
|
|
151
|
+
* @param {{ module_or_path: InitInput | Promise<InitInput> }} module_or_path - Passing `InitInput` directly is deprecated.
|
|
152
|
+
*
|
|
153
|
+
* @returns {Promise<InitOutput>}
|
|
154
|
+
*/
|
|
155
|
+
export default function __wbg_init (module_or_path?: { module_or_path: InitInput | Promise<InitInput> } | InitInput | Promise<InitInput>): Promise<InitOutput>;
|
package/vulture_wasm.js
ADDED
|
@@ -0,0 +1,566 @@
|
|
|
1
|
+
/* @ts-self-types="./vulture_wasm.d.ts" */
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Opaque handle to a parsed GTFS feed + timetable. The JS side
|
|
5
|
+
* constructs one from a `Uint8Array` of the GTFS zip and passes it
|
|
6
|
+
* into query functions by reference. The struct holds both the
|
|
7
|
+
* parsed [`Gtfs`] (used for display-data lookups: stop names,
|
|
8
|
+
* route names, coordinates) and the algorithm-side [`VTimetable`].
|
|
9
|
+
*/
|
|
10
|
+
export class VultureTimetable {
|
|
11
|
+
__destroy_into_raw() {
|
|
12
|
+
const ptr = this.__wbg_ptr;
|
|
13
|
+
this.__wbg_ptr = 0;
|
|
14
|
+
VultureTimetableFinalization.unregister(this);
|
|
15
|
+
return ptr;
|
|
16
|
+
}
|
|
17
|
+
free() {
|
|
18
|
+
const ptr = this.__destroy_into_raw();
|
|
19
|
+
wasm.__wbg_vulturetimetable_free(ptr, 0);
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Returns the entire synthetic-route catalogue as a JS array of
|
|
23
|
+
* `{idx, id, name, agency}` objects.
|
|
24
|
+
* @returns {any}
|
|
25
|
+
*/
|
|
26
|
+
allRoutes() {
|
|
27
|
+
const ret = wasm.vulturetimetable_allRoutes(this.__wbg_ptr);
|
|
28
|
+
if (ret[2]) {
|
|
29
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
30
|
+
}
|
|
31
|
+
return takeFromExternrefTable0(ret[0]);
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Returns the entire stop catalogue as a JS array of
|
|
35
|
+
* `{idx, id, name, lat, lon}` objects, suitable for populating
|
|
36
|
+
* a dropdown. Stops without coordinates have `lat`/`lon` set to
|
|
37
|
+
* `null`.
|
|
38
|
+
* @returns {any}
|
|
39
|
+
*/
|
|
40
|
+
allStops() {
|
|
41
|
+
const ret = wasm.vulturetimetable_allStops(this.__wbg_ptr);
|
|
42
|
+
if (ret[2]) {
|
|
43
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
44
|
+
}
|
|
45
|
+
return takeFromExternrefTable0(ret[0]);
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Number of synthetic RAPTOR routes (one or more per GTFS
|
|
49
|
+
* `route_id`).
|
|
50
|
+
* @returns {number}
|
|
51
|
+
*/
|
|
52
|
+
nRoutes() {
|
|
53
|
+
const ret = wasm.vulturetimetable_nRoutes(this.__wbg_ptr);
|
|
54
|
+
return ret >>> 0;
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Number of stops in the loaded timetable.
|
|
58
|
+
* @returns {number}
|
|
59
|
+
*/
|
|
60
|
+
nStops() {
|
|
61
|
+
const ret = wasm.vulturetimetable_nStops(this.__wbg_ptr);
|
|
62
|
+
return ret >>> 0;
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Parse a GTFS zip (as a `Uint8Array`) and pin the timetable to
|
|
66
|
+
* `service_date` (ISO `YYYY-MM-DD`). Returns a handle the query
|
|
67
|
+
* functions take by reference.
|
|
68
|
+
* @param {Uint8Array} zip_bytes
|
|
69
|
+
* @param {string} service_date
|
|
70
|
+
*/
|
|
71
|
+
constructor(zip_bytes, service_date) {
|
|
72
|
+
const ptr0 = passArray8ToWasm0(zip_bytes, wasm.__wbindgen_malloc);
|
|
73
|
+
const len0 = WASM_VECTOR_LEN;
|
|
74
|
+
const ptr1 = passStringToWasm0(service_date, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
75
|
+
const len1 = WASM_VECTOR_LEN;
|
|
76
|
+
const ret = wasm.vulturetimetable_new(ptr0, len0, ptr1, len1);
|
|
77
|
+
if (ret[2]) {
|
|
78
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
79
|
+
}
|
|
80
|
+
this.__wbg_ptr = ret[0];
|
|
81
|
+
VultureTimetableFinalization.register(this, this.__wbg_ptr, this);
|
|
82
|
+
return this;
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Reset the timetable to its base-date single-day state,
|
|
86
|
+
* discarding any walking-footpath augmentation. Useful for
|
|
87
|
+
* "before/after" demos.
|
|
88
|
+
*/
|
|
89
|
+
resetFootpaths() {
|
|
90
|
+
const ret = wasm.vulturetimetable_resetFootpaths(this.__wbg_ptr);
|
|
91
|
+
if (ret[1]) {
|
|
92
|
+
throw takeFromExternrefTable0(ret[0]);
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* Returns the agency name for the given route, or `undefined`
|
|
97
|
+
* if the route has no agency set or the agency record is
|
|
98
|
+
* missing.
|
|
99
|
+
* @param {number} idx
|
|
100
|
+
* @returns {string | undefined}
|
|
101
|
+
*/
|
|
102
|
+
routeAgency(idx) {
|
|
103
|
+
const ret = wasm.vulturetimetable_routeAgency(this.__wbg_ptr, idx);
|
|
104
|
+
let v1;
|
|
105
|
+
if (ret[0] !== 0) {
|
|
106
|
+
v1 = getStringFromWasm0(ret[0], ret[1]).slice();
|
|
107
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
108
|
+
}
|
|
109
|
+
return v1;
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* Returns the GTFS `route_long_name` (falling back to
|
|
113
|
+
* `route_short_name` when the long name is empty) for the given
|
|
114
|
+
* synthetic route index. Several `RouteIdx`s can share a name —
|
|
115
|
+
* vulture splits one GTFS `route_id` into one or more synthetic
|
|
116
|
+
* routes by stop-pattern.
|
|
117
|
+
* @param {number} idx
|
|
118
|
+
* @returns {string | undefined}
|
|
119
|
+
*/
|
|
120
|
+
routeName(idx) {
|
|
121
|
+
const ret = wasm.vulturetimetable_routeName(this.__wbg_ptr, idx);
|
|
122
|
+
let v1;
|
|
123
|
+
if (ret[0] !== 0) {
|
|
124
|
+
v1 = getStringFromWasm0(ret[0], ret[1]).slice();
|
|
125
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
126
|
+
}
|
|
127
|
+
return v1;
|
|
128
|
+
}
|
|
129
|
+
/**
|
|
130
|
+
* Returns the GTFS `[lat, lon]` for the given stop index, or
|
|
131
|
+
* `undefined` if the stop has no coordinates set.
|
|
132
|
+
* @param {number} idx
|
|
133
|
+
* @returns {Float64Array | undefined}
|
|
134
|
+
*/
|
|
135
|
+
stopCoords(idx) {
|
|
136
|
+
const ret = wasm.vulturetimetable_stopCoords(this.__wbg_ptr, idx);
|
|
137
|
+
let v1;
|
|
138
|
+
if (ret[0] !== 0) {
|
|
139
|
+
v1 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
|
|
140
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
|
|
141
|
+
}
|
|
142
|
+
return v1;
|
|
143
|
+
}
|
|
144
|
+
/**
|
|
145
|
+
* Resolve a GTFS `stop_id` to an integer index, or `undefined`
|
|
146
|
+
* if not in the timetable. JS callers feed the integer back into
|
|
147
|
+
* `runArrival` / `runRange`.
|
|
148
|
+
* @param {string} id
|
|
149
|
+
* @returns {number | undefined}
|
|
150
|
+
*/
|
|
151
|
+
stopIdx(id) {
|
|
152
|
+
const ptr0 = passStringToWasm0(id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
153
|
+
const len0 = WASM_VECTOR_LEN;
|
|
154
|
+
const ret = wasm.vulturetimetable_stopIdx(this.__wbg_ptr, ptr0, len0);
|
|
155
|
+
return ret === Number.MAX_SAFE_INTEGER ? undefined : ret;
|
|
156
|
+
}
|
|
157
|
+
/**
|
|
158
|
+
* Returns the GTFS `stop_name` for the given index, or
|
|
159
|
+
* `undefined` if the stop has no name field set.
|
|
160
|
+
* @param {number} idx
|
|
161
|
+
* @returns {string | undefined}
|
|
162
|
+
*/
|
|
163
|
+
stopName(idx) {
|
|
164
|
+
const ret = wasm.vulturetimetable_stopName(this.__wbg_ptr, idx);
|
|
165
|
+
let v1;
|
|
166
|
+
if (ret[0] !== 0) {
|
|
167
|
+
v1 = getStringFromWasm0(ret[0], ret[1]).slice();
|
|
168
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
169
|
+
}
|
|
170
|
+
return v1;
|
|
171
|
+
}
|
|
172
|
+
/**
|
|
173
|
+
* Augment the timetable's footpath graph with bidirectional
|
|
174
|
+
* walking edges between every pair of stops within
|
|
175
|
+
* `max_distance_m` straight-line distance, using
|
|
176
|
+
* `walking_speed_m_per_s` (1.4 m/s ≈ standard pedestrian rate).
|
|
177
|
+
* Mutates the timetable in place; subsequent queries see the
|
|
178
|
+
* added footpaths.
|
|
179
|
+
* @param {number} max_distance_m
|
|
180
|
+
* @param {number} walking_speed_m_per_s
|
|
181
|
+
*/
|
|
182
|
+
withWalkingFootpaths(max_distance_m, walking_speed_m_per_s) {
|
|
183
|
+
wasm.vulturetimetable_withWalkingFootpaths(this.__wbg_ptr, max_distance_m, walking_speed_m_per_s);
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
if (Symbol.dispose) VultureTimetable.prototype[Symbol.dispose] = VultureTimetable.prototype.free;
|
|
187
|
+
|
|
188
|
+
/**
|
|
189
|
+
* Single-criterion arrival-time query. `origins` and `targets` are
|
|
190
|
+
* `Uint32Array`s of stop indices (each entry gets walk-time zero).
|
|
191
|
+
* `depart` is seconds since midnight.
|
|
192
|
+
* @param {VultureTimetable} tt
|
|
193
|
+
* @param {Uint32Array} origins
|
|
194
|
+
* @param {Uint32Array} targets
|
|
195
|
+
* @param {number} max_transfers
|
|
196
|
+
* @param {number} depart
|
|
197
|
+
* @param {boolean} require_wheelchair
|
|
198
|
+
* @returns {any}
|
|
199
|
+
*/
|
|
200
|
+
export function runArrival(tt, origins, targets, max_transfers, depart, require_wheelchair) {
|
|
201
|
+
_assertClass(tt, VultureTimetable);
|
|
202
|
+
const ptr0 = passArray32ToWasm0(origins, wasm.__wbindgen_malloc);
|
|
203
|
+
const len0 = WASM_VECTOR_LEN;
|
|
204
|
+
const ptr1 = passArray32ToWasm0(targets, wasm.__wbindgen_malloc);
|
|
205
|
+
const len1 = WASM_VECTOR_LEN;
|
|
206
|
+
const ret = wasm.runArrival(tt.__wbg_ptr, ptr0, len0, ptr1, len1, max_transfers, depart, require_wheelchair);
|
|
207
|
+
if (ret[2]) {
|
|
208
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
209
|
+
}
|
|
210
|
+
return takeFromExternrefTable0(ret[0]);
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
/**
|
|
214
|
+
* Range query: run RAPTOR across a window of departure times. JS
|
|
215
|
+
* passes `departures` as a `Uint32Array` of seconds-since-midnight
|
|
216
|
+
* values. Returns `[{depart, journey}]` Pareto-filtered on
|
|
217
|
+
* `(later depart, fewer transfers, earlier arrival)`.
|
|
218
|
+
*
|
|
219
|
+
* Currently single-source / single-target only — the demo's range
|
|
220
|
+
* panel doesn't need multi-endpoint, and rRAPTOR's serial path
|
|
221
|
+
* (the one we use here) requires `ArrivalTime`.
|
|
222
|
+
* @param {VultureTimetable} tt
|
|
223
|
+
* @param {number} origin
|
|
224
|
+
* @param {number} target
|
|
225
|
+
* @param {number} max_transfers
|
|
226
|
+
* @param {Uint32Array} departures
|
|
227
|
+
* @param {boolean} require_wheelchair
|
|
228
|
+
* @returns {any}
|
|
229
|
+
*/
|
|
230
|
+
export function runRange(tt, origin, target, max_transfers, departures, require_wheelchair) {
|
|
231
|
+
_assertClass(tt, VultureTimetable);
|
|
232
|
+
const ptr0 = passArray32ToWasm0(departures, wasm.__wbindgen_malloc);
|
|
233
|
+
const len0 = WASM_VECTOR_LEN;
|
|
234
|
+
const ret = wasm.runRange(tt.__wbg_ptr, origin, target, max_transfers, ptr0, len0, require_wheelchair);
|
|
235
|
+
if (ret[2]) {
|
|
236
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
237
|
+
}
|
|
238
|
+
return takeFromExternrefTable0(ret[0]);
|
|
239
|
+
}
|
|
240
|
+
function __wbg_get_imports() {
|
|
241
|
+
const import0 = {
|
|
242
|
+
__proto__: null,
|
|
243
|
+
__wbg_Error_3639a60ed15f87e7: function(arg0, arg1) {
|
|
244
|
+
const ret = Error(getStringFromWasm0(arg0, arg1));
|
|
245
|
+
return ret;
|
|
246
|
+
},
|
|
247
|
+
__wbg_String_8564e559799eccda: function(arg0, arg1) {
|
|
248
|
+
const ret = String(arg1);
|
|
249
|
+
const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
250
|
+
const len1 = WASM_VECTOR_LEN;
|
|
251
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
|
|
252
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
|
|
253
|
+
},
|
|
254
|
+
__wbg___wbindgen_is_undefined_244a92c34d3b6ec0: function(arg0) {
|
|
255
|
+
const ret = arg0 === undefined;
|
|
256
|
+
return ret;
|
|
257
|
+
},
|
|
258
|
+
__wbg___wbindgen_throw_9c75d47bf9e7731e: function(arg0, arg1) {
|
|
259
|
+
throw new Error(getStringFromWasm0(arg0, arg1));
|
|
260
|
+
},
|
|
261
|
+
__wbg_new_2fad8ca02fd00684: function() {
|
|
262
|
+
const ret = new Object();
|
|
263
|
+
return ret;
|
|
264
|
+
},
|
|
265
|
+
__wbg_new_3baa8d9866155c79: function() {
|
|
266
|
+
const ret = new Array();
|
|
267
|
+
return ret;
|
|
268
|
+
},
|
|
269
|
+
__wbg_now_e7c6795a7f81e10f: function(arg0) {
|
|
270
|
+
const ret = arg0.now();
|
|
271
|
+
return ret;
|
|
272
|
+
},
|
|
273
|
+
__wbg_performance_3fcf6e32a7e1ed0a: function(arg0) {
|
|
274
|
+
const ret = arg0.performance;
|
|
275
|
+
return ret;
|
|
276
|
+
},
|
|
277
|
+
__wbg_set_6be42768c690e380: function(arg0, arg1, arg2) {
|
|
278
|
+
arg0[arg1] = arg2;
|
|
279
|
+
},
|
|
280
|
+
__wbg_set_f614f6a0608d1d1d: function(arg0, arg1, arg2) {
|
|
281
|
+
arg0[arg1 >>> 0] = arg2;
|
|
282
|
+
},
|
|
283
|
+
__wbg_static_accessor_GLOBAL_THIS_1c7f1bd6c6941fdb: function() {
|
|
284
|
+
const ret = typeof globalThis === 'undefined' ? null : globalThis;
|
|
285
|
+
return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
|
|
286
|
+
},
|
|
287
|
+
__wbg_static_accessor_GLOBAL_e039bc914f83e74e: function() {
|
|
288
|
+
const ret = typeof global === 'undefined' ? null : global;
|
|
289
|
+
return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
|
|
290
|
+
},
|
|
291
|
+
__wbg_static_accessor_SELF_8bf8c48c28420ad5: function() {
|
|
292
|
+
const ret = typeof self === 'undefined' ? null : self;
|
|
293
|
+
return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
|
|
294
|
+
},
|
|
295
|
+
__wbg_static_accessor_WINDOW_6aeee9b51652ee0f: function() {
|
|
296
|
+
const ret = typeof window === 'undefined' ? null : window;
|
|
297
|
+
return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
|
|
298
|
+
},
|
|
299
|
+
__wbindgen_cast_0000000000000001: function(arg0) {
|
|
300
|
+
// Cast intrinsic for `F64 -> Externref`.
|
|
301
|
+
const ret = arg0;
|
|
302
|
+
return ret;
|
|
303
|
+
},
|
|
304
|
+
__wbindgen_cast_0000000000000002: function(arg0, arg1) {
|
|
305
|
+
// Cast intrinsic for `Ref(String) -> Externref`.
|
|
306
|
+
const ret = getStringFromWasm0(arg0, arg1);
|
|
307
|
+
return ret;
|
|
308
|
+
},
|
|
309
|
+
__wbindgen_init_externref_table: function() {
|
|
310
|
+
const table = wasm.__wbindgen_externrefs;
|
|
311
|
+
const offset = table.grow(4);
|
|
312
|
+
table.set(0, undefined);
|
|
313
|
+
table.set(offset + 0, undefined);
|
|
314
|
+
table.set(offset + 1, null);
|
|
315
|
+
table.set(offset + 2, true);
|
|
316
|
+
table.set(offset + 3, false);
|
|
317
|
+
},
|
|
318
|
+
};
|
|
319
|
+
return {
|
|
320
|
+
__proto__: null,
|
|
321
|
+
"./vulture_wasm_bg.js": import0,
|
|
322
|
+
};
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
const VultureTimetableFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
326
|
+
? { register: () => {}, unregister: () => {} }
|
|
327
|
+
: new FinalizationRegistry(ptr => wasm.__wbg_vulturetimetable_free(ptr, 1));
|
|
328
|
+
|
|
329
|
+
function addToExternrefTable0(obj) {
|
|
330
|
+
const idx = wasm.__externref_table_alloc();
|
|
331
|
+
wasm.__wbindgen_externrefs.set(idx, obj);
|
|
332
|
+
return idx;
|
|
333
|
+
}
|
|
334
|
+
|
|
335
|
+
function _assertClass(instance, klass) {
|
|
336
|
+
if (!(instance instanceof klass)) {
|
|
337
|
+
throw new Error(`expected instance of ${klass.name}`);
|
|
338
|
+
}
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
function getArrayF64FromWasm0(ptr, len) {
|
|
342
|
+
ptr = ptr >>> 0;
|
|
343
|
+
return getFloat64ArrayMemory0().subarray(ptr / 8, ptr / 8 + len);
|
|
344
|
+
}
|
|
345
|
+
|
|
346
|
+
let cachedDataViewMemory0 = null;
|
|
347
|
+
function getDataViewMemory0() {
|
|
348
|
+
if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || (cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm.memory.buffer)) {
|
|
349
|
+
cachedDataViewMemory0 = new DataView(wasm.memory.buffer);
|
|
350
|
+
}
|
|
351
|
+
return cachedDataViewMemory0;
|
|
352
|
+
}
|
|
353
|
+
|
|
354
|
+
let cachedFloat64ArrayMemory0 = null;
|
|
355
|
+
function getFloat64ArrayMemory0() {
|
|
356
|
+
if (cachedFloat64ArrayMemory0 === null || cachedFloat64ArrayMemory0.byteLength === 0) {
|
|
357
|
+
cachedFloat64ArrayMemory0 = new Float64Array(wasm.memory.buffer);
|
|
358
|
+
}
|
|
359
|
+
return cachedFloat64ArrayMemory0;
|
|
360
|
+
}
|
|
361
|
+
|
|
362
|
+
function getStringFromWasm0(ptr, len) {
|
|
363
|
+
return decodeText(ptr >>> 0, len);
|
|
364
|
+
}
|
|
365
|
+
|
|
366
|
+
let cachedUint32ArrayMemory0 = null;
|
|
367
|
+
function getUint32ArrayMemory0() {
|
|
368
|
+
if (cachedUint32ArrayMemory0 === null || cachedUint32ArrayMemory0.byteLength === 0) {
|
|
369
|
+
cachedUint32ArrayMemory0 = new Uint32Array(wasm.memory.buffer);
|
|
370
|
+
}
|
|
371
|
+
return cachedUint32ArrayMemory0;
|
|
372
|
+
}
|
|
373
|
+
|
|
374
|
+
let cachedUint8ArrayMemory0 = null;
|
|
375
|
+
function getUint8ArrayMemory0() {
|
|
376
|
+
if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
|
|
377
|
+
cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
|
|
378
|
+
}
|
|
379
|
+
return cachedUint8ArrayMemory0;
|
|
380
|
+
}
|
|
381
|
+
|
|
382
|
+
function isLikeNone(x) {
|
|
383
|
+
return x === undefined || x === null;
|
|
384
|
+
}
|
|
385
|
+
|
|
386
|
+
function passArray32ToWasm0(arg, malloc) {
|
|
387
|
+
const ptr = malloc(arg.length * 4, 4) >>> 0;
|
|
388
|
+
getUint32ArrayMemory0().set(arg, ptr / 4);
|
|
389
|
+
WASM_VECTOR_LEN = arg.length;
|
|
390
|
+
return ptr;
|
|
391
|
+
}
|
|
392
|
+
|
|
393
|
+
function passArray8ToWasm0(arg, malloc) {
|
|
394
|
+
const ptr = malloc(arg.length * 1, 1) >>> 0;
|
|
395
|
+
getUint8ArrayMemory0().set(arg, ptr / 1);
|
|
396
|
+
WASM_VECTOR_LEN = arg.length;
|
|
397
|
+
return ptr;
|
|
398
|
+
}
|
|
399
|
+
|
|
400
|
+
function passStringToWasm0(arg, malloc, realloc) {
|
|
401
|
+
if (realloc === undefined) {
|
|
402
|
+
const buf = cachedTextEncoder.encode(arg);
|
|
403
|
+
const ptr = malloc(buf.length, 1) >>> 0;
|
|
404
|
+
getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);
|
|
405
|
+
WASM_VECTOR_LEN = buf.length;
|
|
406
|
+
return ptr;
|
|
407
|
+
}
|
|
408
|
+
|
|
409
|
+
let len = arg.length;
|
|
410
|
+
let ptr = malloc(len, 1) >>> 0;
|
|
411
|
+
|
|
412
|
+
const mem = getUint8ArrayMemory0();
|
|
413
|
+
|
|
414
|
+
let offset = 0;
|
|
415
|
+
|
|
416
|
+
for (; offset < len; offset++) {
|
|
417
|
+
const code = arg.charCodeAt(offset);
|
|
418
|
+
if (code > 0x7F) break;
|
|
419
|
+
mem[ptr + offset] = code;
|
|
420
|
+
}
|
|
421
|
+
if (offset !== len) {
|
|
422
|
+
if (offset !== 0) {
|
|
423
|
+
arg = arg.slice(offset);
|
|
424
|
+
}
|
|
425
|
+
ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
|
|
426
|
+
const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
|
|
427
|
+
const ret = cachedTextEncoder.encodeInto(arg, view);
|
|
428
|
+
|
|
429
|
+
offset += ret.written;
|
|
430
|
+
ptr = realloc(ptr, len, offset, 1) >>> 0;
|
|
431
|
+
}
|
|
432
|
+
|
|
433
|
+
WASM_VECTOR_LEN = offset;
|
|
434
|
+
return ptr;
|
|
435
|
+
}
|
|
436
|
+
|
|
437
|
+
function takeFromExternrefTable0(idx) {
|
|
438
|
+
const value = wasm.__wbindgen_externrefs.get(idx);
|
|
439
|
+
wasm.__externref_table_dealloc(idx);
|
|
440
|
+
return value;
|
|
441
|
+
}
|
|
442
|
+
|
|
443
|
+
let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
|
|
444
|
+
cachedTextDecoder.decode();
|
|
445
|
+
const MAX_SAFARI_DECODE_BYTES = 2146435072;
|
|
446
|
+
let numBytesDecoded = 0;
|
|
447
|
+
function decodeText(ptr, len) {
|
|
448
|
+
numBytesDecoded += len;
|
|
449
|
+
if (numBytesDecoded >= MAX_SAFARI_DECODE_BYTES) {
|
|
450
|
+
cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
|
|
451
|
+
cachedTextDecoder.decode();
|
|
452
|
+
numBytesDecoded = len;
|
|
453
|
+
}
|
|
454
|
+
return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
|
|
455
|
+
}
|
|
456
|
+
|
|
457
|
+
const cachedTextEncoder = new TextEncoder();
|
|
458
|
+
|
|
459
|
+
if (!('encodeInto' in cachedTextEncoder)) {
|
|
460
|
+
cachedTextEncoder.encodeInto = function (arg, view) {
|
|
461
|
+
const buf = cachedTextEncoder.encode(arg);
|
|
462
|
+
view.set(buf);
|
|
463
|
+
return {
|
|
464
|
+
read: arg.length,
|
|
465
|
+
written: buf.length
|
|
466
|
+
};
|
|
467
|
+
};
|
|
468
|
+
}
|
|
469
|
+
|
|
470
|
+
let WASM_VECTOR_LEN = 0;
|
|
471
|
+
|
|
472
|
+
let wasmModule, wasmInstance, wasm;
|
|
473
|
+
function __wbg_finalize_init(instance, module) {
|
|
474
|
+
wasmInstance = instance;
|
|
475
|
+
wasm = instance.exports;
|
|
476
|
+
wasmModule = module;
|
|
477
|
+
cachedDataViewMemory0 = null;
|
|
478
|
+
cachedFloat64ArrayMemory0 = null;
|
|
479
|
+
cachedUint32ArrayMemory0 = null;
|
|
480
|
+
cachedUint8ArrayMemory0 = null;
|
|
481
|
+
wasm.__wbindgen_start();
|
|
482
|
+
return wasm;
|
|
483
|
+
}
|
|
484
|
+
|
|
485
|
+
async function __wbg_load(module, imports) {
|
|
486
|
+
if (typeof Response === 'function' && module instanceof Response) {
|
|
487
|
+
if (typeof WebAssembly.instantiateStreaming === 'function') {
|
|
488
|
+
try {
|
|
489
|
+
return await WebAssembly.instantiateStreaming(module, imports);
|
|
490
|
+
} catch (e) {
|
|
491
|
+
const validResponse = module.ok && expectedResponseType(module.type);
|
|
492
|
+
|
|
493
|
+
if (validResponse && module.headers.get('Content-Type') !== 'application/wasm') {
|
|
494
|
+
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);
|
|
495
|
+
|
|
496
|
+
} else { throw e; }
|
|
497
|
+
}
|
|
498
|
+
}
|
|
499
|
+
|
|
500
|
+
const bytes = await module.arrayBuffer();
|
|
501
|
+
return await WebAssembly.instantiate(bytes, imports);
|
|
502
|
+
} else {
|
|
503
|
+
const instance = await WebAssembly.instantiate(module, imports);
|
|
504
|
+
|
|
505
|
+
if (instance instanceof WebAssembly.Instance) {
|
|
506
|
+
return { instance, module };
|
|
507
|
+
} else {
|
|
508
|
+
return instance;
|
|
509
|
+
}
|
|
510
|
+
}
|
|
511
|
+
|
|
512
|
+
function expectedResponseType(type) {
|
|
513
|
+
switch (type) {
|
|
514
|
+
case 'basic': case 'cors': case 'default': return true;
|
|
515
|
+
}
|
|
516
|
+
return false;
|
|
517
|
+
}
|
|
518
|
+
}
|
|
519
|
+
|
|
520
|
+
function initSync(module) {
|
|
521
|
+
if (wasm !== undefined) return wasm;
|
|
522
|
+
|
|
523
|
+
|
|
524
|
+
if (module !== undefined) {
|
|
525
|
+
if (Object.getPrototypeOf(module) === Object.prototype) {
|
|
526
|
+
({module} = module)
|
|
527
|
+
} else {
|
|
528
|
+
console.warn('using deprecated parameters for `initSync()`; pass a single object instead')
|
|
529
|
+
}
|
|
530
|
+
}
|
|
531
|
+
|
|
532
|
+
const imports = __wbg_get_imports();
|
|
533
|
+
if (!(module instanceof WebAssembly.Module)) {
|
|
534
|
+
module = new WebAssembly.Module(module);
|
|
535
|
+
}
|
|
536
|
+
const instance = new WebAssembly.Instance(module, imports);
|
|
537
|
+
return __wbg_finalize_init(instance, module);
|
|
538
|
+
}
|
|
539
|
+
|
|
540
|
+
async function __wbg_init(module_or_path) {
|
|
541
|
+
if (wasm !== undefined) return wasm;
|
|
542
|
+
|
|
543
|
+
|
|
544
|
+
if (module_or_path !== undefined) {
|
|
545
|
+
if (Object.getPrototypeOf(module_or_path) === Object.prototype) {
|
|
546
|
+
({module_or_path} = module_or_path)
|
|
547
|
+
} else {
|
|
548
|
+
console.warn('using deprecated parameters for the initialization function; pass a single object instead')
|
|
549
|
+
}
|
|
550
|
+
}
|
|
551
|
+
|
|
552
|
+
if (module_or_path === undefined) {
|
|
553
|
+
module_or_path = new URL('vulture_wasm_bg.wasm', import.meta.url);
|
|
554
|
+
}
|
|
555
|
+
const imports = __wbg_get_imports();
|
|
556
|
+
|
|
557
|
+
if (typeof module_or_path === 'string' || (typeof Request === 'function' && module_or_path instanceof Request) || (typeof URL === 'function' && module_or_path instanceof URL)) {
|
|
558
|
+
module_or_path = fetch(module_or_path);
|
|
559
|
+
}
|
|
560
|
+
|
|
561
|
+
const { instance, module } = await __wbg_load(await module_or_path, imports);
|
|
562
|
+
|
|
563
|
+
return __wbg_finalize_init(instance, module);
|
|
564
|
+
}
|
|
565
|
+
|
|
566
|
+
export { initSync, __wbg_init as default };
|
|
Binary file
|