Repository navigation
Description
Goal
A sketch that declares a remote asset — data/track.mp3.lnk or an assets.json entry — should run in the browser with that asset present in the filesystem, reachable through the same FastLED API the sketch would use on an ESP32. examples/AudioUrl receiving real audio bytes is the acceptance test.
The second half matters as much as the first: we want fl::getEmbeddedFs() to work on WASM, so the browser simulates ESP LittleFS. A sketch written against on-chip flash should run unmodified in the web preview.
Where it breaks today
The asset declaration is parsed and a manifest is written, and then nothing reads it.
data/track.mp3.lnk
-> ci/wasm_build.py::generate_asset_manifest
-> fastled_js/asset_manifest.json {"data/track.mp3": {"url": ...}}
|
X nothing fetches this
files.json / sketch_assets.json
-> fastled_init.ts::fetchAllFiles -> fetch(file.path) -> jsAppendFileUint8 -> VFS
Three concrete facts behind that:
-
.lnkfiles are excluded from the file manifest.generate_manifest()filters ondata_extensions—.json,.csv,.txt,.cfg,.bin,.dat,.mp3,.wav..lnkis not in the set, so the sidecar is never listed. Correct as far as it goes: the sidecar is not the asset. -
The real asset does not exist locally. Only
track.mp3.lnkis on disk. So even if.lnkwere listed,fetch('data/track.mp3')404s. -
asset_manifest.jsonis written but unread.fastled_init.ts:361fetchessketch_assets.json, falling back tofiles.json. Nothing in the frontend mentionsasset_manifest.json— a repo-wide search forlnk/asset_manifestmatches one file and one unrelated comment.
So the pipeline stops at a manifest nobody consumes.
And getEmbeddedFs() is a no-op on WASM
FastLED gained an embedded-flash backend in FastLED#4006. Its dispatch:
// src/platforms/embedded_fs.h
#if defined(FL_IS_ESP32) || (defined(FL_IS_ESP8266) && defined(FASTLED_ESP8266_EMBEDDED_FS))
#include "platforms/esp/fs/embedded_fs_esp.hpp" // LittleFS
#else
#include "platforms/shared/embedded_fs_noop.hpp" // <- WASM lands here
#endifWASM already has a perfectly good VFS — FsImplWasm in src/platforms/wasm/fs_wasm.cpp.hpp, reached today via make_sdcard_filesystem(). So on WASM the "SD card" is the browser VFS, and getEmbeddedFs() returns null. A sketch written for ESP LittleFS silently gets nothing in the web preview, which is the opposite of what a simulator should do.
Plan
- Frontend consumes the asset manifest. Merge
asset_manifest.jsoninto the file list, fetching each asset from its declared URL and streaming it into the VFS under its logical path (data/track.mp3), reusing the existingjsAppendFileUint8path so nothing downstream changes. - Size is not known up-front for a remote asset. The current manifest carries
sizeand the loader logs it; a.lnkmay declaresizebut need not. Decide whether to require it, readContent-Length, or make size optional. getEmbeddedFs()on WASM returns the VFS, so LittleFS-targeted sketches work unmodified. FastLED-side change.- Honor
storagetargets. FastLED's scanner now parses a storage target (littlefs,spiffs,sdcard,firmware,vfs,none) from all three declaration forms. WASM should treat on-chip targets as "put it in the VFS" — that is what simulating LittleFS means. - Verify with AudioUrl — not "it compiles", but the sketch actually receiving audio bytes.
Acceptance
examples/AudioUrl builds for WASM, and at runtime the browser fetches the asset named by data/track.mp3.lnk and hands the bytes to the sketch. Anything that blocks that gets a sub-issue.
Context
- FastLED#2284 — the v1 asset pipeline this completes
- FastLED#4006 — the embedded FS backend
- investigate: storage-target descriptors and misconfiguration diagnostics for .lnk / assets.json fbuild#1356 — storage-target descriptors and the target vocabulary
Activity