From 7ad47d75cf581f34dbdd352bfc35d627dd7ecde3 Mon Sep 17 00:00:00 2001 From: "Frank T. Bergmann" Date: Fri, 19 Jan 2024 15:57:12 +0100 Subject: [PATCH] - fix typescript issues --- .gitignore | 2 +- examples/vue-copasi-ts/.gitignore | 1 + .../vue-copasi-ts/src/copasi-plugin-type.ts | 8 ++ examples/vue-copasi-ts/src/copasi-plugin.js | 8 +- examples/vue-copasi-ts/src/views/HomeView.vue | 16 +++- examples/vue-copasi-ts/tsconfig.node.json | 2 +- js/copasi.d.ts | 94 +++++++++++++++++++ 7 files changed, 122 insertions(+), 9 deletions(-) create mode 100644 examples/vue-copasi-ts/src/copasi-plugin-type.ts create mode 100644 js/copasi.d.ts diff --git a/.gitignore b/.gitignore index 2a19cd2..0831134 100644 --- a/.gitignore +++ b/.gitignore @@ -62,4 +62,4 @@ /dist-web/ /em-build/ -.DS_Store \ No newline at end of file +.DS_Store diff --git a/examples/vue-copasi-ts/.gitignore b/examples/vue-copasi-ts/.gitignore index a19d957..3587447 100644 --- a/examples/vue-copasi-ts/.gitignore +++ b/examples/vue-copasi-ts/.gitignore @@ -32,5 +32,6 @@ coverage src/copasijs.js src/copasi.js +src/copasi.d.ts src/copasijs.wasm src/copasijs.data diff --git a/examples/vue-copasi-ts/src/copasi-plugin-type.ts b/examples/vue-copasi-ts/src/copasi-plugin-type.ts new file mode 100644 index 0000000..f55986f --- /dev/null +++ b/examples/vue-copasi-ts/src/copasi-plugin-type.ts @@ -0,0 +1,8 @@ +import type COPASI from "./copasi"; + +export interface CopasiPlugin { + state: string; + module: any; + instance: COPASI|undefined; + version: string; +} \ No newline at end of file diff --git a/examples/vue-copasi-ts/src/copasi-plugin.js b/examples/vue-copasi-ts/src/copasi-plugin.js index c70b6cc..1bba722 100644 --- a/examples/vue-copasi-ts/src/copasi-plugin.js +++ b/examples/vue-copasi-ts/src/copasi-plugin.js @@ -1,7 +1,6 @@ import { COPASI } from './copasi.js' import { createCpsModule } from './copasijs.js' import { reactive } from 'vue' - /** * Install function for installing plugin into Vue 3 application. * @@ -12,15 +11,18 @@ function install(app) { const copasi = reactive({ state: 'loading', module: undefined, - instance: {version: 'loading'}, + instance: undefined, + version: 'loading' }) app.provide('$copasi', copasi) createCpsModule().then((module) => { + const c = new COPASI(module) copasi.state = 'ready' copasi.module = module - copasi.instance = new COPASI(module) + copasi.instance = c + copasi.version = c.version // console.log('initialized COPASI', copasi.instance.version) }) } diff --git a/examples/vue-copasi-ts/src/views/HomeView.vue b/examples/vue-copasi-ts/src/views/HomeView.vue index 983c981..3e59982 100644 --- a/examples/vue-copasi-ts/src/views/HomeView.vue +++ b/examples/vue-copasi-ts/src/views/HomeView.vue @@ -1,15 +1,23 @@