@opencor/opencor 0.20250826.0 → 0.20250827.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (56) hide show
  1. package/dist/opencor.es.js +1 -1
  2. package/package.json +5 -6
  3. package/src/App.vue +0 -7
  4. package/src/ContainerApp.vue +0 -21
  5. package/src/assets/app.css +0 -14
  6. package/src/assets/base.css +0 -31
  7. package/src/assets/logo.svg +0 -17
  8. package/src/common/common.ts +0 -86
  9. package/src/common/constants.ts +0 -12
  10. package/src/common/electron.ts +0 -23
  11. package/src/common/electronApi.ts +0 -63
  12. package/src/common/locCommon.ts +0 -170
  13. package/src/common/settings.ts +0 -95
  14. package/src/common/vueCommon.ts +0 -69
  15. package/src/components/BackgroundComponent.vue +0 -26
  16. package/src/components/BlockingMessageComponent.vue +0 -34
  17. package/src/components/ContentsComponent.vue +0 -277
  18. package/src/components/DragNDropComponent.vue +0 -35
  19. package/src/components/MainMenu.vue +0 -225
  20. package/src/components/OpenCOR.vue +0 -624
  21. package/src/components/dialogs/AboutDialog.vue +0 -51
  22. package/src/components/dialogs/BaseDialog.vue +0 -58
  23. package/src/components/dialogs/OpenRemoteDialog.vue +0 -37
  24. package/src/components/dialogs/ResetAllDialog.vue +0 -13
  25. package/src/components/dialogs/SettingsDialog.vue +0 -42
  26. package/src/components/dialogs/UpdateAvailableDialog.vue +0 -16
  27. package/src/components/dialogs/UpdateDownloadProgressDialog.vue +0 -11
  28. package/src/components/dialogs/UpdateErrorDialog.vue +0 -18
  29. package/src/components/dialogs/UpdateNotAvailableDialog.vue +0 -12
  30. package/src/components/propertyEditors/GraphsPropertyEditor.vue +0 -3
  31. package/src/components/propertyEditors/ParametersPropertyEditor.vue +0 -3
  32. package/src/components/propertyEditors/PropertyEditor.vue +0 -60
  33. package/src/components/propertyEditors/SimulationPropertyEditor.vue +0 -45
  34. package/src/components/propertyEditors/SolversPropertyEditor.vue +0 -3
  35. package/src/components/views/IssuesView.vue +0 -50
  36. package/src/components/views/SimulationExperimentUiView.vue +0 -154
  37. package/src/components/views/SimulationExperimentView.vue +0 -218
  38. package/src/components/widgets/GraphPanelWidget.vue +0 -140
  39. package/src/components/widgets/InputWidget.vue +0 -128
  40. package/src/libopencor/locApi.ts +0 -167
  41. package/src/libopencor/locFileApi.ts +0 -263
  42. package/src/libopencor/locLoggerApi.ts +0 -36
  43. package/src/libopencor/locSedApi.ts +0 -486
  44. package/src/libopencor/locUiJsonApi.ts +0 -485
  45. package/src/libopencor/locVersionApi.ts +0 -17
  46. package/src/libopencor/src/common.cpp +0 -67
  47. package/src/libopencor/src/common.h +0 -27
  48. package/src/libopencor/src/file.cpp +0 -72
  49. package/src/libopencor/src/file.h +0 -15
  50. package/src/libopencor/src/main.cpp +0 -78
  51. package/src/libopencor/src/sed.cpp +0 -348
  52. package/src/libopencor/src/sed.h +0 -53
  53. package/src/libopencor/src/version.cpp +0 -8
  54. package/src/libopencor/src/version.h +0 -5
  55. package/src/main.ts +0 -6
  56. package/src/types/types.d.ts +0 -9
@@ -1,485 +0,0 @@
1
- import * as jsonschema from 'jsonschema'
2
-
3
- import * as common from '../common/common.js'
4
-
5
- import { EIssueType, type IIssue } from './locLoggerApi.js'
6
-
7
- export interface IUiJson {
8
- input: IUiJsonInput[]
9
- output: IUiJsonOutput
10
- parameters: IUiJsonParameter[]
11
- }
12
-
13
- export type IUiJsonInput = IUiJsonDiscreteInput | IUiJsonScalarInput
14
-
15
- interface IUiJsonDiscreteInput {
16
- defaultValue: number
17
- id?: string
18
- name: string
19
- possibleValues: IUiJsonDiscreteInputPossibleValue[]
20
- visible?: string
21
- }
22
-
23
- export interface IUiJsonDiscreteInputPossibleValue {
24
- name: string
25
- value: number
26
- }
27
-
28
- interface IUiJsonScalarInput {
29
- defaultValue: number
30
- id?: string
31
- maximumValue: number
32
- minimumValue: number
33
- name: string
34
- stepValue?: number
35
- visible?: string
36
- }
37
-
38
- export interface IUiJsonOutput {
39
- data: IUiJsonOutputData[]
40
- plots: IUiJsonOutputPlot[]
41
- }
42
-
43
- export interface IUiJsonOutputData {
44
- id: string
45
- name: string
46
- }
47
-
48
- export interface IUiJsonOutputPlot {
49
- xAxisTitle: string
50
- xValue: string
51
- yAxisTitle: string
52
- yValue: string
53
- }
54
-
55
- export interface IUiJsonParameter {
56
- name: string
57
- value: string
58
- }
59
-
60
- export function uiJsonIssues(uiJson: IUiJson | undefined): IIssue[] {
61
- // Make sure that we have some UI JSON.
62
-
63
- if (uiJson === undefined) {
64
- return [
65
- {
66
- type: EIssueType.WARNING,
67
- description: 'UI JSON: no UI JSON was provided.'
68
- }
69
- ]
70
- }
71
-
72
- // Check the UI JSON against our schema.
73
-
74
- const validator = new jsonschema.Validator()
75
- const schema: jsonschema.Schema = {
76
- additionalProperties: false,
77
- properties: {
78
- input: {
79
- items: {
80
- oneOf: [
81
- {
82
- additionalProperties: false,
83
- properties: {
84
- defaultValue: {
85
- required: true,
86
- type: 'number'
87
- },
88
- id: {
89
- type: 'string'
90
- },
91
- name: {
92
- required: true,
93
- type: 'string'
94
- },
95
- possibleValues: {
96
- items: {
97
- additionalProperties: false,
98
- properties: {
99
- name: {
100
- required: true,
101
- type: 'string'
102
- },
103
- value: {
104
- required: true,
105
- type: 'number'
106
- }
107
- },
108
- type: 'object'
109
- },
110
- minItems: 1,
111
- required: true,
112
- type: 'array'
113
- },
114
- visible: {
115
- type: 'string'
116
- }
117
- }
118
- },
119
- {
120
- additionalProperties: false,
121
- properties: {
122
- defaultValue: {
123
- required: true,
124
- type: 'number'
125
- },
126
- id: {
127
- type: 'string'
128
- },
129
- maximumValue: {
130
- required: true,
131
- type: 'number'
132
- },
133
- minimumValue: {
134
- required: true,
135
- type: 'number'
136
- },
137
- name: {
138
- required: true,
139
- type: 'string'
140
- },
141
- stepValue: {
142
- type: 'number'
143
- },
144
- visible: {
145
- type: 'string'
146
- }
147
- }
148
- }
149
- ],
150
- type: 'object'
151
- },
152
- minItems: 1,
153
- required: true,
154
- type: 'array'
155
- },
156
- output: {
157
- additionalProperties: false,
158
- minItems: 1,
159
- properties: {
160
- data: {
161
- items: {
162
- additionalProperties: false,
163
- properties: {
164
- id: {
165
- required: true,
166
- type: 'string'
167
- },
168
- name: {
169
- required: true,
170
- type: 'string'
171
- }
172
- },
173
- type: 'object'
174
- },
175
- minItems: 1,
176
- required: true,
177
- type: 'array'
178
- },
179
- plots: {
180
- items: {
181
- additionalProperties: false,
182
- properties: {
183
- xAxisTitle: {
184
- required: true,
185
- type: 'string'
186
- },
187
- xValue: {
188
- required: true,
189
- type: 'string'
190
- },
191
- yAxisTitle: {
192
- required: true,
193
- type: 'string'
194
- },
195
- yValue: {
196
- required: true,
197
- type: 'string'
198
- }
199
- },
200
- type: 'object'
201
- },
202
- maxItems: 9,
203
- minItems: 1,
204
- required: true,
205
- type: 'array'
206
- }
207
- },
208
- required: true,
209
- type: 'object'
210
- },
211
- parameters: {
212
- items: {
213
- additionalProperties: false,
214
- properties: {
215
- name: {
216
- required: true,
217
- type: 'string'
218
- },
219
- value: {
220
- required: true,
221
- type: 'string'
222
- }
223
- },
224
- minItems: 1,
225
- required: true,
226
- type: 'object'
227
- },
228
- required: true,
229
- type: 'array'
230
- }
231
- },
232
- type: 'object'
233
- }
234
-
235
- const validatorRes = validator.validate(uiJson, schema, { nestedErrors: true })
236
-
237
- if (!validatorRes.valid) {
238
- const res: IIssue[] = []
239
-
240
- for (const issue of String(validatorRes).split('\n')) {
241
- if (issue !== '') {
242
- res.push({
243
- type: EIssueType.WARNING,
244
- description: `UI JSON: ${common.formatIssue(issue)}`
245
- })
246
- }
247
- }
248
-
249
- return res
250
- }
251
-
252
- // Make sure that the input information makes sense.
253
-
254
- const res: IIssue[] = []
255
- const inputIdUsed: Record<string, boolean> = {}
256
-
257
- for (const input of uiJson.input) {
258
- if (input.id !== undefined) {
259
- if (input.id === '') {
260
- res.push({
261
- type: EIssueType.WARNING,
262
- description: 'UI JSON: an input id must not be empty.'
263
- })
264
- }
265
-
266
- if (inputIdUsed[input.id]) {
267
- res.push({
268
- type: EIssueType.WARNING,
269
- description: `UI JSON: an input id must be unique (${input.id} is used more than once).`
270
- })
271
- }
272
-
273
- inputIdUsed[input.id] = true
274
- }
275
-
276
- if (input.name === '') {
277
- res.push({
278
- type: EIssueType.WARNING,
279
- description: 'UI JSON: an input name must not be empty.'
280
- })
281
- }
282
-
283
- function isDiscreteInput(input: IUiJsonInput): input is IUiJsonDiscreteInput {
284
- return 'possibleValues' in input
285
- }
286
-
287
- if (isDiscreteInput(input)) {
288
- for (const possibleValue of input.possibleValues) {
289
- if (possibleValue.name === '') {
290
- res.push({
291
- type: EIssueType.WARNING,
292
- description: 'UI JSON: an input possible value name must not be empty.'
293
- })
294
- }
295
- }
296
-
297
- const values = input.possibleValues.map((value) => {
298
- return value.value
299
- })
300
- const valueUsed: Record<number, boolean> = {}
301
-
302
- for (const value of values) {
303
- if (valueUsed[value]) {
304
- res.push({
305
- type: EIssueType.WARNING,
306
- description:
307
- 'UI JSON: an input possible value must have a unique value (' +
308
- String(value) +
309
- ' is used more than once).'
310
- })
311
- }
312
-
313
- valueUsed[value] = true
314
- }
315
-
316
- if (!values.includes(input.defaultValue)) {
317
- res.push({
318
- type: EIssueType.WARNING,
319
- description:
320
- 'UI JSON: an input default value (' +
321
- String(input.defaultValue) +
322
- ') must be one of the possible values (' +
323
- values.join(', ') +
324
- ').'
325
- })
326
- }
327
- }
328
-
329
- function isScalarInput(input: IUiJsonInput): input is IUiJsonScalarInput {
330
- return 'minimumValue' in input && 'maximumValue' in input
331
- }
332
-
333
- if (isScalarInput(input)) {
334
- if (input.minimumValue >= input.maximumValue) {
335
- res.push({
336
- type: EIssueType.WARNING,
337
- description:
338
- 'UI JSON: an input minimum value (' +
339
- String(input.minimumValue) +
340
- ') must be lower than the maximum value (' +
341
- String(input.maximumValue) +
342
- ').'
343
- })
344
- }
345
-
346
- if (input.defaultValue < input.minimumValue || input.defaultValue > input.maximumValue) {
347
- res.push({
348
- type: EIssueType.WARNING,
349
- description:
350
- 'UI JSON: an input default value (' +
351
- String(input.defaultValue) +
352
- ') must be greater or equal than the minimum value (' +
353
- String(input.minimumValue) +
354
- ') and lower or equal than the maximum value (' +
355
- String(input.maximumValue) +
356
- ').'
357
- })
358
- }
359
-
360
- const range = input.maximumValue - input.minimumValue
361
-
362
- if (input.stepValue !== undefined) {
363
- if (input.stepValue <= 0 || input.stepValue > range) {
364
- res.push({
365
- type: EIssueType.WARNING,
366
- description:
367
- 'UI JSON: an input step value (' +
368
- String(input.stepValue) +
369
- ') must be greater than zero and lower or equal than the range value (' +
370
- String(range) +
371
- ').'
372
- })
373
- }
374
-
375
- if (!Number.isInteger(range / input.stepValue)) {
376
- res.push({
377
- type: EIssueType.WARNING,
378
- description:
379
- 'UI JSON: an input step value (' +
380
- String(input.stepValue) +
381
- ') must be a factor of the range value (' +
382
- String(range) +
383
- ').'
384
- })
385
- }
386
- } else {
387
- if (!Number.isInteger(range)) {
388
- res.push({
389
- type: EIssueType.WARNING,
390
- description:
391
- 'UI JSON: a (default) input step value (1) must be a factor of the range value (' + String(range) + ').'
392
- })
393
- }
394
- }
395
- }
396
-
397
- if (input.visible !== undefined) {
398
- if (input.visible === '') {
399
- res.push({
400
- type: EIssueType.WARNING,
401
- description: 'UI JSON: an input visible must not be empty.'
402
- })
403
- }
404
- }
405
- }
406
-
407
- // Make sure that the output information makes sense.
408
-
409
- const outputIdUsed: Record<string, boolean> = {}
410
-
411
- for (const outputData of uiJson.output.data) {
412
- if (outputData.id === '') {
413
- res.push({
414
- type: EIssueType.WARNING,
415
- description: 'UI JSON: an output data id must not be empty.'
416
- })
417
- }
418
-
419
- if (outputIdUsed[outputData.id]) {
420
- res.push({
421
- type: EIssueType.WARNING,
422
- description: `UI JSON: an output data id must be unique (${outputData.id} is used more than once).`
423
- })
424
- }
425
-
426
- outputIdUsed[outputData.id] = true
427
-
428
- if (outputData.name === '') {
429
- res.push({
430
- type: EIssueType.WARNING,
431
- description: 'UI JSON: an output data name must not be empty.'
432
- })
433
- }
434
- }
435
-
436
- for (const outputPlot of uiJson.output.plots) {
437
- if (outputPlot.xAxisTitle === '') {
438
- res.push({
439
- type: EIssueType.WARNING,
440
- description: 'UI JSON: an output plot X axis title must not be empty.'
441
- })
442
- }
443
-
444
- if (outputPlot.xValue === '') {
445
- res.push({
446
- type: EIssueType.WARNING,
447
- description: 'UI JSON: an output plot X value must not be empty.'
448
- })
449
- }
450
-
451
- if (outputPlot.yAxisTitle === '') {
452
- res.push({
453
- type: EIssueType.WARNING,
454
- description: 'UI JSON: an output plot Y axis title must not be empty.'
455
- })
456
- }
457
-
458
- if (outputPlot.yValue === '') {
459
- res.push({
460
- type: EIssueType.WARNING,
461
- description: 'UI JSON: an output plot Y value must not be empty.'
462
- })
463
- }
464
- }
465
-
466
- // Make sure that the parameters information makes sense.
467
-
468
- for (const parameter of uiJson.parameters) {
469
- if (parameter.name === '') {
470
- res.push({
471
- type: EIssueType.WARNING,
472
- description: 'UI JSON: a parameter name must not be empty.'
473
- })
474
- }
475
-
476
- if (parameter.value === '') {
477
- res.push({
478
- type: EIssueType.WARNING,
479
- description: 'UI JSON: a parameter value must not be empty.'
480
- })
481
- }
482
- }
483
-
484
- return res
485
- }
@@ -1,17 +0,0 @@
1
- import { electronApi } from '../common/electronApi.js'
2
-
3
- import { _cppLocApi, _wasmLocApi } from './locApi.js'
4
-
5
- // Some general methods.
6
-
7
- export function cppVersion(): boolean {
8
- return electronApi !== undefined
9
- }
10
-
11
- export function wasmVersion(): boolean {
12
- return !cppVersion()
13
- }
14
-
15
- export function version(): string {
16
- return cppVersion() ? _cppLocApi.version() : _wasmLocApi.versionString()
17
- }
@@ -1,67 +0,0 @@
1
- #include "common.h"
2
-
3
- libOpenCOR::FileManager fileManager = libOpenCOR::FileManager::instance();
4
- std::map<libOpenCOR::FilePtr, FileData> fileData;
5
-
6
- libOpenCOR::FilePtr valueToFile(const Napi::Value &pValue)
7
- {
8
- return fileManager.file(pValue.ToString().Utf8Value());
9
- }
10
-
11
- libOpenCOR::SedDocumentPtr valueToSedDocument(const Napi::Value &pValue)
12
- {
13
- return fileData[valueToFile(pValue)].sedDocument;
14
- }
15
-
16
- libOpenCOR::SedInstancePtr valueToSedInstance(const Napi::Value &pValue)
17
- {
18
- return fileData[valueToFile(pValue)].sedInstance;
19
- }
20
-
21
- int32_t valueToInt32(const Napi::Value &pValue)
22
- {
23
- return pValue.As<Napi::Number>().Int32Value();
24
- }
25
-
26
- double valueToDouble(const Napi::Value &pValue)
27
- {
28
- return pValue.As<Napi::Number>().DoubleValue();
29
- }
30
-
31
- std::string valueToString(const Napi::Value &pValue)
32
- {
33
- return pValue.As<Napi::String>().Utf8Value();
34
- }
35
-
36
- void untrackFileData(libOpenCOR::FilePtr pFile)
37
- {
38
- fileData.erase(pFile);
39
- }
40
-
41
- napi_value issues(const Napi::CallbackInfo &pInfo, libOpenCOR::IssuePtrs pIssues)
42
- {
43
- auto env = pInfo.Env();
44
- auto res = Napi::Array::New(env);
45
-
46
- for (const auto &issue : pIssues) {
47
- auto object = Napi::Object::New(env);
48
-
49
- object.Set("type", Napi::Number::New(env, static_cast<int>(issue->type())));
50
- object.Set("description", Napi::String::New(env, issue->description()));
51
-
52
- res.Set(res.Length(), object);
53
- }
54
-
55
- return res;
56
- }
57
-
58
- napi_value doublesToNapiArray(const Napi::Env &pEnv, const std::vector<double> &pDoubles)
59
- {
60
- auto array = Napi::Array::New(pEnv, pDoubles.size());
61
-
62
- for (size_t i = 0; i < pDoubles.size(); ++i) {
63
- array[i] = Napi::Number::New(pEnv, pDoubles[i]);
64
- }
65
-
66
- return array;
67
- }
@@ -1,27 +0,0 @@
1
- #pragma once
2
-
3
- #include <libopencor>
4
-
5
- #include <napi.h>
6
-
7
- struct FileData
8
- {
9
- libOpenCOR::SedDocumentPtr sedDocument;
10
- libOpenCOR::SedInstancePtr sedInstance;
11
- };
12
-
13
- extern libOpenCOR::FileManager fileManager;
14
- extern std::map<libOpenCOR::FilePtr, FileData> fileData;
15
-
16
- libOpenCOR::FilePtr valueToFile(const Napi::Value &pValue);
17
- libOpenCOR::SedDocumentPtr valueToSedDocument(const Napi::Value &pValue);
18
- libOpenCOR::SedInstancePtr valueToSedInstance(const Napi::Value &pValue);
19
- int32_t valueToInt32(const Napi::Value &pValue);
20
- double valueToDouble(const Napi::Value &pValue);
21
- std::string valueToString(const Napi::Value &pValue);
22
-
23
- void untrackFileData(libOpenCOR::FilePtr pFile);
24
-
25
- napi_value issues(const Napi::CallbackInfo &pInfo, libOpenCOR::IssuePtrs pIssues);
26
-
27
- napi_value doublesToNapiArray(const Napi::Env &pEnv, const std::vector<double> &pDoubles);
@@ -1,72 +0,0 @@
1
- #include "common.h"
2
- #include "file.h"
3
-
4
- #include <libopencor>
5
-
6
- // FileManager API.
7
-
8
- void fileManagerUnmanage(const Napi::CallbackInfo &pInfo)
9
- {
10
- auto files = fileManager.files();
11
- auto path = pInfo[0].ToString().Utf8Value();
12
-
13
- for (auto file : files) {
14
- if (file->path() == path) {
15
- untrackFileData(file);
16
-
17
- fileManager.unmanage(file);
18
-
19
- break;
20
- }
21
- }
22
- }
23
-
24
- // File API.
25
-
26
- napi_value fileContents(const Napi::CallbackInfo &pInfo)
27
- {
28
- auto file = valueToFile(pInfo[0]);
29
- auto res = file->contents();
30
-
31
- return Napi::Buffer<unsigned char>::Copy(pInfo.Env(), res.data(), res.size());
32
- }
33
-
34
- void fileCreate(const Napi::CallbackInfo &pInfo)
35
- {
36
- auto contents = (pInfo[1].Type() == napi_object) ? pInfo[1].As<Napi::Buffer<unsigned char>>() : Napi::Buffer<unsigned char>();
37
- auto file = libOpenCOR::File::create(pInfo[0].ToString().Utf8Value(), contents.IsEmpty());
38
-
39
- if (!contents.IsEmpty()) {
40
- file->setContents(std::vector<unsigned char>(contents.Data(), contents.Data() + contents.Length()));
41
- }
42
-
43
- // Keep track of the file so that it doesn't get garbage collected.
44
-
45
- fileData[file] = {};
46
- }
47
-
48
- napi_value fileIssues(const Napi::CallbackInfo &pInfo)
49
- {
50
- return issues(pInfo, valueToFile(pInfo[0])->issues());
51
- }
52
-
53
- napi_value fileType(const Napi::CallbackInfo &pInfo)
54
- {
55
- auto file = valueToFile(pInfo[0]);
56
-
57
- return Napi::Number::New(pInfo.Env(), static_cast<int>(file->type()));
58
- }
59
-
60
- napi_value fileUiJson(const Napi::CallbackInfo &pInfo)
61
- {
62
- auto file = valueToFile(pInfo[0]);
63
- auto uiJson = file->childFile("simulation.json");
64
-
65
- if (uiJson == nullptr) {
66
- return pInfo.Env().Undefined();
67
- }
68
-
69
- auto res = uiJson->contents();
70
-
71
- return Napi::Buffer<unsigned char>::Copy(pInfo.Env(), res.data(), res.size());
72
- }
@@ -1,15 +0,0 @@
1
- #pragma once
2
-
3
- #include <napi.h>
4
-
5
- // FileManager API.
6
-
7
- void fileManagerUnmanage(const Napi::CallbackInfo &pInfo);
8
-
9
- // File API.
10
-
11
- napi_value fileContents(const Napi::CallbackInfo &pInfo);
12
- void fileCreate(const Napi::CallbackInfo &pInfo);
13
- napi_value fileIssues(const Napi::CallbackInfo &pInfo);
14
- napi_value fileType(const Napi::CallbackInfo &pInfo);
15
- napi_value fileUiJson(const Napi::CallbackInfo &pInfo);