source: trip-planner-front/node_modules/webpack-sources/lib/SourceMapSource.js@ 6a80231

Last change on this file since 6a80231 was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago

initial commit

  • Property mode set to 100644
File size: 1.8 KB
Line 
1/*
2 MIT License http://www.opensource.org/licenses/mit-license.php
3 Author Tobias Koppers @sokra
4*/
5"use strict";
6
7var SourceNode = require("source-map").SourceNode;
8var SourceMapConsumer = require("source-map").SourceMapConsumer;
9var SourceMapGenerator = require("source-map").SourceMapGenerator;
10var SourceListMap = require("source-list-map").SourceListMap;
11var fromStringWithSourceMap = require("source-list-map").fromStringWithSourceMap;
12var Source = require("./Source");
13var applySourceMap = require("./applySourceMap");
14
15class SourceMapSource extends Source {
16 constructor(value, name, sourceMap, originalSource, innerSourceMap, removeOriginalSource) {
17 super();
18 this._value = value;
19 this._name = name;
20 this._sourceMap = sourceMap;
21 this._originalSource = originalSource;
22 this._innerSourceMap = innerSourceMap;
23 this._removeOriginalSource = removeOriginalSource;
24 }
25
26 source() {
27 return this._value;
28 }
29
30 node(options) {
31 var sourceMap = this._sourceMap;
32 var node = SourceNode.fromStringWithSourceMap(this._value, new SourceMapConsumer(sourceMap));
33 node.setSourceContent(this._name, this._originalSource);
34 var innerSourceMap = this._innerSourceMap;
35 if(innerSourceMap) {
36 node = applySourceMap(node, new SourceMapConsumer(innerSourceMap), this._name, this._removeOriginalSource);
37 }
38 return node;
39 }
40
41 listMap(options) {
42 options = options || {};
43 if(options.module === false)
44 return new SourceListMap(this._value, this._name, this._value);
45 return fromStringWithSourceMap(this._value, typeof this._sourceMap === "string" ? JSON.parse(this._sourceMap) : this._sourceMap);
46 }
47
48 updateHash(hash) {
49 hash.update(this._value);
50 if(this._originalSource)
51 hash.update(this._originalSource);
52 }
53}
54
55require("./SourceAndMapMixin")(SourceMapSource.prototype);
56
57module.exports = SourceMapSource;
Note: See TracBrowser for help on using the repository browser.