wasm-webp 0.0.2 → 0.1.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 +23 -6
- package/dist/cjs/index.js +19 -13
- package/dist/cjs/webp-wasm.js +1133 -325
- package/dist/cjs/webp-wasm.wasm +0 -0
- package/dist/esm/index.js +12 -11
- package/dist/esm/webp-wasm.js +1128 -324
- package/dist/esm/webp-wasm.wasm +0 -0
- package/dist/index.d.ts +1 -0
- package/dist/types.d.ts +1 -0
- package/package.json +1 -1
package/dist/cjs/webp-wasm.wasm
CHANGED
|
Binary file
|
package/dist/esm/index.js
CHANGED
|
@@ -37,19 +37,20 @@ export const encode = (data, width, height, hasAlpha, config) => __awaiter(void
|
|
|
37
37
|
});
|
|
38
38
|
export const encodeAnimation = (width, height, hasAlpha, frames) => __awaiter(void 0, void 0, void 0, function* () {
|
|
39
39
|
const module = yield Module();
|
|
40
|
-
const
|
|
41
|
-
const dataLength = frames.reduce((acc, frame) => {
|
|
42
|
-
acc += frame.data.length;
|
|
43
|
-
return acc;
|
|
44
|
-
}, 0);
|
|
45
|
-
const data = new Uint8Array(dataLength);
|
|
46
|
-
let offset = 0;
|
|
40
|
+
const frameVector = new module.VectorWebPAnimationFrame();
|
|
47
41
|
frames.forEach((frame) => {
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
42
|
+
const hasConfig = frame.config !== undefined;
|
|
43
|
+
const config = Object.assign(Object.assign({}, defaultWebpConfig), frame.config);
|
|
44
|
+
config.lossless = Math.min(1, Math.max(0, config.lossless));
|
|
45
|
+
config.quality = Math.min(100, Math.max(0, config.quality));
|
|
46
|
+
frameVector.push_back({
|
|
47
|
+
duration: frame.duration,
|
|
48
|
+
data: frame.data,
|
|
49
|
+
config,
|
|
50
|
+
has_config: hasConfig,
|
|
51
|
+
});
|
|
51
52
|
});
|
|
52
|
-
return module.encodeAnimation(width, height, hasAlpha,
|
|
53
|
+
return module.encodeAnimation(width, height, hasAlpha, frameVector);
|
|
53
54
|
});
|
|
54
55
|
export const decoderVersion = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
55
56
|
const module = yield Module();
|