2023-07-27 00:31:52 -05:00
|
|
|
/*
|
|
|
|
* SPDX-FileCopyrightText: syuilo and other misskey contributors
|
|
|
|
* SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
*/
|
|
|
|
|
2023-05-18 19:44:06 -05:00
|
|
|
import { render } from 'buraha';
|
|
|
|
|
2023-07-01 23:46:49 -05:00
|
|
|
const canvas = new OffscreenCanvas(64, 64);
|
|
|
|
|
2023-05-18 19:44:06 -05:00
|
|
|
onmessage = (event) => {
|
2023-07-27 00:31:52 -05:00
|
|
|
// console.log(event.data);
|
|
|
|
if (!('id' in event.data && typeof event.data.id === 'string')) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (!('hash' in event.data && typeof event.data.hash === 'string')) {
|
|
|
|
return;
|
|
|
|
}
|
2023-07-01 23:46:49 -05:00
|
|
|
|
2023-07-27 00:31:52 -05:00
|
|
|
render(event.data.hash, canvas);
|
|
|
|
const bitmap = canvas.transferToImageBitmap();
|
|
|
|
postMessage({ id: event.data.id, bitmap });
|
2023-05-18 19:44:06 -05:00
|
|
|
};
|