@tellegen/engine 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 +19 -0
- package/README.md +53 -0
- package/dist/errors.d.ts +7 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +20 -0
- package/dist/errors.js.map +1 -0
- package/dist/generated/contracts.d.ts +225 -0
- package/dist/generated/contracts.d.ts.map +1 -0
- package/dist/generated/contracts.js +8 -0
- package/dist/generated/contracts.js.map +1 -0
- package/dist/host.d.ts +13 -0
- package/dist/host.d.ts.map +1 -0
- package/dist/host.js +95 -0
- package/dist/host.js.map +1 -0
- package/dist/index.d.ts +333 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +393 -0
- package/dist/index.js.map +1 -0
- package/dist/module.d.ts +11 -0
- package/dist/module.d.ts.map +1 -0
- package/dist/module.js +31 -0
- package/dist/module.js.map +1 -0
- package/dist/protocol.d.ts +101 -0
- package/dist/protocol.d.ts.map +1 -0
- package/dist/protocol.js +63 -0
- package/dist/protocol.js.map +1 -0
- package/dist/wasm-pkg/LICENSE +6 -0
- package/dist/wasm-pkg/LICENSE-APACHE +201 -0
- package/dist/wasm-pkg/LICENSE-MIT +19 -0
- package/dist/wasm-pkg/package.json +21 -0
- package/dist/wasm-pkg/tellegen.d.ts +250 -0
- package/dist/wasm-pkg/tellegen.js +959 -0
- package/dist/wasm-pkg/tellegen_bg.wasm +0 -0
- package/dist/wasm-pkg/tellegen_bg.wasm.d.ts +33 -0
- package/dist/worker.d.ts +11 -0
- package/dist/worker.d.ts.map +1 -0
- package/dist/worker.js +47 -0
- package/dist/worker.js.map +1 -0
- package/package.json +43 -0
|
@@ -0,0 +1,959 @@
|
|
|
1
|
+
/* @ts-self-types="./tellegen.d.ts" */
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* A build-once handle over the engine, exported to JS. Construct once per case (the
|
|
5
|
+
* network is parsed and the model built here); then [`replace_edits`](Study::replace_edits)
|
|
6
|
+
* solves exactly at an absolute edit state and [`preview_replacement`](Study::preview_replacement)
|
|
7
|
+
* returns a first-order linearization toward an absolute edit state — neither re-parses
|
|
8
|
+
* the network, unlike `solve_json` which rebuilds it on every call. This is
|
|
9
|
+
* the path a reactive drag should use.
|
|
10
|
+
*
|
|
11
|
+
* Arguments and results are JSON in the engine's `Study` shapes: edits are a
|
|
12
|
+
* `NetworkEdit[]` (e.g. `[{"kind":"add_load","bus":2,"p_mw":50}]`; the element key
|
|
13
|
+
* also accepts the powerio row uid string `ingest_case` stamps, e.g.
|
|
14
|
+
* `"bus":"buses:1"`), `preview` watches an
|
|
15
|
+
* `Operand[]` (e.g. `[{"Price":"Active"}]`) and returns a `Preview`. `commit` takes the
|
|
16
|
+
* edits plus a `SensRequest[]` of watched cells and returns `{ solution, iterations,
|
|
17
|
+
* sensitivities }` — the committed [`SolveResponse`] plus the requested ∂operand/∂param
|
|
18
|
+
* columns, computed in the *same* solve (no second round-trip). Only in the sensitivity
|
|
19
|
+
* build (preview needs the differentiable path).
|
|
20
|
+
*/
|
|
21
|
+
export class Study {
|
|
22
|
+
__destroy_into_raw() {
|
|
23
|
+
const ptr = this.__wbg_ptr;
|
|
24
|
+
this.__wbg_ptr = 0;
|
|
25
|
+
StudyFinalization.unregister(this);
|
|
26
|
+
return ptr;
|
|
27
|
+
}
|
|
28
|
+
free() {
|
|
29
|
+
const ptr = this.__destroy_into_raw();
|
|
30
|
+
wasm.__wbg_study_free(ptr, 0);
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Apply a geographic layer (a canonical `.geo.json` from [`parse_geo`] or
|
|
34
|
+
* [`apply_layout`]) onto this study's base network, so a later
|
|
35
|
+
* [`save_package`](Study::save_package) or export carries the coordinates
|
|
36
|
+
* on screen. Locations are metadata the model never reads; nothing
|
|
37
|
+
* re-solves. Returns the apply report JSON.
|
|
38
|
+
* @param {string} layer_geojson
|
|
39
|
+
* @returns {string}
|
|
40
|
+
*/
|
|
41
|
+
apply_geo(layer_geojson) {
|
|
42
|
+
let deferred3_0;
|
|
43
|
+
let deferred3_1;
|
|
44
|
+
try {
|
|
45
|
+
const ptr0 = passStringToWasm0(layer_geojson, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
46
|
+
const len0 = WASM_VECTOR_LEN;
|
|
47
|
+
const ret = wasm.study_apply_geo(this.__wbg_ptr, ptr0, len0);
|
|
48
|
+
var ptr2 = ret[0];
|
|
49
|
+
var len2 = ret[1];
|
|
50
|
+
if (ret[3]) {
|
|
51
|
+
ptr2 = 0; len2 = 0;
|
|
52
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
53
|
+
}
|
|
54
|
+
deferred3_0 = ptr2;
|
|
55
|
+
deferred3_1 = len2;
|
|
56
|
+
return getStringFromWasm0(ptr2, len2);
|
|
57
|
+
} finally {
|
|
58
|
+
wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Apply `edits_json` (a `NetworkEdit[]`) at the committed point and exact-re-solve,
|
|
63
|
+
* attaching the `sensitivities_json` cells (a `SensRequest[]`, or empty/blank for
|
|
64
|
+
* none) in the same solve. Advances the committed point. Returns
|
|
65
|
+
* `{ "solution": SolveResponse, "iterations": Iterations, "sensitivities":
|
|
66
|
+
* SensitivityMatrix[] }` — `solution` is the full committed response, and
|
|
67
|
+
* `iterations` / `sensitivities` mirror its convergence trace and the watched
|
|
68
|
+
* columns so the UI renders the ∂LMP/∂d column without a second solve.
|
|
69
|
+
* @param {string} edits_json
|
|
70
|
+
* @param {string} sensitivities_json
|
|
71
|
+
* @returns {string}
|
|
72
|
+
*/
|
|
73
|
+
commit(edits_json, sensitivities_json) {
|
|
74
|
+
let deferred4_0;
|
|
75
|
+
let deferred4_1;
|
|
76
|
+
try {
|
|
77
|
+
const ptr0 = passStringToWasm0(edits_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
78
|
+
const len0 = WASM_VECTOR_LEN;
|
|
79
|
+
const ptr1 = passStringToWasm0(sensitivities_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
80
|
+
const len1 = WASM_VECTOR_LEN;
|
|
81
|
+
const ret = wasm.study_commit(this.__wbg_ptr, ptr0, len0, ptr1, len1);
|
|
82
|
+
var ptr3 = ret[0];
|
|
83
|
+
var len3 = ret[1];
|
|
84
|
+
if (ret[3]) {
|
|
85
|
+
ptr3 = 0; len3 = 0;
|
|
86
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
87
|
+
}
|
|
88
|
+
deferred4_0 = ptr3;
|
|
89
|
+
deferred4_1 = len3;
|
|
90
|
+
return getStringFromWasm0(ptr3, len3);
|
|
91
|
+
} finally {
|
|
92
|
+
wasm.__wbindgen_free(deferred4_0, deferred4_1, 1);
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* The formulation tag (`"dcopf"` / `"acpf"`).
|
|
97
|
+
* @returns {string}
|
|
98
|
+
*/
|
|
99
|
+
formulation() {
|
|
100
|
+
let deferred1_0;
|
|
101
|
+
let deferred1_1;
|
|
102
|
+
try {
|
|
103
|
+
const ret = wasm.study_formulation(this.__wbg_ptr);
|
|
104
|
+
deferred1_0 = ret[0];
|
|
105
|
+
deferred1_1 = ret[1];
|
|
106
|
+
return getStringFromWasm0(ret[0], ret[1]);
|
|
107
|
+
} finally {
|
|
108
|
+
wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* Build a study over `network_json` for `formulation` (`"dcopf"` / `"acpf"`, and —
|
|
113
|
+
* in a build that includes them — `"socwr"` / `"acopf"`), solving the base case.
|
|
114
|
+
* Errors on an unknown or not-built formulation.
|
|
115
|
+
* @param {string} network_json
|
|
116
|
+
* @param {string} formulation
|
|
117
|
+
*/
|
|
118
|
+
constructor(network_json, formulation) {
|
|
119
|
+
const ptr0 = passStringToWasm0(network_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
120
|
+
const len0 = WASM_VECTOR_LEN;
|
|
121
|
+
const ptr1 = passStringToWasm0(formulation, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
122
|
+
const len1 = WASM_VECTOR_LEN;
|
|
123
|
+
const ret = wasm.study_new(ptr0, len0, ptr1, len1);
|
|
124
|
+
if (ret[2]) {
|
|
125
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
126
|
+
}
|
|
127
|
+
this.__wbg_ptr = ret[0];
|
|
128
|
+
StudyFinalization.register(this, this.__wbg_ptr, this);
|
|
129
|
+
return this;
|
|
130
|
+
}
|
|
131
|
+
/**
|
|
132
|
+
* First-order preview of `edits_json` (a `NetworkEdit[]`) for the `watched_json`
|
|
133
|
+
* operands (an `Operand[]`), at the committed point, without re-solving. Returns the
|
|
134
|
+
* `Preview` JSON.
|
|
135
|
+
* @param {string} edits_json
|
|
136
|
+
* @param {string} watched_json
|
|
137
|
+
* @returns {string}
|
|
138
|
+
*/
|
|
139
|
+
preview(edits_json, watched_json) {
|
|
140
|
+
let deferred4_0;
|
|
141
|
+
let deferred4_1;
|
|
142
|
+
try {
|
|
143
|
+
const ptr0 = passStringToWasm0(edits_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
144
|
+
const len0 = WASM_VECTOR_LEN;
|
|
145
|
+
const ptr1 = passStringToWasm0(watched_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
146
|
+
const len1 = WASM_VECTOR_LEN;
|
|
147
|
+
const ret = wasm.study_preview(this.__wbg_ptr, ptr0, len0, ptr1, len1);
|
|
148
|
+
var ptr3 = ret[0];
|
|
149
|
+
var len3 = ret[1];
|
|
150
|
+
if (ret[3]) {
|
|
151
|
+
ptr3 = 0; len3 = 0;
|
|
152
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
153
|
+
}
|
|
154
|
+
deferred4_0 = ptr3;
|
|
155
|
+
deferred4_1 = len3;
|
|
156
|
+
return getStringFromWasm0(ptr3, len3);
|
|
157
|
+
} finally {
|
|
158
|
+
wasm.__wbindgen_free(deferred4_0, deferred4_1, 1);
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
/**
|
|
162
|
+
* First-order preview for replacing the committed edit set with `edits_json`.
|
|
163
|
+
* This accepts absolute demand delta state and internally previews only the step
|
|
164
|
+
* from the current committed point.
|
|
165
|
+
* @param {string} edits_json
|
|
166
|
+
* @param {string} watched_json
|
|
167
|
+
* @returns {string}
|
|
168
|
+
*/
|
|
169
|
+
preview_replacement(edits_json, watched_json) {
|
|
170
|
+
let deferred4_0;
|
|
171
|
+
let deferred4_1;
|
|
172
|
+
try {
|
|
173
|
+
const ptr0 = passStringToWasm0(edits_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
174
|
+
const len0 = WASM_VECTOR_LEN;
|
|
175
|
+
const ptr1 = passStringToWasm0(watched_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
176
|
+
const len1 = WASM_VECTOR_LEN;
|
|
177
|
+
const ret = wasm.study_preview_replacement(this.__wbg_ptr, ptr0, len0, ptr1, len1);
|
|
178
|
+
var ptr3 = ret[0];
|
|
179
|
+
var len3 = ret[1];
|
|
180
|
+
if (ret[3]) {
|
|
181
|
+
ptr3 = 0; len3 = 0;
|
|
182
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
183
|
+
}
|
|
184
|
+
deferred4_0 = ptr3;
|
|
185
|
+
deferred4_1 = len3;
|
|
186
|
+
return getStringFromWasm0(ptr3, len3);
|
|
187
|
+
} finally {
|
|
188
|
+
wasm.__wbindgen_free(deferred4_0, deferred4_1, 1);
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
/**
|
|
192
|
+
* Replace the committed edit set with `edits_json` and exact-re-solve, attaching
|
|
193
|
+
* the `sensitivities_json` cells in the same solve. Use this for UI state that stores
|
|
194
|
+
* absolute demand deltas from the base case.
|
|
195
|
+
* @param {string} edits_json
|
|
196
|
+
* @param {string} sensitivities_json
|
|
197
|
+
* @returns {string}
|
|
198
|
+
*/
|
|
199
|
+
replace_edits(edits_json, sensitivities_json) {
|
|
200
|
+
let deferred4_0;
|
|
201
|
+
let deferred4_1;
|
|
202
|
+
try {
|
|
203
|
+
const ptr0 = passStringToWasm0(edits_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
204
|
+
const len0 = WASM_VECTOR_LEN;
|
|
205
|
+
const ptr1 = passStringToWasm0(sensitivities_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
206
|
+
const len1 = WASM_VECTOR_LEN;
|
|
207
|
+
const ret = wasm.study_replace_edits(this.__wbg_ptr, ptr0, len0, ptr1, len1);
|
|
208
|
+
var ptr3 = ret[0];
|
|
209
|
+
var len3 = ret[1];
|
|
210
|
+
if (ret[3]) {
|
|
211
|
+
ptr3 = 0; len3 = 0;
|
|
212
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
213
|
+
}
|
|
214
|
+
deferred4_0 = ptr3;
|
|
215
|
+
deferred4_1 = len3;
|
|
216
|
+
return getStringFromWasm0(ptr3, len3);
|
|
217
|
+
} finally {
|
|
218
|
+
wasm.__wbindgen_free(deferred4_0, deferred4_1, 1);
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
/**
|
|
222
|
+
* Serialize this study as a `.pio.json` package: the base network is the payload,
|
|
223
|
+
* the edit log is the study block (one commit per `commit` call, keyed by row uid),
|
|
224
|
+
* and the formulation and solve options ride under `study.app["tellegen"]`. Returns
|
|
225
|
+
* the package JSON, ready to download or hand to [`export_study`].
|
|
226
|
+
* @returns {string}
|
|
227
|
+
*/
|
|
228
|
+
save_package() {
|
|
229
|
+
let deferred2_0;
|
|
230
|
+
let deferred2_1;
|
|
231
|
+
try {
|
|
232
|
+
const ret = wasm.study_save_package(this.__wbg_ptr);
|
|
233
|
+
var ptr1 = ret[0];
|
|
234
|
+
var len1 = ret[1];
|
|
235
|
+
if (ret[3]) {
|
|
236
|
+
ptr1 = 0; len1 = 0;
|
|
237
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
238
|
+
}
|
|
239
|
+
deferred2_0 = ptr1;
|
|
240
|
+
deferred2_1 = len1;
|
|
241
|
+
return getStringFromWasm0(ptr1, len1);
|
|
242
|
+
} finally {
|
|
243
|
+
wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
/**
|
|
247
|
+
* The most recent committed solution as `SolveResponse` JSON.
|
|
248
|
+
* @returns {string}
|
|
249
|
+
*/
|
|
250
|
+
solution() {
|
|
251
|
+
let deferred2_0;
|
|
252
|
+
let deferred2_1;
|
|
253
|
+
try {
|
|
254
|
+
const ret = wasm.study_solution(this.__wbg_ptr);
|
|
255
|
+
var ptr1 = ret[0];
|
|
256
|
+
var len1 = ret[1];
|
|
257
|
+
if (ret[3]) {
|
|
258
|
+
ptr1 = 0; len1 = 0;
|
|
259
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
260
|
+
}
|
|
261
|
+
deferred2_0 = ptr1;
|
|
262
|
+
deferred2_1 = len1;
|
|
263
|
+
return getStringFromWasm0(ptr1, len1);
|
|
264
|
+
} finally {
|
|
265
|
+
wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
if (Symbol.dispose) Study.prototype[Symbol.dispose] = Study.prototype.free;
|
|
270
|
+
|
|
271
|
+
/**
|
|
272
|
+
* Fill case coordinates from a PowerWorld `.pwd` sibling: substation symbols
|
|
273
|
+
* project to approximate longitude/latitude and join onto buses through the
|
|
274
|
+
* `SubNum` extras key. Returns the refreshed `ingest_case` payload plus a
|
|
275
|
+
* `report`; errors when no bus joined.
|
|
276
|
+
* @param {string} network_json
|
|
277
|
+
* @param {Uint8Array} bytes
|
|
278
|
+
* @returns {string}
|
|
279
|
+
*/
|
|
280
|
+
export function apply_display_geo(network_json, bytes) {
|
|
281
|
+
let deferred4_0;
|
|
282
|
+
let deferred4_1;
|
|
283
|
+
try {
|
|
284
|
+
const ptr0 = passStringToWasm0(network_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
285
|
+
const len0 = WASM_VECTOR_LEN;
|
|
286
|
+
const ptr1 = passArray8ToWasm0(bytes, wasm.__wbindgen_malloc);
|
|
287
|
+
const len1 = WASM_VECTOR_LEN;
|
|
288
|
+
const ret = wasm.apply_display_geo(ptr0, len0, ptr1, len1);
|
|
289
|
+
var ptr3 = ret[0];
|
|
290
|
+
var len3 = ret[1];
|
|
291
|
+
if (ret[3]) {
|
|
292
|
+
ptr3 = 0; len3 = 0;
|
|
293
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
294
|
+
}
|
|
295
|
+
deferred4_0 = ptr3;
|
|
296
|
+
deferred4_1 = len3;
|
|
297
|
+
return getStringFromWasm0(ptr3, len3);
|
|
298
|
+
} finally {
|
|
299
|
+
wasm.__wbindgen_free(deferred4_0, deferred4_1, 1);
|
|
300
|
+
}
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
/**
|
|
304
|
+
* Apply a [`parse_geo`] layer onto a case network: matched bus points land in
|
|
305
|
+
* `Bus.location`, matched routes in `Branch.route` (matching by uid, external
|
|
306
|
+
* id, name, and the unordered endpoint pair — upstream semantics). Returns
|
|
307
|
+
* the refreshed `ingest_case` payload plus a `report` of matched/unmatched
|
|
308
|
+
* counts; errors when nothing matched.
|
|
309
|
+
* @param {string} network_json
|
|
310
|
+
* @param {string} layer_geojson
|
|
311
|
+
* @returns {string}
|
|
312
|
+
*/
|
|
313
|
+
export function apply_geo(network_json, layer_geojson) {
|
|
314
|
+
let deferred4_0;
|
|
315
|
+
let deferred4_1;
|
|
316
|
+
try {
|
|
317
|
+
const ptr0 = passStringToWasm0(network_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
318
|
+
const len0 = WASM_VECTOR_LEN;
|
|
319
|
+
const ptr1 = passStringToWasm0(layer_geojson, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
320
|
+
const len1 = WASM_VECTOR_LEN;
|
|
321
|
+
const ret = wasm.apply_geo(ptr0, len0, ptr1, len1);
|
|
322
|
+
var ptr3 = ret[0];
|
|
323
|
+
var len3 = ret[1];
|
|
324
|
+
if (ret[3]) {
|
|
325
|
+
ptr3 = 0; len3 = 0;
|
|
326
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
327
|
+
}
|
|
328
|
+
deferred4_0 = ptr3;
|
|
329
|
+
deferred4_1 = len3;
|
|
330
|
+
return getStringFromWasm0(ptr3, len3);
|
|
331
|
+
} finally {
|
|
332
|
+
wasm.__wbindgen_free(deferred4_0, deferred4_1, 1);
|
|
333
|
+
}
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
/**
|
|
337
|
+
* Stamp a computed layout (bus id => `[lon, lat]`) onto a case network with
|
|
338
|
+
* `kind` provenance (`synthetic` or `manual`). Returns the refreshed
|
|
339
|
+
* `ingest_case` payload plus `layer`, the stamped layout as a canonical
|
|
340
|
+
* `.geo.json` document.
|
|
341
|
+
* @param {string} network_json
|
|
342
|
+
* @param {string} coords_json
|
|
343
|
+
* @param {string} kind
|
|
344
|
+
* @returns {string}
|
|
345
|
+
*/
|
|
346
|
+
export function apply_layout(network_json, coords_json, kind) {
|
|
347
|
+
let deferred5_0;
|
|
348
|
+
let deferred5_1;
|
|
349
|
+
try {
|
|
350
|
+
const ptr0 = passStringToWasm0(network_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
351
|
+
const len0 = WASM_VECTOR_LEN;
|
|
352
|
+
const ptr1 = passStringToWasm0(coords_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
353
|
+
const len1 = WASM_VECTOR_LEN;
|
|
354
|
+
const ptr2 = passStringToWasm0(kind, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
355
|
+
const len2 = WASM_VECTOR_LEN;
|
|
356
|
+
const ret = wasm.apply_layout(ptr0, len0, ptr1, len1, ptr2, len2);
|
|
357
|
+
var ptr4 = ret[0];
|
|
358
|
+
var len4 = ret[1];
|
|
359
|
+
if (ret[3]) {
|
|
360
|
+
ptr4 = 0; len4 = 0;
|
|
361
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
362
|
+
}
|
|
363
|
+
deferred5_0 = ptr4;
|
|
364
|
+
deferred5_1 = len4;
|
|
365
|
+
return getStringFromWasm0(ptr4, len4);
|
|
366
|
+
} finally {
|
|
367
|
+
wasm.__wbindgen_free(deferred5_0, deferred5_1, 1);
|
|
368
|
+
}
|
|
369
|
+
}
|
|
370
|
+
|
|
371
|
+
/**
|
|
372
|
+
* The capability matrix as JSON: which `(formulation, operand, parameter)` cells this
|
|
373
|
+
* build supports, so the UI can populate menus and grey out the rest.
|
|
374
|
+
* @returns {string}
|
|
375
|
+
*/
|
|
376
|
+
export function capabilities_json() {
|
|
377
|
+
let deferred1_0;
|
|
378
|
+
let deferred1_1;
|
|
379
|
+
try {
|
|
380
|
+
const ret = wasm.capabilities_json();
|
|
381
|
+
deferred1_0 = ret[0];
|
|
382
|
+
deferred1_1 = ret[1];
|
|
383
|
+
return getStringFromWasm0(ret[0], ret[1]);
|
|
384
|
+
} finally {
|
|
385
|
+
wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
|
|
386
|
+
}
|
|
387
|
+
}
|
|
388
|
+
|
|
389
|
+
/**
|
|
390
|
+
* Export the balanced study state at commit `commit` to a powerio `format`
|
|
391
|
+
* (`matpower`, `psse`, `powerio-json`, ...). Returns `{ text, warnings, format,
|
|
392
|
+
* extension }` as JSON: the serialized case, the writer's fidelity warnings so the
|
|
393
|
+
* frontend can surface them, and the format token and file extension. The package
|
|
394
|
+
* JSON is untrusted; malformed input returns a `JsError`, never a panic.
|
|
395
|
+
* @param {string} package_json
|
|
396
|
+
* @param {number} commit
|
|
397
|
+
* @param {string} format
|
|
398
|
+
* @returns {string}
|
|
399
|
+
*/
|
|
400
|
+
export function export_study(package_json, commit, format) {
|
|
401
|
+
let deferred4_0;
|
|
402
|
+
let deferred4_1;
|
|
403
|
+
try {
|
|
404
|
+
const ptr0 = passStringToWasm0(package_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
405
|
+
const len0 = WASM_VECTOR_LEN;
|
|
406
|
+
const ptr1 = passStringToWasm0(format, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
407
|
+
const len1 = WASM_VECTOR_LEN;
|
|
408
|
+
const ret = wasm.export_study(ptr0, len0, commit, ptr1, len1);
|
|
409
|
+
var ptr3 = ret[0];
|
|
410
|
+
var len3 = ret[1];
|
|
411
|
+
if (ret[3]) {
|
|
412
|
+
ptr3 = 0; len3 = 0;
|
|
413
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
414
|
+
}
|
|
415
|
+
deferred4_0 = ptr3;
|
|
416
|
+
deferred4_1 = len3;
|
|
417
|
+
return getStringFromWasm0(ptr3, len3);
|
|
418
|
+
} finally {
|
|
419
|
+
wasm.__wbindgen_free(deferred4_0, deferred4_1, 1);
|
|
420
|
+
}
|
|
421
|
+
}
|
|
422
|
+
|
|
423
|
+
/**
|
|
424
|
+
* A case's coordinates as a canonical `.geo.json` document (one point per
|
|
425
|
+
* located bus, one route per routed branch, provenance preserved). Errors
|
|
426
|
+
* when the case carries none.
|
|
427
|
+
* @param {string} network_json
|
|
428
|
+
* @returns {string}
|
|
429
|
+
*/
|
|
430
|
+
export function extract_geo(network_json) {
|
|
431
|
+
let deferred3_0;
|
|
432
|
+
let deferred3_1;
|
|
433
|
+
try {
|
|
434
|
+
const ptr0 = passStringToWasm0(network_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
435
|
+
const len0 = WASM_VECTOR_LEN;
|
|
436
|
+
const ret = wasm.extract_geo(ptr0, len0);
|
|
437
|
+
var ptr2 = ret[0];
|
|
438
|
+
var len2 = ret[1];
|
|
439
|
+
if (ret[3]) {
|
|
440
|
+
ptr2 = 0; len2 = 0;
|
|
441
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
442
|
+
}
|
|
443
|
+
deferred3_0 = ptr2;
|
|
444
|
+
deferred3_1 = len2;
|
|
445
|
+
return getStringFromWasm0(ptr2, len2);
|
|
446
|
+
} finally {
|
|
447
|
+
wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
|
|
448
|
+
}
|
|
449
|
+
}
|
|
450
|
+
|
|
451
|
+
/**
|
|
452
|
+
* Everything the drop panel needs from one parse: counts, total load and
|
|
453
|
+
* capacity, parse warnings, and a `view` of buses and branches in the shape
|
|
454
|
+
* the tellegen API serves, placed at the coordinates the file carries
|
|
455
|
+
* (PowerWorld complete case aux exports). `view` is null when the file has no
|
|
456
|
+
* coordinates.
|
|
457
|
+
* @param {string} text
|
|
458
|
+
* @param {string} format
|
|
459
|
+
* @returns {string}
|
|
460
|
+
*/
|
|
461
|
+
export function ingest_case(text, format) {
|
|
462
|
+
let deferred4_0;
|
|
463
|
+
let deferred4_1;
|
|
464
|
+
try {
|
|
465
|
+
const ptr0 = passStringToWasm0(text, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
466
|
+
const len0 = WASM_VECTOR_LEN;
|
|
467
|
+
const ptr1 = passStringToWasm0(format, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
468
|
+
const len1 = WASM_VECTOR_LEN;
|
|
469
|
+
const ret = wasm.ingest_case(ptr0, len0, ptr1, len1);
|
|
470
|
+
var ptr3 = ret[0];
|
|
471
|
+
var len3 = ret[1];
|
|
472
|
+
if (ret[3]) {
|
|
473
|
+
ptr3 = 0; len3 = 0;
|
|
474
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
475
|
+
}
|
|
476
|
+
deferred4_0 = ptr3;
|
|
477
|
+
deferred4_1 = len3;
|
|
478
|
+
return getStringFromWasm0(ptr3, len3);
|
|
479
|
+
} finally {
|
|
480
|
+
wasm.__wbindgen_free(deferred4_0, deferred4_1, 1);
|
|
481
|
+
}
|
|
482
|
+
}
|
|
483
|
+
|
|
484
|
+
/**
|
|
485
|
+
* The distribution counterpart of [`ingest_case`]: view a multiconductor case
|
|
486
|
+
* with no solve. `format` is a distribution reader token (`dss`, `bmopf`,
|
|
487
|
+
* `pmd`) parsed by [`powerio_dist`], or `pio` for a `.pio.json` package
|
|
488
|
+
* carrying a multiconductor payload. Returns the drop-panel payload JSON:
|
|
489
|
+
* name, element counts, connected load/generation (kW), parse warnings,
|
|
490
|
+
* coordinate provenance, and the bus/terminal graph the frontend renders (see
|
|
491
|
+
* [`dist`]).
|
|
492
|
+
*
|
|
493
|
+
* Untrusted input: the parse and package restore return error strings (mapped
|
|
494
|
+
* to `JsError` here), so a malformed, truncated, or oversized `.dss`/JSON
|
|
495
|
+
* rejects cleanly and never panics the wasm instance.
|
|
496
|
+
* @param {string} text
|
|
497
|
+
* @param {string} format
|
|
498
|
+
* @returns {string}
|
|
499
|
+
*/
|
|
500
|
+
export function ingest_dist_case(text, format) {
|
|
501
|
+
let deferred4_0;
|
|
502
|
+
let deferred4_1;
|
|
503
|
+
try {
|
|
504
|
+
const ptr0 = passStringToWasm0(text, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
505
|
+
const len0 = WASM_VECTOR_LEN;
|
|
506
|
+
const ptr1 = passStringToWasm0(format, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
507
|
+
const len1 = WASM_VECTOR_LEN;
|
|
508
|
+
const ret = wasm.ingest_dist_case(ptr0, len0, ptr1, len1);
|
|
509
|
+
var ptr3 = ret[0];
|
|
510
|
+
var len3 = ret[1];
|
|
511
|
+
if (ret[3]) {
|
|
512
|
+
ptr3 = 0; len3 = 0;
|
|
513
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
514
|
+
}
|
|
515
|
+
deferred4_0 = ptr3;
|
|
516
|
+
deferred4_1 = len3;
|
|
517
|
+
return getStringFromWasm0(ptr3, len3);
|
|
518
|
+
} finally {
|
|
519
|
+
wasm.__wbindgen_free(deferred4_0, deferred4_1, 1);
|
|
520
|
+
}
|
|
521
|
+
}
|
|
522
|
+
|
|
523
|
+
/**
|
|
524
|
+
* Restore a study saved by [`Study::save_package`]. Returns a JSON bundle the frontend
|
|
525
|
+
* reads to rebuild its case, edit sliders, formulation, and solve options in one step.
|
|
526
|
+
* See [`load_package_bundle`] for the shape and the fail-closed contract.
|
|
527
|
+
* @param {string} package_json
|
|
528
|
+
* @returns {string}
|
|
529
|
+
*/
|
|
530
|
+
export function load_package(package_json) {
|
|
531
|
+
let deferred3_0;
|
|
532
|
+
let deferred3_1;
|
|
533
|
+
try {
|
|
534
|
+
const ptr0 = passStringToWasm0(package_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
535
|
+
const len0 = WASM_VECTOR_LEN;
|
|
536
|
+
const ret = wasm.load_package(ptr0, len0);
|
|
537
|
+
var ptr2 = ret[0];
|
|
538
|
+
var len2 = ret[1];
|
|
539
|
+
if (ret[3]) {
|
|
540
|
+
ptr2 = 0; len2 = 0;
|
|
541
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
542
|
+
}
|
|
543
|
+
deferred3_0 = ptr2;
|
|
544
|
+
deferred3_1 = len2;
|
|
545
|
+
return getStringFromWasm0(ptr2, len2);
|
|
546
|
+
} finally {
|
|
547
|
+
wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
|
|
548
|
+
}
|
|
549
|
+
}
|
|
550
|
+
|
|
551
|
+
/**
|
|
552
|
+
* Parse a case file (MATPOWER, PSS/E RAW, PowerWorld aux, PowerModels or
|
|
553
|
+
* egret JSON) and return `{"network": ..., "warnings": [...]}` as JSON.
|
|
554
|
+
* @param {string} text
|
|
555
|
+
* @param {string} format
|
|
556
|
+
* @returns {string}
|
|
557
|
+
*/
|
|
558
|
+
export function parse_case(text, format) {
|
|
559
|
+
let deferred4_0;
|
|
560
|
+
let deferred4_1;
|
|
561
|
+
try {
|
|
562
|
+
const ptr0 = passStringToWasm0(text, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
563
|
+
const len0 = WASM_VECTOR_LEN;
|
|
564
|
+
const ptr1 = passStringToWasm0(format, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
565
|
+
const len1 = WASM_VECTOR_LEN;
|
|
566
|
+
const ret = wasm.parse_case(ptr0, len0, ptr1, len1);
|
|
567
|
+
var ptr3 = ret[0];
|
|
568
|
+
var len3 = ret[1];
|
|
569
|
+
if (ret[3]) {
|
|
570
|
+
ptr3 = 0; len3 = 0;
|
|
571
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
572
|
+
}
|
|
573
|
+
deferred4_0 = ptr3;
|
|
574
|
+
deferred4_1 = len3;
|
|
575
|
+
return getStringFromWasm0(ptr3, len3);
|
|
576
|
+
} finally {
|
|
577
|
+
wasm.__wbindgen_free(deferred4_0, deferred4_1, 1);
|
|
578
|
+
}
|
|
579
|
+
}
|
|
580
|
+
|
|
581
|
+
/**
|
|
582
|
+
* Decode a PowerWorld `.pwd` display file (binary). Returns the substation
|
|
583
|
+
* symbols at the diagram coordinates the file stores (x east, y north) plus
|
|
584
|
+
* the canvas size, each with the approximate `lon`/`lat` projection
|
|
585
|
+
* (`pwd_mercator_to_lonlat`; hand edited diagrams drift from it). A `.pwd`
|
|
586
|
+
* carries no buses or branches. `format` is "pwd". Pure in-memory parsing,
|
|
587
|
+
* no filesystem, so it runs in the browser.
|
|
588
|
+
* @param {Uint8Array} bytes
|
|
589
|
+
* @param {string} format
|
|
590
|
+
* @returns {string}
|
|
591
|
+
*/
|
|
592
|
+
export function parse_display(bytes, format) {
|
|
593
|
+
let deferred4_0;
|
|
594
|
+
let deferred4_1;
|
|
595
|
+
try {
|
|
596
|
+
const ptr0 = passArray8ToWasm0(bytes, wasm.__wbindgen_malloc);
|
|
597
|
+
const len0 = WASM_VECTOR_LEN;
|
|
598
|
+
const ptr1 = passStringToWasm0(format, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
599
|
+
const len1 = WASM_VECTOR_LEN;
|
|
600
|
+
const ret = wasm.parse_display(ptr0, len0, ptr1, len1);
|
|
601
|
+
var ptr3 = ret[0];
|
|
602
|
+
var len3 = ret[1];
|
|
603
|
+
if (ret[3]) {
|
|
604
|
+
ptr3 = 0; len3 = 0;
|
|
605
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
606
|
+
}
|
|
607
|
+
deferred4_0 = ptr3;
|
|
608
|
+
deferred4_1 = len3;
|
|
609
|
+
return getStringFromWasm0(ptr3, len3);
|
|
610
|
+
} finally {
|
|
611
|
+
wasm.__wbindgen_free(deferred4_0, deferred4_1, 1);
|
|
612
|
+
}
|
|
613
|
+
}
|
|
614
|
+
|
|
615
|
+
/**
|
|
616
|
+
* Parse a geographic sidecar (buscoords CSV, aliased CSV/JSON records,
|
|
617
|
+
* GeoJSON) from raw dropped bytes; `hint` is the file name ("" to sniff).
|
|
618
|
+
* Returns `{ layer, warnings, n_points, n_routes }` — the layer as its
|
|
619
|
+
* canonical `.geo.json` document, ready for [`apply_geo`]. Untrusted input
|
|
620
|
+
* rejects as a `JsError`, never a panic.
|
|
621
|
+
* @param {Uint8Array} bytes
|
|
622
|
+
* @param {string} hint
|
|
623
|
+
* @returns {string}
|
|
624
|
+
*/
|
|
625
|
+
export function parse_geo(bytes, hint) {
|
|
626
|
+
let deferred4_0;
|
|
627
|
+
let deferred4_1;
|
|
628
|
+
try {
|
|
629
|
+
const ptr0 = passArray8ToWasm0(bytes, wasm.__wbindgen_malloc);
|
|
630
|
+
const len0 = WASM_VECTOR_LEN;
|
|
631
|
+
const ptr1 = passStringToWasm0(hint, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
632
|
+
const len1 = WASM_VECTOR_LEN;
|
|
633
|
+
const ret = wasm.parse_geo(ptr0, len0, ptr1, len1);
|
|
634
|
+
var ptr3 = ret[0];
|
|
635
|
+
var len3 = ret[1];
|
|
636
|
+
if (ret[3]) {
|
|
637
|
+
ptr3 = 0; len3 = 0;
|
|
638
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
639
|
+
}
|
|
640
|
+
deferred4_0 = ptr3;
|
|
641
|
+
deferred4_1 = len3;
|
|
642
|
+
return getStringFromWasm0(ptr3, len3);
|
|
643
|
+
} finally {
|
|
644
|
+
wasm.__wbindgen_free(deferred4_0, deferred4_1, 1);
|
|
645
|
+
}
|
|
646
|
+
}
|
|
647
|
+
|
|
648
|
+
/**
|
|
649
|
+
* The stateless solve front door: a [`SolveRequest`](tellegen::SolveRequest) JSON
|
|
650
|
+
* in, a [`SolveResponse`](tellegen::SolveResponse) JSON out. One-shot callers only;
|
|
651
|
+
* the reactive hot path is the [`Study`].
|
|
652
|
+
* @param {string} network_json
|
|
653
|
+
* @param {string} request_json
|
|
654
|
+
* @returns {string}
|
|
655
|
+
*/
|
|
656
|
+
export function solve_json(network_json, request_json) {
|
|
657
|
+
let deferred4_0;
|
|
658
|
+
let deferred4_1;
|
|
659
|
+
try {
|
|
660
|
+
const ptr0 = passStringToWasm0(network_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
661
|
+
const len0 = WASM_VECTOR_LEN;
|
|
662
|
+
const ptr1 = passStringToWasm0(request_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
663
|
+
const len1 = WASM_VECTOR_LEN;
|
|
664
|
+
const ret = wasm.solve_json(ptr0, len0, ptr1, len1);
|
|
665
|
+
var ptr3 = ret[0];
|
|
666
|
+
var len3 = ret[1];
|
|
667
|
+
if (ret[3]) {
|
|
668
|
+
ptr3 = 0; len3 = 0;
|
|
669
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
670
|
+
}
|
|
671
|
+
deferred4_0 = ptr3;
|
|
672
|
+
deferred4_1 = len3;
|
|
673
|
+
return getStringFromWasm0(ptr3, len3);
|
|
674
|
+
} finally {
|
|
675
|
+
wasm.__wbindgen_free(deferred4_0, deferred4_1, 1);
|
|
676
|
+
}
|
|
677
|
+
}
|
|
678
|
+
function __wbg_get_imports() {
|
|
679
|
+
const import0 = {
|
|
680
|
+
__proto__: null,
|
|
681
|
+
__wbg_Error_fdd633d4bb5dd76a: function(arg0, arg1) {
|
|
682
|
+
const ret = Error(getStringFromWasm0(arg0, arg1));
|
|
683
|
+
return ret;
|
|
684
|
+
},
|
|
685
|
+
__wbg___wbindgen_is_undefined_721f8decd50c87a3: function(arg0) {
|
|
686
|
+
const ret = arg0 === undefined;
|
|
687
|
+
return ret;
|
|
688
|
+
},
|
|
689
|
+
__wbg___wbindgen_throw_ea4887a5f8f9a9db: function(arg0, arg1) {
|
|
690
|
+
throw new Error(getStringFromWasm0(arg0, arg1));
|
|
691
|
+
},
|
|
692
|
+
__wbg_error_a6fa202b58aa1cd3: function(arg0, arg1) {
|
|
693
|
+
let deferred0_0;
|
|
694
|
+
let deferred0_1;
|
|
695
|
+
try {
|
|
696
|
+
deferred0_0 = arg0;
|
|
697
|
+
deferred0_1 = arg1;
|
|
698
|
+
console.error(getStringFromWasm0(arg0, arg1));
|
|
699
|
+
} finally {
|
|
700
|
+
wasm.__wbindgen_free(deferred0_0, deferred0_1, 1);
|
|
701
|
+
}
|
|
702
|
+
},
|
|
703
|
+
__wbg_new_227d7c05414eb861: function() {
|
|
704
|
+
const ret = new Error();
|
|
705
|
+
return ret;
|
|
706
|
+
},
|
|
707
|
+
__wbg_now_cace042f68c814d8: function(arg0) {
|
|
708
|
+
const ret = arg0.now();
|
|
709
|
+
return ret;
|
|
710
|
+
},
|
|
711
|
+
__wbg_performance_5fc5a6563dcd33de: function(arg0) {
|
|
712
|
+
const ret = arg0.performance;
|
|
713
|
+
return ret;
|
|
714
|
+
},
|
|
715
|
+
__wbg_stack_3b0d974bbf31e44f: function(arg0, arg1) {
|
|
716
|
+
const ret = arg1.stack;
|
|
717
|
+
const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
718
|
+
const len1 = WASM_VECTOR_LEN;
|
|
719
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
|
|
720
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
|
|
721
|
+
},
|
|
722
|
+
__wbg_static_accessor_GLOBAL_THIS_2fee5048bcca5938: function() {
|
|
723
|
+
const ret = typeof globalThis === 'undefined' ? null : globalThis;
|
|
724
|
+
return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
|
|
725
|
+
},
|
|
726
|
+
__wbg_static_accessor_GLOBAL_ce44e66a4935da8c: function() {
|
|
727
|
+
const ret = typeof global === 'undefined' ? null : global;
|
|
728
|
+
return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
|
|
729
|
+
},
|
|
730
|
+
__wbg_static_accessor_SELF_44f6e0cb5e67cdad: function() {
|
|
731
|
+
const ret = typeof self === 'undefined' ? null : self;
|
|
732
|
+
return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
|
|
733
|
+
},
|
|
734
|
+
__wbg_static_accessor_WINDOW_168f178805d978fe: function() {
|
|
735
|
+
const ret = typeof window === 'undefined' ? null : window;
|
|
736
|
+
return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
|
|
737
|
+
},
|
|
738
|
+
__wbindgen_init_externref_table: function() {
|
|
739
|
+
const table = wasm.__wbindgen_externrefs;
|
|
740
|
+
const offset = table.grow(4);
|
|
741
|
+
table.set(0, undefined);
|
|
742
|
+
table.set(offset + 0, undefined);
|
|
743
|
+
table.set(offset + 1, null);
|
|
744
|
+
table.set(offset + 2, true);
|
|
745
|
+
table.set(offset + 3, false);
|
|
746
|
+
},
|
|
747
|
+
};
|
|
748
|
+
return {
|
|
749
|
+
__proto__: null,
|
|
750
|
+
"./tellegen_bg.js": import0,
|
|
751
|
+
};
|
|
752
|
+
}
|
|
753
|
+
|
|
754
|
+
const StudyFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
755
|
+
? { register: () => {}, unregister: () => {} }
|
|
756
|
+
: new FinalizationRegistry(ptr => wasm.__wbg_study_free(ptr, 1));
|
|
757
|
+
|
|
758
|
+
function addToExternrefTable0(obj) {
|
|
759
|
+
const idx = wasm.__externref_table_alloc();
|
|
760
|
+
wasm.__wbindgen_externrefs.set(idx, obj);
|
|
761
|
+
return idx;
|
|
762
|
+
}
|
|
763
|
+
|
|
764
|
+
let cachedDataViewMemory0 = null;
|
|
765
|
+
function getDataViewMemory0() {
|
|
766
|
+
if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || (cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm.memory.buffer)) {
|
|
767
|
+
cachedDataViewMemory0 = new DataView(wasm.memory.buffer);
|
|
768
|
+
}
|
|
769
|
+
return cachedDataViewMemory0;
|
|
770
|
+
}
|
|
771
|
+
|
|
772
|
+
function getStringFromWasm0(ptr, len) {
|
|
773
|
+
return decodeText(ptr >>> 0, len);
|
|
774
|
+
}
|
|
775
|
+
|
|
776
|
+
let cachedUint8ArrayMemory0 = null;
|
|
777
|
+
function getUint8ArrayMemory0() {
|
|
778
|
+
if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
|
|
779
|
+
cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
|
|
780
|
+
}
|
|
781
|
+
return cachedUint8ArrayMemory0;
|
|
782
|
+
}
|
|
783
|
+
|
|
784
|
+
function isLikeNone(x) {
|
|
785
|
+
return x === undefined || x === null;
|
|
786
|
+
}
|
|
787
|
+
|
|
788
|
+
function passArray8ToWasm0(arg, malloc) {
|
|
789
|
+
const ptr = malloc(arg.length * 1, 1) >>> 0;
|
|
790
|
+
getUint8ArrayMemory0().set(arg, ptr / 1);
|
|
791
|
+
WASM_VECTOR_LEN = arg.length;
|
|
792
|
+
return ptr;
|
|
793
|
+
}
|
|
794
|
+
|
|
795
|
+
function passStringToWasm0(arg, malloc, realloc) {
|
|
796
|
+
if (realloc === undefined) {
|
|
797
|
+
const buf = cachedTextEncoder.encode(arg);
|
|
798
|
+
const ptr = malloc(buf.length, 1) >>> 0;
|
|
799
|
+
getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);
|
|
800
|
+
WASM_VECTOR_LEN = buf.length;
|
|
801
|
+
return ptr;
|
|
802
|
+
}
|
|
803
|
+
|
|
804
|
+
let len = arg.length;
|
|
805
|
+
let ptr = malloc(len, 1) >>> 0;
|
|
806
|
+
|
|
807
|
+
const mem = getUint8ArrayMemory0();
|
|
808
|
+
|
|
809
|
+
let offset = 0;
|
|
810
|
+
|
|
811
|
+
for (; offset < len; offset++) {
|
|
812
|
+
const code = arg.charCodeAt(offset);
|
|
813
|
+
if (code > 0x7F) break;
|
|
814
|
+
mem[ptr + offset] = code;
|
|
815
|
+
}
|
|
816
|
+
if (offset !== len) {
|
|
817
|
+
if (offset !== 0) {
|
|
818
|
+
arg = arg.slice(offset);
|
|
819
|
+
}
|
|
820
|
+
ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
|
|
821
|
+
const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
|
|
822
|
+
const ret = cachedTextEncoder.encodeInto(arg, view);
|
|
823
|
+
|
|
824
|
+
offset += ret.written;
|
|
825
|
+
ptr = realloc(ptr, len, offset, 1) >>> 0;
|
|
826
|
+
}
|
|
827
|
+
|
|
828
|
+
WASM_VECTOR_LEN = offset;
|
|
829
|
+
return ptr;
|
|
830
|
+
}
|
|
831
|
+
|
|
832
|
+
function takeFromExternrefTable0(idx) {
|
|
833
|
+
const value = wasm.__wbindgen_externrefs.get(idx);
|
|
834
|
+
wasm.__externref_table_dealloc(idx);
|
|
835
|
+
return value;
|
|
836
|
+
}
|
|
837
|
+
|
|
838
|
+
let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
|
|
839
|
+
cachedTextDecoder.decode();
|
|
840
|
+
const MAX_SAFARI_DECODE_BYTES = 2146435072;
|
|
841
|
+
let numBytesDecoded = 0;
|
|
842
|
+
function decodeText(ptr, len) {
|
|
843
|
+
numBytesDecoded += len;
|
|
844
|
+
if (numBytesDecoded >= MAX_SAFARI_DECODE_BYTES) {
|
|
845
|
+
cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
|
|
846
|
+
cachedTextDecoder.decode();
|
|
847
|
+
numBytesDecoded = len;
|
|
848
|
+
}
|
|
849
|
+
return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
|
|
850
|
+
}
|
|
851
|
+
|
|
852
|
+
const cachedTextEncoder = new TextEncoder();
|
|
853
|
+
|
|
854
|
+
if (!('encodeInto' in cachedTextEncoder)) {
|
|
855
|
+
cachedTextEncoder.encodeInto = function (arg, view) {
|
|
856
|
+
const buf = cachedTextEncoder.encode(arg);
|
|
857
|
+
view.set(buf);
|
|
858
|
+
return {
|
|
859
|
+
read: arg.length,
|
|
860
|
+
written: buf.length
|
|
861
|
+
};
|
|
862
|
+
};
|
|
863
|
+
}
|
|
864
|
+
|
|
865
|
+
let WASM_VECTOR_LEN = 0;
|
|
866
|
+
|
|
867
|
+
let wasmModule, wasmInstance, wasm;
|
|
868
|
+
function __wbg_finalize_init(instance, module) {
|
|
869
|
+
wasmInstance = instance;
|
|
870
|
+
wasm = instance.exports;
|
|
871
|
+
wasmModule = module;
|
|
872
|
+
cachedDataViewMemory0 = null;
|
|
873
|
+
cachedUint8ArrayMemory0 = null;
|
|
874
|
+
wasm.__wbindgen_start();
|
|
875
|
+
return wasm;
|
|
876
|
+
}
|
|
877
|
+
|
|
878
|
+
async function __wbg_load(module, imports) {
|
|
879
|
+
if (typeof Response === 'function' && module instanceof Response) {
|
|
880
|
+
if (typeof WebAssembly.instantiateStreaming === 'function') {
|
|
881
|
+
try {
|
|
882
|
+
return await WebAssembly.instantiateStreaming(module, imports);
|
|
883
|
+
} catch (e) {
|
|
884
|
+
const validResponse = module.ok && expectedResponseType(module.type);
|
|
885
|
+
|
|
886
|
+
if (validResponse && module.headers.get('Content-Type') !== 'application/wasm') {
|
|
887
|
+
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);
|
|
888
|
+
|
|
889
|
+
} else { throw e; }
|
|
890
|
+
}
|
|
891
|
+
}
|
|
892
|
+
|
|
893
|
+
const bytes = await module.arrayBuffer();
|
|
894
|
+
return await WebAssembly.instantiate(bytes, imports);
|
|
895
|
+
} else {
|
|
896
|
+
const instance = await WebAssembly.instantiate(module, imports);
|
|
897
|
+
|
|
898
|
+
if (instance instanceof WebAssembly.Instance) {
|
|
899
|
+
return { instance, module };
|
|
900
|
+
} else {
|
|
901
|
+
return instance;
|
|
902
|
+
}
|
|
903
|
+
}
|
|
904
|
+
|
|
905
|
+
function expectedResponseType(type) {
|
|
906
|
+
switch (type) {
|
|
907
|
+
case 'basic': case 'cors': case 'default': return true;
|
|
908
|
+
}
|
|
909
|
+
return false;
|
|
910
|
+
}
|
|
911
|
+
}
|
|
912
|
+
|
|
913
|
+
function initSync(module) {
|
|
914
|
+
if (wasm !== undefined) return wasm;
|
|
915
|
+
|
|
916
|
+
|
|
917
|
+
if (module !== undefined) {
|
|
918
|
+
if (Object.getPrototypeOf(module) === Object.prototype) {
|
|
919
|
+
({module} = module)
|
|
920
|
+
} else {
|
|
921
|
+
console.warn('using deprecated parameters for `initSync()`; pass a single object instead')
|
|
922
|
+
}
|
|
923
|
+
}
|
|
924
|
+
|
|
925
|
+
const imports = __wbg_get_imports();
|
|
926
|
+
if (!(module instanceof WebAssembly.Module)) {
|
|
927
|
+
module = new WebAssembly.Module(module);
|
|
928
|
+
}
|
|
929
|
+
const instance = new WebAssembly.Instance(module, imports);
|
|
930
|
+
return __wbg_finalize_init(instance, module);
|
|
931
|
+
}
|
|
932
|
+
|
|
933
|
+
async function __wbg_init(module_or_path) {
|
|
934
|
+
if (wasm !== undefined) return wasm;
|
|
935
|
+
|
|
936
|
+
|
|
937
|
+
if (module_or_path !== undefined) {
|
|
938
|
+
if (Object.getPrototypeOf(module_or_path) === Object.prototype) {
|
|
939
|
+
({module_or_path} = module_or_path)
|
|
940
|
+
} else {
|
|
941
|
+
console.warn('using deprecated parameters for the initialization function; pass a single object instead')
|
|
942
|
+
}
|
|
943
|
+
}
|
|
944
|
+
|
|
945
|
+
if (module_or_path === undefined) {
|
|
946
|
+
module_or_path = new URL('tellegen_bg.wasm', import.meta.url);
|
|
947
|
+
}
|
|
948
|
+
const imports = __wbg_get_imports();
|
|
949
|
+
|
|
950
|
+
if (typeof module_or_path === 'string' || (typeof Request === 'function' && module_or_path instanceof Request) || (typeof URL === 'function' && module_or_path instanceof URL)) {
|
|
951
|
+
module_or_path = fetch(module_or_path);
|
|
952
|
+
}
|
|
953
|
+
|
|
954
|
+
const { instance, module } = await __wbg_load(await module_or_path, imports);
|
|
955
|
+
|
|
956
|
+
return __wbg_finalize_init(instance, module);
|
|
957
|
+
}
|
|
958
|
+
|
|
959
|
+
export { initSync, __wbg_init as default };
|