LarpixClient/webroot/webp-worker.js
olcxja 271c573fb4
All checks were successful
Android Build / publish (push) Successful in 54s
Linux Build / publish (push) Successful in 53s
add better loading for profile settings and user profiles & add details bar
2026-07-04 13:55:23 +02:00

18 lines
806 B
JavaScript

import { encodeAnimation, decodeAnimation } from './wasm-webp/index.js';
self.onmessage = async (e) => {
let action = e.data.action || 'encode';
try {
if (action === 'decode') {
let decoded = await decodeAnimation(e.data.data, true);
let transferables = decoded.map(f => f.data.buffer);
self.postMessage({ success: true, data: decoded, action }, transferables);
} else {
let { targetWidth, targetHeight, webpFrames } = e.data;
let webpUint8 = await encodeAnimation(targetWidth, targetHeight, true, webpFrames);
self.postMessage({ success: true, data: webpUint8, action }, [webpUint8.buffer]);
}
} catch (err) {
self.postMessage({ success: false, error: err.toString(), action });
}
};