@pbk20191/icodec 0.7.0 → 0.9.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/README.md +68 -50
- package/dist/avif-dec.d.ts +14 -0
- package/dist/avif-dec.js +296 -2
- package/dist/avif-dec.wasm +0 -0
- package/dist/avif-enc.d.ts +30 -0
- package/dist/avif-enc.js +298 -2
- package/dist/avif-enc.wasm +0 -0
- package/dist/heic-dec.d.ts +14 -0
- package/dist/heic-dec.js +317 -2
- package/dist/heic-dec.wasm +0 -0
- package/dist/heic-enc.d.ts +26 -0
- package/dist/heic-enc.js +364 -2
- package/dist/heic-enc.wasm +0 -0
- package/dist/jxl-dec.d.ts +14 -0
- package/dist/jxl-dec.js +296 -2
- package/dist/jxl-dec.wasm +0 -0
- package/dist/jxl-enc.d.ts +37 -0
- package/dist/jxl-enc.js +298 -2
- package/dist/jxl-enc.wasm +0 -0
- package/dist/mozjpeg.d.ts +34 -0
- package/dist/mozjpeg.js +298 -2
- package/dist/mozjpeg.wasm +0 -0
- package/dist/pngquant.d.ts +48 -0
- package/dist/pngquant.js +242 -258
- package/dist/pngquant_bg.wasm +0 -0
- package/dist/qoi.d.ts +15 -0
- package/dist/qoi.js +296 -2
- package/dist/qoi.wasm +0 -0
- package/dist/vvic-dec.d.ts +14 -0
- package/dist/vvic-dec.js +327 -0
- package/dist/vvic-dec.wasm +0 -0
- package/dist/vvic-enc.d.ts +20 -0
- package/dist/vvic-enc.js +343 -0
- package/dist/vvic-enc.wasm +0 -0
- package/dist/webp-dec.d.ts +14 -0
- package/dist/webp-dec.js +296 -2
- package/dist/webp-dec.wasm +0 -0
- package/dist/webp-enc.d.ts +50 -0
- package/dist/webp-enc.js +301 -2
- package/dist/webp-enc.wasm +0 -0
- package/dist/wp2-dec.d.ts +14 -0
- package/dist/wp2-dec.js +296 -2
- package/dist/wp2-dec.wasm +0 -0
- package/dist/wp2-enc.d.ts +27 -0
- package/dist/wp2-enc.js +298 -2
- package/dist/wp2-enc.wasm +0 -0
- package/lib/avif.d.ts +5 -3
- package/lib/common.d.ts +4 -1
- package/lib/common.js +10 -3
- package/lib/heic.d.ts +3 -3
- package/lib/index.d.ts +10 -9
- package/lib/index.js +1 -0
- package/lib/jpeg.d.ts +4 -2
- package/lib/jpeg.js +4 -0
- package/lib/jxl.d.ts +3 -3
- package/lib/node.d.ts +16 -0
- package/lib/node.js +31 -37
- package/lib/png.d.ts +3 -3
- package/lib/qoi.d.ts +4 -3
- package/lib/qoi.js +2 -1
- package/lib/vvic.d.ts +25 -0
- package/lib/vvic.js +30 -0
- package/lib/webp.d.ts +5 -4
- package/lib/wp2.d.ts +4 -3
- package/lib/wp2.js +1 -0
- package/package.json +15 -8
- package/types/wasm_type.d.ts +57 -0
- package/versions.json +1 -1
package/dist/pngquant.js
CHANGED
|
@@ -1,42 +1,178 @@
|
|
|
1
|
-
|
|
1
|
+
/* @ts-self-types="./pngquant.d.ts" */
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
let numBytesDecoded = 0;
|
|
18
|
-
function decodeText(ptr, len) {
|
|
19
|
-
numBytesDecoded += len;
|
|
20
|
-
if (numBytesDecoded >= MAX_SAFARI_DECODE_BYTES) {
|
|
21
|
-
cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
|
|
22
|
-
cachedTextDecoder.decode();
|
|
23
|
-
numBytesDecoded = len;
|
|
24
|
-
}
|
|
25
|
-
return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
|
|
3
|
+
/**
|
|
4
|
+
* @param {Uint8Array} data
|
|
5
|
+
* @param {number} width
|
|
6
|
+
* @param {number} height
|
|
7
|
+
* @param {any} options
|
|
8
|
+
* @returns {Uint8Array}
|
|
9
|
+
*/
|
|
10
|
+
export function optimize(data, width, height, options) {
|
|
11
|
+
const ptr0 = passArray8ToWasm0(data, wasm.__wbindgen_malloc);
|
|
12
|
+
const len0 = WASM_VECTOR_LEN;
|
|
13
|
+
const ret = wasm.optimize(ptr0, len0, width, height, options);
|
|
14
|
+
var v2 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
15
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
16
|
+
return v2;
|
|
26
17
|
}
|
|
27
18
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
19
|
+
/**
|
|
20
|
+
* Decode PNG image into 8-bit RGBA data, return only the buffer and width,
|
|
21
|
+
* but height can be calculated by `data.byteLength / width / 4`
|
|
22
|
+
* @param {Uint8Array} data
|
|
23
|
+
* @returns {Array<any>}
|
|
24
|
+
*/
|
|
25
|
+
export function png_to_rgba(data) {
|
|
26
|
+
const ptr0 = passArray8ToWasm0(data, wasm.__wbindgen_malloc);
|
|
27
|
+
const len0 = WASM_VECTOR_LEN;
|
|
28
|
+
const ret = wasm.png_to_rgba(ptr0, len0);
|
|
29
|
+
return ret;
|
|
31
30
|
}
|
|
32
31
|
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
32
|
+
/**
|
|
33
|
+
* @param {Uint8Array} data
|
|
34
|
+
* @param {number} width
|
|
35
|
+
* @param {number} height
|
|
36
|
+
* @param {any} options
|
|
37
|
+
* @returns {Uint8Array}
|
|
38
|
+
*/
|
|
39
|
+
export function quantize(data, width, height, options) {
|
|
40
|
+
const ptr0 = passArray8ToWasm0(data, wasm.__wbindgen_malloc);
|
|
41
|
+
const len0 = WASM_VECTOR_LEN;
|
|
42
|
+
const ret = wasm.quantize(ptr0, len0, width, height, options);
|
|
43
|
+
var v2 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
44
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
45
|
+
return v2;
|
|
36
46
|
}
|
|
37
47
|
|
|
38
|
-
function
|
|
39
|
-
|
|
48
|
+
function __wbg_get_imports() {
|
|
49
|
+
const import0 = {
|
|
50
|
+
__proto__: null,
|
|
51
|
+
__wbg_Error_83742b46f01ce22d: function(arg0, arg1) {
|
|
52
|
+
const ret = Error(getStringFromWasm0(arg0, arg1));
|
|
53
|
+
return ret;
|
|
54
|
+
},
|
|
55
|
+
__wbg_Number_a5a435bd7bbec835: function(arg0) {
|
|
56
|
+
const ret = Number(arg0);
|
|
57
|
+
return ret;
|
|
58
|
+
},
|
|
59
|
+
__wbg___wbindgen_boolean_get_c0f3f60bac5a78d1: function(arg0) {
|
|
60
|
+
const v = arg0;
|
|
61
|
+
const ret = typeof(v) === 'boolean' ? v : undefined;
|
|
62
|
+
return isLikeNone(ret) ? 0xFFFFFF : ret ? 1 : 0;
|
|
63
|
+
},
|
|
64
|
+
__wbg___wbindgen_debug_string_5398f5bb970e0daa: function(arg0, arg1) {
|
|
65
|
+
const ret = debugString(arg1);
|
|
66
|
+
const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
67
|
+
const len1 = WASM_VECTOR_LEN;
|
|
68
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
|
|
69
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
|
|
70
|
+
},
|
|
71
|
+
__wbg___wbindgen_in_41dbb8413020e076: function(arg0, arg1) {
|
|
72
|
+
const ret = arg0 in arg1;
|
|
73
|
+
return ret;
|
|
74
|
+
},
|
|
75
|
+
__wbg___wbindgen_is_object_781bc9f159099513: function(arg0) {
|
|
76
|
+
const val = arg0;
|
|
77
|
+
const ret = typeof(val) === 'object' && val !== null;
|
|
78
|
+
return ret;
|
|
79
|
+
},
|
|
80
|
+
__wbg___wbindgen_is_undefined_52709e72fb9f179c: function(arg0) {
|
|
81
|
+
const ret = arg0 === undefined;
|
|
82
|
+
return ret;
|
|
83
|
+
},
|
|
84
|
+
__wbg___wbindgen_jsval_loose_eq_5bcc3bed3c69e72b: function(arg0, arg1) {
|
|
85
|
+
const ret = arg0 == arg1;
|
|
86
|
+
return ret;
|
|
87
|
+
},
|
|
88
|
+
__wbg___wbindgen_number_get_34bb9d9dcfa21373: function(arg0, arg1) {
|
|
89
|
+
const obj = arg1;
|
|
90
|
+
const ret = typeof(obj) === 'number' ? obj : undefined;
|
|
91
|
+
getDataViewMemory0().setFloat64(arg0 + 8 * 1, isLikeNone(ret) ? 0 : ret, true);
|
|
92
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 0, !isLikeNone(ret), true);
|
|
93
|
+
},
|
|
94
|
+
__wbg___wbindgen_string_get_395e606bd0ee4427: function(arg0, arg1) {
|
|
95
|
+
const obj = arg1;
|
|
96
|
+
const ret = typeof(obj) === 'string' ? obj : undefined;
|
|
97
|
+
var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
98
|
+
var len1 = WASM_VECTOR_LEN;
|
|
99
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
|
|
100
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
|
|
101
|
+
},
|
|
102
|
+
__wbg___wbindgen_throw_6ddd609b62940d55: function(arg0, arg1) {
|
|
103
|
+
throw new Error(getStringFromWasm0(arg0, arg1));
|
|
104
|
+
},
|
|
105
|
+
__wbg_get_with_ref_key_6412cf3094599694: function(arg0, arg1) {
|
|
106
|
+
const ret = arg0[arg1];
|
|
107
|
+
return ret;
|
|
108
|
+
},
|
|
109
|
+
__wbg_instanceof_ArrayBuffer_101e2bf31071a9f6: function(arg0) {
|
|
110
|
+
let result;
|
|
111
|
+
try {
|
|
112
|
+
result = arg0 instanceof ArrayBuffer;
|
|
113
|
+
} catch (_) {
|
|
114
|
+
result = false;
|
|
115
|
+
}
|
|
116
|
+
const ret = result;
|
|
117
|
+
return ret;
|
|
118
|
+
},
|
|
119
|
+
__wbg_instanceof_Uint8Array_740438561a5b956d: function(arg0) {
|
|
120
|
+
let result;
|
|
121
|
+
try {
|
|
122
|
+
result = arg0 instanceof Uint8Array;
|
|
123
|
+
} catch (_) {
|
|
124
|
+
result = false;
|
|
125
|
+
}
|
|
126
|
+
const ret = result;
|
|
127
|
+
return ret;
|
|
128
|
+
},
|
|
129
|
+
__wbg_isSafeInteger_ecd6a7f9c3e053cd: function(arg0) {
|
|
130
|
+
const ret = Number.isSafeInteger(arg0);
|
|
131
|
+
return ret;
|
|
132
|
+
},
|
|
133
|
+
__wbg_length_ea16607d7b61445b: function(arg0) {
|
|
134
|
+
const ret = arg0.length;
|
|
135
|
+
return ret;
|
|
136
|
+
},
|
|
137
|
+
__wbg_new_5f486cdf45a04d78: function(arg0) {
|
|
138
|
+
const ret = new Uint8Array(arg0);
|
|
139
|
+
return ret;
|
|
140
|
+
},
|
|
141
|
+
__wbg_new_from_slice_d16553cb630d3573: function(arg0, arg1) {
|
|
142
|
+
const ret = new Uint8ClampedArray(getArrayU8FromWasm0(arg0, arg1));
|
|
143
|
+
return ret;
|
|
144
|
+
},
|
|
145
|
+
__wbg_of_8fd5dd402bc67165: function(arg0, arg1, arg2) {
|
|
146
|
+
const ret = Array.of(arg0, arg1, arg2);
|
|
147
|
+
return ret;
|
|
148
|
+
},
|
|
149
|
+
__wbg_prototypesetcall_d62e5099504357e6: function(arg0, arg1, arg2) {
|
|
150
|
+
Uint8Array.prototype.set.call(getArrayU8FromWasm0(arg0, arg1), arg2);
|
|
151
|
+
},
|
|
152
|
+
__wbindgen_cast_0000000000000001: function(arg0) {
|
|
153
|
+
// Cast intrinsic for `F64 -> Externref`.
|
|
154
|
+
const ret = arg0;
|
|
155
|
+
return ret;
|
|
156
|
+
},
|
|
157
|
+
__wbindgen_cast_0000000000000002: function(arg0, arg1) {
|
|
158
|
+
// Cast intrinsic for `Ref(String) -> Externref`.
|
|
159
|
+
const ret = getStringFromWasm0(arg0, arg1);
|
|
160
|
+
return ret;
|
|
161
|
+
},
|
|
162
|
+
__wbindgen_init_externref_table: function() {
|
|
163
|
+
const table = wasm.__wbindgen_externrefs;
|
|
164
|
+
const offset = table.grow(4);
|
|
165
|
+
table.set(0, undefined);
|
|
166
|
+
table.set(offset + 0, undefined);
|
|
167
|
+
table.set(offset + 1, null);
|
|
168
|
+
table.set(offset + 2, true);
|
|
169
|
+
table.set(offset + 3, false);
|
|
170
|
+
},
|
|
171
|
+
};
|
|
172
|
+
return {
|
|
173
|
+
__proto__: null,
|
|
174
|
+
"./pngquant_bg.js": import0,
|
|
175
|
+
};
|
|
40
176
|
}
|
|
41
177
|
|
|
42
178
|
function debugString(val) {
|
|
@@ -104,23 +240,44 @@ function debugString(val) {
|
|
|
104
240
|
return className;
|
|
105
241
|
}
|
|
106
242
|
|
|
107
|
-
|
|
243
|
+
function getArrayU8FromWasm0(ptr, len) {
|
|
244
|
+
ptr = ptr >>> 0;
|
|
245
|
+
return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
|
|
246
|
+
}
|
|
108
247
|
|
|
109
|
-
|
|
248
|
+
let cachedDataViewMemory0 = null;
|
|
249
|
+
function getDataViewMemory0() {
|
|
250
|
+
if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || (cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm.memory.buffer)) {
|
|
251
|
+
cachedDataViewMemory0 = new DataView(wasm.memory.buffer);
|
|
252
|
+
}
|
|
253
|
+
return cachedDataViewMemory0;
|
|
254
|
+
}
|
|
110
255
|
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
256
|
+
function getStringFromWasm0(ptr, len) {
|
|
257
|
+
ptr = ptr >>> 0;
|
|
258
|
+
return decodeText(ptr, len);
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
let cachedUint8ArrayMemory0 = null;
|
|
262
|
+
function getUint8ArrayMemory0() {
|
|
263
|
+
if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
|
|
264
|
+
cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
|
|
119
265
|
}
|
|
266
|
+
return cachedUint8ArrayMemory0;
|
|
120
267
|
}
|
|
121
268
|
|
|
122
|
-
function
|
|
269
|
+
function isLikeNone(x) {
|
|
270
|
+
return x === undefined || x === null;
|
|
271
|
+
}
|
|
123
272
|
|
|
273
|
+
function passArray8ToWasm0(arg, malloc) {
|
|
274
|
+
const ptr = malloc(arg.length * 1, 1) >>> 0;
|
|
275
|
+
getUint8ArrayMemory0().set(arg, ptr / 1);
|
|
276
|
+
WASM_VECTOR_LEN = arg.length;
|
|
277
|
+
return ptr;
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
function passStringToWasm0(arg, malloc, realloc) {
|
|
124
281
|
if (realloc === undefined) {
|
|
125
282
|
const buf = cachedTextEncoder.encode(arg);
|
|
126
283
|
const ptr = malloc(buf.length, 1) >>> 0;
|
|
@@ -141,7 +298,6 @@ function passStringToWasm0(arg, malloc, realloc) {
|
|
|
141
298
|
if (code > 0x7F) break;
|
|
142
299
|
mem[ptr + offset] = code;
|
|
143
300
|
}
|
|
144
|
-
|
|
145
301
|
if (offset !== len) {
|
|
146
302
|
if (offset !== 0) {
|
|
147
303
|
arg = arg.slice(offset);
|
|
@@ -158,249 +314,85 @@ function passStringToWasm0(arg, malloc, realloc) {
|
|
|
158
314
|
return ptr;
|
|
159
315
|
}
|
|
160
316
|
|
|
161
|
-
let
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
317
|
+
let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
|
|
318
|
+
cachedTextDecoder.decode();
|
|
319
|
+
const MAX_SAFARI_DECODE_BYTES = 2146435072;
|
|
320
|
+
let numBytesDecoded = 0;
|
|
321
|
+
function decodeText(ptr, len) {
|
|
322
|
+
numBytesDecoded += len;
|
|
323
|
+
if (numBytesDecoded >= MAX_SAFARI_DECODE_BYTES) {
|
|
324
|
+
cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
|
|
325
|
+
cachedTextDecoder.decode();
|
|
326
|
+
numBytesDecoded = len;
|
|
166
327
|
}
|
|
167
|
-
return
|
|
328
|
+
return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
|
|
168
329
|
}
|
|
169
330
|
|
|
170
|
-
|
|
171
|
-
const ptr = malloc(arg.length * 1, 1) >>> 0;
|
|
172
|
-
getUint8ArrayMemory0().set(arg, ptr / 1);
|
|
173
|
-
WASM_VECTOR_LEN = arg.length;
|
|
174
|
-
return ptr;
|
|
175
|
-
}
|
|
176
|
-
/**
|
|
177
|
-
* @param {Uint8Array} data
|
|
178
|
-
* @param {number} width
|
|
179
|
-
* @param {number} height
|
|
180
|
-
* @param {any} options
|
|
181
|
-
* @returns {Uint8Array}
|
|
182
|
-
*/
|
|
183
|
-
export function optimize(data, width, height, options) {
|
|
184
|
-
const ptr0 = passArray8ToWasm0(data, wasm.__wbindgen_malloc);
|
|
185
|
-
const len0 = WASM_VECTOR_LEN;
|
|
186
|
-
const ret = wasm.optimize(ptr0, len0, width, height, options);
|
|
187
|
-
var v2 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
188
|
-
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
189
|
-
return v2;
|
|
190
|
-
}
|
|
331
|
+
const cachedTextEncoder = new TextEncoder();
|
|
191
332
|
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
const len0 = WASM_VECTOR_LEN;
|
|
202
|
-
const ret = wasm.quantize(ptr0, len0, width, height, options);
|
|
203
|
-
var v2 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
204
|
-
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
205
|
-
return v2;
|
|
333
|
+
if (!('encodeInto' in cachedTextEncoder)) {
|
|
334
|
+
cachedTextEncoder.encodeInto = function (arg, view) {
|
|
335
|
+
const buf = cachedTextEncoder.encode(arg);
|
|
336
|
+
view.set(buf);
|
|
337
|
+
return {
|
|
338
|
+
read: arg.length,
|
|
339
|
+
written: buf.length
|
|
340
|
+
};
|
|
341
|
+
};
|
|
206
342
|
}
|
|
207
343
|
|
|
208
|
-
|
|
209
|
-
* Decode PNG image into 8-bit RGBA data, return only the buffer and width,
|
|
210
|
-
* but height can be calculated by `data.byteLength / width / 4`
|
|
211
|
-
* @param {Uint8Array} data
|
|
212
|
-
* @returns {Array<any>}
|
|
213
|
-
*/
|
|
214
|
-
export function png_to_rgba(data) {
|
|
215
|
-
const ptr0 = passArray8ToWasm0(data, wasm.__wbindgen_malloc);
|
|
216
|
-
const len0 = WASM_VECTOR_LEN;
|
|
217
|
-
const ret = wasm.png_to_rgba(ptr0, len0);
|
|
218
|
-
return ret;
|
|
219
|
-
}
|
|
344
|
+
let WASM_VECTOR_LEN = 0;
|
|
220
345
|
|
|
221
|
-
|
|
346
|
+
let wasmModule, wasm;
|
|
347
|
+
function __wbg_finalize_init(instance, module) {
|
|
348
|
+
wasm = instance.exports;
|
|
349
|
+
wasmModule = module;
|
|
350
|
+
cachedDataViewMemory0 = null;
|
|
351
|
+
cachedUint8ArrayMemory0 = null;
|
|
352
|
+
wasm.__wbindgen_start();
|
|
353
|
+
return wasm;
|
|
354
|
+
}
|
|
222
355
|
|
|
223
356
|
async function __wbg_load(module, imports) {
|
|
224
357
|
if (typeof Response === 'function' && module instanceof Response) {
|
|
225
358
|
if (typeof WebAssembly.instantiateStreaming === 'function') {
|
|
226
359
|
try {
|
|
227
360
|
return await WebAssembly.instantiateStreaming(module, imports);
|
|
228
|
-
|
|
229
361
|
} catch (e) {
|
|
230
|
-
const validResponse = module.ok &&
|
|
362
|
+
const validResponse = module.ok && expectedResponseType(module.type);
|
|
231
363
|
|
|
232
364
|
if (validResponse && module.headers.get('Content-Type') !== 'application/wasm') {
|
|
233
365
|
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", e);
|
|
234
366
|
|
|
235
|
-
} else {
|
|
236
|
-
throw e;
|
|
237
|
-
}
|
|
367
|
+
} else { throw e; }
|
|
238
368
|
}
|
|
239
369
|
}
|
|
240
370
|
|
|
241
371
|
const bytes = await module.arrayBuffer();
|
|
242
372
|
return await WebAssembly.instantiate(bytes, imports);
|
|
243
|
-
|
|
244
373
|
} else {
|
|
245
374
|
const instance = await WebAssembly.instantiate(module, imports);
|
|
246
375
|
|
|
247
376
|
if (instance instanceof WebAssembly.Instance) {
|
|
248
377
|
return { instance, module };
|
|
249
|
-
|
|
250
378
|
} else {
|
|
251
379
|
return instance;
|
|
252
380
|
}
|
|
253
381
|
}
|
|
254
|
-
}
|
|
255
382
|
|
|
256
|
-
function
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
imports.wbg.__wbg_Error_e17e777aac105295 = function(arg0, arg1) {
|
|
260
|
-
const ret = Error(getStringFromWasm0(arg0, arg1));
|
|
261
|
-
return ret;
|
|
262
|
-
};
|
|
263
|
-
imports.wbg.__wbg_Number_998bea33bd87c3e0 = function(arg0) {
|
|
264
|
-
const ret = Number(arg0);
|
|
265
|
-
return ret;
|
|
266
|
-
};
|
|
267
|
-
imports.wbg.__wbg_getwithrefkey_1dc361bd10053bfe = function(arg0, arg1) {
|
|
268
|
-
const ret = arg0[arg1];
|
|
269
|
-
return ret;
|
|
270
|
-
};
|
|
271
|
-
imports.wbg.__wbg_instanceof_ArrayBuffer_67f3012529f6a2dd = function(arg0) {
|
|
272
|
-
let result;
|
|
273
|
-
try {
|
|
274
|
-
result = arg0 instanceof ArrayBuffer;
|
|
275
|
-
} catch (_) {
|
|
276
|
-
result = false;
|
|
277
|
-
}
|
|
278
|
-
const ret = result;
|
|
279
|
-
return ret;
|
|
280
|
-
};
|
|
281
|
-
imports.wbg.__wbg_instanceof_Uint8Array_9a8378d955933db7 = function(arg0) {
|
|
282
|
-
let result;
|
|
283
|
-
try {
|
|
284
|
-
result = arg0 instanceof Uint8Array;
|
|
285
|
-
} catch (_) {
|
|
286
|
-
result = false;
|
|
383
|
+
function expectedResponseType(type) {
|
|
384
|
+
switch (type) {
|
|
385
|
+
case 'basic': case 'cors': case 'default': return true;
|
|
287
386
|
}
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
};
|
|
291
|
-
imports.wbg.__wbg_isSafeInteger_1c0d1af5542e102a = function(arg0) {
|
|
292
|
-
const ret = Number.isSafeInteger(arg0);
|
|
293
|
-
return ret;
|
|
294
|
-
};
|
|
295
|
-
imports.wbg.__wbg_length_6bb7e81f9d7713e4 = function(arg0) {
|
|
296
|
-
const ret = arg0.length;
|
|
297
|
-
return ret;
|
|
298
|
-
};
|
|
299
|
-
imports.wbg.__wbg_new_638ebfaedbf32a5e = function(arg0) {
|
|
300
|
-
const ret = new Uint8Array(arg0);
|
|
301
|
-
return ret;
|
|
302
|
-
};
|
|
303
|
-
imports.wbg.__wbg_newfromslice_550eeea99b5190f9 = function(arg0, arg1) {
|
|
304
|
-
const ret = new Uint8ClampedArray(getArrayU8FromWasm0(arg0, arg1));
|
|
305
|
-
return ret;
|
|
306
|
-
};
|
|
307
|
-
imports.wbg.__wbg_of_26ef42cc9a4270a1 = function(arg0, arg1, arg2) {
|
|
308
|
-
const ret = Array.of(arg0, arg1, arg2);
|
|
309
|
-
return ret;
|
|
310
|
-
};
|
|
311
|
-
imports.wbg.__wbg_prototypesetcall_3d4a26c1ed734349 = function(arg0, arg1, arg2) {
|
|
312
|
-
Uint8Array.prototype.set.call(getArrayU8FromWasm0(arg0, arg1), arg2);
|
|
313
|
-
};
|
|
314
|
-
imports.wbg.__wbg_wbindgenbooleanget_3fe6f642c7d97746 = function(arg0) {
|
|
315
|
-
const v = arg0;
|
|
316
|
-
const ret = typeof(v) === 'boolean' ? v : undefined;
|
|
317
|
-
return isLikeNone(ret) ? 0xFFFFFF : ret ? 1 : 0;
|
|
318
|
-
};
|
|
319
|
-
imports.wbg.__wbg_wbindgendebugstring_99ef257a3ddda34d = function(arg0, arg1) {
|
|
320
|
-
const ret = debugString(arg1);
|
|
321
|
-
const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
322
|
-
const len1 = WASM_VECTOR_LEN;
|
|
323
|
-
getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
|
|
324
|
-
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
|
|
325
|
-
};
|
|
326
|
-
imports.wbg.__wbg_wbindgenin_d7a1ee10933d2d55 = function(arg0, arg1) {
|
|
327
|
-
const ret = arg0 in arg1;
|
|
328
|
-
return ret;
|
|
329
|
-
};
|
|
330
|
-
imports.wbg.__wbg_wbindgenisobject_307a53c6bd97fbf8 = function(arg0) {
|
|
331
|
-
const val = arg0;
|
|
332
|
-
const ret = typeof(val) === 'object' && val !== null;
|
|
333
|
-
return ret;
|
|
334
|
-
};
|
|
335
|
-
imports.wbg.__wbg_wbindgenisundefined_c4b71d073b92f3c5 = function(arg0) {
|
|
336
|
-
const ret = arg0 === undefined;
|
|
337
|
-
return ret;
|
|
338
|
-
};
|
|
339
|
-
imports.wbg.__wbg_wbindgenjsvallooseeq_9bec8c9be826bed1 = function(arg0, arg1) {
|
|
340
|
-
const ret = arg0 == arg1;
|
|
341
|
-
return ret;
|
|
342
|
-
};
|
|
343
|
-
imports.wbg.__wbg_wbindgennumberget_f74b4c7525ac05cb = function(arg0, arg1) {
|
|
344
|
-
const obj = arg1;
|
|
345
|
-
const ret = typeof(obj) === 'number' ? obj : undefined;
|
|
346
|
-
getDataViewMemory0().setFloat64(arg0 + 8 * 1, isLikeNone(ret) ? 0 : ret, true);
|
|
347
|
-
getDataViewMemory0().setInt32(arg0 + 4 * 0, !isLikeNone(ret), true);
|
|
348
|
-
};
|
|
349
|
-
imports.wbg.__wbg_wbindgenstringget_0f16a6ddddef376f = function(arg0, arg1) {
|
|
350
|
-
const obj = arg1;
|
|
351
|
-
const ret = typeof(obj) === 'string' ? obj : undefined;
|
|
352
|
-
var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
353
|
-
var len1 = WASM_VECTOR_LEN;
|
|
354
|
-
getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
|
|
355
|
-
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
|
|
356
|
-
};
|
|
357
|
-
imports.wbg.__wbg_wbindgenthrow_451ec1a8469d7eb6 = function(arg0, arg1) {
|
|
358
|
-
throw new Error(getStringFromWasm0(arg0, arg1));
|
|
359
|
-
};
|
|
360
|
-
imports.wbg.__wbindgen_cast_2241b6af4c4b2941 = function(arg0, arg1) {
|
|
361
|
-
// Cast intrinsic for `Ref(String) -> Externref`.
|
|
362
|
-
const ret = getStringFromWasm0(arg0, arg1);
|
|
363
|
-
return ret;
|
|
364
|
-
};
|
|
365
|
-
imports.wbg.__wbindgen_cast_d6cd19b81560fd6e = function(arg0) {
|
|
366
|
-
// Cast intrinsic for `F64 -> Externref`.
|
|
367
|
-
const ret = arg0;
|
|
368
|
-
return ret;
|
|
369
|
-
};
|
|
370
|
-
imports.wbg.__wbindgen_init_externref_table = function() {
|
|
371
|
-
const table = wasm.__wbindgen_export_2;
|
|
372
|
-
const offset = table.grow(4);
|
|
373
|
-
table.set(0, undefined);
|
|
374
|
-
table.set(offset + 0, undefined);
|
|
375
|
-
table.set(offset + 1, null);
|
|
376
|
-
table.set(offset + 2, true);
|
|
377
|
-
table.set(offset + 3, false);
|
|
378
|
-
;
|
|
379
|
-
};
|
|
380
|
-
|
|
381
|
-
return imports;
|
|
382
|
-
}
|
|
383
|
-
|
|
384
|
-
function __wbg_init_memory(imports, memory) {
|
|
385
|
-
|
|
386
|
-
}
|
|
387
|
-
|
|
388
|
-
function __wbg_finalize_init(instance, module) {
|
|
389
|
-
wasm = instance.exports;
|
|
390
|
-
__wbg_init.__wbindgen_wasm_module = module;
|
|
391
|
-
cachedDataViewMemory0 = null;
|
|
392
|
-
cachedUint8ArrayMemory0 = null;
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
wasm.__wbindgen_start();
|
|
396
|
-
return wasm;
|
|
387
|
+
return false;
|
|
388
|
+
}
|
|
397
389
|
}
|
|
398
390
|
|
|
399
391
|
function initSync(module) {
|
|
400
392
|
if (wasm !== undefined) return wasm;
|
|
401
393
|
|
|
402
394
|
|
|
403
|
-
if (
|
|
395
|
+
if (module !== undefined) {
|
|
404
396
|
if (Object.getPrototypeOf(module) === Object.prototype) {
|
|
405
397
|
({module} = module)
|
|
406
398
|
} else {
|
|
@@ -409,15 +401,10 @@ function initSync(module) {
|
|
|
409
401
|
}
|
|
410
402
|
|
|
411
403
|
const imports = __wbg_get_imports();
|
|
412
|
-
|
|
413
|
-
__wbg_init_memory(imports);
|
|
414
|
-
|
|
415
404
|
if (!(module instanceof WebAssembly.Module)) {
|
|
416
405
|
module = new WebAssembly.Module(module);
|
|
417
406
|
}
|
|
418
|
-
|
|
419
407
|
const instance = new WebAssembly.Instance(module, imports);
|
|
420
|
-
|
|
421
408
|
return __wbg_finalize_init(instance, module);
|
|
422
409
|
}
|
|
423
410
|
|
|
@@ -425,7 +412,7 @@ async function __wbg_init(module_or_path) {
|
|
|
425
412
|
if (wasm !== undefined) return wasm;
|
|
426
413
|
|
|
427
414
|
|
|
428
|
-
if (
|
|
415
|
+
if (module_or_path !== undefined) {
|
|
429
416
|
if (Object.getPrototypeOf(module_or_path) === Object.prototype) {
|
|
430
417
|
({module_or_path} = module_or_path)
|
|
431
418
|
} else {
|
|
@@ -433,7 +420,7 @@ async function __wbg_init(module_or_path) {
|
|
|
433
420
|
}
|
|
434
421
|
}
|
|
435
422
|
|
|
436
|
-
if (
|
|
423
|
+
if (module_or_path === undefined) {
|
|
437
424
|
module_or_path = new URL('pngquant_bg.wasm', import.meta.url);
|
|
438
425
|
}
|
|
439
426
|
const imports = __wbg_get_imports();
|
|
@@ -442,12 +429,9 @@ async function __wbg_init(module_or_path) {
|
|
|
442
429
|
module_or_path = fetch(module_or_path);
|
|
443
430
|
}
|
|
444
431
|
|
|
445
|
-
__wbg_init_memory(imports);
|
|
446
|
-
|
|
447
432
|
const { instance, module } = await __wbg_load(await module_or_path, imports);
|
|
448
433
|
|
|
449
434
|
return __wbg_finalize_init(instance, module);
|
|
450
435
|
}
|
|
451
436
|
|
|
452
|
-
export { initSync };
|
|
453
|
-
export default __wbg_init;
|
|
437
|
+
export { initSync, __wbg_init as default };
|
package/dist/pngquant_bg.wasm
CHANGED
|
Binary file
|
package/dist/qoi.d.ts
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
// TypeScript bindings for emscripten-generated code. Automatically generated at compile time.
|
|
2
|
+
declare namespace RuntimeExports {
|
|
3
|
+
let HEAP8: Int8Array;
|
|
4
|
+
}
|
|
5
|
+
interface WasmModule {
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
type EmbindString = ArrayBuffer|Uint8Array|Uint8ClampedArray|Int8Array|string;
|
|
9
|
+
interface EmbindModule {
|
|
10
|
+
encode(_0: EmbindString, _1: number, _2: number, _3: any): any;
|
|
11
|
+
decode(_0: EmbindString): any;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export type MainModule = WasmModule & typeof RuntimeExports & EmbindModule;
|
|
15
|
+
export default function MainModuleFactory (options?: unknown): Promise<MainModule>;
|