omni-compress 2.3.0

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Dharanish V
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,403 @@
1
+ # Omni Compress
2
+
3
+ <p align="center">
4
+ <img src="https://img.shields.io/npm/v/omni-compress?style=flat-square&color=0f4c81" alt="NPM Version" />
5
+ <img src="https://img.shields.io/github/license/dharanish-v/omni-compress?style=flat-square&color=5386b4" alt="License" />
6
+ <img src="https://img.shields.io/npm/dt/omni-compress?style=flat-square&color=c06c5b" alt="NPM Downloads" />
7
+ <img src="https://img.shields.io/github/actions/workflow/status/dharanish-v/omni-compress/ci.yml?branch=master&style=flat-square&color=d9a05b" alt="CI Status" />
8
+ <img src="https://img.shields.io/endpoint?url=https://dharanish-v.github.io/omni-compress/coverage.json&style=flat-square" alt="Coverage" />
9
+ <img src="https://img.shields.io/badge/Tested_with-Vitest-729B1B?style=flat-square&logo=vitest" alt="Tested with Vitest" />
10
+ <img src="https://img.shields.io/badge/TypeScript-strict-blue?style=flat-square" alt="TypeScript" />
11
+ </p>
12
+
13
+ <p align="center">
14
+ <b>Universal compression and archiving for browsers and Node.js.</b><br/>
15
+ One API. Three engines. Isomorphic ZIP & Media processing.
16
+ </p>
17
+
18
+ <p align="center">
19
+ <a href="https://dharanish-v.github.io/omni-compress/"><b>Live Neo-Brutalist Demo 🚀</b></a>
20
+ </p>
21
+
22
+ ---
23
+
24
+ `omni-compress` is a high-performance, isomorphic compression library. It automatically routes media compression (images/audio/video) to the fastest available engine at runtime — native Web APIs, FFmpeg WebAssembly, or OS-level binaries — and provides built-in ZIP archiving for any file type.
25
+
26
+ | Problem | How omni-compress solves it |
27
+ | ---------------------------------------------- | -------------------------------------------------------------------------------- |
28
+ | Browser and Node need different code paths | Single Isomorphic API — environment detection is automatic |
29
+ | Archiving or batching needs separate libs | **Built-in ZIP** `archive()` and `archiveStream()` for any file type |
30
+ | FFmpeg Wasm is heavy (~30 MB) and slow to load | Uses native `OffscreenCanvas`/`WebCodecs` for standard formats (0 KB Wasm) |
31
+ | Media processing freezes the UI | **ALL** browser work runs in Web Workers with zero-copy `Transferable` transfers |
32
+ | FFmpeg Wasm is too slow | **Multi-threading** support via `@ffmpeg/core-mt` (requires COOP/COEP) |
33
+ | Wasm memory leaks crash browser tabs | FFmpeg singleton with idle-timeout auto-termination; VFS cleanup per-operation |
34
+ | Large files crash the browser silently | `FileTooLargeError` thrown before loading files > 250 MB into Wasm |
35
+ | Fast Path fails on unsupported browsers | Automatic fallback from Fast Path to Heavy Path on any runtime error |
36
+ | No way to cancel a running compression | Full `AbortSignal` support — terminates Wasm/child process on abort |
37
+ | Silent failures when file extension ≠ content | `detectFormat()` reads magic bytes to identify the real format |
38
+
39
+ ## Install
40
+
41
+ ```bash
42
+ npm install omni-compress
43
+ ```
44
+
45
+ ```bash
46
+ # bun
47
+ bun add omni-compress
48
+
49
+ # pnpm
50
+ pnpm add omni-compress
51
+
52
+ # yarn
53
+ yarn add omni-compress
54
+ ```
55
+
56
+ > Previously published as `@dharanish/omni-compress` (deprecated — please migrate to `omni-compress`).
57
+
58
+ > **Node.js users:** For the Node adapter to work, install `ffmpeg-static` (bundled as an optional dependency) or ensure `ffmpeg` is available on your system `PATH`.
59
+
60
+ > **AVIF in the browser:** AVIF encoding uses `@jsquash/avif` (standalone libaom-av1 Wasm from Google's Squoosh, 1.1 MB gzipped). It is bundled automatically -- no extra install or configuration needed. No SharedArrayBuffer or special headers required.
61
+
62
+ ## Quick Start
63
+
64
+ ```typescript
65
+ import { compressImage, compressAudio, compressVideo } from "omni-compress";
66
+
67
+ // Image → WebP
68
+ const { blob, ratio } = await compressImage(imageFile, {
69
+ format: "webp",
70
+ quality: 0.8,
71
+ });
72
+ console.log(`Saved ${Math.round((1 - ratio) * 100)}%`);
73
+
74
+ // Audio → Opus (with cancellation)
75
+ const controller = new AbortController();
76
+ const { blob: audio } = await compressAudio(audioFile, {
77
+ format: "opus",
78
+ bitrate: "96k",
79
+ onProgress: (p) => console.log(`${p}%`),
80
+ signal: controller.signal,
81
+ });
82
+
83
+ // Video → MP4
84
+ const { blob: video } = await compressVideo(videoFile, {
85
+ format: "mp4",
86
+ bitrate: "1M",
87
+ });
88
+
89
+ // Archive multiple files into a ZIP
90
+ import { archive } from "omni-compress";
91
+ const { blob: zip } = await archive([
92
+ { name: "photo.webp", data: blob },
93
+ { name: "audio.opus", data: audio },
94
+ { name: "video.mp4", data: video },
95
+ ]);
96
+ ```
97
+
98
+ ## API Reference
99
+
100
+ ### v2.0 Named Exports (recommended)
101
+
102
+ #### `compressImage(input, options): Promise<CompressResult>`
103
+
104
+ Compresses an image using the fastest available engine (OffscreenCanvas fast path, FFmpeg Wasm heavy path, or native ffmpeg on Node).
105
+
106
+ ```typescript
107
+ import { compressImage } from "omni-compress";
108
+
109
+ const result = await compressImage(file, {
110
+ format: "webp",
111
+ quality: 0.8,
112
+ maxWidth: 1920,
113
+ signal: controller.signal,
114
+ });
115
+ // result.blob → the compressed Blob
116
+ // result.ratio → e.g. 0.62 (38% smaller)
117
+ // result.originalSize / result.compressedSize → bytes
118
+ ```
119
+
120
+ **`ImageOptions`**
121
+
122
+ | Property | Type | Default | Description |
123
+ | ------------------ | --------------------------------- | ------- | -------------------------------------------------------- |
124
+ | `format` | `'webp' \| 'avif' \| 'jpeg' \| 'png'` | — | Target output format |
125
+ | `quality` | `number` | `0.8` | Lossy quality `0.0` – `1.0` |
126
+ | `maxWidth` | `number` | — | Max output width in px (aspect ratio preserved) |
127
+ | `maxHeight` | `number` | — | Max output height in px (aspect ratio preserved) |
128
+ | `preserveMetadata` | `boolean` | `false` | Keep EXIF data in the output |
129
+ | `useWorker` | `boolean` | Auto | Force Web Worker (true) or Main Thread (false) |
130
+ | `onProgress` | `(percent: number) => void` | — | Progress callback `0` – `100` |
131
+ | `signal` | `AbortSignal` | — | Cancel the operation — throws `AbortError` when signalled |
132
+
133
+ #### `compressAudio(input, options): Promise<CompressResult>`
134
+
135
+ Compresses an audio file via WebCodecs (fast path) or FFmpeg Wasm (heavy path).
136
+
137
+ **`AudioOptions`**
138
+
139
+ | Property | Type | Default | Description |
140
+ | ------------------ | --------------------------------- | -------- | -------------------------------------------------------- |
141
+ | `format` | `'opus' \| 'mp3' \| 'flac' \| 'wav' \| 'aac'` | — | Target output format |
142
+ | `bitrate` | `string` | `'128k'` | Target bitrate, e.g. `'96k'`, `'192k'` |
143
+ | `channels` | `1 \| 2` | Auto | Output channel count (1 = mono, 2 = stereo) |
144
+ | `sampleRate` | `number` | Auto | Output sample rate in Hz, e.g. `48000` |
145
+ | `preserveMetadata` | `boolean` | `false` | Keep audio tags in the output |
146
+ | `useWorker` | `boolean` | Auto | Force Web Worker (true) or Main Thread (false) |
147
+ | `onProgress` | `(percent: number) => void` | — | Progress callback `0` – `100` |
148
+ | `signal` | `AbortSignal` | — | Cancel the operation — throws `AbortError` when signalled |
149
+
150
+ #### `compressVideo(input, options): Promise<CompressResult>`
151
+
152
+ Compresses a video file via WebCodecs (fast path foundation) or FFmpeg Wasm (heavy path).
153
+
154
+ **`VideoOptions`**
155
+
156
+ | Property | Type | Default | Description |
157
+ | ------------------ | --------------------------- | ------- | -------------------------------------------------------- |
158
+ | `format` | `'mp4' \| 'webm'` | — | Target output format |
159
+ | `bitrate` | `string` | `'1M'` | Target video bitrate, e.g. `'500k'`, `'2M'` |
160
+ | `fps` | `number` | Auto | Output frame rate |
161
+ | `maxWidth` | `number` | — | Max output width in px |
162
+ | `maxHeight` | `number` | — | Max output height in px |
163
+ | `preserveMetadata` | `boolean` | `false` | Keep metadata in the output |
164
+ | `useWorker` | `boolean` | Auto | Force Web Worker (true) or Main Thread (false) |
165
+ | `onProgress` | `(percent: number) => void` | — | Progress callback `0` – `100` |
166
+ | `signal` | `AbortSignal` | — | Cancel the operation — throws `AbortError` when signalled |
167
+
168
+ #### `CompressResult`
169
+
170
+ `compressImage`, `compressAudio`, and `compressVideo` return a `CompressResult`:
171
+
172
+ ```typescript
173
+ interface CompressResult {
174
+ blob: Blob; // The compressed output
175
+ originalSize: number; // Input size in bytes
176
+ compressedSize: number; // Output size in bytes
177
+ ratio: number; // compressedSize / originalSize (< 1.0 = smaller)
178
+ format: string; // Target format used (e.g. 'webp')
179
+ }
180
+ ```
181
+
182
+ #### `archive(entries, options?): Promise<ArchiveResult>`
183
+
184
+ Compresses an array of files into a ZIP archive. Works identically in browser and Node.js.
185
+
186
+ ```typescript
187
+ import { archive } from "omni-compress";
188
+
189
+ const result = await archive(
190
+ [
191
+ { name: "images/photo.webp", data: imageBlob },
192
+ { name: "audio/track.opus", data: audioBlob },
193
+ ],
194
+ { level: 6, signal: controller.signal }
195
+ );
196
+ // result.blob → the ZIP Blob (application/zip)
197
+ // result.ratio → compression ratio
198
+ ```
199
+
200
+ #### `archiveStream(entries, options?): ReadableStream<Uint8Array>`
201
+
202
+ Streaming ZIP output — prefer this for large archives where you want to start sending bytes before all entries are compressed.
203
+
204
+ ```typescript
205
+ import { archiveStream } from "omni-compress";
206
+
207
+ const stream = archiveStream(entries, { level: 6 });
208
+ const response = new Response(stream, {
209
+ headers: { "Content-Type": "application/zip" },
210
+ });
211
+ ```
212
+
213
+ **`ArchiveOptions`**
214
+
215
+ | Property | Type | Default | Description |
216
+ | ------------ | --------------------------- | ------- | ---------------------------------------------- |
217
+ | `format` | `'zip'` | `'zip'` | Archive format (only ZIP supported currently) |
218
+ | `level` | `0` – `9` | `6` | fflate deflate level (0 = store, 9 = max compression) |
219
+ | `onProgress` | `(percent: number) => void` | — | Progress callback `0` – `100` |
220
+ | `signal` | `AbortSignal` | — | Cancel — throws `AbortError` |
221
+
222
+ #### `detectFormat(buffer): string | null`
223
+
224
+ Reads the first 16 bytes of a buffer and returns the file's actual format from its magic bytes — not its extension.
225
+
226
+ ```typescript
227
+ import { detectFormat } from "omni-compress";
228
+
229
+ const buffer = await file.arrayBuffer();
230
+ const format = detectFormat(buffer);
231
+ // e.g. 'webp', 'jpeg', 'flac', 'ogg', null (unknown)
232
+ ```
233
+
234
+ Supported signatures: `jpeg`, `png`, `gif`, `webp`, `wav`, `avif`, `flac`, `ogg`, `mp3`, `aac`.
235
+
236
+ ---
237
+
238
+ ### v1.x Legacy API (deprecated)
239
+
240
+ > **`OmniCompressor.process()` is deprecated** as of v2.0. It will continue to work until v3.0 but returns a raw `Blob` instead of the richer `CompressResult`. Migrate to `compressImage()` or `compressAudio()`.
241
+
242
+ ```typescript
243
+ import { OmniCompressor } from "omni-compress";
244
+
245
+ /** @deprecated Use compressImage() or compressAudio() instead */
246
+ const blob = await OmniCompressor.process(file, {
247
+ type: "image",
248
+ format: "webp",
249
+ quality: 0.8,
250
+ });
251
+ ```
252
+
253
+ ---
254
+
255
+ ## Cancellation (AbortSignal)
256
+
257
+ Pass an `AbortSignal` to any compression or archive call to cancel it mid-flight:
258
+
259
+ ```typescript
260
+ const controller = new AbortController();
261
+
262
+ // Cancel after 5 seconds
263
+ setTimeout(() => controller.abort(), 5000);
264
+
265
+ try {
266
+ const result = await compressImage(file, {
267
+ format: "avif",
268
+ signal: controller.signal,
269
+ });
270
+ } catch (err) {
271
+ if (err instanceof AbortError) {
272
+ console.log("Compression was cancelled");
273
+ }
274
+ }
275
+ ```
276
+
277
+ When a browser compression is cancelled, the underlying Web Worker is **terminated** (killing FFmpeg Wasm mid-run) and a fresh worker is created for the next call. On Node.js, the `ffmpeg` child process receives `SIGTERM`.
278
+
279
+ ---
280
+
281
+ ## Error Classes
282
+
283
+ All library errors extend `OmniCompressError` and carry a machine-readable `code` field:
284
+
285
+ ```typescript
286
+ import {
287
+ OmniCompressError,
288
+ FileTooLargeError,
289
+ FormatNotSupportedError,
290
+ InvalidOptionsError,
291
+ AbortError,
292
+ EncoderError,
293
+ } from "omni-compress";
294
+
295
+ try {
296
+ await compressImage(file, { format: "webp" });
297
+ } catch (err) {
298
+ if (err instanceof FileTooLargeError) {
299
+ console.log(err.fileSize, err.maxSize); // bytes
300
+ } else if (err instanceof AbortError) {
301
+ console.log("Cancelled"); // err.code === 'ABORTED'
302
+ } else if (err instanceof FormatNotSupportedError) {
303
+ console.log(err.format); // e.g. 'hevc'
304
+ }
305
+ }
306
+ ```
307
+
308
+ | Error Class | Code | When Thrown |
309
+ | ------------------------ | --------------------- | ----------------------------------------------------------------- |
310
+ | `OmniCompressError` | — | Base class for all library errors |
311
+ | `FileTooLargeError` | `FILE_TOO_LARGE` | Input exceeds 250 MB (browser) — prevents Wasm OOM |
312
+ | `FormatNotSupportedError`| `FORMAT_NOT_SUPPORTED`| Requested format is not valid for the given media type |
313
+ | `InvalidOptionsError` | `INVALID_OPTIONS` | Options object is missing required fields or contains invalid values |
314
+ | `AbortError` | `ABORTED` | `AbortSignal` fired before or during processing |
315
+ | `EncoderError` | `ENCODER_FAILED` | FFmpeg or fflate encoder threw — wraps the underlying cause |
316
+
317
+ ---
318
+
319
+ ## Supported Formats
320
+
321
+ ### Images
322
+
323
+ | Format | Fast Path (OffscreenCanvas) | Heavy Path (FFmpeg Wasm) | Node (OS binary) |
324
+ | ------ | --------------------------- | ------------------------ | ---------------- |
325
+ | WebP | ✅ | ✅ libwebp | ✅ ffmpeg |
326
+ | AVIF | ❌ (not supported by OffscreenCanvas) | ✅ @jsquash/avif (libaom-av1) | ✅ ffmpeg |
327
+ | JPEG | ✅ | ✅ | ✅ ffmpeg |
328
+ | PNG | ✅ | ✅ | ✅ ffmpeg |
329
+ | HEIC | — | ✅ | ✅ ffmpeg |
330
+ | TIFF | — | ✅ | ✅ ffmpeg |
331
+
332
+ ### Audio
333
+
334
+ | Format | Fast Path (WebCodecs) | Heavy Path (FFmpeg Wasm) | Node (OS binary) |
335
+ | -------- | --------------------- | ------------------------ | ---------------- |
336
+ | MP3 | — | ✅ libmp3lame | ✅ ffmpeg |
337
+ | Opus/OGG | ✅ (Opus) | ✅ libopus | ✅ ffmpeg |
338
+ | FLAC | — | ✅ flac | ✅ ffmpeg |
339
+ | WAV | — | ✅ | ✅ ffmpeg |
340
+ | AAC | ✅ | ✅ | ✅ ffmpeg |
341
+
342
+ ### Video
343
+
344
+ | Format | Heavy Path (FFmpeg Wasm) | Node (OS binary) |
345
+ | ------ | ------------------------ | ---------------- |
346
+ | MP4 | ✅ libx264 | ✅ ffmpeg |
347
+ | WebM | ✅ libvpx-vp9 | ✅ ffmpeg |
348
+
349
+ ---
350
+
351
+ ## Architecture
352
+
353
+ ```
354
+ compressImage() / compressAudio() / compressVideo()
355
+
356
+
357
+ ┌─────────┐
358
+ │ Router │ ← Evaluates runtime + format + size
359
+ └────┬────┘
360
+
361
+ ┌────┴────────────────────────────┐
362
+ │ │ │
363
+ ▼ ▼ ▼
364
+ Fast Path Heavy Path Node Adapter
365
+ (Native) (FFmpeg Wasm) (child_process)
366
+ │ │ │
367
+ OffscreenCanvas @ffmpeg/ffmpeg OS ffmpeg binary
368
+ WebCodecs (A/V) Multi-threaded Via ffmpeg-static
369
+ │ │ │
370
+ └────────────────┴────────────────┘
371
+
372
+ ┌───────────┴───────────┐
373
+ │ │
374
+ Main Thread Path Web Worker Path
375
+ (High Speed) (Isolation)
376
+ Files < 4MB Files > 4MB
377
+ Zero-latency Non-blocking
378
+ ```
379
+
380
+ ### Intelligent Routing
381
+
382
+ `omni-compress` includes a smart switching engine that dynamically chooses between the **Main Thread** and **Web Workers**:
383
+
384
+ * **Main Thread Path:** Standard web files (< 4MB) using native Fast Paths run directly on the main thread. This eliminates `postMessage` communication latency (~50-150ms), matching the performance of legacy main-thread-only libraries like `compressorjs`.
385
+ * *Note: AVIF uses a lower 512KB threshold due to higher CPU intensity.*
386
+ * **Web Worker Path:** Large files and all FFmpeg Heavy Path tasks are automatically dispatched to background workers. This ensures that long-running operations never freeze your application's UI.
387
+
388
+
389
+ ---
390
+
391
+ ## Playground & Themes
392
+
393
+ The [Live Demo](https://dharanish-v.github.io/omni-compress/) features a **Neo-Brutalist "Laboratory" UI** with 25 distinct persona-based themes (Shakespeare, Picasso, Aryabhata, etc.) supporting multiple languages with culturally relevant quotes and accurate technical terminology.
394
+
395
+ ---
396
+
397
+ ## Contributing
398
+
399
+ We welcome contributions! Please see the [Contributing Guide](https://github.com/dharanish-v/omni-compress/blob/master/CONTRIBUTING.md) for setup instructions and guidelines.
400
+
401
+ ## License
402
+
403
+ [MIT](LICENSE) &copy; Dharanish V
@@ -0,0 +1,2 @@
1
+ 'use strict';var chunkMGMH7JY3_cjs=require('./chunk-MGMH7JY3.cjs'),child_process=require('child_process'),os=require('os'),path=require('path'),fs=require('fs'),crypto=require('crypto');var j=chunkMGMH7JY3_cjs.b((H,W)=>{W.exports={name:"ffmpeg-static",version:"5.3.0",description:"ffmpeg binaries for macOS, Linux and Windows",scripts:{install:"node install.js",prepublishOnly:"npm run install"},"ffmpeg-static":{"binary-path-env-var":"FFMPEG_BIN","binary-release-tag-env-var":"FFMPEG_BINARY_RELEASE","binary-release-tag":"b6.1.1","binaries-url-env-var":"FFMPEG_BINARIES_URL","executable-base-name":"ffmpeg"},repository:{type:"git",url:"https://github.com/eugeneware/ffmpeg-static"},keywords:["ffmpeg","static","binary","binaries","mac","linux","windows"],authors:["Eugene Ware <eugene@noblesamurai.com>","Jannis R <mail@jannisr.de>"],contributors:["Thefrank (https://github.com/Thefrank)","Emil Sivervik <emil@sivervik.com>"],license:"GPL-3.0-or-later",bugs:{url:"https://github.com/eugeneware/ffmpeg-static/issues"},engines:{node:">=16"},dependencies:{"@derhuerst/http-basic":"^8.2.0","env-paths":"^2.2.0","https-proxy-agent":"^5.0.0",progress:"^2.0.3"},devDependencies:{"any-shell-escape":"^0.1.1"},main:"index.js",files:["index.js","install.js","example.js","types"],types:"types/index.d.ts"};});var O=chunkMGMH7JY3_cjs.b((U,x)=>{var o=j(),{"binary-path-env-var":w,"executable-base-name":S}=o[o.name];if(typeof w!="string")throw new Error(`package.json: invalid/missing ${o.name}.binary-path-env-var entry`);if(typeof S!="string")throw new Error(`package.json: invalid/missing ${o.name}.executable-base-name entry`);if(process.env[w])x.exports=process.env[w];else {v=chunkMGMH7JY3_cjs.a("os"),A=chunkMGMH7JY3_cjs.a("path"),y=Object.assign(Object.create(null),{darwin:["x64","arm64"],freebsd:["x64"],linux:["x64","ia32","arm64","arm"],win32:["x64","ia32"]}),l=process.env.npm_config_platform||v.platform(),P=process.env.npm_config_arch||v.arch();let i=A.join(__dirname,S+(l==="win32"?".exe":""));(!y[l]||y[l].indexOf(P)===-1)&&(i=null),x.exports=i;}var v,A,y,l,P;});var N=chunkMGMH7JY3_cjs.c(O(),1);async function G(i){if(i instanceof ArrayBuffer)return Buffer.from(i);let e=await chunkMGMH7JY3_cjs.j(i);return Buffer.from(e)}async function Z(i,e,f){if(f?.aborted)throw new chunkMGMH7JY3_cjs.h("Compression aborted");let q=await G(i),_=crypto.randomUUID(),d=path.join(os.tmpdir(),`input_${_}`),h=path.join(os.tmpdir(),`output_${_}.${e.format}`),B=N.default||"ffmpeg";chunkMGMH7JY3_cjs.s.debug(`Using FFmpeg binary at: ${B}`);try{await fs.promises.writeFile(d,q);let r=["-y","-i",d];if(e.preserveMetadata?r.push("-map_metadata","0"):r.push("-map_metadata","-1"),e.type==="image"){if(e.maxWidth||e.maxHeight){let a=e.maxWidth||-1,t=e.maxHeight||-1;a!==-1&&t!==-1?r.push("-vf",`scale='min(${a},iw):min(${t},ih):force_original_aspect_ratio=decrease'`):r.push("-vf",`scale=${a}:${t}`);}if(e.format==="webp")r.push("-vcodec","libwebp"),e.quality!==void 0&&r.push("-q:v",Math.floor(e.quality*100).toString());else if(e.format==="avif"){let a=e.quality!==void 0?Math.max(0,Math.min(63,Math.round((1-e.quality)*63))):32;r.push("-vcodec","libaom-av1","-crf",String(a),"-b:v","0","-still-picture","1");}}else if(e.type==="audio")e.channels&&r.push("-ac",e.channels.toString()),e.sampleRate&&r.push("-ar",e.sampleRate.toString()),e.format==="mp3"?r.push("-acodec","libmp3lame","-b:a",e.bitrate||"128k"):e.format==="flac"?r.push("-acodec","flac"):e.format==="opus"?r.push("-acodec","libopus","-b:a",e.bitrate||"128k"):e.format==="aac"&&r.push("-acodec","aac","-b:a",e.bitrate||"128k");else if(e.type==="video"){if(e.maxWidth||e.maxHeight){let a=e.maxWidth||-1,t=e.maxHeight||-1;a!==-1&&t!==-1?r.push("-vf",`scale='min(${a},iw):min(${t},ih):force_original_aspect_ratio=decrease'`):r.push("-vf",`scale=${a}:${t}`);}e.fps&&r.push("-r",e.fps.toString()),e.format==="mp4"?(r.push("-vcodec","libx264","-pix_fmt","yuv420p","-preset","veryfast"),e.videoBitrate?r.push("-b:v",e.videoBitrate):r.push("-crf","28"),r.push("-acodec","aac","-b:a","128k")):e.format==="webm"&&(r.push("-vcodec","libvpx-vp9","-deadline","realtime"),e.videoBitrate&&r.push("-b:v",e.videoBitrate),r.push("-acodec","libopus","-b:a","128k"));}r.push(h),await new Promise((a,t)=>{let c=child_process.spawn(B,r),b=()=>{c.kill("SIGTERM"),t(new chunkMGMH7JY3_cjs.h("Compression aborted"));};f?.addEventListener("abort",b,{once:!0}),c.stderr.on("data",s=>{let E=s.toString();chunkMGMH7JY3_cjs.s.debug(`[OmniCompress:FFmpeg:Node] ${E.trim()}`),E.includes("time=")&&e.onProgress?.(50);}),c.on("close",s=>{f?.removeEventListener("abort",b),!f?.aborted&&(s===0?a():t(new Error(`FFmpeg exited with code ${s}`)));}),c.on("error",s=>{f?.removeEventListener("abort",b),t(new Error(`Failed to start FFmpeg child process: ${s.message}. Ensure ffmpeg is installed or ffmpeg-static is bundled.`));});});let n=await fs.promises.readFile(h),m="";e.type==="image"?m=e.format==="jpg"?"image/jpeg":`image/${e.format}`:e.type==="audio"?m=e.format==="opus"?"audio/ogg":`audio/${e.format}`:m=e.format==="mp4"?"video/mp4":`video/${e.format}`;let I=n.buffer.slice(n.byteOffset,n.byteOffset+n.byteLength);return new Blob([I],{type:m})}finally{try{await fs.promises.unlink(d).catch(()=>{}),await fs.promises.unlink(h).catch(()=>{});}catch(r){chunkMGMH7JY3_cjs.s.warn("Failed to clean up Node.js temporary files:",r);}}}
2
+ exports.processWithNode=Z;
@@ -0,0 +1,2 @@
1
+ import {b,a,c,h,s,j as j$1}from'./chunk-OXXIGMTX.js';import {spawn}from'child_process';import {tmpdir}from'os';import {join}from'path';import {promises}from'fs';import {randomUUID}from'crypto';var j=b((H,W)=>{W.exports={name:"ffmpeg-static",version:"5.3.0",description:"ffmpeg binaries for macOS, Linux and Windows",scripts:{install:"node install.js",prepublishOnly:"npm run install"},"ffmpeg-static":{"binary-path-env-var":"FFMPEG_BIN","binary-release-tag-env-var":"FFMPEG_BINARY_RELEASE","binary-release-tag":"b6.1.1","binaries-url-env-var":"FFMPEG_BINARIES_URL","executable-base-name":"ffmpeg"},repository:{type:"git",url:"https://github.com/eugeneware/ffmpeg-static"},keywords:["ffmpeg","static","binary","binaries","mac","linux","windows"],authors:["Eugene Ware <eugene@noblesamurai.com>","Jannis R <mail@jannisr.de>"],contributors:["Thefrank (https://github.com/Thefrank)","Emil Sivervik <emil@sivervik.com>"],license:"GPL-3.0-or-later",bugs:{url:"https://github.com/eugeneware/ffmpeg-static/issues"},engines:{node:">=16"},dependencies:{"@derhuerst/http-basic":"^8.2.0","env-paths":"^2.2.0","https-proxy-agent":"^5.0.0",progress:"^2.0.3"},devDependencies:{"any-shell-escape":"^0.1.1"},main:"index.js",files:["index.js","install.js","example.js","types"],types:"types/index.d.ts"};});var O=b((U,x)=>{var o=j(),{"binary-path-env-var":w,"executable-base-name":S}=o[o.name];if(typeof w!="string")throw new Error(`package.json: invalid/missing ${o.name}.binary-path-env-var entry`);if(typeof S!="string")throw new Error(`package.json: invalid/missing ${o.name}.executable-base-name entry`);if(process.env[w])x.exports=process.env[w];else {v=a("os"),A=a("path"),y=Object.assign(Object.create(null),{darwin:["x64","arm64"],freebsd:["x64"],linux:["x64","ia32","arm64","arm"],win32:["x64","ia32"]}),l=process.env.npm_config_platform||v.platform(),P=process.env.npm_config_arch||v.arch();let i=A.join(__dirname,S+(l==="win32"?".exe":""));(!y[l]||y[l].indexOf(P)===-1)&&(i=null),x.exports=i;}var v,A,y,l,P;});var N=c(O(),1);async function G(i){if(i instanceof ArrayBuffer)return Buffer.from(i);let e=await j$1(i);return Buffer.from(e)}async function Z(i,e,f){if(f?.aborted)throw new h("Compression aborted");let q=await G(i),_=randomUUID(),d=join(tmpdir(),`input_${_}`),h$1=join(tmpdir(),`output_${_}.${e.format}`),B=N.default||"ffmpeg";s.debug(`Using FFmpeg binary at: ${B}`);try{await promises.writeFile(d,q);let r=["-y","-i",d];if(e.preserveMetadata?r.push("-map_metadata","0"):r.push("-map_metadata","-1"),e.type==="image"){if(e.maxWidth||e.maxHeight){let a=e.maxWidth||-1,t=e.maxHeight||-1;a!==-1&&t!==-1?r.push("-vf",`scale='min(${a},iw):min(${t},ih):force_original_aspect_ratio=decrease'`):r.push("-vf",`scale=${a}:${t}`);}if(e.format==="webp")r.push("-vcodec","libwebp"),e.quality!==void 0&&r.push("-q:v",Math.floor(e.quality*100).toString());else if(e.format==="avif"){let a=e.quality!==void 0?Math.max(0,Math.min(63,Math.round((1-e.quality)*63))):32;r.push("-vcodec","libaom-av1","-crf",String(a),"-b:v","0","-still-picture","1");}}else if(e.type==="audio")e.channels&&r.push("-ac",e.channels.toString()),e.sampleRate&&r.push("-ar",e.sampleRate.toString()),e.format==="mp3"?r.push("-acodec","libmp3lame","-b:a",e.bitrate||"128k"):e.format==="flac"?r.push("-acodec","flac"):e.format==="opus"?r.push("-acodec","libopus","-b:a",e.bitrate||"128k"):e.format==="aac"&&r.push("-acodec","aac","-b:a",e.bitrate||"128k");else if(e.type==="video"){if(e.maxWidth||e.maxHeight){let a=e.maxWidth||-1,t=e.maxHeight||-1;a!==-1&&t!==-1?r.push("-vf",`scale='min(${a},iw):min(${t},ih):force_original_aspect_ratio=decrease'`):r.push("-vf",`scale=${a}:${t}`);}e.fps&&r.push("-r",e.fps.toString()),e.format==="mp4"?(r.push("-vcodec","libx264","-pix_fmt","yuv420p","-preset","veryfast"),e.videoBitrate?r.push("-b:v",e.videoBitrate):r.push("-crf","28"),r.push("-acodec","aac","-b:a","128k")):e.format==="webm"&&(r.push("-vcodec","libvpx-vp9","-deadline","realtime"),e.videoBitrate&&r.push("-b:v",e.videoBitrate),r.push("-acodec","libopus","-b:a","128k"));}r.push(h$1),await new Promise((a,t)=>{let c=spawn(B,r),b=()=>{c.kill("SIGTERM"),t(new h("Compression aborted"));};f?.addEventListener("abort",b,{once:!0}),c.stderr.on("data",s$1=>{let E=s$1.toString();s.debug(`[OmniCompress:FFmpeg:Node] ${E.trim()}`),E.includes("time=")&&e.onProgress?.(50);}),c.on("close",s=>{f?.removeEventListener("abort",b),!f?.aborted&&(s===0?a():t(new Error(`FFmpeg exited with code ${s}`)));}),c.on("error",s=>{f?.removeEventListener("abort",b),t(new Error(`Failed to start FFmpeg child process: ${s.message}. Ensure ffmpeg is installed or ffmpeg-static is bundled.`));});});let n=await promises.readFile(h$1),m="";e.type==="image"?m=e.format==="jpg"?"image/jpeg":`image/${e.format}`:e.type==="audio"?m=e.format==="opus"?"audio/ogg":`audio/${e.format}`:m=e.format==="mp4"?"video/mp4":`video/${e.format}`;let I=n.buffer.slice(n.byteOffset,n.byteOffset+n.byteLength);return new Blob([I],{type:m})}finally{try{await promises.unlink(d).catch(()=>{}),await promises.unlink(h$1).catch(()=>{});}catch(r){s.warn("Failed to clean up Node.js temporary files:",r);}}}
2
+ export{Z as processWithNode};
@@ -0,0 +1 @@
1
+ 'use strict';var chunkMGMH7JY3_cjs=require('./chunk-MGMH7JY3.cjs'),fflate=require('fflate');var _documentCurrentScript=typeof document!=='undefined'?document.currentScript:null;var y={imageWorkerUrl:"",audioWorkerUrl:"",videoWorkerUrl:"",ffmpegCoreUrl:"",ffmpegWasmUrl:"",ffmpegWorkerUrl:"",mainThreadThreshold:4194304,avifMainThreadThreshold:524288};var K=new Set(["webp","jpeg","png","jpg"]),X=new Set(["aac","opus"]),Y=new Set(["mp4","webm"]),k=class{static getEnvironment(){return typeof process<"u"&&process.versions!=null&&process.versions.node?"node":"browser"}static isFastPathSupported(e){if(this.getEnvironment()==="node")return false;let t=e.format.toLowerCase();return e.type==="image"?K.has(t):e.type==="audio"?X.has(t):Y.has(t)}static evaluate(e,t){let o=this.getEnvironment(),a=this.isFastPathSupported(e),i=e.format.toLowerCase(),n=true;if(o==="browser")if(e.useWorker!==void 0)n=e.useWorker;else {let m=i==="avif";if(a||m){let s=m?y.avifMainThreadThreshold:y.mainThreadThreshold;t<s&&(n=false);}}return {env:o,isFastPath:a,shouldUseWorker:n}}};var ee=0,F=new Map,N=typeof SharedArrayBuffer<"u",v=new Map,B=new Map,re=6e4,te=Math.min(4,typeof navigator<"u"&&navigator.hardwareConcurrency||2);function z(r,e){let t=B.get(r);t&&clearTimeout(t);let o=setTimeout(()=>{if(Array.from(F.values()).some(i=>i.worker===r))z(r,e);else {r.terminate();let i=v.get(e)||[];v.set(e,i.filter(n=>n!==r)),B.delete(r);}},re);B.set(r,o);}function oe(r){let e=v.get(r)||[],t=new Set(Array.from(F.values()).map(a=>a.worker)),o=e.find(a=>!t.has(a));if(o)return z(o,r),o;if(e.length<te){let a="";r==="image"?a=y.imageWorkerUrl||new URL("./workers/image.worker.js",(typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('chunk-4VVOIQUC.cjs', document.baseURI).href))).href:r==="audio"?a=y.audioWorkerUrl||new URL("./workers/audio.worker.js",(typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('chunk-4VVOIQUC.cjs', document.baseURI).href))).href:a=y.videoWorkerUrl||new URL("./workers/video.worker.js",(typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('chunk-4VVOIQUC.cjs', document.baseURI).href))).href;let i=new Worker(a,{type:"module"});return i.onmessage=n=>{let{id:m,type:f,buffer:s,error:l,progress:d}=n.data,c=F.get(m);if(c){if(f==="progress"){c.options.onProgress?.(d);return}f==="error"?c.reject(new Error(l)):f==="success"&&c.resolve(s),F.delete(m),z(i,r),C(r);}},i.onerror=n=>{chunkMGMH7JY3_cjs.s.error("Worker error:",n);let m=v.get(r)||[];v.set(r,m.filter(f=>f!==i)),B.delete(i),i.terminate();},e.push(i),v.set(r,e),z(i,r),i}throw new Error("No available workers")}var D=new Map;function $(r){let e=D.get(r);return e||(e=[],D.set(r,e)),e}function C(r){let e=$(r);if(e.length!==0)try{let t=oe(r),o=e.shift();if(o.signal?.aborted){o.reject(new chunkMGMH7JY3_cjs.h("Compression aborted")),C(r);return}ae(t,o.data,o.options,o.isFastPath,o.resolve,o.reject,o.signal);}catch{}}function ae(r,e,t,o,a,i,n){let m=++ee,f=t.type,s=null,l=b=>{s?.(),a(b);},d=b=>{s?.(),i(b);};if(F.set(m,{id:m,options:t,resolve:l,reject:d,worker:r}),n){let b=()=>{F.delete(m),r.terminate();let A=v.get(f)||[];v.set(f,A.filter(O=>O!==r)),B.delete(r),d(new chunkMGMH7JY3_cjs.h("Compression aborted")),C(f);};n.addEventListener("abort",b,{once:true}),s=()=>n.removeEventListener("abort",b);}let c={...t};delete c.onProgress;let u=e instanceof ArrayBuffer?[e]:[];r.postMessage({id:m,buffer:e,options:c,isFastPath:o,ffmpegConfig:{coreUrl:y.ffmpegCoreUrl,wasmUrl:y.ffmpegWasmUrl,workerUrl:y.ffmpegWorkerUrl,mtSupported:N}},u);}function R(r,e,t,o){return new Promise((a,i)=>{if(o?.aborted){i(new chunkMGMH7JY3_cjs.h("Compression aborted"));return}let n=e.type;$(n).push({data:r,options:e,isFastPath:t,signal:o,resolve:a,reject:i}),C(n);})}var j=null;function ie(r,e){return e.format!=="auto"?e.format:e.type==="image"?r.type==="image/avif"?"avif":"webp":e.type==="audio"?r.type==="audio/opus"||r.type==="audio/ogg"?"opus":"mp3":"mp4"}async function h(r,e,t){if(t?.aborted)throw new chunkMGMH7JY3_cjs.h("Compression aborted");let o=e.format;e.format=ie(r,e),o==="auto"&&chunkMGMH7JY3_cjs.s.info(`Auto-format resolved: ${e.format}`,{type:e.type}),chunkMGMH7JY3_cjs.s.info("Starting compression",{type:e.type,format:e.format});let a=k.evaluate(e,r.size);chunkMGMH7JY3_cjs.s.debug("Route evaluated",a);let i=r.size;chunkMGMH7JY3_cjs.n(i,a.env);let n=chunkMGMH7JY3_cjs.l(e.type,e.format);"name"in r&&(e.originalFileName=r.name,chunkMGMH7JY3_cjs.s.debug(`Extracted original filename: ${e.originalFileName}`)),e.onProgress?.(0);let m;if(a.env==="node")chunkMGMH7JY3_cjs.s.info("Executing via Node.js native adapter"),j||(chunkMGMH7JY3_cjs.s.debug("Dynamically loading Node child_process adapter"),j=(await import('./childProcess-MS3KZ27Y.cjs')).processWithNode),m=await j(r,e,t);else {let f;if(a.shouldUseWorker)chunkMGMH7JY3_cjs.s.info(`Executing via Browser Worker pool. Fast path: ${a.isFastPath}`),f=await R(r,e,a.isFastPath,t);else {chunkMGMH7JY3_cjs.s.debug("Converting File/Blob to ArrayBuffer for main-thread execution");let s=await chunkMGMH7JY3_cjs.j(r);try{chunkMGMH7JY3_cjs.s.info("Executing via Main Thread (High-speed path)"),f=await(await import('./mainThread-UJUELO56.cjs')).processOnMainThread(s,e,a.isFastPath,e.onProgress);}catch(l){chunkMGMH7JY3_cjs.s.warn(`Main thread execution failed: ${l.message}. Falling back to Worker.`),f=await R(r,e,a.isFastPath,t);}}m=chunkMGMH7JY3_cjs.k(f,n);}return chunkMGMH7JY3_cjs.s.info("Processing complete"),e.onProgress?.(100),e.strict&&m.size>=r.size?(chunkMGMH7JY3_cjs.s.info("Strict mode: Compressed size exceeds original. Returning original blob.",{compressed:m.size,original:r.size}),r):m}async function fe(r,e={}){if(e.signal?.aborted)throw new chunkMGMH7JY3_cjs.h("Archive aborted");let t={},o=0,a=r.length,i=e.level??6;for(let s=0;s<a;s++){if(e.signal?.aborted)throw new chunkMGMH7JY3_cjs.h("Archive aborted");let l=r[s],d,c=l.name,u=l.data instanceof Uint8Array?new Blob([l.data.buffer]):l.data;if(o+=u.size,e.smartOptimize&&(chunkMGMH7JY3_cjs.o(u)||chunkMGMH7JY3_cjs.p(u))){let b=chunkMGMH7JY3_cjs.o(u),A=M=>{let J=s/a*50,G=M/100*(50/a);e.onProgress?.(Math.round(J+G));},O=b?await h(u,{type:"image",format:u.type==="image/webp"?"avif":"webp",quality:.8,onProgress:A},e.signal):await h(u,{type:"audio",format:u.type==="audio/mpeg"||u.type==="audio/mp3"?"opus":"mp3",bitrate:"128k",onProgress:A},e.signal);d=new Uint8Array(await O.arrayBuffer());let x=b?u.type==="image/webp"?"avif":"webp":u.type==="audio/mpeg"||u.type==="audio/mp3"?"opus":"mp3",P=c.split(".");P.length>1?(P.pop(),c=P.join(".")+"."+x):c=c+"."+x;}else d=new Uint8Array(await u.arrayBuffer()),e.onProgress?.(Math.round((s+1)/a*50));t[c]=[d,{level:i}];}if(e.signal?.aborted)throw new chunkMGMH7JY3_cjs.h("Archive aborted");let n=await new Promise((s,l)=>{let d=()=>l(new chunkMGMH7JY3_cjs.h("Archive aborted"));e.signal?.addEventListener("abort",d,{once:true}),fflate.zip(t,(c,u)=>{e.signal?.removeEventListener("abort",d),c?l(new chunkMGMH7JY3_cjs.i("ZIP compression failed",c)):s(u);});});e.onProgress?.(100);let m=n.buffer.slice(n.byteOffset,n.byteOffset+n.byteLength);return {blob:new Blob([m],{type:"application/zip"}),originalSize:o,compressedSize:n.byteLength,ratio:o>0?n.byteLength/o:1,format:"zip"}}function le(r,e={}){return new ReadableStream({async start(t){try{if(e.signal?.aborted){t.error(new chunkMGMH7JY3_cjs.h("Archive stream aborted"));return}let o=e.level??6,a=new fflate.Zip((n,m,f)=>{if(n){t.error(new chunkMGMH7JY3_cjs.i("ZIP stream compression failed",n));return}t.enqueue(m),f&&t.close();}),i=r.length;for(let n=0;n<i;n++){if(e.signal?.aborted){a.end(),t.error(new chunkMGMH7JY3_cjs.h("Archive stream aborted"));return}let m=r[n],f=m.name,s=m.data instanceof Uint8Array?new Blob([m.data.buffer]):m.data,l;if(e.smartOptimize&&(chunkMGMH7JY3_cjs.o(s)||chunkMGMH7JY3_cjs.p(s))){let c=chunkMGMH7JY3_cjs.o(s),u=x=>{let P=n/i*100,M=x/100*(100/i);e.onProgress?.(Math.round(P+M));},b=c?await h(s,{type:"image",format:s.type==="image/webp"?"avif":"webp",quality:.8,onProgress:u},e.signal):await h(s,{type:"audio",format:s.type==="audio/mpeg"||s.type==="audio/mp3"?"opus":"mp3",bitrate:"128k",onProgress:u},e.signal);l=new Uint8Array(await b.arrayBuffer());let A=c?s.type==="image/webp"?"avif":"webp":s.type==="audio/mpeg"||s.type==="audio/mp3"?"opus":"mp3",O=f.split(".");O.length>1?(O.pop(),f=O.join(".")+"."+A):f=f+"."+A;}else l=new Uint8Array(await s.arrayBuffer()),e.onProgress?.(Math.round((n+1)/i*100));let d=new fflate.ZipDeflate(f,{level:o});a.add(d),d.push(l,!0);}a.end();}catch(o){t.error(o);}}})}var V=new Set(["webp","avif","jpeg","jpg","png","auto"]),Q=new Set(["opus","mp3","flac","wav","aac","ogg","auto"]),ue=new Set(["mp4","webm","auto"]);async function Z(r,e){if(!e||typeof e!="object")throw new chunkMGMH7JY3_cjs.g("Options object is required");let t=(e.format||"auto").toLowerCase();if(!V.has(t))throw new chunkMGMH7JY3_cjs.f(`"${e.format}" is not a supported image format. Supported: webp, avif, jpeg, png`,e.format);if(e.quality!==void 0&&(e.quality<0||e.quality>1))throw new chunkMGMH7JY3_cjs.g(`Quality must be between 0.0 and 1.0. Received: ${e.quality}`);let o=r.size,a={type:"image",format:t,quality:e.quality,maxWidth:e.maxWidth,maxHeight:e.maxHeight,preserveMetadata:e.preserveMetadata,onProgress:e.onProgress,strict:e.strict},i=await h(r,a,e.signal);return {blob:i,originalSize:o,compressedSize:i.size,ratio:o>0?i.size/o:1,format:a.format}}async function je(r,e){if(!e||typeof e!="object")throw new chunkMGMH7JY3_cjs.g("Options object is required");let t=(e.format||"auto").toLowerCase();if(!Q.has(t))throw new chunkMGMH7JY3_cjs.f(`"${e.format}" is not a supported audio format. Supported: opus, mp3, flac, wav, aac`,e.format);let o=r.size,a={type:"audio",format:t,bitrate:e.bitrate,channels:e.channels,sampleRate:e.sampleRate,preserveMetadata:e.preserveMetadata,onProgress:e.onProgress,strict:e.strict},i=await h(r,a,e.signal);return {blob:i,originalSize:o,compressedSize:i.size,ratio:o>0?i.size/o:1,format:a.format}}async function Ie(r,e){if(!e||typeof e!="object")throw new chunkMGMH7JY3_cjs.g("Options object is required");let t=(e.format||"auto").toLowerCase();if(!ue.has(t))throw new chunkMGMH7JY3_cjs.f(`"${e.format}" is not a supported video format. Supported: mp4, webm`,e.format);let o=r.size,a={type:"video",format:t==="auto"?"mp4":t,videoBitrate:e.bitrate,maxWidth:e.maxWidth,maxHeight:e.maxHeight,fps:e.fps,preserveMetadata:e.preserveMetadata,onProgress:e.onProgress,strict:e.strict},i=await h(r,a,e.signal);return {blob:i,originalSize:o,compressedSize:i.size,ratio:o>0?i.size/o:1,format:a.format}}function ce(r){if(!r||typeof r!="object")throw new chunkMGMH7JY3_cjs.g("Options object is required");if(!new Set(["image","audio"]).has(r.type))throw new chunkMGMH7JY3_cjs.g(`Invalid type "${r.type}". Must be "image" or "audio".`);if(!r.format||typeof r.format!="string")throw new chunkMGMH7JY3_cjs.g("A target format string is required");if((r.type==="image"?V:Q).has(r.format.toLowerCase())||chunkMGMH7JY3_cjs.s.warn(`Format "${r.format}" is not a recognized ${r.type} format. Proceeding via Heavy Path.`),r.quality!==void 0&&(r.quality<0||r.quality>1))throw new chunkMGMH7JY3_cjs.g(`Quality must be between 0.0 and 1.0. Received: ${r.quality}`);if(r.maxSizeMB!==void 0&&(typeof r.maxSizeMB!="number"||r.maxSizeMB<=0))throw new chunkMGMH7JY3_cjs.g(`maxSizeMB must be a positive number. Received: ${r.maxSizeMB}`)}var H=class{static async process(e,t){return ce(t),h(e,t)}static setLogLevel(e){chunkMGMH7JY3_cjs.s.setLevel(e);}};var E=class{constructor(e,t={}){this.compress(e,t);}async compress(e,t){let{success:o,error:a,strict:i=true,convertSize:n=5e6,mimeType:m="image/jpeg",...f}=t;try{let s=m.replace("image/","");s==="jpg"&&(s="jpeg"),e.size>n&&s!=="jpeg"&&(s="jpeg");let l=await Z(e,{...f,format:s});i&&l.compressedSize>=l.originalSize?o?.(e):o?.(l.blob);}catch(s){let l=s instanceof Error?s:new Error(String(s));a?a(l):console.error("[OmniCompress:Compat] Compression failed:",l);}}};exports.a=y;exports.b=k;exports.c=N;exports.d=fe;exports.e=le;exports.f=E;exports.g=Z;exports.h=je;exports.i=Ie;exports.j=H;
@@ -0,0 +1 @@
1
+ 'use strict';var c=Object.create;var u=Object.defineProperty;var g=Object.getOwnPropertyDescriptor;var m=Object.getOwnPropertyNames;var d=Object.getPrototypeOf,h=Object.prototype.hasOwnProperty;var v=(r=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(r,{get:(e,n)=>(typeof require<"u"?require:e)[n]}):r)(function(r){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+r+'" is not supported')});var w=(r,e)=>()=>(e||r((e={exports:{}}).exports,e),e.exports);var b=(r,e,n,o)=>{if(e&&typeof e=="object"||typeof e=="function")for(let t of m(e))!h.call(r,t)&&t!==n&&u(r,t,{get:()=>e[t],enumerable:!(o=g(e,t))||o.enumerable});return r};var L=(r,e,n)=>(n=r!=null?c(d(r)):{},b(e||!r||!r.__esModule?u(n,"default",{value:r,enumerable:true}):n,r));var i=class extends Error{code;constructor(e,n){super(e),this.name="OmniCompressError",this.code=n;}},s=class extends i{fileSize;maxSize;constructor(e,n){let o=(e/1024/1024).toFixed(1),t=(n/1024/1024).toFixed(0);super(`File size (${o} MB) exceeds the safe processing limit (${t} MB). Processing this file would likely exhaust WebAssembly memory. Consider reducing the file size before compression.`,"FILE_TOO_LARGE"),this.name="FileTooLargeError",this.fileSize=e,this.maxSize=n;}},l=class extends i{format;constructor(e,n){super(e,"FORMAT_NOT_SUPPORTED"),this.name="FormatNotSupportedError",this.format=n;}},x=class extends i{constructor(e){super(e,"INVALID_OPTIONS"),this.name="InvalidOptionsError";}},f=class extends i{constructor(e="The operation was aborted"){super(e,"ABORTED"),this.name="AbortError";}},p=class extends i{cause;constructor(e,n){super(e,"ENCODER_FAILED"),this.name="EncoderError",this.cause=n;}};async function O(r){return await r.arrayBuffer()}function E(r,e){return new Blob([r],{type:e})}function T(r,e){return r==="image"?e==="jpg"?"image/jpeg":`image/${e}`:r==="audio"?e==="opus"?"audio/ogg":`audio/${e}`:e==="mp4"?"video/mp4":e==="webm"?"video/webm":`video/${e}`}var y={browser:250*1024*1024,node:1/0};function C(r,e){let n=y[e];if(r>n)throw new s(r,n)}function I(r){if(r.type)return r.type.startsWith("image/");if("name"in r){let e=r.name.split(".").pop()?.toLowerCase();return ["jpg","jpeg","png","webp","avif","gif","heic","tiff"].includes(e||"")}return false}function M(r){if(r.type)return r.type.startsWith("audio/");if("name"in r){let e=r.name.split(".").pop()?.toLowerCase();return ["mp3","opus","ogg","wav","flac","aac","m4a"].includes(e||"")}return false}function R(r){if(r.type)return r.type.startsWith("video/");if("name"in r){let e=r.name.split(".").pop()?.toLowerCase();return ["mp4","webm","mov","avi","mkv","m4v"].includes(e||"")}return false}function S(r){if(r.byteLength<12)return null;let e=new Uint8Array(r,0,Math.min(r.byteLength,16));if(e[0]===255&&e[1]===216&&e[2]===255)return "jpeg";if(e[0]===137&&e[1]===80&&e[2]===78&&e[3]===71&&e[4]===13&&e[5]===10&&e[6]===26&&e[7]===10)return "png";if(e[0]===71&&e[1]===73&&e[2]===70&&e[3]===56)return "gif";if(e[0]===82&&e[1]===73&&e[2]===70&&e[3]===70){if(e[8]===87&&e[9]===69&&e[10]===66&&e[11]===80)return "webp";if(e[8]===87&&e[9]===65&&e[10]===86&&e[11]===69)return "wav"}if(e[4]===102&&e[5]===116&&e[6]===121&&e[7]===112){let n=String.fromCharCode(e[8],e[9],e[10],e[11]);if(n==="avif"||n==="avis"||n==="MA1B"||n==="MA1A")return "avif"}return e[0]===102&&e[1]===76&&e[2]===97&&e[3]===67?"flac":e[0]===79&&e[1]===103&&e[2]===103&&e[3]===83?"ogg":e[0]===73&&e[1]===68&&e[2]===51||e[0]===255&&(e[1]&224)===224&&(e[1]&6)!==0?"mp3":e[0]===255&&(e[1]===241||e[1]===249)?"aac":null}var a=class{level="info";setLevel(e){this.level=e;}shouldLog(e){let n=["debug","info","warn","error"];return n.indexOf(e)>=n.indexOf(this.level)}debug(e,...n){this.shouldLog("debug")&&console.debug(`[OmniCompress:DEBUG] ${e}`,...n);}info(e,...n){this.shouldLog("info")&&console.info(`[OmniCompress:INFO] ${e}`,...n);}warn(e,...n){this.shouldLog("warn")&&console.warn(`[OmniCompress:WARN] ${e}`,...n);}error(e,...n){this.shouldLog("error")&&console.error(`[OmniCompress:ERROR] ${e}`,...n);}},_=new a;exports.a=v;exports.b=w;exports.c=L;exports.d=i;exports.e=s;exports.f=l;exports.g=x;exports.h=f;exports.i=p;exports.j=O;exports.k=E;exports.l=T;exports.m=y;exports.n=C;exports.o=I;exports.p=M;exports.q=R;exports.r=S;exports.s=_;
@@ -0,0 +1 @@
1
+ var c=Object.create;var u=Object.defineProperty;var g=Object.getOwnPropertyDescriptor;var m=Object.getOwnPropertyNames;var d=Object.getPrototypeOf,h=Object.prototype.hasOwnProperty;var v=(r=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(r,{get:(e,n)=>(typeof require<"u"?require:e)[n]}):r)(function(r){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+r+'" is not supported')});var w=(r,e)=>()=>(e||r((e={exports:{}}).exports,e),e.exports);var b=(r,e,n,o)=>{if(e&&typeof e=="object"||typeof e=="function")for(let t of m(e))!h.call(r,t)&&t!==n&&u(r,t,{get:()=>e[t],enumerable:!(o=g(e,t))||o.enumerable});return r};var L=(r,e,n)=>(n=r!=null?c(d(r)):{},b(e||!r||!r.__esModule?u(n,"default",{value:r,enumerable:true}):n,r));var i=class extends Error{code;constructor(e,n){super(e),this.name="OmniCompressError",this.code=n;}},s=class extends i{fileSize;maxSize;constructor(e,n){let o=(e/1024/1024).toFixed(1),t=(n/1024/1024).toFixed(0);super(`File size (${o} MB) exceeds the safe processing limit (${t} MB). Processing this file would likely exhaust WebAssembly memory. Consider reducing the file size before compression.`,"FILE_TOO_LARGE"),this.name="FileTooLargeError",this.fileSize=e,this.maxSize=n;}},l=class extends i{format;constructor(e,n){super(e,"FORMAT_NOT_SUPPORTED"),this.name="FormatNotSupportedError",this.format=n;}},x=class extends i{constructor(e){super(e,"INVALID_OPTIONS"),this.name="InvalidOptionsError";}},f=class extends i{constructor(e="The operation was aborted"){super(e,"ABORTED"),this.name="AbortError";}},p=class extends i{cause;constructor(e,n){super(e,"ENCODER_FAILED"),this.name="EncoderError",this.cause=n;}};async function O(r){return await r.arrayBuffer()}function E(r,e){return new Blob([r],{type:e})}function T(r,e){return r==="image"?e==="jpg"?"image/jpeg":`image/${e}`:r==="audio"?e==="opus"?"audio/ogg":`audio/${e}`:e==="mp4"?"video/mp4":e==="webm"?"video/webm":`video/${e}`}var y={browser:250*1024*1024,node:1/0};function C(r,e){let n=y[e];if(r>n)throw new s(r,n)}function I(r){if(r.type)return r.type.startsWith("image/");if("name"in r){let e=r.name.split(".").pop()?.toLowerCase();return ["jpg","jpeg","png","webp","avif","gif","heic","tiff"].includes(e||"")}return false}function M(r){if(r.type)return r.type.startsWith("audio/");if("name"in r){let e=r.name.split(".").pop()?.toLowerCase();return ["mp3","opus","ogg","wav","flac","aac","m4a"].includes(e||"")}return false}function R(r){if(r.type)return r.type.startsWith("video/");if("name"in r){let e=r.name.split(".").pop()?.toLowerCase();return ["mp4","webm","mov","avi","mkv","m4v"].includes(e||"")}return false}function S(r){if(r.byteLength<12)return null;let e=new Uint8Array(r,0,Math.min(r.byteLength,16));if(e[0]===255&&e[1]===216&&e[2]===255)return "jpeg";if(e[0]===137&&e[1]===80&&e[2]===78&&e[3]===71&&e[4]===13&&e[5]===10&&e[6]===26&&e[7]===10)return "png";if(e[0]===71&&e[1]===73&&e[2]===70&&e[3]===56)return "gif";if(e[0]===82&&e[1]===73&&e[2]===70&&e[3]===70){if(e[8]===87&&e[9]===69&&e[10]===66&&e[11]===80)return "webp";if(e[8]===87&&e[9]===65&&e[10]===86&&e[11]===69)return "wav"}if(e[4]===102&&e[5]===116&&e[6]===121&&e[7]===112){let n=String.fromCharCode(e[8],e[9],e[10],e[11]);if(n==="avif"||n==="avis"||n==="MA1B"||n==="MA1A")return "avif"}return e[0]===102&&e[1]===76&&e[2]===97&&e[3]===67?"flac":e[0]===79&&e[1]===103&&e[2]===103&&e[3]===83?"ogg":e[0]===73&&e[1]===68&&e[2]===51||e[0]===255&&(e[1]&224)===224&&(e[1]&6)!==0?"mp3":e[0]===255&&(e[1]===241||e[1]===249)?"aac":null}var a=class{level="info";setLevel(e){this.level=e;}shouldLog(e){let n=["debug","info","warn","error"];return n.indexOf(e)>=n.indexOf(this.level)}debug(e,...n){this.shouldLog("debug")&&console.debug(`[OmniCompress:DEBUG] ${e}`,...n);}info(e,...n){this.shouldLog("info")&&console.info(`[OmniCompress:INFO] ${e}`,...n);}warn(e,...n){this.shouldLog("warn")&&console.warn(`[OmniCompress:WARN] ${e}`,...n);}error(e,...n){this.shouldLog("error")&&console.error(`[OmniCompress:ERROR] ${e}`,...n);}},_=new a;export{v as a,w as b,L as c,i as d,s as e,l as f,x as g,f as h,p as i,O as j,E as k,T as l,y as m,C as n,I as o,M as p,R as q,S as r,_ as s};
@@ -0,0 +1 @@
1
+ import {h as h$1,o,p,i,g,f,s,n,l,j as j$1,k as k$1}from'./chunk-OXXIGMTX.js';import {zip,Zip,ZipDeflate}from'fflate';var y={imageWorkerUrl:"",audioWorkerUrl:"",videoWorkerUrl:"",ffmpegCoreUrl:"",ffmpegWasmUrl:"",ffmpegWorkerUrl:"",mainThreadThreshold:4194304,avifMainThreadThreshold:524288};var K=new Set(["webp","jpeg","png","jpg"]),X=new Set(["aac","opus"]),Y=new Set(["mp4","webm"]),k=class{static getEnvironment(){return typeof process<"u"&&process.versions!=null&&process.versions.node?"node":"browser"}static isFastPathSupported(e){if(this.getEnvironment()==="node")return false;let t=e.format.toLowerCase();return e.type==="image"?K.has(t):e.type==="audio"?X.has(t):Y.has(t)}static evaluate(e,t){let o=this.getEnvironment(),a=this.isFastPathSupported(e),i=e.format.toLowerCase(),n=true;if(o==="browser")if(e.useWorker!==void 0)n=e.useWorker;else {let m=i==="avif";if(a||m){let s=m?y.avifMainThreadThreshold:y.mainThreadThreshold;t<s&&(n=false);}}return {env:o,isFastPath:a,shouldUseWorker:n}}};var ee=0,F=new Map,N=typeof SharedArrayBuffer<"u",v=new Map,B=new Map,re=6e4,te=Math.min(4,typeof navigator<"u"&&navigator.hardwareConcurrency||2);function z(r,e){let t=B.get(r);t&&clearTimeout(t);let o=setTimeout(()=>{if(Array.from(F.values()).some(i=>i.worker===r))z(r,e);else {r.terminate();let i=v.get(e)||[];v.set(e,i.filter(n=>n!==r)),B.delete(r);}},re);B.set(r,o);}function oe(r){let e=v.get(r)||[],t=new Set(Array.from(F.values()).map(a=>a.worker)),o=e.find(a=>!t.has(a));if(o)return z(o,r),o;if(e.length<te){let a="";r==="image"?a=y.imageWorkerUrl||new URL("./workers/image.worker.js",import.meta.url).href:r==="audio"?a=y.audioWorkerUrl||new URL("./workers/audio.worker.js",import.meta.url).href:a=y.videoWorkerUrl||new URL("./workers/video.worker.js",import.meta.url).href;let i=new Worker(a,{type:"module"});return i.onmessage=n=>{let{id:m,type:f,buffer:s,error:l,progress:d}=n.data,c=F.get(m);if(c){if(f==="progress"){c.options.onProgress?.(d);return}f==="error"?c.reject(new Error(l)):f==="success"&&c.resolve(s),F.delete(m),z(i,r),C(r);}},i.onerror=n=>{s.error("Worker error:",n);let m=v.get(r)||[];v.set(r,m.filter(f=>f!==i)),B.delete(i),i.terminate();},e.push(i),v.set(r,e),z(i,r),i}throw new Error("No available workers")}var D=new Map;function $(r){let e=D.get(r);return e||(e=[],D.set(r,e)),e}function C(r){let e=$(r);if(e.length!==0)try{let t=oe(r),o=e.shift();if(o.signal?.aborted){o.reject(new h$1("Compression aborted")),C(r);return}ae(t,o.data,o.options,o.isFastPath,o.resolve,o.reject,o.signal);}catch{}}function ae(r,e,t,o,a,i,n){let m=++ee,f=t.type,s=null,l=b=>{s?.(),a(b);},d=b=>{s?.(),i(b);};if(F.set(m,{id:m,options:t,resolve:l,reject:d,worker:r}),n){let b=()=>{F.delete(m),r.terminate();let A=v.get(f)||[];v.set(f,A.filter(O=>O!==r)),B.delete(r),d(new h$1("Compression aborted")),C(f);};n.addEventListener("abort",b,{once:true}),s=()=>n.removeEventListener("abort",b);}let c={...t};delete c.onProgress;let u=e instanceof ArrayBuffer?[e]:[];r.postMessage({id:m,buffer:e,options:c,isFastPath:o,ffmpegConfig:{coreUrl:y.ffmpegCoreUrl,wasmUrl:y.ffmpegWasmUrl,workerUrl:y.ffmpegWorkerUrl,mtSupported:N}},u);}function R(r,e,t,o){return new Promise((a,i)=>{if(o?.aborted){i(new h$1("Compression aborted"));return}let n=e.type;$(n).push({data:r,options:e,isFastPath:t,signal:o,resolve:a,reject:i}),C(n);})}var j=null;function ie(r,e){return e.format!=="auto"?e.format:e.type==="image"?r.type==="image/avif"?"avif":"webp":e.type==="audio"?r.type==="audio/opus"||r.type==="audio/ogg"?"opus":"mp3":"mp4"}async function h(r,e,t){if(t?.aborted)throw new h$1("Compression aborted");let o=e.format;e.format=ie(r,e),o==="auto"&&s.info(`Auto-format resolved: ${e.format}`,{type:e.type}),s.info("Starting compression",{type:e.type,format:e.format});let a=k.evaluate(e,r.size);s.debug("Route evaluated",a);let i=r.size;n(i,a.env);let n$1=l(e.type,e.format);"name"in r&&(e.originalFileName=r.name,s.debug(`Extracted original filename: ${e.originalFileName}`)),e.onProgress?.(0);let m;if(a.env==="node")s.info("Executing via Node.js native adapter"),j||(s.debug("Dynamically loading Node child_process adapter"),j=(await import('./childProcess-YP2BUBY7.js')).processWithNode),m=await j(r,e,t);else {let f;if(a.shouldUseWorker)s.info(`Executing via Browser Worker pool. Fast path: ${a.isFastPath}`),f=await R(r,e,a.isFastPath,t);else {s.debug("Converting File/Blob to ArrayBuffer for main-thread execution");let s$1=await j$1(r);try{s.info("Executing via Main Thread (High-speed path)"),f=await(await import('./mainThread-2WMDRJ4L.js')).processOnMainThread(s$1,e,a.isFastPath,e.onProgress);}catch(l){s.warn(`Main thread execution failed: ${l.message}. Falling back to Worker.`),f=await R(r,e,a.isFastPath,t);}}m=k$1(f,n$1);}return s.info("Processing complete"),e.onProgress?.(100),e.strict&&m.size>=r.size?(s.info("Strict mode: Compressed size exceeds original. Returning original blob.",{compressed:m.size,original:r.size}),r):m}async function fe(r,e={}){if(e.signal?.aborted)throw new h$1("Archive aborted");let t={},o$1=0,a=r.length,i$1=e.level??6;for(let s=0;s<a;s++){if(e.signal?.aborted)throw new h$1("Archive aborted");let l=r[s],d,c=l.name,u=l.data instanceof Uint8Array?new Blob([l.data.buffer]):l.data;if(o$1+=u.size,e.smartOptimize&&(o(u)||p(u))){let b=o(u),A=M=>{let J=s/a*50,G=M/100*(50/a);e.onProgress?.(Math.round(J+G));},O=b?await h(u,{type:"image",format:u.type==="image/webp"?"avif":"webp",quality:.8,onProgress:A},e.signal):await h(u,{type:"audio",format:u.type==="audio/mpeg"||u.type==="audio/mp3"?"opus":"mp3",bitrate:"128k",onProgress:A},e.signal);d=new Uint8Array(await O.arrayBuffer());let x=b?u.type==="image/webp"?"avif":"webp":u.type==="audio/mpeg"||u.type==="audio/mp3"?"opus":"mp3",P=c.split(".");P.length>1?(P.pop(),c=P.join(".")+"."+x):c=c+"."+x;}else d=new Uint8Array(await u.arrayBuffer()),e.onProgress?.(Math.round((s+1)/a*50));t[c]=[d,{level:i$1}];}if(e.signal?.aborted)throw new h$1("Archive aborted");let n=await new Promise((s,l)=>{let d=()=>l(new h$1("Archive aborted"));e.signal?.addEventListener("abort",d,{once:true}),zip(t,(c,u)=>{e.signal?.removeEventListener("abort",d),c?l(new i("ZIP compression failed",c)):s(u);});});e.onProgress?.(100);let m=n.buffer.slice(n.byteOffset,n.byteOffset+n.byteLength);return {blob:new Blob([m],{type:"application/zip"}),originalSize:o$1,compressedSize:n.byteLength,ratio:o$1>0?n.byteLength/o$1:1,format:"zip"}}function le(r,e={}){return new ReadableStream({async start(t){try{if(e.signal?.aborted){t.error(new h$1("Archive stream aborted"));return}let o$1=e.level??6,a=new Zip((n,m,f)=>{if(n){t.error(new i("ZIP stream compression failed",n));return}t.enqueue(m),f&&t.close();}),i$1=r.length;for(let n=0;n<i$1;n++){if(e.signal?.aborted){a.end(),t.error(new h$1("Archive stream aborted"));return}let m=r[n],f=m.name,s=m.data instanceof Uint8Array?new Blob([m.data.buffer]):m.data,l;if(e.smartOptimize&&(o(s)||p(s))){let c=o(s),u=x=>{let P=n/i$1*100,M=x/100*(100/i$1);e.onProgress?.(Math.round(P+M));},b=c?await h(s,{type:"image",format:s.type==="image/webp"?"avif":"webp",quality:.8,onProgress:u},e.signal):await h(s,{type:"audio",format:s.type==="audio/mpeg"||s.type==="audio/mp3"?"opus":"mp3",bitrate:"128k",onProgress:u},e.signal);l=new Uint8Array(await b.arrayBuffer());let A=c?s.type==="image/webp"?"avif":"webp":s.type==="audio/mpeg"||s.type==="audio/mp3"?"opus":"mp3",O=f.split(".");O.length>1?(O.pop(),f=O.join(".")+"."+A):f=f+"."+A;}else l=new Uint8Array(await s.arrayBuffer()),e.onProgress?.(Math.round((n+1)/i$1*100));let d=new ZipDeflate(f,{level:o$1});a.add(d),d.push(l,!0);}a.end();}catch(o){t.error(o);}}})}var V=new Set(["webp","avif","jpeg","jpg","png","auto"]),Q=new Set(["opus","mp3","flac","wav","aac","ogg","auto"]),ue=new Set(["mp4","webm","auto"]);async function Z(r,e){if(!e||typeof e!="object")throw new g("Options object is required");let t=(e.format||"auto").toLowerCase();if(!V.has(t))throw new f(`"${e.format}" is not a supported image format. Supported: webp, avif, jpeg, png`,e.format);if(e.quality!==void 0&&(e.quality<0||e.quality>1))throw new g(`Quality must be between 0.0 and 1.0. Received: ${e.quality}`);let o=r.size,a={type:"image",format:t,quality:e.quality,maxWidth:e.maxWidth,maxHeight:e.maxHeight,preserveMetadata:e.preserveMetadata,onProgress:e.onProgress,strict:e.strict},i=await h(r,a,e.signal);return {blob:i,originalSize:o,compressedSize:i.size,ratio:o>0?i.size/o:1,format:a.format}}async function je(r,e){if(!e||typeof e!="object")throw new g("Options object is required");let t=(e.format||"auto").toLowerCase();if(!Q.has(t))throw new f(`"${e.format}" is not a supported audio format. Supported: opus, mp3, flac, wav, aac`,e.format);let o=r.size,a={type:"audio",format:t,bitrate:e.bitrate,channels:e.channels,sampleRate:e.sampleRate,preserveMetadata:e.preserveMetadata,onProgress:e.onProgress,strict:e.strict},i=await h(r,a,e.signal);return {blob:i,originalSize:o,compressedSize:i.size,ratio:o>0?i.size/o:1,format:a.format}}async function Ie(r,e){if(!e||typeof e!="object")throw new g("Options object is required");let t=(e.format||"auto").toLowerCase();if(!ue.has(t))throw new f(`"${e.format}" is not a supported video format. Supported: mp4, webm`,e.format);let o=r.size,a={type:"video",format:t==="auto"?"mp4":t,videoBitrate:e.bitrate,maxWidth:e.maxWidth,maxHeight:e.maxHeight,fps:e.fps,preserveMetadata:e.preserveMetadata,onProgress:e.onProgress,strict:e.strict},i=await h(r,a,e.signal);return {blob:i,originalSize:o,compressedSize:i.size,ratio:o>0?i.size/o:1,format:a.format}}function ce(r){if(!r||typeof r!="object")throw new g("Options object is required");if(!new Set(["image","audio"]).has(r.type))throw new g(`Invalid type "${r.type}". Must be "image" or "audio".`);if(!r.format||typeof r.format!="string")throw new g("A target format string is required");if((r.type==="image"?V:Q).has(r.format.toLowerCase())||s.warn(`Format "${r.format}" is not a recognized ${r.type} format. Proceeding via Heavy Path.`),r.quality!==void 0&&(r.quality<0||r.quality>1))throw new g(`Quality must be between 0.0 and 1.0. Received: ${r.quality}`);if(r.maxSizeMB!==void 0&&(typeof r.maxSizeMB!="number"||r.maxSizeMB<=0))throw new g(`maxSizeMB must be a positive number. Received: ${r.maxSizeMB}`)}var H=class{static async process(e,t){return ce(t),h(e,t)}static setLogLevel(e){s.setLevel(e);}};var E=class{constructor(e,t={}){this.compress(e,t);}async compress(e,t){let{success:o,error:a,strict:i=true,convertSize:n=5e6,mimeType:m="image/jpeg",...f}=t;try{let s=m.replace("image/","");s==="jpg"&&(s="jpeg"),e.size>n&&s!=="jpeg"&&(s="jpeg");let l=await Z(e,{...f,format:s});i&&l.compressedSize>=l.originalSize?o?.(e):o?.(l.blob);}catch(s){let l=s instanceof Error?s:new Error(String(s));a?a(l):console.error("[OmniCompress:Compat] Compression failed:",l);}}};export{y as a,k as b,N as c,fe as d,le as e,E as f,Z as g,je as h,Ie as i,H as j};
@@ -0,0 +1 @@
1
+ 'use strict';var chunk4VVOIQUC_cjs=require('../chunk-4VVOIQUC.cjs');require('../chunk-MGMH7JY3.cjs');module.exports=chunk4VVOIQUC_cjs.f;
@@ -0,0 +1 @@
1
+ export { g as CompressorOptions, e as default } from '../compressor-BVD2z3r0.cjs';
@@ -0,0 +1 @@
1
+ export { g as CompressorOptions, e as default } from '../compressor-BVD2z3r0.js';
@@ -0,0 +1 @@
1
+ export{f as default}from'../chunk-SHYTLD6H.js';import'../chunk-OXXIGMTX.js';