Ship MicroPython stubs from repo lib/ and seed workspace lib on startup
Move machine.py and neopixel.py into a tracked /lib/ at the repo root and auto-copy them into WORKSPACE_ROOT/lib whenever files are missing, so empty volumes and fresh per-user workspaces always have the read-only stubs available to Jedi and Pyodide. Allow all users to browse lib/ in the UI (writes still gated by the API), and add tests covering initial seeding and re-population after the dir is wiped. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
11
README.md
11
README.md
@@ -93,16 +93,19 @@ The home page can store the API key in `sessionStorage` when you are not using c
|
||||
## Layout
|
||||
|
||||
- `src/` — FastAPI app and static UI (`src/static/`)
|
||||
- `workspace/` — default tree: `code/` (editable), `lib/` (read-only via API)
|
||||
- `lib/` — bundled MicroPython stubs (copied into `WORKSPACE_ROOT/lib` when missing; read-only via API)
|
||||
- `workspace/` — default `WORKSPACE_ROOT`: `code/` samples (editable); runtime `lib/` is filled from `lib/` above
|
||||
|
||||
## ESP32 / NeoPixel mock
|
||||
|
||||
The browser runtime now includes MicroPython-style mocks in `workspace/lib`:
|
||||
The browser runtime ships MicroPython-style stubs in repo `lib/` (they appear as `lib/` in the editor and are read-only via the APIs):
|
||||
|
||||
- `machine.Pin`
|
||||
- `machine.Pin`, `machine.freq()`, `machine.unique_id()`, `machine.reset()` (no-op here)
|
||||
- `neopixel.NeoPixel`
|
||||
- `utime` — `ticks_ms`, `ticks_diff`, `ticks_add`, `sleep_ms`, `sleep_us`, `sleep`
|
||||
- `micropython.const` — no-op helper for ported constant declarations
|
||||
|
||||
Use them from scripts in `workspace/code` exactly like ESP32 examples:
|
||||
Use them from scripts in `workspace/code` like typical ESP32 / MicroPython examples:
|
||||
|
||||
```python
|
||||
from machine import Pin
|
||||
|
||||
Reference in New Issue
Block a user