2021-11-14 00:13:19 +01:00
|
|
|
/* eslint-disable no-restricted-globals */
|
2021-11-04 20:07:07 +01:00
|
|
|
import { decode } from 'blurhash';
|
|
|
|
|
2021-11-14 00:13:19 +01:00
|
|
|
self.onmessage = ({ data: { hash, width, height } }): void => {
|
2021-11-04 20:07:07 +01:00
|
|
|
try {
|
2021-11-14 00:13:19 +01:00
|
|
|
self.postMessage({
|
|
|
|
pixels: decode(hash, width, height),
|
|
|
|
hsh: hash,
|
|
|
|
width: width,
|
|
|
|
height: height
|
|
|
|
});
|
2021-11-04 20:07:07 +01:00
|
|
|
} catch {
|
|
|
|
throw new TypeError(`Blurhash ${hash} is not valid`);
|
|
|
|
}
|
2021-11-14 00:13:19 +01:00
|
|
|
};
|
|
|
|
/* eslint-enable no-restricted-globals */
|