PluginProbe ʕ •ᴥ•ʔ
SiteOrigin CSS / 1.1
SiteOrigin CSS v1.1
1.2.1 1.2.10 1.2.11 1.2.12 1.2.13 1.2.14 1.2.2 1.2.3 1.2.4 1.2.5 1.2.6 1.2.7 1.2.8 1.2.9 1.3.0 1.3.1 1.3.2 1.4.0 1.4.1 1.4.2 1.4.3 1.5.0 1.5.1 1.5.10 1.5.11 1.5.2 1.5.3 1.5.4 1.5.5 1.5.6 1.5.7 1.5.8 1.5.9 1.6.0 1.6.1 1.6.2 1.6.3 1.6.4 1.6.5 1.6.6 trunk 1.0 1.0.1 1.0.2 1.0.3 1.0.4 1.0.5 1.0.6 1.0.7 1.0.8 1.1 1.1.1 1.1.2 1.1.3 1.1.4 1.1.5 1.2.0
so-css / js / css.js
so-css / js Last commit date
URI.js 9 years ago URI.min.js 9 years ago css.js 9 years ago css.min.js 9 years ago csslint.js 11 years ago csslint.min.js 10 years ago editor.js 9 years ago editor.min.js 9 years ago inspector.js 9 years ago inspector.min.js 9 years ago jquery.sizes.js 11 years ago jquery.sizes.min.js 10 years ago specificity.js 11 years ago specificity.min.js 10 years ago
css.js
4488 lines
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
3 },{}],2:[function(require,module,exports){
4 (function (process){
5 // Copyright Joyent, Inc. and other Node contributors.
6 //
7 // Permission is hereby granted, free of charge, to any person obtaining a
8 // copy of this software and associated documentation files (the
9 // "Software"), to deal in the Software without restriction, including
10 // without limitation the rights to use, copy, modify, merge, publish,
11 // distribute, sublicense, and/or sell copies of the Software, and to permit
12 // persons to whom the Software is furnished to do so, subject to the
13 // following conditions:
14 //
15 // The above copyright notice and this permission notice shall be included
16 // in all copies or substantial portions of the Software.
17 //
18 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
19 // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
20 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
21 // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
22 // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
23 // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
24 // USE OR OTHER DEALINGS IN THE SOFTWARE.
25
26 // resolves . and .. elements in a path array with directory names there
27 // must be no slashes, empty elements, or device names (c:\) in the array
28 // (so also no leading and trailing slashes - it does not distinguish
29 // relative and absolute paths)
30 function normalizeArray(parts, allowAboveRoot) {
31 // if the path tries to go above the root, `up` ends up > 0
32 var up = 0;
33 for (var i = parts.length - 1; i >= 0; i--) {
34 var last = parts[i];
35 if (last === '.') {
36 parts.splice(i, 1);
37 } else if (last === '..') {
38 parts.splice(i, 1);
39 up++;
40 } else if (up) {
41 parts.splice(i, 1);
42 up--;
43 }
44 }
45
46 // if the path is allowed to go above the root, restore leading ..s
47 if (allowAboveRoot) {
48 for (; up--; up) {
49 parts.unshift('..');
50 }
51 }
52
53 return parts;
54 }
55
56 // Split a filename into [root, dir, basename, ext], unix version
57 // 'root' is just a slash, or nothing.
58 var splitPathRe =
59 /^(\/?|)([\s\S]*?)((?:\.{1,2}|[^\/]+?|)(\.[^.\/]*|))(?:[\/]*)$/;
60 var splitPath = function(filename) {
61 return splitPathRe.exec(filename).slice(1);
62 };
63
64 // path.resolve([from ...], to)
65 // posix version
66 exports.resolve = function() {
67 var resolvedPath = '',
68 resolvedAbsolute = false;
69
70 for (var i = arguments.length - 1; i >= -1 && !resolvedAbsolute; i--) {
71 var path = (i >= 0) ? arguments[i] : process.cwd();
72
73 // Skip empty and invalid entries
74 if (typeof path !== 'string') {
75 throw new TypeError('Arguments to path.resolve must be strings');
76 } else if (!path) {
77 continue;
78 }
79
80 resolvedPath = path + '/' + resolvedPath;
81 resolvedAbsolute = path.charAt(0) === '/';
82 }
83
84 // At this point the path should be resolved to a full absolute path, but
85 // handle relative paths to be safe (might happen when process.cwd() fails)
86
87 // Normalize the path
88 resolvedPath = normalizeArray(filter(resolvedPath.split('/'), function(p) {
89 return !!p;
90 }), !resolvedAbsolute).join('/');
91
92 return ((resolvedAbsolute ? '/' : '') + resolvedPath) || '.';
93 };
94
95 // path.normalize(path)
96 // posix version
97 exports.normalize = function(path) {
98 var isAbsolute = exports.isAbsolute(path),
99 trailingSlash = substr(path, -1) === '/';
100
101 // Normalize the path
102 path = normalizeArray(filter(path.split('/'), function(p) {
103 return !!p;
104 }), !isAbsolute).join('/');
105
106 if (!path && !isAbsolute) {
107 path = '.';
108 }
109 if (path && trailingSlash) {
110 path += '/';
111 }
112
113 return (isAbsolute ? '/' : '') + path;
114 };
115
116 // posix version
117 exports.isAbsolute = function(path) {
118 return path.charAt(0) === '/';
119 };
120
121 // posix version
122 exports.join = function() {
123 var paths = Array.prototype.slice.call(arguments, 0);
124 return exports.normalize(filter(paths, function(p, index) {
125 if (typeof p !== 'string') {
126 throw new TypeError('Arguments to path.join must be strings');
127 }
128 return p;
129 }).join('/'));
130 };
131
132
133 // path.relative(from, to)
134 // posix version
135 exports.relative = function(from, to) {
136 from = exports.resolve(from).substr(1);
137 to = exports.resolve(to).substr(1);
138
139 function trim(arr) {
140 var start = 0;
141 for (; start < arr.length; start++) {
142 if (arr[start] !== '') break;
143 }
144
145 var end = arr.length - 1;
146 for (; end >= 0; end--) {
147 if (arr[end] !== '') break;
148 }
149
150 if (start > end) return [];
151 return arr.slice(start, end - start + 1);
152 }
153
154 var fromParts = trim(from.split('/'));
155 var toParts = trim(to.split('/'));
156
157 var length = Math.min(fromParts.length, toParts.length);
158 var samePartsLength = length;
159 for (var i = 0; i < length; i++) {
160 if (fromParts[i] !== toParts[i]) {
161 samePartsLength = i;
162 break;
163 }
164 }
165
166 var outputParts = [];
167 for (var i = samePartsLength; i < fromParts.length; i++) {
168 outputParts.push('..');
169 }
170
171 outputParts = outputParts.concat(toParts.slice(samePartsLength));
172
173 return outputParts.join('/');
174 };
175
176 exports.sep = '/';
177 exports.delimiter = ':';
178
179 exports.dirname = function(path) {
180 var result = splitPath(path),
181 root = result[0],
182 dir = result[1];
183
184 if (!root && !dir) {
185 // No dirname whatsoever
186 return '.';
187 }
188
189 if (dir) {
190 // It has a dirname, strip trailing slash
191 dir = dir.substr(0, dir.length - 1);
192 }
193
194 return root + dir;
195 };
196
197
198 exports.basename = function(path, ext) {
199 var f = splitPath(path)[2];
200 // TODO: make this comparison case-insensitive on windows?
201 if (ext && f.substr(-1 * ext.length) === ext) {
202 f = f.substr(0, f.length - ext.length);
203 }
204 return f;
205 };
206
207
208 exports.extname = function(path) {
209 return splitPath(path)[3];
210 };
211
212 function filter (xs, f) {
213 if (xs.filter) return xs.filter(f);
214 var res = [];
215 for (var i = 0; i < xs.length; i++) {
216 if (f(xs[i], i, xs)) res.push(xs[i]);
217 }
218 return res;
219 }
220
221 // String.prototype.substr - negative index don't work in IE8
222 var substr = 'ab'.substr(-1) === 'b'
223 ? function (str, start, len) { return str.substr(start, len) }
224 : function (str, start, len) {
225 if (start < 0) start = str.length + start;
226 return str.substr(start, len);
227 }
228 ;
229
230 }).call(this,require('_process'))
231 },{"_process":3}],3:[function(require,module,exports){
232 // shim for using process in browser
233
234 var process = module.exports = {};
235 var queue = [];
236 var draining = false;
237 var currentQueue;
238 var queueIndex = -1;
239
240 function cleanUpNextTick() {
241 draining = false;
242 if (currentQueue.length) {
243 queue = currentQueue.concat(queue);
244 } else {
245 queueIndex = -1;
246 }
247 if (queue.length) {
248 drainQueue();
249 }
250 }
251
252 function drainQueue() {
253 if (draining) {
254 return;
255 }
256 var timeout = setTimeout(cleanUpNextTick);
257 draining = true;
258
259 var len = queue.length;
260 while(len) {
261 currentQueue = queue;
262 queue = [];
263 while (++queueIndex < len) {
264 if (currentQueue) {
265 currentQueue[queueIndex].run();
266 }
267 }
268 queueIndex = -1;
269 len = queue.length;
270 }
271 currentQueue = null;
272 draining = false;
273 clearTimeout(timeout);
274 }
275
276 process.nextTick = function (fun) {
277 var args = new Array(arguments.length - 1);
278 if (arguments.length > 1) {
279 for (var i = 1; i < arguments.length; i++) {
280 args[i - 1] = arguments[i];
281 }
282 }
283 queue.push(new Item(fun, args));
284 if (queue.length === 1 && !draining) {
285 setTimeout(drainQueue, 0);
286 }
287 };
288
289 // v8 likes predictible objects
290 function Item(fun, array) {
291 this.fun = fun;
292 this.array = array;
293 }
294 Item.prototype.run = function () {
295 this.fun.apply(null, this.array);
296 };
297 process.title = 'browser';
298 process.browser = true;
299 process.env = {};
300 process.argv = [];
301 process.version = ''; // empty string to avoid regexp issues
302 process.versions = {};
303
304 function noop() {}
305
306 process.on = noop;
307 process.addListener = noop;
308 process.once = noop;
309 process.off = noop;
310 process.removeListener = noop;
311 process.removeAllListeners = noop;
312 process.emit = noop;
313
314 process.binding = function (name) {
315 throw new Error('process.binding is not supported');
316 };
317
318 process.cwd = function () { return '/' };
319 process.chdir = function (dir) {
320 throw new Error('process.chdir is not supported');
321 };
322 process.umask = function() { return 0; };
323
324 },{}],4:[function(require,module,exports){
325 //This is for browserify to build the required CSS module into something we can use in the browser.
326 window.css = require('css');
327
328 },{"css":5}],5:[function(require,module,exports){
329 exports.parse = require('./lib/parse');
330 exports.stringify = require('./lib/stringify');
331
332 },{"./lib/parse":6,"./lib/stringify":10}],6:[function(require,module,exports){
333 // http://www.w3.org/TR/CSS21/grammar.html
334 // https://github.com/visionmedia/css-parse/pull/49#issuecomment-30088027
335 var commentre = /\/\*[^*]*\*+([^/*][^*]*\*+)*\//g
336
337 module.exports = function(css, options){
338 options = options || {};
339
340 /**
341 * Positional.
342 */
343
344 var lineno = 1;
345 var column = 1;
346
347 /**
348 * Update lineno and column based on `str`.
349 */
350
351 function updatePosition(str) {
352 var lines = str.match(/\n/g);
353 if (lines) lineno += lines.length;
354 var i = str.lastIndexOf('\n');
355 column = ~i ? str.length - i : column + str.length;
356 }
357
358 /**
359 * Mark position and patch `node.position`.
360 */
361
362 function position() {
363 var start = { line: lineno, column: column };
364 return function(node){
365 node.position = new Position(start);
366 whitespace();
367 return node;
368 };
369 }
370
371 /**
372 * Store position information for a node
373 */
374
375 function Position(start) {
376 this.start = start;
377 this.end = { line: lineno, column: column };
378 this.source = options.source;
379 }
380
381 /**
382 * Non-enumerable source string
383 */
384
385 Position.prototype.content = css;
386
387 /**
388 * Error `msg`.
389 */
390
391 var errorsList = [];
392
393 function error(msg) {
394 var err = new Error(options.source + ':' + lineno + ':' + column + ': ' + msg);
395 err.reason = msg;
396 err.filename = options.source;
397 err.line = lineno;
398 err.column = column;
399 err.source = css;
400
401 if (options.silent) {
402 errorsList.push(err);
403 } else {
404 throw err;
405 }
406 }
407
408 /**
409 * Parse stylesheet.
410 */
411
412 function stylesheet() {
413 var rulesList = rules();
414
415 return {
416 type: 'stylesheet',
417 stylesheet: {
418 rules: rulesList,
419 parsingErrors: errorsList
420 }
421 };
422 }
423
424 /**
425 * Opening brace.
426 */
427
428 function open() {
429 return match(/^{\s*/);
430 }
431
432 /**
433 * Closing brace.
434 */
435
436 function close() {
437 return match(/^}/);
438 }
439
440 /**
441 * Parse ruleset.
442 */
443
444 function rules() {
445 var node;
446 var rules = [];
447 whitespace();
448 comments(rules);
449 while (css.length && css.charAt(0) != '}' && (node = atrule() || rule())) {
450 if (node !== false) {
451 rules.push(node);
452 comments(rules);
453 }
454 }
455 return rules;
456 }
457
458 /**
459 * Match `re` and return captures.
460 */
461
462 function match(re) {
463 var m = re.exec(css);
464 if (!m) return;
465 var str = m[0];
466 updatePosition(str);
467 css = css.slice(str.length);
468 return m;
469 }
470
471 /**
472 * Parse whitespace.
473 */
474
475 function whitespace() {
476 match(/^\s*/);
477 }
478
479 /**
480 * Parse comments;
481 */
482
483 function comments(rules) {
484 var c;
485 rules = rules || [];
486 while (c = comment()) {
487 if (c !== false) {
488 rules.push(c);
489 }
490 }
491 return rules;
492 }
493
494 /**
495 * Parse comment.
496 */
497
498 function comment() {
499 var pos = position();
500 if ('/' != css.charAt(0) || '*' != css.charAt(1)) return;
501
502 var i = 2;
503 while ("" != css.charAt(i) && ('*' != css.charAt(i) || '/' != css.charAt(i + 1))) ++i;
504 i += 2;
505
506 if ("" === css.charAt(i-1)) {
507 return error('End of comment missing');
508 }
509
510 var str = css.slice(2, i - 2);
511 column += 2;
512 updatePosition(str);
513 css = css.slice(i);
514 column += 2;
515
516 return pos({
517 type: 'comment',
518 comment: str
519 });
520 }
521
522 /**
523 * Parse selector.
524 */
525
526 function selector() {
527 var m = match(/^([^{]+)/);
528 if (!m) return;
529 /* @fix Remove all comments from selectors
530 * http://ostermiller.org/findcomment.html */
531 return trim(m[0])
532 .replace(/\/\*([^*]|[\r\n]|(\*+([^*/]|[\r\n])))*\*\/+/g, '')
533 .replace(/"(?:\\"|[^"])*"|'(?:\\'|[^'])*'/g, function(m) {
534 return m.replace(/,/g, '\u200C');
535 })
536 .split(/\s*(?![^(]*\)),\s*/)
537 .map(function(s) {
538 return s.replace(/\u200C/g, ',');
539 });
540 }
541
542 /**
543 * Parse declaration.
544 */
545
546 function declaration() {
547 var pos = position();
548
549 // prop
550 var prop = match(/^(\*?[-#\/\*\\\w]+(\[[0-9a-z_-]+\])?)\s*/);
551 if (!prop) return;
552 prop = trim(prop[0]);
553
554 // :
555 if (!match(/^:\s*/)) return error("property missing ':'");
556
557 // val
558 var val = match(/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^\)]*?\)|[^};])+)/);
559
560 var ret = pos({
561 type: 'declaration',
562 property: prop.replace(commentre, ''),
563 value: val ? trim(val[0]).replace(commentre, '') : ''
564 });
565
566 // ;
567 match(/^[;\s]*/);
568
569 return ret;
570 }
571
572 /**
573 * Parse declarations.
574 */
575
576 function declarations() {
577 var decls = [];
578
579 if (!open()) return error("missing '{'");
580 comments(decls);
581
582 // declarations
583 var decl;
584 while (decl = declaration()) {
585 if (decl !== false) {
586 decls.push(decl);
587 comments(decls);
588 }
589 }
590
591 if (!close()) return error("missing '}'");
592 return decls;
593 }
594
595 /**
596 * Parse keyframe.
597 */
598
599 function keyframe() {
600 var m;
601 var vals = [];
602 var pos = position();
603
604 while (m = match(/^((\d+\.\d+|\.\d+|\d+)%?|[a-z]+)\s*/)) {
605 vals.push(m[1]);
606 match(/^,\s*/);
607 }
608
609 if (!vals.length) return;
610
611 return pos({
612 type: 'keyframe',
613 values: vals,
614 declarations: declarations()
615 });
616 }
617
618 /**
619 * Parse keyframes.
620 */
621
622 function atkeyframes() {
623 var pos = position();
624 var m = match(/^@([-\w]+)?keyframes\s*/);
625
626 if (!m) return;
627 var vendor = m[1];
628
629 // identifier
630 var m = match(/^([-\w]+)\s*/);
631 if (!m) return error("@keyframes missing name");
632 var name = m[1];
633
634 if (!open()) return error("@keyframes missing '{'");
635
636 var frame;
637 var frames = comments();
638 while (frame = keyframe()) {
639 frames.push(frame);
640 frames = frames.concat(comments());
641 }
642
643 if (!close()) return error("@keyframes missing '}'");
644
645 return pos({
646 type: 'keyframes',
647 name: name,
648 vendor: vendor,
649 keyframes: frames
650 });
651 }
652
653 /**
654 * Parse supports.
655 */
656
657 function atsupports() {
658 var pos = position();
659 var m = match(/^@supports *([^{]+)/);
660
661 if (!m) return;
662 var supports = trim(m[1]);
663
664 if (!open()) return error("@supports missing '{'");
665
666 var style = comments().concat(rules());
667
668 if (!close()) return error("@supports missing '}'");
669
670 return pos({
671 type: 'supports',
672 supports: supports,
673 rules: style
674 });
675 }
676
677 /**
678 * Parse host.
679 */
680
681 function athost() {
682 var pos = position();
683 var m = match(/^@host\s*/);
684
685 if (!m) return;
686
687 if (!open()) return error("@host missing '{'");
688
689 var style = comments().concat(rules());
690
691 if (!close()) return error("@host missing '}'");
692
693 return pos({
694 type: 'host',
695 rules: style
696 });
697 }
698
699 /**
700 * Parse media.
701 */
702
703 function atmedia() {
704 var pos = position();
705 var m = match(/^@media *([^{]+)/);
706
707 if (!m) return;
708 var media = trim(m[1]);
709
710 if (!open()) return error("@media missing '{'");
711
712 var style = comments().concat(rules());
713
714 if (!close()) return error("@media missing '}'");
715
716 return pos({
717 type: 'media',
718 media: media,
719 rules: style
720 });
721 }
722
723
724 /**
725 * Parse custom-media.
726 */
727
728 function atcustommedia() {
729 var pos = position();
730 var m = match(/^@custom-media\s+(--[^\s]+)\s*([^{;]+);/);
731 if (!m) return;
732
733 return pos({
734 type: 'custom-media',
735 name: trim(m[1]),
736 media: trim(m[2])
737 });
738 }
739
740 /**
741 * Parse paged media.
742 */
743
744 function atpage() {
745 var pos = position();
746 var m = match(/^@page */);
747 if (!m) return;
748
749 var sel = selector() || [];
750
751 if (!open()) return error("@page missing '{'");
752 var decls = comments();
753
754 // declarations
755 var decl;
756 while (decl = declaration()) {
757 decls.push(decl);
758 decls = decls.concat(comments());
759 }
760
761 if (!close()) return error("@page missing '}'");
762
763 return pos({
764 type: 'page',
765 selectors: sel,
766 declarations: decls
767 });
768 }
769
770 /**
771 * Parse document.
772 */
773
774 function atdocument() {
775 var pos = position();
776 var m = match(/^@([-\w]+)?document *([^{]+)/);
777 if (!m) return;
778
779 var vendor = trim(m[1]);
780 var doc = trim(m[2]);
781
782 if (!open()) return error("@document missing '{'");
783
784 var style = comments().concat(rules());
785
786 if (!close()) return error("@document missing '}'");
787
788 return pos({
789 type: 'document',
790 document: doc,
791 vendor: vendor,
792 rules: style
793 });
794 }
795
796 /**
797 * Parse font-face.
798 */
799
800 function atfontface() {
801 var pos = position();
802 var m = match(/^@font-face\s*/);
803 if (!m) return;
804
805 if (!open()) return error("@font-face missing '{'");
806 var decls = comments();
807
808 // declarations
809 var decl;
810 while (decl = declaration()) {
811 decls.push(decl);
812 decls = decls.concat(comments());
813 }
814
815 if (!close()) return error("@font-face missing '}'");
816
817 return pos({
818 type: 'font-face',
819 declarations: decls
820 });
821 }
822
823 /**
824 * Parse import
825 */
826
827 var atimport = _compileAtrule('import');
828
829 /**
830 * Parse charset
831 */
832
833 var atcharset = _compileAtrule('charset');
834
835 /**
836 * Parse namespace
837 */
838
839 var atnamespace = _compileAtrule('namespace');
840
841 /**
842 * Parse non-block at-rules
843 */
844
845
846 function _compileAtrule(name) {
847 var re = new RegExp('^@' + name + '\\s*([^;]+);');
848 return function() {
849 var pos = position();
850 var m = match(re);
851 if (!m) return;
852 var ret = { type: name };
853 ret[name] = m[1].trim();
854 return pos(ret);
855 }
856 }
857
858 /**
859 * Parse at rule.
860 */
861
862 function atrule() {
863 if (css[0] != '@') return;
864
865 return atkeyframes()
866 || atmedia()
867 || atcustommedia()
868 || atsupports()
869 || atimport()
870 || atcharset()
871 || atnamespace()
872 || atdocument()
873 || atpage()
874 || athost()
875 || atfontface();
876 }
877
878 /**
879 * Parse rule.
880 */
881
882 function rule() {
883 var pos = position();
884 var sel = selector();
885
886 if (!sel) return error('selector missing');
887 comments();
888
889 return pos({
890 type: 'rule',
891 selectors: sel,
892 declarations: declarations()
893 });
894 }
895
896 return addParent(stylesheet());
897 };
898
899 /**
900 * Trim `str`.
901 */
902
903 function trim(str) {
904 return str ? str.replace(/^\s+|\s+$/g, '') : '';
905 }
906
907 /**
908 * Adds non-enumerable parent node reference to each node.
909 */
910
911 function addParent(obj, parent) {
912 var isNode = obj && typeof obj.type === 'string';
913 var childParent = isNode ? obj : parent;
914
915 for (var k in obj) {
916 var value = obj[k];
917 if (Array.isArray(value)) {
918 value.forEach(function(v) { addParent(v, childParent); });
919 } else if (value && typeof value === 'object') {
920 addParent(value, childParent);
921 }
922 }
923
924 if (isNode) {
925 Object.defineProperty(obj, 'parent', {
926 configurable: true,
927 writable: true,
928 enumerable: false,
929 value: parent || null
930 });
931 }
932
933 return obj;
934 }
935
936 },{}],7:[function(require,module,exports){
937
938 /**
939 * Expose `Compiler`.
940 */
941
942 module.exports = Compiler;
943
944 /**
945 * Initialize a compiler.
946 *
947 * @param {Type} name
948 * @return {Type}
949 * @api public
950 */
951
952 function Compiler(opts) {
953 this.options = opts || {};
954 }
955
956 /**
957 * Emit `str`
958 */
959
960 Compiler.prototype.emit = function(str) {
961 return str;
962 };
963
964 /**
965 * Visit `node`.
966 */
967
968 Compiler.prototype.visit = function(node){
969 return this[node.type](node);
970 };
971
972 /**
973 * Map visit over array of `nodes`, optionally using a `delim`
974 */
975
976 Compiler.prototype.mapVisit = function(nodes, delim){
977 var buf = '';
978 delim = delim || '';
979
980 for (var i = 0, length = nodes.length; i < length; i++) {
981 buf += this.visit(nodes[i]);
982 if (delim && i < length - 1) buf += this.emit(delim);
983 }
984
985 return buf;
986 };
987
988 },{}],8:[function(require,module,exports){
989
990 /**
991 * Module dependencies.
992 */
993
994 var Base = require('./compiler');
995 var inherits = require('inherits');
996
997 /**
998 * Expose compiler.
999 */
1000
1001 module.exports = Compiler;
1002
1003 /**
1004 * Initialize a new `Compiler`.
1005 */
1006
1007 function Compiler(options) {
1008 Base.call(this, options);
1009 }
1010
1011 /**
1012 * Inherit from `Base.prototype`.
1013 */
1014
1015 inherits(Compiler, Base);
1016
1017 /**
1018 * Compile `node`.
1019 */
1020
1021 Compiler.prototype.compile = function(node){
1022 return node.stylesheet
1023 .rules.map(this.visit, this)
1024 .join('');
1025 };
1026
1027 /**
1028 * Visit comment node.
1029 */
1030
1031 Compiler.prototype.comment = function(node){
1032 return this.emit('', node.position);
1033 };
1034
1035 /**
1036 * Visit import node.
1037 */
1038
1039 Compiler.prototype.import = function(node){
1040 return this.emit('@import ' + node.import + ';', node.position);
1041 };
1042
1043 /**
1044 * Visit media node.
1045 */
1046
1047 Compiler.prototype.media = function(node){
1048 return this.emit('@media ' + node.media, node.position)
1049 + this.emit('{')
1050 + this.mapVisit(node.rules)
1051 + this.emit('}');
1052 };
1053
1054 /**
1055 * Visit document node.
1056 */
1057
1058 Compiler.prototype.document = function(node){
1059 var doc = '@' + (node.vendor || '') + 'document ' + node.document;
1060
1061 return this.emit(doc, node.position)
1062 + this.emit('{')
1063 + this.mapVisit(node.rules)
1064 + this.emit('}');
1065 };
1066
1067 /**
1068 * Visit charset node.
1069 */
1070
1071 Compiler.prototype.charset = function(node){
1072 return this.emit('@charset ' + node.charset + ';', node.position);
1073 };
1074
1075 /**
1076 * Visit namespace node.
1077 */
1078
1079 Compiler.prototype.namespace = function(node){
1080 return this.emit('@namespace ' + node.namespace + ';', node.position);
1081 };
1082
1083 /**
1084 * Visit supports node.
1085 */
1086
1087 Compiler.prototype.supports = function(node){
1088 return this.emit('@supports ' + node.supports, node.position)
1089 + this.emit('{')
1090 + this.mapVisit(node.rules)
1091 + this.emit('}');
1092 };
1093
1094 /**
1095 * Visit keyframes node.
1096 */
1097
1098 Compiler.prototype.keyframes = function(node){
1099 return this.emit('@'
1100 + (node.vendor || '')
1101 + 'keyframes '
1102 + node.name, node.position)
1103 + this.emit('{')
1104 + this.mapVisit(node.keyframes)
1105 + this.emit('}');
1106 };
1107
1108 /**
1109 * Visit keyframe node.
1110 */
1111
1112 Compiler.prototype.keyframe = function(node){
1113 var decls = node.declarations;
1114
1115 return this.emit(node.values.join(','), node.position)
1116 + this.emit('{')
1117 + this.mapVisit(decls)
1118 + this.emit('}');
1119 };
1120
1121 /**
1122 * Visit page node.
1123 */
1124
1125 Compiler.prototype.page = function(node){
1126 var sel = node.selectors.length
1127 ? node.selectors.join(', ')
1128 : '';
1129
1130 return this.emit('@page ' + sel, node.position)
1131 + this.emit('{')
1132 + this.mapVisit(node.declarations)
1133 + this.emit('}');
1134 };
1135
1136 /**
1137 * Visit font-face node.
1138 */
1139
1140 Compiler.prototype['font-face'] = function(node){
1141 return this.emit('@font-face', node.position)
1142 + this.emit('{')
1143 + this.mapVisit(node.declarations)
1144 + this.emit('}');
1145 };
1146
1147 /**
1148 * Visit host node.
1149 */
1150
1151 Compiler.prototype.host = function(node){
1152 return this.emit('@host', node.position)
1153 + this.emit('{')
1154 + this.mapVisit(node.rules)
1155 + this.emit('}');
1156 };
1157
1158 /**
1159 * Visit custom-media node.
1160 */
1161
1162 Compiler.prototype['custom-media'] = function(node){
1163 return this.emit('@custom-media ' + node.name + ' ' + node.media + ';', node.position);
1164 };
1165
1166 /**
1167 * Visit rule node.
1168 */
1169
1170 Compiler.prototype.rule = function(node){
1171 var decls = node.declarations;
1172 if (!decls.length) return '';
1173
1174 return this.emit(node.selectors.join(','), node.position)
1175 + this.emit('{')
1176 + this.mapVisit(decls)
1177 + this.emit('}');
1178 };
1179
1180 /**
1181 * Visit declaration node.
1182 */
1183
1184 Compiler.prototype.declaration = function(node){
1185 return this.emit(node.property + ':' + node.value, node.position) + this.emit(';');
1186 };
1187
1188
1189 },{"./compiler":7,"inherits":12}],9:[function(require,module,exports){
1190
1191 /**
1192 * Module dependencies.
1193 */
1194
1195 var Base = require('./compiler');
1196 var inherits = require('inherits');
1197
1198 /**
1199 * Expose compiler.
1200 */
1201
1202 module.exports = Compiler;
1203
1204 /**
1205 * Initialize a new `Compiler`.
1206 */
1207
1208 function Compiler(options) {
1209 options = options || {};
1210 Base.call(this, options);
1211 this.indentation = options.indent;
1212 }
1213
1214 /**
1215 * Inherit from `Base.prototype`.
1216 */
1217
1218 inherits(Compiler, Base);
1219
1220 /**
1221 * Compile `node`.
1222 */
1223
1224 Compiler.prototype.compile = function(node){
1225 return this.stylesheet(node);
1226 };
1227
1228 /**
1229 * Visit stylesheet node.
1230 */
1231
1232 Compiler.prototype.stylesheet = function(node){
1233 return this.mapVisit(node.stylesheet.rules, '\n\n');
1234 };
1235
1236 /**
1237 * Visit comment node.
1238 */
1239
1240 Compiler.prototype.comment = function(node){
1241 return this.emit(this.indent() + '/*' + node.comment + '*/', node.position);
1242 };
1243
1244 /**
1245 * Visit import node.
1246 */
1247
1248 Compiler.prototype.import = function(node){
1249 return this.emit('@import ' + node.import + ';', node.position);
1250 };
1251
1252 /**
1253 * Visit media node.
1254 */
1255
1256 Compiler.prototype.media = function(node){
1257 return this.emit('@media ' + node.media, node.position)
1258 + this.emit(
1259 ' {\n'
1260 + this.indent(1))
1261 + this.mapVisit(node.rules, '\n\n')
1262 + this.emit(
1263 this.indent(-1)
1264 + '\n}');
1265 };
1266
1267 /**
1268 * Visit document node.
1269 */
1270
1271 Compiler.prototype.document = function(node){
1272 var doc = '@' + (node.vendor || '') + 'document ' + node.document;
1273
1274 return this.emit(doc, node.position)
1275 + this.emit(
1276 ' '
1277 + ' {\n'
1278 + this.indent(1))
1279 + this.mapVisit(node.rules, '\n\n')
1280 + this.emit(
1281 this.indent(-1)
1282 + '\n}');
1283 };
1284
1285 /**
1286 * Visit charset node.
1287 */
1288
1289 Compiler.prototype.charset = function(node){
1290 return this.emit('@charset ' + node.charset + ';', node.position);
1291 };
1292
1293 /**
1294 * Visit namespace node.
1295 */
1296
1297 Compiler.prototype.namespace = function(node){
1298 return this.emit('@namespace ' + node.namespace + ';', node.position);
1299 };
1300
1301 /**
1302 * Visit supports node.
1303 */
1304
1305 Compiler.prototype.supports = function(node){
1306 return this.emit('@supports ' + node.supports, node.position)
1307 + this.emit(
1308 ' {\n'
1309 + this.indent(1))
1310 + this.mapVisit(node.rules, '\n\n')
1311 + this.emit(
1312 this.indent(-1)
1313 + '\n}');
1314 };
1315
1316 /**
1317 * Visit keyframes node.
1318 */
1319
1320 Compiler.prototype.keyframes = function(node){
1321 return this.emit('@' + (node.vendor || '') + 'keyframes ' + node.name, node.position)
1322 + this.emit(
1323 ' {\n'
1324 + this.indent(1))
1325 + this.mapVisit(node.keyframes, '\n')
1326 + this.emit(
1327 this.indent(-1)
1328 + '}');
1329 };
1330
1331 /**
1332 * Visit keyframe node.
1333 */
1334
1335 Compiler.prototype.keyframe = function(node){
1336 var decls = node.declarations;
1337
1338 return this.emit(this.indent())
1339 + this.emit(node.values.join(', '), node.position)
1340 + this.emit(
1341 ' {\n'
1342 + this.indent(1))
1343 + this.mapVisit(decls, '\n')
1344 + this.emit(
1345 this.indent(-1)
1346 + '\n'
1347 + this.indent() + '}\n');
1348 };
1349
1350 /**
1351 * Visit page node.
1352 */
1353
1354 Compiler.prototype.page = function(node){
1355 var sel = node.selectors.length
1356 ? node.selectors.join(', ') + ' '
1357 : '';
1358
1359 return this.emit('@page ' + sel, node.position)
1360 + this.emit('{\n')
1361 + this.emit(this.indent(1))
1362 + this.mapVisit(node.declarations, '\n')
1363 + this.emit(this.indent(-1))
1364 + this.emit('\n}');
1365 };
1366
1367 /**
1368 * Visit font-face node.
1369 */
1370
1371 Compiler.prototype['font-face'] = function(node){
1372 return this.emit('@font-face ', node.position)
1373 + this.emit('{\n')
1374 + this.emit(this.indent(1))
1375 + this.mapVisit(node.declarations, '\n')
1376 + this.emit(this.indent(-1))
1377 + this.emit('\n}');
1378 };
1379
1380 /**
1381 * Visit host node.
1382 */
1383
1384 Compiler.prototype.host = function(node){
1385 return this.emit('@host', node.position)
1386 + this.emit(
1387 ' {\n'
1388 + this.indent(1))
1389 + this.mapVisit(node.rules, '\n\n')
1390 + this.emit(
1391 this.indent(-1)
1392 + '\n}');
1393 };
1394
1395 /**
1396 * Visit custom-media node.
1397 */
1398
1399 Compiler.prototype['custom-media'] = function(node){
1400 return this.emit('@custom-media ' + node.name + ' ' + node.media + ';', node.position);
1401 };
1402
1403 /**
1404 * Visit rule node.
1405 */
1406
1407 Compiler.prototype.rule = function(node){
1408 var indent = this.indent();
1409 var decls = node.declarations;
1410 if (!decls.length) return '';
1411
1412 return this.emit(node.selectors.map(function(s){ return indent + s }).join(',\n'), node.position)
1413 + this.emit(' {\n')
1414 + this.emit(this.indent(1))
1415 + this.mapVisit(decls, '\n')
1416 + this.emit(this.indent(-1))
1417 + this.emit('\n' + this.indent() + '}');
1418 };
1419
1420 /**
1421 * Visit declaration node.
1422 */
1423
1424 Compiler.prototype.declaration = function(node){
1425 return this.emit(this.indent())
1426 + this.emit(node.property + ': ' + node.value, node.position)
1427 + this.emit(';');
1428 };
1429
1430 /**
1431 * Increase, decrease or return current indentation.
1432 */
1433
1434 Compiler.prototype.indent = function(level) {
1435 this.level = this.level || 1;
1436
1437 if (null != level) {
1438 this.level += level;
1439 return '';
1440 }
1441
1442 return Array(this.level).join(this.indentation || ' ');
1443 };
1444
1445 },{"./compiler":7,"inherits":12}],10:[function(require,module,exports){
1446
1447 /**
1448 * Module dependencies.
1449 */
1450
1451 var Compressed = require('./compress');
1452 var Identity = require('./identity');
1453
1454 /**
1455 * Stringfy the given AST `node`.
1456 *
1457 * Options:
1458 *
1459 * - `compress` space-optimized output
1460 * - `sourcemap` return an object with `.code` and `.map`
1461 *
1462 * @param {Object} node
1463 * @param {Object} [options]
1464 * @return {String}
1465 * @api public
1466 */
1467
1468 module.exports = function(node, options){
1469 options = options || {};
1470
1471 var compiler = options.compress
1472 ? new Compressed(options)
1473 : new Identity(options);
1474
1475 // source maps
1476 if (options.sourcemap) {
1477 var sourcemaps = require('./source-map-support');
1478 sourcemaps(compiler);
1479
1480 var code = compiler.compile(node);
1481 compiler.applySourceMaps();
1482
1483 var map = options.sourcemap === 'generator'
1484 ? compiler.map
1485 : compiler.map.toJSON();
1486
1487 return { code: code, map: map };
1488 }
1489
1490 var code = compiler.compile(node);
1491 return code;
1492 };
1493
1494 },{"./compress":8,"./identity":9,"./source-map-support":11}],11:[function(require,module,exports){
1495
1496 /**
1497 * Module dependencies.
1498 */
1499
1500 var SourceMap = require('source-map').SourceMapGenerator;
1501 var SourceMapConsumer = require('source-map').SourceMapConsumer;
1502 var sourceMapResolve = require('source-map-resolve');
1503 var urix = require('urix');
1504 var fs = require('fs');
1505 var path = require('path');
1506
1507 /**
1508 * Expose `mixin()`.
1509 */
1510
1511 module.exports = mixin;
1512
1513 /**
1514 * Mixin source map support into `compiler`.
1515 *
1516 * @param {Compiler} compiler
1517 * @api public
1518 */
1519
1520 function mixin(compiler) {
1521 compiler._comment = compiler.comment;
1522 compiler.map = new SourceMap();
1523 compiler.position = { line: 1, column: 1 };
1524 compiler.files = {};
1525 for (var k in exports) compiler[k] = exports[k];
1526 }
1527
1528 /**
1529 * Update position.
1530 *
1531 * @param {String} str
1532 * @api private
1533 */
1534
1535 exports.updatePosition = function(str) {
1536 var lines = str.match(/\n/g);
1537 if (lines) this.position.line += lines.length;
1538 var i = str.lastIndexOf('\n');
1539 this.position.column = ~i ? str.length - i : this.position.column + str.length;
1540 };
1541
1542 /**
1543 * Emit `str`.
1544 *
1545 * @param {String} str
1546 * @param {Object} [pos]
1547 * @return {String}
1548 * @api private
1549 */
1550
1551 exports.emit = function(str, pos) {
1552 if (pos) {
1553 var sourceFile = urix(pos.source || 'source.css');
1554
1555 this.map.addMapping({
1556 source: sourceFile,
1557 generated: {
1558 line: this.position.line,
1559 column: Math.max(this.position.column - 1, 0)
1560 },
1561 original: {
1562 line: pos.start.line,
1563 column: pos.start.column - 1
1564 }
1565 });
1566
1567 this.addFile(sourceFile, pos);
1568 }
1569
1570 this.updatePosition(str);
1571
1572 return str;
1573 };
1574
1575 /**
1576 * Adds a file to the source map output if it has not already been added
1577 * @param {String} file
1578 * @param {Object} pos
1579 */
1580
1581 exports.addFile = function(file, pos) {
1582 if (typeof pos.content !== 'string') return;
1583 if (Object.prototype.hasOwnProperty.call(this.files, file)) return;
1584
1585 this.files[file] = pos.content;
1586 };
1587
1588 /**
1589 * Applies any original source maps to the output and embeds the source file
1590 * contents in the source map.
1591 */
1592
1593 exports.applySourceMaps = function() {
1594 Object.keys(this.files).forEach(function(file) {
1595 var content = this.files[file];
1596 this.map.setSourceContent(file, content);
1597
1598 if (this.options.inputSourcemaps !== false) {
1599 var originalMap = sourceMapResolve.resolveSync(
1600 content, file, fs.readFileSync);
1601 if (originalMap) {
1602 var map = new SourceMapConsumer(originalMap.map);
1603 var relativeTo = originalMap.sourcesRelativeTo;
1604 this.map.applySourceMap(map, file, urix(path.dirname(relativeTo)));
1605 }
1606 }
1607 }, this);
1608 };
1609
1610 /**
1611 * Process comments, drops sourceMap comments.
1612 * @param {Object} node
1613 */
1614
1615 exports.comment = function(node) {
1616 if (/^# sourceMappingURL=/.test(node.comment))
1617 return this.emit('', node.position);
1618 else
1619 return this._comment(node);
1620 };
1621
1622 },{"fs":1,"path":2,"source-map":16,"source-map-resolve":15,"urix":27}],12:[function(require,module,exports){
1623 if (typeof Object.create === 'function') {
1624 // implementation from standard node.js 'util' module
1625 module.exports = function inherits(ctor, superCtor) {
1626 ctor.super_ = superCtor
1627 ctor.prototype = Object.create(superCtor.prototype, {
1628 constructor: {
1629 value: ctor,
1630 enumerable: false,
1631 writable: true,
1632 configurable: true
1633 }
1634 });
1635 };
1636 } else {
1637 // old school shim for old browsers
1638 module.exports = function inherits(ctor, superCtor) {
1639 ctor.super_ = superCtor
1640 var TempCtor = function () {}
1641 TempCtor.prototype = superCtor.prototype
1642 ctor.prototype = new TempCtor()
1643 ctor.prototype.constructor = ctor
1644 }
1645 }
1646
1647 },{}],13:[function(require,module,exports){
1648 // Copyright 2014 Simon Lydell
1649 // X11 (“MIT”) Licensed. (See LICENSE.)
1650
1651 void (function(root, factory) {
1652 if (typeof define === "function" && define.amd) {
1653 define(factory)
1654 } else if (typeof exports === "object") {
1655 module.exports = factory()
1656 } else {
1657 root.resolveUrl = factory()
1658 }
1659 }(this, function() {
1660
1661 function resolveUrl(/* ...urls */) {
1662 var numUrls = arguments.length
1663
1664 if (numUrls === 0) {
1665 throw new Error("resolveUrl requires at least one argument; got none.")
1666 }
1667
1668 var base = document.createElement("base")
1669 base.href = arguments[0]
1670
1671 if (numUrls === 1) {
1672 return base.href
1673 }
1674
1675 var head = document.getElementsByTagName("head")[0]
1676 head.insertBefore(base, head.firstChild)
1677
1678 var a = document.createElement("a")
1679 var resolved
1680
1681 for (var index = 1; index < numUrls; index++) {
1682 a.href = arguments[index]
1683 resolved = a.href
1684 base.href = resolved
1685 }
1686
1687 head.removeChild(base)
1688
1689 return resolved
1690 }
1691
1692 return resolveUrl
1693
1694 }));
1695
1696 },{}],14:[function(require,module,exports){
1697 // Copyright 2014 Simon Lydell
1698 // X11 (“MIT”) Licensed. (See LICENSE.)
1699
1700 void (function(root, factory) {
1701 if (typeof define === "function" && define.amd) {
1702 define(factory)
1703 } else if (typeof exports === "object") {
1704 module.exports = factory()
1705 } else {
1706 root.sourceMappingURL = factory()
1707 }
1708 }(this, function() {
1709
1710 var innerRegex = /[#@] sourceMappingURL=([^\s'"]*)/
1711
1712 var regex = RegExp(
1713 "(?:" +
1714 "/\\*" +
1715 "(?:\\s*\r?\n(?://)?)?" +
1716 "(?:" + innerRegex.source + ")" +
1717 "\\s*" +
1718 "\\*/" +
1719 "|" +
1720 "//(?:" + innerRegex.source + ")" +
1721 ")" +
1722 "\\s*$"
1723 )
1724
1725 return {
1726
1727 regex: regex,
1728 _innerRegex: innerRegex,
1729
1730 getFrom: function(code) {
1731 var match = code.match(regex)
1732 return (match ? match[1] || match[2] || "" : null)
1733 },
1734
1735 existsIn: function(code) {
1736 return regex.test(code)
1737 },
1738
1739 removeFrom: function(code) {
1740 return code.replace(regex, "")
1741 },
1742
1743 insertBefore: function(code, string) {
1744 var match = code.match(regex)
1745 if (match) {
1746 return code.slice(0, match.index) + string + code.slice(match.index)
1747 } else {
1748 return code + string
1749 }
1750 }
1751 }
1752
1753 }));
1754
1755 },{}],15:[function(require,module,exports){
1756 // Copyright 2014 Simon Lydell
1757 // X11 (“MIT”) Licensed. (See LICENSE.)
1758
1759 // Note: source-map-resolve.js is generated from source-map-resolve-node.js and
1760 // source-map-resolve-template.js. Only edit the two latter files, _not_
1761 // source-map-resolve.js!
1762
1763 void (function(root, factory) {
1764 if (typeof define === "function" && define.amd) {
1765 define(["source-map-url", "resolve-url"], factory)
1766 } else if (typeof exports === "object") {
1767 var sourceMappingURL = require("source-map-url")
1768 var resolveUrl = require("resolve-url")
1769 module.exports = factory(sourceMappingURL, resolveUrl)
1770 } else {
1771 root.sourceMapResolve = factory(root.sourceMappingURL, root.resolveUrl)
1772 }
1773 }(this, function(sourceMappingURL, resolveUrl) {
1774
1775 function callbackAsync(callback, error, result) {
1776 setImmediate(function() { callback(error, result) })
1777 }
1778
1779 function parseMapToJSON(string) {
1780 return JSON.parse(string.replace(/^\)\]\}'/, ""))
1781 }
1782
1783
1784
1785 function resolveSourceMap(code, codeUrl, read, callback) {
1786 var mapData
1787 try {
1788 mapData = resolveSourceMapHelper(code, codeUrl)
1789 } catch (error) {
1790 return callbackAsync(callback, error)
1791 }
1792 if (!mapData || mapData.map) {
1793 return callbackAsync(callback, null, mapData)
1794 }
1795 read(mapData.url, function(error, result) {
1796 if (error) {
1797 return callback(error)
1798 }
1799 try {
1800 mapData.map = parseMapToJSON(String(result))
1801 } catch (error) {
1802 return callback(error)
1803 }
1804 callback(null, mapData)
1805 })
1806 }
1807
1808 function resolveSourceMapSync(code, codeUrl, read) {
1809 var mapData = resolveSourceMapHelper(code, codeUrl)
1810 if (!mapData || mapData.map) {
1811 return mapData
1812 }
1813 mapData.map = parseMapToJSON(String(read(mapData.url)))
1814 return mapData
1815 }
1816
1817 var dataUriRegex = /^data:([^,;]*)(;[^,;]*)*(?:,(.*))?$/
1818 var jsonMimeTypeRegex = /^(?:application|text)\/json$/
1819
1820 function resolveSourceMapHelper(code, codeUrl) {
1821 var url = sourceMappingURL.getFrom(code)
1822 if (!url) {
1823 return null
1824 }
1825
1826 var dataUri = url.match(dataUriRegex)
1827 if (dataUri) {
1828 var mimeType = dataUri[1]
1829 var lastParameter = dataUri[2]
1830 var encoded = dataUri[3]
1831 if (!jsonMimeTypeRegex.test(mimeType)) {
1832 throw new Error("Unuseful data uri mime type: " + (mimeType || "text/plain"))
1833 }
1834 return {
1835 sourceMappingURL: url,
1836 url: null,
1837 sourcesRelativeTo: codeUrl,
1838 map: parseMapToJSON(lastParameter === ";base64" ? atob(encoded) : decodeURIComponent(encoded))
1839 }
1840 }
1841
1842 var mapUrl = resolveUrl(codeUrl, url)
1843 return {
1844 sourceMappingURL: url,
1845 url: mapUrl,
1846 sourcesRelativeTo: mapUrl,
1847 map: null
1848 }
1849 }
1850
1851
1852
1853 function resolveSources(map, mapUrl, read, options, callback) {
1854 if (typeof options === "function") {
1855 callback = options
1856 options = {}
1857 }
1858 var pending = map.sources.length
1859 var errored = false
1860 var result = {
1861 sourcesResolved: [],
1862 sourcesContent: []
1863 }
1864
1865 var done = function(error) {
1866 if (errored) {
1867 return
1868 }
1869 if (error) {
1870 errored = true
1871 return callback(error)
1872 }
1873 pending--
1874 if (pending === 0) {
1875 callback(null, result)
1876 }
1877 }
1878
1879 resolveSourcesHelper(map, mapUrl, options, function(fullUrl, sourceContent, index) {
1880 result.sourcesResolved[index] = fullUrl
1881 if (typeof sourceContent === "string") {
1882 result.sourcesContent[index] = sourceContent
1883 callbackAsync(done, null)
1884 } else {
1885 read(fullUrl, function(error, source) {
1886 result.sourcesContent[index] = String(source)
1887 done(error)
1888 })
1889 }
1890 })
1891 }
1892
1893 function resolveSourcesSync(map, mapUrl, read, options) {
1894 var result = {
1895 sourcesResolved: [],
1896 sourcesContent: []
1897 }
1898 resolveSourcesHelper(map, mapUrl, options, function(fullUrl, sourceContent, index) {
1899 result.sourcesResolved[index] = fullUrl
1900 if (read !== null) {
1901 if (typeof sourceContent === "string") {
1902 result.sourcesContent[index] = sourceContent
1903 } else {
1904 result.sourcesContent[index] = String(read(fullUrl))
1905 }
1906 }
1907 })
1908 return result
1909 }
1910
1911 var endingSlash = /\/?$/
1912
1913 function resolveSourcesHelper(map, mapUrl, options, fn) {
1914 options = options || {}
1915 var fullUrl
1916 var sourceContent
1917 for (var index = 0, len = map.sources.length; index < len; index++) {
1918 if (map.sourceRoot && !options.ignoreSourceRoot) {
1919 // Make sure that the sourceRoot ends with a slash, so that `/scripts/subdir` becomes
1920 // `/scripts/subdir/<source>`, not `/scripts/<source>`. Pointing to a file as source root
1921 // does not make sense.
1922 fullUrl = resolveUrl(mapUrl, map.sourceRoot.replace(endingSlash, "/"), map.sources[index])
1923 } else {
1924 fullUrl = resolveUrl(mapUrl, map.sources[index])
1925 }
1926 sourceContent = (map.sourcesContent || [])[index]
1927 fn(fullUrl, sourceContent, index)
1928 }
1929 }
1930
1931
1932
1933 function resolve(code, codeUrl, read, options, callback) {
1934 if (typeof options === "function") {
1935 callback = options
1936 options = {}
1937 }
1938 resolveSourceMap(code, codeUrl, read, function(error, mapData) {
1939 if (error) {
1940 return callback(error)
1941 }
1942 if (!mapData) {
1943 return callback(null, null)
1944 }
1945 resolveSources(mapData.map, mapData.sourcesRelativeTo, read, options, function(error, result) {
1946 if (error) {
1947 return callback(error)
1948 }
1949 mapData.sourcesResolved = result.sourcesResolved
1950 mapData.sourcesContent = result.sourcesContent
1951 callback(null, mapData)
1952 })
1953 })
1954 }
1955
1956 function resolveSync(code, codeUrl, read, options) {
1957 var mapData = resolveSourceMapSync(code, codeUrl, read)
1958 if (!mapData) {
1959 return null
1960 }
1961 var result = resolveSourcesSync(mapData.map, mapData.sourcesRelativeTo, read, options)
1962 mapData.sourcesResolved = result.sourcesResolved
1963 mapData.sourcesContent = result.sourcesContent
1964 return mapData
1965 }
1966
1967
1968
1969 return {
1970 resolveSourceMap: resolveSourceMap,
1971 resolveSourceMapSync: resolveSourceMapSync,
1972 resolveSources: resolveSources,
1973 resolveSourcesSync: resolveSourcesSync,
1974 resolve: resolve,
1975 resolveSync: resolveSync
1976 }
1977
1978 }));
1979
1980 },{"resolve-url":13,"source-map-url":14}],16:[function(require,module,exports){
1981 /*
1982 * Copyright 2009-2011 Mozilla Foundation and contributors
1983 * Licensed under the New BSD license. See LICENSE.txt or:
1984 * http://opensource.org/licenses/BSD-3-Clause
1985 */
1986 exports.SourceMapGenerator = require('./source-map/source-map-generator').SourceMapGenerator;
1987 exports.SourceMapConsumer = require('./source-map/source-map-consumer').SourceMapConsumer;
1988 exports.SourceNode = require('./source-map/source-node').SourceNode;
1989
1990 },{"./source-map/source-map-consumer":22,"./source-map/source-map-generator":23,"./source-map/source-node":24}],17:[function(require,module,exports){
1991 /* -*- Mode: js; js-indent-level: 2; -*- */
1992 /*
1993 * Copyright 2011 Mozilla Foundation and contributors
1994 * Licensed under the New BSD license. See LICENSE or:
1995 * http://opensource.org/licenses/BSD-3-Clause
1996 */
1997 if (typeof define !== 'function') {
1998 var define = require('amdefine')(module, require);
1999 }
2000 define(function (require, exports, module) {
2001
2002 var util = require('./util');
2003
2004 /**
2005 * A data structure which is a combination of an array and a set. Adding a new
2006 * member is O(1), testing for membership is O(1), and finding the index of an
2007 * element is O(1). Removing elements from the set is not supported. Only
2008 * strings are supported for membership.
2009 */
2010 function ArraySet() {
2011 this._array = [];
2012 this._set = {};
2013 }
2014
2015 /**
2016 * Static method for creating ArraySet instances from an existing array.
2017 */
2018 ArraySet.fromArray = function ArraySet_fromArray(aArray, aAllowDuplicates) {
2019 var set = new ArraySet();
2020 for (var i = 0, len = aArray.length; i < len; i++) {
2021 set.add(aArray[i], aAllowDuplicates);
2022 }
2023 return set;
2024 };
2025
2026 /**
2027 * Add the given string to this set.
2028 *
2029 * @param String aStr
2030 */
2031 ArraySet.prototype.add = function ArraySet_add(aStr, aAllowDuplicates) {
2032 var isDuplicate = this.has(aStr);
2033 var idx = this._array.length;
2034 if (!isDuplicate || aAllowDuplicates) {
2035 this._array.push(aStr);
2036 }
2037 if (!isDuplicate) {
2038 this._set[util.toSetString(aStr)] = idx;
2039 }
2040 };
2041
2042 /**
2043 * Is the given string a member of this set?
2044 *
2045 * @param String aStr
2046 */
2047 ArraySet.prototype.has = function ArraySet_has(aStr) {
2048 return Object.prototype.hasOwnProperty.call(this._set,
2049 util.toSetString(aStr));
2050 };
2051
2052 /**
2053 * What is the index of the given string in the array?
2054 *
2055 * @param String aStr
2056 */
2057 ArraySet.prototype.indexOf = function ArraySet_indexOf(aStr) {
2058 if (this.has(aStr)) {
2059 return this._set[util.toSetString(aStr)];
2060 }
2061 throw new Error('"' + aStr + '" is not in the set.');
2062 };
2063
2064 /**
2065 * What is the element at the given index?
2066 *
2067 * @param Number aIdx
2068 */
2069 ArraySet.prototype.at = function ArraySet_at(aIdx) {
2070 if (aIdx >= 0 && aIdx < this._array.length) {
2071 return this._array[aIdx];
2072 }
2073 throw new Error('No element indexed by ' + aIdx);
2074 };
2075
2076 /**
2077 * Returns the array representation of this set (which has the proper indices
2078 * indicated by indexOf). Note that this is a copy of the internal array used
2079 * for storing the members so that no one can mess with internal state.
2080 */
2081 ArraySet.prototype.toArray = function ArraySet_toArray() {
2082 return this._array.slice();
2083 };
2084
2085 exports.ArraySet = ArraySet;
2086
2087 });
2088
2089 },{"./util":25,"amdefine":26}],18:[function(require,module,exports){
2090 /* -*- Mode: js; js-indent-level: 2; -*- */
2091 /*
2092 * Copyright 2011 Mozilla Foundation and contributors
2093 * Licensed under the New BSD license. See LICENSE or:
2094 * http://opensource.org/licenses/BSD-3-Clause
2095 *
2096 * Based on the Base 64 VLQ implementation in Closure Compiler:
2097 * https://code.google.com/p/closure-compiler/source/browse/trunk/src/com/google/debugging/sourcemap/Base64VLQ.java
2098 *
2099 * Copyright 2011 The Closure Compiler Authors. All rights reserved.
2100 * Redistribution and use in source and binary forms, with or without
2101 * modification, are permitted provided that the following conditions are
2102 * met:
2103 *
2104 * * Redistributions of source code must retain the above copyright
2105 * notice, this list of conditions and the following disclaimer.
2106 * * Redistributions in binary form must reproduce the above
2107 * copyright notice, this list of conditions and the following
2108 * disclaimer in the documentation and/or other materials provided
2109 * with the distribution.
2110 * * Neither the name of Google Inc. nor the names of its
2111 * contributors may be used to endorse or promote products derived
2112 * from this software without specific prior written permission.
2113 *
2114 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
2115 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
2116 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
2117 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
2118 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
2119 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
2120 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
2121 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
2122 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
2123 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
2124 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2125 */
2126 if (typeof define !== 'function') {
2127 var define = require('amdefine')(module, require);
2128 }
2129 define(function (require, exports, module) {
2130
2131 var base64 = require('./base64');
2132
2133 // A single base 64 digit can contain 6 bits of data. For the base 64 variable
2134 // length quantities we use in the source map spec, the first bit is the sign,
2135 // the next four bits are the actual value, and the 6th bit is the
2136 // continuation bit. The continuation bit tells us whether there are more
2137 // digits in this value following this digit.
2138 //
2139 // Continuation
2140 // | Sign
2141 // | |
2142 // V V
2143 // 101011
2144
2145 var VLQ_BASE_SHIFT = 5;
2146
2147 // binary: 100000
2148 var VLQ_BASE = 1 << VLQ_BASE_SHIFT;
2149
2150 // binary: 011111
2151 var VLQ_BASE_MASK = VLQ_BASE - 1;
2152
2153 // binary: 100000
2154 var VLQ_CONTINUATION_BIT = VLQ_BASE;
2155
2156 /**
2157 * Converts from a two-complement value to a value where the sign bit is
2158 * placed in the least significant bit. For example, as decimals:
2159 * 1 becomes 2 (10 binary), -1 becomes 3 (11 binary)
2160 * 2 becomes 4 (100 binary), -2 becomes 5 (101 binary)
2161 */
2162 function toVLQSigned(aValue) {
2163 return aValue < 0
2164 ? ((-aValue) << 1) + 1
2165 : (aValue << 1) + 0;
2166 }
2167
2168 /**
2169 * Converts to a two-complement value from a value where the sign bit is
2170 * placed in the least significant bit. For example, as decimals:
2171 * 2 (10 binary) becomes 1, 3 (11 binary) becomes -1
2172 * 4 (100 binary) becomes 2, 5 (101 binary) becomes -2
2173 */
2174 function fromVLQSigned(aValue) {
2175 var isNegative = (aValue & 1) === 1;
2176 var shifted = aValue >> 1;
2177 return isNegative
2178 ? -shifted
2179 : shifted;
2180 }
2181
2182 /**
2183 * Returns the base 64 VLQ encoded value.
2184 */
2185 exports.encode = function base64VLQ_encode(aValue) {
2186 var encoded = "";
2187 var digit;
2188
2189 var vlq = toVLQSigned(aValue);
2190
2191 do {
2192 digit = vlq & VLQ_BASE_MASK;
2193 vlq >>>= VLQ_BASE_SHIFT;
2194 if (vlq > 0) {
2195 // There are still more digits in this value, so we must make sure the
2196 // continuation bit is marked.
2197 digit |= VLQ_CONTINUATION_BIT;
2198 }
2199 encoded += base64.encode(digit);
2200 } while (vlq > 0);
2201
2202 return encoded;
2203 };
2204
2205 /**
2206 * Decodes the next base 64 VLQ value from the given string and returns the
2207 * value and the rest of the string via the out parameter.
2208 */
2209 exports.decode = function base64VLQ_decode(aStr, aOutParam) {
2210 var i = 0;
2211 var strLen = aStr.length;
2212 var result = 0;
2213 var shift = 0;
2214 var continuation, digit;
2215
2216 do {
2217 if (i >= strLen) {
2218 throw new Error("Expected more digits in base 64 VLQ value.");
2219 }
2220 digit = base64.decode(aStr.charAt(i++));
2221 continuation = !!(digit & VLQ_CONTINUATION_BIT);
2222 digit &= VLQ_BASE_MASK;
2223 result = result + (digit << shift);
2224 shift += VLQ_BASE_SHIFT;
2225 } while (continuation);
2226
2227 aOutParam.value = fromVLQSigned(result);
2228 aOutParam.rest = aStr.slice(i);
2229 };
2230
2231 });
2232
2233 },{"./base64":19,"amdefine":26}],19:[function(require,module,exports){
2234 /* -*- Mode: js; js-indent-level: 2; -*- */
2235 /*
2236 * Copyright 2011 Mozilla Foundation and contributors
2237 * Licensed under the New BSD license. See LICENSE or:
2238 * http://opensource.org/licenses/BSD-3-Clause
2239 */
2240 if (typeof define !== 'function') {
2241 var define = require('amdefine')(module, require);
2242 }
2243 define(function (require, exports, module) {
2244
2245 var charToIntMap = {};
2246 var intToCharMap = {};
2247
2248 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'
2249 .split('')
2250 .forEach(function (ch, index) {
2251 charToIntMap[ch] = index;
2252 intToCharMap[index] = ch;
2253 });
2254
2255 /**
2256 * Encode an integer in the range of 0 to 63 to a single base 64 digit.
2257 */
2258 exports.encode = function base64_encode(aNumber) {
2259 if (aNumber in intToCharMap) {
2260 return intToCharMap[aNumber];
2261 }
2262 throw new TypeError("Must be between 0 and 63: " + aNumber);
2263 };
2264
2265 /**
2266 * Decode a single base 64 digit to an integer.
2267 */
2268 exports.decode = function base64_decode(aChar) {
2269 if (aChar in charToIntMap) {
2270 return charToIntMap[aChar];
2271 }
2272 throw new TypeError("Not a valid base 64 digit: " + aChar);
2273 };
2274
2275 });
2276
2277 },{"amdefine":26}],20:[function(require,module,exports){
2278 /* -*- Mode: js; js-indent-level: 2; -*- */
2279 /*
2280 * Copyright 2011 Mozilla Foundation and contributors
2281 * Licensed under the New BSD license. See LICENSE or:
2282 * http://opensource.org/licenses/BSD-3-Clause
2283 */
2284 if (typeof define !== 'function') {
2285 var define = require('amdefine')(module, require);
2286 }
2287 define(function (require, exports, module) {
2288
2289 /**
2290 * Recursive implementation of binary search.
2291 *
2292 * @param aLow Indices here and lower do not contain the needle.
2293 * @param aHigh Indices here and higher do not contain the needle.
2294 * @param aNeedle The element being searched for.
2295 * @param aHaystack The non-empty array being searched.
2296 * @param aCompare Function which takes two elements and returns -1, 0, or 1.
2297 */
2298 function recursiveSearch(aLow, aHigh, aNeedle, aHaystack, aCompare) {
2299 // This function terminates when one of the following is true:
2300 //
2301 // 1. We find the exact element we are looking for.
2302 //
2303 // 2. We did not find the exact element, but we can return the index of
2304 // the next closest element that is less than that element.
2305 //
2306 // 3. We did not find the exact element, and there is no next-closest
2307 // element which is less than the one we are searching for, so we
2308 // return -1.
2309 var mid = Math.floor((aHigh - aLow) / 2) + aLow;
2310 var cmp = aCompare(aNeedle, aHaystack[mid], true);
2311 if (cmp === 0) {
2312 // Found the element we are looking for.
2313 return mid;
2314 }
2315 else if (cmp > 0) {
2316 // aHaystack[mid] is greater than our needle.
2317 if (aHigh - mid > 1) {
2318 // The element is in the upper half.
2319 return recursiveSearch(mid, aHigh, aNeedle, aHaystack, aCompare);
2320 }
2321 // We did not find an exact match, return the next closest one
2322 // (termination case 2).
2323 return mid;
2324 }
2325 else {
2326 // aHaystack[mid] is less than our needle.
2327 if (mid - aLow > 1) {
2328 // The element is in the lower half.
2329 return recursiveSearch(aLow, mid, aNeedle, aHaystack, aCompare);
2330 }
2331 // The exact needle element was not found in this haystack. Determine if
2332 // we are in termination case (2) or (3) and return the appropriate thing.
2333 return aLow < 0 ? -1 : aLow;
2334 }
2335 }
2336
2337 /**
2338 * This is an implementation of binary search which will always try and return
2339 * the index of next lowest value checked if there is no exact hit. This is
2340 * because mappings between original and generated line/col pairs are single
2341 * points, and there is an implicit region between each of them, so a miss
2342 * just means that you aren't on the very start of a region.
2343 *
2344 * @param aNeedle The element you are looking for.
2345 * @param aHaystack The array that is being searched.
2346 * @param aCompare A function which takes the needle and an element in the
2347 * array and returns -1, 0, or 1 depending on whether the needle is less
2348 * than, equal to, or greater than the element, respectively.
2349 */
2350 exports.search = function search(aNeedle, aHaystack, aCompare) {
2351 if (aHaystack.length === 0) {
2352 return -1;
2353 }
2354 return recursiveSearch(-1, aHaystack.length, aNeedle, aHaystack, aCompare)
2355 };
2356
2357 });
2358
2359 },{"amdefine":26}],21:[function(require,module,exports){
2360 /* -*- Mode: js; js-indent-level: 2; -*- */
2361 /*
2362 * Copyright 2014 Mozilla Foundation and contributors
2363 * Licensed under the New BSD license. See LICENSE or:
2364 * http://opensource.org/licenses/BSD-3-Clause
2365 */
2366 if (typeof define !== 'function') {
2367 var define = require('amdefine')(module, require);
2368 }
2369 define(function (require, exports, module) {
2370
2371 var util = require('./util');
2372
2373 /**
2374 * Determine whether mappingB is after mappingA with respect to generated
2375 * position.
2376 */
2377 function generatedPositionAfter(mappingA, mappingB) {
2378 // Optimized for most common case
2379 var lineA = mappingA.generatedLine;
2380 var lineB = mappingB.generatedLine;
2381 var columnA = mappingA.generatedColumn;
2382 var columnB = mappingB.generatedColumn;
2383 return lineB > lineA || lineB == lineA && columnB >= columnA ||
2384 util.compareByGeneratedPositions(mappingA, mappingB) <= 0;
2385 }
2386
2387 /**
2388 * A data structure to provide a sorted view of accumulated mappings in a
2389 * performance conscious manner. It trades a neglibable overhead in general
2390 * case for a large speedup in case of mappings being added in order.
2391 */
2392 function MappingList() {
2393 this._array = [];
2394 this._sorted = true;
2395 // Serves as infimum
2396 this._last = {generatedLine: -1, generatedColumn: 0};
2397 }
2398
2399 /**
2400 * Iterate through internal items. This method takes the same arguments that
2401 * `Array.prototype.forEach` takes.
2402 *
2403 * NOTE: The order of the mappings is NOT guaranteed.
2404 */
2405 MappingList.prototype.unsortedForEach =
2406 function MappingList_forEach(aCallback, aThisArg) {
2407 this._array.forEach(aCallback, aThisArg);
2408 };
2409
2410 /**
2411 * Add the given source mapping.
2412 *
2413 * @param Object aMapping
2414 */
2415 MappingList.prototype.add = function MappingList_add(aMapping) {
2416 var mapping;
2417 if (generatedPositionAfter(this._last, aMapping)) {
2418 this._last = aMapping;
2419 this._array.push(aMapping);
2420 } else {
2421 this._sorted = false;
2422 this._array.push(aMapping);
2423 }
2424 };
2425
2426 /**
2427 * Returns the flat, sorted array of mappings. The mappings are sorted by
2428 * generated position.
2429 *
2430 * WARNING: This method returns internal data without copying, for
2431 * performance. The return value must NOT be mutated, and should be treated as
2432 * an immutable borrow. If you want to take ownership, you must make your own
2433 * copy.
2434 */
2435 MappingList.prototype.toArray = function MappingList_toArray() {
2436 if (!this._sorted) {
2437 this._array.sort(util.compareByGeneratedPositions);
2438 this._sorted = true;
2439 }
2440 return this._array;
2441 };
2442
2443 exports.MappingList = MappingList;
2444
2445 });
2446
2447 },{"./util":25,"amdefine":26}],22:[function(require,module,exports){
2448 /* -*- Mode: js; js-indent-level: 2; -*- */
2449 /*
2450 * Copyright 2011 Mozilla Foundation and contributors
2451 * Licensed under the New BSD license. See LICENSE or:
2452 * http://opensource.org/licenses/BSD-3-Clause
2453 */
2454 if (typeof define !== 'function') {
2455 var define = require('amdefine')(module, require);
2456 }
2457 define(function (require, exports, module) {
2458
2459 var util = require('./util');
2460 var binarySearch = require('./binary-search');
2461 var ArraySet = require('./array-set').ArraySet;
2462 var base64VLQ = require('./base64-vlq');
2463
2464 /**
2465 * A SourceMapConsumer instance represents a parsed source map which we can
2466 * query for information about the original file positions by giving it a file
2467 * position in the generated source.
2468 *
2469 * The only parameter is the raw source map (either as a JSON string, or
2470 * already parsed to an object). According to the spec, source maps have the
2471 * following attributes:
2472 *
2473 * - version: Which version of the source map spec this map is following.
2474 * - sources: An array of URLs to the original source files.
2475 * - names: An array of identifiers which can be referrenced by individual mappings.
2476 * - sourceRoot: Optional. The URL root from which all sources are relative.
2477 * - sourcesContent: Optional. An array of contents of the original source files.
2478 * - mappings: A string of base64 VLQs which contain the actual mappings.
2479 * - file: Optional. The generated file this source map is associated with.
2480 *
2481 * Here is an example source map, taken from the source map spec[0]:
2482 *
2483 * {
2484 * version : 3,
2485 * file: "out.js",
2486 * sourceRoot : "",
2487 * sources: ["foo.js", "bar.js"],
2488 * names: ["src", "maps", "are", "fun"],
2489 * mappings: "AA,AB;;ABCDE;"
2490 * }
2491 *
2492 * [0]: https://docs.google.com/document/d/1U1RGAehQwRypUTovF1KRlpiOFze0b-_2gc6fAH0KY0k/edit?pli=1#
2493 */
2494 function SourceMapConsumer(aSourceMap) {
2495 var sourceMap = aSourceMap;
2496 if (typeof aSourceMap === 'string') {
2497 sourceMap = JSON.parse(aSourceMap.replace(/^\)\]\}'/, ''));
2498 }
2499
2500 var version = util.getArg(sourceMap, 'version');
2501 var sources = util.getArg(sourceMap, 'sources');
2502 // Sass 3.3 leaves out the 'names' array, so we deviate from the spec (which
2503 // requires the array) to play nice here.
2504 var names = util.getArg(sourceMap, 'names', []);
2505 var sourceRoot = util.getArg(sourceMap, 'sourceRoot', null);
2506 var sourcesContent = util.getArg(sourceMap, 'sourcesContent', null);
2507 var mappings = util.getArg(sourceMap, 'mappings');
2508 var file = util.getArg(sourceMap, 'file', null);
2509
2510 // Once again, Sass deviates from the spec and supplies the version as a
2511 // string rather than a number, so we use loose equality checking here.
2512 if (version != this._version) {
2513 throw new Error('Unsupported version: ' + version);
2514 }
2515
2516 // Some source maps produce relative source paths like "./foo.js" instead of
2517 // "foo.js". Normalize these first so that future comparisons will succeed.
2518 // See bugzil.la/1090768.
2519 sources = sources.map(util.normalize);
2520
2521 // Pass `true` below to allow duplicate names and sources. While source maps
2522 // are intended to be compressed and deduplicated, the TypeScript compiler
2523 // sometimes generates source maps with duplicates in them. See Github issue
2524 // #72 and bugzil.la/889492.
2525 this._names = ArraySet.fromArray(names, true);
2526 this._sources = ArraySet.fromArray(sources, true);
2527
2528 this.sourceRoot = sourceRoot;
2529 this.sourcesContent = sourcesContent;
2530 this._mappings = mappings;
2531 this.file = file;
2532 }
2533
2534 /**
2535 * Create a SourceMapConsumer from a SourceMapGenerator.
2536 *
2537 * @param SourceMapGenerator aSourceMap
2538 * The source map that will be consumed.
2539 * @returns SourceMapConsumer
2540 */
2541 SourceMapConsumer.fromSourceMap =
2542 function SourceMapConsumer_fromSourceMap(aSourceMap) {
2543 var smc = Object.create(SourceMapConsumer.prototype);
2544
2545 smc._names = ArraySet.fromArray(aSourceMap._names.toArray(), true);
2546 smc._sources = ArraySet.fromArray(aSourceMap._sources.toArray(), true);
2547 smc.sourceRoot = aSourceMap._sourceRoot;
2548 smc.sourcesContent = aSourceMap._generateSourcesContent(smc._sources.toArray(),
2549 smc.sourceRoot);
2550 smc.file = aSourceMap._file;
2551
2552 smc.__generatedMappings = aSourceMap._mappings.toArray().slice();
2553 smc.__originalMappings = aSourceMap._mappings.toArray().slice()
2554 .sort(util.compareByOriginalPositions);
2555
2556 return smc;
2557 };
2558
2559 /**
2560 * The version of the source mapping spec that we are consuming.
2561 */
2562 SourceMapConsumer.prototype._version = 3;
2563
2564 /**
2565 * The list of original sources.
2566 */
2567 Object.defineProperty(SourceMapConsumer.prototype, 'sources', {
2568 get: function () {
2569 return this._sources.toArray().map(function (s) {
2570 return this.sourceRoot != null ? util.join(this.sourceRoot, s) : s;
2571 }, this);
2572 }
2573 });
2574
2575 // `__generatedMappings` and `__originalMappings` are arrays that hold the
2576 // parsed mapping coordinates from the source map's "mappings" attribute. They
2577 // are lazily instantiated, accessed via the `_generatedMappings` and
2578 // `_originalMappings` getters respectively, and we only parse the mappings
2579 // and create these arrays once queried for a source location. We jump through
2580 // these hoops because there can be many thousands of mappings, and parsing
2581 // them is expensive, so we only want to do it if we must.
2582 //
2583 // Each object in the arrays is of the form:
2584 //
2585 // {
2586 // generatedLine: The line number in the generated code,
2587 // generatedColumn: The column number in the generated code,
2588 // source: The path to the original source file that generated this
2589 // chunk of code,
2590 // originalLine: The line number in the original source that
2591 // corresponds to this chunk of generated code,
2592 // originalColumn: The column number in the original source that
2593 // corresponds to this chunk of generated code,
2594 // name: The name of the original symbol which generated this chunk of
2595 // code.
2596 // }
2597 //
2598 // All properties except for `generatedLine` and `generatedColumn` can be
2599 // `null`.
2600 //
2601 // `_generatedMappings` is ordered by the generated positions.
2602 //
2603 // `_originalMappings` is ordered by the original positions.
2604
2605 SourceMapConsumer.prototype.__generatedMappings = null;
2606 Object.defineProperty(SourceMapConsumer.prototype, '_generatedMappings', {
2607 get: function () {
2608 if (!this.__generatedMappings) {
2609 this.__generatedMappings = [];
2610 this.__originalMappings = [];
2611 this._parseMappings(this._mappings, this.sourceRoot);
2612 }
2613
2614 return this.__generatedMappings;
2615 }
2616 });
2617
2618 SourceMapConsumer.prototype.__originalMappings = null;
2619 Object.defineProperty(SourceMapConsumer.prototype, '_originalMappings', {
2620 get: function () {
2621 if (!this.__originalMappings) {
2622 this.__generatedMappings = [];
2623 this.__originalMappings = [];
2624 this._parseMappings(this._mappings, this.sourceRoot);
2625 }
2626
2627 return this.__originalMappings;
2628 }
2629 });
2630
2631 SourceMapConsumer.prototype._nextCharIsMappingSeparator =
2632 function SourceMapConsumer_nextCharIsMappingSeparator(aStr) {
2633 var c = aStr.charAt(0);
2634 return c === ";" || c === ",";
2635 };
2636
2637 /**
2638 * Parse the mappings in a string in to a data structure which we can easily
2639 * query (the ordered arrays in the `this.__generatedMappings` and
2640 * `this.__originalMappings` properties).
2641 */
2642 SourceMapConsumer.prototype._parseMappings =
2643 function SourceMapConsumer_parseMappings(aStr, aSourceRoot) {
2644 var generatedLine = 1;
2645 var previousGeneratedColumn = 0;
2646 var previousOriginalLine = 0;
2647 var previousOriginalColumn = 0;
2648 var previousSource = 0;
2649 var previousName = 0;
2650 var str = aStr;
2651 var temp = {};
2652 var mapping;
2653
2654 while (str.length > 0) {
2655 if (str.charAt(0) === ';') {
2656 generatedLine++;
2657 str = str.slice(1);
2658 previousGeneratedColumn = 0;
2659 }
2660 else if (str.charAt(0) === ',') {
2661 str = str.slice(1);
2662 }
2663 else {
2664 mapping = {};
2665 mapping.generatedLine = generatedLine;
2666
2667 // Generated column.
2668 base64VLQ.decode(str, temp);
2669 mapping.generatedColumn = previousGeneratedColumn + temp.value;
2670 previousGeneratedColumn = mapping.generatedColumn;
2671 str = temp.rest;
2672
2673 if (str.length > 0 && !this._nextCharIsMappingSeparator(str)) {
2674 // Original source.
2675 base64VLQ.decode(str, temp);
2676 mapping.source = this._sources.at(previousSource + temp.value);
2677 previousSource += temp.value;
2678 str = temp.rest;
2679 if (str.length === 0 || this._nextCharIsMappingSeparator(str)) {
2680 throw new Error('Found a source, but no line and column');
2681 }
2682
2683 // Original line.
2684 base64VLQ.decode(str, temp);
2685 mapping.originalLine = previousOriginalLine + temp.value;
2686 previousOriginalLine = mapping.originalLine;
2687 // Lines are stored 0-based
2688 mapping.originalLine += 1;
2689 str = temp.rest;
2690 if (str.length === 0 || this._nextCharIsMappingSeparator(str)) {
2691 throw new Error('Found a source and line, but no column');
2692 }
2693
2694 // Original column.
2695 base64VLQ.decode(str, temp);
2696 mapping.originalColumn = previousOriginalColumn + temp.value;
2697 previousOriginalColumn = mapping.originalColumn;
2698 str = temp.rest;
2699
2700 if (str.length > 0 && !this._nextCharIsMappingSeparator(str)) {
2701 // Original name.
2702 base64VLQ.decode(str, temp);
2703 mapping.name = this._names.at(previousName + temp.value);
2704 previousName += temp.value;
2705 str = temp.rest;
2706 }
2707 }
2708
2709 this.__generatedMappings.push(mapping);
2710 if (typeof mapping.originalLine === 'number') {
2711 this.__originalMappings.push(mapping);
2712 }
2713 }
2714 }
2715
2716 this.__generatedMappings.sort(util.compareByGeneratedPositions);
2717 this.__originalMappings.sort(util.compareByOriginalPositions);
2718 };
2719
2720 /**
2721 * Find the mapping that best matches the hypothetical "needle" mapping that
2722 * we are searching for in the given "haystack" of mappings.
2723 */
2724 SourceMapConsumer.prototype._findMapping =
2725 function SourceMapConsumer_findMapping(aNeedle, aMappings, aLineName,
2726 aColumnName, aComparator) {
2727 // To return the position we are searching for, we must first find the
2728 // mapping for the given position and then return the opposite position it
2729 // points to. Because the mappings are sorted, we can use binary search to
2730 // find the best mapping.
2731
2732 if (aNeedle[aLineName] <= 0) {
2733 throw new TypeError('Line must be greater than or equal to 1, got '
2734 + aNeedle[aLineName]);
2735 }
2736 if (aNeedle[aColumnName] < 0) {
2737 throw new TypeError('Column must be greater than or equal to 0, got '
2738 + aNeedle[aColumnName]);
2739 }
2740
2741 return binarySearch.search(aNeedle, aMappings, aComparator);
2742 };
2743
2744 /**
2745 * Compute the last column for each generated mapping. The last column is
2746 * inclusive.
2747 */
2748 SourceMapConsumer.prototype.computeColumnSpans =
2749 function SourceMapConsumer_computeColumnSpans() {
2750 for (var index = 0; index < this._generatedMappings.length; ++index) {
2751 var mapping = this._generatedMappings[index];
2752
2753 // Mappings do not contain a field for the last generated columnt. We
2754 // can come up with an optimistic estimate, however, by assuming that
2755 // mappings are contiguous (i.e. given two consecutive mappings, the
2756 // first mapping ends where the second one starts).
2757 if (index + 1 < this._generatedMappings.length) {
2758 var nextMapping = this._generatedMappings[index + 1];
2759
2760 if (mapping.generatedLine === nextMapping.generatedLine) {
2761 mapping.lastGeneratedColumn = nextMapping.generatedColumn - 1;
2762 continue;
2763 }
2764 }
2765
2766 // The last mapping for each line spans the entire line.
2767 mapping.lastGeneratedColumn = Infinity;
2768 }
2769 };
2770
2771 /**
2772 * Returns the original source, line, and column information for the generated
2773 * source's line and column positions provided. The only argument is an object
2774 * with the following properties:
2775 *
2776 * - line: The line number in the generated source.
2777 * - column: The column number in the generated source.
2778 *
2779 * and an object is returned with the following properties:
2780 *
2781 * - source: The original source file, or null.
2782 * - line: The line number in the original source, or null.
2783 * - column: The column number in the original source, or null.
2784 * - name: The original identifier, or null.
2785 */
2786 SourceMapConsumer.prototype.originalPositionFor =
2787 function SourceMapConsumer_originalPositionFor(aArgs) {
2788 var needle = {
2789 generatedLine: util.getArg(aArgs, 'line'),
2790 generatedColumn: util.getArg(aArgs, 'column')
2791 };
2792
2793 var index = this._findMapping(needle,
2794 this._generatedMappings,
2795 "generatedLine",
2796 "generatedColumn",
2797 util.compareByGeneratedPositions);
2798
2799 if (index >= 0) {
2800 var mapping = this._generatedMappings[index];
2801
2802 if (mapping.generatedLine === needle.generatedLine) {
2803 var source = util.getArg(mapping, 'source', null);
2804 if (source != null && this.sourceRoot != null) {
2805 source = util.join(this.sourceRoot, source);
2806 }
2807 return {
2808 source: source,
2809 line: util.getArg(mapping, 'originalLine', null),
2810 column: util.getArg(mapping, 'originalColumn', null),
2811 name: util.getArg(mapping, 'name', null)
2812 };
2813 }
2814 }
2815
2816 return {
2817 source: null,
2818 line: null,
2819 column: null,
2820 name: null
2821 };
2822 };
2823
2824 /**
2825 * Returns the original source content. The only argument is the url of the
2826 * original source file. Returns null if no original source content is
2827 * availible.
2828 */
2829 SourceMapConsumer.prototype.sourceContentFor =
2830 function SourceMapConsumer_sourceContentFor(aSource) {
2831 if (!this.sourcesContent) {
2832 return null;
2833 }
2834
2835 if (this.sourceRoot != null) {
2836 aSource = util.relative(this.sourceRoot, aSource);
2837 }
2838
2839 if (this._sources.has(aSource)) {
2840 return this.sourcesContent[this._sources.indexOf(aSource)];
2841 }
2842
2843 var url;
2844 if (this.sourceRoot != null
2845 && (url = util.urlParse(this.sourceRoot))) {
2846 // XXX: file:// URIs and absolute paths lead to unexpected behavior for
2847 // many users. We can help them out when they expect file:// URIs to
2848 // behave like it would if they were running a local HTTP server. See
2849 // https://bugzilla.mozilla.org/show_bug.cgi?id=885597.
2850 var fileUriAbsPath = aSource.replace(/^file:\/\//, "");
2851 if (url.scheme == "file"
2852 && this._sources.has(fileUriAbsPath)) {
2853 return this.sourcesContent[this._sources.indexOf(fileUriAbsPath)]
2854 }
2855
2856 if ((!url.path || url.path == "/")
2857 && this._sources.has("/" + aSource)) {
2858 return this.sourcesContent[this._sources.indexOf("/" + aSource)];
2859 }
2860 }
2861
2862 throw new Error('"' + aSource + '" is not in the SourceMap.');
2863 };
2864
2865 /**
2866 * Returns the generated line and column information for the original source,
2867 * line, and column positions provided. The only argument is an object with
2868 * the following properties:
2869 *
2870 * - source: The filename of the original source.
2871 * - line: The line number in the original source.
2872 * - column: The column number in the original source.
2873 *
2874 * and an object is returned with the following properties:
2875 *
2876 * - line: The line number in the generated source, or null.
2877 * - column: The column number in the generated source, or null.
2878 */
2879 SourceMapConsumer.prototype.generatedPositionFor =
2880 function SourceMapConsumer_generatedPositionFor(aArgs) {
2881 var needle = {
2882 source: util.getArg(aArgs, 'source'),
2883 originalLine: util.getArg(aArgs, 'line'),
2884 originalColumn: util.getArg(aArgs, 'column')
2885 };
2886
2887 if (this.sourceRoot != null) {
2888 needle.source = util.relative(this.sourceRoot, needle.source);
2889 }
2890
2891 var index = this._findMapping(needle,
2892 this._originalMappings,
2893 "originalLine",
2894 "originalColumn",
2895 util.compareByOriginalPositions);
2896
2897 if (index >= 0) {
2898 var mapping = this._originalMappings[index];
2899
2900 return {
2901 line: util.getArg(mapping, 'generatedLine', null),
2902 column: util.getArg(mapping, 'generatedColumn', null),
2903 lastColumn: util.getArg(mapping, 'lastGeneratedColumn', null)
2904 };
2905 }
2906
2907 return {
2908 line: null,
2909 column: null,
2910 lastColumn: null
2911 };
2912 };
2913
2914 /**
2915 * Returns all generated line and column information for the original source
2916 * and line provided. The only argument is an object with the following
2917 * properties:
2918 *
2919 * - source: The filename of the original source.
2920 * - line: The line number in the original source.
2921 *
2922 * and an array of objects is returned, each with the following properties:
2923 *
2924 * - line: The line number in the generated source, or null.
2925 * - column: The column number in the generated source, or null.
2926 */
2927 SourceMapConsumer.prototype.allGeneratedPositionsFor =
2928 function SourceMapConsumer_allGeneratedPositionsFor(aArgs) {
2929 // When there is no exact match, SourceMapConsumer.prototype._findMapping
2930 // returns the index of the closest mapping less than the needle. By
2931 // setting needle.originalColumn to Infinity, we thus find the last
2932 // mapping for the given line, provided such a mapping exists.
2933 var needle = {
2934 source: util.getArg(aArgs, 'source'),
2935 originalLine: util.getArg(aArgs, 'line'),
2936 originalColumn: Infinity
2937 };
2938
2939 if (this.sourceRoot != null) {
2940 needle.source = util.relative(this.sourceRoot, needle.source);
2941 }
2942
2943 var mappings = [];
2944
2945 var index = this._findMapping(needle,
2946 this._originalMappings,
2947 "originalLine",
2948 "originalColumn",
2949 util.compareByOriginalPositions);
2950 if (index >= 0) {
2951 var mapping = this._originalMappings[index];
2952
2953 while (mapping && mapping.originalLine === needle.originalLine) {
2954 mappings.push({
2955 line: util.getArg(mapping, 'generatedLine', null),
2956 column: util.getArg(mapping, 'generatedColumn', null),
2957 lastColumn: util.getArg(mapping, 'lastGeneratedColumn', null)
2958 });
2959
2960 mapping = this._originalMappings[--index];
2961 }
2962 }
2963
2964 return mappings.reverse();
2965 };
2966
2967 SourceMapConsumer.GENERATED_ORDER = 1;
2968 SourceMapConsumer.ORIGINAL_ORDER = 2;
2969
2970 /**
2971 * Iterate over each mapping between an original source/line/column and a
2972 * generated line/column in this source map.
2973 *
2974 * @param Function aCallback
2975 * The function that is called with each mapping.
2976 * @param Object aContext
2977 * Optional. If specified, this object will be the value of `this` every
2978 * time that `aCallback` is called.
2979 * @param aOrder
2980 * Either `SourceMapConsumer.GENERATED_ORDER` or
2981 * `SourceMapConsumer.ORIGINAL_ORDER`. Specifies whether you want to
2982 * iterate over the mappings sorted by the generated file's line/column
2983 * order or the original's source/line/column order, respectively. Defaults to
2984 * `SourceMapConsumer.GENERATED_ORDER`.
2985 */
2986 SourceMapConsumer.prototype.eachMapping =
2987 function SourceMapConsumer_eachMapping(aCallback, aContext, aOrder) {
2988 var context = aContext || null;
2989 var order = aOrder || SourceMapConsumer.GENERATED_ORDER;
2990
2991 var mappings;
2992 switch (order) {
2993 case SourceMapConsumer.GENERATED_ORDER:
2994 mappings = this._generatedMappings;
2995 break;
2996 case SourceMapConsumer.ORIGINAL_ORDER:
2997 mappings = this._originalMappings;
2998 break;
2999 default:
3000 throw new Error("Unknown order of iteration.");
3001 }
3002
3003 var sourceRoot = this.sourceRoot;
3004 mappings.map(function (mapping) {
3005 var source = mapping.source;
3006 if (source != null && sourceRoot != null) {
3007 source = util.join(sourceRoot, source);
3008 }
3009 return {
3010 source: source,
3011 generatedLine: mapping.generatedLine,
3012 generatedColumn: mapping.generatedColumn,
3013 originalLine: mapping.originalLine,
3014 originalColumn: mapping.originalColumn,
3015 name: mapping.name
3016 };
3017 }).forEach(aCallback, context);
3018 };
3019
3020 exports.SourceMapConsumer = SourceMapConsumer;
3021
3022 });
3023
3024 },{"./array-set":17,"./base64-vlq":18,"./binary-search":20,"./util":25,"amdefine":26}],23:[function(require,module,exports){
3025 /* -*- Mode: js; js-indent-level: 2; -*- */
3026 /*
3027 * Copyright 2011 Mozilla Foundation and contributors
3028 * Licensed under the New BSD license. See LICENSE or:
3029 * http://opensource.org/licenses/BSD-3-Clause
3030 */
3031 if (typeof define !== 'function') {
3032 var define = require('amdefine')(module, require);
3033 }
3034 define(function (require, exports, module) {
3035
3036 var base64VLQ = require('./base64-vlq');
3037 var util = require('./util');
3038 var ArraySet = require('./array-set').ArraySet;
3039 var MappingList = require('./mapping-list').MappingList;
3040
3041 /**
3042 * An instance of the SourceMapGenerator represents a source map which is
3043 * being built incrementally. You may pass an object with the following
3044 * properties:
3045 *
3046 * - file: The filename of the generated source.
3047 * - sourceRoot: A root for all relative URLs in this source map.
3048 */
3049 function SourceMapGenerator(aArgs) {
3050 if (!aArgs) {
3051 aArgs = {};
3052 }
3053 this._file = util.getArg(aArgs, 'file', null);
3054 this._sourceRoot = util.getArg(aArgs, 'sourceRoot', null);
3055 this._skipValidation = util.getArg(aArgs, 'skipValidation', false);
3056 this._sources = new ArraySet();
3057 this._names = new ArraySet();
3058 this._mappings = new MappingList();
3059 this._sourcesContents = null;
3060 }
3061
3062 SourceMapGenerator.prototype._version = 3;
3063
3064 /**
3065 * Creates a new SourceMapGenerator based on a SourceMapConsumer
3066 *
3067 * @param aSourceMapConsumer The SourceMap.
3068 */
3069 SourceMapGenerator.fromSourceMap =
3070 function SourceMapGenerator_fromSourceMap(aSourceMapConsumer) {
3071 var sourceRoot = aSourceMapConsumer.sourceRoot;
3072 var generator = new SourceMapGenerator({
3073 file: aSourceMapConsumer.file,
3074 sourceRoot: sourceRoot
3075 });
3076 aSourceMapConsumer.eachMapping(function (mapping) {
3077 var newMapping = {
3078 generated: {
3079 line: mapping.generatedLine,
3080 column: mapping.generatedColumn
3081 }
3082 };
3083
3084 if (mapping.source != null) {
3085 newMapping.source = mapping.source;
3086 if (sourceRoot != null) {
3087 newMapping.source = util.relative(sourceRoot, newMapping.source);
3088 }
3089
3090 newMapping.original = {
3091 line: mapping.originalLine,
3092 column: mapping.originalColumn
3093 };
3094
3095 if (mapping.name != null) {
3096 newMapping.name = mapping.name;
3097 }
3098 }
3099
3100 generator.addMapping(newMapping);
3101 });
3102 aSourceMapConsumer.sources.forEach(function (sourceFile) {
3103 var content = aSourceMapConsumer.sourceContentFor(sourceFile);
3104 if (content != null) {
3105 generator.setSourceContent(sourceFile, content);
3106 }
3107 });
3108 return generator;
3109 };
3110
3111 /**
3112 * Add a single mapping from original source line and column to the generated
3113 * source's line and column for this source map being created. The mapping
3114 * object should have the following properties:
3115 *
3116 * - generated: An object with the generated line and column positions.
3117 * - original: An object with the original line and column positions.
3118 * - source: The original source file (relative to the sourceRoot).
3119 * - name: An optional original token name for this mapping.
3120 */
3121 SourceMapGenerator.prototype.addMapping =
3122 function SourceMapGenerator_addMapping(aArgs) {
3123 var generated = util.getArg(aArgs, 'generated');
3124 var original = util.getArg(aArgs, 'original', null);
3125 var source = util.getArg(aArgs, 'source', null);
3126 var name = util.getArg(aArgs, 'name', null);
3127
3128 if (!this._skipValidation) {
3129 this._validateMapping(generated, original, source, name);
3130 }
3131
3132 if (source != null && !this._sources.has(source)) {
3133 this._sources.add(source);
3134 }
3135
3136 if (name != null && !this._names.has(name)) {
3137 this._names.add(name);
3138 }
3139
3140 this._mappings.add({
3141 generatedLine: generated.line,
3142 generatedColumn: generated.column,
3143 originalLine: original != null && original.line,
3144 originalColumn: original != null && original.column,
3145 source: source,
3146 name: name
3147 });
3148 };
3149
3150 /**
3151 * Set the source content for a source file.
3152 */
3153 SourceMapGenerator.prototype.setSourceContent =
3154 function SourceMapGenerator_setSourceContent(aSourceFile, aSourceContent) {
3155 var source = aSourceFile;
3156 if (this._sourceRoot != null) {
3157 source = util.relative(this._sourceRoot, source);
3158 }
3159
3160 if (aSourceContent != null) {
3161 // Add the source content to the _sourcesContents map.
3162 // Create a new _sourcesContents map if the property is null.
3163 if (!this._sourcesContents) {
3164 this._sourcesContents = {};
3165 }
3166 this._sourcesContents[util.toSetString(source)] = aSourceContent;
3167 } else if (this._sourcesContents) {
3168 // Remove the source file from the _sourcesContents map.
3169 // If the _sourcesContents map is empty, set the property to null.
3170 delete this._sourcesContents[util.toSetString(source)];
3171 if (Object.keys(this._sourcesContents).length === 0) {
3172 this._sourcesContents = null;
3173 }
3174 }
3175 };
3176
3177 /**
3178 * Applies the mappings of a sub-source-map for a specific source file to the
3179 * source map being generated. Each mapping to the supplied source file is
3180 * rewritten using the supplied source map. Note: The resolution for the
3181 * resulting mappings is the minimium of this map and the supplied map.
3182 *
3183 * @param aSourceMapConsumer The source map to be applied.
3184 * @param aSourceFile Optional. The filename of the source file.
3185 * If omitted, SourceMapConsumer's file property will be used.
3186 * @param aSourceMapPath Optional. The dirname of the path to the source map
3187 * to be applied. If relative, it is relative to the SourceMapConsumer.
3188 * This parameter is needed when the two source maps aren't in the same
3189 * directory, and the source map to be applied contains relative source
3190 * paths. If so, those relative source paths need to be rewritten
3191 * relative to the SourceMapGenerator.
3192 */
3193 SourceMapGenerator.prototype.applySourceMap =
3194 function SourceMapGenerator_applySourceMap(aSourceMapConsumer, aSourceFile, aSourceMapPath) {
3195 var sourceFile = aSourceFile;
3196 // If aSourceFile is omitted, we will use the file property of the SourceMap
3197 if (aSourceFile == null) {
3198 if (aSourceMapConsumer.file == null) {
3199 throw new Error(
3200 'SourceMapGenerator.prototype.applySourceMap requires either an explicit source file, ' +
3201 'or the source map\'s "file" property. Both were omitted.'
3202 );
3203 }
3204 sourceFile = aSourceMapConsumer.file;
3205 }
3206 var sourceRoot = this._sourceRoot;
3207 // Make "sourceFile" relative if an absolute Url is passed.
3208 if (sourceRoot != null) {
3209 sourceFile = util.relative(sourceRoot, sourceFile);
3210 }
3211 // Applying the SourceMap can add and remove items from the sources and
3212 // the names array.
3213 var newSources = new ArraySet();
3214 var newNames = new ArraySet();
3215
3216 // Find mappings for the "sourceFile"
3217 this._mappings.unsortedForEach(function (mapping) {
3218 if (mapping.source === sourceFile && mapping.originalLine != null) {
3219 // Check if it can be mapped by the source map, then update the mapping.
3220 var original = aSourceMapConsumer.originalPositionFor({
3221 line: mapping.originalLine,
3222 column: mapping.originalColumn
3223 });
3224 if (original.source != null) {
3225 // Copy mapping
3226 mapping.source = original.source;
3227 if (aSourceMapPath != null) {
3228 mapping.source = util.join(aSourceMapPath, mapping.source)
3229 }
3230 if (sourceRoot != null) {
3231 mapping.source = util.relative(sourceRoot, mapping.source);
3232 }
3233 mapping.originalLine = original.line;
3234 mapping.originalColumn = original.column;
3235 if (original.name != null) {
3236 mapping.name = original.name;
3237 }
3238 }
3239 }
3240
3241 var source = mapping.source;
3242 if (source != null && !newSources.has(source)) {
3243 newSources.add(source);
3244 }
3245
3246 var name = mapping.name;
3247 if (name != null && !newNames.has(name)) {
3248 newNames.add(name);
3249 }
3250
3251 }, this);
3252 this._sources = newSources;
3253 this._names = newNames;
3254
3255 // Copy sourcesContents of applied map.
3256 aSourceMapConsumer.sources.forEach(function (sourceFile) {
3257 var content = aSourceMapConsumer.sourceContentFor(sourceFile);
3258 if (content != null) {
3259 if (aSourceMapPath != null) {
3260 sourceFile = util.join(aSourceMapPath, sourceFile);
3261 }
3262 if (sourceRoot != null) {
3263 sourceFile = util.relative(sourceRoot, sourceFile);
3264 }
3265 this.setSourceContent(sourceFile, content);
3266 }
3267 }, this);
3268 };
3269
3270 /**
3271 * A mapping can have one of the three levels of data:
3272 *
3273 * 1. Just the generated position.
3274 * 2. The Generated position, original position, and original source.
3275 * 3. Generated and original position, original source, as well as a name
3276 * token.
3277 *
3278 * To maintain consistency, we validate that any new mapping being added falls
3279 * in to one of these categories.
3280 */
3281 SourceMapGenerator.prototype._validateMapping =
3282 function SourceMapGenerator_validateMapping(aGenerated, aOriginal, aSource,
3283 aName) {
3284 if (aGenerated && 'line' in aGenerated && 'column' in aGenerated
3285 && aGenerated.line > 0 && aGenerated.column >= 0
3286 && !aOriginal && !aSource && !aName) {
3287 // Case 1.
3288 return;
3289 }
3290 else if (aGenerated && 'line' in aGenerated && 'column' in aGenerated
3291 && aOriginal && 'line' in aOriginal && 'column' in aOriginal
3292 && aGenerated.line > 0 && aGenerated.column >= 0
3293 && aOriginal.line > 0 && aOriginal.column >= 0
3294 && aSource) {
3295 // Cases 2 and 3.
3296 return;
3297 }
3298 else {
3299 throw new Error('Invalid mapping: ' + JSON.stringify({
3300 generated: aGenerated,
3301 source: aSource,
3302 original: aOriginal,
3303 name: aName
3304 }));
3305 }
3306 };
3307
3308 /**
3309 * Serialize the accumulated mappings in to the stream of base 64 VLQs
3310 * specified by the source map format.
3311 */
3312 SourceMapGenerator.prototype._serializeMappings =
3313 function SourceMapGenerator_serializeMappings() {
3314 var previousGeneratedColumn = 0;
3315 var previousGeneratedLine = 1;
3316 var previousOriginalColumn = 0;
3317 var previousOriginalLine = 0;
3318 var previousName = 0;
3319 var previousSource = 0;
3320 var result = '';
3321 var mapping;
3322
3323 var mappings = this._mappings.toArray();
3324
3325 for (var i = 0, len = mappings.length; i < len; i++) {
3326 mapping = mappings[i];
3327
3328 if (mapping.generatedLine !== previousGeneratedLine) {
3329 previousGeneratedColumn = 0;
3330 while (mapping.generatedLine !== previousGeneratedLine) {
3331 result += ';';
3332 previousGeneratedLine++;
3333 }
3334 }
3335 else {
3336 if (i > 0) {
3337 if (!util.compareByGeneratedPositions(mapping, mappings[i - 1])) {
3338 continue;
3339 }
3340 result += ',';
3341 }
3342 }
3343
3344 result += base64VLQ.encode(mapping.generatedColumn
3345 - previousGeneratedColumn);
3346 previousGeneratedColumn = mapping.generatedColumn;
3347
3348 if (mapping.source != null) {
3349 result += base64VLQ.encode(this._sources.indexOf(mapping.source)
3350 - previousSource);
3351 previousSource = this._sources.indexOf(mapping.source);
3352
3353 // lines are stored 0-based in SourceMap spec version 3
3354 result += base64VLQ.encode(mapping.originalLine - 1
3355 - previousOriginalLine);
3356 previousOriginalLine = mapping.originalLine - 1;
3357
3358 result += base64VLQ.encode(mapping.originalColumn
3359 - previousOriginalColumn);
3360 previousOriginalColumn = mapping.originalColumn;
3361
3362 if (mapping.name != null) {
3363 result += base64VLQ.encode(this._names.indexOf(mapping.name)
3364 - previousName);
3365 previousName = this._names.indexOf(mapping.name);
3366 }
3367 }
3368 }
3369
3370 return result;
3371 };
3372
3373 SourceMapGenerator.prototype._generateSourcesContent =
3374 function SourceMapGenerator_generateSourcesContent(aSources, aSourceRoot) {
3375 return aSources.map(function (source) {
3376 if (!this._sourcesContents) {
3377 return null;
3378 }
3379 if (aSourceRoot != null) {
3380 source = util.relative(aSourceRoot, source);
3381 }
3382 var key = util.toSetString(source);
3383 return Object.prototype.hasOwnProperty.call(this._sourcesContents,
3384 key)
3385 ? this._sourcesContents[key]
3386 : null;
3387 }, this);
3388 };
3389
3390 /**
3391 * Externalize the source map.
3392 */
3393 SourceMapGenerator.prototype.toJSON =
3394 function SourceMapGenerator_toJSON() {
3395 var map = {
3396 version: this._version,
3397 sources: this._sources.toArray(),
3398 names: this._names.toArray(),
3399 mappings: this._serializeMappings()
3400 };
3401 if (this._file != null) {
3402 map.file = this._file;
3403 }
3404 if (this._sourceRoot != null) {
3405 map.sourceRoot = this._sourceRoot;
3406 }
3407 if (this._sourcesContents) {
3408 map.sourcesContent = this._generateSourcesContent(map.sources, map.sourceRoot);
3409 }
3410
3411 return map;
3412 };
3413
3414 /**
3415 * Render the source map being generated to a string.
3416 */
3417 SourceMapGenerator.prototype.toString =
3418 function SourceMapGenerator_toString() {
3419 return JSON.stringify(this);
3420 };
3421
3422 exports.SourceMapGenerator = SourceMapGenerator;
3423
3424 });
3425
3426 },{"./array-set":17,"./base64-vlq":18,"./mapping-list":21,"./util":25,"amdefine":26}],24:[function(require,module,exports){
3427 /* -*- Mode: js; js-indent-level: 2; -*- */
3428 /*
3429 * Copyright 2011 Mozilla Foundation and contributors
3430 * Licensed under the New BSD license. See LICENSE or:
3431 * http://opensource.org/licenses/BSD-3-Clause
3432 */
3433 if (typeof define !== 'function') {
3434 var define = require('amdefine')(module, require);
3435 }
3436 define(function (require, exports, module) {
3437
3438 var SourceMapGenerator = require('./source-map-generator').SourceMapGenerator;
3439 var util = require('./util');
3440
3441 // Matches a Windows-style `\r\n` newline or a `\n` newline used by all other
3442 // operating systems these days (capturing the result).
3443 var REGEX_NEWLINE = /(\r?\n)/;
3444
3445 // Newline character code for charCodeAt() comparisons
3446 var NEWLINE_CODE = 10;
3447
3448 // Private symbol for identifying `SourceNode`s when multiple versions of
3449 // the source-map library are loaded. This MUST NOT CHANGE across
3450 // versions!
3451 var isSourceNode = "$$$isSourceNode$$$";
3452
3453 /**
3454 * SourceNodes provide a way to abstract over interpolating/concatenating
3455 * snippets of generated JavaScript source code while maintaining the line and
3456 * column information associated with the original source code.
3457 *
3458 * @param aLine The original line number.
3459 * @param aColumn The original column number.
3460 * @param aSource The original source's filename.
3461 * @param aChunks Optional. An array of strings which are snippets of
3462 * generated JS, or other SourceNodes.
3463 * @param aName The original identifier.
3464 */
3465 function SourceNode(aLine, aColumn, aSource, aChunks, aName) {
3466 this.children = [];
3467 this.sourceContents = {};
3468 this.line = aLine == null ? null : aLine;
3469 this.column = aColumn == null ? null : aColumn;
3470 this.source = aSource == null ? null : aSource;
3471 this.name = aName == null ? null : aName;
3472 this[isSourceNode] = true;
3473 if (aChunks != null) this.add(aChunks);
3474 }
3475
3476 /**
3477 * Creates a SourceNode from generated code and a SourceMapConsumer.
3478 *
3479 * @param aGeneratedCode The generated code
3480 * @param aSourceMapConsumer The SourceMap for the generated code
3481 * @param aRelativePath Optional. The path that relative sources in the
3482 * SourceMapConsumer should be relative to.
3483 */
3484 SourceNode.fromStringWithSourceMap =
3485 function SourceNode_fromStringWithSourceMap(aGeneratedCode, aSourceMapConsumer, aRelativePath) {
3486 // The SourceNode we want to fill with the generated code
3487 // and the SourceMap
3488 var node = new SourceNode();
3489
3490 // All even indices of this array are one line of the generated code,
3491 // while all odd indices are the newlines between two adjacent lines
3492 // (since `REGEX_NEWLINE` captures its match).
3493 // Processed fragments are removed from this array, by calling `shiftNextLine`.
3494 var remainingLines = aGeneratedCode.split(REGEX_NEWLINE);
3495 var shiftNextLine = function() {
3496 var lineContents = remainingLines.shift();
3497 // The last line of a file might not have a newline.
3498 var newLine = remainingLines.shift() || "";
3499 return lineContents + newLine;
3500 };
3501
3502 // We need to remember the position of "remainingLines"
3503 var lastGeneratedLine = 1, lastGeneratedColumn = 0;
3504
3505 // The generate SourceNodes we need a code range.
3506 // To extract it current and last mapping is used.
3507 // Here we store the last mapping.
3508 var lastMapping = null;
3509
3510 aSourceMapConsumer.eachMapping(function (mapping) {
3511 if (lastMapping !== null) {
3512 // We add the code from "lastMapping" to "mapping":
3513 // First check if there is a new line in between.
3514 if (lastGeneratedLine < mapping.generatedLine) {
3515 var code = "";
3516 // Associate first line with "lastMapping"
3517 addMappingWithCode(lastMapping, shiftNextLine());
3518 lastGeneratedLine++;
3519 lastGeneratedColumn = 0;
3520 // The remaining code is added without mapping
3521 } else {
3522 // There is no new line in between.
3523 // Associate the code between "lastGeneratedColumn" and
3524 // "mapping.generatedColumn" with "lastMapping"
3525 var nextLine = remainingLines[0];
3526 var code = nextLine.substr(0, mapping.generatedColumn -
3527 lastGeneratedColumn);
3528 remainingLines[0] = nextLine.substr(mapping.generatedColumn -
3529 lastGeneratedColumn);
3530 lastGeneratedColumn = mapping.generatedColumn;
3531 addMappingWithCode(lastMapping, code);
3532 // No more remaining code, continue
3533 lastMapping = mapping;
3534 return;
3535 }
3536 }
3537 // We add the generated code until the first mapping
3538 // to the SourceNode without any mapping.
3539 // Each line is added as separate string.
3540 while (lastGeneratedLine < mapping.generatedLine) {
3541 node.add(shiftNextLine());
3542 lastGeneratedLine++;
3543 }
3544 if (lastGeneratedColumn < mapping.generatedColumn) {
3545 var nextLine = remainingLines[0];
3546 node.add(nextLine.substr(0, mapping.generatedColumn));
3547 remainingLines[0] = nextLine.substr(mapping.generatedColumn);
3548 lastGeneratedColumn = mapping.generatedColumn;
3549 }
3550 lastMapping = mapping;
3551 }, this);
3552 // We have processed all mappings.
3553 if (remainingLines.length > 0) {
3554 if (lastMapping) {
3555 // Associate the remaining code in the current line with "lastMapping"
3556 addMappingWithCode(lastMapping, shiftNextLine());
3557 }
3558 // and add the remaining lines without any mapping
3559 node.add(remainingLines.join(""));
3560 }
3561
3562 // Copy sourcesContent into SourceNode
3563 aSourceMapConsumer.sources.forEach(function (sourceFile) {
3564 var content = aSourceMapConsumer.sourceContentFor(sourceFile);
3565 if (content != null) {
3566 if (aRelativePath != null) {
3567 sourceFile = util.join(aRelativePath, sourceFile);
3568 }
3569 node.setSourceContent(sourceFile, content);
3570 }
3571 });
3572
3573 return node;
3574
3575 function addMappingWithCode(mapping, code) {
3576 if (mapping === null || mapping.source === undefined) {
3577 node.add(code);
3578 } else {
3579 var source = aRelativePath
3580 ? util.join(aRelativePath, mapping.source)
3581 : mapping.source;
3582 node.add(new SourceNode(mapping.originalLine,
3583 mapping.originalColumn,
3584 source,
3585 code,
3586 mapping.name));
3587 }
3588 }
3589 };
3590
3591 /**
3592 * Add a chunk of generated JS to this source node.
3593 *
3594 * @param aChunk A string snippet of generated JS code, another instance of
3595 * SourceNode, or an array where each member is one of those things.
3596 */
3597 SourceNode.prototype.add = function SourceNode_add(aChunk) {
3598 if (Array.isArray(aChunk)) {
3599 aChunk.forEach(function (chunk) {
3600 this.add(chunk);
3601 }, this);
3602 }
3603 else if (aChunk[isSourceNode] || typeof aChunk === "string") {
3604 if (aChunk) {
3605 this.children.push(aChunk);
3606 }
3607 }
3608 else {
3609 throw new TypeError(
3610 "Expected a SourceNode, string, or an array of SourceNodes and strings. Got " + aChunk
3611 );
3612 }
3613 return this;
3614 };
3615
3616 /**
3617 * Add a chunk of generated JS to the beginning of this source node.
3618 *
3619 * @param aChunk A string snippet of generated JS code, another instance of
3620 * SourceNode, or an array where each member is one of those things.
3621 */
3622 SourceNode.prototype.prepend = function SourceNode_prepend(aChunk) {
3623 if (Array.isArray(aChunk)) {
3624 for (var i = aChunk.length-1; i >= 0; i--) {
3625 this.prepend(aChunk[i]);
3626 }
3627 }
3628 else if (aChunk[isSourceNode] || typeof aChunk === "string") {
3629 this.children.unshift(aChunk);
3630 }
3631 else {
3632 throw new TypeError(
3633 "Expected a SourceNode, string, or an array of SourceNodes and strings. Got " + aChunk
3634 );
3635 }
3636 return this;
3637 };
3638
3639 /**
3640 * Walk over the tree of JS snippets in this node and its children. The
3641 * walking function is called once for each snippet of JS and is passed that
3642 * snippet and the its original associated source's line/column location.
3643 *
3644 * @param aFn The traversal function.
3645 */
3646 SourceNode.prototype.walk = function SourceNode_walk(aFn) {
3647 var chunk;
3648 for (var i = 0, len = this.children.length; i < len; i++) {
3649 chunk = this.children[i];
3650 if (chunk[isSourceNode]) {
3651 chunk.walk(aFn);
3652 }
3653 else {
3654 if (chunk !== '') {
3655 aFn(chunk, { source: this.source,
3656 line: this.line,
3657 column: this.column,
3658 name: this.name });
3659 }
3660 }
3661 }
3662 };
3663
3664 /**
3665 * Like `String.prototype.join` except for SourceNodes. Inserts `aStr` between
3666 * each of `this.children`.
3667 *
3668 * @param aSep The separator.
3669 */
3670 SourceNode.prototype.join = function SourceNode_join(aSep) {
3671 var newChildren;
3672 var i;
3673 var len = this.children.length;
3674 if (len > 0) {
3675 newChildren = [];
3676 for (i = 0; i < len-1; i++) {
3677 newChildren.push(this.children[i]);
3678 newChildren.push(aSep);
3679 }
3680 newChildren.push(this.children[i]);
3681 this.children = newChildren;
3682 }
3683 return this;
3684 };
3685
3686 /**
3687 * Call String.prototype.replace on the very right-most source snippet. Useful
3688 * for trimming whitespace from the end of a source node, etc.
3689 *
3690 * @param aPattern The pattern to replace.
3691 * @param aReplacement The thing to replace the pattern with.
3692 */
3693 SourceNode.prototype.replaceRight = function SourceNode_replaceRight(aPattern, aReplacement) {
3694 var lastChild = this.children[this.children.length - 1];
3695 if (lastChild[isSourceNode]) {
3696 lastChild.replaceRight(aPattern, aReplacement);
3697 }
3698 else if (typeof lastChild === 'string') {
3699 this.children[this.children.length - 1] = lastChild.replace(aPattern, aReplacement);
3700 }
3701 else {
3702 this.children.push(''.replace(aPattern, aReplacement));
3703 }
3704 return this;
3705 };
3706
3707 /**
3708 * Set the source content for a source file. This will be added to the SourceMapGenerator
3709 * in the sourcesContent field.
3710 *
3711 * @param aSourceFile The filename of the source file
3712 * @param aSourceContent The content of the source file
3713 */
3714 SourceNode.prototype.setSourceContent =
3715 function SourceNode_setSourceContent(aSourceFile, aSourceContent) {
3716 this.sourceContents[util.toSetString(aSourceFile)] = aSourceContent;
3717 };
3718
3719 /**
3720 * Walk over the tree of SourceNodes. The walking function is called for each
3721 * source file content and is passed the filename and source content.
3722 *
3723 * @param aFn The traversal function.
3724 */
3725 SourceNode.prototype.walkSourceContents =
3726 function SourceNode_walkSourceContents(aFn) {
3727 for (var i = 0, len = this.children.length; i < len; i++) {
3728 if (this.children[i][isSourceNode]) {
3729 this.children[i].walkSourceContents(aFn);
3730 }
3731 }
3732
3733 var sources = Object.keys(this.sourceContents);
3734 for (var i = 0, len = sources.length; i < len; i++) {
3735 aFn(util.fromSetString(sources[i]), this.sourceContents[sources[i]]);
3736 }
3737 };
3738
3739 /**
3740 * Return the string representation of this source node. Walks over the tree
3741 * and concatenates all the various snippets together to one string.
3742 */
3743 SourceNode.prototype.toString = function SourceNode_toString() {
3744 var str = "";
3745 this.walk(function (chunk) {
3746 str += chunk;
3747 });
3748 return str;
3749 };
3750
3751 /**
3752 * Returns the string representation of this source node along with a source
3753 * map.
3754 */
3755 SourceNode.prototype.toStringWithSourceMap = function SourceNode_toStringWithSourceMap(aArgs) {
3756 var generated = {
3757 code: "",
3758 line: 1,
3759 column: 0
3760 };
3761 var map = new SourceMapGenerator(aArgs);
3762 var sourceMappingActive = false;
3763 var lastOriginalSource = null;
3764 var lastOriginalLine = null;
3765 var lastOriginalColumn = null;
3766 var lastOriginalName = null;
3767 this.walk(function (chunk, original) {
3768 generated.code += chunk;
3769 if (original.source !== null
3770 && original.line !== null
3771 && original.column !== null) {
3772 if(lastOriginalSource !== original.source
3773 || lastOriginalLine !== original.line
3774 || lastOriginalColumn !== original.column
3775 || lastOriginalName !== original.name) {
3776 map.addMapping({
3777 source: original.source,
3778 original: {
3779 line: original.line,
3780 column: original.column
3781 },
3782 generated: {
3783 line: generated.line,
3784 column: generated.column
3785 },
3786 name: original.name
3787 });
3788 }
3789 lastOriginalSource = original.source;
3790 lastOriginalLine = original.line;
3791 lastOriginalColumn = original.column;
3792 lastOriginalName = original.name;
3793 sourceMappingActive = true;
3794 } else if (sourceMappingActive) {
3795 map.addMapping({
3796 generated: {
3797 line: generated.line,
3798 column: generated.column
3799 }
3800 });
3801 lastOriginalSource = null;
3802 sourceMappingActive = false;
3803 }
3804 for (var idx = 0, length = chunk.length; idx < length; idx++) {
3805 if (chunk.charCodeAt(idx) === NEWLINE_CODE) {
3806 generated.line++;
3807 generated.column = 0;
3808 // Mappings end at eol
3809 if (idx + 1 === length) {
3810 lastOriginalSource = null;
3811 sourceMappingActive = false;
3812 } else if (sourceMappingActive) {
3813 map.addMapping({
3814 source: original.source,
3815 original: {
3816 line: original.line,
3817 column: original.column
3818 },
3819 generated: {
3820 line: generated.line,
3821 column: generated.column
3822 },
3823 name: original.name
3824 });
3825 }
3826 } else {
3827 generated.column++;
3828 }
3829 }
3830 });
3831 this.walkSourceContents(function (sourceFile, sourceContent) {
3832 map.setSourceContent(sourceFile, sourceContent);
3833 });
3834
3835 return { code: generated.code, map: map };
3836 };
3837
3838 exports.SourceNode = SourceNode;
3839
3840 });
3841
3842 },{"./source-map-generator":23,"./util":25,"amdefine":26}],25:[function(require,module,exports){
3843 /* -*- Mode: js; js-indent-level: 2; -*- */
3844 /*
3845 * Copyright 2011 Mozilla Foundation and contributors
3846 * Licensed under the New BSD license. See LICENSE or:
3847 * http://opensource.org/licenses/BSD-3-Clause
3848 */
3849 if (typeof define !== 'function') {
3850 var define = require('amdefine')(module, require);
3851 }
3852 define(function (require, exports, module) {
3853
3854 /**
3855 * This is a helper function for getting values from parameter/options
3856 * objects.
3857 *
3858 * @param args The object we are extracting values from
3859 * @param name The name of the property we are getting.
3860 * @param defaultValue An optional value to return if the property is missing
3861 * from the object. If this is not specified and the property is missing, an
3862 * error will be thrown.
3863 */
3864 function getArg(aArgs, aName, aDefaultValue) {
3865 if (aName in aArgs) {
3866 return aArgs[aName];
3867 } else if (arguments.length === 3) {
3868 return aDefaultValue;
3869 } else {
3870 throw new Error('"' + aName + '" is a required argument.');
3871 }
3872 }
3873 exports.getArg = getArg;
3874
3875 var urlRegexp = /^(?:([\w+\-.]+):)?\/\/(?:(\w+:\w+)@)?([\w.]*)(?::(\d+))?(\S*)$/;
3876 var dataUrlRegexp = /^data:.+\,.+$/;
3877
3878 function urlParse(aUrl) {
3879 var match = aUrl.match(urlRegexp);
3880 if (!match) {
3881 return null;
3882 }
3883 return {
3884 scheme: match[1],
3885 auth: match[2],
3886 host: match[3],
3887 port: match[4],
3888 path: match[5]
3889 };
3890 }
3891 exports.urlParse = urlParse;
3892
3893 function urlGenerate(aParsedUrl) {
3894 var url = '';
3895 if (aParsedUrl.scheme) {
3896 url += aParsedUrl.scheme + ':';
3897 }
3898 url += '//';
3899 if (aParsedUrl.auth) {
3900 url += aParsedUrl.auth + '@';
3901 }
3902 if (aParsedUrl.host) {
3903 url += aParsedUrl.host;
3904 }
3905 if (aParsedUrl.port) {
3906 url += ":" + aParsedUrl.port
3907 }
3908 if (aParsedUrl.path) {
3909 url += aParsedUrl.path;
3910 }
3911 return url;
3912 }
3913 exports.urlGenerate = urlGenerate;
3914
3915 /**
3916 * Normalizes a path, or the path portion of a URL:
3917 *
3918 * - Replaces consequtive slashes with one slash.
3919 * - Removes unnecessary '.' parts.
3920 * - Removes unnecessary '<dir>/..' parts.
3921 *
3922 * Based on code in the Node.js 'path' core module.
3923 *
3924 * @param aPath The path or url to normalize.
3925 */
3926 function normalize(aPath) {
3927 var path = aPath;
3928 var url = urlParse(aPath);
3929 if (url) {
3930 if (!url.path) {
3931 return aPath;
3932 }
3933 path = url.path;
3934 }
3935 var isAbsolute = (path.charAt(0) === '/');
3936
3937 var parts = path.split(/\/+/);
3938 for (var part, up = 0, i = parts.length - 1; i >= 0; i--) {
3939 part = parts[i];
3940 if (part === '.') {
3941 parts.splice(i, 1);
3942 } else if (part === '..') {
3943 up++;
3944 } else if (up > 0) {
3945 if (part === '') {
3946 // The first part is blank if the path is absolute. Trying to go
3947 // above the root is a no-op. Therefore we can remove all '..' parts
3948 // directly after the root.
3949 parts.splice(i + 1, up);
3950 up = 0;
3951 } else {
3952 parts.splice(i, 2);
3953 up--;
3954 }
3955 }
3956 }
3957 path = parts.join('/');
3958
3959 if (path === '') {
3960 path = isAbsolute ? '/' : '.';
3961 }
3962
3963 if (url) {
3964 url.path = path;
3965 return urlGenerate(url);
3966 }
3967 return path;
3968 }
3969 exports.normalize = normalize;
3970
3971 /**
3972 * Joins two paths/URLs.
3973 *
3974 * @param aRoot The root path or URL.
3975 * @param aPath The path or URL to be joined with the root.
3976 *
3977 * - If aPath is a URL or a data URI, aPath is returned, unless aPath is a
3978 * scheme-relative URL: Then the scheme of aRoot, if any, is prepended
3979 * first.
3980 * - Otherwise aPath is a path. If aRoot is a URL, then its path portion
3981 * is updated with the result and aRoot is returned. Otherwise the result
3982 * is returned.
3983 * - If aPath is absolute, the result is aPath.
3984 * - Otherwise the two paths are joined with a slash.
3985 * - Joining for example 'http://' and 'www.example.com' is also supported.
3986 */
3987 function join(aRoot, aPath) {
3988 if (aRoot === "") {
3989 aRoot = ".";
3990 }
3991 if (aPath === "") {
3992 aPath = ".";
3993 }
3994 var aPathUrl = urlParse(aPath);
3995 var aRootUrl = urlParse(aRoot);
3996 if (aRootUrl) {
3997 aRoot = aRootUrl.path || '/';
3998 }
3999
4000 // `join(foo, '//www.example.org')`
4001 if (aPathUrl && !aPathUrl.scheme) {
4002 if (aRootUrl) {
4003 aPathUrl.scheme = aRootUrl.scheme;
4004 }
4005 return urlGenerate(aPathUrl);
4006 }
4007
4008 if (aPathUrl || aPath.match(dataUrlRegexp)) {
4009 return aPath;
4010 }
4011
4012 // `join('http://', 'www.example.com')`
4013 if (aRootUrl && !aRootUrl.host && !aRootUrl.path) {
4014 aRootUrl.host = aPath;
4015 return urlGenerate(aRootUrl);
4016 }
4017
4018 var joined = aPath.charAt(0) === '/'
4019 ? aPath
4020 : normalize(aRoot.replace(/\/+$/, '') + '/' + aPath);
4021
4022 if (aRootUrl) {
4023 aRootUrl.path = joined;
4024 return urlGenerate(aRootUrl);
4025 }
4026 return joined;
4027 }
4028 exports.join = join;
4029
4030 /**
4031 * Make a path relative to a URL or another path.
4032 *
4033 * @param aRoot The root path or URL.
4034 * @param aPath The path or URL to be made relative to aRoot.
4035 */
4036 function relative(aRoot, aPath) {
4037 if (aRoot === "") {
4038 aRoot = ".";
4039 }
4040
4041 aRoot = aRoot.replace(/\/$/, '');
4042
4043 // XXX: It is possible to remove this block, and the tests still pass!
4044 var url = urlParse(aRoot);
4045 if (aPath.charAt(0) == "/" && url && url.path == "/") {
4046 return aPath.slice(1);
4047 }
4048
4049 return aPath.indexOf(aRoot + '/') === 0
4050 ? aPath.substr(aRoot.length + 1)
4051 : aPath;
4052 }
4053 exports.relative = relative;
4054
4055 /**
4056 * Because behavior goes wacky when you set `__proto__` on objects, we
4057 * have to prefix all the strings in our set with an arbitrary character.
4058 *
4059 * See https://github.com/mozilla/source-map/pull/31 and
4060 * https://github.com/mozilla/source-map/issues/30
4061 *
4062 * @param String aStr
4063 */
4064 function toSetString(aStr) {
4065 return '$' + aStr;
4066 }
4067 exports.toSetString = toSetString;
4068
4069 function fromSetString(aStr) {
4070 return aStr.substr(1);
4071 }
4072 exports.fromSetString = fromSetString;
4073
4074 function strcmp(aStr1, aStr2) {
4075 var s1 = aStr1 || "";
4076 var s2 = aStr2 || "";
4077 return (s1 > s2) - (s1 < s2);
4078 }
4079
4080 /**
4081 * Comparator between two mappings where the original positions are compared.
4082 *
4083 * Optionally pass in `true` as `onlyCompareGenerated` to consider two
4084 * mappings with the same original source/line/column, but different generated
4085 * line and column the same. Useful when searching for a mapping with a
4086 * stubbed out mapping.
4087 */
4088 function compareByOriginalPositions(mappingA, mappingB, onlyCompareOriginal) {
4089 var cmp;
4090
4091 cmp = strcmp(mappingA.source, mappingB.source);
4092 if (cmp) {
4093 return cmp;
4094 }
4095
4096 cmp = mappingA.originalLine - mappingB.originalLine;
4097 if (cmp) {
4098 return cmp;
4099 }
4100
4101 cmp = mappingA.originalColumn - mappingB.originalColumn;
4102 if (cmp || onlyCompareOriginal) {
4103 return cmp;
4104 }
4105
4106 cmp = strcmp(mappingA.name, mappingB.name);
4107 if (cmp) {
4108 return cmp;
4109 }
4110
4111 cmp = mappingA.generatedLine - mappingB.generatedLine;
4112 if (cmp) {
4113 return cmp;
4114 }
4115
4116 return mappingA.generatedColumn - mappingB.generatedColumn;
4117 };
4118 exports.compareByOriginalPositions = compareByOriginalPositions;
4119
4120 /**
4121 * Comparator between two mappings where the generated positions are
4122 * compared.
4123 *
4124 * Optionally pass in `true` as `onlyCompareGenerated` to consider two
4125 * mappings with the same generated line and column, but different
4126 * source/name/original line and column the same. Useful when searching for a
4127 * mapping with a stubbed out mapping.
4128 */
4129 function compareByGeneratedPositions(mappingA, mappingB, onlyCompareGenerated) {
4130 var cmp;
4131
4132 cmp = mappingA.generatedLine - mappingB.generatedLine;
4133 if (cmp) {
4134 return cmp;
4135 }
4136
4137 cmp = mappingA.generatedColumn - mappingB.generatedColumn;
4138 if (cmp || onlyCompareGenerated) {
4139 return cmp;
4140 }
4141
4142 cmp = strcmp(mappingA.source, mappingB.source);
4143 if (cmp) {
4144 return cmp;
4145 }
4146
4147 cmp = mappingA.originalLine - mappingB.originalLine;
4148 if (cmp) {
4149 return cmp;
4150 }
4151
4152 cmp = mappingA.originalColumn - mappingB.originalColumn;
4153 if (cmp) {
4154 return cmp;
4155 }
4156
4157 return strcmp(mappingA.name, mappingB.name);
4158 };
4159 exports.compareByGeneratedPositions = compareByGeneratedPositions;
4160
4161 });
4162
4163 },{"amdefine":26}],26:[function(require,module,exports){
4164 (function (process,__filename){
4165 /** vim: et:ts=4:sw=4:sts=4
4166 * @license amdefine 1.0.0 Copyright (c) 2011-2015, The Dojo Foundation All Rights Reserved.
4167 * Available via the MIT or new BSD license.
4168 * see: http://github.com/jrburke/amdefine for details
4169 */
4170
4171 /*jslint node: true */
4172 /*global module, process */
4173 'use strict';
4174
4175 /**
4176 * Creates a define for node.
4177 * @param {Object} module the "module" object that is defined by Node for the
4178 * current module.
4179 * @param {Function} [requireFn]. Node's require function for the current module.
4180 * It only needs to be passed in Node versions before 0.5, when module.require
4181 * did not exist.
4182 * @returns {Function} a define function that is usable for the current node
4183 * module.
4184 */
4185 function amdefine(module, requireFn) {
4186 'use strict';
4187 var defineCache = {},
4188 loaderCache = {},
4189 alreadyCalled = false,
4190 path = require('path'),
4191 makeRequire, stringRequire;
4192
4193 /**
4194 * Trims the . and .. from an array of path segments.
4195 * It will keep a leading path segment if a .. will become
4196 * the first path segment, to help with module name lookups,
4197 * which act like paths, but can be remapped. But the end result,
4198 * all paths that use this function should look normalized.
4199 * NOTE: this method MODIFIES the input array.
4200 * @param {Array} ary the array of path segments.
4201 */
4202 function trimDots(ary) {
4203 var i, part;
4204 for (i = 0; ary[i]; i+= 1) {
4205 part = ary[i];
4206 if (part === '.') {
4207 ary.splice(i, 1);
4208 i -= 1;
4209 } else if (part === '..') {
4210 if (i === 1 && (ary[2] === '..' || ary[0] === '..')) {
4211 //End of the line. Keep at least one non-dot
4212 //path segment at the front so it can be mapped
4213 //correctly to disk. Otherwise, there is likely
4214 //no path mapping for a path starting with '..'.
4215 //This can still fail, but catches the most reasonable
4216 //uses of ..
4217 break;
4218 } else if (i > 0) {
4219 ary.splice(i - 1, 2);
4220 i -= 2;
4221 }
4222 }
4223 }
4224 }
4225
4226 function normalize(name, baseName) {
4227 var baseParts;
4228
4229 //Adjust any relative paths.
4230 if (name && name.charAt(0) === '.') {
4231 //If have a base name, try to normalize against it,
4232 //otherwise, assume it is a top-level require that will
4233 //be relative to baseUrl in the end.
4234 if (baseName) {
4235 baseParts = baseName.split('/');
4236 baseParts = baseParts.slice(0, baseParts.length - 1);
4237 baseParts = baseParts.concat(name.split('/'));
4238 trimDots(baseParts);
4239 name = baseParts.join('/');
4240 }
4241 }
4242
4243 return name;
4244 }
4245
4246 /**
4247 * Create the normalize() function passed to a loader plugin's
4248 * normalize method.
4249 */
4250 function makeNormalize(relName) {
4251 return function (name) {
4252 return normalize(name, relName);
4253 };
4254 }
4255
4256 function makeLoad(id) {
4257 function load(value) {
4258 loaderCache[id] = value;
4259 }
4260
4261 load.fromText = function (id, text) {
4262 //This one is difficult because the text can/probably uses
4263 //define, and any relative paths and requires should be relative
4264 //to that id was it would be found on disk. But this would require
4265 //bootstrapping a module/require fairly deeply from node core.
4266 //Not sure how best to go about that yet.
4267 throw new Error('amdefine does not implement load.fromText');
4268 };
4269
4270 return load;
4271 }
4272
4273 makeRequire = function (systemRequire, exports, module, relId) {
4274 function amdRequire(deps, callback) {
4275 if (typeof deps === 'string') {
4276 //Synchronous, single module require('')
4277 return stringRequire(systemRequire, exports, module, deps, relId);
4278 } else {
4279 //Array of dependencies with a callback.
4280
4281 //Convert the dependencies to modules.
4282 deps = deps.map(function (depName) {
4283 return stringRequire(systemRequire, exports, module, depName, relId);
4284 });
4285
4286 //Wait for next tick to call back the require call.
4287 if (callback) {
4288 process.nextTick(function () {
4289 callback.apply(null, deps);
4290 });
4291 }
4292 }
4293 }
4294
4295 amdRequire.toUrl = function (filePath) {
4296 if (filePath.indexOf('.') === 0) {
4297 return normalize(filePath, path.dirname(module.filename));
4298 } else {
4299 return filePath;
4300 }
4301 };
4302
4303 return amdRequire;
4304 };
4305
4306 //Favor explicit value, passed in if the module wants to support Node 0.4.
4307 requireFn = requireFn || function req() {
4308 return module.require.apply(module, arguments);
4309 };
4310
4311 function runFactory(id, deps, factory) {
4312 var r, e, m, result;
4313
4314 if (id) {
4315 e = loaderCache[id] = {};
4316 m = {
4317 id: id,
4318 uri: __filename,
4319 exports: e
4320 };
4321 r = makeRequire(requireFn, e, m, id);
4322 } else {
4323 //Only support one define call per file
4324 if (alreadyCalled) {
4325 throw new Error('amdefine with no module ID cannot be called more than once per file.');
4326 }
4327 alreadyCalled = true;
4328
4329 //Use the real variables from node
4330 //Use module.exports for exports, since
4331 //the exports in here is amdefine exports.
4332 e = module.exports;
4333 m = module;
4334 r = makeRequire(requireFn, e, m, module.id);
4335 }
4336
4337 //If there are dependencies, they are strings, so need
4338 //to convert them to dependency values.
4339 if (deps) {
4340 deps = deps.map(function (depName) {
4341 return r(depName);
4342 });
4343 }
4344
4345 //Call the factory with the right dependencies.
4346 if (typeof factory === 'function') {
4347 result = factory.apply(m.exports, deps);
4348 } else {
4349 result = factory;
4350 }
4351
4352 if (result !== undefined) {
4353 m.exports = result;
4354 if (id) {
4355 loaderCache[id] = m.exports;
4356 }
4357 }
4358 }
4359
4360 stringRequire = function (systemRequire, exports, module, id, relId) {
4361 //Split the ID by a ! so that
4362 var index = id.indexOf('!'),
4363 originalId = id,
4364 prefix, plugin;
4365
4366 if (index === -1) {
4367 id = normalize(id, relId);
4368
4369 //Straight module lookup. If it is one of the special dependencies,
4370 //deal with it, otherwise, delegate to node.
4371 if (id === 'require') {
4372 return makeRequire(systemRequire, exports, module, relId);
4373 } else if (id === 'exports') {
4374 return exports;
4375 } else if (id === 'module') {
4376 return module;
4377 } else if (loaderCache.hasOwnProperty(id)) {
4378 return loaderCache[id];
4379 } else if (defineCache[id]) {
4380 runFactory.apply(null, defineCache[id]);
4381 return loaderCache[id];
4382 } else {
4383 if(systemRequire) {
4384 return systemRequire(originalId);
4385 } else {
4386 throw new Error('No module with ID: ' + id);
4387 }
4388 }
4389 } else {
4390 //There is a plugin in play.
4391 prefix = id.substring(0, index);
4392 id = id.substring(index + 1, id.length);
4393
4394 plugin = stringRequire(systemRequire, exports, module, prefix, relId);
4395
4396 if (plugin.normalize) {
4397 id = plugin.normalize(id, makeNormalize(relId));
4398 } else {
4399 //Normalize the ID normally.
4400 id = normalize(id, relId);
4401 }
4402
4403 if (loaderCache[id]) {
4404 return loaderCache[id];
4405 } else {
4406 plugin.load(id, makeRequire(systemRequire, exports, module, relId), makeLoad(id), {});
4407
4408 return loaderCache[id];
4409 }
4410 }
4411 };
4412
4413 //Create a define function specific to the module asking for amdefine.
4414 function define(id, deps, factory) {
4415 if (Array.isArray(id)) {
4416 factory = deps;
4417 deps = id;
4418 id = undefined;
4419 } else if (typeof id !== 'string') {
4420 factory = id;
4421 id = deps = undefined;
4422 }
4423
4424 if (deps && !Array.isArray(deps)) {
4425 factory = deps;
4426 deps = undefined;
4427 }
4428
4429 if (!deps) {
4430 deps = ['require', 'exports', 'module'];
4431 }
4432
4433 //Set up properties for this module. If an ID, then use
4434 //internal cache. If no ID, then use the external variables
4435 //for this node module.
4436 if (id) {
4437 //Put the module in deep freeze until there is a
4438 //require call for it.
4439 defineCache[id] = [id, deps, factory];
4440 } else {
4441 runFactory(id, deps, factory);
4442 }
4443 }
4444
4445 //define.require, which has access to all the values in the
4446 //cache. Useful for AMD modules that all have IDs in the file,
4447 //but need to finally export a value to node based on one of those
4448 //IDs.
4449 define.require = function (id) {
4450 if (loaderCache[id]) {
4451 return loaderCache[id];
4452 }
4453
4454 if (defineCache[id]) {
4455 runFactory.apply(null, defineCache[id]);
4456 return loaderCache[id];
4457 }
4458 };
4459
4460 define.amd = {};
4461
4462 return define;
4463 }
4464
4465 module.exports = amdefine;
4466
4467 }).call(this,require('_process'),"/node_modules/css/node_modules/source-map/node_modules/amdefine/amdefine.js")
4468 },{"_process":3,"path":2}],27:[function(require,module,exports){
4469 // Copyright 2014 Simon Lydell
4470 // X11 (“MIT”) Licensed. (See LICENSE.)
4471
4472 var path = require("path")
4473
4474 "use strict"
4475
4476 function urix(aPath) {
4477 if (path.sep === "\\") {
4478 return aPath
4479 .replace(/\\/g, "/")
4480 .replace(/^[a-z]:\/?/i, "/")
4481 }
4482 return aPath
4483 }
4484
4485 module.exports = urix
4486
4487 },{"path":2}]},{},[4]);
4488