Types


Topics

struct SourceMap

A source map describing how each segment of a generated file corresponds to some original source file.

The main use cases imagined are:

  1. Read a source map, make minor modifications, write it back encode(...).
  2. Create a new source map init(version:), fill in fields, and write it encode(...).
  3. Read and unpack a source map UnpackedSourceMap.init(...) and query it UnpackedSourceMap.map(...).

There are two representations of the actual mappings. The mappings property holds the compacted mapping string that looks like AAAA;EACA. This can be decoded into or written via arrays of Segments. These arrays can be very large and time-consuming to create. The separate UnpackedSourceMap type works to cache them and satisfy queries.

Declaration
Swift
public struct SourceMap: Hashable, Sendable

extension SourceMap: CustomStringConvertible

struct UnpackedSourceMap

A source map that supports efficient mapping queries.

This bundles together a SourceMap and a cache of its unpacked mapping segments.

Declaration
Swift
public struct UnpackedSourceMap: Hashable, Sendable

enum SourceMapError

Error conditions detected by the module.

Declaration
Swift
public enum SourceMapError: Error, CustomStringConvertible