fastled 1.1.35__tar.gz → 1.1.37__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.
Files changed (110) hide show
  1. {fastled-1.1.35 → fastled-1.1.37}/PKG-INFO +3 -1
  2. {fastled-1.1.35 → fastled-1.1.37}/README.md +2 -0
  3. {fastled-1.1.35 → fastled-1.1.37}/examples/Chromancer/Chromancer.ino +5 -5
  4. {fastled-1.1.35 → fastled-1.1.37}/examples/Video/Gfx2Video/Gfx2Video.ino +90 -90
  5. fastled-1.1.37/src/fastled/__init__.py +94 -0
  6. {fastled-1.1.35 → fastled-1.1.37}/src/fastled/app.py +6 -3
  7. {fastled-1.1.35 → fastled-1.1.37}/src/fastled/client_server.py +3 -3
  8. fastled-1.1.37/src/fastled/compile_server.py +82 -0
  9. fastled-1.1.35/src/fastled/compile_server.py → fastled-1.1.37/src/fastled/compile_server_impl.py +68 -17
  10. {fastled-1.1.35 → fastled-1.1.37}/src/fastled/docker_manager.py +1 -1
  11. {fastled-1.1.35 → fastled-1.1.37}/src/fastled/parse_args.py +1 -1
  12. {fastled-1.1.35 → fastled-1.1.37}/src/fastled/project_init.py +11 -6
  13. fastled-1.1.35/src/fastled/env.py → fastled-1.1.37/src/fastled/settings.py +1 -0
  14. fastled-1.1.37/src/fastled/test/examples.py +31 -0
  15. fastled-1.1.37/src/fastled/types.py +25 -0
  16. {fastled-1.1.35 → fastled-1.1.37}/src/fastled/web_compile.py +5 -13
  17. {fastled-1.1.35 → fastled-1.1.37}/src/fastled.egg-info/PKG-INFO +3 -1
  18. {fastled-1.1.35 → fastled-1.1.37}/src/fastled.egg-info/SOURCES.txt +5 -1
  19. {fastled-1.1.35 → fastled-1.1.37}/src/fastled.egg-info/top_level.txt +0 -1
  20. fastled-1.1.37/tests/test_api.py +24 -0
  21. {fastled-1.1.35 → fastled-1.1.37}/tests/test_compile_server.py +3 -7
  22. {fastled-1.1.35 → fastled-1.1.37}/tests/test_embedded_data.py +3 -5
  23. fastled-1.1.37/tests/test_examples.py +63 -0
  24. {fastled-1.1.35 → fastled-1.1.37}/tests/test_server_and_client_seperatly.py +1 -3
  25. fastled-1.1.35/src/fastled/__init__.py +0 -3
  26. fastled-1.1.35/src/fastled/types.py +0 -10
  27. {fastled-1.1.35 → fastled-1.1.37}/.aiderignore +0 -0
  28. {fastled-1.1.35 → fastled-1.1.37}/.github/workflows/build_multi_docker_image.yml +0 -0
  29. {fastled-1.1.35 → fastled-1.1.37}/.github/workflows/lint.yml +0 -0
  30. {fastled-1.1.35 → fastled-1.1.37}/.github/workflows/test_macos.yml +0 -0
  31. {fastled-1.1.35 → fastled-1.1.37}/.github/workflows/test_ubuntu.yml +0 -0
  32. {fastled-1.1.35 → fastled-1.1.37}/.github/workflows/test_win.yml +0 -0
  33. {fastled-1.1.35 → fastled-1.1.37}/.gitignore +0 -0
  34. {fastled-1.1.35 → fastled-1.1.37}/.pylintrc +0 -0
  35. {fastled-1.1.35 → fastled-1.1.37}/.vscode/launch.json +0 -0
  36. {fastled-1.1.35 → fastled-1.1.37}/.vscode/settings.json +0 -0
  37. {fastled-1.1.35 → fastled-1.1.37}/.vscode/tasks.json +0 -0
  38. {fastled-1.1.35 → fastled-1.1.37}/LICENSE +0 -0
  39. {fastled-1.1.35 → fastled-1.1.37}/MANIFEST.in +0 -0
  40. {fastled-1.1.35 → fastled-1.1.37}/clean +0 -0
  41. {fastled-1.1.35 → fastled-1.1.37}/docs/fastled.js +0 -0
  42. {fastled-1.1.35 → fastled-1.1.37}/docs/fastled.wasm +0 -0
  43. {fastled-1.1.35 → fastled-1.1.37}/docs/index.css +0 -0
  44. {fastled-1.1.35 → fastled-1.1.37}/docs/index.html +0 -0
  45. {fastled-1.1.35 → fastled-1.1.37}/docs/index.js +0 -0
  46. {fastled-1.1.35 → fastled-1.1.37}/examples/Blink/Blink.ino +0 -0
  47. {fastled-1.1.35 → fastled-1.1.37}/examples/Chromancer/detail.h +0 -0
  48. {fastled-1.1.35 → fastled-1.1.37}/examples/Chromancer/gary_woos_wled_port/gary_woos_wled_ledmap.h +0 -0
  49. {fastled-1.1.35 → fastled-1.1.37}/examples/Chromancer/gary_woos_wled_port/presets.json +0 -0
  50. {fastled-1.1.35 → fastled-1.1.37}/examples/Chromancer/gary_woos_wled_port/presets.min.json +0 -0
  51. {fastled-1.1.35 → fastled-1.1.37}/examples/Chromancer/gen.py +0 -0
  52. {fastled-1.1.35 → fastled-1.1.37}/examples/Chromancer/mapping.h +0 -0
  53. {fastled-1.1.35 → fastled-1.1.37}/examples/Chromancer/net.h +0 -0
  54. {fastled-1.1.35 → fastled-1.1.37}/examples/Chromancer/output.json +0 -0
  55. {fastled-1.1.35 → fastled-1.1.37}/examples/Chromancer/ripple.h +0 -0
  56. {fastled-1.1.35 → fastled-1.1.37}/examples/Chromancer/screenmap.json.h +0 -0
  57. {fastled-1.1.35 → fastled-1.1.37}/examples/ColorPalette/ColorPalette.ino +0 -0
  58. {fastled-1.1.35 → fastled-1.1.37}/examples/ColorTemperature/ColorTemperature.ino +0 -0
  59. {fastled-1.1.35 → fastled-1.1.37}/examples/Cylon/Cylon.ino +0 -0
  60. {fastled-1.1.35 → fastled-1.1.37}/examples/DemoReel100/DemoReel100.ino +0 -0
  61. {fastled-1.1.35 → fastled-1.1.37}/examples/Esp32Rmt51/Esp32Rmt51.ino +0 -0
  62. {fastled-1.1.35 → fastled-1.1.37}/examples/EspI2SDemo/EspI2SDemo.ino +0 -0
  63. {fastled-1.1.35 → fastled-1.1.37}/examples/Fire2012/Fire2012.ino +0 -0
  64. {fastled-1.1.35 → fastled-1.1.37}/examples/Fire2012WithPalette/Fire2012WithPalette.ino +0 -0
  65. {fastled-1.1.35 → fastled-1.1.37}/examples/FirstLight/FirstLight.ino +0 -0
  66. {fastled-1.1.35 → fastled-1.1.37}/examples/FxEngine/FxEngine.ino +0 -0
  67. {fastled-1.1.35 → fastled-1.1.37}/examples/Noise/Noise.ino +0 -0
  68. {fastled-1.1.35 → fastled-1.1.37}/examples/NoisePlayground/NoisePlayground.ino +0 -0
  69. {fastled-1.1.35 → fastled-1.1.37}/examples/NoisePlusPalette/NoisePlusPalette.ino +0 -0
  70. {fastled-1.1.35 → fastled-1.1.37}/examples/OctoWS2811/OctoWS2811.ino +0 -0
  71. {fastled-1.1.35 → fastled-1.1.37}/examples/Pacifica/Pacifica.ino +0 -0
  72. {fastled-1.1.35 → fastled-1.1.37}/examples/Pride2015/Pride2015.ino +0 -0
  73. {fastled-1.1.35 → fastled-1.1.37}/examples/TwinkleFox/TwinkleFox.ino +0 -0
  74. {fastled-1.1.35 → fastled-1.1.37}/examples/WasmScreenCoords/WasmScreenCoords.ino +0 -0
  75. {fastled-1.1.35 → fastled-1.1.37}/examples/Water/Water.ino +0 -0
  76. {fastled-1.1.35 → fastled-1.1.37}/examples/XYMatrix/XYMatrix.ino +0 -0
  77. {fastled-1.1.35 → fastled-1.1.37}/examples/wasm/wasm.ino +0 -0
  78. {fastled-1.1.35 → fastled-1.1.37}/install +0 -0
  79. {fastled-1.1.35 → fastled-1.1.37}/lint +0 -0
  80. {fastled-1.1.35 → fastled-1.1.37}/pyproject.toml +0 -0
  81. {fastled-1.1.35 → fastled-1.1.37}/requirements.testing.txt +0 -0
  82. {fastled-1.1.35 → fastled-1.1.37}/setup.cfg +0 -0
  83. {fastled-1.1.35 → fastled-1.1.37}/setup.py +0 -0
  84. {fastled-1.1.35 → fastled-1.1.37}/src/fastled/assets/example.txt +0 -0
  85. {fastled-1.1.35 → fastled-1.1.37}/src/fastled/build_mode.py +0 -0
  86. {fastled-1.1.35 → fastled-1.1.37}/src/fastled/cli.py +0 -0
  87. {fastled-1.1.35 → fastled-1.1.37}/src/fastled/filewatcher.py +0 -0
  88. {fastled-1.1.35 → fastled-1.1.37}/src/fastled/keyboard.py +0 -0
  89. {fastled-1.1.35 → fastled-1.1.37}/src/fastled/open_browser.py +0 -0
  90. {fastled-1.1.35 → fastled-1.1.37}/src/fastled/paths.py +0 -0
  91. {fastled-1.1.35 → fastled-1.1.37}/src/fastled/select_sketch_directory.py +0 -0
  92. {fastled-1.1.35 → fastled-1.1.37}/src/fastled/sketch.py +0 -0
  93. {fastled-1.1.35 → fastled-1.1.37}/src/fastled/spinner.py +0 -0
  94. {fastled-1.1.35 → fastled-1.1.37}/src/fastled/string_diff.py +0 -0
  95. {fastled-1.1.35 → fastled-1.1.37}/src/fastled/util.py +0 -0
  96. {fastled-1.1.35 → fastled-1.1.37}/src/fastled.egg-info/dependency_links.txt +0 -0
  97. {fastled-1.1.35 → fastled-1.1.37}/src/fastled.egg-info/entry_points.txt +0 -0
  98. {fastled-1.1.35 → fastled-1.1.37}/src/fastled.egg-info/requires.txt +0 -0
  99. {fastled-1.1.35 → fastled-1.1.37}/test +0 -0
  100. {fastled-1.1.35 → fastled-1.1.37}/tests/test_bad_ino.py +0 -0
  101. {fastled-1.1.35 → fastled-1.1.37}/tests/test_cli.py +0 -0
  102. {fastled-1.1.35 → fastled-1.1.37}/tests/test_docker_linux_on_windows.py +0 -0
  103. {fastled-1.1.35 → fastled-1.1.37}/tests/test_filechanger.py +0 -0
  104. {fastled-1.1.35 → fastled-1.1.37}/tests/test_ino/bad/bad.ino +0 -0
  105. {fastled-1.1.35 → fastled-1.1.37}/tests/test_ino/embedded/data/bigdata.dat +0 -0
  106. {fastled-1.1.35 → fastled-1.1.37}/tests/test_ino/embedded/wasm.ino +0 -0
  107. {fastled-1.1.35 → fastled-1.1.37}/tests/test_ino/wasm/wasm.ino +0 -0
  108. {fastled-1.1.35 → fastled-1.1.37}/tests/test_project_init.py +0 -0
  109. {fastled-1.1.35 → fastled-1.1.37}/tests/test_webcompile.py +0 -0
  110. {fastled-1.1.35 → fastled-1.1.37}/upload_package.sh +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: fastled
3
- Version: 1.1.35
3
+ Version: 1.1.37
4
4
  Summary: FastLED Wasm Compiler
5
5
  Home-page: https://github.com/zackees/fastled-wasm
6
6
  Maintainer: Zachary Vorhies
@@ -163,6 +163,8 @@ A: A big chunk of space is being used by unnecessary javascript `emscripten` is
163
163
 
164
164
  # Revisions
165
165
 
166
+ * 1.1.37 - `Test.test_examples()` is now unit tested to work correctly.
167
+ * 1.1.36 - We now have an api. `from fastled import Api` and `from fastled import Test` for testing.
166
168
  * 1.1.35 - When searching for files cap the limit at a high amount to prevent hang.
167
169
  * 1.1.34 - On windows check to make sure we are in linux container mode, if not try to switch and if that fails then use `--web` compiler.
168
170
  * 1.1.33 - Auto updating frequency has been reduced from one hour to one day. To update immediatly use `--update`.
@@ -140,6 +140,8 @@ A: A big chunk of space is being used by unnecessary javascript `emscripten` is
140
140
 
141
141
  # Revisions
142
142
 
143
+ * 1.1.37 - `Test.test_examples()` is now unit tested to work correctly.
144
+ * 1.1.36 - We now have an api. `from fastled import Api` and `from fastled import Test` for testing.
143
145
  * 1.1.35 - When searching for files cap the limit at a high amount to prevent hang.
144
146
  * 1.1.34 - On windows check to make sure we are in linux container mode, if not try to switch and if that fails then use `--web` compiler.
145
147
  * 1.1.33 - Auto updating frequency has been reduced from one hour to one day. To update immediatly use `--update`.
@@ -15,14 +15,14 @@
15
15
  #include "ripple.h"
16
16
  #include <FastLED.h>
17
17
  #include "detail.h"
18
- #include "screenmap.h"
19
- #include "math_macros.h"
20
- #include "json.h"
18
+ #include "fl/screenmap.h"
19
+ #include "fl/math_macros.h"
20
+ #include "fl/json.h"
21
21
  #include "fl/ui.h"
22
- #include "fixed_map.h"
22
+ #include "fl/map.h"
23
23
 
24
24
  #include "screenmap.json.h"
25
- #include "str.h"
25
+ #include "fl/str.h"
26
26
 
27
27
  enum {
28
28
  BlackStrip = 0,
@@ -1,90 +1,90 @@
1
- /// @file Frame2Video.ino
2
- /// @brief Demonstrates drawing to a frame buffer, which is used as source video for the memory player.
3
- /// The render pattern is alternating black/red pixels as a checkerboard.
4
- /// @example VideoTest.ino
5
-
6
-
7
- #ifndef COMPILE_VIDEO_STREAM
8
- #if defined(__AVR__)
9
- // This has grown too large for the AVR to handle.
10
- #define COMPILE_VIDEO_STREAM 0
11
- #else
12
- #define COMPILE_VIDEO_STREAM 1
13
- #endif
14
- #endif // COMPILE_VIDEO_STREAM
15
-
16
- #if COMPILE_VIDEO_STREAM
17
-
18
-
19
- #include <FastLED.h>
20
- #include "fx/storage/bytestreammemory.h"
21
- #include "fx/2d/video.hpp"
22
- #include "fx/fx_engine.h"
23
- #include "ref.h"
24
- #include "fx/video.h"
25
-
26
- #define LED_PIN 2
27
- #define BRIGHTNESS 96
28
- #define LED_TYPE WS2811
29
- #define COLOR_ORDER GRB
30
-
31
- #define MATRIX_WIDTH 22
32
- #define MATRIX_HEIGHT 22
33
- #define NUM_LEDS (MATRIX_WIDTH * MATRIX_HEIGHT)
34
-
35
- CRGB leds[NUM_LEDS];
36
-
37
- const int BYTES_PER_FRAME = 3 * NUM_LEDS;
38
- const int NUM_FRAMES = 2;
39
- const uint32_t BUFFER_SIZE = BYTES_PER_FRAME * NUM_FRAMES;
40
-
41
- ByteStreamMemoryRef memoryStream;
42
- FxEngine fxEngine(NUM_LEDS);
43
- // Create and initialize Video fx object
44
- XYMap xymap(MATRIX_WIDTH, MATRIX_HEIGHT);
45
-
46
- void write_one_frame(ByteStreamMemoryRef memoryStream) {
47
- //memoryStream->seek(0); // Reset to the beginning of the stream
48
- uint32_t total_bytes_written = 0;
49
- int toggle = (millis() / 500) % 2;
50
- for (uint32_t i = 0; i < NUM_LEDS; ++i) {
51
- CRGB color = (i % 2 == toggle) ? CRGB::Black : CRGB::Red;
52
- size_t bytes_written = memoryStream->write(color.raw, 3);
53
- if (bytes_written != 3) {
54
- }
55
- total_bytes_written += bytes_written;
56
- }
57
- }
58
-
59
- void setup() {
60
- delay(1000); // sanity delay
61
- FastLED.addLeds<LED_TYPE, LED_PIN, COLOR_ORDER>(leds, NUM_LEDS)
62
- .setCorrection(TypicalLEDStrip)
63
- .setScreenMap(xymap);
64
- FastLED.setBrightness(BRIGHTNESS);
65
-
66
- // Create and fill the ByteStreamMemory with test data
67
- memoryStream = ByteStreamMemoryRef::New(BUFFER_SIZE);
68
- write_one_frame(memoryStream); // Write initial frame data
69
- Video video(memoryStream, NUM_LEDS, 30.0f, 0);
70
- // Add the video effect to the FxEngine
71
- fxEngine.addVideo(video, xymap);
72
- }
73
-
74
- void loop() {
75
- // Reset the memory stream position before reading
76
- //memoryStream->seek(0);
77
- write_one_frame(memoryStream); // Write next frame data
78
-
79
- // Draw the frame
80
- fxEngine.draw(millis(), leds);
81
-
82
- // Show the LEDs
83
- FastLED.show();
84
-
85
- delay(100); // Adjust this delay to control frame rate
86
- }
87
- #else
88
- void setup() {}
89
- void loop() {}
90
- #endif // COMPILE_VIDEO_STREAM
1
+ /// @file Frame2Video.ino
2
+ /// @brief Demonstrates drawing to a frame buffer, which is used as source video for the memory player.
3
+ /// The render pattern is alternating black/red pixels as a checkerboard.
4
+ /// @example VideoTest.ino
5
+
6
+
7
+ #ifndef COMPILE_VIDEO_STREAM
8
+ #if defined(__AVR__)
9
+ // This has grown too large for the AVR to handle.
10
+ #define COMPILE_VIDEO_STREAM 0
11
+ #else
12
+ #define COMPILE_VIDEO_STREAM 1
13
+ #endif
14
+ #endif // COMPILE_VIDEO_STREAM
15
+
16
+ #if COMPILE_VIDEO_STREAM
17
+
18
+
19
+ #include <FastLED.h>
20
+ #include "fx/storage/bytestreammemory.h"
21
+ #include "fx/2d/video.hpp"
22
+ #include "fx/fx_engine.h"
23
+ #include "ref.h"
24
+ #include "fx/video.h"
25
+
26
+ #define LED_PIN 2
27
+ #define BRIGHTNESS 96
28
+ #define LED_TYPE WS2811
29
+ #define COLOR_ORDER GRB
30
+
31
+ #define MATRIX_WIDTH 22
32
+ #define MATRIX_HEIGHT 22
33
+ #define NUM_LEDS (MATRIX_WIDTH * MATRIX_HEIGHT)
34
+
35
+ CRGB leds[NUM_LEDS];
36
+
37
+ const int BYTES_PER_FRAME = 3 * NUM_LEDS;
38
+ const int NUM_FRAMES = 2;
39
+ const uint32_t BUFFER_SIZE = BYTES_PER_FRAME * NUM_FRAMES;
40
+
41
+ ByteStreamMemoryRef memoryStream;
42
+ FxEngine fxEngine(NUM_LEDS);
43
+ // Create and initialize Video fx object
44
+ XYMap xymap(MATRIX_WIDTH, MATRIX_HEIGHT);
45
+
46
+ void write_one_frame(ByteStreamMemoryRef memoryStream) {
47
+ //memoryStream->seek(0); // Reset to the beginning of the stream
48
+ uint32_t total_bytes_written = 0;
49
+ int toggle = (millis() / 500) % 2;
50
+ for (uint32_t i = 0; i < NUM_LEDS; ++i) {
51
+ CRGB color = (i % 2 == toggle) ? CRGB::Black : CRGB::Red;
52
+ size_t bytes_written = memoryStream->write(color.raw, 3);
53
+ if (bytes_written != 3) {
54
+ }
55
+ total_bytes_written += bytes_written;
56
+ }
57
+ }
58
+
59
+ void setup() {
60
+ delay(1000); // sanity delay
61
+ FastLED.addLeds<LED_TYPE, LED_PIN, COLOR_ORDER>(leds, NUM_LEDS)
62
+ .setCorrection(TypicalLEDStrip)
63
+ .setScreenMap(xymap);
64
+ FastLED.setBrightness(BRIGHTNESS);
65
+
66
+ // Create and fill the ByteStreamMemory with test data
67
+ memoryStream = ByteStreamMemoryRef::New(BUFFER_SIZE);
68
+ write_one_frame(memoryStream); // Write initial frame data
69
+ Video video(memoryStream, NUM_LEDS, 30.0f, 0);
70
+ // Add the video effect to the FxEngine
71
+ fxEngine.addVideo(video, xymap);
72
+ }
73
+
74
+ void loop() {
75
+ // Reset the memory stream position before reading
76
+ //memoryStream->seek(0);
77
+ write_one_frame(memoryStream); // Write next frame data
78
+
79
+ // Draw the frame
80
+ fxEngine.draw(millis(), leds);
81
+
82
+ // Show the LEDs
83
+ FastLED.show();
84
+
85
+ delay(100); // Adjust this delay to control frame rate
86
+ }
87
+ #else
88
+ void setup() {}
89
+ void loop() {}
90
+ #endif // COMPILE_VIDEO_STREAM
@@ -0,0 +1,94 @@
1
+ """FastLED Wasm Compiler package."""
2
+
3
+ # context
4
+ from contextlib import contextmanager
5
+ from pathlib import Path
6
+
7
+ from .compile_server import CompileServer
8
+ from .types import WebCompileResult
9
+
10
+ __version__ = "1.1.37"
11
+
12
+
13
+ class Api:
14
+ @staticmethod
15
+ def get_examples():
16
+ from fastled.project_init import get_examples
17
+
18
+ return get_examples()
19
+
20
+ @staticmethod
21
+ def project_init(
22
+ example=None, outputdir=None, host: str | CompileServer | None = None
23
+ ) -> Path:
24
+ from fastled.project_init import project_init
25
+
26
+ if isinstance(host, CompileServer):
27
+ host = host.url()
28
+ return project_init(example, outputdir, host)
29
+
30
+ @staticmethod
31
+ def web_compile(
32
+ directory: Path | str, host: str | CompileServer | None = None
33
+ ) -> WebCompileResult:
34
+ from fastled.web_compile import web_compile
35
+
36
+ if isinstance(host, CompileServer):
37
+ host = host.url()
38
+ if isinstance(directory, str):
39
+ directory = Path(directory)
40
+ out: WebCompileResult = web_compile(directory, host)
41
+ return out
42
+
43
+ @staticmethod
44
+ def spawn_server(
45
+ sketch_directory: Path | None = None,
46
+ interactive=False,
47
+ auto_updates=None,
48
+ auto_start=True,
49
+ container_name: str | None = None,
50
+ ):
51
+ from fastled.compile_server import CompileServer
52
+
53
+ out = CompileServer(
54
+ container_name=container_name,
55
+ interactive=interactive,
56
+ auto_updates=auto_updates,
57
+ mapped_dir=sketch_directory,
58
+ auto_start=auto_start,
59
+ )
60
+ return out
61
+
62
+ @staticmethod
63
+ @contextmanager
64
+ def server(
65
+ sketch_directory: Path | None = None,
66
+ interactive=False,
67
+ auto_updates=None,
68
+ auto_start=True,
69
+ container_name: str | None = None,
70
+ ):
71
+ server = Api.spawn_server(
72
+ sketch_directory=sketch_directory,
73
+ interactive=interactive,
74
+ auto_updates=auto_updates,
75
+ auto_start=auto_start,
76
+ container_name=container_name,
77
+ )
78
+ try:
79
+ yield server
80
+ finally:
81
+ server.stop()
82
+
83
+
84
+ class Test:
85
+ @staticmethod
86
+ def test_examples(
87
+ examples: list[str] | None = None, host: str | CompileServer | None = None
88
+ ) -> dict[str, Exception]:
89
+ from fastled.test.examples import test_examples
90
+
91
+ if isinstance(host, CompileServer):
92
+ host = host.url()
93
+
94
+ return test_examples(examples=examples, host=host)
@@ -17,14 +17,17 @@ def run_server(args: argparse.Namespace) -> int:
17
17
  auto_update = args.auto_update
18
18
  mapped_dir = Path(args.directory).absolute() if args.directory else None
19
19
  compile_server = CompileServer(
20
- interactive=interactive, auto_updates=auto_update, mapped_dir=mapped_dir
20
+ interactive=interactive,
21
+ auto_updates=auto_update,
22
+ mapped_dir=mapped_dir,
23
+ auto_start=True,
21
24
  )
25
+
22
26
  if not interactive:
23
27
  print(f"Server started at {compile_server.url()}")
24
- compile_server.wait_for_startup()
25
28
  try:
26
29
  while True:
27
- if not compile_server.proceess_running():
30
+ if not compile_server.process_running():
28
31
  print("Server process is not running. Exiting...")
29
32
  return 1
30
33
  time.sleep(0.1)
@@ -8,10 +8,10 @@ from pathlib import Path
8
8
  from fastled.build_mode import BuildMode, get_build_mode
9
9
  from fastled.compile_server import CompileServer
10
10
  from fastled.docker_manager import DockerManager
11
- from fastled.env import DEFAULT_URL
12
11
  from fastled.filewatcher import FileWatcherProcess
13
12
  from fastled.keyboard import SpaceBarWatcher
14
13
  from fastled.open_browser import open_browser_process
14
+ from fastled.settings import DEFAULT_URL
15
15
  from fastled.sketch import looks_like_sketch_directory
16
16
 
17
17
  # CompiledResult
@@ -112,7 +112,7 @@ def _try_start_server_or_get_url(args: argparse.Namespace) -> str | CompileServe
112
112
  print("No local server found, starting one...")
113
113
  compile_server = CompileServer(auto_updates=auto_update)
114
114
  print("Waiting for the local compiler to start...")
115
- if not compile_server.wait_for_startup():
115
+ if not compile_server.ping():
116
116
  print("Failed to start local compiler.")
117
117
  raise RuntimeError("Failed to start local compiler.")
118
118
  return compile_server
@@ -254,7 +254,7 @@ def run_client_server(args: argparse.Namespace) -> int:
254
254
  if changed:
255
255
  print_status()
256
256
  continue
257
- if compile_server and not compile_server.proceess_running():
257
+ if compile_server and not compile_server.process_running():
258
258
  print("Server process is not running. Exiting...")
259
259
  return 1
260
260
  if source_code_watcher is not None:
@@ -0,0 +1,82 @@
1
+ from pathlib import Path
2
+
3
+ from fastled.build_mode import BuildMode
4
+ from fastled.types import WebCompileResult
5
+
6
+
7
+ class CompileServer:
8
+ def __init__(
9
+ self,
10
+ interactive: bool = False,
11
+ auto_updates: bool | None = None,
12
+ mapped_dir: Path | None = None,
13
+ auto_start: bool = True,
14
+ container_name: str | None = None,
15
+ ) -> None:
16
+ from fastled.compile_server_impl import ( # avoid circular import
17
+ CompileServerImpl,
18
+ )
19
+
20
+ self.impl = CompileServerImpl(
21
+ container_name=container_name,
22
+ interactive=interactive,
23
+ auto_updates=auto_updates,
24
+ mapped_dir=mapped_dir,
25
+ auto_start=auto_start,
26
+ )
27
+
28
+ def start(self, wait_for_startup=True) -> None:
29
+ # from fastled.compile_server_impl import CompileServerImpl # avoid circular import
30
+ self.impl.start(wait_for_startup=wait_for_startup)
31
+
32
+ def web_compile(
33
+ self,
34
+ directory: Path | str,
35
+ build_mode: BuildMode = BuildMode.QUICK,
36
+ profile: bool = False,
37
+ ) -> WebCompileResult:
38
+ return self.impl.web_compile(
39
+ directory=directory, build_mode=build_mode, profile=profile
40
+ )
41
+
42
+ def project_init(
43
+ self, example: str | None = None, outputdir: Path | None = None
44
+ ) -> None:
45
+ from fastled.project_init import project_init # avoid circular import
46
+
47
+ project_init(example=example, outputdir=outputdir)
48
+
49
+ @property
50
+ def running(self) -> bool:
51
+ return self.impl.running
52
+
53
+ @property
54
+ def fastled_src_dir(self) -> Path | None:
55
+ return self.impl.fastled_src_dir
56
+
57
+ def using_fastled_src_dir_volume(self) -> bool:
58
+ return self.impl.using_fastled_src_dir_volume()
59
+
60
+ def port(self) -> int:
61
+ return self.impl.port()
62
+
63
+ def url(self) -> str:
64
+ return self.impl.url()
65
+
66
+ def ping(self) -> bool:
67
+ return self.impl.ping()
68
+
69
+ # by default this is automatically called by the constructor, unless
70
+ # auto_start is set to False.
71
+ def wait_for_startup(self, timeout: int = 100) -> bool:
72
+ """Wait for the server to start up."""
73
+ return self.impl.wait_for_startup(timeout=timeout)
74
+
75
+ def _start(self) -> int:
76
+ return self.impl._start()
77
+
78
+ def stop(self) -> None:
79
+ return self.impl.stop()
80
+
81
+ def process_running(self) -> bool:
82
+ return self.impl.process_running()
@@ -1,34 +1,39 @@
1
1
  import subprocess
2
2
  import time
3
+ import warnings
3
4
  from datetime import datetime, timezone
4
5
  from pathlib import Path
5
6
 
6
7
  import httpx
7
8
 
9
+ from fastled.build_mode import BuildMode
8
10
  from fastled.docker_manager import (
9
11
  DISK_CACHE,
10
12
  Container,
11
13
  DockerManager,
12
14
  RunningContainer,
13
15
  )
16
+ from fastled.settings import SERVER_PORT
14
17
  from fastled.sketch import looks_like_fastled_repo
18
+ from fastled.types import WebCompileResult
15
19
 
16
20
  _IMAGE_NAME = "niteris/fastled-wasm"
17
21
  _DEFAULT_CONTAINER_NAME = "fastled-wasm-compiler"
18
22
 
19
- SERVER_PORT = 9021
20
23
 
21
24
  SERVER_OPTIONS = ["--allow-shutdown", "--no-auto-update"]
22
25
 
23
26
 
24
- class CompileServer:
27
+ class CompileServerImpl:
25
28
  def __init__(
26
29
  self,
27
- container_name=_DEFAULT_CONTAINER_NAME,
28
30
  interactive: bool = False,
29
31
  auto_updates: bool | None = None,
30
32
  mapped_dir: Path | None = None,
33
+ auto_start: bool = True,
34
+ container_name: str | None = None,
31
35
  ) -> None:
36
+ container_name = container_name or _DEFAULT_CONTAINER_NAME
32
37
  if interactive and not mapped_dir:
33
38
  raise ValueError(
34
39
  "Interactive mode requires a mapped directory point to a sketch"
@@ -50,13 +55,47 @@ class CompileServer:
50
55
  self.interactive = interactive
51
56
  self.running_container: RunningContainer | None = None
52
57
  self.auto_updates = auto_updates
53
- self._port = self._start()
58
+ # self._port = self._start()
59
+ self._port = 0 # 0 until compile server is started
54
60
  # fancy print
55
61
  if not interactive:
56
62
  msg = f"# FastLED Compile Server started at {self.url()} #"
57
63
  print("\n" + "#" * len(msg))
58
64
  print(msg)
59
65
  print("#" * len(msg) + "\n")
66
+ if auto_start:
67
+ self.start()
68
+
69
+ def start(self, wait_for_startup=True) -> None:
70
+ if self._port != 0:
71
+ warnings.warn("Server has already been started")
72
+ self._port = self._start()
73
+ if wait_for_startup:
74
+ self.wait_for_startup()
75
+
76
+ def web_compile(
77
+ self,
78
+ directory: Path | str,
79
+ build_mode: BuildMode = BuildMode.QUICK,
80
+ profile: bool = False,
81
+ ) -> WebCompileResult:
82
+ from fastled.web_compile import web_compile # avoid circular import
83
+
84
+ if not self._port:
85
+ raise RuntimeError("Server has not been started yet")
86
+ if not self.ping():
87
+ raise RuntimeError("Server is not running")
88
+ out: WebCompileResult = web_compile(
89
+ directory, host=self.url(), build_mode=build_mode, profile=profile
90
+ )
91
+ return out
92
+
93
+ def project_init(
94
+ self, example: str | None = None, outputdir: Path | None = None
95
+ ) -> None:
96
+ from fastled.project_init import project_init # avoid circular import
97
+
98
+ project_init(example=example, outputdir=outputdir)
60
99
 
61
100
  @property
62
101
  def running(self) -> bool:
@@ -72,11 +111,30 @@ class CompileServer:
72
111
  return self.fastled_src_dir is not None
73
112
 
74
113
  def port(self) -> int:
114
+ if self._port == 0:
115
+ warnings.warn("Server has not been started yet")
75
116
  return self._port
76
117
 
77
118
  def url(self) -> str:
119
+ if self._port == 0:
120
+ warnings.warn("Server has not been started yet")
78
121
  return f"http://localhost:{self._port}"
79
122
 
123
+ def ping(self) -> bool:
124
+ try:
125
+ response = httpx.get(
126
+ f"http://localhost:{self._port}", follow_redirects=True
127
+ )
128
+ if response.status_code < 400:
129
+ return True
130
+ except KeyboardInterrupt:
131
+ raise
132
+ except Exception:
133
+ pass
134
+ return False
135
+
136
+ # by default this is automatically called by the constructor, unless
137
+ # auto_start is set to False.
80
138
  def wait_for_startup(self, timeout: int = 100) -> bool:
81
139
  """Wait for the server to start up."""
82
140
  start_time = time.time()
@@ -86,16 +144,8 @@ class CompileServer:
86
144
  return False
87
145
  # use httpx to ping the server
88
146
  # if successful, return True
89
- try:
90
- response = httpx.get(
91
- f"http://localhost:{self._port}", follow_redirects=True
92
- )
93
- if response.status_code < 400:
94
- return True
95
- except KeyboardInterrupt:
96
- raise
97
- except Exception:
98
- pass
147
+ if self.ping():
148
+ return True
99
149
  time.sleep(0.1)
100
150
  if not self.docker.is_container_running(self.container_name):
101
151
  return False
@@ -182,12 +232,13 @@ class CompileServer:
182
232
  print("Exiting interactive mode")
183
233
  return port
184
234
 
185
- def proceess_running(self) -> bool:
235
+ def process_running(self) -> bool:
186
236
  return self.docker.is_container_running(self.container_name)
187
237
 
188
238
  def stop(self) -> None:
189
- # print(f"Stopping server on port {self._port}")
190
239
  if self.running_container:
191
- self.running_container.stop()
240
+ self.running_container.detach()
241
+ self.running_container = None
192
242
  self.docker.suspend_container(self.container_name)
243
+ self._port = 0
193
244
  print("Compile server stopped")
@@ -89,7 +89,7 @@ class RunningContainer:
89
89
  print(f"Error monitoring logs: {e}")
90
90
  break
91
91
 
92
- def stop(self) -> None:
92
+ def detach(self) -> None:
93
93
  """Stop monitoring the container logs"""
94
94
  self.running = False
95
95
  self.thread.join()
@@ -5,9 +5,9 @@ from pathlib import Path
5
5
 
6
6
  from fastled import __version__
7
7
  from fastled.docker_manager import DockerManager
8
- from fastled.env import DEFAULT_URL
9
8
  from fastled.project_init import project_init
10
9
  from fastled.select_sketch_directory import select_sketch_directory
10
+ from fastled.settings import DEFAULT_URL
11
11
  from fastled.sketch import (
12
12
  find_sketch_directories,
13
13
  looks_like_fastled_repo,
@@ -3,7 +3,7 @@ from pathlib import Path
3
3
 
4
4
  import httpx
5
5
 
6
- from fastled.env import DEFAULT_URL
6
+ from fastled.settings import DEFAULT_URL
7
7
 
8
8
  ENDPOINT_PROJECT_INIT = f"{DEFAULT_URL}/project/init"
9
9
  ENDPOINT_INFO = f"{DEFAULT_URL}/info"
@@ -33,13 +33,17 @@ def _prompt_for_example() -> str:
33
33
  return answer
34
34
 
35
35
 
36
- def project_init(example: str | None = None, outputdir: Path | None = None) -> Path:
36
+ def project_init(
37
+ example: str | None = "PROMPT", # prompt for example
38
+ outputdir: Path | None = None,
39
+ host: str | None = None,
40
+ ) -> Path:
37
41
  """
38
42
  Initialize a new FastLED project.
39
43
  """
40
-
41
- outputdir = outputdir or Path("fastled")
42
- if example is None:
44
+ host = host or DEFAULT_URL
45
+ outputdir = Path(outputdir) if outputdir is not None else Path("fastled")
46
+ if example == "PROMPT" or example is None:
43
47
  try:
44
48
  example = _prompt_for_example()
45
49
  except httpx.HTTPStatusError:
@@ -48,7 +52,8 @@ def project_init(example: str | None = None, outputdir: Path | None = None) -> P
48
52
  )
49
53
  example = DEFAULT_EXAMPLE
50
54
  assert example is not None
51
- response = httpx.get(f"{ENDPOINT_PROJECT_INIT}/{example}", timeout=20)
55
+ endpoint_url = f"{host}/project/init/{example}"
56
+ response = httpx.get(endpoint_url, timeout=20)
52
57
  response.raise_for_status()
53
58
  content = response.content
54
59
  tmpzip = outputdir / "fastled.zip"
@@ -6,3 +6,4 @@ IS_ARM: bool = "arm" in MACHINE or "aarch64" in MACHINE
6
6
  PLATFORM_TAG: str = "-arm64" if IS_ARM else ""
7
7
  CONTAINER_NAME = f"fastled-wasm-compiler{PLATFORM_TAG}"
8
8
  DEFAULT_URL = str(os.environ.get("FASTLED_URL", "https://fastled.onrender.com"))
9
+ SERVER_PORT = 9021