@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.
- package/.cargo/config.toml +2 -0
- package/.devalang +6 -10
- package/.github/workflows/ci.yml +19 -8
- package/Cargo.toml +18 -2
- package/README.md +80 -33
- package/docs/CHANGELOG.md +56 -0
- package/docs/ROADMAP.md +6 -3
- package/examples/index.deva +52 -35
- package/out-tsc/bin/index.d.ts +2 -0
- package/out-tsc/core/functions/index.d.ts +37 -0
- package/out-tsc/core/functions/index.js +76 -0
- package/out-tsc/core/index.d.ts +6 -0
- package/out-tsc/core/index.js +22 -0
- package/out-tsc/core/types/index.d.ts +4 -0
- package/out-tsc/core/types/index.js +20 -0
- package/out-tsc/core/types/plugin.d.ts +18 -0
- package/out-tsc/core/types/plugin.js +2 -0
- package/out-tsc/core/types/result.d.ts +27 -0
- package/out-tsc/core/types/result.js +2 -0
- package/out-tsc/core/types/statement.d.ts +106 -0
- package/out-tsc/core/types/statement.js +2 -0
- package/out-tsc/core/types/value.d.ts +43 -0
- package/out-tsc/core/types/value.js +2 -0
- package/out-tsc/index.d.ts +7 -0
- package/out-tsc/index.js +41 -2
- package/out-tsc/pkg/devalang_core.d.ts +7 -0
- package/out-tsc/pkg/devalang_core_bg.wasm.d.ts +33 -0
- package/out-tsc/scripts/copy-wasm-dts.d.ts +1 -0
- package/out-tsc/scripts/copy-wasm-dts.js +73 -0
- package/out-tsc/scripts/postinstall.d.ts +1 -0
- package/out-tsc/scripts/postinstall.js +33 -23
- package/out-tsc/scripts/version/bump.d.ts +1 -0
- package/out-tsc/scripts/version/fetch.d.ts +1 -0
- package/out-tsc/scripts/version/index.d.ts +1 -0
- package/out-tsc/scripts/version/sync.d.ts +1 -0
- package/package.json +16 -4
- package/project-version.json +3 -3
- package/rust/cli/bank/api.rs +122 -0
- package/rust/cli/bank/commands.rs +275 -0
- package/rust/cli/bank/mod.rs +29 -0
- package/rust/cli/build/commands.rs +97 -0
- package/rust/cli/build/mod.rs +2 -0
- package/rust/cli/build/process.rs +146 -0
- package/rust/cli/{check.rs → check/mod.rs} +18 -31
- package/rust/cli/discover/commands.rs +253 -0
- package/rust/cli/discover/config.rs +111 -0
- package/rust/cli/discover/fs.rs +19 -0
- package/rust/cli/discover/install.rs +103 -0
- package/rust/cli/discover/metadata.rs +48 -0
- package/rust/cli/discover/mod.rs +5 -0
- package/rust/cli/{init.rs → init/commands.rs} +88 -87
- package/rust/cli/init/mod.rs +1 -0
- package/rust/{installer → cli/install}/addon.rs +5 -9
- package/rust/cli/install/bank.rs +53 -0
- package/rust/cli/{install.rs → install/commands.rs} +9 -9
- package/rust/{installer → cli/install}/mod.rs +2 -3
- package/rust/cli/install/plugin.rs +61 -0
- package/rust/cli/{login.rs → login/commands.rs} +8 -11
- package/rust/cli/login/mod.rs +1 -0
- package/rust/cli/mod.rs +2 -3
- package/rust/cli/{driver.rs → parser.rs} +19 -2
- package/rust/cli/play/commands.rs +324 -0
- package/rust/cli/play/io.rs +17 -0
- package/rust/cli/play/mod.rs +5 -0
- package/rust/cli/play/process.rs +150 -0
- package/rust/cli/play/realtime.rs +91 -0
- package/rust/cli/play/utils.rs +23 -0
- package/rust/cli/telemetry/commands.rs +22 -0
- package/rust/cli/telemetry/event_creator.rs +80 -0
- package/rust/cli/telemetry/mod.rs +3 -0
- package/rust/cli/telemetry/send.rs +51 -0
- package/rust/cli/{template.rs → template/commands.rs} +1 -1
- package/rust/cli/template/mod.rs +1 -0
- package/rust/cli/{update.rs → update/commands.rs} +6 -6
- package/rust/cli/update/mod.rs +1 -0
- package/rust/config/driver.rs +57 -72
- package/rust/config/mod.rs +1 -2
- package/rust/config/ops.rs +26 -0
- package/rust/config/settings.rs +60 -50
- package/rust/core/audio/engine/helpers.rs +146 -0
- package/rust/core/audio/engine/mod.rs +7 -0
- package/rust/core/audio/engine/sample.rs +298 -0
- package/rust/core/audio/engine/synth.rs +310 -0
- package/rust/core/audio/evaluator.rs +15 -12
- package/rust/core/audio/interpreter/arrow_call.rs +99 -24
- package/rust/core/audio/interpreter/call.rs +81 -60
- package/rust/core/audio/interpreter/condition.rs +3 -2
- package/rust/core/audio/interpreter/driver.rs +206 -151
- package/rust/core/audio/interpreter/let_.rs +1 -1
- package/rust/core/audio/interpreter/load.rs +2 -1
- package/rust/core/audio/interpreter/loop_.rs +7 -6
- package/rust/core/audio/interpreter/sleep.rs +2 -1
- package/rust/core/audio/interpreter/spawn.rs +45 -57
- package/rust/core/audio/interpreter/tempo.rs +31 -10
- package/rust/core/audio/interpreter/trigger.rs +2 -2
- package/rust/core/audio/loader/trigger.rs +4 -7
- package/rust/core/audio/player.rs +6 -0
- package/rust/core/audio/renderer.rs +5 -7
- package/rust/core/audio/special/env.rs +3 -1
- package/rust/core/audio/special/math.rs +4 -4
- package/rust/core/audio/special/modulator.rs +2 -2
- package/rust/core/builder/mod.rs +9 -3
- package/rust/core/debugger/lexer.rs +1 -1
- package/rust/core/debugger/mod.rs +6 -0
- package/rust/core/debugger/module.rs +4 -4
- package/rust/core/debugger/preprocessor.rs +1 -1
- package/rust/core/debugger/store.rs +2 -2
- package/rust/core/error/mod.rs +189 -0
- package/rust/core/lexer/handler/arrow.rs +1 -1
- package/rust/core/lexer/handler/at.rs +1 -1
- package/rust/core/lexer/handler/brace.rs +2 -2
- package/rust/core/lexer/handler/colon.rs +1 -1
- package/rust/core/lexer/handler/comment.rs +1 -1
- package/rust/core/lexer/handler/dot.rs +1 -1
- package/rust/core/lexer/handler/driver.rs +1 -1
- package/rust/core/lexer/handler/identifier.rs +1 -1
- package/rust/core/lexer/handler/mod.rs +1 -2
- package/rust/core/lexer/handler/number.rs +1 -1
- package/rust/core/lexer/handler/operator.rs +1 -1
- package/rust/core/lexer/handler/parenthesis.rs +2 -2
- package/rust/core/lexer/handler/slash.rs +1 -1
- package/rust/core/lexer/handler/string.rs +1 -1
- package/rust/core/lexer/mod.rs +22 -12
- package/rust/core/lexer/token.rs +90 -97
- package/rust/core/mod.rs +0 -1
- package/rust/core/parser/driver.rs +66 -13
- package/rust/core/parser/handler/arrow_call.rs +28 -8
- package/rust/core/parser/handler/at.rs +55 -21
- package/rust/core/parser/handler/bank.rs +14 -4
- package/rust/core/parser/handler/condition.rs +6 -3
- package/rust/core/parser/handler/dot.rs +2 -1
- package/rust/core/parser/handler/identifier/automate.rs +13 -16
- package/rust/core/parser/handler/identifier/call.rs +4 -4
- package/rust/core/parser/handler/identifier/emit.rs +9 -5
- package/rust/core/parser/handler/identifier/function.rs +20 -7
- package/rust/core/parser/handler/identifier/group.rs +11 -7
- package/rust/core/parser/handler/identifier/let_.rs +24 -9
- package/rust/core/parser/handler/identifier/mod.rs +6 -5
- package/rust/core/parser/handler/identifier/on.rs +16 -7
- package/rust/core/parser/handler/identifier/print.rs +6 -9
- package/rust/core/parser/handler/identifier/sleep.rs +12 -5
- package/rust/core/parser/handler/identifier/spawn.rs +4 -4
- package/rust/core/parser/handler/identifier/synth.rs +79 -9
- package/rust/core/parser/handler/loop_.rs +39 -14
- package/rust/core/parser/handler/tempo.rs +9 -5
- package/rust/core/parser/mod.rs +0 -1
- package/rust/core/parser/statement.rs +6 -137
- package/rust/core/plugin/loader.rs +41 -27
- package/rust/core/plugin/runner.rs +68 -17
- package/rust/core/preprocessor/loader.rs +155 -33
- package/rust/core/preprocessor/processor.rs +2 -2
- package/rust/core/preprocessor/resolver/bank.rs +6 -8
- package/rust/core/preprocessor/resolver/call.rs +20 -24
- package/rust/core/preprocessor/resolver/condition.rs +6 -8
- package/rust/core/preprocessor/resolver/driver.rs +14 -16
- package/rust/core/preprocessor/resolver/function.rs +6 -6
- package/rust/core/preprocessor/resolver/group.rs +6 -8
- package/rust/core/preprocessor/resolver/loop_.rs +8 -10
- package/rust/core/preprocessor/resolver/spawn.rs +19 -23
- package/rust/core/preprocessor/resolver/synth.rs +6 -8
- package/rust/core/preprocessor/resolver/tempo.rs +6 -8
- package/rust/core/preprocessor/resolver/trigger.rs +22 -19
- package/rust/core/preprocessor/resolver/value.rs +99 -4
- package/rust/core/store/export.rs +28 -28
- package/rust/core/store/function.rs +6 -0
- package/rust/core/store/global.rs +7 -1
- package/rust/core/store/import.rs +28 -28
- package/rust/core/store/variable.rs +1 -1
- package/rust/core/utils/mod.rs +0 -1
- package/rust/lib.rs +102 -9
- package/rust/main.rs +156 -45
- package/rust/types/Cargo.toml +8 -0
- package/rust/types/src/addons.rs +55 -0
- package/rust/types/src/ast.rs +198 -0
- package/rust/types/src/config.rs +74 -0
- package/rust/types/src/lib.rs +12 -0
- package/rust/types/src/telemetry.rs +85 -0
- package/rust/utils/Cargo.toml +23 -0
- package/rust/utils/{error.rs → src/error.rs} +186 -200
- package/rust/utils/src/file.rs +94 -0
- package/rust/utils/src/first_usage.rs +97 -0
- package/rust/utils/{mod.rs → src/lib.rs} +1 -1
- package/rust/utils/{logger.rs → src/logger.rs} +17 -12
- package/rust/utils/src/path.rs +88 -0
- package/rust/utils/src/signature.rs +41 -0
- package/rust/utils/{spinner.rs → src/spinner.rs} +3 -5
- package/rust/utils/src/version.rs +27 -0
- package/rust/utils/{watcher.rs → src/watcher.rs} +13 -1
- package/rust/web/api.rs +5 -0
- package/rust/web/cdn.rs +34 -0
- package/templates/minimal/README.md +98 -54
- package/templates/welcome/README.md +98 -54
- package/templates/welcome/src/index.deva +56 -8
- package/templates/welcome/src/variables.deva +2 -4
- package/tests/rust/TODO.md +0 -0
- package/tests/typescript/index.spec.ts +136 -0
- package/tests/typescript/playhead.spec.ts +36 -0
- package/tests/typescript/render_e2e.spec.ts +77 -0
- package/tsconfig.json +1 -1
- package/typescript/core/functions/index.ts +83 -0
- package/typescript/core/index.ts +6 -0
- package/typescript/core/types/index.ts +4 -0
- package/typescript/core/types/plugin.ts +19 -0
- package/typescript/core/types/result.ts +29 -0
- package/typescript/core/types/statement.ts +47 -0
- package/typescript/core/types/value.ts +29 -0
- package/typescript/index.ts +7 -2
- package/typescript/pkg/devalang_core.d.ts +4 -0
- package/typescript/scripts/copy-wasm-dts.ts +41 -0
- package/typescript/scripts/postinstall.ts +45 -32
- package/rust/cli/bank.rs +0 -462
- package/rust/cli/build.rs +0 -252
- package/rust/cli/generator.rs +0 -1
- package/rust/cli/play.rs +0 -1123
- package/rust/cli/telemetry.rs +0 -19
- package/rust/common/api.rs +0 -5
- package/rust/common/cdn.rs +0 -5
- package/rust/config/loader.rs +0 -165
- package/rust/config/stats.rs +0 -257
- package/rust/core/audio/engine.rs +0 -696
- package/rust/core/shared/bank.rs +0 -21
- package/rust/core/shared/duration.rs +0 -9
- package/rust/core/shared/mod.rs +0 -3
- package/rust/core/shared/value.rs +0 -35
- package/rust/core/utils/validation.rs +0 -35
- package/rust/installer/bank.rs +0 -62
- package/rust/installer/plugin.rs +0 -54
- package/rust/installer/utils.rs +0 -56
- package/rust/utils/file.rs +0 -38
- package/rust/utils/first_usage.rs +0 -76
- package/rust/utils/signature.rs +0 -19
- package/rust/utils/telemetry.rs +0 -292
- package/rust/utils/version.rs +0 -15
- /package/rust/{common → web}/mod.rs +0 -0
- /package/rust/{common → web}/sso.rs +0 -0
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
#[cfg(feature = "cli")]
|
|
2
2
|
use crossterm::style::{Attribute, Color, ResetColor, SetAttribute, SetForegroundColor};
|
|
3
|
+
#[cfg(feature = "cli")]
|
|
3
4
|
use std::fmt::Write;
|
|
4
5
|
|
|
5
6
|
#[derive(Debug, Clone, PartialEq)]
|
|
@@ -21,7 +22,15 @@ impl Logger {
|
|
|
21
22
|
Logger
|
|
22
23
|
}
|
|
23
24
|
|
|
24
|
-
//
|
|
25
|
+
// Some methods are only used in CLI builds; silence dead_code warnings for non-cli.
|
|
26
|
+
#[cfg(not(feature = "cli"))]
|
|
27
|
+
#[allow(dead_code)]
|
|
28
|
+
fn __wasm_only_allow_dead_code(&self) {}
|
|
29
|
+
|
|
30
|
+
// Additionally allow dead_code for the CLI-only formatting helpers when building without cli
|
|
31
|
+
#[cfg(not(feature = "cli"))]
|
|
32
|
+
#[allow(dead_code)]
|
|
33
|
+
fn __wasm_only_format_helpers(&self) {}
|
|
25
34
|
|
|
26
35
|
#[cfg(feature = "cli")]
|
|
27
36
|
pub fn log_message(&self, level: LogLevel, message: &str) {
|
|
@@ -39,8 +48,6 @@ impl Logger {
|
|
|
39
48
|
// no-op for WASM
|
|
40
49
|
}
|
|
41
50
|
|
|
42
|
-
// --- log_message_with_trace ---
|
|
43
|
-
|
|
44
51
|
#[cfg(feature = "cli")]
|
|
45
52
|
pub fn log_message_with_trace(&self, level: LogLevel, message: &str, trace: Vec<&str>) {
|
|
46
53
|
let formatted_status = self.format_status(level);
|
|
@@ -60,8 +67,6 @@ impl Logger {
|
|
|
60
67
|
// no-op for WASM
|
|
61
68
|
}
|
|
62
69
|
|
|
63
|
-
// --- log_error_with_stacktrace ---
|
|
64
|
-
|
|
65
70
|
#[cfg(feature = "cli")]
|
|
66
71
|
pub fn log_error_with_stacktrace(&self, message: &str, stacktrace: &str) {
|
|
67
72
|
let formatted_status = self.format_status(LogLevel::Error);
|
|
@@ -79,9 +84,9 @@ impl Logger {
|
|
|
79
84
|
// no-op for WASM
|
|
80
85
|
}
|
|
81
86
|
|
|
82
|
-
// --- language_signature ---
|
|
83
|
-
|
|
84
87
|
#[cfg(feature = "cli")]
|
|
88
|
+
#[allow(dead_code)]
|
|
89
|
+
#[cfg_attr(not(feature = "cli"), allow(dead_code))]
|
|
85
90
|
fn language_signature(&self) -> String {
|
|
86
91
|
let mut s = String::new();
|
|
87
92
|
|
|
@@ -94,7 +99,7 @@ impl Logger {
|
|
|
94
99
|
SetForegroundColor(Color::Rgb {
|
|
95
100
|
r: 29,
|
|
96
101
|
g: 211,
|
|
97
|
-
b: 176
|
|
102
|
+
b: 176,
|
|
98
103
|
})
|
|
99
104
|
)
|
|
100
105
|
.unwrap();
|
|
@@ -110,12 +115,11 @@ impl Logger {
|
|
|
110
115
|
}
|
|
111
116
|
|
|
112
117
|
#[cfg(not(feature = "cli"))]
|
|
118
|
+
#[allow(dead_code)]
|
|
113
119
|
fn language_signature(&self) -> String {
|
|
114
120
|
"[Devalang]".to_string()
|
|
115
121
|
}
|
|
116
122
|
|
|
117
|
-
// --- format_status ---
|
|
118
|
-
|
|
119
123
|
#[cfg(feature = "cli")]
|
|
120
124
|
fn format_status(&self, level: LogLevel) -> String {
|
|
121
125
|
let mut s = String::new();
|
|
@@ -180,8 +184,9 @@ impl Logger {
|
|
|
180
184
|
}
|
|
181
185
|
|
|
182
186
|
#[cfg(not(feature = "cli"))]
|
|
187
|
+
#[allow(dead_code)]
|
|
183
188
|
fn format_status(&self, level: LogLevel) -> String {
|
|
184
|
-
match level {
|
|
189
|
+
(match level {
|
|
185
190
|
LogLevel::Success => "[SUCCESS]",
|
|
186
191
|
LogLevel::Error => "[ERROR]",
|
|
187
192
|
LogLevel::Info => "[INFO]",
|
|
@@ -189,7 +194,7 @@ impl Logger {
|
|
|
189
194
|
LogLevel::Watcher => "[WATCHER]",
|
|
190
195
|
LogLevel::Debug => "[DEBUG]",
|
|
191
196
|
LogLevel::Print => "[PRINT]",
|
|
192
|
-
}
|
|
197
|
+
})
|
|
193
198
|
.to_string()
|
|
194
199
|
}
|
|
195
200
|
}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
use std::{
|
|
2
|
+
env, fs,
|
|
3
|
+
path::{Path, PathBuf},
|
|
4
|
+
};
|
|
5
|
+
|
|
6
|
+
pub const DEVALANG_CONFIG: &str = ".devalang";
|
|
7
|
+
pub const DEVA_DIR: &str = ".deva";
|
|
8
|
+
|
|
9
|
+
/// Returns the current working directory.
|
|
10
|
+
pub fn get_cwd() -> PathBuf {
|
|
11
|
+
// In wasm (and some restricted environments) `env::current_dir()` is unsupported
|
|
12
|
+
// and will return an error. Avoid panicking here and fall back to `.` so the
|
|
13
|
+
// runtime can still operate in a virtual environment.
|
|
14
|
+
env::current_dir().unwrap_or_else(|_| PathBuf::from("."))
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
/// Returns true if the given directory looks like a devalang project root.
|
|
18
|
+
/// Preference is given to the presence of `.devalang` (config file),
|
|
19
|
+
/// but falling back to a `.deva` directory is allowed.
|
|
20
|
+
pub fn is_project_root(dir: &Path) -> bool {
|
|
21
|
+
let config = dir.join(DEVALANG_CONFIG);
|
|
22
|
+
if config.is_file() {
|
|
23
|
+
return true;
|
|
24
|
+
}
|
|
25
|
+
let deva = dir.join(DEVA_DIR);
|
|
26
|
+
deva.is_dir()
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/// Walks upward from `start` to locate the first directory considered a project root.
|
|
30
|
+
pub fn find_project_root_from(start: &Path) -> Option<PathBuf> {
|
|
31
|
+
for ancestor in start.ancestors() {
|
|
32
|
+
if is_project_root(ancestor) {
|
|
33
|
+
return Some(ancestor.to_path_buf());
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
None
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/// Finds the project root from the current working directory.
|
|
40
|
+
pub fn find_project_root() -> Option<PathBuf> {
|
|
41
|
+
find_project_root_from(&get_cwd())
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/// Finds the package root using the `CARGO_MANIFEST_DIR` env var set by Cargo.
|
|
45
|
+
pub fn get_package_root() -> Option<PathBuf> {
|
|
46
|
+
let cargo_dir = env::var("CARGO_MANIFEST_DIR").ok()?;
|
|
47
|
+
Some(PathBuf::from(cargo_dir))
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/// Gets the project root or returns a descriptive error if not found.
|
|
51
|
+
pub fn get_project_root() -> Result<PathBuf, String> {
|
|
52
|
+
find_project_root()
|
|
53
|
+
.ok_or_else(|| "Project root not found. Run 'devalang init' in your project.".to_string())
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/// Returns the path to `.devalang` in the project root, ensuring it exists.
|
|
57
|
+
pub fn get_devalang_config_path() -> Result<PathBuf, String> {
|
|
58
|
+
let root = get_project_root()?;
|
|
59
|
+
let config_path = root.join(DEVALANG_CONFIG);
|
|
60
|
+
if !config_path.exists() {
|
|
61
|
+
return Err(format!(
|
|
62
|
+
"Config file not found at '{}'. Please run 'devalang init' before continuing.",
|
|
63
|
+
config_path.display()
|
|
64
|
+
));
|
|
65
|
+
}
|
|
66
|
+
Ok(config_path)
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/// Returns the `.deva` directory inside the project root (without creating it).
|
|
70
|
+
pub fn get_deva_dir() -> Result<PathBuf, String> {
|
|
71
|
+
let root = get_project_root()?;
|
|
72
|
+
Ok(root.join(DEVA_DIR))
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
/// Ensures the `.deva` directory exists in the project root and returns its path.
|
|
76
|
+
pub fn ensure_deva_dir() -> Result<PathBuf, String> {
|
|
77
|
+
let deva = get_deva_dir()?;
|
|
78
|
+
if !deva.exists() {
|
|
79
|
+
fs::create_dir_all(&deva).map_err(|e| {
|
|
80
|
+
format!(
|
|
81
|
+
"Failed to create Deva directory '{}': {}",
|
|
82
|
+
deva.display(),
|
|
83
|
+
e
|
|
84
|
+
)
|
|
85
|
+
})?;
|
|
86
|
+
}
|
|
87
|
+
Ok(deva)
|
|
88
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
#[cfg(feature = "cli")]
|
|
2
|
+
pub fn get_signature(version: &str) -> String {
|
|
3
|
+
let signature = format!(
|
|
4
|
+
r#"
|
|
5
|
+
/|_/|
|
|
6
|
+
/ ^ ^(_o 🦊 Devalang
|
|
7
|
+
/ __.'
|
|
8
|
+
/ \ A programming language for music and sound.
|
|
9
|
+
/ _ \_ Part of the Devaloop project.
|
|
10
|
+
(_) (_) '._
|
|
11
|
+
'.__ '. .-''-'. https://devalang.com
|
|
12
|
+
( '. ('.____.''
|
|
13
|
+
_) )'_, ) v{}
|
|
14
|
+
(__/ (__/
|
|
15
|
+
"#,
|
|
16
|
+
version
|
|
17
|
+
);
|
|
18
|
+
|
|
19
|
+
signature
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
#[cfg(not(feature = "cli"))]
|
|
23
|
+
pub fn get_signature(version: &str) -> String {
|
|
24
|
+
let signature = format!(
|
|
25
|
+
r#"
|
|
26
|
+
/|_/|
|
|
27
|
+
/ ^ ^(_o 🦊 Devalang
|
|
28
|
+
/ __.'
|
|
29
|
+
/ \ A programming language for music and sound.
|
|
30
|
+
/ _ \_ Part of the Devaloop project.
|
|
31
|
+
(_) (_) '._
|
|
32
|
+
'.__ '. .-''-'. https://devalang.com
|
|
33
|
+
( '. ('.____.''
|
|
34
|
+
_) )'_, ) v{}
|
|
35
|
+
(__/ (__/
|
|
36
|
+
"#,
|
|
37
|
+
version
|
|
38
|
+
);
|
|
39
|
+
|
|
40
|
+
signature
|
|
41
|
+
}
|
|
@@ -1,12 +1,10 @@
|
|
|
1
1
|
#[cfg(feature = "cli")]
|
|
2
2
|
use indicatif::{ProgressBar, ProgressStyle};
|
|
3
|
+
#[cfg(feature = "cli")]
|
|
3
4
|
use std::time::Duration;
|
|
4
5
|
|
|
5
6
|
#[cfg(feature = "cli")]
|
|
6
|
-
pub fn
|
|
7
|
-
where
|
|
8
|
-
F: FnOnce() -> T,
|
|
9
|
-
{
|
|
7
|
+
pub fn start_spinner(start_msg: &str) -> ProgressBar {
|
|
10
8
|
let spinner = ProgressBar::new_spinner();
|
|
11
9
|
spinner.set_style(
|
|
12
10
|
ProgressStyle::with_template("{spinner:.green} {msg}")
|
|
@@ -16,7 +14,7 @@ where
|
|
|
16
14
|
spinner.set_message(start_msg.to_string());
|
|
17
15
|
spinner.enable_steady_tick(Duration::from_millis(80));
|
|
18
16
|
|
|
19
|
-
|
|
17
|
+
std::thread::sleep(Duration::from_millis(750));
|
|
20
18
|
|
|
21
19
|
spinner
|
|
22
20
|
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
use crate::{path::get_package_root, signature::get_signature};
|
|
2
|
+
|
|
3
|
+
pub fn get_version() -> String {
|
|
4
|
+
if let Some(root) = get_package_root() {
|
|
5
|
+
let project_version_json = root.join("project-version.json");
|
|
6
|
+
if let Ok(version) = std::fs::read_to_string(project_version_json) {
|
|
7
|
+
if let Ok(parsed) = serde_json::from_str::<serde_json::Value>(&version) {
|
|
8
|
+
if let Some(version_val) = parsed.get("version") {
|
|
9
|
+
if let Some(s) = version_val.as_str() {
|
|
10
|
+
return s.to_string();
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
"0.0.0".to_string()
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
pub fn get_version_with_signature() -> String {
|
|
21
|
+
let version = get_version();
|
|
22
|
+
let signature = get_signature(&version);
|
|
23
|
+
|
|
24
|
+
println!("{}", signature);
|
|
25
|
+
|
|
26
|
+
"(c) 2025 Devaloop. All rights reserved.".to_string()
|
|
27
|
+
}
|
|
@@ -24,7 +24,19 @@ where
|
|
|
24
24
|
}
|
|
25
25
|
}
|
|
26
26
|
Err(e) => {
|
|
27
|
-
|
|
27
|
+
// Prefer structured logging when available
|
|
28
|
+
#[cfg(feature = "cli")]
|
|
29
|
+
{
|
|
30
|
+
let logger = crate::logger::Logger::new();
|
|
31
|
+
logger.log_message(
|
|
32
|
+
crate::logger::LogLevel::Error,
|
|
33
|
+
&format!("Channel error: {:?}", e),
|
|
34
|
+
);
|
|
35
|
+
}
|
|
36
|
+
#[cfg(not(feature = "cli"))]
|
|
37
|
+
{
|
|
38
|
+
eprintln!("Channel error: {:?}", e);
|
|
39
|
+
}
|
|
28
40
|
break;
|
|
29
41
|
}
|
|
30
42
|
}
|
package/rust/web/api.rs
ADDED
package/rust/web/cdn.rs
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
use std::error::Error;
|
|
2
|
+
use std::fs::File;
|
|
3
|
+
use std::io::{Cursor, copy};
|
|
4
|
+
use std::path::Path;
|
|
5
|
+
|
|
6
|
+
pub fn get_cdn_url() -> String {
|
|
7
|
+
let cdn_url = "https://cdn.devalang.com";
|
|
8
|
+
// let cdn_url = "http://127.0.0.1:8888";
|
|
9
|
+
cdn_url.to_string()
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
pub async fn download_from_cdn(url: &str, destination: &Path) -> Result<(), Box<dyn Error>> {
|
|
13
|
+
if !url.starts_with(&get_cdn_url()) {
|
|
14
|
+
return Err(format!("Invalid CDN URL: {}", url).into());
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
let response = reqwest::get(url).await?;
|
|
18
|
+
|
|
19
|
+
if !response.status().is_success() {
|
|
20
|
+
return Err(format!("Failed to download file: HTTP {}", response.status()).into());
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
if let Some(parent) = destination.parent() {
|
|
24
|
+
std::fs::create_dir_all(parent)?;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
let bytes = response.bytes().await?;
|
|
28
|
+
let mut content = Cursor::new(bytes);
|
|
29
|
+
let mut file = File::create(destination)?;
|
|
30
|
+
|
|
31
|
+
copy(&mut content, &mut file)?;
|
|
32
|
+
|
|
33
|
+
Ok(())
|
|
34
|
+
}
|
|
@@ -9,12 +9,15 @@
|
|
|
9
9
|

|
|
10
10
|

|
|
11
11
|

|
|
12
|
-
|
|
12
|
+
|
|
13
|
+

|
|
14
|
+

|
|
15
|
+

|
|
13
16
|
|
|
14
17
|

|
|
15
18
|

|
|
16
19
|
|
|
17
|
-
|
|
20
|
+

|
|
18
21
|
|
|
19
22
|
# 🦊 Devalang (CORE) — Compose music with code
|
|
20
23
|
|
|
@@ -25,12 +28,13 @@ Whether you're building a track, shaping textures, or performing live, Devalang
|
|
|
25
28
|
|
|
26
29
|
From studio sketches to live sets, Devalang gives you rhythmic control — with the elegance of code.
|
|
27
30
|
|
|
28
|
-
>
|
|
31
|
+
> **🚧 Notice 🚧**
|
|
32
|
+
>
|
|
33
|
+
> Includes synthesis, playback, and rendering features, but is still in early development, and breaking changes may occur.
|
|
29
34
|
>
|
|
30
|
-
>
|
|
35
|
+
> **NEW**: [Devaforge is now available for creating addons](https://github.com/devaloop-labs/devaforge).
|
|
31
36
|
>
|
|
32
|
-
>
|
|
33
|
-
> Linux and macOS binaries will be added in future releases via cross-platform builds.
|
|
37
|
+
> **NEW**: Now available for Windows, Linux, and macOS.
|
|
34
38
|
|
|
35
39
|
## 📚 Quick Access
|
|
36
40
|
|
|
@@ -41,81 +45,113 @@ From studio sketches to live sets, Devalang gives you rhythmic control — with
|
|
|
41
45
|
- [📜 Changelog](./docs/CHANGELOG.md)
|
|
42
46
|
- [💡 Examples](./examples/)
|
|
43
47
|
- [🌐 Project Website](https://devalang.com)
|
|
44
|
-
- [📦
|
|
48
|
+
- [📦 Devaforge on npm](https://www.npmjs.com/package/@devaloop/devaforge)
|
|
49
|
+
- [📦 Devalang on npm](https://www.npmjs.com/package/@devaloop/devalang)
|
|
45
50
|
|
|
46
51
|
## ⏱️ Try it now !
|
|
47
52
|
|
|
48
53
|
### Try Devalang in your browser
|
|
49
54
|
|
|
50
|
-
> Have a look at the
|
|
55
|
+
> [Have a look at the Playground to try Devalang directly in your browser](https://playground.devalang.com)
|
|
51
56
|
|
|
52
|
-
### Try Devalang
|
|
57
|
+
### Try Devalang in your terminal
|
|
58
|
+
|
|
59
|
+
#### With Node.js
|
|
53
60
|
|
|
54
61
|
```bash
|
|
55
|
-
|
|
56
|
-
|
|
62
|
+
npm install -g @devaloop/devalang@latest
|
|
63
|
+
```
|
|
57
64
|
|
|
58
|
-
|
|
65
|
+
#### With Rust
|
|
66
|
+
|
|
67
|
+
```bash
|
|
68
|
+
cargo install devalang
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
#### Initialize a new project (current directory)
|
|
72
|
+
|
|
73
|
+
```bash
|
|
59
74
|
devalang init --name my-project --template minimal
|
|
60
|
-
cd my-project
|
|
61
75
|
```
|
|
62
76
|
|
|
77
|
+
#### Write your first script
|
|
78
|
+
|
|
63
79
|
Create a new Devalang file `src/index.deva` in the project directory:
|
|
64
80
|
|
|
65
81
|
```deva
|
|
66
82
|
# src/index.deva
|
|
67
83
|
|
|
68
|
-
|
|
69
|
-
|
|
84
|
+
# BPM definition
|
|
85
|
+
bpm 125
|
|
86
|
+
|
|
87
|
+
# Bank picking (make sure you installed it)
|
|
88
|
+
bank devaloop.808 as my808Bank
|
|
89
|
+
|
|
90
|
+
group myGroup:
|
|
91
|
+
# Rhythmic (each beat playing a kick)
|
|
92
|
+
on beat:
|
|
93
|
+
.my808Bank.kick 1/4
|
|
94
|
+
|
|
95
|
+
# Synth definition with ADSR
|
|
96
|
+
let myLead = synth sine {
|
|
70
97
|
attack: 0,
|
|
71
98
|
decay: 100,
|
|
72
99
|
sustain: 100,
|
|
73
100
|
release: 100
|
|
74
101
|
}
|
|
75
102
|
|
|
76
|
-
# Global automation
|
|
77
|
-
automate
|
|
103
|
+
# Global automation
|
|
104
|
+
automate myLead:
|
|
78
105
|
param volume {
|
|
79
106
|
0% = 0.0
|
|
80
|
-
100% =
|
|
81
|
-
}
|
|
82
|
-
param pan {
|
|
83
|
-
0% = -1.0
|
|
84
|
-
100% = 1.0
|
|
107
|
+
100% = 0.5
|
|
85
108
|
}
|
|
86
109
|
param pitch {
|
|
87
110
|
0% = -12.0
|
|
88
111
|
100% = 12.0
|
|
89
112
|
}
|
|
90
113
|
|
|
91
|
-
|
|
114
|
+
# Notes in a loop with condition
|
|
115
|
+
for i in [1, 2, 3]:
|
|
116
|
+
if i == 3:
|
|
117
|
+
myLead -> note(C5, { duration: 200 })
|
|
118
|
+
print "Playing note C5 for " + i
|
|
119
|
+
|
|
120
|
+
# Pause runtime for 500ms
|
|
121
|
+
sleep 500
|
|
122
|
+
|
|
123
|
+
# Note with automation
|
|
124
|
+
myLead -> note(C4, {
|
|
92
125
|
duration: 400,
|
|
93
126
|
velocity: 0.8,
|
|
94
|
-
automate: {
|
|
127
|
+
automate: {
|
|
128
|
+
pan: {
|
|
129
|
+
0%: -1.0,
|
|
130
|
+
100%: 0.0
|
|
131
|
+
}
|
|
132
|
+
}
|
|
95
133
|
})
|
|
96
134
|
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
135
|
+
# Notes with params
|
|
136
|
+
myLead -> note(E4, { duration: 400 })
|
|
137
|
+
myLead -> note(G4, { duration: 600, glide: true, target_freq: 659.25 })
|
|
138
|
+
myLead -> note(B3, { duration: 400, slide: true, target_amp: 0.3 })
|
|
100
139
|
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
# Play the lead
|
|
105
|
-
|
|
106
|
-
call main
|
|
140
|
+
# Calling the group to play it
|
|
141
|
+
call myGroup
|
|
107
142
|
```
|
|
108
143
|
|
|
109
144
|
### And the best part ? You can play it directly from the command line:
|
|
110
145
|
|
|
146
|
+
#### Play the script once
|
|
147
|
+
|
|
111
148
|
```bash
|
|
112
|
-
# Play the Devalang file
|
|
113
149
|
devalang play
|
|
150
|
+
```
|
|
114
151
|
|
|
115
|
-
|
|
116
|
-
devalang play --watch
|
|
152
|
+
#### **LIVE mode** (repeat the playback + watch mode)
|
|
117
153
|
|
|
118
|
-
|
|
154
|
+
```bash
|
|
119
155
|
devalang play --repeat
|
|
120
156
|
```
|
|
121
157
|
|
|
@@ -125,40 +161,48 @@ devalang play --repeat
|
|
|
125
161
|
|
|
126
162
|
## ❓ Why Devalang ?
|
|
127
163
|
|
|
128
|
-
- 🎹 Prototype audio ideas without opening a DAW, even VSCode
|
|
164
|
+
- 🎹 Prototype audio ideas without opening a DAW, even VSCode with our Playground
|
|
129
165
|
- 💻 Integrate sound into code-based workflows
|
|
130
166
|
- 🎛️ Control audio parameters through readable syntax
|
|
131
167
|
- 🧪 Build musical logic with variables and conditions
|
|
132
168
|
- 🔄 Create complex patterns with ease
|
|
169
|
+
- 🎚️ Automate everything
|
|
133
170
|
|
|
134
171
|
## 🚀 Features
|
|
135
172
|
|
|
136
|
-
-
|
|
137
|
-
-
|
|
138
|
-
-
|
|
139
|
-
-
|
|
140
|
-
-
|
|
141
|
-
-
|
|
142
|
-
-
|
|
143
|
-
-
|
|
144
|
-
-
|
|
173
|
+
- ⚡ **Fast Build & Hot Reload** — optimized build process for quicker iteration.
|
|
174
|
+
- 🎵 **Audio Engine & Real-time runner** — low-latency playback, render-to-file, and a realtime runner used by `devalang play` for live feedback.
|
|
175
|
+
- ▶️ **Live mode (watch + repeat)** — edit and hear changes instantly with `devalang play --repeat` and watch mode.
|
|
176
|
+
- 🧩 **Language primitives** — synths, notes, ADSR, maps, arrays, loops, conditionals and functions for expressive musical logic.
|
|
177
|
+
- 🎛️ **Per-note automation & modulators** — `automate` maps, `$mod.*`, `$easing.*` and `$math.*` helpers for envelopes and LFOs.
|
|
178
|
+
- 🧩 **Module system & structured AST** — import/export variables, stable AST output for debugging and tooling.
|
|
179
|
+
- 🧰 **Plugins & Addons (WASM-ready)** — install plugins/banks, `@use` directive, and WASM plugin integration so plugins can render or process audio at runtime.
|
|
180
|
+
- 📦 **Addon manager & Devaforge** — CLI commands to discover/install banks, plugins and templates; `devaforge` helps create addons.
|
|
181
|
+
- ⚙️ **CLI tooling** — `build`, `check`, `play`, `install`, `init`, `discover`, `telemetry` and more with consistent flags (`--watch`, `--debug`, `--compress`).
|
|
182
|
+
- 📂 **Project templates & examples** — quick-start templates and many example projects in `examples/`.
|
|
183
|
+
- 🧑💻 **TypeScript API & WASM distribution** — Node-friendly package with TypeScript bindings and a WASM build for browser/Node usage.
|
|
184
|
+
- 🧰 **Editor & formatting support** — VSCode extension and Prettier plugin to edit Devalang with syntax and formatting support.
|
|
185
|
+
- 🎵 **Custom samples & banks** — drop samples into `.deva` and reference them from code; banks of sounds for fast composition.
|
|
186
|
+
- 🔄 **Looping, grouping & scheduling** — precise beat-tied scheduling primitives for complex rhythmic patterns.
|
|
145
187
|
|
|
146
188
|
## 📄 Documentation
|
|
147
189
|
|
|
148
|
-
### Please refer to the
|
|
190
|
+
### [Please refer to the online documentation](https://docs.devalang.com) for detailed information on syntax, features, and usage examples
|
|
149
191
|
|
|
150
|
-
##
|
|
192
|
+
## 📰 What's new
|
|
151
193
|
|
|
152
|
-
-
|
|
153
|
-
-
|
|
194
|
+
- **Devaforge**: Introduced a new system for creating and managing addons, including a CLI for addon generation.
|
|
195
|
+
- **Documentation updates**: Improved documentation for clarity and completeness.
|
|
196
|
+
- **Discovering addons**: Introduced a new command to detect addons.
|
|
197
|
+
- **Public TypeScript API**: Added a public TypeScript API for easier integration.
|
|
198
|
+
- **Improved error messages**: Enhanced error messages for better debugging.
|
|
199
|
+
- **Bug fixes**: Various bug fixes and stability improvements.
|
|
154
200
|
|
|
155
201
|
## 🧪 Roadmap Highlights
|
|
156
202
|
|
|
157
203
|
For more info, see [docs/ROADMAP.md](./docs/ROADMAP.md)
|
|
158
204
|
|
|
159
|
-
- ⏳
|
|
160
|
-
- ⏳ Cross-platform support (Linux, macOS)
|
|
161
|
-
- ⏳ More built-in instruments (e.g. snare, hi-hat, etc.)
|
|
205
|
+
- ⏳ Smart modules
|
|
162
206
|
|
|
163
207
|
## 🛡️ License
|
|
164
208
|
|