Data types that cross the MoonBit-to-JavaScript boundary: the view tree, diff patches, user intents, and diagnostics. Everything defined here is serializable to JSON and has no dependency on the CRDT internals.
This package is the stable contract between the MoonBit engine and the TypeScript/React frontend. It also contains the two conversion functions that build a ViewNode tree from a ProjNode tree or a pretty-printer Layout.
ViewNode— tree node sent to the frontend; carriesid,kind_tag,label,text,text_range,token_spans, andchildrenViewPatch— incremental update:TextChange,ReplaceNode,InsertChild,RemoveChild,UpdateNode,SetDecorations,SetDiagnostics,SetSelection,SelectNode,FullTreeUserIntent— frontend-originated action:TextEdit,StructuralEdit,SelectNode,SetCursor,Undo,Redo,CommitEditDecoration/Diagnostic/Severity— CodeMirror decoration and lint annotationsproj_to_view_node— converts aProjNode[T]+SourceMapinto aViewNodelayout_to_view_tree— converts a pretty-printerLayoutinto aViewNodetree
editor— producesViewPatchsequences viacompute_view_patchesandcompute_pretty_patcheslang/lambda/companion— passesViewAnnotationarrays intoproj_to_view_nodeffi/lambda,ffi/json,ffi/markdown— serializeViewPatch/ViewNodeto JSON for JavaScript- Root
moon.pkg(canopy module facade)
dowdiness/canopy/core—NodeId,ProjNode,SourceMapdowdiness/pretty—Layout,SyntaxCategorymoonbitlang/core/json—ToJson/FromJsonderivations
Stable wire format / public surface — changes here break the TypeScript frontend and require coordinated updates to the JS consumer side.
UserIntent implements both ToJson and FromJson — it is the one type that flows both directions across the FFI boundary. All other protocol types are output-only (MoonBit → JS).