Repository navigation
Description
Summary
Promote data/ to a first-class asset folder that fbuild wires into sketches automatically, starting with fl::UIAudio. Today UIAudio already accepts a fl::url(...) (see examples/AudioUrl/AudioUrl.ino, src/fl/ui.h:432), but the URL is hardcoded in the sketch. This proposal moves the asset reference into the project's data/ directory so it becomes a build-time artifact the platform layer can resolve — WASM today, ESP32 LittleFS tomorrow — without changing sketch source.
Motivation
- Current state:
fl::UIAudio audio(\"Audio\", fl::url(\"https://...\"))bakes the URL into the sketch. Swapping assets means recompiling. - Desired state:
fl::UIAudio audio(\"Audio\", fl::asset(\"data/track.mp3\"))— fbuild resolves the asset at build time based on what's indata/and the target platform's asset capabilities. - Precedent:
examples/Fx/FxSdCard/data/already carries runtime assets. We want the same ergonomics but with transparent URL-or-local resolution and a path to LittleFS on ESP32.
Proposed Asset Model
1. The data/ folder is first-class
- fbuild scans
<sketch>/data/at build time. - Each platform backend declares how it serves assets:
- WASM: assets become fetchable URLs (virtual filesystem or emitted
<script>blob). ExistingurlJSON field on the audio UI element is reused. - ESP32 (future): when
CONFIG_LITTLEFS_ENABLEis selected, fbuild packsdata/into a LittleFS partition image and flashes alongside the sketch. The runtime opens/data/track.mp3. - Native/stub/host tests: resolved via filesystem relative to the sketch.
- WASM: assets become fetchable URLs (virtual filesystem or emitted
- Sketch code is platform-agnostic:
fl::asset(\"data/track.mp3\")returns an opaque handle thatUIAudio(and futureUIImage,UIVideo, etc.) consume.
2. URL link files — design choice
The user raised two options for "this asset lives at a URL, not on disk":
| Option | Example | Pros | Cons |
|---|---|---|---|
| A. Bare file contains URL | data/track.mp3 whose contents are literally https://.../song.mp3\n |
zero-config; drop-in; no new extension | magic sniffing required; breaks any tool that opens the file as real MP3 bytes; confuses editors/preview; can't survive a binary byte that happens to match http |
| B. Suffix marker | data/track.mp3.lnk containing the URL |
explicit; unambiguous to tools and humans; preserves the underlying mime (.mp3) for type detection; easy to grep/list; extensible to multi-line (primary + fallback URLs, checksum, cache hint) |
one more filename convention to learn |
C. Windows .url / .desktop |
data/track.url (INI-style) |
established format | drops mime info; parser overhead; Windows Explorer auto-resolves and can hide the file |
Recommendation: Option B (*.lnk) as the primary mechanism, with Option A reserved as a future opt-in shortcut.
Rationale:
.lnkpreserves the real extension (track.mp3.lnk) so the asset pipeline still knows it's audio without sniffing content.- A build-time scan is trivial:
for f in data/**; if f.endswith('.lnk'): read_url(f). - Multi-line format leaves room for metadata without breaking v1:
https://www.soundhelix.com/examples/mp3/SoundHelix-Song-1.mp3 # optional: sha256=abc123... fallback=https://mirror.example.com/song.mp3 - Tooling (editors,
git diff,cat) handles it correctly with no surprises. - Forward-compatible: if we later want Option A ("bare file whose content is a URL"), we can add it as a detection pass without invalidating
.lnkfiles.
3. Sketch-side API (proposed)
// URL-backed asset (resolves .lnk at build time, or points to local file on LittleFS-capable platforms)
fl::UIAudio audio(\"Audio\", fl::asset(\"data/track.mp3\"));
// Equivalent explicit forms still work:
fl::UIAudio audio(\"Audio\", fl::url(\"https://...\")); // existing
fl::UIAudio audio(\"Audio\", fl::asset::local(\"data/track.mp3\")); // forces local/LittleFS
fl::UIAudio audio(\"Audio\", fl::asset::remote(\"data/track.mp3\")); // forces URL (must resolve to .lnk)fl::asset(path) is a compile-time-friendly handle. At runtime it yields either a fl::url or a filesystem path depending on the platform backend fbuild selected.
Scope of this Issue
In scope (v1):
-
.lnkfile format spec (one URL per line,#comments, trailing metadata keys TBD) -
fl::asset(path)handle type insrc/fl/asset.hwith compile-time path validation - fbuild scan of
<sketch>/data/to build an asset manifest - WASM backend: resolve
.lnk→fl::url, emit existingurlJSON field soUIAudiokeeps working with zero changes to the JS side (src/platforms/wasm/compiler/modules/audio/audio_manager.ts) - Host/stub backend: resolve local files via filesystem;
.lnkfalls back to URL viafl::urlfor tests - Migration:
examples/AudioUrl/gets adata/track.mp3.lnkvariant alongside the existing inline-URL version
Out of scope (tracked for future issues):
- ESP32 LittleFS partition generation and flashing from
data/ - ESP32 runtime asset open (
/data/track.mp3) - Option A (bare-file-with-URL auto-detection)
- Asset checksums / integrity verification
UIImage,UIVideoasset support (same pipeline, different UI element)
Risks / Open Questions
- Checksum / cache: should v1 of
.lnksupportsha256=so WASM can cache across reloads? Lean toward yes for the format, no for enforcement. - Path security:
fl::asset(\"data/../../../etc/passwd\")must be rejected at compile time. - Offline WASM: today the browser fetches the URL live. Do we also want fbuild to optionally pre-fetch and inline via data: URL? Defer.
- ESP32 partition layout: LittleFS requires partition table changes — needs coordination with existing partition presets.
References
src/fl/ui.h:428—class UIAudio(existing URL ctor)examples/AudioUrl/AudioUrl.ino— current URL usagetests/fl/audio_url.cpp— serialization tests forurlJSON fieldsrc/platforms/shared/ui/json/audio.h— JSON schema for audio UI elementexamples/Fx/FxSdCard/data/— existingdata/folder convention
Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fieldsTriage
Activity
feat(fl::url): add parse_lnk() helper for .lnk asset link files
feat(fl::url): add parse_lnk() helper for .lnk asset link files (#2286)
feat(fbuild): first-class data/ asset pipeline (#2284)
feat(fbuild): first-class data/ asset pipeline (#2284)
zackees commentedon Apr 19, 2026
Closing — shipped in
ec35801a feat(fbuild): first-class data/ asset pipeline (#2284)via PR #2335.Landed:
src/fl/asset.h+src/fl/asset.cpp.hpp— runtime asset resolution layer.ci/compiler/asset_scanner.py— build-time asset discovery that wiresdata/into sketches.src/fl/stl/url.hwithparse_lnk()helper (feat(fl::url): add parse_lnk() for .lnk asset link files (slice 1 of #2284) #2286, merged earlier as bd197af5) — resolves.lnkURL link files from the asset pipeline.examples/AudioUrl/AudioUrl.inoupdated to demonstrate the new flow;src/fl/ui.cpp.hpp/src/fl/ui.hintegrateUIAudiowith the pipeline.Reopen if there's a regression or the follow-up work (ESP32 LittleFS backend for the same pipeline) deserves its own tracker.