Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 7 additions & 11 deletions bun.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion electron.vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ export default electronVite.defineConfig({
name: 'strip-unneeded-primeicons-files',
generateBundle(_options, bundle) {
for (const fileName of Object.keys(bundle)) {
if (fileName.includes('assets/primeicons') && /\.(eot|svg|ttf|woff)$/.test(fileName)) {
if (fileName.includes('assets/primeicons') && /\.(eot|svg|ttf|woff2?)$/.test(fileName)) {
delete bundle[fileName];
}
}
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
"url": "git+https://github.com/opencor/webapp.git"
},
"type": "module",
"version": "1.20261005.1",
"version": "1.20261007.0",
"engines": {
"bun": ">=1.2.0"
},
Expand Down Expand Up @@ -57,7 +57,7 @@
},
"dependencies": {
"@napi-rs/keyring": "^2.1.0",
"@opencor/libopencor-types": "^1.20260803.0",
"@opencor/libopencor-types": "^1.20261006.1",
"@primeuix/themes": "2.0.3",
"@primevue/auto-import-resolver": "4.2.5",
"@vueuse/core": "12.8.2",
Expand Down
2 changes: 2 additions & 0 deletions src/preload/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,7 @@ electron.contextBridge.exposeInMainWorld('locApi', {

sedDocumentCreate: (path: string) => loc.sedDocumentCreate(path),
sedDocumentInstantiate: (documentId: number) => loc.sedDocumentInstantiate(documentId),
sedDocumentRelease: (documentId: number) => loc.sedDocumentRelease(documentId),
sedDocumentIssues: (documentId: number) => loc.sedDocumentIssues(documentId),
sedDocumentModelCount: (documentId: number) => loc.sedDocumentModelCount(documentId),
sedDocumentSimulationCount: (documentId: number) => loc.sedDocumentSimulationCount(documentId),
Expand Down Expand Up @@ -277,6 +278,7 @@ electron.contextBridge.exposeInMainWorld('locApi', {
sedInstancePauseRun: (instanceId: number) => loc.sedInstancePauseRun(instanceId),
sedInstanceResumeRun: (instanceId: number) => loc.sedInstanceResumeRun(instanceId),
sedInstanceStopRun: (instanceId: number) => loc.sedInstanceStopRun(instanceId),
sedInstanceRelease: (instanceId: number) => loc.sedInstanceRelease(instanceId),

// SedInstanceTask API.

Expand Down
12 changes: 6 additions & 6 deletions src/renderer/bun.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions src/renderer/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@
},
"./style.css": "./dist/opencor.css"
},
"version": "1.20261005.1",
"libopencorVersion": "1.20260803.0",
"version": "1.20261007.0",
"libopencorVersion": "1.20261006.1",
"scripts": {
"build": "vite build && bun scripts/generate.version.ts",
"build:lib": "vite build --config vite.lib.config.ts && bun --bun scripts/type.check.ts --project tsconfig.lib.types.json",
Expand All @@ -68,7 +68,7 @@
},
"dependencies": {
"@napi-rs/keyring": "^2.1.0",
"@opencor/libopencor-types": "^1.20260803.0",
"@opencor/libopencor-types": "^1.20261006.1",
"@primeuix/themes": "2.0.3",
"@primevue/auto-import-resolver": "4.2.5",
"@vueuse/core": "12.8.2",
Expand Down
21 changes: 20 additions & 1 deletion src/renderer/src/components/ContentsComponent.vue
Original file line number Diff line number Diff line change
Expand Up @@ -271,8 +271,17 @@ const closeFile = async (filePath: string): Promise<void> => {
locApi.fileManager.unmanage(filePath);

const fileTabIndex = fileTabs.value.findIndex((fileTab) => fileTab.file.path() === filePath);
const fileTab = fileTabs.value[fileTabIndex];

fileTabs.value.splice(fileTabIndex, 1);
if (fileTab) {
fileTabs.value.splice(fileTabIndex, 1);

// Release the file once its views have been unmounted (and have therefore released their own resources).

vue.nextTick(() => {
fileTab.file.release();
});
}

if (activeFile.value === filePath && fileTabs.value.length) {
const nextFileTab = fileTabs.value[Math.min(fileTabIndex, fileTabs.value.length - 1)];
Expand Down Expand Up @@ -550,6 +559,16 @@ defineExpose({
simulationData
});

// Release the files that are still open once we (and therefore their views) have been unmounted.

vue.onUnmounted(() => {
for (const fileTab of fileTabs.value) {
locApi.fileManager.unmanage(fileTab.file.path());

fileTab.file.release();
}
});

// Some watchers to let people know about changes to the opened files and the selected file.

vue.watch(filePaths, (newFilePaths: string[]) => {
Expand Down
16 changes: 14 additions & 2 deletions src/renderer/src/components/OpenCOR.vue
Original file line number Diff line number Diff line change
Expand Up @@ -782,6 +782,8 @@ const processFile = async (fileFilePathOrFileContents: string | Uint8Array | Fil

emit('file', { type: 'issue', filePath, issues: [issueMessage] });

file.release();

return null;
}

Expand Down Expand Up @@ -821,6 +823,16 @@ const processFile = async (fileFilePathOrFileContents: string | Uint8Array | Fil
}
};

const openFileInContents = async (file: locApi.File, wait: boolean = false): Promise<void> => {
// Open the given file in our contents component or release it if we can't (e.g., we got unmounted in the meantime).

if (contentsRef.value) {
await contentsRef.value.openFile(file, wait);
} else {
file.release();
}
};

const openFile = (fileFilePathOrFileContents: string | Uint8Array | File): void => {
processFile(fileFilePathOrFileContents).then(async (fileInfo) => {
if (!fileInfo) {
Expand All @@ -834,7 +846,7 @@ const openFile = (fileFilePathOrFileContents: string | Uint8Array | File): void
}

if (fileInfo.file) {
await contentsRef.value?.openFile(fileInfo.file);
await openFileInContents(fileInfo.file);
}
});
};
Expand Down Expand Up @@ -862,7 +874,7 @@ const openFiles = (filesFilePathsOrFileContents: (string | Uint8Array | File)[])
}

if (currentFileInfo.file) {
await contentsRef.value?.openFile(currentFileInfo.file, true);
await openFileInContents(currentFileInfo.file, true);
}
}, Promise.resolve());
};
Expand Down
Loading
Loading