(src: string)
| 453 | } |
| 454 | |
| 455 | function getCubeLut(src: string): LutCacheEntry { |
| 456 | const resolved = resolveLutUrl(src); |
| 457 | if ("error" in resolved) return { state: "error", message: resolved.error }; |
| 458 | const cached = LUT_CACHE.get(resolved.href); |
| 459 | if (cached) return cached; |
| 460 | |
| 461 | const promise = fetch(resolved.href, { credentials: "same-origin" }) |
| 462 | .then((response) => { |
| 463 | if (!response.ok) throw new Error(`Failed to load LUT (${response.status})`); |
| 464 | return response.text(); |
| 465 | }) |
| 466 | .then((text) => parseCubeLut(text, { maxSize: MAX_LUT_SIZE })); |
| 467 | |
| 468 | const pending: LutCacheEntry = { state: "pending", promise }; |
| 469 | LUT_CACHE.set(resolved.href, pending); |
| 470 | promise.then( |
| 471 | (lut) => LUT_CACHE.set(resolved.href, { state: "ready", lut }), |
| 472 | (err) => LUT_CACHE.set(resolved.href, { state: "error", message: errorMessage(err) }), |
| 473 | ); |
| 474 | return pending; |
| 475 | } |
| 476 | |
| 477 | function uploadEntryLut( |
| 478 | entry: ColorGradingEntry, |
no test coverage detected