@squoosh-kit/resize 0.0.26 → 0.0.28
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.
- package/dist/bridge.browser.mjs +3 -3
- package/dist/bridge.browser.mjs.map +4 -4
- package/dist/bridge.bun.js +3 -3
- package/dist/bridge.bun.js.map +4 -4
- package/dist/bridge.d.ts +1 -1
- package/dist/bridge.d.ts.map +1 -1
- package/dist/bridge.node.cjs +2 -2
- package/dist/bridge.node.cjs.map +4 -4
- package/dist/bridge.node.mjs +3 -3
- package/dist/bridge.node.mjs.map +4 -4
- package/dist/chunk-5vdxd0v3.js +4 -0
- package/dist/chunk-5vdxd0v3.js.map +10 -0
- package/dist/chunk-8y42hv65.js +5 -0
- package/dist/chunk-8y42hv65.js.map +9 -0
- package/dist/chunk-bhj61bkd.js +4 -0
- package/dist/chunk-bhj61bkd.js.map +9 -0
- package/dist/chunk-c6cx0d7q.js +4 -0
- package/dist/chunk-c6cx0d7q.js.map +9 -0
- package/dist/chunk-gw29pvyv.js +3 -0
- package/dist/chunk-gw29pvyv.js.map +10 -0
- package/dist/chunk-q0apy7nk.js +5 -0
- package/dist/chunk-q0apy7nk.js.map +10 -0
- package/dist/chunk-szbj3b6y.js +4 -0
- package/dist/chunk-szbj3b6y.js.map +10 -0
- package/dist/index.browser.mjs +2 -2
- package/dist/index.browser.mjs.map +3 -3
- package/dist/index.bun.js +2 -2
- package/dist/index.bun.js.map +3 -3
- package/dist/index.d.ts +30 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.node.cjs +2 -2
- package/dist/index.node.cjs.map +3 -3
- package/dist/index.node.mjs +2 -2
- package/dist/index.node.mjs.map +3 -3
- package/dist/resize.worker.browser.mjs +2 -2
- package/dist/resize.worker.browser.mjs.map +4 -4
- package/dist/resize.worker.bun.js +2 -2
- package/dist/resize.worker.bun.js.map +4 -4
- package/dist/resize.worker.d.ts.map +1 -1
- package/dist/resize.worker.node.cjs +2 -2
- package/dist/resize.worker.node.cjs.map +4 -4
- package/dist/resize.worker.node.mjs +2 -2
- package/dist/resize.worker.node.mjs.map +4 -4
- package/dist/validators.browser.mjs +4 -0
- package/dist/validators.browser.mjs.map +10 -0
- package/dist/validators.bun.js +5 -0
- package/dist/validators.bun.js.map +10 -0
- package/dist/validators.d.ts +8 -0
- package/dist/validators.d.ts.map +1 -0
- package/dist/validators.node.cjs +3 -0
- package/dist/validators.node.cjs.map +10 -0
- package/dist/validators.node.mjs +4 -0
- package/dist/validators.node.mjs.map +10 -0
- package/package.json +2 -2
- package/dist/chunk-6qec3cgc.js +0 -5
- package/dist/chunk-6qec3cgc.js.map +0 -10
- package/dist/chunk-cg8pk3a2.js +0 -3
- package/dist/chunk-cg8pk3a2.js.map +0 -10
- package/dist/chunk-dfj7cgx8.js +0 -4
- package/dist/chunk-dfj7cgx8.js.map +0 -10
- package/dist/chunk-xrd0djzj.js +0 -4
- package/dist/chunk-xrd0djzj.js.map +0 -10
package/dist/bridge.node.mjs.map
CHANGED
|
@@ -4,10 +4,10 @@
|
|
|
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\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(workerFilename: string): 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 // 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 try {\n const workerUrl = new URL(relPath, import.meta.url);\n return new Worker(workerUrl, {\n type: 'module',\n });\n } catch (error) {\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 throw lastError;\n }\n throw new Error(\n `Could not resolve worker ${normalizedName} using any available path strategy`\n );\n }\n\n // Node.js/Bun: use import.meta.resolve if available\n if (typeof import.meta.resolve === 'function') {\n try {\n const resolved = import.meta.resolve(\n `${workerConfig.package}/${workerConfig.specifier}`\n );\n return new Worker(resolved, { type: 'module' });\n } catch {\n // Fallback if resolve fails - use relative path as last resort\n }\n }\n\n // Fallback for Bun: use relative path from this file's location\n const platformExt = isBun() ? '.bun.js' : '.node.mjs';\n const baseName = normalizedName.replace('.js', '');\n const relPath = workerConfig.package.includes('resize')\n ? `../../resize/dist/${baseName}.${platformExt.slice(1)}`\n : `../../webp/dist/${baseName}.${platformExt.slice(1)}`;\n\n return new Worker(new URL(relPath, import.meta.url), { 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 );\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 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);\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 resolve(worker);\n }\n };\n\n worker.addEventListener('message', handleMessage);\n worker.postMessage({ type: 'worker:ping' });\n });\n}\n",
|
|
8
|
-
"/**\n * Bridge implementation for the Resize package, handling worker and client modes.\n */\n\nimport {\n callWorker,\n createReadyWorker,\n type ImageInput,\n} from '@squoosh-kit/runtime';\nimport { validateImageInput } from '@squoosh-kit/runtime';\nimport type { ResizeOptions } from './types.ts';\n\ninterface ResizeBridge {\n resize(\n image: ImageInput,\n options: ResizeOptions,\n signal?: AbortSignal\n ): Promise<ImageInput>;\n terminate(): Promise<void>;\n}\n\nclass ResizeClientBridge implements ResizeBridge {\n async resize(\n image: ImageInput,\n options: ResizeOptions,\n signal?: AbortSignal\n ): Promise<ImageInput> {\n // Dynamically import the client resizer to avoid module loading issues in Vite\n const module = await import('./resize.worker.ts');\n const resizeClient = module.resizeClient as (\n image: ImageInput,\n options: ResizeOptions,\n signal?: AbortSignal\n ) => Promise<ImageInput>;\n return resizeClient(image, options, signal);\n }\n\n async terminate(): Promise<void> {\n // Client mode has nothing to terminate\n }\n}\n\nclass ResizeWorkerBridge implements ResizeBridge {\n private worker: Worker | null = null;\n private workerReady: Promise<Worker> | null = null;\n\n private async getWorker(): Promise<Worker> {\n if (!this.worker) {\n if (!this.workerReady) {\n this.workerReady = this.createWorker();\n }\n this.worker = await this.workerReady;\n }\n return this.worker;\n }\n\n private async createWorker(): Promise<Worker> {\n // Use the centralized worker helper for robust path resolution\n return createReadyWorker('resize.worker');\n }\n\n async resize(\n image: ImageInput,\n options: ResizeOptions,\n signal?: AbortSignal\n ): Promise<ImageInput> {\n const worker = await this.getWorker();\n\n validateImageInput(image);\n\n try {\n const result = await callWorker<\n { image: ImageInput; options: ResizeOptions },\n ImageInput\n >(worker, 'resize:run', { image, options }, signal);\n\n return result;\n } catch (error) {\n console.error('Resize error:', error);\n throw error;\n }\n }\n\n async terminate(): Promise<void> {\n if (this.worker) {\n this.worker.terminate();\n this.worker = null;\n this.workerReady = null;\n }\n }\n}\n\nexport function createBridge(mode: 'worker' | 'client'): ResizeBridge {\n return mode === 'client'\n ? new ResizeClientBridge()\n : new ResizeWorkerBridge();\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 * Smart auto-detection: Automatically detects the correct worker base URL\n * using meta tags, import.meta.url inference, and HEAD request probing.\n */\n\nimport { isBun } from './env';\n\n// Cache for detected worker base URL\n// undefined = not yet detected, null = detection failed, string = detected base\nlet detectedWorkerBase: string | null | undefined;\nlet detectionPromise: Promise<string | null> | null = null;\n\n/**\n * Auto-detect the correct base URL for squoosh-kit worker files\n * Uses multiple strategies: meta tag, import.meta.url inference, and HEAD requests\n */\nasync function detectWorkerBase(): Promise<string | null> {\n if (detectedWorkerBase !== undefined) {\n return detectedWorkerBase;\n }\n\n if (detectionPromise) {\n return detectionPromise;\n }\n\n detectionPromise = (async () => {\n // Only run in browser environment\n if (typeof window === 'undefined' || typeof document === 'undefined') {\n return (detectedWorkerBase = null);\n }\n\n // Strategy 1: Check for optional meta tag (for users with complex deploys)\n const metaTag = document.querySelector(\n 'meta[name=\"squoosh-base\"]'\n ) as HTMLMetaElement | null;\n if (metaTag?.content) {\n return (detectedWorkerBase = metaTag.content);\n }\n\n // Strategy 2: Look for Vite-bundled workers in assets directory FIRST\n // Vite bundles workers as separate chunks with hashes, e.g., resize.worker.browser-ABC123.js\n // This is the most common case for production Vite/React apps\n try {\n // Fetch the current HTML document to find script references\n const html = await fetch(window.location.href).then((r) => r.text());\n\n // Look for both resize and webp worker scripts in assets\n const workerPatterns = [\n {\n regex:\n /[\"']([^\"']*assets[^\"']*resize\\.worker\\.browser[^\"']*\\.js)[\"']/,\n package: 'resize',\n },\n {\n regex: /[\"']([^\"']*assets[^\"']*webp\\.worker\\.browser[^\"']*\\.js)[\"']/,\n package: 'webp',\n },\n ];\n\n for (const { regex, package: packageName } of workerPatterns) {\n const match = html.match(regex);\n if (match?.[1]) {\n const workerPath = match[1];\n // Cache the full hashed URL\n cacheHashedWorkerUrl(\n packageName,\n `${packageName}.worker.browser.mjs`,\n workerPath\n );\n // Return the base assets path for fallback\n const assetsBase = workerPath.substring(\n 0,\n workerPath.lastIndexOf('/') + 1\n );\n return (detectedWorkerBase = assetsBase);\n }\n }\n } catch {\n // Continue to next strategy\n }\n\n // Strategy 3: Infer from current script context (for npm-installed packages)\n try {\n // Try to detect if we're already in node_modules by checking import.meta.url\n const currentUrl = import.meta.url;\n const match = currentUrl.match(\n /^(.*\\/node_modules\\/@squoosh-kit\\/runtime\\/)/\n );\n if (match) {\n const base = match[1].replace('runtime/', '');\n return (detectedWorkerBase = base);\n }\n } catch {\n // Continue to next strategy\n }\n\n // Strategy 4: Try common CDN/deployment patterns with HEAD requests\n const testPatterns = [\n '/node_modules/@squoosh-kit/',\n '/@squoosh-kit/',\n window.location.origin + '/node_modules/@squoosh-kit/',\n ];\n\n for (const pattern of testPatterns) {\n try {\n // Test if the pattern is valid by checking if resize worker exists\n const testUrl = `${pattern}resize/dist/resize.worker.browser.mjs`;\n await fetch(testUrl, {\n method: 'HEAD',\n mode: 'no-cors',\n });\n // If fetch succeeds without error, pattern is valid\n return (detectedWorkerBase = pattern);\n } catch {\n // Continue to next pattern\n }\n }\n\n // No detection successful\n return (detectedWorkerBase = null);\n })();\n\n return detectionPromise;\n}\n\n/**\n * Manually trigger worker base URL detection\n * Useful for debugging or for apps that need explicit control over detection timing\n *\n * @returns Promise that resolves to the detected base URL (or null if detection fails)\n */\nexport async function initializeWorkerDetection(): Promise<string | null> {\n return detectWorkerBase();\n}\n\n// Cache for hashed worker URLs (for Vite-bundled apps)\nconst hashedWorkerUrls: Record<string, string> = {};\n\n/**\n * Build worker URL from detected base\n */\nfunction buildWorkerUrlFromBase(\n base: string,\n packageName: string,\n workerFile: string\n): string {\n // Check if we have a cached hashed URL for this worker\n const cacheKey = `${packageName}:${workerFile}`;\n if (hashedWorkerUrls[cacheKey]) {\n return hashedWorkerUrls[cacheKey];\n }\n\n // Ensure base ends with / and doesn't have leading @\n const normalizedBase = base.replace(/\\/$/, '') + '/';\n return `${normalizedBase}@squoosh-kit/${packageName}/dist/${workerFile}`;\n}\n\n/**\n * Cache a hashed worker URL (called during Vite assets detection)\n */\nfunction cacheHashedWorkerUrl(\n packageName: string,\n workerFile: string,\n hashedUrl: string\n): void {\n const cacheKey = `${packageName}:${workerFile}`;\n hashedWorkerUrls[cacheKey] = hashedUrl;\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 smart auto-detection with fallback to relative paths.\n *\n * @param workerFilename - The name of the worker file (e.g., 'resize.worker' or 'webp.worker')\n * @param customWorkerUrl - (Optional) Custom URL for the worker file. When provided, this takes precedence.\n * Useful for explicit URL configuration when auto-detection fails.\n * @returns Worker instance\n * @throws Error if worker creation fails with detailed error message\n */\nexport function createCodecWorker(\n workerFilename: string,\n customWorkerUrl?: string\n): Worker {\n // If a custom worker URL is provided, use it directly\n if (customWorkerUrl) {\n try {\n return new Worker(customWorkerUrl, { type: 'module' });\n } catch (error) {\n const errorMessage =\n error instanceof Error ? error.message : String(error);\n throw new Error(\n `Failed to create worker from custom URL ${customWorkerUrl}: ${errorMessage}`\n );\n }\n }\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, try smart auto-detection first, then fall back to relative paths\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 // If detection has already been attempted, use cached result\n const cachedBase =\n detectedWorkerBase !== undefined ? detectedWorkerBase : null;\n if (cachedBase) {\n try {\n const detectedUrl = buildWorkerUrlFromBase(\n cachedBase,\n packageName,\n workerFile\n );\n return new Worker(detectedUrl, { type: 'module' });\n } catch {\n // Fall through to relative paths\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 try {\n const workerUrl = new URL(relPath, import.meta.url);\n return new Worker(workerUrl, {\n type: 'module',\n });\n } catch (error) {\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 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 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 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 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 * Automatically triggers smart auto-detection of worker base URLs in browser environments.\n *\n * @param workerFilename - The name of the worker file\n * @param options - Configuration options for worker creation\n * @param options.customWorkerUrl - (Optional) Custom URL for the worker file\n * @param options.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?: { customWorkerUrl?: string; timeoutMs?: number } | number\n): Promise<Worker> {\n // Support both old API (timeoutMs as number) and new API (options object)\n let customWorkerUrl: string | undefined;\n let timeoutMs: number = 10000;\n\n if (typeof options === 'number') {\n timeoutMs = options;\n } else if (options) {\n customWorkerUrl = options.customWorkerUrl;\n timeoutMs = options.timeoutMs ?? 10000;\n }\n\n // Kick off auto-detection in the background (doesn't block)\n // This will cache the result for subsequent calls\n if (typeof window !== 'undefined' && detectedWorkerBase === undefined) {\n detectWorkerBase().catch(() => {\n // Silently fail detection - we'll fall back to relative paths\n });\n }\n\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, customWorkerUrl);\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 * Bridge implementation for the Resize package, handling worker and client modes.\n */\n\nimport {\n callWorker,\n createReadyWorker,\n type ImageInput,\n} from '@squoosh-kit/runtime';\nimport { validateImageInput } from '@squoosh-kit/runtime';\nimport type { ResizeOptions } from './types.ts';\n\ninterface ResizeBridge {\n resize(\n image: ImageInput,\n options: ResizeOptions,\n signal?: AbortSignal\n ): Promise<ImageInput>;\n terminate(): Promise<void>;\n}\n\nclass ResizeClientBridge implements ResizeBridge {\n async resize(\n image: ImageInput,\n options: ResizeOptions,\n signal?: AbortSignal\n ): Promise<ImageInput> {\n // Dynamically import the client resizer to avoid module loading issues in Vite\n const module = await import('./resize.worker.ts');\n const resizeClient = module.resizeClient as (\n image: ImageInput,\n options: ResizeOptions,\n signal?: AbortSignal\n ) => Promise<ImageInput>;\n return resizeClient(image, options, signal);\n }\n\n async terminate(): Promise<void> {\n // Client mode has nothing to terminate\n }\n}\n\nclass ResizeWorkerBridge implements ResizeBridge {\n private worker: Worker | null = null;\n private workerReady: Promise<Worker> | null = null;\n private customWorkerUrl: string | undefined;\n\n constructor(customWorkerUrl?: string) {\n this.customWorkerUrl = customWorkerUrl;\n }\n\n private async getWorker(): Promise<Worker> {\n if (!this.worker) {\n if (!this.workerReady) {\n this.workerReady = this.createWorker();\n }\n this.worker = await this.workerReady;\n }\n return this.worker;\n }\n\n private async createWorker(): Promise<Worker> {\n // Use the centralized worker helper for robust path resolution\n return createReadyWorker('resize.worker', {\n customWorkerUrl: this.customWorkerUrl,\n });\n }\n\n async resize(\n image: ImageInput,\n options: ResizeOptions,\n signal?: AbortSignal\n ): Promise<ImageInput> {\n const worker = await this.getWorker();\n\n validateImageInput(image);\n\n try {\n const result = await callWorker<\n { image: ImageInput; options: ResizeOptions },\n ImageInput\n >(worker, 'resize:run', { image, options }, signal);\n\n return result;\n } catch (error) {\n console.error('Resize error:', error);\n throw error;\n }\n }\n\n async terminate(): Promise<void> {\n if (this.worker) {\n this.worker.terminate();\n this.worker = null;\n this.workerReady = null;\n }\n }\n}\n\nexport function createBridge(\n mode: 'worker' | 'client',\n customWorkerUrl?: string\n): ResizeBridge {\n return mode === 'client'\n ? new ResizeClientBridge()\n : new ResizeWorkerBridge(customWorkerUrl);\n}\n"
|
|
9
9
|
],
|
|
10
|
-
"mappings": "
|
|
11
|
-
"debugId": "
|
|
10
|
+
"mappings": "6FAyBO,GAAS,CAAK,EAAY,CAC/B,OAAO,OAAO,IAAQ,ICTxB,IAAI,EAAY,EAYh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kB,CAC/B,GAAI,KAAK,OACP,KAAK,OAAO,UAAU,EACtB,KAAK,OAAS,KACd,KAAK,YAAc,KAGzB,CAEO,SAAS,CAAY,CAC1B,EACA,EACc,CACd,OAAO,IAAS,SACZ,IAAI,EACJ,IAAI,EAAmB,CAAe",
|
|
11
|
+
"debugId": "FBD243A330EB7A3B64756E2164756E21",
|
|
12
12
|
"names": []
|
|
13
13
|
}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import"./chunk-bhj61bkd.js";var{URL:J,URLSearchParams:X}=globalThis;function F(s){return typeof s==="string"}function K(s){return typeof s==="object"&&s!==null}function w(s){return s===null}function Y(s){return s==null}function m(){this.protocol=null,this.slashes=null,this.auth=null,this.host=null,this.port=null,this.hostname=null,this.hash=null,this.search=null,this.query=null,this.pathname=null,this.path=null,this.href=null}var S=/^([a-z0-9.+-]+:)/i,k=/:[0-9]*$/,H=/^(\/\/?(?!\/)[^\?\s]*)(\?[^\s]*)?$/,Q=["<",">",'"',"`"," ","\r",`
|
|
2
|
+
`,"\t"],E=["{","}","|","\\","^","`"].concat(Q),N=["'"].concat(E),M=["%","/","?",";","#"].concat(N),D=["/","?","#"],tt=255,G=/^[+a-z0-9A-Z_-]{0,63}$/,st=/^([+a-z0-9A-Z_-]{0,63})(.*)$/,ht={javascript:!0,"javascript:":!0},Z={javascript:!0,"javascript:":!0},R={http:!0,https:!0,ftp:!0,gopher:!0,file:!0,"http:":!0,"https:":!0,"ftp:":!0,"gopher:":!0,"file:":!0},B={parse(s){var o=decodeURIComponent;return(s+"").replace(/\+/g," ").split("&").filter(Boolean).reduce(function(t,n,a){var l=n.split("="),f=o(l[0]||""),h=o(l[1]||""),g=t[f];return t[f]=g===void 0?h:[].concat(g,h),t},{})},stringify(s){var o=encodeURIComponent;return Object.keys(s||{}).reduce(function(t,n){return[].concat(s[n]).forEach(function(a){t.push(o(n)+"="+o(a))}),t},[]).join("&").replace(/\s/g,"+")}};function I(s,o,t){if(s&&K(s)&&s instanceof m)return s;var n=new m;return n.parse(s,o,t),n}m.prototype.parse=function(s,o,t){if(!F(s))throw TypeError("Parameter 'url' must be a string, not "+typeof s);var n=s.indexOf("?"),a=n!==-1&&n<s.indexOf("#")?"?":"#",l=s.split(a),f=/\\/g;l[0]=l[0].replace(f,"/"),s=l.join(a);var h=s;if(h=h.trim(),!t&&s.split("#").length===1){var g=H.exec(h);if(g){if(this.path=h,this.href=h,this.pathname=g[1],g[2])if(this.search=g[2],o)this.query=B.parse(this.search.substr(1));else this.query=this.search.substr(1);else if(o)this.search="",this.query={};return this}}var p=S.exec(h);if(p){p=p[0];var A=p.toLowerCase();this.protocol=A,h=h.substr(p.length)}if(t||p||h.match(/^\/\/[^@\/]+@[^@\/]+/)){var C=h.substr(0,2)==="//";if(C&&!(p&&Z[p]))h=h.substr(2),this.slashes=!0}if(!Z[p]&&(C||p&&!R[p])){var c=-1;for(var r=0;r<D.length;r++){var b=h.indexOf(D[r]);if(b!==-1&&(c===-1||b<c))c=b}var P,u;if(c===-1)u=h.lastIndexOf("@");else u=h.lastIndexOf("@",c);if(u!==-1)P=h.slice(0,u),h=h.slice(u+1),this.auth=decodeURIComponent(P);c=-1;for(var r=0;r<M.length;r++){var b=h.indexOf(M[r]);if(b!==-1&&(c===-1||b<c))c=b}if(c===-1)c=h.length;this.host=h.slice(0,c),h=h.slice(c),this.parseHost(),this.hostname=this.hostname||"";var U=this.hostname[0]==="["&&this.hostname[this.hostname.length-1]==="]";if(!U){var e=this.hostname.split(/\./);for(var r=0,i=e.length;r<i;r++){var d=e[r];if(!d)continue;if(!d.match(G)){var y="";for(var O=0,L=d.length;O<L;O++)if(d.charCodeAt(O)>127)y+="x";else y+=d[O];if(!y.match(G)){var x=e.slice(0,r),q=e.slice(r+1),j=d.match(st);if(j)x.push(j[1]),q.unshift(j[2]);if(q.length)h="/"+q.join(".")+h;this.hostname=x.join(".");break}}}}if(this.hostname.length>tt)this.hostname="";else this.hostname=this.hostname.toLowerCase();if(!U)this.hostname=new J(`https://${this.hostname}`).hostname;var $=this.port?":"+this.port:"",V=this.hostname||"";if(this.host=V+$,this.href+=this.host,U){if(this.hostname=this.hostname.substr(1,this.hostname.length-2),h[0]!=="/")h="/"+h}}if(!ht[A])for(var r=0,i=N.length;r<i;r++){var v=N[r];if(h.indexOf(v)===-1)continue;var z=encodeURIComponent(v);if(z===v)z=escape(v);h=h.split(v).join(z)}var T=h.indexOf("#");if(T!==-1)this.hash=h.substr(T),h=h.slice(0,T);var _=h.indexOf("?");if(_!==-1){if(this.search=h.substr(_),this.query=h.substr(_+1),o)this.query=B.parse(this.query);h=h.slice(0,_)}else if(o)this.search="",this.query={};if(h)this.pathname=h;if(R[A]&&this.hostname&&!this.pathname)this.pathname="/";if(this.pathname||this.search){var $=this.pathname||"",W=this.search||"";this.path=$+W}return this.href=this.format(),this};function et(s){if(F(s))s=I(s);if(!(s instanceof m))return m.prototype.format.call(s);return s.format()}m.prototype.format=function(){var s=this.auth||"";if(s)s=encodeURIComponent(s),s=s.replace(/%3A/i,":"),s+="@";var o=this.protocol||"",t=this.pathname||"",n=this.hash||"",a=!1,l="";if(this.host)a=s+this.host;else if(this.hostname){if(a=s+(this.hostname.indexOf(":")===-1?this.hostname:"["+this.hostname+"]"),this.port)a+=":"+this.port}if(this.query&&K(this.query)&&Object.keys(this.query).length)l=B.stringify(this.query);var f=this.search||l&&"?"+l||"";if(o&&o.substr(-1)!==":")o+=":";if(this.slashes||(!o||R[o])&&a!==!1){if(a="//"+(a||""),t&&t.charAt(0)!=="/")t="/"+t}else if(!a)a="";if(n&&n.charAt(0)!=="#")n="#"+n;if(f&&f.charAt(0)!=="?")f="?"+f;return t=t.replace(/[?#]/g,function(h){return encodeURIComponent(h)}),f=f.replace("#","%23"),o+a+t+f+n};function ot(s,o){return I(s,!1,!0).resolve(o)}m.prototype.resolve=function(s){return this.resolveObject(I(s,!1,!0)).format()};function nt(s,o){if(!s)return o;return I(s,!1,!0).resolveObject(o)}m.prototype.resolveObject=function(s){if(F(s)){var o=new m;o.parse(s,!1,!0),s=o}var t=new m,n=Object.keys(this);for(var a=0;a<n.length;a++){var l=n[a];t[l]=this[l]}if(t.hash=s.hash,s.href==="")return t.href=t.format(),t;if(s.slashes&&!s.protocol){var f=Object.keys(s);for(var h=0;h<f.length;h++){var g=f[h];if(g!=="protocol")t[g]=s[g]}if(R[t.protocol]&&t.hostname&&!t.pathname)t.path=t.pathname="/";return t.href=t.format(),t}if(s.protocol&&s.protocol!==t.protocol){if(!R[s.protocol]){var p=Object.keys(s);for(var A=0;A<p.length;A++){var C=p[A];t[C]=s[C]}return t.href=t.format(),t}if(t.protocol=s.protocol,!s.host&&!Z[s.protocol]){var i=(s.pathname||"").split("/");while(i.length&&!(s.host=i.shift()));if(!s.host)s.host="";if(!s.hostname)s.hostname="";if(i[0]!=="")i.unshift("");if(i.length<2)i.unshift("");t.pathname=i.join("/")}else t.pathname=s.pathname;if(t.search=s.search,t.query=s.query,t.host=s.host||"",t.auth=s.auth,t.hostname=s.hostname||s.host,t.port=s.port,t.pathname||t.search){var c=t.pathname||"",r=t.search||"";t.path=c+r}return t.slashes=t.slashes||s.slashes,t.href=t.format(),t}var b=t.pathname&&t.pathname.charAt(0)==="/",P=s.host||s.pathname&&s.pathname.charAt(0)==="/",u=P||b||t.host&&s.pathname,U=u,e=t.pathname&&t.pathname.split("/")||[],i=s.pathname&&s.pathname.split("/")||[],d=t.protocol&&!R[t.protocol];if(d){if(t.hostname="",t.port=null,t.host)if(e[0]==="")e[0]=t.host;else e.unshift(t.host);if(t.host="",s.protocol){if(s.hostname=null,s.port=null,s.host)if(i[0]==="")i[0]=s.host;else i.unshift(s.host);s.host=null}u=u&&(i[0]===""||e[0]==="")}if(P)t.host=s.host||s.host===""?s.host:t.host,t.hostname=s.hostname||s.hostname===""?s.hostname:t.hostname,t.search=s.search,t.query=s.query,e=i;else if(i.length){if(!e)e=[];e.pop(),e=e.concat(i),t.search=s.search,t.query=s.query}else if(!Y(s.search)){if(d){t.hostname=t.host=e.shift();var y=t.host&&t.host.indexOf("@")>0?t.host.split("@"):!1;if(y)t.auth=y.shift(),t.host=t.hostname=y.shift()}if(t.search=s.search,t.query=s.query,!w(t.pathname)||!w(t.search))t.path=(t.pathname?t.pathname:"")+(t.search?t.search:"");return t.href=t.format(),t}if(!e.length){if(t.pathname=null,t.search)t.path="/"+t.search;else t.path=null;return t.href=t.format(),t}var O=e.slice(-1)[0],L=(t.host||s.host||e.length>1)&&(O==="."||O==="..")||O==="",x=0;for(var q=e.length;q>=0;q--)if(O=e[q],O===".")e.splice(q,1);else if(O==="..")e.splice(q,1),x++;else if(x)e.splice(q,1),x--;if(!u&&!U)for(;x--;x)e.unshift("..");if(u&&e[0]!==""&&(!e[0]||e[0].charAt(0)!=="/"))e.unshift("");if(L&&e.join("/").substr(-1)!=="/")e.push("");var j=e[0]===""||e[0]&&e[0].charAt(0)==="/";if(d){t.hostname=t.host=j?"":e.length?e.shift():"";var y=t.host&&t.host.indexOf("@")>0?t.host.split("@"):!1;if(y)t.auth=y.shift(),t.host=t.hostname=y.shift()}if(u=u||t.host&&e.length,u&&!j)e.unshift("");if(!e.length)t.pathname=null,t.path=null;else t.pathname=e.join("/");if(!w(t.pathname)||!w(t.search))t.path=(t.pathname?t.pathname:"")+(t.search?t.search:"");return t.auth=s.auth||t.auth,t.slashes=t.slashes||s.slashes,t.href=t.format(),t};m.prototype.parseHost=function(){var s=this.host,o=k.exec(s);if(o){if(o=o[0],o!==":")this.port=o.substr(1);s=s.substr(0,s.length-o.length)}if(s)this.hostname=s};var at={parse:I,resolve:ot,resolveObject:nt,format:et,Url:m,URL:J,URLSearchParams:X};export{nt as resolveObject,ot as resolve,I as parse,et as format,at as default,m as Url,X as URLSearchParams,J as URL};
|
|
3
|
+
|
|
4
|
+
//# debugId=A51CEBA1D864A1DF64756E2164756E21
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["node:url"],
|
|
4
|
+
"sourcesContent": [
|
|
5
|
+
"var{URL,URLSearchParams}=globalThis;function util_isString(arg){return typeof arg===\"string\"}function util_isObject(arg){return typeof arg===\"object\"&&arg!==null}function util_isNull(arg){return arg===null}function util_isNullOrUndefined(arg){return arg==null}function Url(){this.protocol=null,this.slashes=null,this.auth=null,this.host=null,this.port=null,this.hostname=null,this.hash=null,this.search=null,this.query=null,this.pathname=null,this.path=null,this.href=null}var protocolPattern=/^([a-z0-9.+-]+:)/i,portPattern=/:[0-9]*$/,simplePathPattern=/^(\\/\\/?(?!\\/)[^\\?\\s]*)(\\?[^\\s]*)?$/,delims=[\"<\",\">\",'\"',\"`\",\" \",\"\\r\",`\n`,\"\\t\"],unwise=[\"{\",\"}\",\"|\",\"\\\\\",\"^\",\"`\"].concat(delims),autoEscape=[\"'\"].concat(unwise),nonHostChars=[\"%\",\"/\",\"?\",\";\",\"#\"].concat(autoEscape),hostEndingChars=[\"/\",\"?\",\"#\"],hostnameMaxLen=255,hostnamePartPattern=/^[+a-z0-9A-Z_-]{0,63}$/,hostnamePartStart=/^([+a-z0-9A-Z_-]{0,63})(.*)$/,unsafeProtocol={javascript:!0,\"javascript:\":!0},hostlessProtocol={javascript:!0,\"javascript:\":!0},slashedProtocol={http:!0,https:!0,ftp:!0,gopher:!0,file:!0,\"http:\":!0,\"https:\":!0,\"ftp:\":!0,\"gopher:\":!0,\"file:\":!0},querystring={parse(str){var decode=decodeURIComponent;return(str+\"\").replace(/\\+/g,\" \").split(\"&\").filter(Boolean).reduce(function(obj,item,index){var ref=item.split(\"=\"),key=decode(ref[0]||\"\"),val=decode(ref[1]||\"\"),prev=obj[key];return obj[key]=prev===void 0?val:[].concat(prev,val),obj},{})},stringify(obj){var encode=encodeURIComponent;return Object.keys(obj||{}).reduce(function(arr,key){return[].concat(obj[key]).forEach(function(v){arr.push(encode(key)+\"=\"+encode(v))}),arr},[]).join(\"&\").replace(/\\s/g,\"+\")}};function urlParse(url,parseQueryString,slashesDenoteHost){if(url&&util_isObject(url)&&url instanceof Url)return url;var u=new Url;return u.parse(url,parseQueryString,slashesDenoteHost),u}Url.prototype.parse=function(url,parseQueryString,slashesDenoteHost){if(!util_isString(url))throw new TypeError(\"Parameter 'url' must be a string, not \"+typeof url);var queryIndex=url.indexOf(\"?\"),splitter=queryIndex!==-1&&queryIndex<url.indexOf(\"#\")?\"?\":\"#\",uSplit=url.split(splitter),slashRegex=/\\\\/g;uSplit[0]=uSplit[0].replace(slashRegex,\"/\"),url=uSplit.join(splitter);var rest=url;if(rest=rest.trim(),!slashesDenoteHost&&url.split(\"#\").length===1){var simplePath=simplePathPattern.exec(rest);if(simplePath){if(this.path=rest,this.href=rest,this.pathname=simplePath[1],simplePath[2])if(this.search=simplePath[2],parseQueryString)this.query=querystring.parse(this.search.substr(1));else this.query=this.search.substr(1);else if(parseQueryString)this.search=\"\",this.query={};return this}}var proto=protocolPattern.exec(rest);if(proto){proto=proto[0];var lowerProto=proto.toLowerCase();this.protocol=lowerProto,rest=rest.substr(proto.length)}if(slashesDenoteHost||proto||rest.match(/^\\/\\/[^@\\/]+@[^@\\/]+/)){var slashes=rest.substr(0,2)===\"//\";if(slashes&&!(proto&&hostlessProtocol[proto]))rest=rest.substr(2),this.slashes=!0}if(!hostlessProtocol[proto]&&(slashes||proto&&!slashedProtocol[proto])){var hostEnd=-1;for(var i=0;i<hostEndingChars.length;i++){var hec=rest.indexOf(hostEndingChars[i]);if(hec!==-1&&(hostEnd===-1||hec<hostEnd))hostEnd=hec}var auth,atSign;if(hostEnd===-1)atSign=rest.lastIndexOf(\"@\");else atSign=rest.lastIndexOf(\"@\",hostEnd);if(atSign!==-1)auth=rest.slice(0,atSign),rest=rest.slice(atSign+1),this.auth=decodeURIComponent(auth);hostEnd=-1;for(var i=0;i<nonHostChars.length;i++){var hec=rest.indexOf(nonHostChars[i]);if(hec!==-1&&(hostEnd===-1||hec<hostEnd))hostEnd=hec}if(hostEnd===-1)hostEnd=rest.length;this.host=rest.slice(0,hostEnd),rest=rest.slice(hostEnd),this.parseHost(),this.hostname=this.hostname||\"\";var ipv6Hostname=this.hostname[0]===\"[\"&&this.hostname[this.hostname.length-1]===\"]\";if(!ipv6Hostname){var hostparts=this.hostname.split(/\\./);for(var i=0,l=hostparts.length;i<l;i++){var part=hostparts[i];if(!part)continue;if(!part.match(hostnamePartPattern)){var newpart=\"\";for(var j=0,k=part.length;j<k;j++)if(part.charCodeAt(j)>127)newpart+=\"x\";else newpart+=part[j];if(!newpart.match(hostnamePartPattern)){var validParts=hostparts.slice(0,i),notHost=hostparts.slice(i+1),bit=part.match(hostnamePartStart);if(bit)validParts.push(bit[1]),notHost.unshift(bit[2]);if(notHost.length)rest=\"/\"+notHost.join(\".\")+rest;this.hostname=validParts.join(\".\");break}}}}if(this.hostname.length>hostnameMaxLen)this.hostname=\"\";else this.hostname=this.hostname.toLowerCase();if(!ipv6Hostname)this.hostname=new URL(`https://${this.hostname}`).hostname;var p=this.port?\":\"+this.port:\"\",h=this.hostname||\"\";if(this.host=h+p,this.href+=this.host,ipv6Hostname){if(this.hostname=this.hostname.substr(1,this.hostname.length-2),rest[0]!==\"/\")rest=\"/\"+rest}}if(!unsafeProtocol[lowerProto])for(var i=0,l=autoEscape.length;i<l;i++){var ae=autoEscape[i];if(rest.indexOf(ae)===-1)continue;var esc=encodeURIComponent(ae);if(esc===ae)esc=escape(ae);rest=rest.split(ae).join(esc)}var hash=rest.indexOf(\"#\");if(hash!==-1)this.hash=rest.substr(hash),rest=rest.slice(0,hash);var qm=rest.indexOf(\"?\");if(qm!==-1){if(this.search=rest.substr(qm),this.query=rest.substr(qm+1),parseQueryString)this.query=querystring.parse(this.query);rest=rest.slice(0,qm)}else if(parseQueryString)this.search=\"\",this.query={};if(rest)this.pathname=rest;if(slashedProtocol[lowerProto]&&this.hostname&&!this.pathname)this.pathname=\"/\";if(this.pathname||this.search){var p=this.pathname||\"\",s=this.search||\"\";this.path=p+s}return this.href=this.format(),this};function urlFormat(obj){if(util_isString(obj))obj=urlParse(obj);if(!(obj instanceof Url))return Url.prototype.format.call(obj);return obj.format()}Url.prototype.format=function(){var auth=this.auth||\"\";if(auth)auth=encodeURIComponent(auth),auth=auth.replace(/%3A/i,\":\"),auth+=\"@\";var protocol=this.protocol||\"\",pathname=this.pathname||\"\",hash=this.hash||\"\",host=!1,query=\"\";if(this.host)host=auth+this.host;else if(this.hostname){if(host=auth+(this.hostname.indexOf(\":\")===-1?this.hostname:\"[\"+this.hostname+\"]\"),this.port)host+=\":\"+this.port}if(this.query&&util_isObject(this.query)&&Object.keys(this.query).length)query=querystring.stringify(this.query);var search=this.search||query&&\"?\"+query||\"\";if(protocol&&protocol.substr(-1)!==\":\")protocol+=\":\";if(this.slashes||(!protocol||slashedProtocol[protocol])&&host!==!1){if(host=\"//\"+(host||\"\"),pathname&&pathname.charAt(0)!==\"/\")pathname=\"/\"+pathname}else if(!host)host=\"\";if(hash&&hash.charAt(0)!==\"#\")hash=\"#\"+hash;if(search&&search.charAt(0)!==\"?\")search=\"?\"+search;return pathname=pathname.replace(/[?#]/g,function(match){return encodeURIComponent(match)}),search=search.replace(\"#\",\"%23\"),protocol+host+pathname+search+hash};function urlResolve(source,relative){return urlParse(source,!1,!0).resolve(relative)}Url.prototype.resolve=function(relative){return this.resolveObject(urlParse(relative,!1,!0)).format()};function urlResolveObject(source,relative){if(!source)return relative;return urlParse(source,!1,!0).resolveObject(relative)}Url.prototype.resolveObject=function(relative){if(util_isString(relative)){var rel=new Url;rel.parse(relative,!1,!0),relative=rel}var result=new Url,tkeys=Object.keys(this);for(var tk=0;tk<tkeys.length;tk++){var tkey=tkeys[tk];result[tkey]=this[tkey]}if(result.hash=relative.hash,relative.href===\"\")return result.href=result.format(),result;if(relative.slashes&&!relative.protocol){var rkeys=Object.keys(relative);for(var rk=0;rk<rkeys.length;rk++){var rkey=rkeys[rk];if(rkey!==\"protocol\")result[rkey]=relative[rkey]}if(slashedProtocol[result.protocol]&&result.hostname&&!result.pathname)result.path=result.pathname=\"/\";return result.href=result.format(),result}if(relative.protocol&&relative.protocol!==result.protocol){if(!slashedProtocol[relative.protocol]){var keys=Object.keys(relative);for(var v=0;v<keys.length;v++){var k=keys[v];result[k]=relative[k]}return result.href=result.format(),result}if(result.protocol=relative.protocol,!relative.host&&!hostlessProtocol[relative.protocol]){var relPath=(relative.pathname||\"\").split(\"/\");while(relPath.length&&!(relative.host=relPath.shift()));if(!relative.host)relative.host=\"\";if(!relative.hostname)relative.hostname=\"\";if(relPath[0]!==\"\")relPath.unshift(\"\");if(relPath.length<2)relPath.unshift(\"\");result.pathname=relPath.join(\"/\")}else result.pathname=relative.pathname;if(result.search=relative.search,result.query=relative.query,result.host=relative.host||\"\",result.auth=relative.auth,result.hostname=relative.hostname||relative.host,result.port=relative.port,result.pathname||result.search){var p=result.pathname||\"\",s=result.search||\"\";result.path=p+s}return result.slashes=result.slashes||relative.slashes,result.href=result.format(),result}var isSourceAbs=result.pathname&&result.pathname.charAt(0)===\"/\",isRelAbs=relative.host||relative.pathname&&relative.pathname.charAt(0)===\"/\",mustEndAbs=isRelAbs||isSourceAbs||result.host&&relative.pathname,removeAllDots=mustEndAbs,srcPath=result.pathname&&result.pathname.split(\"/\")||[],relPath=relative.pathname&&relative.pathname.split(\"/\")||[],psychotic=result.protocol&&!slashedProtocol[result.protocol];if(psychotic){if(result.hostname=\"\",result.port=null,result.host)if(srcPath[0]===\"\")srcPath[0]=result.host;else srcPath.unshift(result.host);if(result.host=\"\",relative.protocol){if(relative.hostname=null,relative.port=null,relative.host)if(relPath[0]===\"\")relPath[0]=relative.host;else relPath.unshift(relative.host);relative.host=null}mustEndAbs=mustEndAbs&&(relPath[0]===\"\"||srcPath[0]===\"\")}if(isRelAbs)result.host=relative.host||relative.host===\"\"?relative.host:result.host,result.hostname=relative.hostname||relative.hostname===\"\"?relative.hostname:result.hostname,result.search=relative.search,result.query=relative.query,srcPath=relPath;else if(relPath.length){if(!srcPath)srcPath=[];srcPath.pop(),srcPath=srcPath.concat(relPath),result.search=relative.search,result.query=relative.query}else if(!util_isNullOrUndefined(relative.search)){if(psychotic){result.hostname=result.host=srcPath.shift();var authInHost=result.host&&result.host.indexOf(\"@\")>0?result.host.split(\"@\"):!1;if(authInHost)result.auth=authInHost.shift(),result.host=result.hostname=authInHost.shift()}if(result.search=relative.search,result.query=relative.query,!util_isNull(result.pathname)||!util_isNull(result.search))result.path=(result.pathname?result.pathname:\"\")+(result.search?result.search:\"\");return result.href=result.format(),result}if(!srcPath.length){if(result.pathname=null,result.search)result.path=\"/\"+result.search;else result.path=null;return result.href=result.format(),result}var last=srcPath.slice(-1)[0],hasTrailingSlash=(result.host||relative.host||srcPath.length>1)&&(last===\".\"||last===\"..\")||last===\"\",up=0;for(var i=srcPath.length;i>=0;i--)if(last=srcPath[i],last===\".\")srcPath.splice(i,1);else if(last===\"..\")srcPath.splice(i,1),up++;else if(up)srcPath.splice(i,1),up--;if(!mustEndAbs&&!removeAllDots)for(;up--;up)srcPath.unshift(\"..\");if(mustEndAbs&&srcPath[0]!==\"\"&&(!srcPath[0]||srcPath[0].charAt(0)!==\"/\"))srcPath.unshift(\"\");if(hasTrailingSlash&&srcPath.join(\"/\").substr(-1)!==\"/\")srcPath.push(\"\");var isAbsolute=srcPath[0]===\"\"||srcPath[0]&&srcPath[0].charAt(0)===\"/\";if(psychotic){result.hostname=result.host=isAbsolute?\"\":srcPath.length?srcPath.shift():\"\";var authInHost=result.host&&result.host.indexOf(\"@\")>0?result.host.split(\"@\"):!1;if(authInHost)result.auth=authInHost.shift(),result.host=result.hostname=authInHost.shift()}if(mustEndAbs=mustEndAbs||result.host&&srcPath.length,mustEndAbs&&!isAbsolute)srcPath.unshift(\"\");if(!srcPath.length)result.pathname=null,result.path=null;else result.pathname=srcPath.join(\"/\");if(!util_isNull(result.pathname)||!util_isNull(result.search))result.path=(result.pathname?result.pathname:\"\")+(result.search?result.search:\"\");return result.auth=relative.auth||result.auth,result.slashes=result.slashes||relative.slashes,result.href=result.format(),result};Url.prototype.parseHost=function(){var host=this.host,port=portPattern.exec(host);if(port){if(port=port[0],port!==\":\")this.port=port.substr(1);host=host.substr(0,host.length-port.length)}if(host)this.hostname=host};var url_default={parse:urlParse,resolve:urlResolve,resolveObject:urlResolveObject,format:urlFormat,Url,URL,URLSearchParams};export{urlResolveObject as resolveObject,urlResolve as resolve,urlParse as parse,urlFormat as format,url_default as default,Url,URLSearchParams,URL};"
|
|
6
|
+
],
|
|
7
|
+
"mappings": "4BAAA,IAAI,MAAI,mBAAiB,WAAW,SAAS,CAAa,CAAC,EAAI,CAAC,OAAO,OAAO,IAAM,SAAS,SAAS,CAAa,CAAC,EAAI,CAAC,OAAO,OAAO,IAAM,UAAU,IAAM,KAAK,SAAS,CAAW,CAAC,EAAI,CAAC,OAAO,IAAM,KAAK,SAAS,CAAsB,CAAC,EAAI,CAAC,OAAO,GAAK,KAAK,SAAS,CAAG,EAAE,CAAC,KAAK,SAAS,KAAK,KAAK,QAAQ,KAAK,KAAK,KAAK,KAAK,KAAK,KAAK,KAAK,KAAK,KAAK,KAAK,KAAK,SAAS,KAAK,KAAK,KAAK,KAAK,KAAK,OAAO,KAAK,KAAK,MAAM,KAAK,KAAK,SAAS,KAAK,KAAK,KAAK,KAAK,KAAK,KAAK,KAAK,IAAI,EAAgB,oBAAoB,EAAY,WAAW,EAAkB,qCAAqC,EAAO,CAAC,IAAI,IAAI,IAAI,IAAI,IAAI,KAAK;AAAA,EAC9mB,IAAI,EAAE,EAAO,CAAC,IAAI,IAAI,IAAI,KAAK,IAAI,GAAG,EAAE,OAAO,CAAM,EAAE,EAAW,CAAC,GAAG,EAAE,OAAO,CAAM,EAAE,EAAa,CAAC,IAAI,IAAI,IAAI,IAAI,GAAG,EAAE,OAAO,CAAU,EAAE,EAAgB,CAAC,IAAI,IAAI,GAAG,EAAE,GAAe,IAAI,EAAoB,yBAAyB,GAAkB,+BAA+B,GAAe,CAAC,WAAW,GAAG,cAAc,EAAE,EAAE,EAAiB,CAAC,WAAW,GAAG,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||!a.__esModule?e(b,"default",{value:a,enumerable:!0}):b;for(let d of i(a))if(!j.call(c,d))e(c,d,{get:()=>a[d],enumerable:!0});return c};var l=import.meta.require;
|
|
3
|
+
export{k as d,l as e};
|
|
4
|
+
|
|
5
|
+
//# debugId=A9A34199A0D9BFB964756E2164756E21
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
var g=Object.create;var{getPrototypeOf:h,defineProperty:f,getOwnPropertyNames:i}=Object;var j=Object.prototype.hasOwnProperty;var k=(a,c,b)=>{b=a!=null?g(h(a)):{};let d=c||!a||!a.__esModule?f(b,"default",{value:a,enumerable:!0}):b;for(let e of i(a))if(!j.call(d,e))f(d,e,{get:()=>a[e],enumerable:!0});return d};var l=((a)=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(a,{get:(c,b)=>(typeof require<"u"?require:c)[b]}):a)(function(a){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+a+'" is not supported')});
|
|
2
|
+
export{k as d,l as e};
|
|
3
|
+
|
|
4
|
+
//# debugId=DD012EC9AF92EB4264756E2164756E21
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import{createRequire as k}from"node:module";var g=Object.create;var{getPrototypeOf:h,defineProperty:e,getOwnPropertyNames:i}=Object;var j=Object.prototype.hasOwnProperty;var l=(a,f,b)=>{b=a!=null?g(h(a)):{};let c=f||!a||!a.__esModule?e(b,"default",{value:a,enumerable:!0}):b;for(let d of i(a))if(!j.call(c,d))e(c,d,{get:()=>a[d],enumerable:!0});return c};var n=k(import.meta.url);
|
|
2
|
+
export{l as d,n as e};
|
|
3
|
+
|
|
4
|
+
//# debugId=F652FC5CA4201BB864756E2164756E21
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
function H(F){if(!F||typeof F!=="object")throw TypeError("image must be an object");let D=F;if(!("data"in D))throw TypeError("image.data is required");let{data:E}=D;if(!(E instanceof Uint8Array||E instanceof Uint8ClampedArray))throw TypeError("image.data must be Uint8Array or Uint8ClampedArray");if(!("width"in D)||!("height"in D))throw TypeError("image.width and image.height are required");let{width:l,height:q}=D;if(typeof l!=="number"||!Number.isInteger(l)||l<=0)throw RangeError(`image.width must be a positive integer, got ${l}`);if(typeof q!=="number"||!Number.isInteger(q)||q<=0)throw RangeError(`image.height must be a positive integer, got ${q}`);let G=l*q*4;if(E.length<G)throw RangeError(`image.data too small: ${E.length} bytes, expected at least ${G} bytes for ${l}x${q} RGBA image`)}
|
|
2
|
+
|
|
3
|
+
//# debugId=09889CC44937212964756E2164756E21
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../runtime/src/validators.ts"],
|
|
4
|
+
"sourcesContent": [
|
|
5
|
+
"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"
|
|
6
|
+
],
|
|
7
|
+
"mappings": "AAqBO,SAAS,CAAkB,CAChC,EAC6B,CAC7B,GAAI,CAAC,GAAS,OAAO,IAAU,SAC7B,MAAU,UAAU,yBAAyB,EAG/C,IAAM,EAAW,EAEjB,GAAI,EAAE,SAAU,GACd,MAAU,UAAU,wBAAwB,EAG9C,IAAQ,QAAS,EACjB,GAAI,EAAE,aAAgB,YAAc,aAAgB,mBAClD,MAAU,UAAU,oDAAoD,EAG1E,GAAI,EAAE,UAAW,IAAa,EAAE,WAAY,GAC1C,MAAU,UAAU,2CAA2C,EAGjE,IAAQ,QAAO,UAAW,EAE1B,GAAI,OAAO,IAAU,UAAY,CAAC,OAAO,UAAU,CAAK,GAAK,GAAS,EACpE,MAAU,WACR,+CAA+C,GACjD,EAGF,GAAI,OAAO,IAAW,UAAY,CAAC,OAAO,UAAU,CAAM,GAAK,GAAU,EACvE,MAAU,WACR,gDAAgD,GAClD,EAGF,IAAM,EAAe,EAAQ,EAAS,EACtC,GAAI,EAAK,OAAS,EAChB,MAAU,WACR,yBAAyB,EAAK,mCAAmC,eAA0B,KAAS,cACtG",
|
|
8
|
+
"debugId": "09889CC44937212964756E2164756E21",
|
|
9
|
+
"names": []
|
|
10
|
+
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
function H(F){if(!F||typeof F!=="object")throw TypeError("image must be an object");let D=F;if(!("data"in D))throw TypeError("image.data is required");let{data:E}=D;if(!(E instanceof Uint8Array||E instanceof Uint8ClampedArray))throw TypeError("image.data must be Uint8Array or Uint8ClampedArray");if(!("width"in D)||!("height"in D))throw TypeError("image.width and image.height are required");let{width:l,height:q}=D;if(typeof l!=="number"||!Number.isInteger(l)||l<=0)throw RangeError(`image.width must be a positive integer, got ${l}`);if(typeof q!=="number"||!Number.isInteger(q)||q<=0)throw RangeError(`image.height must be a positive integer, got ${q}`);let G=l*q*4;if(E.length<G)throw RangeError(`image.data too small: ${E.length} bytes, expected at least ${G} bytes for ${l}x${q} RGBA image`)}
|
|
3
|
+
export{H as b};
|
|
4
|
+
|
|
5
|
+
//# debugId=7AE3A24486B7640E64756E2164756E21
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../runtime/src/validators.ts"],
|
|
4
|
+
"sourcesContent": [
|
|
5
|
+
"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"
|
|
6
|
+
],
|
|
7
|
+
"mappings": ";AAqBO,SAAS,CAAkB,CAChC,EAC6B,CAC7B,GAAI,CAAC,GAAS,OAAO,IAAU,SAC7B,MAAU,UAAU,yBAAyB,EAG/C,IAAM,EAAW,EAEjB,GAAI,EAAE,SAAU,GACd,MAAU,UAAU,wBAAwB,EAG9C,IAAQ,QAAS,EACjB,GAAI,EAAE,aAAgB,YAAc,aAAgB,mBAClD,MAAU,UAAU,oDAAoD,EAG1E,GAAI,EAAE,UAAW,IAAa,EAAE,WAAY,GAC1C,MAAU,UAAU,2CAA2C,EAGjE,IAAQ,QAAO,UAAW,EAE1B,GAAI,OAAO,IAAU,UAAY,CAAC,OAAO,UAAU,CAAK,GAAK,GAAS,EACpE,MAAU,WACR,+CAA+C,GACjD,EAGF,GAAI,OAAO,IAAW,UAAY,CAAC,OAAO,UAAU,CAAM,GAAK,GAAU,EACvE,MAAU,WACR,gDAAgD,GAClD,EAGF,IAAM,EAAe,EAAQ,EAAS,EACtC,GAAI,EAAK,OAAS,EAChB,MAAU,WACR,yBAAyB,EAAK,mCAAmC,eAA0B,KAAS,cACtG",
|
|
8
|
+
"debugId": "7AE3A24486B7640E64756E2164756E21",
|
|
9
|
+
"names": []
|
|
10
|
+
}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
function H(F){if(!F||typeof F!=="object")throw TypeError("image must be an object");let D=F;if(!("data"in D))throw TypeError("image.data is required");let{data:E}=D;if(!(E instanceof Uint8Array||E instanceof Uint8ClampedArray))throw TypeError("image.data must be Uint8Array or Uint8ClampedArray");if(!("width"in D)||!("height"in D))throw TypeError("image.width and image.height are required");let{width:l,height:q}=D;if(typeof l!=="number"||!Number.isInteger(l)||l<=0)throw RangeError(`image.width must be a positive integer, got ${l}`);if(typeof q!=="number"||!Number.isInteger(q)||q<=0)throw RangeError(`image.height must be a positive integer, got ${q}`);let G=l*q*4;if(E.length<G)throw RangeError(`image.data too small: ${E.length} bytes, expected at least ${G} bytes for ${l}x${q} RGBA image`)}
|
|
2
|
+
export{H as b};
|
|
3
|
+
|
|
4
|
+
//# debugId=BE7FDBD72E428B8E64756E2164756E21
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../runtime/src/validators.ts"],
|
|
4
|
+
"sourcesContent": [
|
|
5
|
+
"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"
|
|
6
|
+
],
|
|
7
|
+
"mappings": "AAqBO,SAAS,CAAkB,CAChC,EAC6B,CAC7B,GAAI,CAAC,GAAS,OAAO,IAAU,SAC7B,MAAU,UAAU,yBAAyB,EAG/C,IAAM,EAAW,EAEjB,GAAI,EAAE,SAAU,GACd,MAAU,UAAU,wBAAwB,EAG9C,IAAQ,QAAS,EACjB,GAAI,EAAE,aAAgB,YAAc,aAAgB,mBAClD,MAAU,UAAU,oDAAoD,EAG1E,GAAI,EAAE,UAAW,IAAa,EAAE,WAAY,GAC1C,MAAU,UAAU,2CAA2C,EAGjE,IAAQ,QAAO,UAAW,EAE1B,GAAI,OAAO,IAAU,UAAY,CAAC,OAAO,UAAU,CAAK,GAAK,GAAS,EACpE,MAAU,WACR,+CAA+C,GACjD,EAGF,GAAI,OAAO,IAAW,UAAY,CAAC,OAAO,UAAU,CAAM,GAAK,GAAU,EACvE,MAAU,WACR,gDAAgD,GAClD,EAGF,IAAM,EAAe,EAAQ,EAAS,EACtC,GAAI,EAAK,OAAS,EAChB,MAAU,WACR,yBAAyB,EAAK,mCAAmC,eAA0B,KAAS,cACtG",
|
|
8
|
+
"debugId": "BE7FDBD72E428B8E64756E2164756E21",
|
|
9
|
+
"names": []
|
|
10
|
+
}
|
package/dist/index.browser.mjs
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import{a as
|
|
1
|
+
import{a as G}from"./bridge.browser.mjs";import"./chunk-szbj3b6y.js";import"./chunk-bhj61bkd.js";var E=null,H;function P(v){H=v,E=null}async function Q(v,F,y){if(!E)E=G("worker",H);return E.resize(v,F,y)}function X(v="worker",F){let y=G(v,F);return Object.assign((J,K,M)=>{return y.resize(J,K,M)},{terminate:async()=>{await y.terminate()}})}export{Q as resize,X as createResizer,P as configureResizeWorker};
|
|
2
2
|
|
|
3
|
-
//# debugId=
|
|
3
|
+
//# debugId=A8CB0914A9ED894564756E2164756E21
|
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../src/index.ts"],
|
|
4
4
|
"sourcesContent": [
|
|
5
|
-
"/**\n * @squoosh-kit/resize public API\n */\n\nimport type { ImageInput } from '@squoosh-kit/runtime';\nimport { createBridge } from './bridge';\nimport type { ResizeOptions } from './types';\n\nexport type { ImageInput, ResizeOptions };\n\n// Global bridge instance for reuse\nlet globalClientBridge: ReturnType<typeof createBridge> | null = null;\n\n/**\n * A resizable image processor that can be reused for multiple operations.\n * Can be terminated to clean up associated resources (especially workers).\n */\nexport type ResizerFactory = ((\n imageData: ImageInput,\n options: ResizeOptions,\n signal?: AbortSignal\n) => Promise<ImageInput>) & {\n /**\n * Terminates the resizer and cleans up resources.\n * Important for worker mode to prevent memory leaks.\n *\n * @example\n * const resizer = createResizer('worker');\n * try {\n * const result = await resizer(imageData, options);\n * } finally {\n * await resizer.terminate();\n * }\n */\n terminate(): Promise<void>;\n};\n\n/**\n * Resizes an image. Uses worker mode for UI responsiveness.\n *\n * @param imageData - The image data to resize.\n * @param options - Resize options.\n * @param signal - (Optional) AbortSignal to cancel the resizing operation.\n * If provided, you can cancel the operation by calling\n * `controller.abort()` on the associated AbortController.\n * If not provided, the operation cannot be cancelled.\n * @returns A Promise resolving to the resized image data.\n *\n * @example\n * // With cancellation support\n * const controller = new AbortController();\n * const result = await resize(imageData, { width: 800 }, controller.signal);\n * setTimeout(() => controller.abort(), 5000);\n *\n * @example\n * // Without cancellation (operation cannot be stopped)\n * const result = await resize(imageData, { width: 800 });\n */\nexport async function resize(\n imageData: ImageInput,\n options: ResizeOptions,\n signal?: AbortSignal\n): Promise<ImageInput> {\n // Use worker mode for UI responsiveness - prevents blocking the main thread\n if (!globalClientBridge) {\n globalClientBridge = createBridge('worker');\n }\n\n return globalClientBridge.resize(imageData, options, signal);\n}\n\n/**\n * Creates a reusable resizer function for a specific execution mode.\n *\n * @param mode - The execution mode, either 'worker' or 'client'.\n * @returns A function that resizes an image with optional AbortSignal.\n */\nexport function createResizer(\n mode: 'worker' | 'client' = 'worker'\n): ResizerFactory {\n const bridge = createBridge(mode);\n\n return Object.assign(\n (imageData: ImageInput, options: ResizeOptions, signal?: AbortSignal) => {\n return bridge.resize(imageData, options, signal);\n },\n {\n terminate: async () => {\n await bridge.terminate();\n },\n }\n );\n}\n"
|
|
5
|
+
"/**\n * @squoosh-kit/resize public API\n */\n\nimport type { ImageInput } from '@squoosh-kit/runtime';\nimport { createBridge } from './bridge';\nimport type { ResizeOptions } from './types';\n\nexport type { ImageInput, ResizeOptions };\n\n// Global bridge instance for reuse\nlet globalClientBridge: ReturnType<typeof createBridge> | null = null;\nlet globalCustomWorkerUrl: string | undefined;\n\n/**\n * A resizable image processor that can be reused for multiple operations.\n * Can be terminated to clean up associated resources (especially workers).\n */\nexport type ResizerFactory = ((\n imageData: ImageInput,\n options: ResizeOptions,\n signal?: AbortSignal\n) => Promise<ImageInput>) & {\n /**\n * Terminates the resizer and cleans up resources.\n * Important for worker mode to prevent memory leaks.\n *\n * @example\n * const resizer = createResizer('worker');\n * try {\n * const result = await resizer(imageData, options);\n * } finally {\n * await resizer.terminate();\n * }\n */\n terminate(): Promise<void>;\n};\n\n/**\n * Configure the global resize worker URL. Call this before using the resize function\n * in environments like Vite where the worker path needs to be explicitly resolved.\n *\n * @param workerUrl - The absolute URL to the resize worker file.\n * In Vite apps, use: new URL('@squoosh-kit/resize/dist/resize.worker.browser.mjs', import.meta.url).href\n *\n * @example\n * import { configureResizeWorker, resize } from '@squoosh-kit/resize';\n *\n * // In your Vite app initialization:\n * configureResizeWorker(\n * new URL('@squoosh-kit/resize/dist/resize.worker.browser.mjs', import.meta.url).href\n * );\n *\n * // Then use resize normally:\n * const result = await resize(imageData, { width: 800 });\n */\nexport function configureResizeWorker(workerUrl: string): void {\n globalCustomWorkerUrl = workerUrl;\n // Reset the bridge so it uses the new worker URL on next call\n globalClientBridge = null;\n}\n\n/**\n * Resizes an image. Uses worker mode for UI responsiveness.\n *\n * @param imageData - The image data to resize.\n * @param options - Resize options.\n * @param signal - (Optional) AbortSignal to cancel the resizing operation.\n * If provided, you can cancel the operation by calling\n * `controller.abort()` on the associated AbortController.\n * If not provided, the operation cannot be cancelled.\n * @returns A Promise resolving to the resized image data.\n *\n * @example\n * // With cancellation support\n * const controller = new AbortController();\n * const result = await resize(imageData, { width: 800 }, controller.signal);\n * setTimeout(() => controller.abort(), 5000);\n *\n * @example\n * // Without cancellation (operation cannot be stopped)\n * const result = await resize(imageData, { width: 800 });\n */\nexport async function resize(\n imageData: ImageInput,\n options: ResizeOptions,\n signal?: AbortSignal\n): Promise<ImageInput> {\n // Use worker mode for UI responsiveness - prevents blocking the main thread\n if (!globalClientBridge) {\n globalClientBridge = createBridge('worker', globalCustomWorkerUrl);\n }\n\n return globalClientBridge.resize(imageData, options, signal);\n}\n\n/**\n * Creates a reusable resizer function for a specific execution mode.\n *\n * @param mode - The execution mode, either 'worker' or 'client'.\n * @param customWorkerUrl - (Optional) Custom URL for the worker file in 'worker' mode.\n * @returns A function that resizes an image with optional AbortSignal.\n *\n * @example\n * // In a Vite app with custom worker URL:\n * const resizer = createResizer(\n * 'worker',\n * new URL('@squoosh-kit/resize/dist/resize.worker.browser.mjs', import.meta.url).href\n * );\n * const result = await resizer(imageData, { width: 800 });\n * await resizer.terminate();\n */\nexport function createResizer(\n mode: 'worker' | 'client' = 'worker',\n customWorkerUrl?: string\n): ResizerFactory {\n const bridge = createBridge(mode, customWorkerUrl);\n\n return Object.assign(\n (imageData: ImageInput, options: ResizeOptions, signal?: AbortSignal) => {\n return bridge.resize(imageData, options, signal);\n },\n {\n terminate: async () => {\n await bridge.terminate();\n },\n }\n );\n}\n"
|
|
6
6
|
],
|
|
7
|
-
"mappings": "
|
|
8
|
-
"debugId": "
|
|
7
|
+
"mappings": "6GAWA,FAAI,JAA6D,KAC7D,EA4CG,SAAS,CAAqB,CAAC,EAAyB,CAC7D,EAAwB,EAExB,EAAqB,KAwBvB,eAAsB,CAAM,CAC1B,EACA,EACA,EACqB,CAErB,GAAI,CAAC,EACH,EAAqB,EAAa,SAAU,CAAqB,EAGnE,OAAO,EAAmB,OAAO,EAAW,EAAS,CAAM,EAmBtD,SAAS,CAAa,CAC3B,EAA4B,SAC5B,EACgB,CAChB,IAAM,EAAS,EAAa,EAAM,CAAe,EAEjD,OAAO,OAAO,OACZ,CAAC,EAAuB,EAAwB,IAAyB,CACvE,OAAO,EAAO,OAAO,EAAW,EAAS,CAAM,GAEjD,CACE,UAAW,SAAY,CACrB,MAAM,EAAO,UAAU,EAE3B,CACF",
|
|
8
|
+
"debugId": "A8CB0914A9ED894564756E2164756E21",
|
|
9
9
|
"names": []
|
|
10
10
|
}
|
package/dist/index.bun.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{a as
|
|
2
|
+
import{a as G}from"./bridge.bun.js";import"./chunk-q0apy7nk.js";import"./chunk-8y42hv65.js";var E=null,H;function P(v){H=v,E=null}async function Q(v,F,y){if(!E)E=G("worker",H);return E.resize(v,F,y)}function X(v="worker",F){let y=G(v,F);return Object.assign((J,K,M)=>{return y.resize(J,K,M)},{terminate:async()=>{await y.terminate()}})}export{Q as resize,X as createResizer,P as configureResizeWorker};
|
|
3
3
|
|
|
4
|
-
//# debugId=
|
|
4
|
+
//# debugId=45B78DB4C08FB64364756E2164756E21
|
package/dist/index.bun.js.map
CHANGED
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../src/index.ts"],
|
|
4
4
|
"sourcesContent": [
|
|
5
|
-
"/**\n * @squoosh-kit/resize public API\n */\n\nimport type { ImageInput } from '@squoosh-kit/runtime';\nimport { createBridge } from './bridge';\nimport type { ResizeOptions } from './types';\n\nexport type { ImageInput, ResizeOptions };\n\n// Global bridge instance for reuse\nlet globalClientBridge: ReturnType<typeof createBridge> | null = null;\n\n/**\n * A resizable image processor that can be reused for multiple operations.\n * Can be terminated to clean up associated resources (especially workers).\n */\nexport type ResizerFactory = ((\n imageData: ImageInput,\n options: ResizeOptions,\n signal?: AbortSignal\n) => Promise<ImageInput>) & {\n /**\n * Terminates the resizer and cleans up resources.\n * Important for worker mode to prevent memory leaks.\n *\n * @example\n * const resizer = createResizer('worker');\n * try {\n * const result = await resizer(imageData, options);\n * } finally {\n * await resizer.terminate();\n * }\n */\n terminate(): Promise<void>;\n};\n\n/**\n * Resizes an image. Uses worker mode for UI responsiveness.\n *\n * @param imageData - The image data to resize.\n * @param options - Resize options.\n * @param signal - (Optional) AbortSignal to cancel the resizing operation.\n * If provided, you can cancel the operation by calling\n * `controller.abort()` on the associated AbortController.\n * If not provided, the operation cannot be cancelled.\n * @returns A Promise resolving to the resized image data.\n *\n * @example\n * // With cancellation support\n * const controller = new AbortController();\n * const result = await resize(imageData, { width: 800 }, controller.signal);\n * setTimeout(() => controller.abort(), 5000);\n *\n * @example\n * // Without cancellation (operation cannot be stopped)\n * const result = await resize(imageData, { width: 800 });\n */\nexport async function resize(\n imageData: ImageInput,\n options: ResizeOptions,\n signal?: AbortSignal\n): Promise<ImageInput> {\n // Use worker mode for UI responsiveness - prevents blocking the main thread\n if (!globalClientBridge) {\n globalClientBridge = createBridge('worker');\n }\n\n return globalClientBridge.resize(imageData, options, signal);\n}\n\n/**\n * Creates a reusable resizer function for a specific execution mode.\n *\n * @param mode - The execution mode, either 'worker' or 'client'.\n * @returns A function that resizes an image with optional AbortSignal.\n */\nexport function createResizer(\n mode: 'worker' | 'client' = 'worker'\n): ResizerFactory {\n const bridge = createBridge(mode);\n\n return Object.assign(\n (imageData: ImageInput, options: ResizeOptions, signal?: AbortSignal) => {\n return bridge.resize(imageData, options, signal);\n },\n {\n terminate: async () => {\n await bridge.terminate();\n },\n }\n );\n}\n"
|
|
5
|
+
"/**\n * @squoosh-kit/resize public API\n */\n\nimport type { ImageInput } from '@squoosh-kit/runtime';\nimport { createBridge } from './bridge';\nimport type { ResizeOptions } from './types';\n\nexport type { ImageInput, ResizeOptions };\n\n// Global bridge instance for reuse\nlet globalClientBridge: ReturnType<typeof createBridge> | null = null;\nlet globalCustomWorkerUrl: string | undefined;\n\n/**\n * A resizable image processor that can be reused for multiple operations.\n * Can be terminated to clean up associated resources (especially workers).\n */\nexport type ResizerFactory = ((\n imageData: ImageInput,\n options: ResizeOptions,\n signal?: AbortSignal\n) => Promise<ImageInput>) & {\n /**\n * Terminates the resizer and cleans up resources.\n * Important for worker mode to prevent memory leaks.\n *\n * @example\n * const resizer = createResizer('worker');\n * try {\n * const result = await resizer(imageData, options);\n * } finally {\n * await resizer.terminate();\n * }\n */\n terminate(): Promise<void>;\n};\n\n/**\n * Configure the global resize worker URL. Call this before using the resize function\n * in environments like Vite where the worker path needs to be explicitly resolved.\n *\n * @param workerUrl - The absolute URL to the resize worker file.\n * In Vite apps, use: new URL('@squoosh-kit/resize/dist/resize.worker.browser.mjs', import.meta.url).href\n *\n * @example\n * import { configureResizeWorker, resize } from '@squoosh-kit/resize';\n *\n * // In your Vite app initialization:\n * configureResizeWorker(\n * new URL('@squoosh-kit/resize/dist/resize.worker.browser.mjs', import.meta.url).href\n * );\n *\n * // Then use resize normally:\n * const result = await resize(imageData, { width: 800 });\n */\nexport function configureResizeWorker(workerUrl: string): void {\n globalCustomWorkerUrl = workerUrl;\n // Reset the bridge so it uses the new worker URL on next call\n globalClientBridge = null;\n}\n\n/**\n * Resizes an image. Uses worker mode for UI responsiveness.\n *\n * @param imageData - The image data to resize.\n * @param options - Resize options.\n * @param signal - (Optional) AbortSignal to cancel the resizing operation.\n * If provided, you can cancel the operation by calling\n * `controller.abort()` on the associated AbortController.\n * If not provided, the operation cannot be cancelled.\n * @returns A Promise resolving to the resized image data.\n *\n * @example\n * // With cancellation support\n * const controller = new AbortController();\n * const result = await resize(imageData, { width: 800 }, controller.signal);\n * setTimeout(() => controller.abort(), 5000);\n *\n * @example\n * // Without cancellation (operation cannot be stopped)\n * const result = await resize(imageData, { width: 800 });\n */\nexport async function resize(\n imageData: ImageInput,\n options: ResizeOptions,\n signal?: AbortSignal\n): Promise<ImageInput> {\n // Use worker mode for UI responsiveness - prevents blocking the main thread\n if (!globalClientBridge) {\n globalClientBridge = createBridge('worker', globalCustomWorkerUrl);\n }\n\n return globalClientBridge.resize(imageData, options, signal);\n}\n\n/**\n * Creates a reusable resizer function for a specific execution mode.\n *\n * @param mode - The execution mode, either 'worker' or 'client'.\n * @param customWorkerUrl - (Optional) Custom URL for the worker file in 'worker' mode.\n * @returns A function that resizes an image with optional AbortSignal.\n *\n * @example\n * // In a Vite app with custom worker URL:\n * const resizer = createResizer(\n * 'worker',\n * new URL('@squoosh-kit/resize/dist/resize.worker.browser.mjs', import.meta.url).href\n * );\n * const result = await resizer(imageData, { width: 800 });\n * await resizer.terminate();\n */\nexport function createResizer(\n mode: 'worker' | 'client' = 'worker',\n customWorkerUrl?: string\n): ResizerFactory {\n const bridge = createBridge(mode, customWorkerUrl);\n\n return Object.assign(\n (imageData: ImageInput, options: ResizeOptions, signal?: AbortSignal) => {\n return bridge.resize(imageData, options, signal);\n },\n {\n terminate: async () => {\n await bridge.terminate();\n },\n }\n );\n}\n"
|
|
6
6
|
],
|
|
7
|
-
"mappings": ";
|
|
8
|
-
"debugId": "
|
|
7
|
+
"mappings": ";wGAWA,FAAI,JAA6D,KAC7D,EA4CG,SAAS,CAAqB,CAAC,EAAyB,CAC7D,EAAwB,EAExB,EAAqB,KAwBvB,eAAsB,CAAM,CAC1B,EACA,EACA,EACqB,CAErB,GAAI,CAAC,EACH,EAAqB,EAAa,SAAU,CAAqB,EAGnE,OAAO,EAAmB,OAAO,EAAW,EAAS,CAAM,EAmBtD,SAAS,CAAa,CAC3B,EAA4B,SAC5B,EACgB,CAChB,IAAM,EAAS,EAAa,EAAM,CAAe,EAEjD,OAAO,OAAO,OACZ,CAAC,EAAuB,EAAwB,IAAyB,CACvE,OAAO,EAAO,OAAO,EAAW,EAAS,CAAM,GAEjD,CACE,UAAW,SAAY,CACrB,MAAM,EAAO,UAAU,EAE3B,CACF",
|
|
8
|
+
"debugId": "45B78DB4C08FB64364756E2164756E21",
|
|
9
9
|
"names": []
|
|
10
10
|
}
|
package/dist/index.d.ts
CHANGED
|
@@ -23,6 +23,25 @@ export type ResizerFactory = ((imageData: ImageInput, options: ResizeOptions, si
|
|
|
23
23
|
*/
|
|
24
24
|
terminate(): Promise<void>;
|
|
25
25
|
};
|
|
26
|
+
/**
|
|
27
|
+
* Configure the global resize worker URL. Call this before using the resize function
|
|
28
|
+
* in environments like Vite where the worker path needs to be explicitly resolved.
|
|
29
|
+
*
|
|
30
|
+
* @param workerUrl - The absolute URL to the resize worker file.
|
|
31
|
+
* In Vite apps, use: new URL('@squoosh-kit/resize/dist/resize.worker.browser.mjs', import.meta.url).href
|
|
32
|
+
*
|
|
33
|
+
* @example
|
|
34
|
+
* import { configureResizeWorker, resize } from '@squoosh-kit/resize';
|
|
35
|
+
*
|
|
36
|
+
* // In your Vite app initialization:
|
|
37
|
+
* configureResizeWorker(
|
|
38
|
+
* new URL('@squoosh-kit/resize/dist/resize.worker.browser.mjs', import.meta.url).href
|
|
39
|
+
* );
|
|
40
|
+
*
|
|
41
|
+
* // Then use resize normally:
|
|
42
|
+
* const result = await resize(imageData, { width: 800 });
|
|
43
|
+
*/
|
|
44
|
+
export declare function configureResizeWorker(workerUrl: string): void;
|
|
26
45
|
/**
|
|
27
46
|
* Resizes an image. Uses worker mode for UI responsiveness.
|
|
28
47
|
*
|
|
@@ -49,7 +68,17 @@ export declare function resize(imageData: ImageInput, options: ResizeOptions, si
|
|
|
49
68
|
* Creates a reusable resizer function for a specific execution mode.
|
|
50
69
|
*
|
|
51
70
|
* @param mode - The execution mode, either 'worker' or 'client'.
|
|
71
|
+
* @param customWorkerUrl - (Optional) Custom URL for the worker file in 'worker' mode.
|
|
52
72
|
* @returns A function that resizes an image with optional AbortSignal.
|
|
73
|
+
*
|
|
74
|
+
* @example
|
|
75
|
+
* // In a Vite app with custom worker URL:
|
|
76
|
+
* const resizer = createResizer(
|
|
77
|
+
* 'worker',
|
|
78
|
+
* new URL('@squoosh-kit/resize/dist/resize.worker.browser.mjs', import.meta.url).href
|
|
79
|
+
* );
|
|
80
|
+
* const result = await resizer(imageData, { width: 800 });
|
|
81
|
+
* await resizer.terminate();
|
|
53
82
|
*/
|
|
54
|
-
export declare function createResizer(mode?: 'worker' | 'client'): ResizerFactory;
|
|
83
|
+
export declare function createResizer(mode?: 'worker' | 'client', customWorkerUrl?: string): ResizerFactory;
|
|
55
84
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAEvD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAE7C,YAAY,EAAE,UAAU,EAAE,aAAa,EAAE,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAEvD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAE7C,YAAY,EAAE,UAAU,EAAE,aAAa,EAAE,CAAC;AAM1C;;;GAGG;AACH,MAAM,MAAM,cAAc,GAAG,CAAC,CAC5B,SAAS,EAAE,UAAU,EACrB,OAAO,EAAE,aAAa,EACtB,MAAM,CAAC,EAAE,WAAW,KACjB,OAAO,CAAC,UAAU,CAAC,CAAC,GAAG;IAC1B;;;;;;;;;;;OAWG;IACH,SAAS,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;CAC5B,CAAC;AAEF;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,qBAAqB,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI,CAI7D;AAED;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAsB,MAAM,CAC1B,SAAS,EAAE,UAAU,EACrB,OAAO,EAAE,aAAa,EACtB,MAAM,CAAC,EAAE,WAAW,GACnB,OAAO,CAAC,UAAU,CAAC,CAOrB;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,aAAa,CAC3B,IAAI,GAAE,QAAQ,GAAG,QAAmB,EACpC,eAAe,CAAC,EAAE,MAAM,GACvB,cAAc,CAahB"}
|
package/dist/index.node.cjs
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
var
|
|
1
|
+
var Z={};P(Z,{resize:()=>X,createResizer:()=>Y,configureResizeWorker:()=>Q});module.exports=N(Z);var E=null,H;function Q(v){H=v,E=null}async function X(v,F,y){if(!E)E=G("worker",H);return E.resize(v,F,y)}function Y(v="worker",F){let y=G(v,F);return Object.assign((J,K,M)=>{return y.resize(J,K,M)},{terminate:async()=>{await y.terminate()}})}
|
|
2
2
|
|
|
3
|
-
//# debugId=
|
|
3
|
+
//# debugId=85319A893BA043BB64756E2164756E21
|
package/dist/index.node.cjs.map
CHANGED
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../src/index.ts"],
|
|
4
4
|
"sourcesContent": [
|
|
5
|
-
"/**\n * @squoosh-kit/resize public API\n */\n\nimport type { ImageInput } from '@squoosh-kit/runtime';\nimport { createBridge } from './bridge';\nimport type { ResizeOptions } from './types';\n\nexport type { ImageInput, ResizeOptions };\n\n// Global bridge instance for reuse\nlet globalClientBridge: ReturnType<typeof createBridge> | null = null;\n\n/**\n * A resizable image processor that can be reused for multiple operations.\n * Can be terminated to clean up associated resources (especially workers).\n */\nexport type ResizerFactory = ((\n imageData: ImageInput,\n options: ResizeOptions,\n signal?: AbortSignal\n) => Promise<ImageInput>) & {\n /**\n * Terminates the resizer and cleans up resources.\n * Important for worker mode to prevent memory leaks.\n *\n * @example\n * const resizer = createResizer('worker');\n * try {\n * const result = await resizer(imageData, options);\n * } finally {\n * await resizer.terminate();\n * }\n */\n terminate(): Promise<void>;\n};\n\n/**\n * Resizes an image. Uses worker mode for UI responsiveness.\n *\n * @param imageData - The image data to resize.\n * @param options - Resize options.\n * @param signal - (Optional) AbortSignal to cancel the resizing operation.\n * If provided, you can cancel the operation by calling\n * `controller.abort()` on the associated AbortController.\n * If not provided, the operation cannot be cancelled.\n * @returns A Promise resolving to the resized image data.\n *\n * @example\n * // With cancellation support\n * const controller = new AbortController();\n * const result = await resize(imageData, { width: 800 }, controller.signal);\n * setTimeout(() => controller.abort(), 5000);\n *\n * @example\n * // Without cancellation (operation cannot be stopped)\n * const result = await resize(imageData, { width: 800 });\n */\nexport async function resize(\n imageData: ImageInput,\n options: ResizeOptions,\n signal?: AbortSignal\n): Promise<ImageInput> {\n // Use worker mode for UI responsiveness - prevents blocking the main thread\n if (!globalClientBridge) {\n globalClientBridge = createBridge('worker');\n }\n\n return globalClientBridge.resize(imageData, options, signal);\n}\n\n/**\n * Creates a reusable resizer function for a specific execution mode.\n *\n * @param mode - The execution mode, either 'worker' or 'client'.\n * @returns A function that resizes an image with optional AbortSignal.\n */\nexport function createResizer(\n mode: 'worker' | 'client' = 'worker'\n): ResizerFactory {\n const bridge = createBridge(mode);\n\n return Object.assign(\n (imageData: ImageInput, options: ResizeOptions, signal?: AbortSignal) => {\n return bridge.resize(imageData, options, signal);\n },\n {\n terminate: async () => {\n await bridge.terminate();\n },\n }\n );\n}\n"
|
|
5
|
+
"/**\n * @squoosh-kit/resize public API\n */\n\nimport type { ImageInput } from '@squoosh-kit/runtime';\nimport { createBridge } from './bridge';\nimport type { ResizeOptions } from './types';\n\nexport type { ImageInput, ResizeOptions };\n\n// Global bridge instance for reuse\nlet globalClientBridge: ReturnType<typeof createBridge> | null = null;\nlet globalCustomWorkerUrl: string | undefined;\n\n/**\n * A resizable image processor that can be reused for multiple operations.\n * Can be terminated to clean up associated resources (especially workers).\n */\nexport type ResizerFactory = ((\n imageData: ImageInput,\n options: ResizeOptions,\n signal?: AbortSignal\n) => Promise<ImageInput>) & {\n /**\n * Terminates the resizer and cleans up resources.\n * Important for worker mode to prevent memory leaks.\n *\n * @example\n * const resizer = createResizer('worker');\n * try {\n * const result = await resizer(imageData, options);\n * } finally {\n * await resizer.terminate();\n * }\n */\n terminate(): Promise<void>;\n};\n\n/**\n * Configure the global resize worker URL. Call this before using the resize function\n * in environments like Vite where the worker path needs to be explicitly resolved.\n *\n * @param workerUrl - The absolute URL to the resize worker file.\n * In Vite apps, use: new URL('@squoosh-kit/resize/dist/resize.worker.browser.mjs', import.meta.url).href\n *\n * @example\n * import { configureResizeWorker, resize } from '@squoosh-kit/resize';\n *\n * // In your Vite app initialization:\n * configureResizeWorker(\n * new URL('@squoosh-kit/resize/dist/resize.worker.browser.mjs', import.meta.url).href\n * );\n *\n * // Then use resize normally:\n * const result = await resize(imageData, { width: 800 });\n */\nexport function configureResizeWorker(workerUrl: string): void {\n globalCustomWorkerUrl = workerUrl;\n // Reset the bridge so it uses the new worker URL on next call\n globalClientBridge = null;\n}\n\n/**\n * Resizes an image. Uses worker mode for UI responsiveness.\n *\n * @param imageData - The image data to resize.\n * @param options - Resize options.\n * @param signal - (Optional) AbortSignal to cancel the resizing operation.\n * If provided, you can cancel the operation by calling\n * `controller.abort()` on the associated AbortController.\n * If not provided, the operation cannot be cancelled.\n * @returns A Promise resolving to the resized image data.\n *\n * @example\n * // With cancellation support\n * const controller = new AbortController();\n * const result = await resize(imageData, { width: 800 }, controller.signal);\n * setTimeout(() => controller.abort(), 5000);\n *\n * @example\n * // Without cancellation (operation cannot be stopped)\n * const result = await resize(imageData, { width: 800 });\n */\nexport async function resize(\n imageData: ImageInput,\n options: ResizeOptions,\n signal?: AbortSignal\n): Promise<ImageInput> {\n // Use worker mode for UI responsiveness - prevents blocking the main thread\n if (!globalClientBridge) {\n globalClientBridge = createBridge('worker', globalCustomWorkerUrl);\n }\n\n return globalClientBridge.resize(imageData, options, signal);\n}\n\n/**\n * Creates a reusable resizer function for a specific execution mode.\n *\n * @param mode - The execution mode, either 'worker' or 'client'.\n * @param customWorkerUrl - (Optional) Custom URL for the worker file in 'worker' mode.\n * @returns A function that resizes an image with optional AbortSignal.\n *\n * @example\n * // In a Vite app with custom worker URL:\n * const resizer = createResizer(\n * 'worker',\n * new URL('@squoosh-kit/resize/dist/resize.worker.browser.mjs', import.meta.url).href\n * );\n * const result = await resizer(imageData, { width: 800 });\n * await resizer.terminate();\n */\nexport function createResizer(\n mode: 'worker' | 'client' = 'worker',\n customWorkerUrl?: string\n): ResizerFactory {\n const bridge = createBridge(mode, customWorkerUrl);\n\n return Object.assign(\n (imageData: ImageInput, options: ResizeOptions, signal?: AbortSignal) => {\n return bridge.resize(imageData, options, signal);\n },\n {\n terminate: async () => {\n await bridge.terminate();\n },\n }\n );\n}\n"
|
|
6
6
|
],
|
|
7
|
-
"mappings": "
|
|
8
|
-
"debugId": "
|
|
7
|
+
"mappings": "iGAWA,IAAI,EAA6D,KAC7D,EA4CG,SAAS,CAAqB,CAAC,EAAyB,CAC7D,EAAwB,EAExB,EAAqB,KAwBvB,eAAsB,CAAM,CAC1B,EACA,EACA,EACqB,CAErB,GAAI,CAAC,EACH,EAAqB,EAAa,SAAU,CAAqB,EAGnE,OAAO,EAAmB,OAAO,EAAW,EAAS,CAAM,EAmBtD,SAAS,CAAa,CAC3B,EAA4B,SAC5B,EACgB,CAChB,IAAM,EAAS,EAAa,EAAM,CAAe,EAEjD,OAAO,OAAO,OACZ,CAAC,EAAuB,EAAwB,IAAyB,CACvE,OAAO,EAAO,OAAO,EAAW,EAAS,CAAM,GAEjD,CACE,UAAW,SAAY,CACrB,MAAM,EAAO,UAAU,EAE3B,CACF",
|
|
8
|
+
"debugId": "85319A893BA043BB64756E2164756E21",
|
|
9
9
|
"names": []
|
|
10
10
|
}
|
package/dist/index.node.mjs
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import{a as
|
|
1
|
+
import{a as G}from"./bridge.node.mjs";import"./chunk-szbj3b6y.js";import"./chunk-c6cx0d7q.js";var E=null,H;function P(v){H=v,E=null}async function Q(v,F,y){if(!E)E=G("worker",H);return E.resize(v,F,y)}function X(v="worker",F){let y=G(v,F);return Object.assign((J,K,M)=>{return y.resize(J,K,M)},{terminate:async()=>{await y.terminate()}})}export{Q as resize,X as createResizer,P as configureResizeWorker};
|
|
2
2
|
|
|
3
|
-
//# debugId=
|
|
3
|
+
//# debugId=EC7EDF3CF360F2BB64756E2164756E21
|
package/dist/index.node.mjs.map
CHANGED
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../src/index.ts"],
|
|
4
4
|
"sourcesContent": [
|
|
5
|
-
"/**\n * @squoosh-kit/resize public API\n */\n\nimport type { ImageInput } from '@squoosh-kit/runtime';\nimport { createBridge } from './bridge';\nimport type { ResizeOptions } from './types';\n\nexport type { ImageInput, ResizeOptions };\n\n// Global bridge instance for reuse\nlet globalClientBridge: ReturnType<typeof createBridge> | null = null;\n\n/**\n * A resizable image processor that can be reused for multiple operations.\n * Can be terminated to clean up associated resources (especially workers).\n */\nexport type ResizerFactory = ((\n imageData: ImageInput,\n options: ResizeOptions,\n signal?: AbortSignal\n) => Promise<ImageInput>) & {\n /**\n * Terminates the resizer and cleans up resources.\n * Important for worker mode to prevent memory leaks.\n *\n * @example\n * const resizer = createResizer('worker');\n * try {\n * const result = await resizer(imageData, options);\n * } finally {\n * await resizer.terminate();\n * }\n */\n terminate(): Promise<void>;\n};\n\n/**\n * Resizes an image. Uses worker mode for UI responsiveness.\n *\n * @param imageData - The image data to resize.\n * @param options - Resize options.\n * @param signal - (Optional) AbortSignal to cancel the resizing operation.\n * If provided, you can cancel the operation by calling\n * `controller.abort()` on the associated AbortController.\n * If not provided, the operation cannot be cancelled.\n * @returns A Promise resolving to the resized image data.\n *\n * @example\n * // With cancellation support\n * const controller = new AbortController();\n * const result = await resize(imageData, { width: 800 }, controller.signal);\n * setTimeout(() => controller.abort(), 5000);\n *\n * @example\n * // Without cancellation (operation cannot be stopped)\n * const result = await resize(imageData, { width: 800 });\n */\nexport async function resize(\n imageData: ImageInput,\n options: ResizeOptions,\n signal?: AbortSignal\n): Promise<ImageInput> {\n // Use worker mode for UI responsiveness - prevents blocking the main thread\n if (!globalClientBridge) {\n globalClientBridge = createBridge('worker');\n }\n\n return globalClientBridge.resize(imageData, options, signal);\n}\n\n/**\n * Creates a reusable resizer function for a specific execution mode.\n *\n * @param mode - The execution mode, either 'worker' or 'client'.\n * @returns A function that resizes an image with optional AbortSignal.\n */\nexport function createResizer(\n mode: 'worker' | 'client' = 'worker'\n): ResizerFactory {\n const bridge = createBridge(mode);\n\n return Object.assign(\n (imageData: ImageInput, options: ResizeOptions, signal?: AbortSignal) => {\n return bridge.resize(imageData, options, signal);\n },\n {\n terminate: async () => {\n await bridge.terminate();\n },\n }\n );\n}\n"
|
|
5
|
+
"/**\n * @squoosh-kit/resize public API\n */\n\nimport type { ImageInput } from '@squoosh-kit/runtime';\nimport { createBridge } from './bridge';\nimport type { ResizeOptions } from './types';\n\nexport type { ImageInput, ResizeOptions };\n\n// Global bridge instance for reuse\nlet globalClientBridge: ReturnType<typeof createBridge> | null = null;\nlet globalCustomWorkerUrl: string | undefined;\n\n/**\n * A resizable image processor that can be reused for multiple operations.\n * Can be terminated to clean up associated resources (especially workers).\n */\nexport type ResizerFactory = ((\n imageData: ImageInput,\n options: ResizeOptions,\n signal?: AbortSignal\n) => Promise<ImageInput>) & {\n /**\n * Terminates the resizer and cleans up resources.\n * Important for worker mode to prevent memory leaks.\n *\n * @example\n * const resizer = createResizer('worker');\n * try {\n * const result = await resizer(imageData, options);\n * } finally {\n * await resizer.terminate();\n * }\n */\n terminate(): Promise<void>;\n};\n\n/**\n * Configure the global resize worker URL. Call this before using the resize function\n * in environments like Vite where the worker path needs to be explicitly resolved.\n *\n * @param workerUrl - The absolute URL to the resize worker file.\n * In Vite apps, use: new URL('@squoosh-kit/resize/dist/resize.worker.browser.mjs', import.meta.url).href\n *\n * @example\n * import { configureResizeWorker, resize } from '@squoosh-kit/resize';\n *\n * // In your Vite app initialization:\n * configureResizeWorker(\n * new URL('@squoosh-kit/resize/dist/resize.worker.browser.mjs', import.meta.url).href\n * );\n *\n * // Then use resize normally:\n * const result = await resize(imageData, { width: 800 });\n */\nexport function configureResizeWorker(workerUrl: string): void {\n globalCustomWorkerUrl = workerUrl;\n // Reset the bridge so it uses the new worker URL on next call\n globalClientBridge = null;\n}\n\n/**\n * Resizes an image. Uses worker mode for UI responsiveness.\n *\n * @param imageData - The image data to resize.\n * @param options - Resize options.\n * @param signal - (Optional) AbortSignal to cancel the resizing operation.\n * If provided, you can cancel the operation by calling\n * `controller.abort()` on the associated AbortController.\n * If not provided, the operation cannot be cancelled.\n * @returns A Promise resolving to the resized image data.\n *\n * @example\n * // With cancellation support\n * const controller = new AbortController();\n * const result = await resize(imageData, { width: 800 }, controller.signal);\n * setTimeout(() => controller.abort(), 5000);\n *\n * @example\n * // Without cancellation (operation cannot be stopped)\n * const result = await resize(imageData, { width: 800 });\n */\nexport async function resize(\n imageData: ImageInput,\n options: ResizeOptions,\n signal?: AbortSignal\n): Promise<ImageInput> {\n // Use worker mode for UI responsiveness - prevents blocking the main thread\n if (!globalClientBridge) {\n globalClientBridge = createBridge('worker', globalCustomWorkerUrl);\n }\n\n return globalClientBridge.resize(imageData, options, signal);\n}\n\n/**\n * Creates a reusable resizer function for a specific execution mode.\n *\n * @param mode - The execution mode, either 'worker' or 'client'.\n * @param customWorkerUrl - (Optional) Custom URL for the worker file in 'worker' mode.\n * @returns A function that resizes an image with optional AbortSignal.\n *\n * @example\n * // In a Vite app with custom worker URL:\n * const resizer = createResizer(\n * 'worker',\n * new URL('@squoosh-kit/resize/dist/resize.worker.browser.mjs', import.meta.url).href\n * );\n * const result = await resizer(imageData, { width: 800 });\n * await resizer.terminate();\n */\nexport function createResizer(\n mode: 'worker' | 'client' = 'worker',\n customWorkerUrl?: string\n): ResizerFactory {\n const bridge = createBridge(mode, customWorkerUrl);\n\n return Object.assign(\n (imageData: ImageInput, options: ResizeOptions, signal?: AbortSignal) => {\n return bridge.resize(imageData, options, signal);\n },\n {\n terminate: async () => {\n await bridge.terminate();\n },\n }\n );\n}\n"
|
|
6
6
|
],
|
|
7
|
-
"mappings": "
|
|
8
|
-
"debugId": "
|
|
7
|
+
"mappings": "0GAWA,FAAI,JAA6D,KAC7D,EA4CG,SAAS,CAAqB,CAAC,EAAyB,CAC7D,EAAwB,EAExB,EAAqB,KAwBvB,eAAsB,CAAM,CAC1B,EACA,EACA,EACqB,CAErB,GAAI,CAAC,EACH,EAAqB,EAAa,SAAU,CAAqB,EAGnE,OAAO,EAAmB,OAAO,EAAW,EAAS,CAAM,EAmBtD,SAAS,CAAa,CAC3B,EAA4B,SAC5B,EACgB,CAChB,IAAM,EAAS,EAAa,EAAM,CAAe,EAEjD,OAAO,OAAO,OACZ,CAAC,EAAuB,EAAwB,IAAyB,CACvE,OAAO,EAAO,OAAO,EAAW,EAAS,CAAM,GAEjD,CACE,UAAW,SAAY,CACrB,MAAM,EAAO,UAAU,EAE3B,CACF",
|
|
8
|
+
"debugId": "EC7EDF3CF360F2BB64756E2164756E21",
|
|
9
9
|
"names": []
|
|
10
10
|
}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import{b as
|
|
1
|
+
import{b as C}from"./chunk-szbj3b6y.js";import{c as E}from"./validators.browser.mjs";import{d as B,e as T}from"./chunk-bhj61bkd.js";async function A(j){try{if(typeof process<"u"&&process.versions?.node){let D=await import("fs/promises"),J=/^(file:|https?:)/.test(j)?new URL(j):new URL(j,import.meta.url),K=J.protocol==="file:"?(await import("./chunk-5vdxd0v3.js")).fileURLToPath(J):J.pathname,Q=await D.readFile(K);return Q.buffer.slice(Q.byteOffset,Q.byteOffset+Q.byteLength)}}catch(D){}try{let D=/^(file:|https?:)/.test(j)?new URL(j):new URL(j,import.meta.url),G=await fetch(D);if(!G.ok)throw Error(`Failed to fetch WASM binary: ${G.status} ${G.statusText}`);return await G.arrayBuffer()}catch(D){throw Error(`Failed to load WASM binary from "${j}": ${D instanceof Error?D.message:String(D)}`)}}var Y,$=null;function M(){if($===null||$.buffer!==Y.memory.buffer)$=new Uint8Array(Y.memory.buffer);return $}var z=0;function v(j,D){let G=D(j.length*1);return M().set(j,G/1),z=j.length,G}var k=null;function R(){if(k===null||k.buffer!==Y.memory.buffer)k=new Int32Array(Y.memory.buffer);return k}var F=null;function f(){if(F===null||F.buffer!==Y.memory.buffer)F=new Uint8ClampedArray(Y.memory.buffer);return F}function w(j,D){return f().subarray(j/1,j/1+D)}function H(j,D,G,J,K,Q,X,N){try{let S=Y.__wbindgen_add_to_stack_pointer(-16);var q=v(j,Y.__wbindgen_malloc),W=z;Y.resize(S,q,W,D,G,J,K,Q,X,N);var O=R()[S/4+0],x=R()[S/4+1],U=w(O,x).slice();return Y.__wbindgen_free(O,x*1),U}finally{Y.__wbindgen_add_to_stack_pointer(16)}}async function P(j,D){if(typeof Response==="function"&&j instanceof Response){if(typeof WebAssembly.instantiateStreaming==="function")try{return await WebAssembly.instantiateStreaming(j,D)}catch(J){if(j.headers.get("Content-Type")!="application/wasm")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",J);else throw J}let G=await j.arrayBuffer();return await WebAssembly.instantiate(G,D)}else{let G=await WebAssembly.instantiate(j,D);if(G instanceof WebAssembly.Instance)return{instance:G,module:j};else return G}}async function I(j){if(typeof j>"u")j=new URL("squoosh_resize_bg.wasm",import.meta.url);let D={};if(typeof j==="string"||typeof Request==="function"&&j instanceof Request||typeof URL==="function"&&j instanceof URL)j=fetch(j);let{instance:G,module:J}=await P(await j,D);return Y=G.exports,I.__wbindgen_wasm_module=J,Y}var V=I;var L=null,Z=null;async function y(){if(L)return;if(Z)return Z;return Z=(async()=>{try{let j=null,D=[new URL("./wasm/squoosh_resize_bg.wasm",import.meta.url).href,new URL("../wasm/squoosh_resize_bg.wasm",import.meta.url).href],G=null;for(let J of D)try{j=await A(J);break}catch(K){G=K instanceof Error?K:Error(String(K))}if(!j)throw G||Error("Could not load WASM binary from any path");try{await V(j)}catch(J){if(J instanceof Error&&(J.message.includes("SharedArrayBuffer")||J.message.includes("first argument must be"))){if(typeof SharedArrayBuffer>"u")globalThis.SharedArrayBuffer=ArrayBuffer;try{await V(j)}catch(K){throw Error(`WASM module initialization failed even with polyfill: ${K instanceof Error?K.message:String(K)}`)}}else throw J}L=H}catch(j){throw Z=null,Error(`Failed to initialize resize WASM module: ${j instanceof Error?j.message:String(j)}`)}})(),Z}async function b(j,D){if(C(j),E(D),await y(),!L)throw Error("Resize module not initialized");let{data:G,width:J,height:K}=j,Q=D.width??J,X=D.height??K;if(D.width&&!D.height)X=Math.max(1,Math.round(K*D.width/J));else if(D.height&&!D.width)Q=Math.max(1,Math.round(J*D.height/K));if(Q<1||X<1)throw RangeError(`Output dimensions must be at least 1x1, got ${Q}x${X}`);let N=G instanceof Uint8ClampedArray?new Uint8Array(G.buffer,G.byteOffset,G.length):new Uint8Array(G.buffer,G.byteOffset,G.length);return{data:L(N,J,K,Q,X,c(D),D.premultiply??!0,D.linearRGB??!0),width:Q,height:X}}async function l(j,D,G){if(G?.aborted)throw new DOMException("Aborted","AbortError");return b(j,D)}function c(j){return{triangular:0,catrom:1,mitchell:2,lanczos3:3}[j?.method??"lanczos3"]??3}if(typeof self<"u")self.onmessage=async(j)=>{let D=j.data;if(D?.type==="worker:ping"){self.postMessage({type:"worker:ready"});return}let{id:G,type:J,payload:K}=D,Q={id:G,ok:!1};try{if(J!=="resize:run")throw Error(`Unknown message type: ${J}`);let X=await b(K.image,K.options);Q.ok=!0,Q.data=X,self.postMessage(Q)}catch(X){Q.error=X instanceof Error?X.message:String(X),self.postMessage(Q)}};export{l as resizeClient};
|
|
2
2
|
|
|
3
|
-
//# debugId=
|
|
3
|
+
//# debugId=FFF6041AE058784C64756E2164756E21
|