@tellegen/engine 0.2.0 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +19 -14
- package/dist/generated/contracts.d.ts +25 -17
- package/dist/generated/contracts.d.ts.map +1 -1
- package/dist/generated/contracts.js +3 -3
- package/dist/generated/study-contracts.d.ts +426 -0
- package/dist/generated/study-contracts.d.ts.map +1 -0
- package/dist/generated/study-contracts.js +4 -0
- package/dist/generated/study-contracts.js.map +1 -0
- package/dist/generated/study-schema.d.ts +2 -0
- package/dist/generated/study-schema.d.ts.map +1 -0
- package/dist/generated/study-schema.js +3 -0
- package/dist/generated/study-schema.js.map +1 -0
- package/dist/host.d.ts +12 -0
- package/dist/host.d.ts.map +1 -1
- package/dist/host.js +58 -10
- package/dist/host.js.map +1 -1
- package/dist/index.d.ts +309 -119
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +359 -110
- package/dist/index.js.map +1 -1
- package/dist/input-limit.d.ts +1 -1
- package/dist/input-limit.js +1 -1
- package/dist/module.d.ts +1 -0
- package/dist/module.d.ts.map +1 -1
- package/dist/module.js.map +1 -1
- package/dist/protocol.d.ts +87 -26
- package/dist/protocol.d.ts.map +1 -1
- package/dist/protocol.js +60 -23
- package/dist/protocol.js.map +1 -1
- package/dist/study-document.d.ts +46 -0
- package/dist/study-document.d.ts.map +1 -0
- package/dist/study-document.js +183 -0
- package/dist/study-document.js.map +1 -0
- package/dist/study-document.test.d.ts +2 -0
- package/dist/study-document.test.d.ts.map +1 -0
- package/dist/study-document.test.js +119 -0
- package/dist/study-document.test.js.map +1 -0
- package/dist/wasm-pkg/tellegen.d.ts +167 -85
- package/dist/wasm-pkg/tellegen.js +667 -187
- package/dist/wasm-pkg/tellegen_bg.wasm +0 -0
- package/dist/wasm-pkg/tellegen_bg.wasm.d.ts +27 -9
- package/dist/worker.js +15 -3
- package/dist/worker.js.map +1 -1
- package/package.json +20 -3
|
@@ -1,17 +1,171 @@
|
|
|
1
1
|
/* @ts-self-types="./tellegen.d.ts" */
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
|
-
* A
|
|
5
|
-
*
|
|
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.
|
|
7
|
+
*/
|
|
8
|
+
export class McPfSession {
|
|
9
|
+
__destroy_into_raw() {
|
|
10
|
+
const ptr = this.__wbg_ptr;
|
|
11
|
+
this.__wbg_ptr = 0;
|
|
12
|
+
McPfSessionFinalization.unregister(this);
|
|
13
|
+
return ptr;
|
|
14
|
+
}
|
|
15
|
+
free() {
|
|
16
|
+
const ptr = this.__destroy_into_raw();
|
|
17
|
+
wasm.__wbg_mcpfsession_free(ptr, 0);
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Materialize the current edited input as PowerIO IR.
|
|
21
|
+
* @returns {string}
|
|
22
|
+
*/
|
|
23
|
+
input_module() {
|
|
24
|
+
let deferred2_0;
|
|
25
|
+
let deferred2_1;
|
|
26
|
+
try {
|
|
27
|
+
const ret = wasm.mcpfsession_input_module(this.__wbg_ptr);
|
|
28
|
+
var ptr1 = ret[0];
|
|
29
|
+
var len1 = ret[1];
|
|
30
|
+
if (ret[3]) {
|
|
31
|
+
ptr1 = 0; len1 = 0;
|
|
32
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
33
|
+
}
|
|
34
|
+
deferred2_0 = ptr1;
|
|
35
|
+
deferred2_1 = len1;
|
|
36
|
+
return getStringFromWasm0(ptr1, len1);
|
|
37
|
+
} finally {
|
|
38
|
+
wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Editable load branches with base and current P/Q values.
|
|
43
|
+
* @returns {string}
|
|
44
|
+
*/
|
|
45
|
+
load_branches() {
|
|
46
|
+
let deferred2_0;
|
|
47
|
+
let deferred2_1;
|
|
48
|
+
try {
|
|
49
|
+
const ret = wasm.mcpfsession_load_branches(this.__wbg_ptr);
|
|
50
|
+
var ptr1 = ret[0];
|
|
51
|
+
var len1 = ret[1];
|
|
52
|
+
if (ret[3]) {
|
|
53
|
+
ptr1 = 0; len1 = 0;
|
|
54
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
55
|
+
}
|
|
56
|
+
deferred2_0 = ptr1;
|
|
57
|
+
deferred2_1 = len1;
|
|
58
|
+
return getStringFromWasm0(ptr1, len1);
|
|
59
|
+
} finally {
|
|
60
|
+
wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* @param {string} module_json
|
|
65
|
+
* @param {string} options_json
|
|
66
|
+
*/
|
|
67
|
+
constructor(module_json, options_json) {
|
|
68
|
+
const ptr0 = passStringToWasm0(module_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
69
|
+
const len0 = WASM_VECTOR_LEN;
|
|
70
|
+
const ptr1 = passStringToWasm0(options_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
71
|
+
const len1 = WASM_VECTOR_LEN;
|
|
72
|
+
const ret = wasm.mcpfsession_new(ptr0, len0, ptr1, len1);
|
|
73
|
+
if (ret[2]) {
|
|
74
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
75
|
+
}
|
|
76
|
+
this.__wbg_ptr = ret[0];
|
|
77
|
+
McPfSessionFinalization.register(this, this.__wbg_ptr, this);
|
|
78
|
+
return this;
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Replace the absolute branch-power edit state and solve with the retained
|
|
82
|
+
* factorization and previous converged voltage.
|
|
83
|
+
* @param {string} edits_json
|
|
84
|
+
* @returns {string}
|
|
85
|
+
*/
|
|
86
|
+
replace_load_powers(edits_json) {
|
|
87
|
+
let deferred3_0;
|
|
88
|
+
let deferred3_1;
|
|
89
|
+
try {
|
|
90
|
+
const ptr0 = passStringToWasm0(edits_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
91
|
+
const len0 = WASM_VECTOR_LEN;
|
|
92
|
+
const ret = wasm.mcpfsession_replace_load_powers(this.__wbg_ptr, ptr0, len0);
|
|
93
|
+
var ptr2 = ret[0];
|
|
94
|
+
var len2 = ret[1];
|
|
95
|
+
if (ret[3]) {
|
|
96
|
+
ptr2 = 0; len2 = 0;
|
|
97
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
98
|
+
}
|
|
99
|
+
deferred3_0 = ptr2;
|
|
100
|
+
deferred3_1 = len2;
|
|
101
|
+
return getStringFromWasm0(ptr2, len2);
|
|
102
|
+
} finally {
|
|
103
|
+
wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* The current complete solver result.
|
|
108
|
+
* @returns {string}
|
|
109
|
+
*/
|
|
110
|
+
result() {
|
|
111
|
+
let deferred2_0;
|
|
112
|
+
let deferred2_1;
|
|
113
|
+
try {
|
|
114
|
+
const ret = wasm.mcpfsession_result(this.__wbg_ptr);
|
|
115
|
+
var ptr1 = ret[0];
|
|
116
|
+
var len1 = ret[1];
|
|
117
|
+
if (ret[3]) {
|
|
118
|
+
ptr1 = 0; len1 = 0;
|
|
119
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
120
|
+
}
|
|
121
|
+
deferred2_0 = ptr1;
|
|
122
|
+
deferred2_1 = len1;
|
|
123
|
+
return getStringFromWasm0(ptr1, len1);
|
|
124
|
+
} finally {
|
|
125
|
+
wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
/**
|
|
129
|
+
* Save the current edited point and result without re-solving.
|
|
130
|
+
* @param {string} study_id
|
|
131
|
+
* @param {string} study_title
|
|
132
|
+
* @returns {string}
|
|
133
|
+
*/
|
|
134
|
+
snapshot(study_id, study_title) {
|
|
135
|
+
let deferred4_0;
|
|
136
|
+
let deferred4_1;
|
|
137
|
+
try {
|
|
138
|
+
const ptr0 = passStringToWasm0(study_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
139
|
+
const len0 = WASM_VECTOR_LEN;
|
|
140
|
+
const ptr1 = passStringToWasm0(study_title, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
141
|
+
const len1 = WASM_VECTOR_LEN;
|
|
142
|
+
const ret = wasm.mcpfsession_snapshot(this.__wbg_ptr, ptr0, len0, ptr1, len1);
|
|
143
|
+
var ptr3 = ret[0];
|
|
144
|
+
var len3 = ret[1];
|
|
145
|
+
if (ret[3]) {
|
|
146
|
+
ptr3 = 0; len3 = 0;
|
|
147
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
148
|
+
}
|
|
149
|
+
deferred4_0 = ptr3;
|
|
150
|
+
deferred4_1 = len3;
|
|
151
|
+
return getStringFromWasm0(ptr3, len3);
|
|
152
|
+
} finally {
|
|
153
|
+
wasm.__wbindgen_free(deferred4_0, deferred4_1, 1);
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
if (Symbol.dispose) McPfSession.prototype[Symbol.dispose] = McPfSession.prototype.free;
|
|
158
|
+
|
|
159
|
+
/**
|
|
160
|
+
* A retained handle over the engine, exported to JS. Construct once per PowerIO module;
|
|
161
|
+
* then [`replace_edits`](Study::replace_edits)
|
|
6
162
|
* solves exactly at an absolute edit state and [`preview_replacement`](Study::preview_replacement)
|
|
7
|
-
* returns a first
|
|
8
|
-
* the network, unlike `solve_json` which rebuilds it on every call. This is
|
|
9
|
-
* the path a reactive drag should use.
|
|
163
|
+
* returns a first order linearization toward an absolute edit state.
|
|
10
164
|
*
|
|
11
165
|
* Arguments and results are JSON in the engine's `Study` shapes: edits are a
|
|
12
166
|
* `NetworkEdit[]` (e.g. `[{"kind":"add_load","bus":2,"p_mw":50}]`; the element key
|
|
13
|
-
* also accepts
|
|
14
|
-
* `"bus":"buses:1"`), `preview` watches an
|
|
167
|
+
* also accepts a powerio row uid string when the source format carries uids,
|
|
168
|
+
* e.g. `"bus":"buses:1"`), `preview` watches an
|
|
15
169
|
* `Operand[]` (e.g. `[{"Price":"Active"}]`) and returns a `Preview`. `commit` takes the
|
|
16
170
|
* edits plus a `SensRequest[]` of watched cells and returns `{ solution, iterations,
|
|
17
171
|
* sensitivities }` — the committed [`SolveResponse`] plus the requested ∂operand/∂param
|
|
@@ -32,7 +186,7 @@ export class Study {
|
|
|
32
186
|
/**
|
|
33
187
|
* Apply a geographic layer (a canonical `.geo.json` from [`parse_geo`] or
|
|
34
188
|
* [`apply_layout`]) onto this study's base network, so a later
|
|
35
|
-
* [`
|
|
189
|
+
* [`save_module`](Study::save_module) or export carries the coordinates
|
|
36
190
|
* on screen. Locations are metadata the model never reads; nothing
|
|
37
191
|
* re-solves. Returns the apply report JSON.
|
|
38
192
|
* @param {string} layer_geojson
|
|
@@ -92,6 +246,34 @@ export class Study {
|
|
|
92
246
|
wasm.__wbindgen_free(deferred4_0, deferred4_1, 1);
|
|
93
247
|
}
|
|
94
248
|
}
|
|
249
|
+
/**
|
|
250
|
+
* Export the committed operating point to a powerio `format` (`matpower`,
|
|
251
|
+
* `psse`, ...). Returns `{ text, diagnostics, format,
|
|
252
|
+
* extension }` as JSON: the serialized case, this output operation's
|
|
253
|
+
* structured diagnostics, and the format token and file extension.
|
|
254
|
+
* @param {string} format
|
|
255
|
+
* @returns {string}
|
|
256
|
+
*/
|
|
257
|
+
export(format) {
|
|
258
|
+
let deferred3_0;
|
|
259
|
+
let deferred3_1;
|
|
260
|
+
try {
|
|
261
|
+
const ptr0 = passStringToWasm0(format, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
262
|
+
const len0 = WASM_VECTOR_LEN;
|
|
263
|
+
const ret = wasm.study_export(this.__wbg_ptr, ptr0, len0);
|
|
264
|
+
var ptr2 = ret[0];
|
|
265
|
+
var len2 = ret[1];
|
|
266
|
+
if (ret[3]) {
|
|
267
|
+
ptr2 = 0; len2 = 0;
|
|
268
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
269
|
+
}
|
|
270
|
+
deferred3_0 = ptr2;
|
|
271
|
+
deferred3_1 = len2;
|
|
272
|
+
return getStringFromWasm0(ptr2, len2);
|
|
273
|
+
} finally {
|
|
274
|
+
wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
|
|
275
|
+
}
|
|
276
|
+
}
|
|
95
277
|
/**
|
|
96
278
|
* The formulation tag (`"dcopf"` / `"acpf"`).
|
|
97
279
|
* @returns {string}
|
|
@@ -109,14 +291,14 @@ export class Study {
|
|
|
109
291
|
}
|
|
110
292
|
}
|
|
111
293
|
/**
|
|
112
|
-
* Build a study over `
|
|
294
|
+
* Build a study over `module_json` for `formulation` (`"dcopf"` / `"acpf"`, and —
|
|
113
295
|
* in a build that includes them — `"socwr"` / `"acopf"`), solving the base case.
|
|
114
|
-
*
|
|
115
|
-
* @param {string}
|
|
296
|
+
* Bare model JSON and unknown or unavailable formulations are rejected.
|
|
297
|
+
* @param {string} module_json
|
|
116
298
|
* @param {string} formulation
|
|
117
299
|
*/
|
|
118
|
-
constructor(
|
|
119
|
-
const ptr0 = passStringToWasm0(
|
|
300
|
+
constructor(module_json, formulation) {
|
|
301
|
+
const ptr0 = passStringToWasm0(module_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
120
302
|
const len0 = WASM_VECTOR_LEN;
|
|
121
303
|
const ptr1 = passStringToWasm0(formulation, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
122
304
|
const len1 = WASM_VECTOR_LEN;
|
|
@@ -128,6 +310,38 @@ export class Study {
|
|
|
128
310
|
StudyFinalization.register(this, this.__wbg_ptr, this);
|
|
129
311
|
return this;
|
|
130
312
|
}
|
|
313
|
+
/**
|
|
314
|
+
* Run a bounded differentiable planning search over the committed
|
|
315
|
+
* operating point: the implicit gradient of the serializable outer
|
|
316
|
+
* objective through the exact DC OPF KKT orders capacity trials
|
|
317
|
+
* whose every step is verified by an exact re-solve. Read only — the
|
|
318
|
+
* committed case, edits, and revision are untouched. `spec_json` is a
|
|
319
|
+
* [`tellegen::plan::CapacityPlanSpec`]; the returned JSON is the complete
|
|
320
|
+
* [`tellegen::plan::CapacityPlanOutcome`] trace with the unapplied
|
|
321
|
+
* proposal. A non-DC formulation returns a typed error.
|
|
322
|
+
* @param {string} spec_json
|
|
323
|
+
* @returns {string}
|
|
324
|
+
*/
|
|
325
|
+
plan(spec_json) {
|
|
326
|
+
let deferred3_0;
|
|
327
|
+
let deferred3_1;
|
|
328
|
+
try {
|
|
329
|
+
const ptr0 = passStringToWasm0(spec_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
330
|
+
const len0 = WASM_VECTOR_LEN;
|
|
331
|
+
const ret = wasm.study_plan(this.__wbg_ptr, ptr0, len0);
|
|
332
|
+
var ptr2 = ret[0];
|
|
333
|
+
var len2 = ret[1];
|
|
334
|
+
if (ret[3]) {
|
|
335
|
+
ptr2 = 0; len2 = 0;
|
|
336
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
337
|
+
}
|
|
338
|
+
deferred3_0 = ptr2;
|
|
339
|
+
deferred3_1 = len2;
|
|
340
|
+
return getStringFromWasm0(ptr2, len2);
|
|
341
|
+
} finally {
|
|
342
|
+
wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
|
|
343
|
+
}
|
|
344
|
+
}
|
|
131
345
|
/**
|
|
132
346
|
* First-order preview of `edits_json` (a `NetworkEdit[]`) for the `watched_json`
|
|
133
347
|
* operands (an `Operand[]`), at the committed point, without re-solving. Returns the
|
|
@@ -219,17 +433,62 @@ export class Study {
|
|
|
219
433
|
}
|
|
220
434
|
}
|
|
221
435
|
/**
|
|
222
|
-
* Serialize
|
|
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`].
|
|
436
|
+
* Serialize the exact problem instance, including its inner objective and constraints.
|
|
226
437
|
* @returns {string}
|
|
227
438
|
*/
|
|
228
|
-
|
|
439
|
+
save_instance_module() {
|
|
229
440
|
let deferred2_0;
|
|
230
441
|
let deferred2_1;
|
|
231
442
|
try {
|
|
232
|
-
const ret = wasm.
|
|
443
|
+
const ret = wasm.study_save_instance_module(this.__wbg_ptr);
|
|
444
|
+
var ptr1 = ret[0];
|
|
445
|
+
var len1 = ret[1];
|
|
446
|
+
if (ret[3]) {
|
|
447
|
+
ptr1 = 0; len1 = 0;
|
|
448
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
449
|
+
}
|
|
450
|
+
deferred2_0 = ptr1;
|
|
451
|
+
deferred2_1 = len1;
|
|
452
|
+
return getStringFromWasm0(ptr1, len1);
|
|
453
|
+
} finally {
|
|
454
|
+
wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
|
|
455
|
+
}
|
|
456
|
+
}
|
|
457
|
+
/**
|
|
458
|
+
* Serialize the committed operating point as a stored PowerIO module:
|
|
459
|
+
* the materialized network with one descriptive `Edit` history entry per
|
|
460
|
+
* committed edit, ready to download as `.pio.json`. Any PowerIO reader
|
|
461
|
+
* understands the file; reloading it starts a fresh session.
|
|
462
|
+
* @returns {string}
|
|
463
|
+
*/
|
|
464
|
+
save_module() {
|
|
465
|
+
let deferred2_0;
|
|
466
|
+
let deferred2_1;
|
|
467
|
+
try {
|
|
468
|
+
const ret = wasm.study_save_module(this.__wbg_ptr);
|
|
469
|
+
var ptr1 = ret[0];
|
|
470
|
+
var len1 = ret[1];
|
|
471
|
+
if (ret[3]) {
|
|
472
|
+
ptr1 = 0; len1 = 0;
|
|
473
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
474
|
+
}
|
|
475
|
+
deferred2_0 = ptr1;
|
|
476
|
+
deferred2_1 = len1;
|
|
477
|
+
return getStringFromWasm0(ptr1, len1);
|
|
478
|
+
} finally {
|
|
479
|
+
wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
|
|
480
|
+
}
|
|
481
|
+
}
|
|
482
|
+
/**
|
|
483
|
+
* Save the committed exact DC OPF result as a PowerIO solution module.
|
|
484
|
+
* The embedded instance contains the materialized case that was solved.
|
|
485
|
+
* @returns {string}
|
|
486
|
+
*/
|
|
487
|
+
save_solution_module() {
|
|
488
|
+
let deferred2_0;
|
|
489
|
+
let deferred2_1;
|
|
490
|
+
try {
|
|
491
|
+
const ret = wasm.study_save_solution_module(this.__wbg_ptr);
|
|
233
492
|
var ptr1 = ret[0];
|
|
234
493
|
var len1 = ret[1];
|
|
235
494
|
if (ret[3]) {
|
|
@@ -273,15 +532,15 @@ if (Symbol.dispose) Study.prototype[Symbol.dispose] = Study.prototype.free;
|
|
|
273
532
|
* project to approximate longitude/latitude and join onto buses through the
|
|
274
533
|
* `SubNum` extras key. Returns the refreshed `ingest_case` payload plus a
|
|
275
534
|
* `report`; errors when no bus joined.
|
|
276
|
-
* @param {string}
|
|
535
|
+
* @param {string} module_json
|
|
277
536
|
* @param {Uint8Array} bytes
|
|
278
537
|
* @returns {string}
|
|
279
538
|
*/
|
|
280
|
-
export function apply_display_geo(
|
|
539
|
+
export function apply_display_geo(module_json, bytes) {
|
|
281
540
|
let deferred4_0;
|
|
282
541
|
let deferred4_1;
|
|
283
542
|
try {
|
|
284
|
-
const ptr0 = passStringToWasm0(
|
|
543
|
+
const ptr0 = passStringToWasm0(module_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
285
544
|
const len0 = WASM_VECTOR_LEN;
|
|
286
545
|
const ptr1 = passArray8ToWasm0(bytes, wasm.__wbindgen_malloc);
|
|
287
546
|
const len1 = WASM_VECTOR_LEN;
|
|
@@ -306,15 +565,15 @@ export function apply_display_geo(network_json, bytes) {
|
|
|
306
565
|
* id, name, and the unordered endpoint pair — upstream semantics). Returns
|
|
307
566
|
* the refreshed `ingest_case` payload plus a `report` of matched/unmatched
|
|
308
567
|
* counts; errors when nothing matched.
|
|
309
|
-
* @param {string}
|
|
568
|
+
* @param {string} module_json
|
|
310
569
|
* @param {string} layer_geojson
|
|
311
570
|
* @returns {string}
|
|
312
571
|
*/
|
|
313
|
-
export function apply_geo(
|
|
572
|
+
export function apply_geo(module_json, layer_geojson) {
|
|
314
573
|
let deferred4_0;
|
|
315
574
|
let deferred4_1;
|
|
316
575
|
try {
|
|
317
|
-
const ptr0 = passStringToWasm0(
|
|
576
|
+
const ptr0 = passStringToWasm0(module_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
318
577
|
const len0 = WASM_VECTOR_LEN;
|
|
319
578
|
const ptr1 = passStringToWasm0(layer_geojson, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
320
579
|
const len1 = WASM_VECTOR_LEN;
|
|
@@ -338,16 +597,16 @@ export function apply_geo(network_json, layer_geojson) {
|
|
|
338
597
|
* `kind` provenance (`synthetic` or `manual`). Returns the refreshed
|
|
339
598
|
* `ingest_case` payload plus `layer`, the stamped layout as a canonical
|
|
340
599
|
* `.geo.json` document.
|
|
341
|
-
* @param {string}
|
|
600
|
+
* @param {string} module_json
|
|
342
601
|
* @param {string} coords_json
|
|
343
602
|
* @param {string} kind
|
|
344
603
|
* @returns {string}
|
|
345
604
|
*/
|
|
346
|
-
export function apply_layout(
|
|
605
|
+
export function apply_layout(module_json, coords_json, kind) {
|
|
347
606
|
let deferred5_0;
|
|
348
607
|
let deferred5_1;
|
|
349
608
|
try {
|
|
350
|
-
const ptr0 = passStringToWasm0(
|
|
609
|
+
const ptr0 = passStringToWasm0(module_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
351
610
|
const len0 = WASM_VECTOR_LEN;
|
|
352
611
|
const ptr1 = passStringToWasm0(coords_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
353
612
|
const len1 = WASM_VECTOR_LEN;
|
|
@@ -368,6 +627,35 @@ export function apply_layout(network_json, coords_json, kind) {
|
|
|
368
627
|
}
|
|
369
628
|
}
|
|
370
629
|
|
|
630
|
+
/**
|
|
631
|
+
* Attach geographic or drawing positions to a saved multiconductor result.
|
|
632
|
+
* @param {string} snapshot_json
|
|
633
|
+
* @param {string} layer_geojson
|
|
634
|
+
* @returns {string}
|
|
635
|
+
*/
|
|
636
|
+
export function apply_mc_study_geo(snapshot_json, layer_geojson) {
|
|
637
|
+
let deferred4_0;
|
|
638
|
+
let deferred4_1;
|
|
639
|
+
try {
|
|
640
|
+
const ptr0 = passStringToWasm0(snapshot_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
641
|
+
const len0 = WASM_VECTOR_LEN;
|
|
642
|
+
const ptr1 = passStringToWasm0(layer_geojson, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
643
|
+
const len1 = WASM_VECTOR_LEN;
|
|
644
|
+
const ret = wasm.apply_mc_study_geo(ptr0, len0, ptr1, len1);
|
|
645
|
+
var ptr3 = ret[0];
|
|
646
|
+
var len3 = ret[1];
|
|
647
|
+
if (ret[3]) {
|
|
648
|
+
ptr3 = 0; len3 = 0;
|
|
649
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
650
|
+
}
|
|
651
|
+
deferred4_0 = ptr3;
|
|
652
|
+
deferred4_1 = len3;
|
|
653
|
+
return getStringFromWasm0(ptr3, len3);
|
|
654
|
+
} finally {
|
|
655
|
+
wasm.__wbindgen_free(deferred4_0, deferred4_1, 1);
|
|
656
|
+
}
|
|
657
|
+
}
|
|
658
|
+
|
|
371
659
|
/**
|
|
372
660
|
* The capability matrix as JSON: which `(formulation, operand, parameter)` cells this
|
|
373
661
|
* build supports, so the UI can populate menus and grey out the rest.
|
|
@@ -413,52 +701,18 @@ export function classify_json(bytes) {
|
|
|
413
701
|
}
|
|
414
702
|
}
|
|
415
703
|
|
|
416
|
-
/**
|
|
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
|
|
424
|
-
* @param {string} format
|
|
425
|
-
* @returns {string}
|
|
426
|
-
*/
|
|
427
|
-
export function export_study(package_json, commit, format) {
|
|
428
|
-
let deferred4_0;
|
|
429
|
-
let deferred4_1;
|
|
430
|
-
try {
|
|
431
|
-
const ptr0 = passStringToWasm0(package_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
432
|
-
const len0 = WASM_VECTOR_LEN;
|
|
433
|
-
const ptr1 = passStringToWasm0(format, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
434
|
-
const len1 = WASM_VECTOR_LEN;
|
|
435
|
-
const ret = wasm.export_study(ptr0, len0, commit, ptr1, len1);
|
|
436
|
-
var ptr3 = ret[0];
|
|
437
|
-
var len3 = ret[1];
|
|
438
|
-
if (ret[3]) {
|
|
439
|
-
ptr3 = 0; len3 = 0;
|
|
440
|
-
throw takeFromExternrefTable0(ret[2]);
|
|
441
|
-
}
|
|
442
|
-
deferred4_0 = ptr3;
|
|
443
|
-
deferred4_1 = len3;
|
|
444
|
-
return getStringFromWasm0(ptr3, len3);
|
|
445
|
-
} finally {
|
|
446
|
-
wasm.__wbindgen_free(deferred4_0, deferred4_1, 1);
|
|
447
|
-
}
|
|
448
|
-
}
|
|
449
|
-
|
|
450
704
|
/**
|
|
451
705
|
* A case's coordinates as a canonical `.geo.json` document (one point per
|
|
452
706
|
* located bus, one route per routed branch, provenance preserved). Errors
|
|
453
707
|
* when the case carries none.
|
|
454
|
-
* @param {string}
|
|
708
|
+
* @param {string} module_json
|
|
455
709
|
* @returns {string}
|
|
456
710
|
*/
|
|
457
|
-
export function extract_geo(
|
|
711
|
+
export function extract_geo(module_json) {
|
|
458
712
|
let deferred3_0;
|
|
459
713
|
let deferred3_1;
|
|
460
714
|
try {
|
|
461
|
-
const ptr0 = passStringToWasm0(
|
|
715
|
+
const ptr0 = passStringToWasm0(module_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
462
716
|
const len0 = WASM_VECTOR_LEN;
|
|
463
717
|
const ret = wasm.extract_geo(ptr0, len0);
|
|
464
718
|
var ptr2 = ret[0];
|
|
@@ -477,7 +731,7 @@ export function extract_geo(network_json) {
|
|
|
477
731
|
|
|
478
732
|
/**
|
|
479
733
|
* Everything the drop panel needs from one parse: counts, total load and
|
|
480
|
-
* capacity, parse
|
|
734
|
+
* capacity, parse diagnostics, and a `view` of buses and branches in the shape
|
|
481
735
|
* the tellegen API serves, placed at the coordinates the file carries
|
|
482
736
|
* (PowerWorld complete case aux exports). `view` is null when the file has no
|
|
483
737
|
* coordinates.
|
|
@@ -514,13 +768,14 @@ export function ingest_case(bytes, format) {
|
|
|
514
768
|
/**
|
|
515
769
|
* The distribution counterpart of [`ingest_case`]: view a multiconductor case
|
|
516
770
|
* with no solve. `format` is a distribution reader token (`dss`, `bmopf`,
|
|
517
|
-
* `pmd`) parsed by [`powerio_dist`], or `pio` for a `.pio.json`
|
|
518
|
-
*
|
|
519
|
-
*
|
|
771
|
+
* `pmd`) parsed by [`powerio_dist`], or `pio` for a `.pio.json` stored module
|
|
772
|
+
* holding a supported multiconductor network, instance, or solution. Returns
|
|
773
|
+
* the drop-panel payload JSON:
|
|
774
|
+
* name, element counts, connected load/generation (kW), parse diagnostics,
|
|
520
775
|
* coordinate provenance, and the bus/terminal graph the frontend renders (see
|
|
521
|
-
*
|
|
776
|
+
* the private `dist` adapter).
|
|
522
777
|
*
|
|
523
|
-
* Untrusted input: the parse and
|
|
778
|
+
* Untrusted input: the parse and module restore return error strings (mapped
|
|
524
779
|
* to `JsError` here), so a malformed, truncated, or oversized `.dss`/JSON
|
|
525
780
|
* rejects cleanly and never panics the wasm instance.
|
|
526
781
|
* @param {string} text
|
|
@@ -583,8 +838,9 @@ export function ingest_dist_case_bytes(bytes, format) {
|
|
|
583
838
|
* Classify and ingest one dropped JSON byte buffer. Known inputs return their
|
|
584
839
|
* render-ready payload; ambiguous and unknown documents return a null payload
|
|
585
840
|
* so the caller can request an explicit format without decoding the bytes a
|
|
586
|
-
* second time.
|
|
587
|
-
*
|
|
841
|
+
* second time. A stored module is read once and its value routed to the
|
|
842
|
+
* balanced or multiconductor view. The TS drop-classify layer must mirror
|
|
843
|
+
* the kinds (`module` and powerio's families).
|
|
588
844
|
* @param {Uint8Array} bytes
|
|
589
845
|
* @returns {string}
|
|
590
846
|
*/
|
|
@@ -610,102 +866,115 @@ export function ingest_json_drop(bytes) {
|
|
|
610
866
|
}
|
|
611
867
|
|
|
612
868
|
/**
|
|
613
|
-
*
|
|
614
|
-
*
|
|
615
|
-
*
|
|
616
|
-
*
|
|
617
|
-
*
|
|
618
|
-
*
|
|
869
|
+
* Parse a case file (MATPOWER, PSS/E RAW, PowerWorld aux, PowerModels or
|
|
870
|
+
* egret JSON) and return `{"network": ..., "diagnostics": [...]}` as JSON.
|
|
871
|
+
*
|
|
872
|
+
* Takes the upload's bytes, not decoded text: powerio refuses a text format
|
|
873
|
+
* whose bytes are not UTF-8, where a browser side `File.text()` would have
|
|
874
|
+
* replaced each offending byte with U+FFFD and parsed on. It also reaches
|
|
875
|
+
* PowerWorld `.pwb`, which has no text form at all.
|
|
876
|
+
* @param {Uint8Array} bytes
|
|
877
|
+
* @param {string} format
|
|
619
878
|
* @returns {string}
|
|
620
879
|
*/
|
|
621
|
-
export function
|
|
622
|
-
let
|
|
623
|
-
let
|
|
880
|
+
export function parse_case(bytes, format) {
|
|
881
|
+
let deferred4_0;
|
|
882
|
+
let deferred4_1;
|
|
624
883
|
try {
|
|
625
|
-
const ptr0 =
|
|
884
|
+
const ptr0 = passArray8ToWasm0(bytes, wasm.__wbindgen_malloc);
|
|
626
885
|
const len0 = WASM_VECTOR_LEN;
|
|
627
|
-
const
|
|
628
|
-
|
|
629
|
-
|
|
886
|
+
const ptr1 = passStringToWasm0(format, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
887
|
+
const len1 = WASM_VECTOR_LEN;
|
|
888
|
+
const ret = wasm.parse_case(ptr0, len0, ptr1, len1);
|
|
889
|
+
var ptr3 = ret[0];
|
|
890
|
+
var len3 = ret[1];
|
|
630
891
|
if (ret[3]) {
|
|
631
|
-
|
|
892
|
+
ptr3 = 0; len3 = 0;
|
|
632
893
|
throw takeFromExternrefTable0(ret[2]);
|
|
633
894
|
}
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
return getStringFromWasm0(
|
|
895
|
+
deferred4_0 = ptr3;
|
|
896
|
+
deferred4_1 = len3;
|
|
897
|
+
return getStringFromWasm0(ptr3, len3);
|
|
637
898
|
} finally {
|
|
638
|
-
wasm.__wbindgen_free(
|
|
899
|
+
wasm.__wbindgen_free(deferred4_0, deferred4_1, 1);
|
|
639
900
|
}
|
|
640
901
|
}
|
|
641
902
|
|
|
642
903
|
/**
|
|
643
|
-
*
|
|
644
|
-
* and model validation both stay in powerio.
|
|
904
|
+
* Decode a PowerWorld drawing as a canonical PowerIO GeoLayer in diagram units.
|
|
645
905
|
* @param {Uint8Array} bytes
|
|
906
|
+
* @param {string} format
|
|
646
907
|
* @returns {string}
|
|
647
908
|
*/
|
|
648
|
-
export function
|
|
649
|
-
let
|
|
650
|
-
let
|
|
909
|
+
export function parse_display(bytes, format) {
|
|
910
|
+
let deferred4_0;
|
|
911
|
+
let deferred4_1;
|
|
651
912
|
try {
|
|
652
913
|
const ptr0 = passArray8ToWasm0(bytes, wasm.__wbindgen_malloc);
|
|
653
914
|
const len0 = WASM_VECTOR_LEN;
|
|
654
|
-
const
|
|
655
|
-
|
|
656
|
-
|
|
915
|
+
const ptr1 = passStringToWasm0(format, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
916
|
+
const len1 = WASM_VECTOR_LEN;
|
|
917
|
+
const ret = wasm.parse_display(ptr0, len0, ptr1, len1);
|
|
918
|
+
var ptr3 = ret[0];
|
|
919
|
+
var len3 = ret[1];
|
|
657
920
|
if (ret[3]) {
|
|
658
|
-
|
|
921
|
+
ptr3 = 0; len3 = 0;
|
|
659
922
|
throw takeFromExternrefTable0(ret[2]);
|
|
660
923
|
}
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
return getStringFromWasm0(
|
|
924
|
+
deferred4_0 = ptr3;
|
|
925
|
+
deferred4_1 = len3;
|
|
926
|
+
return getStringFromWasm0(ptr3, len3);
|
|
664
927
|
} finally {
|
|
665
|
-
wasm.__wbindgen_free(
|
|
928
|
+
wasm.__wbindgen_free(deferred4_0, deferred4_1, 1);
|
|
666
929
|
}
|
|
667
930
|
}
|
|
668
931
|
|
|
669
932
|
/**
|
|
670
|
-
*
|
|
671
|
-
*
|
|
672
|
-
*
|
|
673
|
-
*
|
|
933
|
+
* Parse a geographic sidecar (buscoords CSV, aliased CSV/JSON records,
|
|
934
|
+
* GeoJSON) from raw dropped bytes; `hint` is the file name ("" to sniff).
|
|
935
|
+
* Returns `{ layer, diagnostics, n_points, n_routes }` — the layer as its
|
|
936
|
+
* canonical `.geo.json` document, ready for [`apply_geo`]. Untrusted input
|
|
937
|
+
* rejects as a `JsError`, never a panic.
|
|
938
|
+
* @param {Uint8Array} bytes
|
|
939
|
+
* @param {string} hint
|
|
674
940
|
* @returns {string}
|
|
675
941
|
*/
|
|
676
|
-
export function
|
|
677
|
-
let
|
|
678
|
-
let
|
|
942
|
+
export function parse_geo(bytes, hint) {
|
|
943
|
+
let deferred4_0;
|
|
944
|
+
let deferred4_1;
|
|
679
945
|
try {
|
|
680
|
-
const ptr0 =
|
|
946
|
+
const ptr0 = passArray8ToWasm0(bytes, wasm.__wbindgen_malloc);
|
|
681
947
|
const len0 = WASM_VECTOR_LEN;
|
|
682
|
-
const
|
|
683
|
-
|
|
684
|
-
|
|
948
|
+
const ptr1 = passStringToWasm0(hint, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
949
|
+
const len1 = WASM_VECTOR_LEN;
|
|
950
|
+
const ret = wasm.parse_geo(ptr0, len0, ptr1, len1);
|
|
951
|
+
var ptr3 = ret[0];
|
|
952
|
+
var len3 = ret[1];
|
|
685
953
|
if (ret[3]) {
|
|
686
|
-
|
|
954
|
+
ptr3 = 0; len3 = 0;
|
|
687
955
|
throw takeFromExternrefTable0(ret[2]);
|
|
688
956
|
}
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
return getStringFromWasm0(
|
|
957
|
+
deferred4_0 = ptr3;
|
|
958
|
+
deferred4_1 = len3;
|
|
959
|
+
return getStringFromWasm0(ptr3, len3);
|
|
692
960
|
} finally {
|
|
693
|
-
wasm.__wbindgen_free(
|
|
961
|
+
wasm.__wbindgen_free(deferred4_0, deferred4_1, 1);
|
|
694
962
|
}
|
|
695
963
|
}
|
|
696
964
|
|
|
697
965
|
/**
|
|
698
|
-
*
|
|
699
|
-
*
|
|
966
|
+
* Validate and canonicalize a saved multiconductor Study snapshot without
|
|
967
|
+
* re-solving it.
|
|
968
|
+
* @param {string} snapshot_json
|
|
700
969
|
* @returns {string}
|
|
701
970
|
*/
|
|
702
|
-
export function
|
|
971
|
+
export function replay_mc_study(snapshot_json) {
|
|
703
972
|
let deferred3_0;
|
|
704
973
|
let deferred3_1;
|
|
705
974
|
try {
|
|
706
|
-
const ptr0 =
|
|
975
|
+
const ptr0 = passStringToWasm0(snapshot_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
707
976
|
const len0 = WASM_VECTOR_LEN;
|
|
708
|
-
const ret = wasm.
|
|
977
|
+
const ret = wasm.replay_mc_study(ptr0, len0);
|
|
709
978
|
var ptr2 = ret[0];
|
|
710
979
|
var len2 = ret[1];
|
|
711
980
|
if (ret[3]) {
|
|
@@ -721,26 +990,22 @@ export function load_package_bytes(bytes) {
|
|
|
721
990
|
}
|
|
722
991
|
|
|
723
992
|
/**
|
|
724
|
-
*
|
|
725
|
-
*
|
|
726
|
-
*
|
|
727
|
-
*
|
|
728
|
-
*
|
|
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
|
|
993
|
+
* Solve a raw BMOPF multiconductor constant-power case. The parser and
|
|
994
|
+
* fixed-point implementation remain in the engine crate; this export only
|
|
995
|
+
* performs the bounded text/JSON conversion at the browser boundary.
|
|
996
|
+
* @param {string} text
|
|
997
|
+
* @param {string} options_json
|
|
733
998
|
* @returns {string}
|
|
734
999
|
*/
|
|
735
|
-
export function
|
|
1000
|
+
export function solve_mc_bmopf(text, options_json) {
|
|
736
1001
|
let deferred4_0;
|
|
737
1002
|
let deferred4_1;
|
|
738
1003
|
try {
|
|
739
|
-
const ptr0 =
|
|
1004
|
+
const ptr0 = passStringToWasm0(text, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
740
1005
|
const len0 = WASM_VECTOR_LEN;
|
|
741
|
-
const ptr1 = passStringToWasm0(
|
|
1006
|
+
const ptr1 = passStringToWasm0(options_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
742
1007
|
const len1 = WASM_VECTOR_LEN;
|
|
743
|
-
const ret = wasm.
|
|
1008
|
+
const ret = wasm.solve_mc_bmopf(ptr0, len0, ptr1, len1);
|
|
744
1009
|
var ptr3 = ret[0];
|
|
745
1010
|
var len3 = ret[1];
|
|
746
1011
|
if (ret[3]) {
|
|
@@ -756,25 +1021,21 @@ export function parse_case(bytes, format) {
|
|
|
756
1021
|
}
|
|
757
1022
|
|
|
758
1023
|
/**
|
|
759
|
-
*
|
|
760
|
-
*
|
|
761
|
-
*
|
|
762
|
-
*
|
|
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
|
|
1024
|
+
* Solve a stored PowerIO multiconductor module. This accepts the portable
|
|
1025
|
+
* module form used by browser persistence in addition to raw BMOPF text.
|
|
1026
|
+
* @param {string} module_json
|
|
1027
|
+
* @param {string} options_json
|
|
767
1028
|
* @returns {string}
|
|
768
1029
|
*/
|
|
769
|
-
export function
|
|
1030
|
+
export function solve_mc_module(module_json, options_json) {
|
|
770
1031
|
let deferred4_0;
|
|
771
1032
|
let deferred4_1;
|
|
772
1033
|
try {
|
|
773
|
-
const ptr0 =
|
|
1034
|
+
const ptr0 = passStringToWasm0(module_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
774
1035
|
const len0 = WASM_VECTOR_LEN;
|
|
775
|
-
const ptr1 = passStringToWasm0(
|
|
1036
|
+
const ptr1 = passStringToWasm0(options_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
776
1037
|
const len1 = WASM_VECTOR_LEN;
|
|
777
|
-
const ret = wasm.
|
|
1038
|
+
const ret = wasm.solve_mc_module(ptr0, len0, ptr1, len1);
|
|
778
1039
|
var ptr3 = ret[0];
|
|
779
1040
|
var len3 = ret[1];
|
|
780
1041
|
if (ret[3]) {
|
|
@@ -790,55 +1051,59 @@ export function parse_display(bytes, format) {
|
|
|
790
1051
|
}
|
|
791
1052
|
|
|
792
1053
|
/**
|
|
793
|
-
*
|
|
794
|
-
*
|
|
795
|
-
*
|
|
796
|
-
*
|
|
797
|
-
*
|
|
798
|
-
* @param {
|
|
799
|
-
* @param {string}
|
|
1054
|
+
* Solve a supported multiconductor Study input and return a self-contained,
|
|
1055
|
+
* replayable snapshot containing the typed input, PowerIO solution module, and
|
|
1056
|
+
* terminal-aware result view.
|
|
1057
|
+
* @param {string} module_json
|
|
1058
|
+
* @param {string} study_id
|
|
1059
|
+
* @param {string} study_title
|
|
1060
|
+
* @param {string} options_json
|
|
800
1061
|
* @returns {string}
|
|
801
1062
|
*/
|
|
802
|
-
export function
|
|
803
|
-
let
|
|
804
|
-
let
|
|
1063
|
+
export function solve_mc_study(module_json, study_id, study_title, options_json) {
|
|
1064
|
+
let deferred6_0;
|
|
1065
|
+
let deferred6_1;
|
|
805
1066
|
try {
|
|
806
|
-
const ptr0 =
|
|
1067
|
+
const ptr0 = passStringToWasm0(module_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
807
1068
|
const len0 = WASM_VECTOR_LEN;
|
|
808
|
-
const ptr1 = passStringToWasm0(
|
|
1069
|
+
const ptr1 = passStringToWasm0(study_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
809
1070
|
const len1 = WASM_VECTOR_LEN;
|
|
810
|
-
const
|
|
811
|
-
|
|
812
|
-
|
|
1071
|
+
const ptr2 = passStringToWasm0(study_title, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
1072
|
+
const len2 = WASM_VECTOR_LEN;
|
|
1073
|
+
const ptr3 = passStringToWasm0(options_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
1074
|
+
const len3 = WASM_VECTOR_LEN;
|
|
1075
|
+
const ret = wasm.solve_mc_study(ptr0, len0, ptr1, len1, ptr2, len2, ptr3, len3);
|
|
1076
|
+
var ptr5 = ret[0];
|
|
1077
|
+
var len5 = ret[1];
|
|
813
1078
|
if (ret[3]) {
|
|
814
|
-
|
|
1079
|
+
ptr5 = 0; len5 = 0;
|
|
815
1080
|
throw takeFromExternrefTable0(ret[2]);
|
|
816
1081
|
}
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
return getStringFromWasm0(
|
|
1082
|
+
deferred6_0 = ptr5;
|
|
1083
|
+
deferred6_1 = len5;
|
|
1084
|
+
return getStringFromWasm0(ptr5, len5);
|
|
820
1085
|
} finally {
|
|
821
|
-
wasm.__wbindgen_free(
|
|
1086
|
+
wasm.__wbindgen_free(deferred6_0, deferred6_1, 1);
|
|
822
1087
|
}
|
|
823
1088
|
}
|
|
824
1089
|
|
|
825
1090
|
/**
|
|
826
|
-
* The stateless solve front door: a
|
|
827
|
-
* in, a [`SolveResponse`]
|
|
1091
|
+
* The stateless solve front door: a retained PowerIO module and a
|
|
1092
|
+
* [`tellegen::SolveRequest`] JSON in, a [`tellegen::SolveResponse`] JSON out. One-shot callers only;
|
|
828
1093
|
* the reactive hot path is the [`Study`].
|
|
829
|
-
* @param {string}
|
|
1094
|
+
* @param {string} module_json
|
|
830
1095
|
* @param {string} request_json
|
|
831
1096
|
* @returns {string}
|
|
832
1097
|
*/
|
|
833
|
-
export function
|
|
1098
|
+
export function solve_module(module_json, request_json) {
|
|
834
1099
|
let deferred4_0;
|
|
835
1100
|
let deferred4_1;
|
|
836
1101
|
try {
|
|
837
|
-
const ptr0 = passStringToWasm0(
|
|
1102
|
+
const ptr0 = passStringToWasm0(module_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
838
1103
|
const len0 = WASM_VECTOR_LEN;
|
|
839
1104
|
const ptr1 = passStringToWasm0(request_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
840
1105
|
const len1 = WASM_VECTOR_LEN;
|
|
841
|
-
const ret = wasm.
|
|
1106
|
+
const ret = wasm.solve_module(ptr0, len0, ptr1, len1);
|
|
842
1107
|
var ptr3 = ret[0];
|
|
843
1108
|
var len3 = ret[1];
|
|
844
1109
|
if (ret[3]) {
|
|
@@ -852,21 +1117,109 @@ export function solve_json(network_json, request_json) {
|
|
|
852
1117
|
wasm.__wbindgen_free(deferred4_0, deferred4_1, 1);
|
|
853
1118
|
}
|
|
854
1119
|
}
|
|
1120
|
+
|
|
1121
|
+
/**
|
|
1122
|
+
* Create a portable application Study through the shared native controller.
|
|
1123
|
+
* @param {string} request_json
|
|
1124
|
+
* @returns {string}
|
|
1125
|
+
*/
|
|
1126
|
+
export function study_document_create(request_json) {
|
|
1127
|
+
let deferred3_0;
|
|
1128
|
+
let deferred3_1;
|
|
1129
|
+
try {
|
|
1130
|
+
const ptr0 = passStringToWasm0(request_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
1131
|
+
const len0 = WASM_VECTOR_LEN;
|
|
1132
|
+
const ret = wasm.study_document_create(ptr0, len0);
|
|
1133
|
+
var ptr2 = ret[0];
|
|
1134
|
+
var len2 = ret[1];
|
|
1135
|
+
if (ret[3]) {
|
|
1136
|
+
ptr2 = 0; len2 = 0;
|
|
1137
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
1138
|
+
}
|
|
1139
|
+
deferred3_0 = ptr2;
|
|
1140
|
+
deferred3_1 = len2;
|
|
1141
|
+
return getStringFromWasm0(ptr2, len2);
|
|
1142
|
+
} finally {
|
|
1143
|
+
wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
|
|
1144
|
+
}
|
|
1145
|
+
}
|
|
1146
|
+
|
|
1147
|
+
/**
|
|
1148
|
+
* Validate and normalize a portable bundle without executing its contents.
|
|
1149
|
+
* @param {string} bundle_json
|
|
1150
|
+
* @returns {string}
|
|
1151
|
+
*/
|
|
1152
|
+
export function study_document_import(bundle_json) {
|
|
1153
|
+
let deferred3_0;
|
|
1154
|
+
let deferred3_1;
|
|
1155
|
+
try {
|
|
1156
|
+
const ptr0 = passStringToWasm0(bundle_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
1157
|
+
const len0 = WASM_VECTOR_LEN;
|
|
1158
|
+
const ret = wasm.study_document_import(ptr0, len0);
|
|
1159
|
+
var ptr2 = ret[0];
|
|
1160
|
+
var len2 = ret[1];
|
|
1161
|
+
if (ret[3]) {
|
|
1162
|
+
ptr2 = 0; len2 = 0;
|
|
1163
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
1164
|
+
}
|
|
1165
|
+
deferred3_0 = ptr2;
|
|
1166
|
+
deferred3_1 = len2;
|
|
1167
|
+
return getStringFromWasm0(ptr2, len2);
|
|
1168
|
+
} finally {
|
|
1169
|
+
wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
|
|
1170
|
+
}
|
|
1171
|
+
}
|
|
1172
|
+
|
|
1173
|
+
/**
|
|
1174
|
+
* Execute a revision-checked Study operation and return the completed bundle.
|
|
1175
|
+
* @param {string} bundle_json
|
|
1176
|
+
* @param {string} request_json
|
|
1177
|
+
* @param {Function} cancelled
|
|
1178
|
+
* @returns {Promise<string>}
|
|
1179
|
+
*/
|
|
1180
|
+
export function study_document_run(bundle_json, request_json, cancelled) {
|
|
1181
|
+
const ptr0 = passStringToWasm0(bundle_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
1182
|
+
const len0 = WASM_VECTOR_LEN;
|
|
1183
|
+
const ptr1 = passStringToWasm0(request_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
1184
|
+
const len1 = WASM_VECTOR_LEN;
|
|
1185
|
+
const ret = wasm.study_document_run(ptr0, len0, ptr1, len1, cancelled);
|
|
1186
|
+
return ret;
|
|
1187
|
+
}
|
|
855
1188
|
function __wbg_get_imports() {
|
|
856
1189
|
const import0 = {
|
|
857
1190
|
__proto__: null,
|
|
858
|
-
|
|
1191
|
+
__wbg_Error_67e7344beaa85059: function(arg0, arg1) {
|
|
859
1192
|
const ret = Error(getStringFromWasm0(arg0, arg1));
|
|
860
1193
|
return ret;
|
|
861
1194
|
},
|
|
862
|
-
|
|
1195
|
+
__wbg___wbindgen_boolean_get_7a12af2b3f899c5a: function(arg0) {
|
|
1196
|
+
const v = arg0;
|
|
1197
|
+
const ret = typeof(v) === 'boolean' ? v : undefined;
|
|
1198
|
+
return isLikeNone(ret) ? 0xFFFFFF : ret ? 1 : 0;
|
|
1199
|
+
},
|
|
1200
|
+
__wbg___wbindgen_is_function_fcda5e3902d732fe: function(arg0) {
|
|
1201
|
+
const ret = typeof(arg0) === 'function';
|
|
1202
|
+
return ret;
|
|
1203
|
+
},
|
|
1204
|
+
__wbg___wbindgen_is_undefined_8c687d0b90d5b524: function(arg0) {
|
|
863
1205
|
const ret = arg0 === undefined;
|
|
864
1206
|
return ret;
|
|
865
1207
|
},
|
|
866
|
-
|
|
1208
|
+
__wbg___wbindgen_throw_5d9e815e6fdf150f: function(arg0, arg1) {
|
|
867
1209
|
throw new Error(getStringFromWasm0(arg0, arg1));
|
|
868
1210
|
},
|
|
869
|
-
|
|
1211
|
+
__wbg__wbg_cb_unref_997e73d32238e655: function(arg0) {
|
|
1212
|
+
arg0._wbg_cb_unref();
|
|
1213
|
+
},
|
|
1214
|
+
__wbg_call_269c5566fbede3eb: function() { return handleError(function (arg0, arg1) {
|
|
1215
|
+
const ret = arg0.call(arg1);
|
|
1216
|
+
return ret;
|
|
1217
|
+
}, arguments); },
|
|
1218
|
+
__wbg_call_6bcf8d3e20937e46: function() { return handleError(function (arg0, arg1, arg2) {
|
|
1219
|
+
const ret = arg0.call(arg1, arg2);
|
|
1220
|
+
return ret;
|
|
1221
|
+
}, arguments); },
|
|
1222
|
+
__wbg_error_757e9472f8410341: function(arg0, arg1) {
|
|
870
1223
|
let deferred0_0;
|
|
871
1224
|
let deferred0_1;
|
|
872
1225
|
try {
|
|
@@ -881,6 +1234,42 @@ function __wbg_get_imports() {
|
|
|
881
1234
|
const ret = new Error();
|
|
882
1235
|
return ret;
|
|
883
1236
|
},
|
|
1237
|
+
__wbg_new_8f72ed7c652bf5a2: function(arg0, arg1) {
|
|
1238
|
+
try {
|
|
1239
|
+
var state0 = {a: arg0, b: arg1};
|
|
1240
|
+
var cb0 = (arg0, arg1) => {
|
|
1241
|
+
const a = state0.a;
|
|
1242
|
+
state0.a = 0;
|
|
1243
|
+
try {
|
|
1244
|
+
return wasm_bindgen__convert__closures_____invoke__h0178a8f776e4ef73(a, state0.b, arg0, arg1);
|
|
1245
|
+
} finally {
|
|
1246
|
+
state0.a = a;
|
|
1247
|
+
}
|
|
1248
|
+
};
|
|
1249
|
+
const ret = new Promise(cb0);
|
|
1250
|
+
return ret;
|
|
1251
|
+
} finally {
|
|
1252
|
+
state0.a = 0;
|
|
1253
|
+
}
|
|
1254
|
+
},
|
|
1255
|
+
__wbg_new_typed_6f8b0d724fe26c07: function(arg0, arg1) {
|
|
1256
|
+
try {
|
|
1257
|
+
var state0 = {a: arg0, b: arg1};
|
|
1258
|
+
var cb0 = (arg0, arg1) => {
|
|
1259
|
+
const a = state0.a;
|
|
1260
|
+
state0.a = 0;
|
|
1261
|
+
try {
|
|
1262
|
+
return wasm_bindgen__convert__closures_____invoke__h0178a8f776e4ef73(a, state0.b, arg0, arg1);
|
|
1263
|
+
} finally {
|
|
1264
|
+
state0.a = a;
|
|
1265
|
+
}
|
|
1266
|
+
};
|
|
1267
|
+
const ret = new Promise(cb0);
|
|
1268
|
+
return ret;
|
|
1269
|
+
} finally {
|
|
1270
|
+
state0.a = 0;
|
|
1271
|
+
}
|
|
1272
|
+
},
|
|
884
1273
|
__wbg_now_cace042f68c814d8: function(arg0) {
|
|
885
1274
|
const ret = arg0.now();
|
|
886
1275
|
return ret;
|
|
@@ -889,6 +1278,20 @@ function __wbg_get_imports() {
|
|
|
889
1278
|
const ret = arg0.performance;
|
|
890
1279
|
return ret;
|
|
891
1280
|
},
|
|
1281
|
+
__wbg_queueMicrotask_85c90f6987555d65: function(arg0) {
|
|
1282
|
+
const ret = arg0.queueMicrotask;
|
|
1283
|
+
return ret;
|
|
1284
|
+
},
|
|
1285
|
+
__wbg_queueMicrotask_f6a1fa10b81d1fc0: function(arg0) {
|
|
1286
|
+
queueMicrotask(arg0);
|
|
1287
|
+
},
|
|
1288
|
+
__wbg_resolve_35ec7e0c6af4c82c: function(arg0) {
|
|
1289
|
+
const ret = Promise.resolve(arg0);
|
|
1290
|
+
return ret;
|
|
1291
|
+
},
|
|
1292
|
+
__wbg_setTimeout_b92adebff51f057a: function(arg0, arg1) {
|
|
1293
|
+
setTimeout(arg0, arg1);
|
|
1294
|
+
},
|
|
892
1295
|
__wbg_stack_3b0d974bbf31e44f: function(arg0, arg1) {
|
|
893
1296
|
const ret = arg1.stack;
|
|
894
1297
|
const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
@@ -896,22 +1299,40 @@ function __wbg_get_imports() {
|
|
|
896
1299
|
getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
|
|
897
1300
|
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
|
|
898
1301
|
},
|
|
899
|
-
|
|
900
|
-
const ret = typeof
|
|
1302
|
+
__wbg_static_accessor_GLOBAL_8eb4cd83130a11a0: function() {
|
|
1303
|
+
const ret = typeof global === 'undefined' ? null : global;
|
|
901
1304
|
return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
|
|
902
1305
|
},
|
|
903
|
-
|
|
904
|
-
const ret = typeof
|
|
1306
|
+
__wbg_static_accessor_GLOBAL_THIS_1e7044f654e934db: function() {
|
|
1307
|
+
const ret = typeof globalThis === 'undefined' ? null : globalThis;
|
|
905
1308
|
return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
|
|
906
1309
|
},
|
|
907
|
-
|
|
1310
|
+
__wbg_static_accessor_SELF_d8b50611246a6d92: function() {
|
|
908
1311
|
const ret = typeof self === 'undefined' ? null : self;
|
|
909
1312
|
return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
|
|
910
1313
|
},
|
|
911
|
-
|
|
1314
|
+
__wbg_static_accessor_WINDOW_fd0bc376bf0f8b42: function() {
|
|
912
1315
|
const ret = typeof window === 'undefined' ? null : window;
|
|
913
1316
|
return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
|
|
914
1317
|
},
|
|
1318
|
+
__wbg_then_7a850dae4493f353: function(arg0, arg1, arg2) {
|
|
1319
|
+
const ret = arg0.then(arg1, arg2);
|
|
1320
|
+
return ret;
|
|
1321
|
+
},
|
|
1322
|
+
__wbg_then_b830475380919203: function(arg0, arg1) {
|
|
1323
|
+
const ret = arg0.then(arg1);
|
|
1324
|
+
return ret;
|
|
1325
|
+
},
|
|
1326
|
+
__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);
|
|
1329
|
+
return ret;
|
|
1330
|
+
},
|
|
1331
|
+
__wbindgen_generic_0000000000000002: function(arg0, arg1) {
|
|
1332
|
+
// Cast intrinsic for `Ref(String) -> Externref`.
|
|
1333
|
+
const ret = getStringFromWasm0(arg0, arg1);
|
|
1334
|
+
return ret;
|
|
1335
|
+
},
|
|
915
1336
|
__wbindgen_init_externref_table: function() {
|
|
916
1337
|
const table = wasm.__wbindgen_externrefs;
|
|
917
1338
|
const offset = table.grow(4);
|
|
@@ -928,6 +1349,20 @@ function __wbg_get_imports() {
|
|
|
928
1349
|
};
|
|
929
1350
|
}
|
|
930
1351
|
|
|
1352
|
+
function wasm_bindgen__convert__closures_____invoke__h42fc1c09ce4112c3(arg0, arg1, arg2) {
|
|
1353
|
+
const ret = wasm.wasm_bindgen__convert__closures_____invoke__h42fc1c09ce4112c3(arg0, arg1, arg2);
|
|
1354
|
+
if (ret[1]) {
|
|
1355
|
+
throw takeFromExternrefTable0(ret[0]);
|
|
1356
|
+
}
|
|
1357
|
+
}
|
|
1358
|
+
|
|
1359
|
+
function wasm_bindgen__convert__closures_____invoke__h0178a8f776e4ef73(arg0, arg1, arg2, arg3) {
|
|
1360
|
+
wasm.wasm_bindgen__convert__closures_____invoke__h0178a8f776e4ef73(arg0, arg1, arg2, arg3);
|
|
1361
|
+
}
|
|
1362
|
+
|
|
1363
|
+
const McPfSessionFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
1364
|
+
? { register: () => {}, unregister: () => {} }
|
|
1365
|
+
: new FinalizationRegistry(ptr => wasm.__wbg_mcpfsession_free(ptr, 1));
|
|
931
1366
|
const StudyFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
932
1367
|
? { register: () => {}, unregister: () => {} }
|
|
933
1368
|
: new FinalizationRegistry(ptr => wasm.__wbg_study_free(ptr, 1));
|
|
@@ -938,6 +1373,10 @@ function addToExternrefTable0(obj) {
|
|
|
938
1373
|
return idx;
|
|
939
1374
|
}
|
|
940
1375
|
|
|
1376
|
+
const CLOSURE_DTORS = (typeof FinalizationRegistry === 'undefined')
|
|
1377
|
+
? { register: () => {}, unregister: () => {} }
|
|
1378
|
+
: new FinalizationRegistry(state => wasm.__wbindgen_destroy_closure(state.a, state.b));
|
|
1379
|
+
|
|
941
1380
|
let cachedDataViewMemory0 = null;
|
|
942
1381
|
function getDataViewMemory0() {
|
|
943
1382
|
if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || (cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm.memory.buffer)) {
|
|
@@ -958,10 +1397,47 @@ function getUint8ArrayMemory0() {
|
|
|
958
1397
|
return cachedUint8ArrayMemory0;
|
|
959
1398
|
}
|
|
960
1399
|
|
|
1400
|
+
function handleError(f, args) {
|
|
1401
|
+
try {
|
|
1402
|
+
return f.apply(this, args);
|
|
1403
|
+
} catch (e) {
|
|
1404
|
+
const idx = addToExternrefTable0(e);
|
|
1405
|
+
wasm.__wbindgen_exn_store(idx);
|
|
1406
|
+
}
|
|
1407
|
+
}
|
|
1408
|
+
|
|
961
1409
|
function isLikeNone(x) {
|
|
962
1410
|
return x === undefined || x === null;
|
|
963
1411
|
}
|
|
964
1412
|
|
|
1413
|
+
function makeMutClosure(arg0, arg1, f) {
|
|
1414
|
+
const state = { a: arg0, b: arg1, cnt: 1 };
|
|
1415
|
+
const real = (...args) => {
|
|
1416
|
+
|
|
1417
|
+
// First up with a closure we increment the internal reference
|
|
1418
|
+
// count. This ensures that the Rust closure environment won't
|
|
1419
|
+
// be deallocated while we're invoking it.
|
|
1420
|
+
state.cnt++;
|
|
1421
|
+
const a = state.a;
|
|
1422
|
+
state.a = 0;
|
|
1423
|
+
try {
|
|
1424
|
+
return f(a, state.b, ...args);
|
|
1425
|
+
} finally {
|
|
1426
|
+
state.a = a;
|
|
1427
|
+
real._wbg_cb_unref();
|
|
1428
|
+
}
|
|
1429
|
+
};
|
|
1430
|
+
real._wbg_cb_unref = () => {
|
|
1431
|
+
if (--state.cnt === 0) {
|
|
1432
|
+
wasm.__wbindgen_destroy_closure(state.a, state.b);
|
|
1433
|
+
state.a = 0;
|
|
1434
|
+
CLOSURE_DTORS.unregister(state);
|
|
1435
|
+
}
|
|
1436
|
+
};
|
|
1437
|
+
CLOSURE_DTORS.register(real, state, state);
|
|
1438
|
+
return real;
|
|
1439
|
+
}
|
|
1440
|
+
|
|
965
1441
|
function passArray8ToWasm0(arg, malloc) {
|
|
966
1442
|
const ptr = malloc(arg.length * 1, 1) >>> 0;
|
|
967
1443
|
getUint8ArrayMemory0().set(arg, ptr / 1);
|
|
@@ -1054,11 +1530,15 @@ function __wbg_finalize_init(instance, module) {
|
|
|
1054
1530
|
|
|
1055
1531
|
async function __wbg_load(module, imports) {
|
|
1056
1532
|
if (typeof Response === 'function' && module instanceof Response) {
|
|
1533
|
+
if (!module.ok) {
|
|
1534
|
+
throw new Error(`failed to fetch Wasm: ${module.status} ${module.statusText} fetching '${module.url}'`);
|
|
1535
|
+
}
|
|
1536
|
+
|
|
1057
1537
|
if (typeof WebAssembly.instantiateStreaming === 'function') {
|
|
1058
1538
|
try {
|
|
1059
1539
|
return await WebAssembly.instantiateStreaming(module, imports);
|
|
1060
1540
|
} catch (e) {
|
|
1061
|
-
const validResponse =
|
|
1541
|
+
const validResponse = expectedResponseType(module.type);
|
|
1062
1542
|
|
|
1063
1543
|
if (validResponse && module.headers.get('Content-Type') !== 'application/wasm') {
|
|
1064
1544
|
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);
|