@devaloop/devalang 0.0.1-beta.2 → 0.1.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/README.md +177 -146
- package/out-tsc/api.d.ts +180 -0
- package/out-tsc/api.d.ts.map +1 -0
- package/out-tsc/api.js +286 -0
- package/out-tsc/api.js.map +1 -0
- package/out-tsc/bin/index.d.ts +12 -0
- package/out-tsc/bin/index.d.ts.map +1 -0
- package/out-tsc/bin/index.js +20 -54
- package/out-tsc/bin/index.js.map +1 -0
- package/out-tsc/examples/basic-usage.d.ts +8 -0
- package/out-tsc/examples/basic-usage.d.ts.map +1 -0
- package/out-tsc/examples/basic-usage.js +113 -0
- package/out-tsc/examples/basic-usage.js.map +1 -0
- package/out-tsc/index.d.ts +19 -5
- package/out-tsc/index.d.ts.map +1 -0
- package/out-tsc/index.js +24 -6
- package/out-tsc/index.js.map +1 -0
- package/out-tsc/scripts/copy-wasm-dts.d.ts +7 -0
- package/out-tsc/scripts/copy-wasm-dts.d.ts.map +1 -0
- package/out-tsc/scripts/copy-wasm-dts.js +36 -32
- package/out-tsc/scripts/copy-wasm-dts.js.map +1 -0
- package/out-tsc/scripts/postinstall.d.ts +1 -0
- package/out-tsc/scripts/postinstall.d.ts.map +1 -0
- package/out-tsc/scripts/postinstall.js +4 -1
- package/out-tsc/scripts/postinstall.js.map +1 -0
- package/out-tsc/scripts/version/bump.d.ts +5 -1
- package/out-tsc/scripts/version/bump.d.ts.map +1 -0
- package/out-tsc/scripts/version/bump.js +114 -44
- package/out-tsc/scripts/version/bump.js.map +1 -0
- package/out-tsc/scripts/version/fetch.d.ts +12 -1
- package/out-tsc/scripts/version/fetch.d.ts.map +1 -0
- package/out-tsc/scripts/version/fetch.js +68 -24
- package/out-tsc/scripts/version/fetch.js.map +1 -0
- package/out-tsc/scripts/version/index.d.ts +6 -0
- package/out-tsc/scripts/version/index.d.ts.map +1 -0
- package/out-tsc/scripts/version/index.js +44 -22
- package/out-tsc/scripts/version/index.js.map +1 -0
- package/out-tsc/scripts/version/sync.d.ts +5 -1
- package/out-tsc/scripts/version/sync.d.ts.map +1 -0
- package/out-tsc/scripts/version/sync.js +78 -29
- package/out-tsc/scripts/version/sync.js.map +1 -0
- package/out-tsc/types.d.ts +68 -0
- package/out-tsc/types.d.ts.map +1 -0
- package/out-tsc/{core/types/value.js → types.js} +4 -0
- package/out-tsc/types.js.map +1 -0
- package/out-tsc/wasm.d.ts +8 -0
- package/out-tsc/wasm.d.ts.map +1 -0
- package/out-tsc/{core/index.js → wasm.js} +9 -6
- package/out-tsc/wasm.js.map +1 -0
- package/package.json +50 -37
- package/.cargo/config.toml +0 -2
- package/.devalang +0 -9
- package/.github/workflows/ci.yml +0 -103
- package/Cargo.toml +0 -81
- package/docs/CHANGELOG.md +0 -581
- package/docs/CONTRIBUTING.md +0 -101
- package/docs/ROADMAP.md +0 -38
- package/docs/TODO.md +0 -71
- package/examples/automation.deva +0 -42
- package/examples/bank.deva +0 -7
- package/examples/bus.deva +0 -10
- package/examples/condition.deva +0 -20
- package/examples/duration.deva +0 -9
- package/examples/effect.deva +0 -2
- package/examples/events.deva +0 -12
- package/examples/filter.deva +0 -11
- package/examples/function.deva +0 -15
- package/examples/group.deva +0 -12
- package/examples/index.deva +0 -63
- package/examples/lfo.deva +0 -9
- package/examples/loop.deva +0 -10
- package/examples/pattern.deva +0 -8
- package/examples/plugin.deva +0 -16
- package/examples/samples/hat-808.wav +0 -0
- package/examples/samples/kick-808.wav +0 -0
- package/examples/synth.deva +0 -24
- package/examples/synth_types.deva +0 -17
- package/examples/variables.deva +0 -9
- package/out-tsc/core/functions/index.d.ts +0 -42
- package/out-tsc/core/functions/index.js +0 -87
- package/out-tsc/core/index.d.ts +0 -6
- package/out-tsc/core/types/index.d.ts +0 -4
- package/out-tsc/core/types/index.js +0 -20
- package/out-tsc/core/types/plugin.d.ts +0 -18
- package/out-tsc/core/types/plugin.js +0 -2
- package/out-tsc/core/types/result.d.ts +0 -27
- package/out-tsc/core/types/result.js +0 -2
- package/out-tsc/core/types/statement.d.ts +0 -106
- package/out-tsc/core/types/statement.js +0 -2
- package/out-tsc/core/types/value.d.ts +0 -43
- package/out-tsc/pkg/devalang_core.d.ts +0 -15
- package/out-tsc/pkg/devalang_core.js +0 -65
- package/out-tsc/pkg/devalang_core_bg.wasm.d.ts +0 -34
- package/project-version.json +0 -6
- package/rust/cli/bank/api.rs +0 -122
- package/rust/cli/bank/commands.rs +0 -306
- package/rust/cli/bank/mod.rs +0 -29
- package/rust/cli/build/commands.rs +0 -153
- package/rust/cli/build/mod.rs +0 -2
- package/rust/cli/build/process.rs +0 -165
- package/rust/cli/check/mod.rs +0 -208
- package/rust/cli/discover/commands.rs +0 -253
- package/rust/cli/discover/config.rs +0 -111
- package/rust/cli/discover/fs.rs +0 -19
- package/rust/cli/discover/install.rs +0 -103
- package/rust/cli/discover/metadata.rs +0 -48
- package/rust/cli/discover/mod.rs +0 -5
- package/rust/cli/init/commands.rs +0 -88
- package/rust/cli/init/mod.rs +0 -1
- package/rust/cli/install/addon.rs +0 -118
- package/rust/cli/install/bank.rs +0 -72
- package/rust/cli/install/commands.rs +0 -35
- package/rust/cli/install/mod.rs +0 -4
- package/rust/cli/install/plugin.rs +0 -80
- package/rust/cli/login/commands.rs +0 -124
- package/rust/cli/login/mod.rs +0 -1
- package/rust/cli/mod.rs +0 -12
- package/rust/cli/parser.rs +0 -359
- package/rust/cli/play/commands.rs +0 -375
- package/rust/cli/play/io.rs +0 -17
- package/rust/cli/play/mod.rs +0 -5
- package/rust/cli/play/process.rs +0 -159
- package/rust/cli/play/realtime.rs +0 -91
- package/rust/cli/play/utils.rs +0 -23
- package/rust/cli/telemetry/commands.rs +0 -22
- package/rust/cli/telemetry/event_creator.rs +0 -80
- package/rust/cli/telemetry/mod.rs +0 -3
- package/rust/cli/telemetry/send.rs +0 -51
- package/rust/cli/template/commands.rs +0 -69
- package/rust/cli/template/mod.rs +0 -1
- package/rust/cli/update/commands.rs +0 -6
- package/rust/cli/update/mod.rs +0 -1
- package/rust/config/driver.rs +0 -112
- package/rust/config/mod.rs +0 -3
- package/rust/config/ops.rs +0 -26
- package/rust/config/settings.rs +0 -101
- package/rust/core/audio/engine/driver.rs +0 -220
- package/rust/core/audio/engine/export.rs +0 -169
- package/rust/core/audio/engine/helpers.rs +0 -178
- package/rust/core/audio/engine/mod.rs +0 -56
- package/rust/core/audio/engine/notes/dsp.rs +0 -85
- package/rust/core/audio/engine/notes/mod.rs +0 -44
- package/rust/core/audio/engine/notes/params.rs +0 -294
- package/rust/core/audio/engine/sample/insert.rs +0 -199
- package/rust/core/audio/engine/sample/mod.rs +0 -40
- package/rust/core/audio/engine/sample/padding.rs +0 -170
- package/rust/core/audio/evaluator/condition.rs +0 -61
- package/rust/core/audio/evaluator/mod.rs +0 -9
- package/rust/core/audio/evaluator/numeric.rs +0 -152
- package/rust/core/audio/evaluator/rhs.rs +0 -16
- package/rust/core/audio/evaluator/string_expr.rs +0 -94
- package/rust/core/audio/interpreter/driver.rs +0 -574
- package/rust/core/audio/interpreter/mod.rs +0 -2
- package/rust/core/audio/interpreter/statements/arrow_call/interprete.rs +0 -175
- package/rust/core/audio/interpreter/statements/arrow_call/methods/chord.rs +0 -384
- package/rust/core/audio/interpreter/statements/arrow_call/methods/mod.rs +0 -2
- package/rust/core/audio/interpreter/statements/arrow_call/methods/note.rs +0 -316
- package/rust/core/audio/interpreter/statements/arrow_call/mod.rs +0 -3
- package/rust/core/audio/interpreter/statements/arrow_call/types/arp.rs +0 -192
- package/rust/core/audio/interpreter/statements/arrow_call/types/mod.rs +0 -24
- package/rust/core/audio/interpreter/statements/arrow_call/types/pad.rs +0 -116
- package/rust/core/audio/interpreter/statements/arrow_call/types/pluck.rs +0 -97
- package/rust/core/audio/interpreter/statements/arrow_call/types/sub.rs +0 -100
- package/rust/core/audio/interpreter/statements/automate.rs +0 -16
- package/rust/core/audio/interpreter/statements/call.rs +0 -295
- package/rust/core/audio/interpreter/statements/condition.rs +0 -72
- package/rust/core/audio/interpreter/statements/function.rs +0 -24
- package/rust/core/audio/interpreter/statements/let_.rs +0 -36
- package/rust/core/audio/interpreter/statements/load.rs +0 -17
- package/rust/core/audio/interpreter/statements/loop_.rs +0 -115
- package/rust/core/audio/interpreter/statements/mod.rs +0 -12
- package/rust/core/audio/interpreter/statements/sleep.rs +0 -28
- package/rust/core/audio/interpreter/statements/spawn.rs +0 -253
- package/rust/core/audio/interpreter/statements/tempo.rs +0 -40
- package/rust/core/audio/interpreter/statements/trigger.rs +0 -239
- package/rust/core/audio/loader/mod.rs +0 -1
- package/rust/core/audio/loader/trigger.rs +0 -98
- package/rust/core/audio/mod.rs +0 -6
- package/rust/core/audio/player.rs +0 -70
- package/rust/core/audio/special/easing.rs +0 -189
- package/rust/core/audio/special/env.rs +0 -45
- package/rust/core/audio/special/math.rs +0 -134
- package/rust/core/audio/special/mod.rs +0 -9
- package/rust/core/audio/special/modulator.rs +0 -143
- package/rust/core/builder/mod.rs +0 -129
- package/rust/core/debugger/lexer.rs +0 -27
- package/rust/core/debugger/logs.rs +0 -52
- package/rust/core/debugger/mod.rs +0 -30
- package/rust/core/debugger/preprocessor.rs +0 -27
- package/rust/core/debugger/store.rs +0 -38
- package/rust/core/error/mod.rs +0 -269
- package/rust/core/lexer/driver.rs +0 -59
- package/rust/core/lexer/handler/arrow.rs +0 -82
- package/rust/core/lexer/handler/at.rs +0 -21
- package/rust/core/lexer/handler/brace.rs +0 -41
- package/rust/core/lexer/handler/colon.rs +0 -21
- package/rust/core/lexer/handler/comment.rs +0 -30
- package/rust/core/lexer/handler/dot.rs +0 -21
- package/rust/core/lexer/handler/driver.rs +0 -337
- package/rust/core/lexer/handler/identifier.rs +0 -47
- package/rust/core/lexer/handler/indent.rs +0 -66
- package/rust/core/lexer/handler/mod.rs +0 -15
- package/rust/core/lexer/handler/newline.rs +0 -23
- package/rust/core/lexer/handler/number.rs +0 -31
- package/rust/core/lexer/handler/operator.rs +0 -46
- package/rust/core/lexer/handler/parenthesis.rs +0 -41
- package/rust/core/lexer/handler/slash.rs +0 -21
- package/rust/core/lexer/handler/string.rs +0 -63
- package/rust/core/lexer/mod.rs +0 -3
- package/rust/core/lexer/token.rs +0 -91
- package/rust/core/mod.rs +0 -9
- package/rust/core/parser/driver/block.rs +0 -111
- package/rust/core/parser/driver/cursor.rs +0 -82
- package/rust/core/parser/driver/driver_impl.rs +0 -139
- package/rust/core/parser/driver/mod.rs +0 -6
- package/rust/core/parser/driver/parse_array.rs +0 -120
- package/rust/core/parser/driver/parse_map.rs +0 -223
- package/rust/core/parser/driver/parser.rs +0 -160
- package/rust/core/parser/handler/arrow_call.rs +0 -277
- package/rust/core/parser/handler/at.rs +0 -279
- package/rust/core/parser/handler/bank.rs +0 -104
- package/rust/core/parser/handler/condition.rs +0 -83
- package/rust/core/parser/handler/dot.rs +0 -148
- package/rust/core/parser/handler/identifier/automate.rs +0 -254
- package/rust/core/parser/handler/identifier/call.rs +0 -91
- package/rust/core/parser/handler/identifier/emit.rs +0 -70
- package/rust/core/parser/handler/identifier/function.rs +0 -113
- package/rust/core/parser/handler/identifier/group.rs +0 -89
- package/rust/core/parser/handler/identifier/let_.rs +0 -173
- package/rust/core/parser/handler/identifier/mod.rs +0 -55
- package/rust/core/parser/handler/identifier/on.rs +0 -107
- package/rust/core/parser/handler/identifier/print.rs +0 -49
- package/rust/core/parser/handler/identifier/sleep.rs +0 -96
- package/rust/core/parser/handler/identifier/spawn.rs +0 -91
- package/rust/core/parser/handler/identifier/synth.rs +0 -135
- package/rust/core/parser/handler/loop_.rs +0 -194
- package/rust/core/parser/handler/mod.rs +0 -9
- package/rust/core/parser/handler/pattern.rs +0 -74
- package/rust/core/parser/handler/tempo.rs +0 -105
- package/rust/core/parser/mod.rs +0 -3
- package/rust/core/parser/statement.rs +0 -10
- package/rust/core/plugin/loader.rs +0 -137
- package/rust/core/plugin/mod.rs +0 -2
- package/rust/core/plugin/runner/mod.rs +0 -11
- package/rust/core/plugin/runner/non_wasm.rs +0 -297
- package/rust/core/plugin/runner/wasm32.rs +0 -43
- package/rust/core/preprocessor/loader/inject.rs +0 -278
- package/rust/core/preprocessor/loader/loader_helpers.rs +0 -110
- package/rust/core/preprocessor/loader/mod.rs +0 -235
- package/rust/core/preprocessor/mod.rs +0 -4
- package/rust/core/preprocessor/module.rs +0 -55
- package/rust/core/preprocessor/processor/handlers.rs +0 -107
- package/rust/core/preprocessor/processor/mod.rs +0 -1
- package/rust/core/preprocessor/resolver/bank.rs +0 -49
- package/rust/core/preprocessor/resolver/call.rs +0 -124
- package/rust/core/preprocessor/resolver/condition.rs +0 -95
- package/rust/core/preprocessor/resolver/driver.rs +0 -324
- package/rust/core/preprocessor/resolver/function.rs +0 -69
- package/rust/core/preprocessor/resolver/group.rs +0 -122
- package/rust/core/preprocessor/resolver/let_.rs +0 -32
- package/rust/core/preprocessor/resolver/loop_.rs +0 -318
- package/rust/core/preprocessor/resolver/mod.rs +0 -16
- package/rust/core/preprocessor/resolver/pattern.rs +0 -83
- package/rust/core/preprocessor/resolver/spawn.rs +0 -99
- package/rust/core/preprocessor/resolver/synth.rs +0 -54
- package/rust/core/preprocessor/resolver/tempo.rs +0 -48
- package/rust/core/preprocessor/resolver/trigger.rs +0 -116
- package/rust/core/preprocessor/resolver/value.rs +0 -176
- package/rust/core/store/global.rs +0 -57
- package/rust/core/store/mod.rs +0 -1
- package/rust/lib.rs +0 -323
- package/rust/main.rs +0 -388
- package/rust/types/Cargo.toml +0 -11
- package/rust/types/src/addons.rs +0 -55
- package/rust/types/src/ast.rs +0 -202
- package/rust/types/src/config.rs +0 -84
- package/rust/types/src/lib.rs +0 -15
- package/rust/types/src/plugin.rs +0 -20
- package/rust/types/src/store.rs +0 -139
- package/rust/types/src/telemetry.rs +0 -85
- package/rust/utils/Cargo.toml +0 -26
- package/rust/utils/src/error.rs +0 -186
- package/rust/utils/src/file.rs +0 -94
- package/rust/utils/src/first_usage.rs +0 -97
- package/rust/utils/src/lib.rs +0 -9
- package/rust/utils/src/logger.rs +0 -200
- package/rust/utils/src/path.rs +0 -129
- package/rust/utils/src/signature.rs +0 -41
- package/rust/utils/src/spinner.rs +0 -20
- package/rust/utils/src/version.rs +0 -27
- package/rust/utils/src/watcher.rs +0 -46
- package/rust/web/api.rs +0 -5
- package/rust/web/cdn.rs +0 -34
- package/rust/web/mod.rs +0 -3
- package/rust/web/sso.rs +0 -5
- package/templates/minimal/.devalang +0 -5
- package/templates/minimal/README.md +0 -218
- package/templates/minimal/src/index.deva +0 -2
- package/templates/welcome/.devalang +0 -5
- package/templates/welcome/README.md +0 -218
- package/templates/welcome/samples/kick-808.wav +0 -0
- package/templates/welcome/src/index.deva +0 -61
- package/templates/welcome/src/variables.deva +0 -3
- package/tests/integration.rs +0 -21
- package/tests/rust/cli_check_build.rs +0 -21
- package/tests/rust/cli_help.rs +0 -12
- package/tests/rust/cli_template_list.rs +0 -10
- package/tests/rust/cli_version.rs +0 -11
- package/tests/typescript/index.spec.ts +0 -136
- package/tests/typescript/playhead.spec.ts +0 -36
- package/tests/typescript/render_e2e.spec.ts +0 -77
- package/tsconfig.json +0 -115
- package/typescript/bin/index.ts +0 -28
- package/typescript/core/functions/index.ts +0 -94
- package/typescript/core/index.ts +0 -6
- package/typescript/core/types/index.ts +0 -4
- package/typescript/core/types/plugin.ts +0 -19
- package/typescript/core/types/result.ts +0 -29
- package/typescript/core/types/statement.ts +0 -47
- package/typescript/core/types/value.ts +0 -29
- package/typescript/index.ts +0 -8
- package/typescript/pkg/devalang_core.d.ts +0 -4
- package/typescript/pkg/devalang_core.ts +0 -65
- package/typescript/scripts/copy-wasm-dts.ts +0 -41
- package/typescript/scripts/postinstall.ts +0 -85
- package/typescript/scripts/version/bump.ts +0 -44
- package/typescript/scripts/version/fetch.ts +0 -18
- package/typescript/scripts/version/index.ts +0 -25
- package/typescript/scripts/version/sync.ts +0 -24
|
@@ -1,136 +0,0 @@
|
|
|
1
|
-
import { expect } from "chai";
|
|
2
|
-
import * as fs from "fs";
|
|
3
|
-
import * as os from "os";
|
|
4
|
-
import * as path from "path";
|
|
5
|
-
|
|
6
|
-
// CommonJS bundle import (TypeScript-friendly)
|
|
7
|
-
const core: any = require("../../out-tsc");
|
|
8
|
-
|
|
9
|
-
describe("devalang typescript index", () => {
|
|
10
|
-
let origCwd: string;
|
|
11
|
-
let tmpDir: string | null = null;
|
|
12
|
-
|
|
13
|
-
before(function () {
|
|
14
|
-
// Prepare a temporary project root so wasm code that looks up project files
|
|
15
|
-
// and `.devalang` config can succeed during E2E runs.
|
|
16
|
-
origCwd = process.cwd();
|
|
17
|
-
tmpDir = fs.mkdtempSync(path.join(os.tmpdir(), "devalang-e2e-"));
|
|
18
|
-
// Create minimal .devalang config file so get_project_root finds it
|
|
19
|
-
fs.writeFileSync(
|
|
20
|
-
path.join(tmpDir, ".devalang"),
|
|
21
|
-
'name = "devalang-test"\n'
|
|
22
|
-
);
|
|
23
|
-
// Ensure .deva exists (optional banks/plugins)
|
|
24
|
-
fs.mkdirSync(path.join(tmpDir, ".deva"), { recursive: true });
|
|
25
|
-
process.chdir(tmpDir);
|
|
26
|
-
});
|
|
27
|
-
|
|
28
|
-
after(function () {
|
|
29
|
-
// restore cwd and attempt cleanup
|
|
30
|
-
if (tmpDir) {
|
|
31
|
-
try {
|
|
32
|
-
process.chdir(origCwd);
|
|
33
|
-
// best-effort cleanup
|
|
34
|
-
fs.rmSync(tmpDir, { recursive: true, force: true });
|
|
35
|
-
} catch (e) {
|
|
36
|
-
// ignore
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
});
|
|
40
|
-
it("should expose render_audio and return a Float32Array when wasm is available", function () {
|
|
41
|
-
// Prefer wasm binding if available
|
|
42
|
-
const wasmFn = core.pkg && core.pkg.render_audio;
|
|
43
|
-
|
|
44
|
-
const sampleProgram = `# simple program for tests
|
|
45
|
-
bpm 120
|
|
46
|
-
|
|
47
|
-
group myLead:
|
|
48
|
-
let mySynth = synth sine
|
|
49
|
-
mySynth -> note(C4, { duration: 400 })
|
|
50
|
-
mySynth -> note(G4, { duration: 400 })
|
|
51
|
-
call myLead
|
|
52
|
-
`;
|
|
53
|
-
|
|
54
|
-
if (typeof wasmFn === "function") {
|
|
55
|
-
try {
|
|
56
|
-
// Get parsed AST first for debugging
|
|
57
|
-
if (core.pkg && typeof core.pkg.parse === "function") {
|
|
58
|
-
try {
|
|
59
|
-
const parsed = core.pkg.parse("playground.deva", sampleProgram);
|
|
60
|
-
// parsed may be an object { ok, ast, errors } or a string
|
|
61
|
-
const astStr =
|
|
62
|
-
parsed && parsed.ast
|
|
63
|
-
? parsed.ast
|
|
64
|
-
: typeof parsed === "string"
|
|
65
|
-
? parsed
|
|
66
|
-
: JSON.stringify(parsed);
|
|
67
|
-
expect(astStr).to.match(/note|synth/i);
|
|
68
|
-
} catch (e) {
|
|
69
|
-
console.warn(
|
|
70
|
-
"[TEST DEBUG] parse() failed or returned non-standard result:",
|
|
71
|
-
e
|
|
72
|
-
);
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
const result = wasmFn(sampleProgram);
|
|
77
|
-
expect(result.constructor && result.constructor.name).to.match(
|
|
78
|
-
/Float32Array|Float64Array|ArrayBuffer|Uint8Array/
|
|
79
|
-
);
|
|
80
|
-
} catch (err: any) {
|
|
81
|
-
// If the wasm panicked because the audio buffer is empty, skip the test in this env.
|
|
82
|
-
const msg =
|
|
83
|
-
typeof err === "string"
|
|
84
|
-
? err
|
|
85
|
-
: err && err.message
|
|
86
|
-
? err.message
|
|
87
|
-
: String(err);
|
|
88
|
-
if (msg.includes("Audio buffer is empty")) {
|
|
89
|
-
// skip this test on environments where generating audio isn't supported
|
|
90
|
-
// eslint-disable-next-line no-invalid-this
|
|
91
|
-
this.skip();
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
throw err;
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
return;
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
// If wasm binding isn't available, ensure a runtime placeholder exists but don't call it
|
|
101
|
-
const runtimeFn = core.render_audio;
|
|
102
|
-
expect(runtimeFn).to.be.a("function");
|
|
103
|
-
});
|
|
104
|
-
|
|
105
|
-
it("should find statements for entry module", function () {
|
|
106
|
-
const parseFn = core.pkg && core.pkg.parse;
|
|
107
|
-
if (typeof parseFn !== "function") {
|
|
108
|
-
// nothing to test if parse binding missing
|
|
109
|
-
// eslint-disable-next-line no-invalid-this
|
|
110
|
-
this.skip();
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
try {
|
|
114
|
-
const res = parseFn("playground.deva", "bpm 120");
|
|
115
|
-
expect(res).to.be.an("object");
|
|
116
|
-
// prefer explicit shape when available
|
|
117
|
-
if (Object.prototype.hasOwnProperty.call(res, "ok")) {
|
|
118
|
-
expect(res.ok).to.equal(true);
|
|
119
|
-
} else {
|
|
120
|
-
expect(res).to.have.property("ast");
|
|
121
|
-
}
|
|
122
|
-
} catch (err: any) {
|
|
123
|
-
const msg = err && err.message ? err.message : String(err);
|
|
124
|
-
if (
|
|
125
|
-
msg.includes("Module loading error") ||
|
|
126
|
-
msg.includes("Project root not found")
|
|
127
|
-
) {
|
|
128
|
-
// environment not prepared for module loading, skip
|
|
129
|
-
// eslint-disable-next-line no-invalid-this
|
|
130
|
-
this.skip();
|
|
131
|
-
return;
|
|
132
|
-
}
|
|
133
|
-
throw err;
|
|
134
|
-
}
|
|
135
|
-
});
|
|
136
|
-
});
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import { expect } from "chai";
|
|
2
|
-
|
|
3
|
-
const core: any = require("../../out-tsc");
|
|
4
|
-
|
|
5
|
-
describe("playhead callback", () => {
|
|
6
|
-
it("should call registered callback during run", () => {
|
|
7
|
-
const register = core.pkg && core.pkg.register_playhead_callback;
|
|
8
|
-
const unregister = core.pkg && core.pkg.unregister_playhead_callback;
|
|
9
|
-
if (typeof register !== "function") {
|
|
10
|
-
// skip when wasm not available
|
|
11
|
-
return;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
let called = false;
|
|
15
|
-
const cb = (ev: any) => {
|
|
16
|
-
called = true;
|
|
17
|
-
expect(ev).to.have.property("time");
|
|
18
|
-
expect(ev).to.have.property("line");
|
|
19
|
-
expect(ev).to.have.property("column");
|
|
20
|
-
};
|
|
21
|
-
|
|
22
|
-
register(cb);
|
|
23
|
-
|
|
24
|
-
// run a simple program to trigger events
|
|
25
|
-
const program = `bpm 120\n\n.myTrigger 1/4\n`;
|
|
26
|
-
// render_audio will schedule triggers and should invoke the callback during execution
|
|
27
|
-
const render = core.pkg && core.pkg.render_audio;
|
|
28
|
-
if (typeof render === "function") {
|
|
29
|
-
render(program);
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
unregister && unregister();
|
|
33
|
-
|
|
34
|
-
expect(called).to.be.true;
|
|
35
|
-
});
|
|
36
|
-
});
|
|
@@ -1,77 +0,0 @@
|
|
|
1
|
-
import { expect } from "chai";
|
|
2
|
-
import * as fs from "fs";
|
|
3
|
-
import * as os from "os";
|
|
4
|
-
import * as path from "path";
|
|
5
|
-
|
|
6
|
-
const core: any = require("../../out-tsc");
|
|
7
|
-
|
|
8
|
-
describe("devalang debug_render and render_audio E2E", () => {
|
|
9
|
-
let origCwd: string;
|
|
10
|
-
let tmpDir: string | null = null;
|
|
11
|
-
|
|
12
|
-
before(function () {
|
|
13
|
-
origCwd = process.cwd();
|
|
14
|
-
tmpDir = fs.mkdtempSync(path.join(os.tmpdir(), "devalang-e2e-"));
|
|
15
|
-
fs.writeFileSync(
|
|
16
|
-
path.join(tmpDir, ".devalang"),
|
|
17
|
-
'name = "devalang-test"\n'
|
|
18
|
-
);
|
|
19
|
-
fs.mkdirSync(path.join(tmpDir, ".deva"), { recursive: true });
|
|
20
|
-
process.chdir(tmpDir as string);
|
|
21
|
-
});
|
|
22
|
-
|
|
23
|
-
after(function () {
|
|
24
|
-
if (tmpDir) {
|
|
25
|
-
try {
|
|
26
|
-
process.chdir(origCwd);
|
|
27
|
-
fs.rmSync(tmpDir, { recursive: true, force: true });
|
|
28
|
-
} catch (e) {
|
|
29
|
-
// ignore
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
});
|
|
33
|
-
|
|
34
|
-
it("debug_render should return diagnostics including note_count and global_vars", function () {
|
|
35
|
-
const dbg = core.pkg && core.pkg.debug_render;
|
|
36
|
-
if (typeof dbg !== "function") {
|
|
37
|
-
// skip if wasm binding missing
|
|
38
|
-
// eslint-disable-next-line no-invalid-this
|
|
39
|
-
this.skip();
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
const sampleProgram = `# sample program\nbpm 120\n\ngroup myLead:\n let mySynth = synth sine\n mySynth -> note(C4, { duration: 400 })\n mySynth -> note(G4, { duration: 400 })\ncall myLead\n`;
|
|
43
|
-
|
|
44
|
-
const out = dbg(sampleProgram);
|
|
45
|
-
expect(out).to.be.an("object");
|
|
46
|
-
expect(out).to.have.property("samples_len");
|
|
47
|
-
expect(out).to.have.property("any_nonzero");
|
|
48
|
-
expect(out).to.have.property("note_count");
|
|
49
|
-
expect(out).to.have.property("global_vars");
|
|
50
|
-
|
|
51
|
-
// Basic assertions: at least one non-zero sample or note_count > 0
|
|
52
|
-
expect(out.note_count).to.be.at.least(0);
|
|
53
|
-
expect(out.global_vars).to.include("myLead");
|
|
54
|
-
});
|
|
55
|
-
|
|
56
|
-
it("render_audio should return a Float32Array and not be completely silent", function () {
|
|
57
|
-
const render = (core.pkg && core.pkg.render_audio) || core.render_audio;
|
|
58
|
-
if (typeof render !== "function") {
|
|
59
|
-
// eslint-disable-next-line no-invalid-this
|
|
60
|
-
this.skip();
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
const sampleProgram = `# sample program\nbpm 120\n\ngroup myLead:\n let mySynth = synth sine\n mySynth -> note(C4, { duration: 400 })\n mySynth -> note(G4, { duration: 400 })\ncall myLead\n`;
|
|
64
|
-
|
|
65
|
-
const arr = render(sampleProgram);
|
|
66
|
-
// If wasm returns JS typed array wrapper, check constructor name
|
|
67
|
-
expect(arr.constructor && arr.constructor.name).to.match(
|
|
68
|
-
/Float32Array|Float64Array|ArrayBuffer|Uint8Array/
|
|
69
|
-
);
|
|
70
|
-
|
|
71
|
-
// Convert to plain array if needed
|
|
72
|
-
const samples: number[] = Array.from(arr as any);
|
|
73
|
-
// Expect either note_count > 0 indirectly via nonzero samples
|
|
74
|
-
const anyNonZero = samples.some((s) => s !== 0);
|
|
75
|
-
expect(anyNonZero).to.be.true;
|
|
76
|
-
});
|
|
77
|
-
});
|
package/tsconfig.json
DELETED
|
@@ -1,115 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"compilerOptions": {
|
|
3
|
-
/* Visit https://aka.ms/tsconfig to read more about this file */
|
|
4
|
-
|
|
5
|
-
/* Projects */
|
|
6
|
-
// "incremental": true, /* Save .tsbuildinfo files to allow for incremental compilation of projects. */
|
|
7
|
-
// "composite": true, /* Enable constraints that allow a TypeScript project to be used with project references. */
|
|
8
|
-
// "tsBuildInfoFile": "./.tsbuildinfo", /* Specify the path to .tsbuildinfo incremental compilation file. */
|
|
9
|
-
// "disableSourceOfProjectReferenceRedirect": true, /* Disable preferring source files instead of declaration files when referencing composite projects. */
|
|
10
|
-
// "disableSolutionSearching": true, /* Opt a project out of multi-project reference checking when editing. */
|
|
11
|
-
// "disableReferencedProjectLoad": true, /* Reduce the number of projects loaded automatically by TypeScript. */
|
|
12
|
-
|
|
13
|
-
/* Language and Environment */
|
|
14
|
-
"target": "es2016" /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */,
|
|
15
|
-
// "lib": [], /* Specify a set of bundled library declaration files that describe the target runtime environment. */
|
|
16
|
-
// "jsx": "preserve", /* Specify what JSX code is generated. */
|
|
17
|
-
// "libReplacement": true, /* Enable lib replacement. */
|
|
18
|
-
// "experimentalDecorators": true, /* Enable experimental support for legacy experimental decorators. */
|
|
19
|
-
// "emitDecoratorMetadata": true, /* Emit design-type metadata for decorated declarations in source files. */
|
|
20
|
-
// "jsxFactory": "", /* Specify the JSX factory function used when targeting React JSX emit, e.g. 'React.createElement' or 'h'. */
|
|
21
|
-
// "jsxFragmentFactory": "", /* Specify the JSX Fragment reference used for fragments when targeting React JSX emit e.g. 'React.Fragment' or 'Fragment'. */
|
|
22
|
-
// "jsxImportSource": "", /* Specify module specifier used to import the JSX factory functions when using 'jsx: react-jsx*'. */
|
|
23
|
-
// "reactNamespace": "", /* Specify the object invoked for 'createElement'. This only applies when targeting 'react' JSX emit. */
|
|
24
|
-
// "noLib": true, /* Disable including any library files, including the default lib.d.ts. */
|
|
25
|
-
// "useDefineForClassFields": true, /* Emit ECMAScript-standard-compliant class fields. */
|
|
26
|
-
// "moduleDetection": "auto", /* Control what method is used to detect module-format JS files. */
|
|
27
|
-
|
|
28
|
-
/* Modules */
|
|
29
|
-
"module": "commonjs" /* Specify what module code is generated. */,
|
|
30
|
-
"rootDir": "./typescript" /* Specify the root folder within your source files. */,
|
|
31
|
-
// "moduleResolution": "node10", /* Specify how TypeScript looks up a file from a given module specifier. */
|
|
32
|
-
// "baseUrl": "./", /* Specify the base directory to resolve non-relative module names. */
|
|
33
|
-
// "paths": {}, /* Specify a set of entries that re-map imports to additional lookup locations. */
|
|
34
|
-
// "rootDirs": [], /* Allow multiple folders to be treated as one when resolving modules. */
|
|
35
|
-
// "typeRoots": [], /* Specify multiple folders that act like './node_modules/@types'. */
|
|
36
|
-
// "types": [], /* Specify type package names to be included without being referenced in a source file. */
|
|
37
|
-
// "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */
|
|
38
|
-
// "moduleSuffixes": [], /* List of file name suffixes to search when resolving a module. */
|
|
39
|
-
// "allowImportingTsExtensions": true, /* Allow imports to include TypeScript file extensions. Requires '--moduleResolution bundler' and either '--noEmit' or '--emitDeclarationOnly' to be set. */
|
|
40
|
-
// "rewriteRelativeImportExtensions": true, /* Rewrite '.ts', '.tsx', '.mts', and '.cts' file extensions in relative import paths to their JavaScript equivalent in output files. */
|
|
41
|
-
// "resolvePackageJsonExports": true, /* Use the package.json 'exports' field when resolving package imports. */
|
|
42
|
-
// "resolvePackageJsonImports": true, /* Use the package.json 'imports' field when resolving imports. */
|
|
43
|
-
// "customConditions": [], /* Conditions to set in addition to the resolver-specific defaults when resolving imports. */
|
|
44
|
-
// "noUncheckedSideEffectImports": true, /* Check side effect imports. */
|
|
45
|
-
// "resolveJsonModule": true, /* Enable importing .json files. */
|
|
46
|
-
// "allowArbitraryExtensions": true, /* Enable importing files with any extension, provided a declaration file is present. */
|
|
47
|
-
// "noResolve": true, /* Disallow 'import's, 'require's or '<reference>'s from expanding the number of files TypeScript should add to a project. */
|
|
48
|
-
|
|
49
|
-
/* JavaScript Support */
|
|
50
|
-
// "allowJs": true, /* Allow JavaScript files to be a part of your program. Use the 'checkJS' option to get errors from these files. */
|
|
51
|
-
// "checkJs": true, /* Enable error reporting in type-checked JavaScript files. */
|
|
52
|
-
// "maxNodeModuleJsDepth": 1, /* Specify the maximum folder depth used for checking JavaScript files from 'node_modules'. Only applicable with 'allowJs'. */
|
|
53
|
-
|
|
54
|
-
/* Emit */
|
|
55
|
-
"declaration": true, /* Generate .d.ts files from TypeScript and JavaScript files in your project. */
|
|
56
|
-
// "declarationMap": true, /* Create sourcemaps for d.ts files. */
|
|
57
|
-
// "emitDeclarationOnly": true, /* Only output d.ts files and not JavaScript files. */
|
|
58
|
-
// "sourceMap": true, /* Create source map files for emitted JavaScript files. */
|
|
59
|
-
// "inlineSourceMap": true, /* Include sourcemap files inside the emitted JavaScript. */
|
|
60
|
-
// "noEmit": true, /* Disable emitting files from a compilation. */
|
|
61
|
-
// "outFile": "./", /* Specify a file that bundles all outputs into one JavaScript file. If 'declaration' is true, also designates a file that bundles all .d.ts output. */
|
|
62
|
-
"outDir": "./out-tsc" /* Specify an output folder for all emitted files. */,
|
|
63
|
-
// "removeComments": true, /* Disable emitting comments. */
|
|
64
|
-
// "importHelpers": true, /* Allow importing helper functions from tslib once per project, instead of including them per-file. */
|
|
65
|
-
// "downlevelIteration": true, /* Emit more compliant, but verbose and less performant JavaScript for iteration. */
|
|
66
|
-
// "sourceRoot": "", /* Specify the root path for debuggers to find the reference source code. */
|
|
67
|
-
// "mapRoot": "", /* Specify the location where debugger should locate map files instead of generated locations. */
|
|
68
|
-
// "inlineSources": true, /* Include source code in the sourcemaps inside the emitted JavaScript. */
|
|
69
|
-
// "emitBOM": true, /* Emit a UTF-8 Byte Order Mark (BOM) in the beginning of output files. */
|
|
70
|
-
// "newLine": "crlf", /* Set the newline character for emitting files. */
|
|
71
|
-
// "stripInternal": true, /* Disable emitting declarations that have '@internal' in their JSDoc comments. */
|
|
72
|
-
// "noEmitHelpers": true, /* Disable generating custom helper functions like '__extends' in compiled output. */
|
|
73
|
-
// "noEmitOnError": true, /* Disable emitting files if any type checking errors are reported. */
|
|
74
|
-
// "preserveConstEnums": true, /* Disable erasing 'const enum' declarations in generated code. */
|
|
75
|
-
// "declarationDir": "./", /* Specify the output directory for generated declaration files. */
|
|
76
|
-
|
|
77
|
-
/* Interop Constraints */
|
|
78
|
-
// "isolatedModules": true, /* Ensure that each file can be safely transpiled without relying on other imports. */
|
|
79
|
-
// "verbatimModuleSyntax": true, /* Do not transform or elide any imports or exports not marked as type-only, ensuring they are written in the output file's format based on the 'module' setting. */
|
|
80
|
-
// "isolatedDeclarations": true, /* Require sufficient annotation on exports so other tools can trivially generate declaration files. */
|
|
81
|
-
// "erasableSyntaxOnly": true, /* Do not allow runtime constructs that are not part of ECMAScript. */
|
|
82
|
-
// "allowSyntheticDefaultImports": true, /* Allow 'import x from y' when a module doesn't have a default export. */
|
|
83
|
-
"esModuleInterop": true /* Emit additional JavaScript to ease support for importing CommonJS modules. This enables 'allowSyntheticDefaultImports' for type compatibility. */,
|
|
84
|
-
// "preserveSymlinks": true, /* Disable resolving symlinks to their realpath. This correlates to the same flag in node. */
|
|
85
|
-
"forceConsistentCasingInFileNames": true /* Ensure that casing is correct in imports. */,
|
|
86
|
-
|
|
87
|
-
/* Type Checking */
|
|
88
|
-
"strict": true /* Enable all strict type-checking options. */,
|
|
89
|
-
// "noImplicitAny": true, /* Enable error reporting for expressions and declarations with an implied 'any' type. */
|
|
90
|
-
// "strictNullChecks": true, /* When type checking, take into account 'null' and 'undefined'. */
|
|
91
|
-
// "strictFunctionTypes": true, /* When assigning functions, check to ensure parameters and the return values are subtype-compatible. */
|
|
92
|
-
// "strictBindCallApply": true, /* Check that the arguments for 'bind', 'call', and 'apply' methods match the original function. */
|
|
93
|
-
// "strictPropertyInitialization": true, /* Check for class properties that are declared but not set in the constructor. */
|
|
94
|
-
// "strictBuiltinIteratorReturn": true, /* Built-in iterators are instantiated with a 'TReturn' type of 'undefined' instead of 'any'. */
|
|
95
|
-
// "noImplicitThis": true, /* Enable error reporting when 'this' is given the type 'any'. */
|
|
96
|
-
// "useUnknownInCatchVariables": true, /* Default catch clause variables as 'unknown' instead of 'any'. */
|
|
97
|
-
// "alwaysStrict": true, /* Ensure 'use strict' is always emitted. */
|
|
98
|
-
// "noUnusedLocals": true, /* Enable error reporting when local variables aren't read. */
|
|
99
|
-
// "noUnusedParameters": true, /* Raise an error when a function parameter isn't read. */
|
|
100
|
-
// "exactOptionalPropertyTypes": true, /* Interpret optional property types as written, rather than adding 'undefined'. */
|
|
101
|
-
// "noImplicitReturns": true, /* Enable error reporting for codepaths that do not explicitly return in a function. */
|
|
102
|
-
// "noFallthroughCasesInSwitch": true, /* Enable error reporting for fallthrough cases in switch statements. */
|
|
103
|
-
// "noUncheckedIndexedAccess": true, /* Add 'undefined' to a type when accessed using an index. */
|
|
104
|
-
// "noImplicitOverride": true, /* Ensure overriding members in derived classes are marked with an override modifier. */
|
|
105
|
-
// "noPropertyAccessFromIndexSignature": true, /* Enforces using indexed accessors for keys declared using an indexed type. */
|
|
106
|
-
// "allowUnusedLabels": true, /* Disable error reporting for unused labels. */
|
|
107
|
-
// "allowUnreachableCode": true, /* Disable error reporting for unreachable code. */
|
|
108
|
-
|
|
109
|
-
/* Completeness */
|
|
110
|
-
// "skipDefaultLibCheck": true, /* Skip type checking .d.ts files that are included with TypeScript. */
|
|
111
|
-
"skipLibCheck": true /* Skip type checking all .d.ts files. */
|
|
112
|
-
},
|
|
113
|
-
"include": ["typescript/**/*.ts"],
|
|
114
|
-
"exclude": ["node_modules", "out-tsc", "target", "dist", "**/*.spec.ts"]
|
|
115
|
-
}
|
package/typescript/bin/index.ts
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
import { spawn } from "child_process";
|
|
4
|
-
import * as path from "path";
|
|
5
|
-
|
|
6
|
-
let binaryName: string;
|
|
7
|
-
|
|
8
|
-
switch (process.platform) {
|
|
9
|
-
case "win32":
|
|
10
|
-
binaryName = "devalang-x86_64-pc-windows-msvc.exe";
|
|
11
|
-
break;
|
|
12
|
-
case "darwin":
|
|
13
|
-
binaryName = "devalang-x86_64-apple-darwin";
|
|
14
|
-
break;
|
|
15
|
-
case "linux":
|
|
16
|
-
binaryName = "devalang-x86_64-unknown-linux-gnu";
|
|
17
|
-
break;
|
|
18
|
-
default:
|
|
19
|
-
console.error(`Unsupported platform: ${process.platform}`);
|
|
20
|
-
process.exit(1);
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
const binaryPath = path.join(__dirname, binaryName);
|
|
24
|
-
|
|
25
|
-
const args = process.argv.slice(2);
|
|
26
|
-
const child = spawn(binaryPath, args, { stdio: "inherit" });
|
|
27
|
-
|
|
28
|
-
child.on("exit", (code) => process.exit(code ?? 1));
|
|
@@ -1,94 +0,0 @@
|
|
|
1
|
-
import { ParseResult } from "../types/result";
|
|
2
|
-
import { DebugResult } from "../types/result";
|
|
3
|
-
|
|
4
|
-
let wasmPkg: any = undefined;
|
|
5
|
-
try {
|
|
6
|
-
// prefer runtime pkg generated by wasm-pack when available
|
|
7
|
-
// require at runtime so the package can be used even if wasm hasn't been built
|
|
8
|
-
// (this keeps tests and consumers robust).
|
|
9
|
-
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
10
|
-
wasmPkg = require("../../pkg/devalang_core");
|
|
11
|
-
} catch (_e) {
|
|
12
|
-
wasmPkg = undefined;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
/**
|
|
16
|
-
* Parses the user code.
|
|
17
|
-
* @param entry_path The entry path for the code.
|
|
18
|
-
* @param source The source code to parse.
|
|
19
|
-
* @returns ParseResult | any
|
|
20
|
-
*/
|
|
21
|
-
export function parse(entry_path: string, source: string): ParseResult | any {
|
|
22
|
-
if (wasmPkg && typeof wasmPkg.parse === "function") {
|
|
23
|
-
return wasmPkg.parse(entry_path, source);
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
throw new Error(
|
|
27
|
-
"WASM binding 'parse' not available. Build the wasm package or use the JS runtime."
|
|
28
|
-
);
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
/**
|
|
32
|
-
* Renders the debug information for the user code.
|
|
33
|
-
* @param user_code The user-provided code to render debug information for.
|
|
34
|
-
* @returns DebugResult | any
|
|
35
|
-
*/
|
|
36
|
-
export function debug_render(user_code: string): DebugResult | any {
|
|
37
|
-
if (wasmPkg && typeof wasmPkg.debug_render === "function") {
|
|
38
|
-
return wasmPkg.debug_render(user_code);
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
throw new Error(
|
|
42
|
-
"WASM binding 'debug_render' not available. Build the wasm package or use the JS runtime."
|
|
43
|
-
);
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
/**
|
|
47
|
-
* Renders audio from the user code.
|
|
48
|
-
* @param user_code The user-provided code to render audio from.
|
|
49
|
-
* @returns Float32Array
|
|
50
|
-
*/
|
|
51
|
-
export function render_audio(user_code: string): Float32Array {
|
|
52
|
-
if (wasmPkg && typeof wasmPkg.render_audio === "function") {
|
|
53
|
-
return wasmPkg.render_audio(user_code);
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
// Fallback: indicate missing wasm with an empty buffer rather than breaking consumers.
|
|
57
|
-
return new Float32Array(0);
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
/**
|
|
61
|
-
* Register a JS callback to receive playhead events { time, line, column } during playback.
|
|
62
|
-
* The callback will be called with a single object argument.
|
|
63
|
-
* @param cb The callback function to register.
|
|
64
|
-
* @returns void
|
|
65
|
-
*/
|
|
66
|
-
export function register_playhead_callback(cb: (ev: { time: number; line: number; column: number }) => void) {
|
|
67
|
-
if (wasmPkg && typeof wasmPkg.register_playhead_callback === "function") {
|
|
68
|
-
return wasmPkg.register_playhead_callback(cb);
|
|
69
|
-
}
|
|
70
|
-
// no-op fallback
|
|
71
|
-
return;
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
/**
|
|
75
|
-
* Collects playhead events that have been recorded during playback.
|
|
76
|
-
* @returns Array of playhead events { time, line, column }.
|
|
77
|
-
*/
|
|
78
|
-
export function collect_playhead_events() {
|
|
79
|
-
if (wasmPkg && typeof wasmPkg.collect_playhead_events === "function") {
|
|
80
|
-
return wasmPkg.collect_playhead_events();
|
|
81
|
-
}
|
|
82
|
-
return [];
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
/**
|
|
86
|
-
* Unregisters the JS callback for playhead events.
|
|
87
|
-
* @returns void
|
|
88
|
-
*/
|
|
89
|
-
export function unregister_playhead_callback() {
|
|
90
|
-
if (wasmPkg && typeof wasmPkg.unregister_playhead_callback === "function") {
|
|
91
|
-
return wasmPkg.unregister_playhead_callback();
|
|
92
|
-
}
|
|
93
|
-
return;
|
|
94
|
-
}
|
package/typescript/core/index.ts
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Represents a plugin export.
|
|
3
|
-
*/
|
|
4
|
-
export interface PluginExport {
|
|
5
|
-
name: string;
|
|
6
|
-
kind: string;
|
|
7
|
-
default?: any;
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* Represents a plugin.
|
|
12
|
-
*/
|
|
13
|
-
export interface PluginInfo {
|
|
14
|
-
author: string;
|
|
15
|
-
name: string;
|
|
16
|
-
version?: string;
|
|
17
|
-
description?: string;
|
|
18
|
-
exports: PluginExport[];
|
|
19
|
-
}
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Represents an error that occurred during parsing.
|
|
3
|
-
*/
|
|
4
|
-
export interface ErrorResult {
|
|
5
|
-
message: string;
|
|
6
|
-
line: number;
|
|
7
|
-
column: number;
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* Represents the result of parsing user code.
|
|
12
|
-
*/
|
|
13
|
-
export interface ParseResult {
|
|
14
|
-
ok: boolean;
|
|
15
|
-
ast: string;
|
|
16
|
-
errors: ErrorResult[];
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
/**
|
|
20
|
-
* Represents the result of debugging user code.
|
|
21
|
-
*/
|
|
22
|
-
export interface DebugResult {
|
|
23
|
-
samples_len: number;
|
|
24
|
-
any_nonzero: boolean;
|
|
25
|
-
ast: string;
|
|
26
|
-
note_count: number;
|
|
27
|
-
global_vars: string[];
|
|
28
|
-
statements_count: number;
|
|
29
|
-
}
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
import { Value, Duration } from "./value";
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Represents a statement kind in the code.
|
|
5
|
-
*/
|
|
6
|
-
export type StatementKind =
|
|
7
|
-
| { kind: "Tempo" }
|
|
8
|
-
| { kind: "Bank"; alias?: string }
|
|
9
|
-
| { kind: "Print" }
|
|
10
|
-
| { kind: "Load"; source: string; alias: string }
|
|
11
|
-
| { kind: "Use"; name: string; alias?: string }
|
|
12
|
-
| { kind: "Let"; name: string }
|
|
13
|
-
| { kind: "Automate"; target: string }
|
|
14
|
-
| { kind: "ArrowCall"; target: string; method: string; args: Value[] }
|
|
15
|
-
| { kind: "Function"; name: string; parameters: string[]; body: Statement[] }
|
|
16
|
-
| { kind: "Synth" }
|
|
17
|
-
| { kind: "Trigger"; entity: string; duration: Duration; effects?: Value }
|
|
18
|
-
| { kind: "Sleep" }
|
|
19
|
-
| { kind: "Call"; name: string; args: Value[] }
|
|
20
|
-
| { kind: "Spawn"; name: string; args: Value[] }
|
|
21
|
-
| { kind: "Loop" }
|
|
22
|
-
| { kind: "Group" }
|
|
23
|
-
| { kind: "Include"; path: string }
|
|
24
|
-
| { kind: "Export"; names: string[]; source: string }
|
|
25
|
-
| { kind: "Import"; names: string[]; source: string }
|
|
26
|
-
| { kind: "If" }
|
|
27
|
-
| { kind: "Else" }
|
|
28
|
-
| { kind: "ElseIf" }
|
|
29
|
-
| { kind: "Comment" }
|
|
30
|
-
| { kind: "Indent" }
|
|
31
|
-
| { kind: "Dedent" }
|
|
32
|
-
| { kind: "NewLine" }
|
|
33
|
-
| { kind: "On"; event: string; args?: Value[]; body: Statement[] }
|
|
34
|
-
| { kind: "Emit"; event: string; payload?: Value }
|
|
35
|
-
| { kind: "Unknown" }
|
|
36
|
-
| { kind: "Error"; message: string };
|
|
37
|
-
|
|
38
|
-
/**
|
|
39
|
-
* Represents a statement in the code.
|
|
40
|
-
*/
|
|
41
|
-
export interface Statement {
|
|
42
|
-
kind: StatementKind;
|
|
43
|
-
value: Value;
|
|
44
|
-
indent: number;
|
|
45
|
-
line: number;
|
|
46
|
-
column: number;
|
|
47
|
-
}
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import { Statement } from "./statement";
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Represents a duration in the code.
|
|
5
|
-
*/
|
|
6
|
-
export type Duration =
|
|
7
|
-
| { Number: number }
|
|
8
|
-
| { Identifier: string }
|
|
9
|
-
| { Beat: string }
|
|
10
|
-
| { Auto: null };
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* Represents a value in the code.
|
|
14
|
-
*/
|
|
15
|
-
export type Value =
|
|
16
|
-
| { Boolean: boolean }
|
|
17
|
-
| { Number: number }
|
|
18
|
-
| { Duration: Duration }
|
|
19
|
-
| { Identifier: string }
|
|
20
|
-
| { String: string }
|
|
21
|
-
| { Array: Value[] }
|
|
22
|
-
| { Map: Record<string, Value> }
|
|
23
|
-
| { Block: Statement[] }
|
|
24
|
-
| { Sample: string }
|
|
25
|
-
| { Beat: string }
|
|
26
|
-
| { Statement: Statement }
|
|
27
|
-
| { StatementKind: any }
|
|
28
|
-
| { Unknown: null }
|
|
29
|
-
| null;
|
package/typescript/index.ts
DELETED