Sha256: 688348c786e07a8e3350cf820e670231222e696c23a186c05b5b5e2fb47f8f23
Contents?: true
Size: 941 Bytes
Versions: 4
Compression:
Stored size: 941 Bytes
Contents
# require 'opal' require 'source_map' module Opal class SourceMap attr_reader :fragments attr_reader :file def initialize(fragments, file) @fragments = fragments @file = file end def map @map ||= ::SourceMap.new.tap do |map| line, column = 1, 0 @fragments.each do |fragment| if source_line = fragment.line map.add_mapping( :generated_line => line, :generated_col => column, :source_line => source_line, :source_col => 0, :source => file ) end new_lines = fragment.code.count "\n" line += new_lines column = 0 end end end def as_json map.as_json end def to_s map.to_s end def magic_comment map_path "\n//@ sourceMappingURL=file://#{map_path}" end end end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
opal-0.5.5 | lib/opal/source_map.rb |
opal-0.5.4 | lib/opal/source_map.rb |
opal-0.5.2 | lib/opal/source_map.rb |
opal-0.5.0 | lib/opal/source_map.rb |