From 6e0e010cc008b92db587e55fefc258c841fc6870 Mon Sep 17 00:00:00 2001 From: ansbbrooks Date: Thu, 21 May 2026 07:29:12 -0500 Subject: [PATCH 1/2] fix(javascript): removed wasm url extension check --- src/core/gzipBundle.js | 9 --------- src/standalone.js | 12 ++++++++++-- src/wasmLoader.js | 8 +++++--- 3 files changed, 15 insertions(+), 14 deletions(-) diff --git a/src/core/gzipBundle.js b/src/core/gzipBundle.js index 0c98c20..bb84606 100644 --- a/src/core/gzipBundle.js +++ b/src/core/gzipBundle.js @@ -3,15 +3,6 @@ import { stripLeadingDotSlash } from "./stringOps.js"; import { createFuture } from "./future.js"; import { MODULE_JS_FILE_EXTENSION, WASM_FILE_EXTENSION } from "./constants.js"; -/** - * Check if provided URL points to a gzip bundle - * @param {string} url - * @returns {boolean} - */ -export function isGzipBundle(url) { - return typeof url === "string" && url.endsWith(".gz"); -} - /** * Fetch gzip bundle from provided URL * @param {string} url diff --git a/src/standalone.js b/src/standalone.js index 8c036da..7badf0e 100644 --- a/src/standalone.js +++ b/src/standalone.js @@ -9,15 +9,23 @@ import { createInstantiatorProxy } from "./core/proxy"; * If vtkWebAssemblyInterface.mjs is already loaded as a script, * this will be ignored. * @param {Object} config + * @param {string} [wasmBaseName] - (default is `"vtk"`) base name of the wasm bundle to load. e.g., `"vtk"` or `"addon"` will + * look for vtkWebAssembly.mjs or addonWebAssembly.mjs in the wasmBaseURL. + * @param {boolean} [urlIsGzipBundle] - (default is `true`) specifies whether the resource at `wasmBaseURL` is in Gzip format. * * @returns the vtk namespace for creating VTK objects. */ -export async function createNamespace(url, config = {}, wasmBaseName = "vtk") { +export async function createNamespace( + url, + config = {}, + wasmBaseName = "vtk", + urlIsGzipBundle = true, +) { const vtkProxyCache = new WeakMap(); const idToRef = new Map(); const loader = new VtkWASMLoader(); - await loader.load(url || "loaded-module", config, wasmBaseName); + await loader.load(url || "loaded-module", config, wasmBaseName, urlIsGzipBundle); const wasm = loader.createStandaloneSession(); return createInstantiatorProxy(wasm, vtkProxyCache, idToRef); diff --git a/src/wasmLoader.js b/src/wasmLoader.js index 64152a9..c0bfef8 100644 --- a/src/wasmLoader.js +++ b/src/wasmLoader.js @@ -1,4 +1,4 @@ -import { extractFilesFromGzipBundle, fetchGzipBundle, isGzipBundle } from "./core/gzipBundle"; +import { extractFilesFromGzipBundle, fetchGzipBundle } from "./core/gzipBundle"; import { createEmscriptenConfig, normalizeConfig, validateConfig } from "./core/configManager"; import { DEFAULT_CONFIG, MIME_TYPES } from "./core/constants"; import { createScriptURL, loadWebAssemblyModuleFromExistingScript, loadWebAssemblyModuleFromScript } from "./core/scriptLoader"; @@ -41,13 +41,15 @@ export class VtkWASMLoader { * * @param {string} wasmBaseURL * @param {object} config - for WASM runtime creation. - * @param {string} wasmBaseName - (default is "vtk") base name of the wasm bundle to load. e.g., "vtk" or "addon" will + * @param {string} wasmBaseName - (default is `"vtk"`) base name of the wasm bundle to load. e.g., `"vtk"` or `"addon"` will * look for vtkWebAssembly.mjs or addonWebAssembly.mjs in the wasmBaseURL. + * @param {boolean} [urlIsGzipBundle] - (default is `true`) specifies whether the resource at `wasmBaseURL` is in Gzip format. */ async load( wasmBaseURL, config = DEFAULT_CONFIG, wasmBaseName = "vtk", + urlIsGzipBundle = true, ) { if (this.#loaded) { return; @@ -66,7 +68,7 @@ export class VtkWASMLoader { let wasmFile = null; if (!window.createVTKWASM) { - if (isGzipBundle(wasmBaseURL)) { + if (urlIsGzipBundle) { let gzipArrayBuffer; let javaScriptBlobURL = null; try { From e42e306c30487619af98f374a4c91412887818e7 Mon Sep 17 00:00:00 2001 From: ansbbrooks Date: Thu, 21 May 2026 07:36:53 -0500 Subject: [PATCH 2/2] fix(javascript): better JSDoc comment --- src/standalone.js | 2 +- src/wasmLoader.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/standalone.js b/src/standalone.js index 7badf0e..014ed8e 100644 --- a/src/standalone.js +++ b/src/standalone.js @@ -11,7 +11,7 @@ import { createInstantiatorProxy } from "./core/proxy"; * @param {Object} config * @param {string} [wasmBaseName] - (default is `"vtk"`) base name of the wasm bundle to load. e.g., `"vtk"` or `"addon"` will * look for vtkWebAssembly.mjs or addonWebAssembly.mjs in the wasmBaseURL. - * @param {boolean} [urlIsGzipBundle] - (default is `true`) specifies whether the resource at `wasmBaseURL` is in Gzip format. + * @param {boolean} [urlIsGzipBundle] - (default is `true`) specifies whether the resource at `wasmBaseURL` is a Gzip archive. * * @returns the vtk namespace for creating VTK objects. */ diff --git a/src/wasmLoader.js b/src/wasmLoader.js index c0bfef8..74fdf04 100644 --- a/src/wasmLoader.js +++ b/src/wasmLoader.js @@ -43,7 +43,7 @@ export class VtkWASMLoader { * @param {object} config - for WASM runtime creation. * @param {string} wasmBaseName - (default is `"vtk"`) base name of the wasm bundle to load. e.g., `"vtk"` or `"addon"` will * look for vtkWebAssembly.mjs or addonWebAssembly.mjs in the wasmBaseURL. - * @param {boolean} [urlIsGzipBundle] - (default is `true`) specifies whether the resource at `wasmBaseURL` is in Gzip format. + * @param {boolean} [urlIsGzipBundle] - (default is `true`) specifies whether the resource at `wasmBaseURL` is a Gzip archive. */ async load( wasmBaseURL,