@devaloop/devalang 0.0.1-alpha.16-hotfix.1 → 0.0.1-alpha.17

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 (235) hide show
  1. package/.cargo/config.toml +2 -0
  2. package/.devalang +6 -10
  3. package/.github/workflows/ci.yml +19 -8
  4. package/Cargo.toml +18 -2
  5. package/README.md +80 -33
  6. package/docs/CHANGELOG.md +56 -0
  7. package/docs/ROADMAP.md +6 -3
  8. package/examples/index.deva +52 -35
  9. package/out-tsc/bin/index.d.ts +2 -0
  10. package/out-tsc/core/functions/index.d.ts +37 -0
  11. package/out-tsc/core/functions/index.js +76 -0
  12. package/out-tsc/core/index.d.ts +6 -0
  13. package/out-tsc/core/index.js +22 -0
  14. package/out-tsc/core/types/index.d.ts +4 -0
  15. package/out-tsc/core/types/index.js +20 -0
  16. package/out-tsc/core/types/plugin.d.ts +18 -0
  17. package/out-tsc/core/types/plugin.js +2 -0
  18. package/out-tsc/core/types/result.d.ts +27 -0
  19. package/out-tsc/core/types/result.js +2 -0
  20. package/out-tsc/core/types/statement.d.ts +106 -0
  21. package/out-tsc/core/types/statement.js +2 -0
  22. package/out-tsc/core/types/value.d.ts +43 -0
  23. package/out-tsc/core/types/value.js +2 -0
  24. package/out-tsc/index.d.ts +7 -0
  25. package/out-tsc/index.js +41 -2
  26. package/out-tsc/pkg/devalang_core.d.ts +7 -0
  27. package/out-tsc/pkg/devalang_core_bg.wasm.d.ts +33 -0
  28. package/out-tsc/scripts/copy-wasm-dts.d.ts +1 -0
  29. package/out-tsc/scripts/copy-wasm-dts.js +73 -0
  30. package/out-tsc/scripts/postinstall.d.ts +1 -0
  31. package/out-tsc/scripts/postinstall.js +33 -23
  32. package/out-tsc/scripts/version/bump.d.ts +1 -0
  33. package/out-tsc/scripts/version/fetch.d.ts +1 -0
  34. package/out-tsc/scripts/version/index.d.ts +1 -0
  35. package/out-tsc/scripts/version/sync.d.ts +1 -0
  36. package/package.json +16 -4
  37. package/project-version.json +3 -3
  38. package/rust/cli/bank/api.rs +122 -0
  39. package/rust/cli/bank/commands.rs +275 -0
  40. package/rust/cli/bank/mod.rs +29 -0
  41. package/rust/cli/build/commands.rs +97 -0
  42. package/rust/cli/build/mod.rs +2 -0
  43. package/rust/cli/build/process.rs +146 -0
  44. package/rust/cli/{check.rs → check/mod.rs} +18 -31
  45. package/rust/cli/discover/commands.rs +253 -0
  46. package/rust/cli/discover/config.rs +111 -0
  47. package/rust/cli/discover/fs.rs +19 -0
  48. package/rust/cli/discover/install.rs +103 -0
  49. package/rust/cli/discover/metadata.rs +48 -0
  50. package/rust/cli/discover/mod.rs +5 -0
  51. package/rust/cli/{init.rs → init/commands.rs} +88 -87
  52. package/rust/cli/init/mod.rs +1 -0
  53. package/rust/{installer → cli/install}/addon.rs +5 -9
  54. package/rust/cli/install/bank.rs +53 -0
  55. package/rust/cli/{install.rs → install/commands.rs} +9 -9
  56. package/rust/{installer → cli/install}/mod.rs +2 -3
  57. package/rust/cli/install/plugin.rs +61 -0
  58. package/rust/cli/{login.rs → login/commands.rs} +8 -11
  59. package/rust/cli/login/mod.rs +1 -0
  60. package/rust/cli/mod.rs +2 -3
  61. package/rust/cli/{driver.rs → parser.rs} +19 -2
  62. package/rust/cli/play/commands.rs +324 -0
  63. package/rust/cli/play/io.rs +17 -0
  64. package/rust/cli/play/mod.rs +5 -0
  65. package/rust/cli/play/process.rs +150 -0
  66. package/rust/cli/play/realtime.rs +91 -0
  67. package/rust/cli/play/utils.rs +23 -0
  68. package/rust/cli/telemetry/commands.rs +22 -0
  69. package/rust/cli/telemetry/event_creator.rs +80 -0
  70. package/rust/cli/telemetry/mod.rs +3 -0
  71. package/rust/cli/telemetry/send.rs +51 -0
  72. package/rust/cli/{template.rs → template/commands.rs} +1 -1
  73. package/rust/cli/template/mod.rs +1 -0
  74. package/rust/cli/{update.rs → update/commands.rs} +6 -6
  75. package/rust/cli/update/mod.rs +1 -0
  76. package/rust/config/driver.rs +57 -72
  77. package/rust/config/mod.rs +1 -2
  78. package/rust/config/ops.rs +26 -0
  79. package/rust/config/settings.rs +60 -50
  80. package/rust/core/audio/engine/helpers.rs +146 -0
  81. package/rust/core/audio/engine/mod.rs +7 -0
  82. package/rust/core/audio/engine/sample.rs +298 -0
  83. package/rust/core/audio/engine/synth.rs +310 -0
  84. package/rust/core/audio/evaluator.rs +15 -12
  85. package/rust/core/audio/interpreter/arrow_call.rs +99 -24
  86. package/rust/core/audio/interpreter/call.rs +81 -60
  87. package/rust/core/audio/interpreter/condition.rs +3 -2
  88. package/rust/core/audio/interpreter/driver.rs +206 -151
  89. package/rust/core/audio/interpreter/let_.rs +1 -1
  90. package/rust/core/audio/interpreter/load.rs +2 -1
  91. package/rust/core/audio/interpreter/loop_.rs +7 -6
  92. package/rust/core/audio/interpreter/sleep.rs +2 -1
  93. package/rust/core/audio/interpreter/spawn.rs +45 -57
  94. package/rust/core/audio/interpreter/tempo.rs +31 -10
  95. package/rust/core/audio/interpreter/trigger.rs +2 -2
  96. package/rust/core/audio/loader/trigger.rs +4 -7
  97. package/rust/core/audio/player.rs +6 -0
  98. package/rust/core/audio/renderer.rs +5 -7
  99. package/rust/core/audio/special/env.rs +3 -1
  100. package/rust/core/audio/special/math.rs +4 -4
  101. package/rust/core/audio/special/modulator.rs +2 -2
  102. package/rust/core/builder/mod.rs +9 -3
  103. package/rust/core/debugger/lexer.rs +1 -1
  104. package/rust/core/debugger/mod.rs +6 -0
  105. package/rust/core/debugger/module.rs +4 -4
  106. package/rust/core/debugger/preprocessor.rs +1 -1
  107. package/rust/core/debugger/store.rs +2 -2
  108. package/rust/core/error/mod.rs +189 -0
  109. package/rust/core/lexer/handler/arrow.rs +1 -1
  110. package/rust/core/lexer/handler/at.rs +1 -1
  111. package/rust/core/lexer/handler/brace.rs +2 -2
  112. package/rust/core/lexer/handler/colon.rs +1 -1
  113. package/rust/core/lexer/handler/comment.rs +1 -1
  114. package/rust/core/lexer/handler/dot.rs +1 -1
  115. package/rust/core/lexer/handler/driver.rs +1 -1
  116. package/rust/core/lexer/handler/identifier.rs +1 -1
  117. package/rust/core/lexer/handler/mod.rs +1 -2
  118. package/rust/core/lexer/handler/number.rs +1 -1
  119. package/rust/core/lexer/handler/operator.rs +1 -1
  120. package/rust/core/lexer/handler/parenthesis.rs +2 -2
  121. package/rust/core/lexer/handler/slash.rs +1 -1
  122. package/rust/core/lexer/handler/string.rs +1 -1
  123. package/rust/core/lexer/mod.rs +22 -12
  124. package/rust/core/lexer/token.rs +90 -97
  125. package/rust/core/mod.rs +0 -1
  126. package/rust/core/parser/driver.rs +66 -13
  127. package/rust/core/parser/handler/arrow_call.rs +28 -8
  128. package/rust/core/parser/handler/at.rs +55 -21
  129. package/rust/core/parser/handler/bank.rs +14 -4
  130. package/rust/core/parser/handler/condition.rs +6 -3
  131. package/rust/core/parser/handler/dot.rs +2 -1
  132. package/rust/core/parser/handler/identifier/automate.rs +13 -16
  133. package/rust/core/parser/handler/identifier/call.rs +4 -4
  134. package/rust/core/parser/handler/identifier/emit.rs +9 -5
  135. package/rust/core/parser/handler/identifier/function.rs +20 -7
  136. package/rust/core/parser/handler/identifier/group.rs +11 -7
  137. package/rust/core/parser/handler/identifier/let_.rs +24 -9
  138. package/rust/core/parser/handler/identifier/mod.rs +6 -5
  139. package/rust/core/parser/handler/identifier/on.rs +16 -7
  140. package/rust/core/parser/handler/identifier/print.rs +6 -9
  141. package/rust/core/parser/handler/identifier/sleep.rs +12 -5
  142. package/rust/core/parser/handler/identifier/spawn.rs +4 -4
  143. package/rust/core/parser/handler/identifier/synth.rs +79 -9
  144. package/rust/core/parser/handler/loop_.rs +39 -14
  145. package/rust/core/parser/handler/tempo.rs +9 -5
  146. package/rust/core/parser/mod.rs +0 -1
  147. package/rust/core/parser/statement.rs +6 -137
  148. package/rust/core/plugin/loader.rs +41 -27
  149. package/rust/core/plugin/runner.rs +68 -17
  150. package/rust/core/preprocessor/loader.rs +155 -33
  151. package/rust/core/preprocessor/processor.rs +2 -2
  152. package/rust/core/preprocessor/resolver/bank.rs +6 -8
  153. package/rust/core/preprocessor/resolver/call.rs +20 -24
  154. package/rust/core/preprocessor/resolver/condition.rs +6 -8
  155. package/rust/core/preprocessor/resolver/driver.rs +14 -16
  156. package/rust/core/preprocessor/resolver/function.rs +6 -6
  157. package/rust/core/preprocessor/resolver/group.rs +6 -8
  158. package/rust/core/preprocessor/resolver/loop_.rs +8 -10
  159. package/rust/core/preprocessor/resolver/spawn.rs +19 -23
  160. package/rust/core/preprocessor/resolver/synth.rs +6 -8
  161. package/rust/core/preprocessor/resolver/tempo.rs +6 -8
  162. package/rust/core/preprocessor/resolver/trigger.rs +22 -19
  163. package/rust/core/preprocessor/resolver/value.rs +99 -4
  164. package/rust/core/store/export.rs +28 -28
  165. package/rust/core/store/function.rs +6 -0
  166. package/rust/core/store/global.rs +7 -1
  167. package/rust/core/store/import.rs +28 -28
  168. package/rust/core/store/variable.rs +1 -1
  169. package/rust/core/utils/mod.rs +0 -1
  170. package/rust/lib.rs +102 -9
  171. package/rust/main.rs +156 -45
  172. package/rust/types/Cargo.toml +8 -0
  173. package/rust/types/src/addons.rs +55 -0
  174. package/rust/types/src/ast.rs +198 -0
  175. package/rust/types/src/config.rs +74 -0
  176. package/rust/types/src/lib.rs +12 -0
  177. package/rust/types/src/telemetry.rs +85 -0
  178. package/rust/utils/Cargo.toml +23 -0
  179. package/rust/utils/{error.rs → src/error.rs} +186 -200
  180. package/rust/utils/src/file.rs +94 -0
  181. package/rust/utils/src/first_usage.rs +97 -0
  182. package/rust/utils/{mod.rs → src/lib.rs} +1 -1
  183. package/rust/utils/{logger.rs → src/logger.rs} +17 -12
  184. package/rust/utils/src/path.rs +88 -0
  185. package/rust/utils/src/signature.rs +41 -0
  186. package/rust/utils/{spinner.rs → src/spinner.rs} +3 -5
  187. package/rust/utils/src/version.rs +27 -0
  188. package/rust/utils/{watcher.rs → src/watcher.rs} +13 -1
  189. package/rust/web/api.rs +5 -0
  190. package/rust/web/cdn.rs +34 -0
  191. package/templates/minimal/README.md +98 -54
  192. package/templates/welcome/README.md +98 -54
  193. package/templates/welcome/src/index.deva +56 -8
  194. package/templates/welcome/src/variables.deva +2 -4
  195. package/tests/rust/TODO.md +0 -0
  196. package/tests/typescript/index.spec.ts +136 -0
  197. package/tests/typescript/playhead.spec.ts +36 -0
  198. package/tests/typescript/render_e2e.spec.ts +77 -0
  199. package/tsconfig.json +1 -1
  200. package/typescript/core/functions/index.ts +83 -0
  201. package/typescript/core/index.ts +6 -0
  202. package/typescript/core/types/index.ts +4 -0
  203. package/typescript/core/types/plugin.ts +19 -0
  204. package/typescript/core/types/result.ts +29 -0
  205. package/typescript/core/types/statement.ts +47 -0
  206. package/typescript/core/types/value.ts +29 -0
  207. package/typescript/index.ts +7 -2
  208. package/typescript/pkg/devalang_core.d.ts +4 -0
  209. package/typescript/scripts/copy-wasm-dts.ts +41 -0
  210. package/typescript/scripts/postinstall.ts +45 -32
  211. package/rust/cli/bank.rs +0 -462
  212. package/rust/cli/build.rs +0 -252
  213. package/rust/cli/generator.rs +0 -1
  214. package/rust/cli/play.rs +0 -1123
  215. package/rust/cli/telemetry.rs +0 -19
  216. package/rust/common/api.rs +0 -5
  217. package/rust/common/cdn.rs +0 -5
  218. package/rust/config/loader.rs +0 -165
  219. package/rust/config/stats.rs +0 -257
  220. package/rust/core/audio/engine.rs +0 -696
  221. package/rust/core/shared/bank.rs +0 -21
  222. package/rust/core/shared/duration.rs +0 -9
  223. package/rust/core/shared/mod.rs +0 -3
  224. package/rust/core/shared/value.rs +0 -35
  225. package/rust/core/utils/validation.rs +0 -35
  226. package/rust/installer/bank.rs +0 -62
  227. package/rust/installer/plugin.rs +0 -54
  228. package/rust/installer/utils.rs +0 -56
  229. package/rust/utils/file.rs +0 -38
  230. package/rust/utils/first_usage.rs +0 -76
  231. package/rust/utils/signature.rs +0 -19
  232. package/rust/utils/telemetry.rs +0 -292
  233. package/rust/utils/version.rs +0 -15
  234. /package/rust/{common → web}/mod.rs +0 -0
  235. /package/rust/{common → web}/sso.rs +0 -0
@@ -1,12 +1,10 @@
1
- use crate::{
2
- core::{
3
- parser::statement::{Statement, StatementKind},
4
- preprocessor::module::Module,
5
- shared::value::Value,
6
- store::global::GlobalStore,
7
- },
8
- utils::logger::{LogLevel, Logger},
1
+ use crate::core::{
2
+ parser::statement::{Statement, StatementKind},
3
+ preprocessor::module::Module,
4
+ store::global::GlobalStore,
9
5
  };
6
+ use devalang_types::Value;
7
+ use devalang_utils::logger::{LogLevel, Logger};
10
8
 
11
9
  pub fn resolve_call(
12
10
  stmt: &Statement,
@@ -44,23 +42,21 @@ pub fn resolve_call(
44
42
  }
45
43
 
46
44
  // Otherwise, check if it's a variable (e.g. group)
47
- if let Some(variable) = global_store.variables.variables.get(&name) {
48
- if let Value::Statement(stmt_box) = variable {
49
- if let StatementKind::Group = stmt_box.kind {
50
- if let Value::Map(map) = &stmt_box.value {
51
- if let Some(Value::Block(body)) = map.get("body") {
52
- let mut resolved_map = std::collections::HashMap::new();
53
- resolved_map
54
- .insert("identifier".to_string(), Value::String(name.clone()));
55
- resolved_map.insert("args".to_string(), Value::Array(args.clone()));
56
- resolved_map.insert("body".to_string(), Value::Block(body.clone()));
45
+ if let Some(Value::Statement(stmt_box)) = global_store.variables.variables.get(&name) {
46
+ if let StatementKind::Group = stmt_box.kind {
47
+ if let Value::Map(map) = &stmt_box.value {
48
+ if let Some(Value::Block(body)) = map.get("body") {
49
+ let mut resolved_map = std::collections::HashMap::new();
50
+ resolved_map
51
+ .insert("identifier".to_string(), Value::String(name.clone()));
52
+ resolved_map.insert("args".to_string(), Value::Array(args.clone()));
53
+ resolved_map.insert("body".to_string(), Value::Block(body.clone()));
57
54
 
58
- return Statement {
59
- kind: StatementKind::Call { name, args },
60
- value: Value::Map(resolved_map),
61
- ..stmt.clone()
62
- };
63
- }
55
+ return Statement {
56
+ kind: StatementKind::Call { name, args },
57
+ value: Value::Map(resolved_map),
58
+ ..stmt.clone()
59
+ };
64
60
  }
65
61
  }
66
62
  }
@@ -1,12 +1,10 @@
1
- use crate::{
2
- core::{
3
- parser::statement::{Statement, StatementKind},
4
- preprocessor::{module::Module, resolver::driver::resolve_statement},
5
- shared::value::Value,
6
- store::global::GlobalStore,
7
- },
8
- utils::logger::Logger,
1
+ use crate::core::{
2
+ parser::statement::{Statement, StatementKind},
3
+ preprocessor::{module::Module, resolver::driver::resolve_statement},
4
+ store::global::GlobalStore,
9
5
  };
6
+ use devalang_types::Value;
7
+ use devalang_utils::logger::Logger;
10
8
 
11
9
  pub fn resolve_condition(
12
10
  stmt: &Statement,
@@ -1,21 +1,19 @@
1
- use crate::{
2
- core::{
3
- parser::statement::{Statement, StatementKind},
4
- preprocessor::{
5
- loader::ModuleLoader,
6
- module::Module,
7
- resolver::{
8
- bank::resolve_bank, call::resolve_call, condition::resolve_condition,
9
- function::resolve_function, group::resolve_group, let_::resolve_let,
10
- loop_::resolve_loop, spawn::resolve_spawn, tempo::resolve_tempo,
11
- trigger::resolve_trigger,
12
- },
1
+ use crate::core::{
2
+ parser::statement::{Statement, StatementKind},
3
+ preprocessor::{
4
+ loader::ModuleLoader,
5
+ module::Module,
6
+ resolver::{
7
+ bank::resolve_bank, call::resolve_call, condition::resolve_condition,
8
+ function::resolve_function, group::resolve_group, let_::resolve_let,
9
+ loop_::resolve_loop, spawn::resolve_spawn, tempo::resolve_tempo,
10
+ trigger::resolve_trigger,
13
11
  },
14
- shared::value::Value,
15
- store::global::GlobalStore,
16
12
  },
17
- utils::logger::Logger,
13
+ store::global::GlobalStore,
18
14
  };
15
+ use devalang_types::Value;
16
+ use devalang_utils::logger::Logger;
19
17
  use std::collections::HashMap;
20
18
 
21
19
  pub fn resolve_all_modules(module_loader: &ModuleLoader, global_store: &mut GlobalStore) {
@@ -134,7 +132,7 @@ fn resolve_value(value: &Value, module: &Module, global_store: &mut GlobalStore)
134
132
  }
135
133
 
136
134
  fn find_export_value(name: &str, global_store: &GlobalStore) -> Option<Value> {
137
- for (_path, module) in &global_store.modules {
135
+ for module in global_store.modules.values() {
138
136
  if let Some(val) = module.export_table.get_export(name) {
139
137
  return Some(val.clone());
140
138
  }
@@ -1,9 +1,9 @@
1
1
  use crate::core::{
2
2
  parser::statement::{Statement, StatementKind},
3
3
  preprocessor::{module::Module, resolver::driver::resolve_statement},
4
- shared::value::Value,
5
4
  store::{function::FunctionDef, global::GlobalStore},
6
5
  };
6
+ use devalang_types::Value;
7
7
 
8
8
  pub fn resolve_function(
9
9
  stmt: &Statement,
@@ -17,7 +17,7 @@ pub fn resolve_function(
17
17
  body,
18
18
  } = &stmt.kind
19
19
  {
20
- let resolved_body = resolve_block_statements(body, &module, path, global_store);
20
+ let resolved_body = resolve_block_statements(body, module, path, global_store);
21
21
 
22
22
  global_store.functions.add_function(FunctionDef {
23
23
  name: name.clone(),
@@ -35,7 +35,7 @@ pub fn resolve_function(
35
35
  eprintln!("[resolve_statement] ❌ Module path not found: {path}");
36
36
  }
37
37
 
38
- return Statement {
38
+ Statement {
39
39
  kind: StatementKind::Function {
40
40
  name: name.clone(),
41
41
  parameters: parameters.clone(),
@@ -43,15 +43,15 @@ pub fn resolve_function(
43
43
  },
44
44
  value: Value::Null,
45
45
  ..stmt.clone()
46
- };
46
+ }
47
47
  } else {
48
- return Statement {
48
+ Statement {
49
49
  kind: StatementKind::Error {
50
50
  message: "Expected a function statement".to_string(),
51
51
  },
52
52
  value: Value::Null,
53
53
  ..stmt.clone()
54
- };
54
+ }
55
55
  }
56
56
  }
57
57
 
@@ -1,12 +1,10 @@
1
- use crate::{
2
- core::{
3
- parser::statement::{Statement, StatementKind},
4
- preprocessor::{module::Module, resolver::driver::resolve_statement},
5
- shared::value::Value,
6
- store::global::GlobalStore,
7
- },
8
- utils::logger::{LogLevel, Logger},
1
+ use crate::core::{
2
+ parser::statement::{Statement, StatementKind},
3
+ preprocessor::{module::Module, resolver::driver::resolve_statement},
4
+ store::global::GlobalStore,
9
5
  };
6
+ use devalang_types::Value;
7
+ use devalang_utils::logger::{LogLevel, Logger};
10
8
 
11
9
  pub fn resolve_group(
12
10
  stmt: &Statement,
@@ -1,17 +1,15 @@
1
1
  use std::collections::HashMap;
2
2
 
3
- use crate::{
4
- core::{
5
- parser::statement::{Statement, StatementKind},
6
- preprocessor::{
7
- module::Module,
8
- resolver::{driver::resolve_statement, value::resolve_value},
9
- },
10
- shared::value::Value,
11
- store::global::GlobalStore,
3
+ use crate::core::{
4
+ parser::statement::{Statement, StatementKind},
5
+ preprocessor::{
6
+ module::Module,
7
+ resolver::{driver::resolve_statement, value::resolve_value},
12
8
  },
13
- utils::logger::Logger,
9
+ store::global::GlobalStore,
14
10
  };
11
+ use devalang_types::Value;
12
+ use devalang_utils::logger::Logger;
15
13
 
16
14
  pub fn resolve_loop(
17
15
  stmt: &Statement,
@@ -1,12 +1,10 @@
1
- use crate::{
2
- core::{
3
- parser::statement::{Statement, StatementKind},
4
- preprocessor::module::Module,
5
- shared::value::Value,
6
- store::global::GlobalStore,
7
- },
8
- utils::logger::{LogLevel, Logger},
1
+ use crate::core::{
2
+ parser::statement::{Statement, StatementKind},
3
+ preprocessor::module::Module,
4
+ store::global::GlobalStore,
9
5
  };
6
+ use devalang_types::Value;
7
+ use devalang_utils::logger::{LogLevel, Logger};
10
8
 
11
9
  pub fn resolve_spawn(
12
10
  stmt: &Statement,
@@ -33,22 +31,20 @@ pub fn resolve_spawn(
33
31
  }
34
32
 
35
33
  // If it's a group stored in variables
36
- if let Some(variable) = global_store.variables.variables.get(&name) {
37
- if let Value::Statement(stmt_box) = variable {
38
- if let StatementKind::Group = stmt_box.kind {
39
- if let Value::Map(map) = &stmt_box.value {
40
- if let Some(Value::Block(body)) = map.get("body") {
41
- let mut resolved_map = std::collections::HashMap::new();
42
- resolved_map.insert("identifier".to_string(), Value::String(name.clone()));
43
- resolved_map.insert("args".to_string(), Value::Array(args.clone()));
44
- resolved_map.insert("body".to_string(), Value::Block(body.clone()));
34
+ if let Some(Value::Statement(stmt_box)) = global_store.variables.variables.get(&name) {
35
+ if let StatementKind::Group = stmt_box.kind {
36
+ if let Value::Map(map) = &stmt_box.value {
37
+ if let Some(Value::Block(body)) = map.get("body") {
38
+ let mut resolved_map = std::collections::HashMap::new();
39
+ resolved_map.insert("identifier".to_string(), Value::String(name.clone()));
40
+ resolved_map.insert("args".to_string(), Value::Array(args.clone()));
41
+ resolved_map.insert("body".to_string(), Value::Block(body.clone()));
45
42
 
46
- return Statement {
47
- kind: StatementKind::Spawn { name, args },
48
- value: Value::Map(resolved_map),
49
- ..stmt.clone()
50
- };
51
- }
43
+ return Statement {
44
+ kind: StatementKind::Spawn { name, args },
45
+ value: Value::Map(resolved_map),
46
+ ..stmt.clone()
47
+ };
52
48
  }
53
49
  }
54
50
  }
@@ -1,12 +1,10 @@
1
- use crate::{
2
- core::{
3
- parser::statement::{Statement, StatementKind},
4
- preprocessor::{module::Module, resolver::driver::resolve_statement},
5
- shared::value::Value,
6
- store::global::GlobalStore,
7
- },
8
- utils::logger::{LogLevel, Logger},
1
+ use crate::core::{
2
+ parser::statement::{Statement, StatementKind},
3
+ preprocessor::{module::Module, resolver::driver::resolve_statement},
4
+ store::global::GlobalStore,
9
5
  };
6
+ use devalang_types::Value;
7
+ use devalang_utils::logger::{LogLevel, Logger};
10
8
 
11
9
  pub fn resolve_synth(
12
10
  stmt: &Statement,
@@ -1,12 +1,10 @@
1
- use crate::{
2
- core::{
3
- parser::statement::{Statement, StatementKind},
4
- preprocessor::module::Module,
5
- shared::value::Value,
6
- store::global::GlobalStore,
7
- },
8
- utils::logger::Logger,
1
+ use crate::core::{
2
+ parser::statement::{Statement, StatementKind},
3
+ preprocessor::module::Module,
4
+ store::global::GlobalStore,
9
5
  };
6
+ use devalang_types::Value;
7
+ use devalang_utils::logger::Logger;
10
8
 
11
9
  pub fn resolve_tempo(
12
10
  stmt: &Statement,
@@ -1,14 +1,11 @@
1
- use std::collections::HashMap;
2
-
3
- use crate::{
4
- core::{
5
- parser::statement::{Statement, StatementKind},
6
- preprocessor::module::Module,
7
- shared::{duration::Duration, value::Value},
8
- store::global::GlobalStore,
9
- },
10
- utils::logger::Logger,
1
+ use crate::core::{
2
+ parser::statement::{Statement, StatementKind},
3
+ preprocessor::module::Module,
4
+ store::global::GlobalStore,
11
5
  };
6
+ use devalang_types::{Duration, Value};
7
+ use devalang_utils::logger::Logger;
8
+ use std::collections::HashMap;
12
9
 
13
10
  pub fn resolve_trigger(
14
11
  stmt: &Statement,
@@ -44,15 +41,21 @@ pub fn resolve_trigger(
44
41
  // Params value resolution
45
42
  let final_value = match &stmt.value {
46
43
  Value::Identifier(ident) => {
47
- println!("Resolving identifier: {}", ident);
44
+ logger.log_message(
45
+ devalang_utils::logger::LogLevel::Debug,
46
+ &format!("Resolving identifier: {}", ident),
47
+ );
48
48
 
49
- resolve_identifier(ident, module, global_store).unwrap_or_else(|| {
50
- logger.log_error_with_stacktrace(
51
- &format!("'{path}': value identifier '{ident}' not found"),
52
- &format!("{}:{}:{}", module.path, stmt.line, stmt.column),
53
- );
54
- Value::Null
55
- })
49
+ match resolve_identifier(ident, module, global_store) {
50
+ Some(v) => v,
51
+ None => {
52
+ logger.log_error_with_stacktrace(
53
+ &format!("'{path}': value identifier '{ident}' not found"),
54
+ &format!("{}:{}:{}", module.path, stmt.line, stmt.column),
55
+ );
56
+ Value::Null
57
+ }
58
+ }
56
59
  }
57
60
  Value::Map(map) => {
58
61
  let mut resolved_map = HashMap::new();
@@ -88,7 +91,7 @@ fn resolve_identifier(ident: &str, module: &Module, global_store: &GlobalStore)
88
91
  return Some(resolve_value(val, module, global_store));
89
92
  }
90
93
 
91
- for (_, other_mod) in &global_store.modules {
94
+ for other_mod in global_store.modules.values() {
92
95
  if let Some(val) = other_mod.variable_table.get(ident) {
93
96
  return Some(resolve_value(val, other_mod, global_store));
94
97
  }
@@ -1,13 +1,15 @@
1
1
  use std::collections::HashMap;
2
+ use toml::Value as TomlValue;
2
3
 
3
4
  use crate::core::{
4
5
  preprocessor::{module::Module, resolver::driver::resolve_statement},
5
- shared::value::Value,
6
6
  store::global::GlobalStore,
7
7
  };
8
8
 
9
+ use devalang_types::Value;
10
+
9
11
  fn find_export_value(name: &str, global_store: &GlobalStore) -> Option<Value> {
10
- for (_path, module) in &global_store.modules {
12
+ for module in global_store.modules.values() {
11
13
  if let Some(val) = module.export_table.get_export(name) {
12
14
  return Some(val.clone());
13
15
  }
@@ -51,9 +53,102 @@ pub fn resolve_value(value: &Value, module: &Module, global_store: &mut GlobalSt
51
53
  .map(|p| resolve_value(p, module, global_store))
52
54
  .unwrap_or(Value::Map(HashMap::new()));
53
55
 
56
+ // If waveform refers to a plugin synth (e.g., alias.synth),
57
+ // merge plugin-exported defaults (dynamic) into parameters and
58
+ // allow 'waveform' override from parameters map.
59
+ let mut final_waveform = resolved_waveform.clone();
60
+ let mut params_map = match resolved_params.clone() {
61
+ Value::Map(m) => m,
62
+ _ => HashMap::new(),
63
+ };
64
+
65
+ // Helper: convert TomlValue into runtime Value
66
+ fn toml_to_value(tv: &TomlValue) -> Value {
67
+ match tv {
68
+ TomlValue::String(s) => Value::String(s.clone()),
69
+ TomlValue::Integer(i) => Value::Number(*i as f32),
70
+ TomlValue::Float(f) => Value::Number(*f as f32),
71
+ TomlValue::Boolean(b) => Value::Boolean(*b),
72
+ TomlValue::Array(arr) => {
73
+ Value::Array(arr.iter().map(toml_to_value).collect())
74
+ }
75
+ TomlValue::Table(t) => {
76
+ let mut m = HashMap::new();
77
+ for (k, v) in t.iter() {
78
+ m.insert(k.clone(), toml_to_value(v));
79
+ }
80
+ Value::Map(m)
81
+ }
82
+ _ => Value::Null,
83
+ }
84
+ }
85
+
86
+ // Detect plugin alias from waveform string like "alias.synth" OR just "alias"
87
+ let (alias_opt, explicit_synth_export) = match &final_waveform {
88
+ Value::String(s) | Value::Identifier(s) => {
89
+ let parts: Vec<&str> = s.split('.').collect();
90
+ if parts.len() >= 2 && parts[1] == "synth" {
91
+ (Some(parts[0].to_string()), true)
92
+ } else if parts.len() == 1 {
93
+ (Some(parts[0].to_string()), false)
94
+ } else {
95
+ (None, false)
96
+ }
97
+ }
98
+ _ => (None, false),
99
+ };
100
+
101
+ if let Some(alias) = alias_opt {
102
+ // Resolve alias -> plugin uri -> plugin info
103
+ if let Some(Value::String(uri)) = module.variable_table.get(&alias) {
104
+ if let Some(id) = uri.strip_prefix("devalang://plugin/") {
105
+ let mut parts = id.split('.');
106
+ let author = parts.next().unwrap_or("");
107
+ let pname = parts.next().unwrap_or("");
108
+ let key = format!("{}:{}", author, pname);
109
+ if let Some((plugin_info, _wasm)) =
110
+ global_store.plugins.get(&key)
111
+ {
112
+ // Merge defaults dynamically from exports
113
+ for exp in &plugin_info.exports {
114
+ // Skip entry named 'synth' which is used as the flag
115
+ if exp.name == "synth" {
116
+ continue;
117
+ }
118
+ if let Some(def) = &exp.default {
119
+ let val = toml_to_value(def);
120
+ // only apply if not overridden by user params
121
+ params_map.entry(exp.name.clone()).or_insert(val);
122
+ }
123
+ }
124
+
125
+ // If 'waveform' is provided in params (by user or default), use it
126
+ if let Some(wf_val) = params_map.remove("waveform") {
127
+ final_waveform =
128
+ resolve_value(&wf_val, module, global_store);
129
+ } else if let Some(wf_default) = plugin_info
130
+ .exports
131
+ .iter()
132
+ .find(|e| e.name == "waveform")
133
+ .and_then(|e| e.default.as_ref())
134
+ {
135
+ final_waveform = toml_to_value(wf_default);
136
+ } else if explicit_synth_export {
137
+ // keep as alias.synth if no default waveform
138
+ } else {
139
+ // If no explicit .synth in waveform, but alias is a plugin,
140
+ // treat it as alias.synth by default to enable plugin synth usage
141
+ final_waveform =
142
+ Value::String(format!("{}.synth", alias));
143
+ }
144
+ }
145
+ }
146
+ }
147
+ }
148
+
54
149
  let mut result = HashMap::new();
55
- result.insert("waveform".to_string(), resolved_waveform);
56
- result.insert("parameters".to_string(), resolved_params);
150
+ result.insert("waveform".to_string(), final_waveform);
151
+ result.insert("parameters".to_string(), Value::Map(params_map));
57
152
 
58
153
  return Value::Map(result);
59
154
  }
@@ -1,28 +1,28 @@
1
- use std::collections::HashMap;
2
-
3
- use crate::core::shared::value::Value;
4
-
5
- #[derive(Debug, Default, Clone, PartialEq)]
6
- pub struct ExportTable {
7
- pub exports: HashMap<String, Value>,
8
- }
9
-
10
- impl ExportTable {
11
- pub fn new() -> Self {
12
- ExportTable {
13
- exports: HashMap::new(),
14
- }
15
- }
16
-
17
- pub fn add_export(&mut self, name: String, value: Value) {
18
- self.exports.insert(name, value);
19
- }
20
-
21
- pub fn get_export(&self, name: &str) -> Option<&Value> {
22
- self.exports.get(name)
23
- }
24
-
25
- pub fn remove_export(&mut self, name: &str) -> Option<Value> {
26
- self.exports.remove(name)
27
- }
28
- }
1
+ use std::collections::HashMap;
2
+
3
+ use devalang_types::Value;
4
+
5
+ #[derive(Debug, Default, Clone, PartialEq)]
6
+ pub struct ExportTable {
7
+ pub exports: HashMap<String, Value>,
8
+ }
9
+
10
+ impl ExportTable {
11
+ pub fn new() -> Self {
12
+ ExportTable {
13
+ exports: HashMap::new(),
14
+ }
15
+ }
16
+
17
+ pub fn add_export(&mut self, name: String, value: Value) {
18
+ self.exports.insert(name, value);
19
+ }
20
+
21
+ pub fn get_export(&self, name: &str) -> Option<&Value> {
22
+ self.exports.get(name)
23
+ }
24
+
25
+ pub fn remove_export(&mut self, name: &str) -> Option<Value> {
26
+ self.exports.remove(name)
27
+ }
28
+ }
@@ -13,6 +13,12 @@ pub struct FunctionTable {
13
13
  pub functions: HashMap<String, FunctionDef>,
14
14
  }
15
15
 
16
+ impl Default for FunctionTable {
17
+ fn default() -> Self {
18
+ Self::new()
19
+ }
20
+ }
21
+
16
22
  impl FunctionTable {
17
23
  pub fn new() -> Self {
18
24
  FunctionTable {
@@ -1,9 +1,9 @@
1
1
  use crate::core::{
2
2
  parser::statement::Statement,
3
- plugin::loader::PluginInfo,
4
3
  preprocessor::module::Module,
5
4
  store::{function::FunctionTable, variable::VariableTable},
6
5
  };
6
+ use devalang_types::PluginInfo;
7
7
  use std::collections::HashMap;
8
8
 
9
9
  #[derive(Debug, Clone)]
@@ -15,6 +15,12 @@ pub struct GlobalStore {
15
15
  pub plugins: HashMap<String, (PluginInfo, Vec<u8>)>,
16
16
  }
17
17
 
18
+ impl Default for GlobalStore {
19
+ fn default() -> Self {
20
+ Self::new()
21
+ }
22
+ }
23
+
18
24
  impl GlobalStore {
19
25
  pub fn new() -> Self {
20
26
  GlobalStore {
@@ -1,28 +1,28 @@
1
- use std::collections::HashMap;
2
-
3
- use crate::core::shared::value::Value;
4
-
5
- #[derive(Debug, Default, Clone, PartialEq)]
6
- pub struct ImportTable {
7
- pub imports: HashMap<String, Value>,
8
- }
9
-
10
- impl ImportTable {
11
- pub fn new() -> Self {
12
- ImportTable {
13
- imports: HashMap::new(),
14
- }
15
- }
16
-
17
- pub fn add_import(&mut self, name: String, value: Value) {
18
- self.imports.insert(name, value);
19
- }
20
-
21
- pub fn get_import(&self, name: &str) -> Option<&Value> {
22
- self.imports.get(name)
23
- }
24
-
25
- pub fn remove_import(&mut self, name: &str) -> Option<Value> {
26
- self.imports.remove(name)
27
- }
28
- }
1
+ use std::collections::HashMap;
2
+
3
+ use devalang_types::Value;
4
+
5
+ #[derive(Debug, Default, Clone, PartialEq)]
6
+ pub struct ImportTable {
7
+ pub imports: HashMap<String, Value>,
8
+ }
9
+
10
+ impl ImportTable {
11
+ pub fn new() -> Self {
12
+ ImportTable {
13
+ imports: HashMap::new(),
14
+ }
15
+ }
16
+
17
+ pub fn add_import(&mut self, name: String, value: Value) {
18
+ self.imports.insert(name, value);
19
+ }
20
+
21
+ pub fn get_import(&self, name: &str) -> Option<&Value> {
22
+ self.imports.get(name)
23
+ }
24
+
25
+ pub fn remove_import(&mut self, name: &str) -> Option<Value> {
26
+ self.imports.remove(name)
27
+ }
28
+ }
@@ -1,6 +1,6 @@
1
1
  use std::collections::HashMap;
2
2
 
3
- use crate::core::shared::value::Value;
3
+ use devalang_types::Value;
4
4
 
5
5
  #[derive(Debug, Default, Clone, PartialEq)]
6
6
  pub struct VariableTable {