Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Download
80713 views
1
/***********************************************************************
2
3
A JavaScript tokenizer / parser / beautifier / compressor.
4
https://github.com/mishoo/UglifyJS2
5
6
-------------------------------- (C) ---------------------------------
7
8
Author: Mihai Bazon
9
<[email protected]>
10
http://mihai.bazon.net/blog
11
12
Distributed under the BSD license:
13
14
Copyright 2012 (c) Mihai Bazon <[email protected]>
15
16
Redistribution and use in source and binary forms, with or without
17
modification, are permitted provided that the following conditions
18
are met:
19
20
* Redistributions of source code must retain the above
21
copyright notice, this list of conditions and the following
22
disclaimer.
23
24
* Redistributions in binary form must reproduce the above
25
copyright notice, this list of conditions and the following
26
disclaimer in the documentation and/or other materials
27
provided with the distribution.
28
29
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER “AS IS” AND ANY
30
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
31
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
32
PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE
33
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
34
OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
35
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
36
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
37
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
38
TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
39
THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
40
SUCH DAMAGE.
41
42
***********************************************************************/
43
44
"use strict";
45
46
// a small wrapper around fitzgen's source-map library
47
function SourceMap(options) {
48
options = defaults(options, {
49
file : null,
50
root : null,
51
orig : null,
52
});
53
var generator = new MOZ_SourceMap.SourceMapGenerator({
54
file : options.file,
55
sourceRoot : options.root
56
});
57
var orig_map = options.orig && new MOZ_SourceMap.SourceMapConsumer(options.orig);
58
function add(source, gen_line, gen_col, orig_line, orig_col, name) {
59
if (orig_map) {
60
var info = orig_map.originalPositionFor({
61
line: orig_line,
62
column: orig_col
63
});
64
source = info.source;
65
orig_line = info.line;
66
orig_col = info.column;
67
name = info.name;
68
}
69
generator.addMapping({
70
generated : { line: gen_line, column: gen_col },
71
original : { line: orig_line, column: orig_col },
72
source : source,
73
name : name
74
});
75
};
76
return {
77
add : add,
78
get : function() { return generator },
79
toString : function() { return generator.toString() }
80
};
81
};
82
83