@tellegen/engine 0.2.0 → 0.4.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.
Files changed (60) hide show
  1. package/README.md +71 -20
  2. package/dist/data/populated_places.json +1 -0
  3. package/dist/generated/{contracts.d.ts → api-types.d.ts} +26 -18
  4. package/dist/generated/api-types.d.ts.map +1 -0
  5. package/dist/generated/api-types.js +8 -0
  6. package/dist/generated/api-types.js.map +1 -0
  7. package/dist/generated/study-schema.d.ts +2 -0
  8. package/dist/generated/study-schema.d.ts.map +1 -0
  9. package/dist/generated/study-schema.js +3 -0
  10. package/dist/generated/study-schema.js.map +1 -0
  11. package/dist/generated/study-types.d.ts +426 -0
  12. package/dist/generated/study-types.d.ts.map +1 -0
  13. package/dist/generated/study-types.js +4 -0
  14. package/dist/generated/study-types.js.map +1 -0
  15. package/dist/generated/synth-schema.d.ts +2 -0
  16. package/dist/generated/synth-schema.d.ts.map +1 -0
  17. package/dist/generated/synth-schema.js +3 -0
  18. package/dist/generated/synth-schema.js.map +1 -0
  19. package/dist/generated/synth-types.d.ts +482 -0
  20. package/dist/generated/synth-types.d.ts.map +1 -0
  21. package/dist/generated/synth-types.js +4 -0
  22. package/dist/generated/synth-types.js.map +1 -0
  23. package/dist/host.d.ts +35 -2
  24. package/dist/host.d.ts.map +1 -1
  25. package/dist/host.js +103 -17
  26. package/dist/host.js.map +1 -1
  27. package/dist/index.d.ts +549 -122
  28. package/dist/index.d.ts.map +1 -1
  29. package/dist/index.js +780 -109
  30. package/dist/index.js.map +1 -1
  31. package/dist/input-limit.d.ts +1 -1
  32. package/dist/input-limit.js +1 -1
  33. package/dist/module.d.ts +2 -0
  34. package/dist/module.d.ts.map +1 -1
  35. package/dist/module.js.map +1 -1
  36. package/dist/protocol.d.ts +182 -31
  37. package/dist/protocol.d.ts.map +1 -1
  38. package/dist/protocol.js +153 -26
  39. package/dist/protocol.js.map +1 -1
  40. package/dist/study-document.d.ts +46 -0
  41. package/dist/study-document.d.ts.map +1 -0
  42. package/dist/study-document.js +183 -0
  43. package/dist/study-document.js.map +1 -0
  44. package/dist/study-document.test.d.ts +2 -0
  45. package/dist/study-document.test.d.ts.map +1 -0
  46. package/dist/study-document.test.js +119 -0
  47. package/dist/study-document.test.js.map +1 -0
  48. package/dist/wasm-pkg/LICENSE +17 -4
  49. package/dist/wasm-pkg/tellegen.d.ts +332 -85
  50. package/dist/wasm-pkg/tellegen.js +1324 -250
  51. package/dist/wasm-pkg/tellegen_bg.wasm +0 -0
  52. package/dist/wasm-pkg/tellegen_bg.wasm.d.ts +57 -9
  53. package/dist/worker.js +20 -5
  54. package/dist/worker.js.map +1 -1
  55. package/package.json +32 -11
  56. package/dist/generated/contracts.d.ts.map +0 -1
  57. package/dist/generated/contracts.js +0 -8
  58. package/dist/generated/contracts.js.map +0 -1
  59. package/dist/wasm-pkg/LICENSE-APACHE +0 -201
  60. package/dist/wasm-pkg/LICENSE-MIT +0 -19
@@ -1,17 +1,315 @@
1
1
  /* @ts-self-types="./tellegen.d.ts" */
2
2
 
3
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)
4
+ * A retained fixed-point current-injection session. The prepared network,
5
+ * sparse LU, and last converged voltage remain in this WASM object across
6
+ * load edits. Ordinary edits return the compact summary; detailed terminal
7
+ * and equipment values are fetched on demand.
8
+ */
9
+ export class McPfSession {
10
+ __destroy_into_raw() {
11
+ const ptr = this.__wbg_ptr;
12
+ this.__wbg_ptr = 0;
13
+ McPfSessionFinalization.unregister(this);
14
+ return ptr;
15
+ }
16
+ free() {
17
+ const ptr = this.__destroy_into_raw();
18
+ wasm.__wbg_mcpfsession_free(ptr, 0);
19
+ }
20
+ /**
21
+ * Phase timings of the session's parse, preparation, factorization, and first solve.
22
+ * @returns {string}
23
+ */
24
+ cold_profile() {
25
+ let deferred2_0;
26
+ let deferred2_1;
27
+ try {
28
+ const ret = wasm.mcpfsession_cold_profile(this.__wbg_ptr);
29
+ var ptr1 = ret[0];
30
+ var len1 = ret[1];
31
+ if (ret[3]) {
32
+ ptr1 = 0; len1 = 0;
33
+ throw takeFromExternrefTable0(ret[2]);
34
+ }
35
+ deferred2_0 = ptr1;
36
+ deferred2_1 = len1;
37
+ return getStringFromWasm0(ptr1, len1);
38
+ } finally {
39
+ wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
40
+ }
41
+ }
42
+ /**
43
+ * One bounded page of terminal and equipment values for a bus or element.
44
+ * @param {string} query_json
45
+ * @returns {string}
46
+ */
47
+ detail(query_json) {
48
+ let deferred3_0;
49
+ let deferred3_1;
50
+ try {
51
+ const ptr0 = passStringToWasm0(query_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
52
+ const len0 = WASM_VECTOR_LEN;
53
+ const ret = wasm.mcpfsession_detail(this.__wbg_ptr, ptr0, len0);
54
+ var ptr2 = ret[0];
55
+ var len2 = ret[1];
56
+ if (ret[3]) {
57
+ ptr2 = 0; len2 = 0;
58
+ throw takeFromExternrefTable0(ret[2]);
59
+ }
60
+ deferred3_0 = ptr2;
61
+ deferred3_1 = len2;
62
+ return getStringFromWasm0(ptr2, len2);
63
+ } finally {
64
+ wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
65
+ }
66
+ }
67
+ /**
68
+ * Materialize the current edited input as PowerIO IR.
69
+ * @returns {string}
70
+ */
71
+ input_module() {
72
+ let deferred2_0;
73
+ let deferred2_1;
74
+ try {
75
+ const ret = wasm.mcpfsession_input_module(this.__wbg_ptr);
76
+ var ptr1 = ret[0];
77
+ var len1 = ret[1];
78
+ if (ret[3]) {
79
+ ptr1 = 0; len1 = 0;
80
+ throw takeFromExternrefTable0(ret[2]);
81
+ }
82
+ deferred2_0 = ptr1;
83
+ deferred2_1 = len1;
84
+ return getStringFromWasm0(ptr1, len1);
85
+ } finally {
86
+ wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
87
+ }
88
+ }
89
+ /**
90
+ * Editable load branches with base and current P/Q values.
91
+ * @returns {string}
92
+ */
93
+ load_branches() {
94
+ let deferred2_0;
95
+ let deferred2_1;
96
+ try {
97
+ const ret = wasm.mcpfsession_load_branches(this.__wbg_ptr);
98
+ var ptr1 = ret[0];
99
+ var len1 = ret[1];
100
+ if (ret[3]) {
101
+ ptr1 = 0; len1 = 0;
102
+ throw takeFromExternrefTable0(ret[2]);
103
+ }
104
+ deferred2_0 = ptr1;
105
+ deferred2_1 = len1;
106
+ return getStringFromWasm0(ptr1, len1);
107
+ } finally {
108
+ wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
109
+ }
110
+ }
111
+ /**
112
+ * Edited networks materialized for portable output; ordinary edits build none.
113
+ * @returns {number}
114
+ */
115
+ materialization_count() {
116
+ const ret = wasm.mcpfsession_materialization_count(this.__wbg_ptr);
117
+ return ret >>> 0;
118
+ }
119
+ /**
120
+ * @param {string} module_json
121
+ * @param {string} options_json
122
+ */
123
+ constructor(module_json, options_json) {
124
+ const ptr0 = passStringToWasm0(module_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
125
+ const len0 = WASM_VECTOR_LEN;
126
+ const ptr1 = passStringToWasm0(options_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
127
+ const len1 = WASM_VECTOR_LEN;
128
+ const ret = wasm.mcpfsession_new(ptr0, len0, ptr1, len1);
129
+ if (ret[2]) {
130
+ throw takeFromExternrefTable0(ret[1]);
131
+ }
132
+ this.__wbg_ptr = ret[0];
133
+ McPfSessionFinalization.register(this, this.__wbg_ptr, this);
134
+ return this;
135
+ }
136
+ /**
137
+ * Phase timings of the most recent solve.
138
+ * @returns {string}
139
+ */
140
+ profile() {
141
+ let deferred2_0;
142
+ let deferred2_1;
143
+ try {
144
+ const ret = wasm.mcpfsession_profile(this.__wbg_ptr);
145
+ var ptr1 = ret[0];
146
+ var len1 = ret[1];
147
+ if (ret[3]) {
148
+ ptr1 = 0; len1 = 0;
149
+ throw takeFromExternrefTable0(ret[2]);
150
+ }
151
+ deferred2_0 = ptr1;
152
+ deferred2_1 = len1;
153
+ return getStringFromWasm0(ptr1, len1);
154
+ } finally {
155
+ wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
156
+ }
157
+ }
158
+ /**
159
+ * Replace the absolute branch-power edit state, solve with the retained
160
+ * factorization and previous converged voltage, and return the summary.
161
+ * @param {string} edits_json
162
+ * @returns {string}
163
+ */
164
+ replace_load_powers(edits_json) {
165
+ let deferred3_0;
166
+ let deferred3_1;
167
+ try {
168
+ const ptr0 = passStringToWasm0(edits_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
169
+ const len0 = WASM_VECTOR_LEN;
170
+ const ret = wasm.mcpfsession_replace_load_powers(this.__wbg_ptr, ptr0, len0);
171
+ var ptr2 = ret[0];
172
+ var len2 = ret[1];
173
+ if (ret[3]) {
174
+ ptr2 = 0; len2 = 0;
175
+ throw takeFromExternrefTable0(ret[2]);
176
+ }
177
+ deferred3_0 = ptr2;
178
+ deferred3_1 = len2;
179
+ return getStringFromWasm0(ptr2, len2);
180
+ } finally {
181
+ wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
182
+ }
183
+ }
184
+ /**
185
+ * The complete terminal and equipment result, built on demand. Its size
186
+ * grows with the network; the interactive path uses `summary`/`detail`.
187
+ * @returns {string}
188
+ */
189
+ result() {
190
+ let deferred2_0;
191
+ let deferred2_1;
192
+ try {
193
+ const ret = wasm.mcpfsession_result(this.__wbg_ptr);
194
+ var ptr1 = ret[0];
195
+ var len1 = ret[1];
196
+ if (ret[3]) {
197
+ ptr1 = 0; len1 = 0;
198
+ throw takeFromExternrefTable0(ret[2]);
199
+ }
200
+ deferred2_0 = ptr1;
201
+ deferred2_1 = len1;
202
+ return getStringFromWasm0(ptr1, len1);
203
+ } finally {
204
+ wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
205
+ }
206
+ }
207
+ /**
208
+ * Save the current edited point and result without re-solving.
209
+ * @param {string} study_id
210
+ * @param {string} study_title
211
+ * @returns {string}
212
+ */
213
+ snapshot(study_id, study_title) {
214
+ let deferred4_0;
215
+ let deferred4_1;
216
+ try {
217
+ const ptr0 = passStringToWasm0(study_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
218
+ const len0 = WASM_VECTOR_LEN;
219
+ const ptr1 = passStringToWasm0(study_title, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
220
+ const len1 = WASM_VECTOR_LEN;
221
+ const ret = wasm.mcpfsession_snapshot(this.__wbg_ptr, ptr0, len0, ptr1, len1);
222
+ var ptr3 = ret[0];
223
+ var len3 = ret[1];
224
+ if (ret[3]) {
225
+ ptr3 = 0; len3 = 0;
226
+ throw takeFromExternrefTable0(ret[2]);
227
+ }
228
+ deferred4_0 = ptr3;
229
+ deferred4_1 = len3;
230
+ return getStringFromWasm0(ptr3, len3);
231
+ } finally {
232
+ wasm.__wbindgen_free(deferred4_0, deferred4_1, 1);
233
+ }
234
+ }
235
+ /**
236
+ * The compact summary of the current operating point (constant size).
237
+ * @returns {string}
238
+ */
239
+ summary() {
240
+ let deferred2_0;
241
+ let deferred2_1;
242
+ try {
243
+ const ret = wasm.mcpfsession_summary(this.__wbg_ptr);
244
+ var ptr1 = ret[0];
245
+ var len1 = ret[1];
246
+ if (ret[3]) {
247
+ ptr1 = 0; len1 = 0;
248
+ throw takeFromExternrefTable0(ret[2]);
249
+ }
250
+ deferred2_0 = ptr1;
251
+ deferred2_1 = len1;
252
+ return getStringFromWasm0(ptr1, len1);
253
+ } finally {
254
+ wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
255
+ }
256
+ }
257
+ /**
258
+ * Currents injected into the network as interleaved `[re, im]` amperes.
259
+ * @returns {Float64Array}
260
+ */
261
+ terminal_currents() {
262
+ const ret = wasm.mcpfsession_terminal_currents(this.__wbg_ptr);
263
+ var v1 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
264
+ wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
265
+ return v1;
266
+ }
267
+ /**
268
+ * Terminal identities as `[bus, terminal]` pairs in calculation order.
269
+ * They never change for a session, so a host fetches them once.
270
+ * @returns {string}
271
+ */
272
+ terminal_ids() {
273
+ let deferred2_0;
274
+ let deferred2_1;
275
+ try {
276
+ const ret = wasm.mcpfsession_terminal_ids(this.__wbg_ptr);
277
+ var ptr1 = ret[0];
278
+ var len1 = ret[1];
279
+ if (ret[3]) {
280
+ ptr1 = 0; len1 = 0;
281
+ throw takeFromExternrefTable0(ret[2]);
282
+ }
283
+ deferred2_0 = ptr1;
284
+ deferred2_1 = len1;
285
+ return getStringFromWasm0(ptr1, len1);
286
+ } finally {
287
+ wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
288
+ }
289
+ }
290
+ /**
291
+ * Terminal voltages as interleaved `[re, im]` volts (a `Float64Array`).
292
+ * @returns {Float64Array}
293
+ */
294
+ terminal_voltages() {
295
+ const ret = wasm.mcpfsession_terminal_voltages(this.__wbg_ptr);
296
+ var v1 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
297
+ wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
298
+ return v1;
299
+ }
300
+ }
301
+ if (Symbol.dispose) McPfSession.prototype[Symbol.dispose] = McPfSession.prototype.free;
302
+
303
+ /**
304
+ * A retained handle over the engine, exported to JS. Construct once per PowerIO module;
305
+ * then [`replace_edits`](Study::replace_edits)
6
306
  * 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.
307
+ * returns a first order linearization toward an absolute edit state.
10
308
  *
11
309
  * Arguments and results are JSON in the engine's `Study` shapes: edits are a
12
310
  * `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
311
+ * also accepts a powerio row uid string when the source format carries uids,
312
+ * e.g. `"bus":"buses:1"`), `preview` watches an
15
313
  * `Operand[]` (e.g. `[{"Price":"Active"}]`) and returns a `Preview`. `commit` takes the
16
314
  * edits plus a `SensRequest[]` of watched cells and returns `{ solution, iterations,
17
315
  * sensitivities }` — the committed [`SolveResponse`] plus the requested ∂operand/∂param
@@ -32,7 +330,7 @@ export class Study {
32
330
  /**
33
331
  * Apply a geographic layer (a canonical `.geo.json` from [`parse_geo`] or
34
332
  * [`apply_layout`]) onto this study's base network, so a later
35
- * [`save_package`](Study::save_package) or export carries the coordinates
333
+ * [`save_module`](Study::save_module) or export carries the coordinates
36
334
  * on screen. Locations are metadata the model never reads; nothing
37
335
  * re-solves. Returns the apply report JSON.
38
336
  * @param {string} layer_geojson
@@ -92,6 +390,34 @@ export class Study {
92
390
  wasm.__wbindgen_free(deferred4_0, deferred4_1, 1);
93
391
  }
94
392
  }
393
+ /**
394
+ * Export the committed operating point to a powerio `format` (`matpower`,
395
+ * `psse`, ...). Returns `{ text, diagnostics, format,
396
+ * extension }` as JSON: the serialized case, this output operation's
397
+ * structured diagnostics, and the format token and file extension.
398
+ * @param {string} format
399
+ * @returns {string}
400
+ */
401
+ export(format) {
402
+ let deferred3_0;
403
+ let deferred3_1;
404
+ try {
405
+ const ptr0 = passStringToWasm0(format, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
406
+ const len0 = WASM_VECTOR_LEN;
407
+ const ret = wasm.study_export(this.__wbg_ptr, ptr0, len0);
408
+ var ptr2 = ret[0];
409
+ var len2 = ret[1];
410
+ if (ret[3]) {
411
+ ptr2 = 0; len2 = 0;
412
+ throw takeFromExternrefTable0(ret[2]);
413
+ }
414
+ deferred3_0 = ptr2;
415
+ deferred3_1 = len2;
416
+ return getStringFromWasm0(ptr2, len2);
417
+ } finally {
418
+ wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
419
+ }
420
+ }
95
421
  /**
96
422
  * The formulation tag (`"dcopf"` / `"acpf"`).
97
423
  * @returns {string}
@@ -109,14 +435,14 @@ export class Study {
109
435
  }
110
436
  }
111
437
  /**
112
- * Build a study over `network_json` for `formulation` (`"dcopf"` / `"acpf"`, and —
438
+ * Build a study over `module_json` for `formulation` (`"dcopf"` / `"acpf"`, and —
113
439
  * 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
440
+ * Bare model JSON and unknown or unavailable formulations are rejected.
441
+ * @param {string} module_json
116
442
  * @param {string} formulation
117
443
  */
118
- constructor(network_json, formulation) {
119
- const ptr0 = passStringToWasm0(network_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
444
+ constructor(module_json, formulation) {
445
+ const ptr0 = passStringToWasm0(module_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
120
446
  const len0 = WASM_VECTOR_LEN;
121
447
  const ptr1 = passStringToWasm0(formulation, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
122
448
  const len1 = WASM_VECTOR_LEN;
@@ -128,6 +454,38 @@ export class Study {
128
454
  StudyFinalization.register(this, this.__wbg_ptr, this);
129
455
  return this;
130
456
  }
457
+ /**
458
+ * Run a bounded differentiable planning search over the committed
459
+ * operating point: the implicit gradient of the serializable outer
460
+ * objective through the exact DC OPF KKT orders capacity trials
461
+ * whose every step is verified by an exact re-solve. Read only — the
462
+ * committed case, edits, and revision are untouched. `spec_json` is a
463
+ * [`tellegen::plan::CapacityPlanSpec`]; the returned JSON is the complete
464
+ * [`tellegen::plan::CapacityPlanOutcome`] trace with the unapplied
465
+ * proposal. A non-DC formulation returns a typed error.
466
+ * @param {string} spec_json
467
+ * @returns {string}
468
+ */
469
+ plan(spec_json) {
470
+ let deferred3_0;
471
+ let deferred3_1;
472
+ try {
473
+ const ptr0 = passStringToWasm0(spec_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
474
+ const len0 = WASM_VECTOR_LEN;
475
+ const ret = wasm.study_plan(this.__wbg_ptr, ptr0, len0);
476
+ var ptr2 = ret[0];
477
+ var len2 = ret[1];
478
+ if (ret[3]) {
479
+ ptr2 = 0; len2 = 0;
480
+ throw takeFromExternrefTable0(ret[2]);
481
+ }
482
+ deferred3_0 = ptr2;
483
+ deferred3_1 = len2;
484
+ return getStringFromWasm0(ptr2, len2);
485
+ } finally {
486
+ wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
487
+ }
488
+ }
131
489
  /**
132
490
  * First-order preview of `edits_json` (a `NetworkEdit[]`) for the `watched_json`
133
491
  * operands (an `Operand[]`), at the committed point, without re-solving. Returns the
@@ -219,17 +577,62 @@ export class Study {
219
577
  }
220
578
  }
221
579
  /**
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`].
580
+ * Serialize the exact problem instance, including its inner objective and constraints.
581
+ * @returns {string}
582
+ */
583
+ save_instance_module() {
584
+ let deferred2_0;
585
+ let deferred2_1;
586
+ try {
587
+ const ret = wasm.study_save_instance_module(this.__wbg_ptr);
588
+ var ptr1 = ret[0];
589
+ var len1 = ret[1];
590
+ if (ret[3]) {
591
+ ptr1 = 0; len1 = 0;
592
+ throw takeFromExternrefTable0(ret[2]);
593
+ }
594
+ deferred2_0 = ptr1;
595
+ deferred2_1 = len1;
596
+ return getStringFromWasm0(ptr1, len1);
597
+ } finally {
598
+ wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
599
+ }
600
+ }
601
+ /**
602
+ * Serialize the committed operating point as a stored PowerIO module:
603
+ * the materialized network with one descriptive `Edit` history entry per
604
+ * committed edit, ready to download as `.pio.json`. Any PowerIO reader
605
+ * understands the file; reloading it starts a fresh session.
226
606
  * @returns {string}
227
607
  */
228
- save_package() {
608
+ save_module() {
229
609
  let deferred2_0;
230
610
  let deferred2_1;
231
611
  try {
232
- const ret = wasm.study_save_package(this.__wbg_ptr);
612
+ const ret = wasm.study_save_module(this.__wbg_ptr);
613
+ var ptr1 = ret[0];
614
+ var len1 = ret[1];
615
+ if (ret[3]) {
616
+ ptr1 = 0; len1 = 0;
617
+ throw takeFromExternrefTable0(ret[2]);
618
+ }
619
+ deferred2_0 = ptr1;
620
+ deferred2_1 = len1;
621
+ return getStringFromWasm0(ptr1, len1);
622
+ } finally {
623
+ wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
624
+ }
625
+ }
626
+ /**
627
+ * Save the committed exact DC OPF result as a PowerIO solution module.
628
+ * The embedded instance contains the materialized case that was solved.
629
+ * @returns {string}
630
+ */
631
+ save_solution_module() {
632
+ let deferred2_0;
633
+ let deferred2_1;
634
+ try {
635
+ const ret = wasm.study_save_solution_module(this.__wbg_ptr);
233
636
  var ptr1 = ret[0];
234
637
  var len1 = ret[1];
235
638
  if (ret[3]) {
@@ -247,11 +650,274 @@ export class Study {
247
650
  * The most recent committed solution as `SolveResponse` JSON.
248
651
  * @returns {string}
249
652
  */
250
- solution() {
653
+ solution() {
654
+ let deferred2_0;
655
+ let deferred2_1;
656
+ try {
657
+ const ret = wasm.study_solution(this.__wbg_ptr);
658
+ var ptr1 = ret[0];
659
+ var len1 = ret[1];
660
+ if (ret[3]) {
661
+ ptr1 = 0; len1 = 0;
662
+ throw takeFromExternrefTable0(ret[2]);
663
+ }
664
+ deferred2_0 = ptr1;
665
+ deferred2_1 = len1;
666
+ return getStringFromWasm0(ptr1, len1);
667
+ } finally {
668
+ wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
669
+ }
670
+ }
671
+ }
672
+ if (Symbol.dispose) Study.prototype[Symbol.dispose] = Study.prototype.free;
673
+
674
+ /**
675
+ * A synthetic preview as flat arrays: bus `[lon, lat]` pairs, kinds (0 load,
676
+ * 1 substation, 2 generator, 3 converter) and kV in bus order, branch route
677
+ * points, the index where each route starts (one entry more than there are
678
+ * branches) and branch kV.
679
+ */
680
+ export class SynthPreviewBuffers {
681
+ static __wrap(ptr) {
682
+ const obj = Object.create(SynthPreviewBuffers.prototype);
683
+ obj.__wbg_ptr = ptr;
684
+ SynthPreviewBuffersFinalization.register(obj, obj.__wbg_ptr, obj);
685
+ return obj;
686
+ }
687
+ __destroy_into_raw() {
688
+ const ptr = this.__wbg_ptr;
689
+ this.__wbg_ptr = 0;
690
+ SynthPreviewBuffersFinalization.unregister(this);
691
+ return ptr;
692
+ }
693
+ free() {
694
+ const ptr = this.__destroy_into_raw();
695
+ wasm.__wbg_synthpreviewbuffers_free(ptr, 0);
696
+ }
697
+ /**
698
+ * @returns {Float32Array}
699
+ */
700
+ branch_kv() {
701
+ const ret = wasm.synthpreviewbuffers_branch_kv(this.__wbg_ptr);
702
+ var v1 = getArrayF32FromWasm0(ret[0], ret[1]).slice();
703
+ wasm.__wbindgen_free(ret[0], ret[1] * 4, 4);
704
+ return v1;
705
+ }
706
+ /**
707
+ * @returns {Float64Array}
708
+ */
709
+ branch_positions() {
710
+ const ret = wasm.synthpreviewbuffers_branch_positions(this.__wbg_ptr);
711
+ var v1 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
712
+ wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
713
+ return v1;
714
+ }
715
+ /**
716
+ * @returns {Uint32Array}
717
+ */
718
+ branch_start_indices() {
719
+ const ret = wasm.synthpreviewbuffers_branch_start_indices(this.__wbg_ptr);
720
+ var v1 = getArrayU32FromWasm0(ret[0], ret[1]).slice();
721
+ wasm.__wbindgen_free(ret[0], ret[1] * 4, 4);
722
+ return v1;
723
+ }
724
+ /**
725
+ * @returns {Uint8Array}
726
+ */
727
+ bus_kinds() {
728
+ const ret = wasm.synthpreviewbuffers_bus_kinds(this.__wbg_ptr);
729
+ var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
730
+ wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
731
+ return v1;
732
+ }
733
+ /**
734
+ * @returns {Float32Array}
735
+ */
736
+ bus_kv() {
737
+ const ret = wasm.synthpreviewbuffers_bus_kv(this.__wbg_ptr);
738
+ var v1 = getArrayF32FromWasm0(ret[0], ret[1]).slice();
739
+ wasm.__wbindgen_free(ret[0], ret[1] * 4, 4);
740
+ return v1;
741
+ }
742
+ /**
743
+ * @returns {Float64Array}
744
+ */
745
+ bus_positions() {
746
+ const ret = wasm.synthpreviewbuffers_bus_positions(this.__wbg_ptr);
747
+ var v1 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
748
+ wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
749
+ return v1;
750
+ }
751
+ }
752
+ if (Symbol.dispose) SynthPreviewBuffers.prototype[Symbol.dispose] = SynthPreviewBuffers.prototype.free;
753
+
754
+ /**
755
+ * A staged synthetic generation: one bounded stage per `advance`, a map
756
+ * preview between stages, and the module, the report and the drop-panel
757
+ * payload once it is done.
758
+ */
759
+ export class SynthSession {
760
+ __destroy_into_raw() {
761
+ const ptr = this.__wbg_ptr;
762
+ this.__wbg_ptr = 0;
763
+ SynthSessionFinalization.unregister(this);
764
+ return ptr;
765
+ }
766
+ free() {
767
+ const ptr = this.__destroy_into_raw();
768
+ wasm.__wbg_synthsession_free(ptr, 0);
769
+ }
770
+ /**
771
+ * Run one stage (one calibration iteration for `calibrate`); returns the
772
+ * `StepOutcome` JSON.
773
+ * @returns {string}
774
+ */
775
+ advance() {
776
+ let deferred2_0;
777
+ let deferred2_1;
778
+ try {
779
+ const ret = wasm.synthsession_advance(this.__wbg_ptr);
780
+ var ptr1 = ret[0];
781
+ var len1 = ret[1];
782
+ if (ret[3]) {
783
+ ptr1 = 0; len1 = 0;
784
+ throw takeFromExternrefTable0(ret[2]);
785
+ }
786
+ deferred2_0 = ptr1;
787
+ deferred2_1 = len1;
788
+ return getStringFromWasm0(ptr1, len1);
789
+ } finally {
790
+ wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
791
+ }
792
+ }
793
+ /**
794
+ * The network as GridFM graphkit JSON (per-unit feature matrices on a
795
+ * 0-based bus index), from `electrify` on.
796
+ * @returns {string}
797
+ */
798
+ export_gridfm() {
799
+ let deferred2_0;
800
+ let deferred2_1;
801
+ try {
802
+ const ret = wasm.synthsession_export_gridfm(this.__wbg_ptr);
803
+ var ptr1 = ret[0];
804
+ var len1 = ret[1];
805
+ if (ret[3]) {
806
+ ptr1 = 0; len1 = 0;
807
+ throw takeFromExternrefTable0(ret[2]);
808
+ }
809
+ deferred2_0 = ptr1;
810
+ deferred2_1 = len1;
811
+ return getStringFromWasm0(ptr1, len1);
812
+ } finally {
813
+ wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
814
+ }
815
+ }
816
+ /**
817
+ * The drop-panel payload of the module (the `ingest_case` shape with
818
+ * `module_json`).
819
+ * @returns {string}
820
+ */
821
+ ingest() {
822
+ let deferred2_0;
823
+ let deferred2_1;
824
+ try {
825
+ const ret = wasm.synthsession_ingest(this.__wbg_ptr);
826
+ var ptr1 = ret[0];
827
+ var len1 = ret[1];
828
+ if (ret[3]) {
829
+ ptr1 = 0; len1 = 0;
830
+ throw takeFromExternrefTable0(ret[2]);
831
+ }
832
+ deferred2_0 = ptr1;
833
+ deferred2_1 = len1;
834
+ return getStringFromWasm0(ptr1, len1);
835
+ } finally {
836
+ wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
837
+ }
838
+ }
839
+ /**
840
+ * The module as generation 2 PowerIO IR text, with bus locations and
841
+ * branch routes, from `electrify` on.
842
+ * @returns {string}
843
+ */
844
+ module() {
845
+ let deferred2_0;
846
+ let deferred2_1;
847
+ try {
848
+ const ret = wasm.synthsession_module(this.__wbg_ptr);
849
+ var ptr1 = ret[0];
850
+ var len1 = ret[1];
851
+ if (ret[3]) {
852
+ ptr1 = 0; len1 = 0;
853
+ throw takeFromExternrefTable0(ret[2]);
854
+ }
855
+ deferred2_0 = ptr1;
856
+ deferred2_1 = len1;
857
+ return getStringFromWasm0(ptr1, len1);
858
+ } finally {
859
+ wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
860
+ }
861
+ }
862
+ /**
863
+ * Open a session at the `context` stage. `osm_json` is the Overpass
864
+ * document (one, or a JSON array of documents) for `source: "osm"`.
865
+ * @param {string} request_json
866
+ * @param {string | null} [osm_json]
867
+ */
868
+ constructor(request_json, osm_json) {
869
+ const ptr0 = passStringToWasm0(request_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
870
+ const len0 = WASM_VECTOR_LEN;
871
+ var ptr1 = isLikeNone(osm_json) ? 0 : passStringToWasm0(osm_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
872
+ var len1 = WASM_VECTOR_LEN;
873
+ const ret = wasm.synthsession_new(ptr0, len0, ptr1, len1);
874
+ if (ret[2]) {
875
+ throw takeFromExternrefTable0(ret[1]);
876
+ }
877
+ this.__wbg_ptr = ret[0];
878
+ SynthSessionFinalization.register(this, this.__wbg_ptr, this);
879
+ return this;
880
+ }
881
+ /**
882
+ * The map preview as `Preview` JSON records.
883
+ * @returns {string}
884
+ */
885
+ preview() {
886
+ let deferred2_0;
887
+ let deferred2_1;
888
+ try {
889
+ const ret = wasm.synthsession_preview(this.__wbg_ptr);
890
+ var ptr1 = ret[0];
891
+ var len1 = ret[1];
892
+ if (ret[3]) {
893
+ ptr1 = 0; len1 = 0;
894
+ throw takeFromExternrefTable0(ret[2]);
895
+ }
896
+ deferred2_0 = ptr1;
897
+ deferred2_1 = len1;
898
+ return getStringFromWasm0(ptr1, len1);
899
+ } finally {
900
+ wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
901
+ }
902
+ }
903
+ /**
904
+ * The map preview as flat arrays for binary map attributes, computed
905
+ * once; read each array, then `free()` the buffers.
906
+ * @returns {SynthPreviewBuffers}
907
+ */
908
+ preview_buffers() {
909
+ const ret = wasm.synthsession_preview_buffers(this.__wbg_ptr);
910
+ return SynthPreviewBuffers.__wrap(ret);
911
+ }
912
+ /**
913
+ * The `GenerationReport` JSON, partial until the session is done.
914
+ * @returns {string}
915
+ */
916
+ report() {
251
917
  let deferred2_0;
252
918
  let deferred2_1;
253
919
  try {
254
- const ret = wasm.study_solution(this.__wbg_ptr);
920
+ const ret = wasm.synthsession_report(this.__wbg_ptr);
255
921
  var ptr1 = ret[0];
256
922
  var len1 = ret[1];
257
923
  if (ret[3]) {
@@ -265,23 +931,39 @@ export class Study {
265
931
  wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
266
932
  }
267
933
  }
934
+ /**
935
+ * The stage the next `advance` runs.
936
+ * @returns {string}
937
+ */
938
+ stage() {
939
+ let deferred1_0;
940
+ let deferred1_1;
941
+ try {
942
+ const ret = wasm.synthsession_stage(this.__wbg_ptr);
943
+ deferred1_0 = ret[0];
944
+ deferred1_1 = ret[1];
945
+ return getStringFromWasm0(ret[0], ret[1]);
946
+ } finally {
947
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
948
+ }
949
+ }
268
950
  }
269
- if (Symbol.dispose) Study.prototype[Symbol.dispose] = Study.prototype.free;
951
+ if (Symbol.dispose) SynthSession.prototype[Symbol.dispose] = SynthSession.prototype.free;
270
952
 
271
953
  /**
272
954
  * Fill case coordinates from a PowerWorld `.pwd` sibling: substation symbols
273
955
  * project to approximate longitude/latitude and join onto buses through the
274
956
  * `SubNum` extras key. Returns the refreshed `ingest_case` payload plus a
275
957
  * `report`; errors when no bus joined.
276
- * @param {string} network_json
958
+ * @param {string} module_json
277
959
  * @param {Uint8Array} bytes
278
960
  * @returns {string}
279
961
  */
280
- export function apply_display_geo(network_json, bytes) {
962
+ export function apply_display_geo(module_json, bytes) {
281
963
  let deferred4_0;
282
964
  let deferred4_1;
283
965
  try {
284
- const ptr0 = passStringToWasm0(network_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
966
+ const ptr0 = passStringToWasm0(module_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
285
967
  const len0 = WASM_VECTOR_LEN;
286
968
  const ptr1 = passArray8ToWasm0(bytes, wasm.__wbindgen_malloc);
287
969
  const len1 = WASM_VECTOR_LEN;
@@ -306,15 +988,15 @@ export function apply_display_geo(network_json, bytes) {
306
988
  * id, name, and the unordered endpoint pair — upstream semantics). Returns
307
989
  * the refreshed `ingest_case` payload plus a `report` of matched/unmatched
308
990
  * counts; errors when nothing matched.
309
- * @param {string} network_json
991
+ * @param {string} module_json
310
992
  * @param {string} layer_geojson
311
993
  * @returns {string}
312
994
  */
313
- export function apply_geo(network_json, layer_geojson) {
995
+ export function apply_geo(module_json, layer_geojson) {
314
996
  let deferred4_0;
315
997
  let deferred4_1;
316
998
  try {
317
- const ptr0 = passStringToWasm0(network_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
999
+ const ptr0 = passStringToWasm0(module_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
318
1000
  const len0 = WASM_VECTOR_LEN;
319
1001
  const ptr1 = passStringToWasm0(layer_geojson, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
320
1002
  const len1 = WASM_VECTOR_LEN;
@@ -338,16 +1020,16 @@ export function apply_geo(network_json, layer_geojson) {
338
1020
  * `kind` provenance (`synthetic` or `manual`). Returns the refreshed
339
1021
  * `ingest_case` payload plus `layer`, the stamped layout as a canonical
340
1022
  * `.geo.json` document.
341
- * @param {string} network_json
1023
+ * @param {string} module_json
342
1024
  * @param {string} coords_json
343
1025
  * @param {string} kind
344
1026
  * @returns {string}
345
1027
  */
346
- export function apply_layout(network_json, coords_json, kind) {
1028
+ export function apply_layout(module_json, coords_json, kind) {
347
1029
  let deferred5_0;
348
1030
  let deferred5_1;
349
1031
  try {
350
- const ptr0 = passStringToWasm0(network_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1032
+ const ptr0 = passStringToWasm0(module_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
351
1033
  const len0 = WASM_VECTOR_LEN;
352
1034
  const ptr1 = passStringToWasm0(coords_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
353
1035
  const len1 = WASM_VECTOR_LEN;
@@ -368,6 +1050,35 @@ export function apply_layout(network_json, coords_json, kind) {
368
1050
  }
369
1051
  }
370
1052
 
1053
+ /**
1054
+ * Attach geographic or drawing positions to a saved multiconductor result.
1055
+ * @param {string} snapshot_json
1056
+ * @param {string} layer_geojson
1057
+ * @returns {string}
1058
+ */
1059
+ export function apply_mc_study_geo(snapshot_json, layer_geojson) {
1060
+ let deferred4_0;
1061
+ let deferred4_1;
1062
+ try {
1063
+ const ptr0 = passStringToWasm0(snapshot_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1064
+ const len0 = WASM_VECTOR_LEN;
1065
+ const ptr1 = passStringToWasm0(layer_geojson, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1066
+ const len1 = WASM_VECTOR_LEN;
1067
+ const ret = wasm.apply_mc_study_geo(ptr0, len0, ptr1, len1);
1068
+ var ptr3 = ret[0];
1069
+ var len3 = ret[1];
1070
+ if (ret[3]) {
1071
+ ptr3 = 0; len3 = 0;
1072
+ throw takeFromExternrefTable0(ret[2]);
1073
+ }
1074
+ deferred4_0 = ptr3;
1075
+ deferred4_1 = len3;
1076
+ return getStringFromWasm0(ptr3, len3);
1077
+ } finally {
1078
+ wasm.__wbindgen_free(deferred4_0, deferred4_1, 1);
1079
+ }
1080
+ }
1081
+
371
1082
  /**
372
1083
  * The capability matrix as JSON: which `(formulation, operand, parameter)` cells this
373
1084
  * build supports, so the UI can populate menus and grey out the rest.
@@ -414,25 +1125,55 @@ export function classify_json(bytes) {
414
1125
  }
415
1126
 
416
1127
  /**
417
- * Export the balanced study state at commit `commit` to a powerio `format`
418
- * (`matpower`, `psse`, `model-json`, ...). Returns `{ text, warnings, format,
419
- * extension }` as JSON: the serialized case, the writer's fidelity warnings so the
420
- * frontend can surface them, and the format token and file extension. The package
421
- * JSON is untrusted; malformed input returns a `JsError`, never a panic.
422
- * @param {string} package_json
423
- * @param {number} commit
1128
+ * A case's coordinates as a canonical `.geo.json` document (one point per
1129
+ * located bus, one route per routed branch, provenance preserved). Errors
1130
+ * when the case carries none.
1131
+ * @param {string} module_json
1132
+ * @returns {string}
1133
+ */
1134
+ export function extract_geo(module_json) {
1135
+ let deferred3_0;
1136
+ let deferred3_1;
1137
+ try {
1138
+ const ptr0 = passStringToWasm0(module_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1139
+ const len0 = WASM_VECTOR_LEN;
1140
+ const ret = wasm.extract_geo(ptr0, len0);
1141
+ var ptr2 = ret[0];
1142
+ var len2 = ret[1];
1143
+ if (ret[3]) {
1144
+ ptr2 = 0; len2 = 0;
1145
+ throw takeFromExternrefTable0(ret[2]);
1146
+ }
1147
+ deferred3_0 = ptr2;
1148
+ deferred3_1 = len2;
1149
+ return getStringFromWasm0(ptr2, len2);
1150
+ } finally {
1151
+ wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
1152
+ }
1153
+ }
1154
+
1155
+ /**
1156
+ * Everything the drop panel needs from one parse: counts, total load and
1157
+ * capacity, parse diagnostics, and a `view` of buses and branches in the shape
1158
+ * the tellegen API serves, placed at the coordinates the file carries
1159
+ * (PowerWorld complete case aux exports). `view` is null when the file has no
1160
+ * coordinates.
1161
+ *
1162
+ * Takes the dropped file's bytes, as [`parse_case`] does and for the same
1163
+ * reason.
1164
+ * @param {Uint8Array} bytes
424
1165
  * @param {string} format
425
1166
  * @returns {string}
426
1167
  */
427
- export function export_study(package_json, commit, format) {
1168
+ export function ingest_case(bytes, format) {
428
1169
  let deferred4_0;
429
1170
  let deferred4_1;
430
1171
  try {
431
- const ptr0 = passStringToWasm0(package_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1172
+ const ptr0 = passArray8ToWasm0(bytes, wasm.__wbindgen_malloc);
432
1173
  const len0 = WASM_VECTOR_LEN;
433
1174
  const ptr1 = passStringToWasm0(format, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
434
1175
  const len1 = WASM_VECTOR_LEN;
435
- const ret = wasm.export_study(ptr0, len0, commit, ptr1, len1);
1176
+ const ret = wasm.ingest_case(ptr0, len0, ptr1, len1);
436
1177
  var ptr3 = ret[0];
437
1178
  var len3 = ret[1];
438
1179
  if (ret[3]) {
@@ -448,19 +1189,91 @@ export function export_study(package_json, commit, format) {
448
1189
  }
449
1190
 
450
1191
  /**
451
- * A case's coordinates as a canonical `.geo.json` document (one point per
452
- * located bus, one route per routed branch, provenance preserved). Errors
453
- * when the case carries none.
454
- * @param {string} network_json
1192
+ * The distribution counterpart of [`ingest_case`]: view a multiconductor case
1193
+ * with no solve. `format` is a distribution reader token (`dss`, `bmopf`,
1194
+ * `pmd`) parsed by [`powerio_dist`], or `pio` for a `.pio.json` stored module
1195
+ * holding a supported multiconductor network, instance, or solution. Returns
1196
+ * the drop-panel payload JSON:
1197
+ * name, element counts, connected load/generation (kW), parse diagnostics,
1198
+ * coordinate provenance, and the bus/terminal graph the frontend renders (see
1199
+ * the private `dist` adapter).
1200
+ *
1201
+ * Untrusted input: the parse and module restore return error strings (mapped
1202
+ * to `JsError` here), so a malformed, truncated, or oversized `.dss`/JSON
1203
+ * rejects cleanly and never panics the wasm instance.
1204
+ * @param {string} text
1205
+ * @param {string} format
1206
+ * @returns {string}
1207
+ */
1208
+ export function ingest_dist_case(text, format) {
1209
+ let deferred4_0;
1210
+ let deferred4_1;
1211
+ try {
1212
+ const ptr0 = passStringToWasm0(text, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1213
+ const len0 = WASM_VECTOR_LEN;
1214
+ const ptr1 = passStringToWasm0(format, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1215
+ const len1 = WASM_VECTOR_LEN;
1216
+ const ret = wasm.ingest_dist_case(ptr0, len0, ptr1, len1);
1217
+ var ptr3 = ret[0];
1218
+ var len3 = ret[1];
1219
+ if (ret[3]) {
1220
+ ptr3 = 0; len3 = 0;
1221
+ throw takeFromExternrefTable0(ret[2]);
1222
+ }
1223
+ deferred4_0 = ptr3;
1224
+ deferred4_1 = len3;
1225
+ return getStringFromWasm0(ptr3, len3);
1226
+ } finally {
1227
+ wasm.__wbindgen_free(deferred4_0, deferred4_1, 1);
1228
+ }
1229
+ }
1230
+
1231
+ /**
1232
+ * Byte counterpart of [`ingest_dist_case`] for dropped files.
1233
+ * @param {Uint8Array} bytes
1234
+ * @param {string} format
1235
+ * @returns {string}
1236
+ */
1237
+ export function ingest_dist_case_bytes(bytes, format) {
1238
+ let deferred4_0;
1239
+ let deferred4_1;
1240
+ try {
1241
+ const ptr0 = passArray8ToWasm0(bytes, wasm.__wbindgen_malloc);
1242
+ const len0 = WASM_VECTOR_LEN;
1243
+ const ptr1 = passStringToWasm0(format, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1244
+ const len1 = WASM_VECTOR_LEN;
1245
+ const ret = wasm.ingest_dist_case_bytes(ptr0, len0, ptr1, len1);
1246
+ var ptr3 = ret[0];
1247
+ var len3 = ret[1];
1248
+ if (ret[3]) {
1249
+ ptr3 = 0; len3 = 0;
1250
+ throw takeFromExternrefTable0(ret[2]);
1251
+ }
1252
+ deferred4_0 = ptr3;
1253
+ deferred4_1 = len3;
1254
+ return getStringFromWasm0(ptr3, len3);
1255
+ } finally {
1256
+ wasm.__wbindgen_free(deferred4_0, deferred4_1, 1);
1257
+ }
1258
+ }
1259
+
1260
+ /**
1261
+ * Classify and ingest one dropped JSON byte buffer. Known inputs return their
1262
+ * render-ready payload; ambiguous and unknown documents return a null payload
1263
+ * so the caller can request an explicit format without decoding the bytes a
1264
+ * second time. A stored module is read once and its value routed to the
1265
+ * balanced or multiconductor view. The TS drop-classify layer must mirror
1266
+ * the kinds (`module` and powerio's families).
1267
+ * @param {Uint8Array} bytes
455
1268
  * @returns {string}
456
1269
  */
457
- export function extract_geo(network_json) {
1270
+ export function ingest_json_drop(bytes) {
458
1271
  let deferred3_0;
459
1272
  let deferred3_1;
460
1273
  try {
461
- const ptr0 = passStringToWasm0(network_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1274
+ const ptr0 = passArray8ToWasm0(bytes, wasm.__wbindgen_malloc);
462
1275
  const len0 = WASM_VECTOR_LEN;
463
- const ret = wasm.extract_geo(ptr0, len0);
1276
+ const ret = wasm.ingest_json_drop(ptr0, len0);
464
1277
  var ptr2 = ret[0];
465
1278
  var len2 = ret[1];
466
1279
  if (ret[3]) {
@@ -476,19 +1289,37 @@ export function extract_geo(network_json) {
476
1289
  }
477
1290
 
478
1291
  /**
479
- * Everything the drop panel needs from one parse: counts, total load and
480
- * capacity, parse warnings, and a `view` of buses and branches in the shape
481
- * the tellegen API serves, placed at the coordinates the file carries
482
- * (PowerWorld complete case aux exports). `view` is null when the file has no
483
- * coordinates.
1292
+ * Engine heap accounting: live and peak bytes held by the WASM allocator
1293
+ * (peak since the last reset) and the size of linear memory, which only
1294
+ * grows. Native builds report zeros.
1295
+ * @returns {string}
1296
+ */
1297
+ export function memory_stats() {
1298
+ let deferred1_0;
1299
+ let deferred1_1;
1300
+ try {
1301
+ const ret = wasm.memory_stats();
1302
+ deferred1_0 = ret[0];
1303
+ deferred1_1 = ret[1];
1304
+ return getStringFromWasm0(ret[0], ret[1]);
1305
+ } finally {
1306
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
1307
+ }
1308
+ }
1309
+
1310
+ /**
1311
+ * Parse a case file (MATPOWER, PSS/E RAW, PowerWorld aux, PowerModels or
1312
+ * egret JSON) and return `{"network": ..., "diagnostics": [...]}` as JSON.
484
1313
  *
485
- * Takes the dropped file's bytes, as [`parse_case`] does and for the same
486
- * reason.
1314
+ * Takes the upload's bytes, not decoded text: powerio refuses a text format
1315
+ * whose bytes are not UTF-8, where a browser side `File.text()` would have
1316
+ * replaced each offending byte with U+FFFD and parsed on. It also reaches
1317
+ * PowerWorld `.pwb`, which has no text form at all.
487
1318
  * @param {Uint8Array} bytes
488
1319
  * @param {string} format
489
1320
  * @returns {string}
490
1321
  */
491
- export function ingest_case(bytes, format) {
1322
+ export function parse_case(bytes, format) {
492
1323
  let deferred4_0;
493
1324
  let deferred4_1;
494
1325
  try {
@@ -496,46 +1327,134 @@ export function ingest_case(bytes, format) {
496
1327
  const len0 = WASM_VECTOR_LEN;
497
1328
  const ptr1 = passStringToWasm0(format, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
498
1329
  const len1 = WASM_VECTOR_LEN;
499
- const ret = wasm.ingest_case(ptr0, len0, ptr1, len1);
1330
+ const ret = wasm.parse_case(ptr0, len0, ptr1, len1);
1331
+ var ptr3 = ret[0];
1332
+ var len3 = ret[1];
1333
+ if (ret[3]) {
1334
+ ptr3 = 0; len3 = 0;
1335
+ throw takeFromExternrefTable0(ret[2]);
1336
+ }
1337
+ deferred4_0 = ptr3;
1338
+ deferred4_1 = len3;
1339
+ return getStringFromWasm0(ptr3, len3);
1340
+ } finally {
1341
+ wasm.__wbindgen_free(deferred4_0, deferred4_1, 1);
1342
+ }
1343
+ }
1344
+
1345
+ /**
1346
+ * Decode a PowerWorld drawing as a canonical PowerIO GeoLayer in diagram units.
1347
+ * @param {Uint8Array} bytes
1348
+ * @param {string} format
1349
+ * @returns {string}
1350
+ */
1351
+ export function parse_display(bytes, format) {
1352
+ let deferred4_0;
1353
+ let deferred4_1;
1354
+ try {
1355
+ const ptr0 = passArray8ToWasm0(bytes, wasm.__wbindgen_malloc);
1356
+ const len0 = WASM_VECTOR_LEN;
1357
+ const ptr1 = passStringToWasm0(format, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1358
+ const len1 = WASM_VECTOR_LEN;
1359
+ const ret = wasm.parse_display(ptr0, len0, ptr1, len1);
1360
+ var ptr3 = ret[0];
1361
+ var len3 = ret[1];
1362
+ if (ret[3]) {
1363
+ ptr3 = 0; len3 = 0;
1364
+ throw takeFromExternrefTable0(ret[2]);
1365
+ }
1366
+ deferred4_0 = ptr3;
1367
+ deferred4_1 = len3;
1368
+ return getStringFromWasm0(ptr3, len3);
1369
+ } finally {
1370
+ wasm.__wbindgen_free(deferred4_0, deferred4_1, 1);
1371
+ }
1372
+ }
1373
+
1374
+ /**
1375
+ * Parse a geographic sidecar (buscoords CSV, aliased CSV/JSON records,
1376
+ * GeoJSON) from raw dropped bytes; `hint` is the file name ("" to sniff).
1377
+ * Returns `{ layer, diagnostics, n_points, n_routes }` — the layer as its
1378
+ * canonical `.geo.json` document, ready for [`apply_geo`]. Untrusted input
1379
+ * rejects as a `JsError`, never a panic.
1380
+ * @param {Uint8Array} bytes
1381
+ * @param {string} hint
1382
+ * @returns {string}
1383
+ */
1384
+ export function parse_geo(bytes, hint) {
1385
+ let deferred4_0;
1386
+ let deferred4_1;
1387
+ try {
1388
+ const ptr0 = passArray8ToWasm0(bytes, wasm.__wbindgen_malloc);
1389
+ const len0 = WASM_VECTOR_LEN;
1390
+ const ptr1 = passStringToWasm0(hint, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1391
+ const len1 = WASM_VECTOR_LEN;
1392
+ const ret = wasm.parse_geo(ptr0, len0, ptr1, len1);
500
1393
  var ptr3 = ret[0];
501
1394
  var len3 = ret[1];
502
1395
  if (ret[3]) {
503
1396
  ptr3 = 0; len3 = 0;
504
1397
  throw takeFromExternrefTable0(ret[2]);
505
1398
  }
506
- deferred4_0 = ptr3;
507
- deferred4_1 = len3;
508
- return getStringFromWasm0(ptr3, len3);
1399
+ deferred4_0 = ptr3;
1400
+ deferred4_1 = len3;
1401
+ return getStringFromWasm0(ptr3, len3);
1402
+ } finally {
1403
+ wasm.__wbindgen_free(deferred4_0, deferred4_1, 1);
1404
+ }
1405
+ }
1406
+
1407
+ /**
1408
+ * Validate and canonicalize a saved multiconductor Study snapshot without
1409
+ * re-solving it.
1410
+ * @param {string} snapshot_json
1411
+ * @returns {string}
1412
+ */
1413
+ export function replay_mc_study(snapshot_json) {
1414
+ let deferred3_0;
1415
+ let deferred3_1;
1416
+ try {
1417
+ const ptr0 = passStringToWasm0(snapshot_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1418
+ const len0 = WASM_VECTOR_LEN;
1419
+ const ret = wasm.replay_mc_study(ptr0, len0);
1420
+ var ptr2 = ret[0];
1421
+ var len2 = ret[1];
1422
+ if (ret[3]) {
1423
+ ptr2 = 0; len2 = 0;
1424
+ throw takeFromExternrefTable0(ret[2]);
1425
+ }
1426
+ deferred3_0 = ptr2;
1427
+ deferred3_1 = len2;
1428
+ return getStringFromWasm0(ptr2, len2);
509
1429
  } finally {
510
- wasm.__wbindgen_free(deferred4_0, deferred4_1, 1);
1430
+ wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
511
1431
  }
512
1432
  }
513
1433
 
514
1434
  /**
515
- * The distribution counterpart of [`ingest_case`]: view a multiconductor case
516
- * with no solve. `format` is a distribution reader token (`dss`, `bmopf`,
517
- * `pmd`) parsed by [`powerio_dist`], or `pio` for a `.pio.json` package
518
- * carrying a multiconductor payload. Returns the drop-panel payload JSON:
519
- * name, element counts, connected load/generation (kW), parse warnings,
520
- * coordinate provenance, and the bus/terminal graph the frontend renders (see
521
- * [`dist`]).
522
- *
523
- * Untrusted input: the parse and package restore return error strings (mapped
524
- * to `JsError` here), so a malformed, truncated, or oversized `.dss`/JSON
525
- * rejects cleanly and never panics the wasm instance.
1435
+ * Start a new peak-heap window at the current live size.
1436
+ */
1437
+ export function reset_peak_memory() {
1438
+ wasm.reset_peak_memory();
1439
+ }
1440
+
1441
+ /**
1442
+ * Solve a raw BMOPF multiconductor constant-power case. The parser and
1443
+ * fixed-point implementation remain in the engine crate; this export only
1444
+ * performs the bounded text/JSON conversion at the browser boundary.
526
1445
  * @param {string} text
527
- * @param {string} format
1446
+ * @param {string} options_json
528
1447
  * @returns {string}
529
1448
  */
530
- export function ingest_dist_case(text, format) {
1449
+ export function solve_mc_bmopf(text, options_json) {
531
1450
  let deferred4_0;
532
1451
  let deferred4_1;
533
1452
  try {
534
1453
  const ptr0 = passStringToWasm0(text, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
535
1454
  const len0 = WASM_VECTOR_LEN;
536
- const ptr1 = passStringToWasm0(format, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1455
+ const ptr1 = passStringToWasm0(options_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
537
1456
  const len1 = WASM_VECTOR_LEN;
538
- const ret = wasm.ingest_dist_case(ptr0, len0, ptr1, len1);
1457
+ const ret = wasm.solve_mc_bmopf(ptr0, len0, ptr1, len1);
539
1458
  var ptr3 = ret[0];
540
1459
  var len3 = ret[1];
541
1460
  if (ret[3]) {
@@ -551,20 +1470,21 @@ export function ingest_dist_case(text, format) {
551
1470
  }
552
1471
 
553
1472
  /**
554
- * Byte counterpart of [`ingest_dist_case`] for dropped files.
555
- * @param {Uint8Array} bytes
556
- * @param {string} format
1473
+ * Solve a stored PowerIO multiconductor module. This accepts the portable
1474
+ * module form used by browser persistence in addition to raw BMOPF text.
1475
+ * @param {string} module_json
1476
+ * @param {string} options_json
557
1477
  * @returns {string}
558
1478
  */
559
- export function ingest_dist_case_bytes(bytes, format) {
1479
+ export function solve_mc_module(module_json, options_json) {
560
1480
  let deferred4_0;
561
1481
  let deferred4_1;
562
1482
  try {
563
- const ptr0 = passArray8ToWasm0(bytes, wasm.__wbindgen_malloc);
1483
+ const ptr0 = passStringToWasm0(module_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
564
1484
  const len0 = WASM_VECTOR_LEN;
565
- const ptr1 = passStringToWasm0(format, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1485
+ const ptr1 = passStringToWasm0(options_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
566
1486
  const len1 = WASM_VECTOR_LEN;
567
- const ret = wasm.ingest_dist_case_bytes(ptr0, len0, ptr1, len1);
1487
+ const ret = wasm.solve_mc_module(ptr0, len0, ptr1, len1);
568
1488
  var ptr3 = ret[0];
569
1489
  var len3 = ret[1];
570
1490
  if (ret[3]) {
@@ -580,106 +1500,85 @@ export function ingest_dist_case_bytes(bytes, format) {
580
1500
  }
581
1501
 
582
1502
  /**
583
- * Classify and ingest one dropped JSON byte buffer. Known inputs return their
584
- * render-ready payload; ambiguous and unknown documents return a null payload
585
- * so the caller can request an explicit format without decoding the bytes a
586
- * second time. Package envelopes are decoded once and the parsed package is
587
- * passed directly to the appropriate restore path.
588
- * @param {Uint8Array} bytes
589
- * @returns {string}
590
- */
591
- export function ingest_json_drop(bytes) {
592
- let deferred3_0;
593
- let deferred3_1;
594
- try {
595
- const ptr0 = passArray8ToWasm0(bytes, wasm.__wbindgen_malloc);
596
- const len0 = WASM_VECTOR_LEN;
597
- const ret = wasm.ingest_json_drop(ptr0, len0);
598
- var ptr2 = ret[0];
599
- var len2 = ret[1];
600
- if (ret[3]) {
601
- ptr2 = 0; len2 = 0;
602
- throw takeFromExternrefTable0(ret[2]);
603
- }
604
- deferred3_0 = ptr2;
605
- deferred3_1 = len2;
606
- return getStringFromWasm0(ptr2, len2);
607
- } finally {
608
- wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
609
- }
610
- }
611
-
612
- /**
613
- * [`ingest_case`] for powerio's own model JSON, the document `export_study`
614
- * writes under the `model-json` token and powerio classifies as
615
- * `JsonClass::ModelJson`. It is not a case format, so it reaches
616
- * `BalancedNetwork::from_json` rather than a case reader, and there are no
617
- * reader warnings to carry: nothing was converted.
618
- * @param {string} network_json
1503
+ * Solve a supported multiconductor Study input and return a self-contained,
1504
+ * replayable snapshot containing the typed input, PowerIO solution module, and
1505
+ * terminal-aware result view.
1506
+ * @param {string} module_json
1507
+ * @param {string} study_id
1508
+ * @param {string} study_title
1509
+ * @param {string} options_json
619
1510
  * @returns {string}
620
1511
  */
621
- export function ingest_model_json(network_json) {
622
- let deferred3_0;
623
- let deferred3_1;
1512
+ export function solve_mc_study(module_json, study_id, study_title, options_json) {
1513
+ let deferred6_0;
1514
+ let deferred6_1;
624
1515
  try {
625
- const ptr0 = passStringToWasm0(network_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1516
+ const ptr0 = passStringToWasm0(module_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
626
1517
  const len0 = WASM_VECTOR_LEN;
627
- const ret = wasm.ingest_model_json(ptr0, len0);
628
- var ptr2 = ret[0];
629
- var len2 = ret[1];
1518
+ const ptr1 = passStringToWasm0(study_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1519
+ const len1 = WASM_VECTOR_LEN;
1520
+ const ptr2 = passStringToWasm0(study_title, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1521
+ const len2 = WASM_VECTOR_LEN;
1522
+ const ptr3 = passStringToWasm0(options_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1523
+ const len3 = WASM_VECTOR_LEN;
1524
+ const ret = wasm.solve_mc_study(ptr0, len0, ptr1, len1, ptr2, len2, ptr3, len3);
1525
+ var ptr5 = ret[0];
1526
+ var len5 = ret[1];
630
1527
  if (ret[3]) {
631
- ptr2 = 0; len2 = 0;
1528
+ ptr5 = 0; len5 = 0;
632
1529
  throw takeFromExternrefTable0(ret[2]);
633
1530
  }
634
- deferred3_0 = ptr2;
635
- deferred3_1 = len2;
636
- return getStringFromWasm0(ptr2, len2);
1531
+ deferred6_0 = ptr5;
1532
+ deferred6_1 = len5;
1533
+ return getStringFromWasm0(ptr5, len5);
637
1534
  } finally {
638
- wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
1535
+ wasm.__wbindgen_free(deferred6_0, deferred6_1, 1);
639
1536
  }
640
1537
  }
641
1538
 
642
1539
  /**
643
- * Byte counterpart of [`ingest_model_json`] for dropped files. UTF-8 decoding
644
- * and model validation both stay in powerio.
645
- * @param {Uint8Array} bytes
1540
+ * The stateless solve front door: a retained PowerIO module and a
1541
+ * [`tellegen::SolveRequest`] JSON in, a [`tellegen::SolveResponse`] JSON out. One-shot callers only;
1542
+ * the reactive hot path is the [`Study`].
1543
+ * @param {string} module_json
1544
+ * @param {string} request_json
646
1545
  * @returns {string}
647
1546
  */
648
- export function ingest_model_json_bytes(bytes) {
649
- let deferred3_0;
650
- let deferred3_1;
1547
+ export function solve_module(module_json, request_json) {
1548
+ let deferred4_0;
1549
+ let deferred4_1;
651
1550
  try {
652
- const ptr0 = passArray8ToWasm0(bytes, wasm.__wbindgen_malloc);
1551
+ const ptr0 = passStringToWasm0(module_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
653
1552
  const len0 = WASM_VECTOR_LEN;
654
- const ret = wasm.ingest_model_json_bytes(ptr0, len0);
655
- var ptr2 = ret[0];
656
- var len2 = ret[1];
1553
+ const ptr1 = passStringToWasm0(request_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1554
+ const len1 = WASM_VECTOR_LEN;
1555
+ const ret = wasm.solve_module(ptr0, len0, ptr1, len1);
1556
+ var ptr3 = ret[0];
1557
+ var len3 = ret[1];
657
1558
  if (ret[3]) {
658
- ptr2 = 0; len2 = 0;
1559
+ ptr3 = 0; len3 = 0;
659
1560
  throw takeFromExternrefTable0(ret[2]);
660
1561
  }
661
- deferred3_0 = ptr2;
662
- deferred3_1 = len2;
663
- return getStringFromWasm0(ptr2, len2);
1562
+ deferred4_0 = ptr3;
1563
+ deferred4_1 = len3;
1564
+ return getStringFromWasm0(ptr3, len3);
664
1565
  } finally {
665
- wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
1566
+ wasm.__wbindgen_free(deferred4_0, deferred4_1, 1);
666
1567
  }
667
1568
  }
668
1569
 
669
1570
  /**
670
- * Restore a study saved by [`Study::save_package`]. Returns a JSON bundle the frontend
671
- * reads to rebuild its case, edit sliders, formulation, and solve options in one step.
672
- * See [`load_package_bundle`] for the shape and the fail-closed contract.
673
- * @param {string} package_json
1571
+ * Create a portable application Study through the shared native controller.
1572
+ * @param {string} request_json
674
1573
  * @returns {string}
675
1574
  */
676
- export function load_package(package_json) {
1575
+ export function study_document_create(request_json) {
677
1576
  let deferred3_0;
678
1577
  let deferred3_1;
679
1578
  try {
680
- const ptr0 = passStringToWasm0(package_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1579
+ const ptr0 = passStringToWasm0(request_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
681
1580
  const len0 = WASM_VECTOR_LEN;
682
- const ret = wasm.load_package(ptr0, len0);
1581
+ const ret = wasm.study_document_create(ptr0, len0);
683
1582
  var ptr2 = ret[0];
684
1583
  var len2 = ret[1];
685
1584
  if (ret[3]) {
@@ -695,17 +1594,17 @@ export function load_package(package_json) {
695
1594
  }
696
1595
 
697
1596
  /**
698
- * Byte counterpart of [`load_package`] for a dropped package.
699
- * @param {Uint8Array} bytes
1597
+ * Validate and normalize a portable bundle without executing its contents.
1598
+ * @param {string} bundle_json
700
1599
  * @returns {string}
701
1600
  */
702
- export function load_package_bytes(bytes) {
1601
+ export function study_document_import(bundle_json) {
703
1602
  let deferred3_0;
704
1603
  let deferred3_1;
705
1604
  try {
706
- const ptr0 = passArray8ToWasm0(bytes, wasm.__wbindgen_malloc);
1605
+ const ptr0 = passStringToWasm0(bundle_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
707
1606
  const len0 = WASM_VECTOR_LEN;
708
- const ret = wasm.load_package_bytes(ptr0, len0);
1607
+ const ret = wasm.study_document_import(ptr0, len0);
709
1608
  var ptr2 = ret[0];
710
1609
  var len2 = ret[1];
711
1610
  if (ret[3]) {
@@ -721,60 +1620,36 @@ export function load_package_bytes(bytes) {
721
1620
  }
722
1621
 
723
1622
  /**
724
- * Parse a case file (MATPOWER, PSS/E RAW, PowerWorld aux, PowerModels or
725
- * egret JSON) and return `{"network": ..., "warnings": [...]}` as JSON.
726
- *
727
- * Takes the upload's bytes, not decoded text: `powerio::parse_bytes` refuses a
728
- * text format whose bytes are not UTF-8, where a browser side `File.text()`
729
- * would have replaced each offending byte with U+FFFD and parsed on. It also
730
- * reaches PowerWorld `.pwb`, which has no text form at all.
731
- * @param {Uint8Array} bytes
732
- * @param {string} format
733
- * @returns {string}
1623
+ * Execute a revision-checked Study operation and return the completed bundle.
1624
+ * @param {string} bundle_json
1625
+ * @param {string} request_json
1626
+ * @param {Function} cancelled
1627
+ * @returns {Promise<string>}
734
1628
  */
735
- export function parse_case(bytes, format) {
736
- let deferred4_0;
737
- let deferred4_1;
738
- try {
739
- const ptr0 = passArray8ToWasm0(bytes, wasm.__wbindgen_malloc);
740
- const len0 = WASM_VECTOR_LEN;
741
- const ptr1 = passStringToWasm0(format, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
742
- const len1 = WASM_VECTOR_LEN;
743
- const ret = wasm.parse_case(ptr0, len0, ptr1, len1);
744
- var ptr3 = ret[0];
745
- var len3 = ret[1];
746
- if (ret[3]) {
747
- ptr3 = 0; len3 = 0;
748
- throw takeFromExternrefTable0(ret[2]);
749
- }
750
- deferred4_0 = ptr3;
751
- deferred4_1 = len3;
752
- return getStringFromWasm0(ptr3, len3);
753
- } finally {
754
- wasm.__wbindgen_free(deferred4_0, deferred4_1, 1);
755
- }
1629
+ export function study_document_run(bundle_json, request_json, cancelled) {
1630
+ const ptr0 = passStringToWasm0(bundle_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1631
+ const len0 = WASM_VECTOR_LEN;
1632
+ const ptr1 = passStringToWasm0(request_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1633
+ const len1 = WASM_VECTOR_LEN;
1634
+ const ret = wasm.study_document_run(ptr0, len0, ptr1, len1, cancelled);
1635
+ return ret;
756
1636
  }
757
1637
 
758
1638
  /**
759
- * Decode a PowerWorld `.pwd` display file (binary). Returns the substation
760
- * symbols at the diagram coordinates the file stores (x east, y north) plus
761
- * the canvas size, each with the approximate `lon`/`lat` projection
762
- * (`pwd_mercator_to_lonlat`; hand edited diagrams drift from it). A `.pwd`
763
- * carries no buses or branches. `format` is "pwd". Pure in-memory parsing,
764
- * no filesystem, so it runs in the browser.
765
- * @param {Uint8Array} bytes
766
- * @param {string} format
1639
+ * Run every stage of a synthetic generation: `{module_json, report, ingest}`.
1640
+ * @param {string} request_json
1641
+ * @param {string | null} [osm_json]
767
1642
  * @returns {string}
768
1643
  */
769
- export function parse_display(bytes, format) {
1644
+ export function synth_generate(request_json, osm_json) {
770
1645
  let deferred4_0;
771
1646
  let deferred4_1;
772
1647
  try {
773
- const ptr0 = passArray8ToWasm0(bytes, wasm.__wbindgen_malloc);
1648
+ const ptr0 = passStringToWasm0(request_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
774
1649
  const len0 = WASM_VECTOR_LEN;
775
- const ptr1 = passStringToWasm0(format, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
776
- const len1 = WASM_VECTOR_LEN;
777
- const ret = wasm.parse_display(ptr0, len0, ptr1, len1);
1650
+ var ptr1 = isLikeNone(osm_json) ? 0 : passStringToWasm0(osm_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1651
+ var len1 = WASM_VECTOR_LEN;
1652
+ const ret = wasm.synth_generate(ptr0, len0, ptr1, len1);
778
1653
  var ptr3 = ret[0];
779
1654
  var len3 = ret[1];
780
1655
  if (ret[3]) {
@@ -790,83 +1665,94 @@ export function parse_display(bytes, format) {
790
1665
  }
791
1666
 
792
1667
  /**
793
- * Parse a geographic sidecar (buscoords CSV, aliased CSV/JSON records,
794
- * GeoJSON) from raw dropped bytes; `hint` is the file name ("" to sniff).
795
- * Returns `{ layer, warnings, n_points, n_routes }` — the layer as its
796
- * canonical `.geo.json` document, ready for [`apply_geo`]. Untrusted input
797
- * rejects as a `JsError`, never a panic.
1668
+ * Load the populated places table every synthetic session of this instance
1669
+ * reads (the engine package's `data/populated_places.json`, or any table of
1670
+ * `{n, lo, la, p, c}` rows). Returns `{count, sha256}`.
798
1671
  * @param {Uint8Array} bytes
799
- * @param {string} hint
800
1672
  * @returns {string}
801
1673
  */
802
- export function parse_geo(bytes, hint) {
803
- let deferred4_0;
804
- let deferred4_1;
1674
+ export function synth_load_places(bytes) {
1675
+ let deferred3_0;
1676
+ let deferred3_1;
805
1677
  try {
806
1678
  const ptr0 = passArray8ToWasm0(bytes, wasm.__wbindgen_malloc);
807
1679
  const len0 = WASM_VECTOR_LEN;
808
- const ptr1 = passStringToWasm0(hint, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
809
- const len1 = WASM_VECTOR_LEN;
810
- const ret = wasm.parse_geo(ptr0, len0, ptr1, len1);
811
- var ptr3 = ret[0];
812
- var len3 = ret[1];
1680
+ const ret = wasm.synth_load_places(ptr0, len0);
1681
+ var ptr2 = ret[0];
1682
+ var len2 = ret[1];
813
1683
  if (ret[3]) {
814
- ptr3 = 0; len3 = 0;
1684
+ ptr2 = 0; len2 = 0;
815
1685
  throw takeFromExternrefTable0(ret[2]);
816
1686
  }
817
- deferred4_0 = ptr3;
818
- deferred4_1 = len3;
819
- return getStringFromWasm0(ptr3, len3);
1687
+ deferred3_0 = ptr2;
1688
+ deferred3_1 = len2;
1689
+ return getStringFromWasm0(ptr2, len2);
820
1690
  } finally {
821
- wasm.__wbindgen_free(deferred4_0, deferred4_1, 1);
1691
+ wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
822
1692
  }
823
1693
  }
824
1694
 
825
1695
  /**
826
- * The stateless solve front door: a [`SolveRequest`](tellegen::SolveRequest) JSON
827
- * in, a [`SolveResponse`](tellegen::SolveResponse) JSON out. One-shot callers only;
828
- * the reactive hot path is the [`Study`].
829
- * @param {string} network_json
1696
+ * The Overpass QL queries for a synthetic request's region: a JSON array, two
1697
+ * entries when the region crosses the antimeridian.
830
1698
  * @param {string} request_json
831
1699
  * @returns {string}
832
1700
  */
833
- export function solve_json(network_json, request_json) {
834
- let deferred4_0;
835
- let deferred4_1;
1701
+ export function synth_overpass_queries(request_json) {
1702
+ let deferred3_0;
1703
+ let deferred3_1;
836
1704
  try {
837
- const ptr0 = passStringToWasm0(network_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1705
+ const ptr0 = passStringToWasm0(request_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
838
1706
  const len0 = WASM_VECTOR_LEN;
839
- const ptr1 = passStringToWasm0(request_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
840
- const len1 = WASM_VECTOR_LEN;
841
- const ret = wasm.solve_json(ptr0, len0, ptr1, len1);
842
- var ptr3 = ret[0];
843
- var len3 = ret[1];
1707
+ const ret = wasm.synth_overpass_queries(ptr0, len0);
1708
+ var ptr2 = ret[0];
1709
+ var len2 = ret[1];
844
1710
  if (ret[3]) {
845
- ptr3 = 0; len3 = 0;
1711
+ ptr2 = 0; len2 = 0;
846
1712
  throw takeFromExternrefTable0(ret[2]);
847
1713
  }
848
- deferred4_0 = ptr3;
849
- deferred4_1 = len3;
850
- return getStringFromWasm0(ptr3, len3);
1714
+ deferred3_0 = ptr2;
1715
+ deferred3_1 = len2;
1716
+ return getStringFromWasm0(ptr2, len2);
851
1717
  } finally {
852
- wasm.__wbindgen_free(deferred4_0, deferred4_1, 1);
1718
+ wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
853
1719
  }
854
1720
  }
855
1721
  function __wbg_get_imports() {
856
1722
  const import0 = {
857
1723
  __proto__: null,
858
- __wbg_Error_fdd633d4bb5dd76a: function(arg0, arg1) {
1724
+ __wbg_Error_30c8987f7c2ed4e2: function(arg0, arg1) {
859
1725
  const ret = Error(getStringFromWasm0(arg0, arg1));
860
1726
  return ret;
861
1727
  },
862
- __wbg___wbindgen_is_undefined_721f8decd50c87a3: function(arg0) {
1728
+ __wbg___wbindgen_boolean_get_5b446f51afd21013: function(arg0) {
1729
+ const v = arg0;
1730
+ const ret = typeof(v) === 'boolean' ? v : undefined;
1731
+ return isLikeNone(ret) ? 0xFFFFFF : ret ? 1 : 0;
1732
+ },
1733
+ __wbg___wbindgen_is_function_1f9d30630b8b1d3d: function(arg0) {
1734
+ const ret = typeof(arg0) === 'function';
1735
+ return ret;
1736
+ },
1737
+ __wbg___wbindgen_is_undefined_8865fb403f8fe9d8: function(arg0) {
863
1738
  const ret = arg0 === undefined;
864
1739
  return ret;
865
1740
  },
866
- __wbg___wbindgen_throw_ea4887a5f8f9a9db: function(arg0, arg1) {
1741
+ __wbg___wbindgen_throw_41e9ee4f547fc59a: function(arg0, arg1) {
867
1742
  throw new Error(getStringFromWasm0(arg0, arg1));
868
1743
  },
869
- __wbg_error_a6fa202b58aa1cd3: function(arg0, arg1) {
1744
+ __wbg__wbg_cb_unref_dcc1a90847f04c41: function(arg0) {
1745
+ arg0._wbg_cb_unref();
1746
+ },
1747
+ __wbg_call_187d372bd5fdd4aa: function() { return handleError(function (arg0, arg1, arg2) {
1748
+ const ret = arg0.call(arg1, arg2);
1749
+ return ret;
1750
+ }, arguments); },
1751
+ __wbg_call_6137034ef55c9d0f: function() { return handleError(function (arg0, arg1) {
1752
+ const ret = arg0.call(arg1);
1753
+ return ret;
1754
+ }, arguments); },
1755
+ __wbg_error_757e9472f8410341: function(arg0, arg1) {
870
1756
  let deferred0_0;
871
1757
  let deferred0_1;
872
1758
  try {
@@ -881,6 +1767,50 @@ function __wbg_get_imports() {
881
1767
  const ret = new Error();
882
1768
  return ret;
883
1769
  },
1770
+ __wbg_new_5502aad30c185fc8: function(arg0, arg1) {
1771
+ try {
1772
+ var state0 = {a: arg0, b: arg1};
1773
+ var cb0 = (arg0, arg1) => {
1774
+ const a = state0.a;
1775
+ state0.a = 0;
1776
+ try {
1777
+ return wasm_bindgen__convert__closures_____invoke__h67ba427e9454f1d8(a, state0.b, arg0, arg1);
1778
+ } finally {
1779
+ state0.a = a;
1780
+ }
1781
+ };
1782
+ const ret = new Promise(cb0);
1783
+ return ret;
1784
+ } finally {
1785
+ state0.a = 0;
1786
+ }
1787
+ },
1788
+ __wbg_new_typed_b01cb72a8af741a3: function(arg0, arg1) {
1789
+ try {
1790
+ var state0 = {a: arg0, b: arg1};
1791
+ var cb0 = (arg0, arg1) => {
1792
+ const a = state0.a;
1793
+ state0.a = 0;
1794
+ try {
1795
+ return wasm_bindgen__convert__closures_____invoke__h67ba427e9454f1d8(a, state0.b, arg0, arg1);
1796
+ } finally {
1797
+ state0.a = a;
1798
+ }
1799
+ };
1800
+ const ret = new Promise(cb0);
1801
+ return ret;
1802
+ } finally {
1803
+ state0.a = 0;
1804
+ }
1805
+ },
1806
+ __wbg_now_8a594da121f77701: function() {
1807
+ const ret = performance.now();
1808
+ return ret;
1809
+ },
1810
+ __wbg_now_aa4ccb83129e9e55: function() {
1811
+ const ret = Date.now();
1812
+ return ret;
1813
+ },
884
1814
  __wbg_now_cace042f68c814d8: function(arg0) {
885
1815
  const ret = arg0.now();
886
1816
  return ret;
@@ -889,6 +1819,20 @@ function __wbg_get_imports() {
889
1819
  const ret = arg0.performance;
890
1820
  return ret;
891
1821
  },
1822
+ __wbg_queueMicrotask_9833f9a49df95a49: function(arg0) {
1823
+ const ret = arg0.queueMicrotask;
1824
+ return ret;
1825
+ },
1826
+ __wbg_queueMicrotask_a72f977e97f23c5f: function(arg0) {
1827
+ queueMicrotask(arg0);
1828
+ },
1829
+ __wbg_resolve_0076e10020304ede: function(arg0) {
1830
+ const ret = Promise.resolve(arg0);
1831
+ return ret;
1832
+ },
1833
+ __wbg_setTimeout_b92adebff51f057a: function(arg0, arg1) {
1834
+ setTimeout(arg0, arg1);
1835
+ },
892
1836
  __wbg_stack_3b0d974bbf31e44f: function(arg0, arg1) {
893
1837
  const ret = arg1.stack;
894
1838
  const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
@@ -896,22 +1840,40 @@ function __wbg_get_imports() {
896
1840
  getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
897
1841
  getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
898
1842
  },
899
- __wbg_static_accessor_GLOBAL_THIS_2fee5048bcca5938: function() {
900
- const ret = typeof globalThis === 'undefined' ? null : globalThis;
1843
+ __wbg_static_accessor_GLOBAL_266715b9d96ba635: function() {
1844
+ const ret = typeof global === 'undefined' ? null : global;
901
1845
  return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
902
1846
  },
903
- __wbg_static_accessor_GLOBAL_ce44e66a4935da8c: function() {
904
- const ret = typeof global === 'undefined' ? null : global;
1847
+ __wbg_static_accessor_GLOBAL_THIS_10fb7dc1ae063179: function() {
1848
+ const ret = typeof globalThis === 'undefined' ? null : globalThis;
905
1849
  return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
906
1850
  },
907
- __wbg_static_accessor_SELF_44f6e0cb5e67cdad: function() {
1851
+ __wbg_static_accessor_SELF_0b583911f537483a: function() {
908
1852
  const ret = typeof self === 'undefined' ? null : self;
909
1853
  return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
910
1854
  },
911
- __wbg_static_accessor_WINDOW_168f178805d978fe: function() {
1855
+ __wbg_static_accessor_WINDOW_d7f903d1508cbdc4: function() {
912
1856
  const ret = typeof window === 'undefined' ? null : window;
913
1857
  return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
914
1858
  },
1859
+ __wbg_then_c949d5a25a4e78f8: function(arg0, arg1, arg2) {
1860
+ const ret = arg0.then(arg1, arg2);
1861
+ return ret;
1862
+ },
1863
+ __wbg_then_e71170d78fcf8954: function(arg0, arg1) {
1864
+ const ret = arg0.then(arg1);
1865
+ return ret;
1866
+ },
1867
+ __wbindgen_generic_0000000000000001: function(arg0, arg1) {
1868
+ // Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [Externref], shim_idx: 569, ret: Result(Unit), inner_ret: Some(Result(Unit)) }, mutable: true }) -> Externref`.
1869
+ const ret = makeMutClosure(arg0, arg1, wasm_bindgen__convert__closures_____invoke__h1c534e945ee6d3b6);
1870
+ return ret;
1871
+ },
1872
+ __wbindgen_generic_0000000000000002: function(arg0, arg1) {
1873
+ // Cast intrinsic for `Ref(String) -> Externref`.
1874
+ const ret = getStringFromWasm0(arg0, arg1);
1875
+ return ret;
1876
+ },
915
1877
  __wbindgen_init_externref_table: function() {
916
1878
  const table = wasm.__wbindgen_externrefs;
917
1879
  const offset = table.grow(4);
@@ -928,9 +1890,29 @@ function __wbg_get_imports() {
928
1890
  };
929
1891
  }
930
1892
 
1893
+ function wasm_bindgen__convert__closures_____invoke__h1c534e945ee6d3b6(arg0, arg1, arg2) {
1894
+ const ret = wasm.wasm_bindgen__convert__closures_____invoke__h1c534e945ee6d3b6(arg0, arg1, arg2);
1895
+ if (ret[1]) {
1896
+ throw takeFromExternrefTable0(ret[0]);
1897
+ }
1898
+ }
1899
+
1900
+ function wasm_bindgen__convert__closures_____invoke__h67ba427e9454f1d8(arg0, arg1, arg2, arg3) {
1901
+ wasm.wasm_bindgen__convert__closures_____invoke__h67ba427e9454f1d8(arg0, arg1, arg2, arg3);
1902
+ }
1903
+
1904
+ const McPfSessionFinalization = (typeof FinalizationRegistry === 'undefined')
1905
+ ? { register: () => {}, unregister: () => {} }
1906
+ : new FinalizationRegistry(ptr => wasm.__wbg_mcpfsession_free(ptr, 1));
931
1907
  const StudyFinalization = (typeof FinalizationRegistry === 'undefined')
932
1908
  ? { register: () => {}, unregister: () => {} }
933
1909
  : new FinalizationRegistry(ptr => wasm.__wbg_study_free(ptr, 1));
1910
+ const SynthPreviewBuffersFinalization = (typeof FinalizationRegistry === 'undefined')
1911
+ ? { register: () => {}, unregister: () => {} }
1912
+ : new FinalizationRegistry(ptr => wasm.__wbg_synthpreviewbuffers_free(ptr, 1));
1913
+ const SynthSessionFinalization = (typeof FinalizationRegistry === 'undefined')
1914
+ ? { register: () => {}, unregister: () => {} }
1915
+ : new FinalizationRegistry(ptr => wasm.__wbg_synthsession_free(ptr, 1));
934
1916
 
935
1917
  function addToExternrefTable0(obj) {
936
1918
  const idx = wasm.__externref_table_alloc();
@@ -938,6 +1920,30 @@ function addToExternrefTable0(obj) {
938
1920
  return idx;
939
1921
  }
940
1922
 
1923
+ const CLOSURE_DTORS = (typeof FinalizationRegistry === 'undefined')
1924
+ ? { register: () => {}, unregister: () => {} }
1925
+ : new FinalizationRegistry(state => wasm.__wbindgen_destroy_closure(state.a, state.b));
1926
+
1927
+ function getArrayF32FromWasm0(ptr, len) {
1928
+ ptr = ptr >>> 0;
1929
+ return getFloat32ArrayMemory0().subarray(ptr / 4, ptr / 4 + len);
1930
+ }
1931
+
1932
+ function getArrayF64FromWasm0(ptr, len) {
1933
+ ptr = ptr >>> 0;
1934
+ return getFloat64ArrayMemory0().subarray(ptr / 8, ptr / 8 + len);
1935
+ }
1936
+
1937
+ function getArrayU32FromWasm0(ptr, len) {
1938
+ ptr = ptr >>> 0;
1939
+ return getUint32ArrayMemory0().subarray(ptr / 4, ptr / 4 + len);
1940
+ }
1941
+
1942
+ function getArrayU8FromWasm0(ptr, len) {
1943
+ ptr = ptr >>> 0;
1944
+ return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
1945
+ }
1946
+
941
1947
  let cachedDataViewMemory0 = null;
942
1948
  function getDataViewMemory0() {
943
1949
  if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || (cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm.memory.buffer)) {
@@ -946,10 +1952,34 @@ function getDataViewMemory0() {
946
1952
  return cachedDataViewMemory0;
947
1953
  }
948
1954
 
1955
+ let cachedFloat32ArrayMemory0 = null;
1956
+ function getFloat32ArrayMemory0() {
1957
+ if (cachedFloat32ArrayMemory0 === null || cachedFloat32ArrayMemory0.byteLength === 0) {
1958
+ cachedFloat32ArrayMemory0 = new Float32Array(wasm.memory.buffer);
1959
+ }
1960
+ return cachedFloat32ArrayMemory0;
1961
+ }
1962
+
1963
+ let cachedFloat64ArrayMemory0 = null;
1964
+ function getFloat64ArrayMemory0() {
1965
+ if (cachedFloat64ArrayMemory0 === null || cachedFloat64ArrayMemory0.byteLength === 0) {
1966
+ cachedFloat64ArrayMemory0 = new Float64Array(wasm.memory.buffer);
1967
+ }
1968
+ return cachedFloat64ArrayMemory0;
1969
+ }
1970
+
949
1971
  function getStringFromWasm0(ptr, len) {
950
1972
  return decodeText(ptr >>> 0, len);
951
1973
  }
952
1974
 
1975
+ let cachedUint32ArrayMemory0 = null;
1976
+ function getUint32ArrayMemory0() {
1977
+ if (cachedUint32ArrayMemory0 === null || cachedUint32ArrayMemory0.byteLength === 0) {
1978
+ cachedUint32ArrayMemory0 = new Uint32Array(wasm.memory.buffer);
1979
+ }
1980
+ return cachedUint32ArrayMemory0;
1981
+ }
1982
+
953
1983
  let cachedUint8ArrayMemory0 = null;
954
1984
  function getUint8ArrayMemory0() {
955
1985
  if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
@@ -958,10 +1988,47 @@ function getUint8ArrayMemory0() {
958
1988
  return cachedUint8ArrayMemory0;
959
1989
  }
960
1990
 
1991
+ function handleError(f, args) {
1992
+ try {
1993
+ return f.apply(this, args);
1994
+ } catch (e) {
1995
+ const idx = addToExternrefTable0(e);
1996
+ wasm.__wbindgen_exn_store(idx);
1997
+ }
1998
+ }
1999
+
961
2000
  function isLikeNone(x) {
962
2001
  return x === undefined || x === null;
963
2002
  }
964
2003
 
2004
+ function makeMutClosure(arg0, arg1, f) {
2005
+ const state = { a: arg0, b: arg1, cnt: 1 };
2006
+ const real = (...args) => {
2007
+
2008
+ // First up with a closure we increment the internal reference
2009
+ // count. This ensures that the Rust closure environment won't
2010
+ // be deallocated while we're invoking it.
2011
+ state.cnt++;
2012
+ const a = state.a;
2013
+ state.a = 0;
2014
+ try {
2015
+ return f(a, state.b, ...args);
2016
+ } finally {
2017
+ state.a = a;
2018
+ real._wbg_cb_unref();
2019
+ }
2020
+ };
2021
+ real._wbg_cb_unref = () => {
2022
+ if (--state.cnt === 0) {
2023
+ wasm.__wbindgen_destroy_closure(state.a, state.b);
2024
+ state.a = 0;
2025
+ CLOSURE_DTORS.unregister(state);
2026
+ }
2027
+ };
2028
+ CLOSURE_DTORS.register(real, state, state);
2029
+ return real;
2030
+ }
2031
+
965
2032
  function passArray8ToWasm0(arg, malloc) {
966
2033
  const ptr = malloc(arg.length * 1, 1) >>> 0;
967
2034
  getUint8ArrayMemory0().set(arg, ptr / 1);
@@ -1047,6 +2114,9 @@ function __wbg_finalize_init(instance, module) {
1047
2114
  wasm = instance.exports;
1048
2115
  wasmModule = module;
1049
2116
  cachedDataViewMemory0 = null;
2117
+ cachedFloat32ArrayMemory0 = null;
2118
+ cachedFloat64ArrayMemory0 = null;
2119
+ cachedUint32ArrayMemory0 = null;
1050
2120
  cachedUint8ArrayMemory0 = null;
1051
2121
  wasm.__wbindgen_start();
1052
2122
  return wasm;
@@ -1054,11 +2124,15 @@ function __wbg_finalize_init(instance, module) {
1054
2124
 
1055
2125
  async function __wbg_load(module, imports) {
1056
2126
  if (typeof Response === 'function' && module instanceof Response) {
2127
+ if (!module.ok) {
2128
+ throw new Error(`failed to fetch Wasm: ${module.status} ${module.statusText} fetching '${module.url}'`);
2129
+ }
2130
+
1057
2131
  if (typeof WebAssembly.instantiateStreaming === 'function') {
1058
2132
  try {
1059
2133
  return await WebAssembly.instantiateStreaming(module, imports);
1060
2134
  } catch (e) {
1061
- const validResponse = module.ok && expectedResponseType(module.type);
2135
+ const validResponse = expectedResponseType(module.type);
1062
2136
 
1063
2137
  if (validResponse && module.headers.get('Content-Type') !== 'application/wasm') {
1064
2138
  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);