2023-07-27 05:31:52 +00:00
|
|
|
/*
|
|
|
|
* SPDX-FileCopyrightText: syuilo and other misskey contributors
|
|
|
|
* SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
*/
|
|
|
|
|
2023-05-19 00:44:06 +00:00
|
|
|
import { render } from 'buraha';
|
|
|
|
|
2023-07-02 04:46:49 +00:00
|
|
|
const canvas = new OffscreenCanvas(64, 64);
|
|
|
|
|
2023-05-19 00:44:06 +00:00
|
|
|
onmessage = (event) => {
|
2023-07-27 05:31:52 +00: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-02 04:46:49 +00:00
|
|
|
|
2023-07-27 05:31:52 +00:00
|
|
|
render(event.data.hash, canvas);
|
|
|
|
const bitmap = canvas.transferToImageBitmap();
|
|
|
|
postMessage({ id: event.data.id, bitmap });
|
2023-05-19 00:44:06 +00:00
|
|
|
};
|