dist/ractive-load.es.js
function generateSourceMap ( definition, options ) {
	if ( options === void 0 ) { options = {}; }

	if ( 'padding' in options ) {
		options.offset = options.padding;

		if ( !alreadyWarned ) {
			console.warn( 'rcu: options.padding is deprecated, use options.offset instead' ); // eslint-disable-line no-console
			alreadyWarned = true;
		}
	}

	var mappings = '';

	if ( definition.scriptStart ) {
		// The generated code probably includes a load of module gubbins - we don't bother
		// mapping that to anything, instead we just have a bunch of empty lines
		var offset = new Array( ( options.offset || 0 ) + 1 ).join( ';' );
		var lines = definition.script.split( '\n' );

		var encoded;

		if ( options.hires !== false ) {
			var previousLineEnd = -definition.scriptStart.column;

			encoded = lines.map( function ( line, i ) {
				var lineOffset = i === 0 ? definition.scriptStart.line : 1;

				var encoded = encode([ 0, 0, lineOffset, -previousLineEnd ]);

				var lineEnd = line.length;

				for ( var j = 1; j < lineEnd; j += 1 ) {
					encoded += ',CAAC';
				}

				previousLineEnd = i === 0 ?
					lineEnd + definition.scriptStart.column :
					Math.max( 0, lineEnd - 1 );

				return encoded;
			});
		} else {
			encoded = lines.map( function ( line, i ) {
				if ( i === 0 ) {
					// first mapping points to code immediately following opening <script> tag
					return encode([ 0, 0, definition.scriptStart.line, definition.scriptStart.column ]);
				}

				if ( i === 1 ) {
					return encode([ 0, 0, 1, -definition.scriptStart.column ]);
				}

				return 'AACA'; // equates to [ 0, 0, 1, 0 ];
			});
		}

		mappings = offset + encoded.join( ';' );
	}

	return new SourceMap({
		file: options.file || null,
		sources: [ options.source || null ],
		sourcesContent: [ definition.source ],
		names: [],
		mappings: mappings
	});
}
function generateSourceMap ( definition, options ) {
	if ( options === void 0 ) { options = {}; }

	if ( 'padding' in options ) {
		options.offset = options.padding;

		if ( !alreadyWarned ) {
			console.warn( 'rcu: options.padding is deprecated, use options.offset instead' ); // eslint-disable-line no-console
			alreadyWarned = true;
		}
	}

	var mappings = '';

	if ( definition.scriptStart ) {
		// The generated code probably includes a load of module gubbins - we don't bother
		// mapping that to anything, instead we just have a bunch of empty lines
		var offset = new Array( ( options.offset || 0 ) + 1 ).join( ';' );
		var lines = definition.script.split( '\n' );

		var encoded;

		if ( options.hires !== false ) {
			var previousLineEnd = -definition.scriptStart.column;

			encoded = lines.map( function ( line, i ) {
				var lineOffset = i === 0 ? definition.scriptStart.line : 1;

				var encoded = encode([ 0, 0, lineOffset, -previousLineEnd ]);

				var lineEnd = line.length;

				for ( var j = 1; j < lineEnd; j += 1 ) {
					encoded += ',CAAC';
				}

				previousLineEnd = i === 0 ?
					lineEnd + definition.scriptStart.column :
					Math.max( 0, lineEnd - 1 );

				return encoded;
			});
		} else {
			encoded = lines.map( function ( line, i ) {
				if ( i === 0 ) {
					// first mapping points to code immediately following opening <script> tag
					return encode([ 0, 0, definition.scriptStart.line, definition.scriptStart.column ]);
				}

				if ( i === 1 ) {
					return encode([ 0, 0, 1, -definition.scriptStart.column ]);
				}

				return 'AACA'; // equates to [ 0, 0, 1, 0 ];
			});
		}

		mappings = offset + encoded.join( ';' );
	}

	return new SourceMap({
		file: options.file || null,
		sources: [ options.source || null ],
		sourcesContent: [ definition.source ],
		names: [],
		mappings: mappings
	});
}
function generateSourceMap ( definition , options ) { if ( options === void 0 ) { options = { } ; } if ( 'padding' in options ) { options . offset = options . padding ; if ( ! alreadyWarned ) { console . warn ( 'rcu: options.padding is deprecated, use options.offset instead' ) ; // eslint-disable-line no-console alreadyWarned = true ; } } var mappings = '' ; if ( definition . scriptStart ) { // The generated code probably includes a load of module gubbins - we don't bother // mapping that to anything, instead we just have a bunch of empty lines var offset = new Array ( ( options . offset || 0 ) + 1 ) . join ( ';' ) ; var lines = definition . script . split ( '\n' ) ; var encoded ; if ( options . hires !== false ) { var previousLineEnd = - definition . scriptStart . column ; encoded = lines . map ( function ( line , i ) { var lineOffset = i === 0 ? definition . scriptStart . line : 1 ; var encoded = encode ( [ 0 , 0 , lineOffset , - previousLineEnd ] ) ; var lineEnd = line . length ; for ( var j = 1 ; j < lineEnd ; j += 1 ) { encoded += ',CAAC' ; } previousLineEnd = i === 0 ? lineEnd + definition . scriptStart . column : Math . max ( 0 , lineEnd - 1 ) ; return encoded ; } ) ; } else { encoded = lines . map ( function ( line , i ) { if ( i === 0 ) { // first mapping points to code immediately following opening <script> tag return encode ( [ 0 , 0 , definition . scriptStart . line , definition . scriptStart . column ] ) ; } if ( i === 1 ) { return encode ( [ 0 , 0 , 1 , - definition . scriptStart . column ] ) ; } return 'AACA' ; // equates to [ 0, 0, 1, 0 ]; } ) ; } mappings = offset + encoded . join ( ';' ) ; } return new SourceMap ( { file : options . file || null , sources : [ options . source || null ] , sourcesContent : [ definition . source ] , names : [ ] , mappings : mappings } ) ; }
Generates a v3 sourcemap between an original source and its built form
@param {object} definition - the result of `rcu.parse( originalSource )`
@param {object} options
@param {string} options.source - the name of the original source file
@param {number=} options.offset - the number of lines in the generated
code that precede the script portion of the original source
@param {string=} options.file - the name of the generated file
@returns {object}
Generates a v3 sourcemap between an original source and its built form