class Sprockets::Rails::SourcemappingUrlProcessor
Experimental RBS support (using type sampling data from the type_fusion
project).
# sig/sprockets/rails/sourcemapping_url_processor.rbs class Sprockets::Rails::SourcemappingUrlProcessor def call: (Hash input) -> untyped end
Rewrites source mapping urls with the digested paths and protect against semicolon appending with a dummy comment line
def call(input)
Experimental RBS support (using type sampling data from the type_fusion
project).
def call: (data | String | metadata | dependencies | Set | required | Set | stubbed | Set | links | Set | to_load | Set | to_link | Set | map | version | Integer | file | String | mappings | String | sources | | names | | x_sprockets_linecount | Integer | environment | Sprockets::CachedEnvironment | cache | Sprockets::Cache | uri | String | filename | String | load_path | String | name | String | content_type | String input) -> untyped
This signature was generated using 1 sample from 1 application.
def call(input) env = input[:environment] context = env.context_class.new(input) data = input[:data].gsub(REGEX) do |_match| sourcemap_logical_path = combine_sourcemap_logical_path(sourcefile: input[:name], sourcemap: $1) begin resolved_sourcemap_comment(sourcemap_logical_path, context: context) rescue Sprockets::FileNotFound removed_sourcemap_comment(sourcemap_logical_path, filename: input[:filename], env: env) end end { data: data } end
def combine_sourcemap_logical_path(sourcefile:, sourcemap:)
def combine_sourcemap_logical_path(sourcefile:, sourcemap:) if (parts = sourcefile.split("/")).many? parts[0..-2].append(sourcemap).join("/") else sourcemap end end
def removed_sourcemap_comment(sourcemap_logical_path, filename:, env:)
def removed_sourcemap_comment(sourcemap_logical_path, filename:, env:) env.logger.warn "Removed sourceMappingURL comment for missing asset '#{sourcemap_logical_path}' from #{filename}" nil end
def resolved_sourcemap_comment(sourcemap_logical_path, context:)
def resolved_sourcemap_comment(sourcemap_logical_path, context:) "//# sourceMappingURL=#{sourcemap_asset_path(sourcemap_logical_path, context: context)}\n//!\n" end
def sourcemap_asset_path(sourcemap_logical_path, context:)
def sourcemap_asset_path(sourcemap_logical_path, context:) # FIXME: Work-around for bug where if the sourcemap is nested two levels deep, it'll resolve as the source file # that's being mapped, rather than the map itself. So context.resolve("a/b/c.js.map") will return "c.js?" if context.resolve(sourcemap_logical_path) =~ /\.map/ context.asset_path(sourcemap_logical_path) else raise Sprockets::FileNotFound, "Failed to resolve source map asset due to nesting depth" end end