ngannotate-rails 0.9.7 → 0.9.9

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- ZGFiNDQ4MDBiM2ZmYjQ0NjJiMmQ1MjViMjcwY2YyNTM1YTY2MmQ0Yg==
4
+ ODQ2NmUwNTEwZDE5MTA2YzUwZTg2ZGM0NWVlMjM2NzcxYzdhMWM3YQ==
5
5
  data.tar.gz: !binary |-
6
- MjNlMDMzZTUzMTVlYWEzY2FmODJhM2M1MDQzNzRhYjE0YzhiZTJkZQ==
6
+ MWNhYWZlMTQ3NzZmYmEzYmYzNzIzNmNjZmI0OThlMGVjYzg5YmJkMw==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- MDcxNDAzMmIwMDU1ZWU4MGEwMWIwMzkyZmFlOTYyYzQ2NmY4NTQxMDkyOWY1
10
- NjVlYTY4ZWE2ZTU0YmY4N2I0YTI0Mzg2MDliNGY0YzQwNmY0OGUxMWFlYWU3
11
- YjVhMWI1NzQyYzFkMGIyZGM3ZmQ0MzJjNjE1ZGVmYzZlN2IxNzA=
9
+ YmE0MDM1MGYyNjI2NzEzMzlmNWZiYWE1NGMxNDRiZTk1MzYzMTA4ODYyNzRh
10
+ M2VmODNiMzhiOGFhNWVlNTY2MzAyNjY4MjM1OTZmOGFjN2VhMmI1NmFiYzk3
11
+ NGQxNzlhZDg1M2ZhMzhkODE4YTUxMmRmOGRhNWYxYTA5NzhkN2M=
12
12
  data.tar.gz: !binary |-
13
- Y2U4ZGYyYjFjNWFhZTNjMWVjMWUyZDM2OTU2NGNlZTYyNGY5ZjQwNDI1MzY2
14
- NmI1MThiOTdmYzk4MzAyNjY1MDY0MWEyMjIyODhlZTIzZTJkYWVmYjMzOTQy
15
- NTgyYzFhNDI5ZTJhNDMxZmFhYWQyZDFmYjRlYTUwYzBkMmRiODc=
13
+ MTkzNDQxZjc3OWFlMmE1MTdkYjcwYjU5OGE3OTAwNmQ5YWQ2ZmY3ZDMzNTZl
14
+ MGZiNzlkMzMyNTYwYWNiNjMzMzA4ZWVjZWM5Njc3YTU2NjcyZWJlNmViNWRh
15
+ MWI4Mzc1ODk4MzQwODExM2NiMjRmODM3ZjY1NjZlMTNkMThkNTM=
@@ -1,5 +1,5 @@
1
1
  module Ngannotate
2
2
  module Rails
3
- VERSION = "0.9.7"
3
+ VERSION = "0.9.9"
4
4
  end
5
5
  end
@@ -1,4 +1,4 @@
1
- (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);throw new Error("Cannot find module '"+o+"'")}var f=n[o]={exports:{}};t[o][0].call(f.exports,function(e){var n=t[o][1][e];return s(n?n:e)},f,f.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){
1
+ (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){
2
2
  // http://wiki.commonjs.org/wiki/Unit_Testing/1.0
3
3
  //
4
4
  // THIS IS NOT TESTED NOR LIKELY TO WORK OUTSIDE V8!
@@ -956,8 +956,8 @@ function hasOwnProperty(obj, prop) {
956
956
  return Object.prototype.hasOwnProperty.call(obj, prop);
957
957
  }
958
958
 
959
- }).call(this,require("FWaASH"),typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
960
- },{"./support/isBuffer":2,"FWaASH":5,"inherits":4}],4:[function(require,module,exports){
959
+ }).call(this,require('_process'),typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
960
+ },{"./support/isBuffer":2,"_process":7,"inherits":4}],4:[function(require,module,exports){
961
961
  if (typeof Object.create === 'function') {
962
962
  // implementation from standard node.js 'util' module
963
963
  module.exports = function inherits(ctor, superCtor) {
@@ -983,6 +983,281 @@ if (typeof Object.create === 'function') {
983
983
  }
984
984
 
985
985
  },{}],5:[function(require,module,exports){
986
+ exports.endianness = function () { return 'LE' };
987
+
988
+ exports.hostname = function () {
989
+ if (typeof location !== 'undefined') {
990
+ return location.hostname
991
+ }
992
+ else return '';
993
+ };
994
+
995
+ exports.loadavg = function () { return [] };
996
+
997
+ exports.uptime = function () { return 0 };
998
+
999
+ exports.freemem = function () {
1000
+ return Number.MAX_VALUE;
1001
+ };
1002
+
1003
+ exports.totalmem = function () {
1004
+ return Number.MAX_VALUE;
1005
+ };
1006
+
1007
+ exports.cpus = function () { return [] };
1008
+
1009
+ exports.type = function () { return 'Browser' };
1010
+
1011
+ exports.release = function () {
1012
+ if (typeof navigator !== 'undefined') {
1013
+ return navigator.appVersion;
1014
+ }
1015
+ return '';
1016
+ };
1017
+
1018
+ exports.networkInterfaces
1019
+ = exports.getNetworkInterfaces
1020
+ = function () { return {} };
1021
+
1022
+ exports.arch = function () { return 'javascript' };
1023
+
1024
+ exports.platform = function () { return 'browser' };
1025
+
1026
+ exports.tmpdir = exports.tmpDir = function () {
1027
+ return '/tmp';
1028
+ };
1029
+
1030
+ exports.EOL = '\n';
1031
+
1032
+ },{}],6:[function(require,module,exports){
1033
+ (function (process){
1034
+ // Copyright Joyent, Inc. and other Node contributors.
1035
+ //
1036
+ // Permission is hereby granted, free of charge, to any person obtaining a
1037
+ // copy of this software and associated documentation files (the
1038
+ // "Software"), to deal in the Software without restriction, including
1039
+ // without limitation the rights to use, copy, modify, merge, publish,
1040
+ // distribute, sublicense, and/or sell copies of the Software, and to permit
1041
+ // persons to whom the Software is furnished to do so, subject to the
1042
+ // following conditions:
1043
+ //
1044
+ // The above copyright notice and this permission notice shall be included
1045
+ // in all copies or substantial portions of the Software.
1046
+ //
1047
+ // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
1048
+ // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
1049
+ // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
1050
+ // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
1051
+ // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
1052
+ // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
1053
+ // USE OR OTHER DEALINGS IN THE SOFTWARE.
1054
+
1055
+ // resolves . and .. elements in a path array with directory names there
1056
+ // must be no slashes, empty elements, or device names (c:\) in the array
1057
+ // (so also no leading and trailing slashes - it does not distinguish
1058
+ // relative and absolute paths)
1059
+ function normalizeArray(parts, allowAboveRoot) {
1060
+ // if the path tries to go above the root, `up` ends up > 0
1061
+ var up = 0;
1062
+ for (var i = parts.length - 1; i >= 0; i--) {
1063
+ var last = parts[i];
1064
+ if (last === '.') {
1065
+ parts.splice(i, 1);
1066
+ } else if (last === '..') {
1067
+ parts.splice(i, 1);
1068
+ up++;
1069
+ } else if (up) {
1070
+ parts.splice(i, 1);
1071
+ up--;
1072
+ }
1073
+ }
1074
+
1075
+ // if the path is allowed to go above the root, restore leading ..s
1076
+ if (allowAboveRoot) {
1077
+ for (; up--; up) {
1078
+ parts.unshift('..');
1079
+ }
1080
+ }
1081
+
1082
+ return parts;
1083
+ }
1084
+
1085
+ // Split a filename into [root, dir, basename, ext], unix version
1086
+ // 'root' is just a slash, or nothing.
1087
+ var splitPathRe =
1088
+ /^(\/?|)([\s\S]*?)((?:\.{1,2}|[^\/]+?|)(\.[^.\/]*|))(?:[\/]*)$/;
1089
+ var splitPath = function(filename) {
1090
+ return splitPathRe.exec(filename).slice(1);
1091
+ };
1092
+
1093
+ // path.resolve([from ...], to)
1094
+ // posix version
1095
+ exports.resolve = function() {
1096
+ var resolvedPath = '',
1097
+ resolvedAbsolute = false;
1098
+
1099
+ for (var i = arguments.length - 1; i >= -1 && !resolvedAbsolute; i--) {
1100
+ var path = (i >= 0) ? arguments[i] : process.cwd();
1101
+
1102
+ // Skip empty and invalid entries
1103
+ if (typeof path !== 'string') {
1104
+ throw new TypeError('Arguments to path.resolve must be strings');
1105
+ } else if (!path) {
1106
+ continue;
1107
+ }
1108
+
1109
+ resolvedPath = path + '/' + resolvedPath;
1110
+ resolvedAbsolute = path.charAt(0) === '/';
1111
+ }
1112
+
1113
+ // At this point the path should be resolved to a full absolute path, but
1114
+ // handle relative paths to be safe (might happen when process.cwd() fails)
1115
+
1116
+ // Normalize the path
1117
+ resolvedPath = normalizeArray(filter(resolvedPath.split('/'), function(p) {
1118
+ return !!p;
1119
+ }), !resolvedAbsolute).join('/');
1120
+
1121
+ return ((resolvedAbsolute ? '/' : '') + resolvedPath) || '.';
1122
+ };
1123
+
1124
+ // path.normalize(path)
1125
+ // posix version
1126
+ exports.normalize = function(path) {
1127
+ var isAbsolute = exports.isAbsolute(path),
1128
+ trailingSlash = substr(path, -1) === '/';
1129
+
1130
+ // Normalize the path
1131
+ path = normalizeArray(filter(path.split('/'), function(p) {
1132
+ return !!p;
1133
+ }), !isAbsolute).join('/');
1134
+
1135
+ if (!path && !isAbsolute) {
1136
+ path = '.';
1137
+ }
1138
+ if (path && trailingSlash) {
1139
+ path += '/';
1140
+ }
1141
+
1142
+ return (isAbsolute ? '/' : '') + path;
1143
+ };
1144
+
1145
+ // posix version
1146
+ exports.isAbsolute = function(path) {
1147
+ return path.charAt(0) === '/';
1148
+ };
1149
+
1150
+ // posix version
1151
+ exports.join = function() {
1152
+ var paths = Array.prototype.slice.call(arguments, 0);
1153
+ return exports.normalize(filter(paths, function(p, index) {
1154
+ if (typeof p !== 'string') {
1155
+ throw new TypeError('Arguments to path.join must be strings');
1156
+ }
1157
+ return p;
1158
+ }).join('/'));
1159
+ };
1160
+
1161
+
1162
+ // path.relative(from, to)
1163
+ // posix version
1164
+ exports.relative = function(from, to) {
1165
+ from = exports.resolve(from).substr(1);
1166
+ to = exports.resolve(to).substr(1);
1167
+
1168
+ function trim(arr) {
1169
+ var start = 0;
1170
+ for (; start < arr.length; start++) {
1171
+ if (arr[start] !== '') break;
1172
+ }
1173
+
1174
+ var end = arr.length - 1;
1175
+ for (; end >= 0; end--) {
1176
+ if (arr[end] !== '') break;
1177
+ }
1178
+
1179
+ if (start > end) return [];
1180
+ return arr.slice(start, end - start + 1);
1181
+ }
1182
+
1183
+ var fromParts = trim(from.split('/'));
1184
+ var toParts = trim(to.split('/'));
1185
+
1186
+ var length = Math.min(fromParts.length, toParts.length);
1187
+ var samePartsLength = length;
1188
+ for (var i = 0; i < length; i++) {
1189
+ if (fromParts[i] !== toParts[i]) {
1190
+ samePartsLength = i;
1191
+ break;
1192
+ }
1193
+ }
1194
+
1195
+ var outputParts = [];
1196
+ for (var i = samePartsLength; i < fromParts.length; i++) {
1197
+ outputParts.push('..');
1198
+ }
1199
+
1200
+ outputParts = outputParts.concat(toParts.slice(samePartsLength));
1201
+
1202
+ return outputParts.join('/');
1203
+ };
1204
+
1205
+ exports.sep = '/';
1206
+ exports.delimiter = ':';
1207
+
1208
+ exports.dirname = function(path) {
1209
+ var result = splitPath(path),
1210
+ root = result[0],
1211
+ dir = result[1];
1212
+
1213
+ if (!root && !dir) {
1214
+ // No dirname whatsoever
1215
+ return '.';
1216
+ }
1217
+
1218
+ if (dir) {
1219
+ // It has a dirname, strip trailing slash
1220
+ dir = dir.substr(0, dir.length - 1);
1221
+ }
1222
+
1223
+ return root + dir;
1224
+ };
1225
+
1226
+
1227
+ exports.basename = function(path, ext) {
1228
+ var f = splitPath(path)[2];
1229
+ // TODO: make this comparison case-insensitive on windows?
1230
+ if (ext && f.substr(-1 * ext.length) === ext) {
1231
+ f = f.substr(0, f.length - ext.length);
1232
+ }
1233
+ return f;
1234
+ };
1235
+
1236
+
1237
+ exports.extname = function(path) {
1238
+ return splitPath(path)[3];
1239
+ };
1240
+
1241
+ function filter (xs, f) {
1242
+ if (xs.filter) return xs.filter(f);
1243
+ var res = [];
1244
+ for (var i = 0; i < xs.length; i++) {
1245
+ if (f(xs[i], i, xs)) res.push(xs[i]);
1246
+ }
1247
+ return res;
1248
+ }
1249
+
1250
+ // String.prototype.substr - negative index don't work in IE8
1251
+ var substr = 'ab'.substr(-1) === 'b'
1252
+ ? function (str, start, len) { return str.substr(start, len) }
1253
+ : function (str, start, len) {
1254
+ if (start < 0) start = str.length + start;
1255
+ return str.substr(start, len);
1256
+ }
1257
+ ;
1258
+
1259
+ }).call(this,require('_process'))
1260
+ },{"_process":7}],7:[function(require,module,exports){
986
1261
  // shim for using process in browser
987
1262
 
988
1263
  var process = module.exports = {};
@@ -1047,7 +1322,99 @@ process.chdir = function (dir) {
1047
1322
  throw new Error('process.chdir is not supported');
1048
1323
  };
1049
1324
 
1050
- },{}],6:[function(require,module,exports){
1325
+ },{}],8:[function(require,module,exports){
1326
+ "use strict";
1327
+
1328
+ var SourceMapGenerator = require("source-map").SourceMapGenerator;
1329
+ var stableSort = require("stable");
1330
+
1331
+ function SourceMapper(src, fragments, inFile, sourceRoot) {
1332
+ this.generator = new SourceMapGenerator({ sourceRoot: sourceRoot });
1333
+ this.src = src;
1334
+ this.fragments = stableSort(fragments.slice(0), function(a, b) { return a.start - b.start });
1335
+ this.inFile = inFile || "source.js";
1336
+
1337
+ this.generator.setSourceContent(this.inFile, src);
1338
+ }
1339
+
1340
+ SourceMapper.prototype.generate = function() {
1341
+ var inIndex = 0;
1342
+ var inLine = 1;
1343
+ var inColumn = 0;
1344
+ var outLine = 1;
1345
+ var outColumn = 0;
1346
+ var createMappingAfterWhitespace = true;
1347
+
1348
+ while (inIndex < this.src.length) {
1349
+ if (createMappingAfterWhitespace && !/\s/.test(this.src[inIndex])) {
1350
+ this.addMapping(inLine, inColumn, outLine, outColumn);
1351
+ createMappingAfterWhitespace = false;
1352
+ }
1353
+
1354
+ if (this.fragments[0] && this.fragments[0].start === inIndex) {
1355
+ this.addMapping(inLine, inColumn, outLine, outColumn);
1356
+
1357
+ // iterate over input string
1358
+ for (; inIndex < this.fragments[0].end; inIndex++) {
1359
+ if (this.src[inIndex] === '\n') {
1360
+ inLine++;
1361
+ inColumn = 0;
1362
+ } else {
1363
+ inColumn++;
1364
+ }
1365
+ }
1366
+
1367
+ // iterate over output string
1368
+ for (var outIndex = 0; outIndex < this.fragments[0].str.length; outIndex++) {
1369
+ if (this.fragments[0].str[outIndex] === '\n') {
1370
+ outLine++;
1371
+ outColumn = 0;
1372
+ } else {
1373
+ outColumn++;
1374
+ }
1375
+ }
1376
+
1377
+ this.fragments.shift();
1378
+ createMappingAfterWhitespace = true;
1379
+ }
1380
+
1381
+ else {
1382
+ if (this.src[inIndex] === '\n') {
1383
+ inLine++;
1384
+ outLine++;
1385
+ inColumn = 0;
1386
+ outColumn = 0;
1387
+ createMappingAfterWhitespace = true;
1388
+ } else {
1389
+ inColumn++;
1390
+ outColumn++;
1391
+ }
1392
+ inIndex++;
1393
+ }
1394
+ }
1395
+
1396
+ return this.generator.toString();
1397
+ }
1398
+
1399
+ SourceMapper.prototype.addMapping = function(inLine, inColumn, outLine, outColumn) {
1400
+ this.generator.addMapping({
1401
+ source: this.inFile,
1402
+ original: {
1403
+ line: inLine,
1404
+ column: inColumn
1405
+ },
1406
+ generated: {
1407
+ line: outLine,
1408
+ column: outColumn
1409
+ }
1410
+ });
1411
+ }
1412
+
1413
+ module.exports = function generateSourcemap(src, fragments, inFile, sourceRoot) {
1414
+ return new SourceMapper(src, fragments, inFile, sourceRoot).generate();
1415
+ }
1416
+
1417
+ },{"source-map":19,"stable":29}],9:[function(require,module,exports){
1051
1418
  "use strict";
1052
1419
 
1053
1420
  var assert = require("assert");
@@ -1084,7 +1451,7 @@ function Heap() {
1084
1451
 
1085
1452
  module.exports = Heap;
1086
1453
 
1087
- },{"assert":1,"priorityqueuejs":14}],7:[function(require,module,exports){
1454
+ },{"assert":1,"priorityqueuejs":16}],10:[function(require,module,exports){
1088
1455
  // ng-annotate-main.js
1089
1456
  // MIT licensed, see LICENSE file
1090
1457
  // Copyright (c) 2013-2014 Olov Lassus <olov.lassus@gmail.com>
@@ -1098,6 +1465,7 @@ var alter = require("alter");
1098
1465
  var traverse = require("ordered-ast-traverse");
1099
1466
  var Heap = require("./heap");
1100
1467
  var ngInjectComments = require("./nginject-comments");
1468
+ var generateSourcemap = require("./generate-sourcemap");
1101
1469
 
1102
1470
  var chainedRouteProvider = 1;
1103
1471
  var chainedUrlRouterProvider = 2;
@@ -1291,6 +1659,16 @@ function matchRegular(node, ctx) {
1291
1659
  var obj = callee.object; // identifier or expression
1292
1660
  var method = callee.property; // identifier
1293
1661
 
1662
+ // short-cut implicit config special case:
1663
+ // angular.module("MyMod", function(a) {})
1664
+ if (obj.name === "angular" && method.name === "module") {
1665
+ var args$0 = node.arguments;
1666
+ if (args$0.length >= 2) {
1667
+ last(args$0).$always = true;
1668
+ return last(args$0);
1669
+ }
1670
+ }
1671
+
1294
1672
  var matchAngularModule = (obj.$chained === chainedRegular || isReDef(obj, ctx) || isLongDef(obj)) &&
1295
1673
  is.someof(method.name, ["provider", "value", "constant", "bootstrap", "config", "factory", "directive", "filter", "run", "controller", "service", "decorator", "animation", "invoke"]);
1296
1674
  if (!matchAngularModule) {
@@ -1427,6 +1805,8 @@ function judgeSuspects(ctx) {
1427
1805
  }
1428
1806
  }
1429
1807
 
1808
+ target = jumpOverIife(target);
1809
+
1430
1810
  if (mode === "rebuild" && isAnnotatedArray(target)) {
1431
1811
  replaceArray(target, fragments, quot);
1432
1812
  } else if (mode === "remove" && isAnnotatedArray(target)) {
@@ -1437,6 +1817,18 @@ function judgeSuspects(ctx) {
1437
1817
  }
1438
1818
  }
1439
1819
 
1820
+ function jumpOverIife(node) {
1821
+ var outerfn;
1822
+ var outerbody;
1823
+ if (node.type === "CallExpression" &&
1824
+ (outerfn = node.callee).type === "FunctionExpression" &&
1825
+ (outerbody = outerfn.body.body).length === 1 &&
1826
+ outerbody[0].type === "ReturnStatement" && outerbody[0].argument) {
1827
+ return outerbody[0].argument;
1828
+ }
1829
+ return node;
1830
+ }
1831
+
1440
1832
  function addModuleContextDependentSuspect(target, ctx) {
1441
1833
  ctx.suspects.push(target);
1442
1834
  }
@@ -1589,16 +1981,24 @@ window.annotate = function ngAnnotate(src, options) {
1589
1981
  judgeSuspects(ctx);
1590
1982
 
1591
1983
  var out = alter(src, fragments);
1592
-
1593
- return {
1984
+ var result = {
1594
1985
  src: out,
1595
1986
  _stats: stats,
1596
1987
  };
1988
+
1989
+ if (options.sourcemap) {
1990
+ stats.sourcemap_t0 = Date.now();
1991
+ result.map = generateSourcemap(src, fragments, options.inFile, options.sourceroot);
1992
+ stats.sourcemap_t1 = Date.now();
1993
+ }
1994
+
1995
+ return result;
1597
1996
  }
1598
1997
 
1599
- },{"./heap":6,"./nginject-comments":8,"alter":9,"esprima":11,"ordered-ast-traverse":13,"simple-is":16}],8:[function(require,module,exports){
1998
+ },{"./generate-sourcemap":8,"./heap":9,"./nginject-comments":11,"alter":12,"esprima":13,"ordered-ast-traverse":15,"simple-is":18}],11:[function(require,module,exports){
1600
1999
  "use strict";
1601
2000
 
2001
+ var os = require("os");
1602
2002
  var is = require("simple-is");
1603
2003
  var fmt = require("simple-fmt");
1604
2004
 
@@ -1641,7 +2041,8 @@ function nestedObjectValues(node, res) {
1641
2041
 
1642
2042
  function visitNodeFollowingNgInjectComment(node, ctx) {
1643
2043
  // handle most common case: /*@ngInject*/ prepended to an array or function expression
1644
- if (node.type === "ArrayExpression" || node.type === "FunctionExpression") {
2044
+ // (or call expression, in case of IIFE jumping)
2045
+ if (node.type === "ArrayExpression" || node.type === "FunctionExpression" || node.type === "CallExpression") {
1645
2046
  ctx.addModuleContextIndependentSuspect(node, ctx);
1646
2047
  return;
1647
2048
  }
@@ -1681,7 +2082,7 @@ function visitNodeFollowingNgInjectComment(node, ctx) {
1681
2082
 
1682
2083
  function addRemoveInjectArray(params, posAfterFunctionDeclaration, name) {
1683
2084
  var indent = getIndent(posAfterFunctionDeclaration);
1684
- var str = fmt("\n{0}{1}.$inject = {2};", indent, name, ctx.stringify(params, ctx.quot));
2085
+ var str = fmt("{0}{1}{2}.$inject = {3};", os.EOL, indent, name, ctx.stringify(params, ctx.quot));
1685
2086
 
1686
2087
  ctx.triggers.add({
1687
2088
  pos: posAfterFunctionDeclaration,
@@ -1720,7 +2121,7 @@ function visitNodeFollowingNgInjectComment(node, ctx) {
1720
2121
  }
1721
2122
 
1722
2123
 
1723
- },{"simple-fmt":15,"simple-is":16}],9:[function(require,module,exports){
2124
+ },{"os":5,"simple-fmt":17,"simple-is":18}],12:[function(require,module,exports){
1724
2125
  // alter.js
1725
2126
  // MIT licensed, see LICENSE file
1726
2127
  // Copyright (c) 2013 Olov Lassus <olov.lassus@gmail.com>
@@ -1767,180 +2168,67 @@ if (typeof module !== "undefined" && typeof module.exports !== "undefined") {
1767
2168
  module.exports = alter;
1768
2169
  }
1769
2170
 
1770
- },{"assert":1,"stable":10}],10:[function(require,module,exports){
1771
- //! stable.js 0.1.5, https://github.com/Two-Screen/stable
1772
- //! © 2014 Angry Bytes and contributors. MIT licensed.
1773
-
1774
- (function() {
1775
-
1776
- // A stable array sort, because `Array#sort()` is not guaranteed stable.
1777
- // This is an implementation of merge sort, without recursion.
1778
-
1779
- var stable = function(arr, comp) {
1780
- return exec(arr.slice(), comp);
1781
- };
2171
+ },{"assert":1,"stable":29}],13:[function(require,module,exports){
2172
+ /*
2173
+ Copyright (C) 2013 Ariya Hidayat <ariya.hidayat@gmail.com>
2174
+ Copyright (C) 2013 Thaddee Tyl <thaddee.tyl@gmail.com>
2175
+ Copyright (C) 2013 Mathias Bynens <mathias@qiwi.be>
2176
+ Copyright (C) 2012 Ariya Hidayat <ariya.hidayat@gmail.com>
2177
+ Copyright (C) 2012 Mathias Bynens <mathias@qiwi.be>
2178
+ Copyright (C) 2012 Joost-Wim Boekesteijn <joost-wim@boekesteijn.nl>
2179
+ Copyright (C) 2012 Kris Kowal <kris.kowal@cixar.com>
2180
+ Copyright (C) 2012 Yusuke Suzuki <utatane.tea@gmail.com>
2181
+ Copyright (C) 2012 Arpad Borsos <arpad.borsos@googlemail.com>
2182
+ Copyright (C) 2011 Ariya Hidayat <ariya.hidayat@gmail.com>
1782
2183
 
1783
- stable.inplace = function(arr, comp) {
1784
- var result = exec(arr, comp);
2184
+ Redistribution and use in source and binary forms, with or without
2185
+ modification, are permitted provided that the following conditions are met:
1785
2186
 
1786
- // This simply copies back if the result isn't in the original array,
1787
- // which happens on an odd number of passes.
1788
- if (result !== arr) {
1789
- pass(result, null, arr.length, arr);
1790
- }
2187
+ * Redistributions of source code must retain the above copyright
2188
+ notice, this list of conditions and the following disclaimer.
2189
+ * Redistributions in binary form must reproduce the above copyright
2190
+ notice, this list of conditions and the following disclaimer in the
2191
+ documentation and/or other materials provided with the distribution.
1791
2192
 
1792
- return arr;
1793
- };
2193
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
2194
+ AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
2195
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
2196
+ ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
2197
+ DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
2198
+ (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
2199
+ LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
2200
+ ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
2201
+ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
2202
+ THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2203
+ */
1794
2204
 
1795
- // Execute the sort using the input array and a second buffer as work space.
1796
- // Returns one of those two, containing the final result.
1797
- function exec(arr, comp) {
1798
- if (typeof(comp) !== 'function') {
1799
- comp = function(a, b) {
1800
- return String(a).localeCompare(b);
1801
- };
1802
- }
2205
+ /*jslint bitwise:true plusplus:true */
2206
+ /*global esprima:true, define:true, exports:true, window: true,
2207
+ throwErrorTolerant: true,
2208
+ throwError: true, generateStatement: true, peek: true,
2209
+ parseAssignmentExpression: true, parseBlock: true, parseExpression: true,
2210
+ parseFunctionDeclaration: true, parseFunctionExpression: true,
2211
+ parseFunctionSourceElements: true, parseVariableIdentifier: true,
2212
+ parseLeftHandSideExpression: true,
2213
+ parseUnaryExpression: true,
2214
+ parseStatement: true, parseSourceElement: true */
1803
2215
 
1804
- // Short-circuit when there's nothing to sort.
1805
- var len = arr.length;
1806
- if (len <= 1) {
1807
- return arr;
1808
- }
2216
+ (function (root, factory) {
2217
+ 'use strict';
1809
2218
 
1810
- // Rather than dividing input, simply iterate chunks of 1, 2, 4, 8, etc.
1811
- // Chunks are the size of the left or right hand in merge sort.
1812
- // Stop when the left-hand covers all of the array.
1813
- var buffer = new Array(len);
1814
- for (var chk = 1; chk < len; chk *= 2) {
1815
- pass(arr, comp, chk, buffer);
2219
+ // Universal Module Definition (UMD) to support AMD, CommonJS/Node.js,
2220
+ // Rhino, and plain browser loading.
1816
2221
 
1817
- var tmp = arr;
1818
- arr = buffer;
1819
- buffer = tmp;
2222
+ /* istanbul ignore next */
2223
+ if (typeof define === 'function' && define.amd) {
2224
+ define(['exports'], factory);
2225
+ } else if (typeof exports !== 'undefined') {
2226
+ factory(exports);
2227
+ } else {
2228
+ factory((root.esprima = {}));
1820
2229
  }
1821
-
1822
- return arr;
1823
- }
1824
-
1825
- // Run a single pass with the given chunk size.
1826
- var pass = function(arr, comp, chk, result) {
1827
- var len = arr.length;
1828
- var i = 0;
1829
- // Step size / double chunk size.
1830
- var dbl = chk * 2;
1831
- // Bounds of the left and right chunks.
1832
- var l, r, e;
1833
- // Iterators over the left and right chunk.
1834
- var li, ri;
1835
-
1836
- // Iterate over pairs of chunks.
1837
- for (l = 0; l < len; l += dbl) {
1838
- r = l + chk;
1839
- e = r + chk;
1840
- if (r > len) r = len;
1841
- if (e > len) e = len;
1842
-
1843
- // Iterate both chunks in parallel.
1844
- li = l;
1845
- ri = r;
1846
- while (true) {
1847
- // Compare the chunks.
1848
- if (li < r && ri < e) {
1849
- // This works for a regular `sort()` compatible comparator,
1850
- // but also for a simple comparator like: `a > b`
1851
- if (comp(arr[li], arr[ri]) <= 0) {
1852
- result[i++] = arr[li++];
1853
- }
1854
- else {
1855
- result[i++] = arr[ri++];
1856
- }
1857
- }
1858
- // Nothing to compare, just flush what's left.
1859
- else if (li < r) {
1860
- result[i++] = arr[li++];
1861
- }
1862
- else if (ri < e) {
1863
- result[i++] = arr[ri++];
1864
- }
1865
- // Both iterators are at the chunk ends.
1866
- else {
1867
- break;
1868
- }
1869
- }
1870
- }
1871
- };
1872
-
1873
- // Export using CommonJS or to the window.
1874
- if (typeof(module) !== 'undefined') {
1875
- module.exports = stable;
1876
- }
1877
- else {
1878
- window.stable = stable;
1879
- }
1880
-
1881
- })();
1882
-
1883
- },{}],11:[function(require,module,exports){
1884
- /*
1885
- Copyright (C) 2013 Ariya Hidayat <ariya.hidayat@gmail.com>
1886
- Copyright (C) 2013 Thaddee Tyl <thaddee.tyl@gmail.com>
1887
- Copyright (C) 2013 Mathias Bynens <mathias@qiwi.be>
1888
- Copyright (C) 2012 Ariya Hidayat <ariya.hidayat@gmail.com>
1889
- Copyright (C) 2012 Mathias Bynens <mathias@qiwi.be>
1890
- Copyright (C) 2012 Joost-Wim Boekesteijn <joost-wim@boekesteijn.nl>
1891
- Copyright (C) 2012 Kris Kowal <kris.kowal@cixar.com>
1892
- Copyright (C) 2012 Yusuke Suzuki <utatane.tea@gmail.com>
1893
- Copyright (C) 2012 Arpad Borsos <arpad.borsos@googlemail.com>
1894
- Copyright (C) 2011 Ariya Hidayat <ariya.hidayat@gmail.com>
1895
-
1896
- Redistribution and use in source and binary forms, with or without
1897
- modification, are permitted provided that the following conditions are met:
1898
-
1899
- * Redistributions of source code must retain the above copyright
1900
- notice, this list of conditions and the following disclaimer.
1901
- * Redistributions in binary form must reproduce the above copyright
1902
- notice, this list of conditions and the following disclaimer in the
1903
- documentation and/or other materials provided with the distribution.
1904
-
1905
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
1906
- AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
1907
- IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
1908
- ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
1909
- DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
1910
- (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
1911
- LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
1912
- ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
1913
- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
1914
- THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
1915
- */
1916
-
1917
- /*jslint bitwise:true plusplus:true */
1918
- /*global esprima:true, define:true, exports:true, window: true,
1919
- throwErrorTolerant: true,
1920
- throwError: true, generateStatement: true, peek: true,
1921
- parseAssignmentExpression: true, parseBlock: true, parseExpression: true,
1922
- parseFunctionDeclaration: true, parseFunctionExpression: true,
1923
- parseFunctionSourceElements: true, parseVariableIdentifier: true,
1924
- parseLeftHandSideExpression: true,
1925
- parseUnaryExpression: true,
1926
- parseStatement: true, parseSourceElement: true */
1927
-
1928
- (function (root, factory) {
1929
- 'use strict';
1930
-
1931
- // Universal Module Definition (UMD) to support AMD, CommonJS/Node.js,
1932
- // Rhino, and plain browser loading.
1933
-
1934
- /* istanbul ignore next */
1935
- if (typeof define === 'function' && define.amd) {
1936
- define(['exports'], factory);
1937
- } else if (typeof exports !== 'undefined') {
1938
- factory(exports);
1939
- } else {
1940
- factory((root.esprima = {}));
1941
- }
1942
- }(this, function (exports) {
1943
- 'use strict';
2230
+ }(this, function (exports) {
2231
+ 'use strict';
1944
2232
 
1945
2233
  var Token,
1946
2234
  TokenName,
@@ -5638,7 +5926,7 @@ parseStatement: true, parseSourceElement: true */
5638
5926
  }));
5639
5927
  /* vim: set sw=4 ts=4 et tw=80 : */
5640
5928
 
5641
- },{}],12:[function(require,module,exports){
5929
+ },{}],14:[function(require,module,exports){
5642
5930
  // ordered-esprima-props.js
5643
5931
  // MIT licensed, see LICENSE file
5644
5932
  // Copyright (c) 2014 Olov Lassus <olov.lassus@gmail.com>
@@ -5717,7 +6005,7 @@ module.exports = (function() {
5717
6005
  };
5718
6006
  })();
5719
6007
 
5720
- },{}],13:[function(require,module,exports){
6008
+ },{}],15:[function(require,module,exports){
5721
6009
  // ordered-ast-traverse.js
5722
6010
  // MIT licensed, see LICENSE file
5723
6011
  // Copyright (c) 2014 Olov Lassus <olov.lassus@gmail.com>
@@ -5778,7 +6066,7 @@ if (typeof module !== "undefined" && typeof module.exports !== "undefined") {
5778
6066
  module.exports = traverse;
5779
6067
  }
5780
6068
 
5781
- },{"ordered-esprima-props":12}],14:[function(require,module,exports){
6069
+ },{"ordered-esprima-props":14}],16:[function(require,module,exports){
5782
6070
  /**
5783
6071
  * Expose `PriorityQueue`.
5784
6072
  */
@@ -5952,7 +6240,7 @@ PriorityQueue.prototype._swap = function(a, b) {
5952
6240
  this._elements[b] = aux;
5953
6241
  };
5954
6242
 
5955
- },{}],15:[function(require,module,exports){
6243
+ },{}],17:[function(require,module,exports){
5956
6244
  // simple-fmt.js
5957
6245
  // MIT licensed, see LICENSE file
5958
6246
  // Copyright (c) 2013 Olov Lassus <olov.lassus@gmail.com>
@@ -5987,7 +6275,7 @@ if (typeof module !== "undefined" && typeof module.exports !== "undefined") {
5987
6275
  module.exports = fmt;
5988
6276
  }
5989
6277
 
5990
- },{}],16:[function(require,module,exports){
6278
+ },{}],18:[function(require,module,exports){
5991
6279
  // simple-is.js
5992
6280
  // MIT licensed, see LICENSE file
5993
6281
  // Copyright (c) 2013 Olov Lassus <olov.lassus@gmail.com>
@@ -6045,4 +6333,2418 @@ if (typeof module !== "undefined" && typeof module.exports !== "undefined") {
6045
6333
  module.exports = is;
6046
6334
  }
6047
6335
 
6048
- },{}]},{},[7])
6336
+ },{}],19:[function(require,module,exports){
6337
+ /*
6338
+ * Copyright 2009-2011 Mozilla Foundation and contributors
6339
+ * Licensed under the New BSD license. See LICENSE.txt or:
6340
+ * http://opensource.org/licenses/BSD-3-Clause
6341
+ */
6342
+ exports.SourceMapGenerator = require('./source-map/source-map-generator').SourceMapGenerator;
6343
+ exports.SourceMapConsumer = require('./source-map/source-map-consumer').SourceMapConsumer;
6344
+ exports.SourceNode = require('./source-map/source-node').SourceNode;
6345
+
6346
+ },{"./source-map/source-map-consumer":24,"./source-map/source-map-generator":25,"./source-map/source-node":26}],20:[function(require,module,exports){
6347
+ /* -*- Mode: js; js-indent-level: 2; -*- */
6348
+ /*
6349
+ * Copyright 2011 Mozilla Foundation and contributors
6350
+ * Licensed under the New BSD license. See LICENSE or:
6351
+ * http://opensource.org/licenses/BSD-3-Clause
6352
+ */
6353
+ if (typeof define !== 'function') {
6354
+ var define = require('amdefine')(module, require);
6355
+ }
6356
+ define(function (require, exports, module) {
6357
+
6358
+ var util = require('./util');
6359
+
6360
+ /**
6361
+ * A data structure which is a combination of an array and a set. Adding a new
6362
+ * member is O(1), testing for membership is O(1), and finding the index of an
6363
+ * element is O(1). Removing elements from the set is not supported. Only
6364
+ * strings are supported for membership.
6365
+ */
6366
+ function ArraySet() {
6367
+ this._array = [];
6368
+ this._set = {};
6369
+ }
6370
+
6371
+ /**
6372
+ * Static method for creating ArraySet instances from an existing array.
6373
+ */
6374
+ ArraySet.fromArray = function ArraySet_fromArray(aArray, aAllowDuplicates) {
6375
+ var set = new ArraySet();
6376
+ for (var i = 0, len = aArray.length; i < len; i++) {
6377
+ set.add(aArray[i], aAllowDuplicates);
6378
+ }
6379
+ return set;
6380
+ };
6381
+
6382
+ /**
6383
+ * Add the given string to this set.
6384
+ *
6385
+ * @param String aStr
6386
+ */
6387
+ ArraySet.prototype.add = function ArraySet_add(aStr, aAllowDuplicates) {
6388
+ var isDuplicate = this.has(aStr);
6389
+ var idx = this._array.length;
6390
+ if (!isDuplicate || aAllowDuplicates) {
6391
+ this._array.push(aStr);
6392
+ }
6393
+ if (!isDuplicate) {
6394
+ this._set[util.toSetString(aStr)] = idx;
6395
+ }
6396
+ };
6397
+
6398
+ /**
6399
+ * Is the given string a member of this set?
6400
+ *
6401
+ * @param String aStr
6402
+ */
6403
+ ArraySet.prototype.has = function ArraySet_has(aStr) {
6404
+ return Object.prototype.hasOwnProperty.call(this._set,
6405
+ util.toSetString(aStr));
6406
+ };
6407
+
6408
+ /**
6409
+ * What is the index of the given string in the array?
6410
+ *
6411
+ * @param String aStr
6412
+ */
6413
+ ArraySet.prototype.indexOf = function ArraySet_indexOf(aStr) {
6414
+ if (this.has(aStr)) {
6415
+ return this._set[util.toSetString(aStr)];
6416
+ }
6417
+ throw new Error('"' + aStr + '" is not in the set.');
6418
+ };
6419
+
6420
+ /**
6421
+ * What is the element at the given index?
6422
+ *
6423
+ * @param Number aIdx
6424
+ */
6425
+ ArraySet.prototype.at = function ArraySet_at(aIdx) {
6426
+ if (aIdx >= 0 && aIdx < this._array.length) {
6427
+ return this._array[aIdx];
6428
+ }
6429
+ throw new Error('No element indexed by ' + aIdx);
6430
+ };
6431
+
6432
+ /**
6433
+ * Returns the array representation of this set (which has the proper indices
6434
+ * indicated by indexOf). Note that this is a copy of the internal array used
6435
+ * for storing the members so that no one can mess with internal state.
6436
+ */
6437
+ ArraySet.prototype.toArray = function ArraySet_toArray() {
6438
+ return this._array.slice();
6439
+ };
6440
+
6441
+ exports.ArraySet = ArraySet;
6442
+
6443
+ });
6444
+
6445
+ },{"./util":27,"amdefine":28}],21:[function(require,module,exports){
6446
+ /* -*- Mode: js; js-indent-level: 2; -*- */
6447
+ /*
6448
+ * Copyright 2011 Mozilla Foundation and contributors
6449
+ * Licensed under the New BSD license. See LICENSE or:
6450
+ * http://opensource.org/licenses/BSD-3-Clause
6451
+ *
6452
+ * Based on the Base 64 VLQ implementation in Closure Compiler:
6453
+ * https://code.google.com/p/closure-compiler/source/browse/trunk/src/com/google/debugging/sourcemap/Base64VLQ.java
6454
+ *
6455
+ * Copyright 2011 The Closure Compiler Authors. All rights reserved.
6456
+ * Redistribution and use in source and binary forms, with or without
6457
+ * modification, are permitted provided that the following conditions are
6458
+ * met:
6459
+ *
6460
+ * * Redistributions of source code must retain the above copyright
6461
+ * notice, this list of conditions and the following disclaimer.
6462
+ * * Redistributions in binary form must reproduce the above
6463
+ * copyright notice, this list of conditions and the following
6464
+ * disclaimer in the documentation and/or other materials provided
6465
+ * with the distribution.
6466
+ * * Neither the name of Google Inc. nor the names of its
6467
+ * contributors may be used to endorse or promote products derived
6468
+ * from this software without specific prior written permission.
6469
+ *
6470
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
6471
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
6472
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
6473
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
6474
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
6475
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
6476
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
6477
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
6478
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
6479
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
6480
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
6481
+ */
6482
+ if (typeof define !== 'function') {
6483
+ var define = require('amdefine')(module, require);
6484
+ }
6485
+ define(function (require, exports, module) {
6486
+
6487
+ var base64 = require('./base64');
6488
+
6489
+ // A single base 64 digit can contain 6 bits of data. For the base 64 variable
6490
+ // length quantities we use in the source map spec, the first bit is the sign,
6491
+ // the next four bits are the actual value, and the 6th bit is the
6492
+ // continuation bit. The continuation bit tells us whether there are more
6493
+ // digits in this value following this digit.
6494
+ //
6495
+ // Continuation
6496
+ // | Sign
6497
+ // | |
6498
+ // V V
6499
+ // 101011
6500
+
6501
+ var VLQ_BASE_SHIFT = 5;
6502
+
6503
+ // binary: 100000
6504
+ var VLQ_BASE = 1 << VLQ_BASE_SHIFT;
6505
+
6506
+ // binary: 011111
6507
+ var VLQ_BASE_MASK = VLQ_BASE - 1;
6508
+
6509
+ // binary: 100000
6510
+ var VLQ_CONTINUATION_BIT = VLQ_BASE;
6511
+
6512
+ /**
6513
+ * Converts from a two-complement value to a value where the sign bit is
6514
+ * is placed in the least significant bit. For example, as decimals:
6515
+ * 1 becomes 2 (10 binary), -1 becomes 3 (11 binary)
6516
+ * 2 becomes 4 (100 binary), -2 becomes 5 (101 binary)
6517
+ */
6518
+ function toVLQSigned(aValue) {
6519
+ return aValue < 0
6520
+ ? ((-aValue) << 1) + 1
6521
+ : (aValue << 1) + 0;
6522
+ }
6523
+
6524
+ /**
6525
+ * Converts to a two-complement value from a value where the sign bit is
6526
+ * is placed in the least significant bit. For example, as decimals:
6527
+ * 2 (10 binary) becomes 1, 3 (11 binary) becomes -1
6528
+ * 4 (100 binary) becomes 2, 5 (101 binary) becomes -2
6529
+ */
6530
+ function fromVLQSigned(aValue) {
6531
+ var isNegative = (aValue & 1) === 1;
6532
+ var shifted = aValue >> 1;
6533
+ return isNegative
6534
+ ? -shifted
6535
+ : shifted;
6536
+ }
6537
+
6538
+ /**
6539
+ * Returns the base 64 VLQ encoded value.
6540
+ */
6541
+ exports.encode = function base64VLQ_encode(aValue) {
6542
+ var encoded = "";
6543
+ var digit;
6544
+
6545
+ var vlq = toVLQSigned(aValue);
6546
+
6547
+ do {
6548
+ digit = vlq & VLQ_BASE_MASK;
6549
+ vlq >>>= VLQ_BASE_SHIFT;
6550
+ if (vlq > 0) {
6551
+ // There are still more digits in this value, so we must make sure the
6552
+ // continuation bit is marked.
6553
+ digit |= VLQ_CONTINUATION_BIT;
6554
+ }
6555
+ encoded += base64.encode(digit);
6556
+ } while (vlq > 0);
6557
+
6558
+ return encoded;
6559
+ };
6560
+
6561
+ /**
6562
+ * Decodes the next base 64 VLQ value from the given string and returns the
6563
+ * value and the rest of the string.
6564
+ */
6565
+ exports.decode = function base64VLQ_decode(aStr) {
6566
+ var i = 0;
6567
+ var strLen = aStr.length;
6568
+ var result = 0;
6569
+ var shift = 0;
6570
+ var continuation, digit;
6571
+
6572
+ do {
6573
+ if (i >= strLen) {
6574
+ throw new Error("Expected more digits in base 64 VLQ value.");
6575
+ }
6576
+ digit = base64.decode(aStr.charAt(i++));
6577
+ continuation = !!(digit & VLQ_CONTINUATION_BIT);
6578
+ digit &= VLQ_BASE_MASK;
6579
+ result = result + (digit << shift);
6580
+ shift += VLQ_BASE_SHIFT;
6581
+ } while (continuation);
6582
+
6583
+ return {
6584
+ value: fromVLQSigned(result),
6585
+ rest: aStr.slice(i)
6586
+ };
6587
+ };
6588
+
6589
+ });
6590
+
6591
+ },{"./base64":22,"amdefine":28}],22:[function(require,module,exports){
6592
+ /* -*- Mode: js; js-indent-level: 2; -*- */
6593
+ /*
6594
+ * Copyright 2011 Mozilla Foundation and contributors
6595
+ * Licensed under the New BSD license. See LICENSE or:
6596
+ * http://opensource.org/licenses/BSD-3-Clause
6597
+ */
6598
+ if (typeof define !== 'function') {
6599
+ var define = require('amdefine')(module, require);
6600
+ }
6601
+ define(function (require, exports, module) {
6602
+
6603
+ var charToIntMap = {};
6604
+ var intToCharMap = {};
6605
+
6606
+ 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'
6607
+ .split('')
6608
+ .forEach(function (ch, index) {
6609
+ charToIntMap[ch] = index;
6610
+ intToCharMap[index] = ch;
6611
+ });
6612
+
6613
+ /**
6614
+ * Encode an integer in the range of 0 to 63 to a single base 64 digit.
6615
+ */
6616
+ exports.encode = function base64_encode(aNumber) {
6617
+ if (aNumber in intToCharMap) {
6618
+ return intToCharMap[aNumber];
6619
+ }
6620
+ throw new TypeError("Must be between 0 and 63: " + aNumber);
6621
+ };
6622
+
6623
+ /**
6624
+ * Decode a single base 64 digit to an integer.
6625
+ */
6626
+ exports.decode = function base64_decode(aChar) {
6627
+ if (aChar in charToIntMap) {
6628
+ return charToIntMap[aChar];
6629
+ }
6630
+ throw new TypeError("Not a valid base 64 digit: " + aChar);
6631
+ };
6632
+
6633
+ });
6634
+
6635
+ },{"amdefine":28}],23:[function(require,module,exports){
6636
+ /* -*- Mode: js; js-indent-level: 2; -*- */
6637
+ /*
6638
+ * Copyright 2011 Mozilla Foundation and contributors
6639
+ * Licensed under the New BSD license. See LICENSE or:
6640
+ * http://opensource.org/licenses/BSD-3-Clause
6641
+ */
6642
+ if (typeof define !== 'function') {
6643
+ var define = require('amdefine')(module, require);
6644
+ }
6645
+ define(function (require, exports, module) {
6646
+
6647
+ /**
6648
+ * Recursive implementation of binary search.
6649
+ *
6650
+ * @param aLow Indices here and lower do not contain the needle.
6651
+ * @param aHigh Indices here and higher do not contain the needle.
6652
+ * @param aNeedle The element being searched for.
6653
+ * @param aHaystack The non-empty array being searched.
6654
+ * @param aCompare Function which takes two elements and returns -1, 0, or 1.
6655
+ */
6656
+ function recursiveSearch(aLow, aHigh, aNeedle, aHaystack, aCompare) {
6657
+ // This function terminates when one of the following is true:
6658
+ //
6659
+ // 1. We find the exact element we are looking for.
6660
+ //
6661
+ // 2. We did not find the exact element, but we can return the next
6662
+ // closest element that is less than that element.
6663
+ //
6664
+ // 3. We did not find the exact element, and there is no next-closest
6665
+ // element which is less than the one we are searching for, so we
6666
+ // return null.
6667
+ var mid = Math.floor((aHigh - aLow) / 2) + aLow;
6668
+ var cmp = aCompare(aNeedle, aHaystack[mid], true);
6669
+ if (cmp === 0) {
6670
+ // Found the element we are looking for.
6671
+ return aHaystack[mid];
6672
+ }
6673
+ else if (cmp > 0) {
6674
+ // aHaystack[mid] is greater than our needle.
6675
+ if (aHigh - mid > 1) {
6676
+ // The element is in the upper half.
6677
+ return recursiveSearch(mid, aHigh, aNeedle, aHaystack, aCompare);
6678
+ }
6679
+ // We did not find an exact match, return the next closest one
6680
+ // (termination case 2).
6681
+ return aHaystack[mid];
6682
+ }
6683
+ else {
6684
+ // aHaystack[mid] is less than our needle.
6685
+ if (mid - aLow > 1) {
6686
+ // The element is in the lower half.
6687
+ return recursiveSearch(aLow, mid, aNeedle, aHaystack, aCompare);
6688
+ }
6689
+ // The exact needle element was not found in this haystack. Determine if
6690
+ // we are in termination case (2) or (3) and return the appropriate thing.
6691
+ return aLow < 0
6692
+ ? null
6693
+ : aHaystack[aLow];
6694
+ }
6695
+ }
6696
+
6697
+ /**
6698
+ * This is an implementation of binary search which will always try and return
6699
+ * the next lowest value checked if there is no exact hit. This is because
6700
+ * mappings between original and generated line/col pairs are single points,
6701
+ * and there is an implicit region between each of them, so a miss just means
6702
+ * that you aren't on the very start of a region.
6703
+ *
6704
+ * @param aNeedle The element you are looking for.
6705
+ * @param aHaystack The array that is being searched.
6706
+ * @param aCompare A function which takes the needle and an element in the
6707
+ * array and returns -1, 0, or 1 depending on whether the needle is less
6708
+ * than, equal to, or greater than the element, respectively.
6709
+ */
6710
+ exports.search = function search(aNeedle, aHaystack, aCompare) {
6711
+ return aHaystack.length > 0
6712
+ ? recursiveSearch(-1, aHaystack.length, aNeedle, aHaystack, aCompare)
6713
+ : null;
6714
+ };
6715
+
6716
+ });
6717
+
6718
+ },{"amdefine":28}],24:[function(require,module,exports){
6719
+ /* -*- Mode: js; js-indent-level: 2; -*- */
6720
+ /*
6721
+ * Copyright 2011 Mozilla Foundation and contributors
6722
+ * Licensed under the New BSD license. See LICENSE or:
6723
+ * http://opensource.org/licenses/BSD-3-Clause
6724
+ */
6725
+ if (typeof define !== 'function') {
6726
+ var define = require('amdefine')(module, require);
6727
+ }
6728
+ define(function (require, exports, module) {
6729
+
6730
+ var util = require('./util');
6731
+ var binarySearch = require('./binary-search');
6732
+ var ArraySet = require('./array-set').ArraySet;
6733
+ var base64VLQ = require('./base64-vlq');
6734
+
6735
+ /**
6736
+ * A SourceMapConsumer instance represents a parsed source map which we can
6737
+ * query for information about the original file positions by giving it a file
6738
+ * position in the generated source.
6739
+ *
6740
+ * The only parameter is the raw source map (either as a JSON string, or
6741
+ * already parsed to an object). According to the spec, source maps have the
6742
+ * following attributes:
6743
+ *
6744
+ * - version: Which version of the source map spec this map is following.
6745
+ * - sources: An array of URLs to the original source files.
6746
+ * - names: An array of identifiers which can be referrenced by individual mappings.
6747
+ * - sourceRoot: Optional. The URL root from which all sources are relative.
6748
+ * - sourcesContent: Optional. An array of contents of the original source files.
6749
+ * - mappings: A string of base64 VLQs which contain the actual mappings.
6750
+ * - file: Optional. The generated file this source map is associated with.
6751
+ *
6752
+ * Here is an example source map, taken from the source map spec[0]:
6753
+ *
6754
+ * {
6755
+ * version : 3,
6756
+ * file: "out.js",
6757
+ * sourceRoot : "",
6758
+ * sources: ["foo.js", "bar.js"],
6759
+ * names: ["src", "maps", "are", "fun"],
6760
+ * mappings: "AA,AB;;ABCDE;"
6761
+ * }
6762
+ *
6763
+ * [0]: https://docs.google.com/document/d/1U1RGAehQwRypUTovF1KRlpiOFze0b-_2gc6fAH0KY0k/edit?pli=1#
6764
+ */
6765
+ function SourceMapConsumer(aSourceMap) {
6766
+ var sourceMap = aSourceMap;
6767
+ if (typeof aSourceMap === 'string') {
6768
+ sourceMap = JSON.parse(aSourceMap.replace(/^\)\]\}'/, ''));
6769
+ }
6770
+
6771
+ var version = util.getArg(sourceMap, 'version');
6772
+ var sources = util.getArg(sourceMap, 'sources');
6773
+ // Sass 3.3 leaves out the 'names' array, so we deviate from the spec (which
6774
+ // requires the array) to play nice here.
6775
+ var names = util.getArg(sourceMap, 'names', []);
6776
+ var sourceRoot = util.getArg(sourceMap, 'sourceRoot', null);
6777
+ var sourcesContent = util.getArg(sourceMap, 'sourcesContent', null);
6778
+ var mappings = util.getArg(sourceMap, 'mappings');
6779
+ var file = util.getArg(sourceMap, 'file', null);
6780
+
6781
+ // Once again, Sass deviates from the spec and supplies the version as a
6782
+ // string rather than a number, so we use loose equality checking here.
6783
+ if (version != this._version) {
6784
+ throw new Error('Unsupported version: ' + version);
6785
+ }
6786
+
6787
+ // Pass `true` below to allow duplicate names and sources. While source maps
6788
+ // are intended to be compressed and deduplicated, the TypeScript compiler
6789
+ // sometimes generates source maps with duplicates in them. See Github issue
6790
+ // #72 and bugzil.la/889492.
6791
+ this._names = ArraySet.fromArray(names, true);
6792
+ this._sources = ArraySet.fromArray(sources, true);
6793
+
6794
+ this.sourceRoot = sourceRoot;
6795
+ this.sourcesContent = sourcesContent;
6796
+ this._mappings = mappings;
6797
+ this.file = file;
6798
+ }
6799
+
6800
+ /**
6801
+ * Create a SourceMapConsumer from a SourceMapGenerator.
6802
+ *
6803
+ * @param SourceMapGenerator aSourceMap
6804
+ * The source map that will be consumed.
6805
+ * @returns SourceMapConsumer
6806
+ */
6807
+ SourceMapConsumer.fromSourceMap =
6808
+ function SourceMapConsumer_fromSourceMap(aSourceMap) {
6809
+ var smc = Object.create(SourceMapConsumer.prototype);
6810
+
6811
+ smc._names = ArraySet.fromArray(aSourceMap._names.toArray(), true);
6812
+ smc._sources = ArraySet.fromArray(aSourceMap._sources.toArray(), true);
6813
+ smc.sourceRoot = aSourceMap._sourceRoot;
6814
+ smc.sourcesContent = aSourceMap._generateSourcesContent(smc._sources.toArray(),
6815
+ smc.sourceRoot);
6816
+ smc.file = aSourceMap._file;
6817
+
6818
+ smc.__generatedMappings = aSourceMap._mappings.slice()
6819
+ .sort(util.compareByGeneratedPositions);
6820
+ smc.__originalMappings = aSourceMap._mappings.slice()
6821
+ .sort(util.compareByOriginalPositions);
6822
+
6823
+ return smc;
6824
+ };
6825
+
6826
+ /**
6827
+ * The version of the source mapping spec that we are consuming.
6828
+ */
6829
+ SourceMapConsumer.prototype._version = 3;
6830
+
6831
+ /**
6832
+ * The list of original sources.
6833
+ */
6834
+ Object.defineProperty(SourceMapConsumer.prototype, 'sources', {
6835
+ get: function () {
6836
+ return this._sources.toArray().map(function (s) {
6837
+ return this.sourceRoot != null ? util.join(this.sourceRoot, s) : s;
6838
+ }, this);
6839
+ }
6840
+ });
6841
+
6842
+ // `__generatedMappings` and `__originalMappings` are arrays that hold the
6843
+ // parsed mapping coordinates from the source map's "mappings" attribute. They
6844
+ // are lazily instantiated, accessed via the `_generatedMappings` and
6845
+ // `_originalMappings` getters respectively, and we only parse the mappings
6846
+ // and create these arrays once queried for a source location. We jump through
6847
+ // these hoops because there can be many thousands of mappings, and parsing
6848
+ // them is expensive, so we only want to do it if we must.
6849
+ //
6850
+ // Each object in the arrays is of the form:
6851
+ //
6852
+ // {
6853
+ // generatedLine: The line number in the generated code,
6854
+ // generatedColumn: The column number in the generated code,
6855
+ // source: The path to the original source file that generated this
6856
+ // chunk of code,
6857
+ // originalLine: The line number in the original source that
6858
+ // corresponds to this chunk of generated code,
6859
+ // originalColumn: The column number in the original source that
6860
+ // corresponds to this chunk of generated code,
6861
+ // name: The name of the original symbol which generated this chunk of
6862
+ // code.
6863
+ // }
6864
+ //
6865
+ // All properties except for `generatedLine` and `generatedColumn` can be
6866
+ // `null`.
6867
+ //
6868
+ // `_generatedMappings` is ordered by the generated positions.
6869
+ //
6870
+ // `_originalMappings` is ordered by the original positions.
6871
+
6872
+ SourceMapConsumer.prototype.__generatedMappings = null;
6873
+ Object.defineProperty(SourceMapConsumer.prototype, '_generatedMappings', {
6874
+ get: function () {
6875
+ if (!this.__generatedMappings) {
6876
+ this.__generatedMappings = [];
6877
+ this.__originalMappings = [];
6878
+ this._parseMappings(this._mappings, this.sourceRoot);
6879
+ }
6880
+
6881
+ return this.__generatedMappings;
6882
+ }
6883
+ });
6884
+
6885
+ SourceMapConsumer.prototype.__originalMappings = null;
6886
+ Object.defineProperty(SourceMapConsumer.prototype, '_originalMappings', {
6887
+ get: function () {
6888
+ if (!this.__originalMappings) {
6889
+ this.__generatedMappings = [];
6890
+ this.__originalMappings = [];
6891
+ this._parseMappings(this._mappings, this.sourceRoot);
6892
+ }
6893
+
6894
+ return this.__originalMappings;
6895
+ }
6896
+ });
6897
+
6898
+ /**
6899
+ * Parse the mappings in a string in to a data structure which we can easily
6900
+ * query (the ordered arrays in the `this.__generatedMappings` and
6901
+ * `this.__originalMappings` properties).
6902
+ */
6903
+ SourceMapConsumer.prototype._parseMappings =
6904
+ function SourceMapConsumer_parseMappings(aStr, aSourceRoot) {
6905
+ var generatedLine = 1;
6906
+ var previousGeneratedColumn = 0;
6907
+ var previousOriginalLine = 0;
6908
+ var previousOriginalColumn = 0;
6909
+ var previousSource = 0;
6910
+ var previousName = 0;
6911
+ var mappingSeparator = /^[,;]/;
6912
+ var str = aStr;
6913
+ var mapping;
6914
+ var temp;
6915
+
6916
+ while (str.length > 0) {
6917
+ if (str.charAt(0) === ';') {
6918
+ generatedLine++;
6919
+ str = str.slice(1);
6920
+ previousGeneratedColumn = 0;
6921
+ }
6922
+ else if (str.charAt(0) === ',') {
6923
+ str = str.slice(1);
6924
+ }
6925
+ else {
6926
+ mapping = {};
6927
+ mapping.generatedLine = generatedLine;
6928
+
6929
+ // Generated column.
6930
+ temp = base64VLQ.decode(str);
6931
+ mapping.generatedColumn = previousGeneratedColumn + temp.value;
6932
+ previousGeneratedColumn = mapping.generatedColumn;
6933
+ str = temp.rest;
6934
+
6935
+ if (str.length > 0 && !mappingSeparator.test(str.charAt(0))) {
6936
+ // Original source.
6937
+ temp = base64VLQ.decode(str);
6938
+ mapping.source = this._sources.at(previousSource + temp.value);
6939
+ previousSource += temp.value;
6940
+ str = temp.rest;
6941
+ if (str.length === 0 || mappingSeparator.test(str.charAt(0))) {
6942
+ throw new Error('Found a source, but no line and column');
6943
+ }
6944
+
6945
+ // Original line.
6946
+ temp = base64VLQ.decode(str);
6947
+ mapping.originalLine = previousOriginalLine + temp.value;
6948
+ previousOriginalLine = mapping.originalLine;
6949
+ // Lines are stored 0-based
6950
+ mapping.originalLine += 1;
6951
+ str = temp.rest;
6952
+ if (str.length === 0 || mappingSeparator.test(str.charAt(0))) {
6953
+ throw new Error('Found a source and line, but no column');
6954
+ }
6955
+
6956
+ // Original column.
6957
+ temp = base64VLQ.decode(str);
6958
+ mapping.originalColumn = previousOriginalColumn + temp.value;
6959
+ previousOriginalColumn = mapping.originalColumn;
6960
+ str = temp.rest;
6961
+
6962
+ if (str.length > 0 && !mappingSeparator.test(str.charAt(0))) {
6963
+ // Original name.
6964
+ temp = base64VLQ.decode(str);
6965
+ mapping.name = this._names.at(previousName + temp.value);
6966
+ previousName += temp.value;
6967
+ str = temp.rest;
6968
+ }
6969
+ }
6970
+
6971
+ this.__generatedMappings.push(mapping);
6972
+ if (typeof mapping.originalLine === 'number') {
6973
+ this.__originalMappings.push(mapping);
6974
+ }
6975
+ }
6976
+ }
6977
+
6978
+ this.__generatedMappings.sort(util.compareByGeneratedPositions);
6979
+ this.__originalMappings.sort(util.compareByOriginalPositions);
6980
+ };
6981
+
6982
+ /**
6983
+ * Find the mapping that best matches the hypothetical "needle" mapping that
6984
+ * we are searching for in the given "haystack" of mappings.
6985
+ */
6986
+ SourceMapConsumer.prototype._findMapping =
6987
+ function SourceMapConsumer_findMapping(aNeedle, aMappings, aLineName,
6988
+ aColumnName, aComparator) {
6989
+ // To return the position we are searching for, we must first find the
6990
+ // mapping for the given position and then return the opposite position it
6991
+ // points to. Because the mappings are sorted, we can use binary search to
6992
+ // find the best mapping.
6993
+
6994
+ if (aNeedle[aLineName] <= 0) {
6995
+ throw new TypeError('Line must be greater than or equal to 1, got '
6996
+ + aNeedle[aLineName]);
6997
+ }
6998
+ if (aNeedle[aColumnName] < 0) {
6999
+ throw new TypeError('Column must be greater than or equal to 0, got '
7000
+ + aNeedle[aColumnName]);
7001
+ }
7002
+
7003
+ return binarySearch.search(aNeedle, aMappings, aComparator);
7004
+ };
7005
+
7006
+ /**
7007
+ * Returns the original source, line, and column information for the generated
7008
+ * source's line and column positions provided. The only argument is an object
7009
+ * with the following properties:
7010
+ *
7011
+ * - line: The line number in the generated source.
7012
+ * - column: The column number in the generated source.
7013
+ *
7014
+ * and an object is returned with the following properties:
7015
+ *
7016
+ * - source: The original source file, or null.
7017
+ * - line: The line number in the original source, or null.
7018
+ * - column: The column number in the original source, or null.
7019
+ * - name: The original identifier, or null.
7020
+ */
7021
+ SourceMapConsumer.prototype.originalPositionFor =
7022
+ function SourceMapConsumer_originalPositionFor(aArgs) {
7023
+ var needle = {
7024
+ generatedLine: util.getArg(aArgs, 'line'),
7025
+ generatedColumn: util.getArg(aArgs, 'column')
7026
+ };
7027
+
7028
+ var mapping = this._findMapping(needle,
7029
+ this._generatedMappings,
7030
+ "generatedLine",
7031
+ "generatedColumn",
7032
+ util.compareByGeneratedPositions);
7033
+
7034
+ if (mapping && mapping.generatedLine === needle.generatedLine) {
7035
+ var source = util.getArg(mapping, 'source', null);
7036
+ if (source != null && this.sourceRoot != null) {
7037
+ source = util.join(this.sourceRoot, source);
7038
+ }
7039
+ return {
7040
+ source: source,
7041
+ line: util.getArg(mapping, 'originalLine', null),
7042
+ column: util.getArg(mapping, 'originalColumn', null),
7043
+ name: util.getArg(mapping, 'name', null)
7044
+ };
7045
+ }
7046
+
7047
+ return {
7048
+ source: null,
7049
+ line: null,
7050
+ column: null,
7051
+ name: null
7052
+ };
7053
+ };
7054
+
7055
+ /**
7056
+ * Returns the original source content. The only argument is the url of the
7057
+ * original source file. Returns null if no original source content is
7058
+ * availible.
7059
+ */
7060
+ SourceMapConsumer.prototype.sourceContentFor =
7061
+ function SourceMapConsumer_sourceContentFor(aSource) {
7062
+ if (!this.sourcesContent) {
7063
+ return null;
7064
+ }
7065
+
7066
+ if (this.sourceRoot != null) {
7067
+ aSource = util.relative(this.sourceRoot, aSource);
7068
+ }
7069
+
7070
+ if (this._sources.has(aSource)) {
7071
+ return this.sourcesContent[this._sources.indexOf(aSource)];
7072
+ }
7073
+
7074
+ var url;
7075
+ if (this.sourceRoot != null
7076
+ && (url = util.urlParse(this.sourceRoot))) {
7077
+ // XXX: file:// URIs and absolute paths lead to unexpected behavior for
7078
+ // many users. We can help them out when they expect file:// URIs to
7079
+ // behave like it would if they were running a local HTTP server. See
7080
+ // https://bugzilla.mozilla.org/show_bug.cgi?id=885597.
7081
+ var fileUriAbsPath = aSource.replace(/^file:\/\//, "");
7082
+ if (url.scheme == "file"
7083
+ && this._sources.has(fileUriAbsPath)) {
7084
+ return this.sourcesContent[this._sources.indexOf(fileUriAbsPath)]
7085
+ }
7086
+
7087
+ if ((!url.path || url.path == "/")
7088
+ && this._sources.has("/" + aSource)) {
7089
+ return this.sourcesContent[this._sources.indexOf("/" + aSource)];
7090
+ }
7091
+ }
7092
+
7093
+ throw new Error('"' + aSource + '" is not in the SourceMap.');
7094
+ };
7095
+
7096
+ /**
7097
+ * Returns the generated line and column information for the original source,
7098
+ * line, and column positions provided. The only argument is an object with
7099
+ * the following properties:
7100
+ *
7101
+ * - source: The filename of the original source.
7102
+ * - line: The line number in the original source.
7103
+ * - column: The column number in the original source.
7104
+ *
7105
+ * and an object is returned with the following properties:
7106
+ *
7107
+ * - line: The line number in the generated source, or null.
7108
+ * - column: The column number in the generated source, or null.
7109
+ */
7110
+ SourceMapConsumer.prototype.generatedPositionFor =
7111
+ function SourceMapConsumer_generatedPositionFor(aArgs) {
7112
+ var needle = {
7113
+ source: util.getArg(aArgs, 'source'),
7114
+ originalLine: util.getArg(aArgs, 'line'),
7115
+ originalColumn: util.getArg(aArgs, 'column')
7116
+ };
7117
+
7118
+ if (this.sourceRoot != null) {
7119
+ needle.source = util.relative(this.sourceRoot, needle.source);
7120
+ }
7121
+
7122
+ var mapping = this._findMapping(needle,
7123
+ this._originalMappings,
7124
+ "originalLine",
7125
+ "originalColumn",
7126
+ util.compareByOriginalPositions);
7127
+
7128
+ if (mapping) {
7129
+ return {
7130
+ line: util.getArg(mapping, 'generatedLine', null),
7131
+ column: util.getArg(mapping, 'generatedColumn', null)
7132
+ };
7133
+ }
7134
+
7135
+ return {
7136
+ line: null,
7137
+ column: null
7138
+ };
7139
+ };
7140
+
7141
+ SourceMapConsumer.GENERATED_ORDER = 1;
7142
+ SourceMapConsumer.ORIGINAL_ORDER = 2;
7143
+
7144
+ /**
7145
+ * Iterate over each mapping between an original source/line/column and a
7146
+ * generated line/column in this source map.
7147
+ *
7148
+ * @param Function aCallback
7149
+ * The function that is called with each mapping.
7150
+ * @param Object aContext
7151
+ * Optional. If specified, this object will be the value of `this` every
7152
+ * time that `aCallback` is called.
7153
+ * @param aOrder
7154
+ * Either `SourceMapConsumer.GENERATED_ORDER` or
7155
+ * `SourceMapConsumer.ORIGINAL_ORDER`. Specifies whether you want to
7156
+ * iterate over the mappings sorted by the generated file's line/column
7157
+ * order or the original's source/line/column order, respectively. Defaults to
7158
+ * `SourceMapConsumer.GENERATED_ORDER`.
7159
+ */
7160
+ SourceMapConsumer.prototype.eachMapping =
7161
+ function SourceMapConsumer_eachMapping(aCallback, aContext, aOrder) {
7162
+ var context = aContext || null;
7163
+ var order = aOrder || SourceMapConsumer.GENERATED_ORDER;
7164
+
7165
+ var mappings;
7166
+ switch (order) {
7167
+ case SourceMapConsumer.GENERATED_ORDER:
7168
+ mappings = this._generatedMappings;
7169
+ break;
7170
+ case SourceMapConsumer.ORIGINAL_ORDER:
7171
+ mappings = this._originalMappings;
7172
+ break;
7173
+ default:
7174
+ throw new Error("Unknown order of iteration.");
7175
+ }
7176
+
7177
+ var sourceRoot = this.sourceRoot;
7178
+ mappings.map(function (mapping) {
7179
+ var source = mapping.source;
7180
+ if (source != null && sourceRoot != null) {
7181
+ source = util.join(sourceRoot, source);
7182
+ }
7183
+ return {
7184
+ source: source,
7185
+ generatedLine: mapping.generatedLine,
7186
+ generatedColumn: mapping.generatedColumn,
7187
+ originalLine: mapping.originalLine,
7188
+ originalColumn: mapping.originalColumn,
7189
+ name: mapping.name
7190
+ };
7191
+ }).forEach(aCallback, context);
7192
+ };
7193
+
7194
+ exports.SourceMapConsumer = SourceMapConsumer;
7195
+
7196
+ });
7197
+
7198
+ },{"./array-set":20,"./base64-vlq":21,"./binary-search":23,"./util":27,"amdefine":28}],25:[function(require,module,exports){
7199
+ /* -*- Mode: js; js-indent-level: 2; -*- */
7200
+ /*
7201
+ * Copyright 2011 Mozilla Foundation and contributors
7202
+ * Licensed under the New BSD license. See LICENSE or:
7203
+ * http://opensource.org/licenses/BSD-3-Clause
7204
+ */
7205
+ if (typeof define !== 'function') {
7206
+ var define = require('amdefine')(module, require);
7207
+ }
7208
+ define(function (require, exports, module) {
7209
+
7210
+ var base64VLQ = require('./base64-vlq');
7211
+ var util = require('./util');
7212
+ var ArraySet = require('./array-set').ArraySet;
7213
+
7214
+ /**
7215
+ * An instance of the SourceMapGenerator represents a source map which is
7216
+ * being built incrementally. You may pass an object with the following
7217
+ * properties:
7218
+ *
7219
+ * - file: The filename of the generated source.
7220
+ * - sourceRoot: A root for all relative URLs in this source map.
7221
+ */
7222
+ function SourceMapGenerator(aArgs) {
7223
+ if (!aArgs) {
7224
+ aArgs = {};
7225
+ }
7226
+ this._file = util.getArg(aArgs, 'file', null);
7227
+ this._sourceRoot = util.getArg(aArgs, 'sourceRoot', null);
7228
+ this._sources = new ArraySet();
7229
+ this._names = new ArraySet();
7230
+ this._mappings = [];
7231
+ this._sourcesContents = null;
7232
+ }
7233
+
7234
+ SourceMapGenerator.prototype._version = 3;
7235
+
7236
+ /**
7237
+ * Creates a new SourceMapGenerator based on a SourceMapConsumer
7238
+ *
7239
+ * @param aSourceMapConsumer The SourceMap.
7240
+ */
7241
+ SourceMapGenerator.fromSourceMap =
7242
+ function SourceMapGenerator_fromSourceMap(aSourceMapConsumer) {
7243
+ var sourceRoot = aSourceMapConsumer.sourceRoot;
7244
+ var generator = new SourceMapGenerator({
7245
+ file: aSourceMapConsumer.file,
7246
+ sourceRoot: sourceRoot
7247
+ });
7248
+ aSourceMapConsumer.eachMapping(function (mapping) {
7249
+ var newMapping = {
7250
+ generated: {
7251
+ line: mapping.generatedLine,
7252
+ column: mapping.generatedColumn
7253
+ }
7254
+ };
7255
+
7256
+ if (mapping.source != null) {
7257
+ newMapping.source = mapping.source;
7258
+ if (sourceRoot != null) {
7259
+ newMapping.source = util.relative(sourceRoot, newMapping.source);
7260
+ }
7261
+
7262
+ newMapping.original = {
7263
+ line: mapping.originalLine,
7264
+ column: mapping.originalColumn
7265
+ };
7266
+
7267
+ if (mapping.name != null) {
7268
+ newMapping.name = mapping.name;
7269
+ }
7270
+ }
7271
+
7272
+ generator.addMapping(newMapping);
7273
+ });
7274
+ aSourceMapConsumer.sources.forEach(function (sourceFile) {
7275
+ var content = aSourceMapConsumer.sourceContentFor(sourceFile);
7276
+ if (content != null) {
7277
+ generator.setSourceContent(sourceFile, content);
7278
+ }
7279
+ });
7280
+ return generator;
7281
+ };
7282
+
7283
+ /**
7284
+ * Add a single mapping from original source line and column to the generated
7285
+ * source's line and column for this source map being created. The mapping
7286
+ * object should have the following properties:
7287
+ *
7288
+ * - generated: An object with the generated line and column positions.
7289
+ * - original: An object with the original line and column positions.
7290
+ * - source: The original source file (relative to the sourceRoot).
7291
+ * - name: An optional original token name for this mapping.
7292
+ */
7293
+ SourceMapGenerator.prototype.addMapping =
7294
+ function SourceMapGenerator_addMapping(aArgs) {
7295
+ var generated = util.getArg(aArgs, 'generated');
7296
+ var original = util.getArg(aArgs, 'original', null);
7297
+ var source = util.getArg(aArgs, 'source', null);
7298
+ var name = util.getArg(aArgs, 'name', null);
7299
+
7300
+ this._validateMapping(generated, original, source, name);
7301
+
7302
+ if (source != null && !this._sources.has(source)) {
7303
+ this._sources.add(source);
7304
+ }
7305
+
7306
+ if (name != null && !this._names.has(name)) {
7307
+ this._names.add(name);
7308
+ }
7309
+
7310
+ this._mappings.push({
7311
+ generatedLine: generated.line,
7312
+ generatedColumn: generated.column,
7313
+ originalLine: original != null && original.line,
7314
+ originalColumn: original != null && original.column,
7315
+ source: source,
7316
+ name: name
7317
+ });
7318
+ };
7319
+
7320
+ /**
7321
+ * Set the source content for a source file.
7322
+ */
7323
+ SourceMapGenerator.prototype.setSourceContent =
7324
+ function SourceMapGenerator_setSourceContent(aSourceFile, aSourceContent) {
7325
+ var source = aSourceFile;
7326
+ if (this._sourceRoot != null) {
7327
+ source = util.relative(this._sourceRoot, source);
7328
+ }
7329
+
7330
+ if (aSourceContent != null) {
7331
+ // Add the source content to the _sourcesContents map.
7332
+ // Create a new _sourcesContents map if the property is null.
7333
+ if (!this._sourcesContents) {
7334
+ this._sourcesContents = {};
7335
+ }
7336
+ this._sourcesContents[util.toSetString(source)] = aSourceContent;
7337
+ } else {
7338
+ // Remove the source file from the _sourcesContents map.
7339
+ // If the _sourcesContents map is empty, set the property to null.
7340
+ delete this._sourcesContents[util.toSetString(source)];
7341
+ if (Object.keys(this._sourcesContents).length === 0) {
7342
+ this._sourcesContents = null;
7343
+ }
7344
+ }
7345
+ };
7346
+
7347
+ /**
7348
+ * Applies the mappings of a sub-source-map for a specific source file to the
7349
+ * source map being generated. Each mapping to the supplied source file is
7350
+ * rewritten using the supplied source map. Note: The resolution for the
7351
+ * resulting mappings is the minimium of this map and the supplied map.
7352
+ *
7353
+ * @param aSourceMapConsumer The source map to be applied.
7354
+ * @param aSourceFile Optional. The filename of the source file.
7355
+ * If omitted, SourceMapConsumer's file property will be used.
7356
+ * @param aSourceMapPath Optional. The dirname of the path to the source map
7357
+ * to be applied. If relative, it is relative to the SourceMapConsumer.
7358
+ * This parameter is needed when the two source maps aren't in the same
7359
+ * directory, and the source map to be applied contains relative source
7360
+ * paths. If so, those relative source paths need to be rewritten
7361
+ * relative to the SourceMapGenerator.
7362
+ */
7363
+ SourceMapGenerator.prototype.applySourceMap =
7364
+ function SourceMapGenerator_applySourceMap(aSourceMapConsumer, aSourceFile, aSourceMapPath) {
7365
+ var sourceFile = aSourceFile;
7366
+ // If aSourceFile is omitted, we will use the file property of the SourceMap
7367
+ if (aSourceFile == null) {
7368
+ if (aSourceMapConsumer.file == null) {
7369
+ throw new Error(
7370
+ 'SourceMapGenerator.prototype.applySourceMap requires either an explicit source file, ' +
7371
+ 'or the source map\'s "file" property. Both were omitted.'
7372
+ );
7373
+ }
7374
+ sourceFile = aSourceMapConsumer.file;
7375
+ }
7376
+ var sourceRoot = this._sourceRoot;
7377
+ // Make "sourceFile" relative if an absolute Url is passed.
7378
+ if (sourceRoot != null) {
7379
+ sourceFile = util.relative(sourceRoot, sourceFile);
7380
+ }
7381
+ // Applying the SourceMap can add and remove items from the sources and
7382
+ // the names array.
7383
+ var newSources = new ArraySet();
7384
+ var newNames = new ArraySet();
7385
+
7386
+ // Find mappings for the "sourceFile"
7387
+ this._mappings.forEach(function (mapping) {
7388
+ if (mapping.source === sourceFile && mapping.originalLine != null) {
7389
+ // Check if it can be mapped by the source map, then update the mapping.
7390
+ var original = aSourceMapConsumer.originalPositionFor({
7391
+ line: mapping.originalLine,
7392
+ column: mapping.originalColumn
7393
+ });
7394
+ if (original.source != null) {
7395
+ // Copy mapping
7396
+ mapping.source = original.source;
7397
+ if (aSourceMapPath != null) {
7398
+ mapping.source = util.join(aSourceMapPath, mapping.source)
7399
+ }
7400
+ if (sourceRoot != null) {
7401
+ mapping.source = util.relative(sourceRoot, mapping.source);
7402
+ }
7403
+ mapping.originalLine = original.line;
7404
+ mapping.originalColumn = original.column;
7405
+ if (original.name != null && mapping.name != null) {
7406
+ // Only use the identifier name if it's an identifier
7407
+ // in both SourceMaps
7408
+ mapping.name = original.name;
7409
+ }
7410
+ }
7411
+ }
7412
+
7413
+ var source = mapping.source;
7414
+ if (source != null && !newSources.has(source)) {
7415
+ newSources.add(source);
7416
+ }
7417
+
7418
+ var name = mapping.name;
7419
+ if (name != null && !newNames.has(name)) {
7420
+ newNames.add(name);
7421
+ }
7422
+
7423
+ }, this);
7424
+ this._sources = newSources;
7425
+ this._names = newNames;
7426
+
7427
+ // Copy sourcesContents of applied map.
7428
+ aSourceMapConsumer.sources.forEach(function (sourceFile) {
7429
+ var content = aSourceMapConsumer.sourceContentFor(sourceFile);
7430
+ if (content != null) {
7431
+ if (aSourceMapPath != null) {
7432
+ sourceFile = util.join(aSourceMapPath, sourceFile);
7433
+ }
7434
+ if (sourceRoot != null) {
7435
+ sourceFile = util.relative(sourceRoot, sourceFile);
7436
+ }
7437
+ this.setSourceContent(sourceFile, content);
7438
+ }
7439
+ }, this);
7440
+ };
7441
+
7442
+ /**
7443
+ * A mapping can have one of the three levels of data:
7444
+ *
7445
+ * 1. Just the generated position.
7446
+ * 2. The Generated position, original position, and original source.
7447
+ * 3. Generated and original position, original source, as well as a name
7448
+ * token.
7449
+ *
7450
+ * To maintain consistency, we validate that any new mapping being added falls
7451
+ * in to one of these categories.
7452
+ */
7453
+ SourceMapGenerator.prototype._validateMapping =
7454
+ function SourceMapGenerator_validateMapping(aGenerated, aOriginal, aSource,
7455
+ aName) {
7456
+ if (aGenerated && 'line' in aGenerated && 'column' in aGenerated
7457
+ && aGenerated.line > 0 && aGenerated.column >= 0
7458
+ && !aOriginal && !aSource && !aName) {
7459
+ // Case 1.
7460
+ return;
7461
+ }
7462
+ else if (aGenerated && 'line' in aGenerated && 'column' in aGenerated
7463
+ && aOriginal && 'line' in aOriginal && 'column' in aOriginal
7464
+ && aGenerated.line > 0 && aGenerated.column >= 0
7465
+ && aOriginal.line > 0 && aOriginal.column >= 0
7466
+ && aSource) {
7467
+ // Cases 2 and 3.
7468
+ return;
7469
+ }
7470
+ else {
7471
+ throw new Error('Invalid mapping: ' + JSON.stringify({
7472
+ generated: aGenerated,
7473
+ source: aSource,
7474
+ original: aOriginal,
7475
+ name: aName
7476
+ }));
7477
+ }
7478
+ };
7479
+
7480
+ /**
7481
+ * Serialize the accumulated mappings in to the stream of base 64 VLQs
7482
+ * specified by the source map format.
7483
+ */
7484
+ SourceMapGenerator.prototype._serializeMappings =
7485
+ function SourceMapGenerator_serializeMappings() {
7486
+ var previousGeneratedColumn = 0;
7487
+ var previousGeneratedLine = 1;
7488
+ var previousOriginalColumn = 0;
7489
+ var previousOriginalLine = 0;
7490
+ var previousName = 0;
7491
+ var previousSource = 0;
7492
+ var result = '';
7493
+ var mapping;
7494
+
7495
+ // The mappings must be guaranteed to be in sorted order before we start
7496
+ // serializing them or else the generated line numbers (which are defined
7497
+ // via the ';' separators) will be all messed up. Note: it might be more
7498
+ // performant to maintain the sorting as we insert them, rather than as we
7499
+ // serialize them, but the big O is the same either way.
7500
+ this._mappings.sort(util.compareByGeneratedPositions);
7501
+
7502
+ for (var i = 0, len = this._mappings.length; i < len; i++) {
7503
+ mapping = this._mappings[i];
7504
+
7505
+ if (mapping.generatedLine !== previousGeneratedLine) {
7506
+ previousGeneratedColumn = 0;
7507
+ while (mapping.generatedLine !== previousGeneratedLine) {
7508
+ result += ';';
7509
+ previousGeneratedLine++;
7510
+ }
7511
+ }
7512
+ else {
7513
+ if (i > 0) {
7514
+ if (!util.compareByGeneratedPositions(mapping, this._mappings[i - 1])) {
7515
+ continue;
7516
+ }
7517
+ result += ',';
7518
+ }
7519
+ }
7520
+
7521
+ result += base64VLQ.encode(mapping.generatedColumn
7522
+ - previousGeneratedColumn);
7523
+ previousGeneratedColumn = mapping.generatedColumn;
7524
+
7525
+ if (mapping.source != null) {
7526
+ result += base64VLQ.encode(this._sources.indexOf(mapping.source)
7527
+ - previousSource);
7528
+ previousSource = this._sources.indexOf(mapping.source);
7529
+
7530
+ // lines are stored 0-based in SourceMap spec version 3
7531
+ result += base64VLQ.encode(mapping.originalLine - 1
7532
+ - previousOriginalLine);
7533
+ previousOriginalLine = mapping.originalLine - 1;
7534
+
7535
+ result += base64VLQ.encode(mapping.originalColumn
7536
+ - previousOriginalColumn);
7537
+ previousOriginalColumn = mapping.originalColumn;
7538
+
7539
+ if (mapping.name != null) {
7540
+ result += base64VLQ.encode(this._names.indexOf(mapping.name)
7541
+ - previousName);
7542
+ previousName = this._names.indexOf(mapping.name);
7543
+ }
7544
+ }
7545
+ }
7546
+
7547
+ return result;
7548
+ };
7549
+
7550
+ SourceMapGenerator.prototype._generateSourcesContent =
7551
+ function SourceMapGenerator_generateSourcesContent(aSources, aSourceRoot) {
7552
+ return aSources.map(function (source) {
7553
+ if (!this._sourcesContents) {
7554
+ return null;
7555
+ }
7556
+ if (aSourceRoot != null) {
7557
+ source = util.relative(aSourceRoot, source);
7558
+ }
7559
+ var key = util.toSetString(source);
7560
+ return Object.prototype.hasOwnProperty.call(this._sourcesContents,
7561
+ key)
7562
+ ? this._sourcesContents[key]
7563
+ : null;
7564
+ }, this);
7565
+ };
7566
+
7567
+ /**
7568
+ * Externalize the source map.
7569
+ */
7570
+ SourceMapGenerator.prototype.toJSON =
7571
+ function SourceMapGenerator_toJSON() {
7572
+ var map = {
7573
+ version: this._version,
7574
+ sources: this._sources.toArray(),
7575
+ names: this._names.toArray(),
7576
+ mappings: this._serializeMappings()
7577
+ };
7578
+ if (this._file != null) {
7579
+ map.file = this._file;
7580
+ }
7581
+ if (this._sourceRoot != null) {
7582
+ map.sourceRoot = this._sourceRoot;
7583
+ }
7584
+ if (this._sourcesContents) {
7585
+ map.sourcesContent = this._generateSourcesContent(map.sources, map.sourceRoot);
7586
+ }
7587
+
7588
+ return map;
7589
+ };
7590
+
7591
+ /**
7592
+ * Render the source map being generated to a string.
7593
+ */
7594
+ SourceMapGenerator.prototype.toString =
7595
+ function SourceMapGenerator_toString() {
7596
+ return JSON.stringify(this);
7597
+ };
7598
+
7599
+ exports.SourceMapGenerator = SourceMapGenerator;
7600
+
7601
+ });
7602
+
7603
+ },{"./array-set":20,"./base64-vlq":21,"./util":27,"amdefine":28}],26:[function(require,module,exports){
7604
+ /* -*- Mode: js; js-indent-level: 2; -*- */
7605
+ /*
7606
+ * Copyright 2011 Mozilla Foundation and contributors
7607
+ * Licensed under the New BSD license. See LICENSE or:
7608
+ * http://opensource.org/licenses/BSD-3-Clause
7609
+ */
7610
+ if (typeof define !== 'function') {
7611
+ var define = require('amdefine')(module, require);
7612
+ }
7613
+ define(function (require, exports, module) {
7614
+
7615
+ var SourceMapGenerator = require('./source-map-generator').SourceMapGenerator;
7616
+ var util = require('./util');
7617
+
7618
+ // Matches a Windows-style `\r\n` newline or a `\n` newline used by all other
7619
+ // operating systems these days (capturing the result).
7620
+ var REGEX_NEWLINE = /(\r?\n)/;
7621
+
7622
+ // Matches a Windows-style newline, or any character.
7623
+ var REGEX_CHARACTER = /\r\n|[\s\S]/g;
7624
+
7625
+ /**
7626
+ * SourceNodes provide a way to abstract over interpolating/concatenating
7627
+ * snippets of generated JavaScript source code while maintaining the line and
7628
+ * column information associated with the original source code.
7629
+ *
7630
+ * @param aLine The original line number.
7631
+ * @param aColumn The original column number.
7632
+ * @param aSource The original source's filename.
7633
+ * @param aChunks Optional. An array of strings which are snippets of
7634
+ * generated JS, or other SourceNodes.
7635
+ * @param aName The original identifier.
7636
+ */
7637
+ function SourceNode(aLine, aColumn, aSource, aChunks, aName) {
7638
+ this.children = [];
7639
+ this.sourceContents = {};
7640
+ this.line = aLine == null ? null : aLine;
7641
+ this.column = aColumn == null ? null : aColumn;
7642
+ this.source = aSource == null ? null : aSource;
7643
+ this.name = aName == null ? null : aName;
7644
+ if (aChunks != null) this.add(aChunks);
7645
+ }
7646
+
7647
+ /**
7648
+ * Creates a SourceNode from generated code and a SourceMapConsumer.
7649
+ *
7650
+ * @param aGeneratedCode The generated code
7651
+ * @param aSourceMapConsumer The SourceMap for the generated code
7652
+ * @param aRelativePath Optional. The path that relative sources in the
7653
+ * SourceMapConsumer should be relative to.
7654
+ */
7655
+ SourceNode.fromStringWithSourceMap =
7656
+ function SourceNode_fromStringWithSourceMap(aGeneratedCode, aSourceMapConsumer, aRelativePath) {
7657
+ // The SourceNode we want to fill with the generated code
7658
+ // and the SourceMap
7659
+ var node = new SourceNode();
7660
+
7661
+ // All even indices of this array are one line of the generated code,
7662
+ // while all odd indices are the newlines between two adjacent lines
7663
+ // (since `REGEX_NEWLINE` captures its match).
7664
+ // Processed fragments are removed from this array, by calling `shiftNextLine`.
7665
+ var remainingLines = aGeneratedCode.split(REGEX_NEWLINE);
7666
+ var shiftNextLine = function() {
7667
+ var lineContents = remainingLines.shift();
7668
+ // The last line of a file might not have a newline.
7669
+ var newLine = remainingLines.shift() || "";
7670
+ return lineContents + newLine;
7671
+ };
7672
+
7673
+ // We need to remember the position of "remainingLines"
7674
+ var lastGeneratedLine = 1, lastGeneratedColumn = 0;
7675
+
7676
+ // The generate SourceNodes we need a code range.
7677
+ // To extract it current and last mapping is used.
7678
+ // Here we store the last mapping.
7679
+ var lastMapping = null;
7680
+
7681
+ aSourceMapConsumer.eachMapping(function (mapping) {
7682
+ if (lastMapping !== null) {
7683
+ // We add the code from "lastMapping" to "mapping":
7684
+ // First check if there is a new line in between.
7685
+ if (lastGeneratedLine < mapping.generatedLine) {
7686
+ var code = "";
7687
+ // Associate first line with "lastMapping"
7688
+ addMappingWithCode(lastMapping, shiftNextLine());
7689
+ lastGeneratedLine++;
7690
+ lastGeneratedColumn = 0;
7691
+ // The remaining code is added without mapping
7692
+ } else {
7693
+ // There is no new line in between.
7694
+ // Associate the code between "lastGeneratedColumn" and
7695
+ // "mapping.generatedColumn" with "lastMapping"
7696
+ var nextLine = remainingLines[0];
7697
+ var code = nextLine.substr(0, mapping.generatedColumn -
7698
+ lastGeneratedColumn);
7699
+ remainingLines[0] = nextLine.substr(mapping.generatedColumn -
7700
+ lastGeneratedColumn);
7701
+ lastGeneratedColumn = mapping.generatedColumn;
7702
+ addMappingWithCode(lastMapping, code);
7703
+ // No more remaining code, continue
7704
+ lastMapping = mapping;
7705
+ return;
7706
+ }
7707
+ }
7708
+ // We add the generated code until the first mapping
7709
+ // to the SourceNode without any mapping.
7710
+ // Each line is added as separate string.
7711
+ while (lastGeneratedLine < mapping.generatedLine) {
7712
+ node.add(shiftNextLine());
7713
+ lastGeneratedLine++;
7714
+ }
7715
+ if (lastGeneratedColumn < mapping.generatedColumn) {
7716
+ var nextLine = remainingLines[0];
7717
+ node.add(nextLine.substr(0, mapping.generatedColumn));
7718
+ remainingLines[0] = nextLine.substr(mapping.generatedColumn);
7719
+ lastGeneratedColumn = mapping.generatedColumn;
7720
+ }
7721
+ lastMapping = mapping;
7722
+ }, this);
7723
+ // We have processed all mappings.
7724
+ if (remainingLines.length > 0) {
7725
+ if (lastMapping) {
7726
+ // Associate the remaining code in the current line with "lastMapping"
7727
+ addMappingWithCode(lastMapping, shiftNextLine());
7728
+ }
7729
+ // and add the remaining lines without any mapping
7730
+ node.add(remainingLines.join(""));
7731
+ }
7732
+
7733
+ // Copy sourcesContent into SourceNode
7734
+ aSourceMapConsumer.sources.forEach(function (sourceFile) {
7735
+ var content = aSourceMapConsumer.sourceContentFor(sourceFile);
7736
+ if (content != null) {
7737
+ if (aRelativePath != null) {
7738
+ sourceFile = util.join(aRelativePath, sourceFile);
7739
+ }
7740
+ node.setSourceContent(sourceFile, content);
7741
+ }
7742
+ });
7743
+
7744
+ return node;
7745
+
7746
+ function addMappingWithCode(mapping, code) {
7747
+ if (mapping === null || mapping.source === undefined) {
7748
+ node.add(code);
7749
+ } else {
7750
+ var source = aRelativePath
7751
+ ? util.join(aRelativePath, mapping.source)
7752
+ : mapping.source;
7753
+ node.add(new SourceNode(mapping.originalLine,
7754
+ mapping.originalColumn,
7755
+ source,
7756
+ code,
7757
+ mapping.name));
7758
+ }
7759
+ }
7760
+ };
7761
+
7762
+ /**
7763
+ * Add a chunk of generated JS to this source node.
7764
+ *
7765
+ * @param aChunk A string snippet of generated JS code, another instance of
7766
+ * SourceNode, or an array where each member is one of those things.
7767
+ */
7768
+ SourceNode.prototype.add = function SourceNode_add(aChunk) {
7769
+ if (Array.isArray(aChunk)) {
7770
+ aChunk.forEach(function (chunk) {
7771
+ this.add(chunk);
7772
+ }, this);
7773
+ }
7774
+ else if (aChunk instanceof SourceNode || typeof aChunk === "string") {
7775
+ if (aChunk) {
7776
+ this.children.push(aChunk);
7777
+ }
7778
+ }
7779
+ else {
7780
+ throw new TypeError(
7781
+ "Expected a SourceNode, string, or an array of SourceNodes and strings. Got " + aChunk
7782
+ );
7783
+ }
7784
+ return this;
7785
+ };
7786
+
7787
+ /**
7788
+ * Add a chunk of generated JS to the beginning of this source node.
7789
+ *
7790
+ * @param aChunk A string snippet of generated JS code, another instance of
7791
+ * SourceNode, or an array where each member is one of those things.
7792
+ */
7793
+ SourceNode.prototype.prepend = function SourceNode_prepend(aChunk) {
7794
+ if (Array.isArray(aChunk)) {
7795
+ for (var i = aChunk.length-1; i >= 0; i--) {
7796
+ this.prepend(aChunk[i]);
7797
+ }
7798
+ }
7799
+ else if (aChunk instanceof SourceNode || typeof aChunk === "string") {
7800
+ this.children.unshift(aChunk);
7801
+ }
7802
+ else {
7803
+ throw new TypeError(
7804
+ "Expected a SourceNode, string, or an array of SourceNodes and strings. Got " + aChunk
7805
+ );
7806
+ }
7807
+ return this;
7808
+ };
7809
+
7810
+ /**
7811
+ * Walk over the tree of JS snippets in this node and its children. The
7812
+ * walking function is called once for each snippet of JS and is passed that
7813
+ * snippet and the its original associated source's line/column location.
7814
+ *
7815
+ * @param aFn The traversal function.
7816
+ */
7817
+ SourceNode.prototype.walk = function SourceNode_walk(aFn) {
7818
+ var chunk;
7819
+ for (var i = 0, len = this.children.length; i < len; i++) {
7820
+ chunk = this.children[i];
7821
+ if (chunk instanceof SourceNode) {
7822
+ chunk.walk(aFn);
7823
+ }
7824
+ else {
7825
+ if (chunk !== '') {
7826
+ aFn(chunk, { source: this.source,
7827
+ line: this.line,
7828
+ column: this.column,
7829
+ name: this.name });
7830
+ }
7831
+ }
7832
+ }
7833
+ };
7834
+
7835
+ /**
7836
+ * Like `String.prototype.join` except for SourceNodes. Inserts `aStr` between
7837
+ * each of `this.children`.
7838
+ *
7839
+ * @param aSep The separator.
7840
+ */
7841
+ SourceNode.prototype.join = function SourceNode_join(aSep) {
7842
+ var newChildren;
7843
+ var i;
7844
+ var len = this.children.length;
7845
+ if (len > 0) {
7846
+ newChildren = [];
7847
+ for (i = 0; i < len-1; i++) {
7848
+ newChildren.push(this.children[i]);
7849
+ newChildren.push(aSep);
7850
+ }
7851
+ newChildren.push(this.children[i]);
7852
+ this.children = newChildren;
7853
+ }
7854
+ return this;
7855
+ };
7856
+
7857
+ /**
7858
+ * Call String.prototype.replace on the very right-most source snippet. Useful
7859
+ * for trimming whitespace from the end of a source node, etc.
7860
+ *
7861
+ * @param aPattern The pattern to replace.
7862
+ * @param aReplacement The thing to replace the pattern with.
7863
+ */
7864
+ SourceNode.prototype.replaceRight = function SourceNode_replaceRight(aPattern, aReplacement) {
7865
+ var lastChild = this.children[this.children.length - 1];
7866
+ if (lastChild instanceof SourceNode) {
7867
+ lastChild.replaceRight(aPattern, aReplacement);
7868
+ }
7869
+ else if (typeof lastChild === 'string') {
7870
+ this.children[this.children.length - 1] = lastChild.replace(aPattern, aReplacement);
7871
+ }
7872
+ else {
7873
+ this.children.push(''.replace(aPattern, aReplacement));
7874
+ }
7875
+ return this;
7876
+ };
7877
+
7878
+ /**
7879
+ * Set the source content for a source file. This will be added to the SourceMapGenerator
7880
+ * in the sourcesContent field.
7881
+ *
7882
+ * @param aSourceFile The filename of the source file
7883
+ * @param aSourceContent The content of the source file
7884
+ */
7885
+ SourceNode.prototype.setSourceContent =
7886
+ function SourceNode_setSourceContent(aSourceFile, aSourceContent) {
7887
+ this.sourceContents[util.toSetString(aSourceFile)] = aSourceContent;
7888
+ };
7889
+
7890
+ /**
7891
+ * Walk over the tree of SourceNodes. The walking function is called for each
7892
+ * source file content and is passed the filename and source content.
7893
+ *
7894
+ * @param aFn The traversal function.
7895
+ */
7896
+ SourceNode.prototype.walkSourceContents =
7897
+ function SourceNode_walkSourceContents(aFn) {
7898
+ for (var i = 0, len = this.children.length; i < len; i++) {
7899
+ if (this.children[i] instanceof SourceNode) {
7900
+ this.children[i].walkSourceContents(aFn);
7901
+ }
7902
+ }
7903
+
7904
+ var sources = Object.keys(this.sourceContents);
7905
+ for (var i = 0, len = sources.length; i < len; i++) {
7906
+ aFn(util.fromSetString(sources[i]), this.sourceContents[sources[i]]);
7907
+ }
7908
+ };
7909
+
7910
+ /**
7911
+ * Return the string representation of this source node. Walks over the tree
7912
+ * and concatenates all the various snippets together to one string.
7913
+ */
7914
+ SourceNode.prototype.toString = function SourceNode_toString() {
7915
+ var str = "";
7916
+ this.walk(function (chunk) {
7917
+ str += chunk;
7918
+ });
7919
+ return str;
7920
+ };
7921
+
7922
+ /**
7923
+ * Returns the string representation of this source node along with a source
7924
+ * map.
7925
+ */
7926
+ SourceNode.prototype.toStringWithSourceMap = function SourceNode_toStringWithSourceMap(aArgs) {
7927
+ var generated = {
7928
+ code: "",
7929
+ line: 1,
7930
+ column: 0
7931
+ };
7932
+ var map = new SourceMapGenerator(aArgs);
7933
+ var sourceMappingActive = false;
7934
+ var lastOriginalSource = null;
7935
+ var lastOriginalLine = null;
7936
+ var lastOriginalColumn = null;
7937
+ var lastOriginalName = null;
7938
+ this.walk(function (chunk, original) {
7939
+ generated.code += chunk;
7940
+ if (original.source !== null
7941
+ && original.line !== null
7942
+ && original.column !== null) {
7943
+ if(lastOriginalSource !== original.source
7944
+ || lastOriginalLine !== original.line
7945
+ || lastOriginalColumn !== original.column
7946
+ || lastOriginalName !== original.name) {
7947
+ map.addMapping({
7948
+ source: original.source,
7949
+ original: {
7950
+ line: original.line,
7951
+ column: original.column
7952
+ },
7953
+ generated: {
7954
+ line: generated.line,
7955
+ column: generated.column
7956
+ },
7957
+ name: original.name
7958
+ });
7959
+ }
7960
+ lastOriginalSource = original.source;
7961
+ lastOriginalLine = original.line;
7962
+ lastOriginalColumn = original.column;
7963
+ lastOriginalName = original.name;
7964
+ sourceMappingActive = true;
7965
+ } else if (sourceMappingActive) {
7966
+ map.addMapping({
7967
+ generated: {
7968
+ line: generated.line,
7969
+ column: generated.column
7970
+ }
7971
+ });
7972
+ lastOriginalSource = null;
7973
+ sourceMappingActive = false;
7974
+ }
7975
+ chunk.match(REGEX_CHARACTER).forEach(function (ch, idx, array) {
7976
+ if (REGEX_NEWLINE.test(ch)) {
7977
+ generated.line++;
7978
+ generated.column = 0;
7979
+ // Mappings end at eol
7980
+ if (idx + 1 === array.length) {
7981
+ lastOriginalSource = null;
7982
+ sourceMappingActive = false;
7983
+ } else if (sourceMappingActive) {
7984
+ map.addMapping({
7985
+ source: original.source,
7986
+ original: {
7987
+ line: original.line,
7988
+ column: original.column
7989
+ },
7990
+ generated: {
7991
+ line: generated.line,
7992
+ column: generated.column
7993
+ },
7994
+ name: original.name
7995
+ });
7996
+ }
7997
+ } else {
7998
+ generated.column += ch.length;
7999
+ }
8000
+ });
8001
+ });
8002
+ this.walkSourceContents(function (sourceFile, sourceContent) {
8003
+ map.setSourceContent(sourceFile, sourceContent);
8004
+ });
8005
+
8006
+ return { code: generated.code, map: map };
8007
+ };
8008
+
8009
+ exports.SourceNode = SourceNode;
8010
+
8011
+ });
8012
+
8013
+ },{"./source-map-generator":25,"./util":27,"amdefine":28}],27:[function(require,module,exports){
8014
+ /* -*- Mode: js; js-indent-level: 2; -*- */
8015
+ /*
8016
+ * Copyright 2011 Mozilla Foundation and contributors
8017
+ * Licensed under the New BSD license. See LICENSE or:
8018
+ * http://opensource.org/licenses/BSD-3-Clause
8019
+ */
8020
+ if (typeof define !== 'function') {
8021
+ var define = require('amdefine')(module, require);
8022
+ }
8023
+ define(function (require, exports, module) {
8024
+
8025
+ /**
8026
+ * This is a helper function for getting values from parameter/options
8027
+ * objects.
8028
+ *
8029
+ * @param args The object we are extracting values from
8030
+ * @param name The name of the property we are getting.
8031
+ * @param defaultValue An optional value to return if the property is missing
8032
+ * from the object. If this is not specified and the property is missing, an
8033
+ * error will be thrown.
8034
+ */
8035
+ function getArg(aArgs, aName, aDefaultValue) {
8036
+ if (aName in aArgs) {
8037
+ return aArgs[aName];
8038
+ } else if (arguments.length === 3) {
8039
+ return aDefaultValue;
8040
+ } else {
8041
+ throw new Error('"' + aName + '" is a required argument.');
8042
+ }
8043
+ }
8044
+ exports.getArg = getArg;
8045
+
8046
+ var urlRegexp = /^(?:([\w+\-.]+):)?\/\/(?:(\w+:\w+)@)?([\w.]*)(?::(\d+))?(\S*)$/;
8047
+ var dataUrlRegexp = /^data:.+\,.+$/;
8048
+
8049
+ function urlParse(aUrl) {
8050
+ var match = aUrl.match(urlRegexp);
8051
+ if (!match) {
8052
+ return null;
8053
+ }
8054
+ return {
8055
+ scheme: match[1],
8056
+ auth: match[2],
8057
+ host: match[3],
8058
+ port: match[4],
8059
+ path: match[5]
8060
+ };
8061
+ }
8062
+ exports.urlParse = urlParse;
8063
+
8064
+ function urlGenerate(aParsedUrl) {
8065
+ var url = '';
8066
+ if (aParsedUrl.scheme) {
8067
+ url += aParsedUrl.scheme + ':';
8068
+ }
8069
+ url += '//';
8070
+ if (aParsedUrl.auth) {
8071
+ url += aParsedUrl.auth + '@';
8072
+ }
8073
+ if (aParsedUrl.host) {
8074
+ url += aParsedUrl.host;
8075
+ }
8076
+ if (aParsedUrl.port) {
8077
+ url += ":" + aParsedUrl.port
8078
+ }
8079
+ if (aParsedUrl.path) {
8080
+ url += aParsedUrl.path;
8081
+ }
8082
+ return url;
8083
+ }
8084
+ exports.urlGenerate = urlGenerate;
8085
+
8086
+ /**
8087
+ * Normalizes a path, or the path portion of a URL:
8088
+ *
8089
+ * - Replaces consequtive slashes with one slash.
8090
+ * - Removes unnecessary '.' parts.
8091
+ * - Removes unnecessary '<dir>/..' parts.
8092
+ *
8093
+ * Based on code in the Node.js 'path' core module.
8094
+ *
8095
+ * @param aPath The path or url to normalize.
8096
+ */
8097
+ function normalize(aPath) {
8098
+ var path = aPath;
8099
+ var url = urlParse(aPath);
8100
+ if (url) {
8101
+ if (!url.path) {
8102
+ return aPath;
8103
+ }
8104
+ path = url.path;
8105
+ }
8106
+ var isAbsolute = (path.charAt(0) === '/');
8107
+
8108
+ var parts = path.split(/\/+/);
8109
+ for (var part, up = 0, i = parts.length - 1; i >= 0; i--) {
8110
+ part = parts[i];
8111
+ if (part === '.') {
8112
+ parts.splice(i, 1);
8113
+ } else if (part === '..') {
8114
+ up++;
8115
+ } else if (up > 0) {
8116
+ if (part === '') {
8117
+ // The first part is blank if the path is absolute. Trying to go
8118
+ // above the root is a no-op. Therefore we can remove all '..' parts
8119
+ // directly after the root.
8120
+ parts.splice(i + 1, up);
8121
+ up = 0;
8122
+ } else {
8123
+ parts.splice(i, 2);
8124
+ up--;
8125
+ }
8126
+ }
8127
+ }
8128
+ path = parts.join('/');
8129
+
8130
+ if (path === '') {
8131
+ path = isAbsolute ? '/' : '.';
8132
+ }
8133
+
8134
+ if (url) {
8135
+ url.path = path;
8136
+ return urlGenerate(url);
8137
+ }
8138
+ return path;
8139
+ }
8140
+ exports.normalize = normalize;
8141
+
8142
+ /**
8143
+ * Joins two paths/URLs.
8144
+ *
8145
+ * @param aRoot The root path or URL.
8146
+ * @param aPath The path or URL to be joined with the root.
8147
+ *
8148
+ * - If aPath is a URL or a data URI, aPath is returned, unless aPath is a
8149
+ * scheme-relative URL: Then the scheme of aRoot, if any, is prepended
8150
+ * first.
8151
+ * - Otherwise aPath is a path. If aRoot is a URL, then its path portion
8152
+ * is updated with the result and aRoot is returned. Otherwise the result
8153
+ * is returned.
8154
+ * - If aPath is absolute, the result is aPath.
8155
+ * - Otherwise the two paths are joined with a slash.
8156
+ * - Joining for example 'http://' and 'www.example.com' is also supported.
8157
+ */
8158
+ function join(aRoot, aPath) {
8159
+ if (aRoot === "") {
8160
+ aRoot = ".";
8161
+ }
8162
+ if (aPath === "") {
8163
+ aPath = ".";
8164
+ }
8165
+ var aPathUrl = urlParse(aPath);
8166
+ var aRootUrl = urlParse(aRoot);
8167
+ if (aRootUrl) {
8168
+ aRoot = aRootUrl.path || '/';
8169
+ }
8170
+
8171
+ // `join(foo, '//www.example.org')`
8172
+ if (aPathUrl && !aPathUrl.scheme) {
8173
+ if (aRootUrl) {
8174
+ aPathUrl.scheme = aRootUrl.scheme;
8175
+ }
8176
+ return urlGenerate(aPathUrl);
8177
+ }
8178
+
8179
+ if (aPathUrl || aPath.match(dataUrlRegexp)) {
8180
+ return aPath;
8181
+ }
8182
+
8183
+ // `join('http://', 'www.example.com')`
8184
+ if (aRootUrl && !aRootUrl.host && !aRootUrl.path) {
8185
+ aRootUrl.host = aPath;
8186
+ return urlGenerate(aRootUrl);
8187
+ }
8188
+
8189
+ var joined = aPath.charAt(0) === '/'
8190
+ ? aPath
8191
+ : normalize(aRoot.replace(/\/+$/, '') + '/' + aPath);
8192
+
8193
+ if (aRootUrl) {
8194
+ aRootUrl.path = joined;
8195
+ return urlGenerate(aRootUrl);
8196
+ }
8197
+ return joined;
8198
+ }
8199
+ exports.join = join;
8200
+
8201
+ /**
8202
+ * Make a path relative to a URL or another path.
8203
+ *
8204
+ * @param aRoot The root path or URL.
8205
+ * @param aPath The path or URL to be made relative to aRoot.
8206
+ */
8207
+ function relative(aRoot, aPath) {
8208
+ if (aRoot === "") {
8209
+ aRoot = ".";
8210
+ }
8211
+
8212
+ aRoot = aRoot.replace(/\/$/, '');
8213
+
8214
+ // XXX: It is possible to remove this block, and the tests still pass!
8215
+ var url = urlParse(aRoot);
8216
+ if (aPath.charAt(0) == "/" && url && url.path == "/") {
8217
+ return aPath.slice(1);
8218
+ }
8219
+
8220
+ return aPath.indexOf(aRoot + '/') === 0
8221
+ ? aPath.substr(aRoot.length + 1)
8222
+ : aPath;
8223
+ }
8224
+ exports.relative = relative;
8225
+
8226
+ /**
8227
+ * Because behavior goes wacky when you set `__proto__` on objects, we
8228
+ * have to prefix all the strings in our set with an arbitrary character.
8229
+ *
8230
+ * See https://github.com/mozilla/source-map/pull/31 and
8231
+ * https://github.com/mozilla/source-map/issues/30
8232
+ *
8233
+ * @param String aStr
8234
+ */
8235
+ function toSetString(aStr) {
8236
+ return '$' + aStr;
8237
+ }
8238
+ exports.toSetString = toSetString;
8239
+
8240
+ function fromSetString(aStr) {
8241
+ return aStr.substr(1);
8242
+ }
8243
+ exports.fromSetString = fromSetString;
8244
+
8245
+ function strcmp(aStr1, aStr2) {
8246
+ var s1 = aStr1 || "";
8247
+ var s2 = aStr2 || "";
8248
+ return (s1 > s2) - (s1 < s2);
8249
+ }
8250
+
8251
+ /**
8252
+ * Comparator between two mappings where the original positions are compared.
8253
+ *
8254
+ * Optionally pass in `true` as `onlyCompareGenerated` to consider two
8255
+ * mappings with the same original source/line/column, but different generated
8256
+ * line and column the same. Useful when searching for a mapping with a
8257
+ * stubbed out mapping.
8258
+ */
8259
+ function compareByOriginalPositions(mappingA, mappingB, onlyCompareOriginal) {
8260
+ var cmp;
8261
+
8262
+ cmp = strcmp(mappingA.source, mappingB.source);
8263
+ if (cmp) {
8264
+ return cmp;
8265
+ }
8266
+
8267
+ cmp = mappingA.originalLine - mappingB.originalLine;
8268
+ if (cmp) {
8269
+ return cmp;
8270
+ }
8271
+
8272
+ cmp = mappingA.originalColumn - mappingB.originalColumn;
8273
+ if (cmp || onlyCompareOriginal) {
8274
+ return cmp;
8275
+ }
8276
+
8277
+ cmp = strcmp(mappingA.name, mappingB.name);
8278
+ if (cmp) {
8279
+ return cmp;
8280
+ }
8281
+
8282
+ cmp = mappingA.generatedLine - mappingB.generatedLine;
8283
+ if (cmp) {
8284
+ return cmp;
8285
+ }
8286
+
8287
+ return mappingA.generatedColumn - mappingB.generatedColumn;
8288
+ };
8289
+ exports.compareByOriginalPositions = compareByOriginalPositions;
8290
+
8291
+ /**
8292
+ * Comparator between two mappings where the generated positions are
8293
+ * compared.
8294
+ *
8295
+ * Optionally pass in `true` as `onlyCompareGenerated` to consider two
8296
+ * mappings with the same generated line and column, but different
8297
+ * source/name/original line and column the same. Useful when searching for a
8298
+ * mapping with a stubbed out mapping.
8299
+ */
8300
+ function compareByGeneratedPositions(mappingA, mappingB, onlyCompareGenerated) {
8301
+ var cmp;
8302
+
8303
+ cmp = mappingA.generatedLine - mappingB.generatedLine;
8304
+ if (cmp) {
8305
+ return cmp;
8306
+ }
8307
+
8308
+ cmp = mappingA.generatedColumn - mappingB.generatedColumn;
8309
+ if (cmp || onlyCompareGenerated) {
8310
+ return cmp;
8311
+ }
8312
+
8313
+ cmp = strcmp(mappingA.source, mappingB.source);
8314
+ if (cmp) {
8315
+ return cmp;
8316
+ }
8317
+
8318
+ cmp = mappingA.originalLine - mappingB.originalLine;
8319
+ if (cmp) {
8320
+ return cmp;
8321
+ }
8322
+
8323
+ cmp = mappingA.originalColumn - mappingB.originalColumn;
8324
+ if (cmp) {
8325
+ return cmp;
8326
+ }
8327
+
8328
+ return strcmp(mappingA.name, mappingB.name);
8329
+ };
8330
+ exports.compareByGeneratedPositions = compareByGeneratedPositions;
8331
+
8332
+ });
8333
+
8334
+ },{"amdefine":28}],28:[function(require,module,exports){
8335
+ (function (process,__filename){
8336
+ /** vim: et:ts=4:sw=4:sts=4
8337
+ * @license amdefine 0.1.0 Copyright (c) 2011, The Dojo Foundation All Rights Reserved.
8338
+ * Available via the MIT or new BSD license.
8339
+ * see: http://github.com/jrburke/amdefine for details
8340
+ */
8341
+
8342
+ /*jslint node: true */
8343
+ /*global module, process */
8344
+ 'use strict';
8345
+
8346
+ /**
8347
+ * Creates a define for node.
8348
+ * @param {Object} module the "module" object that is defined by Node for the
8349
+ * current module.
8350
+ * @param {Function} [requireFn]. Node's require function for the current module.
8351
+ * It only needs to be passed in Node versions before 0.5, when module.require
8352
+ * did not exist.
8353
+ * @returns {Function} a define function that is usable for the current node
8354
+ * module.
8355
+ */
8356
+ function amdefine(module, requireFn) {
8357
+ 'use strict';
8358
+ var defineCache = {},
8359
+ loaderCache = {},
8360
+ alreadyCalled = false,
8361
+ path = require('path'),
8362
+ makeRequire, stringRequire;
8363
+
8364
+ /**
8365
+ * Trims the . and .. from an array of path segments.
8366
+ * It will keep a leading path segment if a .. will become
8367
+ * the first path segment, to help with module name lookups,
8368
+ * which act like paths, but can be remapped. But the end result,
8369
+ * all paths that use this function should look normalized.
8370
+ * NOTE: this method MODIFIES the input array.
8371
+ * @param {Array} ary the array of path segments.
8372
+ */
8373
+ function trimDots(ary) {
8374
+ var i, part;
8375
+ for (i = 0; ary[i]; i+= 1) {
8376
+ part = ary[i];
8377
+ if (part === '.') {
8378
+ ary.splice(i, 1);
8379
+ i -= 1;
8380
+ } else if (part === '..') {
8381
+ if (i === 1 && (ary[2] === '..' || ary[0] === '..')) {
8382
+ //End of the line. Keep at least one non-dot
8383
+ //path segment at the front so it can be mapped
8384
+ //correctly to disk. Otherwise, there is likely
8385
+ //no path mapping for a path starting with '..'.
8386
+ //This can still fail, but catches the most reasonable
8387
+ //uses of ..
8388
+ break;
8389
+ } else if (i > 0) {
8390
+ ary.splice(i - 1, 2);
8391
+ i -= 2;
8392
+ }
8393
+ }
8394
+ }
8395
+ }
8396
+
8397
+ function normalize(name, baseName) {
8398
+ var baseParts;
8399
+
8400
+ //Adjust any relative paths.
8401
+ if (name && name.charAt(0) === '.') {
8402
+ //If have a base name, try to normalize against it,
8403
+ //otherwise, assume it is a top-level require that will
8404
+ //be relative to baseUrl in the end.
8405
+ if (baseName) {
8406
+ baseParts = baseName.split('/');
8407
+ baseParts = baseParts.slice(0, baseParts.length - 1);
8408
+ baseParts = baseParts.concat(name.split('/'));
8409
+ trimDots(baseParts);
8410
+ name = baseParts.join('/');
8411
+ }
8412
+ }
8413
+
8414
+ return name;
8415
+ }
8416
+
8417
+ /**
8418
+ * Create the normalize() function passed to a loader plugin's
8419
+ * normalize method.
8420
+ */
8421
+ function makeNormalize(relName) {
8422
+ return function (name) {
8423
+ return normalize(name, relName);
8424
+ };
8425
+ }
8426
+
8427
+ function makeLoad(id) {
8428
+ function load(value) {
8429
+ loaderCache[id] = value;
8430
+ }
8431
+
8432
+ load.fromText = function (id, text) {
8433
+ //This one is difficult because the text can/probably uses
8434
+ //define, and any relative paths and requires should be relative
8435
+ //to that id was it would be found on disk. But this would require
8436
+ //bootstrapping a module/require fairly deeply from node core.
8437
+ //Not sure how best to go about that yet.
8438
+ throw new Error('amdefine does not implement load.fromText');
8439
+ };
8440
+
8441
+ return load;
8442
+ }
8443
+
8444
+ makeRequire = function (systemRequire, exports, module, relId) {
8445
+ function amdRequire(deps, callback) {
8446
+ if (typeof deps === 'string') {
8447
+ //Synchronous, single module require('')
8448
+ return stringRequire(systemRequire, exports, module, deps, relId);
8449
+ } else {
8450
+ //Array of dependencies with a callback.
8451
+
8452
+ //Convert the dependencies to modules.
8453
+ deps = deps.map(function (depName) {
8454
+ return stringRequire(systemRequire, exports, module, depName, relId);
8455
+ });
8456
+
8457
+ //Wait for next tick to call back the require call.
8458
+ process.nextTick(function () {
8459
+ callback.apply(null, deps);
8460
+ });
8461
+ }
8462
+ }
8463
+
8464
+ amdRequire.toUrl = function (filePath) {
8465
+ if (filePath.indexOf('.') === 0) {
8466
+ return normalize(filePath, path.dirname(module.filename));
8467
+ } else {
8468
+ return filePath;
8469
+ }
8470
+ };
8471
+
8472
+ return amdRequire;
8473
+ };
8474
+
8475
+ //Favor explicit value, passed in if the module wants to support Node 0.4.
8476
+ requireFn = requireFn || function req() {
8477
+ return module.require.apply(module, arguments);
8478
+ };
8479
+
8480
+ function runFactory(id, deps, factory) {
8481
+ var r, e, m, result;
8482
+
8483
+ if (id) {
8484
+ e = loaderCache[id] = {};
8485
+ m = {
8486
+ id: id,
8487
+ uri: __filename,
8488
+ exports: e
8489
+ };
8490
+ r = makeRequire(requireFn, e, m, id);
8491
+ } else {
8492
+ //Only support one define call per file
8493
+ if (alreadyCalled) {
8494
+ throw new Error('amdefine with no module ID cannot be called more than once per file.');
8495
+ }
8496
+ alreadyCalled = true;
8497
+
8498
+ //Use the real variables from node
8499
+ //Use module.exports for exports, since
8500
+ //the exports in here is amdefine exports.
8501
+ e = module.exports;
8502
+ m = module;
8503
+ r = makeRequire(requireFn, e, m, module.id);
8504
+ }
8505
+
8506
+ //If there are dependencies, they are strings, so need
8507
+ //to convert them to dependency values.
8508
+ if (deps) {
8509
+ deps = deps.map(function (depName) {
8510
+ return r(depName);
8511
+ });
8512
+ }
8513
+
8514
+ //Call the factory with the right dependencies.
8515
+ if (typeof factory === 'function') {
8516
+ result = factory.apply(m.exports, deps);
8517
+ } else {
8518
+ result = factory;
8519
+ }
8520
+
8521
+ if (result !== undefined) {
8522
+ m.exports = result;
8523
+ if (id) {
8524
+ loaderCache[id] = m.exports;
8525
+ }
8526
+ }
8527
+ }
8528
+
8529
+ stringRequire = function (systemRequire, exports, module, id, relId) {
8530
+ //Split the ID by a ! so that
8531
+ var index = id.indexOf('!'),
8532
+ originalId = id,
8533
+ prefix, plugin;
8534
+
8535
+ if (index === -1) {
8536
+ id = normalize(id, relId);
8537
+
8538
+ //Straight module lookup. If it is one of the special dependencies,
8539
+ //deal with it, otherwise, delegate to node.
8540
+ if (id === 'require') {
8541
+ return makeRequire(systemRequire, exports, module, relId);
8542
+ } else if (id === 'exports') {
8543
+ return exports;
8544
+ } else if (id === 'module') {
8545
+ return module;
8546
+ } else if (loaderCache.hasOwnProperty(id)) {
8547
+ return loaderCache[id];
8548
+ } else if (defineCache[id]) {
8549
+ runFactory.apply(null, defineCache[id]);
8550
+ return loaderCache[id];
8551
+ } else {
8552
+ if(systemRequire) {
8553
+ return systemRequire(originalId);
8554
+ } else {
8555
+ throw new Error('No module with ID: ' + id);
8556
+ }
8557
+ }
8558
+ } else {
8559
+ //There is a plugin in play.
8560
+ prefix = id.substring(0, index);
8561
+ id = id.substring(index + 1, id.length);
8562
+
8563
+ plugin = stringRequire(systemRequire, exports, module, prefix, relId);
8564
+
8565
+ if (plugin.normalize) {
8566
+ id = plugin.normalize(id, makeNormalize(relId));
8567
+ } else {
8568
+ //Normalize the ID normally.
8569
+ id = normalize(id, relId);
8570
+ }
8571
+
8572
+ if (loaderCache[id]) {
8573
+ return loaderCache[id];
8574
+ } else {
8575
+ plugin.load(id, makeRequire(systemRequire, exports, module, relId), makeLoad(id), {});
8576
+
8577
+ return loaderCache[id];
8578
+ }
8579
+ }
8580
+ };
8581
+
8582
+ //Create a define function specific to the module asking for amdefine.
8583
+ function define(id, deps, factory) {
8584
+ if (Array.isArray(id)) {
8585
+ factory = deps;
8586
+ deps = id;
8587
+ id = undefined;
8588
+ } else if (typeof id !== 'string') {
8589
+ factory = id;
8590
+ id = deps = undefined;
8591
+ }
8592
+
8593
+ if (deps && !Array.isArray(deps)) {
8594
+ factory = deps;
8595
+ deps = undefined;
8596
+ }
8597
+
8598
+ if (!deps) {
8599
+ deps = ['require', 'exports', 'module'];
8600
+ }
8601
+
8602
+ //Set up properties for this module. If an ID, then use
8603
+ //internal cache. If no ID, then use the external variables
8604
+ //for this node module.
8605
+ if (id) {
8606
+ //Put the module in deep freeze until there is a
8607
+ //require call for it.
8608
+ defineCache[id] = [id, deps, factory];
8609
+ } else {
8610
+ runFactory(id, deps, factory);
8611
+ }
8612
+ }
8613
+
8614
+ //define.require, which has access to all the values in the
8615
+ //cache. Useful for AMD modules that all have IDs in the file,
8616
+ //but need to finally export a value to node based on one of those
8617
+ //IDs.
8618
+ define.require = function (id) {
8619
+ if (loaderCache[id]) {
8620
+ return loaderCache[id];
8621
+ }
8622
+
8623
+ if (defineCache[id]) {
8624
+ runFactory.apply(null, defineCache[id]);
8625
+ return loaderCache[id];
8626
+ }
8627
+ };
8628
+
8629
+ define.amd = {};
8630
+
8631
+ return define;
8632
+ }
8633
+
8634
+ module.exports = amdefine;
8635
+
8636
+ }).call(this,require('_process'),"/node_modules/ng-annotate/node_modules/source-map/node_modules/amdefine/amdefine.js")
8637
+ },{"_process":7,"path":6}],29:[function(require,module,exports){
8638
+ //! stable.js 0.1.5, https://github.com/Two-Screen/stable
8639
+ //! © 2014 Angry Bytes and contributors. MIT licensed.
8640
+
8641
+ (function() {
8642
+
8643
+ // A stable array sort, because `Array#sort()` is not guaranteed stable.
8644
+ // This is an implementation of merge sort, without recursion.
8645
+
8646
+ var stable = function(arr, comp) {
8647
+ return exec(arr.slice(), comp);
8648
+ };
8649
+
8650
+ stable.inplace = function(arr, comp) {
8651
+ var result = exec(arr, comp);
8652
+
8653
+ // This simply copies back if the result isn't in the original array,
8654
+ // which happens on an odd number of passes.
8655
+ if (result !== arr) {
8656
+ pass(result, null, arr.length, arr);
8657
+ }
8658
+
8659
+ return arr;
8660
+ };
8661
+
8662
+ // Execute the sort using the input array and a second buffer as work space.
8663
+ // Returns one of those two, containing the final result.
8664
+ function exec(arr, comp) {
8665
+ if (typeof(comp) !== 'function') {
8666
+ comp = function(a, b) {
8667
+ return String(a).localeCompare(b);
8668
+ };
8669
+ }
8670
+
8671
+ // Short-circuit when there's nothing to sort.
8672
+ var len = arr.length;
8673
+ if (len <= 1) {
8674
+ return arr;
8675
+ }
8676
+
8677
+ // Rather than dividing input, simply iterate chunks of 1, 2, 4, 8, etc.
8678
+ // Chunks are the size of the left or right hand in merge sort.
8679
+ // Stop when the left-hand covers all of the array.
8680
+ var buffer = new Array(len);
8681
+ for (var chk = 1; chk < len; chk *= 2) {
8682
+ pass(arr, comp, chk, buffer);
8683
+
8684
+ var tmp = arr;
8685
+ arr = buffer;
8686
+ buffer = tmp;
8687
+ }
8688
+
8689
+ return arr;
8690
+ }
8691
+
8692
+ // Run a single pass with the given chunk size.
8693
+ var pass = function(arr, comp, chk, result) {
8694
+ var len = arr.length;
8695
+ var i = 0;
8696
+ // Step size / double chunk size.
8697
+ var dbl = chk * 2;
8698
+ // Bounds of the left and right chunks.
8699
+ var l, r, e;
8700
+ // Iterators over the left and right chunk.
8701
+ var li, ri;
8702
+
8703
+ // Iterate over pairs of chunks.
8704
+ for (l = 0; l < len; l += dbl) {
8705
+ r = l + chk;
8706
+ e = r + chk;
8707
+ if (r > len) r = len;
8708
+ if (e > len) e = len;
8709
+
8710
+ // Iterate both chunks in parallel.
8711
+ li = l;
8712
+ ri = r;
8713
+ while (true) {
8714
+ // Compare the chunks.
8715
+ if (li < r && ri < e) {
8716
+ // This works for a regular `sort()` compatible comparator,
8717
+ // but also for a simple comparator like: `a > b`
8718
+ if (comp(arr[li], arr[ri]) <= 0) {
8719
+ result[i++] = arr[li++];
8720
+ }
8721
+ else {
8722
+ result[i++] = arr[ri++];
8723
+ }
8724
+ }
8725
+ // Nothing to compare, just flush what's left.
8726
+ else if (li < r) {
8727
+ result[i++] = arr[li++];
8728
+ }
8729
+ else if (ri < e) {
8730
+ result[i++] = arr[ri++];
8731
+ }
8732
+ // Both iterators are at the chunk ends.
8733
+ else {
8734
+ break;
8735
+ }
8736
+ }
8737
+ }
8738
+ };
8739
+
8740
+ // Export using CommonJS or to the window.
8741
+ if (typeof(module) !== 'undefined') {
8742
+ module.exports = stable;
8743
+ }
8744
+ else {
8745
+ window.stable = stable;
8746
+ }
8747
+
8748
+ })();
8749
+
8750
+ },{}]},{},[10]);