@abi-software/simulationvuer 3.2.6 → 4.0.0
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.
- package/README.md +41 -0
- package/dist/simulationvuer.js +15780 -15559
- package/dist/simulationvuer.umd.cjs +121 -121
- package/dist/style.css +1 -1
- package/package.json +19 -16
- package/vite.config.js +102 -24
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@abi-software/simulationvuer",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "4.0.0",
|
|
4
4
|
"private": false,
|
|
5
5
|
"scripts": {
|
|
6
6
|
"serve": "vite serve --host --force",
|
|
@@ -21,32 +21,35 @@
|
|
|
21
21
|
},
|
|
22
22
|
"dependencies": {
|
|
23
23
|
"@abi-software/plotvuer": "1.0.7",
|
|
24
|
-
"@opencor/opencor": "^0.
|
|
24
|
+
"@opencor/opencor": "^0.20260728.1",
|
|
25
25
|
"element-plus": "2.8.4",
|
|
26
|
-
"jsonschema": "^1.
|
|
27
|
-
"mathjs": "^15.
|
|
26
|
+
"jsonschema": "^1.5.0",
|
|
27
|
+
"mathjs": "^15.2.0",
|
|
28
28
|
"unplugin-vue-components": "^0.26.0",
|
|
29
|
-
"vue": "
|
|
29
|
+
"vue": "3.4.21"
|
|
30
30
|
},
|
|
31
31
|
"devDependencies": {
|
|
32
|
-
"@babel/eslint-parser": "^7.
|
|
33
|
-
"@vitejs/plugin-vue": "^5.
|
|
32
|
+
"@babel/eslint-parser": "^7.29.7",
|
|
33
|
+
"@vitejs/plugin-vue": "^5.2.4",
|
|
34
34
|
"@vuese/markdown-render": "^2.11.3",
|
|
35
35
|
"babel-eslint": "^10.1.0",
|
|
36
36
|
"babel-plugin-component": "^1.1.1",
|
|
37
37
|
"base64-inline-loader": "^2.0.1",
|
|
38
38
|
"chokidar": "^3.6.0",
|
|
39
39
|
"concurrently": "^8.2.2",
|
|
40
|
-
"eslint": "^8.
|
|
41
|
-
"eslint-config-prettier": "^9.
|
|
42
|
-
"eslint-plugin-prettier": "^5.
|
|
43
|
-
"eslint-plugin-vue": "^9.
|
|
44
|
-
"
|
|
45
|
-
"
|
|
46
|
-
"
|
|
47
|
-
"
|
|
40
|
+
"eslint": "^8.57.1",
|
|
41
|
+
"eslint-config-prettier": "^9.1.2",
|
|
42
|
+
"eslint-plugin-prettier": "^5.5.6",
|
|
43
|
+
"eslint-plugin-vue": "^9.33.0",
|
|
44
|
+
"jsonschema": "^1.5.0",
|
|
45
|
+
"mathjs": "^15.2.0",
|
|
46
|
+
"prettier": "^3.9.6",
|
|
47
|
+
"sass": "^1.102.0",
|
|
48
|
+
"unplugin-vue-components": "^0.26.0",
|
|
49
|
+
"vite": "^5.4.21",
|
|
50
|
+
"vitepress": "^1.6.4",
|
|
48
51
|
"vue-docgen-api": "^4.79.2",
|
|
49
|
-
"vue-router": "
|
|
52
|
+
"vue-router": "4.2.5",
|
|
50
53
|
"webpack-node-externals": "^2.5.2"
|
|
51
54
|
},
|
|
52
55
|
"eslintConfig": {
|
package/vite.config.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import vue from "@vitejs/plugin-vue";
|
|
2
2
|
|
|
3
|
+
import fs from "node:fs";
|
|
3
4
|
import path from "node:path";
|
|
4
5
|
import { fileURLToPath } from "node:url";
|
|
5
6
|
import { ElementPlusResolver } from "unplugin-vue-components/resolvers";
|
|
@@ -9,6 +10,17 @@ import { defineConfig } from "vite";
|
|
|
9
10
|
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
10
11
|
const pathSrc = path.resolve(__dirname, "./src");
|
|
11
12
|
|
|
13
|
+
// Retrieve the version of libOpenCOR used by @opencor/opencor.
|
|
14
|
+
|
|
15
|
+
const opencorPackage = JSON.parse(
|
|
16
|
+
fs.readFileSync(
|
|
17
|
+
path.resolve(__dirname, "node_modules/@opencor/opencor/package.json"),
|
|
18
|
+
"utf-8",
|
|
19
|
+
),
|
|
20
|
+
);
|
|
21
|
+
const libopencorVersion = opencorPackage.libopencorVersion;
|
|
22
|
+
const libopencorUrl = `https://opencor.ws/libopencor/downloads/wasm/${libopencorVersion}`;
|
|
23
|
+
|
|
12
24
|
export default defineConfig(({ command, mode }) => {
|
|
13
25
|
const config = {
|
|
14
26
|
plugins: [
|
|
@@ -25,24 +37,73 @@ export default defineConfig(({ command, mode }) => {
|
|
|
25
37
|
],
|
|
26
38
|
dts: "src/components.d.ts",
|
|
27
39
|
}),
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
40
|
+
|
|
41
|
+
// Rewrite the libOpenCOR import URL in @opencor/opencor to a same-origin path. This is needed because
|
|
42
|
+
// libopencor.js constructs pthread workers via new Worker(), which requires the worker script to be
|
|
43
|
+
// same-origin with the page. The actual files are served by the dev server proxy (see below).
|
|
44
|
+
|
|
45
|
+
{
|
|
46
|
+
name: "opencor-local-libopencor",
|
|
47
|
+
enforce: "pre",
|
|
48
|
+
|
|
49
|
+
// Tell Vite that /libopencor/* paths are external.
|
|
50
|
+
// Note: they are served via the dev server proxy, so Vite should not try to resolve them locally.
|
|
51
|
+
|
|
52
|
+
resolveId(id) {
|
|
53
|
+
if (id.startsWith("/libopencor/")) {
|
|
54
|
+
return { id, external: true };
|
|
55
|
+
}
|
|
56
|
+
},
|
|
57
|
+
|
|
58
|
+
// Rewrite the libOpenCOR URL to same-origin path for @opencor/opencor.
|
|
59
|
+
// Note: this is needed so the worker constructed inside libopencor.js is same-origin (i.e. no CORS error).
|
|
60
|
+
// For production, the target server should be configured to serve /libopencor/* files.
|
|
61
|
+
|
|
62
|
+
transform(code, id) {
|
|
63
|
+
if (command !== "serve") {
|
|
64
|
+
return;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
if (
|
|
68
|
+
id.includes("@opencor/opencor") &&
|
|
69
|
+
!id.split("?")[0].endsWith(".css")
|
|
70
|
+
) {
|
|
71
|
+
return {
|
|
72
|
+
code: code.replace(
|
|
73
|
+
/"https:\/\/opencor\.ws\/libopencor\/downloads\/wasm\/[^/]+\/libopencor\.js"/g,
|
|
74
|
+
'"/libopencor/libopencor.js"',
|
|
75
|
+
),
|
|
76
|
+
map: null,
|
|
77
|
+
};
|
|
78
|
+
}
|
|
43
79
|
},
|
|
44
80
|
},
|
|
45
|
-
|
|
81
|
+
],
|
|
82
|
+
base: mode === "app" ? "./" : "/",
|
|
83
|
+
build:
|
|
84
|
+
mode === "app"
|
|
85
|
+
? {}
|
|
86
|
+
: {
|
|
87
|
+
lib: {
|
|
88
|
+
entry: path.resolve(__dirname, "./src/components/index.js"),
|
|
89
|
+
name: "SimulationVuer",
|
|
90
|
+
fileName: "simulationvuer",
|
|
91
|
+
},
|
|
92
|
+
rollupOptions: {
|
|
93
|
+
external: [
|
|
94
|
+
"vue",
|
|
95
|
+
"@abi-software/svg-sprite",
|
|
96
|
+
"@abi-software/plotvuer",
|
|
97
|
+
],
|
|
98
|
+
output: {
|
|
99
|
+
globals: {
|
|
100
|
+
vue: "Vue",
|
|
101
|
+
"@abi-software/svg-sprite": "@abi-software/svg-sprite",
|
|
102
|
+
"@abi-software/plotvuer": "@abi-software/plotvuer",
|
|
103
|
+
},
|
|
104
|
+
},
|
|
105
|
+
},
|
|
106
|
+
},
|
|
46
107
|
resolve: {
|
|
47
108
|
alias: {
|
|
48
109
|
"~/": `${pathSrc}/`,
|
|
@@ -53,6 +114,31 @@ export default defineConfig(({ command, mode }) => {
|
|
|
53
114
|
if (command === "serve") {
|
|
54
115
|
config.server = {
|
|
55
116
|
port: 8081,
|
|
117
|
+
|
|
118
|
+
// Proxy /libopencor/* requests to the libOpenCOR server, so the worker constructed inside libopencor.js loads
|
|
119
|
+
// from a same-origin path (new Worker() requires the worker script to be same-origin with the page).
|
|
120
|
+
|
|
121
|
+
proxy: {
|
|
122
|
+
"/libopencor": {
|
|
123
|
+
target: libopencorUrl,
|
|
124
|
+
changeOrigin: true,
|
|
125
|
+
rewrite: (path) => path.replace(/^\/libopencor/, ""),
|
|
126
|
+
},
|
|
127
|
+
},
|
|
128
|
+
|
|
129
|
+
// Emscripten pthreads require SharedArrayBuffer, which needs cross-origin isolation.
|
|
130
|
+
|
|
131
|
+
headers: {
|
|
132
|
+
"Cross-Origin-Opener-Policy": "same-origin",
|
|
133
|
+
"Cross-Origin-Embedder-Policy": "require-corp",
|
|
134
|
+
},
|
|
135
|
+
};
|
|
136
|
+
|
|
137
|
+
// Exclude @opencor/opencor from Vite's pre-bundling so our transform plugin above can rewrite the import URL in
|
|
138
|
+
// opencor.es.js.
|
|
139
|
+
|
|
140
|
+
config.optimizeDeps = {
|
|
141
|
+
exclude: ["@opencor/opencor"],
|
|
56
142
|
};
|
|
57
143
|
config.define = {
|
|
58
144
|
"process.env.HTTP_PROXY": 8081,
|
|
@@ -60,13 +146,5 @@ export default defineConfig(({ command, mode }) => {
|
|
|
60
146
|
};
|
|
61
147
|
}
|
|
62
148
|
|
|
63
|
-
if (mode === "app") {
|
|
64
|
-
config.base = "./";
|
|
65
|
-
|
|
66
|
-
for (const key of ["build", "define", "resolve", "server"]) {
|
|
67
|
-
delete config[key];
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
|
|
71
149
|
return config;
|
|
72
150
|
});
|