|
4 | 4 | import os |
5 | 5 | import shutil |
6 | 6 | import tarfile |
| 7 | +from packaging.version import parse |
7 | 8 |
|
8 | 9 |
|
9 | 10 | def run_async(coroutine): |
@@ -86,18 +87,31 @@ def register_wasm(serve_path, **kwargs): |
86 | 87 | # get wasm version and url |
87 | 88 | wasm_url = kwargs.get("wasm_url", wasm_url) |
88 | 89 |
|
89 | | - if ( |
90 | | - not dest_directory.joinpath(f"{wasm_base_name}WebAssembly.mjs").exists() |
91 | | - or not dest_directory.joinpath(f"{wasm_base_name}WebAssembly.wasm").exists() |
92 | | - or not dest_directory.joinpath( |
93 | | - f"{wasm_base_name}WebAssemblyAsync.mjs" |
94 | | - ).exists() |
95 | | - or not dest_directory.joinpath( |
96 | | - f"{wasm_base_name}WebAssemblyAsync.wasm" |
97 | | - ).exists() |
98 | | - ): |
99 | | - # if the wasm directory does not exist, we need to download it |
100 | | - run_async(setup_wasm_directory(dest_directory, wasm_url)) |
| 90 | + # if the required wasm files do not exist, we need to download them |
| 91 | + # Versions before 9.5.20250531 use different WASM file naming conventions. |
| 92 | + # this cutoff distinguishes between old and new formats. |
| 93 | + if parse(version) < parse("9.5.20250531"): |
| 94 | + # For older versions, the wasm files are named differently. |
| 95 | + if ( |
| 96 | + not dest_directory.joinpath("vtkWasmSceneManager.mjs").exists() |
| 97 | + or not dest_directory.joinpath("vtkWasmSceneManager.wasm").exists() |
| 98 | + ): |
| 99 | + run_async(setup_wasm_directory(dest_directory, wasm_url)) |
| 100 | + else: |
| 101 | + if ( |
| 102 | + not dest_directory.joinpath(f"{wasm_base_name}WebAssembly.mjs").exists() |
| 103 | + or not dest_directory.joinpath( |
| 104 | + f"{wasm_base_name}WebAssembly.wasm" |
| 105 | + ).exists() |
| 106 | + or not dest_directory.joinpath( |
| 107 | + f"{wasm_base_name}WebAssemblyAsync.mjs" |
| 108 | + ).exists() |
| 109 | + or not dest_directory.joinpath( |
| 110 | + f"{wasm_base_name}WebAssemblyAsync.wasm" |
| 111 | + ).exists() |
| 112 | + ): |
| 113 | + run_async(setup_wasm_directory(dest_directory, wasm_url)) |
| 114 | + |
101 | 115 | return dict( |
102 | 116 | state={ |
103 | 117 | "__trame_vtklocal_wasm_url": BASE_URL, |
|
0 commit comments