wasm-vipsを使いたい→無理そう
from 自前Nostr Webクライアント(仮案)
wasm-vipsを使いたい→少なくとも自分の用途では無理そうね
とりあえず既存のviteプロジェクトで npm i wasm-vips して適当にimportしてbuildしてみたらこれ。
npm i -D vite-plugin-wasmしても変わらず
code:err.log
Unexpected early exit. This happens when Promises returned by plugins cannot resolve. Unfinished hook action(s) on exit:
(commonjs--resolver) resolveId "wasm-vips" "/Users/qser/_/p/nostr/nostr-following-list-util/src/components/BadgesMain/BadgesMain.tsx"
(vite:worker-import-meta-url) transform "/Users/qser/_/p/nostr/nostr-following-list-util/node_modules/wasm-vips/lib/vips-es6.js"
error during build:
Error: Unexpected early exit. This happens when Promises returned by plugins cannot resolve. Unfinished hook action(s) on exit:
(commonjs--resolver) resolveId "wasm-vips" "/Users/qser/_/p/nostr/nostr-following-list-util/src/components/BadgesMain/BadgesMain.tsx"
(vite:worker-import-meta-url) transform "/Users/qser/_/p/nostr/nostr-following-list-util/node_modules/wasm-vips/lib/vips-es6.js"
at EventEmitter.handleEmptyEventLoop (file:///Users/qser/_/p/nostr/nostr-following-list-util/node_modules/rollup/dist/es/shared/rollup.js:24256:20)
at Object.onceWrapper (node:events:627:28)
at EventEmitter.emit (node:events:525:35)
at process.<anonymous> (file:///Users/qser/_/p/nostr/nostr-following-list-util/node_modules/rollup/dist/es/shared/rollup.js:24250:55)
at process.emit (node:events:513:28)
npm run devしてみたら Uncaught (in promise) ReferenceError: SharedArrayBuffer is not defined が。
(question) - SharedArrayBuffer is not available · Issue #18 · kleisauke/wasm-vips
The SharedArrayBuffer API, as required by Emscripten pthreads integration, is currently a hard-requirement. There's no workaround for this since libvips requires threading functionality to be available.
Spectre対策のため、SharedArrayBufferを有効化するにはCross Origin Isolation(オリジン間プロセス分離)が必須
SharedArrayBuffer と過渡期な cross-origin isolation の話
この記事を何故かFirefoxでブクマしてた自分ナイス
これをやるとimgタグでの外部画像読み込みにすらCORSヘッダーが要るようになり、postMessageはできなくなる
Cross-Origin-Embedder-Policy: credentiallessは現在Chrome only
やるとしたら完全に別サイトで用意かな
別サイト用メモ
kleisauke/wasm-vips: libvips for the browser and Node.js, compiled to WebAssembly with Emscripten.
開発自体は上流のバージョンの1つ下を追えてるなど活発っぽい
pngquantはlibimgquantというRustライブラリになっててwasm用ビルドについての記述もある
pngエンコーダー/デコーダーは付いてなくて8bitカラーに変換する機能だけあるようなので、vipsと組み合わせるとか?(できるのか?)
zopflipngはCのソースしかないなぁ