squoosh_oxipng.js 3.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", {
  3. value: true
  4. });
  5. exports.optimise = optimise;
  6. exports.cleanup = cleanup;
  7. exports.default = void 0;
  8. let wasm;
  9. let cachedTextDecoder = new TextDecoder("utf-8", {
  10. ignoreBOM: true,
  11. fatal: true
  12. });
  13. cachedTextDecoder.decode();
  14. let cachegetUint8Memory0 = null;
  15. function getUint8Memory0() {
  16. if (cachegetUint8Memory0 === null || cachegetUint8Memory0.buffer !== wasm.memory.buffer) {
  17. cachegetUint8Memory0 = new Uint8Array(wasm.memory.buffer);
  18. }
  19. return cachegetUint8Memory0;
  20. }
  21. function getStringFromWasm0(ptr, len) {
  22. return cachedTextDecoder.decode(getUint8Memory0().subarray(ptr, ptr + len));
  23. }
  24. let WASM_VECTOR_LEN = 0;
  25. function passArray8ToWasm0(arg, malloc) {
  26. const ptr = malloc(arg.length * 1);
  27. getUint8Memory0().set(arg, ptr / 1);
  28. WASM_VECTOR_LEN = arg.length;
  29. return ptr;
  30. }
  31. let cachegetInt32Memory0 = null;
  32. function getInt32Memory0() {
  33. if (cachegetInt32Memory0 === null || cachegetInt32Memory0.buffer !== wasm.memory.buffer) {
  34. cachegetInt32Memory0 = new Int32Array(wasm.memory.buffer);
  35. }
  36. return cachegetInt32Memory0;
  37. }
  38. function getArrayU8FromWasm0(ptr, len) {
  39. return getUint8Memory0().subarray(ptr / 1, ptr / 1 + len);
  40. }
  41. function optimise(data, level, interlace) {
  42. try {
  43. const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
  44. var ptr0 = passArray8ToWasm0(data, wasm.__wbindgen_malloc);
  45. var len0 = WASM_VECTOR_LEN;
  46. wasm.optimise(retptr, ptr0, len0, level, interlace);
  47. var r0 = getInt32Memory0()[retptr / 4 + 0];
  48. var r1 = getInt32Memory0()[retptr / 4 + 1];
  49. var v1 = getArrayU8FromWasm0(r0, r1).slice();
  50. wasm.__wbindgen_free(r0, r1 * 1);
  51. return v1;
  52. } finally{
  53. wasm.__wbindgen_add_to_stack_pointer(16);
  54. }
  55. }
  56. async function load(module, imports) {
  57. if (typeof Response === "function" && module instanceof Response) {
  58. if (typeof WebAssembly.instantiateStreaming === "function") {
  59. return await WebAssembly.instantiateStreaming(module, imports);
  60. }
  61. const bytes = await module.arrayBuffer();
  62. return await WebAssembly.instantiate(bytes, imports);
  63. } else {
  64. const instance = await WebAssembly.instantiate(module, imports);
  65. if (instance instanceof WebAssembly.Instance) {
  66. return {
  67. instance,
  68. module
  69. };
  70. } else {
  71. return instance;
  72. }
  73. }
  74. }
  75. async function init(input) {
  76. const imports = {};
  77. imports.wbg = {};
  78. imports.wbg.__wbindgen_throw = function(arg0, arg1) {
  79. throw new Error(getStringFromWasm0(arg0, arg1));
  80. };
  81. if (typeof input === "string" || typeof Request === "function" && input instanceof Request || typeof URL === "function" && input instanceof URL) {
  82. input = fetch(input);
  83. }
  84. const { instance , module } = await load(await input, imports);
  85. wasm = instance.exports;
  86. init.__wbindgen_wasm_module = module;
  87. return wasm;
  88. }
  89. var _default = init;
  90. exports.default = _default;
  91. function cleanup() {
  92. wasm = null;
  93. cachegetUint8Memory0 = null;
  94. cachegetInt32Memory0 = null;
  95. }
  96. //# sourceMappingURL=squoosh_oxipng.js.map