diff --git a/.dockerignore b/.dockerignore deleted file mode 100644 index e81dc79c..00000000 --- a/.dockerignore +++ /dev/null @@ -1,2 +0,0 @@ -**/.mypy_cache/ -**/.ruff_cache/ \ No newline at end of file diff --git a/chrome_vscode_bridge_design_task.md b/chrome_vscode_bridge_design_task.md deleted file mode 100644 index 71dd891f..00000000 --- a/chrome_vscode_bridge_design_task.md +++ /dev/null @@ -1,195 +0,0 @@ -Hereβs a refined `chrome_vscode_bridge_design_task.md` file for your repo. Feel free to adjust paths, placeholders, or formatting to match your project's style. - ---- - -# Chrome β VSCode Bridge Design π οΈ - -## Overview - -Design and implement a minimal debugging bridge between a Python backend (using a hypothetical `fastled` library) and a Chrome-based frontend, invokable from VS Code. The goal is to allow: - -* **Step-through debugging** (`step`, `next`, `in`, `out`) -* **Program counter**, call stack, local variable inspection -* Integration with VS Code Python or Node debugger - ---- - -## π Architecture - -``` -[VS Code] β [Chrome Frontend CLI: Puppeteer + CDP] β HTTP β [Python Debug API (fastled)] -``` - -1. **Backend** (`Python + Flask`) - - * Exposes endpoints: - - * `POST /start` β begins execution, stops at first pause - * `POST /step/next` β advances one logical step - * `GET /state` β returns `{ pc, function, locals }` - * Internally uses generator-based control flow and `inspect` to snapshot state. -2. **Frontend** (`Node.js + Puppeteer`) - - * Launches Chrome with remote-debugging enabled - * Serves a minimal UI (e.g. HTML + JS) to send `start`, `step`, and poll `state` - * Renders debugging state to the user; future CDP integration for real-time UI -3. **VS Code Integration** - - * Launch configuration invokes the frontend script - * Stepping and inspection occur in the Chrome UI - * Optionally hooks into VS Code Debug Console for unified control - ---- - -## π Files - -### 1. `debug_fastled_api.py` (Backend) - -```python -import fastled, inspect -from flask import Flask, jsonify, request - -app = Flask(__name__) -_state, _step_generator = {}, None - -def compute(n): - x = n * 2 - y = fastled.compute(x) - yield from report_and_pause() - return y - -def report_and_pause(): - frame = inspect.currentframe().f_back - _state.update({ - "pc": frame.f_lineno, - "func": frame.f_code.co_name, - "locals": frame.f_locals.copy() - }) - yield True - -@app.route('/start', methods=['POST']) -def start(): - global _step_generator - n = request.json.get("n", 5) - def runner(): - gen = compute(n) - try: next(gen) - except StopIteration: pass - _step_generator = runner - return jsonify({"status": "started"}) - -@app.route('/state', methods=['GET']) -def state(): - return jsonify(_state) - -@app.route('/step/next', methods=['POST']) -def step_next(): - try: - _step_generator() - return jsonify({"status": "paused", **_state}) - except Exception: - return jsonify({"status": "done"}) - -if __name__ == "__main__": - app.run(port=5000) -``` - ---- - -### 2. `debug_fastled_frontend.js` (Frontend) - -```js -const puppeteer = require('puppeteer-core'); -const fetch = require('node-fetch'); - -(async () => { - const browser = await puppeteer.launch({ - executablePath: '/path/to/chrome', - args: ['--remote-debugging-port=9222'] - }); - const [page] = await browser.pages(); - - const html = ` - - -
- - `; - await page.setContent(html); -})(); -``` - ---- - -## βοΈ Integration with VS Code - -Add this to `.vscode/launch.json`: - -```jsonc -{ - "configurations": [ - { - "name": "Chrome-FastLED Debug Bridge", - "type": "node", - "request": "launch", - "program": "${workspaceFolder}/debug_fastled_frontend.js" - } - ] -} -``` - -* Launch this first to start Chrome with debugging enabled -* Use the UI to `Start`, `Next`, and inspect state output -* Optionally, add CDP logic to highlight lines in VS Code or Chrome DevTools - ---- - -## β Roadmap & Next Steps - -| Task | Status | -| --------------------------------------- | ------------- | -| Generator-based stepping API | β Implemented | -| Backend state introspection (PC/locals) | β Implemented | -| Frontend stepping UI (buttons + state) | β Implemented | -| VS Code `launch.json` integration | β Drafted | -| CDP / DevTools integration | π² To Do | -| Support for `step in`, `step out` | π² To Do | -| Breakpoints, multi-file support | π² To Do | - ---- - -## π§ Future Enhancements - -* **Full CDP client**: translate HTTP state to actual Chrome DevTools UI breakpoints/stepping -* **Rich UI**: live code view, synchronized highlighting, variable inspectors -* **Language-agnostic bridge**: plug in Node.js or other backends -* **VS Code Extension support**: unify stepping flows and tooltips - ---- - -## π Summary - -This bridge provides: - -* A **Python backend** exposing stepping and state via HTTP -* A **Node.js/pupeteer frontend** for remote-debug Chrome UI -* **VS Code launch config** for seamless integration - -You're all set to explore, refine, or build upon this foundation. Let me know if you'd like help developing CDP integration or full VS Code extension support! diff --git a/compiler/debug.sh b/compiler/debug.sh deleted file mode 100755 index bf11fb8e..00000000 --- a/compiler/debug.sh +++ /dev/null @@ -1,6 +0,0 @@ -#!/bin/bash - -# Run this when you want to debug the compiler and you are in interactive -# mode at /js - -python compile.py --debug --keep \ No newline at end of file diff --git a/compiler/run.py b/compiler/run.py deleted file mode 100644 index b4c0ac6a..00000000 --- a/compiler/run.py +++ /dev/null @@ -1,104 +0,0 @@ -import argparse -import os -import subprocess -import sys -import warnings -from pathlib import Path -from typing import Tuple - -from fastled_wasm_compiler import Compiler # type: ignore[reportMissingImports] - -from fastled.interrupts import handle_keyboard_interrupt - -from fastled_wasm_compiler.paths import VOLUME_MAPPED_SRC # type: ignore[reportMissingImports] # isort: skip - -_PORT = os.environ.get("PORT", 80) - -_CHOICES = ["compile", "server"] - -HERE = Path(__file__).parent - - -def _parse_args() -> Tuple[argparse.Namespace, list[str]]: - parser = argparse.ArgumentParser( - description="Run compile.py with additional arguments" - ) - parser.add_argument( - "mode", help="Which mode does this script run in", choices=_CHOICES - ) - return parser.parse_known_args() - - -def _run_server(unknown_args: list[str]) -> int: - env = os.environ.copy() - if "--disable-auto-clean" in unknown_args: - env["DISABLE_AUTO_CLEAN"] = "1" - unknown_args.remove("--disable-auto-clean") - if "--allow-shutdown" in unknown_args: - env["ALLOW_SHUTDOWN"] = "1" - unknown_args.remove("--allow-shutdown") - if "--no-auto-update" in unknown_args: - env["NO_AUTO_UPDATE"] = "1" - unknown_args.remove("--no-auto-update") - if "--no-sketch-cache" in unknown_args: - env["NO_SKETCH_CACHE"] = "1" - unknown_args.remove("--no-sketch-cache") - if unknown_args: - warnings.warn(f"Unknown arguments: {unknown_args}") - unknown_args = [] - cmd_list = [ - "uvicorn", - "fastled_wasm_server.server:app", - "--host", - "0.0.0.0", - "--workers", - "1", - "--port", - f"{_PORT}", - ] - cp: subprocess.CompletedProcess = subprocess.run(cmd_list, cwd=str(HERE), env=env) - return cp.returncode - - -def _run_compile(unknown_args: list[str]) -> int: - - # Construct the command to call compile.py with unknown arguments - command = [sys.executable, "compile.py"] + unknown_args - - # Call compile.py with the unknown arguments - result = subprocess.run(command, text=True, cwd=str(HERE)) - - # Print the output from compile.py - # print(result.stdout) - # if result.stderr: - # print(result.stderr, file=sys.stderr) - return result.returncode - - -def main() -> int: - print("Running...") - args, unknown_args = _parse_args() - compiler = Compiler( - volume_mapped_src=VOLUME_MAPPED_SRC, - ) - compiler.update_src() - - try: - if args.mode == "compile": - warnings.warn( - "The compile mode is deprecated and may fail. Use server mode instead." - ) - rtn = _run_compile(unknown_args) - return rtn - elif args.mode == "server": - rtn = _run_server(unknown_args) - return rtn - raise ValueError(f"Unknown mode: {args.mode}") - except KeyboardInterrupt as ki: - print("Exiting...") - handle_keyboard_interrupt(ki) - return 1 - - -if __name__ == "__main__": - sys.exit(main()) diff --git a/entrypoint.sh b/entrypoint.sh deleted file mode 100644 index 78044a4a..00000000 --- a/entrypoint.sh +++ /dev/null @@ -1,13 +0,0 @@ -#!/usr/bin/env bash - -# load emsdk environment -source /emsdk/emsdk_env.sh -export PATH="$PATH:/emsdk/upstream/bin" - -# only do the final prewarm if RUNTIME_PREWARM is set to "1" -if [[ "${RUNTIME_PREWARM:-0}" == "1" ]]; then - uv run -m fastled_wasm_compiler.cli_update_from_master -fi - -# hand off to the main command -exec "$@" diff --git a/lint b/lint index 85b0658e..7f8f39ea 100755 --- a/lint +++ b/lint @@ -13,17 +13,17 @@ else echo "WARNING: cargo not found, skipping Rust linting" fi -echo Running ruff src compiler -uv run ruff check --fix src compiler -echo Running ruff tests compiler -uv run ruff check --fix tests compiler -echo Running black src tests compiler -uv run black src tests compiler -echo Running isort src tests compiler -uv run isort --profile black src tests compiler -echo Running pyright src tests compiler -uv run pyright src compiler tests -echo Running keyboard interrupt checker src tests compiler -uv run python ci/lint_python/keyboard_interrupt_checker.py src tests compiler +echo Running ruff src +uv run ruff check --fix src +echo Running ruff tests +uv run ruff check --fix tests +echo Running black src tests +uv run black src tests +echo Running isort src tests +uv run isort --profile black src tests +echo Running pyright src tests +uv run pyright src tests +echo Running keyboard interrupt checker src tests +uv run python ci/lint_python/keyboard_interrupt_checker.py src tests echo Linting complete! exit 0 diff --git a/upload_package.sh b/upload_package.sh deleted file mode 100755 index 5280f60c..00000000 --- a/upload_package.sh +++ /dev/null @@ -1,7 +0,0 @@ -#!/bin/bash -set -e -rm -rf build dist -uv pip install wheel twine -uv build --wheel -uv run twine upload dist/* --verbose -# echo Pushing git tagsβ¦