Files
glenloch-media/lumenroom/server/libraw-runtime.mjs
bhursey 0cb315ea88
CI / build (push) Has been cancelled
feat(editor): bridge the advanced photo editor into the event workflow
Event photos can now be opened in Lumenroom, a WebGL2 develop module, from the
photo editor's Advanced button. The dashboard signs a short-lived token scoped
to one user and event; Lumenroom exchanges it, imports the event's photo list
and proxies bytes on demand, so nothing is copied and the temporary catalog
expires with the bridge session. Saving in Lumenroom renders the photo and
writes it back as the event's edited JPEG, with the advanced recipe kept in
event_photos.advanced_edit_json.

Lumenroom is vendored under lumenroom/ and built as a second compose service,
so one clone and `docker compose up -d --build` deploys both apps.

🤖 Generated with Codebuff
Co-Authored-By: Codebuff <noreply@codebuff.com>
2026-11-21 01:34:20 +00:00

35 lines
1.1 KiB
JavaScript

/**
* libraw-wasm is browser-first: the wrapper spawns a Web Worker and the
* Emscripten build loads libraw.wasm with fetch(). Node has neither a global
* Worker nor file:// support in fetch, so the decoder runs in a worker_thread
* with a tiny browser-globals shim (see libraw-worker.mjs).
*
* This is a no-op in the browser, where the real Worker already exists.
*/
let installed = false;
export async function installLibrawRuntime() {
if (installed) return;
installed = true;
if (typeof globalThis.Worker === 'function') return;
const { Worker: NodeWorker } = await import('node:worker_threads');
const entry = new URL('./libraw-worker.mjs', import.meta.url);
class BrowserWorker {
constructor() {
this._worker = new NodeWorker(entry);
this._worker.on('message', (data) => this.onmessage?.({ data }));
this._worker.on('error', (err) => this.onerror?.(err));
}
postMessage(message, transfer) {
this._worker.postMessage(message, transfer);
}
terminate() {
return this._worker.terminate();
}
}
globalThis.Worker = BrowserWorker;
}