From e94fe99a1eec9bb22be7699d4d05483419880e87 Mon Sep 17 00:00:00 2001 From: Alan Garny Date: Mon, 27 Jul 2026 17:16:29 +0200 Subject: [PATCH 1/2] New version. --- package.json | 2 +- src/renderer/package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index c72e5715..cbcc12cd 100644 --- a/package.json +++ b/package.json @@ -23,7 +23,7 @@ "url": "git+https://github.com/opencor/webapp.git" }, "type": "module", - "version": "0.20260727.1", + "version": "0.20260727.2", "engines": { "bun": ">=1.2.0" }, diff --git a/src/renderer/package.json b/src/renderer/package.json index 2df8f02a..3f1bf3c3 100644 --- a/src/renderer/package.json +++ b/src/renderer/package.json @@ -42,7 +42,7 @@ }, "./style.css": "./dist/opencor.css" }, - "version": "0.20260727.1", + "version": "0.20260727.2", "libopencorVersion": "1.20260723.2", "scripts": { "build": "vite build && bun scripts/generate.version.ts", From cc627f0c6e52005717afd03b7dfddef42e2e2a9e Mon Sep 17 00:00:00 2001 From: Alan Garny Date: Mon, 27 Jul 2026 17:16:21 +0200 Subject: [PATCH 2/2] Set libOpenCOR's WASM base URL when building the npm package. --- src/renderer/src/common/initialisation.ts | 6 +----- src/renderer/vite.lib.config.ts | 5 +++++ 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/renderer/src/common/initialisation.ts b/src/renderer/src/common/initialisation.ts index 28d1801d..91f82b34 100644 --- a/src/renderer/src/common/initialisation.ts +++ b/src/renderer/src/common/initialisation.ts @@ -64,13 +64,9 @@ export const initialiseLocApi = async (): Promise => { // @ts-expect-error (window.locApi is defined) locApi.setCppLocApi(window.locApi); } else { - // We are running OpenCOR's Web app, so we must import libOpenCOR's WebAssembly module. + // We are running OpenCOR's Web app, so we must import libOpenCOR's WebAssembly module and instantiate it. try { - // Use a configurable base URL (set via Vite `define`). The default is a same-origin path proxied to opencor.ws - // during development. Production web deployments can override this at build time to point to wherever the - // libOpenCOR WASM build is hosted (e.g. a CDN or a local path served by the web server). - const libOpenCOR = (await import(/* @vite-ignore */ `${__LIBOPENCOR_WASM_BASE_URL__}/libopencor.js`)) .default as WasmFactory; diff --git a/src/renderer/vite.lib.config.ts b/src/renderer/vite.lib.config.ts index 8fbcab4c..1c5d7cd0 100644 --- a/src/renderer/vite.lib.config.ts +++ b/src/renderer/vite.lib.config.ts @@ -7,6 +7,8 @@ import * as postcss from 'postcss'; import vitePlugin from 'unplugin-vue-components/vite'; import * as vite from 'vite'; +import { libopencorVersion } from './scripts/libopencor.version'; + export default vite.defineConfig({ build: { lib: { @@ -33,6 +35,9 @@ export default vite.defineConfig({ }, target: 'esnext' }, + define: { + __LIBOPENCOR_WASM_BASE_URL__: JSON.stringify(`https://opencor.ws/libopencor/downloads/wasm/${libopencorVersion}`) + }, plugins: [ // Note: this must be in sync with vite.config.ts, except for the process-css-layers plugin which is only needed for // the library build (to prevent styles from leaking into and being overridden by host apps).