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

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 (93) hide show
  1. package/.devalang +8 -9
  2. package/Cargo.toml +8 -3
  3. package/README.md +36 -34
  4. package/docs/CHANGELOG.md +65 -1
  5. package/docs/CONTRIBUTING.md +1 -0
  6. package/docs/ROADMAP.md +2 -2
  7. package/docs/TODO.md +6 -5
  8. package/examples/bank.deva +2 -4
  9. package/examples/function.deva +15 -0
  10. package/examples/index.deva +25 -14
  11. package/out-tsc/bin/devalang.exe +0 -0
  12. package/package.json +6 -6
  13. package/project-version.json +3 -3
  14. package/rust/cli/bank.rs +2 -1
  15. package/rust/cli/build.rs +76 -14
  16. package/rust/cli/check.rs +71 -8
  17. package/rust/cli/driver.rs +40 -28
  18. package/rust/cli/install.rs +22 -7
  19. package/rust/cli/login.rs +134 -0
  20. package/rust/cli/mod.rs +2 -1
  21. package/rust/cli/play.rs +45 -20
  22. package/rust/common/api.rs +8 -0
  23. package/rust/common/cdn.rs +2 -5
  24. package/rust/common/mod.rs +3 -1
  25. package/rust/common/sso.rs +8 -0
  26. package/rust/config/driver.rs +19 -1
  27. package/rust/config/loader.rs +56 -10
  28. package/rust/core/audio/engine.rs +254 -91
  29. package/rust/core/audio/interpreter/arrow_call.rs +34 -15
  30. package/rust/core/audio/interpreter/call.rs +72 -47
  31. package/rust/core/audio/interpreter/condition.rs +14 -12
  32. package/rust/core/audio/interpreter/driver.rs +90 -128
  33. package/rust/core/audio/interpreter/function.rs +21 -0
  34. package/rust/core/audio/interpreter/load.rs +1 -1
  35. package/rust/core/audio/interpreter/loop_.rs +24 -18
  36. package/rust/core/audio/interpreter/mod.rs +2 -1
  37. package/rust/core/audio/interpreter/sleep.rs +0 -6
  38. package/rust/core/audio/interpreter/spawn.rs +78 -60
  39. package/rust/core/audio/interpreter/trigger.rs +157 -70
  40. package/rust/core/audio/loader/trigger.rs +37 -4
  41. package/rust/core/audio/player.rs +20 -10
  42. package/rust/core/audio/renderer.rs +24 -25
  43. package/rust/core/builder/mod.rs +11 -6
  44. package/rust/core/debugger/mod.rs +2 -0
  45. package/rust/core/debugger/module.rs +47 -0
  46. package/rust/core/debugger/store.rs +25 -11
  47. package/rust/core/error/mod.rs +6 -0
  48. package/rust/core/lexer/handler/driver.rs +23 -1
  49. package/rust/core/lexer/handler/identifier.rs +1 -0
  50. package/rust/core/lexer/handler/indent.rs +16 -2
  51. package/rust/core/lexer/handler/mod.rs +1 -0
  52. package/rust/core/lexer/handler/parenthesis.rs +41 -0
  53. package/rust/core/lexer/token.rs +4 -0
  54. package/rust/core/mod.rs +2 -1
  55. package/rust/core/parser/driver.rs +47 -4
  56. package/rust/core/parser/handler/arrow_call.rs +78 -18
  57. package/rust/core/parser/handler/bank.rs +35 -7
  58. package/rust/core/parser/handler/dot.rs +81 -123
  59. package/rust/core/parser/handler/identifier/call.rs +69 -22
  60. package/rust/core/parser/handler/identifier/function.rs +92 -0
  61. package/rust/core/parser/handler/identifier/let_.rs +13 -19
  62. package/rust/core/parser/handler/identifier/mod.rs +1 -0
  63. package/rust/core/parser/handler/identifier/spawn.rs +74 -27
  64. package/rust/core/parser/statement.rs +16 -4
  65. package/rust/core/plugin/loader.rs +48 -0
  66. package/rust/core/plugin/mod.rs +1 -0
  67. package/rust/core/preprocessor/loader.rs +50 -32
  68. package/rust/core/preprocessor/module.rs +3 -1
  69. package/rust/core/preprocessor/processor.rs +26 -1
  70. package/rust/core/preprocessor/resolver/call.rs +61 -84
  71. package/rust/core/preprocessor/resolver/condition.rs +11 -6
  72. package/rust/core/preprocessor/resolver/driver.rs +52 -6
  73. package/rust/core/preprocessor/resolver/function.rs +78 -0
  74. package/rust/core/preprocessor/resolver/group.rs +43 -13
  75. package/rust/core/preprocessor/resolver/let_.rs +7 -10
  76. package/rust/core/preprocessor/resolver/mod.rs +2 -1
  77. package/rust/core/preprocessor/resolver/spawn.rs +64 -30
  78. package/rust/core/preprocessor/resolver/trigger.rs +7 -3
  79. package/rust/core/preprocessor/resolver/value.rs +10 -1
  80. package/rust/core/shared/value.rs +4 -1
  81. package/rust/core/store/function.rs +34 -0
  82. package/rust/core/store/global.rs +9 -10
  83. package/rust/core/store/mod.rs +2 -1
  84. package/rust/core/store/variable.rs +6 -0
  85. package/rust/installer/addon.rs +80 -0
  86. package/rust/installer/bank.rs +24 -14
  87. package/rust/installer/mod.rs +4 -1
  88. package/rust/installer/plugin.rs +55 -0
  89. package/rust/lib.rs +10 -7
  90. package/rust/main.rs +32 -9
  91. package/rust/utils/logger.rs +16 -0
  92. package/rust/utils/mod.rs +45 -1
  93. package/rust/utils/spinner.rs +2 -4
package/.devalang CHANGED
@@ -1,9 +1,8 @@
1
- [defaults]
2
- entry = "./examples"
3
- output = "./output"
4
- watch = false
5
-
6
- [[banks]]
7
- path = "devalang://bank/808"
8
- version = "0.0.1"
9
- author = "devaloop"
1
+ [defaults]
2
+ entry = "./examples"
3
+ output = "./output"
4
+ watch = false
5
+
6
+ [[banks]]
7
+ path = "devalang://bank/devaloop.808"
8
+ version = "0.0.2"
package/Cargo.toml CHANGED
@@ -1,6 +1,6 @@
1
1
  [package]
2
2
  name = "devalang"
3
- version = "0.0.1-alpha.12"
3
+ version = "0.0.1-alpha.14"
4
4
  authors = ["Devaloop <contact@devaloop.com>"]
5
5
  description = "Write music like code. Devalang is a domain-specific language (DSL) for sound designers and music hackers. Compose, automate, and control sound — in plain text."
6
6
  license = "MIT"
@@ -20,7 +20,7 @@ required-features = ["cli"]
20
20
 
21
21
  [lib]
22
22
  path = "rust/lib.rs"
23
- crate-type = ["cdylib"]
23
+ crate-type = ["cdylib", "rlib"]
24
24
 
25
25
  [profile.release]
26
26
  opt-level = "s"
@@ -50,4 +50,9 @@ js-sys = "0.3"
50
50
  reqwest = { version = "0.12.22", optional = true, features = ["json"] }
51
51
  flate2 = { version = "1.0", optional = true }
52
52
  tokio = { version = "1", features = ["full"], optional = true }
53
- zip = { version = "4.3.0", optional = true }
53
+ zip = { version = "4.3.0", optional = true }
54
+ rayon = "1.10.0"
55
+ webbrowser = "0.8"
56
+ tiny_http = "0.9.0"
57
+ dirs = "5"
58
+ urlencoding = "2.1"
package/README.md CHANGED
@@ -1,5 +1,5 @@
1
1
  <div align="center">
2
- <img src="https://devalang.com/images/devalang-logo-cyan.svg" alt="Devalang Logo" width="300" />
2
+ <img src="https://devalang.com/images/devalang-logo.svg" alt="Devalang Logo" width="300" />
3
3
  </div>
4
4
 
5
5
  ![Rust](https://img.shields.io/badge/Made%20with-Rust-orange?logo=rust)
@@ -7,7 +7,7 @@
7
7
  ![Node.js](https://img.shields.io/badge/Node.js-18%2B-brightgreen?logo=node.js)
8
8
 
9
9
  ![Project Status](https://img.shields.io/badge/status-alpha-red)
10
- ![Version](https://img.shields.io/badge/version-0.0.1-blue)
10
+ ![Version](https://img.shields.io/npm/v/@devaloop/devalang)
11
11
  ![License: MIT](https://img.shields.io/badge/license-MIT-green)
12
12
  ![Platform](https://img.shields.io/badge/platform-Windows-blue)
13
13
 
@@ -16,26 +16,20 @@
16
16
 
17
17
  [![VSCode Extension](https://img.shields.io/visual-studio-marketplace/v/devaloop.devalang-vscode?label=VSCode%20Extension)](https://marketplace.visualstudio.com/items?itemName=devaloop.devalang-vscode)
18
18
 
19
- # 🎶 Devalang
20
-
21
- Compose music with code — structured, expressive, and fast.
19
+ # 🦊 Devalang (CORE) — Compose music with code
22
20
 
23
21
  Devalang is a tiny domain-specific language (DSL) for music makers, sound designers, and audio hackers.
24
22
  Compose loops, control samples, render and play audio — all in clean, readable text.
25
23
 
26
- 🦊 Whether you're building a track, shaping textures, or performing live, Devalang helps you think in rhythms. It’s designed to be simple, expressive, and fast — because your ideas shouldn’t wait.
24
+ Whether you're building a track, shaping textures, or performing live, Devalang helps you think in rhythms. It’s designed to be simple, expressive, and fast — because your ideas shouldn’t wait.
27
25
 
28
26
  From studio sketches to live sets, Devalang gives you rhythmic control — with the elegance of code.
29
27
 
30
- > 🚧 **v0.0.1-alpha.11 Notice** 🚧
31
- >
32
- > NEW: Devalang is available in your browser at [playground.devalang.com](https://playground.devalang.com) !
33
- >
34
- > NEW: Online documentation is now available at [docs.devalang.com](https://docs.devalang.com)
28
+ > 🚧 Alpha Notice 🚧
35
29
  >
36
30
  > Includes synthesis, playback, and rendering features, but is still in early development.
37
31
  >
38
- > Currently, Devalang CLI is only available for **Windows**.
32
+ > Currently, Devalang CLI is only available for **Windows**.
39
33
  > Linux and macOS binaries will be added in future releases via cross-platform builds.
40
34
 
41
35
  ## 📚 Quick Access
@@ -51,7 +45,11 @@ From studio sketches to live sets, Devalang gives you rhythmic control — with
51
45
 
52
46
  ## ⏱️ Try it now !
53
47
 
54
- ### You can also have a look at the [Playground](https://playground.devalang.com) to try Devalang directly in your browser
48
+ ### Try Devalang in your browser
49
+
50
+ > Have a look at the [Playground](https://playground.devalang.com) to try Devalang directly in your browser
51
+
52
+ ### Try Devalang CLI
55
53
 
56
54
  ```bash
57
55
  # Install Devalang CLI globally
@@ -68,10 +66,23 @@ Create a new Devalang file `src/index.deva` in the project directory:
68
66
  # src/index.deva
69
67
 
70
68
  group myLead:
71
- let mySynth = synth sine
72
-
73
- mySynth -> note(C4, { duration: 400 })
74
- mySynth -> note(G4, { duration: 600 })
69
+ let mySynth = synth sine {
70
+ attack: 0,
71
+ decay: 100,
72
+ sustain: 100,
73
+ release: 100
74
+ }
75
+
76
+ mySynth -> note(C4, {
77
+ duration: 400,
78
+ velocity: 0.7,
79
+ glide: true
80
+ })
81
+
82
+ mySynth -> note(G4, {
83
+ duration: 600,
84
+ slide: true
85
+ })
75
86
 
76
87
  # Play the lead
77
88
 
@@ -95,19 +106,19 @@ devalang play --repeat
95
106
 
96
107
  > For more examples, check out the [examples directory](./examples/).
97
108
 
98
- ## ❓ Why Devalang?
109
+ ## ❓ Why Devalang ?
99
110
 
100
- - 🎹 Prototype audio ideas without opening a DAW
111
+ - 🎹 Prototype audio ideas without opening a DAW, even VSCode
101
112
  - 💻 Integrate sound into code-based workflows
102
113
  - 🎛️ Control audio parameters through readable syntax
103
114
  - 🧪 Build musical logic with variables and conditions
104
-
105
- > Producer, coder, or both — Devalang gives you musical structure, instantly.
115
+ - 🔄 Create complex patterns with ease
106
116
 
107
117
  ## 🚀 Features
108
118
 
109
119
  - 🎵 **Audio Engine**: Integrated audio playback and rendering
110
120
  - 🧩 **Module system** for importing and exporting variables between files
121
+ - 📦 **Addon manager** for managing external banks, plugins and more
111
122
  - 📜 **Structured AST** generation for debugging and future compilation
112
123
  - 🔢 **Basic data types**: strings, numbers, booleans, maps, arrays
113
124
  - 👁️ **Watch mode** for `build`, `check` and `play` commands
@@ -119,22 +130,9 @@ devalang play --repeat
119
130
 
120
131
  ### Please refer to the [online documentation](https://docs.devalang.com) for detailed information on syntax, features, and usage examples.
121
132
 
122
- ## 📜 Changelog Highlights
123
-
124
- For a complete list of changes, see [docs/CHANGELOG.md](./docs/CHANGELOG.md)
125
-
126
- - Implemented beat durations in `triggers` and `arrow_calls` statements
127
- - Implemented `bank` resolver to resolve banks of sounds in the code
128
- - Support for namespaced banks of sounds (e.g. `.808.myTrigger`)
129
- - Implemented multiple commands for `bank` management
130
- - `bank list`, `bank available`, `bank info <bank_name>`, `bank remove <bank_name>`, `bank update`, `bank update <bank_name>`
131
- - Implemented `install` command to install banks of sounds
132
- - `install bank <bank_name>`
133
-
134
133
  ## 🧯 Known issues
135
134
 
136
135
  - No smart modules yet, all groups, variables, and samples must be explicitly imported where used
137
- - No support yet for `pattern`, `function`, ... statements
138
136
  - No support yet for cross-platform builds (Linux, macOS)
139
137
 
140
138
  ## 🧪 Roadmap Highlights
@@ -154,6 +152,10 @@ MIT — see [LICENSE](./LICENSE)
154
152
  Contributions, bug reports and suggestions are welcome !
155
153
  Feel free to open an issue or submit a pull request.
156
154
 
155
+ For more info, see [docs/CONTRIBUTING.md](./docs/CONTRIBUTING.md).
156
+
157
157
  ## 📢 Contact
158
158
 
159
+ Feel free to reach out for any inquiries or feedback.
160
+
159
161
  📧 [contact@devaloop.com](mailto:contact@devaloop.com)
package/docs/CHANGELOG.md CHANGED
@@ -1,9 +1,73 @@
1
1
  <div align="center">
2
- <img src="https://devalang.com/images/devalang-logo-cyan.svg" alt="Devalang Logo" width="300" />
2
+ <img src="https://devalang.com/images/devalang-logo.svg" alt="Devalang Logo" width="300" />
3
3
  </div>
4
4
 
5
5
  # Changelog
6
6
 
7
+ ## Version 0.0.1-alpha.14 (2025-08-24)
8
+
9
+ ### 🌎 Ecosystem
10
+
11
+ - Deployed "SSO" (Single Sign-On) for user authentication. [(https://sso.devalang.com)](https://sso.devalang.com) when using `devalang login`.
12
+
13
+ ### 🧩 Language Features
14
+
15
+ - Added support for ADSR envelopes in synthesizers.
16
+ - Example: `let mySynth = synth sine { attack: 0, decay: 50, sustain: 100, release: 50 }`
17
+ - Added support for `note` parameters in synthesizers.
18
+ - Example: `mySynth -> note(C4, { duration: 500, velocity: 0.8, glide: true, slide: false })`
19
+
20
+ ### 🧠 Core Engine
21
+
22
+ - Patched banks resolution with improved namespace handling. (declaring `bank <bank_author>.<bank_name>` and using `.<bank_name>.<bank_trigger>`)
23
+ - Patched `arrow_call` to correctly handle argument parsing and improve error reporting.
24
+ - Implemented multi-line argument parsing for `arrow_call`.
25
+ - Patched execution of `arrow_call` to ensure correct timing and execution order.
26
+ - Upgraded indent lexer to handle multi-line statements and improve indentation handling.
27
+ - Upgraded `parse_map_value` to handle multi-line values and improve parsing logic in Parser.
28
+ - Added `log_message_with_trace` function to log messages with informations when running commands with `debug` flag.
29
+
30
+ ### 🧰 Commands
31
+
32
+ - Added `login` command to authenticate users to install protected or private packages.
33
+ - Refactored `install` command to support installing banks, presets and plugins.
34
+ - `install bank <bank_author>.<bank_name>` to install a specific bank of sounds.
35
+ - `install preset <preset_author>.<preset_name>` to install a specific preset.
36
+ - `install plugin <plugin_author>.<plugin_name>` to install a specific plugin.
37
+ - Implemented `debug` and `compress` arguments for `build`, `check` and `play` commands.
38
+ - `build --debug` to build the AST with debug information.
39
+ - `check --debug` to check the syntax with debug information.
40
+ - `play --debug` to play the audio with debug information.
41
+ - `build --compress` to compress the output.
42
+ - `check --compress` to compress the output.
43
+ - `play --compress` to compress the output.
44
+
45
+ ## Version 0.0.1-alpha.13 (2025-07-26)
46
+
47
+ ### 🧩 Language Features
48
+
49
+ - Added support for `fn` directive to define functions in Devalang.
50
+ - Example: `fn myFunction(param1, param2):`
51
+
52
+ ### 🧠 Core Engine
53
+
54
+ - Patched `trigger`, `call`, and `spawn`, `renderer` to handle correct cursor time in the audio interpreter.
55
+ - Refactored audio engine and interpreter to handle correct timing and execution while using `loop`, `call`, and `spawn` statements.
56
+ - Refactored `trigger` effects to apply more effects to triggers.
57
+ - Example: `.myTrigger auto { reverb: 0.25, pitch: 0.75, gain: 0.8 }`
58
+ - Refactored `preprocessor` to handle correct namespaced banks of sounds and triggers.
59
+ - Refactored `collect_errors_recursively` to provide detailed error reporting across nested statements.
60
+ - Optimized the `renderer` to handle silent buffers and improve performance.
61
+
62
+ ### 🛠️ Utilities
63
+
64
+ - Added the `extract_loop_body_statements` utility for better loop handling.
65
+ - Improved logging for module variables and functions.
66
+
67
+ ### 🧩 Web Assembly
68
+
69
+ - Patched `lib.rs` dependencies to ensure compatibility with the latest Rust and WASM standards.
70
+
7
71
  ## Version 0.0.1-alpha.12 (2025-07-21)
8
72
 
9
73
  ### 🧩 Language Features
@@ -0,0 +1 @@
1
+ # This file is a placeholder
package/docs/ROADMAP.md CHANGED
@@ -1,5 +1,5 @@
1
1
  <div align="center">
2
- <img src="https://devalang.com/images/devalang-logo-cyan.svg" alt="Devalang Logo" width="300" />
2
+ <img src="https://devalang.com/images/devalang-logo.svg" alt="Devalang Logo" width="300" />
3
3
  </div>
4
4
 
5
5
  # Roadmap
@@ -8,7 +8,7 @@ Devalang is a work in progress. Here’s what we’re planning next:
8
8
 
9
9
  ## Completed
10
10
 
11
- - ✅ **Audio engine**: Integrate the audio engine for sound playback.
11
+ - ✅ **Audio engine**: Integrate the audio engine for sound playback.
12
12
  - ✅ **Basic syntax**: Implement the core syntax for Devalang, including data types and basic statements.
13
13
  - ✅ **Watch mode**: Add a watch mode to automatically rebuild on file changes.
14
14
  - ✅ **Module system**: Add support for importing and exporting variables between files using `@import` and `@export`.
package/docs/TODO.md CHANGED
@@ -1,5 +1,5 @@
1
1
  <div align="center">
2
- <img src="https://devalang.com/images/devalang-logo-cyan.svg" alt="Devalang Logo" width="300" />
2
+ <img src="https://devalang.com/images/devalang-logo.svg" alt="Devalang Logo" width="300" />
3
3
  </div>
4
4
 
5
5
  # TODOs list
@@ -17,15 +17,16 @@ This is a list of tasks and features to be implemented in Devalang. Note that th
17
17
  - [x] Implement template info
18
18
  - [x] Checking
19
19
  - [x] Implement watch mode
20
- - [ ] Implement debug mode
20
+ - [x] Implement debug mode
21
21
  - [ ] Implement compilation mode
22
22
  - [x] Building
23
23
  - [x] Implement watch mode
24
- - [ ] Implement debug mode
24
+ - [x] Implement debug mode
25
25
  - [ ] Implement compilation mode
26
- - [ ] Implement compression mode
26
+ - [x] Implement compression mode
27
27
  - [x] Play
28
28
  - [x] Implement Audio Engine
29
+ - [x] Implement debug mode
29
30
  - [x] Implement loop mode
30
31
 
31
32
  ## Core components
@@ -44,7 +45,7 @@ This is a list of tasks and features to be implemented in Devalang. Note that th
44
45
  - [x] @export
45
46
  - [x] @load
46
47
  - [ ] @include
47
- - [ ] function
48
+ - [x] function
48
49
  - [ ] pattern
49
50
  - [x] group
50
51
  - [x] call
@@ -1,9 +1,7 @@
1
1
  # This file demonstrates the use of banks in Devalang.
2
2
 
3
- let default_bank = 808
4
-
5
- bank default_bank
3
+ bank devaloop.808
6
4
 
7
5
  .808.kick auto
8
6
  .808.snare auto
9
- .808.hat auto
7
+ .808.openhat auto
@@ -0,0 +1,15 @@
1
+ # This file demonstrates the use of main features in Devalang.
2
+ bpm 135
3
+
4
+ bank 808
5
+
6
+ let entityTest1 = .808.kick auto
7
+ let entityTest2 = .808.clap auto
8
+ let entityTest3 = .808.snare auto
9
+
10
+ fn myFirstGroup(entity1, entity2, entity3):
11
+ .entity1
12
+ .entity2
13
+ .entity3
14
+
15
+ call myFirstGroup(entityTest1, entityTest2, entityTest3)
@@ -1,18 +1,29 @@
1
- # This file demonstrates the use of main features in Devalang.
1
+ # This example demonstrates how to create a custom synth and use it in a group with notes.
2
2
 
3
- @import { duration, default_bank, params, loopCount, tempo } from "./variables.deva"
4
- @import { myLead } from "./synth.deva"
5
- @import { myLoop } from "./loop.deva"
3
+ bpm 135
6
4
 
7
- @load "./samples/kick-808.wav" as kickCustom
8
- @load "./samples/hat-808.wav" as hatCustom
5
+ let customSynth = synth sine {
6
+ attack: 0,
7
+ decay: 100,
8
+ sustain: 50,
9
+ release: 200,
10
+ }
9
11
 
10
- # bpm tempo
12
+ group mySynthGroup:
13
+ customSynth -> note(C4, {
14
+ duration: 1000,
15
+ glide: true,
16
+ velocity: 0.8
17
+ })
18
+ customSynth -> note(E3, {
19
+ duration: 1000,
20
+ glide: true,
21
+ velocity: 0.5
22
+ })
23
+ customSynth -> note(D3, {
24
+ duration: 1000,
25
+ glide: true,
26
+ velocity: 0.6
27
+ })
11
28
 
12
- # group myTrack:
13
- # spawn myLoop
14
- # spawn myLead
15
-
16
- # call myTrack
17
-
18
- .kickCustom duration { gain: 1, pitch: 1.25 }
29
+ spawn mySynthGroup
Binary file
package/package.json CHANGED
@@ -1,21 +1,21 @@
1
1
  {
2
2
  "name": "@devaloop/devalang",
3
3
  "private": false,
4
- "version": "0.0.1-alpha.12",
4
+ "version": "0.0.1-alpha.14",
5
5
  "description": "Write music like code. Devalang is a domain-specific language (DSL) for sound designers and music hackers. Compose, automate, and control sound — in plain text.",
6
6
  "main": "out-tsc/index.js",
7
7
  "bin": {
8
8
  "devalang": "./out-tsc/bin/index.js"
9
9
  },
10
10
  "scripts": {
11
- "prepublish": "cargo build --release && npm run script:postbuild",
12
- "rust:dev:build": "cargo run build --entry examples --output output",
13
- "rust:dev:check": "cargo run check --entry examples --output output",
14
- "rust:dev:play": "cargo run play --entry examples --output output --repeat",
11
+ "rust:dev:build": "cargo run build --entry examples --output output --debug",
12
+ "rust:dev:check": "cargo run check --entry examples --output output --debug",
13
+ "rust:dev:play": "cargo run play --entry examples --output output --repeat --debug",
15
14
  "rust:wasm:web": "wasm-pack build --target=web --no-default-features",
16
15
  "rust:wasm:node": "wasm-pack build --target=nodejs --no-default-features",
17
16
  "script:postbuild": "tsc && node out-tsc/scripts/postbuild.js",
18
- "script:version:bump": "tsc && node out-tsc/scripts/version/index.js"
17
+ "script:version:bump": "tsc && node out-tsc/scripts/version/index.js",
18
+ "prepublish": "cargo build --release && npm run script:postbuild"
19
19
  },
20
20
  "homepage": "https://devalang.com",
21
21
  "keywords": [
@@ -1,6 +1,6 @@
1
1
  {
2
- "version": "0.0.1-alpha.12",
2
+ "version": "0.0.1-alpha.14",
3
3
  "channel": "alpha",
4
- "lastCommit": "e16a21167693d0265195bf4256b3f8ec0ed1e55f",
5
- "build": 11
4
+ "lastCommit": "e9243d1e7ec612d0d4d31307bcfbf28c5e912b11",
5
+ "build": 13
6
6
  }
package/rust/cli/bank.rs CHANGED
@@ -398,6 +398,7 @@ async fn list_installed_banks() -> Result<Vec<BankFile>, String> {
398
398
  return Ok(banks); // No banks installed
399
399
  }
400
400
 
401
+ // TODO: Verify installed banks in files
401
402
  // let installed_banks = std::fs
402
403
  // ::read_dir(bank_dir)
403
404
  // .map_err(|e| format!("Failed to read bank directory: {}", e))?;
@@ -416,7 +417,7 @@ async fn list_installed_banks() -> Result<Vec<BankFile>, String> {
416
417
  );
417
418
  }
418
419
 
419
- let mut config = load_config(Some(&config_path)).ok_or_else(||
420
+ let config = load_config(Some(&config_path)).ok_or_else(||
420
421
  format!("Failed to load config from '{}'", config_path.display())
421
422
  )?;
422
423
 
package/rust/cli/build.rs CHANGED
@@ -4,8 +4,9 @@ use crate::{
4
4
  builder::Builder,
5
5
  debugger::{
6
6
  lexer::write_lexer_log_file,
7
+ module::{ write_module_function_log_file, write_module_variable_log_file },
7
8
  preprocessor::write_preprocessor_log_file,
8
- store::write_store_log_file,
9
+ store::{ write_function_log_file, write_variables_log_file },
9
10
  },
10
11
  preprocessor::loader::ModuleLoader,
11
12
  store::global::GlobalStore,
@@ -20,7 +21,9 @@ pub fn handle_build_command(
20
21
  config: Option<Config>,
21
22
  entry: Option<String>,
22
23
  output: Option<String>,
23
- watch: bool
24
+ watch: bool,
25
+ debug: bool,
26
+ compress: bool
24
27
  ) {
25
28
  let fetched_entry = if entry.is_none() {
26
29
  config
@@ -76,7 +79,7 @@ pub fn handle_build_command(
76
79
 
77
80
  // SECTION Begin build
78
81
  if fetched_watch {
79
- begin_build(entry_file.clone(), fetched_output.clone());
82
+ begin_build(entry_file.clone(), fetched_output.clone(), debug, compress);
80
83
 
81
84
  logger.log_message(
82
85
  LogLevel::Watcher,
@@ -86,14 +89,14 @@ pub fn handle_build_command(
86
89
  watch_directory(entry_file.clone(), move || {
87
90
  logger.log_message(LogLevel::Watcher, "Detected changes, re-building...");
88
91
 
89
- begin_build(entry_file.clone(), fetched_output.clone());
92
+ begin_build(entry_file.clone(), fetched_output.clone(), debug, compress);
90
93
  }).unwrap();
91
94
  } else {
92
- begin_build(entry_file.clone(), fetched_output.clone());
95
+ begin_build(entry_file.clone(), fetched_output.clone(), debug, compress);
93
96
  }
94
97
  }
95
98
 
96
- fn begin_build(entry: String, output: String) {
99
+ fn begin_build(entry: String, output: String, debug: bool, compress: bool) {
97
100
  let spinner = with_spinner("Building...", || {
98
101
  thread::sleep(Duration::from_millis(800));
99
102
  });
@@ -111,27 +114,86 @@ fn begin_build(entry: String, output: String) {
111
114
  let (modules_tokens, modules_statements) = module_loader.load_all_modules(&mut global_store);
112
115
 
113
116
  // SECTION Write logs
114
- write_lexer_log_file(&normalized_output_dir, "lexer_tokens.log", modules_tokens.clone());
115
- write_preprocessor_log_file(
116
- &normalized_output_dir,
117
- "resolved_statements.log",
118
- modules_statements.clone()
119
- );
120
- write_store_log_file(&normalized_output_dir, "global_store.log", global_store.modules.clone());
117
+ if debug {
118
+ for (module_path, module) in global_store.modules.clone() {
119
+ write_module_variable_log_file(
120
+ &normalized_output_dir,
121
+ &module_path,
122
+ &module.variable_table
123
+ );
124
+ write_module_function_log_file(
125
+ &normalized_output_dir,
126
+ &module_path,
127
+ &module.function_table
128
+ );
129
+ }
130
+
131
+ write_lexer_log_file(&normalized_output_dir, "lexer_tokens.log", modules_tokens.clone());
132
+ write_preprocessor_log_file(
133
+ &normalized_output_dir,
134
+ "resolved_statements.log",
135
+ modules_statements.clone()
136
+ );
137
+ write_variables_log_file(
138
+ &normalized_output_dir,
139
+ "global_variables.log",
140
+ global_store.variables.clone()
141
+ );
142
+ write_function_log_file(
143
+ &normalized_output_dir,
144
+ "global_functions.log",
145
+ global_store.functions.clone()
146
+ );
147
+ }
121
148
 
122
149
  // SECTION Building AST and Audio
123
150
  let builder = Builder::new();
124
- builder.build_ast(&modules_statements, &normalized_output_dir);
151
+ builder.build_ast(&modules_statements, &normalized_output_dir, compress);
125
152
  builder.build_audio(&modules_statements, &normalized_output_dir, &mut global_store);
126
153
 
127
154
  // SECTION Logging
128
155
  let logger = Logger::new();
129
156
 
157
+ if debug {
158
+ let modules_loaded = global_store.modules
159
+ .iter()
160
+ .map(|(k, _)| k)
161
+ .collect::<Vec<_>>();
162
+ let global_variables_loaded = global_store.variables.variables.keys().collect::<Vec<_>>();
163
+ let global_functions_loaded = global_store.functions.functions.keys().collect::<Vec<_>>();
164
+
165
+ logger.log_message_with_trace(
166
+ LogLevel::Debug,
167
+ &format!("Modules loaded: {}", global_store.modules.len()),
168
+ modules_loaded
169
+ .iter()
170
+ .map(|s| s.as_str())
171
+ .collect()
172
+ );
173
+ logger.log_message_with_trace(
174
+ LogLevel::Debug,
175
+ &format!("Global variables: {}", global_store.variables.variables.len()),
176
+ global_variables_loaded
177
+ .iter()
178
+ .map(|s| s.as_str())
179
+ .collect()
180
+ );
181
+ logger.log_message_with_trace(
182
+ LogLevel::Debug,
183
+ &format!("Global functions: {}", global_store.functions.functions.len()),
184
+ global_functions_loaded
185
+ .iter()
186
+ .map(|s| s.as_str())
187
+ .collect()
188
+ );
189
+ }
190
+
130
191
  let success_message = format!(
131
192
  "Build completed successfully in {:.2?}. Output files written to: '{}'",
132
193
  duration.elapsed(),
133
194
  normalized_output_dir
134
195
  );
135
196
 
197
+ spinner.finish_and_clear();
136
198
  logger.log_message(LogLevel::Success, &success_message);
137
199
  }