diff --git a/doc/changelog.d/147.maintenance.md b/doc/changelog.d/147.maintenance.md new file mode 100644 index 00000000..f0d190c7 --- /dev/null +++ b/doc/changelog.d/147.maintenance.md @@ -0,0 +1 @@ +Bump trame_vtklocal to 1.6.2 diff --git a/poetry.lock b/poetry.lock index c083c87b..b1799546 100644 --- a/poetry.lock +++ b/poetry.lock @@ -1,4 +1,4 @@ -# This file is automatically @generated by Poetry 2.3.2 and should not be changed by hand. +# This file is automatically @generated by Poetry 2.1.3 and should not be changed by hand. [[package]] name = "accessible-pygments" @@ -1721,7 +1721,7 @@ files = [ [package.dependencies] attrs = ">=22.2.0" -jsonschema-specifications = ">=2023.3.6" +jsonschema-specifications = ">=2023.03.6" referencing = ">=0.28.4" rpds-py = ">=0.25.0" @@ -4500,14 +4500,14 @@ dev = ["nox", "pre-commit", "pytest", "pytest-asyncio", "pytest-cov", "ruff", "t [[package]] name = "trame-vtklocal" -version = "0.16.4" +version = "1.6.2" description = "VTK Local Rendering using WASM" optional = false -python-versions = ">=3.9" +python-versions = ">=3.10" groups = ["main", "setup"] files = [ - {file = "trame_vtklocal-0.16.4-py3-none-any.whl", hash = "sha256:21028d627a025694076e85bcb6cc564db6190652bfcdf04154c6158936e3601b"}, - {file = "trame_vtklocal-0.16.4.tar.gz", hash = "sha256:97c0d11e43913f79b9697fde65fad9ab752b92c2a28fcedd5344eca0b589b4e5"}, + {file = "trame_vtklocal-1.6.2-py3-none-any.whl", hash = "sha256:43c6f004db542010d8b77f0d62386da8bfa8d2c7aa2d892201bd3a2987c3a079"}, + {file = "trame_vtklocal-1.6.2.tar.gz", hash = "sha256:72371cea11a5c9b0bbb18398bdc3926d05277632d1f45c78edea1d4285307e39"}, ] [package.dependencies] @@ -4516,8 +4516,8 @@ trame = "*" trame-common = "*" [package.extras] -dev = ["pre-commit", "pytest", "pytest-asyncio", "ruff", "trame-client[test]"] -vtk = ["vtk (>=9.4)"] +dev = ["coverage", "pre-commit", "pytest", "pytest-asyncio", "pytest-cov (>=3)", "pytest-playwright", "ruff", "trame-client[test]", "trame-vuetify", "vtk (==9.7.20260726.dev0)"] +vtk = ["vtk (>=9.6.1)"] [[package]] name = "trio" @@ -4844,4 +4844,4 @@ type = ["pytest-mypy (>=1.0.1) ; platform_python_implementation != \"PyPy\""] [metadata] lock-version = "2.1" python-versions = "^3.11" -content-hash = "62b8a9dd70649a4e2e0347aed933c708c0a81189394d7347ea0d0c57482e3577" +content-hash = "d5d6bab06e18ca951403bf70d4f00868671f036d7d2a7b07351abd9646f14fbf" diff --git a/pyproject.toml b/pyproject.toml index 81a2ce6b..f69585b3 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -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" @@ -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"]} diff --git a/src/ansys/visor/viewer/utils/autosetup.py b/src/ansys/visor/viewer/utils/autosetup.py index d05f599b..62efcbdf 100644 --- a/src/ansys/visor/viewer/utils/autosetup.py +++ b/src/ansys/visor/viewer/utils/autosetup.py @@ -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/" directory; it downloads + # per-architecture builds on demand into "wasm32/" and "wasm64/" 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}") diff --git a/src/ansys/visor/visor-client/src/wasm/RemoteVtkScene.js b/src/ansys/visor/visor-client/src/wasm/RemoteVtkScene.js index 3a0ed10b..4006a6f2 100644 --- a/src/ansys/visor/visor-client/src/wasm/RemoteVtkScene.js +++ b/src/ansys/visor/visor-client/src/wasm/RemoteVtkScene.js @@ -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', + '__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); diff --git a/tests/unit/utils/test_autosetup.py b/tests/unit/utils/test_autosetup.py index 576628d4..9554b7dc 100644 --- a/tests/unit/utils/test_autosetup.py +++ b/tests/unit/utils/test_autosetup.py @@ -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)]) @@ -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)