@onda-lang/wasm-compiler 0.6.0 → 0.7.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 CHANGED
@@ -25,13 +25,13 @@ Release builds post-optimize the Rust frontend Wasm with the package's pinned Bi
25
25
  `dist/build.json`, and fails if the pass does not reduce the shipped module. Generated DSP modules
26
26
  are already optimized independently by the runtime Binaryen O4 pipeline.
27
27
 
28
- ## Projects
28
+ ## Source workspaces
29
29
 
30
30
  Project compilation resolves imports and includes entirely from the supplied source map and the
31
31
  embedded standard library:
32
32
 
33
33
  ```js
34
- const { artifact, sourceFiles } = await compiler.compileProject({
34
+ const { artifact, sourceFiles } = await compiler.compileWorkspace({
35
35
  entry: "main.onda",
36
36
  sources: {
37
37
  "main.onda": mainSource,
@@ -53,6 +53,55 @@ watch registrations while the project is temporarily invalid. `unresolvedSourceF
53
53
  referenced non-standard-library candidates which were not present, allowing hosts to watch for their
54
54
  creation without treating them as contributing compilation inputs.
55
55
 
56
+ ## Portable project images
57
+
58
+ Successful workspace compilation also returns `sourceGraph`, the exact documents and resolved
59
+ import/include edges used for that build. Combine it with canonical typed buffers to create a
60
+ portable project image:
61
+
62
+ ```js
63
+ const compiled = await compiler.compileWorkspace(workspace, options);
64
+ const sample = await compiler.encodeBufferAsset({
65
+ element: "f32",
66
+ frames: samples.length,
67
+ channels: 1,
68
+ sampleRate: 48_000,
69
+ data: new Float32Array(samples),
70
+ });
71
+ const image = await compiler.createProjectImage(
72
+ compiled.sourceGraph,
73
+ new Map([["sample", sample]]),
74
+ );
75
+
76
+ const replayed = await compiler.compileProjectImage(image.bytes, options);
77
+ const exported = await compiler.materializeProjectImage(
78
+ image.bytes,
79
+ new Map([["sample", "recording.wav"]]),
80
+ );
81
+
82
+ // WAV and .ondabuffer inputs share the same canonical Rust decoder.
83
+ const decoded = await compiler.decodeBufferFile(fileBytes, "sample.wav");
84
+ ```
85
+
86
+ Project-image buffer maps use physical slot names. A scalar declaration uses its source name;
87
+ fixed arrays use names such as `bank[0]` and `bank[1]`. Omitted slots remain unbound and neutral at
88
+ runtime, so an image contains only the assets the project actually supplies.
89
+
90
+ `materializeProjectImage` emits Onda's canonical publication layout: `code/main.onda`, meaningful
91
+ source subdirectories below `code/`, and typed assets below `assets/`.
92
+ `loadProjectFiles(files, projectFilePath?)` performs the reverse operation from a complete map of
93
+ extracted project-relative files. Pass the `.ondaproject` path when the map contains multiple
94
+ projects; manifests may occur in any directory and resolve their paths relative to that directory.
95
+ Omitting it requires an unambiguous manifest. Loading rejects a reachable source graph
96
+ that cannot be loaded and parsed. Portable project exports must be created from a successful
97
+ compilation, as in the example above. `inspectProjectImage` validates an image and returns its
98
+ source graph, logical buffer bindings, asset metadata, and content digest. `projectCapabilities`
99
+ reports the immutable image, buffer-container, and embedded-standard-library versions. The worker
100
+ client exposes the same methods and transfers binary payloads rather than cloning them.
101
+
102
+ All canonical project and `.ondabuffer` serialization is implemented by the same Rust `onda_project`
103
+ crate used by the native C API. JavaScript only adapts maps, typed arrays, and worker messages.
104
+
56
105
  ## Browser workers
57
106
 
58
107
  Compilation is CPU-intensive. Use the built-in worker client in interactive browser applications:
@@ -106,7 +155,7 @@ await compiler.sendLspMessage({
106
155
  Open every virtual project file with `didOpen`; imports and includes resolve from those overlays and
107
156
  the embedded standard library. Diagnostics, semantic tokens, completion, hover, definitions, and
108
157
  document symbols use the native server implementation. The browser transport does not run MIR or a
109
- backend until the host explicitly calls `compileSource` or `compileProject`.
158
+ backend until the host explicitly calls `compileSource` or `compileWorkspace`.
110
159
 
111
160
  ## CLI
112
161
 
package/bin/onda-wasm.js CHANGED
@@ -72,7 +72,7 @@ export async function main(argv = process.argv.slice(2)) {
72
72
  const watOutput = parsed.watOut === undefined ? undefined : resolve(parsed.watOut);
73
73
  const compiler = await createCompiler();
74
74
  try {
75
- const { artifact } = await compiler.compileProject({ entry, sources }, {
75
+ const { artifact } = await compiler.compileWorkspace({ entry, sources }, {
76
76
  sampleRate: parsed.sampleRate,
77
77
  blockSize: parsed.blockSize,
78
78
  codegen: {
@@ -1,2 +1,2 @@
1
1
  // Synchronized from format-versions.json; do not edit this copy directly.
2
- export const SUPPORTED_MIR_SCHEMA_VERSION = 3;
2
+ export const SUPPORTED_MIR_SCHEMA_VERSION = 4;