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