Add PyPI package installer, file-tree context menu, and demos UI

Expose micropip installs from the menu, right-click actions on the file
tree, local folder/file open shortcuts, and browse demos/ alongside code/.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-06-14 22:34:55 +12:00
parent 8c45097ec5
commit 551c3d1efc
5 changed files with 1616 additions and 108 deletions

View File

@@ -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=36">
<link rel="stylesheet" href="/static/styles.css?v=41">
</head>
<body>
<div class="container">
@@ -26,6 +26,8 @@
</div>
</div>
<div id="file-tree-context-menu" class="file-tree-context-menu" role="menu" hidden aria-hidden="true"></div>
<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="true" title="Toggle file browser"><span class="sidebar-toggle-icon" aria-hidden="true"></span></button>
@@ -48,6 +50,9 @@
<input type="checkbox" id="panel-16x16-checkbox" />
16×16 panel
</label>
<button type="button" class="menu-item menu-button" id="packages-menu-btn" role="menuitem">📦 Python packages…</button>
<button type="button" class="menu-item menu-button" id="menu-open-local-folder-btn" role="menuitem">📂 Open local folder…</button>
<button type="button" class="menu-item menu-button" id="menu-open-local-file-btn" role="menuitem">📄 Open local file…</button>
<div class="menu-separator" role="separator"></div>
<div class="menu-section-label" id="workspace-menu-label">Workspace</div>
<div id="workspace-menu-actions" role="group"></div>
@@ -121,6 +126,27 @@
</div>
</div>
<script type="module" src="/static/script.js?v=59"></script>
<div id="packages-modal" class="modal">
<div class="modal-content packages-modal-content">
<h3>Python packages (Pyodide)</h3>
<p class="packages-modal-hint">Install from PyPI using micropip inside the browser. Pure-Python wheels (or packages built for WebAssembly) usually work; manylinux-only C extensions often do not.</p>
<label class="packages-field-label" for="packages-install-input">Package names or PEP 508 specs</label>
<input type="text" id="packages-install-input" placeholder="e.g. httpx, phonenumbers" autocomplete="off" />
<div id="packages-pypi-info" class="packages-pypi-info" aria-live="polite"></div>
<div class="packages-modal-actions-row">
<button type="button" id="packages-lookup-btn" class="packages-secondary-btn">Look up on PyPI</button>
</div>
<div id="packages-modal-status" class="packages-modal-status" aria-live="polite"></div>
<pre id="packages-install-log" class="packages-install-log hidden" aria-label="Micropip installer output"></pre>
<p class="packages-saved-label">Saved in this browser (restored when the editor loads Pyodide):</p>
<ul id="packages-saved-list" class="packages-saved-list"></ul>
<div class="modal-actions">
<button type="button" id="packages-install-btn">Install</button>
<button type="button" id="packages-close-btn">Close</button>
</div>
</div>
</div>
<script type="module" src="/static/script.js?v=83"></script>
</body>
</html>

File diff suppressed because it is too large Load Diff

View File

@@ -138,6 +138,15 @@ button,
background: #f7fafc;
}
button.menu-item.menu-button {
border: none;
background: transparent;
width: 100%;
text-align: left;
font: inherit;
font-family: inherit;
}
.menu-checkbox input[type="checkbox"] {
margin: 0;
}
@@ -239,6 +248,63 @@ button,
padding: 0.5rem;
}
.file-tree-context-menu {
position: fixed;
z-index: 250;
min-width: 210px;
max-width: min(92vw, 300px);
background: #fff;
border: 1px solid #cbd5e0;
border-radius: 8px;
box-shadow: 0 10px 28px rgba(0, 0, 0, 0.16);
padding: 0.35rem 0;
font-size: 0.875rem;
color: #2d3748;
}
.file-tree-context-menu[hidden] {
display: none !important;
}
.file-tree-context-menu .file-tree-cm-note {
padding: 0.35rem 0.85rem 0.5rem;
font-size: 0.75rem;
color: #718096;
line-height: 1.35;
}
.file-tree-context-menu button {
display: block;
width: 100%;
text-align: left;
padding: 0.45rem 0.85rem;
border: none;
background: transparent;
cursor: pointer;
font: inherit;
color: inherit;
}
.file-tree-context-menu button:disabled {
opacity: 0.45;
cursor: not-allowed;
}
.file-tree-context-menu button:hover:not(:disabled) {
background: #edf2f7;
}
.file-tree-context-menu button.file-tree-cm-danger {
color: #c53030;
}
.file-tree-context-menu hr.file-tree-cm-sep {
height: 1px;
margin: 0.3rem 0.5rem;
background: #e2e8f0;
border: none;
}
.file-item {
padding: 0.5rem;
cursor: pointer;
@@ -1126,6 +1192,134 @@ button,
border-color: #2c5aa0;
}
.packages-modal-content {
width: min(440px, 92vw);
max-height: 85vh;
overflow-y: auto;
margin: 6% auto;
}
.packages-modal-hint {
font-size: 0.8rem;
color: #718096;
line-height: 1.45;
margin: 0 0 0.75rem;
}
.packages-field-label {
display: block;
font-size: 0.75rem;
font-weight: 600;
color: #64748b;
margin: 0.25rem 0 0.35rem;
}
.packages-pypi-info {
min-height: 1.2rem;
font-size: 0.85rem;
color: #334155;
margin: 0.15rem 0 0.5rem;
}
.packages-modal-actions-row {
margin-bottom: 0.65rem;
}
.packages-secondary-btn {
padding: 0.4rem 0.75rem;
border: 1px solid #cbd5e0;
background: #f8fafc;
color: #334155;
border-radius: 6px;
font-size: 0.8rem;
cursor: pointer;
}
.packages-secondary-btn:hover {
background: #edf2f7;
}
.packages-modal-status {
min-height: 1.25rem;
font-size: 0.85rem;
color: #2b6cb0;
margin-bottom: 0.5rem;
}
.packages-install-log {
max-height: 12rem;
overflow: auto;
margin: 0 0 0.65rem;
padding: 0.45rem 0.5rem;
font-size: 0.72rem;
line-height: 1.35;
color: #1e293b;
background: #f8fafc;
border: 1px solid #e2e8f0;
border-radius: 6px;
white-space: pre-wrap;
word-break: break-word;
}
.packages-saved-label {
font-size: 0.75rem;
font-weight: 600;
color: #64748b;
margin: 0 0 0.35rem;
}
.packages-saved-list {
list-style: none;
margin: 0 0 1rem;
padding: 0;
border: 1px solid #e2e8f0;
border-radius: 6px;
max-height: 10rem;
overflow-y: auto;
}
.packages-saved-item {
display: flex;
align-items: center;
justify-content: space-between;
gap: 0.5rem;
padding: 0.4rem 0.55rem;
border-bottom: 1px solid #f1f5f9;
font-size: 0.85rem;
color: #2d3748;
}
.packages-saved-item:last-child {
border-bottom: none;
}
.packages-saved-item span {
word-break: break-all;
}
.packages-saved-empty {
padding: 0.55rem 0.65rem;
color: #94a3b8;
font-size: 0.85rem;
}
.packages-remove-btn {
flex-shrink: 0;
padding: 0.2rem 0.45rem;
font-size: 0.75rem;
border: 1px solid #e2e8f0;
background: white;
border-radius: 4px;
cursor: pointer;
color: #4a5568;
}
.packages-remove-btn:hover {
background: #fff5f5;
border-color: #feb2b2;
color: #c53030;
}
/* Desktop: hide the file browser when collapsed via the hamburger toggle. */
@media (min-width: 769px) {
.sidebar.is-collapsed {

View File

@@ -245,6 +245,6 @@
</section>
</div>
</main>
<script type="module" src="/static/tutorial.js?v=2"></script>
<script type="module" src="/static/tutorial.js?v=4"></script>
</body>
</html>

View File

@@ -289,7 +289,7 @@ class TutorialApp {
ensurePyWorker() {
if (!this.pyWorker) {
this.pyWorker = new Worker("/static/pyodide-worker.js?v=4");
this.pyWorker = new Worker("/static/pyodide-worker.js?v=24");
this.pyWorker.onmessage = (event) => this.onWorkerMessage(event);
}
return this.pyWorker;