FastLED 3.9.15
Loading...
Searching...
No Matches

◆ resolve_asset()

fl::url fl::resolve_asset ( const asset_ref & a)

Resolve an asset handle to a URL (or local file path) at runtime.

Resolution rules:

  • WASM: consults the build-time manifest injected as window.fastledAssetManifest (mirrored into the C++ registry by generated code from ci/compiler/asset_scanner.py).
  • Host/stub (FASTLED_TESTING, FL_IS_STUB): returns the file path as a fl::url if the file exists on disk. Otherwise, if a sibling <path>.lnk exists, returns the URL from the .lnk — same fallback as WASM.
  • Other platforms (e.g., ESP32): v1 returns an empty url(). ESP32 LittleFS / SD-card resolution is tracked as future work.

The runtime ignores any sha256= / fallback= metadata in .lnk files. These are parsed by fl::parse_lnk_with_metadata() for forward-compat and reserved for future integrity/retry features.

Declared here; defined in fl/asset/asset.cpp.hpp.

Definition at line 123 of file asset.cpp.hpp.

123 {
124 if (!a) {
125 return fl::url();
126 }
127 const fl::string_view p = a.path();
128
129 // 1. Registry always wins. On WASM this is populated by generated code
130 // from the asset scanner; on host/stub tests may populate it manually.
131 fl::url fromRegistry = asset_detail::lookup_registry(p);
132 if (fromRegistry.isValid()) {
133 return fromRegistry;
134 }
135
136 // 2. Host/stub: fall back to filesystem probe + sibling .lnk.
137#if defined(FASTLED_TESTING) || defined(FL_IS_STUB)
138 return asset_detail::resolve_host(p);
139#else
140 // 3. Other platforms (WASM without manifest, ESP32 v1): no fallback.
141 // TODO(#2284): ESP32 LittleFS / SD-card resolution.
142 return fl::url();
143#endif
144}
fl::string_view path() const FL_NOEXCEPT
The relative asset path as a string view (e.g. "data/track.mp3").
Definition asset.h:106
bool isValid() const FL_NOEXCEPT
Definition url.h:37
Definition url.h:15
fl::url lookup_registry(fl::string_view path) FL_NOEXCEPT
Look up an asset path in the registry. Returns invalid url() on miss.
Definition asset.cpp.hpp:50

References FL_NOEXCEPT, fl::url::isValid(), and fl::asset_detail::lookup_registry().

Referenced by fl::UIAudio::UIAudio().

+ Here is the call graph for this function:
+ Here is the caller graph for this function: