@cognipilot/rumoca 0.9.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +201 -0
- package/README.md +22 -0
- package/package.json +46 -0
- package/parse_worker.js +53 -0
- package/rumoca_bind_wasm.d.ts +295 -0
- package/rumoca_bind_wasm.js +1473 -0
- package/rumoca_bind_wasm_bg.wasm +0 -0
- package/rumoca_bind_wasm_diffsol.d.ts +49 -0
- package/rumoca_bind_wasm_diffsol.js +270 -0
- package/rumoca_bind_wasm_diffsol_bg.wasm +0 -0
- package/rumoca_diffsol.js +109 -0
- package/rumoca_gpu.js +335 -0
- package/rumoca_package_meta.json +3 -0
- package/rumoca_worker.js +394 -0
|
@@ -0,0 +1,1473 @@
|
|
|
1
|
+
/* @ts-self-types="./rumoca_bind_wasm.d.ts" */
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Check Modelica source code and return all diagnostics.
|
|
5
|
+
* @param {string} source
|
|
6
|
+
* @returns {any}
|
|
7
|
+
*/
|
|
8
|
+
export function check(source) {
|
|
9
|
+
const ptr0 = passStringToWasm0(source, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
10
|
+
const len0 = WASM_VECTOR_LEN;
|
|
11
|
+
const ret = wasm.check(ptr0, len0);
|
|
12
|
+
return ret;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export function clear_source_root_cache() {
|
|
16
|
+
wasm.clear_source_root_cache();
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Compile Modelica source code to DAE JSON.
|
|
21
|
+
* @param {string} source
|
|
22
|
+
* @param {string} model_name
|
|
23
|
+
* @returns {string}
|
|
24
|
+
*/
|
|
25
|
+
export function compile(source, model_name) {
|
|
26
|
+
let deferred4_0;
|
|
27
|
+
let deferred4_1;
|
|
28
|
+
try {
|
|
29
|
+
const ptr0 = passStringToWasm0(source, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
30
|
+
const len0 = WASM_VECTOR_LEN;
|
|
31
|
+
const ptr1 = passStringToWasm0(model_name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
32
|
+
const len1 = WASM_VECTOR_LEN;
|
|
33
|
+
const ret = wasm.compile(ptr0, len0, ptr1, len1);
|
|
34
|
+
var ptr3 = ret[0];
|
|
35
|
+
var len3 = ret[1];
|
|
36
|
+
if (ret[3]) {
|
|
37
|
+
ptr3 = 0; len3 = 0;
|
|
38
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
39
|
+
}
|
|
40
|
+
deferred4_0 = ptr3;
|
|
41
|
+
deferred4_1 = len3;
|
|
42
|
+
return getStringFromWasm0(ptr3, len3);
|
|
43
|
+
} finally {
|
|
44
|
+
wasm.__wbindgen_free(deferred4_0, deferred4_1, 1);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* @param {string} source
|
|
50
|
+
* @param {string} model_name
|
|
51
|
+
* @param {string} source_roots_json
|
|
52
|
+
* @returns {string}
|
|
53
|
+
*/
|
|
54
|
+
export function compile_check_with_source_roots(source, model_name, source_roots_json) {
|
|
55
|
+
let deferred5_0;
|
|
56
|
+
let deferred5_1;
|
|
57
|
+
try {
|
|
58
|
+
const ptr0 = passStringToWasm0(source, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
59
|
+
const len0 = WASM_VECTOR_LEN;
|
|
60
|
+
const ptr1 = passStringToWasm0(model_name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
61
|
+
const len1 = WASM_VECTOR_LEN;
|
|
62
|
+
const ptr2 = passStringToWasm0(source_roots_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
63
|
+
const len2 = WASM_VECTOR_LEN;
|
|
64
|
+
const ret = wasm.compile_check_with_source_roots(ptr0, len0, ptr1, len1, ptr2, len2);
|
|
65
|
+
var ptr4 = ret[0];
|
|
66
|
+
var len4 = ret[1];
|
|
67
|
+
if (ret[3]) {
|
|
68
|
+
ptr4 = 0; len4 = 0;
|
|
69
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
70
|
+
}
|
|
71
|
+
deferred5_0 = ptr4;
|
|
72
|
+
deferred5_1 = len4;
|
|
73
|
+
return getStringFromWasm0(ptr4, len4);
|
|
74
|
+
} finally {
|
|
75
|
+
wasm.__wbindgen_free(deferred5_0, deferred5_1, 1);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* Strict compile-check using loaded source roots with explicit behavior options.
|
|
81
|
+
*
|
|
82
|
+
* This validates requested-model compilation without producing full DAE output.
|
|
83
|
+
* Option semantics are identical to `compile_with_source_roots_with_options`.
|
|
84
|
+
* @param {string} source
|
|
85
|
+
* @param {string} model_name
|
|
86
|
+
* @param {string} source_roots_json
|
|
87
|
+
* @param {string} compile_options_json
|
|
88
|
+
* @returns {string}
|
|
89
|
+
*/
|
|
90
|
+
export function compile_check_with_source_roots_with_options(source, model_name, source_roots_json, compile_options_json) {
|
|
91
|
+
let deferred6_0;
|
|
92
|
+
let deferred6_1;
|
|
93
|
+
try {
|
|
94
|
+
const ptr0 = passStringToWasm0(source, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
95
|
+
const len0 = WASM_VECTOR_LEN;
|
|
96
|
+
const ptr1 = passStringToWasm0(model_name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
97
|
+
const len1 = WASM_VECTOR_LEN;
|
|
98
|
+
const ptr2 = passStringToWasm0(source_roots_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
99
|
+
const len2 = WASM_VECTOR_LEN;
|
|
100
|
+
const ptr3 = passStringToWasm0(compile_options_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
101
|
+
const len3 = WASM_VECTOR_LEN;
|
|
102
|
+
const ret = wasm.compile_check_with_source_roots_with_options(ptr0, len0, ptr1, len1, ptr2, len2, ptr3, len3);
|
|
103
|
+
var ptr5 = ret[0];
|
|
104
|
+
var len5 = ret[1];
|
|
105
|
+
if (ret[3]) {
|
|
106
|
+
ptr5 = 0; len5 = 0;
|
|
107
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
108
|
+
}
|
|
109
|
+
deferred6_0 = ptr5;
|
|
110
|
+
deferred6_1 = len5;
|
|
111
|
+
return getStringFromWasm0(ptr5, len5);
|
|
112
|
+
} finally {
|
|
113
|
+
wasm.__wbindgen_free(deferred6_0, deferred6_1, 1);
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
/**
|
|
118
|
+
* Compile Modelica source code to DAE JSON (alias for worker compatibility).
|
|
119
|
+
* @param {string} source
|
|
120
|
+
* @param {string} model_name
|
|
121
|
+
* @returns {string}
|
|
122
|
+
*/
|
|
123
|
+
export function compile_to_json(source, model_name) {
|
|
124
|
+
let deferred4_0;
|
|
125
|
+
let deferred4_1;
|
|
126
|
+
try {
|
|
127
|
+
const ptr0 = passStringToWasm0(source, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
128
|
+
const len0 = WASM_VECTOR_LEN;
|
|
129
|
+
const ptr1 = passStringToWasm0(model_name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
130
|
+
const len1 = WASM_VECTOR_LEN;
|
|
131
|
+
const ret = wasm.compile_to_json(ptr0, len0, ptr1, len1);
|
|
132
|
+
var ptr3 = ret[0];
|
|
133
|
+
var len3 = ret[1];
|
|
134
|
+
if (ret[3]) {
|
|
135
|
+
ptr3 = 0; len3 = 0;
|
|
136
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
137
|
+
}
|
|
138
|
+
deferred4_0 = ptr3;
|
|
139
|
+
deferred4_1 = len3;
|
|
140
|
+
return getStringFromWasm0(ptr3, len3);
|
|
141
|
+
} finally {
|
|
142
|
+
wasm.__wbindgen_free(deferred4_0, deferred4_1, 1);
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
/**
|
|
147
|
+
* @param {string} source
|
|
148
|
+
* @param {string} model_name
|
|
149
|
+
* @param {string} project_sources_json
|
|
150
|
+
* @returns {string}
|
|
151
|
+
*/
|
|
152
|
+
export function compile_with_project_sources(source, model_name, project_sources_json) {
|
|
153
|
+
let deferred5_0;
|
|
154
|
+
let deferred5_1;
|
|
155
|
+
try {
|
|
156
|
+
const ptr0 = passStringToWasm0(source, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
157
|
+
const len0 = WASM_VECTOR_LEN;
|
|
158
|
+
const ptr1 = passStringToWasm0(model_name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
159
|
+
const len1 = WASM_VECTOR_LEN;
|
|
160
|
+
const ptr2 = passStringToWasm0(project_sources_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
161
|
+
const len2 = WASM_VECTOR_LEN;
|
|
162
|
+
const ret = wasm.compile_with_project_sources(ptr0, len0, ptr1, len1, ptr2, len2);
|
|
163
|
+
var ptr4 = ret[0];
|
|
164
|
+
var len4 = ret[1];
|
|
165
|
+
if (ret[3]) {
|
|
166
|
+
ptr4 = 0; len4 = 0;
|
|
167
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
168
|
+
}
|
|
169
|
+
deferred5_0 = ptr4;
|
|
170
|
+
deferred5_1 = len4;
|
|
171
|
+
return getStringFromWasm0(ptr4, len4);
|
|
172
|
+
} finally {
|
|
173
|
+
wasm.__wbindgen_free(deferred5_0, deferred5_1, 1);
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
/**
|
|
178
|
+
* @param {string} source
|
|
179
|
+
* @param {string} model_name
|
|
180
|
+
* @param {string} source_roots_json
|
|
181
|
+
* @returns {string}
|
|
182
|
+
*/
|
|
183
|
+
export function compile_with_source_roots(source, model_name, source_roots_json) {
|
|
184
|
+
let deferred5_0;
|
|
185
|
+
let deferred5_1;
|
|
186
|
+
try {
|
|
187
|
+
const ptr0 = passStringToWasm0(source, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
188
|
+
const len0 = WASM_VECTOR_LEN;
|
|
189
|
+
const ptr1 = passStringToWasm0(model_name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
190
|
+
const len1 = WASM_VECTOR_LEN;
|
|
191
|
+
const ptr2 = passStringToWasm0(source_roots_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
192
|
+
const len2 = WASM_VECTOR_LEN;
|
|
193
|
+
const ret = wasm.compile_with_source_roots(ptr0, len0, ptr1, len1, ptr2, len2);
|
|
194
|
+
var ptr4 = ret[0];
|
|
195
|
+
var len4 = ret[1];
|
|
196
|
+
if (ret[3]) {
|
|
197
|
+
ptr4 = 0; len4 = 0;
|
|
198
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
199
|
+
}
|
|
200
|
+
deferred5_0 = ptr4;
|
|
201
|
+
deferred5_1 = len4;
|
|
202
|
+
return getStringFromWasm0(ptr4, len4);
|
|
203
|
+
} finally {
|
|
204
|
+
wasm.__wbindgen_free(deferred5_0, deferred5_1, 1);
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
/**
|
|
209
|
+
* Compile using loaded source roots with explicit compile behavior options.
|
|
210
|
+
*
|
|
211
|
+
* `compile_options_json` example:
|
|
212
|
+
* `{"allowNonParamEvaluateAnnotation":true,"allowMultiWhenSingleAssign":false}`
|
|
213
|
+
*
|
|
214
|
+
* Strict behavior remains default when this function is not used (or options are false).
|
|
215
|
+
* @param {string} source
|
|
216
|
+
* @param {string} model_name
|
|
217
|
+
* @param {string} source_roots_json
|
|
218
|
+
* @param {string} compile_options_json
|
|
219
|
+
* @returns {string}
|
|
220
|
+
*/
|
|
221
|
+
export function compile_with_source_roots_with_options(source, model_name, source_roots_json, compile_options_json) {
|
|
222
|
+
let deferred6_0;
|
|
223
|
+
let deferred6_1;
|
|
224
|
+
try {
|
|
225
|
+
const ptr0 = passStringToWasm0(source, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
226
|
+
const len0 = WASM_VECTOR_LEN;
|
|
227
|
+
const ptr1 = passStringToWasm0(model_name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
228
|
+
const len1 = WASM_VECTOR_LEN;
|
|
229
|
+
const ptr2 = passStringToWasm0(source_roots_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
230
|
+
const len2 = WASM_VECTOR_LEN;
|
|
231
|
+
const ptr3 = passStringToWasm0(compile_options_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
232
|
+
const len3 = WASM_VECTOR_LEN;
|
|
233
|
+
const ret = wasm.compile_with_source_roots_with_options(ptr0, len0, ptr1, len1, ptr2, len2, ptr3, len3);
|
|
234
|
+
var ptr5 = ret[0];
|
|
235
|
+
var len5 = ret[1];
|
|
236
|
+
if (ret[3]) {
|
|
237
|
+
ptr5 = 0; len5 = 0;
|
|
238
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
239
|
+
}
|
|
240
|
+
deferred6_0 = ptr5;
|
|
241
|
+
deferred6_1 = len5;
|
|
242
|
+
return getStringFromWasm0(ptr5, len5);
|
|
243
|
+
} finally {
|
|
244
|
+
wasm.__wbindgen_free(deferred6_0, deferred6_1, 1);
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
/**
|
|
249
|
+
* @param {string} uris_json
|
|
250
|
+
* @returns {Uint8Array}
|
|
251
|
+
*/
|
|
252
|
+
export function export_parsed_source_roots_binary(uris_json) {
|
|
253
|
+
const ptr0 = passStringToWasm0(uris_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
254
|
+
const len0 = WASM_VECTOR_LEN;
|
|
255
|
+
const ret = wasm.export_parsed_source_roots_binary(ptr0, len0);
|
|
256
|
+
if (ret[3]) {
|
|
257
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
258
|
+
}
|
|
259
|
+
var v2 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
260
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
261
|
+
return v2;
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
/**
|
|
265
|
+
* Get the UTC build timestamp for this WASM build.
|
|
266
|
+
* @returns {string}
|
|
267
|
+
*/
|
|
268
|
+
export function get_build_time_utc() {
|
|
269
|
+
let deferred1_0;
|
|
270
|
+
let deferred1_1;
|
|
271
|
+
try {
|
|
272
|
+
const ret = wasm.get_build_time_utc();
|
|
273
|
+
deferred1_0 = ret[0];
|
|
274
|
+
deferred1_1 = ret[1];
|
|
275
|
+
return getStringFromWasm0(ret[0], ret[1]);
|
|
276
|
+
} finally {
|
|
277
|
+
wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
/**
|
|
282
|
+
* Get the built-in codegen targets bundled with the WASM runtime.
|
|
283
|
+
* @returns {any}
|
|
284
|
+
*/
|
|
285
|
+
export function get_builtin_targets() {
|
|
286
|
+
const ret = wasm.get_builtin_targets();
|
|
287
|
+
return ret;
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
/**
|
|
291
|
+
* @returns {string}
|
|
292
|
+
*/
|
|
293
|
+
export function get_bundled_source_root_manifest() {
|
|
294
|
+
let deferred1_0;
|
|
295
|
+
let deferred1_1;
|
|
296
|
+
try {
|
|
297
|
+
const ret = wasm.get_bundled_source_root_manifest();
|
|
298
|
+
deferred1_0 = ret[0];
|
|
299
|
+
deferred1_1 = ret[1];
|
|
300
|
+
return getStringFromWasm0(ret[0], ret[1]);
|
|
301
|
+
} finally {
|
|
302
|
+
wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
|
|
303
|
+
}
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
/**
|
|
307
|
+
* Get detailed class documentation and summary metadata.
|
|
308
|
+
* @param {string} qualified_name
|
|
309
|
+
* @returns {string}
|
|
310
|
+
*/
|
|
311
|
+
export function get_class_info(qualified_name) {
|
|
312
|
+
let deferred3_0;
|
|
313
|
+
let deferred3_1;
|
|
314
|
+
try {
|
|
315
|
+
const ptr0 = passStringToWasm0(qualified_name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
316
|
+
const len0 = WASM_VECTOR_LEN;
|
|
317
|
+
const ret = wasm.get_class_info(ptr0, len0);
|
|
318
|
+
var ptr2 = ret[0];
|
|
319
|
+
var len2 = ret[1];
|
|
320
|
+
if (ret[3]) {
|
|
321
|
+
ptr2 = 0; len2 = 0;
|
|
322
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
323
|
+
}
|
|
324
|
+
deferred3_0 = ptr2;
|
|
325
|
+
deferred3_1 = len2;
|
|
326
|
+
return getStringFromWasm0(ptr2, len2);
|
|
327
|
+
} finally {
|
|
328
|
+
wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
|
|
329
|
+
}
|
|
330
|
+
}
|
|
331
|
+
|
|
332
|
+
/**
|
|
333
|
+
* Get the Git commit hash for this WASM build.
|
|
334
|
+
* @returns {string}
|
|
335
|
+
*/
|
|
336
|
+
export function get_git_commit() {
|
|
337
|
+
let deferred1_0;
|
|
338
|
+
let deferred1_1;
|
|
339
|
+
try {
|
|
340
|
+
const ret = wasm.get_git_commit();
|
|
341
|
+
deferred1_0 = ret[0];
|
|
342
|
+
deferred1_1 = ret[1];
|
|
343
|
+
return getStringFromWasm0(ret[0], ret[1]);
|
|
344
|
+
} finally {
|
|
345
|
+
wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
|
|
346
|
+
}
|
|
347
|
+
}
|
|
348
|
+
|
|
349
|
+
/**
|
|
350
|
+
* Discover compilable simulation models in a source document.
|
|
351
|
+
* @param {string} source
|
|
352
|
+
* @param {string} default_model
|
|
353
|
+
* @returns {string}
|
|
354
|
+
*/
|
|
355
|
+
export function get_simulation_models(source, default_model) {
|
|
356
|
+
let deferred4_0;
|
|
357
|
+
let deferred4_1;
|
|
358
|
+
try {
|
|
359
|
+
const ptr0 = passStringToWasm0(source, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
360
|
+
const len0 = WASM_VECTOR_LEN;
|
|
361
|
+
const ptr1 = passStringToWasm0(default_model, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
362
|
+
const len1 = WASM_VECTOR_LEN;
|
|
363
|
+
const ret = wasm.get_simulation_models(ptr0, len0, ptr1, len1);
|
|
364
|
+
var ptr3 = ret[0];
|
|
365
|
+
var len3 = ret[1];
|
|
366
|
+
if (ret[3]) {
|
|
367
|
+
ptr3 = 0; len3 = 0;
|
|
368
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
369
|
+
}
|
|
370
|
+
deferred4_0 = ptr3;
|
|
371
|
+
deferred4_1 = len3;
|
|
372
|
+
return getStringFromWasm0(ptr3, len3);
|
|
373
|
+
} finally {
|
|
374
|
+
wasm.__wbindgen_free(deferred4_0, deferred4_1, 1);
|
|
375
|
+
}
|
|
376
|
+
}
|
|
377
|
+
|
|
378
|
+
/**
|
|
379
|
+
* @returns {number}
|
|
380
|
+
*/
|
|
381
|
+
export function get_source_root_document_count() {
|
|
382
|
+
const ret = wasm.get_source_root_document_count();
|
|
383
|
+
return ret >>> 0;
|
|
384
|
+
}
|
|
385
|
+
|
|
386
|
+
/**
|
|
387
|
+
* @returns {string}
|
|
388
|
+
*/
|
|
389
|
+
export function get_source_root_statuses() {
|
|
390
|
+
let deferred2_0;
|
|
391
|
+
let deferred2_1;
|
|
392
|
+
try {
|
|
393
|
+
const ret = wasm.get_source_root_statuses();
|
|
394
|
+
var ptr1 = ret[0];
|
|
395
|
+
var len1 = ret[1];
|
|
396
|
+
if (ret[3]) {
|
|
397
|
+
ptr1 = 0; len1 = 0;
|
|
398
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
399
|
+
}
|
|
400
|
+
deferred2_0 = ptr1;
|
|
401
|
+
deferred2_1 = len1;
|
|
402
|
+
return getStringFromWasm0(ptr1, len1);
|
|
403
|
+
} finally {
|
|
404
|
+
wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
|
|
405
|
+
}
|
|
406
|
+
}
|
|
407
|
+
|
|
408
|
+
/**
|
|
409
|
+
* Get the Rumoca version string.
|
|
410
|
+
* @returns {string}
|
|
411
|
+
*/
|
|
412
|
+
export function get_version() {
|
|
413
|
+
let deferred1_0;
|
|
414
|
+
let deferred1_1;
|
|
415
|
+
try {
|
|
416
|
+
const ret = wasm.get_version();
|
|
417
|
+
deferred1_0 = ret[0];
|
|
418
|
+
deferred1_1 = ret[1];
|
|
419
|
+
return getStringFromWasm0(ret[0], ret[1]);
|
|
420
|
+
} finally {
|
|
421
|
+
wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
|
|
422
|
+
}
|
|
423
|
+
}
|
|
424
|
+
|
|
425
|
+
/**
|
|
426
|
+
* Initialize panic hook for better error messages in console.
|
|
427
|
+
*/
|
|
428
|
+
export function init() {
|
|
429
|
+
wasm.init();
|
|
430
|
+
}
|
|
431
|
+
|
|
432
|
+
/**
|
|
433
|
+
* Lint Modelica source code and return messages.
|
|
434
|
+
* @param {string} source
|
|
435
|
+
* @returns {any}
|
|
436
|
+
*/
|
|
437
|
+
export function lint(source) {
|
|
438
|
+
const ptr0 = passStringToWasm0(source, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
439
|
+
const len0 = WASM_VECTOR_LEN;
|
|
440
|
+
const ret = wasm.lint(ptr0, len0);
|
|
441
|
+
return ret;
|
|
442
|
+
}
|
|
443
|
+
|
|
444
|
+
/**
|
|
445
|
+
* List all loaded classes as a package/class hierarchy.
|
|
446
|
+
* @returns {string}
|
|
447
|
+
*/
|
|
448
|
+
export function list_classes() {
|
|
449
|
+
let deferred2_0;
|
|
450
|
+
let deferred2_1;
|
|
451
|
+
try {
|
|
452
|
+
const ret = wasm.list_classes();
|
|
453
|
+
var ptr1 = ret[0];
|
|
454
|
+
var len1 = ret[1];
|
|
455
|
+
if (ret[3]) {
|
|
456
|
+
ptr1 = 0; len1 = 0;
|
|
457
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
458
|
+
}
|
|
459
|
+
deferred2_0 = ptr1;
|
|
460
|
+
deferred2_1 = len1;
|
|
461
|
+
return getStringFromWasm0(ptr1, len1);
|
|
462
|
+
} finally {
|
|
463
|
+
wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
|
|
464
|
+
}
|
|
465
|
+
}
|
|
466
|
+
|
|
467
|
+
/**
|
|
468
|
+
* @param {string} archive_id
|
|
469
|
+
* @returns {number}
|
|
470
|
+
*/
|
|
471
|
+
export function load_bundled_source_root_cache(archive_id) {
|
|
472
|
+
const ptr0 = passStringToWasm0(archive_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
473
|
+
const len0 = WASM_VECTOR_LEN;
|
|
474
|
+
const ret = wasm.load_bundled_source_root_cache(ptr0, len0);
|
|
475
|
+
if (ret[2]) {
|
|
476
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
477
|
+
}
|
|
478
|
+
return ret[0] >>> 0;
|
|
479
|
+
}
|
|
480
|
+
|
|
481
|
+
/**
|
|
482
|
+
* @param {string} source_roots_json
|
|
483
|
+
* @returns {string}
|
|
484
|
+
*/
|
|
485
|
+
export function load_source_roots(source_roots_json) {
|
|
486
|
+
let deferred3_0;
|
|
487
|
+
let deferred3_1;
|
|
488
|
+
try {
|
|
489
|
+
const ptr0 = passStringToWasm0(source_roots_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
490
|
+
const len0 = WASM_VECTOR_LEN;
|
|
491
|
+
const ret = wasm.load_source_roots(ptr0, len0);
|
|
492
|
+
var ptr2 = ret[0];
|
|
493
|
+
var len2 = ret[1];
|
|
494
|
+
if (ret[3]) {
|
|
495
|
+
ptr2 = 0; len2 = 0;
|
|
496
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
497
|
+
}
|
|
498
|
+
deferred3_0 = ptr2;
|
|
499
|
+
deferred3_1 = len2;
|
|
500
|
+
return getStringFromWasm0(ptr2, len2);
|
|
501
|
+
} finally {
|
|
502
|
+
wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
|
|
503
|
+
}
|
|
504
|
+
}
|
|
505
|
+
|
|
506
|
+
/**
|
|
507
|
+
* Compile a model and return its lowered `SolveModel` as JSON, for the lazy
|
|
508
|
+
* diffsol addon (`@cognipilot/rumoca/diffsol`) to simulate. Lets the stiff
|
|
509
|
+
* solver run without putting relaxed-SIMD in this (universal) module.
|
|
510
|
+
* @param {string} source
|
|
511
|
+
* @param {string} model_name
|
|
512
|
+
* @param {number} t_end
|
|
513
|
+
* @param {number} dt
|
|
514
|
+
* @returns {string}
|
|
515
|
+
*/
|
|
516
|
+
export function lower_model_to_solve_json(source, model_name, t_end, dt) {
|
|
517
|
+
let deferred4_0;
|
|
518
|
+
let deferred4_1;
|
|
519
|
+
try {
|
|
520
|
+
const ptr0 = passStringToWasm0(source, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
521
|
+
const len0 = WASM_VECTOR_LEN;
|
|
522
|
+
const ptr1 = passStringToWasm0(model_name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
523
|
+
const len1 = WASM_VECTOR_LEN;
|
|
524
|
+
const ret = wasm.lower_model_to_solve_json(ptr0, len0, ptr1, len1, t_end, dt);
|
|
525
|
+
var ptr3 = ret[0];
|
|
526
|
+
var len3 = ret[1];
|
|
527
|
+
if (ret[3]) {
|
|
528
|
+
ptr3 = 0; len3 = 0;
|
|
529
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
530
|
+
}
|
|
531
|
+
deferred4_0 = ptr3;
|
|
532
|
+
deferred4_1 = len3;
|
|
533
|
+
return getStringFromWasm0(ptr3, len3);
|
|
534
|
+
} finally {
|
|
535
|
+
wasm.__wbindgen_free(deferred4_0, deferred4_1, 1);
|
|
536
|
+
}
|
|
537
|
+
}
|
|
538
|
+
|
|
539
|
+
/**
|
|
540
|
+
* Get code actions (quick fixes) for diagnostics in a selected range.
|
|
541
|
+
* @param {string} source
|
|
542
|
+
* @param {number} range_start_line
|
|
543
|
+
* @param {number} range_start_character
|
|
544
|
+
* @param {number} range_end_line
|
|
545
|
+
* @param {number} range_end_character
|
|
546
|
+
* @param {string} diagnostics_json
|
|
547
|
+
* @returns {string}
|
|
548
|
+
*/
|
|
549
|
+
export function lsp_code_actions(source, range_start_line, range_start_character, range_end_line, range_end_character, diagnostics_json) {
|
|
550
|
+
let deferred4_0;
|
|
551
|
+
let deferred4_1;
|
|
552
|
+
try {
|
|
553
|
+
const ptr0 = passStringToWasm0(source, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
554
|
+
const len0 = WASM_VECTOR_LEN;
|
|
555
|
+
const ptr1 = passStringToWasm0(diagnostics_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
556
|
+
const len1 = WASM_VECTOR_LEN;
|
|
557
|
+
const ret = wasm.lsp_code_actions(ptr0, len0, range_start_line, range_start_character, range_end_line, range_end_character, ptr1, len1);
|
|
558
|
+
var ptr3 = ret[0];
|
|
559
|
+
var len3 = ret[1];
|
|
560
|
+
if (ret[3]) {
|
|
561
|
+
ptr3 = 0; len3 = 0;
|
|
562
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
563
|
+
}
|
|
564
|
+
deferred4_0 = ptr3;
|
|
565
|
+
deferred4_1 = len3;
|
|
566
|
+
return getStringFromWasm0(ptr3, len3);
|
|
567
|
+
} finally {
|
|
568
|
+
wasm.__wbindgen_free(deferred4_0, deferred4_1, 1);
|
|
569
|
+
}
|
|
570
|
+
}
|
|
571
|
+
|
|
572
|
+
/**
|
|
573
|
+
* Get code completion suggestions.
|
|
574
|
+
* @param {string} source
|
|
575
|
+
* @param {number} line
|
|
576
|
+
* @param {number} character
|
|
577
|
+
* @returns {string}
|
|
578
|
+
*/
|
|
579
|
+
export function lsp_completion(source, line, character) {
|
|
580
|
+
let deferred3_0;
|
|
581
|
+
let deferred3_1;
|
|
582
|
+
try {
|
|
583
|
+
const ptr0 = passStringToWasm0(source, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
584
|
+
const len0 = WASM_VECTOR_LEN;
|
|
585
|
+
const ret = wasm.lsp_completion(ptr0, len0, line, character);
|
|
586
|
+
var ptr2 = ret[0];
|
|
587
|
+
var len2 = ret[1];
|
|
588
|
+
if (ret[3]) {
|
|
589
|
+
ptr2 = 0; len2 = 0;
|
|
590
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
591
|
+
}
|
|
592
|
+
deferred3_0 = ptr2;
|
|
593
|
+
deferred3_1 = len2;
|
|
594
|
+
return getStringFromWasm0(ptr2, len2);
|
|
595
|
+
} finally {
|
|
596
|
+
wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
|
|
597
|
+
}
|
|
598
|
+
}
|
|
599
|
+
|
|
600
|
+
/**
|
|
601
|
+
* Get code completion suggestions plus the completion timing breakdown used by the benchmark.
|
|
602
|
+
* @param {string} source
|
|
603
|
+
* @param {number} line
|
|
604
|
+
* @param {number} character
|
|
605
|
+
* @returns {string}
|
|
606
|
+
*/
|
|
607
|
+
export function lsp_completion_with_timing(source, line, character) {
|
|
608
|
+
let deferred3_0;
|
|
609
|
+
let deferred3_1;
|
|
610
|
+
try {
|
|
611
|
+
const ptr0 = passStringToWasm0(source, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
612
|
+
const len0 = WASM_VECTOR_LEN;
|
|
613
|
+
const ret = wasm.lsp_completion_with_timing(ptr0, len0, line, character);
|
|
614
|
+
var ptr2 = ret[0];
|
|
615
|
+
var len2 = ret[1];
|
|
616
|
+
if (ret[3]) {
|
|
617
|
+
ptr2 = 0; len2 = 0;
|
|
618
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
619
|
+
}
|
|
620
|
+
deferred3_0 = ptr2;
|
|
621
|
+
deferred3_1 = len2;
|
|
622
|
+
return getStringFromWasm0(ptr2, len2);
|
|
623
|
+
} finally {
|
|
624
|
+
wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
|
|
625
|
+
}
|
|
626
|
+
}
|
|
627
|
+
|
|
628
|
+
/**
|
|
629
|
+
* Get go-to-definition target(s) for a position.
|
|
630
|
+
* @param {string} source
|
|
631
|
+
* @param {number} line
|
|
632
|
+
* @param {number} character
|
|
633
|
+
* @returns {string}
|
|
634
|
+
*/
|
|
635
|
+
export function lsp_definition(source, line, character) {
|
|
636
|
+
let deferred3_0;
|
|
637
|
+
let deferred3_1;
|
|
638
|
+
try {
|
|
639
|
+
const ptr0 = passStringToWasm0(source, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
640
|
+
const len0 = WASM_VECTOR_LEN;
|
|
641
|
+
const ret = wasm.lsp_definition(ptr0, len0, line, character);
|
|
642
|
+
var ptr2 = ret[0];
|
|
643
|
+
var len2 = ret[1];
|
|
644
|
+
if (ret[3]) {
|
|
645
|
+
ptr2 = 0; len2 = 0;
|
|
646
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
647
|
+
}
|
|
648
|
+
deferred3_0 = ptr2;
|
|
649
|
+
deferred3_1 = len2;
|
|
650
|
+
return getStringFromWasm0(ptr2, len2);
|
|
651
|
+
} finally {
|
|
652
|
+
wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
|
|
653
|
+
}
|
|
654
|
+
}
|
|
655
|
+
|
|
656
|
+
/**
|
|
657
|
+
* Compute diagnostics (syntax, lint, and compilation errors).
|
|
658
|
+
* @param {string} source
|
|
659
|
+
* @returns {string}
|
|
660
|
+
*/
|
|
661
|
+
export function lsp_diagnostics(source) {
|
|
662
|
+
let deferred3_0;
|
|
663
|
+
let deferred3_1;
|
|
664
|
+
try {
|
|
665
|
+
const ptr0 = passStringToWasm0(source, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
666
|
+
const len0 = WASM_VECTOR_LEN;
|
|
667
|
+
const ret = wasm.lsp_diagnostics(ptr0, len0);
|
|
668
|
+
var ptr2 = ret[0];
|
|
669
|
+
var len2 = ret[1];
|
|
670
|
+
if (ret[3]) {
|
|
671
|
+
ptr2 = 0; len2 = 0;
|
|
672
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
673
|
+
}
|
|
674
|
+
deferred3_0 = ptr2;
|
|
675
|
+
deferred3_1 = len2;
|
|
676
|
+
return getStringFromWasm0(ptr2, len2);
|
|
677
|
+
} finally {
|
|
678
|
+
wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
|
|
679
|
+
}
|
|
680
|
+
}
|
|
681
|
+
|
|
682
|
+
/**
|
|
683
|
+
* Get document symbols (outline).
|
|
684
|
+
* @param {string} source
|
|
685
|
+
* @returns {string}
|
|
686
|
+
*/
|
|
687
|
+
export function lsp_document_symbols(source) {
|
|
688
|
+
let deferred3_0;
|
|
689
|
+
let deferred3_1;
|
|
690
|
+
try {
|
|
691
|
+
const ptr0 = passStringToWasm0(source, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
692
|
+
const len0 = WASM_VECTOR_LEN;
|
|
693
|
+
const ret = wasm.lsp_document_symbols(ptr0, len0);
|
|
694
|
+
var ptr2 = ret[0];
|
|
695
|
+
var len2 = ret[1];
|
|
696
|
+
if (ret[3]) {
|
|
697
|
+
ptr2 = 0; len2 = 0;
|
|
698
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
699
|
+
}
|
|
700
|
+
deferred3_0 = ptr2;
|
|
701
|
+
deferred3_1 = len2;
|
|
702
|
+
return getStringFromWasm0(ptr2, len2);
|
|
703
|
+
} finally {
|
|
704
|
+
wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
|
|
705
|
+
}
|
|
706
|
+
}
|
|
707
|
+
|
|
708
|
+
/**
|
|
709
|
+
* Get hover information for a position.
|
|
710
|
+
* @param {string} source
|
|
711
|
+
* @param {number} line
|
|
712
|
+
* @param {number} character
|
|
713
|
+
* @returns {string}
|
|
714
|
+
*/
|
|
715
|
+
export function lsp_hover(source, line, character) {
|
|
716
|
+
let deferred3_0;
|
|
717
|
+
let deferred3_1;
|
|
718
|
+
try {
|
|
719
|
+
const ptr0 = passStringToWasm0(source, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
720
|
+
const len0 = WASM_VECTOR_LEN;
|
|
721
|
+
const ret = wasm.lsp_hover(ptr0, len0, line, character);
|
|
722
|
+
var ptr2 = ret[0];
|
|
723
|
+
var len2 = ret[1];
|
|
724
|
+
if (ret[3]) {
|
|
725
|
+
ptr2 = 0; len2 = 0;
|
|
726
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
727
|
+
}
|
|
728
|
+
deferred3_0 = ptr2;
|
|
729
|
+
deferred3_1 = len2;
|
|
730
|
+
return getStringFromWasm0(ptr2, len2);
|
|
731
|
+
} finally {
|
|
732
|
+
wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
|
|
733
|
+
}
|
|
734
|
+
}
|
|
735
|
+
|
|
736
|
+
/**
|
|
737
|
+
* Get the semantic token legend.
|
|
738
|
+
* @returns {string}
|
|
739
|
+
*/
|
|
740
|
+
export function lsp_semantic_token_legend() {
|
|
741
|
+
let deferred2_0;
|
|
742
|
+
let deferred2_1;
|
|
743
|
+
try {
|
|
744
|
+
const ret = wasm.lsp_semantic_token_legend();
|
|
745
|
+
var ptr1 = ret[0];
|
|
746
|
+
var len1 = ret[1];
|
|
747
|
+
if (ret[3]) {
|
|
748
|
+
ptr1 = 0; len1 = 0;
|
|
749
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
750
|
+
}
|
|
751
|
+
deferred2_0 = ptr1;
|
|
752
|
+
deferred2_1 = len1;
|
|
753
|
+
return getStringFromWasm0(ptr1, len1);
|
|
754
|
+
} finally {
|
|
755
|
+
wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
|
|
756
|
+
}
|
|
757
|
+
}
|
|
758
|
+
|
|
759
|
+
/**
|
|
760
|
+
* Get semantic tokens for syntax highlighting.
|
|
761
|
+
* @param {string} source
|
|
762
|
+
* @returns {string}
|
|
763
|
+
*/
|
|
764
|
+
export function lsp_semantic_tokens(source) {
|
|
765
|
+
let deferred3_0;
|
|
766
|
+
let deferred3_1;
|
|
767
|
+
try {
|
|
768
|
+
const ptr0 = passStringToWasm0(source, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
769
|
+
const len0 = WASM_VECTOR_LEN;
|
|
770
|
+
const ret = wasm.lsp_semantic_tokens(ptr0, len0);
|
|
771
|
+
var ptr2 = ret[0];
|
|
772
|
+
var len2 = ret[1];
|
|
773
|
+
if (ret[3]) {
|
|
774
|
+
ptr2 = 0; len2 = 0;
|
|
775
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
776
|
+
}
|
|
777
|
+
deferred3_0 = ptr2;
|
|
778
|
+
deferred3_1 = len2;
|
|
779
|
+
return getStringFromWasm0(ptr2, len2);
|
|
780
|
+
} finally {
|
|
781
|
+
wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
|
|
782
|
+
}
|
|
783
|
+
}
|
|
784
|
+
|
|
785
|
+
/**
|
|
786
|
+
* @param {string} definitions_json
|
|
787
|
+
* @returns {number}
|
|
788
|
+
*/
|
|
789
|
+
export function merge_parsed_source_roots(definitions_json) {
|
|
790
|
+
const ptr0 = passStringToWasm0(definitions_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
791
|
+
const len0 = WASM_VECTOR_LEN;
|
|
792
|
+
const ret = wasm.merge_parsed_source_roots(ptr0, len0);
|
|
793
|
+
if (ret[2]) {
|
|
794
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
795
|
+
}
|
|
796
|
+
return ret[0] >>> 0;
|
|
797
|
+
}
|
|
798
|
+
|
|
799
|
+
/**
|
|
800
|
+
* @param {Uint8Array} bytes
|
|
801
|
+
* @returns {number}
|
|
802
|
+
*/
|
|
803
|
+
export function merge_parsed_source_roots_binary(bytes) {
|
|
804
|
+
const ptr0 = passArray8ToWasm0(bytes, wasm.__wbindgen_malloc);
|
|
805
|
+
const len0 = WASM_VECTOR_LEN;
|
|
806
|
+
const ret = wasm.merge_parsed_source_roots_binary(ptr0, len0);
|
|
807
|
+
if (ret[2]) {
|
|
808
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
809
|
+
}
|
|
810
|
+
return ret[0] >>> 0;
|
|
811
|
+
}
|
|
812
|
+
|
|
813
|
+
/**
|
|
814
|
+
* Parse Modelica source code and return whether it's valid.
|
|
815
|
+
* @param {string} source
|
|
816
|
+
* @returns {any}
|
|
817
|
+
*/
|
|
818
|
+
export function parse(source) {
|
|
819
|
+
const ptr0 = passStringToWasm0(source, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
820
|
+
const len0 = WASM_VECTOR_LEN;
|
|
821
|
+
const ret = wasm.parse(ptr0, len0);
|
|
822
|
+
return ret;
|
|
823
|
+
}
|
|
824
|
+
|
|
825
|
+
/**
|
|
826
|
+
* @param {string} source
|
|
827
|
+
* @param {string} filename
|
|
828
|
+
* @returns {string}
|
|
829
|
+
*/
|
|
830
|
+
export function parse_source_root_file(source, filename) {
|
|
831
|
+
let deferred4_0;
|
|
832
|
+
let deferred4_1;
|
|
833
|
+
try {
|
|
834
|
+
const ptr0 = passStringToWasm0(source, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
835
|
+
const len0 = WASM_VECTOR_LEN;
|
|
836
|
+
const ptr1 = passStringToWasm0(filename, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
837
|
+
const len1 = WASM_VECTOR_LEN;
|
|
838
|
+
const ret = wasm.parse_source_root_file(ptr0, len0, ptr1, len1);
|
|
839
|
+
var ptr3 = ret[0];
|
|
840
|
+
var len3 = ret[1];
|
|
841
|
+
if (ret[3]) {
|
|
842
|
+
ptr3 = 0; len3 = 0;
|
|
843
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
844
|
+
}
|
|
845
|
+
deferred4_0 = ptr3;
|
|
846
|
+
deferred4_1 = len3;
|
|
847
|
+
return getStringFromWasm0(ptr3, len3);
|
|
848
|
+
} finally {
|
|
849
|
+
wasm.__wbindgen_free(deferred4_0, deferred4_1, 1);
|
|
850
|
+
}
|
|
851
|
+
}
|
|
852
|
+
|
|
853
|
+
/**
|
|
854
|
+
* Prepare a model for WebGPU execution.
|
|
855
|
+
*
|
|
856
|
+
* Compiles `source`, lowers it to the Solve IR with simulation defaults
|
|
857
|
+
* (honoring the model's `experiment` annotation like `simulate_model`),
|
|
858
|
+
* renders the `wgsl-solve` builtin target, and returns a JSON object:
|
|
859
|
+
*
|
|
860
|
+
* ```json
|
|
861
|
+
* {
|
|
862
|
+
* "wgsl": "...compute shader source...",
|
|
863
|
+
* "layout": { ...the wgsl-solve layout manifest... },
|
|
864
|
+
* "y0": [..], "p0": [..],
|
|
865
|
+
* "n_states": 3,
|
|
866
|
+
* "t_start": 0.0, "t_end": 1.0, "dt": 0.01
|
|
867
|
+
* }
|
|
868
|
+
* ```
|
|
869
|
+
*
|
|
870
|
+
* v1 semantics: the host integrates the first `n_states` entries of `y`;
|
|
871
|
+
* the remaining (algebraic) slots and all parameters - including relation
|
|
872
|
+
* memory - stay frozen at their prepared initial values. The layout's
|
|
873
|
+
* `runtime_event_roots` count lets hosts warn when that matters.
|
|
874
|
+
* @param {string} source
|
|
875
|
+
* @param {string} model_name
|
|
876
|
+
* @returns {string}
|
|
877
|
+
*/
|
|
878
|
+
export function prepare_gpu_simulation(source, model_name) {
|
|
879
|
+
let deferred4_0;
|
|
880
|
+
let deferred4_1;
|
|
881
|
+
try {
|
|
882
|
+
const ptr0 = passStringToWasm0(source, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
883
|
+
const len0 = WASM_VECTOR_LEN;
|
|
884
|
+
const ptr1 = passStringToWasm0(model_name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
885
|
+
const len1 = WASM_VECTOR_LEN;
|
|
886
|
+
const ret = wasm.prepare_gpu_simulation(ptr0, len0, ptr1, len1);
|
|
887
|
+
var ptr3 = ret[0];
|
|
888
|
+
var len3 = ret[1];
|
|
889
|
+
if (ret[3]) {
|
|
890
|
+
ptr3 = 0; len3 = 0;
|
|
891
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
892
|
+
}
|
|
893
|
+
deferred4_0 = ptr3;
|
|
894
|
+
deferred4_1 = len3;
|
|
895
|
+
return getStringFromWasm0(ptr3, len3);
|
|
896
|
+
} finally {
|
|
897
|
+
wasm.__wbindgen_free(deferred4_0, deferred4_1, 1);
|
|
898
|
+
}
|
|
899
|
+
}
|
|
900
|
+
|
|
901
|
+
/**
|
|
902
|
+
* @param {string} dae_json
|
|
903
|
+
* @param {string} model_name
|
|
904
|
+
* @param {string} target
|
|
905
|
+
* @param {string} manifest_source
|
|
906
|
+
* @param {string} templates_json
|
|
907
|
+
* @returns {any}
|
|
908
|
+
*/
|
|
909
|
+
export function render_target(dae_json, model_name, target, manifest_source, templates_json) {
|
|
910
|
+
const ptr0 = passStringToWasm0(dae_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
911
|
+
const len0 = WASM_VECTOR_LEN;
|
|
912
|
+
const ptr1 = passStringToWasm0(model_name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
913
|
+
const len1 = WASM_VECTOR_LEN;
|
|
914
|
+
const ptr2 = passStringToWasm0(target, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
915
|
+
const len2 = WASM_VECTOR_LEN;
|
|
916
|
+
const ptr3 = passStringToWasm0(manifest_source, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
917
|
+
const len3 = WASM_VECTOR_LEN;
|
|
918
|
+
const ptr4 = passStringToWasm0(templates_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
919
|
+
const len4 = WASM_VECTOR_LEN;
|
|
920
|
+
const ret = wasm.render_target(ptr0, len0, ptr1, len1, ptr2, len2, ptr3, len3, ptr4, len4);
|
|
921
|
+
if (ret[2]) {
|
|
922
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
923
|
+
}
|
|
924
|
+
return takeFromExternrefTable0(ret[0]);
|
|
925
|
+
}
|
|
926
|
+
|
|
927
|
+
/**
|
|
928
|
+
* Compile and simulate a Modelica model.
|
|
929
|
+
* @param {string} source
|
|
930
|
+
* @param {string} model_name
|
|
931
|
+
* @param {number} t_end
|
|
932
|
+
* @param {number} dt
|
|
933
|
+
* @param {string} solver
|
|
934
|
+
* @returns {string}
|
|
935
|
+
*/
|
|
936
|
+
export function simulate_model(source, model_name, t_end, dt, solver) {
|
|
937
|
+
let deferred5_0;
|
|
938
|
+
let deferred5_1;
|
|
939
|
+
try {
|
|
940
|
+
const ptr0 = passStringToWasm0(source, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
941
|
+
const len0 = WASM_VECTOR_LEN;
|
|
942
|
+
const ptr1 = passStringToWasm0(model_name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
943
|
+
const len1 = WASM_VECTOR_LEN;
|
|
944
|
+
const ptr2 = passStringToWasm0(solver, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
945
|
+
const len2 = WASM_VECTOR_LEN;
|
|
946
|
+
const ret = wasm.simulate_model(ptr0, len0, ptr1, len1, t_end, dt, ptr2, len2);
|
|
947
|
+
var ptr4 = ret[0];
|
|
948
|
+
var len4 = ret[1];
|
|
949
|
+
if (ret[3]) {
|
|
950
|
+
ptr4 = 0; len4 = 0;
|
|
951
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
952
|
+
}
|
|
953
|
+
deferred5_0 = ptr4;
|
|
954
|
+
deferred5_1 = len4;
|
|
955
|
+
return getStringFromWasm0(ptr4, len4);
|
|
956
|
+
} finally {
|
|
957
|
+
wasm.__wbindgen_free(deferred5_0, deferred5_1, 1);
|
|
958
|
+
}
|
|
959
|
+
}
|
|
960
|
+
|
|
961
|
+
/**
|
|
962
|
+
* Compile with additional project-local sources and simulate a Modelica model.
|
|
963
|
+
* @param {string} source
|
|
964
|
+
* @param {string} model_name
|
|
965
|
+
* @param {string} project_sources_json
|
|
966
|
+
* @param {number} t_end
|
|
967
|
+
* @param {number} dt
|
|
968
|
+
* @param {string} solver
|
|
969
|
+
* @returns {string}
|
|
970
|
+
*/
|
|
971
|
+
export function simulate_model_with_project_sources(source, model_name, project_sources_json, t_end, dt, solver) {
|
|
972
|
+
let deferred6_0;
|
|
973
|
+
let deferred6_1;
|
|
974
|
+
try {
|
|
975
|
+
const ptr0 = passStringToWasm0(source, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
976
|
+
const len0 = WASM_VECTOR_LEN;
|
|
977
|
+
const ptr1 = passStringToWasm0(model_name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
978
|
+
const len1 = WASM_VECTOR_LEN;
|
|
979
|
+
const ptr2 = passStringToWasm0(project_sources_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
980
|
+
const len2 = WASM_VECTOR_LEN;
|
|
981
|
+
const ptr3 = passStringToWasm0(solver, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
982
|
+
const len3 = WASM_VECTOR_LEN;
|
|
983
|
+
const ret = wasm.simulate_model_with_project_sources(ptr0, len0, ptr1, len1, ptr2, len2, t_end, dt, ptr3, len3);
|
|
984
|
+
var ptr5 = ret[0];
|
|
985
|
+
var len5 = ret[1];
|
|
986
|
+
if (ret[3]) {
|
|
987
|
+
ptr5 = 0; len5 = 0;
|
|
988
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
989
|
+
}
|
|
990
|
+
deferred6_0 = ptr5;
|
|
991
|
+
deferred6_1 = len5;
|
|
992
|
+
return getStringFromWasm0(ptr5, len5);
|
|
993
|
+
} finally {
|
|
994
|
+
wasm.__wbindgen_free(deferred6_0, deferred6_1, 1);
|
|
995
|
+
}
|
|
996
|
+
}
|
|
997
|
+
|
|
998
|
+
/**
|
|
999
|
+
* @param {string} project_sources_json
|
|
1000
|
+
* @returns {string}
|
|
1001
|
+
*/
|
|
1002
|
+
export function sync_project_sources(project_sources_json) {
|
|
1003
|
+
let deferred3_0;
|
|
1004
|
+
let deferred3_1;
|
|
1005
|
+
try {
|
|
1006
|
+
const ptr0 = passStringToWasm0(project_sources_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
1007
|
+
const len0 = WASM_VECTOR_LEN;
|
|
1008
|
+
const ret = wasm.sync_project_sources(ptr0, len0);
|
|
1009
|
+
var ptr2 = ret[0];
|
|
1010
|
+
var len2 = ret[1];
|
|
1011
|
+
if (ret[3]) {
|
|
1012
|
+
ptr2 = 0; len2 = 0;
|
|
1013
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
1014
|
+
}
|
|
1015
|
+
deferred3_0 = ptr2;
|
|
1016
|
+
deferred3_1 = len2;
|
|
1017
|
+
return getStringFromWasm0(ptr2, len2);
|
|
1018
|
+
} finally {
|
|
1019
|
+
wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
|
|
1020
|
+
}
|
|
1021
|
+
}
|
|
1022
|
+
|
|
1023
|
+
/**
|
|
1024
|
+
* Re-settle the prepared vectors of the last `prepare_gpu_simulation` for
|
|
1025
|
+
* new parameter values, without re-lowering the model. `overrides_json`
|
|
1026
|
+
* is a `{ "name": value }` object naming scalar parameters. Returns
|
|
1027
|
+
* `{ "y0": [...], "p0": [...] }`.
|
|
1028
|
+
* @param {string} source
|
|
1029
|
+
* @param {string} model_name
|
|
1030
|
+
* @param {string} overrides_json
|
|
1031
|
+
* @returns {string}
|
|
1032
|
+
*/
|
|
1033
|
+
export function update_gpu_parameters(source, model_name, overrides_json) {
|
|
1034
|
+
let deferred5_0;
|
|
1035
|
+
let deferred5_1;
|
|
1036
|
+
try {
|
|
1037
|
+
const ptr0 = passStringToWasm0(source, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
1038
|
+
const len0 = WASM_VECTOR_LEN;
|
|
1039
|
+
const ptr1 = passStringToWasm0(model_name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
1040
|
+
const len1 = WASM_VECTOR_LEN;
|
|
1041
|
+
const ptr2 = passStringToWasm0(overrides_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
1042
|
+
const len2 = WASM_VECTOR_LEN;
|
|
1043
|
+
const ret = wasm.update_gpu_parameters(ptr0, len0, ptr1, len1, ptr2, len2);
|
|
1044
|
+
var ptr4 = ret[0];
|
|
1045
|
+
var len4 = ret[1];
|
|
1046
|
+
if (ret[3]) {
|
|
1047
|
+
ptr4 = 0; len4 = 0;
|
|
1048
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
1049
|
+
}
|
|
1050
|
+
deferred5_0 = ptr4;
|
|
1051
|
+
deferred5_1 = len4;
|
|
1052
|
+
return getStringFromWasm0(ptr4, len4);
|
|
1053
|
+
} finally {
|
|
1054
|
+
wasm.__wbindgen_free(deferred5_0, deferred5_1, 1);
|
|
1055
|
+
}
|
|
1056
|
+
}
|
|
1057
|
+
|
|
1058
|
+
/**
|
|
1059
|
+
* Fallback thread-pool initializer for non-threaded builds.
|
|
1060
|
+
* @param {number} _num_threads
|
|
1061
|
+
* @returns {boolean}
|
|
1062
|
+
*/
|
|
1063
|
+
export function wasm_init(_num_threads) {
|
|
1064
|
+
const ret = wasm.wasm_init(_num_threads);
|
|
1065
|
+
return ret !== 0;
|
|
1066
|
+
}
|
|
1067
|
+
|
|
1068
|
+
function __wbg_get_imports() {
|
|
1069
|
+
const import0 = {
|
|
1070
|
+
__proto__: null,
|
|
1071
|
+
__wbg_String_8f0eb39a4a4c2f66: function(arg0, arg1) {
|
|
1072
|
+
const ret = String(arg1);
|
|
1073
|
+
const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
1074
|
+
const len1 = WASM_VECTOR_LEN;
|
|
1075
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
|
|
1076
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
|
|
1077
|
+
},
|
|
1078
|
+
__wbg___wbindgen_debug_string_0bc8482c6e3508ae: function(arg0, arg1) {
|
|
1079
|
+
const ret = debugString(arg1);
|
|
1080
|
+
const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
1081
|
+
const len1 = WASM_VECTOR_LEN;
|
|
1082
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
|
|
1083
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
|
|
1084
|
+
},
|
|
1085
|
+
__wbg___wbindgen_is_undefined_9e4d92534c42d778: function(arg0) {
|
|
1086
|
+
const ret = arg0 === undefined;
|
|
1087
|
+
return ret;
|
|
1088
|
+
},
|
|
1089
|
+
__wbg___wbindgen_throw_be289d5034ed271b: function(arg0, arg1) {
|
|
1090
|
+
throw new Error(getStringFromWasm0(arg0, arg1));
|
|
1091
|
+
},
|
|
1092
|
+
__wbg_call_389efe28435a9388: function() { return handleError(function (arg0, arg1) {
|
|
1093
|
+
const ret = arg0.call(arg1);
|
|
1094
|
+
return ret;
|
|
1095
|
+
}, arguments); },
|
|
1096
|
+
__wbg_error_7534b8e9a36f1ab4: function(arg0, arg1) {
|
|
1097
|
+
let deferred0_0;
|
|
1098
|
+
let deferred0_1;
|
|
1099
|
+
try {
|
|
1100
|
+
deferred0_0 = arg0;
|
|
1101
|
+
deferred0_1 = arg1;
|
|
1102
|
+
console.error(getStringFromWasm0(arg0, arg1));
|
|
1103
|
+
} finally {
|
|
1104
|
+
wasm.__wbindgen_free(deferred0_0, deferred0_1, 1);
|
|
1105
|
+
}
|
|
1106
|
+
},
|
|
1107
|
+
__wbg_get_b3ed3ad4be2bc8ac: function() { return handleError(function (arg0, arg1) {
|
|
1108
|
+
const ret = Reflect.get(arg0, arg1);
|
|
1109
|
+
return ret;
|
|
1110
|
+
}, arguments); },
|
|
1111
|
+
__wbg_log_30dc80163601f3bb: function(arg0, arg1) {
|
|
1112
|
+
console.log(getStringFromWasm0(arg0, arg1));
|
|
1113
|
+
},
|
|
1114
|
+
__wbg_new_361308b2356cecd0: function() {
|
|
1115
|
+
const ret = new Object();
|
|
1116
|
+
return ret;
|
|
1117
|
+
},
|
|
1118
|
+
__wbg_new_3eb36ae241fe6f44: function() {
|
|
1119
|
+
const ret = new Array();
|
|
1120
|
+
return ret;
|
|
1121
|
+
},
|
|
1122
|
+
__wbg_new_8a6f238a6ece86ea: function() {
|
|
1123
|
+
const ret = new Error();
|
|
1124
|
+
return ret;
|
|
1125
|
+
},
|
|
1126
|
+
__wbg_new_no_args_1c7c842f08d00ebb: function(arg0, arg1) {
|
|
1127
|
+
const ret = new Function(getStringFromWasm0(arg0, arg1));
|
|
1128
|
+
return ret;
|
|
1129
|
+
},
|
|
1130
|
+
__wbg_now_a3af9a2f4bbaa4d1: function() {
|
|
1131
|
+
const ret = Date.now();
|
|
1132
|
+
return ret;
|
|
1133
|
+
},
|
|
1134
|
+
__wbg_now_ebffdf7e580f210d: function(arg0) {
|
|
1135
|
+
const ret = arg0.now();
|
|
1136
|
+
return ret;
|
|
1137
|
+
},
|
|
1138
|
+
__wbg_set_3f1d0b984ed272ed: function(arg0, arg1, arg2) {
|
|
1139
|
+
arg0[arg1] = arg2;
|
|
1140
|
+
},
|
|
1141
|
+
__wbg_set_f43e577aea94465b: function(arg0, arg1, arg2) {
|
|
1142
|
+
arg0[arg1 >>> 0] = arg2;
|
|
1143
|
+
},
|
|
1144
|
+
__wbg_stack_0ed75d68575b0f3c: function(arg0, arg1) {
|
|
1145
|
+
const ret = arg1.stack;
|
|
1146
|
+
const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
1147
|
+
const len1 = WASM_VECTOR_LEN;
|
|
1148
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
|
|
1149
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
|
|
1150
|
+
},
|
|
1151
|
+
__wbg_static_accessor_GLOBAL_12837167ad935116: function() {
|
|
1152
|
+
const ret = typeof global === 'undefined' ? null : global;
|
|
1153
|
+
return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
|
|
1154
|
+
},
|
|
1155
|
+
__wbg_static_accessor_GLOBAL_THIS_e628e89ab3b1c95f: function() {
|
|
1156
|
+
const ret = typeof globalThis === 'undefined' ? null : globalThis;
|
|
1157
|
+
return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
|
|
1158
|
+
},
|
|
1159
|
+
__wbg_static_accessor_SELF_a621d3dfbb60d0ce: function() {
|
|
1160
|
+
const ret = typeof self === 'undefined' ? null : self;
|
|
1161
|
+
return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
|
|
1162
|
+
},
|
|
1163
|
+
__wbg_static_accessor_WINDOW_f8727f0cf888e0bd: function() {
|
|
1164
|
+
const ret = typeof window === 'undefined' ? null : window;
|
|
1165
|
+
return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
|
|
1166
|
+
},
|
|
1167
|
+
__wbindgen_cast_0000000000000001: function(arg0) {
|
|
1168
|
+
// Cast intrinsic for `F64 -> Externref`.
|
|
1169
|
+
const ret = arg0;
|
|
1170
|
+
return ret;
|
|
1171
|
+
},
|
|
1172
|
+
__wbindgen_cast_0000000000000002: function(arg0, arg1) {
|
|
1173
|
+
// Cast intrinsic for `Ref(String) -> Externref`.
|
|
1174
|
+
const ret = getStringFromWasm0(arg0, arg1);
|
|
1175
|
+
return ret;
|
|
1176
|
+
},
|
|
1177
|
+
__wbindgen_init_externref_table: function() {
|
|
1178
|
+
const table = wasm.__wbindgen_externrefs;
|
|
1179
|
+
const offset = table.grow(4);
|
|
1180
|
+
table.set(0, undefined);
|
|
1181
|
+
table.set(offset + 0, undefined);
|
|
1182
|
+
table.set(offset + 1, null);
|
|
1183
|
+
table.set(offset + 2, true);
|
|
1184
|
+
table.set(offset + 3, false);
|
|
1185
|
+
},
|
|
1186
|
+
};
|
|
1187
|
+
return {
|
|
1188
|
+
__proto__: null,
|
|
1189
|
+
"./rumoca_bind_wasm_bg.js": import0,
|
|
1190
|
+
};
|
|
1191
|
+
}
|
|
1192
|
+
|
|
1193
|
+
function addToExternrefTable0(obj) {
|
|
1194
|
+
const idx = wasm.__externref_table_alloc();
|
|
1195
|
+
wasm.__wbindgen_externrefs.set(idx, obj);
|
|
1196
|
+
return idx;
|
|
1197
|
+
}
|
|
1198
|
+
|
|
1199
|
+
function debugString(val) {
|
|
1200
|
+
// primitive types
|
|
1201
|
+
const type = typeof val;
|
|
1202
|
+
if (type == 'number' || type == 'boolean' || val == null) {
|
|
1203
|
+
return `${val}`;
|
|
1204
|
+
}
|
|
1205
|
+
if (type == 'string') {
|
|
1206
|
+
return `"${val}"`;
|
|
1207
|
+
}
|
|
1208
|
+
if (type == 'symbol') {
|
|
1209
|
+
const description = val.description;
|
|
1210
|
+
if (description == null) {
|
|
1211
|
+
return 'Symbol';
|
|
1212
|
+
} else {
|
|
1213
|
+
return `Symbol(${description})`;
|
|
1214
|
+
}
|
|
1215
|
+
}
|
|
1216
|
+
if (type == 'function') {
|
|
1217
|
+
const name = val.name;
|
|
1218
|
+
if (typeof name == 'string' && name.length > 0) {
|
|
1219
|
+
return `Function(${name})`;
|
|
1220
|
+
} else {
|
|
1221
|
+
return 'Function';
|
|
1222
|
+
}
|
|
1223
|
+
}
|
|
1224
|
+
// objects
|
|
1225
|
+
if (Array.isArray(val)) {
|
|
1226
|
+
const length = val.length;
|
|
1227
|
+
let debug = '[';
|
|
1228
|
+
if (length > 0) {
|
|
1229
|
+
debug += debugString(val[0]);
|
|
1230
|
+
}
|
|
1231
|
+
for(let i = 1; i < length; i++) {
|
|
1232
|
+
debug += ', ' + debugString(val[i]);
|
|
1233
|
+
}
|
|
1234
|
+
debug += ']';
|
|
1235
|
+
return debug;
|
|
1236
|
+
}
|
|
1237
|
+
// Test for built-in
|
|
1238
|
+
const builtInMatches = /\[object ([^\]]+)\]/.exec(toString.call(val));
|
|
1239
|
+
let className;
|
|
1240
|
+
if (builtInMatches && builtInMatches.length > 1) {
|
|
1241
|
+
className = builtInMatches[1];
|
|
1242
|
+
} else {
|
|
1243
|
+
// Failed to match the standard '[object ClassName]'
|
|
1244
|
+
return toString.call(val);
|
|
1245
|
+
}
|
|
1246
|
+
if (className == 'Object') {
|
|
1247
|
+
// we're a user defined class or Object
|
|
1248
|
+
// JSON.stringify avoids problems with cycles, and is generally much
|
|
1249
|
+
// easier than looping through ownProperties of `val`.
|
|
1250
|
+
try {
|
|
1251
|
+
return 'Object(' + JSON.stringify(val) + ')';
|
|
1252
|
+
} catch (_) {
|
|
1253
|
+
return 'Object';
|
|
1254
|
+
}
|
|
1255
|
+
}
|
|
1256
|
+
// errors
|
|
1257
|
+
if (val instanceof Error) {
|
|
1258
|
+
return `${val.name}: ${val.message}\n${val.stack}`;
|
|
1259
|
+
}
|
|
1260
|
+
// TODO we could test for more things here, like `Set`s and `Map`s.
|
|
1261
|
+
return className;
|
|
1262
|
+
}
|
|
1263
|
+
|
|
1264
|
+
function getArrayU8FromWasm0(ptr, len) {
|
|
1265
|
+
ptr = ptr >>> 0;
|
|
1266
|
+
return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
|
|
1267
|
+
}
|
|
1268
|
+
|
|
1269
|
+
let cachedDataViewMemory0 = null;
|
|
1270
|
+
function getDataViewMemory0() {
|
|
1271
|
+
if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || (cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm.memory.buffer)) {
|
|
1272
|
+
cachedDataViewMemory0 = new DataView(wasm.memory.buffer);
|
|
1273
|
+
}
|
|
1274
|
+
return cachedDataViewMemory0;
|
|
1275
|
+
}
|
|
1276
|
+
|
|
1277
|
+
function getStringFromWasm0(ptr, len) {
|
|
1278
|
+
ptr = ptr >>> 0;
|
|
1279
|
+
return decodeText(ptr, len);
|
|
1280
|
+
}
|
|
1281
|
+
|
|
1282
|
+
let cachedUint8ArrayMemory0 = null;
|
|
1283
|
+
function getUint8ArrayMemory0() {
|
|
1284
|
+
if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
|
|
1285
|
+
cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
|
|
1286
|
+
}
|
|
1287
|
+
return cachedUint8ArrayMemory0;
|
|
1288
|
+
}
|
|
1289
|
+
|
|
1290
|
+
function handleError(f, args) {
|
|
1291
|
+
try {
|
|
1292
|
+
return f.apply(this, args);
|
|
1293
|
+
} catch (e) {
|
|
1294
|
+
const idx = addToExternrefTable0(e);
|
|
1295
|
+
wasm.__wbindgen_exn_store(idx);
|
|
1296
|
+
}
|
|
1297
|
+
}
|
|
1298
|
+
|
|
1299
|
+
function isLikeNone(x) {
|
|
1300
|
+
return x === undefined || x === null;
|
|
1301
|
+
}
|
|
1302
|
+
|
|
1303
|
+
function passArray8ToWasm0(arg, malloc) {
|
|
1304
|
+
const ptr = malloc(arg.length * 1, 1) >>> 0;
|
|
1305
|
+
getUint8ArrayMemory0().set(arg, ptr / 1);
|
|
1306
|
+
WASM_VECTOR_LEN = arg.length;
|
|
1307
|
+
return ptr;
|
|
1308
|
+
}
|
|
1309
|
+
|
|
1310
|
+
function passStringToWasm0(arg, malloc, realloc) {
|
|
1311
|
+
if (realloc === undefined) {
|
|
1312
|
+
const buf = cachedTextEncoder.encode(arg);
|
|
1313
|
+
const ptr = malloc(buf.length, 1) >>> 0;
|
|
1314
|
+
getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);
|
|
1315
|
+
WASM_VECTOR_LEN = buf.length;
|
|
1316
|
+
return ptr;
|
|
1317
|
+
}
|
|
1318
|
+
|
|
1319
|
+
let len = arg.length;
|
|
1320
|
+
let ptr = malloc(len, 1) >>> 0;
|
|
1321
|
+
|
|
1322
|
+
const mem = getUint8ArrayMemory0();
|
|
1323
|
+
|
|
1324
|
+
let offset = 0;
|
|
1325
|
+
|
|
1326
|
+
for (; offset < len; offset++) {
|
|
1327
|
+
const code = arg.charCodeAt(offset);
|
|
1328
|
+
if (code > 0x7F) break;
|
|
1329
|
+
mem[ptr + offset] = code;
|
|
1330
|
+
}
|
|
1331
|
+
if (offset !== len) {
|
|
1332
|
+
if (offset !== 0) {
|
|
1333
|
+
arg = arg.slice(offset);
|
|
1334
|
+
}
|
|
1335
|
+
ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
|
|
1336
|
+
const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
|
|
1337
|
+
const ret = cachedTextEncoder.encodeInto(arg, view);
|
|
1338
|
+
|
|
1339
|
+
offset += ret.written;
|
|
1340
|
+
ptr = realloc(ptr, len, offset, 1) >>> 0;
|
|
1341
|
+
}
|
|
1342
|
+
|
|
1343
|
+
WASM_VECTOR_LEN = offset;
|
|
1344
|
+
return ptr;
|
|
1345
|
+
}
|
|
1346
|
+
|
|
1347
|
+
function takeFromExternrefTable0(idx) {
|
|
1348
|
+
const value = wasm.__wbindgen_externrefs.get(idx);
|
|
1349
|
+
wasm.__externref_table_dealloc(idx);
|
|
1350
|
+
return value;
|
|
1351
|
+
}
|
|
1352
|
+
|
|
1353
|
+
let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
|
|
1354
|
+
cachedTextDecoder.decode();
|
|
1355
|
+
const MAX_SAFARI_DECODE_BYTES = 2146435072;
|
|
1356
|
+
let numBytesDecoded = 0;
|
|
1357
|
+
function decodeText(ptr, len) {
|
|
1358
|
+
numBytesDecoded += len;
|
|
1359
|
+
if (numBytesDecoded >= MAX_SAFARI_DECODE_BYTES) {
|
|
1360
|
+
cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
|
|
1361
|
+
cachedTextDecoder.decode();
|
|
1362
|
+
numBytesDecoded = len;
|
|
1363
|
+
}
|
|
1364
|
+
return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
|
|
1365
|
+
}
|
|
1366
|
+
|
|
1367
|
+
const cachedTextEncoder = new TextEncoder();
|
|
1368
|
+
|
|
1369
|
+
if (!('encodeInto' in cachedTextEncoder)) {
|
|
1370
|
+
cachedTextEncoder.encodeInto = function (arg, view) {
|
|
1371
|
+
const buf = cachedTextEncoder.encode(arg);
|
|
1372
|
+
view.set(buf);
|
|
1373
|
+
return {
|
|
1374
|
+
read: arg.length,
|
|
1375
|
+
written: buf.length
|
|
1376
|
+
};
|
|
1377
|
+
};
|
|
1378
|
+
}
|
|
1379
|
+
|
|
1380
|
+
let WASM_VECTOR_LEN = 0;
|
|
1381
|
+
|
|
1382
|
+
let wasmModule, wasm;
|
|
1383
|
+
function __wbg_finalize_init(instance, module) {
|
|
1384
|
+
wasm = instance.exports;
|
|
1385
|
+
wasmModule = module;
|
|
1386
|
+
cachedDataViewMemory0 = null;
|
|
1387
|
+
cachedUint8ArrayMemory0 = null;
|
|
1388
|
+
wasm.__wbindgen_start();
|
|
1389
|
+
return wasm;
|
|
1390
|
+
}
|
|
1391
|
+
|
|
1392
|
+
async function __wbg_load(module, imports) {
|
|
1393
|
+
if (typeof Response === 'function' && module instanceof Response) {
|
|
1394
|
+
if (typeof WebAssembly.instantiateStreaming === 'function') {
|
|
1395
|
+
try {
|
|
1396
|
+
return await WebAssembly.instantiateStreaming(module, imports);
|
|
1397
|
+
} catch (e) {
|
|
1398
|
+
const validResponse = module.ok && expectedResponseType(module.type);
|
|
1399
|
+
|
|
1400
|
+
if (validResponse && module.headers.get('Content-Type') !== 'application/wasm') {
|
|
1401
|
+
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);
|
|
1402
|
+
|
|
1403
|
+
} else { throw e; }
|
|
1404
|
+
}
|
|
1405
|
+
}
|
|
1406
|
+
|
|
1407
|
+
const bytes = await module.arrayBuffer();
|
|
1408
|
+
return await WebAssembly.instantiate(bytes, imports);
|
|
1409
|
+
} else {
|
|
1410
|
+
const instance = await WebAssembly.instantiate(module, imports);
|
|
1411
|
+
|
|
1412
|
+
if (instance instanceof WebAssembly.Instance) {
|
|
1413
|
+
return { instance, module };
|
|
1414
|
+
} else {
|
|
1415
|
+
return instance;
|
|
1416
|
+
}
|
|
1417
|
+
}
|
|
1418
|
+
|
|
1419
|
+
function expectedResponseType(type) {
|
|
1420
|
+
switch (type) {
|
|
1421
|
+
case 'basic': case 'cors': case 'default': return true;
|
|
1422
|
+
}
|
|
1423
|
+
return false;
|
|
1424
|
+
}
|
|
1425
|
+
}
|
|
1426
|
+
|
|
1427
|
+
function initSync(module) {
|
|
1428
|
+
if (wasm !== undefined) return wasm;
|
|
1429
|
+
|
|
1430
|
+
|
|
1431
|
+
if (module !== undefined) {
|
|
1432
|
+
if (Object.getPrototypeOf(module) === Object.prototype) {
|
|
1433
|
+
({module} = module)
|
|
1434
|
+
} else {
|
|
1435
|
+
console.warn('using deprecated parameters for `initSync()`; pass a single object instead')
|
|
1436
|
+
}
|
|
1437
|
+
}
|
|
1438
|
+
|
|
1439
|
+
const imports = __wbg_get_imports();
|
|
1440
|
+
if (!(module instanceof WebAssembly.Module)) {
|
|
1441
|
+
module = new WebAssembly.Module(module);
|
|
1442
|
+
}
|
|
1443
|
+
const instance = new WebAssembly.Instance(module, imports);
|
|
1444
|
+
return __wbg_finalize_init(instance, module);
|
|
1445
|
+
}
|
|
1446
|
+
|
|
1447
|
+
async function __wbg_init(module_or_path) {
|
|
1448
|
+
if (wasm !== undefined) return wasm;
|
|
1449
|
+
|
|
1450
|
+
|
|
1451
|
+
if (module_or_path !== undefined) {
|
|
1452
|
+
if (Object.getPrototypeOf(module_or_path) === Object.prototype) {
|
|
1453
|
+
({module_or_path} = module_or_path)
|
|
1454
|
+
} else {
|
|
1455
|
+
console.warn('using deprecated parameters for the initialization function; pass a single object instead')
|
|
1456
|
+
}
|
|
1457
|
+
}
|
|
1458
|
+
|
|
1459
|
+
if (module_or_path === undefined) {
|
|
1460
|
+
module_or_path = new URL('rumoca_bind_wasm_bg.wasm', import.meta.url);
|
|
1461
|
+
}
|
|
1462
|
+
const imports = __wbg_get_imports();
|
|
1463
|
+
|
|
1464
|
+
if (typeof module_or_path === 'string' || (typeof Request === 'function' && module_or_path instanceof Request) || (typeof URL === 'function' && module_or_path instanceof URL)) {
|
|
1465
|
+
module_or_path = fetch(module_or_path);
|
|
1466
|
+
}
|
|
1467
|
+
|
|
1468
|
+
const { instance, module } = await __wbg_load(await module_or_path, imports);
|
|
1469
|
+
|
|
1470
|
+
return __wbg_finalize_init(instance, module);
|
|
1471
|
+
}
|
|
1472
|
+
|
|
1473
|
+
export { initSync, __wbg_init as default };
|