fastled 1.2.60__tar.gz → 1.2.63__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {fastled-1.2.60 → fastled-1.2.63}/PKG-INFO +3 -1
- fastled-1.2.63/compiler/extra/mp3upload.html +38 -0
- {fastled-1.2.60 → fastled-1.2.63}/pyproject.toml +2 -0
- {fastled-1.2.60 → fastled-1.2.63}/src/fastled/__init__.py +1 -1
- {fastled-1.2.60 → fastled-1.2.63}/src/fastled/open_browser.py +14 -17
- {fastled-1.2.60 → fastled-1.2.63}/src/fastled/server_fastapi_cli.py +4 -4
- fastled-1.2.63/src/fastled/server_flask.py +152 -0
- fastled-1.2.60/src/fastled/open_browser2.py → fastled-1.2.63/src/fastled/server_start.py +64 -40
- {fastled-1.2.60 → fastled-1.2.63}/src/fastled.egg-info/PKG-INFO +3 -1
- {fastled-1.2.60 → fastled-1.2.63}/src/fastled.egg-info/SOURCES.txt +3 -1
- {fastled-1.2.60 → fastled-1.2.63}/src/fastled.egg-info/requires.txt +2 -0
- {fastled-1.2.60 → fastled-1.2.63}/.aiderignore +0 -0
- {fastled-1.2.60 → fastled-1.2.63}/.dockerignore +0 -0
- {fastled-1.2.60 → fastled-1.2.63}/.github/workflows/build_multi_docker_image.yml +0 -0
- {fastled-1.2.60 → fastled-1.2.63}/.github/workflows/build_webpage.yml +0 -0
- {fastled-1.2.60 → fastled-1.2.63}/.github/workflows/lint.yml +0 -0
- {fastled-1.2.60 → fastled-1.2.63}/.github/workflows/publish_release.yml +0 -0
- {fastled-1.2.60 → fastled-1.2.63}/.github/workflows/template_build_docker_image.yml +0 -0
- {fastled-1.2.60 → fastled-1.2.63}/.github/workflows/test_build_exe.yml +0 -0
- {fastled-1.2.60 → fastled-1.2.63}/.github/workflows/test_macos.yml +0 -0
- {fastled-1.2.60 → fastled-1.2.63}/.github/workflows/test_ubuntu.yml +0 -0
- {fastled-1.2.60 → fastled-1.2.63}/.github/workflows/test_win.yml +0 -0
- {fastled-1.2.60 → fastled-1.2.63}/.gitignore +0 -0
- {fastled-1.2.60 → fastled-1.2.63}/.pylintrc +0 -0
- {fastled-1.2.60 → fastled-1.2.63}/.vscode/launch.json +0 -0
- {fastled-1.2.60 → fastled-1.2.63}/.vscode/settings.json +0 -0
- {fastled-1.2.60 → fastled-1.2.63}/.vscode/tasks.json +0 -0
- {fastled-1.2.60 → fastled-1.2.63}/Dockerfile +0 -0
- {fastled-1.2.60 → fastled-1.2.63}/LICENSE +0 -0
- {fastled-1.2.60 → fastled-1.2.63}/MANIFEST.in +0 -0
- {fastled-1.2.60 → fastled-1.2.63}/README.md +0 -0
- {fastled-1.2.60 → fastled-1.2.63}/RELEASE.md +0 -0
- {fastled-1.2.60 → fastled-1.2.63}/TODO.md +0 -0
- {fastled-1.2.60 → fastled-1.2.63}/build_exe.py +0 -0
- {fastled-1.2.60 → fastled-1.2.63}/build_site.py +0 -0
- {fastled-1.2.60 → fastled-1.2.63}/clean +0 -0
- {fastled-1.2.60 → fastled-1.2.63}/compiler/CMakeLists.txt +0 -0
- {fastled-1.2.60 → fastled-1.2.63}/compiler/__init__.py +0 -0
- {fastled-1.2.60 → fastled-1.2.63}/compiler/arduino-pre-process.sh +0 -0
- {fastled-1.2.60 → fastled-1.2.63}/compiler/build.sh +0 -0
- {fastled-1.2.60 → fastled-1.2.63}/compiler/build_archive.sh +0 -0
- {fastled-1.2.60 → fastled-1.2.63}/compiler/build_fast.sh +0 -0
- {fastled-1.2.60 → fastled-1.2.63}/compiler/code_sync.py +0 -0
- {fastled-1.2.60 → fastled-1.2.63}/compiler/compile.py +0 -0
- {fastled-1.2.60 → fastled-1.2.63}/compiler/compile_lock.py +0 -0
- {fastled-1.2.60 → fastled-1.2.63}/compiler/entrypoint.sh +0 -0
- {fastled-1.2.60 → fastled-1.2.63}/compiler/extra/100dots.html +0 -0
- {fastled-1.2.60 → fastled-1.2.63}/compiler/extra/demo_threejs.html +0 -0
- {fastled-1.2.60 → fastled-1.2.63}/compiler/extra/micdemo.html +0 -0
- {fastled-1.2.60 → fastled-1.2.63}/compiler/extra/webgl_postprocessing_unreal_bloom.html +0 -0
- {fastled-1.2.60 → fastled-1.2.63}/compiler/final_prewarm.sh +0 -0
- {fastled-1.2.60 → fastled-1.2.63}/compiler/init_runtime.py +0 -0
- {fastled-1.2.60 → fastled-1.2.63}/compiler/install-arduino-cli.sh +0 -0
- {fastled-1.2.60 → fastled-1.2.63}/compiler/libcompile/CMakeLists.txt +0 -0
- {fastled-1.2.60 → fastled-1.2.63}/compiler/paths.py +0 -0
- {fastled-1.2.60 → fastled-1.2.63}/compiler/pre-process.sh +0 -0
- {fastled-1.2.60 → fastled-1.2.63}/compiler/prewarm.sh +0 -0
- {fastled-1.2.60 → fastled-1.2.63}/compiler/process-ino.py +0 -0
- {fastled-1.2.60 → fastled-1.2.63}/compiler/process_extended.py +0 -0
- {fastled-1.2.60 → fastled-1.2.63}/compiler/pyproject.toml +0 -0
- {fastled-1.2.60 → fastled-1.2.63}/compiler/run.py +0 -0
- {fastled-1.2.60 → fastled-1.2.63}/compiler/server.py +0 -0
- {fastled-1.2.60 → fastled-1.2.63}/compiler/sketch_hasher.py +0 -0
- {fastled-1.2.60 → fastled-1.2.63}/compiler/wasm_compiler_flags.py +0 -0
- {fastled-1.2.60 → fastled-1.2.63}/docker-compose.yml +0 -0
- {fastled-1.2.60 → fastled-1.2.63}/install +0 -0
- {fastled-1.2.60 → fastled-1.2.63}/install_linux.sh +0 -0
- {fastled-1.2.60 → fastled-1.2.63}/lint +0 -0
- {fastled-1.2.60 → fastled-1.2.63}/requirements.testing.txt +0 -0
- {fastled-1.2.60 → fastled-1.2.63}/setup.cfg +0 -0
- {fastled-1.2.60 → fastled-1.2.63}/setup.py +0 -0
- {fastled-1.2.60 → fastled-1.2.63}/src/fastled/app.py +0 -0
- {fastled-1.2.60 → fastled-1.2.63}/src/fastled/assets/example.txt +0 -0
- {fastled-1.2.60 → fastled-1.2.63}/src/fastled/assets/localhost-key.pem +0 -0
- {fastled-1.2.60 → fastled-1.2.63}/src/fastled/assets/localhost.pem +0 -0
- {fastled-1.2.60 → fastled-1.2.63}/src/fastled/cli.py +0 -0
- {fastled-1.2.60 → fastled-1.2.63}/src/fastled/cli_test.py +0 -0
- {fastled-1.2.60 → fastled-1.2.63}/src/fastled/client_server.py +0 -0
- {fastled-1.2.60 → fastled-1.2.63}/src/fastled/compile_server.py +0 -0
- {fastled-1.2.60 → fastled-1.2.63}/src/fastled/compile_server_impl.py +0 -0
- {fastled-1.2.60 → fastled-1.2.63}/src/fastled/docker_manager.py +0 -0
- {fastled-1.2.60 → fastled-1.2.63}/src/fastled/filewatcher.py +0 -0
- {fastled-1.2.60 → fastled-1.2.63}/src/fastled/interactive_srcs.py +0 -0
- {fastled-1.2.60 → fastled-1.2.63}/src/fastled/keyboard.py +0 -0
- {fastled-1.2.60 → fastled-1.2.63}/src/fastled/keyz.py +0 -0
- {fastled-1.2.60 → fastled-1.2.63}/src/fastled/live_client.py +0 -0
- {fastled-1.2.60 → fastled-1.2.63}/src/fastled/parse_args.py +0 -0
- {fastled-1.2.60 → fastled-1.2.63}/src/fastled/paths.py +0 -0
- {fastled-1.2.60 → fastled-1.2.63}/src/fastled/project_init.py +0 -0
- {fastled-1.2.60 → fastled-1.2.63}/src/fastled/select_sketch_directory.py +0 -0
- {fastled-1.2.60 → fastled-1.2.63}/src/fastled/server_fastapi.py +0 -0
- {fastled-1.2.60 → fastled-1.2.63}/src/fastled/settings.py +0 -0
- {fastled-1.2.60 → fastled-1.2.63}/src/fastled/site/build.py +0 -0
- {fastled-1.2.60 → fastled-1.2.63}/src/fastled/site/examples.py +0 -0
- {fastled-1.2.60 → fastled-1.2.63}/src/fastled/sketch.py +0 -0
- {fastled-1.2.60 → fastled-1.2.63}/src/fastled/spinner.py +0 -0
- {fastled-1.2.60 → fastled-1.2.63}/src/fastled/string_diff.py +0 -0
- {fastled-1.2.60 → fastled-1.2.63}/src/fastled/test/can_run_local_docker_tests.py +0 -0
- {fastled-1.2.60 → fastled-1.2.63}/src/fastled/test/examples.py +0 -0
- {fastled-1.2.60 → fastled-1.2.63}/src/fastled/types.py +0 -0
- {fastled-1.2.60 → fastled-1.2.63}/src/fastled/util.py +0 -0
- {fastled-1.2.60 → fastled-1.2.63}/src/fastled/web_compile.py +0 -0
- {fastled-1.2.60 → fastled-1.2.63}/src/fastled.egg-info/dependency_links.txt +0 -0
- {fastled-1.2.60 → fastled-1.2.63}/src/fastled.egg-info/entry_points.txt +0 -0
- {fastled-1.2.60 → fastled-1.2.63}/src/fastled.egg-info/top_level.txt +0 -0
- {fastled-1.2.60 → fastled-1.2.63}/test +0 -0
- {fastled-1.2.60 → fastled-1.2.63}/tests/integration/test_build_examples.py +0 -0
- {fastled-1.2.60 → fastled-1.2.63}/tests/integration/test_examples.py +0 -0
- {fastled-1.2.60 → fastled-1.2.63}/tests/unit/html/index.html +0 -0
- {fastled-1.2.60 → fastled-1.2.63}/tests/unit/test_api.py +0 -0
- {fastled-1.2.60 → fastled-1.2.63}/tests/unit/test_bad_ino.py +0 -0
- {fastled-1.2.60 → fastled-1.2.63}/tests/unit/test_cli.py +0 -0
- {fastled-1.2.60 → fastled-1.2.63}/tests/unit/test_compile_server.py +0 -0
- {fastled-1.2.60 → fastled-1.2.63}/tests/unit/test_docker_linux_on_windows.py +0 -0
- {fastled-1.2.60 → fastled-1.2.63}/tests/unit/test_embedded_data.py +0 -0
- {fastled-1.2.60 → fastled-1.2.63}/tests/unit/test_filechanger.py +0 -0
- {fastled-1.2.60 → fastled-1.2.63}/tests/unit/test_http_server.py +0 -0
- {fastled-1.2.60 → fastled-1.2.63}/tests/unit/test_ino/bad/bad.ino +0 -0
- {fastled-1.2.60 → fastled-1.2.63}/tests/unit/test_ino/bad_platformio/bad_platformio.ino +0 -0
- {fastled-1.2.60 → fastled-1.2.63}/tests/unit/test_ino/bad_platformio/platformio.ini +0 -0
- {fastled-1.2.60 → fastled-1.2.63}/tests/unit/test_ino/embedded/data/bigdata.dat +0 -0
- {fastled-1.2.60 → fastled-1.2.63}/tests/unit/test_ino/embedded/wasm.ino +0 -0
- {fastled-1.2.60 → fastled-1.2.63}/tests/unit/test_ino/wasm/wasm.ino +0 -0
- {fastled-1.2.60 → fastled-1.2.63}/tests/unit/test_project_init.py +0 -0
- {fastled-1.2.60 → fastled-1.2.63}/tests/unit/test_server_and_client_seperatly.py +0 -0
- {fastled-1.2.60 → fastled-1.2.63}/tests/unit/test_string_diff.py +0 -0
- {fastled-1.2.60 → fastled-1.2.63}/tests/unit/test_webcompile.py +0 -0
- {fastled-1.2.60 → fastled-1.2.63}/upload_package.sh +0 -0
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.4
|
2
2
|
Name: fastled
|
3
|
-
Version: 1.2.
|
3
|
+
Version: 1.2.63
|
4
4
|
Summary: FastLED Wasm Compiler
|
5
5
|
Home-page: https://github.com/zackees/fastled-wasm
|
6
6
|
Maintainer: Zachary Vorhies
|
@@ -23,6 +23,8 @@ Requires-Dist: fastapi>=0.115.12
|
|
23
23
|
Requires-Dist: uvicorn>=0.34.2
|
24
24
|
Requires-Dist: pywebview>=5.4
|
25
25
|
Requires-Dist: watchfiles>=1.0.5
|
26
|
+
Requires-Dist: Flask>=3.0.0
|
27
|
+
Requires-Dist: livereload
|
26
28
|
Dynamic: home-page
|
27
29
|
Dynamic: license-file
|
28
30
|
Dynamic: maintainer
|
@@ -0,0 +1,38 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html lang="en">
|
3
|
+
<head>
|
4
|
+
<meta charset="UTF-8">
|
5
|
+
<title>MP3 Upload & Play Demo</title>
|
6
|
+
</head>
|
7
|
+
<body>
|
8
|
+
<!-- Button that triggers the hidden file input -->
|
9
|
+
<button id="upload_mp3">upload_mp3</button>
|
10
|
+
<!-- Hidden file input, restricted to MP3 files -->
|
11
|
+
<input type="file" id="file_input" accept="audio/mpeg" style="display:none" />
|
12
|
+
<!-- Audio element, shown once a file is loaded -->
|
13
|
+
<audio id="player" controls style="display:none; margin-top:1em;"></audio>
|
14
|
+
|
15
|
+
<script>
|
16
|
+
const uploadBtn = document.getElementById('upload_mp3');
|
17
|
+
const fileInput = document.getElementById('file_input');
|
18
|
+
const player = document.getElementById('player');
|
19
|
+
|
20
|
+
// When our button is clicked, open the file picker
|
21
|
+
uploadBtn.addEventListener('click', () => {
|
22
|
+
fileInput.click();
|
23
|
+
});
|
24
|
+
|
25
|
+
// When a file is selected...
|
26
|
+
fileInput.addEventListener('change', (e) => {
|
27
|
+
const file = e.target.files[0];
|
28
|
+
if (!file) return;
|
29
|
+
|
30
|
+
// Create a temporary URL & set it on the audio element
|
31
|
+
const url = URL.createObjectURL(file);
|
32
|
+
player.src = url;
|
33
|
+
player.style.display = 'block'; // show the player
|
34
|
+
player.play(); // start playback
|
35
|
+
});
|
36
|
+
</script>
|
37
|
+
</body>
|
38
|
+
</html>
|
@@ -13,7 +13,7 @@ from .types import BuildMode, CompileResult, CompileServerError
|
|
13
13
|
# IMPORTANT! There's a bug in github which will REJECT any version update
|
14
14
|
# that has any other change in the repo. Please bump the version as the
|
15
15
|
# ONLY change in a commit, or else the pypi update and the release will fail.
|
16
|
-
__version__ = "1.2.
|
16
|
+
__version__ = "1.2.63"
|
17
17
|
|
18
18
|
DOCKER_FILE = (
|
19
19
|
"https://raw.githubusercontent.com/zackees/fastled-wasm/refs/heads/main/Dockerfile"
|
@@ -14,10 +14,9 @@ SSL_CONFIG = get_ssl_config()
|
|
14
14
|
# print(f"SSL Config: {SSL_CONFIG.certfile}, {SSL_CONFIG.keyfile}")
|
15
15
|
|
16
16
|
|
17
|
-
def
|
17
|
+
def _open_http_server_subprocess(
|
18
18
|
fastled_js: Path,
|
19
19
|
port: int,
|
20
|
-
open_browser: bool,
|
21
20
|
) -> None:
|
22
21
|
print("\n################################################################")
|
23
22
|
print(f"# Opening browser to {fastled_js} on port {port}")
|
@@ -27,13 +26,11 @@ def open_http_server_subprocess(
|
|
27
26
|
cmd = [
|
28
27
|
PYTHON_EXE,
|
29
28
|
"-m",
|
30
|
-
"fastled.
|
29
|
+
"fastled.server_start",
|
31
30
|
str(fastled_js),
|
32
31
|
"--port",
|
33
32
|
str(port),
|
34
33
|
]
|
35
|
-
if open_browser:
|
36
|
-
cmd.append("--open-browser")
|
37
34
|
# Pass SSL flags if available
|
38
35
|
if SSL_CONFIG.certfile and SSL_CONFIG.keyfile:
|
39
36
|
cmd.extend(
|
@@ -52,7 +49,7 @@ def open_http_server_subprocess(
|
|
52
49
|
subprocess.run(
|
53
50
|
cmd,
|
54
51
|
stdout=subprocess.DEVNULL,
|
55
|
-
stderr=subprocess.DEVNULL,
|
52
|
+
# stderr=subprocess.DEVNULL,
|
56
53
|
) # type ignore
|
57
54
|
except KeyboardInterrupt:
|
58
55
|
print("Exiting from server...")
|
@@ -111,21 +108,21 @@ def open_browser_process(
|
|
111
108
|
port = find_free_port(DEFAULT_PORT)
|
112
109
|
|
113
110
|
proc = Process(
|
114
|
-
target=
|
115
|
-
args=(fastled_js, port
|
111
|
+
target=_open_http_server_subprocess,
|
112
|
+
args=(fastled_js, port),
|
116
113
|
daemon=True,
|
117
114
|
)
|
118
115
|
proc.start()
|
119
116
|
wait_for_server(port)
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
117
|
+
if open_browser:
|
118
|
+
print(f"Opening browser to http://localhost:{port}")
|
119
|
+
import webbrowser
|
120
|
+
|
121
|
+
webbrowser.open(
|
122
|
+
url=f"http://localhost:{port}",
|
123
|
+
new=1,
|
124
|
+
autoraise=True,
|
125
|
+
)
|
129
126
|
return proc
|
130
127
|
|
131
128
|
|
@@ -32,14 +32,14 @@ def _run_fastapi_server(
|
|
32
32
|
"fastled.server_fastapi:app",
|
33
33
|
host="127.0.0.1",
|
34
34
|
port=port,
|
35
|
-
reload=
|
36
|
-
reload_includes=["index.html"],
|
35
|
+
reload=False,
|
36
|
+
# reload_includes=["index.html"],
|
37
37
|
ssl_certfile=certfile,
|
38
38
|
ssl_keyfile=keyfile,
|
39
39
|
)
|
40
40
|
|
41
41
|
|
42
|
-
def
|
42
|
+
def run_fastapi_server_process(
|
43
43
|
port: int,
|
44
44
|
cwd: Path | None = None,
|
45
45
|
certfile: Path | None = None,
|
@@ -57,5 +57,5 @@ def run_fastapi_server_proces(
|
|
57
57
|
|
58
58
|
if __name__ == "__main__":
|
59
59
|
# Example usage
|
60
|
-
proc =
|
60
|
+
proc = run_fastapi_server_process(port=8000)
|
61
61
|
proc.join()
|
@@ -0,0 +1,152 @@
|
|
1
|
+
import argparse
|
2
|
+
from multiprocessing import Process
|
3
|
+
from pathlib import Path
|
4
|
+
|
5
|
+
from livereload import Server
|
6
|
+
|
7
|
+
|
8
|
+
def _run_flask_server(
|
9
|
+
fastled_js: Path,
|
10
|
+
port: int,
|
11
|
+
certfile: Path | None = None,
|
12
|
+
keyfile: Path | None = None,
|
13
|
+
) -> None:
|
14
|
+
"""Run Flask server with live reload in a subprocess
|
15
|
+
|
16
|
+
Args:
|
17
|
+
fastled_js: Path to the fastled_js directory
|
18
|
+
port: Port to run the server on
|
19
|
+
certfile: Path to the SSL certificate file
|
20
|
+
keyfile: Path to the SSL key file
|
21
|
+
"""
|
22
|
+
try:
|
23
|
+
from flask import Flask, send_from_directory
|
24
|
+
|
25
|
+
app = Flask(__name__)
|
26
|
+
|
27
|
+
# Must be a full path or flask will fail to find the file.
|
28
|
+
fastled_js = fastled_js.resolve()
|
29
|
+
|
30
|
+
@app.route("/")
|
31
|
+
def serve_index():
|
32
|
+
return send_from_directory(fastled_js, "index.html")
|
33
|
+
|
34
|
+
@app.route("/<path:path>")
|
35
|
+
def serve_files(path):
|
36
|
+
response = send_from_directory(fastled_js, path)
|
37
|
+
# Some servers don't set the Content-Type header for a bunch of files.
|
38
|
+
if path.endswith(".js"):
|
39
|
+
response.headers["Content-Type"] = "application/javascript"
|
40
|
+
if path.endswith(".css"):
|
41
|
+
response.headers["Content-Type"] = "text/css"
|
42
|
+
if path.endswith(".wasm"):
|
43
|
+
response.headers["Content-Type"] = "application/wasm"
|
44
|
+
if path.endswith(".json"):
|
45
|
+
response.headers["Content-Type"] = "application/json"
|
46
|
+
if path.endswith(".png"):
|
47
|
+
response.headers["Content-Type"] = "image/png"
|
48
|
+
if path.endswith(".jpg"):
|
49
|
+
response.headers["Content-Type"] = "image/jpeg"
|
50
|
+
if path.endswith(".jpeg"):
|
51
|
+
response.headers["Content-Type"] = "image/jpeg"
|
52
|
+
if path.endswith(".gif"):
|
53
|
+
response.headers["Content-Type"] = "image/gif"
|
54
|
+
if path.endswith(".svg"):
|
55
|
+
response.headers["Content-Type"] = "image/svg+xml"
|
56
|
+
if path.endswith(".ico"):
|
57
|
+
response.headers["Content-Type"] = "image/x-icon"
|
58
|
+
if path.endswith(".html"):
|
59
|
+
response.headers["Content-Type"] = "text/html"
|
60
|
+
|
61
|
+
# now also add headers to force no caching
|
62
|
+
response.headers["Cache-Control"] = "no-cache, no-store, must-revalidate"
|
63
|
+
response.headers["Pragma"] = "no-cache"
|
64
|
+
response.headers["Expires"] = "0"
|
65
|
+
return response
|
66
|
+
|
67
|
+
server = Server(app.wsgi_app)
|
68
|
+
# Watch index.html for changes
|
69
|
+
server.watch(str(fastled_js / "index.html"))
|
70
|
+
# server.watch(str(fastled_js / "index.js"))
|
71
|
+
# server.watch(str(fastled_js / "index.css"))
|
72
|
+
# Start the server
|
73
|
+
server.serve(port=port, debug=True)
|
74
|
+
except KeyboardInterrupt:
|
75
|
+
import _thread
|
76
|
+
|
77
|
+
_thread.interrupt_main()
|
78
|
+
except Exception as e:
|
79
|
+
print(f"Failed to run Flask server: {e}")
|
80
|
+
import _thread
|
81
|
+
|
82
|
+
_thread.interrupt_main()
|
83
|
+
|
84
|
+
|
85
|
+
def run(
|
86
|
+
port: int, cwd: Path, certfile: Path | None = None, keyfile: Path | None = None
|
87
|
+
) -> None:
|
88
|
+
"""Run the Flask server."""
|
89
|
+
try:
|
90
|
+
_run_flask_server(cwd, port, certfile, keyfile)
|
91
|
+
import warnings
|
92
|
+
|
93
|
+
warnings.warn("Flask server has stopped")
|
94
|
+
except KeyboardInterrupt:
|
95
|
+
import _thread
|
96
|
+
|
97
|
+
_thread.interrupt_main()
|
98
|
+
pass
|
99
|
+
|
100
|
+
|
101
|
+
def parse_args() -> argparse.Namespace:
|
102
|
+
"""Parse the command line arguments."""
|
103
|
+
parser = argparse.ArgumentParser(
|
104
|
+
description="Open a browser to the fastled_js directory"
|
105
|
+
)
|
106
|
+
parser.add_argument(
|
107
|
+
"fastled_js", type=Path, help="Path to the fastled_js directory"
|
108
|
+
)
|
109
|
+
parser.add_argument(
|
110
|
+
"--port",
|
111
|
+
"-p",
|
112
|
+
type=int,
|
113
|
+
required=True,
|
114
|
+
help="Port to run the server on (default: %(default)s)",
|
115
|
+
)
|
116
|
+
parser.add_argument(
|
117
|
+
"--certfile",
|
118
|
+
type=Path,
|
119
|
+
help="Path to the SSL certificate file for HTTPS",
|
120
|
+
)
|
121
|
+
parser.add_argument(
|
122
|
+
"--keyfile",
|
123
|
+
type=Path,
|
124
|
+
help="Path to the SSL key file for HTTPS",
|
125
|
+
)
|
126
|
+
return parser.parse_args()
|
127
|
+
|
128
|
+
|
129
|
+
def run_flask_server_process(
|
130
|
+
port: int,
|
131
|
+
cwd: Path | None = None,
|
132
|
+
certfile: Path | None = None,
|
133
|
+
keyfile: Path | None = None,
|
134
|
+
) -> Process:
|
135
|
+
"""Run the Flask server in a separate process."""
|
136
|
+
cwd = cwd or Path(".")
|
137
|
+
process = Process(
|
138
|
+
target=run,
|
139
|
+
args=(port, cwd, certfile, keyfile),
|
140
|
+
)
|
141
|
+
process.start()
|
142
|
+
return process
|
143
|
+
|
144
|
+
|
145
|
+
def main() -> None:
|
146
|
+
"""Main function."""
|
147
|
+
args = parse_args()
|
148
|
+
run(args.port, args.fastled_js, args.certfile, args.keyfile)
|
149
|
+
|
150
|
+
|
151
|
+
if __name__ == "__main__":
|
152
|
+
main()
|
@@ -1,8 +1,34 @@
|
|
1
1
|
import argparse
|
2
2
|
import importlib.resources as pkg_resources
|
3
|
+
from dataclasses import dataclass
|
4
|
+
from multiprocessing import Process
|
3
5
|
from pathlib import Path
|
4
6
|
|
5
|
-
from .server_fastapi_cli import
|
7
|
+
from fastled.server_fastapi_cli import run_fastapi_server_process
|
8
|
+
from fastled.server_flask import run_flask_server_process
|
9
|
+
|
10
|
+
|
11
|
+
def run_server_process(
|
12
|
+
port: int, cwd: Path, certfile: Path | None = None, keyfile: Path | None = None
|
13
|
+
) -> Process:
|
14
|
+
"""Run the server in a separate process."""
|
15
|
+
if True:
|
16
|
+
# Use Flask server
|
17
|
+
process = run_flask_server_process(
|
18
|
+
port=port,
|
19
|
+
cwd=cwd,
|
20
|
+
certfile=certfile,
|
21
|
+
keyfile=keyfile,
|
22
|
+
)
|
23
|
+
else:
|
24
|
+
# Use FastAPI server
|
25
|
+
process = run_fastapi_server_process(
|
26
|
+
port=port,
|
27
|
+
cwd=cwd,
|
28
|
+
certfile=certfile,
|
29
|
+
keyfile=keyfile,
|
30
|
+
)
|
31
|
+
return process
|
6
32
|
|
7
33
|
|
8
34
|
def get_asset_path(filename: str) -> Path | None:
|
@@ -16,31 +42,12 @@ def get_asset_path(filename: str) -> Path | None:
|
|
16
42
|
return None
|
17
43
|
|
18
44
|
|
19
|
-
def
|
20
|
-
# import webview
|
21
|
-
|
22
|
-
# print("\n##################################################")
|
23
|
-
# print(f"# Opening browser to {url}")
|
24
|
-
# print("##################################################\n")
|
25
|
-
|
26
|
-
# webview.create_window("FastLED", url)
|
27
|
-
# webview.start()
|
28
|
-
import webbrowser
|
29
|
-
|
30
|
-
webbrowser.open(url, new=1, autoraise=True)
|
31
|
-
while True:
|
32
|
-
import time
|
33
|
-
|
34
|
-
time.sleep(1)
|
35
|
-
|
36
|
-
|
37
|
-
def run(
|
45
|
+
def start_process(
|
38
46
|
path: Path,
|
39
47
|
port: int,
|
40
|
-
open_browser: bool,
|
41
48
|
certfile: Path | None = None,
|
42
49
|
keyfile: Path | None = None,
|
43
|
-
) ->
|
50
|
+
) -> Process:
|
44
51
|
"""Run the server, using package assets if explicit paths are not provided"""
|
45
52
|
# Use package resources if no explicit path
|
46
53
|
if certfile is None:
|
@@ -49,19 +56,26 @@ def run(
|
|
49
56
|
keyfile = get_asset_path("localhost-key.pem")
|
50
57
|
|
51
58
|
# _run_flask_server(path, port, certfile, keyfile)
|
52
|
-
#
|
53
|
-
proc =
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
except KeyboardInterrupt:
|
59
|
-
import _thread
|
59
|
+
# run_fastapi_server_process(port=port, path=path, certfile=certfile, keyfile=keyfile)
|
60
|
+
proc = run_server_process(port=port, cwd=path)
|
61
|
+
# try:
|
62
|
+
# proc.join()
|
63
|
+
# except KeyboardInterrupt:
|
64
|
+
# import _thread
|
60
65
|
|
61
|
-
|
66
|
+
# _thread.interrupt_main()
|
67
|
+
return proc
|
68
|
+
|
69
|
+
|
70
|
+
@dataclass
|
71
|
+
class Args:
|
72
|
+
fastled_js: Path
|
73
|
+
port: int
|
74
|
+
cert: Path | None
|
75
|
+
key: Path | None
|
62
76
|
|
63
77
|
|
64
|
-
def parse_args() ->
|
78
|
+
def parse_args() -> Args:
|
65
79
|
parser = argparse.ArgumentParser(
|
66
80
|
description="Open a browser to the fastled_js directory"
|
67
81
|
)
|
@@ -81,27 +95,37 @@ def parse_args() -> argparse.Namespace:
|
|
81
95
|
parser.add_argument(
|
82
96
|
"--key", type=Path, help="(Optional) Path to SSL private key (PEM format)"
|
83
97
|
)
|
84
|
-
parser.
|
85
|
-
|
86
|
-
|
98
|
+
args = parser.parse_args()
|
99
|
+
out: Args = Args(
|
100
|
+
fastled_js=args.fastled_js,
|
101
|
+
port=args.port,
|
102
|
+
cert=args.cert,
|
103
|
+
key=args.key,
|
87
104
|
)
|
88
|
-
|
105
|
+
if args.fastled_js is None:
|
106
|
+
raise ValueError("fastled_js directory is required")
|
107
|
+
return out
|
89
108
|
|
90
109
|
|
91
110
|
def main() -> None:
|
92
|
-
args = parse_args()
|
93
|
-
open_browser: bool = args.open_browser
|
111
|
+
args: Args = parse_args()
|
94
112
|
fastled_js: Path = args.fastled_js
|
95
113
|
port: int = args.port
|
96
114
|
cert: Path | None = args.cert
|
97
115
|
key: Path | None = args.key
|
98
|
-
|
116
|
+
proc = start_process(
|
99
117
|
path=fastled_js,
|
100
118
|
port=port,
|
101
|
-
open_browser=open_browser,
|
102
119
|
certfile=cert,
|
103
120
|
keyfile=key,
|
104
121
|
)
|
122
|
+
try:
|
123
|
+
proc.join()
|
124
|
+
except KeyboardInterrupt:
|
125
|
+
import _thread
|
126
|
+
|
127
|
+
_thread.interrupt_main()
|
128
|
+
pass
|
105
129
|
|
106
130
|
|
107
131
|
if __name__ == "__main__":
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.4
|
2
2
|
Name: fastled
|
3
|
-
Version: 1.2.
|
3
|
+
Version: 1.2.63
|
4
4
|
Summary: FastLED Wasm Compiler
|
5
5
|
Home-page: https://github.com/zackees/fastled-wasm
|
6
6
|
Maintainer: Zachary Vorhies
|
@@ -23,6 +23,8 @@ Requires-Dist: fastapi>=0.115.12
|
|
23
23
|
Requires-Dist: uvicorn>=0.34.2
|
24
24
|
Requires-Dist: pywebview>=5.4
|
25
25
|
Requires-Dist: watchfiles>=1.0.5
|
26
|
+
Requires-Dist: Flask>=3.0.0
|
27
|
+
Requires-Dist: livereload
|
26
28
|
Dynamic: home-page
|
27
29
|
Dynamic: license-file
|
28
30
|
Dynamic: maintainer
|
@@ -58,6 +58,7 @@ compiler/wasm_compiler_flags.py
|
|
58
58
|
compiler/extra/100dots.html
|
59
59
|
compiler/extra/demo_threejs.html
|
60
60
|
compiler/extra/micdemo.html
|
61
|
+
compiler/extra/mp3upload.html
|
61
62
|
compiler/extra/webgl_postprocessing_unreal_bloom.html
|
62
63
|
compiler/libcompile/CMakeLists.txt
|
63
64
|
src/fastled/__init__.py
|
@@ -74,13 +75,14 @@ src/fastled/keyboard.py
|
|
74
75
|
src/fastled/keyz.py
|
75
76
|
src/fastled/live_client.py
|
76
77
|
src/fastled/open_browser.py
|
77
|
-
src/fastled/open_browser2.py
|
78
78
|
src/fastled/parse_args.py
|
79
79
|
src/fastled/paths.py
|
80
80
|
src/fastled/project_init.py
|
81
81
|
src/fastled/select_sketch_directory.py
|
82
82
|
src/fastled/server_fastapi.py
|
83
83
|
src/fastled/server_fastapi_cli.py
|
84
|
+
src/fastled/server_flask.py
|
85
|
+
src/fastled/server_start.py
|
84
86
|
src/fastled/settings.py
|
85
87
|
src/fastled/sketch.py
|
86
88
|
src/fastled/spinner.py
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|