sourcemap
Version, currently master branch1 version
- master branchlatestSep 11, 2023
github.com/confact/sourcemap
A sourcemap parser in crystal using vlq decoding
Installation
# Add this to your shard.yml
dependencies:
sourcemap:
github: confact/sourcemap
branch: mastermaster is a branch, not a release, so this tracks it rather than pinning a version.
Then run:
shards installshard.yml
- Crystal
1.5.0- License
- MIT
- Author
- Håkan
Dependencies
This version declares no dependencies.
README
Sourcemap Parser
A sourcemap parser in crystal, using vlq encoding.
This repo use changed code from the repo ConradIrwin/ruby-source_map. Thanks Conrad Irwin!
Installation
-
Add the dependency to your
shard.yml:dependencies: sourcemap: github: confact/sourcemap -
Run
shards install
Usage
require "sourcemap"
Get a sourcemap from a sourcemap file:
Sourcemap::Parser.from_file("sourcemap.js.map")
Get a sourcemap from a sourcemap json string:
Sourcemap::Parser.from_string(sourcemap_string)
To get the mappings of the sourcemap:
sourcemap = Sourcemap::Parser.from_file("sourcemap.js.map")
sourcemap.parsed_mappings
It will return an array of Sourcemap::Mapping. Those mappings can be used to get the original source code and the original line and column.
Retrive all mappings for a line and column:
sourcemap = Sourcemap::Parser.from_file("sourcemap.js.map")
mapping = sourcemap.mapping_for(1, 1)
Get mappings for specific source file:
sourcemap = Sourcemap::Parser.from_file("sourcemap.js.map")
sourcemap.mappings_for_source("sourcemap.js")
Development
clone the repo and see the code and test the specs. the specs can be run with crystal spec
Contributing
- Fork it (https://github.com/confact/sourcemap/fork)
- Create your feature branch (
git checkout -b my-new-feature) - Commit your changes (
git commit -am 'Add some feature') - Push to the branch (
git push origin my-new-feature) - Create a new Pull Request
Contributors
- Håkan - creator and maintainer
Documentation
Built from the current release. The first visit to a release nobody has asked for starts its build.
Links
This branch
- Branch
master- Seen
- Sep 11, 2023
- Crystal
1.5.0- Indexed
- yes
Dependents
No indexed shard depends on this one yet.
Repository
github.com/confact/sourcemap
Metadata
- Created
- Aug 12, 2026
- Updated
- Aug 16, 2026
- Synced
- Aug 16, 2026
- Versions
- 1