@squoosh-kit/rotate 0.2.7 → 0.2.8

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.
@@ -65,6 +65,54 @@ async function callWorker(worker, type, payload, signal, transfer) {
65
65
  var requestId = 0;
66
66
 
67
67
  // ../runtime/src/worker-helper.ts
68
+ function scriptUrlToPath(scriptUrl) {
69
+ const href = typeof scriptUrl === "string" ? scriptUrl : scriptUrl.href;
70
+ if (href.startsWith("file://")) {
71
+ return decodeURIComponent(href.startsWith("file:///") ? href.slice(7) : href.slice(5));
72
+ }
73
+ return href;
74
+ }
75
+ function workerScriptExists(scriptUrl) {
76
+ if (typeof window !== "undefined") {
77
+ return false;
78
+ }
79
+ const path = scriptUrlToPath(scriptUrl);
80
+ if (typeof Bun !== "undefined") {
81
+ return Bun.spawnSync(["test", "-f", path], {
82
+ stdout: "ignore",
83
+ stderr: "ignore"
84
+ }).exitCode === 0;
85
+ }
86
+ try {
87
+ const existsSync = Function('return require("node:fs").existsSync')();
88
+ return existsSync(path);
89
+ } catch {
90
+ return false;
91
+ }
92
+ }
93
+ function resolveServerWorkerScript(workerConfig, normalizedName) {
94
+ const platformExt = isBun() ? "bun.js" : "node.mjs";
95
+ const baseName = normalizedName.replace(".js", "");
96
+ const pkgName = workerConfig.package.split("/")[1];
97
+ if (typeof import.meta.resolve === "function") {
98
+ try {
99
+ const resolved = import.meta.resolve(`${workerConfig.package}/${workerConfig.specifier}`);
100
+ if (workerScriptExists(resolved)) {
101
+ return resolved;
102
+ }
103
+ } catch {}
104
+ }
105
+ const candidates = [
106
+ new URL(`../../${pkgName}/dist/${baseName}.${platformExt}`, import.meta.url),
107
+ new URL(`../../${pkgName}/src/${baseName}.ts`, import.meta.url)
108
+ ];
109
+ for (const candidate of candidates) {
110
+ if (workerScriptExists(candidate)) {
111
+ return candidate;
112
+ }
113
+ }
114
+ throw new Error(`Failed to resolve worker script for ${normalizedName}. ` + `Tried import.meta.resolve, dist output, and TypeScript source. ` + `Ensure ${workerConfig.package} is installed.`);
115
+ }
68
116
  function createCodecWorker(workerFilename, options) {
69
117
  const normalizedName = workerFilename.endsWith(".js") ? workerFilename : `${workerFilename}.js`;
70
118
  const workerMap = {
@@ -181,35 +229,8 @@ function createCodecWorker(workerFilename, options) {
181
229
  }
182
230
  throw new Error(`Could not resolve worker ${normalizedName} using any available path strategy`);
183
231
  }
184
- const platformExt = isBun() ? ".bun.js" : ".node.mjs";
185
- const baseName = normalizedName.replace(".js", "");
186
- const pkgName = workerConfig.package.split("/")[1];
187
- const srcRelPath = `../../${pkgName}/src/${baseName}.ts`;
188
- console.log("srcRelPath:", srcRelPath);
189
- console.log("import.meta.url:", import.meta.url);
190
- try {
191
- return new Worker(new URL(srcRelPath, import.meta.url), {
192
- type: "module"
193
- });
194
- } catch {
195
- const distRelPath = `../../${pkgName}/dist/${baseName}.${platformExt.slice(1)}`;
196
- console.log("distRelPath:", distRelPath);
197
- console.log("import.meta.url:", import.meta.url);
198
- try {
199
- return new Worker(new URL(distRelPath, import.meta.url), {
200
- type: "module"
201
- });
202
- } catch {
203
- if (typeof import.meta.resolve === "function") {
204
- try {
205
- const resolved = import.meta.resolve(`${workerConfig.package}/${workerConfig.specifier}`);
206
- console.log("resolved:", resolved);
207
- return new Worker(resolved, { type: "module" });
208
- } catch {}
209
- }
210
- }
211
- }
212
- 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.`);
232
+ const workerScript = resolveServerWorkerScript(workerConfig, normalizedName);
233
+ return new Worker(workerScript, { type: "module" });
213
234
  } catch (error) {
214
235
  const errorMessage = error instanceof Error ? error.message : String(error);
215
236
  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 });
@@ -425,4 +446,4 @@ export {
425
446
  rotateClient
426
447
  };
427
448
 
428
- //# debugId=C5F85453B59AC36864756E2164756E21
449
+ //# debugId=B4F0A2751EA9058864756E2164756E21
@@ -4,13 +4,13 @@
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 const DEFAULT_BROWSER_ASSET_PATH = '/squoosh-kit';\n\nexport type CreateWorkerOptions = {\n /**\n * Public URL prefix for worker and WASM files.\n * Defaults to `/squoosh-kit` in the browser (the path used by\n * `@squoosh-kit/vite-plugin`). Pass an empty string to resolve workers\n * relative to the installed package instead.\n */\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 browsers, workers load from `/squoosh-kit/{package}/` by default.\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 browsers, workers load from /squoosh-kit by default\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 const assetPath =\n options?.assetPath === undefined\n ? DEFAULT_BROWSER_ASSET_PATH\n : options.assetPath;\n\n if (assetPath) {\n let normalizedAssetPath = 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 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",
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 const DEFAULT_BROWSER_ASSET_PATH = '/squoosh-kit';\n\ntype WorkerPackageConfig = {\n package: string;\n specifier: string;\n};\n\nfunction scriptUrlToPath(scriptUrl: string | URL): string {\n const href = typeof scriptUrl === 'string' ? scriptUrl : scriptUrl.href;\n if (href.startsWith('file://')) {\n return decodeURIComponent(\n href.startsWith('file:///') ? href.slice(7) : href.slice(5)\n );\n }\n return href;\n}\n\nfunction workerScriptExists(scriptUrl: string | URL): boolean {\n if (typeof window !== 'undefined') {\n return false;\n }\n\n const path = scriptUrlToPath(scriptUrl);\n\n if (typeof Bun !== 'undefined') {\n return (\n Bun.spawnSync(['test', '-f', path], {\n stdout: 'ignore',\n stderr: 'ignore',\n }).exitCode === 0\n );\n }\n\n try {\n const existsSync = Function('return require(\"node:fs\").existsSync')() as (\n filePath: string\n ) => boolean;\n return existsSync(path);\n } catch {\n return false;\n }\n}\n\nexport function resolveServerWorkerScript(\n workerConfig: WorkerPackageConfig,\n normalizedName: string\n): string | URL {\n const platformExt = isBun() ? 'bun.js' : 'node.mjs';\n const baseName = normalizedName.replace('.js', '');\n const pkgName = workerConfig.package.split('/')[1];\n\n if (typeof import.meta.resolve === 'function') {\n try {\n const resolved = import.meta.resolve(\n `${workerConfig.package}/${workerConfig.specifier}`\n );\n if (workerScriptExists(resolved)) {\n return resolved;\n }\n } catch {\n // Continue to monorepo fallbacks\n }\n }\n\n const candidates = [\n new URL(\n `../../${pkgName}/dist/${baseName}.${platformExt}`,\n import.meta.url\n ),\n new URL(`../../${pkgName}/src/${baseName}.ts`, import.meta.url),\n ];\n\n for (const candidate of candidates) {\n if (workerScriptExists(candidate)) {\n return candidate;\n }\n }\n\n throw new Error(\n `Failed to resolve worker script for ${normalizedName}. ` +\n `Tried import.meta.resolve, dist output, and TypeScript source. ` +\n `Ensure ${workerConfig.package} is installed.`\n );\n}\n\nexport type CreateWorkerOptions = {\n /**\n * Public URL prefix for worker and WASM files.\n * Defaults to `/squoosh-kit` in the browser (the path used by\n * `@squoosh-kit/vite-plugin`). Pass an empty string to resolve workers\n * relative to the installed package instead.\n */\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 browsers, workers load from `/squoosh-kit/{package}/` by default.\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 browsers, workers load from /squoosh-kit by default\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 const assetPath =\n options?.assetPath === undefined\n ? DEFAULT_BROWSER_ASSET_PATH\n : options.assetPath;\n\n if (assetPath) {\n let normalizedAssetPath = 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 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 const workerScript = resolveServerWorkerScript(\n workerConfig,\n normalizedName\n );\n return new Worker(workerScript, { type: 'module' });\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
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
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
11
  "/**\n * Rotate processor - raw WASM instantiation (no JS glue)\n */\n\nimport { loadWasmBinary } from '@squoosh-kit/runtime';\nimport type {\n WorkerRequest,\n WorkerResponse,\n ImageInput,\n} from '@squoosh-kit/runtime';\nimport type { RotateOptions } from './types';\n\nlet wasmInstance: WebAssembly.Instance | null = null;\nlet initPromise: Promise<void> | null = null;\n\nasync function initRotate(): Promise<void> {\n if (wasmInstance) return;\n if (initPromise) return initPromise;\n\n initPromise = (async () => {\n try {\n const workerBaseUrl = new URL('.', import.meta.url);\n const isSource = import.meta.url.includes('/src/');\n const wasmPaths = isSource\n ? ['../wasm/rotate/rotate.wasm', './wasm/rotate/rotate.wasm']\n : ['./wasm/rotate/rotate.wasm', '../wasm/rotate/rotate.wasm'];\n\n let wasmBuffer: ArrayBuffer | null = null;\n let lastError: Error | null = null;\n for (const path of wasmPaths) {\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 if (!wasmBuffer) {\n throw lastError || new Error('Could not load rotate WASM');\n }\n\n const { instance } = await WebAssembly.instantiate(wasmBuffer);\n wasmInstance = instance;\n initPromise = null;\n } catch (error) {\n initPromise = null;\n throw new Error(\n `Failed to initialize rotate WASM module: ${error instanceof Error ? error.message : String(error)}`,\n { cause: error }\n );\n }\n })();\n\n return initPromise;\n}\n\nexport async function rotateClient(\n image: ImageInput,\n options?: RotateOptions,\n signal?: AbortSignal\n): Promise<ImageInput> {\n if (signal?.aborted) {\n throw new DOMException('Aborted', 'AbortError');\n }\n\n await initRotate();\n\n if (signal?.aborted) {\n throw new DOMException('Aborted', 'AbortError');\n }\n\n if (!wasmInstance) {\n throw new Error('Rotate module not initialized');\n }\n\n const degrees = options?.rotate ?? 0;\n const { data, width, height } = image;\n const n = width * height;\n\n // Calculate output dimensions\n const outW = degrees === 90 || degrees === 270 ? height : width;\n const outH = degrees === 90 || degrees === 270 ? width : height;\n\n const memory = wasmInstance.exports.memory as WebAssembly.Memory;\n const rotate = wasmInstance.exports.rotate as (\n width: number,\n height: number,\n degrees: number\n ) => void;\n\n // Ensure enough memory: need n*4*2 bytes (input + output) + some buffer\n const needed = n * 4 * 2 + 65536;\n while (memory.buffer.byteLength < needed) {\n memory.grow(1);\n }\n\n // Write input pixels at offset 0\n const uint32Input = new Uint32Array(\n data instanceof Uint8ClampedArray\n ? (data.buffer as ArrayBuffer)\n : (data.buffer as ArrayBuffer),\n data.byteOffset,\n n\n );\n new Uint32Array(memory.buffer).set(uint32Input, 0);\n\n // Execute rotation\n rotate(width, height, degrees);\n\n // Read output starting at offset n*4 (bytes)\n const outputData = new Uint8ClampedArray(\n memory.buffer.slice(n * 4, n * 4 + outW * outH * 4)\n );\n\n return { data: outputData, width: outW, height: outH };\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 request = data as WorkerRequest<{\n image: ImageInput;\n options?: RotateOptions;\n }>;\n const response: WorkerResponse<ImageInput> = { id: request.id, ok: false };\n\n try {\n if (request.type === 'rotate:run') {\n const result = await rotateClient(\n request.payload.image,\n request.payload.options\n );\n response.ok = true;\n response.data = result;\n self.postMessage(response);\n } else {\n response.error = `Unknown message type: ${request.type}`;\n self.postMessage(response);\n }\n } catch (error) {\n response.error = error instanceof Error ? error.message : String(error);\n self.postMessage(response);\n }\n };\n}\n"
12
12
  ],
13
- "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,I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EAoHA,IAAI,OAAO,SAAS,aAAa;AAAA,IAC/B,KAAK,YAAY,OAAO,UAAwB;AAAA,MAC9C,MAAM,OAAO,MAAM;AAAA,MAGnB,IAAI,MAAM,SAAS,eAAe;AAAA,QAChC,KAAK,YAAY,EAAE,MAAM,eAAe,CAAC;AAAA,QACzC;AAAA,MACF;AAAA,MAEA,MAAM,UAAU;AAAA,MAIhB,MAAM,WAAuC,EAAE,IAAI,QAAQ,IAAI,IAAI,MAAM;AAAA,MAEzE,IAAI;AAAA,QACF,IAAI,QAAQ,SAAS,cAAc;AAAA,UACjC,MAAM,SAAS,MAAM,aACnB,QAAQ,QAAQ,OAChB,QAAQ,QAAQ,OAClB;AAAA,UACA,SAAS,KAAK;AAAA,UACd,SAAS,OAAO;AAAA,UAChB,KAAK,YAAY,QAAQ;AAAA,QAC3B,EAAO;AAAA,UACL,SAAS,QAAQ,yBAAyB,QAAQ;AAAA,UAClD,KAAK,YAAY,QAAQ;AAAA;AAAA,QAE3B,OAAO,OAAO;AAAA,QACd,SAAS,QAAQ,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK;AAAA,QACtE,KAAK,YAAY,QAAQ;AAAA;AAAA;AAAA,EAG/B;AAAA;",
14
+ "debugId": "B4F0A2751EA9058864756E2164756E21",
15
15
  "names": []
16
16
  }
@@ -66,6 +66,54 @@ async function callWorker(worker, type, payload, signal, transfer) {
66
66
  var requestId = 0;
67
67
 
68
68
  // ../runtime/src/worker-helper.ts
69
+ function scriptUrlToPath(scriptUrl) {
70
+ const href = typeof scriptUrl === "string" ? scriptUrl : scriptUrl.href;
71
+ if (href.startsWith("file://")) {
72
+ return decodeURIComponent(href.startsWith("file:///") ? href.slice(7) : href.slice(5));
73
+ }
74
+ return href;
75
+ }
76
+ function workerScriptExists(scriptUrl) {
77
+ if (typeof window !== "undefined") {
78
+ return false;
79
+ }
80
+ const path = scriptUrlToPath(scriptUrl);
81
+ if (typeof Bun !== "undefined") {
82
+ return Bun.spawnSync(["test", "-f", path], {
83
+ stdout: "ignore",
84
+ stderr: "ignore"
85
+ }).exitCode === 0;
86
+ }
87
+ try {
88
+ const existsSync = Function('return require("node:fs").existsSync')();
89
+ return existsSync(path);
90
+ } catch {
91
+ return false;
92
+ }
93
+ }
94
+ function resolveServerWorkerScript(workerConfig, normalizedName) {
95
+ const platformExt = isBun() ? "bun.js" : "node.mjs";
96
+ const baseName = normalizedName.replace(".js", "");
97
+ const pkgName = workerConfig.package.split("/")[1];
98
+ if (typeof import.meta.resolve === "function") {
99
+ try {
100
+ const resolved = import.meta.resolve(`${workerConfig.package}/${workerConfig.specifier}`);
101
+ if (workerScriptExists(resolved)) {
102
+ return resolved;
103
+ }
104
+ } catch {}
105
+ }
106
+ const candidates = [
107
+ new URL(`../../${pkgName}/dist/${baseName}.${platformExt}`, import.meta.url),
108
+ new URL(`../../${pkgName}/src/${baseName}.ts`, import.meta.url)
109
+ ];
110
+ for (const candidate of candidates) {
111
+ if (workerScriptExists(candidate)) {
112
+ return candidate;
113
+ }
114
+ }
115
+ throw new Error(`Failed to resolve worker script for ${normalizedName}. ` + `Tried import.meta.resolve, dist output, and TypeScript source. ` + `Ensure ${workerConfig.package} is installed.`);
116
+ }
69
117
  function createCodecWorker(workerFilename, options) {
70
118
  const normalizedName = workerFilename.endsWith(".js") ? workerFilename : `${workerFilename}.js`;
71
119
  const workerMap = {
@@ -182,35 +230,8 @@ function createCodecWorker(workerFilename, options) {
182
230
  }
183
231
  throw new Error(`Could not resolve worker ${normalizedName} using any available path strategy`);
184
232
  }
185
- const platformExt = isBun() ? ".bun.js" : ".node.mjs";
186
- const baseName = normalizedName.replace(".js", "");
187
- const pkgName = workerConfig.package.split("/")[1];
188
- const srcRelPath = `../../${pkgName}/src/${baseName}.ts`;
189
- console.log("srcRelPath:", srcRelPath);
190
- console.log("import.meta.url:", import.meta.url);
191
- try {
192
- return new Worker(new URL(srcRelPath, import.meta.url), {
193
- type: "module"
194
- });
195
- } catch {
196
- const distRelPath = `../../${pkgName}/dist/${baseName}.${platformExt.slice(1)}`;
197
- console.log("distRelPath:", distRelPath);
198
- console.log("import.meta.url:", import.meta.url);
199
- try {
200
- return new Worker(new URL(distRelPath, import.meta.url), {
201
- type: "module"
202
- });
203
- } catch {
204
- if (typeof import.meta.resolve === "function") {
205
- try {
206
- const resolved = import.meta.resolve(`${workerConfig.package}/${workerConfig.specifier}`);
207
- console.log("resolved:", resolved);
208
- return new Worker(resolved, { type: "module" });
209
- } catch {}
210
- }
211
- }
212
- }
213
- 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.`);
233
+ const workerScript = resolveServerWorkerScript(workerConfig, normalizedName);
234
+ return new Worker(workerScript, { type: "module" });
214
235
  } catch (error) {
215
236
  const errorMessage = error instanceof Error ? error.message : String(error);
216
237
  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 });
@@ -426,4 +447,4 @@ export {
426
447
  rotateClient
427
448
  };
428
449
 
429
- //# debugId=F894B771458D07A164756E2164756E21
450
+ //# debugId=B6460515DC4EC8E164756E2164756E21
@@ -4,13 +4,13 @@
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 const DEFAULT_BROWSER_ASSET_PATH = '/squoosh-kit';\n\nexport type CreateWorkerOptions = {\n /**\n * Public URL prefix for worker and WASM files.\n * Defaults to `/squoosh-kit` in the browser (the path used by\n * `@squoosh-kit/vite-plugin`). Pass an empty string to resolve workers\n * relative to the installed package instead.\n */\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 browsers, workers load from `/squoosh-kit/{package}/` by default.\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 browsers, workers load from /squoosh-kit by default\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 const assetPath =\n options?.assetPath === undefined\n ? DEFAULT_BROWSER_ASSET_PATH\n : options.assetPath;\n\n if (assetPath) {\n let normalizedAssetPath = 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 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",
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 const DEFAULT_BROWSER_ASSET_PATH = '/squoosh-kit';\n\ntype WorkerPackageConfig = {\n package: string;\n specifier: string;\n};\n\nfunction scriptUrlToPath(scriptUrl: string | URL): string {\n const href = typeof scriptUrl === 'string' ? scriptUrl : scriptUrl.href;\n if (href.startsWith('file://')) {\n return decodeURIComponent(\n href.startsWith('file:///') ? href.slice(7) : href.slice(5)\n );\n }\n return href;\n}\n\nfunction workerScriptExists(scriptUrl: string | URL): boolean {\n if (typeof window !== 'undefined') {\n return false;\n }\n\n const path = scriptUrlToPath(scriptUrl);\n\n if (typeof Bun !== 'undefined') {\n return (\n Bun.spawnSync(['test', '-f', path], {\n stdout: 'ignore',\n stderr: 'ignore',\n }).exitCode === 0\n );\n }\n\n try {\n const existsSync = Function('return require(\"node:fs\").existsSync')() as (\n filePath: string\n ) => boolean;\n return existsSync(path);\n } catch {\n return false;\n }\n}\n\nexport function resolveServerWorkerScript(\n workerConfig: WorkerPackageConfig,\n normalizedName: string\n): string | URL {\n const platformExt = isBun() ? 'bun.js' : 'node.mjs';\n const baseName = normalizedName.replace('.js', '');\n const pkgName = workerConfig.package.split('/')[1];\n\n if (typeof import.meta.resolve === 'function') {\n try {\n const resolved = import.meta.resolve(\n `${workerConfig.package}/${workerConfig.specifier}`\n );\n if (workerScriptExists(resolved)) {\n return resolved;\n }\n } catch {\n // Continue to monorepo fallbacks\n }\n }\n\n const candidates = [\n new URL(\n `../../${pkgName}/dist/${baseName}.${platformExt}`,\n import.meta.url\n ),\n new URL(`../../${pkgName}/src/${baseName}.ts`, import.meta.url),\n ];\n\n for (const candidate of candidates) {\n if (workerScriptExists(candidate)) {\n return candidate;\n }\n }\n\n throw new Error(\n `Failed to resolve worker script for ${normalizedName}. ` +\n `Tried import.meta.resolve, dist output, and TypeScript source. ` +\n `Ensure ${workerConfig.package} is installed.`\n );\n}\n\nexport type CreateWorkerOptions = {\n /**\n * Public URL prefix for worker and WASM files.\n * Defaults to `/squoosh-kit` in the browser (the path used by\n * `@squoosh-kit/vite-plugin`). Pass an empty string to resolve workers\n * relative to the installed package instead.\n */\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 browsers, workers load from `/squoosh-kit/{package}/` by default.\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 browsers, workers load from /squoosh-kit by default\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 const assetPath =\n options?.assetPath === undefined\n ? DEFAULT_BROWSER_ASSET_PATH\n : options.assetPath;\n\n if (assetPath) {\n let normalizedAssetPath = 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 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 const workerScript = resolveServerWorkerScript(\n workerConfig,\n normalizedName\n );\n return new Worker(workerScript, { type: 'module' });\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
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
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
11
  "/**\n * Rotate processor - raw WASM instantiation (no JS glue)\n */\n\nimport { loadWasmBinary } from '@squoosh-kit/runtime';\nimport type {\n WorkerRequest,\n WorkerResponse,\n ImageInput,\n} from '@squoosh-kit/runtime';\nimport type { RotateOptions } from './types';\n\nlet wasmInstance: WebAssembly.Instance | null = null;\nlet initPromise: Promise<void> | null = null;\n\nasync function initRotate(): Promise<void> {\n if (wasmInstance) return;\n if (initPromise) return initPromise;\n\n initPromise = (async () => {\n try {\n const workerBaseUrl = new URL('.', import.meta.url);\n const isSource = import.meta.url.includes('/src/');\n const wasmPaths = isSource\n ? ['../wasm/rotate/rotate.wasm', './wasm/rotate/rotate.wasm']\n : ['./wasm/rotate/rotate.wasm', '../wasm/rotate/rotate.wasm'];\n\n let wasmBuffer: ArrayBuffer | null = null;\n let lastError: Error | null = null;\n for (const path of wasmPaths) {\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 if (!wasmBuffer) {\n throw lastError || new Error('Could not load rotate WASM');\n }\n\n const { instance } = await WebAssembly.instantiate(wasmBuffer);\n wasmInstance = instance;\n initPromise = null;\n } catch (error) {\n initPromise = null;\n throw new Error(\n `Failed to initialize rotate WASM module: ${error instanceof Error ? error.message : String(error)}`,\n { cause: error }\n );\n }\n })();\n\n return initPromise;\n}\n\nexport async function rotateClient(\n image: ImageInput,\n options?: RotateOptions,\n signal?: AbortSignal\n): Promise<ImageInput> {\n if (signal?.aborted) {\n throw new DOMException('Aborted', 'AbortError');\n }\n\n await initRotate();\n\n if (signal?.aborted) {\n throw new DOMException('Aborted', 'AbortError');\n }\n\n if (!wasmInstance) {\n throw new Error('Rotate module not initialized');\n }\n\n const degrees = options?.rotate ?? 0;\n const { data, width, height } = image;\n const n = width * height;\n\n // Calculate output dimensions\n const outW = degrees === 90 || degrees === 270 ? height : width;\n const outH = degrees === 90 || degrees === 270 ? width : height;\n\n const memory = wasmInstance.exports.memory as WebAssembly.Memory;\n const rotate = wasmInstance.exports.rotate as (\n width: number,\n height: number,\n degrees: number\n ) => void;\n\n // Ensure enough memory: need n*4*2 bytes (input + output) + some buffer\n const needed = n * 4 * 2 + 65536;\n while (memory.buffer.byteLength < needed) {\n memory.grow(1);\n }\n\n // Write input pixels at offset 0\n const uint32Input = new Uint32Array(\n data instanceof Uint8ClampedArray\n ? (data.buffer as ArrayBuffer)\n : (data.buffer as ArrayBuffer),\n data.byteOffset,\n n\n );\n new Uint32Array(memory.buffer).set(uint32Input, 0);\n\n // Execute rotation\n rotate(width, height, degrees);\n\n // Read output starting at offset n*4 (bytes)\n const outputData = new Uint8ClampedArray(\n memory.buffer.slice(n * 4, n * 4 + outW * outH * 4)\n );\n\n return { data: outputData, width: outW, height: outH };\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 request = data as WorkerRequest<{\n image: ImageInput;\n options?: RotateOptions;\n }>;\n const response: WorkerResponse<ImageInput> = { id: request.id, ok: false };\n\n try {\n if (request.type === 'rotate:run') {\n const result = await rotateClient(\n request.payload.image,\n request.payload.options\n );\n response.ok = true;\n response.data = result;\n self.postMessage(response);\n } else {\n response.error = `Unknown message type: ${request.type}`;\n self.postMessage(response);\n }\n } catch (error) {\n response.error = error instanceof Error ? error.message : String(error);\n self.postMessage(response);\n }\n };\n}\n"
12
12
  ],
13
- "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,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,SAAS,QAAQ,yBAAyB,QAAQ;AAAA,UAClD,KAAK,YAAY,QAAQ;AAAA;AAAA,QAE3B,OAAO,OAAO;AAAA,QACd,SAAS,QAAQ,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK;AAAA,QACtE,KAAK,YAAY,QAAQ;AAAA;AAAA;AAAA,EAG/B;AAAA;",
14
+ "debugId": "B6460515DC4EC8E164756E2164756E21",
15
15
  "names": []
16
16
  }
@@ -88,6 +88,54 @@ async function callWorker(worker, type, payload, signal, transfer) {
88
88
  var requestId = 0;
89
89
 
90
90
  // ../runtime/src/worker-helper.ts
91
+ function scriptUrlToPath(scriptUrl) {
92
+ const href = typeof scriptUrl === "string" ? scriptUrl : scriptUrl.href;
93
+ if (href.startsWith("file://")) {
94
+ return decodeURIComponent(href.startsWith("file:///") ? href.slice(7) : href.slice(5));
95
+ }
96
+ return href;
97
+ }
98
+ function workerScriptExists(scriptUrl) {
99
+ if (typeof window !== "undefined") {
100
+ return false;
101
+ }
102
+ const path = scriptUrlToPath(scriptUrl);
103
+ if (typeof Bun !== "undefined") {
104
+ return Bun.spawnSync(["test", "-f", path], {
105
+ stdout: "ignore",
106
+ stderr: "ignore"
107
+ }).exitCode === 0;
108
+ }
109
+ try {
110
+ const existsSync = Function('return require("node:fs").existsSync')();
111
+ return existsSync(path);
112
+ } catch {
113
+ return false;
114
+ }
115
+ }
116
+ function resolveServerWorkerScript(workerConfig, normalizedName) {
117
+ const platformExt = isBun() ? "bun.js" : "node.mjs";
118
+ const baseName = normalizedName.replace(".js", "");
119
+ const pkgName = workerConfig.package.split("/")[1];
120
+ if (typeof import.meta.resolve === "function") {
121
+ try {
122
+ const resolved = import.meta.resolve(`${workerConfig.package}/${workerConfig.specifier}`);
123
+ if (workerScriptExists(resolved)) {
124
+ return resolved;
125
+ }
126
+ } catch {}
127
+ }
128
+ const candidates = [
129
+ new URL(`../../${pkgName}/dist/${baseName}.${platformExt}`, "file:///home/runner/work/squoosh-kit/squoosh-kit/packages/runtime/src/worker-helper.ts"),
130
+ new URL(`../../${pkgName}/src/${baseName}.ts`, "file:///home/runner/work/squoosh-kit/squoosh-kit/packages/runtime/src/worker-helper.ts")
131
+ ];
132
+ for (const candidate of candidates) {
133
+ if (workerScriptExists(candidate)) {
134
+ return candidate;
135
+ }
136
+ }
137
+ throw new Error(`Failed to resolve worker script for ${normalizedName}. ` + `Tried import.meta.resolve, dist output, and TypeScript source. ` + `Ensure ${workerConfig.package} is installed.`);
138
+ }
91
139
  function createCodecWorker(workerFilename, options) {
92
140
  const normalizedName = workerFilename.endsWith(".js") ? workerFilename : `${workerFilename}.js`;
93
141
  const workerMap = {
@@ -204,35 +252,8 @@ function createCodecWorker(workerFilename, options) {
204
252
  }
205
253
  throw new Error(`Could not resolve worker ${normalizedName} using any available path strategy`);
206
254
  }
207
- const platformExt = isBun() ? ".bun.js" : ".node.mjs";
208
- const baseName = normalizedName.replace(".js", "");
209
- const pkgName = workerConfig.package.split("/")[1];
210
- const srcRelPath = `../../${pkgName}/src/${baseName}.ts`;
211
- console.log("srcRelPath:", srcRelPath);
212
- console.log("import.meta.url:", "file:///home/runner/work/squoosh-kit/squoosh-kit/packages/runtime/src/worker-helper.ts");
213
- try {
214
- return new Worker(new URL(srcRelPath, "file:///home/runner/work/squoosh-kit/squoosh-kit/packages/runtime/src/worker-helper.ts"), {
215
- type: "module"
216
- });
217
- } catch {
218
- const distRelPath = `../../${pkgName}/dist/${baseName}.${platformExt.slice(1)}`;
219
- console.log("distRelPath:", distRelPath);
220
- console.log("import.meta.url:", "file:///home/runner/work/squoosh-kit/squoosh-kit/packages/runtime/src/worker-helper.ts");
221
- try {
222
- return new Worker(new URL(distRelPath, "file:///home/runner/work/squoosh-kit/squoosh-kit/packages/runtime/src/worker-helper.ts"), {
223
- type: "module"
224
- });
225
- } catch {
226
- if (typeof import.meta.resolve === "function") {
227
- try {
228
- const resolved = import.meta.resolve(`${workerConfig.package}/${workerConfig.specifier}`);
229
- console.log("resolved:", resolved);
230
- return new Worker(resolved, { type: "module" });
231
- } catch {}
232
- }
233
- }
234
- }
235
- 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.`);
255
+ const workerScript = resolveServerWorkerScript(workerConfig, normalizedName);
256
+ return new Worker(workerScript, { type: "module" });
236
257
  } catch (error) {
237
258
  const errorMessage = error instanceof Error ? error.message : String(error);
238
259
  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 });
@@ -445,4 +466,4 @@ var init_rotate_worker = __esm(() => {
445
466
  });
446
467
  init_rotate_worker();
447
468
 
448
- //# debugId=085170AEBBDE18E764756E2164756E21
469
+ //# debugId=727F1505628BEC4764756E2164756E21