wasm-image-optimization 1.2.6 → 1.2.9

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.
@@ -106,7 +106,7 @@ var init_libImage = __esm({
106
106
  runtimeInitialized = true;
107
107
  if (!Module2["noFSInit"] && !FS.initialized) FS.init();
108
108
  TTY.init();
109
- wasmExports["ea"]();
109
+ wasmExports["fa"]();
110
110
  FS.ignorePermissions = false;
111
111
  }
112
112
  function postRun() {
@@ -203,9 +203,9 @@ var init_libImage = __esm({
203
203
  async function createWasm() {
204
204
  function receiveInstance(instance, module) {
205
205
  wasmExports = instance.exports;
206
- wasmMemory = wasmExports["da"];
206
+ wasmMemory = wasmExports["ea"];
207
207
  updateMemoryViews();
208
- wasmTable = wasmExports["fa"];
208
+ wasmTable = wasmExports["ga"];
209
209
  removeRunDependency("wasm-instantiate");
210
210
  return wasmExports;
211
211
  }
@@ -887,12 +887,12 @@ var init_libImage = __esm({
887
887
  if (canWrite) mode |= 146;
888
888
  return mode;
889
889
  };
890
- var FS = { root: null, mounts: [], devices: {}, streams: [], nextInode: 1, nameTable: null, currentPath: "/", initialized: false, ignorePermissions: true, ErrnoError: class {
890
+ var FS = { root: null, mounts: [], devices: {}, streams: [], nextInode: 1, nameTable: null, currentPath: "/", initialized: false, ignorePermissions: true, filesystems: null, syncFSRequests: 0, readFiles: {}, ErrnoError: class {
891
891
  name = "ErrnoError";
892
892
  constructor(errno) {
893
893
  this.errno = errno;
894
894
  }
895
- }, filesystems: null, syncFSRequests: 0, readFiles: {}, FSStream: class {
895
+ }, FSStream: class {
896
896
  shared = {};
897
897
  get object() {
898
898
  return this.node;
@@ -1916,6 +1916,7 @@ var init_libImage = __esm({
1916
1916
  try {
1917
1917
  FS.mkdir(current);
1918
1918
  } catch (e) {
1919
+ if (e.errno != 20) throw e;
1919
1920
  }
1920
1921
  parent = current;
1921
1922
  }
@@ -2546,7 +2547,7 @@ var init_libImage = __esm({
2546
2547
  name = readLatin1String(name);
2547
2548
  registerType(rawType, { name, fromWireType: (value) => value, toWireType: (destructors, value) => value, argPackAdvance: GenericWireTypeSize, readValueFromPointer: floatReadValueFromPointer(name, size), destructorFunction: null });
2548
2549
  };
2549
- var createNamedFunction = (name, body) => Object.defineProperty(body, "name", { value: name });
2550
+ var createNamedFunction = (name, func) => Object.defineProperty(func, "name", { value: name });
2550
2551
  var runDestructors = (destructors) => {
2551
2552
  while (destructors.length) {
2552
2553
  var ptr = destructors.pop();
@@ -3660,16 +3661,16 @@ var init_libImage = __esm({
3660
3661
  Module2["setCanvasSize"] = Browser.setCanvasSize;
3661
3662
  Module2["getUserMedia"] = Browser.getUserMedia;
3662
3663
  Module2["createContext"] = Browser.createContext;
3663
- var wasmImports = { a: ___assert_fail, s: ___cxa_throw, B: ___syscall_fcntl64, N: ___syscall_ioctl, O: ___syscall_openat, Q: __abort_js, E: __embind_register_bigint, Y: __embind_register_bool, W: __embind_register_emval, D: __embind_register_float, q: __embind_register_function, j: __embind_register_integer, f: __embind_register_memory_view, X: __embind_register_std_string, v: __embind_register_std_wstring, Z: __embind_register_void, F: __emscripten_throw_longjmp, i: __emval_decref, o: __emval_new_cstring, ca: __emval_new_object, n: __emval_set_property, p: __emval_take_value, H: __localtime_js, I: __tzset_js, P: _emscripten_date_now, y: _emscripten_get_now, V: _emscripten_get_preloaded_image_data_from_FILE, S: _emscripten_has_asyncify, G: _emscripten_resize_heap, R: _emscripten_sleep, K: _environ_get, L: _environ_sizes_get, T: _exit, z: _fd_close, M: _fd_read, J: _fd_seek, A: _fd_write, e: invoke_ii, c: invoke_iii, l: invoke_iiii, m: invoke_iiiii, U: invoke_iiiiii, t: invoke_iiiiiiiii, w: invoke_iiiiiiiiii, ba: invoke_iiiiiiiiiiii, aa: invoke_iiiijj, C: invoke_ji, u: invoke_jiji, d: invoke_vi, g: invoke_vii, h: invoke_viii, b: invoke_viiii, k: invoke_viiiii, r: invoke_viiiiiii, $: invoke_viiiiiiii, x: invoke_viiiiiiiii, _: invoke_viiiiiiiiiii };
3664
+ var wasmImports = { a: ___assert_fail, s: ___cxa_throw, A: ___syscall_fcntl64, N: ___syscall_ioctl, O: ___syscall_openat, Q: __abort_js, E: __embind_register_bigint, Y: __embind_register_bool, W: __embind_register_emval, D: __embind_register_float, q: __embind_register_function, j: __embind_register_integer, f: __embind_register_memory_view, X: __embind_register_std_string, v: __embind_register_std_wstring, Z: __embind_register_void, F: __emscripten_throw_longjmp, i: __emval_decref, o: __emval_new_cstring, da: __emval_new_object, n: __emval_set_property, p: __emval_take_value, H: __localtime_js, I: __tzset_js, P: _emscripten_date_now, x: _emscripten_get_now, V: _emscripten_get_preloaded_image_data_from_FILE, S: _emscripten_has_asyncify, G: _emscripten_resize_heap, R: _emscripten_sleep, K: _environ_get, L: _environ_sizes_get, T: _exit, y: _fd_close, M: _fd_read, J: _fd_seek, z: _fd_write, e: invoke_ii, c: invoke_iii, l: invoke_iiii, m: invoke_iiiii, U: invoke_iiiiii, t: invoke_iiiiiiiii, B: invoke_iiiiiiiiii, aa: invoke_iiiiiiiiiii, ca: invoke_iiiiiiiiiiii, ba: invoke_iiiijj, C: invoke_ji, u: invoke_jiji, d: invoke_vi, g: invoke_vii, h: invoke_viii, b: invoke_viiii, k: invoke_viiiii, r: invoke_viiiiiii, $: invoke_viiiiiiii, w: invoke_viiiiiiiii, _: invoke_viiiiiiiiiii };
3664
3665
  var wasmExports = await createWasm();
3665
- var ___wasm_call_ctors = wasmExports["ea"];
3666
- var _malloc = wasmExports["ga"];
3667
- var _free = wasmExports["ha"];
3668
- var ___getTypeName = wasmExports["ia"];
3669
- var _fileno = wasmExports["ja"];
3670
- var _setThrew = wasmExports["ka"];
3671
- var __emscripten_stack_restore = wasmExports["la"];
3672
- var _emscripten_stack_get_current = wasmExports["ma"];
3666
+ var ___wasm_call_ctors = wasmExports["fa"];
3667
+ var _malloc = wasmExports["ha"];
3668
+ var _free = wasmExports["ia"];
3669
+ var ___getTypeName = wasmExports["ja"];
3670
+ var _fileno = wasmExports["ka"];
3671
+ var _setThrew = wasmExports["la"];
3672
+ var __emscripten_stack_restore = wasmExports["ma"];
3673
+ var _emscripten_stack_get_current = wasmExports["na"];
3673
3674
  function invoke_viiiiiiiii(index, a1, a2, a3, a4, a5, a6, a7, a8, a9) {
3674
3675
  var sp = stackSave();
3675
3676
  try {
@@ -3800,10 +3801,10 @@ var init_libImage = __esm({
3800
3801
  _setThrew(1, 0);
3801
3802
  }
3802
3803
  }
3803
- function invoke_iiiiiiiiii(index, a1, a2, a3, a4, a5, a6, a7, a8, a9) {
3804
+ function invoke_iiiiiiiiiii(index, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10) {
3804
3805
  var sp = stackSave();
3805
3806
  try {
3806
- return getWasmTableEntry(index)(a1, a2, a3, a4, a5, a6, a7, a8, a9);
3807
+ return getWasmTableEntry(index)(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10);
3807
3808
  } catch (e) {
3808
3809
  stackRestore(sp);
3809
3810
  if (e !== e + 0) throw e;
@@ -3862,6 +3863,16 @@ var init_libImage = __esm({
3862
3863
  _setThrew(1, 0);
3863
3864
  }
3864
3865
  }
3866
+ function invoke_iiiiiiiiii(index, a1, a2, a3, a4, a5, a6, a7, a8, a9) {
3867
+ var sp = stackSave();
3868
+ try {
3869
+ return getWasmTableEntry(index)(a1, a2, a3, a4, a5, a6, a7, a8, a9);
3870
+ } catch (e) {
3871
+ stackRestore(sp);
3872
+ if (e !== e + 0) throw e;
3873
+ _setThrew(1, 0);
3874
+ }
3875
+ }
3865
3876
  function invoke_iiiiii(index, a1, a2, a3, a4, a5) {
3866
3877
  var sp = stackSave();
3867
3878
  try {
@@ -3962,8 +3973,16 @@ var result = (result2, releaseResult) => {
3962
3973
  releaseResult();
3963
3974
  return r;
3964
3975
  };
3965
- var _optimizeImage = async ({ image, width = 0, height = 0, quality = 100, format = "avif", libImage: libImage2 }) => _optimizeImageExt({ image, width, height, quality, format, libImage: libImage2 }).then((r) => r?.data);
3966
- var _optimizeImageExt = async ({ image, width = 0, height = 0, quality = 100, format = "avif", libImage: libImage2 }) => libImage2.then(({ optimize, releaseResult }) => result(optimize(image, width, height, quality, format), releaseResult));
3976
+ var _optimizeImage = async ({ image, width = 0, height = 0, quality = 100, format = "avif", speed = 6, libImage: libImage2 }) => _optimizeImageExt({
3977
+ image,
3978
+ width,
3979
+ height,
3980
+ quality,
3981
+ format,
3982
+ speed,
3983
+ libImage: libImage2
3984
+ }).then((r) => r?.data);
3985
+ var _optimizeImageExt = async ({ image, width = 0, height = 0, quality = 100, format = "avif", speed = 6, libImage: libImage2 }) => libImage2.then(({ optimize, releaseResult }) => result(optimize(image, width, height, quality, format, speed), releaseResult));
3967
3986
 
3968
3987
  // dist/next-web-worker/_web-worker.js
3969
3988
  var libImage = Promise.resolve().then(() => (init_libImage(), libImage_exports)).then((m) => m.default({}));
@@ -119,7 +119,7 @@
119
119
  runtimeInitialized = true;
120
120
  if (!Module2["noFSInit"] && !FS.initialized) FS.init();
121
121
  TTY.init();
122
- wasmExports["ea"]();
122
+ wasmExports["fa"]();
123
123
  FS.ignorePermissions = false;
124
124
  }
125
125
  function postRun() {
@@ -213,9 +213,9 @@
213
213
  async function createWasm() {
214
214
  function receiveInstance(instance, module2) {
215
215
  wasmExports = instance.exports;
216
- wasmMemory = wasmExports["da"];
216
+ wasmMemory = wasmExports["ea"];
217
217
  updateMemoryViews();
218
- wasmTable = wasmExports["fa"];
218
+ wasmTable = wasmExports["ga"];
219
219
  removeRunDependency("wasm-instantiate");
220
220
  return wasmExports;
221
221
  }
@@ -897,12 +897,12 @@
897
897
  if (canWrite) mode |= 146;
898
898
  return mode;
899
899
  };
900
- var FS = { root: null, mounts: [], devices: {}, streams: [], nextInode: 1, nameTable: null, currentPath: "/", initialized: false, ignorePermissions: true, ErrnoError: class {
900
+ var FS = { root: null, mounts: [], devices: {}, streams: [], nextInode: 1, nameTable: null, currentPath: "/", initialized: false, ignorePermissions: true, filesystems: null, syncFSRequests: 0, readFiles: {}, ErrnoError: class {
901
901
  name = "ErrnoError";
902
902
  constructor(errno) {
903
903
  this.errno = errno;
904
904
  }
905
- }, filesystems: null, syncFSRequests: 0, readFiles: {}, FSStream: class {
905
+ }, FSStream: class {
906
906
  shared = {};
907
907
  get object() {
908
908
  return this.node;
@@ -1926,6 +1926,7 @@
1926
1926
  try {
1927
1927
  FS.mkdir(current);
1928
1928
  } catch (e) {
1929
+ if (e.errno != 20) throw e;
1929
1930
  }
1930
1931
  parent = current;
1931
1932
  }
@@ -2556,7 +2557,7 @@
2556
2557
  name = readLatin1String(name);
2557
2558
  registerType(rawType, { name, fromWireType: (value) => value, toWireType: (destructors, value) => value, argPackAdvance: GenericWireTypeSize, readValueFromPointer: floatReadValueFromPointer(name, size), destructorFunction: null });
2558
2559
  };
2559
- var createNamedFunction = (name, body) => Object.defineProperty(body, "name", { value: name });
2560
+ var createNamedFunction = (name, func) => Object.defineProperty(func, "name", { value: name });
2560
2561
  var runDestructors = (destructors) => {
2561
2562
  while (destructors.length) {
2562
2563
  var ptr = destructors.pop();
@@ -3670,16 +3671,16 @@
3670
3671
  Module2["setCanvasSize"] = Browser.setCanvasSize;
3671
3672
  Module2["getUserMedia"] = Browser.getUserMedia;
3672
3673
  Module2["createContext"] = Browser.createContext;
3673
- var wasmImports = { a: ___assert_fail, s: ___cxa_throw, B: ___syscall_fcntl64, N: ___syscall_ioctl, O: ___syscall_openat, Q: __abort_js, E: __embind_register_bigint, Y: __embind_register_bool, W: __embind_register_emval, D: __embind_register_float, q: __embind_register_function, j: __embind_register_integer, f: __embind_register_memory_view, X: __embind_register_std_string, v: __embind_register_std_wstring, Z: __embind_register_void, F: __emscripten_throw_longjmp, i: __emval_decref, o: __emval_new_cstring, ca: __emval_new_object, n: __emval_set_property, p: __emval_take_value, H: __localtime_js, I: __tzset_js, P: _emscripten_date_now, y: _emscripten_get_now, V: _emscripten_get_preloaded_image_data_from_FILE, S: _emscripten_has_asyncify, G: _emscripten_resize_heap, R: _emscripten_sleep, K: _environ_get, L: _environ_sizes_get, T: _exit, z: _fd_close, M: _fd_read, J: _fd_seek, A: _fd_write, e: invoke_ii, c: invoke_iii, l: invoke_iiii, m: invoke_iiiii, U: invoke_iiiiii, t: invoke_iiiiiiiii, w: invoke_iiiiiiiiii, ba: invoke_iiiiiiiiiiii, aa: invoke_iiiijj, C: invoke_ji, u: invoke_jiji, d: invoke_vi, g: invoke_vii, h: invoke_viii, b: invoke_viiii, k: invoke_viiiii, r: invoke_viiiiiii, $: invoke_viiiiiiii, x: invoke_viiiiiiiii, _: invoke_viiiiiiiiiii };
3674
+ var wasmImports = { a: ___assert_fail, s: ___cxa_throw, A: ___syscall_fcntl64, N: ___syscall_ioctl, O: ___syscall_openat, Q: __abort_js, E: __embind_register_bigint, Y: __embind_register_bool, W: __embind_register_emval, D: __embind_register_float, q: __embind_register_function, j: __embind_register_integer, f: __embind_register_memory_view, X: __embind_register_std_string, v: __embind_register_std_wstring, Z: __embind_register_void, F: __emscripten_throw_longjmp, i: __emval_decref, o: __emval_new_cstring, da: __emval_new_object, n: __emval_set_property, p: __emval_take_value, H: __localtime_js, I: __tzset_js, P: _emscripten_date_now, x: _emscripten_get_now, V: _emscripten_get_preloaded_image_data_from_FILE, S: _emscripten_has_asyncify, G: _emscripten_resize_heap, R: _emscripten_sleep, K: _environ_get, L: _environ_sizes_get, T: _exit, y: _fd_close, M: _fd_read, J: _fd_seek, z: _fd_write, e: invoke_ii, c: invoke_iii, l: invoke_iiii, m: invoke_iiiii, U: invoke_iiiiii, t: invoke_iiiiiiiii, B: invoke_iiiiiiiiii, aa: invoke_iiiiiiiiiii, ca: invoke_iiiiiiiiiiii, ba: invoke_iiiijj, C: invoke_ji, u: invoke_jiji, d: invoke_vi, g: invoke_vii, h: invoke_viii, b: invoke_viiii, k: invoke_viiiii, r: invoke_viiiiiii, $: invoke_viiiiiiii, w: invoke_viiiiiiiii, _: invoke_viiiiiiiiiii };
3674
3675
  var wasmExports = await createWasm();
3675
- var ___wasm_call_ctors = wasmExports["ea"];
3676
- var _malloc = wasmExports["ga"];
3677
- var _free = wasmExports["ha"];
3678
- var ___getTypeName = wasmExports["ia"];
3679
- var _fileno = wasmExports["ja"];
3680
- var _setThrew = wasmExports["ka"];
3681
- var __emscripten_stack_restore = wasmExports["la"];
3682
- var _emscripten_stack_get_current = wasmExports["ma"];
3676
+ var ___wasm_call_ctors = wasmExports["fa"];
3677
+ var _malloc = wasmExports["ha"];
3678
+ var _free = wasmExports["ia"];
3679
+ var ___getTypeName = wasmExports["ja"];
3680
+ var _fileno = wasmExports["ka"];
3681
+ var _setThrew = wasmExports["la"];
3682
+ var __emscripten_stack_restore = wasmExports["ma"];
3683
+ var _emscripten_stack_get_current = wasmExports["na"];
3683
3684
  function invoke_viiiiiiiii(index, a1, a2, a3, a4, a5, a6, a7, a8, a9) {
3684
3685
  var sp = stackSave();
3685
3686
  try {
@@ -3810,10 +3811,10 @@
3810
3811
  _setThrew(1, 0);
3811
3812
  }
3812
3813
  }
3813
- function invoke_iiiiiiiiii(index, a1, a2, a3, a4, a5, a6, a7, a8, a9) {
3814
+ function invoke_iiiiiiiiiii(index, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10) {
3814
3815
  var sp = stackSave();
3815
3816
  try {
3816
- return getWasmTableEntry(index)(a1, a2, a3, a4, a5, a6, a7, a8, a9);
3817
+ return getWasmTableEntry(index)(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10);
3817
3818
  } catch (e) {
3818
3819
  stackRestore(sp);
3819
3820
  if (e !== e + 0) throw e;
@@ -3872,6 +3873,16 @@
3872
3873
  _setThrew(1, 0);
3873
3874
  }
3874
3875
  }
3876
+ function invoke_iiiiiiiiii(index, a1, a2, a3, a4, a5, a6, a7, a8, a9) {
3877
+ var sp = stackSave();
3878
+ try {
3879
+ return getWasmTableEntry(index)(a1, a2, a3, a4, a5, a6, a7, a8, a9);
3880
+ } catch (e) {
3881
+ stackRestore(sp);
3882
+ if (e !== e + 0) throw e;
3883
+ _setThrew(1, 0);
3884
+ }
3885
+ }
3875
3886
  function invoke_iiiiii(index, a1, a2, a3, a4, a5) {
3876
3887
  var sp = stackSave();
3877
3888
  try {
@@ -3976,8 +3987,16 @@
3976
3987
  releaseResult();
3977
3988
  return r;
3978
3989
  };
3979
- var _optimizeImage = async ({ image, width = 0, height = 0, quality = 100, format = "avif", libImage: libImage2 }) => _optimizeImageExt({ image, width, height, quality, format, libImage: libImage2 }).then((r) => r?.data);
3980
- var _optimizeImageExt = async ({ image, width = 0, height = 0, quality = 100, format = "avif", libImage: libImage2 }) => libImage2.then(({ optimize, releaseResult }) => result(optimize(image, width, height, quality, format), releaseResult));
3990
+ var _optimizeImage = async ({ image, width = 0, height = 0, quality = 100, format = "avif", speed = 6, libImage: libImage2 }) => _optimizeImageExt({
3991
+ image,
3992
+ width,
3993
+ height,
3994
+ quality,
3995
+ format,
3996
+ speed,
3997
+ libImage: libImage2
3998
+ }).then((r) => r?.data);
3999
+ var _optimizeImageExt = async ({ image, width = 0, height = 0, quality = 100, format = "avif", speed = 6, libImage: libImage2 }) => libImage2.then(({ optimize, releaseResult }) => result(optimize(image, width, height, quality, format, speed), releaseResult));
3981
4000
 
3982
4001
  // dist/vite-web-worker/_web-worker.js
3983
4002
  var libImage = Promise.resolve().then(() => __toESM(require_libImage())).then((m) => m.default({}));
@@ -5,11 +5,12 @@ export type OptimizeParams = {
5
5
  height?: number;
6
6
  quality?: number;
7
7
  format?: "jpeg" | "png" | "webp" | "avif";
8
+ speed?: number;
8
9
  };
9
- export declare const _optimizeImage: ({ image, width, height, quality, format, libImage, }: OptimizeParams & {
10
+ export declare const _optimizeImage: ({ image, width, height, quality, format, speed, libImage, }: OptimizeParams & {
10
11
  libImage: Promise<ModuleType>;
11
12
  }) => Promise<Uint8Array<ArrayBuffer> | undefined>;
12
- export declare const _optimizeImageExt: ({ image, width, height, quality, format, libImage, }: OptimizeParams & {
13
+ export declare const _optimizeImageExt: ({ image, width, height, quality, format, speed, libImage, }: OptimizeParams & {
13
14
  libImage: Promise<ModuleType>;
14
15
  }) => Promise<{
15
16
  data: Uint8Array<ArrayBuffer>;
@@ -5,6 +5,14 @@ const result = (result, releaseResult) => {
5
5
  releaseResult();
6
6
  return r;
7
7
  };
8
- export const _optimizeImage = async ({ image, width = 0, height = 0, quality = 100, format = "avif", libImage, }) => _optimizeImageExt({ image, width, height, quality, format, libImage }).then((r) => r?.data);
9
- export const _optimizeImageExt = async ({ image, width = 0, height = 0, quality = 100, format = "avif", libImage, }) => libImage.then(({ optimize, releaseResult }) => result(optimize(image, width, height, quality, format), releaseResult));
8
+ export const _optimizeImage = async ({ image, width = 0, height = 0, quality = 100, format = "avif", speed = 6, libImage, }) => _optimizeImageExt({
9
+ image,
10
+ width,
11
+ height,
12
+ quality,
13
+ format,
14
+ speed,
15
+ libImage,
16
+ }).then((r) => r?.data);
17
+ export const _optimizeImageExt = async ({ image, width = 0, height = 0, quality = 100, format = "avif", speed = 6, libImage, }) => libImage.then(({ optimize, releaseResult }) => result(optimize(image, width, height, quality, format, speed), releaseResult));
10
18
  //# sourceMappingURL=optimizeImage.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"optimizeImage.js","sourceRoot":"","sources":["../../src/lib/optimizeImage.ts"],"names":[],"mappings":"AAUA,MAAM,MAAM,GAAG,CACb,MAAsD,EACtD,aAAyB,EACzB,EAAE;IACF,MAAM,CAAC,GAAG,MAAM;QACd,CAAC,CAAC,EAAE,GAAG,MAAM,EAAE,IAAI,EAAE,UAAU,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE;QACnD,CAAC,CAAC,SAAS,CAAC;IACd,aAAa,EAAE,CAAC;IAChB,OAAO,CAAC,CAAC;AACX,CAAC,CAAC;AACF,MAAM,CAAC,MAAM,cAAc,GAAG,KAAK,EAAE,EACnC,KAAK,EACL,KAAK,GAAG,CAAC,EACT,MAAM,GAAG,CAAC,EACV,OAAO,GAAG,GAAG,EACb,MAAM,GAAG,MAAM,EACf,QAAQ,GAGT,EAAE,EAAE,CACH,iBAAiB,CAAC,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,CAAC,CAAC,IAAI,CACzE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,EAAE,IAAI,CACf,CAAC;AAEJ,MAAM,CAAC,MAAM,iBAAiB,GAAG,KAAK,EAAE,EACtC,KAAK,EACL,KAAK,GAAG,CAAC,EACT,MAAM,GAAG,CAAC,EACV,OAAO,GAAG,GAAG,EACb,MAAM,GAAG,MAAM,EACf,QAAQ,GAGT,EAAE,EAAE,CACH,QAAQ,CAAC,IAAI,CAAC,CAAC,EAAE,QAAQ,EAAE,aAAa,EAAE,EAAE,EAAE,CAC5C,MAAM,CAAC,QAAQ,CAAC,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,CAAC,EAAE,aAAa,CAAC,CACvE,CAAC","sourcesContent":["import { type ModuleType } from \"../esm/libImage.js\";\n\nexport type OptimizeParams = {\n image: BufferSource | string; // The input image data\n width?: number; // The desired output width (optional)\n height?: number; // The desired output height (optional)\n quality?: number; // The desired output quality (0-100, optional)\n format?: \"jpeg\" | \"png\" | \"webp\" | \"avif\"; // The desired output format (optional)\n};\n\nconst result = (\n result: ReturnType<ModuleType[\"optimize\"]> | undefined,\n releaseResult: () => void,\n) => {\n const r = result\n ? { ...result, data: Uint8Array.from(result.data) }\n : undefined;\n releaseResult();\n return r;\n};\nexport const _optimizeImage = async ({\n image,\n width = 0,\n height = 0,\n quality = 100,\n format = \"avif\",\n libImage,\n}: OptimizeParams & {\n libImage: Promise<ModuleType>;\n}) =>\n _optimizeImageExt({ image, width, height, quality, format, libImage }).then(\n (r) => r?.data,\n );\n\nexport const _optimizeImageExt = async ({\n image,\n width = 0,\n height = 0,\n quality = 100,\n format = \"avif\",\n libImage,\n}: OptimizeParams & {\n libImage: Promise<ModuleType>;\n}) =>\n libImage.then(({ optimize, releaseResult }) =>\n result(optimize(image, width, height, quality, format), releaseResult),\n );\n"]}
1
+ {"version":3,"file":"optimizeImage.js","sourceRoot":"","sources":["../../src/lib/optimizeImage.ts"],"names":[],"mappings":"AAWA,MAAM,MAAM,GAAG,CACb,MAAsD,EACtD,aAAyB,EACzB,EAAE;IACF,MAAM,CAAC,GAAG,MAAM;QACd,CAAC,CAAC,EAAE,GAAG,MAAM,EAAE,IAAI,EAAE,UAAU,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE;QACnD,CAAC,CAAC,SAAS,CAAC;IACd,aAAa,EAAE,CAAC;IAChB,OAAO,CAAC,CAAC;AACX,CAAC,CAAC;AACF,MAAM,CAAC,MAAM,cAAc,GAAG,KAAK,EAAE,EACnC,KAAK,EACL,KAAK,GAAG,CAAC,EACT,MAAM,GAAG,CAAC,EACV,OAAO,GAAG,GAAG,EACb,MAAM,GAAG,MAAM,EACf,KAAK,GAAG,CAAC,EACT,QAAQ,GAGT,EAAE,EAAE,CACH,iBAAiB,CAAC;IAChB,KAAK;IACL,KAAK;IACL,MAAM;IACN,OAAO;IACP,MAAM;IACN,KAAK;IACL,QAAQ;CACT,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC;AAE1B,MAAM,CAAC,MAAM,iBAAiB,GAAG,KAAK,EAAE,EACtC,KAAK,EACL,KAAK,GAAG,CAAC,EACT,MAAM,GAAG,CAAC,EACV,OAAO,GAAG,GAAG,EACb,MAAM,GAAG,MAAM,EACf,KAAK,GAAG,CAAC,EACT,QAAQ,GAGT,EAAE,EAAE,CACH,QAAQ,CAAC,IAAI,CAAC,CAAC,EAAE,QAAQ,EAAE,aAAa,EAAE,EAAE,EAAE,CAC5C,MAAM,CACJ,QAAQ,CAAC,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,KAAK,CAAC,EACtD,aAAa,CACd,CACF,CAAC","sourcesContent":["import { type ModuleType } from \"../esm/libImage.js\";\n\nexport type OptimizeParams = {\n image: BufferSource | string; // The input image data\n width?: number; // The desired output width (optional)\n height?: number; // The desired output height (optional)\n quality?: number; // The desired output quality (0-100, optional)\n format?: \"jpeg\" | \"png\" | \"webp\" | \"avif\"; // The desired output format (optional)\n speed?: number; // The desired speed (0-10, Slow-Fast, Optional)\n};\n\nconst result = (\n result: ReturnType<ModuleType[\"optimize\"]> | undefined,\n releaseResult: () => void\n) => {\n const r = result\n ? { ...result, data: Uint8Array.from(result.data) }\n : undefined;\n releaseResult();\n return r;\n};\nexport const _optimizeImage = async ({\n image,\n width = 0,\n height = 0,\n quality = 100,\n format = \"avif\",\n speed = 6,\n libImage,\n}: OptimizeParams & {\n libImage: Promise<ModuleType>;\n}) =>\n _optimizeImageExt({\n image,\n width,\n height,\n quality,\n format,\n speed,\n libImage,\n }).then((r) => r?.data);\n\nexport const _optimizeImageExt = async ({\n image,\n width = 0,\n height = 0,\n quality = 100,\n format = \"avif\",\n speed = 6,\n libImage,\n}: OptimizeParams & {\n libImage: Promise<ModuleType>;\n}) =>\n libImage.then(({ optimize, releaseResult }) =>\n result(\n optimize(image, width, height, quality, format, speed),\n releaseResult\n )\n );\n"]}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "wasm-image-optimization",
3
3
  "description": "Optimize images with wasm on edge runtime",
4
- "version": "1.2.6",
4
+ "version": "1.2.9",
5
5
  "scripts": {
6
6
  "test": "yarn ts-node test",
7
7
  "lint:fix": "eslint --fix src/ && prettier -w src",
@@ -18,7 +18,7 @@
18
18
  "types": "./dist/next-web-worker/index.d.ts",
19
19
  "browser": "./dist/next-web-worker/index.js",
20
20
  "edge-light": "./dist/esm/index.js",
21
- "default": "./dist/vite/dummy.js"
21
+ "default": "./dist/dummy/index.js"
22
22
  },
23
23
  "./node": {
24
24
  "types": "./dist/cjs/node/index.d.ts",
@@ -27,8 +27,8 @@
27
27
  "./vite": {
28
28
  "types": "./dist/vite/index.d.ts",
29
29
  "browser": "./dist/vite/index.js",
30
- "node": "./dist/vite/dummy.js",
31
- "default": "./dist/vite/dummy.js"
30
+ "node": "./dist/dummy/index.js",
31
+ "default": "./dist/dummy/index.js"
32
32
  },
33
33
  "./vite-plugin": {
34
34
  "types": "./dist/vite-plugin/index.d.ts",
@@ -37,7 +37,7 @@
37
37
  "./web-worker": {
38
38
  "types": "./dist/vite-web-worker/index.d.ts",
39
39
  "browser": "./dist/vite-web-worker/index.js",
40
- "node": "./dist/vite/dummy.js"
40
+ "node": "./dist/dummy/index.js"
41
41
  },
42
42
  "./node-worker": {
43
43
  "types": "./dist/cjs/node/cjs-worker.d.ts",
@@ -1,2 +0,0 @@
1
- export declare const optimizeImage: null;
2
- export declare const optimizeImageExt: null;
@@ -1,3 +0,0 @@
1
- export const optimizeImage = null;
2
- export const optimizeImageExt = null;
3
- //# sourceMappingURL=dummy.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"dummy.js","sourceRoot":"","sources":["../../src/vite/dummy.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,aAAa,GAAG,IAAI,CAAC;AAClC,MAAM,CAAC,MAAM,gBAAgB,GAAG,IAAI,CAAC","sourcesContent":["export const optimizeImage = null;\nexport const optimizeImageExt = null;\n"]}