diff --git a/src/core/gzipBundle.js b/src/core/gzipBundle.js index ef331c7..0ee7cd9 100644 --- a/src/core/gzipBundle.js +++ b/src/core/gzipBundle.js @@ -2,15 +2,6 @@ import untar from "js-untar"; import { stripLeadingDotSlash } from "./stringOps.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 f3a81e9..2df94e7 100644 --- a/src/standalone.js +++ b/src/standalone.js @@ -8,12 +8,20 @@ import { createFuture } from "./core/future"; * 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 a Gzip archive. * * @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 loader = new VtkWASMLoader(); - await loader.load(url || "loaded-module", config, wasmBaseName); + await loader.load(url || "loaded-module", config, wasmBaseName, urlIsGzipBundle); return loader.createNamespace(); } diff --git a/src/wasmLoader.js b/src/wasmLoader.js index 37696fc..010b8a5 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"; @@ -42,13 +42,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 a Gzip archive. */ async load( wasmBaseURL, config = DEFAULT_CONFIG, wasmBaseName = "vtk", + urlIsGzipBundle = true, ) { if (this.#loaded) { return; @@ -67,7 +69,7 @@ export class VtkWASMLoader { let wasmFile = null; if (!window.createVTKWASM) { - if (isGzipBundle(wasmBaseURL)) { + if (urlIsGzipBundle) { let gzipArrayBuffer; let javaScriptBlobURL = null; try {