1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
// =============================================================================
// bnto-core — The Foundation WASM Library
// =============================================================================
//
// Shared foundation for all Bnto WASM node crates: error types,
// the NodeProcessor trait, progress reporting, pipeline execution,
// and the node registry. This is an rlib -- it doesn't produce a
// .wasm file itself. That's the job of the bnto-wasm entry point.
// --- Public Modules ---
// These are the building blocks that node crates and the web app will use.
/// Controlled system access for processors that need external tools.
/// Browser gets `NoopContext`, CLI gets `NativeContext`, desktop gets `SandboxedContext`.
/// Error types for the WASM engine.
/// Every error that can happen during node execution is defined here.
/// Structured pipeline events — rich progress reporting for multi-node execution.
/// Powers per-node status highlighting in the editor, progress bars, and error display.
/// Definition JSON Schema — validates `.bnto.json` files.
/// Generates a JSON Schema (Draft 2020-12) describing the Definition structure
/// so any consumer can validate recipe files without reimplementing TS types.
/// Node metadata types — self-describing processor definitions.
/// Each processor declares its name, category, parameters, accepted MIME types,
/// and whether it runs in the browser. Powers the `node_catalog()` WASM export.
/// The pipeline executor — walks nodes, iterates files, chains outputs.
/// This is the engine's brain. See `.claude/strategy/engine-execution.md`.
/// Pipeline definition types — what the engine receives to execute.
/// Mirrors the TypeScript `PipelineDefinition` / `PipelineNode` types.
/// The NodeProcessor trait — the contract every node type must implement.
/// If you're building a new node (like image compression), you implement this.
/// Progress reporting — how nodes tell the UI "I'm 50% done".
/// Uses target-agnostic closures (no WASM dependency).
/// Node registry — maps node type keys (e.g., "image-compress") to processors.
/// Replaces the JS-side `wasmLoader.ts` registry.
// --- Re-exports ---
// These `pub use` statements let users import directly from the crate root.
// Instead of writing `use bnto_core::errors::BntoError`, they can write
// `use bnto_core::BntoError`. Convenience!
pub use ;
pub use definition_json_schema;
pub use BntoError;
pub use ;
pub use execute_pipeline;
pub use ;
pub use ;
pub use ;
pub use ProgressReporter;
pub use NodeRegistry;
// =============================================================================
// Shared Constants
// =============================================================================
//
// Constants used by multiple node crates live here so there's a single source
// of truth. When compress, resize, and convert all need the same default JPEG
// quality, defining it once in bnto-core prevents the values from drifting
// apart over time.
/// The current `.bnto.json` format version.
///
/// This must stay in sync with `CURRENT_FORMAT_VERSION` in `@bnto/nodes`.
/// The WASM engine uses this to verify that a definition it receives is
/// compatible with the node processors it has compiled in.
///
/// Semver rules: definitions with the same major version are compatible.
/// A definition at "1.3.0" works fine on an engine that supports "1.0.0".
pub const FORMAT_VERSION: &str = "1.0.0";
/// Default quality when not specified by the user (1-100 scale).
/// 80 is the industry sweet spot: significant file size savings with barely
/// noticeable quality loss for most photos. Used by all image operations
/// (compress, resize, convert).
pub const DEFAULT_QUALITY: u8 = 80;
// =============================================================================
// Utility Functions (Pure Rust — no WASM boundary)
// =============================================================================
//
// NOTE: setup(), version(), and greet() used to live here with #[wasm_bindgen]
// attributes. They've moved to the bnto-wasm entry point crate which is the
// single cdylib that produces the .wasm file for the browser. This crate is
// now purely an rlib (Rust library) — no JS exports.
//
// These utility functions remain available as regular Rust functions for use
// by other crates in the workspace and for testing.
/// Returns the version of the bnto-core crate.
// =============================================================================
// Tests
// =============================================================================