@squoosh-kit/resize 0.1.18 → 0.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -4,15 +4,15 @@
4
4
  "sourcesContent": [
5
5
  "/**\n * Runtime environment detection utilities\n */\n\n/**\n * Detect if running in a Web Worker context\n */\nexport function isWorker(): boolean {\n return (\n typeof self !== 'undefined' &&\n typeof (globalThis as unknown as { DedicatedWorkerGlobalScope?: unknown })\n .DedicatedWorkerGlobalScope !== 'undefined'\n );\n}\n\n/**\n * Detect if running in a browser context\n */\nexport function isBrowser(): boolean {\n return typeof window !== 'undefined' && typeof document !== 'undefined';\n}\n\n/**\n * Detect if running in Bun\n */\nexport function isBun(): boolean {\n return typeof Bun !== 'undefined';\n}\n\n/**\n * Detect if running in Node.js\n */\nexport function isNode(): boolean {\n return (\n typeof process !== 'undefined' &&\n process.versions != null &&\n process.versions.node != null\n );\n}\n\n/**\n * Check if ImageData is available in the current environment\n */\nexport function hasImageData(): boolean {\n return typeof ImageData !== 'undefined';\n}\n",
6
6
  "/**\n * Generic worker communication helper with support for transferables and AbortSignal\n */\n\nexport interface WorkerRequest<T = unknown> {\n type: string;\n id: number;\n payload: T;\n}\n\nexport interface WorkerResponse<T = unknown> {\n id: number;\n ok: boolean;\n data?: T;\n error?: string;\n}\n\nlet requestId = 0;\n\n/**\n * Call a worker with a typed request and wait for response\n *\n * @param worker - The worker instance to call\n * @param type - The message type\n * @param payload - The payload to send\n * @param signal - Optional AbortSignal to cancel the operation\n * @param transfer - Optional list of Transferable objects to transfer\n * @returns Promise that resolves with the worker's response data\n */\nexport async function callWorker<TPayload, TResponse>(\n worker: Worker,\n type: string,\n payload: TPayload,\n signal?: AbortSignal,\n transfer?: Transferable[]\n): Promise<TResponse> {\n return new Promise<TResponse>((resolve, reject) => {\n const id = ++requestId;\n\n // Check if already aborted\n if (signal?.aborted) {\n reject(new DOMException('Aborted', 'AbortError'));\n return;\n }\n\n const handleMessage = (event: MessageEvent) => {\n const response = event.data as WorkerResponse<TResponse>;\n if (response.id !== id) return;\n\n cleanup();\n\n if (response.ok && response.data !== undefined) {\n resolve(response.data);\n } else {\n reject(new Error(response.error || 'Unknown worker error'));\n }\n };\n\n const handleError = (error: ErrorEvent) => {\n cleanup();\n reject(new Error(`Worker error: ${error.message}`));\n };\n\n const handleAbort = () => {\n cleanup();\n reject(new DOMException('Aborted', 'AbortError'));\n };\n\n const cleanup = () => {\n worker.removeEventListener('message', handleMessage);\n worker.removeEventListener('error', handleError);\n signal?.removeEventListener('abort', handleAbort);\n };\n\n // Set up listeners\n worker.addEventListener('message', handleMessage);\n worker.addEventListener('error', handleError);\n signal?.addEventListener('abort', handleAbort);\n\n // Send the request\n const request: WorkerRequest<TPayload> = { type, id, payload };\n\n if (transfer && transfer.length > 0) {\n worker.postMessage(request, transfer);\n } else {\n worker.postMessage(request);\n }\n });\n}\n",
7
- "/**\n * Worker helper utilities for creating and managing Web Workers\n *\n * This module provides centralized logic for creating worker instances\n * in different environments (browser, Node.js, Bun) using import.meta.resolve\n * for server-side and package-relative paths for browsers.\n */\n\nimport { isBun } from './env';\n\nexport type CreateWorkerOptions = {\n assetPath?: string;\n};\n\n/**\n * Create a Web Worker for a specific codec\n *\n * In Node.js/Bun environments, uses import.meta.resolve to locate worker files.\n * In browser environments, uses relative paths within node_modules that Vite can resolve.\n *\n * @param workerFilename - The name of the worker file (e.g., 'resize.worker' or 'webp.worker')\n * @returns Worker instance\n * @throws Error if worker creation fails with detailed error message\n */\nexport function createCodecWorker(\n workerFilename: string,\n options?: CreateWorkerOptions\n): Worker {\n // Ensure filename has correct format\n const normalizedName = workerFilename.endsWith('.js')\n ? workerFilename\n : `${workerFilename}.js`;\n\n // Map worker filenames to their package and export\n const workerMap: Record<string, { package: string; specifier: string }> = {\n 'resize.worker.js': {\n package: '@squoosh-kit/resize',\n specifier: 'resize.worker.js',\n },\n 'webp.worker.js': {\n package: '@squoosh-kit/webp',\n specifier: 'webp.worker.js',\n },\n };\n\n const workerConfig = workerMap[normalizedName];\n if (!workerConfig) {\n throw new Error(\n `Unknown worker: ${normalizedName}. ` +\n `Supported workers: ${Object.keys(workerMap).join(', ')}`\n );\n }\n\n try {\n // In browser contexts, use relative paths within the installed packages\n if (typeof window !== 'undefined') {\n const packageName = workerConfig.package.split('/')[1]; // Extract 'resize' or 'webp'\n const workerFile = normalizedName.replace('.js', '.browser.mjs');\n\n console.log(\n `[worker-helper] In browser environment. Trying to create worker:`\n );\n console.log(`[worker-helper] - Package Name: ${packageName}`);\n console.log(`[worker-helper] - Worker File: ${workerFile}`);\n\n // If a custom asset path is provided, use it directly\n if (options?.assetPath) {\n // Normalize the asset path - ensure it starts with / and ends without /\n let normalizedAssetPath = options.assetPath;\n if (!normalizedAssetPath.startsWith('/')) {\n normalizedAssetPath = '/' + normalizedAssetPath;\n }\n if (normalizedAssetPath.endsWith('/')) {\n normalizedAssetPath = normalizedAssetPath.slice(0, -1);\n }\n\n // Construct absolute URL: {origin}{assetPath}/{package}/{workerFile}\n const workerPath = `${normalizedAssetPath}/${packageName}/${workerFile}`;\n const workerUrl = new URL(workerPath, window.location.origin).href;\n\n console.log(\n `[worker-helper] Using provided assetPath. Full Worker URL: ${workerUrl}`\n );\n try {\n const worker = new Worker(workerUrl, { type: 'module' });\n console.log(\n `[worker-helper] Successfully created worker with assetPath: ${workerUrl}`\n );\n return worker;\n } catch (e) {\n console.error(\n `[worker-helper] Failed to load worker from assetPath URL: ${workerUrl}`,\n e\n );\n throw new Error(\n `Worker failed to load from ${workerUrl}: ${e instanceof Error ? e.message : String(e)}`\n );\n }\n }\n\n // Try multiple path strategies to support both:\n // 1. Monorepo development structure: ../../{package}/dist/{workerFile}\n // 2. npm installed structure: ../../../{package}/dist/{workerFile}\n const pathStrategies = [\n // First try monorepo structure (when runtime is at packages/runtime/src)\n `../../${packageName}/dist/${workerFile}`,\n // Then try npm structure (when runtime is at node_modules/@squoosh-kit/runtime)\n `../../../node_modules/@squoosh-kit/${packageName}/dist/${workerFile}`,\n // Alternative npm structure for cases where packages are flattened\n `../../../${packageName}/dist/${workerFile}`,\n ];\n\n let lastError: Error | null = null;\n\n for (const relPath of pathStrategies) {\n console.log('relPath:', relPath);\n console.log('import.meta.url:', import.meta.url);\n try {\n const workerUrl = new URL(relPath, import.meta.url);\n console.log(\n `[worker-helper] Trying path strategy. Full Worker URL: ${workerUrl.href}`\n );\n const worker = new Worker(workerUrl, {\n type: 'module',\n });\n console.log(\n `[worker-helper] Successfully created worker with URL: ${workerUrl.href}`\n );\n return worker;\n } catch (error) {\n console.warn(\n `[worker-helper] Path strategy failed for ${relPath}:`,\n error\n );\n lastError = error instanceof Error ? error : new Error(String(error));\n // Continue to next strategy\n }\n }\n\n // If all strategies failed, throw the last error\n if (lastError) {\n console.error('[worker-helper] All path strategies failed.', lastError);\n throw lastError;\n }\n throw new Error(\n `Could not resolve worker ${normalizedName} using any available path strategy`\n );\n }\n\n // Fallbacks for monorepo/dev without build artifacts\n const platformExt = isBun() ? '.bun.js' : '.node.mjs';\n const baseName = normalizedName.replace('.js', '');\n\n // 1) Try TypeScript source first (Bun can transpile TS, works in dev)\n const srcRelPath = workerConfig.package.includes('resize')\n ? `../../resize/src/${baseName}.ts`\n : `../../webp/src/${baseName}.ts`;\n\n console.log('srcRelPath:', srcRelPath);\n console.log('import.meta.url:', import.meta.url);\n try {\n return new Worker(new URL(srcRelPath, import.meta.url), {\n type: 'module',\n });\n } catch {\n // 2) Try dist output (if already built)\n const distRelPath = workerConfig.package.includes('resize')\n ? `../../resize/dist/${baseName}.${platformExt.slice(1)}`\n : `../../webp/dist/${baseName}.${platformExt.slice(1)}`;\n\n console.log('distRelPath:', distRelPath);\n console.log('import.meta.url:', import.meta.url);\n try {\n return new Worker(new URL(distRelPath, import.meta.url), {\n type: 'module',\n });\n } catch {\n // 3) Try import.meta.resolve as last resort\n if (typeof import.meta.resolve === 'function') {\n try {\n const resolved = import.meta.resolve(\n `${workerConfig.package}/${workerConfig.specifier}`\n );\n console.log('resolved:', resolved);\n return new Worker(resolved, { type: 'module' });\n } catch {\n // Continue to error below\n }\n }\n }\n }\n\n // If we get here, all fallbacks failed\n throw new Error(\n `Failed to create worker from ${normalizedName}. ` +\n `Tried TypeScript source, dist output, and import.meta.resolve. ` +\n `Ensure the @squoosh-kit/resize and @squoosh-kit/webp packages are installed.`\n );\n } catch (error) {\n const errorMessage = error instanceof Error ? error.message : String(error);\n throw new Error(\n `Failed to create worker from ${normalizedName}: ${errorMessage}. ` +\n `Ensure the @squoosh-kit/resize and @squoosh-kit/webp packages are installed. ` +\n `If you're using Vite, ensure the worker files are not being optimized as dependencies.`\n );\n }\n}\n\n/**\n * Create a worker with initialization timeout and ready signal handling\n *\n * This is a higher-level function that creates a worker and waits for it\n * to signal that it's ready to receive messages.\n *\n * @param workerFilename - The name of the worker file\n * @param timeoutMs - Timeout in milliseconds (default: 10000)\n * @returns Promise that resolves to a ready Worker instance\n * @throws Error if worker creation fails or times out\n */\nexport function createReadyWorker(\n workerFilename: string,\n options?: CreateWorkerOptions,\n timeoutMs: number = 10000\n): Promise<Worker> {\n return new Promise((resolve, reject) => {\n const timeout = setTimeout(() => {\n reject(\n new Error(\n `Worker initialization timeout after ${timeoutMs}ms. Worker file: ${workerFilename}`\n )\n );\n }, timeoutMs);\n\n let worker: Worker;\n try {\n worker = createCodecWorker(workerFilename, options);\n } catch (error) {\n clearTimeout(timeout);\n reject(error);\n return;\n }\n\n const handleMessage = (event: MessageEvent) => {\n if (event.data?.type === 'worker:ready') {\n clearTimeout(timeout);\n worker.removeEventListener('message', handleMessage);\n worker.removeEventListener('error', handleError);\n worker.removeEventListener('messageerror', handleMessageError);\n resolve(worker);\n }\n };\n\n const handleError = (event: ErrorEvent) => {\n clearTimeout(timeout);\n worker.removeEventListener('message', handleMessage);\n worker.removeEventListener('error', handleError);\n worker.removeEventListener('messageerror', handleMessageError);\n reject(\n new Error(\n `Worker failed to start: ${event?.message || 'Unknown error'}. Worker file: ${workerFilename}`\n )\n );\n };\n\n const handleMessageError = () => {\n clearTimeout(timeout);\n worker.removeEventListener('message', handleMessage);\n worker.removeEventListener('error', handleError);\n worker.removeEventListener('messageerror', handleMessageError);\n reject(\n new Error(\n `Worker message error during initialization. Worker file: ${workerFilename}`\n )\n );\n };\n\n worker.addEventListener('message', handleMessage);\n worker.addEventListener('error', handleError);\n worker.addEventListener('messageerror', handleMessageError);\n worker.postMessage({ type: 'worker:ping' });\n });\n}\n",
8
- "/**\n * Load WASM binary from various sources with fallback strategies\n *\n * Supports:\n * - Node.js (fs/promises)\n * - Browsers (fetch)\n * - Workers (fetch)\n */\nexport async function loadWasmBinary(\n relativePath: string,\n baseUrlOverride?: string | URL\n): Promise<ArrayBuffer> {\n // Get the base URL depending on the environment (worker or main thread)\n // If a base URL is provided, use it; otherwise use import.meta.url from this module\n // In a worker, import.meta.url is the worker's own URL.\n // In the main thread, it's the URL of the current module.\n const baseUrl = baseUrlOverride\n ? typeof baseUrlOverride === 'string'\n ? new URL('.', baseUrlOverride)\n : new URL('.', baseUrlOverride.href)\n : new URL('.', import.meta.url);\n const fullUrl = new URL(relativePath, baseUrl);\n\n console.log(`[WasmLoader] Loading WASM from relative path: ${relativePath}`);\n console.log(`[WasmLoader] Base URL (import.meta.url): ${baseUrl.href}`);\n console.log(`[WasmLoader] Constructed full URL: ${fullUrl.href}`);\n\n try {\n const response = await fetch(fullUrl.href);\n\n console.log(\n `[WasmLoader] Fetch response status for ${fullUrl.href}: ${response.status}`\n );\n\n if (!response.ok) {\n const responseText = await response.text();\n console.error(\n `[WasmLoader] Fetch response text (first 500 chars):`,\n responseText.substring(0, 500)\n );\n throw new Error(\n `Failed to fetch WASM module at ${fullUrl.href}: ${response.status} ${response.statusText}`\n );\n }\n\n const contentType = response.headers.get('content-type');\n console.log(`[WasmLoader] Response Content-Type: ${contentType}`);\n if (!contentType || !contentType.includes('application/wasm')) {\n console.warn(\n `[WasmLoader] Warning: WASM module at ${fullUrl.href} served with incorrect MIME type: \"${contentType}\". Should be \"application/wasm\".`\n );\n }\n\n return await response.arrayBuffer();\n } catch (error) {\n console.error(\n `[WasmLoader] CRITICAL: Fetching WASM binary from ${fullUrl.href} failed.`,\n error\n );\n throw error;\n }\n}\n\n/**\n * Load WASM JavaScript module with fallback strategies\n *\n * Strategy 1: Static relative import (works everywhere)\n * Strategy 2: import.meta.resolve (Node.js 22+)\n * Strategy 3: URL-based import (browsers/workers)\n */\nexport async function loadWasmModule(\n modulePath: string\n): Promise<WebAssembly.Module> {\n // Strategy 1: Try direct static import\n try {\n return await import(/* @vite-ignore */ modulePath);\n\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n } catch (e1) {\n // Continue to next strategy\n }\n\n // Strategy 2: Try import.meta.resolve (Node.js 22+)\n try {\n const resolvedPath = await import.meta.resolve(modulePath);\n\n return await import(/* @vite-ignore */ resolvedPath);\n\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n } catch (e2) {\n // Continue to next strategy\n }\n\n // Strategy 3: Try URL-based import\n try {\n const url = new URL(/* @vite-ignore */ modulePath, import.meta.url);\n\n return await import(/* @vite-ignore */ url.href);\n\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n } catch (e3) {\n throw new Error(\n `Failed to load WASM module from \"${modulePath}\". ` +\n `Ensure WASM files are in the expected location and the module can be resolved.`\n );\n }\n}\n",
7
+ "/**\n * Worker helper utilities for creating and managing Web Workers\n *\n * This module provides centralized logic for creating worker instances\n * in different environments (browser, Node.js, Bun) using import.meta.resolve\n * for server-side and package-relative paths for browsers.\n */\n\nimport { isBun } from './env';\n\nexport type CreateWorkerOptions = {\n assetPath?: string;\n};\n\n/**\n * Create a Web Worker for a specific codec\n *\n * In Node.js/Bun environments, uses import.meta.resolve to locate worker files.\n * In browser environments, uses relative paths within node_modules that Vite can resolve.\n *\n * @param workerFilename - The name of the worker file (e.g., 'resize.worker' or 'webp.worker')\n * @returns Worker instance\n * @throws Error if worker creation fails with detailed error message\n */\nexport function createCodecWorker(\n workerFilename: string,\n options?: CreateWorkerOptions\n): Worker {\n // Ensure filename has correct format\n const normalizedName = workerFilename.endsWith('.js')\n ? workerFilename\n : `${workerFilename}.js`;\n\n // Map worker filenames to their package and export\n const workerMap: Record<string, { package: string; specifier: string }> = {\n 'resize.worker.js': {\n package: '@squoosh-kit/resize',\n specifier: 'resize.worker.js',\n },\n 'webp.worker.js': {\n package: '@squoosh-kit/webp',\n specifier: 'webp.worker.js',\n },\n 'avif.worker.js': {\n package: '@squoosh-kit/avif',\n specifier: 'avif.worker.js',\n },\n 'mozjpeg.worker.js': {\n package: '@squoosh-kit/mozjpeg',\n specifier: 'mozjpeg.worker.js',\n },\n 'jxl.worker.js': {\n package: '@squoosh-kit/jxl',\n specifier: 'jxl.worker.js',\n },\n 'oxipng.worker.js': {\n package: '@squoosh-kit/oxipng',\n specifier: 'oxipng.worker.js',\n },\n 'png.worker.js': {\n package: '@squoosh-kit/png',\n specifier: 'png.worker.js',\n },\n 'imagequant.worker.js': {\n package: '@squoosh-kit/imagequant',\n specifier: 'imagequant.worker.js',\n },\n 'qoi.worker.js': {\n package: '@squoosh-kit/qoi',\n specifier: 'qoi.worker.js',\n },\n 'wp2.worker.js': {\n package: '@squoosh-kit/wp2',\n specifier: 'wp2.worker.js',\n },\n 'hqx.worker.js': {\n package: '@squoosh-kit/hqx',\n specifier: 'hqx.worker.js',\n },\n 'rotate.worker.js': {\n package: '@squoosh-kit/rotate',\n specifier: 'rotate.worker.js',\n },\n 'visdif.worker.js': {\n package: '@squoosh-kit/visdif',\n specifier: 'visdif.worker.js',\n },\n };\n\n const workerConfig = workerMap[normalizedName];\n if (!workerConfig) {\n throw new Error(\n `Unknown worker: ${normalizedName}. ` +\n `Supported workers: ${Object.keys(workerMap).join(', ')}`\n );\n }\n\n try {\n // In browser contexts, use relative paths within the installed packages\n if (typeof window !== 'undefined') {\n const packageName = workerConfig.package.split('/')[1]; // Extract 'resize' or 'webp'\n const workerFile = normalizedName.replace('.js', '.browser.mjs');\n\n console.log(\n `[worker-helper] In browser environment. Trying to create worker:`\n );\n console.log(`[worker-helper] - Package Name: ${packageName}`);\n console.log(`[worker-helper] - Worker File: ${workerFile}`);\n\n // If a custom asset path is provided, use it directly\n if (options?.assetPath) {\n // Normalize the asset path - ensure it starts with / and ends without /\n let normalizedAssetPath = options.assetPath;\n if (!normalizedAssetPath.startsWith('/')) {\n normalizedAssetPath = '/' + normalizedAssetPath;\n }\n if (normalizedAssetPath.endsWith('/')) {\n normalizedAssetPath = normalizedAssetPath.slice(0, -1);\n }\n\n // Construct absolute URL: {origin}{assetPath}/{package}/{workerFile}\n const workerPath = `${normalizedAssetPath}/${packageName}/${workerFile}`;\n const workerUrl = new URL(workerPath, window.location.origin).href;\n\n console.log(\n `[worker-helper] Using provided assetPath. Full Worker URL: ${workerUrl}`\n );\n try {\n const worker = new Worker(workerUrl, { type: 'module' });\n console.log(\n `[worker-helper] Successfully created worker with assetPath: ${workerUrl}`\n );\n return worker;\n } catch (e) {\n console.error(\n `[worker-helper] Failed to load worker from assetPath URL: ${workerUrl}`,\n e\n );\n throw new Error(\n `Worker failed to load from ${workerUrl}: ${e instanceof Error ? e.message : String(e)}`,\n { cause: e }\n );\n }\n }\n\n // Try multiple path strategies to support both:\n // 1. Monorepo development structure: ../../{package}/dist/{workerFile}\n // 2. npm installed structure: ../../../{package}/dist/{workerFile}\n const pathStrategies = [\n // First try monorepo structure (when runtime is at packages/runtime/src)\n `../../${packageName}/dist/${workerFile}`,\n // Then try npm structure (when runtime is at node_modules/@squoosh-kit/runtime)\n `../../../node_modules/@squoosh-kit/${packageName}/dist/${workerFile}`,\n // Alternative npm structure for cases where packages are flattened\n `../../../${packageName}/dist/${workerFile}`,\n ];\n\n let lastError: Error | null = null;\n\n for (const relPath of pathStrategies) {\n console.log('relPath:', relPath);\n console.log('import.meta.url:', import.meta.url);\n try {\n const workerUrl = new URL(relPath, import.meta.url);\n console.log(\n `[worker-helper] Trying path strategy. Full Worker URL: ${workerUrl.href}`\n );\n const worker = new Worker(workerUrl, {\n type: 'module',\n });\n console.log(\n `[worker-helper] Successfully created worker with URL: ${workerUrl.href}`\n );\n return worker;\n } catch (error) {\n console.warn(\n `[worker-helper] Path strategy failed for ${relPath}:`,\n error\n );\n lastError = error instanceof Error ? error : new Error(String(error));\n // Continue to next strategy\n }\n }\n\n // If all strategies failed, throw the last error\n if (lastError) {\n console.error('[worker-helper] All path strategies failed.', lastError);\n throw lastError;\n }\n throw new Error(\n `Could not resolve worker ${normalizedName} using any available path strategy`\n );\n }\n\n // Fallbacks for monorepo/dev without build artifacts\n const platformExt = isBun() ? '.bun.js' : '.node.mjs';\n const baseName = normalizedName.replace('.js', '');\n const pkgName = workerConfig.package.split('/')[1]; // e.g. 'avif', 'webp', 'resize'\n\n // 1) Try TypeScript source first (Bun can transpile TS, works in dev)\n const srcRelPath = `../../${pkgName}/src/${baseName}.ts`;\n\n console.log('srcRelPath:', srcRelPath);\n console.log('import.meta.url:', import.meta.url);\n try {\n return new Worker(new URL(srcRelPath, import.meta.url), {\n type: 'module',\n });\n } catch {\n // 2) Try dist output (if already built)\n const distRelPath = `../../${pkgName}/dist/${baseName}.${platformExt.slice(1)}`;\n\n console.log('distRelPath:', distRelPath);\n console.log('import.meta.url:', import.meta.url);\n try {\n return new Worker(new URL(distRelPath, import.meta.url), {\n type: 'module',\n });\n } catch {\n // 3) Try import.meta.resolve as last resort\n if (typeof import.meta.resolve === 'function') {\n try {\n const resolved = import.meta.resolve(\n `${workerConfig.package}/${workerConfig.specifier}`\n );\n console.log('resolved:', resolved);\n return new Worker(resolved, { type: 'module' });\n } catch {\n // Continue to error below\n }\n }\n }\n }\n\n // If we get here, all fallbacks failed\n throw new Error(\n `Failed to create worker from ${normalizedName}. ` +\n `Tried TypeScript source, dist output, and import.meta.resolve. ` +\n `Ensure the @squoosh-kit/resize and @squoosh-kit/webp packages are installed.`\n );\n } catch (error) {\n const errorMessage = error instanceof Error ? error.message : String(error);\n throw new Error(\n `Failed to create worker from ${normalizedName}: ${errorMessage}. ` +\n `Ensure the @squoosh-kit/resize and @squoosh-kit/webp packages are installed. ` +\n `If you're using Vite, ensure the worker files are not being optimized as dependencies.`,\n { cause: error }\n );\n }\n}\n\n/**\n * Create a worker with initialization timeout and ready signal handling\n *\n * This is a higher-level function that creates a worker and waits for it\n * to signal that it's ready to receive messages.\n *\n * @param workerFilename - The name of the worker file\n * @param timeoutMs - Timeout in milliseconds (default: 10000)\n * @returns Promise that resolves to a ready Worker instance\n * @throws Error if worker creation fails or times out\n */\nexport function createReadyWorker(\n workerFilename: string,\n options?: CreateWorkerOptions,\n timeoutMs: number = 10000\n): Promise<Worker> {\n return new Promise((resolve, reject) => {\n const timeout = setTimeout(() => {\n reject(\n new Error(\n `Worker initialization timeout after ${timeoutMs}ms. Worker file: ${workerFilename}`\n )\n );\n }, timeoutMs);\n\n let worker: Worker;\n try {\n worker = createCodecWorker(workerFilename, options);\n } catch (error) {\n clearTimeout(timeout);\n reject(error);\n return;\n }\n\n const handleMessage = (event: MessageEvent) => {\n if (event.data?.type === 'worker:ready') {\n clearTimeout(timeout);\n worker.removeEventListener('message', handleMessage);\n worker.removeEventListener('error', handleError);\n worker.removeEventListener('messageerror', handleMessageError);\n resolve(worker);\n }\n };\n\n const handleError = (event: ErrorEvent) => {\n clearTimeout(timeout);\n worker.removeEventListener('message', handleMessage);\n worker.removeEventListener('error', handleError);\n worker.removeEventListener('messageerror', handleMessageError);\n reject(\n new Error(\n `Worker failed to start: ${event?.message || 'Unknown error'}. Worker file: ${workerFilename}`\n )\n );\n };\n\n const handleMessageError = () => {\n clearTimeout(timeout);\n worker.removeEventListener('message', handleMessage);\n worker.removeEventListener('error', handleError);\n worker.removeEventListener('messageerror', handleMessageError);\n reject(\n new Error(\n `Worker message error during initialization. Worker file: ${workerFilename}`\n )\n );\n };\n\n worker.addEventListener('message', handleMessage);\n worker.addEventListener('error', handleError);\n worker.addEventListener('messageerror', handleMessageError);\n worker.postMessage({ type: 'worker:ping' });\n });\n}\n",
8
+ "/**\n * Load WASM binary from various sources with fallback strategies\n *\n * Supports:\n * - Node.js (fs/promises)\n * - Browsers (fetch)\n * - Workers (fetch)\n */\nexport async function loadWasmBinary(\n relativePath: string,\n baseUrlOverride?: string | URL\n): Promise<ArrayBuffer> {\n // Get the base URL depending on the environment (worker or main thread)\n // If a base URL is provided, use it; otherwise use import.meta.url from this module\n // In a worker, import.meta.url is the worker's own URL.\n // In the main thread, it's the URL of the current module.\n const baseUrl = baseUrlOverride\n ? typeof baseUrlOverride === 'string'\n ? new URL('.', baseUrlOverride)\n : new URL('.', baseUrlOverride.href)\n : new URL('.', import.meta.url);\n const fullUrl = new URL(relativePath, baseUrl);\n\n console.log(`[WasmLoader] Loading WASM from relative path: ${relativePath}`);\n console.log(`[WasmLoader] Base URL (import.meta.url): ${baseUrl.href}`);\n console.log(`[WasmLoader] Constructed full URL: ${fullUrl.href}`);\n\n try {\n const response = await fetch(fullUrl.href);\n\n console.log(\n `[WasmLoader] Fetch response status for ${fullUrl.href}: ${response.status}`\n );\n\n if (!response.ok) {\n const responseText = await response.text();\n console.error(\n `[WasmLoader] Fetch response text (first 500 chars):`,\n responseText.substring(0, 500)\n );\n throw new Error(\n `Failed to fetch WASM module at ${fullUrl.href}: ${response.status} ${response.statusText}`\n );\n }\n\n const contentType = response.headers.get('content-type');\n console.log(`[WasmLoader] Response Content-Type: ${contentType}`);\n if (!contentType || !contentType.includes('application/wasm')) {\n console.warn(\n `[WasmLoader] Warning: WASM module at ${fullUrl.href} served with incorrect MIME type: \"${contentType}\". Should be \"application/wasm\".`\n );\n }\n\n return await response.arrayBuffer();\n } catch (error) {\n console.error(\n `[WasmLoader] CRITICAL: Fetching WASM binary from ${fullUrl.href} failed.`,\n error\n );\n throw error;\n }\n}\n\n/**\n * Load WASM JavaScript module with fallback strategies\n *\n * Strategy 1: Static relative import (works everywhere)\n * Strategy 2: import.meta.resolve (Node.js 22+)\n * Strategy 3: URL-based import (browsers/workers)\n */\nexport async function loadWasmModule(\n modulePath: string\n): Promise<WebAssembly.Module> {\n // Strategy 1: Try direct static import\n try {\n return await import(/* @vite-ignore */ modulePath);\n\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n } catch (e1) {\n // Continue to next strategy\n }\n\n // Strategy 2: Try import.meta.resolve (Node.js 22+)\n try {\n const resolvedPath = await import.meta.resolve(modulePath);\n\n return await import(/* @vite-ignore */ resolvedPath);\n\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n } catch (e2) {\n // Continue to next strategy\n }\n\n // Strategy 3: Try URL-based import\n try {\n const url = new URL(/* @vite-ignore */ modulePath, import.meta.url);\n\n return await import(/* @vite-ignore */ url.href);\n } catch (e3) {\n throw new Error(\n `Failed to load WASM module from \"${modulePath}\". ` +\n `Ensure WASM files are in the expected location and the module can be resolved.`,\n { cause: e3 }\n );\n }\n}\n",
9
9
  "import type { ImageInput } from './types.js';\n\nexport function validateArrayBuffer(\n buffer: unknown\n): asserts buffer is ArrayBuffer {\n // Check if SharedArrayBuffer is defined in the current environment before using it\n if (\n typeof SharedArrayBuffer !== 'undefined' &&\n buffer instanceof SharedArrayBuffer\n ) {\n throw new Error(\n 'SharedArrayBuffer is not supported. ' +\n 'Use regular ArrayBuffer or Uint8Array instead.'\n );\n }\n\n if (!(buffer instanceof ArrayBuffer)) {\n throw new TypeError('image.data.buffer must be an ArrayBuffer');\n }\n}\n\nexport function validateImageInput(\n image: unknown\n): asserts image is ImageInput {\n if (!image || typeof image !== 'object') {\n throw new TypeError('image must be an object');\n }\n\n const imageObj = image as Record<string, unknown>;\n\n if (!('data' in imageObj)) {\n throw new TypeError('image.data is required');\n }\n\n const { data } = imageObj;\n if (!(data instanceof Uint8Array || data instanceof Uint8ClampedArray)) {\n throw new TypeError('image.data must be Uint8Array or Uint8ClampedArray');\n }\n\n if (!('width' in imageObj) || !('height' in imageObj)) {\n throw new TypeError('image.width and image.height are required');\n }\n\n const { width, height } = imageObj;\n\n if (typeof width !== 'number' || !Number.isInteger(width) || width <= 0) {\n throw new RangeError(\n `image.width must be a positive integer, got ${width}`\n );\n }\n\n if (typeof height !== 'number' || !Number.isInteger(height) || height <= 0) {\n throw new RangeError(\n `image.height must be a positive integer, got ${height}`\n );\n }\n\n const expectedSize = width * height * 4;\n if (data.length < expectedSize) {\n throw new RangeError(\n `image.data too small: ${data.length} bytes, expected at least ${expectedSize} bytes for ${width}x${height} RGBA image`\n );\n }\n}\n",
10
- "/**\n * @squoosh-kit/runtime\n *\n * Core runtime logic for squoosh-kit, including environment utilities\n * and worker communication helpers.\n */\n\nexport * from './env.js';\nexport * from './worker-call.js';\nexport * from './types.js';\nexport * from './worker-helper.js';\nexport * from './wasm-loader.js';\nexport * from './validators.js';\nexport * from './simd-detector.js';\n",
11
- "export function validateResizeOptions(options: unknown): asserts options is {\n width?: number;\n height?: number;\n method?: 'triangular' | 'catrom' | 'mitchell' | 'lanczos3';\n premultiply?: boolean;\n linearRGB?: boolean;\n} {\n if (typeof options !== 'object' || options === null) {\n throw new TypeError('options must be an object');\n }\n\n const opts = options as Record<string, unknown>;\n\n if (opts.width !== undefined) {\n if (\n typeof opts.width !== 'number' ||\n !Number.isInteger(opts.width) ||\n opts.width <= 0\n ) {\n throw new RangeError(\n `options.width must be a positive integer, got ${opts.width}`\n );\n }\n }\n\n if (opts.height !== undefined) {\n if (\n typeof opts.height !== 'number' ||\n !Number.isInteger(opts.height) ||\n opts.height <= 0\n ) {\n throw new RangeError(\n `options.height must be a positive integer, got ${opts.height}`\n );\n }\n }\n\n if (opts.method !== undefined) {\n const validMethods = ['triangular', 'catrom', 'mitchell', 'lanczos3'];\n if (!validMethods.includes(opts.method as string)) {\n throw new TypeError(\n `options.method must be one of: ${validMethods.join(', ')}, got ${opts.method}`\n );\n }\n }\n\n if (opts.premultiply !== undefined && typeof opts.premultiply !== 'boolean') {\n throw new TypeError(\n `options.premultiply must be boolean, got ${typeof opts.premultiply}`\n );\n }\n\n if (opts.linearRGB !== undefined && typeof opts.linearRGB !== 'boolean') {\n throw new TypeError(\n `options.linearRGB must be boolean, got ${typeof opts.linearRGB}`\n );\n }\n}\n",
10
+ "/**\n * @squoosh-kit/runtime\n *\n * Core runtime logic for squoosh-kit, including environment utilities\n * and worker communication helpers.\n */\n\nexport * from './env.js';\nexport * from './worker-call.js';\nexport * from './types.js';\nexport * from './worker-helper.js';\nexport * from './wasm-loader.js';\nexport * from './validators.js';\nexport * from './simd-detector.js';\nexport * from './image-data-polyfill.js';\n",
11
+ "export function validateResizeOptions(options: unknown): asserts options is {\n width?: number;\n height?: number;\n method?: 'triangular' | 'catrom' | 'mitchell' | 'lanczos3';\n premultiply?: boolean;\n linearRGB?: boolean;\n} {\n if (typeof options !== 'object' || options === null) {\n throw new TypeError('options must be an object');\n }\n\n const opts = options as Record<string, unknown>;\n\n if (opts.width !== undefined) {\n if (\n typeof opts.width !== 'number' ||\n !Number.isFinite(opts.width) ||\n !Number.isInteger(opts.width) ||\n opts.width <= 0\n ) {\n throw new RangeError(\n `options.width must be a positive integer, got ${opts.width}`\n );\n }\n }\n\n if (opts.height !== undefined) {\n if (\n typeof opts.height !== 'number' ||\n !Number.isFinite(opts.height) ||\n !Number.isInteger(opts.height) ||\n opts.height <= 0\n ) {\n throw new RangeError(\n `options.height must be a positive integer, got ${opts.height}`\n );\n }\n }\n\n if (opts.method !== undefined) {\n const validMethods = ['triangular', 'catrom', 'mitchell', 'lanczos3'];\n if (!validMethods.includes(opts.method as string)) {\n throw new TypeError(\n `options.method must be one of: ${validMethods.join(', ')}, got ${opts.method}`\n );\n }\n }\n\n if (opts.premultiply !== undefined && typeof opts.premultiply !== 'boolean') {\n throw new TypeError(\n `options.premultiply must be boolean, got ${typeof opts.premultiply}`\n );\n }\n\n if (opts.linearRGB !== undefined && typeof opts.linearRGB !== 'boolean') {\n throw new TypeError(\n `options.linearRGB must be boolean, got ${typeof opts.linearRGB}`\n );\n }\n}\n",
12
12
  "\nlet wasm;\n\nlet cachegetUint8Memory0 = null;\nfunction getUint8Memory0() {\n if (cachegetUint8Memory0 === null || cachegetUint8Memory0.buffer !== wasm.memory.buffer) {\n cachegetUint8Memory0 = new Uint8Array(wasm.memory.buffer);\n }\n return cachegetUint8Memory0;\n}\n\nlet WASM_VECTOR_LEN = 0;\n\nfunction passArray8ToWasm0(arg, malloc) {\n const ptr = malloc(arg.length * 1);\n getUint8Memory0().set(arg, ptr / 1);\n WASM_VECTOR_LEN = arg.length;\n return ptr;\n}\n\nlet cachegetInt32Memory0 = null;\nfunction getInt32Memory0() {\n if (cachegetInt32Memory0 === null || cachegetInt32Memory0.buffer !== wasm.memory.buffer) {\n cachegetInt32Memory0 = new Int32Array(wasm.memory.buffer);\n }\n return cachegetInt32Memory0;\n}\n\nlet cachegetUint8ClampedMemory0 = null;\nfunction getUint8ClampedMemory0() {\n if (cachegetUint8ClampedMemory0 === null || cachegetUint8ClampedMemory0.buffer !== wasm.memory.buffer) {\n cachegetUint8ClampedMemory0 = new Uint8ClampedArray(wasm.memory.buffer);\n }\n return cachegetUint8ClampedMemory0;\n}\n\nfunction getClampedArrayU8FromWasm0(ptr, len) {\n return getUint8ClampedMemory0().subarray(ptr / 1, ptr / 1 + len);\n}\n/**\n* @param {Uint8Array} input_image\n* @param {number} input_width\n* @param {number} input_height\n* @param {number} output_width\n* @param {number} output_height\n* @param {number} typ_idx\n* @param {boolean} premultiply\n* @param {boolean} color_space_conversion\n* @returns {Uint8ClampedArray}\n*/\nexport function resize(input_image, input_width, input_height, output_width, output_height, typ_idx, premultiply, color_space_conversion) {\n try {\n const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);\n var ptr0 = passArray8ToWasm0(input_image, wasm.__wbindgen_malloc);\n var len0 = WASM_VECTOR_LEN;\n wasm.resize(retptr, ptr0, len0, input_width, input_height, output_width, output_height, typ_idx, premultiply, color_space_conversion);\n var r0 = getInt32Memory0()[retptr / 4 + 0];\n var r1 = getInt32Memory0()[retptr / 4 + 1];\n var v1 = getClampedArrayU8FromWasm0(r0, r1).slice();\n wasm.__wbindgen_free(r0, r1 * 1);\n return v1;\n } finally {\n wasm.__wbindgen_add_to_stack_pointer(16);\n }\n}\n\nasync function load(module, imports) {\n if (typeof Response === 'function' && module instanceof Response) {\n if (typeof WebAssembly.instantiateStreaming === 'function') {\n try {\n return await WebAssembly.instantiateStreaming(module, imports);\n\n } catch (e) {\n if (module.headers.get('Content-Type') != 'application/wasm') {\n console.warn(\"`WebAssembly.instantiateStreaming` failed because your server does not serve wasm with `application/wasm` MIME type. Falling back to `WebAssembly.instantiate` which is slower. Original error:\\n\", e);\n\n } else {\n throw e;\n }\n }\n }\n\n const bytes = await module.arrayBuffer();\n return await WebAssembly.instantiate(bytes, imports);\n\n } else {\n const instance = await WebAssembly.instantiate(module, imports);\n\n if (instance instanceof WebAssembly.Instance) {\n return { instance, module };\n\n } else {\n return instance;\n }\n }\n}\n\nasync function init(input) {\n if (typeof input === 'undefined') {\n input = new URL('squoosh_resize_bg.wasm', import.meta.url);\n }\n const imports = {};\n\n\n if (typeof input === 'string' || (typeof Request === 'function' && input instanceof Request) || (typeof URL === 'function' && input instanceof URL)) {\n input = fetch(input);\n }\n\n\n\n const { instance, module } = await load(await input, imports);\n\n wasm = instance.exports;\n init.__wbindgen_wasm_module = module;\n\n return wasm;\n}\n\nexport default init;\n\n",
13
- "/**\n * Resize processor - single-source worker/client implementation\n */\n\nimport {\n type WorkerRequest,\n type WorkerResponse,\n type ImageInput,\n loadWasmBinary,\n validateImageInput,\n} from '@squoosh-kit/runtime';\nimport { validateResizeOptions } from './validators';\nimport type { ResizeOptions } from './types';\nimport * as squoosh_resize_module from '../wasm/squoosh_resize';\n\n// Define the type locally to avoid module resolution issues with the linter\ntype SquooshWasmResize = (\n input_image: Uint8Array,\n input_width: number,\n input_height: number,\n output_width: number,\n output_height: number,\n typ_idx: number,\n premultiply: boolean,\n color_space_conversion: boolean\n) => Uint8ClampedArray;\n\nlet wasmResize: SquooshWasmResize | null = null;\nlet initPromise: Promise<void> | null = null;\n\nasync function init(): Promise<void> {\n if (wasmResize) {\n return;\n }\n\n if (initPromise) {\n return initPromise;\n }\n\n initPromise = (async () => {\n try {\n // Use the worker's own import.meta.url as the base for resolving WASM paths\n const workerBaseUrl = new URL('.', import.meta.url);\n const wasmPathsToTry = [\n './wasm/squoosh_resize_bg.wasm',\n '../wasm/squoosh_resize_bg.wasm',\n ];\n\n let wasmBuffer: ArrayBuffer | null = null;\n let lastError: Error | null = null;\n for (const path of wasmPathsToTry) {\n try {\n wasmBuffer = await loadWasmBinary(path, workerBaseUrl);\n break;\n } catch (error) {\n lastError = error instanceof Error ? error : new Error(String(error));\n }\n }\n\n if (!wasmBuffer) {\n throw (\n lastError || new Error('Could not load WASM binary from any path')\n );\n }\n\n // Initialize WASM module with the binary buffer\n try {\n await squoosh_resize_module.default(wasmBuffer);\n } catch (initError: unknown) {\n // If initialization fails due to SharedArrayBuffer issues, try with polyfill\n if (\n initError instanceof Error &&\n (initError.message.includes('SharedArrayBuffer') ||\n initError.message.includes('first argument must be'))\n ) {\n // Apply polyfill and retry\n if (typeof SharedArrayBuffer === 'undefined') {\n (\n globalThis as unknown as Record<string, typeof ArrayBuffer>\n ).SharedArrayBuffer = ArrayBuffer;\n }\n // Reload the module with polyfill in place\n try {\n await squoosh_resize_module.default(wasmBuffer);\n } catch (retryError) {\n throw new Error(\n `WASM module initialization failed even with polyfill: ${retryError instanceof Error ? retryError.message : String(retryError)}`\n );\n }\n } else {\n throw initError;\n }\n }\n // After initialization, the module's exported resize function is ready to use\n wasmResize = squoosh_resize_module.resize as unknown as SquooshWasmResize;\n } catch (error) {\n initPromise = null;\n throw new Error(\n `Failed to initialize resize WASM module: ${error instanceof Error ? error.message : String(error)}`\n );\n }\n })();\n\n return initPromise;\n}\n\nasync function _resizeCore(\n image: ImageInput,\n options: ResizeOptions\n): Promise<ImageInput> {\n validateImageInput(image);\n validateResizeOptions(options);\n\n await init();\n if (!wasmResize) {\n throw new Error('Resize module not initialized');\n }\n\n const { data, width: inputWidth, height: inputHeight } = image;\n\n let outputWidth = options.width ?? inputWidth;\n let outputHeight = options.height ?? inputHeight;\n\n if (options.width && !options.height) {\n outputHeight = Math.max(\n 1,\n Math.round((inputHeight * options.width) / inputWidth)\n );\n } else if (options.height && !options.width) {\n outputWidth = Math.max(\n 1,\n Math.round((inputWidth * options.height) / inputHeight)\n );\n }\n\n if (outputWidth < 1 || outputHeight < 1) {\n throw new RangeError(\n `Output dimensions must be at least 1x1, got ${outputWidth}x${outputHeight}`\n );\n }\n\n // Create a zero-copy Uint8Array view if needed\n // (don't copy the buffer - just create a view on the same memory)\n const dataArray =\n data instanceof Uint8ClampedArray\n ? new Uint8Array(data.buffer as ArrayBuffer, data.byteOffset, data.length)\n : new Uint8Array(\n data.buffer as ArrayBuffer,\n data.byteOffset,\n data.length\n );\n\n const result = wasmResize(\n dataArray,\n inputWidth,\n inputHeight,\n outputWidth,\n outputHeight,\n getResizeMethod(options),\n options.premultiply ?? true,\n options.linearRGB ?? true\n );\n\n return {\n data: result,\n width: outputWidth,\n height: outputHeight,\n };\n}\n\nexport async function resizeClient(\n image: ImageInput,\n options: ResizeOptions,\n signal?: AbortSignal\n): Promise<ImageInput> {\n if (signal?.aborted) {\n throw new DOMException('Aborted', 'AbortError');\n }\n return _resizeCore(image, options);\n}\n\n/**\n * Map ResizeOptions method to WASM typ_idx parameter\n * typ_idx values (from Squoosh):\n * 0: Triangular - fastest, lowest quality\n * 1: Catrom - medium quality and speed\n * 2: Mitchell - good balance (default)\n * 3: Lanczos3 - highest quality, slowest\n */\nfunction getResizeMethod(options?: ResizeOptions): number {\n const methodMap: Record<string, number> = {\n triangular: 0,\n catrom: 1,\n mitchell: 2,\n lanczos3: 3,\n };\n return methodMap[options?.method ?? 'lanczos3'] ?? 3;\n}\n\n/**\n * Worker message handler\n */\nif (typeof self !== 'undefined') {\n self.onmessage = async (event: MessageEvent) => {\n const data = event.data;\n\n // Handle worker ping for initialization\n if (data?.type === 'worker:ping') {\n self.postMessage({ type: 'worker:ready' });\n return;\n }\n\n const { id, type, payload } = data as WorkerRequest<{\n image: ImageInput;\n options: ResizeOptions;\n }>;\n\n const response: WorkerResponse<ImageInput> = { id, ok: false };\n\n try {\n if (type !== 'resize:run') {\n throw new Error(`Unknown message type: ${type}`);\n }\n\n const resultImage = await _resizeCore(payload.image, payload.options);\n\n response.ok = true;\n response.data = resultImage;\n\n // Post the response without transferring - the ImageInput with data will be cloned\n // Transfer is only used for incoming requests (image.data buffer from client)\n self.postMessage(response);\n } catch (error) {\n response.error = error instanceof Error ? error.message : String(error);\n self.postMessage(response);\n }\n };\n}\n"
13
+ "/**\n * Resize processor - single-source worker/client implementation\n */\n\nimport {\n type WorkerRequest,\n type WorkerResponse,\n type ImageInput,\n loadWasmBinary,\n validateImageInput,\n} from '@squoosh-kit/runtime';\nimport { validateResizeOptions } from './validators';\nimport type { ResizeOptions } from './types';\nimport * as squoosh_resize_module from '../wasm/squoosh_resize';\n\n// Define the type locally to avoid module resolution issues with the linter\ntype SquooshWasmResize = (\n input_image: Uint8Array,\n input_width: number,\n input_height: number,\n output_width: number,\n output_height: number,\n typ_idx: number,\n premultiply: boolean,\n color_space_conversion: boolean\n) => Uint8ClampedArray;\n\nlet wasmResize: SquooshWasmResize | null = null;\nlet initPromise: Promise<void> | null = null;\n\nasync function init(): Promise<void> {\n if (wasmResize) {\n return;\n }\n\n if (initPromise) {\n return initPromise;\n }\n\n initPromise = (async () => {\n try {\n // Use the worker's own import.meta.url as the base for resolving WASM paths\n const workerBaseUrl = new URL('.', import.meta.url);\n const isSource = import.meta.url.includes('/src/');\n const wasmPathsToTry = isSource\n ? ['../wasm/squoosh_resize_bg.wasm', './wasm/squoosh_resize_bg.wasm']\n : ['./wasm/squoosh_resize_bg.wasm', '../wasm/squoosh_resize_bg.wasm'];\n\n let wasmBuffer: ArrayBuffer | null = null;\n let lastError: Error | null = null;\n for (const path of wasmPathsToTry) {\n try {\n wasmBuffer = await loadWasmBinary(path, workerBaseUrl);\n break;\n } catch (error) {\n lastError = error instanceof Error ? error : new Error(String(error));\n }\n }\n\n if (!wasmBuffer) {\n throw (\n lastError || new Error('Could not load WASM binary from any path')\n );\n }\n\n // Initialize WASM module with the binary buffer\n try {\n await squoosh_resize_module.default(wasmBuffer);\n } catch (initError: unknown) {\n // If initialization fails due to SharedArrayBuffer issues, try with polyfill\n if (\n initError instanceof Error &&\n (initError.message.includes('SharedArrayBuffer') ||\n initError.message.includes('first argument must be'))\n ) {\n // Apply polyfill and retry\n if (typeof SharedArrayBuffer === 'undefined') {\n (\n globalThis as unknown as Record<string, typeof ArrayBuffer>\n ).SharedArrayBuffer = ArrayBuffer;\n }\n // Reload the module with polyfill in place\n try {\n await squoosh_resize_module.default(wasmBuffer);\n } catch (retryError) {\n throw new Error(\n `WASM module initialization failed even with polyfill: ${retryError instanceof Error ? retryError.message : String(retryError)}`,\n { cause: retryError }\n );\n }\n } else {\n throw initError;\n }\n }\n // After initialization, the module's exported resize function is ready to use\n wasmResize = squoosh_resize_module.resize as unknown as SquooshWasmResize;\n } catch (error) {\n initPromise = null;\n throw new Error(\n `Failed to initialize resize WASM module: ${error instanceof Error ? error.message : String(error)}`,\n { cause: error }\n );\n }\n })();\n\n return initPromise;\n}\n\nasync function _resizeCore(\n image: ImageInput,\n options: ResizeOptions\n): Promise<ImageInput> {\n validateImageInput(image);\n validateResizeOptions(options);\n\n await init();\n if (!wasmResize) {\n throw new Error('Resize module not initialized');\n }\n\n const { data, width: inputWidth, height: inputHeight } = image;\n\n let outputWidth = options.width ?? inputWidth;\n let outputHeight = options.height ?? inputHeight;\n\n if (options.width && !options.height) {\n outputHeight = Math.max(\n 1,\n Math.round((inputHeight * options.width) / inputWidth)\n );\n } else if (options.height && !options.width) {\n outputWidth = Math.max(\n 1,\n Math.round((inputWidth * options.height) / inputHeight)\n );\n }\n\n if (outputWidth < 1 || outputHeight < 1) {\n throw new RangeError(\n `Output dimensions must be at least 1x1, got ${outputWidth}x${outputHeight}`\n );\n }\n\n // Create a zero-copy Uint8Array view if needed\n // (don't copy the buffer - just create a view on the same memory)\n const dataArray =\n data instanceof Uint8ClampedArray\n ? new Uint8Array(data.buffer as ArrayBuffer, data.byteOffset, data.length)\n : new Uint8Array(\n data.buffer as ArrayBuffer,\n data.byteOffset,\n data.length\n );\n\n const result = wasmResize(\n dataArray,\n inputWidth,\n inputHeight,\n outputWidth,\n outputHeight,\n getResizeMethod(options),\n options.premultiply ?? true,\n options.linearRGB ?? true\n );\n\n return {\n data: result,\n width: outputWidth,\n height: outputHeight,\n };\n}\n\nexport async function resizeClient(\n image: ImageInput,\n options: ResizeOptions,\n signal?: AbortSignal\n): Promise<ImageInput> {\n if (signal?.aborted) {\n throw new DOMException('Aborted', 'AbortError');\n }\n return _resizeCore(image, options);\n}\n\n/**\n * Map ResizeOptions method to WASM typ_idx parameter\n * typ_idx values (from Squoosh):\n * 0: Triangular - fastest, lowest quality\n * 1: Catrom - medium quality and speed\n * 2: Mitchell - good balance (default)\n * 3: Lanczos3 - highest quality, slowest\n */\nfunction getResizeMethod(options?: ResizeOptions): number {\n const methodMap: Record<string, number> = {\n triangular: 0,\n catrom: 1,\n mitchell: 2,\n lanczos3: 3,\n };\n return methodMap[options?.method ?? 'lanczos3'] ?? 3;\n}\n\n/**\n * Worker message handler\n */\nif (typeof self !== 'undefined') {\n self.onmessage = async (event: MessageEvent) => {\n const data = event.data;\n\n // Handle worker ping for initialization\n if (data?.type === 'worker:ping') {\n await init();\n self.postMessage({ type: 'worker:ready' });\n return;\n }\n\n const { id, type, payload } = data as WorkerRequest<{\n image: ImageInput;\n options: ResizeOptions;\n }>;\n\n const response: WorkerResponse<ImageInput> = { id, ok: false };\n\n try {\n if (type !== 'resize:run') {\n throw new Error(`Unknown message type: ${type}`);\n }\n\n const resultImage = await _resizeCore(payload.image, payload.options);\n\n response.ok = true;\n response.data = resultImage;\n const transferBuffer =\n resultImage.data.buffer instanceof ArrayBuffer\n ? resultImage.data.buffer\n : resultImage.data.slice().buffer;\n self.postMessage(response, { transfer: [transferBuffer] });\n } catch (error) {\n response.error = error instanceof Error ? error.message : String(error);\n self.postMessage(response);\n }\n };\n}\n"
14
14
  ],
15
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAyBO,SAAS,KAAK,GAAY;AAAA,EAC/B,OAAO,OAAO,QAAQ;AAAA;;;ACGxB,eAAsB,UAA+B,CACnD,QACA,MACA,SACA,QACA,UACoB;AAAA,EACpB,OAAO,IAAI,QAAmB,CAAC,SAAS,WAAW;AAAA,IACjD,MAAM,KAAK,EAAE;AAAA,IAGb,IAAI,QAAQ,SAAS;AAAA,MACnB,OAAO,IAAI,aAAa,WAAW,YAAY,CAAC;AAAA,MAChD;AAAA,IACF;AAAA,IAEA,MAAM,gBAAgB,CAAC,UAAwB;AAAA,MAC7C,MAAM,WAAW,MAAM;AAAA,MACvB,IAAI,SAAS,OAAO;AAAA,QAAI;AAAA,MAExB,QAAQ;AAAA,MAER,IAAI,SAAS,MAAM,SAAS,SAAS,WAAW;AAAA,QAC9C,QAAQ,SAAS,IAAI;AAAA,MACvB,EAAO;AAAA,QACL,OAAO,IAAI,MAAM,SAAS,SAAS,sBAAsB,CAAC;AAAA;AAAA;AAAA,IAI9D,MAAM,cAAc,CAAC,UAAsB;AAAA,MACzC,QAAQ;AAAA,MACR,OAAO,IAAI,MAAM,iBAAiB,MAAM,SAAS,CAAC;AAAA;AAAA,IAGpD,MAAM,cAAc,MAAM;AAAA,MACxB,QAAQ;AAAA,MACR,OAAO,IAAI,aAAa,WAAW,YAAY,CAAC;AAAA;AAAA,IAGlD,MAAM,UAAU,MAAM;AAAA,MACpB,OAAO,oBAAoB,WAAW,aAAa;AAAA,MACnD,OAAO,oBAAoB,SAAS,WAAW;AAAA,MAC/C,QAAQ,oBAAoB,SAAS,WAAW;AAAA;AAAA,IAIlD,OAAO,iBAAiB,WAAW,aAAa;AAAA,IAChD,OAAO,iBAAiB,SAAS,WAAW;AAAA,IAC5C,QAAQ,iBAA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F4BC4365B0764756E2164756E21",
17
17
  "names": []
18
18
  }
@@ -1,11 +1,15 @@
1
1
  var __defProp = Object.defineProperty;
2
+ var __returnValue = (v) => v;
3
+ function __exportSetter(name, newValue) {
4
+ this[name] = __returnValue.bind(null, newValue);
5
+ }
2
6
  var __export = (target, all) => {
3
7
  for (var name in all)
4
8
  __defProp(target, name, {
5
9
  get: all[name],
6
10
  enumerable: true,
7
11
  configurable: true,
8
- set: (newValue) => all[name] = () => newValue
12
+ set: __exportSetter.bind(all, name)
9
13
  });
10
14
  };
11
15
  var __esm = (fn, res) => () => (fn && (res = fn(fn = 0)), res);
@@ -71,6 +75,50 @@ function createCodecWorker(workerFilename, options) {
71
75
  "webp.worker.js": {
72
76
  package: "@squoosh-kit/webp",
73
77
  specifier: "webp.worker.js"
78
+ },
79
+ "avif.worker.js": {
80
+ package: "@squoosh-kit/avif",
81
+ specifier: "avif.worker.js"
82
+ },
83
+ "mozjpeg.worker.js": {
84
+ package: "@squoosh-kit/mozjpeg",
85
+ specifier: "mozjpeg.worker.js"
86
+ },
87
+ "jxl.worker.js": {
88
+ package: "@squoosh-kit/jxl",
89
+ specifier: "jxl.worker.js"
90
+ },
91
+ "oxipng.worker.js": {
92
+ package: "@squoosh-kit/oxipng",
93
+ specifier: "oxipng.worker.js"
94
+ },
95
+ "png.worker.js": {
96
+ package: "@squoosh-kit/png",
97
+ specifier: "png.worker.js"
98
+ },
99
+ "imagequant.worker.js": {
100
+ package: "@squoosh-kit/imagequant",
101
+ specifier: "imagequant.worker.js"
102
+ },
103
+ "qoi.worker.js": {
104
+ package: "@squoosh-kit/qoi",
105
+ specifier: "qoi.worker.js"
106
+ },
107
+ "wp2.worker.js": {
108
+ package: "@squoosh-kit/wp2",
109
+ specifier: "wp2.worker.js"
110
+ },
111
+ "hqx.worker.js": {
112
+ package: "@squoosh-kit/hqx",
113
+ specifier: "hqx.worker.js"
114
+ },
115
+ "rotate.worker.js": {
116
+ package: "@squoosh-kit/rotate",
117
+ specifier: "rotate.worker.js"
118
+ },
119
+ "visdif.worker.js": {
120
+ package: "@squoosh-kit/visdif",
121
+ specifier: "visdif.worker.js"
74
122
  }
75
123
  };
76
124
  const workerConfig = workerMap[normalizedName];
@@ -101,7 +149,7 @@ function createCodecWorker(workerFilename, options) {
101
149
  return worker;
102
150
  } catch (e) {
103
151
  console.error(`[worker-helper] Failed to load worker from assetPath URL: ${workerUrl}`, e);
104
- throw new Error(`Worker failed to load from ${workerUrl}: ${e instanceof Error ? e.message : String(e)}`);
152
+ throw new Error(`Worker failed to load from ${workerUrl}: ${e instanceof Error ? e.message : String(e)}`, { cause: e });
105
153
  }
106
154
  }
107
155
  const pathStrategies = [
@@ -134,7 +182,8 @@ function createCodecWorker(workerFilename, options) {
134
182
  }
135
183
  const platformExt = isBun() ? ".bun.js" : ".node.mjs";
136
184
  const baseName = normalizedName.replace(".js", "");
137
- const srcRelPath = workerConfig.package.includes("resize") ? `../../resize/src/${baseName}.ts` : `../../webp/src/${baseName}.ts`;
185
+ const pkgName = workerConfig.package.split("/")[1];
186
+ const srcRelPath = `../../${pkgName}/src/${baseName}.ts`;
138
187
  console.log("srcRelPath:", srcRelPath);
139
188
  console.log("import.meta.url:", import.meta.url);
140
189
  try {
@@ -142,7 +191,7 @@ function createCodecWorker(workerFilename, options) {
142
191
  type: "module"
143
192
  });
144
193
  } catch {
145
- const distRelPath = workerConfig.package.includes("resize") ? `../../resize/dist/${baseName}.${platformExt.slice(1)}` : `../../webp/dist/${baseName}.${platformExt.slice(1)}`;
194
+ const distRelPath = `../../${pkgName}/dist/${baseName}.${platformExt.slice(1)}`;
146
195
  console.log("distRelPath:", distRelPath);
147
196
  console.log("import.meta.url:", import.meta.url);
148
197
  try {
@@ -162,7 +211,7 @@ function createCodecWorker(workerFilename, options) {
162
211
  throw new Error(`Failed to create worker from ${normalizedName}. ` + `Tried TypeScript source, dist output, and import.meta.resolve. ` + `Ensure the @squoosh-kit/resize and @squoosh-kit/webp packages are installed.`);
163
212
  } catch (error) {
164
213
  const errorMessage = error instanceof Error ? error.message : String(error);
165
- throw new Error(`Failed to create worker from ${normalizedName}: ${errorMessage}. ` + `Ensure the @squoosh-kit/resize and @squoosh-kit/webp packages are installed. ` + `If you're using Vite, ensure the worker files are not being optimized as dependencies.`);
214
+ throw new Error(`Failed to create worker from ${normalizedName}: ${errorMessage}. ` + `Ensure the @squoosh-kit/resize and @squoosh-kit/webp packages are installed. ` + `If you're using Vite, ensure the worker files are not being optimized as dependencies.`, { cause: error });
166
215
  }
167
216
  }
168
217
  function createReadyWorker(workerFilename, options, timeoutMs = 1e4) {
@@ -280,12 +329,12 @@ function validateResizeOptions(options) {
280
329
  }
281
330
  const opts = options;
282
331
  if (opts.width !== undefined) {
283
- if (typeof opts.width !== "number" || !Number.isInteger(opts.width) || opts.width <= 0) {
332
+ if (typeof opts.width !== "number" || !Number.isFinite(opts.width) || !Number.isInteger(opts.width) || opts.width <= 0) {
284
333
  throw new RangeError(`options.width must be a positive integer, got ${opts.width}`);
285
334
  }
286
335
  }
287
336
  if (opts.height !== undefined) {
288
- if (typeof opts.height !== "number" || !Number.isInteger(opts.height) || opts.height <= 0) {
337
+ if (typeof opts.height !== "number" || !Number.isFinite(opts.height) || !Number.isInteger(opts.height) || opts.height <= 0) {
289
338
  throw new RangeError(`options.height must be a positive integer, got ${opts.height}`);
290
339
  }
291
340
  }
@@ -403,10 +452,8 @@ async function init2() {
403
452
  initPromise = (async () => {
404
453
  try {
405
454
  const workerBaseUrl = new URL(".", import.meta.url);
406
- const wasmPathsToTry = [
407
- "./wasm/squoosh_resize_bg.wasm",
408
- "../wasm/squoosh_resize_bg.wasm"
409
- ];
455
+ const isSource = import.meta.url.includes("/src/");
456
+ const wasmPathsToTry = isSource ? ["../wasm/squoosh_resize_bg.wasm", "./wasm/squoosh_resize_bg.wasm"] : ["./wasm/squoosh_resize_bg.wasm", "../wasm/squoosh_resize_bg.wasm"];
410
457
  let wasmBuffer = null;
411
458
  let lastError = null;
412
459
  for (const path of wasmPathsToTry) {
@@ -430,7 +477,7 @@ async function init2() {
430
477
  try {
431
478
  await squoosh_resize_default(wasmBuffer);
432
479
  } catch (retryError) {
433
- throw new Error(`WASM module initialization failed even with polyfill: ${retryError instanceof Error ? retryError.message : String(retryError)}`);
480
+ throw new Error(`WASM module initialization failed even with polyfill: ${retryError instanceof Error ? retryError.message : String(retryError)}`, { cause: retryError });
434
481
  }
435
482
  } else {
436
483
  throw initError;
@@ -439,7 +486,7 @@ async function init2() {
439
486
  wasmResize = resize;
440
487
  } catch (error) {
441
488
  initPromise = null;
442
- throw new Error(`Failed to initialize resize WASM module: ${error instanceof Error ? error.message : String(error)}`);
489
+ throw new Error(`Failed to initialize resize WASM module: ${error instanceof Error ? error.message : String(error)}`, { cause: error });
443
490
  }
444
491
  })();
445
492
  return initPromise;
@@ -493,6 +540,7 @@ var init_resize_worker = __esm(() => {
493
540
  self.onmessage = async (event) => {
494
541
  const data = event.data;
495
542
  if (data?.type === "worker:ping") {
543
+ await init2();
496
544
  self.postMessage({ type: "worker:ready" });
497
545
  return;
498
546
  }
@@ -505,7 +553,8 @@ var init_resize_worker = __esm(() => {
505
553
  const resultImage = await _resizeCore(payload.image, payload.options);
506
554
  response.ok = true;
507
555
  response.data = resultImage;
508
- self.postMessage(response);
556
+ const transferBuffer = resultImage.data.buffer instanceof ArrayBuffer ? resultImage.data.buffer : resultImage.data.slice().buffer;
557
+ self.postMessage(response, { transfer: [transferBuffer] });
509
558
  } catch (error) {
510
559
  response.error = error instanceof Error ? error.message : String(error);
511
560
  self.postMessage(response);
@@ -519,4 +568,4 @@ export {
519
568
  resizeClient
520
569
  };
521
570
 
522
- //# debugId=E09F3C892E1DFEA664756E2164756E21
571
+ //# debugId=84B8B85EB0A5400164756E2164756E21