Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function fixMappings( mappings ) {
if ( typeof mappings !== 'string' ) {
return '';
}
mappings = decode( mappings );
mappings[ 0 ].forEach( ( line, index ) => {
// If the line has only one segment with only one item,
// just drop the whole line.
if ( line && line.length === 1 ) {
mappings[ 0 ].splice( index, 1 );
}
} );
return encode( mappings );
}
while ( i-- ) {
line = this.node.mappings[i];
resolved[i] = result = [];
for ( j = 0; j < line.length; j += 1 ) {
applySegment( line[j], result );
}
}
let tracingTime = process.hrtime( tracingStart );
this._stats.tracingTime = 1e9 * tracingTime[0] + tracingTime[1];
// Encode mappings
let encodingStart = process.hrtime();
let mappings = encode( resolved );
let encodingTime = process.hrtime( encodingStart );
this._stats.encodingTime = 1e9 * encodingTime[0] + encodingTime[1];
let includeContent = options.includeContent !== false;
return new SourceMap({
file: basename( this.node.file ),
sources: allSources.map( source => slash( relative( options.base || dirname( this.node.file ), source ) ) ),
sourcesContent: allSources.map( source => includeContent ? this.sourcesContentByPath[ source ] : null ),
names: allNames,
mappings
});
},
});
return source;
});
let source = new Link( map, sources );
bundleSourcemapChain.forEach( map => {
source = new Link( map, [ source ] );
});
const { names, mappings } = source.traceMappings();
// we re-use the `map` object because it has convenient toString/toURL methods
map.sourcesContent = modules.map( module => module.originalCode );
map.mappings = encode( mappings );
map.names = names;
return map;
}
// adjust name index
if (segment[4]) segment[4] += combined_map.names.length;
});
});
}
combined_map.sources.push(...map.sources);
combined_map.sourcesContent.push(...map.sourcesContent);
combined_map.names.push(...map.names);
mappings.push(...lines);
}
});
if (parts.length > 0) {
combined_map.mappings = codec.encode(mappings);
combined_map.sources = combined_map.sources.map(source => path.relative(asset_dir, source).replace(/\\/g, '/'));
return {
code: parts.join('\n'),
map: combined_map
};
}
return null;
}
unit => {
t.deepEqual(unit, {
contents: 'a;\nadd;\nb;\n',
path: 'src/foo.js',
moduleId: 'foo',
sourceMap: {
version: 3,
file: 'src/foo.js',
sources: [ 'src/foo.js' ],
sourcesContent: [ 'a;b;\n' ],
names: [],
mappings: encode([
[ [ 0, 0, 0, 0 ], [ 1, 0, 0, 0 ], [ 2, 0, 0, 0 ] ],
[ [ 0, 0, 0, 0 ] ],
[ [ 0, 0, 0, 3 ], [ 1, 0, 0, 3 ], [ 2, 0, 0, 3 ] ]
])
}
})
},
t.fail
if (i > 0) {
decoded.forEach(line => {
line.forEach(segment => {
segment[1] = i;
});
});
}
mappings.push(...decoded);
}
}
const writer = new CssWriter(result, {
sources,
sourcesContent,
mappings: encode(mappings)
}, this.warn);
css(writer);
}
}
};
codeStart = codeStart ? codeStart.length + 1 : 1;
let whitespaceAtStart = code.replace( `${ banner }\n`, '' ).match( /^(\s)+/g );
whitespaceAtStart = whitespaceAtStart ? whitespaceAtStart.length : 0;
mappings.unshift( [] );
if ( Array.isArray( mappings[ codeStart ] ) && mappings[ codeStart ].length ) {
const offset = mappings[ codeStart ][ 0 ][ 0 ] - whitespaceAtStart;
mappings[ codeStart ].forEach( ( segment ) => {
segment[ 0 ] -= offset;
} );
}
map.mappings = encodeSourceMap( mappings );
return {
code,
map
};
}
chunk.loc.end.line - 1,
chunk.loc.end.column,
]);
}
}
mappings.push(current_line);
return {
code,
map: {
version: 3,
names: [],
sources: [opts.sourceMapSource || null],
sourcesContent: [opts.sourceMapContent || null],
mappings: encode(mappings)
}
};
}