sourcemap

    Pure MoonBit Source Map v3 parser, encoder, validator and lookup toolkit

    sourcemap
    source-map
    vlq
    compiler
    debug
    Download zip
    Author
    Version
    0.1.1
    License
    MIT
    Last updated
    2 months ago
    Downloads
    46

    No dependencies

    #Derk2006/sourcemap

    Derk2006/sourcemap 是一个 MoonBit 原生 Source Map v3 工具库,提供 Base64 VLQ 编码解码、mappings 字段解析与生成、Source Map JSON 读写、位置查询、多阶段映射合成、范围裁剪、覆盖率统计、质量 lint 和可读报告。

    Source Map 是编译器、代码生成器、打包器、压缩器和 WASM 工具链常用的调试映射格式。本项目把这类能力做成可测试、可复用、无外部运行时依赖的 MoonBit 基础库,便于 MoonBit 生态中的编译器实验、构建工具和调试工具直接复用。

    #安装

    moon add Derk2006/sourcemap

    Mooncakes 包名:

    Derk2006/sourcemap

    #快速示例

    test {
    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-run

    #核心能力

    • Base64 VLQ:encode_vlq、decode_vlq、encode_vlq_values、decode_vlq_values
    • mappings 编解码:decode_mappings、encode_mappings、SourceMap::encoded_mappings
    • JSON 读写:SourceMap::from_json_string、SourceMap::to_json_string
    • 位置查询:find_original、find_generated、explain_generated
    • 校验诊断:validate、errors、warnings、ValidationPolicy
    • 统计报告:stats、source_summaries、report
    • Builder:SourceMapBuilder 自动维护 source/name 索引并支持合并片段
    • 索引与 span:index、spans、gaps_for_line、span_at
    • 范围裁剪:GeneratedRange、OriginalRange、slice_generated_range、slice_original_range
    • 多阶段合成:compose_with、compose_chain、compose_report
    • 质量门禁:SourceMapLintOptions、lint、lint_summary、lint_report
    • 覆盖率:coverage_for_lengths、coverage_for_text、coverage_text_report
    • 名称分析:name_uses、name_frequency、name_report
    • 差异分析:diff、SourceMapDiff::summary
    • 追踪调试:trace_vlq、trace_mappings、trace_mappings_report

    #适用场景

    • MoonBit 编译器实验和代码生成器输出 Source Map
    • 构建工具在 CI 中检查 sources、names、ignoreList 和 mappings 的一致性
    • 打包器或压缩器把多阶段 Source Map 合成为最终调试映射
    • 调试工具根据生成代码位置反查原始源码位置
    • 发布前裁剪 Source Map,只保留某个 bundle 片段或某个源文件区间
    • 构建报告统计每个源文件的映射覆盖情况

    #支持范围

    • Source Map v3 普通单文件 map
    • version、file、sourceRoot、sources、sourcesContent、names、mappings、ignoreList
    • 1 字段、4 字段和 5 字段 mapping segment
    • 生成位置到原始位置的最近段查询
    • 原始位置到生成位置的同源同线最近段查询
    • 多阶段 Source Map 合成
    • 生成范围和原始范围裁剪
    • CI lint、覆盖率报告和文本行表分析

    #暂不支持范围

    • sections 索引型 Source Map
    • 读取外部源码文件或远程 Source Map
    • 字符集探测和文件系统路径规范化
    • 与非 MoonBit 运行时的绑定层

    #开源与合规

    本项目采用 MIT 许可证。项目为原创 MoonBit 实现,不移植第三方源代码,不包含来源不明素材或私有代码。实现依据 Source Map v3 公开格式描述完成,核心功能全部使用 MoonBit 编写。

    #工程记录

    • 设计说明:docs/DESIGN.md
    • Mooncakes 非重复调研:docs/MOONCAKES_RESEARCH.md
    • 工单记录:docs/WORKLOG.md
    • 测试记录:docs/TEST_RECORD.md
    • 版本发布记录:docs/RELEASE_NOTES.md
    • 更新日志:CHANGELOG.md

    ComposeSummary

    pub struct ComposeSummary {
    input_segments : Int
    composed_segments : Int
    preserved_segments : Int
    unmapped_segments : Int
    missing_intermediate_segments : Int
    } derive(Eq, ToJson,
    Debug
    )

    ComposeSummary::summary

    fn ComposeSummary::summary(self : ComposeSummary) -> String

    CoverageLine

    pub struct CoverageLine {
    line : Int
    line_length : Int
    mapped_columns : Int
    unmapped_columns : Int
    gap_count : Int
    mapped_ratio : Double
    } derive(Eq, ToJson,
    Debug
    )

    CoverageLine::summary

    fn CoverageLine::summary(self : CoverageLine) -> String

    CoverageReport

    pub struct CoverageReport {
    lines : Array[CoverageLine]
    total_columns : Int
    mapped_columns : Int
    unmapped_columns : Int
    mapped_ratio : Double
    } derive(Eq, ToJson,
    Debug
    )

    CoverageReport::render

    fn CoverageReport::render(self : CoverageReport) -> String

    CoverageReport::summary

    fn CoverageReport::summary(self : CoverageReport) -> String

    Diagnostic

    pub struct Diagnostic {
    severity : String
    code : String
    path : String
    message : String
    } derive(Eq, ToJson,
    Debug
    )

    Validation diagnostic. severity is "error" or "warning"; path points at the field or mapping segment that triggered the diagnostic.

    GeneratedGap

    pub struct GeneratedGap {
    line : Int
    start_column : Int
    end_column : Int?
    } derive(Eq, ToJson,
    Debug
    )

    GeneratedLineInfo

    pub struct GeneratedLineInfo {
    line : Int
    start_offset : Int
    end_offset : Int
    length : Int
    has_line_break : Bool
    } derive(Eq, ToJson,
    Debug
    )

    GeneratedLineInfo::summary

    fn GeneratedLineInfo::summary(self : GeneratedLineInfo) -> String

    GeneratedPosition

    pub struct GeneratedPosition {
    line : Int
    column : Int
    } derive(Eq, ToJson,
    Debug
    )

    Position in generated code. Lines and columns are zero-based, matching the Source Map v3 format.

    GeneratedPosition::GeneratedPosition

    fn GeneratedPosition::GeneratedPosition(line : Int, column : Int) -> GeneratedPosition

    GeneratedRange

    pub struct GeneratedRange {
    start_line : Int
    start_column : Int
    end_line : Int?
    end_column : Int?
    } derive(Eq, ToJson,
    Debug
    )

    Half-open generated-code range. end_line=None means the range has no upper bound. When end_line is present and end_column=None, the range ends at the start of end_line.

    GeneratedRange::GeneratedRange

    fn GeneratedRange::GeneratedRange(start_line : Int, start_column? : Int, end_line? : Int, end_column? : Int) -> GeneratedRange

    GeneratedRange::contains

    fn GeneratedRange::contains(self : GeneratedRange, line : Int, column : Int) -> Bool

    GeneratedRange::is_empty

    fn GeneratedRange::is_empty(self : GeneratedRange) -> Bool

    GeneratedSpan

    pub struct GeneratedSpan {
    line : Int
    start_column : Int
    end_column : Int?
    source_index : Int?
    original_line : Int?
    original_column : Int?
    name_index : Int?
    } derive(Eq, ToJson,
    Debug
    )

    A generated-code span derived from adjacent mapping segments on the same generated line. end_column=None means the span extends to the end of line.

    GeneratedSpan::contains

    fn GeneratedSpan::contains(self : GeneratedSpan, line : Int, column : Int) -> Bool

    GeneratedSpan::width_hint

    fn GeneratedSpan::width_hint(self : GeneratedSpan, fallback_end : Int) -> Int

    LineIndexEntry

    pub struct LineIndexEntry {
    line : Int
    start : Int
    end : Int
    } derive(Eq, ToJson,
    Debug
    )

    LineSummary

    pub struct LineSummary {
    line : Int
    segment_count : Int
    mapped_segment_count : Int
    unmapped_segment_count : Int
    first_column : Int?
    last_column : Int?
    } derive(Eq, ToJson,
    Debug
    )

    LintSummary

    pub struct LintSummary {
    errors : Int
    warnings : Int
    mapped_ratio : Double
    unused_sources : Int
    unused_names : Int
    duplicate_sources : Int
    duplicate_names : Int
    } derive(Eq, ToJson,
    Debug
    )

    LintSummary::passes

    fn LintSummary::passes(self : LintSummary) -> Bool

    LintSummary::summary

    fn LintSummary::summary(self : LintSummary) -> String

    MappingIndex

    pub struct MappingIndex {
    segments : Array[MappingSegment]
    lines : Array[LineIndexEntry]
    } derive(Eq, ToJson,
    Debug
    )

    MappingIndex::entry_for_line

    fn MappingIndex::entry_for_line(self : MappingIndex, line : Int) -> LineIndexEntry?

    MappingIndex::find_generated_exact

    fn MappingIndex::find_generated_exact(self : MappingIndex, line : Int, column : Int) -> MappingSegment?

    MappingIndex::find_generated_floor

    fn MappingIndex::find_generated_floor(self : MappingIndex, line : Int, column : Int) -> MappingSegment?

    MappingIndex::first_segment_for_line

    fn MappingIndex::first_segment_for_line(self : MappingIndex, line : Int) -> MappingSegment?

    MappingIndex::generated_line_numbers

    fn MappingIndex::generated_line_numbers(self : MappingIndex) -> Array[Int]

    MappingIndex::last_segment_for_line

    fn MappingIndex::last_segment_for_line(self : MappingIndex, line : Int) -> MappingSegment?

    MappingIndex::line_count

    fn MappingIndex::line_count(self : MappingIndex) -> Int

    MappingIndex::line_has_mappings

    fn MappingIndex::line_has_mappings(self : MappingIndex, line : Int) -> Bool

    MappingIndex::line_summary

    fn MappingIndex::line_summary(self : MappingIndex, line : Int) -> LineSummary

    MappingIndex::mapped_segments

    fn MappingIndex::mapped_segments(self : MappingIndex) -> Array[MappingSegment]

    MappingIndex::named_segments

    fn MappingIndex::named_segments(self : MappingIndex) -> Array[MappingSegment]

    MappingIndex::segment_count

    fn MappingIndex::segment_count(self : MappingIndex) -> Int

    MappingIndex::segments_for_line

    fn MappingIndex::segments_for_line(self : MappingIndex, line : Int) -> Array[MappingSegment]

    MappingIndex::summaries

    fn MappingIndex::summaries(self : MappingIndex) -> Array[LineSummary]

    MappingIndex::unmapped_segments

    fn MappingIndex::unmapped_segments(self : MappingIndex) -> Array[MappingSegment]

    MappingSegment

    pub struct MappingSegment {
    generated_line : Int
    generated_column : Int
    source_index : Int?
    original_line : Int?
    original_column : Int?
    name_index : Int?
    } derive(Eq, ToJson,
    Debug
    )

    A decoded mapping segment. A segment with only generated fields is an unmapped generated span; mapped segments carry a source index and original coordinates, plus an optional name index.

    MappingSegment::generated_position

    fn MappingSegment::generated_position(self : MappingSegment) -> GeneratedPosition

    MappingSegment::has_name

    fn MappingSegment::has_name(self : MappingSegment) -> Bool

    MappingSegment::is_mapped

    fn MappingSegment::is_mapped(self : MappingSegment) -> Bool

    MappingSegment::mapped

    fn MappingSegment::mapped(generated_line : Int, generated_column : Int, source_index : Int, original_line : Int, original_column : Int, name_index? : Int) -> MappingSegment

    MappingSegment::unmapped

    fn MappingSegment::unmapped(generated_line : Int, generated_column : Int) -> MappingSegment

    MappingStats

    pub struct MappingStats {
    generated_lines : Int
    total_segments : Int
    mapped_segments : Int
    unmapped_segments : Int
    named_segments : Int
    source_count : Int
    name_count : Int
    ignored_source_count : Int
    } derive(Eq, ToJson,
    Debug
    )

    Aggregated counts that are useful in CI output and smoke tests.

    MappingStats::summary

    fn MappingStats::summary(self : MappingStats) -> String

    NameUse

    pub struct NameUse {
    name : String
    name_index : Int
    generated_line : Int
    generated_column : Int
    source : String?
    original_line : Int?
    original_column : Int?
    } derive(Eq, ToJson,
    Debug
    )

    OriginalPosition

    pub struct OriginalPosition {
    source : String
    line : Int
    column : Int
    name : String?
    } derive(Eq, ToJson,
    Debug
    )

    Position in an original source file. name is optional because most source maps only attach names to identifiers and call sites.

    OriginalPosition::OriginalPosition

    fn OriginalPosition::OriginalPosition(source : StringView, line : Int, column : Int, name? : String) -> OriginalPosition

    OriginalRange

    pub struct OriginalRange {
    source : String
    start_line : Int
    start_column : Int
    end_line : Int?
    end_column : Int?
    } derive(Eq, ToJson,
    Debug
    )

    OriginalRange::OriginalRange

    fn OriginalRange::OriginalRange(source : StringView, start_line : Int, start_column? : Int, end_line? : Int, end_column? : Int) -> OriginalRange

    OriginalRange::contains

    fn OriginalRange::contains(self : OriginalRange, source : StringView, line : Int, column : Int) -> Bool

    OriginalRange::is_empty

    fn OriginalRange::is_empty(self : OriginalRange) -> Bool

    PruneSummary

    pub struct PruneSummary {
    sources_before : Int
    sources_after : Int
    names_before : Int
    names_after : Int
    mappings_before : Int
    mappings_after : Int
    } derive(Eq, ToJson,
    Debug
    )

    PruneSummary::summary

    fn PruneSummary::summary(self : PruneSummary) -> String

    SegmentTrace

    pub 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
    )

    SegmentTrace::summary

    fn SegmentTrace::summary(self : SegmentTrace) -> String

    SourceMap

    pub struct SourceMap {
    version : Int
    file : String?
    source_root : String?
    sources : Array[String]
    sources_content : Array[String?]
    names : Array[String]
    mappings : Array[MappingSegment]
    ignore_list : Array[Int]
    } derive(Eq, ToJson,
    Debug
    )

    Source Map v3 data model. mappings is stored decoded so callers can query, validate and transform it without repeatedly parsing VLQ text.

    SourceMap::SourceMap

    fn SourceMap::SourceMap(sources : ArrayView[String], mappings : ArrayView[MappingSegment], names? : ArrayView[String], file? : String, source_root? : String, sources_content? : ArrayView[String?], ignore_list? : ArrayView[Int]) -> SourceMap

    SourceMap::canonical

    fn SourceMap::canonical(self : SourceMap) -> SourceMap

    SourceMap::compact

    fn SourceMap::compact(self : SourceMap) -> SourceMap

    SourceMap::compose_report

    fn SourceMap::compose_report(self : SourceMap, previous : SourceMap, intermediate_source? : String) -> String

    SourceMap::compose_summary

    fn SourceMap::compose_summary(self : SourceMap, previous : SourceMap, intermediate_source? : String) -> ComposeSummary

    SourceMap::compose_with

    fn SourceMap::compose_with(self : SourceMap, previous : SourceMap, intermediate_source? : String, preserve_unresolved? : Bool) -> SourceMap

    SourceMap::coverage_for_lengths

    fn SourceMap::coverage_for_lengths(self : SourceMap, line_lengths : ArrayView[Int]) -> CoverageReport

    SourceMap::coverage_for_text

    fn SourceMap::coverage_for_text(self : SourceMap, generated : StringView) -> CoverageReport

    SourceMap::coverage_line

    fn SourceMap::coverage_line(self : SourceMap, line : Int, line_length : Int) -> CoverageLine

    SourceMap::coverage_text_report

    fn SourceMap::coverage_text_report(self : SourceMap, line_lengths : ArrayView[Int]) -> String

    SourceMap::coverage_text_report_for_text

    fn SourceMap::coverage_text_report_for_text(self : SourceMap, generated : StringView) -> String

    SourceMap::deduplicate_names

    fn SourceMap::deduplicate_names(self : SourceMap) -> SourceMap

    SourceMap::deduplicate_sources

    fn SourceMap::deduplicate_sources(self : SourceMap) -> SourceMap

    SourceMap::diff

    fn SourceMap::diff(self : SourceMap, other : SourceMap) -> SourceMapDiff

    SourceMap::drop_generated_before

    fn SourceMap::drop_generated_before(self : SourceMap, line : Int, column? : Int) -> SourceMap

    SourceMap::drop_unmapped

    fn SourceMap::drop_unmapped(self : SourceMap) -> SourceMap

    SourceMap::empty

    fn SourceMap::empty() -> SourceMap

    SourceMap::encoded_mappings

    fn SourceMap::encoded_mappings(self : SourceMap) -> String

    SourceMap::errors

    fn SourceMap::errors(self : SourceMap) -> Array[Diagnostic]

    SourceMap::explain_generated

    fn SourceMap::explain_generated(self : SourceMap, generated_line : Int, generated_column : Int) -> String

    SourceMap::filter_names

    fn SourceMap::filter_names(self : SourceMap, keep : (String) -> Bool) -> SourceMap

    SourceMap::filter_sources

    fn SourceMap::filter_sources(self : SourceMap, keep : (String) -> Bool) -> SourceMap

    SourceMap::find_generated

    fn SourceMap::find_generated(self : SourceMap, source : StringView, original_line : Int, original_column : Int) -> GeneratedPosition?

    SourceMap::find_original

    fn SourceMap::find_original(self : SourceMap, generated_line : Int, generated_column : Int) -> OriginalPosition?

    SourceMap::from_json

    fn SourceMap::from_json(json : Json) -> Result[SourceMap, SourceMapError]

    SourceMap::from_json_string

    fn SourceMap::from_json_string(text : StringView) -> Result[SourceMap, SourceMapError]

    SourceMap::gaps_for_line

    fn SourceMap::gaps_for_line(self : SourceMap, line : Int, line_length : Int) -> Array[GeneratedGap]

    SourceMap::generated_lines

    fn SourceMap::generated_lines(self : SourceMap) -> Int

    SourceMap::generated_range_summary

    fn SourceMap::generated_range_summary(self : SourceMap, range : GeneratedRange) -> String

    SourceMap::index

    fn SourceMap::index(self : SourceMap) -> MappingIndex

    SourceMap::is_source_ignored

    fn SourceMap::is_source_ignored(self : SourceMap, source : StringView) -> Bool

    SourceMap::is_valid

    fn SourceMap::is_valid(self : SourceMap) -> Bool

    SourceMap::line_summaries

    fn SourceMap::line_summaries(self : SourceMap) -> Array[LineSummary]

    SourceMap::lint

    fn SourceMap::lint(self : SourceMap, line_lengths? : ArrayView[Int], options? : SourceMapLintOptions) -> Array[Diagnostic]

    SourceMap::lint_report

    fn SourceMap::lint_report(self : SourceMap, line_lengths? : ArrayView[Int], options? : SourceMapLintOptions) -> String

    SourceMap::lint_summary

    fn SourceMap::lint_summary(self : SourceMap, line_lengths? : ArrayView[Int], options? : SourceMapLintOptions) -> LintSummary

    SourceMap::map_generated_columns

    fn SourceMap::map_generated_columns(self : SourceMap, f : (Int, Int) -> Int) -> SourceMap

    SourceMap::map_original_lines

    fn SourceMap::map_original_lines(self : SourceMap, f : (String, Int) -> Int) -> SourceMap

    SourceMap::mapped_spans

    fn SourceMap::mapped_spans(self : SourceMap) -> Array[GeneratedSpan]

    SourceMap::name_frequency

    fn SourceMap::name_frequency(self : SourceMap) -> Array[(String, Int)]

    SourceMap::name_report

    fn SourceMap::name_report(self : SourceMap) -> String

    SourceMap::name_uses

    fn SourceMap::name_uses(self : SourceMap) -> Array[NameUse]

    SourceMap::normalize_source_slashes

    fn SourceMap::normalize_source_slashes(self : SourceMap) -> SourceMap

    SourceMap::passes_lint

    fn SourceMap::passes_lint(self : SourceMap, line_lengths? : ArrayView[Int], options? : SourceMapLintOptions) -> Bool

    SourceMap::passes_policy

    fn SourceMap::passes_policy(self : SourceMap, policy : ValidationPolicy) -> Bool

    SourceMap::prefix_sources

    fn SourceMap::prefix_sources(self : SourceMap, prefix : StringView) -> SourceMap

    SourceMap::prune_summary

    fn SourceMap::prune_summary(self : SourceMap) -> PruneSummary

    SourceMap::prune_unused

    fn SourceMap::prune_unused(self : SourceMap) -> SourceMap

    SourceMap::prune_unused_names

    fn SourceMap::prune_unused_names(self : SourceMap) -> SourceMap

    SourceMap::prune_unused_sources

    fn SourceMap::prune_unused_sources(self : SourceMap) -> SourceMap

    SourceMap::rename_name

    fn SourceMap::rename_name(self : SourceMap, old_name : StringView, new_name : StringView) -> SourceMap

    SourceMap::rename_source

    fn SourceMap::rename_source(self : SourceMap, old_source : StringView, new_source : StringView) -> SourceMap

    SourceMap::replace_source_prefix

    fn SourceMap::replace_source_prefix(self : SourceMap, old_prefix : StringView, new_prefix : StringView) -> SourceMap

    SourceMap::report

    fn SourceMap::report(self : SourceMap) -> String

    SourceMap::segments_for_source

    fn SourceMap::segments_for_source(self : SourceMap, source : StringView) -> Array[MappingSegment]

    SourceMap::shift_generated

    fn SourceMap::shift_generated(self : SourceMap, line_delta : Int, column_delta_for_first_line : Int) -> SourceMap

    SourceMap::slice_generated_lines

    fn SourceMap::slice_generated_lines(self : SourceMap, start_line : Int, end_line : Int) -> SourceMap

    SourceMap::slice_generated_range

    fn SourceMap::slice_generated_range(self : SourceMap, range : GeneratedRange, rebase? : Bool) -> SourceMap

    SourceMap::slice_original_range

    fn SourceMap::slice_original_range(self : SourceMap, range : OriginalRange, keep_unmapped? : Bool) -> SourceMap

    SourceMap::sorted

    fn SourceMap::sorted(self : SourceMap) -> SourceMap

    SourceMap::source_summaries

    fn SourceMap::source_summaries(self : SourceMap) -> Array[SourceSummary]

    SourceMap::sources_in_generated_range

    fn SourceMap::sources_in_generated_range(self : SourceMap, range : GeneratedRange) -> Array[String]

    SourceMap::span_at

    fn SourceMap::span_at(self : SourceMap, line : Int, column : Int) -> GeneratedSpan?

    SourceMap::spans

    fn SourceMap::spans(self : SourceMap) -> Array[GeneratedSpan]

    SourceMap::spans_for_line

    fn SourceMap::spans_for_line(self : SourceMap, line : Int) -> Array[GeneratedSpan]

    SourceMap::stats

    fn SourceMap::stats(self : SourceMap) -> MappingStats

    SourceMap::symbolicate_frame

    fn SourceMap::symbolicate_frame(self : SourceMap, frame : StackFrame) -> SymbolicatedFrame

    SourceMap::symbolicate_stack

    fn SourceMap::symbolicate_stack(self : SourceMap, stack : StringView) -> Array[SymbolicatedFrame]

    SourceMap::symbolicate_stack_report

    fn SourceMap::symbolicate_stack_report(self : SourceMap, stack : StringView) -> String

    SourceMap::take_generated_before

    fn SourceMap::take_generated_before(self : SourceMap, line : Int, column? : Int) -> SourceMap

    SourceMap::to_builder

    fn SourceMap::to_builder(self : SourceMap) -> SourceMapBuilder

    SourceMap::to_json

    fn SourceMap::to_json(self : SourceMap) -> Json

    SourceMap::to_json_string

    fn SourceMap::to_json_string(self : SourceMap, indent? : Int) -> String

    SourceMap::unmapped_spans

    fn SourceMap::unmapped_spans(self : SourceMap) -> Array[GeneratedSpan]

    SourceMap::unused_names

    fn SourceMap::unused_names(self : SourceMap) -> Array[String]

    SourceMap::unused_sources

    fn SourceMap::unused_sources(self : SourceMap) -> Array[String]

    SourceMap::validate

    fn SourceMap::validate(self : SourceMap) -> Array[Diagnostic]

    SourceMap::validate_with

    fn SourceMap::validate_with(self : SourceMap, policy : ValidationPolicy) -> Array[Diagnostic]

    SourceMap::warnings

    fn SourceMap::warnings(self : SourceMap) -> Array[Diagnostic]

    SourceMap::with_file

    fn SourceMap::with_file(self : SourceMap, file : StringView) -> SourceMap

    SourceMap::with_source_root

    fn SourceMap::with_source_root(self : SourceMap, source_root : StringView) -> SourceMap

    SourceMap::with_sources_content

    fn SourceMap::with_sources_content(self : SourceMap, contents : ArrayView[String?]) -> SourceMap

    SourceMap::without_file

    fn SourceMap::without_file(self : SourceMap) -> SourceMap

    SourceMap::without_names

    fn SourceMap::without_names(self : SourceMap) -> SourceMap

    SourceMap::without_source_root

    fn SourceMap::without_source_root(self : SourceMap) -> SourceMap

    SourceMap::without_sources_content

    fn SourceMap::without_sources_content(self : SourceMap) -> SourceMap

    SourceMapBuilder

    pub struct SourceMapBuilder {
    file : String?
    source_root : String?
    sources : Array[String]
    sources_content : Array[String?]
    names : Array[String]
    mappings : Array[MappingSegment]
    ignore_list : Array[Int]
    } derive(
    Debug
    )

    Mutable builder for producing Source Map v3 values without manually maintaining source and name indexes.

    SourceMapBuilder::SourceMapBuilder

    fn SourceMapBuilder::SourceMapBuilder(file? : String, source_root? : String) -> SourceMapBuilder

    SourceMapBuilder::add_line_start

    fn SourceMapBuilder::add_line_start(self : SourceMapBuilder, generated_line : Int, source : StringView, original_line : Int) -> Unit

    SourceMapBuilder::add_mapping

    fn SourceMapBuilder::add_mapping(self : SourceMapBuilder, generated_line : Int, generated_column : Int, source : StringView, original_line : Int, original_column : Int, name? : StringView) -> Unit

    SourceMapBuilder::add_name

    fn SourceMapBuilder::add_name(self : SourceMapBuilder, name : StringView) -> Int

    SourceMapBuilder::add_source

    fn SourceMapBuilder::add_source(self : SourceMapBuilder, source : StringView) -> Int

    SourceMapBuilder::add_unmapped

    fn SourceMapBuilder::add_unmapped(self : SourceMapBuilder, generated_line : Int, generated_column : Int) -> Unit

    SourceMapBuilder::append_segments

    fn SourceMapBuilder::append_segments(self : SourceMapBuilder, segments : ArrayView[MappingSegment]) -> Unit

    SourceMapBuilder::build

    SourceMapBuilder::clear_file

    fn SourceMapBuilder::clear_file(self : SourceMapBuilder) -> Unit

    SourceMapBuilder::clear_source_content

    fn SourceMapBuilder::clear_source_content(self : SourceMapBuilder, source : StringView) -> Bool

    SourceMapBuilder::clear_source_root

    fn SourceMapBuilder::clear_source_root(self : SourceMapBuilder) -> Unit

    SourceMapBuilder::mapping_count

    fn SourceMapBuilder::mapping_count(self : SourceMapBuilder) -> Int

    SourceMapBuilder::mark_ignored

    fn SourceMapBuilder::mark_ignored(self : SourceMapBuilder, source : StringView) -> Int

    SourceMapBuilder::merge_from

    fn SourceMapBuilder::merge_from(self : SourceMapBuilder, other : SourceMap, generated_line_offset? : Int, generated_column_offset? : Int) -> Unit

    SourceMapBuilder::name_count

    fn SourceMapBuilder::name_count(self : SourceMapBuilder) -> Int

    SourceMapBuilder::reset_all

    fn SourceMapBuilder::reset_all(self : SourceMapBuilder) -> Unit

    SourceMapBuilder::reset_mappings

    fn SourceMapBuilder::reset_mappings(self : SourceMapBuilder) -> Unit

    SourceMapBuilder::set_file

    fn SourceMapBuilder::set_file(self : SourceMapBuilder, file : StringView) -> Unit

    SourceMapBuilder::set_source_content

    fn SourceMapBuilder::set_source_content(self : SourceMapBuilder, source : StringView, content : StringView) -> Int

    SourceMapBuilder::set_source_root

    fn SourceMapBuilder::set_source_root(self : SourceMapBuilder, source_root : StringView) -> Unit

    SourceMapBuilder::sort_mappings

    fn SourceMapBuilder::sort_mappings(self : SourceMapBuilder) -> Unit

    SourceMapBuilder::source_count

    fn SourceMapBuilder::source_count(self : SourceMapBuilder) -> Int

    SourceMapBuilder::unmark_ignored

    fn SourceMapBuilder::unmark_ignored(self : SourceMapBuilder, source : StringView) -> Bool

    SourceMapDiff

    pub struct SourceMapDiff {
    same_version : Bool
    same_file : Bool
    added_sources : Array[String]
    removed_sources : Array[String]
    added_names : Array[String]
    removed_names : Array[String]
    mapping_count_before : Int
    mapping_count_after : Int
    changed_mapping_count : Int
    } derive(Eq, ToJson,
    Debug
    )

    SourceMapDiff::has_changes

    fn SourceMapDiff::has_changes(self : SourceMapDiff) -> Bool

    SourceMapDiff::summary

    fn SourceMapDiff::summary(self : SourceMapDiff) -> String

    SourceMapError

    pub(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
    )

    Error type returned by parsing and encoding helpers.

    SourceMapError::message

    fn SourceMapError::message(self : SourceMapError) -> String

    SourceMapLintOptions

    pub struct 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?
    } derive(Eq, ToJson,
    Debug
    )

    SourceMapLintOptions::SourceMapLintOptions

    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) -> SourceMapLintOptions

    SourceMapLintOptions::ci

    SourceSummary

    pub struct SourceSummary {
    source : String
    index : Int
    mapped_segments : Int
    named_segments : Int
    first_original_line : Int?
    last_original_line : Int?
    ignored : Bool
    } derive(Eq, ToJson,
    Debug
    )

    Per-source summary for dashboards and build reports.

    StackFrame

    pub struct StackFrame {
    function_name : String?
    file : String
    line : Int
    column : Int
    } derive(Eq, ToJson,
    Debug
    )

    StackFrame::render

    fn StackFrame::render(self : StackFrame) -> String

    SymbolicatedFrame

    pub struct SymbolicatedFrame {
    generated : StackFrame
    original : OriginalPosition?
    } derive(Eq, ToJson,
    Debug
    )

    SymbolicatedFrame::render

    fn SymbolicatedFrame::render(self : SymbolicatedFrame) -> String

    ValidationPolicy

    pub struct 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?
    } derive(Eq, ToJson,
    Debug
    )

    ValidationPolicy::ValidationPolicy

    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) -> ValidationPolicy

    ValidationPolicy::default

    ValidationPolicy::strict

    ValidationPolicy::with_ignore_list

    fn ValidationPolicy::with_ignore_list(self : ValidationPolicy, allow : Bool) -> ValidationPolicy

    ValidationPolicy::with_limits

    fn ValidationPolicy::with_limits(self : ValidationPolicy, max_segment_count? : Int, max_source_count? : Int) -> ValidationPolicy

    ValidationPolicy::with_unmapped_segments

    fn ValidationPolicy::with_unmapped_segments(self : ValidationPolicy, allow : Bool) -> ValidationPolicy

    VlqTraceStep

    pub struct VlqTraceStep {
    offset : Int
    char : String
    digit : Int
    payload : Int
    continuation : Bool
    shift : Int
    partial : Int
    } derive(Eq, ToJson,
    Debug
    )

    compose_chain

    fn compose_chain(maps : ArrayView[SourceMap]) -> SourceMap

    decode_mappings

    fn decode_mappings(input : StringView) -> Result[Array[MappingSegment], SourceMapError]

    decode_vlq

    fn decode_vlq(input : StringView, offset : Int) -> Result[(Int, Int), SourceMapError]

    decode_vlq_values

    fn decode_vlq_values(input : StringView) -> Result[Array[Int], SourceMapError]

    encode_mappings

    fn encode_mappings(segments : ArrayView[MappingSegment]) -> String

    encode_vlq

    fn encode_vlq(value : Int) -> String

    encode_vlq_values

    fn encode_vlq_values(values : ArrayView[Int]) -> String

    generated_line_count

    fn generated_line_count(input : StringView) -> Int

    generated_line_lengths

    fn generated_line_lengths(input : StringView) -> Array[Int]

    generated_offset_to_position

    fn generated_offset_to_position(input : StringView, offset : Int) -> GeneratedPosition?

    generated_position_to_offset

    fn generated_position_to_offset(input : StringView, line : Int, column : Int) -> Int?

    line_table

    fn line_table(input : StringView) -> Array[GeneratedLineInfo]

    line_table_report

    fn line_table_report(input : StringView) -> String

    parse_stack

    fn parse_stack(text : StringView) -> Array[StackFrame]

    parse_stack_frame

    fn parse_stack_frame(line : StringView) -> StackFrame?

    render_symbolicated_stack

    fn render_symbolicated_stack(frames : ArrayView[SymbolicatedFrame]) -> String

    trace_mappings

    fn trace_mappings(input : StringView) -> Array[SegmentTrace]

    trace_mappings_report

    fn trace_mappings_report(input : StringView) -> String

    trace_vlq

    fn trace_vlq(input : StringView, offset : Int) -> Result[Array[VlqTraceStep], SourceMapError]

    vlq_fixture_checksum

    fn vlq_fixture_checksum() -> Int

    vlq_fixture_values

    fn vlq_fixture_values() -> Array[Int]

    Regression corpus for Base64 VLQ roundtrip checks. The dense -350..350 window crosses every low-bit continuation boundary used by Source Map VLQ.