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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ yarn-error.log*
pnpm-debug.log*
lerna-debug.log*

.omo
node_modules
.DS_Store
dist
Expand Down
357 changes: 169 additions & 188 deletions bun.lock

Large diffs are not rendered by default.

16 changes: 14 additions & 2 deletions electron.vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@ import tailwindcssPlugin from '@tailwindcss/vite';
import vuePlugin from '@vitejs/plugin-vue';

import * as electronVite from 'electron-vite';
import * as nodeFs from 'node:fs';
import path from 'node:path';
import vitePlugin from 'unplugin-vue-components/vite';
import { visualizer as visualizerPlugin } from 'rollup-plugin-visualizer';
import vitePlugin from 'unplugin-vue-components/vite';

import { libopencorVersion } from './src/renderer/scripts/libopencor.version';

Expand All @@ -19,6 +20,9 @@ export default electronVite.defineConfig({
format: 'cjs'
}
}
},
ssr: {
external: ['electron']
}
},
preload: {},
Expand Down Expand Up @@ -46,7 +50,15 @@ export default electronVite.defineConfig({
}
},
tailwindcssPlugin(),
vuePlugin(),
vuePlugin({
script: {
fs: {
fileExists: (file: string) => nodeFs.existsSync(file),
readFile: (file: string) => nodeFs.readFileSync(file, 'utf-8'),
realpath: (file: string) => nodeFs.realpathSync(file)
}
}
}),
vitePlugin({
resolvers: [primeVueAutoImportResolver.PrimeVueResolver()]
}),
Expand Down
36 changes: 19 additions & 17 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": "0.20260619.0",
"version": "0.20260714.0",
"engines": {
"bun": ">=1.2.0"
},
Expand All @@ -38,11 +38,12 @@
"format": "bunx --bun biome format --fix --max-diagnostics=none && clang-format -i src/renderer/src/libopencor/src/*",
"format:check": "bunx --bun biome format --max-diagnostics=none && clang-format --dry-run -Werror src/renderer/src/libopencor/src/*",
"lint": "bunx --bun biome lint --fix --error-on-warnings --max-diagnostics=none && bunx stylelint '**/*.css' --fix",
"postinstall": "bun src/renderer/scripts/ensure.electron.js",
"release": "bun src/renderer/scripts/libopencor.js && electron-builder",
"release:local": "bun src/renderer/scripts/libopencor.js && CSC_IDENTITY_AUTO_DISCOVERY=false electron-builder --config.mac.notarize=false --publish=never",
"start": "bun src/renderer/scripts/libopencor.js && electron-vite preview",
"start:web": "bun --cwd src/renderer start",
"typecheck": "bunx --bun vue-tsc --noEmit -p tsconfig.app.json",
"typecheck": "bun --bun src/renderer/scripts/type.check.js --noEmit -p tsconfig.app.json",
"version:new": "bun src/renderer/scripts/version.new.js"
},
"bun": {
Expand All @@ -64,35 +65,36 @@
"xxhash-wasm": "^1.1.0"
},
"devDependencies": {
"@biomejs/biome": "^2.5.0",
"@biomejs/biome": "^2.5.3",
"@electron-toolkit/tsconfig": "^2.0.0",
"@electron-toolkit/utils": "^4.0.0",
"@tailwindcss/postcss": "^4.3.1",
"@tailwindcss/vite": "^4.3.1",
"@types/node": "^25.9.3",
"@tailwindcss/postcss": "^4.3.2",
"@tailwindcss/vite": "^4.3.2",
"@types/node": "^26.1.1",
"@types/plotly.js": "^3.0.10",
"@vitejs/plugin-vue": "^6.0.7",
"@vue/tsconfig": "^0.9.1",
"@wasm-fmt/clang-format": "^22.1.7",
"autoprefixer": "^10.5.0",
"@wasm-fmt/clang-format": "^22.1.8",
"autoprefixer": "^10.5.2",
"cmake-js": "^8.0.0",
"electron": "^41.5.0",
"electron": "^43.1.0",
"electron-builder": "^26.15.3",
"electron-conf": "^1.3.0",
"electron-updater": "^6.8.9",
"electron-vite": "^5.0.0",
"esbuild": "^0.28.1",
"node-addon-api": "^8.8.0",
"postcss": "^8.5.15",
"node-addon-api": "^8.9.0",
"postcss": "^8.5.19",
"rollup-plugin-visualizer": "^7.0.1",
"stylelint": "^17.13.0",
"stylelint": "^17.14.0",
"stylelint-config-standard": "^40.0.0",
"tailwindcss": "^4.3.1",
"tailwindcss": "^4.3.2",
"tailwindcss-primeui": "^0.6.1",
"tar": "^7.5.16",
"typescript": "^6.0.3",
"tar": "^7.5.20",
"typescript": "^7.0.2",
"typescript-6": "npm:typescript@^6.0.0",
"unplugin-vue-components": "^32.1.0",
"vite": "^7.3.2",
"vue-tsc": "^3.3.5"
"vite": "^8.1.4",
"vue-tsc": "^3.3.7"
}
}
301 changes: 141 additions & 160 deletions src/renderer/bun.lock

Large diffs are not rendered by default.

29 changes: 15 additions & 14 deletions src/renderer/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,19 +42,19 @@
},
"./style.css": "./dist/opencor.css"
},
"version": "0.20260619.0",
"version": "0.20260714.0",
"libopencorVersion": "0.20260619.0",
"scripts": {
"build": "vite build && bun scripts/generate.version.js",
"build:lib": "vite build --config vite.lib.config.ts && bunx --bun vue-tsc --project tsconfig.lib.types.json",
"build:lib": "vite build --config vite.lib.config.ts && bun --bun scripts/type.check.js --project tsconfig.lib.types.json",
"clean": "bun scripts/clean.js",
"dependencies:update": "bun scripts/dependencies.update.js",
"dev": "vite dev",
"format": "bunx --bun biome format --fix --max-diagnostics=none",
"format:check": "bunx --bun biome format --max-diagnostics=none",
"lint": "bunx --bun biome lint --fix --error-on-warnings --max-diagnostics=none && bunx stylelint '**/*.css' --fix",
"start": "bun run build && vite preview",
"typecheck": "bunx --bun vue-tsc --noEmit",
"typecheck": "bun --bun scripts/type.check.js --noEmit",
"version:new": "bun scripts/version.new.js"
},
"bun": {
Expand All @@ -76,24 +76,25 @@
"xxhash-wasm": "^1.1.0"
},
"devDependencies": {
"@biomejs/biome": "^2.5.0",
"@tailwindcss/postcss": "^4.3.1",
"@tailwindcss/vite": "^4.3.1",
"@types/node": "^25.9.3",
"@biomejs/biome": "^2.5.3",
"@tailwindcss/postcss": "^4.3.2",
"@tailwindcss/vite": "^4.3.2",
"@types/node": "^26.1.1",
"@types/plotly.js": "^3.0.10",
"@vitejs/plugin-vue": "^6.0.7",
"@vue/tsconfig": "^0.9.1",
"autoprefixer": "^10.5.0",
"autoprefixer": "^10.5.2",
"esbuild": "^0.28.1",
"postcss": "^8.5.15",
"postcss": "^8.5.19",
"rollup-plugin-visualizer": "^7.0.1",
"stylelint": "^17.13.0",
"stylelint": "^17.14.0",
"stylelint-config-standard": "^40.0.0",
"tailwindcss": "^4.3.1",
"tailwindcss": "^4.3.2",
"tailwindcss-primeui": "^0.6.1",
"typescript": "^6.0.3",
"typescript": "^7.0.2",
"typescript-6": "npm:typescript@^6.0.0",
"unplugin-vue-components": "^32.1.0",
"vite": "^7.3.2",
"vue-tsc": "^3.3.5"
"vite": "^8.1.4",
"vue-tsc": "^3.3.7"
}
}
29 changes: 29 additions & 0 deletions src/renderer/scripts/ensure.electron.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#!/usr/bin/env node

// Ensure that the Electron binary is installed.
// Note: indeed, unlike npm, Bun's package manager doesn't run lifecycle scripts from dependencies, so the `electron`
// package's `install.js` (which downloads the platform-specific binary) is never executed automatically. This
// script runs it explicitly after `bun install` to prevent the "Electron uninstall" error from `electron-vite`.

import { spawnSync } from 'node:child_process';
import { dirname, resolve } from 'node:path';
import { fileURLToPath } from 'node:url';

const __dirname = dirname(fileURLToPath(import.meta.url));
const installScript = resolve(__dirname, '../../../node_modules/electron/install.js');
const result = spawnSync(process.execPath, [installScript], {
cwd: resolve(__dirname, '../../..'),
env: { ...process.env },
stdio: 'inherit'
});

if (result.status === null) {
// The child process failed to spawn or was terminated by a signal. status will be null, so surfacing the error (if
// present) to avoid silently exiting 0 and misleading the user into thinking Electron was installed.

console.error(result.error ?? new Error('The Electron install script failed to run.'));

process.exit(1);
}

process.exit(result.status);
11 changes: 9 additions & 2 deletions src/renderer/scripts/libopencor.version.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,17 @@ type RendererPackageJson = {
libopencorVersion: string;
};

const rendererPackageJsonPath = [
const resolvedPaths = [
path.resolve(process.cwd(), 'src/renderer/package.json'),
path.join(import.meta.dirname, '..', 'package.json')
].find((candidatePath) => fs.existsSync(candidatePath));
];
const rendererPackageJsonPath = resolvedPaths.find((candidatePath) => {
return fs.existsSync(candidatePath);
});

if (rendererPackageJsonPath === undefined) {
throw new Error(`Could not find package.json in any of the following paths: ${resolvedPaths.join(', ')}.`);
}

const rendererPackageJson = JSON.parse(fs.readFileSync(rendererPackageJsonPath, 'utf8')) as RendererPackageJson;

Expand Down
27 changes: 27 additions & 0 deletions src/renderer/scripts/type.check.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#!/usr/bin/env node

// Type-checking wrapper for projects that use TypeScript 7 while `vue-tsc` still expects TypeScript 6 internals.
// Note: this requires the `typescript-6` package alias to be installed in the project (so that we can have both
// TypeScript 6 and TypeScript 7 installed at the same time).

import Module from 'node:module';
import path from 'node:path';

const currentWorkingDir = process.cwd();
const currentFolder = path.basename(currentWorkingDir);
const parentFolder = path.basename(path.resolve(currentWorkingDir, '..'));
const projectRoot =
currentFolder === 'scripts' && parentFolder === 'renderer'
? path.resolve(currentWorkingDir, '..')
: currentWorkingDir;
const origResolveFilename = Module._resolveFilename;

Module._resolveFilename = function (request, parent, ...args) {
if (request === 'typescript/lib/tsc') {
return path.join(projectRoot, 'node_modules', 'typescript-6', 'lib', 'tsc.js');
}

return origResolveFilename.call(this, request, parent, ...args);
};

await import(path.join(projectRoot, 'node_modules', 'vue-tsc', 'bin', 'vue-tsc.js'));
3 changes: 2 additions & 1 deletion src/renderer/src/common/electronApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,4 +63,5 @@ interface IWindow {
electronApi: IElectronApi;
}

export const electronApi: IElectronApi | undefined = (window as unknown as IWindow).electronApi;
export const electronApi: IElectronApi | undefined =
typeof window !== 'undefined' ? (window as unknown as IWindow).electronApi : undefined;
13 changes: 11 additions & 2 deletions src/renderer/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@ import tailwindcssPlugin from '@tailwindcss/vite';
import vuePlugin from '@vitejs/plugin-vue';

import { fileURLToPath } from 'node:url';
import vitePlugin from 'unplugin-vue-components/vite';
import * as nodeFs from 'node:fs';
import { visualizer as visualizerPlugin } from 'rollup-plugin-visualizer';
import vitePlugin from 'unplugin-vue-components/vite';
import * as vite from 'vite';

import { libopencorVersion } from './scripts/libopencor.version';
Expand Down Expand Up @@ -43,7 +44,15 @@ export default vite.defineConfig({
}
},
tailwindcssPlugin(),
vuePlugin(),
vuePlugin({
script: {
fs: {
fileExists: (file: string) => nodeFs.existsSync(file),
readFile: (file: string) => nodeFs.readFileSync(file, 'utf-8'),
realpath: (file: string) => nodeFs.realpathSync(file)
}
}
}),
vitePlugin({
resolvers: [primeVueAutoImportResolver.PrimeVueResolver()]
}),
Expand Down
11 changes: 10 additions & 1 deletion src/renderer/vite.lib.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import * as primeVueAutoImportResolver from '@primevue/auto-import-resolver';
import tailwindcssPlugin from '@tailwindcss/vite';
import vuePlugin from '@vitejs/plugin-vue';

import * as nodeFs from 'node:fs';
import * as postcss from 'postcss';
import vitePlugin from 'unplugin-vue-components/vite';
import * as vite from 'vite';
Expand Down Expand Up @@ -83,7 +84,15 @@ export default vite.defineConfig({
}
},
tailwindcssPlugin(),
vuePlugin(),
vuePlugin({
script: {
fs: {
fileExists: (file: string) => nodeFs.existsSync(file),
readFile: (file: string) => nodeFs.readFileSync(file, 'utf-8'),
realpath: (file: string) => nodeFs.realpathSync(file)
}
}
}),
vitePlugin({
resolvers: [primeVueAutoImportResolver.PrimeVueResolver()]
})
Expand Down
Loading