Sha256: 34f931a51818589ae9716eabc51a8ff51be891d26de567f981b08546b921ac08

Contents?: true

Size: 1.78 KB

Versions: 29

Compression:

Stored size: 1.78 KB

Contents

/*
	MIT License http://www.opensource.org/licenses/mit-license.php
	Author Tobias Koppers @sokra
*/
"use strict";

var SourceNode = require("source-map").SourceNode;
var SourceMapConsumer = require("source-map").SourceMapConsumer;
var SourceMapGenerator = require("source-map").SourceMapGenerator;
var SourceListMap = require("source-list-map").SourceListMap;
var fromStringWithSourceMap = require("source-list-map").fromStringWithSourceMap;
var Source = require("./Source");
var applySourceMap = require("./applySourceMap");

class SourceMapSource extends Source {
	constructor(value, name, sourceMap, originalSource, innerSourceMap, removeOriginalSource) {
		super();
		this._value = value;
		this._name = name;
		this._sourceMap = sourceMap;
		this._originalSource = originalSource;
		this._innerSourceMap = innerSourceMap;
		this._removeOriginalSource = removeOriginalSource;
	}

	source() {
		return this._value;
	}

	node(options) {
		var sourceMap = this._sourceMap;
		var node = SourceNode.fromStringWithSourceMap(this._value, new SourceMapConsumer(sourceMap));
		node.setSourceContent(this._name, this._originalSource);
		var innerSourceMap = this._innerSourceMap;
		if(innerSourceMap) {
			node = applySourceMap(node, new SourceMapConsumer(innerSourceMap), this._name, this._removeOriginalSource);
		}
		return node;
	}

	listMap(options) {
		options = options || {};
		if(options.module === false)
			return new SourceListMap(this._value, this._name, this._value);
		return fromStringWithSourceMap(this._value, typeof this._sourceMap === "string" ? JSON.parse(this._sourceMap) : this._sourceMap);
	}

	updateHash(hash) {
		hash.update(this._value);
		if(this._originalSource)
			hash.update(this._originalSource);
	}
}

require("./SourceAndMapMixin")(SourceMapSource.prototype);

module.exports = SourceMapSource;

Version data entries

29 entries across 28 versions & 9 rubygems

Version Path
optimacms-0.1.61 spec/dummy/node_modules/webpack-sources/lib/SourceMapSource.js
disco_app-0.18.0 test/dummy/node_modules/webpack-sources/lib/SourceMapSource.js
disco_app-0.18.2 test/dummy/node_modules/webpack-sources/lib/SourceMapSource.js
disco_app-0.16.1 test/dummy/node_modules/webpack-sources/lib/SourceMapSource.js
disco_app-0.15.2 test/dummy/node_modules/webpack-sources/lib/SourceMapSource.js
disco_app-0.18.4 test/dummy/node_modules/webpack-sources/lib/SourceMapSource.js
disco_app-0.18.1 test/dummy/node_modules/webpack-sources/lib/SourceMapSource.js
disco_app-0.12.7.pre.puma.pre.3 test/dummy/node_modules/webpack-sources/lib/SourceMapSource.js
disco_app-0.14.0 test/dummy/node_modules/webpack-sources/lib/SourceMapSource.js
disco_app-0.13.6.pre.puma.pre.3 test/dummy/node_modules/webpack-sources/lib/SourceMapSource.js
tang-0.2.1 spec/tang_app/node_modules/webpack-sources/lib/SourceMapSource.js
groonga-client-model-6.0.0 test/apps/rails6.0.3.5/node_modules/webpack-sources/lib/SourceMapSource.js
groonga-client-model-6.0.0 test/apps/rails6.1.3/node_modules/webpack-sources/lib/SourceMapSource.js
ruby2js-4.0.4 lib/tasks/testrails/node_modules/webpack-sources/lib/SourceMapSource.js
ruby2js-4.0.3 lib/tasks/testrails/node_modules/webpack-sources/lib/SourceMapSource.js
tang-0.2.0 spec/tang_app/node_modules/webpack-sources/lib/SourceMapSource.js
tang-0.1.0 spec/tang_app/node_modules/webpack-sources/lib/SourceMapSource.js
tang-0.0.9 spec/tang_app/node_modules/webpack-sources/lib/SourceMapSource.js
enju_library-0.3.8 spec/dummy/node_modules/webpack-sources/lib/SourceMapSource.js
ilog-0.4.1 node_modules/webpack/node_modules/webpack-sources/lib/SourceMapSource.js