Commit Graph

14 Commits

Author SHA1 Message Date
timurgordon
db5b9a0a42 archive old code 2025-06-03 21:47:59 +03:00
timurgordon
b20140785e add engine and rpc client, archive old code 2025-06-03 21:47:36 +03:00
timurgordon
061aee6f1d rhai rpc queue worker and client 2025-06-01 02:10:58 +03:00
timurgordon
ec4769a6b0 more efforts to automate rhai bindings 2025-05-13 02:00:35 +03:00
timurgordon
16ad4f5743 create macros for generating rhai wrappers and add tests 2025-05-12 02:31:45 +03:00
Timur Gordon
22032f329a feat(tera_factory): Implement hot reload example for Tera templates with Rhai
This commit adds a comprehensive hot reload example that demonstrates how to use the rhai_system for dynamic template rendering with Tera. Key improvements include:

- Refactor the example to use external script files instead of hardcoded Rhai code
- Implement proper module imports using the BasePathModuleResolver approach
- Fix template rendering by using keyword arguments in Tera function calls
- Add support for hot reloading both main and utility scripts
- Remove unnecessary output file generation to keep the example clean
- Fix compatibility issues with Rhai functions (avoiding to_string with parameters)

This example showcases how changes to Rhai scripts are automatically detected and applied to rendered templates without restarting the application, providing a smooth development experience.
2025-05-02 21:34:28 +02:00
Timur Gordon
c23de6871b remove old examples 2025-05-02 21:05:30 +02:00
Timur Gordon
372b7a2772 refactor: Overhaul Rhai scripting with multi-file hot reloading
This commit represents a major refactoring of our Rhai scripting system,
transforming it from a factory-based approach to a more robust system-based
architecture with improved hot reloading capabilities.

Key Changes:
- Renamed package from rhai_factory to rhai_system to better reflect its purpose
- Renamed system_factory.rs to factory.rs for consistency and clarity
- Implemented support for multiple script files in hot reloading
- Added cross-script function calls, allowing functions in one script to call functions in another
- Improved file watching to monitor all script files for changes
- Enhanced error handling for script compilation failures
- Simplified the API with a cleaner create_hot_reloadable_system function
- Removed unused modules (error.rs, factory.rs, hot_reload_old.rs, module_cache.rs, relative_resolver.rs)
- Updated all tests to work with the new architecture

The new architecture:
- Uses a System struct that holds references to script paths and provides a clean API
- Compiles and merges multiple Rhai script files into a single AST
- Automatically detects changes to any script file and recompiles them
- Maintains thread safety with proper synchronization primitives
- Provides better error messages when scripts fail to compile

This refactoring aligns with our BasePathModuleResolver approach for module imports,
making the resolution process more predictable and consistent. The hot reload example
has been updated to demonstrate the new capabilities, showing how to:
1. Load and execute multiple script files
2. Watch for changes to these files
3. Automatically reload scripts when they change
4. Call functions across different script files

All tests are passing, and the example demonstrates the improved functionality.
2025-05-02 21:04:33 +02:00
Timur Gordon
939b6b4e57 reorganize module 2025-04-04 08:28:07 +02:00
Timur Gordon
1ea37e2e7f rust rhai ui components wip 2025-04-03 19:03:38 +02:00
5764950949 ... 2025-04-03 10:50:58 +02:00
c8fcdfcbb2 ... 2025-04-03 10:40:47 +02:00
7e9ad524cc ... 2025-04-03 09:18:05 +02:00
f6935492fb Initial commit 2025-04-03 04:07:30 +00:00