diff --git a/packages/frontend/src/components/MkImgWithBlurhash.vue b/packages/frontend/src/components/MkImgWithBlurhash.vue index 6406a35060..22619ba2fd 100644 --- a/packages/frontend/src/components/MkImgWithBlurhash.vue +++ b/packages/frontend/src/components/MkImgWithBlurhash.vue @@ -1,6 +1,6 @@ diff --git a/packages/frontend/src/components/MkMediaImage.vue b/packages/frontend/src/components/MkMediaImage.vue index f815ef32dd..6b0a43a8a9 100644 --- a/packages/frontend/src/components/MkMediaImage.vue +++ b/packages/frontend/src/components/MkMediaImage.vue @@ -1,27 +1,32 @@ @@ -49,6 +54,12 @@ const url = $computed(() => (props.raw || defaultStore.state.loadRawImages) : props.image.thumbnailUrl, ); +function onclick() { + if (hide) { + hide = false; + } +} + // Plugin:register_note_view_interruptor を使って書き換えられる可能性があるためwatchする watch(() => props.image, () => { hide = (defaultStore.state.nsfw === 'force' || defaultStore.state.enableDataSaverMode) ? true : (props.image.isSensitive && defaultStore.state.nsfw !== 'ignore'); diff --git a/packages/frontend/src/workers/draw-blurhash.ts b/packages/frontend/src/workers/draw-blurhash.ts new file mode 100644 index 0000000000..3c701584ce --- /dev/null +++ b/packages/frontend/src/workers/draw-blurhash.ts @@ -0,0 +1,20 @@ +import { decode } from 'blurhash'; + +let canvas: OffscreenCanvas | null = null; + +onmessage = (event) => { + if ('canvas' in event.data) { + canvas = event.data.canvas; + } + if (!(canvas && 'hash' in event.data && typeof event.data.hash === 'string')) { + return; + } + const width = event.data.width ?? 64; + const height = event.data.height ?? 64; + const ctx = canvas.getContext!('2d'); + if (!ctx) return; + const imageData = ctx.createImageData(width, height); + const pixels = decode(event.data.hash, width, height); + imageData.data.set(pixels); + ctx!.putImageData(imageData, 0, 0); +}; diff --git a/packages/frontend/src/workers/tsconfig.json b/packages/frontend/src/workers/tsconfig.json new file mode 100644 index 0000000000..304d02d046 --- /dev/null +++ b/packages/frontend/src/workers/tsconfig.json @@ -0,0 +1,7 @@ + +{ + "extends": "../tsconfig.json", + "compilerOptions": { + "lib": ["esnext", "webworker"], + } +} diff --git a/packages/frontend/vite.config.ts b/packages/frontend/vite.config.ts index fad0dd0177..7fc21701ce 100644 --- a/packages/frontend/vite.config.ts +++ b/packages/frontend/vite.config.ts @@ -139,6 +139,10 @@ export function getConfig(): UserConfig { }, }, + worker: { + format: 'es', + }, + test: { environment: 'happy-dom', deps: {