@devaloop/devalang 0.0.1-alpha.9 → 0.0.1-beta.1
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 +10 -4
- package/.github/workflows/ci.yml +103 -0
- package/Cargo.toml +80 -48
- package/README.md +135 -154
- package/docs/CHANGELOG.md +386 -1
- package/docs/CONTRIBUTING.md +101 -0
- package/docs/ROADMAP.md +10 -7
- package/docs/TODO.md +21 -9
- package/examples/automation.deva +42 -0
- package/examples/bank.deva +7 -0
- package/examples/duration.deva +9 -0
- package/examples/events.deva +12 -0
- package/examples/function.deva +15 -0
- package/examples/index.deva +57 -12
- package/examples/loop.deva +5 -12
- package/examples/pattern.deva +8 -0
- package/examples/plugin.deva +16 -0
- package/examples/variables.deva +1 -1
- package/out-tsc/bin/index.d.ts +2 -0
- package/out-tsc/bin/index.js +51 -7
- 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 +42 -1
- package/out-tsc/pkg/devalang_core.d.ts +13 -0
- package/out-tsc/pkg/devalang_core.js +50 -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 +83 -0
- 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 +28 -7
- package/project-version.json +4 -4
- 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 +103 -0
- package/rust/cli/build/mod.rs +2 -0
- package/rust/cli/build/process.rs +146 -0
- package/rust/cli/check/mod.rs +208 -0
- 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} +32 -23
- package/rust/cli/init/mod.rs +1 -0
- package/rust/cli/install/addon.rs +118 -0
- package/rust/cli/install/bank.rs +53 -0
- package/rust/cli/install/commands.rs +35 -0
- package/rust/cli/install/mod.rs +4 -0
- package/rust/cli/install/plugin.rs +61 -0
- package/rust/cli/login/commands.rs +124 -0
- package/rust/cli/login/mod.rs +1 -0
- package/rust/cli/mod.rs +12 -205
- package/rust/cli/parser.rs +314 -0
- 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} +69 -57
- package/rust/cli/template/mod.rs +1 -0
- package/rust/cli/update/commands.rs +6 -0
- package/rust/cli/update/mod.rs +1 -0
- package/rust/config/driver.rs +103 -0
- package/rust/config/mod.rs +3 -16
- package/rust/config/ops.rs +26 -0
- package/rust/config/settings.rs +101 -0
- package/rust/core/audio/engine/helpers.rs +170 -0
- package/rust/core/audio/engine/mod.rs +7 -0
- package/rust/core/audio/engine/sample.rs +366 -0
- package/rust/core/audio/engine/synth.rs +325 -0
- package/rust/core/audio/evaluator.rs +310 -31
- package/rust/core/audio/interpreter/arrow_call.rs +311 -129
- package/rust/core/audio/interpreter/automate.rs +18 -0
- package/rust/core/audio/interpreter/call.rs +294 -64
- package/rust/core/audio/interpreter/condition.rs +71 -69
- package/rust/core/audio/interpreter/driver.rs +542 -216
- package/rust/core/audio/interpreter/function.rs +26 -0
- package/rust/core/audio/interpreter/let_.rs +38 -19
- package/rust/core/audio/interpreter/load.rs +19 -18
- package/rust/core/audio/interpreter/loop_.rs +114 -67
- package/rust/core/audio/interpreter/mod.rs +14 -12
- package/rust/core/audio/interpreter/sleep.rs +28 -36
- package/rust/core/audio/interpreter/spawn.rs +252 -66
- package/rust/core/audio/interpreter/tempo.rs +40 -16
- package/rust/core/audio/interpreter/trigger.rs +239 -69
- package/rust/core/audio/loader/mod.rs +1 -1
- package/rust/core/audio/loader/trigger.rs +97 -52
- package/rust/core/audio/mod.rs +7 -6
- package/rust/core/audio/player.rs +70 -54
- package/rust/core/audio/renderer.rs +54 -54
- package/rust/core/audio/special/easing.rs +189 -0
- package/rust/core/audio/special/env.rs +45 -0
- package/rust/core/audio/special/math.rs +134 -0
- package/rust/core/audio/special/mod.rs +9 -0
- package/rust/core/audio/special/modulator.rs +143 -0
- package/rust/core/builder/mod.rs +86 -80
- package/rust/core/debugger/lexer.rs +27 -27
- package/rust/core/debugger/mod.rs +30 -21
- package/rust/core/debugger/module.rs +55 -0
- package/rust/core/debugger/preprocessor.rs +27 -27
- package/rust/core/debugger/store.rs +40 -25
- package/rust/core/error/mod.rs +269 -60
- package/rust/core/lexer/driver.rs +61 -0
- package/rust/core/lexer/handler/arrow.rs +82 -31
- package/rust/core/lexer/handler/at.rs +21 -21
- package/rust/core/lexer/handler/brace.rs +41 -41
- package/rust/core/lexer/handler/colon.rs +21 -21
- package/rust/core/lexer/handler/comment.rs +30 -30
- package/rust/core/lexer/handler/dot.rs +21 -21
- package/rust/core/lexer/handler/driver.rs +337 -226
- package/rust/core/lexer/handler/identifier.rs +47 -41
- package/rust/core/lexer/handler/indent.rs +66 -52
- package/rust/core/lexer/handler/mod.rs +15 -14
- package/rust/core/lexer/handler/newline.rs +23 -23
- package/rust/core/lexer/handler/number.rs +31 -31
- package/rust/core/lexer/handler/operator.rs +46 -44
- package/rust/core/lexer/handler/parenthesis.rs +41 -0
- package/rust/core/lexer/handler/slash.rs +21 -0
- package/rust/core/lexer/handler/string.rs +63 -63
- package/rust/core/lexer/mod.rs +3 -51
- package/rust/core/lexer/token.rs +17 -12
- package/rust/core/mod.rs +10 -10
- package/rust/core/parser/driver.rs +584 -331
- package/rust/core/parser/handler/arrow_call.rs +253 -126
- package/rust/core/parser/handler/at.rs +279 -162
- package/rust/core/parser/handler/bank.rs +104 -41
- package/rust/core/parser/handler/condition.rs +83 -74
- package/rust/core/parser/handler/dot.rs +148 -112
- package/rust/core/parser/handler/identifier/automate.rs +254 -0
- package/rust/core/parser/handler/identifier/call.rs +91 -41
- package/rust/core/parser/handler/identifier/emit.rs +70 -0
- package/rust/core/parser/handler/identifier/function.rs +113 -0
- package/rust/core/parser/handler/identifier/group.rs +89 -75
- package/rust/core/parser/handler/identifier/let_.rs +173 -133
- package/rust/core/parser/handler/identifier/mod.rs +55 -51
- package/rust/core/parser/handler/identifier/on.rs +107 -0
- package/rust/core/parser/handler/identifier/print.rs +49 -0
- package/rust/core/parser/handler/identifier/sleep.rs +43 -33
- package/rust/core/parser/handler/identifier/spawn.rs +91 -41
- package/rust/core/parser/handler/identifier/synth.rs +135 -65
- package/rust/core/parser/handler/loop_.rs +194 -72
- package/rust/core/parser/handler/mod.rs +9 -8
- package/rust/core/parser/handler/pattern.rs +74 -0
- package/rust/core/parser/handler/tempo.rs +57 -47
- package/rust/core/parser/mod.rs +3 -4
- package/rust/core/parser/statement.rs +11 -96
- package/rust/core/plugin/loader.rs +137 -0
- package/rust/core/plugin/mod.rs +2 -0
- package/rust/core/plugin/runner.rs +347 -0
- package/rust/core/preprocessor/loader.rs +637 -193
- package/rust/core/preprocessor/mod.rs +4 -4
- package/rust/core/preprocessor/module.rs +60 -50
- package/rust/core/preprocessor/processor.rs +114 -76
- package/rust/core/preprocessor/resolver/bank.rs +49 -47
- package/rust/core/preprocessor/resolver/call.rs +124 -123
- package/rust/core/preprocessor/resolver/condition.rs +95 -92
- package/rust/core/preprocessor/resolver/driver.rs +324 -227
- package/rust/core/preprocessor/resolver/function.rs +69 -0
- package/rust/core/preprocessor/resolver/group.rs +94 -61
- package/rust/core/preprocessor/resolver/let_.rs +32 -31
- package/rust/core/preprocessor/resolver/loop_.rs +318 -91
- package/rust/core/preprocessor/resolver/mod.rs +16 -14
- package/rust/core/preprocessor/resolver/pattern.rs +83 -0
- package/rust/core/preprocessor/resolver/spawn.rs +99 -58
- package/rust/core/preprocessor/resolver/synth.rs +54 -50
- package/rust/core/preprocessor/resolver/tempo.rs +48 -49
- package/rust/core/preprocessor/resolver/trigger.rs +116 -112
- package/rust/core/preprocessor/resolver/value.rs +176 -78
- package/rust/core/store/export.rs +28 -28
- package/rust/core/store/function.rs +40 -0
- package/rust/core/store/global.rs +61 -39
- package/rust/core/store/import.rs +28 -28
- package/rust/core/store/mod.rs +5 -4
- package/rust/core/store/variable.rs +51 -28
- package/rust/core/utils/mod.rs +1 -2
- package/rust/core/utils/path.rs +37 -31
- package/rust/lib.rs +308 -117
- package/rust/main.rs +364 -65
- package/rust/types/Cargo.toml +11 -0
- package/rust/types/src/addons.rs +55 -0
- package/rust/types/src/ast.rs +202 -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 +26 -0
- package/rust/utils/src/error.rs +186 -0
- 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} +9 -6
- package/rust/utils/{logger.rs → src/logger.rs} +200 -123
- package/rust/utils/src/path.rs +88 -0
- package/rust/utils/src/signature.rs +41 -0
- package/rust/utils/{spinner.rs → src/spinner.rs} +20 -21
- package/rust/utils/src/version.rs +27 -0
- package/rust/utils/{watcher.rs → src/watcher.rs} +46 -33
- package/rust/web/api.rs +5 -0
- package/rust/web/cdn.rs +34 -0
- package/rust/web/mod.rs +3 -0
- package/rust/web/sso.rs +5 -0
- package/templates/minimal/README.md +143 -127
- package/templates/welcome/README.md +143 -127
- package/templates/welcome/src/index.deva +56 -8
- package/templates/welcome/src/variables.deva +2 -4
- package/tests/integration.rs +21 -0
- package/tests/rust/cli_check_build.rs +21 -0
- package/tests/rust/cli_help.rs +12 -0
- package/tests/rust/cli_template_list.rs +10 -0
- package/tests/rust/cli_version.rs +11 -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 +12 -10
- package/typescript/bin/index.ts +19 -5
- 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 +8 -1
- package/typescript/pkg/devalang_core.d.ts +4 -0
- package/typescript/pkg/devalang_core.ts +49 -0
- package/typescript/scripts/copy-wasm-dts.ts +41 -0
- package/typescript/scripts/postinstall.ts +85 -0
- package/typescript/scripts/version/bump.ts +0 -1
- package/typescript/scripts/version/index.ts +0 -1
- package/docs/COMMANDS.md +0 -85
- package/docs/CONFIG.md +0 -30
- package/docs/SYNTAX.md +0 -210
- package/out-tsc/bin/devalang.exe +0 -0
- package/out-tsc/scripts/postbuild.js +0 -11
- package/rust/cli/build.rs +0 -137
- package/rust/cli/check.rs +0 -117
- package/rust/cli/play.rs +0 -193
- package/rust/config/loader.rs +0 -13
- package/rust/core/audio/engine.rs +0 -203
- package/rust/core/shared/duration.rs +0 -8
- package/rust/core/shared/mod.rs +0 -2
- package/rust/core/shared/value.rs +0 -18
- package/rust/core/utils/validation.rs +0 -37
- package/rust/utils/file.rs +0 -35
- package/rust/utils/signature.rs +0 -17
- package/rust/utils/version.rs +0 -15
- package/typescript/scripts/postbuild.ts +0 -8
package/docs/COMMANDS.md
DELETED
|
@@ -1,85 +0,0 @@
|
|
|
1
|
-
<div align="center">
|
|
2
|
-
<img src="https://firebasestorage.googleapis.com/v0/b/devaloop-labs.firebasestorage.app/o/devalang-teal-logo.svg?alt=media&token=d2a5705a-1eba-4b49-88e6-895a761fb7f7" alt="Devalang Logo">
|
|
3
|
-
</div>
|
|
4
|
-
|
|
5
|
-
# Devalang Commands Guide
|
|
6
|
-
|
|
7
|
-
## Initialization
|
|
8
|
-
|
|
9
|
-
Initialize a new Devalang project (current folder)
|
|
10
|
-
|
|
11
|
-
```bash
|
|
12
|
-
devalang init
|
|
13
|
-
```
|
|
14
|
-
|
|
15
|
-
Initialize a new Devalang project (new folder)
|
|
16
|
-
|
|
17
|
-
```bash
|
|
18
|
-
devalang init --name <project-name> --template <template-name>
|
|
19
|
-
```
|
|
20
|
-
|
|
21
|
-
Available arguments:
|
|
22
|
-
|
|
23
|
-
- `--name`: The name of the project (cannot be empty)
|
|
24
|
-
- `--template`: The template to use for the project (default to `welcome`)
|
|
25
|
-
|
|
26
|
-
## Checking
|
|
27
|
-
|
|
28
|
-
Checking syntax of .deva file(s)
|
|
29
|
-
|
|
30
|
-
```bash
|
|
31
|
-
devalang check --entry ./examples --output ./output --watch
|
|
32
|
-
```
|
|
33
|
-
|
|
34
|
-
Available arguments :
|
|
35
|
-
|
|
36
|
-
- `--no-config`: Whether to ignore the configuration file (default to `false`)
|
|
37
|
-
- `--entry`: The input folder (default to `./src`)
|
|
38
|
-
- `--output`: The output folder (default to `./output`)
|
|
39
|
-
- `--watch`: Whether to watch for changes and re-analyze (default to `false`)
|
|
40
|
-
|
|
41
|
-
## Building
|
|
42
|
-
|
|
43
|
-
Building AST of .deva file(s)
|
|
44
|
-
|
|
45
|
-
```bash
|
|
46
|
-
devalang build --entry ./examples --output ./output --watch
|
|
47
|
-
```
|
|
48
|
-
|
|
49
|
-
Available arguments :
|
|
50
|
-
|
|
51
|
-
- `--no-config`: Whether to ignore the configuration file (default to `false`)
|
|
52
|
-
- `--entry`: The input folder (default to `./src`)
|
|
53
|
-
- `--output`: The output folder (default to `./output`)
|
|
54
|
-
- `--watch`: Whether to watch for changes and rebuild (default to `false`)
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
## Playing
|
|
58
|
-
|
|
59
|
-
Playing .deva file(s) without audio playback (once)
|
|
60
|
-
|
|
61
|
-
```bash
|
|
62
|
-
devalang play --entry ./examples --output ./output
|
|
63
|
-
```
|
|
64
|
-
|
|
65
|
-
Playing .deva file(s) with audio playback (once by file change)
|
|
66
|
-
|
|
67
|
-
```bash
|
|
68
|
-
devalang play --entry ./examples --output ./output --watch
|
|
69
|
-
```
|
|
70
|
-
|
|
71
|
-
Playing .deva file(s) with audio playback (infinite loop)
|
|
72
|
-
|
|
73
|
-
```bash
|
|
74
|
-
devalang play --entry ./examples --output ./output --repeat
|
|
75
|
-
```
|
|
76
|
-
|
|
77
|
-
Note : You cannot use `--watch` and `--repeat` options together. Use `--repeat` instead.
|
|
78
|
-
|
|
79
|
-
Available arguments :
|
|
80
|
-
|
|
81
|
-
- `--no-config`: Whether to ignore the configuration file (default to `false`)
|
|
82
|
-
- `--entry`: The input folder (default to `./src`)
|
|
83
|
-
- `--output`: The output folder (default to `./output`)
|
|
84
|
-
- `--watch`: Whether to watch for changes and rebuild + play (default to `false`)
|
|
85
|
-
- `--repeat`: Whether to repeat the playback of the audio file (default to `false`)
|
package/docs/CONFIG.md
DELETED
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
<div align="center">
|
|
2
|
-
<img src="https://firebasestorage.googleapis.com/v0/b/devaloop-labs.firebasestorage.app/o/devalang-teal-logo.svg?alt=media&token=d2a5705a-1eba-4b49-88e6-895a761fb7f7" alt="Devalang Logo">
|
|
3
|
-
</div>
|
|
4
|
-
|
|
5
|
-
# Devalang Configuration File
|
|
6
|
-
|
|
7
|
-
Use a configuration file if you don't want to pass command-line arguments every time you run a command. The configuration file allows you to set default values for various settings, making it easier to manage your Devalang project.
|
|
8
|
-
|
|
9
|
-
## Ignoring the Configuration File
|
|
10
|
-
|
|
11
|
-
If you prefer not to use a configuration file, you can ignore it by passing the `--no-config` flag when running Devalang commands. This will bypass any settings defined in the configuration file and use only the command-line arguments you provide.
|
|
12
|
-
|
|
13
|
-
## Structure of the Configuration File
|
|
14
|
-
|
|
15
|
-
The configuration file is a TOML (Tom's Obvious, Minimal Language) file that contains key-value pairs to define various settings for your Devalang project. Below is a sample configuration file:
|
|
16
|
-
|
|
17
|
-
```toml
|
|
18
|
-
[defaults]
|
|
19
|
-
entry = "./src"
|
|
20
|
-
output = "./output"
|
|
21
|
-
watch = false
|
|
22
|
-
repeat = true
|
|
23
|
-
```
|
|
24
|
-
|
|
25
|
-
### Available Settings
|
|
26
|
-
|
|
27
|
-
- `entry`: (String) The entry point for your Devalang project (default to `./src`)
|
|
28
|
-
- `output`: (String) The output directory for generated files (default to `./output`)
|
|
29
|
-
- `watch`: (Boolean) Whether to watch for changes in files and automatically rebuild or check them (default to `false`)
|
|
30
|
-
- `repeat`: (Boolean) Whether to repeat the playback of audio files (default to `false`)
|
package/docs/SYNTAX.md
DELETED
|
@@ -1,210 +0,0 @@
|
|
|
1
|
-
<div align="center">
|
|
2
|
-
<img src="https://firebasestorage.googleapis.com/v0/b/devaloop-labs.firebasestorage.app/o/devalang-teal-logo.svg?alt=media&token=d2a5705a-1eba-4b49-88e6-895a761fb7f7" alt="Devalang Logo">
|
|
3
|
-
</div>
|
|
4
|
-
|
|
5
|
-
# Devalang Syntax Guide
|
|
6
|
-
|
|
7
|
-
Devalang supports a simple and intuitive syntax for composing music and sound design. Below is a guide to the basic syntax elements, types, and usage examples.
|
|
8
|
-
|
|
9
|
-
The engine is designed to be easy to read and write, allowing you to focus on your music rather than the code.
|
|
10
|
-
|
|
11
|
-
The engine uses indentation to define blocks, similar to Python. Each block must be indented consistently.
|
|
12
|
-
|
|
13
|
-
➡️ For full examples, check the `examples/` folder of the repository.
|
|
14
|
-
|
|
15
|
-
## Types
|
|
16
|
-
|
|
17
|
-
<details>
|
|
18
|
-
<summary>Show available types</summary>
|
|
19
|
-
|
|
20
|
-
### Duration
|
|
21
|
-
|
|
22
|
-
Duration is defined using a number. It represents the length of a sound in milliseconds.
|
|
23
|
-
|
|
24
|
-
```deva
|
|
25
|
-
let duration = 1000
|
|
26
|
-
```
|
|
27
|
-
|
|
28
|
-
Will play a sound for 1000 milliseconds (1 second).
|
|
29
|
-
|
|
30
|
-
NOTE: Other time units like seconds or beats are not supported yet, but will be in the future.
|
|
31
|
-
|
|
32
|
-
### String
|
|
33
|
-
|
|
34
|
-
Strings are defined using double quotes.
|
|
35
|
-
|
|
36
|
-
```deva
|
|
37
|
-
let string = "myValue"
|
|
38
|
-
```
|
|
39
|
-
|
|
40
|
-
### Number
|
|
41
|
-
|
|
42
|
-
Numbers can be integers or floating-point values. They do not require quotes.
|
|
43
|
-
|
|
44
|
-
```deva
|
|
45
|
-
let number = 99
|
|
46
|
-
```
|
|
47
|
-
|
|
48
|
-
### Boolean
|
|
49
|
-
|
|
50
|
-
Booleans can be either `true` or `false` without quotes.
|
|
51
|
-
|
|
52
|
-
```deva
|
|
53
|
-
let boolean = false
|
|
54
|
-
```
|
|
55
|
-
|
|
56
|
-
### Map
|
|
57
|
-
|
|
58
|
-
Maps are key-value pairs defined using curly braces. Keys are strings, and values can be of any type (string, number, boolean, map, or array).
|
|
59
|
-
|
|
60
|
-
```deva
|
|
61
|
-
let map = { myKey: 99 }
|
|
62
|
-
```
|
|
63
|
-
|
|
64
|
-
### Array
|
|
65
|
-
|
|
66
|
-
Arrays are ordered lists of values defined using square brackets. Values can be of any type (string, number, boolean, map, or array).
|
|
67
|
-
|
|
68
|
-
```deva
|
|
69
|
-
let array = [3, 4]
|
|
70
|
-
```
|
|
71
|
-
|
|
72
|
-
</details>
|
|
73
|
-
|
|
74
|
-
## Syntax usage
|
|
75
|
-
|
|
76
|
-
### Beats Per Minute
|
|
77
|
-
|
|
78
|
-
BPM is used to set the global tempo of the music.
|
|
79
|
-
|
|
80
|
-
```deva
|
|
81
|
-
bpm 125
|
|
82
|
-
```
|
|
83
|
-
|
|
84
|
-
### Sound Bank
|
|
85
|
-
|
|
86
|
-
Bank is used to select a sound bank for the audio engine.
|
|
87
|
-
|
|
88
|
-
```deva
|
|
89
|
-
bank 808
|
|
90
|
-
```
|
|
91
|
-
|
|
92
|
-
### Importing / Exporting Modules
|
|
93
|
-
|
|
94
|
-
Modules can be imported and exported to share variables between different files.
|
|
95
|
-
|
|
96
|
-
> ⚠️ The import/export system is still experimental and may change in the future.
|
|
97
|
-
>
|
|
98
|
-
> You must explicitly declare imports and exports in each file — Devalang does not automatically detect or resolve them.
|
|
99
|
-
|
|
100
|
-
Exporting variables from a module :
|
|
101
|
-
|
|
102
|
-
```deva
|
|
103
|
-
# exported.deva
|
|
104
|
-
|
|
105
|
-
let exportedIterator = 10
|
|
106
|
-
let exportedParams = { drive: 50, decay: 30 }
|
|
107
|
-
|
|
108
|
-
@export { exportedIterator, exportedParams }
|
|
109
|
-
```
|
|
110
|
-
|
|
111
|
-
Importing and using the exported variables in another module :
|
|
112
|
-
|
|
113
|
-
```deva
|
|
114
|
-
# index.deva
|
|
115
|
-
|
|
116
|
-
@import { exportedIterator, exportedParams } "./exported.deva"
|
|
117
|
-
|
|
118
|
-
loop exportedIterator:
|
|
119
|
-
.kick auto exportedParams
|
|
120
|
-
```
|
|
121
|
-
|
|
122
|
-
### Loading Samples
|
|
123
|
-
|
|
124
|
-
You can load your own samples and use them in your music.
|
|
125
|
-
|
|
126
|
-
Load usage : `@load <path> as <name>`
|
|
127
|
-
|
|
128
|
-
Trigger usage : `.<name> <duration> <params>`
|
|
129
|
-
|
|
130
|
-
```deva
|
|
131
|
-
@load "./path/to/instrument.mp3" as mySample
|
|
132
|
-
|
|
133
|
-
.mySample auto {reverb: 50, drive: 25}
|
|
134
|
-
```
|
|
135
|
-
|
|
136
|
-
### Variables
|
|
137
|
-
|
|
138
|
-
Variables are defined using the `let` keyword, followed by the variable name and its value. The value can be of any type (string, number, boolean, map, or array).
|
|
139
|
-
|
|
140
|
-
```deva
|
|
141
|
-
let number = 0
|
|
142
|
-
let boolean = true
|
|
143
|
-
let string = "string"
|
|
144
|
-
let map = { myKey: 200 }
|
|
145
|
-
let array = [0, 1, 2]
|
|
146
|
-
```
|
|
147
|
-
|
|
148
|
-
### Loops
|
|
149
|
-
|
|
150
|
-
Loops are defined using the `loop` keyword, followed by the number of iterations. The body of the loop is indented.
|
|
151
|
-
|
|
152
|
-
```deva
|
|
153
|
-
loop 10:
|
|
154
|
-
# ...
|
|
155
|
-
```
|
|
156
|
-
|
|
157
|
-
### Groups
|
|
158
|
-
|
|
159
|
-
Groups are defined using the `group` keyword, followed by the group name. The body of the group is indented.
|
|
160
|
-
|
|
161
|
-
Groups allow you to organize your code into reusable blocks. They can be called or spawned later in the code.
|
|
162
|
-
|
|
163
|
-
```deva
|
|
164
|
-
group myGroup:
|
|
165
|
-
# ...
|
|
166
|
-
```
|
|
167
|
-
|
|
168
|
-
### Conditions
|
|
169
|
-
|
|
170
|
-
Conditions are defined using the `if` keyword, followed by a condition. The body of the condition is indented.
|
|
171
|
-
|
|
172
|
-
```deva
|
|
173
|
-
if myCondition:
|
|
174
|
-
# ...
|
|
175
|
-
```
|
|
176
|
-
|
|
177
|
-
You can also use `else` and `else if` for alternative branches:
|
|
178
|
-
|
|
179
|
-
```deva
|
|
180
|
-
if myCondition:
|
|
181
|
-
# ...
|
|
182
|
-
else if anotherCondition:
|
|
183
|
-
# ...
|
|
184
|
-
else:
|
|
185
|
-
# ...
|
|
186
|
-
```
|
|
187
|
-
|
|
188
|
-
### Calling Groups (Sequential Execution)
|
|
189
|
-
|
|
190
|
-
Groups can be called using the `call` keyword, which executes only the group in sequence.
|
|
191
|
-
|
|
192
|
-
> ⚠️ `call` only works on `group` declarations. It does not apply to other statements.
|
|
193
|
-
|
|
194
|
-
This executes the entire group in the current execution thread, following a sequential order.
|
|
195
|
-
|
|
196
|
-
```deva
|
|
197
|
-
call myGroup
|
|
198
|
-
```
|
|
199
|
-
|
|
200
|
-
### Spawning Groups (Parallel Execution)
|
|
201
|
-
|
|
202
|
-
Groups can be spawned using the `spawn` keyword, which executes only the group in parallel.
|
|
203
|
-
|
|
204
|
-
> ⚠️ spawn also only works on group declarations. It does not make the group’s content parallel unless it explicitly uses spawn inside.
|
|
205
|
-
|
|
206
|
-
This runs the entire group in a separate execution thread, allowing it to play alongside other actions.
|
|
207
|
-
|
|
208
|
-
```deva
|
|
209
|
-
spawn myGroup
|
|
210
|
-
```
|
package/out-tsc/bin/devalang.exe
DELETED
|
Binary file
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
const fs_1 = __importDefault(require("fs"));
|
|
7
|
-
const path_1 = __importDefault(require("path"));
|
|
8
|
-
const source = path_1.default.join(__dirname, "..", "..", "target", "release", "devalang.exe");
|
|
9
|
-
const destination = path_1.default.join(__dirname, "..", "bin", "devalang.exe");
|
|
10
|
-
fs_1.default.copyFileSync(source, destination);
|
|
11
|
-
fs_1.default.chmodSync(destination, 0o755);
|
package/rust/cli/build.rs
DELETED
|
@@ -1,137 +0,0 @@
|
|
|
1
|
-
use crate::{
|
|
2
|
-
config::Config,
|
|
3
|
-
core::{
|
|
4
|
-
builder::Builder,
|
|
5
|
-
debugger::{
|
|
6
|
-
lexer::write_lexer_log_file,
|
|
7
|
-
preprocessor::write_preprocessor_log_file,
|
|
8
|
-
store::write_store_log_file,
|
|
9
|
-
},
|
|
10
|
-
preprocessor::loader::ModuleLoader,
|
|
11
|
-
store::global::GlobalStore,
|
|
12
|
-
utils::path::{ find_entry_file, normalize_path },
|
|
13
|
-
},
|
|
14
|
-
utils::{ logger::{ LogLevel, Logger }, spinner::with_spinner, watcher::watch_directory },
|
|
15
|
-
};
|
|
16
|
-
use std::{ thread, time::Duration };
|
|
17
|
-
|
|
18
|
-
#[cfg(feature = "cli")]
|
|
19
|
-
pub fn handle_build_command(
|
|
20
|
-
config: Option<Config>,
|
|
21
|
-
entry: Option<String>,
|
|
22
|
-
output: Option<String>,
|
|
23
|
-
watch: bool
|
|
24
|
-
) {
|
|
25
|
-
let fetched_entry = if entry.is_none() {
|
|
26
|
-
config
|
|
27
|
-
.as_ref()
|
|
28
|
-
.and_then(|c| c.defaults.entry.clone())
|
|
29
|
-
.unwrap_or_else(|| "".to_string())
|
|
30
|
-
} else {
|
|
31
|
-
entry.clone().unwrap_or_else(|| "".to_string())
|
|
32
|
-
};
|
|
33
|
-
|
|
34
|
-
let fetched_output = if output.is_none() {
|
|
35
|
-
config
|
|
36
|
-
.as_ref()
|
|
37
|
-
.and_then(|c| c.defaults.output.clone())
|
|
38
|
-
.unwrap_or_else(|| "".to_string())
|
|
39
|
-
} else {
|
|
40
|
-
output.clone().unwrap_or_else(|| "".to_string())
|
|
41
|
-
};
|
|
42
|
-
|
|
43
|
-
let fetched_watch = if watch {
|
|
44
|
-
watch
|
|
45
|
-
} else {
|
|
46
|
-
config
|
|
47
|
-
.as_ref()
|
|
48
|
-
.and_then(|c| c.defaults.watch)
|
|
49
|
-
.unwrap_or(false)
|
|
50
|
-
};
|
|
51
|
-
|
|
52
|
-
let logger = Logger::new();
|
|
53
|
-
|
|
54
|
-
if fetched_entry.is_empty() {
|
|
55
|
-
logger.log_message(
|
|
56
|
-
LogLevel::Error,
|
|
57
|
-
"Entry path is not specified. Please provide a valid entry path."
|
|
58
|
-
);
|
|
59
|
-
std::process::exit(1);
|
|
60
|
-
}
|
|
61
|
-
if fetched_output.is_empty() {
|
|
62
|
-
logger.log_message(
|
|
63
|
-
LogLevel::Error,
|
|
64
|
-
"Output directory is not specified. Please provide a valid output directory."
|
|
65
|
-
);
|
|
66
|
-
std::process::exit(1);
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
let entry_file = find_entry_file(&fetched_entry).unwrap_or_else(|| {
|
|
70
|
-
logger.log_message(
|
|
71
|
-
LogLevel::Error,
|
|
72
|
-
&format!("❌ index.deva not found in directory: {}", fetched_entry)
|
|
73
|
-
);
|
|
74
|
-
std::process::exit(1);
|
|
75
|
-
});
|
|
76
|
-
|
|
77
|
-
// SECTION Begin build
|
|
78
|
-
if fetched_watch {
|
|
79
|
-
begin_build(entry_file.clone(), fetched_output.clone());
|
|
80
|
-
|
|
81
|
-
logger.log_message(
|
|
82
|
-
LogLevel::Watcher,
|
|
83
|
-
&format!("Watching for changes in '{}'...", fetched_entry)
|
|
84
|
-
);
|
|
85
|
-
|
|
86
|
-
watch_directory(entry_file.clone(), move || {
|
|
87
|
-
logger.log_message(LogLevel::Watcher, "Detected changes, re-building...");
|
|
88
|
-
|
|
89
|
-
begin_build(entry_file.clone(), fetched_output.clone());
|
|
90
|
-
}).unwrap();
|
|
91
|
-
} else {
|
|
92
|
-
begin_build(entry_file.clone(), fetched_output.clone());
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
fn begin_build(entry: String, output: String) {
|
|
97
|
-
let spinner = with_spinner("Building...", || {
|
|
98
|
-
thread::sleep(Duration::from_millis(800));
|
|
99
|
-
});
|
|
100
|
-
|
|
101
|
-
let duration = std::time::Instant::now();
|
|
102
|
-
|
|
103
|
-
let normalized_entry_file = normalize_path(&entry);
|
|
104
|
-
let normalized_output_dir = normalize_path(&output);
|
|
105
|
-
|
|
106
|
-
let mut global_store = GlobalStore::new();
|
|
107
|
-
let module_loader = ModuleLoader::new(&normalized_entry_file, &normalized_output_dir);
|
|
108
|
-
|
|
109
|
-
// SECTION Load
|
|
110
|
-
// NOTE: We use modules in the build command, so we need to load them
|
|
111
|
-
let (modules_tokens, modules_statements) = module_loader.load_all_modules(&mut global_store);
|
|
112
|
-
|
|
113
|
-
// 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());
|
|
121
|
-
|
|
122
|
-
// SECTION Building AST and Audio
|
|
123
|
-
let builder = Builder::new();
|
|
124
|
-
builder.build_ast(&modules_statements, &normalized_output_dir);
|
|
125
|
-
builder.build_audio(&modules_statements, &normalized_output_dir, &mut global_store);
|
|
126
|
-
|
|
127
|
-
// SECTION Logging
|
|
128
|
-
let logger = Logger::new();
|
|
129
|
-
|
|
130
|
-
let success_message = format!(
|
|
131
|
-
"Build completed successfully in {:.2?}. Output files written to: '{}'",
|
|
132
|
-
duration.elapsed(),
|
|
133
|
-
normalized_output_dir
|
|
134
|
-
);
|
|
135
|
-
|
|
136
|
-
logger.log_message(LogLevel::Success, &success_message);
|
|
137
|
-
}
|
package/rust/cli/check.rs
DELETED
|
@@ -1,117 +0,0 @@
|
|
|
1
|
-
use crate::{
|
|
2
|
-
config::Config,
|
|
3
|
-
core::{
|
|
4
|
-
preprocessor::loader::ModuleLoader,
|
|
5
|
-
store::global::GlobalStore,
|
|
6
|
-
utils::path::{ find_entry_file, normalize_path },
|
|
7
|
-
},
|
|
8
|
-
utils::{ logger::{ LogLevel, Logger }, spinner::with_spinner, watcher::watch_directory },
|
|
9
|
-
};
|
|
10
|
-
use std::{ thread, time::Duration };
|
|
11
|
-
|
|
12
|
-
#[cfg(feature = "cli")]
|
|
13
|
-
pub fn handle_check_command(
|
|
14
|
-
config: Option<Config>,
|
|
15
|
-
entry: Option<String>,
|
|
16
|
-
output: Option<String>,
|
|
17
|
-
watch: bool
|
|
18
|
-
) {
|
|
19
|
-
let fetched_entry = if entry.is_none() {
|
|
20
|
-
config
|
|
21
|
-
.as_ref()
|
|
22
|
-
.and_then(|c| c.defaults.entry.clone())
|
|
23
|
-
.unwrap_or_else(|| "".to_string())
|
|
24
|
-
} else {
|
|
25
|
-
entry.clone().unwrap_or_else(|| "".to_string())
|
|
26
|
-
};
|
|
27
|
-
|
|
28
|
-
let fetched_output = if output.is_none() {
|
|
29
|
-
config
|
|
30
|
-
.as_ref()
|
|
31
|
-
.and_then(|c| c.defaults.output.clone())
|
|
32
|
-
.unwrap_or_else(|| "".to_string())
|
|
33
|
-
} else {
|
|
34
|
-
output.clone().unwrap_or_else(|| "".to_string())
|
|
35
|
-
};
|
|
36
|
-
|
|
37
|
-
let fetched_watch = if watch {
|
|
38
|
-
watch
|
|
39
|
-
} else {
|
|
40
|
-
config
|
|
41
|
-
.as_ref()
|
|
42
|
-
.and_then(|c| c.defaults.watch)
|
|
43
|
-
.unwrap_or(false)
|
|
44
|
-
};
|
|
45
|
-
|
|
46
|
-
let logger = Logger::new();
|
|
47
|
-
|
|
48
|
-
if fetched_entry.is_empty() {
|
|
49
|
-
logger.log_message(
|
|
50
|
-
LogLevel::Error,
|
|
51
|
-
"Entry path is not specified. Please provide a valid entry path."
|
|
52
|
-
);
|
|
53
|
-
std::process::exit(1);
|
|
54
|
-
}
|
|
55
|
-
if fetched_output.is_empty() {
|
|
56
|
-
logger.log_message(
|
|
57
|
-
LogLevel::Error,
|
|
58
|
-
"Output directory is not specified. Please provide a valid output directory."
|
|
59
|
-
);
|
|
60
|
-
std::process::exit(1);
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
let entry_file = find_entry_file(&fetched_entry).unwrap_or_else(|| {
|
|
64
|
-
logger.log_message(
|
|
65
|
-
LogLevel::Error,
|
|
66
|
-
&format!("❌ index.deva not found in directory: {}", fetched_entry)
|
|
67
|
-
);
|
|
68
|
-
std::process::exit(1);
|
|
69
|
-
});
|
|
70
|
-
|
|
71
|
-
// SECTION Begin check
|
|
72
|
-
if fetched_watch {
|
|
73
|
-
begin_check(entry_file.clone(), fetched_output.clone());
|
|
74
|
-
|
|
75
|
-
logger.log_message(
|
|
76
|
-
LogLevel::Watcher,
|
|
77
|
-
&format!("Watching for changes in '{}'...", fetched_entry)
|
|
78
|
-
);
|
|
79
|
-
|
|
80
|
-
watch_directory(entry_file.clone(), move || {
|
|
81
|
-
logger.log_message(LogLevel::Watcher, "Detected changes, re-checking...");
|
|
82
|
-
|
|
83
|
-
begin_check(entry_file.clone(), fetched_output.clone());
|
|
84
|
-
}).unwrap();
|
|
85
|
-
} else {
|
|
86
|
-
begin_check(entry_file.clone(), fetched_output.clone());
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
fn begin_check(entry: String, output: String) {
|
|
91
|
-
let spinner = with_spinner("Checking...", || {
|
|
92
|
-
thread::sleep(Duration::from_millis(800));
|
|
93
|
-
});
|
|
94
|
-
|
|
95
|
-
let duration = std::time::Instant::now();
|
|
96
|
-
|
|
97
|
-
let normalized_entry_file = normalize_path(&entry);
|
|
98
|
-
let normalized_output_dir = normalize_path(&output);
|
|
99
|
-
|
|
100
|
-
let mut global_store = GlobalStore::new();
|
|
101
|
-
let module_loader = ModuleLoader::new(&normalized_entry_file, &normalized_output_dir);
|
|
102
|
-
|
|
103
|
-
// SECTION Load
|
|
104
|
-
// NOTE: We don't use modules in the check command, but we still need to load them
|
|
105
|
-
let modules = module_loader.load_all_modules(&mut global_store);
|
|
106
|
-
|
|
107
|
-
// TODO: Implement debugging
|
|
108
|
-
|
|
109
|
-
let success_message = format!(
|
|
110
|
-
"Check completed successfully in {:.2?}. Output files written to: '{}'",
|
|
111
|
-
duration.elapsed(),
|
|
112
|
-
normalized_output_dir
|
|
113
|
-
);
|
|
114
|
-
|
|
115
|
-
let logger = Logger::new();
|
|
116
|
-
logger.log_message(LogLevel::Success, &success_message);
|
|
117
|
-
}
|