@@ -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 ( / ^ w s ( s ? ) : \/ \/ / , 'http$1://' ) . replace ( / \/ w s $ / , '' ) ;
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 ( / ^ w s ( s ? ) : \/ \/ / , 'http$1://' ) . replace ( / \/ w s $ / , '' ) ;
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 ) ;
0 commit comments