Skip to content

Support .lnk and assets.json, and back getEmbeddedFs() with the WASM VFS #216

Closed

Description

@zackees

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:

  1. .lnk files are excluded from the file manifest. generate_manifest() filters on data_extensions — .json, .csv, .txt, .cfg, .bin, .dat, .mp3, .wav. .lnk is not in the set, so the sidecar is never listed. Correct as far as it goes: the sidecar is not the asset.

  2. The real asset does not exist locally. Only track.mp3.lnk is on disk. So even if .lnk were listed, fetch('data/track.mp3') 404s.

  3. asset_manifest.json is written but unread. fastled_init.ts:361 fetches sketch_assets.json, falling back to files.json. Nothing in the frontend mentions asset_manifest.json — a repo-wide search for lnk/asset_manifest matches 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
#endif

WASM 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

  1. Frontend consumes the asset manifest. Merge asset_manifest.json into 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 existing jsAppendFileUint8 path so nothing downstream changes.
  2. Size is not known up-front for a remote asset. The current manifest carries size and the loader logs it; a .lnk may declare size but need not. Decide whether to require it, read Content-Length, or make size optional.
  3. getEmbeddedFs() on WASM returns the VFS, so LittleFS-targeted sketches work unmodified. FastLED-side change.
  4. Honor storage targets. 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.
  5. 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

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions