@devaloop/devalang 0.0.1-alpha.14 → 0.0.1-alpha.15

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 (90) hide show
  1. package/.devalang +8 -8
  2. package/Cargo.toml +2 -2
  3. package/README.md +31 -14
  4. package/docs/CHANGELOG.md +59 -0
  5. package/docs/ROADMAP.md +1 -1
  6. package/examples/automation.deva +44 -0
  7. package/examples/index.deva +41 -25
  8. package/examples/plugin.deva +15 -0
  9. package/out-tsc/bin/devalang.exe +0 -0
  10. package/package.json +1 -1
  11. package/project-version.json +3 -3
  12. package/rust/cli/bank.rs +14 -15
  13. package/rust/cli/check.rs +1 -1
  14. package/rust/cli/play.rs +1 -1
  15. package/rust/cli/update.rs +1 -1
  16. package/rust/common/api.rs +3 -6
  17. package/rust/common/cdn.rs +3 -6
  18. package/rust/common/sso.rs +3 -6
  19. package/rust/core/audio/engine.rs +215 -74
  20. package/rust/core/audio/evaluator.rs +101 -0
  21. package/rust/core/audio/interpreter/arrow_call.rs +27 -1
  22. package/rust/core/audio/interpreter/automate.rs +18 -0
  23. package/rust/core/audio/interpreter/call.rs +2 -2
  24. package/rust/core/audio/interpreter/condition.rs +3 -3
  25. package/rust/core/audio/interpreter/driver.rs +49 -16
  26. package/rust/core/audio/interpreter/let_.rs +14 -7
  27. package/rust/core/audio/interpreter/loop_.rs +39 -6
  28. package/rust/core/audio/interpreter/mod.rs +2 -1
  29. package/rust/core/audio/interpreter/sleep.rs +2 -4
  30. package/rust/core/audio/interpreter/spawn.rs +2 -2
  31. package/rust/core/audio/loader/trigger.rs +2 -5
  32. package/rust/core/audio/mod.rs +2 -1
  33. package/rust/core/audio/renderer.rs +1 -1
  34. package/rust/core/audio/special/easing.rs +120 -0
  35. package/rust/core/audio/special/env.rs +41 -0
  36. package/rust/core/audio/special/math.rs +92 -0
  37. package/rust/core/audio/special/mod.rs +9 -0
  38. package/rust/core/audio/special/modulator.rs +120 -0
  39. package/rust/core/debugger/store.rs +1 -1
  40. package/rust/core/error/mod.rs +4 -1
  41. package/rust/core/lexer/handler/arrow.rs +60 -9
  42. package/rust/core/lexer/handler/at.rs +4 -4
  43. package/rust/core/lexer/handler/brace.rs +8 -8
  44. package/rust/core/lexer/handler/colon.rs +4 -4
  45. package/rust/core/lexer/handler/comment.rs +2 -2
  46. package/rust/core/lexer/handler/dot.rs +4 -4
  47. package/rust/core/lexer/handler/driver.rs +42 -13
  48. package/rust/core/lexer/handler/identifier.rs +5 -4
  49. package/rust/core/lexer/handler/newline.rs +1 -1
  50. package/rust/core/lexer/handler/number.rs +3 -3
  51. package/rust/core/lexer/handler/operator.rs +3 -1
  52. package/rust/core/lexer/handler/parenthesis.rs +8 -8
  53. package/rust/core/lexer/handler/slash.rs +5 -5
  54. package/rust/core/lexer/handler/string.rs +1 -1
  55. package/rust/core/lexer/mod.rs +1 -1
  56. package/rust/core/lexer/token.rs +3 -0
  57. package/rust/core/parser/driver.rs +94 -12
  58. package/rust/core/parser/handler/arrow_call.rs +105 -89
  59. package/rust/core/parser/handler/at.rs +1 -1
  60. package/rust/core/parser/handler/dot.rs +3 -3
  61. package/rust/core/parser/handler/identifier/automate.rs +194 -0
  62. package/rust/core/parser/handler/identifier/function.rs +2 -3
  63. package/rust/core/parser/handler/identifier/let_.rs +16 -0
  64. package/rust/core/parser/handler/identifier/mod.rs +14 -10
  65. package/rust/core/parser/handler/identifier/print.rs +29 -0
  66. package/rust/core/parser/handler/identifier/sleep.rs +1 -1
  67. package/rust/core/parser/handler/identifier/synth.rs +7 -9
  68. package/rust/core/parser/handler/loop_.rs +60 -43
  69. package/rust/core/parser/statement.rs +5 -0
  70. package/rust/core/preprocessor/loader.rs +1 -1
  71. package/rust/core/preprocessor/processor.rs +4 -4
  72. package/rust/core/preprocessor/resolver/bank.rs +1 -2
  73. package/rust/core/preprocessor/resolver/call.rs +19 -18
  74. package/rust/core/preprocessor/resolver/driver.rs +7 -5
  75. package/rust/core/preprocessor/resolver/function.rs +3 -13
  76. package/rust/core/preprocessor/resolver/loop_.rs +31 -1
  77. package/rust/core/preprocessor/resolver/spawn.rs +3 -22
  78. package/rust/core/preprocessor/resolver/tempo.rs +1 -1
  79. package/rust/core/preprocessor/resolver/trigger.rs +2 -3
  80. package/rust/core/preprocessor/resolver/value.rs +6 -12
  81. package/rust/core/shared/bank.rs +1 -1
  82. package/rust/core/utils/path.rs +1 -1
  83. package/rust/core/utils/validation.rs +0 -1
  84. package/rust/installer/bank.rs +1 -1
  85. package/rust/installer/plugin.rs +2 -2
  86. package/rust/main.rs +0 -1
  87. package/rust/utils/error.rs +51 -0
  88. package/rust/utils/logger.rs +4 -0
  89. package/rust/utils/mod.rs +1 -44
  90. package/rust/utils/spinner.rs +1 -1
@@ -34,7 +34,7 @@ pub async fn install_plugin(name: &str, target_dir: &Path) -> Result<(), String>
34
34
  .ok_or_else(|| "Failed to determine root directory".to_string())?;
35
35
 
36
36
  let config_path = root_dir.join(".devalang");
37
- if (!config_path.exists()) {
37
+ if !config_path.exists() {
38
38
  return Err(
39
39
  format!(
40
40
  "Config file not found at '{}'. Please run 'devalang init' before adding an addon",
@@ -49,7 +49,7 @@ pub async fn install_plugin(name: &str, target_dir: &Path) -> Result<(), String>
49
49
 
50
50
  let dependency_path = &format!("devalang://plugin/{}", name);
51
51
 
52
- add_plugin_to_config(&mut config, &extract_path, &dependency_path);
52
+ add_plugin_to_config(&mut config, &extract_path, dependency_path);
53
53
 
54
54
  Ok(())
55
55
  }
package/rust/main.rs CHANGED
@@ -138,7 +138,6 @@ async fn main() -> io::Result<()> {
138
138
  eprintln!("❌ Logout command is not implemented yet.");
139
139
  }
140
140
 
141
- _ => {}
142
141
  }
143
142
 
144
143
  Ok(())
@@ -0,0 +1,51 @@
1
+ use crate::core::{
2
+ error::ErrorResult,
3
+ parser::statement::{Statement, StatementKind},
4
+ shared::value::Value,
5
+ };
6
+
7
+ /// Recursively collects errors from a list of statements.
8
+ ///
9
+ /// This function traverses the provided statements and aggregates any
10
+ /// `Unknown` or explicit `Error` statements into a flat vector.
11
+ /// It also descends into loop bodies to ensure nested errors are
12
+ /// surfaced.
13
+ pub fn collect_errors_recursively(statements: &[Statement]) -> Vec<ErrorResult> {
14
+ let mut errors: Vec<ErrorResult> = Vec::new();
15
+
16
+ for stmt in statements {
17
+ match &stmt.kind {
18
+ StatementKind::Unknown => {
19
+ errors.push(ErrorResult {
20
+ message: format!("Unknown statement at line {}:{}", stmt.line, stmt.column),
21
+ line: stmt.line,
22
+ column: stmt.column,
23
+ });
24
+ }
25
+ StatementKind::Error { message } => {
26
+ errors.push(ErrorResult {
27
+ message: message.clone(),
28
+ line: stmt.line,
29
+ column: stmt.column,
30
+ });
31
+ }
32
+ StatementKind::Loop => {
33
+ if let Some(body_statements) = extract_loop_body_statements(&stmt.value) {
34
+ errors.extend(collect_errors_recursively(body_statements));
35
+ }
36
+ }
37
+ _ => {}
38
+ }
39
+ }
40
+
41
+ errors
42
+ }
43
+
44
+ fn extract_loop_body_statements(value: &Value) -> Option<&[Statement]> {
45
+ if let Value::Map(map) = value {
46
+ if let Some(Value::Block(statements)) = map.get("body") {
47
+ return Some(statements);
48
+ }
49
+ }
50
+ None
51
+ }
@@ -7,6 +7,7 @@ pub enum LogLevel {
7
7
  Success,
8
8
  Error,
9
9
  Info,
10
+ Print,
10
11
  Warning,
11
12
  Watcher,
12
13
  Debug,
@@ -102,6 +103,7 @@ impl Logger {
102
103
  LogLevel::Warning => Color::Rgb { r: 255, g: 152, b: 0 },
103
104
  LogLevel::Watcher => Color::Rgb { r: 156, g: 39, b: 176 },
104
105
  LogLevel::Debug => Color::Rgb { r: 103, g: 58, b: 183 },
106
+ LogLevel::Print => Color::Rgb { r: 255, g: 255, b: 255 },
105
107
  };
106
108
 
107
109
  let status = match level {
@@ -111,6 +113,7 @@ impl Logger {
111
113
  LogLevel::Warning => "WARNING",
112
114
  LogLevel::Watcher => "WATCHER",
113
115
  LogLevel::Debug => "DEBUG",
116
+ LogLevel::Print => "PRINT",
114
117
  };
115
118
 
116
119
  s.push('[');
@@ -133,6 +136,7 @@ impl Logger {
133
136
  LogLevel::Warning => "[WARNING]",
134
137
  LogLevel::Watcher => "[WATCHER]",
135
138
  LogLevel::Debug => "[DEBUG]",
139
+ LogLevel::Print => "[PRINT]",
136
140
  }
137
141
  .to_string()
138
142
  }
package/rust/utils/mod.rs CHANGED
@@ -4,47 +4,4 @@ pub mod spinner;
4
4
  pub mod watcher;
5
5
  pub mod file;
6
6
  pub mod logger;
7
-
8
- use crate::core::parser::statement::{Statement, StatementKind};
9
- use crate::core::error::ErrorResult;
10
- use crate::core::shared::value::Value;
11
-
12
- pub fn collect_errors_recursively(statements: &[Statement]) -> Vec<ErrorResult> {
13
- let mut errors: Vec<ErrorResult> = Vec::new();
14
-
15
- for stmt in statements {
16
- match &stmt.kind {
17
- StatementKind::Unknown => {
18
- errors.push(ErrorResult {
19
- message: format!("Unknown statement at line {}:{}", stmt.line, stmt.column),
20
- line: stmt.line,
21
- column: stmt.column,
22
- });
23
- }
24
- StatementKind::Error { message } => {
25
- errors.push(ErrorResult {
26
- message: message.clone(),
27
- line: stmt.line,
28
- column: stmt.column,
29
- });
30
- }
31
- StatementKind::Loop => {
32
- if let Some(body_statements) = extract_loop_body_statements(&stmt.value) {
33
- errors.extend(collect_errors_recursively(body_statements));
34
- }
35
- }
36
- _ => {}
37
- }
38
- }
39
-
40
- errors
41
- }
42
-
43
- pub fn extract_loop_body_statements(value: &Value) -> Option<&[Statement]> {
44
- if let Value::Map(map) = value {
45
- if let Some(Value::Block(statements)) = map.get("body") {
46
- return Some(statements);
47
- }
48
- }
49
- None
50
- }
7
+ pub mod error;
@@ -13,7 +13,7 @@ pub fn with_spinner<T, F>(start_msg: &str, f: F) -> ProgressBar where F: FnOnce(
13
13
  spinner.set_message(start_msg.to_string());
14
14
  spinner.enable_steady_tick(Duration::from_millis(80));
15
15
 
16
- let result = f();
16
+ let _ = f();
17
17
 
18
18
  spinner
19
19
  }