Skip to content

Commit 61fe9f3

Browse files
chore: Bump trame_vtklocal to 1.6.2 (#147)
Co-authored-by: pyansys-ci-bot <92810346+pyansys-ci-bot@users.noreply.github.com>
1 parent 6ead663 commit 61fe9f3

6 files changed

Lines changed: 41 additions & 25 deletions

File tree

‎doc/changelog.d/147.maintenance.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Bump trame_vtklocal to 1.6.2

‎poetry.lock‎

Lines changed: 9 additions & 9 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎pyproject.toml‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ python = "^3.11"
6464
trame = "3.12.0"
6565
trame-server = "^3.6.0"
6666
wslink = "^2.5.0"
67-
trame-vtklocal = "0.16.4"
67+
trame-vtklocal = "1.6.2"
6868
vtk = "9.6.1"
6969
fastapi = "^0.136.3"
7070
starlette = ">=1.3.1"
@@ -99,7 +99,7 @@ deepdiff = "^8.6.1"
9999

100100
[tool.poetry.group.setup.dependencies]
101101
trame = "3.12.0"
102-
trame-vtklocal = "0.16.4"
102+
trame-vtklocal = "1.6.2"
103103
vtk = "9.6.1"
104104
# Provides dash-generate-components CLI used by `npm run build:backends`
105105
dash = {version = ">=2.0.0", extras = ["dev"]}

‎src/ansys/visor/viewer/utils/autosetup.py‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,10 @@ def copy_wasm(src: Path, dst: Path) -> None:
4747
else:
4848
raise RuntimeError(f"Unsupported platform: {sys.platform}")
4949

50-
src = site_packages / "trame_vtklocal" / "module" / "serve" / "wasm" / version
50+
# trame_vtklocal >= 1.6.2 no longer ships a flat "wasm/<version>" directory; it downloads
51+
# per-architecture builds on demand into "wasm32/<version>" and "wasm64/<version>" instead.
52+
# We bundle the wasm32 (non-threaded) build since it doesn't require crossOriginIsolated.
53+
src = site_packages / "trame_vtklocal" / "module" / "serve" / "wasm32" / version
5154

5255
if not src.is_dir():
5356
raise Exception(f"WASM not found at: {src}")

‎src/ansys/visor/visor-client/src/wasm/RemoteVtkScene.js‎

Lines changed: 23 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -128,17 +128,29 @@ export default class RemoteVtkScene {
128128
let wasmUrl = config.wasmUrl;
129129
const trameInterface = await TrameInterface.getInstanceAsync(webSocketUrl, refNameStateKey);
130130

131-
// trame-vtklocal registers wasm files under a versioned path and
132-
// exposes it as `__trame_vtklocal_wasm_url` in Trame state.
133-
// We derive the absolute wasm base URL from the WebSocket origin +
134-
// that state value so we always fetch from the server that actually
135-
// has the files, regardless of which port the Dash app runs on.
136-
const trameWasmUrl = trameInterface.getState('__trame_vtklocal_wasm_url');
137-
if (trameWasmUrl && typeof trameWasmUrl === 'string') {
138-
// webSocketUrl is e.g. "ws://127.0.0.1:44473/ws"
139-
// We need "http://127.0.0.1:44473/__trame_vtklocal/wasm/9.6.1"
140-
const wsOrigin = webSocketUrl.replace(/^ws(s?):\/\//, 'http$1://').replace(/\/ws$/, '');
141-
wasmUrl = `${wsOrigin}/${trameWasmUrl}`;
131+
// trame-vtklocal registers wasm files under a versioned path.
132+
// Older versions exposed a plain string under
133+
// `__trame_vtklocal_wasm_url`. Newer versions expose an object under
134+
// keys like `__trame_vtklocal_wasm32` / `__trame_vtklocal_wasm64` with
135+
// a `url` property. Try multiple possible state keys and use the
136+
// first one we find.
137+
const wsOrigin = webSocketUrl.replace(/^ws(s?):\/\//, 'http$1://').replace(/\/ws$/, '');
138+
const wasmStateCandidates = [
139+
'__trame_vtklocal_wasm_url',
140+
'__trame_vtklocal_wasm',
141+
'__trame_vtklocal_wasm32',
142+
'__trame_vtklocal_wasm64',
143+
];
144+
for (const key of wasmStateCandidates) {
145+
const val = trameInterface.getState(key);
146+
if (typeof val === 'string' && val.length > 0) {
147+
wasmUrl = `${wsOrigin}/${val}`;
148+
break;
149+
}
150+
if (val && typeof val === 'object' && typeof val.url === 'string') {
151+
wasmUrl = `${wsOrigin}/${val.url}`;
152+
break;
153+
}
142154
}
143155

144156
const wasmIds = trameInterface.getState(wasmIdsStateKey);

‎tests/unit/utils/test_autosetup.py‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ def test_prepare_wasm_assets_linux_success(monkeypatch, tmp_path):
2525
monkeypatch.setattr(f"{MODULE}.sys.platform", "linux")
2626

2727
fake_site = tmp_path / "site-packages"
28-
wasm_src = fake_site / "trame_vtklocal/module/serve/wasm/9.3"
28+
wasm_src = fake_site / "trame_vtklocal/module/serve/wasm32/9.3"
2929
wasm_src.mkdir(parents=True)
3030

3131
monkeypatch.setattr(f"{MODULE}.site.getsitepackages", lambda: [str(fake_site)])
@@ -52,7 +52,7 @@ def test_prepare_wasm_assets_windows_success(monkeypatch, tmp_path):
5252

5353
monkeypatch.setattr(f"{MODULE}.sys.platform", "win32")
5454

55-
wasm_src = tmp_path / ".venv/Lib/site-packages/trame_vtklocal/module/serve/wasm/9.3"
55+
wasm_src = tmp_path / ".venv/Lib/site-packages/trame_vtklocal/module/serve/wasm32/9.3"
5656
wasm_src.mkdir(parents=True)
5757

5858
monkeypatch.setattr(f"{MODULE}.shutil.copytree", lambda s, d: None)

0 commit comments

Comments
 (0)