Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions doc/changelog.d/147.maintenance.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Bump trame_vtklocal to 1.6.2
18 changes: 9 additions & 9 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ python = "^3.11"
trame = "3.12.0"
trame-server = "^3.6.0"
wslink = "^2.5.0"
trame-vtklocal = "0.16.4"
trame-vtklocal = "1.6.2"
vtk = "9.6.1"
fastapi = "^0.136.3"
starlette = ">=1.3.1"
Expand Down Expand Up @@ -99,7 +99,7 @@ deepdiff = "^8.6.1"

[tool.poetry.group.setup.dependencies]
trame = "3.12.0"
trame-vtklocal = "0.16.4"
trame-vtklocal = "1.6.2"
vtk = "9.6.1"
# Provides dash-generate-components CLI used by `npm run build:backends`
dash = {version = ">=2.0.0", extras = ["dev"]}
Expand Down
5 changes: 4 additions & 1 deletion src/ansys/visor/viewer/utils/autosetup.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,10 @@ def copy_wasm(src: Path, dst: Path) -> None:
else:
raise RuntimeError(f"Unsupported platform: {sys.platform}")

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

if not src.is_dir():
raise Exception(f"WASM not found at: {src}")
Expand Down
34 changes: 23 additions & 11 deletions src/ansys/visor/visor-client/src/wasm/RemoteVtkScene.js
Original file line number Diff line number Diff line change
Expand Up @@ -128,17 +128,29 @@ export default class RemoteVtkScene {
let wasmUrl = config.wasmUrl;
const trameInterface = await TrameInterface.getInstanceAsync(webSocketUrl, refNameStateKey);

// trame-vtklocal registers wasm files under a versioned path and
// exposes it as `__trame_vtklocal_wasm_url` in Trame state.
// We derive the absolute wasm base URL from the WebSocket origin +
// that state value so we always fetch from the server that actually
// has the files, regardless of which port the Dash app runs on.
const trameWasmUrl = trameInterface.getState('__trame_vtklocal_wasm_url');
if (trameWasmUrl && typeof trameWasmUrl === 'string') {
// webSocketUrl is e.g. "ws://127.0.0.1:44473/ws"
// We need "http://127.0.0.1:44473/__trame_vtklocal/wasm/9.6.1"
const wsOrigin = webSocketUrl.replace(/^ws(s?):\/\//, 'http$1://').replace(/\/ws$/, '');
wasmUrl = `${wsOrigin}/${trameWasmUrl}`;
// trame-vtklocal registers wasm files under a versioned path.
// Older versions exposed a plain string under
// `__trame_vtklocal_wasm_url`. Newer versions expose an object under
// keys like `__trame_vtklocal_wasm32` / `__trame_vtklocal_wasm64` with
// a `url` property. Try multiple possible state keys and use the
// first one we find.
const wsOrigin = webSocketUrl.replace(/^ws(s?):\/\//, 'http$1://').replace(/\/ws$/, '');
const wasmStateCandidates = [
'__trame_vtklocal_wasm_url',
'__trame_vtklocal_wasm',
Comment thread
LKasianAnsys marked this conversation as resolved.
'__trame_vtklocal_wasm32',
'__trame_vtklocal_wasm64',
];
for (const key of wasmStateCandidates) {
const val = trameInterface.getState(key);
if (typeof val === 'string' && val.length > 0) {
wasmUrl = `${wsOrigin}/${val}`;
break;
}
if (val && typeof val === 'object' && typeof val.url === 'string') {
wasmUrl = `${wsOrigin}/${val.url}`;
break;
}
}

const wasmIds = trameInterface.getState(wasmIdsStateKey);
Expand Down
4 changes: 2 additions & 2 deletions tests/unit/utils/test_autosetup.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def test_prepare_wasm_assets_linux_success(monkeypatch, tmp_path):
monkeypatch.setattr(f"{MODULE}.sys.platform", "linux")

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

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

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

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

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