Add local-mode workspace, ZIP import/export, and richer pin/ADC/serial sims
Boot: - Editor now picks local vs server mode based on URL flag, sign-in state, and a stale local-mode flag. Signed-in users are no longer bounced to IndexedDB if they had previously clicked "Use locally". Local mode: - New LocalWorkspaceClient (src/static/local-workspace.js) with pluggable IndexedDB and File System Access backends. Picked folder handles persist across reloads with a Reconnect button when the permission lapses. - Static-only host: scripts/serve_static_editor.py serves src/static/ with COOP/COEP so SharedArrayBuffer-backed sims keep working. - Bundled MicroPython stubs ship under src/static/bundled-lib/ for static hosting; FastAPI also exposes them at /api/public/lib-bundle. Workspace import / export: - Zero-dep ZIP encoder + reader (STORE + DEFLATE via DecompressionStream). Export/Import buttons in the workspace badge work in both local and server modes; imports are confined to code/. Pin / ADC / Serial simulation: - machine.py grows ADC, UART, expanded Pin, and PWM mocks, all driven by SharedArrayBuffer when cross-origin isolated and falling back to postMessage + [pin-out] stdout markers otherwise — pins, ADC slider, and serial input now keep working over plain HTTP / LAN-IP origins. - NeoPixel pins are claimed via a [pin-claim] marker and dropped from the Pins panel so the data line doesn't flicker per write(). - New demos: adc_slider_demo.py, pin_demo.py, serial_demo.py. Lib layout: - Single source of truth at repo lib/; workspace/lib/ caching layer removed and the directory deleted. Filesystem service reads stubs directly from PROJECT_ROOT/lib. UI: - Home page slimmed to "Sign in" + "Use locally" with optional editor / manage-users links. Admin user/invite UI moved to /users. - Workspace badge gains storage indicator, Folder…/Reconnect, Export, Import, and Exit controls. - Mobile-friendly tweaks: safer-area padding, larger touch targets, iOS-zoom-proof serial input, file-tree highlight fix. Tests: - test_auth.py patches PROJECT_ROOT for the lib-shared test so the repo-root lib refactor stays green. test_api.py asserts the new "LED Editor" branding. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -6,7 +6,7 @@
|
||||
<meta name="theme-color" content="#2d3748">
|
||||
<title>LED Editor</title>
|
||||
<link rel="icon" href="data:,">
|
||||
<link rel="stylesheet" href="/static/styles.css?v=13">
|
||||
<link rel="stylesheet" href="/static/styles.css?v=32">
|
||||
</head>
|
||||
<body>
|
||||
<div class="container">
|
||||
@@ -28,27 +28,28 @@
|
||||
|
||||
<div class="main-content">
|
||||
<div class="editor-header">
|
||||
<button id="sidebar-toggle" class="sidebar-toggle" type="button" aria-label="Toggle file tree" aria-controls="sidebar" aria-expanded="false">☰</button>
|
||||
<button id="sidebar-toggle" class="sidebar-toggle" type="button" aria-label="Toggle file tree" aria-controls="sidebar" aria-expanded="true" title="Toggle file browser"><span class="sidebar-toggle-icon" aria-hidden="true">‹</span></button>
|
||||
<div class="file-info">
|
||||
<span id="save-status" class="save-status"></span>
|
||||
<span class="runtime-hint" title="Python runs locally in your browser via Pyodide; completions use Jedi in the same runtime.">Browser · Pyodide</span>
|
||||
<span id="lsp-status" class="runtime-hint" title="Jedi in-browser diagnostics">LSP: n/a</span>
|
||||
<span id="workspace-badge" class="runtime-hint hidden"></span>
|
||||
</div>
|
||||
<div class="mode-toggle">
|
||||
<a id="home-btn" class="mode-btn active" href="/">Home</a>
|
||||
</div>
|
||||
<div class="editor-actions">
|
||||
<button id="run-btn" disabled>Run Python</button>
|
||||
<button id="stop-btn" disabled>Stop</button>
|
||||
<label for="run-main-checkbox" class="run-main-toggle">
|
||||
<input type="checkbox" id="run-main-checkbox" />
|
||||
Run `main.py`
|
||||
</label>
|
||||
<label for="panel-16x16-checkbox" class="run-main-toggle">
|
||||
<input type="checkbox" id="panel-16x16-checkbox" />
|
||||
16x16 panel
|
||||
</label>
|
||||
<button id="run-btn" class="icon-btn" disabled aria-label="Run" title="Run">▶</button>
|
||||
<button id="stop-btn" class="icon-btn" disabled aria-label="Stop" title="Stop">■</button>
|
||||
<details class="header-menu" id="header-menu">
|
||||
<summary class="menu-toggle" aria-label="Editor options" title="Options">⋮</summary>
|
||||
<div class="menu-content" role="menu">
|
||||
<a href="/" class="menu-item" id="home-btn" role="menuitem">🏠 Home</a>
|
||||
<label class="menu-item menu-checkbox">
|
||||
<input type="checkbox" id="run-main-checkbox" />
|
||||
Run main.py
|
||||
</label>
|
||||
<label class="menu-item menu-checkbox">
|
||||
<input type="checkbox" id="panel-16x16-checkbox" />
|
||||
16×16 panel
|
||||
</label>
|
||||
</div>
|
||||
</details>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -60,20 +61,47 @@
|
||||
</div>
|
||||
|
||||
<section id="led-sim-panel" class="led-sim-panel hidden" aria-label="NeoPixel Simulator">
|
||||
<div class="led-sim-header">
|
||||
<h3>NeoPixel Simulator</h3>
|
||||
<div class="led-sim-actions">
|
||||
<button id="led-run-btn" type="button">Run</button>
|
||||
<button id="led-stop-btn" type="button">Stop</button>
|
||||
<button id="led-close-btn" type="button" aria-label="Close simulator">Close</button>
|
||||
</div>
|
||||
</div>
|
||||
<div id="led-meta" class="led-meta">Waiting for neopixel.write()...</div>
|
||||
<div id="led-grid" class="led-grid"></div>
|
||||
</section>
|
||||
|
||||
<div class="console-container">
|
||||
<div class="console-header">Console Output</div>
|
||||
<section id="pin-panel" class="pin-panel hidden" aria-label="Pins">
|
||||
<div class="pin-panel-header">
|
||||
<span class="pin-panel-title">Pins</span>
|
||||
<span class="pin-panel-hint">OUT shows live state · IN is clickable · PWM shows duty</span>
|
||||
</div>
|
||||
<div id="pin-rows" class="pin-rows"></div>
|
||||
</section>
|
||||
|
||||
<section id="adc-panel" class="adc-panel hidden" aria-label="ADC inputs">
|
||||
<div class="adc-panel-header">
|
||||
<span class="adc-panel-title">ADC inputs</span>
|
||||
<span class="adc-panel-hint">drag to set value (0–65535)</span>
|
||||
</div>
|
||||
<div id="adc-sliders" class="adc-sliders"></div>
|
||||
</section>
|
||||
|
||||
<section id="serial-panel" class="serial-panel hidden" aria-label="Serial monitor">
|
||||
<div class="serial-header">
|
||||
<span class="serial-title">Serial monitor</span>
|
||||
<span id="serial-meta" class="serial-meta"></span>
|
||||
<button type="button" id="serial-clear" class="serial-clear" title="Clear">Clear</button>
|
||||
</div>
|
||||
<div id="serial-output" class="serial-output" aria-live="polite"></div>
|
||||
<form id="serial-form" class="serial-form" autocomplete="off">
|
||||
<input id="serial-input" type="text" class="serial-input" placeholder="Type and press Enter to send" />
|
||||
<label class="serial-newline" title="Append \n on send">
|
||||
<input type="checkbox" id="serial-newline-checkbox" checked />
|
||||
<span>\n</span>
|
||||
</label>
|
||||
<button type="submit" class="serial-send">Send</button>
|
||||
</form>
|
||||
</section>
|
||||
|
||||
<div class="console-container" id="console-container">
|
||||
<button type="button" class="console-header" id="console-toggle" aria-expanded="true" aria-controls="console-output">
|
||||
<span class="chevron" aria-hidden="true">▾</span>
|
||||
<span>Console Output</span>
|
||||
</button>
|
||||
<pre id="console-output" class="console-output"></pre>
|
||||
</div>
|
||||
</div>
|
||||
@@ -90,6 +118,6 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script type="module" src="/static/script.js?v=27"></script>
|
||||
<script type="module" src="/static/script.js?v=56"></script>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
Reference in New Issue
Block a user