|
|
|
|
@ -182,6 +182,8 @@ export class MappedCode {
|
|
|
|
|
return new MappedCode(string, map);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private static regex_line_token = /([^\d\w\s]|\s+)/g;
|
|
|
|
|
|
|
|
|
|
static from_source({ source, file_basename, get_location }: Source): MappedCode {
|
|
|
|
|
let offset: SourceLocation = get_location(0);
|
|
|
|
|
|
|
|
|
|
@ -195,7 +197,7 @@ export class MappedCode {
|
|
|
|
|
const line_list = source.split('\n');
|
|
|
|
|
for (let line = 0; line < line_list.length; line++) {
|
|
|
|
|
map.mappings.push([]);
|
|
|
|
|
const token_list = line_list[line].split(/([^\d\w\s]|\s+)/g);
|
|
|
|
|
const token_list = line_list[line].split(this.regex_line_token);
|
|
|
|
|
for (let token = 0, column = 0; token < token_list.length; token++) {
|
|
|
|
|
if (token_list[token] == '') continue;
|
|
|
|
|
map.mappings[line].push([column, 0, offset.line + line, column]);
|
|
|
|
|
@ -289,6 +291,8 @@ export function apply_preprocessor_sourcemap(filename: string, svelte_map: Sourc
|
|
|
|
|
return result_map as SourceMap;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const regex_data_uri = /data:(?:application|text)\/json;(?:charset[:=]\S+?;)?base64,(\S*)/;
|
|
|
|
|
|
|
|
|
|
// parse attached sourcemap in processed.code
|
|
|
|
|
export function parse_attached_sourcemap(processed: Processed, tag_name: 'script' | 'style'): void {
|
|
|
|
|
const r_in = '[#@]\\s*sourceMappingURL\\s*=\\s*(\\S*)';
|
|
|
|
|
@ -302,7 +306,7 @@ export function parse_attached_sourcemap(processed: Processed, tag_name: 'script
|
|
|
|
|
}
|
|
|
|
|
processed.code = processed.code.replace(regex, (_, match1, match2) => {
|
|
|
|
|
const map_url = (tag_name == 'script') ? (match1 || match2) : match1;
|
|
|
|
|
const map_data = (map_url.match(/data:(?:application|text)\/json;(?:charset[:=]\S+?;)?base64,(\S*)/) || [])[1];
|
|
|
|
|
const map_data = (map_url.match(regex_data_uri) || [])[1];
|
|
|
|
|
if (map_data) {
|
|
|
|
|
// sourceMappingURL is data URL
|
|
|
|
|
if (processed.map) {
|
|
|
|
|
|