@abi-software/simulationvuer 4.0.4 → 4.0.5
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/dist/simulationvuer.js +6347 -6320
- package/dist/simulationvuer.umd.cjs +105 -105
- package/dist/style.css +1 -1
- package/package.json +2 -2
- package/vite.config.js +20 -49
- /package/dist/libopencor/{wasm → downloads/wasm}/1.20260803.0/libopencor.js +0 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@abi-software/simulationvuer",
|
|
3
|
-
"version": "4.0.
|
|
3
|
+
"version": "4.0.5",
|
|
4
4
|
"private": false,
|
|
5
5
|
"scripts": {
|
|
6
6
|
"serve": "vite serve --host --force",
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
},
|
|
22
22
|
"dependencies": {
|
|
23
23
|
"@abi-software/plotvuer": "1.0.7",
|
|
24
|
-
"@opencor/opencor": "^0.
|
|
24
|
+
"@opencor/opencor": "^0.20260804.0",
|
|
25
25
|
"element-plus": "2.8.4",
|
|
26
26
|
"jsonschema": "^1.5.0",
|
|
27
27
|
"mathjs": "^15.2.0",
|
package/vite.config.js
CHANGED
|
@@ -31,53 +31,23 @@ export default defineConfig(({ command, mode }) => {
|
|
|
31
31
|
dts: "src/components.d.ts",
|
|
32
32
|
}),
|
|
33
33
|
|
|
34
|
-
//
|
|
35
|
-
// (not just Vite projects) and this without server configuration.
|
|
34
|
+
// Serve libOpenCOR for OpenCOR's runtime probe.
|
|
36
35
|
//
|
|
37
|
-
// In @opencor/opencor,
|
|
38
|
-
// new URL("
|
|
36
|
+
// In @opencor/opencor, opencor.es.js locates its glue code at runtime:
|
|
37
|
+
// new URL("libopencor/downloads/wasm/<version>/libopencor.js", document.baseURI).href
|
|
38
|
+
// and fetches that same-origin path (HEAD) before falling back to opencor.ws. The WASM is always loaded from a
|
|
39
|
+
// hardcoded opencor.ws base via locateFile. The probe is evaluated at runtime and the glue is imported
|
|
40
|
+
// dynamically (with @vite-ignore), so there is no static URL for Vite to rewrite.
|
|
39
41
|
//
|
|
40
|
-
//
|
|
41
|
-
// (
|
|
42
|
-
//
|
|
43
|
-
//
|
|
44
|
-
//
|
|
45
|
-
//
|
|
46
|
-
// (same directory, libopencor.js is copied alongside it via closeBundle).
|
|
42
|
+
// The probe is satisfied by:
|
|
43
|
+
// - Dev (serve): serving "/libopencor/*" from the installed package via the middleware below, so the probe
|
|
44
|
+
// resolves same-origin (required for pthread Workers).
|
|
45
|
+
// - Build (lib): copying the package's libOpenCOR dir to dist/libopencor via closeBundle, so the
|
|
46
|
+
// document-relative probe hits when the page is served from the dist root (otherwise OpenCOR
|
|
47
|
+
// falls back to opencor.ws).
|
|
47
48
|
|
|
48
49
|
{
|
|
49
50
|
name: "opencor-libopencor",
|
|
50
|
-
transform(code, id) {
|
|
51
|
-
if (id.includes("@opencor/opencor") && id.endsWith("opencor.es.js")) {
|
|
52
|
-
const importRegex =
|
|
53
|
-
/(\/\*\s*@vite-ignore\s*\*\/[\s\n]*)(new URL\("(\.\/libopencor\/wasm\/[^/]+\/libopencor\.js)",\s*window\.location\.href\)\.href)/g;
|
|
54
|
-
const res = code.replace(
|
|
55
|
-
importRegex,
|
|
56
|
-
(_match, prefix, _urlExpr, urlPath) => {
|
|
57
|
-
if (command === "serve") {
|
|
58
|
-
// Dev mode: absolute path served by the middleware below.
|
|
59
|
-
|
|
60
|
-
return `${prefix}"/libopencor/libopencor.js"`;
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
// Build mode: resolve relative to the bundle's own URL.
|
|
64
|
-
// Note: we use replace() instead of new URL(..., import.meta.url) to avoid Vite's asset handler, which
|
|
65
|
-
// would inline the file as a data: URL (which breaks Emscripten's pthread Worker creation). At
|
|
66
|
-
// runtime, import.meta.url points to simulationvuer.js and the derived path correctly reaches
|
|
67
|
-
// libopencor in the same directory (copied alongside by closeBundle).
|
|
68
|
-
|
|
69
|
-
return `${prefix}import.meta.url.replace(/[^/]*$/, "") + ${JSON.stringify(urlPath.substring(2))}`;
|
|
70
|
-
},
|
|
71
|
-
);
|
|
72
|
-
|
|
73
|
-
if (res !== code) {
|
|
74
|
-
return {
|
|
75
|
-
code: res,
|
|
76
|
-
map: null,
|
|
77
|
-
};
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
},
|
|
81
51
|
configureServer(server) {
|
|
82
52
|
// Serve libopencor files from @opencor/opencor during development so the dynamic import in opencor.es.js
|
|
83
53
|
// resolves same-origin (required for pthread Workers).
|
|
@@ -178,18 +148,19 @@ export default defineConfig(({ command, mode }) => {
|
|
|
178
148
|
});
|
|
179
149
|
},
|
|
180
150
|
closeBundle() {
|
|
181
|
-
// Copy
|
|
182
|
-
//
|
|
183
|
-
//
|
|
151
|
+
// Copy liboOpenCOR to the dist root (dist/libopencor) so that OpenCOR's document-relative probe
|
|
152
|
+
// (`<baseURI>/libopencor/downloads/wasm/<version>/libopencor.js`) resolves: in app mode, dist is the
|
|
153
|
+
// deployment root, and in lib mode the probed files ship in the package for consumers that serve them at the
|
|
154
|
+
// page root (everyone else falls back to opencor.ws).
|
|
184
155
|
|
|
185
156
|
if (!fs.existsSync(libopencorDir)) {
|
|
186
157
|
return;
|
|
187
158
|
}
|
|
188
159
|
|
|
189
|
-
const
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
160
|
+
const targetDir = path.join(
|
|
161
|
+
path.resolve(__dirname, "dist"),
|
|
162
|
+
"libopencor",
|
|
163
|
+
);
|
|
193
164
|
|
|
194
165
|
fs.cpSync(libopencorDir, targetDir, { recursive: true, force: true });
|
|
195
166
|
},
|
|
File without changes
|