@opencor/opencor 0.20250826.0 → 0.20250827.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (57) hide show
  1. package/README.md +1 -1
  2. package/dist/opencor.es.js +1 -1
  3. package/package.json +5 -6
  4. package/src/App.vue +0 -7
  5. package/src/ContainerApp.vue +0 -21
  6. package/src/assets/app.css +0 -14
  7. package/src/assets/base.css +0 -31
  8. package/src/assets/logo.svg +0 -17
  9. package/src/common/common.ts +0 -86
  10. package/src/common/constants.ts +0 -12
  11. package/src/common/electron.ts +0 -23
  12. package/src/common/electronApi.ts +0 -63
  13. package/src/common/locCommon.ts +0 -170
  14. package/src/common/settings.ts +0 -95
  15. package/src/common/vueCommon.ts +0 -69
  16. package/src/components/BackgroundComponent.vue +0 -26
  17. package/src/components/BlockingMessageComponent.vue +0 -34
  18. package/src/components/ContentsComponent.vue +0 -277
  19. package/src/components/DragNDropComponent.vue +0 -35
  20. package/src/components/MainMenu.vue +0 -225
  21. package/src/components/OpenCOR.vue +0 -624
  22. package/src/components/dialogs/AboutDialog.vue +0 -51
  23. package/src/components/dialogs/BaseDialog.vue +0 -58
  24. package/src/components/dialogs/OpenRemoteDialog.vue +0 -37
  25. package/src/components/dialogs/ResetAllDialog.vue +0 -13
  26. package/src/components/dialogs/SettingsDialog.vue +0 -42
  27. package/src/components/dialogs/UpdateAvailableDialog.vue +0 -16
  28. package/src/components/dialogs/UpdateDownloadProgressDialog.vue +0 -11
  29. package/src/components/dialogs/UpdateErrorDialog.vue +0 -18
  30. package/src/components/dialogs/UpdateNotAvailableDialog.vue +0 -12
  31. package/src/components/propertyEditors/GraphsPropertyEditor.vue +0 -3
  32. package/src/components/propertyEditors/ParametersPropertyEditor.vue +0 -3
  33. package/src/components/propertyEditors/PropertyEditor.vue +0 -60
  34. package/src/components/propertyEditors/SimulationPropertyEditor.vue +0 -45
  35. package/src/components/propertyEditors/SolversPropertyEditor.vue +0 -3
  36. package/src/components/views/IssuesView.vue +0 -50
  37. package/src/components/views/SimulationExperimentUiView.vue +0 -154
  38. package/src/components/views/SimulationExperimentView.vue +0 -218
  39. package/src/components/widgets/GraphPanelWidget.vue +0 -140
  40. package/src/components/widgets/InputWidget.vue +0 -128
  41. package/src/libopencor/locApi.ts +0 -167
  42. package/src/libopencor/locFileApi.ts +0 -263
  43. package/src/libopencor/locLoggerApi.ts +0 -36
  44. package/src/libopencor/locSedApi.ts +0 -486
  45. package/src/libopencor/locUiJsonApi.ts +0 -485
  46. package/src/libopencor/locVersionApi.ts +0 -17
  47. package/src/libopencor/src/common.cpp +0 -67
  48. package/src/libopencor/src/common.h +0 -27
  49. package/src/libopencor/src/file.cpp +0 -72
  50. package/src/libopencor/src/file.h +0 -15
  51. package/src/libopencor/src/main.cpp +0 -78
  52. package/src/libopencor/src/sed.cpp +0 -348
  53. package/src/libopencor/src/sed.h +0 -53
  54. package/src/libopencor/src/version.cpp +0 -8
  55. package/src/libopencor/src/version.h +0 -5
  56. package/src/main.ts +0 -6
  57. package/src/types/types.d.ts +0 -9
@@ -1,218 +0,0 @@
1
- <template>
2
- <div :class="`h-full ${simulationOnly ? 'div-simulation-only' : 'div-simulation'}`">
3
- <Toolbar :id="toolbarId" class="p-1!">
4
- <template #start>
5
- <Button class="p-1!" icon="pi pi-play-circle" severity="secondary" text @click="onRun()" />
6
- <Button class="p-1!" disabled icon="pi pi-stop-circle" severity="secondary" text />
7
- </template>
8
- </Toolbar>
9
- <Splitter class="border-none! h-full m-0" layout="vertical">
10
- <SplitterPanel :size="simulationOnly ? 100 : 89">
11
- <Splitter>
12
- <SplitterPanel class="ml-4 mr-4 mb-4 min-w-fit" :size="25">
13
- <ScrollPanel class="h-full">
14
- <SimulationPropertyEditor :file="file" />
15
- <!--
16
- <SolversPropertyEditor />
17
- <GraphsPropertyEditor />
18
- <ParametersPropertyEditor />
19
- -->
20
- <Fieldset legend="X-axis">
21
- <Select
22
- v-model="xParameter"
23
- filter
24
- filterMode="lenient"
25
- :options="parameters"
26
- size="small"
27
- class="w-full"
28
- @change="updatePlot()"
29
- />
30
- </Fieldset>
31
- <Fieldset legend="Y-axis">
32
- <Select
33
- v-model="yParameter"
34
- filter
35
- filterMode="lenient"
36
- :options="parameters"
37
- size="small"
38
- class="w-full"
39
- @change="updatePlot()"
40
- />
41
- </Fieldset>
42
- </ScrollPanel>
43
- </SplitterPanel>
44
- <SplitterPanel :size="75">
45
- <GraphPanelWidget :plots="plots" />
46
- </SplitterPanel>
47
- </Splitter>
48
- </SplitterPanel>
49
- <SplitterPanel v-if="!simulationOnly" :size="11">
50
- <Editor :id="editorId" class="border-none h-full" :readonly="true" v-model="consoleContents" />
51
- </SplitterPanel>
52
- </Splitter>
53
- </div>
54
- </template>
55
-
56
- <script setup lang="ts">
57
- import * as vueusecore from '@vueuse/core'
58
-
59
- import * as vue from 'vue'
60
-
61
- import * as common from '../../common/common'
62
- import * as locCommon from '../../common/locCommon'
63
- import * as vueCommon from '../../common/vueCommon'
64
- import * as locApi from '../../libopencor/locApi'
65
-
66
- import { type IGraphPanelPlot } from '../widgets/GraphPanelWidget.vue'
67
-
68
- const props = defineProps<{
69
- uiEnabled: boolean
70
- file: locApi.File
71
- isActiveFile: boolean
72
- simulationOnly?: boolean
73
- }>()
74
-
75
- const toolbarId = `simulationExperimentToolbar_${props.file.path()}`
76
- const editorId = `simulationExperimentEditor_${props.file.path()}`
77
- const instance = props.file.instance()
78
- const instanceTask = instance.task(0)
79
-
80
- const parameters = vue.ref<string[]>([])
81
- const xParameter = vue.ref(instanceTask.voiName())
82
- const yParameter = vue.ref(instanceTask.stateName(0))
83
- const plots = vue.ref<IGraphPanelPlot[]>([])
84
- const consoleContents = vue.ref<string>(`<b>${props.file.path()}</b>`)
85
-
86
- function addParameter(param: string): void {
87
- parameters.value.push(param)
88
- }
89
-
90
- addParameter(instanceTask.voiName())
91
-
92
- for (let i = 0; i < instanceTask.stateCount(); i++) {
93
- addParameter(instanceTask.stateName(i))
94
- }
95
-
96
- for (let i = 0; i < instanceTask.rateCount(); i++) {
97
- addParameter(instanceTask.rateName(i))
98
- }
99
-
100
- for (let i = 0; i < instanceTask.constantCount(); i++) {
101
- addParameter(instanceTask.constantName(i))
102
- }
103
-
104
- for (let i = 0; i < instanceTask.computedConstantCount(); i++) {
105
- addParameter(instanceTask.computedConstantName(i))
106
- }
107
-
108
- for (let i = 0; i < instanceTask.algebraicCount(); i++) {
109
- addParameter(instanceTask.algebraicName(i))
110
- }
111
-
112
- function onRun(): void {
113
- // Run the instance, output the simulation time to the console, and update the plot.
114
-
115
- const simulationTime = instance.run()
116
-
117
- consoleContents.value += `<br/>&nbsp;&nbsp;<b>Simulation time:</b> ${common.formatTime(simulationTime)}`
118
-
119
- void vue.nextTick().then(() => {
120
- const consoleElement = document.getElementById(editorId)?.getElementsByClassName('ql-editor')[0]
121
-
122
- if (consoleElement !== undefined) {
123
- consoleElement.scrollTop = consoleElement.scrollHeight
124
- }
125
- })
126
-
127
- updatePlot()
128
- }
129
-
130
- const xInfo = vue.computed(() => locCommon.simulationDataInfo(instanceTask, xParameter.value))
131
- const yInfo = vue.computed(() => locCommon.simulationDataInfo(instanceTask, yParameter.value))
132
-
133
- function updatePlot() {
134
- plots.value = [
135
- {
136
- x: {
137
- data: locCommon.simulationData(instanceTask, xInfo.value)
138
- },
139
- y: {
140
- data: locCommon.simulationData(instanceTask, yInfo.value)
141
- }
142
- }
143
- ]
144
- }
145
-
146
- // "Initialise" our plot.
147
-
148
- vue.onMounted(() => {
149
- updatePlot()
150
- })
151
-
152
- // Track the height of our file tablist toolbar.
153
-
154
- vueCommon.trackElementHeight(toolbarId)
155
-
156
- // Keyboard shortcuts.
157
-
158
- if (!common.isMobile()) {
159
- vueusecore.onKeyStroke((event: KeyboardEvent) => {
160
- if (!props.uiEnabled) {
161
- return
162
- }
163
-
164
- if (props.isActiveFile && !event.ctrlKey && !event.shiftKey && !event.metaKey && event.code === 'F9') {
165
- event.preventDefault()
166
-
167
- onRun()
168
- }
169
- })
170
- }
171
- </script>
172
-
173
- <style scoped>
174
- :deep(.p-button-icon) {
175
- font-size: 1.5rem;
176
- }
177
-
178
- :deep(.p-button-icon-only) {
179
- width: 2rem;
180
- }
181
-
182
- :deep(.p-button-label) {
183
- height: 0;
184
- }
185
-
186
- :deep(.p-editor-content) {
187
- border: none !important;
188
- }
189
-
190
- :deep(.p-editor-toolbar) {
191
- display: none;
192
- }
193
-
194
- .p-toolbar {
195
- border: none;
196
- border-radius: 0;
197
- border-bottom: 1px solid var(--p-content-border-color);
198
- }
199
-
200
- :deep(.ql-editor) {
201
- padding: 0.25rem 0.5rem;
202
- }
203
-
204
- :deep(.ql-editor > *) {
205
- cursor: default;
206
- }
207
-
208
- .div-simulation-only {
209
- height: calc(var(--block-ui-height) - var(--simulation-experiment-toolbar-height));
210
- }
211
-
212
- .div-simulation {
213
- height: calc(
214
- var(--block-ui-height) - var(--main-menu-height) - var(--file-tablist-height) -
215
- var(--simulation-experiment-toolbar-height)
216
- );
217
- }
218
- </style>
@@ -1,140 +0,0 @@
1
- <template>
2
- <div class="flex flex-row h-full">
3
- <div v-if="showMarker" class="marker" />
4
- <div ref="mainDiv" class="grow h-full" />
5
- </div>
6
- </template>
7
-
8
- <script setup lang="ts">
9
- import Plotly from 'https://cdn.jsdelivr.net/npm/plotly.js-gl2d-dist-min@3.1.0/+esm'
10
- import * as vue from 'vue'
11
-
12
- import * as vueCommon from '../../common/vueCommon'
13
- import { MEDIUM_DELAY } from '../../common/constants'
14
-
15
- let oldMainDivClientWidth = -1
16
- let oldMainDivClientHeight = -1
17
-
18
- function resizeIfNeeded() {
19
- if (mainDiv.value !== null) {
20
- if (mainDiv.value.clientWidth !== oldMainDivClientWidth || mainDiv.value.clientHeight !== oldMainDivClientHeight) {
21
- oldMainDivClientWidth = mainDiv.value.clientWidth
22
- oldMainDivClientHeight = mainDiv.value.clientHeight
23
-
24
- Plotly.Plots.resize(mainDiv.value)
25
- }
26
- }
27
-
28
- setTimeout(resizeIfNeeded, MEDIUM_DELAY)
29
- }
30
-
31
- vue.onMounted(() => {
32
- resizeIfNeeded()
33
- })
34
-
35
- interface IGraphPanelPlotData {
36
- data: number[]
37
- }
38
-
39
- export interface IGraphPanelPlot {
40
- x: IGraphPanelPlotData
41
- y: IGraphPanelPlotData
42
- }
43
-
44
- const props = withDefaults(
45
- defineProps<{
46
- plots: IGraphPanelPlot[]
47
- showMarker?: boolean
48
- }>(),
49
- {
50
- showMarker: false
51
- }
52
- )
53
-
54
- const mainDiv = vue.ref<InstanceType<typeof Element> | null>(null)
55
-
56
- function themeData() {
57
- // Note: the various keys can be found at https://plotly.com/javascript/reference/.
58
-
59
- function axisThemeData() {
60
- return {
61
- zerolinecolor: vueCommon.useLightMode() ? '#94a3b8' : '#71717a', // --p-surface-400 / --p-surface-500
62
- gridcolor: vueCommon.useLightMode() ? '#e2e8f0' : '#3f3f46', // --p-surface-200 / --p-surface-700
63
- minor: {
64
- gridcolor: vueCommon.useLightMode() ? '#f1f5f9' : '#27272a' // --p-surface-100 / --p-surface-800
65
- }
66
- }
67
- }
68
-
69
- return {
70
- paper_bgcolor: vueCommon.useLightMode() ? '#ffffff' : '#18181b', // --p-content-background
71
- plot_bgcolor: vueCommon.useLightMode() ? '#ffffff' : '#18181b', // --p-content-background
72
- font: {
73
- color: vueCommon.useLightMode() ? '#334155' : '#ffffff' // --p-text-color
74
- },
75
- colorway: [
76
- '#7289ab', // Blue
77
- '#ea7e53', // Orange
78
- '#eedd78', // Yellow
79
- '#e69d87', // Pink
80
- '#73a373', // Green
81
- '#73b9bc', // Cyan
82
- '#dd6b66' // Red
83
- ],
84
- xaxis: axisThemeData(),
85
- yaxis: axisThemeData()
86
- }
87
- }
88
-
89
- vue.watch(
90
- () => [props.plots, vueCommon.useLightMode()],
91
- () => {
92
- Plotly.react(
93
- mainDiv.value,
94
- props.plots.map((plot) => ({
95
- x: plot.x.data,
96
- y: plot.y.data,
97
- type: 'scattergl'
98
- //---OPENCOR---
99
- // WebGL rendering currently results in "Performance warning: clear() called with no buffers in bitmask" being
100
- // logged to the console. This is a known issue and it should hopefully be fixed in the next version of Plotly.
101
- // See https://github.com/plotly/plotly.js/issues/7387 and https://github.com/plotly/plotly.js/pull/7390.
102
- })),
103
- {
104
- // Note: the various keys can be found at https://plotly.com/javascript/reference/.
105
-
106
- ...themeData(),
107
- margin: {
108
- t: 5,
109
- l: 30,
110
- b: 20,
111
- r: 5
112
- },
113
- showlegend: false,
114
- xaxis: {
115
- tickangle: 0
116
- },
117
- yaxis: {
118
- tickangle: 0
119
- }
120
- },
121
- {
122
- // Note: the various keys can be found at https://plotly.com/javascript/configuration-options/.
123
-
124
- responsive: true,
125
- displayModeBar: false,
126
- doubleClickDelay: 1000,
127
- scrollZoom: true,
128
- showTips: false
129
- }
130
- )
131
- }
132
- )
133
- </script>
134
-
135
- <style scoped>
136
- .marker {
137
- width: 3px;
138
- background-color: var(--p-primary-color);
139
- }
140
- </style>
@@ -1,128 +0,0 @@
1
- <template>
2
- <div v-if="possibleValues !== undefined">
3
- <FloatLabel variant="on">
4
- <Select
5
- v-model="discreteValue"
6
- :options="possibleValues"
7
- optionLabel="name"
8
- @change="selectChange"
9
- class="w-full"
10
- size="small"
11
- />
12
- <label>{{ name }}</label>
13
- </FloatLabel>
14
- </div>
15
- <div v-else>
16
- <FloatLabel variant="on">
17
- <InputText
18
- v-model="scalarValueString"
19
- v-keyfilter="{ pattern: /^[+-]?(\d*(\.\d*)?|\.d*)([eE][+-]?\d*)?$/, validateOnly: true }"
20
- v-on:focusout="inputTextFocusOut"
21
- v-on:keypress="inputTextKeyPress"
22
- class="w-full"
23
- size="small"
24
- />
25
- <label>{{ name }}</label>
26
- </FloatLabel>
27
- <Slider
28
- v-model="scalarValue"
29
- :min="minimumValue"
30
- :max="maximumValue"
31
- :step="stepValue"
32
- @change="sliderChange"
33
- class="w-full mt-3"
34
- size="small"
35
- />
36
- </div>
37
- </template>
38
-
39
- <script setup lang="ts">
40
- import * as vue from 'vue'
41
-
42
- import * as locApi from '../../libopencor/locApi'
43
-
44
- const value = defineModel<number>({ required: true })
45
- const emits = defineEmits(['change'])
46
- const props = defineProps<{
47
- maximumValue?: number
48
- minimumValue?: number
49
- name: string
50
- possibleValues?: locApi.IUiJsonDiscreteInputPossibleValue[]
51
- stepValue?: number
52
- }>()
53
-
54
- let oldValue = value.value
55
- const discreteValue = vue.ref<locApi.IUiJsonDiscreteInputPossibleValue | undefined>(
56
- props.possibleValues ? props.possibleValues[value.value] : undefined
57
- )
58
- const scalarValue = vue.ref<number>(value.value)
59
- const scalarValueString = vue.ref<string>(String(value.value))
60
-
61
- // Some methods to handle a scalar value using an input text and a slider.
62
-
63
- function emitChange(newValue: number) {
64
- void vue.nextTick().then(() => {
65
- value.value = newValue
66
-
67
- if (props.possibleValues === undefined) {
68
- scalarValue.value = newValue
69
- scalarValueString.value = String(newValue) // This will properly format the input text.
70
- }
71
-
72
- oldValue = newValue
73
-
74
- emits('change', props.name, newValue)
75
- })
76
- }
77
-
78
- interface ISelectChangeEvent {
79
- value: {
80
- name: string
81
- value: number
82
- }
83
- }
84
-
85
- function selectChange(event: ISelectChangeEvent) {
86
- if (event.value.value !== oldValue) {
87
- emitChange(event.value.value)
88
- }
89
- }
90
-
91
- function inputTextChange(newValueString: string) {
92
- if (newValueString === '') {
93
- newValueString = String(props.minimumValue)
94
- }
95
-
96
- if (props.minimumValue !== undefined && Number(newValueString) < props.minimumValue) {
97
- newValueString = String(props.minimumValue)
98
- }
99
-
100
- if (props.maximumValue !== undefined && Number(newValueString) > props.maximumValue) {
101
- newValueString = String(props.maximumValue)
102
- }
103
-
104
- const newValue = Number(newValueString)
105
-
106
- if (newValue !== oldValue) {
107
- emitChange(newValue)
108
- }
109
- }
110
-
111
- function inputTextFocusOut(event: Event) {
112
- inputTextChange((event.target as HTMLInputElement).value)
113
- }
114
-
115
- function inputTextKeyPress(event: KeyboardEvent) {
116
- if (event.key === 'Enter') {
117
- inputTextChange((event.target as HTMLInputElement).value)
118
- }
119
- }
120
-
121
- function sliderChange(newValue: number | number[]) {
122
- const valueToEmit = Array.isArray(newValue) ? newValue[0] : newValue
123
-
124
- if (valueToEmit !== oldValue) {
125
- emitChange(valueToEmit)
126
- }
127
- }
128
- </script>
@@ -1,167 +0,0 @@
1
- import { proxyUrl } from '../common/locCommon.js'
2
-
3
- import { EFileType, type IWasmFile, type IWasmFileManager } from './locFileApi.js'
4
- import type { IIssue } from './locLoggerApi.js'
5
- import type { IWasmSedChangeAttribute, IWasmSedDocument } from './locSedApi.js'
6
-
7
- export interface ICppLocApi {
8
- // FileManager API.
9
-
10
- fileManagerUnmanage: (path: string) => void
11
-
12
- // File API.
13
-
14
- fileContents: (path: string) => Uint8Array
15
- fileCreate: (path: string, contents?: Uint8Array) => void
16
- fileIssues: (path: string) => IIssue[]
17
- fileType: (path: string) => EFileType
18
- fileUiJson: (path: string) => Uint8Array | undefined
19
-
20
- // SedDocument API.
21
-
22
- sedDocumentCreate: (path: string) => void
23
- sedDocumentInstantiate: (path: string) => void
24
- sedDocumentIssues: (path: string) => IIssue[]
25
- sedDocumentModelCount: (path: string) => number
26
- sedDocumentModelAddChange: (
27
- path: string,
28
- index: number,
29
- componentName: string,
30
- variableName: string,
31
- newValue: string
32
- ) => void
33
- sedDocumentModelRemoveAllChanges: (path: string, index: number) => void
34
- sedDocumentSimulationCount: (path: string) => number
35
- sedDocumentSimulationType: (path: string, index: number) => number
36
- sedDocumentSimulationUniformTimeCourseInitialTime: (path: string, index: number) => number
37
- sedDocumentSimulationUniformTimeCourseOutputStartTime: (path: string, index: number) => number
38
- sedDocumentSimulationUniformTimeCourseSetOutputStartTime: (path: string, index: number, value: number) => void
39
- sedDocumentSimulationUniformTimeCourseOutputEndTime: (path: string, index: number) => number
40
- sedDocumentSimulationUniformTimeCourseSetOutputEndTime: (path: string, index: number, value: number) => void
41
- sedDocumentSimulationUniformTimeCourseNumberOfSteps: (path: string, index: number) => number
42
- sedDocumentSimulationUniformTimeCourseSetNumberOfSteps: (path: string, index: number, value: number) => void
43
- sedDocumentSimulationOneStepStep: (path: string, index: number) => number
44
-
45
- // SedInstance API.
46
-
47
- sedInstanceIssues: (path: string) => IIssue[]
48
- sedInstanceRun: (path: string) => number
49
-
50
- // SedInstanceTask API.
51
-
52
- sedInstanceTaskVoiName: (path: string, index: number) => string
53
- sedInstanceTaskVoiUnit: (path: string, index: number) => string
54
- sedInstanceTaskVoi: (path: string, index: number) => number[]
55
- sedInstanceTaskStateCount: (path: string, index: number) => number
56
- sedInstanceTaskStateName: (path: string, index: number, stateIndex: number) => string
57
- sedInstanceTaskStateUnit: (path: string, index: number, stateIndex: number) => string
58
- sedInstanceTaskState: (path: string, index: number, stateIndex: number) => number[]
59
- sedInstanceTaskRateCount: (path: string, index: number) => number
60
- sedInstanceTaskRateName: (path: string, index: number, rateIndex: number) => string
61
- sedInstanceTaskRateUnit: (path: string, index: number, rateIndex: number) => string
62
- sedInstanceTaskRate: (path: string, index: number, rateIndex: number) => number[]
63
- sedInstanceTaskConstantCount: (path: string, index: number) => number
64
- sedInstanceTaskConstantName: (path: string, index: number, constantIndex: number) => string
65
- sedInstanceTaskConstantUnit: (path: string, index: number, constantIndex: number) => string
66
- sedInstanceTaskConstant: (path: string, index: number, constantIndex: number) => number[]
67
- sedInstanceTaskComputedConstantCount: (path: string, index: number) => number
68
- sedInstanceTaskComputedConstantName: (path: string, index: number, computedConstantIndex: number) => string
69
- sedInstanceTaskComputedConstantUnit: (path: string, index: number, computedConstantIndex: number) => string
70
- sedInstanceTaskComputedConstant: (path: string, index: number, computedConstantIndex: number) => number[]
71
- sedInstanceTaskAlgebraicCount: (path: string, index: number) => number
72
- sedInstanceTaskAlgebraicName: (path: string, index: number, algebraicIndex: number) => string
73
- sedInstanceTaskAlgebraicUnit: (path: string, index: number, algebraicIndex: number) => string
74
- sedInstanceTaskAlgebraic: (path: string, index: number, algebraicIndex: number) => number[]
75
-
76
- // Version API.
77
-
78
- version: () => string
79
- }
80
-
81
- export interface IWasmLocApi {
82
- // Memory management.
83
-
84
- HEAPU8: Uint8Array
85
- _malloc: (size: number) => number
86
-
87
- // FileManager API.
88
-
89
- FileManager: IWasmFileManager
90
-
91
- // File API.
92
-
93
- File: new (path: string) => IWasmFile
94
-
95
- // SedDocument API
96
-
97
- SedDocument: new (wasmFile: IWasmFile) => IWasmSedDocument
98
- SedChangeAttribute: new (componentName: string, variableName: string, newValue: string) => IWasmSedChangeAttribute
99
-
100
- // Version API.
101
-
102
- versionString: () => string
103
- }
104
-
105
- // Retrieve the version of libOpenCOR that is to be used. Two options:
106
- // - OpenCOR: libOpenCOR can be accessed using window.locApi, which references our C++ API.
107
- // - OpenCOR's Web app: libOpenCOR can be accessed using our WebAssembly module.
108
-
109
- export let _cppLocApi = {} as ICppLocApi
110
- export let _wasmLocApi = {} as IWasmLocApi
111
-
112
- export async function initialiseLocApi() {
113
- // @ts-expect-error (window.locApi may or may not be defined which is why we test it)
114
- if (window.locApi !== undefined) {
115
- // We are running OpenCOR, so libOpenCOR can be accessed using window.locApi.
116
-
117
- // @ts-expect-error (window.locApi is defined)
118
- _cppLocApi = window.locApi
119
- } else {
120
- // We are running OpenCOR's Web app, so we must import libOpenCOR's WebAssembly module.
121
-
122
- try {
123
- const libOpenCOR = (
124
- await import(/* @vite-ignore */ proxyUrl('https://opencor.ws/libopencor/downloads/0.20250805.0/libopencor.js'))
125
- ).default
126
-
127
- _wasmLocApi = (await libOpenCOR()) as IWasmLocApi
128
- } catch (error) {
129
- console.error("Failed to load libOpenCOR's WebAssembly module:", error)
130
- }
131
- }
132
- }
133
-
134
- // Logger API.
135
-
136
- export { EIssueType, wasmIssuesToIssues, type IIssue, type IWasmIssues } from './locLoggerApi.js'
137
-
138
- // File API.
139
-
140
- export { EFileType, File, fileManager, type IWasmFile } from './locFileApi.js'
141
-
142
- // SED-ML API.
143
-
144
- export {
145
- ESedSimulationType,
146
- SedDocument,
147
- SedInstance,
148
- SedInstanceTask,
149
- SedSimulationUniformTimeCourse
150
- } from './locSedApi.js'
151
-
152
- // UI JSON API.
153
-
154
- export {
155
- type IUiJson,
156
- type IUiJsonDiscreteInputPossibleValue,
157
- type IUiJsonInput,
158
- type IUiJsonOutput,
159
- type IUiJsonOutputData,
160
- type IUiJsonOutputPlot,
161
- type IUiJsonParameter,
162
- uiJsonIssues
163
- } from './locUiJsonApi.js'
164
-
165
- // Version API.
166
-
167
- export { cppVersion, wasmVersion, version } from './locVersionApi.js'