@tellegen/engine 0.3.0 → 0.4.1

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 (56) hide show
  1. package/README.md +65 -5
  2. package/dist/data/populated_places.json +7351 -0
  3. package/dist/generated/{contracts.d.ts → api-types.d.ts} +4 -4
  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.map +1 -1
  8. package/dist/generated/study-schema.js +2 -2
  9. package/dist/generated/study-schema.js.map +1 -1
  10. package/dist/generated/{study-contracts.d.ts → study-types.d.ts} +1 -1
  11. package/dist/generated/study-types.d.ts.map +1 -0
  12. package/dist/generated/study-types.js +4 -0
  13. package/dist/generated/study-types.js.map +1 -0
  14. package/dist/generated/synth-schema.d.ts +2 -0
  15. package/dist/generated/synth-schema.d.ts.map +1 -0
  16. package/dist/generated/synth-schema.js +3 -0
  17. package/dist/generated/synth-schema.js.map +1 -0
  18. package/dist/generated/synth-types.d.ts +484 -0
  19. package/dist/generated/synth-types.d.ts.map +1 -0
  20. package/dist/generated/synth-types.js +4 -0
  21. package/dist/generated/synth-types.js.map +1 -0
  22. package/dist/host.d.ts +23 -2
  23. package/dist/host.d.ts.map +1 -1
  24. package/dist/host.js +60 -22
  25. package/dist/host.js.map +1 -1
  26. package/dist/index.d.ts +253 -16
  27. package/dist/index.d.ts.map +1 -1
  28. package/dist/index.js +433 -11
  29. package/dist/index.js.map +1 -1
  30. package/dist/module.d.ts +1 -0
  31. package/dist/module.d.ts.map +1 -1
  32. package/dist/module.js.map +1 -1
  33. package/dist/protocol.d.ts +97 -7
  34. package/dist/protocol.d.ts.map +1 -1
  35. package/dist/protocol.js +96 -6
  36. package/dist/protocol.js.map +1 -1
  37. package/dist/study-document.d.ts +2 -2
  38. package/dist/study-document.d.ts.map +1 -1
  39. package/dist/study-document.js +1 -1
  40. package/dist/study-document.js.map +1 -1
  41. package/dist/wasm-pkg/LICENSE +17 -4
  42. package/dist/wasm-pkg/tellegen.d.ts +171 -6
  43. package/dist/wasm-pkg/tellegen.js +627 -33
  44. package/dist/wasm-pkg/tellegen_bg.wasm +0 -0
  45. package/dist/wasm-pkg/tellegen_bg.wasm.d.ts +32 -2
  46. package/dist/worker.js +10 -7
  47. package/dist/worker.js.map +1 -1
  48. package/package.json +17 -11
  49. package/dist/generated/contracts.d.ts.map +0 -1
  50. package/dist/generated/contracts.js +0 -8
  51. package/dist/generated/contracts.js.map +0 -1
  52. package/dist/generated/study-contracts.d.ts.map +0 -1
  53. package/dist/generated/study-contracts.js +0 -4
  54. package/dist/generated/study-contracts.js.map +0 -1
  55. package/dist/wasm-pkg/LICENSE-APACHE +0 -201
  56. package/dist/wasm-pkg/LICENSE-MIT +0 -19
@@ -3,7 +3,8 @@
3
3
  /**
4
4
  * A retained fixed-point current-injection session. The prepared network,
5
5
  * sparse LU, and last converged voltage remain in this WASM object across
6
- * load edits.
6
+ * load edits. Ordinary edits return the compact summary; detailed terminal
7
+ * and equipment values are fetched on demand.
7
8
  */
8
9
  export class McPfSession {
9
10
  __destroy_into_raw() {
@@ -16,6 +17,53 @@ export class McPfSession {
16
17
  const ptr = this.__destroy_into_raw();
17
18
  wasm.__wbg_mcpfsession_free(ptr, 0);
18
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
+ }
19
67
  /**
20
68
  * Materialize the current edited input as PowerIO IR.
21
69
  * @returns {string}
@@ -60,6 +108,14 @@ export class McPfSession {
60
108
  wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
61
109
  }
62
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
+ }
63
119
  /**
64
120
  * @param {string} module_json
65
121
  * @param {string} options_json
@@ -78,8 +134,30 @@ export class McPfSession {
78
134
  return this;
79
135
  }
80
136
  /**
81
- * Replace the absolute branch-power edit state and solve with the retained
82
- * factorization and previous converged voltage.
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.
83
161
  * @param {string} edits_json
84
162
  * @returns {string}
85
163
  */
@@ -104,7 +182,8 @@ export class McPfSession {
104
182
  }
105
183
  }
106
184
  /**
107
- * The current complete solver result.
185
+ * The complete terminal and equipment result, built on demand. Its size
186
+ * grows with the network; the interactive path uses `summary`/`detail`.
108
187
  * @returns {string}
109
188
  */
110
189
  result() {
@@ -153,6 +232,71 @@ export class McPfSession {
153
232
  wasm.__wbindgen_free(deferred4_0, deferred4_1, 1);
154
233
  }
155
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
+ }
156
300
  }
157
301
  if (Symbol.dispose) McPfSession.prototype[Symbol.dispose] = McPfSession.prototype.free;
158
302
 
@@ -527,6 +671,285 @@ export class Study {
527
671
  }
528
672
  if (Symbol.dispose) Study.prototype[Symbol.dispose] = Study.prototype.free;
529
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() {
917
+ let deferred2_0;
918
+ let deferred2_1;
919
+ try {
920
+ const ret = wasm.synthsession_report(this.__wbg_ptr);
921
+ var ptr1 = ret[0];
922
+ var len1 = ret[1];
923
+ if (ret[3]) {
924
+ ptr1 = 0; len1 = 0;
925
+ throw takeFromExternrefTable0(ret[2]);
926
+ }
927
+ deferred2_0 = ptr1;
928
+ deferred2_1 = len1;
929
+ return getStringFromWasm0(ptr1, len1);
930
+ } finally {
931
+ wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
932
+ }
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
+ }
950
+ }
951
+ if (Symbol.dispose) SynthSession.prototype[Symbol.dispose] = SynthSession.prototype.free;
952
+
530
953
  /**
531
954
  * Fill case coordinates from a PowerWorld `.pwd` sibling: substation symbols
532
955
  * project to approximate longitude/latitude and join onto buses through the
@@ -865,6 +1288,25 @@ export function ingest_json_drop(bytes) {
865
1288
  }
866
1289
  }
867
1290
 
1291
+ /**
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
+
868
1310
  /**
869
1311
  * Parse a case file (MATPOWER, PSS/E RAW, PowerWorld aux, PowerModels or
870
1312
  * egret JSON) and return `{"network": ..., "diagnostics": [...]}` as JSON.
@@ -989,6 +1431,13 @@ export function replay_mc_study(snapshot_json) {
989
1431
  }
990
1432
  }
991
1433
 
1434
+ /**
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
+
992
1441
  /**
993
1442
  * Solve a raw BMOPF multiconductor constant-power case. The parser and
994
1443
  * fixed-point implementation remain in the engine crate; this export only
@@ -1185,38 +1634,122 @@ export function study_document_run(bundle_json, request_json, cancelled) {
1185
1634
  const ret = wasm.study_document_run(ptr0, len0, ptr1, len1, cancelled);
1186
1635
  return ret;
1187
1636
  }
1637
+
1638
+ /**
1639
+ * Run every stage of a synthetic generation: `{module_json, report, ingest}`.
1640
+ * @param {string} request_json
1641
+ * @param {string | null} [osm_json]
1642
+ * @returns {string}
1643
+ */
1644
+ export function synth_generate(request_json, osm_json) {
1645
+ let deferred4_0;
1646
+ let deferred4_1;
1647
+ try {
1648
+ const ptr0 = passStringToWasm0(request_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1649
+ const len0 = WASM_VECTOR_LEN;
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);
1653
+ var ptr3 = ret[0];
1654
+ var len3 = ret[1];
1655
+ if (ret[3]) {
1656
+ ptr3 = 0; len3 = 0;
1657
+ throw takeFromExternrefTable0(ret[2]);
1658
+ }
1659
+ deferred4_0 = ptr3;
1660
+ deferred4_1 = len3;
1661
+ return getStringFromWasm0(ptr3, len3);
1662
+ } finally {
1663
+ wasm.__wbindgen_free(deferred4_0, deferred4_1, 1);
1664
+ }
1665
+ }
1666
+
1667
+ /**
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}`.
1671
+ * @param {Uint8Array} bytes
1672
+ * @returns {string}
1673
+ */
1674
+ export function synth_load_places(bytes) {
1675
+ let deferred3_0;
1676
+ let deferred3_1;
1677
+ try {
1678
+ const ptr0 = passArray8ToWasm0(bytes, wasm.__wbindgen_malloc);
1679
+ const len0 = WASM_VECTOR_LEN;
1680
+ const ret = wasm.synth_load_places(ptr0, len0);
1681
+ var ptr2 = ret[0];
1682
+ var len2 = ret[1];
1683
+ if (ret[3]) {
1684
+ ptr2 = 0; len2 = 0;
1685
+ throw takeFromExternrefTable0(ret[2]);
1686
+ }
1687
+ deferred3_0 = ptr2;
1688
+ deferred3_1 = len2;
1689
+ return getStringFromWasm0(ptr2, len2);
1690
+ } finally {
1691
+ wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
1692
+ }
1693
+ }
1694
+
1695
+ /**
1696
+ * The Overpass QL queries for a synthetic request's region: a JSON array, two
1697
+ * entries when the region crosses the antimeridian.
1698
+ * @param {string} request_json
1699
+ * @returns {string}
1700
+ */
1701
+ export function synth_overpass_queries(request_json) {
1702
+ let deferred3_0;
1703
+ let deferred3_1;
1704
+ try {
1705
+ const ptr0 = passStringToWasm0(request_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1706
+ const len0 = WASM_VECTOR_LEN;
1707
+ const ret = wasm.synth_overpass_queries(ptr0, len0);
1708
+ var ptr2 = ret[0];
1709
+ var len2 = ret[1];
1710
+ if (ret[3]) {
1711
+ ptr2 = 0; len2 = 0;
1712
+ throw takeFromExternrefTable0(ret[2]);
1713
+ }
1714
+ deferred3_0 = ptr2;
1715
+ deferred3_1 = len2;
1716
+ return getStringFromWasm0(ptr2, len2);
1717
+ } finally {
1718
+ wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
1719
+ }
1720
+ }
1188
1721
  function __wbg_get_imports() {
1189
1722
  const import0 = {
1190
1723
  __proto__: null,
1191
- __wbg_Error_67e7344beaa85059: function(arg0, arg1) {
1724
+ __wbg_Error_30c8987f7c2ed4e2: function(arg0, arg1) {
1192
1725
  const ret = Error(getStringFromWasm0(arg0, arg1));
1193
1726
  return ret;
1194
1727
  },
1195
- __wbg___wbindgen_boolean_get_7a12af2b3f899c5a: function(arg0) {
1728
+ __wbg___wbindgen_boolean_get_5b446f51afd21013: function(arg0) {
1196
1729
  const v = arg0;
1197
1730
  const ret = typeof(v) === 'boolean' ? v : undefined;
1198
1731
  return isLikeNone(ret) ? 0xFFFFFF : ret ? 1 : 0;
1199
1732
  },
1200
- __wbg___wbindgen_is_function_fcda5e3902d732fe: function(arg0) {
1733
+ __wbg___wbindgen_is_function_1f9d30630b8b1d3d: function(arg0) {
1201
1734
  const ret = typeof(arg0) === 'function';
1202
1735
  return ret;
1203
1736
  },
1204
- __wbg___wbindgen_is_undefined_8c687d0b90d5b524: function(arg0) {
1737
+ __wbg___wbindgen_is_undefined_8865fb403f8fe9d8: function(arg0) {
1205
1738
  const ret = arg0 === undefined;
1206
1739
  return ret;
1207
1740
  },
1208
- __wbg___wbindgen_throw_5d9e815e6fdf150f: function(arg0, arg1) {
1741
+ __wbg___wbindgen_throw_41e9ee4f547fc59a: function(arg0, arg1) {
1209
1742
  throw new Error(getStringFromWasm0(arg0, arg1));
1210
1743
  },
1211
- __wbg__wbg_cb_unref_997e73d32238e655: function(arg0) {
1744
+ __wbg__wbg_cb_unref_dcc1a90847f04c41: function(arg0) {
1212
1745
  arg0._wbg_cb_unref();
1213
1746
  },
1214
- __wbg_call_269c5566fbede3eb: function() { return handleError(function (arg0, arg1) {
1215
- const ret = arg0.call(arg1);
1747
+ __wbg_call_187d372bd5fdd4aa: function() { return handleError(function (arg0, arg1, arg2) {
1748
+ const ret = arg0.call(arg1, arg2);
1216
1749
  return ret;
1217
1750
  }, arguments); },
1218
- __wbg_call_6bcf8d3e20937e46: function() { return handleError(function (arg0, arg1, arg2) {
1219
- const ret = arg0.call(arg1, arg2);
1751
+ __wbg_call_6137034ef55c9d0f: function() { return handleError(function (arg0, arg1) {
1752
+ const ret = arg0.call(arg1);
1220
1753
  return ret;
1221
1754
  }, arguments); },
1222
1755
  __wbg_error_757e9472f8410341: function(arg0, arg1) {
@@ -1234,14 +1767,14 @@ function __wbg_get_imports() {
1234
1767
  const ret = new Error();
1235
1768
  return ret;
1236
1769
  },
1237
- __wbg_new_8f72ed7c652bf5a2: function(arg0, arg1) {
1770
+ __wbg_new_5502aad30c185fc8: function(arg0, arg1) {
1238
1771
  try {
1239
1772
  var state0 = {a: arg0, b: arg1};
1240
1773
  var cb0 = (arg0, arg1) => {
1241
1774
  const a = state0.a;
1242
1775
  state0.a = 0;
1243
1776
  try {
1244
- return wasm_bindgen__convert__closures_____invoke__h0178a8f776e4ef73(a, state0.b, arg0, arg1);
1777
+ return wasm_bindgen__convert__closures_____invoke__h67ba427e9454f1d8(a, state0.b, arg0, arg1);
1245
1778
  } finally {
1246
1779
  state0.a = a;
1247
1780
  }
@@ -1252,14 +1785,14 @@ function __wbg_get_imports() {
1252
1785
  state0.a = 0;
1253
1786
  }
1254
1787
  },
1255
- __wbg_new_typed_6f8b0d724fe26c07: function(arg0, arg1) {
1788
+ __wbg_new_typed_b01cb72a8af741a3: function(arg0, arg1) {
1256
1789
  try {
1257
1790
  var state0 = {a: arg0, b: arg1};
1258
1791
  var cb0 = (arg0, arg1) => {
1259
1792
  const a = state0.a;
1260
1793
  state0.a = 0;
1261
1794
  try {
1262
- return wasm_bindgen__convert__closures_____invoke__h0178a8f776e4ef73(a, state0.b, arg0, arg1);
1795
+ return wasm_bindgen__convert__closures_____invoke__h67ba427e9454f1d8(a, state0.b, arg0, arg1);
1263
1796
  } finally {
1264
1797
  state0.a = a;
1265
1798
  }
@@ -1270,6 +1803,14 @@ function __wbg_get_imports() {
1270
1803
  state0.a = 0;
1271
1804
  }
1272
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
+ },
1273
1814
  __wbg_now_cace042f68c814d8: function(arg0) {
1274
1815
  const ret = arg0.now();
1275
1816
  return ret;
@@ -1278,14 +1819,14 @@ function __wbg_get_imports() {
1278
1819
  const ret = arg0.performance;
1279
1820
  return ret;
1280
1821
  },
1281
- __wbg_queueMicrotask_85c90f6987555d65: function(arg0) {
1822
+ __wbg_queueMicrotask_9833f9a49df95a49: function(arg0) {
1282
1823
  const ret = arg0.queueMicrotask;
1283
1824
  return ret;
1284
1825
  },
1285
- __wbg_queueMicrotask_f6a1fa10b81d1fc0: function(arg0) {
1826
+ __wbg_queueMicrotask_a72f977e97f23c5f: function(arg0) {
1286
1827
  queueMicrotask(arg0);
1287
1828
  },
1288
- __wbg_resolve_35ec7e0c6af4c82c: function(arg0) {
1829
+ __wbg_resolve_0076e10020304ede: function(arg0) {
1289
1830
  const ret = Promise.resolve(arg0);
1290
1831
  return ret;
1291
1832
  },
@@ -1299,33 +1840,33 @@ function __wbg_get_imports() {
1299
1840
  getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
1300
1841
  getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
1301
1842
  },
1302
- __wbg_static_accessor_GLOBAL_8eb4cd83130a11a0: function() {
1843
+ __wbg_static_accessor_GLOBAL_266715b9d96ba635: function() {
1303
1844
  const ret = typeof global === 'undefined' ? null : global;
1304
1845
  return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
1305
1846
  },
1306
- __wbg_static_accessor_GLOBAL_THIS_1e7044f654e934db: function() {
1847
+ __wbg_static_accessor_GLOBAL_THIS_10fb7dc1ae063179: function() {
1307
1848
  const ret = typeof globalThis === 'undefined' ? null : globalThis;
1308
1849
  return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
1309
1850
  },
1310
- __wbg_static_accessor_SELF_d8b50611246a6d92: function() {
1851
+ __wbg_static_accessor_SELF_0b583911f537483a: function() {
1311
1852
  const ret = typeof self === 'undefined' ? null : self;
1312
1853
  return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
1313
1854
  },
1314
- __wbg_static_accessor_WINDOW_fd0bc376bf0f8b42: function() {
1855
+ __wbg_static_accessor_WINDOW_d7f903d1508cbdc4: function() {
1315
1856
  const ret = typeof window === 'undefined' ? null : window;
1316
1857
  return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
1317
1858
  },
1318
- __wbg_then_7a850dae4493f353: function(arg0, arg1, arg2) {
1859
+ __wbg_then_c949d5a25a4e78f8: function(arg0, arg1, arg2) {
1319
1860
  const ret = arg0.then(arg1, arg2);
1320
1861
  return ret;
1321
1862
  },
1322
- __wbg_then_b830475380919203: function(arg0, arg1) {
1863
+ __wbg_then_e71170d78fcf8954: function(arg0, arg1) {
1323
1864
  const ret = arg0.then(arg1);
1324
1865
  return ret;
1325
1866
  },
1326
1867
  __wbindgen_generic_0000000000000001: function(arg0, arg1) {
1327
- // Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [Externref], shim_idx: 498, ret: Result(Unit), inner_ret: Some(Result(Unit)) }, mutable: true }) -> Externref`.
1328
- const ret = makeMutClosure(arg0, arg1, wasm_bindgen__convert__closures_____invoke__h42fc1c09ce4112c3);
1868
+ // Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [Externref], shim_idx: 572, ret: Result(Unit), inner_ret: Some(Result(Unit)) }, mutable: true }) -> Externref`.
1869
+ const ret = makeMutClosure(arg0, arg1, wasm_bindgen__convert__closures_____invoke__h1c534e945ee6d3b6);
1329
1870
  return ret;
1330
1871
  },
1331
1872
  __wbindgen_generic_0000000000000002: function(arg0, arg1) {
@@ -1349,15 +1890,15 @@ function __wbg_get_imports() {
1349
1890
  };
1350
1891
  }
1351
1892
 
1352
- function wasm_bindgen__convert__closures_____invoke__h42fc1c09ce4112c3(arg0, arg1, arg2) {
1353
- const ret = wasm.wasm_bindgen__convert__closures_____invoke__h42fc1c09ce4112c3(arg0, arg1, arg2);
1893
+ function wasm_bindgen__convert__closures_____invoke__h1c534e945ee6d3b6(arg0, arg1, arg2) {
1894
+ const ret = wasm.wasm_bindgen__convert__closures_____invoke__h1c534e945ee6d3b6(arg0, arg1, arg2);
1354
1895
  if (ret[1]) {
1355
1896
  throw takeFromExternrefTable0(ret[0]);
1356
1897
  }
1357
1898
  }
1358
1899
 
1359
- function wasm_bindgen__convert__closures_____invoke__h0178a8f776e4ef73(arg0, arg1, arg2, arg3) {
1360
- wasm.wasm_bindgen__convert__closures_____invoke__h0178a8f776e4ef73(arg0, arg1, arg2, arg3);
1900
+ function wasm_bindgen__convert__closures_____invoke__h67ba427e9454f1d8(arg0, arg1, arg2, arg3) {
1901
+ wasm.wasm_bindgen__convert__closures_____invoke__h67ba427e9454f1d8(arg0, arg1, arg2, arg3);
1361
1902
  }
1362
1903
 
1363
1904
  const McPfSessionFinalization = (typeof FinalizationRegistry === 'undefined')
@@ -1366,6 +1907,12 @@ const McPfSessionFinalization = (typeof FinalizationRegistry === 'undefined')
1366
1907
  const StudyFinalization = (typeof FinalizationRegistry === 'undefined')
1367
1908
  ? { register: () => {}, unregister: () => {} }
1368
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));
1369
1916
 
1370
1917
  function addToExternrefTable0(obj) {
1371
1918
  const idx = wasm.__externref_table_alloc();
@@ -1377,6 +1924,26 @@ const CLOSURE_DTORS = (typeof FinalizationRegistry === 'undefined')
1377
1924
  ? { register: () => {}, unregister: () => {} }
1378
1925
  : new FinalizationRegistry(state => wasm.__wbindgen_destroy_closure(state.a, state.b));
1379
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
+
1380
1947
  let cachedDataViewMemory0 = null;
1381
1948
  function getDataViewMemory0() {
1382
1949
  if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || (cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm.memory.buffer)) {
@@ -1385,10 +1952,34 @@ function getDataViewMemory0() {
1385
1952
  return cachedDataViewMemory0;
1386
1953
  }
1387
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
+
1388
1971
  function getStringFromWasm0(ptr, len) {
1389
1972
  return decodeText(ptr >>> 0, len);
1390
1973
  }
1391
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
+
1392
1983
  let cachedUint8ArrayMemory0 = null;
1393
1984
  function getUint8ArrayMemory0() {
1394
1985
  if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
@@ -1523,6 +2114,9 @@ function __wbg_finalize_init(instance, module) {
1523
2114
  wasm = instance.exports;
1524
2115
  wasmModule = module;
1525
2116
  cachedDataViewMemory0 = null;
2117
+ cachedFloat32ArrayMemory0 = null;
2118
+ cachedFloat64ArrayMemory0 = null;
2119
+ cachedUint32ArrayMemory0 = null;
1526
2120
  cachedUint8ArrayMemory0 = null;
1527
2121
  wasm.__wbindgen_start();
1528
2122
  return wasm;