wip
This commit is contained in:
22
packages/frontend-embed/src/workers/draw-blurhash.ts
Normal file
22
packages/frontend-embed/src/workers/draw-blurhash.ts
Normal file
@@ -0,0 +1,22 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: syuilo and misskey-project
|
||||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
*/
|
||||
|
||||
import { render } from 'buraha';
|
||||
|
||||
const canvas = new OffscreenCanvas(64, 64);
|
||||
|
||||
onmessage = (event) => {
|
||||
// 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;
|
||||
}
|
||||
|
||||
render(event.data.hash, canvas);
|
||||
const bitmap = canvas.transferToImageBitmap();
|
||||
postMessage({ id: event.data.id, bitmap });
|
||||
};
|
14
packages/frontend-embed/src/workers/test-webgl2.ts
Normal file
14
packages/frontend-embed/src/workers/test-webgl2.ts
Normal file
@@ -0,0 +1,14 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: syuilo and misskey-project
|
||||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
*/
|
||||
|
||||
const canvas = globalThis.OffscreenCanvas && new OffscreenCanvas(1, 1);
|
||||
// 環境によってはOffscreenCanvasが存在しないため
|
||||
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
|
||||
const gl = canvas?.getContext('webgl2');
|
||||
if (gl) {
|
||||
postMessage({ result: true });
|
||||
} else {
|
||||
postMessage({ result: false });
|
||||
}
|
5
packages/frontend-embed/src/workers/tsconfig.json
Normal file
5
packages/frontend-embed/src/workers/tsconfig.json
Normal file
@@ -0,0 +1,5 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"lib": ["esnext", "webworker"],
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user