Pure MoonBit Source Map v3 parser, encoder, validator and lookup toolkit
moon add Derk2006/sourcemapDerk2006/sourcemaptest {
let map = @sourcemap.SourceMap::SourceMap(
["src/main.mbt"],
[@sourcemap.MappingSegment::mapped(0, 0, 0, 3, 2, name_index=0)],
names=["main"],
)
inspect(
map.explain_generated(0, 4),
content="generated 0:4 -> src/main.mbt:3:2 name=main",
)
}moon check
moon build
moon test
moon run cmd/main
moon publish --dry-runpub struct CoverageReport {
lines : Array[CoverageLine]
total_columns : Int
mapped_columns : Int
unmapped_columns : Int
mapped_ratio : Double
} derive(Eq, ToJson, Debug)fn GeneratedRange::GeneratedRange(start_line : Int, start_column? : Int, end_line? : Int, end_column? : Int) -> GeneratedRangepub struct MappingIndex {
segments : Array[MappingSegment]
lines : Array[LineIndexEntry]
} derive(Eq, ToJson, Debug)fn MappingIndex::find_generated_exact(self : MappingIndex, line : Int, column : Int) -> MappingSegment?fn MappingIndex::find_generated_floor(self : MappingIndex, line : Int, column : Int) -> MappingSegment?fn MappingSegment::mapped(generated_line : Int, generated_column : Int, source_index : Int, original_line : Int, original_column : Int, name_index? : Int) -> MappingSegmentfn OriginalPosition::OriginalPosition(source : StringView, line : Int, column : Int, name? : String) -> OriginalPositionfn OriginalRange::OriginalRange(source : StringView, start_line : Int, start_column? : Int, end_line? : Int, end_column? : Int) -> OriginalRangefn OriginalRange::contains(self : OriginalRange, source : StringView, line : Int, column : Int) -> Boolpub struct SegmentTrace {
line : Int
segment : Int
start_offset : Int
end_offset : Int
raw : String
values : Array[Int]
decoded : MappingSegment?
error : String?
} derive(Eq, ToJson, Debug)fn SourceMap::compose_summary(self : SourceMap, previous : SourceMap, intermediate_source? : String) -> ComposeSummaryfn SourceMap::coverage_for_lengths(self : SourceMap, line_lengths : ArrayView[Int]) -> CoverageReportfn SourceMap::find_generated(self : SourceMap, source : StringView, original_line : Int, original_column : Int) -> GeneratedPosition?fn SourceMap::find_original(self : SourceMap, generated_line : Int, generated_column : Int) -> OriginalPosition?fn SourceMap::lint(self : SourceMap, line_lengths? : ArrayView[Int], options? : SourceMapLintOptions) -> Array[Diagnostic]fn SourceMap::lint_report(self : SourceMap, line_lengths? : ArrayView[Int], options? : SourceMapLintOptions) -> Stringfn SourceMap::lint_summary(self : SourceMap, line_lengths? : ArrayView[Int], options? : SourceMapLintOptions) -> LintSummaryfn SourceMap::passes_lint(self : SourceMap, line_lengths? : ArrayView[Int], options? : SourceMapLintOptions) -> Boolfn SourceMap::slice_generated_range(self : SourceMap, range : GeneratedRange, rebase? : Bool) -> SourceMapfn SourceMap::slice_original_range(self : SourceMap, range : OriginalRange, keep_unmapped? : Bool) -> SourceMapfn SourceMapBuilder::add_line_start(self : SourceMapBuilder, generated_line : Int, source : StringView, original_line : Int) -> Unitfn SourceMapBuilder::add_mapping(self : SourceMapBuilder, generated_line : Int, generated_column : Int, source : StringView, original_line : Int, original_column : Int, name? : StringView) -> Unitfn SourceMapBuilder::add_unmapped(self : SourceMapBuilder, generated_line : Int, generated_column : Int) -> Unitfn SourceMapBuilder::append_segments(self : SourceMapBuilder, segments : ArrayView[MappingSegment]) -> Unitfn SourceMapBuilder::merge_from(self : SourceMapBuilder, other : SourceMap, generated_line_offset? : Int, generated_column_offset? : Int) -> Unitfn SourceMapBuilder::set_source_content(self : SourceMapBuilder, source : StringView, content : StringView) -> Intpub(all) enum SourceMapError {
InvalidBase64(char~ : Char, offset~ : Int)
TruncatedVlq(offset~ : Int)
VlqOverflow(offset~ : Int)
InvalidSegment(line~ : Int, segment~ : Int, values~ : Int, reason~ : String)
JsonParse(message~ : String)
JsonDecode(path~ : String, expected~ : String)
MissingField(field~ : String)
InvalidField(field~ : String, message~ : String)
} derive(Eq, ToJson, Debug)fn SourceMapLintOptions::SourceMapLintOptions(require_file? : Bool, require_sorted_mappings? : Bool, require_no_duplicate_sources? : Bool, require_no_duplicate_names? : Bool, require_all_sources_used? : Bool, require_all_names_used? : Bool, min_mapped_ratio? : Double, max_unmapped_segments? : Int) -> SourceMapLintOptionspub struct SymbolicatedFrame {
generated : StackFrame
original : OriginalPosition?
} derive(Eq, ToJson, Debug)fn ValidationPolicy::ValidationPolicy(require_file? : Bool, require_sources_content? : Bool, forbid_empty_sources? : Bool, forbid_empty_names? : Bool, allow_unmapped_segments? : Bool, allow_ignore_list? : Bool, max_segment_count? : Int, max_source_count? : Int) -> ValidationPolicyfn ValidationPolicy::with_limits(self : ValidationPolicy, max_segment_count? : Int, max_source_count? : Int) -> ValidationPolicyfn ValidationPolicy::with_unmapped_segments(self : ValidationPolicy, allow : Bool) -> ValidationPolicyfn generated_position_to_offset(input : StringView, line : Int, column : Int) -> Int?Pure MoonBit Source Map v3 parser, encoder, validator and lookup toolkit