@tellegen/engine 0.1.1 → 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 +50 -6
- package/dist/generated/contracts.d.ts +35 -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 +71 -17
- package/dist/host.js.map +1 -1
- package/dist/index.d.ts +360 -96
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +407 -89
- package/dist/index.js.map +1 -1
- package/dist/input-limit.d.ts +8 -0
- package/dist/input-limit.d.ts.map +1 -0
- package/dist/input-limit.js +14 -0
- package/dist/input-limit.js.map +1 -0
- 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 +105 -20
- package/dist/protocol.d.ts.map +1 -1
- package/dist/protocol.js +67 -18
- 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 +191 -55
- package/dist/wasm-pkg/tellegen.js +754 -97
- package/dist/wasm-pkg/tellegen_bg.wasm +0 -0
- package/dist/wasm-pkg/tellegen_bg.wasm.d.ts +30 -6
- package/dist/worker.js +27 -3
- package/dist/worker.js.map +1 -1
- package/package.json +26 -4
|
@@ -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.
|
|
@@ -387,36 +675,29 @@ export function capabilities_json() {
|
|
|
387
675
|
}
|
|
388
676
|
|
|
389
677
|
/**
|
|
390
|
-
*
|
|
391
|
-
*
|
|
392
|
-
*
|
|
393
|
-
* frontend can surface them, and the format token and file extension. The package
|
|
394
|
-
* JSON is untrusted; malformed input returns a `JsError`, never a panic.
|
|
395
|
-
* @param {string} package_json
|
|
396
|
-
* @param {number} commit
|
|
397
|
-
* @param {string} format
|
|
678
|
+
* Classify JSON bytes for the browser drop router. Invalid UTF-8 is never
|
|
679
|
+
* replaced; it follows powerio's unknown classification.
|
|
680
|
+
* @param {Uint8Array} bytes
|
|
398
681
|
* @returns {string}
|
|
399
682
|
*/
|
|
400
|
-
export function
|
|
401
|
-
let
|
|
402
|
-
let
|
|
683
|
+
export function classify_json(bytes) {
|
|
684
|
+
let deferred3_0;
|
|
685
|
+
let deferred3_1;
|
|
403
686
|
try {
|
|
404
|
-
const ptr0 =
|
|
687
|
+
const ptr0 = passArray8ToWasm0(bytes, wasm.__wbindgen_malloc);
|
|
405
688
|
const len0 = WASM_VECTOR_LEN;
|
|
406
|
-
const
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
var ptr3 = ret[0];
|
|
410
|
-
var len3 = ret[1];
|
|
689
|
+
const ret = wasm.classify_json(ptr0, len0);
|
|
690
|
+
var ptr2 = ret[0];
|
|
691
|
+
var len2 = ret[1];
|
|
411
692
|
if (ret[3]) {
|
|
412
|
-
|
|
693
|
+
ptr2 = 0; len2 = 0;
|
|
413
694
|
throw takeFromExternrefTable0(ret[2]);
|
|
414
695
|
}
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
return getStringFromWasm0(
|
|
696
|
+
deferred3_0 = ptr2;
|
|
697
|
+
deferred3_1 = len2;
|
|
698
|
+
return getStringFromWasm0(ptr2, len2);
|
|
418
699
|
} finally {
|
|
419
|
-
wasm.__wbindgen_free(
|
|
700
|
+
wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
|
|
420
701
|
}
|
|
421
702
|
}
|
|
422
703
|
|
|
@@ -424,14 +705,14 @@ export function export_study(package_json, commit, format) {
|
|
|
424
705
|
* A case's coordinates as a canonical `.geo.json` document (one point per
|
|
425
706
|
* located bus, one route per routed branch, provenance preserved). Errors
|
|
426
707
|
* when the case carries none.
|
|
427
|
-
* @param {string}
|
|
708
|
+
* @param {string} module_json
|
|
428
709
|
* @returns {string}
|
|
429
710
|
*/
|
|
430
|
-
export function extract_geo(
|
|
711
|
+
export function extract_geo(module_json) {
|
|
431
712
|
let deferred3_0;
|
|
432
713
|
let deferred3_1;
|
|
433
714
|
try {
|
|
434
|
-
const ptr0 = passStringToWasm0(
|
|
715
|
+
const ptr0 = passStringToWasm0(module_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
435
716
|
const len0 = WASM_VECTOR_LEN;
|
|
436
717
|
const ret = wasm.extract_geo(ptr0, len0);
|
|
437
718
|
var ptr2 = ret[0];
|
|
@@ -450,19 +731,22 @@ export function extract_geo(network_json) {
|
|
|
450
731
|
|
|
451
732
|
/**
|
|
452
733
|
* Everything the drop panel needs from one parse: counts, total load and
|
|
453
|
-
* capacity, parse
|
|
734
|
+
* capacity, parse diagnostics, and a `view` of buses and branches in the shape
|
|
454
735
|
* the tellegen API serves, placed at the coordinates the file carries
|
|
455
736
|
* (PowerWorld complete case aux exports). `view` is null when the file has no
|
|
456
737
|
* coordinates.
|
|
457
|
-
*
|
|
738
|
+
*
|
|
739
|
+
* Takes the dropped file's bytes, as [`parse_case`] does and for the same
|
|
740
|
+
* reason.
|
|
741
|
+
* @param {Uint8Array} bytes
|
|
458
742
|
* @param {string} format
|
|
459
743
|
* @returns {string}
|
|
460
744
|
*/
|
|
461
|
-
export function ingest_case(
|
|
745
|
+
export function ingest_case(bytes, format) {
|
|
462
746
|
let deferred4_0;
|
|
463
747
|
let deferred4_1;
|
|
464
748
|
try {
|
|
465
|
-
const ptr0 =
|
|
749
|
+
const ptr0 = passArray8ToWasm0(bytes, wasm.__wbindgen_malloc);
|
|
466
750
|
const len0 = WASM_VECTOR_LEN;
|
|
467
751
|
const ptr1 = passStringToWasm0(format, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
468
752
|
const len1 = WASM_VECTOR_LEN;
|
|
@@ -484,13 +768,14 @@ export function ingest_case(text, format) {
|
|
|
484
768
|
/**
|
|
485
769
|
* The distribution counterpart of [`ingest_case`]: view a multiconductor case
|
|
486
770
|
* with no solve. `format` is a distribution reader token (`dss`, `bmopf`,
|
|
487
|
-
* `pmd`) parsed by [`powerio_dist`], or `pio` for a `.pio.json`
|
|
488
|
-
*
|
|
489
|
-
*
|
|
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,
|
|
490
775
|
* coordinate provenance, and the bus/terminal graph the frontend renders (see
|
|
491
|
-
*
|
|
776
|
+
* the private `dist` adapter).
|
|
492
777
|
*
|
|
493
|
-
* Untrusted input: the parse and
|
|
778
|
+
* Untrusted input: the parse and module restore return error strings (mapped
|
|
494
779
|
* to `JsError` here), so a malformed, truncated, or oversized `.dss`/JSON
|
|
495
780
|
* rejects cleanly and never panics the wasm instance.
|
|
496
781
|
* @param {string} text
|
|
@@ -521,19 +806,51 @@ export function ingest_dist_case(text, format) {
|
|
|
521
806
|
}
|
|
522
807
|
|
|
523
808
|
/**
|
|
524
|
-
*
|
|
525
|
-
*
|
|
526
|
-
*
|
|
527
|
-
* @param {string} package_json
|
|
809
|
+
* Byte counterpart of [`ingest_dist_case`] for dropped files.
|
|
810
|
+
* @param {Uint8Array} bytes
|
|
811
|
+
* @param {string} format
|
|
528
812
|
* @returns {string}
|
|
529
813
|
*/
|
|
530
|
-
export function
|
|
814
|
+
export function ingest_dist_case_bytes(bytes, format) {
|
|
815
|
+
let deferred4_0;
|
|
816
|
+
let deferred4_1;
|
|
817
|
+
try {
|
|
818
|
+
const ptr0 = passArray8ToWasm0(bytes, wasm.__wbindgen_malloc);
|
|
819
|
+
const len0 = WASM_VECTOR_LEN;
|
|
820
|
+
const ptr1 = passStringToWasm0(format, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
821
|
+
const len1 = WASM_VECTOR_LEN;
|
|
822
|
+
const ret = wasm.ingest_dist_case_bytes(ptr0, len0, ptr1, len1);
|
|
823
|
+
var ptr3 = ret[0];
|
|
824
|
+
var len3 = ret[1];
|
|
825
|
+
if (ret[3]) {
|
|
826
|
+
ptr3 = 0; len3 = 0;
|
|
827
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
828
|
+
}
|
|
829
|
+
deferred4_0 = ptr3;
|
|
830
|
+
deferred4_1 = len3;
|
|
831
|
+
return getStringFromWasm0(ptr3, len3);
|
|
832
|
+
} finally {
|
|
833
|
+
wasm.__wbindgen_free(deferred4_0, deferred4_1, 1);
|
|
834
|
+
}
|
|
835
|
+
}
|
|
836
|
+
|
|
837
|
+
/**
|
|
838
|
+
* Classify and ingest one dropped JSON byte buffer. Known inputs return their
|
|
839
|
+
* render-ready payload; ambiguous and unknown documents return a null payload
|
|
840
|
+
* so the caller can request an explicit format without decoding the bytes a
|
|
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).
|
|
844
|
+
* @param {Uint8Array} bytes
|
|
845
|
+
* @returns {string}
|
|
846
|
+
*/
|
|
847
|
+
export function ingest_json_drop(bytes) {
|
|
531
848
|
let deferred3_0;
|
|
532
849
|
let deferred3_1;
|
|
533
850
|
try {
|
|
534
|
-
const ptr0 =
|
|
851
|
+
const ptr0 = passArray8ToWasm0(bytes, wasm.__wbindgen_malloc);
|
|
535
852
|
const len0 = WASM_VECTOR_LEN;
|
|
536
|
-
const ret = wasm.
|
|
853
|
+
const ret = wasm.ingest_json_drop(ptr0, len0);
|
|
537
854
|
var ptr2 = ret[0];
|
|
538
855
|
var len2 = ret[1];
|
|
539
856
|
if (ret[3]) {
|
|
@@ -550,16 +867,21 @@ export function load_package(package_json) {
|
|
|
550
867
|
|
|
551
868
|
/**
|
|
552
869
|
* Parse a case file (MATPOWER, PSS/E RAW, PowerWorld aux, PowerModels or
|
|
553
|
-
* egret JSON) and return `{"network": ..., "
|
|
554
|
-
*
|
|
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
|
|
555
877
|
* @param {string} format
|
|
556
878
|
* @returns {string}
|
|
557
879
|
*/
|
|
558
|
-
export function parse_case(
|
|
880
|
+
export function parse_case(bytes, format) {
|
|
559
881
|
let deferred4_0;
|
|
560
882
|
let deferred4_1;
|
|
561
883
|
try {
|
|
562
|
-
const ptr0 =
|
|
884
|
+
const ptr0 = passArray8ToWasm0(bytes, wasm.__wbindgen_malloc);
|
|
563
885
|
const len0 = WASM_VECTOR_LEN;
|
|
564
886
|
const ptr1 = passStringToWasm0(format, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
565
887
|
const len1 = WASM_VECTOR_LEN;
|
|
@@ -579,12 +901,7 @@ export function parse_case(text, format) {
|
|
|
579
901
|
}
|
|
580
902
|
|
|
581
903
|
/**
|
|
582
|
-
* Decode a PowerWorld
|
|
583
|
-
* symbols at the diagram coordinates the file stores (x east, y north) plus
|
|
584
|
-
* the canvas size, each with the approximate `lon`/`lat` projection
|
|
585
|
-
* (`pwd_mercator_to_lonlat`; hand edited diagrams drift from it). A `.pwd`
|
|
586
|
-
* carries no buses or branches. `format` is "pwd". Pure in-memory parsing,
|
|
587
|
-
* no filesystem, so it runs in the browser.
|
|
904
|
+
* Decode a PowerWorld drawing as a canonical PowerIO GeoLayer in diagram units.
|
|
588
905
|
* @param {Uint8Array} bytes
|
|
589
906
|
* @param {string} format
|
|
590
907
|
* @returns {string}
|
|
@@ -615,7 +932,7 @@ export function parse_display(bytes, format) {
|
|
|
615
932
|
/**
|
|
616
933
|
* Parse a geographic sidecar (buscoords CSV, aliased CSV/JSON records,
|
|
617
934
|
* GeoJSON) from raw dropped bytes; `hint` is the file name ("" to sniff).
|
|
618
|
-
* Returns `{ layer,
|
|
935
|
+
* Returns `{ layer, diagnostics, n_points, n_routes }` — the layer as its
|
|
619
936
|
* canonical `.geo.json` document, ready for [`apply_geo`]. Untrusted input
|
|
620
937
|
* rejects as a `JsError`, never a panic.
|
|
621
938
|
* @param {Uint8Array} bytes
|
|
@@ -646,22 +963,147 @@ export function parse_geo(bytes, hint) {
|
|
|
646
963
|
}
|
|
647
964
|
|
|
648
965
|
/**
|
|
649
|
-
*
|
|
650
|
-
*
|
|
966
|
+
* Validate and canonicalize a saved multiconductor Study snapshot without
|
|
967
|
+
* re-solving it.
|
|
968
|
+
* @param {string} snapshot_json
|
|
969
|
+
* @returns {string}
|
|
970
|
+
*/
|
|
971
|
+
export function replay_mc_study(snapshot_json) {
|
|
972
|
+
let deferred3_0;
|
|
973
|
+
let deferred3_1;
|
|
974
|
+
try {
|
|
975
|
+
const ptr0 = passStringToWasm0(snapshot_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
976
|
+
const len0 = WASM_VECTOR_LEN;
|
|
977
|
+
const ret = wasm.replay_mc_study(ptr0, len0);
|
|
978
|
+
var ptr2 = ret[0];
|
|
979
|
+
var len2 = ret[1];
|
|
980
|
+
if (ret[3]) {
|
|
981
|
+
ptr2 = 0; len2 = 0;
|
|
982
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
983
|
+
}
|
|
984
|
+
deferred3_0 = ptr2;
|
|
985
|
+
deferred3_1 = len2;
|
|
986
|
+
return getStringFromWasm0(ptr2, len2);
|
|
987
|
+
} finally {
|
|
988
|
+
wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
|
|
989
|
+
}
|
|
990
|
+
}
|
|
991
|
+
|
|
992
|
+
/**
|
|
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
|
|
998
|
+
* @returns {string}
|
|
999
|
+
*/
|
|
1000
|
+
export function solve_mc_bmopf(text, options_json) {
|
|
1001
|
+
let deferred4_0;
|
|
1002
|
+
let deferred4_1;
|
|
1003
|
+
try {
|
|
1004
|
+
const ptr0 = passStringToWasm0(text, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
1005
|
+
const len0 = WASM_VECTOR_LEN;
|
|
1006
|
+
const ptr1 = passStringToWasm0(options_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
1007
|
+
const len1 = WASM_VECTOR_LEN;
|
|
1008
|
+
const ret = wasm.solve_mc_bmopf(ptr0, len0, ptr1, len1);
|
|
1009
|
+
var ptr3 = ret[0];
|
|
1010
|
+
var len3 = ret[1];
|
|
1011
|
+
if (ret[3]) {
|
|
1012
|
+
ptr3 = 0; len3 = 0;
|
|
1013
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
1014
|
+
}
|
|
1015
|
+
deferred4_0 = ptr3;
|
|
1016
|
+
deferred4_1 = len3;
|
|
1017
|
+
return getStringFromWasm0(ptr3, len3);
|
|
1018
|
+
} finally {
|
|
1019
|
+
wasm.__wbindgen_free(deferred4_0, deferred4_1, 1);
|
|
1020
|
+
}
|
|
1021
|
+
}
|
|
1022
|
+
|
|
1023
|
+
/**
|
|
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
|
|
1028
|
+
* @returns {string}
|
|
1029
|
+
*/
|
|
1030
|
+
export function solve_mc_module(module_json, options_json) {
|
|
1031
|
+
let deferred4_0;
|
|
1032
|
+
let deferred4_1;
|
|
1033
|
+
try {
|
|
1034
|
+
const ptr0 = passStringToWasm0(module_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
1035
|
+
const len0 = WASM_VECTOR_LEN;
|
|
1036
|
+
const ptr1 = passStringToWasm0(options_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
1037
|
+
const len1 = WASM_VECTOR_LEN;
|
|
1038
|
+
const ret = wasm.solve_mc_module(ptr0, len0, ptr1, len1);
|
|
1039
|
+
var ptr3 = ret[0];
|
|
1040
|
+
var len3 = ret[1];
|
|
1041
|
+
if (ret[3]) {
|
|
1042
|
+
ptr3 = 0; len3 = 0;
|
|
1043
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
1044
|
+
}
|
|
1045
|
+
deferred4_0 = ptr3;
|
|
1046
|
+
deferred4_1 = len3;
|
|
1047
|
+
return getStringFromWasm0(ptr3, len3);
|
|
1048
|
+
} finally {
|
|
1049
|
+
wasm.__wbindgen_free(deferred4_0, deferred4_1, 1);
|
|
1050
|
+
}
|
|
1051
|
+
}
|
|
1052
|
+
|
|
1053
|
+
/**
|
|
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
|
|
1061
|
+
* @returns {string}
|
|
1062
|
+
*/
|
|
1063
|
+
export function solve_mc_study(module_json, study_id, study_title, options_json) {
|
|
1064
|
+
let deferred6_0;
|
|
1065
|
+
let deferred6_1;
|
|
1066
|
+
try {
|
|
1067
|
+
const ptr0 = passStringToWasm0(module_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
1068
|
+
const len0 = WASM_VECTOR_LEN;
|
|
1069
|
+
const ptr1 = passStringToWasm0(study_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
1070
|
+
const len1 = WASM_VECTOR_LEN;
|
|
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];
|
|
1078
|
+
if (ret[3]) {
|
|
1079
|
+
ptr5 = 0; len5 = 0;
|
|
1080
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
1081
|
+
}
|
|
1082
|
+
deferred6_0 = ptr5;
|
|
1083
|
+
deferred6_1 = len5;
|
|
1084
|
+
return getStringFromWasm0(ptr5, len5);
|
|
1085
|
+
} finally {
|
|
1086
|
+
wasm.__wbindgen_free(deferred6_0, deferred6_1, 1);
|
|
1087
|
+
}
|
|
1088
|
+
}
|
|
1089
|
+
|
|
1090
|
+
/**
|
|
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;
|
|
651
1093
|
* the reactive hot path is the [`Study`].
|
|
652
|
-
* @param {string}
|
|
1094
|
+
* @param {string} module_json
|
|
653
1095
|
* @param {string} request_json
|
|
654
1096
|
* @returns {string}
|
|
655
1097
|
*/
|
|
656
|
-
export function
|
|
1098
|
+
export function solve_module(module_json, request_json) {
|
|
657
1099
|
let deferred4_0;
|
|
658
1100
|
let deferred4_1;
|
|
659
1101
|
try {
|
|
660
|
-
const ptr0 = passStringToWasm0(
|
|
1102
|
+
const ptr0 = passStringToWasm0(module_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
661
1103
|
const len0 = WASM_VECTOR_LEN;
|
|
662
1104
|
const ptr1 = passStringToWasm0(request_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
663
1105
|
const len1 = WASM_VECTOR_LEN;
|
|
664
|
-
const ret = wasm.
|
|
1106
|
+
const ret = wasm.solve_module(ptr0, len0, ptr1, len1);
|
|
665
1107
|
var ptr3 = ret[0];
|
|
666
1108
|
var len3 = ret[1];
|
|
667
1109
|
if (ret[3]) {
|
|
@@ -675,21 +1117,109 @@ export function solve_json(network_json, request_json) {
|
|
|
675
1117
|
wasm.__wbindgen_free(deferred4_0, deferred4_1, 1);
|
|
676
1118
|
}
|
|
677
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
|
+
}
|
|
678
1188
|
function __wbg_get_imports() {
|
|
679
1189
|
const import0 = {
|
|
680
1190
|
__proto__: null,
|
|
681
|
-
|
|
1191
|
+
__wbg_Error_67e7344beaa85059: function(arg0, arg1) {
|
|
682
1192
|
const ret = Error(getStringFromWasm0(arg0, arg1));
|
|
683
1193
|
return ret;
|
|
684
1194
|
},
|
|
685
|
-
|
|
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) {
|
|
686
1205
|
const ret = arg0 === undefined;
|
|
687
1206
|
return ret;
|
|
688
1207
|
},
|
|
689
|
-
|
|
1208
|
+
__wbg___wbindgen_throw_5d9e815e6fdf150f: function(arg0, arg1) {
|
|
690
1209
|
throw new Error(getStringFromWasm0(arg0, arg1));
|
|
691
1210
|
},
|
|
692
|
-
|
|
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) {
|
|
693
1223
|
let deferred0_0;
|
|
694
1224
|
let deferred0_1;
|
|
695
1225
|
try {
|
|
@@ -704,6 +1234,42 @@ function __wbg_get_imports() {
|
|
|
704
1234
|
const ret = new Error();
|
|
705
1235
|
return ret;
|
|
706
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
|
+
},
|
|
707
1273
|
__wbg_now_cace042f68c814d8: function(arg0) {
|
|
708
1274
|
const ret = arg0.now();
|
|
709
1275
|
return ret;
|
|
@@ -712,6 +1278,20 @@ function __wbg_get_imports() {
|
|
|
712
1278
|
const ret = arg0.performance;
|
|
713
1279
|
return ret;
|
|
714
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
|
+
},
|
|
715
1295
|
__wbg_stack_3b0d974bbf31e44f: function(arg0, arg1) {
|
|
716
1296
|
const ret = arg1.stack;
|
|
717
1297
|
const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
@@ -719,22 +1299,40 @@ function __wbg_get_imports() {
|
|
|
719
1299
|
getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
|
|
720
1300
|
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
|
|
721
1301
|
},
|
|
722
|
-
|
|
723
|
-
const ret = typeof
|
|
1302
|
+
__wbg_static_accessor_GLOBAL_8eb4cd83130a11a0: function() {
|
|
1303
|
+
const ret = typeof global === 'undefined' ? null : global;
|
|
724
1304
|
return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
|
|
725
1305
|
},
|
|
726
|
-
|
|
727
|
-
const ret = typeof
|
|
1306
|
+
__wbg_static_accessor_GLOBAL_THIS_1e7044f654e934db: function() {
|
|
1307
|
+
const ret = typeof globalThis === 'undefined' ? null : globalThis;
|
|
728
1308
|
return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
|
|
729
1309
|
},
|
|
730
|
-
|
|
1310
|
+
__wbg_static_accessor_SELF_d8b50611246a6d92: function() {
|
|
731
1311
|
const ret = typeof self === 'undefined' ? null : self;
|
|
732
1312
|
return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
|
|
733
1313
|
},
|
|
734
|
-
|
|
1314
|
+
__wbg_static_accessor_WINDOW_fd0bc376bf0f8b42: function() {
|
|
735
1315
|
const ret = typeof window === 'undefined' ? null : window;
|
|
736
1316
|
return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
|
|
737
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
|
+
},
|
|
738
1336
|
__wbindgen_init_externref_table: function() {
|
|
739
1337
|
const table = wasm.__wbindgen_externrefs;
|
|
740
1338
|
const offset = table.grow(4);
|
|
@@ -751,6 +1349,20 @@ function __wbg_get_imports() {
|
|
|
751
1349
|
};
|
|
752
1350
|
}
|
|
753
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));
|
|
754
1366
|
const StudyFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
755
1367
|
? { register: () => {}, unregister: () => {} }
|
|
756
1368
|
: new FinalizationRegistry(ptr => wasm.__wbg_study_free(ptr, 1));
|
|
@@ -761,6 +1373,10 @@ function addToExternrefTable0(obj) {
|
|
|
761
1373
|
return idx;
|
|
762
1374
|
}
|
|
763
1375
|
|
|
1376
|
+
const CLOSURE_DTORS = (typeof FinalizationRegistry === 'undefined')
|
|
1377
|
+
? { register: () => {}, unregister: () => {} }
|
|
1378
|
+
: new FinalizationRegistry(state => wasm.__wbindgen_destroy_closure(state.a, state.b));
|
|
1379
|
+
|
|
764
1380
|
let cachedDataViewMemory0 = null;
|
|
765
1381
|
function getDataViewMemory0() {
|
|
766
1382
|
if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || (cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm.memory.buffer)) {
|
|
@@ -781,10 +1397,47 @@ function getUint8ArrayMemory0() {
|
|
|
781
1397
|
return cachedUint8ArrayMemory0;
|
|
782
1398
|
}
|
|
783
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
|
+
|
|
784
1409
|
function isLikeNone(x) {
|
|
785
1410
|
return x === undefined || x === null;
|
|
786
1411
|
}
|
|
787
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
|
+
|
|
788
1441
|
function passArray8ToWasm0(arg, malloc) {
|
|
789
1442
|
const ptr = malloc(arg.length * 1, 1) >>> 0;
|
|
790
1443
|
getUint8ArrayMemory0().set(arg, ptr / 1);
|
|
@@ -877,11 +1530,15 @@ function __wbg_finalize_init(instance, module) {
|
|
|
877
1530
|
|
|
878
1531
|
async function __wbg_load(module, imports) {
|
|
879
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
|
+
|
|
880
1537
|
if (typeof WebAssembly.instantiateStreaming === 'function') {
|
|
881
1538
|
try {
|
|
882
1539
|
return await WebAssembly.instantiateStreaming(module, imports);
|
|
883
1540
|
} catch (e) {
|
|
884
|
-
const validResponse =
|
|
1541
|
+
const validResponse = expectedResponseType(module.type);
|
|
885
1542
|
|
|
886
1543
|
if (validResponse && module.headers.get('Content-Type') !== 'application/wasm') {
|
|
887
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);
|